@ycodium-ai/agent-kimi 0.2.3192 → 0.2.3208

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 +76 -14
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -27215,6 +27215,9 @@ function createAcpSessionRegistry(threads, stopBooked2) {
27215
27215
  if (!booked) return Promise.resolve();
27216
27216
  booked.closing ??= Promise.resolve().then(() => stopBooked2(booked)).then(() => {
27217
27217
  if (threads.get(threadId) === booked) threads.delete(threadId);
27218
+ }).catch((cause) => {
27219
+ if (threads.get(threadId) === booked) delete booked.closing;
27220
+ throw cause;
27218
27221
  });
27219
27222
  return booked.closing;
27220
27223
  };
@@ -27224,6 +27227,61 @@ function createAcpSessionRegistry(threads, stopBooked2) {
27224
27227
  return { requireThread, stopSession, stopAll };
27225
27228
  }
27226
27229
 
27230
+ // ../../packages/ycodium-acp-executor/src/session-cleanup.ts
27231
+ var reportedForwardingFailures = /* @__PURE__ */ new WeakSet();
27232
+ async function cleanupAcpSession(input2) {
27233
+ const failures = [];
27234
+ const forwarding = input2.forwarding.catch((cause) => {
27235
+ if (reportedForwardingFailures.has(input2.forwarding)) return;
27236
+ reportedForwardingFailures.add(input2.forwarding);
27237
+ failures.push(new Error(`forwarding failed: ${String(cause)}`, { cause }));
27238
+ });
27239
+ for (const [step, cleanup] of [
27240
+ ["executor.dispose", () => input2.executor.dispose()],
27241
+ ["stopProcess", input2.stopProcess],
27242
+ ["forwarding", () => forwarding]
27243
+ ]) {
27244
+ try {
27245
+ await cleanup();
27246
+ } catch (cause) {
27247
+ failures.push(new Error(`${step} failed: ${String(cause)}`, { cause }));
27248
+ }
27249
+ }
27250
+ if (failures.length > 0) {
27251
+ throw new AggregateError(failures, failures.map((error62) => error62.message).join("; "));
27252
+ }
27253
+ }
27254
+ async function cleanupAcpStartup(input2) {
27255
+ try {
27256
+ await cleanupAcpSession(input2);
27257
+ return true;
27258
+ } catch (cleanupError) {
27259
+ input2.log.warn("ACP session startup cleanup failed", {
27260
+ threadId: input2.threadId,
27261
+ error: String(cleanupError)
27262
+ });
27263
+ return false;
27264
+ }
27265
+ }
27266
+ function createRetryableClose(run) {
27267
+ let task;
27268
+ return () => {
27269
+ if (task) return task;
27270
+ const done = Promise.withResolvers();
27271
+ const current = done.promise;
27272
+ task = current;
27273
+ void current.catch(() => {
27274
+ if (task === current) task = void 0;
27275
+ });
27276
+ try {
27277
+ run().then(done.resolve, done.reject);
27278
+ } catch (cause) {
27279
+ done.reject(cause);
27280
+ }
27281
+ return current;
27282
+ };
27283
+ }
27284
+
27227
27285
  // ../../packages/ycodium-acp-executor/src/sessionProcess.ts
27228
27286
  var fileName = (path) => path.slice(path.lastIndexOf("/") + 1);
27229
27287
  var withoutExe = (name) => name.replace(/\.exe$/, "");
@@ -28293,18 +28351,23 @@ function kimiHooks(recipe) {
28293
28351
  };
28294
28352
  }
28295
28353
  async function stopBooked(booked) {
28296
- await booked.executor.dispose().catch(() => void 0);
28297
- await booked.handle.kill("SIGTERM").catch(() => void 0);
28298
- await booked.forwarding.catch(() => void 0);
28354
+ await cleanupAcpSession({
28355
+ executor: booked.executor,
28356
+ stopProcess: () => booked.handle.kill("SIGTERM"),
28357
+ forwarding: booked.forwarding
28358
+ });
28299
28359
  }
28300
28360
  var createKimiInstance = (config2, host) => {
28301
28361
  const recipe = parseKimiInstanceConfig(config2);
28302
28362
  const events = new EventBus();
28303
28363
  const threads = /* @__PURE__ */ new Map();
28304
28364
  let disposed = false;
28305
- let disposeTask;
28306
28365
  const usageHome = kimiEffectiveHome(resolveHomePath(recipe), process.env[recipe.homeEnvVar]);
28307
28366
  const { requireThread, stopSession, stopAll } = createAcpSessionRegistry(threads, stopBooked);
28367
+ const disposeOnce = createRetryableClose(async () => {
28368
+ await stopAll();
28369
+ events.close();
28370
+ });
28308
28371
  const instance = {
28309
28372
  probe: async () => {
28310
28373
  if (recipe.binaryPath.length === 0) {
@@ -28485,9 +28548,13 @@ var createKimiInstance = (config2, host) => {
28485
28548
  });
28486
28549
  return session;
28487
28550
  } catch (error62) {
28488
- await executor.dispose().catch(() => void 0);
28489
- await handle.kill("SIGTERM").catch(() => void 0);
28490
- await forwarding.catch(() => void 0);
28551
+ await cleanupAcpStartup({
28552
+ executor,
28553
+ stopProcess: () => handle.kill("SIGTERM"),
28554
+ forwarding,
28555
+ log: host.log,
28556
+ threadId: input2.threadId
28557
+ });
28491
28558
  throw error62;
28492
28559
  }
28493
28560
  },
@@ -28585,13 +28652,8 @@ var createKimiInstance = (config2, host) => {
28585
28652
  },
28586
28653
  continuationKey: kimiContinuationKey(recipe),
28587
28654
  dispose: () => {
28588
- if (disposeTask) return disposeTask;
28589
28655
  disposed = true;
28590
- disposeTask = (async () => {
28591
- await stopAll();
28592
- events.close();
28593
- })();
28594
- return disposeTask;
28656
+ return disposeOnce();
28595
28657
  }
28596
28658
  };
28597
28659
  return instance;
@@ -28609,7 +28671,7 @@ var executors = [
28609
28671
  ];
28610
28672
  var index_default = definePlugin({
28611
28673
  id: "agent-kimi",
28612
- apiVersion: 17,
28674
+ apiVersion: 19,
28613
28675
  executors,
28614
28676
  activate(ctx) {
28615
28677
  ctx.log.info("Kimi Code executor ready");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-kimi",
3
- "version": "0.2.3192",
3
+ "version": "0.2.3208",
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.3192",
25
24
  "ycodium-executor-testing": "0.0.0",
26
- "ycodium-acp-executor": "0.2.3192"
25
+ "@ycodium-ai/plugin-api": "0.2.3208",
26
+ "ycodium-acp-executor": "0.2.3208"
27
27
  },
28
28
  "ycodium": {
29
29
  "plugin": "./dist/index.js",