@linzumi/cli 0.0.80-beta → 0.0.81-beta
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 +1 -1
- package/dist/index.js +1440 -1048
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -770,6 +770,47 @@ async function pushOk(kandan, topic, event, payload) {
|
|
|
770
770
|
`kandan push failed: ${event}: ${JSON.stringify(reply).slice(0, 500)}`
|
|
771
771
|
);
|
|
772
772
|
}
|
|
773
|
+
async function prepareCommanderCompletedPushPayload(runtime, event, payload) {
|
|
774
|
+
switch (event) {
|
|
775
|
+
case "session:post_thread_message":
|
|
776
|
+
case "session:stream_thread_message":
|
|
777
|
+
case "session:edit_thread_message":
|
|
778
|
+
break;
|
|
779
|
+
default:
|
|
780
|
+
return payload;
|
|
781
|
+
}
|
|
782
|
+
const isEdit = event === "session:edit_thread_message";
|
|
783
|
+
const structured = isEdit ? objectValue(payload.structured) : objectValue(objectValue(payload.payload)?.structured);
|
|
784
|
+
const body = typeof payload.body === "string" ? payload.body : void 0;
|
|
785
|
+
if (structured === void 0 || body === void 0 || stringValue(structured.stream_state) !== "completed") {
|
|
786
|
+
return payload;
|
|
787
|
+
}
|
|
788
|
+
const uploadedFileIds = await uploadedFileIdsForCommanderOutput(
|
|
789
|
+
runtime,
|
|
790
|
+
body,
|
|
791
|
+
structured
|
|
792
|
+
);
|
|
793
|
+
const displayBody = displayBodyForCommanderOutput(body, uploadedFileIds);
|
|
794
|
+
const displayStructured = structuredWithAssistantContent(
|
|
795
|
+
structured,
|
|
796
|
+
displayBody
|
|
797
|
+
);
|
|
798
|
+
if (displayBody === body && uploadedFileIds.length === 0) {
|
|
799
|
+
return payload;
|
|
800
|
+
}
|
|
801
|
+
const base = {
|
|
802
|
+
...payload,
|
|
803
|
+
body: displayBody,
|
|
804
|
+
...uploadedFileIds.length === 0 ? {} : { uploaded_file_ids: uploadedFileIds }
|
|
805
|
+
};
|
|
806
|
+
return isEdit ? { ...base, structured: displayStructured } : {
|
|
807
|
+
...base,
|
|
808
|
+
payload: {
|
|
809
|
+
...objectValue(payload.payload) ?? {},
|
|
810
|
+
structured: displayStructured
|
|
811
|
+
}
|
|
812
|
+
};
|
|
813
|
+
}
|
|
773
814
|
var commanderAttachmentUploadExtensions;
|
|
774
815
|
var init_commanderAttachments = __esm({
|
|
775
816
|
"src/commanderAttachments.ts"() {
|
|
@@ -1845,8 +1886,8 @@ async function connectPhoenixClient(baseUrl, token, socketFactory = (url, protoc
|
|
|
1845
1886
|
if (state.resolveReady !== void 0) {
|
|
1846
1887
|
return;
|
|
1847
1888
|
}
|
|
1848
|
-
state.ready = new Promise((
|
|
1849
|
-
state.resolveReady =
|
|
1889
|
+
state.ready = new Promise((resolve12, reject) => {
|
|
1890
|
+
state.resolveReady = resolve12;
|
|
1850
1891
|
state.rejectReady = reject;
|
|
1851
1892
|
});
|
|
1852
1893
|
state.ready.catch(() => void 0);
|
|
@@ -2079,13 +2120,13 @@ async function connectPhoenixClient(baseUrl, token, socketFactory = (url, protoc
|
|
|
2079
2120
|
const joinRef = event === "phx_join" ? ref : topicJoinRefs.get(topic) ?? null;
|
|
2080
2121
|
const frame = [joinRef, ref, topic, event, payload];
|
|
2081
2122
|
const replyBudgetMs = Math.max(0, Math.ceil(timeoutMs));
|
|
2082
|
-
return new Promise((
|
|
2123
|
+
return new Promise((resolve12, reject) => {
|
|
2083
2124
|
const timer = setTimeout(() => {
|
|
2084
2125
|
if (pending.delete(ref)) {
|
|
2085
2126
|
reject(phoenixPushErrors.replyTimeout(replyBudgetMs, event));
|
|
2086
2127
|
}
|
|
2087
2128
|
}, replyBudgetMs);
|
|
2088
|
-
pending.set(ref, { event, timer, resolve:
|
|
2129
|
+
pending.set(ref, { event, timer, resolve: resolve12, reject });
|
|
2089
2130
|
websocket.send(JSON.stringify(frame));
|
|
2090
2131
|
});
|
|
2091
2132
|
};
|
|
@@ -2252,7 +2293,7 @@ async function connectPhoenixClient(baseUrl, token, socketFactory = (url, protoc
|
|
|
2252
2293
|
resetReady();
|
|
2253
2294
|
void openSocket();
|
|
2254
2295
|
await state.ready;
|
|
2255
|
-
const awaitReady = (event, deadlineMs) => new Promise((
|
|
2296
|
+
const awaitReady = (event, deadlineMs) => new Promise((resolve12, reject) => {
|
|
2256
2297
|
const timer = setTimeout(
|
|
2257
2298
|
() => {
|
|
2258
2299
|
reject(phoenixPushErrors.connectionWaitTimeout(pushTimeoutMs, event));
|
|
@@ -2262,7 +2303,7 @@ async function connectPhoenixClient(baseUrl, token, socketFactory = (url, protoc
|
|
|
2262
2303
|
state.ready.then(
|
|
2263
2304
|
() => {
|
|
2264
2305
|
clearTimeout(timer);
|
|
2265
|
-
|
|
2306
|
+
resolve12();
|
|
2266
2307
|
},
|
|
2267
2308
|
(error) => {
|
|
2268
2309
|
clearTimeout(timer);
|
|
@@ -2396,8 +2437,8 @@ function isControlBacklogEntry(value) {
|
|
|
2396
2437
|
return isJsonObject(value) && typeof value.event === "string" && isJsonObject(value.payload) && (value.control_seq === void 0 || typeof value.control_seq === "number" && Number.isInteger(value.control_seq));
|
|
2397
2438
|
}
|
|
2398
2439
|
function waitForOpen(websocket) {
|
|
2399
|
-
return new Promise((
|
|
2400
|
-
websocket.addEventListener("open", () =>
|
|
2440
|
+
return new Promise((resolve12, reject) => {
|
|
2441
|
+
websocket.addEventListener("open", () => resolve12(), { once: true });
|
|
2401
2442
|
websocket.addEventListener(
|
|
2402
2443
|
"error",
|
|
2403
2444
|
() => reject(new Error("websocket open failed")),
|
|
@@ -3097,15 +3138,15 @@ function createThreadOutbox(options) {
|
|
|
3097
3138
|
}
|
|
3098
3139
|
pushLatencyNextIndex = (pushLatencyNextIndex + 1) % outboxPushLatencyWindowSize;
|
|
3099
3140
|
};
|
|
3100
|
-
const sleep2 = (ms) => new Promise((
|
|
3141
|
+
const sleep2 = (ms) => new Promise((resolve12) => {
|
|
3101
3142
|
const timer = setTimeout(() => {
|
|
3102
3143
|
wakeSleep = void 0;
|
|
3103
|
-
|
|
3144
|
+
resolve12();
|
|
3104
3145
|
}, ms);
|
|
3105
3146
|
wakeSleep = () => {
|
|
3106
3147
|
clearTimeout(timer);
|
|
3107
3148
|
wakeSleep = void 0;
|
|
3108
|
-
|
|
3149
|
+
resolve12();
|
|
3109
3150
|
};
|
|
3110
3151
|
});
|
|
3111
3152
|
const drainHeadEntry = async (pending) => {
|
|
@@ -3235,10 +3276,10 @@ function createThreadOutbox(options) {
|
|
|
3235
3276
|
if (head === void 0 || head.entry.entrySeq > upToSeq) {
|
|
3236
3277
|
return Promise.resolve();
|
|
3237
3278
|
}
|
|
3238
|
-
return new Promise((
|
|
3279
|
+
return new Promise((resolve12, reject) => {
|
|
3239
3280
|
const waiter = {
|
|
3240
3281
|
upToSeq,
|
|
3241
|
-
resolve:
|
|
3282
|
+
resolve: resolve12,
|
|
3242
3283
|
reject,
|
|
3243
3284
|
timer: void 0
|
|
3244
3285
|
};
|
|
@@ -3416,8 +3457,8 @@ function nearestRank(sortedAscending, quantile) {
|
|
|
3416
3457
|
return sortedAscending[rank - 1] ?? 0;
|
|
3417
3458
|
}
|
|
3418
3459
|
function sleepUncancellable(ms) {
|
|
3419
|
-
return new Promise((
|
|
3420
|
-
setTimeout(
|
|
3460
|
+
return new Promise((resolve12) => {
|
|
3461
|
+
setTimeout(resolve12, ms);
|
|
3421
3462
|
});
|
|
3422
3463
|
}
|
|
3423
3464
|
function toError(value) {
|
|
@@ -5349,8 +5390,8 @@ function isConnectionWaitPushError(error) {
|
|
|
5349
5390
|
return isPhoenixConnectionWaitError(error);
|
|
5350
5391
|
}
|
|
5351
5392
|
function sleep(ms) {
|
|
5352
|
-
return new Promise((
|
|
5353
|
-
setTimeout(
|
|
5393
|
+
return new Promise((resolve12) => {
|
|
5394
|
+
setTimeout(resolve12, ms);
|
|
5354
5395
|
});
|
|
5355
5396
|
}
|
|
5356
5397
|
var defaultSnapshotRetryDelaysMs, toolCallOutputTypes, toolCallItemTypes;
|
|
@@ -7301,22 +7342,8 @@ async function pipelinePush(args, state, event, payload) {
|
|
|
7301
7342
|
}
|
|
7302
7343
|
}
|
|
7303
7344
|
async function preparePipelinePushPayload(args, event, payload) {
|
|
7304
|
-
switch (event) {
|
|
7305
|
-
case "session:post_thread_message":
|
|
7306
|
-
case "session:stream_thread_message":
|
|
7307
|
-
case "session:edit_thread_message":
|
|
7308
|
-
break;
|
|
7309
|
-
default:
|
|
7310
|
-
return payload;
|
|
7311
|
-
}
|
|
7312
|
-
const isEdit = event === "session:edit_thread_message";
|
|
7313
|
-
const structured = isEdit ? objectValue(payload.structured) : objectValue(objectValue(payload.payload)?.structured);
|
|
7314
|
-
const body = typeof payload.body === "string" ? payload.body : void 0;
|
|
7315
|
-
if (structured === void 0 || body === void 0 || stringValue(structured.stream_state) !== "completed") {
|
|
7316
|
-
return payload;
|
|
7317
|
-
}
|
|
7318
7345
|
const session = args.options.channelSession;
|
|
7319
|
-
|
|
7346
|
+
return prepareCommanderCompletedPushPayload(
|
|
7320
7347
|
{
|
|
7321
7348
|
kandan: args.kandan,
|
|
7322
7349
|
topic: args.topic,
|
|
@@ -7327,29 +7354,9 @@ async function preparePipelinePushPayload(args, event, payload) {
|
|
|
7327
7354
|
token: args.options.token,
|
|
7328
7355
|
fetch: args.options.fetch
|
|
7329
7356
|
},
|
|
7330
|
-
|
|
7331
|
-
|
|
7357
|
+
event,
|
|
7358
|
+
payload
|
|
7332
7359
|
);
|
|
7333
|
-
const displayBody = displayBodyForCommanderOutput(body, uploadedFileIds);
|
|
7334
|
-
const displayStructured = structuredWithAssistantContent(
|
|
7335
|
-
structured,
|
|
7336
|
-
displayBody
|
|
7337
|
-
);
|
|
7338
|
-
if (displayBody === body && uploadedFileIds.length === 0) {
|
|
7339
|
-
return payload;
|
|
7340
|
-
}
|
|
7341
|
-
const base = {
|
|
7342
|
-
...payload,
|
|
7343
|
-
body: displayBody,
|
|
7344
|
-
...uploadedFileIds.length === 0 ? {} : { uploaded_file_ids: uploadedFileIds }
|
|
7345
|
-
};
|
|
7346
|
-
return isEdit ? { ...base, structured: displayStructured } : {
|
|
7347
|
-
...base,
|
|
7348
|
-
payload: {
|
|
7349
|
-
...objectValue(payload.payload) ?? {},
|
|
7350
|
-
structured: displayStructured
|
|
7351
|
-
}
|
|
7352
|
-
};
|
|
7353
7360
|
}
|
|
7354
7361
|
async function resolvePipelineSnapshot(args, state, turnId) {
|
|
7355
7362
|
const codexThreadId = state.codexThreadId;
|
|
@@ -9417,12 +9424,12 @@ async function requestKandanApproval(args, state, request, turnId, payloadContex
|
|
|
9417
9424
|
reason: "awaiting approval",
|
|
9418
9425
|
approval
|
|
9419
9426
|
};
|
|
9420
|
-
const approvalPromise = new Promise((
|
|
9427
|
+
const approvalPromise = new Promise((resolve12, reject) => {
|
|
9421
9428
|
const pendingRequest = {
|
|
9422
9429
|
requestId: approval.requestId,
|
|
9423
9430
|
sourceSeq,
|
|
9424
9431
|
turnId,
|
|
9425
|
-
resolve:
|
|
9432
|
+
resolve: resolve12,
|
|
9426
9433
|
reject
|
|
9427
9434
|
};
|
|
9428
9435
|
state.pendingApprovalRequests.set(
|
|
@@ -9514,8 +9521,8 @@ async function mirrorLocalTuiInputFromNotification(args, state, turnId, params,
|
|
|
9514
9521
|
}
|
|
9515
9522
|
}
|
|
9516
9523
|
function sleepMs(ms) {
|
|
9517
|
-
return new Promise((
|
|
9518
|
-
setTimeout(
|
|
9524
|
+
return new Promise((resolve12) => {
|
|
9525
|
+
setTimeout(resolve12, ms);
|
|
9519
9526
|
});
|
|
9520
9527
|
}
|
|
9521
9528
|
async function mirrorLocalTuiInputMessage(args, state, turnId, message, payloadContext) {
|
|
@@ -10255,8 +10262,547 @@ var init_channelSession = __esm({
|
|
|
10255
10262
|
}
|
|
10256
10263
|
});
|
|
10257
10264
|
|
|
10265
|
+
// src/claudeCodePipeline.ts
|
|
10266
|
+
import { existsSync } from "node:fs";
|
|
10267
|
+
import { isAbsolute as isAbsolute2, resolve as resolve2 } from "node:path";
|
|
10268
|
+
function createClaudeCodeSessionPipeline(host) {
|
|
10269
|
+
const sourceSeqByTurn = /* @__PURE__ */ new Map();
|
|
10270
|
+
const snapshotsByTurn = /* @__PURE__ */ new Map();
|
|
10271
|
+
const snapshotOrder = [];
|
|
10272
|
+
const openTurnIds = /* @__PURE__ */ new Set();
|
|
10273
|
+
const turnSettlementWaiters = [];
|
|
10274
|
+
let activeTurn;
|
|
10275
|
+
let interruptPending = false;
|
|
10276
|
+
let turnCounter = 0;
|
|
10277
|
+
let lastSourceSeq;
|
|
10278
|
+
let lastUsage;
|
|
10279
|
+
let pipeline2;
|
|
10280
|
+
const push = async (event, payload, timeoutMs) => {
|
|
10281
|
+
const prepared = host.preparePush === void 0 ? payload : await host.preparePush(event, payload);
|
|
10282
|
+
try {
|
|
10283
|
+
return await host.push(event, prepared, timeoutMs);
|
|
10284
|
+
} catch (error) {
|
|
10285
|
+
if (isConnectionLostPushError(error)) {
|
|
10286
|
+
pipeline2.pause();
|
|
10287
|
+
}
|
|
10288
|
+
throw error;
|
|
10289
|
+
}
|
|
10290
|
+
};
|
|
10291
|
+
pipeline2 = createSessionPipeline({
|
|
10292
|
+
instanceId: host.instanceId,
|
|
10293
|
+
threadKey: host.threadKey,
|
|
10294
|
+
persistDir: host.persistDir,
|
|
10295
|
+
push,
|
|
10296
|
+
wire: host.wire,
|
|
10297
|
+
runnerPayload: (eventType, claudeSessionId, sourceMessageSeq, extra) => host.runnerPayload(eventType, claudeSessionId, sourceMessageSeq, {
|
|
10298
|
+
...extra ?? {},
|
|
10299
|
+
agent_provider: "claude-code",
|
|
10300
|
+
claude_session_id: claudeSessionId
|
|
10301
|
+
}),
|
|
10302
|
+
sourceSeqForTurn: (turnId) => sourceSeqByTurn.get(turnId),
|
|
10303
|
+
resolveSnapshot: (turnId) => {
|
|
10304
|
+
const items = snapshotsByTurn.get(turnId);
|
|
10305
|
+
if (items === void 0) {
|
|
10306
|
+
return Promise.reject(
|
|
10307
|
+
new Error(`no retained claude snapshot for turn ${turnId}`)
|
|
10308
|
+
);
|
|
10309
|
+
}
|
|
10310
|
+
return Promise.resolve({ items: [...items] });
|
|
10311
|
+
},
|
|
10312
|
+
onTurnTerminal: (turnId, outcome, reason) => {
|
|
10313
|
+
openTurnIds.delete(turnId);
|
|
10314
|
+
if (openTurnIds.size === 0) {
|
|
10315
|
+
for (const waiter of turnSettlementWaiters.splice(0)) {
|
|
10316
|
+
waiter();
|
|
10317
|
+
}
|
|
10318
|
+
}
|
|
10319
|
+
host.onTurnTerminal(turnId, outcome, reason);
|
|
10320
|
+
},
|
|
10321
|
+
log: host.log,
|
|
10322
|
+
outboxRetryDelaysMs: host.outboxRetryDelaysMs,
|
|
10323
|
+
snapshotRetryDelaysMs: host.snapshotRetryDelaysMs,
|
|
10324
|
+
statsIntervalMs: host.statsIntervalMs,
|
|
10325
|
+
turnStalledThresholdMs: host.turnStalledThresholdMs
|
|
10326
|
+
});
|
|
10327
|
+
const submit = (method, params) => {
|
|
10328
|
+
pipeline2.submitNotification(method, params);
|
|
10329
|
+
};
|
|
10330
|
+
const ensureTurn = () => {
|
|
10331
|
+
if (activeTurn !== void 0) {
|
|
10332
|
+
return activeTurn;
|
|
10333
|
+
}
|
|
10334
|
+
interruptPending = false;
|
|
10335
|
+
turnCounter += 1;
|
|
10336
|
+
const turnId = `claude:${host.instanceId}:turn:${turnCounter}`;
|
|
10337
|
+
const sourceSeq = host.currentSourceSeq() ?? lastSourceSeq ?? host.wire().rootSeq;
|
|
10338
|
+
if (sourceSeq === void 0) {
|
|
10339
|
+
host.log("claude_pipeline.turn_without_source_seq", {
|
|
10340
|
+
thread_key: host.threadKey,
|
|
10341
|
+
turn_id: turnId
|
|
10342
|
+
});
|
|
10343
|
+
} else {
|
|
10344
|
+
lastSourceSeq = sourceSeq;
|
|
10345
|
+
sourceSeqByTurn.set(turnId, sourceSeq);
|
|
10346
|
+
}
|
|
10347
|
+
activeTurn = {
|
|
10348
|
+
turnId,
|
|
10349
|
+
sourceSeq: sourceSeq ?? 0,
|
|
10350
|
+
itemOrder: [],
|
|
10351
|
+
itemsByKey: /* @__PURE__ */ new Map(),
|
|
10352
|
+
pendingTools: /* @__PURE__ */ new Map()
|
|
10353
|
+
};
|
|
10354
|
+
openTurnIds.add(turnId);
|
|
10355
|
+
submit("turn/started", { turnId });
|
|
10356
|
+
pipeline2.notifyTurnMappingReady(turnId);
|
|
10357
|
+
return activeTurn;
|
|
10358
|
+
};
|
|
10359
|
+
const recordItem = (turn, item) => {
|
|
10360
|
+
const key = stringValue(item.id) ?? `item:${turn.itemOrder.length}`;
|
|
10361
|
+
if (!turn.itemsByKey.has(key)) {
|
|
10362
|
+
turn.itemOrder.push(key);
|
|
10363
|
+
}
|
|
10364
|
+
turn.itemsByKey.set(key, item);
|
|
10365
|
+
};
|
|
10366
|
+
const appendRawText = (turn, itemId, type, delta) => {
|
|
10367
|
+
const existing = turn.itemsByKey.get(itemId);
|
|
10368
|
+
const previous = existing === void 0 ? "" : rawItemText(existing, type);
|
|
10369
|
+
recordItem(turn, rawTextItem(type, itemId, `${previous}${delta}`));
|
|
10370
|
+
};
|
|
10371
|
+
const setRawText = (turn, itemId, type, text2) => {
|
|
10372
|
+
recordItem(turn, rawTextItem(type, itemId, text2));
|
|
10373
|
+
};
|
|
10374
|
+
const frozenSnapshotItems = (turn) => turn.itemOrder.flatMap((key) => {
|
|
10375
|
+
const item = turn.itemsByKey.get(key);
|
|
10376
|
+
return item === void 0 ? [] : [item];
|
|
10377
|
+
});
|
|
10378
|
+
const finishTurn = (turn, finalBody) => {
|
|
10379
|
+
const bodyAlreadyRecorded = turn.itemOrder.some((key) => {
|
|
10380
|
+
const item = turn.itemsByKey.get(key);
|
|
10381
|
+
return item !== void 0 && stringValue(item.type) === "agentMessage" && rawItemText(item, "agentMessage").trim() === finalBody.trim();
|
|
10382
|
+
});
|
|
10383
|
+
if (!bodyAlreadyRecorded && finalBody.trim() !== "") {
|
|
10384
|
+
setRawText(turn, `result:${turn.turnId}`, "agentMessage", finalBody);
|
|
10385
|
+
}
|
|
10386
|
+
snapshotsByTurn.set(turn.turnId, frozenSnapshotItems(turn));
|
|
10387
|
+
snapshotOrder.push(turn.turnId);
|
|
10388
|
+
while (snapshotOrder.length > maxRetainedSnapshots) {
|
|
10389
|
+
const evicted = snapshotOrder.shift();
|
|
10390
|
+
if (evicted !== void 0) {
|
|
10391
|
+
snapshotsByTurn.delete(evicted);
|
|
10392
|
+
}
|
|
10393
|
+
}
|
|
10394
|
+
submit("turn/completed", { turnId: turn.turnId });
|
|
10395
|
+
activeTurn = void 0;
|
|
10396
|
+
};
|
|
10397
|
+
const handleToolResult = (turn, event) => {
|
|
10398
|
+
const pending = turn.pendingTools.get(event.itemKey);
|
|
10399
|
+
turn.pendingTools.delete(event.itemKey);
|
|
10400
|
+
const toolName2 = pending?.toolName ?? event.toolName ?? "tool";
|
|
10401
|
+
const input = pending?.input ?? {};
|
|
10402
|
+
const itemId = `tool:${event.itemKey}`;
|
|
10403
|
+
if (!event.isError && isFileChangeTool(toolName2)) {
|
|
10404
|
+
const patchText = claudeFileChangePatchText(toolName2, input, {
|
|
10405
|
+
targetExistedAtCall: pending?.targetExistedAtCall
|
|
10406
|
+
});
|
|
10407
|
+
if (patchText !== void 0) {
|
|
10408
|
+
const item2 = {
|
|
10409
|
+
type: "fileChange",
|
|
10410
|
+
id: itemId,
|
|
10411
|
+
status: "completed",
|
|
10412
|
+
patchText
|
|
10413
|
+
};
|
|
10414
|
+
recordItem(turn, item2);
|
|
10415
|
+
submit("item/completed", { turnId: turn.turnId, item: item2 });
|
|
10416
|
+
return;
|
|
10417
|
+
}
|
|
10418
|
+
}
|
|
10419
|
+
if (isWebSearchTool(toolName2)) {
|
|
10420
|
+
const query = stringValue(input.query) ?? stringValue(input.url) ?? toolName2;
|
|
10421
|
+
const item2 = {
|
|
10422
|
+
type: "web_search_call",
|
|
10423
|
+
id: `web:${event.itemKey}`,
|
|
10424
|
+
query,
|
|
10425
|
+
status: "completed"
|
|
10426
|
+
};
|
|
10427
|
+
recordItem(turn, item2);
|
|
10428
|
+
submit("item/completed", { turnId: turn.turnId, item: item2 });
|
|
10429
|
+
return;
|
|
10430
|
+
}
|
|
10431
|
+
if (!event.isError && toolName2 === "TodoWrite") {
|
|
10432
|
+
const plan = claudePlanItem(itemId, input);
|
|
10433
|
+
if (plan !== void 0) {
|
|
10434
|
+
recordItem(turn, plan);
|
|
10435
|
+
submit("item/completed", { turnId: turn.turnId, item: plan });
|
|
10436
|
+
return;
|
|
10437
|
+
}
|
|
10438
|
+
}
|
|
10439
|
+
const item = {
|
|
10440
|
+
type: "commandExecution",
|
|
10441
|
+
id: itemId,
|
|
10442
|
+
command: claudeToolCommandLabel(toolName2, input),
|
|
10443
|
+
aggregatedOutput: event.content,
|
|
10444
|
+
status: event.isError ? "failed" : "completed"
|
|
10445
|
+
};
|
|
10446
|
+
recordItem(turn, item);
|
|
10447
|
+
submit("item/completed", { turnId: turn.turnId, item });
|
|
10448
|
+
};
|
|
10449
|
+
const handleTranscriptEvent = (event) => {
|
|
10450
|
+
switch (event.type) {
|
|
10451
|
+
case "session_started":
|
|
10452
|
+
return;
|
|
10453
|
+
case "assistant_delta": {
|
|
10454
|
+
const turn = ensureTurn();
|
|
10455
|
+
const itemId = claudeAssistantPipelineItemId(event.itemKey);
|
|
10456
|
+
appendRawText(turn, itemId, "agentMessage", event.delta);
|
|
10457
|
+
submit("item/agentMessage/delta", {
|
|
10458
|
+
turnId: turn.turnId,
|
|
10459
|
+
itemId,
|
|
10460
|
+
delta: event.delta
|
|
10461
|
+
});
|
|
10462
|
+
return;
|
|
10463
|
+
}
|
|
10464
|
+
case "reasoning_delta": {
|
|
10465
|
+
const turn = ensureTurn();
|
|
10466
|
+
const itemId = claudeAssistantPipelineItemId(event.itemKey);
|
|
10467
|
+
appendRawText(turn, itemId, "reasoning", event.delta);
|
|
10468
|
+
submit("item/reasoning/textDelta", {
|
|
10469
|
+
turnId: turn.turnId,
|
|
10470
|
+
itemId,
|
|
10471
|
+
delta: event.delta
|
|
10472
|
+
});
|
|
10473
|
+
return;
|
|
10474
|
+
}
|
|
10475
|
+
case "assistant_message": {
|
|
10476
|
+
const turn = ensureTurn();
|
|
10477
|
+
const itemId = claudeAssistantPipelineItemId(event.itemKey);
|
|
10478
|
+
setRawText(turn, itemId, "agentMessage", event.content);
|
|
10479
|
+
submit("item/completed", {
|
|
10480
|
+
turnId: turn.turnId,
|
|
10481
|
+
item: rawTextItem("agentMessage", itemId, event.content)
|
|
10482
|
+
});
|
|
10483
|
+
return;
|
|
10484
|
+
}
|
|
10485
|
+
case "reasoning_message": {
|
|
10486
|
+
const turn = ensureTurn();
|
|
10487
|
+
const itemId = claudeAssistantPipelineItemId(event.itemKey);
|
|
10488
|
+
setRawText(turn, itemId, "reasoning", event.content);
|
|
10489
|
+
submit("item/completed", {
|
|
10490
|
+
turnId: turn.turnId,
|
|
10491
|
+
item: rawTextItem("reasoning", itemId, event.content)
|
|
10492
|
+
});
|
|
10493
|
+
return;
|
|
10494
|
+
}
|
|
10495
|
+
case "tool_call": {
|
|
10496
|
+
const turn = ensureTurn();
|
|
10497
|
+
turn.pendingTools.set(event.itemKey, {
|
|
10498
|
+
toolName: event.toolName,
|
|
10499
|
+
input: event.input,
|
|
10500
|
+
targetExistedAtCall: fileChangeTargetExists(
|
|
10501
|
+
event.toolName,
|
|
10502
|
+
event.input,
|
|
10503
|
+
host.cwd
|
|
10504
|
+
)
|
|
10505
|
+
});
|
|
10506
|
+
if (isWebSearchTool(event.toolName)) {
|
|
10507
|
+
const query = stringValue(event.input.query) ?? stringValue(event.input.url) ?? event.toolName;
|
|
10508
|
+
submit("item/started", {
|
|
10509
|
+
turnId: turn.turnId,
|
|
10510
|
+
item: {
|
|
10511
|
+
type: "web_search_call",
|
|
10512
|
+
id: `web:${event.itemKey}`,
|
|
10513
|
+
query
|
|
10514
|
+
}
|
|
10515
|
+
});
|
|
10516
|
+
}
|
|
10517
|
+
return;
|
|
10518
|
+
}
|
|
10519
|
+
case "tool_result": {
|
|
10520
|
+
handleToolResult(ensureTurn(), event);
|
|
10521
|
+
return;
|
|
10522
|
+
}
|
|
10523
|
+
case "command_output": {
|
|
10524
|
+
const turn = ensureTurn();
|
|
10525
|
+
const item = {
|
|
10526
|
+
type: "commandExecution",
|
|
10527
|
+
id: `local:${event.itemKey}`,
|
|
10528
|
+
command: "Claude Code local command",
|
|
10529
|
+
aggregatedOutput: event.content,
|
|
10530
|
+
status: "completed"
|
|
10531
|
+
};
|
|
10532
|
+
recordItem(turn, item);
|
|
10533
|
+
submit("item/completed", { turnId: turn.turnId, item });
|
|
10534
|
+
return;
|
|
10535
|
+
}
|
|
10536
|
+
case "usage":
|
|
10537
|
+
lastUsage = event.usage;
|
|
10538
|
+
return;
|
|
10539
|
+
case "unknown":
|
|
10540
|
+
host.log("claude_pipeline.unknown_event", {
|
|
10541
|
+
thread_key: host.threadKey,
|
|
10542
|
+
item_key: event.itemKey,
|
|
10543
|
+
summary: event.summary
|
|
10544
|
+
});
|
|
10545
|
+
return;
|
|
10546
|
+
case "turn_interrupted": {
|
|
10547
|
+
interruptPending = false;
|
|
10548
|
+
if (activeTurn !== void 0) {
|
|
10549
|
+
submit("turn/aborted", {
|
|
10550
|
+
turnId: activeTurn.turnId,
|
|
10551
|
+
reason: "Claude Code turn interrupted"
|
|
10552
|
+
});
|
|
10553
|
+
activeTurn = void 0;
|
|
10554
|
+
}
|
|
10555
|
+
return;
|
|
10556
|
+
}
|
|
10557
|
+
case "turn_completed": {
|
|
10558
|
+
if (activeTurn === void 0 && interruptPending) {
|
|
10559
|
+
interruptPending = false;
|
|
10560
|
+
host.log("claude_pipeline.turn_completed_after_interrupt", {
|
|
10561
|
+
thread_key: host.threadKey
|
|
10562
|
+
});
|
|
10563
|
+
return;
|
|
10564
|
+
}
|
|
10565
|
+
const turn = ensureTurn();
|
|
10566
|
+
lastUsage = event.usage ?? lastUsage;
|
|
10567
|
+
finishTurn(turn, event.body);
|
|
10568
|
+
return;
|
|
10569
|
+
}
|
|
10570
|
+
case "session_completed": {
|
|
10571
|
+
if (activeTurn === void 0) {
|
|
10572
|
+
interruptPending = false;
|
|
10573
|
+
return;
|
|
10574
|
+
}
|
|
10575
|
+
lastUsage = event.usage ?? lastUsage;
|
|
10576
|
+
finishTurn(activeTurn, event.body);
|
|
10577
|
+
return;
|
|
10578
|
+
}
|
|
10579
|
+
case "session_failed": {
|
|
10580
|
+
if (activeTurn === void 0) {
|
|
10581
|
+
interruptPending = false;
|
|
10582
|
+
host.log("claude_pipeline.session_failed_without_turn", {
|
|
10583
|
+
thread_key: host.threadKey,
|
|
10584
|
+
reason: event.reason
|
|
10585
|
+
});
|
|
10586
|
+
return;
|
|
10587
|
+
}
|
|
10588
|
+
submit("turn/failed", {
|
|
10589
|
+
turnId: activeTurn.turnId,
|
|
10590
|
+
reason: event.reason
|
|
10591
|
+
});
|
|
10592
|
+
activeTurn = void 0;
|
|
10593
|
+
return;
|
|
10594
|
+
}
|
|
10595
|
+
}
|
|
10596
|
+
};
|
|
10597
|
+
return {
|
|
10598
|
+
handleTranscriptEvent,
|
|
10599
|
+
interruptActiveTurn: (reason) => {
|
|
10600
|
+
if (activeTurn === void 0) {
|
|
10601
|
+
return false;
|
|
10602
|
+
}
|
|
10603
|
+
submit("turn/aborted", { turnId: activeTurn.turnId, reason });
|
|
10604
|
+
activeTurn = void 0;
|
|
10605
|
+
interruptPending = true;
|
|
10606
|
+
return true;
|
|
10607
|
+
},
|
|
10608
|
+
submitLifecycle: (kind, reason) => {
|
|
10609
|
+
pipeline2.submitLifecycle(kind, reason);
|
|
10610
|
+
},
|
|
10611
|
+
awaitTurnsSettled: (timeoutMs = 3e4) => {
|
|
10612
|
+
if (openTurnIds.size === 0) {
|
|
10613
|
+
return Promise.resolve();
|
|
10614
|
+
}
|
|
10615
|
+
return new Promise((resolve12) => {
|
|
10616
|
+
const timer = setTimeout(() => {
|
|
10617
|
+
host.log("claude_pipeline.turn_settlement_timeout", {
|
|
10618
|
+
thread_key: host.threadKey,
|
|
10619
|
+
open_turn_ids: [...openTurnIds]
|
|
10620
|
+
});
|
|
10621
|
+
resolve12();
|
|
10622
|
+
}, timeoutMs);
|
|
10623
|
+
turnSettlementWaiters.push(() => {
|
|
10624
|
+
clearTimeout(timer);
|
|
10625
|
+
resolve12();
|
|
10626
|
+
});
|
|
10627
|
+
});
|
|
10628
|
+
},
|
|
10629
|
+
activeTurnId: () => activeTurn?.turnId,
|
|
10630
|
+
lastUsage: () => lastUsage,
|
|
10631
|
+
flush: (timeoutMs) => pipeline2.flushOutbox(timeoutMs),
|
|
10632
|
+
metrics: () => pipeline2.metrics(),
|
|
10633
|
+
close: (timeoutMs) => pipeline2.close(timeoutMs)
|
|
10634
|
+
};
|
|
10635
|
+
}
|
|
10636
|
+
function rawTextItem(type, id, text2) {
|
|
10637
|
+
return type === "agentMessage" ? { type, id, content: [{ type: "text", text: text2 }] } : { type, id, content: [text2], summary: [] };
|
|
10638
|
+
}
|
|
10639
|
+
function rawItemText(item, type) {
|
|
10640
|
+
const content = Array.isArray(item.content) ? item.content : [];
|
|
10641
|
+
if (type === "reasoning") {
|
|
10642
|
+
return content.filter((part) => typeof part === "string").join("");
|
|
10643
|
+
}
|
|
10644
|
+
return content.flatMap((part) => {
|
|
10645
|
+
const text2 = stringValue(objectValue(part)?.text);
|
|
10646
|
+
return text2 === void 0 ? [] : [text2];
|
|
10647
|
+
}).join("");
|
|
10648
|
+
}
|
|
10649
|
+
function claudeAssistantPipelineItemId(itemKey) {
|
|
10650
|
+
const streamIndex = itemKey.match(/^assistant-stream-(\d+)$/)?.[1];
|
|
10651
|
+
return streamIndex === void 0 ? itemKey : `content-block-${streamIndex}`;
|
|
10652
|
+
}
|
|
10653
|
+
function isFileChangeTool(toolName2) {
|
|
10654
|
+
switch (toolName2) {
|
|
10655
|
+
case "Edit":
|
|
10656
|
+
case "MultiEdit":
|
|
10657
|
+
case "Write":
|
|
10658
|
+
case "NotebookEdit":
|
|
10659
|
+
return true;
|
|
10660
|
+
default:
|
|
10661
|
+
return false;
|
|
10662
|
+
}
|
|
10663
|
+
}
|
|
10664
|
+
function isWebSearchTool(toolName2) {
|
|
10665
|
+
return toolName2 === "WebSearch" || toolName2 === "WebFetch";
|
|
10666
|
+
}
|
|
10667
|
+
function fileChangeTargetExists(toolName2, input, sessionCwd) {
|
|
10668
|
+
if (!isFileChangeTool(toolName2)) {
|
|
10669
|
+
return void 0;
|
|
10670
|
+
}
|
|
10671
|
+
const path2 = stringValue(input.file_path) ?? stringValue(input.filePath) ?? stringValue(input.notebook_path);
|
|
10672
|
+
if (path2 === void 0 || path2.trim() === "") {
|
|
10673
|
+
return void 0;
|
|
10674
|
+
}
|
|
10675
|
+
try {
|
|
10676
|
+
return existsSync(isAbsolute2(path2) ? path2 : resolve2(sessionCwd, path2));
|
|
10677
|
+
} catch (_error) {
|
|
10678
|
+
return void 0;
|
|
10679
|
+
}
|
|
10680
|
+
}
|
|
10681
|
+
function claudeFileChangePatchText(toolName2, input, options = {}) {
|
|
10682
|
+
const path2 = stringValue(input.file_path) ?? stringValue(input.filePath) ?? stringValue(input.notebook_path);
|
|
10683
|
+
if (path2 === void 0 || path2.trim() === "") {
|
|
10684
|
+
return void 0;
|
|
10685
|
+
}
|
|
10686
|
+
switch (toolName2) {
|
|
10687
|
+
case "Write": {
|
|
10688
|
+
const header = options.targetExistedAtCall === false ? `*** Add File: ${path2}` : `*** Update File: ${path2}`;
|
|
10689
|
+
const content = stringValue(input.content) ?? "";
|
|
10690
|
+
return wrapPatch(header, prefixLines(content, "+"));
|
|
10691
|
+
}
|
|
10692
|
+
case "Edit": {
|
|
10693
|
+
const oldString = stringValue(input.old_string) ?? "";
|
|
10694
|
+
const newString = stringValue(input.new_string) ?? "";
|
|
10695
|
+
return wrapPatch(
|
|
10696
|
+
`*** Update File: ${path2}`,
|
|
10697
|
+
editHunk(oldString, newString)
|
|
10698
|
+
);
|
|
10699
|
+
}
|
|
10700
|
+
case "MultiEdit": {
|
|
10701
|
+
const edits = Array.isArray(input.edits) ? input.edits : [];
|
|
10702
|
+
const hunks = edits.flatMap((edit) => {
|
|
10703
|
+
const value = objectValue(edit);
|
|
10704
|
+
if (value === void 0) {
|
|
10705
|
+
return [];
|
|
10706
|
+
}
|
|
10707
|
+
return [
|
|
10708
|
+
editHunk(
|
|
10709
|
+
stringValue(value.old_string) ?? "",
|
|
10710
|
+
stringValue(value.new_string) ?? ""
|
|
10711
|
+
)
|
|
10712
|
+
];
|
|
10713
|
+
});
|
|
10714
|
+
return hunks.length === 0 ? void 0 : wrapPatch(`*** Update File: ${path2}`, hunks.join("\n@@\n"));
|
|
10715
|
+
}
|
|
10716
|
+
case "NotebookEdit": {
|
|
10717
|
+
const source = stringValue(input.new_source) ?? "";
|
|
10718
|
+
return wrapPatch(`*** Update File: ${path2}`, prefixLines(source, "+"));
|
|
10719
|
+
}
|
|
10720
|
+
default:
|
|
10721
|
+
return void 0;
|
|
10722
|
+
}
|
|
10723
|
+
}
|
|
10724
|
+
function editHunk(oldString, newString) {
|
|
10725
|
+
const removed = oldString === "" ? [] : [prefixLines(oldString, "-")];
|
|
10726
|
+
const added = newString === "" ? [] : [prefixLines(newString, "+")];
|
|
10727
|
+
return [...removed, ...added].join("\n");
|
|
10728
|
+
}
|
|
10729
|
+
function prefixLines(text2, prefix) {
|
|
10730
|
+
return text2.split("\n").map((line) => `${prefix}${line}`).join("\n");
|
|
10731
|
+
}
|
|
10732
|
+
function wrapPatch(header, body) {
|
|
10733
|
+
return `*** Begin Patch
|
|
10734
|
+
${header}
|
|
10735
|
+
${body}
|
|
10736
|
+
*** End Patch
|
|
10737
|
+
`;
|
|
10738
|
+
}
|
|
10739
|
+
function claudePlanItem(itemId, input) {
|
|
10740
|
+
const todos = Array.isArray(input.todos) ? input.todos : [];
|
|
10741
|
+
const lines = todos.flatMap((todo) => {
|
|
10742
|
+
const value = objectValue(todo);
|
|
10743
|
+
if (value === void 0) {
|
|
10744
|
+
return [];
|
|
10745
|
+
}
|
|
10746
|
+
const label = stringValue(value.content) ?? stringValue(value.subject) ?? stringValue(value.activeForm);
|
|
10747
|
+
if (label === void 0 || label.trim() === "") {
|
|
10748
|
+
return [];
|
|
10749
|
+
}
|
|
10750
|
+
const glyph = todoStatusGlyphs[stringValue(value.status) ?? "pending"] ?? "[ ]";
|
|
10751
|
+
return [`${glyph} ${label}`];
|
|
10752
|
+
});
|
|
10753
|
+
if (lines.length === 0) {
|
|
10754
|
+
return void 0;
|
|
10755
|
+
}
|
|
10756
|
+
return {
|
|
10757
|
+
type: "reasoning",
|
|
10758
|
+
id: `plan:${itemId}`,
|
|
10759
|
+
content: [["Plan", ...lines].join("\n")],
|
|
10760
|
+
summary: ["Plan", ...lines]
|
|
10761
|
+
};
|
|
10762
|
+
}
|
|
10763
|
+
function claudeToolCommandLabel(toolName2, input) {
|
|
10764
|
+
const mcpMatch = toolName2.match(/^mcp__([^_]+(?:_[^_]+)*?)__(.+)$/);
|
|
10765
|
+
if (mcpMatch !== void 0 && mcpMatch !== null) {
|
|
10766
|
+
const summary2 = claudeToolInputSummary(input);
|
|
10767
|
+
const label = `mcp: ${mcpMatch[1]}.${mcpMatch[2]}`;
|
|
10768
|
+
return summary2 === void 0 ? label : `${label} ${summary2}`;
|
|
10769
|
+
}
|
|
10770
|
+
if (toolName2 === "Bash") {
|
|
10771
|
+
return stringValue(input.command) ?? "Bash";
|
|
10772
|
+
}
|
|
10773
|
+
const summary = claudeToolInputSummary(input);
|
|
10774
|
+
return summary === void 0 ? toolName2 : `${toolName2} ${summary}`;
|
|
10775
|
+
}
|
|
10776
|
+
function claudeToolInputSummary(input) {
|
|
10777
|
+
const direct = stringValue(input.command) ?? stringValue(input.file_path) ?? stringValue(input.notebook_path) ?? stringValue(input.path) ?? stringValue(input.pattern) ?? stringValue(input.query) ?? stringValue(input.url) ?? stringValue(input.description) ?? stringValue(input.prompt);
|
|
10778
|
+
const trimmed = direct?.trim();
|
|
10779
|
+
if (trimmed !== void 0 && trimmed !== "") {
|
|
10780
|
+
return trimmed.length > 200 ? `${trimmed.slice(0, 200)}\u2026` : trimmed;
|
|
10781
|
+
}
|
|
10782
|
+
try {
|
|
10783
|
+
const preview = JSON.stringify(input);
|
|
10784
|
+
return preview === "{}" ? void 0 : preview.slice(0, 200);
|
|
10785
|
+
} catch (_error) {
|
|
10786
|
+
return void 0;
|
|
10787
|
+
}
|
|
10788
|
+
}
|
|
10789
|
+
var maxRetainedSnapshots, todoStatusGlyphs;
|
|
10790
|
+
var init_claudeCodePipeline = __esm({
|
|
10791
|
+
"src/claudeCodePipeline.ts"() {
|
|
10792
|
+
"use strict";
|
|
10793
|
+
init_json();
|
|
10794
|
+
init_integration();
|
|
10795
|
+
maxRetainedSnapshots = 8;
|
|
10796
|
+
todoStatusGlyphs = {
|
|
10797
|
+
completed: "[x]",
|
|
10798
|
+
in_progress: "[>]",
|
|
10799
|
+
pending: "[ ]"
|
|
10800
|
+
};
|
|
10801
|
+
}
|
|
10802
|
+
});
|
|
10803
|
+
|
|
10258
10804
|
// src/claudeCodeSession.ts
|
|
10259
|
-
import { existsSync, readFileSync as readFileSync3 } from "node:fs";
|
|
10805
|
+
import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
|
|
10260
10806
|
import { homedir as homedir3 } from "node:os";
|
|
10261
10807
|
import { join as join4 } from "node:path";
|
|
10262
10808
|
function claudeCodeSettingSources() {
|
|
@@ -10267,7 +10813,7 @@ async function probeClaudeCodeAvailability(args) {
|
|
|
10267
10813
|
cwd: args.cwd,
|
|
10268
10814
|
homeDir: homedir3(),
|
|
10269
10815
|
platform: process.platform,
|
|
10270
|
-
fileExists:
|
|
10816
|
+
fileExists: existsSync2,
|
|
10271
10817
|
readTextFile: readTextFileIfPresent
|
|
10272
10818
|
})) {
|
|
10273
10819
|
return false;
|
|
@@ -10281,11 +10827,19 @@ async function probeClaudeCodeAvailability(args) {
|
|
|
10281
10827
|
settingSources: claudeCodeSettingSources(),
|
|
10282
10828
|
tools: []
|
|
10283
10829
|
},
|
|
10284
|
-
|
|
10830
|
+
// Cold SDK startup spawns the Claude Code subprocess; a fresh npx
|
|
10831
|
+
// install routinely needs several seconds on first launch, and a
|
|
10832
|
+
// too-tight probe silently demotes the runner to codex-only until
|
|
10833
|
+
// the next restart. This runs once at runner startup, so a generous
|
|
10834
|
+
// deadline costs nothing in steady state.
|
|
10835
|
+
initializeTimeoutMs: 15e3
|
|
10285
10836
|
});
|
|
10286
10837
|
warmQuery.close();
|
|
10287
10838
|
return true;
|
|
10288
|
-
} catch (
|
|
10839
|
+
} catch (error) {
|
|
10840
|
+
console.error(
|
|
10841
|
+
`claude code availability probe failed: ${error instanceof Error ? error.message : String(error)}`
|
|
10842
|
+
);
|
|
10289
10843
|
return false;
|
|
10290
10844
|
}
|
|
10291
10845
|
}
|
|
@@ -10417,6 +10971,21 @@ async function startClaudeCodeSession(options) {
|
|
|
10417
10971
|
}
|
|
10418
10972
|
break;
|
|
10419
10973
|
}
|
|
10974
|
+
case "interrupted": {
|
|
10975
|
+
state.completedTurnCount += 1;
|
|
10976
|
+
if (state.sessionId !== void 0) {
|
|
10977
|
+
await options.onTranscriptEvent?.({
|
|
10978
|
+
type: "turn_interrupted",
|
|
10979
|
+
sessionId: state.sessionId
|
|
10980
|
+
});
|
|
10981
|
+
}
|
|
10982
|
+
if (options.streamingInput !== void 0) {
|
|
10983
|
+
await options.onTurnCompleted?.();
|
|
10984
|
+
resetClaudeAssistantAggregate(state);
|
|
10985
|
+
state.resultText = void 0;
|
|
10986
|
+
}
|
|
10987
|
+
break;
|
|
10988
|
+
}
|
|
10420
10989
|
case "error":
|
|
10421
10990
|
return await failClaudeCodeSession(
|
|
10422
10991
|
options,
|
|
@@ -10447,14 +11016,14 @@ async function emitClaudeCodeTurnCompleted(options, state) {
|
|
|
10447
11016
|
async function completeClaudeCodeSession(options, state) {
|
|
10448
11017
|
const body = state.resultText ?? nonEmptyText(claudeAssistantAggregateText(state));
|
|
10449
11018
|
if (body === void 0) {
|
|
10450
|
-
await failClaudeCodeSession(
|
|
11019
|
+
return await failClaudeCodeSession(
|
|
10451
11020
|
options,
|
|
10452
11021
|
state.sessionId,
|
|
10453
11022
|
"Claude Code completed without a text response"
|
|
10454
11023
|
);
|
|
10455
11024
|
}
|
|
10456
11025
|
if (state.sessionId === void 0) {
|
|
10457
|
-
await failClaudeCodeSession(
|
|
11026
|
+
return await failClaudeCodeSession(
|
|
10458
11027
|
options,
|
|
10459
11028
|
void 0,
|
|
10460
11029
|
"Claude Code completed without a session id"
|
|
@@ -10537,8 +11106,9 @@ async function failClaudeCodeSession(options, sessionId, reason) {
|
|
|
10537
11106
|
}
|
|
10538
11107
|
async function* defaultClaudeCodeRunner(options) {
|
|
10539
11108
|
const sdk = await import("@anthropic-ai/claude-agent-sdk");
|
|
11109
|
+
const prompt = options.streamingInput?.messages ?? options.prompt;
|
|
10540
11110
|
const query = sdk.query({
|
|
10541
|
-
prompt
|
|
11111
|
+
prompt,
|
|
10542
11112
|
options: {
|
|
10543
11113
|
cwd: options.cwd,
|
|
10544
11114
|
persistSession: true,
|
|
@@ -10552,8 +11122,27 @@ async function* defaultClaudeCodeRunner(options) {
|
|
|
10552
11122
|
preset: "claude_code",
|
|
10553
11123
|
...options.developerInstructions === void 0 ? {} : { append: options.developerInstructions }
|
|
10554
11124
|
},
|
|
11125
|
+
...options.mcpServers === void 0 ? {} : {
|
|
11126
|
+
mcpServers: options.mcpServers
|
|
11127
|
+
},
|
|
11128
|
+
...options.allowedTools === void 0 ? {} : { allowedTools: [...options.allowedTools] },
|
|
11129
|
+
...options.env === void 0 ? {} : { env: options.env },
|
|
10555
11130
|
...options.canUseTool === void 0 ? { hooks: claudeCodePolicyDeferHooks() } : { canUseTool: claudeCodeCanUseTool(options.canUseTool) },
|
|
10556
11131
|
...options.model === void 0 ? {} : { model: options.model }
|
|
11132
|
+
// exactOptionalPropertyTypes: the conditional spreads build a union the
|
|
11133
|
+
// SDK's Options cannot absorb verbatim; the shape is correct field-wise.
|
|
11134
|
+
}
|
|
11135
|
+
});
|
|
11136
|
+
const handle = query;
|
|
11137
|
+
options.onSessionControls?.({
|
|
11138
|
+
interrupt: async () => {
|
|
11139
|
+
await handle.interrupt?.call(query);
|
|
11140
|
+
},
|
|
11141
|
+
setModel: async (model) => {
|
|
11142
|
+
await handle.setModel?.call(query, model);
|
|
11143
|
+
},
|
|
11144
|
+
setPermissionMode: async (mode) => {
|
|
11145
|
+
await handle.setPermissionMode?.call(query, mode);
|
|
10557
11146
|
}
|
|
10558
11147
|
});
|
|
10559
11148
|
try {
|
|
@@ -10676,6 +11265,9 @@ function extractClaudeResultOutcome(message) {
|
|
|
10676
11265
|
}
|
|
10677
11266
|
const subtype = stringValue(messageObject?.subtype);
|
|
10678
11267
|
const isError = messageObject?.is_error === true;
|
|
11268
|
+
if (subtype === "interrupt" || subtype === "error_interrupted" || messageObject?.is_interrupt === true) {
|
|
11269
|
+
return { type: "interrupted" };
|
|
11270
|
+
}
|
|
10679
11271
|
if (isError || subtype === "error_max_turns" || subtype === "error_during_execution") {
|
|
10680
11272
|
return {
|
|
10681
11273
|
type: "error",
|
|
@@ -10720,8 +11312,12 @@ function streamTranscriptEvents(message, sessionId) {
|
|
|
10720
11312
|
switch (stringValue(event?.type)) {
|
|
10721
11313
|
case "content_block_delta": {
|
|
10722
11314
|
const delta = objectValue(event?.delta);
|
|
10723
|
-
const text2 = typeof delta?.text === "string" ? nonEmptyStreamDelta(delta.text) : void 0;
|
|
10724
11315
|
const itemKey = streamItemKey(event, message);
|
|
11316
|
+
if (stringValue(delta?.type) === "thinking_delta") {
|
|
11317
|
+
const thinking = typeof delta?.thinking === "string" ? nonEmptyStreamDelta(delta.thinking) : void 0;
|
|
11318
|
+
return thinking === void 0 ? [] : [{ type: "reasoning_delta", sessionId, itemKey, delta: thinking }];
|
|
11319
|
+
}
|
|
11320
|
+
const text2 = typeof delta?.text === "string" ? nonEmptyStreamDelta(delta.text) : void 0;
|
|
10725
11321
|
return text2 === void 0 ? [] : [{ type: "assistant_delta", sessionId, itemKey, delta: text2 }];
|
|
10726
11322
|
}
|
|
10727
11323
|
case "content_block_start": {
|
|
@@ -10816,47 +11412,27 @@ function transcriptEventsForContentBlock(block, sessionId, itemKey) {
|
|
|
10816
11412
|
}
|
|
10817
11413
|
];
|
|
10818
11414
|
}
|
|
11415
|
+
case "thinking": {
|
|
11416
|
+
const content = nonEmptyText(stringValue(block?.thinking));
|
|
11417
|
+
return content === void 0 ? [] : [{ type: "reasoning_message", sessionId, itemKey, content }];
|
|
11418
|
+
}
|
|
10819
11419
|
case "tool_use": {
|
|
10820
11420
|
const toolName2 = stringValue(block?.name) ?? "tool";
|
|
10821
11421
|
const input = objectValue(block?.input) ?? {};
|
|
10822
|
-
|
|
10823
|
-
|
|
10824
|
-
|
|
10825
|
-
|
|
10826
|
-
|
|
10827
|
-
|
|
10828
|
-
|
|
10829
|
-
|
|
10830
|
-
|
|
10831
|
-
itemKey,
|
|
10832
|
-
toolName2,
|
|
10833
|
-
input
|
|
10834
|
-
);
|
|
10835
|
-
return fileChange === void 0 ? [toolCall] : [toolCall, fileChange];
|
|
11422
|
+
return [
|
|
11423
|
+
{
|
|
11424
|
+
type: "tool_call",
|
|
11425
|
+
sessionId,
|
|
11426
|
+
itemKey,
|
|
11427
|
+
toolName: toolName2,
|
|
11428
|
+
input
|
|
11429
|
+
}
|
|
11430
|
+
];
|
|
10836
11431
|
}
|
|
10837
11432
|
default:
|
|
10838
11433
|
return [];
|
|
10839
11434
|
}
|
|
10840
11435
|
}
|
|
10841
|
-
function fileChangeEventForToolUse(sessionId, itemKey, toolName2, input) {
|
|
10842
|
-
switch (toolName2) {
|
|
10843
|
-
case "Edit":
|
|
10844
|
-
case "MultiEdit":
|
|
10845
|
-
case "Write":
|
|
10846
|
-
case "NotebookEdit": {
|
|
10847
|
-
const path2 = stringValue(input.file_path) ?? stringValue(input.filePath) ?? stringValue(input.notebook_path);
|
|
10848
|
-
return {
|
|
10849
|
-
type: "file_change",
|
|
10850
|
-
sessionId,
|
|
10851
|
-
itemKey: `file:${itemKey}`,
|
|
10852
|
-
path: path2,
|
|
10853
|
-
summary: `${toolName2}${path2 === void 0 ? "" : ` ${path2}`}`
|
|
10854
|
-
};
|
|
10855
|
-
}
|
|
10856
|
-
default:
|
|
10857
|
-
return void 0;
|
|
10858
|
-
}
|
|
10859
|
-
}
|
|
10860
11436
|
function unknownTranscriptEvent(message, sessionId) {
|
|
10861
11437
|
const type = stringValue(message?.type);
|
|
10862
11438
|
if (type === void 0 || type === "keep_alive") {
|
|
@@ -11095,9 +11671,9 @@ function closeStream(stream) {
|
|
|
11095
11671
|
if (stream.closed || stream.destroyed) {
|
|
11096
11672
|
return Promise.resolve();
|
|
11097
11673
|
}
|
|
11098
|
-
return new Promise((
|
|
11674
|
+
return new Promise((resolve12, reject) => {
|
|
11099
11675
|
stream.once("error", reject);
|
|
11100
|
-
stream.end(
|
|
11676
|
+
stream.end(resolve12);
|
|
11101
11677
|
});
|
|
11102
11678
|
}
|
|
11103
11679
|
var sensitiveMarker, sensitiveQueryParams, sensitiveArgFlags;
|
|
@@ -11261,7 +11837,7 @@ import {
|
|
|
11261
11837
|
import { createServer } from "node:net";
|
|
11262
11838
|
import { WebSocket as NodeWebSocket } from "ws";
|
|
11263
11839
|
async function chooseLoopbackPort() {
|
|
11264
|
-
return new Promise((
|
|
11840
|
+
return new Promise((resolve12, reject) => {
|
|
11265
11841
|
const server = createServer();
|
|
11266
11842
|
server.on("error", (error) => reject(error));
|
|
11267
11843
|
server.listen(0, "127.0.0.1", () => {
|
|
@@ -11272,7 +11848,7 @@ async function chooseLoopbackPort() {
|
|
|
11272
11848
|
if (error !== void 0) {
|
|
11273
11849
|
reject(error);
|
|
11274
11850
|
} else {
|
|
11275
|
-
|
|
11851
|
+
resolve12(port);
|
|
11276
11852
|
}
|
|
11277
11853
|
});
|
|
11278
11854
|
} else {
|
|
@@ -11457,7 +12033,26 @@ function codexConfigArgs(options) {
|
|
|
11457
12033
|
...options.fast === true ? ["-c", `service_tier=${JSON.stringify("fast")}`] : [],
|
|
11458
12034
|
...(options.mcpServers ?? []).flatMap(
|
|
11459
12035
|
(server) => codexMcpConfigArgs(server)
|
|
11460
|
-
)
|
|
12036
|
+
),
|
|
12037
|
+
...options.modelProvider === void 0 ? [] : codexModelProviderConfigArgs(options.modelProvider)
|
|
12038
|
+
];
|
|
12039
|
+
}
|
|
12040
|
+
function codexModelProviderConfigArgs(provider) {
|
|
12041
|
+
return [
|
|
12042
|
+
"-c",
|
|
12043
|
+
`model_providers.${provider.id}.name=${JSON.stringify(provider.name)}`,
|
|
12044
|
+
"-c",
|
|
12045
|
+
`model_providers.${provider.id}.base_url=${JSON.stringify(provider.baseUrl)}`,
|
|
12046
|
+
"-c",
|
|
12047
|
+
`model_providers.${provider.id}.env_key=${JSON.stringify(provider.envKey)}`,
|
|
12048
|
+
"-c",
|
|
12049
|
+
`model_providers.${provider.id}.wire_api=${JSON.stringify(provider.wireApi)}`,
|
|
12050
|
+
...Object.entries(provider.httpHeaders ?? {}).flatMap(([header, value]) => [
|
|
12051
|
+
"-c",
|
|
12052
|
+
`model_providers.${provider.id}.http_headers.${header}=${JSON.stringify(value)}`
|
|
12053
|
+
]),
|
|
12054
|
+
"-c",
|
|
12055
|
+
`model_provider=${JSON.stringify(provider.id)}`
|
|
11461
12056
|
];
|
|
11462
12057
|
}
|
|
11463
12058
|
async function connectCodexAppServer(websocketUrl, socketFactory = (url) => new NodeWebSocket(url)) {
|
|
@@ -11690,14 +12285,14 @@ function sendRequest(websocket, pending, message) {
|
|
|
11690
12285
|
if (websocket.readyState !== WebSocket.OPEN) {
|
|
11691
12286
|
return Promise.reject(new Error("codex app-server websocket is not open"));
|
|
11692
12287
|
}
|
|
11693
|
-
return new Promise((
|
|
11694
|
-
pending.set(message.id, { resolve:
|
|
12288
|
+
return new Promise((resolve12, reject) => {
|
|
12289
|
+
pending.set(message.id, { resolve: resolve12, reject });
|
|
11695
12290
|
websocket.send(JSON.stringify(message));
|
|
11696
12291
|
});
|
|
11697
12292
|
}
|
|
11698
12293
|
function waitForOpen2(websocket) {
|
|
11699
|
-
return new Promise((
|
|
11700
|
-
websocket.addEventListener("open", () =>
|
|
12294
|
+
return new Promise((resolve12, reject) => {
|
|
12295
|
+
websocket.addEventListener("open", () => resolve12(), { once: true });
|
|
11701
12296
|
websocket.addEventListener(
|
|
11702
12297
|
"error",
|
|
11703
12298
|
() => reject(new Error("websocket open failed")),
|
|
@@ -11710,7 +12305,7 @@ function waitForOpen2(websocket) {
|
|
|
11710
12305
|
function waitForReadyz(websocketUrl, child, timeoutMs = 1e4) {
|
|
11711
12306
|
const readyzUrl = readyzUrlForWebsocket(websocketUrl);
|
|
11712
12307
|
const deadline = Date.now() + timeoutMs;
|
|
11713
|
-
return new Promise((
|
|
12308
|
+
return new Promise((resolve12, reject) => {
|
|
11714
12309
|
let settled = false;
|
|
11715
12310
|
let timer;
|
|
11716
12311
|
const finish = (result) => {
|
|
@@ -11723,7 +12318,7 @@ function waitForReadyz(websocketUrl, child, timeoutMs = 1e4) {
|
|
|
11723
12318
|
}
|
|
11724
12319
|
child.off("exit", onExit2);
|
|
11725
12320
|
if (result === "ready") {
|
|
11726
|
-
|
|
12321
|
+
resolve12();
|
|
11727
12322
|
} else {
|
|
11728
12323
|
reject(result);
|
|
11729
12324
|
}
|
|
@@ -11782,19 +12377,19 @@ var init_codexAppServer = __esm({
|
|
|
11782
12377
|
|
|
11783
12378
|
// src/codexProjectTrust.ts
|
|
11784
12379
|
import {
|
|
11785
|
-
existsSync as
|
|
12380
|
+
existsSync as existsSync3,
|
|
11786
12381
|
mkdirSync as mkdirSync3,
|
|
11787
12382
|
readFileSync as readFileSync4,
|
|
11788
12383
|
realpathSync,
|
|
11789
12384
|
writeFileSync
|
|
11790
12385
|
} from "node:fs";
|
|
11791
12386
|
import { homedir as homedir5 } from "node:os";
|
|
11792
|
-
import { join as join6, resolve as
|
|
12387
|
+
import { join as join6, resolve as resolve3 } from "node:path";
|
|
11793
12388
|
function ensureCodexProjectTrusted(projectPath, options = {}) {
|
|
11794
|
-
const trustedPath = realpathSync(
|
|
12389
|
+
const trustedPath = realpathSync(resolve3(projectPath));
|
|
11795
12390
|
const configHome = options.configHome ?? process.env.CODEX_HOME ?? join6(homedir5(), ".codex");
|
|
11796
12391
|
const configPath = join6(configHome, "config.toml");
|
|
11797
|
-
const currentConfig =
|
|
12392
|
+
const currentConfig = existsSync3(configPath) ? readFileSync4(configPath, "utf8") : "";
|
|
11798
12393
|
const nextConfig = codexConfigWithTrustedProject(currentConfig, trustedPath);
|
|
11799
12394
|
if (nextConfig !== currentConfig) {
|
|
11800
12395
|
mkdirSync3(configHome, { recursive: true });
|
|
@@ -12144,7 +12739,7 @@ var init_codexNotificationConsoleStats = __esm({
|
|
|
12144
12739
|
// src/localCapabilities.ts
|
|
12145
12740
|
import { realpathSync as realpathSync2 } from "node:fs";
|
|
12146
12741
|
import { homedir as homedir6 } from "node:os";
|
|
12147
|
-
import { isAbsolute as
|
|
12742
|
+
import { isAbsolute as isAbsolute3, relative as relative2, resolve as resolve4 } from "node:path";
|
|
12148
12743
|
function parseAllowedCwdList(value) {
|
|
12149
12744
|
if (value === void 0) {
|
|
12150
12745
|
return [];
|
|
@@ -12172,7 +12767,7 @@ function parseAllowedPortList(value) {
|
|
|
12172
12767
|
function assertConfiguredAllowedCwds(paths) {
|
|
12173
12768
|
const allowed = paths.flatMap((path2) => {
|
|
12174
12769
|
try {
|
|
12175
|
-
const absolutePath =
|
|
12770
|
+
const absolutePath = resolve4(expandUserPath(path2));
|
|
12176
12771
|
const realPath = realpathSync2(absolutePath);
|
|
12177
12772
|
return realPath === absolutePath ? [realPath] : [realPath, absolutePath];
|
|
12178
12773
|
} catch (_error) {
|
|
@@ -12186,7 +12781,7 @@ function expandUserPath(pathValue) {
|
|
|
12186
12781
|
return currentHomeDirectory();
|
|
12187
12782
|
}
|
|
12188
12783
|
if (pathValue.startsWith("~/")) {
|
|
12189
|
-
return
|
|
12784
|
+
return resolve4(currentHomeDirectory(), pathValue.slice(2));
|
|
12190
12785
|
}
|
|
12191
12786
|
return pathValue;
|
|
12192
12787
|
}
|
|
@@ -12203,7 +12798,7 @@ function resolveAllowedCwd(requestedCwd, allowedRoots) {
|
|
|
12203
12798
|
}
|
|
12204
12799
|
let cwd;
|
|
12205
12800
|
try {
|
|
12206
|
-
cwd = realpathSync2(
|
|
12801
|
+
cwd = realpathSync2(resolve4(requestedCwd));
|
|
12207
12802
|
} catch (_error) {
|
|
12208
12803
|
return { ok: false, reason: "cwd_not_found" };
|
|
12209
12804
|
}
|
|
@@ -12219,7 +12814,7 @@ function relativePathIsInsideRoot(pathRelativeToRoot) {
|
|
|
12219
12814
|
return pathRelativeToRoot === "" || !pathLooksAbsolute(pathRelativeToRoot) && pathRelativeToRoot !== ".." && !pathRelativeToRoot.startsWith("../") && !pathRelativeToRoot.startsWith("..\\") && !pathRelativeToRoot.includes("/../") && !pathRelativeToRoot.includes("\\..\\");
|
|
12220
12815
|
}
|
|
12221
12816
|
function pathLooksAbsolute(pathValue) {
|
|
12222
|
-
return
|
|
12817
|
+
return isAbsolute3(pathValue) || /^[A-Za-z]:[\\/]/.test(pathValue) || pathValue.startsWith("\\\\");
|
|
12223
12818
|
}
|
|
12224
12819
|
var init_localCapabilities = __esm({
|
|
12225
12820
|
"src/localCapabilities.ts"() {
|
|
@@ -12431,7 +13026,7 @@ function stringBodyField(body, key) {
|
|
|
12431
13026
|
return typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
12432
13027
|
}
|
|
12433
13028
|
function startCallbackServer(args) {
|
|
12434
|
-
return new Promise((
|
|
13029
|
+
return new Promise((resolve12, reject) => {
|
|
12435
13030
|
let resolveCallback;
|
|
12436
13031
|
let rejectCallback;
|
|
12437
13032
|
const callbackPromise = new Promise((callbackResolve, callbackReject) => {
|
|
@@ -12487,7 +13082,7 @@ function startCallbackServer(args) {
|
|
|
12487
13082
|
);
|
|
12488
13083
|
return;
|
|
12489
13084
|
}
|
|
12490
|
-
|
|
13085
|
+
resolve12({
|
|
12491
13086
|
redirectUri: `http://${args.host}:${address.port}/callback`,
|
|
12492
13087
|
waitForCallback: () => callbackPromise,
|
|
12493
13088
|
close: () => {
|
|
@@ -12540,7 +13135,7 @@ function escapeHtml(value) {
|
|
|
12540
13135
|
function openBrowser(url) {
|
|
12541
13136
|
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
|
|
12542
13137
|
const args = process.platform === "win32" ? ["/c", "start", "", url] : [url];
|
|
12543
|
-
return new Promise((
|
|
13138
|
+
return new Promise((resolve12) => {
|
|
12544
13139
|
writeCliAuditEvent("process.spawn", {
|
|
12545
13140
|
command,
|
|
12546
13141
|
args,
|
|
@@ -12553,10 +13148,10 @@ function openBrowser(url) {
|
|
|
12553
13148
|
pid: child.pid,
|
|
12554
13149
|
purpose: "oauth.open_browser"
|
|
12555
13150
|
});
|
|
12556
|
-
child.on("error", () =>
|
|
13151
|
+
child.on("error", () => resolve12());
|
|
12557
13152
|
child.on("spawn", () => {
|
|
12558
13153
|
child.unref();
|
|
12559
|
-
|
|
13154
|
+
resolve12();
|
|
12560
13155
|
});
|
|
12561
13156
|
});
|
|
12562
13157
|
}
|
|
@@ -12571,7 +13166,7 @@ var init_oauth = __esm({
|
|
|
12571
13166
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
12572
13167
|
import {
|
|
12573
13168
|
chmodSync,
|
|
12574
|
-
existsSync as
|
|
13169
|
+
existsSync as existsSync4,
|
|
12575
13170
|
linkSync,
|
|
12576
13171
|
mkdirSync as mkdirSync4,
|
|
12577
13172
|
readFileSync as readFileSync5,
|
|
@@ -12580,10 +13175,10 @@ import {
|
|
|
12580
13175
|
writeFileSync as writeFileSync2
|
|
12581
13176
|
} from "node:fs";
|
|
12582
13177
|
import { homedir as homedir7 } from "node:os";
|
|
12583
|
-
import { basename as basename3, dirname as dirname3, join as join7, resolve as
|
|
13178
|
+
import { basename as basename3, dirname as dirname3, join as join7, resolve as resolve5 } from "node:path";
|
|
12584
13179
|
function localConfigPath(env = process.env) {
|
|
12585
13180
|
const override = env.LINZUMI_CONFIG_FILE;
|
|
12586
|
-
return override !== void 0 && override.trim() !== "" ?
|
|
13181
|
+
return override !== void 0 && override.trim() !== "" ? resolve5(expandUserPath(override)) : resolve5(homedir7(), ".linzumi", "config.json");
|
|
12587
13182
|
}
|
|
12588
13183
|
function localConfigScopeKey(linzumiUrl) {
|
|
12589
13184
|
const normalizedUrl = kandanHttpBaseUrl(linzumiUrl);
|
|
@@ -12689,7 +13284,7 @@ function readConfiguredAllowedCwdDetailsFromConfig(config) {
|
|
|
12689
13284
|
const allowedCwds = [];
|
|
12690
13285
|
const missingAllowedCwds = [];
|
|
12691
13286
|
for (const cwd of config.allowedCwds) {
|
|
12692
|
-
const absolutePath =
|
|
13287
|
+
const absolutePath = resolve5(expandUserPath(cwd));
|
|
12693
13288
|
try {
|
|
12694
13289
|
const realPath = realpathSync3(absolutePath);
|
|
12695
13290
|
allowedCwds.push(
|
|
@@ -12719,7 +13314,7 @@ function replaceAllowedCwdsForLinzumiUrl(pathValues, linzumiUrl, path2 = localCo
|
|
|
12719
13314
|
const allowedCwds = uniqueStrings(
|
|
12720
13315
|
pathValues.flatMap((pathValue) => {
|
|
12721
13316
|
const trimmedPath = pathValue.trim();
|
|
12722
|
-
return trimmedPath === "" ? [] : [realpathOrResolved(
|
|
13317
|
+
return trimmedPath === "" ? [] : [realpathOrResolved(resolve5(expandUserPath(trimmedPath)))];
|
|
12723
13318
|
})
|
|
12724
13319
|
);
|
|
12725
13320
|
writeLocalConfigSection(
|
|
@@ -12730,7 +13325,7 @@ function replaceAllowedCwdsForLinzumiUrl(pathValues, linzumiUrl, path2 = localCo
|
|
|
12730
13325
|
return allowedCwds;
|
|
12731
13326
|
}
|
|
12732
13327
|
function addAllowedCwdToConfig(pathValue, path2, linzumiUrl) {
|
|
12733
|
-
const normalizedPath = realpathSync3(
|
|
13328
|
+
const normalizedPath = realpathSync3(resolve5(expandUserPath(pathValue)));
|
|
12734
13329
|
const config = readLocalConfigSection(path2, linzumiUrl);
|
|
12735
13330
|
const allowedCwds = uniqueStrings([...config.allowedCwds, normalizedPath]);
|
|
12736
13331
|
writeLocalConfigSection(
|
|
@@ -12747,7 +13342,7 @@ function removeAllowedCwdForLinzumiUrl(pathValue, linzumiUrl, path2 = localConfi
|
|
|
12747
13342
|
return removeAllowedCwdFromConfig(pathValue, path2, linzumiUrl);
|
|
12748
13343
|
}
|
|
12749
13344
|
function removeAllowedCwdFromConfig(pathValue, path2, linzumiUrl) {
|
|
12750
|
-
const requestedPath =
|
|
13345
|
+
const requestedPath = resolve5(expandUserPath(pathValue));
|
|
12751
13346
|
const normalizedRequest = realpathOrResolved(requestedPath);
|
|
12752
13347
|
const config = readLocalConfigSection(path2, linzumiUrl);
|
|
12753
13348
|
const allowedCwds = config.allowedCwds.filter((cwd) => {
|
|
@@ -12813,7 +13408,7 @@ function writeLocalSignupAuth(auth, path2 = localConfigPath()) {
|
|
|
12813
13408
|
return signupAuthFromJson(nextSignupAuth);
|
|
12814
13409
|
}
|
|
12815
13410
|
function writeLocalConfigJson(path2, payload) {
|
|
12816
|
-
if (
|
|
13411
|
+
if (existsSync4(path2)) {
|
|
12817
13412
|
chmodSync(path2, localConfigFileMode);
|
|
12818
13413
|
}
|
|
12819
13414
|
writeFileSync2(path2, `${JSON.stringify(payload, null, 2)}
|
|
@@ -12840,7 +13435,7 @@ function writeLocalSignupCompletion(completion, path2 = localConfigPath()) {
|
|
|
12840
13435
|
return writeLocalSignupAuth(completion, path2);
|
|
12841
13436
|
}
|
|
12842
13437
|
function readLocalConfigFile(path2) {
|
|
12843
|
-
if (!
|
|
13438
|
+
if (!existsSync4(path2)) {
|
|
12844
13439
|
return { version: 1, allowedCwds: [] };
|
|
12845
13440
|
}
|
|
12846
13441
|
const parsed = JSON.parse(readFileSync5(path2, "utf8"));
|
|
@@ -12940,7 +13535,7 @@ function runnerIdValid(value) {
|
|
|
12940
13535
|
}
|
|
12941
13536
|
function ensureLocalMachineIdSeed(configPath, createMachineId, linzumiUrl) {
|
|
12942
13537
|
const seedPath = localMachineIdSeedPath(configPath, linzumiUrl);
|
|
12943
|
-
if (
|
|
13538
|
+
if (existsSync4(seedPath)) {
|
|
12944
13539
|
return readMachineIdSeed(seedPath);
|
|
12945
13540
|
}
|
|
12946
13541
|
const machineId = createMachineId();
|
|
@@ -12968,7 +13563,7 @@ function ensureLocalMachineIdSeed(configPath, createMachineId, linzumiUrl) {
|
|
|
12968
13563
|
}
|
|
12969
13564
|
function ensureLocalRunnerIdSeed(configPath, createRunnerId, linzumiUrl) {
|
|
12970
13565
|
const seedPath = localRunnerIdSeedPath(configPath, linzumiUrl);
|
|
12971
|
-
if (
|
|
13566
|
+
if (existsSync4(seedPath)) {
|
|
12972
13567
|
return readRunnerIdSeed(seedPath);
|
|
12973
13568
|
}
|
|
12974
13569
|
const runnerId = createRunnerId();
|
|
@@ -13026,9 +13621,9 @@ function isNodeErrorCode(error, code) {
|
|
|
13026
13621
|
}
|
|
13027
13622
|
function realpathOrResolved(pathValue) {
|
|
13028
13623
|
try {
|
|
13029
|
-
return realpathSync3(
|
|
13624
|
+
return realpathSync3(resolve5(expandUserPath(pathValue)));
|
|
13030
13625
|
} catch (_error) {
|
|
13031
|
-
return
|
|
13626
|
+
return resolve5(expandUserPath(pathValue));
|
|
13032
13627
|
}
|
|
13033
13628
|
}
|
|
13034
13629
|
var localConfigFileMode, prodConfigScope;
|
|
@@ -13189,10 +13784,10 @@ function runSandboxRunnerWithTimeout(sandboxRunner, request, parentAbortSignal)
|
|
|
13189
13784
|
}
|
|
13190
13785
|
throw error;
|
|
13191
13786
|
});
|
|
13192
|
-
const timeoutPromise = new Promise((
|
|
13787
|
+
const timeoutPromise = new Promise((resolve12) => {
|
|
13193
13788
|
timeout = setTimeout(() => {
|
|
13194
13789
|
timedOut = true;
|
|
13195
|
-
|
|
13790
|
+
resolve12(timeoutResult);
|
|
13196
13791
|
abortController.abort();
|
|
13197
13792
|
}, request.timeoutMs);
|
|
13198
13793
|
});
|
|
@@ -13301,8 +13896,8 @@ var init_remoteCodexExecutionContext = __esm({
|
|
|
13301
13896
|
});
|
|
13302
13897
|
|
|
13303
13898
|
// src/helloLinzumiProject.ts
|
|
13304
|
-
import { existsSync as
|
|
13305
|
-
import { dirname as dirname4, join as join8, resolve as
|
|
13899
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync6, rmSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
13900
|
+
import { dirname as dirname4, join as join8, resolve as resolve6 } from "node:path";
|
|
13306
13901
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
13307
13902
|
function createHelloLinzumiProject(input = {}) {
|
|
13308
13903
|
const options = typeof input === "string" ? { rootPath: input } : input;
|
|
@@ -13328,10 +13923,10 @@ function resolveHelloProjectRoot(options) {
|
|
|
13328
13923
|
throw new Error("linzumi init-hello-linzumi-demo-app accepts either --dir or --parent-dir/--name, not both");
|
|
13329
13924
|
}
|
|
13330
13925
|
if (options.rootPath !== void 0) {
|
|
13331
|
-
return
|
|
13926
|
+
return resolve6(options.rootPath);
|
|
13332
13927
|
}
|
|
13333
13928
|
const name = normalizeProjectName(options.name ?? defaultHelloLinzumiProjectName);
|
|
13334
|
-
return
|
|
13929
|
+
return resolve6(options.parentDir ?? defaultHelloLinzumiParentDir, name);
|
|
13335
13930
|
}
|
|
13336
13931
|
function normalizeProjectName(value) {
|
|
13337
13932
|
const name = value.trim();
|
|
@@ -13354,11 +13949,11 @@ function assertTcpPort(port) {
|
|
|
13354
13949
|
throw new Error("--port must be a TCP port from 1 to 65535");
|
|
13355
13950
|
}
|
|
13356
13951
|
function assertWritableDemoRoot(root, reset) {
|
|
13357
|
-
if (!
|
|
13952
|
+
if (!existsSync5(root)) {
|
|
13358
13953
|
return;
|
|
13359
13954
|
}
|
|
13360
13955
|
const markerPath = join8(root, markerFile);
|
|
13361
|
-
const isDemoRoot =
|
|
13956
|
+
const isDemoRoot = existsSync5(markerPath) && readFileSync6(markerPath, "utf8").trim() === "hello-linzumi";
|
|
13362
13957
|
if (isDemoRoot && reset) {
|
|
13363
13958
|
rmSync(root, { recursive: true, force: true });
|
|
13364
13959
|
return;
|
|
@@ -14194,7 +14789,7 @@ import { spawn as spawn3 } from "node:child_process";
|
|
|
14194
14789
|
import {
|
|
14195
14790
|
copyFileSync,
|
|
14196
14791
|
cpSync,
|
|
14197
|
-
existsSync as
|
|
14792
|
+
existsSync as existsSync6,
|
|
14198
14793
|
mkdirSync as mkdirSync6,
|
|
14199
14794
|
mkdtempSync,
|
|
14200
14795
|
readFileSync as readFileSync7,
|
|
@@ -14523,9 +15118,9 @@ function ensureCodeServerBrowserExtensionAssets(runtime) {
|
|
|
14523
15118
|
];
|
|
14524
15119
|
repairs.forEach(({ source, target, required: required3 }) => {
|
|
14525
15120
|
switch (true) {
|
|
14526
|
-
case
|
|
15121
|
+
case existsSync6(target):
|
|
14527
15122
|
return;
|
|
14528
|
-
case (!required3 && !
|
|
15123
|
+
case (!required3 && !existsSync6(source)):
|
|
14529
15124
|
return;
|
|
14530
15125
|
default:
|
|
14531
15126
|
mkdirSync6(dirname5(target), { recursive: true });
|
|
@@ -14543,7 +15138,7 @@ function codeServerVscodeRoot(runtime) {
|
|
|
14543
15138
|
)
|
|
14544
15139
|
]);
|
|
14545
15140
|
const rootWithRequiredAssets = roots.find(
|
|
14546
|
-
(root) => codeServerBrowserAssetSources(root).every((source) =>
|
|
15141
|
+
(root) => codeServerBrowserAssetSources(root).every((source) => existsSync6(source))
|
|
14547
15142
|
);
|
|
14548
15143
|
const fallbackRoot = roots[0];
|
|
14549
15144
|
if (fallbackRoot === void 0) {
|
|
@@ -14692,7 +15287,7 @@ function resolveCodeServerExecutable(command, envPath) {
|
|
|
14692
15287
|
continue;
|
|
14693
15288
|
}
|
|
14694
15289
|
const candidate = join9(directory, command);
|
|
14695
|
-
if (!
|
|
15290
|
+
if (!existsSync6(candidate)) {
|
|
14696
15291
|
continue;
|
|
14697
15292
|
}
|
|
14698
15293
|
const realpath2 = realpathSync4(candidate);
|
|
@@ -14920,7 +15515,7 @@ function sameCollaboration(running, requested) {
|
|
|
14920
15515
|
return running.editorSessionId === requested.editorSessionId && running.runtimeSessionId === requested.runtimeSessionId && running.roomId === requested.roomId;
|
|
14921
15516
|
}
|
|
14922
15517
|
function runProcess(command, args) {
|
|
14923
|
-
return new Promise((
|
|
15518
|
+
return new Promise((resolve12, reject) => {
|
|
14924
15519
|
writeCliAuditEvent("process.spawn", {
|
|
14925
15520
|
command,
|
|
14926
15521
|
args,
|
|
@@ -14946,7 +15541,7 @@ function runProcess(command, args) {
|
|
|
14946
15541
|
purpose: "local_editor.install_process"
|
|
14947
15542
|
});
|
|
14948
15543
|
if (code === 0) {
|
|
14949
|
-
|
|
15544
|
+
resolve12();
|
|
14950
15545
|
} else {
|
|
14951
15546
|
reject(new Error(`${command} exited with ${code ?? "unknown"}`));
|
|
14952
15547
|
}
|
|
@@ -14954,7 +15549,7 @@ function runProcess(command, args) {
|
|
|
14954
15549
|
});
|
|
14955
15550
|
}
|
|
14956
15551
|
function waitForCodeServerExit(child) {
|
|
14957
|
-
return new Promise((
|
|
15552
|
+
return new Promise((resolve12) => {
|
|
14958
15553
|
let settled = false;
|
|
14959
15554
|
const cleanup = () => {
|
|
14960
15555
|
child.off("exit", onDone);
|
|
@@ -14966,7 +15561,7 @@ function waitForCodeServerExit(child) {
|
|
|
14966
15561
|
}
|
|
14967
15562
|
settled = true;
|
|
14968
15563
|
cleanup();
|
|
14969
|
-
|
|
15564
|
+
resolve12();
|
|
14970
15565
|
};
|
|
14971
15566
|
child.once("exit", onDone);
|
|
14972
15567
|
child.once("close", onDone);
|
|
@@ -14978,7 +15573,7 @@ function waitForCodeServerExit(child) {
|
|
|
14978
15573
|
function waitForCodeServerReady(port, exited, timeoutMs = 1e4) {
|
|
14979
15574
|
const deadline = Date.now() + timeoutMs;
|
|
14980
15575
|
const readyUrl = `http://127.0.0.1:${port}/`;
|
|
14981
|
-
return new Promise((
|
|
15576
|
+
return new Promise((resolve12) => {
|
|
14982
15577
|
let settled = false;
|
|
14983
15578
|
let timer;
|
|
14984
15579
|
const finish = (result) => {
|
|
@@ -14989,7 +15584,7 @@ function waitForCodeServerReady(port, exited, timeoutMs = 1e4) {
|
|
|
14989
15584
|
if (timer !== void 0) {
|
|
14990
15585
|
clearTimeout(timer);
|
|
14991
15586
|
}
|
|
14992
|
-
|
|
15587
|
+
resolve12(result);
|
|
14993
15588
|
};
|
|
14994
15589
|
const scheduleCheck = () => {
|
|
14995
15590
|
timer = setTimeout(checkReady, 50);
|
|
@@ -15018,7 +15613,7 @@ function waitForCodeServerReady(port, exited, timeoutMs = 1e4) {
|
|
|
15018
15613
|
function waitForCollaborationServerReady(port, exited, timeoutMs = 1e4) {
|
|
15019
15614
|
const deadline = Date.now() + timeoutMs;
|
|
15020
15615
|
const readyUrl = `http://127.0.0.1:${port}/api/login/initial`;
|
|
15021
|
-
return new Promise((
|
|
15616
|
+
return new Promise((resolve12) => {
|
|
15022
15617
|
let settled = false;
|
|
15023
15618
|
let timer;
|
|
15024
15619
|
const finish = (result) => {
|
|
@@ -15029,7 +15624,7 @@ function waitForCollaborationServerReady(port, exited, timeoutMs = 1e4) {
|
|
|
15029
15624
|
if (timer !== void 0) {
|
|
15030
15625
|
clearTimeout(timer);
|
|
15031
15626
|
}
|
|
15032
|
-
|
|
15627
|
+
resolve12(result);
|
|
15033
15628
|
};
|
|
15034
15629
|
const scheduleCheck = () => {
|
|
15035
15630
|
timer = setTimeout(checkReady, 50);
|
|
@@ -15056,7 +15651,7 @@ function waitForCollaborationServerReady(port, exited, timeoutMs = 1e4) {
|
|
|
15056
15651
|
});
|
|
15057
15652
|
}
|
|
15058
15653
|
function waitForCodeServerSpawn(child) {
|
|
15059
|
-
return new Promise((
|
|
15654
|
+
return new Promise((resolve12) => {
|
|
15060
15655
|
let settled = false;
|
|
15061
15656
|
const cleanup = () => {
|
|
15062
15657
|
child.off("spawn", onSpawn);
|
|
@@ -15068,7 +15663,7 @@ function waitForCodeServerSpawn(child) {
|
|
|
15068
15663
|
}
|
|
15069
15664
|
settled = true;
|
|
15070
15665
|
cleanup();
|
|
15071
|
-
|
|
15666
|
+
resolve12("spawned");
|
|
15072
15667
|
};
|
|
15073
15668
|
const onError = () => {
|
|
15074
15669
|
if (settled) {
|
|
@@ -15076,7 +15671,7 @@ function waitForCodeServerSpawn(child) {
|
|
|
15076
15671
|
}
|
|
15077
15672
|
settled = true;
|
|
15078
15673
|
cleanup();
|
|
15079
|
-
|
|
15674
|
+
resolve12("failed");
|
|
15080
15675
|
};
|
|
15081
15676
|
child.once("spawn", onSpawn);
|
|
15082
15677
|
child.once("error", onError);
|
|
@@ -15102,7 +15697,7 @@ import { createHash as createHash4 } from "node:crypto";
|
|
|
15102
15697
|
import {
|
|
15103
15698
|
createReadStream,
|
|
15104
15699
|
createWriteStream as createWriteStream2,
|
|
15105
|
-
existsSync as
|
|
15700
|
+
existsSync as existsSync7,
|
|
15106
15701
|
mkdirSync as mkdirSync7,
|
|
15107
15702
|
mkdtempSync as mkdtempSync2,
|
|
15108
15703
|
readFileSync as readFileSync8,
|
|
@@ -15111,7 +15706,7 @@ import {
|
|
|
15111
15706
|
writeFileSync as writeFileSync5
|
|
15112
15707
|
} from "node:fs";
|
|
15113
15708
|
import { homedir as homedir8 } from "node:os";
|
|
15114
|
-
import { dirname as dirname6, join as join10, resolve as
|
|
15709
|
+
import { dirname as dirname6, join as join10, resolve as resolve7 } from "node:path";
|
|
15115
15710
|
import { Readable } from "node:stream";
|
|
15116
15711
|
import { pipeline } from "node:stream/promises";
|
|
15117
15712
|
async function resolveEditorRuntime(options) {
|
|
@@ -15305,7 +15900,7 @@ function installedRuntime(cacheRoot, manifest) {
|
|
|
15305
15900
|
const manifestPath = join10(runtimeRoot, manifest.manifestPath);
|
|
15306
15901
|
const codeServerBin = join10(runtimeRoot, manifest.codeServerBinPath);
|
|
15307
15902
|
const assets = verifiedRuntimeAssetPaths(runtimeRoot, manifest);
|
|
15308
|
-
if (!
|
|
15903
|
+
if (!existsSync7(manifestPath) || !existsSync7(codeServerBin) || assets === void 0) {
|
|
15309
15904
|
return { ok: false };
|
|
15310
15905
|
}
|
|
15311
15906
|
try {
|
|
@@ -15358,7 +15953,7 @@ async function installRuntime(args) {
|
|
|
15358
15953
|
const manifestPath = join10(extractRoot, args.manifest.manifestPath);
|
|
15359
15954
|
const codeServerBin = join10(extractRoot, args.manifest.codeServerBinPath);
|
|
15360
15955
|
const assets = verifiedRuntimeAssetPaths(extractRoot, args.manifest);
|
|
15361
|
-
if (!
|
|
15956
|
+
if (!existsSync7(codeServerBin) || assets === void 0) {
|
|
15362
15957
|
return { ok: false, reason: "invalid_archive" };
|
|
15363
15958
|
}
|
|
15364
15959
|
mkdirSync7(dirname6(manifestPath), { recursive: true });
|
|
@@ -15516,7 +16111,7 @@ function fileSha256(path2) {
|
|
|
15516
16111
|
});
|
|
15517
16112
|
}
|
|
15518
16113
|
function runtimeInstallRoot(cacheRoot, manifest) {
|
|
15519
|
-
return
|
|
16114
|
+
return resolve7(cacheRoot, manifest.platform, manifest.archiveSha256);
|
|
15520
16115
|
}
|
|
15521
16116
|
function verifiedRuntimeAssetPaths(runtimeRoot, manifest) {
|
|
15522
16117
|
const collaborationExtensionTarball = join10(
|
|
@@ -15572,14 +16167,14 @@ function verifiedRuntimeAssetPaths(runtimeRoot, manifest) {
|
|
|
15572
16167
|
return void 0;
|
|
15573
16168
|
}
|
|
15574
16169
|
const absolutePath = join10(runtimeRoot, relativePath);
|
|
15575
|
-
if (!
|
|
16170
|
+
if (!existsSync7(absolutePath)) {
|
|
15576
16171
|
return void 0;
|
|
15577
16172
|
}
|
|
15578
16173
|
if (expectedSha256 !== void 0 && fileSha256Sync(absolutePath) !== expectedSha256) {
|
|
15579
16174
|
return void 0;
|
|
15580
16175
|
}
|
|
15581
16176
|
}
|
|
15582
|
-
if (!
|
|
16177
|
+
if (!existsSync7(collaborationExtensionTarball) || !existsSync7(collaborationServerTarball)) {
|
|
15583
16178
|
return void 0;
|
|
15584
16179
|
}
|
|
15585
16180
|
return {
|
|
@@ -15625,7 +16220,7 @@ var init_localEditorRuntime = __esm({
|
|
|
15625
16220
|
import { spawn as spawn5, spawnSync as spawnSync3 } from "node:child_process";
|
|
15626
16221
|
import { delimiter as delimiter2, dirname as dirname7, join as join11 } from "node:path";
|
|
15627
16222
|
function probeTool(command, cwd) {
|
|
15628
|
-
return new Promise((
|
|
16223
|
+
return new Promise((resolve12) => {
|
|
15629
16224
|
const args = ["--version"];
|
|
15630
16225
|
writeCliAuditEvent("process.spawn", {
|
|
15631
16226
|
command,
|
|
@@ -15654,7 +16249,7 @@ function probeTool(command, cwd) {
|
|
|
15654
16249
|
}
|
|
15655
16250
|
resolved = true;
|
|
15656
16251
|
clearTimeout(timeout);
|
|
15657
|
-
|
|
16252
|
+
resolve12(status);
|
|
15658
16253
|
};
|
|
15659
16254
|
const timeout = setTimeout(() => {
|
|
15660
16255
|
killDependencyProbe(child.pid);
|
|
@@ -15901,7 +16496,7 @@ var linzumiCliVersion, linzumiCliVersionText;
|
|
|
15901
16496
|
var init_version = __esm({
|
|
15902
16497
|
"src/version.ts"() {
|
|
15903
16498
|
"use strict";
|
|
15904
|
-
linzumiCliVersion = "0.0.
|
|
16499
|
+
linzumiCliVersion = "0.0.81-beta";
|
|
15905
16500
|
linzumiCliVersionText = `linzumi ${linzumiCliVersion}`;
|
|
15906
16501
|
}
|
|
15907
16502
|
});
|
|
@@ -15909,7 +16504,7 @@ var init_version = __esm({
|
|
|
15909
16504
|
// src/runnerLock.ts
|
|
15910
16505
|
import {
|
|
15911
16506
|
closeSync,
|
|
15912
|
-
existsSync as
|
|
16507
|
+
existsSync as existsSync8,
|
|
15913
16508
|
mkdirSync as mkdirSync8,
|
|
15914
16509
|
openSync as openSync2,
|
|
15915
16510
|
readFileSync as readFileSync9,
|
|
@@ -15972,7 +16567,7 @@ function rejectLiveLegacyProductionRunnerLock(machineId, configPath, linzumiUrl,
|
|
|
15972
16567
|
throw new Error(activeRunnerLockMessage(legacyPath, existing));
|
|
15973
16568
|
}
|
|
15974
16569
|
withStaleReplacementLock(legacyPath, isPidAlive, () => {
|
|
15975
|
-
const latest =
|
|
16570
|
+
const latest = existsSync8(legacyPath) ? readRunnerLock(legacyPath) : void 0;
|
|
15976
16571
|
if (latest !== void 0 && isPidAlive(latest.pid)) {
|
|
15977
16572
|
throw new Error(activeRunnerLockMessage(legacyPath, latest));
|
|
15978
16573
|
}
|
|
@@ -16000,7 +16595,7 @@ function writeLockOrHandleExisting(path2, record, isPidAlive, beforeReadExisting
|
|
|
16000
16595
|
}
|
|
16001
16596
|
beforeReplaceStaleLock?.();
|
|
16002
16597
|
withStaleReplacementLock(path2, isPidAlive, () => {
|
|
16003
|
-
const latest =
|
|
16598
|
+
const latest = existsSync8(path2) ? readRunnerLock(path2) : void 0;
|
|
16004
16599
|
if (latest !== void 0 && isPidAlive(latest.pid)) {
|
|
16005
16600
|
throw new Error(activeRunnerLockMessage(path2, latest));
|
|
16006
16601
|
}
|
|
@@ -16098,7 +16693,7 @@ function readRunnerLockForRelease(path2) {
|
|
|
16098
16693
|
}
|
|
16099
16694
|
}
|
|
16100
16695
|
function readRunnerLockIfPresent(path2) {
|
|
16101
|
-
if (!
|
|
16696
|
+
if (!existsSync8(path2)) {
|
|
16102
16697
|
return void 0;
|
|
16103
16698
|
}
|
|
16104
16699
|
try {
|
|
@@ -17655,111 +18250,6 @@ var init_runnerConsoleReporter = __esm({
|
|
|
17655
18250
|
}
|
|
17656
18251
|
});
|
|
17657
18252
|
|
|
17658
|
-
// src/streamDeltaQueue.ts
|
|
17659
|
-
function createStreamDeltaQueue() {
|
|
17660
|
-
return {
|
|
17661
|
-
pending: [],
|
|
17662
|
-
timer: void 0,
|
|
17663
|
-
chain: Promise.resolve(),
|
|
17664
|
-
retryAttempts: 0,
|
|
17665
|
-
retryTimer: void 0
|
|
17666
|
-
};
|
|
17667
|
-
}
|
|
17668
|
-
function enqueueStreamDelta(queue, delta, runtime) {
|
|
17669
|
-
queue.pending.push(delta);
|
|
17670
|
-
scheduleStreamDeltaFlush(queue, runtime);
|
|
17671
|
-
}
|
|
17672
|
-
function flushStreamDeltaQueue(queue, runtime) {
|
|
17673
|
-
clearStreamDeltaFlushTimer(queue);
|
|
17674
|
-
if (queue.retryTimer !== void 0) {
|
|
17675
|
-
return;
|
|
17676
|
-
}
|
|
17677
|
-
const pending = queue.pending;
|
|
17678
|
-
if (pending.length === 0) {
|
|
17679
|
-
return;
|
|
17680
|
-
}
|
|
17681
|
-
queue.pending = [];
|
|
17682
|
-
const deltas = runtime.coalesce(pending);
|
|
17683
|
-
const previous = queue.chain;
|
|
17684
|
-
const next = previous.catch(() => void 0).then(() => forwardCoalescedStreamDeltas(queue, runtime, deltas));
|
|
17685
|
-
queue.chain = next.catch((error) => {
|
|
17686
|
-
runtime.logFailure(runtime.firstTurnId(deltas), error);
|
|
17687
|
-
});
|
|
17688
|
-
}
|
|
17689
|
-
async function forwardCoalescedStreamDeltas(queue, runtime, deltas) {
|
|
17690
|
-
for (let index = 0; index < deltas.length; index += 1) {
|
|
17691
|
-
const delta = deltas[index];
|
|
17692
|
-
if (delta === void 0) {
|
|
17693
|
-
continue;
|
|
17694
|
-
}
|
|
17695
|
-
try {
|
|
17696
|
-
await runtime.forward(delta);
|
|
17697
|
-
} catch (error) {
|
|
17698
|
-
handleStreamDeltaForwardFailure(queue, runtime, deltas.slice(index), error);
|
|
17699
|
-
return;
|
|
17700
|
-
}
|
|
17701
|
-
}
|
|
17702
|
-
queue.retryAttempts = 0;
|
|
17703
|
-
}
|
|
17704
|
-
function handleStreamDeltaForwardFailure(queue, runtime, unsent, error) {
|
|
17705
|
-
runtime.logFailure(runtime.firstTurnId(unsent), error);
|
|
17706
|
-
queue.retryAttempts += 1;
|
|
17707
|
-
const maxRetries = runtime.maxFlushRetries ?? defaultMaxFlushRetries;
|
|
17708
|
-
if (queue.retryAttempts > maxRetries) {
|
|
17709
|
-
queue.retryAttempts = 0;
|
|
17710
|
-
runtime.onPermanentFailure?.(unsent, error);
|
|
17711
|
-
clearStreamDeltaRetryTimer(queue);
|
|
17712
|
-
if (queue.pending.length > 0) {
|
|
17713
|
-
scheduleStreamDeltaFlush(queue, runtime);
|
|
17714
|
-
}
|
|
17715
|
-
return;
|
|
17716
|
-
}
|
|
17717
|
-
queue.pending = [...unsent, ...queue.pending];
|
|
17718
|
-
const retryAttempt = queue.retryAttempts;
|
|
17719
|
-
queue.retryTimer = setTimeout(() => {
|
|
17720
|
-
queue.retryTimer = void 0;
|
|
17721
|
-
flushStreamDeltaQueue(queue, runtime);
|
|
17722
|
-
}, streamDeltaRetryDelayMs(runtime, retryAttempt));
|
|
17723
|
-
}
|
|
17724
|
-
function streamDeltaRetryDelayMs(runtime, retryAttempt) {
|
|
17725
|
-
if (runtime.retryDelayMs !== void 0) {
|
|
17726
|
-
return runtime.retryDelayMs(retryAttempt);
|
|
17727
|
-
}
|
|
17728
|
-
return Math.min(500 * 2 ** (retryAttempt - 1), 1e4);
|
|
17729
|
-
}
|
|
17730
|
-
function clearStreamDeltaFlushTimer(queue) {
|
|
17731
|
-
if (queue.timer !== void 0) {
|
|
17732
|
-
clearTimeout(queue.timer);
|
|
17733
|
-
queue.timer = void 0;
|
|
17734
|
-
}
|
|
17735
|
-
}
|
|
17736
|
-
function clearStreamDeltaRetryTimer(queue) {
|
|
17737
|
-
if (queue.retryTimer !== void 0) {
|
|
17738
|
-
clearTimeout(queue.retryTimer);
|
|
17739
|
-
queue.retryTimer = void 0;
|
|
17740
|
-
}
|
|
17741
|
-
}
|
|
17742
|
-
function scheduleStreamDeltaFlush(queue, runtime) {
|
|
17743
|
-
if (queue.timer !== void 0 || queue.retryTimer !== void 0) {
|
|
17744
|
-
return;
|
|
17745
|
-
}
|
|
17746
|
-
if (runtime.flushIntervalMs <= 0) {
|
|
17747
|
-
flushStreamDeltaQueue(queue, runtime);
|
|
17748
|
-
return;
|
|
17749
|
-
}
|
|
17750
|
-
queue.timer = setTimeout(() => {
|
|
17751
|
-
queue.timer = void 0;
|
|
17752
|
-
flushStreamDeltaQueue(queue, runtime);
|
|
17753
|
-
}, runtime.flushIntervalMs);
|
|
17754
|
-
}
|
|
17755
|
-
var defaultMaxFlushRetries;
|
|
17756
|
-
var init_streamDeltaQueue = __esm({
|
|
17757
|
-
"src/streamDeltaQueue.ts"() {
|
|
17758
|
-
"use strict";
|
|
17759
|
-
defaultMaxFlushRetries = 5;
|
|
17760
|
-
}
|
|
17761
|
-
});
|
|
17762
|
-
|
|
17763
18253
|
// src/telemetry.ts
|
|
17764
18254
|
import { mkdirSync as mkdirSync9, readFileSync as readFileSync10, writeFileSync as writeFileSync6 } from "node:fs";
|
|
17765
18255
|
import { dirname as dirname9, basename as basename5, join as join13 } from "node:path";
|
|
@@ -18004,7 +18494,7 @@ var init_linzumiApiClient = __esm({
|
|
|
18004
18494
|
// src/onboardingConversationDiscovery.ts
|
|
18005
18495
|
import {
|
|
18006
18496
|
closeSync as closeSync2,
|
|
18007
|
-
existsSync as
|
|
18497
|
+
existsSync as existsSync9,
|
|
18008
18498
|
openSync as openSync3,
|
|
18009
18499
|
readdirSync as readdirSync2,
|
|
18010
18500
|
readFileSync as readFileSync11,
|
|
@@ -18115,7 +18605,7 @@ function candidateFromRecord(record) {
|
|
|
18115
18605
|
}
|
|
18116
18606
|
}
|
|
18117
18607
|
function listJsonlFiles(root) {
|
|
18118
|
-
if (!
|
|
18608
|
+
if (!existsSync9(root)) {
|
|
18119
18609
|
return [];
|
|
18120
18610
|
}
|
|
18121
18611
|
const walk = (directory) => {
|
|
@@ -18136,7 +18626,7 @@ function listJsonlFiles(root) {
|
|
|
18136
18626
|
return walk(root);
|
|
18137
18627
|
}
|
|
18138
18628
|
function existingPathCount(paths) {
|
|
18139
|
-
return paths.filter((path2) =>
|
|
18629
|
+
return paths.filter((path2) => existsSync9(path2)).length;
|
|
18140
18630
|
}
|
|
18141
18631
|
function codexCandidateFromPath(path2, activityAt) {
|
|
18142
18632
|
const lines = boundedJsonLines(path2);
|
|
@@ -18507,7 +18997,7 @@ var init_onboardingConversationDiscovery = __esm({
|
|
|
18507
18997
|
// src/onboardingProjectDiscovery.ts
|
|
18508
18998
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
18509
18999
|
import { homedir as homedir10 } from "node:os";
|
|
18510
|
-
import { existsSync as
|
|
19000
|
+
import { existsSync as existsSync10, readdirSync as readdirSync3, readFileSync as readFileSync12, statSync as statSync2 } from "node:fs";
|
|
18511
19001
|
import { basename as basename7, dirname as dirname10, join as join15 } from "node:path";
|
|
18512
19002
|
function discoverCurrentGitProject(args) {
|
|
18513
19003
|
const startedAtMs = args.nowMs ?? Date.now();
|
|
@@ -18672,7 +19162,7 @@ function discoverGitWorktreesInSourceRoot(sourceRoot) {
|
|
|
18672
19162
|
}
|
|
18673
19163
|
}
|
|
18674
19164
|
function isGitWorktreeRoot(path2) {
|
|
18675
|
-
return
|
|
19165
|
+
return existsSync10(join15(path2, ".git"));
|
|
18676
19166
|
}
|
|
18677
19167
|
function defaultLocalProjectSourceRoots(cwd) {
|
|
18678
19168
|
return uniqueStrings2([
|
|
@@ -18766,7 +19256,7 @@ function gitWorktrees(cwd) {
|
|
|
18766
19256
|
);
|
|
18767
19257
|
}
|
|
18768
19258
|
function readmeProjectName(projectPath) {
|
|
18769
|
-
const readmePath = ["README.md", "README.markdown", "readme.md"].map((fileName) => join15(projectPath, fileName)).find((path2) =>
|
|
19259
|
+
const readmePath = ["README.md", "README.markdown", "readme.md"].map((fileName) => join15(projectPath, fileName)).find((path2) => existsSync10(path2));
|
|
18770
19260
|
if (readmePath === void 0) {
|
|
18771
19261
|
return void 0;
|
|
18772
19262
|
}
|
|
@@ -18795,14 +19285,14 @@ var init_onboardingProjectDiscovery = __esm({
|
|
|
18795
19285
|
});
|
|
18796
19286
|
|
|
18797
19287
|
// src/authCache.ts
|
|
18798
|
-
import { existsSync as
|
|
19288
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync10, readFileSync as readFileSync13, writeFileSync as writeFileSync7 } from "node:fs";
|
|
18799
19289
|
import { homedir as homedir11 } from "node:os";
|
|
18800
19290
|
import { dirname as dirname11, join as join16 } from "node:path";
|
|
18801
19291
|
function defaultAuthFilePath() {
|
|
18802
19292
|
return join16(homedir11(), ".linzumi", "auth.json");
|
|
18803
19293
|
}
|
|
18804
19294
|
function readCachedLocalRunnerToken(kandanUrl, authFilePath = defaultAuthFilePath()) {
|
|
18805
|
-
if (!
|
|
19295
|
+
if (!existsSync11(authFilePath)) {
|
|
18806
19296
|
return void 0;
|
|
18807
19297
|
}
|
|
18808
19298
|
const authFile = parseAuthFile(readFileSync13(authFilePath, "utf8"));
|
|
@@ -18822,7 +19312,7 @@ function readCachedLocalRunnerToken(kandanUrl, authFilePath = defaultAuthFilePat
|
|
|
18822
19312
|
};
|
|
18823
19313
|
}
|
|
18824
19314
|
function readPersonalAgentDelegationToken(authFilePath) {
|
|
18825
|
-
if (!
|
|
19315
|
+
if (!existsSync11(authFilePath)) {
|
|
18826
19316
|
throw new Error(
|
|
18827
19317
|
`missing personal-agent delegation auth file: ${authFilePath}`
|
|
18828
19318
|
);
|
|
@@ -18845,7 +19335,7 @@ function readPersonalAgentDelegationToken(authFilePath) {
|
|
|
18845
19335
|
}
|
|
18846
19336
|
function writeCachedLocalRunnerToken(args) {
|
|
18847
19337
|
const authFilePath = args.authFilePath ?? defaultAuthFilePath();
|
|
18848
|
-
const existing =
|
|
19338
|
+
const existing = existsSync11(authFilePath) ? parseAuthFile(readFileSync13(authFilePath, "utf8")) : { version: 1 };
|
|
18849
19339
|
const kandanBaseUrl = kandanHttpBaseUrl(args.kandanUrl);
|
|
18850
19340
|
const issuedAt = /* @__PURE__ */ new Date();
|
|
18851
19341
|
const expiresAt = args.expiresInSeconds === void 0 ? void 0 : new Date(
|
|
@@ -19017,10 +19507,10 @@ function bindThreadCodexWorkerIpc(codex, ipc = process) {
|
|
|
19017
19507
|
});
|
|
19018
19508
|
});
|
|
19019
19509
|
codex.onRequest(
|
|
19020
|
-
(request) => new Promise((
|
|
19510
|
+
(request) => new Promise((resolve12, reject) => {
|
|
19021
19511
|
const id = state.nextServerRequestId;
|
|
19022
19512
|
state.nextServerRequestId += 1;
|
|
19023
|
-
pendingServerRequests.set(id, { resolve:
|
|
19513
|
+
pendingServerRequests.set(id, { resolve: resolve12, reject });
|
|
19024
19514
|
send({
|
|
19025
19515
|
type: "linzumi_thread_codex_worker_server_request",
|
|
19026
19516
|
id,
|
|
@@ -19109,10 +19599,10 @@ function connectThreadCodexWorkerIpc(child) {
|
|
|
19109
19599
|
child.once("exit", onClosed);
|
|
19110
19600
|
child.once("disconnect", onClosed);
|
|
19111
19601
|
return {
|
|
19112
|
-
request: (method, params) => new Promise((
|
|
19602
|
+
request: (method, params) => new Promise((resolve12, reject) => {
|
|
19113
19603
|
const id = state.nextRequestId;
|
|
19114
19604
|
state.nextRequestId += 1;
|
|
19115
|
-
pendingRequests.set(id, { resolve:
|
|
19605
|
+
pendingRequests.set(id, { resolve: resolve12, reject });
|
|
19116
19606
|
try {
|
|
19117
19607
|
send({
|
|
19118
19608
|
type: "linzumi_thread_codex_worker_request",
|
|
@@ -19526,8 +20016,8 @@ var init_signupTaskSuggestions = __esm({
|
|
|
19526
20016
|
|
|
19527
20017
|
// src/remoteCodexSandboxRunner.ts
|
|
19528
20018
|
import { spawn as spawn7 } from "node:child_process";
|
|
19529
|
-
import { existsSync as
|
|
19530
|
-
import { dirname as dirname12, isAbsolute as
|
|
20019
|
+
import { existsSync as existsSync12, realpathSync as realpathSync5 } from "node:fs";
|
|
20020
|
+
import { dirname as dirname12, isAbsolute as isAbsolute4 } from "node:path";
|
|
19531
20021
|
function createConfiguredRemoteCodexSandboxRunner(args) {
|
|
19532
20022
|
const kind = normalizedSandboxKind(args.env.LINZUMI_REMOTE_CODEX_SANDBOX);
|
|
19533
20023
|
if (kind === void 0) {
|
|
@@ -19546,7 +20036,7 @@ function createConfiguredRemoteCodexSandboxRunner(args) {
|
|
|
19546
20036
|
}
|
|
19547
20037
|
break;
|
|
19548
20038
|
}
|
|
19549
|
-
if (!
|
|
20039
|
+
if (!existsSync12(sandboxBin)) {
|
|
19550
20040
|
throw new Error(`remote Codex sandbox binary not found: ${sandboxBin}`);
|
|
19551
20041
|
}
|
|
19552
20042
|
return createRemoteCodexSandboxRunner({
|
|
@@ -19557,7 +20047,7 @@ function createConfiguredRemoteCodexSandboxRunner(args) {
|
|
|
19557
20047
|
function createRemoteCodexSandboxRunner(config, deps = {}) {
|
|
19558
20048
|
const resolvedDeps = {
|
|
19559
20049
|
platform: deps.platform ?? process.platform,
|
|
19560
|
-
exists: deps.exists ??
|
|
20050
|
+
exists: deps.exists ?? existsSync12,
|
|
19561
20051
|
spawnProcess: deps.spawnProcess ?? spawn7
|
|
19562
20052
|
};
|
|
19563
20053
|
return (request) => runSandboxInvocation(
|
|
@@ -19591,7 +20081,7 @@ function buildRemoteCodexSandboxInvocation(config, request, deps) {
|
|
|
19591
20081
|
}
|
|
19592
20082
|
}
|
|
19593
20083
|
function runSandboxInvocation(invocation, request, spawnProcess) {
|
|
19594
|
-
return new Promise((
|
|
20084
|
+
return new Promise((resolve12, reject) => {
|
|
19595
20085
|
const child = spawnProcess(invocation.command, invocation.args, {
|
|
19596
20086
|
cwd: invocation.cwd,
|
|
19597
20087
|
env: invocation.env,
|
|
@@ -19615,7 +20105,7 @@ function runSandboxInvocation(invocation, request, spawnProcess) {
|
|
|
19615
20105
|
child.on("close", (exitCode, signal) => {
|
|
19616
20106
|
if (!settled) {
|
|
19617
20107
|
settled = true;
|
|
19618
|
-
|
|
20108
|
+
resolve12({
|
|
19619
20109
|
exitCode,
|
|
19620
20110
|
signal,
|
|
19621
20111
|
stdout: stdout.value(),
|
|
@@ -19642,7 +20132,7 @@ function bubblewrapArgs(sandboxBin, request, exists) {
|
|
|
19642
20132
|
]);
|
|
19643
20133
|
const readOnlyBindArgs = uniqueStrings3([
|
|
19644
20134
|
...linuxReadOnlyRoots,
|
|
19645
|
-
...
|
|
20135
|
+
...isAbsolute4(request.command) ? [dirname12(request.command)] : [],
|
|
19646
20136
|
dirname12(sandboxBin)
|
|
19647
20137
|
]).flatMap((path2) => exists(path2) ? ["--ro-bind", path2, path2] : []);
|
|
19648
20138
|
const cwdParentDirs = parentDirs(request.cwd).flatMap((path2) => [
|
|
@@ -19676,7 +20166,7 @@ function bubblewrapArgs(sandboxBin, request, exists) {
|
|
|
19676
20166
|
function macosSeatbeltProfile(request, exists) {
|
|
19677
20167
|
const readableRoots = uniqueStrings3([
|
|
19678
20168
|
...macosReadOnlyRoots,
|
|
19679
|
-
...
|
|
20169
|
+
...isAbsolute4(request.command) ? [dirname12(request.command)] : []
|
|
19680
20170
|
]).filter(exists);
|
|
19681
20171
|
const readableRules = readableRoots.map((path2) => `(allow file-read* (subpath ${sandboxString(path2)}))`).join("\n");
|
|
19682
20172
|
const writableTempRules = macosWritableTempRoots.filter(exists).flatMap((path2) => [
|
|
@@ -19746,7 +20236,7 @@ function requiredSandboxBin(kind, env) {
|
|
|
19746
20236
|
if (value === void 0 || value.trim() === "") {
|
|
19747
20237
|
throw new Error(`LINZUMI_REMOTE_CODEX_SANDBOX_BIN is required for ${kind}`);
|
|
19748
20238
|
}
|
|
19749
|
-
if (!
|
|
20239
|
+
if (!isAbsolute4(value)) {
|
|
19750
20240
|
throw new Error("LINZUMI_REMOTE_CODEX_SANDBOX_BIN must be absolute");
|
|
19751
20241
|
}
|
|
19752
20242
|
return value;
|
|
@@ -19820,9 +20310,9 @@ import {
|
|
|
19820
20310
|
basename as basename8,
|
|
19821
20311
|
dirname as dirname13,
|
|
19822
20312
|
extname as extname2,
|
|
19823
|
-
isAbsolute as
|
|
20313
|
+
isAbsolute as isAbsolute5,
|
|
19824
20314
|
join as join18,
|
|
19825
|
-
resolve as
|
|
20315
|
+
resolve as resolve8
|
|
19826
20316
|
} from "node:path";
|
|
19827
20317
|
async function runLocalCodexRunner(options) {
|
|
19828
20318
|
const log2 = makeRunnerLogger(options);
|
|
@@ -21100,6 +21590,17 @@ async function openLocalCodexRunner(options, log2, cleanup, close) {
|
|
|
21100
21590
|
if (workspaceSlug === void 0 || channelSlug === void 0 || kandanThreadId === void 0) {
|
|
21101
21591
|
return void 0;
|
|
21102
21592
|
}
|
|
21593
|
+
const waferResolution = resolveControlWaferModelProvider(control);
|
|
21594
|
+
if (waferResolution.type === "error") {
|
|
21595
|
+
return {
|
|
21596
|
+
instanceId,
|
|
21597
|
+
controlType: control.type,
|
|
21598
|
+
ok: false,
|
|
21599
|
+
error: waferResolution.error,
|
|
21600
|
+
kandanThreadId,
|
|
21601
|
+
cwd
|
|
21602
|
+
};
|
|
21603
|
+
}
|
|
21103
21604
|
const existing = threadRunnerProcesses.get(kandanThreadId);
|
|
21104
21605
|
if (existing !== void 0) {
|
|
21105
21606
|
return {
|
|
@@ -22402,6 +22903,34 @@ async function applyControl(codex, kandan, topic, instanceId, options, agentProv
|
|
|
22402
22903
|
if (delegated !== void 0) {
|
|
22403
22904
|
return delegated;
|
|
22404
22905
|
}
|
|
22906
|
+
if (agentProvider === "codex") {
|
|
22907
|
+
const waferControlError = waferModelProviderControlError(
|
|
22908
|
+
options,
|
|
22909
|
+
control
|
|
22910
|
+
);
|
|
22911
|
+
if (waferControlError !== void 0) {
|
|
22912
|
+
try {
|
|
22913
|
+
await publishStartInstanceMessageState(
|
|
22914
|
+
kandan,
|
|
22915
|
+
topic,
|
|
22916
|
+
control,
|
|
22917
|
+
"failed",
|
|
22918
|
+
waferControlError,
|
|
22919
|
+
{ instanceId }
|
|
22920
|
+
);
|
|
22921
|
+
} catch (error) {
|
|
22922
|
+
log2("kandan.start_instance_wafer_state_push_failed", {
|
|
22923
|
+
message: error instanceof Error ? error.message : String(error)
|
|
22924
|
+
});
|
|
22925
|
+
}
|
|
22926
|
+
return {
|
|
22927
|
+
instanceId,
|
|
22928
|
+
controlType: control.type,
|
|
22929
|
+
ok: false,
|
|
22930
|
+
error: waferControlError
|
|
22931
|
+
};
|
|
22932
|
+
}
|
|
22933
|
+
}
|
|
22405
22934
|
if (agentProvider === "claude-code") {
|
|
22406
22935
|
startupStage = "starting_claude_code_session";
|
|
22407
22936
|
const result2 = await startClaudeCodeProviderInstance({
|
|
@@ -22545,6 +23074,20 @@ async function applyControl(codex, kandan, topic, instanceId, options, agentProv
|
|
|
22545
23074
|
if (delegated !== void 0) {
|
|
22546
23075
|
return delegated;
|
|
22547
23076
|
}
|
|
23077
|
+
if (agentProvider === "codex") {
|
|
23078
|
+
const waferControlError = waferModelProviderControlError(
|
|
23079
|
+
options,
|
|
23080
|
+
control
|
|
23081
|
+
);
|
|
23082
|
+
if (waferControlError !== void 0) {
|
|
23083
|
+
return {
|
|
23084
|
+
instanceId,
|
|
23085
|
+
controlType: control.type,
|
|
23086
|
+
ok: false,
|
|
23087
|
+
error: waferControlError
|
|
23088
|
+
};
|
|
23089
|
+
}
|
|
23090
|
+
}
|
|
22548
23091
|
if (agentProvider === "claude-code") {
|
|
22549
23092
|
const activeSession = activeClaudeCodeSessions.get(codexThreadId);
|
|
22550
23093
|
if (activeSession !== void 0 && workDescription !== void 0) {
|
|
@@ -22843,6 +23386,33 @@ async function applyControl(codex, kandan, topic, instanceId, options, agentProv
|
|
|
22843
23386
|
};
|
|
22844
23387
|
}
|
|
22845
23388
|
case "steer_turn": {
|
|
23389
|
+
const claudeSession = activeClaudeCodeSessions.get(control.threadId);
|
|
23390
|
+
if (claudeSession !== void 0) {
|
|
23391
|
+
const steerText = claudeSteerInputText(control.input);
|
|
23392
|
+
if (steerText === void 0) {
|
|
23393
|
+
return {
|
|
23394
|
+
instanceId,
|
|
23395
|
+
controlType: control.type,
|
|
23396
|
+
agentProvider: "claude-code",
|
|
23397
|
+
ok: false,
|
|
23398
|
+
error: "claude_code_steer_requires_text_input"
|
|
23399
|
+
};
|
|
23400
|
+
}
|
|
23401
|
+
await claudeSession.interruptTurn("Steered by Linzumi");
|
|
23402
|
+
claudeSession.enqueueInput({
|
|
23403
|
+
content: `You were interrupted mid-task. Updated guidance from the user - continue the task with this in mind:
|
|
23404
|
+
|
|
23405
|
+
${steerText}`,
|
|
23406
|
+
sourceSeq: claudeSession.currentSourceSeq()
|
|
23407
|
+
});
|
|
23408
|
+
return {
|
|
23409
|
+
instanceId,
|
|
23410
|
+
controlType: control.type,
|
|
23411
|
+
agentProvider: "claude-code",
|
|
23412
|
+
steered: "steered_via_restart",
|
|
23413
|
+
threadId: control.threadId
|
|
23414
|
+
};
|
|
23415
|
+
}
|
|
22846
23416
|
const response = await codex.request("turn/steer", {
|
|
22847
23417
|
threadId: control.threadId,
|
|
22848
23418
|
turnId: control.turnId,
|
|
@@ -22855,6 +23425,19 @@ async function applyControl(codex, kandan, topic, instanceId, options, agentProv
|
|
|
22855
23425
|
};
|
|
22856
23426
|
}
|
|
22857
23427
|
case "interrupt_turn": {
|
|
23428
|
+
const claudeSession = activeClaudeCodeSessions.get(control.threadId);
|
|
23429
|
+
if (claudeSession !== void 0) {
|
|
23430
|
+
const interrupted = await claudeSession.interruptTurn(
|
|
23431
|
+
"Interrupted by Linzumi"
|
|
23432
|
+
);
|
|
23433
|
+
return {
|
|
23434
|
+
instanceId,
|
|
23435
|
+
controlType: control.type,
|
|
23436
|
+
agentProvider: "claude-code",
|
|
23437
|
+
interrupted,
|
|
23438
|
+
threadId: control.threadId
|
|
23439
|
+
};
|
|
23440
|
+
}
|
|
22858
23441
|
const response = await codex.request("turn/interrupt", {
|
|
22859
23442
|
threadId: control.threadId,
|
|
22860
23443
|
turnId: control.turnId ?? null
|
|
@@ -22888,6 +23471,7 @@ async function applyControl(codex, kandan, topic, instanceId, options, agentProv
|
|
|
22888
23471
|
error: "claude_code_session_not_active"
|
|
22889
23472
|
};
|
|
22890
23473
|
}
|
|
23474
|
+
await activeSession.interruptTurn("Claude Code interrupted by Linzumi");
|
|
22891
23475
|
activeSession.abortController.abort(
|
|
22892
23476
|
new Error("Claude Code interrupted by Linzumi")
|
|
22893
23477
|
);
|
|
@@ -22987,11 +23571,27 @@ async function applyControl(codex, kandan, topic, instanceId, options, agentProv
|
|
|
22987
23571
|
response
|
|
22988
23572
|
};
|
|
22989
23573
|
}
|
|
23574
|
+
case "update_session_settings": {
|
|
23575
|
+
const claudeSession = activeClaudeCodeSessions.get(control.threadId);
|
|
23576
|
+
if (claudeSession === void 0) {
|
|
23577
|
+
return { instanceId, controlType: control.type, skipped: true };
|
|
23578
|
+
}
|
|
23579
|
+
const applied = await claudeSession.updateSettings({
|
|
23580
|
+
model: stringValue(control.model) ?? void 0,
|
|
23581
|
+
approvalPolicy: stringValue(control.approvalPolicy) ?? void 0
|
|
23582
|
+
});
|
|
23583
|
+
return {
|
|
23584
|
+
instanceId,
|
|
23585
|
+
controlType: control.type,
|
|
23586
|
+
agentProvider: "claude-code",
|
|
23587
|
+
threadId: control.threadId,
|
|
23588
|
+
applied
|
|
23589
|
+
};
|
|
23590
|
+
}
|
|
22990
23591
|
case "stop_instance":
|
|
22991
23592
|
case "kill_instance":
|
|
22992
23593
|
case "resolve_port_forward_request":
|
|
22993
23594
|
case "update_thread_interaction_access":
|
|
22994
|
-
case "update_session_settings":
|
|
22995
23595
|
case "set_port_forward_enabled":
|
|
22996
23596
|
case "forward_http_request":
|
|
22997
23597
|
case "forward_tcp_open":
|
|
@@ -23283,6 +23883,52 @@ function startInstanceAgentLabel(provider) {
|
|
|
23283
23883
|
return "Claude Code";
|
|
23284
23884
|
}
|
|
23285
23885
|
}
|
|
23886
|
+
function resolveControlWaferModelProvider(control) {
|
|
23887
|
+
const modelProvider = stringValue(control.modelProvider)?.trim();
|
|
23888
|
+
if (modelProvider === void 0 || modelProvider === "") {
|
|
23889
|
+
return { type: "none" };
|
|
23890
|
+
}
|
|
23891
|
+
if (modelProvider !== "wafer") {
|
|
23892
|
+
return {
|
|
23893
|
+
type: "error",
|
|
23894
|
+
error: `model_provider_unsupported:${modelProvider}`
|
|
23895
|
+
};
|
|
23896
|
+
}
|
|
23897
|
+
const llmProxy = objectValue(control.llmProxy);
|
|
23898
|
+
const baseUrl = stringValue(llmProxy?.baseUrl)?.trim();
|
|
23899
|
+
const token = stringValue(llmProxy?.token)?.trim();
|
|
23900
|
+
if (baseUrl === void 0 || baseUrl === "" || token === void 0 || token === "") {
|
|
23901
|
+
return { type: "error", error: "wafer_model_provider_missing_llm_proxy" };
|
|
23902
|
+
}
|
|
23903
|
+
return {
|
|
23904
|
+
type: "wafer",
|
|
23905
|
+
runtime: {
|
|
23906
|
+
provider: "wafer",
|
|
23907
|
+
llmProxyBaseUrl: baseUrl,
|
|
23908
|
+
llmProxyToken: token
|
|
23909
|
+
}
|
|
23910
|
+
};
|
|
23911
|
+
}
|
|
23912
|
+
function waferModelProviderControlError(options, control) {
|
|
23913
|
+
const resolution = resolveControlWaferModelProvider(control);
|
|
23914
|
+
switch (resolution.type) {
|
|
23915
|
+
case "none":
|
|
23916
|
+
return void 0;
|
|
23917
|
+
case "error":
|
|
23918
|
+
return resolution.error;
|
|
23919
|
+
case "wafer":
|
|
23920
|
+
return options.codexModelProvider?.provider === "wafer" ? void 0 : "wafer_model_provider_requires_thread_worker";
|
|
23921
|
+
}
|
|
23922
|
+
}
|
|
23923
|
+
function linzumiCodexModelProviderConfig(runtime) {
|
|
23924
|
+
return {
|
|
23925
|
+
id: "linzumi",
|
|
23926
|
+
name: "Linzumi Proxy",
|
|
23927
|
+
baseUrl: `${runtime.llmProxyBaseUrl.replace(/\/+$/, "")}/v1`,
|
|
23928
|
+
envKey: "LINZUMI_LLM_PROXY_TOKEN",
|
|
23929
|
+
wireApi: "responses"
|
|
23930
|
+
};
|
|
23931
|
+
}
|
|
23286
23932
|
async function startCodexProviderInstance(args) {
|
|
23287
23933
|
if (args.options.codexUrl === void 0) {
|
|
23288
23934
|
args.setStartupStage("checking_project_trust");
|
|
@@ -23417,8 +24063,8 @@ function createClaudeCodeInputQueue(input) {
|
|
|
23417
24063
|
if (state.closed) {
|
|
23418
24064
|
return Promise.resolve({ done: true, value: void 0 });
|
|
23419
24065
|
}
|
|
23420
|
-
return new Promise((
|
|
23421
|
-
waiters.push(
|
|
24066
|
+
return new Promise((resolve12) => {
|
|
24067
|
+
waiters.push(resolve12);
|
|
23422
24068
|
});
|
|
23423
24069
|
}
|
|
23424
24070
|
};
|
|
@@ -23465,7 +24111,7 @@ async function waitForClaudeCodeToolApproval(args) {
|
|
|
23465
24111
|
}
|
|
23466
24112
|
let completeApproval;
|
|
23467
24113
|
const approvalPromise = new Promise(
|
|
23468
|
-
(
|
|
24114
|
+
(resolve12) => {
|
|
23469
24115
|
let completed = false;
|
|
23470
24116
|
const cleanup = () => {
|
|
23471
24117
|
args.signal.removeEventListener("abort", onAbort);
|
|
@@ -23477,7 +24123,7 @@ async function waitForClaudeCodeToolApproval(args) {
|
|
|
23477
24123
|
}
|
|
23478
24124
|
completed = true;
|
|
23479
24125
|
cleanup();
|
|
23480
|
-
|
|
24126
|
+
resolve12(decision);
|
|
23481
24127
|
};
|
|
23482
24128
|
const onAbort = () => {
|
|
23483
24129
|
complete({
|
|
@@ -23648,23 +24294,124 @@ async function startClaudeCodeProviderInstance(args) {
|
|
|
23648
24294
|
validator: args.options.claudeCodeSessionValidator
|
|
23649
24295
|
});
|
|
23650
24296
|
}
|
|
23651
|
-
const
|
|
24297
|
+
const payloadContext = {
|
|
24298
|
+
runnerIdentity: identityFromAccessToken(args.options.token),
|
|
24299
|
+
codexVersion: void 0
|
|
24300
|
+
};
|
|
24301
|
+
const abortController = new AbortController();
|
|
24302
|
+
let activeSessionId;
|
|
24303
|
+
let sessionControls;
|
|
24304
|
+
const adapter = createClaudeCodeSessionPipeline({
|
|
24305
|
+
instanceId: args.instanceId,
|
|
24306
|
+
cwd: args.cwd,
|
|
24307
|
+
threadKey: `${workspace}:${channel}:${threadId}`,
|
|
24308
|
+
// Injected mock runners (tests) keep the outbox in memory; the real SDK
|
|
24309
|
+
// runner journals to the commander outbox dir for restart recovery.
|
|
24310
|
+
persistDir: args.options.claudeCodeRunner === void 0 ? commanderOutboxPersistDir() : void 0,
|
|
24311
|
+
wire: () => ({
|
|
24312
|
+
workspaceSlug: workspace,
|
|
24313
|
+
channelSlug: channel,
|
|
24314
|
+
kandanThreadId: threadId,
|
|
24315
|
+
codexThreadId: activeSessionId ?? args.resumeSessionId,
|
|
24316
|
+
rootSeq
|
|
24317
|
+
}),
|
|
24318
|
+
push: async (event, payload) => {
|
|
24319
|
+
const reply = await args.kandan.push(args.topic, event, payload);
|
|
24320
|
+
if (isJsonObject(reply) && reply.status === "ok") {
|
|
24321
|
+
return reply;
|
|
24322
|
+
}
|
|
24323
|
+
throw new Error(
|
|
24324
|
+
`kandan push failed: ${event}: ${JSON.stringify(reply).slice(0, 500)}`
|
|
24325
|
+
);
|
|
24326
|
+
},
|
|
24327
|
+
preparePush: (event, payload) => prepareCommanderCompletedPushPayload(
|
|
24328
|
+
{
|
|
24329
|
+
kandan: args.kandan,
|
|
24330
|
+
topic: args.topic,
|
|
24331
|
+
workspace,
|
|
24332
|
+
channel,
|
|
24333
|
+
cwd: args.cwd,
|
|
24334
|
+
kandanUrl: args.options.kandanUrl,
|
|
24335
|
+
token: args.options.token,
|
|
24336
|
+
fetch: args.options.fetch
|
|
24337
|
+
},
|
|
24338
|
+
event,
|
|
24339
|
+
payload
|
|
24340
|
+
),
|
|
24341
|
+
runnerPayload: (eventType, claudeSessionId, sourceMessageSeq, extra) => localRunnerPayload(
|
|
24342
|
+
{ ...args.options, cwd: args.cwd },
|
|
24343
|
+
args.instanceId,
|
|
24344
|
+
eventType,
|
|
24345
|
+
claudeSessionId,
|
|
24346
|
+
payloadContext,
|
|
24347
|
+
sourceMessageSeq,
|
|
24348
|
+
extra
|
|
24349
|
+
),
|
|
24350
|
+
currentSourceSeq: inputQueue.currentSourceSeq,
|
|
24351
|
+
onTurnTerminal: (turnId, outcome, reason) => {
|
|
24352
|
+
args.log("claude_code.turn_terminal", {
|
|
24353
|
+
turn_id: turnId,
|
|
24354
|
+
outcome,
|
|
24355
|
+
reason: reason ?? null,
|
|
24356
|
+
thread_id: threadId,
|
|
24357
|
+
claude_session_id: activeSessionId ?? null
|
|
24358
|
+
});
|
|
24359
|
+
},
|
|
24360
|
+
log: args.log
|
|
24361
|
+
});
|
|
24362
|
+
let mcpAuthCleanup;
|
|
24363
|
+
let mcpServers;
|
|
24364
|
+
try {
|
|
24365
|
+
const mcpCommand = currentLinzumiCommand();
|
|
24366
|
+
const mcpAuth = writeEphemeralMcpAuthFile(args.options);
|
|
24367
|
+
mcpAuthCleanup = mcpAuth.cleanup;
|
|
24368
|
+
const linzumiMcp = linzumiMcpServerConfig({
|
|
24369
|
+
command: mcpCommand.command,
|
|
24370
|
+
argsPrefix: mcpCommand.argsPrefix,
|
|
24371
|
+
kandanUrl: args.options.kandanUrl,
|
|
24372
|
+
authFilePath: mcpAuth.path,
|
|
24373
|
+
ownerUsername: mcpOwnerUsername(args.options),
|
|
24374
|
+
operatingMode: "text",
|
|
24375
|
+
cwd: args.cwd,
|
|
24376
|
+
threadId
|
|
24377
|
+
});
|
|
24378
|
+
mcpServers = {
|
|
24379
|
+
[linzumiMcp.name]: {
|
|
24380
|
+
type: "stdio",
|
|
24381
|
+
command: linzumiMcp.command,
|
|
24382
|
+
args: [...linzumiMcp.args],
|
|
24383
|
+
env: { ...linzumiMcp.env }
|
|
24384
|
+
}
|
|
24385
|
+
};
|
|
24386
|
+
} catch (error) {
|
|
24387
|
+
mcpAuthCleanup?.();
|
|
24388
|
+
mcpAuthCleanup = void 0;
|
|
24389
|
+
args.log("claude_code.mcp_config_failed", {
|
|
24390
|
+
message: error instanceof Error ? error.message : String(error),
|
|
24391
|
+
thread_id: threadId
|
|
24392
|
+
});
|
|
24393
|
+
}
|
|
24394
|
+
const mirrorArgs = {
|
|
23652
24395
|
kandan: args.kandan,
|
|
23653
24396
|
topic: args.topic,
|
|
23654
|
-
options: args.options,
|
|
23655
|
-
instanceId: args.instanceId,
|
|
23656
24397
|
workspace,
|
|
23657
24398
|
channel,
|
|
23658
24399
|
threadId,
|
|
23659
24400
|
cwd: args.cwd,
|
|
23660
24401
|
initialPrompt: workDescription,
|
|
23661
|
-
sourceSeq: inputQueue.currentSourceSeq,
|
|
23662
24402
|
rootSeq,
|
|
23663
24403
|
log: args.log
|
|
23664
|
-
}
|
|
23665
|
-
const abortController = new AbortController();
|
|
23666
|
-
let activeSessionId;
|
|
24404
|
+
};
|
|
23667
24405
|
const onTranscriptEvent = async (event) => {
|
|
24406
|
+
try {
|
|
24407
|
+
await mirrorClaudeSessionStoreAppend(mirrorArgs, event);
|
|
24408
|
+
} catch (error) {
|
|
24409
|
+
args.log("claude_code.session_store_mirror_failed", {
|
|
24410
|
+
session_id: event.sessionId ?? null,
|
|
24411
|
+
event_type: event.type,
|
|
24412
|
+
message: error instanceof Error ? error.message : String(error)
|
|
24413
|
+
});
|
|
24414
|
+
}
|
|
23668
24415
|
if (event.type === "session_started") {
|
|
23669
24416
|
activeSessionId = event.sessionId;
|
|
23670
24417
|
args.activeClaudeCodeSessions.set(event.sessionId, {
|
|
@@ -23673,7 +24420,31 @@ async function startClaudeCodeProviderInstance(args) {
|
|
|
23673
24420
|
channel,
|
|
23674
24421
|
threadId,
|
|
23675
24422
|
currentSourceSeq: inputQueue.currentSourceSeq,
|
|
23676
|
-
enqueueInput: inputQueue.enqueue
|
|
24423
|
+
enqueueInput: inputQueue.enqueue,
|
|
24424
|
+
interruptTurn: async (reason) => {
|
|
24425
|
+
const aborted = adapter.interruptActiveTurn(reason);
|
|
24426
|
+
await sessionControls?.interrupt();
|
|
24427
|
+
return aborted;
|
|
24428
|
+
},
|
|
24429
|
+
updateSettings: async (settings) => {
|
|
24430
|
+
const applied = {};
|
|
24431
|
+
if (settings.model !== void 0) {
|
|
24432
|
+
await sessionControls?.setModel(
|
|
24433
|
+
claudeCodeModelForRuntimeModel(settings.model)
|
|
24434
|
+
);
|
|
24435
|
+
applied.model = settings.model;
|
|
24436
|
+
}
|
|
24437
|
+
if (settings.approvalPolicy !== void 0) {
|
|
24438
|
+
const mode = claudePermissionModeForApprovalPolicy(
|
|
24439
|
+
settings.approvalPolicy
|
|
24440
|
+
);
|
|
24441
|
+
if (mode !== void 0) {
|
|
24442
|
+
await sessionControls?.setPermissionMode(mode);
|
|
24443
|
+
applied.approval_policy = settings.approvalPolicy;
|
|
24444
|
+
}
|
|
24445
|
+
}
|
|
24446
|
+
return applied;
|
|
24447
|
+
}
|
|
23677
24448
|
});
|
|
23678
24449
|
args.ensureClaudeCodeForwardPortSession?.({
|
|
23679
24450
|
sessionId: event.sessionId,
|
|
@@ -23684,7 +24455,7 @@ async function startClaudeCodeProviderInstance(args) {
|
|
|
23684
24455
|
rootSeq,
|
|
23685
24456
|
currentSourceSeq: inputQueue.currentSourceSeq
|
|
23686
24457
|
});
|
|
23687
|
-
|
|
24458
|
+
adapter.handleTranscriptEvent(event);
|
|
23688
24459
|
await args.kandan.push(args.topic, "session:bind", {
|
|
23689
24460
|
workspace,
|
|
23690
24461
|
channel,
|
|
@@ -23698,8 +24469,16 @@ async function startClaudeCodeProviderInstance(args) {
|
|
|
23698
24469
|
});
|
|
23699
24470
|
return;
|
|
23700
24471
|
}
|
|
23701
|
-
|
|
24472
|
+
adapter.handleTranscriptEvent(event);
|
|
23702
24473
|
};
|
|
24474
|
+
const llmProxy = objectValue(args.control.llmProxy);
|
|
24475
|
+
const llmProxyBaseUrl = stringValue(llmProxy?.baseUrl)?.trim();
|
|
24476
|
+
const llmProxyToken = stringValue(llmProxy?.token)?.trim();
|
|
24477
|
+
const sessionEnv = llmProxyBaseUrl !== void 0 && llmProxyBaseUrl !== "" && llmProxyToken !== void 0 && llmProxyToken !== "" ? claudeCodeLlmProxyEnv(
|
|
24478
|
+
process.env,
|
|
24479
|
+
{ baseUrl: llmProxyBaseUrl, token: llmProxyToken },
|
|
24480
|
+
runtimeSettings.model
|
|
24481
|
+
) : void 0;
|
|
23703
24482
|
const canUseTool = (request, signal) => waitForClaudeCodeToolApproval({
|
|
23704
24483
|
kandan: args.kandan,
|
|
23705
24484
|
topic: args.topic,
|
|
@@ -23712,89 +24491,58 @@ async function startClaudeCodeProviderInstance(args) {
|
|
|
23712
24491
|
request,
|
|
23713
24492
|
signal
|
|
23714
24493
|
});
|
|
23715
|
-
|
|
24494
|
+
let result;
|
|
24495
|
+
try {
|
|
23716
24496
|
try {
|
|
23717
|
-
|
|
23718
|
-
|
|
24497
|
+
result = await startClaudeCodeSession({
|
|
24498
|
+
cwd: args.cwd,
|
|
24499
|
+
prompt: workDescription,
|
|
24500
|
+
developerInstructions: commanderDeveloperInstructions({
|
|
23719
24501
|
cwd: args.cwd,
|
|
23720
|
-
|
|
23721
|
-
|
|
23722
|
-
|
|
23723
|
-
|
|
23724
|
-
|
|
23725
|
-
|
|
23726
|
-
|
|
23727
|
-
|
|
23728
|
-
|
|
23729
|
-
|
|
23730
|
-
|
|
23731
|
-
|
|
23732
|
-
|
|
23733
|
-
|
|
23734
|
-
|
|
23735
|
-
|
|
23736
|
-
|
|
23737
|
-
|
|
23738
|
-
|
|
23739
|
-
|
|
23740
|
-
|
|
23741
|
-
|
|
23742
|
-
|
|
23743
|
-
|
|
23744
|
-
|
|
23745
|
-
|
|
23746
|
-
|
|
23747
|
-
|
|
23748
|
-
|
|
23749
|
-
|
|
23750
|
-
claude_session_id: activeSessionId ?? null
|
|
23751
|
-
});
|
|
23752
|
-
}
|
|
23753
|
-
},
|
|
23754
|
-
onTranscriptEvent
|
|
23755
|
-
});
|
|
23756
|
-
} finally {
|
|
23757
|
-
inputQueue.close();
|
|
23758
|
-
if (activeSessionId !== void 0) {
|
|
23759
|
-
args.activeClaudeCodeSessions.delete(activeSessionId);
|
|
23760
|
-
await args.disposeClaudeCodeForwardPortSession?.(activeSessionId);
|
|
23761
|
-
}
|
|
23762
|
-
}
|
|
23763
|
-
} catch (error) {
|
|
23764
|
-
switch (isClaudeCodeOutputPostError(error)) {
|
|
23765
|
-
case true:
|
|
23766
|
-
args.setStartupStage("posting_claude_code_output");
|
|
23767
|
-
throw error;
|
|
23768
|
-
case false:
|
|
23769
|
-
switch (transcriptForwarder.startedSessionId()) {
|
|
23770
|
-
case void 0:
|
|
23771
|
-
throw error;
|
|
23772
|
-
default:
|
|
23773
|
-
args.setStartupStage("claude_code_session_failed");
|
|
23774
|
-
throw error;
|
|
23775
|
-
}
|
|
24502
|
+
agentLabel: "Claude Code",
|
|
24503
|
+
developerPrompt,
|
|
24504
|
+
linzumiContext
|
|
24505
|
+
}),
|
|
24506
|
+
model: claudeCodeModelForRuntimeModel(runtimeSettings.model),
|
|
24507
|
+
resumeSessionId: args.resumeSessionId,
|
|
24508
|
+
abortController,
|
|
24509
|
+
streamingInput: inputQueue,
|
|
24510
|
+
runner: args.options.claudeCodeRunner,
|
|
24511
|
+
canUseTool,
|
|
24512
|
+
...mcpServers === void 0 ? {} : { mcpServers },
|
|
24513
|
+
...sessionEnv === void 0 ? {} : { env: sessionEnv },
|
|
24514
|
+
// The built-in Linzumi MCP is trusted like the codex side: its tools
|
|
24515
|
+
// run without an approval round-trip. SDK allowedTools matches MCP
|
|
24516
|
+
// tools as mcp__<server>__<tool>; the __* suffix covers the server.
|
|
24517
|
+
allowedTools: ["mcp__linzumi__*"],
|
|
24518
|
+
onSessionControls: (controls) => {
|
|
24519
|
+
sessionControls = controls;
|
|
24520
|
+
},
|
|
24521
|
+
onTurnCompleted: () => {
|
|
24522
|
+
inputQueue.completeTurn();
|
|
24523
|
+
},
|
|
24524
|
+
onTranscriptEvent
|
|
24525
|
+
});
|
|
24526
|
+
} finally {
|
|
24527
|
+
inputQueue.close();
|
|
24528
|
+
mcpAuthCleanup?.();
|
|
24529
|
+
if (activeSessionId !== void 0) {
|
|
24530
|
+
args.activeClaudeCodeSessions.delete(activeSessionId);
|
|
24531
|
+
await args.disposeClaudeCodeForwardPortSession?.(activeSessionId);
|
|
23776
24532
|
}
|
|
23777
24533
|
}
|
|
23778
|
-
})();
|
|
23779
|
-
args.setStartupStage("posting_claude_code_output");
|
|
23780
|
-
try {
|
|
23781
|
-
await publishClaudeCodeMessageState(args.kandan, args.topic, {
|
|
23782
|
-
workspace,
|
|
23783
|
-
channel,
|
|
23784
|
-
threadId,
|
|
23785
|
-
sourceSeq: inputQueue.currentSourceSeq(),
|
|
23786
|
-
status: "processed",
|
|
23787
|
-
reason: "Claude Code completed",
|
|
23788
|
-
sessionId: result.sessionId
|
|
23789
|
-
});
|
|
23790
24534
|
} catch (error) {
|
|
23791
|
-
|
|
23792
|
-
|
|
23793
|
-
|
|
23794
|
-
|
|
23795
|
-
|
|
23796
|
-
|
|
24535
|
+
adapter.submitLifecycle(
|
|
24536
|
+
"codexDied",
|
|
24537
|
+
error instanceof Error ? error.message : String(error)
|
|
24538
|
+
);
|
|
24539
|
+
await adapter.close(5e3).catch(() => void 0);
|
|
24540
|
+
args.setStartupStage("claude_code_session_failed");
|
|
24541
|
+
throw error;
|
|
23797
24542
|
}
|
|
24543
|
+
args.setStartupStage("posting_claude_code_output");
|
|
24544
|
+
await adapter.awaitTurnsSettled(3e4);
|
|
24545
|
+
await adapter.close(3e4);
|
|
23798
24546
|
return {
|
|
23799
24547
|
controlResponse: {
|
|
23800
24548
|
instanceId: args.instanceId,
|
|
@@ -23814,268 +24562,27 @@ async function startClaudeCodeProviderInstance(args) {
|
|
|
23814
24562
|
}
|
|
23815
24563
|
};
|
|
23816
24564
|
}
|
|
23817
|
-
function
|
|
23818
|
-
|
|
23819
|
-
|
|
23820
|
-
|
|
23821
|
-
|
|
23822
|
-
|
|
23823
|
-
|
|
23824
|
-
|
|
23825
|
-
|
|
23826
|
-
|
|
23827
|
-
|
|
23828
|
-
|
|
23829
|
-
|
|
23830
|
-
|
|
23831
|
-
|
|
23832
|
-
|
|
23833
|
-
|
|
23834
|
-
|
|
23835
|
-
|
|
23836
|
-
|
|
23837
|
-
|
|
23838
|
-
assistantContent.set(itemKey, content);
|
|
23839
|
-
assistantStreamStates.set(itemKey, "streaming");
|
|
23840
|
-
assistantSourceSeqs.set(itemKey, delta.sourceSeq);
|
|
23841
|
-
},
|
|
23842
|
-
firstTurnId: (deltas) => deltas[0]?.turnId,
|
|
23843
|
-
logFailure: (turnId, error) => {
|
|
23844
|
-
args.log("claude_code.assistant_delta_forward_failed", {
|
|
23845
|
-
session_id: turnId ?? null,
|
|
23846
|
-
message: error instanceof Error ? error.message : String(error)
|
|
23847
|
-
});
|
|
23848
|
-
}
|
|
23849
|
-
};
|
|
23850
|
-
const flushClaudeAssistantDeltas = async () => {
|
|
23851
|
-
flushStreamDeltaQueue(assistantDeltaQueue, assistantDeltaRuntime);
|
|
23852
|
-
await assistantDeltaQueue.chain;
|
|
23853
|
-
};
|
|
23854
|
-
const forward = async (event) => {
|
|
23855
|
-
try {
|
|
23856
|
-
await mirrorClaudeSessionStoreAppend(args, event);
|
|
23857
|
-
} catch (error) {
|
|
23858
|
-
args.log("claude_code.session_store_mirror_failed", {
|
|
23859
|
-
session_id: claudeTranscriptSessionId(event) ?? null,
|
|
23860
|
-
event_type: event.type,
|
|
23861
|
-
message: error instanceof Error ? error.message : String(error)
|
|
23862
|
-
});
|
|
23863
|
-
}
|
|
23864
|
-
switch (event.type) {
|
|
23865
|
-
case "session_started":
|
|
23866
|
-
startedSessionId = event.sessionId;
|
|
23867
|
-
return;
|
|
23868
|
-
case "assistant_delta":
|
|
23869
|
-
enqueueStreamDelta(
|
|
23870
|
-
assistantDeltaQueue,
|
|
23871
|
-
{
|
|
23872
|
-
turnId: event.sessionId,
|
|
23873
|
-
sessionId: event.sessionId,
|
|
23874
|
-
itemKey: event.itemKey,
|
|
23875
|
-
sourceSeq: args.sourceSeq(),
|
|
23876
|
-
delta: event.delta
|
|
23877
|
-
},
|
|
23878
|
-
assistantDeltaRuntime
|
|
23879
|
-
);
|
|
23880
|
-
return;
|
|
23881
|
-
case "assistant_message":
|
|
23882
|
-
await flushClaudeAssistantDeltas();
|
|
23883
|
-
const sourceSeq = args.sourceSeq();
|
|
23884
|
-
const completedItemKey = claudeAssistantSourceItemKey(
|
|
23885
|
-
event.itemKey,
|
|
23886
|
-
sourceSeq
|
|
23887
|
-
);
|
|
23888
|
-
const matchingCompletedStreamEntries = event.streamState === "completed" ? claudeAssistantCompletedStreamItemKeys(
|
|
23889
|
-
event.itemKey,
|
|
23890
|
-
sourceSeq
|
|
23891
|
-
).flatMap(
|
|
23892
|
-
(itemKey) => assistantContent.get(itemKey) === event.content && assistantSourceSeqs.get(itemKey) === sourceSeq && (assistantStreamStates.get(itemKey) === "streaming" || assistantStreamStates.get(itemKey) === "completed") ? [[itemKey, assistantStreamStates.get(itemKey)]] : []
|
|
23893
|
-
) : [];
|
|
23894
|
-
const matchingStreamingEntries = matchingCompletedStreamEntries.filter(
|
|
23895
|
-
([_itemKey, streamState]) => streamState === "streaming"
|
|
23896
|
-
);
|
|
23897
|
-
if (matchingCompletedStreamEntries.length > 0) {
|
|
23898
|
-
for (const [itemKey] of matchingStreamingEntries) {
|
|
23899
|
-
await streamClaudeCodeStructuredMessage(args, event.sessionId, {
|
|
23900
|
-
itemKey,
|
|
23901
|
-
body: event.content,
|
|
23902
|
-
structured: claudeAssistantStructured(
|
|
23903
|
-
itemKey,
|
|
23904
|
-
event.content,
|
|
23905
|
-
"completed"
|
|
23906
|
-
)
|
|
23907
|
-
});
|
|
23908
|
-
assistantStreamStates.set(itemKey, "completed");
|
|
23909
|
-
}
|
|
23910
|
-
return;
|
|
23911
|
-
}
|
|
23912
|
-
await streamClaudeCodeStructuredMessage(args, event.sessionId, {
|
|
23913
|
-
itemKey: completedItemKey,
|
|
23914
|
-
body: event.content,
|
|
23915
|
-
structured: claudeAssistantStructured(
|
|
23916
|
-
completedItemKey,
|
|
23917
|
-
event.content,
|
|
23918
|
-
event.streamState
|
|
23919
|
-
)
|
|
23920
|
-
});
|
|
23921
|
-
assistantContent.set(completedItemKey, event.content);
|
|
23922
|
-
assistantStreamStates.set(completedItemKey, event.streamState);
|
|
23923
|
-
assistantSourceSeqs.set(completedItemKey, sourceSeq);
|
|
23924
|
-
return;
|
|
23925
|
-
case "tool_call":
|
|
23926
|
-
await flushClaudeAssistantDeltas();
|
|
23927
|
-
await postClaudeCodeStructuredMessage(args, event.sessionId, {
|
|
23928
|
-
itemKey: `tool:${event.itemKey}`,
|
|
23929
|
-
body: claudeToolCallBody(event.toolName, event.input),
|
|
23930
|
-
structured: claudeCommandStructured({
|
|
23931
|
-
itemKey: `tool:${event.itemKey}`,
|
|
23932
|
-
command: event.toolName,
|
|
23933
|
-
output: stableJsonString(event.input),
|
|
23934
|
-
status: "started"
|
|
23935
|
-
})
|
|
23936
|
-
});
|
|
23937
|
-
return;
|
|
23938
|
-
case "tool_result":
|
|
23939
|
-
await flushClaudeAssistantDeltas();
|
|
23940
|
-
await postClaudeCodeStructuredMessage(args, event.sessionId, {
|
|
23941
|
-
itemKey: `tool-result:${event.itemKey}`,
|
|
23942
|
-
body: event.content,
|
|
23943
|
-
structured: claudeCommandStructured({
|
|
23944
|
-
itemKey: `tool-result:${event.itemKey}`,
|
|
23945
|
-
command: event.toolName ?? "tool result",
|
|
23946
|
-
output: event.content,
|
|
23947
|
-
status: event.isError ? "failed" : "completed"
|
|
23948
|
-
})
|
|
23949
|
-
});
|
|
23950
|
-
return;
|
|
23951
|
-
case "command_output":
|
|
23952
|
-
await flushClaudeAssistantDeltas();
|
|
23953
|
-
await postClaudeCodeStructuredMessage(args, event.sessionId, {
|
|
23954
|
-
itemKey: `command-output:${event.itemKey}`,
|
|
23955
|
-
body: event.content,
|
|
23956
|
-
structured: claudeCommandStructured({
|
|
23957
|
-
itemKey: `command-output:${event.itemKey}`,
|
|
23958
|
-
command: "Claude Code local command",
|
|
23959
|
-
output: event.content,
|
|
23960
|
-
status: "completed"
|
|
23961
|
-
})
|
|
23962
|
-
});
|
|
23963
|
-
return;
|
|
23964
|
-
case "file_change":
|
|
23965
|
-
await flushClaudeAssistantDeltas();
|
|
23966
|
-
await postClaudeCodeStructuredMessage(args, event.sessionId, {
|
|
23967
|
-
itemKey: event.itemKey,
|
|
23968
|
-
body: event.summary,
|
|
23969
|
-
structured: {
|
|
23970
|
-
kind: "codex_file_change",
|
|
23971
|
-
item_id: event.itemKey,
|
|
23972
|
-
transcript_unit_id: `claude_file_change:${event.itemKey}`,
|
|
23973
|
-
agent_provider: "claude-code",
|
|
23974
|
-
stream_state: "completed",
|
|
23975
|
-
status: "started",
|
|
23976
|
-
patch_text: event.summary,
|
|
23977
|
-
changes: event.path === void 0 ? [] : [{ path: event.path, diff: event.summary, kind: "modified" }]
|
|
23978
|
-
}
|
|
23979
|
-
});
|
|
23980
|
-
return;
|
|
23981
|
-
case "usage":
|
|
23982
|
-
return;
|
|
23983
|
-
case "unknown":
|
|
23984
|
-
await flushClaudeAssistantDeltas();
|
|
23985
|
-
await postClaudeCodeStructuredMessage(
|
|
23986
|
-
args,
|
|
23987
|
-
event.sessionId ?? "unknown",
|
|
23988
|
-
{
|
|
23989
|
-
itemKey: event.itemKey,
|
|
23990
|
-
body: event.summary,
|
|
23991
|
-
structured: {
|
|
23992
|
-
kind: "codex_reasoning",
|
|
23993
|
-
item_id: event.itemKey,
|
|
23994
|
-
transcript_unit_id: `claude_unknown:${event.itemKey}`,
|
|
23995
|
-
agent_provider: "claude-code",
|
|
23996
|
-
stream_state: "completed",
|
|
23997
|
-
content: event.summary,
|
|
23998
|
-
summary_parts: []
|
|
23999
|
-
}
|
|
24000
|
-
}
|
|
24001
|
-
);
|
|
24002
|
-
return;
|
|
24003
|
-
case "session_failed":
|
|
24004
|
-
await flushClaudeAssistantDeltas();
|
|
24005
|
-
await postClaudeCodeStructuredMessage(
|
|
24006
|
-
args,
|
|
24007
|
-
event.sessionId ?? "unknown",
|
|
24008
|
-
{
|
|
24009
|
-
itemKey: `session-failed:${event.sessionId ?? "unknown"}`,
|
|
24010
|
-
body: event.reason,
|
|
24011
|
-
structured: {
|
|
24012
|
-
kind: "codex_reasoning",
|
|
24013
|
-
item_id: `session-failed:${event.sessionId ?? "unknown"}`,
|
|
24014
|
-
transcript_unit_id: `claude_session_failed:${event.sessionId ?? "unknown"}`,
|
|
24015
|
-
agent_provider: "claude-code",
|
|
24016
|
-
stream_state: "completed",
|
|
24017
|
-
content: event.reason,
|
|
24018
|
-
summary_parts: []
|
|
24019
|
-
}
|
|
24020
|
-
}
|
|
24021
|
-
);
|
|
24022
|
-
return;
|
|
24023
|
-
case "turn_completed":
|
|
24024
|
-
case "session_completed": {
|
|
24025
|
-
await flushClaudeAssistantDeltas();
|
|
24026
|
-
const sourceSeq2 = args.sourceSeq();
|
|
24027
|
-
const duplicateEntries = Array.from(assistantContent.entries()).flatMap(
|
|
24028
|
-
([itemKey2, content]) => {
|
|
24029
|
-
const streamState = assistantStreamStates.get(itemKey2);
|
|
24030
|
-
const entrySourceSeq = assistantSourceSeqs.get(itemKey2);
|
|
24031
|
-
if (content === event.body && entrySourceSeq === sourceSeq2 && (streamState === "streaming" || streamState === "completed")) {
|
|
24032
|
-
return [[itemKey2, streamState]];
|
|
24033
|
-
}
|
|
24034
|
-
return [];
|
|
24035
|
-
}
|
|
24036
|
-
);
|
|
24037
|
-
const streamingDuplicateEntries = duplicateEntries.filter(
|
|
24038
|
-
([_itemKey, streamState]) => streamState === "streaming"
|
|
24039
|
-
);
|
|
24040
|
-
if (duplicateEntries.length > 0) {
|
|
24041
|
-
for (const [itemKey2] of streamingDuplicateEntries) {
|
|
24042
|
-
await streamClaudeCodeStructuredMessage(args, event.sessionId, {
|
|
24043
|
-
itemKey: itemKey2,
|
|
24044
|
-
body: event.body,
|
|
24045
|
-
structured: claudeAssistantStructured(
|
|
24046
|
-
itemKey2,
|
|
24047
|
-
event.body,
|
|
24048
|
-
"completed"
|
|
24049
|
-
)
|
|
24050
|
-
});
|
|
24051
|
-
assistantStreamStates.set(itemKey2, "completed");
|
|
24052
|
-
}
|
|
24053
|
-
return;
|
|
24054
|
-
}
|
|
24055
|
-
const itemKey = sourceSeq2 === void 0 ? `result:${event.sessionId}` : `result:${event.sessionId}:source:${sourceSeq2}`;
|
|
24056
|
-
if (assistantContent.get(itemKey) === event.body && assistantStreamStates.get(itemKey) === "completed") {
|
|
24057
|
-
return;
|
|
24058
|
-
}
|
|
24059
|
-
await streamClaudeCodeStructuredMessage(args, event.sessionId, {
|
|
24060
|
-
itemKey,
|
|
24061
|
-
body: event.body,
|
|
24062
|
-
structured: claudeAssistantStructured(
|
|
24063
|
-
itemKey,
|
|
24064
|
-
event.body,
|
|
24065
|
-
"completed"
|
|
24066
|
-
)
|
|
24067
|
-
});
|
|
24068
|
-
assistantContent.set(itemKey, event.body);
|
|
24069
|
-
assistantStreamStates.set(itemKey, "completed");
|
|
24070
|
-
assistantSourceSeqs.set(itemKey, sourceSeq2);
|
|
24071
|
-
return;
|
|
24072
|
-
}
|
|
24073
|
-
}
|
|
24074
|
-
};
|
|
24075
|
-
return {
|
|
24076
|
-
forward,
|
|
24077
|
-
startedSessionId: () => startedSessionId
|
|
24078
|
-
};
|
|
24565
|
+
function claudePermissionModeForApprovalPolicy(approvalPolicy) {
|
|
24566
|
+
switch (approvalPolicy) {
|
|
24567
|
+
case "never":
|
|
24568
|
+
return "bypassPermissions";
|
|
24569
|
+
case "on-request":
|
|
24570
|
+
case "untrusted":
|
|
24571
|
+
return "default";
|
|
24572
|
+
case "on-failure":
|
|
24573
|
+
return "acceptEdits";
|
|
24574
|
+
default:
|
|
24575
|
+
return void 0;
|
|
24576
|
+
}
|
|
24577
|
+
}
|
|
24578
|
+
function claudeSteerInputText(input) {
|
|
24579
|
+
const items = arrayValue(input) ?? [];
|
|
24580
|
+
const text2 = items.flatMap((item) => {
|
|
24581
|
+
const value = objectValue(item);
|
|
24582
|
+
const itemText = stringValue(value?.text) ?? stringValue(value?.content);
|
|
24583
|
+
return itemText === void 0 ? [] : [itemText];
|
|
24584
|
+
}).join("\n\n").trim();
|
|
24585
|
+
return text2 === "" ? void 0 : text2;
|
|
24079
24586
|
}
|
|
24080
24587
|
async function mirrorClaudeSessionStoreAppend(args, event) {
|
|
24081
24588
|
const sessionId = claudeTranscriptSessionId(event);
|
|
@@ -24147,16 +24654,17 @@ function claudeSessionStoreEntryPayload(args, event) {
|
|
|
24147
24654
|
body: event.content,
|
|
24148
24655
|
isError: event.isError
|
|
24149
24656
|
};
|
|
24150
|
-
case "
|
|
24657
|
+
case "reasoning_delta":
|
|
24658
|
+
return void 0;
|
|
24659
|
+
case "reasoning_message":
|
|
24151
24660
|
return {
|
|
24152
24661
|
itemKey: event.itemKey,
|
|
24153
24662
|
body: event.content
|
|
24154
24663
|
};
|
|
24155
|
-
case "
|
|
24664
|
+
case "command_output":
|
|
24156
24665
|
return {
|
|
24157
24666
|
itemKey: event.itemKey,
|
|
24158
|
-
|
|
24159
|
-
body: event.summary
|
|
24667
|
+
body: event.content
|
|
24160
24668
|
};
|
|
24161
24669
|
case "usage":
|
|
24162
24670
|
return { usage: event.usage };
|
|
@@ -24171,210 +24679,48 @@ function claudeSessionStoreEntryPayload(args, event) {
|
|
|
24171
24679
|
body: event.body,
|
|
24172
24680
|
usage: event.usage ?? null
|
|
24173
24681
|
};
|
|
24682
|
+
case "turn_interrupted":
|
|
24683
|
+
return { body: "Claude Code turn interrupted" };
|
|
24174
24684
|
case "session_failed":
|
|
24175
24685
|
return { body: event.reason };
|
|
24176
24686
|
}
|
|
24177
24687
|
}
|
|
24178
|
-
function
|
|
24179
|
-
const
|
|
24180
|
-
const
|
|
24181
|
-
|
|
24182
|
-
|
|
24183
|
-
|
|
24184
|
-
if (
|
|
24185
|
-
|
|
24186
|
-
byKey.set(key, delta);
|
|
24187
|
-
} else {
|
|
24188
|
-
byKey.set(key, {
|
|
24189
|
-
...existing,
|
|
24190
|
-
delta: `${existing.delta}${delta.delta}`
|
|
24191
|
-
});
|
|
24688
|
+
function claudeCodeLlmProxyEnv(baseEnv, proxy, model) {
|
|
24689
|
+
const env = {};
|
|
24690
|
+
for (const [key, value] of Object.entries(baseEnv)) {
|
|
24691
|
+
if (value === void 0) {
|
|
24692
|
+
continue;
|
|
24693
|
+
}
|
|
24694
|
+
if (key === "ANTHROPIC_BASE_URL" || key === "ANTHROPIC_CUSTOM_HEADERS" || key.startsWith("CLAUDE_CODE_USE_")) {
|
|
24695
|
+
continue;
|
|
24192
24696
|
}
|
|
24697
|
+
env[key] = value;
|
|
24193
24698
|
}
|
|
24194
|
-
|
|
24195
|
-
|
|
24196
|
-
|
|
24197
|
-
|
|
24198
|
-
|
|
24199
|
-
|
|
24200
|
-
|
|
24201
|
-
|
|
24202
|
-
function claudeAssistantCompletedStreamItemKeys(completedItemKey, sourceSeq) {
|
|
24203
|
-
const directItemKey = claudeAssistantSourceItemKey(
|
|
24204
|
-
completedItemKey,
|
|
24205
|
-
sourceSeq
|
|
24206
|
-
);
|
|
24207
|
-
const fallbackIndex = completedItemKey.match(/^content-block-(\d+)$/)?.[1];
|
|
24208
|
-
const streamingItemKey = fallbackIndex === void 0 ? directItemKey : claudeAssistantSourceItemKey(
|
|
24209
|
-
`assistant-stream-${fallbackIndex}`,
|
|
24210
|
-
sourceSeq
|
|
24211
|
-
);
|
|
24212
|
-
return directItemKey === streamingItemKey ? [directItemKey] : [directItemKey, streamingItemKey];
|
|
24213
|
-
}
|
|
24214
|
-
async function streamClaudeCodeStructuredMessage(args, sessionId, message) {
|
|
24215
|
-
try {
|
|
24216
|
-
const streamKey = claudeCodeStreamKey(sessionId, message.itemKey);
|
|
24217
|
-
const uploadedFileIds = stringValue(message.structured.stream_state) === "completed" ? await uploadedFileIdsForCommanderOutput(
|
|
24218
|
-
{
|
|
24219
|
-
kandan: args.kandan,
|
|
24220
|
-
topic: args.topic,
|
|
24221
|
-
workspace: args.workspace,
|
|
24222
|
-
channel: args.channel,
|
|
24223
|
-
cwd: args.cwd,
|
|
24224
|
-
kandanUrl: args.options.kandanUrl,
|
|
24225
|
-
token: args.options.token,
|
|
24226
|
-
fetch: args.options.fetch
|
|
24227
|
-
},
|
|
24228
|
-
message.body,
|
|
24229
|
-
message.structured
|
|
24230
|
-
) : [];
|
|
24231
|
-
const displayBody = displayBodyForCommanderOutput(
|
|
24232
|
-
message.body,
|
|
24233
|
-
uploadedFileIds
|
|
24234
|
-
);
|
|
24235
|
-
const displayStructured = structuredWithAssistantContent(
|
|
24236
|
-
message.structured,
|
|
24237
|
-
displayBody
|
|
24238
|
-
);
|
|
24239
|
-
await args.kandan.push(args.topic, "session:stream_thread_message", {
|
|
24240
|
-
workspace: args.workspace,
|
|
24241
|
-
channel: args.channel,
|
|
24242
|
-
thread_id: args.threadId,
|
|
24243
|
-
stream_key: streamKey,
|
|
24244
|
-
body: displayBody,
|
|
24245
|
-
payload: claudeCodePayload(
|
|
24246
|
-
{ ...args, sourceSeq: args.sourceSeq() },
|
|
24247
|
-
sessionId,
|
|
24248
|
-
displayStructured
|
|
24249
|
-
),
|
|
24250
|
-
...uploadedFileIds.length === 0 ? {} : { uploaded_file_ids: uploadedFileIds },
|
|
24251
|
-
client_message_id: streamKey
|
|
24252
|
-
});
|
|
24253
|
-
} catch (error) {
|
|
24254
|
-
throw new ClaudeCodeOutputPostError(error);
|
|
24699
|
+
env.ANTHROPIC_BASE_URL = proxy.baseUrl;
|
|
24700
|
+
env.ANTHROPIC_CUSTOM_HEADERS = `${claudeCodeLlmProxySessionHeader}: ${proxy.token}`;
|
|
24701
|
+
const routedModel = claudeCodeRoutedProxyModel(model);
|
|
24702
|
+
if (routedModel !== void 0) {
|
|
24703
|
+
env.ANTHROPIC_DEFAULT_OPUS_MODEL = routedModel;
|
|
24704
|
+
env.ANTHROPIC_DEFAULT_SONNET_MODEL = routedModel;
|
|
24705
|
+
env.ANTHROPIC_DEFAULT_HAIKU_MODEL = routedModel;
|
|
24706
|
+
env.CLAUDE_CODE_SUBAGENT_MODEL = routedModel;
|
|
24255
24707
|
}
|
|
24708
|
+
return env;
|
|
24256
24709
|
}
|
|
24257
|
-
|
|
24258
|
-
|
|
24259
|
-
|
|
24260
|
-
|
|
24261
|
-
|
|
24262
|
-
|
|
24263
|
-
|
|
24264
|
-
|
|
24265
|
-
|
|
24266
|
-
|
|
24267
|
-
|
|
24268
|
-
|
|
24269
|
-
},
|
|
24270
|
-
message.body,
|
|
24271
|
-
message.structured
|
|
24272
|
-
);
|
|
24273
|
-
const displayBody = displayBodyForCommanderOutput(
|
|
24274
|
-
message.body,
|
|
24275
|
-
uploadedFileIds
|
|
24276
|
-
);
|
|
24277
|
-
const displayStructured = structuredWithAssistantContent(
|
|
24278
|
-
message.structured,
|
|
24279
|
-
displayBody
|
|
24280
|
-
);
|
|
24281
|
-
await args.kandan.push(args.topic, "session:post_thread_message", {
|
|
24282
|
-
workspace: args.workspace,
|
|
24283
|
-
channel: args.channel,
|
|
24284
|
-
thread_id: args.threadId,
|
|
24285
|
-
body: displayBody,
|
|
24286
|
-
payload: claudeCodePayload(
|
|
24287
|
-
{ ...args, sourceSeq: args.sourceSeq() },
|
|
24288
|
-
sessionId,
|
|
24289
|
-
displayStructured
|
|
24290
|
-
),
|
|
24291
|
-
...uploadedFileIds.length === 0 ? {} : { uploaded_file_ids: uploadedFileIds },
|
|
24292
|
-
client_message_id: claudeCodeMessageClientId(
|
|
24293
|
-
args,
|
|
24294
|
-
sessionId,
|
|
24295
|
-
message.itemKey
|
|
24296
|
-
)
|
|
24297
|
-
});
|
|
24298
|
-
} catch (error) {
|
|
24299
|
-
throw new ClaudeCodeOutputPostError(error);
|
|
24710
|
+
function claudeCodeRoutedProxyModel(model) {
|
|
24711
|
+
const trimmed = model?.trim();
|
|
24712
|
+
switch (trimmed) {
|
|
24713
|
+
case void 0:
|
|
24714
|
+
case "":
|
|
24715
|
+
case "default":
|
|
24716
|
+
case "haiku":
|
|
24717
|
+
case "sonnet":
|
|
24718
|
+
case "opus":
|
|
24719
|
+
return void 0;
|
|
24720
|
+
default:
|
|
24721
|
+
return trimmed.startsWith("claude") ? void 0 : trimmed;
|
|
24300
24722
|
}
|
|
24301
24723
|
}
|
|
24302
|
-
function claudeCodeMessageClientId(args, sessionId, itemKey) {
|
|
24303
|
-
const sourceSeq = args.sourceSeq();
|
|
24304
|
-
const replyKey = sourceSeq === void 0 ? args.rootSeq === void 0 ? "source:none" : `root:${args.rootSeq}` : `source:${sourceSeq}`;
|
|
24305
|
-
return boundedClaudeCodeClientId(
|
|
24306
|
-
`claude-code:${sessionId}:${replyKey}:${args.threadId}:${itemKey}`,
|
|
24307
|
-
"claude-code-message"
|
|
24308
|
-
);
|
|
24309
|
-
}
|
|
24310
|
-
function claudeCodeStreamKey(sessionId, itemKey) {
|
|
24311
|
-
return boundedClaudeCodeClientId(
|
|
24312
|
-
`claude-code:${sessionId}:${itemKey}`,
|
|
24313
|
-
"claude-code-stream"
|
|
24314
|
-
);
|
|
24315
|
-
}
|
|
24316
|
-
function boundedClaudeCodeClientId(candidate, prefix) {
|
|
24317
|
-
return candidate.length <= 128 ? candidate : `${prefix}-${createHash5("sha256").update(candidate).digest("hex").slice(0, 32)}`;
|
|
24318
|
-
}
|
|
24319
|
-
function isClaudeCodeOutputPostError(error) {
|
|
24320
|
-
return error instanceof ClaudeCodeOutputPostError;
|
|
24321
|
-
}
|
|
24322
|
-
function claudeCodePayload(args, sessionId, structured) {
|
|
24323
|
-
return {
|
|
24324
|
-
...localRunnerPayload(
|
|
24325
|
-
{ ...args.options, cwd: args.cwd },
|
|
24326
|
-
args.instanceId,
|
|
24327
|
-
"codex_output",
|
|
24328
|
-
sessionId,
|
|
24329
|
-
{
|
|
24330
|
-
runnerIdentity: identityFromAccessToken(args.options.token),
|
|
24331
|
-
codexVersion: void 0
|
|
24332
|
-
},
|
|
24333
|
-
args.sourceSeq,
|
|
24334
|
-
{
|
|
24335
|
-
agent_provider: "claude-code",
|
|
24336
|
-
claude_session_id: sessionId
|
|
24337
|
-
}
|
|
24338
|
-
),
|
|
24339
|
-
...args.rootSeq === void 0 ? {} : { reply_to_seq: args.rootSeq },
|
|
24340
|
-
structured
|
|
24341
|
-
};
|
|
24342
|
-
}
|
|
24343
|
-
function claudeAssistantStructured(itemKey, content, streamState) {
|
|
24344
|
-
return {
|
|
24345
|
-
kind: "codex_assistant_message",
|
|
24346
|
-
item_id: itemKey,
|
|
24347
|
-
transcript_unit_id: `claude_assistant:${itemKey}`,
|
|
24348
|
-
agent_provider: "claude-code",
|
|
24349
|
-
content,
|
|
24350
|
-
phase: "final_answer",
|
|
24351
|
-
stream_state: streamState
|
|
24352
|
-
};
|
|
24353
|
-
}
|
|
24354
|
-
function claudeCommandStructured(args) {
|
|
24355
|
-
return {
|
|
24356
|
-
kind: "codex_command_execution",
|
|
24357
|
-
item_id: args.itemKey,
|
|
24358
|
-
transcript_unit_id: `claude_command:${args.itemKey}`,
|
|
24359
|
-
agent_provider: "claude-code",
|
|
24360
|
-
stream_state: "completed",
|
|
24361
|
-
status: args.status,
|
|
24362
|
-
command: args.command,
|
|
24363
|
-
cwd: "",
|
|
24364
|
-
process_id: "",
|
|
24365
|
-
duration_ms: null,
|
|
24366
|
-
exit_code: null,
|
|
24367
|
-
output: args.output
|
|
24368
|
-
};
|
|
24369
|
-
}
|
|
24370
|
-
function claudeToolCallBody(toolName2, input) {
|
|
24371
|
-
return `Claude Code tool: ${toolName2}
|
|
24372
|
-
|
|
24373
|
-
${stableJsonString(input)}`;
|
|
24374
|
-
}
|
|
24375
|
-
function stableJsonString(value) {
|
|
24376
|
-
return JSON.stringify(value, null, 2);
|
|
24377
|
-
}
|
|
24378
24724
|
function claudeCodeModelForRuntimeModel(model) {
|
|
24379
24725
|
const trimmed = model?.trim();
|
|
24380
24726
|
switch (trimmed) {
|
|
@@ -24575,14 +24921,14 @@ function strictTcpPortFromEnv(rawValue, envName) {
|
|
|
24575
24921
|
return port;
|
|
24576
24922
|
}
|
|
24577
24923
|
function listenOnLoopback(server, port) {
|
|
24578
|
-
return new Promise((
|
|
24924
|
+
return new Promise((resolve12, reject) => {
|
|
24579
24925
|
const onError = (error) => {
|
|
24580
24926
|
server.off("listening", onListening);
|
|
24581
24927
|
reject(error);
|
|
24582
24928
|
};
|
|
24583
24929
|
const onListening = () => {
|
|
24584
24930
|
server.off("error", onError);
|
|
24585
|
-
|
|
24931
|
+
resolve12();
|
|
24586
24932
|
};
|
|
24587
24933
|
server.once("error", onError);
|
|
24588
24934
|
server.once("listening", onListening);
|
|
@@ -24593,13 +24939,13 @@ function closeHttpServer(server) {
|
|
|
24593
24939
|
if (!server.listening) {
|
|
24594
24940
|
return Promise.resolve();
|
|
24595
24941
|
}
|
|
24596
|
-
return new Promise((
|
|
24942
|
+
return new Promise((resolve12, reject) => {
|
|
24597
24943
|
server.close((error) => {
|
|
24598
24944
|
if (error !== void 0) {
|
|
24599
24945
|
reject(error);
|
|
24600
24946
|
return;
|
|
24601
24947
|
}
|
|
24602
|
-
|
|
24948
|
+
resolve12();
|
|
24603
24949
|
});
|
|
24604
24950
|
});
|
|
24605
24951
|
}
|
|
@@ -24659,6 +25005,7 @@ function threadRunnerOptions(args) {
|
|
|
24659
25005
|
args.options,
|
|
24660
25006
|
args.control
|
|
24661
25007
|
);
|
|
25008
|
+
const waferResolution = resolveControlWaferModelProvider(args.control);
|
|
24662
25009
|
return {
|
|
24663
25010
|
...args.options,
|
|
24664
25011
|
clientId: void 0,
|
|
@@ -24675,6 +25022,7 @@ function threadRunnerOptions(args) {
|
|
|
24675
25022
|
role: "thread",
|
|
24676
25023
|
kandanThreadId: args.kandanThreadId
|
|
24677
25024
|
},
|
|
25025
|
+
codexModelProvider: waferResolution.type === "wafer" ? waferResolution.runtime : void 0,
|
|
24678
25026
|
spawnThreadRunner: void 0,
|
|
24679
25027
|
threadRunnerReadyTimeoutMs: args.options.threadRunnerReadyTimeoutMs,
|
|
24680
25028
|
runtimeDefaults: {
|
|
@@ -24715,7 +25063,10 @@ async function spawnLocalThreadRunnerProcess(options) {
|
|
|
24715
25063
|
...process.env,
|
|
24716
25064
|
LINZUMI_THREAD_RUNNER_ROLE: "thread",
|
|
24717
25065
|
LINZUMI_THREAD_RUNNER_KANDAN_THREAD_ID: kandanThreadId,
|
|
24718
|
-
LINZUMI_THREAD_RUNNER_TOKEN: options.token
|
|
25066
|
+
LINZUMI_THREAD_RUNNER_TOKEN: options.token,
|
|
25067
|
+
// The LLM proxy credential travels via env (like the runner token), not
|
|
25068
|
+
// argv, so the spawned worker's command line never carries it.
|
|
25069
|
+
...options.codexModelProvider === void 0 ? {} : { LINZUMI_LLM_PROXY_TOKEN: options.codexModelProvider.llmProxyToken }
|
|
24719
25070
|
};
|
|
24720
25071
|
writeCliAuditEvent("process.spawn", {
|
|
24721
25072
|
command: process.execPath,
|
|
@@ -24753,7 +25104,7 @@ async function spawnLocalThreadRunnerProcess(options) {
|
|
|
24753
25104
|
}
|
|
24754
25105
|
exitListeners.clear();
|
|
24755
25106
|
});
|
|
24756
|
-
const ready2 = await new Promise((
|
|
25107
|
+
const ready2 = await new Promise((resolve12, reject) => {
|
|
24757
25108
|
let settled = false;
|
|
24758
25109
|
let timeout;
|
|
24759
25110
|
const cleanupReadyListeners = () => {
|
|
@@ -24785,7 +25136,7 @@ async function spawnLocalThreadRunnerProcess(options) {
|
|
|
24785
25136
|
if (parsed === void 0) {
|
|
24786
25137
|
return;
|
|
24787
25138
|
}
|
|
24788
|
-
settle(() =>
|
|
25139
|
+
settle(() => resolve12(parsed));
|
|
24789
25140
|
};
|
|
24790
25141
|
const onExitBeforeReady = (code, signal) => {
|
|
24791
25142
|
settle(
|
|
@@ -24838,7 +25189,7 @@ function threadRunnerScriptPath(scriptPath, cwd) {
|
|
|
24838
25189
|
"cannot fork thread runner without current CLI script path"
|
|
24839
25190
|
);
|
|
24840
25191
|
}
|
|
24841
|
-
return
|
|
25192
|
+
return isAbsolute5(scriptPath) ? scriptPath : resolve8(cwd, scriptPath);
|
|
24842
25193
|
}
|
|
24843
25194
|
function threadRunnerLoaderExecArgv(execArgv, index = 0) {
|
|
24844
25195
|
const current = execArgv[index];
|
|
@@ -24931,13 +25282,13 @@ function providerKindValue(value) {
|
|
|
24931
25282
|
}
|
|
24932
25283
|
}
|
|
24933
25284
|
function waitForThreadCodexWorkerStop(codexProcess) {
|
|
24934
|
-
return new Promise((
|
|
25285
|
+
return new Promise((resolve12) => {
|
|
24935
25286
|
const stop = once(() => {
|
|
24936
25287
|
process.off("disconnect", stop);
|
|
24937
25288
|
process.off("SIGINT", stop);
|
|
24938
25289
|
process.off("SIGTERM", stop);
|
|
24939
25290
|
codexProcess.off("exit", stop);
|
|
24940
|
-
|
|
25291
|
+
resolve12();
|
|
24941
25292
|
});
|
|
24942
25293
|
process.once("disconnect", stop);
|
|
24943
25294
|
process.once("SIGINT", stop);
|
|
@@ -24946,7 +25297,7 @@ function waitForThreadCodexWorkerStop(codexProcess) {
|
|
|
24946
25297
|
});
|
|
24947
25298
|
}
|
|
24948
25299
|
function withThreadRunnerReadyTimeout(promise, args) {
|
|
24949
|
-
return new Promise((
|
|
25300
|
+
return new Promise((resolve12, reject) => {
|
|
24950
25301
|
let settled = false;
|
|
24951
25302
|
const timeout = setTimeout(() => {
|
|
24952
25303
|
if (settled) {
|
|
@@ -24964,7 +25315,7 @@ function withThreadRunnerReadyTimeout(promise, args) {
|
|
|
24964
25315
|
}
|
|
24965
25316
|
settled = true;
|
|
24966
25317
|
clearTimeout(timeout);
|
|
24967
|
-
|
|
25318
|
+
resolve12(handle);
|
|
24968
25319
|
},
|
|
24969
25320
|
(error) => {
|
|
24970
25321
|
if (settled) {
|
|
@@ -25016,6 +25367,12 @@ function threadRunnerCliArgs(options) {
|
|
|
25016
25367
|
"--approval-policy",
|
|
25017
25368
|
options.runtimeDefaults?.approvalPolicy
|
|
25018
25369
|
),
|
|
25370
|
+
...options.codexModelProvider === void 0 ? [] : [
|
|
25371
|
+
"--model-provider",
|
|
25372
|
+
options.codexModelProvider.provider,
|
|
25373
|
+
"--llm-proxy-base-url",
|
|
25374
|
+
options.codexModelProvider.llmProxyBaseUrl
|
|
25375
|
+
],
|
|
25019
25376
|
"--allow-port-forwarding-by-default"
|
|
25020
25377
|
];
|
|
25021
25378
|
}
|
|
@@ -25582,7 +25939,7 @@ async function localConversationAttachmentFile(candidatePath, attachment) {
|
|
|
25582
25939
|
};
|
|
25583
25940
|
}
|
|
25584
25941
|
case "path": {
|
|
25585
|
-
const path2 =
|
|
25942
|
+
const path2 = isAbsolute5(attachment.path) ? attachment.path : resolve8(dirname13(candidatePath), attachment.path);
|
|
25586
25943
|
try {
|
|
25587
25944
|
const bytes = await readFile2(path2);
|
|
25588
25945
|
return {
|
|
@@ -25910,6 +26267,17 @@ async function startOwnedCodexAppServer(options, args = { linzumiMcp: true }) {
|
|
|
25910
26267
|
model: defaults.model,
|
|
25911
26268
|
reasoningEffort: defaults.reasoningEffort,
|
|
25912
26269
|
fast: options.fast,
|
|
26270
|
+
// Wafer-routed thread workers point their owned app-server at the
|
|
26271
|
+
// Kandan LLM proxy via a custom Linzumi model provider; the proxy
|
|
26272
|
+
// credential rides env_key plus the session header.
|
|
26273
|
+
...options.codexModelProvider === void 0 ? {} : {
|
|
26274
|
+
modelProvider: linzumiCodexModelProviderConfig(
|
|
26275
|
+
options.codexModelProvider
|
|
26276
|
+
),
|
|
26277
|
+
env: {
|
|
26278
|
+
LINZUMI_LLM_PROXY_TOKEN: options.codexModelProvider.llmProxyToken
|
|
26279
|
+
}
|
|
26280
|
+
},
|
|
25913
26281
|
mcpServers: mcpAuth === void 0 ? [] : [
|
|
25914
26282
|
linzumiMcpServerConfig({
|
|
25915
26283
|
command: mcpCommand.command,
|
|
@@ -26031,7 +26399,7 @@ function configuredAllowedCwds(values, options = {}) {
|
|
|
26031
26399
|
const allowedCwds = [];
|
|
26032
26400
|
const missingAllowedCwds = [];
|
|
26033
26401
|
for (const value of normalizeAllowedCwds(values)) {
|
|
26034
|
-
const absolutePath =
|
|
26402
|
+
const absolutePath = resolve8(expandUserPath(value));
|
|
26035
26403
|
try {
|
|
26036
26404
|
if (options.createMissing === true) {
|
|
26037
26405
|
mkdirSync11(absolutePath, { recursive: true });
|
|
@@ -26083,7 +26451,7 @@ function browseRunnerDirectory(control, options) {
|
|
|
26083
26451
|
const requestId = stringValue(control.requestId) ?? null;
|
|
26084
26452
|
const requestedPath = stringValue(control.path) ?? currentHomeDirectory();
|
|
26085
26453
|
try {
|
|
26086
|
-
const currentPath = realpathSync6(
|
|
26454
|
+
const currentPath = realpathSync6(resolve8(expandUserPath(requestedPath)));
|
|
26087
26455
|
const stats = statSync3(currentPath);
|
|
26088
26456
|
if (!stats.isDirectory()) {
|
|
26089
26457
|
return {
|
|
@@ -26113,7 +26481,7 @@ function browseRunnerDirectory(control, options) {
|
|
|
26113
26481
|
currentPath,
|
|
26114
26482
|
parentPath: parent === currentPath ? null : parent,
|
|
26115
26483
|
homePath: currentHomeDirectory(),
|
|
26116
|
-
runnerCwd:
|
|
26484
|
+
runnerCwd: resolve8(options.cwd),
|
|
26117
26485
|
entries,
|
|
26118
26486
|
isGit: isGitProjectDirectory(currentPath)
|
|
26119
26487
|
};
|
|
@@ -26298,13 +26666,14 @@ async function suggestRunnerTasks(control, options, allowedCwds) {
|
|
|
26298
26666
|
};
|
|
26299
26667
|
}
|
|
26300
26668
|
}
|
|
26301
|
-
var THREAD_RUNNER_READY_TIMEOUT_MS, onboardingDiscoveryAgentStartKeys, onboardingConversationImportKeys, onboardingConversationDiscoveryReportLimit, controlCursorWriteDebounceMs, codexTurnTerminalNotificationMethods, claudeSessionStoreSequenceHighWater,
|
|
26669
|
+
var THREAD_RUNNER_READY_TIMEOUT_MS, onboardingDiscoveryAgentStartKeys, onboardingConversationImportKeys, onboardingConversationDiscoveryReportLimit, controlCursorWriteDebounceMs, codexTurnTerminalNotificationMethods, claudeSessionStoreSequenceHighWater, claudeCodeLlmProxySessionHeader, onboardingConversationTitleFirstMessages, onboardingConversationTitleLastMessages, onboardingConversationTitleBodyMaxLength, onboardingConversationImportMessageMaxLength, onboardingConversationImportCandidateLimit, onboardingConversationImportProgressInterval;
|
|
26302
26670
|
var init_runner = __esm({
|
|
26303
26671
|
"src/runner.ts"() {
|
|
26304
26672
|
"use strict";
|
|
26305
26673
|
init_channelSession();
|
|
26306
26674
|
init_channelSessionSupport();
|
|
26307
26675
|
init_commanderAttachments();
|
|
26676
|
+
init_claudeCodePipeline();
|
|
26308
26677
|
init_claudeCodeSession();
|
|
26309
26678
|
init_codexAppServer();
|
|
26310
26679
|
init_codexProjectTrust();
|
|
@@ -26327,7 +26696,6 @@ var init_runner = __esm({
|
|
|
26327
26696
|
init_runnerLogger();
|
|
26328
26697
|
init_runnerLock();
|
|
26329
26698
|
init_runnerConsoleReporter();
|
|
26330
|
-
init_streamDeltaQueue();
|
|
26331
26699
|
init_version();
|
|
26332
26700
|
init_telemetry();
|
|
26333
26701
|
init_mcpConfig();
|
|
@@ -26352,13 +26720,7 @@ var init_runner = __esm({
|
|
|
26352
26720
|
"turn/cancelled"
|
|
26353
26721
|
]);
|
|
26354
26722
|
claudeSessionStoreSequenceHighWater = /* @__PURE__ */ new Map();
|
|
26355
|
-
|
|
26356
|
-
constructor(cause) {
|
|
26357
|
-
super(cause instanceof Error ? cause.message : String(cause));
|
|
26358
|
-
this.cause = cause;
|
|
26359
|
-
this.name = "ClaudeCodeOutputPostError";
|
|
26360
|
-
}
|
|
26361
|
-
};
|
|
26723
|
+
claudeCodeLlmProxySessionHeader = "x-linzumi-llm-proxy-token";
|
|
26362
26724
|
onboardingConversationTitleFirstMessages = 4;
|
|
26363
26725
|
onboardingConversationTitleLastMessages = 4;
|
|
26364
26726
|
onboardingConversationTitleBodyMaxLength = 1200;
|
|
@@ -26369,7 +26731,7 @@ var init_runner = __esm({
|
|
|
26369
26731
|
});
|
|
26370
26732
|
|
|
26371
26733
|
// src/kandanTls.ts
|
|
26372
|
-
import { existsSync as
|
|
26734
|
+
import { existsSync as existsSync13, readFileSync as readFileSync16 } from "node:fs";
|
|
26373
26735
|
import { Agent } from "undici";
|
|
26374
26736
|
import WsWebSocket from "ws";
|
|
26375
26737
|
function kandanTlsTrustFromEnv() {
|
|
@@ -26380,7 +26742,7 @@ function kandanTlsTrustFromCaFile(caFile) {
|
|
|
26380
26742
|
return void 0;
|
|
26381
26743
|
}
|
|
26382
26744
|
const trimmed = caFile.trim();
|
|
26383
|
-
if (!
|
|
26745
|
+
if (!existsSync13(trimmed)) {
|
|
26384
26746
|
throw new Error(`KANDAN_TLS_CA_FILE does not exist: ${trimmed}`);
|
|
26385
26747
|
}
|
|
26386
26748
|
const ca = readFileSync16(trimmed, "utf8");
|
|
@@ -27161,7 +27523,7 @@ var require_uri_all = __commonJS({
|
|
|
27161
27523
|
target.fragment = relative3.fragment;
|
|
27162
27524
|
return target;
|
|
27163
27525
|
}
|
|
27164
|
-
function
|
|
27526
|
+
function resolve12(baseURI, relativeURI, options) {
|
|
27165
27527
|
var schemelessOptions = assign({ scheme: "null" }, options);
|
|
27166
27528
|
return serialize(resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
|
|
27167
27529
|
}
|
|
@@ -27426,7 +27788,7 @@ var require_uri_all = __commonJS({
|
|
|
27426
27788
|
exports2.removeDotSegments = removeDotSegments;
|
|
27427
27789
|
exports2.serialize = serialize;
|
|
27428
27790
|
exports2.resolveComponents = resolveComponents;
|
|
27429
|
-
exports2.resolve =
|
|
27791
|
+
exports2.resolve = resolve12;
|
|
27430
27792
|
exports2.normalize = normalize;
|
|
27431
27793
|
exports2.equal = equal;
|
|
27432
27794
|
exports2.escapeComponent = escapeComponent;
|
|
@@ -27471,9 +27833,9 @@ var require_fast_deep_equal = __commonJS({
|
|
|
27471
27833
|
}
|
|
27472
27834
|
});
|
|
27473
27835
|
|
|
27474
|
-
// ../../node_modules
|
|
27836
|
+
// ../../node_modules/ajv/lib/compile/ucs2length.js
|
|
27475
27837
|
var require_ucs2length = __commonJS({
|
|
27476
|
-
"../../node_modules
|
|
27838
|
+
"../../node_modules/ajv/lib/compile/ucs2length.js"(exports, module) {
|
|
27477
27839
|
"use strict";
|
|
27478
27840
|
module.exports = function ucs2length(str) {
|
|
27479
27841
|
var length = 0, len = str.length, pos = 0, value;
|
|
@@ -27490,9 +27852,9 @@ var require_ucs2length = __commonJS({
|
|
|
27490
27852
|
}
|
|
27491
27853
|
});
|
|
27492
27854
|
|
|
27493
|
-
// ../../node_modules
|
|
27855
|
+
// ../../node_modules/ajv/lib/compile/util.js
|
|
27494
27856
|
var require_util = __commonJS({
|
|
27495
|
-
"../../node_modules
|
|
27857
|
+
"../../node_modules/ajv/lib/compile/util.js"(exports, module) {
|
|
27496
27858
|
"use strict";
|
|
27497
27859
|
module.exports = {
|
|
27498
27860
|
copy,
|
|
@@ -27674,9 +28036,9 @@ var require_util = __commonJS({
|
|
|
27674
28036
|
}
|
|
27675
28037
|
});
|
|
27676
28038
|
|
|
27677
|
-
// ../../node_modules
|
|
28039
|
+
// ../../node_modules/ajv/lib/compile/schema_obj.js
|
|
27678
28040
|
var require_schema_obj = __commonJS({
|
|
27679
|
-
"../../node_modules
|
|
28041
|
+
"../../node_modules/ajv/lib/compile/schema_obj.js"(exports, module) {
|
|
27680
28042
|
"use strict";
|
|
27681
28043
|
var util3 = require_util();
|
|
27682
28044
|
module.exports = SchemaObject;
|
|
@@ -27770,27 +28132,27 @@ var require_json_schema_traverse = __commonJS({
|
|
|
27770
28132
|
}
|
|
27771
28133
|
});
|
|
27772
28134
|
|
|
27773
|
-
// ../../node_modules
|
|
28135
|
+
// ../../node_modules/ajv/lib/compile/resolve.js
|
|
27774
28136
|
var require_resolve = __commonJS({
|
|
27775
|
-
"../../node_modules
|
|
28137
|
+
"../../node_modules/ajv/lib/compile/resolve.js"(exports, module) {
|
|
27776
28138
|
"use strict";
|
|
27777
28139
|
var URI = require_uri_all();
|
|
27778
28140
|
var equal = require_fast_deep_equal();
|
|
27779
28141
|
var util3 = require_util();
|
|
27780
28142
|
var SchemaObject = require_schema_obj();
|
|
27781
28143
|
var traverse = require_json_schema_traverse();
|
|
27782
|
-
module.exports =
|
|
27783
|
-
|
|
27784
|
-
|
|
27785
|
-
|
|
27786
|
-
|
|
27787
|
-
|
|
27788
|
-
|
|
27789
|
-
function
|
|
28144
|
+
module.exports = resolve12;
|
|
28145
|
+
resolve12.normalizeId = normalizeId;
|
|
28146
|
+
resolve12.fullPath = getFullPath;
|
|
28147
|
+
resolve12.url = resolveUrl;
|
|
28148
|
+
resolve12.ids = resolveIds;
|
|
28149
|
+
resolve12.inlineRef = inlineRef;
|
|
28150
|
+
resolve12.schema = resolveSchema;
|
|
28151
|
+
function resolve12(compile, root, ref) {
|
|
27790
28152
|
var refVal = this._refs[ref];
|
|
27791
28153
|
if (typeof refVal == "string") {
|
|
27792
28154
|
if (this._refs[refVal]) refVal = this._refs[refVal];
|
|
27793
|
-
else return
|
|
28155
|
+
else return resolve12.call(this, compile, root, refVal);
|
|
27794
28156
|
}
|
|
27795
28157
|
refVal = refVal || this._schemas[ref];
|
|
27796
28158
|
if (refVal instanceof SchemaObject) {
|
|
@@ -27991,11 +28353,11 @@ var require_resolve = __commonJS({
|
|
|
27991
28353
|
}
|
|
27992
28354
|
});
|
|
27993
28355
|
|
|
27994
|
-
// ../../node_modules
|
|
28356
|
+
// ../../node_modules/ajv/lib/compile/error_classes.js
|
|
27995
28357
|
var require_error_classes = __commonJS({
|
|
27996
|
-
"../../node_modules
|
|
28358
|
+
"../../node_modules/ajv/lib/compile/error_classes.js"(exports, module) {
|
|
27997
28359
|
"use strict";
|
|
27998
|
-
var
|
|
28360
|
+
var resolve12 = require_resolve();
|
|
27999
28361
|
module.exports = {
|
|
28000
28362
|
Validation: errorSubclass(ValidationError2),
|
|
28001
28363
|
MissingRef: errorSubclass(MissingRefError)
|
|
@@ -28010,8 +28372,8 @@ var require_error_classes = __commonJS({
|
|
|
28010
28372
|
};
|
|
28011
28373
|
function MissingRefError(baseId, ref, message) {
|
|
28012
28374
|
this.message = message || MissingRefError.message(baseId, ref);
|
|
28013
|
-
this.missingRef =
|
|
28014
|
-
this.missingSchema =
|
|
28375
|
+
this.missingRef = resolve12.url(baseId, ref);
|
|
28376
|
+
this.missingSchema = resolve12.normalizeId(resolve12.fullPath(this.missingRef));
|
|
28015
28377
|
}
|
|
28016
28378
|
function errorSubclass(Subclass) {
|
|
28017
28379
|
Subclass.prototype = Object.create(Error.prototype);
|
|
@@ -28077,9 +28439,9 @@ var require_fast_json_stable_stringify = __commonJS({
|
|
|
28077
28439
|
}
|
|
28078
28440
|
});
|
|
28079
28441
|
|
|
28080
|
-
// ../../node_modules
|
|
28442
|
+
// ../../node_modules/ajv/lib/dotjs/validate.js
|
|
28081
28443
|
var require_validate = __commonJS({
|
|
28082
|
-
"../../node_modules
|
|
28444
|
+
"../../node_modules/ajv/lib/dotjs/validate.js"(exports, module) {
|
|
28083
28445
|
"use strict";
|
|
28084
28446
|
module.exports = function generate_validate(it, $keyword, $ruleType) {
|
|
28085
28447
|
var out = "";
|
|
@@ -28535,11 +28897,11 @@ var require_validate = __commonJS({
|
|
|
28535
28897
|
}
|
|
28536
28898
|
});
|
|
28537
28899
|
|
|
28538
|
-
// ../../node_modules
|
|
28900
|
+
// ../../node_modules/ajv/lib/compile/index.js
|
|
28539
28901
|
var require_compile = __commonJS({
|
|
28540
|
-
"../../node_modules
|
|
28902
|
+
"../../node_modules/ajv/lib/compile/index.js"(exports, module) {
|
|
28541
28903
|
"use strict";
|
|
28542
|
-
var
|
|
28904
|
+
var resolve12 = require_resolve();
|
|
28543
28905
|
var util3 = require_util();
|
|
28544
28906
|
var errorClasses = require_error_classes();
|
|
28545
28907
|
var stableStringify = require_fast_json_stable_stringify();
|
|
@@ -28597,7 +28959,7 @@ var require_compile = __commonJS({
|
|
|
28597
28959
|
RULES,
|
|
28598
28960
|
validate: validateGenerator,
|
|
28599
28961
|
util: util3,
|
|
28600
|
-
resolve:
|
|
28962
|
+
resolve: resolve12,
|
|
28601
28963
|
resolveRef,
|
|
28602
28964
|
usePattern,
|
|
28603
28965
|
useDefault,
|
|
@@ -28657,7 +29019,7 @@ var require_compile = __commonJS({
|
|
|
28657
29019
|
return validate;
|
|
28658
29020
|
}
|
|
28659
29021
|
function resolveRef(baseId2, ref, isRoot) {
|
|
28660
|
-
ref =
|
|
29022
|
+
ref = resolve12.url(baseId2, ref);
|
|
28661
29023
|
var refIndex = refs[ref];
|
|
28662
29024
|
var _refVal, refCode;
|
|
28663
29025
|
if (refIndex !== void 0) {
|
|
@@ -28674,11 +29036,11 @@ var require_compile = __commonJS({
|
|
|
28674
29036
|
}
|
|
28675
29037
|
}
|
|
28676
29038
|
refCode = addLocalRef(ref);
|
|
28677
|
-
var v2 =
|
|
29039
|
+
var v2 = resolve12.call(self, localCompile, root, ref);
|
|
28678
29040
|
if (v2 === void 0) {
|
|
28679
29041
|
var localSchema = localRefs && localRefs[ref];
|
|
28680
29042
|
if (localSchema) {
|
|
28681
|
-
v2 =
|
|
29043
|
+
v2 = resolve12.inlineRef(localSchema, opts.inlineRefs) ? localSchema : compile.call(self, localSchema, root, localRefs, baseId2);
|
|
28682
29044
|
}
|
|
28683
29045
|
}
|
|
28684
29046
|
if (v2 === void 0) {
|
|
@@ -28814,9 +29176,9 @@ var require_compile = __commonJS({
|
|
|
28814
29176
|
}
|
|
28815
29177
|
});
|
|
28816
29178
|
|
|
28817
|
-
// ../../node_modules
|
|
29179
|
+
// ../../node_modules/ajv/lib/cache.js
|
|
28818
29180
|
var require_cache = __commonJS({
|
|
28819
|
-
"../../node_modules
|
|
29181
|
+
"../../node_modules/ajv/lib/cache.js"(exports, module) {
|
|
28820
29182
|
"use strict";
|
|
28821
29183
|
var Cache = module.exports = function Cache2() {
|
|
28822
29184
|
this._cache = {};
|
|
@@ -28836,9 +29198,9 @@ var require_cache = __commonJS({
|
|
|
28836
29198
|
}
|
|
28837
29199
|
});
|
|
28838
29200
|
|
|
28839
|
-
// ../../node_modules
|
|
29201
|
+
// ../../node_modules/ajv/lib/compile/formats.js
|
|
28840
29202
|
var require_formats = __commonJS({
|
|
28841
|
-
"../../node_modules
|
|
29203
|
+
"../../node_modules/ajv/lib/compile/formats.js"(exports, module) {
|
|
28842
29204
|
"use strict";
|
|
28843
29205
|
var util3 = require_util();
|
|
28844
29206
|
var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
@@ -28948,9 +29310,9 @@ var require_formats = __commonJS({
|
|
|
28948
29310
|
}
|
|
28949
29311
|
});
|
|
28950
29312
|
|
|
28951
|
-
// ../../node_modules
|
|
29313
|
+
// ../../node_modules/ajv/lib/dotjs/ref.js
|
|
28952
29314
|
var require_ref = __commonJS({
|
|
28953
|
-
"../../node_modules
|
|
29315
|
+
"../../node_modules/ajv/lib/dotjs/ref.js"(exports, module) {
|
|
28954
29316
|
"use strict";
|
|
28955
29317
|
module.exports = function generate_ref(it, $keyword, $ruleType) {
|
|
28956
29318
|
var out = " ";
|
|
@@ -29076,9 +29438,9 @@ var require_ref = __commonJS({
|
|
|
29076
29438
|
}
|
|
29077
29439
|
});
|
|
29078
29440
|
|
|
29079
|
-
// ../../node_modules
|
|
29441
|
+
// ../../node_modules/ajv/lib/dotjs/allOf.js
|
|
29080
29442
|
var require_allOf = __commonJS({
|
|
29081
|
-
"../../node_modules
|
|
29443
|
+
"../../node_modules/ajv/lib/dotjs/allOf.js"(exports, module) {
|
|
29082
29444
|
"use strict";
|
|
29083
29445
|
module.exports = function generate_allOf(it, $keyword, $ruleType) {
|
|
29084
29446
|
var out = " ";
|
|
@@ -29122,9 +29484,9 @@ var require_allOf = __commonJS({
|
|
|
29122
29484
|
}
|
|
29123
29485
|
});
|
|
29124
29486
|
|
|
29125
|
-
// ../../node_modules
|
|
29487
|
+
// ../../node_modules/ajv/lib/dotjs/anyOf.js
|
|
29126
29488
|
var require_anyOf = __commonJS({
|
|
29127
|
-
"../../node_modules
|
|
29489
|
+
"../../node_modules/ajv/lib/dotjs/anyOf.js"(exports, module) {
|
|
29128
29490
|
"use strict";
|
|
29129
29491
|
module.exports = function generate_anyOf(it, $keyword, $ruleType) {
|
|
29130
29492
|
var out = " ";
|
|
@@ -29199,9 +29561,9 @@ var require_anyOf = __commonJS({
|
|
|
29199
29561
|
}
|
|
29200
29562
|
});
|
|
29201
29563
|
|
|
29202
|
-
// ../../node_modules
|
|
29564
|
+
// ../../node_modules/ajv/lib/dotjs/comment.js
|
|
29203
29565
|
var require_comment = __commonJS({
|
|
29204
|
-
"../../node_modules
|
|
29566
|
+
"../../node_modules/ajv/lib/dotjs/comment.js"(exports, module) {
|
|
29205
29567
|
"use strict";
|
|
29206
29568
|
module.exports = function generate_comment(it, $keyword, $ruleType) {
|
|
29207
29569
|
var out = " ";
|
|
@@ -29219,9 +29581,9 @@ var require_comment = __commonJS({
|
|
|
29219
29581
|
}
|
|
29220
29582
|
});
|
|
29221
29583
|
|
|
29222
|
-
// ../../node_modules
|
|
29584
|
+
// ../../node_modules/ajv/lib/dotjs/const.js
|
|
29223
29585
|
var require_const = __commonJS({
|
|
29224
|
-
"../../node_modules
|
|
29586
|
+
"../../node_modules/ajv/lib/dotjs/const.js"(exports, module) {
|
|
29225
29587
|
"use strict";
|
|
29226
29588
|
module.exports = function generate_const(it, $keyword, $ruleType) {
|
|
29227
29589
|
var out = " ";
|
|
@@ -29279,9 +29641,9 @@ var require_const = __commonJS({
|
|
|
29279
29641
|
}
|
|
29280
29642
|
});
|
|
29281
29643
|
|
|
29282
|
-
// ../../node_modules
|
|
29644
|
+
// ../../node_modules/ajv/lib/dotjs/contains.js
|
|
29283
29645
|
var require_contains = __commonJS({
|
|
29284
|
-
"../../node_modules
|
|
29646
|
+
"../../node_modules/ajv/lib/dotjs/contains.js"(exports, module) {
|
|
29285
29647
|
"use strict";
|
|
29286
29648
|
module.exports = function generate_contains(it, $keyword, $ruleType) {
|
|
29287
29649
|
var out = " ";
|
|
@@ -29361,9 +29723,9 @@ var require_contains = __commonJS({
|
|
|
29361
29723
|
}
|
|
29362
29724
|
});
|
|
29363
29725
|
|
|
29364
|
-
// ../../node_modules
|
|
29726
|
+
// ../../node_modules/ajv/lib/dotjs/dependencies.js
|
|
29365
29727
|
var require_dependencies = __commonJS({
|
|
29366
|
-
"../../node_modules
|
|
29728
|
+
"../../node_modules/ajv/lib/dotjs/dependencies.js"(exports, module) {
|
|
29367
29729
|
"use strict";
|
|
29368
29730
|
module.exports = function generate_dependencies(it, $keyword, $ruleType) {
|
|
29369
29731
|
var out = " ";
|
|
@@ -29526,9 +29888,9 @@ var require_dependencies = __commonJS({
|
|
|
29526
29888
|
}
|
|
29527
29889
|
});
|
|
29528
29890
|
|
|
29529
|
-
// ../../node_modules
|
|
29891
|
+
// ../../node_modules/ajv/lib/dotjs/enum.js
|
|
29530
29892
|
var require_enum = __commonJS({
|
|
29531
|
-
"../../node_modules
|
|
29893
|
+
"../../node_modules/ajv/lib/dotjs/enum.js"(exports, module) {
|
|
29532
29894
|
"use strict";
|
|
29533
29895
|
module.exports = function generate_enum(it, $keyword, $ruleType) {
|
|
29534
29896
|
var out = " ";
|
|
@@ -29595,9 +29957,9 @@ var require_enum = __commonJS({
|
|
|
29595
29957
|
}
|
|
29596
29958
|
});
|
|
29597
29959
|
|
|
29598
|
-
// ../../node_modules
|
|
29960
|
+
// ../../node_modules/ajv/lib/dotjs/format.js
|
|
29599
29961
|
var require_format = __commonJS({
|
|
29600
|
-
"../../node_modules
|
|
29962
|
+
"../../node_modules/ajv/lib/dotjs/format.js"(exports, module) {
|
|
29601
29963
|
"use strict";
|
|
29602
29964
|
module.exports = function generate_format(it, $keyword, $ruleType) {
|
|
29603
29965
|
var out = " ";
|
|
@@ -29746,9 +30108,9 @@ var require_format = __commonJS({
|
|
|
29746
30108
|
}
|
|
29747
30109
|
});
|
|
29748
30110
|
|
|
29749
|
-
// ../../node_modules
|
|
30111
|
+
// ../../node_modules/ajv/lib/dotjs/if.js
|
|
29750
30112
|
var require_if = __commonJS({
|
|
29751
|
-
"../../node_modules
|
|
30113
|
+
"../../node_modules/ajv/lib/dotjs/if.js"(exports, module) {
|
|
29752
30114
|
"use strict";
|
|
29753
30115
|
module.exports = function generate_if(it, $keyword, $ruleType) {
|
|
29754
30116
|
var out = " ";
|
|
@@ -29850,9 +30212,9 @@ var require_if = __commonJS({
|
|
|
29850
30212
|
}
|
|
29851
30213
|
});
|
|
29852
30214
|
|
|
29853
|
-
// ../../node_modules
|
|
30215
|
+
// ../../node_modules/ajv/lib/dotjs/items.js
|
|
29854
30216
|
var require_items = __commonJS({
|
|
29855
|
-
"../../node_modules
|
|
30217
|
+
"../../node_modules/ajv/lib/dotjs/items.js"(exports, module) {
|
|
29856
30218
|
"use strict";
|
|
29857
30219
|
module.exports = function generate_items(it, $keyword, $ruleType) {
|
|
29858
30220
|
var out = " ";
|
|
@@ -29991,9 +30353,9 @@ var require_items = __commonJS({
|
|
|
29991
30353
|
}
|
|
29992
30354
|
});
|
|
29993
30355
|
|
|
29994
|
-
// ../../node_modules
|
|
30356
|
+
// ../../node_modules/ajv/lib/dotjs/_limit.js
|
|
29995
30357
|
var require_limit = __commonJS({
|
|
29996
|
-
"../../node_modules
|
|
30358
|
+
"../../node_modules/ajv/lib/dotjs/_limit.js"(exports, module) {
|
|
29997
30359
|
"use strict";
|
|
29998
30360
|
module.exports = function generate__limit(it, $keyword, $ruleType) {
|
|
29999
30361
|
var out = " ";
|
|
@@ -30145,9 +30507,9 @@ var require_limit = __commonJS({
|
|
|
30145
30507
|
}
|
|
30146
30508
|
});
|
|
30147
30509
|
|
|
30148
|
-
// ../../node_modules
|
|
30510
|
+
// ../../node_modules/ajv/lib/dotjs/_limitItems.js
|
|
30149
30511
|
var require_limitItems = __commonJS({
|
|
30150
|
-
"../../node_modules
|
|
30512
|
+
"../../node_modules/ajv/lib/dotjs/_limitItems.js"(exports, module) {
|
|
30151
30513
|
"use strict";
|
|
30152
30514
|
module.exports = function generate__limitItems(it, $keyword, $ruleType) {
|
|
30153
30515
|
var out = " ";
|
|
@@ -30229,9 +30591,9 @@ var require_limitItems = __commonJS({
|
|
|
30229
30591
|
}
|
|
30230
30592
|
});
|
|
30231
30593
|
|
|
30232
|
-
// ../../node_modules
|
|
30594
|
+
// ../../node_modules/ajv/lib/dotjs/_limitLength.js
|
|
30233
30595
|
var require_limitLength = __commonJS({
|
|
30234
|
-
"../../node_modules
|
|
30596
|
+
"../../node_modules/ajv/lib/dotjs/_limitLength.js"(exports, module) {
|
|
30235
30597
|
"use strict";
|
|
30236
30598
|
module.exports = function generate__limitLength(it, $keyword, $ruleType) {
|
|
30237
30599
|
var out = " ";
|
|
@@ -30318,9 +30680,9 @@ var require_limitLength = __commonJS({
|
|
|
30318
30680
|
}
|
|
30319
30681
|
});
|
|
30320
30682
|
|
|
30321
|
-
// ../../node_modules
|
|
30683
|
+
// ../../node_modules/ajv/lib/dotjs/_limitProperties.js
|
|
30322
30684
|
var require_limitProperties = __commonJS({
|
|
30323
|
-
"../../node_modules
|
|
30685
|
+
"../../node_modules/ajv/lib/dotjs/_limitProperties.js"(exports, module) {
|
|
30324
30686
|
"use strict";
|
|
30325
30687
|
module.exports = function generate__limitProperties(it, $keyword, $ruleType) {
|
|
30326
30688
|
var out = " ";
|
|
@@ -30402,9 +30764,9 @@ var require_limitProperties = __commonJS({
|
|
|
30402
30764
|
}
|
|
30403
30765
|
});
|
|
30404
30766
|
|
|
30405
|
-
// ../../node_modules
|
|
30767
|
+
// ../../node_modules/ajv/lib/dotjs/multipleOf.js
|
|
30406
30768
|
var require_multipleOf = __commonJS({
|
|
30407
|
-
"../../node_modules
|
|
30769
|
+
"../../node_modules/ajv/lib/dotjs/multipleOf.js"(exports, module) {
|
|
30408
30770
|
"use strict";
|
|
30409
30771
|
module.exports = function generate_multipleOf(it, $keyword, $ruleType) {
|
|
30410
30772
|
var out = " ";
|
|
@@ -30486,9 +30848,9 @@ var require_multipleOf = __commonJS({
|
|
|
30486
30848
|
}
|
|
30487
30849
|
});
|
|
30488
30850
|
|
|
30489
|
-
// ../../node_modules
|
|
30851
|
+
// ../../node_modules/ajv/lib/dotjs/not.js
|
|
30490
30852
|
var require_not = __commonJS({
|
|
30491
|
-
"../../node_modules
|
|
30853
|
+
"../../node_modules/ajv/lib/dotjs/not.js"(exports, module) {
|
|
30492
30854
|
"use strict";
|
|
30493
30855
|
module.exports = function generate_not(it, $keyword, $ruleType) {
|
|
30494
30856
|
var out = " ";
|
|
@@ -30575,9 +30937,9 @@ var require_not = __commonJS({
|
|
|
30575
30937
|
}
|
|
30576
30938
|
});
|
|
30577
30939
|
|
|
30578
|
-
// ../../node_modules
|
|
30940
|
+
// ../../node_modules/ajv/lib/dotjs/oneOf.js
|
|
30579
30941
|
var require_oneOf = __commonJS({
|
|
30580
|
-
"../../node_modules
|
|
30942
|
+
"../../node_modules/ajv/lib/dotjs/oneOf.js"(exports, module) {
|
|
30581
30943
|
"use strict";
|
|
30582
30944
|
module.exports = function generate_oneOf(it, $keyword, $ruleType) {
|
|
30583
30945
|
var out = " ";
|
|
@@ -30650,9 +31012,9 @@ var require_oneOf = __commonJS({
|
|
|
30650
31012
|
}
|
|
30651
31013
|
});
|
|
30652
31014
|
|
|
30653
|
-
// ../../node_modules
|
|
31015
|
+
// ../../node_modules/ajv/lib/dotjs/pattern.js
|
|
30654
31016
|
var require_pattern = __commonJS({
|
|
30655
|
-
"../../node_modules
|
|
31017
|
+
"../../node_modules/ajv/lib/dotjs/pattern.js"(exports, module) {
|
|
30656
31018
|
"use strict";
|
|
30657
31019
|
module.exports = function generate_pattern(it, $keyword, $ruleType) {
|
|
30658
31020
|
var out = " ";
|
|
@@ -30729,9 +31091,9 @@ var require_pattern = __commonJS({
|
|
|
30729
31091
|
}
|
|
30730
31092
|
});
|
|
30731
31093
|
|
|
30732
|
-
// ../../node_modules
|
|
31094
|
+
// ../../node_modules/ajv/lib/dotjs/properties.js
|
|
30733
31095
|
var require_properties = __commonJS({
|
|
30734
|
-
"../../node_modules
|
|
31096
|
+
"../../node_modules/ajv/lib/dotjs/properties.js"(exports, module) {
|
|
30735
31097
|
"use strict";
|
|
30736
31098
|
module.exports = function generate_properties(it, $keyword, $ruleType) {
|
|
30737
31099
|
var out = " ";
|
|
@@ -31045,9 +31407,9 @@ var require_properties = __commonJS({
|
|
|
31045
31407
|
}
|
|
31046
31408
|
});
|
|
31047
31409
|
|
|
31048
|
-
// ../../node_modules
|
|
31410
|
+
// ../../node_modules/ajv/lib/dotjs/propertyNames.js
|
|
31049
31411
|
var require_propertyNames = __commonJS({
|
|
31050
|
-
"../../node_modules
|
|
31412
|
+
"../../node_modules/ajv/lib/dotjs/propertyNames.js"(exports, module) {
|
|
31051
31413
|
"use strict";
|
|
31052
31414
|
module.exports = function generate_propertyNames(it, $keyword, $ruleType) {
|
|
31053
31415
|
var out = " ";
|
|
@@ -31123,9 +31485,9 @@ var require_propertyNames = __commonJS({
|
|
|
31123
31485
|
}
|
|
31124
31486
|
});
|
|
31125
31487
|
|
|
31126
|
-
// ../../node_modules
|
|
31488
|
+
// ../../node_modules/ajv/lib/dotjs/required.js
|
|
31127
31489
|
var require_required = __commonJS({
|
|
31128
|
-
"../../node_modules
|
|
31490
|
+
"../../node_modules/ajv/lib/dotjs/required.js"(exports, module) {
|
|
31129
31491
|
"use strict";
|
|
31130
31492
|
module.exports = function generate_required(it, $keyword, $ruleType) {
|
|
31131
31493
|
var out = " ";
|
|
@@ -31383,9 +31745,9 @@ var require_required = __commonJS({
|
|
|
31383
31745
|
}
|
|
31384
31746
|
});
|
|
31385
31747
|
|
|
31386
|
-
// ../../node_modules
|
|
31748
|
+
// ../../node_modules/ajv/lib/dotjs/uniqueItems.js
|
|
31387
31749
|
var require_uniqueItems = __commonJS({
|
|
31388
|
-
"../../node_modules
|
|
31750
|
+
"../../node_modules/ajv/lib/dotjs/uniqueItems.js"(exports, module) {
|
|
31389
31751
|
"use strict";
|
|
31390
31752
|
module.exports = function generate_uniqueItems(it, $keyword, $ruleType) {
|
|
31391
31753
|
var out = " ";
|
|
@@ -31472,9 +31834,9 @@ var require_uniqueItems = __commonJS({
|
|
|
31472
31834
|
}
|
|
31473
31835
|
});
|
|
31474
31836
|
|
|
31475
|
-
// ../../node_modules
|
|
31837
|
+
// ../../node_modules/ajv/lib/dotjs/index.js
|
|
31476
31838
|
var require_dotjs = __commonJS({
|
|
31477
|
-
"../../node_modules
|
|
31839
|
+
"../../node_modules/ajv/lib/dotjs/index.js"(exports, module) {
|
|
31478
31840
|
"use strict";
|
|
31479
31841
|
module.exports = {
|
|
31480
31842
|
"$ref": require_ref(),
|
|
@@ -31509,9 +31871,9 @@ var require_dotjs = __commonJS({
|
|
|
31509
31871
|
}
|
|
31510
31872
|
});
|
|
31511
31873
|
|
|
31512
|
-
// ../../node_modules
|
|
31874
|
+
// ../../node_modules/ajv/lib/compile/rules.js
|
|
31513
31875
|
var require_rules = __commonJS({
|
|
31514
|
-
"../../node_modules
|
|
31876
|
+
"../../node_modules/ajv/lib/compile/rules.js"(exports, module) {
|
|
31515
31877
|
"use strict";
|
|
31516
31878
|
var ruleModules = require_dotjs();
|
|
31517
31879
|
var toHash = require_util().toHash;
|
|
@@ -31603,9 +31965,9 @@ var require_rules = __commonJS({
|
|
|
31603
31965
|
}
|
|
31604
31966
|
});
|
|
31605
31967
|
|
|
31606
|
-
// ../../node_modules
|
|
31968
|
+
// ../../node_modules/ajv/lib/data.js
|
|
31607
31969
|
var require_data = __commonJS({
|
|
31608
|
-
"../../node_modules
|
|
31970
|
+
"../../node_modules/ajv/lib/data.js"(exports, module) {
|
|
31609
31971
|
"use strict";
|
|
31610
31972
|
var KEYWORDS = [
|
|
31611
31973
|
"multipleOf",
|
|
@@ -31654,9 +32016,9 @@ var require_data = __commonJS({
|
|
|
31654
32016
|
}
|
|
31655
32017
|
});
|
|
31656
32018
|
|
|
31657
|
-
// ../../node_modules
|
|
32019
|
+
// ../../node_modules/ajv/lib/compile/async.js
|
|
31658
32020
|
var require_async = __commonJS({
|
|
31659
|
-
"../../node_modules
|
|
32021
|
+
"../../node_modules/ajv/lib/compile/async.js"(exports, module) {
|
|
31660
32022
|
"use strict";
|
|
31661
32023
|
var MissingRefError = require_error_classes().MissingRef;
|
|
31662
32024
|
module.exports = compileAsync;
|
|
@@ -31721,9 +32083,9 @@ var require_async = __commonJS({
|
|
|
31721
32083
|
}
|
|
31722
32084
|
});
|
|
31723
32085
|
|
|
31724
|
-
// ../../node_modules
|
|
32086
|
+
// ../../node_modules/ajv/lib/dotjs/custom.js
|
|
31725
32087
|
var require_custom = __commonJS({
|
|
31726
|
-
"../../node_modules
|
|
32088
|
+
"../../node_modules/ajv/lib/dotjs/custom.js"(exports, module) {
|
|
31727
32089
|
"use strict";
|
|
31728
32090
|
module.exports = function generate_custom(it, $keyword, $ruleType) {
|
|
31729
32091
|
var out = " ";
|
|
@@ -31945,9 +32307,9 @@ var require_custom = __commonJS({
|
|
|
31945
32307
|
}
|
|
31946
32308
|
});
|
|
31947
32309
|
|
|
31948
|
-
// ../../node_modules
|
|
32310
|
+
// ../../node_modules/ajv/lib/refs/json-schema-draft-07.json
|
|
31949
32311
|
var require_json_schema_draft_07 = __commonJS({
|
|
31950
|
-
"../../node_modules
|
|
32312
|
+
"../../node_modules/ajv/lib/refs/json-schema-draft-07.json"(exports, module) {
|
|
31951
32313
|
module.exports = {
|
|
31952
32314
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
31953
32315
|
$id: "http://json-schema.org/draft-07/schema#",
|
|
@@ -32119,9 +32481,9 @@ var require_json_schema_draft_07 = __commonJS({
|
|
|
32119
32481
|
}
|
|
32120
32482
|
});
|
|
32121
32483
|
|
|
32122
|
-
// ../../node_modules
|
|
32484
|
+
// ../../node_modules/ajv/lib/definition_schema.js
|
|
32123
32485
|
var require_definition_schema = __commonJS({
|
|
32124
|
-
"../../node_modules
|
|
32486
|
+
"../../node_modules/ajv/lib/definition_schema.js"(exports, module) {
|
|
32125
32487
|
"use strict";
|
|
32126
32488
|
var metaSchema = require_json_schema_draft_07();
|
|
32127
32489
|
module.exports = {
|
|
@@ -32160,9 +32522,9 @@ var require_definition_schema = __commonJS({
|
|
|
32160
32522
|
}
|
|
32161
32523
|
});
|
|
32162
32524
|
|
|
32163
|
-
// ../../node_modules
|
|
32525
|
+
// ../../node_modules/ajv/lib/keyword.js
|
|
32164
32526
|
var require_keyword = __commonJS({
|
|
32165
|
-
"../../node_modules
|
|
32527
|
+
"../../node_modules/ajv/lib/keyword.js"(exports, module) {
|
|
32166
32528
|
"use strict";
|
|
32167
32529
|
var IDENTIFIER = /^[a-z_$][a-z0-9_$-]*$/i;
|
|
32168
32530
|
var customRuleCode = require_custom();
|
|
@@ -32260,9 +32622,9 @@ var require_keyword = __commonJS({
|
|
|
32260
32622
|
}
|
|
32261
32623
|
});
|
|
32262
32624
|
|
|
32263
|
-
// ../../node_modules
|
|
32625
|
+
// ../../node_modules/ajv/lib/refs/data.json
|
|
32264
32626
|
var require_data2 = __commonJS({
|
|
32265
|
-
"../../node_modules
|
|
32627
|
+
"../../node_modules/ajv/lib/refs/data.json"(exports, module) {
|
|
32266
32628
|
module.exports = {
|
|
32267
32629
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
32268
32630
|
$id: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
|
|
@@ -32283,12 +32645,12 @@ var require_data2 = __commonJS({
|
|
|
32283
32645
|
}
|
|
32284
32646
|
});
|
|
32285
32647
|
|
|
32286
|
-
// ../../node_modules
|
|
32648
|
+
// ../../node_modules/ajv/lib/ajv.js
|
|
32287
32649
|
var require_ajv = __commonJS({
|
|
32288
|
-
"../../node_modules
|
|
32650
|
+
"../../node_modules/ajv/lib/ajv.js"(exports, module) {
|
|
32289
32651
|
"use strict";
|
|
32290
32652
|
var compileSchema = require_compile();
|
|
32291
|
-
var
|
|
32653
|
+
var resolve12 = require_resolve();
|
|
32292
32654
|
var Cache = require_cache();
|
|
32293
32655
|
var SchemaObject = require_schema_obj();
|
|
32294
32656
|
var stableStringify = require_fast_json_stable_stringify();
|
|
@@ -32370,7 +32732,7 @@ var require_ajv = __commonJS({
|
|
|
32370
32732
|
var id = this._getId(schema);
|
|
32371
32733
|
if (id !== void 0 && typeof id != "string")
|
|
32372
32734
|
throw new Error("schema id must be string");
|
|
32373
|
-
key =
|
|
32735
|
+
key = resolve12.normalizeId(key || id);
|
|
32374
32736
|
checkUnique(this, key);
|
|
32375
32737
|
this._schemas[key] = this._addSchema(schema, _skipValidation, _meta, true);
|
|
32376
32738
|
return this;
|
|
@@ -32414,7 +32776,7 @@ var require_ajv = __commonJS({
|
|
|
32414
32776
|
}
|
|
32415
32777
|
}
|
|
32416
32778
|
function _getSchemaFragment(self, ref) {
|
|
32417
|
-
var res =
|
|
32779
|
+
var res = resolve12.schema.call(self, { schema: {} }, ref);
|
|
32418
32780
|
if (res) {
|
|
32419
32781
|
var schema = res.schema, root = res.root, baseId = res.baseId;
|
|
32420
32782
|
var v = compileSchema.call(self, schema, root, void 0, baseId);
|
|
@@ -32430,7 +32792,7 @@ var require_ajv = __commonJS({
|
|
|
32430
32792
|
}
|
|
32431
32793
|
}
|
|
32432
32794
|
function _getSchemaObj(self, keyRef) {
|
|
32433
|
-
keyRef =
|
|
32795
|
+
keyRef = resolve12.normalizeId(keyRef);
|
|
32434
32796
|
return self._schemas[keyRef] || self._refs[keyRef] || self._fragments[keyRef];
|
|
32435
32797
|
}
|
|
32436
32798
|
function removeSchema(schemaKeyRef) {
|
|
@@ -32457,7 +32819,7 @@ var require_ajv = __commonJS({
|
|
|
32457
32819
|
this._cache.del(cacheKey);
|
|
32458
32820
|
var id = this._getId(schemaKeyRef);
|
|
32459
32821
|
if (id) {
|
|
32460
|
-
id =
|
|
32822
|
+
id = resolve12.normalizeId(id);
|
|
32461
32823
|
delete this._schemas[id];
|
|
32462
32824
|
delete this._refs[id];
|
|
32463
32825
|
}
|
|
@@ -32481,13 +32843,13 @@ var require_ajv = __commonJS({
|
|
|
32481
32843
|
var cached = this._cache.get(cacheKey);
|
|
32482
32844
|
if (cached) return cached;
|
|
32483
32845
|
shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false;
|
|
32484
|
-
var id =
|
|
32846
|
+
var id = resolve12.normalizeId(this._getId(schema));
|
|
32485
32847
|
if (id && shouldAddSchema) checkUnique(this, id);
|
|
32486
32848
|
var willValidate = this._opts.validateSchema !== false && !skipValidation;
|
|
32487
32849
|
var recursiveMeta;
|
|
32488
|
-
if (willValidate && !(recursiveMeta = id && id ==
|
|
32850
|
+
if (willValidate && !(recursiveMeta = id && id == resolve12.normalizeId(schema.$schema)))
|
|
32489
32851
|
this.validateSchema(schema, true);
|
|
32490
|
-
var localRefs =
|
|
32852
|
+
var localRefs = resolve12.ids.call(this, schema);
|
|
32491
32853
|
var schemaObj = new SchemaObject({
|
|
32492
32854
|
id,
|
|
32493
32855
|
schema,
|
|
@@ -35344,13 +35706,13 @@ var init_promise_polyfill = __esm({
|
|
|
35344
35706
|
// Available starting from Node 22
|
|
35345
35707
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
|
|
35346
35708
|
static withResolver() {
|
|
35347
|
-
let
|
|
35709
|
+
let resolve12;
|
|
35348
35710
|
let reject;
|
|
35349
35711
|
const promise = new Promise((res, rej) => {
|
|
35350
|
-
|
|
35712
|
+
resolve12 = res;
|
|
35351
35713
|
reject = rej;
|
|
35352
35714
|
});
|
|
35353
|
-
return { promise, resolve:
|
|
35715
|
+
return { promise, resolve: resolve12, reject };
|
|
35354
35716
|
}
|
|
35355
35717
|
};
|
|
35356
35718
|
}
|
|
@@ -35388,7 +35750,7 @@ function createPrompt(view) {
|
|
|
35388
35750
|
output
|
|
35389
35751
|
});
|
|
35390
35752
|
const screen = new ScreenManager(rl);
|
|
35391
|
-
const { promise, resolve:
|
|
35753
|
+
const { promise, resolve: resolve12, reject } = PromisePolyfill.withResolver();
|
|
35392
35754
|
const cancel = () => reject(new CancelPromptError());
|
|
35393
35755
|
if (signal) {
|
|
35394
35756
|
const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
|
|
@@ -35415,7 +35777,7 @@ function createPrompt(view) {
|
|
|
35415
35777
|
cycle(() => {
|
|
35416
35778
|
try {
|
|
35417
35779
|
const nextView = view(config, (value) => {
|
|
35418
|
-
setImmediate(() =>
|
|
35780
|
+
setImmediate(() => resolve12(value));
|
|
35419
35781
|
});
|
|
35420
35782
|
if (nextView === void 0) {
|
|
35421
35783
|
const callerFilename = callSites[1]?.getFileName();
|
|
@@ -41268,7 +41630,7 @@ var require_lib2 = __commonJS({
|
|
|
41268
41630
|
return matches;
|
|
41269
41631
|
};
|
|
41270
41632
|
exports.analyse = analyse;
|
|
41271
|
-
var detectFile = (filepath, opts = {}) => new Promise((
|
|
41633
|
+
var detectFile = (filepath, opts = {}) => new Promise((resolve12, reject) => {
|
|
41272
41634
|
let fd;
|
|
41273
41635
|
const fs = (0, node_1.default)();
|
|
41274
41636
|
const handler = (err, buffer) => {
|
|
@@ -41278,7 +41640,7 @@ var require_lib2 = __commonJS({
|
|
|
41278
41640
|
if (err) {
|
|
41279
41641
|
reject(err);
|
|
41280
41642
|
} else if (buffer) {
|
|
41281
|
-
|
|
41643
|
+
resolve12((0, exports.detect)(buffer));
|
|
41282
41644
|
} else {
|
|
41283
41645
|
reject(new Error("No error and no buffer received"));
|
|
41284
41646
|
}
|
|
@@ -46658,7 +47020,7 @@ __export(signupFlow_exports, {
|
|
|
46658
47020
|
});
|
|
46659
47021
|
import { spawn as spawn11, spawnSync as spawnSync7 } from "node:child_process";
|
|
46660
47022
|
import {
|
|
46661
|
-
existsSync as
|
|
47023
|
+
existsSync as existsSync16,
|
|
46662
47024
|
constants as fsConstants,
|
|
46663
47025
|
mkdirSync as mkdirSync14,
|
|
46664
47026
|
mkdtempSync as mkdtempSync5,
|
|
@@ -46670,7 +47032,7 @@ import {
|
|
|
46670
47032
|
} from "node:fs";
|
|
46671
47033
|
import { access } from "node:fs/promises";
|
|
46672
47034
|
import { homedir as homedir15, tmpdir as tmpdir4 } from "node:os";
|
|
46673
|
-
import { delimiter as delimiter3, dirname as dirname16, join as join21, resolve as
|
|
47035
|
+
import { delimiter as delimiter3, dirname as dirname16, join as join21, resolve as resolve10 } from "node:path";
|
|
46674
47036
|
import { stdin as defaultStdin, stdout as defaultStdout } from "node:process";
|
|
46675
47037
|
import { emitKeypressEvents } from "node:readline";
|
|
46676
47038
|
function signupHelpText() {
|
|
@@ -46786,7 +47148,7 @@ function defaultSignupDraftStore(serviceUrl) {
|
|
|
46786
47148
|
const path2 = defaultSignupDraftPath(serviceUrl);
|
|
46787
47149
|
return {
|
|
46788
47150
|
read: () => {
|
|
46789
|
-
if (!
|
|
47151
|
+
if (!existsSync16(path2)) {
|
|
46790
47152
|
return void 0;
|
|
46791
47153
|
}
|
|
46792
47154
|
let parsed;
|
|
@@ -46865,7 +47227,7 @@ function defaultSignupTaskCachePath(serviceUrl) {
|
|
|
46865
47227
|
);
|
|
46866
47228
|
}
|
|
46867
47229
|
function readSignupTaskCache(path2) {
|
|
46868
|
-
if (!
|
|
47230
|
+
if (!existsSync16(path2)) {
|
|
46869
47231
|
return { version: 1, entries: {} };
|
|
46870
47232
|
}
|
|
46871
47233
|
let parsed;
|
|
@@ -48184,11 +48546,11 @@ async function openUrlInBrowser(url) {
|
|
|
48184
48546
|
return;
|
|
48185
48547
|
}
|
|
48186
48548
|
const [command, args] = process.platform === "darwin" ? ["open", [url]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", url]] : ["xdg-open", [url]];
|
|
48187
|
-
await new Promise((
|
|
48549
|
+
await new Promise((resolve12, reject) => {
|
|
48188
48550
|
const child = spawn11(command, args, { stdio: "ignore", detached: true });
|
|
48189
48551
|
child.once("spawn", () => {
|
|
48190
48552
|
child.unref();
|
|
48191
|
-
|
|
48553
|
+
resolve12();
|
|
48192
48554
|
});
|
|
48193
48555
|
child.once("error", reject);
|
|
48194
48556
|
});
|
|
@@ -48403,7 +48765,7 @@ function runProjectPickerPrompt(input, output, args) {
|
|
|
48403
48765
|
(answer) => answer.split(",").map((path2) => path2.trim()).filter((path2) => path2 !== "")
|
|
48404
48766
|
);
|
|
48405
48767
|
}
|
|
48406
|
-
return new Promise((
|
|
48768
|
+
return new Promise((resolve12, reject) => {
|
|
48407
48769
|
emitKeypressEvents(keypressInput);
|
|
48408
48770
|
keypressInput.setRawMode?.(true);
|
|
48409
48771
|
keypressInput.resume?.();
|
|
@@ -48467,7 +48829,7 @@ function runProjectPickerPrompt(input, output, args) {
|
|
|
48467
48829
|
}
|
|
48468
48830
|
cleanup();
|
|
48469
48831
|
clearRenderedLines(output, renderedLines);
|
|
48470
|
-
|
|
48832
|
+
resolve12([...selectedPaths]);
|
|
48471
48833
|
};
|
|
48472
48834
|
const toggleHighlighted = () => {
|
|
48473
48835
|
const highlightedRow = rows()[highlightIndex];
|
|
@@ -49267,7 +49629,7 @@ function resolveHomePath(path2, homeDir) {
|
|
|
49267
49629
|
if (path2.startsWith("~/")) {
|
|
49268
49630
|
return join21(homeDir, path2.slice(2));
|
|
49269
49631
|
}
|
|
49270
|
-
return
|
|
49632
|
+
return resolve10(path2);
|
|
49271
49633
|
}
|
|
49272
49634
|
function resolveCodexCommandOverride(command, homeDir) {
|
|
49273
49635
|
const trimmed = command.trim();
|
|
@@ -49650,7 +50012,7 @@ function spawnSyncGitOutput(args, cwd) {
|
|
|
49650
50012
|
}
|
|
49651
50013
|
}
|
|
49652
50014
|
function probeToolWithArgs(command, args, cwd) {
|
|
49653
|
-
return new Promise((
|
|
50015
|
+
return new Promise((resolve12) => {
|
|
49654
50016
|
const child = spawn11(command, [...args], {
|
|
49655
50017
|
cwd,
|
|
49656
50018
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -49663,7 +50025,7 @@ function probeToolWithArgs(command, args, cwd) {
|
|
|
49663
50025
|
}
|
|
49664
50026
|
settled = true;
|
|
49665
50027
|
clearTimeout(timeout);
|
|
49666
|
-
|
|
50028
|
+
resolve12(status);
|
|
49667
50029
|
};
|
|
49668
50030
|
const timeout = setTimeout(() => {
|
|
49669
50031
|
child.kill("SIGKILL");
|
|
@@ -49689,7 +50051,7 @@ async function discoverCodeRoots(homeDir) {
|
|
|
49689
50051
|
const candidates = ["src", "code", "projects"].map(
|
|
49690
50052
|
(name) => join21(homeDir, name)
|
|
49691
50053
|
);
|
|
49692
|
-
return candidates.filter((path2) =>
|
|
50054
|
+
return candidates.filter((path2) => existsSync16(path2)).flatMap((path2) => discoveredProjectNames(path2));
|
|
49693
50055
|
}
|
|
49694
50056
|
function discoveredProjectNames(root) {
|
|
49695
50057
|
try {
|
|
@@ -49793,25 +50155,25 @@ function looksLikeProject(path2) {
|
|
|
49793
50155
|
"pnpm-lock.yaml",
|
|
49794
50156
|
"yarn.lock",
|
|
49795
50157
|
"package-lock.json"
|
|
49796
|
-
].some((name) =>
|
|
50158
|
+
].some((name) => existsSync16(join21(path2, name)));
|
|
49797
50159
|
}
|
|
49798
50160
|
function detectProjectLanguage(path2) {
|
|
49799
|
-
if (
|
|
50161
|
+
if (existsSync16(join21(path2, "pyproject.toml")) || existsSync16(join21(path2, "requirements.txt"))) {
|
|
49800
50162
|
return "Python";
|
|
49801
50163
|
}
|
|
49802
|
-
if (
|
|
50164
|
+
if (existsSync16(join21(path2, "Cargo.toml"))) {
|
|
49803
50165
|
return "Rust";
|
|
49804
50166
|
}
|
|
49805
|
-
if (
|
|
50167
|
+
if (existsSync16(join21(path2, "go.mod"))) {
|
|
49806
50168
|
return "Go";
|
|
49807
50169
|
}
|
|
49808
|
-
if (
|
|
50170
|
+
if (existsSync16(join21(path2, "mix.exs"))) {
|
|
49809
50171
|
return "Elixir";
|
|
49810
50172
|
}
|
|
49811
|
-
if (
|
|
50173
|
+
if (existsSync16(join21(path2, "tsconfig.json")) || packageJsonMentionsTypeScript(path2)) {
|
|
49812
50174
|
return "TypeScript";
|
|
49813
50175
|
}
|
|
49814
|
-
if (
|
|
50176
|
+
if (existsSync16(join21(path2, "package.json"))) {
|
|
49815
50177
|
return "JavaScript";
|
|
49816
50178
|
}
|
|
49817
50179
|
return "Project";
|
|
@@ -49827,7 +50189,7 @@ function packageJsonMentionsTypeScript(path2) {
|
|
|
49827
50189
|
}
|
|
49828
50190
|
}
|
|
49829
50191
|
function hasGitMetadata(path2) {
|
|
49830
|
-
return
|
|
50192
|
+
return existsSync16(join21(path2, ".git"));
|
|
49831
50193
|
}
|
|
49832
50194
|
function childDirectories(root) {
|
|
49833
50195
|
try {
|
|
@@ -49862,7 +50224,7 @@ function expandHomePath(path2) {
|
|
|
49862
50224
|
if (path2.startsWith("~/")) {
|
|
49863
50225
|
return join21(homedir15(), path2.slice(2));
|
|
49864
50226
|
}
|
|
49865
|
-
return
|
|
50227
|
+
return resolve10(path2);
|
|
49866
50228
|
}
|
|
49867
50229
|
function summarizeCodeRoots(roots) {
|
|
49868
50230
|
const first = roots[0];
|
|
@@ -49949,9 +50311,9 @@ secure mission control for all your agents on your computers
|
|
|
49949
50311
|
init_runner();
|
|
49950
50312
|
init_claudeCodeSession();
|
|
49951
50313
|
init_authCache();
|
|
49952
|
-
import { existsSync as
|
|
50314
|
+
import { existsSync as existsSync17, readFileSync as readFileSync21, realpathSync as realpathSync7 } from "node:fs";
|
|
49953
50315
|
import { homedir as homedir16 } from "node:os";
|
|
49954
|
-
import { resolve as
|
|
50316
|
+
import { resolve as resolve11 } from "node:path";
|
|
49955
50317
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
49956
50318
|
|
|
49957
50319
|
// src/authResolution.ts
|
|
@@ -50012,7 +50374,7 @@ init_kandanTls();
|
|
|
50012
50374
|
init_protocol();
|
|
50013
50375
|
init_json();
|
|
50014
50376
|
init_defaultUrls();
|
|
50015
|
-
import { existsSync as
|
|
50377
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync12, readFileSync as readFileSync17, writeFileSync as writeFileSync10 } from "node:fs";
|
|
50016
50378
|
import { dirname as dirname14, join as join19 } from "node:path";
|
|
50017
50379
|
import { homedir as homedir13 } from "node:os";
|
|
50018
50380
|
async function runAgentCliCommand(args, deps = {
|
|
@@ -50731,7 +51093,7 @@ function authorizationHeaders(token) {
|
|
|
50731
51093
|
return { authorization: `Bearer ${token}` };
|
|
50732
51094
|
}
|
|
50733
51095
|
function readOptionalTextFile(path2) {
|
|
50734
|
-
return
|
|
51096
|
+
return existsSync14(path2) ? readFileSync17(path2, "utf8") : void 0;
|
|
50735
51097
|
}
|
|
50736
51098
|
function writeTextFile(path2, content) {
|
|
50737
51099
|
mkdirSync12(dirname14(path2), { recursive: true });
|
|
@@ -50822,7 +51184,7 @@ init_helloLinzumiProject();
|
|
|
50822
51184
|
// src/commanderDaemon.ts
|
|
50823
51185
|
init_runnerLogger();
|
|
50824
51186
|
import {
|
|
50825
|
-
existsSync as
|
|
51187
|
+
existsSync as existsSync15,
|
|
50826
51188
|
closeSync as closeSync3,
|
|
50827
51189
|
mkdirSync as mkdirSync13,
|
|
50828
51190
|
openSync as openSync4,
|
|
@@ -50831,7 +51193,7 @@ import {
|
|
|
50831
51193
|
writeFileSync as writeFileSync11
|
|
50832
51194
|
} from "node:fs";
|
|
50833
51195
|
import { homedir as homedir14 } from "node:os";
|
|
50834
|
-
import { dirname as dirname15, join as join20, resolve as
|
|
51196
|
+
import { dirname as dirname15, join as join20, resolve as resolve9 } from "node:path";
|
|
50835
51197
|
import { execFileSync, spawn as spawn9 } from "node:child_process";
|
|
50836
51198
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
50837
51199
|
var connectedMarkers = ["Connected to Linzumi", "Runner connected:"];
|
|
@@ -50850,7 +51212,7 @@ function commanderLogIsConnected(log2) {
|
|
|
50850
51212
|
function startCommanderDaemon(options) {
|
|
50851
51213
|
const statusDir = options.statusDir ?? commanderStatusDir();
|
|
50852
51214
|
const statusFile = commanderStatusFile(options.runnerId, statusDir);
|
|
50853
|
-
const logFile =
|
|
51215
|
+
const logFile = resolve9(
|
|
50854
51216
|
options.logFile ?? defaultCommanderLogFile(options.runnerId)
|
|
50855
51217
|
);
|
|
50856
51218
|
const entrypoint = options.entrypoint ?? currentEntrypoint();
|
|
@@ -50916,7 +51278,7 @@ function startCommanderDaemon(options) {
|
|
|
50916
51278
|
}
|
|
50917
51279
|
function commanderDaemonStatus(runnerId, statusDir = commanderStatusDir(), processIdentityReader = readProcessIdentity) {
|
|
50918
51280
|
const statusFile = commanderStatusFile(runnerId, statusDir);
|
|
50919
|
-
if (!
|
|
51281
|
+
if (!existsSync15(statusFile)) {
|
|
50920
51282
|
return { status: "missing", runnerId, statusFile };
|
|
50921
51283
|
}
|
|
50922
51284
|
const record = parseRecord(readFileSync18(statusFile, "utf8"));
|
|
@@ -50924,7 +51286,7 @@ function commanderDaemonStatus(runnerId, statusDir = commanderStatusDir(), proce
|
|
|
50924
51286
|
}
|
|
50925
51287
|
async function waitForCommanderDaemon(options) {
|
|
50926
51288
|
const now = options.now ?? (() => Date.now());
|
|
50927
|
-
const readTextFile = options.readTextFile ?? ((path2) =>
|
|
51289
|
+
const readTextFile = options.readTextFile ?? ((path2) => existsSync15(path2) ? readFileSync18(path2, "utf8") : void 0);
|
|
50928
51290
|
const statusImpl = options.statusImpl ?? commanderDaemonStatus;
|
|
50929
51291
|
const deadline = now() + options.timeoutMs;
|
|
50930
51292
|
while (now() <= deadline) {
|
|
@@ -51092,7 +51454,7 @@ function safeRunnerId(runnerId) {
|
|
|
51092
51454
|
}
|
|
51093
51455
|
async function waitForFileChangeOrTimeout(path2, deadline, now, ready2 = () => false) {
|
|
51094
51456
|
const remaining = Math.max(0, deadline - now());
|
|
51095
|
-
return new Promise((
|
|
51457
|
+
return new Promise((resolve12) => {
|
|
51096
51458
|
let resolved = false;
|
|
51097
51459
|
let watcher;
|
|
51098
51460
|
const finish = (connected) => {
|
|
@@ -51102,7 +51464,7 @@ async function waitForFileChangeOrTimeout(path2, deadline, now, ready2 = () => f
|
|
|
51102
51464
|
resolved = true;
|
|
51103
51465
|
watcher?.close();
|
|
51104
51466
|
clearTimeout(timer);
|
|
51105
|
-
|
|
51467
|
+
resolve12(connected);
|
|
51106
51468
|
};
|
|
51107
51469
|
const timer = setTimeout(() => finish(false), remaining);
|
|
51108
51470
|
try {
|
|
@@ -56376,7 +56738,7 @@ var Protocol = class {
|
|
|
56376
56738
|
*/
|
|
56377
56739
|
request(request, resultSchema, options) {
|
|
56378
56740
|
const { relatedRequestId, resumptionToken, onresumptiontoken } = options !== null && options !== void 0 ? options : {};
|
|
56379
|
-
return new Promise((
|
|
56741
|
+
return new Promise((resolve12, reject) => {
|
|
56380
56742
|
var _a, _b, _c, _d, _e, _f;
|
|
56381
56743
|
if (!this._transport) {
|
|
56382
56744
|
reject(new Error("Not connected"));
|
|
@@ -56427,7 +56789,7 @@ var Protocol = class {
|
|
|
56427
56789
|
}
|
|
56428
56790
|
try {
|
|
56429
56791
|
const result = resultSchema.parse(response.result);
|
|
56430
|
-
|
|
56792
|
+
resolve12(result);
|
|
56431
56793
|
} catch (error) {
|
|
56432
56794
|
reject(error);
|
|
56433
56795
|
}
|
|
@@ -58777,12 +59139,12 @@ var StdioServerTransport = class {
|
|
|
58777
59139
|
(_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
58778
59140
|
}
|
|
58779
59141
|
send(message) {
|
|
58780
|
-
return new Promise((
|
|
59142
|
+
return new Promise((resolve12) => {
|
|
58781
59143
|
const json = serializeMessage(message);
|
|
58782
59144
|
if (this._stdout.write(json)) {
|
|
58783
|
-
|
|
59145
|
+
resolve12();
|
|
58784
59146
|
} else {
|
|
58785
|
-
this._stdout.once("drain",
|
|
59147
|
+
this._stdout.once("drain", resolve12);
|
|
58786
59148
|
}
|
|
58787
59149
|
});
|
|
58788
59150
|
}
|
|
@@ -64012,9 +64374,9 @@ function remoteHarnessRunnerJoinPayload(config) {
|
|
|
64012
64374
|
};
|
|
64013
64375
|
}
|
|
64014
64376
|
function defaultWaitUntilShutdown(cleanup) {
|
|
64015
|
-
return new Promise((
|
|
64377
|
+
return new Promise((resolve12, reject) => {
|
|
64016
64378
|
const finish = () => {
|
|
64017
|
-
cleanup().then(
|
|
64379
|
+
cleanup().then(resolve12, reject);
|
|
64018
64380
|
};
|
|
64019
64381
|
process.once("SIGINT", finish);
|
|
64020
64382
|
process.once("SIGTERM", finish);
|
|
@@ -64034,9 +64396,9 @@ function waitForCodexAppServerExit(child) {
|
|
|
64034
64396
|
signal: child.signalCode
|
|
64035
64397
|
});
|
|
64036
64398
|
}
|
|
64037
|
-
return new Promise((
|
|
64399
|
+
return new Promise((resolve12) => {
|
|
64038
64400
|
child.once("exit", (code, signal) => {
|
|
64039
|
-
|
|
64401
|
+
resolve12({ code, signal });
|
|
64040
64402
|
});
|
|
64041
64403
|
});
|
|
64042
64404
|
}
|
|
@@ -64111,6 +64473,11 @@ var flagDefinitions = /* @__PURE__ */ new Map([
|
|
|
64111
64473
|
["reasoning-effort", { kind: "value" }],
|
|
64112
64474
|
["sandbox", { kind: "value" }],
|
|
64113
64475
|
["approval-policy", { kind: "value" }],
|
|
64476
|
+
// Thread-worker-only flags: wafer-routed codex threads carry their model
|
|
64477
|
+
// transport selector and Kandan LLM proxy base URL through the worker argv
|
|
64478
|
+
// (the credential travels via LINZUMI_LLM_PROXY_TOKEN env).
|
|
64479
|
+
["model-provider", { kind: "value" }],
|
|
64480
|
+
["llm-proxy-base-url", { kind: "value" }],
|
|
64114
64481
|
["allow-port-forwarding-by-default", { kind: "boolean" }],
|
|
64115
64482
|
["stream-flush-ms", { kind: "value" }],
|
|
64116
64483
|
["allowed-cwd", { kind: "value" }],
|
|
@@ -64154,7 +64521,7 @@ function isMainModule() {
|
|
|
64154
64521
|
if (scriptPath === void 0) {
|
|
64155
64522
|
return false;
|
|
64156
64523
|
}
|
|
64157
|
-
return fileURLToPath4(import.meta.url) ===
|
|
64524
|
+
return fileURLToPath4(import.meta.url) === resolve11(scriptPath);
|
|
64158
64525
|
}
|
|
64159
64526
|
async function main(args) {
|
|
64160
64527
|
const parsed = parseCommand(args);
|
|
@@ -64406,7 +64773,7 @@ function runPathsCommand(args) {
|
|
|
64406
64773
|
if (pathValue === void 0 || pathValue.trim() === "") {
|
|
64407
64774
|
throw new Error("missing path for linzumi paths add");
|
|
64408
64775
|
}
|
|
64409
|
-
const trustedPath = realpathSync7(
|
|
64776
|
+
const trustedPath = realpathSync7(resolve11(expandUserPath(pathValue)));
|
|
64410
64777
|
if (linzumiUrl === void 0) {
|
|
64411
64778
|
addAllowedCwd(pathValue);
|
|
64412
64779
|
} else {
|
|
@@ -64801,7 +65168,7 @@ async function parseAgentRunnerArgs(args, deps = {
|
|
|
64801
65168
|
};
|
|
64802
65169
|
}
|
|
64803
65170
|
function readAgentTokenTextFile(path2) {
|
|
64804
|
-
return
|
|
65171
|
+
return existsSync17(path2) ? readFileSync21(path2, "utf8") : void 0;
|
|
64805
65172
|
}
|
|
64806
65173
|
function rejectAgentRunnerTargetingFlags(values) {
|
|
64807
65174
|
const unsupportedFlags = [
|
|
@@ -65115,9 +65482,9 @@ function resolveUserPath(pathValue) {
|
|
|
65115
65482
|
return homedir16();
|
|
65116
65483
|
}
|
|
65117
65484
|
if (pathValue.startsWith("~/")) {
|
|
65118
|
-
return
|
|
65485
|
+
return resolve11(homedir16(), pathValue.slice(2));
|
|
65119
65486
|
}
|
|
65120
|
-
return
|
|
65487
|
+
return resolve11(pathValue);
|
|
65121
65488
|
}
|
|
65122
65489
|
function defaultListenUserFromToken(token) {
|
|
65123
65490
|
const username = identityFromAccessToken(token).actorUsername;
|
|
@@ -65209,9 +65576,34 @@ function parseThreadCodexWorkerArgs(args) {
|
|
|
65209
65576
|
role: "thread",
|
|
65210
65577
|
kandanThreadId
|
|
65211
65578
|
},
|
|
65579
|
+
codexModelProvider: threadRunnerCodexModelProvider(values),
|
|
65212
65580
|
channelSession: void 0
|
|
65213
65581
|
};
|
|
65214
65582
|
}
|
|
65583
|
+
function threadRunnerCodexModelProvider(values) {
|
|
65584
|
+
const modelProvider = stringValue7(values, "model-provider");
|
|
65585
|
+
if (modelProvider === void 0) {
|
|
65586
|
+
return void 0;
|
|
65587
|
+
}
|
|
65588
|
+
if (modelProvider !== "wafer") {
|
|
65589
|
+
throw new Error(`unsupported --model-provider: ${modelProvider}`);
|
|
65590
|
+
}
|
|
65591
|
+
const llmProxyBaseUrl = stringValue7(values, "llm-proxy-base-url");
|
|
65592
|
+
const llmProxyToken = process.env.LINZUMI_LLM_PROXY_TOKEN?.trim();
|
|
65593
|
+
if (llmProxyBaseUrl === void 0) {
|
|
65594
|
+
throw new Error("--model-provider wafer requires --llm-proxy-base-url");
|
|
65595
|
+
}
|
|
65596
|
+
if (llmProxyToken === void 0 || llmProxyToken === "") {
|
|
65597
|
+
throw new Error(
|
|
65598
|
+
"--model-provider wafer requires the LINZUMI_LLM_PROXY_TOKEN env credential"
|
|
65599
|
+
);
|
|
65600
|
+
}
|
|
65601
|
+
return {
|
|
65602
|
+
provider: "wafer",
|
|
65603
|
+
llmProxyBaseUrl,
|
|
65604
|
+
llmProxyToken
|
|
65605
|
+
};
|
|
65606
|
+
}
|
|
65215
65607
|
function requiredThreadRunnerKandanThreadId() {
|
|
65216
65608
|
const kandanThreadId = process.env.LINZUMI_THREAD_RUNNER_KANDAN_THREAD_ID;
|
|
65217
65609
|
if (kandanThreadId === void 0 || kandanThreadId.trim() === "") {
|