@lumenflow/cli 3.12.6 → 3.12.7

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 (109) hide show
  1. package/dist/wu-claim.js +2 -1
  2. package/dist/wu-claim.js.map +1 -1
  3. package/dist/wu-done-policies.js +9 -9
  4. package/dist/wu-done-policies.js.map +1 -1
  5. package/dist/wu-spawn-strategy-resolver.js +14 -6
  6. package/dist/wu-spawn-strategy-resolver.js.map +1 -1
  7. package/package.json +8 -8
  8. package/packs/sidekick/.turbo/turbo-build.log +1 -1
  9. package/packs/sidekick/package.json +1 -1
  10. package/packs/software-delivery/.turbo/turbo-build.log +1 -1
  11. package/packs/software-delivery/package.json +1 -1
  12. package/dist/chunk-2D2VOCA4.js +0 -37
  13. package/dist/chunk-2D5KFYGX.js +0 -284
  14. package/dist/chunk-2GXVIN57.js +0 -14072
  15. package/dist/chunk-2MQ7HZWZ.js +0 -26
  16. package/dist/chunk-2UFQ3A3C.js +0 -643
  17. package/dist/chunk-3RG5ZIWI.js +0 -10
  18. package/dist/chunk-4N74J3UT.js +0 -15
  19. package/dist/chunk-5GTOXFYR.js +0 -392
  20. package/dist/chunk-5VY6MQMC.js +0 -240
  21. package/dist/chunk-67XVPMRY.js +0 -1297
  22. package/dist/chunk-6HO4GWJE.js +0 -164
  23. package/dist/chunk-6W5XHWYV.js +0 -1890
  24. package/dist/chunk-6X4EMYJQ.js +0 -64
  25. package/dist/chunk-6XYXI2NQ.js +0 -772
  26. package/dist/chunk-7ANSOV6Q.js +0 -285
  27. package/dist/chunk-A624LFLB.js +0 -1380
  28. package/dist/chunk-ADN5NHG4.js +0 -126
  29. package/dist/chunk-B7YJYJKG.js +0 -33
  30. package/dist/chunk-CCLHCPKG.js +0 -210
  31. package/dist/chunk-CK36VROC.js +0 -1584
  32. package/dist/chunk-D3UOFRSB.js +0 -81
  33. package/dist/chunk-DFR4DJBM.js +0 -230
  34. package/dist/chunk-DSYBDHYH.js +0 -79
  35. package/dist/chunk-DWMLTXKQ.js +0 -1176
  36. package/dist/chunk-E3REJTAJ.js +0 -28
  37. package/dist/chunk-EA3IVO64.js +0 -633
  38. package/dist/chunk-EK2AKZKD.js +0 -55
  39. package/dist/chunk-ELD7JTTT.js +0 -343
  40. package/dist/chunk-EX6TT2XI.js +0 -195
  41. package/dist/chunk-EXINSFZE.js +0 -82
  42. package/dist/chunk-EZ6ZBYBM.js +0 -510
  43. package/dist/chunk-FBKAPTJ2.js +0 -16
  44. package/dist/chunk-FVLV5RYH.js +0 -1118
  45. package/dist/chunk-GDNSBQVK.js +0 -2485
  46. package/dist/chunk-GPQHMBNN.js +0 -278
  47. package/dist/chunk-GTFJB67L.js +0 -68
  48. package/dist/chunk-HANJXVKW.js +0 -1127
  49. package/dist/chunk-HEVS5YLD.js +0 -269
  50. package/dist/chunk-HMEVZKPQ.js +0 -9
  51. package/dist/chunk-HRGSYNLM.js +0 -3511
  52. package/dist/chunk-ISZR5N4K.js +0 -60
  53. package/dist/chunk-J6SUPR2C.js +0 -226
  54. package/dist/chunk-JERYVEIZ.js +0 -244
  55. package/dist/chunk-JHHWGL2N.js +0 -87
  56. package/dist/chunk-JONWQUB5.js +0 -775
  57. package/dist/chunk-K2DIWWDM.js +0 -1766
  58. package/dist/chunk-KY4PGL5V.js +0 -969
  59. package/dist/chunk-L737LQ4C.js +0 -1285
  60. package/dist/chunk-LFTWYIB2.js +0 -497
  61. package/dist/chunk-LV47RFNJ.js +0 -41
  62. package/dist/chunk-MKSAITI7.js +0 -15
  63. package/dist/chunk-MZ7RKIX4.js +0 -212
  64. package/dist/chunk-NAP6CFSO.js +0 -84
  65. package/dist/chunk-ND6MY37M.js +0 -16
  66. package/dist/chunk-NMG736UR.js +0 -683
  67. package/dist/chunk-NRAXROED.js +0 -32
  68. package/dist/chunk-NRIZR3A7.js +0 -690
  69. package/dist/chunk-NX43BG3M.js +0 -233
  70. package/dist/chunk-O645XLSI.js +0 -297
  71. package/dist/chunk-OMJD6A3S.js +0 -235
  72. package/dist/chunk-QB6SJD4T.js +0 -430
  73. package/dist/chunk-QFSTL4J3.js +0 -276
  74. package/dist/chunk-QLGDFMFX.js +0 -212
  75. package/dist/chunk-RIAAGL2E.js +0 -13
  76. package/dist/chunk-RWO5XMZ6.js +0 -86
  77. package/dist/chunk-RXRKBBSM.js +0 -149
  78. package/dist/chunk-RZOZMML6.js +0 -363
  79. package/dist/chunk-U7I7FS7T.js +0 -113
  80. package/dist/chunk-UI42RODY.js +0 -717
  81. package/dist/chunk-UTVMVSCO.js +0 -519
  82. package/dist/chunk-V6OJGLBA.js +0 -1746
  83. package/dist/chunk-W2JHVH7D.js +0 -152
  84. package/dist/chunk-WD3Y7VQN.js +0 -280
  85. package/dist/chunk-WOCTQ5MS.js +0 -303
  86. package/dist/chunk-WZR3ZUNN.js +0 -696
  87. package/dist/chunk-XGI665H7.js +0 -150
  88. package/dist/chunk-XKY65P2T.js +0 -304
  89. package/dist/chunk-Y4CQZY65.js +0 -57
  90. package/dist/chunk-YFEXKLVE.js +0 -194
  91. package/dist/chunk-YHO3HS5X.js +0 -287
  92. package/dist/chunk-YLS7AZSX.js +0 -738
  93. package/dist/chunk-ZE473AO6.js +0 -49
  94. package/dist/chunk-ZF747T3O.js +0 -644
  95. package/dist/chunk-ZHCZHZH3.js +0 -43
  96. package/dist/chunk-ZZNZX2XY.js +0 -87
  97. package/dist/constants-7QAP3VQ4.js +0 -23
  98. package/dist/dist-IY3UUMWK.js +0 -33
  99. package/dist/invariants-runner-W5RGHCSU.js +0 -27
  100. package/dist/lane-lock-6J36HD5O.js +0 -35
  101. package/dist/mem-checkpoint-core-EANG2GVN.js +0 -14
  102. package/dist/mem-signal-core-2LZ2WYHW.js +0 -19
  103. package/dist/memory-store-OLB5FO7K.js +0 -18
  104. package/dist/service-6BYCOCO5.js +0 -13
  105. package/dist/spawn-policy-resolver-NTSZYQ6R.js +0 -17
  106. package/dist/spawn-task-builder-R4E2BHSW.js +0 -22
  107. package/dist/wu-done-pr-WLFFFEPJ.js +0 -25
  108. package/dist/wu-done-validation-3J5E36FE.js +0 -30
  109. package/dist/wu-duplicate-id-detector-5S7JHELK.js +0 -232
