@lumenflow/cli 5.4.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 (227) 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 +191 -9
  7. package/dist/gate-defaults.js.map +1 -1
  8. package/dist/gate-registry.js.map +1 -1
  9. package/dist/gates/monolithic-file-contention-guard.js +167 -0
  10. package/dist/gates/monolithic-file-contention-guard.js.map +1 -0
  11. package/dist/gates/prod-migration-drift.js +207 -0
  12. package/dist/gates/prod-migration-drift.js.map +1 -0
  13. package/dist/gates/test-over-deletion-guard.js +255 -0
  14. package/dist/gates/test-over-deletion-guard.js.map +1 -0
  15. package/dist/gates-runners.js +401 -2
  16. package/dist/gates-runners.js.map +1 -1
  17. package/dist/gates.js +349 -4
  18. package/dist/gates.js.map +1 -1
  19. package/dist/lumenflow-setup.js +144 -0
  20. package/dist/lumenflow-setup.js.map +1 -0
  21. package/dist/lumenflow-upgrade.js +2 -1
  22. package/dist/lumenflow-upgrade.js.map +1 -1
  23. package/dist/mem-create.js +10 -1
  24. package/dist/mem-create.js.map +1 -1
  25. package/dist/mem-signal.js +21 -4
  26. package/dist/mem-signal.js.map +1 -1
  27. package/dist/metrics-cli.js +19 -2
  28. package/dist/metrics-cli.js.map +1 -1
  29. package/dist/metrics-snapshot.js +25 -2
  30. package/dist/metrics-snapshot.js.map +1 -1
  31. package/dist/orchestrate-initiative.js +28 -3
  32. package/dist/orchestrate-initiative.js.map +1 -1
  33. package/dist/public-manifest.js +17 -0
  34. package/dist/public-manifest.js.map +1 -1
  35. package/dist/release.js +53 -18
  36. package/dist/release.js.map +1 -1
  37. package/dist/wu-done-gates.js +121 -8
  38. package/dist/wu-done-gates.js.map +1 -1
  39. package/dist/wu-done.js +30 -6
  40. package/dist/wu-done.js.map +1 -1
  41. package/dist/wu-edit-operations.js +74 -0
  42. package/dist/wu-edit-operations.js.map +1 -1
  43. package/dist/wu-edit-validators.js +58 -0
  44. package/dist/wu-edit-validators.js.map +1 -1
  45. package/dist/wu-edit.js +106 -4
  46. package/dist/wu-edit.js.map +1 -1
  47. package/dist/wu-prep.js +132 -8
  48. package/dist/wu-prep.js.map +1 -1
  49. package/dist/wu-recover.js +6 -0
  50. package/dist/wu-recover.js.map +1 -1
  51. package/dist/wu-release.js +120 -2
  52. package/dist/wu-release.js.map +1 -1
  53. package/dist/wu-sizing-validation.js +47 -17
  54. package/dist/wu-sizing-validation.js.map +1 -1
  55. package/dist/wu-status.js +33 -0
  56. package/dist/wu-status.js.map +1 -1
  57. package/package.json +13 -11
  58. package/packs/agent-runtime/package.json +1 -1
  59. package/packs/sidekick/package.json +1 -1
  60. package/packs/software-delivery/package.json +1 -1
  61. package/templates/core/AGENTS.md.template +162 -26
  62. package/templates/core/LUMENFLOW.md.template +381 -70
  63. package/templates/core/ai/onboarding/agent-invocation-guide.md.template +0 -5
  64. package/templates/core/ai/onboarding/agent-safety-card.md.template +63 -17
  65. package/templates/core/ai/onboarding/initiative-orchestration.md.template +4 -0
  66. package/templates/core/ai/onboarding/release-process.md.template +7 -7
  67. package/templates/core/ai/onboarding/vendor-support.md.template +74 -10
  68. package/templates/vendors/claude/.claude/skills/frontend-design/SKILL.md.template +1 -1
  69. package/templates/vendors/claude/.claude/skills/wu-lifecycle/SKILL.md.template +28 -0
  70. package/packs/agent-runtime/agent-heartbeat.ts +0 -163
  71. package/packs/agent-runtime/auto-session-integration.ts +0 -888
  72. package/packs/agent-runtime/capability-factory.ts +0 -104
  73. package/packs/agent-runtime/constants.ts +0 -21
  74. package/packs/agent-runtime/delegation-registry-schema.ts +0 -220
  75. package/packs/agent-runtime/delegation-registry-store.ts +0 -269
  76. package/packs/agent-runtime/delegation-tree.ts +0 -328
  77. package/packs/agent-runtime/index.ts +0 -20
  78. package/packs/agent-runtime/manifest.ts +0 -348
  79. package/packs/agent-runtime/memory-coordination-contract.ts +0 -86
  80. package/packs/agent-runtime/orchestration.ts +0 -2027
  81. package/packs/agent-runtime/pack-registration.ts +0 -110
  82. package/packs/agent-runtime/policy-factory.ts +0 -165
  83. package/packs/agent-runtime/remote-controls/index.ts +0 -7
  84. package/packs/agent-runtime/remote-controls/operations.ts +0 -405
  85. package/packs/agent-runtime/remote-controls/port.ts +0 -48
  86. package/packs/agent-runtime/remote-controls/state-store.ts +0 -258
  87. package/packs/agent-runtime/remote-controls/types.ts +0 -105
  88. package/packs/agent-runtime/session-schema.ts +0 -467
  89. package/packs/agent-runtime/tool-impl/agent-turn-tools.ts +0 -793
  90. package/packs/agent-runtime/tool-impl/index.ts +0 -6
  91. package/packs/agent-runtime/tool-impl/provider-adapters.ts +0 -1245
  92. package/packs/agent-runtime/tool-impl/remote-controls.mock.ts +0 -256
  93. package/packs/agent-runtime/tool-impl/remote-controls.ts +0 -273
  94. package/packs/agent-runtime/tools/index.ts +0 -4
  95. package/packs/agent-runtime/tools/types.ts +0 -47
  96. package/packs/agent-runtime/turn-lifecycle-events.ts +0 -590
  97. package/packs/agent-runtime/types.ts +0 -128
  98. package/packs/agent-runtime/vitest.config.ts +0 -11
  99. package/packs/sidekick/channel-ingress.ts +0 -137
  100. package/packs/sidekick/constants.ts +0 -10
  101. package/packs/sidekick/index.ts +0 -8
  102. package/packs/sidekick/manifest-schema.ts +0 -49
  103. package/packs/sidekick/manifest.ts +0 -512
  104. package/packs/sidekick/pack-registration.ts +0 -110
  105. package/packs/sidekick/policy-factory.ts +0 -38
  106. package/packs/sidekick/sidekick-events.ts +0 -694
  107. package/packs/sidekick/src/adapters/cloud-queue.ts +0 -101
  108. package/packs/sidekick/src/adapters/control-plane-bridge.adapter.ts +0 -386
  109. package/packs/sidekick/src/adapters/filesystem-bridge.adapter.ts +0 -228
  110. package/packs/sidekick/src/domain/channel.types.ts +0 -64
  111. package/packs/sidekick/src/ports/channel-bridge.port.ts +0 -92
  112. package/packs/sidekick/src/routines/commit.ts +0 -74
  113. package/packs/sidekick/tool-impl/channel-tools.ts +0 -577
  114. package/packs/sidekick/tool-impl/channel-transports.ts +0 -75
  115. package/packs/sidekick/tool-impl/index.ts +0 -29
  116. package/packs/sidekick/tool-impl/memory-tools.ts +0 -290
  117. package/packs/sidekick/tool-impl/routine-commit.ts +0 -102
  118. package/packs/sidekick/tool-impl/routine-tools.ts +0 -440
  119. package/packs/sidekick/tool-impl/runtime-context.ts +0 -28
  120. package/packs/sidekick/tool-impl/shared.ts +0 -125
  121. package/packs/sidekick/tool-impl/storage.ts +0 -325
  122. package/packs/sidekick/tool-impl/system-tools.ts +0 -160
  123. package/packs/sidekick/tool-impl/task-tools.ts +0 -506
  124. package/packs/sidekick/tools/channel-tools.ts +0 -53
  125. package/packs/sidekick/tools/index.ts +0 -9
  126. package/packs/sidekick/tools/memory-tools.ts +0 -53
  127. package/packs/sidekick/tools/routine-tools.ts +0 -53
  128. package/packs/sidekick/tools/system-tools.ts +0 -47
  129. package/packs/sidekick/tools/task-tools.ts +0 -61
  130. package/packs/sidekick/tools/types.ts +0 -57
  131. package/packs/sidekick/vitest.config.ts +0 -11
  132. package/packs/software-delivery/constants.ts +0 -10
  133. package/packs/software-delivery/extensions.ts +0 -140
  134. package/packs/software-delivery/gate-policies.ts +0 -134
  135. package/packs/software-delivery/index.ts +0 -8
  136. package/packs/software-delivery/manifest-schema.ts +0 -268
  137. package/packs/software-delivery/manifest.ts +0 -657
  138. package/packs/software-delivery/pack-registration.ts +0 -113
  139. package/packs/software-delivery/src/commands/index.ts +0 -5
  140. package/packs/software-delivery/src/config/delivery-review-contract.ts +0 -256
  141. package/packs/software-delivery/src/config/env-accessors.ts +0 -66
  142. package/packs/software-delivery/src/config/index.ts +0 -8
  143. package/packs/software-delivery/src/config/normalize-config-keys.ts +0 -9
  144. package/packs/software-delivery/src/config/schemas/lumenflow-config-schema-types.ts +0 -460
  145. package/packs/software-delivery/src/config/workspace-reader.ts +0 -375
  146. package/packs/software-delivery/src/constants/backlog-patterns.ts +0 -31
  147. package/packs/software-delivery/src/constants/client-ids.ts +0 -19
  148. package/packs/software-delivery/src/constants/config-contract.ts +0 -7
  149. package/packs/software-delivery/src/constants/docs-layout-presets.ts +0 -50
  150. package/packs/software-delivery/src/constants/duration-constants.ts +0 -20
  151. package/packs/software-delivery/src/constants/gate-constants.ts +0 -32
  152. package/packs/software-delivery/src/constants/index.ts +0 -29
  153. package/packs/software-delivery/src/constants/lock-constants.ts +0 -35
  154. package/packs/software-delivery/src/constants/object-guards.ts +0 -12
  155. package/packs/software-delivery/src/constants/section-headings.ts +0 -107
  156. package/packs/software-delivery/src/constants/wu-cli-constants.ts +0 -488
  157. package/packs/software-delivery/src/constants/wu-domain-constants.ts +0 -466
  158. package/packs/software-delivery/src/constants/wu-git-constants.ts +0 -7
  159. package/packs/software-delivery/src/constants/wu-id-format.ts +0 -327
  160. package/packs/software-delivery/src/constants/wu-paths-constants.ts +0 -384
  161. package/packs/software-delivery/src/constants/wu-statuses.ts +0 -287
  162. package/packs/software-delivery/src/constants/wu-type-helpers.ts +0 -67
  163. package/packs/software-delivery/src/constants/wu-ui-constants.ts +0 -267
  164. package/packs/software-delivery/src/constants/wu-validation-constants.ts +0 -73
  165. package/packs/software-delivery/src/domain/index.ts +0 -5
  166. package/packs/software-delivery/src/domain/orchestration.constants.ts +0 -166
  167. package/packs/software-delivery/src/domain/orchestration.schemas.ts +0 -238
  168. package/packs/software-delivery/src/domain/orchestration.types.ts +0 -176
  169. package/packs/software-delivery/src/methodology/incremental-test.ts +0 -122
  170. package/packs/software-delivery/src/methodology/index.ts +0 -6
  171. package/packs/software-delivery/src/methodology/manual-test-validator.ts +0 -292
  172. package/packs/software-delivery/src/policy/coverage-gate.ts +0 -270
  173. package/packs/software-delivery/src/policy/gates-agent-mode.ts +0 -223
  174. package/packs/software-delivery/src/policy/gates-config-internal.ts +0 -121
  175. package/packs/software-delivery/src/policy/gates-config.ts +0 -300
  176. package/packs/software-delivery/src/policy/gates-coverage.ts +0 -356
  177. package/packs/software-delivery/src/policy/gates-presets.ts +0 -134
  178. package/packs/software-delivery/src/policy/gates-schemas.ts +0 -173
  179. package/packs/software-delivery/src/policy/index.ts +0 -22
  180. package/packs/software-delivery/src/policy/package-manager-resolver.ts +0 -319
  181. package/packs/software-delivery/src/policy/resolve-policy.ts +0 -601
  182. package/packs/software-delivery/src/ports/config.ports.ts +0 -90
  183. package/packs/software-delivery/src/ports/dashboard-renderer.port.ts +0 -125
  184. package/packs/software-delivery/src/ports/index.ts +0 -10
  185. package/packs/software-delivery/src/ports/sync-validator.ports.ts +0 -59
  186. package/packs/software-delivery/src/ports/wu-helpers.ports.ts +0 -168
  187. package/packs/software-delivery/src/ports/wu-state.ports.ts +0 -241
  188. package/packs/software-delivery/src/primitives/index.ts +0 -5
  189. package/packs/software-delivery/src/runtime/index.ts +0 -6
  190. package/packs/software-delivery/src/runtime/work-classifier.ts +0 -561
  191. package/packs/software-delivery/src/sandbox/index.ts +0 -10
  192. package/packs/software-delivery/src/sandbox/sandbox-allowlist.ts +0 -118
  193. package/packs/software-delivery/src/sandbox/sandbox-backend-linux.ts +0 -88
  194. package/packs/software-delivery/src/sandbox/sandbox-backend-macos.ts +0 -154
  195. package/packs/software-delivery/src/sandbox/sandbox-backend-windows.ts +0 -47
  196. package/packs/software-delivery/src/sandbox/sandbox-profile.ts +0 -153
  197. package/packs/software-delivery/src/schemas/index.ts +0 -5
  198. package/packs/software-delivery/src/state/date-utils.ts +0 -158
  199. package/packs/software-delivery/src/state/index.ts +0 -15
  200. package/packs/software-delivery/src/state/state-machine.ts +0 -119
  201. package/packs/software-delivery/src/state/wu-doc-types.ts +0 -51
  202. package/packs/software-delivery/src/state/wu-paths.ts +0 -381
  203. package/packs/software-delivery/src/state/wu-schema.ts +0 -1139
  204. package/packs/software-delivery/src/state/wu-state-schema.ts +0 -255
  205. package/packs/software-delivery/src/state/wu-yaml.ts +0 -338
  206. package/packs/software-delivery/tool-impl/agent-tools.ts +0 -263
  207. package/packs/software-delivery/tool-impl/delegation-tools.ts +0 -66
  208. package/packs/software-delivery/tool-impl/flow-metrics-tools.ts +0 -219
  209. package/packs/software-delivery/tool-impl/git-runner.ts +0 -113
  210. package/packs/software-delivery/tool-impl/git-tools.ts +0 -316
  211. package/packs/software-delivery/tool-impl/index.ts +0 -15
  212. package/packs/software-delivery/tool-impl/initiative-orchestration-tools.ts +0 -720
  213. package/packs/software-delivery/tool-impl/lane-lock.ts +0 -246
  214. package/packs/software-delivery/tool-impl/memory-tools.ts +0 -470
  215. package/packs/software-delivery/tool-impl/pending-runtime-tools.ts +0 -21
  216. package/packs/software-delivery/tool-impl/runtime-cli-adapter.ts +0 -329
  217. package/packs/software-delivery/tool-impl/runtime-native-tools.ts +0 -687
  218. package/packs/software-delivery/tool-impl/worker-loader.ts +0 -52
  219. package/packs/software-delivery/tool-impl/worktree-tools.ts +0 -46
  220. package/packs/software-delivery/tool-impl/wu-lifecycle-tools.ts +0 -807
  221. package/packs/software-delivery/tools/delegation-tools.ts +0 -23
  222. package/packs/software-delivery/tools/git-tools.ts +0 -55
  223. package/packs/software-delivery/tools/index.ts +0 -8
  224. package/packs/software-delivery/tools/lane-lock-tool.ts +0 -37
  225. package/packs/software-delivery/tools/types.ts +0 -71
  226. package/packs/software-delivery/tools/worktree-tools.ts +0 -49
  227. package/packs/software-delivery/vitest.config.ts +0 -11
