@ycodium-ai/agent-dsh 0.2.2634 → 0.2.2664
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 +297 -44
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -23543,11 +23543,21 @@ var AcpExecutorRequestError = class extends AcpExecutorError {
|
|
|
23543
23543
|
}
|
|
23544
23544
|
};
|
|
23545
23545
|
var AcpConnectionClosedError = class extends Error {
|
|
23546
|
-
constructor(message = "ACP connection closed") {
|
|
23547
|
-
super(message);
|
|
23546
|
+
constructor(message = "ACP connection closed", options) {
|
|
23547
|
+
super(message, options);
|
|
23548
23548
|
this.name = "AcpConnectionClosedError";
|
|
23549
23549
|
}
|
|
23550
23550
|
};
|
|
23551
|
+
async function withStartupStderr(error62, stderrTail) {
|
|
23552
|
+
if (!(error62 instanceof AcpConnectionClosedError) || stderrTail === void 0) return error62;
|
|
23553
|
+
const tail = await stderrTail();
|
|
23554
|
+
if (tail.length === 0) return error62;
|
|
23555
|
+
return new AcpConnectionClosedError(`${error62.message}
|
|
23556
|
+
Agent stderr (last lines):
|
|
23557
|
+
${tail}`, {
|
|
23558
|
+
cause: error62
|
|
23559
|
+
});
|
|
23560
|
+
}
|
|
23551
23561
|
|
|
23552
23562
|
// ../../packages/ycodium-acp-executor/src/jsonrpc.ts
|
|
23553
23563
|
function isRecord2(value) {
|
|
@@ -24463,7 +24473,9 @@ function findAcpEffortConfig(configOptions) {
|
|
|
24463
24473
|
function acpModelChoicesFromConfigOptions(configOptions) {
|
|
24464
24474
|
if (!Array.isArray(configOptions)) return void 0;
|
|
24465
24475
|
const records = configOptions.filter(isRecord3);
|
|
24466
|
-
const modelOption = records.find((option) => normalizedField(option, "category") === "model")
|
|
24476
|
+
const modelOption = records.find((option) => normalizedField(option, "category") === "model") ?? records.find(
|
|
24477
|
+
(option) => normalizedField(option, "id") === "model" && normalizedField(option, "type") === "select"
|
|
24478
|
+
);
|
|
24467
24479
|
if (modelOption === void 0) return void 0;
|
|
24468
24480
|
if (!asString(modelOption["id"])?.trim()) return void 0;
|
|
24469
24481
|
return flattenChoices(modelOption["options"], asString(modelOption["currentValue"])?.trim());
|
|
@@ -24812,7 +24824,7 @@ function extractModelConfigId(sessionResponse) {
|
|
|
24812
24824
|
return opt.id.trim();
|
|
24813
24825
|
}
|
|
24814
24826
|
}
|
|
24815
|
-
return void 0;
|
|
24827
|
+
return configOptions.find((opt) => opt.id.trim() === "model" && opt.type === "select") ? "model" : void 0;
|
|
24816
24828
|
}
|
|
24817
24829
|
function findSessionConfigOption(configOptions, configId) {
|
|
24818
24830
|
if (!configOptions) {
|
|
@@ -25209,6 +25221,13 @@ function readAcpText(source, key) {
|
|
|
25209
25221
|
const trimmed = value.trim();
|
|
25210
25222
|
return trimmed.length > 0 ? trimmed : void 0;
|
|
25211
25223
|
}
|
|
25224
|
+
function textFromContentBlocks(blocks) {
|
|
25225
|
+
const parts = blocks.flatMap(
|
|
25226
|
+
(block) => isRecord5(block) && block["type"] === "text" && typeof block["text"] === "string" ? [block["text"]] : []
|
|
25227
|
+
);
|
|
25228
|
+
const joined = parts.join("");
|
|
25229
|
+
return joined.trim().length > 0 ? joined : void 0;
|
|
25230
|
+
}
|
|
25212
25231
|
function parseSessionUpdateEvent(params) {
|
|
25213
25232
|
const upd = params.update;
|
|
25214
25233
|
const events = [];
|
|
@@ -25292,6 +25311,28 @@ function parseSessionUpdateEvent(params) {
|
|
|
25292
25311
|
}
|
|
25293
25312
|
break;
|
|
25294
25313
|
}
|
|
25314
|
+
case "compaction_update": {
|
|
25315
|
+
const compactionId = readAcpText(upd, "compactionId");
|
|
25316
|
+
const status = readAcpText(upd, "status");
|
|
25317
|
+
if (compactionId === void 0 || status === void 0) break;
|
|
25318
|
+
const rawSummary = upd["summary"];
|
|
25319
|
+
events.push({
|
|
25320
|
+
_tag: "CompactionUpdated",
|
|
25321
|
+
compactionId,
|
|
25322
|
+
status,
|
|
25323
|
+
summary: rawSummary === void 0 ? void 0 : Array.isArray(rawSummary) ? textFromContentBlocks(rawSummary) ?? null : null,
|
|
25324
|
+
error: readAcpText(upd, "error")
|
|
25325
|
+
});
|
|
25326
|
+
break;
|
|
25327
|
+
}
|
|
25328
|
+
case "compaction_summary_chunk": {
|
|
25329
|
+
const compactionId = readAcpText(upd, "compactionId");
|
|
25330
|
+
const content = isRecord5(upd["content"]) ? upd["content"] : void 0;
|
|
25331
|
+
const text = content?.["type"] === "text" ? content["text"] : void 0;
|
|
25332
|
+
if (compactionId === void 0 || typeof text !== "string" || text.length === 0) break;
|
|
25333
|
+
events.push({ _tag: "CompactionSummaryChunk", compactionId, text });
|
|
25334
|
+
break;
|
|
25335
|
+
}
|
|
25295
25336
|
default:
|
|
25296
25337
|
break;
|
|
25297
25338
|
}
|
|
@@ -25388,6 +25429,97 @@ function createAcpExecutor(options) {
|
|
|
25388
25429
|
if (settledPromptKeys.length > SETTLED_PROMPT_KEY_LIMIT) settledPromptKeys.shift();
|
|
25389
25430
|
};
|
|
25390
25431
|
const toolCalls = /* @__PURE__ */ new Map();
|
|
25432
|
+
const compactions = /* @__PURE__ */ new Map();
|
|
25433
|
+
let manualCompaction;
|
|
25434
|
+
const COMPACTION_SUMMARY_MAX_CHARS = 8e3;
|
|
25435
|
+
const nowMs = () => options.nowMs?.() ?? Date.now();
|
|
25436
|
+
const emitCompactionState = (record2, state) => {
|
|
25437
|
+
const summary = record2.summary?.trim() ?? "";
|
|
25438
|
+
const truncated = summary.length > COMPACTION_SUMMARY_MAX_CHARS;
|
|
25439
|
+
emit({
|
|
25440
|
+
type: "thread.state.changed",
|
|
25441
|
+
...stamp(),
|
|
25442
|
+
provider: options.provider,
|
|
25443
|
+
threadId: options.threadId,
|
|
25444
|
+
...activeTurnId !== void 0 ? { turnId: activeTurnId } : {},
|
|
25445
|
+
payload: {
|
|
25446
|
+
state,
|
|
25447
|
+
compaction: {
|
|
25448
|
+
compactionId: record2.snapshotId,
|
|
25449
|
+
trigger: record2.trigger,
|
|
25450
|
+
...state === "compacted" ? { durationMs: Math.max(0, nowMs() - record2.startedAtMs) } : {},
|
|
25451
|
+
...summary.length > 0 ? {
|
|
25452
|
+
summary: truncated ? summary.slice(0, COMPACTION_SUMMARY_MAX_CHARS) : summary,
|
|
25453
|
+
...truncated ? { summaryTruncated: true } : {}
|
|
25454
|
+
} : {}
|
|
25455
|
+
}
|
|
25456
|
+
}
|
|
25457
|
+
});
|
|
25458
|
+
};
|
|
25459
|
+
const applyCompactionUpdate = (event) => {
|
|
25460
|
+
let record2 = compactions.get(event.compactionId);
|
|
25461
|
+
if (record2 === void 0) {
|
|
25462
|
+
if (manualCompaction !== void 0 && !manualCompaction.adopted) {
|
|
25463
|
+
manualCompaction.adopted = true;
|
|
25464
|
+
record2 = manualCompaction;
|
|
25465
|
+
} else {
|
|
25466
|
+
record2 = {
|
|
25467
|
+
snapshotId: randomId(),
|
|
25468
|
+
trigger: "automatic",
|
|
25469
|
+
startedAtMs: nowMs(),
|
|
25470
|
+
summary: void 0,
|
|
25471
|
+
announced: false,
|
|
25472
|
+
finished: false,
|
|
25473
|
+
adopted: false
|
|
25474
|
+
};
|
|
25475
|
+
}
|
|
25476
|
+
compactions.set(event.compactionId, record2);
|
|
25477
|
+
}
|
|
25478
|
+
if (event.summary !== void 0) record2.summary = event.summary ?? void 0;
|
|
25479
|
+
switch (event.status) {
|
|
25480
|
+
case "in_progress":
|
|
25481
|
+
if (!record2.announced) {
|
|
25482
|
+
record2.announced = true;
|
|
25483
|
+
emitCompactionState(record2, "compacting");
|
|
25484
|
+
}
|
|
25485
|
+
return;
|
|
25486
|
+
case "completed":
|
|
25487
|
+
record2.announced = true;
|
|
25488
|
+
record2.finished = true;
|
|
25489
|
+
compactions.delete(event.compactionId);
|
|
25490
|
+
emitCompactionState(record2, "compacted");
|
|
25491
|
+
return;
|
|
25492
|
+
case "failed":
|
|
25493
|
+
case "cancelled":
|
|
25494
|
+
record2.finished = true;
|
|
25495
|
+
compactions.delete(event.compactionId);
|
|
25496
|
+
emit({
|
|
25497
|
+
type: "runtime.warning",
|
|
25498
|
+
...stamp(),
|
|
25499
|
+
provider: options.provider,
|
|
25500
|
+
threadId: options.threadId,
|
|
25501
|
+
...activeTurnId !== void 0 ? { turnId: activeTurnId } : {},
|
|
25502
|
+
payload: {
|
|
25503
|
+
message: event.error ?? `Context compaction ${event.status}`,
|
|
25504
|
+
detail: { code: `context-compaction-${event.status}` }
|
|
25505
|
+
}
|
|
25506
|
+
});
|
|
25507
|
+
return;
|
|
25508
|
+
default:
|
|
25509
|
+
return;
|
|
25510
|
+
}
|
|
25511
|
+
};
|
|
25512
|
+
const shownToolCallIds = /* @__PURE__ */ new Set();
|
|
25513
|
+
const SHOWN_TOOL_CALL_LIMIT = 256;
|
|
25514
|
+
const rememberShownToolCall = (toolCallId) => {
|
|
25515
|
+
shownToolCallIds.add(toolCallId);
|
|
25516
|
+
if (shownToolCallIds.size <= SHOWN_TOOL_CALL_LIMIT) return;
|
|
25517
|
+
for (const id of shownToolCallIds) {
|
|
25518
|
+
if (toolCalls.has(id)) continue;
|
|
25519
|
+
shownToolCallIds.delete(id);
|
|
25520
|
+
return;
|
|
25521
|
+
}
|
|
25522
|
+
};
|
|
25391
25523
|
let assistantSegment = { nextSegmentIndex: 0 };
|
|
25392
25524
|
let modeState;
|
|
25393
25525
|
let availableCommands = [];
|
|
@@ -25474,7 +25606,6 @@ function createAcpExecutor(options) {
|
|
|
25474
25606
|
}
|
|
25475
25607
|
for (const event of parsed.events) {
|
|
25476
25608
|
if (event._tag === "ToolCallUpdated") {
|
|
25477
|
-
closeActiveAssistantSegment(activeTurnId);
|
|
25478
25609
|
const tracked = toolCalls.get(event.toolCall.toolCallId);
|
|
25479
25610
|
const previous = tracked?.state;
|
|
25480
25611
|
const nextToolCall = mergeToolCallState(previous, event.toolCall);
|
|
@@ -25493,9 +25624,35 @@ function createAcpExecutor(options) {
|
|
|
25493
25624
|
skippedSinceEmit: decision.skippedSinceEmit
|
|
25494
25625
|
});
|
|
25495
25626
|
}
|
|
25496
|
-
|
|
25627
|
+
const hookResult = hooks.onToolCallUpdated?.({
|
|
25628
|
+
toolCallId: nextToolCall.toolCallId,
|
|
25629
|
+
status: nextToolCall.status,
|
|
25630
|
+
title: nextToolCall.title,
|
|
25631
|
+
kind: nextToolCall.kind,
|
|
25632
|
+
rawInput: nextToolCall.data["rawInput"],
|
|
25633
|
+
rawOutput: nextToolCall.data["rawOutput"],
|
|
25634
|
+
meta: params.update._meta,
|
|
25635
|
+
turnId: activeTurnId
|
|
25636
|
+
});
|
|
25637
|
+
const taskEvents = hookResult === void 0 ? [] : "events" in hookResult ? hookResult.events : hookResult;
|
|
25638
|
+
const handledByHook = hookResult !== void 0 && "events" in hookResult && hookResult.handled === true;
|
|
25639
|
+
for (const taskEvent of taskEvents) {
|
|
25640
|
+
emit({
|
|
25641
|
+
type: taskEvent.type,
|
|
25642
|
+
...stamp(),
|
|
25643
|
+
provider: options.provider,
|
|
25644
|
+
threadId: options.threadId,
|
|
25645
|
+
...taskEvent.turnId !== void 0 ? { turnId: taskEvent.turnId } : {},
|
|
25646
|
+
payload: taskEvent.payload
|
|
25647
|
+
});
|
|
25648
|
+
}
|
|
25649
|
+
if (handledByHook || !decision.emit) {
|
|
25497
25650
|
continue;
|
|
25498
25651
|
}
|
|
25652
|
+
if (!shownToolCallIds.has(nextToolCall.toolCallId)) {
|
|
25653
|
+
rememberShownToolCall(nextToolCall.toolCallId);
|
|
25654
|
+
closeActiveAssistantSegment(activeTurnId);
|
|
25655
|
+
}
|
|
25499
25656
|
emit(
|
|
25500
25657
|
makeAcpToolCallEvent({
|
|
25501
25658
|
stamp: stamp(),
|
|
@@ -25508,7 +25665,21 @@ function createAcpExecutor(options) {
|
|
|
25508
25665
|
);
|
|
25509
25666
|
continue;
|
|
25510
25667
|
}
|
|
25668
|
+
if (event._tag === "CompactionUpdated") {
|
|
25669
|
+
applyCompactionUpdate(event);
|
|
25670
|
+
continue;
|
|
25671
|
+
}
|
|
25672
|
+
if (event._tag === "CompactionSummaryChunk") {
|
|
25673
|
+
const record2 = compactions.get(event.compactionId);
|
|
25674
|
+
if (record2 !== void 0 && !record2.finished) {
|
|
25675
|
+
record2.summary = (record2.summary ?? "") + event.text;
|
|
25676
|
+
}
|
|
25677
|
+
continue;
|
|
25678
|
+
}
|
|
25511
25679
|
if (event._tag === "ContentDelta") {
|
|
25680
|
+
if (manualCompaction !== void 0) {
|
|
25681
|
+
continue;
|
|
25682
|
+
}
|
|
25512
25683
|
if (event.streamKind === "reasoning_text") {
|
|
25513
25684
|
if (event.text.trim().length === 0) {
|
|
25514
25685
|
continue;
|
|
@@ -25751,7 +25922,9 @@ function createAcpExecutor(options) {
|
|
|
25751
25922
|
},
|
|
25752
25923
|
onNotification: (notification) => {
|
|
25753
25924
|
if (notification.method === "session/update") {
|
|
25754
|
-
|
|
25925
|
+
const params = notification.params;
|
|
25926
|
+
const transformed = hooks.transformSessionUpdate ? hooks.transformSessionUpdate(params) : params;
|
|
25927
|
+
if (transformed !== void 0) handleSessionUpdate(transformed);
|
|
25755
25928
|
return;
|
|
25756
25929
|
}
|
|
25757
25930
|
if (settleFromNotification(notification.method, notification.params)) return;
|
|
@@ -25885,13 +26058,15 @@ function createAcpExecutor(options) {
|
|
|
25885
26058
|
options.mcpServers ?? [],
|
|
25886
26059
|
initialized.agentCapabilities
|
|
25887
26060
|
);
|
|
26061
|
+
const additionalDirectories = options.additionalDirectories !== void 0 && options.additionalDirectories.length > 0 ? { additionalDirectories: options.additionalDirectories } : {};
|
|
25888
26062
|
let setup;
|
|
25889
26063
|
let nextSessionId;
|
|
25890
26064
|
if (options.resumeSessionId && options.resumeMethod === "session/resume") {
|
|
25891
26065
|
setup = await connection.request("session/resume", {
|
|
25892
26066
|
sessionId: options.resumeSessionId,
|
|
25893
26067
|
cwd: options.cwd,
|
|
25894
|
-
mcpServers
|
|
26068
|
+
mcpServers,
|
|
26069
|
+
...additionalDirectories
|
|
25895
26070
|
});
|
|
25896
26071
|
nextSessionId = options.resumeSessionId;
|
|
25897
26072
|
} else if (options.resumeSessionId) {
|
|
@@ -25900,7 +26075,8 @@ function createAcpExecutor(options) {
|
|
|
25900
26075
|
setup = await connection.request("session/load", {
|
|
25901
26076
|
sessionId: options.resumeSessionId,
|
|
25902
26077
|
cwd: options.cwd,
|
|
25903
|
-
mcpServers
|
|
26078
|
+
mcpServers,
|
|
26079
|
+
...additionalDirectories
|
|
25904
26080
|
});
|
|
25905
26081
|
} finally {
|
|
25906
26082
|
sessionLoadInFlight = false;
|
|
@@ -25913,7 +26089,8 @@ function createAcpExecutor(options) {
|
|
|
25913
26089
|
} else {
|
|
25914
26090
|
const created = await connection.request("session/new", {
|
|
25915
26091
|
cwd: options.cwd,
|
|
25916
|
-
mcpServers
|
|
26092
|
+
mcpServers,
|
|
26093
|
+
...additionalDirectories
|
|
25917
26094
|
});
|
|
25918
26095
|
nextSessionId = created.sessionId;
|
|
25919
26096
|
setup = created;
|
|
@@ -25987,13 +26164,13 @@ function createAcpExecutor(options) {
|
|
|
25987
26164
|
startInFlight = void 0;
|
|
25988
26165
|
return result;
|
|
25989
26166
|
},
|
|
25990
|
-
(error62) => {
|
|
26167
|
+
async (error62) => {
|
|
25991
26168
|
startInFlight = void 0;
|
|
25992
26169
|
if (isLive(expectedGeneration) && !startResult) {
|
|
25993
26170
|
status = "idle";
|
|
25994
26171
|
generation = expectedGeneration;
|
|
25995
26172
|
}
|
|
25996
|
-
throw error62;
|
|
26173
|
+
throw await withStartupStderr(error62, options.stderrTail);
|
|
25997
26174
|
}
|
|
25998
26175
|
);
|
|
25999
26176
|
return startInFlight;
|
|
@@ -26061,6 +26238,36 @@ function createAcpExecutor(options) {
|
|
|
26061
26238
|
interruptedTurnIds.delete(input2.turnId);
|
|
26062
26239
|
}
|
|
26063
26240
|
};
|
|
26241
|
+
const sendPromptRpc = async (sessionId2, promptParts) => {
|
|
26242
|
+
const settlementHooks = hooks.promptSettlement;
|
|
26243
|
+
const promptKey = settlementHooks === void 0 ? void 0 : randomId();
|
|
26244
|
+
const promptRpc = connection.request("session/prompt", {
|
|
26245
|
+
sessionId: sessionId2,
|
|
26246
|
+
prompt: promptParts,
|
|
26247
|
+
...settlementHooks !== void 0 && promptKey !== void 0 ? settlementHooks.requestFields(promptKey) : {}
|
|
26248
|
+
});
|
|
26249
|
+
if (settlementHooks === void 0 || promptKey === void 0) {
|
|
26250
|
+
return await promptRpc;
|
|
26251
|
+
} else {
|
|
26252
|
+
const { promise: early, resolve: settleEarly } = Promise.withResolvers();
|
|
26253
|
+
pendingSettlement = { promptKey, sessionId: sessionId2, settle: settleEarly };
|
|
26254
|
+
try {
|
|
26255
|
+
const outcome = await Promise.race([
|
|
26256
|
+
promptRpc.then((value) => {
|
|
26257
|
+
const key = settlementHooks.responseKey?.(value);
|
|
26258
|
+
if (key !== void 0) rememberSettledPromptKey(key);
|
|
26259
|
+
return { response: value };
|
|
26260
|
+
}),
|
|
26261
|
+
early
|
|
26262
|
+
]);
|
|
26263
|
+
if (outcome.error !== void 0) throw outcome.error;
|
|
26264
|
+
return outcome.response;
|
|
26265
|
+
} finally {
|
|
26266
|
+
pendingSettlement = void 0;
|
|
26267
|
+
void promptRpc.catch(() => void 0);
|
|
26268
|
+
}
|
|
26269
|
+
}
|
|
26270
|
+
};
|
|
26064
26271
|
const prompt = async (input2) => {
|
|
26065
26272
|
failIfDisposed();
|
|
26066
26273
|
const started = requireStarted();
|
|
@@ -26111,35 +26318,8 @@ function createAcpExecutor(options) {
|
|
|
26111
26318
|
expectedGeneration: started.generation
|
|
26112
26319
|
});
|
|
26113
26320
|
closeActiveAssistantSegment(turnId);
|
|
26114
|
-
const settlementHooks = hooks.promptSettlement;
|
|
26115
|
-
const promptKey = settlementHooks === void 0 ? void 0 : randomId();
|
|
26116
|
-
const promptRpc = connection.request("session/prompt", {
|
|
26117
|
-
sessionId: started.sessionId,
|
|
26118
|
-
prompt: promptParts,
|
|
26119
|
-
...settlementHooks !== void 0 && promptKey !== void 0 ? settlementHooks.requestFields(promptKey) : {}
|
|
26120
|
-
});
|
|
26121
26321
|
try {
|
|
26122
|
-
|
|
26123
|
-
response = await promptRpc;
|
|
26124
|
-
} else {
|
|
26125
|
-
const { promise: early, resolve: settleEarly } = Promise.withResolvers();
|
|
26126
|
-
pendingSettlement = { promptKey, sessionId: started.sessionId, settle: settleEarly };
|
|
26127
|
-
try {
|
|
26128
|
-
const outcome = await Promise.race([
|
|
26129
|
-
promptRpc.then((value) => {
|
|
26130
|
-
const key = settlementHooks.responseKey?.(value);
|
|
26131
|
-
if (key !== void 0) rememberSettledPromptKey(key);
|
|
26132
|
-
return { response: value };
|
|
26133
|
-
}),
|
|
26134
|
-
early
|
|
26135
|
-
]);
|
|
26136
|
-
if (outcome.error !== void 0) throw outcome.error;
|
|
26137
|
-
response = outcome.response;
|
|
26138
|
-
} finally {
|
|
26139
|
-
pendingSettlement = void 0;
|
|
26140
|
-
void promptRpc.catch(() => void 0);
|
|
26141
|
-
}
|
|
26142
|
-
}
|
|
26322
|
+
response = await sendPromptRpc(started.sessionId, promptParts);
|
|
26143
26323
|
} catch (error62) {
|
|
26144
26324
|
if (disposed) {
|
|
26145
26325
|
throw new AcpExecutorDisposedError();
|
|
@@ -26303,6 +26483,74 @@ function createAcpExecutor(options) {
|
|
|
26303
26483
|
};
|
|
26304
26484
|
apply();
|
|
26305
26485
|
};
|
|
26486
|
+
const compact = async (input2) => {
|
|
26487
|
+
failIfDisposed();
|
|
26488
|
+
const started = requireStarted();
|
|
26489
|
+
const trimmedName = input2.commandName.trim();
|
|
26490
|
+
const commandName = trimmedName.startsWith("/") ? trimmedName.slice(1) : trimmedName;
|
|
26491
|
+
if (!availableCommands.some((command) => command.name === commandName)) {
|
|
26492
|
+
throw new AcpExecutorError(
|
|
26493
|
+
"command-unavailable",
|
|
26494
|
+
`The agent has not advertised the /${commandName} command`
|
|
26495
|
+
);
|
|
26496
|
+
}
|
|
26497
|
+
if (promptsInFlight > 0 || promptMutex.isLocked || manualCompaction !== void 0) {
|
|
26498
|
+
throw new AcpExecutorError(
|
|
26499
|
+
"busy",
|
|
26500
|
+
"Cannot compact while a turn or another compaction is running"
|
|
26501
|
+
);
|
|
26502
|
+
}
|
|
26503
|
+
const record2 = {
|
|
26504
|
+
snapshotId: randomId(),
|
|
26505
|
+
trigger: "manual",
|
|
26506
|
+
startedAtMs: nowMs(),
|
|
26507
|
+
summary: void 0,
|
|
26508
|
+
announced: true,
|
|
26509
|
+
finished: false,
|
|
26510
|
+
adopted: false
|
|
26511
|
+
};
|
|
26512
|
+
await promptMutex.acquire();
|
|
26513
|
+
manualCompaction = record2;
|
|
26514
|
+
const emitSessionState = (state) => {
|
|
26515
|
+
emit({
|
|
26516
|
+
type: "session.state.changed",
|
|
26517
|
+
...stamp(),
|
|
26518
|
+
provider: options.provider,
|
|
26519
|
+
threadId: options.threadId,
|
|
26520
|
+
payload: { state, reason: "compaction" }
|
|
26521
|
+
});
|
|
26522
|
+
};
|
|
26523
|
+
try {
|
|
26524
|
+
failIfDisposed();
|
|
26525
|
+
emitSessionState("compacting");
|
|
26526
|
+
emitCompactionState(record2, "compacting");
|
|
26527
|
+
let response;
|
|
26528
|
+
try {
|
|
26529
|
+
response = await sendPromptRpc(started.sessionId, [
|
|
26530
|
+
{ type: "text", text: `/${commandName}` }
|
|
26531
|
+
]);
|
|
26532
|
+
} catch (error62) {
|
|
26533
|
+
if (disposed) throw new AcpExecutorDisposedError();
|
|
26534
|
+
throw error62;
|
|
26535
|
+
}
|
|
26536
|
+
await connection.awaitInboundIdle();
|
|
26537
|
+
if (response.stopReason === "cancelled") {
|
|
26538
|
+
return;
|
|
26539
|
+
}
|
|
26540
|
+
if (!record2.finished) {
|
|
26541
|
+
record2.finished = true;
|
|
26542
|
+
emitCompactionState(record2, "compacted");
|
|
26543
|
+
}
|
|
26544
|
+
} finally {
|
|
26545
|
+
for (const [agentId, tracked] of compactions) {
|
|
26546
|
+
if (tracked === record2) compactions.delete(agentId);
|
|
26547
|
+
}
|
|
26548
|
+
manualCompaction = void 0;
|
|
26549
|
+
promptMutex.release();
|
|
26550
|
+
notifyPromptSettled();
|
|
26551
|
+
if (!disposed) emitSessionState("ready");
|
|
26552
|
+
}
|
|
26553
|
+
};
|
|
26306
26554
|
const setNativeMode = async (modeId) => {
|
|
26307
26555
|
failIfDisposed();
|
|
26308
26556
|
const started = startResult;
|
|
@@ -26390,6 +26638,7 @@ function createAcpExecutor(options) {
|
|
|
26390
26638
|
respondToRequest,
|
|
26391
26639
|
respondToUserInput,
|
|
26392
26640
|
setNativeMode,
|
|
26641
|
+
compact,
|
|
26393
26642
|
dispose
|
|
26394
26643
|
};
|
|
26395
26644
|
}
|
|
@@ -26612,6 +26861,7 @@ import * as NodeFS from "node:fs";
|
|
|
26612
26861
|
import * as NodeOS2 from "node:os";
|
|
26613
26862
|
import * as NodePath2 from "node:path";
|
|
26614
26863
|
import {
|
|
26864
|
+
describeExecutorSpawnFailure,
|
|
26615
26865
|
ExecutorSpawnRefusedError
|
|
26616
26866
|
} from "@ycodium-ai/plugin-api/executor";
|
|
26617
26867
|
import { nodeStreamsFromHandle } from "@ycodium-ai/plugin-api/process-stdin";
|
|
@@ -26770,7 +27020,7 @@ async function probeDshModels(input2) {
|
|
|
26770
27020
|
});
|
|
26771
27021
|
} catch (error62) {
|
|
26772
27022
|
if (error62 instanceof ExecutorSpawnRefusedError) throw error62;
|
|
26773
|
-
return { kind: "not-started",
|
|
27023
|
+
return { kind: "not-started", ...describeExecutorSpawnFailure(error62) };
|
|
26774
27024
|
}
|
|
26775
27025
|
let handshake;
|
|
26776
27026
|
try {
|
|
@@ -26874,7 +27124,7 @@ var createDshInstance = (config2, host) => {
|
|
|
26874
27124
|
return {
|
|
26875
27125
|
installed: false,
|
|
26876
27126
|
version: null,
|
|
26877
|
-
readiness: "
|
|
27127
|
+
readiness: "not-installed",
|
|
26878
27128
|
auth: { status: "unknown" },
|
|
26879
27129
|
detail: "DeepSeek Harness program path is not configured"
|
|
26880
27130
|
};
|
|
@@ -26887,7 +27137,9 @@ var createDshInstance = (config2, host) => {
|
|
|
26887
27137
|
return {
|
|
26888
27138
|
installed: outcome.kind === "failed",
|
|
26889
27139
|
version: version2,
|
|
26890
|
-
|
|
27140
|
+
// 起不起得来答的是装没装:找不到、路径不存在、不可执行是 not-installed,别的启动失败与
|
|
27141
|
+
// 握不上手都是 error。
|
|
27142
|
+
readiness: outcome.kind === "not-started" ? outcome.readiness : "error",
|
|
26891
27143
|
auth: { status: "unknown" },
|
|
26892
27144
|
...outcome.detail === void 0 ? {} : { detail: outcome.detail },
|
|
26893
27145
|
// 装着但握不上手时界面照样画权限格,不报档就退回宿主四档。
|
|
@@ -26926,12 +27178,13 @@ var createDshInstance = (config2, host) => {
|
|
|
26926
27178
|
owner: { bindingId: host.bindingId },
|
|
26927
27179
|
...Object.keys(env).length > 0 ? { env } : {}
|
|
26928
27180
|
});
|
|
26929
|
-
const { readable, writable } = nodeStreamsFromHandle2(handle);
|
|
27181
|
+
const { readable, writable, stderrTail } = nodeStreamsFromHandle2(handle);
|
|
26930
27182
|
const resume = input2.discardResumeCursor === true ? void 0 : parseAcpResumeCursor(input2.resumeCursor, RESUME_SCHEMA_VERSION);
|
|
26931
27183
|
const requestedModelId = modelIdFromSelection(input2.modelSelection);
|
|
26932
27184
|
const executor = createAcpExecutor({
|
|
26933
27185
|
readable,
|
|
26934
27186
|
writable,
|
|
27187
|
+
stderrTail,
|
|
26935
27188
|
cwd,
|
|
26936
27189
|
threadId: input2.threadId,
|
|
26937
27190
|
provider: DSH_DRIVER_KIND,
|
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.2664",
|
|
4
4
|
"description": "DeepSeek Harness executor: dsh CLI over Agent Client Protocol stdio.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"@types/node": "24.12.4",
|
|
22
22
|
"esbuild": "0.28.1",
|
|
23
23
|
"vite-plus": "0.2.2",
|
|
24
|
-
"@ycodium-ai/plugin-api": "0.2.
|
|
25
|
-
"ycodium-
|
|
26
|
-
"ycodium-executor
|
|
24
|
+
"@ycodium-ai/plugin-api": "0.2.2664",
|
|
25
|
+
"ycodium-executor-testing": "0.0.0",
|
|
26
|
+
"ycodium-acp-executor": "0.2.2664"
|
|
27
27
|
},
|
|
28
28
|
"ycodium": {
|
|
29
29
|
"plugin": "./dist/index.js",
|