@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/cli.js CHANGED
@@ -3381,7 +3381,7 @@ var program = new Command();
3381
3381
  // package.json
3382
3382
  var package_default = {
3383
3383
  name: "@moxt-ai/mobius",
3384
- version: "0.0.187",
3384
+ version: "0.0.188",
3385
3385
  description: "Mobius CLI for pairing and running local AI agent services.",
3386
3386
  type: "module",
3387
3387
  bin: {
@@ -30086,24 +30086,28 @@ var decodeAcpSessionUpdateV2 = (value) => decode5(value, acpSessionUpdateV2Schem
30086
30086
  // ../protocol/src/session-live-history.ts
30087
30087
  var SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND = "session.live-history.v2.page.load";
30088
30088
  var SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND = "session.live-history.v2.page.loaded";
30089
+ var SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND = "session.preview-history.page.load";
30090
+ var SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND = "session.preview-history.page.loaded";
30089
30091
  var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
30090
- var sessionLiveHistoryV2PageLoadSchema = external_exports.object({
30092
+ var pageLoadFields = {
30091
30093
  additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
30092
30094
  agentId: identifierStringSchema,
30093
30095
  bindingId: identifierStringSchema,
30094
30096
  cursor: external_exports.string().min(1).max(512).nullable(),
30095
30097
  directoryId: directoryIdentifier,
30096
- kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND),
30097
30098
  eventLimit: external_exports.number().int().min(1).max(1e4),
30098
30099
  requestId: identifierStringSchema,
30099
30100
  sessionId: identifierStringSchema
30100
- }).readonly();
30101
- var sessionLiveHistoryV2PageLoadedSchema = external_exports.object({
30101
+ };
30102
+ var sessionLiveHistoryV2PageLoadSchema = external_exports.object({ ...pageLoadFields, kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND) }).readonly();
30103
+ var sessionPreviewHistoryPageLoadSchema = external_exports.object({ ...pageLoadFields, kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND) }).readonly();
30104
+ var pageLoadedFields = {
30102
30105
  events: nativeSessionEventsV2Schema,
30103
- kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND),
30104
30106
  requestId: identifierStringSchema,
30105
30107
  sessionId: identifierStringSchema
30106
- }).readonly();
30108
+ };
30109
+ var sessionLiveHistoryV2PageLoadedSchema = external_exports.object({ ...pageLoadedFields, kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND) }).readonly();
30110
+ var sessionPreviewHistoryPageLoadedSchema = external_exports.object({ ...pageLoadedFields, kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND) }).readonly();
30107
30111
  function decode6(schema, encoded) {
30108
30112
  try {
30109
30113
  const value = JSON.parse(encoded);
@@ -30114,8 +30118,12 @@ function decode6(schema, encoded) {
30114
30118
  }
30115
30119
  var decodeSessionLiveHistoryV2PageLoad = (encoded) => decode6(sessionLiveHistoryV2PageLoadSchema, encoded);
30116
30120
  var decodeSessionLiveHistoryV2PageLoaded = (encoded) => decode6(sessionLiveHistoryV2PageLoadedSchema, encoded);
30121
+ var decodeSessionPreviewHistoryPageLoad = (encoded) => decode6(sessionPreviewHistoryPageLoadSchema, encoded);
30122
+ var decodeSessionPreviewHistoryPageLoaded = (encoded) => decode6(sessionPreviewHistoryPageLoadedSchema, encoded);
30117
30123
  var encodeSessionLiveHistoryV2PageLoad = (value) => JSON.stringify(sessionLiveHistoryV2PageLoadSchema.parse(value));
30118
30124
  var encodeSessionLiveHistoryV2PageLoaded = (value) => JSON.stringify(sessionLiveHistoryV2PageLoadedSchema.parse(value));
30125
+ var encodeSessionPreviewHistoryPageLoad = (value) => JSON.stringify(sessionPreviewHistoryPageLoadSchema.parse(value));
30126
+ var encodeSessionPreviewHistoryPageLoaded = (value) => JSON.stringify(sessionPreviewHistoryPageLoadedSchema.parse(value));
30119
30127
 
30120
30128
  // ../protocol/src/daemon-transport.ts
30121
30129
  function defineMessageSignature(kind, encoder, decoder) {
@@ -30128,6 +30136,11 @@ function defineMessageSignature(kind, encoder, decoder) {
30128
30136
  };
30129
30137
  }
30130
30138
  var serviceToDaemonSignatures = {
30139
+ [SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND]: defineMessageSignature(
30140
+ SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND,
30141
+ encodeSessionPreviewHistoryPageLoad,
30142
+ decodeSessionPreviewHistoryPageLoad
30143
+ ),
30131
30144
  [AGENT_INSTALL_CANCEL_KIND]: defineMessageSignature(
30132
30145
  AGENT_INSTALL_CANCEL_KIND,
30133
30146
  encodeAgentInstallCancelCommand,
@@ -30232,6 +30245,11 @@ function decodeServiceToDaemonMessage(encoded) {
30232
30245
  return signature.decoder(encoded);
30233
30246
  }
30234
30247
  var daemonToServiceSignatures = {
30248
+ [SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND]: defineMessageSignature(
30249
+ SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND,
30250
+ encodeSessionPreviewHistoryPageLoaded,
30251
+ decodeSessionPreviewHistoryPageLoaded
30252
+ ),
30235
30253
  [SESSION_CONFIG_UPDATED_KIND]: defineMessageSignature(
30236
30254
  SESSION_CONFIG_UPDATED_KIND,
30237
30255
  encodeSessionConfigUpdatedEvent,
@@ -30411,7 +30429,7 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
30411
30429
 
30412
30430
  // src/daemon-manager.ts
30413
30431
  import { spawn as spawn6 } from "node:child_process";
30414
- import { createHash as createHash8, randomBytes } from "node:crypto";
30432
+ import { createHash as createHash9, randomBytes } from "node:crypto";
30415
30433
  import { readFile as readFile3, unlink as unlink2, writeFile as writeFile5 } from "node:fs/promises";
30416
30434
  import { createConnection, createServer } from "node:net";
30417
30435
  import { tmpdir } from "node:os";
@@ -31245,7 +31263,7 @@ var AuditStore = class {
31245
31263
  };
31246
31264
 
31247
31265
  // src/run-daemon.ts
31248
- import { createHash as createHash7, randomUUID as randomUUID9 } from "node:crypto";
31266
+ import { createHash as createHash8, randomUUID as randomUUID9 } from "node:crypto";
31249
31267
  import { join as join19 } from "node:path";
31250
31268
  import { styleText } from "node:util";
31251
31269
 
@@ -32140,7 +32158,7 @@ var AcpActivity = class _AcpActivity {
32140
32158
  toolKind;
32141
32159
  content;
32142
32160
  detail;
32143
- constructor(activityId, activityType, input2, locations, name2, output2, sequence, status, title2, toolKind, content = [], detail = captureActivityDetail(content, input2, output2)) {
32161
+ constructor(activityId, activityType, input2, locations, name2, output2, sequence, status, title2, toolKind2, content = [], detail = captureActivityDetail(content, input2, output2)) {
32144
32162
  this.activityId = activityId;
32145
32163
  this.activityType = activityType;
32146
32164
  this.input = input2;
@@ -32150,7 +32168,7 @@ var AcpActivity = class _AcpActivity {
32150
32168
  this.sequence = sequence;
32151
32169
  this.status = status;
32152
32170
  this.title = title2;
32153
- this.toolKind = toolKind;
32171
+ this.toolKind = toolKind2;
32154
32172
  this.content = content;
32155
32173
  this.detail = detail;
32156
32174
  }
@@ -32807,6 +32825,9 @@ function sessionConfigProtocolForAgent(_agentId) {
32807
32825
  }
32808
32826
 
32809
32827
  // src/acp/session-contracts.ts
32828
+ var acpNativeHistoryReader = {
32829
+ access: () => ({ kind: "acp" })
32830
+ };
32810
32831
  var NullAcpSessionObserver = class {
32811
32832
  onSessionEventV2 = (_sessionId, _event, _position) => Promise.resolve();
32812
32833
  onCommands = () => Promise.resolve();
@@ -38457,6 +38478,15 @@ function eventPage(sessionGenerationId, eventCount, eventLimit, cursor, read) {
38457
38478
  truncated: startPosition > 0
38458
38479
  };
38459
38480
  }
38481
+ function pageAcpSessionEventsV2(sessionGenerationId, events, eventLimit, cursor) {
38482
+ return eventPage(
38483
+ sessionGenerationId,
38484
+ events.length,
38485
+ eventLimit,
38486
+ cursor,
38487
+ (startPosition, endPosition) => events.slice(startPosition - 1, endPosition)
38488
+ );
38489
+ }
38460
38490
  var MemoryAcpSessionEventStoreV2 = class {
38461
38491
  #events = /* @__PURE__ */ new Map();
38462
38492
  #session = (sessionId) => {
@@ -40579,6 +40609,147 @@ function isNativeChatSessionId(agentId, sessionId) {
40579
40609
  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);
40580
40610
  }
40581
40611
 
40612
+ // src/native-sessions/native-history-events-v2.ts
40613
+ import { createHash as createHash4 } from "node:crypto";
40614
+ function contentBlock(content) {
40615
+ switch (content.type) {
40616
+ case "text":
40617
+ return { text: content.text, type: "text" };
40618
+ case "image":
40619
+ return {
40620
+ data: content.data,
40621
+ mimeType: content.mimeType,
40622
+ type: "image",
40623
+ ...content.uri.length === 0 ? {} : { uri: content.uri }
40624
+ };
40625
+ case "resource_link":
40626
+ return {
40627
+ name: content.name.length === 0 ? content.uri : content.name,
40628
+ type: "resource_link",
40629
+ uri: content.uri,
40630
+ ...content.mimeType.length === 0 ? {} : { mimeType: content.mimeType }
40631
+ };
40632
+ case "resource":
40633
+ return {
40634
+ resource: content.text.length > 0 ? {
40635
+ text: content.text,
40636
+ uri: content.uri,
40637
+ ...content.mimeType.length === 0 ? {} : { mimeType: content.mimeType }
40638
+ } : {
40639
+ blob: content.data,
40640
+ uri: content.uri,
40641
+ ...content.mimeType.length === 0 ? {} : { mimeType: content.mimeType }
40642
+ },
40643
+ type: "resource"
40644
+ };
40645
+ case "diff":
40646
+ case "terminal":
40647
+ case "video":
40648
+ return null;
40649
+ default: {
40650
+ const unhandled = content.type;
40651
+ throw new Error(`Unknown native history content: ${String(unhandled)}`);
40652
+ }
40653
+ }
40654
+ }
40655
+ function toolContent2(content) {
40656
+ if (content.type === "diff") {
40657
+ return {
40658
+ newText: content.newText,
40659
+ path: content.path,
40660
+ type: "diff",
40661
+ ...content.oldText.length === 0 ? {} : { oldText: content.oldText }
40662
+ };
40663
+ }
40664
+ if (content.type === "terminal") {
40665
+ return { terminalId: content.terminalId, type: "terminal" };
40666
+ }
40667
+ const block = contentBlock(content);
40668
+ return block === null ? null : { content: block, type: "content" };
40669
+ }
40670
+ function toolKind(value) {
40671
+ switch (value) {
40672
+ case "read":
40673
+ case "edit":
40674
+ case "delete":
40675
+ case "move":
40676
+ case "search":
40677
+ case "execute":
40678
+ case "think":
40679
+ case "fetch":
40680
+ case "switch_mode":
40681
+ case "other":
40682
+ return value;
40683
+ default:
40684
+ return "other";
40685
+ }
40686
+ }
40687
+ function toolStatus(value) {
40688
+ switch (value) {
40689
+ case "pending":
40690
+ return "pending";
40691
+ case "running":
40692
+ case "in_progress":
40693
+ return "in_progress";
40694
+ case "completed":
40695
+ return "completed";
40696
+ default:
40697
+ return "failed";
40698
+ }
40699
+ }
40700
+ function activityEvent(activity2) {
40701
+ const content = activity2.content.flatMap((item) => {
40702
+ const converted = toolContent2(item);
40703
+ return converted === null ? [] : [converted];
40704
+ });
40705
+ return {
40706
+ payload: {
40707
+ content,
40708
+ kind: toolKind(activity2.toolKind),
40709
+ locations: activity2.locations.map((path3) => ({ path: path3 })),
40710
+ rawInput: activity2.input,
40711
+ rawOutput: activity2.output,
40712
+ sessionUpdate: "tool_call",
40713
+ status: toolStatus(activity2.status),
40714
+ title: activity2.title,
40715
+ toolCallId: activity2.activityId,
40716
+ ...activity2.name.length === 0 ? {} : { name: activity2.name }
40717
+ },
40718
+ type: "acp"
40719
+ };
40720
+ }
40721
+ function contentEvent(sessionUpdate, messageId, content) {
40722
+ return { payload: { content, messageId, sessionUpdate }, type: "acp" };
40723
+ }
40724
+ function historyEvents(history) {
40725
+ return history.messages.flatMap((message, index2) => {
40726
+ const messageId = `native-history-${index2.toString()}`;
40727
+ const sessionUpdate = message.role === "user" ? "user_message_chunk" : "agent_message_chunk";
40728
+ const images = (message.images ?? []).map(
40729
+ (image) => contentEvent(sessionUpdate, messageId, {
40730
+ data: image.data,
40731
+ mimeType: image.mimeType,
40732
+ type: "image"
40733
+ })
40734
+ );
40735
+ const text2 = message.text.length === 0 ? [] : [contentEvent(sessionUpdate, messageId, { text: message.text, type: "text" })];
40736
+ if (message.role === "user") {
40737
+ return [...images, ...text2];
40738
+ }
40739
+ const activities = message.activities.map(activityEvent);
40740
+ const content = message.content.flatMap((item) => {
40741
+ const converted = contentBlock(item);
40742
+ return converted === null ? [] : [contentEvent(sessionUpdate, messageId, converted)];
40743
+ });
40744
+ return [...activities, ...content, ...images, ...text2];
40745
+ });
40746
+ }
40747
+ function nativeHistoryEventsV2(nativeSessionId, history, eventLimit, cursor) {
40748
+ const events = historyEvents(history);
40749
+ const generationId = createHash4("sha256").update(nativeSessionId).update("\0").update(JSON.stringify(events)).digest("hex");
40750
+ return pageAcpSessionEventsV2(generationId, events, eventLimit, cursor);
40751
+ }
40752
+
40582
40753
  // src/acp/process-capacity.ts
40583
40754
  var AcpProcessCapacityLease = class {
40584
40755
  #releaseCapacity;
@@ -40791,7 +40962,7 @@ var AgentRuntimeManager = class {
40791
40962
  #onSessionStatusChanged;
40792
40963
  #contentExternalizer;
40793
40964
  #observer;
40794
- constructor(observer = new NullAcpSessionObserver(), store = new MemoryAcpSessionStore(), nativeHistoryReader = null, sessionIdentity = "assigned", onSessionStatusChanged = () => void 0, contentExternalizer = new AcpContentExternalizer(new UnretainedExternalContentStore())) {
40965
+ constructor(observer = new NullAcpSessionObserver(), store = new MemoryAcpSessionStore(), nativeHistoryReader = acpNativeHistoryReader, sessionIdentity = "assigned", onSessionStatusChanged = () => void 0, contentExternalizer = new AcpContentExternalizer(new UnretainedExternalContentStore())) {
40795
40966
  this.#observer = observer;
40796
40967
  this.#store = store;
40797
40968
  this.#nativeHistoryReader = nativeHistoryReader;
@@ -41321,6 +41492,14 @@ var AgentRuntimeManager = class {
41321
41492
  }
41322
41493
  this.#nativeOperations.add(key);
41323
41494
  try {
41495
+ const historyAccess = this.#nativeHistoryReader.access(options2);
41496
+ if (historyAccess.kind === "direct") {
41497
+ const history = await historyAccess.read(nativeSessionId, () => null);
41498
+ if (history.status === "unavailable") {
41499
+ throw new AcpExecutionError(history.cause.message, {}, history.cause.code);
41500
+ }
41501
+ return nativeHistoryEventsV2(nativeSessionId, history, eventLimit, cursor);
41502
+ }
41324
41503
  return await this.#queryProcesses.previewEventsV2(options2, nativeSessionId, eventLimit, cursor);
41325
41504
  } finally {
41326
41505
  this.#nativeOperations.delete(key);
@@ -41330,15 +41509,9 @@ var AgentRuntimeManager = class {
41330
41509
  return await this.#executionProcesses.use(options2.sessionId, async () => {
41331
41510
  const runtime = await this.ensureSession(options2);
41332
41511
  const stored = this.#store.read(options2.sessionId);
41333
- if (stored instanceof FoundAcpStoredSession && this.#nativeHistoryReader !== null) {
41334
- const history = await this.#nativeHistoryReader.read(
41335
- options2,
41336
- stored.session.nativeSessionId,
41337
- runtime.nativeHistoryTurn
41338
- );
41339
- if (history !== null) {
41340
- return history;
41341
- }
41512
+ const historyAccess = this.#nativeHistoryReader.access(options2);
41513
+ if (stored instanceof FoundAcpStoredSession && historyAccess.kind === "direct") {
41514
+ return await historyAccess.read(stored.session.nativeSessionId, runtime.nativeHistoryTurn);
41342
41515
  }
41343
41516
  return await runtime.loadHistory(options2.signal);
41344
41517
  });
@@ -42231,7 +42404,7 @@ import { WebSocket as WebSocket2 } from "undici";
42231
42404
  import { WebSocket } from "undici";
42232
42405
 
42233
42406
  // src/prompt-artifact-resolver.ts
42234
- import { createHash as createHash4 } from "node:crypto";
42407
+ import { createHash as createHash5 } from "node:crypto";
42235
42408
  import { fetch as fetch4 } from "undici";
42236
42409
  var ARTIFACT_SCHEME = "mobius-artifact:";
42237
42410
  var ARTIFACT_DOWNLOAD_TIMEOUT_MILLISECONDS = 2e4;
@@ -42369,7 +42542,7 @@ async function download(config2, command, reference, signal) {
42369
42542
  );
42370
42543
  }
42371
42544
  const bytes = await responseBytes(response, reference.byteLength, requestSignal);
42372
- if (createHash4("sha256").update(bytes).digest("hex") !== reference.sha256) {
42545
+ if (createHash5("sha256").update(bytes).digest("hex") !== reference.sha256) {
42373
42546
  throw new PromptArtifactError(
42374
42547
  "artifact_integrity_failed",
42375
42548
  "The prompt artifact failed integrity validation"
@@ -43390,6 +43563,14 @@ var historyItemSchema = external_exports.discriminatedUnion("type", [
43390
43563
  dynamicToolCallSchema,
43391
43564
  planSchema
43392
43565
  ]);
43566
+ var CodexHistoryResponseError = class extends Error {
43567
+ code;
43568
+ constructor(response) {
43569
+ super(response.message);
43570
+ this.code = response.code;
43571
+ this.name = "CodexHistoryResponseError";
43572
+ }
43573
+ };
43393
43574
  function bounded(value, maximum) {
43394
43575
  return value.slice(0, maximum);
43395
43576
  }
@@ -43429,7 +43610,7 @@ function formatted(value) {
43429
43610
  }
43430
43611
  return JSON.stringify(value) ?? "";
43431
43612
  }
43432
- function toolStatus(status) {
43613
+ function toolStatus2(status) {
43433
43614
  return status === "inProgress" ? "running" : status === "completed" ? "completed" : "failed";
43434
43615
  }
43435
43616
  function diffDisplayContent(path3, newText) {
@@ -43636,7 +43817,7 @@ function decodeHistory(thread, value, options) {
43636
43817
  formatted_output: historyItem.aggregatedOutput ?? "",
43637
43818
  ...historyItem.exitCode == null ? {} : { exit_code: historyItem.exitCode }
43638
43819
  }),
43639
- status: toolStatus(historyItem.status),
43820
+ status: toolStatus2(historyItem.status),
43640
43821
  title: historyItem.command,
43641
43822
  toolKind: action
43642
43823
  })
@@ -43658,7 +43839,7 @@ function decodeHistory(thread, value, options) {
43658
43839
  locations: paths,
43659
43840
  name: "",
43660
43841
  output: "",
43661
- status: toolStatus(historyItem.status),
43842
+ status: toolStatus2(historyItem.status),
43662
43843
  title: paths.join(", "),
43663
43844
  toolKind: "edit"
43664
43845
  })
@@ -43676,7 +43857,7 @@ function decodeHistory(thread, value, options) {
43676
43857
  locations: [],
43677
43858
  name: historyItem.tool,
43678
43859
  output: formatted(historyItem.error ?? historyItem.result),
43679
- status: toolStatus(historyItem.status),
43860
+ status: toolStatus2(historyItem.status),
43680
43861
  title: `${historyItem.server}/${historyItem.tool}`,
43681
43862
  toolKind: "other"
43682
43863
  })
@@ -43694,7 +43875,7 @@ function decodeHistory(thread, value, options) {
43694
43875
  locations: [],
43695
43876
  name: historyItem.tool,
43696
43877
  output: formatted(historyItem.contentItems),
43697
- status: toolStatus(historyItem.status),
43878
+ status: toolStatus2(historyItem.status),
43698
43879
  title: historyItem.namespace == null ? historyItem.tool : `${historyItem.namespace}/${historyItem.tool}`,
43699
43880
  toolKind: "other"
43700
43881
  })
@@ -43860,7 +44041,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
43860
44041
  fail(
43861
44042
  new AcpExecutionError(
43862
44043
  "Saved Codex history could not be read.",
43863
- { cause: message.error },
44044
+ { cause: new CodexHistoryResponseError(message.error) },
43864
44045
  "native_history_unavailable"
43865
44046
  )
43866
44047
  );
@@ -44368,7 +44549,7 @@ var NativeSessionService = class {
44368
44549
  };
44369
44550
 
44370
44551
  // src/relay-connection/daemon-operation-state.ts
44371
- import { createHash as createHash5, randomUUID as randomUUID6 } from "node:crypto";
44552
+ import { createHash as createHash6, randomUUID as randomUUID6 } from "node:crypto";
44372
44553
  var MAX_TERMINAL_RECEIPTS = 1024;
44373
44554
  function isTerminal(state) {
44374
44555
  return state === "succeeded" || state === "failed" || state === "cancelled";
@@ -44377,7 +44558,7 @@ var DaemonOperationState = class {
44377
44558
  #executions = /* @__PURE__ */ new Map();
44378
44559
  #terminalCount = 0;
44379
44560
  claimExecution = (commandId, sessionId, commandJson) => {
44380
- const commandHash = createHash5("sha256").update(commandJson).digest("hex");
44561
+ const commandHash = createHash6("sha256").update(commandJson).digest("hex");
44381
44562
  const existing = this.#executions.get(commandId);
44382
44563
  if (existing !== void 0) {
44383
44564
  if (existing.sessionId !== sessionId || existing.commandHash !== commandHash) {
@@ -44599,7 +44780,7 @@ import { WebSocket as WebSocket5 } from "undici";
44599
44780
  import { WebSocket as WebSocket3 } from "undici";
44600
44781
 
44601
44782
  // src/agent-catalog/discover-agent-settings.ts
44602
- import { createHash as createHash6 } from "node:crypto";
44783
+ import { createHash as createHash7 } from "node:crypto";
44603
44784
 
44604
44785
  // src/agent-catalog/agent-settings-base.ts
44605
44786
  var AgentSettingsConfigurationError = class extends Error {
@@ -45063,7 +45244,7 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
45063
45244
  unsupportedModelIds: modelEffort.unsupportedModelIds,
45064
45245
  valuesByModel: {}
45065
45246
  };
45066
- return createHash6("sha256").update(
45247
+ return createHash7("sha256").update(
45067
45248
  JSON.stringify({
45068
45249
  adapterVersion: agent.kind === "acp-adapter-process" ? agent.adapterVersion : agent.agentVersion,
45069
45250
  agentId: agent.id,
@@ -45375,7 +45556,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
45375
45556
  },
45376
45557
  queuedPromptRequests: recovery.queuedPromptRequests
45377
45558
  },
45378
- kind: "session.live-history.v2.page.loaded",
45559
+ kind: SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND,
45379
45560
  requestId: command.requestId,
45380
45561
  sessionId: command.sessionId
45381
45562
  });
@@ -45404,6 +45585,81 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
45404
45585
  }
45405
45586
  }
45406
45587
  }
45588
+ async function executeSessionPreviewHistoryPageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventLogV2, signal) {
45589
+ try {
45590
+ const resolved = await resolveSessionDirectories(
45591
+ directories,
45592
+ config2.bindingId,
45593
+ command.directoryId,
45594
+ command.additionalDirectoryIds,
45595
+ signal
45596
+ );
45597
+ const replay = await sessions.previewNativeSessionEventsV2(
45598
+ {
45599
+ additionalDirectories: resolved.additionalDirectories,
45600
+ agent: config2.catalog.find(command.agentId),
45601
+ cwd: resolved.cwd,
45602
+ sessionId: command.sessionId,
45603
+ signal
45604
+ },
45605
+ command.sessionId,
45606
+ command.eventLimit,
45607
+ command.cursor
45608
+ );
45609
+ signal.throwIfAborted();
45610
+ const events = replay.events.map(
45611
+ (event, index2) => eventLogV2.event(
45612
+ command.sessionId,
45613
+ replay.sessionGenerationId,
45614
+ replay.startPosition + index2,
45615
+ event,
45616
+ "1970-01-01T00:00:00.000Z"
45617
+ )
45618
+ );
45619
+ const tailCursor = events.at(-1)?.eventId ?? "";
45620
+ audit.record({
45621
+ commandId: command.requestId,
45622
+ event: "session_event_log_v2_loaded",
45623
+ sessionId: command.sessionId
45624
+ });
45625
+ send(socket, {
45626
+ events: {
45627
+ events: {
45628
+ events,
45629
+ nextCursor: replay.nextCursor,
45630
+ sessionGenerationId: replay.sessionGenerationId,
45631
+ tailCursor,
45632
+ truncated: replay.truncated,
45633
+ version: 2
45634
+ },
45635
+ queuedPromptRequests: []
45636
+ },
45637
+ kind: SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND,
45638
+ requestId: command.requestId,
45639
+ sessionId: command.sessionId
45640
+ });
45641
+ } catch (error62) {
45642
+ if (!signal.aborted) {
45643
+ diagnostics.daemonDiagnostic(
45644
+ "session_history_v2_load_failed",
45645
+ command.requestId,
45646
+ {
45647
+ agentId: command.agentId,
45648
+ code: operationErrorCode(error62),
45649
+ sessionId: command.sessionId
45650
+ },
45651
+ error62
45652
+ );
45653
+ audit.record({
45654
+ commandId: command.requestId,
45655
+ details: { agentId: command.agentId, code: operationErrorCode(error62) },
45656
+ event: "session_history_v2_load_failed",
45657
+ sessionId: command.sessionId
45658
+ });
45659
+ reportOperationFailure(socket, command.requestId, command.sessionId, error62);
45660
+ }
45661
+ }
45662
+ }
45407
45663
 
45408
45664
  // src/acp/session-config/apply-session-configuration.ts
45409
45665
  import { randomUUID as randomUUID7 } from "node:crypto";
@@ -46153,6 +46409,20 @@ function createDaemonCommandHandler({
46153
46409
  );
46154
46410
  return;
46155
46411
  }
46412
+ if (kind === SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND) {
46413
+ void executeSessionPreviewHistoryPageLoad(
46414
+ socket,
46415
+ message,
46416
+ config2,
46417
+ directories,
46418
+ audit,
46419
+ diagnostics,
46420
+ sessions,
46421
+ eventLogV2,
46422
+ signal
46423
+ );
46424
+ return;
46425
+ }
46156
46426
  if (kind === NATIVE_SESSION_CANCEL_KIND) {
46157
46427
  nativeRequestHandler.cancel(message);
46158
46428
  return;
@@ -47124,7 +47394,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
47124
47394
  publishCatalog: async (installationSignal) => await publishAgentCatalog(config2, installationSignal),
47125
47395
  stateDirectory
47126
47396
  });
47127
- const channelHash = createHash7("sha256").update(config2.channelId).digest("hex");
47397
+ const channelHash = createHash8("sha256").update(config2.channelId).digest("hex");
47128
47398
  const sessionDatabase = openAcpSessionDatabase(join19(stateDirectory, "sessions", `${channelHash}.sqlite`));
47129
47399
  let eventsV2;
47130
47400
  try {
@@ -47150,13 +47420,16 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
47150
47420
  }, eventLogV2.record),
47151
47421
  sessionStore,
47152
47422
  {
47153
- read: async (options2, nativeSessionId, nativeTurn) => options2.agent.id === "codex" ? (await readCodexFullHistory(
47154
- options2.agent,
47155
- options2.cwd,
47156
- nativeSessionId,
47157
- options2.signal,
47158
- nativeTurn
47159
- )).history : null
47423
+ access: (options2) => options2.agent.id === "codex" ? {
47424
+ kind: "direct",
47425
+ read: async (nativeSessionId, nativeTurn) => (await readCodexFullHistory(
47426
+ options2.agent,
47427
+ options2.cwd,
47428
+ nativeSessionId,
47429
+ options2.signal,
47430
+ nativeTurn
47431
+ )).history
47432
+ } : { kind: "acp" }
47160
47433
  },
47161
47434
  "native",
47162
47435
  publisher.publishStatus,
@@ -47421,7 +47694,7 @@ function isRecord12(value) {
47421
47694
  return typeof value === "object" && value !== null && !Array.isArray(value);
47422
47695
  }
47423
47696
  function controlSocketPath(stateDirectory) {
47424
- const installationHash = createHash8("sha256").update(stateDirectory).digest("hex").slice(0, 32);
47697
+ const installationHash = createHash9("sha256").update(stateDirectory).digest("hex").slice(0, 32);
47425
47698
  return process.platform === "win32" ? `\\\\.\\pipe\\mobius-${installationHash}` : join20(tmpdir(), `mobius-${installationHash}.sock`);
47426
47699
  }
47427
47700
  function controlTokenPath(stateDirectory) {