@ycodium-ai/agent-kimi 0.2.2988 → 0.2.2990

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.
Files changed (2) hide show
  1. package/dist/index.js +27 -18
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -23502,6 +23502,12 @@ var AcpExecutorDisposedError = class extends AcpExecutorError {
23502
23502
  this.name = "AcpExecutorDisposedError";
23503
23503
  }
23504
23504
  };
23505
+ var AcpExecutorTurnEndedError = class extends AcpExecutorError {
23506
+ constructor(message = "The target turn has ended. The message was not sent.") {
23507
+ super("provider-rejected", message);
23508
+ this.name = "AcpExecutorTurnEndedError";
23509
+ }
23510
+ };
23505
23511
  var AcpExecutorNotStartedError = class extends AcpExecutorError {
23506
23512
  constructor(message = "ACP session has not been started") {
23507
23513
  super("not-started", message);
@@ -24267,6 +24273,12 @@ function asTrimmedString(value) {
24267
24273
  const trimmed = value.trim();
24268
24274
  return trimmed.length > 0 ? trimmed : void 0;
24269
24275
  }
24276
+ var selectPromptTurnId = (input2, activeTurnId, freshTurnId) => {
24277
+ const target = input2.expectedActiveTurnId;
24278
+ if (target === void 0) return input2.turnId ?? activeTurnId ?? freshTurnId();
24279
+ if (activeTurnId !== target) throw new AcpExecutorTurnEndedError();
24280
+ return target;
24281
+ };
24270
24282
 
24271
24283
  // ../../packages/ycodium-acp-executor/src/tool-presentation.ts
24272
24284
  function normalizeCommandValue(value) {
@@ -26369,7 +26381,7 @@ function createAcpExecutor(options) {
26369
26381
  await threadMutex.acquire();
26370
26382
  try {
26371
26383
  failIfDisposed();
26372
- turnId = input2.turnId ?? (promptsInFlight > 0 ? activeTurnId : void 0) ?? randomId();
26384
+ turnId = selectPromptTurnId(input2, promptsInFlight > 0 ? activeTurnId : void 0, randomId);
26373
26385
  promptsInFlight += 1;
26374
26386
  activeTurnId = turnId;
26375
26387
  status = "running";
@@ -26391,20 +26403,20 @@ function createAcpExecutor(options) {
26391
26403
  let response;
26392
26404
  try {
26393
26405
  failIfDisposed();
26394
- if (interruptedTurnIds.has(turnId)) {
26406
+ const queuedTurnId = turnId;
26407
+ const isStale = () => interruptedTurnIds.has(queuedTurnId) || input2.expectedActiveTurnId !== void 0 && activeTurnId !== queuedTurnId;
26408
+ if (!isStale()) {
26409
+ modelSelectionState = await applyRequestedModel({
26410
+ state: modelSelectionState,
26411
+ acpSessionId: started.sessionId,
26412
+ requestedModelId: input2.requestedModelId,
26413
+ expectedGeneration: started.generation
26414
+ });
26415
+ }
26416
+ if (isStale()) {
26395
26417
  settle2({ turnId, stopReason: "cancelled", state: "cancelled" });
26396
- return {
26397
- threadId: options.threadId,
26398
- turnId,
26399
- stopReason: "cancelled"
26400
- };
26418
+ return { threadId: options.threadId, turnId, stopReason: "cancelled" };
26401
26419
  }
26402
- modelSelectionState = await applyRequestedModel({
26403
- state: modelSelectionState,
26404
- acpSessionId: started.sessionId,
26405
- requestedModelId: input2.requestedModelId,
26406
- expectedGeneration: started.generation
26407
- });
26408
26420
  closeActiveAssistantSegment(turnId);
26409
26421
  let written = false;
26410
26422
  try {
@@ -26534,10 +26546,7 @@ function createAcpExecutor(options) {
26534
26546
  provider: options.provider,
26535
26547
  threadId: options.threadId,
26536
26548
  turnId: targetTurnId,
26537
- payload: {
26538
- state: "cancelled",
26539
- stopReason: "cancelled"
26540
- }
26549
+ payload: { state: "cancelled", stopReason: "cancelled" }
26541
26550
  });
26542
26551
  interruptedTurnIds.delete(targetTurnId);
26543
26552
  }
@@ -27930,7 +27939,7 @@ var createKimiInstance = (config2, host) => {
27930
27939
  const requestedModelId = modelIdFromSelection(input2.modelSelection);
27931
27940
  const turn = await dispatchAcpPrompt(booked.executor, {
27932
27941
  text: input2.input ?? "",
27933
- ...input2.expectedTurnId === void 0 ? {} : { turnId: input2.expectedTurnId },
27942
+ expectedActiveTurnId: input2.expectedTurnId,
27934
27943
  ...requestedModelId === void 0 ? {} : { requestedModelId }
27935
27944
  });
27936
27945
  booked.turns.push({ id: turn.turnId, items: [] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-kimi",
3
- "version": "0.2.2988",
3
+ "version": "0.2.2990",
4
4
  "description": "Kimi Code executor: runs `kimi acp` 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.2988",
25
- "ycodium-acp-executor": "0.2.2988",
26
- "ycodium-executor-testing": "0.0.0"
24
+ "ycodium-acp-executor": "0.2.2990",
25
+ "ycodium-executor-testing": "0.0.0",
26
+ "@ycodium-ai/plugin-api": "0.2.2990"
27
27
  },
28
28
  "ycodium": {
29
29
  "plugin": "./dist/index.js",