@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/runtime.js CHANGED
@@ -21189,6 +21189,14 @@ var modelListResponseSchema = external_exports.object({
21189
21189
  data: external_exports.array(modelSchema).max(1e3),
21190
21190
  nextCursor: boundedText(1024).nullish()
21191
21191
  });
21192
+ var threadSettingsUpdatedSchema = external_exports.object({
21193
+ threadId: boundedText(256),
21194
+ threadSettings: external_exports.object({
21195
+ collaborationMode: external_exports.object({
21196
+ mode: external_exports.enum(["default", "plan"])
21197
+ }).nullish()
21198
+ })
21199
+ });
21192
21200
 
21193
21201
  // src/acp/codex/app-server-client.ts
21194
21202
  var INITIALIZE_TIMEOUT_MILLISECONDS = 3e4;
@@ -21373,7 +21381,10 @@ var CodexAppServerClient = class {
21373
21381
  initialize = async (signal) => {
21374
21382
  await this.request(
21375
21383
  "initialize",
21376
- { clientInfo: { name: "mobius", version: "1.0.0" } },
21384
+ {
21385
+ capabilities: { experimentalApi: true },
21386
+ clientInfo: { name: "mobius", version: "1.0.0" }
21387
+ },
21377
21388
  AbortSignal.any([signal, AbortSignal.timeout(INITIALIZE_TIMEOUT_MILLISECONDS)])
21378
21389
  );
21379
21390
  this.notify("initialized", void 0);
@@ -21533,6 +21544,7 @@ var MODEL_SETTING_ID = "model";
21533
21544
  var REASONING_EFFORT_SETTING_ID = "reasoning_effort";
21534
21545
  var MODE_SETTING_ID = "mode";
21535
21546
  var FAST_MODE_SETTING_ID = "fast-mode";
21547
+ var COLLABORATION_MODE_SETTING_ID = "collaboration_mode";
21536
21548
  var MODEL_CATALOG_LIMIT = 1e3;
21537
21549
  var FAST_TIER = "fast";
21538
21550
  var SERVICE_TIER_FAST = "priority";
@@ -21662,6 +21674,22 @@ function modeSetting(currentValue) {
21662
21674
  type: "select"
21663
21675
  };
21664
21676
  }
21677
+ var COLLABORATION_MODES = Object.freeze([
21678
+ { description: "Codex answers and makes changes directly", name: "Build", value: "default" },
21679
+ { description: "Codex plans before making changes", name: "Plan", value: "plan" }
21680
+ ]);
21681
+ function collaborationModeSetting(currentValue) {
21682
+ const current = COLLABORATION_MODES.some((mode) => mode.value === currentValue) ? currentValue : COLLABORATION_MODES[0]?.value ?? "default";
21683
+ return {
21684
+ category: "collaboration_mode",
21685
+ currentValue: current,
21686
+ description: "How Codex collaborates for subsequent turns",
21687
+ id: COLLABORATION_MODE_SETTING_ID,
21688
+ name: "Collaboration mode",
21689
+ options: [...COLLABORATION_MODES],
21690
+ type: "select"
21691
+ };
21692
+ }
21665
21693
  function fastModeSetting(model, enabled) {
21666
21694
  if (model?.additionalSpeedTiers?.includes(FAST_TIER) !== true) {
21667
21695
  return null;
@@ -21723,11 +21751,19 @@ var CodexAcpAgent = class {
21723
21751
  // Whether the current turn must carry a policy at all. Until the user picks a mode, Codex's own
21724
21752
  // configuration decides, so `turn/start` omits the fields and inherits what the host set up.
21725
21753
  #policySelected = false;
21754
+ // Whether a collaboration mode choice has been made in this session. A restored thread keeps
21755
+ // the mode Codex already persisted, so the first turn does not reset it to Build.
21756
+ #collaborationModeSelected = false;
21757
+ // Whether the app-server accepts collaboration mode on `turn/start`, probed once per
21758
+ // app-server. An older Codex rejects the experimental field, and the setting must disappear
21759
+ // rather than break every turn.
21760
+ #collaborationModeSupported = null;
21726
21761
  #selection;
21727
21762
  #turn = null;
21728
21763
  #updateTail = Promise.resolve();
21729
21764
  constructor(options) {
21730
21765
  this.#selection = {
21766
+ collaborationMode: "default",
21731
21767
  effort: "",
21732
21768
  fastMode: false,
21733
21769
  mode: initialMode(options.environment),
@@ -21768,9 +21804,12 @@ var CodexAcpAgent = class {
21768
21804
  this.#nativeSessionId = created.thread.id;
21769
21805
  this.#selection = {
21770
21806
  ...this.#selection,
21807
+ collaborationMode: "default",
21771
21808
  effort: created.reasoningEffort ?? "",
21772
21809
  model: created.model ?? ""
21773
21810
  };
21811
+ this.#collaborationModeSelected = false;
21812
+ await this.#probeCollaborationMode(context.signal);
21774
21813
  return { configOptions: this.#configOptions(), sessionId: created.thread.id };
21775
21814
  }).onRequest(methods.agent.session.setConfigOption, async (context) => {
21776
21815
  this.#applySelection(context.params.configId, context.params.value);
@@ -21787,8 +21826,9 @@ var CodexAcpAgent = class {
21787
21826
  )
21788
21827
  );
21789
21828
  this.#selectRestoredThread(resumed);
21829
+ await this.#probeCollaborationMode(context.signal);
21790
21830
  await this.#replayHistory(resumed.turns);
21791
- return {};
21831
+ return { configOptions: this.#configOptions() };
21792
21832
  }).onRequest(methods.agent.session.fork, async (context) => {
21793
21833
  const forked = threadForkResponseSchema.parse(
21794
21834
  await this.#appServer.request(
@@ -21802,8 +21842,9 @@ var CodexAcpAgent = class {
21802
21842
  )
21803
21843
  );
21804
21844
  this.#selectRestoredThread(forked);
21845
+ await this.#probeCollaborationMode(context.signal);
21805
21846
  await this.#replayHistory(forked.turns);
21806
- return { sessionId: forked.thread.id };
21847
+ return { configOptions: this.#configOptions(), sessionId: forked.thread.id };
21807
21848
  }).onRequest(methods.agent.session.resume, async (context) => {
21808
21849
  const resumed = threadResumeResponseSchema.parse(
21809
21850
  await this.#appServer.request(
@@ -21813,7 +21854,8 @@ var CodexAcpAgent = class {
21813
21854
  )
21814
21855
  );
21815
21856
  this.#selectRestoredThread(resumed);
21816
- return {};
21857
+ await this.#probeCollaborationMode(context.signal);
21858
+ return { configOptions: this.#configOptions() };
21817
21859
  }).onRequest(methods.agent.session.prompt, async (context) => {
21818
21860
  return await this.#runTurn(promptInput(context.params.prompt), context.signal);
21819
21861
  }).onRequest(methods.agent.session.list, async (context) => {
@@ -21885,6 +21927,27 @@ var CodexAcpAgent = class {
21885
21927
  this.#models = Object.freeze(models.slice(0, MODEL_CATALOG_LIMIT));
21886
21928
  };
21887
21929
  #model = (id) => this.#models.find((model) => model.id === id);
21930
+ /**
21931
+ * Learns, once per app-server, whether collaboration mode can be applied. An empty settings
21932
+ * update is a no-op on a supporting Codex; an older Codex answers an error, which costs the
21933
+ * Build/Plan selector alone without changing a restored thread's persisted mode.
21934
+ */
21935
+ #probeCollaborationMode = async (signal) => {
21936
+ if (this.#collaborationModeSupported !== null) {
21937
+ return;
21938
+ }
21939
+ try {
21940
+ await this.#appServer.request(
21941
+ "thread/settings/update",
21942
+ { threadId: this.#nativeSessionId },
21943
+ AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
21944
+ );
21945
+ this.#collaborationModeSupported = true;
21946
+ } catch {
21947
+ signal.throwIfAborted();
21948
+ this.#collaborationModeSupported = false;
21949
+ }
21950
+ };
21888
21951
  /** The ACP settings Mobius discovers and renders in Run settings. */
21889
21952
  #configOptions = () => {
21890
21953
  const options = [];
@@ -21900,6 +21963,9 @@ var CodexAcpAgent = class {
21900
21963
  if (fastMode !== null) {
21901
21964
  options.push(fastMode);
21902
21965
  }
21966
+ if (this.#collaborationModeSupported === true) {
21967
+ options.push(collaborationModeSetting(this.#selection.collaborationMode));
21968
+ }
21903
21969
  options.push(modeSetting(this.#selection.mode));
21904
21970
  return options;
21905
21971
  };
@@ -21992,6 +22058,18 @@ var CodexAcpAgent = class {
21992
22058
  this.#policySelected = true;
21993
22059
  return;
21994
22060
  }
22061
+ if (configId === COLLABORATION_MODE_SETTING_ID) {
22062
+ if (!COLLABORATION_MODES.some((mode) => mode.value === value)) {
22063
+ throw new AcpExecutionError(
22064
+ "The requested Codex collaboration mode is unavailable",
22065
+ {},
22066
+ "invalid_session_configuration"
22067
+ );
22068
+ }
22069
+ this.#selection = { ...this.#selection, collaborationMode: value };
22070
+ this.#collaborationModeSelected = true;
22071
+ return;
22072
+ }
21995
22073
  if (configId === MODEL_SETTING_ID) {
21996
22074
  if (value === this.#selection.model) {
21997
22075
  return;
@@ -22040,6 +22118,17 @@ var CodexAcpAgent = class {
22040
22118
  update
22041
22119
  });
22042
22120
  };
22121
+ /** Pushes the current settings so a mode change Codex applied reaches the Run settings panel. */
22122
+ #emitConfigOptionsUpdate = async () => {
22123
+ const connection = this.#connection;
22124
+ if (connection === null || this.#nativeSessionId.length === 0) {
22125
+ return;
22126
+ }
22127
+ await connection.client.notify(methods.client.session.update, {
22128
+ sessionId: this.#nativeSessionId,
22129
+ update: { configOptions: this.#configOptions(), sessionUpdate: "config_option_update" }
22130
+ });
22131
+ };
22043
22132
  // Notifications are serialized so two app-server items cannot interleave into one ACP update
22044
22133
  // stream, and the caller awaits the result: `turn/completed` must not resolve the prompt before
22045
22134
  // the updates it precedes have reached the client.
@@ -22072,6 +22161,19 @@ var CodexAcpAgent = class {
22072
22161
  }
22073
22162
  return;
22074
22163
  }
22164
+ if (method === "thread/settings/updated") {
22165
+ const decoded = threadSettingsUpdatedSchema.safeParse(params);
22166
+ if (decoded.success && decoded.data.threadId === this.#nativeSessionId) {
22167
+ const mode = decoded.data.threadSettings.collaborationMode?.mode;
22168
+ if (mode !== void 0 && mode !== this.#selection.collaborationMode) {
22169
+ this.#selection = { ...this.#selection, collaborationMode: mode };
22170
+ await this.#enqueue(async () => {
22171
+ await this.#emitConfigOptionsUpdate();
22172
+ });
22173
+ }
22174
+ }
22175
+ return;
22176
+ }
22075
22177
  if (method === "turn/plan/updated") {
22076
22178
  const plan = params.plan;
22077
22179
  if (Array.isArray(plan) && params.threadId === this.#nativeSessionId) {
@@ -22250,6 +22352,19 @@ var CodexAcpAgent = class {
22250
22352
  approvalsReviewer: mode.approvalsReviewer,
22251
22353
  sandboxPolicy: mode.sandboxPolicy
22252
22354
  } : {},
22355
+ // The collaboration mode rides on the turn: Codex applies it to the
22356
+ // thread, where it persists until changed. "Build" is Codex's `default`
22357
+ // mode, so it is only sent once a choice exists to apply.
22358
+ ...this.#collaborationModeSupported && (selection.collaborationMode !== "default" || this.#collaborationModeSelected) ? {
22359
+ collaborationMode: {
22360
+ mode: selection.collaborationMode,
22361
+ settings: {
22362
+ developer_instructions: null,
22363
+ model: selection.model,
22364
+ reasoning_effort: selection.effort.length === 0 ? null : selection.effort
22365
+ }
22366
+ }
22367
+ } : {},
22253
22368
  ...selection.effort.length === 0 ? {} : { effort: selection.effort },
22254
22369
  input: input2,
22255
22370
  ...selection.model.length === 0 ? {} : { model: selection.model },