@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.
- package/README.md +41 -40
- package/dist/db-journal-recover.js +400 -0
- package/dist/db-journal-recover.js.map +1 -0
- package/dist/docs-sync.js +8 -3
- package/dist/docs-sync.js.map +1 -1
- package/dist/doctor.js +11 -0
- package/dist/doctor.js.map +1 -1
- package/dist/gate-defaults.js +37 -0
- package/dist/gate-defaults.js.map +1 -1
- package/dist/gates/monolithic-file-contention-guard.js +167 -0
- package/dist/gates/monolithic-file-contention-guard.js.map +1 -0
- package/dist/gates/prod-migration-drift.js +207 -0
- package/dist/gates/prod-migration-drift.js.map +1 -0
- package/dist/gates/test-over-deletion-guard.js +280 -0
- package/dist/gates/test-over-deletion-guard.js.map +1 -0
- package/dist/gates-runners.js +44 -3
- package/dist/gates-runners.js.map +1 -1
- package/dist/gates.js +3 -2
- package/dist/gates.js.map +1 -1
- package/dist/hooks/config-resolver.js +16 -1
- package/dist/hooks/config-resolver.js.map +1 -1
- package/dist/hooks/dirty-guard.js +43 -2
- package/dist/hooks/dirty-guard.js.map +1 -1
- package/dist/hooks/git-status-parser.js +22 -8
- package/dist/hooks/git-status-parser.js.map +1 -1
- package/dist/init-templates.js +241 -0
- package/dist/init-templates.js.map +1 -1
- package/dist/init.js +122 -16
- package/dist/init.js.map +1 -1
- package/dist/lumenflow-setup.js +144 -0
- package/dist/lumenflow-setup.js.map +1 -0
- package/dist/lumenflow-upgrade.js +43 -1
- package/dist/lumenflow-upgrade.js.map +1 -1
- package/dist/mem-create.js +10 -1
- package/dist/mem-create.js.map +1 -1
- package/dist/mem-signal.js +21 -4
- package/dist/mem-signal.js.map +1 -1
- package/dist/orchestrate-initiative.js +28 -3
- package/dist/orchestrate-initiative.js.map +1 -1
- package/dist/public-manifest.js +17 -7
- package/dist/public-manifest.js.map +1 -1
- package/dist/release.js +53 -18
- package/dist/release.js.map +1 -1
- package/dist/wu-done-gates.js +13 -9
- package/dist/wu-done-gates.js.map +1 -1
- package/dist/wu-done.js +14 -2
- package/dist/wu-done.js.map +1 -1
- package/dist/wu-edit-operations.js +74 -0
- package/dist/wu-edit-operations.js.map +1 -1
- package/dist/wu-edit-validators.js +58 -0
- package/dist/wu-edit-validators.js.map +1 -1
- package/dist/wu-edit.js +106 -4
- package/dist/wu-edit.js.map +1 -1
- package/dist/wu-prep.js +57 -9
- package/dist/wu-prep.js.map +1 -1
- package/dist/wu-recover.js +6 -0
- package/dist/wu-recover.js.map +1 -1
- package/dist/wu-release.js +120 -2
- package/dist/wu-release.js.map +1 -1
- package/dist/wu-sizing-validation.js +47 -17
- package/dist/wu-sizing-validation.js.map +1 -1
- package/dist/wu-status.js +33 -0
- package/dist/wu-status.js.map +1 -1
- package/package.json +13 -12
- package/packs/agent-runtime/package.json +1 -1
- package/packs/sidekick/package.json +1 -1
- package/packs/software-delivery/package.json +1 -1
- package/templates/core/AGENTS.md.template +67 -3
- package/templates/core/LUMENFLOW.md.template +196 -47
- package/dist/distribution-preflight.js +0 -230
- package/dist/distribution-preflight.js.map +0 -1
- package/packs/agent-runtime/agent-heartbeat.ts +0 -163
- package/packs/agent-runtime/auto-session-integration.ts +0 -888
- package/packs/agent-runtime/capability-factory.ts +0 -104
- package/packs/agent-runtime/constants.ts +0 -21
- package/packs/agent-runtime/delegation-registry-schema.ts +0 -220
- package/packs/agent-runtime/delegation-registry-store.ts +0 -269
- package/packs/agent-runtime/delegation-tree.ts +0 -328
- package/packs/agent-runtime/index.ts +0 -20
- package/packs/agent-runtime/manifest.ts +0 -348
- package/packs/agent-runtime/memory-coordination-contract.ts +0 -86
- package/packs/agent-runtime/orchestration.ts +0 -2027
- package/packs/agent-runtime/pack-registration.ts +0 -110
- package/packs/agent-runtime/policy-factory.ts +0 -165
- package/packs/agent-runtime/remote-controls/index.ts +0 -7
- package/packs/agent-runtime/remote-controls/operations.ts +0 -405
- package/packs/agent-runtime/remote-controls/port.ts +0 -48
- package/packs/agent-runtime/remote-controls/state-store.ts +0 -258
- package/packs/agent-runtime/remote-controls/types.ts +0 -105
- package/packs/agent-runtime/session-schema.ts +0 -467
- package/packs/agent-runtime/tool-impl/agent-turn-tools.ts +0 -793
- package/packs/agent-runtime/tool-impl/index.ts +0 -6
- package/packs/agent-runtime/tool-impl/provider-adapters.ts +0 -1245
- package/packs/agent-runtime/tool-impl/remote-controls.mock.ts +0 -256
- package/packs/agent-runtime/tool-impl/remote-controls.ts +0 -273
- package/packs/agent-runtime/tools/index.ts +0 -4
- package/packs/agent-runtime/tools/types.ts +0 -47
- package/packs/agent-runtime/turn-lifecycle-events.ts +0 -590
- package/packs/agent-runtime/types.ts +0 -128
- package/packs/agent-runtime/vitest.config.ts +0 -11
- package/packs/sidekick/channel-ingress.ts +0 -137
- package/packs/sidekick/constants.ts +0 -10
- package/packs/sidekick/index.ts +0 -8
- package/packs/sidekick/manifest-schema.ts +0 -49
- package/packs/sidekick/manifest.ts +0 -512
- package/packs/sidekick/pack-registration.ts +0 -110
- package/packs/sidekick/policy-factory.ts +0 -38
- package/packs/sidekick/sidekick-events.ts +0 -694
- package/packs/sidekick/src/adapters/cloud-queue.ts +0 -101
- package/packs/sidekick/src/adapters/control-plane-bridge.adapter.ts +0 -386
- package/packs/sidekick/src/adapters/filesystem-bridge.adapter.ts +0 -228
- package/packs/sidekick/src/domain/channel.types.ts +0 -64
- package/packs/sidekick/src/ports/channel-bridge.port.ts +0 -92
- package/packs/sidekick/src/routines/commit.ts +0 -74
- package/packs/sidekick/tool-impl/channel-tools.ts +0 -577
- package/packs/sidekick/tool-impl/channel-transports.ts +0 -75
- package/packs/sidekick/tool-impl/index.ts +0 -29
- package/packs/sidekick/tool-impl/memory-tools.ts +0 -290
- package/packs/sidekick/tool-impl/routine-commit.ts +0 -102
- package/packs/sidekick/tool-impl/routine-tools.ts +0 -440
- package/packs/sidekick/tool-impl/runtime-context.ts +0 -28
- package/packs/sidekick/tool-impl/shared.ts +0 -125
- package/packs/sidekick/tool-impl/storage.ts +0 -325
- package/packs/sidekick/tool-impl/system-tools.ts +0 -160
- package/packs/sidekick/tool-impl/task-tools.ts +0 -506
- package/packs/sidekick/tools/channel-tools.ts +0 -53
- package/packs/sidekick/tools/index.ts +0 -9
- package/packs/sidekick/tools/memory-tools.ts +0 -53
- package/packs/sidekick/tools/routine-tools.ts +0 -53
- package/packs/sidekick/tools/system-tools.ts +0 -47
- package/packs/sidekick/tools/task-tools.ts +0 -61
- package/packs/sidekick/tools/types.ts +0 -57
- package/packs/sidekick/vitest.config.ts +0 -11
- package/packs/software-delivery/constants.ts +0 -10
- package/packs/software-delivery/extensions.ts +0 -140
- package/packs/software-delivery/gate-policies.ts +0 -134
- package/packs/software-delivery/index.ts +0 -8
- package/packs/software-delivery/manifest-schema.ts +0 -268
- package/packs/software-delivery/manifest.ts +0 -657
- package/packs/software-delivery/pack-registration.ts +0 -113
- package/packs/software-delivery/src/commands/index.ts +0 -5
- package/packs/software-delivery/src/config/delivery-review-contract.ts +0 -256
- package/packs/software-delivery/src/config/env-accessors.ts +0 -66
- package/packs/software-delivery/src/config/index.ts +0 -8
- package/packs/software-delivery/src/config/normalize-config-keys.ts +0 -9
- package/packs/software-delivery/src/config/schemas/lumenflow-config-schema-types.ts +0 -460
- package/packs/software-delivery/src/config/workspace-reader.ts +0 -375
- package/packs/software-delivery/src/constants/backlog-patterns.ts +0 -31
- package/packs/software-delivery/src/constants/client-ids.ts +0 -19
- package/packs/software-delivery/src/constants/config-contract.ts +0 -7
- package/packs/software-delivery/src/constants/docs-layout-presets.ts +0 -50
- package/packs/software-delivery/src/constants/duration-constants.ts +0 -20
- package/packs/software-delivery/src/constants/gate-constants.ts +0 -32
- package/packs/software-delivery/src/constants/index.ts +0 -29
- package/packs/software-delivery/src/constants/lock-constants.ts +0 -35
- package/packs/software-delivery/src/constants/object-guards.ts +0 -12
- package/packs/software-delivery/src/constants/section-headings.ts +0 -107
- package/packs/software-delivery/src/constants/wu-cli-constants.ts +0 -500
- package/packs/software-delivery/src/constants/wu-domain-constants.ts +0 -466
- package/packs/software-delivery/src/constants/wu-git-constants.ts +0 -7
- package/packs/software-delivery/src/constants/wu-id-format.ts +0 -327
- package/packs/software-delivery/src/constants/wu-paths-constants.ts +0 -384
- package/packs/software-delivery/src/constants/wu-statuses.ts +0 -287
- package/packs/software-delivery/src/constants/wu-type-helpers.ts +0 -67
- package/packs/software-delivery/src/constants/wu-ui-constants.ts +0 -267
- package/packs/software-delivery/src/constants/wu-validation-constants.ts +0 -73
- package/packs/software-delivery/src/domain/index.ts +0 -5
- package/packs/software-delivery/src/domain/orchestration.constants.ts +0 -166
- package/packs/software-delivery/src/domain/orchestration.schemas.ts +0 -238
- package/packs/software-delivery/src/domain/orchestration.types.ts +0 -176
- package/packs/software-delivery/src/methodology/incremental-test.ts +0 -122
- package/packs/software-delivery/src/methodology/index.ts +0 -6
- package/packs/software-delivery/src/methodology/manual-test-validator.ts +0 -292
- package/packs/software-delivery/src/policy/coverage-gate.ts +0 -270
- package/packs/software-delivery/src/policy/gates-agent-mode.ts +0 -223
- package/packs/software-delivery/src/policy/gates-config-internal.ts +0 -121
- package/packs/software-delivery/src/policy/gates-config.ts +0 -300
- package/packs/software-delivery/src/policy/gates-coverage.ts +0 -356
- package/packs/software-delivery/src/policy/gates-presets.ts +0 -134
- package/packs/software-delivery/src/policy/gates-schemas.ts +0 -173
- package/packs/software-delivery/src/policy/index.ts +0 -22
- package/packs/software-delivery/src/policy/package-manager-resolver.ts +0 -319
- package/packs/software-delivery/src/policy/resolve-policy.ts +0 -601
- package/packs/software-delivery/src/ports/config.ports.ts +0 -90
- package/packs/software-delivery/src/ports/dashboard-renderer.port.ts +0 -125
- package/packs/software-delivery/src/ports/index.ts +0 -10
- package/packs/software-delivery/src/ports/sync-validator.ports.ts +0 -59
- package/packs/software-delivery/src/ports/wu-helpers.ports.ts +0 -168
- package/packs/software-delivery/src/ports/wu-state.ports.ts +0 -241
- package/packs/software-delivery/src/primitives/index.ts +0 -5
- package/packs/software-delivery/src/runtime/index.ts +0 -6
- package/packs/software-delivery/src/runtime/work-classifier.ts +0 -561
- package/packs/software-delivery/src/sandbox/index.ts +0 -10
- package/packs/software-delivery/src/sandbox/sandbox-allowlist.ts +0 -118
- package/packs/software-delivery/src/sandbox/sandbox-backend-linux.ts +0 -88
- package/packs/software-delivery/src/sandbox/sandbox-backend-macos.ts +0 -154
- package/packs/software-delivery/src/sandbox/sandbox-backend-windows.ts +0 -47
- package/packs/software-delivery/src/sandbox/sandbox-profile.ts +0 -153
- package/packs/software-delivery/src/schemas/index.ts +0 -5
- package/packs/software-delivery/src/state/date-utils.ts +0 -158
- package/packs/software-delivery/src/state/index.ts +0 -15
- package/packs/software-delivery/src/state/state-machine.ts +0 -119
- package/packs/software-delivery/src/state/wu-doc-types.ts +0 -51
- package/packs/software-delivery/src/state/wu-paths.ts +0 -381
- package/packs/software-delivery/src/state/wu-schema.ts +0 -1139
- package/packs/software-delivery/src/state/wu-state-schema.ts +0 -255
- package/packs/software-delivery/src/state/wu-yaml.ts +0 -338
- package/packs/software-delivery/tool-impl/agent-tools.ts +0 -263
- package/packs/software-delivery/tool-impl/delegation-tools.ts +0 -66
- package/packs/software-delivery/tool-impl/flow-metrics-tools.ts +0 -219
- package/packs/software-delivery/tool-impl/git-runner.ts +0 -113
- package/packs/software-delivery/tool-impl/git-tools.ts +0 -316
- package/packs/software-delivery/tool-impl/index.ts +0 -15
- package/packs/software-delivery/tool-impl/initiative-orchestration-tools.ts +0 -720
- package/packs/software-delivery/tool-impl/lane-lock.ts +0 -246
- package/packs/software-delivery/tool-impl/memory-tools.ts +0 -470
- package/packs/software-delivery/tool-impl/pending-runtime-tools.ts +0 -21
- package/packs/software-delivery/tool-impl/runtime-cli-adapter.ts +0 -329
- package/packs/software-delivery/tool-impl/runtime-native-tools.ts +0 -687
- package/packs/software-delivery/tool-impl/worker-loader.ts +0 -52
- package/packs/software-delivery/tool-impl/worktree-tools.ts +0 -46
- package/packs/software-delivery/tool-impl/wu-lifecycle-tools.ts +0 -807
- package/packs/software-delivery/tools/delegation-tools.ts +0 -23
- package/packs/software-delivery/tools/git-tools.ts +0 -55
- package/packs/software-delivery/tools/index.ts +0 -8
- package/packs/software-delivery/tools/lane-lock-tool.ts +0 -37
- package/packs/software-delivery/tools/types.ts +0 -71
- package/packs/software-delivery/tools/worktree-tools.ts +0 -49
- 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
|
-
}
|