From 9847e0702e070c61be72a46b5d58b386b31f1614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 16 Nov 2026 23:59:44 +0100 Subject: [PATCH] refactor(wait): type the wait command target with the contracts DaemonWaitTarget The command-runtime WaitCommandOptions.target repeated the daemon surface union (fallow dup:52af5926). Reuse the contracts owner and keep the fuller replay-landmark doc there. Co-Authored-By: Claude Opus 5.5 --- .../interaction/runtime/selector-wait.ts | 22 ++----------------- .../contracts/src/daemon-command-surface.ts | 7 +++++- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/packages/command-runtime/src/commands/interaction/runtime/selector-wait.ts b/packages/command-runtime/src/commands/interaction/runtime/selector-wait.ts index 2c7d4de739..ac0eb8dec3 100644 --- a/packages/command-runtime/src/commands/interaction/runtime/selector-wait.ts +++ b/packages/command-runtime/src/commands/interaction/runtime/selector-wait.ts @@ -1,6 +1,6 @@ import { AppError } from '@agent-device/kernel/errors'; import { findNodeByRef, normalizeRef, type SnapshotNode } from '@agent-device/kernel/snapshot'; -import type { TargetAnnotationV1 } from '@agent-device/contracts/replay'; +import type { DaemonWaitTarget } from '@agent-device/contracts/daemon-command-surface'; import type { PublicPlatform } from '@agent-device/kernel/device'; import type { CapturedSnapshot } from './selector-read-shared.ts'; import { checkWaitText, STALE_REF_HINT } from '@agent-device/selectors'; @@ -27,25 +27,7 @@ export type SelectorSnapshotOptions = { export type WaitCommandOptions = WaitCommandContext & SelectorSnapshotOptions & { - target: - | { kind: 'sleep'; durationMs: number } - | { kind: 'text'; text: string; timeoutMs?: number | null } - | { kind: 'ref'; ref: string; timeoutMs?: number | null } - | { - kind: 'selector'; - selector: string; - timeoutMs?: number | null; - /** - * ADR 0012 / #1349, replay-only: the recorded landmark identity this - * wait must observe before reporting success. Polling is unchanged — - * the loop keeps waiting while no selector match carries this - * identity, and a timeout with rejected candidates throws the - * `WAIT_LANDMARK_MISMATCH_REASON` refusal instead of success. - */ - recordedLandmark?: TargetAnnotationV1; - } - | { kind: 'absent'; selector: string; timeoutMs?: number | null } - | { kind: 'stable'; quietMs?: number | null; timeoutMs?: number | null }; + target: DaemonWaitTarget; }; export type WaitCommandResult = diff --git a/packages/contracts/src/daemon-command-surface.ts b/packages/contracts/src/daemon-command-surface.ts index 85e86560bc..69675ba6bd 100644 --- a/packages/contracts/src/daemon-command-surface.ts +++ b/packages/contracts/src/daemon-command-surface.ts @@ -170,7 +170,12 @@ export type DaemonWaitTarget = kind: 'selector'; selector: string; timeoutMs?: number | null; - /** ADR 0012 / #1349: the recorded landmark identity a replayed wait must observe. */ + /** + * ADR 0012 / #1349, replay-only: the recorded landmark identity this wait must observe before + * reporting success. Polling is unchanged: the loop keeps waiting while no selector match + * carries this identity, and a timeout with rejected candidates throws the + * `WAIT_LANDMARK_MISMATCH_REASON` refusal instead of success. + */ recordedLandmark?: TargetAnnotationV1; } | { kind: 'absent'; selector: string; timeoutMs?: number | null }