@lumenflow/cli 5.5.0 → 5.7.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/README.md +42 -40
  2. package/dist/db-journal-recover.js +400 -0
  3. package/dist/db-journal-recover.js.map +1 -0
  4. package/dist/docs-sync.js +8 -3
  5. package/dist/docs-sync.js.map +1 -1
  6. package/dist/gate-defaults.js +37 -0
  7. package/dist/gate-defaults.js.map +1 -1
  8. package/dist/gates/monolithic-file-contention-guard.js +167 -0
  9. package/dist/gates/monolithic-file-contention-guard.js.map +1 -0
  10. package/dist/gates/prod-migration-drift.js +207 -0
  11. package/dist/gates/prod-migration-drift.js.map +1 -0
  12. package/dist/gates/test-over-deletion-guard.js +255 -0
  13. package/dist/gates/test-over-deletion-guard.js.map +1 -0
  14. package/dist/gates-runners.js +44 -3
  15. package/dist/gates-runners.js.map +1 -1
  16. package/dist/gates.js +3 -2
  17. package/dist/gates.js.map +1 -1
  18. package/dist/lumenflow-setup.js +144 -0
  19. package/dist/lumenflow-setup.js.map +1 -0
  20. package/dist/lumenflow-upgrade.js +2 -1
  21. package/dist/lumenflow-upgrade.js.map +1 -1
  22. package/dist/mem-create.js +10 -1
  23. package/dist/mem-create.js.map +1 -1
  24. package/dist/mem-signal.js +21 -4
  25. package/dist/mem-signal.js.map +1 -1
  26. package/dist/orchestrate-initiative.js +28 -3
  27. package/dist/orchestrate-initiative.js.map +1 -1
  28. package/dist/public-manifest.js +17 -0
  29. package/dist/public-manifest.js.map +1 -1
  30. package/dist/release.js +53 -18
  31. package/dist/release.js.map +1 -1
  32. package/dist/wu-done-gates.js +13 -9
  33. package/dist/wu-done-gates.js.map +1 -1
  34. package/dist/wu-edit-operations.js +74 -0
  35. package/dist/wu-edit-operations.js.map +1 -1
  36. package/dist/wu-edit-validators.js +58 -0
  37. package/dist/wu-edit-validators.js.map +1 -1
  38. package/dist/wu-edit.js +106 -4
  39. package/dist/wu-edit.js.map +1 -1
  40. package/dist/wu-prep.js +41 -7
  41. package/dist/wu-prep.js.map +1 -1
  42. package/dist/wu-recover.js +6 -0
  43. package/dist/wu-recover.js.map +1 -1
  44. package/dist/wu-release.js +120 -2
  45. package/dist/wu-release.js.map +1 -1
  46. package/dist/wu-sizing-validation.js +47 -17
  47. package/dist/wu-sizing-validation.js.map +1 -1
  48. package/dist/wu-status.js +33 -0
  49. package/dist/wu-status.js.map +1 -1
  50. package/package.json +13 -11
  51. package/packs/agent-runtime/package.json +1 -1
  52. package/packs/sidekick/package.json +1 -1
  53. package/packs/software-delivery/package.json +1 -1
  54. package/templates/core/AGENTS.md.template +67 -3
  55. package/templates/core/LUMENFLOW.md.template +197 -47
  56. package/packs/agent-runtime/agent-heartbeat.ts +0 -163
  57. package/packs/agent-runtime/auto-session-integration.ts +0 -888
  58. package/packs/agent-runtime/capability-factory.ts +0 -104
  59. package/packs/agent-runtime/constants.ts +0 -21
  60. package/packs/agent-runtime/delegation-registry-schema.ts +0 -220
  61. package/packs/agent-runtime/delegation-registry-store.ts +0 -269
  62. package/packs/agent-runtime/delegation-tree.ts +0 -328
  63. package/packs/agent-runtime/index.ts +0 -20
  64. package/packs/agent-runtime/manifest.ts +0 -348
  65. package/packs/agent-runtime/memory-coordination-contract.ts +0 -86
  66. package/packs/agent-runtime/orchestration.ts +0 -2027
  67. package/packs/agent-runtime/pack-registration.ts +0 -110
  68. package/packs/agent-runtime/policy-factory.ts +0 -165
  69. package/packs/agent-runtime/remote-controls/index.ts +0 -7
  70. package/packs/agent-runtime/remote-controls/operations.ts +0 -405
  71. package/packs/agent-runtime/remote-controls/port.ts +0 -48
  72. package/packs/agent-runtime/remote-controls/state-store.ts +0 -258
  73. package/packs/agent-runtime/remote-controls/types.ts +0 -105
  74. package/packs/agent-runtime/session-schema.ts +0 -467
  75. package/packs/agent-runtime/tool-impl/agent-turn-tools.ts +0 -793
  76. package/packs/agent-runtime/tool-impl/index.ts +0 -6
  77. package/packs/agent-runtime/tool-impl/provider-adapters.ts +0 -1245
  78. package/packs/agent-runtime/tool-impl/remote-controls.mock.ts +0 -256
  79. package/packs/agent-runtime/tool-impl/remote-controls.ts +0 -273
  80. package/packs/agent-runtime/tools/index.ts +0 -4
  81. package/packs/agent-runtime/tools/types.ts +0 -47
  82. package/packs/agent-runtime/turn-lifecycle-events.ts +0 -590
  83. package/packs/agent-runtime/types.ts +0 -128
  84. package/packs/agent-runtime/vitest.config.ts +0 -11
  85. package/packs/sidekick/channel-ingress.ts +0 -137
  86. package/packs/sidekick/constants.ts +0 -10
  87. package/packs/sidekick/index.ts +0 -8
  88. package/packs/sidekick/manifest-schema.ts +0 -49
  89. package/packs/sidekick/manifest.ts +0 -512
  90. package/packs/sidekick/pack-registration.ts +0 -110
  91. package/packs/sidekick/policy-factory.ts +0 -38
  92. package/packs/sidekick/sidekick-events.ts +0 -694
  93. package/packs/sidekick/src/adapters/cloud-queue.ts +0 -101
  94. package/packs/sidekick/src/adapters/control-plane-bridge.adapter.ts +0 -386
  95. package/packs/sidekick/src/adapters/filesystem-bridge.adapter.ts +0 -228
  96. package/packs/sidekick/src/domain/channel.types.ts +0 -64
  97. package/packs/sidekick/src/ports/channel-bridge.port.ts +0 -92
  98. package/packs/sidekick/src/routines/commit.ts +0 -74
  99. package/packs/sidekick/tool-impl/channel-tools.ts +0 -577
  100. package/packs/sidekick/tool-impl/channel-transports.ts +0 -75
  101. package/packs/sidekick/tool-impl/index.ts +0 -29
  102. package/packs/sidekick/tool-impl/memory-tools.ts +0 -290
  103. package/packs/sidekick/tool-impl/routine-commit.ts +0 -102
  104. package/packs/sidekick/tool-impl/routine-tools.ts +0 -440
  105. package/packs/sidekick/tool-impl/runtime-context.ts +0 -28
  106. package/packs/sidekick/tool-impl/shared.ts +0 -125
  107. package/packs/sidekick/tool-impl/storage.ts +0 -325
  108. package/packs/sidekick/tool-impl/system-tools.ts +0 -160
  109. package/packs/sidekick/tool-impl/task-tools.ts +0 -506
  110. package/packs/sidekick/tools/channel-tools.ts +0 -53
  111. package/packs/sidekick/tools/index.ts +0 -9
  112. package/packs/sidekick/tools/memory-tools.ts +0 -53
  113. package/packs/sidekick/tools/routine-tools.ts +0 -53
  114. package/packs/sidekick/tools/system-tools.ts +0 -47
  115. package/packs/sidekick/tools/task-tools.ts +0 -61
  116. package/packs/sidekick/tools/types.ts +0 -57
  117. package/packs/sidekick/vitest.config.ts +0 -11
  118. package/packs/software-delivery/constants.ts +0 -10
  119. package/packs/software-delivery/extensions.ts +0 -140
  120. package/packs/software-delivery/gate-policies.ts +0 -134
  121. package/packs/software-delivery/index.ts +0 -8
  122. package/packs/software-delivery/manifest-schema.ts +0 -268
  123. package/packs/software-delivery/manifest.ts +0 -657
  124. package/packs/software-delivery/pack-registration.ts +0 -113
  125. package/packs/software-delivery/src/commands/index.ts +0 -5
  126. package/packs/software-delivery/src/config/delivery-review-contract.ts +0 -256
  127. package/packs/software-delivery/src/config/env-accessors.ts +0 -66
  128. package/packs/software-delivery/src/config/index.ts +0 -8
  129. package/packs/software-delivery/src/config/normalize-config-keys.ts +0 -9
  130. package/packs/software-delivery/src/config/schemas/lumenflow-config-schema-types.ts +0 -460
  131. package/packs/software-delivery/src/config/workspace-reader.ts +0 -375
  132. package/packs/software-delivery/src/constants/backlog-patterns.ts +0 -31
  133. package/packs/software-delivery/src/constants/client-ids.ts +0 -19
  134. package/packs/software-delivery/src/constants/config-contract.ts +0 -7
  135. package/packs/software-delivery/src/constants/docs-layout-presets.ts +0 -50
  136. package/packs/software-delivery/src/constants/duration-constants.ts +0 -20
  137. package/packs/software-delivery/src/constants/gate-constants.ts +0 -32
  138. package/packs/software-delivery/src/constants/index.ts +0 -29
  139. package/packs/software-delivery/src/constants/lock-constants.ts +0 -35
  140. package/packs/software-delivery/src/constants/object-guards.ts +0 -12
  141. package/packs/software-delivery/src/constants/section-headings.ts +0 -107
  142. package/packs/software-delivery/src/constants/wu-cli-constants.ts +0 -500
  143. package/packs/software-delivery/src/constants/wu-domain-constants.ts +0 -466
  144. package/packs/software-delivery/src/constants/wu-git-constants.ts +0 -7
  145. package/packs/software-delivery/src/constants/wu-id-format.ts +0 -327
  146. package/packs/software-delivery/src/constants/wu-paths-constants.ts +0 -384
  147. package/packs/software-delivery/src/constants/wu-statuses.ts +0 -287
  148. package/packs/software-delivery/src/constants/wu-type-helpers.ts +0 -67
  149. package/packs/software-delivery/src/constants/wu-ui-constants.ts +0 -267
  150. package/packs/software-delivery/src/constants/wu-validation-constants.ts +0 -73
  151. package/packs/software-delivery/src/domain/index.ts +0 -5
  152. package/packs/software-delivery/src/domain/orchestration.constants.ts +0 -166
  153. package/packs/software-delivery/src/domain/orchestration.schemas.ts +0 -238
  154. package/packs/software-delivery/src/domain/orchestration.types.ts +0 -176
  155. package/packs/software-delivery/src/methodology/incremental-test.ts +0 -122
  156. package/packs/software-delivery/src/methodology/index.ts +0 -6
  157. package/packs/software-delivery/src/methodology/manual-test-validator.ts +0 -292
  158. package/packs/software-delivery/src/policy/coverage-gate.ts +0 -270
  159. package/packs/software-delivery/src/policy/gates-agent-mode.ts +0 -223
  160. package/packs/software-delivery/src/policy/gates-config-internal.ts +0 -121
  161. package/packs/software-delivery/src/policy/gates-config.ts +0 -300
  162. package/packs/software-delivery/src/policy/gates-coverage.ts +0 -356
  163. package/packs/software-delivery/src/policy/gates-presets.ts +0 -134
  164. package/packs/software-delivery/src/policy/gates-schemas.ts +0 -173
  165. package/packs/software-delivery/src/policy/index.ts +0 -22
  166. package/packs/software-delivery/src/policy/package-manager-resolver.ts +0 -319
  167. package/packs/software-delivery/src/policy/resolve-policy.ts +0 -601
  168. package/packs/software-delivery/src/ports/config.ports.ts +0 -90
  169. package/packs/software-delivery/src/ports/dashboard-renderer.port.ts +0 -125
  170. package/packs/software-delivery/src/ports/index.ts +0 -10
  171. package/packs/software-delivery/src/ports/sync-validator.ports.ts +0 -59
  172. package/packs/software-delivery/src/ports/wu-helpers.ports.ts +0 -168
  173. package/packs/software-delivery/src/ports/wu-state.ports.ts +0 -241
  174. package/packs/software-delivery/src/primitives/index.ts +0 -5
  175. package/packs/software-delivery/src/runtime/index.ts +0 -6
  176. package/packs/software-delivery/src/runtime/work-classifier.ts +0 -561
  177. package/packs/software-delivery/src/sandbox/index.ts +0 -10
  178. package/packs/software-delivery/src/sandbox/sandbox-allowlist.ts +0 -118
  179. package/packs/software-delivery/src/sandbox/sandbox-backend-linux.ts +0 -88
  180. package/packs/software-delivery/src/sandbox/sandbox-backend-macos.ts +0 -154
  181. package/packs/software-delivery/src/sandbox/sandbox-backend-windows.ts +0 -47
  182. package/packs/software-delivery/src/sandbox/sandbox-profile.ts +0 -153
  183. package/packs/software-delivery/src/schemas/index.ts +0 -5
  184. package/packs/software-delivery/src/state/date-utils.ts +0 -158
  185. package/packs/software-delivery/src/state/index.ts +0 -15
  186. package/packs/software-delivery/src/state/state-machine.ts +0 -119
  187. package/packs/software-delivery/src/state/wu-doc-types.ts +0 -51
  188. package/packs/software-delivery/src/state/wu-paths.ts +0 -381
  189. package/packs/software-delivery/src/state/wu-schema.ts +0 -1139
  190. package/packs/software-delivery/src/state/wu-state-schema.ts +0 -255
  191. package/packs/software-delivery/src/state/wu-yaml.ts +0 -338
  192. package/packs/software-delivery/tool-impl/agent-tools.ts +0 -263
  193. package/packs/software-delivery/tool-impl/delegation-tools.ts +0 -66
  194. package/packs/software-delivery/tool-impl/flow-metrics-tools.ts +0 -219
  195. package/packs/software-delivery/tool-impl/git-runner.ts +0 -113
  196. package/packs/software-delivery/tool-impl/git-tools.ts +0 -316
  197. package/packs/software-delivery/tool-impl/index.ts +0 -15
  198. package/packs/software-delivery/tool-impl/initiative-orchestration-tools.ts +0 -720
  199. package/packs/software-delivery/tool-impl/lane-lock.ts +0 -246
  200. package/packs/software-delivery/tool-impl/memory-tools.ts +0 -470
  201. package/packs/software-delivery/tool-impl/pending-runtime-tools.ts +0 -21
  202. package/packs/software-delivery/tool-impl/runtime-cli-adapter.ts +0 -329
  203. package/packs/software-delivery/tool-impl/runtime-native-tools.ts +0 -687
  204. package/packs/software-delivery/tool-impl/worker-loader.ts +0 -52
  205. package/packs/software-delivery/tool-impl/worktree-tools.ts +0 -46
  206. package/packs/software-delivery/tool-impl/wu-lifecycle-tools.ts +0 -807
  207. package/packs/software-delivery/tools/delegation-tools.ts +0 -23
  208. package/packs/software-delivery/tools/git-tools.ts +0 -55
  209. package/packs/software-delivery/tools/index.ts +0 -8
  210. package/packs/software-delivery/tools/lane-lock-tool.ts +0 -37
  211. package/packs/software-delivery/tools/types.ts +0 -71
  212. package/packs/software-delivery/tools/worktree-tools.ts +0 -49
  213. package/packs/software-delivery/vitest.config.ts +0 -11
