@moxt-ai/mobius 0.0.72 → 0.0.74

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 (52) hide show
  1. package/dist/acp/activity.d.ts +9 -1
  2. package/dist/acp/activity.d.ts.map +1 -1
  3. package/dist/acp/activity.js +51 -13
  4. package/dist/acp/activity.js.map +1 -1
  5. package/dist/acp/codex/agent.d.ts +1 -1
  6. package/dist/acp/codex/agent.d.ts.map +1 -1
  7. package/dist/acp/codex/agent.js +415 -6
  8. package/dist/acp/codex/agent.js.map +1 -1
  9. package/dist/acp/codex/app-server-protocol.d.ts +68 -0
  10. package/dist/acp/codex/app-server-protocol.d.ts.map +1 -1
  11. package/dist/acp/codex/app-server-protocol.js +51 -0
  12. package/dist/acp/codex/app-server-protocol.js.map +1 -1
  13. package/dist/acp/run-prompt.d.ts +2 -1
  14. package/dist/acp/run-prompt.d.ts.map +1 -1
  15. package/dist/acp/run-prompt.js +1 -0
  16. package/dist/acp/run-prompt.js.map +1 -1
  17. package/dist/acp/session-history.d.ts.map +1 -1
  18. package/dist/acp/session-history.js +4 -1
  19. package/dist/acp/session-history.js.map +1 -1
  20. package/dist/acp/session-manager.d.ts +7 -2
  21. package/dist/acp/session-manager.d.ts.map +1 -1
  22. package/dist/acp/session-manager.js +18 -7
  23. package/dist/acp/session-manager.js.map +1 -1
  24. package/dist/cli.js +854 -62
  25. package/dist/cli.js.map +4 -4
  26. package/dist/daemon-diagnostic-log.d.ts +6 -0
  27. package/dist/daemon-diagnostic-log.d.ts.map +1 -0
  28. package/dist/daemon-diagnostic-log.js +48 -0
  29. package/dist/daemon-diagnostic-log.js.map +1 -0
  30. package/dist/index.js +856 -63
  31. package/dist/index.js.map +4 -4
  32. package/dist/native-sessions/service.d.ts.map +1 -1
  33. package/dist/native-sessions/service.js +6 -5
  34. package/dist/native-sessions/service.js.map +1 -1
  35. package/dist/relay-connection/coalescing-narration-publisher.d.ts +31 -0
  36. package/dist/relay-connection/coalescing-narration-publisher.d.ts.map +1 -0
  37. package/dist/relay-connection/coalescing-narration-publisher.js +61 -0
  38. package/dist/relay-connection/coalescing-narration-publisher.js.map +1 -0
  39. package/dist/relay-connection/diagnostics.d.ts +3 -1
  40. package/dist/relay-connection/diagnostics.d.ts.map +1 -1
  41. package/dist/relay-connection/diagnostics.js +16 -1
  42. package/dist/relay-connection/diagnostics.js.map +1 -1
  43. package/dist/relay-connection/session-event-outbox.d.ts +6 -0
  44. package/dist/relay-connection/session-event-outbox.d.ts.map +1 -1
  45. package/dist/relay-connection/session-event-outbox.js +13 -0
  46. package/dist/relay-connection/session-event-outbox.js.map +1 -1
  47. package/dist/run-daemon.d.ts.map +1 -1
  48. package/dist/run-daemon.js +104 -7
  49. package/dist/run-daemon.js.map +1 -1
  50. package/dist/runtime.js +866 -74
  51. package/dist/runtime.js.map +4 -4
  52. package/package.json +1 -1
