@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/runtime.js CHANGED
@@ -21409,24 +21409,28 @@ var decodeAcpSessionUpdateV2 = (value) => decode5(value, acpSessionUpdateV2Schem
21409
21409
  // ../protocol/src/session-live-history.ts
21410
21410
  var SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND = "session.live-history.v2.page.load";
21411
21411
  var SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND = "session.live-history.v2.page.loaded";
21412
+ var SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND = "session.preview-history.page.load";
21413
+ var SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND = "session.preview-history.page.loaded";
21412
21414
  var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
21413
- var sessionLiveHistoryV2PageLoadSchema = external_exports.object({
21415
+ var pageLoadFields = {
21414
21416
  additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
21415
21417
  agentId: identifierStringSchema,
21416
21418
  bindingId: identifierStringSchema,
21417
21419
  cursor: external_exports.string().min(1).max(512).nullable(),
21418
21420
  directoryId: directoryIdentifier,
21419
- kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND),
21420
21421
  eventLimit: external_exports.number().int().min(1).max(1e4),
21421
21422
  requestId: identifierStringSchema,
21422
21423
  sessionId: identifierStringSchema
21423
- }).readonly();
21424
- var sessionLiveHistoryV2PageLoadedSchema = external_exports.object({
21424
+ };
21425
+ var sessionLiveHistoryV2PageLoadSchema = external_exports.object({ ...pageLoadFields, kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND) }).readonly();
21426
+ var sessionPreviewHistoryPageLoadSchema = external_exports.object({ ...pageLoadFields, kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND) }).readonly();
21427
+ var pageLoadedFields = {
21425
21428
  events: nativeSessionEventsV2Schema,
21426
- kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND),
21427
21429
  requestId: identifierStringSchema,
21428
21430
  sessionId: identifierStringSchema
