@moxt-ai/mobius 0.0.186 → 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 (39) 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/codex/agent.d.ts.map +1 -1
  6. package/dist/acp/codex/agent.js +3 -2
  7. package/dist/acp/codex/agent.js.map +1 -1
  8. package/dist/acp/session-contracts.d.ts +10 -3
  9. package/dist/acp/session-contracts.d.ts.map +1 -1
  10. package/dist/acp/session-contracts.js +3 -0
  11. package/dist/acp/session-contracts.js.map +1 -1
  12. package/dist/acp/session-event-store-v2.d.ts +1 -0
  13. package/dist/acp/session-event-store-v2.d.ts.map +1 -1
  14. package/dist/acp/session-event-store-v2.js +3 -0
  15. package/dist/acp/session-event-store-v2.js.map +1 -1
  16. package/dist/cli.js +319 -45
  17. package/dist/cli.js.map +4 -4
  18. package/dist/daemon-command-handler.d.ts.map +1 -1
  19. package/dist/daemon-command-handler.js +6 -2
  20. package/dist/daemon-command-handler.js.map +1 -1
  21. package/dist/daemon-history-commands.d.ts +2 -1
  22. package/dist/daemon-history-commands.d.ts.map +1 -1
  23. package/dist/daemon-history-commands.js +54 -1
  24. package/dist/daemon-history-commands.js.map +1 -1
  25. package/dist/index.js +320 -46
  26. package/dist/index.js.map +4 -4
  27. package/dist/native-sessions/codex-history.d.ts.map +1 -1
  28. package/dist/native-sessions/codex-history.js +9 -1
  29. package/dist/native-sessions/codex-history.js.map +1 -1
  30. package/dist/native-sessions/native-history-events-v2.d.ts +8 -0
  31. package/dist/native-sessions/native-history-events-v2.d.ts.map +1 -0
  32. package/dist/native-sessions/native-history-events-v2.js +147 -0
  33. package/dist/native-sessions/native-history-events-v2.js.map +1 -0
  34. package/dist/run-daemon.d.ts.map +1 -1
  35. package/dist/run-daemon.js +6 -3
  36. package/dist/run-daemon.js.map +1 -1
  37. package/dist/runtime.js +318 -44
  38. package/dist/runtime.js.map +4 -4
  39. 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
  });
