@cleocode/runtime 2026.5.130 → 2026.5.131
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/dist/chunk-5ZXRYEQ5.js +190 -0
- package/dist/chunk-5ZXRYEQ5.js.map +1 -0
- package/dist/chunk-R4XBXUQN.js +253 -0
- package/dist/chunk-R4XBXUQN.js.map +1 -0
- package/dist/chunk-WSQQ5DQL.js +215 -0
- package/dist/chunk-WSQQ5DQL.js.map +1 -0
- package/dist/chunk-YZBIPGMH.js +305 -0
- package/dist/chunk-YZBIPGMH.js.map +1 -0
- package/dist/daemon/index.d.ts +306 -0
- package/dist/daemon/index.js +15 -0
- package/dist/daemon/index.js.map +1 -0
- package/dist/gateway/http/index.d.ts +10 -0
- package/dist/gateway/http/index.js +21 -0
- package/dist/gateway/http/index.js.map +1 -0
- package/dist/gateway/index.d.ts +10 -0
- package/dist/gateway/index.js +1220 -0
- package/dist/gateway/index.js.map +1 -0
- package/dist/gateway/mcp/index.d.ts +10 -0
- package/dist/gateway/mcp/index.js +21 -0
- package/dist/gateway/mcp/index.js.map +1 -0
- package/dist/gateway/rpc/index.d.ts +1545 -0
- package/dist/gateway/rpc/index.js +17 -0
- package/dist/gateway/rpc/index.js.map +1 -0
- package/package.json +23 -3
|
@@ -0,0 +1,1220 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineSubsystem
|
|
3
|
+
} from "../chunk-WSQQ5DQL.js";
|
|
4
|
+
import {
|
|
5
|
+
MCP_TOOL_PREFIX,
|
|
6
|
+
OPERATIONS,
|
|
7
|
+
buildToolsList,
|
|
8
|
+
callTool,
|
|
9
|
+
deriveGatewayMatrix,
|
|
10
|
+
exposedOperations,
|
|
11
|
+
getActiveDomains,
|
|
12
|
+
getByDomain,
|
|
13
|
+
getByGateway,
|
|
14
|
+
getByTier,
|
|
15
|
+
getCounts,
|
|
16
|
+
getGatewayDomains,
|
|
17
|
+
operationToMcpTool,
|
|
18
|
+
operationToToolName,
|
|
19
|
+
resolve,
|
|
20
|
+
startMcpServer,
|
|
21
|
+
toolNameToOperationKey,
|
|
22
|
+
validateRequiredParams
|
|
23
|
+
} from "../chunk-R4XBXUQN.js";
|
|
24
|
+
import {
|
|
25
|
+
LineBuffer,
|
|
26
|
+
buildErrorFrame,
|
|
27
|
+
decodeLine,
|
|
28
|
+
encodeFrame,
|
|
29
|
+
routeFrame,
|
|
30
|
+
startRpcServer
|
|
31
|
+
} from "../chunk-5ZXRYEQ5.js";
|
|
32
|
+
import {
|
|
33
|
+
SSE_HEADERS,
|
|
34
|
+
createSseStream,
|
|
35
|
+
encodeSseFrame,
|
|
36
|
+
encodeStreamEvent,
|
|
37
|
+
parseHttpRoute,
|
|
38
|
+
routeUnary,
|
|
39
|
+
startHttpServer,
|
|
40
|
+
statusForResponse
|
|
41
|
+
} from "../chunk-YZBIPGMH.js";
|
|
42
|
+
|
|
43
|
+
// src/gateway/dispatcher.ts
|
|
44
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
45
|
+
import { getLogger, getProjectRoot } from "@cleocode/core";
|
|
46
|
+
|
|
47
|
+
// src/gateway/meta.ts
|
|
48
|
+
import { randomUUID } from "crypto";
|
|
49
|
+
function createDispatchMeta(gateway, domain, operation, startTime, source = "cli", requestId, sessionId, originSessionId, executionSessionId) {
|
|
50
|
+
return {
|
|
51
|
+
gateway,
|
|
52
|
+
domain,
|
|
53
|
+
operation,
|
|
54
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
55
|
+
duration_ms: Date.now() - startTime,
|
|
56
|
+
source,
|
|
57
|
+
requestId: requestId ?? randomUUID(),
|
|
58
|
+
...sessionId != null && { sessionId },
|
|
59
|
+
...originSessionId != null && { originSessionId },
|
|
60
|
+
...executionSessionId != null && { executionSessionId }
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// src/gateway/pipeline.ts
|
|
65
|
+
function compose(middlewares) {
|
|
66
|
+
if (middlewares.length === 0) {
|
|
67
|
+
return async (_req, next) => next();
|
|
68
|
+
}
|
|
69
|
+
return async (request, next) => {
|
|
70
|
+
let index = -1;
|
|
71
|
+
async function dispatch(i) {
|
|
72
|
+
if (i <= index) {
|
|
73
|
+
throw new Error("next() called multiple times in middleware");
|
|
74
|
+
}
|
|
75
|
+
index = i;
|
|
76
|
+
let fn = middlewares[i];
|
|
77
|
+
if (i === middlewares.length) {
|
|
78
|
+
fn = async (_req, nxt) => nxt();
|
|
79
|
+
}
|
|
80
|
+
if (!fn) {
|
|
81
|
+
return next();
|
|
82
|
+
}
|
|
83
|
+
return fn(request, async () => {
|
|
84
|
+
if (i === middlewares.length) {
|
|
85
|
+
return next();
|
|
86
|
+
}
|
|
87
|
+
return dispatch(i + 1);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return dispatch(0);
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/gateway/dispatcher.ts
|
|
95
|
+
var DIALECTIC_RATE_LIMIT_MS = 1e4;
|
|
96
|
+
var _dialecticLastEvalMs = /* @__PURE__ */ new Map();
|
|
97
|
+
function ensureRequestSessionLineage(request) {
|
|
98
|
+
request.executionSessionId ??= process.env.CLEO_EXECUTION_SESSION_ID ?? process.env.CLEO_SESSION_EXECUTION_ID ?? randomUUID2();
|
|
99
|
+
request.originSessionId ??= process.env.CLEO_ORIGIN_SESSION_ID ?? process.env.CLEO_SESSION_ORIGIN_ID ?? request.sessionId ?? request.executionSessionId;
|
|
100
|
+
}
|
|
101
|
+
function isDialecticEvalAllowed(sessionId) {
|
|
102
|
+
const last = _dialecticLastEvalMs.get(sessionId) ?? 0;
|
|
103
|
+
const now = Date.now();
|
|
104
|
+
if (now - last < DIALECTIC_RATE_LIMIT_MS) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
_dialecticLastEvalMs.set(sessionId, now);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
var Dispatcher = class {
|
|
111
|
+
handlers;
|
|
112
|
+
pipeline;
|
|
113
|
+
constructor(config) {
|
|
114
|
+
this.handlers = config.handlers;
|
|
115
|
+
this.pipeline = config.middlewares?.length ? compose(config.middlewares) : (_req, next) => next();
|
|
116
|
+
}
|
|
117
|
+
async dispatch(request) {
|
|
118
|
+
const startTime = Date.now();
|
|
119
|
+
ensureRequestSessionLineage(request);
|
|
120
|
+
const resolved = resolve(request.gateway, request.domain, request.operation);
|
|
121
|
+
if (!resolved) {
|
|
122
|
+
return {
|
|
123
|
+
meta: createDispatchMeta(
|
|
124
|
+
request.gateway,
|
|
125
|
+
request.domain,
|
|
126
|
+
request.operation,
|
|
127
|
+
startTime,
|
|
128
|
+
request.source,
|
|
129
|
+
request.requestId,
|
|
130
|
+
request.sessionId,
|
|
131
|
+
request.originSessionId,
|
|
132
|
+
request.executionSessionId
|
|
133
|
+
),
|
|
134
|
+
success: false,
|
|
135
|
+
error: {
|
|
136
|
+
code: "E_INVALID_OPERATION",
|
|
137
|
+
message: `Unknown operation: ${request.gateway}:${request.domain}.${request.operation}`
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
const missing = validateRequiredParams(resolved.def, request.params);
|
|
142
|
+
if (missing.length > 0) {
|
|
143
|
+
return {
|
|
144
|
+
meta: createDispatchMeta(
|
|
145
|
+
request.gateway,
|
|
146
|
+
resolved.domain,
|
|
147
|
+
resolved.operation,
|
|
148
|
+
startTime,
|
|
149
|
+
request.source,
|
|
150
|
+
request.requestId,
|
|
151
|
+
request.sessionId,
|
|
152
|
+
request.originSessionId,
|
|
153
|
+
request.executionSessionId
|
|
154
|
+
),
|
|
155
|
+
success: false,
|
|
156
|
+
error: {
|
|
157
|
+
code: "E_MISSING_PARAMS",
|
|
158
|
+
message: `Missing required parameters: ${missing.join(", ")}`,
|
|
159
|
+
details: { missing }
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
const handler = this.handlers.get(resolved.domain);
|
|
164
|
+
if (!handler) {
|
|
165
|
+
return {
|
|
166
|
+
meta: createDispatchMeta(
|
|
167
|
+
request.gateway,
|
|
168
|
+
resolved.domain,
|
|
169
|
+
resolved.operation,
|
|
170
|
+
startTime,
|
|
171
|
+
request.source,
|
|
172
|
+
request.requestId,
|
|
173
|
+
request.sessionId,
|
|
174
|
+
request.originSessionId,
|
|
175
|
+
request.executionSessionId
|
|
176
|
+
),
|
|
177
|
+
success: false,
|
|
178
|
+
error: {
|
|
179
|
+
code: "E_NO_HANDLER",
|
|
180
|
+
message: `No handler for domain: ${resolved.domain}`
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
const terminal = async () => {
|
|
185
|
+
if (request.gateway === "query") {
|
|
186
|
+
return handler.query(resolved.operation, request.params);
|
|
187
|
+
} else {
|
|
188
|
+
return handler.mutate(resolved.operation, request.params);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
const response = await this.pipeline(request, terminal);
|
|
192
|
+
response.meta.duration_ms = Date.now() - startTime;
|
|
193
|
+
response.meta.requestId = request.requestId;
|
|
194
|
+
response.meta.source = request.source;
|
|
195
|
+
if (request.sessionId) {
|
|
196
|
+
response.meta.sessionId = request.sessionId;
|
|
197
|
+
}
|
|
198
|
+
if (request.originSessionId) {
|
|
199
|
+
response.meta.originSessionId = request.originSessionId;
|
|
200
|
+
}
|
|
201
|
+
if (request.executionSessionId) {
|
|
202
|
+
response.meta.executionSessionId = request.executionSessionId;
|
|
203
|
+
}
|
|
204
|
+
if (response.success && request.gateway === "mutate" && request.sessionId && isDialecticEvalAllowed(request.sessionId)) {
|
|
205
|
+
const capturedRequest = request;
|
|
206
|
+
const capturedSessionId = request.sessionId;
|
|
207
|
+
setImmediate(() => {
|
|
208
|
+
Promise.all([
|
|
209
|
+
import("@cleocode/core/memory/dialectic-evaluator.js"),
|
|
210
|
+
import("@cleocode/core/store/nexus-sqlite.js"),
|
|
211
|
+
import("@cleocode/core/store/memory-sqlite.js")
|
|
212
|
+
]).then(async ([{ evaluateDialectic, applyInsights }, { getNexusDb }, { getBrainDb }]) => {
|
|
213
|
+
const projectRoot = getProjectRoot();
|
|
214
|
+
const turn = {
|
|
215
|
+
userMessage: `cleo ${capturedRequest.domain} ${capturedRequest.operation} ${JSON.stringify(capturedRequest.params ?? {})}`,
|
|
216
|
+
systemResponse: `Operation succeeded in domain "${capturedRequest.domain}".`,
|
|
217
|
+
activePeerId: capturedRequest.params?.["peerId"] ?? "global",
|
|
218
|
+
sessionId: capturedSessionId
|
|
219
|
+
};
|
|
220
|
+
const insights = await evaluateDialectic(turn);
|
|
221
|
+
const [nexusDb, brainDb] = await Promise.all([getNexusDb(), getBrainDb()]);
|
|
222
|
+
await applyInsights(insights, nexusDb, brainDb, {
|
|
223
|
+
sessionId: capturedSessionId,
|
|
224
|
+
activePeerId: turn.activePeerId,
|
|
225
|
+
projectRoot
|
|
226
|
+
});
|
|
227
|
+
}).catch((err) => {
|
|
228
|
+
const log = getLogger("dialectic-hook");
|
|
229
|
+
log.warn({ err }, "dialectic-evaluator failed");
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return response;
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
// src/gateway/background-jobs.ts
|
|
238
|
+
import {
|
|
239
|
+
BackgroundJobManager,
|
|
240
|
+
DurableJobStore
|
|
241
|
+
} from "@cleocode/core/store/background-jobs.js";
|
|
242
|
+
|
|
243
|
+
// src/gateway/daemon-subsystem.ts
|
|
244
|
+
import { getLogger as getLogger2 } from "@cleocode/core";
|
|
245
|
+
function gatewaySubsystemName(scope) {
|
|
246
|
+
return `gateway-${scope}`;
|
|
247
|
+
}
|
|
248
|
+
function defineGatewaySubsystem(opts) {
|
|
249
|
+
if (opts.rpc === void 0 && opts.http === void 0) {
|
|
250
|
+
throw new TypeError(
|
|
251
|
+
"defineGatewaySubsystem: at least one transport (rpc and/or http) must be configured"
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
const name = gatewaySubsystemName(opts.scope);
|
|
255
|
+
const log = getLogger2(name);
|
|
256
|
+
let live;
|
|
257
|
+
return defineSubsystem({
|
|
258
|
+
name,
|
|
259
|
+
async start() {
|
|
260
|
+
let rpc;
|
|
261
|
+
try {
|
|
262
|
+
if (opts.rpc !== void 0) {
|
|
263
|
+
rpc = await startRpcServer(opts.handler, opts.rpc);
|
|
264
|
+
}
|
|
265
|
+
let http;
|
|
266
|
+
if (opts.http !== void 0) {
|
|
267
|
+
http = await startHttpServer(opts.handler, opts.http);
|
|
268
|
+
}
|
|
269
|
+
const context = { pid: process.pid, rpc, http };
|
|
270
|
+
live = context;
|
|
271
|
+
log.info(
|
|
272
|
+
{ scope: opts.scope, rpc: rpc?.socketPath, httpPort: http?.port },
|
|
273
|
+
"gateway subsystem started"
|
|
274
|
+
);
|
|
275
|
+
return context;
|
|
276
|
+
} catch (cause) {
|
|
277
|
+
if (rpc !== void 0) {
|
|
278
|
+
await rpc.close().catch(() => void 0);
|
|
279
|
+
}
|
|
280
|
+
live = void 0;
|
|
281
|
+
throw cause;
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
healthProbe() {
|
|
285
|
+
if (live === void 0) {
|
|
286
|
+
const stopped = "stopped";
|
|
287
|
+
return {
|
|
288
|
+
child_id: name,
|
|
289
|
+
pid: 0,
|
|
290
|
+
state: stopped,
|
|
291
|
+
restart_count: 0,
|
|
292
|
+
detail: `scope=${opts.scope} not started`
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
const transports = [];
|
|
296
|
+
if (live.rpc !== void 0) transports.push(`rpc=${live.rpc.socketPath}`);
|
|
297
|
+
if (live.http !== void 0) {
|
|
298
|
+
transports.push(`http=${live.http.host}:${live.http.port}`);
|
|
299
|
+
}
|
|
300
|
+
const running = "running";
|
|
301
|
+
return {
|
|
302
|
+
child_id: name,
|
|
303
|
+
pid: live.pid,
|
|
304
|
+
state: running,
|
|
305
|
+
restart_count: 0,
|
|
306
|
+
detail: `scope=${opts.scope} ${transports.join(" ")}`.trim()
|
|
307
|
+
};
|
|
308
|
+
},
|
|
309
|
+
async shutdown(context) {
|
|
310
|
+
if (context.http !== void 0) {
|
|
311
|
+
await context.http.close().catch((err) => {
|
|
312
|
+
log.warn({ err }, "gateway http close failed");
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
if (context.rpc !== void 0) {
|
|
316
|
+
await context.rpc.close().catch((err) => {
|
|
317
|
+
log.warn({ err }, "gateway rpc close failed");
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
live = void 0;
|
|
321
|
+
log.info({ scope: opts.scope }, "gateway subsystem stopped");
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// src/gateway/engine.ts
|
|
327
|
+
import {
|
|
328
|
+
addTaskWithSessionScope,
|
|
329
|
+
completeTaskStrict,
|
|
330
|
+
configGet,
|
|
331
|
+
configListPresets,
|
|
332
|
+
configSet,
|
|
333
|
+
configSetPreset,
|
|
334
|
+
coreBatchValidate,
|
|
335
|
+
coreCoherenceCheck,
|
|
336
|
+
coreComplianceRecord,
|
|
337
|
+
coreComplianceSummary,
|
|
338
|
+
coreComplianceViolations,
|
|
339
|
+
coreTestCoverage,
|
|
340
|
+
coreTestRun,
|
|
341
|
+
coreTestStatus,
|
|
342
|
+
coreValidateManifest,
|
|
343
|
+
coreValidateOutput,
|
|
344
|
+
coreValidateProtocol,
|
|
345
|
+
coreValidateSchema,
|
|
346
|
+
coreValidateTask,
|
|
347
|
+
ensureInitialized,
|
|
348
|
+
filterEntries,
|
|
349
|
+
getVersion,
|
|
350
|
+
initProject,
|
|
351
|
+
isAutoInitEnabled,
|
|
352
|
+
lifecycleCheck,
|
|
353
|
+
lifecycleGateFail,
|
|
354
|
+
lifecycleGatePass,
|
|
355
|
+
lifecycleGates,
|
|
356
|
+
lifecycleHistory,
|
|
357
|
+
lifecyclePrerequisites,
|
|
358
|
+
lifecycleProgress,
|
|
359
|
+
lifecycleReset,
|
|
360
|
+
lifecycleSkip,
|
|
361
|
+
lifecycleStatus,
|
|
362
|
+
mapCodebase,
|
|
363
|
+
memoryBrainStats,
|
|
364
|
+
memoryContradictions,
|
|
365
|
+
memoryDecisionFind,
|
|
366
|
+
memoryDecisionStore,
|
|
367
|
+
memoryFetch,
|
|
368
|
+
memoryFind,
|
|
369
|
+
memoryGraphAdd,
|
|
370
|
+
memoryGraphContext,
|
|
371
|
+
memoryGraphNeighbors,
|
|
372
|
+
memoryGraphRelated,
|
|
373
|
+
memoryGraphRemove,
|
|
374
|
+
memoryGraphShow,
|
|
375
|
+
memoryGraphStatsFull,
|
|
376
|
+
memoryGraphTrace,
|
|
377
|
+
memoryLearningFind,
|
|
378
|
+
memoryLearningStats,
|
|
379
|
+
memoryLearningStore,
|
|
380
|
+
memoryLink,
|
|
381
|
+
memoryObserve,
|
|
382
|
+
memoryPatternFind,
|
|
383
|
+
memoryPatternStats,
|
|
384
|
+
memoryPatternStore,
|
|
385
|
+
memoryQualityReport,
|
|
386
|
+
memoryReasonSimilar,
|
|
387
|
+
memoryReasonWhy,
|
|
388
|
+
memorySearchHybrid,
|
|
389
|
+
memoryShow,
|
|
390
|
+
memorySuperseded,
|
|
391
|
+
memoryTimeline,
|
|
392
|
+
memoryUnlink,
|
|
393
|
+
orchestrateAnalyze,
|
|
394
|
+
orchestrateBootstrap,
|
|
395
|
+
orchestrateCheck,
|
|
396
|
+
orchestrateContext,
|
|
397
|
+
orchestrateCriticalPath,
|
|
398
|
+
orchestrateHandoff,
|
|
399
|
+
orchestrateNext,
|
|
400
|
+
orchestrateParallelEnd,
|
|
401
|
+
orchestrateParallelStart,
|
|
402
|
+
orchestratePlan,
|
|
403
|
+
orchestrateReady,
|
|
404
|
+
orchestrateReport,
|
|
405
|
+
orchestrateSkillInject,
|
|
406
|
+
orchestrateSpawn,
|
|
407
|
+
orchestrateSpawnExecute,
|
|
408
|
+
orchestrateStartup,
|
|
409
|
+
orchestrateStatus,
|
|
410
|
+
orchestrateUnblockOpportunities,
|
|
411
|
+
orchestrateValidate,
|
|
412
|
+
orchestrateWaves,
|
|
413
|
+
phaseAdvance,
|
|
414
|
+
phaseComplete,
|
|
415
|
+
phaseDelete,
|
|
416
|
+
phaseList,
|
|
417
|
+
phaseRename,
|
|
418
|
+
phaseSet,
|
|
419
|
+
phaseShow,
|
|
420
|
+
phaseStart,
|
|
421
|
+
pipelineManifestAppend,
|
|
422
|
+
pipelineManifestArchive,
|
|
423
|
+
pipelineManifestFind,
|
|
424
|
+
pipelineManifestList,
|
|
425
|
+
pipelineManifestPending,
|
|
426
|
+
pipelineManifestShow,
|
|
427
|
+
pipelineManifestStats,
|
|
428
|
+
queryCommonHooks,
|
|
429
|
+
queryHookProviders,
|
|
430
|
+
readManifestEntries,
|
|
431
|
+
releaseCancel,
|
|
432
|
+
releaseCommit,
|
|
433
|
+
releaseGateCheck,
|
|
434
|
+
releaseGatesRun,
|
|
435
|
+
releaseIvtrAutoSuggest,
|
|
436
|
+
releaseList,
|
|
437
|
+
releaseOpen,
|
|
438
|
+
releasePlan,
|
|
439
|
+
releasePrepare,
|
|
440
|
+
releasePrStatus,
|
|
441
|
+
releasePush,
|
|
442
|
+
releaseReconcileV2,
|
|
443
|
+
releaseRollback,
|
|
444
|
+
releaseRollbackFull,
|
|
445
|
+
releaseShow,
|
|
446
|
+
releaseTag,
|
|
447
|
+
sessionAdopt,
|
|
448
|
+
sessionArchive,
|
|
449
|
+
sessionBriefing,
|
|
450
|
+
sessionChainShow,
|
|
451
|
+
sessionCleanup,
|
|
452
|
+
sessionComputeDebrief,
|
|
453
|
+
sessionComputeHandoff,
|
|
454
|
+
sessionContextDrift,
|
|
455
|
+
sessionContextInject,
|
|
456
|
+
sessionDebriefShow,
|
|
457
|
+
sessionDecisionLog,
|
|
458
|
+
sessionEnd,
|
|
459
|
+
sessionFind,
|
|
460
|
+
sessionGc,
|
|
461
|
+
sessionHandoff,
|
|
462
|
+
sessionHistory,
|
|
463
|
+
sessionList,
|
|
464
|
+
sessionRecordAssumption,
|
|
465
|
+
sessionRecordDecision,
|
|
466
|
+
sessionResume,
|
|
467
|
+
sessionShow,
|
|
468
|
+
sessionStart,
|
|
469
|
+
sessionStats,
|
|
470
|
+
sessionStatus,
|
|
471
|
+
sessionSuspend,
|
|
472
|
+
sessionSwitch,
|
|
473
|
+
systemHooksMatrix,
|
|
474
|
+
taskAnalyze,
|
|
475
|
+
taskArchive,
|
|
476
|
+
taskBatchValidate,
|
|
477
|
+
taskBlockers,
|
|
478
|
+
taskCancel,
|
|
479
|
+
taskClaim,
|
|
480
|
+
taskComplete,
|
|
481
|
+
taskComplexityEstimate,
|
|
482
|
+
taskCurrentGet,
|
|
483
|
+
taskDelete,
|
|
484
|
+
taskDepends,
|
|
485
|
+
taskDeps,
|
|
486
|
+
taskDepsCycles,
|
|
487
|
+
taskDepsOverview,
|
|
488
|
+
taskDepsTree,
|
|
489
|
+
taskDepsValidate,
|
|
490
|
+
taskExists,
|
|
491
|
+
taskExport,
|
|
492
|
+
taskFind,
|
|
493
|
+
taskHistory,
|
|
494
|
+
taskImpact,
|
|
495
|
+
taskImport,
|
|
496
|
+
taskLabelList,
|
|
497
|
+
taskLabelShow,
|
|
498
|
+
taskLint,
|
|
499
|
+
taskList,
|
|
500
|
+
taskNext,
|
|
501
|
+
taskPlan,
|
|
502
|
+
taskPromote,
|
|
503
|
+
taskRelates,
|
|
504
|
+
taskRelatesAdd,
|
|
505
|
+
taskRelatesAddBatch,
|
|
506
|
+
taskRelatesFind,
|
|
507
|
+
taskRelatesRemove,
|
|
508
|
+
taskReopen,
|
|
509
|
+
taskReorder,
|
|
510
|
+
taskReparent,
|
|
511
|
+
taskRestore,
|
|
512
|
+
taskShow,
|
|
513
|
+
taskShowIvtrHistory,
|
|
514
|
+
taskShowOperation,
|
|
515
|
+
taskShowWithHistory,
|
|
516
|
+
taskSlice,
|
|
517
|
+
taskStart,
|
|
518
|
+
taskStats,
|
|
519
|
+
taskStop,
|
|
520
|
+
taskSyncLinks,
|
|
521
|
+
taskSyncLinksRemove,
|
|
522
|
+
taskSyncReconcile,
|
|
523
|
+
tasksAddBatchOp,
|
|
524
|
+
taskTree,
|
|
525
|
+
taskUnarchive,
|
|
526
|
+
taskUnclaim,
|
|
527
|
+
taskUpdate,
|
|
528
|
+
taskWorkHistory,
|
|
529
|
+
validateChangelog,
|
|
530
|
+
validateGateVerify,
|
|
531
|
+
validateProtocolArchitectureDecision,
|
|
532
|
+
validateProtocolArtifactPublish,
|
|
533
|
+
validateProtocolConsensus,
|
|
534
|
+
validateProtocolContribution,
|
|
535
|
+
validateProtocolDecomposition,
|
|
536
|
+
validateProtocolImplementation,
|
|
537
|
+
validateProtocolProvenance,
|
|
538
|
+
validateProtocolRelease,
|
|
539
|
+
validateProtocolResearch,
|
|
540
|
+
validateProtocolSpecification,
|
|
541
|
+
validateProtocolTesting,
|
|
542
|
+
validateProtocolValidation
|
|
543
|
+
} from "@cleocode/core/internal";
|
|
544
|
+
|
|
545
|
+
// src/gateway/template-parser.ts
|
|
546
|
+
import {
|
|
547
|
+
generateTemplateConfig as coreGenerateTemplateConfig,
|
|
548
|
+
getTemplateForSubcommand as coreGetTemplateForSubcommand,
|
|
549
|
+
parseIssueTemplates as coreParseIssueTemplates,
|
|
550
|
+
templates
|
|
551
|
+
} from "@cleocode/core/internal";
|
|
552
|
+
function adaptResult(result) {
|
|
553
|
+
if (result.success) {
|
|
554
|
+
if (result.data === void 0) {
|
|
555
|
+
return {
|
|
556
|
+
success: false,
|
|
557
|
+
error: { code: "E_INTERNAL", message: "Template parser succeeded with no data" }
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
return { success: true, data: result.data };
|
|
561
|
+
}
|
|
562
|
+
return {
|
|
563
|
+
success: false,
|
|
564
|
+
error: result.error ? {
|
|
565
|
+
code: result.error.code,
|
|
566
|
+
message: result.error.message,
|
|
567
|
+
...result.error.details ? { details: result.error.details } : {}
|
|
568
|
+
} : { code: "E_INTERNAL", message: "Unknown error" }
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
function parseIssueTemplates(projectRoot) {
|
|
572
|
+
return adaptResult(coreParseIssueTemplates(projectRoot));
|
|
573
|
+
}
|
|
574
|
+
function getTemplateForSubcommand(projectRoot, subcommand) {
|
|
575
|
+
return adaptResult(coreGetTemplateForSubcommand(projectRoot, subcommand));
|
|
576
|
+
}
|
|
577
|
+
async function generateTemplateConfig(projectRoot) {
|
|
578
|
+
return adaptResult(await coreGenerateTemplateConfig(projectRoot));
|
|
579
|
+
}
|
|
580
|
+
function validateLabels(labels, repoLabels) {
|
|
581
|
+
return adaptResult(templates.validateLabels(labels, repoLabels));
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
// src/gateway/engine-error.ts
|
|
585
|
+
import {
|
|
586
|
+
engineError as coreEngineError,
|
|
587
|
+
getLogger as getLogger3
|
|
588
|
+
} from "@cleocode/core";
|
|
589
|
+
|
|
590
|
+
// src/gateway/exit-codes.ts
|
|
591
|
+
var _inverseCache = null;
|
|
592
|
+
function getInverseMap() {
|
|
593
|
+
if (_inverseCache) return _inverseCache;
|
|
594
|
+
const map = /* @__PURE__ */ new Map();
|
|
595
|
+
for (const [key, value] of Object.entries(STRING_TO_EXIT)) {
|
|
596
|
+
if (!map.has(value)) {
|
|
597
|
+
map.set(value, key);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
_inverseCache = map;
|
|
601
|
+
return map;
|
|
602
|
+
}
|
|
603
|
+
function mapNumericExitCodeToString(numericCode) {
|
|
604
|
+
if (numericCode === void 0) return void 0;
|
|
605
|
+
return getInverseMap().get(numericCode);
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
// src/gateway/engine-error.ts
|
|
609
|
+
import { engineSuccess } from "@cleocode/core";
|
|
610
|
+
var STRING_TO_EXIT = {
|
|
611
|
+
// General Errors (1-9)
|
|
612
|
+
E_GENERAL: 1,
|
|
613
|
+
E_GENERAL_ERROR: 1,
|
|
614
|
+
E_INVALID_INPUT: 2,
|
|
615
|
+
E_MISSING_PARAMS: 2,
|
|
616
|
+
E_INVALID_OPERATION: 2,
|
|
617
|
+
E_FILE_ERROR: 3,
|
|
618
|
+
E_NOT_FOUND: 4,
|
|
619
|
+
E_DEPENDENCY: 5,
|
|
620
|
+
E_DEPENDENCY_ERROR: 5,
|
|
621
|
+
E_VALIDATION: 6,
|
|
622
|
+
E_VALIDATION_FAILED: 6,
|
|
623
|
+
E_VALIDATION_ERROR: 6,
|
|
624
|
+
E_RETRYABLE: 7,
|
|
625
|
+
E_LOCK_TIMEOUT: 7,
|
|
626
|
+
E_CONFIG_ERROR: 8,
|
|
627
|
+
// Hierarchy Errors (10-19)
|
|
628
|
+
E_PARENT_NOT_FOUND: 10,
|
|
629
|
+
E_DEPTH_EXCEEDED: 11,
|
|
630
|
+
E_SIBLING_LIMIT: 12,
|
|
631
|
+
E_INVALID_PARENT_TYPE: 13,
|
|
632
|
+
E_INVALID_PARENT: 13,
|
|
633
|
+
E_CIRCULAR_DEP: 14,
|
|
634
|
+
E_CIRCULAR_REFERENCE: 14,
|
|
635
|
+
E_ORPHAN_DETECTED: 15,
|
|
636
|
+
E_HAS_CHILDREN: 16,
|
|
637
|
+
E_TASK_COMPLETED: 17,
|
|
638
|
+
// ExitCode.TASK_COMPLETED — canonical value from @cleocode/contracts
|
|
639
|
+
E_CASCADE_FAILED: 18,
|
|
640
|
+
E_HAS_DEPENDENTS: 19,
|
|
641
|
+
// Concurrency Errors (20-29)
|
|
642
|
+
E_CHECKSUM_MISMATCH: 20,
|
|
643
|
+
E_CONCURRENT_MODIFICATION: 21,
|
|
644
|
+
E_ID_COLLISION: 22,
|
|
645
|
+
// Session Errors (30-39)
|
|
646
|
+
E_SESSION_EXISTS: 30,
|
|
647
|
+
E_SESSION_CONFLICT: 30,
|
|
648
|
+
E_SESSION_NOT_FOUND: 31,
|
|
649
|
+
E_SCOPE_CONFLICT: 32,
|
|
650
|
+
E_SCOPE_INVALID: 33,
|
|
651
|
+
E_TASK_NOT_IN_SCOPE: 34,
|
|
652
|
+
E_TASK_CLAIMED: 35,
|
|
653
|
+
E_SESSION_REQUIRED: 36,
|
|
654
|
+
E_SESSION_CLOSE_BLOCKED: 37,
|
|
655
|
+
E_ACTIVE_TASK_REQUIRED: 38,
|
|
656
|
+
E_NOTES_REQUIRED: 39,
|
|
657
|
+
// Verification Errors (40-47)
|
|
658
|
+
E_VERIFICATION_INIT_FAILED: 40,
|
|
659
|
+
E_GATE_UPDATE_FAILED: 41,
|
|
660
|
+
E_INVALID_GATE: 42,
|
|
661
|
+
E_INVALID_AGENT: 43,
|
|
662
|
+
E_MAX_ROUNDS_EXCEEDED: 44,
|
|
663
|
+
E_GATE_DEPENDENCY: 45,
|
|
664
|
+
E_VERIFICATION_LOCKED: 46,
|
|
665
|
+
E_ROUND_MISMATCH: 47,
|
|
666
|
+
// T1590 — Acceptance-criteria immutability after implementation stage
|
|
667
|
+
E_AC_LOCKED: 48,
|
|
668
|
+
// Context Safeguard (50-54)
|
|
669
|
+
E_CONTEXT_WARNING: 50,
|
|
670
|
+
E_CONTEXT_CAUTION: 51,
|
|
671
|
+
E_CONTEXT_CRITICAL: 52,
|
|
672
|
+
E_CONTEXT_EMERGENCY: 53,
|
|
673
|
+
E_CONTEXT_STALE: 54,
|
|
674
|
+
// Orchestrator / Protocol Errors (60-67)
|
|
675
|
+
E_PROTOCOL_MISSING: 60,
|
|
676
|
+
E_PROTOCOL_RESEARCH: 60,
|
|
677
|
+
E_INVALID_RETURN_MESSAGE: 61,
|
|
678
|
+
E_PROTOCOL_CONSENSUS: 61,
|
|
679
|
+
E_MANIFEST_ENTRY_MISSING: 62,
|
|
680
|
+
E_PROTOCOL_SPECIFICATION: 62,
|
|
681
|
+
E_SPAWN_VALIDATION_FAILED: 63,
|
|
682
|
+
E_PROTOCOL_DECOMPOSITION: 63,
|
|
683
|
+
E_AUTONOMOUS_BOUNDARY: 64,
|
|
684
|
+
E_PROTOCOL_IMPLEMENTATION: 64,
|
|
685
|
+
E_HANDOFF_REQUIRED: 65,
|
|
686
|
+
E_PROTOCOL_CONTRIBUTION: 65,
|
|
687
|
+
E_RESUME_FAILED: 66,
|
|
688
|
+
E_PROTOCOL_RELEASE: 66,
|
|
689
|
+
E_CONCURRENT_SESSION: 67,
|
|
690
|
+
E_PROTOCOL_GENERIC: 67,
|
|
691
|
+
// Nexus Errors (70-79)
|
|
692
|
+
E_NEXUS_NOT_INITIALIZED: 70,
|
|
693
|
+
E_NEXUS_PROJECT_NOT_FOUND: 71,
|
|
694
|
+
E_NEXUS_PERMISSION_DENIED: 72,
|
|
695
|
+
E_NEXUS_INVALID_SYNTAX: 73,
|
|
696
|
+
E_NEXUS_SYNC_FAILED: 74,
|
|
697
|
+
E_NEXUS_REGISTRY_CORRUPT: 75,
|
|
698
|
+
E_NEXUS_PROJECT_EXISTS: 76,
|
|
699
|
+
E_NEXUS_QUERY_FAILED: 77,
|
|
700
|
+
E_NEXUS_GRAPH_ERROR: 78,
|
|
701
|
+
// Lifecycle Enforcement (80-84)
|
|
702
|
+
E_LIFECYCLE_GATE_FAILED: 80,
|
|
703
|
+
E_AUDIT_MISSING: 81,
|
|
704
|
+
E_CIRCULAR_VALIDATION: 82,
|
|
705
|
+
E_LIFECYCLE_TRANSITION_INVALID: 83,
|
|
706
|
+
E_IVTR_INCOMPLETE: 83,
|
|
707
|
+
E_PROVENANCE_REQUIRED: 84,
|
|
708
|
+
// T1162: lifecycle scope guard — maps to ExitCode.TASK_NOT_IN_SCOPE (34)
|
|
709
|
+
// because a subagent attempting to mutate a parent epic's lifecycle is
|
|
710
|
+
// operating outside the scope granted by its session.
|
|
711
|
+
E_LIFECYCLE_SCOPE_DENIED: 34,
|
|
712
|
+
// Artifact Publish (85-89)
|
|
713
|
+
E_ARTIFACT_TYPE_UNKNOWN: 85,
|
|
714
|
+
E_ARTIFACT_VALIDATION_FAILED: 86,
|
|
715
|
+
E_ARTIFACT_BUILD_FAILED: 87,
|
|
716
|
+
E_ARTIFACT_PUBLISH_FAILED: 88,
|
|
717
|
+
E_ARTIFACT_ROLLBACK_FAILED: 89,
|
|
718
|
+
// Provenance (90-94)
|
|
719
|
+
E_PROVENANCE_CONFIG_INVALID: 90,
|
|
720
|
+
E_SIGNING_KEY_MISSING: 91,
|
|
721
|
+
E_SIGNATURE_INVALID: 92,
|
|
722
|
+
E_DIGEST_MISMATCH: 93,
|
|
723
|
+
E_ATTESTATION_INVALID: 94,
|
|
724
|
+
// Special Codes (100+) - NOT errors
|
|
725
|
+
E_NO_DATA: 100,
|
|
726
|
+
E_ALREADY_EXISTS: 101,
|
|
727
|
+
E_NO_CHANGE: 102,
|
|
728
|
+
E_TESTS_SKIPPED: 103,
|
|
729
|
+
// Adapter Errors (95-99)
|
|
730
|
+
E_ADAPTER_NOT_FOUND: 95,
|
|
731
|
+
E_ADAPTER_INIT_FAILED: 96,
|
|
732
|
+
E_ADAPTER_HOOK_FAILED: 97,
|
|
733
|
+
E_ADAPTER_SPAWN_FAILED: 98,
|
|
734
|
+
E_ADAPTER_INSTALL_FAILED: 99,
|
|
735
|
+
// Common engine-specific aliases
|
|
736
|
+
E_NOT_INITIALIZED: 3,
|
|
737
|
+
E_NO_HANDLER: 1,
|
|
738
|
+
E_INTERNAL: 1,
|
|
739
|
+
E_LIST_FAILED: 3,
|
|
740
|
+
E_READ_FAILED: 3,
|
|
741
|
+
E_WRITE_FAILED: 3,
|
|
742
|
+
E_PARSE_ERROR: 2,
|
|
743
|
+
E_TEMPLATE_ERROR: 2
|
|
744
|
+
};
|
|
745
|
+
function logLevel(exitCode) {
|
|
746
|
+
if (exitCode === 0 || exitCode >= 100) return "debug";
|
|
747
|
+
if (exitCode === 1 || exitCode === 3) return "error";
|
|
748
|
+
return "warn";
|
|
749
|
+
}
|
|
750
|
+
function engineError(code, message, options) {
|
|
751
|
+
const resolvedExitCode = options?.exitCode ?? STRING_TO_EXIT[code] ?? 1;
|
|
752
|
+
const level = logLevel(resolvedExitCode);
|
|
753
|
+
const isVitest = process.env["VITEST"] === "true";
|
|
754
|
+
if (!isVitest) {
|
|
755
|
+
const logger = getLogger3("engine");
|
|
756
|
+
logger[level](
|
|
757
|
+
{ code, exitCode: resolvedExitCode, ...options?.details && { details: options.details } },
|
|
758
|
+
message
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
return coreEngineError(code, message, { ...options, exitCode: resolvedExitCode });
|
|
762
|
+
}
|
|
763
|
+
function cleoErrorToEngineError(err, fallbackCode, fallbackMessage, meta) {
|
|
764
|
+
if (typeof err === "string") {
|
|
765
|
+
const exitCode2 = STRING_TO_EXIT[fallbackCode] ?? 1;
|
|
766
|
+
return engineError(fallbackCode, err, {
|
|
767
|
+
exitCode: exitCode2,
|
|
768
|
+
problemDetails: {
|
|
769
|
+
type: `https://cleocode.dev/errors/${fallbackCode}`,
|
|
770
|
+
title: fallbackCode,
|
|
771
|
+
status: exitCode2,
|
|
772
|
+
detail: err,
|
|
773
|
+
...meta?.requestId !== void 0 ? { instance: meta.requestId } : {}
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
if (err !== null && typeof err !== "object") {
|
|
778
|
+
const exitCode2 = STRING_TO_EXIT[fallbackCode] ?? 1;
|
|
779
|
+
const message2 = String(err);
|
|
780
|
+
return engineError(fallbackCode, message2, {
|
|
781
|
+
exitCode: exitCode2,
|
|
782
|
+
problemDetails: {
|
|
783
|
+
type: `https://cleocode.dev/errors/${fallbackCode}`,
|
|
784
|
+
title: fallbackCode,
|
|
785
|
+
status: exitCode2,
|
|
786
|
+
detail: message2,
|
|
787
|
+
...meta?.requestId !== void 0 ? { instance: meta.requestId } : {}
|
|
788
|
+
}
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
const e = err;
|
|
792
|
+
const code = mapNumericExitCodeToString(e.code) ?? fallbackCode;
|
|
793
|
+
const message = e.message ?? fallbackMessage;
|
|
794
|
+
const exitCode = STRING_TO_EXIT[code] ?? 1;
|
|
795
|
+
return engineError(code, message, {
|
|
796
|
+
exitCode,
|
|
797
|
+
...e.fix !== void 0 && { fix: e.fix },
|
|
798
|
+
...e.details !== void 0 && { details: e.details },
|
|
799
|
+
...e.alternatives !== void 0 && { alternatives: e.alternatives },
|
|
800
|
+
problemDetails: {
|
|
801
|
+
type: `https://cleocode.dev/errors/${code}`,
|
|
802
|
+
title: code,
|
|
803
|
+
status: exitCode,
|
|
804
|
+
detail: message,
|
|
805
|
+
...meta?.requestId !== void 0 ? { instance: meta.requestId } : {}
|
|
806
|
+
}
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
// src/gateway/job-manager-accessor.ts
|
|
811
|
+
var _instance = null;
|
|
812
|
+
function setJobManager(manager) {
|
|
813
|
+
_instance = manager;
|
|
814
|
+
}
|
|
815
|
+
function getJobManager() {
|
|
816
|
+
return _instance;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
// src/gateway/nexus-decorator.ts
|
|
820
|
+
import { getNexusDescriptor, NEXUS_SCOPE_MAP } from "@cleocode/contracts";
|
|
821
|
+
function resolveBindingSource(descriptor, params) {
|
|
822
|
+
if (!descriptor.requiresProject) return "none";
|
|
823
|
+
if (typeof params["projectId"] === "string" && params["projectId"]) {
|
|
824
|
+
return "arg-project-id";
|
|
825
|
+
}
|
|
826
|
+
if (typeof params["path"] === "string" && params["path"]) {
|
|
827
|
+
return "arg-path";
|
|
828
|
+
}
|
|
829
|
+
if (typeof params["_resolvedFrom"] === "string") {
|
|
830
|
+
return params["_resolvedFrom"] === "cwd" ? "cwd" : "registry";
|
|
831
|
+
}
|
|
832
|
+
return "cwd";
|
|
833
|
+
}
|
|
834
|
+
function resolveIndexFreshness(params) {
|
|
835
|
+
const fromParams = params["_indexFreshness"];
|
|
836
|
+
if (fromParams === "fresh" || fromParams === "stale") return fromParams;
|
|
837
|
+
return "unknown";
|
|
838
|
+
}
|
|
839
|
+
function canonicalCommandFor(op) {
|
|
840
|
+
return `cleo nexus ${op}`;
|
|
841
|
+
}
|
|
842
|
+
function validateSuggestedNext(suggestions) {
|
|
843
|
+
for (const s of suggestions) {
|
|
844
|
+
if (!(s.op in NEXUS_SCOPE_MAP)) {
|
|
845
|
+
throw new TypeError(
|
|
846
|
+
`[nexus-decorator] suggestedNext.op "${s.op}" is not a known NEXUS_SCOPE_MAP entry. Add it to packages/contracts/src/operations/nexus-scope-map.ts first.`
|
|
847
|
+
);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
function formatSuggestedNext(s) {
|
|
852
|
+
const argParts = Object.entries(s.args).map(([k, v]) => `--${k} ${String(v)}`).join(" ");
|
|
853
|
+
const cmd = `cleo nexus ${s.op}${argParts ? ` ${argParts}` : ""}`;
|
|
854
|
+
const confirm = s.requiresConfirmation ? "confirm before running" : "no confirmation needed";
|
|
855
|
+
return `${cmd} (${s.effect}, ${confirm}) \u2014 ${s.reason}`;
|
|
856
|
+
}
|
|
857
|
+
function stampNexusMeta(response, operation, params, isTopLevel = true) {
|
|
858
|
+
if (!(operation in NEXUS_SCOPE_MAP)) {
|
|
859
|
+
return response;
|
|
860
|
+
}
|
|
861
|
+
const descriptor = getNexusDescriptor(operation);
|
|
862
|
+
const bindingSource = resolveBindingSource(descriptor, params);
|
|
863
|
+
const projectId = typeof params["projectId"] === "string" ? params["projectId"] : void 0;
|
|
864
|
+
const projectName = typeof params["_projectName"] === "string" ? params["_projectName"] : void 0;
|
|
865
|
+
const projectPath = typeof params["_projectPath"] === "string" ? params["_projectPath"] : void 0;
|
|
866
|
+
const registryPath = typeof params["_registryPath"] === "string" ? params["_registryPath"] : void 0;
|
|
867
|
+
const counterpartProjectId = descriptor.scope === "cross" || descriptor.scope === "hybrid" ? typeof params["counterpartProjectId"] === "string" ? params["counterpartProjectId"] : void 0 : void 0;
|
|
868
|
+
const indexFreshness = descriptor.indexSensitive && isTopLevel ? resolveIndexFreshness(params) : void 0;
|
|
869
|
+
const legacyAliasFor = typeof params["_legacyAliasFor"] === "string" ? params["_legacyAliasFor"] : void 0;
|
|
870
|
+
const nexusMeta = {
|
|
871
|
+
scope: descriptor.scope,
|
|
872
|
+
effect: descriptor.effect,
|
|
873
|
+
...projectId !== void 0 && { projectId },
|
|
874
|
+
...projectName !== void 0 && { projectName },
|
|
875
|
+
...projectPath !== void 0 && { projectPath },
|
|
876
|
+
...registryPath !== void 0 && { registryPath },
|
|
877
|
+
bindingSource,
|
|
878
|
+
...counterpartProjectId !== void 0 && { counterpartProjectId },
|
|
879
|
+
...indexFreshness !== void 0 && { indexFreshness },
|
|
880
|
+
canonicalCommand: canonicalCommandFor(operation),
|
|
881
|
+
...legacyAliasFor !== void 0 && { legacyAliasFor }
|
|
882
|
+
};
|
|
883
|
+
return {
|
|
884
|
+
...response,
|
|
885
|
+
meta: {
|
|
886
|
+
...response.meta,
|
|
887
|
+
_nexus: nexusMeta,
|
|
888
|
+
// Stamp top-level deprecated field for alias shims (T9147)
|
|
889
|
+
...legacyAliasFor !== void 0 && {
|
|
890
|
+
deprecated: {
|
|
891
|
+
since: "v2026.6.5",
|
|
892
|
+
removeIn: "v2026.8.0",
|
|
893
|
+
replacement: `cleo graph ${operation}`
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
function pickDecoratorMetaExtensions(responseMeta) {
|
|
900
|
+
if (!responseMeta) return {};
|
|
901
|
+
const out = {};
|
|
902
|
+
if (responseMeta["_nexus"] !== void 0) out["_nexus"] = responseMeta["_nexus"];
|
|
903
|
+
if (responseMeta["deprecated"] !== void 0) out["deprecated"] = responseMeta["deprecated"];
|
|
904
|
+
if (responseMeta.sessionId !== void 0) out["sessionId"] = responseMeta.sessionId;
|
|
905
|
+
if (responseMeta.originSessionId !== void 0) {
|
|
906
|
+
out["originSessionId"] = responseMeta.originSessionId;
|
|
907
|
+
}
|
|
908
|
+
if (responseMeta.executionSessionId !== void 0) {
|
|
909
|
+
out["executionSessionId"] = responseMeta.executionSessionId;
|
|
910
|
+
}
|
|
911
|
+
if (responseMeta["suggestedNext"] !== void 0) {
|
|
912
|
+
out["suggestedNext"] = responseMeta["suggestedNext"];
|
|
913
|
+
}
|
|
914
|
+
return out;
|
|
915
|
+
}
|
|
916
|
+
function buildNexusMetaExtensions(operation, params = {}) {
|
|
917
|
+
const synthetic = {
|
|
918
|
+
success: true,
|
|
919
|
+
data: void 0,
|
|
920
|
+
meta: {
|
|
921
|
+
gateway: "query",
|
|
922
|
+
domain: "nexus",
|
|
923
|
+
operation,
|
|
924
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
925
|
+
duration_ms: 0,
|
|
926
|
+
source: "cli",
|
|
927
|
+
requestId: ""
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
const stamped = stampNexusMeta(synthetic, operation, params);
|
|
931
|
+
return pickDecoratorMetaExtensions(stamped.meta);
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
// src/gateway/paths.ts
|
|
935
|
+
var CLEO_DIR_NAME = ".cleo";
|
|
936
|
+
var WORKFLOWS_SUBDIR = "workflows";
|
|
937
|
+
var BRAIN_DB_FILENAME = "brain.db";
|
|
938
|
+
|
|
939
|
+
// src/gateway/index.ts
|
|
940
|
+
function createGatewayHandler(config) {
|
|
941
|
+
const dispatcher = new Dispatcher(config);
|
|
942
|
+
return { handle: (req) => dispatcher.dispatch(req) };
|
|
943
|
+
}
|
|
944
|
+
export {
|
|
945
|
+
BRAIN_DB_FILENAME,
|
|
946
|
+
BackgroundJobManager,
|
|
947
|
+
CLEO_DIR_NAME,
|
|
948
|
+
Dispatcher,
|
|
949
|
+
DurableJobStore,
|
|
950
|
+
LineBuffer,
|
|
951
|
+
MCP_TOOL_PREFIX,
|
|
952
|
+
OPERATIONS,
|
|
953
|
+
SSE_HEADERS,
|
|
954
|
+
STRING_TO_EXIT,
|
|
955
|
+
WORKFLOWS_SUBDIR,
|
|
956
|
+
addTaskWithSessionScope,
|
|
957
|
+
buildErrorFrame,
|
|
958
|
+
buildNexusMetaExtensions,
|
|
959
|
+
buildToolsList,
|
|
960
|
+
callTool,
|
|
961
|
+
cleoErrorToEngineError,
|
|
962
|
+
completeTaskStrict,
|
|
963
|
+
compose,
|
|
964
|
+
configGet,
|
|
965
|
+
configListPresets,
|
|
966
|
+
configSet,
|
|
967
|
+
configSetPreset,
|
|
968
|
+
createDispatchMeta,
|
|
969
|
+
createGatewayHandler,
|
|
970
|
+
createSseStream,
|
|
971
|
+
decodeLine,
|
|
972
|
+
defineGatewaySubsystem,
|
|
973
|
+
deriveGatewayMatrix,
|
|
974
|
+
encodeFrame,
|
|
975
|
+
encodeSseFrame,
|
|
976
|
+
encodeStreamEvent,
|
|
977
|
+
engineError,
|
|
978
|
+
engineSuccess,
|
|
979
|
+
ensureInitialized,
|
|
980
|
+
exposedOperations,
|
|
981
|
+
filterEntries as filterManifestEntries,
|
|
982
|
+
formatSuggestedNext,
|
|
983
|
+
gatewaySubsystemName,
|
|
984
|
+
generateTemplateConfig,
|
|
985
|
+
getActiveDomains,
|
|
986
|
+
getByDomain,
|
|
987
|
+
getByGateway,
|
|
988
|
+
getByTier,
|
|
989
|
+
getCounts,
|
|
990
|
+
getGatewayDomains,
|
|
991
|
+
getJobManager,
|
|
992
|
+
getTemplateForSubcommand,
|
|
993
|
+
getVersion,
|
|
994
|
+
initProject,
|
|
995
|
+
isAutoInitEnabled,
|
|
996
|
+
lifecycleCheck,
|
|
997
|
+
lifecycleGateFail,
|
|
998
|
+
lifecycleGatePass,
|
|
999
|
+
lifecycleGates,
|
|
1000
|
+
lifecycleHistory,
|
|
1001
|
+
lifecyclePrerequisites,
|
|
1002
|
+
lifecycleProgress,
|
|
1003
|
+
lifecycleReset,
|
|
1004
|
+
lifecycleSkip,
|
|
1005
|
+
lifecycleStatus,
|
|
1006
|
+
mapCodebase,
|
|
1007
|
+
mapNumericExitCodeToString,
|
|
1008
|
+
memoryBrainStats,
|
|
1009
|
+
memoryContradictions,
|
|
1010
|
+
memoryDecisionFind,
|
|
1011
|
+
memoryDecisionStore,
|
|
1012
|
+
memoryFetch,
|
|
1013
|
+
memoryFind,
|
|
1014
|
+
memoryGraphAdd,
|
|
1015
|
+
memoryGraphContext,
|
|
1016
|
+
memoryGraphNeighbors,
|
|
1017
|
+
memoryGraphRelated,
|
|
1018
|
+
memoryGraphRemove,
|
|
1019
|
+
memoryGraphShow,
|
|
1020
|
+
memoryGraphStatsFull,
|
|
1021
|
+
memoryGraphTrace,
|
|
1022
|
+
memoryLearningFind,
|
|
1023
|
+
memoryLearningStats,
|
|
1024
|
+
memoryLearningStore,
|
|
1025
|
+
memoryLink,
|
|
1026
|
+
memoryObserve,
|
|
1027
|
+
memoryPatternFind,
|
|
1028
|
+
memoryPatternStats,
|
|
1029
|
+
memoryPatternStore,
|
|
1030
|
+
memoryQualityReport,
|
|
1031
|
+
memoryReasonSimilar,
|
|
1032
|
+
memoryReasonWhy,
|
|
1033
|
+
memorySearchHybrid,
|
|
1034
|
+
memoryShow,
|
|
1035
|
+
memorySuperseded,
|
|
1036
|
+
memoryTimeline,
|
|
1037
|
+
memoryUnlink,
|
|
1038
|
+
operationToMcpTool,
|
|
1039
|
+
operationToToolName,
|
|
1040
|
+
orchestrateAnalyze,
|
|
1041
|
+
orchestrateBootstrap,
|
|
1042
|
+
orchestrateCheck,
|
|
1043
|
+
orchestrateContext,
|
|
1044
|
+
orchestrateCriticalPath,
|
|
1045
|
+
orchestrateHandoff,
|
|
1046
|
+
orchestrateNext,
|
|
1047
|
+
orchestrateParallelEnd,
|
|
1048
|
+
orchestrateParallelStart,
|
|
1049
|
+
orchestratePlan,
|
|
1050
|
+
orchestrateReady,
|
|
1051
|
+
orchestrateReport,
|
|
1052
|
+
orchestrateSkillInject,
|
|
1053
|
+
orchestrateSpawn,
|
|
1054
|
+
orchestrateSpawnExecute,
|
|
1055
|
+
orchestrateStartup,
|
|
1056
|
+
orchestrateStatus,
|
|
1057
|
+
orchestrateUnblockOpportunities,
|
|
1058
|
+
orchestrateValidate,
|
|
1059
|
+
orchestrateWaves,
|
|
1060
|
+
parseHttpRoute,
|
|
1061
|
+
parseIssueTemplates,
|
|
1062
|
+
phaseAdvance,
|
|
1063
|
+
phaseComplete,
|
|
1064
|
+
phaseDelete,
|
|
1065
|
+
phaseList,
|
|
1066
|
+
phaseRename,
|
|
1067
|
+
phaseSet,
|
|
1068
|
+
phaseShow,
|
|
1069
|
+
phaseStart,
|
|
1070
|
+
pickDecoratorMetaExtensions,
|
|
1071
|
+
pipelineManifestAppend,
|
|
1072
|
+
pipelineManifestArchive,
|
|
1073
|
+
pipelineManifestFind,
|
|
1074
|
+
pipelineManifestList,
|
|
1075
|
+
pipelineManifestPending,
|
|
1076
|
+
pipelineManifestShow,
|
|
1077
|
+
pipelineManifestStats,
|
|
1078
|
+
queryCommonHooks,
|
|
1079
|
+
queryHookProviders,
|
|
1080
|
+
readManifestEntries,
|
|
1081
|
+
releaseCancel,
|
|
1082
|
+
releaseCommit,
|
|
1083
|
+
releaseGateCheck,
|
|
1084
|
+
releaseGatesRun,
|
|
1085
|
+
releaseIvtrAutoSuggest,
|
|
1086
|
+
releaseList,
|
|
1087
|
+
releaseOpen,
|
|
1088
|
+
releasePlan,
|
|
1089
|
+
releasePrStatus,
|
|
1090
|
+
releasePrepare,
|
|
1091
|
+
releasePush,
|
|
1092
|
+
releaseReconcileV2,
|
|
1093
|
+
releaseRollback,
|
|
1094
|
+
releaseRollbackFull,
|
|
1095
|
+
releaseShow,
|
|
1096
|
+
releaseTag,
|
|
1097
|
+
resolve,
|
|
1098
|
+
routeFrame,
|
|
1099
|
+
routeUnary,
|
|
1100
|
+
sessionAdopt,
|
|
1101
|
+
sessionArchive,
|
|
1102
|
+
sessionBriefing,
|
|
1103
|
+
sessionChainShow,
|
|
1104
|
+
sessionCleanup,
|
|
1105
|
+
sessionComputeDebrief,
|
|
1106
|
+
sessionComputeHandoff,
|
|
1107
|
+
sessionContextDrift,
|
|
1108
|
+
sessionContextInject,
|
|
1109
|
+
sessionDebriefShow,
|
|
1110
|
+
sessionDecisionLog,
|
|
1111
|
+
sessionEnd,
|
|
1112
|
+
sessionFind,
|
|
1113
|
+
sessionGc,
|
|
1114
|
+
sessionHandoff,
|
|
1115
|
+
sessionHistory,
|
|
1116
|
+
sessionList,
|
|
1117
|
+
sessionRecordAssumption,
|
|
1118
|
+
sessionRecordDecision,
|
|
1119
|
+
sessionResume,
|
|
1120
|
+
sessionShow,
|
|
1121
|
+
sessionStart,
|
|
1122
|
+
sessionStats,
|
|
1123
|
+
sessionStatus,
|
|
1124
|
+
sessionSuspend,
|
|
1125
|
+
sessionSwitch,
|
|
1126
|
+
setJobManager,
|
|
1127
|
+
stampNexusMeta,
|
|
1128
|
+
startHttpServer,
|
|
1129
|
+
startMcpServer,
|
|
1130
|
+
startRpcServer,
|
|
1131
|
+
statusForResponse,
|
|
1132
|
+
systemHooksMatrix,
|
|
1133
|
+
taskAnalyze,
|
|
1134
|
+
taskArchive,
|
|
1135
|
+
taskBatchValidate,
|
|
1136
|
+
taskBlockers,
|
|
1137
|
+
taskCancel,
|
|
1138
|
+
taskClaim,
|
|
1139
|
+
taskComplete,
|
|
1140
|
+
taskComplexityEstimate,
|
|
1141
|
+
taskCurrentGet,
|
|
1142
|
+
taskDelete,
|
|
1143
|
+
taskDepends,
|
|
1144
|
+
taskDeps,
|
|
1145
|
+
taskDepsCycles,
|
|
1146
|
+
taskDepsOverview,
|
|
1147
|
+
taskDepsTree,
|
|
1148
|
+
taskDepsValidate,
|
|
1149
|
+
taskExists,
|
|
1150
|
+
taskExport,
|
|
1151
|
+
taskFind,
|
|
1152
|
+
taskHistory,
|
|
1153
|
+
taskImpact,
|
|
1154
|
+
taskImport,
|
|
1155
|
+
taskLabelList,
|
|
1156
|
+
taskLabelShow,
|
|
1157
|
+
taskLint,
|
|
1158
|
+
taskList,
|
|
1159
|
+
taskNext,
|
|
1160
|
+
taskPlan,
|
|
1161
|
+
taskPromote,
|
|
1162
|
+
taskRelates,
|
|
1163
|
+
taskRelatesAdd,
|
|
1164
|
+
taskRelatesAddBatch,
|
|
1165
|
+
taskRelatesFind,
|
|
1166
|
+
taskRelatesRemove,
|
|
1167
|
+
taskReopen,
|
|
1168
|
+
taskReorder,
|
|
1169
|
+
taskReparent,
|
|
1170
|
+
taskRestore,
|
|
1171
|
+
taskShow,
|
|
1172
|
+
taskShowIvtrHistory,
|
|
1173
|
+
taskShowOperation,
|
|
1174
|
+
taskShowWithHistory,
|
|
1175
|
+
taskSlice,
|
|
1176
|
+
taskStart,
|
|
1177
|
+
taskStats,
|
|
1178
|
+
taskStop,
|
|
1179
|
+
taskSyncLinks,
|
|
1180
|
+
taskSyncLinksRemove,
|
|
1181
|
+
taskSyncReconcile,
|
|
1182
|
+
taskTree,
|
|
1183
|
+
taskUnarchive,
|
|
1184
|
+
taskUnclaim,
|
|
1185
|
+
taskUpdate,
|
|
1186
|
+
taskWorkHistory,
|
|
1187
|
+
tasksAddBatchOp,
|
|
1188
|
+
toolNameToOperationKey,
|
|
1189
|
+
coreBatchValidate as validateBatchValidate,
|
|
1190
|
+
validateChangelog,
|
|
1191
|
+
coreCoherenceCheck as validateCoherenceCheck,
|
|
1192
|
+
coreComplianceRecord as validateComplianceRecord,
|
|
1193
|
+
coreComplianceSummary as validateComplianceSummary,
|
|
1194
|
+
coreComplianceViolations as validateComplianceViolations,
|
|
1195
|
+
validateGateVerify,
|
|
1196
|
+
validateLabels,
|
|
1197
|
+
coreValidateManifest as validateManifestOp,
|
|
1198
|
+
coreValidateOutput as validateOutput,
|
|
1199
|
+
coreValidateProtocol as validateProtocol,
|
|
1200
|
+
validateProtocolArchitectureDecision,
|
|
1201
|
+
validateProtocolArtifactPublish,
|
|
1202
|
+
validateProtocolConsensus,
|
|
1203
|
+
validateProtocolContribution,
|
|
1204
|
+
validateProtocolDecomposition,
|
|
1205
|
+
validateProtocolImplementation,
|
|
1206
|
+
validateProtocolProvenance,
|
|
1207
|
+
validateProtocolRelease,
|
|
1208
|
+
validateProtocolResearch,
|
|
1209
|
+
validateProtocolSpecification,
|
|
1210
|
+
validateProtocolTesting,
|
|
1211
|
+
validateProtocolValidation,
|
|
1212
|
+
validateRequiredParams,
|
|
1213
|
+
coreValidateSchema as validateSchemaOp,
|
|
1214
|
+
validateSuggestedNext,
|
|
1215
|
+
coreValidateTask as validateTaskOp,
|
|
1216
|
+
coreTestCoverage as validateTestCoverage,
|
|
1217
|
+
coreTestRun as validateTestRun,
|
|
1218
|
+
coreTestStatus as validateTestStatus
|
|
1219
|
+
};
|
|
1220
|
+
//# sourceMappingURL=index.js.map
|