@moxt-ai/mobius 0.0.294 → 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.
- package/dist/cli.js +165 -22
- package/dist/cli.js.map +2 -2
- package/dist/runtime.js +165 -22
- package/dist/runtime.js.map +2 -2
- package/package.json +1 -1
package/dist/runtime.js
CHANGED
|
@@ -22582,7 +22582,7 @@ import { fetch as fetch3 } from "undici";
|
|
|
22582
22582
|
// package.json
|
|
22583
22583
|
var package_default = {
|
|
22584
22584
|
name: "@moxt-ai/mobius",
|
|
22585
|
-
version: "0.0.
|
|
22585
|
+
version: "0.0.295",
|
|
22586
22586
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
22587
22587
|
type: "module",
|
|
22588
22588
|
bin: {
|
|
@@ -22731,6 +22731,7 @@ import { mkdir as CL, readdir as snt, readFile as sne, rm as int2, writeFile as
|
|
|
22731
22731
|
import { createRequire as ant } from "module";
|
|
22732
22732
|
import { homedir as kL, tmpdir as cnt } from "os";
|
|
22733
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";
|
|
22734
22735
|
import { fileURLToPath as unt } from "url";
|
|
22735
22736
|
import { setMaxListeners as bae } from "events";
|
|
22736
22737
|
import { spawn as BFe } from "child_process";
|
|
@@ -54184,6 +54185,78 @@ function mZ(e, t, n, r) {
|
|
|
54184
54185
|
if (!p) p = `${r() || "Forked session"} (fork)`;
|
|
54185
54186
|
return u.push({ type: "custom-title", sessionId: c, customTitle: p, uuid: zS(), timestamp: l }), { entries: u, forkedSessionId: c };
|
|
54186
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
|
+
}
|
|
54187
54260
|
function OZ(e) {
|
|
54188
54261
|
return { globalConfig: GP(e || CZ(), ".claude.json"), userSettings: GP(e || GP(CZ(), ".claude"), "settings.json") };
|
|
54189
54262
|
}
|
|
@@ -58824,6 +58897,75 @@ async function KZt(e, t) {
|
|
|
58824
58897
|
if (t?.sessionStore) return Tnt(t.sessionStore, e, t);
|
|
58825
58898
|
return pZ(e, t);
|
|
58826
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
|
+
}
|
|
58827
58969
|
function une(e) {
|
|
58828
58970
|
let t = Vh(e ?? "."), n;
|
|
58829
58971
|
try {
|
|
@@ -59237,7 +59379,26 @@ function listEnvironmentSessions(environment, cwd, signal) {
|
|
|
59237
59379
|
// src/acp/harness/claude/upstream/dist/environment-session-messages.js
|
|
59238
59380
|
var SESSION_MESSAGES_TIMEOUT_MILLISECONDS = 3e4;
|
|
59239
59381
|
function getEnvironmentSessionMessages(environment, sessionId, signal) {
|
|
59240
|
-
return withEnvironment(environment, () => withDeadline(signal, SESSION_MESSAGES_TIMEOUT_MILLISECONDS, () =>
|
|
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
|
+
}));
|
|
59241
59402
|
}
|
|
59242
59403
|
|
|
59243
59404
|
// src/acp/harness/claude/upstream/dist/session-config-ids.js
|
|
@@ -62064,17 +62225,6 @@ function stripLocalCommandMetadata(content) {
|
|
|
62064
62225
|
}
|
|
62065
62226
|
return kept;
|
|
62066
62227
|
}
|
|
62067
|
-
function isSyntheticLoginMessage(apiMessage) {
|
|
62068
|
-
if (!apiMessage || typeof apiMessage !== "object") {
|
|
62069
|
-
return false;
|
|
62070
|
-
}
|
|
62071
|
-
const { model, content } = apiMessage;
|
|
62072
|
-
if (model !== "<synthetic>" || !Array.isArray(content) || content.length !== 1) {
|
|
62073
|
-
return false;
|
|
62074
|
-
}
|
|
62075
|
-
const block = content[0];
|
|
62076
|
-
return !!block && block.type === "text" && typeof block.text === "string" && block.text.includes("Please run /login");
|
|
62077
|
-
}
|
|
62078
62228
|
var ClientConnection = class {
|
|
62079
62229
|
ctx;
|
|
62080
62230
|
onSessionUpdate;
|
|
@@ -63573,10 +63723,6 @@ ${message.api_refusal_explanation}` : "";
|
|
|
63573
63723
|
}
|
|
63574
63724
|
switch (message.subtype) {
|
|
63575
63725
|
case "success": {
|
|
63576
|
-
if (message.result.includes("Please run /login")) {
|
|
63577
|
-
failActive(RequestError3.authRequired());
|
|
63578
|
-
break;
|
|
63579
|
-
}
|
|
63580
63726
|
if (message.stop_reason === "max_tokens") {
|
|
63581
63727
|
stopReason = "max_tokens";
|
|
63582
63728
|
break;
|
|
@@ -63800,8 +63946,8 @@ ${message.api_refusal_explanation}` : "";
|
|
|
63800
63946
|
if (message.message.role === "system") {
|
|
63801
63947
|
break;
|
|
63802
63948
|
}
|
|
63803
|
-
if (message.type === "assistant" &&
|
|
63804
|
-
failActive(RequestError3.authRequired());
|
|
63949
|
+
if (message.type === "assistant" && message.error === "authentication_failed") {
|
|
63950
|
+
failActive(RequestError3.authRequired(errorKindData(message.error)));
|
|
63805
63951
|
break;
|
|
63806
63952
|
}
|
|
63807
63953
|
let content;
|
|
@@ -64184,9 +64330,6 @@ ${message.api_refusal_explanation}` : "";
|
|
|
64184
64330
|
if (replaySession && replayMessageId && message.uuid) {
|
|
64185
64331
|
replaySession.messageIdToUuid.set(replayMessageId, message.uuid);
|
|
64186
64332
|
}
|
|
64187
|
-
if (message.type === "assistant" && isSyntheticLoginMessage(message.message)) {
|
|
64188
|
-
continue;
|
|
64189
|
-
}
|
|
64190
64333
|
const parentToolUseId = parentToolUseIdOf(message);
|
|
64191
64334
|
if (parentToolUseId !== null && !forwardSubagentText) {
|
|
64192
64335
|
continue;
|