@@ -34759,7 +34932,9 @@ var CodexAcpAgent = class {
34759
34932
  "thread/fork",
34760
34933
  {
34761
34934
  cwd: context.params.cwd,
34762
- excludeTurns: false,
34935
+ // Fork keeps the native context; its response only needs the new identity
34936
+ // and settings. History is read through the separate history boundary.
34937
+ excludeTurns: true,
34763
34938
  threadId: context.params.sessionId
34764
34939
  },
34765
34940
  AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
@@ -34768,7 +34943,6 @@ var CodexAcpAgent = class {
34768
34943
  this.#nativeSessionId = forked.thread.id;
34769
34944
  this.#settings.selectRestoredThread(forked);
34770
34945
  await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
34771
- await this.#replayHistory(forked.thread.turns);
34772
34946
  await this.#emitAvailableCommands();
34773
34947
  return { configOptions: this.#settings.configOptions(), sessionId: forked.thread.id };
34774
34948
  }).onRequest(methods4.agent.session.resume, async (context) => {
@@ -35814,7 +35988,7 @@ var OhMyPiAgentSpecification = class extends DirectAcpAgentDefinition {
35814
35988
  import { join as join11 } from "node:path";
35815
35989
 
35816
35990
  // src/agent-installation/managed-agent-archive.ts
35817
- import { createHash as createHash2 } from "node:crypto";
35991
+ import { createHash as createHash3 } from "node:crypto";
35818
35992
  import { createReadStream } from "node:fs";
35819
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";
35820
35994
  import { delimiter as delimiter2, dirname as dirname3, isAbsolute as isAbsolute7, join as join10, relative as relative3, sep as sep3 } from "node:path";
@@ -35927,7 +36101,7 @@ function isContainedPath3(root, candidate) {
35927
36101
  }
35928
36102
  async function hashFile(path2, signal) {
35929
36103
  signal.throwIfAborted();
35930
- const digest = createHash2("sha256");
36104
+ const digest = createHash3("sha256");
35931
36105
  const stream = createReadStream(path2, { signal });
35932
36106
  try {
35933
36107
  for await (const chunk of stream) {
@@ -37125,7 +37299,7 @@ async function discoverLocalAgentInventory(options) {
37125
37299
  }
37126
37300
 
37127
37301
  // src/storage/runtime-installation-store.ts
37128
- import { createHash as createHash3, randomUUID as randomUUID3 } from "node:crypto";
37302
+ import { createHash as createHash4, randomUUID as randomUUID3 } from "node:crypto";
37129
37303
  import { mkdir as mkdir5, open as open5, readdir as readdir3, rename as rename4, unlink, writeFile as writeFile4 } from "node:fs/promises";
37130
37304
  import { dirname as dirname4, join as join16, resolve as resolve4 } from "node:path";
37131
37305
  var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
@@ -37261,7 +37435,7 @@ function installationId() {
37261
37435
  return `min_${randomUUID3().replaceAll("-", "")}`;
37262
37436
  }
37263
37437
  function channelIndexFileName(channelId) {
37264
- return `mci_${createHash3("sha256").update(channelId).digest("hex")}.json`;
37438
+ return `mci_${createHash4("sha256").update(channelId).digest("hex")}.json`;
37265
37439
  }
37266
37440
  function decodeInstallationPointer(value) {
37267
37441
  if (!isRecord9(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
@@ -37960,7 +38134,7 @@ function isRuntimeRelayRevocation(closeCode, closeReason) {
37960
38134
  }
37961
38135
 
37962
38136
  // src/run-daemon.ts
37963
- import { createHash as createHash7, randomUUID as randomUUID9 } from "node:crypto";
38137
+ import { createHash as createHash8, randomUUID as randomUUID9 } from "node:crypto";
37964
38138
  import { join as join19 } from "node:path";
37965
38139
  import { styleText } from "node:util";
37966
38140
 
@@ -38746,7 +38920,7 @@ import { WebSocket as WebSocket2 } from "undici";
38746
38920
  import { WebSocket } from "undici";
38747
38921
 
38748
38922
  // src/prompt-artifact-resolver.ts
38749
- import { createHash as createHash4 } from "node:crypto";
38923
+ import { createHash as createHash5 } from "node:crypto";
38750
38924
  import { fetch as fetch4 } from "undici";
38751
38925
  var ARTIFACT_SCHEME = "mobius-artifact:";
38752
38926
  var ARTIFACT_DOWNLOAD_TIMEOUT_MILLISECONDS = 2e4;
@@ -38884,7 +39058,7 @@ async function download(config2, command, reference, signal) {
38884
39058
  );
38885
39059
  }
38886
39060
  const bytes = await responseBytes(response, reference.byteLength, requestSignal);
38887
- if (createHash4("sha256").update(bytes).digest("hex") !== reference.sha256) {
39061
+ if (createHash5("sha256").update(bytes).digest("hex") !== reference.sha256) {
38888
39062
  throw new PromptArtifactError(
38889
39063
  "artifact_integrity_failed",
38890
39064
  "The prompt artifact failed integrity validation"
@@ -39905,6 +40079,14 @@ var historyItemSchema = external_exports.discriminatedUnion("type", [
39905
40079
  dynamicToolCallSchema,
39906
40080
  planSchema
39907
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
+ };
39908
40090
  function bounded(value, maximum) {
39909
40091
  return value.slice(0, maximum);
39910
40092
  }
@@ -39944,7 +40126,7 @@ function formatted(value) {
39944
40126
  }
39945
40127
  return JSON.stringify(value) ?? "";
39946
40128
  }
39947
- function toolStatus(status) {
40129
+ function toolStatus2(status) {
39948
40130
  return status === "inProgress" ? "running" : status === "completed" ? "completed" : "failed";
39949
40131
  }
39950
40132
  function diffDisplayContent(path2, newText) {
@@ -40151,7 +40333,7 @@ function decodeHistory(thread, value, options) {
40151
40333
  formatted_output: historyItem.aggregatedOutput ?? "",
40152
40334
  ...historyItem.exitCode == null ? {} : { exit_code: historyItem.exitCode }
40153
40335
  }),
40154
- status: toolStatus(historyItem.status),
40336
+ status: toolStatus2(historyItem.status),
40155
40337
  title: historyItem.command,
40156
40338
  toolKind: action
40157
40339
  })
@@ -40173,7 +40355,7 @@ function decodeHistory(thread, value, options) {
40173
40355
  locations: paths,
40174
40356
  name: "",
40175
40357
  output: "",
40176
- status: toolStatus(historyItem.status),
40358
+ status: toolStatus2(historyItem.status),
40177
40359
  title: paths.join(", "),
40178
40360
  toolKind: "edit"
40179
40361
  })
@@ -40191,7 +40373,7 @@ function decodeHistory(thread, value, options) {
40191
40373
  locations: [],
40192
40374
  name: historyItem.tool,
40193
40375
  output: formatted(historyItem.error ?? historyItem.result),
40194
- status: toolStatus(historyItem.status),
40376
+ status: toolStatus2(historyItem.status),
40195
40377
  title: `${historyItem.server}/${historyItem.tool}`,
40196
40378
  toolKind: "other"
40197
40379
  })
@@ -40209,7 +40391,7 @@ function decodeHistory(thread, value, options) {
40209
40391
  locations: [],
40210
40392
  name: historyItem.tool,
40211
40393
  output: formatted(historyItem.contentItems),
40212
- status: toolStatus(historyItem.status),
40394
+ status: toolStatus2(historyItem.status),
40213
40395
  title: historyItem.namespace == null ? historyItem.tool : `${historyItem.namespace}/${historyItem.tool}`,
40214
40396
  toolKind: "other"
40215
40397
  })
@@ -40375,7 +40557,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
40375
40557
  fail(
40376
40558
  new AcpExecutionError(
40377
40559
  "Saved Codex history could not be read.",
40378
- { cause: message.error },
40560
+ { cause: new CodexHistoryResponseError(message.error) },
40379
40561
  "native_history_unavailable"
40380
40562
  )
40381
40563
  );
@@ -40883,7 +41065,7 @@ var NativeSessionService = class {
40883
41065
  };
40884
41066
 
40885
41067
  // src/relay-connection/daemon-operation-state.ts
40886
- import { createHash as createHash5, randomUUID as randomUUID6 } from "node:crypto";
41068
+ import { createHash as createHash6, randomUUID as randomUUID6 } from "node:crypto";
40887
41069
  var MAX_TERMINAL_RECEIPTS = 1024;
40888
41070
  function isTerminal(state) {
40889
41071
  return state === "succeeded" || state === "failed" || state === "cancelled";
@@ -40892,7 +41074,7 @@ var DaemonOperationState = class {
40892
41074
  #executions = /* @__PURE__ */ new Map();
40893
41075
  #terminalCount = 0;
40894
41076
  claimExecution = (commandId, sessionId, commandJson) => {
40895
- const commandHash = createHash5("sha256").update(commandJson).digest("hex");
41077
+ const commandHash = createHash6("sha256").update(commandJson).digest("hex");
40896
41078
  const existing = this.#executions.get(commandId);
40897
41079
  if (existing !== void 0) {
40898
41080
  if (existing.sessionId !== sessionId || existing.commandHash !== commandHash) {
@@ -41114,7 +41296,7 @@ import { WebSocket as WebSocket5 } from "undici";
41114
41296
  import { WebSocket as WebSocket3 } from "undici";
41115
41297
 
41116
41298
  // src/agent-catalog/discover-agent-settings.ts
41117
- import { createHash as createHash6 } from "node:crypto";
41299
+ import { createHash as createHash7 } from "node:crypto";
41118
41300
 
41119
41301
  // src/agent-catalog/agent-settings-base.ts
41120
41302
  var AgentSettingsConfigurationError = class extends Error {
@@ -41578,7 +41760,7 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
41578
41760
  unsupportedModelIds: modelEffort.unsupportedModelIds,
41579
41761
  valuesByModel: {}
41580
41762
  };
41581
- return createHash6("sha256").update(
41763
+ return createHash7("sha256").update(
41582
41764
  JSON.stringify({
41583
41765
  adapterVersion: agent.kind === "acp-adapter-process" ? agent.adapterVersion : agent.agentVersion,
41584
41766
  agentId: agent.id,
@@ -41890,7 +42072,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
41890
42072
  },
41891
42073
  queuedPromptRequests: recovery.queuedPromptRequests
41892
42074
  },
41893
- kind: "session.live-history.v2.page.loaded",
42075
+ kind: SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND,
41894
42076
  requestId: command.requestId,
41895
42077
  sessionId: command.sessionId
41896
42078
  });
@@ -41919,6 +42101,81 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
41919
42101
  }
41920
42102
  }
41921
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
+ }
41922
42179
 
41923
42180
  // src/acp/session-config/apply-session-configuration.ts
41924
42181
  import { randomUUID as randomUUID7 } from "node:crypto";
@@ -42668,6 +42925,20 @@ function createDaemonCommandHandler({
42668
42925
  );
42669
42926
  return;
42670
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
+ }
42671
42942
  if (kind === NATIVE_SESSION_CANCEL_KIND) {
42672
42943
  nativeRequestHandler.cancel(message);
42673
42944
  return;
@@ -43619,7 +43890,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
43619
43890
  publishCatalog: async (installationSignal) => await publishAgentCatalog(config2, installationSignal),
43620
43891
  stateDirectory
43621
43892
  });
43622
- const channelHash = createHash7("sha256").update(config2.channelId).digest("hex");
43893
+ const channelHash = createHash8("sha256").update(config2.channelId).digest("hex");
43623
43894
  const sessionDatabase = openAcpSessionDatabase(join19(stateDirectory, "sessions", `${channelHash}.sqlite`));
43624
43895
  let eventsV2;
43625
43896
  try {
@@ -43645,13 +43916,16 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
43645
43916
  }, eventLogV2.record),
43646
43917
  sessionStore,
43647
43918
  {
43648
- read: async (options2, nativeSessionId, nativeTurn) => options2.agent.id === "codex" ? (await readCodexFullHistory(
43649
- options2.agent,
43650
- options2.cwd,
43651
- nativeSessionId,
43652
- options2.signal,
43653
- nativeTurn
43654
- )).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" }
43655
43929
  },
43656
43930
  "native",
43657
43931
  publisher.publishStatus,