@moxt-ai/mobius 0.0.187 → 0.0.188

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.
Files changed (36) hide show
  1. package/dist/acp/agent-runtime-manager.d.ts +2 -2
  2. package/dist/acp/agent-runtime-manager.d.ts.map +1 -1
  3. package/dist/acp/agent-runtime-manager.js +17 -8
  4. package/dist/acp/agent-runtime-manager.js.map +1 -1
  5. package/dist/acp/session-contracts.d.ts +10 -3
  6. package/dist/acp/session-contracts.d.ts.map +1 -1
  7. package/dist/acp/session-contracts.js +3 -0
  8. package/dist/acp/session-contracts.js.map +1 -1
  9. package/dist/acp/session-event-store-v2.d.ts +1 -0
  10. package/dist/acp/session-event-store-v2.d.ts.map +1 -1
  11. package/dist/acp/session-event-store-v2.js +3 -0
  12. package/dist/acp/session-event-store-v2.js.map +1 -1
  13. package/dist/cli.js +316 -43
  14. package/dist/cli.js.map +4 -4
  15. package/dist/daemon-command-handler.d.ts.map +1 -1
  16. package/dist/daemon-command-handler.js +6 -2
  17. package/dist/daemon-command-handler.js.map +1 -1
  18. package/dist/daemon-history-commands.d.ts +2 -1
  19. package/dist/daemon-history-commands.d.ts.map +1 -1
  20. package/dist/daemon-history-commands.js +54 -1
  21. package/dist/daemon-history-commands.js.map +1 -1
  22. package/dist/index.js +317 -44
  23. package/dist/index.js.map +4 -4
  24. package/dist/native-sessions/codex-history.d.ts.map +1 -1
  25. package/dist/native-sessions/codex-history.js +9 -1
  26. package/dist/native-sessions/codex-history.js.map +1 -1
  27. package/dist/native-sessions/native-history-events-v2.d.ts +8 -0
  28. package/dist/native-sessions/native-history-events-v2.d.ts.map +1 -0
  29. package/dist/native-sessions/native-history-events-v2.js +147 -0
  30. package/dist/native-sessions/native-history-events-v2.js.map +1 -0
  31. package/dist/run-daemon.d.ts.map +1 -1
  32. package/dist/run-daemon.js +6 -3
  33. package/dist/run-daemon.js.map +1 -1
  34. package/dist/runtime.js +315 -42
  35. package/dist/runtime.js.map +4 -4
  36. 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 sessionLiveHistoryV2PageLoadSchema = external_exports.object({
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
- }).readonly();
21450
- var sessionLiveHistoryV2PageLoadedSchema = external_exports.object({
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
- }).readonly();
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, toolKind, content = [], detail = captureActivityDetail(content, input2, output2)) {
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 = 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 = null, sessionIdentity = "assigned", onSessionStatusChanged = () => void 0, contentExternalizer = new AcpContentExternalizer(new UnretainedExternalContentStore())) {
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
- if (stored instanceof FoundAcpStoredSession && this.#nativeHistoryReader !== null) {
32715
- const history = await this.#nativeHistoryReader.read(
32716
- options2,
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
  });
