@ycodium-ai/agent-kimi 0.2.3766 → 0.2.3851

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 +43 -30
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -26065,6 +26065,7 @@ function createExecutorPrompt({
26065
26065
  promptResults,
26066
26066
  settleToolSubagents
26067
26067
  }) {
26068
+ const ownOutcomes = /* @__PURE__ */ new Map();
26068
26069
  const settleTurn = (input2) => {
26069
26070
  if (!isLive(input2.expectedGeneration) || input2.record.finished) {
26070
26071
  return false;
@@ -26081,14 +26082,22 @@ function createExecutorPrompt({
26081
26082
  }
26082
26083
  closeActiveAssistantSegment(input2.turnId);
26083
26084
  shared.promptsInFlight = Math.max(0, shared.promptsInFlight - 1);
26084
- if (shared.promptsInFlight !== 0 || shared.activeTurnId !== input2.turnId) return false;
26085
+ if (shared.promptsInFlight !== 0 || shared.activeTurnId !== input2.turnId) {
26086
+ if (input2.foldedIn !== true) ownOutcomes.set(input2.turnId, input2);
26087
+ return false;
26088
+ }
26089
+ const outcome = (input2.foldedIn === true ? ownOutcomes.get(input2.turnId) : void 0) ?? input2;
26090
+ ownOutcomes.delete(input2.turnId);
26085
26091
  shared.activeTurnId = void 0;
26086
26092
  if (shared.status !== "disposed") {
26087
26093
  shared.status = "ready";
26088
26094
  }
26089
26095
  const interrupted = promptResults.hasInterrupted(input2.turnId);
26090
26096
  settleToolSubagents(
26091
- toolSubagentSettlementOfTurn(interrupted ? "cancelled" : input2.state, input2.failureCategory),
26097
+ toolSubagentSettlementOfTurn(
26098
+ interrupted ? "cancelled" : outcome.state,
26099
+ outcome.failureCategory
26100
+ ),
26092
26101
  input2.turnId
26093
26102
  );
26094
26103
  emit({
@@ -26098,10 +26107,10 @@ function createExecutorPrompt({
26098
26107
  threadId: options.threadId,
26099
26108
  turnId: input2.turnId,
26100
26109
  payload: {
26101
- state: interrupted ? "cancelled" : input2.state,
26102
- stopReason: interrupted ? "cancelled" : input2.stopReason,
26103
- ...input2.errorMessage === void 0 ? {} : { errorMessage: input2.errorMessage },
26104
- ...input2.state === "failed" ? failureCategoryField(input2.failureCategory) : {}
26110
+ state: interrupted ? "cancelled" : outcome.state,
26111
+ stopReason: interrupted ? "cancelled" : outcome.stopReason,
26112
+ ...outcome.errorMessage === void 0 ? {} : { errorMessage: outcome.errorMessage },
26113
+ ...outcome.state === "failed" ? failureCategoryField(outcome.failureCategory) : {}
26105
26114
  }
26106
26115
  });
26107
26116
  interruptedTurnIds.delete(input2.turnId);
@@ -26126,7 +26135,7 @@ function createExecutorPrompt({
26126
26135
  return await promptRpc;
26127
26136
  } else {
26128
26137
  const { promise: early, resolve: settleEarly } = Promise.withResolvers();
26129
- shared.pendingSettlement = {
26138
+ shared.pendingSettlements.set(promptKey, {
26130
26139
  promptKey,
26131
26140
  sessionId,
26132
26141
  settle: settleEarly,
@@ -26135,7 +26144,7 @@ function createExecutorPrompt({
26135
26144
  onError: () => promptResults.reject(record2.promptId),
26136
26145
  hasResult: () => record2.response !== void 0
26137
26146
  }
26138
- };
26147
+ });
26139
26148
  try {
26140
26149
  const outcome = await Promise.race([
26141
26150
  promptRpc.then((value) => {
@@ -26148,7 +26157,7 @@ function createExecutorPrompt({
26148
26157
  if (outcome.error !== void 0) throw outcome.error;
26149
26158
  return outcome.response;
26150
26159
  } finally {
26151
- shared.pendingSettlement = void 0;
26160
+ shared.pendingSettlements.delete(promptKey);
26152
26161
  void promptRpc.catch(() => void 0);
26153
26162
  }
26154
26163
  }
@@ -26298,7 +26307,9 @@ function createExecutorPrompt({
26298
26307
  settle2({
26299
26308
  turnId,
26300
26309
  stopReason,
26301
- state: response2.stopReason === "cancelled" ? "cancelled" : "completed"
26310
+ state: response2.stopReason === "cancelled" ? "cancelled" : "completed",
26311
+ // 立刻写出的插话没被打断却应答 cancelled:agent 把它并进了这一轮(grok 的 removedFromQueue)。
26312
+ foldedIn: response2.stopReason === "cancelled" && input2.expectedActiveTurnId !== void 0 && hooks.queuesPromptsWhileRunning === true
26302
26313
  });
26303
26314
  return {
26304
26315
  threadId: options.threadId,
@@ -26307,7 +26318,8 @@ function createExecutorPrompt({
26307
26318
  ...response2.usage !== void 0 && response2.usage !== null ? { usage: response2.usage } : {}
26308
26319
  };
26309
26320
  };
26310
- await promptMutex.acquire();
26321
+ const writesWhileRunning = input2.expectedActiveTurnId !== void 0 && hooks.queuesPromptsWhileRunning === true;
26322
+ if (!writesWhileRunning) await promptMutex.acquire();
26311
26323
  let response;
26312
26324
  try {
26313
26325
  failIfDisposed();
@@ -26389,7 +26401,7 @@ function createExecutorPrompt({
26389
26401
  await options.beforeApplyResult();
26390
26402
  }
26391
26403
  } finally {
26392
- promptMutex.release();
26404
+ if (!writesWhileRunning) promptMutex.release();
26393
26405
  notifyPromptSettled();
26394
26406
  }
26395
26407
  if (!isLive(started.generation)) {
@@ -27450,28 +27462,29 @@ function createExecutorSettlement({
27450
27462
  if (settledPromptKeys.length > SETTLED_PROMPT_KEY_LIMIT) settledPromptKeys.shift();
27451
27463
  };
27452
27464
  const abortPendingSettlement = (reason, failureCategory) => {
27453
- const waiting = shared.pendingSettlement;
27454
- if (waiting === void 0) return;
27455
- if (waiting.hasResult?.()) return;
27456
- shared.pendingSettlement = void 0;
27457
- waiting.settle({
27458
- error: withFailureCategory(
27459
- new AcpExecutorRequestError("session/prompt", reason),
27460
- failureCategory
27461
- )
27462
- });
27465
+ for (const [key, waiting] of shared.pendingSettlements) {
27466
+ if (waiting.hasResult?.()) continue;
27467
+ shared.pendingSettlements.delete(key);
27468
+ waiting.settle({
27469
+ error: withFailureCategory(
27470
+ new AcpExecutorRequestError("session/prompt", reason),
27471
+ failureCategory
27472
+ )
27473
+ });
27474
+ }
27463
27475
  };
27464
27476
  const settleFromNotification = (method, params) => {
27465
27477
  const hook = hooks.promptSettlement;
27466
- if (hook === void 0 || shared.pendingSettlement === void 0) return false;
27478
+ if (hook === void 0 || shared.pendingSettlements.size === 0) return false;
27467
27479
  const signal = hook.fromNotification(method, params);
27468
27480
  if (signal === void 0) return false;
27469
- const waiting = shared.pendingSettlement;
27470
- if (signal.sessionId !== waiting.sessionId) return false;
27471
- if (signal.promptKey !== void 0 && signal.promptKey !== waiting.promptKey) {
27472
- return settledPromptKeys.includes(signal.promptKey);
27481
+ const waiting = signal.promptKey === void 0 ? [...shared.pendingSettlements.values()].find(
27482
+ (candidate) => candidate.sessionId === signal.sessionId
27483
+ ) : shared.pendingSettlements.get(signal.promptKey);
27484
+ if (waiting === void 0 || waiting.sessionId !== signal.sessionId) {
27485
+ return signal.promptKey !== void 0 && settledPromptKeys.includes(signal.promptKey);
27473
27486
  }
27474
- shared.pendingSettlement = void 0;
27487
+ shared.pendingSettlements.delete(waiting.promptKey);
27475
27488
  rememberSettledPromptKey(waiting.promptKey);
27476
27489
  if (signal.outcome === "error") {
27477
27490
  waiting.onError?.();
@@ -28065,7 +28078,7 @@ function createAcpExecutor(options) {
28065
28078
  startInFlight: void 0,
28066
28079
  activeTurnId: void 0,
28067
28080
  promptsInFlight: 0,
28068
- pendingSettlement: void 0,
28081
+ pendingSettlements: /* @__PURE__ */ new Map(),
28069
28082
  manualCompaction: void 0,
28070
28083
  assistantSegment: { nextSegmentIndex: 0 },
28071
28084
  modeState: void 0,
@@ -29930,7 +29943,7 @@ var executors = [
29930
29943
  ];
29931
29944
  var index_default = definePlugin({
29932
29945
  id: "agent-kimi",
29933
- apiVersion: 56,
29946
+ apiVersion: 63,
29934
29947
  executors,
29935
29948
  activate(ctx) {
29936
29949
  ctx.command({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-kimi",
3
- "version": "0.2.3766",
3
+ "version": "0.2.3851",
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-acp-executor": "0.2.3766",
24
+ "ycodium-acp-executor": "0.2.3851",
25
25
  "ycodium-executor-testing": "0.0.0",
26
- "@ycodium-ai/plugin-api": "0.2.3766"
26
+ "@ycodium-ai/plugin-api": "0.2.3851"
27
27
  },
28
28
  "ycodium": {
29
29
  "plugin": "./dist/index.js",