@moxt-ai/mobius 0.0.91 → 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/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.91",
3384
+ version: "0.0.93",
3385
3385
  description: "Mobius CLI for pairing and running local AI agent services.",
3386
3386
  type: "module",
3387
3387
  bin: {
@@ -29128,6 +29128,7 @@ var nativeSessionTurnForkCommandSchema = external_exports.strictObject({
29128
29128
  }).readonly();
29129
29129
  var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
29130
29130
  external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
29131
+ external_exports.strictObject({ ...identity, action: external_exports.literal("history"), entryId: identifier }).readonly(),
29131
29132
  external_exports.strictObject({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifier }).readonly(),
29132
29133
  external_exports.strictObject({
29133
29134
  ...identity,
@@ -29148,6 +29149,7 @@ var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
29148
29149
  ]);
29149
29150
  var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
29150
29151
  external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
29152
+ external_exports.strictObject({ ...identity, action: external_exports.literal("history"), entryId: identifier }).readonly(),
29151
29153
  external_exports.strictObject({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifier }).readonly(),
29152
29154
  external_exports.strictObject({
29153
29155
  ...identity,
@@ -29174,6 +29176,7 @@ var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
29174
29176
  ]);
29175
29177
  var nativeSessionEntrySchema = external_exports.strictObject({
29176
29178
  entryId: identifier,
29179
+ mobiusSessionIds: external_exports.array(identifier).max(500).readonly(),
29177
29180
  title: external_exports.string().max(500),
29178
29181
  directoryId,
29179
29182
  directoryLabel: external_exports.string().min(1).max(2048),
@@ -29214,6 +29217,13 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
29214
29217
  history: sessionHistorySchema,
29215
29218
  title: external_exports.string().max(500)
29216
29219
  }).readonly(),
29220
+ external_exports.strictObject({
29221
+ ...resultEnvelope,
29222
+ action: external_exports.literal("history"),
29223
+ entryId: identifier,
29224
+ history: sessionHistorySchema,
29225
+ title: external_exports.string().max(500)
29226
+ }).readonly(),
29217
29227
  external_exports.strictObject({
29218
29228
  ...resultEnvelope,
29219
29229
  action: external_exports.literal("delete"),
@@ -41365,6 +41375,7 @@ var AcpSessionManager = class {
41365
41375
  setObserver = (observer) => {
41366
41376
  this.#observer = observer;
41367
41377
  };
41378
+ findLinkedSessions = (agentId, nativeSessionId) => this.#store.findNative(agentId, nativeSessionId);
41368
41379
  #notifyProcessCapacityChanged() {
41369
41380
  const changed = this.#processCapacityChanged;
41370
41381
  this.#processCapacityChanged = Promise.withResolvers();
@@ -43416,7 +43427,7 @@ var turnsSchema = external_exports.object({
43416
43427
  error: external_exports.unknown().nullish(),
43417
43428
  items: external_exports.array(external_exports.unknown()).max(1e5)
43418
43429
  })
43419
- ).max(SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT),
43430
+ ).max(SESSION_HISTORY_MESSAGE_LIMIT),
43420
43431
  nextCursor: external_exports.string().nullish()
43421
43432
  });
43422
43433
  var itemTypeSchema = external_exports.object({ type: external_exports.string().min(1).max(80) });
@@ -43603,7 +43614,7 @@ function decodeHistory(thread, value, options) {
43603
43614
  messages.push(message);
43604
43615
  characters += messageSize(message);
43605
43616
  }