@@ -35815,7 +35988,7 @@ var OhMyPiAgentSpecification = class extends DirectAcpAgentDefinition {
35815
35988
  import { join as join11 } from "node:path";
35816
35989
 
35817
35990
  // src/agent-installation/managed-agent-archive.ts
35818
- import { createHash as createHash2 } from "node:crypto";
35991
+ import { createHash as createHash3 } from "node:crypto";
35819
35992
  import { createReadStream } from "node:fs";
35820
35993
  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
35994
  import { delimiter as delimiter2, dirname as dirname3, isAbsolute as isAbsolute7, join as join10, relative as relative3, sep as sep3 } from "node:path";
@@ -35928,7 +36101,7 @@ function isContainedPath3(root, candidate) {
35928
36101
  }
35929
36102
  async function hashFile(path2, signal) {
35930
36103
  signal.throwIfAborted();
35931
- const digest = createHash2("sha256");
36104
+ const digest = createHash3("sha256");
35932
36105
  const stream = createReadStream(path2, { signal });
35933
36106
  try {
35934
36107
  for await (const chunk of stream) {
@@ -37126,7 +37299,7 @@ async function discoverLocalAgentInventory(options) {
37126
37299
  }
37127
37300
 
37128
37301
  // src/storage/runtime-installation-store.ts
37129
- import { createHash as createHash3, randomUUID as randomUUID3 } from "node:crypto";
37302
+ import { createHash as createHash4, randomUUID as randomUUID3 } from "node:crypto";
37130
37303
  import { mkdir as mkdir5, open as open5, readdir as readdir3, rename as rename4, unlink, writeFile as writeFile4 } from "node:fs/promises";
37131
37304
  import { dirname as dirname4, join as join16, resolve as resolve4 } from "node:path";
37132
37305
  var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
@@ -37262,7 +37435,7 @@ function installationId() {
37262
37435
  return `min_${randomUUID3().replaceAll("-", "")}`;
37263
37436
  }
37264
37437
  function channelIndexFileName(channelId) {
37265
- return `mci_${createHash3("sha256").update(channelId).digest("hex")}.json`;
37438
+ return `mci_${createHash4("sha256").update(channelId).digest("hex")}.json`;
37266
37439
  }
37267
37440
  function decodeInstallationPointer(value) {
37268
37441
  if (!isRecord9(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
@@ -37961,7 +38134,7 @@ function isRuntimeRelayRevocation(closeCode, closeReason) {
37961
38134
  }
37962
38135
 
37963
38136
  // src/run-daemon.ts
37964
- import { createHash as createHash7, randomUUID as randomUUID9 } from "node:crypto";
38137
+ import { createHash as createHash8, randomUUID as randomUUID9 } from "node:crypto";
37965
38138
  import { join as join19 } from "node:path";
37966
38139
  import { styleText } from "node:util";
37967
38140
 
@@ -38747,7 +38920,7 @@ import { WebSocket as WebSocket2 } from "undici";
38747
38920
  import { WebSocket } from "undici";
38748
38921
 
38749
38922
  // src/prompt-artifact-resolver.ts
38750
- import { createHash as createHash4 } from "node:crypto";
38923
+ import { createHash as createHash5 } from "node:crypto";
38751
38924
  import { fetch as fetch4 } from "undici";
38752
38925
  var ARTIFACT_SCHEME = "mobius-artifact:";
38753
38926
  var ARTIFACT_DOWNLOAD_TIMEOUT_MILLISECONDS = 2e4;
@@ -38885,7 +39058,7 @@ async function download(config2, command, reference, signal) {
38885
39058
  );
38886
39059
  }
38887
39060
  const bytes = await responseBytes(response, reference.byteLength, requestSignal);
38888
- if (createHash4("sha256").update(bytes).digest("hex") !== reference.sha256) {
39061
+ if (createHash5("sha256").update(bytes).digest("hex") !== reference.sha256) {
38889
39062
  throw new PromptArtifactError(
38890
39063
  "artifact_integrity_failed",
38891
39064
  "The prompt artifact failed integrity validation"
@@ -39906,6 +40079,14 @@ var historyItemSchema = external_exports.discriminatedUnion("type", [
39906
40079
  dynamicToolCallSchema,
39907
40080
  planSchema
39908
40081
  ]);
40082
+ var CodexHistoryResponseError = class extends Error {
40083
+ code;
40084
+ constructor(response) {
40085
+ super(response.message);
40086
+ this.code = response.code;
40087
+ this.name = "CodexHistoryResponseError";
40088
+ }
40089
+ };
39909
40090
  function bounded(value, maximum) {
39910
40091
  return value.slice(0, maximum);
39911
40092
  }
@@ -39945,7 +40126,7 @@ function formatted(value) {
39945
40126
  }
39946
40127
  return JSON.stringify(value) ?? "";
39947
40128
  }
39948
- function toolStatus(status) {
40129
+ function toolStatus2(status) {
39949
40130
  return status === "inProgress" ? "running" : status === "completed" ? "completed" : "failed";
39950
40131
  }
39951
40132
  function diffDisplayContent(path2, newText) {
@@ -40152,7 +40333,7 @@ function decodeHistory(thread, value, options) {
40152
40333
  formatted_output: historyItem.aggregatedOutput ?? "",
40153
40334
  ...historyItem.exitCode == null ? {} : { exit_code: historyItem.exitCode }
40154
40335
  }),
40155
- status: toolStatus(historyItem.status),
40336
+ status: toolStatus2(historyItem.status),
40156
40337
  title: historyItem.command,
40157
40338
  toolKind: action
40158
40339
  })
@@ -40174,7 +40355,7 @@ function decodeHistory(thread, value, options) {
40174
40355
  locations: paths,
40175
40356
  name: "",
40176
40357
  output: "",
40177
- status: toolStatus(historyItem.status),
40358
+ status: toolStatus2(historyItem.status),
40178
40359
  title: paths.join(", "),
40179
40360
  toolKind: "edit"
40180
40361
  })
@@ -40192,7 +40373,7 @@ function decodeHistory(thread, value, options) {
40192
40373
  locations: [],
40193
40374
  name: historyItem.tool,
40194
40375
  output: formatted(historyItem.error ?? historyItem.result),
40195
- status: toolStatus(historyItem.status),
40376
+ status: toolStatus2(historyItem.status),
40196
40377
  title: `${historyItem.server}/${historyItem.tool}`,
40197
40378
  toolKind: "other"
40198
40379
  })
@@ -40210,7 +40391,7 @@ function decodeHistory(thread, value, options) {
40210
40391
  locations: [],
40211
40392
  name: historyItem.tool,
40212
40393
  output: formatted(historyItem.contentItems),
40213
- status: toolStatus(historyItem.status),
40394
+ status: toolStatus2(historyItem.status),
40214
40395
  title: historyItem.namespace == null ? historyItem.tool : `${historyItem.namespace}/${historyItem.tool}`,
40215
40396
  toolKind: "other"
40216
40397
  })
@@ -40376,7 +40557,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
40376
40557
  fail(
40377
40558
  new AcpExecutionError(
40378
40559
  "Saved Codex history could not be read.",
40379
- { cause: message.error },
40560
+ { cause: new CodexHistoryResponseError(message.error) },
40380
40561
  "native_history_unavailable"
40381
40562
  )
40382
40563
  );
@@ -40884,7 +41065,7 @@ var NativeSessionService = class {
40884
41065
  };
40885
41066
 
40886
41067
  // src/relay-connection/daemon-operation-state.ts
40887
- import { createHash as createHash5, randomUUID as randomUUID6 } from "node:crypto";
41068
+ import { createHash as createHash6, randomUUID as randomUUID6 } from "node:crypto";
40888
41069
  var MAX_TERMINAL_RECEIPTS = 1024;
40889
41070
  function isTerminal(state) {
40890
41071
  return state === "succeeded" || state === "failed" || state === "cancelled";
@@ -40893,7 +41074,7 @@ var DaemonOperationState = class {
40893
41074
  #executions = /* @__PURE__ */ new Map();
40894
41075
  #terminalCount = 0;
40895
41076
  claimExecution = (commandId, sessionId, commandJson) => {
40896
- const commandHash = createHash5("sha256").update(commandJson).digest("hex");
41077
+ const commandHash = createHash6("sha256").update(commandJson).digest("hex");
40897
41078
  const existing = this.#executions.get(commandId);
40898
41079
  if (existing !== void 0) {
40899
41080
  if (existing.sessionId !== sessionId || existing.commandHash !== commandHash) {
@@ -41115,7 +41296,7 @@ import { WebSocket as WebSocket5 } from "undici";
41115
41296
  import { WebSocket as WebSocket3 } from "undici";
41116
41297
 
41117
41298
  // src/agent-catalog/discover-agent-settings.ts
41118
- import { createHash as createHash6 } from "node:crypto";
41299
+ import { createHash as createHash7 } from "node:crypto";
41119
41300
 
41120
41301
  // src/agent-catalog/agent-settings-base.ts
41121
41302
  var AgentSettingsConfigurationError = class extends Error {
@@ -41579,7 +41760,7 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
41579
41760
  unsupportedModelIds: modelEffort.unsupportedModelIds,
41580
41761
  valuesByModel: {}
41581
41762
  };
41582
- return createHash6("sha256").update(
41763
+ return createHash7("sha256").update(
41583
41764
  JSON.stringify({
41584
41765
  adapterVersion: agent.kind === "acp-adapter-process" ? agent.adapterVersion : agent.agentVersion,
41585
41766
  agentId: agent.id,
@@ -41891,7 +42072,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
41891
42072
  },
41892
42073
  queuedPromptRequests: recovery.queuedPromptRequests
41893
42074
  },
41894
- kind: "session.live-history.v2.page.loaded",
42075
+ kind: SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND,
41895
42076
  requestId: command.requestId,
41896
42077
  sessionId: command.sessionId
41897
42078
  });
@@ -41920,6 +42101,81 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
41920
42101
  }
41921
42102
  }
41922
42103
  }
42104
+ async function executeSessionPreviewHistoryPageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventLogV2, signal) {
42105
+ try {
42106
+ const resolved = await resolveSessionDirectories(
42107
+ directories,
42108
+ config2.bindingId,
42109
+ command.directoryId,
42110
+ command.additionalDirectoryIds,
42111
+ signal
42112
+ );
42113
+ const replay = await sessions.previewNativeSessionEventsV2(
42114
+ {
42115
+ additionalDirectories: resolved.additionalDirectories,
42116
+ agent: config2.catalog.find(command.agentId),
42117
+ cwd: resolved.cwd,
42118
+ sessionId: command.sessionId,
42119
+ signal
42120
+ },
42121
+ command.sessionId,
42122
+ command.eventLimit,
42123
+ command.cursor
42124
+ );
42125
+ signal.throwIfAborted();
42126
+ const events = replay.events.map(
42127
+ (event, index2) => eventLogV2.event(
42128
+ command.sessionId,
42129
+ replay.sessionGenerationId,
42130
+ replay.startPosition + index2,
42131
+ event,
42132
+ "1970-01-01T00:00:00.000Z"
42133
+ )
42134
+ );
42135
+ const tailCursor = events.at(-1)?.eventId ?? "";
42136
+ audit.record({
42137
+ commandId: command.requestId,
42138
+ event: "session_event_log_v2_loaded",
42139
+ sessionId: command.sessionId
42140
+ });
42141
+ send(socket, {
42142
+ events: {
42143
+ events: {
42144
+ events,
42145
+ nextCursor: replay.nextCursor,
42146
+ sessionGenerationId: replay.sessionGenerationId,
42147
+ tailCursor,
42148
+ truncated: replay.truncated,
42149
+ version: 2
42150
+ },
42151
+ queuedPromptRequests: []
42152
+ },
42153
+ kind: SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND,
42154
+ requestId: command.requestId,
42155
+ sessionId: command.sessionId
42156
+ });
42157
+ } catch (error62) {
42158
+ if (!signal.aborted) {
42159
+ diagnostics.daemonDiagnostic(
42160
+ "session_history_v2_load_failed",
42161
+ command.requestId,
42162
+ {
42163
+ agentId: command.agentId,
42164
+ code: operationErrorCode(error62),
42165
+ sessionId: command.sessionId
42166
+ },
42167
+ error62
42168
+ );
42169
+ audit.record({
42170
+ commandId: command.requestId,
42171
+ details: { agentId: command.agentId, code: operationErrorCode(error62) },
42172
+ event: "session_history_v2_load_failed",
42173
+ sessionId: command.sessionId
42174
+ });
42175
+ reportOperationFailure(socket, command.requestId, command.sessionId, error62);
42176
+ }
42177
+ }
42178
+ }
41923
42179
 
41924
42180
  // src/acp/session-config/apply-session-configuration.ts
41925
42181
  import { randomUUID as randomUUID7 } from "node:crypto";
@@ -42669,6 +42925,20 @@ function createDaemonCommandHandler({
42669
42925
  );
42670
42926
  return;
42671
42927
  }
42928
+ if (kind === SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND) {
42929
+ void executeSessionPreviewHistoryPageLoad(
42930
+ socket,
42931
+ message,
42932
+ config2,
42933
+ directories,
42934
+ audit,
42935
+ diagnostics,
42936
+ sessions,
42937
+ eventLogV2,
42938
+ signal
42939
+ );
42940
+ return;
42941
+ }
42672
42942
  if (kind === NATIVE_SESSION_CANCEL_KIND) {
42673
42943
  nativeRequestHandler.cancel(message);
42674
42944
  return;
@@ -43620,7 +43890,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
43620
43890
  publishCatalog: async (installationSignal) => await publishAgentCatalog(config2, installationSignal),
43621
43891
  stateDirectory
43622
43892
  });
43623
- const channelHash = createHash7("sha256").update(config2.channelId).digest("hex");
43893
+ const channelHash = createHash8("sha256").update(config2.channelId).digest("hex");
43624
43894
  const sessionDatabase = openAcpSessionDatabase(join19(stateDirectory, "sessions", `${channelHash}.sqlite`));
43625
43895
  let eventsV2;
43626
43896
  try {
@@ -43646,13 +43916,16 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
43646
43916
  }, eventLogV2.record),
43647
43917
  sessionStore,
43648
43918
  {
43649
- read: async (options2, nativeSessionId, nativeTurn) => options2.agent.id === "codex" ? (await readCodexFullHistory(
43650
- options2.agent,
43651
- options2.cwd,
43652
- nativeSessionId,
43653
- options2.signal,
43654
- nativeTurn
43655
- )).history : null
43919
+ access: (options2) => options2.agent.id === "codex" ? {
43920
+ kind: "direct",
43921
+ read: async (nativeSessionId, nativeTurn) => (await readCodexFullHistory(
43922
+ options2.agent,
43923
+ options2.cwd,
43924
+ nativeSessionId,
43925
+ options2.signal,
43926
+ nativeTurn
43927
+ )).history
43928
+ } : { kind: "acp" }
43656
43929
  },
43657
43930
  "native",
43658
43931
  publisher.publishStatus,