acpx 0.13.1 → 0.13.2
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.
- package/dist/{cli-_7Sei6dD.js → cli-DJT3MRRI.js} +6 -5
- package/dist/{cli-_7Sei6dD.js.map → cli-DJT3MRRI.js.map} +1 -1
- package/dist/cli.js +20 -13
- package/dist/cli.js.map +1 -1
- package/dist/{flags-Ds6FzmHG.js → flags-CM2rAdBo.js} +3 -3
- package/dist/{flags-Ds6FzmHG.js.map → flags-CM2rAdBo.js.map} +1 -1
- package/dist/{flows-fzH0GKYF.js → flows-BiRKgCnW.js} +4 -4
- package/dist/{flows-fzH0GKYF.js.map → flows-BiRKgCnW.js.map} +1 -1
- package/dist/flows.js +1 -1
- package/dist/{live-checkpoint-BSIrfgVo.js → live-checkpoint-Gw2oGjhe.js} +102 -68
- package/dist/{live-checkpoint-BSIrfgVo.js.map → live-checkpoint-Gw2oGjhe.js.map} +1 -1
- package/dist/{output-BZQE0gI1.js → output-DiPPprGk.js} +35 -118
- package/dist/output-DiPPprGk.js.map +1 -0
- package/dist/runtime.d.ts +5 -8
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +51 -104
- package/dist/runtime.js.map +1 -1
- package/package.json +15 -15
- package/skills/acpx/SKILL.md +5 -1
- package/dist/output-BZQE0gI1.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
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";
|
|
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";
|
|
@@ -1116,7 +1116,7 @@ var SessionQueueOwner = class SessionQueueOwner {
|
|
|
1116
1116
|
};
|
|
1117
1117
|
//#endregion
|
|
1118
1118
|
//#region src/cli/queue/ipc.ts
|
|
1119
|
-
const MAX_MESSAGE_BUFFER_SIZE =
|
|
1119
|
+
const MAX_MESSAGE_BUFFER_SIZE = 10485760;
|
|
1120
1120
|
const STALE_OWNER_PROTOCOL_DETAIL_CODES = /* @__PURE__ */ new Set(["QUEUE_PROTOCOL_MALFORMED_MESSAGE", "QUEUE_PROTOCOL_UNEXPECTED_RESPONSE"]);
|
|
1121
1121
|
async function maybeRecoverStaleOwnerAfterProtocolMismatch(params) {
|
|
1122
1122
|
if (!(params.error instanceof QueueProtocolError)) return false;
|
|
@@ -1604,6 +1604,7 @@ async function trySetConfigOptionOnRunningOwner(sessionId, configId, value, time
|
|
|
1604
1604
|
function buildDirectConnectedSessionOptions(options, run) {
|
|
1605
1605
|
return {
|
|
1606
1606
|
sessionRecordId: options.sessionRecordId,
|
|
1607
|
+
replacingConfigOption: options.replacingConfigOption,
|
|
1607
1608
|
loadRecord: resolveSessionRecord,
|
|
1608
1609
|
saveRecord: writeSessionRecord,
|
|
1609
1610
|
mcpServers: options.mcpServers,
|
|
@@ -1628,56 +1629,20 @@ function toSessionMutationResult(result) {
|
|
|
1628
1629
|
loadError: result.loadError
|
|
1629
1630
|
};
|
|
1630
1631
|
}
|
|
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
|
-
}
|
|
1662
1632
|
async function runSessionSetModeDirect(options) {
|
|
1663
1633
|
return toSessionMutationResult(await withConnectedSession(buildDirectConnectedSessionOptions(options, async ({ client, sessionId, record }) => {
|
|
1664
|
-
await reapplyPinnedModelAfterConnect({
|
|
1665
|
-
client,
|
|
1666
|
-
sessionId,
|
|
1667
|
-
record,
|
|
1668
|
-
timeoutMs: options.timeoutMs
|
|
1669
|
-
});
|
|
1670
1634
|
await withTimeout(client.setSessionMode(sessionId, options.modeId), options.timeoutMs);
|
|
1671
1635
|
setDesiredModeId(record, options.modeId);
|
|
1672
1636
|
})));
|
|
1673
1637
|
}
|
|
1674
1638
|
async function runSessionSetModelDirect(options) {
|
|
1675
|
-
const result = await withConnectedSession(buildDirectConnectedSessionOptions(
|
|
1639
|
+
const result = await withConnectedSession(buildDirectConnectedSessionOptions({
|
|
1640
|
+
...options,
|
|
1641
|
+
replacingConfigOption: { key: "model" }
|
|
1642
|
+
}, async ({ client, sessionId, record }) => {
|
|
1676
1643
|
const models = advertisedModelState(record.acpx);
|
|
1677
1644
|
const response = await withTimeout(client.setSessionModel(sessionId, options.modelId, models), options.timeoutMs);
|
|
1678
|
-
|
|
1679
|
-
setDesiredModelId(record, options.modelId, models?.configId);
|
|
1680
|
-
setCurrentModelId(record, currentModelIdFromSetModelResponse(response, options.modelId));
|
|
1645
|
+
record.acpx = applyModelSelection(record.acpx, options.modelId, response);
|
|
1681
1646
|
return response;
|
|
1682
1647
|
}));
|
|
1683
1648
|
return {
|
|
@@ -1686,21 +1651,12 @@ async function runSessionSetModelDirect(options) {
|
|
|
1686
1651
|
};
|
|
1687
1652
|
}
|
|
1688
1653
|
async function runSessionSetConfigOptionDirect(options) {
|
|
1689
|
-
const result = await withConnectedSession(buildDirectConnectedSessionOptions(
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
sessionId,
|
|
1694
|
-
record,
|
|
1695
|
-
timeoutMs: options.timeoutMs
|
|
1696
|
-
});
|
|
1654
|
+
const result = await withConnectedSession(buildDirectConnectedSessionOptions({
|
|
1655
|
+
...options,
|
|
1656
|
+
replacingConfigOption: { key: options.configId }
|
|
1657
|
+
}, async ({ client, sessionId, record }) => {
|
|
1697
1658
|
const response = await withTimeout(client.setSessionConfigOption(sessionId, options.configId, options.value), options.timeoutMs);
|
|
1698
|
-
|
|
1699
|
-
if (options.configId === modelConfigId) {
|
|
1700
|
-
setDesiredModelId(record, options.value, options.configId);
|
|
1701
|
-
setCurrentModelId(record, currentModelIdFromSetModelResponse(response, options.value));
|
|
1702
|
-
} else if (options.configId === "mode") setDesiredModeId(record, options.value);
|
|
1703
|
-
else setDesiredConfigOption(record, options.configId, options.value);
|
|
1659
|
+
record.acpx = applyConfigOptionSelection(record.acpx, options.configId, options.value, response);
|
|
1704
1660
|
return response;
|
|
1705
1661
|
}));
|
|
1706
1662
|
return {
|
|
@@ -1746,9 +1702,7 @@ async function setSessionModel(options) {
|
|
|
1746
1702
|
const submittedToOwner = await trySetModelOnRunningOwner(options.sessionId, options.modelId, options.timeoutMs, options.verbose);
|
|
1747
1703
|
if (submittedToOwner) {
|
|
1748
1704
|
const record = await resolveSessionRecord(options.sessionId);
|
|
1749
|
-
|
|
1750
|
-
setDesiredModelId(record, options.modelId, advertisedModelState(record.acpx)?.configId);
|
|
1751
|
-
setCurrentModelId(record, currentModelIdFromSetModelResponse(submittedToOwner.response, options.modelId));
|
|
1705
|
+
record.acpx = applyModelSelection(record.acpx, options.modelId, submittedToOwner.response);
|
|
1752
1706
|
await writeSessionRecord(record);
|
|
1753
1707
|
return {
|
|
1754
1708
|
record,
|
|
@@ -1773,13 +1727,7 @@ async function setSessionConfigOption(options) {
|
|
|
1773
1727
|
const ownerResponse = await trySetConfigOptionOnRunningOwner(options.sessionId, options.configId, options.value, options.timeoutMs, options.verbose);
|
|
1774
1728
|
if (ownerResponse) {
|
|
1775
1729
|
const record = await resolveSessionRecord(options.sessionId);
|
|
1776
|
-
|
|
1777
|
-
applyConfigOptionsToRecord(record, ownerResponse);
|
|
1778
|
-
if (options.configId === modelConfigId) {
|
|
1779
|
-
setDesiredModelId(record, options.value, options.configId);
|
|
1780
|
-
setCurrentModelId(record, currentModelIdFromSetModelResponse(ownerResponse, options.value));
|
|
1781
|
-
} else if (options.configId === "mode") setDesiredModeId(record, options.value);
|
|
1782
|
-
else setDesiredConfigOption(record, options.configId, options.value);
|
|
1730
|
+
record.acpx = applyConfigOptionSelection(record.acpx, options.configId, options.value, ownerResponse);
|
|
1783
1731
|
await writeSessionRecord(record);
|
|
1784
1732
|
return {
|
|
1785
1733
|
record,
|
|
@@ -2745,10 +2693,6 @@ function toPromptResult(stopReason, sessionId, client) {
|
|
|
2745
2693
|
function requestedModelId(value) {
|
|
2746
2694
|
return typeof value === "string" ? value.trim() : "";
|
|
2747
2695
|
}
|
|
2748
|
-
function applyConfigOptionResponseToState(state, response) {
|
|
2749
|
-
if (!response?.configOptions) return state;
|
|
2750
|
-
return applyConfigOptionsToState(state, response.configOptions);
|
|
2751
|
-
}
|
|
2752
2696
|
function mergeConnectedModelState(state, connectedState) {
|
|
2753
2697
|
if (!connectedState) return state;
|
|
2754
2698
|
const nextState = cloneSessionAcpxState(state) ?? {};
|
|
@@ -2770,29 +2714,21 @@ function mergeConnectedModelPreferences(nextState, connectedState) {
|
|
|
2770
2714
|
if (connectedState.session_options) nextState.session_options = cloneSessionAcpxState(connectedState)?.session_options;
|
|
2771
2715
|
if (connectedState.desired_mode_id !== void 0) nextState.desired_mode_id = connectedState.desired_mode_id;
|
|
2772
2716
|
if (connectedState.desired_config_options) nextState.desired_config_options = { ...connectedState.desired_config_options };
|
|
2717
|
+
else delete nextState.desired_config_options;
|
|
2773
2718
|
}
|
|
2774
2719
|
async function applyPromptModelIfAdvertised(params) {
|
|
2775
2720
|
const requestedModel = requestedModelId(params.requestedModel);
|
|
2776
2721
|
if (!requestedModel) return;
|
|
2777
|
-
const
|
|
2778
|
-
|
|
2722
|
+
const result = await applyRequestedModelIfAdvertised({
|
|
2723
|
+
client: params.client,
|
|
2724
|
+
sessionId: params.sessionId,
|
|
2779
2725
|
requestedModel,
|
|
2780
|
-
models,
|
|
2726
|
+
models: advertisedModelState(params.record.acpx),
|
|
2781
2727
|
agentCommand: params.record.agentCommand,
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
if (params.record.acpx
|
|
2786
|
-
setDesiredModelId(params.record, requestedModel, models.configId);
|
|
2787
|
-
return;
|
|
2788
|
-
}
|
|
2789
|
-
const response = await withTimeout(params.client.setSessionModel(params.sessionId, requestedModel, models), params.timeoutMs);
|
|
2790
|
-
applyConfigOptionsToRecord(params.record, response);
|
|
2791
|
-
setDesiredModelId(params.record, requestedModel, models.configId);
|
|
2792
|
-
setCurrentModelId(params.record, currentModelIdFromSetModelResponse(response, requestedModel));
|
|
2793
|
-
}
|
|
2794
|
-
function emitModelSupportWarning(warning, suppressWarnings) {
|
|
2795
|
-
if (warning && !suppressWarnings) process.stderr.write(`[acpx] warning: ${warning}\n`);
|
|
2728
|
+
timeoutMs: params.timeoutMs,
|
|
2729
|
+
onWarning: params.suppressWarnings ? void 0 : (message) => process.stderr.write(`[acpx] warning: ${message}\n`)
|
|
2730
|
+
});
|
|
2731
|
+
if (result.applied) params.record.acpx = applyModelSelection(params.record.acpx, requestedModel, result.response);
|
|
2796
2732
|
}
|
|
2797
2733
|
function jsonRpcIdKey$1(value) {
|
|
2798
2734
|
if (typeof value === "string") return `s:${value}`;
|
|
@@ -3015,7 +2951,7 @@ async function runSessionPrompt(options) {
|
|
|
3015
2951
|
if (options.verbose) process.stderr.write("[acpx] live session checkpoint failed: " + formatErrorMessage(error) + "\n");
|
|
3016
2952
|
}
|
|
3017
2953
|
});
|
|
3018
|
-
|
|
2954
|
+
let closeClientOnExit = options.client == null;
|
|
3019
2955
|
const client = options.client ?? new AcpClient({
|
|
3020
2956
|
agentCommand: record.agentCommand,
|
|
3021
2957
|
agentArgv: record.agentArgv,
|
|
@@ -3086,34 +3022,13 @@ async function runSessionPrompt(options) {
|
|
|
3086
3022
|
setSessionModel: async (modelId) => {
|
|
3087
3023
|
const models = advertisedModelState(acpxState);
|
|
3088
3024
|
const response = await client.setSessionModel(activeSessionIdForControl, modelId, models);
|
|
3089
|
-
acpxState =
|
|
3090
|
-
const nextState = cloneSessionAcpxState(acpxState) ?? {};
|
|
3091
|
-
nextState.session_options = {
|
|
3092
|
-
...nextState.session_options,
|
|
3093
|
-
model: modelId
|
|
3094
|
-
};
|
|
3095
|
-
nextState.current_model_id = currentModelIdFromSetModelResponse(response, modelId);
|
|
3096
|
-
clearDesiredConfigOption(nextState, models?.configId);
|
|
3097
|
-
acpxState = nextState;
|
|
3025
|
+
acpxState = applyModelSelection(acpxState, modelId, response);
|
|
3098
3026
|
return response;
|
|
3099
3027
|
},
|
|
3100
3028
|
setSessionConfigOption: async (configId, value) => {
|
|
3029
|
+
const modelConfigId = advertisedModelState(acpxState)?.configId;
|
|
3101
3030
|
const response = await client.setSessionConfigOption(activeSessionIdForControl, configId, value);
|
|
3102
|
-
acpxState =
|
|
3103
|
-
const nextState = cloneSessionAcpxState(acpxState) ?? {};
|
|
3104
|
-
if (configId === modelStateFromConfigOptions(nextState.config_options)?.configId) {
|
|
3105
|
-
nextState.session_options = {
|
|
3106
|
-
...nextState.session_options,
|
|
3107
|
-
model: value
|
|
3108
|
-
};
|
|
3109
|
-
nextState.current_model_id = currentModelIdFromSetModelResponse(response, value);
|
|
3110
|
-
clearDesiredConfigOption(nextState, configId);
|
|
3111
|
-
} else if (configId === "mode") nextState.desired_mode_id = value;
|
|
3112
|
-
else nextState.desired_config_options = {
|
|
3113
|
-
...nextState.desired_config_options,
|
|
3114
|
-
[configId]: value
|
|
3115
|
-
};
|
|
3116
|
-
acpxState = nextState;
|
|
3031
|
+
acpxState = applyConfigOptionSelection(acpxState, configId, value, response, modelConfigId);
|
|
3117
3032
|
return response;
|
|
3118
3033
|
}
|
|
3119
3034
|
};
|
|
@@ -3131,6 +3046,7 @@ async function runSessionPrompt(options) {
|
|
|
3131
3046
|
client,
|
|
3132
3047
|
record,
|
|
3133
3048
|
resumePolicy: options.resumePolicy,
|
|
3049
|
+
replacingConfigOption: requestedModelId(options.sessionOptions?.model) ? { key: "model" } : void 0,
|
|
3134
3050
|
timeoutMs: options.timeoutMs,
|
|
3135
3051
|
verbose: options.verbose,
|
|
3136
3052
|
suppressWarnings: options.suppressSdkConsoleErrors,
|
|
@@ -3152,6 +3068,7 @@ async function runSessionPrompt(options) {
|
|
|
3152
3068
|
emitConnectPerfMetric(connectStartedAt, options.verbose);
|
|
3153
3069
|
return connected;
|
|
3154
3070
|
} catch (error) {
|
|
3071
|
+
closeClientOnExit = true;
|
|
3155
3072
|
flushConnectOutput();
|
|
3156
3073
|
throw error;
|
|
3157
3074
|
}
|
|
@@ -3239,7 +3156,7 @@ async function runSessionPrompt(options) {
|
|
|
3239
3156
|
await applyPromptModelIfAdvertised({
|
|
3240
3157
|
client,
|
|
3241
3158
|
sessionId: activeSessionId,
|
|
3242
|
-
requestedModel: sessionOptions?.model,
|
|
3159
|
+
requestedModel: options.sessionOptions?.model,
|
|
3243
3160
|
record,
|
|
3244
3161
|
timeoutMs: options.timeoutMs,
|
|
3245
3162
|
suppressWarnings: options.suppressSdkConsoleErrors
|
|
@@ -3263,7 +3180,7 @@ async function runSessionPrompt(options) {
|
|
|
3263
3180
|
applyConversation(record, conversation);
|
|
3264
3181
|
record.acpx = acpxState;
|
|
3265
3182
|
await flushPendingMessages(false).catch(() => {});
|
|
3266
|
-
if (
|
|
3183
|
+
if (closeClientOnExit) await client.close();
|
|
3267
3184
|
};
|
|
3268
3185
|
try {
|
|
3269
3186
|
return await runWithOptionalInterrupt({
|
|
@@ -3281,7 +3198,7 @@ async function runSessionPrompt(options) {
|
|
|
3281
3198
|
else stopTotalTimer();
|
|
3282
3199
|
if (notifiedClientAvailable) options.onClientClosed?.();
|
|
3283
3200
|
client.clearEventHandlers();
|
|
3284
|
-
if (
|
|
3201
|
+
if (closeClientOnExit) await client.close();
|
|
3285
3202
|
applyLifecycleSnapshotToRecord(record, client.getAgentLifecycleSnapshot());
|
|
3286
3203
|
applyConversation(record, conversation);
|
|
3287
3204
|
record.acpx = acpxState;
|
|
@@ -4413,7 +4330,7 @@ function limitOutputBlock(value) {
|
|
|
4413
4330
|
const hidden = lines.length - visible.length;
|
|
4414
4331
|
result += `\n... (${hidden} more lines)`;
|
|
4415
4332
|
}
|
|
4416
|
-
if (result.length > MAX_OUTPUT_CHARS) result = `${result.slice(0,
|
|
4333
|
+
if (result.length > MAX_OUTPUT_CHARS) result = `${result.slice(0, 1997)}...`;
|
|
4417
4334
|
return result;
|
|
4418
4335
|
}
|
|
4419
4336
|
var TextOutputFormatter = class {
|
|
@@ -4761,4 +4678,4 @@ function createOutputFormatter(format, options = {}) {
|
|
|
4761
4678
|
//#endregion
|
|
4762
4679
|
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 };
|
|
4763
4680
|
|
|
4764
|
-
//# sourceMappingURL=output-
|
|
4681
|
+
//# sourceMappingURL=output-DiPPprGk.js.map
|