@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,256 +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 abort + §6 governance):
5
- // Pattern A tracer-bullet mock implementation for the six
6
- // remote-control tools. Returns deterministic fixed responses so the
7
- // wire contract (manifest entries, POST /tools/:name round-trip,
8
- // tool_called emission) can be proven BEFORE the real kernel-side
9
- // implementation lands in WU-2733.
10
- //
11
- // REAL IMPL WILL REPLACE THIS FILE: WU-2733 ships
12
- // tool-impl/remote-controls.ts with the real pause/resume/abort logic.
13
- // The mock's role is purely contract stabilisation.
14
-
15
- import { randomUUID } from 'node:crypto';
16
- import type { ExecutionContext, ToolOutput } from '@lumenflow/kernel';
17
- import {
18
- AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES,
19
- MOCK_SESSION_ID,
20
- type AbortTurnInvocationResult,
21
- type AgentRuntimeRemoteControlToolName,
22
- type AnyRemoteControlInvocationResult,
23
- type RemoteControlInvocationResult,
24
- } from '../remote-controls/types.js';
25
- import type {
26
- AbortTurnInvocationInput,
27
- RemoteControlInvocationInput,
28
- RemoteControlPort,
29
- } from '../remote-controls/port.js';
30
- import {
31
- buildToolCalledEvent,
32
- emitAgentRuntimeEvent,
33
- type AgentRuntimeEventSink,
34
- } from '../turn-lifecycle-events.js';
35
-
36
- const MOCK_TURN_INDEX = 0;
37
- const MOCK_CLEANUP_STATUS_CLEAN = 'clean' as const;
38
- const MOCK_ABORT_RECOVERY_ACTION: string | null = null;
39
-
40
- /**
41
- * Mock adapter implementing RemoteControlPort. Every invocation:
42
- * 1. Returns a deterministic response matching the declared contract.
43
- * 2. Emits `agent-runtime:tool_called` via the supplied sink (ADR-013
44
- * §6 governance — every tool call is auditable).
45
- *
46
- * Fixed session_id + turn_index in the emitted event mean tests can
47
- * assert exact payloads without runtime coupling.
48
- */
49
- export class MockRemoteControlAdapter implements RemoteControlPort {
50
- constructor(private readonly eventSink?: AgentRuntimeEventSink) {}
51
-
52
- async resumeWorkflow(
53
- input: RemoteControlInvocationInput,
54
- ): Promise<RemoteControlInvocationResult> {
55
- return this.handle(AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.RESUME_WORKFLOW, input);
56
- }
57
-
58
- async pauseTurn(input: RemoteControlInvocationInput): Promise<RemoteControlInvocationResult> {
59
- return this.handle(AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.PAUSE_TURN, input);
60
- }
61
-
62
- async abortTurn(input: AbortTurnInvocationInput): Promise<AbortTurnInvocationResult> {
63
- const sessionId = resolveSessionId(input.session_id);
64
- this.emitToolCalled(AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.ABORT_TURN, sessionId);
65
- return {
66
- status: 'ok',
67
- tool_name: AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.ABORT_TURN,
68
- session_id: sessionId,
69
- cleanup_status: MOCK_CLEANUP_STATUS_CLEAN,
70
- recovery_action: MOCK_ABORT_RECOVERY_ACTION,
71
- };
72
- }
73
-
74
- async elevateAutonomy(
75
- input: RemoteControlInvocationInput,
76
- ): Promise<RemoteControlInvocationResult> {
77
- return this.handle(AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.ELEVATE_AUTONOMY, input);
78
- }
79
-
80
- async lowerAutonomy(input: RemoteControlInvocationInput): Promise<RemoteControlInvocationResult> {
81
- return this.handle(AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.LOWER_AUTONOMY, input);
82
- }
83
-
84
- async approveInflight(
85
- input: RemoteControlInvocationInput,
86
- ): Promise<RemoteControlInvocationResult> {
87
- return this.handle(AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.APPROVE_INFLIGHT, input);
88
- }
89
-
90
- private handle(
91
- toolName: AgentRuntimeRemoteControlToolName,
92
- input: RemoteControlInvocationInput,
93
- ): RemoteControlInvocationResult {
94
- const sessionId = resolveSessionId(input.session_id);
95
- this.emitToolCalled(toolName, sessionId);
96
- return {
97
- status: 'ok',
98
- tool_name: toolName,
99
- session_id: sessionId,
100
- };
101
- }
102
-
103
- private emitToolCalled(toolName: AgentRuntimeRemoteControlToolName, sessionId: string): void {
104
- if (!this.eventSink) {
105
- return;
106
- }
107
- emitAgentRuntimeEvent(
108
- this.eventSink,
109
- buildToolCalledEvent({
110
- session_id: sessionId,
111
- turn_index: MOCK_TURN_INDEX,
112
- tool_name: toolName,
113
- tool_call_id: randomUUID(),
114
- // WU-2829: mock fixture mirrors the real-adapter contract —
115
- // remote-control operations emit tool_called after the
116
- // conductor's approval flow has authorised the invocation.
117
- approved: true,
118
- }),
119
- );
120
- }
121
- }
122
-
123
- function resolveSessionId(input: string | undefined): string {
124
- if (input !== undefined && input.trim().length > 0) {
125
- return input;
126
- }
127
- return MOCK_SESSION_ID;
128
- }
129
-
130
- /**
131
- * Factory for the default mock adapter. Tests and the manifest-wired
132
- * tool functions below both use this so the fixture surface has a
133
- * single instantiation path.
134
- */
135
- export function createMockRemoteControlAdapter(
136
- eventSink?: AgentRuntimeEventSink,
137
- ): MockRemoteControlAdapter {
138
- return new MockRemoteControlAdapter(eventSink);
139
- }
140
-
141
- /**
142
- * Manifest-entrypoint adapter: each of the six exported functions
143
- * matches the kernel's InProcessToolFn signature
144
- * `(input: unknown, ctx: ExecutionContext) => Promise<ToolOutput>`.
145
- *
146
- * The module-scoped sink is rebound via `setMockRemoteControlEventSink`
147
- * for tests that want to assert tool_called emission. Production
148
- * wiring (HTTP surface → runtime → manifest-dispatch) will ignore the
149
- * sink and rely on runtime-level tool_called events; the in-process
150
- * sink is a mock-only convenience for the unit suite.
151
- */
152
- let moduleEventSink: AgentRuntimeEventSink | undefined;
153
-
154
- export function setMockRemoteControlEventSink(sink: AgentRuntimeEventSink | undefined): void {
155
- moduleEventSink = sink;
156
- }
157
-
158
- function buildToolOutput(data: AnyRemoteControlInvocationResult): ToolOutput {
159
- return {
160
- success: true,
161
- data,
162
- metadata: {
163
- mock: true,
164
- tracer_bullet: 'WU-2732',
165
- },
166
- };
167
- }
168
-
169
- async function invokeMock(
170
- toolName: AgentRuntimeRemoteControlToolName,
171
- input: unknown,
172
- ): Promise<ToolOutput> {
173
- const adapter = createMockRemoteControlAdapter(moduleEventSink);
174
- const parsed = parseInput(input);
175
-
176
- switch (toolName) {
177
- case AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.RESUME_WORKFLOW:
178
- return buildToolOutput(await adapter.resumeWorkflow(parsed));
179
- case AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.PAUSE_TURN:
180
- return buildToolOutput(await adapter.pauseTurn(parsed));
181
- case AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.ABORT_TURN:
182
- return buildToolOutput(await adapter.abortTurn(parsed));
183
- case AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.ELEVATE_AUTONOMY:
184
- return buildToolOutput(await adapter.elevateAutonomy(parsed));
185
- case AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.LOWER_AUTONOMY:
186
- return buildToolOutput(await adapter.lowerAutonomy(parsed));
187
- case AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.APPROVE_INFLIGHT:
188
- return buildToolOutput(await adapter.approveInflight(parsed));
189
- default:
190
- return exhaustive(toolName);
191
- }
192
- }
193
-
194
- function parseInput(input: unknown): AbortTurnInvocationInput {
195
- if (input === null || input === undefined) {
196
- return {};
197
- }
198
- if (typeof input !== 'object') {
199
- return {};
200
- }
201
- const record = input as Record<string, unknown>;
202
- const result: AbortTurnInvocationInput = {};
203
- if (typeof record.session_id === 'string') {
204
- result.session_id = record.session_id;
205
- }
206
- if (typeof record.reason === 'string') {
207
- result.reason = record.reason;
208
- }
209
- return result;
210
- }
211
-
212
- function exhaustive(value: never): never {
213
- throw new Error(`Unhandled remote-control tool: ${String(value)}`);
214
- }
215
-
216
- export async function resumeWorkflowMockTool(
217
- input: unknown,
218
- _ctx: ExecutionContext,
219
- ): Promise<ToolOutput> {
220
- return invokeMock(AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.RESUME_WORKFLOW, input);
221
- }
222
-
223
- export async function pauseTurnMockTool(
224
- input: unknown,
225
- _ctx: ExecutionContext,
226
- ): Promise<ToolOutput> {
227
- return invokeMock(AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.PAUSE_TURN, input);
228
- }
229
-
230
- export async function abortTurnMockTool(
231
- input: unknown,
232
- _ctx: ExecutionContext,
233
- ): Promise<ToolOutput> {
234
- return invokeMock(AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.ABORT_TURN, input);
235
- }
236
-
237
- export async function elevateAutonomyMockTool(
238
- input: unknown,
239
- _ctx: ExecutionContext,
240
- ): Promise<ToolOutput> {
241
- return invokeMock(AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.ELEVATE_AUTONOMY, input);
242
- }
243
-
244
- export async function lowerAutonomyMockTool(
245
- input: unknown,
246
- _ctx: ExecutionContext,
247
- ): Promise<ToolOutput> {
248
- return invokeMock(AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.LOWER_AUTONOMY, input);
249
- }
250
-
251
- export async function approveInflightMockTool(
252
- input: unknown,
253
- _ctx: ExecutionContext,
254
- ): Promise<ToolOutput> {
255
- return invokeMock(AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.APPROVE_INFLIGHT, input);
256
- }
@@ -1,273 +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 + §6):
5
- // Real kernel-side RemoteControlPort adapter + manifest-entrypoint tool
6
- // functions. Replaces the mock tracer-bullet entries from WU-2732
7
- // without changing tool names, permissions, scopes, approvals, input
8
- // schemas, or result shapes — the wire contract survives unchanged
9
- // because every shape is pinned by `remote-controls/port.ts` +
10
- // `remote-controls/types.ts`.
11
- //
12
- // Side effects: this adapter persists remote-control state under
13
- // `.agent-runtime/remote-controls/<session>.json` (sidecar, isolated
14
- // from the core orchestration workflow state store so existing
15
- // workflow schema validation is untouched) and emits events through
16
- // the supplied sink.
17
-
18
- import type { ExecutionContext, ToolOutput } from '@lumenflow/kernel';
19
- import {
20
- abortTurn,
21
- approveInflight,
22
- elevateAutonomy,
23
- lowerAutonomy,
24
- pauseTurn,
25
- resumeWorkflow,
26
- type RemoteControlOperationContext,
27
- } from '../remote-controls/operations.js';
28
- import type {
29
- AbortTurnInvocationInput,
30
- RemoteControlInvocationInput,
31
- RemoteControlPort,
32
- } from '../remote-controls/port.js';
33
- import {
34
- createRemoteControlStateStore,
35
- type RemoteControlStateStore,
36
- } from '../remote-controls/state-store.js';
37
- import {
38
- AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES,
39
- type AbortTurnInvocationResult,
40
- type AgentRuntimeRemoteControlToolName,
41
- type AnyRemoteControlInvocationResult,
42
- type RemoteControlInvocationResult,
43
- } from '../remote-controls/types.js';
44
- import type { AgentRuntimeEventSink } from '../turn-lifecycle-events.js';
45
-
46
- export interface RealRemoteControlAdapterInput {
47
- store: RemoteControlStateStore;
48
- eventSink?: AgentRuntimeEventSink;
49
- now?: () => string;
50
- }
51
-
52
- /**
53
- * Real (non-mock) implementation of RemoteControlPort. Wires each port
54
- * method to the corresponding operation in `operations.ts`. Every port
55
- * method load-bears a `RemoteControlStateStore` so state survives
56
- * restarts; emission goes through the `AgentRuntimeEventSink` supplied
57
- * at construction (matches the mock's pattern so wiring parity holds).
58
- */
59
- export class RealRemoteControlAdapter implements RemoteControlPort {
60
- private readonly context: RemoteControlOperationContext;
61
-
62
- constructor(input: RealRemoteControlAdapterInput) {
63
- this.context = {
64
- store: input.store,
65
- eventSink: input.eventSink,
66
- now: input.now ?? (() => new Date().toISOString()),
67
- };
68
- }
69
-
70
- async resumeWorkflow(
71
- input: RemoteControlInvocationInput,
72
- ): Promise<RemoteControlInvocationResult> {
73
- return resumeWorkflow(input, this.context);
74
- }
75
-
76
- async pauseTurn(input: RemoteControlInvocationInput): Promise<RemoteControlInvocationResult> {
77
- return pauseTurn(input, this.context);
78
- }
79
-
80
- async abortTurn(input: AbortTurnInvocationInput): Promise<AbortTurnInvocationResult> {
81
- return abortTurn(input, this.context);
82
- }
83
-
84
- async elevateAutonomy(
85
- input: RemoteControlInvocationInput,
86
- ): Promise<RemoteControlInvocationResult> {
87
- return elevateAutonomy(input, this.context);
88
- }
89
-
90
- async lowerAutonomy(input: RemoteControlInvocationInput): Promise<RemoteControlInvocationResult> {
91
- return lowerAutonomy(input, this.context);
92
- }
93
-
94
- async approveInflight(
95
- input: RemoteControlInvocationInput,
96
- ): Promise<RemoteControlInvocationResult> {
97
- return approveInflight(input, this.context);
98
- }
99
- }
100
-
101
- export function createRealRemoteControlAdapter(
102
- input: RealRemoteControlAdapterInput,
103
- ): RealRemoteControlAdapter {
104
- return new RealRemoteControlAdapter(input);
105
- }
106
-
107
- // ---------------------------------------------------------------------------
108
- // Manifest-entrypoint wiring
109
- // ---------------------------------------------------------------------------
110
- //
111
- // Each exported `*Tool` below matches the kernel's InProcessToolFn
112
- // signature `(input, ctx) => Promise<ToolOutput>`. The `ctx` carries
113
- // the run identifiers and allowed_scopes; we derive the storage root
114
- // from the runtime's allowlist `.agent-runtime/**` path — or the
115
- // module-scoped override when the host wires one directly (test
116
- // harness + conductor runtime).
117
-
118
- let moduleEventSink: AgentRuntimeEventSink | undefined;
119
- let moduleStore: RemoteControlStateStore | undefined;
120
- let moduleNow: (() => string) | undefined;
121
-
122
- /**
123
- * Test/host-wiring hooks so the manifest-entrypoint tool functions
124
- * reuse a single adapter across invocations. Production wiring rebinds
125
- * these during pack activation (capability factory registers the
126
- * adapter once); tests clear them in beforeEach.
127
- */
128
- export function setRealRemoteControlEventSink(sink: AgentRuntimeEventSink | undefined): void {
129
- moduleEventSink = sink;
130
- }
131
-
132
- export function setRealRemoteControlStateStore(store: RemoteControlStateStore | undefined): void {
133
- moduleStore = store;
134
- }
135
-
136
- export function setRealRemoteControlNow(now: (() => string) | undefined): void {
137
- moduleNow = now;
138
- }
139
-
140
- /** Resets all module-scoped wiring. Intended for unit-test teardown. */
141
- export function resetRealRemoteControlModuleWiring(): void {
142
- moduleEventSink = undefined;
143
- moduleStore = undefined;
144
- moduleNow = undefined;
145
- }
146
-
147
- function resolveStore(ctx: ExecutionContext): RemoteControlStateStore {
148
- if (moduleStore) {
149
- return moduleStore;
150
- }
151
- const workspaceRoot = resolveWorkspaceRoot(ctx);
152
- return createRemoteControlStateStore({ workspaceRoot });
153
- }
154
-
155
- /**
156
- * Pull the workspace root from the kernel ExecutionContext. Falls back
157
- * to the process cwd when no explicit workspace_root metadata is
158
- * present — matching how the rest of the agent-runtime pack resolves
159
- * storage roots (keeps us on the kernel-provided path when available
160
- * without hard-failing when a test harness omits it).
161
- */
162
- function resolveWorkspaceRoot(ctx: ExecutionContext): string {
163
- const metadata = (ctx as unknown as { metadata?: Record<string, unknown> }).metadata;
164
- const fromMetadata = metadata?.workspace_root;
165
- if (typeof fromMetadata === 'string' && fromMetadata.length > 0) {
166
- return fromMetadata;
167
- }
168
- const fromCtx = (ctx as unknown as { workspace_root?: unknown }).workspace_root;
169
- if (typeof fromCtx === 'string' && fromCtx.length > 0) {
170
- return fromCtx;
171
- }
172
- return process.cwd();
173
- }
174
-
175
- function buildToolOutput(data: AnyRemoteControlInvocationResult): ToolOutput {
176
- return {
177
- success: true,
178
- data,
179
- metadata: {
180
- real: true,
181
- source: 'WU-2733',
182
- },
183
- };
184
- }
185
-
186
- function parseInput(input: unknown): AbortTurnInvocationInput {
187
- if (input === null || input === undefined) {
188
- return {};
189
- }
190
- if (typeof input !== 'object') {
191
- return {};
192
- }
193
- const record = input as Record<string, unknown>;
194
- const result: AbortTurnInvocationInput = {};
195
- if (typeof record.session_id === 'string') {
196
- result.session_id = record.session_id;
197
- }
198
- if (typeof record.reason === 'string') {
199
- result.reason = record.reason;
200
- }
201
- return result;
202
- }
203
-
204
- async function invoke(
205
- toolName: AgentRuntimeRemoteControlToolName,
206
- input: unknown,
207
- ctx: ExecutionContext,
208
- ): Promise<ToolOutput> {
209
- const store = resolveStore(ctx);
210
- const adapter = new RealRemoteControlAdapter({
211
- store,
212
- eventSink: moduleEventSink,
213
- now: moduleNow,
214
- });
215
- const parsed = parseInput(input);
216
-
217
- switch (toolName) {
218
- case AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.RESUME_WORKFLOW:
219
- return buildToolOutput(await adapter.resumeWorkflow(parsed));
220
- case AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.PAUSE_TURN:
221
- return buildToolOutput(await adapter.pauseTurn(parsed));
222
- case AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.ABORT_TURN:
223
- return buildToolOutput(await adapter.abortTurn(parsed));
224
- case AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.ELEVATE_AUTONOMY:
225
- return buildToolOutput(await adapter.elevateAutonomy(parsed));
226
- case AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.LOWER_AUTONOMY:
227
- return buildToolOutput(await adapter.lowerAutonomy(parsed));
228
- case AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.APPROVE_INFLIGHT:
229
- return buildToolOutput(await adapter.approveInflight(parsed));
230
- default:
231
- return exhaustive(toolName);
232
- }
233
- }
234
-
235
- function exhaustive(value: never): never {
236
- throw new Error(`Unhandled remote-control tool: ${String(value)}`);
237
- }
238
-
239
- export async function resumeWorkflowTool(
240
- input: unknown,
241
- ctx: ExecutionContext,
242
- ): Promise<ToolOutput> {
243
- return invoke(AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.RESUME_WORKFLOW, input, ctx);
244
- }
245
-
246
- export async function pauseTurnTool(input: unknown, ctx: ExecutionContext): Promise<ToolOutput> {
247
- return invoke(AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.PAUSE_TURN, input, ctx);
248
- }
249
-
250
- export async function abortTurnTool(input: unknown, ctx: ExecutionContext): Promise<ToolOutput> {
251
- return invoke(AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.ABORT_TURN, input, ctx);
252
- }
253
-
254
- export async function elevateAutonomyTool(
255
- input: unknown,
256
- ctx: ExecutionContext,
257
- ): Promise<ToolOutput> {
258
- return invoke(AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.ELEVATE_AUTONOMY, input, ctx);
259
- }
260
-
261
- export async function lowerAutonomyTool(
262
- input: unknown,
263
- ctx: ExecutionContext,
264
- ): Promise<ToolOutput> {
265
- return invoke(AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.LOWER_AUTONOMY, input, ctx);
266
- }
267
-
268
- export async function approveInflightTool(
269
- input: unknown,
270
- ctx: ExecutionContext,
271
- ): Promise<ToolOutput> {
272
- return invoke(AGENT_RUNTIME_REMOTE_CONTROL_TOOL_NAMES.APPROVE_INFLIGHT, input, ctx);
273
- }
@@ -1,4 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- export * from './types.js';
@@ -1,47 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- import type { ToolScope } from '@lumenflow/kernel';
5
- import {
6
- AGENT_RUNTIME_DOMAIN,
7
- AGENT_RUNTIME_PACK_ID,
8
- AGENT_RUNTIME_PACK_VERSION,
9
- } from '../constants.js';
10
- import type { AgentRuntimeToolName } from '../types.js';
11
-
12
- export const AGENT_RUNTIME_TOOL_PERMISSIONS = {
13
- READ: 'read',
14
- WRITE: 'write',
15
- ADMIN: 'admin',
16
- } as const;
17
-
18
- export type AgentRuntimeToolPermission =
19
- (typeof AGENT_RUNTIME_TOOL_PERMISSIONS)[keyof typeof AGENT_RUNTIME_TOOL_PERMISSIONS];
20
-
21
- export interface AgentRuntimeToolDescriptor {
22
- name: AgentRuntimeToolName;
23
- domain: typeof AGENT_RUNTIME_DOMAIN;
24
- pack: typeof AGENT_RUNTIME_PACK_ID;
25
- version: typeof AGENT_RUNTIME_PACK_VERSION;
26
- permission: AgentRuntimeToolPermission;
27
- required_scopes: ToolScope[];
28
- entry: string;
29
- }
30
-
31
- export interface AgentRuntimeToolDescriptorInput {
32
- name: AgentRuntimeToolDescriptor['name'];
33
- permission: AgentRuntimeToolDescriptor['permission'];
34
- required_scopes: AgentRuntimeToolDescriptor['required_scopes'];
35
- entry: AgentRuntimeToolDescriptor['entry'];
36
- }
37
-
38
- export function createAgentRuntimeToolDescriptor(
39
- input: AgentRuntimeToolDescriptorInput,
40
- ): AgentRuntimeToolDescriptor {
41
- return {
42
- ...input,
43
- domain: AGENT_RUNTIME_DOMAIN,
44
- pack: AGENT_RUNTIME_PACK_ID,
45
- version: AGENT_RUNTIME_PACK_VERSION,
46
- };
47
- }