acpx 0.5.3 → 0.6.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.
- package/README.md +12 -4
- package/dist/{cli-ChWsO-bb.js → cli-Ddxpnz9X.js} +4 -4
- package/dist/{cli-ChWsO-bb.js.map → cli-Ddxpnz9X.js.map} +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +147 -75
- package/dist/cli.js.map +1 -1
- package/dist/{client-D-4_aZf2.d.ts → client-2fTFutRH.d.ts} +4 -2
- package/dist/client-2fTFutRH.d.ts.map +1 -0
- package/dist/{flags-ceSqz2T6.js → flags-yXzUm7Aq.js} +25 -6
- package/dist/flags-yXzUm7Aq.js.map +1 -0
- package/dist/{flows-_KmnuUXd.js → flows-CDsfbaA2.js} +13 -6
- package/dist/flows-CDsfbaA2.js.map +1 -0
- package/dist/flows.d.ts +2 -8
- package/dist/flows.d.ts.map +1 -1
- package/dist/flows.js +1 -1
- package/dist/{ipc-BM335WFg.js → ipc-BruTG5Fb.js} +50 -19
- package/dist/ipc-BruTG5Fb.js.map +1 -0
- package/dist/{output-C4QhjpM6.js → output-DmHvT8vm.js} +141 -12
- package/dist/output-DmHvT8vm.js.map +1 -0
- package/dist/{perf-metrics-D0um6IR6.js → perf-metrics-C2pXfxvR.js} +12 -2
- package/dist/perf-metrics-C2pXfxvR.js.map +1 -0
- package/dist/{prompt-turn-CXMtXBl-.js → prompt-turn-BY5SwU1F.js} +256 -80
- package/dist/prompt-turn-BY5SwU1F.js.map +1 -0
- package/dist/{render-Br-kVPK_.js → render-yqwtaOX4.js} +35 -3
- package/dist/{render-Br-kVPK_.js.map → render-yqwtaOX4.js.map} +1 -1
- package/dist/runtime.d.ts +84 -10
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +425 -190
- package/dist/runtime.js.map +1 -1
- package/dist/{session-BtwAKtJ3.js → session-BwgaPK8-.js} +119 -81
- package/dist/session-BwgaPK8-.js.map +1 -0
- package/dist/session-options-pCbHn_n7.d.ts +13 -0
- package/dist/session-options-pCbHn_n7.d.ts.map +1 -0
- package/dist/{types-yxf-gcOE.d.ts → types-CVBeQyi3.d.ts} +9 -1
- package/dist/types-CVBeQyi3.d.ts.map +1 -0
- package/package.json +21 -21
- package/skills/acpx/SKILL.md +9 -4
- package/dist/client-D-4_aZf2.d.ts.map +0 -1
- package/dist/flags-ceSqz2T6.js.map +0 -1
- package/dist/flows-_KmnuUXd.js.map +0 -1
- package/dist/ipc-BM335WFg.js.map +0 -1
- package/dist/output-C4QhjpM6.js.map +0 -1
- package/dist/perf-metrics-D0um6IR6.js.map +0 -1
- package/dist/prompt-turn-CXMtXBl-.js.map +0 -1
- package/dist/session-BtwAKtJ3.js.map +0 -1
- package/dist/types-yxf-gcOE.d.ts.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-CiIaOW0V.js";
|
|
2
|
-
import {
|
|
3
|
-
import { A as
|
|
2
|
+
import { H as QueueConnectionError, b as isRetryablePromptError, c as startPerfTimer, g as textPrompt, h as promptToDisplayText, i as measurePerf, n as getPerfMetricsSnapshot, o as resetPerfMetrics, r as incrementPerfCounter, s as setPerfGauge, t as formatPerfMetric, u as normalizeRuntimeSessionId, v as formatErrorMessage, x as normalizeOutputError } from "./perf-metrics-C2pXfxvR.js";
|
|
3
|
+
import { A as listSessions, B as sessionEventActivePath, D as findSession, E as findGitRepositoryRoot, F as writeSessionRecord, G as InterruptedError, H as sessionEventSegmentPath, J as withTimeout, K as TimeoutError, M as normalizeName, N as pruneSessions, O as findSessionByDirectoryWalk, P as resolveSessionRecord, R as defaultSessionEventLog, S as AcpClient, T as absolutePath, V as sessionEventLockPath, _ as createSessionConversation, a as connectAndLoadSession, b as recordSessionUpdate, d as setDesiredConfigOption, f as setDesiredModeId, g as cloneSessionConversation, h as cloneSessionAcpxState, i as sessionOptionsFromRecord, j as listSessionsForAgent, k as isoNow, l as assertRequestedModelSupported, m as syncAdvertisedModelState, n as withConnectedSession, o as applyConversation, p as setDesiredModelId, q as withInterrupt, r as mergeSessionOptions, s as applyLifecycleSnapshotToRecord, t as runPromptTurn, u as setCurrentModelId, v as recordClientOperation, x as trimConversationForRuntime, y as recordPromptSubmission, z as sessionBaseDir } from "./prompt-turn-BY5SwU1F.js";
|
|
4
4
|
import { n as isAcpJsonRpcMessage } from "./jsonrpc-DSxh2w5R.js";
|
|
5
|
-
import { a as trySubmitToRunningOwner, c as isProcessAlive, d as terminateProcess, f as terminateQueueOwnerForSession, i as trySetModelOnRunningOwner, l as refreshQueueOwnerLease, m as waitMs, n as trySetConfigOptionOnRunningOwner, o as SessionQueueOwner, p as tryAcquireQueueOwnerLease, r as trySetModeOnRunningOwner, t as tryCancelOnRunningOwner, u as releaseQueueOwnerLease } from "./ipc-
|
|
5
|
+
import { a as trySubmitToRunningOwner, c as isProcessAlive, d as terminateProcess, f as terminateQueueOwnerForSession, i as trySetModelOnRunningOwner, l as refreshQueueOwnerLease, m as waitMs, n as trySetConfigOptionOnRunningOwner, o as SessionQueueOwner, p as tryAcquireQueueOwnerLease, r as trySetModeOnRunningOwner, t as tryCancelOnRunningOwner, u as releaseQueueOwnerLease } from "./ipc-BruTG5Fb.js";
|
|
6
6
|
import fs, { realpathSync } from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import fs$1 from "node:fs/promises";
|
|
@@ -15,9 +15,25 @@ function normalizeQueueOwnerTtlMs(ttlMs) {
|
|
|
15
15
|
return Math.round(ttlMs);
|
|
16
16
|
}
|
|
17
17
|
//#endregion
|
|
18
|
+
//#region src/cli/session/model-helpers.ts
|
|
19
|
+
async function applyRequestedModelIfAdvertised(params) {
|
|
20
|
+
const requestedModel = typeof params.requestedModel === "string" ? params.requestedModel.trim() : "";
|
|
21
|
+
if (!requestedModel) return false;
|
|
22
|
+
assertRequestedModelSupported({
|
|
23
|
+
requestedModel,
|
|
24
|
+
models: params.models,
|
|
25
|
+
agentCommand: params.agentCommand,
|
|
26
|
+
context: "apply"
|
|
27
|
+
});
|
|
28
|
+
if (!params.models) return false;
|
|
29
|
+
if (params.models.currentModelId === requestedModel) return true;
|
|
30
|
+
await withTimeout(params.client.setSessionModel(params.sessionId, requestedModel), params.timeoutMs);
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
18
34
|
//#region src/cli/session/prompt-runner.ts
|
|
19
|
-
|
|
20
|
-
|
|
35
|
+
function buildDirectConnectedSessionOptions(options, run) {
|
|
36
|
+
return {
|
|
21
37
|
sessionRecordId: options.sessionRecordId,
|
|
22
38
|
loadRecord: resolveSessionRecord,
|
|
23
39
|
saveRecord: writeSessionRecord,
|
|
@@ -25,71 +41,43 @@ async function runSessionSetModeDirect(options) {
|
|
|
25
41
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
26
42
|
authCredentials: options.authCredentials,
|
|
27
43
|
authPolicy: options.authPolicy,
|
|
44
|
+
terminal: options.terminal,
|
|
28
45
|
timeoutMs: options.timeoutMs,
|
|
29
46
|
verbose: options.verbose,
|
|
30
47
|
onClientAvailable: (controller) => {
|
|
31
48
|
options.onClientAvailable?.(controller);
|
|
32
49
|
},
|
|
33
50
|
onClientClosed: options.onClientClosed,
|
|
34
|
-
run
|
|
35
|
-
await withTimeout(client.setSessionMode(sessionId, options.modeId), options.timeoutMs);
|
|
36
|
-
setDesiredModeId(record, options.modeId);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
return {
|
|
40
|
-
record: result.record,
|
|
41
|
-
resumed: result.resumed,
|
|
42
|
-
loadError: result.loadError
|
|
51
|
+
run
|
|
43
52
|
};
|
|
44
53
|
}
|
|
45
|
-
|
|
46
|
-
const result = await withConnectedSession({
|
|
47
|
-
sessionRecordId: options.sessionRecordId,
|
|
48
|
-
loadRecord: resolveSessionRecord,
|
|
49
|
-
saveRecord: writeSessionRecord,
|
|
50
|
-
mcpServers: options.mcpServers,
|
|
51
|
-
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
52
|
-
authCredentials: options.authCredentials,
|
|
53
|
-
authPolicy: options.authPolicy,
|
|
54
|
-
timeoutMs: options.timeoutMs,
|
|
55
|
-
verbose: options.verbose,
|
|
56
|
-
onClientAvailable: (controller) => {
|
|
57
|
-
options.onClientAvailable?.(controller);
|
|
58
|
-
},
|
|
59
|
-
onClientClosed: options.onClientClosed,
|
|
60
|
-
run: async ({ client, sessionId, record }) => {
|
|
61
|
-
await withTimeout(client.setSessionModel(sessionId, options.modelId), options.timeoutMs);
|
|
62
|
-
setDesiredModelId(record, options.modelId);
|
|
63
|
-
setCurrentModelId(record, options.modelId);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
54
|
+
function toSessionMutationResult(result) {
|
|
66
55
|
return {
|
|
67
56
|
record: result.record,
|
|
68
57
|
resumed: result.resumed,
|
|
69
58
|
loadError: result.loadError
|
|
70
59
|
};
|
|
71
60
|
}
|
|
61
|
+
async function runSessionSetModeDirect(options) {
|
|
62
|
+
return toSessionMutationResult(await withConnectedSession(buildDirectConnectedSessionOptions(options, async ({ client, sessionId, record }) => {
|
|
63
|
+
await withTimeout(client.setSessionMode(sessionId, options.modeId), options.timeoutMs);
|
|
64
|
+
setDesiredModeId(record, options.modeId);
|
|
65
|
+
})));
|
|
66
|
+
}
|
|
67
|
+
async function runSessionSetModelDirect(options) {
|
|
68
|
+
return toSessionMutationResult(await withConnectedSession(buildDirectConnectedSessionOptions(options, async ({ client, sessionId, record }) => {
|
|
69
|
+
await withTimeout(client.setSessionModel(sessionId, options.modelId), options.timeoutMs);
|
|
70
|
+
setDesiredModelId(record, options.modelId);
|
|
71
|
+
setCurrentModelId(record, options.modelId);
|
|
72
|
+
})));
|
|
73
|
+
}
|
|
72
74
|
async function runSessionSetConfigOptionDirect(options) {
|
|
73
|
-
const result = await withConnectedSession({
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
authCredentials: options.authCredentials,
|
|
80
|
-
authPolicy: options.authPolicy,
|
|
81
|
-
timeoutMs: options.timeoutMs,
|
|
82
|
-
verbose: options.verbose,
|
|
83
|
-
onClientAvailable: (controller) => {
|
|
84
|
-
options.onClientAvailable?.(controller);
|
|
85
|
-
},
|
|
86
|
-
onClientClosed: options.onClientClosed,
|
|
87
|
-
run: async ({ client, sessionId, record }) => {
|
|
88
|
-
const response = await withTimeout(client.setSessionConfigOption(sessionId, options.configId, options.value), options.timeoutMs);
|
|
89
|
-
if (options.configId === "mode") setDesiredModeId(record, options.value);
|
|
90
|
-
return response;
|
|
91
|
-
}
|
|
92
|
-
});
|
|
75
|
+
const result = await withConnectedSession(buildDirectConnectedSessionOptions(options, async ({ client, sessionId, record }) => {
|
|
76
|
+
const response = await withTimeout(client.setSessionConfigOption(sessionId, options.configId, options.value), options.timeoutMs);
|
|
77
|
+
if (options.configId === "mode") setDesiredModeId(record, options.value);
|
|
78
|
+
else setDesiredConfigOption(record, options.configId, options.value);
|
|
79
|
+
return response;
|
|
80
|
+
}));
|
|
93
81
|
return {
|
|
94
82
|
record: result.record,
|
|
95
83
|
response: result.value,
|
|
@@ -123,6 +111,7 @@ async function setSessionMode(options) {
|
|
|
123
111
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
124
112
|
authCredentials: options.authCredentials,
|
|
125
113
|
authPolicy: options.authPolicy,
|
|
114
|
+
terminal: options.terminal,
|
|
126
115
|
timeoutMs: options.timeoutMs,
|
|
127
116
|
verbose: options.verbose
|
|
128
117
|
});
|
|
@@ -145,6 +134,7 @@ async function setSessionModel(options) {
|
|
|
145
134
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
146
135
|
authCredentials: options.authCredentials,
|
|
147
136
|
authPolicy: options.authPolicy,
|
|
137
|
+
terminal: options.terminal,
|
|
148
138
|
timeoutMs: options.timeoutMs,
|
|
149
139
|
verbose: options.verbose
|
|
150
140
|
});
|
|
@@ -153,10 +143,9 @@ async function setSessionConfigOption(options) {
|
|
|
153
143
|
const ownerResponse = await trySetConfigOptionOnRunningOwner(options.sessionId, options.configId, options.value, options.timeoutMs, options.verbose);
|
|
154
144
|
if (ownerResponse) {
|
|
155
145
|
const record = await resolveSessionRecord(options.sessionId);
|
|
156
|
-
if (options.configId === "mode")
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
146
|
+
if (options.configId === "mode") setDesiredModeId(record, options.value);
|
|
147
|
+
else setDesiredConfigOption(record, options.configId, options.value);
|
|
148
|
+
await writeSessionRecord(record);
|
|
160
149
|
return {
|
|
161
150
|
record,
|
|
162
151
|
response: ownerResponse,
|
|
@@ -171,6 +160,7 @@ async function setSessionConfigOption(options) {
|
|
|
171
160
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
172
161
|
authCredentials: options.authCredentials,
|
|
173
162
|
authPolicy: options.authPolicy,
|
|
163
|
+
terminal: options.terminal,
|
|
174
164
|
timeoutMs: options.timeoutMs,
|
|
175
165
|
verbose: options.verbose
|
|
176
166
|
});
|
|
@@ -208,12 +198,15 @@ async function closeSession(sessionId) {
|
|
|
208
198
|
//#endregion
|
|
209
199
|
//#region src/cli/session/session-management.ts
|
|
210
200
|
function persistSessionOptions(record, options) {
|
|
201
|
+
const systemPromptOption = options?.systemPrompt;
|
|
202
|
+
const normalizedSystemPrompt = typeof systemPromptOption === "string" && systemPromptOption.length > 0 ? systemPromptOption : systemPromptOption && typeof systemPromptOption === "object" && typeof systemPromptOption.append === "string" && systemPromptOption.append.length > 0 ? { append: systemPromptOption.append } : void 0;
|
|
211
203
|
const next = options && {
|
|
212
204
|
model: typeof options.model === "string" ? options.model : void 0,
|
|
213
205
|
allowed_tools: Array.isArray(options.allowedTools) ? [...options.allowedTools] : void 0,
|
|
214
|
-
max_turns: typeof options.maxTurns === "number" ? options.maxTurns : void 0
|
|
206
|
+
max_turns: typeof options.maxTurns === "number" ? options.maxTurns : void 0,
|
|
207
|
+
system_prompt: normalizedSystemPrompt
|
|
215
208
|
};
|
|
216
|
-
if (Boolean(next && (typeof next.model === "string" && next.model.trim().length > 0 || Array.isArray(next.allowed_tools) && next.allowed_tools.length > 0 || typeof next.max_turns === "number")) && next) {
|
|
209
|
+
if (Boolean(next && (typeof next.model === "string" && next.model.trim().length > 0 || Array.isArray(next.allowed_tools) && next.allowed_tools.length > 0 || typeof next.max_turns === "number" || next.system_prompt !== void 0)) && next) {
|
|
217
210
|
record.acpx = {
|
|
218
211
|
...record.acpx,
|
|
219
212
|
session_options: next
|
|
@@ -223,13 +216,6 @@ function persistSessionOptions(record, options) {
|
|
|
223
216
|
if (!record.acpx) return;
|
|
224
217
|
delete record.acpx.session_options;
|
|
225
218
|
}
|
|
226
|
-
async function applyRequestedModelIfAdvertised$1(params) {
|
|
227
|
-
const requestedModel = typeof params.requestedModel === "string" ? params.requestedModel.trim() : "";
|
|
228
|
-
if (!requestedModel || !params.models) return false;
|
|
229
|
-
if (params.models.currentModelId === requestedModel) return true;
|
|
230
|
-
await withTimeout(params.client.setSessionModel(params.sessionId, requestedModel), params.timeoutMs);
|
|
231
|
-
return true;
|
|
232
|
-
}
|
|
233
219
|
async function createSessionRecordWithClient(client, options) {
|
|
234
220
|
const cwd = absolutePath(options.cwd);
|
|
235
221
|
await withTimeout(client.start(), options.timeoutMs);
|
|
@@ -244,11 +230,12 @@ async function createSessionRecordWithClient(client, options) {
|
|
|
244
230
|
sessionId = options.resumeSessionId;
|
|
245
231
|
agentSessionId = normalizeRuntimeSessionId(loadedSession.agentSessionId);
|
|
246
232
|
sessionModels = loadedSession.models;
|
|
247
|
-
requestedModelApplied = await applyRequestedModelIfAdvertised
|
|
233
|
+
requestedModelApplied = await applyRequestedModelIfAdvertised({
|
|
248
234
|
client,
|
|
249
235
|
sessionId,
|
|
250
236
|
requestedModel: options.sessionOptions?.model,
|
|
251
237
|
models: sessionModels,
|
|
238
|
+
agentCommand: options.agentCommand,
|
|
252
239
|
timeoutMs: options.timeoutMs
|
|
253
240
|
});
|
|
254
241
|
} catch (error) {
|
|
@@ -259,11 +246,12 @@ async function createSessionRecordWithClient(client, options) {
|
|
|
259
246
|
sessionId = createdSession.sessionId;
|
|
260
247
|
agentSessionId = normalizeRuntimeSessionId(createdSession.agentSessionId);
|
|
261
248
|
sessionModels = createdSession.models;
|
|
262
|
-
requestedModelApplied = await applyRequestedModelIfAdvertised
|
|
249
|
+
requestedModelApplied = await applyRequestedModelIfAdvertised({
|
|
263
250
|
client,
|
|
264
251
|
sessionId,
|
|
265
252
|
requestedModel: options.sessionOptions?.model,
|
|
266
253
|
models: sessionModels,
|
|
254
|
+
agentCommand: options.agentCommand,
|
|
267
255
|
timeoutMs: options.timeoutMs
|
|
268
256
|
});
|
|
269
257
|
}
|
|
@@ -306,6 +294,7 @@ async function createSessionWithClient(options) {
|
|
|
306
294
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
307
295
|
authCredentials: options.authCredentials,
|
|
308
296
|
authPolicy: options.authPolicy,
|
|
297
|
+
terminal: options.terminal,
|
|
309
298
|
verbose: options.verbose,
|
|
310
299
|
sessionOptions: options.sessionOptions
|
|
311
300
|
});
|
|
@@ -349,6 +338,7 @@ async function ensureSession(options) {
|
|
|
349
338
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
350
339
|
authCredentials: options.authCredentials,
|
|
351
340
|
authPolicy: options.authPolicy,
|
|
341
|
+
terminal: options.terminal,
|
|
352
342
|
timeoutMs: options.timeoutMs,
|
|
353
343
|
verbose: options.verbose
|
|
354
344
|
})).record,
|
|
@@ -370,6 +360,7 @@ async function ensureSession(options) {
|
|
|
370
360
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
371
361
|
authCredentials: options.authCredentials,
|
|
372
362
|
authPolicy: options.authPolicy,
|
|
363
|
+
terminal: options.terminal,
|
|
373
364
|
timeoutMs: options.timeoutMs,
|
|
374
365
|
verbose: options.verbose,
|
|
375
366
|
sessionOptions: options.sessionOptions
|
|
@@ -586,11 +577,13 @@ function queueOwnerRuntimeOptionsFromSend(options) {
|
|
|
586
577
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
587
578
|
authCredentials: options.authCredentials,
|
|
588
579
|
authPolicy: options.authPolicy,
|
|
580
|
+
terminal: options.terminal,
|
|
589
581
|
suppressSdkConsoleErrors: options.suppressSdkConsoleErrors,
|
|
590
582
|
verbose: options.verbose,
|
|
591
583
|
ttlMs: options.ttlMs,
|
|
592
584
|
maxQueueDepth: options.maxQueueDepth,
|
|
593
|
-
promptRetries: options.promptRetries
|
|
585
|
+
promptRetries: options.promptRetries,
|
|
586
|
+
sessionOptions: options.sessionOptions
|
|
594
587
|
};
|
|
595
588
|
}
|
|
596
589
|
function buildQueueOwnerSpawnOptions(payload) {
|
|
@@ -839,12 +832,30 @@ function toPromptResult(stopReason, sessionId, client) {
|
|
|
839
832
|
permissionStats: client.getPermissionStats()
|
|
840
833
|
};
|
|
841
834
|
}
|
|
842
|
-
async function
|
|
835
|
+
async function applyPromptModelIfAdvertised(params) {
|
|
843
836
|
const requestedModel = typeof params.requestedModel === "string" ? params.requestedModel.trim() : "";
|
|
844
|
-
if (!requestedModel
|
|
845
|
-
|
|
837
|
+
if (!requestedModel) return;
|
|
838
|
+
const availableModels = params.record.acpx?.available_models;
|
|
839
|
+
assertRequestedModelSupported({
|
|
840
|
+
requestedModel,
|
|
841
|
+
models: Array.isArray(availableModels) ? {
|
|
842
|
+
currentModelId: params.record.acpx?.current_model_id ?? "",
|
|
843
|
+
availableModels: availableModels.map((modelId) => ({
|
|
844
|
+
modelId,
|
|
845
|
+
name: modelId
|
|
846
|
+
}))
|
|
847
|
+
} : void 0,
|
|
848
|
+
agentCommand: params.record.agentCommand,
|
|
849
|
+
context: "apply"
|
|
850
|
+
});
|
|
851
|
+
if (!Array.isArray(availableModels)) return;
|
|
852
|
+
if (params.record.acpx?.current_model_id === requestedModel) {
|
|
853
|
+
setDesiredModelId(params.record, requestedModel);
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
846
856
|
await withTimeout(params.client.setSessionModel(params.sessionId, requestedModel), params.timeoutMs);
|
|
847
|
-
|
|
857
|
+
setDesiredModelId(params.record, requestedModel);
|
|
858
|
+
setCurrentModelId(params.record, requestedModel);
|
|
848
859
|
}
|
|
849
860
|
function jsonRpcIdKey(value) {
|
|
850
861
|
if (typeof value === "string") return `s:${value}`;
|
|
@@ -914,6 +925,7 @@ async function runQueuedTask(sessionRecordId, task, options) {
|
|
|
914
925
|
suppressSdkConsoleErrors: task.suppressSdkConsoleErrors ?? options.suppressSdkConsoleErrors,
|
|
915
926
|
verbose: options.verbose,
|
|
916
927
|
promptRetries: options.promptRetries,
|
|
928
|
+
sessionOptions: mergeSessionOptions(task.sessionOptions, options.sessionOptions),
|
|
917
929
|
onClientAvailable: options.onClientAvailable,
|
|
918
930
|
onClientClosed: options.onClientClosed,
|
|
919
931
|
onPromptActive: options.onPromptActive,
|
|
@@ -954,13 +966,20 @@ async function runSessionPrompt(options) {
|
|
|
954
966
|
});
|
|
955
967
|
const conversation = cloneSessionConversation(record);
|
|
956
968
|
let acpxState = cloneSessionAcpxState(record.acpx);
|
|
957
|
-
const
|
|
969
|
+
const promptStartedAt = isoNow();
|
|
970
|
+
const promptMessageId = recordPromptSubmission(conversation, options.prompt, promptStartedAt);
|
|
971
|
+
record.lastPromptAt = promptStartedAt;
|
|
972
|
+
record.lastUsedAt = promptStartedAt;
|
|
973
|
+
applyConversation(record, conversation);
|
|
974
|
+
record.acpx = acpxState;
|
|
975
|
+
await writeSessionRecord(record);
|
|
958
976
|
output.setContext({ sessionId: record.acpxRecordId });
|
|
959
977
|
const eventWriter = await measurePerf("session.events.open", async () => {
|
|
960
978
|
return await SessionEventWriter.open(record);
|
|
961
979
|
});
|
|
962
980
|
const pendingMessages = [];
|
|
963
981
|
const pendingConnectOutputMessages = [];
|
|
982
|
+
const sessionOptions = mergeSessionOptions(options.sessionOptions, sessionOptionsFromRecord(record));
|
|
964
983
|
let bufferingConnectOutput = true;
|
|
965
984
|
let promptTurnActive = false;
|
|
966
985
|
let promptTurnHadSideEffects = false;
|
|
@@ -973,7 +992,7 @@ async function runSessionPrompt(options) {
|
|
|
973
992
|
};
|
|
974
993
|
const flushPendingMessages = async (checkpoint = false) => {
|
|
975
994
|
if (pendingMessages.length === 0) return;
|
|
976
|
-
const batch = pendingMessages.splice(0
|
|
995
|
+
const batch = pendingMessages.splice(0);
|
|
977
996
|
await measurePerf("session.events.flush_pending", async () => {
|
|
978
997
|
await eventWriter.appendMessages(batch, { checkpoint });
|
|
979
998
|
});
|
|
@@ -987,13 +1006,15 @@ async function runSessionPrompt(options) {
|
|
|
987
1006
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
988
1007
|
authCredentials: options.authCredentials,
|
|
989
1008
|
authPolicy: options.authPolicy,
|
|
1009
|
+
terminal: options.terminal,
|
|
990
1010
|
suppressSdkConsoleErrors: options.suppressSdkConsoleErrors,
|
|
991
1011
|
verbose: options.verbose,
|
|
992
|
-
sessionOptions
|
|
1012
|
+
sessionOptions
|
|
993
1013
|
});
|
|
994
1014
|
client.updateRuntimeOptions({
|
|
995
1015
|
permissionMode: options.permissionMode,
|
|
996
1016
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
1017
|
+
terminal: options.terminal,
|
|
997
1018
|
suppressSdkConsoleErrors: options.suppressSdkConsoleErrors,
|
|
998
1019
|
verbose: options.verbose
|
|
999
1020
|
});
|
|
@@ -1073,6 +1094,13 @@ async function runSessionPrompt(options) {
|
|
|
1073
1094
|
for (const message of connectOutputMessages) output.onAcpMessage(message);
|
|
1074
1095
|
pendingConnectOutputMessages.length = 0;
|
|
1075
1096
|
if (options.verbose) process.stderr.write(`[acpx] ${formatPerfMetric("prompt.connect_and_load", Date.now() - connectStartedAt)}\n`);
|
|
1097
|
+
await applyPromptModelIfAdvertised({
|
|
1098
|
+
client,
|
|
1099
|
+
sessionId: activeSessionId,
|
|
1100
|
+
requestedModel: sessionOptions?.model,
|
|
1101
|
+
record,
|
|
1102
|
+
timeoutMs: options.timeoutMs
|
|
1103
|
+
});
|
|
1076
1104
|
output.setContext({ sessionId: record.acpxRecordId });
|
|
1077
1105
|
await flushPendingMessages(false);
|
|
1078
1106
|
const maxRetries = options.promptRetries ?? 0;
|
|
@@ -1181,6 +1209,7 @@ async function runOnce(options) {
|
|
|
1181
1209
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
1182
1210
|
authCredentials: options.authCredentials,
|
|
1183
1211
|
authPolicy: options.authPolicy,
|
|
1212
|
+
terminal: options.terminal,
|
|
1184
1213
|
suppressSdkConsoleErrors: options.suppressSdkConsoleErrors,
|
|
1185
1214
|
verbose: options.verbose,
|
|
1186
1215
|
onAcpMessage: options.onAcpMessage,
|
|
@@ -1209,6 +1238,7 @@ async function runOnce(options) {
|
|
|
1209
1238
|
sessionId,
|
|
1210
1239
|
requestedModel: options.sessionOptions?.model,
|
|
1211
1240
|
models: createdSession.models,
|
|
1241
|
+
agentCommand: options.agentCommand,
|
|
1212
1242
|
timeoutMs: options.timeoutMs
|
|
1213
1243
|
});
|
|
1214
1244
|
output.setContext({ sessionId });
|
|
@@ -1257,6 +1287,7 @@ async function sendSessionDirect(options) {
|
|
|
1257
1287
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
1258
1288
|
authCredentials: options.authCredentials,
|
|
1259
1289
|
authPolicy: options.authPolicy,
|
|
1290
|
+
terminal: options.terminal,
|
|
1260
1291
|
outputFormatter: options.outputFormatter,
|
|
1261
1292
|
onAcpMessage: options.onAcpMessage,
|
|
1262
1293
|
onSessionUpdate: options.onSessionUpdate,
|
|
@@ -1283,7 +1314,8 @@ async function submitToRunningOwner(options, waitForCompletion) {
|
|
|
1283
1314
|
timeoutMs: options.timeoutMs,
|
|
1284
1315
|
suppressSdkConsoleErrors: options.suppressSdkConsoleErrors,
|
|
1285
1316
|
waitForCompletion,
|
|
1286
|
-
verbose: options.verbose
|
|
1317
|
+
verbose: options.verbose,
|
|
1318
|
+
sessionOptions: options.sessionOptions
|
|
1287
1319
|
});
|
|
1288
1320
|
}
|
|
1289
1321
|
async function runSessionQueueOwner(options) {
|
|
@@ -1300,9 +1332,10 @@ async function runSessionQueueOwner(options) {
|
|
|
1300
1332
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
1301
1333
|
authCredentials: options.authCredentials,
|
|
1302
1334
|
authPolicy: options.authPolicy,
|
|
1335
|
+
terminal: options.terminal,
|
|
1303
1336
|
suppressSdkConsoleErrors: options.suppressSdkConsoleErrors,
|
|
1304
1337
|
verbose: options.verbose,
|
|
1305
|
-
sessionOptions: sessionOptionsFromRecord(sessionRecord)
|
|
1338
|
+
sessionOptions: mergeSessionOptions(options.sessionOptions, sessionOptionsFromRecord(sessionRecord))
|
|
1306
1339
|
});
|
|
1307
1340
|
const ttlMs = normalizeQueueOwnerTtlMs(options.ttlMs);
|
|
1308
1341
|
const maxQueueDepth = Math.max(1, Math.round(options.maxQueueDepth ?? 16));
|
|
@@ -1318,6 +1351,7 @@ async function runSessionQueueOwner(options) {
|
|
|
1318
1351
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
1319
1352
|
authCredentials: options.authCredentials,
|
|
1320
1353
|
authPolicy: options.authPolicy,
|
|
1354
|
+
terminal: options.terminal,
|
|
1321
1355
|
timeoutMs,
|
|
1322
1356
|
verbose: options.verbose
|
|
1323
1357
|
});
|
|
@@ -1330,6 +1364,7 @@ async function runSessionQueueOwner(options) {
|
|
|
1330
1364
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
1331
1365
|
authCredentials: options.authCredentials,
|
|
1332
1366
|
authPolicy: options.authPolicy,
|
|
1367
|
+
terminal: options.terminal,
|
|
1333
1368
|
timeoutMs,
|
|
1334
1369
|
verbose: options.verbose
|
|
1335
1370
|
});
|
|
@@ -1343,6 +1378,7 @@ async function runSessionQueueOwner(options) {
|
|
|
1343
1378
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
1344
1379
|
authCredentials: options.authCredentials,
|
|
1345
1380
|
authPolicy: options.authPolicy,
|
|
1381
|
+
terminal: options.terminal,
|
|
1346
1382
|
timeoutMs,
|
|
1347
1383
|
verbose: options.verbose
|
|
1348
1384
|
})).response;
|
|
@@ -1416,6 +1452,7 @@ async function runSessionQueueOwner(options) {
|
|
|
1416
1452
|
authPolicy: options.authPolicy,
|
|
1417
1453
|
suppressSdkConsoleErrors: options.suppressSdkConsoleErrors,
|
|
1418
1454
|
promptRetries: options.promptRetries,
|
|
1455
|
+
sessionOptions: options.sessionOptions,
|
|
1419
1456
|
onClientAvailable: setActiveController,
|
|
1420
1457
|
onClientClosed: clearActiveController,
|
|
1421
1458
|
onPromptActive: async () => {
|
|
@@ -1473,6 +1510,7 @@ var session_exports = /* @__PURE__ */ __exportAll({
|
|
|
1473
1510
|
listSessions: () => listSessions,
|
|
1474
1511
|
listSessionsForAgent: () => listSessionsForAgent,
|
|
1475
1512
|
normalizeQueueOwnerTtlMs: () => normalizeQueueOwnerTtlMs,
|
|
1513
|
+
pruneSessions: () => pruneSessions,
|
|
1476
1514
|
runOnce: () => runOnce,
|
|
1477
1515
|
runQueuedTask: () => runQueuedTask,
|
|
1478
1516
|
runSessionQueueOwner: () => runSessionQueueOwner,
|
|
@@ -1485,4 +1523,4 @@ var session_exports = /* @__PURE__ */ __exportAll({
|
|
|
1485
1523
|
//#endregion
|
|
1486
1524
|
export { buildQueueOwnerArgOverride as a, createSessionWithClient as c, sendSessionDirect as i, cancelSessionPrompt as l, runSessionQueueOwner as n, flushPerfMetricsCapture as o, runOnce as r, installPerfMetricsCapture as s, session_exports as t, DEFAULT_QUEUE_OWNER_TTL_MS as u };
|
|
1487
1525
|
|
|
1488
|
-
//# sourceMappingURL=session-
|
|
1526
|
+
//# sourceMappingURL=session-BwgaPK8-.js.map
|