acpx 0.13.2 → 0.15.0

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 (34) hide show
  1. package/README.md +4 -3
  2. package/dist/{cli-DJT3MRRI.js → cli-Cen2Rb6S.js} +4 -4
  3. package/dist/{cli-DJT3MRRI.js.map → cli-Cen2Rb6S.js.map} +1 -1
  4. package/dist/cli.d.ts +5 -6
  5. package/dist/cli.d.ts.map +1 -1
  6. package/dist/cli.js +11 -8
  7. package/dist/cli.js.map +1 -1
  8. package/dist/{client-CxNllqui.d.ts → client-Cvz6msGc.d.ts} +8 -3
  9. package/dist/client-Cvz6msGc.d.ts.map +1 -0
  10. package/dist/{flags-CM2rAdBo.js → flags-CRh8BJre.js} +21 -4
  11. package/dist/flags-CRh8BJre.js.map +1 -0
  12. package/dist/{flows-BiRKgCnW.js → flows-D-F3Y2o9.js} +436 -63
  13. package/dist/flows-D-F3Y2o9.js.map +1 -0
  14. package/dist/flows.d.ts +27 -17
  15. package/dist/flows.d.ts.map +1 -1
  16. package/dist/flows.js +1 -1
  17. package/dist/{live-checkpoint-Gw2oGjhe.js → live-checkpoint-CYRs-D9t.js} +312 -124
  18. package/dist/live-checkpoint-CYRs-D9t.js.map +1 -0
  19. package/dist/{output-DiPPprGk.js → output-CIVecnHU.js} +42 -9
  20. package/dist/output-CIVecnHU.js.map +1 -0
  21. package/dist/runtime.d.ts +22 -15
  22. package/dist/runtime.d.ts.map +1 -1
  23. package/dist/runtime.js +46 -8
  24. package/dist/runtime.js.map +1 -1
  25. package/dist/{session-options-DwRDODlr.d.ts → session-options-DyIGRNfu.d.ts} +48 -2
  26. package/dist/session-options-DyIGRNfu.d.ts.map +1 -0
  27. package/package.json +10 -10
  28. package/skills/acpx/SKILL.md +5 -0
  29. package/dist/client-CxNllqui.d.ts.map +0 -1
  30. package/dist/flags-CM2rAdBo.js.map +0 -1
  31. package/dist/flows-BiRKgCnW.js.map +0 -1
  32. package/dist/live-checkpoint-Gw2oGjhe.js.map +0 -1
  33. package/dist/output-DiPPprGk.js.map +0 -1
  34. package/dist/session-options-DwRDODlr.d.ts.map +0 -1
