@ycodium-ai/agent-acp 0.2.5029 → 0.2.5093
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/dist/index.js +986 -620
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -8,17 +8,10 @@ var __export = (target, all) => {
|
|
|
8
8
|
import { definePlugin } from "@ycodium-ai/plugin-api";
|
|
9
9
|
|
|
10
10
|
// ../../packages/plugin-api/src/version.ts
|
|
11
|
-
var PLUGIN_API_VERSION =
|
|
11
|
+
var PLUGIN_API_VERSION = 147;
|
|
12
12
|
|
|
13
13
|
// src/acpInstance.ts
|
|
14
|
-
import
|
|
15
|
-
import * as NodePath4 from "node:path";
|
|
16
|
-
import {
|
|
17
|
-
mergeLaunchEnv,
|
|
18
|
-
modelSelectionStringOption,
|
|
19
|
-
raceAbort as raceAbort2
|
|
20
|
-
} from "@ycodium-ai/plugin-api/executor";
|
|
21
|
-
import { nodeStreamsFromHandle as nodeStreamsFromHandle2 } from "@ycodium-ai/plugin-api/process-stdin";
|
|
14
|
+
import { raceAbort as raceAbort3 } from "@ycodium-ai/plugin-api/executor";
|
|
22
15
|
|
|
23
16
|
// ../../packages/ycodium-acp-executor/src/executor.ts
|
|
24
17
|
import * as NodeCrypto from "node:crypto";
|
|
@@ -80,6 +73,24 @@ function approvalOutcomeForDecision(decision, optionId) {
|
|
|
80
73
|
return decision !== "cancel" && optionId !== void 0 ? { outcome: "selected", optionId } : { outcome: "cancelled" };
|
|
81
74
|
}
|
|
82
75
|
|
|
76
|
+
// ../../packages/ycodium-executor-common/src/stderrTail.ts
|
|
77
|
+
var REDACTION_MARKERS = ["[redacted]", "[pairing-url]"];
|
|
78
|
+
function lastStderrTail(text, maxChars) {
|
|
79
|
+
if (text.length <= maxChars) return text;
|
|
80
|
+
let start = text.length - maxChars;
|
|
81
|
+
if (text[start - 1] !== "\n") {
|
|
82
|
+
const lineEnd = text.indexOf("\n", start);
|
|
83
|
+
if (lineEnd !== -1 && lineEnd < text.length - 1) return text.slice(lineEnd + 1);
|
|
84
|
+
const code = text.charCodeAt(start);
|
|
85
|
+
if (code >= 56320 && code <= 57343) start += 1;
|
|
86
|
+
for (const marker of REDACTION_MARKERS) {
|
|
87
|
+
const at = text.lastIndexOf(marker, start);
|
|
88
|
+
if (at !== -1 && at < start && start < at + marker.length) start = at + marker.length;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return text.slice(start);
|
|
92
|
+
}
|
|
93
|
+
|
|
83
94
|
// ../../packages/ycodium-acp-executor/src/errors.ts
|
|
84
95
|
var AcpExecutorError = class extends Error {
|
|
85
96
|
code;
|
|
@@ -184,22 +195,6 @@ var AcpAgentExitedError = class extends AcpConnectionClosedError {
|
|
|
184
195
|
this.exitCode = exitCode;
|
|
185
196
|
}
|
|
186
197
|
};
|
|
187
|
-
var REDACTION_MARKERS = ["[redacted]", "[pairing-url]"];
|
|
188
|
-
var lastLines = (text, maxChars) => {
|
|
189
|
-
if (text.length <= maxChars) return text;
|
|
190
|
-
let start = text.length - maxChars;
|
|
191
|
-
if (text[start - 1] !== "\n") {
|
|
192
|
-
const lineEnd = text.indexOf("\n", start);
|
|
193
|
-
if (lineEnd !== -1 && lineEnd < text.length - 1) return text.slice(lineEnd + 1);
|
|
194
|
-
const code = text.charCodeAt(start);
|
|
195
|
-
if (code >= 56320 && code <= 57343) start += 1;
|
|
196
|
-
for (const marker of REDACTION_MARKERS) {
|
|
197
|
-
const at = text.lastIndexOf(marker, start);
|
|
198
|
-
if (at !== -1 && at < start && start < at + marker.length) start = at + marker.length;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return text.slice(start);
|
|
202
|
-
};
|
|
203
198
|
var settledExitCode = async (exited) => {
|
|
204
199
|
if (exited === void 0) return void 0;
|
|
205
200
|
let timer;
|
|
@@ -220,7 +215,7 @@ async function describeAgentExit(input2) {
|
|
|
220
215
|
input2.stderrTail === void 0 ? "" : Promise.resolve().then(input2.stderrTail).catch(() => "")
|
|
221
216
|
]);
|
|
222
217
|
const head = exitCode === void 0 ? "The agent closed its connection." : exitCode === null ? "The agent process exited without an exit code." : `The agent process exited with code ${exitCode}.`;
|
|
223
|
-
const excerpt =
|
|
218
|
+
const excerpt = lastStderrTail(tail.trim(), AGENT_EXIT_STDERR_MAX_CHARS);
|
|
224
219
|
return new AcpAgentExitedError(
|
|
225
220
|
excerpt.length === 0 ? head : `${head}
|
|
226
221
|
Agent stderr (last lines):
|
|
@@ -451,9 +446,17 @@ var selectPromptTurnId = (input2, activeTurnId, freshTurnId) => {
|
|
|
451
446
|
return target;
|
|
452
447
|
};
|
|
453
448
|
|
|
454
|
-
// ../../packages/ycodium-
|
|
449
|
+
// ../../packages/ycodium-executor-common/src/toolPresentation.ts
|
|
450
|
+
function isRecord3(value) {
|
|
451
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
452
|
+
}
|
|
453
|
+
function asTrimmedString2(value) {
|
|
454
|
+
if (typeof value !== "string") return void 0;
|
|
455
|
+
const trimmed = value.trim();
|
|
456
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
457
|
+
}
|
|
455
458
|
function normalizeCommandValue(value) {
|
|
456
|
-
const direct =
|
|
459
|
+
const direct = asTrimmedString2(value);
|
|
457
460
|
if (direct) {
|
|
458
461
|
return direct;
|
|
459
462
|
}
|
|
@@ -462,7 +465,7 @@ function normalizeCommandValue(value) {
|
|
|
462
465
|
}
|
|
463
466
|
const parts = [];
|
|
464
467
|
for (const entry of value) {
|
|
465
|
-
const part =
|
|
468
|
+
const part = asTrimmedString2(entry);
|
|
466
469
|
if (part !== void 0) {
|
|
467
470
|
parts.push(part);
|
|
468
471
|
}
|
|
@@ -486,11 +489,11 @@ function extractCommandFromTitle(title) {
|
|
|
486
489
|
return backtickMatch?.[1]?.trim() || void 0;
|
|
487
490
|
}
|
|
488
491
|
function extractToolCommand(data, title) {
|
|
489
|
-
const item =
|
|
490
|
-
const itemInput = item &&
|
|
491
|
-
const itemResult = item &&
|
|
492
|
-
const rawInput =
|
|
493
|
-
const dataInput =
|
|
492
|
+
const item = isRecord3(data?.["item"]) ? data["item"] : void 0;
|
|
493
|
+
const itemInput = item && isRecord3(item["input"]) ? item["input"] : void 0;
|
|
494
|
+
const itemResult = item && isRecord3(item["result"]) ? item["result"] : void 0;
|
|
495
|
+
const rawInput = isRecord3(data?.["rawInput"]) ? data["rawInput"] : void 0;
|
|
496
|
+
const dataInput = isRecord3(data?.["input"]) ? data["input"] : void 0;
|
|
494
497
|
const candidates = [
|
|
495
498
|
normalizeCommandValue(item?.["command"]),
|
|
496
499
|
normalizeCommandValue(itemInput?.["command"]),
|
|
@@ -503,7 +506,7 @@ function extractToolCommand(data, title) {
|
|
|
503
506
|
if (direct) {
|
|
504
507
|
return direct;
|
|
505
508
|
}
|
|
506
|
-
const executable =
|
|
509
|
+
const executable = asTrimmedString2(rawInput?.["executable"]);
|
|
507
510
|
const args = normalizeCommandValue(rawInput?.["args"]);
|
|
508
511
|
if (executable && args) {
|
|
509
512
|
return `${executable} ${args}`;
|
|
@@ -535,11 +538,11 @@ function collectPaths(value, paths, seen, depth) {
|
|
|
535
538
|
}
|
|
536
539
|
return;
|
|
537
540
|
}
|
|
538
|
-
if (!
|
|
541
|
+
if (!isRecord3(value)) {
|
|
539
542
|
return;
|
|
540
543
|
}
|
|
541
544
|
for (const key of ["path", "filePath", "relativePath", "filename", "newPath", "oldPath"]) {
|
|
542
|
-
const candidate = maybePathLike(
|
|
545
|
+
const candidate = maybePathLike(asTrimmedString2(value[key]));
|
|
543
546
|
if (!candidate || seen.has(candidate)) {
|
|
544
547
|
continue;
|
|
545
548
|
}
|
|
@@ -565,7 +568,7 @@ function extractPrimaryPath(data) {
|
|
|
565
568
|
return paths[0];
|
|
566
569
|
}
|
|
567
570
|
function normalizeEquivalentValue(value) {
|
|
568
|
-
const trimmed =
|
|
571
|
+
const trimmed = asTrimmedString2(value);
|
|
569
572
|
if (!trimmed) {
|
|
570
573
|
return void 0;
|
|
571
574
|
}
|
|
@@ -578,8 +581,8 @@ function isEquivalent(left, right) {
|
|
|
578
581
|
}
|
|
579
582
|
function classifyToolAction(input2) {
|
|
580
583
|
const itemType = input2.itemType ?? void 0;
|
|
581
|
-
const kind =
|
|
582
|
-
const title =
|
|
584
|
+
const kind = asTrimmedString2(input2.data?.["kind"])?.toLowerCase();
|
|
585
|
+
const title = asTrimmedString2(input2.title)?.toLowerCase();
|
|
583
586
|
if (itemType === "command_execution" || kind === "execute" || title === "terminal") {
|
|
584
587
|
return "command";
|
|
585
588
|
}
|
|
@@ -594,26 +597,11 @@ function classifyToolAction(input2) {
|
|
|
594
597
|
}
|
|
595
598
|
return "other";
|
|
596
599
|
}
|
|
597
|
-
function canonicalItemTypeFromAcpToolKind(kind) {
|
|
598
|
-
switch (kind) {
|
|
599
|
-
case "execute":
|
|
600
|
-
return "command_execution";
|
|
601
|
-
case "edit":
|
|
602
|
-
case "delete":
|
|
603
|
-
case "move":
|
|
604
|
-
return "file_change";
|
|
605
|
-
case "search":
|
|
606
|
-
case "fetch":
|
|
607
|
-
return "web_search";
|
|
608
|
-
default:
|
|
609
|
-
return "dynamic_tool_call";
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
600
|
function deriveToolActivityPresentation(input2) {
|
|
613
|
-
const title =
|
|
614
|
-
const detail = stripTrailingExitCode(
|
|
615
|
-
const fallbackSummary =
|
|
616
|
-
const data =
|
|
601
|
+
const title = asTrimmedString2(input2.title);
|
|
602
|
+
const detail = stripTrailingExitCode(asTrimmedString2(input2.detail));
|
|
603
|
+
const fallbackSummary = asTrimmedString2(input2.fallbackSummary) ?? "Tool";
|
|
604
|
+
const data = isRecord3(input2.data) ? input2.data : void 0;
|
|
617
605
|
const command = extractToolCommand(data, title);
|
|
618
606
|
const primaryPath = extractPrimaryPath(data);
|
|
619
607
|
const action = classifyToolAction({
|
|
@@ -645,8 +633,8 @@ function deriveToolActivityPresentation(input2) {
|
|
|
645
633
|
};
|
|
646
634
|
}
|
|
647
635
|
if (action === "search") {
|
|
648
|
-
const rawInput =
|
|
649
|
-
const query =
|
|
636
|
+
const rawInput = isRecord3(data?.["rawInput"]) ? data["rawInput"] : void 0;
|
|
637
|
+
const query = asTrimmedString2(rawInput?.["query"]) ?? asTrimmedString2(rawInput?.["pattern"]) ?? asTrimmedString2(rawInput?.["searchTerm"]);
|
|
650
638
|
return {
|
|
651
639
|
summary: "Searched files",
|
|
652
640
|
...query ? { detail: query } : {}
|
|
@@ -663,6 +651,23 @@ function deriveToolActivityPresentation(input2) {
|
|
|
663
651
|
};
|
|
664
652
|
}
|
|
665
653
|
|
|
654
|
+
// ../../packages/ycodium-acp-executor/src/tool-presentation.ts
|
|
655
|
+
function canonicalItemTypeFromAcpToolKind(kind) {
|
|
656
|
+
switch (kind) {
|
|
657
|
+
case "execute":
|
|
658
|
+
return "command_execution";
|
|
659
|
+
case "edit":
|
|
660
|
+
case "delete":
|
|
661
|
+
case "move":
|
|
662
|
+
return "file_change";
|
|
663
|
+
case "search":
|
|
664
|
+
case "fetch":
|
|
665
|
+
return "web_search";
|
|
666
|
+
default:
|
|
667
|
+
return "dynamic_tool_call";
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
|
|
666
671
|
// ../../packages/ycodium-acp-executor/src/tool-call-state.ts
|
|
667
672
|
function normalizeToolCallStatus(raw, fallback) {
|
|
668
673
|
switch (raw) {
|
|
@@ -891,6 +896,30 @@ function decideToolCallUpdateEmission(input2) {
|
|
|
891
896
|
return { emit: false, skippedSinceEmit: skippedSinceEmit + 1 };
|
|
892
897
|
}
|
|
893
898
|
|
|
899
|
+
// ../../packages/ycodium-executor-common/src/catalogModel.ts
|
|
900
|
+
function catalogModelLastSegment(value) {
|
|
901
|
+
if (value.startsWith("[")) {
|
|
902
|
+
let parsed;
|
|
903
|
+
try {
|
|
904
|
+
parsed = JSON.parse(value);
|
|
905
|
+
} catch {
|
|
906
|
+
return void 0;
|
|
907
|
+
}
|
|
908
|
+
if (!Array.isArray(parsed) || parsed.length < 2) return void 0;
|
|
909
|
+
const last = parsed[parsed.length - 1];
|
|
910
|
+
return typeof last === "string" ? last : void 0;
|
|
911
|
+
}
|
|
912
|
+
const separator = value.indexOf("/");
|
|
913
|
+
return separator > 0 && separator < value.length - 1 ? value.slice(separator + 1) : void 0;
|
|
914
|
+
}
|
|
915
|
+
function matchCatalogModel(requested, catalog) {
|
|
916
|
+
const wanted = requested?.trim();
|
|
917
|
+
if (!wanted) return void 0;
|
|
918
|
+
if (catalog.includes(wanted)) return wanted;
|
|
919
|
+
const byLastSegment = catalog.filter((value) => catalogModelLastSegment(value) === wanted);
|
|
920
|
+
return byLastSegment.length === 1 ? byLastSegment[0] : void 0;
|
|
921
|
+
}
|
|
922
|
+
|
|
894
923
|
// ../../packages/ycodium-acp-executor/src/runtime-model.ts
|
|
895
924
|
function normalizePlanStepStatus(raw) {
|
|
896
925
|
switch (raw) {
|
|
@@ -932,30 +961,6 @@ function collectSessionModelIds(models) {
|
|
|
932
961
|
(model) => isRecord2(model) && typeof model["modelId"] === "string" ? [model["modelId"]] : []
|
|
933
962
|
);
|
|
934
963
|
}
|
|
935
|
-
function catalogModelLastSegment(value) {
|
|
936
|
-
if (value.startsWith("[")) {
|
|
937
|
-
let parsed;
|
|
938
|
-
try {
|
|
939
|
-
parsed = JSON.parse(value);
|
|
940
|
-
} catch {
|
|
941
|
-
return void 0;
|
|
942
|
-
}
|
|
943
|
-
if (!Array.isArray(parsed) || parsed.length < 2) return void 0;
|
|
944
|
-
const last = parsed[parsed.length - 1];
|
|
945
|
-
return typeof last === "string" ? last : void 0;
|
|
946
|
-
}
|
|
947
|
-
const separator = value.indexOf("/");
|
|
948
|
-
return separator > 0 && separator < value.length - 1 ? value.slice(separator + 1) : void 0;
|
|
949
|
-
}
|
|
950
|
-
function matchAdvertisedModelValue(requestedModelId, advertisedValues) {
|
|
951
|
-
const wanted = requestedModelId.trim();
|
|
952
|
-
if (!wanted) return void 0;
|
|
953
|
-
if (advertisedValues.includes(wanted)) return wanted;
|
|
954
|
-
const byLastSegment = advertisedValues.filter(
|
|
955
|
-
(value) => catalogModelLastSegment(value) === wanted
|
|
956
|
-
);
|
|
957
|
-
return byLastSegment.length === 1 ? byLastSegment[0] : void 0;
|
|
958
|
-
}
|
|
959
964
|
function parseSessionModeState(sessionResponse) {
|
|
960
965
|
const modes = sessionResponse.modes;
|
|
961
966
|
if (!modes) return void 0;
|
|
@@ -22871,17 +22876,17 @@ function isResponseMessage(value) {
|
|
|
22871
22876
|
function isNotificationMessage(value) {
|
|
22872
22877
|
return isJsonRpcEnvelope(value) && !("id" in value) && typeof value["method"] === "string";
|
|
22873
22878
|
}
|
|
22874
|
-
function
|
|
22879
|
+
function isRecord4(value) {
|
|
22875
22880
|
return typeof value === "object" && value !== null;
|
|
22876
22881
|
}
|
|
22877
22882
|
function isJsonRpcEnvelope(value) {
|
|
22878
|
-
return
|
|
22883
|
+
return isRecord4(value) && value["jsonrpc"] === "2.0";
|
|
22879
22884
|
}
|
|
22880
22885
|
function isJsonRpcId(value) {
|
|
22881
22886
|
return value === null || typeof value === "string" || typeof value === "number" && Number.isFinite(value);
|
|
22882
22887
|
}
|
|
22883
22888
|
function isResponseShapedMessage(value) {
|
|
22884
|
-
return
|
|
22889
|
+
return isRecord4(value) && !("method" in value) && ("id" in value || "result" in value || "error" in value);
|
|
22885
22890
|
}
|
|
22886
22891
|
function isResponseBatch(batch) {
|
|
22887
22892
|
let hasValidCall = false;
|
|
@@ -22891,7 +22896,7 @@ function isResponseBatch(batch) {
|
|
|
22891
22896
|
for (const entry of batch) {
|
|
22892
22897
|
hasValidCall ||= isRequestMessage(entry) || isNotificationMessage(entry);
|
|
22893
22898
|
hasValidResponse ||= isResponseMessage(entry);
|
|
22894
|
-
if (!
|
|
22899
|
+
if (!isRecord4(entry)) {
|
|
22895
22900
|
continue;
|
|
22896
22901
|
}
|
|
22897
22902
|
hasCallShape ||= "method" in entry;
|
|
@@ -22906,13 +22911,13 @@ function isResponseBatch(batch) {
|
|
|
22906
22911
|
return hasResponseShape && !hasCallShape;
|
|
22907
22912
|
}
|
|
22908
22913
|
function cancelRequestId(params) {
|
|
22909
|
-
if (!
|
|
22914
|
+
if (!isRecord4(params) || !isJsonRpcId(params["requestId"])) {
|
|
22910
22915
|
return void 0;
|
|
22911
22916
|
}
|
|
22912
22917
|
return params["requestId"];
|
|
22913
22918
|
}
|
|
22914
22919
|
function isErrorResponse(value) {
|
|
22915
|
-
return
|
|
22920
|
+
return isRecord4(value) && typeof value["code"] === "number" && Number.isInteger(value["code"]) && typeof value["message"] === "string";
|
|
22916
22921
|
}
|
|
22917
22922
|
var Handled = {
|
|
22918
22923
|
/**
|
|
@@ -23457,7 +23462,7 @@ var Connection = class {
|
|
|
23457
23462
|
if (this.abortController.signal.aborted) {
|
|
23458
23463
|
return Promise.resolve();
|
|
23459
23464
|
}
|
|
23460
|
-
if (!
|
|
23465
|
+
if (!isRecord4(message)) {
|
|
23461
23466
|
console.error("Invalid message", { message });
|
|
23462
23467
|
return Promise.resolve();
|
|
23463
23468
|
}
|
|
@@ -23860,7 +23865,7 @@ function ndJsonStream(output2, input2) {
|
|
|
23860
23865
|
await writeJson(protocolErrorResponse(RequestError.parseError()));
|
|
23861
23866
|
return;
|
|
23862
23867
|
}
|
|
23863
|
-
if (
|
|
23868
|
+
if (isRecord4(message) || Array.isArray(message)) {
|
|
23864
23869
|
controller.enqueue(message);
|
|
23865
23870
|
} else {
|
|
23866
23871
|
await writeJson(protocolErrorResponse(RequestError.invalidRequest(message)));
|
|
@@ -24847,14 +24852,14 @@ var legacyClientNotificationMethods = /* @__PURE__ */ new Set([
|
|
|
24847
24852
|
import * as NodeStream from "node:stream";
|
|
24848
24853
|
|
|
24849
24854
|
// ../../packages/ycodium-acp-executor/src/jsonrpc.ts
|
|
24850
|
-
function
|
|
24855
|
+
function isRecord5(value) {
|
|
24851
24856
|
return typeof value === "object" && value !== null;
|
|
24852
24857
|
}
|
|
24853
24858
|
function isJsonRpcId2(value) {
|
|
24854
24859
|
return typeof value === "string" || typeof value === "number" && Number.isFinite(value);
|
|
24855
24860
|
}
|
|
24856
24861
|
function isJsonRpcEnvelope2(value) {
|
|
24857
|
-
return
|
|
24862
|
+
return isRecord5(value) && value["jsonrpc"] === "2.0";
|
|
24858
24863
|
}
|
|
24859
24864
|
function isRequestMessage2(value) {
|
|
24860
24865
|
return isJsonRpcEnvelope2(value) && "id" in value && typeof value["method"] === "string" && isJsonRpcId2(value["id"]);
|
|
@@ -24874,7 +24879,7 @@ function isNotificationMessage2(value) {
|
|
|
24874
24879
|
return isJsonRpcEnvelope2(value) && !("id" in value) && typeof value["method"] === "string";
|
|
24875
24880
|
}
|
|
24876
24881
|
function readJsonRpcError(value) {
|
|
24877
|
-
if (!
|
|
24882
|
+
if (!isRecord5(value) || typeof value["code"] !== "number" || typeof value["message"] !== "string") {
|
|
24878
24883
|
return void 0;
|
|
24879
24884
|
}
|
|
24880
24885
|
return {
|
|
@@ -24947,11 +24952,11 @@ var KNOWN_SESSION_UPDATES = /* @__PURE__ */ new Set([
|
|
|
24947
24952
|
"compaction_summary_chunk"
|
|
24948
24953
|
]);
|
|
24949
24954
|
function isSessionUpdateEnvelope(payload) {
|
|
24950
|
-
if (!
|
|
24955
|
+
if (!isRecord5(payload) || typeof payload["sessionId"] !== "string") {
|
|
24951
24956
|
return false;
|
|
24952
24957
|
}
|
|
24953
24958
|
const update = payload["update"];
|
|
24954
|
-
return
|
|
24959
|
+
return isRecord5(update) && typeof update["sessionUpdate"] === "string";
|
|
24955
24960
|
}
|
|
24956
24961
|
function hasKnownVariantShape(update) {
|
|
24957
24962
|
const kind = update["sessionUpdate"];
|
|
@@ -24959,7 +24964,7 @@ function hasKnownVariantShape(update) {
|
|
|
24959
24964
|
return false;
|
|
24960
24965
|
}
|
|
24961
24966
|
if (kind === "user_message_chunk" || kind === "agent_message_chunk" || kind === "agent_thought_chunk") {
|
|
24962
|
-
return
|
|
24967
|
+
return isRecord5(update["content"]);
|
|
24963
24968
|
}
|
|
24964
24969
|
return true;
|
|
24965
24970
|
}
|
|
@@ -25727,7 +25732,7 @@ var alignRequestedEffort = async (input2) => {
|
|
|
25727
25732
|
return { configOptions, unsupportedEffort, ...confirmed ? { appliedEffort: fallback } : {} };
|
|
25728
25733
|
};
|
|
25729
25734
|
|
|
25730
|
-
// ../../packages/ycodium-
|
|
25735
|
+
// ../../packages/ycodium-executor-common/src/reasoningLevelFallback.ts
|
|
25731
25736
|
var REASONING_LEVEL_FALLBACK_CODE = "reasoning-level-fallback";
|
|
25732
25737
|
function reasoningLevelFallbackWarning(input2) {
|
|
25733
25738
|
const model = input2.model ?? "This model";
|
|
@@ -26879,7 +26884,7 @@ function makeArtifactEmitter(input2) {
|
|
|
26879
26884
|
// ../../packages/ycodium-acp-executor/src/executor/runtime.ts
|
|
26880
26885
|
function createExecutorRuntime({
|
|
26881
26886
|
randomId,
|
|
26882
|
-
nowIso:
|
|
26887
|
+
nowIso: nowIso3,
|
|
26883
26888
|
eventStream,
|
|
26884
26889
|
options,
|
|
26885
26890
|
assistantItemRuntimeId,
|
|
@@ -26888,7 +26893,7 @@ function createExecutorRuntime({
|
|
|
26888
26893
|
}) {
|
|
26889
26894
|
const stamp = () => ({
|
|
26890
26895
|
eventId: randomId(),
|
|
26891
|
-
createdAt:
|
|
26896
|
+
createdAt: nowIso3()
|
|
26892
26897
|
});
|
|
26893
26898
|
const isLive = (expectedGeneration) => !shared.disposed && shared.generation === expectedGeneration;
|
|
26894
26899
|
const publish = (event) => {
|
|
@@ -27066,7 +27071,7 @@ function judgeRequestedModel(input2) {
|
|
|
27066
27071
|
const hasCurrent = current !== void 0;
|
|
27067
27072
|
if (!hasCatalog && !hasCurrent && input2.state.modelUnconfirmed !== true) return { kind: "keep" };
|
|
27068
27073
|
const canSwitch = canSwitchModel(input2.state);
|
|
27069
|
-
const value = hasCatalog ?
|
|
27074
|
+
const value = hasCatalog ? matchCatalogModel(requested, input2.state.advertisedModelValues) : void 0;
|
|
27070
27075
|
if (value !== void 0 && value === current) return { kind: "keep" };
|
|
27071
27076
|
if (value !== void 0 && canSwitch) return { kind: "switch", value };
|
|
27072
27077
|
return { kind: "refresh" };
|
|
@@ -27106,23 +27111,23 @@ function modelRefreshFailedError(requestedModelId, error62) {
|
|
|
27106
27111
|
}
|
|
27107
27112
|
|
|
27108
27113
|
// ../../packages/ycodium-acp-executor/src/runtime-mode.ts
|
|
27109
|
-
function
|
|
27114
|
+
function isRecord6(value) {
|
|
27110
27115
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27111
27116
|
}
|
|
27112
27117
|
function asString2(value) {
|
|
27113
27118
|
return typeof value === "string" ? value : void 0;
|
|
27114
27119
|
}
|
|
27115
27120
|
function acpAvailableModes(setup) {
|
|
27116
|
-
if (!
|
|
27121
|
+
if (!isRecord6(setup)) return [];
|
|
27117
27122
|
const out = [];
|
|
27118
27123
|
const seen = /* @__PURE__ */ new Set();
|
|
27119
27124
|
const push = (entry) => {
|
|
27120
|
-
if (!
|
|
27125
|
+
if (!isRecord6(entry)) return;
|
|
27121
27126
|
const id = (asString2(entry["id"]) ?? asString2(entry["value"]))?.trim();
|
|
27122
27127
|
if (!id || seen.has(id)) return;
|
|
27123
27128
|
seen.add(id);
|
|
27124
27129
|
const meta3 = entry["_meta"];
|
|
27125
|
-
const kind =
|
|
27130
|
+
const kind = isRecord6(meta3) ? asString2(meta3["kind"])?.trim().toLowerCase() : void 0;
|
|
27126
27131
|
const name = asString2(entry["name"])?.trim();
|
|
27127
27132
|
const description = asString2(entry["description"])?.trim();
|
|
27128
27133
|
out.push({
|
|
@@ -27133,13 +27138,13 @@ function acpAvailableModes(setup) {
|
|
|
27133
27138
|
});
|
|
27134
27139
|
};
|
|
27135
27140
|
const modes = setup["modes"];
|
|
27136
|
-
if (
|
|
27141
|
+
if (isRecord6(modes) && Array.isArray(modes["availableModes"])) {
|
|
27137
27142
|
for (const entry of modes["availableModes"]) push(entry);
|
|
27138
27143
|
}
|
|
27139
27144
|
const configOptions = setup["configOptions"];
|
|
27140
27145
|
if (Array.isArray(configOptions)) {
|
|
27141
27146
|
for (const option of configOptions) {
|
|
27142
|
-
if (!
|
|
27147
|
+
if (!isRecord6(option)) continue;
|
|
27143
27148
|
if (asString2(option["category"])?.trim().toLowerCase() !== "mode") continue;
|
|
27144
27149
|
if (!Array.isArray(option["options"])) continue;
|
|
27145
27150
|
for (const entry of option["options"]) push(entry);
|
|
@@ -27148,11 +27153,11 @@ function acpAvailableModes(setup) {
|
|
|
27148
27153
|
return out;
|
|
27149
27154
|
}
|
|
27150
27155
|
function acpModeConfigId(setup) {
|
|
27151
|
-
if (!
|
|
27156
|
+
if (!isRecord6(setup)) return void 0;
|
|
27152
27157
|
const configOptions = setup["configOptions"];
|
|
27153
27158
|
if (!Array.isArray(configOptions)) return void 0;
|
|
27154
27159
|
for (const option of configOptions) {
|
|
27155
|
-
if (!
|
|
27160
|
+
if (!isRecord6(option)) continue;
|
|
27156
27161
|
if (asString2(option["category"])?.trim().toLowerCase() !== "mode") continue;
|
|
27157
27162
|
const id = asString2(option["id"])?.trim();
|
|
27158
27163
|
if (id) return id;
|
|
@@ -27160,16 +27165,16 @@ function acpModeConfigId(setup) {
|
|
|
27160
27165
|
return void 0;
|
|
27161
27166
|
}
|
|
27162
27167
|
function acpCurrentModeId(setup) {
|
|
27163
|
-
if (!
|
|
27168
|
+
if (!isRecord6(setup)) return void 0;
|
|
27164
27169
|
const modes = setup["modes"];
|
|
27165
|
-
if (
|
|
27170
|
+
if (isRecord6(modes)) {
|
|
27166
27171
|
const current = asString2(modes["currentModeId"])?.trim();
|
|
27167
27172
|
if (current) return current;
|
|
27168
27173
|
}
|
|
27169
27174
|
const configOptions = setup["configOptions"];
|
|
27170
27175
|
if (Array.isArray(configOptions)) {
|
|
27171
27176
|
for (const option of configOptions) {
|
|
27172
|
-
if (!
|
|
27177
|
+
if (!isRecord6(option)) continue;
|
|
27173
27178
|
if (asString2(option["category"])?.trim().toLowerCase() !== "mode") continue;
|
|
27174
27179
|
const current = asString2(option["currentValue"])?.trim();
|
|
27175
27180
|
if (current) return current;
|
|
@@ -28178,7 +28183,7 @@ function defaultRandomId() {
|
|
|
28178
28183
|
function createAcpExecutor(options) {
|
|
28179
28184
|
const hooks = { ...defaultVendorHooks, ...options.hooks };
|
|
28180
28185
|
const cancelGraceMs = options.cancelGraceMs ?? DEFAULT_CANCEL_GRACE_MS;
|
|
28181
|
-
const
|
|
28186
|
+
const nowIso3 = options.nowIso ?? defaultNowIso;
|
|
28182
28187
|
const randomId = options.randomId ?? defaultRandomId;
|
|
28183
28188
|
const eventStream = new UnboundedEventStream();
|
|
28184
28189
|
const threadMutex = new Mutex();
|
|
@@ -28239,7 +28244,7 @@ function createAcpExecutor(options) {
|
|
|
28239
28244
|
waitForPromptIdle
|
|
28240
28245
|
} = createExecutorRuntime({
|
|
28241
28246
|
randomId,
|
|
28242
|
-
nowIso:
|
|
28247
|
+
nowIso: nowIso3,
|
|
28243
28248
|
eventStream,
|
|
28244
28249
|
options,
|
|
28245
28250
|
assistantItemRuntimeId,
|
|
@@ -28483,7 +28488,7 @@ function createAcpExecutor(options) {
|
|
|
28483
28488
|
}
|
|
28484
28489
|
|
|
28485
28490
|
// ../../packages/ycodium-acp-executor/src/session-registry.ts
|
|
28486
|
-
function createAcpSessionRegistry(threads,
|
|
28491
|
+
function createAcpSessionRegistry(threads, stopBooked, log) {
|
|
28487
28492
|
const exits = /* @__PURE__ */ new WeakMap();
|
|
28488
28493
|
const requireThread = (threadId) => {
|
|
28489
28494
|
const booked = threads.get(threadId);
|
|
@@ -28494,7 +28499,7 @@ function createAcpSessionRegistry(threads, stopBooked2, log) {
|
|
|
28494
28499
|
const stopSession = (threadId, booked = threads.get(threadId)) => {
|
|
28495
28500
|
if (!booked) return Promise.resolve();
|
|
28496
28501
|
const close = { exitCode: exits.get(booked), hasExited: () => exits.has(booked) };
|
|
28497
|
-
booked.closing ??= Promise.resolve().then(() =>
|
|
28502
|
+
booked.closing ??= Promise.resolve().then(() => stopBooked(booked, close)).then(() => {
|
|
28498
28503
|
if (threads.get(threadId) === booked) threads.delete(threadId);
|
|
28499
28504
|
}).catch((cause) => {
|
|
28500
28505
|
if (threads.get(threadId) === booked) delete booked.closing;
|
|
@@ -28597,22 +28602,225 @@ var dispatchAcpPrompt = (executor, input2) => {
|
|
|
28597
28602
|
]);
|
|
28598
28603
|
};
|
|
28599
28604
|
|
|
28600
|
-
// ../../packages/ycodium-acp-executor/src/
|
|
28601
|
-
|
|
28602
|
-
|
|
28605
|
+
// ../../packages/ycodium-acp-executor/src/thread-operations.ts
|
|
28606
|
+
var yieldTick = () => new Promise((resolve2) => {
|
|
28607
|
+
setImmediate(resolve2);
|
|
28608
|
+
});
|
|
28609
|
+
var nowIso = () => (/* @__PURE__ */ new Date()).toISOString();
|
|
28610
|
+
function createAcpThreadOperations(options) {
|
|
28611
|
+
const { threads, requireThread } = options;
|
|
28612
|
+
return {
|
|
28613
|
+
sendTurn: async (input2, signal) => {
|
|
28614
|
+
if (options.isDisposed()) throw new Error("instance disposed");
|
|
28615
|
+
const booked = requireThread(input2.threadId);
|
|
28616
|
+
if (signal?.aborted) throw new Error("aborted");
|
|
28617
|
+
options.beforeSendTurn?.(booked);
|
|
28618
|
+
const onAbort = () => {
|
|
28619
|
+
void booked.executor.cancel(input2.expectedTurnId).catch(() => void 0);
|
|
28620
|
+
};
|
|
28621
|
+
signal?.addEventListener("abort", onAbort);
|
|
28622
|
+
try {
|
|
28623
|
+
const { requestedModelId, requestedEffort } = options.turnSelection?.(input2.modelSelection) ?? {};
|
|
28624
|
+
const turn = await dispatchAcpPrompt(booked.executor, {
|
|
28625
|
+
text: input2.input ?? "",
|
|
28626
|
+
expectedActiveTurnId: input2.expectedTurnId,
|
|
28627
|
+
...requestedModelId === void 0 ? {} : { requestedModelId },
|
|
28628
|
+
...requestedEffort === void 0 ? {} : { requestedEffort }
|
|
28629
|
+
});
|
|
28630
|
+
booked.turns.push({ id: turn.turnId, items: [] });
|
|
28631
|
+
return {
|
|
28632
|
+
threadId: input2.threadId,
|
|
28633
|
+
turnId: turn.turnId,
|
|
28634
|
+
...booked.session.resumeCursor === void 0 ? {} : { resumeCursor: booked.session.resumeCursor }
|
|
28635
|
+
};
|
|
28636
|
+
} finally {
|
|
28637
|
+
signal?.removeEventListener("abort", onAbort);
|
|
28638
|
+
}
|
|
28639
|
+
},
|
|
28640
|
+
interruptTurn: async (threadId, turnId) => {
|
|
28641
|
+
const booked = threads.get(threadId);
|
|
28642
|
+
if (booked === void 0 || booked.closing) return;
|
|
28643
|
+
options.log.info("interrupt turn", { threadId, turnId });
|
|
28644
|
+
await booked.executor.cancel(turnId);
|
|
28645
|
+
await yieldTick();
|
|
28646
|
+
},
|
|
28647
|
+
respondToRequest: async (threadId, requestId, decision, reason) => {
|
|
28648
|
+
const booked = requireThread(threadId);
|
|
28649
|
+
await booked.executor.respondToRequest(
|
|
28650
|
+
requestId,
|
|
28651
|
+
decision === "allow" ? "accept" : "decline",
|
|
28652
|
+
reason
|
|
28653
|
+
);
|
|
28654
|
+
},
|
|
28655
|
+
respondToUserInput: async (threadId, requestId, answers) => {
|
|
28656
|
+
const booked = requireThread(threadId);
|
|
28657
|
+
await booked.executor.respondToUserInput(requestId, answers);
|
|
28658
|
+
},
|
|
28659
|
+
/**
|
|
28660
|
+
* 切这只手自报的审批档。`nativeModeId` 是它自己报的 id(探测时原样上报的那些),
|
|
28661
|
+
* 一路不翻译成宿主四档。
|
|
28662
|
+
*
|
|
28663
|
+
* 这是 `setRuntimeMode` 做不到的那一半:那个只改插件自己的会话记录,CLI 收不到
|
|
28664
|
+
* (`runtime-mode-never-reaches-cli` 记的那族缺陷)。
|
|
28665
|
+
*/
|
|
28666
|
+
setNativeMode: async (threadId, nativeModeId) => {
|
|
28667
|
+
const booked = requireThread(threadId);
|
|
28668
|
+
await booked.executor.setNativeMode(nativeModeId);
|
|
28669
|
+
booked.session = { ...booked.session, nativeModeId, updatedAt: nowIso() };
|
|
28670
|
+
},
|
|
28671
|
+
setRuntimeMode: async (threadId, runtimeMode) => {
|
|
28672
|
+
const booked = requireThread(threadId);
|
|
28673
|
+
booked.session = { ...booked.session, runtimeMode, updatedAt: nowIso() };
|
|
28674
|
+
},
|
|
28675
|
+
readThread: async (threadId) => {
|
|
28676
|
+
const booked = requireThread(threadId);
|
|
28677
|
+
return { threadId, turns: booked.turns };
|
|
28678
|
+
}
|
|
28679
|
+
};
|
|
28603
28680
|
}
|
|
28604
|
-
|
|
28605
|
-
|
|
28606
|
-
|
|
28607
|
-
if (
|
|
28608
|
-
|
|
28609
|
-
|
|
28610
|
-
|
|
28611
|
-
|
|
28612
|
-
|
|
28613
|
-
|
|
28614
|
-
|
|
28681
|
+
|
|
28682
|
+
// ../../packages/ycodium-executor-common/src/modelSelection.ts
|
|
28683
|
+
function modelSelectionStringOption(selection, optionId) {
|
|
28684
|
+
if (typeof selection !== "object" || selection === null || Array.isArray(selection)) {
|
|
28685
|
+
return void 0;
|
|
28686
|
+
}
|
|
28687
|
+
const options = selection["options"];
|
|
28688
|
+
if (!Array.isArray(options)) return void 0;
|
|
28689
|
+
for (const entry of options) {
|
|
28690
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) continue;
|
|
28691
|
+
const record2 = entry;
|
|
28692
|
+
if (record2["id"] !== optionId) continue;
|
|
28693
|
+
const value = record2["value"];
|
|
28694
|
+
return typeof value === "string" ? value.trim() || void 0 : void 0;
|
|
28695
|
+
}
|
|
28696
|
+
return void 0;
|
|
28697
|
+
}
|
|
28698
|
+
|
|
28699
|
+
// ../../packages/ycodium-executor-common/src/nodeStreams.ts
|
|
28700
|
+
import * as NodeOS2 from "node:os";
|
|
28701
|
+
import * as NodeStream2 from "node:stream";
|
|
28702
|
+
var PEER_CLOSED_STDIN_CODES = /* @__PURE__ */ new Set([
|
|
28703
|
+
"EPIPE",
|
|
28704
|
+
"ECONNRESET",
|
|
28705
|
+
"EOF",
|
|
28706
|
+
"ERR_STREAM_DESTROYED",
|
|
28707
|
+
"ERR_STREAM_WRITE_AFTER_END",
|
|
28708
|
+
"ERR_STREAM_ALREADY_FINISHED"
|
|
28709
|
+
]);
|
|
28710
|
+
function errorCode(value) {
|
|
28711
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
28712
|
+
const code = value.code;
|
|
28713
|
+
return typeof code === "string" ? code : void 0;
|
|
28714
|
+
}
|
|
28715
|
+
function asError(value) {
|
|
28716
|
+
return value instanceof Error ? value : new Error(String(value));
|
|
28717
|
+
}
|
|
28718
|
+
function isPeerClosedStdinError(error62) {
|
|
28719
|
+
const code = errorCode(error62);
|
|
28720
|
+
return code !== void 0 && PEER_CLOSED_STDIN_CODES.has(code);
|
|
28721
|
+
}
|
|
28722
|
+
var PeerClosedStdinError = class extends Error {
|
|
28723
|
+
name = "PeerClosedStdinError";
|
|
28724
|
+
code;
|
|
28725
|
+
constructor(operation, cause) {
|
|
28726
|
+
super(
|
|
28727
|
+
`Child process stdin is closed; the ${operation} did not reach the peer.`,
|
|
28728
|
+
cause === void 0 ? void 0 : { cause }
|
|
28729
|
+
);
|
|
28730
|
+
this.code = errorCode(cause) ?? "ERR_STREAM_DESTROYED";
|
|
28731
|
+
}
|
|
28732
|
+
};
|
|
28733
|
+
var ownErrors = {
|
|
28734
|
+
isPeerClosed: isPeerClosedStdinError,
|
|
28735
|
+
peerClosed: (operation, cause) => new PeerClosedStdinError(operation, cause)
|
|
28736
|
+
};
|
|
28737
|
+
function toStreamError(errors, operation, error62) {
|
|
28738
|
+
if (errors.isPeerClosed(error62)) return errors.peerClosed(operation, error62);
|
|
28739
|
+
return asError(error62);
|
|
28740
|
+
}
|
|
28741
|
+
function nodeWritableFromHandle(handle, errors = ownErrors) {
|
|
28742
|
+
return new NodeStream2.Writable({
|
|
28743
|
+
write(chunk, _encoding, callback) {
|
|
28744
|
+
const bytes = typeof chunk === "string" ? new TextEncoder().encode(chunk) : chunk;
|
|
28745
|
+
handle.writeStdin(bytes).then(
|
|
28746
|
+
() => callback(),
|
|
28747
|
+
(error62) => callback(toStreamError(errors, "write", error62))
|
|
28748
|
+
);
|
|
28749
|
+
},
|
|
28750
|
+
final(callback) {
|
|
28751
|
+
handle.closeStdin().then(
|
|
28752
|
+
() => callback(),
|
|
28753
|
+
// 关一条对端已经没了的流是正常收尾,不是失败;真异常照旧交出去。
|
|
28754
|
+
(error62) => callback(errors.isPeerClosed(error62) ? void 0 : toStreamError(errors, "close", error62))
|
|
28755
|
+
);
|
|
28756
|
+
}
|
|
28757
|
+
});
|
|
28758
|
+
}
|
|
28759
|
+
var STDERR_TAIL_MAX_CHARS = 4096;
|
|
28760
|
+
var STDERR_SETTLE_MS = 500;
|
|
28761
|
+
var PAIRING_URL_PATTERN = /https?:\/\/[^\s]*\/pair#[^\s]*/gi;
|
|
28762
|
+
var BEARER_TOKEN_PATTERN = /\bBearer\s+[A-Za-z0-9._\-+=/]+/gi;
|
|
28763
|
+
var BASIC_AUTH_PATTERN = /\bAuthorization:\s*Basic\s+\S+/gi;
|
|
28764
|
+
var API_KEY_HEADER_PATTERN = /\bx-api-key:\s*\S+/gi;
|
|
28765
|
+
var SECRET_TOKEN_PATTERN = /\b(?:sk-[A-Za-z0-9][A-Za-z0-9-]{7,}|ghp_[A-Za-z0-9]+|xox[a-zA-Z]-[A-Za-z0-9-]+)\b/g;
|
|
28766
|
+
function redactStderrExcerpt(text, environment = process.env) {
|
|
28767
|
+
let result = text.replaceAll("\0", "");
|
|
28768
|
+
const homes = [environment["HOME"], environment["USERPROFILE"], NodeOS2.homedir()].filter(
|
|
28769
|
+
(value) => typeof value === "string" && value.length > 1
|
|
28770
|
+
);
|
|
28771
|
+
for (const home of new Set(homes)) {
|
|
28772
|
+
result = result.split(home).join("~");
|
|
28615
28773
|
}
|
|
28774
|
+
return result.replace(PAIRING_URL_PATTERN, "[pairing-url]").replace(BEARER_TOKEN_PATTERN, "Bearer [redacted]").replace(BASIC_AUTH_PATTERN, "Authorization: Basic [redacted]").replace(API_KEY_HEADER_PATTERN, "x-api-key: [redacted]").replace(SECRET_TOKEN_PATTERN, "[redacted]").trim();
|
|
28775
|
+
}
|
|
28776
|
+
function drainStderrTail(stderr) {
|
|
28777
|
+
let tail = "";
|
|
28778
|
+
const decoder = new TextDecoder();
|
|
28779
|
+
const drained = (async () => {
|
|
28780
|
+
for await (const chunk of stderr) {
|
|
28781
|
+
const next = tail + decoder.decode(chunk, { stream: true });
|
|
28782
|
+
tail = next.length <= STDERR_TAIL_MAX_CHARS ? next : next.slice(-STDERR_TAIL_MAX_CHARS);
|
|
28783
|
+
}
|
|
28784
|
+
})().catch(() => void 0);
|
|
28785
|
+
return async () => {
|
|
28786
|
+
let timer;
|
|
28787
|
+
await Promise.race([
|
|
28788
|
+
drained,
|
|
28789
|
+
new Promise((resolve2) => {
|
|
28790
|
+
timer = setTimeout(resolve2, STDERR_SETTLE_MS);
|
|
28791
|
+
})
|
|
28792
|
+
]);
|
|
28793
|
+
clearTimeout(timer);
|
|
28794
|
+
return redactStderrExcerpt(tail);
|
|
28795
|
+
};
|
|
28796
|
+
}
|
|
28797
|
+
function nodeStreamsFromHandle(handle, errors = ownErrors) {
|
|
28798
|
+
const readable = new NodeStream2.PassThrough();
|
|
28799
|
+
void (async () => {
|
|
28800
|
+
try {
|
|
28801
|
+
for await (const chunk of handle.stdout) {
|
|
28802
|
+
if (!readable.writable) return;
|
|
28803
|
+
if (!readable.write(chunk)) {
|
|
28804
|
+
await new Promise((resolve2) => {
|
|
28805
|
+
const onDone = () => {
|
|
28806
|
+
readable.off("drain", onDone);
|
|
28807
|
+
readable.off("close", onDone);
|
|
28808
|
+
resolve2();
|
|
28809
|
+
};
|
|
28810
|
+
readable.once("drain", onDone);
|
|
28811
|
+
readable.once("close", onDone);
|
|
28812
|
+
});
|
|
28813
|
+
}
|
|
28814
|
+
}
|
|
28815
|
+
} catch (error62) {
|
|
28816
|
+
readable.destroy(asError(error62));
|
|
28817
|
+
return;
|
|
28818
|
+
}
|
|
28819
|
+
if (readable.writable) readable.end();
|
|
28820
|
+
})();
|
|
28821
|
+
const settledStderrTail = drainStderrTail(handle.stderr);
|
|
28822
|
+
const writable = nodeWritableFromHandle(handle, errors);
|
|
28823
|
+
return { readable, writable, stderrTail: settledStderrTail };
|
|
28616
28824
|
}
|
|
28617
28825
|
|
|
28618
28826
|
// ../../packages/ycodium-acp-executor/src/mcp-servers.ts
|
|
@@ -28635,20 +28843,284 @@ function toAcpMcpServers(entries) {
|
|
|
28635
28843
|
);
|
|
28636
28844
|
}
|
|
28637
28845
|
|
|
28638
|
-
// ../../packages/ycodium-acp-executor/src/
|
|
28639
|
-
function
|
|
28640
|
-
signal?.
|
|
28641
|
-
|
|
28642
|
-
|
|
28643
|
-
|
|
28644
|
-
|
|
28645
|
-
|
|
28646
|
-
|
|
28647
|
-
|
|
28648
|
-
|
|
28649
|
-
|
|
28650
|
-
|
|
28651
|
-
|
|
28846
|
+
// ../../packages/ycodium-acp-executor/src/start-abort.ts
|
|
28847
|
+
function throwIfStartAborted(signal) {
|
|
28848
|
+
if (signal?.aborted) throw new Error("aborted");
|
|
28849
|
+
}
|
|
28850
|
+
async function raceStartAbort(promise2, signal) {
|
|
28851
|
+
void promise2.catch(() => void 0);
|
|
28852
|
+
throwIfStartAborted(signal);
|
|
28853
|
+
if (signal === void 0) return promise2;
|
|
28854
|
+
const aborted2 = Promise.withResolvers();
|
|
28855
|
+
const onAbort = () => aborted2.reject(new Error("aborted"));
|
|
28856
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
28857
|
+
try {
|
|
28858
|
+
return await Promise.race([promise2, aborted2.promise]);
|
|
28859
|
+
} finally {
|
|
28860
|
+
signal.removeEventListener("abort", onAbort);
|
|
28861
|
+
}
|
|
28862
|
+
}
|
|
28863
|
+
|
|
28864
|
+
// ../../packages/ycodium-acp-executor/src/instance-kit.ts
|
|
28865
|
+
var yieldTick2 = () => new Promise((resolve2) => {
|
|
28866
|
+
setImmediate(resolve2);
|
|
28867
|
+
});
|
|
28868
|
+
var nowIso2 = () => (/* @__PURE__ */ new Date()).toISOString();
|
|
28869
|
+
function createAcpThreadTable(log, beforeStopAll) {
|
|
28870
|
+
const threads = /* @__PURE__ */ new Map();
|
|
28871
|
+
const registry2 = createAcpSessionRegistry(
|
|
28872
|
+
threads,
|
|
28873
|
+
(booked, processExit) => cleanupAcpSession({
|
|
28874
|
+
executor: booked.executor,
|
|
28875
|
+
stopProcess: () => booked.handle.kill("SIGTERM"),
|
|
28876
|
+
forwarding: booked.forwarding,
|
|
28877
|
+
processExit
|
|
28878
|
+
}),
|
|
28879
|
+
log
|
|
28880
|
+
);
|
|
28881
|
+
const disposeOnce = createRetryableClose(async () => {
|
|
28882
|
+
await beforeStopAll?.();
|
|
28883
|
+
await registry2.stopAll();
|
|
28884
|
+
});
|
|
28885
|
+
return { threads, ...registry2, disposeOnce };
|
|
28886
|
+
}
|
|
28887
|
+
function bindAcpInstanceThreads(input2) {
|
|
28888
|
+
const table = createAcpThreadTable(input2.log);
|
|
28889
|
+
const { threads, requireThread, registerSession, stopSession, disposeOnce } = table;
|
|
28890
|
+
const threadOps = createAcpThreadOperations({
|
|
28891
|
+
threads,
|
|
28892
|
+
requireThread,
|
|
28893
|
+
isDisposed: input2.isDisposed,
|
|
28894
|
+
log: input2.log,
|
|
28895
|
+
...input2.turnSelection === void 0 ? {} : { turnSelection: input2.turnSelection },
|
|
28896
|
+
...input2.beforeSendTurn === void 0 ? {} : { beforeSendTurn: input2.beforeSendTurn }
|
|
28897
|
+
});
|
|
28898
|
+
return { table, threads, requireThread, registerSession, stopSession, disposeOnce, threadOps };
|
|
28899
|
+
}
|
|
28900
|
+
function acpProgramNotConfigured(detail) {
|
|
28901
|
+
return {
|
|
28902
|
+
installed: false,
|
|
28903
|
+
version: null,
|
|
28904
|
+
readiness: "not-installed",
|
|
28905
|
+
auth: { status: "unknown" },
|
|
28906
|
+
detail
|
|
28907
|
+
};
|
|
28908
|
+
}
|
|
28909
|
+
function acpOwnedSpawnSpec(input2) {
|
|
28910
|
+
return {
|
|
28911
|
+
program: input2.program,
|
|
28912
|
+
args: [...input2.args],
|
|
28913
|
+
cwd: input2.cwd,
|
|
28914
|
+
owner: { bindingId: input2.bindingId },
|
|
28915
|
+
...Object.keys(input2.env).length > 0 ? { env: { ...input2.env } } : {}
|
|
28916
|
+
};
|
|
28917
|
+
}
|
|
28918
|
+
function acpLaunchFromHandle(input2) {
|
|
28919
|
+
const { readable, writable, stderrTail } = nodeStreamsFromHandle(input2.handle);
|
|
28920
|
+
const resume = acpResumeFrom(input2.start, input2.resumeSchemaVersion);
|
|
28921
|
+
const requestedModelId = input2.modelIdFromSelection(input2.modelSelection);
|
|
28922
|
+
const requestedEffort = modelSelectionStringOption(input2.modelSelection, input2.effortOptionId);
|
|
28923
|
+
return { readable, writable, stderrTail, resume, requestedModelId, requestedEffort };
|
|
28924
|
+
}
|
|
28925
|
+
async function stopExistingAcpThread(table, threadId, isDisposed, signal) {
|
|
28926
|
+
const existing = table.threads.get(threadId);
|
|
28927
|
+
if (existing === void 0) return;
|
|
28928
|
+
await table.stopSession(threadId, existing);
|
|
28929
|
+
if (isDisposed()) throw new Error("instance disposed");
|
|
28930
|
+
throwIfStartAborted(signal);
|
|
28931
|
+
}
|
|
28932
|
+
function acpResumeFrom(input2, schemaVersion) {
|
|
28933
|
+
return input2.discardResumeCursor === true ? void 0 : parseAcpResumeCursor(input2.resumeCursor, schemaVersion);
|
|
28934
|
+
}
|
|
28935
|
+
function acpStartedSession(input2, started) {
|
|
28936
|
+
const createdAt = nowIso2();
|
|
28937
|
+
return {
|
|
28938
|
+
provider: input2.provider,
|
|
28939
|
+
providerInstanceId: input2.providerInstanceId,
|
|
28940
|
+
status: "idle",
|
|
28941
|
+
runtimeMode: input2.runtimeMode,
|
|
28942
|
+
...input2.nativeModeId === void 0 ? {} : { nativeModeId: input2.nativeModeId },
|
|
28943
|
+
cwd: input2.cwd,
|
|
28944
|
+
threadId: input2.threadId,
|
|
28945
|
+
createdAt,
|
|
28946
|
+
updatedAt: createdAt,
|
|
28947
|
+
resumeCursor: { schemaVersion: input2.resumeSchemaVersion, sessionId: started.sessionId },
|
|
28948
|
+
...started.modelId === void 0 ? {} : {
|
|
28949
|
+
model: started.modelId,
|
|
28950
|
+
// agent 在握手里报的才是读回的;切型号走 session/set_model 时回包不带型号,那只是请求值。
|
|
28951
|
+
modelSource: started.modelReported ? "reported" : "echo"
|
|
28952
|
+
},
|
|
28953
|
+
...input2.bindingGeneration === void 0 ? {} : { bindingGeneration: input2.bindingGeneration }
|
|
28954
|
+
};
|
|
28955
|
+
}
|
|
28956
|
+
async function openAcpThread(input2) {
|
|
28957
|
+
const { executor, handle, signal, threadId } = input2;
|
|
28958
|
+
const forwarding = (async () => {
|
|
28959
|
+
for await (const event of executor.events) {
|
|
28960
|
+
const forwarded = input2.forward(event);
|
|
28961
|
+
if (forwarded !== void 0) await forwarded;
|
|
28962
|
+
}
|
|
28963
|
+
})();
|
|
28964
|
+
try {
|
|
28965
|
+
throwIfStartAborted(signal);
|
|
28966
|
+
const started = await raceStartAbort(executor.start(), signal);
|
|
28967
|
+
const after = input2.afterStart?.(started);
|
|
28968
|
+
if (after !== void 0) await after;
|
|
28969
|
+
await yieldTick2();
|
|
28970
|
+
throwIfStartAborted(signal);
|
|
28971
|
+
const session = input2.session(started);
|
|
28972
|
+
input2.registerSession(
|
|
28973
|
+
threadId,
|
|
28974
|
+
input2.booked({ session, turns: [], executor, handle, forwarding })
|
|
28975
|
+
);
|
|
28976
|
+
input2.log.info("session started", { threadId, sessionId: started.sessionId });
|
|
28977
|
+
input2.afterRegister?.();
|
|
28978
|
+
return session;
|
|
28979
|
+
} catch (error62) {
|
|
28980
|
+
await cleanupAcpStartup({
|
|
28981
|
+
executor,
|
|
28982
|
+
stopProcess: () => handle.kill("SIGTERM"),
|
|
28983
|
+
forwarding,
|
|
28984
|
+
log: input2.log,
|
|
28985
|
+
threadId
|
|
28986
|
+
});
|
|
28987
|
+
throw error62;
|
|
28988
|
+
}
|
|
28989
|
+
}
|
|
28990
|
+
function acpLaunchMcpFields(input2) {
|
|
28991
|
+
const omit2 = input2.omitWhenEmpty === true && (input2.mcpServers === void 0 || input2.mcpServers.length === 0);
|
|
28992
|
+
return {
|
|
28993
|
+
...omit2 ? {} : { mcpServers: toAcpMcpServers(input2.mcpServers) },
|
|
28994
|
+
...input2.resumeSessionId === void 0 ? {} : { resumeSessionId: input2.resumeSessionId }
|
|
28995
|
+
};
|
|
28996
|
+
}
|
|
28997
|
+
function openAcpThreadSession(input2) {
|
|
28998
|
+
return openAcpThread({
|
|
28999
|
+
registerSession: input2.registerSession,
|
|
29000
|
+
threadId: input2.threadId,
|
|
29001
|
+
executor: input2.executor,
|
|
29002
|
+
handle: input2.handle,
|
|
29003
|
+
...input2.signal === void 0 ? {} : { signal: input2.signal },
|
|
29004
|
+
log: input2.log,
|
|
29005
|
+
forward: input2.emit,
|
|
29006
|
+
...input2.afterStart === void 0 ? {} : { afterStart: input2.afterStart },
|
|
29007
|
+
session: (started) => {
|
|
29008
|
+
input2.beforeSession?.(started);
|
|
29009
|
+
return acpStartedSession({ ...input2.session, threadId: input2.threadId }, started);
|
|
29010
|
+
},
|
|
29011
|
+
booked: input2.booked,
|
|
29012
|
+
...input2.afterRegister === void 0 ? {} : { afterRegister: input2.afterRegister }
|
|
29013
|
+
});
|
|
29014
|
+
}
|
|
29015
|
+
function openRequestedAcpThread(input2) {
|
|
29016
|
+
return openAcpThreadSession({
|
|
29017
|
+
registerSession: input2.registerSession,
|
|
29018
|
+
threadId: input2.threadId,
|
|
29019
|
+
executor: input2.executor,
|
|
29020
|
+
handle: input2.handle,
|
|
29021
|
+
...input2.signal === void 0 ? {} : { signal: input2.signal },
|
|
29022
|
+
log: input2.log,
|
|
29023
|
+
emit: input2.emit,
|
|
29024
|
+
afterStart: (started) => applyRequestedAcpMode(input2.executor, {
|
|
29025
|
+
requestedNativeModeId: input2.requestedNativeModeId,
|
|
29026
|
+
started,
|
|
29027
|
+
resumed: input2.resumed,
|
|
29028
|
+
...input2.signal === void 0 ? {} : { signal: input2.signal }
|
|
29029
|
+
}),
|
|
29030
|
+
session: input2.session,
|
|
29031
|
+
booked: input2.booked,
|
|
29032
|
+
...input2.afterRegister === void 0 ? {} : { afterRegister: input2.afterRegister }
|
|
29033
|
+
});
|
|
29034
|
+
}
|
|
29035
|
+
function acpSessionModeToApply(requestedNativeModeId, startedModeId, isResuming) {
|
|
29036
|
+
return requestedNativeModeId !== void 0 && (isResuming || requestedNativeModeId !== startedModeId) ? requestedNativeModeId : void 0;
|
|
29037
|
+
}
|
|
29038
|
+
async function applyRequestedAcpMode(executor, input2) {
|
|
29039
|
+
const modeId = acpSessionModeToApply(
|
|
29040
|
+
input2.requestedNativeModeId,
|
|
29041
|
+
acpCurrentModeId(input2.started.sessionSetupResult),
|
|
29042
|
+
input2.resumed
|
|
29043
|
+
);
|
|
29044
|
+
if (modeId === void 0) return;
|
|
29045
|
+
await raceStartAbort(executor.setNativeMode(modeId), input2.signal);
|
|
29046
|
+
}
|
|
29047
|
+
function acpNotStartedProbeResult(outcome) {
|
|
29048
|
+
return {
|
|
29049
|
+
installed: false,
|
|
29050
|
+
version: null,
|
|
29051
|
+
readiness: outcome.readiness,
|
|
29052
|
+
auth: { status: "unknown" },
|
|
29053
|
+
...outcome.detail === void 0 ? {} : { detail: outcome.detail }
|
|
29054
|
+
};
|
|
29055
|
+
}
|
|
29056
|
+
function acpFailedProbeResult(outcome, auth) {
|
|
29057
|
+
return {
|
|
29058
|
+
installed: true,
|
|
29059
|
+
version: outcome.version,
|
|
29060
|
+
readiness: "error",
|
|
29061
|
+
auth,
|
|
29062
|
+
...outcome.detail === void 0 ? {} : { detail: outcome.detail }
|
|
29063
|
+
};
|
|
29064
|
+
}
|
|
29065
|
+
|
|
29066
|
+
// ../../packages/ycodium-acp-executor/src/probe-session.ts
|
|
29067
|
+
var acpProbeFailureDetail = (error62) => (error62 instanceof Error ? error62.message : String(error62)).trim() || void 0;
|
|
29068
|
+
function findAcpProbeSessionId(listed, probeCwd) {
|
|
29069
|
+
if (!isRecord2(listed) || !Array.isArray(listed["sessions"])) return void 0;
|
|
29070
|
+
for (const entry of listed["sessions"]) {
|
|
29071
|
+
if (!isRecord2(entry)) continue;
|
|
29072
|
+
if (entry["cwd"] !== probeCwd) continue;
|
|
29073
|
+
const sessionId = entry["sessionId"];
|
|
29074
|
+
if (typeof sessionId === "string" && sessionId.length > 0) return sessionId;
|
|
29075
|
+
}
|
|
29076
|
+
return void 0;
|
|
29077
|
+
}
|
|
29078
|
+
async function reuseAcpProbeSession(handshake, probeCwd) {
|
|
29079
|
+
const listed = await handshake.request("session/list", {}).catch(() => void 0);
|
|
29080
|
+
const reusable = findAcpProbeSessionId(listed, probeCwd);
|
|
29081
|
+
if (reusable !== void 0) {
|
|
29082
|
+
const resumed = await handshake.request("session/resume", { sessionId: reusable, cwd: probeCwd, mcpServers: [] }).catch(() => void 0);
|
|
29083
|
+
if (resumed !== void 0) return resumed;
|
|
29084
|
+
}
|
|
29085
|
+
return handshake.request("session/new", { cwd: probeCwd, mcpServers: [] });
|
|
29086
|
+
}
|
|
29087
|
+
function acpEffortCapabilities(configOptions, descriptor) {
|
|
29088
|
+
const state = acpEffortConfigState(configOptions);
|
|
29089
|
+
if (state === "unknown") return "unknown";
|
|
29090
|
+
if (state === "none") return { optionDescriptors: [] };
|
|
29091
|
+
const effort = findAcpEffortConfig(configOptions);
|
|
29092
|
+
if (effort === void 0) return "unknown";
|
|
29093
|
+
return {
|
|
29094
|
+
optionDescriptors: [
|
|
29095
|
+
{
|
|
29096
|
+
id: descriptor.id,
|
|
29097
|
+
label: effort.label || descriptor.fallbackLabel,
|
|
29098
|
+
type: "select",
|
|
29099
|
+
options: effort.choices.map((choice) => ({
|
|
29100
|
+
id: choice.value,
|
|
29101
|
+
label: choice.label,
|
|
29102
|
+
...choice.description === void 0 ? {} : { description: choice.description },
|
|
29103
|
+
...choice.isDefault === true ? { isDefault: true } : {}
|
|
29104
|
+
}))
|
|
29105
|
+
}
|
|
29106
|
+
]
|
|
29107
|
+
};
|
|
29108
|
+
}
|
|
29109
|
+
|
|
29110
|
+
// ../../packages/ycodium-acp-executor/src/probe.ts
|
|
29111
|
+
function withProbeTimeout(promise2, timeoutMs, what, signal) {
|
|
29112
|
+
signal?.throwIfAborted();
|
|
29113
|
+
return new Promise((resolve2, reject) => {
|
|
29114
|
+
const onAbort = () => {
|
|
29115
|
+
clearTimeout(timer);
|
|
29116
|
+
reject(signal?.reason ?? new Error("aborted"));
|
|
29117
|
+
};
|
|
29118
|
+
const timer = setTimeout(() => {
|
|
29119
|
+
signal?.removeEventListener("abort", onAbort);
|
|
29120
|
+
reject(new Error(`${what} timed out after ${timeoutMs}ms`));
|
|
29121
|
+
}, timeoutMs);
|
|
29122
|
+
timer.unref?.();
|
|
29123
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
28652
29124
|
promise2.then(
|
|
28653
29125
|
(value) => {
|
|
28654
29126
|
clearTimeout(timer);
|
|
@@ -28704,6 +29176,200 @@ function acpAgentVersion(initializeResult) {
|
|
|
28704
29176
|
}
|
|
28705
29177
|
var MAX_VERSION_OUTPUT_BYTES = 64 * 1024;
|
|
28706
29178
|
|
|
29179
|
+
// ../../packages/ycodium-acp-executor/src/probe-process.ts
|
|
29180
|
+
import * as NodeFS2 from "node:fs";
|
|
29181
|
+
|
|
29182
|
+
// ../../packages/ycodium-executor-common/src/raceAbort.ts
|
|
29183
|
+
async function raceAbort(pending, signal) {
|
|
29184
|
+
if (signal === void 0) return pending;
|
|
29185
|
+
void pending.catch(() => void 0);
|
|
29186
|
+
if (signal.aborted) throw new Error("aborted");
|
|
29187
|
+
let onAbort;
|
|
29188
|
+
const aborted2 = new Promise((_resolve, reject) => {
|
|
29189
|
+
onAbort = () => reject(new Error("aborted"));
|
|
29190
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
29191
|
+
});
|
|
29192
|
+
try {
|
|
29193
|
+
return await Promise.race([pending, aborted2]);
|
|
29194
|
+
} finally {
|
|
29195
|
+
signal.removeEventListener("abort", onAbort);
|
|
29196
|
+
}
|
|
29197
|
+
}
|
|
29198
|
+
|
|
29199
|
+
// ../../packages/ycodium-acp-executor/src/probe-process.ts
|
|
29200
|
+
async function withAcpProbeProcess(input2) {
|
|
29201
|
+
try {
|
|
29202
|
+
NodeFS2.mkdirSync(input2.cwd, { recursive: true });
|
|
29203
|
+
} catch (error62) {
|
|
29204
|
+
return { kind: "mkdir-failed", detail: acpProbeFailureDetail(error62) };
|
|
29205
|
+
}
|
|
29206
|
+
const spawned = await input2.spawn(input2.cwd);
|
|
29207
|
+
if (spawned.kind !== "spawned") return spawned;
|
|
29208
|
+
const handle = spawned.handle;
|
|
29209
|
+
let handshake;
|
|
29210
|
+
try {
|
|
29211
|
+
const streams = nodeStreamsFromHandle(handle);
|
|
29212
|
+
handshake = await raceAbort(
|
|
29213
|
+
openAcpProbeHandshake({
|
|
29214
|
+
readable: streams.readable,
|
|
29215
|
+
writable: streams.writable,
|
|
29216
|
+
clientInfo: input2.clientInfo,
|
|
29217
|
+
requestTimeoutMs: input2.requestTimeoutMs,
|
|
29218
|
+
...input2.subagentSessions === void 0 ? {} : { subagentSessions: input2.subagentSessions }
|
|
29219
|
+
}),
|
|
29220
|
+
input2.signal
|
|
29221
|
+
);
|
|
29222
|
+
return { kind: "ok", value: await input2.run(handshake) };
|
|
29223
|
+
} catch (error62) {
|
|
29224
|
+
return {
|
|
29225
|
+
kind: "threw",
|
|
29226
|
+
error: error62,
|
|
29227
|
+
handshakeOpened: handshake !== void 0,
|
|
29228
|
+
initializeResult: handshake?.initializeResult
|
|
29229
|
+
};
|
|
29230
|
+
} finally {
|
|
29231
|
+
await handshake?.close().catch(() => void 0);
|
|
29232
|
+
await handle.kill("SIGTERM").catch(() => void 0);
|
|
29233
|
+
}
|
|
29234
|
+
}
|
|
29235
|
+
|
|
29236
|
+
// ../../packages/ycodium-instance-config/src/launchArgs.ts
|
|
29237
|
+
function tokenizeShellWords(value) {
|
|
29238
|
+
const input2 = value.trim();
|
|
29239
|
+
if (!input2) return [];
|
|
29240
|
+
const tokens = [];
|
|
29241
|
+
let current = "";
|
|
29242
|
+
let quote;
|
|
29243
|
+
let quoted = false;
|
|
29244
|
+
for (let index = 0; index < input2.length; index++) {
|
|
29245
|
+
const char = input2[index];
|
|
29246
|
+
if (char === void 0) continue;
|
|
29247
|
+
if (quote) {
|
|
29248
|
+
if (char === quote) {
|
|
29249
|
+
quote = void 0;
|
|
29250
|
+
quoted = true;
|
|
29251
|
+
} else if (char === "\\" && quote === '"') {
|
|
29252
|
+
const next = input2[index + 1];
|
|
29253
|
+
if (next !== void 0 && ['"', "\\", "$", "`"].includes(next)) {
|
|
29254
|
+
current += next;
|
|
29255
|
+
index++;
|
|
29256
|
+
} else {
|
|
29257
|
+
current += char;
|
|
29258
|
+
}
|
|
29259
|
+
} else {
|
|
29260
|
+
current += char;
|
|
29261
|
+
}
|
|
29262
|
+
continue;
|
|
29263
|
+
}
|
|
29264
|
+
if (char === "'" || char === '"') {
|
|
29265
|
+
quote = char;
|
|
29266
|
+
quoted = true;
|
|
29267
|
+
} else if (/\s/.test(char)) {
|
|
29268
|
+
if (current || quoted) {
|
|
29269
|
+
tokens.push(current);
|
|
29270
|
+
current = "";
|
|
29271
|
+
quoted = false;
|
|
29272
|
+
}
|
|
29273
|
+
} else if (char === "\\") {
|
|
29274
|
+
const next = input2[index + 1];
|
|
29275
|
+
if (next !== void 0 && /\s/.test(next)) {
|
|
29276
|
+
current += next;
|
|
29277
|
+
index++;
|
|
29278
|
+
} else {
|
|
29279
|
+
current += char;
|
|
29280
|
+
}
|
|
29281
|
+
} else {
|
|
29282
|
+
current += char;
|
|
29283
|
+
}
|
|
29284
|
+
}
|
|
29285
|
+
if (current || quoted) tokens.push(current);
|
|
29286
|
+
return tokens;
|
|
29287
|
+
}
|
|
29288
|
+
|
|
29289
|
+
// ../../packages/ycodium-instance-config/src/homePath.ts
|
|
29290
|
+
import * as NodeOS3 from "node:os";
|
|
29291
|
+
import * as NodePath3 from "node:path";
|
|
29292
|
+
import { mergeLaunchEnv } from "@ycodium-ai/plugin-api/executor";
|
|
29293
|
+
function expandHomePath(value) {
|
|
29294
|
+
if (value === "~") return NodeOS3.homedir();
|
|
29295
|
+
if (value.startsWith("~/") || value.startsWith("~\\")) {
|
|
29296
|
+
return NodePath3.join(NodeOS3.homedir(), value.slice(2));
|
|
29297
|
+
}
|
|
29298
|
+
return value;
|
|
29299
|
+
}
|
|
29300
|
+
function homeLaunchEnv(recipe, configuredHomePath) {
|
|
29301
|
+
const homePath = configuredHomePath.trim();
|
|
29302
|
+
const homeEnvVar = recipe.homeEnvVar.trim();
|
|
29303
|
+
const homeInjection = homePath.length > 0 && homeEnvVar.length > 0 ? { [homeEnvVar]: expandHomePath(homePath) } : {};
|
|
29304
|
+
return mergeLaunchEnv({ accountHome: homeInjection, instanceTable: recipe.environment });
|
|
29305
|
+
}
|
|
29306
|
+
function homeContinuationKey(kind, recipe) {
|
|
29307
|
+
const homePath = recipe.homePath.trim();
|
|
29308
|
+
const resolvedHomePath = homePath.length > 0 ? NodePath3.resolve(expandHomePath(homePath)) : "";
|
|
29309
|
+
return `${kind}:home:${recipe.binaryPath.trim()}\0${resolvedHomePath}`;
|
|
29310
|
+
}
|
|
29311
|
+
|
|
29312
|
+
// ../../packages/ycodium-instance-config/src/instanceConfig.ts
|
|
29313
|
+
import { modelSelectionStringOption as modelSelectionStringOption2 } from "@ycodium-ai/plugin-api/executor";
|
|
29314
|
+
function isRecord7(value) {
|
|
29315
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
29316
|
+
}
|
|
29317
|
+
function readString(value) {
|
|
29318
|
+
return typeof value === "string" ? value : "";
|
|
29319
|
+
}
|
|
29320
|
+
function readTrimmed(value) {
|
|
29321
|
+
return readString(value).trim();
|
|
29322
|
+
}
|
|
29323
|
+
function modelIdFromSelection(selection) {
|
|
29324
|
+
if (!isRecord7(selection)) return void 0;
|
|
29325
|
+
const model = selection["model"];
|
|
29326
|
+
return typeof model === "string" ? model.trim() || void 0 : void 0;
|
|
29327
|
+
}
|
|
29328
|
+
function readTurnSelection(selection, effortOptionId) {
|
|
29329
|
+
const requestedModelId = modelIdFromSelection(selection);
|
|
29330
|
+
const requestedEffort = modelSelectionStringOption2(selection, effortOptionId);
|
|
29331
|
+
return {
|
|
29332
|
+
...requestedModelId === void 0 ? {} : { requestedModelId },
|
|
29333
|
+
...requestedEffort === void 0 ? {} : { requestedEffort }
|
|
29334
|
+
};
|
|
29335
|
+
}
|
|
29336
|
+
function readEnvironment(value) {
|
|
29337
|
+
if (!Array.isArray(value)) return {};
|
|
29338
|
+
const env = {};
|
|
29339
|
+
for (const entry of value) {
|
|
29340
|
+
if (!isRecord7(entry)) continue;
|
|
29341
|
+
const name = readTrimmed(entry["name"]);
|
|
29342
|
+
if (name.length === 0) continue;
|
|
29343
|
+
env[name] = readString(entry["value"]);
|
|
29344
|
+
}
|
|
29345
|
+
return env;
|
|
29346
|
+
}
|
|
29347
|
+
function instanceSettings(config2) {
|
|
29348
|
+
if (!isRecord7(config2)) return {};
|
|
29349
|
+
return isRecord7(config2["config"]) ? config2["config"] : config2;
|
|
29350
|
+
}
|
|
29351
|
+
function readInstanceEnvelope(config2) {
|
|
29352
|
+
const envelope = isRecord7(config2) ? config2 : {};
|
|
29353
|
+
const settings = instanceSettings(config2);
|
|
29354
|
+
return {
|
|
29355
|
+
settings,
|
|
29356
|
+
settingOrEnvelope: (key) => readTrimmed(settings[key]) || readTrimmed(envelope[key]),
|
|
29357
|
+
environment: readEnvironment(envelope["environment"]),
|
|
29358
|
+
envelopeDriver: readTrimmed(envelope["driver"]) || void 0
|
|
29359
|
+
};
|
|
29360
|
+
}
|
|
29361
|
+
function readLaunchInstanceRecipe(config2, defaultLaunchArgs = "") {
|
|
29362
|
+
const envelope = readInstanceEnvelope(config2);
|
|
29363
|
+
return {
|
|
29364
|
+
binaryPath: readTrimmed(envelope.settings["binaryPath"]),
|
|
29365
|
+
launchArgs: readString(envelope.settings["launchArgs"]) || defaultLaunchArgs,
|
|
29366
|
+
homePath: envelope.settingOrEnvelope("homePath"),
|
|
29367
|
+
homeEnvVar: envelope.settingOrEnvelope("homeEnvVar"),
|
|
29368
|
+
environment: envelope.environment,
|
|
29369
|
+
envelopeDriver: envelope.envelopeDriver
|
|
29370
|
+
};
|
|
29371
|
+
}
|
|
29372
|
+
|
|
28707
29373
|
// src/card.ts
|
|
28708
29374
|
var ACP_DRIVER_KIND = "acp";
|
|
28709
29375
|
var ACP_CARD = {
|
|
@@ -28771,180 +29437,93 @@ var ACP_CARD = {
|
|
|
28771
29437
|
type: "string",
|
|
28772
29438
|
"x-ycodium-form": {
|
|
28773
29439
|
titleKey: "form.launchArgs.title",
|
|
28774
|
-
descriptionKey: "form.launchArgs.description",
|
|
28775
|
-
placeholderKey: "form.launchArgs.placeholder"
|
|
28776
|
-
}
|
|
28777
|
-
},
|
|
28778
|
-
homePath: {
|
|
28779
|
-
type: "string",
|
|
28780
|
-
"x-ycodium-form": {
|
|
28781
|
-
titleKey: "form.homePath.title",
|
|
28782
|
-
machineLocal: true,
|
|
28783
|
-
descriptionKey: "form.homePath.description",
|
|
28784
|
-
placeholderKey: "form.homePath.placeholder"
|
|
28785
|
-
}
|
|
28786
|
-
},
|
|
28787
|
-
homeEnvVar: { type: "string" },
|
|
28788
|
-
enabled: { type: "boolean" },
|
|
28789
|
-
customModels: { type: "array" },
|
|
28790
|
-
driver: { type: "string" },
|
|
28791
|
-
config: { type: "object" },
|
|
28792
|
-
environment: { type: "array" }
|
|
28793
|
-
},
|
|
28794
|
-
additionalProperties: true
|
|
28795
|
-
},
|
|
28796
|
-
modelConnectivity: {
|
|
28797
|
-
dialects: ["anthropic-messages", "openai-responses", "openai-chat-completions"],
|
|
28798
|
-
// **通用 ACP 这张名片说不出怎么接外部地址,而且说不出是对的。** ACP 协议本身没有
|
|
28799
|
-
// 端点概念,地址与钥匙全靠各家 CLI 自己的环境变量,各家各不相同。用户按那家 CLI
|
|
28800
|
-
// 自己的文档在实例上设变量。哪家要写清楚,就为那一家单出一个插件(像 `agent-kimi`),
|
|
28801
|
-
// 别回来改这一张。
|
|
28802
|
-
acceptsExternalEndpoints: false
|
|
28803
|
-
}
|
|
28804
|
-
};
|
|
28805
|
-
|
|
28806
|
-
// src/config.ts
|
|
28807
|
-
function isRecord6(value) {
|
|
28808
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
28809
|
-
}
|
|
28810
|
-
function readString(value) {
|
|
28811
|
-
return typeof value === "string" ? value : "";
|
|
28812
|
-
}
|
|
28813
|
-
function readTrimmed(value) {
|
|
28814
|
-
return readString(value).trim();
|
|
28815
|
-
}
|
|
28816
|
-
function readEnvironment(value) {
|
|
28817
|
-
if (!Array.isArray(value)) return {};
|
|
28818
|
-
const env = {};
|
|
28819
|
-
for (const entry of value) {
|
|
28820
|
-
if (!isRecord6(entry)) continue;
|
|
28821
|
-
const name = readTrimmed(entry["name"]);
|
|
28822
|
-
if (name.length === 0) continue;
|
|
28823
|
-
env[name] = readString(entry["value"]);
|
|
28824
|
-
}
|
|
28825
|
-
return env;
|
|
28826
|
-
}
|
|
28827
|
-
function parseAcpInstanceConfig(config2) {
|
|
28828
|
-
if (!isRecord6(config2)) {
|
|
28829
|
-
return {
|
|
28830
|
-
binaryPath: "",
|
|
28831
|
-
launchArgs: "",
|
|
28832
|
-
homePath: "",
|
|
28833
|
-
homeEnvVar: "",
|
|
28834
|
-
environment: {},
|
|
28835
|
-
envelopeDriver: void 0
|
|
28836
|
-
};
|
|
28837
|
-
}
|
|
28838
|
-
const nested = isRecord6(config2["config"]) ? config2["config"] : void 0;
|
|
28839
|
-
const settings = nested ?? config2;
|
|
28840
|
-
return {
|
|
28841
|
-
binaryPath: readTrimmed(settings["binaryPath"]),
|
|
28842
|
-
launchArgs: readString(settings["launchArgs"]),
|
|
28843
|
-
homePath: readTrimmed(settings["homePath"]) || readTrimmed(config2["homePath"]),
|
|
28844
|
-
homeEnvVar: readTrimmed(settings["homeEnvVar"]) || readTrimmed(config2["homeEnvVar"]),
|
|
28845
|
-
environment: readEnvironment(config2["environment"]),
|
|
28846
|
-
envelopeDriver: readTrimmed(config2["driver"]) || void 0
|
|
28847
|
-
};
|
|
28848
|
-
}
|
|
28849
|
-
function tokenizeLaunchArgs(value) {
|
|
28850
|
-
const input2 = value.trim();
|
|
28851
|
-
if (!input2) return [];
|
|
28852
|
-
const tokens = [];
|
|
28853
|
-
let current = "";
|
|
28854
|
-
let quote;
|
|
28855
|
-
let quoted = false;
|
|
28856
|
-
for (let index = 0; index < input2.length; index++) {
|
|
28857
|
-
const char = input2[index];
|
|
28858
|
-
if (char === void 0) continue;
|
|
28859
|
-
if (quote) {
|
|
28860
|
-
if (char === quote) {
|
|
28861
|
-
quote = void 0;
|
|
28862
|
-
quoted = true;
|
|
28863
|
-
} else if (char === "\\" && quote === '"') {
|
|
28864
|
-
const next = input2[index + 1];
|
|
28865
|
-
if (next !== void 0 && ['"', "\\", "$", "`"].includes(next)) {
|
|
28866
|
-
current += next;
|
|
28867
|
-
index++;
|
|
28868
|
-
} else {
|
|
28869
|
-
current += char;
|
|
28870
|
-
}
|
|
28871
|
-
} else {
|
|
28872
|
-
current += char;
|
|
28873
|
-
}
|
|
28874
|
-
continue;
|
|
28875
|
-
}
|
|
28876
|
-
if (char === "'" || char === '"') {
|
|
28877
|
-
quote = char;
|
|
28878
|
-
quoted = true;
|
|
28879
|
-
} else if (/\s/.test(char)) {
|
|
28880
|
-
if (current || quoted) {
|
|
28881
|
-
tokens.push(current);
|
|
28882
|
-
current = "";
|
|
28883
|
-
quoted = false;
|
|
28884
|
-
}
|
|
28885
|
-
} else if (char === "\\") {
|
|
28886
|
-
const next = input2[index + 1];
|
|
28887
|
-
if (next !== void 0 && /\s/.test(next)) {
|
|
28888
|
-
current += next;
|
|
28889
|
-
index++;
|
|
28890
|
-
} else {
|
|
28891
|
-
current += char;
|
|
28892
|
-
}
|
|
28893
|
-
} else {
|
|
28894
|
-
current += char;
|
|
28895
|
-
}
|
|
29440
|
+
descriptionKey: "form.launchArgs.description",
|
|
29441
|
+
placeholderKey: "form.launchArgs.placeholder"
|
|
29442
|
+
}
|
|
29443
|
+
},
|
|
29444
|
+
homePath: {
|
|
29445
|
+
type: "string",
|
|
29446
|
+
"x-ycodium-form": {
|
|
29447
|
+
titleKey: "form.homePath.title",
|
|
29448
|
+
machineLocal: true,
|
|
29449
|
+
descriptionKey: "form.homePath.description",
|
|
29450
|
+
placeholderKey: "form.homePath.placeholder"
|
|
29451
|
+
}
|
|
29452
|
+
},
|
|
29453
|
+
homeEnvVar: { type: "string" },
|
|
29454
|
+
enabled: { type: "boolean" },
|
|
29455
|
+
customModels: { type: "array" },
|
|
29456
|
+
driver: { type: "string" },
|
|
29457
|
+
config: { type: "object" },
|
|
29458
|
+
environment: { type: "array" }
|
|
29459
|
+
},
|
|
29460
|
+
additionalProperties: true
|
|
29461
|
+
},
|
|
29462
|
+
modelConnectivity: {
|
|
29463
|
+
dialects: ["anthropic-messages", "openai-responses", "openai-chat-completions"],
|
|
29464
|
+
// **通用 ACP 这张名片说不出怎么接外部地址,而且说不出是对的。** ACP 协议本身没有
|
|
29465
|
+
// 端点概念,地址与钥匙全靠各家 CLI 自己的环境变量,各家各不相同。用户按那家 CLI
|
|
29466
|
+
// 自己的文档在实例上设变量。哪家要写清楚,就为那一家单出一个插件(像 `agent-kimi`),
|
|
29467
|
+
// 别回来改这一张。
|
|
29468
|
+
acceptsExternalEndpoints: false
|
|
28896
29469
|
}
|
|
28897
|
-
|
|
28898
|
-
|
|
29470
|
+
};
|
|
29471
|
+
|
|
29472
|
+
// src/config.ts
|
|
29473
|
+
function parseAcpInstanceConfig(config2) {
|
|
29474
|
+
return readLaunchInstanceRecipe(config2);
|
|
28899
29475
|
}
|
|
28900
29476
|
|
|
28901
29477
|
// src/probeModels.ts
|
|
28902
29478
|
import {
|
|
28903
29479
|
withProcessOperation,
|
|
28904
|
-
OperationCleanupError
|
|
29480
|
+
OperationCleanupError as OperationCleanupError2
|
|
28905
29481
|
} from "@ycodium-ai/plugin-api/process-operation";
|
|
28906
|
-
import * as
|
|
28907
|
-
import * as
|
|
28908
|
-
import * as
|
|
29482
|
+
import * as NodeFS3 from "node:fs";
|
|
29483
|
+
import * as NodeOS4 from "node:os";
|
|
29484
|
+
import * as NodePath4 from "node:path";
|
|
29485
|
+
import {
|
|
29486
|
+
raceAbort as raceAbort2,
|
|
29487
|
+
REASONING_OPTION_LABEL
|
|
29488
|
+
} from "@ycodium-ai/plugin-api/executor";
|
|
29489
|
+
import { nodeStreamsFromHandle as nodeStreamsFromHandle2 } from "@ycodium-ai/plugin-api/process-stdin";
|
|
29490
|
+
|
|
29491
|
+
// ../../packages/ycodium-instance-config/src/probeProcess.ts
|
|
28909
29492
|
import {
|
|
28910
29493
|
describeExecutorSpawnFailure,
|
|
28911
29494
|
ExecutorSpawnAbortedError,
|
|
28912
|
-
ExecutorSpawnRefusedError
|
|
28913
|
-
raceAbort,
|
|
28914
|
-
REASONING_OPTION_LABEL
|
|
29495
|
+
ExecutorSpawnRefusedError
|
|
28915
29496
|
} from "@ycodium-ai/plugin-api/executor";
|
|
28916
|
-
import {
|
|
29497
|
+
import {
|
|
29498
|
+
OperationCleanupError,
|
|
29499
|
+
runProcessOperation
|
|
29500
|
+
} from "@ycodium-ai/plugin-api/process-operation";
|
|
29501
|
+
async function spawnProbeProcess(host, launch) {
|
|
29502
|
+
try {
|
|
29503
|
+
const handle = await host.process.spawn({
|
|
29504
|
+
program: launch.program,
|
|
29505
|
+
args: launch.args,
|
|
29506
|
+
cwd: launch.cwd,
|
|
29507
|
+
owner: { bindingId: host.bindingId },
|
|
29508
|
+
...Object.keys(launch.env).length > 0 ? { env: launch.env } : {},
|
|
29509
|
+
...launch.signal === void 0 ? {} : { signal: launch.signal }
|
|
29510
|
+
});
|
|
29511
|
+
return { kind: "spawned", handle };
|
|
29512
|
+
} catch (error62) {
|
|
29513
|
+
if (error62 instanceof ExecutorSpawnRefusedError || error62 instanceof ExecutorSpawnAbortedError) {
|
|
29514
|
+
throw error62;
|
|
29515
|
+
}
|
|
29516
|
+
return { kind: "not-started", ...describeExecutorSpawnFailure(error62) };
|
|
29517
|
+
}
|
|
29518
|
+
}
|
|
29519
|
+
|
|
29520
|
+
// src/probeModels.ts
|
|
28917
29521
|
var PROBE_REQUEST_TIMEOUT_MS = 15e3;
|
|
28918
29522
|
var CLIENT_INFO = { name: "ycodium-agent-acp-probe", version: "0.2.0" };
|
|
28919
29523
|
var ACP_EFFORT_OPTION_ID = "reasoning";
|
|
28920
29524
|
function acpProbeSessionCwd(instanceId) {
|
|
28921
29525
|
const safe = instanceId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
28922
|
-
return
|
|
28923
|
-
}
|
|
28924
|
-
function isRecord7(value) {
|
|
28925
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
28926
|
-
}
|
|
28927
|
-
function asString3(value) {
|
|
28928
|
-
return typeof value === "string" ? value : void 0;
|
|
28929
|
-
}
|
|
28930
|
-
function findAcpProbeSessionId(listed, probeCwd) {
|
|
28931
|
-
if (!isRecord7(listed) || !Array.isArray(listed["sessions"])) return void 0;
|
|
28932
|
-
for (const entry of listed["sessions"]) {
|
|
28933
|
-
if (!isRecord7(entry)) continue;
|
|
28934
|
-
if (asString3(entry["cwd"]) !== probeCwd) continue;
|
|
28935
|
-
const sessionId = asString3(entry["sessionId"]);
|
|
28936
|
-
if (sessionId !== void 0) return sessionId;
|
|
28937
|
-
}
|
|
28938
|
-
return void 0;
|
|
28939
|
-
}
|
|
28940
|
-
async function probeSessionSetup(handshake, probeCwd) {
|
|
28941
|
-
const listed = await handshake.request("session/list", {}).catch(() => void 0);
|
|
28942
|
-
const reusable = findAcpProbeSessionId(listed, probeCwd);
|
|
28943
|
-
if (reusable !== void 0) {
|
|
28944
|
-
const resumed = await handshake.request("session/resume", { sessionId: reusable, cwd: probeCwd, mcpServers: [] }).catch(() => void 0);
|
|
28945
|
-
if (resumed !== void 0) return resumed;
|
|
28946
|
-
}
|
|
28947
|
-
return handshake.request("session/new", { cwd: probeCwd, mcpServers: [] });
|
|
29526
|
+
return NodePath4.join(NodeOS4.tmpdir(), `ycodium-acp-probe-${safe}`);
|
|
28948
29527
|
}
|
|
28949
29528
|
function acpProbeModels(setup) {
|
|
28950
29529
|
if (!isRecord7(setup)) return void 0;
|
|
@@ -28956,100 +29535,64 @@ function acpProbeModels(setup) {
|
|
|
28956
29535
|
...choice.name === void 0 ? {} : { name: choice.name },
|
|
28957
29536
|
...choice.isDefault === true ? { isDefault: true } : {}
|
|
28958
29537
|
}));
|
|
28959
|
-
const
|
|
28960
|
-
|
|
28961
|
-
|
|
28962
|
-
|
|
28963
|
-
}
|
|
28964
|
-
const effort = findAcpEffortConfig(rawOptions);
|
|
28965
|
-
if (effort === void 0) return models;
|
|
28966
|
-
const capabilities = {
|
|
28967
|
-
optionDescriptors: [
|
|
28968
|
-
{
|
|
28969
|
-
id: ACP_EFFORT_OPTION_ID,
|
|
28970
|
-
label: effort.label || REASONING_OPTION_LABEL,
|
|
28971
|
-
type: "select",
|
|
28972
|
-
options: effort.choices.map((choice) => ({
|
|
28973
|
-
id: choice.value,
|
|
28974
|
-
label: choice.label,
|
|
28975
|
-
...choice.description === void 0 ? {} : { description: choice.description },
|
|
28976
|
-
...choice.isDefault === true ? { isDefault: true } : {}
|
|
28977
|
-
}))
|
|
28978
|
-
}
|
|
28979
|
-
]
|
|
28980
|
-
};
|
|
28981
|
-
return models.map((model) => ({ ...model, capabilities }));
|
|
29538
|
+
const capabilities = acpEffortCapabilities(rawOptions, {
|
|
29539
|
+
id: ACP_EFFORT_OPTION_ID,
|
|
29540
|
+
fallbackLabel: REASONING_OPTION_LABEL
|
|
29541
|
+
});
|
|
29542
|
+
return capabilities === "unknown" ? models : models.map((model) => ({ ...model, capabilities }));
|
|
28982
29543
|
}
|
|
28983
|
-
var probeFailureDetail = (error62) => (error62 instanceof Error ? error62.message : String(error62)).trim() || void 0;
|
|
28984
29544
|
var ACP_AUTH_REQUIRED_CODE = RequestError.authRequired().code;
|
|
28985
29545
|
var isAcpAuthRequired = (error62) => error62 instanceof RequestError && error62.code === ACP_AUTH_REQUIRED_CODE;
|
|
28986
29546
|
async function probeAcpModelsViaSession(input2) {
|
|
28987
29547
|
const { recipe, host, env } = input2;
|
|
28988
29548
|
const probeCwd = acpProbeSessionCwd(host.instanceId);
|
|
28989
|
-
|
|
28990
|
-
|
|
28991
|
-
|
|
28992
|
-
|
|
28993
|
-
|
|
28994
|
-
|
|
28995
|
-
|
|
28996
|
-
handle = await host.process.spawn({
|
|
29549
|
+
const attempt = await withAcpProbeProcess({
|
|
29550
|
+
cwd: probeCwd,
|
|
29551
|
+
signal: input2.signal,
|
|
29552
|
+
clientInfo: CLIENT_INFO,
|
|
29553
|
+
subagentSessions: true,
|
|
29554
|
+
requestTimeoutMs: PROBE_REQUEST_TIMEOUT_MS,
|
|
29555
|
+
spawn: (cwd) => spawnProbeProcess(host, {
|
|
28997
29556
|
program: recipe.binaryPath,
|
|
28998
|
-
args:
|
|
28999
|
-
cwd
|
|
29000
|
-
|
|
29001
|
-
...Object.keys(env).length > 0 ? { env } : {},
|
|
29557
|
+
args: tokenizeShellWords(recipe.launchArgs),
|
|
29558
|
+
cwd,
|
|
29559
|
+
env,
|
|
29002
29560
|
...input2.signal === void 0 ? {} : { signal: input2.signal }
|
|
29003
|
-
})
|
|
29004
|
-
|
|
29005
|
-
|
|
29006
|
-
|
|
29561
|
+
}),
|
|
29562
|
+
run: async (handshake) => {
|
|
29563
|
+
const setup = await raceAbort2(reuseAcpProbeSession(handshake, probeCwd), input2.signal);
|
|
29564
|
+
return {
|
|
29565
|
+
version: acpAgentVersion(handshake.initializeResult),
|
|
29566
|
+
models: acpProbeModels(setup),
|
|
29567
|
+
// 审批档原样上报:宿主落进 provider 快照的 `nativeModes`,composer 直接画这只手
|
|
29568
|
+
// 自己的那几档,不再退回宿主四档开关。
|
|
29569
|
+
nativeModes: acpAvailableModes(setup).map((mode) => ({
|
|
29570
|
+
id: mode.id,
|
|
29571
|
+
name: mode.name,
|
|
29572
|
+
...mode.description === void 0 ? {} : { description: mode.description }
|
|
29573
|
+
})),
|
|
29574
|
+
currentNativeModeId: acpCurrentModeId(setup)
|
|
29575
|
+
};
|
|
29007
29576
|
}
|
|
29008
|
-
|
|
29577
|
+
});
|
|
29578
|
+
if (attempt.kind === "not-started") return attempt;
|
|
29579
|
+
if (attempt.kind === "mkdir-failed") {
|
|
29580
|
+
return { kind: "failed", detail: attempt.detail, version: null };
|
|
29009
29581
|
}
|
|
29010
|
-
|
|
29011
|
-
|
|
29012
|
-
|
|
29013
|
-
handshake = await raceAbort(
|
|
29014
|
-
openAcpProbeHandshake({
|
|
29015
|
-
readable,
|
|
29016
|
-
writable,
|
|
29017
|
-
clientInfo: CLIENT_INFO,
|
|
29018
|
-
subagentSessions: true,
|
|
29019
|
-
requestTimeoutMs: PROBE_REQUEST_TIMEOUT_MS
|
|
29020
|
-
}),
|
|
29021
|
-
input2.signal
|
|
29022
|
-
);
|
|
29023
|
-
const setup = await raceAbort(probeSessionSetup(handshake, probeCwd), input2.signal);
|
|
29024
|
-
return {
|
|
29025
|
-
kind: "answered",
|
|
29026
|
-
version: acpAgentVersion(handshake.initializeResult),
|
|
29027
|
-
models: acpProbeModels(setup),
|
|
29028
|
-
// 审批档原样上报:宿主落进 provider 快照的 `nativeModes`,composer 直接画这只手
|
|
29029
|
-
// 自己的那几档,不再退回宿主四档开关。
|
|
29030
|
-
nativeModes: acpAvailableModes(setup).map((mode) => ({
|
|
29031
|
-
id: mode.id,
|
|
29032
|
-
name: mode.name,
|
|
29033
|
-
...mode.description === void 0 ? {} : { description: mode.description }
|
|
29034
|
-
})),
|
|
29035
|
-
currentNativeModeId: acpCurrentModeId(setup)
|
|
29036
|
-
};
|
|
29037
|
-
} catch (error62) {
|
|
29038
|
-
const version2 = acpAgentVersion(handshake?.initializeResult);
|
|
29039
|
-
if (handshake !== void 0 && isAcpAuthRequired(error62)) {
|
|
29582
|
+
if (attempt.kind === "threw") {
|
|
29583
|
+
const version2 = acpAgentVersion(attempt.initializeResult);
|
|
29584
|
+
if (attempt.handshakeOpened && isAcpAuthRequired(attempt.error)) {
|
|
29040
29585
|
return { kind: "auth-required", version: version2 };
|
|
29041
29586
|
}
|
|
29042
|
-
return { kind: "failed", detail:
|
|
29043
|
-
} finally {
|
|
29044
|
-
await handshake?.close().catch(() => void 0);
|
|
29045
|
-
await handle.kill("SIGTERM").catch(() => void 0);
|
|
29587
|
+
return { kind: "failed", detail: acpProbeFailureDetail(attempt.error), version: version2 };
|
|
29046
29588
|
}
|
|
29589
|
+
return { kind: "answered", ...attempt.value };
|
|
29047
29590
|
}
|
|
29048
29591
|
async function probeAcpAgentVersion(input2) {
|
|
29049
29592
|
if (input2.recipe.binaryPath.length === 0) return null;
|
|
29050
29593
|
const probeCwd = acpProbeSessionCwd(input2.host.instanceId);
|
|
29051
29594
|
try {
|
|
29052
|
-
|
|
29595
|
+
NodeFS3.mkdirSync(probeCwd, { recursive: true });
|
|
29053
29596
|
} catch {
|
|
29054
29597
|
return null;
|
|
29055
29598
|
}
|
|
@@ -29063,12 +29606,12 @@ async function probeAcpAgentVersion(input2) {
|
|
|
29063
29606
|
async (operation) => {
|
|
29064
29607
|
const handle = await operation.spawn({
|
|
29065
29608
|
program: input2.recipe.binaryPath,
|
|
29066
|
-
args:
|
|
29609
|
+
args: tokenizeShellWords(input2.recipe.launchArgs),
|
|
29067
29610
|
cwd: probeCwd,
|
|
29068
29611
|
owner: { bindingId: input2.host.bindingId },
|
|
29069
29612
|
...Object.keys(input2.env).length > 0 ? { env: input2.env } : {}
|
|
29070
29613
|
});
|
|
29071
|
-
const { readable, writable } =
|
|
29614
|
+
const { readable, writable } = nodeStreamsFromHandle2(handle);
|
|
29072
29615
|
const handshake = await openAcpProbeHandshake({
|
|
29073
29616
|
readable,
|
|
29074
29617
|
writable,
|
|
@@ -29082,7 +29625,7 @@ async function probeAcpAgentVersion(input2) {
|
|
|
29082
29625
|
}
|
|
29083
29626
|
);
|
|
29084
29627
|
} catch (error62) {
|
|
29085
|
-
if (error62 instanceof
|
|
29628
|
+
if (error62 instanceof OperationCleanupError2 || input2.signal?.aborted) throw error62;
|
|
29086
29629
|
return null;
|
|
29087
29630
|
}
|
|
29088
29631
|
}
|
|
@@ -29099,81 +29642,27 @@ function acpRuntimeModeAutoApproves(runtimeMode, toolKind) {
|
|
|
29099
29642
|
return false;
|
|
29100
29643
|
}
|
|
29101
29644
|
}
|
|
29102
|
-
function acpSessionModeToApply(requestedNativeModeId, startedModeId, isResuming) {
|
|
29103
|
-
return requestedNativeModeId !== void 0 && (isResuming || requestedNativeModeId !== startedModeId) ? requestedNativeModeId : void 0;
|
|
29104
|
-
}
|
|
29105
29645
|
|
|
29106
29646
|
// src/acpInstance.ts
|
|
29107
29647
|
var RESUME_SCHEMA_VERSION = 1;
|
|
29108
29648
|
var CLIENT_INFO2 = { name: "ycodium-agent-acp", version: "0.2.0" };
|
|
29109
|
-
var yieldTick = () => new Promise((resolve2) => {
|
|
29110
|
-
setImmediate(resolve2);
|
|
29111
|
-
});
|
|
29112
|
-
function expandHomePath(value) {
|
|
29113
|
-
if (value === "~") return NodeOS3.homedir();
|
|
29114
|
-
if (value.startsWith("~/") || value.startsWith("~\\")) {
|
|
29115
|
-
return NodePath4.join(NodeOS3.homedir(), value.slice(2));
|
|
29116
|
-
}
|
|
29117
|
-
return value;
|
|
29118
|
-
}
|
|
29119
|
-
function modelIdFromSelection(selection) {
|
|
29120
|
-
if (typeof selection !== "object" || selection === null || Array.isArray(selection)) {
|
|
29121
|
-
return void 0;
|
|
29122
|
-
}
|
|
29123
|
-
const model = selection["model"];
|
|
29124
|
-
return typeof model === "string" ? model.trim() || void 0 : void 0;
|
|
29125
|
-
}
|
|
29126
|
-
function buildSpawnEnv(recipe, configuredHomePath) {
|
|
29127
|
-
const homePath = configuredHomePath.trim();
|
|
29128
|
-
const homeEnvVar = recipe.homeEnvVar.trim();
|
|
29129
|
-
const homeInjection = homePath.length > 0 && homeEnvVar.length > 0 ? { [homeEnvVar]: expandHomePath(homePath) } : {};
|
|
29130
|
-
return mergeLaunchEnv({
|
|
29131
|
-
accountHome: homeInjection,
|
|
29132
|
-
instanceTable: recipe.environment
|
|
29133
|
-
});
|
|
29134
|
-
}
|
|
29135
|
-
function nowIso() {
|
|
29136
|
-
return (/* @__PURE__ */ new Date()).toISOString();
|
|
29137
|
-
}
|
|
29138
|
-
function acpContinuationKey(recipe) {
|
|
29139
|
-
const homePath = recipe.homePath.trim();
|
|
29140
|
-
const resolvedHomePath = homePath.length > 0 ? NodePath4.resolve(expandHomePath(homePath)) : "";
|
|
29141
|
-
return `acp:home:${recipe.binaryPath.trim()}\0${resolvedHomePath}`;
|
|
29142
|
-
}
|
|
29143
|
-
async function stopBooked(booked, processExit) {
|
|
29144
|
-
await cleanupAcpSession({
|
|
29145
|
-
executor: booked.executor,
|
|
29146
|
-
stopProcess: () => booked.handle.kill("SIGTERM"),
|
|
29147
|
-
forwarding: booked.forwarding,
|
|
29148
|
-
processExit
|
|
29149
|
-
});
|
|
29150
|
-
}
|
|
29151
29649
|
var createAcpInstance = (config2, host) => {
|
|
29152
29650
|
const recipe = parseAcpInstanceConfig(config2);
|
|
29153
|
-
const threads = /* @__PURE__ */ new Map();
|
|
29154
29651
|
let disposed = false;
|
|
29155
|
-
const { requireThread, registerSession, stopSession,
|
|
29156
|
-
|
|
29157
|
-
|
|
29158
|
-
|
|
29159
|
-
);
|
|
29160
|
-
const disposeOnce = createRetryableClose(async () => {
|
|
29161
|
-
await stopAll();
|
|
29652
|
+
const { table, threads, requireThread, registerSession, stopSession, disposeOnce, threadOps } = bindAcpInstanceThreads({
|
|
29653
|
+
log: host.log,
|
|
29654
|
+
isDisposed: () => disposed,
|
|
29655
|
+
turnSelection: (selection) => readTurnSelection(selection, ACP_EFFORT_OPTION_ID)
|
|
29162
29656
|
});
|
|
29657
|
+
const missingProgram = acpProgramNotConfigured("ACP program path is not configured");
|
|
29163
29658
|
const instance = {
|
|
29164
29659
|
probe: async (signal) => {
|
|
29165
29660
|
if (recipe.binaryPath.length === 0) {
|
|
29166
|
-
return
|
|
29167
|
-
installed: false,
|
|
29168
|
-
version: null,
|
|
29169
|
-
readiness: "not-installed",
|
|
29170
|
-
auth: { status: "unknown" },
|
|
29171
|
-
detail: "ACP program path is not configured"
|
|
29172
|
-
};
|
|
29661
|
+
return missingProgram;
|
|
29173
29662
|
}
|
|
29174
29663
|
if (signal?.aborted) throw new Error("aborted");
|
|
29175
|
-
const env =
|
|
29176
|
-
const outcome = await
|
|
29664
|
+
const env = homeLaunchEnv(recipe, recipe.homePath);
|
|
29665
|
+
const outcome = await raceAbort3(
|
|
29177
29666
|
probeAcpModelsViaSession({
|
|
29178
29667
|
recipe,
|
|
29179
29668
|
host,
|
|
@@ -29184,21 +29673,9 @@ var createAcpInstance = (config2, host) => {
|
|
|
29184
29673
|
);
|
|
29185
29674
|
switch (outcome.kind) {
|
|
29186
29675
|
case "not-started":
|
|
29187
|
-
return
|
|
29188
|
-
installed: false,
|
|
29189
|
-
version: null,
|
|
29190
|
-
readiness: outcome.readiness,
|
|
29191
|
-
auth: { status: "unknown" },
|
|
29192
|
-
...outcome.detail === void 0 ? {} : { detail: outcome.detail }
|
|
29193
|
-
};
|
|
29676
|
+
return acpNotStartedProbeResult(outcome);
|
|
29194
29677
|
case "failed":
|
|
29195
|
-
return {
|
|
29196
|
-
installed: true,
|
|
29197
|
-
version: outcome.version,
|
|
29198
|
-
readiness: "error",
|
|
29199
|
-
auth: { status: "unknown" },
|
|
29200
|
-
...outcome.detail === void 0 ? {} : { detail: outcome.detail }
|
|
29201
|
-
};
|
|
29678
|
+
return acpFailedProbeResult(outcome, { status: "unknown" });
|
|
29202
29679
|
case "auth-required":
|
|
29203
29680
|
return {
|
|
29204
29681
|
installed: true,
|
|
@@ -29224,7 +29701,7 @@ var createAcpInstance = (config2, host) => {
|
|
|
29224
29701
|
readCliVersion: (signal) => recipe.binaryPath.length === 0 ? Promise.resolve(null) : probeAcpAgentVersion({
|
|
29225
29702
|
recipe,
|
|
29226
29703
|
host,
|
|
29227
|
-
env:
|
|
29704
|
+
env: homeLaunchEnv(recipe, recipe.homePath),
|
|
29228
29705
|
...signal === void 0 ? {} : { signal }
|
|
29229
29706
|
}),
|
|
29230
29707
|
// 暂不处理 input.readOnlyDirectories(有意为之):acp 经共享的 ycodium-acp-executor 起会话,
|
|
@@ -29237,27 +29714,25 @@ var createAcpInstance = (config2, host) => {
|
|
|
29237
29714
|
}
|
|
29238
29715
|
const cwd = input2.cwd ?? host.workspacePath(input2.threadId);
|
|
29239
29716
|
if (cwd.trim() === "") throw new Error("workspace path missing");
|
|
29240
|
-
|
|
29241
|
-
|
|
29242
|
-
|
|
29243
|
-
|
|
29244
|
-
|
|
29245
|
-
|
|
29246
|
-
|
|
29247
|
-
|
|
29248
|
-
|
|
29249
|
-
|
|
29250
|
-
cwd,
|
|
29251
|
-
owner: { bindingId: host.bindingId },
|
|
29252
|
-
...Object.keys(env).length > 0 ? { env } : {}
|
|
29253
|
-
});
|
|
29254
|
-
const { readable, writable, stderrTail } = nodeStreamsFromHandle2(handle);
|
|
29255
|
-
const resume = input2.discardResumeCursor === true ? void 0 : parseAcpResumeCursor(input2.resumeCursor, RESUME_SCHEMA_VERSION);
|
|
29256
|
-
const requestedModelId = modelIdFromSelection(input2.modelSelection);
|
|
29257
|
-
const requestedEffort = modelSelectionStringOption(
|
|
29258
|
-
input2.modelSelection,
|
|
29259
|
-
ACP_EFFORT_OPTION_ID
|
|
29717
|
+
await stopExistingAcpThread(table, input2.threadId, () => disposed, signal);
|
|
29718
|
+
const env = homeLaunchEnv(recipe, recipe.homePath);
|
|
29719
|
+
const handle = await host.process.spawn(
|
|
29720
|
+
acpOwnedSpawnSpec({
|
|
29721
|
+
program: recipe.binaryPath,
|
|
29722
|
+
args: tokenizeShellWords(recipe.launchArgs),
|
|
29723
|
+
cwd,
|
|
29724
|
+
bindingId: host.bindingId,
|
|
29725
|
+
env
|
|
29726
|
+
})
|
|
29260
29727
|
);
|
|
29728
|
+
const { readable, writable, stderrTail, resume, requestedModelId, requestedEffort } = acpLaunchFromHandle({
|
|
29729
|
+
handle,
|
|
29730
|
+
start: input2,
|
|
29731
|
+
modelSelection: input2.modelSelection,
|
|
29732
|
+
resumeSchemaVersion: RESUME_SCHEMA_VERSION,
|
|
29733
|
+
effortOptionId: ACP_EFFORT_OPTION_ID,
|
|
29734
|
+
modelIdFromSelection
|
|
29735
|
+
});
|
|
29261
29736
|
const autoApprove = input2.nativeModeId === void 0 ? (request) => acpRuntimeModeAutoApproves(
|
|
29262
29737
|
threads.get(input2.threadId)?.session.runtimeMode ?? input2.runtimeMode,
|
|
29263
29738
|
request.kind
|
|
@@ -29283,154 +29758,45 @@ var createAcpInstance = (config2, host) => {
|
|
|
29283
29758
|
}),
|
|
29284
29759
|
...requestedModelId === void 0 ? {} : { requestedModelId },
|
|
29285
29760
|
...autoApprove === void 0 ? {} : { autoApprove },
|
|
29286
|
-
...resume === void 0 ? {} : { resumeSessionId: resume.sessionId },
|
|
29287
29761
|
// 内置编排那一条排第一,后面跟用户在插件中心配的;缺了 `mcpServers` 这一栏,
|
|
29288
|
-
// `mcp__ycodium__*` 整套工具在通用 ACP
|
|
29289
|
-
...
|
|
29762
|
+
// `mcp__ycodium__*` 整套工具在通用 ACP 会话里都不存在。空列表不传这一栏。
|
|
29763
|
+
...acpLaunchMcpFields({
|
|
29764
|
+
mcpServers: input2.mcpServers,
|
|
29765
|
+
resumeSessionId: resume?.sessionId,
|
|
29766
|
+
omitWhenEmpty: true
|
|
29767
|
+
})
|
|
29290
29768
|
});
|
|
29291
|
-
|
|
29292
|
-
|
|
29293
|
-
|
|
29294
|
-
|
|
29295
|
-
|
|
29296
|
-
|
|
29297
|
-
|
|
29298
|
-
|
|
29299
|
-
|
|
29300
|
-
|
|
29301
|
-
|
|
29302
|
-
resume !== void 0
|
|
29303
|
-
);
|
|
29304
|
-
if (modeToApply !== void 0) {
|
|
29305
|
-
await raceStartAbort(executor.setNativeMode(modeToApply), signal);
|
|
29306
|
-
}
|
|
29307
|
-
await yieldTick();
|
|
29308
|
-
throwIfStartAborted(signal);
|
|
29309
|
-
const createdAt = nowIso();
|
|
29310
|
-
const resumeCursor = {
|
|
29311
|
-
schemaVersion: RESUME_SCHEMA_VERSION,
|
|
29312
|
-
sessionId: started.sessionId
|
|
29313
|
-
};
|
|
29314
|
-
const session = {
|
|
29769
|
+
return openRequestedAcpThread({
|
|
29770
|
+
registerSession,
|
|
29771
|
+
threadId: input2.threadId,
|
|
29772
|
+
executor,
|
|
29773
|
+
handle,
|
|
29774
|
+
signal,
|
|
29775
|
+
log: host.log,
|
|
29776
|
+
emit: (event) => input2.events.emit(event),
|
|
29777
|
+
requestedNativeModeId: input2.nativeModeId,
|
|
29778
|
+
resumed: resume !== void 0,
|
|
29779
|
+
session: {
|
|
29315
29780
|
provider: ACP_DRIVER_KIND,
|
|
29316
29781
|
providerInstanceId: host.instanceId,
|
|
29317
|
-
status: "idle",
|
|
29318
29782
|
runtimeMode: input2.runtimeMode,
|
|
29319
|
-
|
|
29783
|
+
nativeModeId: input2.nativeModeId,
|
|
29320
29784
|
cwd,
|
|
29321
|
-
|
|
29322
|
-
|
|
29323
|
-
|
|
29324
|
-
|
|
29325
|
-
|
|
29326
|
-
model: started.modelId,
|
|
29327
|
-
// agent 在握手里报的才是读回的;切型号走 session/set_model 时回包不带型号,那只是请求值。
|
|
29328
|
-
modelSource: started.modelReported ? "reported" : "echo"
|
|
29329
|
-
},
|
|
29330
|
-
...input2.bindingGeneration === void 0 ? {} : { bindingGeneration: input2.bindingGeneration }
|
|
29331
|
-
};
|
|
29332
|
-
registerSession(input2.threadId, {
|
|
29333
|
-
session,
|
|
29334
|
-
turns: [],
|
|
29335
|
-
executor,
|
|
29336
|
-
handle,
|
|
29337
|
-
forwarding
|
|
29338
|
-
});
|
|
29339
|
-
host.log.info("session started", {
|
|
29340
|
-
threadId: input2.threadId,
|
|
29341
|
-
sessionId: started.sessionId
|
|
29342
|
-
});
|
|
29343
|
-
return session;
|
|
29344
|
-
} catch (error62) {
|
|
29345
|
-
await cleanupAcpStartup({
|
|
29346
|
-
executor,
|
|
29347
|
-
stopProcess: () => handle.kill("SIGTERM"),
|
|
29348
|
-
forwarding,
|
|
29349
|
-
log: host.log,
|
|
29350
|
-
threadId: input2.threadId
|
|
29351
|
-
});
|
|
29352
|
-
throw error62;
|
|
29353
|
-
}
|
|
29354
|
-
},
|
|
29355
|
-
sendTurn: async (input2, signal) => {
|
|
29356
|
-
if (disposed) throw new Error("instance disposed");
|
|
29357
|
-
const booked = requireThread(input2.threadId);
|
|
29358
|
-
if (signal?.aborted) throw new Error("aborted");
|
|
29359
|
-
const onAbort = () => {
|
|
29360
|
-
void booked.executor.cancel(input2.expectedTurnId).catch(() => void 0);
|
|
29361
|
-
};
|
|
29362
|
-
signal?.addEventListener("abort", onAbort);
|
|
29363
|
-
try {
|
|
29364
|
-
const requestedModelId = modelIdFromSelection(input2.modelSelection);
|
|
29365
|
-
const requestedEffort = modelSelectionStringOption(
|
|
29366
|
-
input2.modelSelection,
|
|
29367
|
-
ACP_EFFORT_OPTION_ID
|
|
29368
|
-
);
|
|
29369
|
-
const turn = await dispatchAcpPrompt(booked.executor, {
|
|
29370
|
-
text: input2.input ?? "",
|
|
29371
|
-
expectedActiveTurnId: input2.expectedTurnId,
|
|
29372
|
-
...requestedModelId === void 0 ? {} : { requestedModelId },
|
|
29373
|
-
...requestedEffort === void 0 ? {} : { requestedEffort }
|
|
29374
|
-
});
|
|
29375
|
-
booked.turns.push({ id: turn.turnId, items: [] });
|
|
29376
|
-
return {
|
|
29377
|
-
threadId: input2.threadId,
|
|
29378
|
-
turnId: turn.turnId,
|
|
29379
|
-
...booked.session.resumeCursor === void 0 ? {} : { resumeCursor: booked.session.resumeCursor }
|
|
29380
|
-
};
|
|
29381
|
-
} finally {
|
|
29382
|
-
signal?.removeEventListener("abort", onAbort);
|
|
29383
|
-
}
|
|
29384
|
-
},
|
|
29385
|
-
interruptTurn: async (threadId, turnId) => {
|
|
29386
|
-
const booked = threads.get(threadId);
|
|
29387
|
-
if (booked === void 0 || booked.closing) return;
|
|
29388
|
-
host.log.info("interrupt turn", { threadId, turnId });
|
|
29389
|
-
await booked.executor.cancel(turnId);
|
|
29390
|
-
await yieldTick();
|
|
29391
|
-
},
|
|
29392
|
-
respondToRequest: async (threadId, requestId, decision, reason) => {
|
|
29393
|
-
const booked = requireThread(threadId);
|
|
29394
|
-
await booked.executor.respondToRequest(
|
|
29395
|
-
requestId,
|
|
29396
|
-
decision === "allow" ? "accept" : "decline",
|
|
29397
|
-
reason
|
|
29398
|
-
);
|
|
29399
|
-
},
|
|
29400
|
-
respondToUserInput: async (threadId, requestId, answers) => {
|
|
29401
|
-
const booked = requireThread(threadId);
|
|
29402
|
-
await booked.executor.respondToUserInput(requestId, answers);
|
|
29403
|
-
},
|
|
29404
|
-
/**
|
|
29405
|
-
* 切这只手自报的审批档。`nativeModeId` 是它自己报的 id(探测时原样上报的那些),
|
|
29406
|
-
* 一路不翻译成宿主四档。
|
|
29407
|
-
*
|
|
29408
|
-
* 这是 `setRuntimeMode` 做不到的那一半:那个只改插件自己的会话记录,CLI 收不到
|
|
29409
|
-
* (`runtime-mode-never-reaches-cli` 记的那族缺陷)。
|
|
29410
|
-
*/
|
|
29411
|
-
setNativeMode: async (threadId, nativeModeId) => {
|
|
29412
|
-
const booked = requireThread(threadId);
|
|
29413
|
-
await booked.executor.setNativeMode(nativeModeId);
|
|
29414
|
-
booked.session = {
|
|
29415
|
-
...booked.session,
|
|
29416
|
-
nativeModeId,
|
|
29417
|
-
updatedAt: nowIso()
|
|
29418
|
-
};
|
|
29419
|
-
},
|
|
29420
|
-
setRuntimeMode: async (threadId, runtimeMode) => {
|
|
29421
|
-
const booked = requireThread(threadId);
|
|
29422
|
-
booked.session = {
|
|
29423
|
-
...booked.session,
|
|
29424
|
-
runtimeMode,
|
|
29425
|
-
updatedAt: nowIso()
|
|
29426
|
-
};
|
|
29785
|
+
bindingGeneration: input2.bindingGeneration,
|
|
29786
|
+
resumeSchemaVersion: RESUME_SCHEMA_VERSION
|
|
29787
|
+
},
|
|
29788
|
+
booked: (base) => ({ ...base })
|
|
29789
|
+
});
|
|
29427
29790
|
},
|
|
29791
|
+
sendTurn: threadOps.sendTurn,
|
|
29792
|
+
interruptTurn: threadOps.interruptTurn,
|
|
29793
|
+
respondToRequest: threadOps.respondToRequest,
|
|
29794
|
+
respondToUserInput: threadOps.respondToUserInput,
|
|
29795
|
+
setNativeMode: threadOps.setNativeMode,
|
|
29796
|
+
setRuntimeMode: threadOps.setRuntimeMode,
|
|
29428
29797
|
stopSession: (threadId) => stopSession(threadId),
|
|
29429
|
-
readThread:
|
|
29430
|
-
|
|
29431
|
-
return { threadId, turns: booked.turns };
|
|
29432
|
-
},
|
|
29433
|
-
continuationKey: acpContinuationKey(recipe),
|
|
29798
|
+
readThread: threadOps.readThread,
|
|
29799
|
+
continuationKey: homeContinuationKey("acp", recipe),
|
|
29434
29800
|
dispose: () => {
|
|
29435
29801
|
disposed = true;
|
|
29436
29802
|
return disposeOnce();
|