@lumenflow/cli 3.17.7 → 3.18.1

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 (156) hide show
  1. package/README.md +44 -43
  2. package/dist/chunk-2D2VOCA4.js +37 -0
  3. package/dist/chunk-2D5KFYGX.js +284 -0
  4. package/dist/chunk-2GXVIN57.js +14072 -0
  5. package/dist/chunk-2MQ7HZWZ.js +26 -0
  6. package/dist/chunk-2UFQ3A3C.js +643 -0
  7. package/dist/chunk-3RG5ZIWI.js +10 -0
  8. package/dist/chunk-4N74J3UT.js +15 -0
  9. package/dist/chunk-5GTOXFYR.js +392 -0
  10. package/dist/chunk-5VY6MQMC.js +240 -0
  11. package/dist/chunk-67XVPMRY.js +1297 -0
  12. package/dist/chunk-6HO4GWJE.js +164 -0
  13. package/dist/chunk-6W5XHWYV.js +1890 -0
  14. package/dist/chunk-6X4EMYJQ.js +64 -0
  15. package/dist/chunk-6XYXI2NQ.js +772 -0
  16. package/dist/chunk-7ANSOV6Q.js +285 -0
  17. package/dist/chunk-A624LFLB.js +1380 -0
  18. package/dist/chunk-ADN5NHG4.js +126 -0
  19. package/dist/chunk-B7YJYJKG.js +33 -0
  20. package/dist/chunk-CCLHCPKG.js +210 -0
  21. package/dist/chunk-CK36VROC.js +1584 -0
  22. package/dist/chunk-D3UOFRSB.js +81 -0
  23. package/dist/chunk-DFR4DJBM.js +230 -0
  24. package/dist/chunk-DSYBDHYH.js +79 -0
  25. package/dist/chunk-DWMLTXKQ.js +1176 -0
  26. package/dist/chunk-E3REJTAJ.js +28 -0
  27. package/dist/chunk-EA3IVO64.js +633 -0
  28. package/dist/chunk-EK2AKZKD.js +55 -0
  29. package/dist/chunk-ELD7JTTT.js +343 -0
  30. package/dist/chunk-EX6TT2XI.js +195 -0
  31. package/dist/chunk-EXINSFZE.js +82 -0
  32. package/dist/chunk-EZ6ZBYBM.js +510 -0
  33. package/dist/chunk-FBKAPTJ2.js +16 -0
  34. package/dist/chunk-FVLV5RYH.js +1118 -0
  35. package/dist/chunk-GDNSBQVK.js +2485 -0
  36. package/dist/chunk-GPQHMBNN.js +278 -0
  37. package/dist/chunk-GTFJB67L.js +68 -0
  38. package/dist/chunk-HANJXVKW.js +1127 -0
  39. package/dist/chunk-HEVS5YLD.js +269 -0
  40. package/dist/chunk-HMEVZKPQ.js +9 -0
  41. package/dist/chunk-HRGSYNLM.js +3511 -0
  42. package/dist/chunk-ISZR5N4K.js +60 -0
  43. package/dist/chunk-J6SUPR2C.js +226 -0
  44. package/dist/chunk-JERYVEIZ.js +244 -0
  45. package/dist/chunk-JHHWGL2N.js +87 -0
  46. package/dist/chunk-JONWQUB5.js +775 -0
  47. package/dist/chunk-K2DIWWDM.js +1766 -0
  48. package/dist/chunk-KY4PGL5V.js +969 -0
  49. package/dist/chunk-L737LQ4C.js +1285 -0
  50. package/dist/chunk-LFTWYIB2.js +497 -0
  51. package/dist/chunk-LV47RFNJ.js +41 -0
  52. package/dist/chunk-MKSAITI7.js +15 -0
  53. package/dist/chunk-MZ7RKIX4.js +212 -0
  54. package/dist/chunk-NAP6CFSO.js +84 -0
  55. package/dist/chunk-ND6MY37M.js +16 -0
  56. package/dist/chunk-NMG736UR.js +683 -0
  57. package/dist/chunk-NRAXROED.js +32 -0
  58. package/dist/chunk-NRIZR3A7.js +690 -0
  59. package/dist/chunk-NX43BG3M.js +233 -0
  60. package/dist/chunk-O645XLSI.js +297 -0
  61. package/dist/chunk-OMJD6A3S.js +235 -0
  62. package/dist/chunk-QB6SJD4T.js +430 -0
  63. package/dist/chunk-QFSTL4J3.js +276 -0
  64. package/dist/chunk-QLGDFMFX.js +212 -0
  65. package/dist/chunk-RIAAGL2E.js +13 -0
  66. package/dist/chunk-RWO5XMZ6.js +86 -0
  67. package/dist/chunk-RXRKBBSM.js +149 -0
  68. package/dist/chunk-RZOZMML6.js +363 -0
  69. package/dist/chunk-U7I7FS7T.js +113 -0
  70. package/dist/chunk-UI42RODY.js +717 -0
  71. package/dist/chunk-UTVMVSCO.js +519 -0
  72. package/dist/chunk-V6OJGLBA.js +1746 -0
  73. package/dist/chunk-W2JHVH7D.js +152 -0
  74. package/dist/chunk-WD3Y7VQN.js +280 -0
  75. package/dist/chunk-WOCTQ5MS.js +303 -0
  76. package/dist/chunk-WZR3ZUNN.js +696 -0
  77. package/dist/chunk-XGI665H7.js +150 -0
  78. package/dist/chunk-XKY65P2T.js +304 -0
  79. package/dist/chunk-Y4CQZY65.js +57 -0
  80. package/dist/chunk-YFEXKLVE.js +194 -0
  81. package/dist/chunk-YHO3HS5X.js +287 -0
  82. package/dist/chunk-YLS7AZSX.js +738 -0
  83. package/dist/chunk-ZE473AO6.js +49 -0
  84. package/dist/chunk-ZF747T3O.js +644 -0
  85. package/dist/chunk-ZHCZHZH3.js +43 -0
  86. package/dist/chunk-ZZNZX2XY.js +87 -0
  87. package/dist/config-set.js +10 -1
  88. package/dist/config-set.js.map +1 -1
  89. package/dist/constants-7QAP3VQ4.js +23 -0
  90. package/dist/dist-IY3UUMWK.js +33 -0
  91. package/dist/gate-co-change.js +5 -2
  92. package/dist/gate-co-change.js.map +1 -1
  93. package/dist/init-detection.js +5 -3
  94. package/dist/init-detection.js.map +1 -1
  95. package/dist/init-templates.js +4 -4
  96. package/dist/init-templates.js.map +1 -1
  97. package/dist/initiative-edit.js +8 -3
  98. package/dist/initiative-edit.js.map +1 -1
  99. package/dist/initiative-plan.js +1 -1
  100. package/dist/initiative-plan.js.map +1 -1
  101. package/dist/invariants-runner-W5RGHCSU.js +27 -0
  102. package/dist/lane-lock-6J36HD5O.js +35 -0
  103. package/dist/lumenflow-upgrade.js +49 -0
  104. package/dist/lumenflow-upgrade.js.map +1 -1
  105. package/dist/mem-checkpoint-core-EANG2GVN.js +14 -0
  106. package/dist/mem-signal-core-2LZ2WYHW.js +19 -0
  107. package/dist/memory-store-OLB5FO7K.js +18 -0
  108. package/dist/pre-commit-check.js +1 -1
  109. package/dist/pre-commit-check.js.map +1 -1
  110. package/dist/service-6BYCOCO5.js +13 -0
  111. package/dist/spawn-policy-resolver-NTSZYQ6R.js +17 -0
  112. package/dist/spawn-task-builder-R4E2BHSW.js +22 -0
  113. package/dist/wu-done-pr-WLFFFEPJ.js +25 -0
  114. package/dist/wu-done-validation-3J5E36FE.js +30 -0
  115. package/dist/wu-duplicate-id-detector-5S7JHELK.js +232 -0
  116. package/dist/wu-edit-operations.js +4 -0
  117. package/dist/wu-edit-operations.js.map +1 -1
  118. package/dist/wu-edit-validators.js +4 -0
  119. package/dist/wu-edit-validators.js.map +1 -1
  120. package/dist/wu-edit.js +11 -0
  121. package/dist/wu-edit.js.map +1 -1
  122. package/dist/wu-spawn-strategy-resolver.js +13 -1
  123. package/dist/wu-spawn-strategy-resolver.js.map +1 -1
  124. package/package.json +8 -8
  125. package/packs/agent-runtime/.turbo/turbo-build.log +4 -0
  126. package/packs/agent-runtime/README.md +147 -0
  127. package/packs/agent-runtime/capability-factory.ts +104 -0
  128. package/packs/agent-runtime/config.schema.json +87 -0
  129. package/packs/agent-runtime/constants.ts +21 -0
  130. package/packs/agent-runtime/index.ts +11 -0
  131. package/packs/agent-runtime/manifest.ts +207 -0
  132. package/packs/agent-runtime/manifest.yaml +193 -0
  133. package/packs/agent-runtime/orchestration.ts +1787 -0
  134. package/packs/agent-runtime/pack-registration.ts +110 -0
  135. package/packs/agent-runtime/package.json +57 -0
  136. package/packs/agent-runtime/policy-factory.ts +165 -0
  137. package/packs/agent-runtime/tool-impl/agent-turn-tools.ts +793 -0
  138. package/packs/agent-runtime/tool-impl/index.ts +5 -0
  139. package/packs/agent-runtime/tool-impl/provider-adapters.ts +1245 -0
  140. package/packs/agent-runtime/tools/index.ts +4 -0
  141. package/packs/agent-runtime/tools/types.ts +47 -0
  142. package/packs/agent-runtime/tsconfig.json +20 -0
  143. package/packs/agent-runtime/types.ts +128 -0
  144. package/packs/agent-runtime/vitest.config.ts +11 -0
  145. package/packs/sidekick/.turbo/turbo-build.log +1 -1
  146. package/packs/sidekick/.turbo/turbo-test.log +12 -0
  147. package/packs/sidekick/.turbo/turbo-typecheck.log +4 -0
  148. package/packs/sidekick/package.json +1 -1
  149. package/packs/software-delivery/.turbo/turbo-build.log +1 -1
  150. package/packs/software-delivery/.turbo/turbo-typecheck.log +4 -0
  151. package/packs/software-delivery/package.json +1 -1
  152. package/templates/core/.lumenflow/rules/wu-workflow.md.template +1 -1
  153. package/templates/core/ai/onboarding/first-wu-mistakes.md.template +2 -2
  154. package/templates/core/ai/onboarding/quick-ref-commands.md.template +1 -1
  155. package/templates/core/ai/onboarding/starting-prompt.md.template +1 -1
  156. package/templates/vendors/claude/.claude/skills/frontend-design/SKILL.md.template +1 -1
