@moxt-ai/mobius 0.0.187 → 0.0.189
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/acp/agent-runtime-manager.d.ts +2 -2
- package/dist/acp/agent-runtime-manager.d.ts.map +1 -1
- package/dist/acp/agent-runtime-manager.js +17 -8
- package/dist/acp/agent-runtime-manager.js.map +1 -1
- package/dist/acp/codex/agent.d.ts.map +1 -1
- package/dist/acp/codex/agent.js +32 -10
- package/dist/acp/codex/agent.js.map +1 -1
- package/dist/acp/codex/app-server-protocol.d.ts +7 -0
- package/dist/acp/codex/app-server-protocol.d.ts.map +1 -1
- package/dist/acp/codex/app-server-protocol.js +5 -0
- package/dist/acp/codex/app-server-protocol.js.map +1 -1
- package/dist/acp/session-contracts.d.ts +10 -3
- package/dist/acp/session-contracts.d.ts.map +1 -1
- package/dist/acp/session-contracts.js +3 -0
- package/dist/acp/session-contracts.js.map +1 -1
- package/dist/acp/session-event-store-v2.d.ts +1 -0
- package/dist/acp/session-event-store-v2.d.ts.map +1 -1
- package/dist/acp/session-event-store-v2.js +3 -0
- package/dist/acp/session-event-store-v2.js.map +1 -1
- package/dist/cli.js +362 -52
- package/dist/cli.js.map +4 -4
- package/dist/daemon-command-handler.d.ts.map +1 -1
- package/dist/daemon-command-handler.js +6 -2
- package/dist/daemon-command-handler.js.map +1 -1
- package/dist/daemon-history-commands.d.ts +2 -1
- package/dist/daemon-history-commands.d.ts.map +1 -1
- package/dist/daemon-history-commands.js +54 -1
- package/dist/daemon-history-commands.js.map +1 -1
- package/dist/index.js +363 -53
- package/dist/index.js.map +4 -4
- package/dist/native-sessions/codex-history.d.ts.map +1 -1
- package/dist/native-sessions/codex-history.js +9 -1
- package/dist/native-sessions/codex-history.js.map +1 -1
- package/dist/native-sessions/native-history-events-v2.d.ts +8 -0
- package/dist/native-sessions/native-history-events-v2.d.ts.map +1 -0
- package/dist/native-sessions/native-history-events-v2.js +147 -0
- package/dist/native-sessions/native-history-events-v2.js.map +1 -0
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +6 -3
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +361 -51
- package/dist/runtime.js.map +4 -4
- package/package.json +1 -1
package/dist/runtime.js
CHANGED
|
@@ -21409,24 +21409,28 @@ var decodeAcpSessionUpdateV2 = (value) => decode5(value, acpSessionUpdateV2Schem
|
|
|
21409
21409
|
// ../protocol/src/session-live-history.ts
|
|
21410
21410
|
var SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND = "session.live-history.v2.page.load";
|
|
21411
21411
|
var SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND = "session.live-history.v2.page.loaded";
|
|
21412
|
+
var SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND = "session.preview-history.page.load";
|
|
21413
|
+
var SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND = "session.preview-history.page.loaded";
|
|
21412
21414
|
var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
|
|
21413
|
-
var
|
|
21415
|
+
var pageLoadFields = {
|
|
21414
21416
|
additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
|
|
21415
21417
|
agentId: identifierStringSchema,
|
|
21416
21418
|
bindingId: identifierStringSchema,
|
|
21417
21419
|
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
21418
21420
|
directoryId: directoryIdentifier,
|
|
21419
|
-
kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND),
|
|
21420
21421
|
eventLimit: external_exports.number().int().min(1).max(1e4),
|
|
21421
21422
|
requestId: identifierStringSchema,
|
|
21422
21423
|
sessionId: identifierStringSchema
|
|
21423
|
-
}
|
|
21424
|
-
var
|
|
21424
|
+
};
|
|
21425
|
+
var sessionLiveHistoryV2PageLoadSchema = external_exports.object({ ...pageLoadFields, kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND) }).readonly();
|
|
21426
|
+
var sessionPreviewHistoryPageLoadSchema = external_exports.object({ ...pageLoadFields, kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND) }).readonly();
|
|
21427
|
+
var pageLoadedFields = {
|
|
21425
21428
|
events: nativeSessionEventsV2Schema,
|
|
21426
|
-
kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND),
|
|
21427
21429
|
requestId: identifierStringSchema,
|
|
21428
21430
|
sessionId: identifierStringSchema
|
|
21429
|
-
}
|
|
21431
|
+
};
|
|
21432
|
+
var sessionLiveHistoryV2PageLoadedSchema = external_exports.object({ ...pageLoadedFields, kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND) }).readonly();
|
|
21433
|
+
var sessionPreviewHistoryPageLoadedSchema = external_exports.object({ ...pageLoadedFields, kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND) }).readonly();
|
|
21430
21434
|
function decode6(schema, encoded) {
|
|
21431
21435
|
try {
|
|
21432
21436
|
const value = JSON.parse(encoded);
|
|
@@ -21437,8 +21441,12 @@ function decode6(schema, encoded) {
|
|
|
21437
21441
|
}
|
|
21438
21442
|
var decodeSessionLiveHistoryV2PageLoad = (encoded) => decode6(sessionLiveHistoryV2PageLoadSchema, encoded);
|
|
21439
21443
|
var decodeSessionLiveHistoryV2PageLoaded = (encoded) => decode6(sessionLiveHistoryV2PageLoadedSchema, encoded);
|
|
21444
|
+
var decodeSessionPreviewHistoryPageLoad = (encoded) => decode6(sessionPreviewHistoryPageLoadSchema, encoded);
|
|
21445
|
+
var decodeSessionPreviewHistoryPageLoaded = (encoded) => decode6(sessionPreviewHistoryPageLoadedSchema, encoded);
|
|
21440
21446
|
var encodeSessionLiveHistoryV2PageLoad = (value) => JSON.stringify(sessionLiveHistoryV2PageLoadSchema.parse(value));
|
|
21441
21447
|
var encodeSessionLiveHistoryV2PageLoaded = (value) => JSON.stringify(sessionLiveHistoryV2PageLoadedSchema.parse(value));
|
|
21448
|
+
var encodeSessionPreviewHistoryPageLoad = (value) => JSON.stringify(sessionPreviewHistoryPageLoadSchema.parse(value));
|
|
21449
|
+
var encodeSessionPreviewHistoryPageLoaded = (value) => JSON.stringify(sessionPreviewHistoryPageLoadedSchema.parse(value));
|
|
21442
21450
|
|
|
21443
21451
|
// ../protocol/src/daemon-transport.ts
|
|
21444
21452
|
function defineMessageSignature(kind, encoder, decoder) {
|
|
@@ -21451,6 +21459,11 @@ function defineMessageSignature(kind, encoder, decoder) {
|
|
|
21451
21459
|
};
|
|
21452
21460
|
}
|
|
21453
21461
|
var serviceToDaemonSignatures = {
|
|
21462
|
+
[SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND]: defineMessageSignature(
|
|
21463
|
+
SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND,
|
|
21464
|
+
encodeSessionPreviewHistoryPageLoad,
|
|
21465
|
+
decodeSessionPreviewHistoryPageLoad
|
|
21466
|
+
),
|
|
21454
21467
|
[AGENT_INSTALL_CANCEL_KIND]: defineMessageSignature(
|
|
21455
21468
|
AGENT_INSTALL_CANCEL_KIND,
|
|
21456
21469
|
encodeAgentInstallCancelCommand,
|
|
@@ -21555,6 +21568,11 @@ function decodeServiceToDaemonMessage(encoded) {
|
|
|
21555
21568
|
return signature.decoder(encoded);
|
|
21556
21569
|
}
|
|
21557
21570
|
var daemonToServiceSignatures = {
|
|
21571
|
+
[SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND]: defineMessageSignature(
|
|
21572
|
+
SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND,
|
|
21573
|
+
encodeSessionPreviewHistoryPageLoaded,
|
|
21574
|
+
decodeSessionPreviewHistoryPageLoaded
|
|
21575
|
+
),
|
|
21558
21576
|
[SESSION_CONFIG_UPDATED_KIND]: defineMessageSignature(
|
|
21559
21577
|
SESSION_CONFIG_UPDATED_KIND,
|
|
21560
21578
|
encodeSessionConfigUpdatedEvent,
|
|
@@ -23314,6 +23332,11 @@ var threadLifecycleResponseSchema = external_exports.object({
|
|
|
23314
23332
|
serviceTier: boundedText(256).nullish(),
|
|
23315
23333
|
thread: external_exports.object({ id: boundedText(256), turns: threadTurnsSchema })
|
|
23316
23334
|
});
|
|
23335
|
+
var CODEX_HISTORY_TURN_PAGE_LIMIT = 20;
|
|
23336
|
+
var threadTurnsPageSchema = external_exports.object({
|
|
23337
|
+
data: external_exports.array(threadTurnSchema).max(CODEX_HISTORY_TURN_PAGE_LIMIT),
|
|
23338
|
+
nextCursor: boundedText(1024).nullish()
|
|
23339
|
+
});
|
|
23317
23340
|
var threadResumeResponseSchema = threadLifecycleResponseSchema;
|
|
23318
23341
|
var threadForkResponseSchema = threadLifecycleResponseSchema;
|
|
23319
23342
|
var threadTitleSchema = external_exports.string().transform((value) => value.slice(0, 500));
|
|
@@ -24388,14 +24411,14 @@ var CodexAcpAgent = class {
|
|
|
24388
24411
|
const resumed = threadResumeResponseSchema.parse(
|
|
24389
24412
|
await this.#appServer.request(
|
|
24390
24413
|
"thread/resume",
|
|
24391
|
-
{ cwd: context.params.cwd, excludeTurns:
|
|
24414
|
+
{ cwd: context.params.cwd, excludeTurns: true, threadId: context.params.sessionId },
|
|
24392
24415
|
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
|
|
24393
24416
|
)
|
|
24394
24417
|
);
|
|
24395
24418
|
this.#nativeSessionId = resumed.thread.id;
|
|
24396
24419
|
this.#settings.selectRestoredThread(resumed);
|
|
24397
24420
|
await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
|
|
24398
|
-
await this.#
|
|
24421
|
+
await this.#replaySavedHistory(context.signal);
|
|
24399
24422
|
await this.#emitAvailableCommands();
|
|
24400
24423
|
return { configOptions: this.#settings.configOptions() };
|
|
24401
24424
|
}).onRequest(methods.agent.session.fork, async (context) => {
|
|
@@ -24490,14 +24513,46 @@ var CodexAcpAgent = class {
|
|
|
24490
24513
|
}
|
|
24491
24514
|
return this.#closePromise;
|
|
24492
24515
|
};
|
|
24493
|
-
|
|
24494
|
-
|
|
24495
|
-
|
|
24496
|
-
|
|
24497
|
-
|
|
24498
|
-
|
|
24499
|
-
for (
|
|
24516
|
+
// ACP load requires chronological replay. Resume only restores execution;
|
|
24517
|
+
// native pages supply history without a single full-transcript response.
|
|
24518
|
+
#replaySavedHistory = async (signal) => {
|
|
24519
|
+
const deadline = AbortSignal.any([signal, AbortSignal.timeout(6e4)]);
|
|
24520
|
+
const seenCursors = /* @__PURE__ */ new Set();
|
|
24521
|
+
let cursor = null;
|
|
24522
|
+
for (; ; ) {
|
|
24523
|
+
deadline.throwIfAborted();
|
|
24524
|
+
const page = threadTurnsPageSchema.parse(
|
|
24525
|
+
await this.#appServer.request(
|
|
24526
|
+
"thread/turns/list",
|
|
24527
|
+
{
|
|
24528
|
+
threadId: this.#nativeSessionId,
|
|
24529
|
+
limit: CODEX_HISTORY_TURN_PAGE_LIMIT,
|
|
24530
|
+
sortDirection: "asc",
|
|
24531
|
+
itemsView: "full",
|
|
24532
|
+
...cursor === null ? {} : { cursor }
|
|
24533
|
+
},
|
|
24534
|
+
deadline
|
|
24535
|
+
)
|
|
24536
|
+
);
|
|
24537
|
+
await this.#replayHistory(page.data, deadline);
|
|
24538
|
+
if (page.nextCursor == null) {
|
|
24539
|
+
return;
|
|
24540
|
+
}
|
|
24541
|
+
if (page.data.length === 0 || seenCursors.has(page.nextCursor)) {
|
|
24542
|
+
throw new AcpExecutionError(
|
|
24543
|
+
"Codex repeated a history page cursor",
|
|
24544
|
+
{},
|
|
24545
|
+
"invalid_native_session_response"
|
|
24546
|
+
);
|
|
24547
|
+
}
|
|
24548
|
+
seenCursors.add(page.nextCursor);
|
|
24549
|
+
cursor = page.nextCursor;
|
|
24550
|
+
}
|
|
24551
|
+
};
|
|
24552
|
+
#replayHistory = async (turns, signal) => {
|
|
24553
|
+
for (const turn of turns) {
|
|
24500
24554
|
for (const rawItem of turn.items) {
|
|
24555
|
+
signal.throwIfAborted();
|
|
24501
24556
|
const item = decodeThreadItem(rawItem);
|
|
24502
24557
|
if (item === null) {
|
|
24503
24558
|
continue;
|
|
@@ -26877,7 +26932,7 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
|
|
|
26877
26932
|
}
|
|
26878
26933
|
|
|
26879
26934
|
// src/run-daemon.ts
|
|
26880
|
-
import { createHash as
|
|
26935
|
+
import { createHash as createHash7, randomUUID as randomUUID8 } from "node:crypto";
|
|
26881
26936
|
import { join as join18 } from "node:path";
|
|
26882
26937
|
import { styleText } from "node:util";
|
|
26883
26938
|
|
|
@@ -27772,7 +27827,7 @@ var AcpActivity = class _AcpActivity {
|
|
|
27772
27827
|
toolKind;
|
|
27773
27828
|
content;
|
|
27774
27829
|
detail;
|
|
27775
|
-
constructor(activityId, activityType, input2, locations, name2, output2, sequence, status, title2,
|
|
27830
|
+
constructor(activityId, activityType, input2, locations, name2, output2, sequence, status, title2, toolKind2, content = [], detail = captureActivityDetail(content, input2, output2)) {
|
|
27776
27831
|
this.activityId = activityId;
|
|
27777
27832
|
this.activityType = activityType;
|
|
27778
27833
|
this.input = input2;
|
|
@@ -27782,7 +27837,7 @@ var AcpActivity = class _AcpActivity {
|
|
|
27782
27837
|
this.sequence = sequence;
|
|
27783
27838
|
this.status = status;
|
|
27784
27839
|
this.title = title2;
|
|
27785
|
-
this.toolKind =
|
|
27840
|
+
this.toolKind = toolKind2;
|
|
27786
27841
|
this.content = content;
|
|
27787
27842
|
this.detail = detail;
|
|
27788
27843
|
}
|
|
@@ -28439,6 +28494,9 @@ function sessionConfigProtocolForAgent(_agentId) {
|
|
|
28439
28494
|
}
|
|
28440
28495
|
|
|
28441
28496
|
// src/acp/session-contracts.ts
|
|
28497
|
+
var acpNativeHistoryReader = {
|
|
28498
|
+
access: () => ({ kind: "acp" })
|
|
28499
|
+
};
|
|
28442
28500
|
var NullAcpSessionObserver = class {
|
|
28443
28501
|
onSessionEventV2 = (_sessionId, _event, _position) => Promise.resolve();
|
|
28444
28502
|
onCommands = () => Promise.resolve();
|
|
@@ -34089,6 +34147,15 @@ function eventPage(sessionGenerationId, eventCount, eventLimit, cursor, read) {
|
|
|
34089
34147
|
truncated: startPosition > 0
|
|
34090
34148
|
};
|
|
34091
34149
|
}
|
|
34150
|
+
function pageAcpSessionEventsV2(sessionGenerationId, events, eventLimit, cursor) {
|
|
34151
|
+
return eventPage(
|
|
34152
|
+
sessionGenerationId,
|
|
34153
|
+
events.length,
|
|
34154
|
+
eventLimit,
|
|
34155
|
+
cursor,
|
|
34156
|
+
(startPosition, endPosition) => events.slice(startPosition - 1, endPosition)
|
|
34157
|
+
);
|
|
34158
|
+
}
|
|
34092
34159
|
var MemoryAcpSessionEventStoreV2 = class {
|
|
34093
34160
|
#events = /* @__PURE__ */ new Map();
|
|
34094
34161
|
#session = (sessionId) => {
|
|
@@ -36211,6 +36278,147 @@ function isNativeChatSessionId(agentId, sessionId) {
|
|
|
36211
36278
|
return (agentId === "codex" || agentId === "claude" || agentId === "pi") && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu.test(sessionId);
|
|
36212
36279
|
}
|
|
36213
36280
|
|
|
36281
|
+
// src/native-sessions/native-history-events-v2.ts
|
|
36282
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
36283
|
+
function contentBlock(content) {
|
|
36284
|
+
switch (content.type) {
|
|
36285
|
+
case "text":
|
|
36286
|
+
return { text: content.text, type: "text" };
|
|
36287
|
+
case "image":
|
|
36288
|
+
return {
|
|
36289
|
+
data: content.data,
|
|
36290
|
+
mimeType: content.mimeType,
|
|
36291
|
+
type: "image",
|
|
36292
|
+
...content.uri.length === 0 ? {} : { uri: content.uri }
|
|
36293
|
+
};
|
|
36294
|
+
case "resource_link":
|
|
36295
|
+
return {
|
|
36296
|
+
name: content.name.length === 0 ? content.uri : content.name,
|
|
36297
|
+
type: "resource_link",
|
|
36298
|
+
uri: content.uri,
|
|
36299
|
+
...content.mimeType.length === 0 ? {} : { mimeType: content.mimeType }
|
|
36300
|
+
};
|
|
36301
|
+
case "resource":
|
|
36302
|
+
return {
|
|
36303
|
+
resource: content.text.length > 0 ? {
|
|
36304
|
+
text: content.text,
|
|
36305
|
+
uri: content.uri,
|
|
36306
|
+
...content.mimeType.length === 0 ? {} : { mimeType: content.mimeType }
|
|
36307
|
+
} : {
|
|
36308
|
+
blob: content.data,
|
|
36309
|
+
uri: content.uri,
|
|
36310
|
+
...content.mimeType.length === 0 ? {} : { mimeType: content.mimeType }
|
|
36311
|
+
},
|
|
36312
|
+
type: "resource"
|
|
36313
|
+
};
|
|
36314
|
+
case "diff":
|
|
36315
|
+
case "terminal":
|
|
36316
|
+
case "video":
|
|
36317
|
+
return null;
|
|
36318
|
+
default: {
|
|
36319
|
+
const unhandled = content.type;
|
|
36320
|
+
throw new Error(`Unknown native history content: ${String(unhandled)}`);
|
|
36321
|
+
}
|
|
36322
|
+
}
|
|
36323
|
+
}
|
|
36324
|
+
function toolContent2(content) {
|
|
36325
|
+
if (content.type === "diff") {
|
|
36326
|
+
return {
|
|
36327
|
+
newText: content.newText,
|
|
36328
|
+
path: content.path,
|
|
36329
|
+
type: "diff",
|
|
36330
|
+
...content.oldText.length === 0 ? {} : { oldText: content.oldText }
|
|
36331
|
+
};
|
|
36332
|
+
}
|
|
36333
|
+
if (content.type === "terminal") {
|
|
36334
|
+
return { terminalId: content.terminalId, type: "terminal" };
|
|
36335
|
+
}
|
|
36336
|
+
const block = contentBlock(content);
|
|
36337
|
+
return block === null ? null : { content: block, type: "content" };
|
|
36338
|
+
}
|
|
36339
|
+
function toolKind(value) {
|
|
36340
|
+
switch (value) {
|
|
36341
|
+
case "read":
|
|
36342
|
+
case "edit":
|
|
36343
|
+
case "delete":
|
|
36344
|
+
case "move":
|
|
36345
|
+
case "search":
|
|
36346
|
+
case "execute":
|
|
36347
|
+
case "think":
|
|
36348
|
+
case "fetch":
|
|
36349
|
+
case "switch_mode":
|
|
36350
|
+
case "other":
|
|
36351
|
+
return value;
|
|
36352
|
+
default:
|
|
36353
|
+
return "other";
|
|
36354
|
+
}
|
|
36355
|
+
}
|
|
36356
|
+
function toolStatus(value) {
|
|
36357
|
+
switch (value) {
|
|
36358
|
+
case "pending":
|
|
36359
|
+
return "pending";
|
|
36360
|
+
case "running":
|
|
36361
|
+
case "in_progress":
|
|
36362
|
+
return "in_progress";
|
|
36363
|
+
case "completed":
|
|
36364
|
+
return "completed";
|
|
36365
|
+
default:
|
|
36366
|
+
return "failed";
|
|
36367
|
+
}
|
|
36368
|
+
}
|
|
36369
|
+
function activityEvent(activity2) {
|
|
36370
|
+
const content = activity2.content.flatMap((item) => {
|
|
36371
|
+
const converted = toolContent2(item);
|
|
36372
|
+
return converted === null ? [] : [converted];
|
|
36373
|
+
});
|
|
36374
|
+
return {
|
|
36375
|
+
payload: {
|
|
36376
|
+
content,
|
|
36377
|
+
kind: toolKind(activity2.toolKind),
|
|
36378
|
+
locations: activity2.locations.map((path2) => ({ path: path2 })),
|
|
36379
|
+
rawInput: activity2.input,
|
|
36380
|
+
rawOutput: activity2.output,
|
|
36381
|
+
sessionUpdate: "tool_call",
|
|
36382
|
+
status: toolStatus(activity2.status),
|
|
36383
|
+
title: activity2.title,
|
|
36384
|
+
toolCallId: activity2.activityId,
|
|
36385
|
+
...activity2.name.length === 0 ? {} : { name: activity2.name }
|
|
36386
|
+
},
|
|
36387
|
+
type: "acp"
|
|
36388
|
+
};
|
|
36389
|
+
}
|
|
36390
|
+
function contentEvent(sessionUpdate, messageId, content) {
|
|
36391
|
+
return { payload: { content, messageId, sessionUpdate }, type: "acp" };
|
|
36392
|
+
}
|
|
36393
|
+
function historyEvents(history) {
|
|
36394
|
+
return history.messages.flatMap((message, index2) => {
|
|
36395
|
+
const messageId = `native-history-${index2.toString()}`;
|
|
36396
|
+
const sessionUpdate = message.role === "user" ? "user_message_chunk" : "agent_message_chunk";
|
|
36397
|
+
const images = (message.images ?? []).map(
|
|
36398
|
+
(image) => contentEvent(sessionUpdate, messageId, {
|
|
36399
|
+
data: image.data,
|
|
36400
|
+
mimeType: image.mimeType,
|
|
36401
|
+
type: "image"
|
|
36402
|
+
})
|
|
36403
|
+
);
|
|
36404
|
+
const text2 = message.text.length === 0 ? [] : [contentEvent(sessionUpdate, messageId, { text: message.text, type: "text" })];
|
|
36405
|
+
if (message.role === "user") {
|
|
36406
|
+
return [...images, ...text2];
|
|
36407
|
+
}
|
|
36408
|
+
const activities = message.activities.map(activityEvent);
|
|
36409
|
+
const content = message.content.flatMap((item) => {
|
|
36410
|
+
const converted = contentBlock(item);
|
|
36411
|
+
return converted === null ? [] : [contentEvent(sessionUpdate, messageId, converted)];
|
|
36412
|
+
});
|
|
36413
|
+
return [...activities, ...content, ...images, ...text2];
|
|
36414
|
+
});
|
|
36415
|
+
}
|
|
36416
|
+
function nativeHistoryEventsV2(nativeSessionId, history, eventLimit, cursor) {
|
|
36417
|
+
const events = historyEvents(history);
|
|
36418
|
+
const generationId = createHash3("sha256").update(nativeSessionId).update("\0").update(JSON.stringify(events)).digest("hex");
|
|
36419
|
+
return pageAcpSessionEventsV2(generationId, events, eventLimit, cursor);
|
|
36420
|
+
}
|
|
36421
|
+
|
|
36214
36422
|
// src/acp/process-capacity.ts
|
|
36215
36423
|
var AcpProcessCapacityLease = class {
|
|
36216
36424
|
#releaseCapacity;
|
|
@@ -36423,7 +36631,7 @@ var AgentRuntimeManager = class {
|
|
|
36423
36631
|
#onSessionStatusChanged;
|
|
36424
36632
|
#contentExternalizer;
|
|
36425
36633
|
#observer;
|
|
36426
|
-
constructor(observer = new NullAcpSessionObserver(), store = new MemoryAcpSessionStore(), nativeHistoryReader =
|
|
36634
|
+
constructor(observer = new NullAcpSessionObserver(), store = new MemoryAcpSessionStore(), nativeHistoryReader = acpNativeHistoryReader, sessionIdentity = "assigned", onSessionStatusChanged = () => void 0, contentExternalizer = new AcpContentExternalizer(new UnretainedExternalContentStore())) {
|
|
36427
36635
|
this.#observer = observer;
|
|
36428
36636
|
this.#store = store;
|
|
36429
36637
|
this.#nativeHistoryReader = nativeHistoryReader;
|
|
@@ -36953,6 +37161,14 @@ var AgentRuntimeManager = class {
|
|
|
36953
37161
|
}
|
|
36954
37162
|
this.#nativeOperations.add(key);
|
|
36955
37163
|
try {
|
|
37164
|
+
const historyAccess = this.#nativeHistoryReader.access(options2);
|
|
37165
|
+
if (historyAccess.kind === "direct") {
|
|
37166
|
+
const history = await historyAccess.read(nativeSessionId, () => null);
|
|
37167
|
+
if (history.status === "unavailable") {
|
|
37168
|
+
throw new AcpExecutionError(history.cause.message, {}, history.cause.code);
|
|
37169
|
+
}
|
|
37170
|
+
return nativeHistoryEventsV2(nativeSessionId, history, eventLimit, cursor);
|
|
37171
|
+
}
|
|
36956
37172
|
return await this.#queryProcesses.previewEventsV2(options2, nativeSessionId, eventLimit, cursor);
|
|
36957
37173
|
} finally {
|
|
36958
37174
|
this.#nativeOperations.delete(key);
|
|
@@ -36962,15 +37178,9 @@ var AgentRuntimeManager = class {
|
|
|
36962
37178
|
return await this.#executionProcesses.use(options2.sessionId, async () => {
|
|
36963
37179
|
const runtime = await this.ensureSession(options2);
|
|
36964
37180
|
const stored = this.#store.read(options2.sessionId);
|
|
36965
|
-
|
|
36966
|
-
|
|
36967
|
-
|
|
36968
|
-
stored.session.nativeSessionId,
|
|
36969
|
-
runtime.nativeHistoryTurn
|
|
36970
|
-
);
|
|
36971
|
-
if (history !== null) {
|
|
36972
|
-
return history;
|
|
36973
|
-
}
|
|
37181
|
+
const historyAccess = this.#nativeHistoryReader.access(options2);
|
|
37182
|
+
if (stored instanceof FoundAcpStoredSession && historyAccess.kind === "direct") {
|
|
37183
|
+
return await historyAccess.read(stored.session.nativeSessionId, runtime.nativeHistoryTurn);
|
|
36974
37184
|
}
|
|
36975
37185
|
return await runtime.loadHistory(options2.signal);
|
|
36976
37186
|
});
|
|
@@ -37863,7 +38073,7 @@ import { WebSocket as WebSocket2 } from "undici";
|
|
|
37863
38073
|
import { WebSocket } from "undici";
|
|
37864
38074
|
|
|
37865
38075
|
// src/prompt-artifact-resolver.ts
|
|
37866
|
-
import { createHash as
|
|
38076
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
37867
38077
|
import { fetch as fetch3 } from "undici";
|
|
37868
38078
|
var ARTIFACT_SCHEME = "mobius-artifact:";
|
|
37869
38079
|
var ARTIFACT_DOWNLOAD_TIMEOUT_MILLISECONDS = 2e4;
|
|
@@ -38001,7 +38211,7 @@ async function download(config2, command, reference, signal) {
|
|
|
38001
38211
|
);
|
|
38002
38212
|
}
|
|
38003
38213
|
const bytes = await responseBytes(response, reference.byteLength, requestSignal);
|
|
38004
|
-
if (
|
|
38214
|
+
if (createHash4("sha256").update(bytes).digest("hex") !== reference.sha256) {
|
|
38005
38215
|
throw new PromptArtifactError(
|
|
38006
38216
|
"artifact_integrity_failed",
|
|
38007
38217
|
"The prompt artifact failed integrity validation"
|
|
@@ -39022,6 +39232,14 @@ var historyItemSchema = external_exports.discriminatedUnion("type", [
|
|
|
39022
39232
|
dynamicToolCallSchema,
|
|
39023
39233
|
planSchema
|
|
39024
39234
|
]);
|
|
39235
|
+
var CodexHistoryResponseError = class extends Error {
|
|
39236
|
+
code;
|
|
39237
|
+
constructor(response) {
|
|
39238
|
+
super(response.message);
|
|
39239
|
+
this.code = response.code;
|
|
39240
|
+
this.name = "CodexHistoryResponseError";
|
|
39241
|
+
}
|
|
39242
|
+
};
|
|
39025
39243
|
function bounded(value, maximum) {
|
|
39026
39244
|
return value.slice(0, maximum);
|
|
39027
39245
|
}
|
|
@@ -39061,7 +39279,7 @@ function formatted(value) {
|
|
|
39061
39279
|
}
|
|
39062
39280
|
return JSON.stringify(value) ?? "";
|
|
39063
39281
|
}
|
|
39064
|
-
function
|
|
39282
|
+
function toolStatus2(status) {
|
|
39065
39283
|
return status === "inProgress" ? "running" : status === "completed" ? "completed" : "failed";
|
|
39066
39284
|
}
|
|
39067
39285
|
function diffDisplayContent(path2, newText) {
|
|
@@ -39268,7 +39486,7 @@ function decodeHistory(thread, value, options) {
|
|
|
39268
39486
|
formatted_output: historyItem.aggregatedOutput ?? "",
|
|
39269
39487
|
...historyItem.exitCode == null ? {} : { exit_code: historyItem.exitCode }
|
|
39270
39488
|
}),
|
|
39271
|
-
status:
|
|
39489
|
+
status: toolStatus2(historyItem.status),
|
|
39272
39490
|
title: historyItem.command,
|
|
39273
39491
|
toolKind: action
|
|
39274
39492
|
})
|
|
@@ -39290,7 +39508,7 @@ function decodeHistory(thread, value, options) {
|
|
|
39290
39508
|
locations: paths,
|
|
39291
39509
|
name: "",
|
|
39292
39510
|
output: "",
|
|
39293
|
-
status:
|
|
39511
|
+
status: toolStatus2(historyItem.status),
|
|
39294
39512
|
title: paths.join(", "),
|
|
39295
39513
|
toolKind: "edit"
|
|
39296
39514
|
})
|
|
@@ -39308,7 +39526,7 @@ function decodeHistory(thread, value, options) {
|
|
|
39308
39526
|
locations: [],
|
|
39309
39527
|
name: historyItem.tool,
|
|
39310
39528
|
output: formatted(historyItem.error ?? historyItem.result),
|
|
39311
|
-
status:
|
|
39529
|
+
status: toolStatus2(historyItem.status),
|
|
39312
39530
|
title: `${historyItem.server}/${historyItem.tool}`,
|
|
39313
39531
|
toolKind: "other"
|
|
39314
39532
|
})
|
|
@@ -39326,7 +39544,7 @@ function decodeHistory(thread, value, options) {
|
|
|
39326
39544
|
locations: [],
|
|
39327
39545
|
name: historyItem.tool,
|
|
39328
39546
|
output: formatted(historyItem.contentItems),
|
|
39329
|
-
status:
|
|
39547
|
+
status: toolStatus2(historyItem.status),
|
|
39330
39548
|
title: historyItem.namespace == null ? historyItem.tool : `${historyItem.namespace}/${historyItem.tool}`,
|
|
39331
39549
|
toolKind: "other"
|
|
39332
39550
|
})
|
|
@@ -39492,7 +39710,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
39492
39710
|
fail(
|
|
39493
39711
|
new AcpExecutionError(
|
|
39494
39712
|
"Saved Codex history could not be read.",
|
|
39495
|
-
{ cause: message.error },
|
|
39713
|
+
{ cause: new CodexHistoryResponseError(message.error) },
|
|
39496
39714
|
"native_history_unavailable"
|
|
39497
39715
|
)
|
|
39498
39716
|
);
|
|
@@ -40000,7 +40218,7 @@ var NativeSessionService = class {
|
|
|
40000
40218
|
};
|
|
40001
40219
|
|
|
40002
40220
|
// src/relay-connection/daemon-operation-state.ts
|
|
40003
|
-
import { createHash as
|
|
40221
|
+
import { createHash as createHash5, randomUUID as randomUUID5 } from "node:crypto";
|
|
40004
40222
|
var MAX_TERMINAL_RECEIPTS = 1024;
|
|
40005
40223
|
function isTerminal(state) {
|
|
40006
40224
|
return state === "succeeded" || state === "failed" || state === "cancelled";
|
|
@@ -40009,7 +40227,7 @@ var DaemonOperationState = class {
|
|
|
40009
40227
|
#executions = /* @__PURE__ */ new Map();
|
|
40010
40228
|
#terminalCount = 0;
|
|
40011
40229
|
claimExecution = (commandId, sessionId, commandJson) => {
|
|
40012
|
-
const commandHash =
|
|
40230
|
+
const commandHash = createHash5("sha256").update(commandJson).digest("hex");
|
|
40013
40231
|
const existing = this.#executions.get(commandId);
|
|
40014
40232
|
if (existing !== void 0) {
|
|
40015
40233
|
if (existing.sessionId !== sessionId || existing.commandHash !== commandHash) {
|
|
@@ -40231,7 +40449,7 @@ import { WebSocket as WebSocket5 } from "undici";
|
|
|
40231
40449
|
import { WebSocket as WebSocket3 } from "undici";
|
|
40232
40450
|
|
|
40233
40451
|
// src/agent-catalog/discover-agent-settings.ts
|
|
40234
|
-
import { createHash as
|
|
40452
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
40235
40453
|
|
|
40236
40454
|
// src/agent-catalog/agent-settings-base.ts
|
|
40237
40455
|
var AgentSettingsConfigurationError = class extends Error {
|
|
@@ -40695,7 +40913,7 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
|
|
|
40695
40913
|
unsupportedModelIds: modelEffort.unsupportedModelIds,
|
|
40696
40914
|
valuesByModel: {}
|
|
40697
40915
|
};
|
|
40698
|
-
return
|
|
40916
|
+
return createHash6("sha256").update(
|
|
40699
40917
|
JSON.stringify({
|
|
40700
40918
|
adapterVersion: agent.kind === "acp-adapter-process" ? agent.adapterVersion : agent.agentVersion,
|
|
40701
40919
|
agentId: agent.id,
|
|
@@ -41007,7 +41225,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
41007
41225
|
},
|
|
41008
41226
|
queuedPromptRequests: recovery.queuedPromptRequests
|
|
41009
41227
|
},
|
|
41010
|
-
kind:
|
|
41228
|
+
kind: SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND,
|
|
41011
41229
|
requestId: command.requestId,
|
|
41012
41230
|
sessionId: command.sessionId
|
|
41013
41231
|
});
|
|
@@ -41036,6 +41254,81 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
41036
41254
|
}
|
|
41037
41255
|
}
|
|
41038
41256
|
}
|
|
41257
|
+
async function executeSessionPreviewHistoryPageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventLogV2, signal) {
|
|
41258
|
+
try {
|
|
41259
|
+
const resolved = await resolveSessionDirectories(
|
|
41260
|
+
directories,
|
|
41261
|
+
config2.bindingId,
|
|
41262
|
+
command.directoryId,
|
|
41263
|
+
command.additionalDirectoryIds,
|
|
41264
|
+
signal
|
|
41265
|
+
);
|
|
41266
|
+
const replay = await sessions.previewNativeSessionEventsV2(
|
|
41267
|
+
{
|
|
41268
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
41269
|
+
agent: config2.catalog.find(command.agentId),
|
|
41270
|
+
cwd: resolved.cwd,
|
|
41271
|
+
sessionId: command.sessionId,
|
|
41272
|
+
signal
|
|
41273
|
+
},
|
|
41274
|
+
command.sessionId,
|
|
41275
|
+
command.eventLimit,
|
|
41276
|
+
command.cursor
|
|
41277
|
+
);
|
|
41278
|
+
signal.throwIfAborted();
|
|
41279
|
+
const events = replay.events.map(
|
|
41280
|
+
(event, index2) => eventLogV2.event(
|
|
41281
|
+
command.sessionId,
|
|
41282
|
+
replay.sessionGenerationId,
|
|
41283
|
+
replay.startPosition + index2,
|
|
41284
|
+
event,
|
|
41285
|
+
"1970-01-01T00:00:00.000Z"
|
|
41286
|
+
)
|
|
41287
|
+
);
|
|
41288
|
+
const tailCursor = events.at(-1)?.eventId ?? "";
|
|
41289
|
+
audit.record({
|
|
41290
|
+
commandId: command.requestId,
|
|
41291
|
+
event: "session_event_log_v2_loaded",
|
|
41292
|
+
sessionId: command.sessionId
|
|
41293
|
+
});
|
|
41294
|
+
send(socket, {
|
|
41295
|
+
events: {
|
|
41296
|
+
events: {
|
|
41297
|
+
events,
|
|
41298
|
+
nextCursor: replay.nextCursor,
|
|
41299
|
+
sessionGenerationId: replay.sessionGenerationId,
|
|
41300
|
+
tailCursor,
|
|
41301
|
+
truncated: replay.truncated,
|
|
41302
|
+
version: 2
|
|
41303
|
+
},
|
|
41304
|
+
queuedPromptRequests: []
|
|
41305
|
+
},
|
|
41306
|
+
kind: SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND,
|
|
41307
|
+
requestId: command.requestId,
|
|
41308
|
+
sessionId: command.sessionId
|
|
41309
|
+
});
|
|
41310
|
+
} catch (error62) {
|
|
41311
|
+
if (!signal.aborted) {
|
|
41312
|
+
diagnostics.daemonDiagnostic(
|
|
41313
|
+
"session_history_v2_load_failed",
|
|
41314
|
+
command.requestId,
|
|
41315
|
+
{
|
|
41316
|
+
agentId: command.agentId,
|
|
41317
|
+
code: operationErrorCode(error62),
|
|
41318
|
+
sessionId: command.sessionId
|
|
41319
|
+
},
|
|
41320
|
+
error62
|
|
41321
|
+
);
|
|
41322
|
+
audit.record({
|
|
41323
|
+
commandId: command.requestId,
|
|
41324
|
+
details: { agentId: command.agentId, code: operationErrorCode(error62) },
|
|
41325
|
+
event: "session_history_v2_load_failed",
|
|
41326
|
+
sessionId: command.sessionId
|
|
41327
|
+
});
|
|
41328
|
+
reportOperationFailure(socket, command.requestId, command.sessionId, error62);
|
|
41329
|
+
}
|
|
41330
|
+
}
|
|
41331
|
+
}
|
|
41039
41332
|
|
|
41040
41333
|
// src/acp/session-config/apply-session-configuration.ts
|
|
41041
41334
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
@@ -41785,6 +42078,20 @@ function createDaemonCommandHandler({
|
|
|
41785
42078
|
);
|
|
41786
42079
|
return;
|
|
41787
42080
|
}
|
|
42081
|
+
if (kind === SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND) {
|
|
42082
|
+
void executeSessionPreviewHistoryPageLoad(
|
|
42083
|
+
socket,
|
|
42084
|
+
message,
|
|
42085
|
+
config2,
|
|
42086
|
+
directories,
|
|
42087
|
+
audit,
|
|
42088
|
+
diagnostics,
|
|
42089
|
+
sessions,
|
|
42090
|
+
eventLogV2,
|
|
42091
|
+
signal
|
|
42092
|
+
);
|
|
42093
|
+
return;
|
|
42094
|
+
}
|
|
41788
42095
|
if (kind === NATIVE_SESSION_CANCEL_KIND) {
|
|
41789
42096
|
nativeRequestHandler.cancel(message);
|
|
41790
42097
|
return;
|
|
@@ -42756,7 +43063,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
42756
43063
|
publishCatalog: async (installationSignal) => await publishAgentCatalog(config2, installationSignal),
|
|
42757
43064
|
stateDirectory
|
|
42758
43065
|
});
|
|
42759
|
-
const channelHash =
|
|
43066
|
+
const channelHash = createHash7("sha256").update(config2.channelId).digest("hex");
|
|
42760
43067
|
const sessionDatabase = openAcpSessionDatabase(join18(stateDirectory, "sessions", `${channelHash}.sqlite`));
|
|
42761
43068
|
let eventsV2;
|
|
42762
43069
|
try {
|
|
@@ -42782,13 +43089,16 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
42782
43089
|
}, eventLogV2.record),
|
|
42783
43090
|
sessionStore,
|
|
42784
43091
|
{
|
|
42785
|
-
|
|
42786
|
-
|
|
42787
|
-
|
|
42788
|
-
|
|
42789
|
-
|
|
42790
|
-
|
|
42791
|
-
|
|
43092
|
+
access: (options2) => options2.agent.id === "codex" ? {
|
|
43093
|
+
kind: "direct",
|
|
43094
|
+
read: async (nativeSessionId, nativeTurn) => (await readCodexFullHistory(
|
|
43095
|
+
options2.agent,
|
|
43096
|
+
options2.cwd,
|
|
43097
|
+
nativeSessionId,
|
|
43098
|
+
options2.signal,
|
|
43099
|
+
nativeTurn
|
|
43100
|
+
)).history
|
|
43101
|
+
} : { kind: "acp" }
|
|
42792
43102
|
},
|
|
42793
43103
|
"native",
|
|
42794
43104
|
publisher.publishStatus,
|
|
@@ -42964,7 +43274,7 @@ import { basename as basename6, resolve as resolve7 } from "node:path";
|
|
|
42964
43274
|
import { fetch as fetch4 } from "undici";
|
|
42965
43275
|
|
|
42966
43276
|
// src/storage/runtime-installation-store.ts
|
|
42967
|
-
import { createHash as
|
|
43277
|
+
import { createHash as createHash8, randomUUID as randomUUID9 } from "node:crypto";
|
|
42968
43278
|
import { mkdir as mkdir5, open as open5, readdir as readdir4, rename as rename4, unlink, writeFile as writeFile4 } from "node:fs/promises";
|
|
42969
43279
|
import { dirname as dirname6, join as join19, resolve as resolve6 } from "node:path";
|
|
42970
43280
|
var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
|
|
@@ -43100,7 +43410,7 @@ function installationId() {
|
|
|
43100
43410
|
return `min_${randomUUID9().replaceAll("-", "")}`;
|
|
43101
43411
|
}
|
|
43102
43412
|
function channelIndexFileName(channelId) {
|
|
43103
|
-
return `mci_${
|
|
43413
|
+
return `mci_${createHash8("sha256").update(channelId).digest("hex")}.json`;
|
|
43104
43414
|
}
|
|
43105
43415
|
function decodeInstallationPointer(value) {
|
|
43106
43416
|
if (!isRecord10(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
|