@moxt-ai/mobius 0.0.293 → 0.0.295

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 (31) hide show
  1. package/dist/acp/harness/codex/agent.d.ts.map +1 -1
  2. package/dist/acp/harness/codex/agent.js +8 -2
  3. package/dist/acp/harness/codex/agent.js.map +1 -1
  4. package/dist/acp/harness/codex/borrowed-agent.d.ts +2 -4
  5. package/dist/acp/harness/codex/borrowed-agent.d.ts.map +1 -1
  6. package/dist/acp/harness/codex/borrowed-agent.js +2 -1
  7. package/dist/acp/harness/codex/borrowed-agent.js.map +1 -1
  8. package/dist/acp/harness/codex/owned-agent.d.ts +1 -0
  9. package/dist/acp/harness/codex/owned-agent.d.ts.map +1 -1
  10. package/dist/acp/harness/codex/owned-agent.js +1 -0
  11. package/dist/acp/harness/codex/owned-agent.js.map +1 -1
  12. package/dist/acp/harness/codex/session-agent.d.ts +1 -0
  13. package/dist/acp/harness/codex/session-agent.d.ts.map +1 -1
  14. package/dist/acp/protocol/session-capabilities.d.ts +2 -0
  15. package/dist/acp/protocol/session-capabilities.d.ts.map +1 -1
  16. package/dist/acp/protocol/session-capabilities.js +11 -0
  17. package/dist/acp/protocol/session-capabilities.js.map +1 -1
  18. package/dist/cli.js +191 -25
  19. package/dist/cli.js.map +2 -2
  20. package/dist/runtime.js +191 -25
  21. package/dist/runtime.js.map +2 -2
  22. package/dist/session/live/agent-session-restore.d.ts +1 -0
  23. package/dist/session/live/agent-session-restore.d.ts.map +1 -1
  24. package/dist/session/live/agent-session.d.ts +1 -0
  25. package/dist/session/live/agent-session.d.ts.map +1 -1
  26. package/dist/session/live/agent-session.js +5 -1
  27. package/dist/session/live/agent-session.js.map +1 -1
  28. package/dist/session/live/session-restore.d.ts.map +1 -1
  29. package/dist/session/live/session-restore.js +1 -0
  30. package/dist/session/live/session-restore.js.map +1 -1
  31. package/package.json +1 -1
package/dist/runtime.js CHANGED
@@ -958,6 +958,16 @@ function normalizeAcpCapabilities(initialized) {
958
958
  unstableForkSession: session?.fork != null
959
959
  });
960
960
  }
961
+ function restrictAcpSessionCapabilities(capabilities, response) {
962
+ if (!isRecord(response) || !isRecord(response["_meta"])) {
963
+ return capabilities;
964
+ }
965
+ const steering = response["_meta"]["steering"];
966
+ if (!isRecord(steering) || steering["supported"] !== false) {
967
+ return capabilities;
968
+ }
969
+ return Object.freeze({ ...capabilities, steering: false });
970
+ }
961
971
 
962
972
  // src/acp/agent/agent-definition.ts