@@ -1,4 +1,4 @@
1
- import { $ as formatPerfMetric, B as absolutePath, Bt as extractAcpError, C as sessionOptionsFromRecord, D as AcpClient, Dt as TimeoutError, Et as InterruptedError, F as runTimedExecFile, G as listSessions, H as findSession, Ht as toAcpErrorPayload, I as splitCommandLine, J as pruneSessions, K as listSessionsForAgent, Kt as OUTPUT_ERROR_CODES, Lt as formatErrorMessage, M as modelStateFromConfigOptions, Ot as withInterrupt, Rt as isRetryablePromptError, S as persistSessionOptions, T as applyLifecycleSnapshotToRecord, Tt as textPrompt, U as findSessionByDirectoryWalk, V as findGitRepositoryRoot, W as isoNow, X as writeSessionRecord, Y as resolveSessionRecord, _ as recordPromptSubmission, _t as isAcpJsonRpcMessage, a as applyConfigOptionSelection, at as setPerfGauge, b as advertisedModelState, c as applyRequestedModelIfAdvertised, d as setDesiredModeId, dt as defaultSessionEventLog, en as QueueConnectionError, et as getPerfMetricsSnapshot, f as syncAdvertisedModelState, ft as sessionBaseDir, g as recordClientOperation, gt as extractSessionUpdateNotification, h as createSessionConversation, ht as sessionEventSegmentPath, i as connectAndLoadSession, it as resetPerfMetrics, kt as withTimeout, l as currentModelIdFromSetModelResponse, lt as normalizeRuntimeSessionId, m as cloneSessionConversation, mt as sessionEventLockPath, n as runPromptTurn, nt as measurePerf, o as applyConfigOptionsToRecord, ot as startPerfTimer, p as cloneSessionAcpxState, pt as sessionEventActivePath, q as normalizeName, qt as OUTPUT_ERROR_ORIGINS, r as withConnectedSession, rt as recordPerfDuration, s as applyModelSelection, t as LiveSessionCheckpoint, tn as QueueProtocolError, tt as incrementPerfCounter, u as setCurrentModelId, v as recordSessionUpdate, vt as parseJsonRpcErrorMessage, w as applyConversation, wt as promptToDisplayText, x as mergeSessionOptions, xt as isPromptInput, y as trimConversationForRuntime, yt as parsePromptStopReason, zt as normalizeOutputError } from "./live-checkpoint-Gw2oGjhe.js";
1
+ import { $ as formatPerfMetric, B as absolutePath, Bt as extractAcpError, C as sessionOptionsFromRecord, D as AcpClient, Dt as TimeoutError, Et as InterruptedError, F as runTimedExecFile, G as listSessions, H as findSession, Ht as toAcpErrorPayload, I as splitCommandLine, J as pruneSessions, K as listSessionsForAgent, Kt as OUTPUT_ERROR_CODES, Lt as formatErrorMessage, M as modelStateFromConfigOptions, Ot as withInterrupt, Rt as isRetryablePromptError, S as persistSessionOptions, T as applyLifecycleSnapshotToRecord, Tt as textPrompt, U as findSessionByDirectoryWalk, V as findGitRepositoryRoot, W as isoNow, X as writeSessionRecord, Y as resolveSessionRecord, _ as recordPromptSubmission, _t as isAcpJsonRpcMessage, a as applyConfigOptionSelection, at as setPerfGauge, b as advertisedModelState, c as applyRequestedModelIfAdvertised, d as setDesiredModeId, dt as defaultSessionEventLog, en as QueueConnectionError, et as getPerfMetricsSnapshot, f as syncAdvertisedModelState, ft as sessionBaseDir, g as recordClientOperation, gt as extractSessionUpdateNotification, h as createSessionConversation, ht as sessionEventSegmentPath, i as connectAndLoadSession, it as resetPerfMetrics, kt as withTimeout, l as currentModelIdFromSetModelResponse, lt as normalizeRuntimeSessionId, m as cloneSessionConversation, mt as sessionEventLockPath, n as runPromptTurn, nt as measurePerf, o as applyConfigOptionsToRecord, ot as startPerfTimer, p as cloneSessionAcpxState, pt as sessionEventActivePath, q as normalizeName, qt as OUTPUT_ERROR_ORIGINS, r as withConnectedSession, rt as recordPerfDuration, s as applyModelSelection, t as LiveSessionCheckpoint, tn as QueueProtocolError, tt as incrementPerfCounter, u as setCurrentModelId, v as recordSessionUpdate, vt as parseJsonRpcErrorMessage, w as applyConversation, wt as promptToDisplayText, x as mergeSessionOptions, xt as isPromptInput, y as trimConversationForRuntime, yt as parsePromptStopReason, zt as normalizeOutputError } from "./live-checkpoint-CYRs-D9t.js";
2
2
  import fs, { mkdtempSync, realpathSync, writeFileSync } from "node:fs";
3
3
  import path from "node:path";
4
4
  import fs$1 from "node:fs/promises";
@@ -624,7 +624,7 @@ function parseSessionSendResult(raw) {
624
624
  return result;
625
625
  }
626
626
  function hasValidSessionSendResultCore(result) {
627
- return typeof result.stopReason === "string" && typeof result.sessionId === "string" && typeof result.resumed === "boolean";
627
+ return typeof result.stopReason === "string" && typeof result.sessionId === "string" && typeof result.resumed === "boolean" && (result._meta === void 0 || result._meta === null || asRecord$2(result._meta) !== void 0);
628
628
  }