43606
- while (messages.length > SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT || characters > SESSION_HISTORY_CHARACTER_LIMIT) {
43617
+ while (messages.length > (options.detail === "rich" ? SESSION_HISTORY_MESSAGE_LIMIT : SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT) || characters > SESSION_HISTORY_CHARACTER_LIMIT) {
43607
43618
  const removed = messages.shift();
43608
43619
  if (removed !== void 0) {
43609
43620
  characters -= messageSize(removed);
@@ -43643,6 +43654,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
43643
43654
  });
43644
43655
  const response = Promise.withResolvers();
43645
43656
  let state = { kind: "initializing", requestId: 1 };
43657
+ const seenCursors = /* @__PURE__ */ new Set();
43646
43658
  let pending = "";
43647
43659
  let receivedBytes = 0;
43648
43660
  const fail = (cause) => response.reject(
@@ -43709,7 +43721,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
43709
43721
  break;
43710
43722
  case "metadata": {
43711
43723
  const { thread } = threadSchema.parse(message.result);
43712
- state = { kind: "turns", requestId: 3, thread };
43724
+ state = { kind: "turns", requestId: 3, thread, pages: [] };
43713
43725
  send2({
43714
43726
  id: state.requestId,
43715
43727
  method: "thread/turns/list",
@@ -43722,9 +43734,45 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
43722
43734
  });
43723
43735
  break;
43724
43736
  }
43725
- case "turns":
43726
- response.resolve(decodeHistory(state.thread, message.result, options));
43727
- return;
43737
+ case "turns": {
43738
+ const page = turnsSchema.parse(message.result);
43739
+ const pages = [...state.pages, ...page.data];
43740
+ const maxTurns = options.detail === "rich" ? SESSION_HISTORY_MESSAGE_LIMIT : SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT;
43741
+ if (page.nextCursor == null || pages.length >= maxTurns) {
43742
+ response.resolve(
43743
+ decodeHistory(
43744
+ state.thread,
43745
+ {
43746
+ data: pages.slice(0, maxTurns),
43747
+ nextCursor: page.nextCursor
43748
+ },
43749
+ options
43750
+ )
43751
+ );
43752
+ return;
43753
+ }
43754
+ if (page.data.length === 0 || seenCursors.has(page.nextCursor)) {
43755
+ throw new AcpExecutionError(
43756
+ "Codex repeated a history page cursor.",
43757
+ {},
43758
+ "invalid_native_session_response"
43759
+ );
43760
+ }
43761
+ seenCursors.add(page.nextCursor);
43762
+ state = { kind: "turns", requestId: state.requestId + 1, thread: state.thread, pages };
43763
+ send2({
43764
+ id: state.requestId,
43765
+ method: "thread/turns/list",
43766
+ params: {
43767
+ threadId: nativeSessionId,
43768
+ cursor: page.nextCursor,
43769
+ limit: Math.min(SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT, maxTurns - pages.length),
43770
+ sortDirection: "desc",
43771
+ itemsView: options.detail === "rich" ? "full" : "summary"
43772
+ }
43773
+ });
43774
+ break;
43775
+ }
43728
43776
  default: {
43729
43777
  const unhandled = state;
43730
43778
  throw new Error(`Unknown history read state: ${String(unhandled)}`);
@@ -43745,7 +43793,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
43745
43793
  );
43746
43794
  const timeout = setTimeout(
43747
43795
  () => fail(new AcpExecutionError("Reading saved Codex history timed out.", {}, "native_history_timeout")),
43748
- 15e3
43796
+ options.detail === "rich" ? 6e4 : 15e3
43749
43797
  );
43750
43798
  child.stdout.setEncoding("utf8");
43751
43799
  child.stdout.on("data", onData);
@@ -43842,6 +43890,7 @@ var NativeSessionService = class {
43842
43890
  });
43843
43891
  return {
43844
43892
  entryId,
43893
+ mobiusSessionIds: this.#sessions.findLinkedSessions(command.agentId, info.sessionId).filter((session) => session.prompted && session.cwd === authorized.cwd).map((session) => session.sessionId),
43845
43894
  title: info.title ?? "Untitled session",
43846
43895
  directoryId: authorized.directoryId,
43847
43896
  directoryLabel: authorized.directoryLabel,
@@ -43947,6 +43996,18 @@ var NativeSessionService = class {
43947
43996
  );
43948
43997
  }
43949
43998
  const target = await this.resolveTarget(command, options, selected);
43999
+ if (command.action === "history") {
44000
+ const history = await this.readHistory(command, options, target, signal);
44001
+ signal.throwIfAborted();
44002
+ this.record(command, "native_session_history_read");
44003
+ return {
44004
+ ...envelope2,
44005
+ action: "history",
44006
+ entryId: command.entryId,
44007
+ history,
44008
+ title: target.info.title ?? "Untitled session"
44009
+ };
44010
+ }
43950
44011
  if (command.action === "preview") {
43951
44012
  const history = await this.previewHistory(command, options, target, signal);
43952
44013
  signal.throwIfAborted();
@@ -44120,6 +44181,25 @@ var NativeSessionService = class {
44120
44181
  }
44121
44182
  return snapshot.history;
44122
44183
  };
44184
+ readHistory = async (command, options, target, signal) => {
44185
+ if (options.agent.id !== "codex") {
44186
+ throw new AcpExecutionError(
44187
+ "Native history is unavailable for this Agent",
44188
+ {},
44189
+ "native_session_unsupported"
44190
+ );
44191
+ }
44192
+ const snapshot = await readCodexFullHistory(options.agent, target.cwd, target.info.sessionId, signal);
44193
+ const resolved = await this.#directories.identify(command.bindingId, snapshot.cwd, signal);
44194
+ if (snapshot.nativeSessionId !== target.info.sessionId || resolved.path !== target.cwd) {
44195
+ throw new AcpExecutionError(
44196
+ "Codex returned history for a different session or workspace.",
44197
+ {},
44198
+ "invalid_native_session_response"
44199
+ );
44200
+ }
44201
+ return snapshot.history;
44202
+ };
44123
44203
  authorizeEntry = async (command, options, info) => {
44124
44204
  try {
44125
44205
  const primary = await this.#directories.identify(command.bindingId, info.cwd, options.signal);
@@ -48800,22 +48880,22 @@ async function waitForManagerExit(stateDirectory, signal) {
48800
48880
  const deadline = AbortSignal.any([signal, AbortSignal.timeout(1e4)]);
48801
48881
  while (!deadline.aborted) {
48802
48882
  try {
48803
- await sendControlRequest(stateDirectory, { kind: "list" }, AbortSignal.timeout(200));
48883
+ await readFile3(join18(stateDirectory, "manager.lock"), "utf8");
48804
48884
  } catch (cause) {
48805
- if (isNodeError2(cause, "ENOENT") || isNodeError2(cause, "ECONNREFUSED")) {
48885
+ if (isNodeError2(cause, "ENOENT")) {
48806
48886
  return;
48807
48887
  }
48888
+ throw cause;
48808
48889
  }
48809
48890
  await new Promise((resolve8, reject) => {
48810
- const timeout = setTimeout(resolve8, 20);
48811
- deadline.addEventListener(
48812
- "abort",
48813
- () => {
48814
- clearTimeout(timeout);
48815
- reject(deadline.reason);
48816
- },
48817
- { once: true }
48818
- );
48891
+ const timeout = setTimeout(finish, 20);
48892
+ const abort = () => finish(deadline.reason);
48893
+ function finish(cause) {
48894
+ clearTimeout(timeout);
48895
+ deadline.removeEventListener("abort", abort);
48896
+ cause === void 0 ? resolve8() : reject(cause);
48897
+ }
48898
+ deadline.addEventListener("abort", abort, { once: true });
48819
48899
  });
48820
48900
  }
48821
48901
  throw deadline.reason;
@@ -48909,6 +48989,7 @@ async function runManager(installation, managerVersion, signal) {
48909
48989
  const shutdown2 = new AbortController();
48910
48990
  const combined = AbortSignal.any([signal, shutdown2.signal]);
48911
48991
  const supervisor = new RuntimeSupervisor(installation);
48992
+ const sockets = /* @__PURE__ */ new Set();
48912
48993
  try {
48913
48994
  await supervisor.restore(combined);
48914
48995
  } catch (cause) {
@@ -48917,6 +48998,8 @@ async function runManager(installation, managerVersion, signal) {
48917
48998
  `);
48918
48999
  }
48919
49000
  const server = createServer((socket) => {
49001
+ sockets.add(socket);
49002
+ socket.once("close", () => sockets.delete(socket));
48920
49003
  void (async () => {
48921
49004
  try {
48922
49005
  const request = decodeCommand(await readSocketMessage(socket, combined), token);
@@ -48940,8 +49023,12 @@ async function runManager(installation, managerVersion, signal) {
48940
49023
  kind: "pair-removed"
48941
49024
  };
48942
49025
  } else {
48943
- response = { kind: "stopped" };
48944
- shutdown2.abort();
49026
+ const beginShutdown = () => shutdown2.abort();
49027
+ socket.once("close", beginShutdown);
49028
+ socket.once("error", beginShutdown);
49029
+ socket.end(`${JSON.stringify({ kind: "stopped" })}
49030
+ `, beginShutdown);
49031
+ return;
48945
49032
  }
48946
49033
  socket.end(`${JSON.stringify(response)}
48947
49034
  `);
@@ -48970,7 +49057,11 @@ async function runManager(installation, managerVersion, signal) {
48970
49057
  }
48971
49058
  try {
48972
49059
  await new Promise((resolve8) => combined.addEventListener("abort", () => resolve8(), { once: true }));
48973
- await new Promise((resolve8) => server.close(() => resolve8()));
49060
+ const serverClosed = new Promise((resolve8) => server.close(() => resolve8()));
49061
+ for (const socket of sockets) {
49062
+ socket.destroy();
49063
+ }
49064
+ await serverClosed;
48974
49065
  await supervisor.close();
48975
49066
  } finally {
48976
49067
  if (process.platform !== "win32") {