@super-one/cli 0.77.0-alpha.1 → 0.77.0-alpha.3
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/MANIFEST.json +2 -2
- package/lib/cli.mjs +552 -410
- package/package.json +1 -1
package/lib/cli.mjs
CHANGED
|
@@ -142,8 +142,8 @@ import { fileURLToPath } from "node:url";
|
|
|
142
142
|
function resolveCliReleaseVersion() {
|
|
143
143
|
const fromEnv = process.env.SUPERONE_CLI_VERSION?.trim();
|
|
144
144
|
if (fromEnv) return fromEnv;
|
|
145
|
-
if ("0.77.0-alpha.
|
|
146
|
-
return "0.77.0-alpha.
|
|
145
|
+
if ("0.77.0-alpha.3".trim()) {
|
|
146
|
+
return "0.77.0-alpha.3".trim();
|
|
147
147
|
}
|
|
148
148
|
const fromDist = readDistManifestVersion();
|
|
149
149
|
if (fromDist) return fromDist;
|
|
@@ -10753,8 +10753,8 @@ var init_mcp_app_resource = __esm({
|
|
|
10753
10753
|
return cached5 ? Promise.resolve(cached5) : this.refresh(key3, read5);
|
|
10754
10754
|
}
|
|
10755
10755
|
refresh(key3, read5) {
|
|
10756
|
-
const
|
|
10757
|
-
if (
|
|
10756
|
+
const pending4 = this.pending.get(key3);
|
|
10757
|
+
if (pending4) return pending4;
|
|
10758
10758
|
if (this.pending.size >= this.limits.pending) return Promise.reject(new McpAppsError("denied", "Too many pending MCP App resource reads"));
|
|
10759
10759
|
const next = Promise.resolve().then(read5).then((value) => {
|
|
10760
10760
|
this.put(key3, value);
|
|
@@ -11170,6 +11170,10 @@ function isToolResultBlock(block) {
|
|
|
11170
11170
|
function isToolUseBlock(block) {
|
|
11171
11171
|
return "toolName" in block;
|
|
11172
11172
|
}
|
|
11173
|
+
function hasEditReplacementFields(input) {
|
|
11174
|
+
const obj = parseInputObject(input);
|
|
11175
|
+
return typeof obj.old_string === "string" || typeof obj.new_string === "string" || typeof obj.TargetContent === "string" || typeof obj.ReplacementContent === "string" || Array.isArray(obj.ReplacementChunks) || Array.isArray(obj.edits);
|
|
11176
|
+
}
|
|
11173
11177
|
function parseInputObject(input) {
|
|
11174
11178
|
if (input == null || input === "") return {};
|
|
11175
11179
|
if (typeof input === "object" && !Array.isArray(input)) {
|
|
@@ -11254,7 +11258,15 @@ function applyIdentifiedDelta(content, delta, replace) {
|
|
|
11254
11258
|
if (target2.type === "text" && delta.type === "text") {
|
|
11255
11259
|
next = { ...target2, ...delta, text: replace ? delta.text : target2.text + delta.text };
|
|
11256
11260
|
} else if (target2.type === "thinking" && delta.type === "thinking") {
|
|
11257
|
-
|
|
11261
|
+
const remoteDetail = delta.remoteDetail ?? target2.remoteDetail;
|
|
11262
|
+
next = {
|
|
11263
|
+
...target2,
|
|
11264
|
+
...delta,
|
|
11265
|
+
thinking: replace ? delta.thinking : target2.thinking + delta.thinking,
|
|
11266
|
+
startedAt: target2.startedAt ?? delta.startedAt,
|
|
11267
|
+
endedAt: delta.endedAt ?? target2.endedAt,
|
|
11268
|
+
...remoteDetail !== void 0 ? { remoteDetail } : {}
|
|
11269
|
+
};
|
|
11258
11270
|
} else if (target2.type === "plan" && delta.type === "plan") {
|
|
11259
11271
|
next = { ...target2, text: replace ? delta.text : target2.text + delta.text };
|
|
11260
11272
|
} else {
|
|
@@ -11280,11 +11292,13 @@ function applyContentDelta(content, delta, now = Date.now, options = {}) {
|
|
|
11280
11292
|
const idx = lastMergeTargetIndex(content, delta);
|
|
11281
11293
|
const target2 = idx === -1 ? void 0 : content[idx];
|
|
11282
11294
|
if (target2?.type === "thinking" && target2.id === void 0) {
|
|
11295
|
+
const remoteDetail = delta.remoteDetail ?? target2.remoteDetail;
|
|
11283
11296
|
return content.map((b5, i2) => i2 === idx ? {
|
|
11284
11297
|
...target2,
|
|
11285
11298
|
thinking: target2.thinking + delta.thinking,
|
|
11286
11299
|
startedAt: target2.startedAt ?? delta.startedAt,
|
|
11287
|
-
endedAt: delta.endedAt ?? target2.endedAt
|
|
11300
|
+
endedAt: delta.endedAt ?? target2.endedAt,
|
|
11301
|
+
...remoteDetail !== void 0 ? { remoteDetail } : {}
|
|
11288
11302
|
} : b5);
|
|
11289
11303
|
}
|
|
11290
11304
|
}
|
|
@@ -11301,12 +11315,14 @@ function applyContentDelta(content, delta, now = Date.now, options = {}) {
|
|
|
11301
11315
|
delta.toolSummary,
|
|
11302
11316
|
mergedInput
|
|
11303
11317
|
);
|
|
11318
|
+
const preservedToolName = existing.toolName === "Write" && delta.toolName === "Edit" && !hasEditReplacementFields(delta.input) ? existing.toolName : delta.toolName;
|
|
11304
11319
|
const liveOutput = delta.outputDelta === void 0 ? existing.liveOutput : options.replace ? delta.outputDelta : (existing.liveOutput ?? "") + delta.outputDelta;
|
|
11305
11320
|
return content.map((b5, i2) => i2 === idx ? {
|
|
11306
11321
|
...existing,
|
|
11307
11322
|
...withoutOutputDelta(delta),
|
|
11308
11323
|
...liveOutput !== void 0 ? { liveOutput } : {},
|
|
11309
11324
|
...existing.app || delta.app ? { app: mergeMcpAppAttachment(existing.app, delta.app) } : {},
|
|
11325
|
+
toolName: preservedToolName,
|
|
11310
11326
|
startedAt: existing.startedAt,
|
|
11311
11327
|
elapsedSeconds: delta.elapsedSeconds ?? existing.elapsedSeconds,
|
|
11312
11328
|
status: delta.status ?? existing.status,
|
|
@@ -11452,7 +11468,14 @@ var init_content_delta = __esm({
|
|
|
11452
11468
|
"skill",
|
|
11453
11469
|
"tool_name",
|
|
11454
11470
|
"subject",
|
|
11455
|
-
"task_id"
|
|
11471
|
+
"task_id",
|
|
11472
|
+
"content",
|
|
11473
|
+
"CodeContent",
|
|
11474
|
+
"old_string",
|
|
11475
|
+
"new_string",
|
|
11476
|
+
"TargetContent",
|
|
11477
|
+
"ReplacementContent",
|
|
11478
|
+
"TargetFile"
|
|
11456
11479
|
];
|
|
11457
11480
|
CODEX_DETACHED_ITEM_TYPES = /* @__PURE__ */ new Set(["image_generation", "video_generation"]);
|
|
11458
11481
|
}
|
|
@@ -11822,21 +11845,21 @@ function codexAsyncQuestionItems(message) {
|
|
|
11822
11845
|
function pendingCodexAsyncQuestions(messages) {
|
|
11823
11846
|
const answered = new Set(messages.filter(isCodexAsyncAnswer).map((message) => message.id));
|
|
11824
11847
|
const seen = /* @__PURE__ */ new Set();
|
|
11825
|
-
const
|
|
11848
|
+
const pending4 = [];
|
|
11826
11849
|
for (const message of messages) {
|
|
11827
11850
|
if (message.role !== "assistant") continue;
|
|
11828
11851
|
for (const item of codexAsyncQuestionItems(message)) {
|
|
11829
11852
|
if (seen.has(item.id)) continue;
|
|
11830
11853
|
seen.add(item.id);
|
|
11831
|
-
if (!answered.has(codexAsyncAnswerId(item.id)))
|
|
11854
|
+
if (!answered.has(codexAsyncAnswerId(item.id))) pending4.push({ messageId: message.id, item, request: codexAsyncQuestionRequest(item) });
|
|
11832
11855
|
}
|
|
11833
11856
|
}
|
|
11834
|
-
return
|
|
11857
|
+
return pending4;
|
|
11835
11858
|
}
|
|
11836
11859
|
function codexAsyncQuestionQueue(session) {
|
|
11837
|
-
const
|
|
11860
|
+
const pending4 = session.pendingAsyncQuestions ?? pendingCodexAsyncQuestions(session.messages);
|
|
11838
11861
|
const answered = new Set(session.messages.filter(isCodexAsyncAnswer).map((message) => message.id));
|
|
11839
|
-
return
|
|
11862
|
+
return pending4.some((q3) => answered.has(q3.request.requestId)) ? pending4.filter((q3) => !answered.has(q3.request.requestId)) : pending4;
|
|
11840
11863
|
}
|
|
11841
11864
|
function codexAsyncAnswerQuestions(message, messages) {
|
|
11842
11865
|
if (!isCodexAsyncAnswer(message)) return void 0;
|
|
@@ -12004,10 +12027,10 @@ function coverBeforeCut(content, at2) {
|
|
|
12004
12027
|
const keys = contentKeys(content);
|
|
12005
12028
|
const counts = /* @__PURE__ */ new Map();
|
|
12006
12029
|
const map2 = {};
|
|
12007
|
-
let
|
|
12030
|
+
let pending4 = [];
|
|
12008
12031
|
const flush = () => {
|
|
12009
|
-
for (const item of
|
|
12010
|
-
|
|
12032
|
+
for (const item of pending4) map2[item.key] = item.length;
|
|
12033
|
+
pending4 = [];
|
|
12011
12034
|
};
|
|
12012
12035
|
const placed = () => (counts.get(kind) ?? 0) === target2 && Object.keys(map2).length ? map2 : null;
|
|
12013
12036
|
for (let index = 0; index < content.length; index++) {
|
|
@@ -12023,7 +12046,7 @@ function coverBeforeCut(content, at2) {
|
|
|
12023
12046
|
counts.set(name, (counts.get(name) ?? 0) + value);
|
|
12024
12047
|
}
|
|
12025
12048
|
if (count === 0) {
|
|
12026
|
-
if (key3)
|
|
12049
|
+
if (key3) pending4.push({ key: key3, length: -1 });
|
|
12027
12050
|
continue;
|
|
12028
12051
|
}
|
|
12029
12052
|
if (target2 < start || target2 < start + count) return target2 < start ? placed() : null;
|
|
@@ -12048,7 +12071,7 @@ function coverBeforeCut(content, at2) {
|
|
|
12048
12071
|
}
|
|
12049
12072
|
}
|
|
12050
12073
|
const text4 = blockText(block);
|
|
12051
|
-
if (key3)
|
|
12074
|
+
if (key3) pending4.push({ key: key3, length: text4 === void 0 ? -1 : text4.length });
|
|
12052
12075
|
}
|
|
12053
12076
|
return placed();
|
|
12054
12077
|
}
|
|
@@ -13990,6 +14013,53 @@ var init_input_admission = __esm({
|
|
|
13990
14013
|
}
|
|
13991
14014
|
});
|
|
13992
14015
|
|
|
14016
|
+
// ../../packages/runtime/src/session/codex-async-question.ts
|
|
14017
|
+
async function answerNodeAsyncQuestion(session, messages, command, deliver) {
|
|
14018
|
+
if (session.harnessId !== "codex") throw Object.assign(new Error("Async questions require a Codex session"), { code: "unsupported" });
|
|
14019
|
+
const savedId = typeof command.itemId === "string" ? codexAsyncAnswerId(command.itemId) : null;
|
|
14020
|
+
const saved = codexAsyncReplyText(messages.find((message2) => message2.id === savedId && message2.role === "user"));
|
|
14021
|
+
if (saved !== null) return { reply: saved };
|
|
14022
|
+
const message = messages.find((message2) => message2.id === command.messageId && message2.role === "assistant");
|
|
14023
|
+
const item = message ? codexAsyncQuestionItems(message).find((item2) => item2.id === command.itemId) : void 0;
|
|
14024
|
+
if (!item?.questions?.length) throw Object.assign(new Error("Async question not found"), { code: "not_found" });
|
|
14025
|
+
if (!Array.isArray(command.answers) || command.answers.length !== item.questions.length || command.answers.some((answer2) => typeof answer2 !== "string" || !answer2.trim())) {
|
|
14026
|
+
throw Object.assign(new Error("Every question requires an answer"), { code: "invalid_argument" });
|
|
14027
|
+
}
|
|
14028
|
+
const replyId = codexAsyncAnswerId(item.id);
|
|
14029
|
+
let requests2 = pending.get(session);
|
|
14030
|
+
if (!requests2) {
|
|
14031
|
+
requests2 = /* @__PURE__ */ new Map();
|
|
14032
|
+
pending.set(session, requests2);
|
|
14033
|
+
}
|
|
14034
|
+
const existing = requests2.get(replyId);
|
|
14035
|
+
if (existing) return existing;
|
|
14036
|
+
const reply = formatCodexAsyncQuestionReply(item.questions, command.answers);
|
|
14037
|
+
const answer = anchorAsyncAnswer({
|
|
14038
|
+
id: replyId,
|
|
14039
|
+
role: "user",
|
|
14040
|
+
status: "complete",
|
|
14041
|
+
content: [{ type: "text", text: reply, codexAsyncQuestions: item.questions }],
|
|
14042
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
14043
|
+
providerId: "codex"
|
|
14044
|
+
}, messages);
|
|
14045
|
+
const request = deliver(answer, reply).then(() => ({ reply }));
|
|
14046
|
+
requests2.set(replyId, request);
|
|
14047
|
+
try {
|
|
14048
|
+
return await request;
|
|
14049
|
+
} finally {
|
|
14050
|
+
requests2.delete(replyId);
|
|
14051
|
+
}
|
|
14052
|
+
}
|
|
14053
|
+
var pending;
|
|
14054
|
+
var init_codex_async_question2 = __esm({
|
|
14055
|
+
"../../packages/runtime/src/session/codex-async-question.ts"() {
|
|
14056
|
+
"use strict";
|
|
14057
|
+
init_codex_async_question();
|
|
14058
|
+
init_transcript_boundary();
|
|
14059
|
+
pending = /* @__PURE__ */ new WeakMap();
|
|
14060
|
+
}
|
|
14061
|
+
});
|
|
14062
|
+
|
|
13993
14063
|
// ../../packages/shared/src/codex-accounts.ts
|
|
13994
14064
|
function isCodexAccountProvider(id) {
|
|
13995
14065
|
return !!id?.startsWith(CODEX_ACCOUNT_PREFIX);
|
|
@@ -17610,6 +17680,7 @@ var init_session_runtime = __esm({
|
|
|
17610
17680
|
init_attachment_state();
|
|
17611
17681
|
init_artifact_wakes();
|
|
17612
17682
|
init_input_admission();
|
|
17683
|
+
init_codex_async_question2();
|
|
17613
17684
|
init_codex_accounts();
|
|
17614
17685
|
init_session_send();
|
|
17615
17686
|
init_agent_types();
|
|
@@ -18587,6 +18658,45 @@ var init_session_runtime = __esm({
|
|
|
18587
18658
|
}) {
|
|
18588
18659
|
const session = this.live.get(sessionId);
|
|
18589
18660
|
if (!session || session.closed) throw Object.assign(new Error("session not found"), { code: "not_found" });
|
|
18661
|
+
if (method === "session.answerAsyncQuestion") {
|
|
18662
|
+
assertControl2();
|
|
18663
|
+
if (this.disposing || session.status === "ended") throw Object.assign(new Error("session is closed"), { code: "failed_precondition" });
|
|
18664
|
+
return answerNodeAsyncQuestion(session, this.messages(sessionId), input, async (message, text4) => {
|
|
18665
|
+
const admission = new InputAdmission({
|
|
18666
|
+
beforeInput: assertControl2,
|
|
18667
|
+
onInputAccepted: () => {
|
|
18668
|
+
session.transcript.push({
|
|
18669
|
+
id: message.id,
|
|
18670
|
+
role: "user",
|
|
18671
|
+
text: text4,
|
|
18672
|
+
createdAt: Date.parse(message.createdAt),
|
|
18673
|
+
userMessageContent: message.content,
|
|
18674
|
+
...message.metadata ? { metadata: message.metadata } : {}
|
|
18675
|
+
});
|
|
18676
|
+
session.updatedAt = Date.now();
|
|
18677
|
+
this.persist(session);
|
|
18678
|
+
this.events.appendSession({
|
|
18679
|
+
sessionId,
|
|
18680
|
+
eventType: SESSION_DURABLE_EVENT.userMessage,
|
|
18681
|
+
payload: { blockId: message.id, text: text4, message, echoUserMessage: true }
|
|
18682
|
+
});
|
|
18683
|
+
}
|
|
18684
|
+
});
|
|
18685
|
+
this.beginTurn(session, {
|
|
18686
|
+
text: text4,
|
|
18687
|
+
userBlockId: message.id,
|
|
18688
|
+
inputAdmission: admission,
|
|
18689
|
+
// The Codex runner steers a live turn and starts normally when it has ended.
|
|
18690
|
+
turnKind: "run",
|
|
18691
|
+
model: session.model,
|
|
18692
|
+
effort: session.effort,
|
|
18693
|
+
apiProviderId: session.apiProviderId,
|
|
18694
|
+
permissionMode: session.permissionMode,
|
|
18695
|
+
sandboxMode: session.sandboxMode
|
|
18696
|
+
});
|
|
18697
|
+
await admission.promise;
|
|
18698
|
+
});
|
|
18699
|
+
}
|
|
18590
18700
|
if (method === "session.steer" || method === "session.dequeue") return operateNodeQueue(method, input, {
|
|
18591
18701
|
session,
|
|
18592
18702
|
queue: this.turnQueues.get(sessionId) ?? [],
|
|
@@ -18615,7 +18725,7 @@ var init_session_runtime = __esm({
|
|
|
18615
18725
|
});
|
|
18616
18726
|
}
|
|
18617
18727
|
get servedOperations() {
|
|
18618
|
-
return
|
|
18728
|
+
return /* @__PURE__ */ new Set(["session.answerAsyncQuestion", ...this.turnRunner.servedOperations ?? []]);
|
|
18619
18729
|
}
|
|
18620
18730
|
/** Live Codex app-server for a voice call on this node. */
|
|
18621
18731
|
codexVoice() {
|
|
@@ -19199,11 +19309,11 @@ var init_session_runtime = __esm({
|
|
|
19199
19309
|
generation: input.generation,
|
|
19200
19310
|
holderClientId: input.client.clientSessionId
|
|
19201
19311
|
});
|
|
19202
|
-
const
|
|
19203
|
-
if (!
|
|
19312
|
+
const pending4 = session.pendingInteraction;
|
|
19313
|
+
if (!pending4 || pending4.interactionId !== input.interactionId) {
|
|
19204
19314
|
throw Object.assign(new Error("no matching pending permission"), { code: "failed_precondition" });
|
|
19205
19315
|
}
|
|
19206
|
-
if (
|
|
19316
|
+
if (pending4.kind === "session_agents_confirm" || pending4.kind === "session_cleanup_confirm") {
|
|
19207
19317
|
const waiter2 = this.agentsConfirmWaiters.get(input.interactionId);
|
|
19208
19318
|
if (!waiter2 || waiter2.sessionId !== input.sessionId) {
|
|
19209
19319
|
throw Object.assign(new Error("no matching pending agents confirm"), {
|
|
@@ -19221,7 +19331,7 @@ var init_session_runtime = __esm({
|
|
|
19221
19331
|
});
|
|
19222
19332
|
return;
|
|
19223
19333
|
}
|
|
19224
|
-
if (
|
|
19334
|
+
if (pending4.kind && pending4.kind !== "permission") {
|
|
19225
19335
|
throw Object.assign(new Error("no matching pending permission"), { code: "failed_precondition" });
|
|
19226
19336
|
}
|
|
19227
19337
|
const waiter = this.permissionWaiters.get(input.interactionId);
|
|
@@ -19229,14 +19339,14 @@ var init_session_runtime = __esm({
|
|
|
19229
19339
|
throw Object.assign(new Error("no matching pending permission"), { code: "failed_precondition" });
|
|
19230
19340
|
}
|
|
19231
19341
|
const decision = input.decision === "deny" || input.cancel ? "deny" : "allow";
|
|
19232
|
-
if (input.decision === "allow_always" &&
|
|
19342
|
+
if (input.decision === "allow_always" && pending4.permissionDetails && pending4.allowAlwaysAllow === false && !input.cancel) {
|
|
19233
19343
|
throw Object.assign(new Error("This native permission request supports allow once or deny"), { code: "failed_precondition" });
|
|
19234
19344
|
}
|
|
19235
|
-
if (
|
|
19236
|
-
const accepted = acceptedElicitationContent(
|
|
19345
|
+
if (pending4.requestKind === "mcp_elicitation" && decision === "allow") {
|
|
19346
|
+
const accepted = acceptedElicitationContent(pending4.schemaForm, input.formAnswers);
|
|
19237
19347
|
if (!accepted.ok) throw Object.assign(new Error(accepted.reason), { code: "failed_precondition" });
|
|
19238
19348
|
}
|
|
19239
|
-
if (input.decision === "allow_always" &&
|
|
19349
|
+
if (input.decision === "allow_always" && pending4.requestKind !== "mcp_elicitation" && !input.cancel) {
|
|
19240
19350
|
const tool2 = session.pendingInteraction?.toolName?.trim();
|
|
19241
19351
|
if (tool2) {
|
|
19242
19352
|
const list = session.alwaysAllowedTools ?? [];
|
|
@@ -19559,27 +19669,27 @@ var init_session_runtime = __esm({
|
|
|
19559
19669
|
}
|
|
19560
19670
|
/** Deny and clear any active permission waiter for this session. */
|
|
19561
19671
|
rejectPendingPermission(session) {
|
|
19562
|
-
const
|
|
19563
|
-
if (!
|
|
19564
|
-
if (
|
|
19565
|
-
const qw = this.questionWaiters.get(
|
|
19672
|
+
const pending4 = session.pendingInteraction;
|
|
19673
|
+
if (!pending4) return;
|
|
19674
|
+
if (pending4.kind === "question") {
|
|
19675
|
+
const qw = this.questionWaiters.get(pending4.interactionId);
|
|
19566
19676
|
if (qw) qw.settle({ answers: {}, reason: "aborted" });
|
|
19567
19677
|
else session.pendingInteraction = null;
|
|
19568
19678
|
return;
|
|
19569
19679
|
}
|
|
19570
|
-
if (
|
|
19571
|
-
const pw = this.planWaiters.get(
|
|
19680
|
+
if (pending4.kind === "plan") {
|
|
19681
|
+
const pw = this.planWaiters.get(pending4.interactionId);
|
|
19572
19682
|
if (pw) pw.settle({ decision: "reject", reason: "aborted" });
|
|
19573
19683
|
else session.pendingInteraction = null;
|
|
19574
19684
|
return;
|
|
19575
19685
|
}
|
|
19576
|
-
if (
|
|
19577
|
-
const aw = this.agentsConfirmWaiters.get(
|
|
19686
|
+
if (pending4.kind === "session_agents_confirm" || pending4.kind === "session_cleanup_confirm") {
|
|
19687
|
+
const aw = this.agentsConfirmWaiters.get(pending4.interactionId);
|
|
19578
19688
|
if (aw) aw.settle({ action: "cancel", reason: "aborted" });
|
|
19579
19689
|
else session.pendingInteraction = null;
|
|
19580
19690
|
return;
|
|
19581
19691
|
}
|
|
19582
|
-
const waiter = this.permissionWaiters.get(
|
|
19692
|
+
const waiter = this.permissionWaiters.get(pending4.interactionId);
|
|
19583
19693
|
if (waiter) {
|
|
19584
19694
|
waiter.settle({ decision: "deny", reason: "aborted" });
|
|
19585
19695
|
} else {
|
|
@@ -19590,23 +19700,23 @@ var init_session_runtime = __esm({
|
|
|
19590
19700
|
if (session.pendingInteraction) {
|
|
19591
19701
|
this.rejectPendingPermission(session);
|
|
19592
19702
|
}
|
|
19593
|
-
const
|
|
19703
|
+
const pending4 = { ...interaction, kind: "question" };
|
|
19594
19704
|
return new Promise((resolve24) => {
|
|
19595
19705
|
let settled = false;
|
|
19596
|
-
session.pendingInteraction =
|
|
19706
|
+
session.pendingInteraction = pending4;
|
|
19597
19707
|
session.updatedAt = Date.now();
|
|
19598
19708
|
this.persist(session);
|
|
19599
19709
|
this.events.appendSession({
|
|
19600
19710
|
sessionId: session.sessionId,
|
|
19601
19711
|
eventType: SESSION_DURABLE_EVENT.questionRequested,
|
|
19602
|
-
payload:
|
|
19712
|
+
payload: pending4,
|
|
19603
19713
|
causationRequestId: requestId
|
|
19604
19714
|
});
|
|
19605
19715
|
const settle2 = (result3) => {
|
|
19606
19716
|
if (settled) return;
|
|
19607
19717
|
settled = true;
|
|
19608
|
-
this.questionWaiters.delete(
|
|
19609
|
-
if (session.pendingInteraction?.interactionId ===
|
|
19718
|
+
this.questionWaiters.delete(pending4.interactionId);
|
|
19719
|
+
if (session.pendingInteraction?.interactionId === pending4.interactionId) {
|
|
19610
19720
|
session.pendingInteraction = null;
|
|
19611
19721
|
session.updatedAt = Date.now();
|
|
19612
19722
|
this.persist(session);
|
|
@@ -19615,18 +19725,18 @@ var init_session_runtime = __esm({
|
|
|
19615
19725
|
this.events.appendSession({
|
|
19616
19726
|
sessionId: session.sessionId,
|
|
19617
19727
|
eventType: SESSION_DURABLE_EVENT.questionResponded,
|
|
19618
|
-
payload: { interactionId:
|
|
19728
|
+
payload: { interactionId: pending4.interactionId, answers: result3.answers }
|
|
19619
19729
|
});
|
|
19620
19730
|
} else {
|
|
19621
19731
|
this.events.appendSession({
|
|
19622
19732
|
sessionId: session.sessionId,
|
|
19623
19733
|
eventType: SESSION_DURABLE_EVENT.questionAborted,
|
|
19624
|
-
payload: { interactionId:
|
|
19734
|
+
payload: { interactionId: pending4.interactionId }
|
|
19625
19735
|
});
|
|
19626
19736
|
}
|
|
19627
19737
|
resolve24(result3.answers);
|
|
19628
19738
|
};
|
|
19629
|
-
this.questionWaiters.set(
|
|
19739
|
+
this.questionWaiters.set(pending4.interactionId, {
|
|
19630
19740
|
sessionId: session.sessionId,
|
|
19631
19741
|
settle: settle2
|
|
19632
19742
|
});
|
|
@@ -19647,23 +19757,23 @@ var init_session_runtime = __esm({
|
|
|
19647
19757
|
if (session.pendingInteraction) {
|
|
19648
19758
|
this.rejectPendingPermission(session);
|
|
19649
19759
|
}
|
|
19650
|
-
const
|
|
19760
|
+
const pending4 = { ...interaction, kind: "plan" };
|
|
19651
19761
|
return new Promise((resolve24) => {
|
|
19652
19762
|
let settled = false;
|
|
19653
|
-
session.pendingInteraction =
|
|
19763
|
+
session.pendingInteraction = pending4;
|
|
19654
19764
|
session.updatedAt = Date.now();
|
|
19655
19765
|
this.persist(session);
|
|
19656
19766
|
this.events.appendSession({
|
|
19657
19767
|
sessionId: session.sessionId,
|
|
19658
19768
|
eventType: SESSION_DURABLE_EVENT.planRequested,
|
|
19659
|
-
payload:
|
|
19769
|
+
payload: pending4,
|
|
19660
19770
|
causationRequestId: requestId
|
|
19661
19771
|
});
|
|
19662
19772
|
const settle2 = (result3) => {
|
|
19663
19773
|
if (settled) return;
|
|
19664
19774
|
settled = true;
|
|
19665
|
-
this.planWaiters.delete(
|
|
19666
|
-
if (session.pendingInteraction?.interactionId ===
|
|
19775
|
+
this.planWaiters.delete(pending4.interactionId);
|
|
19776
|
+
if (session.pendingInteraction?.interactionId === pending4.interactionId) {
|
|
19667
19777
|
session.pendingInteraction = null;
|
|
19668
19778
|
session.updatedAt = Date.now();
|
|
19669
19779
|
this.persist(session);
|
|
@@ -19673,7 +19783,7 @@ var init_session_runtime = __esm({
|
|
|
19673
19783
|
sessionId: session.sessionId,
|
|
19674
19784
|
eventType: SESSION_DURABLE_EVENT.planResponded,
|
|
19675
19785
|
payload: {
|
|
19676
|
-
interactionId:
|
|
19786
|
+
interactionId: pending4.interactionId,
|
|
19677
19787
|
decision: result3.decision,
|
|
19678
19788
|
options: result3.options
|
|
19679
19789
|
}
|
|
@@ -19682,12 +19792,12 @@ var init_session_runtime = __esm({
|
|
|
19682
19792
|
this.events.appendSession({
|
|
19683
19793
|
sessionId: session.sessionId,
|
|
19684
19794
|
eventType: SESSION_DURABLE_EVENT.planAborted,
|
|
19685
|
-
payload: { interactionId:
|
|
19795
|
+
payload: { interactionId: pending4.interactionId, decision: "reject" }
|
|
19686
19796
|
});
|
|
19687
19797
|
}
|
|
19688
19798
|
resolve24({ decision: result3.decision, options: result3.options });
|
|
19689
19799
|
};
|
|
19690
|
-
this.planWaiters.set(
|
|
19800
|
+
this.planWaiters.set(pending4.interactionId, {
|
|
19691
19801
|
sessionId: session.sessionId,
|
|
19692
19802
|
settle: settle2
|
|
19693
19803
|
});
|
|
@@ -22850,85 +22960,85 @@ var init_ask_user_question = __esm({
|
|
|
22850
22960
|
});
|
|
22851
22961
|
|
|
22852
22962
|
// ../../packages/shared/src/node-session-messages.ts
|
|
22853
|
-
function nodePendingToPermissionRequest(
|
|
22854
|
-
if (!
|
|
22855
|
-
if (
|
|
22856
|
-
const confirm =
|
|
22963
|
+
function nodePendingToPermissionRequest(pending4) {
|
|
22964
|
+
if (!pending4?.interactionId) return null;
|
|
22965
|
+
if (pending4.kind === "session_agents_confirm") {
|
|
22966
|
+
const confirm = pending4.sessionAgentsConfirm;
|
|
22857
22967
|
const payload = {
|
|
22858
22968
|
launches: Array.isArray(confirm?.launches) ? confirm.launches : [],
|
|
22859
22969
|
profiles: Array.isArray(confirm?.profiles) ? confirm.profiles : []
|
|
22860
22970
|
};
|
|
22861
22971
|
return {
|
|
22862
|
-
requestId:
|
|
22863
|
-
toolName:
|
|
22864
|
-
toolUseId:
|
|
22865
|
-
input:
|
|
22972
|
+
requestId: pending4.interactionId,
|
|
22973
|
+
toolName: pending4.toolName || "session_collab_request",
|
|
22974
|
+
toolUseId: pending4.toolUseId ?? pending4.interactionId,
|
|
22975
|
+
input: pending4.input && typeof pending4.input === "object" ? pending4.input : {},
|
|
22866
22976
|
allowAlwaysAllow: false,
|
|
22867
22977
|
requestKind: "session_agents_confirm",
|
|
22868
|
-
serverName:
|
|
22869
|
-
message:
|
|
22978
|
+
serverName: pending4.serverName || "superone",
|
|
22979
|
+
message: pending4.message || "Allow this agent to start the following sessions?",
|
|
22870
22980
|
sessionAgentsConfirm: payload
|
|
22871
22981
|
};
|
|
22872
22982
|
}
|
|
22873
|
-
if (
|
|
22874
|
-
const sessions = Array.isArray(
|
|
22983
|
+
if (pending4.kind === "session_cleanup_confirm") {
|
|
22984
|
+
const sessions = Array.isArray(pending4.sessionCleanupConfirm?.sessions) ? pending4.sessionCleanupConfirm.sessions : [];
|
|
22875
22985
|
return {
|
|
22876
|
-
requestId:
|
|
22877
|
-
toolName:
|
|
22878
|
-
toolUseId:
|
|
22879
|
-
input:
|
|
22986
|
+
requestId: pending4.interactionId,
|
|
22987
|
+
toolName: pending4.toolName || "mcp__superone__session_cleanup",
|
|
22988
|
+
toolUseId: pending4.toolUseId ?? pending4.interactionId,
|
|
22989
|
+
input: pending4.input && typeof pending4.input === "object" ? pending4.input : {},
|
|
22880
22990
|
allowAlwaysAllow: false,
|
|
22881
22991
|
requestKind: "session_cleanup_confirm",
|
|
22882
|
-
serverName:
|
|
22883
|
-
message:
|
|
22992
|
+
serverName: pending4.serverName || "superone",
|
|
22993
|
+
message: pending4.message || "Delete these sessions permanently?",
|
|
22884
22994
|
sessionCleanupConfirm: { sessions }
|
|
22885
22995
|
};
|
|
22886
22996
|
}
|
|
22887
|
-
if (
|
|
22888
|
-
if (
|
|
22889
|
-
if (!
|
|
22997
|
+
if (pending4.kind && pending4.kind !== "permission") return null;
|
|
22998
|
+
if (pending4.requestKind === "input_request") {
|
|
22999
|
+
if (!pending4.inputRequest || !pending4.schemaForm) return null;
|
|
22890
23000
|
return {
|
|
22891
|
-
requestId:
|
|
22892
|
-
toolName:
|
|
22893
|
-
toolUseId:
|
|
23001
|
+
requestId: pending4.interactionId,
|
|
23002
|
+
toolName: pending4.toolName || "composer_request",
|
|
23003
|
+
toolUseId: pending4.toolUseId ?? pending4.interactionId,
|
|
22894
23004
|
input: {},
|
|
22895
23005
|
allowAlwaysAllow: false,
|
|
22896
23006
|
requestKind: "input_request",
|
|
22897
|
-
serverName:
|
|
22898
|
-
message:
|
|
22899
|
-
schemaForm:
|
|
22900
|
-
inputRequest:
|
|
23007
|
+
serverName: pending4.serverName || "superone",
|
|
23008
|
+
message: pending4.message || pending4.inputRequest.title,
|
|
23009
|
+
schemaForm: pending4.schemaForm,
|
|
23010
|
+
inputRequest: pending4.inputRequest
|
|
22901
23011
|
};
|
|
22902
23012
|
}
|
|
22903
|
-
const input =
|
|
22904
|
-
const elicitationUrl =
|
|
22905
|
-
const elicitationId =
|
|
22906
|
-
const schemaForm =
|
|
22907
|
-
const requestKind =
|
|
23013
|
+
const input = pending4.input && typeof pending4.input === "object" ? pending4.input : {};
|
|
23014
|
+
const elicitationUrl = pending4.elicitationUrl ?? (typeof input.elicitationUrl === "string" ? input.elicitationUrl : void 0);
|
|
23015
|
+
const elicitationId = pending4.elicitationId ?? (typeof input.elicitationId === "string" ? input.elicitationId : void 0);
|
|
23016
|
+
const schemaForm = pending4.schemaForm ?? (input.schemaForm && typeof input.schemaForm === "object" ? input.schemaForm : void 0);
|
|
23017
|
+
const requestKind = pending4.requestKind === "mcp_elicitation" ? "mcp_elicitation" : void 0;
|
|
22908
23018
|
return {
|
|
22909
|
-
requestId:
|
|
22910
|
-
toolName:
|
|
22911
|
-
toolUseId:
|
|
23019
|
+
requestId: pending4.interactionId,
|
|
23020
|
+
toolName: pending4.toolName || "tool",
|
|
23021
|
+
toolUseId: pending4.toolUseId,
|
|
22912
23022
|
input,
|
|
22913
|
-
allowAlwaysAllow: requestKind === "mcp_elicitation" ? !schemaForm &&
|
|
23023
|
+
allowAlwaysAllow: requestKind === "mcp_elicitation" ? !schemaForm && pending4.allowAlwaysAllow === true : pending4.allowAlwaysAllow !== false,
|
|
22914
23024
|
...requestKind ? { requestKind } : {},
|
|
22915
|
-
...
|
|
22916
|
-
...
|
|
22917
|
-
...
|
|
22918
|
-
...
|
|
23025
|
+
...pending4.message ? { message: pending4.message } : {},
|
|
23026
|
+
...pending4.permissionDetails ? { permissionDetails: pending4.permissionDetails } : {},
|
|
23027
|
+
...pending4.serverName ? { serverName: pending4.serverName } : {},
|
|
23028
|
+
...pending4.serverLabel ? { serverLabel: pending4.serverLabel } : {},
|
|
22919
23029
|
...elicitationUrl ? { elicitationUrl, subtitle: elicitationUrl } : {},
|
|
22920
23030
|
...elicitationId ? { elicitationId } : {},
|
|
22921
|
-
...elicitationUrl &&
|
|
23031
|
+
...elicitationUrl && pending4.elicitationAcceptOnOpen ? { elicitationAcceptOnOpen: true } : {},
|
|
22922
23032
|
...schemaForm ? { schemaForm } : {},
|
|
22923
|
-
...
|
|
22924
|
-
...
|
|
22925
|
-
...
|
|
22926
|
-
...
|
|
23033
|
+
...pending4.elicitationForm ? { elicitationForm: pending4.elicitationForm } : {},
|
|
23034
|
+
...pending4.subtitle ? { subtitle: pending4.subtitle } : {},
|
|
23035
|
+
...pending4.riskLevel ? { riskLevel: pending4.riskLevel } : {},
|
|
23036
|
+
...pending4.supportsAlwaysPersist !== void 0 ? { supportsAlwaysPersist: pending4.supportsAlwaysPersist } : {}
|
|
22927
23037
|
};
|
|
22928
23038
|
}
|
|
22929
|
-
function nodePendingToQuestionRequest(
|
|
22930
|
-
if (!
|
|
22931
|
-
const input =
|
|
23039
|
+
function nodePendingToQuestionRequest(pending4) {
|
|
23040
|
+
if (!pending4?.interactionId || pending4.kind !== "question") return null;
|
|
23041
|
+
const input = pending4.input && typeof pending4.input === "object" ? pending4.input : {};
|
|
22932
23042
|
const raw2 = Array.isArray(input.questions) ? input.questions : [];
|
|
22933
23043
|
const questions = [];
|
|
22934
23044
|
for (const q3 of raw2) {
|
|
@@ -22970,26 +23080,26 @@ function nodePendingToQuestionRequest(pending3) {
|
|
|
22970
23080
|
typeof input.previewFormat === "string" ? input.previewFormat : void 0
|
|
22971
23081
|
);
|
|
22972
23082
|
return {
|
|
22973
|
-
requestId:
|
|
23083
|
+
requestId: pending4.interactionId,
|
|
22974
23084
|
questions,
|
|
22975
23085
|
...previewFormat ? { previewFormat } : {}
|
|
22976
23086
|
};
|
|
22977
23087
|
}
|
|
22978
|
-
function nodePendingToPlanApprovalRequest(
|
|
22979
|
-
if (!
|
|
22980
|
-
const input =
|
|
23088
|
+
function nodePendingToPlanApprovalRequest(pending4) {
|
|
23089
|
+
if (!pending4?.interactionId || pending4.kind !== "plan") return null;
|
|
23090
|
+
const input = pending4.input && typeof pending4.input === "object" ? pending4.input : {};
|
|
22981
23091
|
const plan = typeof input.plan === "string" ? input.plan : typeof input.planContent === "string" ? input.planContent : input.plan && typeof input.plan === "object" ? JSON.stringify(input.plan) : "Plan approval required";
|
|
22982
23092
|
return {
|
|
22983
|
-
requestId:
|
|
23093
|
+
requestId: pending4.interactionId,
|
|
22984
23094
|
planContent: plan,
|
|
22985
23095
|
planFilePath: typeof input.planFilePath === "string" ? input.planFilePath : "",
|
|
22986
23096
|
allowedPrompts: Array.isArray(input.allowedPrompts) ? input.allowedPrompts : []
|
|
22987
23097
|
};
|
|
22988
23098
|
}
|
|
22989
|
-
function nodePendingInteractionFields(
|
|
22990
|
-
const perm = nodePendingToPermissionRequest(
|
|
22991
|
-
const question = nodePendingToQuestionRequest(
|
|
22992
|
-
const plan = nodePendingToPlanApprovalRequest(
|
|
23099
|
+
function nodePendingInteractionFields(pending4, inputRequests = []) {
|
|
23100
|
+
const perm = nodePendingToPermissionRequest(pending4);
|
|
23101
|
+
const question = nodePendingToQuestionRequest(pending4);
|
|
23102
|
+
const plan = nodePendingToPlanApprovalRequest(pending4);
|
|
22993
23103
|
const forms = inputRequests.flatMap((request) => nodePendingToPermissionRequest(request) ?? []);
|
|
22994
23104
|
return {
|
|
22995
23105
|
pendingPermissions: [...perm ? [perm] : [], ...forms],
|
|
@@ -23198,7 +23308,7 @@ var init_read_model = __esm({
|
|
|
23198
23308
|
return session;
|
|
23199
23309
|
}
|
|
23200
23310
|
const events = this.log.listForSession(sessionId, Number.MAX_SAFE_INTEGER);
|
|
23201
|
-
const
|
|
23311
|
+
const pending4 = nodePendingInteractionFields(record13?.pendingInteraction);
|
|
23202
23312
|
const core2 = {
|
|
23203
23313
|
...createDefaultChatCoreSession(),
|
|
23204
23314
|
sessionProvider: providerId,
|
|
@@ -23206,7 +23316,7 @@ var init_read_model = __esm({
|
|
|
23206
23316
|
claudeFastMode: record13?.claudeFastMode ?? void 0,
|
|
23207
23317
|
messages: record13 ? sessionMessageBlocksToChatMessages(buildSessionMessageCatalog(record13, events), providerId) : [],
|
|
23208
23318
|
status: record13?.status === "streaming" ? "streaming" : "idle",
|
|
23209
|
-
...
|
|
23319
|
+
...pending4
|
|
23210
23320
|
};
|
|
23211
23321
|
session = {
|
|
23212
23322
|
mapper,
|
|
@@ -40975,7 +41085,7 @@ var init_scanner_DX8LRFGE = __esm({
|
|
|
40975
41085
|
}
|
|
40976
41086
|
findNextMatchSync(string8, startPosition, _options) {
|
|
40977
41087
|
const str5 = typeof string8 === "string" ? string8 : string8.content;
|
|
40978
|
-
const
|
|
41088
|
+
const pending4 = [];
|
|
40979
41089
|
function toResult(index, match, offset = 0) {
|
|
40980
41090
|
return {
|
|
40981
41091
|
index,
|
|
@@ -41001,7 +41111,7 @@ var init_scanner_DX8LRFGE = __esm({
|
|
|
41001
41111
|
const match = regexp.exec(str5);
|
|
41002
41112
|
if (!match) continue;
|
|
41003
41113
|
if (match.index === startPosition) return toResult(i2, match, 0);
|
|
41004
|
-
|
|
41114
|
+
pending4.push([
|
|
41005
41115
|
i2,
|
|
41006
41116
|
match,
|
|
41007
41117
|
0
|
|
@@ -41011,9 +41121,9 @@ var init_scanner_DX8LRFGE = __esm({
|
|
|
41011
41121
|
throw e;
|
|
41012
41122
|
}
|
|
41013
41123
|
}
|
|
41014
|
-
if (
|
|
41015
|
-
const minIndex = Math.min(...
|
|
41016
|
-
for (const [i2, match, offset] of
|
|
41124
|
+
if (pending4.length) {
|
|
41125
|
+
const minIndex = Math.min(...pending4.map((m5) => m5[1].index));
|
|
41126
|
+
for (const [i2, match, offset] of pending4) if (match.index === minIndex) return toResult(i2, match, offset);
|
|
41017
41127
|
}
|
|
41018
41128
|
return null;
|
|
41019
41129
|
}
|
|
@@ -48035,7 +48145,7 @@ async function openCodexAppServer(opts) {
|
|
|
48035
48145
|
stderrBuf = (stderrBuf + chunk).slice(-MAX_STDERR_CHARS);
|
|
48036
48146
|
});
|
|
48037
48147
|
const rl = createInterface({ input: child.stdout });
|
|
48038
|
-
const
|
|
48148
|
+
const pending4 = /* @__PURE__ */ new Map();
|
|
48039
48149
|
const notificationWaiters = [];
|
|
48040
48150
|
const notificationQueue = [];
|
|
48041
48151
|
let nextId = 1;
|
|
@@ -48059,11 +48169,11 @@ async function openCodexAppServer(opts) {
|
|
|
48059
48169
|
};
|
|
48060
48170
|
const failAll = (err) => {
|
|
48061
48171
|
inboundAbort.abort();
|
|
48062
|
-
for (const [, p4] of
|
|
48172
|
+
for (const [, p4] of pending4) {
|
|
48063
48173
|
p4.cancelDeadline();
|
|
48064
48174
|
p4.reject(err);
|
|
48065
48175
|
}
|
|
48066
|
-
|
|
48176
|
+
pending4.clear();
|
|
48067
48177
|
while (notificationWaiters.length) {
|
|
48068
48178
|
const w5 = notificationWaiters.shift();
|
|
48069
48179
|
clearTimeout(w5.timer);
|
|
@@ -48191,9 +48301,9 @@ async function openCodexAppServer(opts) {
|
|
|
48191
48301
|
}
|
|
48192
48302
|
if (rec.id != null && (typeof rec.id === "number" || typeof rec.id === "string")) {
|
|
48193
48303
|
const id = typeof rec.id === "number" ? rec.id : Number(rec.id);
|
|
48194
|
-
const waiter =
|
|
48304
|
+
const waiter = pending4.get(id);
|
|
48195
48305
|
if (!waiter) continue;
|
|
48196
|
-
|
|
48306
|
+
pending4.delete(id);
|
|
48197
48307
|
waiter.cancelDeadline();
|
|
48198
48308
|
if (rec.error) {
|
|
48199
48309
|
const errObj = rec.error;
|
|
@@ -48211,6 +48321,10 @@ async function openCodexAppServer(opts) {
|
|
|
48211
48321
|
pushNotification({ method: rec.method, params });
|
|
48212
48322
|
}
|
|
48213
48323
|
}
|
|
48324
|
+
if (!closed && !readLoopError) {
|
|
48325
|
+
readLoopError = new Error("Codex app-server connection closed");
|
|
48326
|
+
failAll(readLoopError);
|
|
48327
|
+
}
|
|
48214
48328
|
} catch (err) {
|
|
48215
48329
|
readLoopError = err instanceof Error ? err : new Error(String(err));
|
|
48216
48330
|
failAll(safePublicError("Codex app-server read failed", readLoopError));
|
|
@@ -48232,15 +48346,15 @@ async function openCodexAppServer(opts) {
|
|
|
48232
48346
|
}
|
|
48233
48347
|
const id = nextId++;
|
|
48234
48348
|
const cancelDeadline = inputBudget.deadline(timeoutMs, () => {
|
|
48235
|
-
|
|
48349
|
+
pending4.delete(id);
|
|
48236
48350
|
reject(new Error(`Codex app-server ${method} timed out after ${timeoutMs}ms`));
|
|
48237
48351
|
});
|
|
48238
48352
|
const waiter = { resolve: resolve24, reject, cancelDeadline };
|
|
48239
|
-
|
|
48353
|
+
pending4.set(id, waiter);
|
|
48240
48354
|
try {
|
|
48241
48355
|
writeLine({ jsonrpc: "2.0", id, method, params: params ?? {} });
|
|
48242
48356
|
} catch (err) {
|
|
48243
|
-
|
|
48357
|
+
pending4.delete(id);
|
|
48244
48358
|
waiter.cancelDeadline();
|
|
48245
48359
|
reject(safePublicError("Codex app-server write failed", err));
|
|
48246
48360
|
}
|
|
@@ -48258,7 +48372,7 @@ async function openCodexAppServer(opts) {
|
|
|
48258
48372
|
return;
|
|
48259
48373
|
}
|
|
48260
48374
|
if (closed) {
|
|
48261
|
-
|
|
48375
|
+
reject(new Error("Codex app-server closed"));
|
|
48262
48376
|
return;
|
|
48263
48377
|
}
|
|
48264
48378
|
const timer = setTimeout(() => {
|
|
@@ -48457,9 +48571,6 @@ async function runCodexAppServerTurn(opts) {
|
|
|
48457
48571
|
turnId = readString4(turn?.id);
|
|
48458
48572
|
}
|
|
48459
48573
|
let finalText = "";
|
|
48460
|
-
const deadline = Date.now() + TURN_WAIT_TIMEOUT_MS;
|
|
48461
|
-
const inputWaitAtStart = opts.client.getUserInputWaitMs?.() ?? 0;
|
|
48462
|
-
const remaining = () => deadline - Date.now() + (opts.client.getUserInputWaitMs?.() ?? 0) - inputWaitAtStart;
|
|
48463
48574
|
const agentEventMapper = opts.onAgentEvent ? createCodexAgentEventMapper({
|
|
48464
48575
|
messageId: opts.messageId ?? `codex_${turnId ?? Date.now()}`,
|
|
48465
48576
|
emit: opts.onAgentEvent,
|
|
@@ -48470,10 +48581,10 @@ async function runCodexAppServerTurn(opts) {
|
|
|
48470
48581
|
turnKind
|
|
48471
48582
|
}) : null;
|
|
48472
48583
|
agentEventMapper?.start(threadId);
|
|
48473
|
-
while (!opts.signal.aborted
|
|
48584
|
+
while (!opts.signal.aborted) {
|
|
48474
48585
|
let note;
|
|
48475
48586
|
try {
|
|
48476
|
-
note = await opts.client.nextNotification(
|
|
48587
|
+
note = await opts.client.nextNotification(5e3);
|
|
48477
48588
|
} catch (err) {
|
|
48478
48589
|
const error51 = err instanceof Error ? err : new Error(String(err));
|
|
48479
48590
|
agentEventMapper?.fail(error51.message, /interrupt|abort/i.test(error51.message));
|
|
@@ -48523,12 +48634,8 @@ async function runCodexAppServerTurn(opts) {
|
|
|
48523
48634
|
return { finalText, threadId, turnId };
|
|
48524
48635
|
}
|
|
48525
48636
|
}
|
|
48526
|
-
|
|
48527
|
-
|
|
48528
|
-
throw new Error("Codex turn interrupted");
|
|
48529
|
-
}
|
|
48530
|
-
agentEventMapper?.fail("Codex turn timed out waiting for turn/completed");
|
|
48531
|
-
throw new Error("Codex turn timed out waiting for turn/completed");
|
|
48637
|
+
agentEventMapper?.fail("Codex turn interrupted", true);
|
|
48638
|
+
throw new Error("Codex turn interrupted");
|
|
48532
48639
|
}
|
|
48533
48640
|
function normalizeCollaborationMode(value, model, reasoningEffort) {
|
|
48534
48641
|
if (!value) return void 0;
|
|
@@ -48590,7 +48697,7 @@ function asRecord9(value) {
|
|
|
48590
48697
|
function readString4(value) {
|
|
48591
48698
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
48592
48699
|
}
|
|
48593
|
-
var DEFAULT_REQUEST_TIMEOUT_MS, THREAD_TIMEOUT_MS,
|
|
48700
|
+
var DEFAULT_REQUEST_TIMEOUT_MS, THREAD_TIMEOUT_MS, MAX_STDERR_CHARS;
|
|
48594
48701
|
var init_app_server_client = __esm({
|
|
48595
48702
|
"../../packages/codex/src/app-server-client.ts"() {
|
|
48596
48703
|
"use strict";
|
|
@@ -48608,7 +48715,6 @@ var init_app_server_client = __esm({
|
|
|
48608
48715
|
init_agent_event_mapper();
|
|
48609
48716
|
DEFAULT_REQUEST_TIMEOUT_MS = 12e4;
|
|
48610
48717
|
THREAD_TIMEOUT_MS = 6e4;
|
|
48611
|
-
TURN_WAIT_TIMEOUT_MS = 3e5;
|
|
48612
48718
|
MAX_STDERR_CHARS = 8e3;
|
|
48613
48719
|
}
|
|
48614
48720
|
});
|
|
@@ -49239,8 +49345,8 @@ var init_account_manager = __esm({
|
|
|
49239
49345
|
if (browser) this.browserStarting = true;
|
|
49240
49346
|
try {
|
|
49241
49347
|
this.store.home(id);
|
|
49242
|
-
for (const [loginId,
|
|
49243
|
-
if (
|
|
49348
|
+
for (const [loginId, pending4] of this.pending) {
|
|
49349
|
+
if (pending4.accountId === id) await this.cancel(loginId).catch(() => {
|
|
49244
49350
|
});
|
|
49245
49351
|
}
|
|
49246
49352
|
this.failed.delete(id);
|
|
@@ -49251,9 +49357,9 @@ var init_account_manager = __esm({
|
|
|
49251
49357
|
type,
|
|
49252
49358
|
...browser ? { useHostedLoginSuccessPage: true, appBrand: "chatgpt" } : {}
|
|
49253
49359
|
}));
|
|
49254
|
-
const
|
|
49255
|
-
this.pending.set(result3.loginId,
|
|
49256
|
-
void this.wait(result3.loginId,
|
|
49360
|
+
const pending4 = { accountId: id, connection, browser };
|
|
49361
|
+
this.pending.set(result3.loginId, pending4);
|
|
49362
|
+
void this.wait(result3.loginId, pending4);
|
|
49257
49363
|
return { ...result3, accountId: id };
|
|
49258
49364
|
} catch (error51) {
|
|
49259
49365
|
this.failed.add(id);
|
|
@@ -49265,53 +49371,53 @@ var init_account_manager = __esm({
|
|
|
49265
49371
|
if (browser) this.browserStarting = false;
|
|
49266
49372
|
}
|
|
49267
49373
|
}
|
|
49268
|
-
async wait(loginId,
|
|
49374
|
+
async wait(loginId, pending4) {
|
|
49269
49375
|
const deadline = Date.now() + 15 * 6e4;
|
|
49270
49376
|
const timeout = setTimeout(() => {
|
|
49271
49377
|
void this.cancel(loginId).catch(() => {
|
|
49272
49378
|
});
|
|
49273
|
-
this.failed.add(
|
|
49379
|
+
this.failed.add(pending4.accountId);
|
|
49274
49380
|
}, 15 * 6e4);
|
|
49275
49381
|
timeout.unref?.();
|
|
49276
49382
|
try {
|
|
49277
|
-
while (this.pending.get(loginId) ===
|
|
49278
|
-
const notification = await
|
|
49383
|
+
while (this.pending.get(loginId) === pending4 && Date.now() < deadline) {
|
|
49384
|
+
const notification = await pending4.connection.nextNotification();
|
|
49279
49385
|
if (!notification) throw new Error("Login connection closed");
|
|
49280
49386
|
if (notification?.method !== "account/login/completed" || notification.params.loginId !== loginId) continue;
|
|
49281
49387
|
if (notification.params.success !== true) throw new Error("Sign-in failed");
|
|
49282
|
-
const status2 = parseAccountStatus(await
|
|
49388
|
+
const status2 = parseAccountStatus(await pending4.connection.request("account/read", { refreshToken: false }));
|
|
49283
49389
|
if (!status2.signedIn) throw new Error("Sign-in did not complete");
|
|
49284
|
-
if (this.pending.get(loginId) !==
|
|
49285
|
-
this.store.update(
|
|
49286
|
-
this.store.invalidateCredentials(
|
|
49287
|
-
this.changed(codexAccountProviderId(
|
|
49390
|
+
if (this.pending.get(loginId) !== pending4) return;
|
|
49391
|
+
this.store.update(pending4.accountId, status2);
|
|
49392
|
+
this.store.invalidateCredentials(pending4.accountId);
|
|
49393
|
+
this.changed(codexAccountProviderId(pending4.accountId));
|
|
49288
49394
|
return;
|
|
49289
49395
|
}
|
|
49290
|
-
if (this.pending.get(loginId) ===
|
|
49396
|
+
if (this.pending.get(loginId) === pending4) this.failed.add(pending4.accountId);
|
|
49291
49397
|
} catch {
|
|
49292
|
-
this.failed.add(
|
|
49398
|
+
this.failed.add(pending4.accountId);
|
|
49293
49399
|
} finally {
|
|
49294
49400
|
clearTimeout(timeout);
|
|
49295
|
-
if (this.pending.get(loginId) ===
|
|
49296
|
-
await
|
|
49401
|
+
if (this.pending.get(loginId) === pending4) this.pending.delete(loginId);
|
|
49402
|
+
await pending4.connection.close().catch(() => {
|
|
49297
49403
|
});
|
|
49298
49404
|
}
|
|
49299
49405
|
}
|
|
49300
49406
|
async cancel(loginId) {
|
|
49301
|
-
const
|
|
49302
|
-
if (!
|
|
49407
|
+
const pending4 = this.pending.get(loginId);
|
|
49408
|
+
if (!pending4) return;
|
|
49303
49409
|
this.pending.delete(loginId);
|
|
49304
49410
|
try {
|
|
49305
|
-
await
|
|
49411
|
+
await pending4.connection.request("account/login/cancel", { loginId });
|
|
49306
49412
|
} finally {
|
|
49307
|
-
await
|
|
49413
|
+
await pending4.connection.close();
|
|
49308
49414
|
}
|
|
49309
49415
|
}
|
|
49310
49416
|
async logout(providerId) {
|
|
49311
49417
|
const id = codexAccountId(providerId) ?? codexAccountId(this.store.defaultProviderId()) ?? CODEX_CLI_ACCOUNT_ID;
|
|
49312
49418
|
this.revisions.set(id, (this.revisions.get(id) ?? 0) + 1);
|
|
49313
|
-
for (const [loginId,
|
|
49314
|
-
if (
|
|
49419
|
+
for (const [loginId, pending4] of this.pending) {
|
|
49420
|
+
if (pending4.accountId === id) await this.cancel(loginId);
|
|
49315
49421
|
}
|
|
49316
49422
|
const selected = codexAccountProviderId(id);
|
|
49317
49423
|
const connection = await this.open(selected);
|
|
@@ -49338,8 +49444,8 @@ var init_account_manager = __esm({
|
|
|
49338
49444
|
const unreachable = signedIn() && await this.status(providerId).then(() => false, () => true);
|
|
49339
49445
|
if (!unreachable && signedIn()) throw new Error("Sign out before removing this Codex account.");
|
|
49340
49446
|
this.revisions.set(id, (this.revisions.get(id) ?? 0) + 1);
|
|
49341
|
-
for (const [loginId,
|
|
49342
|
-
if (
|
|
49447
|
+
for (const [loginId, pending4] of this.pending) {
|
|
49448
|
+
if (pending4.accountId === id) await this.cancel(loginId);
|
|
49343
49449
|
}
|
|
49344
49450
|
this.store.remove(id, unreachable);
|
|
49345
49451
|
this.failed.delete(id);
|
|
@@ -51869,7 +51975,7 @@ var init_claude_live_session = __esm({
|
|
|
51869
51975
|
this.failAmbient("Claude SDK stream ended before the background turn completed");
|
|
51870
51976
|
this.active?.reject(new Error("Claude SDK stream ended before the user turn completed"));
|
|
51871
51977
|
this.active = null;
|
|
51872
|
-
for (const
|
|
51978
|
+
for (const pending4 of this.pending.splice(0)) pending4.reject(new Error("Claude SDK stream ended before the queued turn started"));
|
|
51873
51979
|
}
|
|
51874
51980
|
this.closed = true;
|
|
51875
51981
|
this.bridge.close();
|
|
@@ -52322,7 +52428,7 @@ var init_mod_surface = __esm({
|
|
|
52322
52428
|
this.disposed = true;
|
|
52323
52429
|
if (this.available) this.opts.emit({ type: "mod_ui_state", available: false });
|
|
52324
52430
|
this.available = false;
|
|
52325
|
-
for (const
|
|
52431
|
+
for (const pending4 of this.pendingHost.values()) pending4.resolve(null);
|
|
52326
52432
|
this.pendingHost.clear();
|
|
52327
52433
|
}
|
|
52328
52434
|
/**
|
|
@@ -52357,10 +52463,10 @@ var init_mod_surface = __esm({
|
|
|
52357
52463
|
return this.pendingHost.has(requestId);
|
|
52358
52464
|
}
|
|
52359
52465
|
acceptHostReply({ requestId, clientId: clientId2, reply }) {
|
|
52360
|
-
const
|
|
52361
|
-
if (!
|
|
52466
|
+
const pending4 = this.pendingHost.get(requestId);
|
|
52467
|
+
if (!pending4 || pending4.kind !== reply.kind || pending4.clientId !== clientId2) return { accepted: false };
|
|
52362
52468
|
this.pendingHost.delete(requestId);
|
|
52363
|
-
|
|
52469
|
+
pending4.resolve(reply);
|
|
52364
52470
|
return { accepted: true };
|
|
52365
52471
|
}
|
|
52366
52472
|
};
|
|
@@ -102834,7 +102940,7 @@ function make7(connect) {
|
|
|
102834
102940
|
subscribe(options) {
|
|
102835
102941
|
return {
|
|
102836
102942
|
[Symbol.asyncIterator]() {
|
|
102837
|
-
const
|
|
102943
|
+
const pending4 = [];
|
|
102838
102944
|
const queued = [];
|
|
102839
102945
|
let started = false;
|
|
102840
102946
|
let completion;
|
|
@@ -102846,7 +102952,7 @@ function make7(connect) {
|
|
|
102846
102952
|
options?.signal?.removeEventListener("abort", abort);
|
|
102847
102953
|
if (connection?.subscribers.delete(subscriber) && !connection.subscribers.size)
|
|
102848
102954
|
stop3(connection);
|
|
102849
|
-
|
|
102955
|
+
pending4.splice(0).forEach((request) => {
|
|
102850
102956
|
if ("error" in result3)
|
|
102851
102957
|
request.reject(result3.error);
|
|
102852
102958
|
else
|
|
@@ -102864,7 +102970,7 @@ function make7(connect) {
|
|
|
102864
102970
|
push(value) {
|
|
102865
102971
|
if (completion)
|
|
102866
102972
|
return;
|
|
102867
|
-
const request =
|
|
102973
|
+
const request = pending4.shift();
|
|
102868
102974
|
if (request) {
|
|
102869
102975
|
request.resolve({ done: false, value });
|
|
102870
102976
|
return;
|
|
@@ -102906,7 +103012,7 @@ function make7(connect) {
|
|
|
102906
103012
|
return Promise.resolve({ done: true, value: void 0 });
|
|
102907
103013
|
}
|
|
102908
103014
|
const request = Promise.withResolvers();
|
|
102909
|
-
|
|
103015
|
+
pending4.push(request);
|
|
102910
103016
|
if (!started) {
|
|
102911
103017
|
started = true;
|
|
102912
103018
|
options?.signal?.addEventListener("abort", abort, { once: true });
|
|
@@ -106245,15 +106351,15 @@ var init_opencode_oauth = __esm({
|
|
|
106245
106351
|
return task;
|
|
106246
106352
|
}
|
|
106247
106353
|
reply(id, answers) {
|
|
106248
|
-
const
|
|
106249
|
-
if (!
|
|
106250
|
-
|
|
106354
|
+
const pending4 = this.forms.get(id);
|
|
106355
|
+
if (!pending4) return false;
|
|
106356
|
+
pending4.reply(openCodeV2FormAnswer(pending4.form, answers));
|
|
106251
106357
|
return true;
|
|
106252
106358
|
}
|
|
106253
106359
|
reject(id) {
|
|
106254
|
-
const
|
|
106255
|
-
if (!
|
|
106256
|
-
|
|
106360
|
+
const pending4 = this.forms.get(id);
|
|
106361
|
+
if (!pending4) return false;
|
|
106362
|
+
pending4.cancel();
|
|
106257
106363
|
return true;
|
|
106258
106364
|
}
|
|
106259
106365
|
async close() {
|
|
@@ -106403,8 +106509,8 @@ var init_opencode_oauth = __esm({
|
|
|
106403
106509
|
} finally {
|
|
106404
106510
|
clearTimeout(expiry);
|
|
106405
106511
|
if (!complete && !signal2.aborted) controller.abort(new Error("OpenCode sign-in did not complete"));
|
|
106406
|
-
for (const
|
|
106407
|
-
if (
|
|
106512
|
+
for (const pending4 of [...this.forms.values()]) {
|
|
106513
|
+
if (pending4.owner === controller) pending4.reply({});
|
|
106408
106514
|
}
|
|
106409
106515
|
if (!complete) await this.deps.client.cancelOAuth(id, attempt.attemptID).catch(() => void 0);
|
|
106410
106516
|
}
|
|
@@ -108469,13 +108575,13 @@ function createManagedOpenCodeTurnRunner(resolveProjectPath2, options = {}) {
|
|
|
108469
108575
|
if (existing.active || existing.host) throw new Error("Wait for OpenCode to become idle before changing its provider or launch configuration");
|
|
108470
108576
|
await runner.disposeSession(id);
|
|
108471
108577
|
}
|
|
108472
|
-
let
|
|
108473
|
-
if (!
|
|
108578
|
+
let pending4 = sessions.get(id);
|
|
108579
|
+
if (!pending4) {
|
|
108474
108580
|
if (!isOpenCodeBinaryRunnable(opts.binaryPath) && !opts.serverUrl?.trim())
|
|
108475
108581
|
throw new Error(
|
|
108476
108582
|
"OpenCode runtime client not available on node: enable the harness with a real binary or endpoint"
|
|
108477
108583
|
);
|
|
108478
|
-
|
|
108584
|
+
pending4 = startOpenCodeSessionServer({
|
|
108479
108585
|
...opts,
|
|
108480
108586
|
sessionId: id,
|
|
108481
108587
|
nativeSessionId: input.session.providerResume?.startsWith("opencode:") ? input.session.providerResume.slice(9) : void 0,
|
|
@@ -108498,9 +108604,9 @@ function createManagedOpenCodeTurnRunner(resolveProjectPath2, options = {}) {
|
|
|
108498
108604
|
return live2;
|
|
108499
108605
|
}
|
|
108500
108606
|
);
|
|
108501
|
-
sessions.set(id,
|
|
108607
|
+
sessions.set(id, pending4);
|
|
108502
108608
|
}
|
|
108503
|
-
const live = await
|
|
108609
|
+
const live = await pending4.catch((error51) => {
|
|
108504
108610
|
sessions.delete(id);
|
|
108505
108611
|
throw error51;
|
|
108506
108612
|
});
|
|
@@ -108583,7 +108689,7 @@ function createManagedOpenCodeTurnRunner(resolveProjectPath2, options = {}) {
|
|
|
108583
108689
|
const opts = { ...options, ...options.resolveLaunch?.(connection) };
|
|
108584
108690
|
const cwd = session.cwd?.trim() || resolveProjectPath2(session.projectId) || process.cwd();
|
|
108585
108691
|
if (!isOpenCodeBinaryRunnable(opts.binaryPath) && !opts.serverUrl?.trim()) throw new Error("OpenCode runtime is unavailable");
|
|
108586
|
-
const
|
|
108692
|
+
const pending4 = sessions.get(session.sessionId) ?? startOpenCodeSessionServer({
|
|
108587
108693
|
...opts,
|
|
108588
108694
|
sessionId: session.sessionId,
|
|
108589
108695
|
nativeSessionId: session.providerResume.slice(9),
|
|
@@ -108597,8 +108703,8 @@ function createManagedOpenCodeTurnRunner(resolveProjectPath2, options = {}) {
|
|
|
108597
108703
|
}
|
|
108598
108704
|
return open2(connection, opts, server, cwd);
|
|
108599
108705
|
});
|
|
108600
|
-
sessions.set(session.sessionId,
|
|
108601
|
-
const handle2 = await
|
|
108706
|
+
sessions.set(session.sessionId, pending4);
|
|
108707
|
+
const handle2 = await pending4;
|
|
108602
108708
|
if (!("legacy" in handle2)) live = handle2;
|
|
108603
108709
|
}
|
|
108604
108710
|
if (!live) {
|
|
@@ -108797,9 +108903,9 @@ function createManagedOpenCodeTurnRunner(resolveProjectPath2, options = {}) {
|
|
|
108797
108903
|
events?.finish(void 0, true);
|
|
108798
108904
|
};
|
|
108799
108905
|
runner.disposeSession = async (id) => {
|
|
108800
|
-
const
|
|
108906
|
+
const pending4 = sessions.get(id);
|
|
108801
108907
|
sessions.delete(id);
|
|
108802
|
-
const live = await
|
|
108908
|
+
const live = await pending4?.catch(() => null);
|
|
108803
108909
|
if (live && !("legacy" in live)) {
|
|
108804
108910
|
live.abort.abort();
|
|
108805
108911
|
await live.runtime.close();
|
|
@@ -110674,17 +110780,17 @@ var init_cursor_store = __esm({
|
|
|
110674
110780
|
|
|
110675
110781
|
// ../../packages/cursor/src/cursor-sdk.ts
|
|
110676
110782
|
function loadCursorSdk() {
|
|
110677
|
-
|
|
110678
|
-
return
|
|
110783
|
+
pending2 ??= import("@cursor/sdk").then((sdk) => loaded = sdk);
|
|
110784
|
+
return pending2;
|
|
110679
110785
|
}
|
|
110680
110786
|
function isCursorSdkError(error51, name) {
|
|
110681
110787
|
return loaded !== null && error51 instanceof loaded[name];
|
|
110682
110788
|
}
|
|
110683
|
-
var
|
|
110789
|
+
var pending2, loaded;
|
|
110684
110790
|
var init_cursor_sdk = __esm({
|
|
110685
110791
|
"../../packages/cursor/src/cursor-sdk.ts"() {
|
|
110686
110792
|
"use strict";
|
|
110687
|
-
|
|
110793
|
+
pending2 = null;
|
|
110688
110794
|
loaded = null;
|
|
110689
110795
|
}
|
|
110690
110796
|
});
|
|
@@ -111707,9 +111813,6 @@ async function openTurnAndStream(opts) {
|
|
|
111707
111813
|
const turnId = readString6(turn?.id);
|
|
111708
111814
|
opts.onTurnStarted?.(turnId);
|
|
111709
111815
|
let finalText = "";
|
|
111710
|
-
const deadline = Date.now() + TURN_WAIT_TIMEOUT_MS2;
|
|
111711
|
-
const inputWaitAtStart = opts.client.getUserInputWaitMs?.() ?? 0;
|
|
111712
|
-
const remaining = () => deadline - Date.now() + (opts.client.getUserInputWaitMs?.() ?? 0) - inputWaitAtStart;
|
|
111713
111816
|
const agentEventMapper = opts.onAgentEvent ? createCodexAgentEventMapper({
|
|
111714
111817
|
messageId: opts.messageId ?? `codex_${turnId ?? Date.now()}`,
|
|
111715
111818
|
emit: opts.onAgentEvent,
|
|
@@ -111720,12 +111823,10 @@ async function openTurnAndStream(opts) {
|
|
|
111720
111823
|
...opts.parentTurnId || opts.rootTurnId ? { requestedProvenance: { ...opts.parentTurnId ? { parentTurnId: opts.parentTurnId } : {}, ...opts.rootTurnId ? { rootTurnId: opts.rootTurnId } : {} } } : {}
|
|
111721
111824
|
}) : null;
|
|
111722
111825
|
agentEventMapper?.start(opts.threadId);
|
|
111723
|
-
while (!opts.signal.aborted
|
|
111826
|
+
while (!opts.signal.aborted) {
|
|
111724
111827
|
let note;
|
|
111725
111828
|
try {
|
|
111726
|
-
note = await opts.client.nextNotification(
|
|
111727
|
-
Math.min(5e3, Math.max(0, remaining()))
|
|
111728
|
-
);
|
|
111829
|
+
note = await opts.client.nextNotification(5e3);
|
|
111729
111830
|
} catch (err) {
|
|
111730
111831
|
const error51 = err instanceof Error ? err : new Error(String(err));
|
|
111731
111832
|
agentEventMapper?.fail(error51.message, /interrupt|abort/i.test(error51.message));
|
|
@@ -111768,20 +111869,14 @@ async function openTurnAndStream(opts) {
|
|
|
111768
111869
|
return { finalText, threadId: opts.threadId, turnId };
|
|
111769
111870
|
}
|
|
111770
111871
|
}
|
|
111771
|
-
|
|
111772
|
-
|
|
111773
|
-
throw new Error("Codex turn interrupted");
|
|
111774
|
-
}
|
|
111775
|
-
agentEventMapper?.fail("Codex turn timed out waiting for turn/completed");
|
|
111776
|
-
throw new Error("Codex turn timed out waiting for turn/completed");
|
|
111872
|
+
agentEventMapper?.fail("Codex turn interrupted", true);
|
|
111873
|
+
throw new Error("Codex turn interrupted");
|
|
111777
111874
|
}
|
|
111778
|
-
var TURN_WAIT_TIMEOUT_MS2;
|
|
111779
111875
|
var init_codex_live_turn = __esm({
|
|
111780
111876
|
"src/session/codex-live-turn.ts"() {
|
|
111781
111877
|
"use strict";
|
|
111782
111878
|
init_protocol_v162();
|
|
111783
111879
|
init_src4();
|
|
111784
|
-
TURN_WAIT_TIMEOUT_MS2 = 3e5;
|
|
111785
111880
|
}
|
|
111786
111881
|
});
|
|
111787
111882
|
|
|
@@ -127623,6 +127718,7 @@ init_environment();
|
|
|
127623
127718
|
|
|
127624
127719
|
// ../../packages/shared/src/environment/session-operations.ts
|
|
127625
127720
|
var SESSION_OPERATION_METHODS = /* @__PURE__ */ new Set([
|
|
127721
|
+
"session.answerAsyncQuestion",
|
|
127626
127722
|
"session.dequeue",
|
|
127627
127723
|
"session.steer",
|
|
127628
127724
|
"session.reportWorktreeRemoved",
|
|
@@ -127684,6 +127780,13 @@ async function callOperation(payload, ctx, method) {
|
|
|
127684
127780
|
const p4 = asRecord(payload);
|
|
127685
127781
|
try {
|
|
127686
127782
|
const sessionId = requiredText(p4, "sessionId");
|
|
127783
|
+
if (method === "session.answerAsyncQuestion") {
|
|
127784
|
+
requiredText(p4, "messageId");
|
|
127785
|
+
requiredText(p4, "itemId");
|
|
127786
|
+
if (!Array.isArray(p4.answers) || p4.answers.some((answer) => typeof answer !== "string")) {
|
|
127787
|
+
throw Object.assign(new Error("answers must be a string array"), { code: "invalid_argument" });
|
|
127788
|
+
}
|
|
127789
|
+
}
|
|
127687
127790
|
if (method === "session.dequeue" || method === "session.steer") requiredText(p4, "clientMessageId");
|
|
127688
127791
|
if (method === "session.rewind" || method === "session.previewRewind" || method === "session.truncateAtCheckpoint") requiredText(p4, "checkpointId");
|
|
127689
127792
|
if (method === "session.mcpAuthenticate") requiredText(p4, "serverName");
|
|
@@ -128518,14 +128621,14 @@ async function cloneRepository(input, onProgress) {
|
|
|
128518
128621
|
}
|
|
128519
128622
|
});
|
|
128520
128623
|
let stderrTail = "";
|
|
128521
|
-
let
|
|
128624
|
+
let pending4 = "";
|
|
128522
128625
|
let lastPercent = -1;
|
|
128523
128626
|
child.stderr.setEncoding("utf8");
|
|
128524
128627
|
child.stderr.on("data", (chunk) => {
|
|
128525
128628
|
stderrTail = (stderrTail + chunk).slice(-STDERR_TAIL_CHARS);
|
|
128526
128629
|
if (!onProgress) return;
|
|
128527
|
-
const lines2 = (
|
|
128528
|
-
|
|
128630
|
+
const lines2 = (pending4 + chunk).split(/\r|\n/);
|
|
128631
|
+
pending4 = lines2.pop() ?? "";
|
|
128529
128632
|
for (const line of lines2) {
|
|
128530
128633
|
const percent = parseCloneProgress(line);
|
|
128531
128634
|
if (percent !== null && percent > lastPercent) {
|
|
@@ -130044,12 +130147,14 @@ function foldContentDelta(prev, next) {
|
|
|
130044
130147
|
return { ...next, ...replace, delta: merged };
|
|
130045
130148
|
}
|
|
130046
130149
|
if (a2.type === "thinking" && b5.type === "thinking") {
|
|
130150
|
+
const remoteDetail = b5.remoteDetail ?? a2.remoteDetail;
|
|
130047
130151
|
const merged = {
|
|
130048
130152
|
...b5,
|
|
130049
130153
|
type: "thinking",
|
|
130050
130154
|
thinking: (a2.thinking ?? "") + (b5.thinking ?? ""),
|
|
130051
130155
|
startedAt: a2.startedAt ?? b5.startedAt,
|
|
130052
|
-
endedAt: b5.endedAt ?? a2.endedAt
|
|
130156
|
+
endedAt: b5.endedAt ?? a2.endedAt,
|
|
130157
|
+
...remoteDetail !== void 0 ? { remoteDetail } : {}
|
|
130053
130158
|
};
|
|
130054
130159
|
return { ...next, ...replace, delta: merged };
|
|
130055
130160
|
}
|
|
@@ -130571,10 +130676,10 @@ init_environment();
|
|
|
130571
130676
|
// ../../packages/shared/src/environment/draft-content.ts
|
|
130572
130677
|
function hasPersistableDraftContent(draft) {
|
|
130573
130678
|
if (draft.text.trim() || draft.attachments?.length) return true;
|
|
130574
|
-
const
|
|
130679
|
+
const pending4 = [draft.docJson];
|
|
130575
130680
|
const seen = /* @__PURE__ */ new Set();
|
|
130576
|
-
while (
|
|
130577
|
-
const node =
|
|
130681
|
+
while (pending4.length) {
|
|
130682
|
+
const node = pending4.pop();
|
|
130578
130683
|
if (!node || typeof node !== "object") continue;
|
|
130579
130684
|
if (seen.has(node)) continue;
|
|
130580
130685
|
seen.add(node);
|
|
@@ -130582,7 +130687,7 @@ function hasPersistableDraftContent(draft) {
|
|
|
130582
130687
|
if (type === "text" && typeof text4 === "string" && text4.trim()) return true;
|
|
130583
130688
|
const value = type === "pasteChip" ? attrs?.text : type === "mention" ? attrs?.value : null;
|
|
130584
130689
|
if (typeof value === "string" && value.trim()) return true;
|
|
130585
|
-
if (Array.isArray(content))
|
|
130690
|
+
if (Array.isArray(content)) pending4.push(...content);
|
|
130586
130691
|
}
|
|
130587
130692
|
return false;
|
|
130588
130693
|
}
|
|
@@ -130615,15 +130720,15 @@ function openTerminalStream(opts) {
|
|
|
130615
130720
|
}
|
|
130616
130721
|
function openDraftStream(opts) {
|
|
130617
130722
|
let following = false;
|
|
130618
|
-
const
|
|
130723
|
+
const pending4 = /* @__PURE__ */ new Map();
|
|
130619
130724
|
const cancel = (draftId) => {
|
|
130620
|
-
clearTimeout(
|
|
130621
|
-
|
|
130725
|
+
clearTimeout(pending4.get(draftId)?.timer);
|
|
130726
|
+
pending4.delete(draftId);
|
|
130622
130727
|
};
|
|
130623
130728
|
const send = (event) => opts.push(event.draft ? { ...event, draft: withoutDraftAttachmentBytes(event.draft) } : event);
|
|
130624
130729
|
const setTopics = (topics) => {
|
|
130625
130730
|
following = topics.some((topic2) => topic2.kind === "drafts" && topic2.environmentId === opts.environmentId);
|
|
130626
|
-
if (!following) for (const draftId of [...
|
|
130731
|
+
if (!following) for (const draftId of [...pending4.keys()]) cancel(draftId);
|
|
130627
130732
|
};
|
|
130628
130733
|
setTopics(opts.topics);
|
|
130629
130734
|
const off = opts.source.watch((event) => {
|
|
@@ -130633,23 +130738,23 @@ function openDraftStream(opts) {
|
|
|
130633
130738
|
send(event);
|
|
130634
130739
|
return;
|
|
130635
130740
|
}
|
|
130636
|
-
const queued =
|
|
130741
|
+
const queued = pending4.get(event.draftId);
|
|
130637
130742
|
if (queued) {
|
|
130638
130743
|
queued.event = event;
|
|
130639
130744
|
return;
|
|
130640
130745
|
}
|
|
130641
130746
|
const timer = setTimeout(() => {
|
|
130642
|
-
const latest =
|
|
130643
|
-
|
|
130747
|
+
const latest = pending4.get(event.draftId);
|
|
130748
|
+
pending4.delete(event.draftId);
|
|
130644
130749
|
if (latest) send(latest.event);
|
|
130645
130750
|
}, DRAFT_SAVE_INTERVAL_MS);
|
|
130646
|
-
|
|
130751
|
+
pending4.set(event.draftId, { event, timer });
|
|
130647
130752
|
});
|
|
130648
130753
|
return {
|
|
130649
130754
|
setTopics,
|
|
130650
130755
|
close: () => {
|
|
130651
130756
|
off();
|
|
130652
|
-
for (const draftId of [...
|
|
130757
|
+
for (const draftId of [...pending4.keys()]) cancel(draftId);
|
|
130653
130758
|
}
|
|
130654
130759
|
};
|
|
130655
130760
|
}
|
|
@@ -144534,32 +144639,32 @@ function sidebarStatus(status2) {
|
|
|
144534
144639
|
if (status2 === "streaming" || status2 === "background" || status2 === "error") return status2;
|
|
144535
144640
|
return "idle";
|
|
144536
144641
|
}
|
|
144537
|
-
function pendingAgentEvents(
|
|
144538
|
-
if (!
|
|
144539
|
-
if (
|
|
144540
|
-
if (
|
|
144541
|
-
return [permissionEvent(
|
|
144642
|
+
function pendingAgentEvents(pending4) {
|
|
144643
|
+
if (!pending4) return [];
|
|
144644
|
+
if (pending4.kind === "question") return [questionEvent(pending4)];
|
|
144645
|
+
if (pending4.kind === "plan") return [planEvent(pending4)];
|
|
144646
|
+
return [permissionEvent(pending4)];
|
|
144542
144647
|
}
|
|
144543
|
-
function permissionEvent(
|
|
144544
|
-
const confirm =
|
|
144648
|
+
function permissionEvent(pending4) {
|
|
144649
|
+
const confirm = pending4.requestKind === "session_agents_confirm" || pending4.kind === "session_agents_confirm";
|
|
144545
144650
|
return {
|
|
144546
144651
|
type: "permission_request",
|
|
144547
144652
|
request: {
|
|
144548
|
-
requestId:
|
|
144549
|
-
toolName:
|
|
144550
|
-
...
|
|
144551
|
-
input:
|
|
144552
|
-
allowAlwaysAllow:
|
|
144553
|
-
...
|
|
144653
|
+
requestId: pending4.interactionId,
|
|
144654
|
+
toolName: pending4.toolName ?? "",
|
|
144655
|
+
...pending4.toolUseId ? { toolUseId: pending4.toolUseId } : {},
|
|
144656
|
+
input: pending4.input ?? {},
|
|
144657
|
+
allowAlwaysAllow: pending4.allowAlwaysAllow === true,
|
|
144658
|
+
...pending4.message ? { message: pending4.message } : {},
|
|
144554
144659
|
...confirm ? {
|
|
144555
144660
|
requestKind: "session_agents_confirm",
|
|
144556
|
-
...
|
|
144661
|
+
...pending4.sessionAgentsConfirm ? { sessionAgentsConfirm: pending4.sessionAgentsConfirm } : {}
|
|
144557
144662
|
} : {}
|
|
144558
144663
|
}
|
|
144559
144664
|
};
|
|
144560
144665
|
}
|
|
144561
|
-
function questionEvent(
|
|
144562
|
-
const raw2 =
|
|
144666
|
+
function questionEvent(pending4) {
|
|
144667
|
+
const raw2 = pending4.input?.questions;
|
|
144563
144668
|
const questions = Array.isArray(raw2) ? raw2.flatMap((item) => {
|
|
144564
144669
|
if (!item || typeof item !== "object") return [];
|
|
144565
144670
|
const row2 = item;
|
|
@@ -144577,11 +144682,11 @@ function questionEvent(pending3) {
|
|
|
144577
144682
|
multiSelect: row2.multiSelect === true
|
|
144578
144683
|
}];
|
|
144579
144684
|
}) : [];
|
|
144580
|
-
return { type: "ask_user_question", request: { requestId:
|
|
144685
|
+
return { type: "ask_user_question", request: { requestId: pending4.interactionId, questions } };
|
|
144581
144686
|
}
|
|
144582
|
-
function planEvent(
|
|
144583
|
-
const input =
|
|
144584
|
-
const planContent2 = typeof input.plan === "string" ? input.plan : typeof input.planContent === "string" ? input.planContent :
|
|
144687
|
+
function planEvent(pending4) {
|
|
144688
|
+
const input = pending4.input ?? {};
|
|
144689
|
+
const planContent2 = typeof input.plan === "string" ? input.plan : typeof input.planContent === "string" ? input.planContent : pending4.message ?? "";
|
|
144585
144690
|
const planFilePath = typeof input.planFilePath === "string" ? input.planFilePath : "";
|
|
144586
144691
|
const allowedPrompts = Array.isArray(input.allowedPrompts) ? input.allowedPrompts.flatMap((item) => {
|
|
144587
144692
|
if (!item || typeof item !== "object") return [];
|
|
@@ -144589,7 +144694,7 @@ function planEvent(pending3) {
|
|
|
144589
144694
|
if (typeof row2.tool !== "string" || typeof row2.prompt !== "string") return [];
|
|
144590
144695
|
return [{ tool: row2.tool, prompt: row2.prompt }];
|
|
144591
144696
|
}) : [];
|
|
144592
|
-
return { type: "plan_approval", request: { requestId:
|
|
144697
|
+
return { type: "plan_approval", request: { requestId: pending4.interactionId, planContent: planContent2, planFilePath, allowedPrompts } };
|
|
144593
144698
|
}
|
|
144594
144699
|
|
|
144595
144700
|
// src/runtime.ts
|
|
@@ -145967,7 +146072,7 @@ async function dispatchSuggestedTaskRpc(method, payload, ctx) {
|
|
|
145967
146072
|
}
|
|
145968
146073
|
}
|
|
145969
146074
|
|
|
145970
|
-
//
|
|
146075
|
+
// node_modules/@toon-format/toon/dist/index.mjs
|
|
145971
146076
|
var NULL_LITERAL = "null";
|
|
145972
146077
|
var DELIMITERS = {
|
|
145973
146078
|
comma: ",",
|
|
@@ -145993,13 +146098,29 @@ function setOwnProperty(target2, key3, value) {
|
|
|
145993
146098
|
}
|
|
145994
146099
|
target2[key3] = value;
|
|
145995
146100
|
}
|
|
146101
|
+
var COMMENT_LINE_PATTERN = new RegExp(`(?:^\uFEFF?|\\n) *#`);
|
|
146102
|
+
var RawString = class {
|
|
146103
|
+
constructor(value) {
|
|
146104
|
+
if (COMMENT_LINE_PATTERN.test(value)) throw new TypeError(`Raw string must not contain a line starting with "#": ${JSON.stringify(value)}`);
|
|
146105
|
+
this.value = value;
|
|
146106
|
+
}
|
|
146107
|
+
};
|
|
146108
|
+
function isRawString(value) {
|
|
146109
|
+
return value instanceof RawString;
|
|
146110
|
+
}
|
|
146111
|
+
var SURROGATE_PATTERN = /[\uD800-\uDFFF]/;
|
|
145996
146112
|
function normalizeValue(value) {
|
|
145997
146113
|
if (value === null) return null;
|
|
146114
|
+
if (isRawString(value)) return value;
|
|
145998
146115
|
if (typeof value === "object" && value !== null && "toJSON" in value && typeof value.toJSON === "function") {
|
|
145999
146116
|
const next = value.toJSON();
|
|
146000
146117
|
if (next !== value) return normalizeValue(next);
|
|
146001
146118
|
}
|
|
146002
|
-
if (typeof value === "string"
|
|
146119
|
+
if (typeof value === "string") {
|
|
146120
|
+
assertNoLoneSurrogate(value, "string value");
|
|
146121
|
+
return value;
|
|
146122
|
+
}
|
|
146123
|
+
if (typeof value === "boolean") return value;
|
|
146003
146124
|
if (typeof value === "number") {
|
|
146004
146125
|
if (Object.is(value, -0)) return 0;
|
|
146005
146126
|
if (!Number.isFinite(value)) return null;
|
|
@@ -146015,19 +146136,39 @@ function normalizeValue(value) {
|
|
|
146015
146136
|
if (value instanceof Map) return Object.fromEntries(Array.from(value, ([k5, v4]) => [String(k5), normalizeValue(v4)]));
|
|
146016
146137
|
if (isPlainObject2(value)) {
|
|
146017
146138
|
const encodedValues = {};
|
|
146018
|
-
for (const key3 in value) if (Object.hasOwn(value, key3))
|
|
146139
|
+
for (const key3 in value) if (Object.hasOwn(value, key3)) {
|
|
146140
|
+
assertNoLoneSurrogate(key3, "object key");
|
|
146141
|
+
setOwnProperty(encodedValues, key3, normalizeValue(value[key3]));
|
|
146142
|
+
}
|
|
146019
146143
|
return encodedValues;
|
|
146020
146144
|
}
|
|
146021
146145
|
return null;
|
|
146022
146146
|
}
|
|
146147
|
+
function assertNoLoneSurrogate(value, context) {
|
|
146148
|
+
if (!SURROGATE_PATTERN.test(value)) return;
|
|
146149
|
+
for (let index = 0; index < value.length; index++) {
|
|
146150
|
+
const code = value.charCodeAt(index);
|
|
146151
|
+
if (code < 55296 || code > 57343) continue;
|
|
146152
|
+
const isHighSurrogate = code <= 56319;
|
|
146153
|
+
const next = value.charCodeAt(index + 1);
|
|
146154
|
+
if (isHighSurrogate && next >= 56320 && next <= 57343) {
|
|
146155
|
+
index++;
|
|
146156
|
+
continue;
|
|
146157
|
+
}
|
|
146158
|
+
throw new TypeError(`Cannot encode ${context} containing an unpaired surrogate U+${code.toString(16).toUpperCase()} at index ${index}`);
|
|
146159
|
+
}
|
|
146160
|
+
}
|
|
146023
146161
|
function isJsonPrimitive(value) {
|
|
146024
146162
|
return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
146025
146163
|
}
|
|
146164
|
+
function isEncodablePrimitive(value) {
|
|
146165
|
+
return isJsonPrimitive(value) || isRawString(value);
|
|
146166
|
+
}
|
|
146026
146167
|
function isJsonArray(value) {
|
|
146027
146168
|
return Array.isArray(value);
|
|
146028
146169
|
}
|
|
146029
146170
|
function isJsonObject(value) {
|
|
146030
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
146171
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && !isRawString(value);
|
|
146031
146172
|
}
|
|
146032
146173
|
function isEmptyObject(value) {
|
|
146033
146174
|
return Object.keys(value).length === 0;
|
|
@@ -146038,7 +146179,7 @@ function isPlainObject2(value) {
|
|
|
146038
146179
|
return prototype === null || prototype === Object.prototype;
|
|
146039
146180
|
}
|
|
146040
146181
|
function isArrayOfPrimitives(value) {
|
|
146041
|
-
return value.length === 0 || value.every((item) =>
|
|
146182
|
+
return value.length === 0 || value.every((item) => isEncodablePrimitive(item));
|
|
146042
146183
|
}
|
|
146043
146184
|
function isArrayOfArrays(value) {
|
|
146044
146185
|
return value.length === 0 || value.every((item) => isJsonArray(item));
|
|
@@ -146046,17 +146187,16 @@ function isArrayOfArrays(value) {
|
|
|
146046
146187
|
function isArrayOfObjects(value) {
|
|
146047
146188
|
return value.length === 0 || value.every((item) => isJsonObject(item));
|
|
146048
146189
|
}
|
|
146049
|
-
var NUMERIC_LIKE_PATTERN =
|
|
146050
|
-
|
|
146190
|
+
var NUMERIC_LIKE_PATTERN = /^[+-]?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i;
|
|
146191
|
+
function assertValidDelimiter(delimiter3) {
|
|
146192
|
+
if (!Object.values(DELIMITERS).includes(delimiter3)) throw new TypeError(`Invalid delimiter ${JSON.stringify(delimiter3)}. Valid delimiters are: comma (,), tab (\\t), pipe (|)`);
|
|
146193
|
+
}
|
|
146051
146194
|
function isValidUnquotedKey(key3) {
|
|
146052
146195
|
return /^[A-Z_][\w.]*$/i.test(key3);
|
|
146053
146196
|
}
|
|
146054
|
-
function isIdentifierSegment(key3) {
|
|
146055
|
-
return /^[A-Z_]\w*$/i.test(key3);
|
|
146056
|
-
}
|
|
146057
146197
|
function isSafeUnquoted(value, delimiter3 = DEFAULT_DELIMITER) {
|
|
146058
146198
|
if (!value) return false;
|
|
146059
|
-
if (
|
|
146199
|
+
if (/^[ \t]|[ \t]$/.test(value)) return false;
|
|
146060
146200
|
if (isBooleanOrNullLiteral(value) || isNumericLike(value)) return false;
|
|
146061
146201
|
if (value.includes(":")) return false;
|
|
146062
146202
|
if (value.includes('"') || value.includes("\\")) return false;
|
|
@@ -146064,55 +146204,14 @@ function isSafeUnquoted(value, delimiter3 = DEFAULT_DELIMITER) {
|
|
|
146064
146204
|
if (/[\u0000-\u001F]/.test(value)) return false;
|
|
146065
146205
|
if (value.includes(delimiter3)) return false;
|
|
146066
146206
|
if (value.startsWith("-")) return false;
|
|
146207
|
+
if (value.startsWith("#")) return false;
|
|
146067
146208
|
return true;
|
|
146068
146209
|
}
|
|
146069
146210
|
function isNumericLike(value) {
|
|
146070
|
-
return NUMERIC_LIKE_PATTERN.test(value)
|
|
146071
|
-
}
|
|
146072
|
-
function tryFoldKeyChain(key3, value, siblings2, options, rootLiteralKeys, pathPrefix, flattenDepth) {
|
|
146073
|
-
if (options.keyFolding !== "safe") return;
|
|
146074
|
-
if (!isJsonObject(value)) return;
|
|
146075
|
-
const { segments, tail, leafValue } = collectSingleKeyChain(key3, value, flattenDepth ?? options.flattenDepth);
|
|
146076
|
-
if (segments.length < 2) return;
|
|
146077
|
-
if (!segments.every((seg) => isIdentifierSegment(seg))) return;
|
|
146078
|
-
const foldedKey = buildFoldedKey(segments);
|
|
146079
|
-
const absolutePath2 = pathPrefix ? `${pathPrefix}.${foldedKey}` : foldedKey;
|
|
146080
|
-
if (siblings2.includes(foldedKey)) return;
|
|
146081
|
-
if (rootLiteralKeys && rootLiteralKeys.has(absolutePath2)) return;
|
|
146082
|
-
return {
|
|
146083
|
-
foldedKey,
|
|
146084
|
-
remainder: tail,
|
|
146085
|
-
leafValue,
|
|
146086
|
-
segmentCount: segments.length
|
|
146087
|
-
};
|
|
146088
|
-
}
|
|
146089
|
-
function collectSingleKeyChain(startKey, startValue, maxDepth) {
|
|
146090
|
-
const segments = [startKey];
|
|
146091
|
-
let currentValue = startValue;
|
|
146092
|
-
while (segments.length < maxDepth) {
|
|
146093
|
-
if (!isJsonObject(currentValue)) break;
|
|
146094
|
-
const keys = Object.keys(currentValue);
|
|
146095
|
-
if (keys.length !== 1) break;
|
|
146096
|
-
const nextKey = keys[0];
|
|
146097
|
-
const nextValue = currentValue[nextKey];
|
|
146098
|
-
segments.push(nextKey);
|
|
146099
|
-
currentValue = nextValue;
|
|
146100
|
-
}
|
|
146101
|
-
if (!isJsonObject(currentValue) || isEmptyObject(currentValue)) return {
|
|
146102
|
-
segments,
|
|
146103
|
-
tail: void 0,
|
|
146104
|
-
leafValue: currentValue
|
|
146105
|
-
};
|
|
146106
|
-
return {
|
|
146107
|
-
segments,
|
|
146108
|
-
tail: currentValue,
|
|
146109
|
-
leafValue: currentValue
|
|
146110
|
-
};
|
|
146111
|
-
}
|
|
146112
|
-
function buildFoldedKey(segments) {
|
|
146113
|
-
return segments.join(".");
|
|
146211
|
+
return NUMERIC_LIKE_PATTERN.test(value);
|
|
146114
146212
|
}
|
|
146115
146213
|
function encodePrimitive(value, delimiter3) {
|
|
146214
|
+
if (isRawString(value)) return value.value;
|
|
146116
146215
|
if (value === null) return NULL_LITERAL;
|
|
146117
146216
|
if (typeof value === "boolean") return String(value);
|
|
146118
146217
|
if (typeof value === "number") return String(value);
|
|
@@ -146135,73 +146234,114 @@ function formatHeader(length, options) {
|
|
|
146135
146234
|
const delimiter3 = options?.delimiter ?? ",";
|
|
146136
146235
|
let header = "";
|
|
146137
146236
|
if (key3 != null) header += encodeKey(key3);
|
|
146138
|
-
header += `[${length}${delimiter3 !== DEFAULT_DELIMITER ? delimiter3 : ""}]`;
|
|
146139
|
-
if (fields) {
|
|
146140
|
-
const quotedFields = fields.map((f4) => encodeKey(f4));
|
|
146141
|
-
header += `{${quotedFields.join(delimiter3)}}`;
|
|
146142
|
-
}
|
|
146237
|
+
header += `[${length}${options?.keyed ? ":" : ""}${delimiter3 !== DEFAULT_DELIMITER ? delimiter3 : ""}]`;
|
|
146238
|
+
if (fields) header += `{${formatFieldSegment(fields, delimiter3)}}`;
|
|
146143
146239
|
header += ":";
|
|
146144
146240
|
return header;
|
|
146145
146241
|
}
|
|
146242
|
+
function formatFieldSegment(fields, delimiter3) {
|
|
146243
|
+
return fields.map((field) => encodeKey(field.name) + (field.children ? `{${formatFieldSegment(field.children, delimiter3)}}` : "")).join(delimiter3);
|
|
146244
|
+
}
|
|
146245
|
+
function extractTabularFields(rows) {
|
|
146246
|
+
if (rows.length === 0) return;
|
|
146247
|
+
const firstKeys = Object.keys(rows[0]);
|
|
146248
|
+
if (firstKeys.length === 0) return;
|
|
146249
|
+
for (const row2 of rows) {
|
|
146250
|
+
if (Object.keys(row2).length !== firstKeys.length) return;
|
|
146251
|
+
for (const key3 of firstKeys) if (!Object.hasOwn(row2, key3)) return;
|
|
146252
|
+
}
|
|
146253
|
+
const fieldNodes = [];
|
|
146254
|
+
for (const key3 of firstKeys) {
|
|
146255
|
+
const fieldNode = classifyColumn(key3, rows.map((row2) => row2[key3]));
|
|
146256
|
+
if (!fieldNode) return;
|
|
146257
|
+
fieldNodes.push(fieldNode);
|
|
146258
|
+
}
|
|
146259
|
+
return fieldNodes;
|
|
146260
|
+
}
|
|
146261
|
+
function extractKeyedTabularFields(value) {
|
|
146262
|
+
const entryValues = Object.values(value);
|
|
146263
|
+
if (entryValues.length < 2) return;
|
|
146264
|
+
if (!entryValues.every((entryValue) => isJsonObject(entryValue) && !isEmptyObject(entryValue))) return;
|
|
146265
|
+
return extractTabularFields(entryValues);
|
|
146266
|
+
}
|
|
146267
|
+
function collectRowLeaves(row2, fields) {
|
|
146268
|
+
const leaves = [];
|
|
146269
|
+
collectLeafValues(row2, fields, leaves);
|
|
146270
|
+
return leaves;
|
|
146271
|
+
}
|
|
146272
|
+
function classifyColumn(name, values) {
|
|
146273
|
+
if (values.every((value) => isEncodablePrimitive(value))) return { name };
|
|
146274
|
+
if (!values.every((value) => isJsonObject(value) && !isEmptyObject(value))) return;
|
|
146275
|
+
const children = extractTabularFields(values);
|
|
146276
|
+
if (!children) return;
|
|
146277
|
+
return {
|
|
146278
|
+
name,
|
|
146279
|
+
children
|
|
146280
|
+
};
|
|
146281
|
+
}
|
|
146282
|
+
function collectLeafValues(row2, fields, leaves) {
|
|
146283
|
+
for (const field of fields) {
|
|
146284
|
+
const value = row2[field.name];
|
|
146285
|
+
if (field.children) collectLeafValues(value, field.children, leaves);
|
|
146286
|
+
else leaves.push(value);
|
|
146287
|
+
}
|
|
146288
|
+
}
|
|
146146
146289
|
function* encodeJsonValue(value, options, depth) {
|
|
146147
|
-
if (
|
|
146290
|
+
if (isEncodablePrimitive(value)) {
|
|
146148
146291
|
const encodedPrimitive = encodePrimitive(value, options.delimiter);
|
|
146149
146292
|
if (encodedPrimitive !== "") yield encodedPrimitive;
|
|
146150
146293
|
return;
|
|
146151
146294
|
}
|
|
146152
146295
|
if (isJsonArray(value)) yield* encodeArrayLines(void 0, value, depth, options);
|
|
146153
|
-
else if (isJsonObject(value))
|
|
146154
|
-
|
|
146155
|
-
|
|
146156
|
-
|
|
146157
|
-
|
|
146158
|
-
const effectiveFlattenDepth = remainingDepth ?? options.flattenDepth;
|
|
146159
|
-
for (const [key3, val] of Object.entries(value)) yield* encodeKeyValuePairLines(key3, val, depth, options, keys, rootLiteralKeys, pathPrefix, effectiveFlattenDepth);
|
|
146160
|
-
}
|
|
146161
|
-
function* encodeKeyValuePairLines(key3, value, depth, options, siblings2, rootLiteralKeys, pathPrefix, flattenDepth) {
|
|
146162
|
-
const currentPath = pathPrefix ? `${pathPrefix}.${key3}` : key3;
|
|
146163
|
-
const effectiveFlattenDepth = flattenDepth ?? options.flattenDepth;
|
|
146164
|
-
if (options.keyFolding === "safe" && siblings2) {
|
|
146165
|
-
const foldResult = tryFoldKeyChain(key3, value, siblings2, options, rootLiteralKeys, pathPrefix, effectiveFlattenDepth);
|
|
146166
|
-
if (foldResult) {
|
|
146167
|
-
const { foldedKey, remainder, leafValue, segmentCount } = foldResult;
|
|
146168
|
-
const encodedFoldedKey = encodeKey(foldedKey);
|
|
146169
|
-
if (remainder === void 0) {
|
|
146170
|
-
if (isJsonPrimitive(leafValue)) {
|
|
146171
|
-
yield indentedLine(depth, `${encodedFoldedKey}: ${encodePrimitive(leafValue, options.delimiter)}`, options.indent);
|
|
146172
|
-
return;
|
|
146173
|
-
} else if (isJsonArray(leafValue)) {
|
|
146174
|
-
yield* encodeArrayLines(foldedKey, leafValue, depth, options);
|
|
146175
|
-
return;
|
|
146176
|
-
} else if (isJsonObject(leafValue) && isEmptyObject(leafValue)) {
|
|
146177
|
-
yield indentedLine(depth, `${encodedFoldedKey}:`, options.indent);
|
|
146178
|
-
return;
|
|
146179
|
-
}
|
|
146180
|
-
}
|
|
146181
|
-
if (isJsonObject(remainder)) {
|
|
146182
|
-
yield indentedLine(depth, `${encodedFoldedKey}:`, options.indent);
|
|
146183
|
-
const remainingDepth = effectiveFlattenDepth - segmentCount;
|
|
146184
|
-
const foldedPath = pathPrefix ? `${pathPrefix}.${foldedKey}` : foldedKey;
|
|
146185
|
-
yield* encodeObjectLines(remainder, depth + 1, options, rootLiteralKeys, foldedPath, remainingDepth);
|
|
146186
|
-
return;
|
|
146187
|
-
}
|
|
146296
|
+
else if (isJsonObject(value)) {
|
|
146297
|
+
const keyedFields = extractKeyedTabularFields(value);
|
|
146298
|
+
if (keyedFields) {
|
|
146299
|
+
yield* encodeKeyedObjectLines(void 0, value, keyedFields, depth, options);
|
|
146300
|
+
return;
|
|
146188
146301
|
}
|
|
146302
|
+
yield* encodeObjectLines(value, depth, options);
|
|
146189
146303
|
}
|
|
146304
|
+
}
|
|
146305
|
+
function* encodeObjectLines(value, depth, options) {
|
|
146306
|
+
for (const [key3, val] of Object.entries(value)) yield* encodeKeyValuePairLines(key3, val, depth, options);
|
|
146307
|
+
}
|
|
146308
|
+
function* encodeKeyValuePairLines(key3, value, depth, options) {
|
|
146190
146309
|
const encodedKey = encodeKey(key3);
|
|
146191
|
-
if (
|
|
146310
|
+
if (isEncodablePrimitive(value)) yield indentedLine(depth, `${encodedKey}: ${encodePrimitive(value, options.delimiter)}`, options.indentSize);
|
|
146192
146311
|
else if (isJsonArray(value)) yield* encodeArrayLines(key3, value, depth, options);
|
|
146193
146312
|
else if (isJsonObject(value)) {
|
|
146194
|
-
|
|
146195
|
-
if (
|
|
146313
|
+
const keyedFields = extractKeyedTabularFields(value);
|
|
146314
|
+
if (keyedFields) {
|
|
146315
|
+
yield* encodeKeyedObjectLines(key3, value, keyedFields, depth, options);
|
|
146316
|
+
return;
|
|
146317
|
+
}
|
|
146318
|
+
yield indentedLine(depth, `${encodedKey}:`, options.indentSize);
|
|
146319
|
+
if (!isEmptyObject(value)) yield* encodeObjectLines(value, depth + 1, options);
|
|
146320
|
+
}
|
|
146321
|
+
}
|
|
146322
|
+
function* encodeKeyedObjectLines(key3, value, fields, depth, options) {
|
|
146323
|
+
const entries = Object.entries(value);
|
|
146324
|
+
yield indentedLine(depth, formatHeader(entries.length, {
|
|
146325
|
+
key: key3,
|
|
146326
|
+
fields,
|
|
146327
|
+
delimiter: options.delimiter,
|
|
146328
|
+
keyed: true
|
|
146329
|
+
}), options.indentSize);
|
|
146330
|
+
yield* encodeKeyedEntryRowsLines(entries, fields, depth + 1, options);
|
|
146331
|
+
}
|
|
146332
|
+
function* encodeKeyedEntryRowsLines(entries, fields, depth, options) {
|
|
146333
|
+
for (const [entryKey, entryValue] of entries) {
|
|
146334
|
+
const leaves = collectRowLeaves(entryValue, fields);
|
|
146335
|
+
yield indentedLine(depth, `${encodeKey(entryKey)}: ${encodeAndJoinPrimitives(leaves, options.delimiter)}`, options.indentSize);
|
|
146196
146336
|
}
|
|
146197
146337
|
}
|
|
146198
146338
|
function* encodeArrayLines(key3, value, depth, options) {
|
|
146199
146339
|
if (value.length === 0) {
|
|
146200
|
-
yield indentedLine(depth, key3 != null ? `${encodeKey(key3)}: []` : "[]", options.
|
|
146340
|
+
yield indentedLine(depth, key3 != null ? `${encodeKey(key3)}: []` : "[]", options.indentSize);
|
|
146201
146341
|
return;
|
|
146202
146342
|
}
|
|
146203
146343
|
if (isArrayOfPrimitives(value)) {
|
|
146204
|
-
yield indentedLine(depth, encodeInlineArrayLine(value, options.delimiter, key3), options.
|
|
146344
|
+
yield indentedLine(depth, encodeInlineArrayLine(value, options.delimiter, key3), options.indentSize);
|
|
146205
146345
|
return;
|
|
146206
146346
|
}
|
|
146207
146347
|
if (isArrayOfArrays(value)) {
|
|
@@ -146211,8 +146351,8 @@ function* encodeArrayLines(key3, value, depth, options) {
|
|
|
146211
146351
|
}
|
|
146212
146352
|
}
|
|
146213
146353
|
if (isArrayOfObjects(value)) {
|
|
146214
|
-
const
|
|
146215
|
-
if (
|
|
146354
|
+
const fields = extractTabularFields(value);
|
|
146355
|
+
if (fields) yield* encodeArrayOfObjectsAsTabularLines(key3, value, fields, depth, options);
|
|
146216
146356
|
else yield* encodeMixedArrayAsListItemsLines(key3, value, depth, options);
|
|
146217
146357
|
return;
|
|
146218
146358
|
}
|
|
@@ -146222,10 +146362,10 @@ function* encodeArrayOfArraysAsListItemsLines(prefix, values, depth, options) {
|
|
|
146222
146362
|
yield indentedLine(depth, formatHeader(values.length, {
|
|
146223
146363
|
key: prefix,
|
|
146224
146364
|
delimiter: options.delimiter
|
|
146225
|
-
}), options.
|
|
146365
|
+
}), options.indentSize);
|
|
146226
146366
|
for (const arr of values) if (isArrayOfPrimitives(arr)) {
|
|
146227
146367
|
const arrayLine = encodeInlineArrayLine(arr, options.delimiter);
|
|
146228
|
-
yield indentedListItem(depth + 1, arrayLine, options.
|
|
146368
|
+
yield indentedListItem(depth + 1, arrayLine, options.indentSize);
|
|
146229
146369
|
}
|
|
146230
146370
|
}
|
|
146231
146371
|
function encodeInlineArrayLine(values, delimiter3, prefix) {
|
|
@@ -146237,81 +146377,79 @@ function encodeInlineArrayLine(values, delimiter3, prefix) {
|
|
|
146237
146377
|
if (values.length === 0) return header;
|
|
146238
146378
|
return `${header} ${joinedValue}`;
|
|
146239
146379
|
}
|
|
146240
|
-
function* encodeArrayOfObjectsAsTabularLines(prefix, rows,
|
|
146380
|
+
function* encodeArrayOfObjectsAsTabularLines(prefix, rows, fields, depth, options) {
|
|
146241
146381
|
yield indentedLine(depth, formatHeader(rows.length, {
|
|
146242
146382
|
key: prefix,
|
|
146243
|
-
fields
|
|
146383
|
+
fields,
|
|
146244
146384
|
delimiter: options.delimiter
|
|
146245
|
-
}), options.
|
|
146246
|
-
yield* writeTabularRowsLines(rows,
|
|
146385
|
+
}), options.indentSize);
|
|
146386
|
+
yield* writeTabularRowsLines(rows, fields, depth + 1, options);
|
|
146247
146387
|
}
|
|
146248
|
-
function
|
|
146249
|
-
|
|
146250
|
-
const firstRow = rows[0];
|
|
146251
|
-
const firstKeys = Object.keys(firstRow);
|
|
146252
|
-
if (firstKeys.length === 0) return;
|
|
146253
|
-
if (isTabularArray(rows, firstKeys)) return firstKeys;
|
|
146254
|
-
}
|
|
146255
|
-
function isTabularArray(rows, header) {
|
|
146256
|
-
for (const row2 of rows) {
|
|
146257
|
-
if (Object.keys(row2).length !== header.length) return false;
|
|
146258
|
-
for (const key3 of header) {
|
|
146259
|
-
if (!Object.hasOwn(row2, key3)) return false;
|
|
146260
|
-
if (!isJsonPrimitive(row2[key3])) return false;
|
|
146261
|
-
}
|
|
146262
|
-
}
|
|
146263
|
-
return true;
|
|
146264
|
-
}
|
|
146265
|
-
function* writeTabularRowsLines(rows, header, depth, options) {
|
|
146266
|
-
for (const row2 of rows) yield indentedLine(depth, encodeAndJoinPrimitives(header.map((key3) => row2[key3]), options.delimiter), options.indent);
|
|
146388
|
+
function* writeTabularRowsLines(rows, fields, depth, options) {
|
|
146389
|
+
for (const row2 of rows) yield indentedLine(depth, encodeAndJoinPrimitives(collectRowLeaves(row2, fields), options.delimiter), options.indentSize);
|
|
146267
146390
|
}
|
|
146268
146391
|
function* encodeMixedArrayAsListItemsLines(prefix, items, depth, options) {
|
|
146269
146392
|
yield indentedLine(depth, formatHeader(items.length, {
|
|
146270
146393
|
key: prefix,
|
|
146271
146394
|
delimiter: options.delimiter
|
|
146272
|
-
}), options.
|
|
146395
|
+
}), options.indentSize);
|
|
146273
146396
|
for (const item of items) yield* encodeListItemValueLines(item, depth + 1, options);
|
|
146274
146397
|
}
|
|
146275
146398
|
function* encodeObjectAsListItemLines(obj, depth, options) {
|
|
146276
146399
|
if (isEmptyObject(obj)) {
|
|
146277
|
-
yield indentedLine(depth, "-", options.
|
|
146400
|
+
yield indentedLine(depth, "-", options.indentSize);
|
|
146278
146401
|
return;
|
|
146279
146402
|
}
|
|
146280
146403
|
const entries = Object.entries(obj);
|
|
146281
146404
|
const [firstKey, firstValue] = entries[0];
|
|
146282
146405
|
const restEntries = entries.slice(1);
|
|
146283
146406
|
if (isJsonArray(firstValue) && isArrayOfObjects(firstValue)) {
|
|
146284
|
-
const
|
|
146285
|
-
if (
|
|
146407
|
+
const fields = extractTabularFields(firstValue);
|
|
146408
|
+
if (fields) {
|
|
146286
146409
|
yield indentedListItem(depth, formatHeader(firstValue.length, {
|
|
146287
146410
|
key: firstKey,
|
|
146288
|
-
fields
|
|
146411
|
+
fields,
|
|
146289
146412
|
delimiter: options.delimiter
|
|
146290
|
-
}), options.
|
|
146291
|
-
yield* writeTabularRowsLines(firstValue,
|
|
146413
|
+
}), options.indentSize);
|
|
146414
|
+
yield* writeTabularRowsLines(firstValue, fields, depth + 2, options);
|
|
146415
|
+
if (restEntries.length > 0) yield* encodeObjectLines(Object.fromEntries(restEntries), depth + 1, options);
|
|
146416
|
+
return;
|
|
146417
|
+
}
|
|
146418
|
+
}
|
|
146419
|
+
if (isJsonObject(firstValue)) {
|
|
146420
|
+
const keyedFields = extractKeyedTabularFields(firstValue);
|
|
146421
|
+
if (keyedFields) {
|
|
146422
|
+
const keyedEntries = Object.entries(firstValue);
|
|
146423
|
+
yield indentedListItem(depth, formatHeader(keyedEntries.length, {
|
|
146424
|
+
key: firstKey,
|
|
146425
|
+
fields: keyedFields,
|
|
146426
|
+
delimiter: options.delimiter,
|
|
146427
|
+
keyed: true
|
|
146428
|
+
}), options.indentSize);
|
|
146429
|
+
yield* encodeKeyedEntryRowsLines(keyedEntries, keyedFields, depth + 2, options);
|
|
146292
146430
|
if (restEntries.length > 0) yield* encodeObjectLines(Object.fromEntries(restEntries), depth + 1, options);
|
|
146293
146431
|
return;
|
|
146294
146432
|
}
|
|
146295
146433
|
}
|
|
146296
146434
|
const encodedKey = encodeKey(firstKey);
|
|
146297
|
-
if (
|
|
146298
|
-
else if (isJsonArray(firstValue)) if (firstValue.length === 0) yield indentedListItem(depth, `${encodedKey}: []`, options.
|
|
146299
|
-
else if (isArrayOfPrimitives(firstValue)) yield indentedListItem(depth, `${encodedKey}${encodeInlineArrayLine(firstValue, options.delimiter)}`, options.
|
|
146435
|
+
if (isEncodablePrimitive(firstValue)) yield indentedListItem(depth, `${encodedKey}: ${encodePrimitive(firstValue, options.delimiter)}`, options.indentSize);
|
|
146436
|
+
else if (isJsonArray(firstValue)) if (firstValue.length === 0) yield indentedListItem(depth, `${encodedKey}: []`, options.indentSize);
|
|
146437
|
+
else if (isArrayOfPrimitives(firstValue)) yield indentedListItem(depth, `${encodedKey}${encodeInlineArrayLine(firstValue, options.delimiter)}`, options.indentSize);
|
|
146300
146438
|
else {
|
|
146301
|
-
yield indentedListItem(depth, `${encodedKey}${formatHeader(firstValue.length, { delimiter: options.delimiter })}`, options.
|
|
146439
|
+
yield indentedListItem(depth, `${encodedKey}${formatHeader(firstValue.length, { delimiter: options.delimiter })}`, options.indentSize);
|
|
146302
146440
|
for (const item of firstValue) yield* encodeListItemValueLines(item, depth + 2, options);
|
|
146303
146441
|
}
|
|
146304
146442
|
else if (isJsonObject(firstValue)) {
|
|
146305
|
-
yield indentedListItem(depth, `${encodedKey}:`, options.
|
|
146443
|
+
yield indentedListItem(depth, `${encodedKey}:`, options.indentSize);
|
|
146306
146444
|
if (!isEmptyObject(firstValue)) yield* encodeObjectLines(firstValue, depth + 2, options);
|
|
146307
146445
|
}
|
|
146308
146446
|
if (restEntries.length > 0) yield* encodeObjectLines(Object.fromEntries(restEntries), depth + 1, options);
|
|
146309
146447
|
}
|
|
146310
146448
|
function* encodeListItemValueLines(value, depth, options) {
|
|
146311
|
-
if (
|
|
146312
|
-
else if (isJsonArray(value)) if (isArrayOfPrimitives(value)) yield indentedListItem(depth, encodeInlineArrayLine(value, options.delimiter), options.
|
|
146449
|
+
if (isEncodablePrimitive(value)) yield indentedListItem(depth, encodePrimitive(value, options.delimiter), options.indentSize);
|
|
146450
|
+
else if (isJsonArray(value)) if (isArrayOfPrimitives(value)) yield indentedListItem(depth, encodeInlineArrayLine(value, options.delimiter), options.indentSize);
|
|
146313
146451
|
else {
|
|
146314
|
-
yield indentedListItem(depth, formatHeader(value.length, { delimiter: options.delimiter }), options.
|
|
146452
|
+
yield indentedListItem(depth, formatHeader(value.length, { delimiter: options.delimiter }), options.indentSize);
|
|
146315
146453
|
for (const item of value) yield* encodeListItemValueLines(item, depth + 1, options);
|
|
146316
146454
|
}
|
|
146317
146455
|
else if (isJsonObject(value)) yield* encodeObjectAsListItemLines(value, depth, options);
|
|
@@ -146325,7 +146463,11 @@ function indentedListItem(depth, content, indentSize) {
|
|
|
146325
146463
|
function applyReplacer(root2, replacer) {
|
|
146326
146464
|
const replacedRoot = replacer("", root2, []);
|
|
146327
146465
|
if (replacedRoot === void 0) return transformChildren(root2, replacer, []);
|
|
146328
|
-
return
|
|
146466
|
+
return transformReplaced(root2, replacedRoot, replacer, []);
|
|
146467
|
+
}
|
|
146468
|
+
function transformReplaced(original, replaced, replacer, path) {
|
|
146469
|
+
if (isRawString(replaced) && !isEncodablePrimitive(original)) return transformChildren(original, replacer, path);
|
|
146470
|
+
return transformChildren(normalizeValue(replaced), replacer, path);
|
|
146329
146471
|
}
|
|
146330
146472
|
function transformChildren(value, replacer, path) {
|
|
146331
146473
|
if (isJsonObject(value)) return transformObject(value, replacer, path);
|
|
@@ -146338,7 +146480,7 @@ function transformObject(obj, replacer, path) {
|
|
|
146338
146480
|
const childPath = [...path, key3];
|
|
146339
146481
|
const replacedValue = replacer(key3, value, childPath);
|
|
146340
146482
|
if (replacedValue === void 0) continue;
|
|
146341
|
-
setOwnProperty(result3, key3,
|
|
146483
|
+
setOwnProperty(result3, key3, transformReplaced(value, replacedValue, replacer, childPath));
|
|
146342
146484
|
}
|
|
146343
146485
|
return result3;
|
|
146344
146486
|
}
|
|
@@ -146349,8 +146491,7 @@ function transformArray(arr, replacer, path) {
|
|
|
146349
146491
|
const childPath = [...path, i2];
|
|
146350
146492
|
const replacedValue = replacer(String(i2), value, childPath);
|
|
146351
146493
|
if (replacedValue === void 0) continue;
|
|
146352
|
-
|
|
146353
|
-
result3.push(transformChildren(normalizedValue, replacer, childPath));
|
|
146494
|
+
result3.push(transformReplaced(value, replacedValue, replacer, childPath));
|
|
146354
146495
|
}
|
|
146355
146496
|
return result3;
|
|
146356
146497
|
}
|
|
@@ -146363,11 +146504,11 @@ function encodeLines(input, options) {
|
|
|
146363
146504
|
return encodeJsonValue(resolvedOptions.replacer ? applyReplacer(normalizedValue, resolvedOptions.replacer) : normalizedValue, resolvedOptions, 0);
|
|
146364
146505
|
}
|
|
146365
146506
|
function resolveOptions(options) {
|
|
146507
|
+
const delimiter3 = options?.delimiter ?? DEFAULT_DELIMITER;
|
|
146508
|
+
assertValidDelimiter(delimiter3);
|
|
146366
146509
|
return {
|
|
146367
|
-
|
|
146368
|
-
delimiter:
|
|
146369
|
-
keyFolding: options?.keyFolding ?? "off",
|
|
146370
|
-
flattenDepth: options?.flattenDepth ?? Number.POSITIVE_INFINITY,
|
|
146510
|
+
indentSize: options?.indentSize ?? options?.indent ?? 2,
|
|
146511
|
+
delimiter: delimiter3,
|
|
146371
146512
|
replacer: options?.replacer
|
|
146372
146513
|
};
|
|
146373
146514
|
}
|
|
@@ -147478,14 +147619,14 @@ async function startMcpOauth(client3, login) {
|
|
|
147478
147619
|
return { loginId, authorizationUrl: first };
|
|
147479
147620
|
}
|
|
147480
147621
|
async function completeMcpOauth(client3, loginId, callbackUrl) {
|
|
147481
|
-
const
|
|
147482
|
-
if (!
|
|
147622
|
+
const pending4 = pendingMcpOauth.get(loginId);
|
|
147623
|
+
if (!pending4 || pending4.clientSessionId !== client3.clientSessionId) {
|
|
147483
147624
|
throw Object.assign(new Error("MCP sign-in not found"), { code: "not_found" });
|
|
147484
147625
|
}
|
|
147485
147626
|
if (callbackUrl) {
|
|
147486
147627
|
let callback;
|
|
147487
147628
|
try {
|
|
147488
|
-
callback = validateLoopbackOAuthCallback(
|
|
147629
|
+
callback = validateLoopbackOAuthCallback(pending4.authorizationUrl, callbackUrl);
|
|
147489
147630
|
} catch (err) {
|
|
147490
147631
|
invalid10(err.message);
|
|
147491
147632
|
}
|
|
@@ -147493,7 +147634,7 @@ async function completeMcpOauth(client3, loginId, callbackUrl) {
|
|
|
147493
147634
|
await response.body?.cancel();
|
|
147494
147635
|
}
|
|
147495
147636
|
try {
|
|
147496
|
-
return await
|
|
147637
|
+
return await pending4.result;
|
|
147497
147638
|
} finally {
|
|
147498
147639
|
pendingMcpOauth.delete(loginId);
|
|
147499
147640
|
}
|
|
@@ -147990,8 +148131,8 @@ function claudeCatalogFor(ctx, apiProviderId, cwd) {
|
|
|
147990
148131
|
if (ctx.probeModels) return null;
|
|
147991
148132
|
if (ctx.probeClaudeCatalog) {
|
|
147992
148133
|
const probe = ctx.probeClaudeCatalog;
|
|
147993
|
-
let
|
|
147994
|
-
return () =>
|
|
148134
|
+
let pending5 = null;
|
|
148135
|
+
return () => pending5 ??= probe(cwd);
|
|
147995
148136
|
}
|
|
147996
148137
|
const binaryPath = resolveClaudeBinaryPath({ harnesses: ctx.harnesses });
|
|
147997
148138
|
if (!binaryPath) {
|
|
@@ -148000,8 +148141,8 @@ function claudeCatalogFor(ctx, apiProviderId, cwd) {
|
|
|
148000
148141
|
);
|
|
148001
148142
|
return async () => EMPTY_CLAUDE_CATALOG;
|
|
148002
148143
|
}
|
|
148003
|
-
let
|
|
148004
|
-
return () =>
|
|
148144
|
+
let pending4 = null;
|
|
148145
|
+
return () => pending4 ??= getNodeClaudeCatalog({
|
|
148005
148146
|
cwd,
|
|
148006
148147
|
binaryPath,
|
|
148007
148148
|
env: claudeAccountProbeEnv(apiProviderId),
|
|
@@ -152480,7 +152621,7 @@ function suggestedTaskToolResult(raw2) {
|
|
|
152480
152621
|
|
|
152481
152622
|
// src/session/suggested-task.ts
|
|
152482
152623
|
var exec = promisify2(execFile6);
|
|
152483
|
-
function
|
|
152624
|
+
function pending3(ctx, sessionId, taskId) {
|
|
152484
152625
|
const parent = ctx.deps.sessions.get(sessionId);
|
|
152485
152626
|
if (!parent || parent.closed) throw new CollaborationError("This session is no longer available.", "not_found");
|
|
152486
152627
|
const found = findSuggestedTask(ctx.deps.sessions.messages(sessionId), taskId);
|
|
@@ -152495,7 +152636,7 @@ function suggestTask(ctx, sessionId, args) {
|
|
|
152495
152636
|
return suggestedTaskToolResult(args);
|
|
152496
152637
|
}
|
|
152497
152638
|
async function suggestedTaskOptions(ctx, sessionId, taskId) {
|
|
152498
|
-
const { parent } =
|
|
152639
|
+
const { parent } = pending3(ctx, sessionId, taskId);
|
|
152499
152640
|
const profiles = ctx.listProfiles();
|
|
152500
152641
|
if (profiles.some((profile2) => profile2.harnessId === "claude")) {
|
|
152501
152642
|
const { getNodeClaudeModelCatalog: getNodeClaudeModelCatalog2 } = await Promise.resolve().then(() => (init_claude_model_catalog(), claude_model_catalog_exports));
|
|
@@ -152530,7 +152671,7 @@ async function taskLocation(ctx, projectId, cwd, input, taskId, assertControl2)
|
|
|
152530
152671
|
}
|
|
152531
152672
|
async function launchNodeSuggestedTask(ctx, sessionId, taskId, choice, assertControl2, controllerClientSessionId) {
|
|
152532
152673
|
assertControl2();
|
|
152533
|
-
const { parent, input } =
|
|
152674
|
+
const { parent, input } = pending3(ctx, sessionId, taskId);
|
|
152534
152675
|
const launchId = `suggested-task-${taskId}`;
|
|
152535
152676
|
if (!ctx.store.grantForLaunch(sessionId, launchId)?.started_at) {
|
|
152536
152677
|
const { profiles, initial } = await suggestedTaskOptions(ctx, sessionId, taskId);
|
|
@@ -166886,6 +167027,7 @@ function withSessionZone(runner, syncRoot) {
|
|
|
166886
167027
|
wrapped.disposeSession = runner.disposeSession;
|
|
166887
167028
|
wrapped.disposeAll = runner.disposeAll;
|
|
166888
167029
|
wrapped.listActiveRuntimes = runner.listActiveRuntimes;
|
|
167030
|
+
wrapped.codexVoice = runner.codexVoice;
|
|
166889
167031
|
return wrapped;
|
|
166890
167032
|
}
|
|
166891
167033
|
|