963
973
  var AgentDefinition = class {
@@ -22572,7 +22582,7 @@ import { fetch as fetch3 } from "undici";
22572
22582
  // package.json
22573
22583
  var package_default = {
22574
22584
  name: "@moxt-ai/mobius",
22575
- version: "0.0.293",
22585
+ version: "0.0.295",
22576
22586
  description: "Mobius CLI for pairing and running local AI agent services.",
22577
22587
  type: "module",
22578
22588
  bin: {
@@ -22721,6 +22731,7 @@ import { mkdir as CL, readdir as snt, readFile as sne, rm as int2, writeFile as
22721
22731
  import { createRequire as ant } from "module";
22722
22732
  import { homedir as kL, tmpdir as cnt } from "os";
22723
22733
  import { dirname as RL, isAbsolute as ane, join as vn, relative as cne, resolve as Vh, sep as IL } from "path";
22734
+ import { createInterface as lnt } from "readline";
22724
22735
  import { fileURLToPath as unt } from "url";
22725
22736
  import { setMaxListeners as bae } from "events";
22726
22737
  import { spawn as BFe } from "child_process";
@@ -54174,6 +54185,78 @@ function mZ(e, t, n, r) {
54174
54185
  if (!p) p = `${r() || "Forked session"} (fork)`;
54175
54186
  return u.push({ type: "custom-title", sessionId: c, customTitle: p, uuid: zS(), timestamp: l }), { entries: u, forkedSessionId: c };
54176
54187
  }
54188
+ function BS(e) {
54189
+ return ["subagents", ...e.agentRelPath ?? [], e.kind === "agent" ? `agent-${e.agentId}` : "journal"].join("/");
54190
+ }
54191
+ async function KP(e, t, n, r, o, s = PKe) {
54192
+ let i = [], a = 0, c, l = false;
54193
+ for (let u = 0; u < s; u++) {
54194
+ let p = await e.readRecords(t, { order: "forward", maxBytes: OKe, ...c !== void 0 && { fromSeq: c } });
54195
+ if (!p.ok) throw new Ze(`importSessionToStore: transcript read failed (${p.error.code})`, "importSessionToStore: transcript read failed");
54196
+ for (let f of p.value.items) {
54197
+ let m = Buffer.from(f.data.buffer, f.data.byteOffset, f.data.byteLength).toString("utf8").replace(/\r?\n$/, "");
54198
+ if (!m) continue;
54199
+ try {
54200
+ i.push(lt(m));
54201
+ } catch (h) {
54202
+ ce(`importSessionToStore: skipping unparseable record ${f.seq}: ${h}`);
54203
+ continue;
54204
+ }
54205
+ if (a += m.length, i.length >= o || a >= Ou) await r.append(n, i), i = [], a = 0;
54206
+ }
54207
+ if (c = p.value.nextSeq, c === void 0) {
54208
+ l = true;
54209
+ break;
54210
+ }
54211
+ }
54212
+ if (!l) throw new Ze("importSessionToStore: transcript read did not end (page cap reached)", "importSessionToStore: transcript read did not end");
54213
+ if (i.length > 0) await r.append(n, i);
54214
+ }
54215
+ var OKe = 67108864;
54216
+ var PKe = 1e5;
54217
+ var IKe = 1e4;
54218
+ async function AZ(e, t, n, r = IKe) {
54219
+ let o = [], s = [{ namespace: "transcript", projectKey: t, sessionId: n }], i = /* @__PURE__ */ new Set([""]), a = /* @__PURE__ */ new Set(), c = 0;
54220
+ while (s.length > 0) {
54221
+ if (++c > r) throw Error("importSessionToStore: subagent listing did not end (scope cap reached)");
54222
+ let l = s.shift(), u = [];
54223
+ if ((await Ao((f) => e.listEntries(l, { skipKeyStats: true, skipScopeStats: true, ...f !== void 0 && { cursor: f } }), (f) => {
54224
+ for (let m of f) if (m.kind === "key" && m.key.namespace === "transcript") {
54225
+ let h = m.key.agentRelPath;
54226
+ if (h !== void 0 && !sr(h)) continue;
54227
+ let y = m.key.agentId !== void 0 ? pn(m.key.agentId) ? { kind: "agent", agentId: m.key.agentId, ...h && { agentRelPath: h } } : void 0 : m.key.journal === true && h !== void 0 ? { kind: "journal", agentRelPath: h } : void 0, _ = y && BS(y);
54228
+ if (y && _ !== void 0 && !a.has(_)) a.add(_), o.push(y);
54229
+ } else if (m.kind === "scope" && m.scope.namespace === "transcript" && m.scope.agentRelPath !== void 0 && sr(m.scope.agentRelPath) && !i.has(m.scope.agentRelPath.join("/"))) i.add(m.scope.agentRelPath.join("/")), u.push({ namespace: "transcript", projectKey: t, sessionId: n, agentRelPath: m.scope.agentRelPath });
54230
+ })).status !== "done") throw Error("importSessionToStore: subagent listing failed");
54231
+ s.unshift(...u);
54232
+ }
54233
+ return o;
54234
+ }
54235
+ function DKe(e, t, n) {
54236
+ return tn.sidecar(e, t, ["subagents", ...n.agentRelPath ?? [], n.kind === "agent" ? `agent-${n.agentId}.meta.json` : "journal.meta.json"]);
54237
+ }
54238
+ async function TZ(e, t, n, r) {
54239
+ let o = r.map((a) => ({ subpath: BS(a), key: DKe(t, n, a) })).filter(({ key: a }) => Ms(a) === void 0), s = /* @__PURE__ */ new Map();
54240
+ if (o.length === 0) return s;
54241
+ let i = await e.readText(o.map(({ key: a }) => a));
54242
+ if (i.ok) return i.value.items.forEach((a, c) => {
54243
+ if (a.found) s.set(o[c].subpath, a.value);
54244
+ }), s;
54245
+ if (!vZ(i.error)) throw wZ(i.error.code);
54246
+ for (let { subpath: a, key: c } of o) {
54247
+ let l = await e.readText([c]);
54248
+ if (l.ok) {
54249
+ if (l.value.items[0].found) s.set(a, l.value.items[0].value);
54250
+ } else if (!vZ(l.error)) throw wZ(l.error.code);
54251
+ }
54252
+ return s;
54253
+ }
54254
+ function vZ(e) {
54255
+ return e.code === "Failed" && (e.telemetryCode === "ELOOP" || e.telemetryCode === "ENXIO");
54256
+ }
54257
+ function wZ(e) {
54258
+ return new Ze(`importSessionToStore: sidecar read failed (${e})`, "importSessionToStore: sidecar read failed");
54259
+ }
54177
54260
  function OZ(e) {
54178
54261
  return { globalConfig: GP(e || CZ(), ".claude.json"), userSettings: GP(e || GP(CZ(), ".claude"), "settings.json") };
54179
54262
  }
@@ -58814,6 +58897,75 @@ async function KZt(e, t) {
58814
58897
  if (t?.sessionStore) return Tnt(t.sessionStore, e, t);
58815
58898
  return pZ(e, t);
58816
58899
  }
58900
+ async function GZt(e, t, n, r) {
58901
+ if (!Je(e)) throw new Ze(`Invalid sessionId: ${e}`, "importSessionToStore: invalid sessionId (must be a UUID)");
58902
+ let o = ye(), s = o ? r : void 0, i = await Ni(e, n?.dir, ir(s), o);
58903
+ if (!i) throw Error(`Session ${e} not found`);
58904
+ let a = no(n?.dir), c = n?.batchSize && n.batchSize > 0 ? n.batchSize : Wy, l = s === void 0 ? void 0 : ac(RL(i.filePath), pn), u = s !== void 0 && l !== void 0 ? { backend: s, projectKey: l } : void 0;
58905
+ if (u !== void 0) await KP(u.backend, tn.transcript(u.projectKey, e), { projectKey: a, sessionId: e }, t, c);
58906
+ else await rne(i.filePath, { projectKey: a, sessionId: e }, t, c);
58907
+ if (n?.includeSubagents === false) return;
58908
+ if (u !== void 0) {
58909
+ let m = await AZ(u.backend, u.projectKey, e), h = await TZ(u.backend, u.projectKey, e, m);
58910
+ for (let y of m) {
58911
+ let _ = { projectKey: a, sessionId: e, subpath: BS(y) };
58912
+ await KP(u.backend, y.kind === "agent" ? tn.transcript(u.projectKey, e, y.agentId, y.agentRelPath) : tn.journal(u.projectKey, e, y.agentRelPath), _, t, c);
58913
+ let E = h.get(_.subpath), S;
58914
+ if (E !== void 0) try {
58915
+ S = lt(E);
58916
+ } catch (x) {
58917
+ ce(`importSessionToStore: skipping unreadable sidecar for ${_.subpath}: ${x}`);
58918
+ }
58919
+ if (S !== void 0) await t.append(_, [{ type: "agent_metadata", ...S }]);
58920
+ }
58921
+ return;
58922
+ }
58923
+ let p = i.filePath.replace(/\.jsonl$/, ""), f = vn(p, "subagents");
58924
+ for (let m of await ynt(f)) {
58925
+ let h = cne(p, m).split(IL);
58926
+ h[h.length - 1] = h.at(-1).replace(/\.jsonl$/, "");
58927
+ let y = { projectKey: a, sessionId: e, subpath: h.join("/") };
58928
+ await rne(m, y, t, c);
58929
+ let _ = m.replace(/\.jsonl$/, ".meta.json"), E;
58930
+ try {
58931
+ E = lt(await sne(_, "utf8"));
58932
+ } catch (S) {
58933
+ if (!wr(S)) ce(`importSessionToStore: skipping unreadable sidecar ${_}: ${S}`);
58934
+ }
58935
+ if (E !== void 0) await t.append(y, [{ type: "agent_metadata", ...E }]);
58936
+ }
58937
+ }
58938
+ async function rne(e, t, n, r) {
58939
+ let o = lnt({ input: rnt(e, { encoding: "utf8" }), crlfDelay: 1 / 0 }), s = [], i = 0;
58940
+ for await (let a of o) {
58941
+ if (!a) continue;
58942
+ try {
58943
+ s.push(lt(a));
58944
+ } catch (c) {
58945
+ ce(`importSessionToStore: skipping unparseable line in ${e}: ${c}`);
58946
+ continue;
58947
+ }
58948
+ if (i += a.length, s.length >= r || i >= Ou) await n.append(t, s), s = [], i = 0;
58949
+ }
58950
+ if (s.length > 0) await n.append(t, s);
58951
+ }
58952
+ async function ynt(e) {
58953
+ let t = [];
58954
+ async function n(r) {
58955
+ let o;
58956
+ try {
58957
+ o = await snt(r, { withFileTypes: true });
58958
+ } catch {
58959
+ return;
58960
+ }
58961
+ for (let s of o) {
58962
+ let i = vn(r, s.name);
58963
+ if (s.isDirectory()) await n(i);
58964
+ else if (s.isFile() && s.name.endsWith(".jsonl")) t.push(i);
58965
+ }
58966
+ }
58967
+ return await n(e), t;
58968
+ }
58817
58969
  function une(e) {
58818
58970
  let t = Vh(e ?? "."), n;
58819
58971
  try {
@@ -59227,7 +59379,26 @@ function listEnvironmentSessions(environment, cwd, signal) {
59227
59379
  // src/acp/harness/claude/upstream/dist/environment-session-messages.js
59228
59380
  var SESSION_MESSAGES_TIMEOUT_MILLISECONDS = 3e4;
59229
59381
  function getEnvironmentSessionMessages(environment, sessionId, signal) {
59230
- return withEnvironment(environment, () => withDeadline(signal, SESSION_MESSAGES_TIMEOUT_MILLISECONDS, () => FZt(sessionId)));
59382
+ return withEnvironment(environment, () => withDeadline(signal, SESSION_MESSAGES_TIMEOUT_MILLISECONDS, async () => {
59383
+ const messages = await FZt(sessionId);
59384
+ if (!messages.some(({ type, message }) => type === "assistant" && typeof message === "object" && message !== null && "model" in message && message.model === "<synthetic>")) {
59385
+ return messages;
59386
+ }
59387
+ const authenticationFailures = /* @__PURE__ */ new Set();
59388
+ await GZt(sessionId, {
59389
+ append: async (_key, entries) => {
59390
+ signal.throwIfAborted();
59391
+ for (const entry of entries) {
59392
+ if (entry.type === "assistant" && entry["error"] === "authentication_failed" && typeof entry.uuid === "string") {
59393
+ authenticationFailures.add(entry.uuid);
59394
+ }
59395
+ }
59396
+ },
59397
+ load: async () => null
59398
+ }, { includeSubagents: false });
59399
+ signal.throwIfAborted();
59400
+ return messages.filter((message) => !authenticationFailures.has(message.uuid));
59401
+ }));
59231
59402
  }
59232
59403
 
59233
59404
  // src/acp/harness/claude/upstream/dist/session-config-ids.js
@@ -62054,17 +62225,6 @@ function stripLocalCommandMetadata(content) {
62054
62225
  }
62055
62226
  return kept;
62056
62227
  }
62057
- function isSyntheticLoginMessage(apiMessage) {
62058
- if (!apiMessage || typeof apiMessage !== "object") {
62059
- return false;
62060
- }
62061
- const { model, content } = apiMessage;
62062
- if (model !== "<synthetic>" || !Array.isArray(content) || content.length !== 1) {
62063
- return false;
62064
- }
62065
- const block = content[0];
62066
- return !!block && block.type === "text" && typeof block.text === "string" && block.text.includes("Please run /login");
62067
- }
62068
62228
  var ClientConnection = class {
62069
62229
  ctx;
62070
62230
  onSessionUpdate;
@@ -63563,10 +63723,6 @@ ${message.api_refusal_explanation}` : "";
63563
63723
  }
63564
63724
  switch (message.subtype) {
63565
63725
  case "success": {
63566
- if (message.result.includes("Please run /login")) {
63567
- failActive(RequestError3.authRequired());
63568
- break;
63569
- }
63570
63726
  if (message.stop_reason === "max_tokens") {
63571
63727
  stopReason = "max_tokens";
63572
63728
  break;
@@ -63790,8 +63946,8 @@ ${message.api_refusal_explanation}` : "";
63790
63946
  if (message.message.role === "system") {
63791
63947
  break;
63792
63948
  }
63793
- if (message.type === "assistant" && isSyntheticLoginMessage(message.message)) {
63794
- failActive(RequestError3.authRequired());
63949
+ if (message.type === "assistant" && message.error === "authentication_failed") {
63950
+ failActive(RequestError3.authRequired(errorKindData(message.error)));
63795
63951
  break;
63796
63952
  }
63797
63953
  let content;
@@ -64174,9 +64330,6 @@ ${message.api_refusal_explanation}` : "";
64174
64330
  if (replaySession && replayMessageId && message.uuid) {
64175
64331
  replaySession.messageIdToUuid.set(replayMessageId, message.uuid);
64176
64332
  }
64177
- if (message.type === "assistant" && isSyntheticLoginMessage(message.message)) {
64178
- continue;
64179
- }
64180
64333
  const parentToolUseId = parentToolUseIdOf(message);
64181
64334
  if (parentToolUseId !== null && !forwardSubagentText) {
64182
64335
  continue;
@@ -67317,6 +67470,7 @@ var queuePageSchema = external_exports.object({
67317
67470
  nextCursor: external_exports.string().nullish()
67318
67471
  });
67319
67472
  var CodexBorrowedAcpAgent = class {
67473
+ steeringSupported = false;
67320
67474
  #client;
67321
67475
  #threadId;
67322
67476
  #emit;
@@ -67538,7 +67692,7 @@ var CodexBorrowedAcpAgent = class {
67538
67692
  nativeTurnId = () => null;
67539
67693
  steer = async (_params, signal) => {
67540
67694
  signal.throwIfAborted();
67541
- return { outcome: "promptRequired", reason: "noRunningTurn" };
67695
+ throw new AcpExecutionError("This Codex session only supports queued input", {}, "steering_unsupported");
67542
67696
  };
67543
67697
  // The reader connection cannot receive or control the owner's live turn.
67544
67698
  onNotification = async (_method, _params) => {
@@ -67678,6 +67832,7 @@ function userInputSchema(questions) {
67678
67832
  return { properties, required: required2, type: "object" };
67679
67833
  }
67680
67834
  var CodexOwnedAcpAgent = class {
67835
+ steeringSupported = true;
67681
67836
  #context;
67682
67837
  #appServer;
67683
67838
  #settings;
@@ -68729,7 +68884,10 @@ var CodexAcpAgent = class {
68729
68884
  await this.#resume(context.params.sessionId, context.params.cwd, context.signal);
68730
68885
  await this.#replaySavedHistory(context.signal);
68731
68886
  this.#advertiseCompactCommand();
68732
- return { configOptions: this.#settings.configOptions() };
68887
+ return {
68888
+ _meta: { steering: { supported: this.#sessionAgent.steeringSupported } },
68889
+ configOptions: this.#settings.configOptions()
68890
+ };
68733
68891
  }).onRequest(methods3.agent.session.fork, async (context) => {
68734
68892
  const forked = threadForkResponseSchema.parse(
68735
68893
  await this.#appServer.request(
@@ -68752,7 +68910,10 @@ var CodexAcpAgent = class {
68752
68910
  }).onRequest(methods3.agent.session.resume, async (context) => {
68753
68911
  await this.#resume(context.params.sessionId, context.params.cwd, context.signal);
68754
68912
  this.#advertiseCompactCommand();
68755
- return { configOptions: this.#settings.configOptions() };
68913
+ return {
68914
+ _meta: { steering: { supported: this.#sessionAgent.steeringSupported } },
68915
+ configOptions: this.#settings.configOptions()
68916
+ };
68756
68917
  }).onRequest(methods3.agent.session.prompt, async (context) => {
68757
68918
  if (isCompactCommand(context.params.prompt)) {
68758
68919
  return await this.#sessionAgent.compact(context.signal);
@@ -83630,6 +83791,7 @@ async function restoreSession(session, signal, recovery, origin) {
83630
83791
  session.setNativeHistoryOwnership({ kind: "fresh-session" });
83631
83792
  lifecycleResponse2 = created;
83632
83793
  }
83794
+ session.restrictSessionCapabilities(lifecycleResponse2);
83633
83795
  session.setConfigOptions(session.sessionConfigProtocol.normalizeLifecycle(lifecycleResponse2));
83634
83796
  if (stored instanceof FoundStoredSession && session.restored) {
83635
83797
  await session.restoreStoredConfigurations(stored.session, signal);
@@ -83882,6 +84044,9 @@ var AgentSession = class _AgentSession {
83882
84044
  signal
83883
84045
  );
83884
84046
  };
84047
+ restrictSessionCapabilities = (response) => {
84048
+ this.#capabilities = restrictAcpSessionCapabilities(this.#capabilities, response);
84049
+ };
83885
84050
  prepared = () => new PreparedSession(
83886
84051
  this.#agentName,
83887
84052
  this.#agentVersion,
@@ -83955,6 +84120,7 @@ var AgentSession = class _AgentSession {
83955
84120
  );
83956
84121
  await this.#updates.drained();
83957
84122
  signal.throwIfAborted();
84123
+ this.restrictSessionCapabilities(response);
83958
84124
  const loaded = { history, kind: "loaded", response };
83959
84125
  this.#sessionLoad = loaded;
83960
84126
  return loaded;