@super-one/cli 0.77.0-alpha → 0.77.0-alpha.2
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 +603 -426
- 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".trim()) {
|
|
146
|
-
return "0.77.0-alpha".trim();
|
|
145
|
+
if ("0.77.0-alpha.2".trim()) {
|
|
146
|
+
return "0.77.0-alpha.2".trim();
|
|
147
147
|
}
|
|
148
148
|
const fromDist = readDistManifestVersion();
|
|
149
149
|
if (fromDist) return fromDist;
|
|
@@ -10032,9 +10032,14 @@ function isCursorGlobResult(obj) {
|
|
|
10032
10032
|
function formatCursorGlobResult(obj) {
|
|
10033
10033
|
return obj.files.join("\n");
|
|
10034
10034
|
}
|
|
10035
|
+
function isStandardMcpResult(obj) {
|
|
10036
|
+
return Array.isArray(obj.content) && obj.content.length > 0 && obj.content.some(
|
|
10037
|
+
(c) => c && typeof c === "object" && !Array.isArray(c) && (c.type === "text" || typeof c.text === "string")
|
|
10038
|
+
);
|
|
10039
|
+
}
|
|
10035
10040
|
function isAgentOutputEnvelope(obj) {
|
|
10036
10041
|
const t = obj.type;
|
|
10037
|
-
return t === "MCP" || t === "ListDir" || t === "list_dir" || t === "LS" || t === "Todo" || t === "SearchTool" || t === "GrepSearch" || t === "grep" || obj.TodosUpdated != null || obj.Content != null && typeof obj.Content === "object" || Array.isArray(obj.results) || obj.action != null && typeof obj.action === "object" || isShellCommandResult(obj) || isCursorGrepResult(obj) || isCursorGlobResult(obj);
|
|
10042
|
+
return t === "MCP" || t === "ListDir" || t === "list_dir" || t === "LS" || t === "Todo" || t === "SearchTool" || t === "GrepSearch" || t === "grep" || obj.TodosUpdated != null || obj.Content != null && typeof obj.Content === "object" || Array.isArray(obj.results) || obj.action != null && typeof obj.action === "object" || isShellCommandResult(obj) || isCursorGrepResult(obj) || isCursorGlobResult(obj) || isStandardMcpResult(obj);
|
|
10038
10043
|
}
|
|
10039
10044
|
function formatAgentToolOutput(raw2) {
|
|
10040
10045
|
if (raw2 == null) return "";
|
|
@@ -10062,6 +10067,12 @@ function formatAgentToolOutput(raw2) {
|
|
|
10062
10067
|
if (values.length === 1 && typeof values[0] === "string") return values[0];
|
|
10063
10068
|
}
|
|
10064
10069
|
}
|
|
10070
|
+
if (obj.type !== "ListDir" && obj.type !== "list_dir" && obj.type !== "LS" && isStandardMcpResult(obj)) {
|
|
10071
|
+
const textParts = obj.content.filter((c) => c && typeof c === "object" && !Array.isArray(c) && (c.type === "text" || typeof c.text === "string")).map((c) => typeof c.text === "string" ? c.text : "").filter((t) => t.length > 0);
|
|
10072
|
+
if (textParts.length > 0) {
|
|
10073
|
+
return textParts.join("\n");
|
|
10074
|
+
}
|
|
10075
|
+
}
|
|
10065
10076
|
const listContent = obj.Content ?? obj.content;
|
|
10066
10077
|
if ((obj.type === "ListDir" || obj.type === "list_dir" || obj.type === "LS") && listContent && typeof listContent === "object") {
|
|
10067
10078
|
const body3 = listContent;
|
|
@@ -10742,8 +10753,8 @@ var init_mcp_app_resource = __esm({
|
|
|
10742
10753
|
return cached5 ? Promise.resolve(cached5) : this.refresh(key3, read5);
|
|
10743
10754
|
}
|
|
10744
10755
|
refresh(key3, read5) {
|
|
10745
|
-
const
|
|
10746
|
-
if (
|
|
10756
|
+
const pending4 = this.pending.get(key3);
|
|
10757
|
+
if (pending4) return pending4;
|
|
10747
10758
|
if (this.pending.size >= this.limits.pending) return Promise.reject(new McpAppsError("denied", "Too many pending MCP App resource reads"));
|
|
10748
10759
|
const next = Promise.resolve().then(read5).then((value) => {
|
|
10749
10760
|
this.put(key3, value);
|
|
@@ -11159,6 +11170,10 @@ function isToolResultBlock(block) {
|
|
|
11159
11170
|
function isToolUseBlock(block) {
|
|
11160
11171
|
return "toolName" in block;
|
|
11161
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
|
+
}
|
|
11162
11177
|
function parseInputObject(input) {
|
|
11163
11178
|
if (input == null || input === "") return {};
|
|
11164
11179
|
if (typeof input === "object" && !Array.isArray(input)) {
|
|
@@ -11191,6 +11206,13 @@ function mergeToolUseInputJson(existing, incoming) {
|
|
|
11191
11206
|
merged[key3] = prev[key3];
|
|
11192
11207
|
}
|
|
11193
11208
|
}
|
|
11209
|
+
for (const key3 of ["answers", "annotations", "previewFormat"]) {
|
|
11210
|
+
const n = merged[key3];
|
|
11211
|
+
const empty2 = n == null || n === "" || typeof n === "object" && !Array.isArray(n) && Object.keys(n).length === 0;
|
|
11212
|
+
if (empty2 && prev[key3] != null && prev[key3] !== "") {
|
|
11213
|
+
merged[key3] = prev[key3];
|
|
11214
|
+
}
|
|
11215
|
+
}
|
|
11194
11216
|
if (!asString7) return merged;
|
|
11195
11217
|
try {
|
|
11196
11218
|
return JSON.stringify(merged);
|
|
@@ -11283,12 +11305,14 @@ function applyContentDelta(content, delta, now = Date.now, options = {}) {
|
|
|
11283
11305
|
delta.toolSummary,
|
|
11284
11306
|
mergedInput
|
|
11285
11307
|
);
|
|
11308
|
+
const preservedToolName = existing.toolName === "Write" && delta.toolName === "Edit" && !hasEditReplacementFields(delta.input) ? existing.toolName : delta.toolName;
|
|
11286
11309
|
const liveOutput = delta.outputDelta === void 0 ? existing.liveOutput : options.replace ? delta.outputDelta : (existing.liveOutput ?? "") + delta.outputDelta;
|
|
11287
11310
|
return content.map((b5, i2) => i2 === idx ? {
|
|
11288
11311
|
...existing,
|
|
11289
11312
|
...withoutOutputDelta(delta),
|
|
11290
11313
|
...liveOutput !== void 0 ? { liveOutput } : {},
|
|
11291
11314
|
...existing.app || delta.app ? { app: mergeMcpAppAttachment(existing.app, delta.app) } : {},
|
|
11315
|
+
toolName: preservedToolName,
|
|
11292
11316
|
startedAt: existing.startedAt,
|
|
11293
11317
|
elapsedSeconds: delta.elapsedSeconds ?? existing.elapsedSeconds,
|
|
11294
11318
|
status: delta.status ?? existing.status,
|
|
@@ -11310,6 +11334,24 @@ function applyContentDelta(content, delta, now = Date.now, options = {}) {
|
|
|
11310
11334
|
const { liveOutput: _final, ...call2 } = b5;
|
|
11311
11335
|
return { ...call2, status: "complete" };
|
|
11312
11336
|
});
|
|
11337
|
+
const existingResultIdx = updated.findIndex(
|
|
11338
|
+
(b5) => isToolResultBlock(b5) && b5.toolUseId === delta.toolUseId
|
|
11339
|
+
);
|
|
11340
|
+
if (existingResultIdx !== -1) {
|
|
11341
|
+
const existingResult = updated[existingResultIdx];
|
|
11342
|
+
if (existingResult.type === "tool_result" && result3.type === "tool_result") {
|
|
11343
|
+
const prevSummary = existingResult.summary?.trim() || "";
|
|
11344
|
+
const nextSummary = result3.summary?.trim() || "";
|
|
11345
|
+
const keepPrevSummary = Boolean(prevSummary) && (nextSummary === "" || nextSummary === "done" || prevSummary.includes('"="') && !nextSummary.includes('"="') || prevSummary === "User dismissed the question without answering.");
|
|
11346
|
+
const mergedResult = {
|
|
11347
|
+
...existingResult,
|
|
11348
|
+
...result3,
|
|
11349
|
+
summary: keepPrevSummary ? existingResult.summary : result3.summary
|
|
11350
|
+
};
|
|
11351
|
+
return updated.map((b5, i2) => i2 === existingResultIdx ? mergedResult : b5);
|
|
11352
|
+
}
|
|
11353
|
+
return updated.map((b5, i2) => i2 === existingResultIdx ? result3 : b5);
|
|
11354
|
+
}
|
|
11313
11355
|
return [...updated, result3];
|
|
11314
11356
|
}
|
|
11315
11357
|
return [...content, delta];
|
|
@@ -11416,7 +11458,14 @@ var init_content_delta = __esm({
|
|
|
11416
11458
|
"skill",
|
|
11417
11459
|
"tool_name",
|
|
11418
11460
|
"subject",
|
|
11419
|
-
"task_id"
|
|
11461
|
+
"task_id",
|
|
11462
|
+
"content",
|
|
11463
|
+
"CodeContent",
|
|
11464
|
+
"old_string",
|
|
11465
|
+
"new_string",
|
|
11466
|
+
"TargetContent",
|
|
11467
|
+
"ReplacementContent",
|
|
11468
|
+
"TargetFile"
|
|
11420
11469
|
];
|
|
11421
11470
|
CODEX_DETACHED_ITEM_TYPES = /* @__PURE__ */ new Set(["image_generation", "video_generation"]);
|
|
11422
11471
|
}
|
|
@@ -11786,21 +11835,21 @@ function codexAsyncQuestionItems(message) {
|
|
|
11786
11835
|
function pendingCodexAsyncQuestions(messages) {
|
|
11787
11836
|
const answered = new Set(messages.filter(isCodexAsyncAnswer).map((message) => message.id));
|
|
11788
11837
|
const seen = /* @__PURE__ */ new Set();
|
|
11789
|
-
const
|
|
11838
|
+
const pending4 = [];
|
|
11790
11839
|
for (const message of messages) {
|
|
11791
11840
|
if (message.role !== "assistant") continue;
|
|
11792
11841
|
for (const item of codexAsyncQuestionItems(message)) {
|
|
11793
11842
|
if (seen.has(item.id)) continue;
|
|
11794
11843
|
seen.add(item.id);
|
|
11795
|
-
if (!answered.has(codexAsyncAnswerId(item.id)))
|
|
11844
|
+
if (!answered.has(codexAsyncAnswerId(item.id))) pending4.push({ messageId: message.id, item, request: codexAsyncQuestionRequest(item) });
|
|
11796
11845
|
}
|
|
11797
11846
|
}
|
|
11798
|
-
return
|
|
11847
|
+
return pending4;
|
|
11799
11848
|
}
|
|
11800
11849
|
function codexAsyncQuestionQueue(session) {
|
|
11801
|
-
const
|
|
11850
|
+
const pending4 = session.pendingAsyncQuestions ?? pendingCodexAsyncQuestions(session.messages);
|
|
11802
11851
|
const answered = new Set(session.messages.filter(isCodexAsyncAnswer).map((message) => message.id));
|
|
11803
|
-
return
|
|
11852
|
+
return pending4.some((q3) => answered.has(q3.request.requestId)) ? pending4.filter((q3) => !answered.has(q3.request.requestId)) : pending4;
|
|
11804
11853
|
}
|
|
11805
11854
|
function codexAsyncAnswerQuestions(message, messages) {
|
|
11806
11855
|
if (!isCodexAsyncAnswer(message)) return void 0;
|
|
@@ -11968,10 +12017,10 @@ function coverBeforeCut(content, at2) {
|
|
|
11968
12017
|
const keys = contentKeys(content);
|
|
11969
12018
|
const counts = /* @__PURE__ */ new Map();
|
|
11970
12019
|
const map2 = {};
|
|
11971
|
-
let
|
|
12020
|
+
let pending4 = [];
|
|
11972
12021
|
const flush = () => {
|
|
11973
|
-
for (const item of
|
|
11974
|
-
|
|
12022
|
+
for (const item of pending4) map2[item.key] = item.length;
|
|
12023
|
+
pending4 = [];
|
|
11975
12024
|
};
|
|
11976
12025
|
const placed = () => (counts.get(kind) ?? 0) === target2 && Object.keys(map2).length ? map2 : null;
|
|
11977
12026
|
for (let index = 0; index < content.length; index++) {
|
|
@@ -11987,7 +12036,7 @@ function coverBeforeCut(content, at2) {
|
|
|
11987
12036
|
counts.set(name, (counts.get(name) ?? 0) + value);
|
|
11988
12037
|
}
|
|
11989
12038
|
if (count === 0) {
|
|
11990
|
-
if (key3)
|
|
12039
|
+
if (key3) pending4.push({ key: key3, length: -1 });
|
|
11991
12040
|
continue;
|
|
11992
12041
|
}
|
|
11993
12042
|
if (target2 < start || target2 < start + count) return target2 < start ? placed() : null;
|
|
@@ -12012,7 +12061,7 @@ function coverBeforeCut(content, at2) {
|
|
|
12012
12061
|
}
|
|
12013
12062
|
}
|
|
12014
12063
|
const text4 = blockText(block);
|
|
12015
|
-
if (key3)
|
|
12064
|
+
if (key3) pending4.push({ key: key3, length: text4 === void 0 ? -1 : text4.length });
|
|
12016
12065
|
}
|
|
12017
12066
|
return placed();
|
|
12018
12067
|
}
|
|
@@ -13954,6 +14003,53 @@ var init_input_admission = __esm({
|
|
|
13954
14003
|
}
|
|
13955
14004
|
});
|
|
13956
14005
|
|
|
14006
|
+
// ../../packages/runtime/src/session/codex-async-question.ts
|
|
14007
|
+
async function answerNodeAsyncQuestion(session, messages, command, deliver) {
|
|
14008
|
+
if (session.harnessId !== "codex") throw Object.assign(new Error("Async questions require a Codex session"), { code: "unsupported" });
|
|
14009
|
+
const savedId = typeof command.itemId === "string" ? codexAsyncAnswerId(command.itemId) : null;
|
|
14010
|
+
const saved = codexAsyncReplyText(messages.find((message2) => message2.id === savedId && message2.role === "user"));
|
|
14011
|
+
if (saved !== null) return { reply: saved };
|
|
14012
|
+
const message = messages.find((message2) => message2.id === command.messageId && message2.role === "assistant");
|
|
14013
|
+
const item = message ? codexAsyncQuestionItems(message).find((item2) => item2.id === command.itemId) : void 0;
|
|
14014
|
+
if (!item?.questions?.length) throw Object.assign(new Error("Async question not found"), { code: "not_found" });
|
|
14015
|
+
if (!Array.isArray(command.answers) || command.answers.length !== item.questions.length || command.answers.some((answer2) => typeof answer2 !== "string" || !answer2.trim())) {
|
|
14016
|
+
throw Object.assign(new Error("Every question requires an answer"), { code: "invalid_argument" });
|
|
14017
|
+
}
|
|
14018
|
+
const replyId = codexAsyncAnswerId(item.id);
|
|
14019
|
+
let requests2 = pending.get(session);
|
|
14020
|
+
if (!requests2) {
|
|
14021
|
+
requests2 = /* @__PURE__ */ new Map();
|
|
14022
|
+
pending.set(session, requests2);
|
|
14023
|
+
}
|
|
14024
|
+
const existing = requests2.get(replyId);
|
|
14025
|
+
if (existing) return existing;
|
|
14026
|
+
const reply = formatCodexAsyncQuestionReply(item.questions, command.answers);
|
|
14027
|
+
const answer = anchorAsyncAnswer({
|
|
14028
|
+
id: replyId,
|
|
14029
|
+
role: "user",
|
|
14030
|
+
status: "complete",
|
|
14031
|
+
content: [{ type: "text", text: reply, codexAsyncQuestions: item.questions }],
|
|
14032
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
14033
|
+
providerId: "codex"
|
|
14034
|
+
}, messages);
|
|
14035
|
+
const request = deliver(answer, reply).then(() => ({ reply }));
|
|
14036
|
+
requests2.set(replyId, request);
|
|
14037
|
+
try {
|
|
14038
|
+
return await request;
|
|
14039
|
+
} finally {
|
|
14040
|
+
requests2.delete(replyId);
|
|
14041
|
+
}
|
|
14042
|
+
}
|
|
14043
|
+
var pending;
|
|
14044
|
+
var init_codex_async_question2 = __esm({
|
|
14045
|
+
"../../packages/runtime/src/session/codex-async-question.ts"() {
|
|
14046
|
+
"use strict";
|
|
14047
|
+
init_codex_async_question();
|
|
14048
|
+
init_transcript_boundary();
|
|
14049
|
+
pending = /* @__PURE__ */ new WeakMap();
|
|
14050
|
+
}
|
|
14051
|
+
});
|
|
14052
|
+
|
|
13957
14053
|
// ../../packages/shared/src/codex-accounts.ts
|
|
13958
14054
|
function isCodexAccountProvider(id) {
|
|
13959
14055
|
return !!id?.startsWith(CODEX_ACCOUNT_PREFIX);
|
|
@@ -17574,6 +17670,7 @@ var init_session_runtime = __esm({
|
|
|
17574
17670
|
init_attachment_state();
|
|
17575
17671
|
init_artifact_wakes();
|
|
17576
17672
|
init_input_admission();
|
|
17673
|
+
init_codex_async_question2();
|
|
17577
17674
|
init_codex_accounts();
|
|
17578
17675
|
init_session_send();
|
|
17579
17676
|
init_agent_types();
|
|
@@ -18551,6 +18648,45 @@ var init_session_runtime = __esm({
|
|
|
18551
18648
|
}) {
|
|
18552
18649
|
const session = this.live.get(sessionId);
|
|
18553
18650
|
if (!session || session.closed) throw Object.assign(new Error("session not found"), { code: "not_found" });
|
|
18651
|
+
if (method === "session.answerAsyncQuestion") {
|
|
18652
|
+
assertControl2();
|
|
18653
|
+
if (this.disposing || session.status === "ended") throw Object.assign(new Error("session is closed"), { code: "failed_precondition" });
|
|
18654
|
+
return answerNodeAsyncQuestion(session, this.messages(sessionId), input, async (message, text4) => {
|
|
18655
|
+
const admission = new InputAdmission({
|
|
18656
|
+
beforeInput: assertControl2,
|
|
18657
|
+
onInputAccepted: () => {
|
|
18658
|
+
session.transcript.push({
|
|
18659
|
+
id: message.id,
|
|
18660
|
+
role: "user",
|
|
18661
|
+
text: text4,
|
|
18662
|
+
createdAt: Date.parse(message.createdAt),
|
|
18663
|
+
userMessageContent: message.content,
|
|
18664
|
+
...message.metadata ? { metadata: message.metadata } : {}
|
|
18665
|
+
});
|
|
18666
|
+
session.updatedAt = Date.now();
|
|
18667
|
+
this.persist(session);
|
|
18668
|
+
this.events.appendSession({
|
|
18669
|
+
sessionId,
|
|
18670
|
+
eventType: SESSION_DURABLE_EVENT.userMessage,
|
|
18671
|
+
payload: { blockId: message.id, text: text4, message, echoUserMessage: true }
|
|
18672
|
+
});
|
|
18673
|
+
}
|
|
18674
|
+
});
|
|
18675
|
+
this.beginTurn(session, {
|
|
18676
|
+
text: text4,
|
|
18677
|
+
userBlockId: message.id,
|
|
18678
|
+
inputAdmission: admission,
|
|
18679
|
+
// The Codex runner steers a live turn and starts normally when it has ended.
|
|
18680
|
+
turnKind: "run",
|
|
18681
|
+
model: session.model,
|
|
18682
|
+
effort: session.effort,
|
|
18683
|
+
apiProviderId: session.apiProviderId,
|
|
18684
|
+
permissionMode: session.permissionMode,
|
|
18685
|
+
sandboxMode: session.sandboxMode
|
|
18686
|
+
});
|
|
18687
|
+
await admission.promise;
|
|
18688
|
+
});
|
|
18689
|
+
}
|
|
18554
18690
|
if (method === "session.steer" || method === "session.dequeue") return operateNodeQueue(method, input, {
|
|
18555
18691
|
session,
|
|
18556
18692
|
queue: this.turnQueues.get(sessionId) ?? [],
|
|
@@ -18579,7 +18715,7 @@ var init_session_runtime = __esm({
|
|
|
18579
18715
|
});
|
|
18580
18716
|
}
|
|
18581
18717
|
get servedOperations() {
|
|
18582
|
-
return
|
|
18718
|
+
return /* @__PURE__ */ new Set(["session.answerAsyncQuestion", ...this.turnRunner.servedOperations ?? []]);
|
|
18583
18719
|
}
|
|
18584
18720
|
/** Live Codex app-server for a voice call on this node. */
|
|
18585
18721
|
codexVoice() {
|
|
@@ -19163,11 +19299,11 @@ var init_session_runtime = __esm({
|
|
|
19163
19299
|
generation: input.generation,
|
|
19164
19300
|
holderClientId: input.client.clientSessionId
|
|
19165
19301
|
});
|
|
19166
|
-
const
|
|
19167
|
-
if (!
|
|
19302
|
+
const pending4 = session.pendingInteraction;
|
|
19303
|
+
if (!pending4 || pending4.interactionId !== input.interactionId) {
|
|
19168
19304
|
throw Object.assign(new Error("no matching pending permission"), { code: "failed_precondition" });
|
|
19169
19305
|
}
|
|
19170
|
-
if (
|
|
19306
|
+
if (pending4.kind === "session_agents_confirm" || pending4.kind === "session_cleanup_confirm") {
|
|
19171
19307
|
const waiter2 = this.agentsConfirmWaiters.get(input.interactionId);
|
|
19172
19308
|
if (!waiter2 || waiter2.sessionId !== input.sessionId) {
|
|
19173
19309
|
throw Object.assign(new Error("no matching pending agents confirm"), {
|
|
@@ -19185,7 +19321,7 @@ var init_session_runtime = __esm({
|
|
|
19185
19321
|
});
|
|
19186
19322
|
return;
|
|
19187
19323
|
}
|
|
19188
|
-
if (
|
|
19324
|
+
if (pending4.kind && pending4.kind !== "permission") {
|
|
19189
19325
|
throw Object.assign(new Error("no matching pending permission"), { code: "failed_precondition" });
|
|
19190
19326
|
}
|
|
19191
19327
|
const waiter = this.permissionWaiters.get(input.interactionId);
|
|
@@ -19193,14 +19329,14 @@ var init_session_runtime = __esm({
|
|
|
19193
19329
|
throw Object.assign(new Error("no matching pending permission"), { code: "failed_precondition" });
|
|
19194
19330
|
}
|
|
19195
19331
|
const decision = input.decision === "deny" || input.cancel ? "deny" : "allow";
|
|
19196
|
-
if (input.decision === "allow_always" &&
|
|
19332
|
+
if (input.decision === "allow_always" && pending4.permissionDetails && pending4.allowAlwaysAllow === false && !input.cancel) {
|
|
19197
19333
|
throw Object.assign(new Error("This native permission request supports allow once or deny"), { code: "failed_precondition" });
|
|
19198
19334
|
}
|
|
19199
|
-
if (
|
|
19200
|
-
const accepted = acceptedElicitationContent(
|
|
19335
|
+
if (pending4.requestKind === "mcp_elicitation" && decision === "allow") {
|
|
19336
|
+
const accepted = acceptedElicitationContent(pending4.schemaForm, input.formAnswers);
|
|
19201
19337
|
if (!accepted.ok) throw Object.assign(new Error(accepted.reason), { code: "failed_precondition" });
|
|
19202
19338
|
}
|
|
19203
|
-
if (input.decision === "allow_always" &&
|
|
19339
|
+
if (input.decision === "allow_always" && pending4.requestKind !== "mcp_elicitation" && !input.cancel) {
|
|
19204
19340
|
const tool2 = session.pendingInteraction?.toolName?.trim();
|
|
19205
19341
|
if (tool2) {
|
|
19206
19342
|
const list = session.alwaysAllowedTools ?? [];
|
|
@@ -19523,27 +19659,27 @@ var init_session_runtime = __esm({
|
|
|
19523
19659
|
}
|
|
19524
19660
|
/** Deny and clear any active permission waiter for this session. */
|
|
19525
19661
|
rejectPendingPermission(session) {
|
|
19526
|
-
const
|
|
19527
|
-
if (!
|
|
19528
|
-
if (
|
|
19529
|
-
const qw = this.questionWaiters.get(
|
|
19662
|
+
const pending4 = session.pendingInteraction;
|
|
19663
|
+
if (!pending4) return;
|
|
19664
|
+
if (pending4.kind === "question") {
|
|
19665
|
+
const qw = this.questionWaiters.get(pending4.interactionId);
|
|
19530
19666
|
if (qw) qw.settle({ answers: {}, reason: "aborted" });
|
|
19531
19667
|
else session.pendingInteraction = null;
|
|
19532
19668
|
return;
|
|
19533
19669
|
}
|
|
19534
|
-
if (
|
|
19535
|
-
const pw = this.planWaiters.get(
|
|
19670
|
+
if (pending4.kind === "plan") {
|
|
19671
|
+
const pw = this.planWaiters.get(pending4.interactionId);
|
|
19536
19672
|
if (pw) pw.settle({ decision: "reject", reason: "aborted" });
|
|
19537
19673
|
else session.pendingInteraction = null;
|
|
19538
19674
|
return;
|
|
19539
19675
|
}
|
|
19540
|
-
if (
|
|
19541
|
-
const aw = this.agentsConfirmWaiters.get(
|
|
19676
|
+
if (pending4.kind === "session_agents_confirm" || pending4.kind === "session_cleanup_confirm") {
|
|
19677
|
+
const aw = this.agentsConfirmWaiters.get(pending4.interactionId);
|
|
19542
19678
|
if (aw) aw.settle({ action: "cancel", reason: "aborted" });
|
|
19543
19679
|
else session.pendingInteraction = null;
|
|
19544
19680
|
return;
|
|
19545
19681
|
}
|
|
19546
|
-
const waiter = this.permissionWaiters.get(
|
|
19682
|
+
const waiter = this.permissionWaiters.get(pending4.interactionId);
|
|
19547
19683
|
if (waiter) {
|
|
19548
19684
|
waiter.settle({ decision: "deny", reason: "aborted" });
|
|
19549
19685
|
} else {
|
|
@@ -19554,23 +19690,23 @@ var init_session_runtime = __esm({
|
|
|
19554
19690
|
if (session.pendingInteraction) {
|
|
19555
19691
|
this.rejectPendingPermission(session);
|
|
19556
19692
|
}
|
|
19557
|
-
const
|
|
19693
|
+
const pending4 = { ...interaction, kind: "question" };
|
|
19558
19694
|
return new Promise((resolve24) => {
|
|
19559
19695
|
let settled = false;
|
|
19560
|
-
session.pendingInteraction =
|
|
19696
|
+
session.pendingInteraction = pending4;
|
|
19561
19697
|
session.updatedAt = Date.now();
|
|
19562
19698
|
this.persist(session);
|
|
19563
19699
|
this.events.appendSession({
|
|
19564
19700
|
sessionId: session.sessionId,
|
|
19565
19701
|
eventType: SESSION_DURABLE_EVENT.questionRequested,
|
|
19566
|
-
payload:
|
|
19702
|
+
payload: pending4,
|
|
19567
19703
|
causationRequestId: requestId
|
|
19568
19704
|
});
|
|
19569
19705
|
const settle2 = (result3) => {
|
|
19570
19706
|
if (settled) return;
|
|
19571
19707
|
settled = true;
|
|
19572
|
-
this.questionWaiters.delete(
|
|
19573
|
-
if (session.pendingInteraction?.interactionId ===
|
|
19708
|
+
this.questionWaiters.delete(pending4.interactionId);
|
|
19709
|
+
if (session.pendingInteraction?.interactionId === pending4.interactionId) {
|
|
19574
19710
|
session.pendingInteraction = null;
|
|
19575
19711
|
session.updatedAt = Date.now();
|
|
19576
19712
|
this.persist(session);
|
|
@@ -19579,18 +19715,18 @@ var init_session_runtime = __esm({
|
|
|
19579
19715
|
this.events.appendSession({
|
|
19580
19716
|
sessionId: session.sessionId,
|
|
19581
19717
|
eventType: SESSION_DURABLE_EVENT.questionResponded,
|
|
19582
|
-
payload: { interactionId:
|
|
19718
|
+
payload: { interactionId: pending4.interactionId, answers: result3.answers }
|
|
19583
19719
|
});
|
|
19584
19720
|
} else {
|
|
19585
19721
|
this.events.appendSession({
|
|
19586
19722
|
sessionId: session.sessionId,
|
|
19587
19723
|
eventType: SESSION_DURABLE_EVENT.questionAborted,
|
|
19588
|
-
payload: { interactionId:
|
|
19724
|
+
payload: { interactionId: pending4.interactionId }
|
|
19589
19725
|
});
|
|
19590
19726
|
}
|
|
19591
19727
|
resolve24(result3.answers);
|
|
19592
19728
|
};
|
|
19593
|
-
this.questionWaiters.set(
|
|
19729
|
+
this.questionWaiters.set(pending4.interactionId, {
|
|
19594
19730
|
sessionId: session.sessionId,
|
|
19595
19731
|
settle: settle2
|
|
19596
19732
|
});
|
|
@@ -19611,23 +19747,23 @@ var init_session_runtime = __esm({
|
|
|
19611
19747
|
if (session.pendingInteraction) {
|
|
19612
19748
|
this.rejectPendingPermission(session);
|
|
19613
19749
|
}
|
|
19614
|
-
const
|
|
19750
|
+
const pending4 = { ...interaction, kind: "plan" };
|
|
19615
19751
|
return new Promise((resolve24) => {
|
|
19616
19752
|
let settled = false;
|
|
19617
|
-
session.pendingInteraction =
|
|
19753
|
+
session.pendingInteraction = pending4;
|
|
19618
19754
|
session.updatedAt = Date.now();
|
|
19619
19755
|
this.persist(session);
|
|
19620
19756
|
this.events.appendSession({
|
|
19621
19757
|
sessionId: session.sessionId,
|
|
19622
19758
|
eventType: SESSION_DURABLE_EVENT.planRequested,
|
|
19623
|
-
payload:
|
|
19759
|
+
payload: pending4,
|
|
19624
19760
|
causationRequestId: requestId
|
|
19625
19761
|
});
|
|
19626
19762
|
const settle2 = (result3) => {
|
|
19627
19763
|
if (settled) return;
|
|
19628
19764
|
settled = true;
|
|
19629
|
-
this.planWaiters.delete(
|
|
19630
|
-
if (session.pendingInteraction?.interactionId ===
|
|
19765
|
+
this.planWaiters.delete(pending4.interactionId);
|
|
19766
|
+
if (session.pendingInteraction?.interactionId === pending4.interactionId) {
|
|
19631
19767
|
session.pendingInteraction = null;
|
|
19632
19768
|
session.updatedAt = Date.now();
|
|
19633
19769
|
this.persist(session);
|
|
@@ -19637,7 +19773,7 @@ var init_session_runtime = __esm({
|
|
|
19637
19773
|
sessionId: session.sessionId,
|
|
19638
19774
|
eventType: SESSION_DURABLE_EVENT.planResponded,
|
|
19639
19775
|
payload: {
|
|
19640
|
-
interactionId:
|
|
19776
|
+
interactionId: pending4.interactionId,
|
|
19641
19777
|
decision: result3.decision,
|
|
19642
19778
|
options: result3.options
|
|
19643
19779
|
}
|
|
@@ -19646,12 +19782,12 @@ var init_session_runtime = __esm({
|
|
|
19646
19782
|
this.events.appendSession({
|
|
19647
19783
|
sessionId: session.sessionId,
|
|
19648
19784
|
eventType: SESSION_DURABLE_EVENT.planAborted,
|
|
19649
|
-
payload: { interactionId:
|
|
19785
|
+
payload: { interactionId: pending4.interactionId, decision: "reject" }
|
|
19650
19786
|
});
|
|
19651
19787
|
}
|
|
19652
19788
|
resolve24({ decision: result3.decision, options: result3.options });
|
|
19653
19789
|
};
|
|
19654
|
-
this.planWaiters.set(
|
|
19790
|
+
this.planWaiters.set(pending4.interactionId, {
|
|
19655
19791
|
sessionId: session.sessionId,
|
|
19656
19792
|
settle: settle2
|
|
19657
19793
|
});
|
|
@@ -22814,85 +22950,85 @@ var init_ask_user_question = __esm({
|
|
|
22814
22950
|
});
|
|
22815
22951
|
|
|
22816
22952
|
// ../../packages/shared/src/node-session-messages.ts
|
|
22817
|
-
function nodePendingToPermissionRequest(
|
|
22818
|
-
if (!
|
|
22819
|
-
if (
|
|
22820
|
-
const confirm =
|
|
22953
|
+
function nodePendingToPermissionRequest(pending4) {
|
|
22954
|
+
if (!pending4?.interactionId) return null;
|
|
22955
|
+
if (pending4.kind === "session_agents_confirm") {
|
|
22956
|
+
const confirm = pending4.sessionAgentsConfirm;
|
|
22821
22957
|
const payload = {
|
|
22822
22958
|
launches: Array.isArray(confirm?.launches) ? confirm.launches : [],
|
|
22823
22959
|
profiles: Array.isArray(confirm?.profiles) ? confirm.profiles : []
|
|
22824
22960
|
};
|
|
22825
22961
|
return {
|
|
22826
|
-
requestId:
|
|
22827
|
-
toolName:
|
|
22828
|
-
toolUseId:
|
|
22829
|
-
input:
|
|
22962
|
+
requestId: pending4.interactionId,
|
|
22963
|
+
toolName: pending4.toolName || "session_collab_request",
|
|
22964
|
+
toolUseId: pending4.toolUseId ?? pending4.interactionId,
|
|
22965
|
+
input: pending4.input && typeof pending4.input === "object" ? pending4.input : {},
|
|
22830
22966
|
allowAlwaysAllow: false,
|
|
22831
22967
|
requestKind: "session_agents_confirm",
|
|
22832
|
-
serverName:
|
|
22833
|
-
message:
|
|
22968
|
+
serverName: pending4.serverName || "superone",
|
|
22969
|
+
message: pending4.message || "Allow this agent to start the following sessions?",
|
|
22834
22970
|
sessionAgentsConfirm: payload
|
|
22835
22971
|
};
|
|
22836
22972
|
}
|
|
22837
|
-
if (
|
|
22838
|
-
const sessions = Array.isArray(
|
|
22973
|
+
if (pending4.kind === "session_cleanup_confirm") {
|
|
22974
|
+
const sessions = Array.isArray(pending4.sessionCleanupConfirm?.sessions) ? pending4.sessionCleanupConfirm.sessions : [];
|
|
22839
22975
|
return {
|
|
22840
|
-
requestId:
|
|
22841
|
-
toolName:
|
|
22842
|
-
toolUseId:
|
|
22843
|
-
input:
|
|
22976
|
+
requestId: pending4.interactionId,
|
|
22977
|
+
toolName: pending4.toolName || "mcp__superone__session_cleanup",
|
|
22978
|
+
toolUseId: pending4.toolUseId ?? pending4.interactionId,
|
|
22979
|
+
input: pending4.input && typeof pending4.input === "object" ? pending4.input : {},
|
|
22844
22980
|
allowAlwaysAllow: false,
|
|
22845
22981
|
requestKind: "session_cleanup_confirm",
|
|
22846
|
-
serverName:
|
|
22847
|
-
message:
|
|
22982
|
+
serverName: pending4.serverName || "superone",
|
|
22983
|
+
message: pending4.message || "Delete these sessions permanently?",
|
|
22848
22984
|
sessionCleanupConfirm: { sessions }
|
|
22849
22985
|
};
|
|
22850
22986
|
}
|
|
22851
|
-
if (
|
|
22852
|
-
if (
|
|
22853
|
-
if (!
|
|
22987
|
+
if (pending4.kind && pending4.kind !== "permission") return null;
|
|
22988
|
+
if (pending4.requestKind === "input_request") {
|
|
22989
|
+
if (!pending4.inputRequest || !pending4.schemaForm) return null;
|
|
22854
22990
|
return {
|
|
22855
|
-
requestId:
|
|
22856
|
-
toolName:
|
|
22857
|
-
toolUseId:
|
|
22991
|
+
requestId: pending4.interactionId,
|
|
22992
|
+
toolName: pending4.toolName || "composer_request",
|
|
22993
|
+
toolUseId: pending4.toolUseId ?? pending4.interactionId,
|
|
22858
22994
|
input: {},
|
|
22859
22995
|
allowAlwaysAllow: false,
|
|
22860
22996
|
requestKind: "input_request",
|
|
22861
|
-
serverName:
|
|
22862
|
-
message:
|
|
22863
|
-
schemaForm:
|
|
22864
|
-
inputRequest:
|
|
22997
|
+
serverName: pending4.serverName || "superone",
|
|
22998
|
+
message: pending4.message || pending4.inputRequest.title,
|
|
22999
|
+
schemaForm: pending4.schemaForm,
|
|
23000
|
+
inputRequest: pending4.inputRequest
|
|
22865
23001
|
};
|
|
22866
23002
|
}
|
|
22867
|
-
const input =
|
|
22868
|
-
const elicitationUrl =
|
|
22869
|
-
const elicitationId =
|
|
22870
|
-
const schemaForm =
|
|
22871
|
-
const requestKind =
|
|
23003
|
+
const input = pending4.input && typeof pending4.input === "object" ? pending4.input : {};
|
|
23004
|
+
const elicitationUrl = pending4.elicitationUrl ?? (typeof input.elicitationUrl === "string" ? input.elicitationUrl : void 0);
|
|
23005
|
+
const elicitationId = pending4.elicitationId ?? (typeof input.elicitationId === "string" ? input.elicitationId : void 0);
|
|
23006
|
+
const schemaForm = pending4.schemaForm ?? (input.schemaForm && typeof input.schemaForm === "object" ? input.schemaForm : void 0);
|
|
23007
|
+
const requestKind = pending4.requestKind === "mcp_elicitation" ? "mcp_elicitation" : void 0;
|
|
22872
23008
|
return {
|
|
22873
|
-
requestId:
|
|
22874
|
-
toolName:
|
|
22875
|
-
toolUseId:
|
|
23009
|
+
requestId: pending4.interactionId,
|
|
23010
|
+
toolName: pending4.toolName || "tool",
|
|
23011
|
+
toolUseId: pending4.toolUseId,
|
|
22876
23012
|
input,
|
|
22877
|
-
allowAlwaysAllow: requestKind === "mcp_elicitation" ? !schemaForm &&
|
|
23013
|
+
allowAlwaysAllow: requestKind === "mcp_elicitation" ? !schemaForm && pending4.allowAlwaysAllow === true : pending4.allowAlwaysAllow !== false,
|
|
22878
23014
|
...requestKind ? { requestKind } : {},
|
|
22879
|
-
...
|
|
22880
|
-
...
|
|
22881
|
-
...
|
|
22882
|
-
...
|
|
23015
|
+
...pending4.message ? { message: pending4.message } : {},
|
|
23016
|
+
...pending4.permissionDetails ? { permissionDetails: pending4.permissionDetails } : {},
|
|
23017
|
+
...pending4.serverName ? { serverName: pending4.serverName } : {},
|
|
23018
|
+
...pending4.serverLabel ? { serverLabel: pending4.serverLabel } : {},
|
|
22883
23019
|
...elicitationUrl ? { elicitationUrl, subtitle: elicitationUrl } : {},
|
|
22884
23020
|
...elicitationId ? { elicitationId } : {},
|
|
22885
|
-
...elicitationUrl &&
|
|
23021
|
+
...elicitationUrl && pending4.elicitationAcceptOnOpen ? { elicitationAcceptOnOpen: true } : {},
|
|
22886
23022
|
...schemaForm ? { schemaForm } : {},
|
|
22887
|
-
...
|
|
22888
|
-
...
|
|
22889
|
-
...
|
|
22890
|
-
...
|
|
23023
|
+
...pending4.elicitationForm ? { elicitationForm: pending4.elicitationForm } : {},
|
|
23024
|
+
...pending4.subtitle ? { subtitle: pending4.subtitle } : {},
|
|
23025
|
+
...pending4.riskLevel ? { riskLevel: pending4.riskLevel } : {},
|
|
23026
|
+
...pending4.supportsAlwaysPersist !== void 0 ? { supportsAlwaysPersist: pending4.supportsAlwaysPersist } : {}
|
|
22891
23027
|
};
|
|
22892
23028
|
}
|
|
22893
|
-
function nodePendingToQuestionRequest(
|
|
22894
|
-
if (!
|
|
22895
|
-
const input =
|
|
23029
|
+
function nodePendingToQuestionRequest(pending4) {
|
|
23030
|
+
if (!pending4?.interactionId || pending4.kind !== "question") return null;
|
|
23031
|
+
const input = pending4.input && typeof pending4.input === "object" ? pending4.input : {};
|
|
22896
23032
|
const raw2 = Array.isArray(input.questions) ? input.questions : [];
|
|
22897
23033
|
const questions = [];
|
|
22898
23034
|
for (const q3 of raw2) {
|
|
@@ -22934,26 +23070,26 @@ function nodePendingToQuestionRequest(pending3) {
|
|
|
22934
23070
|
typeof input.previewFormat === "string" ? input.previewFormat : void 0
|
|
22935
23071
|
);
|
|
22936
23072
|
return {
|
|
22937
|
-
requestId:
|
|
23073
|
+
requestId: pending4.interactionId,
|
|
22938
23074
|
questions,
|
|
22939
23075
|
...previewFormat ? { previewFormat } : {}
|
|
22940
23076
|
};
|
|
22941
23077
|
}
|
|
22942
|
-
function nodePendingToPlanApprovalRequest(
|
|
22943
|
-
if (!
|
|
22944
|
-
const input =
|
|
23078
|
+
function nodePendingToPlanApprovalRequest(pending4) {
|
|
23079
|
+
if (!pending4?.interactionId || pending4.kind !== "plan") return null;
|
|
23080
|
+
const input = pending4.input && typeof pending4.input === "object" ? pending4.input : {};
|
|
22945
23081
|
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";
|
|
22946
23082
|
return {
|
|
22947
|
-
requestId:
|
|
23083
|
+
requestId: pending4.interactionId,
|
|
22948
23084
|
planContent: plan,
|
|
22949
23085
|
planFilePath: typeof input.planFilePath === "string" ? input.planFilePath : "",
|
|
22950
23086
|
allowedPrompts: Array.isArray(input.allowedPrompts) ? input.allowedPrompts : []
|
|
22951
23087
|
};
|
|
22952
23088
|
}
|
|
22953
|
-
function nodePendingInteractionFields(
|
|
22954
|
-
const perm = nodePendingToPermissionRequest(
|
|
22955
|
-
const question = nodePendingToQuestionRequest(
|
|
22956
|
-
const plan = nodePendingToPlanApprovalRequest(
|
|
23089
|
+
function nodePendingInteractionFields(pending4, inputRequests = []) {
|
|
23090
|
+
const perm = nodePendingToPermissionRequest(pending4);
|
|
23091
|
+
const question = nodePendingToQuestionRequest(pending4);
|
|
23092
|
+
const plan = nodePendingToPlanApprovalRequest(pending4);
|
|
22957
23093
|
const forms = inputRequests.flatMap((request) => nodePendingToPermissionRequest(request) ?? []);
|
|
22958
23094
|
return {
|
|
22959
23095
|
pendingPermissions: [...perm ? [perm] : [], ...forms],
|
|
@@ -23162,7 +23298,7 @@ var init_read_model = __esm({
|
|
|
23162
23298
|
return session;
|
|
23163
23299
|
}
|
|
23164
23300
|
const events = this.log.listForSession(sessionId, Number.MAX_SAFE_INTEGER);
|
|
23165
|
-
const
|
|
23301
|
+
const pending4 = nodePendingInteractionFields(record13?.pendingInteraction);
|
|
23166
23302
|
const core2 = {
|
|
23167
23303
|
...createDefaultChatCoreSession(),
|
|
23168
23304
|
sessionProvider: providerId,
|
|
@@ -23170,7 +23306,7 @@ var init_read_model = __esm({
|
|
|
23170
23306
|
claudeFastMode: record13?.claudeFastMode ?? void 0,
|
|
23171
23307
|
messages: record13 ? sessionMessageBlocksToChatMessages(buildSessionMessageCatalog(record13, events), providerId) : [],
|
|
23172
23308
|
status: record13?.status === "streaming" ? "streaming" : "idle",
|
|
23173
|
-
...
|
|
23309
|
+
...pending4
|
|
23174
23310
|
};
|
|
23175
23311
|
session = {
|
|
23176
23312
|
mapper,
|
|
@@ -40939,7 +41075,7 @@ var init_scanner_DX8LRFGE = __esm({
|
|
|
40939
41075
|
}
|
|
40940
41076
|
findNextMatchSync(string8, startPosition, _options) {
|
|
40941
41077
|
const str5 = typeof string8 === "string" ? string8 : string8.content;
|
|
40942
|
-
const
|
|
41078
|
+
const pending4 = [];
|
|
40943
41079
|
function toResult(index, match, offset = 0) {
|
|
40944
41080
|
return {
|
|
40945
41081
|
index,
|
|
@@ -40965,7 +41101,7 @@ var init_scanner_DX8LRFGE = __esm({
|
|
|
40965
41101
|
const match = regexp.exec(str5);
|
|
40966
41102
|
if (!match) continue;
|
|
40967
41103
|
if (match.index === startPosition) return toResult(i2, match, 0);
|
|
40968
|
-
|
|
41104
|
+
pending4.push([
|
|
40969
41105
|
i2,
|
|
40970
41106
|
match,
|
|
40971
41107
|
0
|
|
@@ -40975,9 +41111,9 @@ var init_scanner_DX8LRFGE = __esm({
|
|
|
40975
41111
|
throw e;
|
|
40976
41112
|
}
|
|
40977
41113
|
}
|
|
40978
|
-
if (
|
|
40979
|
-
const minIndex = Math.min(...
|
|
40980
|
-
for (const [i2, match, offset] of
|
|
41114
|
+
if (pending4.length) {
|
|
41115
|
+
const minIndex = Math.min(...pending4.map((m5) => m5[1].index));
|
|
41116
|
+
for (const [i2, match, offset] of pending4) if (match.index === minIndex) return toResult(i2, match, offset);
|
|
40981
41117
|
}
|
|
40982
41118
|
return null;
|
|
40983
41119
|
}
|
|
@@ -47999,7 +48135,7 @@ async function openCodexAppServer(opts) {
|
|
|
47999
48135
|
stderrBuf = (stderrBuf + chunk).slice(-MAX_STDERR_CHARS);
|
|
48000
48136
|
});
|
|
48001
48137
|
const rl = createInterface({ input: child.stdout });
|
|
48002
|
-
const
|
|
48138
|
+
const pending4 = /* @__PURE__ */ new Map();
|
|
48003
48139
|
const notificationWaiters = [];
|
|
48004
48140
|
const notificationQueue = [];
|
|
48005
48141
|
let nextId = 1;
|
|
@@ -48023,11 +48159,11 @@ async function openCodexAppServer(opts) {
|
|
|
48023
48159
|
};
|
|
48024
48160
|
const failAll = (err) => {
|
|
48025
48161
|
inboundAbort.abort();
|
|
48026
|
-
for (const [, p4] of
|
|
48162
|
+
for (const [, p4] of pending4) {
|
|
48027
48163
|
p4.cancelDeadline();
|
|
48028
48164
|
p4.reject(err);
|
|
48029
48165
|
}
|
|
48030
|
-
|
|
48166
|
+
pending4.clear();
|
|
48031
48167
|
while (notificationWaiters.length) {
|
|
48032
48168
|
const w5 = notificationWaiters.shift();
|
|
48033
48169
|
clearTimeout(w5.timer);
|
|
@@ -48155,9 +48291,9 @@ async function openCodexAppServer(opts) {
|
|
|
48155
48291
|
}
|
|
48156
48292
|
if (rec.id != null && (typeof rec.id === "number" || typeof rec.id === "string")) {
|
|
48157
48293
|
const id = typeof rec.id === "number" ? rec.id : Number(rec.id);
|
|
48158
|
-
const waiter =
|
|
48294
|
+
const waiter = pending4.get(id);
|
|
48159
48295
|
if (!waiter) continue;
|
|
48160
|
-
|
|
48296
|
+
pending4.delete(id);
|
|
48161
48297
|
waiter.cancelDeadline();
|
|
48162
48298
|
if (rec.error) {
|
|
48163
48299
|
const errObj = rec.error;
|
|
@@ -48175,6 +48311,10 @@ async function openCodexAppServer(opts) {
|
|
|
48175
48311
|
pushNotification({ method: rec.method, params });
|
|
48176
48312
|
}
|
|
48177
48313
|
}
|
|
48314
|
+
if (!closed && !readLoopError) {
|
|
48315
|
+
readLoopError = new Error("Codex app-server connection closed");
|
|
48316
|
+
failAll(readLoopError);
|
|
48317
|
+
}
|
|
48178
48318
|
} catch (err) {
|
|
48179
48319
|
readLoopError = err instanceof Error ? err : new Error(String(err));
|
|
48180
48320
|
failAll(safePublicError("Codex app-server read failed", readLoopError));
|
|
@@ -48196,15 +48336,15 @@ async function openCodexAppServer(opts) {
|
|
|
48196
48336
|
}
|
|
48197
48337
|
const id = nextId++;
|
|
48198
48338
|
const cancelDeadline = inputBudget.deadline(timeoutMs, () => {
|
|
48199
|
-
|
|
48339
|
+
pending4.delete(id);
|
|
48200
48340
|
reject(new Error(`Codex app-server ${method} timed out after ${timeoutMs}ms`));
|
|
48201
48341
|
});
|
|
48202
48342
|
const waiter = { resolve: resolve24, reject, cancelDeadline };
|
|
48203
|
-
|
|
48343
|
+
pending4.set(id, waiter);
|
|
48204
48344
|
try {
|
|
48205
48345
|
writeLine({ jsonrpc: "2.0", id, method, params: params ?? {} });
|
|
48206
48346
|
} catch (err) {
|
|
48207
|
-
|
|
48347
|
+
pending4.delete(id);
|
|
48208
48348
|
waiter.cancelDeadline();
|
|
48209
48349
|
reject(safePublicError("Codex app-server write failed", err));
|
|
48210
48350
|
}
|
|
@@ -48222,7 +48362,7 @@ async function openCodexAppServer(opts) {
|
|
|
48222
48362
|
return;
|
|
48223
48363
|
}
|
|
48224
48364
|
if (closed) {
|
|
48225
|
-
|
|
48365
|
+
reject(new Error("Codex app-server closed"));
|
|
48226
48366
|
return;
|
|
48227
48367
|
}
|
|
48228
48368
|
const timer = setTimeout(() => {
|
|
@@ -48421,9 +48561,6 @@ async function runCodexAppServerTurn(opts) {
|
|
|
48421
48561
|
turnId = readString4(turn?.id);
|
|
48422
48562
|
}
|
|
48423
48563
|
let finalText = "";
|
|
48424
|
-
const deadline = Date.now() + TURN_WAIT_TIMEOUT_MS;
|
|
48425
|
-
const inputWaitAtStart = opts.client.getUserInputWaitMs?.() ?? 0;
|
|
48426
|
-
const remaining = () => deadline - Date.now() + (opts.client.getUserInputWaitMs?.() ?? 0) - inputWaitAtStart;
|
|
48427
48564
|
const agentEventMapper = opts.onAgentEvent ? createCodexAgentEventMapper({
|
|
48428
48565
|
messageId: opts.messageId ?? `codex_${turnId ?? Date.now()}`,
|
|
48429
48566
|
emit: opts.onAgentEvent,
|
|
@@ -48434,10 +48571,10 @@ async function runCodexAppServerTurn(opts) {
|
|
|
48434
48571
|
turnKind
|
|
48435
48572
|
}) : null;
|
|
48436
48573
|
agentEventMapper?.start(threadId);
|
|
48437
|
-
while (!opts.signal.aborted
|
|
48574
|
+
while (!opts.signal.aborted) {
|
|
48438
48575
|
let note;
|
|
48439
48576
|
try {
|
|
48440
|
-
note = await opts.client.nextNotification(
|
|
48577
|
+
note = await opts.client.nextNotification(5e3);
|
|
48441
48578
|
} catch (err) {
|
|
48442
48579
|
const error51 = err instanceof Error ? err : new Error(String(err));
|
|
48443
48580
|
agentEventMapper?.fail(error51.message, /interrupt|abort/i.test(error51.message));
|
|
@@ -48487,12 +48624,8 @@ async function runCodexAppServerTurn(opts) {
|
|
|
48487
48624
|
return { finalText, threadId, turnId };
|
|
48488
48625
|
}
|
|
48489
48626
|
}
|
|
48490
|
-
|
|
48491
|
-
|
|
48492
|
-
throw new Error("Codex turn interrupted");
|
|
48493
|
-
}
|
|
48494
|
-
agentEventMapper?.fail("Codex turn timed out waiting for turn/completed");
|
|
48495
|
-
throw new Error("Codex turn timed out waiting for turn/completed");
|
|
48627
|
+
agentEventMapper?.fail("Codex turn interrupted", true);
|
|
48628
|
+
throw new Error("Codex turn interrupted");
|
|
48496
48629
|
}
|
|
48497
48630
|
function normalizeCollaborationMode(value, model, reasoningEffort) {
|
|
48498
48631
|
if (!value) return void 0;
|
|
@@ -48554,7 +48687,7 @@ function asRecord9(value) {
|
|
|
48554
48687
|
function readString4(value) {
|
|
48555
48688
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
48556
48689
|
}
|
|
48557
|
-
var DEFAULT_REQUEST_TIMEOUT_MS, THREAD_TIMEOUT_MS,
|
|
48690
|
+
var DEFAULT_REQUEST_TIMEOUT_MS, THREAD_TIMEOUT_MS, MAX_STDERR_CHARS;
|
|
48558
48691
|
var init_app_server_client = __esm({
|
|
48559
48692
|
"../../packages/codex/src/app-server-client.ts"() {
|
|
48560
48693
|
"use strict";
|
|
@@ -48572,7 +48705,6 @@ var init_app_server_client = __esm({
|
|
|
48572
48705
|
init_agent_event_mapper();
|
|
48573
48706
|
DEFAULT_REQUEST_TIMEOUT_MS = 12e4;
|
|
48574
48707
|
THREAD_TIMEOUT_MS = 6e4;
|
|
48575
|
-
TURN_WAIT_TIMEOUT_MS = 3e5;
|
|
48576
48708
|
MAX_STDERR_CHARS = 8e3;
|
|
48577
48709
|
}
|
|
48578
48710
|
});
|
|
@@ -49203,8 +49335,8 @@ var init_account_manager = __esm({
|
|
|
49203
49335
|
if (browser) this.browserStarting = true;
|
|
49204
49336
|
try {
|
|
49205
49337
|
this.store.home(id);
|
|
49206
|
-
for (const [loginId,
|
|
49207
|
-
if (
|
|
49338
|
+
for (const [loginId, pending4] of this.pending) {
|
|
49339
|
+
if (pending4.accountId === id) await this.cancel(loginId).catch(() => {
|
|
49208
49340
|
});
|
|
49209
49341
|
}
|
|
49210
49342
|
this.failed.delete(id);
|
|
@@ -49215,9 +49347,9 @@ var init_account_manager = __esm({
|
|
|
49215
49347
|
type,
|
|
49216
49348
|
...browser ? { useHostedLoginSuccessPage: true, appBrand: "chatgpt" } : {}
|
|
49217
49349
|
}));
|
|
49218
|
-
const
|
|
49219
|
-
this.pending.set(result3.loginId,
|
|
49220
|
-
void this.wait(result3.loginId,
|
|
49350
|
+
const pending4 = { accountId: id, connection, browser };
|
|
49351
|
+
this.pending.set(result3.loginId, pending4);
|
|
49352
|
+
void this.wait(result3.loginId, pending4);
|
|
49221
49353
|
return { ...result3, accountId: id };
|
|
49222
49354
|
} catch (error51) {
|
|
49223
49355
|
this.failed.add(id);
|
|
@@ -49229,53 +49361,53 @@ var init_account_manager = __esm({
|
|
|
49229
49361
|
if (browser) this.browserStarting = false;
|
|
49230
49362
|
}
|
|
49231
49363
|
}
|
|
49232
|
-
async wait(loginId,
|
|
49364
|
+
async wait(loginId, pending4) {
|
|
49233
49365
|
const deadline = Date.now() + 15 * 6e4;
|
|
49234
49366
|
const timeout = setTimeout(() => {
|
|
49235
49367
|
void this.cancel(loginId).catch(() => {
|
|
49236
49368
|
});
|
|
49237
|
-
this.failed.add(
|
|
49369
|
+
this.failed.add(pending4.accountId);
|
|
49238
49370
|
}, 15 * 6e4);
|
|
49239
49371
|
timeout.unref?.();
|
|
49240
49372
|
try {
|
|
49241
|
-
while (this.pending.get(loginId) ===
|
|
49242
|
-
const notification = await
|
|
49373
|
+
while (this.pending.get(loginId) === pending4 && Date.now() < deadline) {
|
|
49374
|
+
const notification = await pending4.connection.nextNotification();
|
|
49243
49375
|
if (!notification) throw new Error("Login connection closed");
|
|
49244
49376
|
if (notification?.method !== "account/login/completed" || notification.params.loginId !== loginId) continue;
|
|
49245
49377
|
if (notification.params.success !== true) throw new Error("Sign-in failed");
|
|
49246
|
-
const status2 = parseAccountStatus(await
|
|
49378
|
+
const status2 = parseAccountStatus(await pending4.connection.request("account/read", { refreshToken: false }));
|
|
49247
49379
|
if (!status2.signedIn) throw new Error("Sign-in did not complete");
|
|
49248
|
-
if (this.pending.get(loginId) !==
|
|
49249
|
-
this.store.update(
|
|
49250
|
-
this.store.invalidateCredentials(
|
|
49251
|
-
this.changed(codexAccountProviderId(
|
|
49380
|
+
if (this.pending.get(loginId) !== pending4) return;
|
|
49381
|
+
this.store.update(pending4.accountId, status2);
|
|
49382
|
+
this.store.invalidateCredentials(pending4.accountId);
|
|
49383
|
+
this.changed(codexAccountProviderId(pending4.accountId));
|
|
49252
49384
|
return;
|
|
49253
49385
|
}
|
|
49254
|
-
if (this.pending.get(loginId) ===
|
|
49386
|
+
if (this.pending.get(loginId) === pending4) this.failed.add(pending4.accountId);
|
|
49255
49387
|
} catch {
|
|
49256
|
-
this.failed.add(
|
|
49388
|
+
this.failed.add(pending4.accountId);
|
|
49257
49389
|
} finally {
|
|
49258
49390
|
clearTimeout(timeout);
|
|
49259
|
-
if (this.pending.get(loginId) ===
|
|
49260
|
-
await
|
|
49391
|
+
if (this.pending.get(loginId) === pending4) this.pending.delete(loginId);
|
|
49392
|
+
await pending4.connection.close().catch(() => {
|
|
49261
49393
|
});
|
|
49262
49394
|
}
|
|
49263
49395
|
}
|
|
49264
49396
|
async cancel(loginId) {
|
|
49265
|
-
const
|
|
49266
|
-
if (!
|
|
49397
|
+
const pending4 = this.pending.get(loginId);
|
|
49398
|
+
if (!pending4) return;
|
|
49267
49399
|
this.pending.delete(loginId);
|
|
49268
49400
|
try {
|
|
49269
|
-
await
|
|
49401
|
+
await pending4.connection.request("account/login/cancel", { loginId });
|
|
49270
49402
|
} finally {
|
|
49271
|
-
await
|
|
49403
|
+
await pending4.connection.close();
|
|
49272
49404
|
}
|
|
49273
49405
|
}
|
|
49274
49406
|
async logout(providerId) {
|
|
49275
49407
|
const id = codexAccountId(providerId) ?? codexAccountId(this.store.defaultProviderId()) ?? CODEX_CLI_ACCOUNT_ID;
|
|
49276
49408
|
this.revisions.set(id, (this.revisions.get(id) ?? 0) + 1);
|
|
49277
|
-
for (const [loginId,
|
|
49278
|
-
if (
|
|
49409
|
+
for (const [loginId, pending4] of this.pending) {
|
|
49410
|
+
if (pending4.accountId === id) await this.cancel(loginId);
|
|
49279
49411
|
}
|
|
49280
49412
|
const selected = codexAccountProviderId(id);
|
|
49281
49413
|
const connection = await this.open(selected);
|
|
@@ -49302,8 +49434,8 @@ var init_account_manager = __esm({
|
|
|
49302
49434
|
const unreachable = signedIn() && await this.status(providerId).then(() => false, () => true);
|
|
49303
49435
|
if (!unreachable && signedIn()) throw new Error("Sign out before removing this Codex account.");
|
|
49304
49436
|
this.revisions.set(id, (this.revisions.get(id) ?? 0) + 1);
|
|
49305
|
-
for (const [loginId,
|
|
49306
|
-
if (
|
|
49437
|
+
for (const [loginId, pending4] of this.pending) {
|
|
49438
|
+
if (pending4.accountId === id) await this.cancel(loginId);
|
|
49307
49439
|
}
|
|
49308
49440
|
this.store.remove(id, unreachable);
|
|
49309
49441
|
this.failed.delete(id);
|
|
@@ -51833,7 +51965,7 @@ var init_claude_live_session = __esm({
|
|
|
51833
51965
|
this.failAmbient("Claude SDK stream ended before the background turn completed");
|
|
51834
51966
|
this.active?.reject(new Error("Claude SDK stream ended before the user turn completed"));
|
|
51835
51967
|
this.active = null;
|
|
51836
|
-
for (const
|
|
51968
|
+
for (const pending4 of this.pending.splice(0)) pending4.reject(new Error("Claude SDK stream ended before the queued turn started"));
|
|
51837
51969
|
}
|
|
51838
51970
|
this.closed = true;
|
|
51839
51971
|
this.bridge.close();
|
|
@@ -52286,7 +52418,7 @@ var init_mod_surface = __esm({
|
|
|
52286
52418
|
this.disposed = true;
|
|
52287
52419
|
if (this.available) this.opts.emit({ type: "mod_ui_state", available: false });
|
|
52288
52420
|
this.available = false;
|
|
52289
|
-
for (const
|
|
52421
|
+
for (const pending4 of this.pendingHost.values()) pending4.resolve(null);
|
|
52290
52422
|
this.pendingHost.clear();
|
|
52291
52423
|
}
|
|
52292
52424
|
/**
|
|
@@ -52321,10 +52453,10 @@ var init_mod_surface = __esm({
|
|
|
52321
52453
|
return this.pendingHost.has(requestId);
|
|
52322
52454
|
}
|
|
52323
52455
|
acceptHostReply({ requestId, clientId: clientId2, reply }) {
|
|
52324
|
-
const
|
|
52325
|
-
if (!
|
|
52456
|
+
const pending4 = this.pendingHost.get(requestId);
|
|
52457
|
+
if (!pending4 || pending4.kind !== reply.kind || pending4.clientId !== clientId2) return { accepted: false };
|
|
52326
52458
|
this.pendingHost.delete(requestId);
|
|
52327
|
-
|
|
52459
|
+
pending4.resolve(reply);
|
|
52328
52460
|
return { accepted: true };
|
|
52329
52461
|
}
|
|
52330
52462
|
};
|
|
@@ -92603,7 +92735,9 @@ var init_monitor_session_hold = __esm({
|
|
|
92603
92735
|
suppressFollowUp = false;
|
|
92604
92736
|
note(event) {
|
|
92605
92737
|
if (event.type === "task_started") {
|
|
92606
|
-
if (event.taskType === "monitor"
|
|
92738
|
+
if (event.taskId && (event.taskType === "monitor" || event.taskType === "bash")) {
|
|
92739
|
+
this.ids.add(event.taskId);
|
|
92740
|
+
}
|
|
92607
92741
|
return;
|
|
92608
92742
|
}
|
|
92609
92743
|
if (event.type !== "task_notification") return;
|
|
@@ -92612,7 +92746,7 @@ var init_monitor_session_hold = __esm({
|
|
|
92612
92746
|
this.ids.delete(event.taskId);
|
|
92613
92747
|
}
|
|
92614
92748
|
}
|
|
92615
|
-
/** Rewrite a terminal idle while a monitor is still running. */
|
|
92749
|
+
/** Rewrite a terminal idle while a monitor or background bash is still running. */
|
|
92616
92750
|
adjust(event) {
|
|
92617
92751
|
this.suppressFollowUp = false;
|
|
92618
92752
|
if (event.type !== "status_change") return event;
|
|
@@ -93357,6 +93491,13 @@ var init_computer_use_result_shape = __esm({
|
|
|
93357
93491
|
function formatAcpRawOutput(raw2) {
|
|
93358
93492
|
return formatAgentToolOutput(raw2);
|
|
93359
93493
|
}
|
|
93494
|
+
function backgroundTaskOutputPath(raw2) {
|
|
93495
|
+
if (!raw2 || typeof raw2 !== "object" || Array.isArray(raw2)) return void 0;
|
|
93496
|
+
const record13 = raw2;
|
|
93497
|
+
if (record13.type !== "BackgroundTaskStarted") return void 0;
|
|
93498
|
+
const file2 = record13.output_file ?? record13.outputFile;
|
|
93499
|
+
return typeof file2 === "string" && file2.length > 0 ? file2 : void 0;
|
|
93500
|
+
}
|
|
93360
93501
|
function mediaGenGallerySummary(raw2) {
|
|
93361
93502
|
if (!raw2 || typeof raw2 !== "object" || Array.isArray(raw2)) return null;
|
|
93362
93503
|
const obj = raw2;
|
|
@@ -93438,10 +93579,12 @@ function toolResultFromUpdate(update, terminalOutput) {
|
|
|
93438
93579
|
const capped = shouldKeepFullToolResult(summary2, toolName) ? summary2 : summary2.slice(0, 4e3);
|
|
93439
93580
|
const failed2 = update.status === "failed";
|
|
93440
93581
|
const text4 = withGrokAutoDenyPrefix(capped || (failed2 ? "failed" : "done"), failed2);
|
|
93582
|
+
const outputPath = backgroundTaskOutputPath(update.rawOutput);
|
|
93441
93583
|
return {
|
|
93442
93584
|
type: "tool_result",
|
|
93443
93585
|
toolUseId: update.toolCallId,
|
|
93444
93586
|
summary: text4,
|
|
93587
|
+
...outputPath ? { outputPath } : {},
|
|
93445
93588
|
isError: failed2
|
|
93446
93589
|
};
|
|
93447
93590
|
}
|
|
@@ -102787,7 +102930,7 @@ function make7(connect) {
|
|
|
102787
102930
|
subscribe(options) {
|
|
102788
102931
|
return {
|
|
102789
102932
|
[Symbol.asyncIterator]() {
|
|
102790
|
-
const
|
|
102933
|
+
const pending4 = [];
|
|
102791
102934
|
const queued = [];
|
|
102792
102935
|
let started = false;
|
|
102793
102936
|
let completion;
|
|
@@ -102799,7 +102942,7 @@ function make7(connect) {
|
|
|
102799
102942
|
options?.signal?.removeEventListener("abort", abort);
|
|
102800
102943
|
if (connection?.subscribers.delete(subscriber) && !connection.subscribers.size)
|
|
102801
102944
|
stop3(connection);
|
|
102802
|
-
|
|
102945
|
+
pending4.splice(0).forEach((request) => {
|
|
102803
102946
|
if ("error" in result3)
|
|
102804
102947
|
request.reject(result3.error);
|
|
102805
102948
|
else
|
|
@@ -102817,7 +102960,7 @@ function make7(connect) {
|
|
|
102817
102960
|
push(value) {
|
|
102818
102961
|
if (completion)
|
|
102819
102962
|
return;
|
|
102820
|
-
const request =
|
|
102963
|
+
const request = pending4.shift();
|
|
102821
102964
|
if (request) {
|
|
102822
102965
|
request.resolve({ done: false, value });
|
|
102823
102966
|
return;
|
|
@@ -102859,7 +103002,7 @@ function make7(connect) {
|
|
|
102859
103002
|
return Promise.resolve({ done: true, value: void 0 });
|
|
102860
103003
|
}
|
|
102861
103004
|
const request = Promise.withResolvers();
|
|
102862
|
-
|
|
103005
|
+
pending4.push(request);
|
|
102863
103006
|
if (!started) {
|
|
102864
103007
|
started = true;
|
|
102865
103008
|
options?.signal?.addEventListener("abort", abort, { once: true });
|
|
@@ -106198,15 +106341,15 @@ var init_opencode_oauth = __esm({
|
|
|
106198
106341
|
return task;
|
|
106199
106342
|
}
|
|
106200
106343
|
reply(id, answers) {
|
|
106201
|
-
const
|
|
106202
|
-
if (!
|
|
106203
|
-
|
|
106344
|
+
const pending4 = this.forms.get(id);
|
|
106345
|
+
if (!pending4) return false;
|
|
106346
|
+
pending4.reply(openCodeV2FormAnswer(pending4.form, answers));
|
|
106204
106347
|
return true;
|
|
106205
106348
|
}
|
|
106206
106349
|
reject(id) {
|
|
106207
|
-
const
|
|
106208
|
-
if (!
|
|
106209
|
-
|
|
106350
|
+
const pending4 = this.forms.get(id);
|
|
106351
|
+
if (!pending4) return false;
|
|
106352
|
+
pending4.cancel();
|
|
106210
106353
|
return true;
|
|
106211
106354
|
}
|
|
106212
106355
|
async close() {
|
|
@@ -106356,8 +106499,8 @@ var init_opencode_oauth = __esm({
|
|
|
106356
106499
|
} finally {
|
|
106357
106500
|
clearTimeout(expiry);
|
|
106358
106501
|
if (!complete && !signal2.aborted) controller.abort(new Error("OpenCode sign-in did not complete"));
|
|
106359
|
-
for (const
|
|
106360
|
-
if (
|
|
106502
|
+
for (const pending4 of [...this.forms.values()]) {
|
|
106503
|
+
if (pending4.owner === controller) pending4.reply({});
|
|
106361
106504
|
}
|
|
106362
106505
|
if (!complete) await this.deps.client.cancelOAuth(id, attempt.attemptID).catch(() => void 0);
|
|
106363
106506
|
}
|
|
@@ -108422,13 +108565,13 @@ function createManagedOpenCodeTurnRunner(resolveProjectPath2, options = {}) {
|
|
|
108422
108565
|
if (existing.active || existing.host) throw new Error("Wait for OpenCode to become idle before changing its provider or launch configuration");
|
|
108423
108566
|
await runner.disposeSession(id);
|
|
108424
108567
|
}
|
|
108425
|
-
let
|
|
108426
|
-
if (!
|
|
108568
|
+
let pending4 = sessions.get(id);
|
|
108569
|
+
if (!pending4) {
|
|
108427
108570
|
if (!isOpenCodeBinaryRunnable(opts.binaryPath) && !opts.serverUrl?.trim())
|
|
108428
108571
|
throw new Error(
|
|
108429
108572
|
"OpenCode runtime client not available on node: enable the harness with a real binary or endpoint"
|
|
108430
108573
|
);
|
|
108431
|
-
|
|
108574
|
+
pending4 = startOpenCodeSessionServer({
|
|
108432
108575
|
...opts,
|
|
108433
108576
|
sessionId: id,
|
|
108434
108577
|
nativeSessionId: input.session.providerResume?.startsWith("opencode:") ? input.session.providerResume.slice(9) : void 0,
|
|
@@ -108451,9 +108594,9 @@ function createManagedOpenCodeTurnRunner(resolveProjectPath2, options = {}) {
|
|
|
108451
108594
|
return live2;
|
|
108452
108595
|
}
|
|
108453
108596
|
);
|
|
108454
|
-
sessions.set(id,
|
|
108597
|
+
sessions.set(id, pending4);
|
|
108455
108598
|
}
|
|
108456
|
-
const live = await
|
|
108599
|
+
const live = await pending4.catch((error51) => {
|
|
108457
108600
|
sessions.delete(id);
|
|
108458
108601
|
throw error51;
|
|
108459
108602
|
});
|
|
@@ -108536,7 +108679,7 @@ function createManagedOpenCodeTurnRunner(resolveProjectPath2, options = {}) {
|
|
|
108536
108679
|
const opts = { ...options, ...options.resolveLaunch?.(connection) };
|
|
108537
108680
|
const cwd = session.cwd?.trim() || resolveProjectPath2(session.projectId) || process.cwd();
|
|
108538
108681
|
if (!isOpenCodeBinaryRunnable(opts.binaryPath) && !opts.serverUrl?.trim()) throw new Error("OpenCode runtime is unavailable");
|
|
108539
|
-
const
|
|
108682
|
+
const pending4 = sessions.get(session.sessionId) ?? startOpenCodeSessionServer({
|
|
108540
108683
|
...opts,
|
|
108541
108684
|
sessionId: session.sessionId,
|
|
108542
108685
|
nativeSessionId: session.providerResume.slice(9),
|
|
@@ -108550,8 +108693,8 @@ function createManagedOpenCodeTurnRunner(resolveProjectPath2, options = {}) {
|
|
|
108550
108693
|
}
|
|
108551
108694
|
return open2(connection, opts, server, cwd);
|
|
108552
108695
|
});
|
|
108553
|
-
sessions.set(session.sessionId,
|
|
108554
|
-
const handle2 = await
|
|
108696
|
+
sessions.set(session.sessionId, pending4);
|
|
108697
|
+
const handle2 = await pending4;
|
|
108555
108698
|
if (!("legacy" in handle2)) live = handle2;
|
|
108556
108699
|
}
|
|
108557
108700
|
if (!live) {
|
|
@@ -108750,9 +108893,9 @@ function createManagedOpenCodeTurnRunner(resolveProjectPath2, options = {}) {
|
|
|
108750
108893
|
events?.finish(void 0, true);
|
|
108751
108894
|
};
|
|
108752
108895
|
runner.disposeSession = async (id) => {
|
|
108753
|
-
const
|
|
108896
|
+
const pending4 = sessions.get(id);
|
|
108754
108897
|
sessions.delete(id);
|
|
108755
|
-
const live = await
|
|
108898
|
+
const live = await pending4?.catch(() => null);
|
|
108756
108899
|
if (live && !("legacy" in live)) {
|
|
108757
108900
|
live.abort.abort();
|
|
108758
108901
|
await live.runtime.close();
|
|
@@ -110627,17 +110770,17 @@ var init_cursor_store = __esm({
|
|
|
110627
110770
|
|
|
110628
110771
|
// ../../packages/cursor/src/cursor-sdk.ts
|
|
110629
110772
|
function loadCursorSdk() {
|
|
110630
|
-
|
|
110631
|
-
return
|
|
110773
|
+
pending2 ??= import("@cursor/sdk").then((sdk) => loaded = sdk);
|
|
110774
|
+
return pending2;
|
|
110632
110775
|
}
|
|
110633
110776
|
function isCursorSdkError(error51, name) {
|
|
110634
110777
|
return loaded !== null && error51 instanceof loaded[name];
|
|
110635
110778
|
}
|
|
110636
|
-
var
|
|
110779
|
+
var pending2, loaded;
|
|
110637
110780
|
var init_cursor_sdk = __esm({
|
|
110638
110781
|
"../../packages/cursor/src/cursor-sdk.ts"() {
|
|
110639
110782
|
"use strict";
|
|
110640
|
-
|
|
110783
|
+
pending2 = null;
|
|
110641
110784
|
loaded = null;
|
|
110642
110785
|
}
|
|
110643
110786
|
});
|
|
@@ -111660,9 +111803,6 @@ async function openTurnAndStream(opts) {
|
|
|
111660
111803
|
const turnId = readString6(turn?.id);
|
|
111661
111804
|
opts.onTurnStarted?.(turnId);
|
|
111662
111805
|
let finalText = "";
|
|
111663
|
-
const deadline = Date.now() + TURN_WAIT_TIMEOUT_MS2;
|
|
111664
|
-
const inputWaitAtStart = opts.client.getUserInputWaitMs?.() ?? 0;
|
|
111665
|
-
const remaining = () => deadline - Date.now() + (opts.client.getUserInputWaitMs?.() ?? 0) - inputWaitAtStart;
|
|
111666
111806
|
const agentEventMapper = opts.onAgentEvent ? createCodexAgentEventMapper({
|
|
111667
111807
|
messageId: opts.messageId ?? `codex_${turnId ?? Date.now()}`,
|
|
111668
111808
|
emit: opts.onAgentEvent,
|
|
@@ -111673,12 +111813,10 @@ async function openTurnAndStream(opts) {
|
|
|
111673
111813
|
...opts.parentTurnId || opts.rootTurnId ? { requestedProvenance: { ...opts.parentTurnId ? { parentTurnId: opts.parentTurnId } : {}, ...opts.rootTurnId ? { rootTurnId: opts.rootTurnId } : {} } } : {}
|
|
111674
111814
|
}) : null;
|
|
111675
111815
|
agentEventMapper?.start(opts.threadId);
|
|
111676
|
-
while (!opts.signal.aborted
|
|
111816
|
+
while (!opts.signal.aborted) {
|
|
111677
111817
|
let note;
|
|
111678
111818
|
try {
|
|
111679
|
-
note = await opts.client.nextNotification(
|
|
111680
|
-
Math.min(5e3, Math.max(0, remaining()))
|
|
111681
|
-
);
|
|
111819
|
+
note = await opts.client.nextNotification(5e3);
|
|
111682
111820
|
} catch (err) {
|
|
111683
111821
|
const error51 = err instanceof Error ? err : new Error(String(err));
|
|
111684
111822
|
agentEventMapper?.fail(error51.message, /interrupt|abort/i.test(error51.message));
|
|
@@ -111721,20 +111859,14 @@ async function openTurnAndStream(opts) {
|
|
|
111721
111859
|
return { finalText, threadId: opts.threadId, turnId };
|
|
111722
111860
|
}
|
|
111723
111861
|
}
|
|
111724
|
-
|
|
111725
|
-
|
|
111726
|
-
throw new Error("Codex turn interrupted");
|
|
111727
|
-
}
|
|
111728
|
-
agentEventMapper?.fail("Codex turn timed out waiting for turn/completed");
|
|
111729
|
-
throw new Error("Codex turn timed out waiting for turn/completed");
|
|
111862
|
+
agentEventMapper?.fail("Codex turn interrupted", true);
|
|
111863
|
+
throw new Error("Codex turn interrupted");
|
|
111730
111864
|
}
|
|
111731
|
-
var TURN_WAIT_TIMEOUT_MS2;
|
|
111732
111865
|
var init_codex_live_turn = __esm({
|
|
111733
111866
|
"src/session/codex-live-turn.ts"() {
|
|
111734
111867
|
"use strict";
|
|
111735
111868
|
init_protocol_v162();
|
|
111736
111869
|
init_src4();
|
|
111737
|
-
TURN_WAIT_TIMEOUT_MS2 = 3e5;
|
|
111738
111870
|
}
|
|
111739
111871
|
});
|
|
111740
111872
|
|
|
@@ -127576,6 +127708,7 @@ init_environment();
|
|
|
127576
127708
|
|
|
127577
127709
|
// ../../packages/shared/src/environment/session-operations.ts
|
|
127578
127710
|
var SESSION_OPERATION_METHODS = /* @__PURE__ */ new Set([
|
|
127711
|
+
"session.answerAsyncQuestion",
|
|
127579
127712
|
"session.dequeue",
|
|
127580
127713
|
"session.steer",
|
|
127581
127714
|
"session.reportWorktreeRemoved",
|
|
@@ -127637,6 +127770,13 @@ async function callOperation(payload, ctx, method) {
|
|
|
127637
127770
|
const p4 = asRecord(payload);
|
|
127638
127771
|
try {
|
|
127639
127772
|
const sessionId = requiredText(p4, "sessionId");
|
|
127773
|
+
if (method === "session.answerAsyncQuestion") {
|
|
127774
|
+
requiredText(p4, "messageId");
|
|
127775
|
+
requiredText(p4, "itemId");
|
|
127776
|
+
if (!Array.isArray(p4.answers) || p4.answers.some((answer) => typeof answer !== "string")) {
|
|
127777
|
+
throw Object.assign(new Error("answers must be a string array"), { code: "invalid_argument" });
|
|
127778
|
+
}
|
|
127779
|
+
}
|
|
127640
127780
|
if (method === "session.dequeue" || method === "session.steer") requiredText(p4, "clientMessageId");
|
|
127641
127781
|
if (method === "session.rewind" || method === "session.previewRewind" || method === "session.truncateAtCheckpoint") requiredText(p4, "checkpointId");
|
|
127642
127782
|
if (method === "session.mcpAuthenticate") requiredText(p4, "serverName");
|
|
@@ -128471,14 +128611,14 @@ async function cloneRepository(input, onProgress) {
|
|
|
128471
128611
|
}
|
|
128472
128612
|
});
|
|
128473
128613
|
let stderrTail = "";
|
|
128474
|
-
let
|
|
128614
|
+
let pending4 = "";
|
|
128475
128615
|
let lastPercent = -1;
|
|
128476
128616
|
child.stderr.setEncoding("utf8");
|
|
128477
128617
|
child.stderr.on("data", (chunk) => {
|
|
128478
128618
|
stderrTail = (stderrTail + chunk).slice(-STDERR_TAIL_CHARS);
|
|
128479
128619
|
if (!onProgress) return;
|
|
128480
|
-
const lines2 = (
|
|
128481
|
-
|
|
128620
|
+
const lines2 = (pending4 + chunk).split(/\r|\n/);
|
|
128621
|
+
pending4 = lines2.pop() ?? "";
|
|
128482
128622
|
for (const line of lines2) {
|
|
128483
128623
|
const percent = parseCloneProgress(line);
|
|
128484
128624
|
if (percent !== null && percent > lastPercent) {
|
|
@@ -130524,10 +130664,10 @@ init_environment();
|
|
|
130524
130664
|
// ../../packages/shared/src/environment/draft-content.ts
|
|
130525
130665
|
function hasPersistableDraftContent(draft) {
|
|
130526
130666
|
if (draft.text.trim() || draft.attachments?.length) return true;
|
|
130527
|
-
const
|
|
130667
|
+
const pending4 = [draft.docJson];
|
|
130528
130668
|
const seen = /* @__PURE__ */ new Set();
|
|
130529
|
-
while (
|
|
130530
|
-
const node =
|
|
130669
|
+
while (pending4.length) {
|
|
130670
|
+
const node = pending4.pop();
|
|
130531
130671
|
if (!node || typeof node !== "object") continue;
|
|
130532
130672
|
if (seen.has(node)) continue;
|
|
130533
130673
|
seen.add(node);
|
|
@@ -130535,7 +130675,7 @@ function hasPersistableDraftContent(draft) {
|
|
|
130535
130675
|
if (type === "text" && typeof text4 === "string" && text4.trim()) return true;
|
|
130536
130676
|
const value = type === "pasteChip" ? attrs?.text : type === "mention" ? attrs?.value : null;
|
|
130537
130677
|
if (typeof value === "string" && value.trim()) return true;
|
|
130538
|
-
if (Array.isArray(content))
|
|
130678
|
+
if (Array.isArray(content)) pending4.push(...content);
|
|
130539
130679
|
}
|
|
130540
130680
|
return false;
|
|
130541
130681
|
}
|
|
@@ -130568,15 +130708,15 @@ function openTerminalStream(opts) {
|
|
|
130568
130708
|
}
|
|
130569
130709
|
function openDraftStream(opts) {
|
|
130570
130710
|
let following = false;
|
|
130571
|
-
const
|
|
130711
|
+
const pending4 = /* @__PURE__ */ new Map();
|
|
130572
130712
|
const cancel = (draftId) => {
|
|
130573
|
-
clearTimeout(
|
|
130574
|
-
|
|
130713
|
+
clearTimeout(pending4.get(draftId)?.timer);
|
|
130714
|
+
pending4.delete(draftId);
|
|
130575
130715
|
};
|
|
130576
130716
|
const send = (event) => opts.push(event.draft ? { ...event, draft: withoutDraftAttachmentBytes(event.draft) } : event);
|
|
130577
130717
|
const setTopics = (topics) => {
|
|
130578
130718
|
following = topics.some((topic2) => topic2.kind === "drafts" && topic2.environmentId === opts.environmentId);
|
|
130579
|
-
if (!following) for (const draftId of [...
|
|
130719
|
+
if (!following) for (const draftId of [...pending4.keys()]) cancel(draftId);
|
|
130580
130720
|
};
|
|
130581
130721
|
setTopics(opts.topics);
|
|
130582
130722
|
const off = opts.source.watch((event) => {
|
|
@@ -130586,23 +130726,23 @@ function openDraftStream(opts) {
|
|
|
130586
130726
|
send(event);
|
|
130587
130727
|
return;
|
|
130588
130728
|
}
|
|
130589
|
-
const queued =
|
|
130729
|
+
const queued = pending4.get(event.draftId);
|
|
130590
130730
|
if (queued) {
|
|
130591
130731
|
queued.event = event;
|
|
130592
130732
|
return;
|
|
130593
130733
|
}
|
|
130594
130734
|
const timer = setTimeout(() => {
|
|
130595
|
-
const latest =
|
|
130596
|
-
|
|
130735
|
+
const latest = pending4.get(event.draftId);
|
|
130736
|
+
pending4.delete(event.draftId);
|
|
130597
130737
|
if (latest) send(latest.event);
|
|
130598
130738
|
}, DRAFT_SAVE_INTERVAL_MS);
|
|
130599
|
-
|
|
130739
|
+
pending4.set(event.draftId, { event, timer });
|
|
130600
130740
|
});
|
|
130601
130741
|
return {
|
|
130602
130742
|
setTopics,
|
|
130603
130743
|
close: () => {
|
|
130604
130744
|
off();
|
|
130605
|
-
for (const draftId of [...
|
|
130745
|
+
for (const draftId of [...pending4.keys()]) cancel(draftId);
|
|
130606
130746
|
}
|
|
130607
130747
|
};
|
|
130608
130748
|
}
|
|
@@ -136798,14 +136938,6 @@ var en2 = {
|
|
|
136798
136938
|
description: "Skip ordinary prompts; deny rules still apply"
|
|
136799
136939
|
},
|
|
136800
136940
|
autoFailClosedToast: "Grok Auto under SuperOne will deny classifier blocks without asking. Stay on Ask if you want a prompt.",
|
|
136801
|
-
folderTrustTitle: "Trust this folder?",
|
|
136802
|
-
folderTrustBody: "Grok loads project rules, MCP servers, hooks, and skills only after you trust the folder.",
|
|
136803
|
-
folderTrustWorkspace: "Workspace",
|
|
136804
|
-
folderTrustCwd: "Directory",
|
|
136805
|
-
folderTrustKinds: "Config",
|
|
136806
|
-
folderTrustEmptyKinds: "No project config kinds were listed.",
|
|
136807
|
-
folderTrustAllow: "Trust",
|
|
136808
|
-
folderTrustReject: "Don't trust",
|
|
136809
136941
|
contextWindowLabel: "Context window",
|
|
136810
136942
|
contextWindowPreserve: "Keep current"
|
|
136811
136943
|
},
|
|
@@ -139443,6 +139575,8 @@ var en2 = {
|
|
|
139443
139575
|
copyCode: "Copy Code",
|
|
139444
139576
|
copyImage: "Copy Image",
|
|
139445
139577
|
copyTable: "Copy Table",
|
|
139578
|
+
transposeTable: "Transpose Table",
|
|
139579
|
+
restoreTable: "Original Layout",
|
|
139446
139580
|
expand: "Expand",
|
|
139447
139581
|
fastMode: "Fast mode: {{state}}",
|
|
139448
139582
|
ultracode: "Ultracode: dynamic workflows on every task",
|
|
@@ -139468,6 +139602,12 @@ var en2 = {
|
|
|
139468
139602
|
refreshUsage: "Refresh Usage",
|
|
139469
139603
|
codexTitle: "Codex Usage",
|
|
139470
139604
|
windowFallback: "Usage",
|
|
139605
|
+
noUsageInfo: "No usage information available",
|
|
139606
|
+
switchAccount: "Switch Subscription Account",
|
|
139607
|
+
allAccounts: "Subscriptions",
|
|
139608
|
+
accountCount: "{{n}} accounts",
|
|
139609
|
+
currentSession: "Current",
|
|
139610
|
+
otherAccount: "Viewing",
|
|
139471
139611
|
fiveHours: "5 Hours",
|
|
139472
139612
|
weekly: "Weekly",
|
|
139473
139613
|
percentLeft: "{{percent}}% left",
|
|
@@ -141564,14 +141704,6 @@ var zh = {
|
|
|
141564
141704
|
description: "\u8DF3\u8FC7\u5E38\u89C4\u63D0\u793A\uFF0C\u62D2\u7EDD\u89C4\u5219\u4ECD\u751F\u6548"
|
|
141565
141705
|
},
|
|
141566
141706
|
autoFailClosedToast: "SuperOne \u4E0B\u7684 Grok \u81EA\u52A8\u6A21\u5F0F\u4F1A\u76F4\u63A5\u62D2\u7EDD\u5206\u7C7B\u5668\u62E6\u622A\u7684\u64CD\u4F5C\uFF0C\u4E0D\u4F1A\u518D\u8BE2\u95EE\u3002\u82E5\u8981\u5F39\u7A97\u786E\u8BA4\uFF0C\u8BF7\u7559\u5728\u300C\u8BE2\u95EE\u300D\u3002",
|
|
141567
|
-
folderTrustTitle: "\u4FE1\u4EFB\u6B64\u6587\u4EF6\u5939\uFF1F",
|
|
141568
|
-
folderTrustBody: "\u53EA\u6709\u5728\u4F60\u4FE1\u4EFB\u8BE5\u6587\u4EF6\u5939\u4E4B\u540E\uFF0CGrok \u624D\u4F1A\u52A0\u8F7D\u9879\u76EE\u89C4\u5219\u3001MCP\u3001hooks \u548C skills\u3002",
|
|
141569
|
-
folderTrustWorkspace: "\u5DE5\u4F5C\u533A",
|
|
141570
|
-
folderTrustCwd: "\u76EE\u5F55",
|
|
141571
|
-
folderTrustKinds: "\u914D\u7F6E",
|
|
141572
|
-
folderTrustEmptyKinds: "\u6CA1\u6709\u5217\u51FA\u9879\u76EE\u914D\u7F6E\u7C7B\u578B\u3002",
|
|
141573
|
-
folderTrustAllow: "\u4FE1\u4EFB",
|
|
141574
|
-
folderTrustReject: "\u4E0D\u4FE1\u4EFB",
|
|
141575
141707
|
contextWindowLabel: "\u4E0A\u4E0B\u6587\u7A97\u53E3",
|
|
141576
141708
|
contextWindowPreserve: "\u4FDD\u6301\u5F53\u524D"
|
|
141577
141709
|
},
|
|
@@ -144206,6 +144338,8 @@ var zh = {
|
|
|
144206
144338
|
copyCode: "\u590D\u5236\u4EE3\u7801",
|
|
144207
144339
|
copyImage: "\u590D\u5236\u56FE\u7247",
|
|
144208
144340
|
copyTable: "\u590D\u5236\u8868\u683C",
|
|
144341
|
+
transposeTable: "\u884C\u5217\u4E92\u6362",
|
|
144342
|
+
restoreTable: "\u6062\u590D\u539F\u8868",
|
|
144209
144343
|
expand: "\u5C55\u5F00",
|
|
144210
144344
|
fastMode: "\u5FEB\u901F\u6A21\u5F0F\uFF1A{{state}}",
|
|
144211
144345
|
ultracode: "Ultracode\uFF1A\u6BCF\u4E2A\u4EFB\u52A1\u90FD\u4F7F\u7528\u52A8\u6001 workflow",
|
|
@@ -144231,6 +144365,12 @@ var zh = {
|
|
|
144231
144365
|
refreshUsage: "\u5237\u65B0\u7528\u91CF",
|
|
144232
144366
|
codexTitle: "Codex \u7528\u91CF",
|
|
144233
144367
|
windowFallback: "\u7528\u91CF",
|
|
144368
|
+
noUsageInfo: "\u6682\u65E0\u7528\u91CF\u4FE1\u606F",
|
|
144369
|
+
switchAccount: "\u5207\u6362\u8BA2\u9605\u8D26\u53F7",
|
|
144370
|
+
allAccounts: "\u8BA2\u9605",
|
|
144371
|
+
accountCount: "{{n}} \u4E2A\u8D26\u53F7",
|
|
144372
|
+
currentSession: "\u5F53\u524D",
|
|
144373
|
+
otherAccount: "\u9884\u89C8\u4E2D",
|
|
144234
144374
|
fiveHours: "5 \u5C0F\u65F6",
|
|
144235
144375
|
weekly: "\u6BCF\u5468",
|
|
144236
144376
|
percentLeft: "\u5269\u4F59 {{percent}}%",
|
|
@@ -144487,32 +144627,32 @@ function sidebarStatus(status2) {
|
|
|
144487
144627
|
if (status2 === "streaming" || status2 === "background" || status2 === "error") return status2;
|
|
144488
144628
|
return "idle";
|
|
144489
144629
|
}
|
|
144490
|
-
function pendingAgentEvents(
|
|
144491
|
-
if (!
|
|
144492
|
-
if (
|
|
144493
|
-
if (
|
|
144494
|
-
return [permissionEvent(
|
|
144630
|
+
function pendingAgentEvents(pending4) {
|
|
144631
|
+
if (!pending4) return [];
|
|
144632
|
+
if (pending4.kind === "question") return [questionEvent(pending4)];
|
|
144633
|
+
if (pending4.kind === "plan") return [planEvent(pending4)];
|
|
144634
|
+
return [permissionEvent(pending4)];
|
|
144495
144635
|
}
|
|
144496
|
-
function permissionEvent(
|
|
144497
|
-
const confirm =
|
|
144636
|
+
function permissionEvent(pending4) {
|
|
144637
|
+
const confirm = pending4.requestKind === "session_agents_confirm" || pending4.kind === "session_agents_confirm";
|
|
144498
144638
|
return {
|
|
144499
144639
|
type: "permission_request",
|
|
144500
144640
|
request: {
|
|
144501
|
-
requestId:
|
|
144502
|
-
toolName:
|
|
144503
|
-
...
|
|
144504
|
-
input:
|
|
144505
|
-
allowAlwaysAllow:
|
|
144506
|
-
...
|
|
144641
|
+
requestId: pending4.interactionId,
|
|
144642
|
+
toolName: pending4.toolName ?? "",
|
|
144643
|
+
...pending4.toolUseId ? { toolUseId: pending4.toolUseId } : {},
|
|
144644
|
+
input: pending4.input ?? {},
|
|
144645
|
+
allowAlwaysAllow: pending4.allowAlwaysAllow === true,
|
|
144646
|
+
...pending4.message ? { message: pending4.message } : {},
|
|
144507
144647
|
...confirm ? {
|
|
144508
144648
|
requestKind: "session_agents_confirm",
|
|
144509
|
-
...
|
|
144649
|
+
...pending4.sessionAgentsConfirm ? { sessionAgentsConfirm: pending4.sessionAgentsConfirm } : {}
|
|
144510
144650
|
} : {}
|
|
144511
144651
|
}
|
|
144512
144652
|
};
|
|
144513
144653
|
}
|
|
144514
|
-
function questionEvent(
|
|
144515
|
-
const raw2 =
|
|
144654
|
+
function questionEvent(pending4) {
|
|
144655
|
+
const raw2 = pending4.input?.questions;
|
|
144516
144656
|
const questions = Array.isArray(raw2) ? raw2.flatMap((item) => {
|
|
144517
144657
|
if (!item || typeof item !== "object") return [];
|
|
144518
144658
|
const row2 = item;
|
|
@@ -144530,11 +144670,11 @@ function questionEvent(pending3) {
|
|
|
144530
144670
|
multiSelect: row2.multiSelect === true
|
|
144531
144671
|
}];
|
|
144532
144672
|
}) : [];
|
|
144533
|
-
return { type: "ask_user_question", request: { requestId:
|
|
144673
|
+
return { type: "ask_user_question", request: { requestId: pending4.interactionId, questions } };
|
|
144534
144674
|
}
|
|
144535
|
-
function planEvent(
|
|
144536
|
-
const input =
|
|
144537
|
-
const planContent2 = typeof input.plan === "string" ? input.plan : typeof input.planContent === "string" ? input.planContent :
|
|
144675
|
+
function planEvent(pending4) {
|
|
144676
|
+
const input = pending4.input ?? {};
|
|
144677
|
+
const planContent2 = typeof input.plan === "string" ? input.plan : typeof input.planContent === "string" ? input.planContent : pending4.message ?? "";
|
|
144538
144678
|
const planFilePath = typeof input.planFilePath === "string" ? input.planFilePath : "";
|
|
144539
144679
|
const allowedPrompts = Array.isArray(input.allowedPrompts) ? input.allowedPrompts.flatMap((item) => {
|
|
144540
144680
|
if (!item || typeof item !== "object") return [];
|
|
@@ -144542,7 +144682,7 @@ function planEvent(pending3) {
|
|
|
144542
144682
|
if (typeof row2.tool !== "string" || typeof row2.prompt !== "string") return [];
|
|
144543
144683
|
return [{ tool: row2.tool, prompt: row2.prompt }];
|
|
144544
144684
|
}) : [];
|
|
144545
|
-
return { type: "plan_approval", request: { requestId:
|
|
144685
|
+
return { type: "plan_approval", request: { requestId: pending4.interactionId, planContent: planContent2, planFilePath, allowedPrompts } };
|
|
144546
144686
|
}
|
|
144547
144687
|
|
|
144548
144688
|
// src/runtime.ts
|
|
@@ -145920,7 +146060,7 @@ async function dispatchSuggestedTaskRpc(method, payload, ctx) {
|
|
|
145920
146060
|
}
|
|
145921
146061
|
}
|
|
145922
146062
|
|
|
145923
|
-
//
|
|
146063
|
+
// node_modules/@toon-format/toon/dist/index.mjs
|
|
145924
146064
|
var NULL_LITERAL = "null";
|
|
145925
146065
|
var DELIMITERS = {
|
|
145926
146066
|
comma: ",",
|
|
@@ -145946,13 +146086,29 @@ function setOwnProperty(target2, key3, value) {
|
|
|
145946
146086
|
}
|
|
145947
146087
|
target2[key3] = value;
|
|
145948
146088
|
}
|
|
146089
|
+
var COMMENT_LINE_PATTERN = new RegExp(`(?:^\uFEFF?|\\n) *#`);
|
|
146090
|
+
var RawString = class {
|
|
146091
|
+
constructor(value) {
|
|
146092
|
+
if (COMMENT_LINE_PATTERN.test(value)) throw new TypeError(`Raw string must not contain a line starting with "#": ${JSON.stringify(value)}`);
|
|
146093
|
+
this.value = value;
|
|
146094
|
+
}
|
|
146095
|
+
};
|
|
146096
|
+
function isRawString(value) {
|
|
146097
|
+
return value instanceof RawString;
|
|
146098
|
+
}
|
|
146099
|
+
var SURROGATE_PATTERN = /[\uD800-\uDFFF]/;
|
|
145949
146100
|
function normalizeValue(value) {
|
|
145950
146101
|
if (value === null) return null;
|
|
146102
|
+
if (isRawString(value)) return value;
|
|
145951
146103
|
if (typeof value === "object" && value !== null && "toJSON" in value && typeof value.toJSON === "function") {
|
|
145952
146104
|
const next = value.toJSON();
|
|
145953
146105
|
if (next !== value) return normalizeValue(next);
|
|
145954
146106
|
}
|
|
145955
|
-
if (typeof value === "string"
|
|
146107
|
+
if (typeof value === "string") {
|
|
146108
|
+
assertNoLoneSurrogate(value, "string value");
|
|
146109
|
+
return value;
|
|
146110
|
+
}
|
|
146111
|
+
if (typeof value === "boolean") return value;
|
|
145956
146112
|
if (typeof value === "number") {
|
|
145957
146113
|
if (Object.is(value, -0)) return 0;
|
|
145958
146114
|
if (!Number.isFinite(value)) return null;
|
|
@@ -145968,19 +146124,39 @@ function normalizeValue(value) {
|
|
|
145968
146124
|
if (value instanceof Map) return Object.fromEntries(Array.from(value, ([k5, v4]) => [String(k5), normalizeValue(v4)]));
|
|
145969
146125
|
if (isPlainObject2(value)) {
|
|
145970
146126
|
const encodedValues = {};
|
|
145971
|
-
for (const key3 in value) if (Object.hasOwn(value, key3))
|
|
146127
|
+
for (const key3 in value) if (Object.hasOwn(value, key3)) {
|
|
146128
|
+
assertNoLoneSurrogate(key3, "object key");
|
|
146129
|
+
setOwnProperty(encodedValues, key3, normalizeValue(value[key3]));
|
|
146130
|
+
}
|
|
145972
146131
|
return encodedValues;
|
|
145973
146132
|
}
|
|
145974
146133
|
return null;
|
|
145975
146134
|
}
|
|
146135
|
+
function assertNoLoneSurrogate(value, context) {
|
|
146136
|
+
if (!SURROGATE_PATTERN.test(value)) return;
|
|
146137
|
+
for (let index = 0; index < value.length; index++) {
|
|
146138
|
+
const code = value.charCodeAt(index);
|
|
146139
|
+
if (code < 55296 || code > 57343) continue;
|
|
146140
|
+
const isHighSurrogate = code <= 56319;
|
|
146141
|
+
const next = value.charCodeAt(index + 1);
|
|
146142
|
+
if (isHighSurrogate && next >= 56320 && next <= 57343) {
|
|
146143
|
+
index++;
|
|
146144
|
+
continue;
|
|
146145
|
+
}
|
|
146146
|
+
throw new TypeError(`Cannot encode ${context} containing an unpaired surrogate U+${code.toString(16).toUpperCase()} at index ${index}`);
|
|
146147
|
+
}
|
|
146148
|
+
}
|
|
145976
146149
|
function isJsonPrimitive(value) {
|
|
145977
146150
|
return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
145978
146151
|
}
|
|
146152
|
+
function isEncodablePrimitive(value) {
|
|
146153
|
+
return isJsonPrimitive(value) || isRawString(value);
|
|
146154
|
+
}
|
|
145979
146155
|
function isJsonArray(value) {
|
|
145980
146156
|
return Array.isArray(value);
|
|
145981
146157
|
}
|
|
145982
146158
|
function isJsonObject(value) {
|
|
145983
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
146159
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && !isRawString(value);
|
|
145984
146160
|
}
|
|
145985
146161
|
function isEmptyObject(value) {
|
|
145986
146162
|
return Object.keys(value).length === 0;
|
|
@@ -145991,7 +146167,7 @@ function isPlainObject2(value) {
|
|
|
145991
146167
|
return prototype === null || prototype === Object.prototype;
|
|
145992
146168
|
}
|
|
145993
146169
|
function isArrayOfPrimitives(value) {
|
|
145994
|
-
return value.length === 0 || value.every((item) =>
|
|
146170
|
+
return value.length === 0 || value.every((item) => isEncodablePrimitive(item));
|
|
145995
146171
|
}
|
|
145996
146172
|
function isArrayOfArrays(value) {
|
|
145997
146173
|
return value.length === 0 || value.every((item) => isJsonArray(item));
|
|
@@ -145999,17 +146175,16 @@ function isArrayOfArrays(value) {
|
|
|
145999
146175
|
function isArrayOfObjects(value) {
|
|
146000
146176
|
return value.length === 0 || value.every((item) => isJsonObject(item));
|
|
146001
146177
|
}
|
|
146002
|
-
var NUMERIC_LIKE_PATTERN =
|
|
146003
|
-
|
|
146178
|
+
var NUMERIC_LIKE_PATTERN = /^[+-]?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i;
|
|
146179
|
+
function assertValidDelimiter(delimiter3) {
|
|
146180
|
+
if (!Object.values(DELIMITERS).includes(delimiter3)) throw new TypeError(`Invalid delimiter ${JSON.stringify(delimiter3)}. Valid delimiters are: comma (,), tab (\\t), pipe (|)`);
|
|
146181
|
+
}
|
|
146004
146182
|
function isValidUnquotedKey(key3) {
|
|
146005
146183
|
return /^[A-Z_][\w.]*$/i.test(key3);
|
|
146006
146184
|
}
|
|
146007
|
-
function isIdentifierSegment(key3) {
|
|
146008
|
-
return /^[A-Z_]\w*$/i.test(key3);
|
|
146009
|
-
}
|
|
146010
146185
|
function isSafeUnquoted(value, delimiter3 = DEFAULT_DELIMITER) {
|
|
146011
146186
|
if (!value) return false;
|
|
146012
|
-
if (
|
|
146187
|
+
if (/^[ \t]|[ \t]$/.test(value)) return false;
|
|
146013
146188
|
if (isBooleanOrNullLiteral(value) || isNumericLike(value)) return false;
|
|
146014
146189
|
if (value.includes(":")) return false;
|
|
146015
146190
|
if (value.includes('"') || value.includes("\\")) return false;
|
|
@@ -146017,55 +146192,14 @@ function isSafeUnquoted(value, delimiter3 = DEFAULT_DELIMITER) {
|
|
|
146017
146192
|
if (/[\u0000-\u001F]/.test(value)) return false;
|
|
146018
146193
|
if (value.includes(delimiter3)) return false;
|
|
146019
146194
|
if (value.startsWith("-")) return false;
|
|
146195
|
+
if (value.startsWith("#")) return false;
|
|
146020
146196
|
return true;
|
|
146021
146197
|
}
|
|
146022
146198
|
function isNumericLike(value) {
|
|
146023
|
-
return NUMERIC_LIKE_PATTERN.test(value)
|
|
146024
|
-
}
|
|
146025
|
-
function tryFoldKeyChain(key3, value, siblings2, options, rootLiteralKeys, pathPrefix, flattenDepth) {
|
|
146026
|
-
if (options.keyFolding !== "safe") return;
|
|
146027
|
-
if (!isJsonObject(value)) return;
|
|
146028
|
-
const { segments, tail, leafValue } = collectSingleKeyChain(key3, value, flattenDepth ?? options.flattenDepth);
|
|
146029
|
-
if (segments.length < 2) return;
|
|
146030
|
-
if (!segments.every((seg) => isIdentifierSegment(seg))) return;
|
|
146031
|
-
const foldedKey = buildFoldedKey(segments);
|
|
146032
|
-
const absolutePath2 = pathPrefix ? `${pathPrefix}.${foldedKey}` : foldedKey;
|
|
146033
|
-
if (siblings2.includes(foldedKey)) return;
|
|
146034
|
-
if (rootLiteralKeys && rootLiteralKeys.has(absolutePath2)) return;
|
|
146035
|
-
return {
|
|
146036
|
-
foldedKey,
|
|
146037
|
-
remainder: tail,
|
|
146038
|
-
leafValue,
|
|
146039
|
-
segmentCount: segments.length
|
|
146040
|
-
};
|
|
146041
|
-
}
|
|
146042
|
-
function collectSingleKeyChain(startKey, startValue, maxDepth) {
|
|
146043
|
-
const segments = [startKey];
|
|
146044
|
-
let currentValue = startValue;
|
|
146045
|
-
while (segments.length < maxDepth) {
|
|
146046
|
-
if (!isJsonObject(currentValue)) break;
|
|
146047
|
-
const keys = Object.keys(currentValue);
|
|
146048
|
-
if (keys.length !== 1) break;
|
|
146049
|
-
const nextKey = keys[0];
|
|
146050
|
-
const nextValue = currentValue[nextKey];
|
|
146051
|
-
segments.push(nextKey);
|
|
146052
|
-
currentValue = nextValue;
|
|
146053
|
-
}
|
|
146054
|
-
if (!isJsonObject(currentValue) || isEmptyObject(currentValue)) return {
|
|
146055
|
-
segments,
|
|
146056
|
-
tail: void 0,
|
|
146057
|
-
leafValue: currentValue
|
|
146058
|
-
};
|
|
146059
|
-
return {
|
|
146060
|
-
segments,
|
|
146061
|
-
tail: currentValue,
|
|
146062
|
-
leafValue: currentValue
|
|
146063
|
-
};
|
|
146064
|
-
}
|
|
146065
|
-
function buildFoldedKey(segments) {
|
|
146066
|
-
return segments.join(".");
|
|
146199
|
+
return NUMERIC_LIKE_PATTERN.test(value);
|
|
146067
146200
|
}
|
|
146068
146201
|
function encodePrimitive(value, delimiter3) {
|
|
146202
|
+
if (isRawString(value)) return value.value;
|
|
146069
146203
|
if (value === null) return NULL_LITERAL;
|
|
146070
146204
|
if (typeof value === "boolean") return String(value);
|
|
146071
146205
|
if (typeof value === "number") return String(value);
|
|
@@ -146088,73 +146222,114 @@ function formatHeader(length, options) {
|
|
|
146088
146222
|
const delimiter3 = options?.delimiter ?? ",";
|
|
146089
146223
|
let header = "";
|
|
146090
146224
|
if (key3 != null) header += encodeKey(key3);
|
|
146091
|
-
header += `[${length}${delimiter3 !== DEFAULT_DELIMITER ? delimiter3 : ""}]`;
|
|
146092
|
-
if (fields) {
|
|
146093
|
-
const quotedFields = fields.map((f4) => encodeKey(f4));
|
|
146094
|
-
header += `{${quotedFields.join(delimiter3)}}`;
|
|
146095
|
-
}
|
|
146225
|
+
header += `[${length}${options?.keyed ? ":" : ""}${delimiter3 !== DEFAULT_DELIMITER ? delimiter3 : ""}]`;
|
|
146226
|
+
if (fields) header += `{${formatFieldSegment(fields, delimiter3)}}`;
|
|
146096
146227
|
header += ":";
|
|
146097
146228
|
return header;
|
|
146098
146229
|
}
|
|
146230
|
+
function formatFieldSegment(fields, delimiter3) {
|
|
146231
|
+
return fields.map((field) => encodeKey(field.name) + (field.children ? `{${formatFieldSegment(field.children, delimiter3)}}` : "")).join(delimiter3);
|
|
146232
|
+
}
|
|
146233
|
+
function extractTabularFields(rows) {
|
|
146234
|
+
if (rows.length === 0) return;
|
|
146235
|
+
const firstKeys = Object.keys(rows[0]);
|
|
146236
|
+
if (firstKeys.length === 0) return;
|
|
146237
|
+
for (const row2 of rows) {
|
|
146238
|
+
if (Object.keys(row2).length !== firstKeys.length) return;
|
|
146239
|
+
for (const key3 of firstKeys) if (!Object.hasOwn(row2, key3)) return;
|
|
146240
|
+
}
|
|
146241
|
+
const fieldNodes = [];
|
|
146242
|
+
for (const key3 of firstKeys) {
|
|
146243
|
+
const fieldNode = classifyColumn(key3, rows.map((row2) => row2[key3]));
|
|
146244
|
+
if (!fieldNode) return;
|
|
146245
|
+
fieldNodes.push(fieldNode);
|
|
146246
|
+
}
|
|
146247
|
+
return fieldNodes;
|
|
146248
|
+
}
|
|
146249
|
+
function extractKeyedTabularFields(value) {
|
|
146250
|
+
const entryValues = Object.values(value);
|
|
146251
|
+
if (entryValues.length < 2) return;
|
|
146252
|
+
if (!entryValues.every((entryValue) => isJsonObject(entryValue) && !isEmptyObject(entryValue))) return;
|
|
146253
|
+
return extractTabularFields(entryValues);
|
|
146254
|
+
}
|
|
146255
|
+
function collectRowLeaves(row2, fields) {
|
|
146256
|
+
const leaves = [];
|
|
146257
|
+
collectLeafValues(row2, fields, leaves);
|
|
146258
|
+
return leaves;
|
|
146259
|
+
}
|
|
146260
|
+
function classifyColumn(name, values) {
|
|
146261
|
+
if (values.every((value) => isEncodablePrimitive(value))) return { name };
|
|
146262
|
+
if (!values.every((value) => isJsonObject(value) && !isEmptyObject(value))) return;
|
|
146263
|
+
const children = extractTabularFields(values);
|
|
146264
|
+
if (!children) return;
|
|
146265
|
+
return {
|
|
146266
|
+
name,
|
|
146267
|
+
children
|
|
146268
|
+
};
|
|
146269
|
+
}
|
|
146270
|
+
function collectLeafValues(row2, fields, leaves) {
|
|
146271
|
+
for (const field of fields) {
|
|
146272
|
+
const value = row2[field.name];
|
|
146273
|
+
if (field.children) collectLeafValues(value, field.children, leaves);
|
|
146274
|
+
else leaves.push(value);
|
|
146275
|
+
}
|
|
146276
|
+
}
|
|
146099
146277
|
function* encodeJsonValue(value, options, depth) {
|
|
146100
|
-
if (
|
|
146278
|
+
if (isEncodablePrimitive(value)) {
|
|
146101
146279
|
const encodedPrimitive = encodePrimitive(value, options.delimiter);
|
|
146102
146280
|
if (encodedPrimitive !== "") yield encodedPrimitive;
|
|
146103
146281
|
return;
|
|
146104
146282
|
}
|
|
146105
146283
|
if (isJsonArray(value)) yield* encodeArrayLines(void 0, value, depth, options);
|
|
146106
|
-
else if (isJsonObject(value))
|
|
146107
|
-
|
|
146108
|
-
|
|
146109
|
-
|
|
146110
|
-
|
|
146111
|
-
const effectiveFlattenDepth = remainingDepth ?? options.flattenDepth;
|
|
146112
|
-
for (const [key3, val] of Object.entries(value)) yield* encodeKeyValuePairLines(key3, val, depth, options, keys, rootLiteralKeys, pathPrefix, effectiveFlattenDepth);
|
|
146113
|
-
}
|
|
146114
|
-
function* encodeKeyValuePairLines(key3, value, depth, options, siblings2, rootLiteralKeys, pathPrefix, flattenDepth) {
|
|
146115
|
-
const currentPath = pathPrefix ? `${pathPrefix}.${key3}` : key3;
|
|
146116
|
-
const effectiveFlattenDepth = flattenDepth ?? options.flattenDepth;
|
|
146117
|
-
if (options.keyFolding === "safe" && siblings2) {
|
|
146118
|
-
const foldResult = tryFoldKeyChain(key3, value, siblings2, options, rootLiteralKeys, pathPrefix, effectiveFlattenDepth);
|
|
146119
|
-
if (foldResult) {
|
|
146120
|
-
const { foldedKey, remainder, leafValue, segmentCount } = foldResult;
|
|
146121
|
-
const encodedFoldedKey = encodeKey(foldedKey);
|
|
146122
|
-
if (remainder === void 0) {
|
|
146123
|
-
if (isJsonPrimitive(leafValue)) {
|
|
146124
|
-
yield indentedLine(depth, `${encodedFoldedKey}: ${encodePrimitive(leafValue, options.delimiter)}`, options.indent);
|
|
146125
|
-
return;
|
|
146126
|
-
} else if (isJsonArray(leafValue)) {
|
|
146127
|
-
yield* encodeArrayLines(foldedKey, leafValue, depth, options);
|
|
146128
|
-
return;
|
|
146129
|
-
} else if (isJsonObject(leafValue) && isEmptyObject(leafValue)) {
|
|
146130
|
-
yield indentedLine(depth, `${encodedFoldedKey}:`, options.indent);
|
|
146131
|
-
return;
|
|
146132
|
-
}
|
|
146133
|
-
}
|
|
146134
|
-
if (isJsonObject(remainder)) {
|
|
146135
|
-
yield indentedLine(depth, `${encodedFoldedKey}:`, options.indent);
|
|
146136
|
-
const remainingDepth = effectiveFlattenDepth - segmentCount;
|
|
146137
|
-
const foldedPath = pathPrefix ? `${pathPrefix}.${foldedKey}` : foldedKey;
|
|
146138
|
-
yield* encodeObjectLines(remainder, depth + 1, options, rootLiteralKeys, foldedPath, remainingDepth);
|
|
146139
|
-
return;
|
|
146140
|
-
}
|
|
146284
|
+
else if (isJsonObject(value)) {
|
|
146285
|
+
const keyedFields = extractKeyedTabularFields(value);
|
|
146286
|
+
if (keyedFields) {
|
|
146287
|
+
yield* encodeKeyedObjectLines(void 0, value, keyedFields, depth, options);
|
|
146288
|
+
return;
|
|
146141
146289
|
}
|
|
146290
|
+
yield* encodeObjectLines(value, depth, options);
|
|
146142
146291
|
}
|
|
146292
|
+
}
|
|
146293
|
+
function* encodeObjectLines(value, depth, options) {
|
|
146294
|
+
for (const [key3, val] of Object.entries(value)) yield* encodeKeyValuePairLines(key3, val, depth, options);
|
|
146295
|
+
}
|
|
146296
|
+
function* encodeKeyValuePairLines(key3, value, depth, options) {
|
|
146143
146297
|
const encodedKey = encodeKey(key3);
|
|
146144
|
-
if (
|
|
146298
|
+
if (isEncodablePrimitive(value)) yield indentedLine(depth, `${encodedKey}: ${encodePrimitive(value, options.delimiter)}`, options.indentSize);
|
|
146145
146299
|
else if (isJsonArray(value)) yield* encodeArrayLines(key3, value, depth, options);
|
|
146146
146300
|
else if (isJsonObject(value)) {
|
|
146147
|
-
|
|
146148
|
-
if (
|
|
146301
|
+
const keyedFields = extractKeyedTabularFields(value);
|
|
146302
|
+
if (keyedFields) {
|
|
146303
|
+
yield* encodeKeyedObjectLines(key3, value, keyedFields, depth, options);
|
|
146304
|
+
return;
|
|
146305
|
+
}
|
|
146306
|
+
yield indentedLine(depth, `${encodedKey}:`, options.indentSize);
|
|
146307
|
+
if (!isEmptyObject(value)) yield* encodeObjectLines(value, depth + 1, options);
|
|
146308
|
+
}
|
|
146309
|
+
}
|
|
146310
|
+
function* encodeKeyedObjectLines(key3, value, fields, depth, options) {
|
|
146311
|
+
const entries = Object.entries(value);
|
|
146312
|
+
yield indentedLine(depth, formatHeader(entries.length, {
|
|
146313
|
+
key: key3,
|
|
146314
|
+
fields,
|
|
146315
|
+
delimiter: options.delimiter,
|
|
146316
|
+
keyed: true
|
|
146317
|
+
}), options.indentSize);
|
|
146318
|
+
yield* encodeKeyedEntryRowsLines(entries, fields, depth + 1, options);
|
|
146319
|
+
}
|
|
146320
|
+
function* encodeKeyedEntryRowsLines(entries, fields, depth, options) {
|
|
146321
|
+
for (const [entryKey, entryValue] of entries) {
|
|
146322
|
+
const leaves = collectRowLeaves(entryValue, fields);
|
|
146323
|
+
yield indentedLine(depth, `${encodeKey(entryKey)}: ${encodeAndJoinPrimitives(leaves, options.delimiter)}`, options.indentSize);
|
|
146149
146324
|
}
|
|
146150
146325
|
}
|
|
146151
146326
|
function* encodeArrayLines(key3, value, depth, options) {
|
|
146152
146327
|
if (value.length === 0) {
|
|
146153
|
-
yield indentedLine(depth, key3 != null ? `${encodeKey(key3)}: []` : "[]", options.
|
|
146328
|
+
yield indentedLine(depth, key3 != null ? `${encodeKey(key3)}: []` : "[]", options.indentSize);
|
|
146154
146329
|
return;
|
|
146155
146330
|
}
|
|
146156
146331
|
if (isArrayOfPrimitives(value)) {
|
|
146157
|
-
yield indentedLine(depth, encodeInlineArrayLine(value, options.delimiter, key3), options.
|
|
146332
|
+
yield indentedLine(depth, encodeInlineArrayLine(value, options.delimiter, key3), options.indentSize);
|
|
146158
146333
|
return;
|
|
146159
146334
|
}
|
|
146160
146335
|
if (isArrayOfArrays(value)) {
|
|
@@ -146164,8 +146339,8 @@ function* encodeArrayLines(key3, value, depth, options) {
|
|
|
146164
146339
|
}
|
|
146165
146340
|
}
|
|
146166
146341
|
if (isArrayOfObjects(value)) {
|
|
146167
|
-
const
|
|
146168
|
-
if (
|
|
146342
|
+
const fields = extractTabularFields(value);
|
|
146343
|
+
if (fields) yield* encodeArrayOfObjectsAsTabularLines(key3, value, fields, depth, options);
|
|
146169
146344
|
else yield* encodeMixedArrayAsListItemsLines(key3, value, depth, options);
|
|
146170
146345
|
return;
|
|
146171
146346
|
}
|
|
@@ -146175,10 +146350,10 @@ function* encodeArrayOfArraysAsListItemsLines(prefix, values, depth, options) {
|
|
|
146175
146350
|
yield indentedLine(depth, formatHeader(values.length, {
|
|
146176
146351
|
key: prefix,
|
|
146177
146352
|
delimiter: options.delimiter
|
|
146178
|
-
}), options.
|
|
146353
|
+
}), options.indentSize);
|
|
146179
146354
|
for (const arr of values) if (isArrayOfPrimitives(arr)) {
|
|
146180
146355
|
const arrayLine = encodeInlineArrayLine(arr, options.delimiter);
|
|
146181
|
-
yield indentedListItem(depth + 1, arrayLine, options.
|
|
146356
|
+
yield indentedListItem(depth + 1, arrayLine, options.indentSize);
|
|
146182
146357
|
}
|
|
146183
146358
|
}
|
|
146184
146359
|
function encodeInlineArrayLine(values, delimiter3, prefix) {
|
|
@@ -146190,81 +146365,79 @@ function encodeInlineArrayLine(values, delimiter3, prefix) {
|
|
|
146190
146365
|
if (values.length === 0) return header;
|
|
146191
146366
|
return `${header} ${joinedValue}`;
|
|
146192
146367
|
}
|
|
146193
|
-
function* encodeArrayOfObjectsAsTabularLines(prefix, rows,
|
|
146368
|
+
function* encodeArrayOfObjectsAsTabularLines(prefix, rows, fields, depth, options) {
|
|
146194
146369
|
yield indentedLine(depth, formatHeader(rows.length, {
|
|
146195
146370
|
key: prefix,
|
|
146196
|
-
fields
|
|
146371
|
+
fields,
|
|
146197
146372
|
delimiter: options.delimiter
|
|
146198
|
-
}), options.
|
|
146199
|
-
yield* writeTabularRowsLines(rows,
|
|
146373
|
+
}), options.indentSize);
|
|
146374
|
+
yield* writeTabularRowsLines(rows, fields, depth + 1, options);
|
|
146200
146375
|
}
|
|
146201
|
-
function
|
|
146202
|
-
|
|
146203
|
-
const firstRow = rows[0];
|
|
146204
|
-
const firstKeys = Object.keys(firstRow);
|
|
146205
|
-
if (firstKeys.length === 0) return;
|
|
146206
|
-
if (isTabularArray(rows, firstKeys)) return firstKeys;
|
|
146207
|
-
}
|
|
146208
|
-
function isTabularArray(rows, header) {
|
|
146209
|
-
for (const row2 of rows) {
|
|
146210
|
-
if (Object.keys(row2).length !== header.length) return false;
|
|
146211
|
-
for (const key3 of header) {
|
|
146212
|
-
if (!Object.hasOwn(row2, key3)) return false;
|
|
146213
|
-
if (!isJsonPrimitive(row2[key3])) return false;
|
|
146214
|
-
}
|
|
146215
|
-
}
|
|
146216
|
-
return true;
|
|
146217
|
-
}
|
|
146218
|
-
function* writeTabularRowsLines(rows, header, depth, options) {
|
|
146219
|
-
for (const row2 of rows) yield indentedLine(depth, encodeAndJoinPrimitives(header.map((key3) => row2[key3]), options.delimiter), options.indent);
|
|
146376
|
+
function* writeTabularRowsLines(rows, fields, depth, options) {
|
|
146377
|
+
for (const row2 of rows) yield indentedLine(depth, encodeAndJoinPrimitives(collectRowLeaves(row2, fields), options.delimiter), options.indentSize);
|
|
146220
146378
|
}
|
|
146221
146379
|
function* encodeMixedArrayAsListItemsLines(prefix, items, depth, options) {
|
|
146222
146380
|
yield indentedLine(depth, formatHeader(items.length, {
|
|
146223
146381
|
key: prefix,
|
|
146224
146382
|
delimiter: options.delimiter
|
|
146225
|
-
}), options.
|
|
146383
|
+
}), options.indentSize);
|
|
146226
146384
|
for (const item of items) yield* encodeListItemValueLines(item, depth + 1, options);
|
|
146227
146385
|
}
|
|
146228
146386
|
function* encodeObjectAsListItemLines(obj, depth, options) {
|
|
146229
146387
|
if (isEmptyObject(obj)) {
|
|
146230
|
-
yield indentedLine(depth, "-", options.
|
|
146388
|
+
yield indentedLine(depth, "-", options.indentSize);
|
|
146231
146389
|
return;
|
|
146232
146390
|
}
|
|
146233
146391
|
const entries = Object.entries(obj);
|
|
146234
146392
|
const [firstKey, firstValue] = entries[0];
|
|
146235
146393
|
const restEntries = entries.slice(1);
|
|
146236
146394
|
if (isJsonArray(firstValue) && isArrayOfObjects(firstValue)) {
|
|
146237
|
-
const
|
|
146238
|
-
if (
|
|
146395
|
+
const fields = extractTabularFields(firstValue);
|
|
146396
|
+
if (fields) {
|
|
146239
146397
|
yield indentedListItem(depth, formatHeader(firstValue.length, {
|
|
146240
146398
|
key: firstKey,
|
|
146241
|
-
fields
|
|
146399
|
+
fields,
|
|
146242
146400
|
delimiter: options.delimiter
|
|
146243
|
-
}), options.
|
|
146244
|
-
yield* writeTabularRowsLines(firstValue,
|
|
146401
|
+
}), options.indentSize);
|
|
146402
|
+
yield* writeTabularRowsLines(firstValue, fields, depth + 2, options);
|
|
146403
|
+
if (restEntries.length > 0) yield* encodeObjectLines(Object.fromEntries(restEntries), depth + 1, options);
|
|
146404
|
+
return;
|
|
146405
|
+
}
|
|
146406
|
+
}
|
|
146407
|
+
if (isJsonObject(firstValue)) {
|
|
146408
|
+
const keyedFields = extractKeyedTabularFields(firstValue);
|
|
146409
|
+
if (keyedFields) {
|
|
146410
|
+
const keyedEntries = Object.entries(firstValue);
|
|
146411
|
+
yield indentedListItem(depth, formatHeader(keyedEntries.length, {
|
|
146412
|
+
key: firstKey,
|
|
146413
|
+
fields: keyedFields,
|
|
146414
|
+
delimiter: options.delimiter,
|
|
146415
|
+
keyed: true
|
|
146416
|
+
}), options.indentSize);
|
|
146417
|
+
yield* encodeKeyedEntryRowsLines(keyedEntries, keyedFields, depth + 2, options);
|
|
146245
146418
|
if (restEntries.length > 0) yield* encodeObjectLines(Object.fromEntries(restEntries), depth + 1, options);
|
|
146246
146419
|
return;
|
|
146247
146420
|
}
|
|
146248
146421
|
}
|
|
146249
146422
|
const encodedKey = encodeKey(firstKey);
|
|
146250
|
-
if (
|
|
146251
|
-
else if (isJsonArray(firstValue)) if (firstValue.length === 0) yield indentedListItem(depth, `${encodedKey}: []`, options.
|
|
146252
|
-
else if (isArrayOfPrimitives(firstValue)) yield indentedListItem(depth, `${encodedKey}${encodeInlineArrayLine(firstValue, options.delimiter)}`, options.
|
|
146423
|
+
if (isEncodablePrimitive(firstValue)) yield indentedListItem(depth, `${encodedKey}: ${encodePrimitive(firstValue, options.delimiter)}`, options.indentSize);
|
|
146424
|
+
else if (isJsonArray(firstValue)) if (firstValue.length === 0) yield indentedListItem(depth, `${encodedKey}: []`, options.indentSize);
|
|
146425
|
+
else if (isArrayOfPrimitives(firstValue)) yield indentedListItem(depth, `${encodedKey}${encodeInlineArrayLine(firstValue, options.delimiter)}`, options.indentSize);
|
|
146253
146426
|
else {
|
|
146254
|
-
yield indentedListItem(depth, `${encodedKey}${formatHeader(firstValue.length, { delimiter: options.delimiter })}`, options.
|
|
146427
|
+
yield indentedListItem(depth, `${encodedKey}${formatHeader(firstValue.length, { delimiter: options.delimiter })}`, options.indentSize);
|
|
146255
146428
|
for (const item of firstValue) yield* encodeListItemValueLines(item, depth + 2, options);
|
|
146256
146429
|
}
|
|
146257
146430
|
else if (isJsonObject(firstValue)) {
|
|
146258
|
-
yield indentedListItem(depth, `${encodedKey}:`, options.
|
|
146431
|
+
yield indentedListItem(depth, `${encodedKey}:`, options.indentSize);
|
|
146259
146432
|
if (!isEmptyObject(firstValue)) yield* encodeObjectLines(firstValue, depth + 2, options);
|
|
146260
146433
|
}
|
|
146261
146434
|
if (restEntries.length > 0) yield* encodeObjectLines(Object.fromEntries(restEntries), depth + 1, options);
|
|
146262
146435
|
}
|
|
146263
146436
|
function* encodeListItemValueLines(value, depth, options) {
|
|
146264
|
-
if (
|
|
146265
|
-
else if (isJsonArray(value)) if (isArrayOfPrimitives(value)) yield indentedListItem(depth, encodeInlineArrayLine(value, options.delimiter), options.
|
|
146437
|
+
if (isEncodablePrimitive(value)) yield indentedListItem(depth, encodePrimitive(value, options.delimiter), options.indentSize);
|
|
146438
|
+
else if (isJsonArray(value)) if (isArrayOfPrimitives(value)) yield indentedListItem(depth, encodeInlineArrayLine(value, options.delimiter), options.indentSize);
|
|
146266
146439
|
else {
|
|
146267
|
-
yield indentedListItem(depth, formatHeader(value.length, { delimiter: options.delimiter }), options.
|
|
146440
|
+
yield indentedListItem(depth, formatHeader(value.length, { delimiter: options.delimiter }), options.indentSize);
|
|
146268
146441
|
for (const item of value) yield* encodeListItemValueLines(item, depth + 1, options);
|
|
146269
146442
|
}
|
|
146270
146443
|
else if (isJsonObject(value)) yield* encodeObjectAsListItemLines(value, depth, options);
|
|
@@ -146278,7 +146451,11 @@ function indentedListItem(depth, content, indentSize) {
|
|
|
146278
146451
|
function applyReplacer(root2, replacer) {
|
|
146279
146452
|
const replacedRoot = replacer("", root2, []);
|
|
146280
146453
|
if (replacedRoot === void 0) return transformChildren(root2, replacer, []);
|
|
146281
|
-
return
|
|
146454
|
+
return transformReplaced(root2, replacedRoot, replacer, []);
|
|
146455
|
+
}
|
|
146456
|
+
function transformReplaced(original, replaced, replacer, path) {
|
|
146457
|
+
if (isRawString(replaced) && !isEncodablePrimitive(original)) return transformChildren(original, replacer, path);
|
|
146458
|
+
return transformChildren(normalizeValue(replaced), replacer, path);
|
|
146282
146459
|
}
|
|
146283
146460
|
function transformChildren(value, replacer, path) {
|
|
146284
146461
|
if (isJsonObject(value)) return transformObject(value, replacer, path);
|
|
@@ -146291,7 +146468,7 @@ function transformObject(obj, replacer, path) {
|
|
|
146291
146468
|
const childPath = [...path, key3];
|
|
146292
146469
|
const replacedValue = replacer(key3, value, childPath);
|
|
146293
146470
|
if (replacedValue === void 0) continue;
|
|
146294
|
-
setOwnProperty(result3, key3,
|
|
146471
|
+
setOwnProperty(result3, key3, transformReplaced(value, replacedValue, replacer, childPath));
|
|
146295
146472
|
}
|
|
146296
146473
|
return result3;
|
|
146297
146474
|
}
|
|
@@ -146302,8 +146479,7 @@ function transformArray(arr, replacer, path) {
|
|
|
146302
146479
|
const childPath = [...path, i2];
|
|
146303
146480
|
const replacedValue = replacer(String(i2), value, childPath);
|
|
146304
146481
|
if (replacedValue === void 0) continue;
|
|
146305
|
-
|
|
146306
|
-
result3.push(transformChildren(normalizedValue, replacer, childPath));
|
|
146482
|
+
result3.push(transformReplaced(value, replacedValue, replacer, childPath));
|
|
146307
146483
|
}
|
|
146308
146484
|
return result3;
|
|
146309
146485
|
}
|
|
@@ -146316,11 +146492,11 @@ function encodeLines(input, options) {
|
|
|
146316
146492
|
return encodeJsonValue(resolvedOptions.replacer ? applyReplacer(normalizedValue, resolvedOptions.replacer) : normalizedValue, resolvedOptions, 0);
|
|
146317
146493
|
}
|
|
146318
146494
|
function resolveOptions(options) {
|
|
146495
|
+
const delimiter3 = options?.delimiter ?? DEFAULT_DELIMITER;
|
|
146496
|
+
assertValidDelimiter(delimiter3);
|
|
146319
146497
|
return {
|
|
146320
|
-
|
|
146321
|
-
delimiter:
|
|
146322
|
-
keyFolding: options?.keyFolding ?? "off",
|
|
146323
|
-
flattenDepth: options?.flattenDepth ?? Number.POSITIVE_INFINITY,
|
|
146498
|
+
indentSize: options?.indentSize ?? options?.indent ?? 2,
|
|
146499
|
+
delimiter: delimiter3,
|
|
146324
146500
|
replacer: options?.replacer
|
|
146325
146501
|
};
|
|
146326
146502
|
}
|
|
@@ -147431,14 +147607,14 @@ async function startMcpOauth(client3, login) {
|
|
|
147431
147607
|
return { loginId, authorizationUrl: first };
|
|
147432
147608
|
}
|
|
147433
147609
|
async function completeMcpOauth(client3, loginId, callbackUrl) {
|
|
147434
|
-
const
|
|
147435
|
-
if (!
|
|
147610
|
+
const pending4 = pendingMcpOauth.get(loginId);
|
|
147611
|
+
if (!pending4 || pending4.clientSessionId !== client3.clientSessionId) {
|
|
147436
147612
|
throw Object.assign(new Error("MCP sign-in not found"), { code: "not_found" });
|
|
147437
147613
|
}
|
|
147438
147614
|
if (callbackUrl) {
|
|
147439
147615
|
let callback;
|
|
147440
147616
|
try {
|
|
147441
|
-
callback = validateLoopbackOAuthCallback(
|
|
147617
|
+
callback = validateLoopbackOAuthCallback(pending4.authorizationUrl, callbackUrl);
|
|
147442
147618
|
} catch (err) {
|
|
147443
147619
|
invalid10(err.message);
|
|
147444
147620
|
}
|
|
@@ -147446,7 +147622,7 @@ async function completeMcpOauth(client3, loginId, callbackUrl) {
|
|
|
147446
147622
|
await response.body?.cancel();
|
|
147447
147623
|
}
|
|
147448
147624
|
try {
|
|
147449
|
-
return await
|
|
147625
|
+
return await pending4.result;
|
|
147450
147626
|
} finally {
|
|
147451
147627
|
pendingMcpOauth.delete(loginId);
|
|
147452
147628
|
}
|
|
@@ -147943,8 +148119,8 @@ function claudeCatalogFor(ctx, apiProviderId, cwd) {
|
|
|
147943
148119
|
if (ctx.probeModels) return null;
|
|
147944
148120
|
if (ctx.probeClaudeCatalog) {
|
|
147945
148121
|
const probe = ctx.probeClaudeCatalog;
|
|
147946
|
-
let
|
|
147947
|
-
return () =>
|
|
148122
|
+
let pending5 = null;
|
|
148123
|
+
return () => pending5 ??= probe(cwd);
|
|
147948
148124
|
}
|
|
147949
148125
|
const binaryPath = resolveClaudeBinaryPath({ harnesses: ctx.harnesses });
|
|
147950
148126
|
if (!binaryPath) {
|
|
@@ -147953,8 +148129,8 @@ function claudeCatalogFor(ctx, apiProviderId, cwd) {
|
|
|
147953
148129
|
);
|
|
147954
148130
|
return async () => EMPTY_CLAUDE_CATALOG;
|
|
147955
148131
|
}
|
|
147956
|
-
let
|
|
147957
|
-
return () =>
|
|
148132
|
+
let pending4 = null;
|
|
148133
|
+
return () => pending4 ??= getNodeClaudeCatalog({
|
|
147958
148134
|
cwd,
|
|
147959
148135
|
binaryPath,
|
|
147960
148136
|
env: claudeAccountProbeEnv(apiProviderId),
|
|
@@ -152433,7 +152609,7 @@ function suggestedTaskToolResult(raw2) {
|
|
|
152433
152609
|
|
|
152434
152610
|
// src/session/suggested-task.ts
|
|
152435
152611
|
var exec = promisify2(execFile6);
|
|
152436
|
-
function
|
|
152612
|
+
function pending3(ctx, sessionId, taskId) {
|
|
152437
152613
|
const parent = ctx.deps.sessions.get(sessionId);
|
|
152438
152614
|
if (!parent || parent.closed) throw new CollaborationError("This session is no longer available.", "not_found");
|
|
152439
152615
|
const found = findSuggestedTask(ctx.deps.sessions.messages(sessionId), taskId);
|
|
@@ -152448,7 +152624,7 @@ function suggestTask(ctx, sessionId, args) {
|
|
|
152448
152624
|
return suggestedTaskToolResult(args);
|
|
152449
152625
|
}
|
|
152450
152626
|
async function suggestedTaskOptions(ctx, sessionId, taskId) {
|
|
152451
|
-
const { parent } =
|
|
152627
|
+
const { parent } = pending3(ctx, sessionId, taskId);
|
|
152452
152628
|
const profiles = ctx.listProfiles();
|
|
152453
152629
|
if (profiles.some((profile2) => profile2.harnessId === "claude")) {
|
|
152454
152630
|
const { getNodeClaudeModelCatalog: getNodeClaudeModelCatalog2 } = await Promise.resolve().then(() => (init_claude_model_catalog(), claude_model_catalog_exports));
|
|
@@ -152483,7 +152659,7 @@ async function taskLocation(ctx, projectId, cwd, input, taskId, assertControl2)
|
|
|
152483
152659
|
}
|
|
152484
152660
|
async function launchNodeSuggestedTask(ctx, sessionId, taskId, choice, assertControl2, controllerClientSessionId) {
|
|
152485
152661
|
assertControl2();
|
|
152486
|
-
const { parent, input } =
|
|
152662
|
+
const { parent, input } = pending3(ctx, sessionId, taskId);
|
|
152487
152663
|
const launchId = `suggested-task-${taskId}`;
|
|
152488
152664
|
if (!ctx.store.grantForLaunch(sessionId, launchId)?.started_at) {
|
|
152489
152665
|
const { profiles, initial } = await suggestedTaskOptions(ctx, sessionId, taskId);
|
|
@@ -166839,6 +167015,7 @@ function withSessionZone(runner, syncRoot) {
|
|
|
166839
167015
|
wrapped.disposeSession = runner.disposeSession;
|
|
166840
167016
|
wrapped.disposeAll = runner.disposeAll;
|
|
166841
167017
|
wrapped.listActiveRuntimes = runner.listActiveRuntimes;
|
|
167018
|
+
wrapped.codexVoice = runner.codexVoice;
|
|
166842
167019
|
return wrapped;
|
|
166843
167020
|
}
|
|
166844
167021
|
|