@ycodium-ai/agent-acp 0.2.3478 → 0.2.3502

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 +50 -31
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -27646,19 +27646,28 @@ function toAcpMcpServers(entries) {
27646
27646
  }
27647
27647
 
27648
27648
  // ../../packages/ycodium-acp-executor/src/probe.ts
27649
- function withProbeTimeout(promise2, timeoutMs, what) {
27649
+ function withProbeTimeout(promise2, timeoutMs, what, signal) {
27650
+ signal?.throwIfAborted();
27650
27651
  return new Promise((resolve2, reject) => {
27652
+ const onAbort = () => {
27653
+ clearTimeout(timer);
27654
+ reject(signal?.reason ?? new Error("aborted"));
27655
+ };
27651
27656
  const timer = setTimeout(() => {
27657
+ signal?.removeEventListener("abort", onAbort);
27652
27658
  reject(new Error(`${what} timed out after ${timeoutMs}ms`));
27653
27659
  }, timeoutMs);
27654
27660
  timer.unref?.();
27661
+ signal?.addEventListener("abort", onAbort, { once: true });
27655
27662
  promise2.then(
27656
27663
  (value) => {
27657
27664
  clearTimeout(timer);
27665
+ signal?.removeEventListener("abort", onAbort);
27658
27666
  resolve2(value);
27659
27667
  },
27660
27668
  (error62) => {
27661
27669
  clearTimeout(timer);
27670
+ signal?.removeEventListener("abort", onAbort);
27662
27671
  reject(error62 instanceof Error ? error62 : new Error(String(error62)));
27663
27672
  }
27664
27673
  );
@@ -27674,14 +27683,16 @@ async function openAcpProbeHandshake(input2) {
27674
27683
  const initializeResult = await withProbeTimeout(
27675
27684
  connection.request("initialize", acpInitializePayload(input2.clientInfo)),
27676
27685
  input2.requestTimeoutMs,
27677
- "ACP probe request 'initialize'"
27686
+ "ACP probe request 'initialize'",
27687
+ input2.signal
27678
27688
  );
27679
27689
  return {
27680
27690
  initializeResult,
27681
27691
  request: (method, params) => withProbeTimeout(
27682
27692
  connection.request(method, params),
27683
27693
  input2.requestTimeoutMs,
27684
- `ACP probe request '${method}'`
27694
+ `ACP probe request '${method}'`,
27695
+ input2.signal
27685
27696
  ),
27686
27697
  close: () => connection.close()
27687
27698
  };
@@ -27890,6 +27901,10 @@ function tokenizeLaunchArgs(value) {
27890
27901
  }
27891
27902
 
27892
27903
  // src/probeModels.ts
27904
+ import {
27905
+ withProcessOperation,
27906
+ OperationCleanupError
27907
+ } from "@ycodium-ai/plugin-api/process-operation";
27893
27908
  import * as NodeFS2 from "node:fs";
27894
27909
  import * as NodeOS2 from "node:os";
27895
27910
  import * as NodePath3 from "node:path";
@@ -28034,34 +28049,37 @@ async function probeAcpAgentVersion(input2) {
28034
28049
  } catch {
28035
28050
  return null;
28036
28051
  }
28037
- let handle;
28038
28052
  try {
28039
- handle = await input2.host.process.spawn({
28040
- program: input2.recipe.binaryPath,
28041
- args: tokenizeLaunchArgs(input2.recipe.launchArgs),
28042
- cwd: probeCwd,
28043
- owner: { bindingId: input2.host.bindingId },
28044
- ...Object.keys(input2.env).length > 0 ? { env: input2.env } : {}
28045
- });
28046
- } catch {
28053
+ return await withProcessOperation(
28054
+ input2.host,
28055
+ {
28056
+ signal: input2.signal,
28057
+ timeoutMs: PROBE_REQUEST_TIMEOUT_MS
28058
+ },
28059
+ async (operation) => {
28060
+ const handle = await operation.spawn({
28061
+ program: input2.recipe.binaryPath,
28062
+ args: tokenizeLaunchArgs(input2.recipe.launchArgs),
28063
+ cwd: probeCwd,
28064
+ owner: { bindingId: input2.host.bindingId },
28065
+ ...Object.keys(input2.env).length > 0 ? { env: input2.env } : {}
28066
+ });
28067
+ const { readable, writable } = nodeStreamsFromHandle(handle);
28068
+ const handshake = await openAcpProbeHandshake({
28069
+ readable,
28070
+ writable,
28071
+ clientInfo: CLIENT_INFO,
28072
+ requestTimeoutMs: PROBE_REQUEST_TIMEOUT_MS,
28073
+ signal: operation.signal
28074
+ });
28075
+ operation.defer(handshake.close);
28076
+ return acpAgentVersion(handshake.initializeResult);
28077
+ }
28078
+ );
28079
+ } catch (error62) {
28080
+ if (error62 instanceof OperationCleanupError || input2.signal?.aborted) throw error62;
28047
28081
  return null;
28048
28082
  }
28049
- let handshake;
28050
- try {
28051
- const { readable, writable } = nodeStreamsFromHandle(handle);
28052
- handshake = await openAcpProbeHandshake({
28053
- readable,
28054
- writable,
28055
- clientInfo: CLIENT_INFO,
28056
- requestTimeoutMs: PROBE_REQUEST_TIMEOUT_MS
28057
- });
28058
- return acpAgentVersion(handshake.initializeResult);
28059
- } catch {
28060
- return acpAgentVersion(handshake?.initializeResult);
28061
- } finally {
28062
- await handshake?.close().catch(() => void 0);
28063
- await handle.kill("SIGTERM").catch(() => void 0);
28064
- }
28065
28083
  }
28066
28084
 
28067
28085
  // src/runtimeModeApproval.ts
@@ -28232,10 +28250,11 @@ var createAcpInstance = (config2, host) => {
28232
28250
  };
28233
28251
  }
28234
28252
  },
28235
- readCliVersion: () => recipe.binaryPath.length === 0 ? Promise.resolve(null) : probeAcpAgentVersion({
28253
+ readCliVersion: (signal) => recipe.binaryPath.length === 0 ? Promise.resolve(null) : probeAcpAgentVersion({
28236
28254
  recipe,
28237
28255
  host,
28238
- env: buildSpawnEnv(recipe, recipe.homePath)
28256
+ env: buildSpawnEnv(recipe, recipe.homePath),
28257
+ ...signal === void 0 ? {} : { signal }
28239
28258
  }),
28240
28259
  // 暂不处理 input.readOnlyDirectories(有意为之):acp 经共享的 ycodium-acp-executor 起会话,
28241
28260
  // 还没用真机确认这家 CLI 对 cwd 之外的读怎么处理、要不要放行。确认之后再接这一栏。
@@ -28450,7 +28469,7 @@ var executors = [
28450
28469
  ];
28451
28470
  var index_default = definePlugin({
28452
28471
  id: "agent-acp",
28453
- apiVersion: 39,
28472
+ apiVersion: 41,
28454
28473
  executors,
28455
28474
  activate(ctx) {
28456
28475
  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.3478",
3
+ "version": "0.2.3502",
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.3478",
24
+ "@ycodium-ai/plugin-api": "0.2.3502",
25
25
  "ycodium-executor-testing": "0.0.0",
26
- "ycodium-acp-executor": "0.2.3478"
26
+ "ycodium-acp-executor": "0.2.3502"
27
27
  },
28
28
  "ycodium": {
29
29
  "plugin": "./dist/index.js",