@ycodium-ai/agent-dsh 0.2.3614 → 0.2.3635
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 +531 -307
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -7411,11 +7411,10 @@ var DSH_CARD = {
|
|
|
7411
7411
|
verifiedSkills: true,
|
|
7412
7412
|
everydayHarness: false,
|
|
7413
7413
|
capabilities: {
|
|
7414
|
-
//
|
|
7415
|
-
//
|
|
7416
|
-
sessionModelSwitch: "
|
|
7417
|
-
|
|
7418
|
-
sessionOptionSwitch: "unsupported",
|
|
7414
|
+
// 型号与力度档都经 `session/set_config_option` 在会话里切,执行器发送前写进去,不重开会话
|
|
7415
|
+
// (0.2.1-rc.5 实测,同一进程,下一轮发给模型的就是新型号、新档)。
|
|
7416
|
+
sessionModelSwitch: "in-session",
|
|
7417
|
+
sessionOptionSwitch: "in-session",
|
|
7419
7418
|
// 权限档只在 spawn 时定得了:CLI 读启动时的 `DSH_PERMISSION_MODE`(见 permission.ts),
|
|
7420
7419
|
// `session/new` 不报 `modes`,`session/set_mode` 回 `-32601 "Method not found"`,活着的
|
|
7421
7420
|
// 会话里没有任何一条路能改它。所以与 Grok 同路:宿主把新档记在 thread 上,下一轮
|
|
@@ -7567,6 +7566,40 @@ var AcpExecutorTurnEndedError = class extends AcpExecutorError {
|
|
|
7567
7566
|
this.name = "AcpExecutorTurnEndedError";
|
|
7568
7567
|
}
|
|
7569
7568
|
};
|
|
7569
|
+
var AcpExecutorOptionRejectedError = class extends AcpExecutorError {
|
|
7570
|
+
constructor(option, value, cause) {
|
|
7571
|
+
const detail = acpErrorDetail(cause);
|
|
7572
|
+
super(
|
|
7573
|
+
"provider-rejected",
|
|
7574
|
+
`The agent rejected the ${option}${value === void 0 ? "" : ` "${value}"`}${detail === void 0 ? "" : ` (${detail})`}. This turn was not sent.`
|
|
7575
|
+
);
|
|
7576
|
+
this.name = "AcpExecutorOptionRejectedError";
|
|
7577
|
+
}
|
|
7578
|
+
};
|
|
7579
|
+
var AcpExecutorOptionTimeoutError = class extends AcpExecutorError {
|
|
7580
|
+
constructor(option, value) {
|
|
7581
|
+
super(
|
|
7582
|
+
"provider-rejected",
|
|
7583
|
+
`The agent did not answer the ${option} "${value}" change in time. This turn was not sent.`
|
|
7584
|
+
);
|
|
7585
|
+
this.name = "AcpExecutorOptionTimeoutError";
|
|
7586
|
+
}
|
|
7587
|
+
};
|
|
7588
|
+
var AcpOptionWriteStoppedError = class extends Error {
|
|
7589
|
+
constructor() {
|
|
7590
|
+
super("option write stopped");
|
|
7591
|
+
this.name = "AcpOptionWriteStoppedError";
|
|
7592
|
+
}
|
|
7593
|
+
};
|
|
7594
|
+
function acpErrorDetail(cause) {
|
|
7595
|
+
if (typeof cause !== "object" || cause === null) return void 0;
|
|
7596
|
+
const message = cause.message;
|
|
7597
|
+
const data = cause.data;
|
|
7598
|
+
const parts = [message, data].filter(
|
|
7599
|
+
(part) => typeof part === "string" && part.trim().length > 0
|
|
7600
|
+
);
|
|
7601
|
+
return parts.length === 0 ? void 0 : parts.join(": ");
|
|
7602
|
+
}
|
|
7570
7603
|
var AcpExecutorNotStartedError = class extends AcpExecutorError {
|
|
7571
7604
|
constructor(message = "ACP session has not been started") {
|
|
7572
7605
|
super("not-started", message);
|
|
@@ -7680,10 +7713,112 @@ var UnboundedEventStream = class {
|
|
|
7680
7713
|
}
|
|
7681
7714
|
};
|
|
7682
7715
|
|
|
7683
|
-
// ../../packages/ycodium-acp-executor/src/
|
|
7716
|
+
// ../../packages/ycodium-acp-executor/src/config-options.ts
|
|
7684
7717
|
function isRecord(value) {
|
|
7685
7718
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7686
7719
|
}
|
|
7720
|
+
function asString(value) {
|
|
7721
|
+
return typeof value === "string" ? value : void 0;
|
|
7722
|
+
}
|
|
7723
|
+
function normalizedField(option, key) {
|
|
7724
|
+
return asString(option[key])?.trim().toLowerCase() ?? "";
|
|
7725
|
+
}
|
|
7726
|
+
function looksLikeEffortOption(option) {
|
|
7727
|
+
const id = normalizedField(option, "id");
|
|
7728
|
+
const name = normalizedField(option, "name");
|
|
7729
|
+
return id === "effort" || id === "reasoning" || name === "effort" || name === "reasoning" || name.includes("effort") || name.includes("reasoning") || normalizedField(option, "category") === "thought_level";
|
|
7730
|
+
}
|
|
7731
|
+
function flattenChoices(rawOptions, currentValue) {
|
|
7732
|
+
if (!Array.isArray(rawOptions)) return [];
|
|
7733
|
+
const out = [];
|
|
7734
|
+
const seen = /* @__PURE__ */ new Set();
|
|
7735
|
+
const push = (entry) => {
|
|
7736
|
+
if (!isRecord(entry)) return;
|
|
7737
|
+
const value = asString(entry["value"]);
|
|
7738
|
+
if (value === void 0 || seen.has(value)) return;
|
|
7739
|
+
seen.add(value);
|
|
7740
|
+
const description = asString(entry["description"])?.trim();
|
|
7741
|
+
const name = asString(entry["name"])?.trim();
|
|
7742
|
+
out.push({
|
|
7743
|
+
value,
|
|
7744
|
+
...name ? { name } : {},
|
|
7745
|
+
label: name || value,
|
|
7746
|
+
...description ? { description } : {},
|
|
7747
|
+
...currentValue !== void 0 && currentValue === value ? { isDefault: true } : {}
|
|
7748
|
+
});
|
|
7749
|
+
};
|
|
7750
|
+
for (const entry of rawOptions) {
|
|
7751
|
+
if (isRecord(entry) && Array.isArray(entry["options"])) {
|
|
7752
|
+
for (const nested of entry["options"]) push(nested);
|
|
7753
|
+
continue;
|
|
7754
|
+
}
|
|
7755
|
+
push(entry);
|
|
7756
|
+
}
|
|
7757
|
+
return out;
|
|
7758
|
+
}
|
|
7759
|
+
function isConfigOption(entry, configId) {
|
|
7760
|
+
return isRecord(entry) && asString(entry["id"])?.trim() === configId.trim();
|
|
7761
|
+
}
|
|
7762
|
+
function findConfigOptionEntry(configOptions, configId) {
|
|
7763
|
+
return Array.isArray(configOptions) && configId.trim() !== "" ? configOptions.find(
|
|
7764
|
+
(entry) => isConfigOption(entry, configId)
|
|
7765
|
+
) : void 0;
|
|
7766
|
+
}
|
|
7767
|
+
function withConfigOptionValue(configOptions, configId, value) {
|
|
7768
|
+
if (!Array.isArray(configOptions)) return configOptions;
|
|
7769
|
+
return configOptions.map(
|
|
7770
|
+
(option) => isConfigOption(option, configId) ? { ...option, currentValue: value } : option
|
|
7771
|
+
);
|
|
7772
|
+
}
|
|
7773
|
+
function pickEffortOption(configOptions) {
|
|
7774
|
+
if (!Array.isArray(configOptions)) return void 0;
|
|
7775
|
+
const candidates = configOptions.filter(isRecord).filter((option) => normalizedField(option, "type") === "select").filter(looksLikeEffortOption);
|
|
7776
|
+
return candidates.find((option) => normalizedField(option, "category") === "model_option") ?? candidates.find((option) => normalizedField(option, "id") === "effort") ?? candidates.find((option) => normalizedField(option, "category") === "thought_level") ?? candidates[0];
|
|
7777
|
+
}
|
|
7778
|
+
function findAcpEffortConfig(configOptions) {
|
|
7779
|
+
const picked = pickEffortOption(configOptions);
|
|
7780
|
+
if (picked === void 0) return void 0;
|
|
7781
|
+
const configId = asString(picked["id"])?.trim();
|
|
7782
|
+
if (!configId) return void 0;
|
|
7783
|
+
const currentValue = asString(picked["currentValue"])?.trim() || void 0;
|
|
7784
|
+
const choices = flattenChoices(picked["options"], currentValue);
|
|
7785
|
+
if (choices.length === 0) return void 0;
|
|
7786
|
+
return {
|
|
7787
|
+
configId,
|
|
7788
|
+
label: asString(picked["name"])?.trim() ?? "",
|
|
7789
|
+
choices,
|
|
7790
|
+
...currentValue === void 0 ? {} : { currentValue }
|
|
7791
|
+
};
|
|
7792
|
+
}
|
|
7793
|
+
function choicesComplete(rawOptions) {
|
|
7794
|
+
const leafOk = (entry) => isRecord(entry) && (asString(entry["value"])?.trim() ?? "") !== "";
|
|
7795
|
+
return rawOptions.every(
|
|
7796
|
+
(entry) => isRecord(entry) && Array.isArray(entry["options"]) ? entry["options"].every(leafOk) : leafOk(entry)
|
|
7797
|
+
);
|
|
7798
|
+
}
|
|
7799
|
+
function acpEffortConfigState(configOptions) {
|
|
7800
|
+
const picked = pickEffortOption(configOptions);
|
|
7801
|
+
if (picked === void 0 || !asString(picked["id"])?.trim()) return "unknown";
|
|
7802
|
+
const options = picked["options"];
|
|
7803
|
+
if (!Array.isArray(options)) return "unknown";
|
|
7804
|
+
if (options.length === 0) return "none";
|
|
7805
|
+
return choicesComplete(options) ? "listed" : "unknown";
|
|
7806
|
+
}
|
|
7807
|
+
function acpModelChoicesFromConfigOptions(configOptions) {
|
|
7808
|
+
if (!Array.isArray(configOptions)) return void 0;
|
|
7809
|
+
const records = configOptions.filter(isRecord);
|
|
7810
|
+
const modelOption = records.find((option) => normalizedField(option, "category") === "model") ?? records.find(
|
|
7811
|
+
(option) => normalizedField(option, "id") === "model" && normalizedField(option, "type") === "select"
|
|
7812
|
+
);
|
|
7813
|
+
if (modelOption === void 0) return void 0;
|
|
7814
|
+
if (!asString(modelOption["id"])?.trim()) return void 0;
|
|
7815
|
+
return flattenChoices(modelOption["options"], asString(modelOption["currentValue"])?.trim());
|
|
7816
|
+
}
|
|
7817
|
+
|
|
7818
|
+
// ../../packages/ycodium-acp-executor/src/util.ts
|
|
7819
|
+
function isRecord2(value) {
|
|
7820
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7821
|
+
}
|
|
7687
7822
|
function asTrimmedString(value) {
|
|
7688
7823
|
if (typeof value !== "string") {
|
|
7689
7824
|
return void 0;
|
|
@@ -7736,11 +7871,11 @@ function extractCommandFromTitle(title) {
|
|
|
7736
7871
|
return backtickMatch?.[1]?.trim() || void 0;
|
|
7737
7872
|
}
|
|
7738
7873
|
function extractToolCommand(data, title) {
|
|
7739
|
-
const item =
|
|
7740
|
-
const itemInput = item &&
|
|
7741
|
-
const itemResult = item &&
|
|
7742
|
-
const rawInput =
|
|
7743
|
-
const dataInput =
|
|
7874
|
+
const item = isRecord2(data?.["item"]) ? data["item"] : void 0;
|
|
7875
|
+
const itemInput = item && isRecord2(item["input"]) ? item["input"] : void 0;
|
|
7876
|
+
const itemResult = item && isRecord2(item["result"]) ? item["result"] : void 0;
|
|
7877
|
+
const rawInput = isRecord2(data?.["rawInput"]) ? data["rawInput"] : void 0;
|
|
7878
|
+
const dataInput = isRecord2(data?.["input"]) ? data["input"] : void 0;
|
|
7744
7879
|
const candidates = [
|
|
7745
7880
|
normalizeCommandValue(item?.["command"]),
|
|
7746
7881
|
normalizeCommandValue(itemInput?.["command"]),
|
|
@@ -7785,7 +7920,7 @@ function collectPaths(value, paths, seen, depth) {
|
|
|
7785
7920
|
}
|
|
7786
7921
|
return;
|
|
7787
7922
|
}
|
|
7788
|
-
if (!
|
|
7923
|
+
if (!isRecord2(value)) {
|
|
7789
7924
|
return;
|
|
7790
7925
|
}
|
|
7791
7926
|
for (const key of ["path", "filePath", "relativePath", "filename", "newPath", "oldPath"]) {
|
|
@@ -7863,7 +7998,7 @@ function deriveToolActivityPresentation(input2) {
|
|
|
7863
7998
|
const title = asTrimmedString(input2.title);
|
|
7864
7999
|
const detail = stripTrailingExitCode(asTrimmedString(input2.detail));
|
|
7865
8000
|
const fallbackSummary = asTrimmedString(input2.fallbackSummary) ?? "Tool";
|
|
7866
|
-
const data =
|
|
8001
|
+
const data = isRecord2(input2.data) ? input2.data : void 0;
|
|
7867
8002
|
const command = extractToolCommand(data, title);
|
|
7868
8003
|
const primaryPath = extractPrimaryPath(data);
|
|
7869
8004
|
const action = classifyToolAction({
|
|
@@ -7895,7 +8030,7 @@ function deriveToolActivityPresentation(input2) {
|
|
|
7895
8030
|
};
|
|
7896
8031
|
}
|
|
7897
8032
|
if (action === "search") {
|
|
7898
|
-
const rawInput =
|
|
8033
|
+
const rawInput = isRecord2(data?.["rawInput"]) ? data["rawInput"] : void 0;
|
|
7899
8034
|
const query = asTrimmedString(rawInput?.["query"]) ?? asTrimmedString(rawInput?.["pattern"]) ?? asTrimmedString(rawInput?.["searchTerm"]);
|
|
7900
8035
|
return {
|
|
7901
8036
|
summary: "Searched files",
|
|
@@ -7955,7 +8090,7 @@ function extractCommandFromTitle2(title) {
|
|
|
7955
8090
|
return match?.[1]?.trim() || void 0;
|
|
7956
8091
|
}
|
|
7957
8092
|
function extractToolCallCommand(rawInput, title) {
|
|
7958
|
-
if (
|
|
8093
|
+
if (isRecord2(rawInput)) {
|
|
7959
8094
|
const directCommand = normalizeCommandValue2(rawInput["command"]);
|
|
7960
8095
|
if (directCommand) {
|
|
7961
8096
|
return directCommand;
|
|
@@ -7983,7 +8118,7 @@ function boundTailText(text, limit = TOOL_CALL_CONTENT_MAX_CHARS) {
|
|
|
7983
8118
|
var boundToolCallOutputText = (text) => boundTailText(text);
|
|
7984
8119
|
var RAW_OUTPUT_TEXT_FIELDS = ["content", "stdout", "stderr", "output"];
|
|
7985
8120
|
function boundToolCallRawOutput(rawOutput) {
|
|
7986
|
-
if (!
|
|
8121
|
+
if (!isRecord2(rawOutput)) {
|
|
7987
8122
|
return rawOutput;
|
|
7988
8123
|
}
|
|
7989
8124
|
let changed = false;
|
|
@@ -8164,14 +8299,7 @@ function extractModelConfigId(sessionResponse) {
|
|
|
8164
8299
|
return configOptions.find((opt) => opt.id.trim() === "model" && opt.type === "select") ? "model" : void 0;
|
|
8165
8300
|
}
|
|
8166
8301
|
function findSessionConfigOption(configOptions, configId) {
|
|
8167
|
-
|
|
8168
|
-
return void 0;
|
|
8169
|
-
}
|
|
8170
|
-
const normalizedConfigId = configId.trim();
|
|
8171
|
-
if (!normalizedConfigId) {
|
|
8172
|
-
return void 0;
|
|
8173
|
-
}
|
|
8174
|
-
return configOptions.find((option) => option.id.trim() === normalizedConfigId);
|
|
8302
|
+
return findConfigOptionEntry(configOptions, configId);
|
|
8175
8303
|
}
|
|
8176
8304
|
function collectSessionConfigOptionValues(configOption) {
|
|
8177
8305
|
if (configOption.type !== "select" || !configOption.options) {
|
|
@@ -8182,11 +8310,11 @@ function collectSessionConfigOptionValues(configOption) {
|
|
|
8182
8310
|
);
|
|
8183
8311
|
}
|
|
8184
8312
|
function collectSessionModelIds(models) {
|
|
8185
|
-
if (!
|
|
8313
|
+
if (!isRecord2(models) || !Array.isArray(models["availableModels"])) {
|
|
8186
8314
|
return [];
|
|
8187
8315
|
}
|
|
8188
8316
|
return models["availableModels"].flatMap(
|
|
8189
|
-
(model) =>
|
|
8317
|
+
(model) => isRecord2(model) && typeof model["modelId"] === "string" ? [model["modelId"]] : []
|
|
8190
8318
|
);
|
|
8191
8319
|
}
|
|
8192
8320
|
function catalogModelLastSegment(value) {
|
|
@@ -8258,7 +8386,7 @@ function parseAvailableCommandsUpdate(params) {
|
|
|
8258
8386
|
}
|
|
8259
8387
|
const commands = [];
|
|
8260
8388
|
for (const command of availableCommands) {
|
|
8261
|
-
if (!
|
|
8389
|
+
if (!isRecord2(command)) {
|
|
8262
8390
|
continue;
|
|
8263
8391
|
}
|
|
8264
8392
|
const name = typeof command["name"] === "string" ? command["name"].trim() : "";
|
|
@@ -8266,7 +8394,7 @@ function parseAvailableCommandsUpdate(params) {
|
|
|
8266
8394
|
continue;
|
|
8267
8395
|
}
|
|
8268
8396
|
const description = typeof command["description"] === "string" ? command["description"].trim() || void 0 : void 0;
|
|
8269
|
-
const input2 =
|
|
8397
|
+
const input2 = isRecord2(command["input"]) ? command["input"] : void 0;
|
|
8270
8398
|
const inputHint = typeof input2?.["hint"] === "string" ? input2["hint"].trim() || void 0 : void 0;
|
|
8271
8399
|
commands.push({
|
|
8272
8400
|
name,
|
|
@@ -8320,7 +8448,7 @@ function boundToolCallRawPayload(params, update, toolCall) {
|
|
|
8320
8448
|
}
|
|
8321
8449
|
function textFromContentBlocks(blocks) {
|
|
8322
8450
|
const parts = blocks.flatMap(
|
|
8323
|
-
(block) =>
|
|
8451
|
+
(block) => isRecord2(block) && block["type"] === "text" && typeof block["text"] === "string" ? [block["text"]] : []
|
|
8324
8452
|
);
|
|
8325
8453
|
const joined = parts.join("");
|
|
8326
8454
|
return joined.trim().length > 0 ? joined : void 0;
|
|
@@ -8345,7 +8473,7 @@ function parseSessionUpdateEvent(params) {
|
|
|
8345
8473
|
const entries = Array.isArray(upd["entries"]) ? upd["entries"] : [];
|
|
8346
8474
|
const plan = entries.map((entry, index) => ({
|
|
8347
8475
|
step: readAcpText(entry, "content") ?? `Step ${index + 1}`,
|
|
8348
|
-
status: normalizePlanStepStatus(
|
|
8476
|
+
status: normalizePlanStepStatus(isRecord2(entry) ? entry["status"] : void 0)
|
|
8349
8477
|
}));
|
|
8350
8478
|
if (plan.length > 0) {
|
|
8351
8479
|
events.push({
|
|
@@ -8385,7 +8513,7 @@ function parseSessionUpdateEvent(params) {
|
|
|
8385
8513
|
}
|
|
8386
8514
|
case "agent_message_chunk":
|
|
8387
8515
|
case "agent_thought_chunk": {
|
|
8388
|
-
const content =
|
|
8516
|
+
const content = isRecord2(upd["content"]) ? upd["content"] : void 0;
|
|
8389
8517
|
const contentType = content?.["type"];
|
|
8390
8518
|
const streamKind = kind === "agent_thought_chunk" ? "reasoning_text" : "assistant_text";
|
|
8391
8519
|
if (contentType === "text") {
|
|
@@ -8425,7 +8553,7 @@ function parseSessionUpdateEvent(params) {
|
|
|
8425
8553
|
}
|
|
8426
8554
|
case "compaction_summary_chunk": {
|
|
8427
8555
|
const compactionId = readAcpText(upd, "compactionId");
|
|
8428
|
-
const content =
|
|
8556
|
+
const content = isRecord2(upd["content"]) ? upd["content"] : void 0;
|
|
8429
8557
|
const text = content?.["type"] === "text" ? content["text"] : void 0;
|
|
8430
8558
|
if (compactionId === void 0 || typeof text !== "string" || text.length === 0) break;
|
|
8431
8559
|
events.push({ _tag: "CompactionSummaryChunk", compactionId, text });
|
|
@@ -30119,17 +30247,17 @@ function isResponseMessage(value) {
|
|
|
30119
30247
|
function isNotificationMessage(value) {
|
|
30120
30248
|
return isJsonRpcEnvelope(value) && !("id" in value) && typeof value["method"] === "string";
|
|
30121
30249
|
}
|
|
30122
|
-
function
|
|
30250
|
+
function isRecord3(value) {
|
|
30123
30251
|
return typeof value === "object" && value !== null;
|
|
30124
30252
|
}
|
|
30125
30253
|
function isJsonRpcEnvelope(value) {
|
|
30126
|
-
return
|
|
30254
|
+
return isRecord3(value) && value["jsonrpc"] === "2.0";
|
|
30127
30255
|
}
|
|
30128
30256
|
function isJsonRpcId(value) {
|
|
30129
30257
|
return value === null || typeof value === "string" || typeof value === "number" && Number.isFinite(value);
|
|
30130
30258
|
}
|
|
30131
30259
|
function isResponseShapedMessage(value) {
|
|
30132
|
-
return
|
|
30260
|
+
return isRecord3(value) && !("method" in value) && ("id" in value || "result" in value || "error" in value);
|
|
30133
30261
|
}
|
|
30134
30262
|
function isResponseBatch(batch) {
|
|
30135
30263
|
let hasValidCall = false;
|
|
@@ -30139,7 +30267,7 @@ function isResponseBatch(batch) {
|
|
|
30139
30267
|
for (const entry of batch) {
|
|
30140
30268
|
hasValidCall ||= isRequestMessage(entry) || isNotificationMessage(entry);
|
|
30141
30269
|
hasValidResponse ||= isResponseMessage(entry);
|
|
30142
|
-
if (!
|
|
30270
|
+
if (!isRecord3(entry)) {
|
|
30143
30271
|
continue;
|
|
30144
30272
|
}
|
|
30145
30273
|
hasCallShape ||= "method" in entry;
|
|
@@ -30154,13 +30282,13 @@ function isResponseBatch(batch) {
|
|
|
30154
30282
|
return hasResponseShape && !hasCallShape;
|
|
30155
30283
|
}
|
|
30156
30284
|
function cancelRequestId(params) {
|
|
30157
|
-
if (!
|
|
30285
|
+
if (!isRecord3(params) || !isJsonRpcId(params["requestId"])) {
|
|
30158
30286
|
return void 0;
|
|
30159
30287
|
}
|
|
30160
30288
|
return params["requestId"];
|
|
30161
30289
|
}
|
|
30162
30290
|
function isErrorResponse(value) {
|
|
30163
|
-
return
|
|
30291
|
+
return isRecord3(value) && typeof value["code"] === "number" && Number.isInteger(value["code"]) && typeof value["message"] === "string";
|
|
30164
30292
|
}
|
|
30165
30293
|
var Handled = {
|
|
30166
30294
|
/**
|
|
@@ -30705,7 +30833,7 @@ var Connection = class {
|
|
|
30705
30833
|
if (this.abortController.signal.aborted) {
|
|
30706
30834
|
return Promise.resolve();
|
|
30707
30835
|
}
|
|
30708
|
-
if (!
|
|
30836
|
+
if (!isRecord3(message)) {
|
|
30709
30837
|
console.error("Invalid message", { message });
|
|
30710
30838
|
return Promise.resolve();
|
|
30711
30839
|
}
|
|
@@ -31108,7 +31236,7 @@ function ndJsonStream(output2, input2) {
|
|
|
31108
31236
|
await writeJson(protocolErrorResponse(RequestError.parseError()));
|
|
31109
31237
|
return;
|
|
31110
31238
|
}
|
|
31111
|
-
if (
|
|
31239
|
+
if (isRecord3(message) || Array.isArray(message)) {
|
|
31112
31240
|
controller.enqueue(message);
|
|
31113
31241
|
} else {
|
|
31114
31242
|
await writeJson(protocolErrorResponse(RequestError.invalidRequest(message)));
|
|
@@ -32095,14 +32223,14 @@ var legacyClientNotificationMethods = /* @__PURE__ */ new Set([
|
|
|
32095
32223
|
import * as NodeStream from "node:stream";
|
|
32096
32224
|
|
|
32097
32225
|
// ../../packages/ycodium-acp-executor/src/jsonrpc.ts
|
|
32098
|
-
function
|
|
32226
|
+
function isRecord4(value) {
|
|
32099
32227
|
return typeof value === "object" && value !== null;
|
|
32100
32228
|
}
|
|
32101
32229
|
function isJsonRpcId2(value) {
|
|
32102
32230
|
return typeof value === "string" || typeof value === "number" && Number.isFinite(value);
|
|
32103
32231
|
}
|
|
32104
32232
|
function isJsonRpcEnvelope2(value) {
|
|
32105
|
-
return
|
|
32233
|
+
return isRecord4(value) && value["jsonrpc"] === "2.0";
|
|
32106
32234
|
}
|
|
32107
32235
|
function isRequestMessage2(value) {
|
|
32108
32236
|
return isJsonRpcEnvelope2(value) && "id" in value && typeof value["method"] === "string" && isJsonRpcId2(value["id"]);
|
|
@@ -32122,7 +32250,7 @@ function isNotificationMessage2(value) {
|
|
|
32122
32250
|
return isJsonRpcEnvelope2(value) && !("id" in value) && typeof value["method"] === "string";
|
|
32123
32251
|
}
|
|
32124
32252
|
function readJsonRpcError(value) {
|
|
32125
|
-
if (!
|
|
32253
|
+
if (!isRecord4(value) || typeof value["code"] !== "number" || typeof value["message"] !== "string") {
|
|
32126
32254
|
return void 0;
|
|
32127
32255
|
}
|
|
32128
32256
|
return {
|
|
@@ -32195,11 +32323,11 @@ var KNOWN_SESSION_UPDATES = /* @__PURE__ */ new Set([
|
|
|
32195
32323
|
"compaction_summary_chunk"
|
|
32196
32324
|
]);
|
|
32197
32325
|
function isSessionUpdateEnvelope(payload) {
|
|
32198
|
-
if (!
|
|
32326
|
+
if (!isRecord4(payload) || typeof payload["sessionId"] !== "string") {
|
|
32199
32327
|
return false;
|
|
32200
32328
|
}
|
|
32201
32329
|
const update = payload["update"];
|
|
32202
|
-
return
|
|
32330
|
+
return isRecord4(update) && typeof update["sessionUpdate"] === "string";
|
|
32203
32331
|
}
|
|
32204
32332
|
function hasKnownVariantShape(update) {
|
|
32205
32333
|
const kind = update["sessionUpdate"];
|
|
@@ -32207,7 +32335,7 @@ function hasKnownVariantShape(update) {
|
|
|
32207
32335
|
return false;
|
|
32208
32336
|
}
|
|
32209
32337
|
if (kind === "user_message_chunk" || kind === "agent_message_chunk" || kind === "agent_thought_chunk") {
|
|
32210
|
-
return
|
|
32338
|
+
return isRecord4(update["content"]);
|
|
32211
32339
|
}
|
|
32212
32340
|
return true;
|
|
32213
32341
|
}
|
|
@@ -32396,6 +32524,10 @@ function createAcpConnection(options) {
|
|
|
32396
32524
|
);
|
|
32397
32525
|
} catch {
|
|
32398
32526
|
}
|
|
32527
|
+
try {
|
|
32528
|
+
waiter.onArrival?.();
|
|
32529
|
+
} catch {
|
|
32530
|
+
}
|
|
32399
32531
|
if (Object.hasOwn(message, "error")) {
|
|
32400
32532
|
const rpcError = readJsonRpcError(message["error"]);
|
|
32401
32533
|
waiter.reject(
|
|
@@ -32526,7 +32658,7 @@ function createAcpConnection(options) {
|
|
|
32526
32658
|
options.readable.on("end", onEnd);
|
|
32527
32659
|
options.readable.on("error", onError);
|
|
32528
32660
|
options.writable.once("error", onWritableError);
|
|
32529
|
-
const begin = (method, params, promptId) => {
|
|
32661
|
+
const begin = (method, params, promptId, onArrival) => {
|
|
32530
32662
|
failIfClosed();
|
|
32531
32663
|
const id = nextRequestId;
|
|
32532
32664
|
nextRequestId += 1;
|
|
@@ -32534,6 +32666,7 @@ function createAcpConnection(options) {
|
|
|
32534
32666
|
pending.set(String(id), {
|
|
32535
32667
|
method,
|
|
32536
32668
|
...promptId === void 0 ? {} : { promptId },
|
|
32669
|
+
...onArrival === void 0 ? {} : { onArrival },
|
|
32537
32670
|
resolve: resolve3,
|
|
32538
32671
|
reject
|
|
32539
32672
|
});
|
|
@@ -32589,10 +32722,31 @@ function createAcpConnection(options) {
|
|
|
32589
32722
|
function normalizeModelId(value) {
|
|
32590
32723
|
return value?.trim() || void 0;
|
|
32591
32724
|
}
|
|
32725
|
+
function adoptReportedConfigOptions(state, configOptions) {
|
|
32726
|
+
const option = state.modelConfigId === void 0 ? void 0 : findConfigOptionEntry(configOptions, state.modelConfigId);
|
|
32727
|
+
const value = option?.["currentValue"];
|
|
32728
|
+
const reported = typeof value === "string" ? normalizeModelId(value) : void 0;
|
|
32729
|
+
if (reported === void 0) return { ...state, configOptions };
|
|
32730
|
+
const { modelUnconfirmed: _confirmed, ...known } = state;
|
|
32731
|
+
return { ...known, configOptions, currentModelId: reported };
|
|
32732
|
+
}
|
|
32733
|
+
function forgetConfigOptionValue(state, configId) {
|
|
32734
|
+
const forgetsModel = configId === void 0 || configId === state.modelConfigId;
|
|
32735
|
+
const configOptions = configId !== void 0 && Array.isArray(state.configOptions) ? state.configOptions.map((option) => {
|
|
32736
|
+
if (!isRecord2(option) || option["id"] !== configId) return option;
|
|
32737
|
+
const { currentValue: _forgotten, ...rest } = option;
|
|
32738
|
+
return rest;
|
|
32739
|
+
}) : state.configOptions;
|
|
32740
|
+
return {
|
|
32741
|
+
...state,
|
|
32742
|
+
configOptions,
|
|
32743
|
+
...forgetsModel ? { currentModelId: void 0, modelUnconfirmed: true } : {}
|
|
32744
|
+
};
|
|
32745
|
+
}
|
|
32592
32746
|
function modelSelectionStateFromSetup(setup) {
|
|
32593
|
-
const sessionModels =
|
|
32747
|
+
const sessionModels = isRecord2(setup.models) ? setup.models : void 0;
|
|
32594
32748
|
const modelConfigId = extractModelConfigId(setup);
|
|
32595
|
-
const strategy =
|
|
32749
|
+
const strategy = modelConfigId !== void 0 ? "config-option" : "session/set_model";
|
|
32596
32750
|
const modelConfigOption = modelConfigId === void 0 ? void 0 : findSessionConfigOption(setup.configOptions, modelConfigId);
|
|
32597
32751
|
const configModel = modelConfigOption?.currentValue;
|
|
32598
32752
|
const currentModelId = strategy === "config-option" ? typeof configModel === "string" ? normalizeModelId(configModel) : void 0 : typeof sessionModels?.["currentModelId"] === "string" ? normalizeModelId(sessionModels["currentModelId"]) : void 0;
|
|
@@ -32602,7 +32756,8 @@ function modelSelectionStateFromSetup(setup) {
|
|
|
32602
32756
|
modelConfigId,
|
|
32603
32757
|
currentModelId,
|
|
32604
32758
|
advertisedModelValues: strategy === "config-option" ? modelConfigOption === void 0 ? [] : collectSessionConfigOptionValues(modelConfigOption) : collectSessionModelIds(sessionModels),
|
|
32605
|
-
configOptions: setup.configOptions
|
|
32759
|
+
configOptions: setup.configOptions,
|
|
32760
|
+
catalogSetup: setup
|
|
32606
32761
|
};
|
|
32607
32762
|
}
|
|
32608
32763
|
|
|
@@ -32700,6 +32855,10 @@ function createExecutorLifecycle({
|
|
|
32700
32855
|
if (targetTurnId !== void 0) {
|
|
32701
32856
|
interruptedTurnIds.add(targetTurnId);
|
|
32702
32857
|
}
|
|
32858
|
+
const optionWrites = shared.optionWriteStop;
|
|
32859
|
+
if (optionWrites !== void 0 && (targetTurnId === void 0 || optionWrites.turnId === targetTurnId)) {
|
|
32860
|
+
optionWrites.stop();
|
|
32861
|
+
}
|
|
32703
32862
|
settleAllApprovals("cancel");
|
|
32704
32863
|
settleAllUserInputs();
|
|
32705
32864
|
abortPendingSettlement("turn cancelled");
|
|
@@ -32912,6 +33071,41 @@ function isAcpRequestPermissionParams(value) {
|
|
|
32912
33071
|
return Array.isArray(record2["options"]);
|
|
32913
33072
|
}
|
|
32914
33073
|
|
|
33074
|
+
// ../../packages/ycodium-acp-executor/src/apply-effort.ts
|
|
33075
|
+
var alignRequestedEffort = async (input2) => {
|
|
33076
|
+
const unchanged = { configOptions: input2.configOptions };
|
|
33077
|
+
const effort = findAcpEffortConfig(input2.configOptions);
|
|
33078
|
+
if (effort === void 0) return unchanged;
|
|
33079
|
+
const values = new Set(effort.choices.map((choice) => choice.value));
|
|
33080
|
+
const current = effort.currentValue;
|
|
33081
|
+
const requested = input2.requestedEffort?.trim() || void 0;
|
|
33082
|
+
const unsupportedEffort = requested !== void 0 && !values.has(requested) ? requested : void 0;
|
|
33083
|
+
const staleCurrent = current !== void 0 && !values.has(current);
|
|
33084
|
+
const fallback = input2.modelDefaultEffort !== void 0 && values.has(input2.modelDefaultEffort) ? input2.modelDefaultEffort : void 0;
|
|
33085
|
+
const target = requested !== void 0 && unsupportedEffort === void 0 ? requested : unsupportedEffort !== void 0 || staleCurrent ? fallback : void 0;
|
|
33086
|
+
const written = target === void 0 || target === current ? void 0 : await input2.write(effort.configId, target);
|
|
33087
|
+
const configOptions = written === void 0 ? input2.configOptions : written.configOptions;
|
|
33088
|
+
if (unsupportedEffort === void 0) return { configOptions };
|
|
33089
|
+
const confirmed = fallback !== void 0 && written?.reported === true && findAcpEffortConfig(written.configOptions)?.currentValue === fallback;
|
|
33090
|
+
return { configOptions, unsupportedEffort, ...confirmed ? { appliedEffort: fallback } : {} };
|
|
33091
|
+
};
|
|
33092
|
+
|
|
33093
|
+
// ../../packages/ycodium-acp-executor/src/reasoning-level-fallback.ts
|
|
33094
|
+
var REASONING_LEVEL_FALLBACK_CODE = "reasoning-level-fallback";
|
|
33095
|
+
function reasoningLevelFallbackWarning(input2) {
|
|
33096
|
+
const model = input2.model ?? "This model";
|
|
33097
|
+
const outcome = input2.appliedEffort === void 0 ? "so the agent picks this turn's level" : `so this turn uses its default, "${input2.appliedEffort}"`;
|
|
33098
|
+
return {
|
|
33099
|
+
message: `${model} does not offer the "${input2.requestedEffort}" reasoning effort, ${outcome}. Your saved choice is unchanged.`,
|
|
33100
|
+
detail: {
|
|
33101
|
+
code: REASONING_LEVEL_FALLBACK_CODE,
|
|
33102
|
+
...input2.model === void 0 ? {} : { model: input2.model },
|
|
33103
|
+
requestedEffort: input2.requestedEffort,
|
|
33104
|
+
...input2.appliedEffort === void 0 ? {} : { appliedEffort: input2.appliedEffort }
|
|
33105
|
+
}
|
|
33106
|
+
};
|
|
33107
|
+
}
|
|
33108
|
+
|
|
32915
33109
|
// ../../packages/ycodium-acp-executor/src/failureCategory.ts
|
|
32916
33110
|
var ACP_FAILURE_CATEGORIES = [
|
|
32917
33111
|
"quota",
|
|
@@ -33252,6 +33446,8 @@ function createExecutorPrompt({
|
|
|
33252
33446
|
threadMutex,
|
|
33253
33447
|
promptMutex,
|
|
33254
33448
|
applyRequestedModel,
|
|
33449
|
+
modelDefaultEffort,
|
|
33450
|
+
writeConfigOptionReported,
|
|
33255
33451
|
notifyPromptSettled,
|
|
33256
33452
|
shared,
|
|
33257
33453
|
promptResults,
|
|
@@ -33345,6 +33541,57 @@ function createExecutorPrompt({
|
|
|
33345
33541
|
}
|
|
33346
33542
|
}
|
|
33347
33543
|
};
|
|
33544
|
+
const alignTurnOptions = async (input2, sessionId, generation, isStale, signal) => {
|
|
33545
|
+
const applied = await applyRequestedModel({
|
|
33546
|
+
state: shared.modelSelectionState,
|
|
33547
|
+
acpSessionId: sessionId,
|
|
33548
|
+
requestedModelId: input2.requestedModelId,
|
|
33549
|
+
expectedGeneration: generation,
|
|
33550
|
+
signal
|
|
33551
|
+
});
|
|
33552
|
+
shared.modelSelectionState = applied;
|
|
33553
|
+
if (isStale()) return;
|
|
33554
|
+
const switched = applied.configOptions;
|
|
33555
|
+
let aligned;
|
|
33556
|
+
try {
|
|
33557
|
+
aligned = await alignRequestedEffort({
|
|
33558
|
+
configOptions: switched,
|
|
33559
|
+
write: (configId, value) => writeConfigOptionReported(sessionId, switched, configId, value, {
|
|
33560
|
+
option: "reasoning level",
|
|
33561
|
+
signal
|
|
33562
|
+
}),
|
|
33563
|
+
requestedEffort: input2.requestedEffort,
|
|
33564
|
+
modelDefaultEffort: modelDefaultEffort(applied)
|
|
33565
|
+
});
|
|
33566
|
+
} catch (error62) {
|
|
33567
|
+
throw error62 instanceof RequestError ? new AcpExecutorOptionRejectedError(
|
|
33568
|
+
"reasoning level",
|
|
33569
|
+
input2.requestedEffort?.trim(),
|
|
33570
|
+
error62
|
|
33571
|
+
) : error62;
|
|
33572
|
+
}
|
|
33573
|
+
if (!isLive(generation)) throw new AcpExecutorDisposedError();
|
|
33574
|
+
if (aligned.configOptions !== switched) {
|
|
33575
|
+
shared.modelSelectionState = adoptReportedConfigOptions(
|
|
33576
|
+
shared.modelSelectionState,
|
|
33577
|
+
aligned.configOptions
|
|
33578
|
+
);
|
|
33579
|
+
}
|
|
33580
|
+
if (aligned.unsupportedEffort !== void 0) {
|
|
33581
|
+
emit({
|
|
33582
|
+
type: "runtime.warning",
|
|
33583
|
+
...stamp(),
|
|
33584
|
+
provider: options.provider,
|
|
33585
|
+
threadId: options.threadId,
|
|
33586
|
+
...shared.activeTurnId === void 0 ? {} : { turnId: shared.activeTurnId },
|
|
33587
|
+
payload: reasoningLevelFallbackWarning({
|
|
33588
|
+
model: applied.currentModelId,
|
|
33589
|
+
requestedEffort: aligned.unsupportedEffort,
|
|
33590
|
+
appliedEffort: aligned.appliedEffort
|
|
33591
|
+
})
|
|
33592
|
+
});
|
|
33593
|
+
}
|
|
33594
|
+
};
|
|
33348
33595
|
const failIfPromptUnavailable = () => {
|
|
33349
33596
|
failIfDisposed();
|
|
33350
33597
|
if (shared.connectionClosed) throw new AcpExecutorDisposedError();
|
|
@@ -33352,7 +33599,7 @@ function createExecutorPrompt({
|
|
|
33352
33599
|
const prompt = async (input2) => {
|
|
33353
33600
|
failIfPromptUnavailable();
|
|
33354
33601
|
const started = requireStarted();
|
|
33355
|
-
|
|
33602
|
+
const sessionId = started.sessionId;
|
|
33356
33603
|
let record2;
|
|
33357
33604
|
const settle2 = (rest) => settleTurn({
|
|
33358
33605
|
expectedGeneration: started.generation,
|
|
@@ -33439,32 +33686,34 @@ function createExecutorPrompt({
|
|
|
33439
33686
|
failIfDisposed();
|
|
33440
33687
|
const queuedTurnId = turnId;
|
|
33441
33688
|
const isStale = () => interruptedTurnIds.has(queuedTurnId) || input2.expectedActiveTurnId !== void 0 && shared.activeTurnId !== queuedTurnId;
|
|
33442
|
-
if (!isStale()) {
|
|
33689
|
+
if (!isStale() && input2.expectedActiveTurnId === void 0) {
|
|
33690
|
+
const optionWrites = new AbortController();
|
|
33691
|
+
shared.optionWriteStop = { turnId, stop: () => optionWrites.abort() };
|
|
33443
33692
|
try {
|
|
33444
|
-
|
|
33445
|
-
|
|
33446
|
-
|
|
33447
|
-
|
|
33448
|
-
|
|
33449
|
-
|
|
33450
|
-
|
|
33451
|
-
shared.modelSelectionState = applied.state;
|
|
33452
|
-
sessionId = applied.sessionId;
|
|
33453
|
-
record2.sessionId = applied.sessionId;
|
|
33693
|
+
await alignTurnOptions(
|
|
33694
|
+
input2,
|
|
33695
|
+
sessionId,
|
|
33696
|
+
started.generation,
|
|
33697
|
+
isStale,
|
|
33698
|
+
optionWrites.signal
|
|
33699
|
+
);
|
|
33454
33700
|
} catch (error62) {
|
|
33455
|
-
|
|
33456
|
-
if (
|
|
33457
|
-
|
|
33458
|
-
|
|
33459
|
-
turnId,
|
|
33460
|
-
stopReason: "error",
|
|
33461
|
-
state: "failed",
|
|
33462
|
-
errorMessage,
|
|
33463
|
-
failureCategory
|
|
33464
|
-
});
|
|
33465
|
-
throw error62 instanceof Error ? withFailureCategory(error62, failureCategory) : error62;
|
|
33701
|
+
if (error62 instanceof AcpExecutorDisposedError) throw error62;
|
|
33702
|
+
if (isStale()) {
|
|
33703
|
+
settle2({ turnId, stopReason: "cancelled", state: "cancelled" });
|
|
33704
|
+
return { threadId: options.threadId, turnId, stopReason: "cancelled" };
|
|
33466
33705
|
}
|
|
33467
|
-
|
|
33706
|
+
const failureCategory = readAcpFailureCategory(error62);
|
|
33707
|
+
settle2({
|
|
33708
|
+
turnId,
|
|
33709
|
+
stopReason: "error",
|
|
33710
|
+
state: "failed",
|
|
33711
|
+
errorMessage: error62 instanceof Error && error62.message.trim() || "Switching the model or reasoning level failed. This turn was not sent.",
|
|
33712
|
+
...failureCategory === void 0 ? {} : { failureCategory }
|
|
33713
|
+
});
|
|
33714
|
+
throw error62 instanceof Error ? withFailureCategory(error62, failureCategory) : error62;
|
|
33715
|
+
} finally {
|
|
33716
|
+
shared.optionWriteStop = void 0;
|
|
33468
33717
|
}
|
|
33469
33718
|
}
|
|
33470
33719
|
failIfDisposed();
|
|
@@ -33847,7 +34096,7 @@ function createExecutorRequests({
|
|
|
33847
34096
|
pendingUserInputs.delete(requestId);
|
|
33848
34097
|
pending.resolve({
|
|
33849
34098
|
kind: "answered",
|
|
33850
|
-
answers:
|
|
34099
|
+
answers: isRecord2(answers) ? answers : {}
|
|
33851
34100
|
});
|
|
33852
34101
|
};
|
|
33853
34102
|
return {
|
|
@@ -34022,107 +34271,6 @@ function createExecutorRuntime({
|
|
|
34022
34271
|
};
|
|
34023
34272
|
}
|
|
34024
34273
|
|
|
34025
|
-
// ../../packages/ycodium-acp-executor/src/config-options.ts
|
|
34026
|
-
function isRecord4(value) {
|
|
34027
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34028
|
-
}
|
|
34029
|
-
function asString(value) {
|
|
34030
|
-
return typeof value === "string" ? value : void 0;
|
|
34031
|
-
}
|
|
34032
|
-
function normalizedField(option, key) {
|
|
34033
|
-
return asString(option[key])?.trim().toLowerCase() ?? "";
|
|
34034
|
-
}
|
|
34035
|
-
function looksLikeEffortOption(option) {
|
|
34036
|
-
const id = normalizedField(option, "id");
|
|
34037
|
-
const name = normalizedField(option, "name");
|
|
34038
|
-
return id === "effort" || id === "reasoning" || name === "effort" || name === "reasoning" || name.includes("effort") || name.includes("reasoning") || normalizedField(option, "category") === "thought_level";
|
|
34039
|
-
}
|
|
34040
|
-
function flattenChoices(rawOptions, currentValue) {
|
|
34041
|
-
if (!Array.isArray(rawOptions)) return [];
|
|
34042
|
-
const out = [];
|
|
34043
|
-
const seen = /* @__PURE__ */ new Set();
|
|
34044
|
-
const push = (entry) => {
|
|
34045
|
-
if (!isRecord4(entry)) return;
|
|
34046
|
-
const value = asString(entry["value"]);
|
|
34047
|
-
if (value === void 0 || seen.has(value)) return;
|
|
34048
|
-
seen.add(value);
|
|
34049
|
-
const description = asString(entry["description"])?.trim();
|
|
34050
|
-
const name = asString(entry["name"])?.trim();
|
|
34051
|
-
out.push({
|
|
34052
|
-
value,
|
|
34053
|
-
...name ? { name } : {},
|
|
34054
|
-
label: name || value,
|
|
34055
|
-
...description ? { description } : {},
|
|
34056
|
-
...currentValue !== void 0 && currentValue === value ? { isDefault: true } : {}
|
|
34057
|
-
});
|
|
34058
|
-
};
|
|
34059
|
-
for (const entry of rawOptions) {
|
|
34060
|
-
if (isRecord4(entry) && Array.isArray(entry["options"])) {
|
|
34061
|
-
for (const nested of entry["options"]) push(nested);
|
|
34062
|
-
continue;
|
|
34063
|
-
}
|
|
34064
|
-
push(entry);
|
|
34065
|
-
}
|
|
34066
|
-
return out;
|
|
34067
|
-
}
|
|
34068
|
-
function findAcpEffortConfig(configOptions) {
|
|
34069
|
-
if (!Array.isArray(configOptions)) return void 0;
|
|
34070
|
-
const candidates = configOptions.filter(isRecord4).filter((option) => normalizedField(option, "type") === "select").filter(looksLikeEffortOption);
|
|
34071
|
-
if (candidates.length === 0) return void 0;
|
|
34072
|
-
const picked = candidates.find((option) => normalizedField(option, "category") === "model_option") ?? candidates.find((option) => normalizedField(option, "id") === "effort") ?? candidates.find((option) => normalizedField(option, "category") === "thought_level") ?? candidates[0];
|
|
34073
|
-
if (picked === void 0) return void 0;
|
|
34074
|
-
const configId = asString(picked["id"])?.trim();
|
|
34075
|
-
if (!configId) return void 0;
|
|
34076
|
-
const choices = flattenChoices(picked["options"], asString(picked["currentValue"])?.trim());
|
|
34077
|
-
if (choices.length === 0) return void 0;
|
|
34078
|
-
return {
|
|
34079
|
-
configId,
|
|
34080
|
-
label: asString(picked["name"])?.trim() ?? "",
|
|
34081
|
-
choices
|
|
34082
|
-
};
|
|
34083
|
-
}
|
|
34084
|
-
function acpModelChoicesFromConfigOptions(configOptions) {
|
|
34085
|
-
if (!Array.isArray(configOptions)) return void 0;
|
|
34086
|
-
const records = configOptions.filter(isRecord4);
|
|
34087
|
-
const modelOption = records.find((option) => normalizedField(option, "category") === "model") ?? records.find(
|
|
34088
|
-
(option) => normalizedField(option, "id") === "model" && normalizedField(option, "type") === "select"
|
|
34089
|
-
);
|
|
34090
|
-
if (modelOption === void 0) return void 0;
|
|
34091
|
-
if (!asString(modelOption["id"])?.trim()) return void 0;
|
|
34092
|
-
return flattenChoices(modelOption["options"], asString(modelOption["currentValue"])?.trim());
|
|
34093
|
-
}
|
|
34094
|
-
|
|
34095
|
-
// ../../packages/ycodium-acp-executor/src/apply-effort.ts
|
|
34096
|
-
var applyRequestedEffort = async (input2) => {
|
|
34097
|
-
const requested = input2.requestedEffort?.trim();
|
|
34098
|
-
if (!requested) return;
|
|
34099
|
-
const effort = findAcpEffortConfig(input2.configOptions);
|
|
34100
|
-
if (effort === void 0) return;
|
|
34101
|
-
const matched = effort.choices.find((choice) => choice.value === requested);
|
|
34102
|
-
if (matched === void 0) {
|
|
34103
|
-
input2.log?.info("requested effort is not in the agent catalog; keeping its own", {
|
|
34104
|
-
requestedEffort: requested,
|
|
34105
|
-
advertised: effort.choices.map((choice) => choice.value)
|
|
34106
|
-
});
|
|
34107
|
-
return;
|
|
34108
|
-
}
|
|
34109
|
-
if (matched.isDefault === true) return;
|
|
34110
|
-
if (!input2.isLive(input2.expectedGeneration)) return;
|
|
34111
|
-
try {
|
|
34112
|
-
await input2.connection.request("session/set_config_option", {
|
|
34113
|
-
sessionId: input2.acpSessionId,
|
|
34114
|
-
configId: effort.configId,
|
|
34115
|
-
value: requested
|
|
34116
|
-
});
|
|
34117
|
-
} catch (error62) {
|
|
34118
|
-
input2.log?.info("setting the effort level failed; the session keeps its own", {
|
|
34119
|
-
requestedEffort: requested,
|
|
34120
|
-
configId: effort.configId,
|
|
34121
|
-
error: error62 instanceof Error ? error62.message : String(error62)
|
|
34122
|
-
});
|
|
34123
|
-
}
|
|
34124
|
-
};
|
|
34125
|
-
|
|
34126
34274
|
// ../../packages/ycodium-acp-executor/src/config-option-wiring.ts
|
|
34127
34275
|
var VENDOR_CATEGORY_PREFIX = "_";
|
|
34128
34276
|
var ACP_CONFIG_CATEGORY_HANDLING = {
|
|
@@ -34136,7 +34284,7 @@ var ACP_CONFIG_CATEGORY_HANDLING = {
|
|
|
34136
34284
|
},
|
|
34137
34285
|
thought_level: {
|
|
34138
34286
|
consumed: true,
|
|
34139
|
-
via: "config-options.ts:findAcpEffortConfig \u2192 apply-effort.ts:
|
|
34287
|
+
via: "config-options.ts:findAcpEffortConfig \u2192 apply-effort.ts:alignRequestedEffort"
|
|
34140
34288
|
},
|
|
34141
34289
|
model_option: {
|
|
34142
34290
|
consumed: true,
|
|
@@ -34205,13 +34353,14 @@ function judgeRequestedModel(input2) {
|
|
|
34205
34353
|
if (requested === void 0 || requested === current) return { kind: "keep" };
|
|
34206
34354
|
const hasCatalog = input2.state.advertisedModelValues.length > 0;
|
|
34207
34355
|
const hasCurrent = current !== void 0;
|
|
34208
|
-
if (!hasCatalog && !hasCurrent) return { kind: "keep" };
|
|
34209
|
-
const canSwitch = input2.state
|
|
34356
|
+
if (!hasCatalog && !hasCurrent && input2.state.modelUnconfirmed !== true) return { kind: "keep" };
|
|
34357
|
+
const canSwitch = canSwitchModel(input2.state);
|
|
34210
34358
|
const value = hasCatalog ? matchAdvertisedModelValue(requested, input2.state.advertisedModelValues) : void 0;
|
|
34211
34359
|
if (value !== void 0 && value === current) return { kind: "keep" };
|
|
34212
34360
|
if (value !== void 0 && canSwitch) return { kind: "switch", value };
|
|
34213
|
-
return
|
|
34361
|
+
return { kind: "refresh" };
|
|
34214
34362
|
}
|
|
34363
|
+
var canSwitchModel = (state) => state.strategy === "session/set_model" && state.sessionModelsAdvertised || state.strategy === "config-option" && state.modelConfigId !== void 0;
|
|
34215
34364
|
function modelUnavailableError(requestedModelId, currentModelId) {
|
|
34216
34365
|
const current = currentModelId ?? "its own model";
|
|
34217
34366
|
return withFailureCategory(
|
|
@@ -34268,6 +34417,7 @@ function acpModeConfigId(setup) {
|
|
|
34268
34417
|
// ../../packages/ycodium-acp-executor/src/executor/session.ts
|
|
34269
34418
|
function createExecutorSession({
|
|
34270
34419
|
options,
|
|
34420
|
+
hooks,
|
|
34271
34421
|
connection,
|
|
34272
34422
|
isLive,
|
|
34273
34423
|
emit,
|
|
@@ -34289,131 +34439,140 @@ function createExecutorSession({
|
|
|
34289
34439
|
shared.sessionOpensInFlight -= 1;
|
|
34290
34440
|
}
|
|
34291
34441
|
};
|
|
34292
|
-
const
|
|
34293
|
-
|
|
34294
|
-
|
|
34295
|
-
|
|
34442
|
+
const optionDeadlineMs = () => options.modelCatalogRefreshTimeoutMs ?? MODEL_CATALOG_REFRESH_TIMEOUT_MS;
|
|
34443
|
+
const within = async (work, signal, onTimeout) => {
|
|
34444
|
+
void work.catch(() => void 0);
|
|
34445
|
+
let timer;
|
|
34446
|
+
let onStop;
|
|
34447
|
+
const bound = new Promise((_resolve, reject) => {
|
|
34448
|
+
timer = setTimeout(() => reject(onTimeout()), optionDeadlineMs());
|
|
34449
|
+
onStop = () => reject(new AcpOptionWriteStoppedError());
|
|
34450
|
+
if (signal?.aborted === true) onStop();
|
|
34451
|
+
else signal?.addEventListener("abort", onStop, { once: true });
|
|
34452
|
+
});
|
|
34453
|
+
try {
|
|
34454
|
+
return await Promise.race([work, bound]);
|
|
34455
|
+
} finally {
|
|
34456
|
+
clearTimeout(timer);
|
|
34457
|
+
if (onStop !== void 0) signal?.removeEventListener("abort", onStop);
|
|
34296
34458
|
}
|
|
34297
|
-
|
|
34298
|
-
|
|
34299
|
-
|
|
34459
|
+
};
|
|
34460
|
+
const awaitOptionReply = async (pending, configId, write) => {
|
|
34461
|
+
void pending.response.catch(() => void 0);
|
|
34462
|
+
try {
|
|
34463
|
+
return await within(
|
|
34464
|
+
pending.written.then(() => pending.response),
|
|
34465
|
+
write.signal,
|
|
34466
|
+
() => new AcpExecutorOptionTimeoutError(write.option, write.value)
|
|
34467
|
+
);
|
|
34468
|
+
} catch (error62) {
|
|
34469
|
+
if (error62 instanceof AcpExecutorOptionTimeoutError || error62 instanceof AcpOptionWriteStoppedError) {
|
|
34470
|
+
shared.modelSelectionState = forgetConfigOptionValue(shared.modelSelectionState, configId);
|
|
34471
|
+
}
|
|
34472
|
+
throw error62;
|
|
34473
|
+
}
|
|
34474
|
+
};
|
|
34475
|
+
const writeConfigOptionReported = async (sessionId, configOptions, configId, value, write) => {
|
|
34476
|
+
const issuedAt = shared.configUpdateSeq;
|
|
34477
|
+
let arrivedAt = Number.POSITIVE_INFINITY;
|
|
34478
|
+
const pending = connection.begin(
|
|
34479
|
+
"session/set_config_option",
|
|
34480
|
+
{ sessionId, configId, value },
|
|
34481
|
+
void 0,
|
|
34482
|
+
() => {
|
|
34483
|
+
arrivedAt = shared.configUpdateSeq;
|
|
34484
|
+
}
|
|
34300
34485
|
);
|
|
34301
|
-
const
|
|
34302
|
-
|
|
34303
|
-
|
|
34304
|
-
|
|
34305
|
-
|
|
34306
|
-
});
|
|
34307
|
-
if (!isLive(expectedGeneration)) {
|
|
34308
|
-
throw new AcpExecutorDisposedError();
|
|
34486
|
+
const reply = await awaitOptionReply(pending, configId, { ...write, value });
|
|
34487
|
+
await connection.awaitInboundIdle();
|
|
34488
|
+
const ours = shared.configOptionUpdates.get(sessionId);
|
|
34489
|
+
if (ours !== void 0 && ours.seq > arrivedAt) {
|
|
34490
|
+
return { configOptions: ours.configOptions, reported: true };
|
|
34309
34491
|
}
|
|
34310
|
-
if (
|
|
34311
|
-
|
|
34492
|
+
if (reply?.configOptions !== void 0) {
|
|
34493
|
+
return { configOptions: reply.configOptions, reported: true };
|
|
34312
34494
|
}
|
|
34313
|
-
|
|
34495
|
+
const base = ours !== void 0 && ours.seq > issuedAt ? ours.configOptions : configOptions;
|
|
34496
|
+
return { configOptions: withConfigOptionValue(base, configId, value), reported: false };
|
|
34314
34497
|
};
|
|
34498
|
+
const writeConfigOption = async (...args) => (await writeConfigOptionReported(...args)).configOptions;
|
|
34315
34499
|
const switchModel = async (input2) => {
|
|
34316
34500
|
let configOptions = input2.state.configOptions;
|
|
34317
|
-
|
|
34318
|
-
|
|
34319
|
-
|
|
34320
|
-
|
|
34501
|
+
const write = { option: "model", signal: input2.signal };
|
|
34502
|
+
if (input2.state.strategy === "config-option" && input2.state.modelConfigId !== void 0) {
|
|
34503
|
+
configOptions = await writeConfigOption(
|
|
34504
|
+
input2.sessionId,
|
|
34505
|
+
configOptions,
|
|
34506
|
+
input2.state.modelConfigId,
|
|
34507
|
+
input2.value,
|
|
34508
|
+
write
|
|
34321
34509
|
);
|
|
34322
|
-
configOptions = switched?.configOptions ?? configOptions;
|
|
34323
34510
|
} else {
|
|
34324
|
-
|
|
34511
|
+
const before = shared.configOptionUpdates.get(input2.sessionId);
|
|
34512
|
+
const pending = connection.begin("session/set_model", {
|
|
34325
34513
|
sessionId: input2.sessionId,
|
|
34326
34514
|
modelId: input2.value
|
|
34327
34515
|
});
|
|
34516
|
+
await awaitOptionReply(pending, void 0, { ...write, value: input2.value });
|
|
34517
|
+
await connection.awaitInboundIdle();
|
|
34518
|
+
const reported = shared.configOptionUpdates.get(input2.sessionId);
|
|
34519
|
+
if (reported !== void 0 && reported !== before) {
|
|
34520
|
+
configOptions = reported.configOptions;
|
|
34521
|
+
}
|
|
34328
34522
|
}
|
|
34329
34523
|
if (!isLive(input2.expectedGeneration)) {
|
|
34330
34524
|
throw new AcpExecutorDisposedError();
|
|
34331
34525
|
}
|
|
34332
|
-
|
|
34333
|
-
|
|
34334
|
-
const adoptReopenedSession = (applied) => {
|
|
34335
|
-
if (shared.sessionId === void 0 && shared.startResult === void 0) return;
|
|
34336
|
-
const setup = applied.setup;
|
|
34337
|
-
shared.sessionId = applied.sessionId;
|
|
34338
|
-
shared.modelSelectionState = applied.state;
|
|
34339
|
-
shared.modeState = parseSessionModeState(setup);
|
|
34340
|
-
if (shared.startResult !== void 0) {
|
|
34341
|
-
shared.startResult = {
|
|
34342
|
-
...shared.startResult,
|
|
34343
|
-
sessionId: applied.sessionId,
|
|
34344
|
-
sessionSetupResult: setup,
|
|
34345
|
-
modelConfigId: extractModelConfigId(setup),
|
|
34346
|
-
modelId: applied.state.currentModelId
|
|
34347
|
-
};
|
|
34348
|
-
}
|
|
34526
|
+
const { modelUnconfirmed: _confirmed, ...known } = input2.state;
|
|
34527
|
+
return adoptReportedConfigOptions({ ...known, currentModelId: input2.value }, configOptions);
|
|
34349
34528
|
};
|
|
34350
34529
|
const applyRequestedModel = async (input2) => {
|
|
34351
|
-
|
|
34352
|
-
|
|
34530
|
+
const requestedModelId = normalizeModelId(input2.requestedModelId) ?? "";
|
|
34531
|
+
const switchTo = (value) => switchModel({
|
|
34532
|
+
state: input2.state,
|
|
34533
|
+
sessionId: input2.acpSessionId,
|
|
34534
|
+
value,
|
|
34535
|
+
expectedGeneration: input2.expectedGeneration,
|
|
34536
|
+
signal: input2.signal
|
|
34537
|
+
});
|
|
34538
|
+
try {
|
|
34353
34539
|
const judgment = judgeRequestedModel({
|
|
34354
|
-
state,
|
|
34355
|
-
requestedModelId: input2.requestedModelId
|
|
34356
|
-
refreshed
|
|
34540
|
+
state: input2.state,
|
|
34541
|
+
requestedModelId: input2.requestedModelId
|
|
34357
34542
|
});
|
|
34358
|
-
if (judgment.kind === "keep") return
|
|
34359
|
-
if (judgment.kind === "
|
|
34360
|
-
|
|
34361
|
-
|
|
34362
|
-
if (
|
|
34363
|
-
|
|
34364
|
-
|
|
34365
|
-
|
|
34366
|
-
|
|
34367
|
-
|
|
34368
|
-
|
|
34369
|
-
|
|
34370
|
-
|
|
34371
|
-
|
|
34372
|
-
|
|
34373
|
-
|
|
34374
|
-
|
|
34375
|
-
}
|
|
34376
|
-
|
|
34377
|
-
|
|
34378
|
-
|
|
34379
|
-
|
|
34380
|
-
|
|
34381
|
-
|
|
34382
|
-
|
|
34383
|
-
if (timedOut) throw timeoutError;
|
|
34384
|
-
const reopened = await openFreshSession(input2.expectedGeneration);
|
|
34385
|
-
if (timedOut) throw timeoutError;
|
|
34386
|
-
const next = modelSelectionStateFromSetup(reopened.setup);
|
|
34387
|
-
const applied = await applyOnce(next, reopened.sessionId, reopened.setup, true);
|
|
34388
|
-
if (timedOut) throw timeoutError;
|
|
34389
|
-
adoptReopenedSession(applied);
|
|
34390
|
-
return applied;
|
|
34391
|
-
})();
|
|
34392
|
-
void work.then(
|
|
34393
|
-
() => void 0,
|
|
34394
|
-
() => void 0
|
|
34543
|
+
if (judgment.kind === "keep") return input2.state;
|
|
34544
|
+
if (judgment.kind === "switch") return await switchTo(judgment.value);
|
|
34545
|
+
await refreshCatalog(requestedModelId, input2.signal);
|
|
34546
|
+
if (!isLive(input2.expectedGeneration)) throw new AcpExecutorDisposedError();
|
|
34547
|
+
if (!canSwitchModel(input2.state)) {
|
|
34548
|
+
throw modelUnavailableError(requestedModelId, input2.state.currentModelId);
|
|
34549
|
+
}
|
|
34550
|
+
const switched = await switchTo(requestedModelId);
|
|
34551
|
+
return switched.advertisedModelValues.includes(requestedModelId) ? switched : {
|
|
34552
|
+
...switched,
|
|
34553
|
+
advertisedModelValues: [...switched.advertisedModelValues, requestedModelId]
|
|
34554
|
+
};
|
|
34555
|
+
} catch (error62) {
|
|
34556
|
+
throw error62 instanceof RequestError ? withFailureCategory(
|
|
34557
|
+
new AcpExecutorOptionRejectedError("model", requestedModelId, error62),
|
|
34558
|
+
"model-unavailable"
|
|
34559
|
+
) : error62;
|
|
34560
|
+
}
|
|
34561
|
+
};
|
|
34562
|
+
const refreshCatalog = async (requestedModelId, signal) => {
|
|
34563
|
+
try {
|
|
34564
|
+
await within(
|
|
34565
|
+
Promise.resolve(options.refreshCatalogForSend?.()),
|
|
34566
|
+
signal,
|
|
34567
|
+
() => new ModelCatalogRefreshTimeoutError()
|
|
34395
34568
|
);
|
|
34396
|
-
|
|
34397
|
-
|
|
34398
|
-
|
|
34399
|
-
|
|
34400
|
-
reject(timeoutError);
|
|
34401
|
-
}, timeoutMs);
|
|
34402
|
-
});
|
|
34403
|
-
try {
|
|
34404
|
-
return await Promise.race([work, deadline]);
|
|
34405
|
-
} catch (error62) {
|
|
34406
|
-
if (error62 instanceof AcpExecutorDisposedError) throw error62;
|
|
34407
|
-
if (timedOut || error62 instanceof ModelCatalogRefreshTimeoutError) {
|
|
34408
|
-
throw modelRefreshTimedOutError(requestedModelId);
|
|
34409
|
-
}
|
|
34410
|
-
if (readAcpFailureCategory(error62) === "model-unavailable") throw error62;
|
|
34411
|
-
throw modelRefreshFailedError(requestedModelId, error62);
|
|
34412
|
-
} finally {
|
|
34413
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
34569
|
+
} catch (error62) {
|
|
34570
|
+
if (error62 instanceof AcpOptionWriteStoppedError) throw error62;
|
|
34571
|
+
if (error62 instanceof ModelCatalogRefreshTimeoutError) {
|
|
34572
|
+
throw modelRefreshTimedOutError(requestedModelId);
|
|
34414
34573
|
}
|
|
34574
|
+
throw modelRefreshFailedError(requestedModelId, error62);
|
|
34415
34575
|
}
|
|
34416
|
-
return applyOnce(input2.state, input2.acpSessionId, input2.setup, false);
|
|
34417
34576
|
};
|
|
34418
34577
|
const startOnce = async (expectedGeneration) => {
|
|
34419
34578
|
const initializePayload = acpInitializePayload(
|
|
@@ -34488,26 +34647,45 @@ function createExecutorSession({
|
|
|
34488
34647
|
categories: unhandledCategories
|
|
34489
34648
|
});
|
|
34490
34649
|
}
|
|
34491
|
-
|
|
34492
|
-
|
|
34493
|
-
state: modelSelectionStateFromSetup(openedSetup),
|
|
34650
|
+
let nextModelSelectionState = await applyRequestedModel({
|
|
34651
|
+
state: modelSelectionStateFromSetup(setup),
|
|
34494
34652
|
acpSessionId: nextSessionId,
|
|
34495
|
-
setup: openedSetup,
|
|
34496
34653
|
requestedModelId: options.requestedModelId,
|
|
34497
34654
|
expectedGeneration
|
|
34498
34655
|
});
|
|
34499
|
-
|
|
34500
|
-
|
|
34501
|
-
|
|
34502
|
-
|
|
34503
|
-
|
|
34504
|
-
|
|
34505
|
-
|
|
34506
|
-
|
|
34507
|
-
|
|
34508
|
-
|
|
34509
|
-
|
|
34510
|
-
|
|
34656
|
+
if (!isLive(expectedGeneration)) {
|
|
34657
|
+
throw new AcpExecutorDisposedError();
|
|
34658
|
+
}
|
|
34659
|
+
try {
|
|
34660
|
+
const opened = nextModelSelectionState.configOptions;
|
|
34661
|
+
const aligned = await alignRequestedEffort({
|
|
34662
|
+
configOptions: opened,
|
|
34663
|
+
write: (configId, value) => writeConfigOptionReported(nextSessionId, opened, configId, value, {
|
|
34664
|
+
option: "reasoning level"
|
|
34665
|
+
}),
|
|
34666
|
+
requestedEffort: options.requestedEffort,
|
|
34667
|
+
modelDefaultEffort: modelDefaultEffort(nextModelSelectionState)
|
|
34668
|
+
});
|
|
34669
|
+
nextModelSelectionState = adoptReportedConfigOptions(
|
|
34670
|
+
nextModelSelectionState,
|
|
34671
|
+
aligned.configOptions
|
|
34672
|
+
);
|
|
34673
|
+
if (aligned.unsupportedEffort !== void 0) {
|
|
34674
|
+
options.log?.info("requested effort is not offered by this model; using its default", {
|
|
34675
|
+
requestedEffort: aligned.unsupportedEffort,
|
|
34676
|
+
modelId: nextModelSelectionState.currentModelId
|
|
34677
|
+
});
|
|
34678
|
+
}
|
|
34679
|
+
} catch (error62) {
|
|
34680
|
+
const effortConfigId = findAcpEffortConfig(nextModelSelectionState.configOptions)?.configId;
|
|
34681
|
+
if (error62 instanceof AcpExecutorOptionTimeoutError && effortConfigId !== void 0) {
|
|
34682
|
+
nextModelSelectionState = forgetConfigOptionValue(nextModelSelectionState, effortConfigId);
|
|
34683
|
+
}
|
|
34684
|
+
options.log?.info("setting the effort level failed; the session keeps its own", {
|
|
34685
|
+
requestedEffort: options.requestedEffort,
|
|
34686
|
+
error: error62 instanceof Error ? error62.message : String(error62)
|
|
34687
|
+
});
|
|
34688
|
+
}
|
|
34511
34689
|
if (options.beforeApplyResult) {
|
|
34512
34690
|
await options.beforeApplyResult();
|
|
34513
34691
|
}
|
|
@@ -34567,6 +34745,7 @@ function createExecutorSession({
|
|
|
34567
34745
|
);
|
|
34568
34746
|
return shared.startInFlight;
|
|
34569
34747
|
};
|
|
34748
|
+
const modelDefaultEffort = (state) => state.currentModelId === void 0 ? void 0 : hooks.modelDefaultEffort?.({ setup: state.catalogSetup, modelId: state.currentModelId });
|
|
34570
34749
|
const requireStarted = () => {
|
|
34571
34750
|
failIfDisposed();
|
|
34572
34751
|
if (!shared.sessionId || !shared.startResult) {
|
|
@@ -34594,7 +34773,14 @@ function createExecutorSession({
|
|
|
34594
34773
|
modeId
|
|
34595
34774
|
});
|
|
34596
34775
|
};
|
|
34597
|
-
return {
|
|
34776
|
+
return {
|
|
34777
|
+
applyRequestedModel,
|
|
34778
|
+
modelDefaultEffort,
|
|
34779
|
+
writeConfigOptionReported,
|
|
34780
|
+
start,
|
|
34781
|
+
requireStarted,
|
|
34782
|
+
setNativeMode
|
|
34783
|
+
};
|
|
34598
34784
|
}
|
|
34599
34785
|
|
|
34600
34786
|
// ../../packages/ycodium-acp-executor/src/executor/settlement.ts
|
|
@@ -34658,14 +34844,14 @@ function createExecutorSettlement({
|
|
|
34658
34844
|
|
|
34659
34845
|
// ../../packages/ycodium-acp-executor/src/executor/subagent-sessions.ts
|
|
34660
34846
|
function parseState(raw) {
|
|
34661
|
-
if (!
|
|
34847
|
+
if (!isRecord2(raw)) return { status: void 0, error: void 0 };
|
|
34662
34848
|
const state = raw["state"];
|
|
34663
34849
|
if (state === "running") return { status: "running", error: void 0 };
|
|
34664
34850
|
if (state === "requires_action") return { status: "waiting", error: void 0 };
|
|
34665
34851
|
if (state !== "idle") return { status: void 0, error: void 0 };
|
|
34666
34852
|
const stopReason = raw["stopReason"];
|
|
34667
|
-
const error62 =
|
|
34668
|
-
if (stopReason === "error" ||
|
|
34853
|
+
const error62 = isRecord2(raw["error"]) ? asTrimmedString(raw["error"]["message"]) : void 0;
|
|
34854
|
+
if (stopReason === "error" || isRecord2(raw["error"])) return { status: "failed", error: error62 };
|
|
34669
34855
|
if (stopReason === "cancelled") return { status: "cancelled", error: void 0 };
|
|
34670
34856
|
return { status: "idle", error: void 0 };
|
|
34671
34857
|
}
|
|
@@ -34681,7 +34867,7 @@ function childLinkage(childId, record2) {
|
|
|
34681
34867
|
function createSubagentSessionTracker(registry2) {
|
|
34682
34868
|
const observe = (notification, ctx) => {
|
|
34683
34869
|
const update = notification.update;
|
|
34684
|
-
if (!
|
|
34870
|
+
if (!isRecord2(update) || update["sessionUpdate"] !== "subagent_update") return [];
|
|
34685
34871
|
const childId = asTrimmedString(update["sessionId"]);
|
|
34686
34872
|
if (childId === void 0 || ctx.ownSessionIds.has(childId)) return [];
|
|
34687
34873
|
const outerId = notification.sessionId;
|
|
@@ -34907,6 +35093,21 @@ function createExecutorUpdates({
|
|
|
34907
35093
|
markChildSession
|
|
34908
35094
|
});
|
|
34909
35095
|
const handleSessionUpdate = (params) => {
|
|
35096
|
+
const update = params.update;
|
|
35097
|
+
const reportedOptions = update["configOptions"];
|
|
35098
|
+
if (update["sessionUpdate"] === "config_option_update" && Array.isArray(reportedOptions)) {
|
|
35099
|
+
shared.configUpdateSeq += 1;
|
|
35100
|
+
shared.configOptionUpdates.set(params.sessionId, {
|
|
35101
|
+
configOptions: reportedOptions,
|
|
35102
|
+
seq: shared.configUpdateSeq
|
|
35103
|
+
});
|
|
35104
|
+
if (params.sessionId === shared.sessionId) {
|
|
35105
|
+
shared.modelSelectionState = adoptReportedConfigOptions(
|
|
35106
|
+
shared.modelSelectionState,
|
|
35107
|
+
reportedOptions
|
|
35108
|
+
);
|
|
35109
|
+
}
|
|
35110
|
+
}
|
|
34910
35111
|
const parsed = parseSessionUpdateEvent(params);
|
|
34911
35112
|
if (parsed.modeId && shared.modeState) {
|
|
34912
35113
|
shared.modeState = {
|
|
@@ -35222,7 +35423,10 @@ function createAcpExecutor(options) {
|
|
|
35222
35423
|
droppedReplayUpdates: 0,
|
|
35223
35424
|
ownSessionIds: /* @__PURE__ */ new Set(),
|
|
35224
35425
|
childSessions: createChildSessionRegistry(),
|
|
35225
|
-
sessionOpensInFlight: 0
|
|
35426
|
+
sessionOpensInFlight: 0,
|
|
35427
|
+
configOptionUpdates: /* @__PURE__ */ new Map(),
|
|
35428
|
+
optionWriteStop: void 0,
|
|
35429
|
+
configUpdateSeq: 0
|
|
35226
35430
|
};
|
|
35227
35431
|
const interruptedTurnIds = /* @__PURE__ */ new Set();
|
|
35228
35432
|
const approvals = createApprovalGate({
|
|
@@ -35371,8 +35575,16 @@ function createAcpExecutor(options) {
|
|
|
35371
35575
|
};
|
|
35372
35576
|
options.readable.once("end", onInputDead);
|
|
35373
35577
|
options.readable.once("error", onInputDead);
|
|
35374
|
-
const {
|
|
35578
|
+
const {
|
|
35579
|
+
applyRequestedModel,
|
|
35580
|
+
modelDefaultEffort,
|
|
35581
|
+
writeConfigOptionReported,
|
|
35582
|
+
start,
|
|
35583
|
+
requireStarted,
|
|
35584
|
+
setNativeMode
|
|
35585
|
+
} = createExecutorSession({
|
|
35375
35586
|
options,
|
|
35587
|
+
hooks,
|
|
35376
35588
|
connection,
|
|
35377
35589
|
isLive,
|
|
35378
35590
|
emit,
|
|
@@ -35398,6 +35610,8 @@ function createAcpExecutor(options) {
|
|
|
35398
35610
|
threadMutex,
|
|
35399
35611
|
promptMutex,
|
|
35400
35612
|
applyRequestedModel,
|
|
35613
|
+
modelDefaultEffort,
|
|
35614
|
+
writeConfigOptionReported,
|
|
35401
35615
|
notifyPromptSettled,
|
|
35402
35616
|
shared
|
|
35403
35617
|
});
|
|
@@ -36274,6 +36488,11 @@ function dshProbeModels(setup) {
|
|
|
36274
36488
|
...choice.name === void 0 ? {} : { name: choice.name },
|
|
36275
36489
|
...choice.isDefault === true ? { isDefault: true } : {}
|
|
36276
36490
|
}));
|
|
36491
|
+
const effortState = acpEffortConfigState(rawOptions);
|
|
36492
|
+
if (effortState === "unknown") return models;
|
|
36493
|
+
if (effortState === "none") {
|
|
36494
|
+
return models.map((model) => ({ ...model, capabilities: { optionDescriptors: [] } }));
|
|
36495
|
+
}
|
|
36277
36496
|
const effort = findAcpEffortConfig(rawOptions);
|
|
36278
36497
|
if (effort === void 0) return models;
|
|
36279
36498
|
const capabilities = {
|
|
@@ -36790,10 +37009,15 @@ var createDshInstance = (config2, host) => {
|
|
|
36790
37009
|
signal?.addEventListener("abort", onAbort);
|
|
36791
37010
|
try {
|
|
36792
37011
|
const requestedModelId = modelIdFromSelection(input2.modelSelection);
|
|
37012
|
+
const requestedEffort = modelSelectionStringOption(
|
|
37013
|
+
input2.modelSelection,
|
|
37014
|
+
DSH_EFFORT_OPTION_ID
|
|
37015
|
+
);
|
|
36793
37016
|
const turn = await dispatchAcpPrompt(booked.executor, {
|
|
36794
37017
|
text: input2.input ?? "",
|
|
36795
37018
|
expectedActiveTurnId: input2.expectedTurnId,
|
|
36796
|
-
...requestedModelId === void 0 ? {} : { requestedModelId }
|
|
37019
|
+
...requestedModelId === void 0 ? {} : { requestedModelId },
|
|
37020
|
+
...requestedEffort === void 0 ? {} : { requestedEffort }
|
|
36797
37021
|
});
|
|
36798
37022
|
booked.turns.push({ id: turn.turnId, items: [] });
|
|
36799
37023
|
return {
|
|
@@ -36879,7 +37103,7 @@ var executors = [
|
|
|
36879
37103
|
];
|
|
36880
37104
|
var index_default = definePlugin({
|
|
36881
37105
|
id: "agent-dsh",
|
|
36882
|
-
apiVersion:
|
|
37106
|
+
apiVersion: 50,
|
|
36883
37107
|
executors,
|
|
36884
37108
|
activate(ctx) {
|
|
36885
37109
|
ctx.log.info("dsh executor ready");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/agent-dsh",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3635",
|
|
4
4
|
"description": "DeepSeek Harness executor: dsh CLI over Agent Client Protocol stdio.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"esbuild": "0.28.1",
|
|
23
23
|
"vite-plus": "0.2.2",
|
|
24
24
|
"yaml": "^2.9.0",
|
|
25
|
-
"@ycodium-ai/plugin-api": "0.2.
|
|
26
|
-
"ycodium-acp-executor": "0.2.
|
|
25
|
+
"@ycodium-ai/plugin-api": "0.2.3635",
|
|
26
|
+
"ycodium-acp-executor": "0.2.3635",
|
|
27
27
|
"ycodium-executor-testing": "0.0.0"
|
|
28
28
|
},
|
|
29
29
|
"ycodium": {
|