@super-one/cli 0.50.8-alpha → 0.51.1-alpha
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 +1201 -420
- package/package.json +1 -1
package/lib/cli.mjs
CHANGED
|
@@ -3485,6 +3485,31 @@ var init_session_messages = __esm({
|
|
|
3485
3485
|
}
|
|
3486
3486
|
});
|
|
3487
3487
|
|
|
3488
|
+
// ../../packages/shared/src/environment/provider-resume.ts
|
|
3489
|
+
function providerSessionIdFromResume(providerResume) {
|
|
3490
|
+
const raw = typeof providerResume === "string" ? providerResume.trim() : "";
|
|
3491
|
+
if (!raw) return null;
|
|
3492
|
+
for (const prefix of RESUME_PREFIXES) {
|
|
3493
|
+
if (raw.startsWith(prefix)) {
|
|
3494
|
+
const id = raw.slice(prefix.length).trim();
|
|
3495
|
+
return id.length > 0 ? id : null;
|
|
3496
|
+
}
|
|
3497
|
+
}
|
|
3498
|
+
return raw;
|
|
3499
|
+
}
|
|
3500
|
+
var RESUME_PREFIXES;
|
|
3501
|
+
var init_provider_resume = __esm({
|
|
3502
|
+
"../../packages/shared/src/environment/provider-resume.ts"() {
|
|
3503
|
+
"use strict";
|
|
3504
|
+
RESUME_PREFIXES = [
|
|
3505
|
+
"claude-session:",
|
|
3506
|
+
"thread:",
|
|
3507
|
+
"acp-session:",
|
|
3508
|
+
"opencode:"
|
|
3509
|
+
];
|
|
3510
|
+
}
|
|
3511
|
+
});
|
|
3512
|
+
|
|
3488
3513
|
// ../../packages/shared/src/environment/lease.ts
|
|
3489
3514
|
var init_lease = __esm({
|
|
3490
3515
|
"../../packages/shared/src/environment/lease.ts"() {
|
|
@@ -3590,6 +3615,7 @@ var init_environment = __esm({
|
|
|
3590
3615
|
init_events();
|
|
3591
3616
|
init_session_events();
|
|
3592
3617
|
init_session_messages();
|
|
3618
|
+
init_provider_resume();
|
|
3593
3619
|
init_lease();
|
|
3594
3620
|
init_gateway();
|
|
3595
3621
|
init_connection_supervisor_core();
|
|
@@ -10612,7 +10638,145 @@ var init_src2 = __esm({
|
|
|
10612
10638
|
}
|
|
10613
10639
|
});
|
|
10614
10640
|
|
|
10615
|
-
// ../../packages/
|
|
10641
|
+
// ../../packages/shared/src/content-delta.ts
|
|
10642
|
+
function parseInputObject(input) {
|
|
10643
|
+
if (input == null || input === "") return {};
|
|
10644
|
+
if (typeof input === "object" && !Array.isArray(input)) {
|
|
10645
|
+
return input;
|
|
10646
|
+
}
|
|
10647
|
+
if (typeof input !== "string" || !input.trim()) return {};
|
|
10648
|
+
try {
|
|
10649
|
+
const parsed = JSON.parse(input);
|
|
10650
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
10651
|
+
} catch {
|
|
10652
|
+
return {};
|
|
10653
|
+
}
|
|
10654
|
+
}
|
|
10655
|
+
function mergeToolUseInputJson(existing, incoming) {
|
|
10656
|
+
const prev = parseInputObject(existing);
|
|
10657
|
+
const next = parseInputObject(incoming);
|
|
10658
|
+
const asString7 = typeof existing === "string" || typeof incoming === "string";
|
|
10659
|
+
if (Object.keys(next).length === 0) {
|
|
10660
|
+
if (existing != null && existing !== "") return existing;
|
|
10661
|
+
return asString7 ? typeof incoming === "string" ? incoming : "{}" : incoming ?? {};
|
|
10662
|
+
}
|
|
10663
|
+
if (Object.keys(prev).length === 0) {
|
|
10664
|
+
return asString7 ? typeof incoming === "string" ? incoming : JSON.stringify(next) : next;
|
|
10665
|
+
}
|
|
10666
|
+
const merged = { ...prev, ...next };
|
|
10667
|
+
for (const key of SUMMARY_INPUT_KEYS) {
|
|
10668
|
+
const n = merged[key];
|
|
10669
|
+
const empty = n == null || n === "";
|
|
10670
|
+
if (empty && prev[key] != null && prev[key] !== "") {
|
|
10671
|
+
merged[key] = prev[key];
|
|
10672
|
+
}
|
|
10673
|
+
}
|
|
10674
|
+
if (!asString7) return merged;
|
|
10675
|
+
try {
|
|
10676
|
+
return JSON.stringify(merged);
|
|
10677
|
+
} catch {
|
|
10678
|
+
return typeof incoming === "string" ? incoming : "{}";
|
|
10679
|
+
}
|
|
10680
|
+
}
|
|
10681
|
+
function pickRicherToolSummary(existing, incoming, mergedInput) {
|
|
10682
|
+
const input = parseInputObject(mergedInput);
|
|
10683
|
+
for (const key of ["query", "pattern", "command", "description"]) {
|
|
10684
|
+
const v2 = input[key];
|
|
10685
|
+
if (typeof v2 === "string" && v2.trim()) return v2.trim();
|
|
10686
|
+
}
|
|
10687
|
+
const a = existing?.trim() || "";
|
|
10688
|
+
const b2 = incoming?.trim() || "";
|
|
10689
|
+
const placeholders = /* @__PURE__ */ new Set(["Web search:", "web_search", "grep", "Grep", "Search"]);
|
|
10690
|
+
if (b2 && !placeholders.has(b2)) return b2;
|
|
10691
|
+
if (a && !placeholders.has(a)) return a;
|
|
10692
|
+
return b2 || a || void 0;
|
|
10693
|
+
}
|
|
10694
|
+
function sameParent(a, b2) {
|
|
10695
|
+
const ap = "parentToolUseId" in a ? a.parentToolUseId ?? null : null;
|
|
10696
|
+
const bp = "parentToolUseId" in b2 ? b2.parentToolUseId ?? null : null;
|
|
10697
|
+
return ap === bp;
|
|
10698
|
+
}
|
|
10699
|
+
function lastMergeTargetIndex(content, delta) {
|
|
10700
|
+
for (let i = content.length - 1; i >= 0; i--) {
|
|
10701
|
+
const b2 = content[i];
|
|
10702
|
+
if (!sameParent(b2, delta)) continue;
|
|
10703
|
+
if (b2.type === "tool_result") continue;
|
|
10704
|
+
return i;
|
|
10705
|
+
}
|
|
10706
|
+
return -1;
|
|
10707
|
+
}
|
|
10708
|
+
function applyContentDelta(content, delta) {
|
|
10709
|
+
if (delta.type === "text") {
|
|
10710
|
+
const idx = lastMergeTargetIndex(content, delta);
|
|
10711
|
+
const target = idx === -1 ? void 0 : content[idx];
|
|
10712
|
+
if (target?.type === "text") {
|
|
10713
|
+
return content.map((b2, i) => i === idx ? { ...target, text: target.text + delta.text } : b2);
|
|
10714
|
+
}
|
|
10715
|
+
}
|
|
10716
|
+
if (delta.type === "thinking") {
|
|
10717
|
+
const idx = lastMergeTargetIndex(content, delta);
|
|
10718
|
+
const target = idx === -1 ? void 0 : content[idx];
|
|
10719
|
+
if (target?.type === "thinking") {
|
|
10720
|
+
return content.map((b2, i) => i === idx ? { ...target, thinking: target.thinking + delta.thinking, endedAt: delta.endedAt ?? target.endedAt } : b2);
|
|
10721
|
+
}
|
|
10722
|
+
}
|
|
10723
|
+
if (delta.type === "tool_use") {
|
|
10724
|
+
const idx = content.findIndex((b2) => b2.type === "tool_use" && b2.toolUseId === delta.toolUseId);
|
|
10725
|
+
if (idx !== -1) {
|
|
10726
|
+
const existing = content[idx];
|
|
10727
|
+
if (existing.type !== "tool_use") {
|
|
10728
|
+
return content.map((b2, i) => i === idx ? { ...delta, startedAt: Date.now() } : b2);
|
|
10729
|
+
}
|
|
10730
|
+
const mergedInput = mergeToolUseInputJson(existing.input, delta.input);
|
|
10731
|
+
const mergedSummary = pickRicherToolSummary(
|
|
10732
|
+
existing.toolSummary,
|
|
10733
|
+
delta.toolSummary,
|
|
10734
|
+
mergedInput
|
|
10735
|
+
);
|
|
10736
|
+
return content.map((b2, i) => i === idx ? {
|
|
10737
|
+
...existing,
|
|
10738
|
+
...delta,
|
|
10739
|
+
startedAt: existing.startedAt,
|
|
10740
|
+
elapsedSeconds: delta.elapsedSeconds ?? existing.elapsedSeconds,
|
|
10741
|
+
status: delta.status ?? existing.status,
|
|
10742
|
+
// ContentBlock.input is typed as string; object form is test/legacy only.
|
|
10743
|
+
input: mergedInput,
|
|
10744
|
+
toolSummary: mergedSummary,
|
|
10745
|
+
toolFilePath: delta.toolFilePath || existing.toolFilePath
|
|
10746
|
+
} : b2);
|
|
10747
|
+
}
|
|
10748
|
+
return [...content, { ...delta, startedAt: Date.now() }];
|
|
10749
|
+
}
|
|
10750
|
+
if (delta.type === "tool_result") {
|
|
10751
|
+
const updated = content.map(
|
|
10752
|
+
(b2) => b2.type === "tool_use" && b2.toolUseId === delta.toolUseId ? { ...b2, status: "complete" } : b2
|
|
10753
|
+
);
|
|
10754
|
+
return [...updated, delta];
|
|
10755
|
+
}
|
|
10756
|
+
return [...content, delta];
|
|
10757
|
+
}
|
|
10758
|
+
var SUMMARY_INPUT_KEYS;
|
|
10759
|
+
var init_content_delta = __esm({
|
|
10760
|
+
"../../packages/shared/src/content-delta.ts"() {
|
|
10761
|
+
"use strict";
|
|
10762
|
+
SUMMARY_INPUT_KEYS = [
|
|
10763
|
+
"query",
|
|
10764
|
+
"pattern",
|
|
10765
|
+
"command",
|
|
10766
|
+
"description",
|
|
10767
|
+
"file_path",
|
|
10768
|
+
"path",
|
|
10769
|
+
"url",
|
|
10770
|
+
"prompt",
|
|
10771
|
+
"skill",
|
|
10772
|
+
"tool_name",
|
|
10773
|
+
"subject",
|
|
10774
|
+
"task_id"
|
|
10775
|
+
];
|
|
10776
|
+
}
|
|
10777
|
+
});
|
|
10778
|
+
|
|
10779
|
+
// ../../packages/shared/src/node-session-event-map.ts
|
|
10616
10780
|
function asRecord5(value) {
|
|
10617
10781
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
10618
10782
|
return value;
|
|
@@ -10622,6 +10786,461 @@ function asRecord5(value) {
|
|
|
10622
10786
|
function asString2(value) {
|
|
10623
10787
|
return typeof value === "string" ? value : void 0;
|
|
10624
10788
|
}
|
|
10789
|
+
function asBool(value) {
|
|
10790
|
+
return typeof value === "boolean" ? value : void 0;
|
|
10791
|
+
}
|
|
10792
|
+
function coerceToolInput(value) {
|
|
10793
|
+
if (typeof value === "string") return value;
|
|
10794
|
+
if (value == null) return "";
|
|
10795
|
+
try {
|
|
10796
|
+
return JSON.stringify(value);
|
|
10797
|
+
} catch {
|
|
10798
|
+
return "";
|
|
10799
|
+
}
|
|
10800
|
+
}
|
|
10801
|
+
function stamp(event, ctx, sequence) {
|
|
10802
|
+
const seqNum = sequence && /^\d+$/.test(sequence) ? Number(sequence) : void 0;
|
|
10803
|
+
return {
|
|
10804
|
+
...event,
|
|
10805
|
+
...ctx.projectPath ? { projectPath: ctx.projectPath } : {},
|
|
10806
|
+
sessionId: ctx.sessionId,
|
|
10807
|
+
...seqNum !== void 0 && Number.isFinite(seqNum) ? { seq: seqNum } : {}
|
|
10808
|
+
};
|
|
10809
|
+
}
|
|
10810
|
+
function mapQuestionRequest(payload, fallbackId) {
|
|
10811
|
+
const interactionId = asString2(payload.interactionId) ?? asString2(payload.requestId) ?? fallbackId;
|
|
10812
|
+
const input = asRecord5(payload.input);
|
|
10813
|
+
const rawQuestions = Array.isArray(payload.questions) ? payload.questions : Array.isArray(input.questions) ? input.questions : [];
|
|
10814
|
+
const questions = [];
|
|
10815
|
+
for (const q of rawQuestions) {
|
|
10816
|
+
if (!q || typeof q !== "object") continue;
|
|
10817
|
+
const row = q;
|
|
10818
|
+
const question = asString2(row.question) ?? asString2(row.header) ?? "";
|
|
10819
|
+
if (!question) continue;
|
|
10820
|
+
const optionsRaw = Array.isArray(row.options) ? row.options : [];
|
|
10821
|
+
const options = optionsRaw.map((opt) => {
|
|
10822
|
+
if (!opt || typeof opt !== "object") return null;
|
|
10823
|
+
const o = opt;
|
|
10824
|
+
const label = asString2(o.label) ?? asString2(o.value) ?? "";
|
|
10825
|
+
if (!label) return null;
|
|
10826
|
+
return {
|
|
10827
|
+
label,
|
|
10828
|
+
description: asString2(o.description) ?? "",
|
|
10829
|
+
...asString2(o.preview) ? { preview: asString2(o.preview) } : {}
|
|
10830
|
+
};
|
|
10831
|
+
}).filter((o) => o != null);
|
|
10832
|
+
questions.push({
|
|
10833
|
+
question,
|
|
10834
|
+
header: asString2(row.header) ?? question,
|
|
10835
|
+
options,
|
|
10836
|
+
multiSelect: row.multiSelect === true || row.multiple === true
|
|
10837
|
+
});
|
|
10838
|
+
}
|
|
10839
|
+
if (questions.length === 0) {
|
|
10840
|
+
questions.push({
|
|
10841
|
+
question: asString2(payload.toolName) ? `Respond to ${asString2(payload.toolName)}` : "Continue?",
|
|
10842
|
+
header: "Question",
|
|
10843
|
+
options: [{ label: "Yes", description: "" }, { label: "No", description: "" }],
|
|
10844
|
+
multiSelect: false
|
|
10845
|
+
});
|
|
10846
|
+
}
|
|
10847
|
+
return { requestId: interactionId, questions };
|
|
10848
|
+
}
|
|
10849
|
+
function mapPlanRequest(payload, fallbackId) {
|
|
10850
|
+
const interactionId = asString2(payload.interactionId) ?? asString2(payload.requestId) ?? fallbackId;
|
|
10851
|
+
const input = asRecord5(payload.input);
|
|
10852
|
+
let planContent = asString2(payload.plan) ?? asString2(payload.planContent) ?? asString2(input.plan) ?? asString2(input.planContent) ?? "";
|
|
10853
|
+
if (!planContent && input.plan && typeof input.plan === "object") {
|
|
10854
|
+
try {
|
|
10855
|
+
planContent = JSON.stringify(input.plan);
|
|
10856
|
+
} catch {
|
|
10857
|
+
planContent = "";
|
|
10858
|
+
}
|
|
10859
|
+
}
|
|
10860
|
+
return {
|
|
10861
|
+
requestId: interactionId,
|
|
10862
|
+
planContent: planContent || "Plan approval required",
|
|
10863
|
+
planFilePath: asString2(payload.planFilePath) ?? asString2(input.planFilePath) ?? "",
|
|
10864
|
+
allowedPrompts: Array.isArray(payload.allowedPrompts) ? payload.allowedPrompts : Array.isArray(input.allowedPrompts) ? input.allowedPrompts : []
|
|
10865
|
+
};
|
|
10866
|
+
}
|
|
10867
|
+
function userMessage(ctx, blockId, text, nowIso) {
|
|
10868
|
+
return {
|
|
10869
|
+
id: blockId,
|
|
10870
|
+
role: "user",
|
|
10871
|
+
status: "complete",
|
|
10872
|
+
content: text ? [{ type: "text", text }] : [],
|
|
10873
|
+
createdAt: nowIso,
|
|
10874
|
+
providerId: ctx.providerId ?? "codex"
|
|
10875
|
+
};
|
|
10876
|
+
}
|
|
10877
|
+
function assistantMessage(ctx, blockId, nowIso) {
|
|
10878
|
+
return {
|
|
10879
|
+
id: blockId,
|
|
10880
|
+
role: "assistant",
|
|
10881
|
+
status: "streaming",
|
|
10882
|
+
content: [],
|
|
10883
|
+
createdAt: nowIso,
|
|
10884
|
+
providerId: ctx.providerId ?? "codex"
|
|
10885
|
+
};
|
|
10886
|
+
}
|
|
10887
|
+
function mapAgentStatus(status, fallback) {
|
|
10888
|
+
if (status === "streaming" || status === "idle" || status === "error" || status === "background") {
|
|
10889
|
+
return status;
|
|
10890
|
+
}
|
|
10891
|
+
if (status === "interrupted" || status === "ended" || status === "unknown") return "idle";
|
|
10892
|
+
return fallback;
|
|
10893
|
+
}
|
|
10894
|
+
function createNodeSessionEventMapper(ctx) {
|
|
10895
|
+
const startedAssistantIds = /* @__PURE__ */ new Set();
|
|
10896
|
+
const completedAssistantIds = /* @__PURE__ */ new Set();
|
|
10897
|
+
let lastAssistantId = null;
|
|
10898
|
+
let rawTerminalThisTurn = false;
|
|
10899
|
+
const nowIso = ctx.nowIso ?? (() => (/* @__PURE__ */ new Date()).toISOString());
|
|
10900
|
+
const ensureAssistant = (push, preferredId) => {
|
|
10901
|
+
if (lastAssistantId) return lastAssistantId;
|
|
10902
|
+
const id = preferredId && preferredId.length > 0 ? preferredId : `assistant-${ctx.sessionId}`;
|
|
10903
|
+
if (!startedAssistantIds.has(id)) {
|
|
10904
|
+
startedAssistantIds.add(id);
|
|
10905
|
+
push({
|
|
10906
|
+
type: "message_start",
|
|
10907
|
+
message: assistantMessage(ctx, id, nowIso())
|
|
10908
|
+
});
|
|
10909
|
+
}
|
|
10910
|
+
lastAssistantId = id;
|
|
10911
|
+
return id;
|
|
10912
|
+
};
|
|
10913
|
+
const mapOne = (envelope) => {
|
|
10914
|
+
if (envelope.aggregateType && envelope.aggregateType !== "session") return [];
|
|
10915
|
+
if (envelope.aggregateId && envelope.aggregateId !== ctx.sessionId) return [];
|
|
10916
|
+
const eventType = envelope.eventType;
|
|
10917
|
+
const payload = asRecord5(envelope.payload);
|
|
10918
|
+
const out = [];
|
|
10919
|
+
const push = (event) => {
|
|
10920
|
+
out.push(stamp(event, ctx, envelope.sequence));
|
|
10921
|
+
};
|
|
10922
|
+
switch (eventType) {
|
|
10923
|
+
case SESSION_DURABLE_EVENT.userMessage: {
|
|
10924
|
+
if (ctx.skipUserMessage) break;
|
|
10925
|
+
const blockId = asString2(payload.blockId) ?? `user-${envelope.eventId}`;
|
|
10926
|
+
const text = asString2(payload.text) ?? "";
|
|
10927
|
+
push({
|
|
10928
|
+
type: "user_message_appended",
|
|
10929
|
+
message: userMessage(ctx, blockId, text, nowIso())
|
|
10930
|
+
});
|
|
10931
|
+
break;
|
|
10932
|
+
}
|
|
10933
|
+
case SESSION_DURABLE_EVENT.turnStarted: {
|
|
10934
|
+
lastAssistantId = null;
|
|
10935
|
+
rawTerminalThisTurn = false;
|
|
10936
|
+
push({
|
|
10937
|
+
type: "status_change",
|
|
10938
|
+
status: mapAgentStatus(asString2(payload.status), "streaming")
|
|
10939
|
+
});
|
|
10940
|
+
break;
|
|
10941
|
+
}
|
|
10942
|
+
case SESSION_DURABLE_EVENT.agentEvent: {
|
|
10943
|
+
const rawEvent = asRecord5(payload.event);
|
|
10944
|
+
const type = asString2(rawEvent.type);
|
|
10945
|
+
if (!type) break;
|
|
10946
|
+
const eventRecord = { ...rawEvent };
|
|
10947
|
+
delete eventRecord.projectPath;
|
|
10948
|
+
delete eventRecord.sessionId;
|
|
10949
|
+
delete eventRecord.draftSessionId;
|
|
10950
|
+
delete eventRecord.seq;
|
|
10951
|
+
delete eventRecord.epoch;
|
|
10952
|
+
const event = eventRecord;
|
|
10953
|
+
const rawMessageId = type === "message_start" ? asString2(asRecord5(eventRecord.message).id) : asString2(eventRecord.messageId);
|
|
10954
|
+
if (type === "message_start" && rawMessageId) {
|
|
10955
|
+
startedAssistantIds.add(rawMessageId);
|
|
10956
|
+
lastAssistantId = rawMessageId;
|
|
10957
|
+
} else if (rawMessageId) {
|
|
10958
|
+
ensureAssistant(push, rawMessageId);
|
|
10959
|
+
}
|
|
10960
|
+
push(event);
|
|
10961
|
+
if (rawMessageId && (type === "message_complete" || type === "message_error" || type === "message_interrupted")) {
|
|
10962
|
+
completedAssistantIds.add(rawMessageId);
|
|
10963
|
+
rawTerminalThisTurn = true;
|
|
10964
|
+
}
|
|
10965
|
+
break;
|
|
10966
|
+
}
|
|
10967
|
+
case SESSION_DURABLE_EVENT.assistantDelta: {
|
|
10968
|
+
const wireBlockId = asString2(payload.blockId);
|
|
10969
|
+
const messageId = ensureAssistant(push, wireBlockId ?? `assistant-${envelope.eventId}`);
|
|
10970
|
+
const delta = asString2(payload.delta) ?? asString2(payload.text) ?? "";
|
|
10971
|
+
if (delta) {
|
|
10972
|
+
push({
|
|
10973
|
+
type: "content_delta",
|
|
10974
|
+
messageId,
|
|
10975
|
+
delta: { type: "text", text: delta }
|
|
10976
|
+
});
|
|
10977
|
+
}
|
|
10978
|
+
break;
|
|
10979
|
+
}
|
|
10980
|
+
case SESSION_DURABLE_EVENT.assistantText: {
|
|
10981
|
+
const wireBlockId = asString2(payload.blockId);
|
|
10982
|
+
const text = asString2(payload.text) ?? "";
|
|
10983
|
+
const first = lastAssistantId == null;
|
|
10984
|
+
const messageId = ensureAssistant(push, wireBlockId ?? `assistant-${envelope.eventId}`);
|
|
10985
|
+
if (first && text) {
|
|
10986
|
+
push({
|
|
10987
|
+
type: "content_delta",
|
|
10988
|
+
messageId,
|
|
10989
|
+
delta: { type: "text", text }
|
|
10990
|
+
});
|
|
10991
|
+
}
|
|
10992
|
+
break;
|
|
10993
|
+
}
|
|
10994
|
+
case SESSION_DURABLE_EVENT.assistantMessage: {
|
|
10995
|
+
const wireBlockId = asString2(payload.blockId);
|
|
10996
|
+
if (wireBlockId && completedAssistantIds.has(wireBlockId)) break;
|
|
10997
|
+
const text = asString2(payload.text);
|
|
10998
|
+
const wasOpen = lastAssistantId != null;
|
|
10999
|
+
const messageId = ensureAssistant(push, wireBlockId ?? `assistant-${envelope.eventId}`);
|
|
11000
|
+
if (!wasOpen && text) {
|
|
11001
|
+
push({
|
|
11002
|
+
type: "content_delta",
|
|
11003
|
+
messageId,
|
|
11004
|
+
delta: { type: "text", text }
|
|
11005
|
+
});
|
|
11006
|
+
}
|
|
11007
|
+
push({ type: "message_complete", messageId });
|
|
11008
|
+
break;
|
|
11009
|
+
}
|
|
11010
|
+
case SESSION_DURABLE_EVENT.toolStarted: {
|
|
11011
|
+
const toolUseId = asString2(payload.toolUseId) ?? envelope.eventId;
|
|
11012
|
+
const toolName = asString2(payload.toolName) ?? "tool";
|
|
11013
|
+
const input = coerceToolInput(payload.input);
|
|
11014
|
+
const parentToolUseId = asString2(payload.parentToolUseId) ?? null;
|
|
11015
|
+
const messageId = ensureAssistant(push, `assistant-${envelope.eventId}`);
|
|
11016
|
+
push({
|
|
11017
|
+
type: "content_delta",
|
|
11018
|
+
messageId,
|
|
11019
|
+
delta: {
|
|
11020
|
+
type: "tool_use",
|
|
11021
|
+
toolUseId,
|
|
11022
|
+
toolName,
|
|
11023
|
+
input,
|
|
11024
|
+
status: "streaming",
|
|
11025
|
+
parentToolUseId
|
|
11026
|
+
}
|
|
11027
|
+
});
|
|
11028
|
+
break;
|
|
11029
|
+
}
|
|
11030
|
+
case SESSION_DURABLE_EVENT.toolInputDelta: {
|
|
11031
|
+
const toolUseId = asString2(payload.toolUseId) ?? envelope.eventId;
|
|
11032
|
+
const partialJson = asString2(payload.inputDelta) ?? asString2(payload.partialJson) ?? (typeof payload.input === "string" ? payload.input : "");
|
|
11033
|
+
if (!partialJson) break;
|
|
11034
|
+
const messageId = ensureAssistant(push, `assistant-${envelope.eventId}`);
|
|
11035
|
+
push({
|
|
11036
|
+
type: "tool_input_delta",
|
|
11037
|
+
messageId,
|
|
11038
|
+
toolUseId,
|
|
11039
|
+
partialJson,
|
|
11040
|
+
parentToolUseId: asString2(payload.parentToolUseId) ?? null
|
|
11041
|
+
});
|
|
11042
|
+
break;
|
|
11043
|
+
}
|
|
11044
|
+
case SESSION_DURABLE_EVENT.toolCompleted:
|
|
11045
|
+
case SESSION_DURABLE_EVENT.toolFailed: {
|
|
11046
|
+
const toolUseId = asString2(payload.toolUseId) ?? envelope.eventId;
|
|
11047
|
+
const toolName = asString2(payload.toolName) ?? "tool";
|
|
11048
|
+
const output = asString2(payload.output) ?? "";
|
|
11049
|
+
const isError = eventType === SESSION_DURABLE_EVENT.toolFailed || asBool(payload.isError) === true;
|
|
11050
|
+
const messageId = ensureAssistant(push, `assistant-${envelope.eventId}`);
|
|
11051
|
+
push({
|
|
11052
|
+
type: "content_delta",
|
|
11053
|
+
messageId,
|
|
11054
|
+
delta: {
|
|
11055
|
+
type: "tool_use",
|
|
11056
|
+
toolUseId,
|
|
11057
|
+
toolName,
|
|
11058
|
+
input: coerceToolInput(payload.input),
|
|
11059
|
+
status: "complete",
|
|
11060
|
+
parentToolUseId: asString2(payload.parentToolUseId) ?? null
|
|
11061
|
+
}
|
|
11062
|
+
});
|
|
11063
|
+
push({
|
|
11064
|
+
type: "content_delta",
|
|
11065
|
+
messageId,
|
|
11066
|
+
delta: {
|
|
11067
|
+
type: "tool_result",
|
|
11068
|
+
toolUseId,
|
|
11069
|
+
summary: output || (isError ? "failed" : "done"),
|
|
11070
|
+
isError,
|
|
11071
|
+
parentToolUseId: asString2(payload.parentToolUseId) ?? null
|
|
11072
|
+
}
|
|
11073
|
+
});
|
|
11074
|
+
break;
|
|
11075
|
+
}
|
|
11076
|
+
case SESSION_DURABLE_EVENT.turnCompleted: {
|
|
11077
|
+
if (rawTerminalThisTurn) {
|
|
11078
|
+
lastAssistantId = null;
|
|
11079
|
+
rawTerminalThisTurn = false;
|
|
11080
|
+
break;
|
|
11081
|
+
}
|
|
11082
|
+
lastAssistantId = null;
|
|
11083
|
+
push({
|
|
11084
|
+
type: "status_change",
|
|
11085
|
+
status: mapAgentStatus(asString2(payload.status), "idle")
|
|
11086
|
+
});
|
|
11087
|
+
break;
|
|
11088
|
+
}
|
|
11089
|
+
case SESSION_DURABLE_EVENT.turnInterrupted: {
|
|
11090
|
+
if (rawTerminalThisTurn) {
|
|
11091
|
+
lastAssistantId = null;
|
|
11092
|
+
rawTerminalThisTurn = false;
|
|
11093
|
+
break;
|
|
11094
|
+
}
|
|
11095
|
+
if (lastAssistantId) {
|
|
11096
|
+
push({ type: "message_interrupted", messageId: lastAssistantId });
|
|
11097
|
+
}
|
|
11098
|
+
lastAssistantId = null;
|
|
11099
|
+
push({ type: "status_change", status: "idle" });
|
|
11100
|
+
break;
|
|
11101
|
+
}
|
|
11102
|
+
case SESSION_DURABLE_EVENT.turnError: {
|
|
11103
|
+
if (rawTerminalThisTurn) {
|
|
11104
|
+
lastAssistantId = null;
|
|
11105
|
+
rawTerminalThisTurn = false;
|
|
11106
|
+
break;
|
|
11107
|
+
}
|
|
11108
|
+
const message = asString2(payload.message) ?? "remote turn failed";
|
|
11109
|
+
const errorId = ensureAssistant(push);
|
|
11110
|
+
push({ type: "message_error", messageId: errorId, error: message });
|
|
11111
|
+
lastAssistantId = null;
|
|
11112
|
+
push({ type: "status_change", status: "error" });
|
|
11113
|
+
break;
|
|
11114
|
+
}
|
|
11115
|
+
case SESSION_DURABLE_EVENT.statusChanged: {
|
|
11116
|
+
push({
|
|
11117
|
+
type: "status_change",
|
|
11118
|
+
status: mapAgentStatus(asString2(payload.status), "idle")
|
|
11119
|
+
});
|
|
11120
|
+
break;
|
|
11121
|
+
}
|
|
11122
|
+
case SESSION_DURABLE_EVENT.permissionRequested: {
|
|
11123
|
+
const interactionId = asString2(payload.interactionId) ?? asString2(payload.requestId) ?? envelope.eventId;
|
|
11124
|
+
const toolName = asString2(payload.toolName) ?? "tool";
|
|
11125
|
+
const requestKind = asString2(payload.requestKind);
|
|
11126
|
+
const sessionAgentsConfirm = payload.sessionAgentsConfirm && typeof payload.sessionAgentsConfirm === "object" ? payload.sessionAgentsConfirm : void 0;
|
|
11127
|
+
const request = {
|
|
11128
|
+
requestId: interactionId,
|
|
11129
|
+
toolName,
|
|
11130
|
+
toolUseId: asString2(payload.toolUseId),
|
|
11131
|
+
input: asRecord5(payload.input),
|
|
11132
|
+
allowAlwaysAllow: requestKind === "session_agents_confirm" ? false : payload.allowAlwaysAllow !== false,
|
|
11133
|
+
...requestKind ? {
|
|
11134
|
+
requestKind
|
|
11135
|
+
} : {},
|
|
11136
|
+
...asString2(payload.serverName) ? { serverName: asString2(payload.serverName) } : {},
|
|
11137
|
+
...asString2(payload.message) ? { message: asString2(payload.message) } : {},
|
|
11138
|
+
...sessionAgentsConfirm ? { sessionAgentsConfirm } : {}
|
|
11139
|
+
};
|
|
11140
|
+
push({ type: "permission_request", request });
|
|
11141
|
+
break;
|
|
11142
|
+
}
|
|
11143
|
+
case SESSION_DURABLE_EVENT.permissionResponded:
|
|
11144
|
+
case SESSION_DURABLE_EVENT.permissionTimeout:
|
|
11145
|
+
case SESSION_DURABLE_EVENT.permissionAborted: {
|
|
11146
|
+
const interactionId = asString2(payload.interactionId) ?? asString2(payload.requestId) ?? envelope.eventId;
|
|
11147
|
+
const decision = asString2(payload.decision);
|
|
11148
|
+
const approved = decision === "allow" || decision === "allow_always";
|
|
11149
|
+
push({
|
|
11150
|
+
type: "interaction_resolved",
|
|
11151
|
+
interactionType: "permission",
|
|
11152
|
+
requestId: interactionId,
|
|
11153
|
+
approved
|
|
11154
|
+
});
|
|
11155
|
+
break;
|
|
11156
|
+
}
|
|
11157
|
+
case SESSION_DURABLE_EVENT.questionRequested: {
|
|
11158
|
+
const request = mapQuestionRequest(payload, envelope.eventId);
|
|
11159
|
+
if (request) push({ type: "ask_user_question", request });
|
|
11160
|
+
break;
|
|
11161
|
+
}
|
|
11162
|
+
case SESSION_DURABLE_EVENT.questionResponded:
|
|
11163
|
+
case SESSION_DURABLE_EVENT.questionTimeout:
|
|
11164
|
+
case SESSION_DURABLE_EVENT.questionAborted: {
|
|
11165
|
+
const interactionId = asString2(payload.interactionId) ?? asString2(payload.requestId) ?? envelope.eventId;
|
|
11166
|
+
push({
|
|
11167
|
+
type: "interaction_resolved",
|
|
11168
|
+
interactionType: "question",
|
|
11169
|
+
requestId: interactionId,
|
|
11170
|
+
approved: eventType === SESSION_DURABLE_EVENT.questionResponded
|
|
11171
|
+
});
|
|
11172
|
+
break;
|
|
11173
|
+
}
|
|
11174
|
+
case SESSION_DURABLE_EVENT.planRequested: {
|
|
11175
|
+
const request = mapPlanRequest(payload, envelope.eventId);
|
|
11176
|
+
if (request) push({ type: "plan_approval", request });
|
|
11177
|
+
break;
|
|
11178
|
+
}
|
|
11179
|
+
case SESSION_DURABLE_EVENT.planResponded:
|
|
11180
|
+
case SESSION_DURABLE_EVENT.planTimeout:
|
|
11181
|
+
case SESSION_DURABLE_EVENT.planAborted: {
|
|
11182
|
+
const interactionId = asString2(payload.interactionId) ?? asString2(payload.requestId) ?? envelope.eventId;
|
|
11183
|
+
const decision = asString2(payload.decision);
|
|
11184
|
+
const approved = decision === "approve" || decision === "approved";
|
|
11185
|
+
push({
|
|
11186
|
+
type: "interaction_resolved",
|
|
11187
|
+
interactionType: "plan_approval",
|
|
11188
|
+
requestId: interactionId,
|
|
11189
|
+
approved,
|
|
11190
|
+
...asString2(payload.feedback) ? { feedback: asString2(payload.feedback) } : {}
|
|
11191
|
+
});
|
|
11192
|
+
break;
|
|
11193
|
+
}
|
|
11194
|
+
case SESSION_DURABLE_EVENT.renamed: {
|
|
11195
|
+
const title = asString2(payload.title);
|
|
11196
|
+
if (title != null) {
|
|
11197
|
+
const sourceRaw = asString2(payload.source);
|
|
11198
|
+
const source = sourceRaw === "agent" || sourceRaw === "user" ? sourceRaw : "user";
|
|
11199
|
+
push({
|
|
11200
|
+
type: "session_title_changed",
|
|
11201
|
+
sessionId: ctx.sessionId,
|
|
11202
|
+
title,
|
|
11203
|
+
source
|
|
11204
|
+
});
|
|
11205
|
+
}
|
|
11206
|
+
break;
|
|
11207
|
+
}
|
|
11208
|
+
case SESSION_DURABLE_EVENT.closed:
|
|
11209
|
+
case SESSION_DURABLE_EVENT.removed: {
|
|
11210
|
+
push({ type: "status_change", status: "idle" });
|
|
11211
|
+
break;
|
|
11212
|
+
}
|
|
11213
|
+
case SESSION_DURABLE_EVENT.created:
|
|
11214
|
+
case SESSION_DURABLE_EVENT.reconciled:
|
|
11215
|
+
case SESSION_DURABLE_EVENT.uiFlags:
|
|
11216
|
+
break;
|
|
11217
|
+
default:
|
|
11218
|
+
break;
|
|
11219
|
+
}
|
|
11220
|
+
return out;
|
|
11221
|
+
};
|
|
11222
|
+
return {
|
|
11223
|
+
map: mapOne,
|
|
11224
|
+
currentAssistantMessageId: () => lastAssistantId
|
|
11225
|
+
};
|
|
11226
|
+
}
|
|
11227
|
+
var init_node_session_event_map = __esm({
|
|
11228
|
+
"../../packages/shared/src/node-session-event-map.ts"() {
|
|
11229
|
+
"use strict";
|
|
11230
|
+
init_session_events();
|
|
11231
|
+
}
|
|
11232
|
+
});
|
|
11233
|
+
|
|
11234
|
+
// ../../packages/runtime/src/session/message-catalog.ts
|
|
11235
|
+
function asRecord6(value) {
|
|
11236
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
11237
|
+
return value;
|
|
11238
|
+
}
|
|
11239
|
+
return {};
|
|
11240
|
+
}
|
|
11241
|
+
function asString3(value) {
|
|
11242
|
+
return typeof value === "string" ? value : void 0;
|
|
11243
|
+
}
|
|
10625
11244
|
function truncate(text, max = SUMMARY_MAX) {
|
|
10626
11245
|
if (text.length <= max) return text;
|
|
10627
11246
|
return `${text.slice(0, max)}\u2026`;
|
|
@@ -10696,7 +11315,7 @@ function collectToolsByAssistantId(events, sessionId) {
|
|
|
10696
11315
|
for (const ev of events) {
|
|
10697
11316
|
if (ev.aggregateType && ev.aggregateType !== "session") continue;
|
|
10698
11317
|
if (ev.aggregateId && ev.aggregateId !== sessionId) continue;
|
|
10699
|
-
const payload =
|
|
11318
|
+
const payload = asRecord6(ev.payload);
|
|
10700
11319
|
switch (ev.eventType) {
|
|
10701
11320
|
case SESSION_DURABLE_EVENT.turnStarted: {
|
|
10702
11321
|
turnKey += 1;
|
|
@@ -10712,47 +11331,47 @@ function collectToolsByAssistantId(events, sessionId) {
|
|
|
10712
11331
|
}
|
|
10713
11332
|
case SESSION_DURABLE_EVENT.assistantDelta:
|
|
10714
11333
|
case SESSION_DURABLE_EVENT.assistantText: {
|
|
10715
|
-
const blockId =
|
|
11334
|
+
const blockId = asString3(payload.blockId);
|
|
10716
11335
|
if (blockId) bindAssistant(blockId);
|
|
10717
11336
|
break;
|
|
10718
11337
|
}
|
|
10719
11338
|
case SESSION_DURABLE_EVENT.assistantMessage: {
|
|
10720
|
-
const blockId =
|
|
11339
|
+
const blockId = asString3(payload.blockId);
|
|
10721
11340
|
if (blockId) bindAssistant(blockId, { authoritative: true });
|
|
10722
11341
|
break;
|
|
10723
11342
|
}
|
|
10724
11343
|
case SESSION_DURABLE_EVENT.agentEvent: {
|
|
10725
|
-
const raw =
|
|
10726
|
-
const type =
|
|
11344
|
+
const raw = asRecord6(payload.event);
|
|
11345
|
+
const type = asString3(raw.type);
|
|
10727
11346
|
if (type === "message_start") {
|
|
10728
|
-
const id =
|
|
11347
|
+
const id = asString3(asRecord6(raw.message).id);
|
|
10729
11348
|
if (id) bindAssistant(id);
|
|
10730
11349
|
} else if (type === "message_complete") {
|
|
10731
|
-
const id =
|
|
11350
|
+
const id = asString3(raw.messageId);
|
|
10732
11351
|
if (id) bindAssistant(id, { authoritative: true });
|
|
10733
11352
|
} else if (type === "content_delta") {
|
|
10734
|
-
const messageId =
|
|
11353
|
+
const messageId = asString3(raw.messageId);
|
|
10735
11354
|
if (messageId) bindAssistant(messageId);
|
|
10736
|
-
const delta =
|
|
10737
|
-
const dType =
|
|
11355
|
+
const delta = asRecord6(raw.delta);
|
|
11356
|
+
const dType = asString3(delta.type);
|
|
10738
11357
|
if (dType === "tool_use") {
|
|
10739
|
-
const toolUseId =
|
|
11358
|
+
const toolUseId = asString3(delta.toolUseId);
|
|
10740
11359
|
if (!toolUseId) break;
|
|
10741
11360
|
const key = currentAssistantId ?? provisionalKey;
|
|
10742
11361
|
const bucket = ensureBucket(key);
|
|
10743
11362
|
const existing = bucket.get(toolUseId) ?? {
|
|
10744
11363
|
toolUseId,
|
|
10745
|
-
toolName:
|
|
11364
|
+
toolName: asString3(delta.toolName) ?? "tool"
|
|
10746
11365
|
};
|
|
10747
|
-
existing.toolName =
|
|
11366
|
+
existing.toolName = asString3(delta.toolName) ?? existing.toolName;
|
|
10748
11367
|
const input = coerceSummary(delta.input);
|
|
10749
11368
|
if (input) existing.inputSummary = input;
|
|
10750
11369
|
if (delta.parentToolUseId !== void 0) {
|
|
10751
|
-
existing.parentToolUseId =
|
|
11370
|
+
existing.parentToolUseId = asString3(delta.parentToolUseId) ?? null;
|
|
10752
11371
|
}
|
|
10753
11372
|
bucket.set(toolUseId, existing);
|
|
10754
11373
|
} else if (dType === "tool_result") {
|
|
10755
|
-
const toolUseId =
|
|
11374
|
+
const toolUseId = asString3(delta.toolUseId);
|
|
10756
11375
|
if (!toolUseId) break;
|
|
10757
11376
|
const key = currentAssistantId ?? provisionalKey;
|
|
10758
11377
|
const bucket = ensureBucket(key);
|
|
@@ -10770,34 +11389,34 @@ function collectToolsByAssistantId(events, sessionId) {
|
|
|
10770
11389
|
}
|
|
10771
11390
|
case SESSION_DURABLE_EVENT.toolStarted:
|
|
10772
11391
|
case SESSION_DURABLE_EVENT.toolInputDelta: {
|
|
10773
|
-
const toolUseId =
|
|
11392
|
+
const toolUseId = asString3(payload.toolUseId);
|
|
10774
11393
|
if (!toolUseId) break;
|
|
10775
11394
|
const key = currentAssistantId ?? provisionalKey;
|
|
10776
11395
|
const bucket = ensureBucket(key);
|
|
10777
11396
|
const existing = bucket.get(toolUseId) ?? {
|
|
10778
11397
|
toolUseId,
|
|
10779
|
-
toolName:
|
|
11398
|
+
toolName: asString3(payload.toolName) ?? "tool"
|
|
10780
11399
|
};
|
|
10781
|
-
existing.toolName =
|
|
11400
|
+
existing.toolName = asString3(payload.toolName) ?? existing.toolName;
|
|
10782
11401
|
const input = coerceSummary(payload.input) ?? coerceSummary(payload.inputDelta) ?? existing.inputSummary;
|
|
10783
11402
|
if (input) existing.inputSummary = input;
|
|
10784
11403
|
if (payload.parentToolUseId !== void 0) {
|
|
10785
|
-
existing.parentToolUseId =
|
|
11404
|
+
existing.parentToolUseId = asString3(payload.parentToolUseId) ?? null;
|
|
10786
11405
|
}
|
|
10787
11406
|
bucket.set(toolUseId, existing);
|
|
10788
11407
|
break;
|
|
10789
11408
|
}
|
|
10790
11409
|
case SESSION_DURABLE_EVENT.toolCompleted:
|
|
10791
11410
|
case SESSION_DURABLE_EVENT.toolFailed: {
|
|
10792
|
-
const toolUseId =
|
|
11411
|
+
const toolUseId = asString3(payload.toolUseId);
|
|
10793
11412
|
if (!toolUseId) break;
|
|
10794
11413
|
const key = currentAssistantId ?? provisionalKey;
|
|
10795
11414
|
const bucket = ensureBucket(key);
|
|
10796
11415
|
const existing = bucket.get(toolUseId) ?? {
|
|
10797
11416
|
toolUseId,
|
|
10798
|
-
toolName:
|
|
11417
|
+
toolName: asString3(payload.toolName) ?? "tool"
|
|
10799
11418
|
};
|
|
10800
|
-
existing.toolName =
|
|
11419
|
+
existing.toolName = asString3(payload.toolName) ?? existing.toolName;
|
|
10801
11420
|
const input = coerceSummary(payload.input);
|
|
10802
11421
|
if (input) existing.inputSummary = input;
|
|
10803
11422
|
const output = coerceSummary(payload.output);
|
|
@@ -10806,7 +11425,7 @@ function collectToolsByAssistantId(events, sessionId) {
|
|
|
10806
11425
|
existing.isError = true;
|
|
10807
11426
|
}
|
|
10808
11427
|
if (payload.parentToolUseId !== void 0) {
|
|
10809
|
-
existing.parentToolUseId =
|
|
11428
|
+
existing.parentToolUseId = asString3(payload.parentToolUseId) ?? null;
|
|
10810
11429
|
}
|
|
10811
11430
|
bucket.set(toolUseId, existing);
|
|
10812
11431
|
break;
|
|
@@ -10839,16 +11458,72 @@ function collectToolsByAssistantId(events, sessionId) {
|
|
|
10839
11458
|
}
|
|
10840
11459
|
return out;
|
|
10841
11460
|
}
|
|
11461
|
+
function collectContentByAssistantId(events, sessionId) {
|
|
11462
|
+
const contentById = /* @__PURE__ */ new Map();
|
|
11463
|
+
const mapper = createNodeSessionEventMapper({ sessionId });
|
|
11464
|
+
const mergeContent = (fromId, toId) => {
|
|
11465
|
+
if (!fromId || !toId || fromId === toId) return;
|
|
11466
|
+
const from = contentById.get(fromId);
|
|
11467
|
+
if (!from || from.length === 0) return;
|
|
11468
|
+
const to = contentById.get(toId);
|
|
11469
|
+
if (!to || to.length === 0) {
|
|
11470
|
+
contentById.set(toId, from);
|
|
11471
|
+
} else {
|
|
11472
|
+
contentById.set(toId, from.length >= to.length ? from : to);
|
|
11473
|
+
}
|
|
11474
|
+
contentById.delete(fromId);
|
|
11475
|
+
};
|
|
11476
|
+
for (const envelope of events) {
|
|
11477
|
+
if (envelope.aggregateType && envelope.aggregateType !== "session") continue;
|
|
11478
|
+
if (envelope.aggregateId && envelope.aggregateId !== sessionId) continue;
|
|
11479
|
+
const stickyBefore = mapper.currentAssistantMessageId();
|
|
11480
|
+
const mapped = mapper.map(envelope);
|
|
11481
|
+
for (const ev of mapped) {
|
|
11482
|
+
if (ev.type === "content_delta" && ev.messageId) {
|
|
11483
|
+
const prev = contentById.get(ev.messageId) ?? [];
|
|
11484
|
+
contentById.set(ev.messageId, applyContentDelta(prev, ev.delta));
|
|
11485
|
+
continue;
|
|
11486
|
+
}
|
|
11487
|
+
if (ev.type === "tool_input_delta" && ev.messageId && ev.toolUseId && ev.partialJson) {
|
|
11488
|
+
const prev = contentById.get(ev.messageId) ?? [];
|
|
11489
|
+
let changed = false;
|
|
11490
|
+
const next = prev.map((block) => {
|
|
11491
|
+
if (block.type !== "tool_use" || block.toolUseId !== ev.toolUseId) return block;
|
|
11492
|
+
changed = true;
|
|
11493
|
+
return { ...block, input: `${block.input ?? ""}${ev.partialJson}` };
|
|
11494
|
+
});
|
|
11495
|
+
if (changed) contentById.set(ev.messageId, next);
|
|
11496
|
+
}
|
|
11497
|
+
}
|
|
11498
|
+
const payload = asRecord6(envelope.payload);
|
|
11499
|
+
if (envelope.eventType === SESSION_DURABLE_EVENT.assistantMessage) {
|
|
11500
|
+
const blockId = asString3(payload.blockId);
|
|
11501
|
+
const sticky = stickyBefore ?? mapper.currentAssistantMessageId();
|
|
11502
|
+
if (blockId && sticky) mergeContent(sticky, blockId);
|
|
11503
|
+
const text = asString3(payload.text);
|
|
11504
|
+
if (blockId && text) {
|
|
11505
|
+
const prev = contentById.get(blockId) ?? [];
|
|
11506
|
+
const hasTopLevelText = prev.some(
|
|
11507
|
+
(b2) => b2.type === "text" && (b2.parentToolUseId == null || b2.parentToolUseId === void 0)
|
|
11508
|
+
);
|
|
11509
|
+
if (!hasTopLevelText) {
|
|
11510
|
+
contentById.set(blockId, applyContentDelta(prev, { type: "text", text }));
|
|
11511
|
+
}
|
|
11512
|
+
}
|
|
11513
|
+
}
|
|
11514
|
+
}
|
|
11515
|
+
return contentById;
|
|
11516
|
+
}
|
|
10842
11517
|
function extractCheckpointMeta(events, sessionId, blockId) {
|
|
10843
11518
|
for (let i = events.length - 1; i >= 0; i--) {
|
|
10844
11519
|
const ev = events[i];
|
|
10845
11520
|
if (ev.aggregateType && ev.aggregateType !== "session") continue;
|
|
10846
11521
|
if (ev.aggregateId && ev.aggregateId !== sessionId) continue;
|
|
10847
|
-
const payload =
|
|
11522
|
+
const payload = asRecord6(ev.payload);
|
|
10848
11523
|
if (ev.eventType === SESSION_DURABLE_EVENT.assistantMessage) {
|
|
10849
|
-
if (
|
|
10850
|
-
const checkpointId =
|
|
10851
|
-
const resumePointId =
|
|
11524
|
+
if (asString3(payload.blockId) !== blockId) continue;
|
|
11525
|
+
const checkpointId = asString3(payload.checkpointId);
|
|
11526
|
+
const resumePointId = asString3(payload.resumePointId);
|
|
10852
11527
|
const metadata = payload.metadata && typeof payload.metadata === "object" ? payload.metadata : void 0;
|
|
10853
11528
|
if (checkpointId || resumePointId || metadata) {
|
|
10854
11529
|
return {
|
|
@@ -10859,14 +11534,14 @@ function extractCheckpointMeta(events, sessionId, blockId) {
|
|
|
10859
11534
|
}
|
|
10860
11535
|
}
|
|
10861
11536
|
if (ev.eventType === SESSION_DURABLE_EVENT.agentEvent) {
|
|
10862
|
-
const raw =
|
|
10863
|
-
if (
|
|
11537
|
+
const raw = asRecord6(payload.event);
|
|
11538
|
+
if (asString3(raw.type) !== "message_complete" && asString3(raw.type) !== "checkpoint_captured") {
|
|
10864
11539
|
continue;
|
|
10865
11540
|
}
|
|
10866
|
-
const messageId =
|
|
11541
|
+
const messageId = asString3(raw.messageId) ?? asString3(raw.id);
|
|
10867
11542
|
if (messageId && messageId !== blockId) continue;
|
|
10868
|
-
const checkpointId =
|
|
10869
|
-
const resumePointId =
|
|
11543
|
+
const checkpointId = asString3(raw.checkpointId);
|
|
11544
|
+
const resumePointId = asString3(raw.resumePointId);
|
|
10870
11545
|
if (checkpointId || resumePointId) {
|
|
10871
11546
|
return {
|
|
10872
11547
|
...checkpointId ? { checkpointId } : {},
|
|
@@ -10879,12 +11554,14 @@ function extractCheckpointMeta(events, sessionId, blockId) {
|
|
|
10879
11554
|
}
|
|
10880
11555
|
function buildSessionMessageCatalog(session, events) {
|
|
10881
11556
|
const toolsByAssistant = collectToolsByAssistantId(events, session.sessionId);
|
|
11557
|
+
const contentByAssistant = collectContentByAssistantId(events, session.sessionId);
|
|
10882
11558
|
const transcript = Array.isArray(session.transcript) ? session.transcript : [];
|
|
10883
11559
|
const out = [];
|
|
10884
11560
|
for (let i = 0; i < transcript.length; i++) {
|
|
10885
11561
|
const block = transcript[i];
|
|
10886
11562
|
const role = block.role === "user" || block.role === "assistant" || block.role === "system" ? block.role : "system";
|
|
10887
11563
|
const tools = role === "assistant" ? toolsByAssistant.get(block.id) : void 0;
|
|
11564
|
+
const orderedContent = role === "assistant" ? contentByAssistant.get(block.id) : void 0;
|
|
10888
11565
|
const extra = role === "assistant" ? extractCheckpointMeta(events, session.sessionId, block.id) : {};
|
|
10889
11566
|
let resumePointId = extra.resumePointId;
|
|
10890
11567
|
if (!resumePointId && role === "assistant" && i === transcript.length - 1 && session.providerResume) {
|
|
@@ -10896,6 +11573,7 @@ function buildSessionMessageCatalog(session, events) {
|
|
|
10896
11573
|
text: typeof block.text === "string" ? block.text : "",
|
|
10897
11574
|
createdAt: typeof block.createdAt === "number" ? block.createdAt : Date.now(),
|
|
10898
11575
|
sortOrder: i,
|
|
11576
|
+
...orderedContent && orderedContent.length > 0 ? { content: orderedContent } : {},
|
|
10899
11577
|
...tools && tools.length > 0 ? { tools } : {},
|
|
10900
11578
|
...extra.metadata ? { metadata: extra.metadata } : {},
|
|
10901
11579
|
...extra.checkpointId ? { checkpointId: extra.checkpointId } : {},
|
|
@@ -10921,7 +11599,9 @@ var DEFAULT_LIMIT, MAX_LIMIT, SUMMARY_MAX;
|
|
|
10921
11599
|
var init_message_catalog = __esm({
|
|
10922
11600
|
"../../packages/runtime/src/session/message-catalog.ts"() {
|
|
10923
11601
|
"use strict";
|
|
11602
|
+
init_content_delta();
|
|
10924
11603
|
init_environment();
|
|
11604
|
+
init_node_session_event_map();
|
|
10925
11605
|
DEFAULT_LIMIT = 50;
|
|
10926
11606
|
MAX_LIMIT = 200;
|
|
10927
11607
|
SUMMARY_MAX = 2e3;
|
|
@@ -14282,6 +14962,12 @@ function familyBaseUrl(family, baseUrl) {
|
|
|
14282
14962
|
if (family === "openai" || family === "newapi") return `${trimmed}/v1`;
|
|
14283
14963
|
return trimmed;
|
|
14284
14964
|
}
|
|
14965
|
+
function harnessChatProtocols(harness, options) {
|
|
14966
|
+
if (harness === "claude" && options?.experimentalClaudeOpenAiChatEnabled) {
|
|
14967
|
+
return [...HARNESS_CHAT_PROTOCOLS.claude, "openai-chat"];
|
|
14968
|
+
}
|
|
14969
|
+
return HARNESS_CHAT_PROTOCOLS[harness];
|
|
14970
|
+
}
|
|
14285
14971
|
var PROTOCOL_TASKS, PROTOCOL_FAMILIES, PROTOCOL_FAMILY, FAMILY_PROTOCOLS, PROTOCOL_ORDER, CAPABILITY_ORDER, FAMILY_TASK_PROTOCOL, FAMILY_TASKS, HARNESS_CHAT_PROTOCOLS, PROXY_TRANSFORMERS_ENV;
|
|
14286
14972
|
var init_protocols = __esm({
|
|
14287
14973
|
"../../packages/shared/src/platform-registry/protocols.ts"() {
|
|
@@ -14354,7 +15040,7 @@ var init_protocols = __esm({
|
|
|
14354
15040
|
google: CAPABILITY_ORDER.filter((task) => FAMILY_TASK_PROTOCOL.google[task])
|
|
14355
15041
|
};
|
|
14356
15042
|
HARNESS_CHAT_PROTOCOLS = {
|
|
14357
|
-
claude: ["anthropic-messages"
|
|
15043
|
+
claude: ["anthropic-messages"],
|
|
14358
15044
|
codex: ["openai-responses", "openai-chat"]
|
|
14359
15045
|
};
|
|
14360
15046
|
PROXY_TRANSFORMERS_ENV = "SUPERONE_PROXY_TRANSFORMERS";
|
|
@@ -14463,11 +15149,31 @@ var init_model_tasks = __esm({
|
|
|
14463
15149
|
});
|
|
14464
15150
|
|
|
14465
15151
|
// ../../packages/shared/src/platform-registry/relay-discovery.ts
|
|
15152
|
+
var CANONICAL_CATALOG_PROVIDERS, FIRST_PARTY_CATALOG_PROVIDERS;
|
|
14466
15153
|
var init_relay_discovery = __esm({
|
|
14467
15154
|
"../../packages/shared/src/platform-registry/relay-discovery.ts"() {
|
|
14468
15155
|
"use strict";
|
|
14469
15156
|
init_model_tasks();
|
|
14470
15157
|
init_protocols();
|
|
15158
|
+
CANONICAL_CATALOG_PROVIDERS = ["openai", "anthropic", "google"];
|
|
15159
|
+
FIRST_PARTY_CATALOG_PROVIDERS = /* @__PURE__ */ new Set([
|
|
15160
|
+
...CANONICAL_CATALOG_PROVIDERS,
|
|
15161
|
+
"xai",
|
|
15162
|
+
"deepseek",
|
|
15163
|
+
"mistral",
|
|
15164
|
+
"cohere",
|
|
15165
|
+
"meta",
|
|
15166
|
+
"moonshotai",
|
|
15167
|
+
"moonshotai-cn",
|
|
15168
|
+
"zhipuai",
|
|
15169
|
+
"zhipuai-coding-plan",
|
|
15170
|
+
"alibaba",
|
|
15171
|
+
"alibaba-cn",
|
|
15172
|
+
"minimax",
|
|
15173
|
+
"minimax-cn",
|
|
15174
|
+
"bytedance",
|
|
15175
|
+
"perplexity"
|
|
15176
|
+
]);
|
|
14471
15177
|
}
|
|
14472
15178
|
});
|
|
14473
15179
|
|
|
@@ -15431,16 +16137,16 @@ function findPlatform(platforms, platformId) {
|
|
|
15431
16137
|
function findPlan(platform2, planId) {
|
|
15432
16138
|
return platform2?.plans.find((p2) => p2.id === planId);
|
|
15433
16139
|
}
|
|
15434
|
-
function selectProtocol(endpoint, task, harness) {
|
|
16140
|
+
function selectProtocol(endpoint, task, harness, options) {
|
|
15435
16141
|
const serving = endpoint.protocols.filter((p2) => protocolServes(p2, task));
|
|
15436
|
-
if (harness) return
|
|
16142
|
+
if (harness) return harnessChatProtocols(harness, options).find((p2) => serving.includes(p2));
|
|
15437
16143
|
return [...serving].sort((a, b2) => PROTOCOL_ORDER.indexOf(a) - PROTOCOL_ORDER.indexOf(b2))[0];
|
|
15438
16144
|
}
|
|
15439
|
-
function selectEndpoint(plan, consumer, endpointId, credential, endpoints = plan.endpoints) {
|
|
16145
|
+
function selectEndpoint(plan, consumer, endpointId, credential, endpoints = plan.endpoints, options) {
|
|
15440
16146
|
const task = CONSUMER_TASK[consumer];
|
|
15441
16147
|
const harness = consumer === "chat:claude" ? "claude" : consumer === "chat:codex" ? "codex" : void 0;
|
|
15442
16148
|
const pick3 = (e) => {
|
|
15443
|
-
const protocol = selectProtocol(e, task, harness);
|
|
16149
|
+
const protocol = selectProtocol(e, task, harness, options);
|
|
15444
16150
|
if (!protocol) return void 0;
|
|
15445
16151
|
if (harness) return protocol;
|
|
15446
16152
|
if (!credential) return protocol;
|
|
@@ -15462,7 +16168,7 @@ function selectEndpoint(plan, consumer, endpointId, credential, endpoints = plan
|
|
|
15462
16168
|
}
|
|
15463
16169
|
}
|
|
15464
16170
|
if (harness) {
|
|
15465
|
-
for (const proto of
|
|
16171
|
+
for (const proto of harnessChatProtocols(harness, options)) {
|
|
15466
16172
|
const endpoint = endpoints.find((e) => e.protocols.includes(proto) && protocolServes(proto, task));
|
|
15467
16173
|
if (endpoint) return { endpoint, protocol: proto };
|
|
15468
16174
|
}
|
|
@@ -15490,7 +16196,7 @@ var init_platform_registry = __esm({
|
|
|
15490
16196
|
});
|
|
15491
16197
|
|
|
15492
16198
|
// ../../packages/runtime/src/llm-proxy/claude-messages/helpers.ts
|
|
15493
|
-
function
|
|
16199
|
+
function asString4(value) {
|
|
15494
16200
|
return typeof value === "string" ? value : void 0;
|
|
15495
16201
|
}
|
|
15496
16202
|
function asArray(value) {
|
|
@@ -15534,13 +16240,13 @@ function splitLeadingThinkBlock(text) {
|
|
|
15534
16240
|
}
|
|
15535
16241
|
function extractReasoningFieldText(value) {
|
|
15536
16242
|
for (const key of ["reasoning_content", "reasoning"]) {
|
|
15537
|
-
const text =
|
|
16243
|
+
const text = asString4(get(value, key));
|
|
15538
16244
|
if (text) return text;
|
|
15539
16245
|
}
|
|
15540
16246
|
const reasoning = get(value, "reasoning");
|
|
15541
16247
|
if (reasoning) {
|
|
15542
16248
|
for (const key of ["content", "text", "summary"]) {
|
|
15543
|
-
const text =
|
|
16249
|
+
const text = asString4(get(reasoning, key));
|
|
15544
16250
|
if (text) return text;
|
|
15545
16251
|
}
|
|
15546
16252
|
}
|
|
@@ -15549,12 +16255,12 @@ function extractReasoningFieldText(value) {
|
|
|
15549
16255
|
if (typeof details === "string") return details || void 0;
|
|
15550
16256
|
const arr = asArray(details);
|
|
15551
16257
|
if (arr) {
|
|
15552
|
-
const joined = arr.map((part) =>
|
|
16258
|
+
const joined = arr.map((part) => asString4(get(part, "text")) ?? asString4(get(part, "content")) ?? asString4(part)).filter((t) => !!t).join("\n\n");
|
|
15553
16259
|
return joined || void 0;
|
|
15554
16260
|
}
|
|
15555
16261
|
const obj = asObject(details);
|
|
15556
16262
|
if (obj) {
|
|
15557
|
-
const text =
|
|
16263
|
+
const text = asString4(get(obj, "text")) ?? asString4(get(obj, "content")) ?? asString4(get(obj, "summary"));
|
|
15558
16264
|
if (text) return text;
|
|
15559
16265
|
}
|
|
15560
16266
|
}
|
|
@@ -15582,7 +16288,7 @@ function isOpenAiOSeries2(model) {
|
|
|
15582
16288
|
function mapThinkingToEffort(thinking, maxTokens) {
|
|
15583
16289
|
const t = asObject2(thinking);
|
|
15584
16290
|
if (!t) return null;
|
|
15585
|
-
const type =
|
|
16291
|
+
const type = asString5(t.type);
|
|
15586
16292
|
if (type === "disabled") return null;
|
|
15587
16293
|
if (type === "adaptive") return "medium";
|
|
15588
16294
|
if (type === "enabled") {
|
|
@@ -15608,7 +16314,7 @@ function stripModelPrefix(model, providerName) {
|
|
|
15608
16314
|
function asObject2(value) {
|
|
15609
16315
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
15610
16316
|
}
|
|
15611
|
-
function
|
|
16317
|
+
function asString5(value) {
|
|
15612
16318
|
return typeof value === "string" ? value : void 0;
|
|
15613
16319
|
}
|
|
15614
16320
|
var init_capabilities3 = __esm({
|
|
@@ -15621,7 +16327,7 @@ var init_capabilities3 = __esm({
|
|
|
15621
16327
|
function claudeMessagesToChatCompletions(body, providerName) {
|
|
15622
16328
|
const result = {};
|
|
15623
16329
|
const src = asObject(body) ?? {};
|
|
15624
|
-
const rawModel =
|
|
16330
|
+
const rawModel = asString4(src.model) ?? "";
|
|
15625
16331
|
const model = stripModelPrefix(rawModel, providerName);
|
|
15626
16332
|
result.model = model;
|
|
15627
16333
|
const maxTokens = typeof src.max_tokens === "number" ? src.max_tokens : void 0;
|
|
@@ -15664,11 +16370,11 @@ function claudeMessagesToChatCompletions(body, providerName) {
|
|
|
15664
16370
|
return result;
|
|
15665
16371
|
}
|
|
15666
16372
|
function systemTextFromClaude(value) {
|
|
15667
|
-
const str2 =
|
|
16373
|
+
const str2 = asString4(value);
|
|
15668
16374
|
if (str2 !== void 0) return str2;
|
|
15669
16375
|
const arr = asArray(value);
|
|
15670
16376
|
if (arr) {
|
|
15671
|
-
return arr.map((part) =>
|
|
16377
|
+
return arr.map((part) => asString4(get(part, "text")) ?? asString4(part)).filter((s2) => !!s2).join("\n\n");
|
|
15672
16378
|
}
|
|
15673
16379
|
return "";
|
|
15674
16380
|
}
|
|
@@ -15676,7 +16382,7 @@ function appendClaudeMessagesAsChat(src, messages) {
|
|
|
15676
16382
|
const arr = asArray(src);
|
|
15677
16383
|
if (!arr) return;
|
|
15678
16384
|
for (const item of arr) {
|
|
15679
|
-
const role =
|
|
16385
|
+
const role = asString4(get(item, "role"));
|
|
15680
16386
|
if (role === "assistant") {
|
|
15681
16387
|
messages.push(claudeAssistantToChat(item));
|
|
15682
16388
|
} else if (role === "user") {
|
|
@@ -15696,9 +16402,9 @@ function claudeUserToChat(item) {
|
|
|
15696
16402
|
const chatParts = [];
|
|
15697
16403
|
let hasNonText = false;
|
|
15698
16404
|
for (const part of parts) {
|
|
15699
|
-
const partType =
|
|
16405
|
+
const partType = asString4(get(part, "type")) ?? "";
|
|
15700
16406
|
if (partType === "text" || partType === "input_text") {
|
|
15701
|
-
const t =
|
|
16407
|
+
const t = asString4(get(part, "text"));
|
|
15702
16408
|
if (t) chatParts.push({ type: "text", text: t });
|
|
15703
16409
|
} else if (partType === "image" || partType === "input_image") {
|
|
15704
16410
|
hasNonText = true;
|
|
@@ -15706,11 +16412,11 @@ function claudeUserToChat(item) {
|
|
|
15706
16412
|
const imageUrl = get(part, "image_url");
|
|
15707
16413
|
let url2;
|
|
15708
16414
|
if (source) {
|
|
15709
|
-
const mediaType =
|
|
15710
|
-
const data =
|
|
16415
|
+
const mediaType = asString4(get(source, "media_type")) ?? "image/png";
|
|
16416
|
+
const data = asString4(get(source, "data"));
|
|
15711
16417
|
if (data) url2 = `data:${mediaType};base64,${data}`;
|
|
15712
16418
|
} else if (imageUrl !== void 0) {
|
|
15713
|
-
url2 =
|
|
16419
|
+
url2 = asString4(imageUrl) ?? "";
|
|
15714
16420
|
}
|
|
15715
16421
|
if (url2) chatParts.push({ type: "image_url", image_url: { url: url2 } });
|
|
15716
16422
|
}
|
|
@@ -15743,17 +16449,17 @@ function extractThinkingFromAssistant(item) {
|
|
|
15743
16449
|
const content = asArray(get(item, "content"));
|
|
15744
16450
|
if (content) {
|
|
15745
16451
|
for (const part of content) {
|
|
15746
|
-
if (
|
|
15747
|
-
const thinking =
|
|
16452
|
+
if (asString4(get(part, "type")) === "thinking") {
|
|
16453
|
+
const thinking = asString4(get(part, "thinking"));
|
|
15748
16454
|
if (thinking) return thinking;
|
|
15749
16455
|
}
|
|
15750
16456
|
}
|
|
15751
16457
|
}
|
|
15752
|
-
return
|
|
16458
|
+
return asString4(get(item, "reasoning_content"));
|
|
15753
16459
|
}
|
|
15754
16460
|
function claudeToolUseToChatToolCall(item) {
|
|
15755
|
-
const callId =
|
|
15756
|
-
const name =
|
|
16461
|
+
const callId = asString4(get(item, "id")) ?? asString4(get(item, "tool_use_id"));
|
|
16462
|
+
const name = asString4(get(item, "name"));
|
|
15757
16463
|
if (!callId || !name) return void 0;
|
|
15758
16464
|
const input = get(item, "input") ?? get(item, "arguments");
|
|
15759
16465
|
return {
|
|
@@ -15763,13 +16469,13 @@ function claudeToolUseToChatToolCall(item) {
|
|
|
15763
16469
|
};
|
|
15764
16470
|
}
|
|
15765
16471
|
function claudeFunctionCallToChatToolCall(functionCall) {
|
|
15766
|
-
const callId =
|
|
15767
|
-
const name =
|
|
16472
|
+
const callId = asString4(get(functionCall, "id")) ?? "call_0";
|
|
16473
|
+
const name = asString4(get(functionCall, "name")) ?? "";
|
|
15768
16474
|
const args = canonicalizeToolArguments(get(functionCall, "arguments"));
|
|
15769
16475
|
return { id: callId, type: "function", function: { name, arguments: args } };
|
|
15770
16476
|
}
|
|
15771
16477
|
function claudeToolResultToChat(item) {
|
|
15772
|
-
const toolUseId =
|
|
16478
|
+
const toolUseId = asString4(get(item, "tool_use_id")) ?? asString4(get(item, "call_id")) ?? "";
|
|
15773
16479
|
const content = get(item, "content");
|
|
15774
16480
|
const text = contentToText(content);
|
|
15775
16481
|
const isError = get(item, "is_error") === true;
|
|
@@ -15781,7 +16487,7 @@ function claudeToolResultToChat(item) {
|
|
|
15781
16487
|
};
|
|
15782
16488
|
}
|
|
15783
16489
|
function claudeToolToChatTool(tool) {
|
|
15784
|
-
const name =
|
|
16490
|
+
const name = asString4(get(tool, "name"));
|
|
15785
16491
|
if (!name) return void 0;
|
|
15786
16492
|
const schema = asObject(get(tool, "input_schema"));
|
|
15787
16493
|
const parameters = schema ?? asObject(get(tool, "parameters")) ?? {};
|
|
@@ -15798,29 +16504,29 @@ function claudeToolToChatTool(tool) {
|
|
|
15798
16504
|
function claudeToolChoiceToChat(toolChoice) {
|
|
15799
16505
|
const obj = asObject(toolChoice);
|
|
15800
16506
|
if (obj) {
|
|
15801
|
-
const type =
|
|
16507
|
+
const type = asString4(obj.type);
|
|
15802
16508
|
if (type === "tool" || type === "function") {
|
|
15803
|
-
const name =
|
|
16509
|
+
const name = asString4(obj.name) ?? asString4(get(obj, "function.name"));
|
|
15804
16510
|
if (name) return { type: "function", function: { name } };
|
|
15805
16511
|
}
|
|
15806
16512
|
if (type === "any") return "required";
|
|
15807
16513
|
if (type === "auto" || type === "none") return type;
|
|
15808
16514
|
}
|
|
15809
|
-
if (
|
|
16515
|
+
if (asString4(toolChoice) === "none" || asString4(toolChoice) === "auto" || asString4(toolChoice) === "required") {
|
|
15810
16516
|
return toolChoice;
|
|
15811
16517
|
}
|
|
15812
16518
|
return toolChoice;
|
|
15813
16519
|
}
|
|
15814
16520
|
function contentToText(content) {
|
|
15815
16521
|
if (content === null || content === void 0) return void 0;
|
|
15816
|
-
const str2 =
|
|
16522
|
+
const str2 = asString4(content);
|
|
15817
16523
|
if (str2 !== void 0) return str2;
|
|
15818
16524
|
const parts = asArray(content);
|
|
15819
16525
|
if (!parts) return void 0;
|
|
15820
16526
|
const textParts = parts.map((part) => {
|
|
15821
|
-
const partType =
|
|
15822
|
-
if (partType === "text" || partType === "input_text") return
|
|
15823
|
-
if (partType === "thinking") return
|
|
16527
|
+
const partType = asString4(get(part, "type")) ?? "";
|
|
16528
|
+
if (partType === "text" || partType === "input_text") return asString4(get(part, "text"));
|
|
16529
|
+
if (partType === "thinking") return asString4(get(part, "thinking"));
|
|
15824
16530
|
return void 0;
|
|
15825
16531
|
}).filter((s2) => s2 !== void 0);
|
|
15826
16532
|
if (textParts.length === 0) return void 0;
|
|
@@ -15830,8 +16536,8 @@ function collapseSystemMessagesToHead(messages) {
|
|
|
15830
16536
|
const systemChunks = [];
|
|
15831
16537
|
const rest = [];
|
|
15832
16538
|
for (const msg of messages) {
|
|
15833
|
-
if (
|
|
15834
|
-
const text =
|
|
16539
|
+
if (asString4(msg.role) === "system") {
|
|
16540
|
+
const text = asString4(msg.content);
|
|
15835
16541
|
if (text !== void 0) {
|
|
15836
16542
|
if (text.trim()) systemChunks.push(text);
|
|
15837
16543
|
continue;
|
|
@@ -15875,10 +16581,10 @@ function chatCompletionToMessage(body) {
|
|
|
15875
16581
|
if (choice === void 0) throw new Error("Empty choices in chat response");
|
|
15876
16582
|
const message = get(choice, "message");
|
|
15877
16583
|
if (message === void 0) throw new Error("No message in chat choice");
|
|
15878
|
-
const messageId = messageIdFromChatId(
|
|
15879
|
-
const model =
|
|
16584
|
+
const messageId = messageIdFromChatId(asString4(get(body, "id")));
|
|
16585
|
+
const model = asString4(get(body, "model")) ?? "";
|
|
15880
16586
|
const createdAt = typeof get(body, "created") === "number" ? get(body, "created") : 0;
|
|
15881
|
-
const finishReason =
|
|
16587
|
+
const finishReason = asString4(get(choice, "finish_reason"));
|
|
15882
16588
|
const reasoning = chatReasoningText(message);
|
|
15883
16589
|
const output = [];
|
|
15884
16590
|
const reasoningItem = chatReasoningToOutputItem(reasoning, messageId);
|
|
@@ -15909,7 +16615,7 @@ function chatReasoningToOutputItem(reasoning, messageId) {
|
|
|
15909
16615
|
function chatReasoningText(message) {
|
|
15910
16616
|
const field = extractReasoningFieldText(message);
|
|
15911
16617
|
if (field) return field;
|
|
15912
|
-
const content =
|
|
16618
|
+
const content = asString4(get(message, "content"));
|
|
15913
16619
|
if (content) {
|
|
15914
16620
|
const split = splitLeadingThinkBlock(content);
|
|
15915
16621
|
if (split && split.reasoning) return split.reasoning;
|
|
@@ -15918,7 +16624,7 @@ function chatReasoningText(message) {
|
|
|
15918
16624
|
}
|
|
15919
16625
|
function chatMessageToOutputItem(message, messageId) {
|
|
15920
16626
|
const content = [];
|
|
15921
|
-
const text =
|
|
16627
|
+
const text = asString4(get(message, "content"));
|
|
15922
16628
|
if (text !== void 0) {
|
|
15923
16629
|
const answer = splitLeadingThinkBlock(text)?.answer ?? text;
|
|
15924
16630
|
if (answer) content.push({ type: "text", text: answer, annotations: [] });
|
|
@@ -15926,12 +16632,12 @@ function chatMessageToOutputItem(message, messageId) {
|
|
|
15926
16632
|
const parts = asArray(get(message, "content"));
|
|
15927
16633
|
if (parts) {
|
|
15928
16634
|
for (const part of parts) {
|
|
15929
|
-
const partType =
|
|
16635
|
+
const partType = asString4(get(part, "type")) ?? "";
|
|
15930
16636
|
if (partType === "text" || partType === "output_text") {
|
|
15931
|
-
const t =
|
|
16637
|
+
const t = asString4(get(part, "text"));
|
|
15932
16638
|
if (t) content.push({ type: "text", text: t, annotations: [] });
|
|
15933
16639
|
} else if (partType === "refusal") {
|
|
15934
|
-
const t =
|
|
16640
|
+
const t = asString4(get(part, "refusal"));
|
|
15935
16641
|
if (t) content.push({ type: "text", text: t, annotations: [] });
|
|
15936
16642
|
}
|
|
15937
16643
|
}
|
|
@@ -15957,9 +16663,9 @@ function chatToolCallsToOutputItems(message) {
|
|
|
15957
16663
|
return output;
|
|
15958
16664
|
}
|
|
15959
16665
|
function chatToolCallToOutputItem(toolCall, index) {
|
|
15960
|
-
const callId =
|
|
16666
|
+
const callId = asString4(get(toolCall, "id"))?.trim() || `call_${index}`;
|
|
15961
16667
|
const fn = get(toolCall, "function");
|
|
15962
|
-
const name =
|
|
16668
|
+
const name = asString4(get(fn, "name")) ?? "";
|
|
15963
16669
|
const args = canonicalizeToolArguments(get(fn, "arguments"));
|
|
15964
16670
|
return {
|
|
15965
16671
|
type: "tool_use",
|
|
@@ -15969,8 +16675,8 @@ function chatToolCallToOutputItem(toolCall, index) {
|
|
|
15969
16675
|
};
|
|
15970
16676
|
}
|
|
15971
16677
|
function chatLegacyFunctionCallToOutputItem(functionCall) {
|
|
15972
|
-
const callId =
|
|
15973
|
-
const name =
|
|
16678
|
+
const callId = asString4(get(functionCall, "id"))?.trim() || "call_0";
|
|
16679
|
+
const name = asString4(get(functionCall, "name")) ?? "";
|
|
15974
16680
|
const args = canonicalizeToolArguments(get(functionCall, "arguments"));
|
|
15975
16681
|
return {
|
|
15976
16682
|
type: "tool_use",
|
|
@@ -16022,13 +16728,13 @@ function chatErrorToMessageError(body) {
|
|
|
16022
16728
|
error: { type: "upstream_error", message: "Upstream returned an empty error response" }
|
|
16023
16729
|
};
|
|
16024
16730
|
}
|
|
16025
|
-
const str2 =
|
|
16731
|
+
const str2 = asString4(body);
|
|
16026
16732
|
if (str2 !== void 0) {
|
|
16027
16733
|
return { type: "error", error: { type: "upstream_error", message: str2 } };
|
|
16028
16734
|
}
|
|
16029
16735
|
const source = get(body, "error") ?? body;
|
|
16030
|
-
const message =
|
|
16031
|
-
const errorType =
|
|
16736
|
+
const message = asString4(get(source, "message")) ?? asString4(get(source, "detail")) ?? asString4(get(source, "status_msg")) ?? asString4(get(get(source, "base_resp"), "status_msg")) ?? asString4(source) ?? safeStringify(source);
|
|
16737
|
+
const errorType = asString4(get(source, "type")) ?? "upstream_error";
|
|
16032
16738
|
return {
|
|
16033
16739
|
type: "error",
|
|
16034
16740
|
error: { type: errorType, message }
|
|
@@ -16121,8 +16827,8 @@ function stripLeadingThinkOpenTag(text) {
|
|
|
16121
16827
|
}
|
|
16122
16828
|
function extractChatSseError(value) {
|
|
16123
16829
|
const error51 = get(value, "error") ?? value;
|
|
16124
|
-
const message =
|
|
16125
|
-
const errorType =
|
|
16830
|
+
const message = asString4(error51) ?? asString4(get(error51, "message")) ?? asString4(get(error51, "detail")) ?? JSON.stringify(error51);
|
|
16831
|
+
const errorType = asString4(get(error51, "type")) ?? asString4(get(error51, "code"));
|
|
16126
16832
|
return { message, errorType: errorType ?? void 0 };
|
|
16127
16833
|
}
|
|
16128
16834
|
function stripSseField(line, field) {
|
|
@@ -16232,9 +16938,9 @@ var init_stream = __esm({
|
|
|
16232
16938
|
inputTokens;
|
|
16233
16939
|
handleChatChunk(chunk) {
|
|
16234
16940
|
const events = [];
|
|
16235
|
-
const id =
|
|
16941
|
+
const id = asString4(get(chunk, "id"));
|
|
16236
16942
|
if (id) this.responseId = messageIdFromChatId(id);
|
|
16237
|
-
const model =
|
|
16943
|
+
const model = asString4(get(chunk, "model"));
|
|
16238
16944
|
if (model) this.model = model;
|
|
16239
16945
|
const created = get(chunk, "created");
|
|
16240
16946
|
if (typeof created === "number") this.createdAt = created;
|
|
@@ -16254,7 +16960,7 @@ var init_stream = __esm({
|
|
|
16254
16960
|
if (delta !== void 0) {
|
|
16255
16961
|
const reasoning = extractReasoningFieldText(delta);
|
|
16256
16962
|
if (reasoning) events.push(...this.pushReasoningDelta(reasoning));
|
|
16257
|
-
const content =
|
|
16963
|
+
const content = asString4(get(delta, "content"));
|
|
16258
16964
|
if (content) events.push(...this.pushContentDelta(content));
|
|
16259
16965
|
const toolCalls = asArray(get(delta, "tool_calls"));
|
|
16260
16966
|
if (toolCalls) {
|
|
@@ -16264,7 +16970,7 @@ var init_stream = __esm({
|
|
|
16264
16970
|
for (const toolCall of toolCalls) events.push(...this.pushToolCallDelta(toolCall, reasoningForTool));
|
|
16265
16971
|
}
|
|
16266
16972
|
}
|
|
16267
|
-
const finishReason =
|
|
16973
|
+
const finishReason = asString4(get(choice, "finish_reason"));
|
|
16268
16974
|
if (finishReason) this.finishReason = finishReason;
|
|
16269
16975
|
return events;
|
|
16270
16976
|
}
|
|
@@ -16420,10 +17126,10 @@ var init_stream = __esm({
|
|
|
16420
17126
|
}
|
|
16421
17127
|
pushToolCallDelta(toolCall, reasoning) {
|
|
16422
17128
|
const chatIndex = typeof get(toolCall, "index") === "number" ? get(toolCall, "index") : 0;
|
|
16423
|
-
const idDelta =
|
|
17129
|
+
const idDelta = asString4(get(toolCall, "id"));
|
|
16424
17130
|
const fn = get(toolCall, "function");
|
|
16425
|
-
const nameDelta =
|
|
16426
|
-
const argsDelta =
|
|
17131
|
+
const nameDelta = asString4(get(fn, "name"));
|
|
17132
|
+
const argsDelta = asString4(get(fn, "arguments")) ?? "";
|
|
16427
17133
|
let state = this.tools.get(chatIndex);
|
|
16428
17134
|
if (!state) {
|
|
16429
17135
|
state = newToolCall();
|
|
@@ -16640,7 +17346,7 @@ var init_transformer = __esm({
|
|
|
16640
17346
|
});
|
|
16641
17347
|
|
|
16642
17348
|
// ../../packages/runtime/src/llm-proxy/codex-responses/helpers.ts
|
|
16643
|
-
function
|
|
17349
|
+
function asString6(value) {
|
|
16644
17350
|
return typeof value === "string" ? value : void 0;
|
|
16645
17351
|
}
|
|
16646
17352
|
function asArray2(value) {
|
|
@@ -16701,7 +17407,7 @@ function stripLeadingThinkOpenTag2(text) {
|
|
|
16701
17407
|
}
|
|
16702
17408
|
function detailPartText(value) {
|
|
16703
17409
|
for (const key of ["text", "content", "summary"]) {
|
|
16704
|
-
const text =
|
|
17410
|
+
const text = asString6(get2(value, key));
|
|
16705
17411
|
if (text) return text;
|
|
16706
17412
|
}
|
|
16707
17413
|
const parts = asArray2(get2(value, "parts"));
|
|
@@ -16723,13 +17429,13 @@ function detailsText(value) {
|
|
|
16723
17429
|
}
|
|
16724
17430
|
function extractReasoningFieldText2(value) {
|
|
16725
17431
|
for (const key of ["reasoning_content", "reasoning"]) {
|
|
16726
|
-
const text =
|
|
17432
|
+
const text = asString6(get2(value, key));
|
|
16727
17433
|
if (text) return text;
|
|
16728
17434
|
}
|
|
16729
17435
|
const reasoning = get2(value, "reasoning");
|
|
16730
17436
|
if (reasoning) {
|
|
16731
17437
|
for (const key of ["content", "text", "summary"]) {
|
|
16732
|
-
const text =
|
|
17438
|
+
const text = asString6(get2(reasoning, key));
|
|
16733
17439
|
if (text) return text;
|
|
16734
17440
|
}
|
|
16735
17441
|
}
|
|
@@ -16742,22 +17448,22 @@ function extractReasoningFieldText2(value) {
|
|
|
16742
17448
|
}
|
|
16743
17449
|
function extractReasoningSummaryText(value) {
|
|
16744
17450
|
for (const key of ["reasoning_content", "content", "text"]) {
|
|
16745
|
-
const text =
|
|
17451
|
+
const text = asString6(get2(value, key));
|
|
16746
17452
|
if (text) return text;
|
|
16747
17453
|
}
|
|
16748
17454
|
const summary = get2(value, "summary");
|
|
16749
17455
|
if (summary === void 0) return void 0;
|
|
16750
|
-
const asStr =
|
|
17456
|
+
const asStr = asString6(summary);
|
|
16751
17457
|
if (asStr !== void 0) return asStr || void 0;
|
|
16752
17458
|
const parts = asArray2(summary);
|
|
16753
17459
|
if (!parts) return void 0;
|
|
16754
|
-
const joined = parts.map((part) =>
|
|
17460
|
+
const joined = parts.map((part) => asString6(get2(part, "text")) ?? asString6(get2(part, "content")) ?? asString6(part)).filter((t) => !!t).join("\n\n");
|
|
16755
17461
|
return joined || void 0;
|
|
16756
17462
|
}
|
|
16757
17463
|
function appendReasoningContent(message, reasoning) {
|
|
16758
17464
|
const trimmed = reasoning.trim();
|
|
16759
17465
|
if (!trimmed) return false;
|
|
16760
|
-
const existing =
|
|
17466
|
+
const existing = asString6(message.reasoning_content);
|
|
16761
17467
|
if (existing) {
|
|
16762
17468
|
message.reasoning_content = `${existing}
|
|
16763
17469
|
|
|
@@ -16785,7 +17491,7 @@ function applyCodexChatReasoning(result, body, config2) {
|
|
|
16785
17491
|
if (!config2) return;
|
|
16786
17492
|
const reasoning = asObject4(asObject4(body)?.reasoning);
|
|
16787
17493
|
if (!reasoning) return;
|
|
16788
|
-
const rawEffort =
|
|
17494
|
+
const rawEffort = asString6(reasoning.effort);
|
|
16789
17495
|
const reasoningEnabled = rawEffort ? !isDisabled(rawEffort) : true;
|
|
16790
17496
|
if (config2.supportsThinking) {
|
|
16791
17497
|
if (config2.thinkingParam === "thinking") {
|
|
@@ -16901,7 +17607,7 @@ function responsesToChatCompletions(body, reasoningConfig) {
|
|
|
16901
17607
|
if (instructions) messages.push({ role: "system", content: instructions });
|
|
16902
17608
|
appendResponsesInputAsChatMessages(src.input, messages);
|
|
16903
17609
|
result.messages = collapseSystemMessagesToHead2(messages);
|
|
16904
|
-
const model =
|
|
17610
|
+
const model = asString6(src.model) ?? "";
|
|
16905
17611
|
if (src.max_output_tokens !== void 0) {
|
|
16906
17612
|
if (isOpenAiOSeries3(model)) result.max_completion_tokens = src.max_output_tokens;
|
|
16907
17613
|
else result.max_tokens = src.max_output_tokens;
|
|
@@ -16928,17 +17634,17 @@ function responsesToChatCompletions(body, reasoningConfig) {
|
|
|
16928
17634
|
return result;
|
|
16929
17635
|
}
|
|
16930
17636
|
function instructionText(value) {
|
|
16931
|
-
const str2 =
|
|
17637
|
+
const str2 = asString6(value);
|
|
16932
17638
|
if (str2 !== void 0) return str2;
|
|
16933
17639
|
const arr = asArray2(value);
|
|
16934
17640
|
if (arr) {
|
|
16935
|
-
return arr.map((part) =>
|
|
17641
|
+
return arr.map((part) => asString6(get2(part, "text")) ?? asString6(part)).filter((s2) => !!s2).join("\n\n");
|
|
16936
17642
|
}
|
|
16937
17643
|
return "";
|
|
16938
17644
|
}
|
|
16939
17645
|
function appendResponsesInputAsChatMessages(input, messages) {
|
|
16940
17646
|
const state = { pendingToolCalls: [], pendingReasoning: void 0, lastAssistantIndex: void 0 };
|
|
16941
|
-
const str2 =
|
|
17647
|
+
const str2 = asString6(input);
|
|
16942
17648
|
if (str2 !== void 0) {
|
|
16943
17649
|
messages.push({ role: "user", content: str2 });
|
|
16944
17650
|
} else {
|
|
@@ -16953,7 +17659,7 @@ function appendResponsesInputAsChatMessages(input, messages) {
|
|
|
16953
17659
|
backfillToolCallReasoningPlaceholders(messages);
|
|
16954
17660
|
}
|
|
16955
17661
|
function appendResponsesItem(item, messages, state) {
|
|
16956
|
-
const itemType =
|
|
17662
|
+
const itemType = asString6(get2(item, "type"));
|
|
16957
17663
|
switch (itemType) {
|
|
16958
17664
|
case "function_call": {
|
|
16959
17665
|
appendUniquePendingReasoning(state, extractReasoningFieldText2(item));
|
|
@@ -16962,7 +17668,7 @@ function appendResponsesItem(item, messages, state) {
|
|
|
16962
17668
|
}
|
|
16963
17669
|
case "function_call_output": {
|
|
16964
17670
|
flushPendingToolCalls(messages, state);
|
|
16965
|
-
const callId =
|
|
17671
|
+
const callId = asString6(get2(item, "call_id")) ?? "";
|
|
16966
17672
|
messages.push({ role: "tool", tool_call_id: callId, content: functionCallOutput(get2(item, "output")) });
|
|
16967
17673
|
return;
|
|
16968
17674
|
}
|
|
@@ -16983,7 +17689,7 @@ function appendResponsesItem(item, messages, state) {
|
|
|
16983
17689
|
}
|
|
16984
17690
|
}
|
|
16985
17691
|
function functionCallOutput(output) {
|
|
16986
|
-
const str2 =
|
|
17692
|
+
const str2 = asString6(output);
|
|
16987
17693
|
if (str2 !== void 0) return canonicalizeJsonStringIfParseable(str2);
|
|
16988
17694
|
if (output === void 0) return "";
|
|
16989
17695
|
return canonicalJsonString(output);
|
|
@@ -16997,7 +17703,7 @@ function flushPendingToolCalls(messages, state) {
|
|
|
16997
17703
|
messages.push(message);
|
|
16998
17704
|
}
|
|
16999
17705
|
function responsesMessageItemToChatMessage(item, state) {
|
|
17000
|
-
const role =
|
|
17706
|
+
const role = asString6(get2(item, "role")) ?? "user";
|
|
17001
17707
|
const chatRole = responsesRoleToChatRole(role);
|
|
17002
17708
|
const content = "content" in (asObject4(item) ?? {}) ? responsesContentToChatContent(get2(item, "content")) : null;
|
|
17003
17709
|
const message = { role: chatRole, content };
|
|
@@ -17023,7 +17729,7 @@ function responsesRoleToChatRole(role) {
|
|
|
17023
17729
|
}
|
|
17024
17730
|
}
|
|
17025
17731
|
function updateLastAssistantIndex(messages, message, state) {
|
|
17026
|
-
const role =
|
|
17732
|
+
const role = asString6(message.role);
|
|
17027
17733
|
if (role === "assistant") state.lastAssistantIndex = messages.length;
|
|
17028
17734
|
else if (role !== "tool") state.lastAssistantIndex = void 0;
|
|
17029
17735
|
}
|
|
@@ -17052,51 +17758,51 @@ function attachReasoningToLastAssistant(messages, lastAssistantIndex, reasoning)
|
|
|
17052
17758
|
if (!trimmed) return true;
|
|
17053
17759
|
if (lastAssistantIndex === void 0) return false;
|
|
17054
17760
|
const message = messages[lastAssistantIndex];
|
|
17055
|
-
if (!message ||
|
|
17761
|
+
if (!message || asString6(message.role) !== "assistant") return false;
|
|
17056
17762
|
appendReasoningContent(message, trimmed);
|
|
17057
17763
|
return true;
|
|
17058
17764
|
}
|
|
17059
17765
|
function backfillToolCallReasoningPlaceholders(messages) {
|
|
17060
17766
|
for (const message of messages) {
|
|
17061
|
-
const isToolCall =
|
|
17062
|
-
if (isToolCall && !
|
|
17767
|
+
const isToolCall = asString6(message.role) === "assistant" && (asArray2(message.tool_calls)?.length ?? 0) > 0;
|
|
17768
|
+
if (isToolCall && !asString6(message.reasoning_content)?.trim()) {
|
|
17063
17769
|
message.reasoning_content = "tool call";
|
|
17064
17770
|
}
|
|
17065
17771
|
}
|
|
17066
17772
|
}
|
|
17067
17773
|
function responsesContentToChatContent(content) {
|
|
17068
17774
|
if (content === null || content === void 0) return null;
|
|
17069
|
-
const str2 =
|
|
17775
|
+
const str2 = asString6(content);
|
|
17070
17776
|
if (str2 !== void 0) return str2;
|
|
17071
17777
|
const parts = asArray2(content);
|
|
17072
17778
|
if (!parts) return content;
|
|
17073
17779
|
const chatParts = [];
|
|
17074
17780
|
let hasNonText = false;
|
|
17075
17781
|
for (const part of parts) {
|
|
17076
|
-
const partType =
|
|
17782
|
+
const partType = asString6(get2(part, "type")) ?? "";
|
|
17077
17783
|
if (partType === "input_text" || partType === "output_text" || partType === "text") {
|
|
17078
|
-
const text =
|
|
17784
|
+
const text = asString6(get2(part, "text"));
|
|
17079
17785
|
if (text) chatParts.push({ type: "text", text });
|
|
17080
17786
|
} else if (partType === "refusal") {
|
|
17081
|
-
const text =
|
|
17787
|
+
const text = asString6(get2(part, "refusal"));
|
|
17082
17788
|
if (text) chatParts.push({ type: "text", text });
|
|
17083
17789
|
} else if (partType === "input_image") {
|
|
17084
17790
|
const imageUrl = get2(part, "image_url");
|
|
17085
17791
|
if (imageUrl !== void 0) {
|
|
17086
|
-
const value = asObject4(imageUrl) ? imageUrl : { url:
|
|
17792
|
+
const value = asObject4(imageUrl) ? imageUrl : { url: asString6(imageUrl) ?? "" };
|
|
17087
17793
|
chatParts.push({ type: "image_url", image_url: value });
|
|
17088
17794
|
hasNonText = true;
|
|
17089
17795
|
}
|
|
17090
17796
|
}
|
|
17091
17797
|
}
|
|
17092
17798
|
if (!hasNonText) {
|
|
17093
|
-
return chatParts.map((part) =>
|
|
17799
|
+
return chatParts.map((part) => asString6(part.text) ?? "").join("\n");
|
|
17094
17800
|
}
|
|
17095
17801
|
return chatParts;
|
|
17096
17802
|
}
|
|
17097
17803
|
function responsesFunctionCallToChatToolCall(item) {
|
|
17098
|
-
const callId =
|
|
17099
|
-
const name =
|
|
17804
|
+
const callId = asString6(get2(item, "call_id")) ?? asString6(get2(item, "id")) ?? "";
|
|
17805
|
+
const name = asString6(get2(item, "name")) ?? "";
|
|
17100
17806
|
return {
|
|
17101
17807
|
id: callId,
|
|
17102
17808
|
type: "function",
|
|
@@ -17104,7 +17810,7 @@ function responsesFunctionCallToChatToolCall(item) {
|
|
|
17104
17810
|
};
|
|
17105
17811
|
}
|
|
17106
17812
|
function responsesToolToChatTool(tool) {
|
|
17107
|
-
if (
|
|
17813
|
+
if (asString6(get2(tool, "type")) !== "function") return void 0;
|
|
17108
17814
|
const fn = asObject4(get2(tool, "function"));
|
|
17109
17815
|
if (fn) {
|
|
17110
17816
|
const cloned = { ...asObject4(tool) };
|
|
@@ -17118,7 +17824,7 @@ function responsesToolToChatTool(tool) {
|
|
|
17118
17824
|
return cloned;
|
|
17119
17825
|
}
|
|
17120
17826
|
const fnObj = {
|
|
17121
|
-
name:
|
|
17827
|
+
name: asString6(get2(tool, "name")) ?? "",
|
|
17122
17828
|
description: get2(tool, "description") ?? null,
|
|
17123
17829
|
parameters: get2(tool, "parameters") ?? {}
|
|
17124
17830
|
};
|
|
@@ -17127,8 +17833,8 @@ function responsesToolToChatTool(tool) {
|
|
|
17127
17833
|
}
|
|
17128
17834
|
function responsesToolChoiceToChat(toolChoice) {
|
|
17129
17835
|
const obj = asObject4(toolChoice);
|
|
17130
|
-
if (obj &&
|
|
17131
|
-
return { type: "function", function: { name:
|
|
17836
|
+
if (obj && asString6(obj.type) === "function") {
|
|
17837
|
+
return { type: "function", function: { name: asString6(obj.name) ?? "" } };
|
|
17132
17838
|
}
|
|
17133
17839
|
return toolChoice;
|
|
17134
17840
|
}
|
|
@@ -17136,8 +17842,8 @@ function collapseSystemMessagesToHead2(messages) {
|
|
|
17136
17842
|
const systemChunks = [];
|
|
17137
17843
|
const rest = [];
|
|
17138
17844
|
for (const msg of messages) {
|
|
17139
|
-
if (
|
|
17140
|
-
const text =
|
|
17845
|
+
if (asString6(msg.role) === "system") {
|
|
17846
|
+
const text = asString6(msg.content);
|
|
17141
17847
|
if (text !== void 0) {
|
|
17142
17848
|
if (text.trim()) systemChunks.push(text);
|
|
17143
17849
|
continue;
|
|
@@ -17181,10 +17887,10 @@ function chatCompletionToResponse(body) {
|
|
|
17181
17887
|
if (choice === void 0) throw new Error("Empty choices in chat response");
|
|
17182
17888
|
const message = get2(choice, "message");
|
|
17183
17889
|
if (message === void 0) throw new Error("No message in chat choice");
|
|
17184
|
-
const responseId = responseIdFromChatId(
|
|
17185
|
-
const model =
|
|
17890
|
+
const responseId = responseIdFromChatId(asString6(get2(body, "id")));
|
|
17891
|
+
const model = asString6(get2(body, "model")) ?? "";
|
|
17186
17892
|
const createdAt = typeof get2(body, "created") === "number" ? get2(body, "created") : 0;
|
|
17187
|
-
const finishReason =
|
|
17893
|
+
const finishReason = asString6(get2(choice, "finish_reason"));
|
|
17188
17894
|
const reasoning = chatReasoningText2(message);
|
|
17189
17895
|
const output = [];
|
|
17190
17896
|
const reasoningItem = chatReasoningToOutputItem2(reasoning, responseId);
|
|
@@ -17215,7 +17921,7 @@ function chatReasoningToOutputItem2(reasoning, responseId) {
|
|
|
17215
17921
|
function chatReasoningText2(message) {
|
|
17216
17922
|
const field = extractReasoningFieldText2(message);
|
|
17217
17923
|
if (field) return field;
|
|
17218
|
-
const content =
|
|
17924
|
+
const content = asString6(get2(message, "content"));
|
|
17219
17925
|
if (content) {
|
|
17220
17926
|
const split = splitLeadingThinkBlock3(content);
|
|
17221
17927
|
if (split && split.reasoning) return split.reasoning;
|
|
@@ -17224,7 +17930,7 @@ function chatReasoningText2(message) {
|
|
|
17224
17930
|
}
|
|
17225
17931
|
function chatMessageToOutputItem2(message, responseId) {
|
|
17226
17932
|
const content = [];
|
|
17227
|
-
const text =
|
|
17933
|
+
const text = asString6(get2(message, "content"));
|
|
17228
17934
|
if (text !== void 0) {
|
|
17229
17935
|
const answer = splitLeadingThinkBlock3(text)?.answer ?? text;
|
|
17230
17936
|
if (answer) content.push({ type: "output_text", text: answer, annotations: [] });
|
|
@@ -17232,18 +17938,18 @@ function chatMessageToOutputItem2(message, responseId) {
|
|
|
17232
17938
|
const parts = asArray2(get2(message, "content"));
|
|
17233
17939
|
if (parts) {
|
|
17234
17940
|
for (const part of parts) {
|
|
17235
|
-
const partType =
|
|
17941
|
+
const partType = asString6(get2(part, "type")) ?? "";
|
|
17236
17942
|
if (partType === "text" || partType === "output_text") {
|
|
17237
|
-
const t =
|
|
17943
|
+
const t = asString6(get2(part, "text"));
|
|
17238
17944
|
if (t) content.push({ type: "output_text", text: t, annotations: [] });
|
|
17239
17945
|
} else if (partType === "refusal") {
|
|
17240
|
-
const t =
|
|
17946
|
+
const t = asString6(get2(part, "refusal"));
|
|
17241
17947
|
if (t) content.push({ type: "refusal", refusal: t });
|
|
17242
17948
|
}
|
|
17243
17949
|
}
|
|
17244
17950
|
}
|
|
17245
17951
|
}
|
|
17246
|
-
const refusal =
|
|
17952
|
+
const refusal = asString6(get2(message, "refusal"));
|
|
17247
17953
|
if (refusal) content.push({ type: "refusal", refusal });
|
|
17248
17954
|
if (content.length === 0) return void 0;
|
|
17249
17955
|
return {
|
|
@@ -17278,15 +17984,15 @@ function functionCallItem(itemId, callId, name, args, reasoning) {
|
|
|
17278
17984
|
return item;
|
|
17279
17985
|
}
|
|
17280
17986
|
function chatToolCallToOutputItem2(toolCall, index, reasoning) {
|
|
17281
|
-
const callId =
|
|
17987
|
+
const callId = asString6(get2(toolCall, "id"))?.trim() || `call_${index}`;
|
|
17282
17988
|
const fn = get2(toolCall, "function");
|
|
17283
|
-
const name =
|
|
17989
|
+
const name = asString6(get2(fn, "name")) ?? "";
|
|
17284
17990
|
const args = canonicalizeToolArguments2(get2(fn, "arguments"));
|
|
17285
17991
|
return functionCallItem(`fc_${callId}`, callId, name, args, reasoning);
|
|
17286
17992
|
}
|
|
17287
17993
|
function chatLegacyFunctionCallToOutputItem2(functionCall, reasoning) {
|
|
17288
|
-
const callId =
|
|
17289
|
-
const name =
|
|
17994
|
+
const callId = asString6(get2(functionCall, "id"))?.trim() || "call_0";
|
|
17995
|
+
const name = asString6(get2(functionCall, "name")) ?? "";
|
|
17290
17996
|
const args = canonicalizeToolArguments2(get2(functionCall, "arguments"));
|
|
17291
17997
|
return functionCallItem(`fc_${callId}`, callId, name, args, reasoning);
|
|
17292
17998
|
}
|
|
@@ -17322,13 +18028,13 @@ function chatErrorToResponseError(body) {
|
|
|
17322
18028
|
error: { message: "Upstream returned an empty error response", type: "upstream_error", code: null, param: null }
|
|
17323
18029
|
};
|
|
17324
18030
|
}
|
|
17325
|
-
const str2 =
|
|
18031
|
+
const str2 = asString6(body);
|
|
17326
18032
|
if (str2 !== void 0) {
|
|
17327
18033
|
return { error: { message: str2, type: "upstream_error", code: null, param: null } };
|
|
17328
18034
|
}
|
|
17329
18035
|
const source = get2(body, "error") ?? body;
|
|
17330
|
-
const message =
|
|
17331
|
-
const errorType =
|
|
18036
|
+
const message = asString6(get2(source, "message")) ?? asString6(get2(source, "detail")) ?? asString6(get2(source, "status_msg")) ?? asString6(get2(get2(source, "base_resp"), "status_msg")) ?? asString6(source) ?? safeStringify2(source);
|
|
18037
|
+
const errorType = asString6(get2(source, "type")) ?? "upstream_error";
|
|
17332
18038
|
const code = get2(source, "code") ?? get2(get2(source, "base_resp"), "status_code") ?? null;
|
|
17333
18039
|
const param = get2(source, "param") ?? null;
|
|
17334
18040
|
return { error: { message, type: errorType, code, param } };
|
|
@@ -17381,8 +18087,8 @@ function leadingThinkPrefixDecision2(buffer) {
|
|
|
17381
18087
|
}
|
|
17382
18088
|
function extractChatSseError2(value) {
|
|
17383
18089
|
const error51 = get2(value, "error") ?? value;
|
|
17384
|
-
const message =
|
|
17385
|
-
const errorType =
|
|
18090
|
+
const message = asString6(error51) ?? asString6(get2(error51, "message")) ?? asString6(get2(error51, "detail")) ?? JSON.stringify(error51);
|
|
18091
|
+
const errorType = asString6(get2(error51, "type")) ?? asString6(get2(error51, "code"));
|
|
17386
18092
|
return { message, errorType: errorType ?? void 0 };
|
|
17387
18093
|
}
|
|
17388
18094
|
function stripSseField2(line, field) {
|
|
@@ -17491,9 +18197,9 @@ var init_stream2 = __esm({
|
|
|
17491
18197
|
finishReason;
|
|
17492
18198
|
handleChatChunk(chunk) {
|
|
17493
18199
|
const events = [];
|
|
17494
|
-
const id =
|
|
18200
|
+
const id = asString6(get2(chunk, "id"));
|
|
17495
18201
|
if (id) this.responseId = responseIdFromChatId(id);
|
|
17496
|
-
const model =
|
|
18202
|
+
const model = asString6(get2(chunk, "model"));
|
|
17497
18203
|
if (model) this.model = model;
|
|
17498
18204
|
const created = get2(chunk, "created");
|
|
17499
18205
|
if (typeof created === "number") this.createdAt = created;
|
|
@@ -17506,7 +18212,7 @@ var init_stream2 = __esm({
|
|
|
17506
18212
|
if (delta !== void 0) {
|
|
17507
18213
|
const reasoning = extractReasoningFieldText2(delta);
|
|
17508
18214
|
if (reasoning) events.push(...this.pushReasoningDelta(reasoning));
|
|
17509
|
-
const content =
|
|
18215
|
+
const content = asString6(get2(delta, "content"));
|
|
17510
18216
|
if (content) events.push(...this.pushContentDelta(content));
|
|
17511
18217
|
const toolCalls = asArray2(get2(delta, "tool_calls"));
|
|
17512
18218
|
if (toolCalls) {
|
|
@@ -17516,7 +18222,7 @@ var init_stream2 = __esm({
|
|
|
17516
18222
|
for (const toolCall of toolCalls) events.push(...this.pushToolCallDelta(toolCall, reasoningForTool));
|
|
17517
18223
|
}
|
|
17518
18224
|
}
|
|
17519
|
-
const finishReason =
|
|
18225
|
+
const finishReason = asString6(get2(choice, "finish_reason"));
|
|
17520
18226
|
if (finishReason) this.finishReason = finishReason;
|
|
17521
18227
|
return events;
|
|
17522
18228
|
}
|
|
@@ -17689,10 +18395,10 @@ var init_stream2 = __esm({
|
|
|
17689
18395
|
}
|
|
17690
18396
|
pushToolCallDelta(toolCall, reasoning) {
|
|
17691
18397
|
const chatIndex = typeof get2(toolCall, "index") === "number" ? get2(toolCall, "index") : 0;
|
|
17692
|
-
const idDelta =
|
|
18398
|
+
const idDelta = asString6(get2(toolCall, "id"));
|
|
17693
18399
|
const fn = get2(toolCall, "function");
|
|
17694
|
-
const nameDelta =
|
|
17695
|
-
const argsDelta =
|
|
18400
|
+
const nameDelta = asString6(get2(fn, "name"));
|
|
18401
|
+
const argsDelta = asString6(get2(fn, "arguments")) ?? "";
|
|
17696
18402
|
let state = this.tools.get(chatIndex);
|
|
17697
18403
|
if (!state) {
|
|
17698
18404
|
state = newToolCall2();
|
|
@@ -18259,7 +18965,7 @@ function platformsForNode(store) {
|
|
|
18259
18965
|
for (const p2 of custom2) byId2.set(p2.id, p2);
|
|
18260
18966
|
return [...byId2.values()];
|
|
18261
18967
|
}
|
|
18262
|
-
function resolveServiceFromCredential(consumer, cred, platforms, binding) {
|
|
18968
|
+
function resolveServiceFromCredential(consumer, cred, platforms, binding, options) {
|
|
18263
18969
|
const platform2 = findPlatform(platforms, cred.platformId);
|
|
18264
18970
|
const plan = findPlan(platform2, cred.planId);
|
|
18265
18971
|
if (!platform2 || !plan) return null;
|
|
@@ -18269,7 +18975,8 @@ function resolveServiceFromCredential(consumer, cred, platforms, binding) {
|
|
|
18269
18975
|
consumer,
|
|
18270
18976
|
binding?.endpointId,
|
|
18271
18977
|
cred,
|
|
18272
|
-
endpoints
|
|
18978
|
+
endpoints,
|
|
18979
|
+
options
|
|
18273
18980
|
);
|
|
18274
18981
|
if (!selected) return null;
|
|
18275
18982
|
const { endpoint, protocol } = selected;
|
|
@@ -18302,7 +19009,7 @@ function consumerForHarness(harness) {
|
|
|
18302
19009
|
if (harness === "codex") return "chat:codex";
|
|
18303
19010
|
return null;
|
|
18304
19011
|
}
|
|
18305
|
-
function listHarnessApiProviders(store, harness) {
|
|
19012
|
+
function listHarnessApiProviders(store, harness, options) {
|
|
18306
19013
|
const consumer = consumerForHarness(harness);
|
|
18307
19014
|
if (!consumer) return [];
|
|
18308
19015
|
const platforms = platformsForNode(store);
|
|
@@ -18312,7 +19019,7 @@ function listHarnessApiProviders(store, harness) {
|
|
|
18312
19019
|
const plan = findPlan(platform2, cred.planId);
|
|
18313
19020
|
if (!platform2 || !plan) continue;
|
|
18314
19021
|
const endpoints = effectiveEndpoints(platform2, plan, cred);
|
|
18315
|
-
if (!selectEndpoint(plan, consumer, void 0, cred, endpoints)) continue;
|
|
19022
|
+
if (!selectEndpoint(plan, consumer, void 0, cred, endpoints, options)) continue;
|
|
18316
19023
|
out.push({
|
|
18317
19024
|
id: cred.id,
|
|
18318
19025
|
name: platform2.name ?? cred.name,
|
|
@@ -18361,7 +19068,7 @@ async function buildHarnessEnvWithProxy(harness, resolved) {
|
|
|
18361
19068
|
}
|
|
18362
19069
|
return env;
|
|
18363
19070
|
}
|
|
18364
|
-
function resolveHarnessService(store, harness, apiProviderId) {
|
|
19071
|
+
function resolveHarnessService(store, harness, apiProviderId, options) {
|
|
18365
19072
|
const consumer = consumerForHarness(harness);
|
|
18366
19073
|
if (!consumer) return null;
|
|
18367
19074
|
const platforms = platformsForNode(store);
|
|
@@ -18375,11 +19082,12 @@ function resolveHarnessService(store, harness, apiProviderId) {
|
|
|
18375
19082
|
consumer,
|
|
18376
19083
|
cred,
|
|
18377
19084
|
platforms,
|
|
18378
|
-
binding && binding.credentialId === cred.id ? { endpointId: binding.endpointId, config: binding.config } : null
|
|
19085
|
+
binding && binding.credentialId === cred.id ? { endpointId: binding.endpointId, config: binding.config } : null,
|
|
19086
|
+
options
|
|
18379
19087
|
);
|
|
18380
19088
|
}
|
|
18381
|
-
function listHarnessProviderModels(store, harness, apiProviderId) {
|
|
18382
|
-
const resolved = resolveHarnessService(store, harness, apiProviderId);
|
|
19089
|
+
function listHarnessProviderModels(store, harness, apiProviderId, options) {
|
|
19090
|
+
const resolved = resolveHarnessService(store, harness, apiProviderId, options);
|
|
18383
19091
|
if (resolved) {
|
|
18384
19092
|
const mapped = /* @__PURE__ */ new Map();
|
|
18385
19093
|
for (const m2 of resolved.models ?? []) {
|
|
@@ -18410,8 +19118,8 @@ function listHarnessProviderModels(store, harness, apiProviderId) {
|
|
|
18410
19118
|
}
|
|
18411
19119
|
return [];
|
|
18412
19120
|
}
|
|
18413
|
-
function listHarnessModels(store, harness, apiProviderId) {
|
|
18414
|
-
const fromProvider = listHarnessProviderModels(store, harness, apiProviderId);
|
|
19121
|
+
function listHarnessModels(store, harness, apiProviderId, options) {
|
|
19122
|
+
const fromProvider = listHarnessProviderModels(store, harness, apiProviderId, options);
|
|
18415
19123
|
if (fromProvider.length > 0) return fromProvider;
|
|
18416
19124
|
if (harness === "claude") return DEFAULT_CLAUDE_MODELS;
|
|
18417
19125
|
if (harness === "codex") return DEFAULT_CODEX_MODELS;
|
|
@@ -21337,7 +22045,9 @@ function createNodeClaudeTurnRunner(opts) {
|
|
|
21337
22045
|
const cwd = input.session.cwd && input.session.cwd.trim() ? input.session.cwd.trim() : projectRoot2;
|
|
21338
22046
|
const providerEnv = opts.providers ? await buildHarnessEnvWithProxy(
|
|
21339
22047
|
"claude",
|
|
21340
|
-
resolveHarnessService(opts.providers, "claude", input.apiProviderId
|
|
22048
|
+
resolveHarnessService(opts.providers, "claude", input.apiProviderId, {
|
|
22049
|
+
experimentalClaudeOpenAiChatEnabled: opts.experimentalClaudeOpenAiChatEnabled?.() ?? false
|
|
22050
|
+
})
|
|
21341
22051
|
) : {};
|
|
21342
22052
|
const authEnv = {
|
|
21343
22053
|
...process.env,
|
|
@@ -40500,7 +41210,7 @@ function toolInputJson(raw) {
|
|
|
40500
41210
|
return "{}";
|
|
40501
41211
|
}
|
|
40502
41212
|
}
|
|
40503
|
-
function
|
|
41213
|
+
function asRecord7(raw) {
|
|
40504
41214
|
if (raw && typeof raw === "object" && !Array.isArray(raw)) return raw;
|
|
40505
41215
|
return {};
|
|
40506
41216
|
}
|
|
@@ -40639,7 +41349,7 @@ function grokMetaInput(tool) {
|
|
|
40639
41349
|
const xai = meta3["x.ai/tool"];
|
|
40640
41350
|
if (!xai || typeof xai !== "object") return {};
|
|
40641
41351
|
const input = xai.input;
|
|
40642
|
-
return
|
|
41352
|
+
return asRecord7(input);
|
|
40643
41353
|
}
|
|
40644
41354
|
function queryFromWebSearchTitle(title) {
|
|
40645
41355
|
if (!title) return void 0;
|
|
@@ -40897,11 +41607,11 @@ function unwrapMcpEnvelope(tool, raw) {
|
|
|
40897
41607
|
if (!isEnvelope) return null;
|
|
40898
41608
|
const id = raw.tool_name;
|
|
40899
41609
|
if (typeof id !== "string" || !id.includes("__")) return null;
|
|
40900
|
-
return { toolName: `mcp__${id}`, input:
|
|
41610
|
+
return { toolName: `mcp__${id}`, input: asRecord7(raw.tool_input) };
|
|
40901
41611
|
}
|
|
40902
41612
|
function normalizeAcpTool(tool, opts) {
|
|
40903
|
-
const raw = { ...grokMetaInput(tool), ...
|
|
40904
|
-
const mcp = unwrapMcpEnvelope(tool,
|
|
41613
|
+
const raw = { ...grokMetaInput(tool), ...asRecord7(tool.rawInput) };
|
|
41614
|
+
const mcp = unwrapMcpEnvelope(tool, asRecord7(tool.rawInput));
|
|
40905
41615
|
if (mcp) return mcp;
|
|
40906
41616
|
const diffs = extractDiffs(tool.content);
|
|
40907
41617
|
const terminalId = extractEmbeddedTerminalId(tool.content);
|
|
@@ -41094,9 +41804,14 @@ function createXaiCorrelationState(opts) {
|
|
|
41094
41804
|
goalStarted: /* @__PURE__ */ new Set(),
|
|
41095
41805
|
lastEventSeq: null,
|
|
41096
41806
|
lastUsage: null,
|
|
41097
|
-
lastMessageId: null
|
|
41807
|
+
lastMessageId: null,
|
|
41808
|
+
turnTokens: { input: 0, output: 0, cacheRead: 0 },
|
|
41809
|
+
rateLimited: false
|
|
41098
41810
|
};
|
|
41099
41811
|
}
|
|
41812
|
+
function resetTurnTokens(state) {
|
|
41813
|
+
state.turnTokens = { input: 0, output: 0, cacheRead: 0 };
|
|
41814
|
+
}
|
|
41100
41815
|
function resolveGrokChildChatHistoryPath(cwd, childSessionId) {
|
|
41101
41816
|
if (!cwd || !childSessionId) return void 0;
|
|
41102
41817
|
return join16(homedir4(), ".grok", "sessions", encodeURIComponent(cwd), childSessionId, "chat_history.jsonl");
|
|
@@ -41129,7 +41844,7 @@ function bindSubagentToolId(state, subagentId, toolUseId, description, migrateOu
|
|
|
41129
41844
|
});
|
|
41130
41845
|
}
|
|
41131
41846
|
}
|
|
41132
|
-
function
|
|
41847
|
+
function asRecord8(v2) {
|
|
41133
41848
|
if (!v2 || typeof v2 !== "object" || Array.isArray(v2)) return null;
|
|
41134
41849
|
return v2;
|
|
41135
41850
|
}
|
|
@@ -41162,18 +41877,18 @@ function arrField(o, ...keys) {
|
|
|
41162
41877
|
return void 0;
|
|
41163
41878
|
}
|
|
41164
41879
|
function parseXaiSessionNotificationEnvelope(raw) {
|
|
41165
|
-
const o =
|
|
41880
|
+
const o = asRecord8(raw);
|
|
41166
41881
|
if (!o) return null;
|
|
41167
|
-
const update =
|
|
41882
|
+
const update = asRecord8(o.update);
|
|
41168
41883
|
if (!update) return null;
|
|
41169
41884
|
const sessionId = strField(o, "sessionId", "session_id");
|
|
41170
|
-
const meta3 =
|
|
41885
|
+
const meta3 = asRecord8(o._meta) ?? asRecord8(o.meta);
|
|
41171
41886
|
const eventSeq = meta3 ? numField(meta3, "eventSeq", "event_seq") ?? null : null;
|
|
41172
41887
|
const eventId = meta3 ? strField(meta3, "eventId", "event_id") ?? null : null;
|
|
41173
41888
|
return { sessionId, update, meta: meta3, eventSeq, eventId };
|
|
41174
41889
|
}
|
|
41175
41890
|
function parseXaiExtParams(raw) {
|
|
41176
|
-
return
|
|
41891
|
+
return asRecord8(raw) ?? {};
|
|
41177
41892
|
}
|
|
41178
41893
|
function parsePlainTextTaskAck(text) {
|
|
41179
41894
|
const subagentId = text.match(/subagent_id:\s*(\S+)/i)?.[1] ?? text.match(/task_ids?\s*=\s*\[\s*"([^"]+)"/i)?.[1];
|
|
@@ -41278,13 +41993,13 @@ function tryParseJsonObject(text) {
|
|
|
41278
41993
|
if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) return null;
|
|
41279
41994
|
try {
|
|
41280
41995
|
const v2 = JSON.parse(trimmed);
|
|
41281
|
-
return
|
|
41996
|
+
return asRecord8(v2);
|
|
41282
41997
|
} catch {
|
|
41283
41998
|
const start = trimmed.indexOf("{");
|
|
41284
41999
|
const end = trimmed.lastIndexOf("}");
|
|
41285
42000
|
if (start < 0 || end <= start) return null;
|
|
41286
42001
|
try {
|
|
41287
|
-
return
|
|
42002
|
+
return asRecord8(JSON.parse(trimmed.slice(start, end + 1)));
|
|
41288
42003
|
} catch {
|
|
41289
42004
|
return null;
|
|
41290
42005
|
}
|
|
@@ -41352,6 +42067,10 @@ function mapXaiSessionUpdate(update, state, ctx = {}) {
|
|
|
41352
42067
|
return mapScheduledTaskDeleted(update, state);
|
|
41353
42068
|
case "turn_completed":
|
|
41354
42069
|
return mapTurnCompleted(update, state, ctx);
|
|
42070
|
+
case "response_started":
|
|
42071
|
+
return mapResponseStarted(update, state, ctx);
|
|
42072
|
+
case "response_completed":
|
|
42073
|
+
return mapResponseCompleted(update, state, ctx);
|
|
41355
42074
|
case "auto_compact_started":
|
|
41356
42075
|
return mapAutoCompactStarted(update);
|
|
41357
42076
|
case "auto_compact_completed":
|
|
@@ -41375,7 +42094,7 @@ function mapXaiSessionUpdate(update, state, ctx = {}) {
|
|
|
41375
42094
|
case "session_recap":
|
|
41376
42095
|
return mapSessionRecap(update);
|
|
41377
42096
|
case "session_recap_unavailable":
|
|
41378
|
-
return [];
|
|
42097
|
+
return [{ type: "session_recap_unavailable" }];
|
|
41379
42098
|
case "unknown":
|
|
41380
42099
|
return [];
|
|
41381
42100
|
default:
|
|
@@ -41508,7 +42227,7 @@ function mapWorkflowPhases(raw) {
|
|
|
41508
42227
|
if (!raw?.length) return [];
|
|
41509
42228
|
const out = [];
|
|
41510
42229
|
for (const item of raw) {
|
|
41511
|
-
const p2 =
|
|
42230
|
+
const p2 = asRecord8(item);
|
|
41512
42231
|
if (!p2) continue;
|
|
41513
42232
|
const title = strField(p2, "title");
|
|
41514
42233
|
if (!title) continue;
|
|
@@ -41521,7 +42240,7 @@ function mapWorkflowAgents(raw) {
|
|
|
41521
42240
|
if (!raw?.length) return [];
|
|
41522
42241
|
const out = [];
|
|
41523
42242
|
for (const item of raw) {
|
|
41524
|
-
const a =
|
|
42243
|
+
const a = asRecord8(item);
|
|
41525
42244
|
if (!a) continue;
|
|
41526
42245
|
const agentId = strField(a, "agent_id", "agentId");
|
|
41527
42246
|
const label = strField(a, "label") ?? agentId ?? "agent";
|
|
@@ -41547,7 +42266,7 @@ function buildWorkflowPhaseSummary(u, currentPhase, pauseMessage, lastEvent, las
|
|
|
41547
42266
|
const phaseBits = [];
|
|
41548
42267
|
if (phases?.length) {
|
|
41549
42268
|
for (const p2 of phases) {
|
|
41550
|
-
const ph =
|
|
42269
|
+
const ph = asRecord8(p2);
|
|
41551
42270
|
if (!ph) continue;
|
|
41552
42271
|
const title = strField(ph, "title") ?? "?";
|
|
41553
42272
|
const state = strField(ph, "state") ?? "";
|
|
@@ -41689,7 +42408,7 @@ function mapTaskBackgrounded(u, state) {
|
|
|
41689
42408
|
}];
|
|
41690
42409
|
}
|
|
41691
42410
|
function mapTaskCompleted(u, state) {
|
|
41692
|
-
const snapshot =
|
|
42411
|
+
const snapshot = asRecord8(u.task_snapshot) ?? asRecord8(u.taskSnapshot) ?? u;
|
|
41693
42412
|
const taskId = strField(snapshot, "task_id", "taskId");
|
|
41694
42413
|
if (!taskId) return [];
|
|
41695
42414
|
const known = state.bgTaskById.get(taskId);
|
|
@@ -41892,9 +42611,55 @@ function noteContextWindow(state, maxTokens) {
|
|
|
41892
42611
|
function uncachedPromptInputTokens(fullInput, cachedRead) {
|
|
41893
42612
|
return Math.max(0, fullInput - cachedRead);
|
|
41894
42613
|
}
|
|
42614
|
+
function messageUsageFromTurnTokens(state, ctx, tokens) {
|
|
42615
|
+
const messageId = ctx.messageId ?? state.lastMessageId;
|
|
42616
|
+
if (!messageId) return null;
|
|
42617
|
+
if (tokens.input <= 0 && tokens.output <= 0 && tokens.cacheRead <= 0) return null;
|
|
42618
|
+
const prev = state.lastUsage;
|
|
42619
|
+
const contextTokens = prev?.totalTokens && prev.totalTokens > 0 ? prev.totalTokens : 0;
|
|
42620
|
+
const maxTokens = prev?.maxTokens && prev.maxTokens > 0 ? prev.maxTokens : 0;
|
|
42621
|
+
return {
|
|
42622
|
+
type: "message_usage",
|
|
42623
|
+
messageId,
|
|
42624
|
+
inputTokens: tokens.input,
|
|
42625
|
+
outputTokens: tokens.output,
|
|
42626
|
+
...tokens.cacheRead > 0 ? { cacheReadTokens: tokens.cacheRead } : {},
|
|
42627
|
+
...contextTokens > 0 ? { contextTokens } : {},
|
|
42628
|
+
...maxTokens > 0 ? { contextWindow: maxTokens } : {}
|
|
42629
|
+
};
|
|
42630
|
+
}
|
|
42631
|
+
function mapResponseStarted(u, state, ctx) {
|
|
42632
|
+
const input = numField(u, "inputTokens", "input_tokens") ?? 0;
|
|
42633
|
+
const cacheRead = numField(u, "cacheReadInputTokens", "cache_read_input_tokens") ?? 0;
|
|
42634
|
+
const provisional = {
|
|
42635
|
+
input: state.turnTokens.input + input,
|
|
42636
|
+
output: state.turnTokens.output,
|
|
42637
|
+
cacheRead: state.turnTokens.cacheRead + cacheRead
|
|
42638
|
+
};
|
|
42639
|
+
const event = messageUsageFromTurnTokens(state, ctx, provisional);
|
|
42640
|
+
return event ? [event] : [];
|
|
42641
|
+
}
|
|
42642
|
+
function mapResponseCompleted(u, state, ctx) {
|
|
42643
|
+
const usageRaw = asRecord8(u.usage) ?? u;
|
|
42644
|
+
const input = numField(usageRaw, "inputTokens", "input_tokens") ?? 0;
|
|
42645
|
+
const output = numField(usageRaw, "outputTokens", "output_tokens") ?? 0;
|
|
42646
|
+
const cacheRead = numField(usageRaw, "cacheReadInputTokens", "cache_read_input_tokens") ?? 0;
|
|
42647
|
+
if (input <= 0 && output <= 0 && cacheRead <= 0) return [];
|
|
42648
|
+
state.turnTokens = {
|
|
42649
|
+
input: state.turnTokens.input + input,
|
|
42650
|
+
output: state.turnTokens.output + output,
|
|
42651
|
+
cacheRead: state.turnTokens.cacheRead + cacheRead
|
|
42652
|
+
};
|
|
42653
|
+
const event = messageUsageFromTurnTokens(state, ctx, state.turnTokens);
|
|
42654
|
+
return event ? [event] : [];
|
|
42655
|
+
}
|
|
41895
42656
|
function mapTurnCompleted(u, state, ctx) {
|
|
41896
|
-
const
|
|
41897
|
-
|
|
42657
|
+
const events = mapTurnStopReason(u, state);
|
|
42658
|
+
const usageRaw = asRecord8(u.usage);
|
|
42659
|
+
if (!usageRaw) {
|
|
42660
|
+
resetTurnTokens(state);
|
|
42661
|
+
return events;
|
|
42662
|
+
}
|
|
41898
42663
|
const fullInput = numField(usageRaw, "inputTokens", "input_tokens") ?? 0;
|
|
41899
42664
|
const cachedRead = numField(usageRaw, "cachedReadTokens", "cached_read_tokens") ?? 0;
|
|
41900
42665
|
const uncachedInput = uncachedPromptInputTokens(fullInput, cachedRead);
|
|
@@ -41917,18 +42682,39 @@ function mapTurnCompleted(u, state, ctx) {
|
|
|
41917
42682
|
model: prev?.model ?? ""
|
|
41918
42683
|
};
|
|
41919
42684
|
}
|
|
42685
|
+
state.turnTokens = {
|
|
42686
|
+
input: uncachedInput,
|
|
42687
|
+
output: outputTokens,
|
|
42688
|
+
cacheRead: cachedRead
|
|
42689
|
+
};
|
|
41920
42690
|
const messageId = ctx.messageId ?? state.lastMessageId;
|
|
41921
|
-
if (
|
|
41922
|
-
|
|
41923
|
-
|
|
41924
|
-
|
|
41925
|
-
|
|
41926
|
-
|
|
41927
|
-
|
|
41928
|
-
|
|
41929
|
-
|
|
41930
|
-
|
|
41931
|
-
|
|
42691
|
+
if (messageId) {
|
|
42692
|
+
events.push({
|
|
42693
|
+
type: "message_usage",
|
|
42694
|
+
messageId,
|
|
42695
|
+
// Footer: this-turn new spend (exclude cache hits).
|
|
42696
|
+
inputTokens: uncachedInput,
|
|
42697
|
+
outputTokens,
|
|
42698
|
+
...cachedRead > 0 ? { cacheReadTokens: cachedRead } : {},
|
|
42699
|
+
...contextTokens > 0 ? { contextTokens } : {},
|
|
42700
|
+
...maxTokens > 0 ? { contextWindow: maxTokens } : {},
|
|
42701
|
+
...costUsd != null ? { costUsd } : {}
|
|
42702
|
+
});
|
|
42703
|
+
}
|
|
42704
|
+
resetTurnTokens(state);
|
|
42705
|
+
return events;
|
|
42706
|
+
}
|
|
42707
|
+
function mapTurnStopReason(u, state) {
|
|
42708
|
+
const stopReason = strField(u, "stopReason", "stop_reason");
|
|
42709
|
+
if (stopReason === "rate_limit") {
|
|
42710
|
+
state.rateLimited = true;
|
|
42711
|
+
return [{ type: "rate_limit", status: "rejected", rateLimitType: "api" }];
|
|
42712
|
+
}
|
|
42713
|
+
if (stopReason === "end_turn" && state.rateLimited) {
|
|
42714
|
+
state.rateLimited = false;
|
|
42715
|
+
return [{ type: "rate_limit", status: "allowed" }];
|
|
42716
|
+
}
|
|
42717
|
+
return [];
|
|
41932
42718
|
}
|
|
41933
42719
|
function mapAutoCompactStarted(u) {
|
|
41934
42720
|
void u;
|
|
@@ -42036,7 +42822,7 @@ function mapModelAutoSwitched(u) {
|
|
|
42036
42822
|
];
|
|
42037
42823
|
}
|
|
42038
42824
|
function mapRetryState(u) {
|
|
42039
|
-
const nested =
|
|
42825
|
+
const nested = asRecord8(u.retry_state) ?? asRecord8(u.retryState) ?? u;
|
|
42040
42826
|
const type = (strField(nested, "type") ?? "").toLowerCase();
|
|
42041
42827
|
if (type === "retrying") {
|
|
42042
42828
|
const attempt = numField(nested, "attempt") ?? 1;
|
|
@@ -42103,7 +42889,7 @@ function mapAutoRecoveryExhausted(u) {
|
|
|
42103
42889
|
}];
|
|
42104
42890
|
}
|
|
42105
42891
|
function mapFollowUps(u) {
|
|
42106
|
-
const meta3 =
|
|
42892
|
+
const meta3 = asRecord8(u._meta) ?? asRecord8(u.meta);
|
|
42107
42893
|
if (meta3 && meta3["x.ai/replayed"] === true) return [];
|
|
42108
42894
|
const responseId = strField(u, "response_id", "responseId");
|
|
42109
42895
|
if (!responseId || responseId.length > 128) return [];
|
|
@@ -42112,7 +42898,7 @@ function mapFollowUps(u) {
|
|
|
42112
42898
|
let count = 0;
|
|
42113
42899
|
for (const s2 of suggestions) {
|
|
42114
42900
|
if (count >= 6) break;
|
|
42115
|
-
const rec =
|
|
42901
|
+
const rec = asRecord8(s2);
|
|
42116
42902
|
const label = (rec ? strField(rec, "label") : typeof s2 === "string" ? s2 : void 0)?.trim();
|
|
42117
42903
|
if (!label) continue;
|
|
42118
42904
|
const cleaned = label.replace(/[\u0000-\u001f\u007f]/g, "").slice(0, 256).trim();
|
|
@@ -49647,7 +50433,7 @@ var init_harness_runners = __esm({
|
|
|
49647
50433
|
});
|
|
49648
50434
|
|
|
49649
50435
|
// src/session/codex-live-turn.ts
|
|
49650
|
-
function
|
|
50436
|
+
function asRecord9(value) {
|
|
49651
50437
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
49652
50438
|
}
|
|
49653
50439
|
function readString4(value) {
|
|
@@ -49678,7 +50464,7 @@ function extractAgentTextFromTurn2(turn) {
|
|
|
49678
50464
|
let text = "";
|
|
49679
50465
|
const items = Array.isArray(turn.items) ? turn.items : [];
|
|
49680
50466
|
for (const item of items) {
|
|
49681
|
-
const rec =
|
|
50467
|
+
const rec = asRecord9(item);
|
|
49682
50468
|
if (!rec) continue;
|
|
49683
50469
|
if (readString4(rec.type) === "agentMessage" || readString4(rec.itemType) === "agentMessage") {
|
|
49684
50470
|
const t = readString4(rec.text);
|
|
@@ -49713,7 +50499,7 @@ async function openTurnAndStream(opts) {
|
|
|
49713
50499
|
...collaborationMode ? { collaborationMode } : {}
|
|
49714
50500
|
})
|
|
49715
50501
|
);
|
|
49716
|
-
const turn =
|
|
50502
|
+
const turn = asRecord9(turnStartResult.turn);
|
|
49717
50503
|
const turnId = readString4(turn?.id);
|
|
49718
50504
|
opts.onTurnStarted?.(turnId);
|
|
49719
50505
|
let finalText = "";
|
|
@@ -49741,7 +50527,7 @@ async function openTurnAndStream(opts) {
|
|
|
49741
50527
|
continue;
|
|
49742
50528
|
}
|
|
49743
50529
|
if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
|
|
49744
|
-
const completedTurn =
|
|
50530
|
+
const completedTurn = asRecord9(note.params.turn);
|
|
49745
50531
|
const completedId = readString4(completedTurn?.id);
|
|
49746
50532
|
if (turnId && completedId && completedId !== turnId) continue;
|
|
49747
50533
|
}
|
|
@@ -49749,14 +50535,14 @@ async function openTurnAndStream(opts) {
|
|
|
49749
50535
|
const applied = agentEventMapper.apply(note);
|
|
49750
50536
|
if (applied.textDelta) finalText += applied.textDelta;
|
|
49751
50537
|
} else if (note.method === "item/agentMessage/delta" || note.method === "item/agentMessageDelta") {
|
|
49752
|
-
const delta = readString4(note.params.delta) ?? readString4(note.params.text) ?? readString4(
|
|
50538
|
+
const delta = readString4(note.params.delta) ?? readString4(note.params.text) ?? readString4(asRecord9(note.params.item)?.delta);
|
|
49753
50539
|
if (delta) {
|
|
49754
50540
|
finalText += delta;
|
|
49755
50541
|
opts.onDelta?.(delta);
|
|
49756
50542
|
}
|
|
49757
50543
|
}
|
|
49758
50544
|
if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
|
|
49759
|
-
const completedTurn =
|
|
50545
|
+
const completedTurn = asRecord9(note.params.turn);
|
|
49760
50546
|
const status = readString4(completedTurn?.status) ?? readString4(note.params.status);
|
|
49761
50547
|
if (status === "failed" || status === "error") {
|
|
49762
50548
|
throw new Error("Codex turn failed");
|
|
@@ -50024,6 +50810,7 @@ function createProductionTurnRunner(opts) {
|
|
|
50024
50810
|
queryFn: opts.claudeQueryFn,
|
|
50025
50811
|
allowSimulatedFallback: opts.allowSimulatedFallback,
|
|
50026
50812
|
providers: opts.providers,
|
|
50813
|
+
experimentalClaudeOpenAiChatEnabled: opts.experimentalClaudeOpenAiChatEnabled,
|
|
50027
50814
|
createHostActionClaudeMcp: opts.createHostActionClaudeMcp,
|
|
50028
50815
|
mcpMergeMode: opts.mcpMergeMode,
|
|
50029
50816
|
homeDir: opts.homeDir
|
|
@@ -57444,8 +58231,8 @@ import { fileURLToPath } from "node:url";
|
|
|
57444
58231
|
function resolveCliReleaseVersion() {
|
|
57445
58232
|
const fromEnv = process.env.SUPERONE_CLI_VERSION?.trim();
|
|
57446
58233
|
if (fromEnv) return fromEnv;
|
|
57447
|
-
if ("0.
|
|
57448
|
-
return "0.
|
|
58234
|
+
if ("0.51.1-alpha".trim()) {
|
|
58235
|
+
return "0.51.1-alpha".trim();
|
|
57449
58236
|
}
|
|
57450
58237
|
const fromDist = readDistManifestVersion();
|
|
57451
58238
|
if (fromDist) return fromDist;
|
|
@@ -58316,6 +59103,7 @@ function openNodeDatabase(dbPath) {
|
|
|
58316
59103
|
mkdirSync2(dirname3(dbPath), { recursive: true });
|
|
58317
59104
|
const db = new Database(dbPath);
|
|
58318
59105
|
db.pragma("journal_mode = WAL");
|
|
59106
|
+
db.pragma("busy_timeout = 5000");
|
|
58319
59107
|
db.pragma("foreign_keys = ON");
|
|
58320
59108
|
db.exec(SCHEMA_SQL);
|
|
58321
59109
|
ensureSessionUiColumns(db);
|
|
@@ -58606,7 +59394,7 @@ var DEFAULT_NODE_AGENT_SETTINGS = {
|
|
|
58606
59394
|
defaultEffort: "",
|
|
58607
59395
|
permissionPreset: ""
|
|
58608
59396
|
},
|
|
58609
|
-
|
|
59397
|
+
experimentalClaudeOpenAiChatEnabled: false
|
|
58610
59398
|
};
|
|
58611
59399
|
function asString(value, fallback) {
|
|
58612
59400
|
return typeof value === "string" ? value : fallback;
|
|
@@ -58648,8 +59436,8 @@ function normalizeNodeAgentSettings(raw) {
|
|
|
58648
59436
|
return {
|
|
58649
59437
|
claude: normalizeClaude(agent.claude),
|
|
58650
59438
|
codex: normalizeCodex(agent.codex),
|
|
58651
|
-
|
|
58652
|
-
agent.
|
|
59439
|
+
experimentalClaudeOpenAiChatEnabled: asBoolean(
|
|
59440
|
+
agent.experimentalClaudeOpenAiChatEnabled,
|
|
58653
59441
|
false
|
|
58654
59442
|
)
|
|
58655
59443
|
};
|
|
@@ -58658,7 +59446,7 @@ function mergeNodeAgentSettings(current, patch) {
|
|
|
58658
59446
|
const next = {
|
|
58659
59447
|
claude: { ...current.claude },
|
|
58660
59448
|
codex: { ...current.codex },
|
|
58661
|
-
|
|
59449
|
+
experimentalClaudeOpenAiChatEnabled: current.experimentalClaudeOpenAiChatEnabled
|
|
58662
59450
|
};
|
|
58663
59451
|
if (patch.claude) {
|
|
58664
59452
|
if (typeof patch.claude.defaultModel === "string") {
|
|
@@ -58692,8 +59480,8 @@ function mergeNodeAgentSettings(current, patch) {
|
|
|
58692
59480
|
}
|
|
58693
59481
|
}
|
|
58694
59482
|
}
|
|
58695
|
-
if (typeof patch.
|
|
58696
|
-
next.
|
|
59483
|
+
if (typeof patch.experimentalClaudeOpenAiChatEnabled === "boolean") {
|
|
59484
|
+
next.experimentalClaudeOpenAiChatEnabled = patch.experimentalClaudeOpenAiChatEnabled;
|
|
58697
59485
|
}
|
|
58698
59486
|
return normalizeNodeAgentSettings(next);
|
|
58699
59487
|
}
|
|
@@ -58712,7 +59500,7 @@ function readConfigFile(path) {
|
|
|
58712
59500
|
function loadNodeAgentSettings(configPath) {
|
|
58713
59501
|
const file2 = readConfigFile(configPath);
|
|
58714
59502
|
if (file2.agent) return normalizeNodeAgentSettings(file2.agent);
|
|
58715
|
-
if (file2.claude || file2.codex || typeof file2.
|
|
59503
|
+
if (file2.claude || file2.codex || typeof file2.experimentalClaudeOpenAiChatEnabled === "boolean") {
|
|
58716
59504
|
return normalizeNodeAgentSettings(file2);
|
|
58717
59505
|
}
|
|
58718
59506
|
return { ...DEFAULT_NODE_AGENT_SETTINGS, claude: { ...DEFAULT_NODE_AGENT_SETTINGS.claude, disabledSkills: [] }, codex: { ...DEFAULT_NODE_AGENT_SETTINGS.codex } };
|
|
@@ -59841,7 +60629,7 @@ function requireResourceWrite(client3, scope) {
|
|
|
59841
60629
|
if (scope === "user") return requireScopes(client3, OPERATION_SCOPES.adminNode);
|
|
59842
60630
|
return null;
|
|
59843
60631
|
}
|
|
59844
|
-
function
|
|
60632
|
+
function asRecord10(payload) {
|
|
59845
60633
|
return payload && typeof payload === "object" ? payload : {};
|
|
59846
60634
|
}
|
|
59847
60635
|
function mapThrown(err) {
|
|
@@ -59870,7 +60658,7 @@ function manageOpts(ctx) {
|
|
|
59870
60658
|
function handleSkillsList(payload, ctx) {
|
|
59871
60659
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
59872
60660
|
if (denied) return denied;
|
|
59873
|
-
const p2 =
|
|
60661
|
+
const p2 = asRecord10(payload);
|
|
59874
60662
|
try {
|
|
59875
60663
|
const projectId = String(p2.projectId ?? "");
|
|
59876
60664
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -59890,7 +60678,7 @@ function handleSkillsList(payload, ctx) {
|
|
|
59890
60678
|
function handleSkillsGet(payload, ctx) {
|
|
59891
60679
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
59892
60680
|
if (denied) return denied;
|
|
59893
|
-
const p2 =
|
|
60681
|
+
const p2 = asRecord10(payload);
|
|
59894
60682
|
try {
|
|
59895
60683
|
const projectId = String(p2.projectId ?? "");
|
|
59896
60684
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -59915,7 +60703,7 @@ function handleSkillsGet(payload, ctx) {
|
|
|
59915
60703
|
function handleSkillsReadFile(payload, ctx) {
|
|
59916
60704
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
59917
60705
|
if (denied) return denied;
|
|
59918
|
-
const p2 =
|
|
60706
|
+
const p2 = asRecord10(payload);
|
|
59919
60707
|
try {
|
|
59920
60708
|
const projectId = String(p2.projectId ?? "");
|
|
59921
60709
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -59949,7 +60737,7 @@ function handleSkillsReadFile(payload, ctx) {
|
|
|
59949
60737
|
function handleSkillsDelete(payload, ctx) {
|
|
59950
60738
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
59951
60739
|
if (denied) return denied;
|
|
59952
|
-
const p2 =
|
|
60740
|
+
const p2 = asRecord10(payload);
|
|
59953
60741
|
try {
|
|
59954
60742
|
const projectId = String(p2.projectId ?? "");
|
|
59955
60743
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -59974,7 +60762,7 @@ function handleSkillsDelete(payload, ctx) {
|
|
|
59974
60762
|
function handleSkillsInstall(payload, ctx) {
|
|
59975
60763
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
59976
60764
|
if (baseDenied) return baseDenied;
|
|
59977
|
-
const p2 =
|
|
60765
|
+
const p2 = asRecord10(payload);
|
|
59978
60766
|
try {
|
|
59979
60767
|
const projectId = String(p2.projectId ?? "");
|
|
59980
60768
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -60008,7 +60796,7 @@ function handleSkillsInstall(payload, ctx) {
|
|
|
60008
60796
|
function handleMcpList(payload, ctx) {
|
|
60009
60797
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
60010
60798
|
if (denied) return denied;
|
|
60011
|
-
const p2 =
|
|
60799
|
+
const p2 = asRecord10(payload);
|
|
60012
60800
|
try {
|
|
60013
60801
|
const projectId = String(p2.projectId ?? "");
|
|
60014
60802
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -60065,7 +60853,7 @@ function parseMcpWriteConfig(raw) {
|
|
|
60065
60853
|
function handleMcpSave(payload, ctx) {
|
|
60066
60854
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
60067
60855
|
if (baseDenied) return baseDenied;
|
|
60068
|
-
const p2 =
|
|
60856
|
+
const p2 = asRecord10(payload);
|
|
60069
60857
|
try {
|
|
60070
60858
|
const projectId = String(p2.projectId ?? "");
|
|
60071
60859
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -60095,7 +60883,7 @@ function handleMcpSave(payload, ctx) {
|
|
|
60095
60883
|
function handleMcpToggle(payload, ctx) {
|
|
60096
60884
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
60097
60885
|
if (baseDenied) return baseDenied;
|
|
60098
|
-
const p2 =
|
|
60886
|
+
const p2 = asRecord10(payload);
|
|
60099
60887
|
try {
|
|
60100
60888
|
const projectId = String(p2.projectId ?? "");
|
|
60101
60889
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -60126,7 +60914,7 @@ function handleMcpToggle(payload, ctx) {
|
|
|
60126
60914
|
function handleMcpDelete(payload, ctx) {
|
|
60127
60915
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
60128
60916
|
if (baseDenied) return baseDenied;
|
|
60129
|
-
const p2 =
|
|
60917
|
+
const p2 = asRecord10(payload);
|
|
60130
60918
|
try {
|
|
60131
60919
|
const projectId = String(p2.projectId ?? "");
|
|
60132
60920
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -60166,7 +60954,7 @@ function parseMarketplaceScope(raw) {
|
|
|
60166
60954
|
async function handlePluginsList(payload, ctx) {
|
|
60167
60955
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
60168
60956
|
if (denied) return denied;
|
|
60169
|
-
const p2 =
|
|
60957
|
+
const p2 = asRecord10(payload);
|
|
60170
60958
|
try {
|
|
60171
60959
|
const projectId = String(p2.projectId ?? "");
|
|
60172
60960
|
projectRoot(ctx.projects, projectId);
|
|
@@ -60213,7 +61001,7 @@ async function handlePluginsList(payload, ctx) {
|
|
|
60213
61001
|
function handlePluginsGet(payload, ctx) {
|
|
60214
61002
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
60215
61003
|
if (denied) return denied;
|
|
60216
|
-
const p2 =
|
|
61004
|
+
const p2 = asRecord10(payload);
|
|
60217
61005
|
try {
|
|
60218
61006
|
const projectId = String(p2.projectId ?? "");
|
|
60219
61007
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -60237,7 +61025,7 @@ function handlePluginsGet(payload, ctx) {
|
|
|
60237
61025
|
function handlePluginsReadFile(payload, ctx) {
|
|
60238
61026
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
60239
61027
|
if (denied) return denied;
|
|
60240
|
-
const p2 =
|
|
61028
|
+
const p2 = asRecord10(payload);
|
|
60241
61029
|
try {
|
|
60242
61030
|
const projectId = String(p2.projectId ?? "");
|
|
60243
61031
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -60265,7 +61053,7 @@ function handlePluginsReadFile(payload, ctx) {
|
|
|
60265
61053
|
function handlePluginsDelete(payload, ctx) {
|
|
60266
61054
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
60267
61055
|
if (baseDenied) return baseDenied;
|
|
60268
|
-
const p2 =
|
|
61056
|
+
const p2 = asRecord10(payload);
|
|
60269
61057
|
try {
|
|
60270
61058
|
const projectId = String(p2.projectId ?? "");
|
|
60271
61059
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -60291,7 +61079,7 @@ function handlePluginsDelete(payload, ctx) {
|
|
|
60291
61079
|
async function handlePluginsInstall(payload, ctx) {
|
|
60292
61080
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
60293
61081
|
if (baseDenied) return baseDenied;
|
|
60294
|
-
const p2 =
|
|
61082
|
+
const p2 = asRecord10(payload);
|
|
60295
61083
|
try {
|
|
60296
61084
|
const projectId = String(p2.projectId ?? "");
|
|
60297
61085
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -60317,7 +61105,7 @@ async function handlePluginsInstall(payload, ctx) {
|
|
|
60317
61105
|
function handlePluginsUpdate(payload, ctx) {
|
|
60318
61106
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
60319
61107
|
if (baseDenied) return baseDenied;
|
|
60320
|
-
const p2 =
|
|
61108
|
+
const p2 = asRecord10(payload);
|
|
60321
61109
|
try {
|
|
60322
61110
|
const projectId = String(p2.projectId ?? "");
|
|
60323
61111
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -60343,7 +61131,7 @@ function handlePluginsUpdate(payload, ctx) {
|
|
|
60343
61131
|
function handlePluginsListMarketplace(payload, ctx) {
|
|
60344
61132
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
60345
61133
|
if (denied) return denied;
|
|
60346
|
-
const p2 =
|
|
61134
|
+
const p2 = asRecord10(payload);
|
|
60347
61135
|
try {
|
|
60348
61136
|
const projectId = String(p2.projectId ?? "");
|
|
60349
61137
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -60365,7 +61153,7 @@ function handlePluginsListMarketplace(payload, ctx) {
|
|
|
60365
61153
|
async function handlePluginsAddMarketplace(payload, ctx) {
|
|
60366
61154
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
60367
61155
|
if (baseDenied) return baseDenied;
|
|
60368
|
-
const p2 =
|
|
61156
|
+
const p2 = asRecord10(payload);
|
|
60369
61157
|
try {
|
|
60370
61158
|
const projectId = String(p2.projectId ?? "");
|
|
60371
61159
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -60391,7 +61179,7 @@ async function handlePluginsAddMarketplace(payload, ctx) {
|
|
|
60391
61179
|
async function handlePluginsRemoveMarketplace(payload, ctx) {
|
|
60392
61180
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
60393
61181
|
if (baseDenied) return baseDenied;
|
|
60394
|
-
const p2 =
|
|
61182
|
+
const p2 = asRecord10(payload);
|
|
60395
61183
|
try {
|
|
60396
61184
|
const projectId = String(p2.projectId ?? "");
|
|
60397
61185
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -60426,7 +61214,7 @@ async function handlePluginsUpdateMarketplace(payload, ctx) {
|
|
|
60426
61214
|
if (denied) return denied;
|
|
60427
61215
|
const adminDenied = requireScopes(ctx.client, OPERATION_SCOPES.adminNode);
|
|
60428
61216
|
if (adminDenied) return adminDenied;
|
|
60429
|
-
const p2 =
|
|
61217
|
+
const p2 = asRecord10(payload);
|
|
60430
61218
|
try {
|
|
60431
61219
|
const projectId = String(p2.projectId ?? "");
|
|
60432
61220
|
if (projectId) {
|
|
@@ -60448,7 +61236,7 @@ async function handlePluginsUpdateMarketplace(payload, ctx) {
|
|
|
60448
61236
|
function handlePluginsReadMarketplace(payload, ctx) {
|
|
60449
61237
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
60450
61238
|
if (denied) return denied;
|
|
60451
|
-
const p2 =
|
|
61239
|
+
const p2 = asRecord10(payload);
|
|
60452
61240
|
try {
|
|
60453
61241
|
const projectId = String(p2.projectId ?? "");
|
|
60454
61242
|
if (projectId) {
|
|
@@ -60479,7 +61267,7 @@ function handlePluginsReadMarketplace(payload, ctx) {
|
|
|
60479
61267
|
function handlePluginsReadMarketplaceFile(payload, ctx) {
|
|
60480
61268
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
60481
61269
|
if (denied) return denied;
|
|
60482
|
-
const p2 =
|
|
61270
|
+
const p2 = asRecord10(payload);
|
|
60483
61271
|
try {
|
|
60484
61272
|
const projectId = String(p2.projectId ?? "");
|
|
60485
61273
|
if (projectId) {
|
|
@@ -60513,7 +61301,7 @@ function handlePluginsReadMarketplaceFile(payload, ctx) {
|
|
|
60513
61301
|
function handleAgentsList(payload, ctx) {
|
|
60514
61302
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
60515
61303
|
if (denied) return denied;
|
|
60516
|
-
const p2 =
|
|
61304
|
+
const p2 = asRecord10(payload);
|
|
60517
61305
|
try {
|
|
60518
61306
|
const projectId = String(p2.projectId ?? "");
|
|
60519
61307
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -60530,7 +61318,7 @@ function handleAgentsList(payload, ctx) {
|
|
|
60530
61318
|
function handleAgentsReadFile(payload, ctx) {
|
|
60531
61319
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
60532
61320
|
if (denied) return denied;
|
|
60533
|
-
const p2 =
|
|
61321
|
+
const p2 = asRecord10(payload);
|
|
60534
61322
|
try {
|
|
60535
61323
|
const projectId = String(p2.projectId ?? "");
|
|
60536
61324
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -60562,7 +61350,7 @@ function parseHookSavePayload(raw) {
|
|
|
60562
61350
|
function handleHooksList(payload, ctx) {
|
|
60563
61351
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
60564
61352
|
if (denied) return denied;
|
|
60565
|
-
const p2 =
|
|
61353
|
+
const p2 = asRecord10(payload);
|
|
60566
61354
|
try {
|
|
60567
61355
|
const projectId = String(p2.projectId ?? "");
|
|
60568
61356
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -60575,7 +61363,7 @@ function handleHooksList(payload, ctx) {
|
|
|
60575
61363
|
function handleHooksSave(payload, ctx) {
|
|
60576
61364
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
60577
61365
|
if (baseDenied) return baseDenied;
|
|
60578
|
-
const p2 =
|
|
61366
|
+
const p2 = asRecord10(payload);
|
|
60579
61367
|
try {
|
|
60580
61368
|
const projectId = String(p2.projectId ?? "");
|
|
60581
61369
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -60603,7 +61391,7 @@ function handleHooksSave(payload, ctx) {
|
|
|
60603
61391
|
function handleHooksDelete(payload, ctx) {
|
|
60604
61392
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
60605
61393
|
if (baseDenied) return baseDenied;
|
|
60606
|
-
const p2 =
|
|
61394
|
+
const p2 = asRecord10(payload);
|
|
60607
61395
|
try {
|
|
60608
61396
|
const projectId = String(p2.projectId ?? "");
|
|
60609
61397
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -60702,7 +61490,7 @@ function requireScopes2(client3, scopes) {
|
|
|
60702
61490
|
}
|
|
60703
61491
|
return null;
|
|
60704
61492
|
}
|
|
60705
|
-
function
|
|
61493
|
+
function asRecord11(payload) {
|
|
60706
61494
|
return payload && typeof payload === "object" ? payload : {};
|
|
60707
61495
|
}
|
|
60708
61496
|
function mapThrown2(err) {
|
|
@@ -60768,7 +61556,7 @@ function parseSchedule(raw) {
|
|
|
60768
61556
|
function handleAutomationList(payload, ctx) {
|
|
60769
61557
|
const denied = requireScopes2(ctx.client, OPERATION_SCOPES.readSession);
|
|
60770
61558
|
if (denied) return denied;
|
|
60771
|
-
const p2 =
|
|
61559
|
+
const p2 = asRecord11(payload);
|
|
60772
61560
|
const projectId = String(p2.projectId ?? "").trim();
|
|
60773
61561
|
if (!projectId) {
|
|
60774
61562
|
return { error: { code: "invalid_argument", message: "projectId is required" } };
|
|
@@ -60787,7 +61575,7 @@ function handleAutomationList(payload, ctx) {
|
|
|
60787
61575
|
function handleAutomationCreate(payload, ctx) {
|
|
60788
61576
|
const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
|
|
60789
61577
|
if (denied) return denied;
|
|
60790
|
-
const p2 =
|
|
61578
|
+
const p2 = asRecord11(payload);
|
|
60791
61579
|
const projectId = String(p2.projectId ?? "").trim();
|
|
60792
61580
|
if (!projectId) {
|
|
60793
61581
|
return { error: { code: "invalid_argument", message: "projectId is required" } };
|
|
@@ -60824,7 +61612,7 @@ function handleAutomationCreate(payload, ctx) {
|
|
|
60824
61612
|
function handleAutomationUpdate(payload, ctx) {
|
|
60825
61613
|
const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
|
|
60826
61614
|
if (denied) return denied;
|
|
60827
|
-
const p2 =
|
|
61615
|
+
const p2 = asRecord11(payload);
|
|
60828
61616
|
const automationId = String(p2.automationId ?? p2.id ?? "").trim();
|
|
60829
61617
|
if (!automationId) {
|
|
60830
61618
|
return { error: { code: "invalid_argument", message: "automationId is required" } };
|
|
@@ -60868,7 +61656,7 @@ function handleAutomationUpdate(payload, ctx) {
|
|
|
60868
61656
|
function handleAutomationDelete(payload, ctx) {
|
|
60869
61657
|
const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
|
|
60870
61658
|
if (denied) return denied;
|
|
60871
|
-
const p2 =
|
|
61659
|
+
const p2 = asRecord11(payload);
|
|
60872
61660
|
const automationId = String(p2.automationId ?? p2.id ?? "").trim();
|
|
60873
61661
|
if (!automationId) {
|
|
60874
61662
|
return { error: { code: "invalid_argument", message: "automationId is required" } };
|
|
@@ -60894,7 +61682,7 @@ function handleAutomationDelete(payload, ctx) {
|
|
|
60894
61682
|
async function handleAutomationRunNow(payload, ctx) {
|
|
60895
61683
|
const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
|
|
60896
61684
|
if (denied) return denied;
|
|
60897
|
-
const p2 =
|
|
61685
|
+
const p2 = asRecord11(payload);
|
|
60898
61686
|
const automationId = String(p2.automationId ?? p2.id ?? "").trim();
|
|
60899
61687
|
if (!automationId) {
|
|
60900
61688
|
return { error: { code: "invalid_argument", message: "automationId is required" } };
|
|
@@ -60952,7 +61740,7 @@ function requireScopes3(client3, scopes) {
|
|
|
60952
61740
|
}
|
|
60953
61741
|
return null;
|
|
60954
61742
|
}
|
|
60955
|
-
function
|
|
61743
|
+
function asRecord12(payload) {
|
|
60956
61744
|
return payload && typeof payload === "object" ? payload : {};
|
|
60957
61745
|
}
|
|
60958
61746
|
function mapThrown3(err) {
|
|
@@ -61023,7 +61811,7 @@ var CODEX_MUTATING_METHODS = [
|
|
|
61023
61811
|
function handleGetAuthStatus(payload, ctx) {
|
|
61024
61812
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
61025
61813
|
if (denied) return denied;
|
|
61026
|
-
const p2 =
|
|
61814
|
+
const p2 = asRecord12(payload);
|
|
61027
61815
|
const projectId = projectIdOf(p2);
|
|
61028
61816
|
if (!projectId) {
|
|
61029
61817
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -61036,7 +61824,7 @@ function handleGetAuthStatus(payload, ctx) {
|
|
|
61036
61824
|
function handleSetAuth(payload, ctx) {
|
|
61037
61825
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.adminNode);
|
|
61038
61826
|
if (denied) return denied;
|
|
61039
|
-
const p2 =
|
|
61827
|
+
const p2 = asRecord12(payload);
|
|
61040
61828
|
const projectId = projectIdOf(p2);
|
|
61041
61829
|
if (!projectId) {
|
|
61042
61830
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -61061,7 +61849,7 @@ function handleSetAuth(payload, ctx) {
|
|
|
61061
61849
|
async function handleGetRateLimits(payload, ctx) {
|
|
61062
61850
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
61063
61851
|
if (denied) return denied;
|
|
61064
|
-
const p2 =
|
|
61852
|
+
const p2 = asRecord12(payload);
|
|
61065
61853
|
const projectId = projectIdOf(p2);
|
|
61066
61854
|
if (!projectId) {
|
|
61067
61855
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -61088,7 +61876,7 @@ async function handleGetRateLimits(payload, ctx) {
|
|
|
61088
61876
|
async function handleGetAccountUsage(payload, ctx) {
|
|
61089
61877
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
61090
61878
|
if (denied) return denied;
|
|
61091
|
-
const p2 =
|
|
61879
|
+
const p2 = asRecord12(payload);
|
|
61092
61880
|
const projectId = projectIdOf(p2);
|
|
61093
61881
|
if (!projectId) {
|
|
61094
61882
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -61115,7 +61903,7 @@ async function handleGetAccountUsage(payload, ctx) {
|
|
|
61115
61903
|
async function handleConsumeRateLimitReset(payload, ctx) {
|
|
61116
61904
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.adminNode);
|
|
61117
61905
|
if (denied) return denied;
|
|
61118
|
-
const p2 =
|
|
61906
|
+
const p2 = asRecord12(payload);
|
|
61119
61907
|
const projectId = projectIdOf(p2);
|
|
61120
61908
|
if (!projectId) {
|
|
61121
61909
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -61145,7 +61933,7 @@ async function handleConsumeRateLimitReset(payload, ctx) {
|
|
|
61145
61933
|
async function handleLoginMcpOauth(payload, ctx) {
|
|
61146
61934
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.adminNode);
|
|
61147
61935
|
if (denied) return denied;
|
|
61148
|
-
const p2 =
|
|
61936
|
+
const p2 = asRecord12(payload);
|
|
61149
61937
|
const projectId = projectIdOf(p2);
|
|
61150
61938
|
const serverName = String(p2.serverName ?? p2.name ?? "").trim();
|
|
61151
61939
|
if (!projectId || !serverName) {
|
|
@@ -61165,7 +61953,7 @@ async function handleLoginMcpOauth(payload, ctx) {
|
|
|
61165
61953
|
async function handleDetectExternalAgent(payload, ctx) {
|
|
61166
61954
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
61167
61955
|
if (denied) return denied;
|
|
61168
|
-
const p2 =
|
|
61956
|
+
const p2 = asRecord12(payload);
|
|
61169
61957
|
const projectId = projectIdOf(p2);
|
|
61170
61958
|
if (!projectId) {
|
|
61171
61959
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -61184,7 +61972,7 @@ async function handleDetectExternalAgent(payload, ctx) {
|
|
|
61184
61972
|
async function handleImportExternalAgent(payload, ctx) {
|
|
61185
61973
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.adminNode);
|
|
61186
61974
|
if (denied) return denied;
|
|
61187
|
-
const p2 =
|
|
61975
|
+
const p2 = asRecord12(payload);
|
|
61188
61976
|
const projectId = projectIdOf(p2);
|
|
61189
61977
|
if (!projectId) {
|
|
61190
61978
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -61202,7 +61990,7 @@ async function handleImportExternalAgent(payload, ctx) {
|
|
|
61202
61990
|
async function handlePluginsList2(payload, ctx) {
|
|
61203
61991
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
61204
61992
|
if (denied) return denied;
|
|
61205
|
-
const p2 =
|
|
61993
|
+
const p2 = asRecord12(payload);
|
|
61206
61994
|
const projectId = projectIdOf(p2);
|
|
61207
61995
|
if (!projectId) {
|
|
61208
61996
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -61225,7 +62013,7 @@ async function handlePluginsList2(payload, ctx) {
|
|
|
61225
62013
|
async function handlePluginsInstall2(payload, ctx) {
|
|
61226
62014
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.adminNode);
|
|
61227
62015
|
if (denied) return denied;
|
|
61228
|
-
const p2 =
|
|
62016
|
+
const p2 = asRecord12(payload);
|
|
61229
62017
|
const projectId = projectIdOf(p2);
|
|
61230
62018
|
const key = String(p2.key ?? p2.pluginId ?? "").trim();
|
|
61231
62019
|
if (!projectId || !key) {
|
|
@@ -61241,7 +62029,7 @@ async function handlePluginsInstall2(payload, ctx) {
|
|
|
61241
62029
|
async function handlePluginsUninstall(payload, ctx) {
|
|
61242
62030
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.adminNode);
|
|
61243
62031
|
if (denied) return denied;
|
|
61244
|
-
const p2 =
|
|
62032
|
+
const p2 = asRecord12(payload);
|
|
61245
62033
|
const projectId = projectIdOf(p2);
|
|
61246
62034
|
const key = String(p2.key ?? p2.pluginId ?? "").trim();
|
|
61247
62035
|
if (!projectId || !key) {
|
|
@@ -61257,7 +62045,7 @@ async function handlePluginsUninstall(payload, ctx) {
|
|
|
61257
62045
|
async function handleMarketplaceAdd(payload, ctx) {
|
|
61258
62046
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.adminNode);
|
|
61259
62047
|
if (denied) return denied;
|
|
61260
|
-
const p2 =
|
|
62048
|
+
const p2 = asRecord12(payload);
|
|
61261
62049
|
const projectId = projectIdOf(p2);
|
|
61262
62050
|
const source = String(p2.source ?? "").trim();
|
|
61263
62051
|
if (!projectId || !source) {
|
|
@@ -61286,7 +62074,7 @@ async function handleMarketplaceAdd(payload, ctx) {
|
|
|
61286
62074
|
async function handleMarketplaceRemove(payload, ctx) {
|
|
61287
62075
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.adminNode);
|
|
61288
62076
|
if (denied) return denied;
|
|
61289
|
-
const p2 =
|
|
62077
|
+
const p2 = asRecord12(payload);
|
|
61290
62078
|
const projectId = projectIdOf(p2);
|
|
61291
62079
|
const marketplaceName = String(p2.marketplaceName ?? p2.name ?? "").trim();
|
|
61292
62080
|
if (!projectId || !marketplaceName) {
|
|
@@ -61309,7 +62097,7 @@ async function handleMarketplaceRemove(payload, ctx) {
|
|
|
61309
62097
|
async function handleMarketplaceUpgrade(payload, ctx) {
|
|
61310
62098
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.adminNode);
|
|
61311
62099
|
if (denied) return denied;
|
|
61312
|
-
const p2 =
|
|
62100
|
+
const p2 = asRecord12(payload);
|
|
61313
62101
|
const projectId = projectIdOf(p2);
|
|
61314
62102
|
if (!projectId) {
|
|
61315
62103
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -61342,7 +62130,7 @@ function requireScopes4(client3, scopes) {
|
|
|
61342
62130
|
}
|
|
61343
62131
|
return null;
|
|
61344
62132
|
}
|
|
61345
|
-
function
|
|
62133
|
+
function asRecord13(payload) {
|
|
61346
62134
|
return payload && typeof payload === "object" ? payload : {};
|
|
61347
62135
|
}
|
|
61348
62136
|
function mapThrown4(err) {
|
|
@@ -61371,7 +62159,7 @@ function dispatchSessionProviderRpc(method, payload, ctx) {
|
|
|
61371
62159
|
function handleList(payload, ctx) {
|
|
61372
62160
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
61373
62161
|
if (denied) return denied;
|
|
61374
|
-
const p2 =
|
|
62162
|
+
const p2 = asRecord13(payload);
|
|
61375
62163
|
try {
|
|
61376
62164
|
const harnessId = typeof p2.harnessId === "string" && p2.harnessId.trim() ? p2.harnessId.trim() : null;
|
|
61377
62165
|
const providers = harnessId ? ctx.sessionProviders.listByHarness(harnessId) : ctx.sessionProviders.list();
|
|
@@ -61383,7 +62171,7 @@ function handleList(payload, ctx) {
|
|
|
61383
62171
|
function handleGet(payload, ctx) {
|
|
61384
62172
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
61385
62173
|
if (denied) return denied;
|
|
61386
|
-
const p2 =
|
|
62174
|
+
const p2 = asRecord13(payload);
|
|
61387
62175
|
const id = String(p2.id ?? "");
|
|
61388
62176
|
if (!id) return { error: { code: "invalid_argument", message: "id required" } };
|
|
61389
62177
|
try {
|
|
@@ -61395,7 +62183,7 @@ function handleGet(payload, ctx) {
|
|
|
61395
62183
|
function handleGetBase(payload, ctx) {
|
|
61396
62184
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
61397
62185
|
if (denied) return denied;
|
|
61398
|
-
const p2 =
|
|
62186
|
+
const p2 = asRecord13(payload);
|
|
61399
62187
|
const harnessId = String(p2.harnessId ?? "");
|
|
61400
62188
|
if (!harnessId) return { error: { code: "invalid_argument", message: "harnessId required" } };
|
|
61401
62189
|
try {
|
|
@@ -61407,7 +62195,7 @@ function handleGetBase(payload, ctx) {
|
|
|
61407
62195
|
function handleCreate(payload, ctx) {
|
|
61408
62196
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
61409
62197
|
if (denied) return denied;
|
|
61410
|
-
const p2 =
|
|
62198
|
+
const p2 = asRecord13(payload);
|
|
61411
62199
|
try {
|
|
61412
62200
|
const provider = ctx.sessionProviders.create({
|
|
61413
62201
|
harnessId: String(p2.harnessId ?? ""),
|
|
@@ -61423,7 +62211,7 @@ function handleCreate(payload, ctx) {
|
|
|
61423
62211
|
function handleUpdate(payload, ctx) {
|
|
61424
62212
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
61425
62213
|
if (denied) return denied;
|
|
61426
|
-
const p2 =
|
|
62214
|
+
const p2 = asRecord13(payload);
|
|
61427
62215
|
const id = String(p2.id ?? "");
|
|
61428
62216
|
if (!id) return { error: { code: "invalid_argument", message: "id required" } };
|
|
61429
62217
|
try {
|
|
@@ -61439,7 +62227,7 @@ function handleUpdate(payload, ctx) {
|
|
|
61439
62227
|
function handleDelete(payload, ctx) {
|
|
61440
62228
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
61441
62229
|
if (denied) return denied;
|
|
61442
|
-
const p2 =
|
|
62230
|
+
const p2 = asRecord13(payload);
|
|
61443
62231
|
const id = String(p2.id ?? "");
|
|
61444
62232
|
if (!id) return { error: { code: "invalid_argument", message: "id required" } };
|
|
61445
62233
|
try {
|
|
@@ -61480,7 +62268,7 @@ function requireScopes5(client3, scopes) {
|
|
|
61480
62268
|
}
|
|
61481
62269
|
return null;
|
|
61482
62270
|
}
|
|
61483
|
-
function
|
|
62271
|
+
function asRecord14(payload) {
|
|
61484
62272
|
return payload && typeof payload === "object" ? payload : {};
|
|
61485
62273
|
}
|
|
61486
62274
|
function defaultProbeModels(ctx) {
|
|
@@ -61508,7 +62296,7 @@ async function dispatchHarnessResourcesRpc(method, payload, ctx) {
|
|
|
61508
62296
|
async function handleHarnessResources(payload, ctx) {
|
|
61509
62297
|
const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
61510
62298
|
if (denied) return denied;
|
|
61511
|
-
const p2 =
|
|
62299
|
+
const p2 = asRecord14(payload);
|
|
61512
62300
|
const projectId = String(p2.projectId ?? "");
|
|
61513
62301
|
if (!projectId) {
|
|
61514
62302
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -61523,8 +62311,16 @@ async function handleHarnessResources(payload, ctx) {
|
|
|
61523
62311
|
ctx.projects.touch(projectId);
|
|
61524
62312
|
const harnessId = typeof p2.harnessId === "string" && p2.harnessId.trim() ? p2.harnessId.trim() : null;
|
|
61525
62313
|
const apiProviderId = typeof p2.apiProviderId === "string" && p2.apiProviderId.trim() ? p2.apiProviderId.trim() : p2.apiProviderId === null ? null : void 0;
|
|
62314
|
+
const providerOptions = {
|
|
62315
|
+
experimentalClaudeOpenAiChatEnabled: ctx.experimentalClaudeOpenAiChatEnabled ?? false
|
|
62316
|
+
};
|
|
61526
62317
|
const listModels = (hid, apiId) => {
|
|
61527
|
-
return listHarnessProviderModels(
|
|
62318
|
+
return listHarnessProviderModels(
|
|
62319
|
+
ctx.providers,
|
|
62320
|
+
hid,
|
|
62321
|
+
apiId ?? null,
|
|
62322
|
+
providerOptions
|
|
62323
|
+
);
|
|
61528
62324
|
};
|
|
61529
62325
|
const probeModels = async (hid) => {
|
|
61530
62326
|
const probe = ctx.probeModels ?? defaultProbeModels(ctx);
|
|
@@ -61533,7 +62329,12 @@ async function handleHarnessResources(payload, ctx) {
|
|
|
61533
62329
|
console.warn(
|
|
61534
62330
|
`[harness.resources] ${hid} probe returned no models; serving the built-in fallback table`
|
|
61535
62331
|
);
|
|
61536
|
-
return listHarnessModels(
|
|
62332
|
+
return listHarnessModels(
|
|
62333
|
+
ctx.providers,
|
|
62334
|
+
hid,
|
|
62335
|
+
apiProviderId ?? null,
|
|
62336
|
+
providerOptions
|
|
62337
|
+
);
|
|
61537
62338
|
};
|
|
61538
62339
|
const bundle = await collectHarnessResources({
|
|
61539
62340
|
projectPath: project.path,
|
|
@@ -61716,7 +62517,8 @@ async function dispatchRpcInner(method, payload, ctx) {
|
|
|
61716
62517
|
client: ctx.client,
|
|
61717
62518
|
projects: ctx.projects,
|
|
61718
62519
|
providers: ctx.providers,
|
|
61719
|
-
harnesses: ctx.harnesses
|
|
62520
|
+
harnesses: ctx.harnesses,
|
|
62521
|
+
experimentalClaudeOpenAiChatEnabled: loadNodeAgentSettings(ctx.settingsConfigPath).experimentalClaudeOpenAiChatEnabled
|
|
61720
62522
|
});
|
|
61721
62523
|
if (harnessResources) return harnessResources;
|
|
61722
62524
|
const codex = await dispatchCodexRpc(method, payload, {
|
|
@@ -61931,7 +62733,7 @@ function handleProviderListCredentials(ctx) {
|
|
|
61931
62733
|
function handleProviderGetCredentialDecrypted(payload, ctx) {
|
|
61932
62734
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.adminNode);
|
|
61933
62735
|
if (denied) return denied;
|
|
61934
|
-
const p2 =
|
|
62736
|
+
const p2 = asRecord15(payload);
|
|
61935
62737
|
const cred = ctx.providers.getCredentialDecrypted(String(p2.id ?? ""));
|
|
61936
62738
|
if (!cred) return { error: { code: "not_found", message: "credential not found" } };
|
|
61937
62739
|
return { result: cred };
|
|
@@ -61939,7 +62741,7 @@ function handleProviderGetCredentialDecrypted(payload, ctx) {
|
|
|
61939
62741
|
function handleProviderCreateCredential(payload, ctx) {
|
|
61940
62742
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.adminNode);
|
|
61941
62743
|
if (denied) return denied;
|
|
61942
|
-
const p2 =
|
|
62744
|
+
const p2 = asRecord15(payload);
|
|
61943
62745
|
try {
|
|
61944
62746
|
return {
|
|
61945
62747
|
result: ctx.providers.createCredential({
|
|
@@ -61961,7 +62763,7 @@ function handleProviderCreateCredential(payload, ctx) {
|
|
|
61961
62763
|
function handleProviderUpdateCredential(payload, ctx) {
|
|
61962
62764
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.adminNode);
|
|
61963
62765
|
if (denied) return denied;
|
|
61964
|
-
const p2 =
|
|
62766
|
+
const p2 = asRecord15(payload);
|
|
61965
62767
|
const id = String(p2.id ?? "");
|
|
61966
62768
|
const updated = ctx.providers.updateCredential(id, {
|
|
61967
62769
|
name: typeof p2.name === "string" ? p2.name : void 0,
|
|
@@ -61978,7 +62780,7 @@ function handleProviderUpdateCredential(payload, ctx) {
|
|
|
61978
62780
|
function handleProviderDeleteCredential(payload, ctx) {
|
|
61979
62781
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.adminNode);
|
|
61980
62782
|
if (denied) return denied;
|
|
61981
|
-
const p2 =
|
|
62783
|
+
const p2 = asRecord15(payload);
|
|
61982
62784
|
const ok = ctx.providers.deleteCredential(String(p2.id ?? ""));
|
|
61983
62785
|
if (!ok) return { error: { code: "not_found", message: "credential not found" } };
|
|
61984
62786
|
return { result: { ok: true } };
|
|
@@ -61991,7 +62793,7 @@ function handleProviderListBindings(ctx) {
|
|
|
61991
62793
|
function handleProviderSetBinding(payload, ctx) {
|
|
61992
62794
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.adminNode);
|
|
61993
62795
|
if (denied) return denied;
|
|
61994
|
-
const p2 =
|
|
62796
|
+
const p2 = asRecord15(payload);
|
|
61995
62797
|
const binding = p2;
|
|
61996
62798
|
if (!binding.consumer || !binding.credentialId) {
|
|
61997
62799
|
return { error: { code: "invalid_argument", message: "consumer and credentialId required" } };
|
|
@@ -62002,7 +62804,7 @@ function handleProviderSetBinding(payload, ctx) {
|
|
|
62002
62804
|
function handleProviderClearBinding(payload, ctx) {
|
|
62003
62805
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.adminNode);
|
|
62004
62806
|
if (denied) return denied;
|
|
62005
|
-
const p2 =
|
|
62807
|
+
const p2 = asRecord15(payload);
|
|
62006
62808
|
ctx.providers.clearBinding(String(p2.consumer ?? ""));
|
|
62007
62809
|
return { result: { ok: true } };
|
|
62008
62810
|
}
|
|
@@ -62014,14 +62816,14 @@ function handleProviderListCustomPlatforms(ctx) {
|
|
|
62014
62816
|
function handleProviderUpsertCustomPlatform(payload, ctx) {
|
|
62015
62817
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.adminNode);
|
|
62016
62818
|
if (denied) return denied;
|
|
62017
|
-
const def =
|
|
62819
|
+
const def = asRecord15(payload);
|
|
62018
62820
|
if (!def?.id) return { error: { code: "invalid_argument", message: "platform id required" } };
|
|
62019
62821
|
return { result: ctx.providers.upsertCustomPlatform(def) };
|
|
62020
62822
|
}
|
|
62021
62823
|
function handleProviderDeleteCustomPlatform(payload, ctx) {
|
|
62022
62824
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.adminNode);
|
|
62023
62825
|
if (denied) return denied;
|
|
62024
|
-
const p2 =
|
|
62826
|
+
const p2 = asRecord15(payload);
|
|
62025
62827
|
const ok = ctx.providers.deleteCustomPlatform(String(p2.id ?? ""));
|
|
62026
62828
|
if (!ok) return { error: { code: "not_found", message: "custom platform not found" } };
|
|
62027
62829
|
return { result: { ok: true } };
|
|
@@ -62034,15 +62836,19 @@ function handleProviderExportBundle(ctx) {
|
|
|
62034
62836
|
function handleProviderListModels(payload, ctx) {
|
|
62035
62837
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
62036
62838
|
if (denied) return denied;
|
|
62037
|
-
const p2 =
|
|
62839
|
+
const p2 = asRecord15(payload);
|
|
62038
62840
|
const harness = String(p2.harness ?? p2.harnessId ?? "claude");
|
|
62039
62841
|
const apiProviderId = typeof p2.apiProviderId === "string" && p2.apiProviderId.trim() ? p2.apiProviderId.trim() : null;
|
|
62040
|
-
return {
|
|
62842
|
+
return {
|
|
62843
|
+
result: listHarnessModels(ctx.providers, harness, apiProviderId, {
|
|
62844
|
+
experimentalClaudeOpenAiChatEnabled: loadNodeAgentSettings(ctx.settingsConfigPath).experimentalClaudeOpenAiChatEnabled
|
|
62845
|
+
})
|
|
62846
|
+
};
|
|
62041
62847
|
}
|
|
62042
62848
|
function handleProviderImportBundle(payload, ctx) {
|
|
62043
62849
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.adminNode);
|
|
62044
62850
|
if (denied) return denied;
|
|
62045
|
-
const p2 =
|
|
62851
|
+
const p2 = asRecord15(payload);
|
|
62046
62852
|
const bundle = p2.bundle && typeof p2.bundle === "object" ? p2.bundle : p2;
|
|
62047
62853
|
const replaceAll = p2.replaceAll === true;
|
|
62048
62854
|
try {
|
|
@@ -62107,7 +62913,7 @@ function handleHarnessList(ctx) {
|
|
|
62107
62913
|
function handleHarnessShow(payload, ctx) {
|
|
62108
62914
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.adminNode);
|
|
62109
62915
|
if (denied) return denied;
|
|
62110
|
-
const p2 =
|
|
62916
|
+
const p2 = asRecord15(payload);
|
|
62111
62917
|
const id = typeof p2.harnessId === "string" ? p2.harnessId : typeof p2.id === "string" ? p2.id : "";
|
|
62112
62918
|
if (!isNodeHarnessId(id)) {
|
|
62113
62919
|
return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
|
|
@@ -62117,7 +62923,7 @@ function handleHarnessShow(payload, ctx) {
|
|
|
62117
62923
|
function handleHarnessProbe(payload, ctx) {
|
|
62118
62924
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.adminNode);
|
|
62119
62925
|
if (denied) return denied;
|
|
62120
|
-
const p2 =
|
|
62926
|
+
const p2 = asRecord15(payload);
|
|
62121
62927
|
const id = typeof p2.harnessId === "string" ? p2.harnessId : typeof p2.id === "string" ? p2.id : "";
|
|
62122
62928
|
if (!isNodeHarnessId(id)) {
|
|
62123
62929
|
return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
|
|
@@ -62132,7 +62938,7 @@ function handleHarnessProbe(payload, ctx) {
|
|
|
62132
62938
|
async function handleHarnessEnable(payload, ctx) {
|
|
62133
62939
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.adminNode);
|
|
62134
62940
|
if (denied) return denied;
|
|
62135
|
-
const p2 =
|
|
62941
|
+
const p2 = asRecord15(payload);
|
|
62136
62942
|
const id = typeof p2.harnessId === "string" ? p2.harnessId : typeof p2.id === "string" ? p2.id : "";
|
|
62137
62943
|
if (!isNodeHarnessId(id)) {
|
|
62138
62944
|
return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
|
|
@@ -62158,7 +62964,7 @@ async function handleHarnessEnable(payload, ctx) {
|
|
|
62158
62964
|
function handleHarnessDisable(payload, ctx) {
|
|
62159
62965
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.adminNode);
|
|
62160
62966
|
if (denied) return denied;
|
|
62161
|
-
const p2 =
|
|
62967
|
+
const p2 = asRecord15(payload);
|
|
62162
62968
|
const id = typeof p2.harnessId === "string" ? p2.harnessId : typeof p2.id === "string" ? p2.id : "";
|
|
62163
62969
|
if (!isNodeHarnessId(id)) {
|
|
62164
62970
|
return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
|
|
@@ -62223,7 +63029,7 @@ function handleSettingsGet(ctx) {
|
|
|
62223
63029
|
function handleSettingsPatch(payload, ctx) {
|
|
62224
63030
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.adminNode);
|
|
62225
63031
|
if (denied) return denied;
|
|
62226
|
-
const p2 =
|
|
63032
|
+
const p2 = asRecord15(payload);
|
|
62227
63033
|
const rawPatch = p2.patch && typeof p2.patch === "object" ? p2.patch : p2;
|
|
62228
63034
|
try {
|
|
62229
63035
|
const settings = patchNodeAgentSettings(
|
|
@@ -62244,13 +63050,13 @@ async function handleSandboxProbe(ctx) {
|
|
|
62244
63050
|
return mapThrown6(err);
|
|
62245
63051
|
}
|
|
62246
63052
|
}
|
|
62247
|
-
function
|
|
63053
|
+
function asRecord15(payload) {
|
|
62248
63054
|
return payload && typeof payload === "object" ? payload : {};
|
|
62249
63055
|
}
|
|
62250
63056
|
function handleTerminalCreate(payload, ctx) {
|
|
62251
63057
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
62252
63058
|
if (denied) return denied;
|
|
62253
|
-
const p2 =
|
|
63059
|
+
const p2 = asRecord15(payload);
|
|
62254
63060
|
const cwd = typeof p2.cwd === "string" ? p2.cwd : process.cwd();
|
|
62255
63061
|
try {
|
|
62256
63062
|
const info = ctx.terminals.create({
|
|
@@ -62275,7 +63081,7 @@ function handleTerminalCreate(payload, ctx) {
|
|
|
62275
63081
|
function handleTerminalAttach(payload, ctx) {
|
|
62276
63082
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
62277
63083
|
if (denied) return denied;
|
|
62278
|
-
const p2 =
|
|
63084
|
+
const p2 = asRecord15(payload);
|
|
62279
63085
|
const terminalId = String(p2.terminalId ?? "");
|
|
62280
63086
|
try {
|
|
62281
63087
|
const attached = ctx.terminals.attach(terminalId);
|
|
@@ -62287,7 +63093,7 @@ function handleTerminalAttach(payload, ctx) {
|
|
|
62287
63093
|
function handleTerminalRead(payload, ctx) {
|
|
62288
63094
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
62289
63095
|
if (denied) return denied;
|
|
62290
|
-
const p2 =
|
|
63096
|
+
const p2 = asRecord15(payload);
|
|
62291
63097
|
try {
|
|
62292
63098
|
return {
|
|
62293
63099
|
result: ctx.terminals.readAfter(
|
|
@@ -62315,7 +63121,7 @@ function requireTerminalLease(payload, ctx, terminalId) {
|
|
|
62315
63121
|
function handleTerminalWrite(payload, ctx) {
|
|
62316
63122
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
62317
63123
|
if (denied) return denied;
|
|
62318
|
-
const p2 =
|
|
63124
|
+
const p2 = asRecord15(payload);
|
|
62319
63125
|
const terminalId = String(p2.terminalId ?? "");
|
|
62320
63126
|
const leaseErr = requireTerminalLease(p2, ctx, terminalId);
|
|
62321
63127
|
if (leaseErr) return leaseErr;
|
|
@@ -62333,7 +63139,7 @@ function handleTerminalWrite(payload, ctx) {
|
|
|
62333
63139
|
function handleTerminalResize(payload, ctx) {
|
|
62334
63140
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
62335
63141
|
if (denied) return denied;
|
|
62336
|
-
const p2 =
|
|
63142
|
+
const p2 = asRecord15(payload);
|
|
62337
63143
|
const terminalId = String(p2.terminalId ?? "");
|
|
62338
63144
|
const leaseErr = requireTerminalLease(p2, ctx, terminalId);
|
|
62339
63145
|
if (leaseErr) return leaseErr;
|
|
@@ -62349,7 +63155,7 @@ function handleTerminalResize(payload, ctx) {
|
|
|
62349
63155
|
function handleTerminalKill(payload, ctx) {
|
|
62350
63156
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
62351
63157
|
if (denied) return denied;
|
|
62352
|
-
const p2 =
|
|
63158
|
+
const p2 = asRecord15(payload);
|
|
62353
63159
|
const terminalId = String(p2.terminalId ?? "");
|
|
62354
63160
|
const leaseErr = requireTerminalLease(p2, ctx, terminalId);
|
|
62355
63161
|
if (leaseErr) return leaseErr;
|
|
@@ -62363,7 +63169,7 @@ function handleTerminalKill(payload, ctx) {
|
|
|
62363
63169
|
function handleTerminalAcquireControl(payload, ctx) {
|
|
62364
63170
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
62365
63171
|
if (denied) return denied;
|
|
62366
|
-
const p2 =
|
|
63172
|
+
const p2 = asRecord15(payload);
|
|
62367
63173
|
const terminalId = String(p2.terminalId ?? "");
|
|
62368
63174
|
try {
|
|
62369
63175
|
return {
|
|
@@ -62380,7 +63186,7 @@ function handleTerminalAcquireControl(payload, ctx) {
|
|
|
62380
63186
|
function handleTerminalRenewControl(payload, ctx) {
|
|
62381
63187
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
62382
63188
|
if (denied) return denied;
|
|
62383
|
-
const p2 =
|
|
63189
|
+
const p2 = asRecord15(payload);
|
|
62384
63190
|
try {
|
|
62385
63191
|
return {
|
|
62386
63192
|
result: ctx.leases.renew({
|
|
@@ -62397,7 +63203,7 @@ function handleTerminalRenewControl(payload, ctx) {
|
|
|
62397
63203
|
function handleTerminalReleaseControl(payload, ctx) {
|
|
62398
63204
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
62399
63205
|
if (denied) return denied;
|
|
62400
|
-
const p2 =
|
|
63206
|
+
const p2 = asRecord15(payload);
|
|
62401
63207
|
try {
|
|
62402
63208
|
ctx.leases.release(
|
|
62403
63209
|
String(p2.leaseId ?? ""),
|
|
@@ -62422,7 +63228,7 @@ function handleProjectList(ctx) {
|
|
|
62422
63228
|
function handleProjectGet(payload, ctx) {
|
|
62423
63229
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readProject);
|
|
62424
63230
|
if (denied) return denied;
|
|
62425
|
-
const p2 =
|
|
63231
|
+
const p2 = asRecord15(payload);
|
|
62426
63232
|
const projectId = String(p2.projectId ?? "");
|
|
62427
63233
|
return { result: ctx.projects.get(projectId) };
|
|
62428
63234
|
}
|
|
@@ -62438,7 +63244,7 @@ function expandHostPath(path) {
|
|
|
62438
63244
|
function handleProjectOpen(payload, ctx) {
|
|
62439
63245
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.manageProject);
|
|
62440
63246
|
if (denied) return denied;
|
|
62441
|
-
const p2 =
|
|
63247
|
+
const p2 = asRecord15(payload);
|
|
62442
63248
|
const path = expandHostPath(String(p2.path ?? ""));
|
|
62443
63249
|
if (!path) {
|
|
62444
63250
|
return { error: { code: "invalid_argument", message: "path is required" } };
|
|
@@ -62456,7 +63262,7 @@ function handleProjectOpen(payload, ctx) {
|
|
|
62456
63262
|
function handleProjectRemove(payload, ctx) {
|
|
62457
63263
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.manageProject);
|
|
62458
63264
|
if (denied) return denied;
|
|
62459
|
-
const p2 =
|
|
63265
|
+
const p2 = asRecord15(payload);
|
|
62460
63266
|
const projectId = typeof p2.projectId === "string" && p2.projectId ? p2.projectId : void 0;
|
|
62461
63267
|
const pathRaw = typeof p2.path === "string" && p2.path ? expandHostPath(p2.path) : void 0;
|
|
62462
63268
|
if (!projectId && !pathRaw) {
|
|
@@ -62475,7 +63281,7 @@ function handleProjectRemove(payload, ctx) {
|
|
|
62475
63281
|
function handleFsListDir(payload, ctx) {
|
|
62476
63282
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
62477
63283
|
if (denied) return denied;
|
|
62478
|
-
const p2 =
|
|
63284
|
+
const p2 = asRecord15(payload);
|
|
62479
63285
|
const raw = String(p2.path ?? "");
|
|
62480
63286
|
if (!raw || raw.includes("\0")) {
|
|
62481
63287
|
return { error: { code: "invalid_argument", message: "path is required" } };
|
|
@@ -62501,7 +63307,7 @@ function handleFsListDir(payload, ctx) {
|
|
|
62501
63307
|
function handleWorkspaceListDir(payload, ctx) {
|
|
62502
63308
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
62503
63309
|
if (denied) return denied;
|
|
62504
|
-
const p2 =
|
|
63310
|
+
const p2 = asRecord15(payload);
|
|
62505
63311
|
try {
|
|
62506
63312
|
return {
|
|
62507
63313
|
result: ctx.workspaceFs.listDir(String(p2.projectId ?? ""), String(p2.relativePath ?? "."))
|
|
@@ -62513,7 +63319,7 @@ function handleWorkspaceListDir(payload, ctx) {
|
|
|
62513
63319
|
function handleWorkspaceListFiles(payload, ctx) {
|
|
62514
63320
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
62515
63321
|
if (denied) return denied;
|
|
62516
|
-
const p2 =
|
|
63322
|
+
const p2 = asRecord15(payload);
|
|
62517
63323
|
try {
|
|
62518
63324
|
return {
|
|
62519
63325
|
result: {
|
|
@@ -62531,7 +63337,7 @@ function handleWorkspaceListFiles(payload, ctx) {
|
|
|
62531
63337
|
function handleWorkspaceListSkills(payload, ctx) {
|
|
62532
63338
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
62533
63339
|
if (denied) return denied;
|
|
62534
|
-
const p2 =
|
|
63340
|
+
const p2 = asRecord15(payload);
|
|
62535
63341
|
try {
|
|
62536
63342
|
return {
|
|
62537
63343
|
result: ctx.workspaceFs.listSkillsAndCommands(String(p2.projectId ?? ""))
|
|
@@ -62543,7 +63349,7 @@ function handleWorkspaceListSkills(payload, ctx) {
|
|
|
62543
63349
|
function handleWorkspaceReadFile(payload, ctx) {
|
|
62544
63350
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
62545
63351
|
if (denied) return denied;
|
|
62546
|
-
const p2 =
|
|
63352
|
+
const p2 = asRecord15(payload);
|
|
62547
63353
|
try {
|
|
62548
63354
|
return {
|
|
62549
63355
|
result: ctx.workspaceFs.readFile(String(p2.projectId ?? ""), String(p2.relativePath ?? ""), {
|
|
@@ -62558,7 +63364,7 @@ function handleWorkspaceReadFile(payload, ctx) {
|
|
|
62558
63364
|
function handleWorkspaceWriteFile(payload, ctx) {
|
|
62559
63365
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
62560
63366
|
if (denied) return denied;
|
|
62561
|
-
const p2 =
|
|
63367
|
+
const p2 = asRecord15(payload);
|
|
62562
63368
|
const raw = typeof p2.content === "string" ? p2.content : String(p2.content ?? "");
|
|
62563
63369
|
const encoding = p2.encoding === "base64" ? "base64" : "utf8";
|
|
62564
63370
|
let content = raw;
|
|
@@ -62588,7 +63394,7 @@ function handleWorkspaceWriteFile(payload, ctx) {
|
|
|
62588
63394
|
function handleWorkspaceSearch(payload, ctx) {
|
|
62589
63395
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
62590
63396
|
if (denied) return denied;
|
|
62591
|
-
const p2 =
|
|
63397
|
+
const p2 = asRecord15(payload);
|
|
62592
63398
|
try {
|
|
62593
63399
|
return {
|
|
62594
63400
|
result: ctx.workspaceFs.search(
|
|
@@ -62604,7 +63410,7 @@ function handleWorkspaceSearch(payload, ctx) {
|
|
|
62604
63410
|
function handleWorkspaceRename(payload, ctx) {
|
|
62605
63411
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
62606
63412
|
if (denied) return denied;
|
|
62607
|
-
const p2 =
|
|
63413
|
+
const p2 = asRecord15(payload);
|
|
62608
63414
|
try {
|
|
62609
63415
|
return {
|
|
62610
63416
|
result: ctx.workspaceFs.rename(
|
|
@@ -62620,7 +63426,7 @@ function handleWorkspaceRename(payload, ctx) {
|
|
|
62620
63426
|
function handleWorkspaceMove(payload, ctx) {
|
|
62621
63427
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
62622
63428
|
if (denied) return denied;
|
|
62623
|
-
const p2 =
|
|
63429
|
+
const p2 = asRecord15(payload);
|
|
62624
63430
|
try {
|
|
62625
63431
|
return {
|
|
62626
63432
|
result: ctx.workspaceFs.move(
|
|
@@ -62636,7 +63442,7 @@ function handleWorkspaceMove(payload, ctx) {
|
|
|
62636
63442
|
function handleWorkspaceDelete(payload, ctx) {
|
|
62637
63443
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
62638
63444
|
if (denied) return denied;
|
|
62639
|
-
const p2 =
|
|
63445
|
+
const p2 = asRecord15(payload);
|
|
62640
63446
|
try {
|
|
62641
63447
|
return {
|
|
62642
63448
|
result: ctx.workspaceFs.delete(
|
|
@@ -62651,7 +63457,7 @@ function handleWorkspaceDelete(payload, ctx) {
|
|
|
62651
63457
|
function handleWorkspaceMkdir(payload, ctx) {
|
|
62652
63458
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
62653
63459
|
if (denied) return denied;
|
|
62654
|
-
const p2 =
|
|
63460
|
+
const p2 = asRecord15(payload);
|
|
62655
63461
|
try {
|
|
62656
63462
|
return {
|
|
62657
63463
|
result: ctx.workspaceFs.mkdir(
|
|
@@ -62666,7 +63472,7 @@ function handleWorkspaceMkdir(payload, ctx) {
|
|
|
62666
63472
|
function handleWorkspaceWatchStart(payload, ctx) {
|
|
62667
63473
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
62668
63474
|
if (denied) return denied;
|
|
62669
|
-
const p2 =
|
|
63475
|
+
const p2 = asRecord15(payload);
|
|
62670
63476
|
try {
|
|
62671
63477
|
const events = [];
|
|
62672
63478
|
const { watchId, cancel } = ctx.workspaceWatch.subscribe(
|
|
@@ -62687,7 +63493,7 @@ function handleWorkspaceWatchStart(payload, ctx) {
|
|
|
62687
63493
|
function handleWorkspaceWatchPoll(payload, ctx) {
|
|
62688
63494
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
62689
63495
|
if (denied) return denied;
|
|
62690
|
-
const p2 =
|
|
63496
|
+
const p2 = asRecord15(payload);
|
|
62691
63497
|
const watchId = String(p2.watchId ?? "");
|
|
62692
63498
|
const buf = watchBuffers.get(watchId);
|
|
62693
63499
|
if (!buf || buf.owner !== ctx.client.clientSessionId) {
|
|
@@ -62699,7 +63505,7 @@ function handleWorkspaceWatchPoll(payload, ctx) {
|
|
|
62699
63505
|
function handleWorkspaceWatchStop(payload, ctx) {
|
|
62700
63506
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
62701
63507
|
if (denied) return denied;
|
|
62702
|
-
const p2 =
|
|
63508
|
+
const p2 = asRecord15(payload);
|
|
62703
63509
|
const watchId = String(p2.watchId ?? "");
|
|
62704
63510
|
const buf = watchBuffers.get(watchId);
|
|
62705
63511
|
if (buf && buf.owner === ctx.client.clientSessionId) {
|
|
@@ -62711,7 +63517,7 @@ function handleWorkspaceWatchStop(payload, ctx) {
|
|
|
62711
63517
|
function handleWorkspaceTailWatchStart(payload, ctx) {
|
|
62712
63518
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
62713
63519
|
if (denied) return denied;
|
|
62714
|
-
const p2 =
|
|
63520
|
+
const p2 = asRecord15(payload);
|
|
62715
63521
|
try {
|
|
62716
63522
|
const offset = typeof p2.offset === "number" ? p2.offset : void 0;
|
|
62717
63523
|
const absolutePath = typeof p2.absolutePath === "string" ? p2.absolutePath : void 0;
|
|
@@ -62729,7 +63535,7 @@ function handleWorkspaceTailWatchStart(payload, ctx) {
|
|
|
62729
63535
|
function handleWorkspaceTailWatchPoll(payload, ctx) {
|
|
62730
63536
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
62731
63537
|
if (denied) return denied;
|
|
62732
|
-
const p2 =
|
|
63538
|
+
const p2 = asRecord15(payload);
|
|
62733
63539
|
try {
|
|
62734
63540
|
return {
|
|
62735
63541
|
result: ctx.workspaceTailWatch.poll(String(p2.watchId ?? ""), ctx.client.clientSessionId)
|
|
@@ -62741,7 +63547,7 @@ function handleWorkspaceTailWatchPoll(payload, ctx) {
|
|
|
62741
63547
|
function handleWorkspaceTailWatchStop(payload, ctx) {
|
|
62742
63548
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
62743
63549
|
if (denied) return denied;
|
|
62744
|
-
const p2 =
|
|
63550
|
+
const p2 = asRecord15(payload);
|
|
62745
63551
|
try {
|
|
62746
63552
|
return {
|
|
62747
63553
|
result: ctx.workspaceTailWatch.stop(String(p2.watchId ?? ""), ctx.client.clientSessionId)
|
|
@@ -62753,7 +63559,7 @@ function handleWorkspaceTailWatchStop(payload, ctx) {
|
|
|
62753
63559
|
function handleGitStatus(payload, ctx) {
|
|
62754
63560
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
62755
63561
|
if (denied) return denied;
|
|
62756
|
-
const p2 =
|
|
63562
|
+
const p2 = asRecord15(payload);
|
|
62757
63563
|
try {
|
|
62758
63564
|
const projectId = String(p2.projectId ?? "");
|
|
62759
63565
|
const cwd = typeof p2.cwd === "string" ? p2.cwd : null;
|
|
@@ -62767,7 +63573,7 @@ function handleGitStatus(payload, ctx) {
|
|
|
62767
63573
|
function handleGitDiff(payload, ctx) {
|
|
62768
63574
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
62769
63575
|
if (denied) return denied;
|
|
62770
|
-
const p2 =
|
|
63576
|
+
const p2 = asRecord15(payload);
|
|
62771
63577
|
try {
|
|
62772
63578
|
return {
|
|
62773
63579
|
result: ctx.workspaceGit.diff(String(p2.projectId ?? ""), {
|
|
@@ -62782,7 +63588,7 @@ function handleGitDiff(payload, ctx) {
|
|
|
62782
63588
|
function handleGitBranches(payload, ctx) {
|
|
62783
63589
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
62784
63590
|
if (denied) return denied;
|
|
62785
|
-
const p2 =
|
|
63591
|
+
const p2 = asRecord15(payload);
|
|
62786
63592
|
try {
|
|
62787
63593
|
return {
|
|
62788
63594
|
result: ctx.workspaceGit.branches(
|
|
@@ -62797,7 +63603,7 @@ function handleGitBranches(payload, ctx) {
|
|
|
62797
63603
|
function handleGitSwitchBranch(payload, ctx) {
|
|
62798
63604
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
62799
63605
|
if (denied) return denied;
|
|
62800
|
-
const p2 =
|
|
63606
|
+
const p2 = asRecord15(payload);
|
|
62801
63607
|
try {
|
|
62802
63608
|
return {
|
|
62803
63609
|
result: ctx.workspaceGit.switchBranch(String(p2.projectId ?? ""), String(p2.branch ?? ""), {
|
|
@@ -62812,7 +63618,7 @@ function handleGitSwitchBranch(payload, ctx) {
|
|
|
62812
63618
|
function handleGitCreateBranch(payload, ctx) {
|
|
62813
63619
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
62814
63620
|
if (denied) return denied;
|
|
62815
|
-
const p2 =
|
|
63621
|
+
const p2 = asRecord15(payload);
|
|
62816
63622
|
try {
|
|
62817
63623
|
return {
|
|
62818
63624
|
result: ctx.workspaceGit.switchBranch(String(p2.projectId ?? ""), String(p2.branch ?? ""), {
|
|
@@ -62827,7 +63633,7 @@ function handleGitCreateBranch(payload, ctx) {
|
|
|
62827
63633
|
function handleGitWorktrees(payload, ctx) {
|
|
62828
63634
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
62829
63635
|
if (denied) return denied;
|
|
62830
|
-
const p2 =
|
|
63636
|
+
const p2 = asRecord15(payload);
|
|
62831
63637
|
try {
|
|
62832
63638
|
return { result: ctx.workspaceGit.worktrees(String(p2.projectId ?? "")) };
|
|
62833
63639
|
} catch (err) {
|
|
@@ -62837,7 +63643,7 @@ function handleGitWorktrees(payload, ctx) {
|
|
|
62837
63643
|
function handleGitWorktreeActivate(payload, ctx) {
|
|
62838
63644
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
62839
63645
|
if (denied) return denied;
|
|
62840
|
-
const p2 =
|
|
63646
|
+
const p2 = asRecord15(payload);
|
|
62841
63647
|
const mode = p2.mode === "attach" || p2.mode === "detach" || p2.mode === "branch" ? p2.mode : null;
|
|
62842
63648
|
if (!mode) {
|
|
62843
63649
|
return { error: { code: "invalid_argument", message: "mode must be branch|attach|detach" } };
|
|
@@ -62858,7 +63664,7 @@ function handleGitWorktreeActivate(payload, ctx) {
|
|
|
62858
63664
|
function handleGitWorktreeCheckedOutBranches(payload, ctx) {
|
|
62859
63665
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
62860
63666
|
if (denied) return denied;
|
|
62861
|
-
const p2 =
|
|
63667
|
+
const p2 = asRecord15(payload);
|
|
62862
63668
|
try {
|
|
62863
63669
|
return { result: { branches: ctx.workspaceGit.checkedOutBranches(String(p2.projectId ?? "")) } };
|
|
62864
63670
|
} catch (err) {
|
|
@@ -62868,7 +63674,7 @@ function handleGitWorktreeCheckedOutBranches(payload, ctx) {
|
|
|
62868
63674
|
function handleGitWorktreeAssignBranch(payload, ctx) {
|
|
62869
63675
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
62870
63676
|
if (denied) return denied;
|
|
62871
|
-
const p2 =
|
|
63677
|
+
const p2 = asRecord15(payload);
|
|
62872
63678
|
try {
|
|
62873
63679
|
return {
|
|
62874
63680
|
result: ctx.workspaceGit.assignBranch(
|
|
@@ -62884,7 +63690,7 @@ function handleGitWorktreeAssignBranch(payload, ctx) {
|
|
|
62884
63690
|
function handleGitWorktreeHandoff(payload, ctx) {
|
|
62885
63691
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
62886
63692
|
if (denied) return denied;
|
|
62887
|
-
const p2 =
|
|
63693
|
+
const p2 = asRecord15(payload);
|
|
62888
63694
|
try {
|
|
62889
63695
|
return {
|
|
62890
63696
|
result: ctx.workspaceGit.handoffToMain(
|
|
@@ -62899,7 +63705,7 @@ function handleGitWorktreeHandoff(payload, ctx) {
|
|
|
62899
63705
|
function handleGitWorktreeHandoffPreview(payload, ctx) {
|
|
62900
63706
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
62901
63707
|
if (denied) return denied;
|
|
62902
|
-
const p2 =
|
|
63708
|
+
const p2 = asRecord15(payload);
|
|
62903
63709
|
try {
|
|
62904
63710
|
return {
|
|
62905
63711
|
result: ctx.workspaceGit.handoffPreview(
|
|
@@ -62914,7 +63720,7 @@ function handleGitWorktreeHandoffPreview(payload, ctx) {
|
|
|
62914
63720
|
function handleSessionSetCwd(payload, ctx) {
|
|
62915
63721
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
62916
63722
|
if (denied) return denied;
|
|
62917
|
-
const p2 =
|
|
63723
|
+
const p2 = asRecord15(payload);
|
|
62918
63724
|
const sessionId = String(p2.sessionId ?? "");
|
|
62919
63725
|
const cwdRaw = p2.cwd;
|
|
62920
63726
|
const cwd = cwdRaw === null || cwdRaw === void 0 || cwdRaw === "" ? null : String(cwdRaw);
|
|
@@ -62943,7 +63749,7 @@ function handleSessionSetCwd(payload, ctx) {
|
|
|
62943
63749
|
function handleSessionPatchSettings(payload, ctx) {
|
|
62944
63750
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
62945
63751
|
if (denied) return denied;
|
|
62946
|
-
const p2 =
|
|
63752
|
+
const p2 = asRecord15(payload);
|
|
62947
63753
|
const sessionId = String(p2.sessionId ?? "").trim();
|
|
62948
63754
|
if (!sessionId) {
|
|
62949
63755
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -62959,7 +63765,7 @@ function handleSessionPatchSettings(payload, ctx) {
|
|
|
62959
63765
|
generation: String(p2.generation ?? ""),
|
|
62960
63766
|
holderClientId: ctx.client.clientSessionId
|
|
62961
63767
|
});
|
|
62962
|
-
const settingsSrc =
|
|
63768
|
+
const settingsSrc = asRecord15(p2.settings ?? p2);
|
|
62963
63769
|
const patch = {};
|
|
62964
63770
|
const take = (key) => {
|
|
62965
63771
|
if (!(key in settingsSrc)) return;
|
|
@@ -62985,7 +63791,7 @@ function handleSessionPatchSettings(payload, ctx) {
|
|
|
62985
63791
|
async function handleSessionFork(payload, ctx) {
|
|
62986
63792
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
62987
63793
|
if (denied) return denied;
|
|
62988
|
-
const p2 =
|
|
63794
|
+
const p2 = asRecord15(payload);
|
|
62989
63795
|
const sessionId = String(p2.sessionId ?? "").trim();
|
|
62990
63796
|
if (!sessionId) {
|
|
62991
63797
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -63072,7 +63878,7 @@ async function handleSessionFork(payload, ctx) {
|
|
|
63072
63878
|
async function handleGitClone(payload, ctx) {
|
|
63073
63879
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.manageProject);
|
|
63074
63880
|
if (denied) return denied;
|
|
63075
|
-
const p2 =
|
|
63881
|
+
const p2 = asRecord15(payload);
|
|
63076
63882
|
try {
|
|
63077
63883
|
const cloned = await cloneRepository({
|
|
63078
63884
|
remoteUrl: String(p2.remoteUrl ?? ""),
|
|
@@ -63087,7 +63893,7 @@ async function handleGitClone(payload, ctx) {
|
|
|
63087
63893
|
function handleSessionCreate(payload, ctx) {
|
|
63088
63894
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63089
63895
|
if (denied) return denied;
|
|
63090
|
-
const p2 =
|
|
63896
|
+
const p2 = asRecord15(payload);
|
|
63091
63897
|
const rawHarnessId = typeof p2.harnessId === "string" ? p2.harnessId : "claude";
|
|
63092
63898
|
const harnessId = normalizeSessionHarnessId(rawHarnessId);
|
|
63093
63899
|
if (!harnessId) {
|
|
@@ -63140,7 +63946,7 @@ function handleSessionCreate(payload, ctx) {
|
|
|
63140
63946
|
try {
|
|
63141
63947
|
const agentSettings = loadNodeAgentSettings(ctx.settingsConfigPath);
|
|
63142
63948
|
const defaults = resolveAgentTurnDefaults(agentSettings, harnessId);
|
|
63143
|
-
const options =
|
|
63949
|
+
const options = asRecord15(p2.options);
|
|
63144
63950
|
const providerId = typeof p2.providerId === "string" && p2.providerId.trim() ? p2.providerId.trim() : void 0;
|
|
63145
63951
|
const profile = providerId ? ctx.sessionProviders.get(providerId) : null;
|
|
63146
63952
|
const profileSettings = profile ? settingsFromSessionProviderConfig(profile.config) : {};
|
|
@@ -63200,13 +64006,13 @@ function handleSessionCreate(payload, ctx) {
|
|
|
63200
64006
|
function handleSessionGet(payload, ctx) {
|
|
63201
64007
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readSession);
|
|
63202
64008
|
if (denied) return denied;
|
|
63203
|
-
const p2 =
|
|
64009
|
+
const p2 = asRecord15(payload);
|
|
63204
64010
|
return { result: ctx.sessions.get(String(p2.sessionId ?? "")) };
|
|
63205
64011
|
}
|
|
63206
64012
|
function handleSessionList(payload, ctx) {
|
|
63207
64013
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readSession);
|
|
63208
64014
|
if (denied) return denied;
|
|
63209
|
-
const p2 =
|
|
64015
|
+
const p2 = asRecord15(payload);
|
|
63210
64016
|
const projectId = typeof p2.projectId === "string" ? p2.projectId : void 0;
|
|
63211
64017
|
if (typeof p2.limit !== "number" || !Number.isFinite(p2.limit)) {
|
|
63212
64018
|
return { error: { code: "invalid_argument", message: "session.list requires finite limit" } };
|
|
@@ -63218,28 +64024,34 @@ function handleSessionList(payload, ctx) {
|
|
|
63218
64024
|
const offset = Math.max(Math.floor(p2.offset), 0);
|
|
63219
64025
|
const rows = ctx.sessions.list(projectId, { limit, offset });
|
|
63220
64026
|
return {
|
|
63221
|
-
result: rows.map((s2) =>
|
|
63222
|
-
|
|
63223
|
-
|
|
63224
|
-
|
|
63225
|
-
|
|
63226
|
-
|
|
63227
|
-
|
|
63228
|
-
|
|
63229
|
-
|
|
63230
|
-
|
|
63231
|
-
|
|
63232
|
-
|
|
63233
|
-
|
|
63234
|
-
|
|
63235
|
-
|
|
63236
|
-
|
|
64027
|
+
result: rows.map((s2) => {
|
|
64028
|
+
const providerResume = s2.providerResume ?? null;
|
|
64029
|
+
const providerSessionId = providerSessionIdFromResume(providerResume);
|
|
64030
|
+
return {
|
|
64031
|
+
sessionId: s2.sessionId,
|
|
64032
|
+
projectId: s2.projectId,
|
|
64033
|
+
harnessId: s2.harnessId,
|
|
64034
|
+
providerId: s2.providerId,
|
|
64035
|
+
title: s2.title,
|
|
64036
|
+
status: s2.status,
|
|
64037
|
+
messageCount: Array.isArray(s2.transcript) ? s2.transcript.length : 0,
|
|
64038
|
+
cwd: s2.cwd,
|
|
64039
|
+
createdAt: s2.createdAt,
|
|
64040
|
+
updatedAt: s2.updatedAt,
|
|
64041
|
+
isPinned: s2.isPinned,
|
|
64042
|
+
isHidden: s2.isHidden,
|
|
64043
|
+
isAutomation: s2.isAutomation === true,
|
|
64044
|
+
automationId: s2.automationId ?? null,
|
|
64045
|
+
providerResume,
|
|
64046
|
+
...providerSessionId ? { providerSessionId } : {}
|
|
64047
|
+
};
|
|
64048
|
+
})
|
|
63237
64049
|
};
|
|
63238
64050
|
}
|
|
63239
64051
|
function handleSessionAcquireControl(payload, ctx) {
|
|
63240
64052
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63241
64053
|
if (denied) return denied;
|
|
63242
|
-
const p2 =
|
|
64054
|
+
const p2 = asRecord15(payload);
|
|
63243
64055
|
const sessionId = String(p2.sessionId ?? "");
|
|
63244
64056
|
if (!sessionId) {
|
|
63245
64057
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -63258,7 +64070,7 @@ function handleSessionAcquireControl(payload, ctx) {
|
|
|
63258
64070
|
function handleSessionRenewControl(payload, ctx) {
|
|
63259
64071
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63260
64072
|
if (denied) return denied;
|
|
63261
|
-
const p2 =
|
|
64073
|
+
const p2 = asRecord15(payload);
|
|
63262
64074
|
try {
|
|
63263
64075
|
return {
|
|
63264
64076
|
result: ctx.leases.renew({
|
|
@@ -63275,7 +64087,7 @@ function handleSessionRenewControl(payload, ctx) {
|
|
|
63275
64087
|
function handleSessionReleaseControl(payload, ctx) {
|
|
63276
64088
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63277
64089
|
if (denied) return denied;
|
|
63278
|
-
const p2 =
|
|
64090
|
+
const p2 = asRecord15(payload);
|
|
63279
64091
|
try {
|
|
63280
64092
|
ctx.leases.release(
|
|
63281
64093
|
String(p2.leaseId ?? ""),
|
|
@@ -63290,7 +64102,7 @@ function handleSessionReleaseControl(payload, ctx) {
|
|
|
63290
64102
|
function handleSessionClose(payload, ctx) {
|
|
63291
64103
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63292
64104
|
if (denied) return denied;
|
|
63293
|
-
const p2 =
|
|
64105
|
+
const p2 = asRecord15(payload);
|
|
63294
64106
|
const sessionId = String(p2.sessionId ?? "");
|
|
63295
64107
|
try {
|
|
63296
64108
|
ctx.leases.assertValid({
|
|
@@ -63316,7 +64128,7 @@ function handleSessionClose(payload, ctx) {
|
|
|
63316
64128
|
function handleSessionRemove(payload, ctx) {
|
|
63317
64129
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63318
64130
|
if (denied) return denied;
|
|
63319
|
-
const p2 =
|
|
64131
|
+
const p2 = asRecord15(payload);
|
|
63320
64132
|
const sessionId = String(p2.sessionId ?? "");
|
|
63321
64133
|
if (!sessionId) {
|
|
63322
64134
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -63343,7 +64155,7 @@ function handleSessionRemove(payload, ctx) {
|
|
|
63343
64155
|
function handleSessionRename(payload, ctx) {
|
|
63344
64156
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63345
64157
|
if (denied) return denied;
|
|
63346
|
-
const p2 =
|
|
64158
|
+
const p2 = asRecord15(payload);
|
|
63347
64159
|
const sessionId = String(p2.sessionId ?? "");
|
|
63348
64160
|
const title = String(p2.title ?? "");
|
|
63349
64161
|
const source = p2.source === "agent" ? "agent" : "user";
|
|
@@ -63359,7 +64171,7 @@ function handleSessionRename(payload, ctx) {
|
|
|
63359
64171
|
function handleSessionSetUiFlags(payload, ctx) {
|
|
63360
64172
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63361
64173
|
if (denied) return denied;
|
|
63362
|
-
const p2 =
|
|
64174
|
+
const p2 = asRecord15(payload);
|
|
63363
64175
|
const sessionId = String(p2.sessionId ?? "");
|
|
63364
64176
|
if (!sessionId) {
|
|
63365
64177
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -63378,9 +64190,9 @@ function handleSessionSetUiFlags(payload, ctx) {
|
|
|
63378
64190
|
async function handleSessionSend(payload, ctx) {
|
|
63379
64191
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63380
64192
|
if (denied) return denied;
|
|
63381
|
-
const p2 =
|
|
64193
|
+
const p2 = asRecord15(payload);
|
|
63382
64194
|
try {
|
|
63383
|
-
const options =
|
|
64195
|
+
const options = asRecord15(p2.options);
|
|
63384
64196
|
const modelFromOptions = typeof options.model === "string" && options.model.trim() ? options.model.trim() : null;
|
|
63385
64197
|
const modelTopLevel = typeof p2.model === "string" && p2.model.trim() ? p2.model.trim() : null;
|
|
63386
64198
|
const apiProviderId = typeof options.apiProviderId === "string" && options.apiProviderId.trim() ? options.apiProviderId.trim() : typeof p2.apiProviderId === "string" && p2.apiProviderId.trim() ? p2.apiProviderId.trim() : null;
|
|
@@ -63473,7 +64285,7 @@ async function handleSessionSend(payload, ctx) {
|
|
|
63473
64285
|
function handleSessionInterrupt(payload, ctx) {
|
|
63474
64286
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63475
64287
|
if (denied) return denied;
|
|
63476
|
-
const p2 =
|
|
64288
|
+
const p2 = asRecord15(payload);
|
|
63477
64289
|
try {
|
|
63478
64290
|
ctx.sessions.interrupt(
|
|
63479
64291
|
String(p2.sessionId ?? ""),
|
|
@@ -63489,7 +64301,7 @@ function handleSessionInterrupt(payload, ctx) {
|
|
|
63489
64301
|
function handleSessionRespondPermission(payload, ctx) {
|
|
63490
64302
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63491
64303
|
if (denied) return denied;
|
|
63492
|
-
const p2 =
|
|
64304
|
+
const p2 = asRecord15(payload);
|
|
63493
64305
|
try {
|
|
63494
64306
|
const formAnswers = p2.formAnswers && typeof p2.formAnswers === "object" && !Array.isArray(p2.formAnswers) ? p2.formAnswers : p2.options && typeof p2.options === "object" && !Array.isArray(p2.options) ? p2.options.formAnswers ?? p2.options : void 0;
|
|
63495
64307
|
ctx.sessions.respondPermission({
|
|
@@ -63510,7 +64322,7 @@ function handleSessionRespondPermission(payload, ctx) {
|
|
|
63510
64322
|
function handleSessionRespondQuestion(payload, ctx) {
|
|
63511
64323
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63512
64324
|
if (denied) return denied;
|
|
63513
|
-
const p2 =
|
|
64325
|
+
const p2 = asRecord15(payload);
|
|
63514
64326
|
try {
|
|
63515
64327
|
ctx.sessions.respondQuestion({
|
|
63516
64328
|
sessionId: String(p2.sessionId ?? ""),
|
|
@@ -63528,7 +64340,7 @@ function handleSessionRespondQuestion(payload, ctx) {
|
|
|
63528
64340
|
function handleSessionRespondPlan(payload, ctx) {
|
|
63529
64341
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63530
64342
|
if (denied) return denied;
|
|
63531
|
-
const p2 =
|
|
64343
|
+
const p2 = asRecord15(payload);
|
|
63532
64344
|
const decision = p2.decision === "approve" || p2.decision === "reject" ? p2.decision : null;
|
|
63533
64345
|
if (!decision) {
|
|
63534
64346
|
return { error: { code: "invalid_argument", message: "decision must be approve|reject" } };
|
|
@@ -63551,7 +64363,7 @@ function handleSessionRespondPlan(payload, ctx) {
|
|
|
63551
64363
|
async function handleSessionHostActionsPoll(payload, ctx) {
|
|
63552
64364
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63553
64365
|
if (denied) return denied;
|
|
63554
|
-
const p2 =
|
|
64366
|
+
const p2 = asRecord15(payload);
|
|
63555
64367
|
try {
|
|
63556
64368
|
const result = await ctx.sessions.pollHostActions({
|
|
63557
64369
|
controllerClientSessionId: ctx.client.clientSessionId,
|
|
@@ -63567,7 +64379,7 @@ async function handleSessionHostActionsPoll(payload, ctx) {
|
|
|
63567
64379
|
function handleSessionClaimHostAction(payload, ctx) {
|
|
63568
64380
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63569
64381
|
if (denied) return denied;
|
|
63570
|
-
const p2 =
|
|
64382
|
+
const p2 = asRecord15(payload);
|
|
63571
64383
|
try {
|
|
63572
64384
|
const result = ctx.sessions.claimHostAction({
|
|
63573
64385
|
actionId: String(p2.actionId ?? ""),
|
|
@@ -63583,7 +64395,7 @@ function handleSessionClaimHostAction(payload, ctx) {
|
|
|
63583
64395
|
function handleSessionRespondHostAction(payload, ctx) {
|
|
63584
64396
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63585
64397
|
if (denied) return denied;
|
|
63586
|
-
const p2 =
|
|
64398
|
+
const p2 = asRecord15(payload);
|
|
63587
64399
|
const outcome = p2.outcome === "failed" ? "failed" : p2.outcome === "succeeded" ? "succeeded" : null;
|
|
63588
64400
|
if (!outcome) {
|
|
63589
64401
|
return { error: { code: "invalid_argument", message: "outcome must be succeeded|failed" } };
|
|
@@ -63605,14 +64417,14 @@ function handleSessionRespondHostAction(payload, ctx) {
|
|
|
63605
64417
|
function handleSessionEvents(payload, ctx) {
|
|
63606
64418
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readSession);
|
|
63607
64419
|
if (denied) return denied;
|
|
63608
|
-
const p2 =
|
|
64420
|
+
const p2 = asRecord15(payload);
|
|
63609
64421
|
const after = String(p2.afterSequence ?? "0");
|
|
63610
64422
|
return { result: { events: ctx.sessions.listEventsAfter(after) } };
|
|
63611
64423
|
}
|
|
63612
64424
|
function handleSessionMessagesList(payload, ctx) {
|
|
63613
64425
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readSession);
|
|
63614
64426
|
if (denied) return denied;
|
|
63615
|
-
const p2 =
|
|
64427
|
+
const p2 = asRecord15(payload);
|
|
63616
64428
|
const sessionId = String(p2.sessionId ?? "").trim();
|
|
63617
64429
|
if (!sessionId) {
|
|
63618
64430
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -63651,7 +64463,7 @@ function handleCollaborationListProfiles(ctx) {
|
|
|
63651
64463
|
async function handleCollaborationRequest(payload, ctx) {
|
|
63652
64464
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63653
64465
|
if (denied) return denied;
|
|
63654
|
-
const p2 =
|
|
64466
|
+
const p2 = asRecord15(payload);
|
|
63655
64467
|
const parentSessionId = String(p2.parentSessionId ?? "");
|
|
63656
64468
|
if (!parentSessionId) {
|
|
63657
64469
|
return { error: { code: "invalid_argument", message: "parentSessionId required" } };
|
|
@@ -63685,7 +64497,7 @@ async function handleCollaborationRequest(payload, ctx) {
|
|
|
63685
64497
|
async function handleCollaborationStart(payload, ctx) {
|
|
63686
64498
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63687
64499
|
if (denied) return denied;
|
|
63688
|
-
const p2 =
|
|
64500
|
+
const p2 = asRecord15(payload);
|
|
63689
64501
|
const credential = typeof p2.credential === "string" ? p2.credential : void 0;
|
|
63690
64502
|
const grantId = typeof p2.grantId === "string" ? p2.grantId : void 0;
|
|
63691
64503
|
if (!credential && !grantId) {
|
|
@@ -63731,7 +64543,7 @@ async function handleCollaborationStart(payload, ctx) {
|
|
|
63731
64543
|
function handleCollaborationSend(payload, ctx) {
|
|
63732
64544
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.operateSession);
|
|
63733
64545
|
if (denied) return denied;
|
|
63734
|
-
const p2 =
|
|
64546
|
+
const p2 = asRecord15(payload);
|
|
63735
64547
|
const credential = String(p2.credential ?? "");
|
|
63736
64548
|
const sessionId = String(p2.sessionId ?? p2.fromSessionId ?? "");
|
|
63737
64549
|
const content = typeof p2.content === "string" ? p2.content : p2.body !== void 0 ? typeof p2.body === "string" ? p2.body : JSON.stringify(p2.body) : "";
|
|
@@ -63767,7 +64579,7 @@ function handleCollaborationSend(payload, ctx) {
|
|
|
63767
64579
|
function handleCollaborationRetrieve(payload, ctx) {
|
|
63768
64580
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readSession);
|
|
63769
64581
|
if (denied) return denied;
|
|
63770
|
-
const p2 =
|
|
64582
|
+
const p2 = asRecord15(payload);
|
|
63771
64583
|
const credential = String(p2.credential ?? "");
|
|
63772
64584
|
const sessionId = String(p2.sessionId ?? "");
|
|
63773
64585
|
if (!credential) {
|
|
@@ -65942,39 +66754,28 @@ var CollaborationService = class {
|
|
|
65942
66754
|
constructor(deps) {
|
|
65943
66755
|
this.deps = deps;
|
|
65944
66756
|
}
|
|
65945
|
-
isEnabled() {
|
|
65946
|
-
return this.deps.isEnabled?.() ?? true;
|
|
65947
|
-
}
|
|
65948
|
-
assertEnabled() {
|
|
65949
|
-
if (!this.isEnabled()) {
|
|
65950
|
-
throw Object.assign(
|
|
65951
|
-
new Error(
|
|
65952
|
-
"Agent session collaboration is disabled. Enable experimentalAgentCollaborationEnabled in node settings."
|
|
65953
|
-
),
|
|
65954
|
-
{ code: "failed_precondition" }
|
|
65955
|
-
);
|
|
65956
|
-
}
|
|
65957
|
-
}
|
|
65958
66757
|
/** Agent profiles from session_providers (+ ready-harness fallback). */
|
|
65959
66758
|
listProfiles() {
|
|
65960
|
-
this.assertEnabled();
|
|
65961
66759
|
const { harnesses, providers, sessions, sessionProviders } = this.deps;
|
|
65962
66760
|
const profiles = [];
|
|
65963
66761
|
const seen = /* @__PURE__ */ new Set();
|
|
66762
|
+
const providerOptions = {
|
|
66763
|
+
experimentalClaudeOpenAiChatEnabled: this.deps.experimentalClaudeOpenAiChatEnabled?.() ?? false
|
|
66764
|
+
};
|
|
65964
66765
|
const pushProfile = (profileId, harnessId, name, description, profileConfig) => {
|
|
65965
66766
|
if (seen.has(profileId)) return;
|
|
65966
66767
|
if (harnessId !== "claude" && harnessId !== "codex" && harnessId !== "acp" && harnessId !== "opencode") {
|
|
65967
66768
|
return;
|
|
65968
66769
|
}
|
|
65969
66770
|
seen.add(profileId);
|
|
65970
|
-
const models = listHarnessModels(providers, harnessId, null).map((m2) => ({
|
|
66771
|
+
const models = listHarnessModels(providers, harnessId, null, providerOptions).map((m2) => ({
|
|
65971
66772
|
id: m2.id,
|
|
65972
66773
|
name: m2.name || m2.id,
|
|
65973
66774
|
...m2.description ? { description: m2.description } : {}
|
|
65974
66775
|
}));
|
|
65975
66776
|
const defaultModel = models.find((m2) => m2.isDefault) ?? models[0];
|
|
65976
66777
|
const efforts = /* @__PURE__ */ new Set();
|
|
65977
|
-
for (const m2 of listHarnessModels(providers, harnessId, null)) {
|
|
66778
|
+
for (const m2 of listHarnessModels(providers, harnessId, null, providerOptions)) {
|
|
65978
66779
|
for (const e of m2.supportedEffortLevels ?? []) efforts.add(e);
|
|
65979
66780
|
}
|
|
65980
66781
|
const cfg = profileConfig && typeof profileConfig === "object" && !Array.isArray(profileConfig) ? profileConfig : {};
|
|
@@ -65994,7 +66795,7 @@ var CollaborationService = class {
|
|
|
65994
66795
|
},
|
|
65995
66796
|
models: models.length > 0 ? models : [{ id: "default", name: "Default" }],
|
|
65996
66797
|
efforts: [...efforts],
|
|
65997
|
-
apiProviders: listHarnessApiProviders(providers, harnessId)
|
|
66798
|
+
apiProviders: listHarnessApiProviders(providers, harnessId, providerOptions)
|
|
65998
66799
|
});
|
|
65999
66800
|
};
|
|
66000
66801
|
if (sessionProviders) {
|
|
@@ -66040,7 +66841,6 @@ var CollaborationService = class {
|
|
|
66040
66841
|
* RPC path defaults to auto-approve (already-trusted controller).
|
|
66041
66842
|
*/
|
|
66042
66843
|
async request(input) {
|
|
66043
|
-
this.assertEnabled();
|
|
66044
66844
|
const parent = this.deps.sessions.get(input.parentSessionId);
|
|
66045
66845
|
if (!parent) {
|
|
66046
66846
|
throw Object.assign(new Error("Parent session is not available"), { code: "not_found" });
|
|
@@ -66210,7 +67010,6 @@ var CollaborationService = class {
|
|
|
66210
67010
|
return { status: "approved", launches: results };
|
|
66211
67011
|
}
|
|
66212
67012
|
async start(input) {
|
|
66213
|
-
this.assertEnabled();
|
|
66214
67013
|
let grant = this.resolveGrant(input.credential, input.grantId);
|
|
66215
67014
|
if (!grant) {
|
|
66216
67015
|
throw Object.assign(new Error("Invalid collaboration credential"), { code: "not_found" });
|
|
@@ -66349,7 +67148,6 @@ var CollaborationService = class {
|
|
|
66349
67148
|
};
|
|
66350
67149
|
}
|
|
66351
67150
|
send(input) {
|
|
66352
|
-
this.assertEnabled();
|
|
66353
67151
|
const grant = this.grantForCredential(input.credential);
|
|
66354
67152
|
if (!grant) {
|
|
66355
67153
|
throw Object.assign(new Error("Invalid collaboration credential"), { code: "not_found" });
|
|
@@ -66429,7 +67227,6 @@ var CollaborationService = class {
|
|
|
66429
67227
|
};
|
|
66430
67228
|
}
|
|
66431
67229
|
retrieve(input) {
|
|
66432
|
-
this.assertEnabled();
|
|
66433
67230
|
const credentials = [
|
|
66434
67231
|
...typeof input.credential === "string" && input.credential.trim() ? [input.credential.trim()] : [],
|
|
66435
67232
|
...Array.isArray(input.credentials) ? input.credentials.filter((c) => typeof c === "string" && c.trim().length > 0) : []
|
|
@@ -78333,16 +79130,6 @@ function collabDescriptor(name) {
|
|
|
78333
79130
|
};
|
|
78334
79131
|
}
|
|
78335
79132
|
function registerNodeCollabTools(server, superoneSessionId, collab) {
|
|
78336
|
-
const requireEnabled = () => {
|
|
78337
|
-
if (!collab.isEnabled()) {
|
|
78338
|
-
throw Object.assign(
|
|
78339
|
-
new Error(
|
|
78340
|
-
"Agent session collaboration is disabled. Enable experimentalAgentCollaborationEnabled in node settings."
|
|
78341
|
-
),
|
|
78342
|
-
{ code: "failed_precondition" }
|
|
78343
|
-
);
|
|
78344
|
-
}
|
|
78345
|
-
};
|
|
78346
79133
|
const listDesc = collabDescriptor("session_collab_list_agents");
|
|
78347
79134
|
server.registerTool(
|
|
78348
79135
|
"session_collab_list_agents",
|
|
@@ -78352,7 +79139,6 @@ function registerNodeCollabTools(server, superoneSessionId, collab) {
|
|
|
78352
79139
|
},
|
|
78353
79140
|
async () => {
|
|
78354
79141
|
try {
|
|
78355
|
-
requireEnabled();
|
|
78356
79142
|
const agents = await collab.listAgents(superoneSessionId);
|
|
78357
79143
|
return toolResultJson({ agents });
|
|
78358
79144
|
} catch (err) {
|
|
@@ -78369,7 +79155,6 @@ function registerNodeCollabTools(server, superoneSessionId, collab) {
|
|
|
78369
79155
|
},
|
|
78370
79156
|
async (args, extra) => {
|
|
78371
79157
|
try {
|
|
78372
|
-
requireEnabled();
|
|
78373
79158
|
const result = await collab.request(superoneSessionId, args ?? {}, extra?.signal);
|
|
78374
79159
|
const status = result && typeof result === "object" && "status" in result ? String(result.status) : "ok";
|
|
78375
79160
|
return toolResultJson(result, status === "error");
|
|
@@ -78389,7 +79174,6 @@ function registerNodeCollabTools(server, superoneSessionId, collab) {
|
|
|
78389
79174
|
},
|
|
78390
79175
|
async (args) => {
|
|
78391
79176
|
try {
|
|
78392
|
-
requireEnabled();
|
|
78393
79177
|
const result = await collab.start(superoneSessionId, args ?? {});
|
|
78394
79178
|
return toolResultJson(result);
|
|
78395
79179
|
} catch (err) {
|
|
@@ -78406,7 +79190,6 @@ function registerNodeCollabTools(server, superoneSessionId, collab) {
|
|
|
78406
79190
|
},
|
|
78407
79191
|
async (args) => {
|
|
78408
79192
|
try {
|
|
78409
|
-
requireEnabled();
|
|
78410
79193
|
const result = await collab.send(superoneSessionId, args ?? {});
|
|
78411
79194
|
return toolResultJson(result);
|
|
78412
79195
|
} catch (err) {
|
|
@@ -78423,7 +79206,6 @@ function registerNodeCollabTools(server, superoneSessionId, collab) {
|
|
|
78423
79206
|
},
|
|
78424
79207
|
async (args) => {
|
|
78425
79208
|
try {
|
|
78426
|
-
requireEnabled();
|
|
78427
79209
|
const result = await collab.retrieve(superoneSessionId, args ?? {});
|
|
78428
79210
|
return toolResultJson(result);
|
|
78429
79211
|
} catch (err) {
|
|
@@ -79713,7 +80495,6 @@ async function startNodeRuntime(partial2 = {}) {
|
|
|
79713
80495
|
const collabSecrets = createNodeSecretCrypto(paths.providerSecretsKey);
|
|
79714
80496
|
let sessionsRef = null;
|
|
79715
80497
|
let collaborationRef = null;
|
|
79716
|
-
const isCollabEnabled = () => loadNodeAgentSettings(paths.configJson).experimentalAgentCollaborationEnabled;
|
|
79717
80498
|
const hostActionMcp = await startHostActionMcpServer({
|
|
79718
80499
|
requestHostAction: (input) => {
|
|
79719
80500
|
if (!sessionsRef) {
|
|
@@ -79724,7 +80505,6 @@ async function startNodeRuntime(partial2 = {}) {
|
|
|
79724
80505
|
return sessionsRef.requestHostAction(input);
|
|
79725
80506
|
},
|
|
79726
80507
|
collab: {
|
|
79727
|
-
isEnabled: isCollabEnabled,
|
|
79728
80508
|
listAgents: () => {
|
|
79729
80509
|
if (!collaborationRef) throw Object.assign(new Error("collab not ready"), { code: "failed_precondition" });
|
|
79730
80510
|
return collaborationRef.listProfiles();
|
|
@@ -79773,6 +80553,7 @@ async function startNodeRuntime(partial2 = {}) {
|
|
|
79773
80553
|
resolveProjectPath: (projectId) => projects.get(projectId)?.path ?? null,
|
|
79774
80554
|
allowSimulatedFallback: allowSimulatedTurnFallback,
|
|
79775
80555
|
providers,
|
|
80556
|
+
experimentalClaudeOpenAiChatEnabled: () => loadNodeAgentSettings(paths.configJson).experimentalClaudeOpenAiChatEnabled,
|
|
79776
80557
|
// Claude: in-process SDK MCP (same core tools as HTTP).
|
|
79777
80558
|
createHostActionClaudeMcp: (sessionId) => hostActionMcp.createClaudeSdkMcp(sessionId),
|
|
79778
80559
|
// Codex / ACP / OpenCode: loopback HTTP with per-session HMAC.
|
|
@@ -79805,7 +80586,7 @@ async function startNodeRuntime(partial2 = {}) {
|
|
|
79805
80586
|
workspaceGit,
|
|
79806
80587
|
secrets: collabSecrets,
|
|
79807
80588
|
sessionProviders,
|
|
79808
|
-
|
|
80589
|
+
experimentalClaudeOpenAiChatEnabled: () => loadNodeAgentSettings(paths.configJson).experimentalClaudeOpenAiChatEnabled
|
|
79809
80590
|
});
|
|
79810
80591
|
collaborationRef = collaboration;
|
|
79811
80592
|
collaboration.rehydrateSystemPrompts();
|