@moxt-ai/mobius 0.0.92 → 0.0.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -21006,6 +21006,7 @@ var nativeSessionTurnForkCommandSchema = external_exports.strictObject({
21006
21006
  }).readonly();
21007
21007
  var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
21008
21008
  external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
21009
+ external_exports.strictObject({ ...identity, action: external_exports.literal("history"), entryId: identifier }).readonly(),
21009
21010
  external_exports.strictObject({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifier }).readonly(),
21010
21011
  external_exports.strictObject({
21011
21012
  ...identity,
@@ -21026,6 +21027,7 @@ var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
21026
21027
  ]);
21027
21028
  var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
21028
21029
  external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
21030
+ external_exports.strictObject({ ...identity, action: external_exports.literal("history"), entryId: identifier }).readonly(),
21029
21031
  external_exports.strictObject({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifier }).readonly(),
21030
21032
  external_exports.strictObject({
21031
21033
  ...identity,
@@ -21052,6 +21054,7 @@ var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
21052
21054
  ]);
21053
21055
  var nativeSessionEntrySchema = external_exports.strictObject({
21054
21056
  entryId: identifier,
21057
+ mobiusSessionIds: external_exports.array(identifier).max(500).readonly(),
21055
21058
  title: external_exports.string().max(500),
21056
21059
  directoryId,
21057
21060
  directoryLabel: external_exports.string().min(1).max(2048),
@@ -21092,6 +21095,13 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
21092
21095
  history: sessionHistorySchema,
21093
21096
  title: external_exports.string().max(500)
21094
21097
  }).readonly(),
21098
+ external_exports.strictObject({
21099
+ ...resultEnvelope,
21100
+ action: external_exports.literal("history"),
21101
+ entryId: identifier,
21102
+ history: sessionHistorySchema,
21103
+ title: external_exports.string().max(500)
21104
+ }).readonly(),
21095
21105
  external_exports.strictObject({
21096
21106
  ...resultEnvelope,
21097
21107
  action: external_exports.literal("delete"),
@@ -33044,6 +33054,7 @@ var AcpSessionManager = class {
33044
33054
  setObserver = (observer) => {
33045
33055
  this.#observer = observer;
33046
33056
  };
33057
+ findLinkedSessions = (agentId, nativeSessionId) => this.#store.findNative(agentId, nativeSessionId);
33047
33058
  #notifyProcessCapacityChanged() {
33048
33059
  const changed = this.#processCapacityChanged;
33049
33060
  this.#processCapacityChanged = Promise.withResolvers();
@@ -39977,7 +39988,7 @@ var turnsSchema = external_exports.object({
39977
39988
  error: external_exports.unknown().nullish(),
39978
39989
  items: external_exports.array(external_exports.unknown()).max(1e5)
39979
39990
  })
39980
- ).max(SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT),
39991
+ ).max(SESSION_HISTORY_MESSAGE_LIMIT),
39981
39992
  nextCursor: external_exports.string().nullish()
39982
39993
  });
39983
39994
  var itemTypeSchema = external_exports.object({ type: external_exports.string().min(1).max(80) });
@@ -40164,7 +40175,7 @@ function decodeHistory(thread, value, options) {
40164
40175
  messages.push(message);
40165
40176
  characters += messageSize(message);
40166
40177
  }
40167
- while (messages.length > SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT || characters > SESSION_HISTORY_CHARACTER_LIMIT) {
40178
+ while (messages.length > (options.detail === "rich" ? SESSION_HISTORY_MESSAGE_LIMIT : SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT) || characters > SESSION_HISTORY_CHARACTER_LIMIT) {
40168
40179
  const removed = messages.shift();
40169
40180
  if (removed !== void 0) {
40170
40181
  characters -= messageSize(removed);
@@ -40204,6 +40215,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
40204
40215
  });
40205
40216
  const response = Promise.withResolvers();
40206
40217
  let state = { kind: "initializing", requestId: 1 };
40218
+ const seenCursors = /* @__PURE__ */ new Set();
40207
40219
  let pending = "";
40208
40220
  let receivedBytes = 0;
40209
40221
  const fail = (cause) => response.reject(
@@ -40270,7 +40282,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
40270
40282
  break;
40271
40283
  case "metadata": {
40272
40284
  const { thread } = threadSchema.parse(message.result);
40273
- state = { kind: "turns", requestId: 3, thread };
40285
+ state = { kind: "turns", requestId: 3, thread, pages: [] };
40274
40286
  send2({
40275
40287
  id: state.requestId,
40276
40288
  method: "thread/turns/list",
@@ -40283,9 +40295,45 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
40283
40295
  });
40284
40296
  break;
40285
40297
  }
40286
- case "turns":
40287
- response.resolve(decodeHistory(state.thread, message.result, options));
40288
- return;
40298
+ case "turns": {
40299
+ const page = turnsSchema.parse(message.result);
40300
+ const pages = [...state.pages, ...page.data];
40301
+ const maxTurns = options.detail === "rich" ? SESSION_HISTORY_MESSAGE_LIMIT : SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT;
40302
+ if (page.nextCursor == null || pages.length >= maxTurns) {
40303
+ response.resolve(
40304
+ decodeHistory(
40305
+ state.thread,
40306
+ {
40307
+ data: pages.slice(0, maxTurns),
40308
+ nextCursor: page.nextCursor
40309
+ },
40310
+ options
40311
+ )
40312
+ );
40313
+ return;
40314
+ }
40315
+ if (page.data.length === 0 || seenCursors.has(page.nextCursor)) {
40316
+ throw new AcpExecutionError(
40317
+ "Codex repeated a history page cursor.",
40318
+ {},
40319
+ "invalid_native_session_response"
40320
+ );
40321
+ }
40322
+ seenCursors.add(page.nextCursor);
40323
+ state = { kind: "turns", requestId: state.requestId + 1, thread: state.thread, pages };
40324
+ send2({
40325
+ id: state.requestId,
40326
+ method: "thread/turns/list",
40327
+ params: {
40328
+ threadId: nativeSessionId,
40329
+ cursor: page.nextCursor,
40330
+ limit: Math.min(SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT, maxTurns - pages.length),
40331
+ sortDirection: "desc",
40332
+ itemsView: options.detail === "rich" ? "full" : "summary"
40333
+ }
40334
+ });
40335
+ break;
40336
+ }
40289
40337
  default: {
40290
40338
  const unhandled = state;
40291
40339
  throw new Error(`Unknown history read state: ${String(unhandled)}`);
@@ -40306,7 +40354,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
40306
40354
  );
40307
40355
  const timeout = setTimeout(
40308
40356
  () => fail(new AcpExecutionError("Reading saved Codex history timed out.", {}, "native_history_timeout")),
40309
- 15e3
40357
+ options.detail === "rich" ? 6e4 : 15e3
40310
40358
  );
40311
40359
  child.stdout.setEncoding("utf8");
40312
40360
  child.stdout.on("data", onData);
@@ -40403,6 +40451,7 @@ var NativeSessionService = class {
40403
40451
  });
40404
40452
  return {
40405
40453
  entryId,
40454
+ mobiusSessionIds: this.#sessions.findLinkedSessions(command.agentId, info.sessionId).filter((session) => session.prompted && session.cwd === authorized.cwd).map((session) => session.sessionId),
40406
40455
  title: info.title ?? "Untitled session",
40407
40456
  directoryId: authorized.directoryId,
40408
40457
  directoryLabel: authorized.directoryLabel,
@@ -40508,6 +40557,18 @@ var NativeSessionService = class {
40508
40557
  );
40509
40558
  }
40510
40559
  const target = await this.resolveTarget(command, options, selected);
40560
+ if (command.action === "history") {
40561
+ const history = await this.readHistory(command, options, target, signal);
40562
+ signal.throwIfAborted();
40563
+ this.record(command, "native_session_history_read");
40564
+ return {
40565
+ ...envelope2,
40566
+ action: "history",
40567
+ entryId: command.entryId,
40568
+ history,
40569
+ title: target.info.title ?? "Untitled session"
40570
+ };
40571
+ }
40511
40572
  if (command.action === "preview") {
40512
40573
  const history = await this.previewHistory(command, options, target, signal);
40513
40574
  signal.throwIfAborted();
@@ -40681,6 +40742,25 @@ var NativeSessionService = class {
40681
40742
  }
40682
40743
  return snapshot.history;
40683
40744
  };
40745
+ readHistory = async (command, options, target, signal) => {
40746
+ if (options.agent.id !== "codex") {
40747
+ throw new AcpExecutionError(
40748
+ "Native history is unavailable for this Agent",
40749
+ {},
40750
+ "native_session_unsupported"
40751
+ );
40752
+ }
40753
+ const snapshot = await readCodexFullHistory(options.agent, target.cwd, target.info.sessionId, signal);
40754
+ const resolved = await this.#directories.identify(command.bindingId, snapshot.cwd, signal);
40755
+ if (snapshot.nativeSessionId !== target.info.sessionId || resolved.path !== target.cwd) {
40756
+ throw new AcpExecutionError(
40757
+ "Codex returned history for a different session or workspace.",
40758
+ {},
40759
+ "invalid_native_session_response"
40760
+ );
40761
+ }
40762
+ return snapshot.history;
40763
+ };
40684
40764
  authorizeEntry = async (command, options, info) => {
40685
40765
  try {
40686
40766
  const primary = await this.#directories.identify(command.bindingId, info.cwd, options.signal);