@@ -1,60 +0,0 @@
1
- import {
2
- PROGRESSABLE_WU_STATUSES
3
- } from "./chunk-V6OJGLBA.js";
4
-
5
- // ../initiatives/dist/initiative-validation.js
6
- var PROGRESSABLE_STATUSES = ["draft", "open"];
7
- function validateInitiativeCompleteness(initiative) {
8
- const warnings = [];
9
- const id = initiative.id || "unknown";
10
- if (!initiative.description || initiative.description.trim() === "") {
11
- warnings.push(`[${id}] Initiative has no description. Add a description to explain its purpose.`);
12
- }
13
- if (!initiative.phases || initiative.phases.length === 0) {
14
- warnings.push(`[${id}] Initiative has no phases defined. Add phases to break down the work.`);
15
- }
16
- if (!initiative.success_metrics || initiative.success_metrics.length === 0) {
17
- warnings.push(`[${id}] Initiative has no success_metrics defined. Add metrics to measure completion.`);
18
- }
19
- return {
20
- valid: true,
21
- // Always valid - issues are warnings not errors
22
- warnings
23
- };
24
- }
25
- function checkInitiativePhases(initiative) {
26
- const hasPhases = Array.isArray(initiative.phases) && initiative.phases.length > 0;
27
- const id = initiative.id || "unknown";
28
- return {
29
- hasPhases,
30
- warning: hasPhases ? null : `Initiative ${id} has no phases defined. Consider adding phases before linking WUs.`
31
- };
32
- }
33
- function shouldProgressInitiativeStatus(initiative, wus) {
34
- const currentStatus = initiative.status || "draft";
35
- const initiativeId = initiative.id;
36
- if (!PROGRESSABLE_STATUSES.includes(currentStatus)) {
37
- return {
38
- shouldProgress: false,
39
- newStatus: null
40
- };
41
- }
42
- const initiativeWUs = wus.filter((wu) => wu.initiative === initiativeId);
43
- const hasActiveWU = initiativeWUs.some((wu) => PROGRESSABLE_WU_STATUSES.includes(wu.status || ""));
44
- if (hasActiveWU) {
45
- return {
46
- shouldProgress: true,
47
- newStatus: "in_progress"
48
- };
49
- }
50
- return {
51
- shouldProgress: false,
52
- newStatus: null
53
- };
54
- }
55
-
56
- export {
57
- validateInitiativeCompleteness,
58
- checkInitiativePhases,
59
- shouldProgressInitiativeStatus
60
- };
@@ -1,226 +0,0 @@
1
- import {
2
- appendNode,
3
- loadMemory
4
- } from "./chunk-DFR4DJBM.js";
5
- import {
6
- validateLaneFormat
7
- } from "./chunk-JONWQUB5.js";
8
- import {
9
- LUMENFLOW_MEMORY_PATHS
10
- } from "./chunk-4N74J3UT.js";
11
- import {
12
- createWuPaths
13
- } from "./chunk-6HO4GWJE.js";
14
- import {
15
- ErrorCodes,
16
- createError
17
- } from "./chunk-RXRKBBSM.js";
18
-
19
- // ../memory/dist/mem-triage-core.js
20
- import fs from "fs/promises";
21
- import path from "path";
22
- var RELATIONSHIPS_FILE_NAME = "relationships.jsonl";
23
- var DEFAULT_PRIORITY = "P2";
24
- var MAX_TITLE_LENGTH = 80;
25
- var PRIORITY_RANK = {
26
- P0: 0,
27
- P1: 1,
28
- P2: 2,
29
- P3: 3
30
- };
31
- var DEFAULT_PRIORITY_RANK = 999;
32
- function getPriorityRank(node) {
33
- const priority = node.metadata?.priority;
34
- if (!priority) {
35
- return DEFAULT_PRIORITY_RANK;
36
- }
37
- return PRIORITY_RANK[priority] ?? DEFAULT_PRIORITY_RANK;
38
- }
39
- function compareNodes(a, b) {
40
- const priorityDiff = getPriorityRank(a) - getPriorityRank(b);
41
- if (priorityDiff !== 0) {
42
- return priorityDiff;
43
- }
44
- const aTime = new Date(a.created_at).getTime();
45
- const bTime = new Date(b.created_at).getTime();
46
- if (aTime !== bTime) {
47
- return aTime - bTime;
48
- }
49
- return a.id.localeCompare(b.id);
50
- }
51
- async function loadRelationships(memoryDir) {
52
- const filePath = path.join(memoryDir, RELATIONSHIPS_FILE_NAME);
53
- try {
54
- const content = await fs.readFile(filePath, { encoding: "utf-8" });
55
- const lines = content.split("\n");
56
- const relationships = [];
57
- for (const line of lines) {
58
- const trimmed = line.trim();
59
- if (!trimmed)
60
- continue;
61
- try {
62
- relationships.push(JSON.parse(trimmed));
63
- } catch {
64
- continue;
65
- }
66
- }
67
- return relationships;
68
- } catch (err) {
69
- const error = err;
70
- if (error.code === "ENOENT") {
71
- return [];
72
- }
73
- throw error;
74
- }
75
- }
76
- function buildBlockedSet(relationships) {
77
- const blocked = /* @__PURE__ */ new Set();
78
- for (const rel of relationships) {
79
- if (rel.type === "blocks") {
80
- blocked.add(rel.to_id);
81
- }
82
- }
83
- return blocked;
84
- }
85
- function isBlocked(node, blockedByRelationships) {
86
- if (blockedByRelationships.has(node.id)) {
87
- return true;
88
- }
89
- const blockedBy = node.metadata?.blocked_by;
90
- if (Array.isArray(blockedBy) && blockedBy.length > 0) {
91
- return true;
92
- }
93
- return false;
94
- }
95
- function isClosed(node) {
96
- const status = node.metadata?.status;
97
- if (status === "closed" || status === "archived") {
98
- return true;
99
- }
100
- if (node.lifecycle === "ephemeral") {
101
- return true;
102
- }
103
- return false;
104
- }
105
- async function listOpenDiscoveries(baseDir, options = {}) {
106
- const memoryDir = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
107
- const memory = await loadMemory(memoryDir);
108
- const relationships = await loadRelationships(memoryDir);
109
- const blockedByRelationships = buildBlockedSet(relationships);
110
- let nodes = memory.nodes.filter((node) => node.type === "discovery");
111
- nodes = nodes.filter((node) => !isBlocked(node, blockedByRelationships));
112
- nodes = nodes.filter((node) => !isClosed(node));
113
- if (options.wuId) {
114
- if (options.wuId === "unlinked") {
115
- nodes = nodes.filter((node) => !node.wu_id);
116
- } else {
117
- nodes = nodes.filter((node) => node.wu_id === options.wuId);
118
- }
119
- }
120
- if (options.tag) {
121
- const filterTag = options.tag;
122
- nodes = nodes.filter((node) => node.tags?.includes(filterTag));
123
- }
124
- return nodes.sort(compareNodes);
125
- }
126
- async function archiveDiscovery(baseDir, options) {
127
- const { nodeId, reason } = options;
128
- const memoryDir = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
129
- const memory = await loadMemory(memoryDir);
130
- const node = memory.byId.get(nodeId);
131
- if (!node) {
132
- throw createError(ErrorCodes.NODE_NOT_FOUND, `Node not found: ${nodeId}`);
133
- }
134
- if (node.type !== "discovery") {
135
- throw createError(ErrorCodes.VALIDATION_ERROR, `Node ${nodeId} is not a discovery (type: ${node.type})`);
136
- }
137
- if (node.metadata?.status === "archived" || node.metadata?.status === "closed") {
138
- throw createError(ErrorCodes.ALREADY_EXISTS, `Node ${nodeId} is already archived/closed`);
139
- }
140
- const archivedNode = {
141
- ...node,
142
- metadata: {
143
- ...node.metadata,
144
- status: "archived",
145
- archive_reason: reason,
146
- archived_at: (/* @__PURE__ */ new Date()).toISOString()
147
- }
148
- };
149
- await appendNode(memoryDir, archivedNode);
150
- return {
151
- success: true,
152
- nodeId
153
- };
154
- }
155
- async function getNextWuId(baseDir) {
156
- const paths = createWuPaths({ projectRoot: baseDir });
157
- const wuDir = path.join(baseDir, paths.WU_DIR());
158
- let maxId = 0;
159
- try {
160
- const files = await fs.readdir(wuDir);
161
- for (const file of files) {
162
- const match = file.match(/^WU-(\d+)\.yaml$/);
163
- if (match && match[1]) {
164
- const id = parseInt(match[1], 10);
165
- if (id > maxId) {
166
- maxId = id;
167
- }
168
- }
169
- }
170
- } catch (err) {
171
- const error = err;
172
- if (error.code !== "ENOENT") {
173
- throw error;
174
- }
175
- }
176
- return `WU-${maxId + 1}`;
177
- }
178
- function truncateToTitle(content) {
179
- const parts = content.split(/[.!?]/);
180
- const firstSentence = (parts[0] ?? "").trim();
181
- if (firstSentence.length <= MAX_TITLE_LENGTH) {
182
- return firstSentence;
183
- }
184
- return firstSentence.substring(0, MAX_TITLE_LENGTH - 3) + "...";
185
- }
186
- async function promoteDiscovery(baseDir, options) {
187
- const { nodeId, lane, title, wuId, priority, dryRun: _dryRun = false } = options;
188
- const memoryDir = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
189
- try {
190
- validateLaneFormat(lane);
191
- } catch (err) {
192
- const errMsg = err instanceof Error ? err.message : String(err);
193
- throw createError(ErrorCodes.INVALID_LANE, `Invalid lane format: ${errMsg}`, { cause: err });
194
- }
195
- const memory = await loadMemory(memoryDir);
196
- const node = memory.byId.get(nodeId);
197
- if (!node) {
198
- throw createError(ErrorCodes.NODE_NOT_FOUND, `Node not found: ${nodeId}`);
199
- }
200
- if (node.type !== "discovery") {
201
- throw createError(ErrorCodes.VALIDATION_ERROR, `Node ${nodeId} is not a discovery (type: ${node.type})`);
202
- }
203
- if (node.metadata?.status === "archived" || node.metadata?.status === "closed") {
204
- throw createError(ErrorCodes.ALREADY_EXISTS, `Node ${nodeId} is already archived/closed`);
205
- }
206
- const resolvedWuId = wuId || await getNextWuId(baseDir);
207
- const resolvedTitle = title || truncateToTitle(node.content);
208
- const resolvedPriority = priority || node.metadata?.priority || DEFAULT_PRIORITY;
209
- const wuSpec = {
210
- id: resolvedWuId,
211
- title: resolvedTitle,
212
- lane,
213
- priority: resolvedPriority,
214
- notes: `Promoted from discovery ${nodeId}`
215
- };
216
- return {
217
- success: true,
218
- wuSpec
219
- };
220
- }
221
-
222
- export {
223
- listOpenDiscoveries,
224
- archiveDiscovery,
225
- promoteDiscovery
226
- };
@@ -1,244 +0,0 @@
1
- import {
2
- WU_LIFECYCLE_CLAIM_DEFAULTS,
3
- WU_LIFECYCLE_COMMANDS,
4
- WU_LIFECYCLE_EVENT_KINDS,
5
- WU_LIFECYCLE_EVENT_SCHEMA_VERSION,
6
- WU_LIFECYCLE_SPEC_HASH,
7
- WU_LIFECYCLE_SYNC_CONFIG,
8
- WU_LIFECYCLE_SYNC_LOG_PREFIX,
9
- WU_LIFECYCLE_SYNC_RESULT_DEFAULTS,
10
- WU_LIFECYCLE_SYNC_SKIPPED_REASONS
11
- } from "./chunk-EK2AKZKD.js";
12
- import {
13
- CONFIG_FILES
14
- } from "./chunk-DWMLTXKQ.js";
15
- import {
16
- ErrorCodes,
17
- createError,
18
- getErrorMessage
19
- } from "./chunk-RXRKBBSM.js";
20
-
21
- // src/wu-lifecycle-sync/service.ts
22
- import { createHash } from "crypto";
23
- import { readFileSync } from "fs";
24
-
25
- // src/wu-lifecycle-sync/control-plane-sink.ts
26
- import path from "path";
27
- import { readFile } from "fs/promises";
28
- import YAML from "yaml";
29
-
30
- // src/wu-lifecycle-sync/noop-sink.ts
31
- function createNoopSink(skippedReason) {
32
- return {
33
- async push() {
34
- return {
35
- sent: WU_LIFECYCLE_SYNC_RESULT_DEFAULTS.SENT,
36
- accepted: WU_LIFECYCLE_SYNC_RESULT_DEFAULTS.ACCEPTED,
37
- skippedReason
38
- };
39
- }
40
- };
41
- }
42
-
43
- // src/wu-lifecycle-sync/control-plane-sink.ts
44
- function isRecord(value) {
45
- return typeof value === "object" && value !== null;
46
- }
47
- function asNonEmptyString(value) {
48
- if (typeof value !== "string") {
49
- return void 0;
50
- }
51
- const trimmed = value.trim();
52
- return trimmed.length > 0 ? trimmed : void 0;
53
- }
54
- function createNoopSyncResult(skippedReason) {
55
- return {
56
- sent: WU_LIFECYCLE_SYNC_RESULT_DEFAULTS.SENT,
57
- accepted: WU_LIFECYCLE_SYNC_RESULT_DEFAULTS.ACCEPTED,
58
- skippedReason
59
- };
60
- }
61
- function createParseInput(workspaceId, controlPlaneRaw) {
62
- return {
63
- [WU_LIFECYCLE_SYNC_CONFIG.WORKSPACE_ID_FIELD]: workspaceId,
64
- [WU_LIFECYCLE_SYNC_CONFIG.CONTROL_PLANE_FIELD]: controlPlaneRaw
65
- };
66
- }
67
- async function loadControlPlaneSdk(logger) {
68
- try {
69
- return await import("./dist-IY3UUMWK.js");
70
- } catch (error) {
71
- logger?.warn?.(
72
- `${WU_LIFECYCLE_SYNC_LOG_PREFIX} control-plane SDK unavailable: ${getErrorMessage(error)}`
73
- );
74
- return null;
75
- }
76
- }
77
- async function resolveWuLifecycleEventSink(options = {}) {
78
- const workspaceRoot = options.workspaceRoot ?? process.cwd();
79
- const workspacePath = path.join(workspaceRoot, CONFIG_FILES.WORKSPACE_CONFIG);
80
- let workspaceContent;
81
- try {
82
- workspaceContent = await readFile(workspacePath, WU_LIFECYCLE_SYNC_CONFIG.TEXT_ENCODING_UTF8);
83
- } catch {
84
- return createNoopSink(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.WORKSPACE_CONFIG_MISSING);
85
- }
86
- let parsedWorkspace;
87
- try {
88
- parsedWorkspace = YAML.parse(workspaceContent);
89
- } catch {
90
- return createNoopSink(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.WORKSPACE_CONFIG_INVALID);
91
- }
92
- if (!isRecord(parsedWorkspace)) {
93
- return createNoopSink(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.WORKSPACE_CONFIG_INVALID);
94
- }
95
- const workspaceId = asNonEmptyString(
96
- Reflect.get(parsedWorkspace, WU_LIFECYCLE_SYNC_CONFIG.WORKSPACE_ID_FIELD)
97
- );
98
- if (!workspaceId) {
99
- return createNoopSink(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.WORKSPACE_ID_MISSING);
100
- }
101
- const controlPlaneRaw = Reflect.get(
102
- parsedWorkspace,
103
- WU_LIFECYCLE_SYNC_CONFIG.CONTROL_PLANE_FIELD
104
- );
105
- if (!isRecord(controlPlaneRaw)) {
106
- return createNoopSink(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.CONTROL_PLANE_NOT_CONFIGURED);
107
- }
108
- const controlPlaneSdk = await loadControlPlaneSdk(options.logger);
109
- if (!controlPlaneSdk) {
110
- return createNoopSink(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.CONTROL_PLANE_SDK_UNAVAILABLE);
111
- }
112
- const { parseWorkspaceControlPlaneConfig, createHttpControlPlaneSyncPort } = controlPlaneSdk;
113
- let runtimeConfig;
114
- try {
115
- runtimeConfig = parseWorkspaceControlPlaneConfig(
116
- createParseInput(workspaceId, controlPlaneRaw)
117
- );
118
- } catch {
119
- return createNoopSink(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.CONTROL_PLANE_INVALID);
120
- }
121
- const environment = options.environment ?? process.env;
122
- const tokenEnv = runtimeConfig.control_plane.auth.token_env;
123
- const token = asNonEmptyString(environment[tokenEnv]);
124
- if (!token) {
125
- return createNoopSink(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.MISSING_TOKEN_ENV);
126
- }
127
- const syncPort = createHttpControlPlaneSyncPort(runtimeConfig.control_plane, options.logger, {
128
- fetchFn: options.fetchFn,
129
- environment,
130
- timeoutMs: options.timeoutMs
131
- });
132
- return {
133
- async push(events) {
134
- if (events.length === 0) {
135
- return createNoopSyncResult(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.NO_EVENTS);
136
- }
137
- try {
138
- const result = await syncPort.pushKernelEvents({
139
- workspace_id: workspaceId,
140
- events
141
- });
142
- return {
143
- sent: result.accepted > 0,
144
- accepted: result.accepted,
145
- ...result.accepted > 0 ? {} : {
146
- skippedReason: WU_LIFECYCLE_SYNC_SKIPPED_REASONS.NO_EVENTS_ACCEPTED
147
- }
148
- };
149
- } catch (error) {
150
- options.logger?.warn?.(
151
- `${WU_LIFECYCLE_SYNC_LOG_PREFIX} pushKernelEvents failed: ${getErrorMessage(error)}`
152
- );
153
- return createNoopSyncResult(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.PUSH_FAILED);
154
- }
155
- }
156
- };
157
- }
158
-
159
- // src/wu-lifecycle-sync/service.ts
160
- function asNonEmptyString2(value) {
161
- if (typeof value !== "string") {
162
- return void 0;
163
- }
164
- const trimmed = value.trim();
165
- return trimmed.length > 0 ? trimmed : void 0;
166
- }
167
- function createSha256Hex(input) {
168
- return createHash(WU_LIFECYCLE_SPEC_HASH.ALGORITHM).update(input).digest(WU_LIFECYCLE_SPEC_HASH.DIGEST_ENCODING);
169
- }
170
- function resolveSpecHash(input) {
171
- const explicitSpecHash = asNonEmptyString2(input.specHash);
172
- if (explicitSpecHash && WU_LIFECYCLE_SPEC_HASH.HEX_256_REGEX.test(explicitSpecHash)) {
173
- return explicitSpecHash;
174
- }
175
- const specPath = asNonEmptyString2(input.specPath);
176
- if (specPath) {
177
- try {
178
- const fileContent = readFileSync(specPath, WU_LIFECYCLE_SYNC_CONFIG.TEXT_ENCODING_UTF8);
179
- return createSha256Hex(fileContent);
180
- } catch {
181
- }
182
- }
183
- return createSha256Hex(`${WU_LIFECYCLE_COMMANDS.CREATE}:${input.wuId}`);
184
- }
185
- function resolveTimestamp(input) {
186
- return input.timestamp ?? (/* @__PURE__ */ new Date()).toISOString();
187
- }
188
- function buildWuLifecycleKernelEvent(input) {
189
- const timestamp = resolveTimestamp(input);
190
- switch (input.command) {
191
- case WU_LIFECYCLE_COMMANDS.CREATE:
192
- return {
193
- schema_version: WU_LIFECYCLE_EVENT_SCHEMA_VERSION,
194
- kind: WU_LIFECYCLE_EVENT_KINDS.CREATE,
195
- task_id: input.wuId,
196
- timestamp,
197
- spec_hash: resolveSpecHash(input)
198
- };
199
- case WU_LIFECYCLE_COMMANDS.CLAIM:
200
- return {
201
- schema_version: WU_LIFECYCLE_EVENT_SCHEMA_VERSION,
202
- kind: WU_LIFECYCLE_EVENT_KINDS.CLAIM,
203
- task_id: input.wuId,
204
- timestamp,
205
- by: asNonEmptyString2(input.by) ?? WU_LIFECYCLE_CLAIM_DEFAULTS.ACTOR,
206
- session_id: asNonEmptyString2(input.sessionId) ?? WU_LIFECYCLE_CLAIM_DEFAULTS.SESSION_ID
207
- };
208
- case WU_LIFECYCLE_COMMANDS.DONE:
209
- return {
210
- schema_version: WU_LIFECYCLE_EVENT_SCHEMA_VERSION,
211
- kind: WU_LIFECYCLE_EVENT_KINDS.DONE,
212
- task_id: input.wuId,
213
- timestamp,
214
- ...input.evidenceRefs && input.evidenceRefs.length > 0 ? { evidence_refs: input.evidenceRefs } : {}
215
- };
216
- default: {
217
- const exhaustiveCheck = input.command;
218
- throw createError(
219
- ErrorCodes.INVALID_ARGUMENT,
220
- `Unsupported WU lifecycle command: ${exhaustiveCheck}`
221
- );
222
- }
223
- }
224
- }
225
- async function flushWuLifecycleSync(input, options = {}) {
226
- const logger = options.logger;
227
- try {
228
- const sink = options.sink ?? await resolveWuLifecycleEventSink(options);
229
- const event = buildWuLifecycleKernelEvent(input);
230
- return await sink.push([event]);
231
- } catch (error) {
232
- logger?.warn?.(`${WU_LIFECYCLE_SYNC_LOG_PREFIX} fail-open: ${getErrorMessage(error)}`);
233
- return {
234
- sent: WU_LIFECYCLE_SYNC_RESULT_DEFAULTS.SENT,
235
- accepted: WU_LIFECYCLE_SYNC_RESULT_DEFAULTS.ACCEPTED,
236
- skippedReason: WU_LIFECYCLE_SYNC_SKIPPED_REASONS.PUSH_FAILED
237
- };
238
- }
239
- }
240
-
241
- export {
242
- buildWuLifecycleKernelEvent,
243
- flushWuLifecycleSync
244
- };
@@ -1,87 +0,0 @@
1
- import {
2
- loadMemory
3
- } from "./chunk-DFR4DJBM.js";
4
- import {
5
- LUMENFLOW_MEMORY_PATHS
6
- } from "./chunk-4N74J3UT.js";
7
-
8
- // ../memory/dist/mem-export-core.js
9
- import path from "path";
10
- function applyFilters(nodes, options) {
11
- const { wuId, type, lifecycle } = options;
12
- return nodes.filter((node) => {
13
- if (wuId && node.wu_id !== wuId)
14
- return false;
15
- if (type && node.type !== type)
16
- return false;
17
- if (lifecycle && node.lifecycle !== lifecycle)
18
- return false;
19
- return true;
20
- });
21
- }
22
- function formatFilters(options) {
23
- const parts = [];
24
- if (options.wuId)
25
- parts.push(`wu=${options.wuId}`);
26
- if (options.type)
27
- parts.push(`type=${options.type}`);
28
- if (options.lifecycle)
29
- parts.push(`lifecycle=${options.lifecycle}`);
30
- return parts.length === 0 ? "none" : parts.join(", ");
31
- }
32
- function formatMarkdown(nodes, options) {
33
- const lines = [];
34
- lines.push("# Memory Export");
35
- lines.push(`Filters: ${formatFilters(options)}`);
36
- lines.push(`Total: ${nodes.length}`);
37
- lines.push("");
38
- if (nodes.length === 0) {
39
- lines.push("No matching nodes.");
40
- return lines.join("\n");
41
- }
42
- for (const node of nodes) {
43
- lines.push(`## ${node.id} (${node.type})`);
44
- lines.push(`- Created: ${node.created_at}`);
45
- lines.push(`- Lifecycle: ${node.lifecycle}`);
46
- if (node.wu_id) {
47
- lines.push(`- WU: ${node.wu_id}`);
48
- }
49
- lines.push(`- Content: ${node.content}`);
50
- if (node.tags && node.tags.length > 0) {
51
- lines.push(`- Tags: ${node.tags.join(", ")}`);
52
- }
53
- if (node.metadata && Object.keys(node.metadata).length > 0) {
54
- lines.push(`- Metadata: ${JSON.stringify(node.metadata)}`);
55
- }
56
- lines.push("");
57
- }
58
- return lines.join("\n");
59
- }
60
- function formatJson(nodes, options) {
61
- const payload = {
62
- count: nodes.length,
63
- filters: {
64
- wuId: options.wuId ?? null,
65
- type: options.type ?? null,
66
- lifecycle: options.lifecycle ?? null
67
- },
68
- nodes
69
- };
70
- return JSON.stringify(payload, null, 2);
71
- }
72
- async function exportMemory(baseDir, options = {}) {
73
- const memoryDir = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
74
- const memory = await loadMemory(memoryDir);
75
- const nodes = applyFilters(memory.nodes, options);
76
- const format = options.format ?? "markdown";
77
- const output = format === "json" ? formatJson(nodes, options) : formatMarkdown(nodes, options);
78
- return {
79
- format,
80
- nodes,
81
- output
82
- };
83
- }
84
-
85
- export {
86
- exportMemory
87
- };