21429
- }).readonly();
21431
+ };
21432
+ var sessionLiveHistoryV2PageLoadedSchema = external_exports.object({ ...pageLoadedFields, kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND) }).readonly();
21433
+ var sessionPreviewHistoryPageLoadedSchema = external_exports.object({ ...pageLoadedFields, kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND) }).readonly();
21430
21434
  function decode6(schema, encoded) {
21431
21435
  try {
21432
21436
  const value = JSON.parse(encoded);
@@ -21437,8 +21441,12 @@ function decode6(schema, encoded) {
21437
21441
  }
21438
21442
  var decodeSessionLiveHistoryV2PageLoad = (encoded) => decode6(sessionLiveHistoryV2PageLoadSchema, encoded);
21439
21443
  var decodeSessionLiveHistoryV2PageLoaded = (encoded) => decode6(sessionLiveHistoryV2PageLoadedSchema, encoded);
21444
+ var decodeSessionPreviewHistoryPageLoad = (encoded) => decode6(sessionPreviewHistoryPageLoadSchema, encoded);
21445
+ var decodeSessionPreviewHistoryPageLoaded = (encoded) => decode6(sessionPreviewHistoryPageLoadedSchema, encoded);
21440
21446
  var encodeSessionLiveHistoryV2PageLoad = (value) => JSON.stringify(sessionLiveHistoryV2PageLoadSchema.parse(value));
21441
21447
  var encodeSessionLiveHistoryV2PageLoaded = (value) => JSON.stringify(sessionLiveHistoryV2PageLoadedSchema.parse(value));
21448
+ var encodeSessionPreviewHistoryPageLoad = (value) => JSON.stringify(sessionPreviewHistoryPageLoadSchema.parse(value));
21449
+ var encodeSessionPreviewHistoryPageLoaded = (value) => JSON.stringify(sessionPreviewHistoryPageLoadedSchema.parse(value));
21442
21450
 
21443
21451
  // ../protocol/src/daemon-transport.ts
21444
21452
  function defineMessageSignature(kind, encoder, decoder) {
@@ -21451,6 +21459,11 @@ function defineMessageSignature(kind, encoder, decoder) {
21451
21459
  };
21452
21460
  }
21453
21461
  var serviceToDaemonSignatures = {
21462
+ [SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND]: defineMessageSignature(
21463
+ SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND,
21464
+ encodeSessionPreviewHistoryPageLoad,
21465
+ decodeSessionPreviewHistoryPageLoad
21466
+ ),
21454
21467
  [AGENT_INSTALL_CANCEL_KIND]: defineMessageSignature(
21455
21468
  AGENT_INSTALL_CANCEL_KIND,
21456
21469
  encodeAgentInstallCancelCommand,
@@ -21555,6 +21568,11 @@ function decodeServiceToDaemonMessage(encoded) {
21555
21568
  return signature.decoder(encoded);
21556
21569
  }
21557
21570
  var daemonToServiceSignatures = {
21571
+ [SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND]: defineMessageSignature(
21572
+ SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND,
21573
+ encodeSessionPreviewHistoryPageLoaded,
21574
+ decodeSessionPreviewHistoryPageLoaded
21575
+ ),
21558
21576
  [SESSION_CONFIG_UPDATED_KIND]: defineMessageSignature(
21559
21577
  SESSION_CONFIG_UPDATED_KIND,
21560
21578
  encodeSessionConfigUpdatedEvent,
@@ -26877,7 +26895,7 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
26877
26895
  }
26878
26896
 
26879
26897
  // src/run-daemon.ts
26880
- import { createHash as createHash6, randomUUID as randomUUID8 } from "node:crypto";
26898
+ import { createHash as createHash7, randomUUID as randomUUID8 } from "node:crypto";
26881
26899
  import { join as join18 } from "node:path";
26882
26900
  import { styleText } from "node:util";
26883
26901
 
@@ -27772,7 +27790,7 @@ var AcpActivity = class _AcpActivity {
27772
27790
  toolKind;
27773
27791
  content;
27774
27792
  detail;
27775
- constructor(activityId, activityType, input2, locations, name2, output2, sequence, status, title2, toolKind, content = [], detail = captureActivityDetail(content, input2, output2)) {
27793
+ constructor(activityId, activityType, input2, locations, name2, output2, sequence, status, title2, toolKind2, content = [], detail = captureActivityDetail(content, input2, output2)) {
27776
27794
  this.activityId = activityId;
27777
27795
  this.activityType = activityType;
27778
27796
  this.input = input2;
@@ -27782,7 +27800,7 @@ var AcpActivity = class _AcpActivity {
27782
27800
  this.sequence = sequence;
27783
27801
  this.status = status;
27784
27802
  this.title = title2;
27785
- this.toolKind = toolKind;
27803
+ this.toolKind = toolKind2;
27786
27804
  this.content = content;
27787
27805
  this.detail = detail;
27788
27806
  }
@@ -28439,6 +28457,9 @@ function sessionConfigProtocolForAgent(_agentId) {
28439
28457
  }
28440
28458
 
28441
28459
  // src/acp/session-contracts.ts
28460
+ var acpNativeHistoryReader = {
28461
+ access: () => ({ kind: "acp" })
28462
+ };
28442
28463
  var NullAcpSessionObserver = class {
28443
28464
  onSessionEventV2 = (_sessionId, _event, _position) => Promise.resolve();
28444
28465
  onCommands = () => Promise.resolve();
@@ -34089,6 +34110,15 @@ function eventPage(sessionGenerationId, eventCount, eventLimit, cursor, read) {
34089
34110
  truncated: startPosition > 0
34090
34111
  };
34091
34112
  }
34113
+ function pageAcpSessionEventsV2(sessionGenerationId, events, eventLimit, cursor) {
34114
+ return eventPage(
34115
+ sessionGenerationId,
34116
+ events.length,
34117
+ eventLimit,
34118
+ cursor,
34119
+ (startPosition, endPosition) => events.slice(startPosition - 1, endPosition)
34120
+ );
34121
+ }
34092
34122
  var MemoryAcpSessionEventStoreV2 = class {
34093
34123
  #events = /* @__PURE__ */ new Map();
34094
34124
  #session = (sessionId) => {
@@ -36211,6 +36241,147 @@ function isNativeChatSessionId(agentId, sessionId) {
36211
36241
  return (agentId === "codex" || agentId === "claude" || agentId === "pi") && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu.test(sessionId);
36212
36242
  }
36213
36243
 
36244
+ // src/native-sessions/native-history-events-v2.ts
36245
+ import { createHash as createHash3 } from "node:crypto";
36246
+ function contentBlock(content) {
36247
+ switch (content.type) {
36248
+ case "text":
36249
+ return { text: content.text, type: "text" };
36250
+ case "image":
36251
+ return {
36252
+ data: content.data,
36253
+ mimeType: content.mimeType,
36254
+ type: "image",
36255
+ ...content.uri.length === 0 ? {} : { uri: content.uri }
36256
+ };
36257
+ case "resource_link":
36258
+ return {
36259
+ name: content.name.length === 0 ? content.uri : content.name,
36260
+ type: "resource_link",
36261
+ uri: content.uri,
36262
+ ...content.mimeType.length === 0 ? {} : { mimeType: content.mimeType }
36263
+ };
36264
+ case "resource":
36265
+ return {
36266
+ resource: content.text.length > 0 ? {
36267
+ text: content.text,
36268
+ uri: content.uri,
36269
+ ...content.mimeType.length === 0 ? {} : { mimeType: content.mimeType }
36270
+ } : {
36271
+ blob: content.data,
36272
+ uri: content.uri,
36273
+ ...content.mimeType.length === 0 ? {} : { mimeType: content.mimeType }
36274
+ },
36275
+ type: "resource"
36276
+ };
36277
+ case "diff":
36278
+ case "terminal":
36279
+ case "video":
36280
+ return null;
36281
+ default: {
36282
+ const unhandled = content.type;
36283
+ throw new Error(`Unknown native history content: ${String(unhandled)}`);
36284
+ }
36285
+ }
36286
+ }
36287
+ function toolContent2(content) {
36288
+ if (content.type === "diff") {
36289
+ return {
36290
+ newText: content.newText,
36291
+ path: content.path,
36292
+ type: "diff",
36293
+ ...content.oldText.length === 0 ? {} : { oldText: content.oldText }
36294
+ };
36295
+ }
36296
+ if (content.type === "terminal") {
36297
+ return { terminalId: content.terminalId, type: "terminal" };
36298
+ }
36299
+ const block = contentBlock(content);
36300
+ return block === null ? null : { content: block, type: "content" };
36301
+ }
36302
+ function toolKind(value) {
36303
+ switch (value) {
36304
+ case "read":
36305
+ case "edit":
36306
+ case "delete":
36307
+ case "move":
36308
+ case "search":
36309
+ case "execute":
36310
+ case "think":
36311
+ case "fetch":
36312
+ case "switch_mode":
36313
+ case "other":
36314
+ return value;
36315
+ default:
36316
+ return "other";
36317
+ }
36318
+ }
36319
+ function toolStatus(value) {
36320
+ switch (value) {
36321
+ case "pending":
36322
+ return "pending";
36323
+ case "running":
36324
+ case "in_progress":
36325
+ return "in_progress";
36326
+ case "completed":
36327
+ return "completed";
36328
+ default:
36329
+ return "failed";
36330
+ }
36331
+ }
36332
+ function activityEvent(activity2) {
36333
+ const content = activity2.content.flatMap((item) => {
36334
+ const converted = toolContent2(item);
36335
+ return converted === null ? [] : [converted];
36336
+ });
36337
+ return {
36338
+ payload: {
36339
+ content,
36340
+ kind: toolKind(activity2.toolKind),
36341
+ locations: activity2.locations.map((path2) => ({ path: path2 })),
36342
+ rawInput: activity2.input,
36343
+ rawOutput: activity2.output,
36344
+ sessionUpdate: "tool_call",
36345
+ status: toolStatus(activity2.status),
36346
+ title: activity2.title,
36347
+ toolCallId: activity2.activityId,
36348
+ ...activity2.name.length === 0 ? {} : { name: activity2.name }
36349
+ },
36350
+ type: "acp"
36351
+ };
36352
+ }
36353
+ function contentEvent(sessionUpdate, messageId, content) {
36354
+ return { payload: { content, messageId, sessionUpdate }, type: "acp" };
36355
+ }
36356
+ function historyEvents(history) {
36357
+ return history.messages.flatMap((message, index2) => {
36358
+ const messageId = `native-history-${index2.toString()}`;
36359
+ const sessionUpdate = message.role === "user" ? "user_message_chunk" : "agent_message_chunk";
36360
+ const images = (message.images ?? []).map(
36361
+ (image) => contentEvent(sessionUpdate, messageId, {
36362
+ data: image.data,
36363
+ mimeType: image.mimeType,
36364
+ type: "image"
36365
+ })
36366
+ );
36367
+ const text2 = message.text.length === 0 ? [] : [contentEvent(sessionUpdate, messageId, { text: message.text, type: "text" })];
36368
+ if (message.role === "user") {
36369
+ return [...images, ...text2];
36370
+ }
36371
+ const activities = message.activities.map(activityEvent);
36372
+ const content = message.content.flatMap((item) => {
36373
+ const converted = contentBlock(item);
36374
+ return converted === null ? [] : [contentEvent(sessionUpdate, messageId, converted)];
36375
+ });
36376
+ return [...activities, ...content, ...images, ...text2];
36377
+ });
36378
+ }
36379
+ function nativeHistoryEventsV2(nativeSessionId, history, eventLimit, cursor) {
36380
+ const events = historyEvents(history);
36381
+ const generationId = createHash3("sha256").update(nativeSessionId).update("\0").update(JSON.stringify(events)).digest("hex");
36382
+ return pageAcpSessionEventsV2(generationId, events, eventLimit, cursor);
36383
+ }
36384
+
36214
36385
  // src/acp/process-capacity.ts
36215
36386
  var AcpProcessCapacityLease = class {
36216
36387
  #releaseCapacity;
@@ -36423,7 +36594,7 @@ var AgentRuntimeManager = class {
36423
36594
  #onSessionStatusChanged;
36424
36595
  #contentExternalizer;
36425
36596
  #observer;
36426
- constructor(observer = new NullAcpSessionObserver(), store = new MemoryAcpSessionStore(), nativeHistoryReader = null, sessionIdentity = "assigned", onSessionStatusChanged = () => void 0, contentExternalizer = new AcpContentExternalizer(new UnretainedExternalContentStore())) {
36597
+ constructor(observer = new NullAcpSessionObserver(), store = new MemoryAcpSessionStore(), nativeHistoryReader = acpNativeHistoryReader, sessionIdentity = "assigned", onSessionStatusChanged = () => void 0, contentExternalizer = new AcpContentExternalizer(new UnretainedExternalContentStore())) {
36427
36598
  this.#observer = observer;
36428
36599
  this.#store = store;
36429
36600
  this.#nativeHistoryReader = nativeHistoryReader;
@@ -36953,6 +37124,14 @@ var AgentRuntimeManager = class {
36953
37124
  }
36954
37125
  this.#nativeOperations.add(key);
36955
37126
  try {
37127
+ const historyAccess = this.#nativeHistoryReader.access(options2);
37128
+ if (historyAccess.kind === "direct") {
37129
+ const history = await historyAccess.read(nativeSessionId, () => null);
37130
+ if (history.status === "unavailable") {
37131
+ throw new AcpExecutionError(history.cause.message, {}, history.cause.code);
37132
+ }
37133
+ return nativeHistoryEventsV2(nativeSessionId, history, eventLimit, cursor);
37134
+ }
36956
37135
  return await this.#queryProcesses.previewEventsV2(options2, nativeSessionId, eventLimit, cursor);
36957
37136
  } finally {
36958
37137
  this.#nativeOperations.delete(key);
@@ -36962,15 +37141,9 @@ var AgentRuntimeManager = class {
36962
37141
  return await this.#executionProcesses.use(options2.sessionId, async () => {
36963
37142
  const runtime = await this.ensureSession(options2);
36964
37143
  const stored = this.#store.read(options2.sessionId);
36965
- if (stored instanceof FoundAcpStoredSession && this.#nativeHistoryReader !== null) {
36966
- const history = await this.#nativeHistoryReader.read(
36967
- options2,
36968
- stored.session.nativeSessionId,
36969
- runtime.nativeHistoryTurn
36970
- );
36971
- if (history !== null) {
36972
- return history;
36973
- }
37144
+ const historyAccess = this.#nativeHistoryReader.access(options2);
37145
+ if (stored instanceof FoundAcpStoredSession && historyAccess.kind === "direct") {
37146
+ return await historyAccess.read(stored.session.nativeSessionId, runtime.nativeHistoryTurn);
36974
37147
  }
36975
37148
  return await runtime.loadHistory(options2.signal);
36976
37149
  });
@@ -37863,7 +38036,7 @@ import { WebSocket as WebSocket2 } from "undici";
37863
38036
  import { WebSocket } from "undici";
37864
38037
 
37865
38038
  // src/prompt-artifact-resolver.ts
37866
- import { createHash as createHash3 } from "node:crypto";
38039
+ import { createHash as createHash4 } from "node:crypto";
37867
38040
  import { fetch as fetch3 } from "undici";
37868
38041
  var ARTIFACT_SCHEME = "mobius-artifact:";
37869
38042
  var ARTIFACT_DOWNLOAD_TIMEOUT_MILLISECONDS = 2e4;
@@ -38001,7 +38174,7 @@ async function download(config2, command, reference, signal) {
38001
38174
  );
38002
38175
  }
38003
38176
  const bytes = await responseBytes(response, reference.byteLength, requestSignal);
38004
- if (createHash3("sha256").update(bytes).digest("hex") !== reference.sha256) {
38177
+ if (createHash4("sha256").update(bytes).digest("hex") !== reference.sha256) {
38005
38178
  throw new PromptArtifactError(
38006
38179
  "artifact_integrity_failed",
38007
38180
  "The prompt artifact failed integrity validation"
@@ -39022,6 +39195,14 @@ var historyItemSchema = external_exports.discriminatedUnion("type", [
39022
39195
  dynamicToolCallSchema,
39023
39196
  planSchema
39024
39197
  ]);
39198
+ var CodexHistoryResponseError = class extends Error {
39199
+ code;
39200
+ constructor(response) {
39201
+ super(response.message);
39202
+ this.code = response.code;
39203
+ this.name = "CodexHistoryResponseError";
39204
+ }
39205
+ };
39025
39206
  function bounded(value, maximum) {
39026
39207
  return value.slice(0, maximum);
39027
39208
  }
@@ -39061,7 +39242,7 @@ function formatted(value) {
39061
39242
  }
39062
39243
  return JSON.stringify(value) ?? "";
39063
39244
  }
39064
- function toolStatus(status) {
39245
+ function toolStatus2(status) {
39065
39246
  return status === "inProgress" ? "running" : status === "completed" ? "completed" : "failed";
39066
39247
  }
39067
39248
  function diffDisplayContent(path2, newText) {
@@ -39268,7 +39449,7 @@ function decodeHistory(thread, value, options) {
39268
39449
  formatted_output: historyItem.aggregatedOutput ?? "",
39269
39450
  ...historyItem.exitCode == null ? {} : { exit_code: historyItem.exitCode }
39270
39451
  }),
39271
- status: toolStatus(historyItem.status),
39452
+ status: toolStatus2(historyItem.status),
39272
39453
  title: historyItem.command,
39273
39454
  toolKind: action
39274
39455
  })
@@ -39290,7 +39471,7 @@ function decodeHistory(thread, value, options) {
39290
39471
  locations: paths,
39291
39472
  name: "",
39292
39473
  output: "",
39293
- status: toolStatus(historyItem.status),
39474
+ status: toolStatus2(historyItem.status),
39294
39475
  title: paths.join(", "),
39295
39476
  toolKind: "edit"
39296
39477
  })
@@ -39308,7 +39489,7 @@ function decodeHistory(thread, value, options) {
39308
39489
  locations: [],
39309
39490
  name: historyItem.tool,
39310
39491
  output: formatted(historyItem.error ?? historyItem.result),
39311
- status: toolStatus(historyItem.status),
39492
+ status: toolStatus2(historyItem.status),
39312
39493
  title: `${historyItem.server}/${historyItem.tool}`,
39313
39494
  toolKind: "other"
39314
39495
  })
@@ -39326,7 +39507,7 @@ function decodeHistory(thread, value, options) {
39326
39507
  locations: [],
39327
39508
  name: historyItem.tool,
39328
39509
  output: formatted(historyItem.contentItems),
39329
- status: toolStatus(historyItem.status),
39510
+ status: toolStatus2(historyItem.status),
39330
39511
  title: historyItem.namespace == null ? historyItem.tool : `${historyItem.namespace}/${historyItem.tool}`,
39331
39512
  toolKind: "other"
39332
39513
  })
@@ -39492,7 +39673,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
39492
39673
  fail(
39493
39674
  new AcpExecutionError(
39494
39675
  "Saved Codex history could not be read.",
39495
- { cause: message.error },
39676
+ { cause: new CodexHistoryResponseError(message.error) },
39496
39677
  "native_history_unavailable"
39497
39678
  )
39498
39679
  );
@@ -40000,7 +40181,7 @@ var NativeSessionService = class {
40000
40181
  };
40001
40182
 
40002
40183
  // src/relay-connection/daemon-operation-state.ts
40003
- import { createHash as createHash4, randomUUID as randomUUID5 } from "node:crypto";
40184
+ import { createHash as createHash5, randomUUID as randomUUID5 } from "node:crypto";
40004
40185
  var MAX_TERMINAL_RECEIPTS = 1024;
40005
40186
  function isTerminal(state) {
40006
40187
  return state === "succeeded" || state === "failed" || state === "cancelled";
@@ -40009,7 +40190,7 @@ var DaemonOperationState = class {
40009
40190
  #executions = /* @__PURE__ */ new Map();
40010
40191
  #terminalCount = 0;
40011
40192
  claimExecution = (commandId, sessionId, commandJson) => {
40012
- const commandHash = createHash4("sha256").update(commandJson).digest("hex");
40193
+ const commandHash = createHash5("sha256").update(commandJson).digest("hex");
40013
40194
  const existing = this.#executions.get(commandId);
40014
40195
  if (existing !== void 0) {
40015
40196
  if (existing.sessionId !== sessionId || existing.commandHash !== commandHash) {
@@ -40231,7 +40412,7 @@ import { WebSocket as WebSocket5 } from "undici";
40231
40412
  import { WebSocket as WebSocket3 } from "undici";
40232
40413
 
40233
40414
  // src/agent-catalog/discover-agent-settings.ts
40234
- import { createHash as createHash5 } from "node:crypto";
40415
+ import { createHash as createHash6 } from "node:crypto";
40235
40416
 
40236
40417
  // src/agent-catalog/agent-settings-base.ts
40237
40418
  var AgentSettingsConfigurationError = class extends Error {
@@ -40695,7 +40876,7 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
40695
40876
  unsupportedModelIds: modelEffort.unsupportedModelIds,
40696
40877
  valuesByModel: {}
40697
40878
  };
40698
- return createHash5("sha256").update(
40879
+ return createHash6("sha256").update(
40699
40880
  JSON.stringify({
40700
40881
  adapterVersion: agent.kind === "acp-adapter-process" ? agent.adapterVersion : agent.agentVersion,
40701
40882
  agentId: agent.id,
@@ -41007,7 +41188,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
41007
41188
  },
41008
41189
  queuedPromptRequests: recovery.queuedPromptRequests
41009
41190
  },
41010
- kind: "session.live-history.v2.page.loaded",
41191
+ kind: SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND,
41011
41192
  requestId: command.requestId,
41012
41193
  sessionId: command.sessionId
41013
41194
  });
@@ -41036,6 +41217,81 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
41036
41217
  }
41037
41218
  }
41038
41219
  }
41220
+ async function executeSessionPreviewHistoryPageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventLogV2, signal) {
41221
+ try {
41222
+ const resolved = await resolveSessionDirectories(
41223
+ directories,
41224
+ config2.bindingId,
41225
+ command.directoryId,
41226
+ command.additionalDirectoryIds,
41227
+ signal
41228
+ );
41229
+ const replay = await sessions.previewNativeSessionEventsV2(
41230
+ {
41231
+ additionalDirectories: resolved.additionalDirectories,
41232
+ agent: config2.catalog.find(command.agentId),
41233
+ cwd: resolved.cwd,
41234
+ sessionId: command.sessionId,
41235
+ signal
41236
+ },
41237
+ command.sessionId,
41238
+ command.eventLimit,
41239
+ command.cursor
41240
+ );
41241
+ signal.throwIfAborted();
41242
+ const events = replay.events.map(
41243
+ (event, index2) => eventLogV2.event(
41244
+ command.sessionId,
41245
+ replay.sessionGenerationId,
41246
+ replay.startPosition + index2,
41247
+ event,
41248
+ "1970-01-01T00:00:00.000Z"
41249
+ )
41250
+ );
41251
+ const tailCursor = events.at(-1)?.eventId ?? "";
41252
+ audit.record({
41253
+ commandId: command.requestId,
41254
+ event: "session_event_log_v2_loaded",
41255
+ sessionId: command.sessionId
41256
+ });
41257
+ send(socket, {
41258
+ events: {
41259
+ events: {
41260
+ events,
41261
+ nextCursor: replay.nextCursor,
41262
+ sessionGenerationId: replay.sessionGenerationId,
41263
+ tailCursor,
41264
+ truncated: replay.truncated,
41265
+ version: 2
41266
+ },
41267
+ queuedPromptRequests: []
41268
+ },
41269
+ kind: SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND,
41270
+ requestId: command.requestId,
41271
+ sessionId: command.sessionId
41272
+ });
41273
+ } catch (error62) {
41274
+ if (!signal.aborted) {
41275
+ diagnostics.daemonDiagnostic(
41276
+ "session_history_v2_load_failed",
41277
+ command.requestId,
41278
+ {
41279
+ agentId: command.agentId,
41280
+ code: operationErrorCode(error62),
41281
+ sessionId: command.sessionId
41282
+ },
41283
+ error62
41284
+ );
41285
+ audit.record({
41286
+ commandId: command.requestId,
41287
+ details: { agentId: command.agentId, code: operationErrorCode(error62) },
41288
+ event: "session_history_v2_load_failed",
41289
+ sessionId: command.sessionId
41290
+ });
41291
+ reportOperationFailure(socket, command.requestId, command.sessionId, error62);
41292
+ }
41293
+ }
41294
+ }
41039
41295
 
41040
41296
  // src/acp/session-config/apply-session-configuration.ts
41041
41297
  import { randomUUID as randomUUID6 } from "node:crypto";
@@ -41785,6 +42041,20 @@ function createDaemonCommandHandler({
41785
42041
  );
41786
42042
  return;
41787
42043
  }
42044
+ if (kind === SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND) {
42045
+ void executeSessionPreviewHistoryPageLoad(
42046
+ socket,
42047
+ message,
42048
+ config2,
42049
+ directories,
42050
+ audit,
42051
+ diagnostics,
42052
+ sessions,
42053
+ eventLogV2,
42054
+ signal
42055
+ );
42056
+ return;
42057
+ }
41788
42058
  if (kind === NATIVE_SESSION_CANCEL_KIND) {
41789
42059
  nativeRequestHandler.cancel(message);
41790
42060
  return;
@@ -42756,7 +43026,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
42756
43026
  publishCatalog: async (installationSignal) => await publishAgentCatalog(config2, installationSignal),
42757
43027
  stateDirectory
42758
43028
  });
42759
- const channelHash = createHash6("sha256").update(config2.channelId).digest("hex");
43029
+ const channelHash = createHash7("sha256").update(config2.channelId).digest("hex");
42760
43030
  const sessionDatabase = openAcpSessionDatabase(join18(stateDirectory, "sessions", `${channelHash}.sqlite`));
42761
43031
  let eventsV2;
42762
43032
  try {
@@ -42782,13 +43052,16 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
42782
43052
  }, eventLogV2.record),
42783
43053
  sessionStore,
42784
43054
  {
42785
- read: async (options2, nativeSessionId, nativeTurn) => options2.agent.id === "codex" ? (await readCodexFullHistory(
42786
- options2.agent,
42787
- options2.cwd,
42788
- nativeSessionId,
42789
- options2.signal,
42790
- nativeTurn
42791
- )).history : null
43055
+ access: (options2) => options2.agent.id === "codex" ? {
43056
+ kind: "direct",
43057
+ read: async (nativeSessionId, nativeTurn) => (await readCodexFullHistory(
43058
+ options2.agent,
43059
+ options2.cwd,
43060
+ nativeSessionId,
43061
+ options2.signal,
43062
+ nativeTurn
43063
+ )).history
43064
+ } : { kind: "acp" }
42792
43065
  },
42793
43066
  "native",
42794
43067
  publisher.publishStatus,
@@ -42964,7 +43237,7 @@ import { basename as basename6, resolve as resolve7 } from "node:path";
42964
43237
  import { fetch as fetch4 } from "undici";
42965
43238
 
42966
43239
  // src/storage/runtime-installation-store.ts
42967
- import { createHash as createHash7, randomUUID as randomUUID9 } from "node:crypto";
43240
+ import { createHash as createHash8, randomUUID as randomUUID9 } from "node:crypto";
42968
43241
  import { mkdir as mkdir5, open as open5, readdir as readdir4, rename as rename4, unlink, writeFile as writeFile4 } from "node:fs/promises";
42969
43242
  import { dirname as dirname6, join as join19, resolve as resolve6 } from "node:path";
42970
43243
  var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
@@ -43100,7 +43373,7 @@ function installationId() {
43100
43373
  return `min_${randomUUID9().replaceAll("-", "")}`;
43101
43374
  }
43102
43375
  function channelIndexFileName(channelId) {
43103
- return `mci_${createHash7("sha256").update(channelId).digest("hex")}.json`;
43376
+ return `mci_${createHash8("sha256").update(channelId).digest("hex")}.json`;
43104
43377
  }
43105
43378
  function decodeInstallationPointer(value) {
43106
43379
  if (!isRecord10(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {