@ycodium-ai/agent-dsh 0.2.4343 → 0.2.4368
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 +119 -27
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -7371,7 +7371,7 @@ var require_dist = __commonJS({
|
|
|
7371
7371
|
import { definePlugin } from "@ycodium-ai/plugin-api";
|
|
7372
7372
|
|
|
7373
7373
|
// ../../packages/plugin-api/src/version.ts
|
|
7374
|
-
var PLUGIN_API_VERSION =
|
|
7374
|
+
var PLUGIN_API_VERSION = 112;
|
|
7375
7375
|
|
|
7376
7376
|
// src/index.ts
|
|
7377
7377
|
import * as NodeOS6 from "node:os";
|
|
@@ -7635,9 +7635,11 @@ var AcpExecutorRequestError = class extends AcpExecutorError {
|
|
|
7635
7635
|
}
|
|
7636
7636
|
};
|
|
7637
7637
|
var AcpConnectionClosedError = class extends Error {
|
|
7638
|
+
reason;
|
|
7638
7639
|
constructor(message = "ACP connection closed", options) {
|
|
7639
|
-
super(message, options);
|
|
7640
|
+
super(message, options?.cause === void 0 ? void 0 : { cause: options.cause });
|
|
7640
7641
|
this.name = "AcpConnectionClosedError";
|
|
7642
|
+
this.reason = options?.reason ?? "closed";
|
|
7641
7643
|
}
|
|
7642
7644
|
};
|
|
7643
7645
|
async function withStartupStderr(error62, stderrTail) {
|
|
@@ -7647,9 +7649,65 @@ async function withStartupStderr(error62, stderrTail) {
|
|
|
7647
7649
|
return new AcpConnectionClosedError(`${error62.message}
|
|
7648
7650
|
Agent stderr (last lines):
|
|
7649
7651
|
${tail}`, {
|
|
7650
|
-
cause: error62
|
|
7652
|
+
cause: error62,
|
|
7653
|
+
reason: error62.reason
|
|
7651
7654
|
});
|
|
7652
7655
|
}
|
|
7656
|
+
var AGENT_EXIT_STDERR_MAX_CHARS = 800;
|
|
7657
|
+
var AGENT_EXIT_SETTLE_MS = 500;
|
|
7658
|
+
var AcpAgentExitedError = class extends AcpConnectionClosedError {
|
|
7659
|
+
exitCode;
|
|
7660
|
+
constructor(message, exitCode, cause) {
|
|
7661
|
+
super(message, { cause, reason: "input-ended" });
|
|
7662
|
+
this.name = "AcpAgentExitedError";
|
|
7663
|
+
this.exitCode = exitCode;
|
|
7664
|
+
}
|
|
7665
|
+
};
|
|
7666
|
+
var REDACTION_MARKERS = ["[redacted]", "[pairing-url]"];
|
|
7667
|
+
var lastLines = (text, maxChars) => {
|
|
7668
|
+
if (text.length <= maxChars) return text;
|
|
7669
|
+
let start = text.length - maxChars;
|
|
7670
|
+
if (text[start - 1] !== "\n") {
|
|
7671
|
+
const lineEnd = text.indexOf("\n", start);
|
|
7672
|
+
if (lineEnd !== -1 && lineEnd < text.length - 1) return text.slice(lineEnd + 1);
|
|
7673
|
+
const code = text.charCodeAt(start);
|
|
7674
|
+
if (code >= 56320 && code <= 57343) start += 1;
|
|
7675
|
+
for (const marker of REDACTION_MARKERS) {
|
|
7676
|
+
const at = text.lastIndexOf(marker, start);
|
|
7677
|
+
if (at !== -1 && at < start && start < at + marker.length) start = at + marker.length;
|
|
7678
|
+
}
|
|
7679
|
+
}
|
|
7680
|
+
return text.slice(start);
|
|
7681
|
+
};
|
|
7682
|
+
var settledExitCode = async (exited) => {
|
|
7683
|
+
if (exited === void 0) return void 0;
|
|
7684
|
+
let timer;
|
|
7685
|
+
try {
|
|
7686
|
+
return await Promise.race([
|
|
7687
|
+
exited.catch(() => void 0),
|
|
7688
|
+
new Promise((resolve4) => {
|
|
7689
|
+
timer = setTimeout(() => resolve4(void 0), AGENT_EXIT_SETTLE_MS);
|
|
7690
|
+
})
|
|
7691
|
+
]);
|
|
7692
|
+
} finally {
|
|
7693
|
+
clearTimeout(timer);
|
|
7694
|
+
}
|
|
7695
|
+
};
|
|
7696
|
+
async function describeAgentExit(input2) {
|
|
7697
|
+
const [exitCode, tail] = await Promise.all([
|
|
7698
|
+
settledExitCode(input2.exited),
|
|
7699
|
+
input2.stderrTail === void 0 ? "" : Promise.resolve().then(input2.stderrTail).catch(() => "")
|
|
7700
|
+
]);
|
|
7701
|
+
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}.`;
|
|
7702
|
+
const excerpt = lastLines(tail.trim(), AGENT_EXIT_STDERR_MAX_CHARS);
|
|
7703
|
+
return new AcpAgentExitedError(
|
|
7704
|
+
excerpt.length === 0 ? head : `${head}
|
|
7705
|
+
Agent stderr (last lines):
|
|
7706
|
+
${excerpt}`,
|
|
7707
|
+
exitCode,
|
|
7708
|
+
input2.cause
|
|
7709
|
+
);
|
|
7710
|
+
}
|
|
7653
7711
|
|
|
7654
7712
|
// ../../packages/ycodium-acp-executor/src/event-stream.ts
|
|
7655
7713
|
var UnboundedEventStream = class {
|
|
@@ -32608,7 +32666,8 @@ function createAcpConnection(options) {
|
|
|
32608
32666
|
options.onInboundFailure?.(error62);
|
|
32609
32667
|
void shutdown(
|
|
32610
32668
|
new AcpConnectionClosedError(
|
|
32611
|
-
`ACP inbound handling failed: ${error62 instanceof Error ? error62.message : String(error62)}
|
|
32669
|
+
`ACP inbound handling failed: ${error62 instanceof Error ? error62.message : String(error62)}`,
|
|
32670
|
+
{ reason: "inbound-failed" }
|
|
32612
32671
|
)
|
|
32613
32672
|
);
|
|
32614
32673
|
};
|
|
@@ -32653,19 +32712,21 @@ function createAcpConnection(options) {
|
|
|
32653
32712
|
} finally {
|
|
32654
32713
|
endInboundBatch();
|
|
32655
32714
|
}
|
|
32656
|
-
await shutdown(
|
|
32715
|
+
await shutdown(
|
|
32716
|
+
new AcpConnectionClosedError("ACP input stream ended", { reason: "input-ended" })
|
|
32717
|
+
);
|
|
32657
32718
|
});
|
|
32658
32719
|
};
|
|
32659
32720
|
const onError = (error62) => {
|
|
32660
32721
|
enqueueInbound(async () => {
|
|
32661
32722
|
await shutdown(
|
|
32662
|
-
error62 instanceof Error ? error62 : new AcpConnectionClosedError("ACP input stream error")
|
|
32723
|
+
error62 instanceof Error ? error62 : new AcpConnectionClosedError("ACP input stream error", { reason: "stream-error" })
|
|
32663
32724
|
);
|
|
32664
32725
|
});
|
|
32665
32726
|
};
|
|
32666
32727
|
const onWritableError = (error62) => {
|
|
32667
32728
|
void shutdown(
|
|
32668
|
-
error62 instanceof Error ? error62 : new AcpConnectionClosedError("ACP output stream error")
|
|
32729
|
+
error62 instanceof Error ? error62 : new AcpConnectionClosedError("ACP output stream error", { reason: "stream-error" })
|
|
32669
32730
|
);
|
|
32670
32731
|
};
|
|
32671
32732
|
options.readable.on("data", onData);
|
|
@@ -32728,7 +32789,8 @@ function createAcpConnection(options) {
|
|
|
32728
32789
|
awaitInboundIdle,
|
|
32729
32790
|
abandonPending,
|
|
32730
32791
|
close,
|
|
32731
|
-
closed
|
|
32792
|
+
closed,
|
|
32793
|
+
closeError: () => closedError
|
|
32732
32794
|
};
|
|
32733
32795
|
}
|
|
32734
32796
|
|
|
@@ -33137,7 +33199,8 @@ var ACP_FAILURE_CATEGORIES = [
|
|
|
33137
33199
|
"auth",
|
|
33138
33200
|
"model-unavailable",
|
|
33139
33201
|
"transport",
|
|
33140
|
-
"unknown"
|
|
33202
|
+
"unknown",
|
|
33203
|
+
"process-exit"
|
|
33141
33204
|
];
|
|
33142
33205
|
var isAcpFailureCategory = (value) => ACP_FAILURE_CATEGORIES.some((category) => category === value);
|
|
33143
33206
|
var readAcpFailureCategory = (error62) => {
|
|
@@ -33147,11 +33210,14 @@ var readAcpFailureCategory = (error62) => {
|
|
|
33147
33210
|
};
|
|
33148
33211
|
var withFailureCategory = (error62, category) => category === void 0 ? error62 : Object.assign(error62, { failureCategory: category });
|
|
33149
33212
|
var failureCategoryField = (category) => category === void 0 ? {} : { failureCategory: category };
|
|
33150
|
-
var
|
|
33213
|
+
var acpClosedConnectionCategory = (closeError, sessionEstablished, disposed) => {
|
|
33214
|
+
if (!sessionEstablished || disposed) return void 0;
|
|
33215
|
+
return closeError instanceof AcpConnectionClosedError && closeError.reason === "input-ended" ? "process-exit" : "transport";
|
|
33216
|
+
};
|
|
33151
33217
|
var acpPromptFailureCategory = (error62, input2) => {
|
|
33152
33218
|
const signaled = readAcpFailureCategory(error62);
|
|
33153
33219
|
if (signaled !== void 0) return signaled;
|
|
33154
|
-
return error62 instanceof AcpConnectionClosedError ?
|
|
33220
|
+
return error62 instanceof AcpConnectionClosedError ? acpClosedConnectionCategory(error62, input2.sessionEstablished, input2.disposed) : void 0;
|
|
33155
33221
|
};
|
|
33156
33222
|
|
|
33157
33223
|
// ../../packages/ycodium-acp-executor/src/tool-subagents.ts
|
|
@@ -33166,7 +33232,7 @@ var sealedHidden = (entry) => ({
|
|
|
33166
33232
|
});
|
|
33167
33233
|
function toolSubagentSettlementOfTurn(state, failureCategory) {
|
|
33168
33234
|
if (state === "cancelled") return "turn-interrupted";
|
|
33169
|
-
return state === "failed" && failureCategory === "
|
|
33235
|
+
return state === "failed" && failureCategory === "process-exit" ? "session-ended" : "turn-ended";
|
|
33170
33236
|
}
|
|
33171
33237
|
var sameFacts = (a, b) => a.title === b.title && a.description === b.description && a.summary === b.summary && a.role === b.role && a.model === b.model && a.effort === b.effort && a.rosterKind === b.rosterKind;
|
|
33172
33238
|
function linkage(taskId, toolCallId, facts) {
|
|
@@ -33783,14 +33849,19 @@ function createExecutorPrompt({
|
|
|
33783
33849
|
},
|
|
33784
33850
|
record2
|
|
33785
33851
|
);
|
|
33786
|
-
} catch (
|
|
33852
|
+
} catch (caught) {
|
|
33787
33853
|
if (shared.disposed) {
|
|
33788
33854
|
throw new AcpExecutorDisposedError();
|
|
33789
33855
|
}
|
|
33790
|
-
const failureCategory = acpPromptFailureCategory(
|
|
33856
|
+
const failureCategory = acpPromptFailureCategory(caught, {
|
|
33791
33857
|
sessionEstablished: shared.startResult !== void 0,
|
|
33792
33858
|
disposed: shared.disposed
|
|
33793
33859
|
});
|
|
33860
|
+
const error62 = failureCategory === "process-exit" && !interruptedTurnIds.has(turnId) ? await describeAgentExit({
|
|
33861
|
+
cause: caught,
|
|
33862
|
+
exited: options.exited,
|
|
33863
|
+
stderrTail: options.stderrTail
|
|
33864
|
+
}) : caught;
|
|
33794
33865
|
if (!interruptedTurnIds.has(turnId)) {
|
|
33795
33866
|
const errorMessage = error62 instanceof Error && error62.message.trim() || "ACP prompt failed";
|
|
33796
33867
|
if (settle2({
|
|
@@ -35126,24 +35197,40 @@ function createExecutorUpdates({
|
|
|
35126
35197
|
return;
|
|
35127
35198
|
}
|
|
35128
35199
|
};
|
|
35129
|
-
const
|
|
35130
|
-
for (const
|
|
35200
|
+
const emitHookEvents = (hookEvents) => {
|
|
35201
|
+
for (const hookEvent of hookEvents ?? []) {
|
|
35202
|
+
if (hookEvent.type === "runtime.warning") {
|
|
35203
|
+
const message = hookEvent.payload.message.trim();
|
|
35204
|
+
if (message.length === 0) continue;
|
|
35205
|
+
emit({
|
|
35206
|
+
type: "runtime.warning",
|
|
35207
|
+
...stamp(),
|
|
35208
|
+
provider: options.provider,
|
|
35209
|
+
threadId: options.threadId,
|
|
35210
|
+
...hookEvent.turnId !== void 0 ? { turnId: hookEvent.turnId } : {},
|
|
35211
|
+
payload: {
|
|
35212
|
+
message,
|
|
35213
|
+
...hookEvent.payload.detail !== void 0 ? { detail: hookEvent.payload.detail } : {}
|
|
35214
|
+
}
|
|
35215
|
+
});
|
|
35216
|
+
continue;
|
|
35217
|
+
}
|
|
35131
35218
|
emit({
|
|
35132
|
-
type:
|
|
35219
|
+
type: hookEvent.type,
|
|
35133
35220
|
...stamp(),
|
|
35134
35221
|
provider: options.provider,
|
|
35135
35222
|
threadId: options.threadId,
|
|
35136
|
-
...
|
|
35137
|
-
payload:
|
|
35223
|
+
...hookEvent.turnId !== void 0 ? { turnId: hookEvent.turnId } : {},
|
|
35224
|
+
payload: hookEvent.payload
|
|
35138
35225
|
});
|
|
35139
35226
|
}
|
|
35140
35227
|
};
|
|
35141
35228
|
const toolSubagents = hooks.toolSubagents === void 0 ? void 0 : createToolSubagentTracker(hooks.toolSubagents);
|
|
35142
|
-
const settleToolSubagents = (settlement, turnId) =>
|
|
35229
|
+
const settleToolSubagents = (settlement, turnId) => emitHookEvents(toolSubagents?.settle(settlement, turnId));
|
|
35143
35230
|
const settleSessionEnded = () => {
|
|
35144
35231
|
settleToolSubagents("session-ended");
|
|
35145
|
-
|
|
35146
|
-
|
|
35232
|
+
emitHookEvents(subagentSessions?.settleSessionEnded());
|
|
35233
|
+
emitHookEvents(hooks.onSessionEnded?.());
|
|
35147
35234
|
};
|
|
35148
35235
|
const observeContext = () => ({
|
|
35149
35236
|
turnId: shared.activeTurnId,
|
|
@@ -35205,7 +35292,7 @@ function createExecutorUpdates({
|
|
|
35205
35292
|
};
|
|
35206
35293
|
const hookResult = call === void 0 ? void 0 : toolSubagents?.onToolCallUpdated(call) ?? hooks.onToolCallUpdated?.(call);
|
|
35207
35294
|
const handledByHook = hookResult !== void 0 && "events" in hookResult && hookResult.handled === true;
|
|
35208
|
-
|
|
35295
|
+
emitHookEvents(
|
|
35209
35296
|
hookResult === void 0 ? [] : "events" in hookResult ? hookResult.events : hookResult
|
|
35210
35297
|
);
|
|
35211
35298
|
if (nextToolCall.status === "completed" && hookResult && "artifacts" in hookResult)
|
|
@@ -35302,7 +35389,7 @@ function createExecutorUpdates({
|
|
|
35302
35389
|
};
|
|
35303
35390
|
const receiveSessionUpdate = (params) => {
|
|
35304
35391
|
const foreign = !shared.ownSessionIds.has(params.sessionId) && (shared.childSessions.has(params.sessionId) || shared.sessionOpensInFlight === 0 && shared.ownSessionIds.size > 0);
|
|
35305
|
-
|
|
35392
|
+
emitHookEvents(
|
|
35306
35393
|
subagentSessions?.observe(params, {
|
|
35307
35394
|
turnId: shared.activeTurnId,
|
|
35308
35395
|
foreign,
|
|
@@ -35312,7 +35399,7 @@ function createExecutorUpdates({
|
|
|
35312
35399
|
);
|
|
35313
35400
|
if (!shared.sessionLoadInFlight) {
|
|
35314
35401
|
if (hooks.onSessionUpdate) {
|
|
35315
|
-
|
|
35402
|
+
emitHookEvents(hooks.onSessionUpdate(params, { ...observeContext(), foreign }));
|
|
35316
35403
|
}
|
|
35317
35404
|
}
|
|
35318
35405
|
if (!foreign) handleSessionUpdate(params);
|
|
@@ -35320,7 +35407,7 @@ function createExecutorUpdates({
|
|
|
35320
35407
|
const receiveExtensionNotification = (method, params) => {
|
|
35321
35408
|
if (shared.sessionLoadInFlight || !hooks.onExtensionNotification) return;
|
|
35322
35409
|
const result = hooks.onExtensionNotification(method, params, observeContext());
|
|
35323
|
-
if (Array.isArray(result))
|
|
35410
|
+
if (Array.isArray(result)) emitHookEvents(result);
|
|
35324
35411
|
};
|
|
35325
35412
|
return {
|
|
35326
35413
|
emitCompactionState,
|
|
@@ -35615,7 +35702,11 @@ function createAcpExecutor(options) {
|
|
|
35615
35702
|
settleAllUserInputs();
|
|
35616
35703
|
abortPendingSettlement(
|
|
35617
35704
|
"connection closed",
|
|
35618
|
-
|
|
35705
|
+
acpClosedConnectionCategory(
|
|
35706
|
+
connection.closeError(),
|
|
35707
|
+
shared.startResult !== void 0,
|
|
35708
|
+
shared.disposed
|
|
35709
|
+
)
|
|
35619
35710
|
);
|
|
35620
35711
|
shared.promptWaiters.splice(0).forEach((wake) => wake());
|
|
35621
35712
|
},
|
|
@@ -36947,6 +37038,7 @@ var createDshInstance = (config2, host) => {
|
|
|
36947
37038
|
readable: readable2,
|
|
36948
37039
|
writable,
|
|
36949
37040
|
stderrTail,
|
|
37041
|
+
exited: handle.exited,
|
|
36950
37042
|
cwd,
|
|
36951
37043
|
threadId: input2.threadId,
|
|
36952
37044
|
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.4368",
|
|
4
4
|
"description": "DeepSeek Harness executor: dsh CLI over Agent Client Protocol stdio.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -22,9 +22,9 @@
|
|
|
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.
|
|
25
|
+
"@ycodium-ai/plugin-api": "0.2.4368",
|
|
26
26
|
"ycodium-executor-testing": "0.0.0",
|
|
27
|
-
"ycodium-acp-executor": "0.2.
|
|
27
|
+
"ycodium-acp-executor": "0.2.4368"
|
|
28
28
|
},
|
|
29
29
|
"ycodium": {
|
|
30
30
|
"plugin": "./dist/index.js",
|