The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 17:00 UTC
feat(mobile): mobile:install --session installs into an agent-device session
For devices opened elsewhere (a device pool, cloud, or remote host), install the cached dev client for this checkout's fingerprint through the caller's agent-device session, from the caller's workspace (agent-device scopes session ownership to it). It never builds; without a shared build it names the next step. --abi picks the Android build, --metro opens it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 25, 2026 at 18:27 UTC
d9abfdd1cb595d186391ed5a28000554d425b5fc
3 files changed
+127
-2
.agents/skills/test-t3-mobile/SKILL.md
+6
@@ -41,6 +41,12 @@ names). The device id may be omitted when exactly one device is booted. It
41
prints one JSON line; on failure it names the next command. Authorized mobile
42
verification includes that step unless the user prohibits it.
43
44
+For a device you opened in an agent-device session elsewhere (a device pool,
45
+cloud, or remote host), run `vp run mobile:install <ios|android> --session <s>`
46
+from the directory you opened the session in. It installs the cached build into
47
+that session (`--abi arm64-v8a` for an ARM Android device; `--metro <url>` also
48
+opens it against Metro) and never builds.
49
+
50
Start `vp run dev:client` from `apps/mobile`, or reuse a healthy Metro belonging
51
to this checkout. Open its printed development-client URL with AgentDevice
52
`open com.t3tools.t3code.dev <url>` and all returned target arguments.
apps/mobile/README.md
+5
@@ -41,6 +41,11 @@ log file it prints (`T3_NATIVE_CLIENT_VERBOSE=1` streams it instead). Builds are
41
your task-cache login (`bash infra/task-cache/install.sh`) can write. `T3_NATIVE_CLIENT_CACHE=read`
42
skips the upload and `off` skips the shared cache. Physical iPhones still use `vp run ios:dev`.
43
44
+`--session <name>` installs into an agent-device session opened elsewhere, such as a device pool
45
+or a cloud simulator, instead of a local device: `vp run mobile:install android --session pool-1
46
+--metro http://<this-machine>:8081`. It uses only the cached build (x86_64 by default; `--abi`
47
+for ARM) and fails with the next step when no machine has built this fingerprint yet.
48
+
49
For a read-only decision, run `node ../../scripts/mobile-native-client.ts check <ios|android>
50
[device]`: exit 0 means compatible, 2 means an install is needed, and 1 means an operational error.
51
An externally installed client is unverified until the helper installs it once.
scripts/mobile-native-client.ts
+116
-2
@@ -14,7 +14,7 @@ import * as Path from "effect/Path";
14
import * as Random from "effect/Random";
15
import * as Schema from "effect/Schema";
16
import * as Stream from "effect/Stream";
17
-import { Argument, Command } from "effect/cli";
17
+import { Argument, Command, Flag } from "effect/cli";
18
import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
19
import { ChildProcess, ChildProcessSpawner } from "effect/process";
20
@@ -710,6 +710,7 @@ export const resolveArtifact = Effect.fn("nativeClient.resolveArtifact")(functio
710
platform: NativePlatform,
711
abi: string | null,
712
fingerprint: string,
713
+ allowBuild = true,
714
) {
715
const fs = yield* FileSystem.FileSystem;
716
const path = yield* Path.Path;
@@ -738,6 +739,10 @@ export const resolveArtifact = Effect.fn("nativeClient.resolveArtifact")(functio
739
return { ...artifact, source: "remote" as const, buildMs: yield* readBuildMs(directory) };
740
}
741
}
742
+ if (!allowBuild)
743
+ return yield* new NativeClientError({
744
+ message: `No shared build of ${key} yet. Run \`vp run mobile:install ${platform}\` once on a machine with a local ${platform === "ios" ? "simulator" : "emulator"} of this checkout; it builds the client and shares it.`,
745
+ });
746
const log = yield* BuildLog;
747
yield* Console.error(
748
`No cached client for ${key}. Building it once for every machine (5-15 min)${log ? `. Log: ${log}` : ""}`,
@@ -830,15 +835,124 @@ const reportTelemetry = Effect.fn("nativeClient.reportTelemetry")(
835
(effect) => effect.pipe(Effect.timeout("5 seconds"), Effect.ignore),
836
);
837
838
+/**
839
+ * Install into an agent-device session the caller already opened (a device pool, a cloud
840
+ * provider, or a local device), using the shared cache only; such hosts cannot build.
841
+ */
842
+const installIntoSession = Effect.fn("nativeClient.installIntoSession")(function* (
843
+ home: string,
844
+ platform: NativePlatform,
845
+ session: string,
846
+ abi: string,
847
+ metro: string | undefined,
848
+) {
849
+ const started = yield* Clock.currentTimeMillis;
850
+ const path = yield* Path.Path;
851
+ const node = yield* HostProcess.ExecutablePath;
852
+ const agentDevice = path.join(
853
+ (yield* roots).repo,
854
+ "scripts/node_modules/agent-device/bin/agent-device.mjs",
855
+ );
856
+ // agent-device scopes session ownership to the workspace (working directory) it runs in.
857
+ const workspace = yield* HostProcess.WorkingDirectory;
858
+ const deviceAbi = platform === "android" ? abi : null;
859
+ const task = deviceAbi ? `native-client:android-${deviceAbi}` : `native-client:${platform}`;
860
+ const current = yield* fingerprint(platform);
861
+ const artifact = yield* resolveArtifact(home, platform, deviceAbi, current, false).pipe(
862
+ Effect.tapError(() => reportTelemetry(home, task, "failed", 0)),
863
+ );
864
+ yield* Console.error(`Installing into agent-device session ${session}...`);
865
+ yield* command(
866
+ node,
867
+ [agentDevice, "install", bundleId, artifact.file, "--session", session],
868
+ true,
869
+ workspace,
870
+ );
871
+ if (metro) {
872
+ const url = encodeURIComponent(metro);
873
+ yield* command(
874
+ node,
875
+ [
876
+ agentDevice,
877
+ "open",
878
+ bundleId,
879
+ `t3code-dev://expo-development-client/?url=${url}&disableOnboarding=1&disableFab=1&disableAutoLaunch=1`,
880
+ "--session",
881
+ session,
882
+ ],
883
+ true,
884
+ workspace,
885
+ );
886
+ }
887
+ yield* reportTelemetry(
888
+ home,
889
+ task,
890
+ artifact.source === "build" ? "executed" : artifact.source,
891
+ artifact.buildMs,
892
+ );
893
+ const seconds = Math.round(((yield* Clock.currentTimeMillis) - started) / 1000);
894
+ yield* Console.error(
895
+ `Installed into session ${session} in ${seconds}s (${artifact.source}).${metro ? "" : " Open it with Metro: --metro http://<this-machine>:8081."}`,
896
+ );
897
+ yield* Console.log(
898
+ yield* encodeOutput({
899
+ status: "installed",
900
+ source: artifact.source,
901
+ fingerprint: current,
902
+ session,
903
+ seconds,
904
+ }),
905
+ );
906
+});
907
+
908
const main = Command.make(
909
"mobile-native-client",
910
{
911
mode: Argument.Literals("mode", ["check", "ensure"]),
912
platform: Argument.Literals("platform", ["ios", "android"]),
913
device: Argument.String("device").pipe(Argument.optional),
914
+ session: Flag.String("session").pipe(
915
+ Flag.withDescription(
916
+ "Install into this already-open agent-device session (a device pool, cloud, or remote host) instead of a local device.",
917
+ ),
918
+ Flag.optional,
919
+ ),
920
+ abi: Flag.Literals("abi", ["x86_64", "arm64-v8a"]).pipe(
921
+ Flag.withDescription("Android ABI of the session's device (default x86_64)."),
922
+ Flag.withDefault("x86_64" as const),
923
+ ),
924
+ metro: Flag.String("metro").pipe(
925
+ Flag.withDescription("With --session, open the dev client against this Metro URL."),
926
+ Flag.optional,
927
+ ),
928
},
840
- Effect.fn("nativeClient.main")(function* ({ mode, platform, device: requested }) {
929
+ Effect.fn("nativeClient.main")(function* ({
930
+ mode,
931
+ platform,
932
+ device: requested,
933
+ session,
934
+ abi: sessionAbi,
935
+ metro,
936
+ }) {
937
const started = yield* Clock.currentTimeMillis;
938
+ if (Option.isSome(session)) {
939
+ if (mode !== "ensure" || Option.isSome(requested))
940
+ return yield* new NativeClientError({
941
+ message:
942
+ "--session installs into an agent-device session; use it with ensure and no device id.",
943
+ });
944
+ const environment = yield* HostProcess.Environment;
945
+ const home = environment.HOME ?? environment.USERPROFILE;
946
+ if (!home)
947
+ return yield* new NativeClientError({ message: "HOME or USERPROFILE must be set." });
948
+ return yield* installIntoSession(
949
+ home,
950
+ platform,
951
+ session.value,
952
+ sessionAbi,
953
+ Option.getOrUndefined(metro),
954
+ );
955
+ }
956
const target = yield* resolveDevice(platform, Option.getOrUndefined(requested));
957
const device = target.id;
958
yield* Console.error(`Device: ${target.label} (${device})`);