@@ -0,0 +1,278 @@
1
+ import {
2
+ startSession
3
+ } from "./chunk-GTFJB67L.js";
4
+ import {
5
+ parseYAML
6
+ } from "./chunk-NRIZR3A7.js";
7
+ import {
8
+ CONFIG_FILES,
9
+ LUMENFLOW_PATHS
10
+ } from "./chunk-DWMLTXKQ.js";
11
+
12
+ // ../agent/dist/auto-session-integration.js
13
+ import { randomUUID } from "crypto";
14
+ import { readFileSync, writeFileSync, existsSync, unlinkSync, mkdirSync } from "fs";
15
+ import { join } from "path";
16
+
17
+ // ../memory/dist/mem-index-core.js
18
+ import fs from "fs/promises";
19
+ import path from "path";
20
+ import crypto from "crypto";
21
+
22
+ // ../memory/dist/mem-promote-core.js
23
+ import fs2 from "fs/promises";
24
+ import path2 from "path";
25
+ var ALLOWED_PROMOTION_TAGS = [
26
+ "decision",
27
+ "convention",
28
+ "pattern",
29
+ "pitfall",
30
+ "interface",
31
+ "invariant",
32
+ "faq"
33
+ ];
34
+ var ERROR_MESSAGES = {
35
+ NODE_NOT_FOUND: "Node not found",
36
+ ALREADY_PROJECT: "Node is already at project lifecycle",
37
+ INVALID_TAG: `Tag must be one of: ${ALLOWED_PROMOTION_TAGS.join(", ")}`,
38
+ INVALID_WU_ID: "Invalid WU ID format. Expected pattern: WU-XXX (e.g., WU-1234)"
39
+ };
40
+
41
+ // ../memory/dist/memory-promotion.js
42
+ import fs3 from "fs/promises";
43
+ import path3 from "path";
44
+
45
+ // ../memory/dist/mem-profile-core.js
46
+ import path4 from "path";
47
+
48
+ // ../memory/dist/control-plane-sync-adapter.js
49
+ import fs4 from "fs/promises";
50
+ import path5 from "path";
51
+ var DEFAULT_CONTROL_PLANE_SYNC_STATE_PATH = path5.join(".lumenflow", "state", "control-plane-sync.json");
52
+
53
+ // ../agent/dist/auto-session-integration.js
54
+ var SESSION_FILENAME = "current.json";
55
+ var WORKSPACE_CONFIG_FILE = CONFIG_FILES.WORKSPACE_CONFIG;
56
+ var CONTROL_PLANE_REGISTER_PATH = "/api/v1/sessions/register";
57
+ var CONTROL_PLANE_DEREGISTER_PATH = "/api/v1/sessions/deregister";
58
+ var DEFAULT_TIER = 2;
59
+ var DEFAULT_AGENT_TYPE = "claude-code";
60
+ var DEFAULT_AGENT_VERSION = "unknown";
61
+ var DEFAULT_HOST_ID = "unknown";
62
+ var DEFAULT_AGENT_CAPABILITIES = ["session_lifecycle", "heartbeat"];
63
+ var AGENT_CAPABILITIES_ENV = "LUMENFLOW_AGENT_CAPABILITIES";
64
+ var AGENT_VERSION_ENV = "LUMENFLOW_AGENT_VERSION";
65
+ var CONTEXT_TIER_MAP = {
66
+ 1: "minimal",
67
+ 2: "core",
68
+ 3: "full"
69
+ };
70
+ function parseCapabilities(rawValue) {
71
+ if (!rawValue) {
72
+ return [...DEFAULT_AGENT_CAPABILITIES];
73
+ }
74
+ const parsed = rawValue.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0);
75
+ return parsed.length > 0 ? parsed : [...DEFAULT_AGENT_CAPABILITIES];
76
+ }
77
+ function asNonEmptyString(value) {
78
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
79
+ }
80
+ function normalizeEndpoint(endpoint) {
81
+ return endpoint.endsWith("/") ? endpoint.slice(0, endpoint.length - 1) : endpoint;
82
+ }
83
+ function resolveControlPlaneSessionSyncConfig(workspaceRoot, environment) {
84
+ const workspacePath = join(workspaceRoot, WORKSPACE_CONFIG_FILE);
85
+ if (!existsSync(workspacePath)) {
86
+ return null;
87
+ }
88
+ let parsedWorkspace;
89
+ try {
90
+ parsedWorkspace = parseYAML(readFileSync(workspacePath, { encoding: "utf-8" }));
91
+ } catch {
92
+ return null;
93
+ }
94
+ const workspaceId = asNonEmptyString(parsedWorkspace?.id);
95
+ const endpoint = asNonEmptyString(parsedWorkspace?.control_plane?.endpoint);
96
+ const tokenEnv = asNonEmptyString(parsedWorkspace?.control_plane?.auth?.token_env);
97
+ if (!workspaceId || !endpoint || !tokenEnv) {
98
+ return null;
99
+ }
100
+ const token = asNonEmptyString(environment[tokenEnv]);
101
+ if (!token) {
102
+ return null;
103
+ }
104
+ try {
105
+ void new URL(endpoint);
106
+ } catch {
107
+ return null;
108
+ }
109
+ return {
110
+ workspaceId,
111
+ endpoint: normalizeEndpoint(endpoint),
112
+ token
113
+ };
114
+ }
115
+ function resolveStandardSessionMetadata(input) {
116
+ const clientType = input.agentType;
117
+ const capabilities = parseCapabilities(asNonEmptyString(input.environment[AGENT_CAPABILITIES_ENV]));
118
+ const agentVersion = asNonEmptyString(input.environment[AGENT_VERSION_ENV]) ?? DEFAULT_AGENT_VERSION;
119
+ const hostId = asNonEmptyString(input.environment.HOSTNAME) ?? asNonEmptyString(input.environment.COMPUTERNAME) ?? DEFAULT_HOST_ID;
120
+ return {
121
+ client_type: clientType,
122
+ capabilities,
123
+ agent_version: agentVersion,
124
+ host_id: hostId,
125
+ metadata: {
126
+ client_type: clientType,
127
+ capabilities,
128
+ agent_version: agentVersion,
129
+ host_id: hostId
130
+ }
131
+ };
132
+ }
133
+ async function postControlPlaneSessionHook(endpoint, token, path6, payload, fetchFn) {
134
+ const response = await fetchFn(`${endpoint}${path6}`, {
135
+ method: "POST",
136
+ headers: {
137
+ authorization: `Bearer ${token}`,
138
+ "content-type": "application/json"
139
+ },
140
+ body: JSON.stringify(payload)
141
+ });
142
+ if (!response.ok) {
143
+ throw new Error(`HTTP ${response.status}`);
144
+ }
145
+ }
146
+ function getSessionFilePath(sessionDir) {
147
+ return join(sessionDir, SESSION_FILENAME);
148
+ }
149
+ async function startSessionForWU(options) {
150
+ const { wuId, tier = DEFAULT_TIER, agentType = DEFAULT_AGENT_TYPE, lane, sessionDir, workspaceRoot = process.cwd(), environment = process.env, controlPlaneSyncPort, fetchFn = fetch, baseDir = process.cwd() } = options;
151
+ const sessDir = sessionDir ?? LUMENFLOW_PATHS.SESSIONS;
152
+ const sessionFile = getSessionFilePath(sessDir);
153
+ if (existsSync(sessionFile)) {
154
+ const existing = JSON.parse(readFileSync(sessionFile, { encoding: "utf-8" }));
155
+ return {
156
+ sessionId: existing.session_id,
157
+ alreadyActive: true
158
+ };
159
+ }
160
+ if (!existsSync(sessDir)) {
161
+ mkdirSync(sessDir, { recursive: true });
162
+ }
163
+ const sessionId = randomUUID();
164
+ const session = {
165
+ session_id: sessionId,
166
+ wu_id: wuId,
167
+ started: (/* @__PURE__ */ new Date()).toISOString(),
168
+ agent_type: agentType,
169
+ context_tier: tier,
170
+ incidents_logged: 0,
171
+ incidents_major: 0,
172
+ auto_started: true
173
+ // Mark as auto-started by wu:claim
174
+ };
175
+ writeFileSync(sessionFile, JSON.stringify(session, null, 2), { encoding: "utf-8" });
176
+ let memoryNodeId = null;
177
+ try {
178
+ const memResult = await startSession(baseDir, {
179
+ wuId,
180
+ agentType,
181
+ contextTier: CONTEXT_TIER_MAP[tier] ?? "full"
182
+ });
183
+ memoryNodeId = memResult.session?.id ?? null;
184
+ } catch {
185
+ }
186
+ const controlPlaneConfig = resolveControlPlaneSessionSyncConfig(workspaceRoot, environment);
187
+ if (controlPlaneConfig) {
188
+ const standardizedMetadata = resolveStandardSessionMetadata({
189
+ agentType,
190
+ environment
191
+ });
192
+ const registerInput = {
193
+ workspace_id: controlPlaneConfig.workspaceId,
194
+ session_id: sessionId,
195
+ agent_id: agentType,
196
+ started_at: session.started,
197
+ lane,
198
+ wu_id: wuId,
199
+ client_type: standardizedMetadata.client_type,
200
+ capabilities: standardizedMetadata.capabilities,
201
+ agent_version: standardizedMetadata.agent_version,
202
+ host_id: standardizedMetadata.host_id,
203
+ metadata: standardizedMetadata.metadata
204
+ };
205
+ try {
206
+ if (controlPlaneSyncPort) {
207
+ await controlPlaneSyncPort.registerSession(registerInput);
208
+ } else {
209
+ await postControlPlaneSessionHook(controlPlaneConfig.endpoint, controlPlaneConfig.token, CONTROL_PLANE_REGISTER_PATH, registerInput, fetchFn);
210
+ }
211
+ } catch {
212
+ }
213
+ }
214
+ return {
215
+ sessionId,
216
+ alreadyActive: false,
217
+ memoryNodeId
218
+ };
219
+ }
220
+ function endSessionForWU(options = {}) {
221
+ const { sessionDir, workspaceRoot = process.cwd(), environment = process.env, controlPlaneSyncPort, fetchFn = fetch } = options;
222
+ const sessDir = sessionDir ?? LUMENFLOW_PATHS.SESSIONS;
223
+ const sessionFile = getSessionFilePath(sessDir);
224
+ if (!existsSync(sessionFile)) {
225
+ return {
226
+ ended: false,
227
+ reason: "no_active_session"
228
+ };
229
+ }
230
+ const session = JSON.parse(readFileSync(sessionFile, { encoding: "utf-8" }));
231
+ session.completed = (/* @__PURE__ */ new Date()).toISOString();
232
+ const summary = {
233
+ wu_id: session.wu_id,
234
+ session_id: session.session_id,
235
+ started: session.started,
236
+ completed: session.completed,
237
+ agent_type: session.agent_type,
238
+ context_tier: session.context_tier,
239
+ incidents_logged: session.incidents_logged,
240
+ incidents_major: session.incidents_major
241
+ };
242
+ unlinkSync(sessionFile);
243
+ const controlPlaneConfig = resolveControlPlaneSessionSyncConfig(workspaceRoot, environment);
244
+ if (controlPlaneConfig) {
245
+ const deregisterInput = {
246
+ workspace_id: controlPlaneConfig.workspaceId,
247
+ session_id: session.session_id,
248
+ ended_at: session.completed,
249
+ reason: "wu_done"
250
+ };
251
+ if (controlPlaneSyncPort) {
252
+ void controlPlaneSyncPort.deregisterSession(deregisterInput).catch(() => {
253
+ });
254
+ } else {
255
+ void postControlPlaneSessionHook(controlPlaneConfig.endpoint, controlPlaneConfig.token, CONTROL_PLANE_DEREGISTER_PATH, deregisterInput, fetchFn).catch(() => {
256
+ });
257
+ }
258
+ }
259
+ return {
260
+ ended: true,
261
+ summary
262
+ };
263
+ }
264
+ function getCurrentSessionForWU(options = {}) {
265
+ const { sessionDir } = options;
266
+ const sessDir = sessionDir ?? LUMENFLOW_PATHS.SESSIONS;
267
+ const sessionFile = getSessionFilePath(sessDir);
268
+ if (!existsSync(sessionFile)) {
269
+ return null;
270
+ }
271
+ return JSON.parse(readFileSync(sessionFile, { encoding: "utf-8" }));
272
+ }
273
+
274
+ export {
275
+ startSessionForWU,
276
+ endSessionForWU,
277
+ getCurrentSessionForWU
278
+ };
@@ -0,0 +1,68 @@
1
+ import {
2
+ ensureMemoryDir
3
+ } from "./chunk-ND6MY37M.js";
4
+ import {
5
+ generateMemId
6
+ } from "./chunk-RIAAGL2E.js";
7
+ import {
8
+ MEMORY_PATTERNS,
9
+ appendNode
10
+ } from "./chunk-DFR4DJBM.js";
11
+ import {
12
+ ErrorCodes,
13
+ createError
14
+ } from "./chunk-RXRKBBSM.js";
15
+
16
+ // ../memory/dist/mem-start-core.js
17
+ import { randomUUID } from "crypto";
18
+ var DEFAULTS = {
19
+ AGENT_TYPE: "unknown",
20
+ CONTEXT_TIER: "full"
21
+ };
22
+ var ERROR_MESSAGES = {
23
+ WU_ID_REQUIRED: "wuId is required",
24
+ WU_ID_INVALID: "Invalid WU ID format. Expected pattern: WU-XXX (e.g., WU-123)"
25
+ };
26
+ function isValidWuId(wuId) {
27
+ return MEMORY_PATTERNS.WU_ID.test(wuId);
28
+ }
29
+ function generateSessionContent(wuId, agentType, contextTier) {
30
+ return `Session started for ${wuId}. Agent: ${agentType}, Context: ${contextTier}`;
31
+ }
32
+ async function startSession(baseDir, options) {
33
+ const { wuId, agentType = DEFAULTS.AGENT_TYPE, contextTier = DEFAULTS.CONTEXT_TIER } = options;
34
+ if (!wuId) {
35
+ throw createError(ErrorCodes.VALIDATION_ERROR, ERROR_MESSAGES.WU_ID_REQUIRED);
36
+ }
37
+ if (!isValidWuId(wuId)) {
38
+ throw createError(ErrorCodes.INVALID_WU_ID, ERROR_MESSAGES.WU_ID_INVALID);
39
+ }
40
+ const memoryDir = await ensureMemoryDir(baseDir);
41
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
42
+ const sessionId = randomUUID();
43
+ const content = generateSessionContent(wuId, agentType, contextTier);
44
+ const idContent = `${content}-${timestamp}-${sessionId}`;
45
+ const id = generateMemId(idContent);
46
+ const sessionNode = {
47
+ id,
48
+ type: "session",
49
+ lifecycle: "wu",
50
+ content,
51
+ created_at: timestamp,
52
+ wu_id: wuId,
53
+ session_id: sessionId,
54
+ metadata: {
55
+ agentType,
56
+ contextTier
57
+ }
58
+ };
59
+ await appendNode(memoryDir, sessionNode);
60
+ return {
61
+ success: true,
62
+ session: sessionNode
63
+ };
64
+ }
65
+
66
+ export {
67
+ startSession
68
+ };