acpx 0.13.0 → 0.13.1

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.
@@ -1,11 +1,10 @@
1
- import { At as withInterrupt, Bt as isRetryablePromptError, C as mergeSessionOptions, Ct as isPromptInput, D as applyLifecycleSnapshotToRecord, Dt as textPrompt, E as applyConversation, Et as promptToDisplayText, F as modelStateFromConfigOptions, G as findSessionByDirectoryWalk, H as absolutePath, Ht as extractAcpError, J as listSessionsForAgent, Jt as OUTPUT_ERROR_CODES, K as isoNow, N as assertRequestedModelSupported, Ot as InterruptedError, Q as writeSessionRecord, R as splitCommandLine, S as advertisedModelState, T as sessionOptionsFromRecord, U as findGitRepositoryRoot, Vt as normalizeOutputError, W as findSession, Wt as toAcpErrorPayload, X as pruneSessions, Y as normalizeName, Yt as OUTPUT_ERROR_ORIGINS, Z as resolveSessionRecord, _ as createSessionConversation, _t as sessionEventSegmentPath, a as applyRequestedModelIfAdvertised, at as recordPerfDuration, b as recordSessionUpdate, bt as parseJsonRpcErrorMessage, c as setCurrentModelId, ct as startPerfTimer, d as setDesiredModelId, dt as normalizeRuntimeSessionId, f as syncAdvertisedModelState, g as cloneSessionConversation, gt as sessionEventLockPath, h as cloneSessionAcpxState, ht as sessionEventActivePath, i as connectAndLoadSession, it as measurePerf, jt as withTimeout, k as AcpClient, kt as TimeoutError, l as setDesiredConfigOption, m as applyConfigOptionsToState, mt as sessionBaseDir, n as runPromptTurn, nn as QueueConnectionError, nt as getPerfMetricsSnapshot, o as currentModelIdFromSetModelResponse, ot as resetPerfMetrics, p as applyConfigOptionsToRecord, pt as defaultSessionEventLog, q as listSessions, r as withConnectedSession, rn as QueueProtocolError, rt as incrementPerfCounter, s as clearDesiredConfigOption, st as setPerfGauge, t as LiveSessionCheckpoint, tt as formatPerfMetric, u as setDesiredModeId, v as recordClientOperation, vt as extractSessionUpdateNotification, w as persistSessionOptions, x as trimConversationForRuntime, xt as parsePromptStopReason, y as recordPromptSubmission, yt as isAcpJsonRpcMessage, zt as formatErrorMessage } from "./live-checkpoint-CBecfnSH.js";
1
+ import { $ as writeSessionRecord, At as TimeoutError, Bt as formatErrorMessage, C as mergeSessionOptions, D as applyLifecycleSnapshotToRecord, Dt as promptToDisplayText, E as applyConversation, F as modelStateFromConfigOptions, G as findSession, Gt as toAcpErrorPayload, Ht as normalizeOutputError, J as listSessions, K as findSessionByDirectoryWalk, Mt as withTimeout, N as assertRequestedModelSupported, Ot as textPrompt, Q as resolveSessionRecord, R as runTimedExecFile, S as advertisedModelState, St as parsePromptStopReason, T as sessionOptionsFromRecord, U as absolutePath, Ut as extractAcpError, Vt as isRetryablePromptError, W as findGitRepositoryRoot, X as normalizeName, Xt as OUTPUT_ERROR_ORIGINS, Y as listSessionsForAgent, Yt as OUTPUT_ERROR_CODES, Z as pruneSessions, _ as createSessionConversation, _t as sessionEventLockPath, a as applyRequestedModelIfAdvertised, at as measurePerf, b as recordSessionUpdate, bt as isAcpJsonRpcMessage, c as setCurrentModelId, ct as setPerfGauge, d as setDesiredModelId, f as syncAdvertisedModelState, ft as normalizeRuntimeSessionId, g as cloneSessionConversation, gt as sessionEventActivePath, h as cloneSessionAcpxState, ht as sessionBaseDir, i as connectAndLoadSession, in as QueueProtocolError, it as incrementPerfCounter, jt as withInterrupt, k as AcpClient, kt as InterruptedError, l as setDesiredConfigOption, lt as startPerfTimer, m as applyConfigOptionsToState, mt as defaultSessionEventLog, n as runPromptTurn, nt as formatPerfMetric, o as currentModelIdFromSetModelResponse, ot as recordPerfDuration, p as applyConfigOptionsToRecord, q as isoNow, r as withConnectedSession, rn as QueueConnectionError, rt as getPerfMetricsSnapshot, s as clearDesiredConfigOption, st as resetPerfMetrics, t as LiveSessionCheckpoint, u as setDesiredModeId, v as recordClientOperation, vt as sessionEventSegmentPath, w as persistSessionOptions, wt as isPromptInput, x as trimConversationForRuntime, xt as parseJsonRpcErrorMessage, y as recordPromptSubmission, yt as extractSessionUpdateNotification, z as splitCommandLine } from "./live-checkpoint-BSIrfgVo.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";
5
5
  import os from "node:os";
6
6
  import { createHash, randomInt, randomUUID } from "node:crypto";
7
- import { execFile, spawn } from "node:child_process";
8
- import { promisify } from "node:util";
7
+ import { spawn } from "node:child_process";
9
8
  import net from "node:net";
10
9
  //#region \0rolldown/runtime.js
