@ycodium-ai/agent-acp 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 +4 -4
package/dist/index.js CHANGED
@@ -27199,6 +27199,9 @@ function createAcpSessionRegistry(threads, stopBooked2) {
27199
27199
  if (!booked) return Promise.resolve();
27200
27200
  booked.closing ??= Promise.resolve().then(() => stopBooked2(booked)).then(() => {
27201
27201
  if (threads.get(threadId) === booked) threads.delete(threadId);
27202
+ }).catch((cause) => {
27203
+ if (threads.get(threadId) === booked) delete booked.closing;
27204
+ throw cause;
27202
27205
  });
27203
27206
  return booked.closing;
27204
27207
  };
@@ -27208,6 +27211,61 @@ function createAcpSessionRegistry(threads, stopBooked2) {
27208
27211
  return { requireThread, stopSession, stopAll };
27209
27212
  }
27210
27213
 
27214
+ // ../../packages/ycodium-acp-executor/src/session-cleanup.ts
27215
+ var reportedForwardingFailures = /* @__PURE__ */ new WeakSet();
27216
+ async function cleanupAcpSession(input2) {
27217
+ const failures = [];
27218
+ const forwarding = input2.forwarding.catch((cause) => {
27219
+ if (reportedForwardingFailures.has(input2.forwarding)) return;
27220
+ reportedForwardingFailures.add(input2.forwarding);
27221
+ failures.push(new Error(`forwarding failed: ${String(cause)}`, { cause }));
27222
+ });
27223
+ for (const [step, cleanup] of [
27224
+ ["executor.dispose", () => input2.executor.dispose()],
27225
+ ["stopProcess", input2.stopProcess],
27226
+ ["forwarding", () => forwarding]
27227
+ ]) {
27228
+ try {
27229
+ await cleanup();
27230
+ } catch (cause) {
27231
+ failures.push(new Error(`${step} failed: ${String(cause)}`, { cause }));
27232
+ }
27233
+ }
27234
+ if (failures.length > 0) {
27235
+ throw new AggregateError(failures, failures.map((error62) => error62.message).join("; "));
27236
+ }
27237
+ }
27238
+ async function cleanupAcpStartup(input2) {
27239
+ try {
27240
+ await cleanupAcpSession(input2);
27241
+ return true;
27242
+ } catch (cleanupError) {
27243
+ input2.log.warn("ACP session startup cleanup failed", {
27244
+ threadId: input2.threadId,
27245
+ error: String(cleanupError)
27246
+ });
27247
+ return false;
27248
+ }
27249
+ }
27250
+ function createRetryableClose(run) {
27251
+ let task;
27252
+ return () => {
27253
+ if (task) return task;
27254
+ const done = Promise.withResolvers();
27255
+ const current = done.promise;
27256
+ task = current;
27257
+ void current.catch(() => {
27258
+ if (task === current) task = void 0;
27259
+ });
27260
+ try {
27261
+ run().then(done.resolve, done.reject);
27262
+ } catch (cause) {
27263
+ done.reject(cause);
27264
+ }
27265
+ return current;
27266
+ };
27267
+ }
27268
+
27211
27269
  // ../../packages/ycodium-acp-executor/src/prompt-dispatch.ts
27212
27270
  var dispatchAcpPrompt = (executor, input2) => {
27213
27271
  const { promise: dispatched, resolve: resolve2 } = Promise.withResolvers();
@@ -27728,17 +27786,22 @@ function acpContinuationKey(recipe) {
27728
27786
  return `acp:home:${recipe.binaryPath.trim()}\0${resolvedHomePath}`;
27729
27787
  }
27730
27788
  async function stopBooked(booked) {
27731
- await booked.executor.dispose().catch(() => void 0);
27732
- await booked.handle.kill("SIGTERM").catch(() => void 0);
27733
- await booked.forwarding.catch(() => void 0);
27789
+ await cleanupAcpSession({
27790
+ executor: booked.executor,
27791
+ stopProcess: () => booked.handle.kill("SIGTERM"),
27792
+ forwarding: booked.forwarding
27793
+ });
27734
27794
  }
27735
27795
  var createAcpInstance = (config2, host) => {
27736
27796
  const recipe = parseAcpInstanceConfig(config2);
27737
27797
  const events = new EventBus();
27738
27798
  const threads = /* @__PURE__ */ new Map();
27739
27799
  let disposed = false;
27740
- let disposeTask;
27741
27800
  const { requireThread, stopSession, stopAll } = createAcpSessionRegistry(threads, stopBooked);
27801
+ const disposeOnce = createRetryableClose(async () => {
27802
+ await stopAll();
27803
+ events.close();
27804
+ });
27742
27805
  const instance = {
27743
27806
  probe: async () => {
27744
27807
  if (recipe.binaryPath.length === 0) {
@@ -27899,9 +27962,13 @@ var createAcpInstance = (config2, host) => {
27899
27962
  });
27900
27963
  return session;
27901
27964
  } catch (error62) {
27902
- await executor.dispose().catch(() => void 0);
27903
- await handle.kill("SIGTERM").catch(() => void 0);
27904
- await forwarding.catch(() => void 0);
27965
+ await cleanupAcpStartup({
27966
+ executor,
27967
+ stopProcess: () => handle.kill("SIGTERM"),
27968
+ forwarding,
27969
+ log: host.log,
27970
+ threadId: input2.threadId
27971
+ });
27905
27972
  throw error62;
27906
27973
  }
27907
27974
  },
@@ -27981,13 +28048,8 @@ var createAcpInstance = (config2, host) => {
27981
28048
  events,
27982
28049
  continuationKey: acpContinuationKey(recipe),
27983
28050
  dispose: () => {
27984
- if (disposeTask) return disposeTask;
27985
28051
  disposed = true;
27986
- disposeTask = (async () => {
27987
- await stopAll();
27988
- events.close();
27989
- })();
27990
- return disposeTask;
28052
+ return disposeOnce();
27991
28053
  }
27992
28054
  };
27993
28055
  return instance;
@@ -28005,7 +28067,7 @@ var executors = [
28005
28067
  ];
28006
28068
  var index_default = definePlugin({
28007
28069
  id: "agent-acp",
28008
- apiVersion: 17,
28070
+ apiVersion: 19,
28009
28071
  executors,
28010
28072
  activate(ctx) {
28011
28073
  ctx.log.info("generic ACP executor ready");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-acp",
3
- "version": "0.2.3192",
3
+ "version": "0.2.3208",
4
4
  "description": "Generic ACP executor: user-supplied CLI 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
- "ycodium-acp-executor": "0.2.3192",
26
- "ycodium-executor-testing": "0.0.0"
24
+ "ycodium-executor-testing": "0.0.0",
25
+ "ycodium-acp-executor": "0.2.3208",
26
+ "@ycodium-ai/plugin-api": "0.2.3208"
27
27
  },
28
28
  "ycodium": {
29
29
  "plugin": "./dist/index.js",