@ycodium-ai/agent-kimi 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/index.ts
|
|
14
14
|
import * as NodeOS6 from "node:os";
|
|
@@ -253,9 +253,11 @@ var AcpExecutorRequestError = class extends AcpExecutorError {
|
|
|
253
253
|
}
|
|
254
254
|
};
|
|
255
255
|
var AcpConnectionClosedError = class extends Error {
|
|
256
|
+
reason;
|
|
256
257
|
constructor(message = "ACP connection closed", options) {
|
|
257
|
-
super(message, options);
|
|
258
|
+
super(message, options?.cause === void 0 ? void 0 : { cause: options.cause });
|
|
258
259
|
this.name = "AcpConnectionClosedError";
|
|
260
|
+
this.reason = options?.reason ?? "closed";
|
|
259
261
|
}
|
|
260
262
|
};
|
|
261
263
|
async function withStartupStderr(error62, stderrTail) {
|
|
@@ -265,9 +267,65 @@ async function withStartupStderr(error62, stderrTail) {
|
|
|
265
267
|
return new AcpConnectionClosedError(`${error62.message}
|
|
266
268
|
Agent stderr (last lines):
|
|
267
269
|
${tail}`, {
|
|
268
|
-
cause: error62
|
|
270
|
+
cause: error62,
|
|
271
|
+
reason: error62.reason
|
|
269
272
|
});
|
|
270
273
|
}
|
|
274
|
+
var AGENT_EXIT_STDERR_MAX_CHARS = 800;
|
|
275
|
+
var AGENT_EXIT_SETTLE_MS = 500;
|
|
276
|
+
var AcpAgentExitedError = class extends AcpConnectionClosedError {
|
|
277
|
+
exitCode;
|
|
278
|
+
constructor(message, exitCode, cause) {
|
|
279
|
+
super(message, { cause, reason: "input-ended" });
|
|
280
|
+
this.name = "AcpAgentExitedError";
|
|
281
|
+
this.exitCode = exitCode;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
var REDACTION_MARKERS = ["[redacted]", "[pairing-url]"];
|
|
285
|
+
var lastLines = (text, maxChars) => {
|
|
286
|
+
if (text.length <= maxChars) return text;
|
|
287
|
+
let start = text.length - maxChars;
|
|
288
|
+
if (text[start - 1] !== "\n") {
|
|
289
|
+
const lineEnd = text.indexOf("\n", start);
|
|
290
|
+
if (lineEnd !== -1 && lineEnd < text.length - 1) return text.slice(lineEnd + 1);
|
|
291
|
+
const code = text.charCodeAt(start);
|
|
292
|
+
if (code >= 56320 && code <= 57343) start += 1;
|
|
293
|
+
for (const marker of REDACTION_MARKERS) {
|
|
294
|
+
const at = text.lastIndexOf(marker, start);
|
|
295
|
+
if (at !== -1 && at < start && start < at + marker.length) start = at + marker.length;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return text.slice(start);
|
|
299
|
+
};
|
|
300
|
+
var settledExitCode = async (exited) => {
|
|
301
|
+
if (exited === void 0) return void 0;
|
|
302
|
+
let timer;
|
|
303
|
+
try {
|
|
304
|
+
return await Promise.race([
|
|
305
|
+
exited.catch(() => void 0),
|
|
306
|
+
new Promise((resolve4) => {
|
|
307
|
+
timer = setTimeout(() => resolve4(void 0), AGENT_EXIT_SETTLE_MS);
|
|
308
|
+
})
|
|
309
|
+
]);
|
|
310
|
+
} finally {
|
|
311
|
+
clearTimeout(timer);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
async function describeAgentExit(input2) {
|
|
315
|
+
const [exitCode, tail] = await Promise.all([
|
|
316
|
+
settledExitCode(input2.exited),
|
|
317
|
+
input2.stderrTail === void 0 ? "" : Promise.resolve().then(input2.stderrTail).catch(() => "")
|
|
318
|
+
]);
|
|
319
|
+
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}.`;
|
|
320
|
+
const excerpt = lastLines(tail.trim(), AGENT_EXIT_STDERR_MAX_CHARS);
|
|
321
|
+
return new AcpAgentExitedError(
|
|
322
|
+
excerpt.length === 0 ? head : `${head}
|
|
323
|
+
Agent stderr (last lines):
|
|
324
|
+
${excerpt}`,
|
|
325
|
+
exitCode,
|
|
326
|
+
input2.cause
|
|
327
|
+
);
|
|
328
|
+
}
|
|
271
329
|
|
|
272
330
|
// ../../packages/ycodium-acp-executor/src/event-stream.ts
|
|
273
331
|
var UnboundedEventStream = class {
|
|
@@ -25202,7 +25260,8 @@ function createAcpConnection(options) {
|
|
|
25202
25260
|
options.onInboundFailure?.(error62);
|
|
25203
25261
|
void shutdown(
|
|
25204
25262
|
new AcpConnectionClosedError(
|
|
25205
|
-
`ACP inbound handling failed: ${error62 instanceof Error ? error62.message : String(error62)}
|
|
25263
|
+
`ACP inbound handling failed: ${error62 instanceof Error ? error62.message : String(error62)}`,
|
|
25264
|
+
{ reason: "inbound-failed" }
|
|
25206
25265
|
)
|
|
25207
25266
|
);
|
|
25208
25267
|
};
|
|
@@ -25247,19 +25306,21 @@ function createAcpConnection(options) {
|
|
|
25247
25306
|
} finally {
|
|
25248
25307
|
endInboundBatch();
|
|
25249
25308
|
}
|
|
25250
|
-
await shutdown(
|
|
25309
|
+
await shutdown(
|
|
25310
|
+
new AcpConnectionClosedError("ACP input stream ended", { reason: "input-ended" })
|
|
25311
|
+
);
|
|
25251
25312
|
});
|
|
25252
25313
|
};
|
|
25253
25314
|
const onError = (error62) => {
|
|
25254
25315
|
enqueueInbound(async () => {
|
|
25255
25316
|
await shutdown(
|
|
25256
|
-
error62 instanceof Error ? error62 : new AcpConnectionClosedError("ACP input stream error")
|
|
25317
|
+
error62 instanceof Error ? error62 : new AcpConnectionClosedError("ACP input stream error", { reason: "stream-error" })
|
|
25257
25318
|
);
|
|
25258
25319
|
});
|
|
25259
25320
|
};
|
|
25260
25321
|
const onWritableError = (error62) => {
|
|
25261
25322
|
void shutdown(
|
|
25262
|
-
error62 instanceof Error ? error62 : new AcpConnectionClosedError("ACP output stream error")
|
|
25323
|
+
error62 instanceof Error ? error62 : new AcpConnectionClosedError("ACP output stream error", { reason: "stream-error" })
|
|
25263
25324
|
);
|
|
25264
25325
|
};
|
|
25265
25326
|
options.readable.on("data", onData);
|
|
@@ -25322,7 +25383,8 @@ function createAcpConnection(options) {
|
|
|
25322
25383
|
awaitInboundIdle,
|
|
25323
25384
|
abandonPending,
|
|
25324
25385
|
close,
|
|
25325
|
-
closed
|
|
25386
|
+
closed,
|
|
25387
|
+
closeError: () => closedError
|
|
25326
25388
|
};
|
|
25327
25389
|
}
|
|
25328
25390
|
|
|
@@ -25731,7 +25793,8 @@ var ACP_FAILURE_CATEGORIES = [
|
|
|
25731
25793
|
"auth",
|
|
25732
25794
|
"model-unavailable",
|
|
25733
25795
|
"transport",
|
|
25734
|
-
"unknown"
|
|
25796
|
+
"unknown",
|
|
25797
|
+
"process-exit"
|
|
25735
25798
|
];
|
|
25736
25799
|
var isAcpFailureCategory = (value) => ACP_FAILURE_CATEGORIES.some((category) => category === value);
|
|
25737
25800
|
var readAcpFailureCategory = (error62) => {
|
|
@@ -25741,11 +25804,14 @@ var readAcpFailureCategory = (error62) => {
|
|
|
25741
25804
|
};
|
|
25742
25805
|
var withFailureCategory = (error62, category) => category === void 0 ? error62 : Object.assign(error62, { failureCategory: category });
|
|
25743
25806
|
var failureCategoryField = (category) => category === void 0 ? {} : { failureCategory: category };
|
|
25744
|
-
var
|
|
25807
|
+
var acpClosedConnectionCategory = (closeError, sessionEstablished, disposed) => {
|
|
25808
|
+
if (!sessionEstablished || disposed) return void 0;
|
|
25809
|
+
return closeError instanceof AcpConnectionClosedError && closeError.reason === "input-ended" ? "process-exit" : "transport";
|
|
25810
|
+
};
|
|
25745
25811
|
var acpPromptFailureCategory = (error62, input2) => {
|
|
25746
25812
|
const signaled = readAcpFailureCategory(error62);
|
|
25747
25813
|
if (signaled !== void 0) return signaled;
|
|
25748
|
-
return error62 instanceof AcpConnectionClosedError ?
|
|
25814
|
+
return error62 instanceof AcpConnectionClosedError ? acpClosedConnectionCategory(error62, input2.sessionEstablished, input2.disposed) : void 0;
|
|
25749
25815
|
};
|
|
25750
25816
|
|
|
25751
25817
|
// ../../packages/ycodium-acp-executor/src/tool-subagents.ts
|
|
@@ -25760,7 +25826,7 @@ var sealedHidden = (entry) => ({
|
|
|
25760
25826
|
});
|
|
25761
25827
|
function toolSubagentSettlementOfTurn(state, failureCategory) {
|
|
25762
25828
|
if (state === "cancelled") return "turn-interrupted";
|
|
25763
|
-
return state === "failed" && failureCategory === "
|
|
25829
|
+
return state === "failed" && failureCategory === "process-exit" ? "session-ended" : "turn-ended";
|
|
25764
25830
|
}
|
|
25765
25831
|
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;
|
|
25766
25832
|
function linkage(taskId, toolCallId, facts) {
|
|
@@ -26377,14 +26443,19 @@ function createExecutorPrompt({
|
|
|
26377
26443
|
},
|
|
26378
26444
|
record2
|
|
26379
26445
|
);
|
|
26380
|
-
} catch (
|
|
26446
|
+
} catch (caught) {
|
|
26381
26447
|
if (shared.disposed) {
|
|
26382
26448
|
throw new AcpExecutorDisposedError();
|
|
26383
26449
|
}
|
|
26384
|
-
const failureCategory = acpPromptFailureCategory(
|
|
26450
|
+
const failureCategory = acpPromptFailureCategory(caught, {
|
|
26385
26451
|
sessionEstablished: shared.startResult !== void 0,
|
|
26386
26452
|
disposed: shared.disposed
|
|
26387
26453
|
});
|
|
26454
|
+
const error62 = failureCategory === "process-exit" && !interruptedTurnIds.has(turnId) ? await describeAgentExit({
|
|
26455
|
+
cause: caught,
|
|
26456
|
+
exited: options.exited,
|
|
26457
|
+
stderrTail: options.stderrTail
|
|
26458
|
+
}) : caught;
|
|
26388
26459
|
if (!interruptedTurnIds.has(turnId)) {
|
|
26389
26460
|
const errorMessage = error62 instanceof Error && error62.message.trim() || "ACP prompt failed";
|
|
26390
26461
|
if (settle2({
|
|
@@ -28227,7 +28298,11 @@ function createAcpExecutor(options) {
|
|
|
28227
28298
|
settleAllUserInputs();
|
|
28228
28299
|
abortPendingSettlement(
|
|
28229
28300
|
"connection closed",
|
|
28230
|
-
|
|
28301
|
+
acpClosedConnectionCategory(
|
|
28302
|
+
connection.closeError(),
|
|
28303
|
+
shared.startResult !== void 0,
|
|
28304
|
+
shared.disposed
|
|
28305
|
+
)
|
|
28231
28306
|
);
|
|
28232
28307
|
shared.promptWaiters.splice(0).forEach((wake) => wake());
|
|
28233
28308
|
},
|
|
@@ -29706,6 +29781,7 @@ var createKimiInstance = (config2, host) => {
|
|
|
29706
29781
|
readable,
|
|
29707
29782
|
writable,
|
|
29708
29783
|
stderrTail,
|
|
29784
|
+
exited: handle.exited,
|
|
29709
29785
|
...requestedEffort === void 0 ? {} : { requestedEffort },
|
|
29710
29786
|
cwd,
|
|
29711
29787
|
threadId: input2.threadId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/agent-kimi",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4351",
|
|
4
4
|
"description": "Kimi Code executor: runs `kimi acp` over Agent Client Protocol stdio.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -21,8 +21,8 @@
|
|
|
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-acp-executor": "0.2.
|
|
24
|
+
"@ycodium-ai/plugin-api": "0.2.4351",
|
|
25
|
+
"ycodium-acp-executor": "0.2.4351",
|
|
26
26
|
"ycodium-executor-testing": "0.0.0"
|
|
27
27
|
},
|
|
28
28
|
"ycodium": {
|