629
629
  function hasValidPermissionStats(permissionStats) {
630
630
  return [
@@ -760,6 +760,25 @@ function isValidOwnerErrorCore(message) {
760
760
  return typeof message.message === "string" && isOutputErrorCode(message.code) && isOutputErrorOrigin(message.origin);
761
761
  }
762
762
  //#endregion
763
+ //#region src/cli/queue/request-limit.ts
764
+ function queueRequestByteLimit(raw = process.env.ACPX_QUEUE_MAX_REQUEST_BYTES) {
765
+ if (raw === void 0 || raw.trim() === "") return;
766
+ const limit = Number(raw);
767
+ if (!Number.isSafeInteger(limit) || limit < 0 || !/^\d+$/.test(raw.trim())) throw new Error("ACPX_QUEUE_MAX_REQUEST_BYTES must be a non-negative safe integer; zero is unlimited");
768
+ return limit || void 0;
769
+ }
770
+ function queueRequestExceedsLimit(line, limit) {
771
+ return limit !== void 0 && Buffer.byteLength(line, "utf8") > limit;
772
+ }
773
+ function assertQueueRequestSize(line) {
774
+ const limit = queueRequestByteLimit();
775
+ if (queueRequestExceedsLimit(line, limit)) throw new QueueProtocolError(`Queue request exceeded ACPX_QUEUE_MAX_REQUEST_BYTES (${limit} bytes); raise or unset the limit`, {
776
+ detailCode: "QUEUE_REQUEST_TOO_LARGE",
777
+ origin: "queue",
778
+ retryable: false
779
+ });
780
+ }
781
+ //#endregion
763
782
  //#region src/cli/queue/ipc-server.ts
764
783
  const QUEUE_SOCKET_DRAIN_TIMEOUT_MS = 1e3;
765
784
  function makeQueueOwnerError(requestId, message, detailCode, options = {}) {
@@ -801,6 +820,7 @@ var SessionQueueOwner = class SessionQueueOwner {
801
820
  controlHandlers;
802
821
  ownerGeneration;
803
822
  maxQueueDepth;
823
+ maxRequestBytes;
804
824
  onQueueDepthChanged;
805
825
  pending = [];
806
826
  waiters = [];
@@ -813,6 +833,7 @@ var SessionQueueOwner = class SessionQueueOwner {
813
833
  this.controlHandlers = controlHandlers;
814
834
  this.ownerGeneration = lease.ownerGeneration;
815
835
  this.maxQueueDepth = Math.max(1, Math.round(options.maxQueueDepth));
836
+ this.maxRequestBytes = queueRequestByteLimit(options.maxRequestBytes?.toString());
816
837
  this.onQueueDepthChanged = options.onQueueDepthChanged;
817
838
  }
818
839
  static async start(lease, controlHandlers, options = { maxQueueDepth: 16 }) {
@@ -1105,14 +1126,22 @@ var SessionQueueOwner = class SessionQueueOwner {
1105
1126
  buffer += chunk;
1106
1127
  let index = buffer.indexOf("\n");
1107
1128
  while (index >= 0) {
1108
- const line = buffer.slice(0, index).trim();
1129
+ const rawLine = buffer.slice(0, index);
1130
+ if (this.rejectOversizedRequest(socket, rawLine)) return;
1131
+ const line = rawLine.trim();
1109
1132
  buffer = buffer.slice(index + 1);
1110
1133
  if (line.length > 0) processLine(line);
1111
1134
  index = buffer.indexOf("\n");
1112
1135
  }
1136
+ this.rejectOversizedRequest(socket, buffer);
1113
1137
  });
1114
1138
  socket.on("error", () => {});
1115
1139
  }
1140
+ rejectOversizedRequest(socket, line) {
1141
+ if (!queueRequestExceedsLimit(line, this.maxRequestBytes)) return false;
1142
+ socket.destroy();
1143
+ return true;
1144
+ }
1116
1145
  };
1117
1146
  //#endregion
1118
1147
  //#region src/cli/queue/ipc.ts
@@ -1187,6 +1216,8 @@ function parseQueueOwnerResponseLine(owner, requestId, line) {
1187
1216
  return message;
1188
1217
  }
1189
1218
  async function runQueueOwnerRequest(options) {
1219
+ const requestLine = JSON.stringify(options.request);
1220
+ assertQueueRequestSize(requestLine);
1190
1221
  const socket = await connectToQueueOwner(options.owner);
1191
1222
  if (!socket) return;
1192
1223
  socket.setEncoding("utf8");
@@ -1250,7 +1281,7 @@ async function runQueueOwnerRequest(options) {
1250
1281
  if (settled) return;
1251
1282
  options.onClose(controls);
1252
1283
  });
1253
- socket.write(`${JSON.stringify(options.request)}\n`);
1284
+ socket.write(`${requestLine}\n`);
1254
1285
  });
