@ycodium-ai/agent-acp 0.2.4321 → 0.2.4351
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 +91 -15
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var __export = (target, all) => {
|
|
|
8
8
|
import { definePlugin } from "@ycodium-ai/plugin-api";
|
|
9
9
|
|
|
10
10
|
// ../../packages/plugin-api/src/version.ts
|
|
11
|
-
var PLUGIN_API_VERSION =
|
|
11
|
+
var PLUGIN_API_VERSION = 110;
|
|
12
12
|
|
|
13
13
|
// src/acpInstance.ts
|
|
14
14
|
import * as NodeOS3 from "node:os";
|
|
@@ -156,9 +156,11 @@ var AcpExecutorRequestError = class extends AcpExecutorError {
|
|
|
156
156
|
}
|
|
157
157
|
};
|
|
158
158
|
var AcpConnectionClosedError = class extends Error {
|
|
159
|
+
reason;
|
|
159
160
|
constructor(message = "ACP connection closed", options) {
|
|
160
|
-
super(message, options);
|
|
161
|
+
super(message, options?.cause === void 0 ? void 0 : { cause: options.cause });
|
|
161
162
|
this.name = "AcpConnectionClosedError";
|
|
163
|
+
this.reason = options?.reason ?? "closed";
|
|
162
164
|
}
|
|
163
165
|
};
|
|
164
166
|
async function withStartupStderr(error62, stderrTail) {
|
|
@@ -168,9 +170,65 @@ async function withStartupStderr(error62, stderrTail) {
|
|
|
168
170
|
return new AcpConnectionClosedError(`${error62.message}
|
|
169
171
|
Agent stderr (last lines):
|
|
170
172
|
${tail}`, {
|
|
171
|
-
cause: error62
|
|
173
|
+
cause: error62,
|
|
174
|
+
reason: error62.reason
|
|
172
175
|
});
|
|
173
176
|
}
|
|
177
|
+
var AGENT_EXIT_STDERR_MAX_CHARS = 800;
|
|
178
|
+
var AGENT_EXIT_SETTLE_MS = 500;
|
|
179
|
+
var AcpAgentExitedError = class extends AcpConnectionClosedError {
|
|
180
|
+
exitCode;
|
|
181
|
+
constructor(message, exitCode, cause) {
|
|
182
|
+
super(message, { cause, reason: "input-ended" });
|
|
183
|
+
this.name = "AcpAgentExitedError";
|
|
184
|
+
this.exitCode = exitCode;
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
var REDACTION_MARKERS = ["[redacted]", "[pairing-url]"];
|
|
188
|
+
var lastLines = (text, maxChars) => {
|
|
189
|
+
if (text.length <= maxChars) return text;
|
|
190
|
+
let start = text.length - maxChars;
|
|
191
|
+
if (text[start - 1] !== "\n") {
|
|
192
|
+
const lineEnd = text.indexOf("\n", start);
|
|
193
|
+
if (lineEnd !== -1 && lineEnd < text.length - 1) return text.slice(lineEnd + 1);
|
|
194
|
+
const code = text.charCodeAt(start);
|
|
195
|
+
if (code >= 56320 && code <= 57343) start += 1;
|
|
196
|
+
for (const marker of REDACTION_MARKERS) {
|
|
197
|
+
const at = text.lastIndexOf(marker, start);
|
|
198
|
+
if (at !== -1 && at < start && start < at + marker.length) start = at + marker.length;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return text.slice(start);
|
|
202
|
+
};
|
|
203
|
+
var settledExitCode = async (exited) => {
|
|
204
|
+
if (exited === void 0) return void 0;
|
|
205
|
+
let timer;
|
|
206
|
+
try {
|
|
207
|
+
return await Promise.race([
|
|
208
|
+
exited.catch(() => void 0),
|
|
209
|
+
new Promise((resolve2) => {
|
|
210
|
+
timer = setTimeout(() => resolve2(void 0), AGENT_EXIT_SETTLE_MS);
|
|
211
|
+
})
|
|
212
|
+
]);
|
|
213
|
+
} finally {
|
|
214
|
+
clearTimeout(timer);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
async function describeAgentExit(input2) {
|
|
218
|
+
const [exitCode, tail] = await Promise.all([
|
|
219
|
+
settledExitCode(input2.exited),
|
|
220
|
+
input2.stderrTail === void 0 ? "" : Promise.resolve().then(input2.stderrTail).catch(() => "")
|
|
221
|
+
]);
|
|
222
|
+
const head = exitCode === void 0 ? "The agent closed its connection." : exitCode === null ? "The agent process exited without an exit code." : `The agent process exited with code ${exitCode}.`;
|
|
223
|
+
const excerpt = lastLines(tail.trim(), AGENT_EXIT_STDERR_MAX_CHARS);
|
|
224
|
+
return new AcpAgentExitedError(
|
|
225
|
+
excerpt.length === 0 ? head : `${head}
|
|
226
|
+
Agent stderr (last lines):
|
|
227
|
+
${excerpt}`,
|
|
228
|
+
exitCode,
|
|
229
|
+
input2.cause
|
|
230
|
+
);
|
|
231
|
+
}
|
|
174
232
|
|
|
175
233
|
// ../../packages/ycodium-acp-executor/src/event-stream.ts
|
|
176
234
|
var UnboundedEventStream = class {
|
|
@@ -25151,7 +25209,8 @@ function createAcpConnection(options) {
|
|
|
25151
25209
|
options.onInboundFailure?.(error62);
|
|
25152
25210
|
void shutdown(
|
|
25153
25211
|
new AcpConnectionClosedError(
|
|
25154
|
-
`ACP inbound handling failed: ${error62 instanceof Error ? error62.message : String(error62)}
|
|
25212
|
+
`ACP inbound handling failed: ${error62 instanceof Error ? error62.message : String(error62)}`,
|
|
25213
|
+
{ reason: "inbound-failed" }
|
|
25155
25214
|
)
|
|
25156
25215
|
);
|
|
25157
25216
|
};
|
|
@@ -25196,19 +25255,21 @@ function createAcpConnection(options) {
|
|
|
25196
25255
|
} finally {
|
|
25197
25256
|
endInboundBatch();
|
|
25198
25257
|
}
|
|
25199
|
-
await shutdown(
|
|
25258
|
+
await shutdown(
|
|
25259
|
+
new AcpConnectionClosedError("ACP input stream ended", { reason: "input-ended" })
|
|
25260
|
+
);
|
|
25200
25261
|
});
|
|
25201
25262
|
};
|
|
25202
25263
|
const onError = (error62) => {
|
|
25203
25264
|
enqueueInbound(async () => {
|
|
25204
25265
|
await shutdown(
|
|
25205
|
-
error62 instanceof Error ? error62 : new AcpConnectionClosedError("ACP input stream error")
|
|
25266
|
+
error62 instanceof Error ? error62 : new AcpConnectionClosedError("ACP input stream error", { reason: "stream-error" })
|
|
25206
25267
|
);
|
|
25207
25268
|
});
|
|
25208
25269
|
};
|
|
25209
25270
|
const onWritableError = (error62) => {
|
|
25210
25271
|
void shutdown(
|
|
25211
|
-
error62 instanceof Error ? error62 : new AcpConnectionClosedError("ACP output stream error")
|
|
25272
|
+
error62 instanceof Error ? error62 : new AcpConnectionClosedError("ACP output stream error", { reason: "stream-error" })
|
|
25212
25273
|
);
|
|
25213
25274
|
};
|
|
25214
25275
|
options.readable.on("data", onData);
|
|
@@ -25271,7 +25332,8 @@ function createAcpConnection(options) {
|
|
|
25271
25332
|
awaitInboundIdle,
|
|
25272
25333
|
abandonPending,
|
|
25273
25334
|
close,
|
|
25274
|
-
closed
|
|
25335
|
+
closed,
|
|
25336
|
+
closeError: () => closedError
|
|
25275
25337
|
};
|
|
25276
25338
|
}
|
|
25277
25339
|
|
|
@@ -25680,7 +25742,8 @@ var ACP_FAILURE_CATEGORIES = [
|
|
|
25680
25742
|
"auth",
|
|
25681
25743
|
"model-unavailable",
|
|
25682
25744
|
"transport",
|
|
25683
|
-
"unknown"
|
|
25745
|
+
"unknown",
|
|
25746
|
+
"process-exit"
|
|
25684
25747
|
];
|
|
25685
25748
|
var isAcpFailureCategory = (value) => ACP_FAILURE_CATEGORIES.some((category) => category === value);
|
|
25686
25749
|
var readAcpFailureCategory = (error62) => {
|
|
@@ -25690,11 +25753,14 @@ var readAcpFailureCategory = (error62) => {
|
|
|
25690
25753
|
};
|
|
25691
25754
|
var withFailureCategory = (error62, category) => category === void 0 ? error62 : Object.assign(error62, { failureCategory: category });
|
|
25692
25755
|
var failureCategoryField = (category) => category === void 0 ? {} : { failureCategory: category };
|
|
25693
|
-
var
|
|
25756
|
+
var acpClosedConnectionCategory = (closeError, sessionEstablished, disposed) => {
|
|
25757
|
+
if (!sessionEstablished || disposed) return void 0;
|
|
25758
|
+
return closeError instanceof AcpConnectionClosedError && closeError.reason === "input-ended" ? "process-exit" : "transport";
|
|
25759
|
+
};
|
|
25694
25760
|
var acpPromptFailureCategory = (error62, input2) => {
|
|
25695
25761
|
const signaled = readAcpFailureCategory(error62);
|
|
25696
25762
|
if (signaled !== void 0) return signaled;
|
|
25697
|
-
return error62 instanceof AcpConnectionClosedError ?
|
|
25763
|
+
return error62 instanceof AcpConnectionClosedError ? acpClosedConnectionCategory(error62, input2.sessionEstablished, input2.disposed) : void 0;
|
|
25698
25764
|
};
|
|
25699
25765
|
|
|
25700
25766
|
// ../../packages/ycodium-acp-executor/src/tool-subagents.ts
|
|
@@ -25709,7 +25775,7 @@ var sealedHidden = (entry) => ({
|
|
|
25709
25775
|
});
|
|
25710
25776
|
function toolSubagentSettlementOfTurn(state, failureCategory) {
|
|
25711
25777
|
if (state === "cancelled") return "turn-interrupted";
|
|
25712
|
-
return state === "failed" && failureCategory === "
|
|
25778
|
+
return state === "failed" && failureCategory === "process-exit" ? "session-ended" : "turn-ended";
|
|
25713
25779
|
}
|
|
25714
25780
|
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;
|
|
25715
25781
|
function linkage(taskId, toolCallId, facts) {
|
|
@@ -26326,14 +26392,19 @@ function createExecutorPrompt({
|
|
|
26326
26392
|
},
|
|
26327
26393
|
record2
|
|
26328
26394
|
);
|
|
26329
|
-
} catch (
|
|
26395
|
+
} catch (caught) {
|
|
26330
26396
|
if (shared.disposed) {
|
|
26331
26397
|
throw new AcpExecutorDisposedError();
|
|
26332
26398
|
}
|
|
26333
|
-
const failureCategory = acpPromptFailureCategory(
|
|
26399
|
+
const failureCategory = acpPromptFailureCategory(caught, {
|
|
26334
26400
|
sessionEstablished: shared.startResult !== void 0,
|
|
26335
26401
|
disposed: shared.disposed
|
|
26336
26402
|
});
|
|
26403
|
+
const error62 = failureCategory === "process-exit" && !interruptedTurnIds.has(turnId) ? await describeAgentExit({
|
|
26404
|
+
cause: caught,
|
|
26405
|
+
exited: options.exited,
|
|
26406
|
+
stderrTail: options.stderrTail
|
|
26407
|
+
}) : caught;
|
|
26337
26408
|
if (!interruptedTurnIds.has(turnId)) {
|
|
26338
26409
|
const errorMessage = error62 instanceof Error && error62.message.trim() || "ACP prompt failed";
|
|
26339
26410
|
if (settle2({
|
|
@@ -28211,7 +28282,11 @@ function createAcpExecutor(options) {
|
|
|
28211
28282
|
settleAllUserInputs();
|
|
28212
28283
|
abortPendingSettlement(
|
|
28213
28284
|
"connection closed",
|
|
28214
|
-
|
|
28285
|
+
acpClosedConnectionCategory(
|
|
28286
|
+
connection.closeError(),
|
|
28287
|
+
shared.startResult !== void 0,
|
|
28288
|
+
shared.disposed
|
|
28289
|
+
)
|
|
28215
28290
|
);
|
|
28216
28291
|
shared.promptWaiters.splice(0).forEach((wake) => wake());
|
|
28217
28292
|
},
|
|
@@ -29125,6 +29200,7 @@ var createAcpInstance = (config2, host) => {
|
|
|
29125
29200
|
readable,
|
|
29126
29201
|
writable,
|
|
29127
29202
|
stderrTail,
|
|
29203
|
+
exited: handle.exited,
|
|
29128
29204
|
...requestedEffort === void 0 ? {} : { requestedEffort },
|
|
29129
29205
|
cwd,
|
|
29130
29206
|
threadId: input2.threadId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/agent-acp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4351",
|
|
4
4
|
"description": "Generic ACP executor: user-supplied 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.4351",
|
|
24
25
|
"ycodium-executor-testing": "0.0.0",
|
|
25
|
-
"
|
|
26
|
-
"ycodium-acp-executor": "0.2.4321"
|
|
26
|
+
"ycodium-acp-executor": "0.2.4351"
|
|
27
27
|
},
|
|
28
28
|
"ycodium": {
|
|
29
29
|
"plugin": "./dist/index.js",
|