@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.
- package/README.md +42 -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/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 +255 -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/lumenflow-setup.js +144 -0
- package/dist/lumenflow-setup.js.map +1 -0
- package/dist/lumenflow-upgrade.js +2 -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 -0
- 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-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 +41 -7
- 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 -11
- 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 +197 -47
- 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,290 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2026 Hellmai Ltd
|
|
2
|
-
// SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
|
|
3
|
-
|
|
4
|
-
import { getStoragePort, type MemoryRecord, type MemoryType } from './storage.js';
|
|
5
|
-
import {
|
|
6
|
-
asInteger,
|
|
7
|
-
asNonEmptyString,
|
|
8
|
-
asStringArray,
|
|
9
|
-
buildAuditEvent,
|
|
10
|
-
createId,
|
|
11
|
-
failure,
|
|
12
|
-
includesText,
|
|
13
|
-
isDryRun,
|
|
14
|
-
matchesTags,
|
|
15
|
-
nowIso,
|
|
16
|
-
success,
|
|
17
|
-
toRecord,
|
|
18
|
-
type ToolContextLike,
|
|
19
|
-
type ToolOutput,
|
|
20
|
-
} from './shared.js';
|
|
21
|
-
import {
|
|
22
|
-
buildMemoryForgottenEvent,
|
|
23
|
-
buildMemoryRecalledEvent,
|
|
24
|
-
buildMemoryStoredEvent,
|
|
25
|
-
emitSidekickEvent,
|
|
26
|
-
} from '../sidekick-events.js';
|
|
27
|
-
|
|
28
|
-
// ---------------------------------------------------------------------------
|
|
29
|
-
// Constants
|
|
30
|
-
// ---------------------------------------------------------------------------
|
|
31
|
-
|
|
32
|
-
const TOOL_NAMES = {
|
|
33
|
-
STORE: 'memory:store',
|
|
34
|
-
RECALL: 'memory:recall',
|
|
35
|
-
UPDATE: 'memory:update',
|
|
36
|
-
FORGET: 'memory:forget',
|
|
37
|
-
} as const;
|
|
38
|
-
|
|
39
|
-
const VALID_MEMORY_TYPES: MemoryType[] = ['fact', 'preference', 'note', 'snippet'];
|
|
40
|
-
|
|
41
|
-
// ---------------------------------------------------------------------------
|
|
42
|
-
// Helpers
|
|
43
|
-
// ---------------------------------------------------------------------------
|
|
44
|
-
|
|
45
|
-
function asMemoryType(value: unknown): MemoryType | null {
|
|
46
|
-
return VALID_MEMORY_TYPES.includes(value as MemoryType) ? (value as MemoryType) : null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// ---------------------------------------------------------------------------
|
|
50
|
-
// memory:store
|
|
51
|
-
// ---------------------------------------------------------------------------
|
|
52
|
-
|
|
53
|
-
async function memoryStoreTool(input: unknown, context?: ToolContextLike): Promise<ToolOutput> {
|
|
54
|
-
const parsed = toRecord(input);
|
|
55
|
-
const type = asMemoryType(parsed.type);
|
|
56
|
-
const content = asNonEmptyString(parsed.content);
|
|
57
|
-
|
|
58
|
-
if (!type) {
|
|
59
|
-
return failure('INVALID_INPUT', 'type must be one of fact, preference, note.');
|
|
60
|
-
}
|
|
61
|
-
if (!content) {
|
|
62
|
-
return failure('INVALID_INPUT', 'content is required.');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const memory: MemoryRecord = {
|
|
66
|
-
id: createId('mem'),
|
|
67
|
-
type,
|
|
68
|
-
content,
|
|
69
|
-
tags: asStringArray(parsed.tags),
|
|
70
|
-
created_at: nowIso(),
|
|
71
|
-
updated_at: nowIso(),
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
if (isDryRun(parsed)) {
|
|
75
|
-
return success({
|
|
76
|
-
dry_run: true,
|
|
77
|
-
memory: memory as unknown as Record<string, unknown>,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const storage = getStoragePort();
|
|
82
|
-
await storage.withLock(async () => {
|
|
83
|
-
const memories = await storage.readStore('memories');
|
|
84
|
-
memories.push(memory);
|
|
85
|
-
await storage.writeStore('memories', memories);
|
|
86
|
-
await storage.appendAudit(
|
|
87
|
-
buildAuditEvent({
|
|
88
|
-
tool: TOOL_NAMES.STORE,
|
|
89
|
-
op: 'create',
|
|
90
|
-
context,
|
|
91
|
-
ids: [memory.id],
|
|
92
|
-
}),
|
|
93
|
-
);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
await emitSidekickEvent(buildMemoryStoredEvent(memory));
|
|
97
|
-
|
|
98
|
-
return success({ memory: memory as unknown as Record<string, unknown> });
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// ---------------------------------------------------------------------------
|
|
102
|
-
// memory:recall
|
|
103
|
-
// ---------------------------------------------------------------------------
|
|
104
|
-
|
|
105
|
-
async function memoryRecallTool(input: unknown, _context?: ToolContextLike): Promise<ToolOutput> {
|
|
106
|
-
const parsed = toRecord(input);
|
|
107
|
-
const query = asNonEmptyString(parsed.query);
|
|
108
|
-
const type = asMemoryType(parsed.type);
|
|
109
|
-
const tags = asStringArray(parsed.tags);
|
|
110
|
-
const limit = asInteger(parsed.limit);
|
|
111
|
-
|
|
112
|
-
const storage = getStoragePort();
|
|
113
|
-
const memories = await storage.readStore('memories');
|
|
114
|
-
|
|
115
|
-
const filtered = memories.filter((memory) => {
|
|
116
|
-
if (type && memory.type !== type) {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
if (!matchesTags(tags, memory.tags)) {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
if (!includesText(memory.content, query)) {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
return true;
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
const sorted = filtered.toSorted((a, b) => Date.parse(b.updated_at) - Date.parse(a.updated_at));
|
|
129
|
-
|
|
130
|
-
const items = limit && limit > 0 ? sorted.slice(0, limit) : sorted;
|
|
131
|
-
|
|
132
|
-
await emitSidekickEvent(
|
|
133
|
-
buildMemoryRecalledEvent({
|
|
134
|
-
query,
|
|
135
|
-
memories: items,
|
|
136
|
-
}),
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
return success({
|
|
140
|
-
items: items as unknown as Record<string, unknown>,
|
|
141
|
-
count: items.length,
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// ---------------------------------------------------------------------------
|
|
146
|
-
// memory:update
|
|
147
|
-
// ---------------------------------------------------------------------------
|
|
148
|
-
|
|
149
|
-
async function memoryUpdateTool(input: unknown, context?: ToolContextLike): Promise<ToolOutput> {
|
|
150
|
-
const parsed = toRecord(input);
|
|
151
|
-
const id = asNonEmptyString(parsed.id);
|
|
152
|
-
|
|
153
|
-
if (!id) {
|
|
154
|
-
return failure('INVALID_INPUT', 'id is required.');
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const patch: Partial<MemoryRecord> = {};
|
|
158
|
-
if (parsed.type !== undefined) {
|
|
159
|
-
const type = asMemoryType(parsed.type);
|
|
160
|
-
if (!type) {
|
|
161
|
-
return failure('INVALID_INPUT', 'type must be one of fact, preference, note, snippet.');
|
|
162
|
-
}
|
|
163
|
-
patch.type = type;
|
|
164
|
-
}
|
|
165
|
-
if (parsed.content !== undefined) {
|
|
166
|
-
const content = asNonEmptyString(parsed.content);
|
|
167
|
-
if (!content) {
|
|
168
|
-
return failure('INVALID_INPUT', 'content must be a non-empty string when provided.');
|
|
169
|
-
}
|
|
170
|
-
patch.content = content;
|
|
171
|
-
}
|
|
172
|
-
if (parsed.tags !== undefined) {
|
|
173
|
-
patch.tags = asStringArray(parsed.tags);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (Object.keys(patch).length === 0) {
|
|
177
|
-
return failure(
|
|
178
|
-
'INVALID_INPUT',
|
|
179
|
-
'memory:update requires at least one of type, content, or tags.',
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const storage = getStoragePort();
|
|
184
|
-
const memories = await storage.readStore('memories');
|
|
185
|
-
const memory = memories.find((entry) => entry.id === id);
|
|
186
|
-
|
|
187
|
-
if (!memory) {
|
|
188
|
-
return failure('NOT_FOUND', `memory ${id} was not found.`);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const preview: MemoryRecord = {
|
|
192
|
-
...memory,
|
|
193
|
-
...patch,
|
|
194
|
-
updated_at: nowIso(),
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
if (isDryRun(parsed)) {
|
|
198
|
-
return success({
|
|
199
|
-
dry_run: true,
|
|
200
|
-
memory: preview as unknown as Record<string, unknown>,
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
await storage.withLock(async () => {
|
|
205
|
-
const latest = await storage.readStore('memories');
|
|
206
|
-
const target = latest.find((entry) => entry.id === id);
|
|
207
|
-
if (!target) {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
Object.assign(target, preview);
|
|
211
|
-
await storage.writeStore('memories', latest);
|
|
212
|
-
await storage.appendAudit(
|
|
213
|
-
buildAuditEvent({
|
|
214
|
-
tool: TOOL_NAMES.UPDATE,
|
|
215
|
-
op: 'update',
|
|
216
|
-
context,
|
|
217
|
-
ids: [id],
|
|
218
|
-
}),
|
|
219
|
-
);
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
const updated = await storage.readStore('memories');
|
|
223
|
-
const updatedMemory = updated.find((entry) => entry.id === id);
|
|
224
|
-
return success({ memory: updatedMemory as unknown as Record<string, unknown> });
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// ---------------------------------------------------------------------------
|
|
228
|
-
// memory:forget
|
|
229
|
-
// ---------------------------------------------------------------------------
|
|
230
|
-
|
|
231
|
-
async function memoryForgetTool(input: unknown, context?: ToolContextLike): Promise<ToolOutput> {
|
|
232
|
-
const parsed = toRecord(input);
|
|
233
|
-
const id = asNonEmptyString(parsed.id);
|
|
234
|
-
|
|
235
|
-
if (!id) {
|
|
236
|
-
return failure('INVALID_INPUT', 'id is required.');
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const storage = getStoragePort();
|
|
240
|
-
const memories = await storage.readStore('memories');
|
|
241
|
-
const exists = memories.some((memory) => memory.id === id);
|
|
242
|
-
|
|
243
|
-
if (!exists) {
|
|
244
|
-
return failure('NOT_FOUND', `memory ${id} was not found.`);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (isDryRun(parsed)) {
|
|
248
|
-
return success({ dry_run: true, deleted_id: id });
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
await storage.withLock(async () => {
|
|
252
|
-
const latest = await storage.readStore('memories');
|
|
253
|
-
const remaining = latest.filter((memory) => memory.id !== id);
|
|
254
|
-
await storage.writeStore('memories', remaining);
|
|
255
|
-
await storage.appendAudit(
|
|
256
|
-
buildAuditEvent({
|
|
257
|
-
tool: TOOL_NAMES.FORGET,
|
|
258
|
-
op: 'delete',
|
|
259
|
-
context,
|
|
260
|
-
ids: [id],
|
|
261
|
-
}),
|
|
262
|
-
);
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
await emitSidekickEvent(buildMemoryForgottenEvent(id));
|
|
266
|
-
|
|
267
|
-
return success({ deleted_id: id });
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
// ---------------------------------------------------------------------------
|
|
271
|
-
// Router (default export)
|
|
272
|
-
// ---------------------------------------------------------------------------
|
|
273
|
-
|
|
274
|
-
export default async function memoryTools(
|
|
275
|
-
input: unknown,
|
|
276
|
-
context?: ToolContextLike,
|
|
277
|
-
): Promise<ToolOutput> {
|
|
278
|
-
switch (context?.tool_name) {
|
|
279
|
-
case TOOL_NAMES.STORE:
|
|
280
|
-
return memoryStoreTool(input, context);
|
|
281
|
-
case TOOL_NAMES.RECALL:
|
|
282
|
-
return memoryRecallTool(input, context);
|
|
283
|
-
case TOOL_NAMES.UPDATE:
|
|
284
|
-
return memoryUpdateTool(input, context);
|
|
285
|
-
case TOOL_NAMES.FORGET:
|
|
286
|
-
return memoryForgetTool(input, context);
|
|
287
|
-
default:
|
|
288
|
-
return failure('UNKNOWN_TOOL', `Unknown memory tool: ${context?.tool_name ?? 'unknown'}`);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
@@ -1,102 +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): `sidekick:routine:commit_plan`
|
|
6
|
-
* is the only path from a planned routine to a committed one. It is
|
|
7
|
-
* registered as a runtime-callable tool (not a top-level surface) so the
|
|
8
|
-
* kernel's governed dispatch emits `agent-runtime:tool_called` inside a
|
|
9
|
-
* turn, and the commit itself emits `sidekick:routine_committed` carrying
|
|
10
|
-
* a content-hash of the commit envelope. No fast-path bypasses this tool.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
buildRoutineCommitEnvelope,
|
|
15
|
-
hashRoutineCommitEnvelope,
|
|
16
|
-
type RoutineCommitAttestation,
|
|
17
|
-
} from '../src/routines/commit.js';
|
|
18
|
-
import { buildRoutineCommittedEvent, emitSidekickEvent } from '../sidekick-events.js';
|
|
19
|
-
import { getStoragePort } from './storage.js';
|
|
20
|
-
import {
|
|
21
|
-
asNonEmptyString,
|
|
22
|
-
buildAuditEvent,
|
|
23
|
-
failure,
|
|
24
|
-
nowIso,
|
|
25
|
-
success,
|
|
26
|
-
toRecord,
|
|
27
|
-
type ToolContextLike,
|
|
28
|
-
type ToolOutput,
|
|
29
|
-
} from './shared.js';
|
|
30
|
-
|
|
31
|
-
const ROUTINE_COMMIT_PLAN_TOOL_NAME = 'sidekick:routine:commit_plan';
|
|
32
|
-
|
|
33
|
-
function readAttestation(value: unknown): RoutineCommitAttestation | null {
|
|
34
|
-
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
const record = value as Record<string, unknown>;
|
|
38
|
-
const actor = asNonEmptyString(record.actor);
|
|
39
|
-
const reason = asNonEmptyString(record.reason);
|
|
40
|
-
if (!actor || !reason) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
...record,
|
|
45
|
-
actor,
|
|
46
|
-
reason,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export default async function routineCommitPlanTool(
|
|
51
|
-
input: unknown,
|
|
52
|
-
context?: ToolContextLike,
|
|
53
|
-
): Promise<ToolOutput> {
|
|
54
|
-
const parsed = toRecord(input);
|
|
55
|
-
const planId = asNonEmptyString(parsed.plan_id);
|
|
56
|
-
const attestation = readAttestation(parsed.attestation);
|
|
57
|
-
|
|
58
|
-
if (!planId) {
|
|
59
|
-
return failure('INVALID_INPUT', 'plan_id is required.');
|
|
60
|
-
}
|
|
61
|
-
if (!attestation) {
|
|
62
|
-
return failure(
|
|
63
|
-
'INVALID_INPUT',
|
|
64
|
-
'attestation must be an object with non-empty actor and reason fields.',
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const storage = getStoragePort();
|
|
69
|
-
const routines = await storage.readStore('routines');
|
|
70
|
-
const routine = routines.find((entry) => entry.id === planId);
|
|
71
|
-
if (!routine) {
|
|
72
|
-
return failure('NOT_FOUND', `routine ${planId} was not found.`);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const committedAt = nowIso();
|
|
76
|
-
const envelope = buildRoutineCommitEnvelope({ routine, attestation, committedAt });
|
|
77
|
-
const envelopeContentHash = hashRoutineCommitEnvelope(envelope);
|
|
78
|
-
|
|
79
|
-
await storage.appendAudit(
|
|
80
|
-
buildAuditEvent({
|
|
81
|
-
tool: ROUTINE_COMMIT_PLAN_TOOL_NAME,
|
|
82
|
-
op: 'execute',
|
|
83
|
-
context,
|
|
84
|
-
ids: [routine.id],
|
|
85
|
-
details: {
|
|
86
|
-
plan_id: routine.id,
|
|
87
|
-
envelope_content_hash: envelopeContentHash,
|
|
88
|
-
},
|
|
89
|
-
}),
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
await emitSidekickEvent(
|
|
93
|
-
buildRoutineCommittedEvent(routine, { envelope_content_hash: envelopeContentHash }),
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
return success({
|
|
97
|
-
plan_id: routine.id,
|
|
98
|
-
routine_id: routine.id,
|
|
99
|
-
envelope_content_hash: envelopeContentHash,
|
|
100
|
-
committed_at: committedAt,
|
|
101
|
-
});
|
|
102
|
-
}
|