11import type { ExecutionPlan } from './execution-plan.ts' ;
2- import type { GestureExecutionProfile } from '@agent-device/contracts/gesture-plan-types' ;
32import type { PreresolvedInteractionTarget } from '@agent-device/contracts/interaction' ;
43import type { DeviceLease } from '@agent-device/contracts/device' ;
5- import type {
6- ReplayTargetGuardDenotation ,
7- TargetAnnotationV1 ,
8- } from '@agent-device/contracts/replay' ;
4+ import type { ReplayDispatchOptions } from '@agent-device/contracts/replay' ;
95import type {
106 DaemonArtifact as PublicDaemonArtifact ,
117 DaemonResponse as PublicDaemonResponse ,
128 DaemonResponseData as PublicDaemonResponseData ,
139} from '@agent-device/kernel/contracts' ;
14- import type { Rect } from '@agent-device/kernel/snapshot' ;
1510import type { DaemonWireRequest } from '@agent-device/contracts/command' ;
16- import type { SessionState } from './session-state.ts' ;
1711
1812/**
1913 * The daemon's own request and response vocabulary: the wire shape from `@agent-device/contracts/command` (`DaemonWireRequest`)
@@ -24,11 +18,12 @@ import type { SessionState } from './session-state.ts';
2418export type DaemonArtifact = PublicDaemonArtifact ;
2519export type DaemonResponseData = PublicDaemonResponseData ;
2620
27- export type DaemonOpenLifecycle = {
28- beforeDispatch ?: ( session : SessionState ) => Promise < DaemonResponse | undefined > ;
29- } ;
30-
31- type DaemonRequestInternal = {
21+ /**
22+ * What only the daemon may see on a request: the replay dispatch options (declared once in
23+ * `@agent-device/contracts/replay`, so the port and the daemon cannot drift), plus the callbacks,
24+ * plan and lease the daemon composes for itself.
25+ */
26+ type DaemonRequestInternal = ReplayDispatchOptions & {
3227 /**
3328 * What an `open` spent from its `--wait` budget while it waited for this device outside the
3429 * device execution lock. The refusal the open ends with has to say the budget was spent, and
@@ -37,7 +32,6 @@ type DaemonRequestInternal = {
3732 */
3833 openDeviceWait ?: { waitedMs : number } ;
3934 publicNetworkOnly ?: true ;
40- openLifecycle ?: DaemonOpenLifecycle ;
4135 /**
4236 * The steps a batch still has ahead of this one. The open seam derives platform readiness
4337 * policy (runner demand) from it; the transport strips `internal`, so it never arrives from a
@@ -51,50 +45,6 @@ type DaemonRequestInternal = {
5145 */
5246 retainDeviceExecutionLock ?: ( deviceId : string ) => Promise < void > ;
5347 admittedLease ?: DeviceLease ;
54- /**
55- * Daemon-composed hierarchy capture used as operational evidence only.
56- * It must not issue or replace client ref authority.
57- */
58- observationOnly ?: true ;
59- /**
60- * Implicit caller scope resolved before a nested dispatch replaces the
61- * public session name with its effective scoped key.
62- */
63- resolvedSessionScope ?: SessionState [ 'sessionScope' ] ;
64- /** Terminate the targeted app without ending the owning daemon session. */
65- closeAppOnly ?: boolean ;
66- /** Provider-owned viewport already resolved while normalizing a nested gesture command. */
67- gestureViewport ?: Rect ;
68- /** Maestro-compat execution profile for timed coordinate swipes projected to `gesture pan`. */
69- gestureExecutionProfile ?: GestureExecutionProfile ;
70- /**
71- * ADR 0012 step 4 post-resolution guard: the verified target member's
72- * normalized local identity AND structural denotation (document order +
73- * sibling ordinal), set ONLY by the replay step loop when dispatching an
74- * annotated action whose pre-action verification passed. Interaction
75- * handlers thread it into command options as `expectedResolvedTarget`;
76- * dispatch's own resolution refuses (pre-action) when its winner differs in
77- * local identity OR structural position — the latter distinguishes a
78- * different same-identity duplicate.
79- */
80- replayTargetGuard ?: ReplayTargetGuardDenotation ;
81- /** Dual-endpoint counterpart of replayTargetGuard for target-authored drag. */
82- replayTargetGuards ?: {
83- source : ReplayTargetGuardDenotation ;
84- destination : ReplayTargetGuardDenotation ;
85- } ;
86- /**
87- * ADR 0012 / #1349 deferred (post-resolution) identity verification: the
88- * recorded `target-v1` landmark of an annotated selector `wait`, set ONLY
89- * by the replay step loop. The wait dispatch threads it into the polling
90- * loop as `recordedLandmark`; success then requires a selector match
91- * carrying this identity, and a timeout with rejected candidates surfaces
92- * the `WAIT_LANDMARK_MISMATCH_REASON` refusal the step loop converts into
93- * an identity-mismatch divergence. Never used by the generic pre-dispatch
94- * verification path — a wait's landmark may legitimately be absent when
95- * the step starts.
96- */
97- replayLandmarkGuard ?: TargetAnnotationV1 ;
9848 /**
9949 * ADR 0014 / #1654: the complete ref/node/tree target a mutating `find`
10050 * resolved against its fresh capture. Its presence both marks the ref as
@@ -104,32 +54,11 @@ type DaemonRequestInternal = {
10454 * side-effect seam and expires the frame.
10555 */
10656 findResolvedTarget ?: PreresolvedInteractionTarget ;
107- /**
108- * #1271 stage 2 (ADR 0012 decision 6 amendment): PROVENANCE — set by the
109- * replay runtime (`invokeResolvedReplayAction`,
110- * `session-replay-action-runtime.ts`) on every action it dispatches from a
111- * replay plan, annotated or not. It marks the action as AUTHORED (it came
112- * from the `.ad` under repair) rather than typed out-of-band by the agent
113- * mid-repair.
114- *
115- * The repair-segment exclusion keys off its ABSENCE: an authored
116- * `get`/`is`/`find`/`snapshot` step must survive into its own healed script
117- * (silently dropping it would make the heal quietly stop asserting what the
118- * original flow asserted), while an interactive diagnostic read used only to
119- * LOCATE the repair target must not. Command class alone cannot tell those
120- * apart — they are the same command — so provenance is the discriminator and
121- * `--record` is only for deliberately inserting an interactive read.
122- *
123- * Trustworthy because `internal` is daemon-only: `toDaemonRequest`
124- * (`server/http-server.ts`) never copies it off the wire, so no client can
125- * spoof authored provenance. Same channel as `replayTargetGuard` above.
126- */
127- replayPlanStep ?: boolean ;
12857} ;
12958
13059/**
13160 * The server-side request: `DaemonWireRequest` plus what only the daemon may see. `internal`
132- * carries `SessionState` callbacks and the admitted lease — which is why this type stays in the
61+ * carries the admitted lease, the execution plan and request-owned callbacks — which is why this type stays in the
13362 * daemon and why the wire half is declared separately. Zones below it that only need to classify
13463 * a command take `contracts/dispatched-command.ts` instead.
13564 */
0 commit comments