@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/index.js
CHANGED
|
@@ -21435,24 +21435,28 @@ var decodeAcpSessionUpdateV2 = (value) => decode5(value, acpSessionUpdateV2Schem
|
|
|
21435
21435
|
// ../protocol/src/session-live-history.ts
|
|
21436
21436
|
var SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND = "session.live-history.v2.page.load";
|
|
21437
21437
|
var SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND = "session.live-history.v2.page.loaded";
|
|
21438
|
+
var SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND = "session.preview-history.page.load";
|
|
21439
|
+
var SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND = "session.preview-history.page.loaded";
|
|
21438
21440
|
var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
|
|
21439
|
-
var
|
|
21441
|
+
var pageLoadFields = {
|
|
21440
21442
|
additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
|
|
21441
21443
|
agentId: identifierStringSchema,
|
|
21442
21444
|
bindingId: identifierStringSchema,
|
|
21443
21445
|
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
21444
21446
|
directoryId: directoryIdentifier,
|
|
21445
|
-
kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND),
|
|
21446
21447
|
eventLimit: external_exports.number().int().min(1).max(1e4),
|
|
21447
21448
|
requestId: identifierStringSchema,
|
|
21448
21449
|
sessionId: identifierStringSchema
|
|
21449
|
-
}
|
|
21450
|
-
var
|
|
21450
|
+
};
|
|
21451
|
+
var sessionLiveHistoryV2PageLoadSchema = external_exports.object({ ...pageLoadFields, kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND) }).readonly();
|
|
21452
|
+
var sessionPreviewHistoryPageLoadSchema = external_exports.object({ ...pageLoadFields, kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND) }).readonly();
|
|
21453
|
+
var pageLoadedFields = {
|
|
21451
21454
|
events: nativeSessionEventsV2Schema,
|
|
21452
|
-
kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND),
|
|
21453
21455
|
requestId: identifierStringSchema,
|
|
21454
21456
|
sessionId: identifierStringSchema
|
|
21455
|
-
}
|
|
21457
|
+
};
|
|
21458
|
+
var sessionLiveHistoryV2PageLoadedSchema = external_exports.object({ ...pageLoadedFields, kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND) }).readonly();
|
|
21459
|
+
var sessionPreviewHistoryPageLoadedSchema = external_exports.object({ ...pageLoadedFields, kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND) }).readonly();
|
|
21456
21460
|
function decode6(schema, encoded) {
|
|
21457
21461
|
try {
|
|
21458
21462
|
const value = JSON.parse(encoded);
|
|
@@ -21463,8 +21467,12 @@ function decode6(schema, encoded) {
|
|
|
21463
21467
|
}
|
|
21464
21468
|
var decodeSessionLiveHistoryV2PageLoad = (encoded) => decode6(sessionLiveHistoryV2PageLoadSchema, encoded);
|
|
21465
21469
|
var decodeSessionLiveHistoryV2PageLoaded = (encoded) => decode6(sessionLiveHistoryV2PageLoadedSchema, encoded);
|
|
21470
|
+
var decodeSessionPreviewHistoryPageLoad = (encoded) => decode6(sessionPreviewHistoryPageLoadSchema, encoded);
|
|
21471
|
+
var decodeSessionPreviewHistoryPageLoaded = (encoded) => decode6(sessionPreviewHistoryPageLoadedSchema, encoded);
|
|
21466
21472
|
var encodeSessionLiveHistoryV2PageLoad = (value) => JSON.stringify(sessionLiveHistoryV2PageLoadSchema.parse(value));
|
|
21467
21473
|
var encodeSessionLiveHistoryV2PageLoaded = (value) => JSON.stringify(sessionLiveHistoryV2PageLoadedSchema.parse(value));
|
|
21474
|
+
var encodeSessionPreviewHistoryPageLoad = (value) => JSON.stringify(sessionPreviewHistoryPageLoadSchema.parse(value));
|
|
21475
|
+
var encodeSessionPreviewHistoryPageLoaded = (value) => JSON.stringify(sessionPreviewHistoryPageLoadedSchema.parse(value));
|
|
21468
21476
|
|
|
21469
21477
|
// ../protocol/src/daemon-transport.ts
|
|
21470
21478
|
function defineMessageSignature(kind, encoder, decoder) {
|
|
@@ -21477,6 +21485,11 @@ function defineMessageSignature(kind, encoder, decoder) {
|
|
|
21477
21485
|
};
|
|
21478
21486
|
}
|
|
21479
21487
|
var serviceToDaemonSignatures = {
|
|
21488
|
+
[SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND]: defineMessageSignature(
|
|
21489
|
+
SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND,
|
|
21490
|
+
encodeSessionPreviewHistoryPageLoad,
|
|
21491
|
+
decodeSessionPreviewHistoryPageLoad
|
|
21492
|
+
),
|
|
21480
21493
|
[AGENT_INSTALL_CANCEL_KIND]: defineMessageSignature(
|
|
21481
21494
|
AGENT_INSTALL_CANCEL_KIND,
|
|
21482
21495
|
encodeAgentInstallCancelCommand,
|
|
@@ -21581,6 +21594,11 @@ function decodeServiceToDaemonMessage(encoded) {
|
|
|
21581
21594
|
return signature.decoder(encoded);
|
|
21582
21595
|
}
|
|
21583
21596
|
var daemonToServiceSignatures = {
|
|
21597
|
+
[SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND]: defineMessageSignature(
|
|
21598
|
+
SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND,
|
|
21599
|
+
encodeSessionPreviewHistoryPageLoaded,
|
|
21600
|
+
decodeSessionPreviewHistoryPageLoaded
|
|
21601
|
+
),
|
|
21584
21602
|
[SESSION_CONFIG_UPDATED_KIND]: defineMessageSignature(
|
|
21585
21603
|
SESSION_CONFIG_UPDATED_KIND,
|
|
21586
21604
|
encodeSessionConfigUpdatedEvent,
|
|
@@ -23464,7 +23482,7 @@ var AcpActivity = class _AcpActivity {
|
|
|
23464
23482
|
toolKind;
|
|
23465
23483
|
content;
|
|
23466
23484
|
detail;
|
|
23467
|
-
constructor(activityId, activityType, input2, locations, name2, output2, sequence, status, title2,
|
|
23485
|
+
constructor(activityId, activityType, input2, locations, name2, output2, sequence, status, title2, toolKind2, content = [], detail = captureActivityDetail(content, input2, output2)) {
|
|
23468
23486
|
this.activityId = activityId;
|
|
23469
23487
|
this.activityType = activityType;
|
|
23470
23488
|
this.input = input2;
|
|
@@ -23474,7 +23492,7 @@ var AcpActivity = class _AcpActivity {
|
|
|
23474
23492
|
this.sequence = sequence;
|
|
23475
23493
|
this.status = status;
|
|
23476
23494
|
this.title = title2;
|
|
23477
|
-
this.toolKind =
|
|
23495
|
+
this.toolKind = toolKind2;
|
|
23478
23496
|
this.content = content;
|
|
23479
23497
|
this.detail = detail;
|
|
23480
23498
|
}
|
|
@@ -24131,6 +24149,9 @@ function sessionConfigProtocolForAgent(_agentId) {
|
|
|
24131
24149
|
}
|
|
24132
24150
|
|
|
24133
24151
|
// src/acp/session-contracts.ts
|
|
24152
|
+
var acpNativeHistoryReader = {
|
|
24153
|
+
access: () => ({ kind: "acp" })
|
|
24154
|
+
};
|
|
24134
24155
|
var NullAcpSessionObserver = class {
|
|
24135
24156
|
onSessionEventV2 = (_sessionId, _event, _position) => Promise.resolve();
|
|
24136
24157
|
onCommands = () => Promise.resolve();
|
|
@@ -29838,6 +29859,15 @@ function eventPage(sessionGenerationId, eventCount, eventLimit, cursor, read) {
|
|
|
29838
29859
|
truncated: startPosition > 0
|
|
29839
29860
|
};
|
|
29840
29861
|
}
|
|
29862
|
+
function pageAcpSessionEventsV2(sessionGenerationId, events, eventLimit, cursor) {
|
|
29863
|
+
return eventPage(
|
|
29864
|
+
sessionGenerationId,
|
|
29865
|
+
events.length,
|
|
29866
|
+
eventLimit,
|
|
29867
|
+
cursor,
|
|
29868
|
+
(startPosition, endPosition) => events.slice(startPosition - 1, endPosition)
|
|
29869
|
+
);
|
|
29870
|
+
}
|
|
29841
29871
|
var MemoryAcpSessionEventStoreV2 = class {
|
|
29842
29872
|
#events = /* @__PURE__ */ new Map();
|
|
29843
29873
|
#session = (sessionId) => {
|
|
@@ -31960,6 +31990,147 @@ function isNativeChatSessionId(agentId, sessionId) {
|
|
|
31960
31990
|
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);
|
|
31961
31991
|
}
|
|
31962
31992
|
|
|
31993
|
+
// src/native-sessions/native-history-events-v2.ts
|
|
31994
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
31995
|
+
function contentBlock(content) {
|
|
31996
|
+
switch (content.type) {
|
|
31997
|
+
case "text":
|
|
31998
|
+
return { text: content.text, type: "text" };
|
|
31999
|
+
case "image":
|
|
32000
|
+
return {
|
|
32001
|
+
data: content.data,
|
|
32002
|
+
mimeType: content.mimeType,
|
|
32003
|
+
type: "image",
|
|
32004
|
+
...content.uri.length === 0 ? {} : { uri: content.uri }
|
|
32005
|
+
};
|
|
32006
|
+
case "resource_link":
|
|
32007
|
+
return {
|
|
32008
|
+
name: content.name.length === 0 ? content.uri : content.name,
|
|
32009
|
+
type: "resource_link",
|
|
32010
|
+
uri: content.uri,
|
|
32011
|
+
...content.mimeType.length === 0 ? {} : { mimeType: content.mimeType }
|
|
32012
|
+
};
|
|
32013
|
+
case "resource":
|
|
32014
|
+
return {
|
|
32015
|
+
resource: content.text.length > 0 ? {
|
|
32016
|
+
text: content.text,
|
|
32017
|
+
uri: content.uri,
|
|
32018
|
+
...content.mimeType.length === 0 ? {} : { mimeType: content.mimeType }
|
|
32019
|
+
} : {
|
|
32020
|
+
blob: content.data,
|
|
32021
|
+
uri: content.uri,
|
|
32022
|
+
...content.mimeType.length === 0 ? {} : { mimeType: content.mimeType }
|
|
32023
|
+
},
|
|
32024
|
+
type: "resource"
|
|
32025
|
+
};
|
|
32026
|
+
case "diff":
|
|
32027
|
+
case "terminal":
|
|
32028
|
+
case "video":
|
|
32029
|
+
return null;
|
|
32030
|
+
default: {
|
|
32031
|
+
const unhandled = content.type;
|
|
32032
|
+
throw new Error(`Unknown native history content: ${String(unhandled)}`);
|
|
32033
|
+
}
|
|
32034
|
+
}
|
|
32035
|
+
}
|
|
32036
|
+
function toolContent2(content) {
|
|
32037
|
+
if (content.type === "diff") {
|
|
32038
|
+
return {
|
|
32039
|
+
newText: content.newText,
|
|
32040
|
+
path: content.path,
|
|
32041
|
+
type: "diff",
|
|
32042
|
+
...content.oldText.length === 0 ? {} : { oldText: content.oldText }
|
|
32043
|
+
};
|
|
32044
|
+
}
|
|
32045
|
+
if (content.type === "terminal") {
|
|
32046
|
+
return { terminalId: content.terminalId, type: "terminal" };
|
|
32047
|
+
}
|
|
32048
|
+
const block = contentBlock(content);
|
|
32049
|
+
return block === null ? null : { content: block, type: "content" };
|
|
32050
|
+
}
|
|
32051
|
+
function toolKind(value) {
|
|
32052
|
+
switch (value) {
|
|
32053
|
+
case "read":
|
|
32054
|
+
case "edit":
|
|
32055
|
+
case "delete":
|
|
32056
|
+
case "move":
|
|
32057
|
+
case "search":
|
|
32058
|
+
case "execute":
|
|
32059
|
+
case "think":
|
|
32060
|
+
case "fetch":
|
|
32061
|
+
case "switch_mode":
|
|
32062
|
+
case "other":
|
|
32063
|
+
return value;
|
|
32064
|
+
default:
|
|
32065
|
+
return "other";
|
|
32066
|
+
}
|
|
32067
|
+
}
|
|
32068
|
+
function toolStatus(value) {
|
|
32069
|
+
switch (value) {
|
|
32070
|
+
case "pending":
|
|
32071
|
+
return "pending";
|
|
32072
|
+
case "running":
|
|
32073
|
+
case "in_progress":
|
|
32074
|
+
return "in_progress";
|
|
32075
|
+
case "completed":
|
|
32076
|
+
return "completed";
|
|
32077
|
+
default:
|
|
32078
|
+
return "failed";
|
|
32079
|
+
}
|
|
32080
|
+
}
|
|
32081
|
+
function activityEvent(activity2) {
|
|
32082
|
+
const content = activity2.content.flatMap((item) => {
|
|
32083
|
+
const converted = toolContent2(item);
|
|
32084
|
+
return converted === null ? [] : [converted];
|
|
32085
|
+
});
|
|
32086
|
+
return {
|
|
32087
|
+
payload: {
|
|
32088
|
+
content,
|
|
32089
|
+
kind: toolKind(activity2.toolKind),
|
|
32090
|
+
locations: activity2.locations.map((path2) => ({ path: path2 })),
|
|
32091
|
+
rawInput: activity2.input,
|
|
32092
|
+
rawOutput: activity2.output,
|
|
32093
|
+
sessionUpdate: "tool_call",
|
|
32094
|
+
status: toolStatus(activity2.status),
|
|
32095
|
+
title: activity2.title,
|
|
32096
|
+
toolCallId: activity2.activityId,
|
|
32097
|
+
...activity2.name.length === 0 ? {} : { name: activity2.name }
|
|
32098
|
+
},
|
|
32099
|
+
type: "acp"
|
|
32100
|
+
};
|
|
32101
|
+
}
|
|
32102
|
+
function contentEvent(sessionUpdate, messageId, content) {
|
|
32103
|
+
return { payload: { content, messageId, sessionUpdate }, type: "acp" };
|
|
32104
|
+
}
|
|
32105
|
+
function historyEvents(history) {
|
|
32106
|
+
return history.messages.flatMap((message, index2) => {
|
|
32107
|
+
const messageId = `native-history-${index2.toString()}`;
|
|
32108
|
+
const sessionUpdate = message.role === "user" ? "user_message_chunk" : "agent_message_chunk";
|
|
32109
|
+
const images = (message.images ?? []).map(
|
|
32110
|
+
(image) => contentEvent(sessionUpdate, messageId, {
|
|
32111
|
+
data: image.data,
|
|
32112
|
+
mimeType: image.mimeType,
|
|
32113
|
+
type: "image"
|
|
32114
|
+
})
|
|
32115
|
+
);
|
|
32116
|
+
const text2 = message.text.length === 0 ? [] : [contentEvent(sessionUpdate, messageId, { text: message.text, type: "text" })];
|
|
32117
|
+
if (message.role === "user") {
|
|
32118
|
+
return [...images, ...text2];
|
|
32119
|
+
}
|
|
32120
|
+
const activities = message.activities.map(activityEvent);
|
|
32121
|
+
const content = message.content.flatMap((item) => {
|
|
32122
|
+
const converted = contentBlock(item);
|
|
32123
|
+
return converted === null ? [] : [contentEvent(sessionUpdate, messageId, converted)];
|
|
32124
|
+
});
|
|
32125
|
+
return [...activities, ...content, ...images, ...text2];
|
|
32126
|
+
});
|
|
32127
|
+
}
|
|
32128
|
+
function nativeHistoryEventsV2(nativeSessionId, history, eventLimit, cursor) {
|
|
32129
|
+
const events = historyEvents(history);
|
|
32130
|
+
const generationId = createHash2("sha256").update(nativeSessionId).update("\0").update(JSON.stringify(events)).digest("hex");
|
|
32131
|
+
return pageAcpSessionEventsV2(generationId, events, eventLimit, cursor);
|
|
32132
|
+
}
|
|
32133
|
+
|
|
31963
32134
|
// src/acp/process-capacity.ts
|
|
31964
32135
|
var AcpProcessCapacityLease = class {
|
|
31965
32136
|
#releaseCapacity;
|
|
@@ -32172,7 +32343,7 @@ var AgentRuntimeManager = class {
|
|
|
32172
32343
|
#onSessionStatusChanged;
|
|
32173
32344
|
#contentExternalizer;
|
|
32174
32345
|
#observer;
|
|
32175
|
-
constructor(observer = new NullAcpSessionObserver(), store = new MemoryAcpSessionStore(), nativeHistoryReader =
|
|
32346
|
+
constructor(observer = new NullAcpSessionObserver(), store = new MemoryAcpSessionStore(), nativeHistoryReader = acpNativeHistoryReader, sessionIdentity = "assigned", onSessionStatusChanged = () => void 0, contentExternalizer = new AcpContentExternalizer(new UnretainedExternalContentStore())) {
|
|
32176
32347
|
this.#observer = observer;
|
|
32177
32348
|
this.#store = store;
|
|
32178
32349
|
this.#nativeHistoryReader = nativeHistoryReader;
|
|
@@ -32702,6 +32873,14 @@ var AgentRuntimeManager = class {
|
|
|
32702
32873
|
}
|
|
32703
32874
|
this.#nativeOperations.add(key);
|
|
32704
32875
|
try {
|
|
32876
|
+
const historyAccess = this.#nativeHistoryReader.access(options2);
|
|
32877
|
+
if (historyAccess.kind === "direct") {
|
|
32878
|
+
const history = await historyAccess.read(nativeSessionId, () => null);
|
|
32879
|
+
if (history.status === "unavailable") {
|
|
32880
|
+
throw new AcpExecutionError(history.cause.message, {}, history.cause.code);
|
|
32881
|
+
}
|
|
32882
|
+
return nativeHistoryEventsV2(nativeSessionId, history, eventLimit, cursor);
|
|
32883
|
+
}
|
|
32705
32884
|
return await this.#queryProcesses.previewEventsV2(options2, nativeSessionId, eventLimit, cursor);
|
|
32706
32885
|
} finally {
|
|
32707
32886
|
this.#nativeOperations.delete(key);
|
|
@@ -32711,15 +32890,9 @@ var AgentRuntimeManager = class {
|
|
|
32711
32890
|
return await this.#executionProcesses.use(options2.sessionId, async () => {
|
|
32712
32891
|
const runtime = await this.ensureSession(options2);
|
|
32713
32892
|
const stored = this.#store.read(options2.sessionId);
|
|
32714
|
-
|
|
32715
|
-
|
|
32716
|
-
|
|
32717
|
-
stored.session.nativeSessionId,
|
|
32718
|
-
runtime.nativeHistoryTurn
|
|
32719
|
-
);
|
|
32720
|
-
if (history !== null) {
|
|
32721
|
-
return history;
|
|
32722
|
-
}
|
|
32893
|
+
const historyAccess = this.#nativeHistoryReader.access(options2);
|
|
32894
|
+
if (stored instanceof FoundAcpStoredSession && historyAccess.kind === "direct") {
|
|
32895
|
+
return await historyAccess.read(stored.session.nativeSessionId, runtime.nativeHistoryTurn);
|
|
32723
32896
|
}
|
|
32724
32897
|
return await runtime.loadHistory(options2.signal);
|
|
32725
32898
|
});
|
|
@@ -33669,6 +33842,11 @@ var threadLifecycleResponseSchema = external_exports.object({
|
|
|
33669
33842
|
serviceTier: boundedText(256).nullish(),
|
|
33670
33843
|
thread: external_exports.object({ id: boundedText(256), turns: threadTurnsSchema })
|
|
33671
33844
|
});
|
|
33845
|
+
var CODEX_HISTORY_TURN_PAGE_LIMIT = 20;
|
|
33846
|
+
var threadTurnsPageSchema = external_exports.object({
|
|
33847
|
+
data: external_exports.array(threadTurnSchema).max(CODEX_HISTORY_TURN_PAGE_LIMIT),
|
|
33848
|
+
nextCursor: boundedText(1024).nullish()
|
|
33849
|
+
});
|
|
33672
33850
|
var threadResumeResponseSchema = threadLifecycleResponseSchema;
|
|
33673
33851
|
var threadForkResponseSchema = threadLifecycleResponseSchema;
|
|
33674
33852
|
var threadTitleSchema = external_exports.string().transform((value) => value.slice(0, 500));
|
|
@@ -34743,14 +34921,14 @@ var CodexAcpAgent = class {
|
|
|
34743
34921
|
const resumed = threadResumeResponseSchema.parse(
|
|
34744
34922
|
await this.#appServer.request(
|
|
34745
34923
|
"thread/resume",
|
|
34746
|
-
{ cwd: context.params.cwd, excludeTurns:
|
|
34924
|
+
{ cwd: context.params.cwd, excludeTurns: true, threadId: context.params.sessionId },
|
|
34747
34925
|
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
|
|
34748
34926
|
)
|
|
34749
34927
|
);
|
|
34750
34928
|
this.#nativeSessionId = resumed.thread.id;
|
|
34751
34929
|
this.#settings.selectRestoredThread(resumed);
|
|
34752
34930
|
await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
|
|
34753
|
-
await this.#
|
|
34931
|
+
await this.#replaySavedHistory(context.signal);
|
|
34754
34932
|
await this.#emitAvailableCommands();
|
|
34755
34933
|
return { configOptions: this.#settings.configOptions() };
|
|
34756
34934
|
}).onRequest(methods4.agent.session.fork, async (context) => {
|
|
@@ -34845,14 +35023,46 @@ var CodexAcpAgent = class {
|
|
|
34845
35023
|
}
|
|
34846
35024
|
return this.#closePromise;
|
|
34847
35025
|
};
|
|
34848
|
-
|
|
34849
|
-
|
|
34850
|
-
|
|
34851
|
-
|
|
34852
|
-
|
|
34853
|
-
|
|
34854
|
-
for (
|
|
35026
|
+
// ACP load requires chronological replay. Resume only restores execution;
|
|
35027
|
+
// native pages supply history without a single full-transcript response.
|
|
35028
|
+
#replaySavedHistory = async (signal) => {
|
|
35029
|
+
const deadline = AbortSignal.any([signal, AbortSignal.timeout(6e4)]);
|
|
35030
|
+
const seenCursors = /* @__PURE__ */ new Set();
|
|
35031
|
+
let cursor = null;
|
|
35032
|
+
for (; ; ) {
|
|
35033
|
+
deadline.throwIfAborted();
|
|
35034
|
+
const page = threadTurnsPageSchema.parse(
|
|
35035
|
+
await this.#appServer.request(
|
|
35036
|
+
"thread/turns/list",
|
|
35037
|
+
{
|
|
35038
|
+
threadId: this.#nativeSessionId,
|
|
35039
|
+
limit: CODEX_HISTORY_TURN_PAGE_LIMIT,
|
|
35040
|
+
sortDirection: "asc",
|
|
35041
|
+
itemsView: "full",
|
|
35042
|
+
...cursor === null ? {} : { cursor }
|
|
35043
|
+
},
|
|
35044
|
+
deadline
|
|
35045
|
+
)
|
|
35046
|
+
);
|
|
35047
|
+
await this.#replayHistory(page.data, deadline);
|
|
35048
|
+
if (page.nextCursor == null) {
|
|
35049
|
+
return;
|
|
35050
|
+
}
|
|
35051
|
+
if (page.data.length === 0 || seenCursors.has(page.nextCursor)) {
|
|
35052
|
+
throw new AcpExecutionError(
|
|
35053
|
+
"Codex repeated a history page cursor",
|
|
35054
|
+
{},
|
|
35055
|
+
"invalid_native_session_response"
|
|
35056
|
+
);
|
|
35057
|
+
}
|
|
35058
|
+
seenCursors.add(page.nextCursor);
|
|
35059
|
+
cursor = page.nextCursor;
|
|
35060
|
+
}
|
|
35061
|
+
};
|
|
35062
|
+
#replayHistory = async (turns, signal) => {
|
|
35063
|
+
for (const turn of turns) {
|
|
34855
35064
|
for (const rawItem of turn.items) {
|
|
35065
|
+
signal.throwIfAborted();
|
|
34856
35066
|
const item = decodeThreadItem(rawItem);
|
|
34857
35067
|
if (item === null) {
|
|
34858
35068
|
continue;
|
|
@@ -35815,7 +36025,7 @@ var OhMyPiAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
35815
36025
|
import { join as join11 } from "node:path";
|
|
35816
36026
|
|
|
35817
36027
|
// src/agent-installation/managed-agent-archive.ts
|
|
35818
|
-
import { createHash as
|
|
36028
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
35819
36029
|
import { createReadStream } from "node:fs";
|
|
35820
36030
|
import { chmod, copyFile, mkdir as mkdir4, mkdtemp as mkdtemp2, open as open4, realpath as realpath7, rename as rename3, rm as rm3, stat as stat6, writeFile as writeFile3 } from "node:fs/promises";
|
|
35821
36031
|
import { delimiter as delimiter2, dirname as dirname3, isAbsolute as isAbsolute7, join as join10, relative as relative3, sep as sep3 } from "node:path";
|
|
@@ -35928,7 +36138,7 @@ function isContainedPath3(root, candidate) {
|
|
|
35928
36138
|
}
|
|
35929
36139
|
async function hashFile(path2, signal) {
|
|
35930
36140
|
signal.throwIfAborted();
|
|
35931
|
-
const digest =
|
|
36141
|
+
const digest = createHash3("sha256");
|
|
35932
36142
|
const stream = createReadStream(path2, { signal });
|
|
35933
36143
|
try {
|
|
35934
36144
|
for await (const chunk of stream) {
|
|
@@ -37126,7 +37336,7 @@ async function discoverLocalAgentInventory(options) {
|
|
|
37126
37336
|
}
|
|
37127
37337
|
|
|
37128
37338
|
// src/storage/runtime-installation-store.ts
|
|
37129
|
-
import { createHash as
|
|
37339
|
+
import { createHash as createHash4, randomUUID as randomUUID3 } from "node:crypto";
|
|
37130
37340
|
import { mkdir as mkdir5, open as open5, readdir as readdir3, rename as rename4, unlink, writeFile as writeFile4 } from "node:fs/promises";
|
|
37131
37341
|
import { dirname as dirname4, join as join16, resolve as resolve4 } from "node:path";
|
|
37132
37342
|
var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
|
|
@@ -37262,7 +37472,7 @@ function installationId() {
|
|
|
37262
37472
|
return `min_${randomUUID3().replaceAll("-", "")}`;
|
|
37263
37473
|
}
|
|
37264
37474
|
function channelIndexFileName(channelId) {
|
|
37265
|
-
return `mci_${
|
|
37475
|
+
return `mci_${createHash4("sha256").update(channelId).digest("hex")}.json`;
|
|
37266
37476
|
}
|
|
37267
37477
|
function decodeInstallationPointer(value) {
|
|
37268
37478
|
if (!isRecord9(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
|
|
@@ -37961,7 +38171,7 @@ function isRuntimeRelayRevocation(closeCode, closeReason) {
|
|
|
37961
38171
|
}
|
|
37962
38172
|
|
|
37963
38173
|
// src/run-daemon.ts
|
|
37964
|
-
import { createHash as
|
|
38174
|
+
import { createHash as createHash8, randomUUID as randomUUID9 } from "node:crypto";
|
|
37965
38175
|
import { join as join19 } from "node:path";
|
|
37966
38176
|
import { styleText } from "node:util";
|
|
37967
38177
|
|
|
@@ -38747,7 +38957,7 @@ import { WebSocket as WebSocket2 } from "undici";
|
|
|
38747
38957
|
import { WebSocket } from "undici";
|
|
38748
38958
|
|
|
38749
38959
|
// src/prompt-artifact-resolver.ts
|
|
38750
|
-
import { createHash as
|
|
38960
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
38751
38961
|
import { fetch as fetch4 } from "undici";
|
|
38752
38962
|
var ARTIFACT_SCHEME = "mobius-artifact:";
|
|
38753
38963
|
var ARTIFACT_DOWNLOAD_TIMEOUT_MILLISECONDS = 2e4;
|
|
@@ -38885,7 +39095,7 @@ async function download(config2, command, reference, signal) {
|
|
|
38885
39095
|
);
|
|
38886
39096
|
}
|
|
38887
39097
|
const bytes = await responseBytes(response, reference.byteLength, requestSignal);
|
|
38888
|
-
if (
|
|
39098
|
+
if (createHash5("sha256").update(bytes).digest("hex") !== reference.sha256) {
|
|
38889
39099
|
throw new PromptArtifactError(
|
|
38890
39100
|
"artifact_integrity_failed",
|
|
38891
39101
|
"The prompt artifact failed integrity validation"
|
|
@@ -39906,6 +40116,14 @@ var historyItemSchema = external_exports.discriminatedUnion("type", [
|
|
|
39906
40116
|
dynamicToolCallSchema,
|
|
39907
40117
|
planSchema
|
|
39908
40118
|
]);
|
|
40119
|
+
var CodexHistoryResponseError = class extends Error {
|
|
40120
|
+
code;
|
|
40121
|
+
constructor(response) {
|
|
40122
|
+
super(response.message);
|
|
40123
|
+
this.code = response.code;
|
|
40124
|
+
this.name = "CodexHistoryResponseError";
|
|
40125
|
+
}
|
|
40126
|
+
};
|
|
39909
40127
|
function bounded(value, maximum) {
|
|
39910
40128
|
return value.slice(0, maximum);
|
|
39911
40129
|
}
|
|
@@ -39945,7 +40163,7 @@ function formatted(value) {
|
|
|
39945
40163
|
}
|
|
39946
40164
|
return JSON.stringify(value) ?? "";
|
|
39947
40165
|
}
|
|
39948
|
-
function
|
|
40166
|
+
function toolStatus2(status) {
|
|
39949
40167
|
return status === "inProgress" ? "running" : status === "completed" ? "completed" : "failed";
|
|
39950
40168
|
}
|
|
39951
40169
|
function diffDisplayContent(path2, newText) {
|
|
@@ -40152,7 +40370,7 @@ function decodeHistory(thread, value, options) {
|
|
|
40152
40370
|
formatted_output: historyItem.aggregatedOutput ?? "",
|
|
40153
40371
|
...historyItem.exitCode == null ? {} : { exit_code: historyItem.exitCode }
|
|
40154
40372
|
}),
|
|
40155
|
-
status:
|
|
40373
|
+
status: toolStatus2(historyItem.status),
|
|
40156
40374
|
title: historyItem.command,
|
|
40157
40375
|
toolKind: action
|
|
40158
40376
|
})
|
|
@@ -40174,7 +40392,7 @@ function decodeHistory(thread, value, options) {
|
|
|
40174
40392
|
locations: paths,
|
|
40175
40393
|
name: "",
|
|
40176
40394
|
output: "",
|
|
40177
|
-
status:
|
|
40395
|
+
status: toolStatus2(historyItem.status),
|
|
40178
40396
|
title: paths.join(", "),
|
|
40179
40397
|
toolKind: "edit"
|
|
40180
40398
|
})
|
|
@@ -40192,7 +40410,7 @@ function decodeHistory(thread, value, options) {
|
|
|
40192
40410
|
locations: [],
|
|
40193
40411
|
name: historyItem.tool,
|
|
40194
40412
|
output: formatted(historyItem.error ?? historyItem.result),
|
|
40195
|
-
status:
|
|
40413
|
+
status: toolStatus2(historyItem.status),
|
|
40196
40414
|
title: `${historyItem.server}/${historyItem.tool}`,
|
|
40197
40415
|
toolKind: "other"
|
|
40198
40416
|
})
|
|
@@ -40210,7 +40428,7 @@ function decodeHistory(thread, value, options) {
|
|
|
40210
40428
|
locations: [],
|
|
40211
40429
|
name: historyItem.tool,
|
|
40212
40430
|
output: formatted(historyItem.contentItems),
|
|
40213
|
-
status:
|
|
40431
|
+
status: toolStatus2(historyItem.status),
|
|
40214
40432
|
title: historyItem.namespace == null ? historyItem.tool : `${historyItem.namespace}/${historyItem.tool}`,
|
|
40215
40433
|
toolKind: "other"
|
|
40216
40434
|
})
|
|
@@ -40376,7 +40594,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
40376
40594
|
fail(
|
|
40377
40595
|
new AcpExecutionError(
|
|
40378
40596
|
"Saved Codex history could not be read.",
|
|
40379
|
-
{ cause: message.error },
|
|
40597
|
+
{ cause: new CodexHistoryResponseError(message.error) },
|
|
40380
40598
|
"native_history_unavailable"
|
|
40381
40599
|
)
|
|
40382
40600
|
);
|
|
@@ -40884,7 +41102,7 @@ var NativeSessionService = class {
|
|
|
40884
41102
|
};
|
|
40885
41103
|
|
|
40886
41104
|
// src/relay-connection/daemon-operation-state.ts
|
|
40887
|
-
import { createHash as
|
|
41105
|
+
import { createHash as createHash6, randomUUID as randomUUID6 } from "node:crypto";
|
|
40888
41106
|
var MAX_TERMINAL_RECEIPTS = 1024;
|
|
40889
41107
|
function isTerminal(state) {
|
|
40890
41108
|
return state === "succeeded" || state === "failed" || state === "cancelled";
|
|
@@ -40893,7 +41111,7 @@ var DaemonOperationState = class {
|
|
|
40893
41111
|
#executions = /* @__PURE__ */ new Map();
|
|
40894
41112
|
#terminalCount = 0;
|
|
40895
41113
|
claimExecution = (commandId, sessionId, commandJson) => {
|
|
40896
|
-
const commandHash =
|
|
41114
|
+
const commandHash = createHash6("sha256").update(commandJson).digest("hex");
|
|
40897
41115
|
const existing = this.#executions.get(commandId);
|
|
40898
41116
|
if (existing !== void 0) {
|
|
40899
41117
|
if (existing.sessionId !== sessionId || existing.commandHash !== commandHash) {
|
|
@@ -41115,7 +41333,7 @@ import { WebSocket as WebSocket5 } from "undici";
|
|
|
41115
41333
|
import { WebSocket as WebSocket3 } from "undici";
|
|
41116
41334
|
|
|
41117
41335
|
// src/agent-catalog/discover-agent-settings.ts
|
|
41118
|
-
import { createHash as
|
|
41336
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
41119
41337
|
|
|
41120
41338
|
// src/agent-catalog/agent-settings-base.ts
|
|
41121
41339
|
var AgentSettingsConfigurationError = class extends Error {
|
|
@@ -41579,7 +41797,7 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
|
|
|
41579
41797
|
unsupportedModelIds: modelEffort.unsupportedModelIds,
|
|
41580
41798
|
valuesByModel: {}
|
|
41581
41799
|
};
|
|
41582
|
-
return
|
|
41800
|
+
return createHash7("sha256").update(
|
|
41583
41801
|
JSON.stringify({
|
|
41584
41802
|
adapterVersion: agent.kind === "acp-adapter-process" ? agent.adapterVersion : agent.agentVersion,
|
|
41585
41803
|
agentId: agent.id,
|
|
@@ -41891,7 +42109,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
41891
42109
|
},
|
|
41892
42110
|
queuedPromptRequests: recovery.queuedPromptRequests
|
|
41893
42111
|
},
|
|
41894
|
-
kind:
|
|
42112
|
+
kind: SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND,
|
|
41895
42113
|
requestId: command.requestId,
|
|
41896
42114
|
sessionId: command.sessionId
|
|
41897
42115
|
});
|
|
@@ -41920,6 +42138,81 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
41920
42138
|
}
|
|
41921
42139
|
}
|
|
41922
42140
|
}
|
|
42141
|
+
async function executeSessionPreviewHistoryPageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventLogV2, signal) {
|
|
42142
|
+
try {
|
|
42143
|
+
const resolved = await resolveSessionDirectories(
|
|
42144
|
+
directories,
|
|
42145
|
+
config2.bindingId,
|
|
42146
|
+
command.directoryId,
|
|
42147
|
+
command.additionalDirectoryIds,
|
|
42148
|
+
signal
|
|
42149
|
+
);
|
|
42150
|
+
const replay = await sessions.previewNativeSessionEventsV2(
|
|
42151
|
+
{
|
|
42152
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
42153
|
+
agent: config2.catalog.find(command.agentId),
|
|
42154
|
+
cwd: resolved.cwd,
|
|
42155
|
+
sessionId: command.sessionId,
|
|
42156
|
+
signal
|
|
42157
|
+
},
|
|
42158
|
+
command.sessionId,
|
|
42159
|
+
command.eventLimit,
|
|
42160
|
+
command.cursor
|
|
42161
|
+
);
|
|
42162
|
+
signal.throwIfAborted();
|
|
42163
|
+
const events = replay.events.map(
|
|
42164
|
+
(event, index2) => eventLogV2.event(
|
|
42165
|
+
command.sessionId,
|
|
42166
|
+
replay.sessionGenerationId,
|
|
42167
|
+
replay.startPosition + index2,
|
|
42168
|
+
event,
|
|
42169
|
+
"1970-01-01T00:00:00.000Z"
|
|
42170
|
+
)
|
|
42171
|
+
);
|
|
42172
|
+
const tailCursor = events.at(-1)?.eventId ?? "";
|
|
42173
|
+
audit.record({
|
|
42174
|
+
commandId: command.requestId,
|
|
42175
|
+
event: "session_event_log_v2_loaded",
|
|
42176
|
+
sessionId: command.sessionId
|
|
42177
|
+
});
|
|
42178
|
+
send(socket, {
|
|
42179
|
+
events: {
|
|
42180
|
+
events: {
|
|
42181
|
+
events,
|
|
42182
|
+
nextCursor: replay.nextCursor,
|
|
42183
|
+
sessionGenerationId: replay.sessionGenerationId,
|
|
42184
|
+
tailCursor,
|
|
42185
|
+
truncated: replay.truncated,
|
|
42186
|
+
version: 2
|
|
42187
|
+
},
|
|
42188
|
+
queuedPromptRequests: []
|
|
42189
|
+
},
|
|
42190
|
+
kind: SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND,
|
|
42191
|
+
requestId: command.requestId,
|
|
42192
|
+
sessionId: command.sessionId
|
|
42193
|
+
});
|
|
42194
|
+
} catch (error62) {
|
|
42195
|
+
if (!signal.aborted) {
|
|
42196
|
+
diagnostics.daemonDiagnostic(
|
|
42197
|
+
"session_history_v2_load_failed",
|
|
42198
|
+
command.requestId,
|
|
42199
|
+
{
|
|
42200
|
+
agentId: command.agentId,
|
|
42201
|
+
code: operationErrorCode(error62),
|
|
42202
|
+
sessionId: command.sessionId
|
|
42203
|
+
},
|
|
42204
|
+
error62
|
|
42205
|
+
);
|
|
42206
|
+
audit.record({
|
|
42207
|
+
commandId: command.requestId,
|
|
42208
|
+
details: { agentId: command.agentId, code: operationErrorCode(error62) },
|
|
42209
|
+
event: "session_history_v2_load_failed",
|
|
42210
|
+
sessionId: command.sessionId
|
|
42211
|
+
});
|
|
42212
|
+
reportOperationFailure(socket, command.requestId, command.sessionId, error62);
|
|
42213
|
+
}
|
|
42214
|
+
}
|
|
42215
|
+
}
|
|
41923
42216
|
|
|
41924
42217
|
// src/acp/session-config/apply-session-configuration.ts
|
|
41925
42218
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
@@ -42669,6 +42962,20 @@ function createDaemonCommandHandler({
|
|
|
42669
42962
|
);
|
|
42670
42963
|
return;
|
|
42671
42964
|
}
|
|
42965
|
+
if (kind === SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND) {
|
|
42966
|
+
void executeSessionPreviewHistoryPageLoad(
|
|
42967
|
+
socket,
|
|
42968
|
+
message,
|
|
42969
|
+
config2,
|
|
42970
|
+
directories,
|
|
42971
|
+
audit,
|
|
42972
|
+
diagnostics,
|
|
42973
|
+
sessions,
|
|
42974
|
+
eventLogV2,
|
|
42975
|
+
signal
|
|
42976
|
+
);
|
|
42977
|
+
return;
|
|
42978
|
+
}
|
|
42672
42979
|
if (kind === NATIVE_SESSION_CANCEL_KIND) {
|
|
42673
42980
|
nativeRequestHandler.cancel(message);
|
|
42674
42981
|
return;
|
|
@@ -43620,7 +43927,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
43620
43927
|
publishCatalog: async (installationSignal) => await publishAgentCatalog(config2, installationSignal),
|
|
43621
43928
|
stateDirectory
|
|
43622
43929
|
});
|
|
43623
|
-
const channelHash =
|
|
43930
|
+
const channelHash = createHash8("sha256").update(config2.channelId).digest("hex");
|
|
43624
43931
|
const sessionDatabase = openAcpSessionDatabase(join19(stateDirectory, "sessions", `${channelHash}.sqlite`));
|
|
43625
43932
|
let eventsV2;
|
|
43626
43933
|
try {
|
|
@@ -43646,13 +43953,16 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
43646
43953
|
}, eventLogV2.record),
|
|
43647
43954
|
sessionStore,
|
|
43648
43955
|
{
|
|
43649
|
-
|
|
43650
|
-
|
|
43651
|
-
|
|
43652
|
-
|
|
43653
|
-
|
|
43654
|
-
|
|
43655
|
-
|
|
43956
|
+
access: (options2) => options2.agent.id === "codex" ? {
|
|
43957
|
+
kind: "direct",
|
|
43958
|
+
read: async (nativeSessionId, nativeTurn) => (await readCodexFullHistory(
|
|
43959
|
+
options2.agent,
|
|
43960
|
+
options2.cwd,
|
|
43961
|
+
nativeSessionId,
|
|
43962
|
+
options2.signal,
|
|
43963
|
+
nativeTurn
|
|
43964
|
+
)).history
|
|
43965
|
+
} : { kind: "acp" }
|
|
43656
43966
|
},
|
|
43657
43967
|
"native",
|
|
43658
43968
|
publisher.publishStatus,
|