@lumenflow/cli 5.5.0 → 5.7.14

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 (229) hide show
  1. package/README.md +41 -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/doctor.js +11 -0
  7. package/dist/doctor.js.map +1 -1
  8. package/dist/gate-defaults.js +37 -0
  9. package/dist/gate-defaults.js.map +1 -1
  10. package/dist/gates/monolithic-file-contention-guard.js +167 -0
  11. package/dist/gates/monolithic-file-contention-guard.js.map +1 -0
  12. package/dist/gates/prod-migration-drift.js +207 -0
  13. package/dist/gates/prod-migration-drift.js.map +1 -0
  14. package/dist/gates/test-over-deletion-guard.js +280 -0
  15. package/dist/gates/test-over-deletion-guard.js.map +1 -0
  16. package/dist/gates-runners.js +44 -3
  17. package/dist/gates-runners.js.map +1 -1
  18. package/dist/gates.js +3 -2
  19. package/dist/gates.js.map +1 -1
  20. package/dist/hooks/config-resolver.js +16 -1
  21. package/dist/hooks/config-resolver.js.map +1 -1
  22. package/dist/hooks/dirty-guard.js +43 -2
  23. package/dist/hooks/dirty-guard.js.map +1 -1
  24. package/dist/hooks/git-status-parser.js +22 -8
  25. package/dist/hooks/git-status-parser.js.map +1 -1
  26. package/dist/init-templates.js +241 -0
  27. package/dist/init-templates.js.map +1 -1
  28. package/dist/init.js +122 -16
  29. package/dist/init.js.map +1 -1
  30. package/dist/lumenflow-setup.js +144 -0
  31. package/dist/lumenflow-setup.js.map +1 -0
  32. package/dist/lumenflow-upgrade.js +43 -1
  33. package/dist/lumenflow-upgrade.js.map +1 -1
  34. package/dist/mem-create.js +10 -1
  35. package/dist/mem-create.js.map +1 -1
  36. package/dist/mem-signal.js +21 -4
  37. package/dist/mem-signal.js.map +1 -1
  38. package/dist/orchestrate-initiative.js +28 -3
  39. package/dist/orchestrate-initiative.js.map +1 -1
  40. package/dist/public-manifest.js +17 -7
  41. package/dist/public-manifest.js.map +1 -1
  42. package/dist/release.js +53 -18
  43. package/dist/release.js.map +1 -1
  44. package/dist/wu-done-gates.js +13 -9
  45. package/dist/wu-done-gates.js.map +1 -1
  46. package/dist/wu-done.js +14 -2
  47. package/dist/wu-done.js.map +1 -1
  48. package/dist/wu-edit-operations.js +74 -0
  49. package/dist/wu-edit-operations.js.map +1 -1
  50. package/dist/wu-edit-validators.js +58 -0
  51. package/dist/wu-edit-validators.js.map +1 -1
  52. package/dist/wu-edit.js +106 -4
  53. package/dist/wu-edit.js.map +1 -1
  54. package/dist/wu-prep.js +57 -9
  55. package/dist/wu-prep.js.map +1 -1
  56. package/dist/wu-recover.js +6 -0
  57. package/dist/wu-recover.js.map +1 -1
  58. package/dist/wu-release.js +120 -2
  59. package/dist/wu-release.js.map +1 -1
  60. package/dist/wu-sizing-validation.js +47 -17
  61. package/dist/wu-sizing-validation.js.map +1 -1
  62. package/dist/wu-status.js +33 -0
  63. package/dist/wu-status.js.map +1 -1
  64. package/package.json +13 -12
  65. package/packs/agent-runtime/package.json +1 -1
  66. package/packs/sidekick/package.json +1 -1
  67. package/packs/software-delivery/package.json +1 -1
  68. package/templates/core/AGENTS.md.template +67 -3
  69. package/templates/core/LUMENFLOW.md.template +196 -47
  70. package/dist/distribution-preflight.js +0 -230
  71. package/dist/distribution-preflight.js.map +0 -1
  72. package/packs/agent-runtime/agent-heartbeat.ts +0 -163
  73. package/packs/agent-runtime/auto-session-integration.ts +0 -888
  74. package/packs/agent-runtime/capability-factory.ts +0 -104
  75. package/packs/agent-runtime/constants.ts +0 -21
  76. package/packs/agent-runtime/delegation-registry-schema.ts +0 -220
  77. package/packs/agent-runtime/delegation-registry-store.ts +0 -269
  78. package/packs/agent-runtime/delegation-tree.ts +0 -328
  79. package/packs/agent-runtime/index.ts +0 -20
  80. package/packs/agent-runtime/manifest.ts +0 -348
  81. package/packs/agent-runtime/memory-coordination-contract.ts +0 -86
  82. package/packs/agent-runtime/orchestration.ts +0 -2027
  83. package/packs/agent-runtime/pack-registration.ts +0 -110
  84. package/packs/agent-runtime/policy-factory.ts +0 -165
  85. package/packs/agent-runtime/remote-controls/index.ts +0 -7
  86. package/packs/agent-runtime/remote-controls/operations.ts +0 -405
  87. package/packs/agent-runtime/remote-controls/port.ts +0 -48
  88. package/packs/agent-runtime/remote-controls/state-store.ts +0 -258
  89. package/packs/agent-runtime/remote-controls/types.ts +0 -105
  90. package/packs/agent-runtime/session-schema.ts +0 -467
  91. package/packs/agent-runtime/tool-impl/agent-turn-tools.ts +0 -793
  92. package/packs/agent-runtime/tool-impl/index.ts +0 -6
  93. package/packs/agent-runtime/tool-impl/provider-adapters.ts +0 -1245
  94. package/packs/agent-runtime/tool-impl/remote-controls.mock.ts +0 -256
  95. package/packs/agent-runtime/tool-impl/remote-controls.ts +0 -273
  96. package/packs/agent-runtime/tools/index.ts +0 -4
  97. package/packs/agent-runtime/tools/types.ts +0 -47
  98. package/packs/agent-runtime/turn-lifecycle-events.ts +0 -590
  99. package/packs/agent-runtime/types.ts +0 -128
  100. package/packs/agent-runtime/vitest.config.ts +0 -11
  101. package/packs/sidekick/channel-ingress.ts +0 -137
  102. package/packs/sidekick/constants.ts +0 -10
  103. package/packs/sidekick/index.ts +0 -8
  104. package/packs/sidekick/manifest-schema.ts +0 -49
  105. package/packs/sidekick/manifest.ts +0 -512
  106. package/packs/sidekick/pack-registration.ts +0 -110
  107. package/packs/sidekick/policy-factory.ts +0 -38
  108. package/packs/sidekick/sidekick-events.ts +0 -694
  109. package/packs/sidekick/src/adapters/cloud-queue.ts +0 -101
  110. package/packs/sidekick/src/adapters/control-plane-bridge.adapter.ts +0 -386
  111. package/packs/sidekick/src/adapters/filesystem-bridge.adapter.ts +0 -228
  112. package/packs/sidekick/src/domain/channel.types.ts +0 -64
  113. package/packs/sidekick/src/ports/channel-bridge.port.ts +0 -92
  114. package/packs/sidekick/src/routines/commit.ts +0 -74
  115. package/packs/sidekick/tool-impl/channel-tools.ts +0 -577
  116. package/packs/sidekick/tool-impl/channel-transports.ts +0 -75
  117. package/packs/sidekick/tool-impl/index.ts +0 -29
  118. package/packs/sidekick/tool-impl/memory-tools.ts +0 -290
  119. package/packs/sidekick/tool-impl/routine-commit.ts +0 -102
  120. package/packs/sidekick/tool-impl/routine-tools.ts +0 -440
  121. package/packs/sidekick/tool-impl/runtime-context.ts +0 -28
  122. package/packs/sidekick/tool-impl/shared.ts +0 -125
  123. package/packs/sidekick/tool-impl/storage.ts +0 -325
  124. package/packs/sidekick/tool-impl/system-tools.ts +0 -160
  125. package/packs/sidekick/tool-impl/task-tools.ts +0 -506
  126. package/packs/sidekick/tools/channel-tools.ts +0 -53
  127. package/packs/sidekick/tools/index.ts +0 -9
  128. package/packs/sidekick/tools/memory-tools.ts +0 -53
  129. package/packs/sidekick/tools/routine-tools.ts +0 -53
  130. package/packs/sidekick/tools/system-tools.ts +0 -47
  131. package/packs/sidekick/tools/task-tools.ts +0 -61
  132. package/packs/sidekick/tools/types.ts +0 -57
  133. package/packs/sidekick/vitest.config.ts +0 -11
  134. package/packs/software-delivery/constants.ts +0 -10
  135. package/packs/software-delivery/extensions.ts +0 -140
  136. package/packs/software-delivery/gate-policies.ts +0 -134
  137. package/packs/software-delivery/index.ts +0 -8
  138. package/packs/software-delivery/manifest-schema.ts +0 -268
  139. package/packs/software-delivery/manifest.ts +0 -657
  140. package/packs/software-delivery/pack-registration.ts +0 -113
  141. package/packs/software-delivery/src/commands/index.ts +0 -5
  142. package/packs/software-delivery/src/config/delivery-review-contract.ts +0 -256
  143. package/packs/software-delivery/src/config/env-accessors.ts +0 -66
  144. package/packs/software-delivery/src/config/index.ts +0 -8
  145. package/packs/software-delivery/src/config/normalize-config-keys.ts +0 -9
  146. package/packs/software-delivery/src/config/schemas/lumenflow-config-schema-types.ts +0 -460
  147. package/packs/software-delivery/src/config/workspace-reader.ts +0 -375
  148. package/packs/software-delivery/src/constants/backlog-patterns.ts +0 -31
  149. package/packs/software-delivery/src/constants/client-ids.ts +0 -19
  150. package/packs/software-delivery/src/constants/config-contract.ts +0 -7
  151. package/packs/software-delivery/src/constants/docs-layout-presets.ts +0 -50
  152. package/packs/software-delivery/src/constants/duration-constants.ts +0 -20
  153. package/packs/software-delivery/src/constants/gate-constants.ts +0 -32
  154. package/packs/software-delivery/src/constants/index.ts +0 -29
  155. package/packs/software-delivery/src/constants/lock-constants.ts +0 -35
  156. package/packs/software-delivery/src/constants/object-guards.ts +0 -12
  157. package/packs/software-delivery/src/constants/section-headings.ts +0 -107
  158. package/packs/software-delivery/src/constants/wu-cli-constants.ts +0 -500
  159. package/packs/software-delivery/src/constants/wu-domain-constants.ts +0 -466
  160. package/packs/software-delivery/src/constants/wu-git-constants.ts +0 -7
  161. package/packs/software-delivery/src/constants/wu-id-format.ts +0 -327
  162. package/packs/software-delivery/src/constants/wu-paths-constants.ts +0 -384
  163. package/packs/software-delivery/src/constants/wu-statuses.ts +0 -287
  164. package/packs/software-delivery/src/constants/wu-type-helpers.ts +0 -67
  165. package/packs/software-delivery/src/constants/wu-ui-constants.ts +0 -267
  166. package/packs/software-delivery/src/constants/wu-validation-constants.ts +0 -73
  167. package/packs/software-delivery/src/domain/index.ts +0 -5
  168. package/packs/software-delivery/src/domain/orchestration.constants.ts +0 -166
  169. package/packs/software-delivery/src/domain/orchestration.schemas.ts +0 -238
  170. package/packs/software-delivery/src/domain/orchestration.types.ts +0 -176
  171. package/packs/software-delivery/src/methodology/incremental-test.ts +0 -122
  172. package/packs/software-delivery/src/methodology/index.ts +0 -6
  173. package/packs/software-delivery/src/methodology/manual-test-validator.ts +0 -292
  174. package/packs/software-delivery/src/policy/coverage-gate.ts +0 -270
  175. package/packs/software-delivery/src/policy/gates-agent-mode.ts +0 -223
  176. package/packs/software-delivery/src/policy/gates-config-internal.ts +0 -121
  177. package/packs/software-delivery/src/policy/gates-config.ts +0 -300
  178. package/packs/software-delivery/src/policy/gates-coverage.ts +0 -356
  179. package/packs/software-delivery/src/policy/gates-presets.ts +0 -134
  180. package/packs/software-delivery/src/policy/gates-schemas.ts +0 -173
  181. package/packs/software-delivery/src/policy/index.ts +0 -22
  182. package/packs/software-delivery/src/policy/package-manager-resolver.ts +0 -319
  183. package/packs/software-delivery/src/policy/resolve-policy.ts +0 -601
  184. package/packs/software-delivery/src/ports/config.ports.ts +0 -90
  185. package/packs/software-delivery/src/ports/dashboard-renderer.port.ts +0 -125
  186. package/packs/software-delivery/src/ports/index.ts +0 -10
  187. package/packs/software-delivery/src/ports/sync-validator.ports.ts +0 -59
  188. package/packs/software-delivery/src/ports/wu-helpers.ports.ts +0 -168
  189. package/packs/software-delivery/src/ports/wu-state.ports.ts +0 -241
  190. package/packs/software-delivery/src/primitives/index.ts +0 -5
  191. package/packs/software-delivery/src/runtime/index.ts +0 -6
  192. package/packs/software-delivery/src/runtime/work-classifier.ts +0 -561
  193. package/packs/software-delivery/src/sandbox/index.ts +0 -10
  194. package/packs/software-delivery/src/sandbox/sandbox-allowlist.ts +0 -118
  195. package/packs/software-delivery/src/sandbox/sandbox-backend-linux.ts +0 -88
  196. package/packs/software-delivery/src/sandbox/sandbox-backend-macos.ts +0 -154
  197. package/packs/software-delivery/src/sandbox/sandbox-backend-windows.ts +0 -47
  198. package/packs/software-delivery/src/sandbox/sandbox-profile.ts +0 -153
  199. package/packs/software-delivery/src/schemas/index.ts +0 -5
  200. package/packs/software-delivery/src/state/date-utils.ts +0 -158
  201. package/packs/software-delivery/src/state/index.ts +0 -15
  202. package/packs/software-delivery/src/state/state-machine.ts +0 -119
  203. package/packs/software-delivery/src/state/wu-doc-types.ts +0 -51
  204. package/packs/software-delivery/src/state/wu-paths.ts +0 -381
  205. package/packs/software-delivery/src/state/wu-schema.ts +0 -1139
  206. package/packs/software-delivery/src/state/wu-state-schema.ts +0 -255
  207. package/packs/software-delivery/src/state/wu-yaml.ts +0 -338
  208. package/packs/software-delivery/tool-impl/agent-tools.ts +0 -263
  209. package/packs/software-delivery/tool-impl/delegation-tools.ts +0 -66
  210. package/packs/software-delivery/tool-impl/flow-metrics-tools.ts +0 -219
  211. package/packs/software-delivery/tool-impl/git-runner.ts +0 -113
  212. package/packs/software-delivery/tool-impl/git-tools.ts +0 -316
  213. package/packs/software-delivery/tool-impl/index.ts +0 -15
  214. package/packs/software-delivery/tool-impl/initiative-orchestration-tools.ts +0 -720
  215. package/packs/software-delivery/tool-impl/lane-lock.ts +0 -246
  216. package/packs/software-delivery/tool-impl/memory-tools.ts +0 -470
  217. package/packs/software-delivery/tool-impl/pending-runtime-tools.ts +0 -21
  218. package/packs/software-delivery/tool-impl/runtime-cli-adapter.ts +0 -329
  219. package/packs/software-delivery/tool-impl/runtime-native-tools.ts +0 -687
  220. package/packs/software-delivery/tool-impl/worker-loader.ts +0 -52
  221. package/packs/software-delivery/tool-impl/worktree-tools.ts +0 -46
  222. package/packs/software-delivery/tool-impl/wu-lifecycle-tools.ts +0 -807
  223. package/packs/software-delivery/tools/delegation-tools.ts +0 -23
  224. package/packs/software-delivery/tools/git-tools.ts +0 -55
  225. package/packs/software-delivery/tools/index.ts +0 -8
  226. package/packs/software-delivery/tools/lane-lock-tool.ts +0 -37
  227. package/packs/software-delivery/tools/types.ts +0 -71
  228. package/packs/software-delivery/tools/worktree-tools.ts +0 -49
  229. 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;