acpx 0.1.8 → 0.1.9
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.d.ts +1 -1
- package/dist/cli.js +81 -61
- package/package.json +1 -1
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -1715,14 +1715,9 @@ function classifyPermissionDecision(params, response) {
|
|
|
1715
1715
|
return "denied";
|
|
1716
1716
|
}
|
|
1717
1717
|
|
|
1718
|
-
// src/
|
|
1719
|
-
var
|
|
1720
|
-
|
|
1721
|
-
"providerSessionId",
|
|
1722
|
-
"codexSessionId",
|
|
1723
|
-
"claudeSessionId"
|
|
1724
|
-
];
|
|
1725
|
-
function normalizeRuntimeSessionId(value) {
|
|
1718
|
+
// src/agent-session-id.ts
|
|
1719
|
+
var AGENT_SESSION_ID_META_KEYS = ["agentSessionId", "sessionId"];
|
|
1720
|
+
function normalizeAgentSessionId(value) {
|
|
1726
1721
|
if (typeof value !== "string") {
|
|
1727
1722
|
return void 0;
|
|
1728
1723
|
}
|
|
@@ -1735,13 +1730,13 @@ function asMetaRecord(meta) {
|
|
|
1735
1730
|
}
|
|
1736
1731
|
return meta;
|
|
1737
1732
|
}
|
|
1738
|
-
function
|
|
1733
|
+
function extractAgentSessionId(meta) {
|
|
1739
1734
|
const record = asMetaRecord(meta);
|
|
1740
1735
|
if (!record) {
|
|
1741
1736
|
return void 0;
|
|
1742
1737
|
}
|
|
1743
|
-
for (const key of
|
|
1744
|
-
const normalized =
|
|
1738
|
+
for (const key of AGENT_SESSION_ID_META_KEYS) {
|
|
1739
|
+
const normalized = normalizeAgentSessionId(record[key]);
|
|
1745
1740
|
if (normalized) {
|
|
1746
1741
|
return normalized;
|
|
1747
1742
|
}
|
|
@@ -2409,7 +2404,7 @@ var AcpClient = class {
|
|
|
2409
2404
|
});
|
|
2410
2405
|
return {
|
|
2411
2406
|
sessionId: result.sessionId,
|
|
2412
|
-
|
|
2407
|
+
agentSessionId: extractAgentSessionId(result._meta)
|
|
2413
2408
|
};
|
|
2414
2409
|
}
|
|
2415
2410
|
async loadSession(sessionId, cwd = this.options.cwd) {
|
|
@@ -2435,7 +2430,7 @@ var AcpClient = class {
|
|
|
2435
2430
|
this.suppressSessionUpdates = previousSuppression;
|
|
2436
2431
|
}
|
|
2437
2432
|
return {
|
|
2438
|
-
|
|
2433
|
+
agentSessionId: extractAgentSessionId(response?._meta)
|
|
2439
2434
|
};
|
|
2440
2435
|
}
|
|
2441
2436
|
async prompt(sessionId, text) {
|
|
@@ -4244,7 +4239,7 @@ function parseSessionRecord(raw) {
|
|
|
4244
4239
|
return null;
|
|
4245
4240
|
}
|
|
4246
4241
|
const record = raw;
|
|
4247
|
-
const
|
|
4242
|
+
const agentSessionId = normalizeAgentSessionId(record.agentSessionId);
|
|
4248
4243
|
const name = record.name == null ? void 0 : typeof record.name === "string" && record.name.trim().length > 0 ? record.name.trim() : null;
|
|
4249
4244
|
const pid = record.pid == null ? void 0 : Number.isInteger(record.pid) && record.pid > 0 ? record.pid : null;
|
|
4250
4245
|
const closed = record.closed == null ? false : typeof record.closed === "boolean" ? record.closed : null;
|
|
@@ -4267,7 +4262,7 @@ function parseSessionRecord(raw) {
|
|
|
4267
4262
|
...record,
|
|
4268
4263
|
id: record.id,
|
|
4269
4264
|
sessionId: record.sessionId,
|
|
4270
|
-
|
|
4265
|
+
agentSessionId,
|
|
4271
4266
|
agentCommand: record.agentCommand,
|
|
4272
4267
|
cwd: record.cwd,
|
|
4273
4268
|
name,
|
|
@@ -4660,12 +4655,12 @@ function applyLifecycleSnapshotToRecord(record, snapshot) {
|
|
|
4660
4655
|
record.lastAgentExitAt = void 0;
|
|
4661
4656
|
record.lastAgentDisconnectReason = void 0;
|
|
4662
4657
|
}
|
|
4663
|
-
function
|
|
4664
|
-
const normalized =
|
|
4658
|
+
function reconcileAgentSessionId(record, agentSessionId) {
|
|
4659
|
+
const normalized = normalizeAgentSessionId(agentSessionId);
|
|
4665
4660
|
if (!normalized) {
|
|
4666
4661
|
return;
|
|
4667
4662
|
}
|
|
4668
|
-
record.
|
|
4663
|
+
record.agentSessionId = normalized;
|
|
4669
4664
|
}
|
|
4670
4665
|
function shouldFallbackToNewSession(error) {
|
|
4671
4666
|
if (error instanceof TimeoutError || error instanceof InterruptedError) {
|
|
@@ -4709,7 +4704,7 @@ async function connectAndLoadSession(options) {
|
|
|
4709
4704
|
}),
|
|
4710
4705
|
options.timeoutMs
|
|
4711
4706
|
);
|
|
4712
|
-
|
|
4707
|
+
reconcileAgentSessionId(record, loadResult.agentSessionId);
|
|
4713
4708
|
resumed = true;
|
|
4714
4709
|
} catch (error) {
|
|
4715
4710
|
loadError = formatErrorMessage(error);
|
|
@@ -4722,7 +4717,7 @@ async function connectAndLoadSession(options) {
|
|
|
4722
4717
|
);
|
|
4723
4718
|
sessionId = createdSession.sessionId;
|
|
4724
4719
|
record.sessionId = sessionId;
|
|
4725
|
-
|
|
4720
|
+
reconcileAgentSessionId(record, createdSession.agentSessionId);
|
|
4726
4721
|
}
|
|
4727
4722
|
} else {
|
|
4728
4723
|
const createdSession = await withTimeout(
|
|
@@ -4731,12 +4726,12 @@ async function connectAndLoadSession(options) {
|
|
|
4731
4726
|
);
|
|
4732
4727
|
sessionId = createdSession.sessionId;
|
|
4733
4728
|
record.sessionId = sessionId;
|
|
4734
|
-
|
|
4729
|
+
reconcileAgentSessionId(record, createdSession.agentSessionId);
|
|
4735
4730
|
}
|
|
4736
4731
|
options.onSessionIdResolved?.(sessionId);
|
|
4737
4732
|
return {
|
|
4738
4733
|
sessionId,
|
|
4739
|
-
|
|
4734
|
+
agentSessionId: record.agentSessionId,
|
|
4740
4735
|
resumed,
|
|
4741
4736
|
loadError
|
|
4742
4737
|
};
|
|
@@ -5139,7 +5134,7 @@ async function createSession(options) {
|
|
|
5139
5134
|
const record = {
|
|
5140
5135
|
id: sessionId,
|
|
5141
5136
|
sessionId,
|
|
5142
|
-
|
|
5137
|
+
agentSessionId: createdSession.agentSessionId,
|
|
5143
5138
|
agentCommand: options.agentCommand,
|
|
5144
5139
|
cwd: absolutePath(options.cwd),
|
|
5145
5140
|
name: normalizeName(options.name),
|
|
@@ -5717,8 +5712,22 @@ function resolveAgentInvocation(explicitAgentName, globalFlags, config) {
|
|
|
5717
5712
|
}
|
|
5718
5713
|
function printSessionsByFormat(sessions, format) {
|
|
5719
5714
|
if (format === "json") {
|
|
5720
|
-
process.stdout.write(
|
|
5721
|
-
|
|
5715
|
+
process.stdout.write(
|
|
5716
|
+
`${JSON.stringify(
|
|
5717
|
+
sessions.map((session) => {
|
|
5718
|
+
const { id, sessionId, agentSessionId, ...rest } = session;
|
|
5719
|
+
return {
|
|
5720
|
+
...rest,
|
|
5721
|
+
...canonicalSessionIdentity({
|
|
5722
|
+
id,
|
|
5723
|
+
sessionId,
|
|
5724
|
+
agentSessionId
|
|
5725
|
+
})
|
|
5726
|
+
};
|
|
5727
|
+
})
|
|
5728
|
+
)}
|
|
5729
|
+
`
|
|
5730
|
+
);
|
|
5722
5731
|
return;
|
|
5723
5732
|
}
|
|
5724
5733
|
if (format === "quiet") {
|
|
@@ -5746,8 +5755,7 @@ function printClosedSessionByFormat(record, format) {
|
|
|
5746
5755
|
process.stdout.write(
|
|
5747
5756
|
`${JSON.stringify({
|
|
5748
5757
|
type: "session_closed",
|
|
5749
|
-
|
|
5750
|
-
sessionId: record.sessionId,
|
|
5758
|
+
...canonicalSessionIdentity(record),
|
|
5751
5759
|
name: record.name
|
|
5752
5760
|
})}
|
|
5753
5761
|
`
|
|
@@ -5760,23 +5768,22 @@ function printClosedSessionByFormat(record, format) {
|
|
|
5760
5768
|
process.stdout.write(`${record.id}
|
|
5761
5769
|
`);
|
|
5762
5770
|
}
|
|
5763
|
-
function
|
|
5764
|
-
const
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5771
|
+
function canonicalSessionIdentity(record) {
|
|
5772
|
+
const normalizedAgentSessionId = normalizeAgentSessionId(record.agentSessionId);
|
|
5773
|
+
return {
|
|
5774
|
+
acpxRecordId: record.id,
|
|
5775
|
+
acpxSessionId: record.sessionId,
|
|
5776
|
+
...normalizedAgentSessionId ? { agentSessionId: normalizedAgentSessionId } : {}
|
|
5777
|
+
};
|
|
5769
5778
|
}
|
|
5770
5779
|
function printNewSessionByFormat(record, replaced, format) {
|
|
5771
5780
|
if (format === "json") {
|
|
5772
5781
|
process.stdout.write(
|
|
5773
5782
|
`${JSON.stringify({
|
|
5774
5783
|
type: "session_created",
|
|
5775
|
-
|
|
5776
|
-
sessionId: record.sessionId,
|
|
5784
|
+
...canonicalSessionIdentity(record),
|
|
5777
5785
|
name: record.name,
|
|
5778
|
-
|
|
5779
|
-
...runtimeSessionIdPayload(record.runtimeSessionId)
|
|
5786
|
+
...replaced ? { replacedAcpxRecordId: replaced.id } : {}
|
|
5780
5787
|
})}
|
|
5781
5788
|
`
|
|
5782
5789
|
);
|
|
@@ -5800,11 +5807,9 @@ function printEnsuredSessionByFormat(record, created, format) {
|
|
|
5800
5807
|
process.stdout.write(
|
|
5801
5808
|
`${JSON.stringify({
|
|
5802
5809
|
type: "session_ensured",
|
|
5803
|
-
|
|
5804
|
-
sessionId: record.sessionId,
|
|
5810
|
+
...canonicalSessionIdentity(record),
|
|
5805
5811
|
name: record.name,
|
|
5806
|
-
created
|
|
5807
|
-
...runtimeSessionIdPayload(record.runtimeSessionId)
|
|
5812
|
+
created
|
|
5808
5813
|
})}
|
|
5809
5814
|
`
|
|
5810
5815
|
);
|
|
@@ -5824,7 +5829,7 @@ function printQueuedPromptByFormat(result, format) {
|
|
|
5824
5829
|
process.stdout.write(
|
|
5825
5830
|
`${JSON.stringify({
|
|
5826
5831
|
type: "queued",
|
|
5827
|
-
|
|
5832
|
+
acpxRecordId: result.sessionId,
|
|
5828
5833
|
requestId: result.requestId
|
|
5829
5834
|
})}
|
|
5830
5835
|
`
|
|
@@ -5981,8 +5986,13 @@ async function handleExec(explicitAgentName, promptParts, flags, command, config
|
|
|
5981
5986
|
}
|
|
5982
5987
|
function printCancelResultByFormat(result, format) {
|
|
5983
5988
|
if (format === "json") {
|
|
5984
|
-
process.stdout.write(
|
|
5985
|
-
|
|
5989
|
+
process.stdout.write(
|
|
5990
|
+
`${JSON.stringify({
|
|
5991
|
+
acpxRecordId: result.sessionId || null,
|
|
5992
|
+
cancelled: result.cancelled
|
|
5993
|
+
})}
|
|
5994
|
+
`
|
|
5995
|
+
);
|
|
5986
5996
|
return;
|
|
5987
5997
|
}
|
|
5988
5998
|
if (result.cancelled) {
|
|
@@ -5995,7 +6005,7 @@ function printSetModeResultByFormat(modeId, result, format) {
|
|
|
5995
6005
|
if (format === "json") {
|
|
5996
6006
|
process.stdout.write(
|
|
5997
6007
|
`${JSON.stringify({
|
|
5998
|
-
|
|
6008
|
+
...canonicalSessionIdentity(result.record),
|
|
5999
6009
|
modeId,
|
|
6000
6010
|
resumed: result.resumed
|
|
6001
6011
|
})}
|
|
@@ -6015,7 +6025,7 @@ function printSetConfigOptionResultByFormat(configId, value, result, format) {
|
|
|
6015
6025
|
if (format === "json") {
|
|
6016
6026
|
process.stdout.write(
|
|
6017
6027
|
`${JSON.stringify({
|
|
6018
|
-
|
|
6028
|
+
...canonicalSessionIdentity(result.record),
|
|
6019
6029
|
configId,
|
|
6020
6030
|
value,
|
|
6021
6031
|
resumed: result.resumed,
|
|
@@ -6207,8 +6217,18 @@ async function handleSessionsEnsure(explicitAgentName, flags, command, config) {
|
|
|
6207
6217
|
}
|
|
6208
6218
|
function printSessionDetailsByFormat(record, format) {
|
|
6209
6219
|
if (format === "json") {
|
|
6210
|
-
|
|
6211
|
-
|
|
6220
|
+
const { id, sessionId, agentSessionId, ...rest } = record;
|
|
6221
|
+
process.stdout.write(
|
|
6222
|
+
`${JSON.stringify({
|
|
6223
|
+
...rest,
|
|
6224
|
+
...canonicalSessionIdentity({
|
|
6225
|
+
id,
|
|
6226
|
+
sessionId,
|
|
6227
|
+
agentSessionId
|
|
6228
|
+
})
|
|
6229
|
+
})}
|
|
6230
|
+
`
|
|
6231
|
+
);
|
|
6212
6232
|
return;
|
|
6213
6233
|
}
|
|
6214
6234
|
if (format === "quiet") {
|
|
@@ -6216,11 +6236,11 @@ function printSessionDetailsByFormat(record, format) {
|
|
|
6216
6236
|
`);
|
|
6217
6237
|
return;
|
|
6218
6238
|
}
|
|
6219
|
-
process.stdout.write(`
|
|
6239
|
+
process.stdout.write(`acpxRecordId: ${record.id}
|
|
6220
6240
|
`);
|
|
6221
|
-
process.stdout.write(`
|
|
6241
|
+
process.stdout.write(`acpxSessionId: ${record.sessionId}
|
|
6222
6242
|
`);
|
|
6223
|
-
process.stdout.write(`
|
|
6243
|
+
process.stdout.write(`agentSessionId: ${record.agentSessionId ?? "-"}
|
|
6224
6244
|
`);
|
|
6225
6245
|
process.stdout.write(`agent: ${record.agentCommand}
|
|
6226
6246
|
`);
|
|
@@ -6261,8 +6281,7 @@ function printSessionHistoryByFormat(record, limit, format) {
|
|
|
6261
6281
|
if (format === "json") {
|
|
6262
6282
|
process.stdout.write(
|
|
6263
6283
|
`${JSON.stringify({
|
|
6264
|
-
|
|
6265
|
-
sessionId: record.sessionId,
|
|
6284
|
+
...canonicalSessionIdentity(record),
|
|
6266
6285
|
limit,
|
|
6267
6286
|
count: visible.length,
|
|
6268
6287
|
entries: visible
|
|
@@ -6348,7 +6367,9 @@ async function handleStatus(explicitAgentName, flags, command, config) {
|
|
|
6348
6367
|
});
|
|
6349
6368
|
if (!record) {
|
|
6350
6369
|
const payload2 = {
|
|
6351
|
-
|
|
6370
|
+
acpxRecordId: null,
|
|
6371
|
+
acpxSessionId: null,
|
|
6372
|
+
agentSessionId: null,
|
|
6352
6373
|
agentCommand: agent.agentCommand,
|
|
6353
6374
|
pid: null,
|
|
6354
6375
|
status: "no-session",
|
|
@@ -6382,15 +6403,14 @@ async function handleStatus(explicitAgentName, flags, command, config) {
|
|
|
6382
6403
|
}
|
|
6383
6404
|
const running = isProcessAlive(record.pid);
|
|
6384
6405
|
const payload = {
|
|
6385
|
-
|
|
6406
|
+
...canonicalSessionIdentity(record),
|
|
6386
6407
|
agentCommand: record.agentCommand,
|
|
6387
6408
|
pid: record.pid ?? null,
|
|
6388
6409
|
status: running ? "running" : "dead",
|
|
6389
6410
|
uptime: running ? formatUptime(record.agentStartedAt) ?? null : null,
|
|
6390
6411
|
lastPromptTime: record.lastPromptAt ?? null,
|
|
6391
6412
|
exitCode: running ? null : record.lastAgentExitCode ?? null,
|
|
6392
|
-
signal: running ? null : record.lastAgentExitSignal ?? null
|
|
6393
|
-
...runtimeSessionIdPayload(record.runtimeSessionId)
|
|
6413
|
+
signal: running ? null : record.lastAgentExitSignal ?? null
|
|
6394
6414
|
};
|
|
6395
6415
|
if (globalFlags.format === "json") {
|
|
6396
6416
|
process.stdout.write(`${JSON.stringify(payload)}
|
|
@@ -6402,12 +6422,12 @@ async function handleStatus(explicitAgentName, flags, command, config) {
|
|
|
6402
6422
|
`);
|
|
6403
6423
|
return;
|
|
6404
6424
|
}
|
|
6405
|
-
process.stdout.write(`
|
|
6425
|
+
process.stdout.write(`acpxRecordId: ${payload.acpxRecordId}
|
|
6406
6426
|
`);
|
|
6407
|
-
|
|
6408
|
-
|
|
6427
|
+
process.stdout.write(`acpxSessionId: ${payload.acpxSessionId}
|
|
6428
|
+
`);
|
|
6429
|
+
process.stdout.write(`agentSessionId: ${payload.agentSessionId ?? "-"}
|
|
6409
6430
|
`);
|
|
6410
|
-
}
|
|
6411
6431
|
process.stdout.write(`agent: ${payload.agentCommand}
|
|
6412
6432
|
`);
|
|
6413
6433
|
process.stdout.write(`pid: ${payload.pid ?? "-"}
|