@@ -1,228 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- /**
5
- * WU-2735 (INIT-060 WU-7a, ADR-013 §ChannelBridge):
6
- * Filesystem implementation of the ChannelBridge port.
7
- *
8
- * Backing layout:
9
- *
10
- * <rootDir>/channels/<channel-id>/envelopes.jsonl
11
- * <rootDir>/channels/<channel-id>/config.json
12
- * <rootDir>/registry.json (BridgeConfig identity → ChannelId)
13
- *
14
- * Writes are atomic: a new envelope is written to a per-pid tmp file and
15
- * `rename(2)`'d on top of a sibling, then append to the JSONL via
16
- * `appendFile` with `O_APPEND` semantics (Node delegates to the kernel, which
17
- * guarantees single-write atomicity for writes below PIPE_BUF; our JSON lines
18
- * sit well below that for realistic envelopes and we additionally bound the
19
- * write under a per-channel in-process mutex).
20
- *
21
- * The adapter is deliberately minimal: the sidekick pack's transport registry
22
- * (`channel-transports.ts`) remains the runtime dispatch path for the existing
23
- * `channel:send` tool; WU-2735 lands the port/adapter skeleton only.
24
- */
25
-
26
- import { createHash } from 'node:crypto';
27
- import { appendFile, mkdir, readFile, writeFile } from 'node:fs/promises';
28
- import path from 'node:path';
29
-
30
- import type {
31
- BridgeConfig,
32
- ChannelEnvelope,
33
- ChannelId,
34
- SendResult,
35
- } from '../domain/channel.types.js';
36
- import type { ChannelBridge } from '../ports/channel-bridge.port.js';
37
-
38
- // ---------------------------------------------------------------------------
39
- // Configuration surface
40
- // ---------------------------------------------------------------------------
41
-
42
- export interface FilesystemChannelBridgeOptions {
43
- /**
44
- * Directory under which the bridge materialises channel state. Tests set
45
- * this to a tmpdir; in production the caller passes
46
- * `.lumenflow/state/packs/sidekick/` (or equivalent per ADR-013).
47
- */
48
- rootDir: string;
49
- }
50
-
51
- interface RegistryEntry {
52
- id: ChannelId;
53
- provider: string;
54
- name: string;
55
- options_hash: string;
56
- }
57
-
58
- interface Registry {
59
- entries: RegistryEntry[];
60
- }
61
-
62
- // ---------------------------------------------------------------------------
63
- // Internal helpers
64
- // ---------------------------------------------------------------------------
65
-
66
- const REGISTRY_FILENAME = 'registry.json';
67
- const CHANNELS_SUBDIR = 'channels';
68
- const ENVELOPES_FILENAME = 'envelopes.jsonl';
69
- const CONFIG_FILENAME = 'config.json';
70
-
71
- function hashOptions(options: Record<string, unknown> | undefined): string {
72
- const payload = JSON.stringify(options ?? {}, Object.keys(options ?? {}).sort());
73
- return createHash('sha256').update(payload).digest('hex').slice(0, 16);
74
- }
75
-
76
- function mintChannelId(config: BridgeConfig): ChannelId {
77
- // Deterministic id per (provider, name, options) — stable across bridge
78
- // instances backed by the same rootDir so `register` is idempotent even on
79
- // cold start without reading the registry.
80
- const payload = `${config.provider}::${config.name}::${hashOptions(config.options as Record<string, unknown> | undefined)}`;
81
- const digest = createHash('sha256').update(payload).digest('hex').slice(0, 24);
82
- return `chan-${digest}` as ChannelId;
83
- }
84
-
85
- async function readRegistry(registryPath: string): Promise<Registry> {
86
- try {
87
- const raw = await readFile(registryPath, 'utf8');
88
- return JSON.parse(raw) as Registry;
89
- } catch (error) {
90
- const err = error as NodeJS.ErrnoException;
91
- if (err.code === 'ENOENT') {
92
- return { entries: [] };
93
- }
94
- throw error;
95
- }
96
- }
97
-
98
- async function writeRegistryAtomic(registryPath: string, registry: Registry): Promise<void> {
99
- await mkdir(path.dirname(registryPath), { recursive: true });
100
- const tmpPath = `${registryPath}.tmp-${process.pid}-${Date.now()}`;
101
- await writeFile(tmpPath, JSON.stringify(registry, null, 2), 'utf8');
102
- const { rename } = await import('node:fs/promises');
103
- await rename(tmpPath, registryPath);
104
- }
105
-
106
- // Per-bridge-instance lock map so concurrent send() calls on a single channel
107
- // serialise their appends. Filesystem atomicity still holds under crash, but
108
- // the mutex ensures emit order is preserved (ADR-013 §3).
109
- function createLockGate(): {
110
- withLock<T>(key: string, fn: () => Promise<T>): Promise<T>;
111
- } {
112
- const chains = new Map<string, Promise<unknown>>();
113
- return {
114
- async withLock<T>(key: string, fn: () => Promise<T>): Promise<T> {
115
- const previous = chains.get(key) ?? Promise.resolve();
116
- const next = previous.then(fn, fn);
117
- chains.set(
118
- key,
119
- next.then(
120
- () => undefined,
121
- () => undefined,
122
- ),
123
- );
124
- return next as Promise<T>;
125
- },
126
- };
127
- }
128
-
129
- // ---------------------------------------------------------------------------
130
- // Adapter factory
131
- // ---------------------------------------------------------------------------
132
-
133
- export function createFilesystemChannelBridge(
134
- options: FilesystemChannelBridgeOptions,
135
- ): ChannelBridge {
136
- const rootDir = path.resolve(options.rootDir);
137
- const registryPath = path.join(rootDir, REGISTRY_FILENAME);
138
- const lockGate = createLockGate();
139
- const disconnected = new Set<ChannelId>();
140
-
141
- function channelDir(id: ChannelId): string {
142
- return path.join(rootDir, CHANNELS_SUBDIR, id);
143
- }
144
-
145
- async function ensureRegistered(config: BridgeConfig): Promise<ChannelId> {
146
- const registry = await readRegistry(registryPath);
147
- const id = mintChannelId(config);
148
- const optionsHash = hashOptions(config.options as Record<string, unknown> | undefined);
149
- const existing = registry.entries.find((entry) => entry.id === id);
150
- if (existing) {
151
- return existing.id;
152
- }
153
-
154
- registry.entries.push({
155
- id,
156
- provider: config.provider,
157
- name: config.name,
158
- options_hash: optionsHash,
159
- });
160
- await writeRegistryAtomic(registryPath, registry);
161
-
162
- const dir = channelDir(id);
163
- await mkdir(dir, { recursive: true });
164
- await writeFile(
165
- path.join(dir, CONFIG_FILENAME),
166
- JSON.stringify({ provider: config.provider, name: config.name }, null, 2),
167
- 'utf8',
168
- );
169
- return id;
170
- }
171
-
172
- async function assertActive(channelId: ChannelId): Promise<void> {
173
- if (disconnected.has(channelId)) {
174
- throw new Error(`ChannelBridge: channel ${channelId} is disconnected; send rejected.`);
175
- }
176
- const registry = await readRegistry(registryPath);
177
- if (!registry.entries.some((entry) => entry.id === channelId)) {
178
- throw new Error(`ChannelBridge: channel ${channelId} is not registered.`);
179
- }
180
- }
181
-
182
- return {
183
- async connect(bridgeConfig: BridgeConfig): Promise<ChannelId> {
184
- return ensureRegistered(bridgeConfig);
185
- },
186
-
187
- async register(bridgeConfig: BridgeConfig): Promise<ChannelId> {
188
- return ensureRegistered(bridgeConfig);
189
- },
190
-
191
- async send(channelId: ChannelId, envelope: ChannelEnvelope): Promise<SendResult> {
192
- await assertActive(channelId);
193
- const envelopesPath = path.join(channelDir(channelId), ENVELOPES_FILENAME);
194
- await lockGate.withLock(channelId, async () => {
195
- await mkdir(path.dirname(envelopesPath), { recursive: true });
196
- await appendFile(envelopesPath, `${JSON.stringify(envelope)}\n`, 'utf8');
197
- });
198
- return { accepted: true, delivery_id: envelope.id };
199
- },
200
-
201
- async *receive(channelId: ChannelId): AsyncIterable<ChannelEnvelope> {
202
- if (disconnected.has(channelId)) {
203
- return;
204
- }
205
- const envelopesPath = path.join(channelDir(channelId), ENVELOPES_FILENAME);
206
- let raw: string;
207
- try {
208
- raw = await readFile(envelopesPath, 'utf8');
209
- } catch (error) {
210
- const err = error as NodeJS.ErrnoException;
211
- if (err.code === 'ENOENT') {
212
- return;
213
- }
214
- throw error;
215
- }
216
- for (const line of raw.split('\n')) {
217
- if (line.length === 0) {
218
- continue;
219
- }
220
- yield JSON.parse(line) as ChannelEnvelope;
221
- }
222
- },
223
-
224
- async disconnect(channelId: ChannelId): Promise<void> {
225
- disconnected.add(channelId);
226
- },
227
- };
228
- }
@@ -1,64 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- /**
5
- * WU-2735 (INIT-060 WU-7a) + WU-2831 (INIT-062 WU-E):
6
- * Domain types for the sidekick ChannelBridge adapters.
7
- *
8
- * As of WU-2831 the port-level identity, config, and send-result shapes are
9
- * canonical in @lumenflow/conductor-sdk (LumenFlow Proprietary). This file re-exports
10
- * those types so sidekick adapters implement the neutral port without
11
- * parallel contract drift.
12
- *
13
- * The internal `EnvelopeKind` + `ChannelEnvelope` shape below remains the
14
- * sidekick-pack wire format: it predates the canonical port and is retained
15
- * for on-disk/control-plane compatibility of existing adapters. New
16
- * implementers (e.g. the cloud phone bridge) SHOULD consume
17
- * `@lumenflow/conductor-sdk`'s `ChannelEnvelope` instead.
18
- */
19
-
20
- // Re-export canonical port types from the LumenFlow Proprietary conductor SDK.
21
- export type {
22
- BackpressurePolicy,
23
- BridgeConfig,
24
- ChannelId,
25
- ChannelIdentity,
26
- DeliveryGuarantee,
27
- IdentityResolver,
28
- SendResult,
29
- } from '@lumenflow/conductor-sdk';
30
-
31
- /**
32
- * Envelope dispatch classification — sidekick-internal wire format.
33
- *
34
- * Predates the canonical `BackpressurePolicy` enum in conductor-sdk.
35
- * Maps: `ephemeral` ↔ `ephemeral`, `queue` ↔ `buffered` (conductor-sdk).
36
- *
37
- * - `ephemeral` — observational; may fail-silent when transport is down.
38
- * - `queue` — commands / approvals; must be queued and replayed on reconnect.
39
- */
40
- export type EnvelopeKind = 'ephemeral' | 'queue';
41
-
42
- /**
43
- * A channel envelope (sidekick-internal wire format).
44
- * Transport-agnostic: `body` is an opaque JSON-serialisable payload,
45
- * `content_type` labels it so receivers can dispatch without snooping the body.
46
- *
47
- * Note: the canonical port-level envelope is
48
- * `@lumenflow/conductor-sdk`'s `ChannelEnvelope` (uses `policy` field).
49
- * Adapters translate between the two when bridging across the Apache boundary.
50
- */
51
- export interface ChannelEnvelope {
52
- /** Unique id per envelope (content-hash or uuid — chosen by the emitter). */
53
- id: string;
54
- /** Pack-internal backpressure classification. */
55
- kind: EnvelopeKind;
56
- /** MIME-like content descriptor, e.g. `application/json`, `text/plain`. */
57
- content_type: string;
58
- /** Payload. JSON-serialisable; no host-specific handles. */
59
- body: unknown;
60
- /** ISO-8601 UTC timestamp of emit; per-channel ordering key (ADR-013 §3). */
61
- emitted_at: string;
62
- /** Optional emitter-supplied metadata (trace ids, correlation keys). */
63
- metadata?: Readonly<Record<string, unknown>>;
64
- }
@@ -1,92 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- /**
5
- * WU-2735 (INIT-060 WU-7a, ADR-013 §ChannelBridge) + WU-2831 (INIT-062 WU-E):
6
- *
7
- * Sidekick-pack ChannelBridge port.
8
- *
9
- * As of WU-2831 the canonical neutral port lives in `@lumenflow/conductor-sdk`
10
- * under LumenFlow Proprietary — consumers that need an Proprietary-free surface (e.g. the
11
- * cloud phone bridge) MUST import from there. The sidekick port below reuses
12
- * the conductor-sdk identity / config / result types (no parallel drift) but
13
- * keeps the pack-internal wire-format envelope (`ChannelEnvelope` with
14
- * `kind: 'ephemeral' | 'queue'`) for on-disk and control-plane compatibility
15
- * of existing adapters.
16
- *
17
- * Port contract — load-bearing across adapters (ADR-013 §ChannelBridge):
18
- *
19
- * - `send` is at-least-once for `queue` envelopes, fail-silent for
20
- * `ephemeral` envelopes (ADR-013 §4 backpressure split).
21
- * - `receive` yields envelopes in emit order on a single channel (§3). No
22
- * cross-channel ordering guarantee.
23
- * - `connect` (alias: `register`) is idempotent on `BridgeConfig` identity —
24
- * same `(provider, name)` returns the same `ChannelId`.
25
- * - `disconnect` flushes queued envelopes before closing; in-flight ephemerals
26
- * may drop.
27
- *
28
- * The port MUST NOT leak filesystem- or network-specific types.
29
- */
30
-
31
- import type {
32
- BridgeConfig,
33
- ChannelEnvelope,
34
- ChannelId,
35
- SendResult,
36
- } from '../domain/channel.types.js';
37
-
38
- export interface ChannelBridge {
39
- /**
40
- * Open (or reuse) a channel. Idempotent on `(provider, name)`.
41
- *
42
- * Canonical method name per the neutral conductor-sdk port (WU-2831).
43
- */
44
- connect(bridgeConfig: BridgeConfig): Promise<ChannelId>;
45
-
46
- /**
47
- * Legacy alias for `connect`. Retained for pack-internal call sites that
48
- * predate WU-2831.
49
- *
50
- * @deprecated Use `connect` instead (WU-2831 port-contract alignment).
51
- */
52
- register(bridgeConfig: BridgeConfig): Promise<ChannelId>;
53
-
54
- /**
55
- * Send an envelope on a registered channel.
56
- *
57
- * @throws if `channelId` is not registered, or has been disconnected.
58
- */
59
- send(channelId: ChannelId, envelope: ChannelEnvelope): Promise<SendResult>;
60
-
61
- /**
62
- * Stream envelopes on the given channel in emit order. The iterator
63
- * terminates after `disconnect(channelId)`; otherwise it is long-lived.
64
- */
65
- receive(channelId: ChannelId): AsyncIterable<ChannelEnvelope>;
66
-
67
- /**
68
- * Close the channel. Queued envelopes flush before this resolves; ephemerals
69
- * in flight may be dropped.
70
- */
71
- disconnect(channelId: ChannelId): Promise<void>;
72
- }
73
-
74
- /**
75
- * Structural type guard. Useful for adapter tests and runtime payload
76
- * validation at the port boundary.
77
- */
78
- export function isChannelEnvelope(value: unknown): value is ChannelEnvelope {
79
- if (!value || typeof value !== 'object') {
80
- return false;
81
- }
82
- const v = value as Record<string, unknown>;
83
- return (
84
- typeof v.id === 'string' &&
85
- (v.kind === 'ephemeral' || v.kind === 'queue') &&
86
- typeof v.content_type === 'string' &&
87
- 'body' in v &&
88
- typeof v.emitted_at === 'string'
89
- );
90
- }
91
-
92
- export type { BridgeConfig, ChannelEnvelope, ChannelId, SendResult };
@@ -1,74 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- /**
5
- * WU-2738 (INIT-060, ADR-013 §6 governance): plan-to-commit envelope +
6
- * content-hash helpers for the governed sidekick:routine:commit_plan
7
- * tool. The commit envelope is what an agent attestation carries; the
8
- * content-hash is what lands on the audit trail so cloud can correlate
9
- * a `sidekick:routine_committed` event with the originating envelope
10
- * without the PII-bearing body ever leaving the local workspace.
11
- */
12
-
13
- import { createHash } from 'node:crypto';
14
- import type { RoutineRecord } from '../../tool-impl/storage.js';
15
-
16
- const CONTENT_HASH_ALGORITHM = 'sha256';
17
- const CONTENT_HASH_ENCODING = 'hex';
18
-
19
- export interface RoutineCommitAttestation {
20
- actor: string;
21
- reason: string;
22
- // Intentionally untyped extension slot: attestation may carry arbitrary
23
- // operator-supplied metadata which can contain PII. The envelope hash
24
- // covers the entire attestation; the body never appears on the audit
25
- // event surface.
26
- [key: string]: unknown;
27
- }
28
-
29
- export interface RoutineCommitEnvelope {
30
- plan_id: string;
31
- routine_name: string;
32
- step_count: number;
33
- committed_at: string;
34
- attestation: RoutineCommitAttestation;
35
- }
36
-
37
- export interface BuildRoutineCommitEnvelopeInput {
38
- routine: RoutineRecord;
39
- attestation: RoutineCommitAttestation;
40
- committedAt: string;
41
- }
42
-
43
- export function buildRoutineCommitEnvelope(
44
- input: BuildRoutineCommitEnvelopeInput,
45
- ): RoutineCommitEnvelope {
46
- return {
47
- plan_id: input.routine.id,
48
- routine_name: input.routine.name,
49
- step_count: input.routine.steps.length,
50
- committed_at: input.committedAt,
51
- attestation: { ...input.attestation },
52
- };
53
- }
54
-
55
- function canonicalize(value: unknown): unknown {
56
- if (Array.isArray(value)) {
57
- return value.map((entry) => canonicalize(entry));
58
- }
59
- if (value && typeof value === 'object') {
60
- const record = value as Record<string, unknown>;
61
- const sortedKeys = Object.keys(record).sort();
62
- const result: Record<string, unknown> = {};
63
- for (const key of sortedKeys) {
64
- result[key] = canonicalize(record[key]);
65
- }
66
- return result;
67
- }
68
- return value;
69
- }
70
-
71
- export function hashRoutineCommitEnvelope(envelope: RoutineCommitEnvelope): string {
72
- const canonical = JSON.stringify(canonicalize(envelope));
73
- return createHash(CONTENT_HASH_ALGORITHM).update(canonical).digest(CONTENT_HASH_ENCODING);
74
- }