@linzumi/cli 0.0.70-beta → 0.0.72-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 +752 -268
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -987,7 +987,7 @@ function codexOutputMessagesForItem(item, index) {
|
|
|
987
987
|
}
|
|
988
988
|
}
|
|
989
989
|
function codexOutputMessagesForItems(items) {
|
|
990
|
-
const
|
|
990
|
+
const consumedCallOutputKeys = /* @__PURE__ */ new Set();
|
|
991
991
|
return items.flatMap((item, index) => {
|
|
992
992
|
const itemType = stringValue(item.type);
|
|
993
993
|
switch (itemType) {
|
|
@@ -997,9 +997,9 @@ function codexOutputMessagesForItems(items) {
|
|
|
997
997
|
"function_call_output",
|
|
998
998
|
stringValue(item.call_id)
|
|
999
999
|
);
|
|
1000
|
-
const
|
|
1001
|
-
if (
|
|
1002
|
-
|
|
1000
|
+
const outputKey = callOutputConsumeKey(output);
|
|
1001
|
+
if (outputKey !== void 0) {
|
|
1002
|
+
consumedCallOutputKeys.add(outputKey);
|
|
1003
1003
|
}
|
|
1004
1004
|
return commandMessageForFunctionCall(item, output, index);
|
|
1005
1005
|
}
|
|
@@ -1009,22 +1009,33 @@ function codexOutputMessagesForItems(items) {
|
|
|
1009
1009
|
"custom_tool_call_output",
|
|
1010
1010
|
stringValue(item.call_id)
|
|
1011
1011
|
);
|
|
1012
|
-
const
|
|
1013
|
-
if (
|
|
1014
|
-
|
|
1012
|
+
const outputKey = callOutputConsumeKey(output);
|
|
1013
|
+
if (outputKey !== void 0) {
|
|
1014
|
+
consumedCallOutputKeys.add(outputKey);
|
|
1015
1015
|
}
|
|
1016
1016
|
return messageForCustomToolCall(item, output, index);
|
|
1017
1017
|
}
|
|
1018
1018
|
case "function_call_output":
|
|
1019
1019
|
case "custom_tool_call_output": {
|
|
1020
|
-
const
|
|
1021
|
-
return
|
|
1020
|
+
const outputKey = callOutputConsumeKey(item);
|
|
1021
|
+
return outputKey !== void 0 && consumedCallOutputKeys.has(outputKey) ? [] : commandMessageForUnpairedToolOutput(item, index);
|
|
1022
1022
|
}
|
|
1023
1023
|
default:
|
|
1024
1024
|
return codexOutputMessagesForItem(item, index);
|
|
1025
1025
|
}
|
|
1026
1026
|
});
|
|
1027
1027
|
}
|
|
1028
|
+
function callOutputConsumeKey(item) {
|
|
1029
|
+
if (item === void 0) {
|
|
1030
|
+
return void 0;
|
|
1031
|
+
}
|
|
1032
|
+
const id = stringValue(item.id);
|
|
1033
|
+
if (id !== void 0) {
|
|
1034
|
+
return `id:${id}`;
|
|
1035
|
+
}
|
|
1036
|
+
const callId = stringValue(item.call_id);
|
|
1037
|
+
return callId === void 0 ? void 0 : `call_id:${callId}`;
|
|
1038
|
+
}
|
|
1028
1039
|
function codexAssistantDeltaFromNotification(params) {
|
|
1029
1040
|
const delta = assistantDeltaText(params);
|
|
1030
1041
|
if (delta === void 0 || delta === "") {
|
|
@@ -1078,10 +1089,13 @@ function codexCommandOutputDeltaFromNotification(params) {
|
|
|
1078
1089
|
return void 0;
|
|
1079
1090
|
}
|
|
1080
1091
|
const processId = stringValue(params.processId) ?? stringValue(params.process_id);
|
|
1092
|
+
const item = objectValue(params.item);
|
|
1093
|
+
const command = nonBlankStringValue(params.command) ?? nonBlankStringValue(params.cmd) ?? nonBlankStringValue(item?.command) ?? nonBlankStringValue(item?.cmd);
|
|
1081
1094
|
return {
|
|
1082
|
-
itemKey: stringValue(params.itemId) ?? stringValue(params.item_id) ?? stringValue(
|
|
1095
|
+
itemKey: stringValue(params.itemId) ?? stringValue(params.item_id) ?? stringValue(item?.id) ?? processId ?? "command-output",
|
|
1083
1096
|
turnId: stringValue(params.turnId) ?? stringValue(params.turn_id) ?? stringValue(objectValue(params.turn)?.id),
|
|
1084
1097
|
processId,
|
|
1098
|
+
command,
|
|
1085
1099
|
stream: stringValue(params.stream) ?? "stdout",
|
|
1086
1100
|
delta
|
|
1087
1101
|
};
|
|
@@ -1658,6 +1672,131 @@ var init_codexOutput = __esm({
|
|
|
1658
1672
|
}
|
|
1659
1673
|
});
|
|
1660
1674
|
|
|
1675
|
+
// src/codexSessionLog.ts
|
|
1676
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
1677
|
+
import { homedir as homedir2 } from "node:os";
|
|
1678
|
+
import { join as join2 } from "node:path";
|
|
1679
|
+
function codexSessionLogOutputMessagesForTurn(args) {
|
|
1680
|
+
const path2 = codexSessionLogPath(args.codexThreadId, args.codexHome);
|
|
1681
|
+
if (path2 === void 0) {
|
|
1682
|
+
return [];
|
|
1683
|
+
}
|
|
1684
|
+
const content = readFileSync(path2, "utf8");
|
|
1685
|
+
const items = codexSessionLogResponseItemsForTurn(content, args.turnId);
|
|
1686
|
+
if (items.length === 0) {
|
|
1687
|
+
return [];
|
|
1688
|
+
}
|
|
1689
|
+
const response = {
|
|
1690
|
+
jsonrpc: "2.0",
|
|
1691
|
+
id: 1,
|
|
1692
|
+
result: {
|
|
1693
|
+
thread: {
|
|
1694
|
+
turns: [
|
|
1695
|
+
{
|
|
1696
|
+
id: args.turnId,
|
|
1697
|
+
items
|
|
1698
|
+
}
|
|
1699
|
+
]
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
};
|
|
1703
|
+
return codexOutputMessagesForTurn(response, args.turnId);
|
|
1704
|
+
}
|
|
1705
|
+
function codexSessionLogPath(codexThreadId, codexHome) {
|
|
1706
|
+
const root = codexHome ?? process.env.CODEX_HOME ?? join2(homedir2(), ".codex");
|
|
1707
|
+
const sessionsRoot = join2(root, "sessions");
|
|
1708
|
+
const candidateDirectories = recentCodexSessionDateDirectories(sessionsRoot);
|
|
1709
|
+
for (const directory of candidateDirectories) {
|
|
1710
|
+
const match = findCodexSessionLogPath(directory, codexThreadId);
|
|
1711
|
+
if (match !== void 0) {
|
|
1712
|
+
return match;
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
return void 0;
|
|
1716
|
+
}
|
|
1717
|
+
function findCodexSessionLogPath(directory, codexThreadId) {
|
|
1718
|
+
let entries;
|
|
1719
|
+
try {
|
|
1720
|
+
entries = readdirSync(directory, { withFileTypes: true });
|
|
1721
|
+
} catch {
|
|
1722
|
+
return void 0;
|
|
1723
|
+
}
|
|
1724
|
+
const directMatch = entries.filter((entry) => entry.isFile()).map((entry) => entry.name).filter((name) => name.endsWith(".jsonl") && name.includes(codexThreadId)).sort().at(-1);
|
|
1725
|
+
if (directMatch !== void 0) {
|
|
1726
|
+
return join2(directory, directMatch);
|
|
1727
|
+
}
|
|
1728
|
+
const directories = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort().reverse();
|
|
1729
|
+
for (const name of directories) {
|
|
1730
|
+
const match = findCodexSessionLogPath(join2(directory, name), codexThreadId);
|
|
1731
|
+
if (match !== void 0) {
|
|
1732
|
+
return match;
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
return void 0;
|
|
1736
|
+
}
|
|
1737
|
+
function recentCodexSessionDateDirectories(sessionsRoot) {
|
|
1738
|
+
const now = /* @__PURE__ */ new Date();
|
|
1739
|
+
const today = codexSessionDateDirectory(sessionsRoot, now);
|
|
1740
|
+
const yesterday = codexSessionDateDirectory(
|
|
1741
|
+
sessionsRoot,
|
|
1742
|
+
new Date(now.getTime() - 24 * 60 * 60 * 1e3)
|
|
1743
|
+
);
|
|
1744
|
+
return today === yesterday ? [today] : [today, yesterday];
|
|
1745
|
+
}
|
|
1746
|
+
function codexSessionDateDirectory(sessionsRoot, date) {
|
|
1747
|
+
const year = String(date.getFullYear());
|
|
1748
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
1749
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
1750
|
+
return join2(sessionsRoot, year, month, day);
|
|
1751
|
+
}
|
|
1752
|
+
function codexSessionLogResponseItemsForTurn(content, targetTurnId) {
|
|
1753
|
+
let activeTurnId2;
|
|
1754
|
+
const items = [];
|
|
1755
|
+
for (const line of content.split("\n")) {
|
|
1756
|
+
if (line.trim() === "") {
|
|
1757
|
+
continue;
|
|
1758
|
+
}
|
|
1759
|
+
const record = parseJsonObject(line);
|
|
1760
|
+
if (record === void 0) {
|
|
1761
|
+
continue;
|
|
1762
|
+
}
|
|
1763
|
+
const payload = objectPayload(record);
|
|
1764
|
+
const recordType3 = stringValue(record.type);
|
|
1765
|
+
const payloadType = stringValue(payload?.type);
|
|
1766
|
+
const nextTurnId = recordType3 === "turn_context" ? stringValue(payload?.turn_id) : payloadType === "task_started" ? stringValue(payload?.turn_id) : void 0;
|
|
1767
|
+
if (nextTurnId !== void 0) {
|
|
1768
|
+
activeTurnId2 = nextTurnId;
|
|
1769
|
+
}
|
|
1770
|
+
if (recordType3 === "response_item" && activeTurnId2 === targetTurnId && payload !== void 0) {
|
|
1771
|
+
items.push(payload);
|
|
1772
|
+
}
|
|
1773
|
+
if (payloadType === "task_complete" && stringValue(payload?.turn_id) === targetTurnId) {
|
|
1774
|
+
activeTurnId2 = void 0;
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
return items;
|
|
1778
|
+
}
|
|
1779
|
+
function parseJsonObject(line) {
|
|
1780
|
+
try {
|
|
1781
|
+
const parsed = JSON.parse(line);
|
|
1782
|
+
return isJsonObject(parsed) ? parsed : void 0;
|
|
1783
|
+
} catch {
|
|
1784
|
+
return void 0;
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
function objectPayload(record) {
|
|
1788
|
+
const payload = record.payload;
|
|
1789
|
+
return isJsonObject(payload) ? payload : void 0;
|
|
1790
|
+
}
|
|
1791
|
+
var init_codexSessionLog = __esm({
|
|
1792
|
+
"src/codexSessionLog.ts"() {
|
|
1793
|
+
"use strict";
|
|
1794
|
+
init_codexOutput();
|
|
1795
|
+
init_protocol();
|
|
1796
|
+
init_json();
|
|
1797
|
+
}
|
|
1798
|
+
});
|
|
1799
|
+
|
|
1661
1800
|
// src/kandanQueue.ts
|
|
1662
1801
|
function formatQueuedKandanMessage(message) {
|
|
1663
1802
|
const sender2 = message.actorSlug === void 0 || message.actorSlug.trim() === "" ? "unknown" : message.actorSlug.trim();
|
|
@@ -2236,6 +2375,7 @@ function coalesceCommandOutputDeltas(deltas) {
|
|
|
2236
2375
|
coalesced.set(key, {
|
|
2237
2376
|
...delta,
|
|
2238
2377
|
processId: delta.processId ?? existing.processId,
|
|
2378
|
+
command: delta.command ?? existing.command,
|
|
2239
2379
|
delta: `${existing.delta}${delta.delta}`
|
|
2240
2380
|
});
|
|
2241
2381
|
}
|
|
@@ -3724,6 +3864,8 @@ function initialChannelSessionState(cursor, rootSeq, kandanThreadId, codexThread
|
|
|
3724
3864
|
streamingAssistantOutputs: createBoundedCache(maxForwardedTurnIds),
|
|
3725
3865
|
streamingReasoningOutputs: createBoundedCache(maxForwardedTurnIds),
|
|
3726
3866
|
streamingCommandOutputs: createBoundedCache(maxForwardedTurnIds),
|
|
3867
|
+
pendingCommandOutputs: createBoundedCache(maxForwardedTurnIds),
|
|
3868
|
+
observedCommandOutputCommands: createBoundedCache(maxForwardedTurnIds * 3),
|
|
3727
3869
|
streamingFileChangeOutputs: createBoundedCache(maxForwardedTurnIds),
|
|
3728
3870
|
assistantDeltaQueue: createStreamDeltaQueue(),
|
|
3729
3871
|
reasoningDeltaQueue: createStreamDeltaQueue(),
|
|
@@ -3927,7 +4069,10 @@ async function handleChannelSessionControl(args, state, payloadContext, control)
|
|
|
3927
4069
|
interruptedActiveSeq,
|
|
3928
4070
|
{
|
|
3929
4071
|
status: "processed"
|
|
3930
|
-
}
|
|
4072
|
+
},
|
|
4073
|
+
void 0,
|
|
4074
|
+
void 0,
|
|
4075
|
+
state.codexThreadId
|
|
3931
4076
|
);
|
|
3932
4077
|
break;
|
|
3933
4078
|
case "starting":
|
|
@@ -3951,10 +4096,18 @@ async function handleChannelSessionControl(args, state, payloadContext, control)
|
|
|
3951
4096
|
});
|
|
3952
4097
|
if (interrupted.ok) {
|
|
3953
4098
|
for (const seq of interrupted.selectedSeqs) {
|
|
3954
|
-
await publishMessageState(
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
4099
|
+
await publishMessageState(
|
|
4100
|
+
args,
|
|
4101
|
+
state.kandanThreadId,
|
|
4102
|
+
seq,
|
|
4103
|
+
{
|
|
4104
|
+
status: "processing",
|
|
4105
|
+
reason: "interrupt requested"
|
|
4106
|
+
},
|
|
4107
|
+
void 0,
|
|
4108
|
+
void 0,
|
|
4109
|
+
state.codexThreadId
|
|
4110
|
+
);
|
|
3958
4111
|
}
|
|
3959
4112
|
}
|
|
3960
4113
|
await drainKandanMessageQueue(args, state, payloadContext);
|
|
@@ -4223,6 +4376,9 @@ async function resolvePendingPortForwardRequest(args, state, payloadContext, con
|
|
|
4223
4376
|
if (request === void 0) {
|
|
4224
4377
|
return void 0;
|
|
4225
4378
|
}
|
|
4379
|
+
if (control.threadId !== void 0 && state.codexThreadId !== control.threadId) {
|
|
4380
|
+
return void 0;
|
|
4381
|
+
}
|
|
4226
4382
|
if (!portForwardControlSenderAllowed(args, payloadContext, control)) {
|
|
4227
4383
|
args.log("port_forward.request_resolution_ignored", {
|
|
4228
4384
|
request_id: control.requestId,
|
|
@@ -4491,11 +4647,19 @@ async function publishPortForwardPrompt(args, state, payloadContext, candidate)
|
|
|
4491
4647
|
allowedActorUserId: args.options.channelSession.listenUser.toLowerCase() === (payloadContext.runnerIdentity.actorUsername ?? "").toLowerCase() ? payloadContext.runnerIdentity.actorUserId : void 0
|
|
4492
4648
|
}
|
|
4493
4649
|
};
|
|
4494
|
-
await publishMessageState(
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4650
|
+
await publishMessageState(
|
|
4651
|
+
args,
|
|
4652
|
+
state.kandanThreadId,
|
|
4653
|
+
sourceSeq,
|
|
4654
|
+
{
|
|
4655
|
+
status: "processing",
|
|
4656
|
+
reason: "awaiting approval",
|
|
4657
|
+
approval: state.activeProcessingState.approval
|
|
4658
|
+
},
|
|
4659
|
+
void 0,
|
|
4660
|
+
void 0,
|
|
4661
|
+
state.codexThreadId
|
|
4662
|
+
);
|
|
4499
4663
|
await publishForwardPortRequestedEvent(args, state, request, processIdentity);
|
|
4500
4664
|
args.log("port_forward.request_pending", {
|
|
4501
4665
|
request_id: requestId,
|
|
@@ -4684,7 +4848,10 @@ async function publishMessageStateForPortForwardResult(args, state, request, sta
|
|
|
4684
4848
|
{
|
|
4685
4849
|
status: "processing",
|
|
4686
4850
|
reason: "running terminal command"
|
|
4687
|
-
}
|
|
4851
|
+
},
|
|
4852
|
+
void 0,
|
|
4853
|
+
void 0,
|
|
4854
|
+
state.codexThreadId
|
|
4688
4855
|
);
|
|
4689
4856
|
return;
|
|
4690
4857
|
}
|
|
@@ -4709,15 +4876,31 @@ async function publishMessageStateForPortForwardResult(args, state, request, sta
|
|
|
4709
4876
|
}
|
|
4710
4877
|
switch (status) {
|
|
4711
4878
|
case "processed":
|
|
4712
|
-
await publishMessageState(
|
|
4713
|
-
|
|
4714
|
-
|
|
4879
|
+
await publishMessageState(
|
|
4880
|
+
args,
|
|
4881
|
+
state.kandanThreadId,
|
|
4882
|
+
request.sourceSeq,
|
|
4883
|
+
{
|
|
4884
|
+
status: "processed"
|
|
4885
|
+
},
|
|
4886
|
+
void 0,
|
|
4887
|
+
void 0,
|
|
4888
|
+
state.codexThreadId
|
|
4889
|
+
);
|
|
4715
4890
|
break;
|
|
4716
4891
|
case "failed":
|
|
4717
|
-
await publishMessageState(
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4892
|
+
await publishMessageState(
|
|
4893
|
+
args,
|
|
4894
|
+
state.kandanThreadId,
|
|
4895
|
+
request.sourceSeq,
|
|
4896
|
+
{
|
|
4897
|
+
status: "failed",
|
|
4898
|
+
reason: failedReason
|
|
4899
|
+
},
|
|
4900
|
+
void 0,
|
|
4901
|
+
void 0,
|
|
4902
|
+
state.codexThreadId
|
|
4903
|
+
);
|
|
4721
4904
|
break;
|
|
4722
4905
|
}
|
|
4723
4906
|
}
|
|
@@ -5097,9 +5280,17 @@ async function drainKandanMessageQueue(args, state, payloadContext) {
|
|
|
5097
5280
|
state.turn = { status: "idle" };
|
|
5098
5281
|
clearActiveProcessingState(state, next.seq);
|
|
5099
5282
|
if (state.kandanThreadId !== void 0) {
|
|
5100
|
-
await publishMessageState(
|
|
5101
|
-
|
|
5102
|
-
|
|
5283
|
+
await publishMessageState(
|
|
5284
|
+
args,
|
|
5285
|
+
state.kandanThreadId,
|
|
5286
|
+
next.seq,
|
|
5287
|
+
{
|
|
5288
|
+
status: "processed"
|
|
5289
|
+
},
|
|
5290
|
+
void 0,
|
|
5291
|
+
void 0,
|
|
5292
|
+
state.codexThreadId
|
|
5293
|
+
);
|
|
5103
5294
|
}
|
|
5104
5295
|
await drainKandanMessageQueue(args, state, payloadContext);
|
|
5105
5296
|
}
|
|
@@ -5216,6 +5407,7 @@ async function handleCodexServerRequest(args, state, payloadContext, request) {
|
|
|
5216
5407
|
return void 0;
|
|
5217
5408
|
}
|
|
5218
5409
|
if (codexApprovalRequestCanAutoAccept(state.runtimeSettings, request.method)) {
|
|
5410
|
+
rememberObservedCommandFromApprovalRequest(state, request, turnId);
|
|
5219
5411
|
args.log("codex.server_request_auto_accepted", {
|
|
5220
5412
|
method: request.method,
|
|
5221
5413
|
turn_id: turnId ?? null
|
|
@@ -5255,7 +5447,20 @@ function codexApprovalRequestCanAutoAccept(settings, method) {
|
|
|
5255
5447
|
function codexApprovalRequestCanSurface(method) {
|
|
5256
5448
|
return method === "item/commandExecution/requestApproval" || method === "item/fileChange/requestApproval";
|
|
5257
5449
|
}
|
|
5450
|
+
function rememberObservedCommandFromApprovalRequest(state, request, turnId) {
|
|
5451
|
+
if (request.method !== "item/commandExecution/requestApproval") {
|
|
5452
|
+
return;
|
|
5453
|
+
}
|
|
5454
|
+
const params = objectValue(request.params) ?? {};
|
|
5455
|
+
rememberObservedCommandOutputCommand(state, {
|
|
5456
|
+
turnId,
|
|
5457
|
+
itemKey: stringValue(params.itemId) ?? stringValue(params.item_id) ?? stringValue(objectValue(params.item)?.id),
|
|
5458
|
+
processId: stringValue(params.processId) ?? stringValue(params.process_id),
|
|
5459
|
+
command: stringValue(params.command) ?? stringValue(params.cmd)
|
|
5460
|
+
});
|
|
5461
|
+
}
|
|
5258
5462
|
async function requestKandanApproval(args, state, request, turnId, payloadContext) {
|
|
5463
|
+
rememberObservedCommandFromApprovalRequest(state, request, turnId);
|
|
5259
5464
|
const approvalResult = state.approvalPromptChain.then(async () => {
|
|
5260
5465
|
const sourceSeq = activeQueuedSeqForTurn(state.turn, turnId);
|
|
5261
5466
|
if (sourceSeq === void 0 || state.kandanThreadId === void 0) {
|
|
@@ -5362,11 +5567,22 @@ async function forwardCompletedCodexTurn(args, state, turnId, payloadContext) {
|
|
|
5362
5567
|
return;
|
|
5363
5568
|
}
|
|
5364
5569
|
const tuiInputMessages = isLocalTuiTurn(state, turnId) ? codexUserInputMessagesForTurn(read, turnId) : [];
|
|
5365
|
-
const
|
|
5570
|
+
const readMessages = codexOutputMessagesForTurn(read, turnId);
|
|
5571
|
+
const sessionLogMessages = await sessionLogOutputMessagesForTurn(
|
|
5572
|
+
args,
|
|
5573
|
+
state.codexThreadId,
|
|
5574
|
+
turnId
|
|
5575
|
+
);
|
|
5576
|
+
const messages = completedMessagesWithSessionLog(
|
|
5577
|
+
readMessages,
|
|
5578
|
+
sessionLogMessages
|
|
5579
|
+
);
|
|
5366
5580
|
args.log("codex.turn_completed", {
|
|
5367
5581
|
turn_id: turnId,
|
|
5368
5582
|
tui_input_count: tuiInputMessages.length,
|
|
5369
|
-
output_count: messages.length
|
|
5583
|
+
output_count: messages.length,
|
|
5584
|
+
thread_read_output_count: readMessages.length,
|
|
5585
|
+
session_log_output_count: sessionLogMessages.length
|
|
5370
5586
|
});
|
|
5371
5587
|
if (isLocalTuiTurn(state, turnId)) {
|
|
5372
5588
|
ensureKandanThreadForLocalTuiTurn(state);
|
|
@@ -5573,6 +5789,85 @@ function completedOutputProjectionsForTurn(state, turnId, messages) {
|
|
|
5573
5789
|
compareCompletedOutputProjection
|
|
5574
5790
|
);
|
|
5575
5791
|
}
|
|
5792
|
+
async function sessionLogOutputMessagesForTurn(args, codexThreadId, turnId) {
|
|
5793
|
+
try {
|
|
5794
|
+
return await codexSessionLogOutputMessagesForTurn({
|
|
5795
|
+
codexThreadId,
|
|
5796
|
+
turnId
|
|
5797
|
+
});
|
|
5798
|
+
} catch (error) {
|
|
5799
|
+
args.log("codex.session_log_read_failed", {
|
|
5800
|
+
codex_thread_id: codexThreadId,
|
|
5801
|
+
turn_id: turnId,
|
|
5802
|
+
message: error instanceof Error ? error.message : String(error)
|
|
5803
|
+
});
|
|
5804
|
+
return [];
|
|
5805
|
+
}
|
|
5806
|
+
}
|
|
5807
|
+
function completedMessagesWithSessionLog(readMessages, sessionLogMessages) {
|
|
5808
|
+
const readExactKeys = new Set(readMessages.map(completedMessageExactKey));
|
|
5809
|
+
const readSemanticCounts = completedMessageSemanticCounts(readMessages);
|
|
5810
|
+
const missingSessionStructuredMessages = [];
|
|
5811
|
+
for (const message of sessionLogMessages) {
|
|
5812
|
+
if (stringValue(message.structured.kind) === "codex_assistant_message") {
|
|
5813
|
+
continue;
|
|
5814
|
+
}
|
|
5815
|
+
if (readExactKeys.has(completedMessageExactKey(message))) {
|
|
5816
|
+
continue;
|
|
5817
|
+
}
|
|
5818
|
+
const semanticKey = completedMessageSemanticKey(message);
|
|
5819
|
+
const remainingReadCount = readSemanticCounts.get(semanticKey) ?? 0;
|
|
5820
|
+
if (remainingReadCount > 0) {
|
|
5821
|
+
readSemanticCounts.set(semanticKey, remainingReadCount - 1);
|
|
5822
|
+
continue;
|
|
5823
|
+
}
|
|
5824
|
+
missingSessionStructuredMessages.push(message);
|
|
5825
|
+
}
|
|
5826
|
+
if (missingSessionStructuredMessages.length === 0) {
|
|
5827
|
+
return [...readMessages];
|
|
5828
|
+
}
|
|
5829
|
+
return [...missingSessionStructuredMessages, ...readMessages];
|
|
5830
|
+
}
|
|
5831
|
+
function completedMessageExactKey(message) {
|
|
5832
|
+
return `${stringValue(message.structured.kind) ?? ""}:${message.itemKey}`;
|
|
5833
|
+
}
|
|
5834
|
+
function completedMessageSemanticCounts(messages) {
|
|
5835
|
+
const counts = /* @__PURE__ */ new Map();
|
|
5836
|
+
for (const message of messages) {
|
|
5837
|
+
const key = completedMessageSemanticKey(message);
|
|
5838
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
5839
|
+
}
|
|
5840
|
+
return counts;
|
|
5841
|
+
}
|
|
5842
|
+
function completedMessageSemanticKey(message) {
|
|
5843
|
+
const kind = stringValue(message.structured.kind) ?? "";
|
|
5844
|
+
switch (kind) {
|
|
5845
|
+
case "codex_command_execution":
|
|
5846
|
+
return JSON.stringify([
|
|
5847
|
+
kind,
|
|
5848
|
+
stringValue(message.structured.command) ?? "",
|
|
5849
|
+
stringValue(message.structured.cwd) ?? "",
|
|
5850
|
+
stringValue(message.structured.output) ?? message.body
|
|
5851
|
+
]);
|
|
5852
|
+
case "codex_file_change":
|
|
5853
|
+
return JSON.stringify([
|
|
5854
|
+
kind,
|
|
5855
|
+
stringValue(message.structured.patch_text) ?? message.body
|
|
5856
|
+
]);
|
|
5857
|
+
case "codex_reasoning":
|
|
5858
|
+
return JSON.stringify([
|
|
5859
|
+
kind,
|
|
5860
|
+
stringValue(message.structured.content) ?? message.body
|
|
5861
|
+
]);
|
|
5862
|
+
case "codex_terminal_input":
|
|
5863
|
+
return JSON.stringify([
|
|
5864
|
+
kind,
|
|
5865
|
+
stringValue(message.structured.input_text) ?? message.body
|
|
5866
|
+
]);
|
|
5867
|
+
default:
|
|
5868
|
+
return JSON.stringify([kind, message.body]);
|
|
5869
|
+
}
|
|
5870
|
+
}
|
|
5576
5871
|
function completedSnapshotOutputProjection(state, turnId, message, snapshotIndex) {
|
|
5577
5872
|
const streamedStructured = resolveStreamingStructuredOutputForCompletedMessage(
|
|
5578
5873
|
state,
|
|
@@ -5700,11 +5995,11 @@ async function postCompletedOutputProjection(args, state, payloadContext, params
|
|
|
5700
5995
|
const output = params.output.output;
|
|
5701
5996
|
const message = {
|
|
5702
5997
|
itemKey: output.itemKey,
|
|
5703
|
-
body: codexCommandOutputBody(
|
|
5998
|
+
body: codexCommandOutputBody(output.command, output.output),
|
|
5704
5999
|
structured: codexCommandExecutionStructuredMessage(
|
|
5705
6000
|
output.itemKey,
|
|
5706
6001
|
{
|
|
5707
|
-
command:
|
|
6002
|
+
command: output.command,
|
|
5708
6003
|
output: output.output,
|
|
5709
6004
|
processId: output.processId,
|
|
5710
6005
|
stream: output.stream
|
|
@@ -6235,6 +6530,59 @@ async function forwardReasoningDeltaPayload(args, state, delta, payloadContext)
|
|
|
6235
6530
|
content_length: nextContent.length
|
|
6236
6531
|
});
|
|
6237
6532
|
}
|
|
6533
|
+
async function resolveCommandForCommandOutputDelta(args, state, turnId, delta, existing) {
|
|
6534
|
+
const observed = delta.command ?? existing?.command ?? findObservedCommandOutputCommand(state, {
|
|
6535
|
+
turnId,
|
|
6536
|
+
itemKey: delta.itemKey,
|
|
6537
|
+
processId: delta.processId
|
|
6538
|
+
});
|
|
6539
|
+
if (observed !== void 0 && observed.trim() !== "") {
|
|
6540
|
+
rememberObservedCommandOutputCommand(state, {
|
|
6541
|
+
turnId,
|
|
6542
|
+
itemKey: delta.itemKey,
|
|
6543
|
+
processId: delta.processId,
|
|
6544
|
+
command: observed
|
|
6545
|
+
});
|
|
6546
|
+
return observed;
|
|
6547
|
+
}
|
|
6548
|
+
if (state.codexThreadId !== void 0) {
|
|
6549
|
+
const read = await args.codex.request("thread/read", {
|
|
6550
|
+
threadId: state.codexThreadId,
|
|
6551
|
+
includeTurns: true
|
|
6552
|
+
});
|
|
6553
|
+
const command = commandOutputCommandFromThreadRead(read, turnId, delta);
|
|
6554
|
+
if (command !== void 0) {
|
|
6555
|
+
rememberObservedCommandOutputCommand(state, {
|
|
6556
|
+
turnId,
|
|
6557
|
+
itemKey: delta.itemKey,
|
|
6558
|
+
processId: delta.processId,
|
|
6559
|
+
command
|
|
6560
|
+
});
|
|
6561
|
+
return command;
|
|
6562
|
+
}
|
|
6563
|
+
}
|
|
6564
|
+
throw new LogicalProjectionError(
|
|
6565
|
+
`Cannot forward command output for item ${delta.itemKey} without the actual command`
|
|
6566
|
+
);
|
|
6567
|
+
}
|
|
6568
|
+
function commandOutputCommandFromThreadRead(response, turnId, delta) {
|
|
6569
|
+
if ("error" in response) {
|
|
6570
|
+
return void 0;
|
|
6571
|
+
}
|
|
6572
|
+
const thread = objectValue(objectValue(response.result)?.thread);
|
|
6573
|
+
const turns = arrayValue(thread?.turns) ?? [];
|
|
6574
|
+
const turn = turns.filter(isJsonObject).find((candidate) => candidate.id === turnId);
|
|
6575
|
+
const items = (arrayValue(turn?.items) ?? []).filter(isJsonObject);
|
|
6576
|
+
for (const item of items) {
|
|
6577
|
+
const itemId = stringValue(item.id);
|
|
6578
|
+
const processId = stringValue(item.processId) ?? stringValue(item.process_id);
|
|
6579
|
+
const command = stringValue(item.command) ?? stringValue(item.cmd);
|
|
6580
|
+
if (command !== void 0 && command.trim() !== "" && stringValue(item.type) === "commandExecution" && (itemId === delta.itemKey || delta.processId !== void 0 && processId === delta.processId)) {
|
|
6581
|
+
return command;
|
|
6582
|
+
}
|
|
6583
|
+
}
|
|
6584
|
+
return void 0;
|
|
6585
|
+
}
|
|
6238
6586
|
async function forwardCommandOutputDeltaPayload(args, state, delta, payloadContext) {
|
|
6239
6587
|
if (state.kandanThreadId === void 0 || state.codexThreadId === void 0) {
|
|
6240
6588
|
return;
|
|
@@ -6252,19 +6600,50 @@ async function forwardCommandOutputDeltaPayload(args, state, delta, payloadConte
|
|
|
6252
6600
|
return;
|
|
6253
6601
|
}
|
|
6254
6602
|
const existing = findStreamingCommandOutput(state, delta.itemKey);
|
|
6255
|
-
const
|
|
6603
|
+
const pending = findPendingCommandOutput(state, delta.itemKey);
|
|
6604
|
+
const output = `${existing?.output ?? pending?.output ?? ""}${delta.delta}`;
|
|
6605
|
+
let command;
|
|
6606
|
+
try {
|
|
6607
|
+
command = await resolveCommandForCommandOutputDelta(
|
|
6608
|
+
args,
|
|
6609
|
+
state,
|
|
6610
|
+
turnId,
|
|
6611
|
+
delta,
|
|
6612
|
+
existing
|
|
6613
|
+
);
|
|
6614
|
+
} catch (error) {
|
|
6615
|
+
if (error instanceof LogicalProjectionError) {
|
|
6616
|
+
rememberPendingCommandOutput(state, {
|
|
6617
|
+
itemKey: delta.itemKey,
|
|
6618
|
+
turnId,
|
|
6619
|
+
output,
|
|
6620
|
+
processId: delta.processId ?? pending?.processId,
|
|
6621
|
+
stream: delta.stream
|
|
6622
|
+
});
|
|
6623
|
+
args.log("codex.command_output_waiting_for_command", {
|
|
6624
|
+
turn_id: turnId,
|
|
6625
|
+
item_key: delta.itemKey,
|
|
6626
|
+
process_id: delta.processId ?? pending?.processId ?? null,
|
|
6627
|
+
output_length: output.length,
|
|
6628
|
+
message: error.message
|
|
6629
|
+
});
|
|
6630
|
+
return;
|
|
6631
|
+
}
|
|
6632
|
+
throw error;
|
|
6633
|
+
}
|
|
6634
|
+
forgetPendingCommandOutput(state, delta.itemKey);
|
|
6256
6635
|
const structured = codexCommandExecutionStructuredMessage(
|
|
6257
6636
|
delta.itemKey,
|
|
6258
6637
|
{
|
|
6259
|
-
command
|
|
6638
|
+
command,
|
|
6260
6639
|
output,
|
|
6261
|
-
processId: delta.processId,
|
|
6640
|
+
processId: delta.processId ?? pending?.processId,
|
|
6262
6641
|
stream: delta.stream
|
|
6263
6642
|
},
|
|
6264
6643
|
"streaming"
|
|
6265
6644
|
);
|
|
6266
6645
|
const persistedOutput = typeof structured.output === "string" ? structured.output : output;
|
|
6267
|
-
const body = codexCommandOutputBody(
|
|
6646
|
+
const body = codexCommandOutputBody(command, output);
|
|
6268
6647
|
if (structured.output_truncated === true) {
|
|
6269
6648
|
args.log("codex.command_output_truncated", {
|
|
6270
6649
|
item_key: delta.itemKey,
|
|
@@ -6311,8 +6690,9 @@ async function forwardCommandOutputDeltaPayload(args, state, delta, payloadConte
|
|
|
6311
6690
|
itemKey: delta.itemKey,
|
|
6312
6691
|
turnId,
|
|
6313
6692
|
seq,
|
|
6693
|
+
command,
|
|
6314
6694
|
output: persistedOutput,
|
|
6315
|
-
processId: delta.processId,
|
|
6695
|
+
processId: delta.processId ?? pending?.processId,
|
|
6316
6696
|
stream: delta.stream
|
|
6317
6697
|
});
|
|
6318
6698
|
}
|
|
@@ -6326,6 +6706,7 @@ async function forwardCommandOutputDeltaPayload(args, state, delta, payloadConte
|
|
|
6326
6706
|
);
|
|
6327
6707
|
rememberStreamingCommandOutput(state, {
|
|
6328
6708
|
...existing,
|
|
6709
|
+
command,
|
|
6329
6710
|
output: persistedOutput,
|
|
6330
6711
|
processId: delta.processId ?? existing.processId,
|
|
6331
6712
|
stream: delta.stream
|
|
@@ -6933,6 +7314,9 @@ function findStreamingReasoningOutput(state, itemKey) {
|
|
|
6933
7314
|
function findStreamingCommandOutput(state, itemKey) {
|
|
6934
7315
|
return getBoundedCacheValue(state.streamingCommandOutputs, itemKey);
|
|
6935
7316
|
}
|
|
7317
|
+
function findPendingCommandOutput(state, itemKey) {
|
|
7318
|
+
return getBoundedCacheValue(state.pendingCommandOutputs, itemKey);
|
|
7319
|
+
}
|
|
6936
7320
|
function findStreamingFileChangeOutput(state, itemKey) {
|
|
6937
7321
|
return getBoundedCacheValue(state.streamingFileChangeOutputs, itemKey);
|
|
6938
7322
|
}
|
|
@@ -6967,6 +7351,39 @@ function forgetStreamingStructuredOutput(state, itemKey, structured) {
|
|
|
6967
7351
|
break;
|
|
6968
7352
|
}
|
|
6969
7353
|
}
|
|
7354
|
+
function observedCommandCacheKeys(input) {
|
|
7355
|
+
return [
|
|
7356
|
+
input.itemKey === void 0 ? void 0 : `item:${input.itemKey}`,
|
|
7357
|
+
input.processId === void 0 ? void 0 : `process:${input.processId}`
|
|
7358
|
+
].filter((key) => key !== void 0);
|
|
7359
|
+
}
|
|
7360
|
+
function rememberObservedCommandOutputCommand(state, input) {
|
|
7361
|
+
const command = input.command?.trim();
|
|
7362
|
+
if (command === void 0 || command === "") {
|
|
7363
|
+
return;
|
|
7364
|
+
}
|
|
7365
|
+
for (const cacheKey of observedCommandCacheKeys(input)) {
|
|
7366
|
+
rememberBoundedCacheValue(state.observedCommandOutputCommands, cacheKey, {
|
|
7367
|
+
cacheKey,
|
|
7368
|
+
turnId: input.turnId,
|
|
7369
|
+
itemKey: input.itemKey,
|
|
7370
|
+
processId: input.processId,
|
|
7371
|
+
command
|
|
7372
|
+
});
|
|
7373
|
+
}
|
|
7374
|
+
}
|
|
7375
|
+
function findObservedCommandOutputCommand(state, input) {
|
|
7376
|
+
for (const cacheKey of observedCommandCacheKeys(input)) {
|
|
7377
|
+
const command = getBoundedCacheValue(
|
|
7378
|
+
state.observedCommandOutputCommands,
|
|
7379
|
+
cacheKey
|
|
7380
|
+
)?.command;
|
|
7381
|
+
if (command !== void 0 && command.trim() !== "") {
|
|
7382
|
+
return command;
|
|
7383
|
+
}
|
|
7384
|
+
}
|
|
7385
|
+
return void 0;
|
|
7386
|
+
}
|
|
6970
7387
|
function resolveStreamingAssistantOutputForCompletedMessage(state, turnId, itemKey, body, structured) {
|
|
6971
7388
|
const exact = findStreamingAssistantOutput(state, itemKey);
|
|
6972
7389
|
if (exact !== void 0) {
|
|
@@ -7064,6 +7481,16 @@ function rememberStreamingCommandOutput(state, output) {
|
|
|
7064
7481
|
output
|
|
7065
7482
|
);
|
|
7066
7483
|
}
|
|
7484
|
+
function rememberPendingCommandOutput(state, output) {
|
|
7485
|
+
rememberBoundedCacheValue(
|
|
7486
|
+
state.pendingCommandOutputs,
|
|
7487
|
+
output.itemKey,
|
|
7488
|
+
output
|
|
7489
|
+
);
|
|
7490
|
+
}
|
|
7491
|
+
function forgetPendingCommandOutput(state, itemKey) {
|
|
7492
|
+
forgetBoundedCacheValue(state.pendingCommandOutputs, itemKey);
|
|
7493
|
+
}
|
|
7067
7494
|
function forgetStreamingCommandOutput(state, itemKey) {
|
|
7068
7495
|
forgetBoundedCacheValue(state.streamingCommandOutputs, itemKey);
|
|
7069
7496
|
}
|
|
@@ -7377,7 +7804,9 @@ async function stopCodexTyping(args, state) {
|
|
|
7377
7804
|
{
|
|
7378
7805
|
workspace: session.workspaceSlug,
|
|
7379
7806
|
channel: session.channelSlug,
|
|
7380
|
-
thread_id: state.kandanThreadId
|
|
7807
|
+
thread_id: state.kandanThreadId,
|
|
7808
|
+
instance_id: args.instanceId,
|
|
7809
|
+
codex_thread_id: state.codexThreadId ?? null
|
|
7381
7810
|
},
|
|
7382
7811
|
args.log
|
|
7383
7812
|
);
|
|
@@ -7396,7 +7825,9 @@ function startCodexTypingHeartbeat(args, state, threadId) {
|
|
|
7396
7825
|
{
|
|
7397
7826
|
workspace: session.workspaceSlug,
|
|
7398
7827
|
channel: session.channelSlug,
|
|
7399
|
-
thread_id: threadId
|
|
7828
|
+
thread_id: threadId,
|
|
7829
|
+
instance_id: args.instanceId,
|
|
7830
|
+
codex_thread_id: state.codexThreadId ?? null
|
|
7400
7831
|
},
|
|
7401
7832
|
args.log
|
|
7402
7833
|
).then(() => refreshActiveProcessingHeartbeat(args, state)).catch((error) => {
|
|
@@ -7441,7 +7872,8 @@ async function publishQueuedMessageState(args, state, message, messageState) {
|
|
|
7441
7872
|
message.seq,
|
|
7442
7873
|
messageState,
|
|
7443
7874
|
message.actorSlug,
|
|
7444
|
-
message.actorUserId
|
|
7875
|
+
message.actorUserId,
|
|
7876
|
+
state.codexThreadId
|
|
7445
7877
|
);
|
|
7446
7878
|
}
|
|
7447
7879
|
async function publishMessageState(args, threadId, seq, state, actorSlug, actorUserId, codexThreadId) {
|
|
@@ -7450,6 +7882,7 @@ async function publishMessageState(args, threadId, seq, state, actorSlug, actorU
|
|
|
7450
7882
|
workspace: session.workspaceSlug,
|
|
7451
7883
|
channel: session.channelSlug,
|
|
7452
7884
|
thread_id: threadId,
|
|
7885
|
+
instance_id: args.instanceId,
|
|
7453
7886
|
...codexThreadId === void 0 ? {} : { codex_thread_id: codexThreadId },
|
|
7454
7887
|
seq,
|
|
7455
7888
|
status: state.status,
|
|
@@ -7503,10 +7936,18 @@ async function failActiveCodexTurn(args, state, turnId, reason, payloadContext)
|
|
|
7503
7936
|
}
|
|
7504
7937
|
const seq = activeQueuedSeqForTurn(state.turn, turnId);
|
|
7505
7938
|
if (seq !== void 0 && state.kandanThreadId !== void 0) {
|
|
7506
|
-
await publishMessageState(
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7939
|
+
await publishMessageState(
|
|
7940
|
+
args,
|
|
7941
|
+
state.kandanThreadId,
|
|
7942
|
+
seq,
|
|
7943
|
+
{
|
|
7944
|
+
status: "failed",
|
|
7945
|
+
reason
|
|
7946
|
+
},
|
|
7947
|
+
void 0,
|
|
7948
|
+
void 0,
|
|
7949
|
+
state.codexThreadId
|
|
7950
|
+
);
|
|
7510
7951
|
clearActiveProcessingState(state, seq);
|
|
7511
7952
|
}
|
|
7512
7953
|
forgetLocalTuiTurnId(state, turnId);
|
|
@@ -7529,10 +7970,18 @@ async function refreshActiveProcessingState(args, state, turnId, reason) {
|
|
|
7529
7970
|
return;
|
|
7530
7971
|
}
|
|
7531
7972
|
state.activeProcessingState = { seq, reason };
|
|
7532
|
-
await publishMessageState(
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7973
|
+
await publishMessageState(
|
|
7974
|
+
args,
|
|
7975
|
+
state.kandanThreadId,
|
|
7976
|
+
seq,
|
|
7977
|
+
{
|
|
7978
|
+
status: "processing",
|
|
7979
|
+
reason
|
|
7980
|
+
},
|
|
7981
|
+
void 0,
|
|
7982
|
+
void 0,
|
|
7983
|
+
state.codexThreadId
|
|
7984
|
+
);
|
|
7536
7985
|
}
|
|
7537
7986
|
async function refreshActiveProcessingHeartbeat(args, state) {
|
|
7538
7987
|
const activeProcessingState = state.activeProcessingState;
|
|
@@ -7730,6 +8179,7 @@ var init_channelSession = __esm({
|
|
|
7730
8179
|
init_commanderAttachments();
|
|
7731
8180
|
init_codexRuntimeOptions();
|
|
7732
8181
|
init_codexOutput();
|
|
8182
|
+
init_codexSessionLog();
|
|
7733
8183
|
init_json();
|
|
7734
8184
|
init_kandanQueue();
|
|
7735
8185
|
init_linzumiContext();
|
|
@@ -7760,16 +8210,16 @@ var init_channelSession = __esm({
|
|
|
7760
8210
|
});
|
|
7761
8211
|
|
|
7762
8212
|
// src/claudeCodeSession.ts
|
|
7763
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
7764
|
-
import { homedir as
|
|
7765
|
-
import { join as
|
|
8213
|
+
import { existsSync, readFileSync as readFileSync2 } from "node:fs";
|
|
8214
|
+
import { homedir as homedir3 } from "node:os";
|
|
8215
|
+
import { join as join3 } from "node:path";
|
|
7766
8216
|
function claudeCodeSettingSources() {
|
|
7767
8217
|
return ["user", "project", "local"];
|
|
7768
8218
|
}
|
|
7769
8219
|
async function probeClaudeCodeAvailability(args) {
|
|
7770
8220
|
if (!hasClaudeCodeAuthHint(process.env, {
|
|
7771
8221
|
cwd: args.cwd,
|
|
7772
|
-
homeDir:
|
|
8222
|
+
homeDir: homedir3(),
|
|
7773
8223
|
platform: process.platform,
|
|
7774
8224
|
fileExists: existsSync,
|
|
7775
8225
|
readTextFile: readTextFileIfPresent
|
|
@@ -7794,7 +8244,7 @@ async function probeClaudeCodeAvailability(args) {
|
|
|
7794
8244
|
}
|
|
7795
8245
|
}
|
|
7796
8246
|
function hasClaudeCodeAuthHint(env, deps) {
|
|
7797
|
-
const configDir = env.CLAUDE_CONFIG_DIR ??
|
|
8247
|
+
const configDir = env.CLAUDE_CONFIG_DIR ?? join3(deps.homeDir, ".claude");
|
|
7798
8248
|
return hasAnthropicCredentialEnv(env) || hasClaudeCloudProviderEnv(env) || hasClaudeCodeFileCredential(configDir, deps) || hasClaudeCodeApiKeyHelper(configDir, deps) || hasMacClaudeCodeKeychainAnchor(deps);
|
|
7799
8249
|
}
|
|
7800
8250
|
function claudeCodePolicyDeferHooks() {
|
|
@@ -7829,14 +8279,14 @@ function hasClaudeCloudProviderEnv(env) {
|
|
|
7829
8279
|
return trueishEnv(env.CLAUDE_CODE_USE_BEDROCK) || trueishEnv(env.CLAUDE_CODE_USE_VERTEX) || trueishEnv(env.CLAUDE_CODE_USE_FOUNDRY) || trueishEnv(env.CLAUDE_CODE_USE_ANTHROPIC_AWS) || trueishEnv(env.CLAUDE_CODE_USE_MANTLE);
|
|
7830
8280
|
}
|
|
7831
8281
|
function hasClaudeCodeFileCredential(configDir, deps) {
|
|
7832
|
-
return deps.fileExists(
|
|
8282
|
+
return deps.fileExists(join3(configDir, ".credentials.json")) || deps.fileExists(join3(configDir, ".claude.json")) || deps.fileExists(join3(deps.homeDir, ".claude.json"));
|
|
7833
8283
|
}
|
|
7834
8284
|
function hasClaudeCodeApiKeyHelper(configDir, deps) {
|
|
7835
8285
|
return [
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
8286
|
+
join3(configDir, "settings.json"),
|
|
8287
|
+
join3(configDir, "settings.local.json"),
|
|
8288
|
+
join3(deps.cwd, ".claude", "settings.json"),
|
|
8289
|
+
join3(deps.cwd, ".claude", "settings.local.json")
|
|
7840
8290
|
].some((path2) => settingsFileHasApiKeyHelper(path2, deps));
|
|
7841
8291
|
}
|
|
7842
8292
|
function settingsFileHasApiKeyHelper(path2, deps) {
|
|
@@ -7856,14 +8306,14 @@ function hasMacClaudeCodeKeychainAnchor(deps) {
|
|
|
7856
8306
|
return false;
|
|
7857
8307
|
}
|
|
7858
8308
|
return [
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
8309
|
+
join3(deps.homeDir, "Library", "Application Support", "claude-cli-nodejs"),
|
|
8310
|
+
join3(deps.homeDir, "Library", "Application Support", "Claude"),
|
|
8311
|
+
join3(deps.homeDir, "Library", "Preferences", "claude-cli-nodejs")
|
|
7862
8312
|
].some((path2) => deps.fileExists(path2));
|
|
7863
8313
|
}
|
|
7864
8314
|
function readTextFileIfPresent(path2) {
|
|
7865
8315
|
try {
|
|
7866
|
-
return
|
|
8316
|
+
return readFileSync2(path2, "utf8");
|
|
7867
8317
|
} catch (_error) {
|
|
7868
8318
|
return void 0;
|
|
7869
8319
|
}
|
|
@@ -8434,8 +8884,8 @@ var init_claudeCodeSession = __esm({
|
|
|
8434
8884
|
// src/runnerLogger.ts
|
|
8435
8885
|
import { appendFileSync, openSync } from "node:fs";
|
|
8436
8886
|
import { createWriteStream } from "node:fs";
|
|
8437
|
-
import { homedir as
|
|
8438
|
-
import { dirname, join as
|
|
8887
|
+
import { homedir as homedir4 } from "node:os";
|
|
8888
|
+
import { dirname, join as join4 } from "node:path";
|
|
8439
8889
|
import { mkdirSync } from "node:fs";
|
|
8440
8890
|
function createRunnerLogger(logFile, consoleReporter) {
|
|
8441
8891
|
mkdirSync(dirname(logFile), { recursive: true });
|
|
@@ -8476,10 +8926,10 @@ function writeCliAuditEvent(event, payload, options = {}) {
|
|
|
8476
8926
|
}
|
|
8477
8927
|
function defaultCliAuditLogFile() {
|
|
8478
8928
|
const override = process.env.LINZUMI_CLI_AUDIT_LOG?.trim();
|
|
8479
|
-
return override === void 0 || override === "" ?
|
|
8929
|
+
return override === void 0 || override === "" ? join4(homedir4(), ".linzumi", "logs", "command-events.jsonl") : override;
|
|
8480
8930
|
}
|
|
8481
8931
|
function defaultRunnerLogFile() {
|
|
8482
|
-
return
|
|
8932
|
+
return join4(homedir4(), ".linzumi", "logs", "runner-events.jsonl");
|
|
8483
8933
|
}
|
|
8484
8934
|
function redactForCliLog(value) {
|
|
8485
8935
|
return redactObject(value);
|
|
@@ -9137,17 +9587,17 @@ var init_codexAppServer = __esm({
|
|
|
9137
9587
|
import {
|
|
9138
9588
|
existsSync as existsSync2,
|
|
9139
9589
|
mkdirSync as mkdirSync2,
|
|
9140
|
-
readFileSync as
|
|
9590
|
+
readFileSync as readFileSync3,
|
|
9141
9591
|
realpathSync,
|
|
9142
9592
|
writeFileSync
|
|
9143
9593
|
} from "node:fs";
|
|
9144
|
-
import { homedir as
|
|
9145
|
-
import { join as
|
|
9594
|
+
import { homedir as homedir5 } from "node:os";
|
|
9595
|
+
import { join as join5, resolve as resolve2 } from "node:path";
|
|
9146
9596
|
function ensureCodexProjectTrusted(projectPath, options = {}) {
|
|
9147
9597
|
const trustedPath = realpathSync(resolve2(projectPath));
|
|
9148
|
-
const configHome = options.configHome ?? process.env.CODEX_HOME ??
|
|
9149
|
-
const configPath =
|
|
9150
|
-
const currentConfig = existsSync2(configPath) ?
|
|
9598
|
+
const configHome = options.configHome ?? process.env.CODEX_HOME ?? join5(homedir5(), ".codex");
|
|
9599
|
+
const configPath = join5(configHome, "config.toml");
|
|
9600
|
+
const currentConfig = existsSync2(configPath) ? readFileSync3(configPath, "utf8") : "";
|
|
9151
9601
|
const nextConfig = codexConfigWithTrustedProject(currentConfig, trustedPath);
|
|
9152
9602
|
if (nextConfig !== currentConfig) {
|
|
9153
9603
|
mkdirSync2(configHome, { recursive: true });
|
|
@@ -9200,7 +9650,7 @@ var init_codexProjectTrust = __esm({
|
|
|
9200
9650
|
|
|
9201
9651
|
// src/localCapabilities.ts
|
|
9202
9652
|
import { realpathSync as realpathSync2 } from "node:fs";
|
|
9203
|
-
import { homedir as
|
|
9653
|
+
import { homedir as homedir6 } from "node:os";
|
|
9204
9654
|
import { isAbsolute as isAbsolute2, relative as relative2, resolve as resolve3 } from "node:path";
|
|
9205
9655
|
function parseAllowedCwdList(value) {
|
|
9206
9656
|
if (value === void 0) {
|
|
@@ -9240,10 +9690,10 @@ function assertConfiguredAllowedCwds(paths) {
|
|
|
9240
9690
|
}
|
|
9241
9691
|
function expandUserPath(pathValue) {
|
|
9242
9692
|
if (pathValue === "~") {
|
|
9243
|
-
return
|
|
9693
|
+
return homedir6();
|
|
9244
9694
|
}
|
|
9245
9695
|
if (pathValue.startsWith("~/")) {
|
|
9246
|
-
return resolve3(
|
|
9696
|
+
return resolve3(homedir6(), pathValue.slice(2));
|
|
9247
9697
|
}
|
|
9248
9698
|
return pathValue;
|
|
9249
9699
|
}
|
|
@@ -9624,16 +10074,16 @@ import {
|
|
|
9624
10074
|
existsSync as existsSync3,
|
|
9625
10075
|
linkSync,
|
|
9626
10076
|
mkdirSync as mkdirSync3,
|
|
9627
|
-
readFileSync as
|
|
10077
|
+
readFileSync as readFileSync4,
|
|
9628
10078
|
realpathSync as realpathSync3,
|
|
9629
10079
|
unlinkSync,
|
|
9630
10080
|
writeFileSync as writeFileSync2
|
|
9631
10081
|
} from "node:fs";
|
|
9632
|
-
import { homedir as
|
|
9633
|
-
import { basename as basename3, dirname as dirname2, join as
|
|
10082
|
+
import { homedir as homedir7 } from "node:os";
|
|
10083
|
+
import { basename as basename3, dirname as dirname2, join as join6, resolve as resolve4 } from "node:path";
|
|
9634
10084
|
function localConfigPath(env = process.env) {
|
|
9635
10085
|
const override = env.LINZUMI_CONFIG_FILE;
|
|
9636
|
-
return override !== void 0 && override.trim() !== "" ? resolve4(expandUserPath(override)) : resolve4(
|
|
10086
|
+
return override !== void 0 && override.trim() !== "" ? resolve4(expandUserPath(override)) : resolve4(homedir7(), ".linzumi", "config.json");
|
|
9637
10087
|
}
|
|
9638
10088
|
function localConfigScopeKey(linzumiUrl) {
|
|
9639
10089
|
const normalizedUrl = kandanHttpBaseUrl(linzumiUrl);
|
|
@@ -9714,21 +10164,21 @@ function ensureLocalRunnerId(path2 = localConfigPath(), createRunnerId = default
|
|
|
9714
10164
|
}
|
|
9715
10165
|
function localMachineIdSeedPath(configPath = localConfigPath(), linzumiUrl) {
|
|
9716
10166
|
if (linzumiUrl !== void 0 && localConfigScopeKey(linzumiUrl) !== prodConfigScope) {
|
|
9717
|
-
return
|
|
10167
|
+
return join6(
|
|
9718
10168
|
dirname2(configPath),
|
|
9719
10169
|
`${basename3(configPath)}.${localConfigScopeFileStem(linzumiUrl)}.machine-id`
|
|
9720
10170
|
);
|
|
9721
10171
|
}
|
|
9722
|
-
return
|
|
10172
|
+
return join6(dirname2(configPath), `${basename3(configPath)}.machine-id`);
|
|
9723
10173
|
}
|
|
9724
10174
|
function localRunnerIdSeedPath(configPath = localConfigPath(), linzumiUrl) {
|
|
9725
10175
|
if (linzumiUrl !== void 0 && localConfigScopeKey(linzumiUrl) !== prodConfigScope) {
|
|
9726
|
-
return
|
|
10176
|
+
return join6(
|
|
9727
10177
|
dirname2(configPath),
|
|
9728
10178
|
`${basename3(configPath)}.${localConfigScopeFileStem(linzumiUrl)}.runner-id`
|
|
9729
10179
|
);
|
|
9730
10180
|
}
|
|
9731
|
-
return
|
|
10181
|
+
return join6(dirname2(configPath), `${basename3(configPath)}.runner-id`);
|
|
9732
10182
|
}
|
|
9733
10183
|
function readConfiguredAllowedCwdDetailsForLinzumiUrl(linzumiUrl, path2 = localConfigPath()) {
|
|
9734
10184
|
return readConfiguredAllowedCwdDetailsFromConfig(
|
|
@@ -9893,7 +10343,7 @@ function readLocalConfigFile(path2) {
|
|
|
9893
10343
|
if (!existsSync3(path2)) {
|
|
9894
10344
|
return { version: 1, allowedCwds: [] };
|
|
9895
10345
|
}
|
|
9896
|
-
const parsed = JSON.parse(
|
|
10346
|
+
const parsed = JSON.parse(readFileSync4(path2, "utf8"));
|
|
9897
10347
|
if (!isConfigPayload(parsed)) {
|
|
9898
10348
|
throw new Error(`invalid Linzumi config: ${path2}`);
|
|
9899
10349
|
}
|
|
@@ -9998,7 +10448,7 @@ function ensureLocalMachineIdSeed(configPath, createMachineId, linzumiUrl) {
|
|
|
9998
10448
|
throw new Error(`invalid generated Linzumi machine id: ${machineId}`);
|
|
9999
10449
|
}
|
|
10000
10450
|
mkdirSync3(dirname2(seedPath), { recursive: true });
|
|
10001
|
-
const tempPath =
|
|
10451
|
+
const tempPath = join6(
|
|
10002
10452
|
dirname2(seedPath),
|
|
10003
10453
|
`.${basename3(seedPath)}.${process.pid}.${randomUUID2()}.tmp`
|
|
10004
10454
|
);
|
|
@@ -10026,7 +10476,7 @@ function ensureLocalRunnerIdSeed(configPath, createRunnerId, linzumiUrl) {
|
|
|
10026
10476
|
throw new Error(`invalid generated Linzumi runner id: ${runnerId}`);
|
|
10027
10477
|
}
|
|
10028
10478
|
mkdirSync3(dirname2(seedPath), { recursive: true });
|
|
10029
|
-
const tempPath =
|
|
10479
|
+
const tempPath = join6(
|
|
10030
10480
|
dirname2(seedPath),
|
|
10031
10481
|
`.${basename3(seedPath)}.${process.pid}.${randomUUID2()}.tmp`
|
|
10032
10482
|
);
|
|
@@ -10045,14 +10495,14 @@ function ensureLocalRunnerIdSeed(configPath, createRunnerId, linzumiUrl) {
|
|
|
10045
10495
|
}
|
|
10046
10496
|
}
|
|
10047
10497
|
function readMachineIdSeed(seedPath) {
|
|
10048
|
-
const machineId =
|
|
10498
|
+
const machineId = readFileSync4(seedPath, "utf8").trim();
|
|
10049
10499
|
if (!machineIdValid(machineId)) {
|
|
10050
10500
|
throw new Error(`invalid Linzumi machine id seed: ${seedPath}`);
|
|
10051
10501
|
}
|
|
10052
10502
|
return machineId;
|
|
10053
10503
|
}
|
|
10054
10504
|
function readRunnerIdSeed(seedPath) {
|
|
10055
|
-
const runnerId =
|
|
10505
|
+
const runnerId = readFileSync4(seedPath, "utf8").trim();
|
|
10056
10506
|
if (!runnerIdValid(runnerId)) {
|
|
10057
10507
|
throw new Error(`invalid Linzumi runner id seed: ${seedPath}`);
|
|
10058
10508
|
}
|
|
@@ -10094,8 +10544,8 @@ var init_localConfig = __esm({
|
|
|
10094
10544
|
});
|
|
10095
10545
|
|
|
10096
10546
|
// src/helloLinzumiProject.ts
|
|
10097
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as
|
|
10098
|
-
import { dirname as dirname3, join as
|
|
10547
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync5, rmSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
10548
|
+
import { dirname as dirname3, join as join7, resolve as resolve5 } from "node:path";
|
|
10099
10549
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
10100
10550
|
function createHelloLinzumiProject(input = {}) {
|
|
10101
10551
|
const options = typeof input === "string" ? { rootPath: input } : input;
|
|
@@ -10104,9 +10554,9 @@ function createHelloLinzumiProject(input = {}) {
|
|
|
10104
10554
|
const host = normalizeHost(options.host);
|
|
10105
10555
|
assertTcpPort(port);
|
|
10106
10556
|
assertWritableDemoRoot(root, options.reset === true);
|
|
10107
|
-
mkdirSync4(
|
|
10557
|
+
mkdirSync4(join7(root, "src"), { recursive: true });
|
|
10108
10558
|
for (const file of demoFiles({ root, port, host })) {
|
|
10109
|
-
writeFileSync3(
|
|
10559
|
+
writeFileSync3(join7(root, file.path), file.content, "utf8");
|
|
10110
10560
|
}
|
|
10111
10561
|
return {
|
|
10112
10562
|
root,
|
|
@@ -10150,8 +10600,8 @@ function assertWritableDemoRoot(root, reset) {
|
|
|
10150
10600
|
if (!existsSync4(root)) {
|
|
10151
10601
|
return;
|
|
10152
10602
|
}
|
|
10153
|
-
const markerPath =
|
|
10154
|
-
const isDemoRoot = existsSync4(markerPath) &&
|
|
10603
|
+
const markerPath = join7(root, markerFile);
|
|
10604
|
+
const isDemoRoot = existsSync4(markerPath) && readFileSync5(markerPath, "utf8").trim() === "hello-linzumi";
|
|
10155
10605
|
if (isDemoRoot && reset) {
|
|
10156
10606
|
rmSync(root, { recursive: true, force: true });
|
|
10157
10607
|
return;
|
|
@@ -10186,7 +10636,7 @@ var init_helloLinzumiProject = __esm({
|
|
|
10186
10636
|
defaultHelloLinzumiHost = "0.0.0.0";
|
|
10187
10637
|
markerFile = ".linzumi-demo-project";
|
|
10188
10638
|
moduleDir = dirname3(fileURLToPath2(import.meta.url));
|
|
10189
|
-
linzumiLogoSvg =
|
|
10639
|
+
linzumiLogoSvg = readFileSync5(join7(moduleDir, "assets", "linzumi-logo.svg"), "utf8");
|
|
10190
10640
|
packageJson = `${JSON.stringify(
|
|
10191
10641
|
{
|
|
10192
10642
|
name: "hello-linzumi",
|
|
@@ -10990,12 +11440,12 @@ import {
|
|
|
10990
11440
|
existsSync as existsSync5,
|
|
10991
11441
|
mkdirSync as mkdirSync5,
|
|
10992
11442
|
mkdtempSync,
|
|
10993
|
-
readFileSync as
|
|
11443
|
+
readFileSync as readFileSync6,
|
|
10994
11444
|
realpathSync as realpathSync4,
|
|
10995
11445
|
writeFileSync as writeFileSync4
|
|
10996
11446
|
} from "node:fs";
|
|
10997
11447
|
import { tmpdir } from "node:os";
|
|
10998
|
-
import { basename as basename4, delimiter, dirname as dirname4, join as
|
|
11448
|
+
import { basename as basename4, delimiter, dirname as dirname4, join as join8 } from "node:path";
|
|
10999
11449
|
function isStartLocalEditorControl(control) {
|
|
11000
11450
|
return control.type === "start_local_editor";
|
|
11001
11451
|
}
|
|
@@ -11213,11 +11663,11 @@ function codeServerArgs(port, cwd, userDataDir, extensionsDir) {
|
|
|
11213
11663
|
}
|
|
11214
11664
|
function prepareCodeServerProfile(collaboration, editorRuntime) {
|
|
11215
11665
|
try {
|
|
11216
|
-
const userDataDir = mkdtempSync(
|
|
11217
|
-
const extensionsDir =
|
|
11218
|
-
const collaborationServerDir =
|
|
11219
|
-
const tempDir =
|
|
11220
|
-
const userSettingsDir =
|
|
11666
|
+
const userDataDir = mkdtempSync(join8(tmpdir(), "kandan-local-editor-"));
|
|
11667
|
+
const extensionsDir = join8(userDataDir, "extensions");
|
|
11668
|
+
const collaborationServerDir = join8(userDataDir, "collaboration-server");
|
|
11669
|
+
const tempDir = join8(userDataDir, "tmp");
|
|
11670
|
+
const userSettingsDir = join8(userDataDir, "User");
|
|
11221
11671
|
mkdirSync5(userSettingsDir, { recursive: true });
|
|
11222
11672
|
mkdirSync5(extensionsDir, { recursive: true });
|
|
11223
11673
|
mkdirSync5(collaborationServerDir, { recursive: true });
|
|
@@ -11226,11 +11676,11 @@ function prepareCodeServerProfile(collaboration, editorRuntime) {
|
|
|
11226
11676
|
ensureCodeServerBrowserExtensionAssets(editorRuntime);
|
|
11227
11677
|
installDirectory(
|
|
11228
11678
|
editorRuntime.assets.documentStateExtensionDir,
|
|
11229
|
-
|
|
11679
|
+
join8(extensionsDir, "kandan.document-state-telemetry")
|
|
11230
11680
|
);
|
|
11231
11681
|
}
|
|
11232
11682
|
writeFileSync4(
|
|
11233
|
-
|
|
11683
|
+
join8(userSettingsDir, "settings.json"),
|
|
11234
11684
|
JSON.stringify(codeServerSettings(collaboration), null, 2)
|
|
11235
11685
|
);
|
|
11236
11686
|
return { ok: true, userDataDir, extensionsDir, collaborationServerDir };
|
|
@@ -11242,14 +11692,14 @@ function ensureCodeServerBrowserExtensionAssets(runtime) {
|
|
|
11242
11692
|
const vscodeRoot = codeServerVscodeRoot(runtime);
|
|
11243
11693
|
const repairs = [
|
|
11244
11694
|
{
|
|
11245
|
-
source:
|
|
11695
|
+
source: join8(
|
|
11246
11696
|
vscodeRoot,
|
|
11247
11697
|
"extensions",
|
|
11248
11698
|
"git-base",
|
|
11249
11699
|
"dist",
|
|
11250
11700
|
"extension.js"
|
|
11251
11701
|
),
|
|
11252
|
-
target:
|
|
11702
|
+
target: join8(
|
|
11253
11703
|
vscodeRoot,
|
|
11254
11704
|
"extensions",
|
|
11255
11705
|
"git-base",
|
|
@@ -11260,14 +11710,14 @@ function ensureCodeServerBrowserExtensionAssets(runtime) {
|
|
|
11260
11710
|
required: true
|
|
11261
11711
|
},
|
|
11262
11712
|
{
|
|
11263
|
-
source:
|
|
11713
|
+
source: join8(
|
|
11264
11714
|
vscodeRoot,
|
|
11265
11715
|
"extensions",
|
|
11266
11716
|
"git-base",
|
|
11267
11717
|
"dist",
|
|
11268
11718
|
"extension.js.map"
|
|
11269
11719
|
),
|
|
11270
|
-
target:
|
|
11720
|
+
target: join8(
|
|
11271
11721
|
vscodeRoot,
|
|
11272
11722
|
"extensions",
|
|
11273
11723
|
"git-base",
|
|
@@ -11278,14 +11728,14 @@ function ensureCodeServerBrowserExtensionAssets(runtime) {
|
|
|
11278
11728
|
required: false
|
|
11279
11729
|
},
|
|
11280
11730
|
{
|
|
11281
|
-
source:
|
|
11731
|
+
source: join8(
|
|
11282
11732
|
vscodeRoot,
|
|
11283
11733
|
"extensions",
|
|
11284
11734
|
"merge-conflict",
|
|
11285
11735
|
"dist",
|
|
11286
11736
|
"mergeConflictMain.js"
|
|
11287
11737
|
),
|
|
11288
|
-
target:
|
|
11738
|
+
target: join8(
|
|
11289
11739
|
vscodeRoot,
|
|
11290
11740
|
"extensions",
|
|
11291
11741
|
"merge-conflict",
|
|
@@ -11296,14 +11746,14 @@ function ensureCodeServerBrowserExtensionAssets(runtime) {
|
|
|
11296
11746
|
required: true
|
|
11297
11747
|
},
|
|
11298
11748
|
{
|
|
11299
|
-
source:
|
|
11749
|
+
source: join8(
|
|
11300
11750
|
vscodeRoot,
|
|
11301
11751
|
"extensions",
|
|
11302
11752
|
"merge-conflict",
|
|
11303
11753
|
"dist",
|
|
11304
11754
|
"mergeConflictMain.js.map"
|
|
11305
11755
|
),
|
|
11306
|
-
target:
|
|
11756
|
+
target: join8(
|
|
11307
11757
|
vscodeRoot,
|
|
11308
11758
|
"extensions",
|
|
11309
11759
|
"merge-conflict",
|
|
@@ -11329,10 +11779,10 @@ function ensureCodeServerBrowserExtensionAssets(runtime) {
|
|
|
11329
11779
|
}
|
|
11330
11780
|
function codeServerVscodeRoot(runtime) {
|
|
11331
11781
|
const roots = uniquePaths([
|
|
11332
|
-
|
|
11333
|
-
|
|
11782
|
+
join8(runtime.root, "lib", "vscode"),
|
|
11783
|
+
join8(dirname4(dirname4(runtime.codeServerBin)), "lib", "vscode"),
|
|
11334
11784
|
...wrappedCodeServerBin(runtime.codeServerBin).map(
|
|
11335
|
-
(codeServerBin) =>
|
|
11785
|
+
(codeServerBin) => join8(dirname4(dirname4(codeServerBin)), "lib", "vscode")
|
|
11336
11786
|
)
|
|
11337
11787
|
]);
|
|
11338
11788
|
const rootWithRequiredAssets = roots.find(
|
|
@@ -11348,7 +11798,7 @@ function codeServerVscodeRoot(runtime) {
|
|
|
11348
11798
|
}
|
|
11349
11799
|
function wrappedCodeServerBin(codeServerBin) {
|
|
11350
11800
|
try {
|
|
11351
|
-
const script =
|
|
11801
|
+
const script = readFileSync6(codeServerBin, "utf8");
|
|
11352
11802
|
const match = script.match(
|
|
11353
11803
|
/exec\s+(?:"([^"]+)"|'([^']+)'|([^\s]+))\s+"\$@"/u
|
|
11354
11804
|
);
|
|
@@ -11360,8 +11810,8 @@ function wrappedCodeServerBin(codeServerBin) {
|
|
|
11360
11810
|
}
|
|
11361
11811
|
function codeServerBrowserAssetSources(vscodeRoot) {
|
|
11362
11812
|
return [
|
|
11363
|
-
|
|
11364
|
-
|
|
11813
|
+
join8(vscodeRoot, "extensions", "git-base", "dist", "extension.js"),
|
|
11814
|
+
join8(
|
|
11365
11815
|
vscodeRoot,
|
|
11366
11816
|
"extensions",
|
|
11367
11817
|
"merge-conflict",
|
|
@@ -11440,10 +11890,10 @@ function prepareLinuxCodeServerLaunch(options) {
|
|
|
11440
11890
|
options.cwd,
|
|
11441
11891
|
"--setenv",
|
|
11442
11892
|
"XDG_DATA_HOME",
|
|
11443
|
-
|
|
11893
|
+
join8(options.userDataDir, "data"),
|
|
11444
11894
|
"--setenv",
|
|
11445
11895
|
"XDG_CONFIG_HOME",
|
|
11446
|
-
|
|
11896
|
+
join8(options.userDataDir, "config"),
|
|
11447
11897
|
...readOnlyRoots.flatMap((path2) => ["--ro-bind-try", path2, path2]),
|
|
11448
11898
|
"--bind",
|
|
11449
11899
|
options.cwd,
|
|
@@ -11484,7 +11934,7 @@ function resolveCodeServerExecutable(command, envPath) {
|
|
|
11484
11934
|
if (directory.trim() === "") {
|
|
11485
11935
|
continue;
|
|
11486
11936
|
}
|
|
11487
|
-
const candidate =
|
|
11937
|
+
const candidate = join8(directory, command);
|
|
11488
11938
|
if (!existsSync5(candidate)) {
|
|
11489
11939
|
continue;
|
|
11490
11940
|
}
|
|
@@ -11570,7 +12020,7 @@ async function startCollaborationSidecar(collaboration, profile, editorRuntime,
|
|
|
11570
12020
|
]);
|
|
11571
12021
|
const command = nodeRuntimeExecutable();
|
|
11572
12022
|
const args = [
|
|
11573
|
-
|
|
12023
|
+
join8(
|
|
11574
12024
|
profile.collaborationServerDir,
|
|
11575
12025
|
"open-collaboration-server",
|
|
11576
12026
|
"bundle",
|
|
@@ -11687,7 +12137,7 @@ function codeServerEnv(env, cwd, userDataDir, collaboration) {
|
|
|
11687
12137
|
KANDAN_EDITOR_COLLABORATION_ENTRY_MODE: "kandan_auto_host_or_join",
|
|
11688
12138
|
KANDAN_EDITOR_COLLABORATION_ROOM_ID: collaboration.roomId,
|
|
11689
12139
|
KANDAN_EDITOR_COLLABORATION_SERVER_URL: collaboration.bootstrapServerUrl,
|
|
11690
|
-
KANDAN_EDITOR_COLLABORATION_AUTO_HOST_CLAIM_PATH:
|
|
12140
|
+
KANDAN_EDITOR_COLLABORATION_AUTO_HOST_CLAIM_PATH: join8(
|
|
11691
12141
|
userDataDir,
|
|
11692
12142
|
"kandan-oct-auto-host.lock"
|
|
11693
12143
|
)
|
|
@@ -11898,13 +12348,13 @@ import {
|
|
|
11898
12348
|
existsSync as existsSync6,
|
|
11899
12349
|
mkdirSync as mkdirSync6,
|
|
11900
12350
|
mkdtempSync as mkdtempSync2,
|
|
11901
|
-
readFileSync as
|
|
12351
|
+
readFileSync as readFileSync7,
|
|
11902
12352
|
renameSync,
|
|
11903
12353
|
rmSync as rmSync2,
|
|
11904
12354
|
writeFileSync as writeFileSync5
|
|
11905
12355
|
} from "node:fs";
|
|
11906
|
-
import { homedir as
|
|
11907
|
-
import { dirname as dirname5, join as
|
|
12356
|
+
import { homedir as homedir8 } from "node:os";
|
|
12357
|
+
import { dirname as dirname5, join as join9, resolve as resolve6 } from "node:path";
|
|
11908
12358
|
import { Readable } from "node:stream";
|
|
11909
12359
|
import { pipeline } from "node:stream/promises";
|
|
11910
12360
|
async function resolveEditorRuntime(options) {
|
|
@@ -12088,14 +12538,14 @@ function normalizeRuntimeAssets(value) {
|
|
|
12088
12538
|
}
|
|
12089
12539
|
function installedRuntime(cacheRoot, manifest) {
|
|
12090
12540
|
const runtimeRoot = runtimeInstallRoot(cacheRoot, manifest);
|
|
12091
|
-
const manifestPath =
|
|
12092
|
-
const codeServerBin =
|
|
12541
|
+
const manifestPath = join9(runtimeRoot, manifest.manifestPath);
|
|
12542
|
+
const codeServerBin = join9(runtimeRoot, manifest.codeServerBinPath);
|
|
12093
12543
|
const assets = verifiedRuntimeAssetPaths(runtimeRoot, manifest);
|
|
12094
12544
|
if (!existsSync6(manifestPath) || !existsSync6(codeServerBin) || assets === void 0) {
|
|
12095
12545
|
return { ok: false };
|
|
12096
12546
|
}
|
|
12097
12547
|
try {
|
|
12098
|
-
const installed = JSON.parse(
|
|
12548
|
+
const installed = JSON.parse(readFileSync7(manifestPath, "utf8"));
|
|
12099
12549
|
if (isJsonObject(installed) && installed.version === manifest.version && installed.platform === manifest.platform && (installed.archiveSha256 === void 0 || installed.archiveSha256 === manifest.archiveSha256)) {
|
|
12100
12550
|
return {
|
|
12101
12551
|
ok: true,
|
|
@@ -12114,9 +12564,9 @@ function installedRuntime(cacheRoot, manifest) {
|
|
|
12114
12564
|
}
|
|
12115
12565
|
async function installRuntime(args) {
|
|
12116
12566
|
mkdirSync6(args.cacheRoot, { recursive: true });
|
|
12117
|
-
const tempRoot = mkdtempSync2(
|
|
12118
|
-
const archivePath =
|
|
12119
|
-
const extractRoot =
|
|
12567
|
+
const tempRoot = mkdtempSync2(join9(args.cacheRoot, ".install-"));
|
|
12568
|
+
const archivePath = join9(tempRoot, "runtime.tar.gz");
|
|
12569
|
+
const extractRoot = join9(tempRoot, "runtime");
|
|
12120
12570
|
try {
|
|
12121
12571
|
const downloaded = await downloadArchive({
|
|
12122
12572
|
kandanUrl: args.kandanUrl,
|
|
@@ -12141,8 +12591,8 @@ async function installRuntime(args) {
|
|
|
12141
12591
|
if (!assetsInstalled) {
|
|
12142
12592
|
return { ok: false, reason: "install_failed" };
|
|
12143
12593
|
}
|
|
12144
|
-
const manifestPath =
|
|
12145
|
-
const codeServerBin =
|
|
12594
|
+
const manifestPath = join9(extractRoot, args.manifest.manifestPath);
|
|
12595
|
+
const codeServerBin = join9(extractRoot, args.manifest.codeServerBinPath);
|
|
12146
12596
|
const assets = verifiedRuntimeAssetPaths(extractRoot, args.manifest);
|
|
12147
12597
|
if (!existsSync6(codeServerBin) || assets === void 0) {
|
|
12148
12598
|
return { ok: false, reason: "invalid_archive" };
|
|
@@ -12173,21 +12623,21 @@ async function installRuntime(args) {
|
|
|
12173
12623
|
runtime: {
|
|
12174
12624
|
mode: "server_managed",
|
|
12175
12625
|
root: targetRoot,
|
|
12176
|
-
codeServerBin:
|
|
12626
|
+
codeServerBin: join9(targetRoot, args.manifest.codeServerBinPath),
|
|
12177
12627
|
assets: {
|
|
12178
|
-
collaborationExtensionTarball:
|
|
12628
|
+
collaborationExtensionTarball: join9(
|
|
12179
12629
|
targetRoot,
|
|
12180
12630
|
"kandan",
|
|
12181
12631
|
"editor_extensions",
|
|
12182
12632
|
"typefox.open-collaboration-tools.tar.gz"
|
|
12183
12633
|
),
|
|
12184
|
-
collaborationServerTarball:
|
|
12634
|
+
collaborationServerTarball: join9(
|
|
12185
12635
|
targetRoot,
|
|
12186
12636
|
"kandan",
|
|
12187
12637
|
"editor_servers",
|
|
12188
12638
|
"open-collaboration-server.tar.gz"
|
|
12189
12639
|
),
|
|
12190
|
-
documentStateExtensionDir:
|
|
12640
|
+
documentStateExtensionDir: join9(
|
|
12191
12641
|
targetRoot,
|
|
12192
12642
|
"kandan",
|
|
12193
12643
|
"editor_extensions",
|
|
@@ -12204,7 +12654,7 @@ async function installRuntime(args) {
|
|
|
12204
12654
|
}
|
|
12205
12655
|
async function materializeRuntimeAssets(args) {
|
|
12206
12656
|
for (const asset of args.manifest.assets) {
|
|
12207
|
-
const targetPath =
|
|
12657
|
+
const targetPath = join9(args.runtimeRoot, asset.path);
|
|
12208
12658
|
try {
|
|
12209
12659
|
const bytes = await runtimeAssetBytes({
|
|
12210
12660
|
kandanUrl: args.kandanUrl,
|
|
@@ -12305,19 +12755,19 @@ function runtimeInstallRoot(cacheRoot, manifest) {
|
|
|
12305
12755
|
return resolve6(cacheRoot, manifest.platform, manifest.archiveSha256);
|
|
12306
12756
|
}
|
|
12307
12757
|
function verifiedRuntimeAssetPaths(runtimeRoot, manifest) {
|
|
12308
|
-
const collaborationExtensionTarball =
|
|
12758
|
+
const collaborationExtensionTarball = join9(
|
|
12309
12759
|
runtimeRoot,
|
|
12310
12760
|
"kandan",
|
|
12311
12761
|
"editor_extensions",
|
|
12312
12762
|
"typefox.open-collaboration-tools.tar.gz"
|
|
12313
12763
|
);
|
|
12314
|
-
const collaborationServerTarball =
|
|
12764
|
+
const collaborationServerTarball = join9(
|
|
12315
12765
|
runtimeRoot,
|
|
12316
12766
|
"kandan",
|
|
12317
12767
|
"editor_servers",
|
|
12318
12768
|
"open-collaboration-server.tar.gz"
|
|
12319
12769
|
);
|
|
12320
|
-
const documentStateExtensionDir =
|
|
12770
|
+
const documentStateExtensionDir = join9(
|
|
12321
12771
|
runtimeRoot,
|
|
12322
12772
|
"kandan",
|
|
12323
12773
|
"editor_extensions",
|
|
@@ -12326,7 +12776,7 @@ function verifiedRuntimeAssetPaths(runtimeRoot, manifest) {
|
|
|
12326
12776
|
const codeServerRoot = codeServerRuntimeRoot(manifest.codeServerBinPath);
|
|
12327
12777
|
const requiredPaths = [
|
|
12328
12778
|
manifest.codeServerBinPath,
|
|
12329
|
-
|
|
12779
|
+
join9(
|
|
12330
12780
|
codeServerRoot,
|
|
12331
12781
|
"lib",
|
|
12332
12782
|
"vscode",
|
|
@@ -12336,7 +12786,7 @@ function verifiedRuntimeAssetPaths(runtimeRoot, manifest) {
|
|
|
12336
12786
|
"web",
|
|
12337
12787
|
"vsda.js"
|
|
12338
12788
|
),
|
|
12339
|
-
|
|
12789
|
+
join9(
|
|
12340
12790
|
codeServerRoot,
|
|
12341
12791
|
"lib",
|
|
12342
12792
|
"vscode",
|
|
@@ -12357,7 +12807,7 @@ function verifiedRuntimeAssetPaths(runtimeRoot, manifest) {
|
|
|
12357
12807
|
if (expectedSha256 === void 0 && relativePath !== manifest.codeServerBinPath) {
|
|
12358
12808
|
return void 0;
|
|
12359
12809
|
}
|
|
12360
|
-
const absolutePath =
|
|
12810
|
+
const absolutePath = join9(runtimeRoot, relativePath);
|
|
12361
12811
|
if (!existsSync6(absolutePath)) {
|
|
12362
12812
|
return void 0;
|
|
12363
12813
|
}
|
|
@@ -12386,10 +12836,10 @@ function manifestAssetChecksums(assets) {
|
|
|
12386
12836
|
return checksums;
|
|
12387
12837
|
}
|
|
12388
12838
|
function fileSha256Sync(path2) {
|
|
12389
|
-
return createHash2("sha256").update(
|
|
12839
|
+
return createHash2("sha256").update(readFileSync7(path2)).digest("hex");
|
|
12390
12840
|
}
|
|
12391
12841
|
function defaultEditorRuntimeCacheRoot() {
|
|
12392
|
-
return
|
|
12842
|
+
return join9(homedir8(), ".linzumi", "editor-runtimes");
|
|
12393
12843
|
}
|
|
12394
12844
|
function nonEmptyString(value) {
|
|
12395
12845
|
return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
|
|
@@ -12409,7 +12859,7 @@ var init_localEditorRuntime = __esm({
|
|
|
12409
12859
|
|
|
12410
12860
|
// src/dependencyStatus.ts
|
|
12411
12861
|
import { spawn as spawn5, spawnSync as spawnSync3 } from "node:child_process";
|
|
12412
|
-
import { delimiter as delimiter2, dirname as dirname6, join as
|
|
12862
|
+
import { delimiter as delimiter2, dirname as dirname6, join as join10 } from "node:path";
|
|
12413
12863
|
function probeTool(command, cwd) {
|
|
12414
12864
|
return new Promise((resolve11) => {
|
|
12415
12865
|
const args = ["--version"];
|
|
@@ -12566,8 +13016,8 @@ function voltaCommandCandidates(args) {
|
|
|
12566
13016
|
new Set(
|
|
12567
13017
|
[
|
|
12568
13018
|
voltaBinBesideCodexShim(args.codexBin),
|
|
12569
|
-
env.VOLTA_HOME === void 0 ? void 0 :
|
|
12570
|
-
env.HOME === void 0 ? void 0 :
|
|
13019
|
+
env.VOLTA_HOME === void 0 ? void 0 : join10(env.VOLTA_HOME, "bin", "volta"),
|
|
13020
|
+
env.HOME === void 0 ? void 0 : join10(env.HOME, ".volta", "bin", "volta"),
|
|
12571
13021
|
...pathVoltaCandidates(env.PATH)
|
|
12572
13022
|
].filter((candidate) => candidate !== void 0)
|
|
12573
13023
|
)
|
|
@@ -12575,10 +13025,10 @@ function voltaCommandCandidates(args) {
|
|
|
12575
13025
|
}
|
|
12576
13026
|
function voltaBinBesideCodexShim(codexBin) {
|
|
12577
13027
|
const normalizedCodexBin = codexBin.replaceAll("\\", "/");
|
|
12578
|
-
return normalizedCodexBin.endsWith("/.volta/bin/codex") ?
|
|
13028
|
+
return normalizedCodexBin.endsWith("/.volta/bin/codex") ? join10(dirname6(codexBin), "volta") : void 0;
|
|
12579
13029
|
}
|
|
12580
13030
|
function pathVoltaCandidates(pathValue) {
|
|
12581
|
-
return pathValue === void 0 ? [] : pathValue.split(delimiter2).filter((entry) => entry !== "").map((entry) =>
|
|
13031
|
+
return pathValue === void 0 ? [] : pathValue.split(delimiter2).filter((entry) => entry !== "").map((entry) => join10(entry, "volta"));
|
|
12582
13032
|
}
|
|
12583
13033
|
function codeServerDependencyStatus(args) {
|
|
12584
13034
|
switch (args.editorRuntime?.status) {
|
|
@@ -12972,7 +13422,7 @@ var linzumiCliVersion, linzumiCliVersionText;
|
|
|
12972
13422
|
var init_version = __esm({
|
|
12973
13423
|
"src/version.ts"() {
|
|
12974
13424
|
"use strict";
|
|
12975
|
-
linzumiCliVersion = "0.0.
|
|
13425
|
+
linzumiCliVersion = "0.0.72-beta";
|
|
12976
13426
|
linzumiCliVersionText = `linzumi ${linzumiCliVersion}`;
|
|
12977
13427
|
}
|
|
12978
13428
|
});
|
|
@@ -12983,14 +13433,14 @@ import {
|
|
|
12983
13433
|
existsSync as existsSync7,
|
|
12984
13434
|
mkdirSync as mkdirSync7,
|
|
12985
13435
|
openSync as openSync2,
|
|
12986
|
-
readFileSync as
|
|
13436
|
+
readFileSync as readFileSync8,
|
|
12987
13437
|
unlinkSync as unlinkSync2,
|
|
12988
13438
|
writeSync
|
|
12989
13439
|
} from "node:fs";
|
|
12990
|
-
import { dirname as dirname7, join as
|
|
13440
|
+
import { dirname as dirname7, join as join11 } from "node:path";
|
|
12991
13441
|
function runnerLockPath(machineId, configPath = localConfigPath(), linzumiUrl) {
|
|
12992
13442
|
const lockName = linzumiUrl === void 0 ? encodeURIComponent(machineId) : localConfigScopeFileStem(linzumiUrl);
|
|
12993
|
-
return
|
|
13443
|
+
return join11(
|
|
12994
13444
|
dirname7(configPath),
|
|
12995
13445
|
"runners",
|
|
12996
13446
|
`${lockName}.lock`
|
|
@@ -13145,7 +13595,7 @@ function withStaleReplacementLock(path2, isPidAlive, callback) {
|
|
|
13145
13595
|
function readReplacementLockPidIfPresent(path2) {
|
|
13146
13596
|
let value;
|
|
13147
13597
|
try {
|
|
13148
|
-
value =
|
|
13598
|
+
value = readFileSync8(path2, "utf8").trim();
|
|
13149
13599
|
} catch (error) {
|
|
13150
13600
|
if (isNodeErrorCode2(error, "ENOENT")) {
|
|
13151
13601
|
return void 0;
|
|
@@ -13185,7 +13635,7 @@ function readRunnerLockIfPresent(path2) {
|
|
|
13185
13635
|
}
|
|
13186
13636
|
}
|
|
13187
13637
|
function readRunnerLock(path2) {
|
|
13188
|
-
const parsed = JSON.parse(
|
|
13638
|
+
const parsed = JSON.parse(readFileSync8(path2, "utf8"));
|
|
13189
13639
|
if (!isRunnerLockRecord(parsed)) {
|
|
13190
13640
|
throw new Error(`invalid Linzumi runner lock: ${path2}`);
|
|
13191
13641
|
}
|
|
@@ -13400,18 +13850,18 @@ var init_runnerConsoleReporter = __esm({
|
|
|
13400
13850
|
});
|
|
13401
13851
|
|
|
13402
13852
|
// src/authCache.ts
|
|
13403
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync8, readFileSync as
|
|
13404
|
-
import { homedir as
|
|
13405
|
-
import { dirname as dirname8, join as
|
|
13853
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync8, readFileSync as readFileSync9, writeFileSync as writeFileSync6 } from "node:fs";
|
|
13854
|
+
import { homedir as homedir9 } from "node:os";
|
|
13855
|
+
import { dirname as dirname8, join as join12 } from "node:path";
|
|
13406
13856
|
function defaultAuthFilePath() {
|
|
13407
|
-
const base = process.env.KANDAN_HOME ??
|
|
13408
|
-
return
|
|
13857
|
+
const base = process.env.KANDAN_HOME ?? join12(homedir9(), ".kandan");
|
|
13858
|
+
return join12(base, "auth.json");
|
|
13409
13859
|
}
|
|
13410
13860
|
function readCachedLocalRunnerToken(kandanUrl, authFilePath = defaultAuthFilePath()) {
|
|
13411
13861
|
if (!existsSync8(authFilePath)) {
|
|
13412
13862
|
return void 0;
|
|
13413
13863
|
}
|
|
13414
|
-
const authFile = parseAuthFile(
|
|
13864
|
+
const authFile = parseAuthFile(readFileSync9(authFilePath, "utf8"));
|
|
13415
13865
|
const kandanBaseUrl = kandanHttpBaseUrl(kandanUrl);
|
|
13416
13866
|
const entry = authFile.local_codex_runner?.[kandanBaseUrl];
|
|
13417
13867
|
if (entry === void 0 || entry.access_token.trim() === "") {
|
|
@@ -13433,7 +13883,7 @@ function readPersonalAgentDelegationToken(authFilePath) {
|
|
|
13433
13883
|
`missing personal-agent delegation auth file: ${authFilePath}`
|
|
13434
13884
|
);
|
|
13435
13885
|
}
|
|
13436
|
-
const authFile = parseAuthFile(
|
|
13886
|
+
const authFile = parseAuthFile(readFileSync9(authFilePath, "utf8"));
|
|
13437
13887
|
const entry = authFile.personal_agent_delegation;
|
|
13438
13888
|
if (entry === void 0 || entry.access_token.trim() === "") {
|
|
13439
13889
|
throw new Error(
|
|
@@ -13451,7 +13901,7 @@ function readPersonalAgentDelegationToken(authFilePath) {
|
|
|
13451
13901
|
}
|
|
13452
13902
|
function writeCachedLocalRunnerToken(args) {
|
|
13453
13903
|
const authFilePath = args.authFilePath ?? defaultAuthFilePath();
|
|
13454
|
-
const existing = existsSync8(authFilePath) ? parseAuthFile(
|
|
13904
|
+
const existing = existsSync8(authFilePath) ? parseAuthFile(readFileSync9(authFilePath, "utf8")) : { version: 1 };
|
|
13455
13905
|
const kandanBaseUrl = kandanHttpBaseUrl(args.kandanUrl);
|
|
13456
13906
|
const issuedAt = /* @__PURE__ */ new Date();
|
|
13457
13907
|
const expiresAt = args.expiresInSeconds === void 0 ? void 0 : new Date(
|
|
@@ -13888,9 +14338,9 @@ var init_threadCodexWorkerIpc = __esm({
|
|
|
13888
14338
|
|
|
13889
14339
|
// src/signupTaskSuggestions.ts
|
|
13890
14340
|
import { spawn as spawn6 } from "node:child_process";
|
|
13891
|
-
import { mkdtempSync as mkdtempSync3, readFileSync as
|
|
14341
|
+
import { mkdtempSync as mkdtempSync3, readFileSync as readFileSync10, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "node:fs";
|
|
13892
14342
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
13893
|
-
import { join as
|
|
14343
|
+
import { join as join13 } from "node:path";
|
|
13894
14344
|
async function suggestSignupTasksWithCodex(args) {
|
|
13895
14345
|
const attempts = 2;
|
|
13896
14346
|
let previousResponse;
|
|
@@ -13912,9 +14362,9 @@ async function suggestSignupTasksWithCodex(args) {
|
|
|
13912
14362
|
);
|
|
13913
14363
|
}
|
|
13914
14364
|
async function runCodexTaskSuggestion(args) {
|
|
13915
|
-
const tempRoot = mkdtempSync3(
|
|
13916
|
-
const schemaPath =
|
|
13917
|
-
const outputPath =
|
|
14365
|
+
const tempRoot = mkdtempSync3(join13(tmpdir2(), "linzumi-signup-codex-tasks-"));
|
|
14366
|
+
const schemaPath = join13(tempRoot, "task-suggestions.schema.json");
|
|
14367
|
+
const outputPath = join13(tempRoot, "task-suggestions.json");
|
|
13918
14368
|
const prompt = taskSuggestionPrompt(args.previousResponse);
|
|
13919
14369
|
writeFileSync7(
|
|
13920
14370
|
schemaPath,
|
|
@@ -13933,7 +14383,7 @@ async function runCodexTaskSuggestion(args) {
|
|
|
13933
14383
|
prompt
|
|
13934
14384
|
})
|
|
13935
14385
|
);
|
|
13936
|
-
return
|
|
14386
|
+
return readFileSync10(outputPath, "utf8");
|
|
13937
14387
|
} finally {
|
|
13938
14388
|
rmSync3(tempRoot, { recursive: true, force: true });
|
|
13939
14389
|
}
|
|
@@ -14101,14 +14551,14 @@ import {
|
|
|
14101
14551
|
lstatSync,
|
|
14102
14552
|
mkdirSync as mkdirSync9,
|
|
14103
14553
|
mkdtempSync as mkdtempSync4,
|
|
14104
|
-
readdirSync,
|
|
14554
|
+
readdirSync as readdirSync2,
|
|
14105
14555
|
realpathSync as realpathSync5,
|
|
14106
14556
|
rmSync as rmSync4,
|
|
14107
14557
|
statSync
|
|
14108
14558
|
} from "node:fs";
|
|
14109
14559
|
import { createServer as createServer3 } from "node:http";
|
|
14110
|
-
import { homedir as
|
|
14111
|
-
import { dirname as dirname9, join as
|
|
14560
|
+
import { homedir as homedir10, hostname as hostname2, tmpdir as tmpdir3 } from "node:os";
|
|
14561
|
+
import { dirname as dirname9, join as join14, resolve as resolve7 } from "node:path";
|
|
14112
14562
|
async function runLocalCodexRunner(options) {
|
|
14113
14563
|
const log = makeRunnerLogger(options);
|
|
14114
14564
|
const cleanup = {
|
|
@@ -15157,7 +15607,7 @@ async function openLocalCodexRunner(options, log, cleanup, close) {
|
|
|
15157
15607
|
if (workspaceSlug === void 0 || channelSlug === void 0 || kandanThreadId === void 0) {
|
|
15158
15608
|
return void 0;
|
|
15159
15609
|
}
|
|
15160
|
-
const existingSession = dynamicChannelSessions.get(
|
|
15610
|
+
const existingSession = dynamicChannelSessions.get(codexThreadId);
|
|
15161
15611
|
if (existingSession !== void 0) {
|
|
15162
15612
|
return existingSession;
|
|
15163
15613
|
}
|
|
@@ -15220,7 +15670,7 @@ async function openLocalCodexRunner(options, log, cleanup, close) {
|
|
|
15220
15670
|
},
|
|
15221
15671
|
log
|
|
15222
15672
|
});
|
|
15223
|
-
dynamicChannelSessions.set(
|
|
15673
|
+
dynamicChannelSessions.set(codexThreadId, session);
|
|
15224
15674
|
if (sessionCodex !== codex) {
|
|
15225
15675
|
sessionCodex.onNotification((notification) => {
|
|
15226
15676
|
seq.value += 1;
|
|
@@ -15791,13 +16241,35 @@ function controlThreadId(control) {
|
|
|
15791
16241
|
async function resolveSessionControl(channelSession, dynamicChannelSessions, control) {
|
|
15792
16242
|
const targetThreadId = controlThreadId(control);
|
|
15793
16243
|
if (targetThreadId !== void 0) {
|
|
15794
|
-
const
|
|
16244
|
+
const directDynamicSession = dynamicChannelSessions.get(targetThreadId);
|
|
16245
|
+
const targetDynamicSessions = Array.from(
|
|
16246
|
+
/* @__PURE__ */ new Set([
|
|
16247
|
+
...directDynamicSession === void 0 ? [] : [directDynamicSession],
|
|
16248
|
+
...Array.from(dynamicChannelSessions.values()).filter(
|
|
16249
|
+
(session) => session.currentKandanThreadId() === targetThreadId
|
|
16250
|
+
)
|
|
16251
|
+
])
|
|
16252
|
+
);
|
|
15795
16253
|
const targetSessions = [
|
|
15796
16254
|
...channelSession?.currentKandanThreadId() === targetThreadId ? [channelSession] : [],
|
|
15797
|
-
...
|
|
16255
|
+
...targetDynamicSessions.filter((session) => session !== channelSession)
|
|
15798
16256
|
].filter(
|
|
15799
16257
|
(session) => session !== void 0
|
|
15800
16258
|
);
|
|
16259
|
+
if (control.type === "update_thread_interaction_access") {
|
|
16260
|
+
let firstHandled;
|
|
16261
|
+
let firstOk;
|
|
16262
|
+
for (const session of targetSessions) {
|
|
16263
|
+
const handled = await session.handleControl(control);
|
|
16264
|
+
if (handled !== void 0) {
|
|
16265
|
+
firstHandled ??= handled;
|
|
16266
|
+
if (handled.ok === true) {
|
|
16267
|
+
firstOk ??= handled;
|
|
16268
|
+
}
|
|
16269
|
+
}
|
|
16270
|
+
}
|
|
16271
|
+
return firstOk ?? firstHandled;
|
|
16272
|
+
}
|
|
15801
16273
|
for (const session of targetSessions) {
|
|
15802
16274
|
const handled = await session.handleControl(control);
|
|
15803
16275
|
if (handled !== void 0) {
|
|
@@ -16051,7 +16523,8 @@ async function applyControl(codex, kandan, topic, instanceId, options, agentProv
|
|
|
16051
16523
|
topic,
|
|
16052
16524
|
control,
|
|
16053
16525
|
cwd.reason,
|
|
16054
|
-
allowedCwds.value
|
|
16526
|
+
allowedCwds.value,
|
|
16527
|
+
{ instanceId }
|
|
16055
16528
|
);
|
|
16056
16529
|
} catch (error) {
|
|
16057
16530
|
log("kandan.start_instance_cwd_failed_state_push_failed", {
|
|
@@ -16075,7 +16548,8 @@ async function applyControl(codex, kandan, topic, instanceId, options, agentProv
|
|
|
16075
16548
|
topic,
|
|
16076
16549
|
control,
|
|
16077
16550
|
"failed",
|
|
16078
|
-
startInstanceUnavailableReason(agentProvider)
|
|
16551
|
+
startInstanceUnavailableReason(agentProvider),
|
|
16552
|
+
{ instanceId }
|
|
16079
16553
|
);
|
|
16080
16554
|
} catch (error) {
|
|
16081
16555
|
log("kandan.start_instance_unavailable_state_push_failed", {
|
|
@@ -16093,7 +16567,8 @@ async function applyControl(codex, kandan, topic, instanceId, options, agentProv
|
|
|
16093
16567
|
const processingStatePayload = startInstanceMessageStatePayload(
|
|
16094
16568
|
control,
|
|
16095
16569
|
"processing",
|
|
16096
|
-
`starting ${startInstanceAgentLabel(agentProvider)} session
|
|
16570
|
+
`starting ${startInstanceAgentLabel(agentProvider)} session`,
|
|
16571
|
+
{ instanceId }
|
|
16097
16572
|
);
|
|
16098
16573
|
if (processingStatePayload !== void 0) {
|
|
16099
16574
|
void kandan.push(topic, "message_state", processingStatePayload).catch((error) => {
|
|
@@ -16163,7 +16638,7 @@ async function applyControl(codex, kandan, topic, instanceId, options, agentProv
|
|
|
16163
16638
|
control,
|
|
16164
16639
|
"failed",
|
|
16165
16640
|
failureReason,
|
|
16166
|
-
{ codexThreadId: startedCodexThreadId }
|
|
16641
|
+
{ codexThreadId: startedCodexThreadId, instanceId }
|
|
16167
16642
|
);
|
|
16168
16643
|
} catch (_publishError) {
|
|
16169
16644
|
}
|
|
@@ -16181,7 +16656,8 @@ async function applyControl(codex, kandan, topic, instanceId, options, agentProv
|
|
|
16181
16656
|
topic,
|
|
16182
16657
|
control,
|
|
16183
16658
|
cwd.reason,
|
|
16184
|
-
allowedCwds.value
|
|
16659
|
+
allowedCwds.value,
|
|
16660
|
+
{ instanceId }
|
|
16185
16661
|
);
|
|
16186
16662
|
} catch (error) {
|
|
16187
16663
|
log("kandan.reconnect_thread_cwd_failed_state_push_failed", {
|
|
@@ -16217,7 +16693,8 @@ async function applyControl(codex, kandan, topic, instanceId, options, agentProv
|
|
|
16217
16693
|
topic,
|
|
16218
16694
|
control,
|
|
16219
16695
|
"failed",
|
|
16220
|
-
startInstanceUnavailableReason(agentProvider)
|
|
16696
|
+
startInstanceUnavailableReason(agentProvider),
|
|
16697
|
+
{ instanceId }
|
|
16221
16698
|
);
|
|
16222
16699
|
} catch (error) {
|
|
16223
16700
|
log("kandan.reconnect_thread_unavailable_state_push_failed", {
|
|
@@ -16256,7 +16733,8 @@ async function applyControl(codex, kandan, topic, instanceId, options, agentProv
|
|
|
16256
16733
|
const processingStatePayload = startInstanceMessageStatePayload(
|
|
16257
16734
|
control,
|
|
16258
16735
|
"processing",
|
|
16259
|
-
"queued Claude Code input"
|
|
16736
|
+
"queued Claude Code input",
|
|
16737
|
+
{ instanceId, codexThreadId }
|
|
16260
16738
|
);
|
|
16261
16739
|
if (processingStatePayload !== void 0) {
|
|
16262
16740
|
void kandan.push(topic, "message_state", processingStatePayload).catch((error) => {
|
|
@@ -16291,7 +16769,8 @@ async function applyControl(codex, kandan, topic, instanceId, options, agentProv
|
|
|
16291
16769
|
topic,
|
|
16292
16770
|
control,
|
|
16293
16771
|
"failed",
|
|
16294
|
-
reason
|
|
16772
|
+
reason,
|
|
16773
|
+
{ instanceId, codexThreadId }
|
|
16295
16774
|
);
|
|
16296
16775
|
} catch (error) {
|
|
16297
16776
|
log("kandan.reconnect_thread_queue_failed_state_push_failed", {
|
|
@@ -16321,7 +16800,8 @@ async function applyControl(codex, kandan, topic, instanceId, options, agentProv
|
|
|
16321
16800
|
topic,
|
|
16322
16801
|
control,
|
|
16323
16802
|
"failed",
|
|
16324
|
-
reason
|
|
16803
|
+
reason,
|
|
16804
|
+
{ instanceId, codexThreadId }
|
|
16325
16805
|
);
|
|
16326
16806
|
} catch (pushError) {
|
|
16327
16807
|
log("kandan.reconnect_thread_queue_closed_state_push_failed", {
|
|
@@ -16360,7 +16840,8 @@ async function applyControl(codex, kandan, topic, instanceId, options, agentProv
|
|
|
16360
16840
|
const processingStatePayload = startInstanceMessageStatePayload(
|
|
16361
16841
|
control,
|
|
16362
16842
|
"processing",
|
|
16363
|
-
"resuming Claude Code session"
|
|
16843
|
+
"resuming Claude Code session",
|
|
16844
|
+
{ instanceId, codexThreadId }
|
|
16364
16845
|
);
|
|
16365
16846
|
if (processingStatePayload !== void 0) {
|
|
16366
16847
|
void kandan.push(topic, "message_state", processingStatePayload).catch((error) => {
|
|
@@ -16406,7 +16887,7 @@ async function applyControl(codex, kandan, topic, instanceId, options, agentProv
|
|
|
16406
16887
|
control,
|
|
16407
16888
|
"failed",
|
|
16408
16889
|
failureReason,
|
|
16409
|
-
{ codexThreadId }
|
|
16890
|
+
{ codexThreadId, instanceId }
|
|
16410
16891
|
);
|
|
16411
16892
|
} catch (_publishError) {
|
|
16412
16893
|
}
|
|
@@ -17157,7 +17638,8 @@ async function startClaudeCodeProviderInstance(args) {
|
|
|
17157
17638
|
args.topic,
|
|
17158
17639
|
args.control,
|
|
17159
17640
|
"failed",
|
|
17160
|
-
reason
|
|
17641
|
+
reason,
|
|
17642
|
+
{ instanceId: args.instanceId }
|
|
17161
17643
|
);
|
|
17162
17644
|
} catch (error) {
|
|
17163
17645
|
args.log(
|
|
@@ -17982,7 +18464,7 @@ async function publishStartInstanceMessageState(kandan, topic, control, status,
|
|
|
17982
18464
|
}
|
|
17983
18465
|
await kandan.push(topic, "message_state", payload);
|
|
17984
18466
|
}
|
|
17985
|
-
async function publishStartInstanceCwdFailureMessageState(kandan, topic, control, reason, allowedCwds) {
|
|
18467
|
+
async function publishStartInstanceCwdFailureMessageState(kandan, topic, control, reason, allowedCwds, diagnostics = {}) {
|
|
17986
18468
|
const rootSeq = integerValue(control.rootSeq);
|
|
17987
18469
|
const sourceSeq = integerValue(control.sourceSeq) ?? rootSeq;
|
|
17988
18470
|
if (sourceSeq === void 0) {
|
|
@@ -17998,6 +18480,7 @@ async function publishStartInstanceCwdFailureMessageState(kandan, topic, control
|
|
|
17998
18480
|
workspace,
|
|
17999
18481
|
channel,
|
|
18000
18482
|
thread_id: threadId,
|
|
18483
|
+
...diagnostics.instanceId === void 0 ? {} : { instance_id: diagnostics.instanceId },
|
|
18001
18484
|
seq: sourceSeq,
|
|
18002
18485
|
status: "failed",
|
|
18003
18486
|
reason,
|
|
@@ -18035,6 +18518,7 @@ function startInstanceMessageStatePayload(control, status, reason, diagnostics =
|
|
|
18035
18518
|
workspace,
|
|
18036
18519
|
channel,
|
|
18037
18520
|
thread_id: threadId,
|
|
18521
|
+
...diagnostics.instanceId === void 0 ? {} : { instance_id: diagnostics.instanceId },
|
|
18038
18522
|
seq: sourceSeq,
|
|
18039
18523
|
status,
|
|
18040
18524
|
reason,
|
|
@@ -18639,9 +19123,9 @@ function mcpOwnerUsername(options) {
|
|
|
18639
19123
|
return options.channelSession?.listenUser ?? identityFromAccessToken(options.token).actorUsername;
|
|
18640
19124
|
}
|
|
18641
19125
|
function writeEphemeralMcpAuthFile(options) {
|
|
18642
|
-
const directory = mkdtempSync4(
|
|
19126
|
+
const directory = mkdtempSync4(join14(tmpdir3(), "linzumi-mcp-auth-"));
|
|
18643
19127
|
chmodSync2(directory, 448);
|
|
18644
|
-
const path2 =
|
|
19128
|
+
const path2 = join14(directory, "auth.json");
|
|
18645
19129
|
writeCachedLocalRunnerToken({
|
|
18646
19130
|
kandanUrl: options.kandanUrl,
|
|
18647
19131
|
accessToken: options.token,
|
|
@@ -18754,7 +19238,7 @@ function allowedCwdProjects(allowedCwds) {
|
|
|
18754
19238
|
});
|
|
18755
19239
|
}
|
|
18756
19240
|
function isGitProjectDirectory(cwd) {
|
|
18757
|
-
const gitPath =
|
|
19241
|
+
const gitPath = join14(cwd, ".git");
|
|
18758
19242
|
try {
|
|
18759
19243
|
const gitPathStats = statSync(gitPath);
|
|
18760
19244
|
return gitPathStats.isDirectory() || gitPathStats.isFile();
|
|
@@ -18764,7 +19248,7 @@ function isGitProjectDirectory(cwd) {
|
|
|
18764
19248
|
}
|
|
18765
19249
|
function browseRunnerDirectory(control, options) {
|
|
18766
19250
|
const requestId = stringValue(control.requestId) ?? null;
|
|
18767
|
-
const requestedPath = stringValue(control.path) ??
|
|
19251
|
+
const requestedPath = stringValue(control.path) ?? homedir10();
|
|
18768
19252
|
try {
|
|
18769
19253
|
const currentPath = realpathSync5(resolve7(expandUserPath(requestedPath)));
|
|
18770
19254
|
const stats = statSync(currentPath);
|
|
@@ -18778,8 +19262,8 @@ function browseRunnerDirectory(control, options) {
|
|
|
18778
19262
|
};
|
|
18779
19263
|
}
|
|
18780
19264
|
const parent = dirname9(currentPath);
|
|
18781
|
-
const entries =
|
|
18782
|
-
const path2 =
|
|
19265
|
+
const entries = readdirSync2(currentPath, { withFileTypes: true }).filter((entry) => entry.isDirectory()).filter((entry) => visibleRunnerDirectoryEntryName(entry.name)).map((entry) => {
|
|
19266
|
+
const path2 = join14(currentPath, entry.name);
|
|
18783
19267
|
return {
|
|
18784
19268
|
name: entry.name,
|
|
18785
19269
|
path: path2,
|
|
@@ -18795,7 +19279,7 @@ function browseRunnerDirectory(control, options) {
|
|
|
18795
19279
|
ok: true,
|
|
18796
19280
|
currentPath,
|
|
18797
19281
|
parentPath: parent === currentPath ? null : parent,
|
|
18798
|
-
homePath:
|
|
19282
|
+
homePath: homedir10(),
|
|
18799
19283
|
runnerCwd: resolve7(options.cwd),
|
|
18800
19284
|
entries,
|
|
18801
19285
|
isGit: isGitProjectDirectory(currentPath)
|
|
@@ -18820,7 +19304,7 @@ function projectDirectoryName(name) {
|
|
|
18820
19304
|
function availableProjectDirectoryName(projectsRoot, baseName, suffix = 0) {
|
|
18821
19305
|
for (let nextSuffix = suffix; ; nextSuffix += 1) {
|
|
18822
19306
|
const candidate = nextSuffix === 0 ? baseName : `${baseName}-${nextSuffix}`;
|
|
18823
|
-
if (!projectPathExists(
|
|
19307
|
+
if (!projectPathExists(join14(projectsRoot, candidate))) {
|
|
18824
19308
|
return candidate;
|
|
18825
19309
|
}
|
|
18826
19310
|
}
|
|
@@ -18848,9 +19332,9 @@ function createRunnerProject(control, options, allowedCwds) {
|
|
|
18848
19332
|
error: "invalid_project_template"
|
|
18849
19333
|
};
|
|
18850
19334
|
}
|
|
18851
|
-
const projectsRoot =
|
|
19335
|
+
const projectsRoot = join14(homedir10(), "linzumi");
|
|
18852
19336
|
const resolvedProjectDirName = template === "hello_linzumi_demo" ? availableProjectDirectoryName(projectsRoot, projectDirName) : projectDirName;
|
|
18853
|
-
const projectPath =
|
|
19337
|
+
const projectPath = join14(projectsRoot, resolvedProjectDirName);
|
|
18854
19338
|
let createdProjectPath = false;
|
|
18855
19339
|
try {
|
|
18856
19340
|
if (template !== "hello_linzumi_demo" && projectPathExists(projectPath)) {
|
|
@@ -19026,7 +19510,7 @@ var init_runner = __esm({
|
|
|
19026
19510
|
});
|
|
19027
19511
|
|
|
19028
19512
|
// src/kandanTls.ts
|
|
19029
|
-
import { existsSync as existsSync9, readFileSync as
|
|
19513
|
+
import { existsSync as existsSync9, readFileSync as readFileSync11 } from "node:fs";
|
|
19030
19514
|
import { Agent } from "undici";
|
|
19031
19515
|
import { WebSocket as WsWebSocket } from "ws";
|
|
19032
19516
|
function kandanTlsTrustFromEnv() {
|
|
@@ -19040,7 +19524,7 @@ function kandanTlsTrustFromCaFile(caFile) {
|
|
|
19040
19524
|
if (!existsSync9(trimmed)) {
|
|
19041
19525
|
throw new Error(`KANDAN_TLS_CA_FILE does not exist: ${trimmed}`);
|
|
19042
19526
|
}
|
|
19043
|
-
const ca =
|
|
19527
|
+
const ca = readFileSync11(trimmed, "utf8");
|
|
19044
19528
|
return {
|
|
19045
19529
|
caFile: trimmed,
|
|
19046
19530
|
ca,
|
|
@@ -37821,7 +38305,7 @@ var init_RemoveFileError = __esm({
|
|
|
37821
38305
|
|
|
37822
38306
|
// ../../node_modules/@inquirer/external-editor/dist/esm/index.js
|
|
37823
38307
|
import { spawn as spawn9, spawnSync as spawnSync5 } from "child_process";
|
|
37824
|
-
import { readFileSync as
|
|
38308
|
+
import { readFileSync as readFileSync14, unlinkSync as unlinkSync3, writeFileSync as writeFileSync10 } from "fs";
|
|
37825
38309
|
import path from "node:path";
|
|
37826
38310
|
import os from "node:os";
|
|
37827
38311
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
@@ -37945,7 +38429,7 @@ var init_esm5 = __esm({
|
|
|
37945
38429
|
}
|
|
37946
38430
|
readTemporaryFile() {
|
|
37947
38431
|
try {
|
|
37948
|
-
const tempFileBuffer =
|
|
38432
|
+
const tempFileBuffer = readFileSync14(this.tempFile);
|
|
37949
38433
|
if (tempFileBuffer.length === 0) {
|
|
37950
38434
|
this.text = "";
|
|
37951
38435
|
} else {
|
|
@@ -39315,15 +39799,15 @@ import {
|
|
|
39315
39799
|
constants as fsConstants,
|
|
39316
39800
|
mkdirSync as mkdirSync12,
|
|
39317
39801
|
mkdtempSync as mkdtempSync5,
|
|
39318
|
-
readFileSync as
|
|
39319
|
-
readdirSync as
|
|
39802
|
+
readFileSync as readFileSync15,
|
|
39803
|
+
readdirSync as readdirSync3,
|
|
39320
39804
|
rmSync as rmSync5,
|
|
39321
39805
|
statSync as statSync2,
|
|
39322
39806
|
writeFileSync as writeFileSync11
|
|
39323
39807
|
} from "node:fs";
|
|
39324
39808
|
import { access } from "node:fs/promises";
|
|
39325
|
-
import { homedir as
|
|
39326
|
-
import { delimiter as delimiter3, dirname as dirname12, join as
|
|
39809
|
+
import { homedir as homedir13, tmpdir as tmpdir4 } from "node:os";
|
|
39810
|
+
import { delimiter as delimiter3, dirname as dirname12, join as join17, resolve as resolve9 } from "node:path";
|
|
39327
39811
|
import { stdin as defaultStdin, stdout as defaultStdout } from "node:process";
|
|
39328
39812
|
import { emitKeypressEvents } from "node:readline";
|
|
39329
39813
|
function signupHelpText() {
|
|
@@ -39427,7 +39911,7 @@ function defaultSignupDraftStore(serviceUrl) {
|
|
|
39427
39911
|
}
|
|
39428
39912
|
let parsed;
|
|
39429
39913
|
try {
|
|
39430
|
-
parsed = JSON.parse(
|
|
39914
|
+
parsed = JSON.parse(readFileSync15(path2, "utf8"));
|
|
39431
39915
|
} catch (_error) {
|
|
39432
39916
|
return void 0;
|
|
39433
39917
|
}
|
|
@@ -39450,7 +39934,7 @@ function defaultSignupDraftStore(serviceUrl) {
|
|
|
39450
39934
|
};
|
|
39451
39935
|
}
|
|
39452
39936
|
function defaultSignupDraftPath(serviceUrl) {
|
|
39453
|
-
return
|
|
39937
|
+
return join17(
|
|
39454
39938
|
dirname12(localConfigPath()),
|
|
39455
39939
|
`signup-draft.${localConfigScopeFileStem(serviceUrl)}.json`
|
|
39456
39940
|
);
|
|
@@ -39495,7 +39979,7 @@ function defaultSignupTaskCacheStore(serviceUrl) {
|
|
|
39495
39979
|
};
|
|
39496
39980
|
}
|
|
39497
39981
|
function defaultSignupTaskCachePath(serviceUrl) {
|
|
39498
|
-
return
|
|
39982
|
+
return join17(
|
|
39499
39983
|
dirname12(localConfigPath()),
|
|
39500
39984
|
`signup-task-cache.${localConfigScopeFileStem(serviceUrl)}.json`
|
|
39501
39985
|
);
|
|
@@ -39506,7 +39990,7 @@ function readSignupTaskCache(path2) {
|
|
|
39506
39990
|
}
|
|
39507
39991
|
let parsed;
|
|
39508
39992
|
try {
|
|
39509
|
-
parsed = JSON.parse(
|
|
39993
|
+
parsed = JSON.parse(readFileSync15(path2, "utf8"));
|
|
39510
39994
|
} catch (_error) {
|
|
39511
39995
|
return { version: 1, entries: {} };
|
|
39512
39996
|
}
|
|
@@ -41379,7 +41863,7 @@ function autocompletePathSuggestions(pathInput) {
|
|
|
41379
41863
|
try {
|
|
41380
41864
|
const showHidden = prefix.startsWith(".");
|
|
41381
41865
|
const currentPath = directoryExists(normalizedInput) ? [normalizedInput.replace(/\/$/, "") || "/"] : [];
|
|
41382
|
-
const childPaths =
|
|
41866
|
+
const childPaths = readdirSync3(directoryPath, { withFileTypes: true }).filter((entry) => entry.isDirectory()).filter((entry) => showHidden || !entry.name.startsWith(".")).map((entry) => join17(directoryPath, entry.name)).map((path2) => ({
|
|
41383
41867
|
path: path2,
|
|
41384
41868
|
score: fuzzyPathSegmentScore(path2.split("/").at(-1) ?? path2, prefix)
|
|
41385
41869
|
})).filter((candidate) => candidate.score !== void 0).sort((left, right) => {
|
|
@@ -41625,7 +42109,7 @@ async function runSignupPreflights(runtime) {
|
|
|
41625
42109
|
function defaultPreflightRuntime() {
|
|
41626
42110
|
return {
|
|
41627
42111
|
cwd: process.cwd(),
|
|
41628
|
-
homeDir:
|
|
42112
|
+
homeDir: homedir13(),
|
|
41629
42113
|
probeTool,
|
|
41630
42114
|
readGitEmail,
|
|
41631
42115
|
discoverCodeRoots,
|
|
@@ -41770,9 +42254,9 @@ async function suggestTasksWithCodex(projectPath, retryPolicy) {
|
|
|
41770
42254
|
);
|
|
41771
42255
|
}
|
|
41772
42256
|
async function runCodexTaskSuggestion2(projectPath, previousResponse, retryPolicy) {
|
|
41773
|
-
const tempRoot = mkdtempSync5(
|
|
41774
|
-
const schemaPath =
|
|
41775
|
-
const outputPath =
|
|
42257
|
+
const tempRoot = mkdtempSync5(join17(tmpdir4(), "linzumi-signup-codex-tasks-"));
|
|
42258
|
+
const schemaPath = join17(tempRoot, "task-suggestions.schema.json");
|
|
42259
|
+
const outputPath = join17(tempRoot, "task-suggestions.json");
|
|
41776
42260
|
const model = process.env.LINZUMI_SIGNUP_TASK_MODEL ?? "gpt-5.4-mini";
|
|
41777
42261
|
const prompt = taskSuggestionPrompt2(previousResponse);
|
|
41778
42262
|
const codexCommand = await resolveSignupCodexCommand();
|
|
@@ -41797,7 +42281,7 @@ async function runCodexTaskSuggestion2(projectPath, previousResponse, retryPolic
|
|
|
41797
42281
|
),
|
|
41798
42282
|
retryPolicy
|
|
41799
42283
|
);
|
|
41800
|
-
return
|
|
42284
|
+
return readFileSync15(outputPath, "utf8");
|
|
41801
42285
|
} finally {
|
|
41802
42286
|
rmSync5(tempRoot, { recursive: true, force: true });
|
|
41803
42287
|
}
|
|
@@ -41834,7 +42318,7 @@ function codexTaskSuggestionProcess2(args) {
|
|
|
41834
42318
|
function signupCodexTaskSuggestionProcessForTest(args) {
|
|
41835
42319
|
return codexTaskSuggestionProcess2(args);
|
|
41836
42320
|
}
|
|
41837
|
-
async function resolveSignupCodexCommand(env = process.env, homeDir =
|
|
42321
|
+
async function resolveSignupCodexCommand(env = process.env, homeDir = homedir13(), executableExists = fileIsExecutable) {
|
|
41838
42322
|
const override = firstConfiguredValue([
|
|
41839
42323
|
env.LINZUMI_SIGNUP_CODEX_BIN,
|
|
41840
42324
|
env.LINZUMI_CODEX_BIN
|
|
@@ -41889,7 +42373,7 @@ function resolveHomePath(path2, homeDir) {
|
|
|
41889
42373
|
return homeDir;
|
|
41890
42374
|
}
|
|
41891
42375
|
if (path2.startsWith("~/")) {
|
|
41892
|
-
return
|
|
42376
|
+
return join17(homeDir, path2.slice(2));
|
|
41893
42377
|
}
|
|
41894
42378
|
return resolve9(path2);
|
|
41895
42379
|
}
|
|
@@ -41902,9 +42386,9 @@ function commandLooksPathLike(command) {
|
|
|
41902
42386
|
}
|
|
41903
42387
|
function homeManagedCodexCandidates(homeDir) {
|
|
41904
42388
|
return [
|
|
41905
|
-
|
|
41906
|
-
|
|
41907
|
-
|
|
42389
|
+
join17(homeDir, ".volta", "bin", "codex"),
|
|
42390
|
+
join17(homeDir, ".local", "bin", "codex"),
|
|
42391
|
+
join17(homeDir, "bin", "codex")
|
|
41908
42392
|
];
|
|
41909
42393
|
}
|
|
41910
42394
|
async function firstExecutablePath(paths, executableExists) {
|
|
@@ -41919,7 +42403,7 @@ function commandPathCandidates(path2) {
|
|
|
41919
42403
|
if (path2 === void 0 || path2.trim() === "") {
|
|
41920
42404
|
return [];
|
|
41921
42405
|
}
|
|
41922
|
-
return path2.split(delimiter3).filter((entry) => entry.trim() !== "").map((entry) =>
|
|
42406
|
+
return path2.split(delimiter3).filter((entry) => entry.trim() !== "").map((entry) => join17(entry, "codex"));
|
|
41923
42407
|
}
|
|
41924
42408
|
async function fileIsExecutable(path2) {
|
|
41925
42409
|
try {
|
|
@@ -42144,11 +42628,11 @@ function codexPreflightLocation(command, homeDir) {
|
|
|
42144
42628
|
switch (command) {
|
|
42145
42629
|
case "codex":
|
|
42146
42630
|
return "on PATH";
|
|
42147
|
-
case
|
|
42631
|
+
case join17(homeDir, ".volta", "bin", "codex"):
|
|
42148
42632
|
return "via Volta";
|
|
42149
|
-
case
|
|
42633
|
+
case join17(homeDir, ".local", "bin", "codex"):
|
|
42150
42634
|
return "via ~/.local/bin";
|
|
42151
|
-
case
|
|
42635
|
+
case join17(homeDir, "bin", "codex"):
|
|
42152
42636
|
return "via ~/bin";
|
|
42153
42637
|
default:
|
|
42154
42638
|
return "from configured path";
|
|
@@ -42303,13 +42787,13 @@ function probeToolWithArgs(command, args, cwd) {
|
|
|
42303
42787
|
}
|
|
42304
42788
|
async function discoverCodeRoots(homeDir) {
|
|
42305
42789
|
const candidates = ["src", "code", "projects"].map(
|
|
42306
|
-
(name) =>
|
|
42790
|
+
(name) => join17(homeDir, name)
|
|
42307
42791
|
);
|
|
42308
42792
|
return candidates.filter((path2) => existsSync12(path2)).flatMap((path2) => discoveredProjectNames(path2));
|
|
42309
42793
|
}
|
|
42310
42794
|
function discoveredProjectNames(root) {
|
|
42311
42795
|
try {
|
|
42312
|
-
return
|
|
42796
|
+
return readdirSync3(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).slice(0, 3).map((entry) => `~/${root.split("/").at(-1)}/${entry.name}`);
|
|
42313
42797
|
} catch {
|
|
42314
42798
|
return [];
|
|
42315
42799
|
}
|
|
@@ -42357,7 +42841,7 @@ function discoverProjectsFromCurrentDirectory(cwd) {
|
|
|
42357
42841
|
}
|
|
42358
42842
|
function discoverProjectsFromGuessedRoots(homeDir) {
|
|
42359
42843
|
const guessedRoots = ["src", "code", "projects"].map(
|
|
42360
|
-
(name) =>
|
|
42844
|
+
(name) => join17(homeDir, name)
|
|
42361
42845
|
);
|
|
42362
42846
|
const projects = guessedRoots.flatMap(
|
|
42363
42847
|
(root) => discoverProjectsUnderRoot(root)
|
|
@@ -42409,25 +42893,25 @@ function looksLikeProject(path2) {
|
|
|
42409
42893
|
"pnpm-lock.yaml",
|
|
42410
42894
|
"yarn.lock",
|
|
42411
42895
|
"package-lock.json"
|
|
42412
|
-
].some((name) => existsSync12(
|
|
42896
|
+
].some((name) => existsSync12(join17(path2, name)));
|
|
42413
42897
|
}
|
|
42414
42898
|
function detectProjectLanguage(path2) {
|
|
42415
|
-
if (existsSync12(
|
|
42899
|
+
if (existsSync12(join17(path2, "pyproject.toml")) || existsSync12(join17(path2, "requirements.txt"))) {
|
|
42416
42900
|
return "Python";
|
|
42417
42901
|
}
|
|
42418
|
-
if (existsSync12(
|
|
42902
|
+
if (existsSync12(join17(path2, "Cargo.toml"))) {
|
|
42419
42903
|
return "Rust";
|
|
42420
42904
|
}
|
|
42421
|
-
if (existsSync12(
|
|
42905
|
+
if (existsSync12(join17(path2, "go.mod"))) {
|
|
42422
42906
|
return "Go";
|
|
42423
42907
|
}
|
|
42424
|
-
if (existsSync12(
|
|
42908
|
+
if (existsSync12(join17(path2, "mix.exs"))) {
|
|
42425
42909
|
return "Elixir";
|
|
42426
42910
|
}
|
|
42427
|
-
if (existsSync12(
|
|
42911
|
+
if (existsSync12(join17(path2, "tsconfig.json")) || packageJsonMentionsTypeScript(path2)) {
|
|
42428
42912
|
return "TypeScript";
|
|
42429
42913
|
}
|
|
42430
|
-
if (existsSync12(
|
|
42914
|
+
if (existsSync12(join17(path2, "package.json"))) {
|
|
42431
42915
|
return "JavaScript";
|
|
42432
42916
|
}
|
|
42433
42917
|
return "Project";
|
|
@@ -42435,7 +42919,7 @@ function detectProjectLanguage(path2) {
|
|
|
42435
42919
|
function packageJsonMentionsTypeScript(path2) {
|
|
42436
42920
|
try {
|
|
42437
42921
|
const packageJson2 = JSON.parse(
|
|
42438
|
-
|
|
42922
|
+
readFileSync15(join17(path2, "package.json"), "utf8")
|
|
42439
42923
|
);
|
|
42440
42924
|
return packageJson2.dependencies?.typescript !== void 0 || packageJson2.devDependencies?.typescript !== void 0;
|
|
42441
42925
|
} catch {
|
|
@@ -42443,11 +42927,11 @@ function packageJsonMentionsTypeScript(path2) {
|
|
|
42443
42927
|
}
|
|
42444
42928
|
}
|
|
42445
42929
|
function hasGitMetadata(path2) {
|
|
42446
|
-
return existsSync12(
|
|
42930
|
+
return existsSync12(join17(path2, ".git"));
|
|
42447
42931
|
}
|
|
42448
42932
|
function childDirectories(root) {
|
|
42449
42933
|
try {
|
|
42450
|
-
return
|
|
42934
|
+
return readdirSync3(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join17(root, entry.name));
|
|
42451
42935
|
} catch {
|
|
42452
42936
|
return [];
|
|
42453
42937
|
}
|
|
@@ -42473,10 +42957,10 @@ function directoryExists(path2) {
|
|
|
42473
42957
|
}
|
|
42474
42958
|
function expandHomePath(path2) {
|
|
42475
42959
|
if (path2 === "~") {
|
|
42476
|
-
return
|
|
42960
|
+
return homedir13();
|
|
42477
42961
|
}
|
|
42478
42962
|
if (path2.startsWith("~/")) {
|
|
42479
|
-
return
|
|
42963
|
+
return join17(homedir13(), path2.slice(2));
|
|
42480
42964
|
}
|
|
42481
42965
|
return resolve9(path2);
|
|
42482
42966
|
}
|
|
@@ -42564,8 +43048,8 @@ secure mission control for all your agents on your computers
|
|
|
42564
43048
|
init_runner();
|
|
42565
43049
|
init_claudeCodeSession();
|
|
42566
43050
|
init_authCache();
|
|
42567
|
-
import { existsSync as existsSync13, readFileSync as
|
|
42568
|
-
import { homedir as
|
|
43051
|
+
import { existsSync as existsSync13, readFileSync as readFileSync16, realpathSync as realpathSync6 } from "node:fs";
|
|
43052
|
+
import { homedir as homedir14 } from "node:os";
|
|
42569
43053
|
import { resolve as resolve10 } from "node:path";
|
|
42570
43054
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
42571
43055
|
|
|
@@ -42626,9 +43110,9 @@ init_kandanTls();
|
|
|
42626
43110
|
init_protocol();
|
|
42627
43111
|
init_json();
|
|
42628
43112
|
init_defaultUrls();
|
|
42629
|
-
import { existsSync as existsSync10, mkdirSync as mkdirSync10, readFileSync as
|
|
42630
|
-
import { dirname as dirname10, join as
|
|
42631
|
-
import { homedir as
|
|
43113
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync10, readFileSync as readFileSync12, writeFileSync as writeFileSync8 } from "node:fs";
|
|
43114
|
+
import { dirname as dirname10, join as join15 } from "node:path";
|
|
43115
|
+
import { homedir as homedir11 } from "node:os";
|
|
42632
43116
|
async function runAgentCliCommand(args, deps = {
|
|
42633
43117
|
fetchImpl: fetch,
|
|
42634
43118
|
stdout: process.stdout,
|
|
@@ -43273,7 +43757,7 @@ async function postJson(apiUrl, path2, body, token, fetchImpl) {
|
|
|
43273
43757
|
async function fetchJson(url, init, fetchImpl) {
|
|
43274
43758
|
const response = await fetchImpl(url, init);
|
|
43275
43759
|
const text2 = await response.text();
|
|
43276
|
-
const payload =
|
|
43760
|
+
const payload = parseJsonObject2(text2);
|
|
43277
43761
|
if (!response.ok) {
|
|
43278
43762
|
const error = objectValue(payload.error);
|
|
43279
43763
|
const code = stringValue(error?.code) ?? `http_${response.status}`;
|
|
@@ -43282,7 +43766,7 @@ async function fetchJson(url, init, fetchImpl) {
|
|
|
43282
43766
|
}
|
|
43283
43767
|
return payload;
|
|
43284
43768
|
}
|
|
43285
|
-
function
|
|
43769
|
+
function parseJsonObject2(text2) {
|
|
43286
43770
|
try {
|
|
43287
43771
|
const parsed = JSON.parse(text2);
|
|
43288
43772
|
if (isJsonObject(parsed)) {
|
|
@@ -43336,7 +43820,7 @@ function agentTokenFile(flags) {
|
|
|
43336
43820
|
return flags.get("agent-token-file") ?? defaultAgentTokenFilePath();
|
|
43337
43821
|
}
|
|
43338
43822
|
function defaultAgentTokenFilePath() {
|
|
43339
|
-
return
|
|
43823
|
+
return join15(homedir11(), ".linzumi", "agent-token.json");
|
|
43340
43824
|
}
|
|
43341
43825
|
function normalizedApiUrl(apiUrl) {
|
|
43342
43826
|
return apiUrl.endsWith("/") ? apiUrl : `${apiUrl}/`;
|
|
@@ -43345,7 +43829,7 @@ function authorizationHeaders(token) {
|
|
|
43345
43829
|
return { authorization: `Bearer ${token}` };
|
|
43346
43830
|
}
|
|
43347
43831
|
function readOptionalTextFile(path2) {
|
|
43348
|
-
return existsSync10(path2) ?
|
|
43832
|
+
return existsSync10(path2) ? readFileSync12(path2, "utf8") : void 0;
|
|
43349
43833
|
}
|
|
43350
43834
|
function writeTextFile(path2, content) {
|
|
43351
43835
|
mkdirSync10(dirname10(path2), { recursive: true });
|
|
@@ -43356,7 +43840,7 @@ function readStoredAgentTokenFile(path2, readTextFile = readOptionalTextFile) {
|
|
|
43356
43840
|
if (content === void 0) {
|
|
43357
43841
|
throw new Error(`missing agent token file: ${path2}`);
|
|
43358
43842
|
}
|
|
43359
|
-
const parsed =
|
|
43843
|
+
const parsed = parseJsonObject2(content);
|
|
43360
43844
|
const cursorsValue = objectValue(parsed.cursors);
|
|
43361
43845
|
const cursors = cursorsValue === void 0 ? {} : Object.fromEntries(
|
|
43362
43846
|
Object.entries(cursorsValue).flatMap(([key, value]) => {
|
|
@@ -43440,23 +43924,23 @@ import {
|
|
|
43440
43924
|
closeSync as closeSync2,
|
|
43441
43925
|
mkdirSync as mkdirSync11,
|
|
43442
43926
|
openSync as openSync3,
|
|
43443
|
-
readFileSync as
|
|
43927
|
+
readFileSync as readFileSync13,
|
|
43444
43928
|
watch,
|
|
43445
43929
|
writeFileSync as writeFileSync9
|
|
43446
43930
|
} from "node:fs";
|
|
43447
|
-
import { homedir as
|
|
43448
|
-
import { dirname as dirname11, join as
|
|
43931
|
+
import { homedir as homedir12 } from "node:os";
|
|
43932
|
+
import { dirname as dirname11, join as join16, resolve as resolve8 } from "node:path";
|
|
43449
43933
|
import { execFileSync, spawn as spawn8 } from "node:child_process";
|
|
43450
43934
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
43451
43935
|
var connectedMarkers = ["Connected to Linzumi", "Runner connected:"];
|
|
43452
43936
|
function commanderStatusDir() {
|
|
43453
|
-
return
|
|
43937
|
+
return join16(homedir12(), ".linzumi", "commanders");
|
|
43454
43938
|
}
|
|
43455
43939
|
function commanderStatusFile(runnerId, statusDir = commanderStatusDir()) {
|
|
43456
|
-
return
|
|
43940
|
+
return join16(statusDir, `${safeRunnerId(runnerId)}.json`);
|
|
43457
43941
|
}
|
|
43458
43942
|
function defaultCommanderLogFile(runnerId, statusDir = commanderStatusDir()) {
|
|
43459
|
-
return
|
|
43943
|
+
return join16(statusDir, `${safeRunnerId(runnerId)}.log`);
|
|
43460
43944
|
}
|
|
43461
43945
|
function commanderLogIsConnected(log) {
|
|
43462
43946
|
return connectedMarkers.some((marker) => log.includes(marker));
|
|
@@ -43533,12 +44017,12 @@ function commanderDaemonStatus(runnerId, statusDir = commanderStatusDir(), proce
|
|
|
43533
44017
|
if (!existsSync11(statusFile)) {
|
|
43534
44018
|
return { status: "missing", runnerId, statusFile };
|
|
43535
44019
|
}
|
|
43536
|
-
const record = parseRecord(
|
|
44020
|
+
const record = parseRecord(readFileSync13(statusFile, "utf8"));
|
|
43537
44021
|
return processIsRunning(record.pid) && processMatchesRecord(record, processIdentityReader) ? { status: "running", record } : { status: "stopped", record };
|
|
43538
44022
|
}
|
|
43539
44023
|
async function waitForCommanderDaemon(options) {
|
|
43540
44024
|
const now = options.now ?? (() => Date.now());
|
|
43541
|
-
const readTextFile = options.readTextFile ?? ((path2) => existsSync11(path2) ?
|
|
44025
|
+
const readTextFile = options.readTextFile ?? ((path2) => existsSync11(path2) ? readFileSync13(path2, "utf8") : void 0);
|
|
43542
44026
|
const statusImpl = options.statusImpl ?? commanderDaemonStatus;
|
|
43543
44027
|
const deadline = now() + options.timeoutMs;
|
|
43544
44028
|
while (now() <= deadline) {
|
|
@@ -56648,7 +57132,7 @@ async function parseAgentRunnerArgs(args, deps = {
|
|
|
56648
57132
|
};
|
|
56649
57133
|
}
|
|
56650
57134
|
function readAgentTokenTextFile(path2) {
|
|
56651
|
-
return existsSync13(path2) ?
|
|
57135
|
+
return existsSync13(path2) ? readFileSync16(path2, "utf8") : void 0;
|
|
56652
57136
|
}
|
|
56653
57137
|
function rejectAgentRunnerTargetingFlags(values) {
|
|
56654
57138
|
const unsupportedFlags = [
|
|
@@ -56942,10 +57426,10 @@ function rejectStartTargetingFlags(values) {
|
|
|
56942
57426
|
}
|
|
56943
57427
|
function resolveUserPath(pathValue) {
|
|
56944
57428
|
if (pathValue === "~") {
|
|
56945
|
-
return
|
|
57429
|
+
return homedir14();
|
|
56946
57430
|
}
|
|
56947
57431
|
if (pathValue.startsWith("~/")) {
|
|
56948
|
-
return resolve10(
|
|
57432
|
+
return resolve10(homedir14(), pathValue.slice(2));
|
|
56949
57433
|
}
|
|
56950
57434
|
return resolve10(pathValue);
|
|
56951
57435
|
}
|