@@ -1,48 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
- //
4
- // WU-2732 (INIT-060 Phase 3, ADR-013 §6 governance surface):
5
- // Port interface for the six remote-control tools. Both the mock
6
- // tracer-bullet adapter (this WU) and the real kernel-side adapter
7
- // (WU-2733) implement this port — so the real impl lands without
8
- // changing the wire contract. This mirrors ADR-013's ChannelBridge
9
- // port pattern (single port, multiple adapters).
10
-
11
- import type { AbortTurnInvocationResult, RemoteControlInvocationResult } from './types.js';
12
-
13
- /**
14
- * Minimum input shape every remote-control tool accepts. The session
15
- * identifier is the load-bearing field: it pins which agent-runtime
16
- * session the command targets. Real impls in WU-2733 will extend this
17
- * with per-tool specific fields (e.g. autonomy level for elevate);
18
- * extensions MUST be additive to preserve the wire contract.
19
- */
20
- export interface RemoteControlInvocationInput {
21
- session_id?: string;
22
- }
23
-
24
- export interface AbortTurnInvocationInput extends RemoteControlInvocationInput {
25
- /**
26
- * Operator-supplied reason surfaced in the emitted
27
- * `agent-runtime:turn_aborted` event in the real impl. The mock
28
- * tracer-bullet records this for round-trip verification but does
29
- * not emit the event (WU-2733 wires the real emission per
30
- * ADR-013 §1 abort table).
31
- */
32
- reason?: string;
33
- }
34
-
35
- /**
36
- * Remote-control port. The six methods correspond 1:1 to the six
37
- * manifest-declared tool names. Keeping them as separate methods (not
38
- * a single `invoke(name, input)` dispatcher) lets TypeScript enforce
39
- * per-tool input/output types at the call site.
40
- */
41
- export interface RemoteControlPort {
42
- resumeWorkflow(input: RemoteControlInvocationInput): Promise<RemoteControlInvocationResult>;
43
- pauseTurn(input: RemoteControlInvocationInput): Promise<RemoteControlInvocationResult>;
44
- abortTurn(input: AbortTurnInvocationInput): Promise<AbortTurnInvocationResult>;
45
- elevateAutonomy(input: RemoteControlInvocationInput): Promise<RemoteControlInvocationResult>;
46
- lowerAutonomy(input: RemoteControlInvocationInput): Promise<RemoteControlInvocationResult>;
47
- approveInflight(input: RemoteControlInvocationInput): Promise<RemoteControlInvocationResult>;
48
- }
@@ -1,258 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
- //
4
- // WU-2733 (INIT-060 Phase 3, ADR-013 §1 abort + §6 governance):
5
- // Sidecar persistence for remote-control session state (pause marker,
6
- // autonomy level, abort record, inflight approval handle). Kept
7
- // separate from the core orchestration workflow state store so the
8
- // existing strict schema validator doesn't need schema-version bumps
9
- // and so remote-control operations remain independently observable
10
- // via a dedicated on-disk artefact (`.agent-runtime/remote-controls/`).
11
-
12
- import { mkdir, readFile, writeFile } from 'node:fs/promises';
13
- import path from 'node:path';
14
-
15
- export const REMOTE_CONTROL_STATE_DIRECTORY = path.join('.agent-runtime', 'remote-controls');
16
-
17
- /** Canonical autonomy bands. Declaration order = low→high. */
18
- export const AGENT_RUNTIME_AUTONOMY_LEVELS = {
19
- MANUAL: 'manual',
20
- ASSISTED: 'assisted',
21
- AUTO: 'auto',
22
- } as const;
23
-
24
- export type AgentRuntimeAutonomyLevel =
25
- (typeof AGENT_RUNTIME_AUTONOMY_LEVELS)[keyof typeof AGENT_RUNTIME_AUTONOMY_LEVELS];
26
-
27
- export const AGENT_RUNTIME_AUTONOMY_LEVEL_VALUES = [
28
- AGENT_RUNTIME_AUTONOMY_LEVELS.MANUAL,
29
- AGENT_RUNTIME_AUTONOMY_LEVELS.ASSISTED,
30
- AGENT_RUNTIME_AUTONOMY_LEVELS.AUTO,
31
- ] as const satisfies readonly AgentRuntimeAutonomyLevel[];
32
-
33
- export const DEFAULT_AUTONOMY_LEVEL: AgentRuntimeAutonomyLevel =
34
- AGENT_RUNTIME_AUTONOMY_LEVELS.ASSISTED;
35
-
36
- export interface RemoteControlPauseState {
37
- paused: boolean;
38
- paused_at: string | null;
39
- resumed_at: string | null;
40
- reason: string | null;
41
- }
42
-
43
- export interface RemoteControlAbortState {
44
- aborted: boolean;
45
- aborted_at: string | null;
46
- cleanup_status: 'clean' | 'partial' | 'needs_recovery' | null;
47
- recovery_action: string | null;
48
- reason: string | null;
49
- }
50
-
51
- export interface RemoteControlInflightApproval {
52
- request_id: string;
53
- tool_name: string;
54
- requested_at: string;
55
- }
56
-
57
- export interface RemoteControlSessionState {
58
- schema_version: 1;
59
- session_id: string;
60
- autonomy_level: AgentRuntimeAutonomyLevel;
61
- pause: RemoteControlPauseState;
62
- abort: RemoteControlAbortState;
63
- inflight_approvals: RemoteControlInflightApproval[];
64
- updated_at: string;
65
- }
66
-
67
- const SCHEMA_VERSION_V1 = 1 as const;
68
-
69
- export interface RemoteControlStateStore {
70
- load(sessionId: string): Promise<RemoteControlSessionState | null>;
71
- save(state: RemoteControlSessionState): Promise<void>;
72
- loadOrDefault(sessionId: string, now: string): Promise<RemoteControlSessionState>;
73
- }
74
-
75
- export interface CreateRemoteControlStateStoreInput {
76
- workspaceRoot: string;
77
- }
78
-
79
- export function createRemoteControlStateStore(
80
- input: CreateRemoteControlStateStoreInput,
81
- ): RemoteControlStateStore {
82
- const stateRoot = path.join(input.workspaceRoot, REMOTE_CONTROL_STATE_DIRECTORY);
83
-
84
- async function load(sessionId: string): Promise<RemoteControlSessionState | null> {
85
- const filePath = sessionFile(stateRoot, sessionId);
86
- try {
87
- const raw = await readFile(filePath, 'utf8');
88
- return parseState(JSON.parse(raw), filePath);
89
- } catch (error) {
90
- const nodeError = error as NodeJS.ErrnoException;
91
- if (nodeError.code === 'ENOENT') {
92
- return null;
93
- }
94
- throw error;
95
- }
96
- }
97
-
98
- async function save(state: RemoteControlSessionState): Promise<void> {
99
- const filePath = sessionFile(stateRoot, state.session_id);
100
- await mkdir(stateRoot, { recursive: true });
101
- await writeFile(filePath, JSON.stringify(state), 'utf8');
102
- }
103
-
104
- async function loadOrDefault(sessionId: string, now: string): Promise<RemoteControlSessionState> {
105
- const existing = await load(sessionId);
106
- if (existing) {
107
- return existing;
108
- }
109
- return buildDefaultState(sessionId, now);
110
- }
111
-
112
- return { load, save, loadOrDefault };
113
- }
114
-
115
- export function buildDefaultState(sessionId: string, now: string): RemoteControlSessionState {
116
- return {
117
- schema_version: SCHEMA_VERSION_V1,
118
- session_id: sessionId,
119
- autonomy_level: DEFAULT_AUTONOMY_LEVEL,
120
- pause: {
121
- paused: false,
122
- paused_at: null,
123
- resumed_at: null,
124
- reason: null,
125
- },
126
- abort: {
127
- aborted: false,
128
- aborted_at: null,
129
- cleanup_status: null,
130
- recovery_action: null,
131
- reason: null,
132
- },
133
- inflight_approvals: [],
134
- updated_at: now,
135
- };
136
- }
137
-
138
- function sessionFile(stateRoot: string, sessionId: string): string {
139
- return path.join(stateRoot, `${sessionId}.json`);
140
- }
141
-
142
- function parseState(value: unknown, filePath: string): RemoteControlSessionState {
143
- if (value === null || typeof value !== 'object') {
144
- throw new Error(
145
- `Failed to parse remote-control state at ${filePath}: expected an object payload.`,
146
- );
147
- }
148
- const record = value as Record<string, unknown>;
149
- if (record.schema_version !== SCHEMA_VERSION_V1) {
150
- throw new Error(
151
- `Failed to parse remote-control state at ${filePath}: unsupported schema_version "${String(record.schema_version)}".`,
152
- );
153
- }
154
- const sessionId = requireString(record.session_id, `${filePath}.session_id`);
155
- const autonomyLevel = requireAutonomyLevel(record.autonomy_level, `${filePath}.autonomy_level`);
156
- const pause = parsePauseState(record.pause, `${filePath}.pause`);
157
- const abort = parseAbortState(record.abort, `${filePath}.abort`);
158
- const inflightApprovals = parseInflightApprovals(
159
- record.inflight_approvals,
160
- `${filePath}.inflight_approvals`,
161
- );
162
- const updatedAt = requireString(record.updated_at, `${filePath}.updated_at`);
163
- return {
164
- schema_version: SCHEMA_VERSION_V1,
165
- session_id: sessionId,
166
- autonomy_level: autonomyLevel,
167
- pause,
168
- abort,
169
- inflight_approvals: inflightApprovals,
170
- updated_at: updatedAt,
171
- };
172
- }
173
-
174
- function parsePauseState(value: unknown, filePath: string): RemoteControlPauseState {
175
- if (value === null || typeof value !== 'object') {
176
- throw new Error(`Failed to parse remote-control state at ${filePath}: expected pause object.`);
177
- }
178
- const record = value as Record<string, unknown>;
179
- return {
180
- paused: typeof record.paused === 'boolean' ? record.paused : false,
181
- paused_at: typeof record.paused_at === 'string' ? record.paused_at : null,
182
- resumed_at: typeof record.resumed_at === 'string' ? record.resumed_at : null,
183
- reason: typeof record.reason === 'string' ? record.reason : null,
184
- };
185
- }
186
-
187
- function parseAbortState(value: unknown, filePath: string): RemoteControlAbortState {
188
- if (value === null || typeof value !== 'object') {
189
- throw new Error(`Failed to parse remote-control state at ${filePath}: expected abort object.`);
190
- }
191
- const record = value as Record<string, unknown>;
192
- const cleanupStatus = record.cleanup_status;
193
- return {
194
- aborted: typeof record.aborted === 'boolean' ? record.aborted : false,
195
- aborted_at: typeof record.aborted_at === 'string' ? record.aborted_at : null,
196
- cleanup_status:
197
- cleanupStatus === 'clean' || cleanupStatus === 'partial' || cleanupStatus === 'needs_recovery'
198
- ? cleanupStatus
199
- : null,
200
- recovery_action: typeof record.recovery_action === 'string' ? record.recovery_action : null,
201
- reason: typeof record.reason === 'string' ? record.reason : null,
202
- };
203
- }
204
-
205
- function parseInflightApprovals(value: unknown, filePath: string): RemoteControlInflightApproval[] {
206
- if (!Array.isArray(value)) {
207
- return [];
208
- }
209
- return value
210
- .map((entry, index) => parseInflightApproval(entry, `${filePath}[${index}]`))
211
- .filter((entry): entry is RemoteControlInflightApproval => entry !== null);
212
- }
213
-
214
- function parseInflightApproval(
215
- value: unknown,
216
- filePath: string,
217
- ): RemoteControlInflightApproval | null {
218
- if (value === null || typeof value !== 'object') {
219
- return null;
220
- }
221
- const record = value as Record<string, unknown>;
222
- if (
223
- typeof record.request_id !== 'string' ||
224
- typeof record.tool_name !== 'string' ||
225
- typeof record.requested_at !== 'string'
226
- ) {
227
- throw new Error(
228
- `Failed to parse remote-control state at ${filePath}: malformed inflight approval entry.`,
229
- );
230
- }
231
- return {
232
- request_id: record.request_id,
233
- tool_name: record.tool_name,
234
- requested_at: record.requested_at,
235
- };
236
- }
237
-
238
- function requireString(value: unknown, filePath: string): string {
239
- if (typeof value !== 'string' || value.length === 0) {
240
- throw new Error(
241
- `Failed to parse remote-control state at ${filePath}: expected a non-empty string.`,
242
- );
243
- }
244
- return value;
245
- }
246
-
247
- function requireAutonomyLevel(value: unknown, filePath: string): AgentRuntimeAutonomyLevel {
248
- if (
249
- value === AGENT_RUNTIME_AUTONOMY_LEVELS.MANUAL ||
250
- value === AGENT_RUNTIME_AUTONOMY_LEVELS.ASSISTED ||
251
- value === AGENT_RUNTIME_AUTONOMY_LEVELS.AUTO
252
- ) {
253
- return value;
254
- }
255
- throw new Error(
256
- `Failed to parse remote-control state at ${filePath}: unknown autonomy level "${String(value)}".`,
257
- );
258
- }
@@ -1,105 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
- //
4
- // WU-2732 (INIT-060 Phase 3, ADR-013 §1 + §6 tracer bullet):
5
- // Remote-control tool name registry and port/result shapes. The six
6
- // tools here form the conductor-mode governance surface for the
7
- // agent-runtime pack. Real implementations land in WU-2733; this file
8
- // defines the wire contract the real impl must satisfy without
9
- // re-deciding tool names or payload shapes.
10
-
11
- import type { AgentRuntimeCleanupStatus } from '../turn-lifecycle-events.js';
12
-
13
- /**
14
- * Canonical remote-control tool names. Prefixed with the pack slug per
15
- * ADR-013 §Event Namespacing convention (extended to tool names for
16
- * consistency with WU-2729 software-delivery pack exposure precedent).
17
- */
18
- export const AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES = {
19
- RESUME_WORKFLOW: 'agent-runtime:resume_workflow',
20
- PAUSE_TURN: 'agent-runtime:pause_turn',
21
- ABORT_TURN: 'agent-runtime:abort_turn',
22
- ELEVATE_AUTONOMY: 'agent-runtime:elevate_autonomy',
23
- LOWER_AUTONOMY: 'agent-runtime:lower_autonomy',
24
- APPROVE_INFLIGHT: 'agent-runtime:approve_inflight',
25
- } as const;
26
-
27
- export type AgentRuntimeRemoteControlToolName =
28
- (typeof AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES)[keyof typeof AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES];
29
-
30
- /**
31
- * Declaration order matters: callers (HTTP surface allowlist, conductor
32
- * UI) render the list in this sequence without re-sorting.
33
- */
34
- export const AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAME_VALUES = [
35
- AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.RESUME_WORKFLOW,
36
- AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.PAUSE_TURN,
37
- AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.ABORT_TURN,
38
- AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.ELEVATE_AUTONOMY,
39
- AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.LOWER_AUTONOMY,
40
- AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.APPROVE_INFLIGHT,
41
- ] as const satisfies readonly AgentRuntimeRemoteControlToolName[];
42
-
43
- /**
44
- * Well-known approval identifier the agent-runtime pack requests for
45
- * safety-critical remote controls (abort, pause, elevate). Single
46
- * identifier per ADR-013 §6 governance lock — cloud renders the same
47
- * approval gate regardless of which of the gated tools was invoked.
48
- */
49
- export const AGENT_RUNTIME_REMOTE_CONTROL_APPROVAL_ID = 'agent-runtime:remote_control' as const;
50
-
51
- /**
52
- * Mapping from remote-control tool name to its declared
53
- * `required_approvals` manifest entry. Gated tools request an explicit
54
- * approval identifier; safer/read-only tools declare an empty array so
55
- * the manifest stays minimally descriptive (matches WU-2729 convention).
56
- */
57
- export const AGENT_RUNTIME_REMOTE_CONTROL_APPROVALS: Record<
58
- AgentRuntimeRemoteControlToolName,
59
- readonly string[]
60
- > = {
61
- [AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.RESUME_WORKFLOW]: [],
62
- [AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.PAUSE_TURN]: [AGENT_RUNTIME_REMOTE_CONTROL_APPROVAL_ID],
63
- [AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.ABORT_TURN]: [AGENT_RUNTIME_REMOTE_CONTROL_APPROVAL_ID],
64
- [AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.ELEVATE_AUTONOMY]: [
65
- AGENT_RUNTIME_REMOTE_CONTROL_APPROVAL_ID,
66
- ],
67
- [AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.LOWER_AUTONOMY]: [],
68
- [AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.APPROVE_INFLIGHT]: [],
69
- };
70
-
71
- /**
72
- * Deterministic mock session identifier returned by tracer-bullet
73
- * implementations. The real impl in WU-2733 reads the session from the
74
- * input payload; the mock returns a fixed value so round-trip tests
75
- * pin the wire contract without leaking runtime state.
76
- */
77
- export const MOCK_SESSION_ID = 'agent-runtime-remote-control-mock-session' as const;
78
-
79
- /**
80
- * Shared result shape for the five non-abort remote controls. Real
81
- * impls may extend this — the additive-only rule lets WU-2733 land
82
- * without contract drift.
83
- */
84
- export interface RemoteControlInvocationResult {
85
- status: 'ok';
86
- tool_name: AgentRuntimeRemoteControlToolName;
87
- session_id: string;
88
- }
89
-
90
- /**
91
- * abort_turn carries the ADR-013 §1 abort contract: cleanup_status +
92
- * recovery_action. Cloud renders recovery_action as a hint; NEVER
93
- * auto-executes (see ADR-013 §1 safety lock).
94
- */
95
- export interface AbortTurnInvocationResult {
96
- status: 'ok';
97
- tool_name: typeof AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.ABORT_TURN;
98
- session_id: string;
99
- cleanup_status: AgentRuntimeCleanupStatus;
100
- recovery_action: string | null;
101
- }
102
-
103
- export type AnyRemoteControlInvocationResult =
104
- | RemoteControlInvocationResult
105
- | AbortTurnInvocationResult;