11
10
  var __defProp = Object.defineProperty;
@@ -1629,8 +1628,45 @@ function toSessionMutationResult(result) {
1629
1628
  loadError: result.loadError
1630
1629
  };
1631
1630
  }
1631
+ /**
1632
+ * Re-apply the session-pinned model after reconnect, matching the prompt path.
1633
+ *
1634
+ * Some agents (e.g. opencode) restore to their default model on session load and
1635
+ * advertise model-dependent config options for that default. Without replaying
1636
+ * `session_options.model` first, `set` fails because the option set belongs to
1637
+ * the wrong model, and the record is overwritten with default-model options.
1638
+ */
1639
+ async function reapplyPinnedModelAfterConnect(params) {
1640
+ const pinnedModel = sessionOptionsFromRecord(params.record)?.model;
1641
+ if (!pinnedModel) return;
1642
+ const models = advertisedModelState(params.record.acpx);
1643
+ if (models?.currentModelId === pinnedModel) {
1644
+ setDesiredModelId(params.record, pinnedModel, models.configId);
1645
+ setCurrentModelId(params.record, pinnedModel);
1646
+ return;
1647
+ }
1648
+ const result = await applyRequestedModelIfAdvertised({
1649
+ client: params.client,
1650
+ sessionId: params.sessionId,
1651
+ requestedModel: pinnedModel,
1652
+ models,
1653
+ agentCommand: params.record.agentCommand,
1654
+ timeoutMs: params.timeoutMs
1655
+ });
1656
+ if (result.response) applyConfigOptionsToRecord(params.record, result.response);
1657
+ if (result.applied) {
1658
+ setDesiredModelId(params.record, pinnedModel, models?.configId);
1659
+ setCurrentModelId(params.record, currentModelIdFromSetModelResponse(result.response, pinnedModel));
1660
+ }
1661
+ }
1632
1662
  async function runSessionSetModeDirect(options) {
1633
1663
  return toSessionMutationResult(await withConnectedSession(buildDirectConnectedSessionOptions(options, async ({ client, sessionId, record }) => {
1664
+ await reapplyPinnedModelAfterConnect({
1665
+ client,
1666
+ sessionId,
1667
+ record,
1668
+ timeoutMs: options.timeoutMs
1669
+ });
1634
1670
  await withTimeout(client.setSessionMode(sessionId, options.modeId), options.timeoutMs);
1635
1671
  setDesiredModeId(record, options.modeId);
1636
1672
  })));
@@ -1652,6 +1688,12 @@ async function runSessionSetModelDirect(options) {
1652
1688
  async function runSessionSetConfigOptionDirect(options) {
1653
1689
  const result = await withConnectedSession(buildDirectConnectedSessionOptions(options, async ({ client, sessionId, record }) => {
1654
1690
  const modelConfigId = advertisedModelState(record.acpx)?.configId;
1691
+ if (options.configId !== modelConfigId) await reapplyPinnedModelAfterConnect({
1692
+ client,
1693
+ sessionId,
1694
+ record,
1695
+ timeoutMs: options.timeoutMs
1696
+ });
1655
1697
  const response = await withTimeout(client.setSessionConfigOption(sessionId, options.configId, options.value), options.timeoutMs);
1656
1698
  applyConfigOptionsToRecord(record, response);
1657
1699
  if (options.configId === modelConfigId) {
@@ -1670,7 +1712,6 @@ async function runSessionSetConfigOptionDirect(options) {
1670
1712
  }
1671
1713
  //#endregion
1672
1714
  //#region src/cli/session/session-control.ts
1673
- const execFileAsync = promisify(execFile);
1674
1715
  async function cancelSessionPrompt(options) {
1675
1716
  const cancelled = await tryCancelOnRunningOwner(options);
1676
1717
  return {
@@ -1790,26 +1831,24 @@ async function readProcCmdline(pid) {
1790
1831
  }
1791
1832
  async function readPosixCommandLine(pid) {
1792
1833
  try {
1793
- const { stdout } = await execFileAsync("ps", [
1834
+ return (await runTimedExecFile("ps", [
1794
1835
  "-p",
1795
1836
  String(pid),
1796
1837
  "-o",
1797
1838
  "command="
1798
- ]);
1799
- return stdout.trim() || void 0;
1839
+ ])).trim() || void 0;
1800
1840
  } catch {
1801
1841
  return;
1802
1842
  }
1803
1843
  }
1804
1844
  async function readWindowsCommandLine(pid) {
1805
1845
  try {
1806
- const { stdout } = await execFileAsync("powershell.exe", [
1846
+ return (await runTimedExecFile("powershell.exe", [
1807
1847
  "-NoProfile",
1808
1848
  "-NonInteractive",
1809
1849
  "-Command",
1810
1850
  `(Get-CimInstance Win32_Process -Filter "ProcessId = ${pid}").CommandLine`
1811
- ], { windowsHide: true });
1812
- return stdout.trim() || void 0;
1851
+ ], { windowsHide: true })).trim() || void 0;
1813
1852
  } catch {
1814
1853
  return;
1815
1854
  }
@@ -4722,4 +4761,4 @@ function createOutputFormatter(format, options = {}) {
4722
4761
  //#endregion
4723
4762
  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 };
4724
4763
 
4725
- //# sourceMappingURL=output-CzN8vLdE.js.map
4764
+ //# sourceMappingURL=output-BZQE0gI1.js.map