@moxt-ai/mobius 0.0.77 → 0.0.78

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.77",
14
+ version: "0.0.78",
15
15
  description: "Mobius CLI for pairing and running local AI agent services.",
16
16
  type: "module",
17
17
  bin: {
@@ -21317,6 +21317,14 @@ var modelListResponseSchema = external_exports.object({
21317
21317
  data: external_exports.array(modelSchema).max(1e3),
21318
21318
  nextCursor: boundedText(1024).nullish()
21319
21319
  });
21320
+ var threadSettingsUpdatedSchema = external_exports.object({
21321
+ threadId: boundedText(256),
21322
+ threadSettings: external_exports.object({
21323
+ collaborationMode: external_exports.object({
21324
+ mode: external_exports.enum(["default", "plan"])
21325
+ }).nullish()
21326
+ })
21327
+ });
21320
21328
 
21321
21329
  // src/acp/codex/app-server-client.ts
21322
21330
  var INITIALIZE_TIMEOUT_MILLISECONDS = 3e4;
@@ -21501,7 +21509,10 @@ var CodexAppServerClient = class {
21501
21509
  initialize = async (signal) => {
21502
21510
  await this.request(
21503
21511
  "initialize",
21504
- { clientInfo: { name: "mobius", version: "1.0.0" } },
21512
+ {
21513
+ capabilities: { experimentalApi: true },
21514
+ clientInfo: { name: "mobius", version: "1.0.0" }
21515
+ },
21505
21516
  AbortSignal.any([signal, AbortSignal.timeout(INITIALIZE_TIMEOUT_MILLISECONDS)])
21506
21517
  );
21507
21518
  this.notify("initialized", void 0);
@@ -21661,6 +21672,7 @@ var MODEL_SETTING_ID = "model";
21661
21672
  var REASONING_EFFORT_SETTING_ID = "reasoning_effort";
21662
21673
  var MODE_SETTING_ID = "mode";
21663
21674
  var FAST_MODE_SETTING_ID = "fast-mode";
21675
+ var COLLABORATION_MODE_SETTING_ID = "collaboration_mode";
21664
21676
  var MODEL_CATALOG_LIMIT = 1e3;
21665
21677
  var FAST_TIER = "fast";
21666
21678
  var SERVICE_TIER_FAST = "priority";
@@ -21790,6 +21802,22 @@ function modeSetting(currentValue) {
21790
21802
  type: "select"
21791
21803
  };
21792
21804
  }
21805
+ var COLLABORATION_MODES = Object.freeze([
21806
+ { description: "Codex answers and makes changes directly", name: "Build", value: "default" },
21807
+ { description: "Codex plans before making changes", name: "Plan", value: "plan" }
21808
+ ]);
21809
+ function collaborationModeSetting(currentValue) {
21810
+ const current = COLLABORATION_MODES.some((mode) => mode.value === currentValue) ? currentValue : COLLABORATION_MODES[0]?.value ?? "default";
21811
+ return {
21812
+ category: "collaboration_mode",
21813
+ currentValue: current,
21814
+ description: "How Codex collaborates for subsequent turns",
21815
+ id: COLLABORATION_MODE_SETTING_ID,
21816
+ name: "Collaboration mode",
21817
+ options: [...COLLABORATION_MODES],
21818
+ type: "select"
21819
+ };
21820
+ }
21793
21821
  function fastModeSetting(model, enabled) {
21794
21822
  if (model?.additionalSpeedTiers?.includes(FAST_TIER) !== true) {
21795
21823
  return null;
@@ -21851,11 +21879,19 @@ var CodexAcpAgent = class {
21851
21879
  // Whether the current turn must carry a policy at all. Until the user picks a mode, Codex's own
21852
21880
  // configuration decides, so `turn/start` omits the fields and inherits what the host set up.
21853
21881
  #policySelected = false;
21882
+ // Whether a collaboration mode choice has been made in this session. A restored thread keeps
21883
+ // the mode Codex already persisted, so the first turn does not reset it to Build.
21884
+ #collaborationModeSelected = false;
21885
+ // Whether the app-server accepts collaboration mode on `turn/start`, probed once per
21886
+ // app-server. An older Codex rejects the experimental field, and the setting must disappear
21887
+ // rather than break every turn.
21888
+ #collaborationModeSupported = null;
21854
21889
  #selection;
21855
21890
  #turn = null;
21856
21891
  #updateTail = Promise.resolve();
21857
21892
  constructor(options) {
21858
21893
  this.#selection = {
21894
+ collaborationMode: "default",
21859
21895
  effort: "",
21860
21896
  fastMode: false,
21861
21897
  mode: initialMode(options.environment),
@@ -21896,9 +21932,12 @@ var CodexAcpAgent = class {
21896
21932
  this.#nativeSessionId = created.thread.id;
21897
21933
  this.#selection = {
21898
21934
  ...this.#selection,
21935
+ collaborationMode: "default",
21899
21936
  effort: created.reasoningEffort ?? "",
21900
21937
  model: created.model ?? ""
21901
21938
  };
21939
+ this.#collaborationModeSelected = false;
21940
+ await this.#probeCollaborationMode(context.signal);
21902
21941
  return { configOptions: this.#configOptions(), sessionId: created.thread.id };
21903
21942
  }).onRequest(methods.agent.session.setConfigOption, async (context) => {
21904
21943
  this.#applySelection(context.params.configId, context.params.value);
@@ -21915,8 +21954,9 @@ var CodexAcpAgent = class {
21915
21954
  )
21916
21955
  );
21917
21956
  this.#selectRestoredThread(resumed);
21957
+ await this.#probeCollaborationMode(context.signal);
21918
21958
  await this.#replayHistory(resumed.turns);
21919
- return {};
21959
+ return { configOptions: this.#configOptions() };
21920
21960
  }).onRequest(methods.agent.session.fork, async (context) => {
21921
21961
  const forked = threadForkResponseSchema.parse(
21922
21962
  await this.#appServer.request(
@@ -21930,8 +21970,9 @@ var CodexAcpAgent = class {
21930
21970
  )
21931
21971
  );
21932
21972
  this.#selectRestoredThread(forked);
21973
+ await this.#probeCollaborationMode(context.signal);
21933
21974
  await this.#replayHistory(forked.turns);
21934
- return { sessionId: forked.thread.id };
21975
+ return { configOptions: this.#configOptions(), sessionId: forked.thread.id };
21935
21976
  }).onRequest(methods.agent.session.resume, async (context) => {
21936
21977
  const resumed = threadResumeResponseSchema.parse(
21937
21978
  await this.#appServer.request(
@@ -21941,7 +21982,8 @@ var CodexAcpAgent = class {
21941
21982
  )
21942
21983
  );
21943
21984
  this.#selectRestoredThread(resumed);
21944
- return {};
21985
+ await this.#probeCollaborationMode(context.signal);
21986
+ return { configOptions: this.#configOptions() };
21945
21987
  }).onRequest(methods.agent.session.prompt, async (context) => {
21946
21988
  return await this.#runTurn(promptInput(context.params.prompt), context.signal);
21947
21989
  }).onRequest(methods.agent.session.list, async (context) => {
@@ -22013,6 +22055,27 @@ var CodexAcpAgent = class {
22013
22055
  this.#models = Object.freeze(models.slice(0, MODEL_CATALOG_LIMIT));
22014
22056
  };
22015
22057
  #model = (id) => this.#models.find((model) => model.id === id);
22058
+ /**
22059
+ * Learns, once per app-server, whether collaboration mode can be applied. An empty settings
22060
+ * update is a no-op on a supporting Codex; an older Codex answers an error, which costs the
22061
+ * Build/Plan selector alone without changing a restored thread's persisted mode.
22062
+ */
22063
+ #probeCollaborationMode = async (signal) => {
22064
+ if (this.#collaborationModeSupported !== null) {
22065
+ return;
22066
+ }
22067
+ try {
22068
+ await this.#appServer.request(
22069
+ "thread/settings/update",
22070
+ { threadId: this.#nativeSessionId },
22071
+ AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
22072
+ );
22073
+ this.#collaborationModeSupported = true;
22074
+ } catch {
22075
+ signal.throwIfAborted();
22076
+ this.#collaborationModeSupported = false;
22077
+ }
22078
+ };
22016
22079
  /** The ACP settings Mobius discovers and renders in Run settings. */
22017
22080
  #configOptions = () => {
22018
22081
  const options = [];
@@ -22028,6 +22091,9 @@ var CodexAcpAgent = class {
22028
22091
  if (fastMode !== null) {
22029
22092
  options.push(fastMode);
22030
22093
  }
22094
+ if (this.#collaborationModeSupported === true) {
22095
+ options.push(collaborationModeSetting(this.#selection.collaborationMode));
22096
+ }
22031
22097
  options.push(modeSetting(this.#selection.mode));
22032
22098
  return options;
22033
22099
  };
@@ -22120,6 +22186,18 @@ var CodexAcpAgent = class {
22120
22186
  this.#policySelected = true;
22121
22187
  return;
22122
22188
  }
22189
+ if (configId === COLLABORATION_MODE_SETTING_ID) {
22190
+ if (!COLLABORATION_MODES.some((mode) => mode.value === value)) {
22191
+ throw new AcpExecutionError(
22192
+ "The requested Codex collaboration mode is unavailable",
22193
+ {},
22194
+ "invalid_session_configuration"
22195
+ );
22196
+ }
22197
+ this.#selection = { ...this.#selection, collaborationMode: value };
22198
+ this.#collaborationModeSelected = true;
22199
+ return;
22200
+ }
22123
22201
  if (configId === MODEL_SETTING_ID) {
22124
22202
  if (value === this.#selection.model) {
22125
22203
  return;
@@ -22168,6 +22246,17 @@ var CodexAcpAgent = class {
22168
22246
  update
22169
22247
  });
22170
22248
  };
22249
+ /** Pushes the current settings so a mode change Codex applied reaches the Run settings panel. */
22250
+ #emitConfigOptionsUpdate = async () => {
22251
+ const connection = this.#connection;
22252
+ if (connection === null || this.#nativeSessionId.length === 0) {
22253
+ return;
22254
+ }
22255
+ await connection.client.notify(methods.client.session.update, {
22256
+ sessionId: this.#nativeSessionId,
22257
+ update: { configOptions: this.#configOptions(), sessionUpdate: "config_option_update" }
22258
+ });
22259
+ };
22171
22260
  // Notifications are serialized so two app-server items cannot interleave into one ACP update
22172
22261
  // stream, and the caller awaits the result: `turn/completed` must not resolve the prompt before
22173
22262
  // the updates it precedes have reached the client.
@@ -22200,6 +22289,19 @@ var CodexAcpAgent = class {
22200
22289
  }
22201
22290
  return;
22202
22291
  }
22292
+ if (method === "thread/settings/updated") {
22293
+ const decoded = threadSettingsUpdatedSchema.safeParse(params);
22294
+ if (decoded.success && decoded.data.threadId === this.#nativeSessionId) {
22295
+ const mode = decoded.data.threadSettings.collaborationMode?.mode;
22296
+ if (mode !== void 0 && mode !== this.#selection.collaborationMode) {
22297
+ this.#selection = { ...this.#selection, collaborationMode: mode };
22298
+ await this.#enqueue(async () => {
22299
+ await this.#emitConfigOptionsUpdate();
22300
+ });
22301
+ }
22302
+ }
22303
+ return;
22304
+ }
22203
22305
  if (method === "turn/plan/updated") {
22204
22306
  const plan = params.plan;
22205
22307
  if (Array.isArray(plan) && params.threadId === this.#nativeSessionId) {
@@ -22378,6 +22480,19 @@ var CodexAcpAgent = class {
22378
22480
  approvalsReviewer: mode.approvalsReviewer,
22379
22481
  sandboxPolicy: mode.sandboxPolicy
22380
22482
  } : {},
22483
+ // The collaboration mode rides on the turn: Codex applies it to the
22484
+ // thread, where it persists until changed. "Build" is Codex's `default`
22485
+ // mode, so it is only sent once a choice exists to apply.
22486
+ ...this.#collaborationModeSupported && (selection.collaborationMode !== "default" || this.#collaborationModeSelected) ? {
22487
+ collaborationMode: {
22488
+ mode: selection.collaborationMode,
22489
+ settings: {
22490
+ developer_instructions: null,
22491
+ model: selection.model,
22492
+ reasoning_effort: selection.effort.length === 0 ? null : selection.effort
22493
+ }
22494
+ }
22495
+ } : {},
22381
22496
  ...selection.effort.length === 0 ? {} : { effort: selection.effort },
22382
22497
  input: input2,
22383
22498
  ...selection.model.length === 0 ? {} : { model: selection.model },