diff --git a/.device-evidence/CHECKLIST.md b/.device-evidence/CHECKLIST.md index 4dc48e688f..b708fc77b8 100644 --- a/.device-evidence/CHECKLIST.md +++ b/.device-evidence/CHECKLIST.md @@ -99,9 +99,11 @@ appended warning: ### Proof the review asked for on this lane The false-attribution class is covered by unit tests rather than a device run, because the device -cannot show a cache hit on command: `src/daemon/__tests__/capture-disclosure-target-activation.test.ts` -pins that a cache-reused tree discloses nothing, and -`src/daemon/interaction/internal/__tests__/interaction-target-activation-disclosure.test.ts` pins that +cannot show a cache hit on command: `packages/daemon/src/execution/__tests__/selector-capture-runtime.test.ts` +drives a session-snapshot cache hit and pins that the consumed tree earns no repair proof and +discloses nothing, `packages/daemon/src/core/__tests__/capture-disclosure-target-activation.test.ts` +pins that the response builder never borrows a repair the stored snapshot happens to carry, and +`src/__tests__/daemon-composition/interaction/interaction-capture-disclosure.test.ts` pins that a press which consumed no capture is not disclosed against an older tree. ## Why the live activation lane is manual diff --git a/.fallowrc.json b/.fallowrc.json index f41e7f33e9..bcfd201c6f 100644 --- a/.fallowrc.json +++ b/.fallowrc.json @@ -29,9 +29,6 @@ "scripts/patch-xcuitest-runner-icon.ts", "scripts/write-xcuitest-cache-metadata.ts", "scripts/xcuitest-build-settings.ts", - // The 11a-4 residue scan runs by hand (and from CI prose until R11 in #3546 owns - // the rule); nothing in the dependency graph imports it. - "scripts/daemon-edge-residue-scan.mjs", "packages/capture-kit/src/ios-snapshot-engine/replay.ts", // #1596 regression fixture: runs as a real `node --experimental-strip-types` // subprocess (test/integration/daemon-replace-exit-flush.test.ts), so @@ -68,7 +65,7 @@ "scripts/help-conformance-sample-outputs.d.mts", "scripts/help-conformance-runner-output.d.mts" ], - "dynamicallyLoaded": ["src/daemon/interaction/index.ts"], + "dynamicallyLoaded": ["packages/daemon/src/execution/interaction/index.ts"], "ignoreDependencies": [ "@theme", // @agent-device/maestro owns the source import, while the published root @@ -158,19 +155,23 @@ }, { // Daemon route handlers are reached only through the dynamic `import()` table in request-handler-chain.ts, which --production analysis cannot follow to a consumer. - "file": "src/daemon/handlers/{human-control,lease,session,snapshot,react-native,record-trace}.ts", + "file": "packages/daemon/src/sessions/handlers/{human-control,lease,session,snapshot,record-trace}.ts", "exports": [ "handleHumanControlCommand", "handleLeaseCommands", "handleSessionCommands", "handleSnapshotCommands", - "handleReactNativeCommands", "handleRecordTraceCommands" ] }, + { + // The react-native route handler lives in the execution layer with its mechanics; same dynamic-loader exemption as the sessions-side route handlers above. + "file": "packages/daemon/src/execution/handlers/react-native.ts", + "exports": ["handleReactNativeCommands"] + }, { // The interaction facade exposes #2178's deferred route handlers plus the existing ref mutation response consumed by help conformance. Fallow's production graph cannot follow the request-handler-chain dynamic imports, so this exact list is the facade contract. - "file": "src/daemon/interaction/index.ts", + "file": "packages/daemon/src/execution/interaction/index.ts", "exports": ["refMutationAdmissionResponse", "handleFindCommands", "handleInteractionCommands"] }, { @@ -243,7 +244,7 @@ "exports": ["IS_PREDICATE_USAGE_HINT"] }, { - // Workspace-package symbols whose only consumers are test-tree files, which --production analysis does not see. Each import is the package specifier, so the façade entry is load-bearing: parseTargetAnnotationV1Payload from src/daemon/__tests__/session-target-evidence.test.ts, MAESTRO_COMPAT_* from src/cli/parser/__tests__/maestro-support-matrix.test.ts, SCRIPT_FLAG_COMMANDS/scriptFlagEntries from src/commands/replay/script-flag-admission.test.ts (the #3197 two-way drift guard between the .ad grammar and the CLI schema). + // Workspace-package symbols whose only consumers are test-tree files, which --production analysis does not see. Each import is the package specifier, so the façade entry is load-bearing: parseTargetAnnotationV1Payload from packages/selectors/src/target-evidence.test.ts, MAESTRO_COMPAT_* from src/cli/parser/__tests__/maestro-support-matrix.test.ts, SCRIPT_FLAG_COMMANDS/scriptFlagEntries from src/commands/replay/script-flag-admission.test.ts (the #3197 two-way drift guard between the .ad grammar and the CLI schema). "file": "packages/{ad-script,maestro,capture-kit}/src/index.ts", "exports": [ "parseTargetAnnotationV1Payload", @@ -254,7 +255,7 @@ ] }, { - // src/daemon/__tests__/request-runtime-binding.test.ts drives the daemon's exact bind through the recovery authority, whose cancellation race is what rejects; production reaches it only through finishRecoveredDurableCapture and recoverDurableCaptureResource in the same package. + // packages/daemon/src/core/__tests__/request-runtime-binding.test.ts drives the daemon's exact bind through the recovery authority, whose cancellation race is what rejects; production reaches it only through finishRecoveredDurableCapture and recoverDurableCaptureResource in the same package. "file": "packages/capture-kit/src/durable-capture/index.ts", "exports": ["acquireDurableCaptureRecoveryAuthorityBeforeDeadline"] }, diff --git a/AGENTS.md b/AGENTS.md index d0b0631dde..3ff131c658 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -49,11 +49,11 @@ Read the declaration rather than maintaining a prose copy: - commands and their surface, runtime-use, batch, and timeout traits: `packages/command-registry/src/registry.ts` -- daemon route ownership and request-policy traits: `src/daemon/daemon-command-registry.ts` +- daemon route ownership and request-policy traits: `packages/daemon/src/core/daemon-command-registry.ts` - interaction paths and guarantees: `packages/contracts/src/interaction-guarantees.ts` - canonical command names: `packages/command-registry/src/catalog.ts` - device runtime-use declarations and fact admission: - `packages/command-registry/src/registry.ts`, `src/daemon/runtime-admission.ts`, and + `packages/command-registry/src/registry.ts`, `packages/daemon/src/core/runtime-admission.ts`, and `src/platform-runtime-gateway.ts` - common command input fields, and which surface may write an input key (model, operator, retired): `src/commands/common-input-fields.ts` and `src/commands/input-audience.ts` @@ -110,7 +110,7 @@ under `contracts/fixtures/`. ## Runtime and diagnostics seams Diagnostics use `@agent-device/host-kit/diagnostics`. Request diagnostics belong in the session request log; -session artifact paths come from `src/daemon/session-artifact-paths.ts`. App/device logs remain in `app.log`; +session artifact paths come from `packages/daemon/src/core/session-artifact-paths.ts`. App/device logs remain in `app.log`; Apple runner and xcodebuild output remains in `runner.log`. Normalize failures with `normalizeError` and preserve `hint`, `diagnosticId`, `logPath`, and typed diff --git a/docs/adr/0003-daemon-command-registry.md b/docs/adr/0003-daemon-command-registry.md index db927c1a3f..4d24859c03 100644 --- a/docs/adr/0003-daemon-command-registry.md +++ b/docs/adr/0003-daemon-command-registry.md @@ -21,7 +21,7 @@ to public command identity, and it required duplicate command sets to stay align Keep public command identity in `src/command-catalog.ts` and public input/output contracts in `src/commands/**`. -Add `src/daemon/daemon-command-registry.ts` as the daemon-side source of truth for command route +Add `packages/daemon/src/core/daemon-command-registry.ts` as the daemon-side source of truth for command route ownership and daemon request-policy traits. Request modules consume predicate functions from the registry instead of recreating command string sets. Handler modules own execution logic only; they do not export duplicate coverage tables to prove route membership. @@ -67,7 +67,7 @@ exposed through named predicates — a property that survives a projected/derive derived daemon registry is therefore permitted **only if** it preserves all of the following invariants: 1. **Daemon-owned declaration.** Route and request-policy traits are declared in a daemon-owned facet - (under `src/daemon/`) and *composed* into the registration — never inlined as fields on the public + (under `packages/daemon/src/`) and *composed* into the registration — never inlined as fields on the public command contract in `src/commands/**` or `src/command-catalog.ts`. Co-locating a registration *call* is fine; co-locating *ownership* of daemon policy in the public surface is the contamination this ADR rejected (see Alternatives, "Keep daemon groups in `src/command-catalog.ts`"). @@ -85,5 +85,5 @@ derived daemon registry is therefore permitted **only if** it preserves all of t A single flat public descriptor whose daemon fields leak into public views is **not** permitted — that is the "collapse daemon policy into a public command registry" failure this ADR exists to prevent. Compose facets owned by their domains; derive the registry from them. Until that derivation lands and is pinned -by the registry tests, the hand-authored `src/daemon/daemon-command-registry.ts` remains the source of +by the registry tests, the hand-authored `packages/daemon/src/core/daemon-command-registry.ts` remains the source of truth and the operating rule in `AGENTS.md` is unchanged. diff --git a/docs/adr/0004-ios-snapshot-backend-strategy.md b/docs/adr/0004-ios-snapshot-backend-strategy.md index 81e31875ef..9657ecd3d1 100644 --- a/docs/adr/0004-ios-snapshot-backend-strategy.md +++ b/docs/adr/0004-ios-snapshot-backend-strategy.md @@ -115,7 +115,7 @@ facet in `@agent-device/capture-kit` owns snapshot policy generally rather than stated as a duration budget; the loop derives the deadline from the window's `markedAt` itself, so the budget is always spent from the action and a caller has no absolute instant it could get wrong. - `src/daemon/session-snapshot-freshness.ts` keeps only what needs a session: reading and retiring + `packages/daemon/src/core/session-snapshot-freshness.ts` keeps only what needs a session: reading and retiring the window on store-owned `SessionState`, and choosing the comparison baseline from snapshot lineage. It remains the declared R7 owner of `androidSnapshotFreshness`. - **Timeout evidence.** Whether a capture failed because the hierarchy never arrived is decided @@ -145,12 +145,12 @@ facet in `@agent-device/capture-kit` owns snapshot policy generally rather than `scripts/layering/snapshot-presentation-boundary.test.ts` enforces the direction, but only across the roots `snapshot-policy` declares in `scripts/layering/architecture-ownership.ts`: nothing in -that snapshot tree may import `src/daemon/`, while the overlay modules beside the tree sit outside +that snapshot tree may import `packages/daemon/src/`, while the overlay modules beside the tree sit outside those roots and are outside that gate. It carries a positive control, because a filter that stopped matching would look identical to a boundary being obeyed. The residual call sites #1983 also named are audited and deliberately left in place. -`src/daemon/direct-ios-selector.ts` carries no presentation policy: `isLocalIosRunnerSession` and +`packages/daemon/src/core/direct-ios-selector.ts` carries no presentation policy: `isLocalIosRunnerSession` and `readSimpleIosSelectorTarget` are session routing (device family, provider ownership, the stabilization window), while `deriveDirectIosNodeSelector` and `isDirectIosSelectorFallbackError` are selector derivation and ADR 0011 delegation-on-error. The latter two are pure and diff --git a/docs/adr/0008-command-descriptor-registry.md b/docs/adr/0008-command-descriptor-registry.md index 241cca57f9..25bfeeec96 100644 --- a/docs/adr/0008-command-descriptor-registry.md +++ b/docs/adr/0008-command-descriptor-registry.md @@ -24,7 +24,7 @@ Accepted A command's identity is restated, by hand, across roughly ten tables that must stay aligned by convention: `PUBLIC_COMMANDS` (`src/command-catalog.ts`), the per-command metadata and family facets (`src/commands/**`), the capability matrix (`src/core/capabilities.ts`), the daemon command registry -(`src/daemon/daemon-command-registry.ts`, ADR 0003), the structured-batch allowlist +(`packages/daemon/src/core/daemon-command-registry.ts`, ADR 0003), the structured-batch allowlist (`src/batch-policy.ts`), the MCP exposure sets, the Node client interface and impl (`src/client-types.ts`, `src/client.ts`), and the generic-dispatch `switch` (`src/core/dispatch.ts`, whose `default: throw` makes a missing or renamed command a runtime error, not a compile error). Adding one command touches ~24 files, the diff --git a/docs/adr/0012-interactive-replay.md b/docs/adr/0012-interactive-replay.md index 741f33dda4..5eb3256398 100644 --- a/docs/adr/0012-interactive-replay.md +++ b/docs/adr/0012-interactive-replay.md @@ -730,7 +730,7 @@ path — no text editing, no silent similarity-heal. **Core mechanism — the healed script IS `session.actions`.** No new splice engine. `session.actions` already accumulates every executed action for the session's lifetime -(`src/daemon/session-action-recorder.ts:37`, unconditional push), and the divergence refusal is +(`packages/daemon/src/core/session-action-recorder.ts:92`, unconditional push), and the divergence refusal is pre-dispatch (target verification refuses before the device action, decision 3), so a divergent step is never pushed. Across a repair session: original steps that verified and dispatched land in `session.actions`; the divergent step is absent (refused pre-dispatch, never recorded); the agent's @@ -766,13 +766,13 @@ works" and "healed scripts are always valid": steps are re-executed during the repair replay; only if recording is armed from the start do they land in `session.actions` with fresh `target-v1` evidence. Arming late yields a hybrid healed script (an annotated corrective step glued to a bare, unannotated prefix) that re-diverges on its own next replay - (`src/daemon/interaction/internal/interaction-common.ts:64-65` attaches evidence only when `recordSession` was + (`packages/daemon/src/execution/interaction/internal/interaction-common.ts:64-65` attaches evidence only when `recordSession` was true when the step ran). - **R2 — `--from` continuation only; never re-run the full replay on the same session.** After a divergence at step N and the corrective action, the agent must continue with `replay --from k --plan-digest `, not a fresh full `replay`. A full re-replay on the same session re-appends the already-recorded prefix `1..N-1` to `session.actions` — duplication, because - `session-action-recorder.ts:37` pushes unconditionally and replay dispatch does not inject `noRecord`. + `session-action-recorder.ts:92` pushes unconditionally and replay dispatch does not inject `noRecord`. The two sub-flows differ in `k`: app-state uses `k = N` (re-run the unchanged step after fixing state); selector-drift uses `k = N + 1` (the agent already performed step N manually; do not re-run it). - **R3 — a mechanical `repairHint` on the divergence payload gates the sub-flow; no LLM-only routing.** @@ -808,8 +808,8 @@ works" and "healed scripts are always valid": instead of leaving it to agent judgment. - **R4 — corrective actions must materialize to selector form; the writer fails loudly on a bare `@ref` cross-session export.** A `press @e12` normally resolves a `selectorChain` at runtime - (`src/daemon/interaction/internal/interaction-touch-targets.ts`), which `buildOptimizedActions` - (`src/daemon/session-script-writer.ts:69-83`) rewrites to a selector line. If no `selectorChain` was + (`packages/daemon/src/execution/interaction/internal/interaction-touch-targets.ts`), which `buildOptimizedActions` + (`packages/daemon/src/core/session-script-writer.ts:368-377`) rewrites to a selector line. If no `selectorChain` was captured, the writer must refuse to emit a bare `@ref` line into a persisted `.ad` — a session-bound ref will not resolve in a fresh run. It **fails loudly**: an error surfaced to the user with a non-zero exit, never a swallowed or silently-dropped line (existing session-write paths swallow such failures; @@ -893,7 +893,7 @@ by construction. The healed `.ad` is written only when the repair ends (below) a - The healed `.ad` is published when a teardown commits the transaction at state `COMPLETE` — normally the agent's own `close`/`close --save-script `, but any teardown of a completed transaction commits (see the commit state machine below) — reusing the existing `session.actions` serializer - (`SessionScriptWriter.write`, `src/daemon/session-script-writer.ts:30-52`) over the post-watermark slice + (`SessionScriptWriter.write`, `packages/daemon/src/core/session-script-writer.ts:120-158`) over the post-watermark slice only (R6). When no `` path is given, the default is the **`.healed.ad` sibling**: the original script's path with its `.ad` extension replaced by `.healed.ad` (e.g. `flows/login.ad` → `flows/login.healed.ad`), @@ -943,7 +943,7 @@ a separate naming change, not part of this decision. **Scope: this refusal is uniform across repair AND ordinary recording, not repair-only.** Everything above is written in the context of decision 6's repair-armed heal, but `publishHealedScriptAtomically` -(`src/daemon/session-script-writer.ts`) is the single publish primitive `SessionScriptWriter.write` calls +(`packages/daemon/src/core/session-script-writer.ts`) is the single publish primitive `SessionScriptWriter.write` calls for every `--save-script` target, with no repair-armed-vs-ordinary branch — a repair-armed heal (`saveScriptBoundary` set) and an ordinary, non-repair `open --save-script`/`close --save-script` recording (`saveScriptBoundary` absent) publish through the exact same exclusive `linkSync`. Before this @@ -1002,10 +1002,10 @@ The tombstone itself expires after its bounded window, after which the key is fu > Provenance travels as `internal.replayPlanStep`, stamped by `invokeResolvedReplayAction` > (`src/daemon/handlers/session-replay-action-runtime.ts`) — the single point every plan step is > dispatched, so the marker covers annotated and unannotated steps alike. `internal` is a daemon-only -> channel (`toDaemonRequest`, `src/daemon/server/http-rpc-methods.ts`, never copies it off the wire), so +> channel (`toDaemonRequest`, `packages/daemon/src/server/server/http-rpc-methods.ts`, never copies it off the wire), so > authored provenance cannot be spoofed by a client; this is the same channel `replayTargetGuard` and > `findResolvedTarget` already use. The rule is written once, in `isInteractiveObservation` -> (`src/daemon/session-action-recorder.ts`), and both recording call sites consume it. +> (`packages/daemon/src/core/session-action-recorder.ts`), and both recording call sites consume it. > > **2. The corrective-read trap: why even out-of-band reads need an opt-in.** Excluding every out-of-band > read is still not safe on its own: a divergence's **correction** can itself be a read. In the wave-3 E3 drift, the diverged step **was** a `get`, so its corrective replacement is a @@ -1044,11 +1044,11 @@ The tombstone itself expires after its bounded window, after which the key is fu > > **4. How the rule projects across CLI/Node/MCP surfaces.** The exclusion is enforced at a single > daemon-side choke point — `isExcludedRepairSegmentObservation` in `recordActionEntry` -> (`src/daemon/session-action-recorder.ts`), gated on `session.saveScriptBoundary !== undefined` (set ONLY +> (`packages/daemon/src/core/session-action-recorder.ts`), gated on `session.saveScriptBoundary !== undefined` (set ONLY > by a repair-armed `replay --save-script`; an ordinary, non-repair `open --save-script`/`close --save-script` > authoring recording never sets it — see decision 6's "Scope" note above) and on the entry's > `interactiveObservation` marker, which both recording call sites -> (`src/daemon/selector-recording.ts` for `get`/`is`/read-only `find`, `src/daemon/snapshot-runtime.ts` for +> (`packages/daemon/src/core/selector-recording.ts` for `get`/`is`/read-only `find`, `packages/daemon/src/sessions/snapshot-runtime.ts` for > `snapshot`) compute from the shared `isInteractiveObservation` predicate rather than each re-deriving it. > Every surface reaches this same function because every surface's request reaches the same daemon. > @@ -1159,8 +1159,8 @@ above and the gates they name are the authoritative record of current behavior. At acceptance, replay was deterministic. `.ad` scripts were plain text — one action per line, `#` comments, and a `context platform=... device=... theme=...` header (`src/replay/script.ts`) — recorded -via `open --save-script` (`src/daemon/session-action-recorder.ts`, -`src/daemon/session-script-writer.ts`) or hand-written, and executed step-by-step by +via `open --save-script` (`packages/daemon/src/core/session-action-recorder.ts`, +`packages/daemon/src/core/session-script-writer.ts`) or hand-written, and executed step-by-step by `runReplayScriptFile` (`src/daemon/handlers/session-replay-runtime.ts`) under the daemon's `replay`/`test` commands (`src/daemon/handlers/session-replay.ts`). Recorded touch/fill/get targets are selector chains with @@ -1289,15 +1289,15 @@ both `.ad` and Maestro paths) grounds the same conclusions from the caller's sea "Retry with --debug and inspect diagnostics log for details." (`defaultHintForCode`, `src/kernel/errors.ts:253-254`). - **Recordings contain zero verification steps.** The script writer strips every recorded `snapshot` - action (`buildOptimizedActions`, `src/daemon/session-script-writer.ts:69`: `if (action.command === + action (`buildOptimizedActions`, `packages/daemon/src/core/session-script-writer.ts:315`: `if (action.command === 'snapshot') continue;` — only synthetic ref-scoped snapshots are re-inserted, as resolution aids, not - observations), and the record-time flag allowlist (`SANITIZED_FLAG_KEYS`, - `src/daemon/session-action-recorder.ts:46-77`) carries neither `settle`/`settleQuietMs` nor `verify`, + observations), and the record-time flag allowlist (`RECORDED_FLAG_KEYS` from the flag + declarations' `recorded` field, `packages/daemon/src/core/session-action-recorder.ts:367-381`) carries neither `settle`/`settleQuietMs` nor `verify`, so `--settle`/`--verify` are dropped from recorded steps. A recording therefore replays actions with no outcome observation at all — exactly the gap decision 3's record-time identity evidence fills. A related, currently under-used precedent: recorded `@ref` steps already carry an optional identity -hint in the `.ad` file. `appendRefLabel` (`src/daemon/session-script-writer.ts:235-240`) writes the +hint in the `.ad` file. `appendRefLabel` (`packages/daemon/src/core/session-script-writer.ts:532-537`) writes the node's label as a trailing token, parsed back into `action.result.refLabel` (`src/replay/script.ts:269,295,315`). Today that label is used only as a fallback LOOKUP key (`tryResolveRefNode`'s `fallbackLabel`, `resolution.ts:393,413-430`) when the ref itself fails to diff --git a/docs/adr/0014-session-ref-frame-lifetime.md b/docs/adr/0014-session-ref-frame-lifetime.md index fb2059f088..a8943fcf06 100644 --- a/docs/adr/0014-session-ref-frame-lifetime.md +++ b/docs/adr/0014-session-ref-frame-lifetime.md @@ -20,7 +20,7 @@ ref-frame vocabulary is promoted into `CONTEXT.md`. issuance scope) — kept separate from the latest operational observation (`session.snapshot`). The frame is one value on `SessionState`, replaced whole by a transition and never edited in place; its type is nominal (`#`-private fields), so no module outside - `src/daemon/ref-frame.ts` can construct a frame, edit one, or derive one from an existing + `packages/daemon/src/core/ref-frame.ts` can construct a frame, edit one, or derive one from an existing frame. What the type cannot judge is a whole frame moved unchanged — clearing the field, or assigning another session's frame — which the field-owner gate still covers. - A complete snapshot activates an `all` frame; `find`, settled diffs, and replay divergence diff --git a/docs/adr/0016-active-session-script-publication.md b/docs/adr/0016-active-session-script-publication.md index c1ee8c4a74..75d30af7fc 100644 --- a/docs/adr/0016-active-session-script-publication.md +++ b/docs/adr/0016-active-session-script-publication.md @@ -2,8 +2,8 @@ ## Status -Accepted; implemented on `main` (`src/daemon/handlers/session-script-publication.ts`, -`src/daemon/session-script-active-publication.ts`), including the #1349 identity-level +Accepted; implemented on `main` (`packages/daemon/src/sessions/handlers/session-script-publication.ts`, +`packages/daemon/src/core/session-script-active-publication.ts`), including the #1349 identity-level destination-guard amendment. ## Rules at a glance diff --git a/docs/adr/0018-unified-event-journal.md b/docs/adr/0018-unified-event-journal.md index b77bb38d92..3c0a5781e7 100644 --- a/docs/adr/0018-unified-event-journal.md +++ b/docs/adr/0018-unified-event-journal.md @@ -64,7 +64,7 @@ redaction discipline, and sink (inventoried 2026-07-24): three request-lifecycle points plus `SessionStore.recordAction`, read only by the public `events` command. `action.recorded` is already a projection of `session.actions` pushes — the model this ADR generalizes. Crucially, not every append happens inside a request: - `finalizeRepairTeardown` (`src/daemon/session-store.ts`) records a synthesized `close` action + `finalizeRepairTeardown` (`packages/daemon/src/core/session-store.ts`) records a synthesized `close` action during idle reap or daemon shutdown, with — per its own comment — "no live request here." 3. **Progress streaming** (`src/request/progress.ts`, `src/daemon/request-progress-protocol.ts`). A closed, typed `RequestProgressEvent` union emitted through a single-sink `AsyncLocalStorage` @@ -85,7 +85,7 @@ usage at all — the codebase already avoids implicit pub/sub, which this design The channels overlap but share nothing: no common envelope, no shared kind vocabulary, and consumers couple to emit sites by string. The sharpest instance: agent-cost's `runnerRoundTrips` is `countDiagnosticEventsByPhase(['ios_runner_command_send', 'ios_runner_readiness_preflight'])` -(`src/daemon/request-router.ts`) — a hand-picked name list a new runner phase can silently drift +(`packages/daemon/src/server/request-router.ts`) — a hand-picked name list a new runner phase can silently drift from. That violates two established repo rules: *what enumerates N?* (nothing enumerates round-trip phases), and *categories come from recorded fields, never parsed names*. @@ -325,7 +325,7 @@ gets built. inconsistency, and three write paths. Kept as the migration's first independently useful step instead. - **Merge `upload-progress` and `app-events` in:** rejected. Upload progress is a local - byte-counter callback that never crosses the request scope; `src/daemon/app-events.ts` is a deep-link + byte-counter callback that never crosses the request scope; `packages/daemon/src/execution/app-events.ts` is a deep-link builder for the `trigger-app-event` command, not an event channel. ## Validation required for implementation diff --git a/docs/adr/0019-request-bound-platform-runtime.md b/docs/adr/0019-request-bound-platform-runtime.md index 45bd0f0d83..7ef18c7afc 100644 --- a/docs/adr/0019-request-bound-platform-runtime.md +++ b/docs/adr/0019-request-bound-platform-runtime.md @@ -24,7 +24,7 @@ is accepted. Completed 2026-08-27 through #2070–#2072. Every descriptor now declares `none`, `host`, `inventory`, or `device-runtime`; capability buckets and the legacy execution shape are gone. -Production `src/daemon/**` has zero dependencies on concrete platform implementations, enforced by +Production `packages/daemon/src/**` has zero dependencies on concrete platform implementations, enforced by R65. The per-command cutover table was retired after completion as required by section 6; R66 now enforces the permanent facts-only admission and runtime-proof invariants without naming historical routes or handler functions. @@ -830,7 +830,7 @@ helper stops follow the owning platform module's lifecycle policy, and close-tim neutral owner services. R65 is the daemon-side end-state enforcement: its planted-red AST tests reject every dependency edge — static, -dynamic, re-export, and type-only — from production `src/daemon/**` modules (test files excluded, +dynamic, re-export, and type-only — from production `packages/daemon/src/**` modules (test files excluded, matching the layering scanner's scope) to `src/platforms/**` and concrete `@agent-device/platform-*` packages. R13 governs concrete package imports across the whole tree, while `retired-platforms-zone` prevents the old root seam from being recreated; platform freedom is @@ -841,13 +841,13 @@ therefore structurally enforced rather than periodically measured. Some request-path work asks the host machine something without ever taking a device runtime: concrete local readiness, boot-time and runner-session observation, and open-target classification. Those asks now cross the daemon boundary as one required dependency, -`DaemonPlatformServices` (`src/daemon/platform-services.ts`), assembled by the daemon runtime's +`DaemonPlatformServices` (`packages/daemon/src/core/platform-services.ts`), assembled by the daemon runtime's root-composition module in `src/daemon-composition.ts` — which reaches the concrete adapters through `src/platform-runtime-daemon-services.ts` behind a function-scoped `await import` — and threaded composition → `startDaemonRuntime` deps → `RequestRouterDeps` → the request execution scope → the handlers and consumers. Stale-claim reconciliation gets the same treatment for the one act it may not perform itself: the composition supplies the `ClaimRecoveryGatewayFactory` -the daemon declares in `src/daemon/device/claim-recovery-gateway.ts`, built from +the daemon declares in `packages/daemon/src/resources/device/claim-recovery-gateway.ts`, built from `src/platform-runtime-claim-recovery.ts` (likewise deferred), and the daemon keeps the transaction — what to rebuild from (the dead owner's recorded state dir), in what order, and when to dispose it. @@ -937,7 +937,7 @@ baseline and are open for revision or rejection. **Daemon top-level footprint.** `git ls-tree --name-only origin/main src/daemon/ | grep -E '\.ts$' | grep -vE '\.test\.ts$' | wc -l` measured 199 production files at `e624ef9d3f`. Proposed -target: ≤ 60. `src/daemon/**` is a permanent zone under R65; the target is about what remains +target: ≤ 60. `packages/daemon/src/**` is a permanent zone under R65; the target is about what remains there, not about retiring the directory. **Entry-to-platform hop count.** Corrected 2026-09-03, re-measured for #2278 at `27a97ee619`: diff --git a/docs/adr/0022-daemon-platform-runtime-coupling.md b/docs/adr/0022-daemon-platform-runtime-coupling.md index f0976e5726..642f14c031 100644 --- a/docs/adr/0022-daemon-platform-runtime-coupling.md +++ b/docs/adr/0022-daemon-platform-runtime-coupling.md @@ -8,17 +8,17 @@ and points at the gates rather than restating the inventory. Amended 2026-10-11 by #3431: the daemon-runtime composition edges this ADR classified (the gateway/diagnostics/resource-cleanup/lifecycle edges, the provider-runtime -hubs, and the platform-services and claim-recovery dynamic edges) moved out of `src/daemon/` into +hubs, and the platform-services and claim-recovery dynamic edges) moved out of `packages/daemon/src/` into the process-root composition module `src/daemon-composition.ts`, which R76 does not see because it is no longer a daemon-zone importer. #3430 then routed the leaked selector-query edge -(`src/daemon/direct-ios-selector.ts`) through the request-bound runtime binding, so the R76 +(`packages/daemon/src/core/direct-ios-selector.ts`) through the request-bound runtime binding, so the R76 inventory is empty; with nothing left to classify, the same change collapsed R76 to a plain ban on the coupling and deleted the classification machinery, per the rule's own kill criterion. The section-2 outcomes below remain the record of how each was classified. ## 1. Context -The platform-package migration removed direct production dependencies from `src/daemon/**` to +The platform-package migration removed direct production dependencies from `packages/daemon/src/**` to concrete platform code (R65: zero such imports in every form). What it did not prove is that every remaining platform-aware responsibility belongs in the daemon. At the audit baseline (`658f822c`) nine daemon files held 13 production imports of root `src/platform-runtime-*.ts` @@ -36,7 +36,7 @@ or owning issue. #2278 audited all four concerns at `27a97ee619`. `DAEMON_PLATFORM_RUNTIME_EDGES` in [`scripts/layering/daemon-platform-runtime-inventory.ts`](../../scripts/layering/daemon-platform-runtime-inventory.ts) is now empty, so the classification table and its symbol-drift and staleness passes are deleted - and R76 bans the coupling outright — any production `src/daemon/**` import of the family or of a + and R76 bans the coupling outright — any production `packages/daemon/src/**` import of the family or of a root hub that reaches it is a violation. The categories and outcomes below remain the record of how each edge was judged and retired): - **Composition-essential** — assembling neutral runtime implementations at the process root. @@ -64,7 +64,7 @@ or owning issue. #2278 audited all four concerns at `27a97ee619`. are daemon-policy-essential. Selector production and lifecycle participation stay separate. - **#2333 (done)** — lifecycle participation of platform resource owners. The `apple-runner-owner` and `operation-host` edges are retired; `daemon-runtime.ts` now holds - only the typed `PlatformOwnerLifecycle` contract (`src/daemon/platform-owner-lifecycle.ts`), + only the typed `PlatformOwnerLifecycle` contract (`packages/daemon/src/core/platform-owner-lifecycle.ts`), composed at the root by `platform-runtime-daemon-lifecycle.ts`, which is the sole importer of the Apple runner owner, the Android snapshot-helper and Web orphan cleanups, and legacy app-log marker recovery. The `resource-cleanup` edge stays, reclassified @@ -86,11 +86,11 @@ or owning issue. #2278 audited all four concerns at `27a97ee619`. 3. **Session state and store authority are measured as a symbol-level overlay and ratcheted on the handler-owned slice.** At `27a97ee619` the overlay is 112 `SessionState` shape edges and 68 `SessionStore` authority edges repo-wide, of which 14 shape / 22 authority files are - handler-owned (`src/daemon/handlers/**`). Gate rule **R75 `session-authority-overlay`** + handler-owned (`packages/daemon/src/{sessions,execution}/handlers/**`). Gate rule **R75 `session-authority-overlay`** (reference measured via `measureRatchets` in `scripts/layering/ratchet-reference.ts`) holds the handler-owned file sets at or under the merge-base: handler code may lose files from either set, never gain them. The ratchet is added now that the edges are classified; - cross-module reads outside `src/daemon/handlers/**` are owned by the logical-module + cross-module reads outside `packages/daemon/src/{sessions,execution}/handlers/**` are owned by the logical-module declarations (R7/R10) and are not ratcheted here. 4. **The entry-to-platform hop trace was re-run with hop roles** diff --git a/docs/adr/0023-end-state-hop-trace.md b/docs/adr/0023-end-state-hop-trace.md index 84fddb1da9..2e93b4262b 100644 --- a/docs/adr/0023-end-state-hop-trace.md +++ b/docs/adr/0023-end-state-hop-trace.md @@ -20,7 +20,7 @@ that reading. - **Unit**: one distinct production `.ts` file entered on the call path, counted once even if re-entered (a lazy `import()` of an already-counted file is not a new hop). Type-only imports and files that only supply types are not hops. -- **Range**: from the daemon's HTTP entry file (`src/daemon/server/http-server.ts`) through the +- **Range**: from the daemon's HTTP entry file (`packages/daemon/src/server/server/http-server.ts`) through the file that issues the concrete platform call, inclusive of both endpoints. For `press`/Android that is the serial-scoped `adb shell input tap` invocation; for `snapshot`/iOS it is the `socket.write` to the in-simulator AX bridge (primary arm) or the `fetch()` to the XCTest @@ -59,7 +59,7 @@ that reading. 41 files: 11 pass-through, 5 translation, 5 policy, 19 orchestration, 1 terminal (adapter). The request spine also runs side-calls that are not hops — they execute on every request but are -not the call that continues toward the platform boundary: `src/daemon/server/daemon-idle-reap.ts` +not the call that continues toward the platform boundary: `packages/daemon/src/sessions/server/daemon-idle-reap.ts` (`cancel()` resets the liveness timer as a sibling of `dispatchRequest`), `packages/host-kit/src/internal/transport.ts` (`timingSafeStringEqual` compares the auth token before the continuation), and `packages/host-kit/src/internal/request-cancel.ts` @@ -67,35 +67,35 @@ before the continuation), and `packages/host-kit/src/internal/request-cancel.ts` | # | File | Hand-off | Role | Delete-test | |---|------|----------|------|-------------| -| 1 | `src/daemon/server/http-server.ts` | parses `/rpc`, resolves the token; calls injected `handleRequest` | pass-through | KEEP — HTTP entry boundary | -| 2 | `src/daemon/server/daemon-runtime.ts` | `handleRequest`: in-flight count, cancels idle reap, `dispatchRequest` | orchestration | KEEP — request lifecycle orchestration | -| 3 | `src/daemon/request-router.ts` | auth, flag guards, scope creation, locked execution, handler chain | orchestration | KEEP — request admission + dispatch core | +| 1 | `packages/daemon/src/server/server/http-server.ts` | parses `/rpc`, resolves the token; calls injected `handleRequest` | pass-through | KEEP — HTTP entry boundary | +| 2 | `packages/daemon/src/server/server/daemon-runtime.ts` | `handleRequest`: in-flight count, cancels idle reap, `dispatchRequest` | orchestration | KEEP — request lifecycle orchestration | +| 3 | `packages/daemon/src/server/request-router.ts` | auth, flag guards, scope creation, locked execution, handler chain | orchestration | KEEP — request admission + dispatch core | | 4 | `packages/host-kit/src/internal/diagnostics.ts` | `withDiagnosticsScope` wraps the request task | pass-through | KEEP — per-request diagnostic attribution | | 5 | `src/request/device-inventory-context.ts` | `withDeviceInventoryContext` wraps the task | pass-through | KEEP — request-scoped device inventory context | | 6 | `src/core/dispatch-resolve.ts` | `withResolveTargetDeviceCacheScope` wraps the task | orchestration | KEEP — per-request target-resolution cache | -| 7 | `src/daemon/request-execution-scope.ts` | `createRequestExecutionScope`; `runLocked`/`runAdmitted` | orchestration | KEEP — scoped execution + lock/claim admission | +| 7 | `packages/daemon/src/server/request-execution-scope.ts` | `createRequestExecutionScope`; `runLocked`/`runAdmitted` | orchestration | KEEP — scoped execution + lock/claim admission | | 8 | `src/provider-device-runtime.ts` | `withProviderDeviceRuntimeScope` (`AsyncLocalStorage.run`) | pass-through | KEEP — provider-runtime scope boundary | -| 9 | `src/daemon/request-handler-chain.ts` | `runRequestHandlerChain` routes to the interaction handler | orchestration | KEEP — command routing | -| 10 | `src/daemon/interaction/index.ts` | route facade delegates to `handleInteractionCommands` | orchestration | KEEP — shared interaction route facade | -| 11 | `src/daemon/interaction/internal/interaction.ts` | switches `press` to `dispatchTargetedTouchViaRuntime` | policy | KEEP — touch command routing | -| 12 | `src/daemon/interaction/internal/interaction-touch-press.ts` | admits the touch, dispatches the runtime interaction | orchestration | KEEP — press admission + orchestration | -| 13 | `src/daemon/interaction/internal/interaction-touch-prepare.ts` | `prepareTouchDispatch` → `resolveBoundTouchRuntime` | translation | KEEP — shared admission + bind seam | -| 14 | `src/daemon/touch-runtime.ts` | resolves the plan, `bind(device, tapPointUse)` | orchestration | KEEP — tap runtime binding | -| 15 | `src/daemon/runtime-admission.ts` | `admitRuntimeOperations`: `inspectFacts`, per-op admission | policy | KEEP — per-operation admission | -| 16 | `src/daemon/request-runtime-binding.ts` | `bindDevice`: per-device-cached `gateway.bind` | orchestration | KEEP — device runtime binding | +| 9 | `packages/daemon/src/sessions/request-handler-chain.ts` | `runRequestHandlerChain` routes to the interaction handler | orchestration | KEEP — command routing | +| 10 | `packages/daemon/src/execution/interaction/index.ts` | route facade delegates to `handleInteractionCommands` | orchestration | KEEP — shared interaction route facade | +| 11 | `packages/daemon/src/execution/interaction/internal/interaction.ts` | switches `press` to `dispatchTargetedTouchViaRuntime` | policy | KEEP — touch command routing | +| 12 | `packages/daemon/src/execution/interaction/internal/interaction-touch-press.ts` | admits the touch, dispatches the runtime interaction | orchestration | KEEP — press admission + orchestration | +| 13 | `packages/daemon/src/execution/interaction/internal/interaction-touch-prepare.ts` | `prepareTouchDispatch` → `resolveBoundTouchRuntime` | translation | KEEP — shared admission + bind seam | +| 14 | `packages/daemon/src/core/touch-runtime.ts` | resolves the plan, `bind(device, tapPointUse)` | orchestration | KEEP — tap runtime binding | +| 15 | `packages/daemon/src/core/runtime-admission.ts` | `admitRuntimeOperations`: `inspectFacts`, per-op admission | policy | KEEP — per-operation admission | +| 16 | `packages/daemon/src/core/request-runtime-binding.ts` | `bindDevice`: per-device-cached `gateway.bind` | orchestration | KEEP — device runtime binding | | 17 | `src/platform-runtime-gateway.ts` | `loadLocal` → `loadHost` → `loadRuntime` | orchestration | KEEP — gateway boundary | | 18 | `src/platform-runtime.ts` | wires the android module, supplies `loadHost` | pass-through | KEEP — declared ADR §1/§2 registry boundary | | 19 | `src/platform-runtime-operation-host.ts` | `createPlatformRuntimeHost` assembles the host | orchestration | KEEP — host composition | | 20 | `packages/platform-android/src/index.ts` | `loadRuntime` pairs the plugin with the runtime module | pass-through | KEEP — declared ADR §2 `loadRuntime` boundary | | 21 | `packages/platform-android/src/runtime.ts` | `bind`: `inspectFacts` (fan-out site), builds the tap operation | orchestration | KEEP — android runtime owner | | 22 | `packages/contracts/src/local-interactor-operation-set.ts` | `bindLocalInteractorOperationSet` → `bindLocalTouchInteractor` | translation | KEEP — tap op mapped to the interactor | -| 23 | `src/daemon/device-claim-admission.ts` | `admit`: owner claim rule; ordinary owner | policy | KEEP — device claim admission | -| 24 | `src/daemon/interaction/internal/interaction-touch-runtime.ts` | `dispatchRuntimeInteraction` → `createInteractionRuntimeForRoute` | orchestration | KEEP — interaction runtime dispatch | -| 25 | `src/daemon/interaction/internal/interaction-runtime.ts` | `createInteractionAgentDevice` with the executor backend | orchestration | KEEP — agent device construction | +| 23 | `packages/daemon/src/resources/device/device-claim-admission.ts` | `admit`: owner claim rule; ordinary owner | policy | KEEP — device claim admission | +| 24 | `packages/daemon/src/execution/interaction/internal/interaction-touch-runtime.ts` | `dispatchRuntimeInteraction` → `createInteractionRuntimeForRoute` | orchestration | KEEP — interaction runtime dispatch | +| 25 | `packages/daemon/src/execution/interaction/internal/interaction-runtime.ts` | `createInteractionAgentDevice` with the executor backend | orchestration | KEEP — agent device construction | | 26 | `src/runtime.ts` | `createAgentDevice`: backend + `bindCommands` | orchestration | KEEP — agent device facade | | 27 | `src/commands/index.ts` | `bindCommands` → `bindInteractionCommands` | orchestration | KEEP — command catalog boundary | | 28 | `src/commands/interaction/runtime/index.ts` | `bindInteractionCommands`: `press` → `pressCommand` | orchestration | KEEP — nine-command binding surface | -| 29 | `src/daemon/interaction/internal/interaction-touch-android-readiness.ts` | `runWithAndroidDialogReadinessCheck` wraps `run` | policy | KEEP — blocking-dialog readiness gate | +| 29 | `packages/daemon/src/execution/interaction/internal/interaction-touch-android-readiness.ts` | `runWithAndroidDialogReadinessCheck` wraps `run` | policy | KEEP — blocking-dialog readiness gate | | 30 | `src/commands/interaction/runtime/interactions.ts` | `pressCommand` → `tapCommand`: resolve target, `backend.tap` | orchestration | KEEP — tap command execution | | 31 | `src/commands/interaction/runtime/resolution.ts` | `resolveInteractionTarget` applies guards, returns the point | translation | KEEP — tap target resolution | | 32 | `packages/contracts/src/interactor-operation-binding.ts` | `interactorFor` resolves the local interactor | translation | KEEP — shared interactor resolution seam | @@ -125,11 +125,11 @@ only by its named composition module per ADR Decision §1). `tv-remote`, `viewport` (each `-runtime.ts`). **Response path (not hops).** 8 files execute only after the platform call: -`src/daemon/interaction/internal/interaction-touch-response.ts`, -`src/daemon/interaction/internal/interaction-common.ts`, -`src/daemon/interaction-surface-signature.ts`, `src/daemon/request-finalization.ts`, -`src/daemon/session-event-log.ts`, `src/daemon/session-snapshot.ts`, -`src/daemon/recording-gestures.ts`, `src/daemon/deferred-interaction-outcome.ts`. +`packages/daemon/src/execution/interaction/internal/interaction-touch-response.ts`, +`packages/daemon/src/execution/interaction/internal/interaction-common.ts`, +`packages/daemon/src/core/interaction-surface-signature.ts`, `packages/daemon/src/server/request-finalization.ts`, +`packages/session-journal/src/session-event-log.ts`, `packages/daemon/src/execution/session-snapshot.ts`, +`packages/daemon/src/core/recording-gestures.ts`, `packages/daemon/src/core/deferred-interaction-outcome.ts`. **Forks not followed**: `request-platform-provider-context.ts` (the call is guarded by the router's early return for a bare local daemon — zero runtimes + non-web), @@ -149,31 +149,31 @@ captures join it). Shared prefix 30 files; primary arm 47 distinct (30 + 17); fallback arm 49 distinct (30 + 19); 66 distinct files across the union. The request spine's side-calls — the idle-reap reset, the auth comparison, the cancellation gate, and the Android freshness guard/clear -(`src/daemon/session-snapshot-freshness.ts`, a guard read plus a post-capture clear that no-ops +(`packages/daemon/src/core/session-snapshot-freshness.ts`, a guard read plus a post-capture clear that no-ops on iOS) — run on this prefix as siblings of the continuation and are not counted. ### Shared prefix (entry → fork) | # | File | Hand-off | Role | Delete-test | |---|------|----------|------|-------------| -| 1 | `src/daemon/server/http-server.ts` | parses `/rpc`, resolves the token; calls injected `handleRequest` | pass-through | KEEP — HTTP entry boundary | -| 2 | `src/daemon/server/daemon-runtime.ts` | `handleRequest`: in-flight count, cancels idle reap, `dispatchRequest` | orchestration | KEEP — request lifecycle orchestration | -| 3 | `src/daemon/request-router.ts` | auth, flag guards, scope creation, locked execution, handler chain | orchestration | KEEP — request admission + dispatch core | +| 1 | `packages/daemon/src/server/server/http-server.ts` | parses `/rpc`, resolves the token; calls injected `handleRequest` | pass-through | KEEP — HTTP entry boundary | +| 2 | `packages/daemon/src/server/server/daemon-runtime.ts` | `handleRequest`: in-flight count, cancels idle reap, `dispatchRequest` | orchestration | KEEP — request lifecycle orchestration | +| 3 | `packages/daemon/src/server/request-router.ts` | auth, flag guards, scope creation, locked execution, handler chain | orchestration | KEEP — request admission + dispatch core | | 4 | `packages/host-kit/src/internal/diagnostics.ts` | `withDiagnosticsScope` wraps the request task | pass-through | KEEP — per-request diagnostic attribution | | 5 | `src/request/device-inventory-context.ts` | `withDeviceInventoryContext` wraps the task | pass-through | KEEP — request-scoped device inventory context | | 6 | `src/core/dispatch-resolve.ts` | `withResolveTargetDeviceCacheScope` wraps the task | orchestration | KEEP — per-request target-resolution cache | -| 7 | `src/daemon/request-execution-scope.ts` | `createRequestExecutionScope`; `runLocked`/`runAdmitted` | orchestration | KEEP — scoped execution + lock/claim admission | +| 7 | `packages/daemon/src/server/request-execution-scope.ts` | `createRequestExecutionScope`; `runLocked`/`runAdmitted` | orchestration | KEEP — scoped execution + lock/claim admission | | 8 | `src/provider-device-runtime.ts` | `withProviderDeviceRuntimeScope` (`AsyncLocalStorage.run`) | pass-through | KEEP — provider-runtime scope boundary | -| 9 | `src/daemon/request-handler-chain.ts` | `runRequestHandlerChain` routes `snapshot` to `runSnapshotHandler` | orchestration | KEEP — command routing | -| 10 | `src/daemon/handlers/snapshot.ts` | `handleSnapshotCommands` routes the plain arm | policy | KEEP — snapshot command routing | -| 11 | `src/daemon/snapshot-runtime.ts` | `dispatchSnapshotViaRuntime` → `params.execute` | pass-through | KEEP — snapshot execute seam (route tests pin it) | -| 12 | `src/daemon/snapshot-command-runtime.ts` | resolves the bound capture; wires session/backend; runs the op | orchestration | KEEP — capture wiring + recording | -| 13 | `src/daemon/deferred-interaction-outcome.ts` | `resolveDeferredInteractionOutcome` before a fresh capture | policy | KEEP — pending-outcome settlement (may short-circuit) | -| 14 | `src/daemon/snapshot-capture.ts` | `resolveSnapshotScope` + the capture attempt | orchestration | KEEP — capture attempt + scope resolution | -| 15 | `src/daemon/snapshot-session.ts` | `resolveSessionDevice` for the capture | translation | KEEP — snapshot session/device resolution | -| 16 | `src/daemon/snapshot-runtime-binding.ts` | `resolveBoundSnapshotCaptureRuntime`: admit-then-bind | policy | KEEP — ADR 0019 §9 admit-then-bind seam | -| 17 | `src/daemon/session-runtime-admission.ts` | `admitRuntimePlan` (fan-out site) / `requireRuntimeBinding` | policy | KEEP — runtime plan fact admission | -| 18 | `src/daemon/request-runtime-binding.ts` | `bindDevice`: per-device-cached `gateway.bind` | orchestration | KEEP — device runtime binding | +| 9 | `packages/daemon/src/sessions/request-handler-chain.ts` | `runRequestHandlerChain` routes `snapshot` to `runSnapshotHandler` | orchestration | KEEP — command routing | +| 10 | `packages/daemon/src/sessions/handlers/snapshot.ts` | `handleSnapshotCommands` routes the plain arm | policy | KEEP — snapshot command routing | +| 11 | `packages/daemon/src/sessions/snapshot-runtime.ts` | `dispatchSnapshotViaRuntime` → `params.execute` | pass-through | KEEP — snapshot execute seam (route tests pin it) | +| 12 | `packages/daemon/src/sessions/snapshot-command-runtime.ts` | resolves the bound capture; wires session/backend; runs the op | orchestration | KEEP — capture wiring + recording | +| 13 | `packages/daemon/src/core/deferred-interaction-outcome.ts` | `resolveDeferredInteractionOutcome` before a fresh capture | policy | KEEP — pending-outcome settlement (may short-circuit) | +| 14 | `packages/daemon/src/core/snapshot-capture.ts` | `resolveSnapshotScope` + the capture attempt | orchestration | KEEP — capture attempt + scope resolution | +| 15 | `packages/daemon/src/core/snapshot-session.ts` | `resolveSessionDevice` for the capture | translation | KEEP — snapshot session/device resolution | +| 16 | `packages/daemon/src/core/snapshot-runtime-binding.ts` | `resolveBoundSnapshotCaptureRuntime`: admit-then-bind | policy | KEEP — ADR 0019 §9 admit-then-bind seam | +| 17 | `packages/daemon/src/core/session-runtime-admission.ts` | `admitRuntimePlan` (fan-out site) / `requireRuntimeBinding` | policy | KEEP — runtime plan fact admission | +| 18 | `packages/daemon/src/core/request-runtime-binding.ts` | `bindDevice`: per-device-cached `gateway.bind` | orchestration | KEEP — device runtime binding | | 19 | `src/platform-runtime-gateway.ts` | `loadLocal` → `loadHost` → `loadRuntime` | orchestration | KEEP — gateway boundary | | 20 | `src/platform-runtime.ts` | wires the apple module, supplies `loadHost` | pass-through | KEEP — declared ADR §1/§2 registry boundary | | 21 | `src/platform-runtime-operation-host.ts` | `createPlatformRuntimeHost` assembles the host | orchestration | KEEP — host composition | @@ -242,10 +242,10 @@ Re-entry: arm B #4 enters `packages/platform-apple/src/index.ts` (shared #22) vi above, as side-calls of the admission step. **Response path (not hops).** 22 files execute only after the platform call: -`src/daemon/ref-frame.ts`, `src/daemon/session-action-recorder.ts`, -`src/daemon/snapshot-quality-latch.ts`, `src/daemon/request-finalization.ts`, -`src/daemon/session-event-request.ts`, `src/daemon/session-snapshot.ts` (lineage), -`src/daemon/sparse-fallback-screenshot.ts`, `src/core/snapshot-state.ts`, +`packages/daemon/src/core/ref-frame.ts`, `packages/daemon/src/core/session-action-recorder.ts`, +`packages/daemon/src/sessions/snapshot-quality-latch.ts`, `packages/daemon/src/server/request-finalization.ts`, +`packages/session-journal/src/session-event-request.ts`, `packages/daemon/src/execution/session-snapshot.ts` (lineage), +`packages/daemon/src/execution/sparse-fallback-screenshot.ts`, `src/core/snapshot-state.ts`, `packages/contracts/src/capture.ts`, `packages/platform-apple/src/runner/snapshot-presentation.ts`, `src/snapshot/ios-snapshot-runtime.ts`, the `packages/capture-kit/src/ios-snapshot-engine/` modules (engine, invariants, geometry, geometry-policy, projection, graph, diff --git a/docs/adr/0033-collocation-decision-table.md b/docs/adr/0033-collocation-decision-table.md index e559470837..f1ed258c1c 100644 --- a/docs/adr/0033-collocation-decision-table.md +++ b/docs/adr/0033-collocation-decision-table.md @@ -79,7 +79,7 @@ already owns the operations behind the vocabulary. | `src/diagnostics.ts` | keep | The diagnostics seam every zone imports (AGENTS.md mandates it); highest fan-in in the repo is what a substrate looks like, not misplacement. | | `src/internal/request-cancel.ts` | keep | Request-cancellation mechanics AGENTS.md routes to `host-kit/request`; internal beside its facade is already the collocation. | | `src/request.ts` | keep | Cross-layer request contracts AGENTS.md names as a host-kit seam; consumers span every zone. | -| `src/session-paths.ts` | keep | Session-artifact path grammar the daemon, cli, and platforms all resolve; AGENTS.md keeps the path *policy* in `src/daemon/session-artifact-paths.ts`, which consumes this. | +| `src/session-paths.ts` | keep | Session-artifact path grammar the daemon, cli, and platforms all resolve; AGENTS.md keeps the path *policy* in `packages/daemon/src/core/session-artifact-paths.ts`, which consumes this. | ### kernel @@ -133,7 +133,7 @@ the whole `daemon-contracts` zone has moved into `packages/daemon-contracts` — package derive the zone, so every moved file's `ROOT_MODULE_ZONES` row is gone. The daemon ⇄ client shared files that remain here (`provider-credential-fingerprint.ts`) trace to #2559, which relocated the shared contracts **to the process root** so the client stops -importing `src/daemon/` at all; R78 keeps any client→daemon +importing `packages/daemon/src/` at all; R78 keeps any client→daemon edge at zero runtime and a five-line recorded type-only residue, and #3288's `daemon-contracts` zone was the declaration of that shared-below-both ownership — the extraction makes it physical, with R11 and the package's dependency edges holding the same boundary. Rows on @@ -152,7 +152,7 @@ optimal. | `src/platform-runtime-resource-cleanup.ts` | retain for this batch | Same path-keyed R13/ADR 0022 seam. | | `src/provider-credential-fingerprint.ts` | keep (type extracted) | Daemon ⇄ client shared contract from the same #2559 decision as `daemon-policy-file.ts`; #3288 declares its zone beside the provider composition that reads the credentials it fingerprints. PR 6 of the daemon extraction moved only the `DaemonProviderCredentials` declaration to `packages/daemon-contracts` (`./provider-credentials`), the same shared-below-both landing as the policy file; the fingerprinting implementation stays here because it reads the installed-plugin manifest. | | `src/provider-limrun-runtime.ts` | keep | Proposed → provider-limrun, but there is no seam: the class's constructor self-builds the root dependency factory (`src/sdk/limrun-runtime-dependencies.ts`), which is the ADR 0019 composition seam — it loads the root's adb-host binder, core Android interactor, and platform-runtime app-state helpers that the package must not import. Moving the class means moving that composition, which is design, not a move. | -| `src/request-progress-protocol.ts` | moved → `packages/daemon-contracts/src/request-progress-protocol.ts` | Daemon ⇄ client shared contract from the same #2559 decision — the client reads it statically (`daemon-client-progress.ts`) and the server through `src/daemon/server/`, so only #2559's shared-placement boundary and the wire-compat ledgers pin it; declared `daemon-contracts` by #3288 and now physically placed by the extraction. Contracts was considered and R18 keeps contracts free of envelope validation mechanics. The wire-ledger keys moved with the file. | +| `src/request-progress-protocol.ts` | moved → `packages/daemon-contracts/src/request-progress-protocol.ts` | Daemon ⇄ client shared contract from the same #2559 decision — the client reads it statically (`daemon-client-progress.ts`) and the server through `packages/daemon/src/server/`, so only #2559's shared-placement boundary and the wire-compat ledgers pin it; declared `daemon-contracts` by #3288 and now physically placed by the extraction. Contracts was considered and R18 keeps contracts free of envelope validation mechanics. The wire-ledger keys moved with the file. | | `src/runtime-command-surface.ts` | moved → `src/command-runtime/runtime-command-surface.ts` ([#3299](https://github.com/callstack/agent-device/pull/3299)) | Physical move landed with `runtime-factory.ts` as one assembly group: the command-surface binding sits beside the factory it composes, under the folder that derives its `command-runtime` zone, so `topFolder` replaces the per-file `ROOT_MODULE_ZONES` row. | | `src/runtime-factory.ts` | moved → `src/command-runtime/runtime-factory.ts` ([#3299](https://github.com/callstack/agent-device/pull/3299)) | Physical move landed: the runtime assembly now lives under the folder that derives its `command-runtime` zone, with the same row deletion through folder-derived ownership. | @@ -188,6 +188,23 @@ files have no seam (published facade, public-type collision, root dependency fac moved there by [#3297](https://github.com/callstack/agent-device/pull/3297)) are now `packages/daemon-contracts/src/` behind narrow per-file subpath exports. +## The daemon package's export surface + +`@agent-device/daemon` publishes a façade, not importer reach: one named subpath per +production/script consumer — a subpath that only tests import is not production surface. +Everything else a root test reaches lives under the `./testing/` namespace: named +`./testing/` entries for production modules tests drive, named `./testing/` +entries, and, per fixture folder, a `./testing//*` pattern whose target template +reconstructs the source path. Never a wildcard that also exposes production modules. R11 +refuses any `./testing/` import from a non-test file, so root production code cannot import +a module the package publishes for tests (a package test double reached through the +boundary is production code depending on a fake), and root production imports are limited +to the named production surface. The exports keys stay exact except the per-folder fixture +patterns; `resolveWorkspaceSpecifier` (layering model) owns Node's exports semantics — the +layering edges, the depgraph, mutation ownership, and R11's named-surface check call it, and +the Stryker alias table orders its Vite first-match list to resolve in exactly its order — +so every lane gives a specifier the module id Node's exports resolution gives it. + ## Refuted alternatives - **Move every ≥80% community match into its dominant zone.** Rejected: the measure is diff --git a/docs/agents/cli-flags.md b/docs/agents/cli-flags.md index b06eb28d27..1b253fef28 100644 --- a/docs/agents/cli-flags.md +++ b/docs/agents/cli-flags.md @@ -28,7 +28,7 @@ Thread a flag only through the layers that consume it: interface exposes it. 6. `src/client/client-normalizers.ts`: update daemon flag normalization only when the request still needs a public-to-internal translation. -7. `src/daemon/context.ts` and `src/daemon/dispatch-context.ts`: add the field only when it flows into +7. `packages/daemon/src/core/context.ts` and `packages/daemon/src/core/dispatch-context.ts`: add the field only when it flows into platform dispatch. 8. Handler/platform modules: thread the option only after the command surface, grammar, and projection prove it belongs there. diff --git a/docs/agents/test-audit.md b/docs/agents/test-audit.md index c9e9af4c29..b6d2ef3351 100644 --- a/docs/agents/test-audit.md +++ b/docs/agents/test-audit.md @@ -50,7 +50,7 @@ Plant the production edit representing the claimed bug: the pre-edit body must s ## Dispatching subagents -Run parallel read-only lanes with exclusive edit ownership: subsystem lanes (per platform package, `src/daemon`, core packages, `scripts/**`), one cross-cutting junk-pattern sweep, one never-run inventory (Vitest includes, `node --test` globs, gate ids). Mandate in every prompt: READ-ONLY; read the production owner and name the bug; verify skip guards and runner/gate ownership; paste the retention list; false positives cost more than misses. +Run parallel read-only lanes with exclusive edit ownership: subsystem lanes (per platform package, `packages/daemon`, core packages, `scripts/**`), one cross-cutting junk-pattern sweep, one never-run inventory (Vitest includes, `node --test` globs, gate ids). Mandate in every prompt: READ-ONLY; read the production owner and name the bug; verify skip guards and runner/gate ownership; paste the retention list; false positives cost more than misses. ## Landing diff --git a/docs/agents/testing.md b/docs/agents/testing.md index e049a264e3..67b67d00f3 100644 --- a/docs/agents/testing.md +++ b/docs/agents/testing.md @@ -68,12 +68,11 @@ Read the entry file before running a lane. Do not copy its environment matrix he ## Shared test utilities Before creating fixtures, look in `@agent-device/test-kit/` (generic) and -`src/daemon/__tests__/support/` (daemon-shaped). Import named builders -from the module that defines them; avoid importing -unrelated helpers through a barrel. Shared `DeviceInfo`, session, snapshot, store, runtime-fact, -and mocked-binary values belong in a sibling fixture module, not in repeated test literals. -`PROPERTY_RUNS` and the touch-point/rect arbitraries live in -`@agent-device/selectors/snapshot-geometry-fixtures`, not `src/__tests__/test-utils/`; +`packages/daemon/src/__tests__/support/` (daemon-shaped). Import named builders from their +defining module, never through a barrel. Shared `DeviceInfo`, session, snapshot, store, +runtime-fact, and mocked-binary values belong in a sibling fixture module, not in repeated +test literals. `PROPERTY_RUNS` and the touch-point/rect arbitraries live in +`@agent-device/selectors/snapshot-geometry-fixtures`; `makeSnapshotState` lives in `@agent-device/capture-kit/snapshot-state-fixtures`. Use `mkdtempForTest` or `mkdtempForTestSync`. Global setup redirects `TMPDIR` for the run and @@ -134,7 +133,7 @@ Run `pnpm depgraph affected` before touching a high-fan-in module: ```sh pnpm depgraph affected packages/host-kit/src/command.ts -pnpm depgraph affected src/daemon/ref-frame.ts --json --limit 25 +pnpm depgraph affected packages/daemon/src/core/ref-frame.ts --json --limit 25 ``` Use its dependent, command, and guarantee-cell report to scope inspection. `pnpm check:affected --run` diff --git a/examples/sdk/tsconfig.json b/examples/sdk/tsconfig.json index f90c5dd2fe..483a3f32d9 100644 --- a/examples/sdk/tsconfig.json +++ b/examples/sdk/tsconfig.json @@ -39,6 +39,7 @@ { "path": "../../packages/capture-kit" }, { "path": "../../packages/command-registry" }, { "path": "../../packages/contracts" }, + { "path": "../../packages/daemon" }, { "path": "../../packages/daemon-contracts" }, { "path": "../../packages/device-selection" }, { "path": "../../packages/host-kit" }, diff --git a/fallow-baselines/health.json b/fallow-baselines/health.json index 5fe587874b..69012dce0e 100644 --- a/fallow-baselines/health.json +++ b/fallow-baselines/health.json @@ -25,22 +25,22 @@ "count": 1 } }, - "src/daemon/interaction/internal/find.ts": { + "packages/daemon/src/execution/interaction/internal/find.ts": { "complexity_moderate": { "count": 1 } }, - "src/daemon/handlers/snapshot-settings.ts": { + "packages/daemon/src/execution/handlers/snapshot-settings.ts": { "complexity_moderate": { "count": 1 } }, - "src/daemon/recording-gestures.ts": { + "packages/daemon/src/core/recording-gestures.ts": { "complexity_moderate": { "count": 1 } }, - "src/daemon/session-selector.ts": { + "packages/daemon/src/core/session-selector.ts": { "complexity_moderate": { "count": 1 } @@ -80,13 +80,13 @@ "target_keys": [ "src/daemon-client/daemon-client.ts:high impact", "src/cli/parser/args.ts:high impact", - "src/daemon/lease-context.ts:high impact", + "packages/daemon/src/core/lease-context.ts:high impact", "packages/replay-port/src/daemon-port/session-replay-heal.ts:high impact", - "src/daemon/context.ts:high impact", - "src/daemon/handlers/session.ts:complexity", + "packages/daemon/src/core/context.ts:high impact", + "packages/daemon/src/sessions/handlers/session.ts:complexity", "packages/selectors/src/internal/predicates.ts:high impact", "packages/provision-kit/src/boot-diagnostics.ts:complexity", - "src/daemon/session-routing.ts:high impact", + "packages/daemon/src/sessions/session-routing.ts:high impact", "src/commands/cli-grammar/common.ts:high impact", "packages/kernel/src/success-text.ts:high impact", "src/cli.ts:complexity", @@ -95,8 +95,8 @@ "packages/kernel/src/rect-center.ts:high impact", "packages/platform-apple/src/core/app-launch.ts:complexity", "packages/kernel/src/record.ts:high impact", - "src/daemon/daemon-command-registry.ts:high impact", - "src/daemon/handlers/session-doctor-output.ts:high impact", + "packages/daemon/src/core/daemon-command-registry.ts:high impact", + "packages/daemon/src/sessions/handlers/session-doctor-output.ts:high impact", "packages/platform-apple/src/core/perf-xml.ts:high impact", "src/client/screenshot-result.ts:high impact", "packages/platform-web/src/json-utils.ts:high impact", diff --git a/oxlint.config.ts b/oxlint.config.ts index c2b9e03fa8..e6fd79d90b 100644 --- a/oxlint.config.ts +++ b/oxlint.config.ts @@ -124,7 +124,7 @@ export default defineConfig({ { files: [ 'src/daemon-client/daemon-client-rpc.ts', - 'src/daemon/downloadable-artifact-http.ts', + 'packages/daemon/src/server/downloadable-artifact-http.ts', 'src/remote/remote-request-diagnostics.ts', 'src/remote/upload-stream.ts', ], @@ -135,7 +135,7 @@ export default defineConfig({ }, { files: [ - 'src/daemon/replay/internal/__tests__/session-replay-target-verification-runtime.test.ts', + 'packages/daemon/src/sessions/__tests__/replay-target/session-replay-target-verification-runtime.test.ts', ], rules: { 'unicorn/prefer-string-raw': 'off', diff --git a/package.json b/package.json index b43df4efa5..23706027fb 100644 --- a/package.json +++ b/package.json @@ -293,6 +293,7 @@ "@agent-device/capture-kit": "workspace:*", "@agent-device/command-registry": "workspace:*", "@agent-device/contracts": "workspace:*", + "@agent-device/daemon": "workspace:*", "@agent-device/daemon-contracts": "workspace:*", "@agent-device/device-selection": "workspace:*", "@agent-device/host-kit": "workspace:*", diff --git a/packages/ad-replay/src/internal/__tests__/step-loop.test.ts b/packages/ad-replay/src/internal/__tests__/step-loop.test.ts index bb2ce6a98f..0ab25f33f5 100644 --- a/packages/ad-replay/src/internal/__tests__/step-loop.test.ts +++ b/packages/ad-replay/src/internal/__tests__/step-loop.test.ts @@ -14,7 +14,7 @@ import type { TargetAnnotationV1 } from '@agent-device/contracts/replay'; * `packages/replay-port/src/daemon-port/native-command.ts` (`runReplayCommand`) does. The equivalent * daemon-level assertions (full `SessionStore`/`runReplayCommand` round * trip, including the `--keep-session` live-session postcondition) live in - * `src/daemon/__tests__/replay-runtime/session-replay-runtime-keep-session.test.ts` + * `packages/daemon/src/sessions/__tests__/replay-runtime/session-replay-runtime-keep-session.test.ts` * (renamed from `session-replay-terminal-lifecycle.test.ts` by the #1555 * structural-quality review — see that file's own header for the rationale); * this file covers the SAME suppression decision at the cheaper, diff --git a/packages/ad-script/src/internal/open-script.ts b/packages/ad-script/src/internal/open-script.ts index 63ac8fc755..451e6a2a37 100644 --- a/packages/ad-script/src/internal/open-script.ts +++ b/packages/ad-script/src/internal/open-script.ts @@ -14,7 +14,7 @@ import { * (or falls back to) that accumulation. Two independent daemon/package call * sites needed exactly this scan and, before this move, each carried its own * copy: `packages/ad-replay/src/internal/inspect.ts`'s plan-digest platform - * precedence, and `src/daemon/replay-device-selection.ts`'s + * precedence, and `packages/daemon/src/server/replay-device-selection.ts`'s * `readScriptReplaySelection` (fused into its own single pass alongside an * app-target scan). A `src/` root file cannot become a façade dependency * (R11), and a workspace package may not reach back into root `src/` either diff --git a/packages/capture-kit/src/mobile-snapshot-semantics.test.ts b/packages/capture-kit/src/mobile-snapshot-semantics.test.ts index d5b939df62..c875a2b8da 100644 --- a/packages/capture-kit/src/mobile-snapshot-semantics.test.ts +++ b/packages/capture-kit/src/mobile-snapshot-semantics.test.ts @@ -644,7 +644,7 @@ test('mobile presentation does not let contradictory scroll indicator add hidden }); // #1542: isConfirmedOnScreenProbe is the pure geometry boundary the off-screen -// refusal double-check's direct probe (src/daemon/offscreen-target-probe.ts) +// refusal double-check's direct probe (packages/daemon/src/execution/offscreen-target-probe.ts) // reduces its confirm/don't-confirm decision to, once it has a fresh, // tree-independent read of the target. Each branch below is proved with a // counterfactual per docs/agents/testing.md — see the comment on each test diff --git a/packages/capture-kit/src/mobile-snapshot-semantics.ts b/packages/capture-kit/src/mobile-snapshot-semantics.ts index 23d21cd508..6c121269d0 100644 --- a/packages/capture-kit/src/mobile-snapshot-semantics.ts +++ b/packages/capture-kit/src/mobile-snapshot-semantics.ts @@ -84,7 +84,7 @@ function analyzeMobileSnapshotVisibility(nodes: SnapshotNode[]): { /** * #1542: the pure geometry boundary the off-screen refusal double-check's - * direct probe (`src/daemon/offscreen-target-probe.ts`) reduces its decision + * direct probe (`packages/daemon/src/execution/offscreen-target-probe.ts`) reduces its decision * to, once it has a fresh, tree-independent read of one element. A probe * confirms the element genuinely on-screen only when BOTH hold: XCTest's own * live hit-test says `hittable`, AND the tap point sits inside the root diff --git a/packages/capture-kit/src/snapshot-chrome.ts b/packages/capture-kit/src/snapshot-chrome.ts index 10c897c520..3276987fbc 100644 --- a/packages/capture-kit/src/snapshot-chrome.ts +++ b/packages/capture-kit/src/snapshot-chrome.ts @@ -375,7 +375,7 @@ export function collectSettleChromeRefs( * only excludes nodes whose OWN type is `keyboard` still leaks every key and * assistant control as "discriminating" evidence. * - * Used by `src/daemon/interaction-surface-signature.ts`'s post-gesture + * Used by `packages/daemon/src/core/interaction-surface-signature.ts`'s post-gesture * baseline-distrust discriminating-overlap classification (#1542 defect 2, * #1563 review): that comparison operates on flat signature entries with no * ref-selection budget of its own, so it needs the ref set directly rather diff --git a/packages/command-registry/src/registry.ts b/packages/command-registry/src/registry.ts index 8b0ce02337..a2f8c806e1 100644 --- a/packages/command-registry/src/registry.ts +++ b/packages/command-registry/src/registry.ts @@ -136,7 +136,7 @@ export type DescriptorCatalogRecord = { /** * The literal union of every command whose `daemon.route` is `'session'`. - * Drives `SESSION_COMMAND_HANDLER_IMPLS` in `src/daemon/handlers/session.ts`: adding a + * Drives `SESSION_COMMAND_HANDLER_IMPLS` in `packages/daemon/src/sessions/handlers/session.ts`: adding a * session-routed descriptor without a matching handler table entry is a compile error rather * than a runtime routing gap caught only by `expectHandlerResponse`. */ @@ -165,7 +165,7 @@ export type DescriptorDaemonRouteCommandName = // --------------------------------------------------------------------------- // Daemon request-policy trait bundles — copied VERBATIM from -// src/daemon/daemon-command-registry.ts (DAEMON_COMMAND_DESCRIPTORS). +// packages/daemon/src/core/daemon-command-registry.ts (DAEMON_COMMAND_DESCRIPTORS). // --------------------------------------------------------------------------- const ADMISSION_AND_LOCK_EXEMPT = { @@ -508,7 +508,9 @@ export const RAW_COMMAND_DESCRIPTORS = [ { name: 'human_control', deviceClaimPolicy: 'none', - ...(ownerFilesEnabled ? { ownerFiles: ['src/daemon/handlers/human-control.ts'] as const } : {}), + ...(ownerFilesEnabled + ? { ownerFiles: ['packages/daemon/src/sessions/handlers/human-control.ts'] as const } + : {}), catalog: { group: 'internal', key: 'humanControl' }, recordsSessionAction: false, daemon: { @@ -526,7 +528,9 @@ export const RAW_COMMAND_DESCRIPTORS = [ { name: 'lease_allocate', deviceClaimPolicy: 'none', - ...(ownerFilesEnabled ? { ownerFiles: ['src/daemon/handlers/lease.ts'] as const } : {}), + ...(ownerFilesEnabled + ? { ownerFiles: ['packages/daemon/src/sessions/handlers/lease.ts'] as const } + : {}), catalog: { group: 'internal', key: 'leaseAllocate' }, recordsSessionAction: false, daemon: { @@ -541,7 +545,9 @@ export const RAW_COMMAND_DESCRIPTORS = [ { name: 'lease_heartbeat', deviceClaimPolicy: 'none', - ...(ownerFilesEnabled ? { ownerFiles: ['src/daemon/handlers/lease.ts'] as const } : {}), + ...(ownerFilesEnabled + ? { ownerFiles: ['packages/daemon/src/sessions/handlers/lease.ts'] as const } + : {}), catalog: { group: 'internal', key: 'leaseHeartbeat' }, recordsSessionAction: false, daemon: { @@ -557,7 +563,9 @@ export const RAW_COMMAND_DESCRIPTORS = [ { name: 'lease_release', deviceClaimPolicy: 'none', - ...(ownerFilesEnabled ? { ownerFiles: ['src/daemon/handlers/lease.ts'] as const } : {}), + ...(ownerFilesEnabled + ? { ownerFiles: ['packages/daemon/src/sessions/handlers/lease.ts'] as const } + : {}), catalog: { group: 'internal', key: 'leaseRelease' }, recordsSessionAction: false, daemon: { @@ -592,7 +600,11 @@ export const RAW_COMMAND_DESCRIPTORS = [ name: 'session_list', deviceClaimPolicy: 'none', ...(ownerFilesEnabled - ? { ownerFiles: ['src/daemon/session-lifecycle/internal/inventory.ts'] as const } + ? { + ownerFiles: [ + 'packages/daemon/src/sessions/session-lifecycle/internal/inventory.ts', + ] as const, + } : {}), catalog: { group: 'internal', key: 'sessionList' }, recordsSessionAction: false, @@ -610,7 +622,11 @@ export const RAW_COMMAND_DESCRIPTORS = [ name: 'session_save_script', deviceClaimPolicy: 'none', ...(ownerFilesEnabled - ? { ownerFiles: ['src/daemon/handlers/session-script-publication.ts'] as const } + ? { + ownerFiles: [ + 'packages/daemon/src/sessions/handlers/session-script-publication.ts', + ] as const, + } : {}), catalog: { group: 'internal', key: 'sessionSaveScript' }, recordsSessionAction: false, @@ -887,8 +903,8 @@ export const RAW_COMMAND_DESCRIPTORS = [ ...(ownerFilesEnabled ? { ownerFiles: [ - 'src/daemon/handlers/session-runtime-command.ts', - 'src/daemon/handlers/session-runtime-port-reverse.ts', + 'packages/daemon/src/sessions/handlers/session-runtime-command.ts', + 'packages/daemon/src/sessions/handlers/session-runtime-port-reverse.ts', ] as const, } : {}), @@ -953,7 +969,11 @@ export const RAW_COMMAND_DESCRIPTORS = [ name: 'install_source', deviceClaimPolicy: 'transient-exclusive', ...(ownerFilesEnabled - ? { ownerFiles: ['src/daemon/handlers/session-app-source-deployment.ts'] as const } + ? { + ownerFiles: [ + 'packages/daemon/src/sessions/handlers/session-app-source-deployment.ts', + ] as const, + } : {}), catalog: { group: 'internal', @@ -971,7 +991,11 @@ export const RAW_COMMAND_DESCRIPTORS = [ name: 'release_materialized_paths', deviceClaimPolicy: 'none', ...(ownerFilesEnabled - ? { ownerFiles: ['src/daemon/handlers/session-app-source-deployment.ts'] as const } + ? { + ownerFiles: [ + 'packages/daemon/src/sessions/handlers/session-app-source-deployment.ts', + ] as const, + } : {}), catalog: { group: 'internal', key: 'releaseMaterializedPaths' }, recordsSessionAction: false, @@ -1502,7 +1526,9 @@ export const RAW_COMMAND_DESCRIPTORS = [ }, { name: 'scroll', - ...(ownerFilesEnabled ? { ownerFiles: ['src/daemon/scroll-runtime.ts'] as const } : {}), + ...(ownerFilesEnabled + ? { ownerFiles: ['packages/daemon/src/execution/scroll-runtime.ts'] as const } + : {}), catalog: { group: 'public' }, frameworkTier: 'core', // R53 retires this command's capability bucket and its `dispatch` leaf together: admission is @@ -1551,7 +1577,7 @@ export const RAW_COMMAND_DESCRIPTORS = [ ? { ownerFiles: [ 'src/commands/capture/screenshot.ts', - 'src/daemon/screenshot-runtime.ts', + 'packages/daemon/src/execution/screenshot-runtime.ts', ] as const, } : {}), diff --git a/packages/contracts/src/app-state.ts b/packages/contracts/src/app-state.ts index 746fcc4078..da9e927c37 100644 --- a/packages/contracts/src/app-state.ts +++ b/packages/contracts/src/app-state.ts @@ -3,7 +3,7 @@ import type { SessionSurface } from './session-surface.ts'; /** * Closed result of the `appstate` command, grounded in the daemon handler's - * success returns (src/daemon/handlers/session-appstate.ts `handleAppStateCommand`). + * success returns (packages/daemon/src/sessions/handlers/session-appstate.ts `handleAppStateCommand`). * A discriminated union on `platform`: * - Apple (`ios` / `macos`) session state, with iOS-only device locators that * the previous hand-written mirror omitted; and diff --git a/packages/contracts/src/clipboard.ts b/packages/contracts/src/clipboard.ts index 646acdb99c..0a400bcd7f 100644 --- a/packages/contracts/src/clipboard.ts +++ b/packages/contracts/src/clipboard.ts @@ -1,6 +1,6 @@ /** * Closed result of the `clipboard` command. Mirrors the session runtime's - * literal return exactly (`src/daemon/handlers/session-clipboard.ts`): a + * literal return exactly (`packages/daemon/src/execution/handlers/session-clipboard.ts`): a * discriminated union on `action`. `read` returns the clipboard `text`; `write` * reports the written `textLength` plus the `successText` message. The handler * spreads nothing else, so each branch is closed. diff --git a/packages/contracts/src/device.ts b/packages/contracts/src/device.ts index e135856f58..b4bb813331 100644 --- a/packages/contracts/src/device.ts +++ b/packages/contracts/src/device.ts @@ -8,7 +8,7 @@ import type { TargetShutdownResult } from './target-shutdown-contract.ts'; /** * Closed result of the `boot` command. Mirrors the daemon handler's only - * success return EXACTLY (src/daemon/handlers/session-boot.ts via + * success return EXACTLY (packages/daemon/src/sessions/handlers/session-boot.ts via * session-device-status-response.ts) — the fixed * object literal `{ platform, target, device, id, kind, booted }` plus the * additive `appleOs` discriminant, emitted only for Apple devices. @@ -33,7 +33,7 @@ export type BootCommandResult = { /** * Closed result of the `shutdown` command. Mirrors the daemon handler's success - * return EXACTLY (src/daemon/handlers/session-shutdown.ts via + * return EXACTLY (packages/daemon/src/sessions/handlers/session-shutdown.ts via * session-device-status-response.ts) — the fixed object * literal `{ platform, target, device, id, kind, shutdown }` plus the additive * `appleOs` discriminant (Apple devices only). The `shutdown` field is the raw diff --git a/packages/contracts/src/dispatch-disclosure.fixtures.ts b/packages/contracts/src/dispatch-disclosure.fixtures.ts index 441205541c..bcf8d9ab65 100644 --- a/packages/contracts/src/dispatch-disclosure.fixtures.ts +++ b/packages/contracts/src/dispatch-disclosure.fixtures.ts @@ -38,7 +38,7 @@ export const DISPATCH_DISCLOSURE_TABLE_PATH = path.join( */ export const DISPATCH_DISCLOSURE_DRIVER_OWNERS: Readonly> = { 'daemon.': 'src/__tests__/daemon-composition/interaction/interaction-dispatch-disclosure.test.ts', - 'daemon.scroll-no-progress': 'src/daemon/__tests__/scroll-movement.test.ts', + 'daemon.scroll-no-progress': 'packages/daemon/src/execution/__tests__/scroll-movement.test.ts', 'daemon.route.': 'src/__tests__/daemon-composition/request-dispatch-disclosure.test.ts', 'post-action-guard.': 'src/__tests__/daemon-composition/interaction/interaction-dispatch-disclosure.test.ts', diff --git a/packages/contracts/src/interaction-guarantees.ts b/packages/contracts/src/interaction-guarantees.ts index 59da90fb15..f783faa40e 100644 --- a/packages/contracts/src/interaction-guarantees.ts +++ b/packages/contracts/src/interaction-guarantees.ts @@ -179,7 +179,7 @@ const RUNTIME_TREE_TARGET_STABILITY: GuaranteeEnforcement = { // (interaction-response-construction-guard.test.ts) keeps new branches on it. const SHARED_RESPONSE_CONSTRUCTION: GuaranteeEnforcement = { kind: 'runtime', - via: 'src/daemon/interaction/internal/interaction-touch-response.ts#buildInteractionResponseData', + via: 'packages/daemon/src/execution/interaction/internal/interaction-touch-response.ts#buildInteractionResponseData', }; // runtime-selector, runtime-ref, and coordinate share this waiver: all three finalize through @@ -192,7 +192,7 @@ const TAP_OUTCOME_NOT_OBSERVED_GAP: GuaranteeEnforcement = { trackingIssue: TAP_OUTCOME_NOT_OBSERVED_GAP_ISSUE, }; -// Both Maestro-compatible fast paths (src/daemon/interaction/internal/interaction-touch-direct-ios.ts) +// Both Maestro-compatible fast paths (packages/daemon/src/execution/interaction/internal/interaction-touch-direct-ios.ts) // dispatch ONE fused XCTest runner request (`command: 'tap'` with a selectorKey/selectorValue) built // in packages/platform-apple/src/interactions.ts#tapElementSelector — not the separate // packages/maestro/ flow-script engine, which drives standalone `.yaml` Maestro flows and never @@ -205,7 +205,7 @@ const DIRECT_IOS_SINGLE_QUERY_READINESS: GuaranteeEnforcement = { // Shares the SAME reasoning as TAP_OUTCOME_NOT_OBSERVED_GAP: the tap outcome is not observed on the // success path here either. The shared ambiguous-XCTest-failure corroboration -// (src/daemon/interaction/internal/interaction-ios-tap-outcome.ts#corroborateIosTapFailure) is +// (packages/daemon/src/execution/interaction/internal/interaction-ios-tap-outcome.ts#corroborateIosTapFailure) is // invoked identically from this fast path and from the tree-based runtime dispatch, but only ever // reconsiders a THROWN error — it never validates a call that returned success, so it is not a // baseline outcome claim for either path. @@ -282,7 +282,7 @@ const RUNTIME_TREE_SHARED_GUARANTEES = { responseConstruction: SHARED_RESPONSE_CONSTRUCTION, responseIdentity: { kind: 'runtime', - via: 'src/daemon/interaction/internal/interaction-touch-targets.ts#interactionResultExtra', + via: 'packages/daemon/src/execution/interaction/internal/interaction-touch-targets.ts#interactionResultExtra', }, verifyEvidence: { kind: 'runtime', @@ -390,7 +390,7 @@ export const INTERACTION_DISPATCH_PATHS: Record { vi.mock('@agent-device/device-selection/dispatch-resolve', async (importOriginal) => { const actual = await importOriginal(); - const { selectionFromResolveTargetDevice } = - await import('../../__tests__/device-selection-stub.ts'); + const { selectionFromResolveTargetDevice } = await import('../device-selection-stub.ts'); const resolveTargetDevice = vi.fn(); return { ...actual, @@ -25,7 +24,9 @@ vi.mock('@agent-device/device-selection/dispatch-resolve', async (importOriginal resolveTargetDeviceSelection: vi.fn(selectionFromResolveTargetDevice(resolveTargetDevice)), }; }); -vi.mock('../../device/device-ready.ts', () => ({ ensureDeviceReady: vi.fn(async () => {}) })); +vi.mock('../../../core/device/device-ready.ts', () => ({ + ensureDeviceReady: vi.fn(async () => {}), +})); vi.mock('@agent-device/platform-apple/runner/operations', async (importOriginal) => { const actual = await importOriginal(); @@ -72,23 +73,24 @@ vi.mock('@agent-device/host-kit/command', async (importOriginal) => { const actual = await importOriginal(); return { ...actual, runCmd: vi.fn(async () => ({ stdout: '', stderr: '', exitCode: 0 })) }; }); -vi.mock('../../materialized-path-registry.ts', async (importOriginal) => { - const actual = await importOriginal(); +vi.mock('../../../sessions/materialized-path-registry.ts', async (importOriginal) => { + const actual = + await importOriginal(); return { ...actual, cleanupRetainedMaterializedPathsForSession: vi.fn(async () => {}) }; }); import * as path from 'node:path'; -import { cleanupRetainedMaterializedPathsForSession } from '../../materialized-path-registry.ts'; -import { SessionStore } from '../../session-store.ts'; -import type { DaemonRequest, DaemonResponse } from '../../daemon-request.ts'; -import type { SessionState } from '../../session-state.ts'; +import { cleanupRetainedMaterializedPathsForSession } from '../../../sessions/materialized-path-registry.ts'; +import { SessionStore } from '../../../core/session-store.ts'; +import type { DaemonRequest, DaemonResponse } from '../../../core/daemon-request.ts'; +import type { SessionState } from '../../../core/session-state.ts'; import { resolveTargetDevice } from '@agent-device/device-selection/dispatch-resolve'; -import { ensureDeviceReady } from '../../device/device-ready.ts'; +import { ensureDeviceReady } from '../../../core/device/device-ready.ts'; import { applyRuntimeHintsFixture, clearRuntimeHintsFixture, dispatchApplicationLifecycleEffect, -} from '../../__tests__/application-lifecycle-runtime-fixture.ts'; +} from '../application-lifecycle-runtime-fixture.ts'; import { prepareIosRunner, prewarmAppleRunnerCache, diff --git a/src/daemon/handlers/__tests__/snapshot-handler.fixtures.ts b/packages/daemon/src/__tests__/support/handlers/snapshot-handler.fixtures.ts similarity index 93% rename from src/daemon/handlers/__tests__/snapshot-handler.fixtures.ts rename to packages/daemon/src/__tests__/support/handlers/snapshot-handler.fixtures.ts index a5d350f263..bfda7d8786 100644 --- a/src/daemon/handlers/__tests__/snapshot-handler.fixtures.ts +++ b/packages/daemon/src/__tests__/support/handlers/snapshot-handler.fixtures.ts @@ -7,13 +7,13 @@ import { buildSnapshotSignatures } from '@agent-device/capture-kit/snapshot-fres import type { BindDeviceRuntime, InspectDeviceRuntimeFacts, -} from '../../request-runtime-binding.ts'; -import { snapshotRuntimeFixture } from '../../__tests__/snapshot-runtime-fixture.ts'; -import { SessionStore } from '../../session-store.ts'; -import type { DaemonRequest } from '../../daemon-request.ts'; -import type { SessionState } from '../../session-state.ts'; -import { handleSnapshotCommands as handleProductionSnapshotCommands } from '../snapshot.ts'; -import { platformResourceCleanupFixture } from '../../__tests__/support/platform-resource-cleanup-fixture.ts'; +} from '../../../core/request-runtime-binding.ts'; +import { snapshotRuntimeFixture } from '../snapshot-runtime-fixture.ts'; +import { SessionStore } from '../../../core/session-store.ts'; +import type { DaemonRequest } from '../../../core/daemon-request.ts'; +import type { SessionState } from '../../../core/session-state.ts'; +import { handleSnapshotCommands as handleProductionSnapshotCommands } from '../../../sessions/handlers/snapshot.ts'; +import { platformResourceCleanupFixture } from '../platform-resource-cleanup-fixture.ts'; export function makeSessionStore(): SessionStore { const root = mkdtempForTestSync('agent-device-snapshot-handler-'); diff --git a/src/daemon/__tests__/support/host-diagnostics-fixture.ts b/packages/daemon/src/__tests__/support/host-diagnostics-fixture.ts similarity index 100% rename from src/daemon/__tests__/support/host-diagnostics-fixture.ts rename to packages/daemon/src/__tests__/support/host-diagnostics-fixture.ts diff --git a/src/daemon/__tests__/human-control-fixtures.ts b/packages/daemon/src/__tests__/support/human-control-fixtures.ts similarity index 92% rename from src/daemon/__tests__/human-control-fixtures.ts rename to packages/daemon/src/__tests__/support/human-control-fixtures.ts index b5c2a9b5ff..3a117db731 100644 --- a/src/daemon/__tests__/human-control-fixtures.ts +++ b/packages/daemon/src/__tests__/support/human-control-fixtures.ts @@ -1,7 +1,7 @@ import type { HumanControlHold, HumanControlHoldScope } from '@agent-device/contracts/client'; import type { DeviceLease } from '@agent-device/contracts/device'; -import type { AllocateLeaseRequest } from '../lease-registry-scope.ts'; -import type { DaemonRequest } from '../daemon-request.ts'; +import type { AllocateLeaseRequest } from '../../resources/lease-registry-scope.ts'; +import type { DaemonRequest } from '../../core/daemon-request.ts'; import { AppError } from '@agent-device/kernel/errors'; export const HUMAN_CONTROL_SCOPE: HumanControlHoldScope = { diff --git a/src/daemon/__tests__/human-control-router-fixture.ts b/packages/daemon/src/__tests__/support/human-control-router-fixture.ts similarity index 73% rename from src/daemon/__tests__/human-control-router-fixture.ts rename to packages/daemon/src/__tests__/support/human-control-router-fixture.ts index 095fa4d8fb..54ed1c1295 100644 --- a/src/daemon/__tests__/human-control-router-fixture.ts +++ b/packages/daemon/src/__tests__/support/human-control-router-fixture.ts @@ -3,16 +3,16 @@ import { daemonPlatformServicesFixture, daemonClaimRecoveryGatewayFixture, } from './platform-services-fixture.ts'; -import { makeIosAppSession } from './support/session-factories.ts'; -import { makeSessionStore } from './support/store-factory.ts'; -import { buildSessionLeaseFromRequest } from '../lease-context.ts'; -import { LeaseRegistry } from '../lease-registry.ts'; -import { createRequestHandler } from '../request-router.ts'; -import { providerCredentialsFixture } from './support/provider-credentials-fixture.ts'; -import { tenantScopedSessionName } from '../session-tenant-scope.ts'; +import { makeIosAppSession } from './session-factories.ts'; +import { makeSessionStore } from './store-factory.ts'; +import { buildSessionLeaseFromRequest } from '../../core/lease-context.ts'; +import { LeaseRegistry } from '../../resources/lease-registry.ts'; +import { createRequestHandler } from '../../server/request-router.ts'; +import { providerCredentialsFixture } from './provider-credentials-fixture.ts'; +import { tenantScopedSessionName } from '../../core/session-tenant-scope.ts'; import { lifecycleDeviceRuntimeGateway } from './test-device-runtime-gateway.ts'; import { HUMAN_CONTROL_LEASE_REQUEST, humanControlRequest } from './human-control-fixtures.ts'; -import { fakeCreateCommandSurface } from './support/command-surface-fake.ts'; +import { fakeCreateCommandSurface } from './command-surface-fake.ts'; export function createHumanControlHarness() { const registry = new LeaseRegistry(); diff --git a/src/daemon/__tests__/legacy-snapshot-capture-fixture.ts b/packages/daemon/src/__tests__/support/legacy-snapshot-capture-fixture.ts similarity index 96% rename from src/daemon/__tests__/legacy-snapshot-capture-fixture.ts rename to packages/daemon/src/__tests__/support/legacy-snapshot-capture-fixture.ts index a206866f21..8979396f22 100644 --- a/src/daemon/__tests__/legacy-snapshot-capture-fixture.ts +++ b/packages/daemon/src/__tests__/support/legacy-snapshot-capture-fixture.ts @@ -1,7 +1,7 @@ import { vi } from 'vitest'; import type { DeviceInfo } from '@agent-device/kernel/device'; import type { SnapshotResult } from '@agent-device/contracts/interactor-types'; -import type { captureSnapshotWithInteractor } from '../snapshot-interactor-capture.ts'; +import type { captureSnapshotWithInteractor } from '../../core/snapshot-interactor-capture.ts'; type CaptureParams = Parameters[0]; diff --git a/src/daemon/__tests__/support/platform-resource-cleanup-fixture.ts b/packages/daemon/src/__tests__/support/platform-resource-cleanup-fixture.ts similarity index 95% rename from src/daemon/__tests__/support/platform-resource-cleanup-fixture.ts rename to packages/daemon/src/__tests__/support/platform-resource-cleanup-fixture.ts index c97551d7f5..1a8b0c7edd 100644 --- a/src/daemon/__tests__/support/platform-resource-cleanup-fixture.ts +++ b/packages/daemon/src/__tests__/support/platform-resource-cleanup-fixture.ts @@ -1,5 +1,5 @@ import { vi, type Mock } from 'vitest'; -import type { PlatformResourceCleanup } from '../../platform-resource-cleanup.ts'; +import type { PlatformResourceCleanup } from '../../core/platform-resource-cleanup.ts'; /** Every member observable as a spy, which is how the daemon suites read the fixture back. */ export type PlatformResourceCleanupFixture = { diff --git a/src/daemon/__tests__/platform-services-fixture.ts b/packages/daemon/src/__tests__/support/platform-services-fixture.ts similarity index 94% rename from src/daemon/__tests__/platform-services-fixture.ts rename to packages/daemon/src/__tests__/support/platform-services-fixture.ts index 62dc9ae641..8a1aad0e95 100644 --- a/src/daemon/__tests__/platform-services-fixture.ts +++ b/packages/daemon/src/__tests__/support/platform-services-fixture.ts @@ -2,9 +2,9 @@ import { vi } from 'vitest'; import type { DeviceInfo } from '@agent-device/kernel/device'; import type { SessionSurface } from '@agent-device/contracts/session'; import type { DeviceBootObservation } from '@agent-device/contracts/device-boot'; -import type { ClaimRecoveryGatewayFactory } from '../device/claim-recovery-gateway.ts'; -import type { DaemonPlatformServices } from '../platform-services.ts'; -import { unavailableDeviceRuntimeGateway } from './support/unavailable-device-runtime-gateway.ts'; +import type { ClaimRecoveryGatewayFactory } from '../../resources/device/claim-recovery-gateway.ts'; +import type { DaemonPlatformServices } from '../../core/platform-services.ts'; +import { unavailableDeviceRuntimeGateway } from './unavailable-device-runtime-gateway.ts'; /** * The `DaemonPlatformServices` port as the daemon suites answer it: every member is a plain diff --git a/src/daemon/__tests__/support/provider-credentials-fixture.ts b/packages/daemon/src/__tests__/support/provider-credentials-fixture.ts similarity index 100% rename from src/daemon/__tests__/support/provider-credentials-fixture.ts rename to packages/daemon/src/__tests__/support/provider-credentials-fixture.ts diff --git a/src/daemon/__tests__/support/provider-device-admission-fixture.ts b/packages/daemon/src/__tests__/support/provider-device-admission-fixture.ts similarity index 92% rename from src/daemon/__tests__/support/provider-device-admission-fixture.ts rename to packages/daemon/src/__tests__/support/provider-device-admission-fixture.ts index 6ddbaa6c54..f48d53eee7 100644 --- a/src/daemon/__tests__/support/provider-device-admission-fixture.ts +++ b/packages/daemon/src/__tests__/support/provider-device-admission-fixture.ts @@ -1,6 +1,6 @@ import type { ProviderDeviceRuntime } from '@agent-device/contracts/device'; import type { DeviceInfo } from '@agent-device/kernel/device'; -import { installProviderDeviceAdmission } from '../../provider-device-admission.ts'; +import { installProviderDeviceAdmission } from '../../core/provider-device-admission.ts'; /** * Provider ownership as the daemon consumes it: the `ProviderDeviceAdmission` port over a list diff --git a/src/daemon/__tests__/request-router-dispatch-mocks.ts b/packages/daemon/src/__tests__/support/request-router-dispatch-mocks.ts similarity index 66% rename from src/daemon/__tests__/request-router-dispatch-mocks.ts rename to packages/daemon/src/__tests__/support/request-router-dispatch-mocks.ts index aff97cea5c..6f1e95bd18 100644 --- a/src/daemon/__tests__/request-router-dispatch-mocks.ts +++ b/packages/daemon/src/__tests__/support/request-router-dispatch-mocks.ts @@ -1,7 +1,10 @@ -import { vi } from 'vitest'; +import { vi, type Mock } from 'vitest'; +// The explicit Mock annotation is what lets the daemon package's composite project emit +// this fixture's declaration; the inferred vi.fn() type names @vitest/spy internals that +// are not importable from the emitted .d.ts (TS2883) — the capture-kit fixtures' pattern. const dispatchMocks = vi.hoisted(() => ({ - resolveTargetDevice: vi.fn(), + resolveTargetDevice: vi.fn() as Mock, })); vi.mock('@agent-device/device-selection/dispatch-resolve', async (importOriginal) => { diff --git a/src/daemon/__tests__/runtime-binding-conformance.ts b/packages/daemon/src/__tests__/support/runtime-binding-conformance.ts similarity index 89% rename from src/daemon/__tests__/runtime-binding-conformance.ts rename to packages/daemon/src/__tests__/support/runtime-binding-conformance.ts index f7f5294998..6bbdfe1025 100644 --- a/src/daemon/__tests__/runtime-binding-conformance.ts +++ b/packages/daemon/src/__tests__/support/runtime-binding-conformance.ts @@ -13,30 +13,30 @@ import { commandRuntimeUseRequirements, } from '@agent-device/command-registry/registry'; import { createUnavailableRuntimeFactsForTest } from '@agent-device/test-kit/runtime-operation-facts'; -import { makeSession } from './support/session-factories.ts'; -import { makeSessionStore } from './support/store-factory.ts'; -import { resolveBoundBackRuntime } from '../back-runtime.ts'; -import { resolveBoundFocusRuntime } from '../focus-runtime.ts'; -import { resolveBoundFoldRuntime } from '../fold-runtime.ts'; -import { resolveBoundGestureRuntime } from '../gesture-runtime.ts'; -import { resolveBoundOrientationRuntime } from '../orientation-runtime.ts'; -import type { ResolvedGenericExecution } from '../generic-leaf-execution.ts'; +import { makeSession } from './session-factories.ts'; +import { makeSessionStore } from './store-factory.ts'; +import { resolveBoundBackRuntime } from '../../execution/back-runtime.ts'; +import { resolveBoundFocusRuntime } from '../../execution/focus-runtime.ts'; +import { resolveBoundFoldRuntime } from '../../execution/fold-runtime.ts'; +import { resolveBoundGestureRuntime } from '../../core/gesture-runtime.ts'; +import { resolveBoundOrientationRuntime } from '../../execution/orientation-runtime.ts'; +import type { ResolvedGenericExecution } from '../../core/generic-leaf-execution.ts'; import type { BindDeviceRuntime, InspectDeviceRuntimeFacts, RuntimeAdmissionBindings, -} from '../request-runtime-binding.ts'; -import { dispatchSnapshotDiffViaRuntime } from '../snapshot-diff-runtime.ts'; +} from '../../core/request-runtime-binding.ts'; +import { dispatchSnapshotDiffViaRuntime } from '../../sessions/snapshot-diff-runtime.ts'; import { isSystemButtonCommand, resolveBoundSystemButtonRuntime, type SystemButtonCommand, -} from '../system-button-runtime.ts'; -import { resolveBoundTvRemoteRuntime } from '../tv-remote-runtime.ts'; -import { resolveBoundTypeTextRuntime } from '../type-text-runtime.ts'; -import { resolveBoundViewportRuntime } from '../viewport-runtime.ts'; +} from '../../execution/system-button-runtime.ts'; +import { resolveBoundTvRemoteRuntime } from '../../execution/tv-remote-runtime.ts'; +import { resolveBoundTypeTextRuntime } from '../../execution/type-text-runtime.ts'; +import { resolveBoundViewportRuntime } from '../../execution/viewport-runtime.ts'; import type { DaemonFailureResponse } from '@agent-device/kernel/contracts'; -import { fakeCreateCommandSurface } from './support/command-surface-fake.ts'; +import { fakeCreateCommandSurface } from './command-surface-fake.ts'; type RuntimeOperation = RuntimeOperationKey; diff --git a/src/daemon/__tests__/support/screen-recording-live-handle.ts b/packages/daemon/src/__tests__/support/screen-recording-live-handle.ts similarity index 96% rename from src/daemon/__tests__/support/screen-recording-live-handle.ts rename to packages/daemon/src/__tests__/support/screen-recording-live-handle.ts index 7276477b0a..de62056477 100644 --- a/src/daemon/__tests__/support/screen-recording-live-handle.ts +++ b/packages/daemon/src/__tests__/support/screen-recording-live-handle.ts @@ -5,7 +5,7 @@ import { import { localRuntimeOwner } from '@agent-device/contracts/platform-runtime'; import type { ScreenRecordingLiveSnapshot } from '@agent-device/contracts/screen-recording-runtime'; import { deviceIdentity } from '@agent-device/kernel/device'; -import type { SessionState } from '../../session-state.ts'; +import type { SessionState } from '../../core/session-state.ts'; type ScreenRecordingOverrides = Partial; diff --git a/src/daemon/__tests__/screenshot-runtime-fixture.ts b/packages/daemon/src/__tests__/support/screenshot-runtime-fixture.ts similarity index 96% rename from src/daemon/__tests__/screenshot-runtime-fixture.ts rename to packages/daemon/src/__tests__/support/screenshot-runtime-fixture.ts index 4049fbfb9f..7a26db4796 100644 --- a/src/daemon/__tests__/screenshot-runtime-fixture.ts +++ b/packages/daemon/src/__tests__/support/screenshot-runtime-fixture.ts @@ -20,8 +20,11 @@ import { deviceShape, type DeviceInfo } from '@agent-device/kernel/device'; import fs from 'node:fs'; import { vi, type Mock } from 'vitest'; import { PNG } from '@agent-device/capture-kit/png'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts'; -import { unavailableDeviceRuntimeGateway } from './support/unavailable-device-runtime-gateway.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../../core/request-runtime-binding.ts'; +import { unavailableDeviceRuntimeGateway } from './unavailable-device-runtime-gateway.ts'; import { type TapPointInput, touchRuntimeOperationFacts, diff --git a/src/daemon/__tests__/selector-capture-fixture.ts b/packages/daemon/src/__tests__/support/selector-capture-fixture.ts similarity index 92% rename from src/daemon/__tests__/selector-capture-fixture.ts rename to packages/daemon/src/__tests__/support/selector-capture-fixture.ts index 1cd6bf5998..08f8cf8a56 100644 --- a/src/daemon/__tests__/selector-capture-fixture.ts +++ b/packages/daemon/src/__tests__/support/selector-capture-fixture.ts @@ -12,9 +12,12 @@ import { snapshotRuntimeOperationFacts, } from '@agent-device/contracts/snapshot-runtime'; import { deviceShape, type DeviceInfo } from '@agent-device/kernel/device'; -import { isActiveProviderDevice } from '../provider-device-admission.ts'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts'; -import { unavailableDeviceRuntimeGateway } from './support/unavailable-device-runtime-gateway.ts'; +import { isActiveProviderDevice } from '../../core/provider-device-admission.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../../core/request-runtime-binding.ts'; +import { unavailableDeviceRuntimeGateway } from './unavailable-device-runtime-gateway.ts'; const available: RuntimeOperationFact = Object.freeze({ available: true }); diff --git a/src/daemon/__tests__/support/session-factories.ts b/packages/daemon/src/__tests__/support/session-factories.ts similarity index 97% rename from src/daemon/__tests__/support/session-factories.ts rename to packages/daemon/src/__tests__/support/session-factories.ts index ad7dcb43c6..546a6d8f29 100644 --- a/src/daemon/__tests__/support/session-factories.ts +++ b/packages/daemon/src/__tests__/support/session-factories.ts @@ -1,8 +1,8 @@ -import type { SessionState } from '../../session-state.ts'; +import type { SessionState } from '../../core/session-state.ts'; import type { SessionScriptPublicationState, SessionScriptRepairStatus, -} from '../../session-script-publication-state.ts'; +} from '../../core/session-script-publication-state.ts'; import { IOS_SIMULATOR, ANDROID_EMULATOR, diff --git a/src/daemon/session-observability/internal/__tests__/network-runtime-harness.ts b/packages/daemon/src/__tests__/support/session-observability/internal/network-runtime-harness.ts similarity index 97% rename from src/daemon/session-observability/internal/__tests__/network-runtime-harness.ts rename to packages/daemon/src/__tests__/support/session-observability/internal/network-runtime-harness.ts index cd88cad1c0..06ac4a6cfd 100644 --- a/src/daemon/session-observability/internal/__tests__/network-runtime-harness.ts +++ b/packages/daemon/src/__tests__/support/session-observability/internal/network-runtime-harness.ts @@ -10,7 +10,7 @@ import { import type { PlatformRuntimeOperations } from '@agent-device/contracts/platform-runtime-operations'; import { unavailableDeploymentSnapshotAndShutdownOperationFacts } from '@agent-device/test-kit/runtime-operation-facts'; import type { DeviceInfo } from '@agent-device/kernel/device'; -import type { BindDeviceRuntime } from '../../../request-runtime-binding.ts'; +import type { BindDeviceRuntime } from '../../../../core/request-runtime-binding.ts'; export function createNetworkRuntime( device: DeviceInfo, diff --git a/src/daemon/__tests__/session-teardown.fixtures.ts b/packages/daemon/src/__tests__/support/session-teardown.fixtures.ts similarity index 94% rename from src/daemon/__tests__/session-teardown.fixtures.ts rename to packages/daemon/src/__tests__/support/session-teardown.fixtures.ts index 94b56f37af..77c4b499a2 100644 --- a/src/daemon/__tests__/session-teardown.fixtures.ts +++ b/packages/daemon/src/__tests__/support/session-teardown.fixtures.ts @@ -4,8 +4,8 @@ import type { ScreenRecordingLiveHandle } from '@agent-device/contracts/screen-r import { createDurableResourceEnvelope } from '@agent-device/capture-kit'; import { WEB_DESKTOP_DEVICE } from '@agent-device/test-kit/device-fixtures'; import { screenRecordingResourceStore } from '@agent-device/capture-kit/screen-recording-resource-store'; -import type { SessionStore } from '../session-store.ts'; -import type { SessionState } from '../session-state.ts'; +import type { SessionStore } from '../../core/session-store.ts'; +import type { SessionState } from '../../core/session-state.ts'; export function makeRecordingSession(params: { name: string; diff --git a/src/daemon/__tests__/snapshot-runtime-fixture.ts b/packages/daemon/src/__tests__/support/snapshot-runtime-fixture.ts similarity index 96% rename from src/daemon/__tests__/snapshot-runtime-fixture.ts rename to packages/daemon/src/__tests__/support/snapshot-runtime-fixture.ts index e97687d0fe..ecedbc69cf 100644 --- a/src/daemon/__tests__/snapshot-runtime-fixture.ts +++ b/packages/daemon/src/__tests__/support/snapshot-runtime-fixture.ts @@ -6,7 +6,7 @@ import { } from '@agent-device/contracts/platform-runtime'; import type { PlatformRuntimeOperations } from '@agent-device/contracts/platform-runtime-operations'; import { daemonPlatformServicesFixture } from './platform-services-fixture.ts'; -import type { DaemonPlatformServices } from '../platform-services.ts'; +import type { DaemonPlatformServices } from '../../core/platform-services.ts'; import { legacyDispatchCapture } from './legacy-snapshot-capture-fixture.ts'; import { type AlertRuntimeInput, @@ -37,11 +37,14 @@ import { } from '@agent-device/kernel/device'; import { applePlugin } from '@agent-device/platform-apple'; import { textSizeSettingPayload } from '@agent-device/contracts/settings'; -import { type DispatchContext } from '../dispatch-context.ts'; +import { type DispatchContext } from '../../core/dispatch-context.ts'; import { getRequestSignal } from '@agent-device/host-kit/request'; -import { isActiveProviderDevice } from '../provider-device-admission.ts'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts'; -import { unavailableDeviceRuntimeGateway } from './support/unavailable-device-runtime-gateway.ts'; +import { isActiveProviderDevice } from '../../core/provider-device-admission.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../../core/request-runtime-binding.ts'; +import { unavailableDeviceRuntimeGateway } from './unavailable-device-runtime-gateway.ts'; import { writeSolidPng } from './screenshot-runtime-fixture.ts'; /** diff --git a/src/daemon/__tests__/support/store-factory.ts b/packages/daemon/src/__tests__/support/store-factory.ts similarity index 86% rename from src/daemon/__tests__/support/store-factory.ts rename to packages/daemon/src/__tests__/support/store-factory.ts index 0c5bf00423..4ad650155d 100644 --- a/src/daemon/__tests__/support/store-factory.ts +++ b/packages/daemon/src/__tests__/support/store-factory.ts @@ -1,7 +1,7 @@ import path from 'node:path'; -import { SessionStore } from '../../session-store.ts'; +import { SessionStore } from '../../core/session-store.ts'; import { mkdtempForTestSync } from '@agent-device/test-kit/tmp-dir'; -import type { SessionRef, SessionState } from '../../session-state.ts'; +import type { SessionRef, SessionState } from '../../core/session-state.ts'; export function makeSessionStore(prefix = 'agent-device-test-'): SessionStore { const tempRoot = mkdtempForTestSync(prefix); diff --git a/src/daemon/__tests__/test-device-runtime-gateway.ts b/packages/daemon/src/__tests__/support/test-device-runtime-gateway.ts similarity index 95% rename from src/daemon/__tests__/test-device-runtime-gateway.ts rename to packages/daemon/src/__tests__/support/test-device-runtime-gateway.ts index d4b604d099..13ea6b5f15 100644 --- a/src/daemon/__tests__/test-device-runtime-gateway.ts +++ b/packages/daemon/src/__tests__/support/test-device-runtime-gateway.ts @@ -17,8 +17,8 @@ import type { ScrollDirectionInput } from '@agent-device/contracts/scroll-runtim import { createRequestHandler as createProductionRequestHandler, type RequestRouterDeps, -} from '../request-router.ts'; -import type { BindDeviceRuntime } from '../request-runtime-binding.ts'; +} from '../../server/request-router.ts'; +import type { BindDeviceRuntime } from '../../core/request-runtime-binding.ts'; import type { DeviceInfo } from '@agent-device/kernel/device'; import { applicationLifecycleRuntimeFixture, @@ -26,18 +26,18 @@ import { } from './application-lifecycle-runtime-fixture.ts'; import { createUnavailableRuntimeFactsForTest } from '@agent-device/test-kit/runtime-operation-facts'; import { withClientReplayScriptSources } from '@agent-device/replay-port/replay-script-source-fixtures'; -import type { DaemonInvokeFn } from '../daemon-request.ts'; +import type { DaemonInvokeFn } from '../../core/daemon-request.ts'; import { clearAndroidObservationFixture } from './android-observation-fixture.ts'; import { daemonClaimRecoveryGatewayFixture, daemonPlatformServicesFixture, } from './platform-services-fixture.ts'; -import { platformResourceCleanupFixture } from './support/platform-resource-cleanup-fixture.ts'; -import { providerCredentialsFixture } from './support/provider-credentials-fixture.ts'; +import { platformResourceCleanupFixture } from './platform-resource-cleanup-fixture.ts'; +import { providerCredentialsFixture } from './provider-credentials-fixture.ts'; import { unavailableBinding, unavailableDeviceRuntimeGateway, -} from './support/unavailable-device-runtime-gateway.ts'; +} from './unavailable-device-runtime-gateway.ts'; const unavailable = Object.freeze({ available: false as const, diff --git a/src/daemon/__tests__/support/unavailable-device-runtime-gateway.ts b/packages/daemon/src/__tests__/support/unavailable-device-runtime-gateway.ts similarity index 95% rename from src/daemon/__tests__/support/unavailable-device-runtime-gateway.ts rename to packages/daemon/src/__tests__/support/unavailable-device-runtime-gateway.ts index 84665a6fda..2426053d8f 100644 --- a/src/daemon/__tests__/support/unavailable-device-runtime-gateway.ts +++ b/packages/daemon/src/__tests__/support/unavailable-device-runtime-gateway.ts @@ -6,7 +6,10 @@ import { import type { PlatformRuntimeOperations } from '@agent-device/contracts/platform-runtime-operations'; import type { DeviceInfo } from '@agent-device/kernel/device'; import { createUnavailableRuntimeFactsForTest } from '@agent-device/test-kit/runtime-operation-facts'; -import type { BindDeviceRuntime, BindExactDeviceRuntime } from '../../request-runtime-binding.ts'; +import type { + BindDeviceRuntime, + BindExactDeviceRuntime, +} from '../../core/request-runtime-binding.ts'; /** * The `DeviceRuntimeGateway` port answering that no owner on this host can bind the device: diff --git a/src/daemon/__tests__/audio-probe-resource-recovery.test.ts b/packages/daemon/src/core/__tests__/audio-probe-resource-recovery.test.ts similarity index 100% rename from src/daemon/__tests__/audio-probe-resource-recovery.test.ts rename to packages/daemon/src/core/__tests__/audio-probe-resource-recovery.test.ts diff --git a/src/daemon/__tests__/capture-disclosure-target-activation-fact.ts b/packages/daemon/src/core/__tests__/capture-disclosure-target-activation-fact.ts similarity index 100% rename from src/daemon/__tests__/capture-disclosure-target-activation-fact.ts rename to packages/daemon/src/core/__tests__/capture-disclosure-target-activation-fact.ts diff --git a/src/daemon/__tests__/capture-disclosure-target-activation.test.ts b/packages/daemon/src/core/__tests__/capture-disclosure-target-activation.test.ts similarity index 100% rename from src/daemon/__tests__/capture-disclosure-target-activation.test.ts rename to packages/daemon/src/core/__tests__/capture-disclosure-target-activation.test.ts diff --git a/src/daemon/__tests__/config.test.ts b/packages/daemon/src/core/__tests__/config.test.ts similarity index 100% rename from src/daemon/__tests__/config.test.ts rename to packages/daemon/src/core/__tests__/config.test.ts diff --git a/src/daemon/__tests__/context.test.ts b/packages/daemon/src/core/__tests__/context.test.ts similarity index 100% rename from src/daemon/__tests__/context.test.ts rename to packages/daemon/src/core/__tests__/context.test.ts diff --git a/src/daemon/__tests__/daemon-command-registry.test.ts b/packages/daemon/src/core/__tests__/daemon-command-registry.test.ts similarity index 100% rename from src/daemon/__tests__/daemon-command-registry.test.ts rename to packages/daemon/src/core/__tests__/daemon-command-registry.test.ts diff --git a/src/daemon/__tests__/daemon-policy.test.ts b/packages/daemon/src/core/__tests__/daemon-policy.test.ts similarity index 95% rename from src/daemon/__tests__/daemon-policy.test.ts rename to packages/daemon/src/core/__tests__/daemon-policy.test.ts index 5e5746003f..cf1557a2a5 100644 --- a/src/daemon/__tests__/daemon-policy.test.ts +++ b/packages/daemon/src/core/__tests__/daemon-policy.test.ts @@ -1,27 +1,27 @@ import fs from 'node:fs'; import path from 'node:path'; import { beforeEach, expect, test, vi } from 'vitest'; -import { getResolveTargetDeviceMock } from './request-router-dispatch-mocks.ts'; -import { fakeCreateCommandSurface } from './support/command-surface-fake.ts'; +import { getResolveTargetDeviceMock } from '../../__tests__/support/request-router-dispatch-mocks.ts'; +import { fakeCreateCommandSurface } from '../../__tests__/support/command-surface-fake.ts'; vi.mock('../device/device-ready.ts', () => ({ ensureDeviceReady: vi.fn(async () => {}) })); import type { DeviceInfo } from '@agent-device/kernel/device'; import { ANDROID_EMULATOR, IOS_SIMULATOR } from '@agent-device/test-kit/device-fixtures'; import { createTestDeviceInventoryGateways } from '@agent-device/device-selection/inventory-gateways-fixtures'; -import { makeIosSession } from './support/session-factories.ts'; -import { makeSessionStore } from './support/store-factory.ts'; +import { makeIosSession } from '../../__tests__/support/session-factories.ts'; +import { makeSessionStore } from '../../__tests__/support/store-factory.ts'; import { mkdtempForTestSync } from '@agent-device/test-kit/tmp-dir'; import { parseDaemonPolicy } from '@agent-device/daemon-contracts/daemon-policy-file'; import { assertDaemonPolicyAdmitsRequest } from '../daemon-policy.ts'; import type { DaemonRequest } from '../daemon-request.ts'; -import { LeaseRegistry } from '../lease-registry.ts'; -import { hostDiagnosticsFixture } from './support/host-diagnostics-fixture.ts'; +import { LeaseRegistry } from '../../resources/lease-registry.ts'; +import { hostDiagnosticsFixture } from '../../__tests__/support/host-diagnostics-fixture.ts'; import { createRequestHandler, lifecycleDeviceRuntimeGateway, systemRuntimeSpies, -} from './test-device-runtime-gateway.ts'; +} from '../../__tests__/support/test-device-runtime-gateway.ts'; const mockResolveTargetDevice = vi.mocked(getResolveTargetDeviceMock()); const OTHER_SIMULATOR: DeviceInfo = { ...IOS_SIMULATOR, id: 'sim-2', name: 'iPhone 16' }; diff --git a/src/daemon/__tests__/daemon-request-wire.test.ts b/packages/daemon/src/core/__tests__/daemon-request-wire.test.ts similarity index 100% rename from src/daemon/__tests__/daemon-request-wire.test.ts rename to packages/daemon/src/core/__tests__/daemon-request-wire.test.ts diff --git a/src/daemon/__tests__/deferred-interaction-outcome.test.ts b/packages/daemon/src/core/__tests__/deferred-interaction-outcome.test.ts similarity index 100% rename from src/daemon/__tests__/deferred-interaction-outcome.test.ts rename to packages/daemon/src/core/__tests__/deferred-interaction-outcome.test.ts diff --git a/src/daemon/__tests__/direct-ios-selector.test.ts b/packages/daemon/src/core/__tests__/direct-ios-selector.test.ts similarity index 100% rename from src/daemon/__tests__/direct-ios-selector.test.ts rename to packages/daemon/src/core/__tests__/direct-ios-selector.test.ts diff --git a/src/daemon/__tests__/execution-plan.test.ts b/packages/daemon/src/core/__tests__/execution-plan.test.ts similarity index 95% rename from src/daemon/__tests__/execution-plan.test.ts rename to packages/daemon/src/core/__tests__/execution-plan.test.ts index 75f41c0544..0a9481930d 100644 --- a/src/daemon/__tests__/execution-plan.test.ts +++ b/packages/daemon/src/core/__tests__/execution-plan.test.ts @@ -1,7 +1,7 @@ import { test } from 'vitest'; import assert from 'node:assert/strict'; import { resolvePlannedOperations } from '../execution-plan.ts'; -import { runBatchCommands } from '../handlers/session-batch.ts'; +import { runBatchCommands } from '../../sessions/handlers/session-batch.ts'; import type { DaemonRequest } from '../daemon-request.ts'; test('an open that ends its batch has an unknown future', () => { diff --git a/src/daemon/__tests__/interaction-surface-signature.test.ts b/packages/daemon/src/core/__tests__/interaction-surface-signature.test.ts similarity index 99% rename from src/daemon/__tests__/interaction-surface-signature.test.ts rename to packages/daemon/src/core/__tests__/interaction-surface-signature.test.ts index e2100079c3..5f27716f3a 100644 --- a/src/daemon/__tests__/interaction-surface-signature.test.ts +++ b/packages/daemon/src/core/__tests__/interaction-surface-signature.test.ts @@ -226,7 +226,7 @@ test('classifyBaselineSurfaceEvidence excludes keyboard DESCENDANTS and window S /** * A keyboard-window subtree: a `[Keyboard]` container plus a SIBLING "Next * keyboard" assistant button under the same window — matches the shape in - * `src/daemon/__tests__/post-gesture-stabilization-fixtures.ts`'s + * `packages/daemon/src/core/__tests__/post-gesture-stabilization-fixtures.ts`'s * `keyboardWindowNodes` (kept local here rather than imported: this file's * fixtures are raw node literals consumed directly by * `buildInteractionSurfaceSignature`, not `SnapshotState`-wrapped like that diff --git a/src/daemon/__tests__/interactor-resolution.test.ts b/packages/daemon/src/core/__tests__/interactor-resolution.test.ts similarity index 100% rename from src/daemon/__tests__/interactor-resolution.test.ts rename to packages/daemon/src/core/__tests__/interactor-resolution.test.ts diff --git a/src/daemon/__tests__/ios-comparison-key-fixture.ts b/packages/daemon/src/core/__tests__/ios-comparison-key-fixture.ts similarity index 100% rename from src/daemon/__tests__/ios-comparison-key-fixture.ts rename to packages/daemon/src/core/__tests__/ios-comparison-key-fixture.ts diff --git a/src/daemon/__tests__/is-predicates.test.ts b/packages/daemon/src/core/__tests__/is-predicates.test.ts similarity index 100% rename from src/daemon/__tests__/is-predicates.test.ts rename to packages/daemon/src/core/__tests__/is-predicates.test.ts diff --git a/src/daemon/__tests__/lease-context.test.ts b/packages/daemon/src/core/__tests__/lease-context.test.ts similarity index 100% rename from src/daemon/__tests__/lease-context.test.ts rename to packages/daemon/src/core/__tests__/lease-context.test.ts diff --git a/src/daemon/__tests__/managed-session-artifact-path.test.ts b/packages/daemon/src/core/__tests__/managed-session-artifact-path.test.ts similarity index 100% rename from src/daemon/__tests__/managed-session-artifact-path.test.ts rename to packages/daemon/src/core/__tests__/managed-session-artifact-path.test.ts diff --git a/src/daemon/__tests__/moving-target-baseline.test.ts b/packages/daemon/src/core/__tests__/moving-target-baseline.test.ts similarity index 100% rename from src/daemon/__tests__/moving-target-baseline.test.ts rename to packages/daemon/src/core/__tests__/moving-target-baseline.test.ts diff --git a/src/daemon/__tests__/post-gesture-no-effect-claim.test.ts b/packages/daemon/src/core/__tests__/post-gesture-no-effect-claim.test.ts similarity index 100% rename from src/daemon/__tests__/post-gesture-no-effect-claim.test.ts rename to packages/daemon/src/core/__tests__/post-gesture-no-effect-claim.test.ts diff --git a/src/daemon/__tests__/post-gesture-stabilization-fixtures.ts b/packages/daemon/src/core/__tests__/post-gesture-stabilization-fixtures.ts similarity index 100% rename from src/daemon/__tests__/post-gesture-stabilization-fixtures.ts rename to packages/daemon/src/core/__tests__/post-gesture-stabilization-fixtures.ts diff --git a/src/daemon/__tests__/post-gesture-stabilization-verdict.test.ts b/packages/daemon/src/core/__tests__/post-gesture-stabilization-verdict.test.ts similarity index 100% rename from src/daemon/__tests__/post-gesture-stabilization-verdict.test.ts rename to packages/daemon/src/core/__tests__/post-gesture-stabilization-verdict.test.ts diff --git a/src/daemon/__tests__/post-gesture-stabilization.test.ts b/packages/daemon/src/core/__tests__/post-gesture-stabilization.test.ts similarity index 100% rename from src/daemon/__tests__/post-gesture-stabilization.test.ts rename to packages/daemon/src/core/__tests__/post-gesture-stabilization.test.ts diff --git a/src/daemon/__tests__/provider-device-admission.test.ts b/packages/daemon/src/core/__tests__/provider-device-admission.test.ts similarity index 100% rename from src/daemon/__tests__/provider-device-admission.test.ts rename to packages/daemon/src/core/__tests__/provider-device-admission.test.ts diff --git a/src/daemon/__tests__/recording-gestures.test.ts b/packages/daemon/src/core/__tests__/recording-gestures.test.ts similarity index 98% rename from src/daemon/__tests__/recording-gestures.test.ts rename to packages/daemon/src/core/__tests__/recording-gestures.test.ts index ca6f4521b2..a816fccc58 100644 --- a/src/daemon/__tests__/recording-gestures.test.ts +++ b/packages/daemon/src/core/__tests__/recording-gestures.test.ts @@ -4,9 +4,9 @@ import { augmentScrollVisualizationResult, recordTouchVisualizationEvent, } from '../recording-gestures.ts'; -import { makeIosSession, makeMacOsSession } from './support/session-factories.ts'; +import { makeIosSession, makeMacOsSession } from '../../__tests__/support/session-factories.ts'; import { makeSnapshotState } from '@agent-device/selectors/snapshot-geometry-fixtures'; -import { makeTestScreenRecordingResource } from './support/screen-recording-live-handle.ts'; +import { makeTestScreenRecordingResource } from '../../__tests__/support/screen-recording-live-handle.ts'; import type { ScreenRecordingLiveSnapshot } from '@agent-device/contracts/screen-recording-runtime'; import { TVOS_SIMULATOR } from '@agent-device/test-kit/device-fixtures'; diff --git a/src/daemon/__tests__/recording-timing.test.ts b/packages/daemon/src/core/__tests__/recording-timing.test.ts similarity index 100% rename from src/daemon/__tests__/recording-timing.test.ts rename to packages/daemon/src/core/__tests__/recording-timing.test.ts diff --git a/src/daemon/__tests__/ref-frame.test.ts b/packages/daemon/src/core/__tests__/ref-frame.test.ts similarity index 100% rename from src/daemon/__tests__/ref-frame.test.ts rename to packages/daemon/src/core/__tests__/ref-frame.test.ts diff --git a/src/daemon/__tests__/request-dispatch-ledger.test.ts b/packages/daemon/src/core/__tests__/request-dispatch-ledger.test.ts similarity index 100% rename from src/daemon/__tests__/request-dispatch-ledger.test.ts rename to packages/daemon/src/core/__tests__/request-dispatch-ledger.test.ts diff --git a/src/daemon/__tests__/request-runtime-binding-router.test.ts b/packages/daemon/src/core/__tests__/request-runtime-binding-router.test.ts similarity index 95% rename from src/daemon/__tests__/request-runtime-binding-router.test.ts rename to packages/daemon/src/core/__tests__/request-runtime-binding-router.test.ts index 25d1be7565..f94bcac0ad 100644 --- a/src/daemon/__tests__/request-runtime-binding-router.test.ts +++ b/packages/daemon/src/core/__tests__/request-runtime-binding-router.test.ts @@ -11,10 +11,10 @@ import { createAppLogStartResult, createDurableResourceEnvelope } from '@agent-d import { createTestAppLogLiveHandle } from '@agent-device/test-kit/app-log-live-handle'; import { createTestDeviceInventoryGateways } from '@agent-device/device-selection/inventory-gateways-fixtures'; import { unavailableDeploymentSnapshotAndShutdownOperationFacts } from '@agent-device/test-kit/runtime-operation-facts'; -import { makeSessionStore } from './support/store-factory.ts'; -import { LeaseRegistry } from '../lease-registry.ts'; -import { createRequestHandler } from './test-device-runtime-gateway.ts'; -import { fakeCreateCommandSurface } from './support/command-surface-fake.ts'; +import { makeSessionStore } from '../../__tests__/support/store-factory.ts'; +import { LeaseRegistry } from '../../resources/lease-registry.ts'; +import { createRequestHandler } from '../../__tests__/support/test-device-runtime-gateway.ts'; +import { fakeCreateCommandSurface } from '../../__tests__/support/command-surface-fake.ts'; test('request binding disposes once after response while adopted app-log handle survives', async () => { const runtime = makeGateway(); diff --git a/src/daemon/__tests__/request-runtime-binding.test.ts b/packages/daemon/src/core/__tests__/request-runtime-binding.test.ts similarity index 99% rename from src/daemon/__tests__/request-runtime-binding.test.ts rename to packages/daemon/src/core/__tests__/request-runtime-binding.test.ts index aa0cd94e6d..50ed9b7a76 100644 --- a/src/daemon/__tests__/request-runtime-binding.test.ts +++ b/packages/daemon/src/core/__tests__/request-runtime-binding.test.ts @@ -1,4 +1,4 @@ -import { daemonPlatformServicesFixture } from './platform-services-fixture.ts'; +import { daemonPlatformServicesFixture } from '../../__tests__/support/platform-services-fixture.ts'; import { beforeEach, expect, test, vi } from 'vitest'; import { applicationLifecycleOperationFacts } from '@agent-device/contracts/application-lifecycle-runtime'; import { diff --git a/src/daemon/__tests__/runtime-operation-effects.test.ts b/packages/daemon/src/core/__tests__/runtime-operation-effects.test.ts similarity index 100% rename from src/daemon/__tests__/runtime-operation-effects.test.ts rename to packages/daemon/src/core/__tests__/runtime-operation-effects.test.ts diff --git a/src/daemon/__tests__/runtime-session.test.ts b/packages/daemon/src/core/__tests__/runtime-session.test.ts similarity index 95% rename from src/daemon/__tests__/runtime-session.test.ts rename to packages/daemon/src/core/__tests__/runtime-session.test.ts index a9e963e83a..df96d306fe 100644 --- a/src/daemon/__tests__/runtime-session.test.ts +++ b/packages/daemon/src/core/__tests__/runtime-session.test.ts @@ -1,7 +1,7 @@ import { test, expect } from 'vitest'; import fs from 'node:fs'; -import { makeSessionStore } from './support/store-factory.ts'; -import { makeIosSession } from './support/session-factories.ts'; +import { makeSessionStore } from '../../__tests__/support/store-factory.ts'; +import { makeIosSession } from '../../__tests__/support/session-factories.ts'; import { flushDiagnosticsToSessionFile, withDiagnosticsScope, diff --git a/src/daemon/__tests__/screen-recording-resource-recovery.test.ts b/packages/daemon/src/core/__tests__/screen-recording-resource-recovery.test.ts similarity index 97% rename from src/daemon/__tests__/screen-recording-resource-recovery.test.ts rename to packages/daemon/src/core/__tests__/screen-recording-resource-recovery.test.ts index 428e67e2d8..341fe10060 100644 --- a/src/daemon/__tests__/screen-recording-resource-recovery.test.ts +++ b/packages/daemon/src/core/__tests__/screen-recording-resource-recovery.test.ts @@ -6,7 +6,7 @@ import { localRuntimeOwner, } from '@agent-device/contracts/platform-runtime'; import type { PlatformRuntimeOperations } from '@agent-device/contracts/platform-runtime-operations'; -import { makeTestScreenRecordingResource } from './support/screen-recording-live-handle.ts'; +import { makeTestScreenRecordingResource } from '../../__tests__/support/screen-recording-live-handle.ts'; import { unavailableDeploymentSnapshotAndShutdownOperationFacts } from '@agent-device/test-kit/runtime-operation-facts'; import { mkdtempForTestSync } from '@agent-device/test-kit/tmp-dir'; import { recoverScreenRecordingResourceAfterDaemonLock } from '@agent-device/capture-kit/screen-recording-recovery'; diff --git a/src/daemon/__tests__/selector-operation-binding.test.ts b/packages/daemon/src/core/__tests__/selector-operation-binding.test.ts similarity index 100% rename from src/daemon/__tests__/selector-operation-binding.test.ts rename to packages/daemon/src/core/__tests__/selector-operation-binding.test.ts diff --git a/src/daemon/__tests__/selector-recording-find-data.test.ts b/packages/daemon/src/core/__tests__/selector-recording-find-data.test.ts similarity index 100% rename from src/daemon/__tests__/selector-recording-find-data.test.ts rename to packages/daemon/src/core/__tests__/selector-recording-find-data.test.ts diff --git a/src/daemon/__tests__/selector-recording.test.ts b/packages/daemon/src/core/__tests__/selector-recording.test.ts similarity index 98% rename from src/daemon/__tests__/selector-recording.test.ts rename to packages/daemon/src/core/__tests__/selector-recording.test.ts index 99c40b3d60..5090a1af02 100644 --- a/src/daemon/__tests__/selector-recording.test.ts +++ b/packages/daemon/src/core/__tests__/selector-recording.test.ts @@ -11,7 +11,7 @@ import { test, expect } from 'vitest'; import path from 'node:path'; import { recordIfSession } from '../selector-recording.ts'; import { SessionStore } from '../session-store.ts'; -import { makeIosSession } from './support/session-factories.ts'; +import { makeIosSession } from '../../__tests__/support/session-factories.ts'; import type { DaemonRequest } from '../daemon-request.ts'; import { mkdtempForTestSync } from '@agent-device/test-kit/tmp-dir'; diff --git a/src/daemon/__tests__/session-action-recorder.test.ts b/packages/daemon/src/core/__tests__/session-action-recorder.test.ts similarity index 99% rename from src/daemon/__tests__/session-action-recorder.test.ts rename to packages/daemon/src/core/__tests__/session-action-recorder.test.ts index 505189f84a..d690110be7 100644 --- a/src/daemon/__tests__/session-action-recorder.test.ts +++ b/packages/daemon/src/core/__tests__/session-action-recorder.test.ts @@ -8,7 +8,7 @@ import { isSessionRecording } from '../session-script-publication-capability.ts' */ import { test, expect } from 'vitest'; import { recordActionEntry } from '../session-action-recorder.ts'; -import { authoringPublication, makeIosSession } from './support/session-factories.ts'; +import { authoringPublication, makeIosSession } from '../../__tests__/support/session-factories.ts'; test('an observation-only action is excluded while repair-armed and no --record is given', () => { const session = makeIosSession('default', { diff --git a/src/daemon/__tests__/session-artifact-paths.test.ts b/packages/daemon/src/core/__tests__/session-artifact-paths.test.ts similarity index 100% rename from src/daemon/__tests__/session-artifact-paths.test.ts rename to packages/daemon/src/core/__tests__/session-artifact-paths.test.ts diff --git a/src/daemon/__tests__/session-capture-binding.test.ts b/packages/daemon/src/core/__tests__/session-capture-binding.test.ts similarity index 98% rename from src/daemon/__tests__/session-capture-binding.test.ts rename to packages/daemon/src/core/__tests__/session-capture-binding.test.ts index d44d732d86..254b0ca5fd 100644 --- a/src/daemon/__tests__/session-capture-binding.test.ts +++ b/packages/daemon/src/core/__tests__/session-capture-binding.test.ts @@ -1,6 +1,6 @@ import { expect, test, vi } from 'vitest'; -import { makeSessionStore } from './support/store-factory.ts'; -import { makeRecordingSession } from './session-teardown.fixtures.ts'; +import { makeSessionStore } from '../../__tests__/support/store-factory.ts'; +import { makeRecordingSession } from '../../__tests__/support/session-teardown.fixtures.ts'; import { bindSessionScreenRecording, bindRecordOnlyScreenRecording, diff --git a/src/daemon/__tests__/session-runtime-admission.test.ts b/packages/daemon/src/core/__tests__/session-runtime-admission.test.ts similarity index 96% rename from src/daemon/__tests__/session-runtime-admission.test.ts rename to packages/daemon/src/core/__tests__/session-runtime-admission.test.ts index 69982f0566..e31f3e9b84 100644 --- a/src/daemon/__tests__/session-runtime-admission.test.ts +++ b/packages/daemon/src/core/__tests__/session-runtime-admission.test.ts @@ -1,7 +1,7 @@ import { resolveSnapshotRuntimePlan } from '@agent-device/contracts/platform-runtime-operations'; import { expect, test } from 'vitest'; import { ANDROID_EMULATOR, IOS_SIMULATOR } from '@agent-device/test-kit/device-fixtures'; -import { snapshotRuntimeFixture } from './snapshot-runtime-fixture.ts'; +import { snapshotRuntimeFixture } from '../../__tests__/support/snapshot-runtime-fixture.ts'; import { admitRuntimePlan, unwrapAdmittedRuntimePlan, @@ -47,7 +47,7 @@ test('the admission cannot be written down or copied: only admitRuntimePlan mint // Planted reds for the seam itself: each directive below becomes unused — and tsc fails — if // the token loses its #private member (degrades to a plain shape). A route holds a token only // by having called admitRuntimePlan (or by a type assertion, which the cutover gate rejects in - // src/daemon/). The class value is not exported, so `new` is not even nameable from here. + // packages/daemon/src/). The class value is not exported, so `new` is not even nameable from here. // @ts-expect-error a literal is not an admission: it lacks the #private member const literal: AdmittedRuntimePlan = { admitted: true }; // @ts-expect-error a spread of a real admission is a plain object without the #private member diff --git a/src/daemon/__tests__/session-script-active-publication.test.ts b/packages/daemon/src/core/__tests__/session-script-active-publication.test.ts similarity index 100% rename from src/daemon/__tests__/session-script-active-publication.test.ts rename to packages/daemon/src/core/__tests__/session-script-active-publication.test.ts diff --git a/src/daemon/__tests__/session-script-publication-state.test.ts b/packages/daemon/src/core/__tests__/session-script-publication-state.test.ts similarity index 100% rename from src/daemon/__tests__/session-script-publication-state.test.ts rename to packages/daemon/src/core/__tests__/session-script-publication-state.test.ts diff --git a/src/daemon/__tests__/session-script-writer.test.ts b/packages/daemon/src/core/__tests__/session-script-writer.test.ts similarity index 99% rename from src/daemon/__tests__/session-script-writer.test.ts rename to packages/daemon/src/core/__tests__/session-script-writer.test.ts index 3146071b53..8d1befb235 100644 --- a/src/daemon/__tests__/session-script-writer.test.ts +++ b/packages/daemon/src/core/__tests__/session-script-writer.test.ts @@ -10,7 +10,7 @@ import { makeRepairCompleteSession, repairPublication, authoringPublication, -} from './support/session-factories.ts'; +} from '../../__tests__/support/session-factories.ts'; import { markRepairTransactionComplete } from '../session-replay-transaction.ts'; import { NO_SCRIPT_PUBLICATION, scriptTargetPath } from '../session-script-publication-state.ts'; import { parseReplayScriptDetailed } from '@agent-device/ad-script'; diff --git a/src/daemon/__tests__/session-selector.test.ts b/packages/daemon/src/core/__tests__/session-selector.test.ts similarity index 98% rename from src/daemon/__tests__/session-selector.test.ts rename to packages/daemon/src/core/__tests__/session-selector.test.ts index af0efeb371..a51470fe26 100644 --- a/src/daemon/__tests__/session-selector.test.ts +++ b/packages/daemon/src/core/__tests__/session-selector.test.ts @@ -1,4 +1,4 @@ -import { makeStoredSessionRef } from './support/store-factory.ts'; +import { makeStoredSessionRef } from '../../__tests__/support/store-factory.ts'; import { test } from 'vitest'; import assert from 'node:assert/strict'; import { assertSessionSelectorMatches } from '../session-selector.ts'; diff --git a/src/daemon/__tests__/session-snapshot-freshness.test.ts b/packages/daemon/src/core/__tests__/session-snapshot-freshness.test.ts similarity index 100% rename from src/daemon/__tests__/session-snapshot-freshness.test.ts rename to packages/daemon/src/core/__tests__/session-snapshot-freshness.test.ts diff --git a/src/daemon/__tests__/session-store-lifetime.test.ts b/packages/daemon/src/core/__tests__/session-store-lifetime.test.ts similarity index 98% rename from src/daemon/__tests__/session-store-lifetime.test.ts rename to packages/daemon/src/core/__tests__/session-store-lifetime.test.ts index 1873069483..a528264685 100644 --- a/src/daemon/__tests__/session-store-lifetime.test.ts +++ b/packages/daemon/src/core/__tests__/session-store-lifetime.test.ts @@ -7,8 +7,8 @@ import { makeRepairCompleteSession, makeRepairArmedSession, authoringPublication, -} from './support/session-factories.ts'; -import { makeSessionStore, storeSessionForTest } from './support/store-factory.ts'; +} from '../../__tests__/support/session-factories.ts'; +import { makeSessionStore, storeSessionForTest } from '../../__tests__/support/store-factory.ts'; import { resolveRepairTombstonePath } from '@agent-device/daemon-contracts/session-repair-tombstone'; const ADDRESS = 'cwd:worktree:default'; diff --git a/src/daemon/__tests__/session-store.test.ts b/packages/daemon/src/core/__tests__/session-store.test.ts similarity index 99% rename from src/daemon/__tests__/session-store.test.ts rename to packages/daemon/src/core/__tests__/session-store.test.ts index 41cb398a2b..33855f6c95 100644 --- a/src/daemon/__tests__/session-store.test.ts +++ b/packages/daemon/src/core/__tests__/session-store.test.ts @@ -1,4 +1,4 @@ -import { storeSessionForTest } from './support/store-factory.ts'; +import { storeSessionForTest } from '../../__tests__/support/store-factory.ts'; import { test } from 'vitest'; import assert from 'node:assert/strict'; import fs from 'node:fs'; @@ -9,7 +9,7 @@ import { buildRequestFinishedEvent } from '@agent-device/session-journal/session import { HEAL_COMPLETE_SENTINEL } from '../session-script-writer.ts'; import { parseReplayScriptDetailed } from '@agent-device/ad-script'; import type { TargetAnnotationV1 } from '@agent-device/contracts/replay'; -import { makeMacOsSession, repairPublication } from './support/session-factories.ts'; +import { makeMacOsSession, repairPublication } from '../../__tests__/support/session-factories.ts'; import { mkdtempForTestSync } from '@agent-device/test-kit/tmp-dir'; diff --git a/src/daemon/__tests__/settle-observation-capture.test.ts b/packages/daemon/src/core/__tests__/settle-observation-capture.test.ts similarity index 95% rename from src/daemon/__tests__/settle-observation-capture.test.ts rename to packages/daemon/src/core/__tests__/settle-observation-capture.test.ts index 7f74cc6def..50c7e47084 100644 --- a/src/daemon/__tests__/settle-observation-capture.test.ts +++ b/packages/daemon/src/core/__tests__/settle-observation-capture.test.ts @@ -1,8 +1,8 @@ import { beforeEach, expect, test, vi } from 'vitest'; import { IOS_SIMULATOR } from '@agent-device/test-kit/device-fixtures'; -import { makeIosSession } from './support/session-factories.ts'; -import { daemonPlatformServicesFixture } from './platform-services-fixture.ts'; -import { selectorCaptureFixture } from './selector-capture-fixture.ts'; +import { makeIosSession } from '../../__tests__/support/session-factories.ts'; +import { daemonPlatformServicesFixture } from '../../__tests__/support/platform-services-fixture.ts'; +import { selectorCaptureFixture } from '../../__tests__/support/selector-capture-fixture.ts'; import { resolveSettleObservationCapture } from '../settle-observation-capture.ts'; import { emitDiagnostic } from '@agent-device/host-kit/diagnostics'; diff --git a/src/daemon/__tests__/snapshot-capture.test.ts b/packages/daemon/src/core/__tests__/snapshot-capture.test.ts similarity index 97% rename from src/daemon/__tests__/snapshot-capture.test.ts rename to packages/daemon/src/core/__tests__/snapshot-capture.test.ts index 389e469178..d45e5bb42e 100644 --- a/src/daemon/__tests__/snapshot-capture.test.ts +++ b/packages/daemon/src/core/__tests__/snapshot-capture.test.ts @@ -10,14 +10,14 @@ import { buildNodes } from '@agent-device/test-kit/snapshot-builders'; import { legacyDispatchCapture, resetLegacySnapshotCapture, -} from './legacy-snapshot-capture-fixture.ts'; +} from '../../__tests__/support/legacy-snapshot-capture-fixture.ts'; import { androidCapture, androidDevice, androidTextRows, inboxBaselineNodes, makeAndroidFreshnessSession, -} from '../handlers/__tests__/snapshot-handler.fixtures.ts'; +} from '../../__tests__/support/handlers/snapshot-handler.fixtures.ts'; import { pendingSurfaceStabilization } from '../deferred-interaction-outcome.ts'; const captureSnapshotWithInteractor = vi.hoisted(() => vi.fn()); diff --git a/src/daemon/__tests__/snapshot-interactor-capture.test.ts b/packages/daemon/src/core/__tests__/snapshot-interactor-capture.test.ts similarity index 100% rename from src/daemon/__tests__/snapshot-interactor-capture.test.ts rename to packages/daemon/src/core/__tests__/snapshot-interactor-capture.test.ts diff --git a/src/daemon/__tests__/snapshot-runtime-binding.test.ts b/packages/daemon/src/core/__tests__/snapshot-runtime-binding.test.ts similarity index 87% rename from src/daemon/__tests__/snapshot-runtime-binding.test.ts rename to packages/daemon/src/core/__tests__/snapshot-runtime-binding.test.ts index 4c5d6b6ad0..ac1e4abfa4 100644 --- a/src/daemon/__tests__/snapshot-runtime-binding.test.ts +++ b/packages/daemon/src/core/__tests__/snapshot-runtime-binding.test.ts @@ -1,19 +1,19 @@ -import { daemonPlatformServicesFixture } from './platform-services-fixture.ts'; +import { daemonPlatformServicesFixture } from '../../__tests__/support/platform-services-fixture.ts'; import type { DeviceInfo } from '@agent-device/kernel/device'; import { expect, test, vi } from 'vitest'; import { resolveSnapshotRuntimePlan } from '@agent-device/contracts/platform-runtime-operations'; import { IOS_SIMULATOR } from '@agent-device/test-kit/device-fixtures'; -import { makeIosSession } from './support/session-factories.ts'; -import { makeSessionStore } from './support/store-factory.ts'; +import { makeIosSession } from '../../__tests__/support/session-factories.ts'; +import { makeSessionStore } from '../../__tests__/support/store-factory.ts'; import type { BindDeviceRuntime } from '../request-runtime-binding.ts'; import { admitAndBindSnapshotCapture, resolveBoundSnapshotCaptureRuntime, } from '../snapshot-runtime-binding.ts'; import type { DaemonRequest } from '../daemon-request.ts'; -import { snapshotRuntimeFixture } from './snapshot-runtime-fixture.ts'; +import { snapshotRuntimeFixture } from '../../__tests__/support/snapshot-runtime-fixture.ts'; import { ensureDeviceReady } from '../device/device-ready.ts'; -import { fakeCreateCommandSurface } from './support/command-surface-fake.ts'; +import { fakeCreateCommandSurface } from '../../__tests__/support/command-surface-fake.ts'; vi.mock('../device/device-ready.ts', () => ({ ensureDeviceReady: vi.fn(async () => {}) })); diff --git a/src/daemon/__tests__/tenant-owned-entry.test.ts b/packages/daemon/src/core/__tests__/tenant-owned-entry.test.ts similarity index 100% rename from src/daemon/__tests__/tenant-owned-entry.test.ts rename to packages/daemon/src/core/__tests__/tenant-owned-entry.test.ts diff --git a/src/daemon/capture-disclosure.ts b/packages/daemon/src/core/capture-disclosure.ts similarity index 100% rename from src/daemon/capture-disclosure.ts rename to packages/daemon/src/core/capture-disclosure.ts diff --git a/src/daemon/config.ts b/packages/daemon/src/core/config.ts similarity index 100% rename from src/daemon/config.ts rename to packages/daemon/src/core/config.ts diff --git a/src/daemon/context.ts b/packages/daemon/src/core/context.ts similarity index 100% rename from src/daemon/context.ts rename to packages/daemon/src/core/context.ts diff --git a/src/daemon/daemon-command-registry.ts b/packages/daemon/src/core/daemon-command-registry.ts similarity index 100% rename from src/daemon/daemon-command-registry.ts rename to packages/daemon/src/core/daemon-command-registry.ts diff --git a/src/daemon/daemon-policy.ts b/packages/daemon/src/core/daemon-policy.ts similarity index 100% rename from src/daemon/daemon-policy.ts rename to packages/daemon/src/core/daemon-policy.ts diff --git a/src/daemon/daemon-request.ts b/packages/daemon/src/core/daemon-request.ts similarity index 100% rename from src/daemon/daemon-request.ts rename to packages/daemon/src/core/daemon-request.ts diff --git a/src/daemon/deferred-interaction-outcome.ts b/packages/daemon/src/core/deferred-interaction-outcome.ts similarity index 100% rename from src/daemon/deferred-interaction-outcome.ts rename to packages/daemon/src/core/deferred-interaction-outcome.ts diff --git a/src/daemon/device/device-ready.ts b/packages/daemon/src/core/device/device-ready.ts similarity index 100% rename from src/daemon/device/device-ready.ts rename to packages/daemon/src/core/device/device-ready.ts diff --git a/src/daemon/device/device-selector-intent.ts b/packages/daemon/src/core/device/device-selector-intent.ts similarity index 100% rename from src/daemon/device/device-selector-intent.ts rename to packages/daemon/src/core/device/device-selector-intent.ts diff --git a/src/daemon/direct-ios-selector.ts b/packages/daemon/src/core/direct-ios-selector.ts similarity index 100% rename from src/daemon/direct-ios-selector.ts rename to packages/daemon/src/core/direct-ios-selector.ts diff --git a/src/daemon/dispatch-context.ts b/packages/daemon/src/core/dispatch-context.ts similarity index 100% rename from src/daemon/dispatch-context.ts rename to packages/daemon/src/core/dispatch-context.ts diff --git a/src/daemon/execution-plan.ts b/packages/daemon/src/core/execution-plan.ts similarity index 100% rename from src/daemon/execution-plan.ts rename to packages/daemon/src/core/execution-plan.ts diff --git a/src/daemon/fill-backend-result.test.ts b/packages/daemon/src/core/fill-backend-result.test.ts similarity index 100% rename from src/daemon/fill-backend-result.test.ts rename to packages/daemon/src/core/fill-backend-result.test.ts diff --git a/src/daemon/fill-backend-result.ts b/packages/daemon/src/core/fill-backend-result.ts similarity index 100% rename from src/daemon/fill-backend-result.ts rename to packages/daemon/src/core/fill-backend-result.ts diff --git a/src/daemon/generic-leaf-execution.ts b/packages/daemon/src/core/generic-leaf-execution.ts similarity index 100% rename from src/daemon/generic-leaf-execution.ts rename to packages/daemon/src/core/generic-leaf-execution.ts diff --git a/src/daemon/gesture-runtime.ts b/packages/daemon/src/core/gesture-runtime.ts similarity index 100% rename from src/daemon/gesture-runtime.ts rename to packages/daemon/src/core/gesture-runtime.ts diff --git a/src/daemon/interaction-surface-signature.ts b/packages/daemon/src/core/interaction-surface-signature.ts similarity index 100% rename from src/daemon/interaction-surface-signature.ts rename to packages/daemon/src/core/interaction-surface-signature.ts diff --git a/src/daemon/interaction/internal/interaction-touch-direct-ios-eligibility.ts b/packages/daemon/src/core/interaction/internal/interaction-touch-direct-ios-eligibility.ts similarity index 100% rename from src/daemon/interaction/internal/interaction-touch-direct-ios-eligibility.ts rename to packages/daemon/src/core/interaction/internal/interaction-touch-direct-ios-eligibility.ts diff --git a/src/daemon/interaction/internal/types.ts b/packages/daemon/src/core/interaction/internal/types.ts similarity index 100% rename from src/daemon/interaction/internal/types.ts rename to packages/daemon/src/core/interaction/internal/types.ts diff --git a/src/daemon/interactor-resolution.ts b/packages/daemon/src/core/interactor-resolution.ts similarity index 100% rename from src/daemon/interactor-resolution.ts rename to packages/daemon/src/core/interactor-resolution.ts diff --git a/src/daemon/ios-app-session-hint.test.ts b/packages/daemon/src/core/ios-app-session-hint.test.ts similarity index 97% rename from src/daemon/ios-app-session-hint.test.ts rename to packages/daemon/src/core/ios-app-session-hint.test.ts index 645d5bdb57..1f99c7e91c 100644 --- a/src/daemon/ios-app-session-hint.test.ts +++ b/packages/daemon/src/core/ios-app-session-hint.test.ts @@ -1,4 +1,4 @@ -import { daemonPlatformServicesFixture } from './__tests__/platform-services-fixture.ts'; +import { daemonPlatformServicesFixture } from '../__tests__/support/platform-services-fixture.ts'; import { beforeEach, expect, test, vi } from 'vitest'; import { IOS_DEVICE, IOS_SIMULATOR } from '@agent-device/test-kit/device-fixtures'; import { buildIosOpenCommandHint } from './ios-app-session-hint.ts'; diff --git a/src/daemon/ios-app-session-hint.ts b/packages/daemon/src/core/ios-app-session-hint.ts similarity index 100% rename from src/daemon/ios-app-session-hint.ts rename to packages/daemon/src/core/ios-app-session-hint.ts diff --git a/src/daemon/lease-context.ts b/packages/daemon/src/core/lease-context.ts similarity index 100% rename from src/daemon/lease-context.ts rename to packages/daemon/src/core/lease-context.ts diff --git a/src/daemon/managed-session-artifact-path.ts b/packages/daemon/src/core/managed-session-artifact-path.ts similarity index 100% rename from src/daemon/managed-session-artifact-path.ts rename to packages/daemon/src/core/managed-session-artifact-path.ts diff --git a/src/daemon/platform-owner-lifecycle.ts b/packages/daemon/src/core/platform-owner-lifecycle.ts similarity index 100% rename from src/daemon/platform-owner-lifecycle.ts rename to packages/daemon/src/core/platform-owner-lifecycle.ts diff --git a/src/daemon/platform-resource-cleanup.ts b/packages/daemon/src/core/platform-resource-cleanup.ts similarity index 100% rename from src/daemon/platform-resource-cleanup.ts rename to packages/daemon/src/core/platform-resource-cleanup.ts diff --git a/src/daemon/platform-services.ts b/packages/daemon/src/core/platform-services.ts similarity index 100% rename from src/daemon/platform-services.ts rename to packages/daemon/src/core/platform-services.ts diff --git a/src/daemon/provider-device-admission.ts b/packages/daemon/src/core/provider-device-admission.ts similarity index 100% rename from src/daemon/provider-device-admission.ts rename to packages/daemon/src/core/provider-device-admission.ts diff --git a/src/daemon/recording-gesture-events.ts b/packages/daemon/src/core/recording-gesture-events.ts similarity index 100% rename from src/daemon/recording-gesture-events.ts rename to packages/daemon/src/core/recording-gesture-events.ts diff --git a/src/daemon/recording-gestures.ts b/packages/daemon/src/core/recording-gestures.ts similarity index 100% rename from src/daemon/recording-gestures.ts rename to packages/daemon/src/core/recording-gestures.ts diff --git a/src/daemon/recording-timing.ts b/packages/daemon/src/core/recording-timing.ts similarity index 100% rename from src/daemon/recording-timing.ts rename to packages/daemon/src/core/recording-timing.ts diff --git a/src/daemon/recording-values.ts b/packages/daemon/src/core/recording-values.ts similarity index 100% rename from src/daemon/recording-values.ts rename to packages/daemon/src/core/recording-values.ts diff --git a/src/daemon/ref-frame-slot.ts b/packages/daemon/src/core/ref-frame-slot.ts similarity index 100% rename from src/daemon/ref-frame-slot.ts rename to packages/daemon/src/core/ref-frame-slot.ts diff --git a/src/daemon/ref-frame.ts b/packages/daemon/src/core/ref-frame.ts similarity index 100% rename from src/daemon/ref-frame.ts rename to packages/daemon/src/core/ref-frame.ts diff --git a/src/daemon/request-dispatch-ledger.ts b/packages/daemon/src/core/request-dispatch-ledger.ts similarity index 100% rename from src/daemon/request-dispatch-ledger.ts rename to packages/daemon/src/core/request-dispatch-ledger.ts diff --git a/src/daemon/request-runtime-binding.ts b/packages/daemon/src/core/request-runtime-binding.ts similarity index 100% rename from src/daemon/request-runtime-binding.ts rename to packages/daemon/src/core/request-runtime-binding.ts diff --git a/src/daemon/runtime-admission.ts b/packages/daemon/src/core/runtime-admission.ts similarity index 100% rename from src/daemon/runtime-admission.ts rename to packages/daemon/src/core/runtime-admission.ts diff --git a/src/daemon/runtime-operation-effects.ts b/packages/daemon/src/core/runtime-operation-effects.ts similarity index 100% rename from src/daemon/runtime-operation-effects.ts rename to packages/daemon/src/core/runtime-operation-effects.ts diff --git a/src/daemon/runtime-session.ts b/packages/daemon/src/core/runtime-session.ts similarity index 100% rename from src/daemon/runtime-session.ts rename to packages/daemon/src/core/runtime-session.ts diff --git a/src/daemon/selector-operation-binding.ts b/packages/daemon/src/core/selector-operation-binding.ts similarity index 100% rename from src/daemon/selector-operation-binding.ts rename to packages/daemon/src/core/selector-operation-binding.ts diff --git a/src/daemon/selector-recording.ts b/packages/daemon/src/core/selector-recording.ts similarity index 100% rename from src/daemon/selector-recording.ts rename to packages/daemon/src/core/selector-recording.ts diff --git a/src/daemon/session-action-recorder.ts b/packages/daemon/src/core/session-action-recorder.ts similarity index 100% rename from src/daemon/session-action-recorder.ts rename to packages/daemon/src/core/session-action-recorder.ts diff --git a/src/daemon/session-artifact-paths.ts b/packages/daemon/src/core/session-artifact-paths.ts similarity index 100% rename from src/daemon/session-artifact-paths.ts rename to packages/daemon/src/core/session-artifact-paths.ts diff --git a/src/daemon/session-capture-binding.ts b/packages/daemon/src/core/session-capture-binding.ts similarity index 100% rename from src/daemon/session-capture-binding.ts rename to packages/daemon/src/core/session-capture-binding.ts diff --git a/src/daemon/session-idle-tombstone.test.ts b/packages/daemon/src/core/session-idle-tombstone.test.ts similarity index 100% rename from src/daemon/session-idle-tombstone.test.ts rename to packages/daemon/src/core/session-idle-tombstone.test.ts diff --git a/src/daemon/session-idle-tombstone.ts b/packages/daemon/src/core/session-idle-tombstone.ts similarity index 100% rename from src/daemon/session-idle-tombstone.ts rename to packages/daemon/src/core/session-idle-tombstone.ts diff --git a/src/daemon/session-recovery-hints.test.ts b/packages/daemon/src/core/session-recovery-hints.test.ts similarity index 97% rename from src/daemon/session-recovery-hints.test.ts rename to packages/daemon/src/core/session-recovery-hints.test.ts index fe88bf2172..f220564329 100644 --- a/src/daemon/session-recovery-hints.test.ts +++ b/packages/daemon/src/core/session-recovery-hints.test.ts @@ -1,4 +1,4 @@ -import { makeStoredSessionRef } from './__tests__/support/store-factory.ts'; +import { makeStoredSessionRef } from '../__tests__/support/store-factory.ts'; import { test, expect } from 'vitest'; import { buildSessionRecoveryHint } from './session-recovery-hints.ts'; import type { SessionRef, SessionState } from './session-state.ts'; diff --git a/src/daemon/session-recovery-hints.ts b/packages/daemon/src/core/session-recovery-hints.ts similarity index 100% rename from src/daemon/session-recovery-hints.ts rename to packages/daemon/src/core/session-recovery-hints.ts diff --git a/src/daemon/session-replay-transaction.ts b/packages/daemon/src/core/session-replay-transaction.ts similarity index 100% rename from src/daemon/session-replay-transaction.ts rename to packages/daemon/src/core/session-replay-transaction.ts diff --git a/src/daemon/session-runtime-admission.ts b/packages/daemon/src/core/session-runtime-admission.ts similarity index 99% rename from src/daemon/session-runtime-admission.ts rename to packages/daemon/src/core/session-runtime-admission.ts index 20e0aa48e1..2d8b84750c 100644 --- a/src/daemon/session-runtime-admission.ts +++ b/packages/daemon/src/core/session-runtime-admission.ts @@ -73,7 +73,7 @@ let mintAdmission: ( * WeakMap keyed by the token's identity. A binder gets at the device and plan only through * `unwrapAdmittedRuntimePlan`, which refuses any object that was not minted here — including a * Proxy around a real token, which types as the token but is a different identity. What remains - * is a type assertion, which the cutover gate's manufactured-proof column rejects in src/daemon/. + * is a type assertion, which the cutover gate's manufactured-proof column rejects in packages/daemon/src/. * A facts-first binder that requires the token therefore enforces "admit before bind" — for this * device, for this plan — at the seam. */ diff --git a/src/daemon/session-script-active-publication.ts b/packages/daemon/src/core/session-script-active-publication.ts similarity index 100% rename from src/daemon/session-script-active-publication.ts rename to packages/daemon/src/core/session-script-active-publication.ts diff --git a/src/daemon/session-script-publication-capability.ts b/packages/daemon/src/core/session-script-publication-capability.ts similarity index 100% rename from src/daemon/session-script-publication-capability.ts rename to packages/daemon/src/core/session-script-publication-capability.ts diff --git a/src/daemon/session-script-publication-state.ts b/packages/daemon/src/core/session-script-publication-state.ts similarity index 100% rename from src/daemon/session-script-publication-state.ts rename to packages/daemon/src/core/session-script-publication-state.ts diff --git a/src/daemon/session-script-writer.ts b/packages/daemon/src/core/session-script-writer.ts similarity index 100% rename from src/daemon/session-script-writer.ts rename to packages/daemon/src/core/session-script-writer.ts diff --git a/src/daemon/session-selector.ts b/packages/daemon/src/core/session-selector.ts similarity index 100% rename from src/daemon/session-selector.ts rename to packages/daemon/src/core/session-selector.ts diff --git a/src/daemon/session-snapshot-freshness.ts b/packages/daemon/src/core/session-snapshot-freshness.ts similarity index 100% rename from src/daemon/session-snapshot-freshness.ts rename to packages/daemon/src/core/session-snapshot-freshness.ts diff --git a/src/daemon/session-state.ts b/packages/daemon/src/core/session-state.ts similarity index 98% rename from src/daemon/session-state.ts rename to packages/daemon/src/core/session-state.ts index 9444108349..1a1f7c5194 100644 --- a/src/daemon/session-state.ts +++ b/packages/daemon/src/core/session-state.ts @@ -200,7 +200,7 @@ export type SessionState = { * resolution, settle observation, system-modal probes) can arm the runner-side penalty * without any user-facing render — when the latch is not held, the first public * deferred verdict re-renders the warning once. Managed only through - * `src/daemon/snapshot-quality-latch.ts`: a genuine recovered render sets it, a healthy + * `packages/daemon/src/sessions/snapshot-quality-latch.ts`: a genuine recovered render sets it, a healthy * public verdict clears it, and an app switch supersedes it. */ recoveredSnapshotWarningLatch?: { appBundleId?: string }; @@ -290,7 +290,7 @@ export type SessionState = { * app-rendered echo of an already-authored literal. In-memory only for * this session's lifetime: never read by the script writer, the event * log, or diagnostics, and dropped with the session. Owned by - * `src/daemon/session-action-recorder.ts`. + * `packages/daemon/src/core/session-action-recorder.ts`. */ recordedFillLiterals?: Map; /** diff --git a/src/daemon/session-store.ts b/packages/daemon/src/core/session-store.ts similarity index 100% rename from src/daemon/session-store.ts rename to packages/daemon/src/core/session-store.ts diff --git a/src/daemon/session-tenant-scope.ts b/packages/daemon/src/core/session-tenant-scope.ts similarity index 100% rename from src/daemon/session-tenant-scope.ts rename to packages/daemon/src/core/session-tenant-scope.ts diff --git a/src/daemon/settle-observation-capture.ts b/packages/daemon/src/core/settle-observation-capture.ts similarity index 100% rename from src/daemon/settle-observation-capture.ts rename to packages/daemon/src/core/settle-observation-capture.ts diff --git a/src/daemon/snapshot-capture.ts b/packages/daemon/src/core/snapshot-capture.ts similarity index 100% rename from src/daemon/snapshot-capture.ts rename to packages/daemon/src/core/snapshot-capture.ts diff --git a/src/daemon/snapshot-interactor-capture.ts b/packages/daemon/src/core/snapshot-interactor-capture.ts similarity index 100% rename from src/daemon/snapshot-interactor-capture.ts rename to packages/daemon/src/core/snapshot-interactor-capture.ts diff --git a/src/daemon/snapshot-runtime-binding.ts b/packages/daemon/src/core/snapshot-runtime-binding.ts similarity index 100% rename from src/daemon/snapshot-runtime-binding.ts rename to packages/daemon/src/core/snapshot-runtime-binding.ts diff --git a/src/daemon/snapshot-runtime-capture-input.ts b/packages/daemon/src/core/snapshot-runtime-capture-input.ts similarity index 100% rename from src/daemon/snapshot-runtime-capture-input.ts rename to packages/daemon/src/core/snapshot-runtime-capture-input.ts diff --git a/src/daemon/snapshot-session.ts b/packages/daemon/src/core/snapshot-session.ts similarity index 100% rename from src/daemon/snapshot-session.ts rename to packages/daemon/src/core/snapshot-session.ts diff --git a/src/daemon/tenant-owned-entry.ts b/packages/daemon/src/core/tenant-owned-entry.ts similarity index 100% rename from src/daemon/tenant-owned-entry.ts rename to packages/daemon/src/core/tenant-owned-entry.ts diff --git a/src/daemon/touch-runtime.ts b/packages/daemon/src/core/touch-runtime.ts similarity index 100% rename from src/daemon/touch-runtime.ts rename to packages/daemon/src/core/touch-runtime.ts diff --git a/src/daemon/__tests__/android-owner-seam.test.ts b/packages/daemon/src/execution/__tests__/android-owner-seam.test.ts similarity index 92% rename from src/daemon/__tests__/android-owner-seam.test.ts rename to packages/daemon/src/execution/__tests__/android-owner-seam.test.ts index 81e9bcfb27..4c53806429 100644 --- a/src/daemon/__tests__/android-owner-seam.test.ts +++ b/packages/daemon/src/execution/__tests__/android-owner-seam.test.ts @@ -1,14 +1,14 @@ import { test, expect, vi } from 'vitest'; import type { AndroidObservationAdapter } from '@agent-device/contracts/android-observation'; -import { makeAndroidSession } from './support/session-factories.ts'; -import { makeTestScreenRecordingResource } from './support/screen-recording-live-handle.ts'; +import { makeAndroidSession } from '../../__tests__/support/session-factories.ts'; +import { makeTestScreenRecordingResource } from '../../__tests__/support/screen-recording-live-handle.ts'; import { ensureAndroidBlockingSystemDialogReady, recoverAndroidBlockingSystemDialog, } from '../android-system-dialog.ts'; import { detectAndroidEscapeSurface } from '../android-foreground-surface.ts'; import { resolveDirectTouchReferenceFrameSafely } from '../interaction/internal/interaction-touch-reference-frame.ts'; -import { SessionStore } from '../session-store.ts'; +import { SessionStore } from '../../core/session-store.ts'; test('provider-owned Android sessions bypass local observation and recovery', async () => { const session = makeAndroidSession('provider-owned-android', { diff --git a/src/daemon/__tests__/android-system-dialog-occlusion.test.ts b/packages/daemon/src/execution/__tests__/android-system-dialog-occlusion.test.ts similarity index 96% rename from src/daemon/__tests__/android-system-dialog-occlusion.test.ts rename to packages/daemon/src/execution/__tests__/android-system-dialog-occlusion.test.ts index 5cf08ceff7..d6c470ce32 100644 --- a/src/daemon/__tests__/android-system-dialog-occlusion.test.ts +++ b/packages/daemon/src/execution/__tests__/android-system-dialog-occlusion.test.ts @@ -11,9 +11,9 @@ vi.mock('@agent-device/platform-android/mechanics', async (importOriginal) => { import { runAndroidAdb, snapshotAndroid } from '@agent-device/platform-android/mechanics'; import { recoverAndroidBlockingSystemDialog as recoverOwnedAndroidBlockingSystemDialog } from '../android-system-dialog.ts'; -import { androidObservationPolicyFixture as androidObservation } from './android-observation-fixture.ts'; -import { makeAndroidSession } from './support/session-factories.ts'; -import { makeTestScreenRecordingResource } from './support/screen-recording-live-handle.ts'; +import { androidObservationPolicyFixture as androidObservation } from '../../__tests__/support/android-observation-fixture.ts'; +import { makeAndroidSession } from '../../__tests__/support/session-factories.ts'; +import { makeTestScreenRecordingResource } from '../../__tests__/support/screen-recording-live-handle.ts'; import { makeAndroidSnapshotCapture } from '@agent-device/platform-android/snapshot-capture-fixtures'; const recoverAndroidBlockingSystemDialog = ( diff --git a/src/daemon/__tests__/android-system-dialog-ref-frame.test.ts b/packages/daemon/src/execution/__tests__/android-system-dialog-ref-frame.test.ts similarity index 88% rename from src/daemon/__tests__/android-system-dialog-ref-frame.test.ts rename to packages/daemon/src/execution/__tests__/android-system-dialog-ref-frame.test.ts index 3a996c8e2c..67dab9618d 100644 --- a/src/daemon/__tests__/android-system-dialog-ref-frame.test.ts +++ b/packages/daemon/src/execution/__tests__/android-system-dialog-ref-frame.test.ts @@ -9,11 +9,11 @@ vi.mock('@agent-device/platform-android/mechanics', async (importOriginal) => { import { runAndroidAdb, snapshotAndroid } from '@agent-device/platform-android/mechanics'; import { recoverAndroidBlockingSystemDialog as recoverOwnedAndroidBlockingSystemDialog } from '../android-system-dialog.ts'; -import { androidObservationPolicyFixture as androidObservation } from './android-observation-fixture.ts'; -import { makeAndroidSession } from './support/session-factories.ts'; -import { makeTestScreenRecordingResource } from './support/screen-recording-live-handle.ts'; +import { androidObservationPolicyFixture as androidObservation } from '../../__tests__/support/android-observation-fixture.ts'; +import { makeAndroidSession } from '../../__tests__/support/session-factories.ts'; +import { makeTestScreenRecordingResource } from '../../__tests__/support/screen-recording-live-handle.ts'; import { makeAndroidSnapshotCapture } from '@agent-device/platform-android/snapshot-capture-fixtures'; -import { refFrameState } from '../ref-frame.ts'; +import { refFrameState } from '../../core/ref-frame.ts'; const recoverAndroidBlockingSystemDialog = ( params: Omit[0], 'observation'>, diff --git a/src/daemon/__tests__/android-system-dialog.test.ts b/packages/daemon/src/execution/__tests__/android-system-dialog.test.ts similarity index 88% rename from src/daemon/__tests__/android-system-dialog.test.ts rename to packages/daemon/src/execution/__tests__/android-system-dialog.test.ts index 11e9792374..4455fe7e77 100644 --- a/src/daemon/__tests__/android-system-dialog.test.ts +++ b/packages/daemon/src/execution/__tests__/android-system-dialog.test.ts @@ -1,7 +1,7 @@ import { test, expect, vi } from 'vitest'; import { AppError } from '@agent-device/kernel/errors'; -import { makeAndroidSession } from './support/session-factories.ts'; -import { makeTestScreenRecordingResource } from './support/screen-recording-live-handle.ts'; +import { makeAndroidSession } from '../../__tests__/support/session-factories.ts'; +import { makeTestScreenRecordingResource } from '../../__tests__/support/screen-recording-live-handle.ts'; vi.mock('@agent-device/platform-android/mechanics', async (importOriginal) => { const actual = await importOriginal(); @@ -10,7 +10,7 @@ vi.mock('@agent-device/platform-android/mechanics', async (importOriginal) => { import { snapshotAndroid } from '@agent-device/platform-android/mechanics'; import { recoverAndroidBlockingSystemDialog as recoverOwnedAndroidBlockingSystemDialog } from '../android-system-dialog.ts'; -import { androidObservationPolicyFixture as androidObservation } from './android-observation-fixture.ts'; +import { androidObservationPolicyFixture as androidObservation } from '../../__tests__/support/android-observation-fixture.ts'; const recoverAndroidBlockingSystemDialog = ( params: Omit[0], 'observation'>, diff --git a/src/daemon/__tests__/back-runtime.test.ts b/packages/daemon/src/execution/__tests__/back-runtime.test.ts similarity index 86% rename from src/daemon/__tests__/back-runtime.test.ts rename to packages/daemon/src/execution/__tests__/back-runtime.test.ts index 5dc2420152..90a1c045f7 100644 --- a/src/daemon/__tests__/back-runtime.test.ts +++ b/packages/daemon/src/execution/__tests__/back-runtime.test.ts @@ -1,4 +1,4 @@ -import { daemonPlatformServicesFixture } from './platform-services-fixture.ts'; +import { daemonPlatformServicesFixture } from '../../__tests__/support/platform-services-fixture.ts'; import { expect, test, vi } from 'vitest'; import { backRuntimeOperationFacts } from '@agent-device/contracts/back-runtime'; import { @@ -14,17 +14,20 @@ import { type PlatformRuntimeOperations, } from '@agent-device/contracts/platform-runtime-operations'; import { deviceShape } from '@agent-device/kernel/device'; -import { makeSession } from './support/session-factories.ts'; -import { makeSessionStore } from './support/store-factory.ts'; +import { makeSession } from '../../__tests__/support/session-factories.ts'; +import { makeSessionStore } from '../../__tests__/support/store-factory.ts'; import { createTestDeviceInventoryGateways } from '@agent-device/device-selection/inventory-gateways-fixtures'; -import { LeaseRegistry } from '../lease-registry.ts'; -import { activateCompleteRefFrame, refFrameState } from '../ref-frame.ts'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts'; -import type { GenericPlatformExecutionParams } from '../generic-leaf-execution.ts'; +import { LeaseRegistry } from '../../resources/lease-registry.ts'; +import { activateCompleteRefFrame, refFrameState } from '../../core/ref-frame.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../../core/request-runtime-binding.ts'; +import type { GenericPlatformExecutionParams } from '../../core/generic-leaf-execution.ts'; import { resolveBoundBackRuntime } from '../back-runtime.ts'; -import { expectRefusesUnavailableExactOwnerFact } from './runtime-binding-conformance.ts'; -import { createRequestHandler } from './test-device-runtime-gateway.ts'; -import { fakeCreateCommandSurface } from './support/command-surface-fake.ts'; +import { expectRefusesUnavailableExactOwnerFact } from '../../__tests__/support/runtime-binding-conformance.ts'; +import { createRequestHandler } from '../../__tests__/support/test-device-runtime-gateway.ts'; +import { fakeCreateCommandSurface } from '../../__tests__/support/command-surface-fake.ts'; // File-scoped id, not the widely shared 'ios-simulator' literal: this owner binding's // `local-family` kind reaches the real on-disk device-claim admission (`require-owner` diff --git a/src/daemon/__tests__/focus-runtime.test.ts b/packages/daemon/src/execution/__tests__/focus-runtime.test.ts similarity index 89% rename from src/daemon/__tests__/focus-runtime.test.ts rename to packages/daemon/src/execution/__tests__/focus-runtime.test.ts index 8a97b29908..a05f5cc25c 100644 --- a/src/daemon/__tests__/focus-runtime.test.ts +++ b/packages/daemon/src/execution/__tests__/focus-runtime.test.ts @@ -1,4 +1,4 @@ -import { daemonPlatformServicesFixture } from './platform-services-fixture.ts'; +import { daemonPlatformServicesFixture } from '../../__tests__/support/platform-services-fixture.ts'; import { expect, test, vi } from 'vitest'; import { focusRuntimeOperationFacts } from '@agent-device/contracts/focus-runtime'; import { @@ -14,17 +14,20 @@ import { focusRuntimeUse, } from '@agent-device/contracts/platform-runtime-operations'; import { deviceShape } from '@agent-device/kernel/device'; -import { makeSession } from './support/session-factories.ts'; -import { makeSessionStore } from './support/store-factory.ts'; +import { makeSession } from '../../__tests__/support/session-factories.ts'; +import { makeSessionStore } from '../../__tests__/support/store-factory.ts'; import { createTestDeviceInventoryGateways } from '@agent-device/device-selection/inventory-gateways-fixtures'; -import { LeaseRegistry } from '../lease-registry.ts'; -import { activateCompleteRefFrame, refFrameState } from '../ref-frame.ts'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts'; -import type { GenericPlatformExecutionParams } from '../generic-leaf-execution.ts'; +import { LeaseRegistry } from '../../resources/lease-registry.ts'; +import { activateCompleteRefFrame, refFrameState } from '../../core/ref-frame.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../../core/request-runtime-binding.ts'; +import type { GenericPlatformExecutionParams } from '../../core/generic-leaf-execution.ts'; import { readFocusPoint, resolveBoundFocusRuntime } from '../focus-runtime.ts'; -import { expectRefusesUnavailableExactOwnerFact } from './runtime-binding-conformance.ts'; -import { createRequestHandler } from './test-device-runtime-gateway.ts'; -import { fakeCreateCommandSurface } from './support/command-surface-fake.ts'; +import { expectRefusesUnavailableExactOwnerFact } from '../../__tests__/support/runtime-binding-conformance.ts'; +import { createRequestHandler } from '../../__tests__/support/test-device-runtime-gateway.ts'; +import { fakeCreateCommandSurface } from '../../__tests__/support/command-surface-fake.ts'; const appleDevice = { id: 'ios-simulator', diff --git a/src/daemon/__tests__/fold-runtime.test.ts b/packages/daemon/src/execution/__tests__/fold-runtime.test.ts similarity index 93% rename from src/daemon/__tests__/fold-runtime.test.ts rename to packages/daemon/src/execution/__tests__/fold-runtime.test.ts index 7382d0ba1c..eae9f118ea 100644 --- a/src/daemon/__tests__/fold-runtime.test.ts +++ b/packages/daemon/src/execution/__tests__/fold-runtime.test.ts @@ -1,5 +1,5 @@ -import { daemonPlatformServicesFixture } from './platform-services-fixture.ts'; -import { recordActionEntry } from '../session-action-recorder.ts'; +import { daemonPlatformServicesFixture } from '../../__tests__/support/platform-services-fixture.ts'; +import { recordActionEntry } from '../../core/session-action-recorder.ts'; import { expect, test, vi } from 'vitest'; import { @@ -18,11 +18,14 @@ import { type PlatformRuntimeOperations, } from '@agent-device/contracts/platform-runtime-operations'; import { deviceShape, type DeviceInfo } from '@agent-device/kernel/device'; -import { makeSession } from './support/session-factories.ts'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts'; -import type { GenericPlatformExecutionParams } from '../generic-leaf-execution.ts'; +import { makeSession } from '../../__tests__/support/session-factories.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../../core/request-runtime-binding.ts'; +import type { GenericPlatformExecutionParams } from '../../core/generic-leaf-execution.ts'; import { readRequestedFoldPose, resolveBoundFoldRuntime } from '../fold-runtime.ts'; -import { expectRefusesUnavailableExactOwnerFact } from './runtime-binding-conformance.ts'; +import { expectRefusesUnavailableExactOwnerFact } from '../../__tests__/support/runtime-binding-conformance.ts'; // File-scoped id: this owner binding's `local-family` kind reaches the real on-disk device-claim // admission, so a shared id risks a cross-file claim collision under parallel execution. diff --git a/src/daemon/__tests__/generic-route-runtime-completeness.test.ts b/packages/daemon/src/execution/__tests__/generic-route-runtime-completeness.test.ts similarity index 100% rename from src/daemon/__tests__/generic-route-runtime-completeness.test.ts rename to packages/daemon/src/execution/__tests__/generic-route-runtime-completeness.test.ts diff --git a/src/daemon/__tests__/interaction-get-runtime-fixture.ts b/packages/daemon/src/execution/__tests__/interaction-get-runtime-fixture.ts similarity index 95% rename from src/daemon/__tests__/interaction-get-runtime-fixture.ts rename to packages/daemon/src/execution/__tests__/interaction-get-runtime-fixture.ts index 563b4ddc09..e889bd06fb 100644 --- a/src/daemon/__tests__/interaction-get-runtime-fixture.ts +++ b/packages/daemon/src/execution/__tests__/interaction-get-runtime-fixture.ts @@ -30,11 +30,14 @@ import type { QuerySelectorResult, } from '@agent-device/contracts/selector-observation-runtime'; import type { DeviceInfo } from '@agent-device/kernel/device'; -import type { DaemonPlatformServices } from '../platform-services.ts'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts'; -import { captureSnapshotWithInteractor } from '../snapshot-interactor-capture.ts'; -import { daemonPlatformServicesFixture } from './platform-services-fixture.ts'; -import { androidObservationFixture } from './android-observation-fixture.ts'; +import type { DaemonPlatformServices } from '../../core/platform-services.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../../core/request-runtime-binding.ts'; +import { captureSnapshotWithInteractor } from '../../core/snapshot-interactor-capture.ts'; +import { daemonPlatformServicesFixture } from '../../__tests__/support/platform-services-fixture.ts'; +import { androidObservationFixture } from '../../__tests__/support/android-observation-fixture.ts'; import { createUnavailableRuntimeFactsForTest } from '@agent-device/test-kit/runtime-operation-facts'; /** diff --git a/src/daemon/__tests__/interaction-surface-baseline-evidence.test.ts b/packages/daemon/src/execution/__tests__/interaction-surface-baseline-evidence.test.ts similarity index 99% rename from src/daemon/__tests__/interaction-surface-baseline-evidence.test.ts rename to packages/daemon/src/execution/__tests__/interaction-surface-baseline-evidence.test.ts index 27cb6a1f3f..6b876eb980 100644 --- a/src/daemon/__tests__/interaction-surface-baseline-evidence.test.ts +++ b/packages/daemon/src/execution/__tests__/interaction-surface-baseline-evidence.test.ts @@ -4,7 +4,7 @@ import type { SnapshotNode } from '@agent-device/kernel/snapshot'; import { buildInteractionSurfaceSignature, classifyBaselineSurfaceEvidence, -} from '../interaction-surface-signature.ts'; +} from '../../core/interaction-surface-signature.ts'; // #1569: node shapes below are transcribed from a live iPhone 17 Pro capture of // examples/test-app's checkout form, before and after `scroll down 0.6`. Two diff --git a/src/daemon/__tests__/internal-observation.test.ts b/packages/daemon/src/execution/__tests__/internal-observation.test.ts similarity index 98% rename from src/daemon/__tests__/internal-observation.test.ts rename to packages/daemon/src/execution/__tests__/internal-observation.test.ts index 271ad4ed47..e0f865439f 100644 --- a/src/daemon/__tests__/internal-observation.test.ts +++ b/packages/daemon/src/execution/__tests__/internal-observation.test.ts @@ -1,6 +1,6 @@ import path from 'node:path'; import { expect, test } from 'vitest'; -import { makeIosSession } from './support/session-factories.ts'; +import { makeIosSession } from '../../__tests__/support/session-factories.ts'; import type { SnapshotState } from '@agent-device/kernel/snapshot'; import { bindInternalObservationAuthority } from '../internal-observation.ts'; import { @@ -9,9 +9,9 @@ import { refFrameScope, refFrameState, refFrameTree, -} from '../ref-frame.ts'; +} from '../../core/ref-frame.ts'; import { markSessionPartialRefsIssued, setSessionSnapshot } from '../session-snapshot.ts'; -import { SessionStore } from '../session-store.ts'; +import { SessionStore } from '../../core/session-store.ts'; import { mkdtempForTestSync } from '@agent-device/test-kit/tmp-dir'; function snapshot(ref: string, label = ref): SnapshotState { diff --git a/src/daemon/__tests__/keyboard-runtime.test.ts b/packages/daemon/src/execution/__tests__/keyboard-runtime.test.ts similarity index 98% rename from src/daemon/__tests__/keyboard-runtime.test.ts rename to packages/daemon/src/execution/__tests__/keyboard-runtime.test.ts index a9caf533e9..0342812f20 100644 --- a/src/daemon/__tests__/keyboard-runtime.test.ts +++ b/packages/daemon/src/execution/__tests__/keyboard-runtime.test.ts @@ -1,4 +1,4 @@ -import { daemonPlatformServicesFixture } from './platform-services-fixture.ts'; +import { daemonPlatformServicesFixture } from '../../__tests__/support/platform-services-fixture.ts'; import { expect, test, vi } from 'vitest'; import { keyboardRuntimeOperationFacts, @@ -20,7 +20,10 @@ import { type PlatformRuntimeOperations, } from '@agent-device/contracts/platform-runtime-operations'; import { deviceShape, type DeviceInfo } from '@agent-device/kernel/device'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../../core/request-runtime-binding.ts'; import { resolveBoundKeyboardRuntime } from '../keyboard-runtime.ts'; // File-scoped ids, not the widely shared 'emulator-5554'/'ios-simulator' literals: these owner diff --git a/src/daemon/__tests__/offscreen-target-probe.test.ts b/packages/daemon/src/execution/__tests__/offscreen-target-probe.test.ts similarity index 98% rename from src/daemon/__tests__/offscreen-target-probe.test.ts rename to packages/daemon/src/execution/__tests__/offscreen-target-probe.test.ts index b08dd4b5be..0ddbdb2a1d 100644 --- a/src/daemon/__tests__/offscreen-target-probe.test.ts +++ b/packages/daemon/src/execution/__tests__/offscreen-target-probe.test.ts @@ -6,7 +6,7 @@ import type { QuerySelectorInput, QuerySelectorResult, } from '@agent-device/contracts/selector-observation-runtime'; -import type { SessionState } from '../session-state.ts'; +import type { SessionState } from '../../core/session-state.ts'; import { confirmIosOffscreenTargetVisible } from '../offscreen-target-probe.ts'; diff --git a/src/daemon/__tests__/orientation-runtime.test.ts b/packages/daemon/src/execution/__tests__/orientation-runtime.test.ts similarity index 89% rename from src/daemon/__tests__/orientation-runtime.test.ts rename to packages/daemon/src/execution/__tests__/orientation-runtime.test.ts index d0a4032a73..78d0998079 100644 --- a/src/daemon/__tests__/orientation-runtime.test.ts +++ b/packages/daemon/src/execution/__tests__/orientation-runtime.test.ts @@ -1,6 +1,6 @@ -import { daemonPlatformServicesFixture } from './platform-services-fixture.ts'; +import { daemonPlatformServicesFixture } from '../../__tests__/support/platform-services-fixture.ts'; import { expect, test, vi } from 'vitest'; -import { fakeCreateCommandSurface } from './support/command-surface-fake.ts'; +import { fakeCreateCommandSurface } from '../../__tests__/support/command-surface-fake.ts'; // `orientation` carries `androidBlockingDialogGuard: true` (like every other generic-route leaf // in this migration), so this file's Android device reaching the real request router below hits @@ -37,20 +37,23 @@ import { type PlatformRuntimeOperations, } from '@agent-device/contracts/platform-runtime-operations'; import { deviceShape } from '@agent-device/kernel/device'; -import { makeSession } from './support/session-factories.ts'; -import { makeSessionStore } from './support/store-factory.ts'; +import { makeSession } from '../../__tests__/support/session-factories.ts'; +import { makeSessionStore } from '../../__tests__/support/store-factory.ts'; import { createTestDeviceInventoryGateways } from '@agent-device/device-selection/inventory-gateways-fixtures'; -import { LeaseRegistry } from '../lease-registry.ts'; -import { activateCompleteRefFrame, refFrameState } from '../ref-frame.ts'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts'; -import type { GenericPlatformExecutionParams } from '../generic-leaf-execution.ts'; +import { LeaseRegistry } from '../../resources/lease-registry.ts'; +import { activateCompleteRefFrame, refFrameState } from '../../core/ref-frame.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../../core/request-runtime-binding.ts'; +import type { GenericPlatformExecutionParams } from '../../core/generic-leaf-execution.ts'; import { readRequestedOrientation, resolveBoundOrientationRuntime, } from '../orientation-runtime.ts'; -import { expectRefusesUnavailableExactOwnerFact } from './runtime-binding-conformance.ts'; -import { createRequestHandler } from './test-device-runtime-gateway.ts'; -import { androidObservationFixture } from './android-observation-fixture.ts'; +import { expectRefusesUnavailableExactOwnerFact } from '../../__tests__/support/runtime-binding-conformance.ts'; +import { createRequestHandler } from '../../__tests__/support/test-device-runtime-gateway.ts'; +import { androidObservationFixture } from '../../__tests__/support/android-observation-fixture.ts'; // File-scoped id, not a shared literal: this owner binding's `local-family` kind reaches the // real on-disk device-claim admission (`require-owner` policy), so a shared id risks a diff --git a/src/daemon/__tests__/ref-snapshot-flag-policy.test.ts b/packages/daemon/src/execution/__tests__/ref-snapshot-flag-policy.test.ts similarity index 100% rename from src/daemon/__tests__/ref-snapshot-flag-policy.test.ts rename to packages/daemon/src/execution/__tests__/ref-snapshot-flag-policy.test.ts diff --git a/src/daemon/__tests__/runtime-policy.test.ts b/packages/daemon/src/execution/__tests__/runtime-policy.test.ts similarity index 100% rename from src/daemon/__tests__/runtime-policy.test.ts rename to packages/daemon/src/execution/__tests__/runtime-policy.test.ts diff --git a/src/daemon/__tests__/screenshot-crop-target.test.ts b/packages/daemon/src/execution/__tests__/screenshot-crop-target.test.ts similarity index 100% rename from src/daemon/__tests__/screenshot-crop-target.test.ts rename to packages/daemon/src/execution/__tests__/screenshot-crop-target.test.ts diff --git a/src/daemon/__tests__/screenshot-crop.test.ts b/packages/daemon/src/execution/__tests__/screenshot-crop.test.ts similarity index 97% rename from src/daemon/__tests__/screenshot-crop.test.ts rename to packages/daemon/src/execution/__tests__/screenshot-crop.test.ts index 2ebe1736bf..ca060f702b 100644 --- a/src/daemon/__tests__/screenshot-crop.test.ts +++ b/packages/daemon/src/execution/__tests__/screenshot-crop.test.ts @@ -1,5 +1,5 @@ import { ANDROID_EMULATOR, IOS_SIMULATOR } from '@agent-device/test-kit/device-fixtures'; -import { makeSession } from './support/session-factories.ts'; +import { makeSession } from '../../__tests__/support/session-factories.ts'; import { readPngSize } from '@agent-device/capture-kit/png-size'; import { SCREENSHOT_CROP_REASONS } from '@agent-device/contracts/capture'; import type { SessionSurface } from '@agent-device/contracts/session'; @@ -14,9 +14,9 @@ import type { import fs from 'node:fs'; import path from 'node:path'; import { expect, test, vi } from 'vitest'; -import type { SessionState } from '../session-state.ts'; +import type { SessionState } from '../../core/session-state.ts'; import { buildScreenshotCropWarnings, cropScreenshotToSelector } from '../screenshot-crop.ts'; -import { writeSolidPng } from './screenshot-runtime-fixture.ts'; +import { writeSolidPng } from '../../__tests__/support/screenshot-runtime-fixture.ts'; import { mkdtempForTestSync } from '@agent-device/test-kit/tmp-dir'; test('the warning composition is the single owner: partial intersection and only', () => { diff --git a/src/daemon/__tests__/scroll-movement.test.ts b/packages/daemon/src/execution/__tests__/scroll-movement.test.ts similarity index 99% rename from src/daemon/__tests__/scroll-movement.test.ts rename to packages/daemon/src/execution/__tests__/scroll-movement.test.ts index 1e2a400be3..8496b50c9e 100644 --- a/src/daemon/__tests__/scroll-movement.test.ts +++ b/packages/daemon/src/execution/__tests__/scroll-movement.test.ts @@ -14,8 +14,8 @@ import type { Rect, SnapshotNode } from '@agent-device/kernel/snapshot'; import { emitDiagnostic } from '@agent-device/host-kit/diagnostics'; import { readScrollEdgeState } from '@agent-device/capture-kit/scroll-edge-state'; import { IOS_SIMULATOR, MACOS_DEVICE } from '@agent-device/test-kit/device-fixtures'; -import { makeSession } from './support/session-factories.ts'; -import { expireRefFrame } from '../ref-frame.ts'; +import { makeSession } from '../../__tests__/support/session-factories.ts'; +import { expireRefFrame } from '../../core/ref-frame.ts'; import { observeScrollMovement, planScrollMovement, diff --git a/src/daemon/__tests__/scroll-runtime.test.ts b/packages/daemon/src/execution/__tests__/scroll-runtime.test.ts similarity index 97% rename from src/daemon/__tests__/scroll-runtime.test.ts rename to packages/daemon/src/execution/__tests__/scroll-runtime.test.ts index 1104f840ce..e34a6a3f4c 100644 --- a/src/daemon/__tests__/scroll-runtime.test.ts +++ b/packages/daemon/src/execution/__tests__/scroll-runtime.test.ts @@ -1,12 +1,12 @@ -import { daemonPlatformServicesFixture } from './platform-services-fixture.ts'; +import { daemonPlatformServicesFixture } from '../../__tests__/support/platform-services-fixture.ts'; import { expect, expectTypeOf, test } from 'vitest'; import assert from 'node:assert/strict'; import { buildSnapshotState } from '@agent-device/capture-kit/snapshot-state'; import { AppError } from '@agent-device/kernel/errors'; import type { CommandFlags } from '@agent-device/contracts/command'; -import type { DaemonRequest } from '../daemon-request.ts'; -import type { SessionState } from '../session-state.ts'; -import type { GenericPlatformExecutionParams } from '../generic-leaf-execution.ts'; +import type { DaemonRequest } from '../../core/daemon-request.ts'; +import type { SessionState } from '../../core/session-state.ts'; +import type { GenericPlatformExecutionParams } from '../../core/generic-leaf-execution.ts'; import type { SnapshotNode } from '@agent-device/kernel/snapshot'; import type { BoundDeviceRuntime, RuntimeFacts } from '@agent-device/contracts/platform-runtime'; import { @@ -14,13 +14,16 @@ import { resolveScrollRuntimePlan, type ScrollRuntimePlan, } from '@agent-device/contracts/platform-runtime-operations'; -import type { DaemonCommandContext } from '../context.ts'; +import type { DaemonCommandContext } from '../../core/context.ts'; import { resolveBoundScrollRuntime } from '../scroll-runtime.ts'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../../core/request-runtime-binding.ts'; import { unavailableDeploymentSnapshotAndShutdownOperationFacts } from '@agent-device/test-kit/runtime-operation-facts'; import { IOS_SIMULATOR } from '@agent-device/test-kit/device-fixtures'; -import { makeIosSession, makeMacOsSession } from './support/session-factories.ts'; -import { activateCompleteRefFrame, expireRefFrame } from '../ref-frame.ts'; +import { makeIosSession, makeMacOsSession } from '../../__tests__/support/session-factories.ts'; +import { activateCompleteRefFrame, expireRefFrame } from '../../core/ref-frame.ts'; /** * The retired `handleScrollCommand` suite, re-pointed at the bound runtime (R43). Every diff --git a/src/daemon/__tests__/selector-capture-binding.test.ts b/packages/daemon/src/execution/__tests__/selector-capture-binding.test.ts similarity index 93% rename from src/daemon/__tests__/selector-capture-binding.test.ts rename to packages/daemon/src/execution/__tests__/selector-capture-binding.test.ts index f38b1a7101..4d2d76e3e2 100644 --- a/src/daemon/__tests__/selector-capture-binding.test.ts +++ b/packages/daemon/src/execution/__tests__/selector-capture-binding.test.ts @@ -1,13 +1,13 @@ -import { daemonPlatformServicesFixture } from './platform-services-fixture.ts'; +import { daemonPlatformServicesFixture } from '../../__tests__/support/platform-services-fixture.ts'; import { expect, test } from 'vitest'; import { ANDROID_EMULATOR, IOS_SIMULATOR } from '@agent-device/test-kit/device-fixtures'; -import { makeAndroidSession, makeIosSession } from './support/session-factories.ts'; -import { makeSessionStore } from './support/store-factory.ts'; +import { makeAndroidSession, makeIosSession } from '../../__tests__/support/session-factories.ts'; +import { makeSessionStore } from '../../__tests__/support/store-factory.ts'; import { withTestDeviceInventory } from '@agent-device/device-selection/inventory-gateways-fixtures'; import { resolveBoundSelectorCapture } from '../selector-capture-binding.ts'; import { createBoundSelectorRuntime } from '../selector-runtime-backend.ts'; -import { selectorCaptureFixture } from './selector-capture-fixture.ts'; -import { fakeCreateCommandSurface } from './support/command-surface-fake.ts'; +import { selectorCaptureFixture } from '../../__tests__/support/selector-capture-fixture.ts'; +import { fakeCreateCommandSurface } from '../../__tests__/support/command-surface-fake.ts'; // The seam every selector unit consumes. `find` landed it; `get`, `is`, and `wait` migrate by // naming their command, so these are the guarantees they inherit rather than re-derive. diff --git a/src/daemon/__tests__/selector-capture-runtime.test.ts b/packages/daemon/src/execution/__tests__/selector-capture-runtime.test.ts similarity index 98% rename from src/daemon/__tests__/selector-capture-runtime.test.ts rename to packages/daemon/src/execution/__tests__/selector-capture-runtime.test.ts index 6eae38f60b..e2bb9e9e1c 100644 --- a/src/daemon/__tests__/selector-capture-runtime.test.ts +++ b/packages/daemon/src/execution/__tests__/selector-capture-runtime.test.ts @@ -8,10 +8,10 @@ import { type IosTargetActivation, type SnapshotState, } from '@agent-device/kernel/snapshot'; -import type { DaemonResponse } from '../daemon-request.ts'; -import { type RequestCaptureProof, withCaptureDisclosures } from '../capture-disclosure.ts'; -import { makeIosSession } from './support/session-factories.ts'; -import { makeSessionStore } from './support/store-factory.ts'; +import type { DaemonResponse } from '../../core/daemon-request.ts'; +import { type RequestCaptureProof, withCaptureDisclosures } from '../../core/capture-disclosure.ts'; +import { makeIosSession } from '../../__tests__/support/session-factories.ts'; +import { makeSessionStore } from '../../__tests__/support/store-factory.ts'; import { createSelectorCaptureRuntime } from '../selector-capture-runtime.ts'; // R35: the capture runtime executes only through its request-bound capture — there is no diff --git a/src/daemon/__tests__/selector-text-runtime.test.ts b/packages/daemon/src/execution/__tests__/selector-text-runtime.test.ts similarity index 100% rename from src/daemon/__tests__/selector-text-runtime.test.ts rename to packages/daemon/src/execution/__tests__/selector-text-runtime.test.ts diff --git a/src/daemon/__tests__/session-snapshot.test.ts b/packages/daemon/src/execution/__tests__/session-snapshot.test.ts similarity index 98% rename from src/daemon/__tests__/session-snapshot.test.ts rename to packages/daemon/src/execution/__tests__/session-snapshot.test.ts index c638122617..8920a289e9 100644 --- a/src/daemon/__tests__/session-snapshot.test.ts +++ b/packages/daemon/src/execution/__tests__/session-snapshot.test.ts @@ -1,9 +1,9 @@ import { expect, test } from 'vitest'; -import { makeSessionStore } from './support/store-factory.ts'; +import { makeSessionStore } from '../../__tests__/support/store-factory.ts'; import type { SettleObservation } from '@agent-device/contracts/interaction'; import { AppError } from '@agent-device/kernel/errors'; import type { SnapshotState } from '@agent-device/kernel/snapshot'; -import type { SessionState } from '../session-state.ts'; +import type { SessionState } from '../../core/session-state.ts'; import { markSessionPartialRefsIssued, issueSettleRefs, @@ -21,7 +21,7 @@ import { refFrameEpoch, refFrameScope, refFrameState, -} from '../ref-frame.ts'; +} from '../../core/ref-frame.ts'; function makeSession(): SessionState { return { diff --git a/src/daemon/__tests__/system-button-runtime.test.ts b/packages/daemon/src/execution/__tests__/system-button-runtime.test.ts similarity index 88% rename from src/daemon/__tests__/system-button-runtime.test.ts rename to packages/daemon/src/execution/__tests__/system-button-runtime.test.ts index 7ea81ecb8d..5d0e6133a7 100644 --- a/src/daemon/__tests__/system-button-runtime.test.ts +++ b/packages/daemon/src/execution/__tests__/system-button-runtime.test.ts @@ -1,4 +1,4 @@ -import { daemonPlatformServicesFixture } from './platform-services-fixture.ts'; +import { daemonPlatformServicesFixture } from '../../__tests__/support/platform-services-fixture.ts'; import { expect, test, vi } from 'vitest'; import { systemButtonRuntimeOperationFacts } from '@agent-device/contracts/system-button-runtime'; import { @@ -17,13 +17,16 @@ import { } from '@agent-device/contracts/platform-runtime-operations'; import type { SystemButton } from '@agent-device/contracts/system-button-runtime'; import { deviceShape, type DeviceInfo } from '@agent-device/kernel/device'; -import { makeSession } from './support/session-factories.ts'; -import { makeSessionStore } from './support/store-factory.ts'; +import { makeSession } from '../../__tests__/support/session-factories.ts'; +import { makeSessionStore } from '../../__tests__/support/store-factory.ts'; import { createTestDeviceInventoryGateways } from '@agent-device/device-selection/inventory-gateways-fixtures'; -import { LeaseRegistry } from '../lease-registry.ts'; -import { activateCompleteRefFrame, refFrameState } from '../ref-frame.ts'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts'; -import type { GenericPlatformExecutionParams } from '../generic-leaf-execution.ts'; +import { LeaseRegistry } from '../../resources/lease-registry.ts'; +import { activateCompleteRefFrame, refFrameState } from '../../core/ref-frame.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../../core/request-runtime-binding.ts'; +import type { GenericPlatformExecutionParams } from '../../core/generic-leaf-execution.ts'; import { resolveBoundSystemButtonRuntime, type SystemButtonCommand, @@ -31,9 +34,9 @@ import { import { expectRefusesUnavailableExactOwnerFact, systemButtonCommands, -} from './runtime-binding-conformance.ts'; -import { createRequestHandler } from './test-device-runtime-gateway.ts'; -import { fakeCreateCommandSurface } from './support/command-surface-fake.ts'; +} from '../../__tests__/support/runtime-binding-conformance.ts'; +import { createRequestHandler } from '../../__tests__/support/test-device-runtime-gateway.ts'; +import { fakeCreateCommandSurface } from '../../__tests__/support/command-surface-fake.ts'; const macOsDevice = { id: 'macos-host', diff --git a/src/daemon/__tests__/tv-remote-runtime.test.ts b/packages/daemon/src/execution/__tests__/tv-remote-runtime.test.ts similarity index 90% rename from src/daemon/__tests__/tv-remote-runtime.test.ts rename to packages/daemon/src/execution/__tests__/tv-remote-runtime.test.ts index 2fd82435cc..63a6956136 100644 --- a/src/daemon/__tests__/tv-remote-runtime.test.ts +++ b/packages/daemon/src/execution/__tests__/tv-remote-runtime.test.ts @@ -1,4 +1,4 @@ -import { daemonPlatformServicesFixture } from './platform-services-fixture.ts'; +import { daemonPlatformServicesFixture } from '../../__tests__/support/platform-services-fixture.ts'; import { expect, test, vi } from 'vitest'; import { localRuntimeOwner, @@ -14,17 +14,20 @@ import { } from '@agent-device/contracts/platform-runtime-operations'; import { tvRemoteRuntimeOperationFacts } from '@agent-device/contracts/tv-remote-runtime'; import { deviceShape } from '@agent-device/kernel/device'; -import { makeSession } from './support/session-factories.ts'; -import { makeSessionStore } from './support/store-factory.ts'; +import { makeSession } from '../../__tests__/support/session-factories.ts'; +import { makeSessionStore } from '../../__tests__/support/store-factory.ts'; import { createTestDeviceInventoryGateways } from '@agent-device/device-selection/inventory-gateways-fixtures'; -import { LeaseRegistry } from '../lease-registry.ts'; -import { activateCompleteRefFrame, refFrameState } from '../ref-frame.ts'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts'; -import type { GenericPlatformExecutionParams } from '../generic-leaf-execution.ts'; +import { LeaseRegistry } from '../../resources/lease-registry.ts'; +import { activateCompleteRefFrame, refFrameState } from '../../core/ref-frame.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../../core/request-runtime-binding.ts'; +import type { GenericPlatformExecutionParams } from '../../core/generic-leaf-execution.ts'; import { resolveBoundTvRemoteRuntime } from '../tv-remote-runtime.ts'; -import { expectRefusesUnavailableExactOwnerFact } from './runtime-binding-conformance.ts'; -import { createRequestHandler } from './test-device-runtime-gateway.ts'; -import { fakeCreateCommandSurface } from './support/command-surface-fake.ts'; +import { expectRefusesUnavailableExactOwnerFact } from '../../__tests__/support/runtime-binding-conformance.ts'; +import { createRequestHandler } from '../../__tests__/support/test-device-runtime-gateway.ts'; +import { fakeCreateCommandSurface } from '../../__tests__/support/command-surface-fake.ts'; const vegaVvd = { id: 'vega-vvd', diff --git a/src/daemon/__tests__/type-text-runtime.test.ts b/packages/daemon/src/execution/__tests__/type-text-runtime.test.ts similarity index 94% rename from src/daemon/__tests__/type-text-runtime.test.ts rename to packages/daemon/src/execution/__tests__/type-text-runtime.test.ts index 0a842678b3..2f37a978e7 100644 --- a/src/daemon/__tests__/type-text-runtime.test.ts +++ b/packages/daemon/src/execution/__tests__/type-text-runtime.test.ts @@ -1,4 +1,4 @@ -import { daemonPlatformServicesFixture } from './platform-services-fixture.ts'; +import { daemonPlatformServicesFixture } from '../../__tests__/support/platform-services-fixture.ts'; import { expect, test, vi } from 'vitest'; import { type DeviceBinding, @@ -16,9 +16,12 @@ import { typeTextRuntimeOperationFacts, } from '@agent-device/contracts/type-text-runtime'; import { deviceShape } from '@agent-device/kernel/device'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../../core/request-runtime-binding.ts'; import { resolveBoundTypeTextRuntime } from '../type-text-runtime.ts'; -import { expectRefusesUnavailableExactOwnerFact } from './runtime-binding-conformance.ts'; +import { expectRefusesUnavailableExactOwnerFact } from '../../__tests__/support/runtime-binding-conformance.ts'; const appleDevice = { id: 'ios-simulator', diff --git a/src/daemon/__tests__/viewport-runtime.test.ts b/packages/daemon/src/execution/__tests__/viewport-runtime.test.ts similarity index 87% rename from src/daemon/__tests__/viewport-runtime.test.ts rename to packages/daemon/src/execution/__tests__/viewport-runtime.test.ts index 4e74cd6a2f..18c5610c64 100644 --- a/src/daemon/__tests__/viewport-runtime.test.ts +++ b/packages/daemon/src/execution/__tests__/viewport-runtime.test.ts @@ -1,4 +1,4 @@ -import { daemonPlatformServicesFixture } from './platform-services-fixture.ts'; +import { daemonPlatformServicesFixture } from '../../__tests__/support/platform-services-fixture.ts'; import { expect, test, vi } from 'vitest'; import { type DeviceBinding, @@ -14,17 +14,20 @@ import { } from '@agent-device/contracts/platform-runtime-operations'; import { viewportRuntimeOperationFacts } from '@agent-device/contracts/viewport-runtime'; import { deviceShape } from '@agent-device/kernel/device'; -import { makeSession } from './support/session-factories.ts'; -import { makeSessionStore } from './support/store-factory.ts'; +import { makeSession } from '../../__tests__/support/session-factories.ts'; +import { makeSessionStore } from '../../__tests__/support/store-factory.ts'; import { createTestDeviceInventoryGateways } from '@agent-device/device-selection/inventory-gateways-fixtures'; -import { LeaseRegistry } from '../lease-registry.ts'; -import { activateCompleteRefFrame, refFrameState } from '../ref-frame.ts'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts'; -import type { GenericPlatformExecutionParams } from '../generic-leaf-execution.ts'; +import { LeaseRegistry } from '../../resources/lease-registry.ts'; +import { activateCompleteRefFrame, refFrameState } from '../../core/ref-frame.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../../core/request-runtime-binding.ts'; +import type { GenericPlatformExecutionParams } from '../../core/generic-leaf-execution.ts'; import { resolveBoundViewportRuntime } from '../viewport-runtime.ts'; -import { expectRefusesUnavailableExactOwnerFact } from './runtime-binding-conformance.ts'; -import { createRequestHandler } from './test-device-runtime-gateway.ts'; -import { fakeCreateCommandSurface } from './support/command-surface-fake.ts'; +import { expectRefusesUnavailableExactOwnerFact } from '../../__tests__/support/runtime-binding-conformance.ts'; +import { createRequestHandler } from '../../__tests__/support/test-device-runtime-gateway.ts'; +import { fakeCreateCommandSurface } from '../../__tests__/support/command-surface-fake.ts'; const webDevice = { id: 'web', diff --git a/src/daemon/android-foreground-surface.ts b/packages/daemon/src/execution/android-foreground-surface.ts similarity index 94% rename from src/daemon/android-foreground-surface.ts rename to packages/daemon/src/execution/android-foreground-surface.ts index c1f6af601a..c9d52e5f73 100644 --- a/src/daemon/android-foreground-surface.ts +++ b/packages/daemon/src/execution/android-foreground-surface.ts @@ -1,7 +1,7 @@ import type { AndroidObservationAdapter } from '@agent-device/contracts/android-observation'; import { AppError } from '@agent-device/kernel/errors'; -import { isActiveProviderDevice } from './provider-device-admission.ts'; -import type { SessionState } from './session-state.ts'; +import { isActiveProviderDevice } from '../core/provider-device-admission.ts'; +import type { SessionState } from '../core/session-state.ts'; export type AndroidEscapeSurface = { expectedPackage: string; diff --git a/src/daemon/android-snapshot-timeout-evidence.ts b/packages/daemon/src/execution/android-snapshot-timeout-evidence.ts similarity index 94% rename from src/daemon/android-snapshot-timeout-evidence.ts rename to packages/daemon/src/execution/android-snapshot-timeout-evidence.ts index 11b8b68197..0d7ab1da01 100644 --- a/src/daemon/android-snapshot-timeout-evidence.ts +++ b/packages/daemon/src/execution/android-snapshot-timeout-evidence.ts @@ -1,8 +1,8 @@ import { promises as fs } from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import type { DaemonResponse } from './daemon-request.ts'; -import type { SessionState } from './session-state.ts'; +import type { DaemonResponse } from '../core/daemon-request.ts'; +import type { SessionState } from '../core/session-state.ts'; import { emitDiagnostic } from '@agent-device/host-kit/diagnostics'; import { AppError, normalizeError } from '@agent-device/kernel/errors'; import { @@ -14,7 +14,7 @@ import { type SnapshotTimeoutEvidence, } from './snapshot-timeout-evidence.ts'; import { isAndroidSnapshotTimeoutError } from '@agent-device/capture-kit/snapshot-timeout-policy'; -import { contextFromFlags } from './context.ts'; +import { contextFromFlags } from '../core/context.ts'; import { annotateScreenshotWithRefs } from '@agent-device/capture-kit/screenshot-overlay'; import { screenshotExecutionFromContext } from './screenshot-runtime.ts'; import { @@ -28,7 +28,7 @@ import { * The two things that are not daemon assembly moved out: whether a failure is the * accessibility-timeout shape is a policy * (`packages/capture-kit/src/snapshot/snapshot-timeout-policy.ts`), and the published evidence shape is - * vocabulary (`src/daemon/snapshot-timeout-evidence.ts`, whose only consumer is this + * vocabulary (`packages/daemon/src/execution/snapshot-timeout-evidence.ts`, whose only consumer is this * module). What remains here is the ordering that * genuinely needs the daemon: resolving a bound screenshot runtime, writing the artifact, * annotating it from the stored observation, and emitting the diagnostics. diff --git a/src/daemon/android-system-dialog.ts b/packages/daemon/src/execution/android-system-dialog.ts similarity index 98% rename from src/daemon/android-system-dialog.ts rename to packages/daemon/src/execution/android-system-dialog.ts index 8816bfe79a..3c13514d94 100644 --- a/src/daemon/android-system-dialog.ts +++ b/packages/daemon/src/execution/android-system-dialog.ts @@ -8,9 +8,9 @@ import { AppError, normalizeError, type NormalizedError } from '@agent-device/ke import { centerOfRect, type SnapshotNode } from '@agent-device/kernel/snapshot'; import { isSnapshotNodeInteractionBlocked } from '@agent-device/capture-kit/snapshot-occlusion'; -import { expireRefFrame } from './ref-frame.ts'; -import type { SessionState } from './session-state.ts'; -import { isActiveProviderDevice } from './provider-device-admission.ts'; +import { expireRefFrame } from '../core/ref-frame.ts'; +import type { SessionState } from '../core/session-state.ts'; +import { isActiveProviderDevice } from '../core/provider-device-admission.ts'; const ANDROID_BLOCKING_MODAL_PATTERN = /\bis(?:n(?:'|'|')?t| not)\s+responding\b/i; const ANDROID_CLOSE_APP_PATTERN = /^close app$/i; diff --git a/src/daemon/app-event-runtime.ts b/packages/daemon/src/execution/app-event-runtime.ts similarity index 94% rename from src/daemon/app-event-runtime.ts rename to packages/daemon/src/execution/app-event-runtime.ts index e74790bb32..e4d270e41b 100644 --- a/src/daemon/app-event-runtime.ts +++ b/packages/daemon/src/execution/app-event-runtime.ts @@ -4,9 +4,9 @@ import type { BoundDeviceRuntime } from '@agent-device/contracts/platform-runtim import type { DeviceInfo } from '@agent-device/kernel/device'; import { parseTriggerAppEventArgs, resolveAppEventUrl } from './app-events.ts'; import { successText } from '@agent-device/kernel/success-text'; -import type { DaemonCommandContext } from './context.ts'; -import { admitRuntimeUse, type RuntimeAdmissionBindings } from './runtime-admission.ts'; -import { runtimeExecutionFromContext } from './snapshot-runtime-capture-input.ts'; +import type { DaemonCommandContext } from '../core/context.ts'; +import { admitRuntimeUse, type RuntimeAdmissionBindings } from '../core/runtime-admission.ts'; +import { runtimeExecutionFromContext } from '../core/snapshot-runtime-capture-input.ts'; import type { DaemonFailureResponse } from '@agent-device/kernel/contracts'; /** diff --git a/src/daemon/app-events.test.ts b/packages/daemon/src/execution/app-events.test.ts similarity index 100% rename from src/daemon/app-events.test.ts rename to packages/daemon/src/execution/app-events.test.ts diff --git a/src/daemon/app-events.ts b/packages/daemon/src/execution/app-events.ts similarity index 100% rename from src/daemon/app-events.ts rename to packages/daemon/src/execution/app-events.ts diff --git a/src/daemon/apps-runtime.ts b/packages/daemon/src/execution/apps-runtime.ts similarity index 100% rename from src/daemon/apps-runtime.ts rename to packages/daemon/src/execution/apps-runtime.ts diff --git a/src/daemon/back-runtime.ts b/packages/daemon/src/execution/back-runtime.ts similarity index 85% rename from src/daemon/back-runtime.ts rename to packages/daemon/src/execution/back-runtime.ts index e63c7ba663..c7df3e8a35 100644 --- a/src/daemon/back-runtime.ts +++ b/packages/daemon/src/execution/back-runtime.ts @@ -4,10 +4,13 @@ import { backRuntimeUse } from '@agent-device/contracts/platform-runtime-operati import type { BoundDeviceRuntime } from '@agent-device/contracts/platform-runtime'; import type { DeviceInfo } from '@agent-device/kernel/device'; import { successText } from '@agent-device/kernel/success-text'; -import type { DaemonCommandContext } from './context.ts'; -import type { ResolvedGenericExecution } from './generic-leaf-execution.ts'; -import { resolveBoundGenericRuntime, type RuntimeAdmissionBindings } from './runtime-admission.ts'; -import { runtimeExecutionFromContext } from './snapshot-runtime-capture-input.ts'; +import type { DaemonCommandContext } from '../core/context.ts'; +import type { ResolvedGenericExecution } from '../core/generic-leaf-execution.ts'; +import { + resolveBoundGenericRuntime, + type RuntimeAdmissionBindings, +} from '../core/runtime-admission.ts'; +import { runtimeExecutionFromContext } from '../core/snapshot-runtime-capture-input.ts'; /** The neutral intent one `back` carries, projected from a resolved command context. */ function backInput(mode: BackMode | undefined, context: DaemonCommandContext): BackInput { diff --git a/src/daemon/focus-runtime.ts b/packages/daemon/src/execution/focus-runtime.ts similarity index 87% rename from src/daemon/focus-runtime.ts rename to packages/daemon/src/execution/focus-runtime.ts index c16e628e66..7f04b83729 100644 --- a/src/daemon/focus-runtime.ts +++ b/packages/daemon/src/execution/focus-runtime.ts @@ -4,10 +4,13 @@ import type { DeviceInfo } from '@agent-device/kernel/device'; import type { Point } from '@agent-device/kernel/snapshot'; import { successText } from '@agent-device/kernel/success-text'; import { readPointPositionals } from '@agent-device/kernel/validation'; -import type { DaemonCommandContext } from './context.ts'; -import type { ResolvedGenericExecution } from './generic-leaf-execution.ts'; -import { resolveBoundGenericRuntime, type RuntimeAdmissionBindings } from './runtime-admission.ts'; -import { runtimeExecutionFromContext } from './snapshot-runtime-capture-input.ts'; +import type { DaemonCommandContext } from '../core/context.ts'; +import type { ResolvedGenericExecution } from '../core/generic-leaf-execution.ts'; +import { + resolveBoundGenericRuntime, + type RuntimeAdmissionBindings, +} from '../core/runtime-admission.ts'; +import { runtimeExecutionFromContext } from '../core/snapshot-runtime-capture-input.ts'; /** `focus x y`, on the same positional parse its still-legacy touch siblings take. */ export function readFocusPoint(positionals: readonly string[]): Point { diff --git a/src/daemon/fold-runtime.ts b/packages/daemon/src/execution/fold-runtime.ts similarity index 93% rename from src/daemon/fold-runtime.ts rename to packages/daemon/src/execution/fold-runtime.ts index d94abe7f4e..2d6c9ff447 100644 --- a/src/daemon/fold-runtime.ts +++ b/packages/daemon/src/execution/fold-runtime.ts @@ -9,8 +9,11 @@ import { foldRuntimeUse } from '@agent-device/contracts/platform-runtime-operati import type { BoundDeviceRuntime } from '@agent-device/contracts/platform-runtime'; import type { DeviceInfo } from '@agent-device/kernel/device'; import { successText } from '@agent-device/kernel/success-text'; -import type { ResolvedGenericExecution } from './generic-leaf-execution.ts'; -import { resolveBoundGenericRuntime, type RuntimeAdmissionBindings } from './runtime-admission.ts'; +import type { ResolvedGenericExecution } from '../core/generic-leaf-execution.ts'; +import { + resolveBoundGenericRuntime, + type RuntimeAdmissionBindings, +} from '../core/runtime-admission.ts'; /** `fold `, parsed with the same aliases the CLI reader accepts. */ export function readRequestedFoldPose(positionals: readonly string[]): FoldPose { diff --git a/src/daemon/generic-runtime-execution.ts b/packages/daemon/src/execution/generic-runtime-execution.ts similarity index 95% rename from src/daemon/generic-runtime-execution.ts rename to packages/daemon/src/execution/generic-runtime-execution.ts index 8539e9b2ae..8aa38b4749 100644 --- a/src/daemon/generic-runtime-execution.ts +++ b/packages/daemon/src/execution/generic-runtime-execution.ts @@ -1,11 +1,11 @@ -import type { ResolvedGenericExecution } from './generic-leaf-execution.ts'; +import type { ResolvedGenericExecution } from '../core/generic-leaf-execution.ts'; import { resolveBoundFocusRuntime } from './focus-runtime.ts'; import { resolveBoundScrollRuntime } from './scroll-runtime.ts'; import type { ScreenshotRuntimeBindings } from './screenshot-runtime-binding.ts'; import type { CreateDaemonCommandSurface } from '@agent-device/contracts/daemon-command-surface'; -import type { DaemonCommandContext } from './context.ts'; -import type { DaemonRequest } from './daemon-request.ts'; -import type { SessionState } from './session-state.ts'; +import type { DaemonCommandContext } from '../core/context.ts'; +import type { DaemonRequest } from '../core/daemon-request.ts'; +import type { SessionState } from '../core/session-state.ts'; import { resolveBoundViewportRuntime } from './viewport-runtime.ts'; import { resolveBoundBackRuntime } from './back-runtime.ts'; import { isSystemButtonCommand, resolveBoundSystemButtonRuntime } from './system-button-runtime.ts'; diff --git a/src/daemon/generic-settle.ts b/packages/daemon/src/execution/generic-settle.ts similarity index 92% rename from src/daemon/generic-settle.ts rename to packages/daemon/src/execution/generic-settle.ts index 01559d9598..ba812847c6 100644 --- a/src/daemon/generic-settle.ts +++ b/packages/daemon/src/execution/generic-settle.ts @@ -12,14 +12,14 @@ import { readSettleRequest, settleFlagGuardResponse, } from './interaction/index.ts'; -import type { BoundContextFromFlags } from './context.ts'; -import type { RuntimeAdmissionBindings } from './request-runtime-binding.ts'; -import type { DaemonPlatformServices } from './platform-services.ts'; -import { resolveSettleObservationCapture } from './settle-observation-capture.ts'; +import type { BoundContextFromFlags } from '../core/context.ts'; +import type { RuntimeAdmissionBindings } from '../core/request-runtime-binding.ts'; +import type { DaemonPlatformServices } from '../core/platform-services.ts'; +import { resolveSettleObservationCapture } from '../core/settle-observation-capture.ts'; import { issueSettleRefs } from './session-snapshot.ts'; -import type { SessionStore } from './session-store.ts'; -import type { DaemonRequest, DaemonResponse } from './daemon-request.ts'; -import type { SessionRef, SessionState } from './session-state.ts'; +import type { SessionStore } from '../core/session-store.ts'; +import type { DaemonRequest, DaemonResponse } from '../core/daemon-request.ts'; +import type { SessionRef, SessionState } from '../core/session-state.ts'; /** * `--settle` on the generic daemon route (#1638): `scroll` and `back` change diff --git a/src/daemon/handlers/__tests__/react-native.test.ts b/packages/daemon/src/execution/handlers/__tests__/react-native.test.ts similarity index 98% rename from src/daemon/handlers/__tests__/react-native.test.ts rename to packages/daemon/src/execution/handlers/__tests__/react-native.test.ts index c2bf743cbd..1dd2f1ada6 100644 --- a/src/daemon/handlers/__tests__/react-native.test.ts +++ b/packages/daemon/src/execution/handlers/__tests__/react-native.test.ts @@ -1,19 +1,19 @@ import { beforeEach, expect, test, vi } from 'vitest'; import path from 'node:path'; import { handleReactNativeCommands } from '../react-native.ts'; -import { captureSnapshot } from '../../snapshot-capture.ts'; -import { SessionStore } from '../../session-store.ts'; -import type { SessionState } from '../../session-state.ts'; +import { captureSnapshot } from '../../../core/snapshot-capture.ts'; +import { SessionStore } from '../../../core/session-store.ts'; +import type { SessionState } from '../../../core/session-state.ts'; import { mkdtempForTestSync } from '@agent-device/test-kit/tmp-dir'; import { getRuntimeBindings, mockTapPoint, resetGetRuntimeFixture, } from '../../__tests__/interaction-get-runtime-fixture.ts'; -import { refFrameState } from '../../ref-frame.ts'; -import { fakeCreateCommandSurface } from '../../__tests__/support/command-surface-fake.ts'; +import { refFrameState } from '../../../core/ref-frame.ts'; +import { fakeCreateCommandSurface } from '../../../__tests__/support/command-surface-fake.ts'; -vi.mock('../../snapshot-capture.ts', () => ({ +vi.mock('../../../core/snapshot-capture.ts', () => ({ captureSnapshot: vi.fn(), })); diff --git a/src/daemon/handlers/__tests__/session-clipboard.test.ts b/packages/daemon/src/execution/handlers/__tests__/session-clipboard.test.ts similarity index 98% rename from src/daemon/handlers/__tests__/session-clipboard.test.ts rename to packages/daemon/src/execution/handlers/__tests__/session-clipboard.test.ts index 0111a11351..90ce3d0dd9 100644 --- a/src/daemon/handlers/__tests__/session-clipboard.test.ts +++ b/packages/daemon/src/execution/handlers/__tests__/session-clipboard.test.ts @@ -1,4 +1,4 @@ -import { daemonPlatformServicesFixture } from '../../__tests__/platform-services-fixture.ts'; +import { daemonPlatformServicesFixture } from '../../../__tests__/support/platform-services-fixture.ts'; import { expect, test, vi } from 'vitest'; import { clipboardRuntimeOperationFacts } from '@agent-device/contracts/clipboard-runtime'; import { @@ -17,13 +17,13 @@ import { deviceShape, type DeviceInfo } from '@agent-device/kernel/device'; import type { BindDeviceRuntime, InspectDeviceRuntimeFacts, -} from '../../request-runtime-binding.ts'; +} from '../../../core/request-runtime-binding.ts'; import { makeSession, makeSessionStore, mockEnsureDeviceReady, mockResolveTargetDevice, -} from './session-test-harness.ts'; +} from '../../../__tests__/support/handlers/session-test-harness.ts'; import { handleSessionClipboardCommand } from '../session-clipboard.ts'; // File-scoped id, not a shared literal: this owner binding's `local-family` kind reaches the real diff --git a/src/daemon/handlers/__tests__/session-selector-dispatch.test.ts b/packages/daemon/src/execution/handlers/__tests__/session-selector-dispatch.test.ts similarity index 95% rename from src/daemon/handlers/__tests__/session-selector-dispatch.test.ts rename to packages/daemon/src/execution/handlers/__tests__/session-selector-dispatch.test.ts index cc008dd3ba..62c05ce336 100644 --- a/src/daemon/handlers/__tests__/session-selector-dispatch.test.ts +++ b/packages/daemon/src/execution/handlers/__tests__/session-selector-dispatch.test.ts @@ -1,7 +1,7 @@ import { daemonPlatformServicesFixture, resolveSessionAppBundleIdForTargetFixture, -} from '../../__tests__/platform-services-fixture.ts'; +} from '../../../__tests__/support/platform-services-fixture.ts'; import { test, expect, vi } from 'vitest'; import * as path from 'node:path'; import { AppError } from '@agent-device/kernel/errors'; @@ -20,21 +20,21 @@ import { deviceShape, type DeviceInfo } from '@agent-device/kernel/device'; import type { BindDeviceRuntime, InspectDeviceRuntimeFacts, -} from '../../request-runtime-binding.ts'; +} from '../../../core/request-runtime-binding.ts'; import { mockDispatch, mockResolveTargetDevice, makeSessionStore, makeSession, noopInvoke, -} from './session-test-harness.ts'; -import type { SessionState } from '../../session-state.ts'; -import { handleSessionCommands } from './session-command-harness.ts'; -import { refFrameState } from '../../ref-frame.ts'; +} from '../../../__tests__/support/handlers/session-test-harness.ts'; +import type { SessionState } from '../../../core/session-state.ts'; +import { handleSessionCommands } from '../../../__tests__/support/handlers/session-command-harness.ts'; +import { refFrameState } from '../../../core/ref-frame.ts'; import { mkdtempForTestSync } from '@agent-device/test-kit/tmp-dir'; -import { makeIosSession } from '../../__tests__/support/session-factories.ts'; +import { makeIosSession } from '../../../__tests__/support/session-factories.ts'; import { createUnavailableRuntimeFactsForTest } from '@agent-device/test-kit/runtime-operation-facts'; -import { fakeCreateCommandSurface } from '../../__tests__/support/command-surface-fake.ts'; +import { fakeCreateCommandSurface } from '../../../__tests__/support/command-surface-fake.ts'; const available = Object.freeze({ available: true } as const); const keyboardFamilyDenial = Object.freeze({ diff --git a/src/daemon/handlers/__tests__/snapshot-alert.test.ts b/packages/daemon/src/execution/handlers/__tests__/snapshot-alert.test.ts similarity index 92% rename from src/daemon/handlers/__tests__/snapshot-alert.test.ts rename to packages/daemon/src/execution/handlers/__tests__/snapshot-alert.test.ts index 94e66d07ba..0c7e849f49 100644 --- a/src/daemon/handlers/__tests__/snapshot-alert.test.ts +++ b/packages/daemon/src/execution/handlers/__tests__/snapshot-alert.test.ts @@ -1,14 +1,14 @@ import { test, expect, vi, beforeEach } from 'vitest'; import { AppError } from '@agent-device/kernel/errors'; -import type { SessionState } from '../../session-state.ts'; -import { SessionStore } from '../../session-store.ts'; -import { handleSnapshotCommands as handleProductionSnapshotCommands } from '../snapshot.ts'; -import { snapshotRuntimeFixture } from '../../__tests__/snapshot-runtime-fixture.ts'; +import type { SessionState } from '../../../core/session-state.ts'; +import { SessionStore } from '../../../core/session-store.ts'; +import { handleSnapshotCommands as handleProductionSnapshotCommands } from '../../../sessions/handlers/snapshot.ts'; +import { snapshotRuntimeFixture } from '../../../__tests__/support/snapshot-runtime-fixture.ts'; import { withAppleRunnerProvider } from '@agent-device/platform-apple/runner'; import { runAppleRunnerCommand } from '@agent-device/platform-apple/runner/operations'; import { mkdtempForTestSync } from '@agent-device/test-kit/tmp-dir'; import path from 'node:path'; -import { fakeCreateCommandSurface } from '../../__tests__/support/command-surface-fake.ts'; +import { fakeCreateCommandSurface } from '../../../__tests__/support/command-surface-fake.ts'; vi.mock('@agent-device/platform-apple/runner/operations', async (importOriginal) => { const actual = diff --git a/src/daemon/handlers/__tests__/snapshot-settings-handler.test.ts b/packages/daemon/src/execution/handlers/__tests__/snapshot-settings-handler.test.ts similarity index 95% rename from src/daemon/handlers/__tests__/snapshot-settings-handler.test.ts rename to packages/daemon/src/execution/handlers/__tests__/snapshot-settings-handler.test.ts index e9fb476c19..747af24a4f 100644 --- a/src/daemon/handlers/__tests__/snapshot-settings-handler.test.ts +++ b/packages/daemon/src/execution/handlers/__tests__/snapshot-settings-handler.test.ts @@ -1,20 +1,20 @@ -import { daemonPlatformServicesFixture } from '../../__tests__/platform-services-fixture.ts'; +import { daemonPlatformServicesFixture } from '../../../__tests__/support/platform-services-fixture.ts'; import { test, expect, vi, afterEach, beforeEach } from 'vitest'; -import { legacyDispatchCapture } from '../../__tests__/legacy-snapshot-capture-fixture.ts'; -import { handleSnapshotCommands as handleProductionSnapshotCommands } from '../snapshot.ts'; -import { providerDeviceAdmissionFixture } from '../../__tests__/support/provider-device-admission-fixture.ts'; -import { fakeCreateCommandSurface } from '../../__tests__/support/command-surface-fake.ts'; +import { legacyDispatchCapture } from '../../../__tests__/support/legacy-snapshot-capture-fixture.ts'; +import { handleSnapshotCommands as handleProductionSnapshotCommands } from '../../../sessions/handlers/snapshot.ts'; +import { providerDeviceAdmissionFixture } from '../../../__tests__/support/provider-device-admission-fixture.ts'; +import { fakeCreateCommandSurface } from '../../../__tests__/support/command-surface-fake.ts'; // The daemon reads provider ownership through its own typed admission seam; these suites // install the seam over runtime fakes, the way root composition installs the real one. const providerAdmission = providerDeviceAdmissionFixture(); -import { platformResourceCleanupFixture } from '../../__tests__/support/platform-resource-cleanup-fixture.ts'; +import { platformResourceCleanupFixture } from '../../../__tests__/support/platform-resource-cleanup-fixture.ts'; import { fixtureSettingsMutations, fixtureSettingsReads, resetSnapshotRuntimeFixture, snapshotRuntimeFixture, -} from '../../__tests__/snapshot-runtime-fixture.ts'; +} from '../../../__tests__/support/snapshot-runtime-fixture.ts'; import { androidDevice, iosSimulatorDevice, @@ -23,12 +23,12 @@ import { makeSessionStore, snapshotRequest, tvOsSimulatorDevice, -} from './snapshot-handler.fixtures.ts'; -import { activateCompleteRefFrame, refFrameState } from '../../ref-frame.ts'; +} from '../../../__tests__/support/handlers/snapshot-handler.fixtures.ts'; +import { activateCompleteRefFrame, refFrameState } from '../../../core/ref-frame.ts'; import { PRE_DISPATCH_REFUSAL_REASONS } from '@agent-device/kernel/errors'; -vi.mock('../../snapshot-interactor-capture.ts', async () => { - const fixture = await import('../../__tests__/legacy-snapshot-capture-fixture.ts'); +vi.mock('../../../core/snapshot-interactor-capture.ts', async () => { + const fixture = await import('../../../__tests__/support/legacy-snapshot-capture-fixture.ts'); return { captureSnapshotWithInteractor: fixture.captureSnapshotThroughLegacyDispatchFixture }; }); vi.mock('@agent-device/platform-apple/runner/operations', async (importOriginal) => { @@ -41,12 +41,12 @@ vi.mock('@agent-device/platform-apple/runner/operations', async (importOriginal) // unambiguous environment; that live-probe logic is covered by // ios-app-session-hint.test.ts. Stubbed here so this suite stays hermetic and // fast — defaults to "no enrichment", matching the current-behavior fallback. -vi.mock('../../ios-app-session-hint.ts', () => ({ +vi.mock('../../../core/ios-app-session-hint.ts', () => ({ buildIosOpenCommandHint: vi.fn(async () => undefined), })); import { runAppleRunnerCommand } from '@agent-device/platform-apple/runner/operations'; -import { buildIosOpenCommandHint } from '../../ios-app-session-hint.ts'; +import { buildIosOpenCommandHint } from '../../../core/ios-app-session-hint.ts'; const mockRunnerCommand = vi.mocked(runAppleRunnerCommand); const mockBuildIosOpenCommandHint = vi.mocked(buildIosOpenCommandHint); diff --git a/src/daemon/handlers/react-native.ts b/packages/daemon/src/execution/handlers/react-native.ts similarity index 97% rename from src/daemon/handlers/react-native.ts rename to packages/daemon/src/execution/handlers/react-native.ts index 5c9a4bbc8e..1eb4e5a2e2 100644 --- a/src/daemon/handlers/react-native.ts +++ b/packages/daemon/src/execution/handlers/react-native.ts @@ -2,7 +2,7 @@ import { createBoundTouchExecutor, resolveBoundTouchRuntime, type BoundTouchRuntime, -} from '../touch-runtime.ts'; +} from '../../core/touch-runtime.ts'; import { PUBLIC_COMMANDS } from '@agent-device/command-registry/catalog'; import { analyzeReactNativeOverlay, @@ -14,15 +14,15 @@ import { successText } from '@agent-device/kernel/success-text'; import type { SnapshotQualityVerdict, SnapshotState } from '@agent-device/kernel/snapshot'; import { isSparseSnapshotQualityVerdict } from '@agent-device/capture-kit/snapshot-quality-verdict'; -import type { DaemonResponse } from '../daemon-request.ts'; -import type { SessionState } from '../session-state.ts'; +import type { DaemonResponse } from '../../core/daemon-request.ts'; +import type { SessionState } from '../../core/session-state.ts'; import { bindInteractionSession, captureSnapshotForSession, finalizeTouchInteraction, type InteractionRouteInput, } from '../interaction/index.ts'; -import { expireRefFrame } from '../ref-frame.ts'; +import { expireRefFrame } from '../../core/ref-frame.ts'; import { readSnapshotNodesReferenceFrame } from '@agent-device/capture-kit/touch-reference-frame'; import { errorResponse, noActiveSessionError } from '@agent-device/kernel/contracts'; diff --git a/src/daemon/handlers/session-clipboard.ts b/packages/daemon/src/execution/handlers/session-clipboard.ts similarity index 91% rename from src/daemon/handlers/session-clipboard.ts rename to packages/daemon/src/execution/handlers/session-clipboard.ts index 61badf6386..85b18755a5 100644 --- a/src/daemon/handlers/session-clipboard.ts +++ b/packages/daemon/src/execution/handlers/session-clipboard.ts @@ -1,4 +1,4 @@ -import type { DaemonPlatformServices } from '../platform-services.ts'; +import type { DaemonPlatformServices } from '../../core/platform-services.ts'; import type { ClipboardReadInput, ClipboardWriteInput, @@ -11,18 +11,21 @@ import type { BoundDeviceRuntime } from '@agent-device/contracts/platform-runtim import { publicPlatformString, type DeviceInfo } from '@agent-device/kernel/device'; import { AppError } from '@agent-device/kernel/errors'; import { PUBLIC_COMMANDS } from '@agent-device/command-registry/catalog'; -import { contextFromFlags, type DaemonCommandContext } from '../context.ts'; -import type { DaemonRequest, DaemonResponse } from '../daemon-request.ts'; -import type { SessionStore } from '../session-store.ts'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts'; -import { admitRuntimeUse, type RuntimeAdmissionBindings } from '../runtime-admission.ts'; -import { runtimeExecutionFromContext } from '../snapshot-runtime-capture-input.ts'; +import { contextFromFlags, type DaemonCommandContext } from '../../core/context.ts'; +import type { DaemonRequest, DaemonResponse } from '../../core/daemon-request.ts'; +import type { SessionStore } from '../../core/session-store.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../../core/request-runtime-binding.ts'; +import { admitRuntimeUse, type RuntimeAdmissionBindings } from '../../core/runtime-admission.ts'; +import { runtimeExecutionFromContext } from '../../core/snapshot-runtime-capture-input.ts'; import { successText } from '@agent-device/kernel/success-text'; -import { recordSessionAction } from '../session-action-recorder.ts'; +import { recordSessionAction } from '../../core/session-action-recorder.ts'; import { requireSessionOrExplicitSelector, resolveCommandDevice, -} from '../session-device-resolution.ts'; +} from '../../resources/session-device-resolution.ts'; import { type DaemonFailureResponse, errorResponse } from '@agent-device/kernel/contracts'; type ClipboardAction = 'read' | 'write'; diff --git a/src/daemon/handlers/session-selector-dispatch.ts b/packages/daemon/src/execution/handlers/session-selector-dispatch.ts similarity index 91% rename from src/daemon/handlers/session-selector-dispatch.ts rename to packages/daemon/src/execution/handlers/session-selector-dispatch.ts index edf0b3b228..4b4605185d 100644 --- a/src/daemon/handlers/session-selector-dispatch.ts +++ b/packages/daemon/src/execution/handlers/session-selector-dispatch.ts @@ -1,21 +1,24 @@ -import type { DaemonPlatformServices } from '../platform-services.ts'; +import type { DaemonPlatformServices } from '../../core/platform-services.ts'; import { PUBLIC_COMMANDS } from '@agent-device/command-registry/catalog'; import type { DeviceInfo } from '@agent-device/kernel/device'; -import type { DaemonRequest, DaemonResponse } from '../daemon-request.ts'; -import type { SessionRef, SessionState } from '../session-state.ts'; -import type { SessionStore } from '../session-store.ts'; -import { contextFromFlags } from '../context.ts'; +import type { DaemonRequest, DaemonResponse } from '../../core/daemon-request.ts'; +import type { SessionRef, SessionState } from '../../core/session-state.ts'; +import type { SessionStore } from '../../core/session-store.ts'; +import { contextFromFlags } from '../../core/context.ts'; import { requireSessionOrExplicitSelector, resolveCommandDevice, -} from '../session-device-resolution.ts'; -import { recordSessionAction } from '../session-action-recorder.ts'; +} from '../../resources/session-device-resolution.ts'; +import { recordSessionAction } from '../../core/session-action-recorder.ts'; import { resolveBoundAppEventRuntime } from '../app-event-runtime.ts'; import { resolveBoundKeyboardRuntime } from '../keyboard-runtime.ts'; -import { resolveRefFrameEffect } from '../daemon-command-registry.ts'; -import { expireRefFrame } from '../ref-frame.ts'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts'; -import type { DaemonCommandContext } from '../context.ts'; +import { resolveRefFrameEffect } from '../../core/daemon-command-registry.ts'; +import { expireRefFrame } from '../../core/ref-frame.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../../core/request-runtime-binding.ts'; +import type { DaemonCommandContext } from '../../core/context.ts'; import { errorResponse } from '@agent-device/kernel/contracts'; /** diff --git a/src/daemon/handlers/snapshot-alert.ts b/packages/daemon/src/execution/handlers/snapshot-alert.ts similarity index 89% rename from src/daemon/handlers/snapshot-alert.ts rename to packages/daemon/src/execution/handlers/snapshot-alert.ts index 295529ebd2..bb914de475 100644 --- a/src/daemon/handlers/snapshot-alert.ts +++ b/packages/daemon/src/execution/handlers/snapshot-alert.ts @@ -1,4 +1,4 @@ -import type { DaemonPlatformServices } from '../platform-services.ts'; +import type { DaemonPlatformServices } from '../../core/platform-services.ts'; import type { AlertRuntimeInput } from '@agent-device/contracts/alert-runtime'; import { type AlertAction, @@ -12,17 +12,20 @@ import { alertWaitUse, } from '@agent-device/contracts/platform-runtime-operations'; import type { DeviceInfo } from '@agent-device/kernel/device'; -import { contextFromFlags } from '../context.ts'; -import type { DaemonRequest, DaemonResponse } from '../daemon-request.ts'; -import type { SessionRef, SessionState } from '../session-state.ts'; -import { SessionStore } from '../session-store.ts'; -import { recordSessionAction } from '../session-action-recorder.ts'; +import { contextFromFlags } from '../../core/context.ts'; +import type { DaemonRequest, DaemonResponse } from '../../core/daemon-request.ts'; +import type { SessionRef, SessionState } from '../../core/session-state.ts'; +import { SessionStore } from '../../core/session-store.ts'; +import { recordSessionAction } from '../../core/session-action-recorder.ts'; import { parseTimeout } from '@agent-device/command-registry/parse-timeout'; -import { resolveRefFrameEffect } from '../daemon-command-registry.ts'; -import { expireRefFrame } from '../ref-frame.ts'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts'; -import { admitRuntimeUse, type RuntimeAdmissionBindings } from '../runtime-admission.ts'; -import { runtimeExecutionFromContext } from '../snapshot-runtime-capture-input.ts'; +import { resolveRefFrameEffect } from '../../core/daemon-command-registry.ts'; +import { expireRefFrame } from '../../core/ref-frame.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../../core/request-runtime-binding.ts'; +import { admitRuntimeUse, type RuntimeAdmissionBindings } from '../../core/runtime-admission.ts'; +import { runtimeExecutionFromContext } from '../../core/snapshot-runtime-capture-input.ts'; import type { DaemonFailureResponse } from '@agent-device/kernel/contracts'; type HandleAlertCommandParams = { diff --git a/src/daemon/handlers/snapshot-settings.ts b/packages/daemon/src/execution/handlers/snapshot-settings.ts similarity index 95% rename from src/daemon/handlers/snapshot-settings.ts rename to packages/daemon/src/execution/handlers/snapshot-settings.ts index ae27c9338c..375d056d73 100644 --- a/src/daemon/handlers/snapshot-settings.ts +++ b/packages/daemon/src/execution/handlers/snapshot-settings.ts @@ -1,4 +1,4 @@ -import type { DaemonPlatformServices } from '../platform-services.ts'; +import type { DaemonPlatformServices } from '../../core/platform-services.ts'; import { isApplePlatform, isHandheldAppleSimulator, @@ -27,20 +27,23 @@ import { settingsRuntimeUse, } from '@agent-device/contracts/platform-runtime-operations'; import type { BoundDeviceRuntime } from '@agent-device/contracts/platform-runtime'; -import { contextFromFlags } from '../context.ts'; -import { SessionStore } from '../session-store.ts'; -import type { DaemonRequest, DaemonResponse } from '../daemon-request.ts'; -import type { SessionRef, SessionState } from '../session-state.ts'; -import { recordSessionAction } from '../session-action-recorder.ts'; -import { expireRefFrame } from '../ref-frame.ts'; +import { contextFromFlags } from '../../core/context.ts'; +import { SessionStore } from '../../core/session-store.ts'; +import type { DaemonRequest, DaemonResponse } from '../../core/daemon-request.ts'; +import type { SessionRef, SessionState } from '../../core/session-state.ts'; +import { recordSessionAction } from '../../core/session-action-recorder.ts'; +import { expireRefFrame } from '../../core/ref-frame.ts'; import { emitDiagnostic } from '@agent-device/host-kit/diagnostics'; import { readLocationCoordinate } from '@agent-device/kernel/location-coordinates'; import { sessionAppRequiredDetails } from '@agent-device/kernel/errors'; import { successText, withSuccessText } from '@agent-device/kernel/success-text'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from '../request-runtime-binding.ts'; -import { admitRuntimeUse } from '../runtime-admission.ts'; -import { runtimeExecutionFromContext } from '../snapshot-runtime-capture-input.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../../core/request-runtime-binding.ts'; +import { admitRuntimeUse } from '../../core/runtime-admission.ts'; +import { runtimeExecutionFromContext } from '../../core/snapshot-runtime-capture-input.ts'; import { type DaemonFailureResponse, errorResponse } from '@agent-device/kernel/contracts'; type ParsedSettingsArgs = { diff --git a/src/daemon/interaction/index.ts b/packages/daemon/src/execution/interaction/index.ts similarity index 86% rename from src/daemon/interaction/index.ts rename to packages/daemon/src/execution/interaction/index.ts index 612abde8c5..81b5f1511b 100644 --- a/src/daemon/interaction/index.ts +++ b/packages/daemon/src/execution/interaction/index.ts @@ -1,8 +1,8 @@ import { bindInteractionSession } from './internal/interaction-session.ts'; import type { Rect } from '@agent-device/kernel/snapshot'; -import { buildRuntimeCaptureInput } from '../snapshot-runtime-capture-input.ts'; +import { buildRuntimeCaptureInput } from '../../core/snapshot-runtime-capture-input.ts'; import { setSessionSnapshot } from '../session-snapshot.ts'; -import { captureSnapshot } from '../snapshot-capture.ts'; +import { captureSnapshot } from '../../core/snapshot-capture.ts'; import { captureInteractionSnapshot } from './internal/interaction-snapshot.ts'; import { createInteractionRuntimeForRoute } from './internal/interaction-runtime.ts'; import { readSettleRequest, settleFlagGuardResponse } from './internal/interaction-flags.ts'; @@ -11,9 +11,12 @@ import type { FindRouteInput, InteractionRouteInput, SettleObservationCaptureInput, -} from './internal/types.ts'; +} from '../../core/interaction/internal/types.ts'; -export type { FindRouteInput, InteractionRouteInput } from './internal/types.ts'; +export type { + FindRouteInput, + InteractionRouteInput, +} from '../../core/interaction/internal/types.ts'; export { refMutationAdmissionResponse } from './internal/interaction-ref-policy.ts'; export { finalizeTouchInteraction } from './internal/interaction-runtime.ts'; @@ -71,8 +74,8 @@ export async function createInteractionRuntime( params: SettleObservationCaptureInput & InteractionRouteInput & { pairedGestureViewport?: Rect; - touchExecutor?: import('../touch-runtime.ts').BoundTouchExecutor; - gestures?: import('../gesture-runtime.ts').BoundGestureExecutor; + touchExecutor?: import('../../core/touch-runtime.ts').BoundTouchExecutor; + gestures?: import('../../core/gesture-runtime.ts').BoundGestureExecutor; }, ) { return await createInteractionRuntimeForRoute({ diff --git a/src/daemon/interaction/internal/__tests__/find-handler-fixture.ts b/packages/daemon/src/execution/interaction/internal/__tests__/find-handler-fixture.ts similarity index 83% rename from src/daemon/interaction/internal/__tests__/find-handler-fixture.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/find-handler-fixture.ts index 5b26c59892..9bb69ef83e 100644 --- a/src/daemon/interaction/internal/__tests__/find-handler-fixture.ts +++ b/packages/daemon/src/execution/interaction/internal/__tests__/find-handler-fixture.ts @@ -1,9 +1,9 @@ -import type { SessionStore } from '../../../session-store.ts'; -import type { DaemonRequest, DaemonResponse } from '../../../daemon-request.ts'; +import type { SessionStore } from '../../../../core/session-store.ts'; +import type { DaemonRequest, DaemonResponse } from '../../../../core/daemon-request.ts'; import { handleFindCommands } from '../find.ts'; import { getRuntimeBindings } from '../../../__tests__/interaction-get-runtime-fixture.ts'; import type { CreateDaemonCommandSurface } from '@agent-device/contracts/daemon-command-surface'; -import { fakeCreateCommandSurface } from '../../../__tests__/support/command-surface-fake.ts'; +import { fakeCreateCommandSurface } from '../../../../__tests__/support/command-surface-fake.ts'; /** * One `handleFindCommands` invocation shape. diff --git a/src/daemon/interaction/internal/__tests__/find-match-ranking.test.ts b/packages/daemon/src/execution/interaction/internal/__tests__/find-match-ranking.test.ts similarity index 100% rename from src/daemon/interaction/internal/__tests__/find-match-ranking.test.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/find-match-ranking.test.ts diff --git a/src/daemon/interaction/internal/__tests__/find-single-bind.test.ts b/packages/daemon/src/execution/interaction/internal/__tests__/find-single-bind.test.ts similarity index 81% rename from src/daemon/interaction/internal/__tests__/find-single-bind.test.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/find-single-bind.test.ts index 9a64128de6..0190dfcfa1 100644 --- a/src/daemon/interaction/internal/__tests__/find-single-bind.test.ts +++ b/packages/daemon/src/execution/interaction/internal/__tests__/find-single-bind.test.ts @@ -1,7 +1,7 @@ import { test, expect, vi, beforeEach } from 'vitest'; -import type { DaemonResponse } from '../../../daemon-request.ts'; -import { makeSessionStore } from '../../../__tests__/support/store-factory.ts'; -import { makeIosSession } from '../../../__tests__/support/session-factories.ts'; +import type { DaemonResponse } from '../../../../core/daemon-request.ts'; +import { makeSessionStore } from '../../../../__tests__/support/store-factory.ts'; +import { makeIosSession } from '../../../../__tests__/support/session-factories.ts'; import { mockFocusPoint, mockTypeText, @@ -9,10 +9,10 @@ import { runtimeBindingSpies, } from '../../../__tests__/interaction-get-runtime-fixture.ts'; import { invokeFindHandler } from './find-handler-fixture.ts'; -import { legacyDispatchCapture } from '../../../__tests__/legacy-snapshot-capture-fixture.ts'; +import { legacyDispatchCapture } from '../../../../__tests__/support/legacy-snapshot-capture-fixture.ts'; -vi.mock('../../../snapshot-interactor-capture.ts', async () => { - const fixture = await import('../../../__tests__/legacy-snapshot-capture-fixture.ts'); +vi.mock('../../../../core/snapshot-interactor-capture.ts', async () => { + const fixture = await import('../../../../__tests__/support/legacy-snapshot-capture-fixture.ts'); return { captureSnapshotWithInteractor: fixture.captureSnapshotThroughLegacyDispatchFixture }; }); diff --git a/src/daemon/interaction/internal/__tests__/find-target-activation-disclosure.test.ts b/packages/daemon/src/execution/interaction/internal/__tests__/find-target-activation-disclosure.test.ts similarity index 89% rename from src/daemon/interaction/internal/__tests__/find-target-activation-disclosure.test.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/find-target-activation-disclosure.test.ts index d686d53bef..662ddf25b8 100644 --- a/src/daemon/interaction/internal/__tests__/find-target-activation-disclosure.test.ts +++ b/packages/daemon/src/execution/interaction/internal/__tests__/find-target-activation-disclosure.test.ts @@ -1,18 +1,18 @@ import { beforeEach, expect, test, vi } from 'vitest'; import type { IosTargetActivation, PostGestureOutcome } from '@agent-device/kernel/snapshot'; import { iosTargetActivationDisclosure } from '@agent-device/contracts/ios-target-activation'; -import { makeSessionStore } from '../../../__tests__/support/store-factory.ts'; -import { makeIosSession } from '../../../__tests__/support/session-factories.ts'; -import type { DaemonResponse } from '../../../daemon-request.ts'; -import { legacyDispatchCapture } from '../../../__tests__/legacy-snapshot-capture-fixture.ts'; +import { makeSessionStore } from '../../../../__tests__/support/store-factory.ts'; +import { makeIosSession } from '../../../../__tests__/support/session-factories.ts'; +import type { DaemonResponse } from '../../../../core/daemon-request.ts'; +import { legacyDispatchCapture } from '../../../../__tests__/support/legacy-snapshot-capture-fixture.ts'; import { getRuntimeBindings } from '../../../__tests__/interaction-get-runtime-fixture.ts'; import { handleFindCommands } from '../../index.ts'; -import { markDeferredInteractionOutcome } from '../../../deferred-interaction-outcome.ts'; +import { markDeferredInteractionOutcome } from '../../../../core/deferred-interaction-outcome.ts'; import { formatPostGestureOutcomeWarning } from '@agent-device/capture-kit/post-gesture-stability'; -import { fakeCreateCommandSurface } from '../../../__tests__/support/command-surface-fake.ts'; +import { fakeCreateCommandSurface } from '../../../../__tests__/support/command-surface-fake.ts'; -vi.mock('../../../snapshot-interactor-capture.ts', async () => { - const fixture = await import('../../../__tests__/legacy-snapshot-capture-fixture.ts'); +vi.mock('../../../../core/snapshot-interactor-capture.ts', async () => { + const fixture = await import('../../../../__tests__/support/legacy-snapshot-capture-fixture.ts'); return { captureSnapshotWithInteractor: fixture.captureSnapshotThroughLegacyDispatchFixture }; }); diff --git a/src/daemon/interaction/internal/__tests__/find-touch-runtime-fixture.ts b/packages/daemon/src/execution/interaction/internal/__tests__/find-touch-runtime-fixture.ts similarity index 88% rename from src/daemon/interaction/internal/__tests__/find-touch-runtime-fixture.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/find-touch-runtime-fixture.ts index 4c2ee94934..46f439138d 100644 --- a/src/daemon/interaction/internal/__tests__/find-touch-runtime-fixture.ts +++ b/packages/daemon/src/execution/interaction/internal/__tests__/find-touch-runtime-fixture.ts @@ -1,5 +1,5 @@ import { expect } from 'vitest'; -import { legacyDispatchCapture } from '../../../__tests__/legacy-snapshot-capture-fixture.ts'; +import { legacyDispatchCapture } from '../../../../__tests__/support/legacy-snapshot-capture-fixture.ts'; import { IOS_SIMULATOR } from '@agent-device/test-kit/device-fixtures'; import { getRuntimeBindings, @@ -8,10 +8,10 @@ import { mockTapPoint, resetGetRuntimeFixture, } from '../../../__tests__/interaction-get-runtime-fixture.ts'; -import { makeSessionStore } from '../../../__tests__/support/store-factory.ts'; -import { makeIosSession as makeSession } from '../../../__tests__/support/session-factories.ts'; -import type { DaemonRequest, DaemonResponse } from '../../../daemon-request.ts'; -import type { SessionState } from '../../../session-state.ts'; +import { makeSessionStore } from '../../../../__tests__/support/store-factory.ts'; +import { makeIosSession as makeSession } from '../../../../__tests__/support/session-factories.ts'; +import type { DaemonRequest, DaemonResponse } from '../../../../core/daemon-request.ts'; +import type { SessionState } from '../../../../core/session-state.ts'; import type { CreateDaemonCommandSurface } from '@agent-device/contracts/daemon-command-surface'; import type { handleFindCommands } from '../find.ts'; import { invokeFindHandler } from './find-handler-fixture.ts'; diff --git a/src/daemon/interaction/internal/__tests__/find.test.ts b/packages/daemon/src/execution/interaction/internal/__tests__/find.test.ts similarity index 98% rename from src/daemon/interaction/internal/__tests__/find.test.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/find.test.ts index 7f24f1cef0..27b4050d7c 100644 --- a/src/daemon/interaction/internal/__tests__/find.test.ts +++ b/packages/daemon/src/execution/interaction/internal/__tests__/find.test.ts @@ -1,5 +1,5 @@ import { test, expect, vi, beforeEach } from 'vitest'; -import { makeIosSession as makeSession } from '../../../__tests__/support/session-factories.ts'; +import { makeIosSession as makeSession } from '../../../../__tests__/support/session-factories.ts'; vi.mock('@agent-device/device-selection/dispatch-resolve', async (importOriginal) => { const actual = (await importOriginal()) as Record; @@ -8,8 +8,8 @@ vi.mock('@agent-device/device-selection/dispatch-resolve', async (importOriginal resolveTargetDevice: actual.resolveTargetDevice, }; }); -vi.mock('../../../snapshot-interactor-capture.ts', async () => { - const fixture = await import('../../../__tests__/legacy-snapshot-capture-fixture.ts'); +vi.mock('../../../../core/snapshot-interactor-capture.ts', async () => { + const fixture = await import('../../../../__tests__/support/legacy-snapshot-capture-fixture.ts'); return { captureSnapshotWithInteractor: fixture.captureSnapshotThroughLegacyDispatchFixture }; }); @@ -19,7 +19,7 @@ import { resetFindTouchRuntimeFixture, runFindClickScenario, } from './find-touch-runtime-fixture.ts'; -import { refFrameState } from '../../../ref-frame.ts'; +import { refFrameState } from '../../../../core/ref-frame.ts'; beforeEach(() => { resetFindTouchRuntimeFixture(); diff --git a/src/daemon/interaction/internal/__tests__/gesture-runtime-bindings.fixtures.ts b/packages/daemon/src/execution/interaction/internal/__tests__/gesture-runtime-bindings.fixtures.ts similarity index 63% rename from src/daemon/interaction/internal/__tests__/gesture-runtime-bindings.fixtures.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/gesture-runtime-bindings.fixtures.ts index ebc033b318..ba8a00ca92 100644 --- a/src/daemon/interaction/internal/__tests__/gesture-runtime-bindings.fixtures.ts +++ b/packages/daemon/src/execution/interaction/internal/__tests__/gesture-runtime-bindings.fixtures.ts @@ -1,11 +1,19 @@ -import { vi } from 'vitest'; +import { vi, type Mock } from 'vitest'; import type { BoundDeviceRuntime, RuntimeFacts } from '@agent-device/contracts/platform-runtime'; import type { PlatformRuntimeOperations } from '@agent-device/contracts/platform-runtime-operations'; import type { Rect } from '@agent-device/kernel/snapshot'; +import type { + GesturePlanInput, + GestureViewportInput, +} from '@agent-device/contracts/gesture-runtime'; +import type { + CaptureSnapshotInput, + SnapshotResult, +} from '@agent-device/contracts/snapshot-runtime'; import type { BindDeviceRuntime, InspectDeviceRuntimeFacts, -} from '../../../request-runtime-binding.ts'; +} from '../../../../core/request-runtime-binding.ts'; import { unavailableDeploymentSnapshotAndShutdownOperationFacts } from '@agent-device/test-kit/runtime-operation-facts'; const available = Object.freeze({ available: true } as const); @@ -26,14 +34,25 @@ export function gestureRuntimeBindingsFixture( ? ({ available: false, reason: 'unsupported-platform-leaf' } as const) : available; const operationSpies = { - captureSnapshot: vi.fn(async () => ({ backend: 'xctest' as const, nodes: [] })), - performGesturePlan: vi.fn(async () => ({})), - performDirectionalFlingPlan: vi.fn(async () => ({})), - performMultiTouchGesturePlan: vi.fn(async () => ({})), - performTargetAuthoredDrag: vi.fn(async () => ({})), + captureSnapshot: vi.fn(async () => ({ + backend: 'xctest' as const, + nodes: [], + })) as unknown as Mock<(input: CaptureSnapshotInput) => Promise>, + performGesturePlan: vi.fn(async () => ({})) as Mock< + (input: GesturePlanInput) => Promise> + >, + performDirectionalFlingPlan: vi.fn(async () => ({})) as Mock< + (input: GesturePlanInput) => Promise> + >, + performMultiTouchGesturePlan: vi.fn(async () => ({})) as Mock< + (input: GesturePlanInput) => Promise> + >, + performTargetAuthoredDrag: vi.fn(async () => ({})) as Mock< + (input: GesturePlanInput) => Promise> + >, gestureViewport: vi.fn( - async () => options.viewport ?? ({ x: 0, y: 0, width: 400, height: 800 } as Rect), - ), + async () => options.viewport ?? { x: 0, y: 0, width: 400, height: 800 }, + ) as Mock<(input: GestureViewportInput) => Promise>, }; const facts = { device: { family: 'apple', kind: 'simulator', providerMode: 'local' }, @@ -48,7 +67,7 @@ export function gestureRuntimeBindingsFixture( }, } as unknown as RuntimeFacts; const inspectFacts = vi.fn(async () => facts) as unknown as InspectDeviceRuntimeFacts & - ReturnType; + Mock<() => Promise>>; const bindDevice = vi.fn( async () => ({ @@ -57,6 +76,6 @@ export function gestureRuntimeBindingsFixture( Object.entries(operationSpies).filter(([name]) => !unavailable.has(name)), ), }) as unknown as BoundDeviceRuntime, - ) as unknown as BindDeviceRuntime & ReturnType; + ) as unknown as BindDeviceRuntime & Mock<() => Promise>>; return { ...operationSpies, facts, inspectFacts, bindDevice }; } diff --git a/src/daemon/interaction/internal/__tests__/interaction-gesture-response.test.ts b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-gesture-response.test.ts similarity index 100% rename from src/daemon/interaction/internal/__tests__/interaction-gesture-response.test.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/interaction-gesture-response.test.ts diff --git a/src/daemon/interaction/internal/__tests__/interaction-ios-tap-outcome-fixtures.ts b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-ios-tap-outcome-fixtures.ts similarity index 100% rename from src/daemon/interaction/internal/__tests__/interaction-ios-tap-outcome-fixtures.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/interaction-ios-tap-outcome-fixtures.ts diff --git a/src/daemon/interaction/internal/__tests__/interaction-recorded-input.test.ts b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-recorded-input.test.ts similarity index 100% rename from src/daemon/interaction/internal/__tests__/interaction-recorded-input.test.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/interaction-recorded-input.test.ts diff --git a/src/daemon/interaction/internal/__tests__/interaction-ref-policy.test.ts b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-ref-policy.test.ts similarity index 98% rename from src/daemon/interaction/internal/__tests__/interaction-ref-policy.test.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/interaction-ref-policy.test.ts index c65902c850..11dabba40a 100644 --- a/src/daemon/interaction/internal/__tests__/interaction-ref-policy.test.ts +++ b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-ref-policy.test.ts @@ -1,5 +1,5 @@ import { expect, test } from 'vitest'; -import { activatePartialRefFrame, readRefMutationFrame } from '../../../ref-frame.ts'; +import { activatePartialRefFrame, readRefMutationFrame } from '../../../../core/ref-frame.ts'; import { refMutationAdmissionResponse } from '../interaction-ref-policy.ts'; import { makeStaleRefSession } from './interaction-touch-fixtures.ts'; diff --git a/src/daemon/interaction/internal/__tests__/interaction-response-construction-guard.test.ts b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-response-construction-guard.test.ts similarity index 100% rename from src/daemon/interaction/internal/__tests__/interaction-response-construction-guard.test.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/interaction-response-construction-guard.test.ts diff --git a/src/daemon/interaction/internal/__tests__/interaction-response-data-transform.test.ts b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-response-data-transform.test.ts similarity index 100% rename from src/daemon/interaction/internal/__tests__/interaction-response-data-transform.test.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/interaction-response-data-transform.test.ts diff --git a/src/daemon/interaction/internal/__tests__/interaction-runtime.test.ts b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-runtime.test.ts similarity index 85% rename from src/daemon/interaction/internal/__tests__/interaction-runtime.test.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/interaction-runtime.test.ts index 8994028ee3..d23491de0a 100644 --- a/src/daemon/interaction/internal/__tests__/interaction-runtime.test.ts +++ b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-runtime.test.ts @@ -1,6 +1,6 @@ import { expectTypeOf, test } from 'vitest'; import type { CommandFlags } from '@agent-device/contracts/command'; -import type { InteractionRuntimeInput } from '../types.ts'; +import type { InteractionRuntimeInput } from '../../../../core/interaction/internal/types.ts'; test('interaction runtime accepts only explicit request capabilities', () => { expectTypeOf() diff --git a/src/daemon/interaction/internal/__tests__/interaction-snapshot-scope.test.ts b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-snapshot-scope.test.ts similarity index 93% rename from src/daemon/interaction/internal/__tests__/interaction-snapshot-scope.test.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/interaction-snapshot-scope.test.ts index 7c4904cbbd..c62c5218d0 100644 --- a/src/daemon/interaction/internal/__tests__/interaction-snapshot-scope.test.ts +++ b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-snapshot-scope.test.ts @@ -2,9 +2,9 @@ import { afterEach, expect, test, vi } from 'vitest'; import type { SnapshotOptions } from '@agent-device/contracts/interactor-types'; import type { CommandFlags } from '@agent-device/contracts/command'; import type { SnapshotNode } from '@agent-device/kernel/snapshot'; -import { makeAndroidSession } from '../../../__tests__/support/session-factories.ts'; -import { makeSessionStore } from '../../../__tests__/support/store-factory.ts'; -import { contextFromFlags } from '../../../context.ts'; +import { makeAndroidSession } from '../../../../__tests__/support/session-factories.ts'; +import { makeSessionStore } from '../../../../__tests__/support/store-factory.ts'; +import { contextFromFlags } from '../../../../core/context.ts'; import { captureSnapshotForSession } from '../../index.ts'; // The interaction runtime's capture (press/click/fill/longpress/hover --scope X, @@ -18,7 +18,7 @@ const captured = vi.hoisted(() => ({ held: undefined as Promise | undefined, })); -vi.mock('../../../snapshot-interactor-capture.ts', () => ({ +vi.mock('../../../../core/snapshot-interactor-capture.ts', () => ({ captureSnapshotWithInteractor: vi.fn(async ({ options }: { options: SnapshotOptions }) => { captured.options.push(options); await captured.held; diff --git a/src/daemon/interaction/internal/__tests__/interaction-touch-fixtures.ts b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-touch-fixtures.ts similarity index 93% rename from src/daemon/interaction/internal/__tests__/interaction-touch-fixtures.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/interaction-touch-fixtures.ts index c9fbad50d5..1b51da7f56 100644 --- a/src/daemon/interaction/internal/__tests__/interaction-touch-fixtures.ts +++ b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-touch-fixtures.ts @@ -4,10 +4,10 @@ import { makeAndroidSession as makeBaseAndroidSession, makeIosAppSession, makeMacOsSession as makeBaseMacOsSession, -} from '../../../__tests__/support/session-factories.ts'; -import { makeTestScreenRecordingResource } from '../../../__tests__/support/screen-recording-live-handle.ts'; -import { activateCompleteRefFrame } from '../../../ref-frame.ts'; -import type { SessionState } from '../../../session-state.ts'; +} from '../../../../__tests__/support/session-factories.ts'; +import { makeTestScreenRecordingResource } from '../../../../__tests__/support/screen-recording-live-handle.ts'; +import { activateCompleteRefFrame } from '../../../../core/ref-frame.ts'; +import type { SessionState } from '../../../../core/session-state.ts'; import { buildSnapshotState } from '@agent-device/capture-kit/snapshot-state'; /** diff --git a/src/daemon/interaction/internal/__tests__/interaction-touch-reference-frame.test.ts b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-touch-reference-frame.test.ts similarity index 89% rename from src/daemon/interaction/internal/__tests__/interaction-touch-reference-frame.test.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/interaction-touch-reference-frame.test.ts index 5eab8cd09c..df7e217a5a 100644 --- a/src/daemon/interaction/internal/__tests__/interaction-touch-reference-frame.test.ts +++ b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-touch-reference-frame.test.ts @@ -3,10 +3,10 @@ import { makeSnapshotState } from '@agent-device/capture-kit/snapshot-state-fixt import { makeAndroidSession, makeIosAppSession, -} from '../../../__tests__/support/session-factories.ts'; -import { makeTestScreenRecordingResource } from '../../../__tests__/support/screen-recording-live-handle.ts'; -import { makeSessionStore } from '../../../__tests__/support/store-factory.ts'; -import { clearAndroidObservationFixture } from '../../../__tests__/android-observation-fixture.ts'; +} from '../../../../__tests__/support/session-factories.ts'; +import { makeTestScreenRecordingResource } from '../../../../__tests__/support/screen-recording-live-handle.ts'; +import { makeSessionStore } from '../../../../__tests__/support/store-factory.ts'; +import { clearAndroidObservationFixture } from '../../../../__tests__/support/android-observation-fixture.ts'; import { contextFromFlags } from './interaction-touch-fixtures.ts'; import { resolveDirectTouchReferenceFrameSafely } from '../interaction-touch-reference-frame.ts'; diff --git a/packages/daemon/src/execution/interaction/internal/__tests__/interaction-touch-response.test.ts b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-touch-response.test.ts new file mode 100644 index 0000000000..13ea9cd835 --- /dev/null +++ b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-touch-response.test.ts @@ -0,0 +1,308 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import { + withDiagnosticsScope, + flushDiagnosticsToSessionFile, +} from '@agent-device/host-kit/diagnostics'; +import { mkdtempForTestSync } from '@agent-device/test-kit/tmp-dir'; +import { test, expect, vi, beforeEach } from 'vitest'; +import { attachRefs } from '@agent-device/kernel/snapshot'; +import { makeSessionStore } from '../../../../__tests__/support/store-factory.ts'; +import { + buildInteractionResponseData, + buildTargetedTouchResponsePayloads, + transformTouchResponseData, +} from '../interaction-touch-response.ts'; +import type { PressCommandResult } from '@agent-device/contracts/interaction'; +import { daemonPlatformServicesFixture } from '../../../../__tests__/support/platform-services-fixture.ts'; +import { fakeCreateCommandSurface as testCreateCommandSurface } from '../../../../__tests__/support/command-surface-fake.ts'; +import { + contextFromFlags, + installTestScreenRecording, + makeSession, +} from './interaction-touch-fixtures.ts'; + +// Pure response-builder suites: every case calls the daemon builders directly. The +// suites that drive `handleInteractionCommands` through the real root command surface +// (the --verify evidence branches) stayed root-side under +// `src/__tests__/daemon-composition/interaction/`, where the surface they exercise lives. + +const { mockRunAppleRunnerCommand } = vi.hoisted(() => ({ + mockRunAppleRunnerCommand: vi.fn(), +})); + +vi.mock('@agent-device/platform-android/mechanics', async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + getAndroidScreenSize: vi.fn(async () => ({ width: 1344, height: 2992 })), + getAndroidAppState: vi.fn(async () => ({})), + getAndroidBlockingDialogObservation: vi.fn(async () => ({ status: 'clear' }) as const), + }; +}); + +vi.mock('../../../../core/snapshot-interactor-capture.ts', () => ({ + captureSnapshotWithInteractor: vi.fn(), +})); + +vi.mock('@agent-device/platform-apple/runner/operations', async (importOriginal) => { + const actual = + await importOriginal(); + return { ...actual, runAppleRunnerCommand: mockRunAppleRunnerCommand }; +}); + +import { + getAndroidAppState, + getAndroidBlockingDialogObservation, + getAndroidScreenSize, +} from '@agent-device/platform-android/mechanics'; +import { captureSnapshotWithInteractor } from '../../../../core/snapshot-interactor-capture.ts'; + +beforeEach(() => { + vi.mocked(getAndroidAppState).mockReset(); + vi.mocked(getAndroidAppState).mockResolvedValue({}); + vi.mocked(getAndroidBlockingDialogObservation).mockReset(); + vi.mocked(getAndroidBlockingDialogObservation).mockResolvedValue({ status: 'clear' }); + vi.mocked(getAndroidScreenSize).mockReset(); + vi.mocked(getAndroidScreenSize).mockResolvedValue({ width: 1344, height: 2992 }); + vi.mocked(captureSnapshotWithInteractor).mockReset(); + mockRunAppleRunnerCommand.mockReset(); + mockRunAppleRunnerCommand.mockResolvedValue({}); +}); + +test('commandless longpress response omits internal interaction diagnostics', () => { + expect( + transformTouchResponseData({ + flags: {}, + data: { + currentUptimeMs: 900, + gestureStartUptimeMs: 100, + gestureEndUptimeMs: 800, + sequenceResults: [{ index: 0, success: true }], + completedSteps: 1, + }, + }), + ).toEqual({ completedSteps: 1 }); +}); + +function selectorResult(readiness?: { polls: number; waitedMs: number }): PressCommandResult { + return { + kind: 'selector', + point: { x: 10, y: 20 }, + target: { kind: 'selector', selector: 'label=Continue' }, + node: { ref: 'e1', index: 0, type: 'Button', label: 'Continue' }, + selectorChain: ['label=Continue'], + warning: 'earlier warning', + ...(readiness ? { readiness } : {}), + }; +} + +const WAITED_SELECTOR_RESULT = selectorResult({ polls: 3, waitedMs: 400 }); + +test.each([false, true])('selector-touch observation after retirement=%s', async (retired) => { + const sessionStore = makeSessionStore(); + const address = 'cwd:selector-touch-response:default'; + const session = makeSession('default'); + session.snapshot = { + nodes: attachRefs([{ index: 0, type: 'Button', label: 'Continue' }]), + createdAt: Date.now(), + backend: 'xctest', + }; + session.snapshotGeneration = 3; + const ref = sessionStore.publish(address, session); + const result: PressCommandResult = { + ...selectorResult(), + settle: { + settled: true, + waitedMs: 25, + captures: 2, + quietMs: 25, + timeoutMs: 2000, + diff: { + summary: { additions: 1, removals: 0, unchanged: 0 }, + lines: [{ kind: 'added', text: 'Continue', ref: 'e1' }], + }, + }, + }; + let successor; + if (retired) { + sessionStore.retire(ref); + successor = sessionStore.publish(address, makeSession('default')); + } + const payloads = await buildTargetedTouchResponsePayloads({ + params: { + createCommandSurface: testCreateCommandSurface, + req: { token: 't', command: 'press', positionals: ['@e1'], session: 'default' }, + sessionName: address, + sessionRef: ref, + sessionStore, + contextFromFlags, + platformServices: daemonPlatformServicesFixture(), + captureSnapshotForSession: vi.fn(), + }, + result, + staleRefsWarning: undefined, + extra: {}, + }); + if (retired) { + expect(payloads.responseData.settle).toBeUndefined(); + expect(payloads.result.settle).toBeUndefined(); + expect(sessionStore.lookup(address)).toEqual(successor); + expect(successor?.session.snapshot).toBeUndefined(); + } else { + expect(payloads.responseData.settle).toMatchObject({ refsGeneration: 3, settled: true }); + } +}); + +test.each([ + [false, false], + [false, true], + [true, false], + [true, true], +])( + 'point-touch publication after a held frame probe, retired=%s, fails=%s', + async (retired, fails) => { + const sessionStore = makeSessionStore(); + const address = 'cwd:held-touch-response:default'; + const session = makeSession('default'); + session.snapshot = { + nodes: attachRefs([{ index: 0, type: 'Button', label: 'Continue' }]), + createdAt: Date.now(), + backend: 'xctest', + }; + session.snapshotGeneration = 3; + installTestScreenRecording(session); + const ref = sessionStore.publish(address, session); + let startProbe!: () => void; + let releaseProbe!: () => void; + const probing = new Promise((resolve) => { + startProbe = resolve; + }); + const released = new Promise((resolve) => { + releaseProbe = resolve; + }); + const result: PressCommandResult = { + kind: 'point', + point: { x: 10, y: 20 }, + settle: { + settled: true, + waitedMs: 25, + captures: 2, + quietMs: 25, + timeoutMs: 2000, + diff: { + summary: { additions: 1, removals: 0, unchanged: 0 }, + lines: [{ kind: 'added', text: 'Continue', ref: 'e1' }], + }, + }, + }; + const logPath = path.join(mkdtempForTestSync('held-point-'), 'request.log'); + const running = withDiagnosticsScope( + { command: 'press', session: address, logPath, debug: true }, + async () => { + const payloads = await buildTargetedTouchResponsePayloads({ + params: { + createCommandSurface: testCreateCommandSurface, + req: { + token: 't', + command: 'press', + positionals: ['10', '20'], + session: 'default', + flags: {}, + }, + sessionName: address, + sessionRef: ref, + sessionStore, + contextFromFlags, + platformServices: daemonPlatformServicesFixture(), + captureSnapshotForSession: async () => { + startProbe(); + await released; + if (fails) throw new Error('frame capture failed'); + return sessionStore.requireCurrent(ref).snapshot!; + }, + }, + result, + staleRefsWarning: undefined, + extra: {}, + }); + flushDiagnosticsToSessionFile({ force: true }); + return payloads; + }, + ); + await probing; + let successor; + if (retired) { + sessionStore.retire(ref); + successor = sessionStore.publish(address, makeSession('default')); + } + releaseProbe(); + const payloads = await running; + const diagnostics = fs.existsSync(logPath) ? fs.readFileSync(logPath, 'utf8') : ''; + expect(diagnostics.includes('touch_reference_frame_resolve_failed')).toBe(!retired && fails); + expect(payloads.responseData.x).toBe(10); + if (retired) { + expect(payloads.responseData.settle).toBeUndefined(); + expect(payloads.result.settle).toBeUndefined(); + expect(sessionStore.lookup(address)).toEqual(successor); + expect(successor?.session.snapshot).toBeUndefined(); + } else { + expect(payloads.responseData.settle).toMatchObject({ refsGeneration: 3, settled: true }); + } + }, +); + +test('the response builder reports the resolved wait and keeps the prior warning', () => { + const { responseData, result } = buildInteractionResponseData({ + source: { kind: 'runtime', result: WAITED_SELECTOR_RESULT }, + referenceFrame: undefined, + staleRefsWarning: 'stale refs', + }); + + expect(responseData.readiness).toEqual({ polls: 3, waitedMs: 400 }); + expect(responseData.warning).toBe('earlier warning stale refs'); + expect(result.readiness).toBeUndefined(); +}); + +test('the response builder omits readiness when nothing waited', () => { + const { responseData } = buildInteractionResponseData({ + source: { kind: 'runtime', result: selectorResult() }, + referenceFrame: undefined, + }); + + expect('readiness' in responseData).toBe(false); +}); + +test('an already retired coordinate touch skips its frame probe without a warning', async () => { + const sessionStore = makeSessionStore(); + const ref = sessionStore.publish('retired-point', makeSession('retired-point')); + sessionStore.retire(ref); + const capture = vi.fn(); + const logPath = path.join(mkdtempForTestSync('retired-point-'), 'request.log'); + await withDiagnosticsScope( + { command: 'click', session: ref.address, logPath, debug: true }, + async () => { + const payloads = await buildTargetedTouchResponsePayloads({ + params: { + createCommandSurface: testCreateCommandSurface, + req: { token: 't', command: 'click', positionals: ['1', '2'], session: ref.address }, + sessionName: ref.address, + sessionRef: ref, + sessionStore, + contextFromFlags, + platformServices: daemonPlatformServicesFixture(), + captureSnapshotForSession: capture, + }, + result: { kind: 'point', point: { x: 1, y: 2 } }, + staleRefsWarning: undefined, + extra: {}, + }); + expect(payloads.responseData).toMatchObject({ x: 1, y: 2 }); + flushDiagnosticsToSessionFile({ force: true }); + }, + ); + expect(capture).not.toHaveBeenCalled(); + expect(fs.existsSync(logPath) ? fs.readFileSync(logPath, 'utf8') : '').not.toContain( + 'touch_reference_frame_resolve_failed', + ); +}); diff --git a/src/daemon/interaction/internal/__tests__/interaction-touch-targets.test.ts b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-touch-targets.test.ts similarity index 100% rename from src/daemon/interaction/internal/__tests__/interaction-touch-targets.test.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/interaction-touch-targets.test.ts diff --git a/src/daemon/interaction/internal/__tests__/interaction-type-android-readiness.test.ts b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-type-android-readiness.test.ts similarity index 86% rename from src/daemon/interaction/internal/__tests__/interaction-type-android-readiness.test.ts rename to packages/daemon/src/execution/interaction/internal/__tests__/interaction-type-android-readiness.test.ts index fe3edf0530..cf077efe6e 100644 --- a/src/daemon/interaction/internal/__tests__/interaction-type-android-readiness.test.ts +++ b/packages/daemon/src/execution/interaction/internal/__tests__/interaction-type-android-readiness.test.ts @@ -1,8 +1,8 @@ import { test, expect, vi, beforeEach } from 'vitest'; import { AppError } from '@agent-device/kernel/errors'; -import { makeAndroidSession } from '../../../__tests__/support/session-factories.ts'; -import { makeTestScreenRecordingResource } from '../../../__tests__/support/screen-recording-live-handle.ts'; -import { makeSessionStore } from '../../../__tests__/support/store-factory.ts'; +import { makeAndroidSession } from '../../../../__tests__/support/session-factories.ts'; +import { makeTestScreenRecordingResource } from '../../../../__tests__/support/screen-recording-live-handle.ts'; +import { makeSessionStore } from '../../../../__tests__/support/store-factory.ts'; import { handleInteractionCommands } from '../../index.ts'; import { contextFromFlags } from './interaction-touch-fixtures.ts'; import { @@ -10,7 +10,7 @@ import { mockTypeText, resetGetRuntimeFixture, } from '../../../__tests__/interaction-get-runtime-fixture.ts'; -import { fakeCreateCommandSurface } from '../../../__tests__/support/command-surface-fake.ts'; +import { fakeCreateCommandSurface } from '../../../../__tests__/support/command-surface-fake.ts'; vi.mock('@agent-device/platform-android/mechanics', async (importOriginal) => { const actual = await importOriginal(); diff --git a/src/daemon/interaction/internal/find-match-ranking.ts b/packages/daemon/src/execution/interaction/internal/find-match-ranking.ts similarity index 100% rename from src/daemon/interaction/internal/find-match-ranking.ts rename to packages/daemon/src/execution/interaction/internal/find-match-ranking.ts diff --git a/src/daemon/interaction/internal/find-match-resolution.ts b/packages/daemon/src/execution/interaction/internal/find-match-resolution.ts similarity index 95% rename from src/daemon/interaction/internal/find-match-resolution.ts rename to packages/daemon/src/execution/interaction/internal/find-match-resolution.ts index 6c4b16152e..3184388f78 100644 --- a/src/daemon/interaction/internal/find-match-resolution.ts +++ b/packages/daemon/src/execution/interaction/internal/find-match-resolution.ts @@ -8,8 +8,8 @@ import { SELECTOR_PIPELINE_POLICIES } from '@agent-device/selectors/selector-pip import type { SnapshotState } from '@agent-device/kernel/snapshot'; import { isRootInteractionContainer } from '@agent-device/selectors/interaction-targeting'; import { preferOnscreenMatches } from './find-match-ranking.ts'; -import type { DaemonRequest, DaemonResponse } from '../../daemon-request.ts'; -import type { SessionState } from '../../session-state.ts'; +import type { DaemonRequest, DaemonResponse } from '../../../core/daemon-request.ts'; +import type { SessionState } from '../../../core/session-state.ts'; import { buildAmbiguousMatchError } from '../../selector-match-errors.ts'; import { errorResponse } from '@agent-device/kernel/contracts'; diff --git a/src/daemon/interaction/internal/find-target-capture.ts b/packages/daemon/src/execution/interaction/internal/find-target-capture.ts similarity index 91% rename from src/daemon/interaction/internal/find-target-capture.ts rename to packages/daemon/src/execution/interaction/internal/find-target-capture.ts index 3109598692..d1ed52ee94 100644 --- a/src/daemon/interaction/internal/find-target-capture.ts +++ b/packages/daemon/src/execution/interaction/internal/find-target-capture.ts @@ -1,11 +1,11 @@ import type { FindLocator } from '@agent-device/selectors'; import type { BoundSelectorCapture } from '../../selector-capture-binding.ts'; import type { SnapshotQualityVerdict, SnapshotState } from '@agent-device/kernel/snapshot'; -import type { CaptureProvenance, RequestCaptureProof } from '../../capture-disclosure.ts'; +import type { CaptureProvenance, RequestCaptureProof } from '../../../core/capture-disclosure.ts'; import { createSelectorCaptureRuntime } from '../../selector-capture-runtime.ts'; -import { SessionStore } from '../../session-store.ts'; -import type { DaemonRequest, DaemonResponse } from '../../daemon-request.ts'; -import type { SessionRef, SessionState } from '../../session-state.ts'; +import { SessionStore } from '../../../core/session-store.ts'; +import type { DaemonRequest, DaemonResponse } from '../../../core/daemon-request.ts'; +import type { SessionRef, SessionState } from '../../../core/session-state.ts'; import { errorResponse } from '@agent-device/kernel/contracts'; /** The tree a mutating find resolves its target against, plus what the capture disclosed. */ diff --git a/src/daemon/interaction/internal/find.ts b/packages/daemon/src/execution/interaction/internal/find.ts similarity index 94% rename from src/daemon/interaction/internal/find.ts rename to packages/daemon/src/execution/interaction/internal/find.ts index 66c635830e..62be98f335 100644 --- a/src/daemon/interaction/internal/find.ts +++ b/packages/daemon/src/execution/interaction/internal/find.ts @@ -13,28 +13,32 @@ import { type SnapshotKeyboardBandFact, type SnapshotState, } from '@agent-device/kernel/snapshot'; -import { expireRefFrame } from '../../ref-frame.ts'; -import type { DaemonInvokeFn, DaemonRequest, DaemonResponse } from '../../daemon-request.ts'; -import type { SessionRef, SessionState } from '../../session-state.ts'; -import { SessionStore } from '../../session-store.ts'; -import { contextFromFlags } from '../../context.ts'; +import { expireRefFrame } from '../../../core/ref-frame.ts'; +import type { + DaemonInvokeFn, + DaemonRequest, + DaemonResponse, +} from '../../../core/daemon-request.ts'; +import type { SessionRef, SessionState } from '../../../core/session-state.ts'; +import { SessionStore } from '../../../core/session-store.ts'; +import { contextFromFlags } from '../../../core/context.ts'; import { readCommandMessage, successText } from '@agent-device/kernel/success-text'; -import type { RequestCaptureProof } from '../../capture-disclosure.ts'; -import { withCaptureDisclosures } from '../../capture-disclosure.ts'; -import { recordSessionAction } from '../../session-action-recorder.ts'; -import { stripInternalInteractionFlags } from '../../deferred-interaction-outcome.ts'; +import type { RequestCaptureProof } from '../../../core/capture-disclosure.ts'; +import { withCaptureDisclosures } from '../../../core/capture-disclosure.ts'; +import { recordSessionAction } from '../../../core/session-action-recorder.ts'; +import { stripInternalInteractionFlags } from '../../../core/deferred-interaction-outcome.ts'; import { resolveFindMatch } from './find-match-resolution.ts'; import { executeFocusPoint } from '../../focus-runtime.ts'; import { executeBoundTypeText } from '../../type-text-runtime.ts'; import { dispatchFindReadOnlyViaRuntime } from '../../selector-runtime.ts'; -import { admitAndBindSnapshotCapture } from '../../snapshot-runtime-binding.ts'; +import { admitAndBindSnapshotCapture } from '../../../core/snapshot-runtime-binding.ts'; import type { FocusPointInput } from '@agent-device/contracts/focus-runtime'; import { findRuntimeIntent, resolveSelectorCaptureRuntimePlan, } from '@agent-device/contracts/platform-runtime-operations'; import type { TypeTextRuntimeOperations } from '@agent-device/contracts/type-text-runtime'; -import type { FindRouteInput } from './types.ts'; +import type { FindRouteInput } from '../../../core/interaction/internal/types.ts'; import { createFindTargetCapture, sparseFindSnapshotResponse } from './find-target-capture.ts'; import { isSparseSnapshotQualityVerdict } from '@agent-device/capture-kit/snapshot-quality-verdict'; import { errorResponse, noActiveSessionError } from '@agent-device/kernel/contracts'; diff --git a/src/daemon/interaction/internal/interaction-android-escape.ts b/packages/daemon/src/execution/interaction/internal/interaction-android-escape.ts similarity index 95% rename from src/daemon/interaction/internal/interaction-android-escape.ts rename to packages/daemon/src/execution/interaction/internal/interaction-android-escape.ts index 4f923396be..355acaf1b8 100644 --- a/src/daemon/interaction/internal/interaction-android-escape.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-android-escape.ts @@ -1,7 +1,7 @@ import type { AndroidObservationAdapter } from '@agent-device/contracts/android-observation'; import { AppError } from '@agent-device/kernel/errors'; import { detectAndroidEscapeSurface } from '../../android-foreground-surface.ts'; -import type { SessionState } from '../../session-state.ts'; +import type { SessionState } from '../../../core/session-state.ts'; /** * Post-press escape guard. Throws when the tap left the app for a genuine diff --git a/src/daemon/interaction/internal/interaction-common.ts b/packages/daemon/src/execution/interaction/internal/interaction-common.ts similarity index 94% rename from src/daemon/interaction/internal/interaction-common.ts rename to packages/daemon/src/execution/interaction/internal/interaction-common.ts index 05d1ecccab..fcbb012248 100644 --- a/src/daemon/interaction/internal/interaction-common.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-common.ts @@ -1,8 +1,8 @@ import type { CommandFlags } from '@agent-device/contracts/command'; import type { SettleObservation, SurfaceScopedNodes } from '@agent-device/contracts/interaction'; import type { SnapshotState } from '@agent-device/kernel/snapshot'; -import type { DaemonResponse } from '../../daemon-request.ts'; -import { stripInternalInteractionFlags } from '../../deferred-interaction-outcome.ts'; +import type { DaemonResponse } from '../../../core/daemon-request.ts'; +import { stripInternalInteractionFlags } from '../../../core/deferred-interaction-outcome.ts'; import { computeTargetEvidence, type RecordedTargetCapture, @@ -14,7 +14,7 @@ import { sensitiveFillPlaceholder, } from '@agent-device/ad-script'; import { parameterizeRecordedFillPayload } from '@agent-device/selectors/parameterized-recorded-fill'; -import type { InteractionFinalizationOperations } from './types.ts'; +import type { InteractionFinalizationOperations } from '../../../core/interaction/internal/types.ts'; export function finalizeTouchInteraction(params: { operations: InteractionFinalizationOperations; diff --git a/src/daemon/interaction/internal/interaction-flags.ts b/packages/daemon/src/execution/interaction/internal/interaction-flags.ts similarity index 93% rename from src/daemon/interaction/internal/interaction-flags.ts rename to packages/daemon/src/execution/interaction/internal/interaction-flags.ts index 4e72352012..075bc4352b 100644 --- a/src/daemon/interaction/internal/interaction-flags.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-flags.ts @@ -1,6 +1,6 @@ import type { CommandFlags } from '@agent-device/contracts/command'; import type { SettleParams } from '@agent-device/contracts/interaction'; -import type { DaemonResponse } from '../../daemon-request.ts'; +import type { DaemonResponse } from '../../../core/daemon-request.ts'; import { interactionErrorResponse } from './interaction-response.ts'; export function settleFlagGuardResponse( diff --git a/src/daemon/interaction/internal/interaction-gesture-response.ts b/packages/daemon/src/execution/interaction/internal/interaction-gesture-response.ts similarity index 100% rename from src/daemon/interaction/internal/interaction-gesture-response.ts rename to packages/daemon/src/execution/interaction/internal/interaction-gesture-response.ts diff --git a/src/daemon/interaction/internal/interaction-gesture.ts b/packages/daemon/src/execution/interaction/internal/interaction-gesture.ts similarity index 96% rename from src/daemon/interaction/internal/interaction-gesture.ts rename to packages/daemon/src/execution/interaction/internal/interaction-gesture.ts index 7e253533ab..a7e990ed3f 100644 --- a/src/daemon/interaction/internal/interaction-gesture.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-gesture.ts @@ -24,23 +24,29 @@ import { splitRefGenerationSuffix, type Point, } from '@agent-device/kernel/snapshot'; -import { resolveBoundGestureRuntime, type BoundGestureExecutor } from '../../gesture-runtime.ts'; -import { isActiveProviderDevice } from '../../provider-device-admission.ts'; +import { + resolveBoundGestureRuntime, + type BoundGestureExecutor, +} from '../../../core/gesture-runtime.ts'; +import { isActiveProviderDevice } from '../../../core/provider-device-admission.ts'; import { sleep } from '@agent-device/host-kit/retry'; import { ensureAndroidBlockingSystemDialogReady, type AndroidBlockingDialogReadinessResult, } from '../../android-system-dialog.ts'; -import { readRefMutationFrame } from '../../ref-frame.ts'; -import type { DaemonResponse } from '../../daemon-request.ts'; +import { readRefMutationFrame } from '../../../core/ref-frame.ts'; +import type { DaemonResponse } from '../../../core/daemon-request.ts'; import { thrownBeforeDispatch } from '../../request-dispatch-disclosure.ts'; -import type { SessionState } from '../../session-state.ts'; +import type { SessionState } from '../../../core/session-state.ts'; import { assertRefMutationAdmitted } from './interaction-ref-policy.ts'; import { createInteractionRuntimeForRoute, finalizeTouchInteraction, } from './interaction-runtime.ts'; -import type { CaptureSnapshotForSession, InteractionRouteInput } from './types.ts'; +import type { + CaptureSnapshotForSession, + InteractionRouteInput, +} from '../../../core/interaction/internal/types.ts'; import type { RecordedTargetCapture } from '@agent-device/selectors/target-evidence'; import { gestureResponseData } from './interaction-gesture-response.ts'; import { noActiveSessionError } from '@agent-device/kernel/contracts'; diff --git a/src/daemon/interaction/internal/interaction-ios-tap-outcome.ts b/packages/daemon/src/execution/interaction/internal/interaction-ios-tap-outcome.ts similarity index 96% rename from src/daemon/interaction/internal/interaction-ios-tap-outcome.ts rename to packages/daemon/src/execution/interaction/internal/interaction-ios-tap-outcome.ts index daa210dd46..88d5c24703 100644 --- a/src/daemon/interaction/internal/interaction-ios-tap-outcome.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-ios-tap-outcome.ts @@ -8,12 +8,15 @@ import { } from '@agent-device/capture-kit/snapshot-quality-verdict'; import { summarizeAxEvidence } from '@agent-device/capture-kit/snapshot-evidence'; import { getRequestSignal } from '@agent-device/host-kit/request'; -import { isLocalIosRunnerSession } from '../../direct-ios-selector.ts'; +import { isLocalIosRunnerSession } from '../../../core/direct-ios-selector.ts'; import { emitDiagnostic } from '@agent-device/host-kit/diagnostics'; -import type { SessionStore } from '../../session-store.ts'; -import type { SessionRef, SessionState } from '../../session-state.ts'; -import type { BoundSnapshotCapture } from '../../snapshot-runtime-binding.ts'; -import type { BoundContextFromFlags, CaptureSnapshotForSession } from './types.ts'; +import type { SessionStore } from '../../../core/session-store.ts'; +import type { SessionRef, SessionState } from '../../../core/session-state.ts'; +import type { BoundSnapshotCapture } from '../../../core/snapshot-runtime-binding.ts'; +import type { + BoundContextFromFlags, + CaptureSnapshotForSession, +} from '../../../core/interaction/internal/types.ts'; const XCTEST_RECORDED_FAILURE = 'XCTEST_RECORDED_FAILURE'; // A model commonly needs 5-10s to choose a target after receiving a snapshot. diff --git a/src/daemon/interaction/internal/interaction-recorded-input.ts b/packages/daemon/src/execution/interaction/internal/interaction-recorded-input.ts similarity index 100% rename from src/daemon/interaction/internal/interaction-recorded-input.ts rename to packages/daemon/src/execution/interaction/internal/interaction-recorded-input.ts diff --git a/src/daemon/interaction/internal/interaction-ref-policy.ts b/packages/daemon/src/execution/interaction/internal/interaction-ref-policy.ts similarity index 96% rename from src/daemon/interaction/internal/interaction-ref-policy.ts rename to packages/daemon/src/execution/interaction/internal/interaction-ref-policy.ts index b0a4723ce5..2e100ffd8b 100644 --- a/src/daemon/interaction/internal/interaction-ref-policy.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-ref-policy.ts @@ -1,6 +1,6 @@ import { AppError } from '@agent-device/kernel/errors'; -import type { DaemonResponse } from '../../daemon-request.ts'; -import type { RefFrameRejectReason, RefMutationFrame } from '../../ref-frame.ts'; +import type { DaemonResponse } from '../../../core/daemon-request.ts'; +import type { RefFrameRejectReason, RefMutationFrame } from '../../../core/ref-frame.ts'; import { interactionErrorResponse } from './interaction-response.ts'; export function refMutationAdmissionResponse(params: { diff --git a/src/daemon/interaction/internal/interaction-response-data-transform.ts b/packages/daemon/src/execution/interaction/internal/interaction-response-data-transform.ts similarity index 100% rename from src/daemon/interaction/internal/interaction-response-data-transform.ts rename to packages/daemon/src/execution/interaction/internal/interaction-response-data-transform.ts diff --git a/src/daemon/interaction/internal/interaction-response.ts b/packages/daemon/src/execution/interaction/internal/interaction-response.ts similarity index 78% rename from src/daemon/interaction/internal/interaction-response.ts rename to packages/daemon/src/execution/interaction/internal/interaction-response.ts index 345b6315f7..71658fa8e2 100644 --- a/src/daemon/interaction/internal/interaction-response.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-response.ts @@ -1,4 +1,4 @@ -import type { DaemonResponse } from '../../daemon-request.ts'; +import type { DaemonResponse } from '../../../core/daemon-request.ts'; export function interactionErrorResponse( code: string, diff --git a/src/daemon/interaction/internal/interaction-runtime.ts b/packages/daemon/src/execution/interaction/internal/interaction-runtime.ts similarity index 90% rename from src/daemon/interaction/internal/interaction-runtime.ts rename to packages/daemon/src/execution/interaction/internal/interaction-runtime.ts index bee3cd7c63..d62c4a488c 100644 --- a/src/daemon/interaction/internal/interaction-runtime.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-runtime.ts @@ -8,30 +8,30 @@ import type { } from '@agent-device/contracts/backend'; import { getRequestSignal } from '@agent-device/host-kit/request'; import type { Rect, SnapshotState } from '@agent-device/kernel/snapshot'; -import type { DaemonCommandContext } from '../../context.ts'; +import type { DaemonCommandContext } from '../../../core/context.ts'; import { createDaemonRuntimePolicy } from '../../runtime-policy.ts'; -import { recordCaptureProof } from '../../capture-disclosure.ts'; +import { recordCaptureProof } from '../../../core/capture-disclosure.ts'; import { confirmIosOffscreenTargetVisible } from '../../offscreen-target-probe.ts'; -import { runtimeExecutionFromContext } from '../../snapshot-runtime-capture-input.ts'; -import { createDaemonRuntimeSessionStore } from '../../runtime-session.ts'; -import { expireRefFrame } from '../../ref-frame.ts'; +import { runtimeExecutionFromContext } from '../../../core/snapshot-runtime-capture-input.ts'; +import { createDaemonRuntimeSessionStore } from '../../../core/runtime-session.ts'; +import { expireRefFrame } from '../../../core/ref-frame.ts'; import { setSessionSnapshot } from '../../session-snapshot.ts'; import type { CaptureSnapshotForSession, InteractionRouteInput, InteractionRuntimeInput, SettleObservationCaptureInput, -} from './types.ts'; +} from '../../../core/interaction/internal/types.ts'; import { finalizeTouchInteraction as finalizeInteraction } from './interaction-common.ts'; -import { markDeferredInteractionOutcome } from '../../deferred-interaction-outcome.ts'; -import { isSessionRecording } from '../../session-script-publication-capability.ts'; -import { recordTouchVisualizationEvent } from '../../recording-gestures.ts'; -import type { SessionStore } from '../../session-store.ts'; -import type { DaemonResponse } from '../../daemon-request.ts'; -import type { SessionRef } from '../../session-state.ts'; -import type { BoundTouchExecutor } from '../../touch-runtime.ts'; -import type { BoundGestureExecutor } from '../../gesture-runtime.ts'; -import type { BoundSnapshotCapture } from '../../snapshot-runtime-binding.ts'; +import { markDeferredInteractionOutcome } from '../../../core/deferred-interaction-outcome.ts'; +import { isSessionRecording } from '../../../core/session-script-publication-capability.ts'; +import { recordTouchVisualizationEvent } from '../../../core/recording-gestures.ts'; +import type { SessionStore } from '../../../core/session-store.ts'; +import type { DaemonResponse } from '../../../core/daemon-request.ts'; +import type { SessionRef } from '../../../core/session-state.ts'; +import type { BoundTouchExecutor } from '../../../core/touch-runtime.ts'; +import type { BoundGestureExecutor } from '../../../core/gesture-runtime.ts'; +import type { BoundSnapshotCapture } from '../../../core/snapshot-runtime-binding.ts'; import { NO_ACTIVE_SESSION_MESSAGE } from '@agent-device/kernel/contracts'; export async function createInteractionRuntimeForRoute( diff --git a/src/daemon/interaction/internal/interaction-session.ts b/packages/daemon/src/execution/interaction/internal/interaction-session.ts similarity index 65% rename from src/daemon/interaction/internal/interaction-session.ts rename to packages/daemon/src/execution/interaction/internal/interaction-session.ts index fa079cd281..8f80c14e17 100644 --- a/src/daemon/interaction/internal/interaction-session.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-session.ts @@ -1,5 +1,5 @@ -import type { InteractionRouteInput } from './types.ts'; -import type { SessionRef } from '../../session-state.ts'; +import type { InteractionRouteInput } from '../../../core/interaction/internal/types.ts'; +import type { SessionRef } from '../../../core/session-state.ts'; export function bindInteractionSession( params: Params, diff --git a/src/daemon/interaction/internal/interaction-snapshot.ts b/packages/daemon/src/execution/interaction/internal/interaction-snapshot.ts similarity index 92% rename from src/daemon/interaction/internal/interaction-snapshot.ts rename to packages/daemon/src/execution/interaction/internal/interaction-snapshot.ts index 32af84964c..cefb420438 100644 --- a/src/daemon/interaction/internal/interaction-snapshot.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-snapshot.ts @@ -1,13 +1,13 @@ import type { CommandFlags } from '@agent-device/contracts/command'; import type { SnapshotState } from '@agent-device/kernel/snapshot'; -import type { DaemonCommandContext } from '../../context.ts'; +import type { DaemonCommandContext } from '../../../core/context.ts'; import { isSparseSnapshotQualityVerdict } from '@agent-device/capture-kit/snapshot-quality-verdict'; import { snapshotOptionsToFlags } from '@agent-device/contracts/backend-snapshot-options'; import type { BoundContextFromFlags, InteractionSessionView, InteractionSnapshotOptions, -} from './types.ts'; +} from '../../../core/interaction/internal/types.ts'; export type InteractionSnapshotCapture = (params: { flags: CommandFlags; diff --git a/src/daemon/interaction/internal/interaction-targeting.ts b/packages/daemon/src/execution/interaction/internal/interaction-targeting.ts similarity index 100% rename from src/daemon/interaction/internal/interaction-targeting.ts rename to packages/daemon/src/execution/interaction/internal/interaction-targeting.ts diff --git a/src/daemon/interaction/internal/interaction-touch-android-freshness.ts b/packages/daemon/src/execution/interaction/internal/interaction-touch-android-freshness.ts similarity index 80% rename from src/daemon/interaction/internal/interaction-touch-android-freshness.ts rename to packages/daemon/src/execution/interaction/internal/interaction-touch-android-freshness.ts index 2704184b40..2f615f9e7e 100644 --- a/src/daemon/interaction/internal/interaction-touch-android-freshness.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-touch-android-freshness.ts @@ -1,7 +1,10 @@ import { emitDiagnostic } from '@agent-device/host-kit/diagnostics'; -import { getActiveAndroidSnapshotFreshness } from '../../session-snapshot-freshness.ts'; -import type { SessionState } from '../../session-state.ts'; -import type { CaptureSnapshotForSession, InteractionRouteInput } from './types.ts'; +import { getActiveAndroidSnapshotFreshness } from '../../../core/session-snapshot-freshness.ts'; +import type { SessionState } from '../../../core/session-state.ts'; +import type { + CaptureSnapshotForSession, + InteractionRouteInput, +} from '../../../core/interaction/internal/types.ts'; /** * The Android ref-refresh capture a `@ref` mutation takes before dispatch, and diff --git a/src/daemon/interaction/internal/interaction-touch-android-readiness.ts b/packages/daemon/src/execution/interaction/internal/interaction-touch-android-readiness.ts similarity index 92% rename from src/daemon/interaction/internal/interaction-touch-android-readiness.ts rename to packages/daemon/src/execution/interaction/internal/interaction-touch-android-readiness.ts index 77da08deca..30d684558e 100644 --- a/src/daemon/interaction/internal/interaction-touch-android-readiness.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-touch-android-readiness.ts @@ -2,9 +2,9 @@ import { ensureAndroidBlockingSystemDialogReady, type AndroidBlockingDialogReadinessResult, } from '../../android-system-dialog.ts'; -import type { DaemonResponse } from '../../daemon-request.ts'; -import type { SessionState } from '../../session-state.ts'; -import { readRefMutationFrame } from '../../ref-frame.ts'; +import type { DaemonResponse } from '../../../core/daemon-request.ts'; +import type { SessionState } from '../../../core/session-state.ts'; +import { readRefMutationFrame } from '../../../core/ref-frame.ts'; import { refMutationAdmissionResponse } from './interaction-ref-policy.ts'; import type { AndroidObservationAdapter } from '@agent-device/contracts/android-observation'; diff --git a/src/daemon/interaction/internal/interaction-touch-direct-ios.ts b/packages/daemon/src/execution/interaction/internal/interaction-touch-direct-ios.ts similarity index 93% rename from src/daemon/interaction/internal/interaction-touch-direct-ios.ts rename to packages/daemon/src/execution/interaction/internal/interaction-touch-direct-ios.ts index 96564df057..9ad8f23ae6 100644 --- a/src/daemon/interaction/internal/interaction-touch-direct-ios.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-touch-direct-ios.ts @@ -4,14 +4,17 @@ import { emitDiagnostic } from '@agent-device/host-kit/diagnostics'; import { isDirectIosSelectorFallbackError, type DirectIosSelectorTarget, -} from '../../direct-ios-selector.ts'; -import { expireRefFrame } from '../../ref-frame.ts'; -import type { DaemonResponse } from '../../daemon-request.ts'; -import type { SessionState } from '../../session-state.ts'; +} from '../../../core/direct-ios-selector.ts'; +import { expireRefFrame } from '../../../core/ref-frame.ts'; +import type { DaemonResponse } from '../../../core/daemon-request.ts'; +import type { SessionState } from '../../../core/session-state.ts'; import { finalizeTouchInteraction } from './interaction-runtime.ts'; -import type { CaptureSnapshotForSession, InteractionRouteInput } from './types.ts'; +import type { + CaptureSnapshotForSession, + InteractionRouteInput, +} from '../../../core/interaction/internal/types.ts'; import { corroborateIosTapFailure } from './interaction-ios-tap-outcome.ts'; -import type { BoundTouchExecutor } from '../../touch-runtime.ts'; +import type { BoundTouchExecutor } from '../../../core/touch-runtime.ts'; import { buildCorroboratedTapResponseData, buildInteractionResponseData, diff --git a/src/daemon/interaction/internal/interaction-touch-fill.ts b/packages/daemon/src/execution/interaction/internal/interaction-touch-fill.ts similarity index 94% rename from src/daemon/interaction/internal/interaction-touch-fill.ts rename to packages/daemon/src/execution/interaction/internal/interaction-touch-fill.ts index 0142edac5d..e2ef365ce5 100644 --- a/src/daemon/interaction/internal/interaction-touch-fill.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-touch-fill.ts @@ -2,11 +2,11 @@ import { bindInteractionSession } from './interaction-session.ts'; import type { CommandFlags } from '@agent-device/contracts/command'; import type { FillCommandResult, InteractionTarget } from '@agent-device/contracts/interaction'; import { issueSettleRefs, resolveRefStalenessWarning } from '../../session-snapshot.ts'; -import { readRefMutationFrame } from '../../ref-frame.ts'; -import type { DaemonResponse } from '../../daemon-request.ts'; -import type { SessionRef, SessionState } from '../../session-state.ts'; -import type { SessionStore } from '../../session-store.ts'; -import { isSessionRecording } from '../../session-script-publication-capability.ts'; +import { readRefMutationFrame } from '../../../core/ref-frame.ts'; +import type { DaemonResponse } from '../../../core/daemon-request.ts'; +import type { SessionRef, SessionState } from '../../../core/session-state.ts'; +import type { SessionStore } from '../../../core/session-store.ts'; +import { isSessionRecording } from '../../../core/session-script-publication-capability.ts'; import { assertRecordedFillParameterization } from './interaction-recorded-input.ts'; import { readSettleRequest, settleFlagGuardResponse } from './interaction-flags.ts'; import { refMutationAdmissionResponse } from './interaction-ref-policy.ts'; @@ -15,7 +15,7 @@ import type { InteractionRouteInput, RefSnapshotFlagGuardResponse, SettleObservationCaptureInput, -} from './types.ts'; +} from '../../../core/interaction/internal/types.ts'; import { refreshAndroidRefSnapshotIfFreshnessActive } from './interaction-touch-android-freshness.ts'; import { unsupportedMacOsDesktopSurfaceInteraction } from './interaction-touch-policy.ts'; import { readSnapshotNodesReferenceFrame } from '@agent-device/capture-kit/touch-reference-frame'; @@ -29,7 +29,7 @@ import { dispatchRuntimeInteraction } from './interaction-touch-runtime.ts'; import { parseFillTarget } from './interaction-touch-targets.ts'; import { prepareTouchDispatch } from './interaction-touch-prepare.ts'; import { refusedBeforeDispatch, thrownBeforeDispatch } from '../../request-dispatch-disclosure.ts'; -import type { BoundTouchExecutor } from '../../touch-runtime.ts'; +import type { BoundTouchExecutor } from '../../../core/touch-runtime.ts'; import { noActiveSessionError } from '@agent-device/kernel/contracts'; /** diff --git a/src/daemon/interaction/internal/interaction-touch-payload.ts b/packages/daemon/src/execution/interaction/internal/interaction-touch-payload.ts similarity index 100% rename from src/daemon/interaction/internal/interaction-touch-payload.ts rename to packages/daemon/src/execution/interaction/internal/interaction-touch-payload.ts diff --git a/src/daemon/interaction/internal/interaction-touch-policy.ts b/packages/daemon/src/execution/interaction/internal/interaction-touch-policy.ts similarity index 84% rename from src/daemon/interaction/internal/interaction-touch-policy.ts rename to packages/daemon/src/execution/interaction/internal/interaction-touch-policy.ts index c557478326..ff7d7049a0 100644 --- a/src/daemon/interaction/internal/interaction-touch-policy.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-touch-policy.ts @@ -1,6 +1,6 @@ import { isMacOs } from '@agent-device/kernel/device'; -import type { DaemonResponse } from '../../daemon-request.ts'; -import type { SessionState } from '../../session-state.ts'; +import type { DaemonResponse } from '../../../core/daemon-request.ts'; +import type { SessionState } from '../../../core/session-state.ts'; import { errorResponse } from '@agent-device/kernel/contracts'; export function unsupportedMacOsDesktopSurfaceInteraction( diff --git a/src/daemon/interaction/internal/interaction-touch-prepare.ts b/packages/daemon/src/execution/interaction/internal/interaction-touch-prepare.ts similarity index 85% rename from src/daemon/interaction/internal/interaction-touch-prepare.ts rename to packages/daemon/src/execution/interaction/internal/interaction-touch-prepare.ts index 6cc9ab7ba5..f38fa831f3 100644 --- a/src/daemon/interaction/internal/interaction-touch-prepare.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-touch-prepare.ts @@ -1,14 +1,14 @@ -import type { SessionState } from '../../session-state.ts'; +import type { SessionState } from '../../../core/session-state.ts'; import { createBoundTouchExecutor, resolveBoundTouchRuntime, type BoundTouchExecutor, type TouchRuntimeCommand, -} from '../../touch-runtime.ts'; +} from '../../../core/touch-runtime.ts'; import { readSettleRequest } from './interaction-flags.ts'; -import type { BoundSnapshotCapture } from '../../snapshot-runtime-binding.ts'; -import { resolveSettleObservationCapture } from '../../settle-observation-capture.ts'; -import type { InteractionRouteInput } from './types.ts'; +import type { BoundSnapshotCapture } from '../../../core/snapshot-runtime-binding.ts'; +import { resolveSettleObservationCapture } from '../../../core/settle-observation-capture.ts'; +import type { InteractionRouteInput } from '../../../core/interaction/internal/types.ts'; import type { DaemonFailureResponse } from '@agent-device/kernel/contracts'; import { refusedBeforeDispatch } from '../../request-dispatch-disclosure.ts'; diff --git a/src/daemon/interaction/internal/interaction-touch-press-admission.ts b/packages/daemon/src/execution/interaction/internal/interaction-touch-press-admission.ts similarity index 96% rename from src/daemon/interaction/internal/interaction-touch-press-admission.ts rename to packages/daemon/src/execution/interaction/internal/interaction-touch-press-admission.ts index b57006e5aa..63232dfa26 100644 --- a/src/daemon/interaction/internal/interaction-touch-press-admission.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-touch-press-admission.ts @@ -7,9 +7,9 @@ import { } from '@agent-device/contracts/click-button'; import { publicPlatformString } from '@agent-device/kernel/device'; import { resolveRefStalenessWarning } from '../../session-snapshot.ts'; -import { readRefMutationFrame } from '../../ref-frame.ts'; -import type { DaemonResponse } from '../../daemon-request.ts'; -import type { SessionState } from '../../session-state.ts'; +import { readRefMutationFrame } from '../../../core/ref-frame.ts'; +import type { DaemonResponse } from '../../../core/daemon-request.ts'; +import type { SessionState } from '../../../core/session-state.ts'; import { refMutationAdmissionResponse } from './interaction-ref-policy.ts'; import { refusedBeforeDispatch } from '../../request-dispatch-disclosure.ts'; import { settleFlagGuardResponse } from './interaction-flags.ts'; @@ -17,7 +17,7 @@ import type { CaptureSnapshotForSession, InteractionRouteInput, RefSnapshotFlagGuardResponse, -} from './types.ts'; +} from '../../../core/interaction/internal/types.ts'; import type { RefAdmissionContext } from './interaction-touch-android-readiness.ts'; import { unsupportedMacOsDesktopSurfaceInteraction } from './interaction-touch-policy.ts'; import { diff --git a/src/daemon/interaction/internal/interaction-touch-press.ts b/packages/daemon/src/execution/interaction/internal/interaction-touch-press.ts similarity index 97% rename from src/daemon/interaction/internal/interaction-touch-press.ts rename to packages/daemon/src/execution/interaction/internal/interaction-touch-press.ts index 1bd6944889..e19a4384f1 100644 --- a/src/daemon/interaction/internal/interaction-touch-press.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-touch-press.ts @@ -6,12 +6,12 @@ import type { } from '@agent-device/contracts/interaction'; import type { resolveClickButton } from '@agent-device/contracts/click-button'; import type { ReplayTargetGuardDenotation } from '@agent-device/contracts/replay'; -import type { DaemonResponse } from '../../daemon-request.ts'; +import type { DaemonResponse } from '../../../core/daemon-request.ts'; import { assertAndroidPressStayedInApp } from './interaction-android-escape.ts'; import { createInteractionRuntimeForRoute } from './interaction-runtime.ts'; import { readSettleRequest } from './interaction-flags.ts'; import { dispatchDirectIosSelectorTap } from './interaction-touch-direct-ios.ts'; -import { readDirectIosSelectorTapTarget } from './interaction-touch-direct-ios-eligibility.ts'; +import { readDirectIosSelectorTapTarget } from '../../../core/interaction/internal/interaction-touch-direct-ios-eligibility.ts'; import { admitTargetedTouch, type AdmittedTargetedTouch, diff --git a/src/daemon/interaction/internal/interaction-touch-reference-frame.ts b/packages/daemon/src/execution/interaction/internal/interaction-touch-reference-frame.ts similarity index 89% rename from src/daemon/interaction/internal/interaction-touch-reference-frame.ts rename to packages/daemon/src/execution/interaction/internal/interaction-touch-reference-frame.ts index e8c4c39389..807a54619f 100644 --- a/src/daemon/interaction/internal/interaction-touch-reference-frame.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-touch-reference-frame.ts @@ -2,11 +2,14 @@ import type { CommandFlags } from '@agent-device/contracts/command'; import type { AndroidObservationAdapter } from '@agent-device/contracts/android-observation'; import type { GestureReferenceFrame } from '@agent-device/contracts/scroll-gesture'; import { emitDiagnostic } from '@agent-device/host-kit/diagnostics'; -import type { SessionStore } from '../../session-store.ts'; +import type { SessionStore } from '../../../core/session-store.ts'; import { getSnapshotReferenceFrame } from '@agent-device/capture-kit/touch-reference-frame'; -import type { SessionRef } from '../../session-state.ts'; -import type { BoundContextFromFlags, CaptureSnapshotForSession } from './types.ts'; -import { isActiveProviderDevice } from '../../provider-device-admission.ts'; +import type { SessionRef } from '../../../core/session-state.ts'; +import type { + BoundContextFromFlags, + CaptureSnapshotForSession, +} from '../../../core/interaction/internal/types.ts'; +import { isActiveProviderDevice } from '../../../core/provider-device-admission.ts'; async function resolveDirectTouchReferenceFrame(params: { ref: SessionRef; diff --git a/src/daemon/interaction/internal/interaction-touch-response.ts b/packages/daemon/src/execution/interaction/internal/interaction-touch-response.ts similarity index 98% rename from src/daemon/interaction/internal/interaction-touch-response.ts rename to packages/daemon/src/execution/interaction/internal/interaction-touch-response.ts index 741da1b325..36ab7bcdee 100644 --- a/src/daemon/interaction/internal/interaction-touch-response.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-touch-response.ts @@ -17,7 +17,10 @@ import { } from './interaction-response-data-transform.ts'; import { issueSettleRefs } from '../../session-snapshot.ts'; import type { RecordedTargetCapture } from '@agent-device/selectors/target-evidence'; -import type { CaptureSnapshotForSession, InteractionRouteInput } from './types.ts'; +import type { + CaptureSnapshotForSession, + InteractionRouteInput, +} from '../../../core/interaction/internal/types.ts'; import { resolveDirectTouchReferenceFrameSafely } from './interaction-touch-reference-frame.ts'; import { readSnapshotNodesReferenceFrame } from '@agent-device/capture-kit/touch-reference-frame'; import { buildTouchPayload } from './interaction-touch-payload.ts'; @@ -155,7 +158,7 @@ export function buildInteractionResponseData(params: { extra?: Record; /** * Staleness warning for the consumed `@ref` argument (ADR 0014), resolved by - * `resolveRefStalenessWarning` (src/daemon/session-snapshot.ts): the + * `resolveRefStalenessWarning` (packages/daemon/src/execution/session-snapshot.ts): the * STALE_SNAPSHOT_REFS_WARNING for a plain ref once the frame has expired, or * the precise pinned-generation warning for a `@e12~s3` ref whose epoch no * longer matches the frame. Stale mutations are rejected before reaching this diff --git a/src/daemon/interaction/internal/interaction-touch-runtime.ts b/packages/daemon/src/execution/interaction/internal/interaction-touch-runtime.ts similarity index 95% rename from src/daemon/interaction/internal/interaction-touch-runtime.ts rename to packages/daemon/src/execution/interaction/internal/interaction-touch-runtime.ts index b7b7480468..fd17b3d4eb 100644 --- a/src/daemon/interaction/internal/interaction-touch-runtime.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-touch-runtime.ts @@ -11,14 +11,17 @@ import type { SnapshotState } from '@agent-device/kernel/snapshot'; import { asAppError, normalizeError } from '@agent-device/kernel/errors'; import { readResolvedInteractionTarget } from '@agent-device/host-kit/interaction-outcome'; import { publishAmbiguousMatchCandidateRefs } from '../../session-snapshot.ts'; -import { isSessionRecording } from '../../session-script-publication-capability.ts'; -import type { DaemonResponse } from '../../daemon-request.ts'; -import type { SessionState } from '../../session-state.ts'; +import { isSessionRecording } from '../../../core/session-script-publication-capability.ts'; +import type { DaemonResponse } from '../../../core/daemon-request.ts'; +import type { SessionState } from '../../../core/session-state.ts'; import { createInteractionRuntimeForRoute, finalizeTouchInteraction, } from './interaction-runtime.ts'; -import type { CaptureSnapshotForSession, InteractionRouteInput } from './types.ts'; +import type { + CaptureSnapshotForSession, + InteractionRouteInput, +} from '../../../core/interaction/internal/types.ts'; import { isAndroidEscapeError } from './interaction-android-escape.ts'; import { corroborateIosTapFailure, interactionTargetExtra } from './interaction-ios-tap-outcome.ts'; import { @@ -31,8 +34,8 @@ import { buildInteractionResponseData, type InteractionResponsePayloads, } from './interaction-touch-response.ts'; -import type { BoundTouchExecutor } from '../../touch-runtime.ts'; -import type { BoundSnapshotCapture } from '../../snapshot-runtime-binding.ts'; +import type { BoundTouchExecutor } from '../../../core/touch-runtime.ts'; +import type { BoundSnapshotCapture } from '../../../core/snapshot-runtime-binding.ts'; import { noActiveSessionError } from '@agent-device/kernel/contracts'; /** diff --git a/src/daemon/interaction/internal/interaction-touch-targets.ts b/packages/daemon/src/execution/interaction/internal/interaction-touch-targets.ts similarity index 99% rename from src/daemon/interaction/internal/interaction-touch-targets.ts rename to packages/daemon/src/execution/interaction/internal/interaction-touch-targets.ts index 922da79a98..100dee27a2 100644 --- a/src/daemon/interaction/internal/interaction-touch-targets.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction-touch-targets.ts @@ -9,7 +9,7 @@ import { stripAtPrefix, type DecodedFillTarget, } from '@agent-device/selectors/interaction-positionals'; -import type { DaemonResponse } from '../../daemon-request.ts'; +import type { DaemonResponse } from '../../../core/daemon-request.ts'; import { parseCoordinateTarget } from './interaction-targeting.ts'; import { parseVersionedRefPositional } from '../../ref-positionals.ts'; import { errorResponse } from '@agent-device/kernel/contracts'; diff --git a/src/daemon/interaction/internal/interaction.ts b/packages/daemon/src/execution/interaction/internal/interaction.ts similarity index 94% rename from src/daemon/interaction/internal/interaction.ts rename to packages/daemon/src/execution/interaction/internal/interaction.ts index 34bdb679c7..35593f4039 100644 --- a/src/daemon/interaction/internal/interaction.ts +++ b/packages/daemon/src/execution/interaction/internal/interaction.ts @@ -1,13 +1,19 @@ -import type { DaemonResponse } from '../../daemon-request.ts'; -import type { SessionRef, SessionState } from '../../session-state.ts'; -import { type RequestCaptureProof, withCaptureDisclosures } from '../../capture-disclosure.ts'; -import type { CaptureSnapshotForSession, InteractionRouteInput } from './types.ts'; +import type { DaemonResponse } from '../../../core/daemon-request.ts'; +import type { SessionRef, SessionState } from '../../../core/session-state.ts'; +import { + type RequestCaptureProof, + withCaptureDisclosures, +} from '../../../core/capture-disclosure.ts'; +import type { + CaptureSnapshotForSession, + InteractionRouteInput, +} from '../../../core/interaction/internal/types.ts'; import { dispatchFillViaRuntime } from './interaction-touch-fill.ts'; import { dispatchTargetedTouchViaRuntime } from './interaction-touch-press.ts'; import { finalizeTouchInteraction } from './interaction-runtime.ts'; import { refSnapshotFlagGuardResponse } from '../../ref-snapshot-flag-policy.ts'; import { dispatchGetViaRuntime, dispatchIsViaRuntime } from '../../selector-runtime.ts'; -import { expireRefFrame } from '../../ref-frame.ts'; +import { expireRefFrame } from '../../../core/ref-frame.ts'; import { PUBLIC_COMMANDS } from '@agent-device/command-registry/catalog'; import { normalizeError } from '@agent-device/kernel/errors'; import { diff --git a/src/daemon/internal-observation.ts b/packages/daemon/src/execution/internal-observation.ts similarity index 95% rename from src/daemon/internal-observation.ts rename to packages/daemon/src/execution/internal-observation.ts index ad1e4bff5b..7b9659c4dd 100644 --- a/src/daemon/internal-observation.ts +++ b/packages/daemon/src/execution/internal-observation.ts @@ -6,11 +6,11 @@ import type { ReplayRefPublicationProjection, ReplayRefPublicationResult, } from '@agent-device/contracts/replay'; -import { readSessionRuntimeRevision, refFrame } from './ref-frame.ts'; -import type { RefFrame } from './ref-frame-slot.ts'; +import { readSessionRuntimeRevision, refFrame } from '../core/ref-frame.ts'; +import type { RefFrame } from '../core/ref-frame-slot.ts'; import { markSessionPartialRefsIssued, setSessionSnapshot } from './session-snapshot.ts'; -import type { SessionRef, SessionState } from './session-state.ts'; -import type { SessionStore } from './session-store.ts'; +import type { SessionRef, SessionState } from '../core/session-state.ts'; +import type { SessionStore } from '../core/session-store.ts'; type InternalObservationLineage = Readonly<{ ref: SessionRef; diff --git a/src/daemon/keyboard-runtime.ts b/packages/daemon/src/execution/keyboard-runtime.ts similarity index 98% rename from src/daemon/keyboard-runtime.ts rename to packages/daemon/src/execution/keyboard-runtime.ts index 5330e5c184..71e394afc5 100644 --- a/src/daemon/keyboard-runtime.ts +++ b/packages/daemon/src/execution/keyboard-runtime.ts @@ -22,13 +22,13 @@ import { type KeyboardAction, } from '@agent-device/session-journal/keyboard-actions'; import { successText } from '@agent-device/kernel/success-text'; -import type { DaemonCommandContext } from './context.ts'; +import type { DaemonCommandContext } from '../core/context.ts'; import { admitRuntimeUse, type RuntimeAdmissionBindings, type RuntimeAdmissionRequest, -} from './runtime-admission.ts'; -import { runtimeExecutionFromContext } from './snapshot-runtime-capture-input.ts'; +} from '../core/runtime-admission.ts'; +import { runtimeExecutionFromContext } from '../core/snapshot-runtime-capture-input.ts'; import type { DaemonFailureResponse } from '@agent-device/kernel/contracts'; type KeyboardRuntimeAction = 'status' | 'dismiss' | 'enter'; diff --git a/src/daemon/offscreen-target-probe.ts b/packages/daemon/src/execution/offscreen-target-probe.ts similarity index 93% rename from src/daemon/offscreen-target-probe.ts rename to packages/daemon/src/execution/offscreen-target-probe.ts index ff253d7e98..b28e560b51 100644 --- a/src/daemon/offscreen-target-probe.ts +++ b/packages/daemon/src/execution/offscreen-target-probe.ts @@ -2,8 +2,8 @@ import type { Rect, SnapshotNode } from '@agent-device/kernel/snapshot'; import { isConfirmedOnScreenProbe } from '@agent-device/capture-kit/mobile-snapshot-semantics'; import type { QuerySelectorRuntimeOperations } from '@agent-device/contracts/selector-observation-runtime'; import type { SnapshotRuntimeExecution } from '@agent-device/contracts/snapshot-runtime'; -import { deriveDirectIosNodeSelector } from './direct-ios-selector.ts'; -import type { SessionState } from './session-state.ts'; +import { deriveDirectIosNodeSelector } from '../core/direct-ios-selector.ts'; +import type { SessionState } from '../core/session-state.ts'; /** * The #1542 rescue read: one live `querySelector` on the caller's request-bound operation, diff --git a/src/daemon/orientation-runtime.ts b/packages/daemon/src/execution/orientation-runtime.ts similarity index 90% rename from src/daemon/orientation-runtime.ts rename to packages/daemon/src/execution/orientation-runtime.ts index 170d1fb87b..a57bb06ffd 100644 --- a/src/daemon/orientation-runtime.ts +++ b/packages/daemon/src/execution/orientation-runtime.ts @@ -4,10 +4,13 @@ import { orientationRuntimeUse } from '@agent-device/contracts/platform-runtime- import type { BoundDeviceRuntime } from '@agent-device/contracts/platform-runtime'; import type { DeviceInfo } from '@agent-device/kernel/device'; import { successText } from '@agent-device/kernel/success-text'; -import type { DaemonCommandContext } from './context.ts'; -import type { ResolvedGenericExecution } from './generic-leaf-execution.ts'; -import { resolveBoundGenericRuntime, type RuntimeAdmissionBindings } from './runtime-admission.ts'; -import { runtimeExecutionFromContext } from './snapshot-runtime-capture-input.ts'; +import type { DaemonCommandContext } from '../core/context.ts'; +import type { ResolvedGenericExecution } from '../core/generic-leaf-execution.ts'; +import { + resolveBoundGenericRuntime, + type RuntimeAdmissionBindings, +} from '../core/runtime-admission.ts'; +import { runtimeExecutionFromContext } from '../core/snapshot-runtime-capture-input.ts'; /** `orientation `, on the same parse the retired leaf used. */ export function readRequestedOrientation(positionals: readonly string[]): DeviceRotation { diff --git a/src/daemon/ref-positionals.ts b/packages/daemon/src/execution/ref-positionals.ts similarity index 94% rename from src/daemon/ref-positionals.ts rename to packages/daemon/src/execution/ref-positionals.ts index 1e0e629661..1a8689edc1 100644 --- a/src/daemon/ref-positionals.ts +++ b/packages/daemon/src/execution/ref-positionals.ts @@ -1,5 +1,5 @@ import { REF_GRAMMAR_HINT, splitRefGenerationSuffix } from '@agent-device/kernel/snapshot'; -import type { DaemonResponse } from './daemon-request.ts'; +import type { DaemonResponse } from '../core/daemon-request.ts'; import { errorResponse } from '@agent-device/kernel/contracts'; /** diff --git a/src/daemon/ref-snapshot-flag-policy.ts b/packages/daemon/src/execution/ref-snapshot-flag-policy.ts similarity index 92% rename from src/daemon/ref-snapshot-flag-policy.ts rename to packages/daemon/src/execution/ref-snapshot-flag-policy.ts index 2ae4232ba7..e112ded6c8 100644 --- a/src/daemon/ref-snapshot-flag-policy.ts +++ b/packages/daemon/src/execution/ref-snapshot-flag-policy.ts @@ -1,5 +1,5 @@ import type { CommandFlags } from '@agent-device/contracts/command'; -import type { DaemonResponse } from './daemon-request.ts'; +import type { DaemonResponse } from '../core/daemon-request.ts'; import { errorResponse } from '@agent-device/kernel/contracts'; const REF_UNSUPPORTED_FLAG_MAP: ReadonlyArray<[keyof CommandFlags, string]> = [ diff --git a/src/daemon/request-dispatch-disclosure.ts b/packages/daemon/src/execution/request-dispatch-disclosure.ts similarity index 94% rename from src/daemon/request-dispatch-disclosure.ts rename to packages/daemon/src/execution/request-dispatch-disclosure.ts index 8fef8ecaeb..35e331d587 100644 --- a/src/daemon/request-dispatch-disclosure.ts +++ b/packages/daemon/src/execution/request-dispatch-disclosure.ts @@ -6,8 +6,8 @@ import { type ErrorWireDetails, } from '@agent-device/kernel/errors'; import { resolveCommandRecordingEffect } from '@agent-device/command-registry/registry'; -import type { DaemonRequest, DaemonResponse } from './daemon-request.ts'; -import type { RequestDispatchLedger } from './request-dispatch-ledger.ts'; +import type { DaemonRequest, DaemonResponse } from '../core/daemon-request.ts'; +import type { RequestDispatchLedger } from '../core/request-dispatch-ledger.ts'; type RecordingEffect = ReturnType; diff --git a/src/daemon/request-generic-dispatch.ts b/packages/daemon/src/execution/request-generic-dispatch.ts similarity index 93% rename from src/daemon/request-generic-dispatch.ts rename to packages/daemon/src/execution/request-generic-dispatch.ts index 4c76de00e2..ebb1d5bbcf 100644 --- a/src/daemon/request-generic-dispatch.ts +++ b/packages/daemon/src/execution/request-generic-dispatch.ts @@ -1,32 +1,38 @@ import type { CommandFlags } from '@agent-device/contracts/command'; import type { SettleObservation } from '@agent-device/contracts/interaction'; import { commandSupportsSettleObservation } from '@agent-device/command-registry/registry'; -import type { SessionStore } from './session-store.ts'; -import type { DaemonCommandContext } from './context.ts'; -import type { DaemonRequest, DaemonResponse } from './daemon-request.ts'; -import type { SessionRef, SessionState } from './session-state.ts'; -import type { DaemonPlatformServices } from './platform-services.ts'; +import type { SessionStore } from '../core/session-store.ts'; +import type { DaemonCommandContext } from '../core/context.ts'; +import type { DaemonRequest, DaemonResponse } from '../core/daemon-request.ts'; +import type { SessionRef, SessionState } from '../core/session-state.ts'; +import type { DaemonPlatformServices } from '../core/platform-services.ts'; import { ensureAndroidBlockingSystemDialogReady, recoverAndroidBlockingSystemDialog, } from './android-system-dialog.ts'; -import { markDeferredInteractionOutcome } from './deferred-interaction-outcome.ts'; +import { markDeferredInteractionOutcome } from '../core/deferred-interaction-outcome.ts'; import { augmentScrollVisualizationResult, recordTouchVisualizationEvent, -} from './recording-gestures.ts'; +} from '../core/recording-gestures.ts'; import { normalizeError } from '@agent-device/kernel/errors'; -import { expireRefFrame } from './ref-frame.ts'; +import { expireRefFrame } from '../core/ref-frame.ts'; import { resolveRefFrameEffect, shouldGuardAndroidBlockingDialog, -} from './daemon-command-registry.ts'; -import { isActiveProviderDevice } from './provider-device-admission.ts'; +} from '../core/daemon-command-registry.ts'; +import { isActiveProviderDevice } from '../core/provider-device-admission.ts'; import { buildActionEventResult } from '@agent-device/session-journal/session-event-action-presentation'; import type { AndroidObservationAdapter } from '@agent-device/contracts/android-observation'; import type { CreateDaemonCommandSurface } from '@agent-device/contracts/daemon-command-surface'; -import type { GenericPlatformExecution, RecordedGenericRequest } from './generic-leaf-execution.ts'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from './request-runtime-binding.ts'; +import type { + GenericPlatformExecution, + RecordedGenericRequest, +} from '../core/generic-leaf-execution.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../core/request-runtime-binding.ts'; export async function dispatchGenericCommand(params: { req: DaemonRequest; diff --git a/src/daemon/runtime-artifacts.ts b/packages/daemon/src/execution/runtime-artifacts.ts similarity index 100% rename from src/daemon/runtime-artifacts.ts rename to packages/daemon/src/execution/runtime-artifacts.ts diff --git a/src/daemon/runtime-policy.ts b/packages/daemon/src/execution/runtime-policy.ts similarity index 100% rename from src/daemon/runtime-policy.ts rename to packages/daemon/src/execution/runtime-policy.ts diff --git a/src/daemon/screenshot-crop-target.ts b/packages/daemon/src/execution/screenshot-crop-target.ts similarity index 100% rename from src/daemon/screenshot-crop-target.ts rename to packages/daemon/src/execution/screenshot-crop-target.ts diff --git a/src/daemon/screenshot-crop.ts b/packages/daemon/src/execution/screenshot-crop.ts similarity index 94% rename from src/daemon/screenshot-crop.ts rename to packages/daemon/src/execution/screenshot-crop.ts index 60f1faf87a..964cfd0ec1 100644 --- a/src/daemon/screenshot-crop.ts +++ b/packages/daemon/src/execution/screenshot-crop.ts @@ -15,11 +15,11 @@ import { import { buildSnapshotState } from '@agent-device/capture-kit/snapshot-state'; import { SELECTOR_PIPELINE_POLICIES } from '@agent-device/selectors/selector-pipeline-policy'; import { resolveSelectorPipeline } from '@agent-device/selectors/selector-pipeline'; -import type { DaemonCommandContext } from './context.ts'; -import { captureSnapshotData } from './snapshot-capture.ts'; -import { runtimeExecutionFromContext } from './snapshot-runtime-capture-input.ts'; +import type { DaemonCommandContext } from '../core/context.ts'; +import { captureSnapshotData } from '../core/snapshot-capture.ts'; +import { runtimeExecutionFromContext } from '../core/snapshot-runtime-capture-input.ts'; import type { BoundScreenshotRuntime } from './screenshot-runtime-binding.ts'; -import type { SessionState } from './session-state.ts'; +import type { SessionState } from '../core/session-state.ts'; export type ScreenshotCropOutcome = Readonly<{ partialIntersection: boolean }>; diff --git a/src/daemon/screenshot-runtime-binding.ts b/packages/daemon/src/execution/screenshot-runtime-binding.ts similarity index 94% rename from src/daemon/screenshot-runtime-binding.ts rename to packages/daemon/src/execution/screenshot-runtime-binding.ts index a0c75f0969..c015562910 100644 --- a/src/daemon/screenshot-runtime-binding.ts +++ b/packages/daemon/src/execution/screenshot-runtime-binding.ts @@ -1,4 +1,4 @@ -import type { DaemonPlatformServices } from './platform-services.ts'; +import type { DaemonPlatformServices } from '../core/platform-services.ts'; import type { RuntimeOperationFact } from '@agent-device/contracts/platform-runtime'; import { type ScreenshotRuntimePlan, @@ -21,9 +21,12 @@ import { unavailableRuntimeOperationResponse, unwrapAdmittedRuntimePlan, type AdmittedRuntimePlan, -} from './session-runtime-admission.ts'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from './request-runtime-binding.ts'; -import type { DaemonResponse } from './daemon-request.ts'; +} from '../core/session-runtime-admission.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../core/request-runtime-binding.ts'; +import type { DaemonResponse } from '../core/daemon-request.ts'; import { errorResponse } from '@agent-device/kernel/contracts'; export type ScreenshotRuntimeBindings = Readonly<{ diff --git a/src/daemon/screenshot-runtime.ts b/packages/daemon/src/execution/screenshot-runtime.ts similarity index 96% rename from src/daemon/screenshot-runtime.ts rename to packages/daemon/src/execution/screenshot-runtime.ts index 500630360f..e28edb852f 100644 --- a/src/daemon/screenshot-runtime.ts +++ b/packages/daemon/src/execution/screenshot-runtime.ts @@ -21,12 +21,15 @@ import { assertSupportedScreenshotPixelDensity, readScreenshotResultMetadata, } from '@agent-device/capture-kit/screenshot-density'; -import { runtimeExecutionFromContext } from './snapshot-runtime-capture-input.ts'; -import type { DaemonCommandContext } from './context.ts'; -import { captureSnapshotData } from './snapshot-capture.ts'; +import { runtimeExecutionFromContext } from '../core/snapshot-runtime-capture-input.ts'; +import type { DaemonCommandContext } from '../core/context.ts'; +import { captureSnapshotData } from '../core/snapshot-capture.ts'; import { buildSnapshotState } from '@agent-device/capture-kit/snapshot-state'; -import type { RecordedGenericRequest, ResolvedGenericExecution } from './generic-leaf-execution.ts'; -import { createReadonlyRuntimeSessionStore } from './runtime-session.ts'; +import type { + RecordedGenericRequest, + ResolvedGenericExecution, +} from '../core/generic-leaf-execution.ts'; +import { createReadonlyRuntimeSessionStore } from '../core/runtime-session.ts'; import { assertScreenshotCropPolicy } from './screenshot-crop-target.ts'; import { buildScreenshotCropWarnings, cropScreenshotToSelector } from './screenshot-crop.ts'; import { annotateScreenshotWithRefs } from '@agent-device/capture-kit/screenshot-overlay'; @@ -36,8 +39,8 @@ import { type ScreenshotRuntimeBindings, } from './screenshot-runtime-binding.ts'; import { setSessionSnapshot } from './session-snapshot.ts'; -import type { DaemonRequest } from './daemon-request.ts'; -import type { SessionState } from './session-state.ts'; +import type { DaemonRequest } from '../core/daemon-request.ts'; +import type { SessionState } from '../core/session-state.ts'; /** * The `screenshot` leaf of the generic route. Argument policy is answered before any device work, diff --git a/src/daemon/scroll-movement.ts b/packages/daemon/src/execution/scroll-movement.ts similarity index 99% rename from src/daemon/scroll-movement.ts rename to packages/daemon/src/execution/scroll-movement.ts index a05c112964..f66ae5b209 100644 --- a/src/daemon/scroll-movement.ts +++ b/packages/daemon/src/execution/scroll-movement.ts @@ -29,10 +29,10 @@ import { summarizeDiscriminatingSurfaceDivergence, type InteractionSurfaceChange, type InteractionSurfaceSignature, -} from './interaction-surface-signature.ts'; -import { refFrameState } from './ref-frame.ts'; -import { isPostGestureStabilizationPending } from './deferred-interaction-outcome.ts'; -import type { SessionState } from './session-state.ts'; +} from '../core/interaction-surface-signature.ts'; +import { refFrameState } from '../core/ref-frame.ts'; +import { isPostGestureStabilizationPending } from '../core/deferred-interaction-outcome.ts'; +import type { SessionState } from '../core/session-state.ts'; /** * What one directional scroll saw after its gesture, and the only thing that can back the distance diff --git a/src/daemon/scroll-runtime.ts b/packages/daemon/src/execution/scroll-runtime.ts similarity index 97% rename from src/daemon/scroll-runtime.ts rename to packages/daemon/src/execution/scroll-runtime.ts index 40ea1212e7..2f7fd959ac 100644 --- a/src/daemon/scroll-runtime.ts +++ b/packages/daemon/src/execution/scroll-runtime.ts @@ -32,10 +32,13 @@ import { formatScrollUntilMessage, runScrollUntilVisible } from './scroll-until. import { publicPlatformString } from '@agent-device/kernel/device'; import type { CommandFlags } from '@agent-device/contracts/command'; import { withSuccessText } from '@agent-device/kernel/success-text'; -import type { DaemonCommandContext } from './context.ts'; -import type { SessionState } from './session-state.ts'; -import type { ResolvedGenericExecution } from './generic-leaf-execution.ts'; -import { resolveBoundGenericRuntime, type RuntimeAdmissionBindings } from './runtime-admission.ts'; +import type { DaemonCommandContext } from '../core/context.ts'; +import type { SessionState } from '../core/session-state.ts'; +import type { ResolvedGenericExecution } from '../core/generic-leaf-execution.ts'; +import { + resolveBoundGenericRuntime, + type RuntimeAdmissionBindings, +} from '../core/runtime-admission.ts'; import { observeScrollMovement, planScrollMovement, @@ -44,7 +47,7 @@ import { type ScrollMovementPlan, type ScrollSwipeEvidence, } from './scroll-movement.ts'; -import { runtimeExecutionFromContext } from './snapshot-runtime-capture-input.ts'; +import { runtimeExecutionFromContext } from '../core/snapshot-runtime-capture-input.ts'; import type { CaptureSnapshotInput } from '@agent-device/contracts/snapshot-runtime'; import { errorResponse } from '@agent-device/kernel/contracts'; diff --git a/src/daemon/scroll-until.test.ts b/packages/daemon/src/execution/scroll-until.test.ts similarity index 100% rename from src/daemon/scroll-until.test.ts rename to packages/daemon/src/execution/scroll-until.test.ts diff --git a/src/daemon/scroll-until.ts b/packages/daemon/src/execution/scroll-until.ts similarity index 100% rename from src/daemon/scroll-until.ts rename to packages/daemon/src/execution/scroll-until.ts diff --git a/src/daemon/selector-capture-binding.ts b/packages/daemon/src/execution/selector-capture-binding.ts similarity index 89% rename from src/daemon/selector-capture-binding.ts rename to packages/daemon/src/execution/selector-capture-binding.ts index aa721933d4..6b206eef25 100644 --- a/src/daemon/selector-capture-binding.ts +++ b/packages/daemon/src/execution/selector-capture-binding.ts @@ -1,4 +1,4 @@ -import type { DaemonPlatformServices } from './platform-services.ts'; +import type { DaemonPlatformServices } from '../core/platform-services.ts'; import type { ElementTextRuntimeOperations } from '@agent-device/contracts/element-text-runtime'; import { resolveSelectorCaptureRuntimePlan } from '@agent-device/contracts/platform-runtime-operations'; import type { FindTextRuntimeOperations } from '@agent-device/contracts/selector-observation-runtime'; @@ -6,10 +6,13 @@ import type { CaptureSnapshotInput, SnapshotResult, } from '@agent-device/contracts/snapshot-runtime'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from './request-runtime-binding.ts'; -import { admitAndBindSnapshotCapture } from './snapshot-runtime-binding.ts'; -import type { DaemonResponse } from './daemon-request.ts'; -import type { SessionState } from './session-state.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../core/request-runtime-binding.ts'; +import { admitAndBindSnapshotCapture } from '../core/snapshot-runtime-binding.ts'; +import type { DaemonResponse } from '../core/daemon-request.ts'; +import type { SessionState } from '../core/session-state.ts'; /** The selector commands that resolve their targets from the shared request-bound capture seam. */ export type SelectorCaptureCommand = 'find' | 'get' | 'is' | 'wait'; diff --git a/src/daemon/selector-capture-runtime.ts b/packages/daemon/src/execution/selector-capture-runtime.ts similarity index 93% rename from src/daemon/selector-capture-runtime.ts rename to packages/daemon/src/execution/selector-capture-runtime.ts index 26b95f3555..6baefa4782 100644 --- a/src/daemon/selector-capture-runtime.ts +++ b/packages/daemon/src/execution/selector-capture-runtime.ts @@ -7,18 +7,18 @@ import { type SnapshotState, } from '@agent-device/kernel/snapshot'; import { isSparseSnapshotQualityVerdict } from '@agent-device/capture-kit/snapshot-quality-verdict'; -import type { DaemonRequest } from './daemon-request.ts'; -import type { SessionRef, SessionState } from './session-state.ts'; -import { SessionStore } from './session-store.ts'; -import { recordCaptureProof } from './capture-disclosure.ts'; -import type { RequestCaptureProof } from './capture-disclosure.ts'; -import { captureSnapshot } from './snapshot-capture.ts'; +import type { DaemonRequest } from '../core/daemon-request.ts'; +import type { SessionRef, SessionState } from '../core/session-state.ts'; +import { SessionStore } from '../core/session-store.ts'; +import { recordCaptureProof } from '../core/capture-disclosure.ts'; +import type { RequestCaptureProof } from '../core/capture-disclosure.ts'; +import { captureSnapshot } from '../core/snapshot-capture.ts'; import { setSessionSnapshot } from './session-snapshot.ts'; -import { getActiveAndroidSnapshotFreshness } from './session-snapshot-freshness.ts'; -import { isPostGestureStabilizationPending } from './deferred-interaction-outcome.ts'; -import { isOutdatedObservation } from './ref-frame.ts'; +import { getActiveAndroidSnapshotFreshness } from '../core/session-snapshot-freshness.ts'; +import { isPostGestureStabilizationPending } from '../core/deferred-interaction-outcome.ts'; +import { isOutdatedObservation } from '../core/ref-frame.ts'; import type { BoundSelectorCapture } from './selector-capture-binding.ts'; -import { buildRuntimeCaptureInput } from './snapshot-runtime-capture-input.ts'; +import { buildRuntimeCaptureInput } from '../core/snapshot-runtime-capture-input.ts'; import { isLegacySparseIosInteractiveSnapshot } from '@agent-device/selectors/absence-observation'; const SELECTOR_CAPTURE_CACHE_TTL_MS = 750; diff --git a/src/daemon/selector-match-errors.ts b/packages/daemon/src/execution/selector-match-errors.ts similarity index 95% rename from src/daemon/selector-match-errors.ts rename to packages/daemon/src/execution/selector-match-errors.ts index 1cd32ca536..cbfa9b7c8a 100644 --- a/src/daemon/selector-match-errors.ts +++ b/packages/daemon/src/execution/selector-match-errors.ts @@ -1,7 +1,7 @@ import type { FindLocator } from '@agent-device/selectors'; import type { SnapshotState } from '@agent-device/kernel/snapshot'; import { elementMatchCandidateDetails } from '@agent-device/capture-kit/snapshot-lines'; -import type { DaemonResponse } from './daemon-request.ts'; +import type { DaemonResponse } from '../core/daemon-request.ts'; import { errorResponse } from '@agent-device/kernel/contracts'; // #1597: an agent reading an ambiguous-match error must be able to act on the diff --git a/src/daemon/selector-runtime-backend.ts b/packages/daemon/src/execution/selector-runtime-backend.ts similarity index 92% rename from src/daemon/selector-runtime-backend.ts rename to packages/daemon/src/execution/selector-runtime-backend.ts index 482d1bedf7..9679e98ff6 100644 --- a/src/daemon/selector-runtime-backend.ts +++ b/packages/daemon/src/execution/selector-runtime-backend.ts @@ -1,4 +1,4 @@ -import type { DaemonPlatformServices } from './platform-services.ts'; +import type { DaemonPlatformServices } from '../core/platform-services.ts'; import type { AgentDeviceBackend, BackendCommandContext, @@ -9,27 +9,30 @@ import type { CreateDaemonCommandSurface } from '@agent-device/contracts/daemon- import { publicPlatformString } from '@agent-device/kernel/device'; import type { SnapshotState, SnapshotNode } from '@agent-device/kernel/snapshot'; import { createDaemonRuntimePolicy } from './runtime-policy.ts'; -import { createDaemonRuntimeSessionStore } from './runtime-session.ts'; -import { contextFromFlags, type BoundContextFromFlags } from './context.ts'; +import { createDaemonRuntimeSessionStore } from '../core/runtime-session.ts'; +import { contextFromFlags, type BoundContextFromFlags } from '../core/context.ts'; import { readTextForNode } from './selector-text-runtime.ts'; import { setSessionSnapshot } from './session-snapshot.ts'; -import { markSessionSnapshotOutdated } from './ref-frame.ts'; -import { SessionStore } from './session-store.ts'; -import type { DaemonRequest, DaemonResponse } from './daemon-request.ts'; -import type { SessionRef, SessionState } from './session-state.ts'; +import { markSessionSnapshotOutdated } from '../core/ref-frame.ts'; +import { SessionStore } from '../core/session-store.ts'; +import type { DaemonRequest, DaemonResponse } from '../core/daemon-request.ts'; +import type { SessionRef, SessionState } from '../core/session-state.ts'; import { createSelectorCaptureRuntime } from './selector-capture-runtime.ts'; -import { buildRuntimeCaptureInput } from './snapshot-runtime-capture-input.ts'; +import { buildRuntimeCaptureInput } from '../core/snapshot-runtime-capture-input.ts'; import { resolveBoundSelectorCapture, type BoundSelectorOperations, type SelectorCaptureCommand, } from './selector-capture-binding.ts'; -import type { BindDeviceRuntime, InspectDeviceRuntimeFacts } from './request-runtime-binding.ts'; +import type { + BindDeviceRuntime, + InspectDeviceRuntimeFacts, +} from '../core/request-runtime-binding.ts'; import type { AndroidObservationAdapter } from '@agent-device/contracts/android-observation'; -import type { PlatformResourceCleanup } from './platform-resource-cleanup.ts'; +import type { PlatformResourceCleanup } from '../core/platform-resource-cleanup.ts'; import { getRequestSignal } from '@agent-device/host-kit/request'; import { snapshotOptionsToFlags } from '@agent-device/contracts/backend-snapshot-options'; -import type { RequestCaptureProof } from './capture-disclosure.ts'; +import type { RequestCaptureProof } from '../core/capture-disclosure.ts'; import { checkIsArgs } from '@agent-device/selectors'; import { noActiveSessionError } from '@agent-device/kernel/contracts'; diff --git a/src/daemon/selector-runtime.ts b/packages/daemon/src/execution/selector-runtime.ts similarity index 97% rename from src/daemon/selector-runtime.ts rename to packages/daemon/src/execution/selector-runtime.ts index 8f54705113..b011a40871 100644 --- a/src/daemon/selector-runtime.ts +++ b/packages/daemon/src/execution/selector-runtime.ts @@ -2,9 +2,9 @@ import { asAppError } from '@agent-device/kernel/errors'; import type { SnapshotNode, SnapshotState } from '@agent-device/kernel/snapshot'; import { absenceCaptureOptionError } from '@agent-device/selectors/absence-observation-errors'; import { absenceCaptureOptionRefusal } from '@agent-device/selectors/absence-observation'; -import type { DaemonRequest, DaemonResponse } from './daemon-request.ts'; -import type { SessionRef } from './session-state.ts'; -import type { SessionStore } from './session-store.ts'; +import type { DaemonRequest, DaemonResponse } from '../core/daemon-request.ts'; +import type { SessionRef } from '../core/session-state.ts'; +import type { SessionStore } from '../core/session-store.ts'; import { markSessionPartialRefsIssued, publishAmbiguousMatchCandidateRefs, @@ -31,9 +31,9 @@ import { stripSelectorChain, toDaemonFindData, toDaemonGetData, -} from './selector-recording.ts'; +} from '../core/selector-recording.ts'; import type { RecordedTargetCapture } from '@agent-device/selectors/target-evidence'; -import { withCaptureDisclosures } from './capture-disclosure.ts'; +import { withCaptureDisclosures } from '../core/capture-disclosure.ts'; import { createBoundSelectorRuntime, type SelectorRuntimeParams, diff --git a/src/daemon/selector-text-runtime.ts b/packages/daemon/src/execution/selector-text-runtime.ts similarity index 93% rename from src/daemon/selector-text-runtime.ts rename to packages/daemon/src/execution/selector-text-runtime.ts index 2881b3414e..db6ece8456 100644 --- a/src/daemon/selector-text-runtime.ts +++ b/packages/daemon/src/execution/selector-text-runtime.ts @@ -4,7 +4,7 @@ import type { ElementTextUnreadableReason, } from '@agent-device/contracts/element-text-runtime'; import { isIosFamily } from '@agent-device/kernel/device'; -import { runtimeExecutionFromContext } from './snapshot-runtime-capture-input.ts'; +import { runtimeExecutionFromContext } from '../core/snapshot-runtime-capture-input.ts'; import { emitDiagnostic } from '@agent-device/host-kit/diagnostics'; import type { SnapshotNode } from '@agent-device/kernel/snapshot'; import type { DeviceInfo } from '@agent-device/kernel/device'; @@ -13,7 +13,7 @@ import { extractReadableText, prefersValueForReadableText, } from '@agent-device/capture-kit/text-surface'; -import type { BoundContextFromFlags } from './context.ts'; +import type { BoundContextFromFlags } from '../core/context.ts'; import { resolveRectCenter } from '@agent-device/kernel/rect-center'; export type ReadElementTextAtPoint = ElementTextRuntimeOperations['readTextAtPoint']; diff --git a/src/daemon/session-snapshot.ts b/packages/daemon/src/execution/session-snapshot.ts similarity index 98% rename from src/daemon/session-snapshot.ts rename to packages/daemon/src/execution/session-snapshot.ts index 503d35c840..daf24c941d 100644 --- a/src/daemon/session-snapshot.ts +++ b/packages/daemon/src/execution/session-snapshot.ts @@ -2,9 +2,9 @@ import { randomInt } from 'node:crypto'; import type { SettleObservation } from '@agent-device/contracts/interaction'; import { readElementMatchCandidateRefs, AppError } from '@agent-device/kernel/errors'; import type { SnapshotState } from '@agent-device/kernel/snapshot'; -import { activatePartialRefFrame, refFrameEpoch, refFrameState } from './ref-frame.ts'; -import type { SessionRef, SessionState } from './session-state.ts'; -import type { SessionStore } from './session-store.ts'; +import { activatePartialRefFrame, refFrameEpoch, refFrameState } from '../core/ref-frame.ts'; +import type { SessionRef, SessionState } from '../core/session-state.ts'; +import type { SessionStore } from '../core/session-store.ts'; /** * Warning attached to a read of an `@ref` argument once the ref frame has @@ -22,7 +22,7 @@ export const STALE_SNAPSHOT_REFS_WARNING = * does NOT touch the ref frame: replacing the latest observation is an * operational read, so it never expires, reactivates, or reindexes the * authorized frame (ADR 0014). Frame lifetime is owned solely by - * `src/daemon/ref-frame.ts`; the partial-issuance writer below decides WHETHER to issue + * `packages/daemon/src/core/ref-frame.ts`; the partial-issuance writer below decides WHETHER to issue * and hands the transition there. */ export function setSessionSnapshot(session: SessionState, snapshot: SnapshotState): void { diff --git a/src/daemon/snapshot-timeout-evidence.test.ts b/packages/daemon/src/execution/snapshot-timeout-evidence.test.ts similarity index 100% rename from src/daemon/snapshot-timeout-evidence.test.ts rename to packages/daemon/src/execution/snapshot-timeout-evidence.test.ts diff --git a/src/daemon/snapshot-timeout-evidence.ts b/packages/daemon/src/execution/snapshot-timeout-evidence.ts similarity index 100% rename from src/daemon/snapshot-timeout-evidence.ts rename to packages/daemon/src/execution/snapshot-timeout-evidence.ts diff --git a/src/daemon/sparse-fallback-screenshot.ts b/packages/daemon/src/execution/sparse-fallback-screenshot.ts similarity index 95% rename from src/daemon/sparse-fallback-screenshot.ts rename to packages/daemon/src/execution/sparse-fallback-screenshot.ts index a57f53a6a5..5574857df2 100644 --- a/src/daemon/sparse-fallback-screenshot.ts +++ b/packages/daemon/src/execution/sparse-fallback-screenshot.ts @@ -2,14 +2,14 @@ import type { DeviceRotation } from '@agent-device/contracts/device'; import type { CreateDaemonCommandSurface } from '@agent-device/contracts/daemon-command-surface'; import type { SnapshotQualityVerdict } from '@agent-device/kernel/snapshot'; import { isSparseSnapshotQualityVerdict } from '@agent-device/capture-kit/snapshot-quality-verdict'; -import { contextFromFlags } from './context.ts'; +import { contextFromFlags } from '../core/context.ts'; import { captureScreenshotArtifact } from './screenshot-runtime.ts'; import { resolveBoundScreenshotRuntime, type ScreenshotRuntimeBindings, } from './screenshot-runtime-binding.ts'; -import type { DaemonRequest } from './daemon-request.ts'; -import type { SessionState } from './session-state.ts'; +import type { DaemonRequest } from '../core/daemon-request.ts'; +import type { SessionState } from '../core/session-state.ts'; export type SparseFallbackScreenshot = { path: string; diff --git a/src/daemon/system-button-runtime.ts b/packages/daemon/src/execution/system-button-runtime.ts similarity index 90% rename from src/daemon/system-button-runtime.ts rename to packages/daemon/src/execution/system-button-runtime.ts index aa01452482..c5be8300c0 100644 --- a/src/daemon/system-button-runtime.ts +++ b/packages/daemon/src/execution/system-button-runtime.ts @@ -11,10 +11,13 @@ import type { } from '@agent-device/contracts/system-button-runtime'; import type { DeviceInfo } from '@agent-device/kernel/device'; import { successText } from '@agent-device/kernel/success-text'; -import type { DaemonCommandContext } from './context.ts'; -import type { ResolvedGenericExecution } from './generic-leaf-execution.ts'; -import { resolveBoundGenericRuntime, type RuntimeAdmissionBindings } from './runtime-admission.ts'; -import { runtimeExecutionFromContext } from './snapshot-runtime-capture-input.ts'; +import type { DaemonCommandContext } from '../core/context.ts'; +import type { ResolvedGenericExecution } from '../core/generic-leaf-execution.ts'; +import { + resolveBoundGenericRuntime, + type RuntimeAdmissionBindings, +} from '../core/runtime-admission.ts'; +import { runtimeExecutionFromContext } from '../core/snapshot-runtime-capture-input.ts'; type SystemButtonUse = RuntimeUse< PlatformRuntimeOperations, diff --git a/src/daemon/tv-remote-runtime.ts b/packages/daemon/src/execution/tv-remote-runtime.ts similarity index 89% rename from src/daemon/tv-remote-runtime.ts rename to packages/daemon/src/execution/tv-remote-runtime.ts index b2263a5d2f..552370b6fc 100644 --- a/src/daemon/tv-remote-runtime.ts +++ b/packages/daemon/src/execution/tv-remote-runtime.ts @@ -6,10 +6,13 @@ import type { DeviceInfo } from '@agent-device/kernel/device'; import { AppError } from '@agent-device/kernel/errors'; import { successText } from '@agent-device/kernel/success-text'; import { requireIntInRange } from '@agent-device/kernel/validation'; -import type { DaemonCommandContext } from './context.ts'; -import type { ResolvedGenericExecution } from './generic-leaf-execution.ts'; -import { resolveBoundGenericRuntime, type RuntimeAdmissionBindings } from './runtime-admission.ts'; -import { runtimeExecutionFromContext } from './snapshot-runtime-capture-input.ts'; +import type { DaemonCommandContext } from '../core/context.ts'; +import type { ResolvedGenericExecution } from '../core/generic-leaf-execution.ts'; +import { + resolveBoundGenericRuntime, + type RuntimeAdmissionBindings, +} from '../core/runtime-admission.ts'; +import { runtimeExecutionFromContext } from '../core/snapshot-runtime-capture-input.ts'; /** `tv-remote