@ycodium-ai/agent-kimi 0.2.5374 → 0.2.5448

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 (3) hide show
  1. package/README.md +4 -0
  2. package/dist/index.js +190 -68
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -22,6 +22,10 @@ customModels } }`; launch arguments (`acp`) and the account-directory variable (
22
22
  and maintainer CLI verification.
23
23
  A selected native mode governs approvals. Without native modes, auto permits MCP dynamic tools
24
24
  (ACP kind `other` with an MCP name); questions and plan confirmations remain user input.
25
+ - Turn failures: Kimi 2.7.0 can return ACP `end_turn` after a provider error. The executor checks
26
+ the main agent’s newly appended `turn.prompt` and `turn.ended` records for the same native turn.
27
+ It waits up to one second for a delayed log flush. Missing or inconclusive records leave the ACP
28
+ result in effect. A confirmed quota error carries the provider’s message and the `quota` category.
25
29
  - Usage (ADR-0034), per instance, read only when the user asks. The account directory is the
26
30
  `homePath` setting, an explicit `KIMI_CODE_HOME` in the instance environment, then the process
27
31
  environment, then `~/.kimi-code`:
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 = 169;
11
+ var PLUGIN_API_VERSION = 171;
12
12
 
13
13
  // src/index.ts
14
14
  import * as NodeOS7 from "node:os";
@@ -204,7 +204,7 @@ function approvalOutcomeForDecision(decision, optionId) {
204
204
  var UnboundedEventStream = class {
205
205
  subscribers = /* @__PURE__ */ new Set();
206
206
  closed = false;
207
- publish(event) {
207
+ publish(event2) {
208
208
  if (this.closed) {
209
209
  return;
210
210
  }
@@ -212,7 +212,7 @@ var UnboundedEventStream = class {
212
212
  if (subscriber.closed) {
213
213
  continue;
214
214
  }
215
- subscriber.queue.push(event);
215
+ subscriber.queue.push(event2);
216
216
  const wake = subscriber.wake;
217
217
  if (wake) {
218
218
  subscriber.wake = void 0;
@@ -25126,8 +25126,8 @@ function createAcpConnection(options) {
25126
25126
  releaseIdleWaiters();
25127
25127
  }
25128
25128
  };
25129
- const log = (event) => {
25130
- options.logger?.(event);
25129
+ const log = (event2) => {
25130
+ options.logger?.(event2);
25131
25131
  };
25132
25132
  const writeMessage = async (message) => {
25133
25133
  log({ direction: "outgoing", stage: "decoded", payload: message });
@@ -25578,9 +25578,9 @@ function createExecutorLifecycle({
25578
25578
  if (targetTurnId !== void 0) {
25579
25579
  interruptedTurnIds.add(targetTurnId);
25580
25580
  }
25581
- const optionWrites = shared.optionWriteStop;
25582
- if (optionWrites !== void 0 && (targetTurnId === void 0 || optionWrites.turnId === targetTurnId)) {
25583
- optionWrites.stop();
25581
+ const waiting = shared.localPromptWait;
25582
+ if (waiting !== void 0 && (targetTurnId === void 0 || waiting.turnId === targetTurnId)) {
25583
+ waiting.stop();
25584
25584
  }
25585
25585
  settleAllApprovals("cancel");
25586
25586
  settleAllUserInputs();
@@ -25693,6 +25693,7 @@ function createExecutorLifecycle({
25693
25693
  if (disposing) return disposing;
25694
25694
  shared.disposing = true;
25695
25695
  disposing = (async () => {
25696
+ shared.localPromptWait?.stop();
25696
25697
  if (exitCode !== void 0) {
25697
25698
  let timer;
25698
25699
  await Promise.race([
@@ -26442,7 +26443,7 @@ function createExecutorPrompt({
26442
26443
  const isStale = () => interruptedTurnIds.has(queuedTurnId) || input2.expectedActiveTurnId !== void 0 && shared.activeTurnId !== queuedTurnId;
26443
26444
  if (!isStale() && input2.expectedActiveTurnId === void 0) {
26444
26445
  const optionWrites = new AbortController();
26445
- shared.optionWriteStop = { turnId, stop: () => optionWrites.abort() };
26446
+ shared.localPromptWait = { turnId, stop: () => optionWrites.abort() };
26446
26447
  try {
26447
26448
  await alignTurnOptions(
26448
26449
  input2,
@@ -26467,7 +26468,7 @@ function createExecutorPrompt({
26467
26468
  });
26468
26469
  throw error62 instanceof Error ? withFailureCategory(error62, failureCategory) : error62;
26469
26470
  } finally {
26470
- shared.optionWriteStop = void 0;
26471
+ shared.localPromptWait = void 0;
26471
26472
  }
26472
26473
  }
26473
26474
  failIfDisposed();
@@ -26478,6 +26479,7 @@ function createExecutorPrompt({
26478
26479
  closeActiveAssistantSegment(turnId);
26479
26480
  let written = false;
26480
26481
  try {
26482
+ const readFailure = hooks.observePromptFailure?.(sessionId);
26481
26483
  response = await sendPromptRpc(
26482
26484
  sessionId,
26483
26485
  promptParts,
@@ -26487,6 +26489,16 @@ function createExecutorPrompt({
26487
26489
  },
26488
26490
  record2
26489
26491
  );
26492
+ if (readFailure && response.stopReason === "end_turn" && isLive(started.generation) && !isStale()) {
26493
+ const controller = new AbortController();
26494
+ shared.localPromptWait = { turnId, stop: () => controller.abort() };
26495
+ try {
26496
+ const failure2 = await readFailure(controller.signal);
26497
+ if (failure2 && !isStale() && !controller.signal.aborted) throw failure2;
26498
+ } finally {
26499
+ shared.localPromptWait = void 0;
26500
+ }
26501
+ }
26490
26502
  } catch (caught) {
26491
26503
  if (shared.disposed) {
26492
26504
  throw new AcpExecutorDisposedError();
@@ -26948,7 +26960,7 @@ function acpArtifactEvent(input2) {
26948
26960
  function makeArtifactEmitter(input2) {
26949
26961
  return (artifacts, toolCallId) => {
26950
26962
  const turnId = input2.turnId();
26951
- const event = acpArtifactEvent({
26963
+ const event2 = acpArtifactEvent({
26952
26964
  artifacts,
26953
26965
  toolCallId,
26954
26966
  base: {
@@ -26958,7 +26970,7 @@ function makeArtifactEmitter(input2) {
26958
26970
  ...turnId === void 0 ? {} : { turnId }
26959
26971
  }
26960
26972
  });
26961
- if (event !== void 0) input2.emit(event);
26973
+ if (event2 !== void 0) input2.emit(event2);
26962
26974
  };
26963
26975
  }
26964
26976
 
@@ -26977,11 +26989,11 @@ function createExecutorRuntime({
26977
26989
  createdAt: nowIso3()
26978
26990
  });
26979
26991
  const isLive = (expectedGeneration) => !shared.disposed && shared.generation === expectedGeneration;
26980
- const publish = (event) => {
26992
+ const publish = (event2) => {
26981
26993
  if (shared.disposed) {
26982
26994
  return;
26983
26995
  }
26984
- eventStream.publish(event);
26996
+ eventStream.publish(event2);
26985
26997
  };
26986
26998
  const emit = publish;
26987
26999
  const emitArtifacts = makeArtifactEmitter({
@@ -27831,8 +27843,8 @@ function createExecutorUpdates({
27831
27843
  }
27832
27844
  });
27833
27845
  };
27834
- const applyCompactionUpdate = (event) => {
27835
- let record2 = compactions.get(event.compactionId);
27846
+ const applyCompactionUpdate = (event2) => {
27847
+ let record2 = compactions.get(event2.compactionId);
27836
27848
  if (record2 === void 0) {
27837
27849
  if (shared.manualCompaction !== void 0 && !shared.manualCompaction.adopted) {
27838
27850
  shared.manualCompaction.adopted = true;
@@ -27848,10 +27860,10 @@ function createExecutorUpdates({
27848
27860
  adopted: false
27849
27861
  };
27850
27862
  }
27851
- compactions.set(event.compactionId, record2);
27863
+ compactions.set(event2.compactionId, record2);
27852
27864
  }
27853
- if (event.summary !== void 0) record2.summary = event.summary ?? void 0;
27854
- switch (event.status) {
27865
+ if (event2.summary !== void 0) record2.summary = event2.summary ?? void 0;
27866
+ switch (event2.status) {
27855
27867
  case "in_progress":
27856
27868
  if (!record2.announced) {
27857
27869
  record2.announced = true;
@@ -27861,13 +27873,13 @@ function createExecutorUpdates({
27861
27873
  case "completed":
27862
27874
  record2.announced = true;
27863
27875
  record2.finished = true;
27864
- compactions.delete(event.compactionId);
27876
+ compactions.delete(event2.compactionId);
27865
27877
  emitCompactionState(record2, "compacted");
27866
27878
  return;
27867
27879
  case "failed":
27868
27880
  case "cancelled":
27869
27881
  record2.finished = true;
27870
- compactions.delete(event.compactionId);
27882
+ compactions.delete(event2.compactionId);
27871
27883
  emit({
27872
27884
  type: "runtime.warning",
27873
27885
  ...stamp(),
@@ -27875,8 +27887,8 @@ function createExecutorUpdates({
27875
27887
  threadId: options.threadId,
27876
27888
  ...shared.activeTurnId !== void 0 ? { turnId: shared.activeTurnId } : {},
27877
27889
  payload: {
27878
- message: event.error ?? `Context compaction ${event.status}`,
27879
- detail: { code: `context-compaction-${event.status}` }
27890
+ message: event2.error ?? `Context compaction ${event2.status}`,
27891
+ detail: { code: `context-compaction-${event2.status}` }
27880
27892
  }
27881
27893
  });
27882
27894
  return;
@@ -27963,13 +27975,13 @@ function createExecutorUpdates({
27963
27975
  }
27964
27976
  if (shared.sessionLoadInFlight) {
27965
27977
  shared.droppedReplayUpdates += parsed.events.filter(
27966
- (event) => event._tag !== "ModeChanged"
27978
+ (event2) => event2._tag !== "ModeChanged"
27967
27979
  ).length;
27968
27980
  return;
27969
27981
  }
27970
- for (const event of parsed.events) {
27971
- if (event._tag === "ToolCallUpdated") {
27972
- const { nextToolCall, decision } = retainToolCallUpdate(toolCalls, event.toolCall, {
27982
+ for (const event2 of parsed.events) {
27983
+ if (event2._tag === "ToolCallUpdated") {
27984
+ const { nextToolCall, decision } = retainToolCallUpdate(toolCalls, event2.toolCall, {
27973
27985
  turnId: shared.activeTurnId,
27974
27986
  rawTitle: params.update.title,
27975
27987
  nowMs
@@ -28008,32 +28020,32 @@ function createExecutorUpdates({
28008
28020
  threadId: options.threadId,
28009
28021
  turnId: toolTurnId,
28010
28022
  toolCall: nextToolCall,
28011
- rawPayload: event.rawPayload
28023
+ rawPayload: event2.rawPayload
28012
28024
  })
28013
28025
  );
28014
28026
  continue;
28015
28027
  }
28016
- if (event._tag === "AssistantContentBlock") {
28017
- emitArtifacts(resourceLinkArtifacts(event.content));
28028
+ if (event2._tag === "AssistantContentBlock") {
28029
+ emitArtifacts(resourceLinkArtifacts(event2.content));
28018
28030
  continue;
28019
28031
  }
28020
- if (event._tag === "CompactionUpdated") {
28021
- applyCompactionUpdate(event);
28032
+ if (event2._tag === "CompactionUpdated") {
28033
+ applyCompactionUpdate(event2);
28022
28034
  continue;
28023
28035
  }
28024
- if (event._tag === "CompactionSummaryChunk") {
28025
- const record2 = compactions.get(event.compactionId);
28036
+ if (event2._tag === "CompactionSummaryChunk") {
28037
+ const record2 = compactions.get(event2.compactionId);
28026
28038
  if (record2 !== void 0 && !record2.finished) {
28027
- record2.summary = (record2.summary ?? "") + event.text;
28039
+ record2.summary = (record2.summary ?? "") + event2.text;
28028
28040
  }
28029
28041
  continue;
28030
28042
  }
28031
- if (event._tag === "ContentDelta") {
28043
+ if (event2._tag === "ContentDelta") {
28032
28044
  if (shared.manualCompaction !== void 0) {
28033
28045
  continue;
28034
28046
  }
28035
- if (event.streamKind === "reasoning_text") {
28036
- if (event.text.trim().length === 0) {
28047
+ if (event2.streamKind === "reasoning_text") {
28048
+ if (event2.text.trim().length === 0) {
28037
28049
  continue;
28038
28050
  }
28039
28051
  emit(
@@ -28042,14 +28054,14 @@ function createExecutorUpdates({
28042
28054
  provider: options.provider,
28043
28055
  threadId: options.threadId,
28044
28056
  turnId: shared.activeTurnId,
28045
- text: event.text,
28057
+ text: event2.text,
28046
28058
  streamKind: "reasoning_text",
28047
- rawPayload: event.rawPayload
28059
+ rawPayload: event2.rawPayload
28048
28060
  })
28049
28061
  );
28050
28062
  continue;
28051
28063
  }
28052
- if (event.text.trim().length === 0 && !shared.assistantSegment.activeItemId) {
28064
+ if (event2.text.trim().length === 0 && !shared.assistantSegment.activeItemId) {
28053
28065
  continue;
28054
28066
  }
28055
28067
  const itemId = shared.sessionId ? ensureActiveAssistantSegment(shared.sessionId, shared.activeTurnId) : void 0;
@@ -28060,24 +28072,24 @@ function createExecutorUpdates({
28060
28072
  threadId: options.threadId,
28061
28073
  turnId: shared.activeTurnId,
28062
28074
  ...itemId ? { itemId } : {},
28063
- text: event.text,
28075
+ text: event2.text,
28064
28076
  streamKind: "assistant_text",
28065
- rawPayload: event.rawPayload
28077
+ rawPayload: event2.rawPayload
28066
28078
  })
28067
28079
  );
28068
28080
  continue;
28069
28081
  }
28070
- if (event._tag === "PlanUpdated") {
28082
+ if (event2._tag === "PlanUpdated") {
28071
28083
  emit(
28072
28084
  makeAcpPlanUpdatedEvent({
28073
28085
  stamp: stamp(),
28074
28086
  provider: options.provider,
28075
28087
  threadId: options.threadId,
28076
28088
  turnId: shared.activeTurnId,
28077
- payload: event.payload,
28089
+ payload: event2.payload,
28078
28090
  source: "acp.jsonrpc",
28079
28091
  method: "session/update",
28080
- rawPayload: event.rawPayload
28092
+ rawPayload: event2.rawPayload
28081
28093
  })
28082
28094
  );
28083
28095
  }
@@ -28181,11 +28193,11 @@ function createAcpProtocolLogFile(input2) {
28181
28193
  };
28182
28194
  return {
28183
28195
  path: filePath,
28184
- write: (event) => writeLine({
28196
+ write: (event2) => writeLine({
28185
28197
  at: (/* @__PURE__ */ new Date()).toISOString(),
28186
- direction: event.direction,
28187
- stage: event.stage,
28188
- payload: event.payload
28198
+ direction: event2.direction,
28199
+ stage: event2.stage,
28200
+ payload: event2.payload
28189
28201
  }),
28190
28202
  close: async () => {
28191
28203
  if (closing) return closed.promise;
@@ -28266,7 +28278,7 @@ function createAcpExecutor(options) {
28266
28278
  childSessions: createChildSessionRegistry(),
28267
28279
  sessionOpensInFlight: 0,
28268
28280
  configOptionUpdates: /* @__PURE__ */ new Map(),
28269
- optionWriteStop: void 0,
28281
+ localPromptWait: void 0,
28270
28282
  configUpdateSeq: 0
28271
28283
  };
28272
28284
  const interruptedTurnIds = /* @__PURE__ */ new Set();
@@ -29024,8 +29036,8 @@ function acpStartedSession(input2, started) {
29024
29036
  async function openAcpThread(input2) {
29025
29037
  const { executor, handle, signal, threadId } = input2;
29026
29038
  const forwarding = (async () => {
29027
- for await (const event of executor.events) {
29028
- const forwarded = input2.forward(event);
29039
+ for await (const event2 of executor.events) {
29040
+ const forwarded = input2.forward(event2);
29029
29041
  if (forwarded !== void 0) await forwarded;
29030
29042
  }
29031
29043
  })();
@@ -29263,6 +29275,9 @@ function parseKimiInstanceConfig(config2) {
29263
29275
  };
29264
29276
  }
29265
29277
 
29278
+ // src/kimiPromptFailure.ts
29279
+ import * as NodeFS3 from "node:fs";
29280
+
29266
29281
  // src/kimi.ts
29267
29282
  import * as NodeFS2 from "node:fs";
29268
29283
  import * as NodePath4 from "node:path";
@@ -29366,6 +29381,8 @@ function readTail(filePath) {
29366
29381
  }
29367
29382
  }
29368
29383
  function findKimiSessionWireLog(input2) {
29384
+ if (!input2.acpSessionId || /[\\/:]/u.test(input2.acpSessionId) || [".", ".."].includes(input2.acpSessionId))
29385
+ return void 0;
29369
29386
  const sessionsRoot = NodePath4.join(input2.homePath, SESSIONS_DIR);
29370
29387
  let workspaces;
29371
29388
  try {
@@ -29392,8 +29409,109 @@ function readKimiContextWindow(input2) {
29392
29409
  return contents === void 0 ? void 0 : parseKimiContextWindow(contents);
29393
29410
  }
29394
29411
 
29412
+ // src/kimiPromptFailure.ts
29413
+ var END_BYTES = 64 * 1024;
29414
+ var START_BYTES = 512 * 1024;
29415
+ function readWindow(fd, start, end) {
29416
+ const buffer = Buffer.alloc(end - start);
29417
+ const bytes = NodeFS3.readSync(fd, buffer, 0, buffer.length, start);
29418
+ return buffer.toString("utf8", 0, bytes).split("\n");
29419
+ }
29420
+ function event(line, type) {
29421
+ if (!line.includes(`"${type}"`)) return void 0;
29422
+ try {
29423
+ const value = JSON.parse(line);
29424
+ if (value?.type === type && value.agentId === "main") return value;
29425
+ } catch {
29426
+ }
29427
+ return void 0;
29428
+ }
29429
+ function observeKimiPromptFailure(homePath, acpSessionId) {
29430
+ const startedAt = Date.now();
29431
+ const find = () => findKimiSessionWireLog({ homePath, acpSessionId });
29432
+ const original = find();
29433
+ let before;
29434
+ try {
29435
+ if (original) before = NodeFS3.statSync(original);
29436
+ } catch {
29437
+ return void 0;
29438
+ }
29439
+ const inspect = () => {
29440
+ const path = original ?? find();
29441
+ if (!path) return void 0;
29442
+ let fd;
29443
+ try {
29444
+ fd = NodeFS3.openSync(path, "r");
29445
+ const after = NodeFS3.fstatSync(fd);
29446
+ const start = before?.size ?? 0;
29447
+ if (after.size < start || before && (before.dev !== after.dev || before.ino !== after.ino))
29448
+ return void 0;
29449
+ if (after.size === start) return "pending";
29450
+ const tailStart = Math.max(start, after.size - END_BYTES);
29451
+ const tail = readWindow(fd, tailStart, after.size);
29452
+ let ended;
29453
+ for (let i = tail.length - 1; i >= 0; i--) {
29454
+ const line = tail[i];
29455
+ if (event(line, "turn.prompt")) return "pending";
29456
+ ended = event(line, "turn.ended");
29457
+ if (ended) break;
29458
+ }
29459
+ if (!ended) return "pending";
29460
+ if (ended.reason !== "failed" || typeof ended.turnId !== "number") return void 0;
29461
+ const turnId = ended.turnId;
29462
+ const promptLines = tailStart === start ? tail : readWindow(fd, start, Math.min(after.size, start + START_BYTES));
29463
+ let prompt;
29464
+ for (const line of promptLines) {
29465
+ prompt = event(line, "turn.prompt");
29466
+ if (prompt) break;
29467
+ }
29468
+ if (!prompt || prompt.turnId !== turnId || before === void 0 && (typeof prompt.time !== "number" || prompt.time < startedAt))
29469
+ return void 0;
29470
+ const error62 = ended.error;
29471
+ if (typeof error62 !== "object" || !error62 || !("message" in error62) || typeof error62.message !== "string" || !error62.message.trim())
29472
+ return new Error("Kimi reported that the turn failed.");
29473
+ const failure2 = new Error(error62.message);
29474
+ return "name" in error62 && error62.name === "APIProviderQuotaExhaustedError" ? Object.assign(failure2, { failureCategory: "quota" }) : failure2;
29475
+ } catch {
29476
+ return void 0;
29477
+ } finally {
29478
+ if (fd !== void 0) NodeFS3.closeSync(fd);
29479
+ }
29480
+ };
29481
+ return async (signal) => {
29482
+ if (signal.aborted) return void 0;
29483
+ const first = inspect();
29484
+ if (first !== "pending") return first;
29485
+ const path = original ?? find();
29486
+ if (!path) return void 0;
29487
+ return new Promise((resolve4) => {
29488
+ let watcher;
29489
+ const finish = (failure2) => {
29490
+ clearTimeout(deadline);
29491
+ signal.removeEventListener("abort", abort);
29492
+ watcher?.close();
29493
+ resolve4(failure2);
29494
+ };
29495
+ const abort = () => finish();
29496
+ const check2 = () => {
29497
+ const result = inspect();
29498
+ if (result !== "pending") finish(result);
29499
+ };
29500
+ const deadline = setTimeout(abort, 1e3);
29501
+ try {
29502
+ watcher = NodeFS3.watch(path, check2);
29503
+ watcher.on("error", abort);
29504
+ signal.addEventListener("abort", abort, { once: true });
29505
+ check2();
29506
+ } catch {
29507
+ finish();
29508
+ }
29509
+ });
29510
+ };
29511
+ }
29512
+
29395
29513
  // src/kimiQuota.ts
29396
- import * as NodeFS4 from "node:fs";
29514
+ import * as NodeFS5 from "node:fs";
29397
29515
  import * as NodeOS5 from "node:os";
29398
29516
  import * as NodePath6 from "node:path";
29399
29517
 
@@ -29463,18 +29581,20 @@ var parseJson = (raw) => {
29463
29581
  };
29464
29582
 
29465
29583
  // src/kimiAccount.ts
29466
- import * as NodeFS3 from "node:fs";
29584
+ import * as NodeFS4 from "node:fs";
29467
29585
  import * as NodeOS4 from "node:os";
29468
29586
  import * as NodePath5 from "node:path";
29587
+ function kimiAccountHome(resolvedHomePath) {
29588
+ return resolvedHomePath.trim().length > 0 ? resolvedHomePath : NodePath5.join(NodeOS4.homedir(), ".kimi-code");
29589
+ }
29469
29590
  function kimiCredentialsPath(resolvedHomePath) {
29470
- const home = resolvedHomePath.trim().length > 0 ? resolvedHomePath : NodePath5.join(NodeOS4.homedir(), ".kimi-code");
29471
- return NodePath5.join(home, "credentials", "kimi-code.json");
29591
+ return NodePath5.join(kimiAccountHome(resolvedHomePath), "credentials", "kimi-code.json");
29472
29592
  }
29473
29593
  var nonEmptyString = (value) => typeof value === "string" && value.length > 0;
29474
29594
  function readKimiAuthState(resolvedHomePath) {
29475
29595
  let raw;
29476
29596
  try {
29477
- raw = NodeFS3.readFileSync(kimiCredentialsPath(resolvedHomePath), "utf8");
29597
+ raw = NodeFS4.readFileSync(kimiCredentialsPath(resolvedHomePath), "utf8");
29478
29598
  } catch (error62) {
29479
29599
  return error62.code === "ENOENT" ? "signed-out" : "unreadable";
29480
29600
  }
@@ -29628,7 +29748,7 @@ var createKimiUsage = (input2) => {
29628
29748
  const readQuota = async (request) => {
29629
29749
  let configToml = null;
29630
29750
  try {
29631
- configToml = NodeFS4.readFileSync(NodePath6.join(home, "config.toml"), "utf8");
29751
+ configToml = NodeFS5.readFileSync(NodePath6.join(home, "config.toml"), "utf8");
29632
29752
  } catch (error62) {
29633
29753
  if (error62.code !== "ENOENT") {
29634
29754
  return { status: "unavailable", reason: "unreachable" };
@@ -29641,7 +29761,7 @@ var createKimiUsage = (input2) => {
29641
29761
  if ("custom" in endpoint) return { status: "unavailable", reason: "customEndpoint" };
29642
29762
  let token = null;
29643
29763
  try {
29644
- token = extractKimiToken(parseJson(NodeFS4.readFileSync(credentialsPath, "utf8")), now());
29764
+ token = extractKimiToken(parseJson(NodeFS5.readFileSync(credentialsPath, "utf8")), now());
29645
29765
  } catch {
29646
29766
  token = null;
29647
29767
  }
@@ -29669,7 +29789,7 @@ var createKimiUsage = (input2) => {
29669
29789
  };
29670
29790
 
29671
29791
  // src/kimiTokens.ts
29672
- import * as NodeFS5 from "node:fs";
29792
+ import * as NodeFS6 from "node:fs";
29673
29793
  import * as NodeOS6 from "node:os";
29674
29794
  import * as NodePath7 from "node:path";
29675
29795
  var MTIME_SLACK_MS = 36 * 60 * 60 * 1e3;
@@ -29708,7 +29828,7 @@ var parseKimiUsageLine = (line) => {
29708
29828
  var hasTokens = (totals) => totals.uncachedInputTokens > 0 || totals.cachedInputTokens > 0 || totals.cacheCreationTokens > 0 || totals.outputTokens > 0;
29709
29829
  var readDirs = (dir) => {
29710
29830
  try {
29711
- return NodeFS5.readdirSync(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
29831
+ return NodeFS6.readdirSync(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
29712
29832
  } catch {
29713
29833
  return [];
29714
29834
  }
@@ -29728,17 +29848,17 @@ var listWireLogs = (sessionsRoot) => {
29728
29848
  var readRange = (file2, from, to) => {
29729
29849
  const length = Math.max(0, to - from);
29730
29850
  const buffer = Buffer.alloc(length);
29731
- const fd = NodeFS5.openSync(file2, "r");
29851
+ const fd = NodeFS6.openSync(file2, "r");
29732
29852
  try {
29733
29853
  let read = 0;
29734
29854
  while (read < length) {
29735
- const n = NodeFS5.readSync(fd, buffer, read, length - read, from + read);
29855
+ const n = NodeFS6.readSync(fd, buffer, read, length - read, from + read);
29736
29856
  if (n === 0) break;
29737
29857
  read += n;
29738
29858
  }
29739
29859
  return read === length ? buffer : buffer.subarray(0, read);
29740
29860
  } finally {
29741
- NodeFS5.closeSync(fd);
29861
+ NodeFS6.closeSync(fd);
29742
29862
  }
29743
29863
  };
29744
29864
  var guardOf = (file2, size) => readRange(file2, 0, Math.min(size, GUARD_LENGTH)).toString("base64");
@@ -29769,7 +29889,7 @@ var createKimiTokenReader = (input2) => {
29769
29889
  const readTokenUsage = async (request) => {
29770
29890
  const sinceMs = Date.parse(request.since);
29771
29891
  const untilMs = Date.parse(request.until);
29772
- if (!NodeFS5.existsSync(sessionsRoot)) {
29892
+ if (!NodeFS6.existsSync(sessionsRoot)) {
29773
29893
  return {
29774
29894
  records: [],
29775
29895
  source: {
@@ -29790,7 +29910,7 @@ var createKimiTokenReader = (input2) => {
29790
29910
  for (const { file: file2, sessionId } of listWireLogs(sessionsRoot)) {
29791
29911
  let size;
29792
29912
  try {
29793
- const stat = NodeFS5.statSync(file2);
29913
+ const stat = NodeFS6.statSync(file2);
29794
29914
  if (stat.mtimeMs < sinceMs - MTIME_SLACK_MS) {
29795
29915
  skippedFiles += 1;
29796
29916
  continue;
@@ -30237,7 +30357,9 @@ function resolveHomePath(recipe) {
30237
30357
  }
30238
30358
  function kimiHooks(recipe) {
30239
30359
  const homePath = resolveHomePath(recipe);
30360
+ const wireHome = kimiAccountHome(kimiEffectiveHome(homePath, process.env[recipe.homeEnvVar]));
30240
30361
  return {
30362
+ observePromptFailure: (sessionId) => observeKimiPromptFailure(wireHome, sessionId),
30241
30363
  permissionUserInput: kimiPermissionUserInput,
30242
30364
  permissionStatement: kimiPermissionStatement,
30243
30365
  toolSubagents: kimiToolSubagents,
@@ -30391,7 +30513,7 @@ var createKimiInstance = (config2, host) => {
30391
30513
  handle,
30392
30514
  signal,
30393
30515
  log: host.log,
30394
- emit: (event) => input2.events.emit(event),
30516
+ emit: (event2) => input2.events.emit(event2),
30395
30517
  requestedNativeModeId: input2.nativeModeId,
30396
30518
  resumed: resume !== void 0,
30397
30519
  session: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-kimi",
3
- "version": "0.2.5374",
3
+ "version": "0.2.5448",
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.5374",
25
- "ycodium-acp-executor": "0.2.5374",
24
+ "@ycodium-ai/plugin-api": "0.2.0",
26
25
  "ycodium-credential-account": "0.0.0",
26
+ "ycodium-acp-executor": "0.2.0",
27
27
  "ycodium-executor-testing": "0.0.0",
28
28
  "ycodium-instance-config": "0.0.0"
29
29
  },