Conversation
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 80dd64f5c9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| snapshotScope: options?.scope, | ||
| snapshotDepth: options?.depth, | ||
| snapshotRaw: options?.raw, |
There was a problem hiding this comment.
Preserve selector snapshot flags in runtime capture
The selector runtime now overwrites snapshotScope, snapshotDepth, and snapshotRaw with values from options, but for get/is/wait (and read-only find in most paths) those fields are usually undefined. Because this assignment happens after spreading req.flags, user-provided CLI flags like --snapshot-depth and --snapshot-raw are silently dropped, changing selector resolution behavior versus the previous handler path. Only override these fields when an explicit runtime option is provided.
Useful? React with 👍 / 👎.
| function cloneSessionRecord( | ||
| record: CommandSessionRecord | undefined, | ||
| ): CommandSessionRecord | undefined { | ||
| return record ? { ...record } : undefined; |
There was a problem hiding this comment.
Deep-clone session records returned by memory store
The in-memory session store returns a shallow copy of a session record, so nested objects (notably snapshot) are still shared with internal state. If a caller mutates record.snapshot.nodes after get, it mutates the store’s baseline in place, which can corrupt later diff/get/is behavior and defeats the “no mutable references” contract implied by this helper. Clone nested session fields (at least snapshot/metadata) before returning.
Useful? React with 👍 / 👎.
278e890 to
5c88f98
Compare
Summary
Introduce
agent-deviceas a reusable command runtime instead of a collection of helper exports. The CLI and daemon keep their existing behavior, while command semantics now have a public JS boundary that can run against local or hosted backend adapters.This PR adds the runtime/backend/io split, migrates the first command families into it, and keeps compatibility subpaths available while the remaining command inventory is migrated.
Scope: 69 files touched across the runtime public boundary, migrated capture/selector/interaction slices, tests/docs, and one Android replay hardening change.
New JS API
Root runtime entrypoint:
Router entrypoint for transport adapters:
New public subpaths:
agent-device/commands: implemented command APIs, selector helpers, command router, command catalogagent-device/backend: backend primitive and capability interfacesagent-device/io: file refs, artifact descriptors, output reservation, temp file contractsagent-device/testing/conformance: backend conformance suites for migrated command familiescreateAgentDeviceClient()remains the daemon RPC client.createAgentDevice()is the in-process runtime.Key Changes
createAgentDevice()with explicitbackend,artifacts,sessions,policy,diagnostics,clock, andsignalruntime dependencies.{ kind: 'path' }and{ kind: 'uploadedArtifact' }{ kind: 'path' }and{ kind: 'downloadableArtifact' }localPath/artifactdescriptorslocalCommandPolicy()andrestrictedCommandPolicy()so local filesystem behavior is explicit and service-safe defaults are available.createMemorySessionStore()with defensive cloning for snapshots and metadata.rootDircontainment forcreateLocalArtifactAdapter()explicit local paths.CommandSessionStoreimplementations must serialize per-session updates when used concurrently.createAgentDevice(); planned commands live incommandCatalograther than autocomplete-only throwing methods.depth,scope,raw) through the public runtime API and daemon bridge.diff screenshot, and the CLI client bridge.label=Notificationsselector.Migrated Runtime Commands
Capture:
capture.screenshotcapture.diffScreenshotcapture.snapshotcapture.diffSnapshotSelectors:
selectors.findselectors.getselectors.getTextselectors.getAttrsselectors.isselectors.isVisibleselectors.isHiddenselectors.waitselectors.waitForTextInteractions:
interactions.clickinteractions.pressinteractions.fillinteractions.typeTextThe daemon and CLI paths now route these slices through the runtime while preserving existing daemon-shaped responses, selector recording, snapshot flag behavior, macOS surface guards, stale-ref refresh, Android escape handling, recording metadata, and screenshot cleanup semantics.
Follow-ups
Remaining command families are tracked in
COMMAND_OWNERSHIP.md. Compatibility helper subpaths stay available for now and are documented as migration-era APIs rather than the preferred public boundary.Validation
pnpm formatpnpm checkpnpm test:integrationnode --test test/integration/installed-package-metro.test.tspnpm test:unit src/__tests__/cli-client-commands.test.ts src/__tests__/runtime-snapshot.test.tspnpm test:unit src/__tests__/runtime-selector-read.test.ts src/__tests__/runtime-interactions.test.ts src/__tests__/runtime-diff-screenshot.test.ts src/__tests__/runtime-snapshot.test.ts src/__tests__/runtime-public.test.ts src/daemon/handlers/__tests__/interaction.test.tspnpm test:replay:ios(6 passed, 0 failed)pnpm test:replay:android(6 passed, 0 failed after hardening the stale Android Settings replay ref)pnpm check:quickpnpm check:unitpnpm check:toolingpnpm test:unit src/daemon/handlers/__tests__/find.test.ts src/__tests__/runtime-snapshot.test.ts src/__tests__/runtime-public.test.tspnpm test:unit src/__tests__/cli-batch.test.ts src/__tests__/cli-diagnostics.test.tsgit diff --check