Skip to content

Commit d05cfc7

Browse files
authored
feat: manage web backend setup (#833)
1 parent 73dc7f8 commit d05cfc7

20 files changed

Lines changed: 669 additions & 121 deletions

.github/actions/setup-node-pnpm/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inputs:
55
node-version:
66
description: 'Node.js version'
77
required: false
8-
default: '22.19'
8+
default: '24.13'
99
pnpm-version:
1010
description: 'pnpm version'
1111
required: false

.github/workflows/publish-mcp-registry.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Setup Node.js
3434
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
3535
with:
36-
node-version: "22"
36+
node-version: '24.13'
3737

3838
- name: Resolve release metadata
3939
id: meta

.github/workflows/release-android-snapshot-helper.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Setup Node.js
3333
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
3434
with:
35-
node-version: "22"
35+
node-version: '24.13'
3636

3737
- name: Install Android SDK packages
3838
run: |

.github/workflows/release-ios-runner.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
env:
2727
AGENT_DEVICE_XCUITEST_PLATFORM: ios
2828
AGENT_DEVICE_XCUITEST_DESTINATION: generic/platform=iOS Simulator
29-
AGENT_DEVICE_IOS_CLEAN_DERIVED: "1"
29+
AGENT_DEVICE_IOS_CLEAN_DERIVED: '1'
3030
steps:
3131
- name: Checkout
3232
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -36,7 +36,7 @@ jobs:
3636
- name: Setup Node.js
3737
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
3838
with:
39-
node-version: "22"
39+
node-version: '24.13'
4040

4141
- name: Resolve release metadata
4242
id: meta

docs/agents/domain.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ Before architecture, diagnosis, TDD, triage, PRD, or roadmap work, read:
77
- `CONTEXT.md` for domain vocabulary, test strategy terms, and architecture language.
88
- Relevant ADRs in `docs/adr/` for accepted architecture decisions.
99
- This `docs/agents/` directory for issue-tracker and triage-label conventions.
10+
- `docs/agents/web-backend.md` before changing web automation backend setup or diagnostics.
1011

1112
Use the vocabulary from `CONTEXT.md` in issue titles, refactor proposals, test names, and architecture notes. If a proposed change contradicts an ADR, call that out explicitly and explain why the decision should be reopened.

docs/agents/web-backend.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Web Backend
2+
3+
Web automation uses a managed `agent-browser` backend as an implementation detail.
4+
5+
- Runtime web commands resolve the backend only from the state-dir managed install at `tools/agent-browser/<version>`.
6+
- Normal `--platform web` commands do not install the managed backend on first use. If the backend is missing, they fail with a setup hint.
7+
- Use `agent-device web setup` before first web automation and in CI/sandbox bootstrap steps.
8+
- Use `agent-device web doctor` to run the backend health check.
9+
- The managed install respects `--state-dir` / `AGENT_DEVICE_STATE_DIR`.
10+
- Web automation requires Node 24+ while the rest of agent-device keeps its Node 22 baseline.
11+
12+
Default first-run flow:
13+
14+
```sh
15+
agent-device web setup
16+
agent-device open "https://example.com" --platform web
17+
agent-device snapshot -i --platform web
18+
agent-device close --platform web
19+
```
20+
21+
Do not document direct `agent-browser` commands as agent-device features. Browser-specific network,
22+
CDP, React web, tabs, downloads, auth vaults, and profiling stay out of the minimal web surface until
23+
there is an explicit agent-device command design for them.

src/cli.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
import { materializeRemoteConnectionForCommand } from './cli/commands/connection-runtime.ts';
1515
import { tryRunClientBackedCommand } from './cli/commands/router.ts';
1616
import { runReactDevtoolsCommand } from './cli/commands/react-devtools.ts';
17+
import { runWebCommand } from './cli/commands/web.ts';
1718
import { readCliBatchStepsJson } from './cli/batch-steps.ts';
1819
import {
1920
createRequestId,
@@ -205,6 +206,14 @@ export async function runCli(argv: string[], deps: CliDeps = DEFAULT_CLI_DEPS):
205206
process.exit(exitCode);
206207
return;
207208
}
209+
if (command === 'web') {
210+
const exitCode = await runWebCommand(positionals, {
211+
flags: effectiveFlags,
212+
stateDir: daemonPaths.baseDir,
213+
});
214+
process.exit(exitCode);
215+
return;
216+
}
208217
maybeRunUpgradeNotifier({
209218
command,
210219
currentVersion: version,

src/cli/commands/web.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import {
2+
doctorManagedAgentBrowser,
3+
setupManagedAgentBrowser,
4+
} from '../../platforms/web/agent-browser-tool.ts';
5+
import { AppError } from '../../utils/errors.ts';
6+
import type { CliFlags } from '../../utils/cli-flags.ts';
7+
import { printJson } from '../../utils/output.ts';
8+
9+
export async function runWebCommand(
10+
positionals: string[],
11+
options: { flags: CliFlags; stateDir: string },
12+
): Promise<number> {
13+
const action = positionals[0];
14+
switch (action) {
15+
case 'setup': {
16+
const status = await setupManagedAgentBrowser({
17+
stateDir: options.stateDir,
18+
});
19+
printWebResult(options.flags.json, 'Managed web backend installed.', { status });
20+
return 0;
21+
}
22+
case 'doctor': {
23+
const result = await doctorManagedAgentBrowser({
24+
stateDir: options.stateDir,
25+
});
26+
printWebResult(
27+
options.flags.json,
28+
result.exitCode === 0 ? 'Web backend is healthy.' : 'Web backend doctor reported issues.',
29+
result,
30+
);
31+
return result.exitCode;
32+
}
33+
default:
34+
throw new AppError('INVALID_ARGS', 'web requires setup or doctor');
35+
}
36+
}
37+
38+
function printWebResult(json: boolean | undefined, message: string, data: Record<string, unknown>) {
39+
if (json) {
40+
printJson({ success: true, data });
41+
return;
42+
}
43+
process.stdout.write(`${message}\n`);
44+
}

src/command-catalog.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const LOCAL_CLI_COMMANDS = {
6767
metro: 'metro',
6868
reactDevtools: 'react-devtools',
6969
session: 'session',
70+
web: 'web',
7071
} as const;
7172

7273
export const GESTURE_KINDS = ['pan', 'fling', 'swipe', 'pinch', 'rotate', 'transform'] as const;
@@ -89,6 +90,7 @@ const MCP_UNEXPOSED_CLI_COMMANDS = commandSet(
8990
LOCAL_CLI_COMMANDS.disconnect,
9091
LOCAL_CLI_COMMANDS.mcp,
9192
LOCAL_CLI_COMMANDS.reactDevtools,
93+
LOCAL_CLI_COMMANDS.web,
9294
PUBLIC_COMMANDS.prepare,
9395
);
9496

@@ -102,6 +104,7 @@ const CAPABILITY_EXEMPT_CLI_COMMANDS = commandSet(
102104
LOCAL_CLI_COMMANDS.metro,
103105
LOCAL_CLI_COMMANDS.reactDevtools,
104106
LOCAL_CLI_COMMANDS.session,
107+
LOCAL_CLI_COMMANDS.web,
105108
PUBLIC_COMMANDS.appState,
106109
PUBLIC_COMMANDS.prepare,
107110
PUBLIC_COMMANDS.batch,

src/daemon-runtime.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export async function startDaemonRuntime(
8383

8484
const handleRequest = createRequestHandler({
8585
logPath,
86+
stateDir: baseDir,
8687
token,
8788
sessionStore,
8889
leaseRegistry,

0 commit comments

Comments
 (0)