@ycodium-ai/agent-acp 0.2.3210 → 0.2.3214

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 +120 -13
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -8,8 +8,8 @@ var __export = (target, all) => {
8
8
  import { definePlugin } from "@ycodium-ai/plugin-api";
9
9
 
10
10
  // src/acpInstance.ts
11
- import * as NodeOS2 from "node:os";
12
- import * as NodePath3 from "node:path";
11
+ import * as NodeOS3 from "node:os";
12
+ import * as NodePath4 from "node:path";
13
13
  import { mergeLaunchEnv, modelSelectionStringOption } from "@ycodium-ai/plugin-api/executor";
14
14
  import { nodeStreamsFromHandle as nodeStreamsFromHandle2 } from "@ycodium-ai/plugin-api/process-stdin";
15
15
 
@@ -26927,6 +26927,92 @@ function readOpenToolCalls(toolCalls, turnId) {
26927
26927
  return running;
26928
26928
  }
26929
26929
 
26930
+ // ../../packages/ycodium-acp-executor/src/protocol-log.ts
26931
+ import * as NodeFS from "node:fs";
26932
+ import * as NodeOS from "node:os";
26933
+ import * as NodePath2 from "node:path";
26934
+ var DEFAULT_MAX_BYTES = 8 * 1024 * 1024;
26935
+ var UNSAFE_FILE_CHARS = /[^A-Za-z0-9._-]+/gu;
26936
+ function safeFileName(value) {
26937
+ return value.replaceAll(UNSAFE_FILE_CHARS, "_");
26938
+ }
26939
+ function createAcpProtocolLogFile(input2) {
26940
+ const maxBytes = input2.maxBytes ?? DEFAULT_MAX_BYTES;
26941
+ NodeFS.mkdirSync(input2.directory, { recursive: true });
26942
+ const filePath = NodePath2.join(
26943
+ input2.directory,
26944
+ `${safeFileName(input2.provider)}-${safeFileName(input2.threadId)}-${Date.now().toString(36)}.ndjson`
26945
+ );
26946
+ const stream = (input2.openStream ?? ((path) => NodeFS.createWriteStream(path, { flags: "a" })))(
26947
+ filePath
26948
+ );
26949
+ let bytes = 0;
26950
+ let stopped = false;
26951
+ const closed = Promise.withResolvers();
26952
+ let closing = false;
26953
+ stream.once("close", () => closed.resolve());
26954
+ stream.on("error", () => {
26955
+ stopped = true;
26956
+ stream.destroy();
26957
+ });
26958
+ const writeTruncated = () => {
26959
+ stopped = true;
26960
+ const marker = `${JSON.stringify({ at: (/* @__PURE__ */ new Date()).toISOString(), stage: "truncated" })}
26961
+ `;
26962
+ if (bytes + Buffer.byteLength(marker) <= maxBytes) stream.write(marker);
26963
+ stream.end();
26964
+ };
26965
+ const writeLine = (value) => {
26966
+ if (stopped) return;
26967
+ const line = `${JSON.stringify(value)}
26968
+ `;
26969
+ const lineBytes = Buffer.byteLength(line);
26970
+ if (bytes + lineBytes > maxBytes) {
26971
+ writeTruncated();
26972
+ return;
26973
+ }
26974
+ bytes += lineBytes;
26975
+ stream.write(line);
26976
+ };
26977
+ return {
26978
+ path: filePath,
26979
+ write: (event) => writeLine({
26980
+ at: (/* @__PURE__ */ new Date()).toISOString(),
26981
+ direction: event.direction,
26982
+ stage: event.stage,
26983
+ payload: event.payload
26984
+ }),
26985
+ close: async () => {
26986
+ if (closing) return closed.promise;
26987
+ closing = true;
26988
+ stopped = true;
26989
+ stream.end();
26990
+ await closed.promise;
26991
+ }
26992
+ };
26993
+ }
26994
+ function createAcpProtocolLogFromEnv(input2) {
26995
+ const flag = process.env.YCODIUM_ACP_PROTOCOL_LOG;
26996
+ if (flag !== "1" && flag?.toLowerCase() !== "true") return void 0;
26997
+ const configured = process.env.YCODIUM_ACP_PROTOCOL_LOG_DIR?.trim();
26998
+ const directory = configured && configured.length > 0 ? configured : NodePath2.join(NodeOS.tmpdir(), "ycodium-acp-protocol");
26999
+ try {
27000
+ const sink = createAcpProtocolLogFile({
27001
+ directory,
27002
+ provider: input2.provider,
27003
+ threadId: input2.threadId
27004
+ });
27005
+ input2.log?.info("acp protocol frames are being recorded", { path: sink.path });
27006
+ return sink;
27007
+ } catch (error62) {
27008
+ input2.log?.warn?.("acp protocol frame log could not be opened", {
27009
+ directory,
27010
+ error: error62 instanceof Error ? error62.message : String(error62)
27011
+ });
27012
+ return void 0;
27013
+ }
27014
+ }
27015
+
26930
27016
  // ../../packages/ycodium-acp-executor/src/executor.ts
26931
27017
  var DEFAULT_CANCEL_GRACE_MS = 5e3;
26932
27018
  function defaultNowIso() {
@@ -27035,9 +27121,16 @@ function createAcpExecutor(options) {
27035
27121
  });
27036
27122
  const { rememberSettledPromptKey, abortPendingSettlement, settleFromNotification } = createExecutorSettlement({ hooks, shared });
27037
27123
  const promptResults = createPromptResults({ options, shared });
27124
+ const protocolLogSink = options.protocolLog === void 0 ? createAcpProtocolLogFromEnv({
27125
+ provider: options.provider,
27126
+ threadId: options.threadId,
27127
+ ...options.log === void 0 ? {} : { log: options.log }
27128
+ }) : void 0;
27129
+ const protocolLog = options.protocolLog ?? protocolLogSink?.write;
27038
27130
  const connection = createAcpConnection({
27039
27131
  readable: options.readable,
27040
27132
  writable: options.writable,
27133
+ ...protocolLog === void 0 ? {} : { logger: protocolLog },
27041
27134
  onInboundFailure: (error62) => {
27042
27135
  options.log?.warn?.("acp connection closed: an inbound request could not be answered", {
27043
27136
  threadId: options.threadId,
@@ -27134,7 +27227,11 @@ function createAcpExecutor(options) {
27134
27227
  notifyPromptSettled,
27135
27228
  shared
27136
27229
  });
27137
- const { cancel, compact, dispose } = createExecutorLifecycle({
27230
+ const {
27231
+ cancel,
27232
+ compact,
27233
+ dispose: disposeLifecycle
27234
+ } = createExecutorLifecycle({
27138
27235
  promptResults,
27139
27236
  failIfDisposed,
27140
27237
  requireStarted,
@@ -27161,6 +27258,7 @@ function createAcpExecutor(options) {
27161
27258
  onInputDead,
27162
27259
  shared
27163
27260
  });
27261
+ let disposeOnce;
27164
27262
  return {
27165
27263
  get generation() {
27166
27264
  return shared.generation;
@@ -27183,7 +27281,16 @@ function createAcpExecutor(options) {
27183
27281
  setNativeMode,
27184
27282
  compact,
27185
27283
  openToolCalls: () => readOpenToolCalls(toolCalls, shared.activeTurnId),
27186
- dispose
27284
+ dispose: () => {
27285
+ disposeOnce ??= (async () => {
27286
+ try {
27287
+ await disposeLifecycle();
27288
+ } finally {
27289
+ await protocolLogSink?.close();
27290
+ }
27291
+ })();
27292
+ return disposeOnce;
27293
+ }
27187
27294
  };
27188
27295
  }
27189
27296
 
@@ -27571,9 +27678,9 @@ function tokenizeLaunchArgs(value) {
27571
27678
  }
27572
27679
 
27573
27680
  // src/probeModels.ts
27574
- import * as NodeFS from "node:fs";
27575
- import * as NodeOS from "node:os";
27576
- import * as NodePath2 from "node:path";
27681
+ import * as NodeFS2 from "node:fs";
27682
+ import * as NodeOS2 from "node:os";
27683
+ import * as NodePath3 from "node:path";
27577
27684
  import {
27578
27685
  describeExecutorSpawnFailure,
27579
27686
  ExecutorSpawnRefusedError,
@@ -27585,7 +27692,7 @@ var CLIENT_INFO = { name: "ycodium-agent-acp-probe", version: "0.2.0" };
27585
27692
  var ACP_EFFORT_OPTION_ID = "reasoning";
27586
27693
  function acpProbeSessionCwd(instanceId) {
27587
27694
  const safe = instanceId.replace(/[^a-zA-Z0-9_-]/g, "_");
27588
- return NodePath2.join(NodeOS.tmpdir(), `ycodium-acp-probe-${safe}`);
27695
+ return NodePath3.join(NodeOS2.tmpdir(), `ycodium-acp-probe-${safe}`);
27589
27696
  }
27590
27697
  function isRecord7(value) {
27591
27698
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -27648,7 +27755,7 @@ async function probeAcpModelsViaSession(input2) {
27648
27755
  const { recipe, host, env } = input2;
27649
27756
  const probeCwd = acpProbeSessionCwd(host.instanceId);
27650
27757
  try {
27651
- NodeFS.mkdirSync(probeCwd, { recursive: true });
27758
+ NodeFS2.mkdirSync(probeCwd, { recursive: true });
27652
27759
  } catch (error62) {
27653
27760
  return { kind: "failed", detail: probeFailureDetail(error62), version: null };
27654
27761
  }
@@ -27755,9 +27862,9 @@ var EventBus = class {
27755
27862
  }
27756
27863
  };
27757
27864
  function expandHomePath(value) {
27758
- if (value === "~") return NodeOS2.homedir();
27865
+ if (value === "~") return NodeOS3.homedir();
27759
27866
  if (value.startsWith("~/") || value.startsWith("~\\")) {
27760
- return NodePath3.join(NodeOS2.homedir(), value.slice(2));
27867
+ return NodePath4.join(NodeOS3.homedir(), value.slice(2));
27761
27868
  }
27762
27869
  return value;
27763
27870
  }
@@ -27782,7 +27889,7 @@ function nowIso() {
27782
27889
  }
27783
27890
  function acpContinuationKey(recipe) {
27784
27891
  const homePath = recipe.homePath.trim();
27785
- const resolvedHomePath = homePath.length > 0 ? NodePath3.resolve(expandHomePath(homePath)) : "";
27892
+ const resolvedHomePath = homePath.length > 0 ? NodePath4.resolve(expandHomePath(homePath)) : "";
27786
27893
  return `acp:home:${recipe.binaryPath.trim()}\0${resolvedHomePath}`;
27787
27894
  }
27788
27895
  async function stopBooked(booked) {
@@ -28067,7 +28174,7 @@ var executors = [
28067
28174
  ];
28068
28175
  var index_default = definePlugin({
28069
28176
  id: "agent-acp",
28070
- apiVersion: 20,
28177
+ apiVersion: 21,
28071
28178
  executors,
28072
28179
  activate(ctx) {
28073
28180
  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.3210",
3
+ "version": "0.2.3214",
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-acp-executor": "0.2.3210",
25
- "ycodium-executor-testing": "0.0.0",
26
- "@ycodium-ai/plugin-api": "0.2.3210"
24
+ "@ycodium-ai/plugin-api": "0.2.3214",
25
+ "ycodium-acp-executor": "0.2.3214",
26
+ "ycodium-executor-testing": "0.0.0"
27
27
  },
28
28
  "ycodium": {
29
29
  "plugin": "./dist/index.js",