package/dist/runtime.js CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all2) => {
6
6
 
7
7
  // src/runtime.ts
8
8
  import { mkdir as mkdir6, realpath as realpath10, stat as stat9 } from "node:fs/promises";
9
- import { dirname as dirname8, join as join17, resolve as resolve7 } from "node:path";
9
+ import { dirname as dirname8, join as join18, resolve as resolve7 } from "node:path";
10
10
 
11
11
  // src/agent-catalog/local-agent.ts
12
12
  import { realpathSync, statSync } from "node:fs";
@@ -21140,8 +21140,49 @@ var mcpElicitationParamsSchema = external_exports.object({
21140
21140
  url: external_exports.string().optional()
21141
21141
  });
21142
21142
  var threadStartResponseSchema = external_exports.object({
21143
+ approvalPolicy: external_exports.unknown().optional(),
21144
+ approvalsReviewer: external_exports.unknown().optional(),
21145
+ model: boundedText(256).nullish(),
21146
+ reasoningEffort: boundedText(256).nullish(),
21147
+ sandbox: external_exports.unknown().optional(),
21148
+ serviceTier: boundedText(256).nullish(),
21143
21149
  thread: external_exports.object({ id: boundedText(256) })
21144
21150
  });
21151
+ var threadResumeResponseSchema = external_exports.object({
21152
+ model: boundedText(256).nullish(),
21153
+ reasoningEffort: boundedText(256).nullish(),
21154
+ thread: external_exports.object({ id: boundedText(256) }).nullish()
21155
+ });
21156
+ var reasoningEffortOptionSchema = external_exports.object({
21157
+ description: boundedText(4096).nullish(),
21158
+ reasoningEffort: boundedText(256)
21159
+ });
21160
+ var modelSchema = external_exports.object({
21161
+ additionalSpeedTiers: external_exports.array(boundedText(256)).max(100).nullish(),
21162
+ defaultReasoningEffort: boundedText(256).nullish(),
21163
+ description: boundedText(4096).nullish(),
21164
+ displayName: boundedText(256).nullish(),
21165
+ id: boundedText(256),
21166
+ isDefault: external_exports.boolean().nullish(),
21167
+ supportedReasoningEfforts: external_exports.array(reasoningEffortOptionSchema).max(100).nullish()
21168
+ });
21169
+ var modelListResponseSchema = external_exports.object({
21170
+ data: external_exports.array(modelSchema).max(1e3),
21171
+ nextCursor: boundedText(1024).nullish()
21172
+ });
21173
+ var threadSchema = external_exports.object({
21174
+ createdAt: external_exports.number().nullish(),
21175
+ cwd: boundedText(4096).nullish(),
21176
+ id: boundedText(256),
21177
+ name: boundedText(4096).nullish(),
21178
+ preview: boundedText(4096).nullish(),
21179
+ updatedAt: external_exports.number().nullish()
21180
+ });
21181
+ var threadListResponseSchema = external_exports.object({
21182
+ data: external_exports.array(threadSchema).max(1e4),
21183
+ nextCursor: boundedText(1024).nullish()
21184
+ });
21185
+ var turnSteerResponseSchema = external_exports.object({ turnId: boundedText(256) });
21145
21186
 
21146
21187
  // src/acp/codex/app-server-client.ts
21147
21188
  var INITIALIZE_TIMEOUT_MILLISECONDS = 3e4;
@@ -21481,6 +21522,77 @@ function agentMessageMeta(phase) {
21481
21522
  var APPROVAL_REASON_CHARACTER_LIMIT = 500;
21482
21523
  var APPROVAL_TIMEOUT_MILLISECONDS = 36e5;
21483
21524
  var CODEX_AGENT_VERSION = "0.154.0";
21525
+ var STEERING_METHOD = "_session/steering";
21526
+ var MODEL_SETTING_ID = "model";
21527
+ var REASONING_EFFORT_SETTING_ID = "reasoning_effort";
21528
+ var MODE_SETTING_ID = "mode";
21529
+ var FAST_MODE_SETTING_ID = "fast-mode";
21530
+ var MODEL_CATALOG_LIMIT = 1e3;
21531
+ var FAST_TIER = "fast";
21532
+ var SERVICE_TIER_FAST = "priority";
21533
+ var WORKSPACE_WRITE_POLICY = Object.freeze({
21534
+ excludeSlashTmp: false,
21535
+ excludeTmpdirEnvVar: false,
21536
+ networkAccess: false,
21537
+ type: "workspaceWrite",
21538
+ writableRoots: []
21539
+ });
21540
+ var READ_ONLY_MODE = Object.freeze({
21541
+ approvalPolicy: "on-request",
21542
+ approvalsReviewer: "user",
21543
+ description: "Always ask to edit external files and use the internet",
21544
+ id: "read-only",
21545
+ name: "Ask for approval",
21546
+ sandboxPolicy: WORKSPACE_WRITE_POLICY
21547
+ });
21548
+ var AGENT_MODE = Object.freeze({
21549
+ approvalPolicy: "on-request",
21550
+ approvalsReviewer: "auto_review",
21551
+ description: "Only ask for actions detected as potentially unsafe",
21552
+ id: "agent",
21553
+ name: "Approve for me",
21554
+ sandboxPolicy: WORKSPACE_WRITE_POLICY
21555
+ });
21556
+ var FULL_ACCESS_MODE = Object.freeze({
21557
+ approvalPolicy: "never",
21558
+ approvalsReviewer: "user",
21559
+ description: "Unrestricted access to the internet and any file on your computer",
21560
+ id: "agent-full-access",
21561
+ name: "Full access",
21562
+ sandboxPolicy: { type: "dangerFullAccess" }
21563
+ });
21564
+ var AGENT_MODES = Object.freeze([READ_ONLY_MODE, AGENT_MODE, FULL_ACCESS_MODE]);
21565
+ var DEFAULT_MODE = AGENT_MODE;
21566
+ function initialMode(environment) {
21567
+ const requested = environment["INITIAL_AGENT_MODE"];
21568
+ if (requested === void 0) {
21569
+ return DEFAULT_MODE.id;
21570
+ }
21571
+ return AGENT_MODES.some((mode) => mode.id === requested) ? requested : DEFAULT_MODE.id;
21572
+ }
21573
+ function capitalize(value) {
21574
+ return value.length === 0 ? value : value.charAt(0).toUpperCase() + value.slice(1);
21575
+ }
21576
+ function threadTitle(thread) {
21577
+ const named = thread.name?.trim() ?? "";
21578
+ if (named.length > 0) {
21579
+ return named;
21580
+ }
21581
+ return thread.preview?.trim() ?? "";
21582
+ }
21583
+ function isoTimestamp(seconds) {
21584
+ if (seconds == null || !Number.isFinite(seconds)) {
21585
+ return null;
21586
+ }
21587
+ return new Date(seconds * 1e3).toISOString();
21588
+ }
21589
+ function steeringParams(params) {
21590
+ const prompt = typeof params === "object" && params !== null ? Reflect.get(params, "prompt") : void 0;
21591
+ if (!Array.isArray(prompt)) {
21592
+ throw new AcpExecutionError("The steering prompt is invalid", {}, "steering_failed");
21593
+ }
21594
+ return { prompt };
21595
+ }
21484
21596
  var APPROVAL_OPTIONS = Object.freeze([
21485
21597
  { kind: "allow_once", name: "Allow once", optionId: "accept" },
21486
21598
  { kind: "allow_always", name: "Allow for this session", optionId: "acceptForSession" },
@@ -21518,6 +21630,84 @@ function promptInput(prompt) {
21518
21630
  }
21519
21631
  return input2;
21520
21632
  }
21633
+ function modelValues(models) {
21634
+ return models.map((model) => ({
21635
+ description: model.description ?? "",
21636
+ name: model.displayName ?? model.id,
21637
+ value: model.id
21638
+ }));
21639
+ }
21640
+ function effortValues(model) {
21641
+ return (model?.supportedReasoningEfforts ?? []).map((option) => ({
21642
+ description: option.description ?? "",
21643
+ name: capitalize(option.reasoningEffort),
21644
+ value: option.reasoningEffort
21645
+ }));
21646
+ }
21647
+ function modelSetting(models, currentValue) {
21648
+ const values = modelValues(models);
21649
+ const current = currentValue.length > 0 ? currentValue : models.find((model) => model.isDefault === true)?.id ?? values[0]?.value ?? "";
21650
+ if (current.length === 0) {
21651
+ return null;
21652
+ }
21653
+ const options = values.some((value) => value.value === current) ? values : [{ description: "", name: current, value: current }, ...values];
21654
+ return {
21655
+ category: "model",
21656
+ currentValue: current,
21657
+ description: "Model Codex uses for the session",
21658
+ id: MODEL_SETTING_ID,
21659
+ name: "Model",
21660
+ options,
21661
+ type: "select"
21662
+ };
21663
+ }
21664
+ function modeSetting(currentValue) {
21665
+ return {
21666
+ category: "mode",
21667
+ currentValue,
21668
+ description: "Approval and sandboxing preset for the session",
21669
+ id: MODE_SETTING_ID,
21670
+ name: "Mode",
21671
+ options: AGENT_MODES.map((mode) => ({
21672
+ description: mode.description,
21673
+ name: mode.name,
21674
+ value: mode.id
21675
+ })),
21676
+ type: "select"
21677
+ };
21678
+ }
21679
+ function fastModeSetting(model, enabled) {
21680
+ if (model?.additionalSpeedTiers?.includes(FAST_TIER) !== true) {
21681
+ return null;
21682
+ }
21683
+ return {
21684
+ category: "model_config",
21685
+ currentValue: enabled,
21686
+ description: "1.5x speed, increased usage",
21687
+ id: FAST_MODE_SETTING_ID,
21688
+ name: "Fast mode",
21689
+ type: "boolean"
21690
+ };
21691
+ }
21692
+ function effortSetting(model, currentValue) {
21693
+ const values = effortValues(model);
21694
+ if (values.length === 0) {
21695
+ return null;
21696
+ }
21697
+ const current = values.some((value) => value.value === currentValue) ? currentValue : values[0]?.value ?? "";
21698
+ if (current.length === 0) {
21699
+ return null;
21700
+ }
21701
+ return {
21702
+ category: "thought_level",
21703
+ currentValue: current,
21704
+ description: "How much reasoning effort the model should use",
21705
+ id: REASONING_EFFORT_SETTING_ID,
21706
+ name: "Reasoning effort",
21707
+ options: values,
21708
+ type: "select"
21709
+ };
21710
+ }
21521
21711
  function userInputSchema(questions) {
21522
21712
  const properties = {};
21523
21713
  const required2 = [];
@@ -21542,10 +21732,21 @@ var CodexAcpAgent = class {
21542
21732
  #app;
21543
21733
  #appServer;
21544
21734
  #connection = null;
21735
+ #models = [];
21545
21736
  #nativeSessionId = "";
21737
+ // Whether the current turn must carry a policy at all. Until the user picks a mode, Codex's own
21738
+ // configuration decides, so `turn/start` omits the fields and inherits what the host set up.
21739
+ #policySelected = false;
21740
+ #selection;
21546
21741
  #turn = null;
21547
21742
  #updateTail = Promise.resolve();
21548
21743
  constructor(options) {
21744
+ this.#selection = {
21745
+ effort: "",
21746
+ fastMode: false,
21747
+ mode: initialMode(options.environment),
21748
+ model: ""
21749
+ };
21549
21750
  this.#appServer = new CodexAppServerClient({
21550
21751
  command: options.command,
21551
21752
  cwd: options.cwd,
@@ -21565,10 +21766,12 @@ var CodexAcpAgent = class {
21565
21766
  agentCapabilities: {
21566
21767
  loadSession: false,
21567
21768
  promptCapabilities: { embeddedContext: true, image: true },
21568
- sessionCapabilities: { close: {} }
21769
+ sessionCapabilities: { close: {}, delete: {}, list: {}, resume: {} }
21569
21770
  },
21570
21771
  agentInfo: { name: "Codex", version: CODEX_AGENT_VERSION },
21571
21772
  authMethods: [],
21773
+ // Mobius reads this to decide whether mid-turn steering can be attempted at all.
21774
+ _meta: { steering: { supported: true } },
21572
21775
  protocolVersion: PROTOCOL_VERSION
21573
21776
  })).onRequest(methods.agent.session.new, async (context) => {
21574
21777
  const created = threadStartResponseSchema.parse(
@@ -21579,9 +21782,92 @@ var CodexAcpAgent = class {
21579
21782
  )
21580
21783
  );
21581
21784
  this.#nativeSessionId = created.thread.id;
21582
- return { sessionId: created.thread.id };
21785
+ this.#selection = {
21786
+ ...this.#selection,
21787
+ effort: created.reasoningEffort ?? "",
21788
+ model: created.model ?? ""
21789
+ };
21790
+ return { configOptions: this.#configOptions(), sessionId: created.thread.id };
21791
+ }).onRequest(methods.agent.session.resume, async (context) => {
21792
+ const resumed = threadResumeResponseSchema.parse(
21793
+ await this.#appServer.request(
21794
+ "thread/resume",
21795
+ { cwd: context.params.cwd, threadId: context.params.sessionId },
21796
+ AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
21797
+ )
21798
+ );
21799
+ if (resumed.thread == null) {
21800
+ throw new AcpExecutionError(
21801
+ "Codex no longer has the native session this conversation belongs to",
21802
+ {},
21803
+ "session_restore_unsupported"
21804
+ );
21805
+ }
21806
+ this.#nativeSessionId = resumed.thread.id;
21807
+ this.#selection = {
21808
+ ...this.#selection,
21809
+ effort: resumed.reasoningEffort ?? this.#selection.effort,
21810
+ model: resumed.model ?? this.#selection.model
21811
+ };
21812
+ return { configOptions: this.#configOptions() };
21813
+ }).onRequest(methods.agent.session.list, async (context) => {
21814
+ const listed = threadListResponseSchema.parse(
21815
+ await this.#appServer.request(
21816
+ "thread/list",
21817
+ context.params.cursor === void 0 || context.params.cursor === null ? {} : { cursor: context.params.cursor },
21818
+ AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
21819
+ )
21820
+ );
21821
+ return {
21822
+ nextCursor: listed.nextCursor ?? null,
21823
+ sessions: listed.data.map((thread) => ({
21824
+ // The thread id is a UUID, which satisfies the native session id contract.
21825
+ additionalDirectories: [],
21826
+ cwd: thread.cwd ?? "",
21827
+ sessionId: thread.id,
21828
+ title: threadTitle(thread),
21829
+ updatedAt: isoTimestamp(thread.updatedAt)
21830
+ }))
21831
+ };
21832
+ }).onRequest(methods.agent.session.delete, async (context) => {
21833
+ await this.#appServer.request(
21834
+ "thread/archive",
21835
+ { threadId: context.params.sessionId },
21836
+ AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
21837
+ );
21838
+ return {};
21839
+ }).onRequest(methods.agent.session.setConfigOption, async (context) => {
21840
+ this.#applySelection(context.params.configId, context.params.value);
21841
+ return { configOptions: this.#configOptions() };
21842
+ }).onRequest(methods.agent.session.setMode, async (context) => {
21843
+ this.#applySelection(MODE_SETTING_ID, context.params.modeId);
21844
+ return {};
21583
21845
  }).onRequest(methods.agent.session.prompt, async (context) => {
21584
21846
  return await this.#runTurn(promptInput(context.params.prompt), context.signal);
21847
+ }).onRequest(STEERING_METHOD, steeringParams, async (context) => {
21848
+ const turn = this.#turn;
21849
+ if (turn === null || turn.turn.id.length === 0) {
21850
+ return { outcome: "promptRequired" };
21851
+ }
21852
+ try {
21853
+ const steered = turnSteerResponseSchema.parse(
21854
+ await this.#appServer.request(
21855
+ "turn/steer",
21856
+ {
21857
+ expectedTurnId: turn.turn.id,
21858
+ input: promptInput(context.params.prompt),
21859
+ threadId: this.#nativeSessionId
21860
+ },
21861
+ AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
21862
+ )
21863
+ );
21864
+ return { outcome: steered.turnId === turn.turn.id ? "injected" : "startedNewTurn" };
21865
+ } catch (error62) {
21866
+ if (error62 instanceof CodexAppServerError) {
21867
+ return { outcome: "promptRequired" };
21868
+ }
21869
+ throw error62;
21870
+ }
21585
21871
  }).onRequest(methods.agent.session.close, async () => {
21586
21872
  await this.#interruptTurn();
21587
21873
  }).onNotification(methods.agent.session.cancel, async () => {
@@ -21590,9 +21876,10 @@ var CodexAcpAgent = class {
21590
21876
  }
21591
21877
  /** The ACP agent app Mobius connects its own ACP client to, in-process. */
21592
21878
  app = () => this.#app;
21593
- /** Starts the app-server and performs its handshake. */
21879
+ /** Starts the app-server, performs its handshake, and reads the model catalog Codex offers. */
21594
21880
  initialize = async (signal) => {
21595
21881
  await this.#appServer.initialize(signal);
21882
+ await this.#loadModels(signal);
21596
21883
  };
21597
21884
  /**
21598
21885
  * Releases the app-server and every process it started. Mirrors the adapter path's teardown so a
@@ -21604,6 +21891,129 @@ var CodexAcpAgent = class {
21604
21891
  this.#appServer.detach();
21605
21892
  await stopProcessTree(child, captured);
21606
21893
  };
21894
+ /**
21895
+ * Reads the model catalog once per app-server. A failure leaves the catalog empty, which costs
21896
+ * the Run settings panel its model selector; it must not cost the conversation itself, so the
21897
+ * turn lifecycle continues without settings rather than failing initialization.
21898
+ */
21899
+ #loadModels = async (signal) => {
21900
+ const models = [];
21901
+ let cursor = null;
21902
+ try {
21903
+ do {
21904
+ const decoded = modelListResponseSchema.parse(
21905
+ await this.#appServer.request(
21906
+ "model/list",
21907
+ { cursor, limit: null },
21908
+ AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
21909
+ )
21910
+ );
21911
+ models.push(...decoded.data);
21912
+ cursor = decoded.nextCursor ?? null;
21913
+ } while (cursor !== null && models.length < MODEL_CATALOG_LIMIT);
21914
+ } catch (error62) {
21915
+ signal.throwIfAborted();
21916
+ process.stderr.write(`[codex-acp] model catalog unavailable: ${String(error62)}
21917
+ `);
21918
+ }
21919
+ this.#models = Object.freeze(models.slice(0, MODEL_CATALOG_LIMIT));
21920
+ };
21921
+ #model = (id) => this.#models.find((model) => model.id === id);
21922
+ /** The ACP settings Mobius discovers and renders in Run settings. */
21923
+ #configOptions = () => {
21924
+ const options = [];
21925
+ const model = modelSetting(this.#models, this.#selection.model);
21926
+ if (model !== null) {
21927
+ options.push(model);
21928
+ }
21929
+ const effort = effortSetting(this.#model(this.#selection.model), this.#selection.effort);
21930
+ if (effort !== null) {
21931
+ options.push(effort);
21932
+ }
21933
+ const fastMode = fastModeSetting(this.#model(this.#selection.model), this.#selection.fastMode);
21934
+ if (fastMode !== null) {
21935
+ options.push(fastMode);
21936
+ }
21937
+ options.push(modeSetting(this.#selection.mode));
21938
+ return options;
21939
+ };
21940
+ /**
21941
+ * Applies one `session/set_config_option`. Switching models re-resolves the effort the way Codex
21942
+ * does — the current effort when the new model supports it, otherwise the model's own default —
21943
+ * so the reply never advertises an effort the selected model cannot run.
21944
+ */
21945
+ #applySelection = (configId, value) => {
21946
+ if (configId === FAST_MODE_SETTING_ID) {
21947
+ if (typeof value !== "boolean") {
21948
+ throw new AcpExecutionError(
21949
+ "The requested Codex setting is invalid",
21950
+ {},
21951
+ "invalid_session_configuration"
21952
+ );
21953
+ }
21954
+ if (value && this.#model(this.#selection.model)?.additionalSpeedTiers?.includes(FAST_TIER) !== true) {
21955
+ throw new AcpExecutionError(
21956
+ "The selected Codex model has no fast mode",
21957
+ {},
21958
+ "invalid_session_configuration"
21959
+ );
21960
+ }
21961
+ this.#selection = { ...this.#selection, fastMode: value };
21962
+ return;
21963
+ }
21964
+ if (typeof value !== "string") {
21965
+ throw new AcpExecutionError("The requested Codex setting is invalid", {}, "invalid_session_configuration");
21966
+ }
21967
+ if (configId === MODE_SETTING_ID) {
21968
+ if (!AGENT_MODES.some((mode) => mode.id === value)) {
21969
+ throw new AcpExecutionError(
21970
+ "The requested Codex mode is unavailable",
21971
+ {},
21972
+ "invalid_session_configuration"
21973
+ );
21974
+ }
21975
+ this.#selection = { ...this.#selection, mode: value };
21976
+ this.#policySelected = true;
21977
+ return;
21978
+ }
21979
+ if (configId === MODEL_SETTING_ID) {
21980
+ if (value === this.#selection.model) {
21981
+ return;
21982
+ }
21983
+ const model = this.#model(value);
21984
+ if (model === void 0) {
21985
+ throw new AcpExecutionError(
21986
+ "The requested Codex model is unavailable",
21987
+ {},
21988
+ "invalid_session_configuration"
21989
+ );
21990
+ }
21991
+ const supported = (model.supportedReasoningEfforts ?? []).map((option) => option.reasoningEffort);
21992
+ const effort = supported.includes(this.#selection.effort) ? this.#selection.effort : model.defaultReasoningEffort ?? supported[0] ?? "";
21993
+ this.#selection = {
21994
+ ...this.#selection,
21995
+ effort,
21996
+ fastMode: this.#selection.fastMode && model.additionalSpeedTiers?.includes(FAST_TIER) === true,
21997
+ model: value
21998
+ };
21999
+ return;
22000
+ }
22001
+ if (configId === REASONING_EFFORT_SETTING_ID) {
22002
+ const supported = (this.#model(this.#selection.model)?.supportedReasoningEfforts ?? []).map(
22003
+ (option) => option.reasoningEffort
22004
+ );
22005
+ if (!supported.includes(value)) {
22006
+ throw new AcpExecutionError(
22007
+ "The requested Codex reasoning effort is unavailable",
22008
+ {},
22009
+ "invalid_session_configuration"
22010
+ );
22011
+ }
22012
+ this.#selection = { ...this.#selection, effort: value };
22013
+ return;
22014
+ }
22015
+ throw new AcpExecutionError("The requested Codex setting is unavailable", {}, "invalid_session_configuration");
22016
+ };
21607
22017
  #emit = async (update) => {
21608
22018
  const connection = this.#connection;
21609
22019
  if (connection === null || this.#nativeSessionId.length === 0) {
@@ -21809,10 +22219,27 @@ var CodexAcpAgent = class {
21809
22219
  const turn = { completion, turn: { id: "" } };
21810
22220
  this.#turn = turn;
21811
22221
  try {
22222
+ const selection = this.#selection;
22223
+ const mode = AGENT_MODES.find((candidate) => candidate.id === selection.mode) ?? DEFAULT_MODE;
22224
+ const supportsFast = this.#model(selection.model)?.additionalSpeedTiers?.includes(FAST_TIER) === true;
21812
22225
  const started = turnSchema.parse(
21813
22226
  (await this.#appServer.request(
21814
22227
  "turn/start",
21815
- { input: input2, threadId: this.#nativeSessionId },
22228
+ {
22229
+ // Until a mode is chosen, `config.toml` decides the sandbox and approval
22230
+ // policy, and those fields stay off the turn so the host's own setup is
22231
+ // inherited rather than overridden.
22232
+ ...this.#policySelected ? {
22233
+ approvalPolicy: mode.approvalPolicy,
22234
+ approvalsReviewer: mode.approvalsReviewer,
22235
+ sandboxPolicy: mode.sandboxPolicy
22236
+ } : {},
22237
+ ...selection.effort.length === 0 ? {} : { effort: selection.effort },
22238
+ input: input2,
22239
+ ...selection.model.length === 0 ? {} : { model: selection.model },
22240
+ ...selection.fastMode && supportsFast ? { serviceTier: SERVICE_TIER_FAST } : {},
22241
+ threadId: this.#nativeSessionId
22242
+ },
21816
22243
  signal
21817
22244
  )).turn
21818
22245
  );
@@ -24253,6 +24680,7 @@ var RUNTIME_DELIVERY_COMMITTED_KIND = "runtime.delivery.committed";
24253
24680
  var SESSION_STARTED_KIND = "session.started";
24254
24681
  var AGENT_MESSAGE_DELTA_KIND = "agent.message.delta";
24255
24682
  var AGENT_ACTIVITY_KIND = "agent.activity";
24683
+ var AGENT_ACTIVITY_NARRATION_KIND = "agent.activity.narration";
24256
24684
  var AGENT_ACTIVITY_DETAIL_LIMIT = 5e5;
24257
24685
  var AGENT_ACTIVITY_RECORDED_FIELD_LIMIT = 4e6;
24258
24686
  var AGENT_ACTIVITY_RECORDED_DETAIL_LIMIT = 6e6;
@@ -24274,6 +24702,7 @@ var MAX_PROMPT_ATTACHMENT_LENGTH = 6e6;
24274
24702
  var MAX_EVENT_TEXT_LENGTH = 1e5;
24275
24703
  var MAX_RUNTIME_DELIVERY_PAYLOAD_LENGTH = 8 * 1024 * 1024;
24276
24704
  var ACTIVITY_TYPES = /* @__PURE__ */ new Set(["plan", "progress", "reasoning", "tool"]);
24705
+ var NARRATION_ACTIVITY_TYPES = /* @__PURE__ */ new Set(["progress", "reasoning"]);
24277
24706
  var ACTIVITY_STATUSES = /* @__PURE__ */ new Set(["pending", "running", "completed", "failed"]);
24278
24707
  var TOOL_KINDS = /* @__PURE__ */ new Set([
24279
24708
  "",
@@ -24697,6 +25126,20 @@ function encodeRuntimeDeliveryReceived(message) {
24697
25126
  function encodeRuntimeDeliveryCommitted(message) {
24698
25127
  return JSON.stringify(decodeRuntimeDeliveryCommitted(JSON.stringify(message)));
24699
25128
  }
25129
+ function decodeAgentActivityNarrationEvent(encoded) {
25130
+ const value = parseJson2(encoded);
25131
+ assertExactKeys(value, ["activityId", "activityType", "commandId", "kind", "sequence", "sessionId", "text"]);
25132
+ assertKind(value, AGENT_ACTIVITY_NARRATION_KIND);
25133
+ return {
25134
+ activityId: readIdentifier(value, "activityId"),
25135
+ activityType: readAllowedString(value, "activityType", NARRATION_ACTIVITY_TYPES),
25136
+ commandId: readIdentifier(value, "commandId"),
25137
+ kind: AGENT_ACTIVITY_NARRATION_KIND,
25138
+ sequence: readSequence(value, "sequence"),
25139
+ sessionId: readIdentifier(value, "sessionId"),
25140
+ text: readText(value, "text", MAX_EVENT_TEXT_LENGTH)
25141
+ };
25142
+ }
24700
25143
 
24701
25144
  // ../protocol/src/session-history.ts
24702
25145
  var SESSION_HISTORY_CHARACTER_LIMIT = 256e3;
@@ -24832,6 +25275,26 @@ var nativeSessionTurnForkCommandSchema = external_exports.strictObject({
24832
25275
  messageOccurrence: external_exports.number().int().positive(),
24833
25276
  title: external_exports.string().max(500)
24834
25277
  }).readonly();
25278
+ var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
25279
+ external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
25280
+ external_exports.strictObject({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifier }).readonly(),
25281
+ external_exports.strictObject({
25282
+ ...identity,
25283
+ action: external_exports.literal("list"),
25284
+ cursor: identifier.nullable()
25285
+ }).readonly(),
25286
+ external_exports.strictObject({
25287
+ ...identity,
25288
+ action: external_exports.enum(["import", "fork"]),
25289
+ entryId: identifier,
25290
+ targetSessionId: identifier
25291
+ }).readonly(),
25292
+ external_exports.strictObject({
25293
+ ...identity,
25294
+ action: external_exports.literal("delete"),
25295
+ entryId: identifier
25296
+ }).readonly()
25297
+ ]);
24835
25298
  var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
24836
25299
  external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
24837
25300
  external_exports.strictObject({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifier }).readonly(),
@@ -24846,6 +25309,12 @@ var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
24846
25309
  entryId: identifier,
24847
25310
  targetSessionId: identifier
24848
25311
  }).readonly(),
25312
+ external_exports.strictObject({
25313
+ ...identity,
25314
+ action: external_exports.enum(["import-only", "fork-only"]),
25315
+ entryId: identifier,
25316
+ targetSessionId: identifier
25317
+ }).readonly(),
24849
25318
  external_exports.strictObject({
24850
25319
  ...identity,
24851
25320
  action: external_exports.literal("delete"),
@@ -25019,6 +25488,8 @@ function decodeRecordedSessionEvent(encoded) {
25019
25488
  switch (kind) {
25020
25489
  case AGENT_ACTIVITY_KIND:
25021
25490
  return decodeAgentActivityEvent(encoded);
25491
+ case AGENT_ACTIVITY_NARRATION_KIND:
25492
+ return decodeAgentActivityNarrationEvent(encoded);
25022
25493
  case AGENT_CONTENT_KIND:
25023
25494
  return decodeAgentContentEvent(encoded);
25024
25495
  case AGENT_MESSAGE_DELTA_KIND:
@@ -25704,6 +26175,18 @@ async function replaceImageMarkers(text3, replace) {
25704
26175
 
25705
26176
  // src/acp/activity.ts
25706
26177
  var TRUNCATION_MARKER = "\n\u2026 output truncated by Mobius";
26178
+ var AcpActivityNarration = class {
26179
+ activityId;
26180
+ activityType;
26181
+ sequence;
26182
+ text;
26183
+ constructor(activityId, activityType, sequence, text3) {
26184
+ this.activityId = activityId;
26185
+ this.activityType = activityType;
26186
+ this.sequence = sequence;
26187
+ this.text = text3;
26188
+ }
26189
+ };
25707
26190
  function isRecord5(value) {
25708
26191
  return typeof value === "object" && value !== null && !Array.isArray(value);
25709
26192
  }
@@ -26036,12 +26519,15 @@ function isProgressMessage(content3) {
26036
26519
  var AcpActivityTracker = class {
26037
26520
  #activities = /* @__PURE__ */ new Map();
26038
26521
  #identities = /* @__PURE__ */ new Map();
26522
+ #narrations = /* @__PURE__ */ new Map();
26039
26523
  #onActivity;
26524
+ #onNarration;
26040
26525
  #prepareContent;
26041
26526
  #activeNarrativeKey = "";
26042
26527
  #nextSequence = 0;
26043
- constructor(onActivity, prepareContent = (content3) => Promise.resolve(content3)) {
26528
+ constructor(onActivity, onNarration, prepareContent = (content3) => Promise.resolve(content3)) {
26044
26529
  this.#onActivity = onActivity;
26530
+ this.#onNarration = onNarration;
26045
26531
  this.#prepareContent = prepareContent;
26046
26532
  }
26047
26533
  recordNarrative = async (activityType, messageId, text3) => {
@@ -26049,26 +26535,34 @@ var AcpActivityTracker = class {
26049
26535
  if (this.#activeNarrativeKey !== key) {
26050
26536
  await this.finishNarrative();
26051
26537
  }
26052
- const previous2 = this.#activities.get(key);
26053
26538
  const identity2 = this.#identity(key);
26054
- const fullOutput = `${recordedDetail(previous2)?.output ?? previous2?.output ?? ""}${text3}`;
26055
- const activity2 = new AcpActivity(
26056
- identity2.id,
26539
+ const previous2 = this.#narrations.get(key);
26540
+ this.#narrations.set(key, {
26541
+ activityId: identity2.id,
26057
26542
  activityType,
26058
- "",
26059
- [],
26060
- "",
26061
- truncate2(fullOutput, AGENT_ACTIVITY_DETAIL_LIMIT),
26062
- identity2.sequence,
26063
- "running",
26064
- activityType === "reasoning" ? "Reasoning" : "Progress update",
26065
- activityType === "reasoning" ? "think" : "",
26066
- [],
26067
- captureActivityDetail([], "", fullOutput)
26068
- );
26069
- await this.#record(key, activity2);
26543
+ output: `${previous2?.output ?? ""}${text3}`,
26544
+ sequence: identity2.sequence
26545
+ });
26546
+ if (previous2 === void 0) {
26547
+ await this.#record(key, this.#narrativeSnapshot(identity2, activityType, "", "running"));
26548
+ }
26070
26549
  this.#activeNarrativeKey = key;
26550
+ if (text3.length > 0) {
26551
+ await this.#onNarration(new AcpActivityNarration(identity2.id, activityType, identity2.sequence, text3));
26552
+ }
26071
26553
  };
26554
+ #narrativeSnapshot = (identity2, activityType, output2, status) => new AcpActivity(
26555
+ identity2.id,
26556
+ activityType,
26557
+ "",
26558
+ [],
26559
+ "",
26560
+ truncate2(output2, AGENT_ACTIVITY_DETAIL_LIMIT),
26561
+ identity2.sequence,
26562
+ status,
26563
+ activityType === "reasoning" ? "Reasoning" : "Progress update",
26564
+ activityType === "reasoning" ? "think" : ""
26565
+ );
26072
26566
  recordPlan = async (plan) => {
26073
26567
  await this.finishNarrative();
26074
26568
  await this.#recordPlanEntries("plan:default", plan.entries);
@@ -26188,17 +26682,13 @@ var AcpActivityTracker = class {
26188
26682
  return;
26189
26683
  }
26190
26684
  this.#activeNarrativeKey = "";
26191
- const activity2 = this.#activities.get(key);
26192
- if (activity2 === void 0) {
26193
- return;
26194
- }
26195
- const completed = activity2.complete();
26196
- if (completed !== activity2) {
26197
- await this.#record(key, completed);
26198
- }
26685
+ await this.#completeNarrative(key);
26199
26686
  };
26200
26687
  finish = async () => {
26201
26688
  await this.finishNarrative();
26689
+ for (const key of this.#narrations.keys()) {
26690
+ await this.#completeNarrative(key);
26691
+ }
26202
26692
  const entries = [...this.#activities.entries()].sort((left, right) => left[1].sequence - right[1].sequence);
26203
26693
  for (const [key, activity2] of entries) {
26204
26694
  const completed = activity2.complete();
@@ -26207,6 +26697,34 @@ var AcpActivityTracker = class {
26207
26697
  }
26208
26698
  }
26209
26699
  };
26700
+ // Materialize a streamed narration as one completed snapshot activity. The
26701
+ // incremental events carried the text; this final event gives consumers the
26702
+ // whole narration with its terminal status, as a single bounded item.
26703
+ #completeNarrative = async (key) => {
26704
+ const narration = this.#narrations.get(key);
26705
+ if (narration === void 0) {
26706
+ return;
26707
+ }
26708
+ this.#narrations.delete(key);
26709
+ const previous2 = this.#activities.get(key);
26710
+ await this.#record(
26711
+ key,
26712
+ new AcpActivity(
26713
+ narration.activityId,
26714
+ narration.activityType,
26715
+ "",
26716
+ [],
26717
+ "",
26718
+ truncate2(narration.output, AGENT_ACTIVITY_DETAIL_LIMIT),
26719
+ narration.sequence,
26720
+ "completed",
26721
+ narration.activityType === "reasoning" ? "Reasoning" : "Progress update",
26722
+ narration.activityType === "reasoning" ? "think" : "",
26723
+ previous2?.content ?? [],
26724
+ captureActivityDetail([], "", narration.output)
26725
+ )
26726
+ );
26727
+ };
26210
26728
  #identity = (key) => {
26211
26729
  const existing = this.#identities.get(key);
26212
26730
  if (existing !== void 0) {
@@ -33850,17 +34368,22 @@ var AcpHistoryReplay = class {
33850
34368
  #activities = /* @__PURE__ */ new Map();
33851
34369
  #messages = [];
33852
34370
  #turnActivityIds = /* @__PURE__ */ new Set();
33853
- #activityTracker = new AcpActivityTracker(async (activity2) => {
33854
- this.#activities.set(activity2.activityId, activity2);
33855
- this.#turnActivityIds.add(activity2.activityId);
33856
- const latest = this.#messages.at(-1);
33857
- if (latest?.role === "assistant") {
33858
- this.#messages[this.#messages.length - 1] = {
33859
- ...latest,
33860
- activityIds: [...this.#turnActivityIds]
33861
- };
33862
- }
33863
- });
34371
+ #activityTracker = new AcpActivityTracker(
34372
+ async (activity2) => {
34373
+ this.#activities.set(activity2.activityId, activity2);
34374
+ this.#turnActivityIds.add(activity2.activityId);
34375
+ const latest = this.#messages.at(-1);
34376
+ if (latest?.role === "assistant") {
34377
+ this.#messages[this.#messages.length - 1] = {
34378
+ ...latest,
34379
+ activityIds: [...this.#turnActivityIds]
34380
+ };
34381
+ }
34382
+ },
34383
+ // History replay folds each narration into its snapshot activity, so no
34384
+ // separate incremental event is produced here.
34385
+ () => Promise.resolve()
34386
+ );
33864
34387
  #lastMessageId = null;
33865
34388
  #characters = 0;
33866
34389
  #truncated = false;
@@ -34220,6 +34743,15 @@ var MAX_PRE_SESSION_UPDATES = 100;
34220
34743
  var MAX_PRE_SESSION_UPDATE_BYTES = 1024 * 1024;
34221
34744
  var SESSION_CONTROL_COMMAND_ID = "session-control";
34222
34745
  var SESSION_CONTROL_TIMEOUT_MILLISECONDS = 3e4;
34746
+ function nativeHistoryNotRetained() {
34747
+ return {
34748
+ cause: {
34749
+ code: "native_history_not_retained",
34750
+ message: "Native message history is not retained in the cloud for this Session."
34751
+ },
34752
+ status: "unavailable"
34753
+ };
34754
+ }
34223
34755
  var NullAcpSessionObserver = class {
34224
34756
  onCommands = () => Promise.resolve();
34225
34757
  onConfig = () => Promise.resolve();
@@ -34670,7 +35202,10 @@ var AcpTurnState = class {
34670
35202
  var IdleAcpTurn = class extends AcpTurnState {
34671
35203
  commandId = SESSION_CONTROL_COMMAND_ID;
34672
35204
  running = false;
34673
- activities = new AcpActivityTracker(() => Promise.resolve());
35205
+ activities = new AcpActivityTracker(
35206
+ () => Promise.resolve(),
35207
+ () => Promise.resolve()
35208
+ );
34674
35209
  onText = () => Promise.resolve();
34675
35210
  };
34676
35211
  var RunningAcpTurn = class extends AcpTurnState {
@@ -34678,10 +35213,10 @@ var RunningAcpTurn = class extends AcpTurnState {
34678
35213
  running = true;
34679
35214
  activities;
34680
35215
  onText;
34681
- constructor(commandId, onActivity, onText, prepareContent) {
35216
+ constructor(commandId, onActivity, onNarration, onText, prepareContent) {
34682
35217
  super();
34683
35218
  this.commandId = commandId;
34684
- this.activities = new AcpActivityTracker(onActivity, prepareContent);
35219
+ this.activities = new AcpActivityTracker(onActivity, onNarration ?? (() => Promise.resolve()), prepareContent);
34685
35220
  this.onText = onText;
34686
35221
  }
34687
35222
  };
@@ -35486,6 +36021,7 @@ var AcpProcessSession = class _AcpProcessSession {
35486
36021
  const running = new RunningAcpTurn(
35487
36022
  options.commandId,
35488
36023
  options.onActivity,
36024
+ options.onNarration,
35489
36025
  options.onText,
35490
36026
  this.prepareAgentContent
35491
36027
  );
@@ -36885,7 +37421,7 @@ var AcpSessionManager = class {
36885
37421
  this.#endSessionUse(options.sessionId);
36886
37422
  }
36887
37423
  };
36888
- openNativeSession = async (options, origin) => {
37424
+ openNativeSession = async (options, origin, loadHistory) => {
36889
37425
  const key = `${options.agent.id}:${origin.nativeSessionId}`;
36890
37426
  if (this.#nativeOperations.has(key)) {
36891
37427
  throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
@@ -36915,7 +37451,7 @@ var AcpSessionManager = class {
36915
37451
  }
36916
37452
  this.#nativeOperations.add(key);
36917
37453
  try {
36918
- const history = await runtime.loadHistory(options.signal);
37454
+ const history = loadHistory ? await runtime.loadHistory(options.signal) : nativeHistoryNotRetained();
36919
37455
  return {
36920
37456
  prepared: runtime.prepared(),
36921
37457
  sessionId: existing.sessionId,
@@ -36946,7 +37482,7 @@ var AcpSessionManager = class {
36946
37482
  const openedKey = `${options.agent.id}:${runtime.nativeSessionId()}`;
36947
37483
  this.#nativeOperations.add(openedKey);
36948
37484
  try {
36949
- const history = await runtime.loadHistory(options.signal);
37485
+ const history = loadHistory ? await runtime.loadHistory(options.signal) : nativeHistoryNotRetained();
36950
37486
  return {
36951
37487
  sessionId: options.sessionId,
36952
37488
  prepared: runtime.prepared(),
@@ -38096,6 +38632,54 @@ var WorkspaceDirectoryService = class {
38096
38632
  };
38097
38633
  };
38098
38634
 
38635
+ // src/daemon-diagnostic-log.ts
38636
+ import { appendFileSync, mkdirSync as mkdirSync3, readFileSync as readFileSync2, renameSync, statSync as statSync3, writeFileSync } from "node:fs";
38637
+ import { join as join16 } from "node:path";
38638
+ var MAXIMUM_DAEMON_LOG_BYTES = 1 * 1024 * 1024;
38639
+ var DaemonDiagnosticLog = class {
38640
+ #directory;
38641
+ #path;
38642
+ #maximumBytes;
38643
+ constructor(stateDirectory, maximumBytes = MAXIMUM_DAEMON_LOG_BYTES) {
38644
+ this.#directory = join16(stateDirectory, "logs");
38645
+ this.#path = join16(this.#directory, "daemon.log");
38646
+ this.#maximumBytes = maximumBytes;
38647
+ }
38648
+ record = (diagnostic) => {
38649
+ const encoded = `${diagnostic.replace(/[\r\n]+/gu, " ").trim()}
38650
+ `;
38651
+ const encodedBytes = Buffer.byteLength(encoded);
38652
+ mkdirSync3(this.#directory, { mode: 448, recursive: true });
38653
+ let existingBytes = 0;
38654
+ try {
38655
+ existingBytes = statSync3(this.#path).size;
38656
+ } catch (cause) {
38657
+ if (!(cause instanceof Error && Reflect.get(cause, "code") === "ENOENT")) {
38658
+ throw cause;
38659
+ }
38660
+ }
38661
+ if (existingBytes + encodedBytes <= this.#maximumBytes) {
38662
+ appendFileSync(this.#path, encoded, { encoding: "utf8", mode: 384 });
38663
+ return;
38664
+ }
38665
+ const lines = `${existingBytes === 0 ? "" : readFileSync2(this.#path, "utf8")}${encoded}`.split("\n").filter((line) => line.length > 0);
38666
+ let totalBytes = lines.reduce((total, line) => total + Buffer.byteLength(line) + 1, 0);
38667
+ while (totalBytes > this.#maximumBytes && lines.length > 0) {
38668
+ const oldest = lines.shift();
38669
+ if (oldest !== void 0) {
38670
+ totalBytes -= Buffer.byteLength(oldest) + 1;
38671
+ }
38672
+ }
38673
+ const temporaryPath = `${this.#path}.tmp`;
38674
+ writeFileSync(temporaryPath, lines.length === 0 ? "" : `${lines.join("\n")}
38675
+ `, {
38676
+ encoding: "utf8",
38677
+ mode: 384
38678
+ });
38679
+ renameSync(temporaryPath, this.#path);
38680
+ };
38681
+ };
38682
+
38099
38683
  // src/native-sessions/codex-history.ts
38100
38684
  import { spawn as spawn5 } from "node:child_process";
38101
38685
  var responseSchema = external_exports.union([
@@ -38106,7 +38690,7 @@ var responseSchema = external_exports.union([
38106
38690
  external_exports.object({ id: external_exports.number(), result: external_exports.unknown() }),
38107
38691
  external_exports.object({ method: external_exports.string() })
38108
38692
  ]);
38109
- var threadSchema = external_exports.object({
38693
+ var threadSchema2 = external_exports.object({
38110
38694
  thread: external_exports.object({
38111
38695
  id: nativeSessionIdSchema,
38112
38696
  cwd: external_exports.string().min(1).max(2048).refine((path2) => !path2.includes("\0"))
@@ -38410,7 +38994,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
38410
38994
  });
38411
38995
  break;
38412
38996
  case "metadata": {
38413
- const { thread } = threadSchema.parse(message.result);
38997
+ const { thread } = threadSchema2.parse(message.result);
38414
38998
  state = { kind: "turns", requestId: 3, thread };
38415
38999
  send2({
38416
39000
  id: state.requestId,
@@ -38682,10 +39266,11 @@ var NativeSessionService = class {
38682
39266
  deletedSessionIds
38683
39267
  };
38684
39268
  }
38685
- if (command.action === "import" && !prepared.capabilities.loadSession && !prepared.capabilities.resumeSession) {
39269
+ const action = command.action === "import-only" ? "import" : command.action === "fork-only" ? "fork" : command.action;
39270
+ if (action === "import" && !prepared.capabilities.loadSession && !prepared.capabilities.resumeSession) {
38686
39271
  throw new AcpExecutionError("This Agent cannot import native sessions", {}, "native_session_unsupported");
38687
39272
  }
38688
- if (command.action === "fork" && !prepared.capabilities.unstableForkSession) {
39273
+ if (action === "fork" && !prepared.capabilities.unstableForkSession) {
38689
39274
  throw new AcpExecutionError(
38690
39275
  "This Agent does not support session forking",
38691
39276
  {},
@@ -38706,7 +39291,8 @@ var NativeSessionService = class {
38706
39291
  sessionId: command.targetSessionId,
38707
39292
  additionalDirectories: target.additionalDirectories
38708
39293
  },
38709
- { kind: command.action, nativeSessionId: target.info.sessionId }
39294
+ { kind: action, nativeSessionId: target.info.sessionId },
39295
+ command.action !== "import-only" && command.action !== "fork-only"
38710
39296
  );
38711
39297
  signal.throwIfAborted();
38712
39298
  const ready = {
@@ -38724,10 +39310,10 @@ var NativeSessionService = class {
38724
39310
  restored: true,
38725
39311
  sessionId: opened.sessionId
38726
39312
  };
38727
- this.record(command, command.action === "fork" ? "native_session_forked" : "native_session_imported");
39313
+ this.record(command, action === "fork" ? "native_session_forked" : "native_session_imported");
38728
39314
  return {
38729
39315
  ...envelope2,
38730
- action: command.action,
39316
+ action,
38731
39317
  ready,
38732
39318
  targetSessionId: command.targetSessionId,
38733
39319
  title: target.info.title ?? "Untitled session",
@@ -39118,6 +39704,59 @@ async function resolvePromptArtifacts(config2, command, signal) {
39118
39704
  return new ResolvedPromptArtifacts(images, resources);
39119
39705
  }
39120
39706
 
39707
+ // src/relay-connection/coalescing-narration-publisher.ts
39708
+ var CoalescingNarrationPublisher = class {
39709
+ #coalescingMilliseconds;
39710
+ #maximumTextLength;
39711
+ #publish;
39712
+ #timer;
39713
+ #pending = /* @__PURE__ */ new Map();
39714
+ #scheduled = null;
39715
+ constructor(timer, publish, coalescingMilliseconds, maximumTextLength) {
39716
+ this.#publish = publish;
39717
+ this.#timer = timer;
39718
+ this.#coalescingMilliseconds = coalescingMilliseconds;
39719
+ this.#maximumTextLength = maximumTextLength;
39720
+ }
39721
+ /** Emit every buffered increment now, cancelling the pending flush. */
39722
+ flush = () => {
39723
+ this.#scheduled?.cancel();
39724
+ this.#scheduled = null;
39725
+ const increments = [...this.#pending.entries()].map(
39726
+ ([activityId, pending]) => ({
39727
+ activityId,
39728
+ activityType: pending.activityType,
39729
+ sequence: pending.sequence,
39730
+ text: pending.text
39731
+ })
39732
+ );
39733
+ this.#pending.clear();
39734
+ for (const increment of increments) {
39735
+ this.#publish(increment);
39736
+ }
39737
+ };
39738
+ /**
39739
+ * Buffer an increment, emitting the buffered text when it would exceed the
39740
+ * protocol's per-event text limit so no event is rejected by the codec.
39741
+ */
39742
+ record = (increment) => {
39743
+ if (increment.text.length === 0) {
39744
+ return;
39745
+ }
39746
+ const previous2 = this.#pending.get(increment.activityId);
39747
+ if (previous2 !== void 0 && previous2.text.length + increment.text.length > this.#maximumTextLength) {
39748
+ this.flush();
39749
+ }
39750
+ const current = this.#pending.get(increment.activityId);
39751
+ this.#pending.set(increment.activityId, {
39752
+ activityType: increment.activityType,
39753
+ sequence: increment.sequence,
39754
+ text: `${current?.text ?? ""}${increment.text}`
39755
+ });
39756
+ this.#scheduled ??= this.#timer.schedule(this.flush, this.#coalescingMilliseconds);
39757
+ };
39758
+ };
39759
+
39121
39760
  // src/relay-connection/coalescing-text-publisher.ts
39122
39761
  var CoalescingTextPublisher = class {
39123
39762
  #coalescingMilliseconds;
@@ -39327,13 +39966,15 @@ function addFailureDetails(details, failure2) {
39327
39966
  var RelayConnectionDiagnostics = class {
39328
39967
  #audit;
39329
39968
  #channelId;
39969
+ #localLog;
39330
39970
  #lastClosedEpoch = 0;
39331
39971
  #lastFailedEpoch = 0;
39332
39972
  #relayOrigin;
39333
39973
  #route;
39334
- constructor(audit, channelId, relayUrl) {
39974
+ constructor(audit, channelId, relayUrl, localLog) {
39335
39975
  this.#audit = audit;
39336
39976
  this.#channelId = channelId;
39977
+ this.#localLog = localLog;
39337
39978
  this.#relayOrigin = relayUrl.origin;
39338
39979
  this.#route = describeEnvironmentProxyRoute(relayUrl);
39339
39980
  }
@@ -39420,6 +40061,20 @@ var RelayConnectionDiagnostics = class {
39420
40061
  true
39421
40062
  );
39422
40063
  };
40064
+ daemonDiagnostic = (event, requestId, details, failure2) => {
40065
+ const recordedDetails = { ...details };
40066
+ if (failure2 !== void 0) {
40067
+ addFailureDetails(recordedDetails, failure2);
40068
+ }
40069
+ this.#localLog.record(
40070
+ `Mobius daemon diagnostic ${JSON.stringify({
40071
+ channelId: this.#channelId,
40072
+ event,
40073
+ requestId,
40074
+ ...recordedDetails
40075
+ })}`
40076
+ );
40077
+ };
39423
40078
  #record = (event, commandId, details, warning) => {
39424
40079
  this.#audit.record({
39425
40080
  commandId,
@@ -39428,6 +40083,7 @@ var RelayConnectionDiagnostics = class {
39428
40083
  sessionId: this.#channelId
39429
40084
  });
39430
40085
  const encoded = JSON.stringify({ channelId: this.#channelId, event, ...details });
40086
+ this.#localLog.record(`Mobius relay diagnostic ${encoded}`);
39431
40087
  if (warning) {
39432
40088
  process.stderr.write(`Mobius relay diagnostic ${encoded}
39433
40089
  `);
@@ -39545,7 +40201,7 @@ var RelayConnectionLiveness = class {
39545
40201
  };
39546
40202
 
39547
40203
  // src/relay-connection/session-event-outbox.ts
39548
- import { mkdirSync as mkdirSync3 } from "node:fs";
40204
+ import { mkdirSync as mkdirSync4 } from "node:fs";
39549
40205
  import { dirname as dirname6 } from "node:path";
39550
40206
  import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
39551
40207
  var DEFAULT_OUTBOX_LIMITS = {
@@ -39612,7 +40268,7 @@ var SessionEventOutbox = class {
39612
40268
  constructor(path2, limits = DEFAULT_OUTBOX_LIMITS) {
39613
40269
  validateLimits(limits);
39614
40270
  this.#limits = limits;
39615
- mkdirSync3(dirname6(path2), { recursive: true });
40271
+ mkdirSync4(dirname6(path2), { recursive: true });
39616
40272
  this.#database = new DatabaseSync3(path2);
39617
40273
  this.#database.exec(`
39618
40274
  CREATE TABLE IF NOT EXISTS relay_session_event_outbox (
@@ -39838,6 +40494,19 @@ var SessionEventOutbox = class {
39838
40494
  return this.#enqueueBounded(sessionId, payload, attemptId ?? "", this.#limits.standardEventBytes);
39839
40495
  };
39840
40496
  enqueueCritical = (sessionId, payload, attemptId = "") => this.#enqueueBounded(sessionId, payload, attemptId, this.#limits.criticalEventBytes);
40497
+ /**
40498
+ * Bytes still available to standard Session events. The daemon uses this to shed
40499
+ * superseded streaming events instead of filling the durable outbox, so a long Turn
40500
+ * behind a slow Relay cannot make the next enqueue throw.
40501
+ */
40502
+ standardCapacityRemaining = () => {
40503
+ const state = this.#database.prepare(
40504
+ `SELECT total_bytes
40505
+ FROM relay_session_event_outbox_state
40506
+ WHERE singleton = 1`
40507
+ ).get();
40508
+ return this.#limits.standardEventBytes - rowNumber(state, "total_bytes");
40509
+ };
39841
40510
  claimRuntimeDelivery = (delivery) => {
39842
40511
  const payloadBytes = new TextEncoder().encode(delivery.payload).byteLength;
39843
40512
  this.#database.exec("BEGIN IMMEDIATE");
@@ -40446,6 +41115,12 @@ var ConnectedDaemonSessionEventState = class extends DaemonSessionEventConnectio
40446
41115
  var SESSION_EVENT_REPLAY_WINDOW = 16;
40447
41116
  var SESSION_EVENT_SOURCE_REPLAY_WINDOW = 4;
40448
41117
  var SESSION_EVENT_REPLAY_BYTE_LIMIT = 32 * 1024 * 1024;
41118
+ function reservesSessionEventCapacity(event) {
41119
+ if (event.kind === SESSION_COMPLETED_KIND || event.kind === SESSION_FAILED_KIND) {
41120
+ return true;
41121
+ }
41122
+ return event.kind === AGENT_ACTIVITY_KIND && (event.activityType === "progress" || event.activityType === "reasoning") && (event.status === "completed" || event.status === "failed");
41123
+ }
40449
41124
  var InFlightSessionEvent = class {
40450
41125
  byteLength;
40451
41126
  sourceKey;
@@ -40461,6 +41136,7 @@ var DaemonSessionEventPublisher = class {
40461
41136
  #outbox;
40462
41137
  #inFlightEvents = /* @__PURE__ */ new Map();
40463
41138
  #pausedSources = /* @__PURE__ */ new Map();
41139
+ #shedEventKinds = /* @__PURE__ */ new Set();
40464
41140
  #timer;
40465
41141
  #inFlightBytes = 0;
40466
41142
  #connection = new DisconnectedDaemonSessionEventState();
@@ -40482,17 +41158,64 @@ var DaemonSessionEventPublisher = class {
40482
41158
  };
40483
41159
  recordAttempt = (sessionId, event, attemptId) => {
40484
41160
  const encoded = encodeRecordedSessionEvent(event);
40485
- if (event.kind === SESSION_COMPLETED_KIND || event.kind === SESSION_FAILED_KIND) {
40486
- this.#outbox.enqueueCritical(sessionId, encoded, attemptId);
41161
+ if (reservesSessionEventCapacity(event)) {
41162
+ this.#enqueueReserved(sessionId, encoded, attemptId, event.kind);
40487
41163
  } else {
40488
- this.#outbox.enqueue(sessionId, encoded, attemptId);
41164
+ this.#enqueueStandard(sessionId, encoded, attemptId, event.kind);
40489
41165
  }
40490
41166
  this.#publishNextBatch();
40491
41167
  };
40492
41168
  recordRuntime = (sessionId, event) => {
40493
- this.#outbox.enqueue(sessionId, encodeRecordedSessionEvent(event));
41169
+ this.#enqueueStandard(sessionId, encodeRecordedSessionEvent(event), "", event.kind);
40494
41170
  this.#publishNextBatch();
40495
41171
  };
41172
+ /**
41173
+ * Enqueue a standard event, shedding it instead of ending the daemon when the
41174
+ * durable outbox is full.
41175
+ *
41176
+ * A capacity error used to escape the coalescing timer that publishes activities,
41177
+ * so the process exited and every restart died on the same retained backlog. A full
41178
+ * outbox is a recoverable runtime condition, not a fatal one: narration increments are
41179
+ * superseded by the completed snapshot, so they are shed first, and any other streaming
41180
+ * event is shed only at the wall rather than terminating the daemon.
41181
+ */
41182
+ #enqueueStandard = (sessionId, encoded, attemptId, kind) => {
41183
+ if (kind === AGENT_ACTIVITY_NARRATION_KIND && this.#outbox.standardCapacityRemaining() <= 0) {
41184
+ this.#reportShedEvent(kind);
41185
+ return;
41186
+ }
41187
+ try {
41188
+ this.#outbox.enqueue(sessionId, encoded, attemptId);
41189
+ } catch (error62) {
41190
+ if (!(error62 instanceof SessionEventOutboxCapacityError)) {
41191
+ throw error62;
41192
+ }
41193
+ this.#reportShedEvent(kind);
41194
+ }
41195
+ };
41196
+ /**
41197
+ * Enqueue on the reserved budget, degrading to a reported drop instead of raising.
41198
+ * Streaming events are shed before this budget is reached, so a Turn's terminal
41199
+ * events and the completed snapshot that carries its narration still land; a drop
41200
+ * here is the last resort for a backlog no acknowledgement can drain.
41201
+ */
41202
+ #enqueueReserved = (sessionId, encoded, attemptId, kind) => {
41203
+ try {
41204
+ this.#outbox.enqueueCritical(sessionId, encoded, attemptId);
41205
+ } catch (error62) {
41206
+ if (!(error62 instanceof SessionEventOutboxCapacityError)) {
41207
+ throw error62;
41208
+ }
41209
+ this.#reportShedEvent(kind);
41210
+ }
41211
+ };
41212
+ #reportShedEvent = (kind) => {
41213
+ if (this.#shedEventKinds.has(kind)) {
41214
+ return;
41215
+ }
41216
+ this.#shedEventKinds.add(kind);
41217
+ console.warn(`Mobius daemon is dropping durable "${kind}" events because the Session event outbox is full`);
41218
+ };
40496
41219
  acknowledge = (acknowledgement) => {
40497
41220
  if (!this.#outbox.acknowledge(acknowledgement)) {
40498
41221
  return;
@@ -41219,6 +41942,26 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
41219
41942
  const activities = new CoalescingDaemonActivityPublisher(timer, (activity2) => {
41220
41943
  publisher.recordAttempt(command.sessionId, daemonActivity(command, activity2), attemptId);
41221
41944
  });
41945
+ const narration = new CoalescingNarrationPublisher(
41946
+ timer,
41947
+ (increment) => {
41948
+ publisher.recordAttempt(
41949
+ command.sessionId,
41950
+ {
41951
+ activityId: increment.activityId,
41952
+ activityType: increment.activityType,
41953
+ commandId: command.commandId,
41954
+ kind: AGENT_ACTIVITY_NARRATION_KIND,
41955
+ sequence: increment.sequence,
41956
+ sessionId: command.sessionId,
41957
+ text: increment.text
41958
+ },
41959
+ attemptId
41960
+ );
41961
+ },
41962
+ AGENT_ACTIVITY_COALESCING_MILLISECONDS,
41963
+ AGENT_TEXT_MAXIMUM_LENGTH
41964
+ );
41222
41965
  const text3 = new CoalescingTextPublisher(
41223
41966
  timer,
41224
41967
  (messageId, delta) => {
@@ -41323,6 +42066,10 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
41323
42066
  disposition: command.disposition,
41324
42067
  images: attachments.images,
41325
42068
  onActivity: activities.record,
42069
+ onNarration: (increment) => {
42070
+ narration.record(increment);
42071
+ return Promise.resolve();
42072
+ },
41326
42073
  onText: (delta, messageId) => {
41327
42074
  text3.record(messageId, delta);
41328
42075
  return Promise.resolve();
@@ -41336,6 +42083,7 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
41336
42083
  stopReason = result.stopReason;
41337
42084
  }
41338
42085
  text3.flush();
42086
+ narration.flush();
41339
42087
  activities.flush();
41340
42088
  publisher.recordAttempt(
41341
42089
  command.sessionId,
@@ -41355,6 +42103,7 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
41355
42103
  });
41356
42104
  } catch (error62) {
41357
42105
  text3.flush();
42106
+ narration.flush();
41358
42107
  activities.flush();
41359
42108
  audit.record({
41360
42109
  commandId: command.commandId,
@@ -42076,6 +42825,11 @@ async function runRelayConnection(config2, directories, audit, sessions, install
42076
42825
  event: "agent_settings_model_unsupported",
42077
42826
  sessionId: `agent-settings:${command2.agentId}`
42078
42827
  });
42828
+ diagnostics.daemonDiagnostic(
42829
+ "agent_settings_model_unsupported",
42830
+ command2.requestId,
42831
+ details
42832
+ );
42079
42833
  process.stderr.write(
42080
42834
  `Mobius daemon diagnostic ${JSON.stringify({ event: "agent_settings_model_unsupported", requestId: command2.requestId, ...details })}
42081
42835
  `
@@ -42106,6 +42860,12 @@ async function runRelayConnection(config2, directories, audit, sessions, install
42106
42860
  event: "agent_settings_discovery_failed",
42107
42861
  sessionId: `agent-settings:${command2.agentId}`
42108
42862
  });
42863
+ diagnostics.daemonDiagnostic(
42864
+ "agent_settings_discovery_failed",
42865
+ command2.requestId,
42866
+ details,
42867
+ failure2
42868
+ );
42109
42869
  if (failure2 instanceof AcpConfigurationValueUnavailableError) {
42110
42870
  process.stderr.write(
42111
42871
  `Mobius daemon diagnostic ${JSON.stringify({ event: "agent_settings_discovery_failed", requestId: command2.requestId, ...details })}
@@ -42183,6 +42943,12 @@ async function runRelayConnection(config2, directories, audit, sessions, install
42183
42943
  event: "agent_catalog_refresh_failed",
42184
42944
  sessionId: "agent-catalog"
42185
42945
  });
42946
+ diagnostics.daemonDiagnostic(
42947
+ "agent_catalog_refresh_failed",
42948
+ command2.requestId,
42949
+ { code: operationErrorCode(failure2) },
42950
+ failure2
42951
+ );
42186
42952
  if (socket.readyState === WebSocket2.OPEN) {
42187
42953
  send(socket, {
42188
42954
  code: operationErrorCode(failure2),
@@ -42267,6 +43033,17 @@ async function runRelayConnection(config2, directories, audit, sessions, install
42267
43033
  event: "native_session_operation_failed",
42268
43034
  details: { code: operationErrorCode(failure2) }
42269
43035
  });
43036
+ diagnostics.daemonDiagnostic(
43037
+ "native_session_operation_failed",
43038
+ command2.requestId,
43039
+ {
43040
+ action: command2.action,
43041
+ agentId: command2.agentId,
43042
+ code: operationErrorCode(failure2),
43043
+ sessionId: command2.sessionId
43044
+ },
43045
+ failure2
43046
+ );
42270
43047
  reportOperationFailure(socket, command2.requestId, command2.sessionId, failure2);
42271
43048
  } finally {
42272
43049
  timeout.cancel();
@@ -42347,6 +43124,16 @@ async function runRelayConnection(config2, directories, audit, sessions, install
42347
43124
  event: "native_session_turn_fork_failed",
42348
43125
  sessionId: command2.sessionId
42349
43126
  });
43127
+ diagnostics.daemonDiagnostic(
43128
+ "native_session_turn_fork_failed",
43129
+ command2.requestId,
43130
+ {
43131
+ agentId: command2.agentId,
43132
+ code: operationErrorCode(failure2),
43133
+ sessionId: command2.sessionId
43134
+ },
43135
+ failure2
43136
+ );
42350
43137
  reportOperationFailure(socket, command2.requestId, command2.sessionId, failure2);
42351
43138
  } finally {
42352
43139
  timeout.cancel();
@@ -42619,7 +43406,12 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
42619
43406
  });
42620
43407
  const directories = new WorkspaceDirectoryService(config2.bindingId, config2.defaultWorkspace);
42621
43408
  const installationObserver = new DaemonInstallationObserver();
42622
- const diagnostics = new RelayConnectionDiagnostics(audit, config2.channelId, config2.relayUrl);
43409
+ const diagnostics = new RelayConnectionDiagnostics(
43410
+ audit,
43411
+ config2.channelId,
43412
+ config2.relayUrl,
43413
+ new DaemonDiagnosticLog(stateDirectory)
43414
+ );
42623
43415
  const nativeSessions = new NativeSessionService(config2, directories, sessions, audit);
42624
43416
  const installations = new AgentInstallationManager(
42625
43417
  specifications,
@@ -42759,7 +43551,7 @@ import { fetch as fetch5 } from "undici";
42759
43551
  // src/storage/runtime-installation-store.ts
42760
43552
  import { createHash as createHash4, randomUUID as randomUUID4 } from "node:crypto";
42761
43553
  import { mkdir as mkdir4, open as open5, rename as rename3, unlink, writeFile as writeFile3 } from "node:fs/promises";
42762
- import { dirname as dirname7, join as join16, resolve as resolve5 } from "node:path";
43554
+ import { dirname as dirname7, join as join17, resolve as resolve5 } from "node:path";
42763
43555
  var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
42764
43556
  var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
42765
43557
  var INSTALLATION_ID_PATTERN = /^min_[a-f0-9]{32}$/;
@@ -43059,7 +43851,7 @@ async function readJsonFile(path2, signal, missingCode) {
43059
43851
  async function writeJsonAtomically(path2, value, signal) {
43060
43852
  signal.throwIfAborted();
43061
43853
  const directory = dirname7(path2);
43062
- const temporaryPath = join16(directory, `.${randomUUID4()}.tmp`);
43854
+ const temporaryPath = join17(directory, `.${randomUUID4()}.tmp`);
43063
43855
  try {
43064
43856
  await mkdir4(directory, { mode: 448, recursive: true });
43065
43857
  signal.throwIfAborted();
@@ -43085,14 +43877,14 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
43085
43877
  this.applicationId = applicationId;
43086
43878
  this.installationId = installationId2;
43087
43879
  this.stateDirectory = stateDirectory;
43088
- this.#channelDirectory = join16(stateDirectory, "channels");
43089
- this.#connectionDirectory = join16(stateDirectory, "connections");
43880
+ this.#channelDirectory = join17(stateDirectory, "channels");
43881
+ this.#connectionDirectory = join17(stateDirectory, "connections");
43090
43882
  }
43091
43883
  static open = async (options, signal) => {
43092
43884
  signal.throwIfAborted();
43093
43885
  const applicationId = validateApplicationId(options.applicationId);
43094
43886
  const rootDirectory = resolve5(options.stateDirectory);
43095
- const applicationDirectory = join16(rootDirectory, "installations", applicationId);
43887
+ const applicationDirectory = join17(rootDirectory, "installations", applicationId);
43096
43888
  try {
43097
43889
  await mkdir4(applicationDirectory, { mode: 448, recursive: true });
43098
43890
  } catch (cause) {
@@ -43105,7 +43897,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
43105
43897
  );
43106
43898
  }
43107
43899
  const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
43108
- const stateDirectory = join16(applicationDirectory, storedInstallationId);
43900
+ const stateDirectory = join17(applicationDirectory, storedInstallationId);
43109
43901
  try {
43110
43902
  await mkdir4(stateDirectory, { mode: 448, recursive: true });
43111
43903
  } catch (cause) {
@@ -43120,9 +43912,9 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
43120
43912
  signal.throwIfAborted();
43121
43913
  return new _RuntimeInstallationStore(applicationId, storedInstallationId, stateDirectory);
43122
43914
  };
43123
- connectionPath = (connectionId2) => join16(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
43124
- auditDatabasePath = (connectionId2) => join16(this.stateDirectory, "audit", `${validateConnectionId(connectionId2)}.sqlite`);
43125
- channelIndexPath = (channelId) => join16(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
43915
+ connectionPath = (connectionId2) => join17(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
43916
+ auditDatabasePath = (connectionId2) => join17(this.stateDirectory, "audit", `${validateConnectionId(connectionId2)}.sqlite`);
43917
+ channelIndexPath = (channelId) => join17(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
43126
43918
  readConnection = async (connectionId2, signal) => {
43127
43919
  const stored = decodeConnection(
43128
43920
  await readJsonFile(this.connectionPath(connectionId2), signal, "connection_not_found")
@@ -43174,7 +43966,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
43174
43966
  };
43175
43967
  importLegacyConnection = async (legacyStateDirectory, channelId, signal) => {
43176
43968
  const normalizedChannelId = validateIdentifier(channelId, "invalid_channel_id");
43177
- const legacyPath = join16(resolve5(legacyStateDirectory), "connections", `${normalizedChannelId}.json`);
43969
+ const legacyPath = join17(resolve5(legacyStateDirectory), "connections", `${normalizedChannelId}.json`);
43178
43970
  const legacy = decodeLegacyConnection(
43179
43971
  await readJsonFile(legacyPath, signal, "connection_not_found"),
43180
43972
  normalizedChannelId
@@ -43253,7 +44045,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
43253
44045
  };
43254
44046
  };
43255
44047
  async function readOrCreateInstallationId(applicationDirectory, signal) {
43256
- const pointerPath = join16(applicationDirectory, "current.json");
44048
+ const pointerPath = join17(applicationDirectory, "current.json");
43257
44049
  try {
43258
44050
  return decodeInstallationPointer(await readJsonFile(pointerPath, signal, "installation_not_found")).installationId;
43259
44051
  } catch (cause) {
@@ -43574,7 +44366,7 @@ function loadMobiusRuntimeConnection(environment = process.env) {
43574
44366
  throw new MobiusRuntimeConfigurationError("MOBIUS_CHANNEL_ID is invalid");
43575
44367
  }
43576
44368
  return Object.freeze({
43577
- auditDatabasePath: environment["MOBIUS_AUDIT_DATABASE"]?.trim() || join17(readStateDirectory(environment), "audit", `${channelId}.sqlite`),
44369
+ auditDatabasePath: environment["MOBIUS_AUDIT_DATABASE"]?.trim() || join18(readStateDirectory(environment), "audit", `${channelId}.sqlite`),
43578
44370
  channelId,
43579
44371
  defaultWorkspace: loadDefaultWorkspace(environment),
43580
44372
  relayUrl: requiredEnvironmentValue(environment, "MOBIUS_RELAY_URL"),