1255
1286
  }
1256
1287
  function missingQueueAckError() {
@@ -2683,11 +2714,12 @@ var AcpErrorTracker = class {
2683
2714
  return this.latestInbound ?? this.outbound.findLast((acp) => outboundAcpErrorMatches(error, acp));
2684
2715
  }
2685
2716
  };
2686
- function toPromptResult(stopReason, sessionId, client) {
2717
+ function toPromptResult(stopReason, sessionId, client, meta) {
2687
2718
  return {
2688
2719
  stopReason,
2689
2720
  sessionId,
2690
- permissionStats: client.getPermissionStats()
2721
+ permissionStats: client.getPermissionStats(),
2722
+ ...meta === void 0 ? {} : { _meta: meta }
2691
2723
  };
2692
2724
  }
2693
2725
  function requestedModelId(value) {
@@ -3167,7 +3199,7 @@ async function runSessionPrompt(options) {
3167
3199
  const response = await savePromptSuccess(await runPromptWithRetries(activeSessionId));
3168
3200
  promptTurnActive = false;
3169
3201
  return {
3170
- ...toPromptResult(response.stopReason, record.acpxRecordId, client),
3202
+ ...toPromptResult(response.stopReason, record.acpxRecordId, client, response._meta),
3171
3203
  record,
3172
3204
  resumed,
3173
3205
  loadError
@@ -3284,11 +3316,12 @@ async function runOnce(options) {
3284
3316
  timeoutMs: options.timeoutMs,
3285
3317
  onWarning: options.suppressSdkConsoleErrors ? void 0 : (message) => process.stderr.write(`[acpx] warning: ${message}\n`)
3286
3318
  });
3319
+ for (const configOption of options.configOptions ?? []) await withTimeout(client.setSessionConfigOption(sessionId, configOption.configId, configOption.value), options.timeoutMs);
3287
3320
  output.setContext({ sessionId });
3288
3321
  const response = await runExecPromptWithRetries(sessionId);
3289
3322
  promptTurnActive = false;
3290
3323
  output.flush();
3291
- return toPromptResult(response.stopReason, sessionId, client);
3324
+ return toPromptResult(response.stopReason, sessionId, client, response._meta);
3292
3325
  }, async () => {
3293
3326
  await client.cancelActivePrompt(INTERRUPT_CANCEL_WAIT_MS);
3294
3327
  await client.close();
@@ -4678,4 +4711,4 @@ function createOutputFormatter(format, options = {}) {
4678
4711
  //#endregion
4679
4712
  export { runSessionQueueOwner as a, buildQueueOwnerArgOverride as c, createSessionWithClient as d, cancelSessionPrompt as f, __exportAll as g, isProcessAlive as h, session_exports as i, flushPerfMetricsCapture as l, DEFAULT_QUEUE_OWNER_TTL_MS as m, getTextErrorRemediationHints as n, runOnce as o, probeQueueOwnerHealth as p, output_exports as r, sendSessionDirect as s, createOutputFormatter as t, installPerfMetricsCapture as u };
4680
4713
 
4681
- //# sourceMappingURL=output-DiPPprGk.js.map
4714
+ //# sourceMappingURL=output-CIVecnHU.js.map