@moxt-ai/mobius 0.0.76 → 0.0.77

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
@@ -11,7 +11,7 @@ import { mkdir as mkdir6 } from "node:fs/promises";
11
11
  // package.json
12
12
  var package_default = {
13
13
  name: "@moxt-ai/mobius",
14
- version: "0.0.76",
14
+ version: "0.0.77",
15
15
  description: "Mobius CLI for pairing and running local AI agent services.",
16
16
  type: "module",
17
17
  bin: {
@@ -21276,10 +21276,29 @@ var threadStartResponseSchema = external_exports.object({
21276
21276
  serviceTier: boundedText(256).nullish(),
21277
21277
  thread: external_exports.object({ id: boundedText(256) })
21278
21278
  });
21279
- var threadResumeResponseSchema = external_exports.object({
21279
+ var threadLifecycleResponseSchema = external_exports.object({
21280
21280
  model: boundedText(256).nullish(),
21281
21281
  reasoningEffort: boundedText(256).nullish(),
21282
- thread: external_exports.object({ id: boundedText(256) }).nullish()
21282
+ serviceTier: boundedText(256).nullish(),
21283
+ thread: external_exports.object({ id: boundedText(256) }),
21284
+ turns: external_exports.array(
21285
+ external_exports.object({
21286
+ items: external_exports.array(external_exports.unknown()).max(1e5)
21287
+ })
21288
+ ).max(1e5).nullish()
21289
+ });
21290
+ var threadResumeResponseSchema = threadLifecycleResponseSchema;
21291
+ var threadForkResponseSchema = threadLifecycleResponseSchema;
21292
+ var threadSummarySchema = external_exports.object({
21293
+ cwd: boundedText(2048),
21294
+ id: boundedText(256),
21295
+ name: boundedText(500).nullish(),
21296
+ preview: boundedText(500).nullish(),
21297
+ updatedAt: external_exports.number().int().nonnegative()
21298
+ });
21299
+ var threadListResponseSchema = external_exports.object({
21300
+ data: external_exports.array(threadSummarySchema).max(500),
21301
+ nextCursor: boundedText(1024).nullish()
21283
21302
  });
21284
21303
  var reasoningEffortOptionSchema = external_exports.object({
21285
21304
  description: boundedText(4096).nullish(),
@@ -21298,19 +21317,6 @@ var modelListResponseSchema = external_exports.object({
21298
21317
  data: external_exports.array(modelSchema).max(1e3),
21299
21318
  nextCursor: boundedText(1024).nullish()
21300
21319
  });
21301
- var threadSchema = external_exports.object({
21302
- createdAt: external_exports.number().nullish(),
21303
- cwd: boundedText(4096).nullish(),
21304
- id: boundedText(256),
21305
- name: boundedText(4096).nullish(),
21306
- preview: boundedText(4096).nullish(),
21307
- updatedAt: external_exports.number().nullish()
21308
- });
21309
- var threadListResponseSchema = external_exports.object({
21310
- data: external_exports.array(threadSchema).max(1e4),
21311
- nextCursor: boundedText(1024).nullish()
21312
- });
21313
- var turnSteerResponseSchema = external_exports.object({ turnId: boundedText(256) });
21314
21320
 
21315
21321
  // src/acp/codex/app-server-client.ts
21316
21322
  var INITIALIZE_TIMEOUT_MILLISECONDS = 3e4;
@@ -21650,7 +21656,7 @@ function agentMessageMeta(phase) {
21650
21656
  var APPROVAL_REASON_CHARACTER_LIMIT = 500;
21651
21657
  var APPROVAL_TIMEOUT_MILLISECONDS = 36e5;
21652
21658
  var CODEX_AGENT_VERSION = "0.154.0";
21653
- var STEERING_METHOD = "_session/steering";
21659
+ var SESSION_LIST_TIMEOUT_MILLISECONDS = 3e4;
21654
21660
  var MODEL_SETTING_ID = "model";
21655
21661
  var REASONING_EFFORT_SETTING_ID = "reasoning_effort";
21656
21662
  var MODE_SETTING_ID = "mode";
@@ -21701,26 +21707,6 @@ function initialMode(environment) {
21701
21707
  function capitalize(value) {
21702
21708
  return value.length === 0 ? value : value.charAt(0).toUpperCase() + value.slice(1);
21703
21709
  }
21704
- function threadTitle(thread) {
21705
- const named = thread.name?.trim() ?? "";
21706
- if (named.length > 0) {
21707
- return named;
21708
- }
21709
- return thread.preview?.trim() ?? "";
21710
- }
21711
- function isoTimestamp(seconds) {
21712
- if (seconds == null || !Number.isFinite(seconds)) {
21713
- return null;
21714
- }
21715
- return new Date(seconds * 1e3).toISOString();
21716
- }
21717
- function steeringParams(params) {
21718
- const prompt = typeof params === "object" && params !== null ? Reflect.get(params, "prompt") : void 0;
21719
- if (!Array.isArray(prompt)) {
21720
- throw new AcpExecutionError("The steering prompt is invalid", {}, "steering_failed");
21721
- }
21722
- return { prompt };
21723
- }
21724
21710
  var APPROVAL_OPTIONS = Object.freeze([
21725
21711
  { kind: "allow_once", name: "Allow once", optionId: "accept" },
21726
21712
  { kind: "allow_always", name: "Allow for this session", optionId: "acceptForSession" },
@@ -21892,14 +21878,12 @@ var CodexAcpAgent = class {
21892
21878
  this.#connection = connection;
21893
21879
  }).onRequest(methods.agent.initialize, async () => ({
21894
21880
  agentCapabilities: {
21895
- loadSession: false,
21881
+ loadSession: true,
21896
21882
  promptCapabilities: { embeddedContext: true, image: true },
21897
- sessionCapabilities: { close: {}, delete: {}, list: {}, resume: {} }
21883
+ sessionCapabilities: { close: {}, fork: {}, list: {} }
21898
21884
  },
21899
21885
  agentInfo: { name: "Codex", version: CODEX_AGENT_VERSION },
21900
21886
  authMethods: [],
21901
- // Mobius reads this to decide whether mid-turn steering can be attempted at all.
21902
- _meta: { steering: { supported: true } },
21903
21887
  protocolVersion: PROTOCOL_VERSION
21904
21888
  })).onRequest(methods.agent.session.new, async (context) => {
21905
21889
  const created = threadStartResponseSchema.parse(
@@ -21916,86 +21900,68 @@ var CodexAcpAgent = class {
21916
21900
  model: created.model ?? ""
21917
21901
  };
21918
21902
  return { configOptions: this.#configOptions(), sessionId: created.thread.id };
21903
+ }).onRequest(methods.agent.session.setConfigOption, async (context) => {
21904
+ this.#applySelection(context.params.configId, context.params.value);
21905
+ return { configOptions: this.#configOptions() };
21906
+ }).onRequest(methods.agent.session.setMode, async (context) => {
21907
+ this.#applySelection(MODE_SETTING_ID, context.params.modeId);
21908
+ return {};
21909
+ }).onRequest(methods.agent.session.load, async (context) => {
21910
+ const resumed = threadResumeResponseSchema.parse(
21911
+ await this.#appServer.request(
21912
+ "thread/resume",
21913
+ { cwd: context.params.cwd, excludeTurns: false, threadId: context.params.sessionId },
21914
+ AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
21915
+ )
21916
+ );
21917
+ this.#selectRestoredThread(resumed);
21918
+ await this.#replayHistory(resumed.turns);
21919
+ return {};
21920
+ }).onRequest(methods.agent.session.fork, async (context) => {
21921
+ const forked = threadForkResponseSchema.parse(
21922
+ await this.#appServer.request(
21923
+ "thread/fork",
21924
+ {
21925
+ cwd: context.params.cwd,
21926
+ excludeTurns: false,
21927
+ threadId: context.params.sessionId
21928
+ },
21929
+ AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
21930
+ )
21931
+ );
21932
+ this.#selectRestoredThread(forked);
21933
+ await this.#replayHistory(forked.turns);
21934
+ return { sessionId: forked.thread.id };
21919
21935
  }).onRequest(methods.agent.session.resume, async (context) => {
21920
21936
  const resumed = threadResumeResponseSchema.parse(
21921
21937
  await this.#appServer.request(
21922
21938
  "thread/resume",
21923
- { cwd: context.params.cwd, threadId: context.params.sessionId },
21939
+ { cwd: context.params.cwd, excludeTurns: true, threadId: context.params.sessionId },
21924
21940
  AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
21925
21941
  )
21926
21942
  );
21927
- if (resumed.thread == null) {
21928
- throw new AcpExecutionError(
21929
- "Codex no longer has the native session this conversation belongs to",
21930
- {},
21931
- "session_restore_unsupported"
21932
- );
21933
- }
21934
- this.#nativeSessionId = resumed.thread.id;
21935
- this.#selection = {
21936
- ...this.#selection,
21937
- effort: resumed.reasoningEffort ?? this.#selection.effort,
21938
- model: resumed.model ?? this.#selection.model
21939
- };
21940
- return { configOptions: this.#configOptions() };
21943
+ this.#selectRestoredThread(resumed);
21944
+ return {};
21945
+ }).onRequest(methods.agent.session.prompt, async (context) => {
21946
+ return await this.#runTurn(promptInput(context.params.prompt), context.signal);
21941
21947
  }).onRequest(methods.agent.session.list, async (context) => {
21942
- const listed = threadListResponseSchema.parse(
21948
+ const decoded = threadListResponseSchema.parse(
21943
21949
  await this.#appServer.request(
21944
21950
  "thread/list",
21945
- context.params.cursor === void 0 || context.params.cursor === null ? {} : { cursor: context.params.cursor },
21946
- AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
21951
+ { cursor: context.params.cursor ?? null },
21952
+ AbortSignal.any([context.signal, AbortSignal.timeout(SESSION_LIST_TIMEOUT_MILLISECONDS)])
21947
21953
  )
21948
21954
  );
21949
21955
  return {
21950
- nextCursor: listed.nextCursor ?? null,
21951
- sessions: listed.data.map((thread) => ({
21952
- // The thread id is a UUID, which satisfies the native session id contract.
21956
+ nextCursor: decoded.nextCursor ?? null,
21957
+ sessions: decoded.data.map((thread) => ({
21953
21958
  additionalDirectories: [],
21954
- cwd: thread.cwd ?? "",
21959
+ cwd: thread.cwd,
21955
21960
  sessionId: thread.id,
21956
- title: threadTitle(thread),
21957
- updatedAt: isoTimestamp(thread.updatedAt)
21961
+ title: thread.name ?? thread.preview ?? null,
21962
+ updatedAt: new Date(thread.updatedAt * 1e3).toISOString()
21958
21963
  }))
21959
21964
  };
21960
- }).onRequest(methods.agent.session.delete, async (context) => {
21961
- await this.#appServer.request(
21962
- "thread/archive",
21963
- { threadId: context.params.sessionId },
21964
- AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
21965
- );
21966
- return {};
21967
- }).onRequest(methods.agent.session.setConfigOption, async (context) => {
21968
- this.#applySelection(context.params.configId, context.params.value);
21969
- return { configOptions: this.#configOptions() };
21970
- }).onRequest(methods.agent.session.setMode, async (context) => {
21971
- this.#applySelection(MODE_SETTING_ID, context.params.modeId);
21972
- return {};
21973
- }).onRequest(methods.agent.session.prompt, async (context) => {
21974
- return await this.#runTurn(promptInput(context.params.prompt), context.signal);
21975
- }).onRequest(STEERING_METHOD, steeringParams, async (context) => {
21976
- const turn = this.#turn;
21977
- if (turn === null || turn.turn.id.length === 0) {
21978
- return { outcome: "promptRequired" };
21979
- }
21980
- try {
21981
- const steered = turnSteerResponseSchema.parse(
21982
- await this.#appServer.request(
21983
- "turn/steer",
21984
- {
21985
- expectedTurnId: turn.turn.id,
21986
- input: promptInput(context.params.prompt),
21987
- threadId: this.#nativeSessionId
21988
- },
21989
- AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
21990
- )
21991
- );
21992
- return { outcome: steered.turnId === turn.turn.id ? "injected" : "startedNewTurn" };
21993
- } catch (error62) {
21994
- if (error62 instanceof CodexAppServerError) {
21995
- return { outcome: "promptRequired" };
21996
- }
21997
- throw error62;
21998
- }
21999
21965
  }).onRequest(methods.agent.session.close, async () => {
22000
21966
  await this.#interruptTurn();
22001
21967
  }).onNotification(methods.agent.session.cancel, async () => {
@@ -22065,6 +22031,56 @@ var CodexAcpAgent = class {
22065
22031
  options.push(modeSetting(this.#selection.mode));
22066
22032
  return options;
22067
22033
  };
22034
+ #selectRestoredThread = (thread) => {
22035
+ this.#nativeSessionId = thread.thread.id;
22036
+ this.#selection = {
22037
+ ...this.#selection,
22038
+ effort: thread.reasoningEffort ?? this.#selection.effort,
22039
+ model: thread.model ?? this.#selection.model,
22040
+ fastMode: thread.serviceTier === SERVICE_TIER_FAST
22041
+ };
22042
+ };
22043
+ #replayHistory = async (turns) => {
22044
+ for (const turn of turns ?? []) {
22045
+ for (const rawItem of turn.items) {
22046
+ const item = decodeThreadItem(rawItem);
22047
+ if (item === null) {
22048
+ continue;
22049
+ }
22050
+ if (item.type === "userMessage") {
22051
+ const text3 = item.content.flatMap((content3) => {
22052
+ if (typeof content3 !== "object" || content3 === null) {
22053
+ return [];
22054
+ }
22055
+ const type = Reflect.get(content3, "type");
22056
+ const text4 = Reflect.get(content3, "text");
22057
+ return type === "text" && typeof text4 === "string" ? [text4] : [];
22058
+ }).join("");
22059
+ if (text3.length > 0) {
22060
+ await this.#emit({
22061
+ content: { text: text3, type: "text" },
22062
+ messageId: item.id,
22063
+ sessionUpdate: "user_message_chunk"
22064
+ });
22065
+ }
22066
+ continue;
22067
+ }
22068
+ if (item.type === "agentMessage") {
22069
+ await this.#emit({
22070
+ _meta: agentMessageMeta(item.phase),
22071
+ content: { text: item.text, type: "text" },
22072
+ messageId: item.id,
22073
+ sessionUpdate: "agent_message_chunk"
22074
+ });
22075
+ continue;
22076
+ }
22077
+ const update = toolCallUpdate(item);
22078
+ if (update !== null) {
22079
+ await this.#emit({ ...update, sessionUpdate: "tool_call_update" });
22080
+ }
22081
+ }
22082
+ }
22083
+ };
22068
22084
  /**
22069
22085
  * Applies one `session/set_config_option`. Switching models re-resolves the effort the way Codex
22070
22086
  * does — the current effort when the new model supports it, otherwise the model's own default —
@@ -39685,7 +39701,7 @@ var responseSchema = external_exports.union([
39685
39701
  external_exports.object({ id: external_exports.number(), result: external_exports.unknown() }),
39686
39702
  external_exports.object({ method: external_exports.string() })
39687
39703
  ]);
39688
- var threadSchema2 = external_exports.object({
39704
+ var threadSchema = external_exports.object({
39689
39705
  thread: external_exports.object({
39690
39706
  id: nativeSessionIdSchema,
39691
39707
  cwd: external_exports.string().min(1).max(2048).refine((path2) => !path2.includes("\0"))
@@ -39989,7 +40005,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
39989
40005
  });
39990
40006
  break;
39991
40007
  case "metadata": {
39992
- const { thread } = threadSchema2.parse(message.result);
40008
+ const { thread } = threadSchema.parse(message.result);
39993
40009
  state = { kind: "turns", requestId: 3, thread };
39994
40010
  send2({
39995
40011
  id: state.requestId,