@moxt-ai/mobius 0.0.190 → 0.0.192

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/agent-session.d.ts.map +1 -1
  2. package/dist/acp/agent-session.js +43 -15
  3. package/dist/acp/agent-session.js.map +1 -1
  4. package/dist/acp/codex/app-server-protocol.d.ts +12 -0
  5. package/dist/acp/codex/app-server-protocol.d.ts.map +1 -1
  6. package/dist/acp/codex/app-server-protocol.js +5 -5
  7. package/dist/acp/codex/app-server-protocol.js.map +1 -1
  8. package/dist/acp/codex/settings.d.ts +3 -0
  9. package/dist/acp/codex/settings.d.ts.map +1 -1
  10. package/dist/acp/codex/settings.js +5 -15
  11. package/dist/acp/codex/settings.js.map +1 -1
  12. package/dist/acp/session-configuration.d.ts +20 -0
  13. package/dist/acp/session-configuration.d.ts.map +1 -0
  14. package/dist/acp/session-configuration.js +49 -0
  15. package/dist/acp/session-configuration.js.map +1 -0
  16. package/dist/acp/session-store.d.ts +3 -1
  17. package/dist/acp/session-store.d.ts.map +1 -1
  18. package/dist/acp/session-store.js +9 -2
  19. package/dist/acp/session-store.js.map +1 -1
  20. package/dist/artifacts/local-file-streamer.d.ts.map +1 -1
  21. package/dist/artifacts/local-file-streamer.js +4 -2
  22. package/dist/artifacts/local-file-streamer.js.map +1 -1
  23. package/dist/cli.js +315 -103
  24. package/dist/cli.js.map +4 -4
  25. package/dist/daemon-command-handler.d.ts.map +1 -1
  26. package/dist/daemon-command-handler.js +35 -1
  27. package/dist/daemon-command-handler.js.map +1 -1
  28. package/dist/daemon-diagnostic-log.d.ts +4 -0
  29. package/dist/daemon-diagnostic-log.d.ts.map +1 -1
  30. package/dist/daemon-diagnostic-log.js +70 -0
  31. package/dist/daemon-diagnostic-log.js.map +1 -1
  32. package/dist/daemon-history-commands.d.ts +3 -2
  33. package/dist/daemon-history-commands.d.ts.map +1 -1
  34. package/dist/daemon-history-commands.js +12 -5
  35. package/dist/daemon-history-commands.js.map +1 -1
  36. package/dist/generated/acp-session-store-migrations.d.ts +3 -0
  37. package/dist/generated/acp-session-store-migrations.d.ts.map +1 -1
  38. package/dist/generated/acp-session-store-migrations.js +5 -1
  39. package/dist/generated/acp-session-store-migrations.js.map +1 -1
  40. package/dist/index.js +390 -102
  41. package/dist/index.js.map +4 -4
  42. package/dist/relay-connection/diagnostics.d.ts +4 -0
  43. package/dist/relay-connection/diagnostics.d.ts.map +1 -1
  44. package/dist/relay-connection/diagnostics.js +8 -1
  45. package/dist/relay-connection/diagnostics.js.map +1 -1
  46. package/dist/runtime.js +390 -102
  47. package/dist/runtime.js.map +4 -4
  48. package/dist/schema/acp-session-store/acp-session.d.ts +16 -0
  49. package/dist/schema/acp-session-store/acp-session.d.ts.map +1 -1
  50. package/dist/schema/acp-session-store/acp-session.js +1 -0
  51. package/dist/schema/acp-session-store/acp-session.js.map +1 -1
  52. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -3381,7 +3381,7 @@ var program = new Command();
3381
3381
  // package.json
3382
3382
  var package_default = {
3383
3383
  name: "@moxt-ai/mobius",
3384
- version: "0.0.190",
3384
+ version: "0.0.192",
3385
3385
  description: "Mobius CLI for pairing and running local AI agent services.",
3386
3386
  type: "module",
3387
3387
  bin: {
@@ -24848,7 +24848,11 @@ var threadTurnSchema = external_exports.object({
24848
24848
  items: external_exports.array(external_exports.unknown()).max(1e5)
24849
24849
  });
24850
24850
  var threadTurnsSchema = external_exports.array(threadTurnSchema).max(1e5);
24851
+ var collaborationModeSchema = external_exports.object({
24852
+ mode: external_exports.enum(["default", "plan"])
24853
+ });
24851
24854
  var threadLifecycleResponseSchema = external_exports.object({
24855
+ collaborationMode: collaborationModeSchema.nullish(),
24852
24856
  model: boundedText(256).nullish(),
24853
24857
  reasoningEffort: boundedText(256).nullish(),
24854
24858
  serviceTier: boundedText(256).nullish(),
@@ -24893,9 +24897,7 @@ var modelListResponseSchema = external_exports.object({
24893
24897
  var threadSettingsUpdatedSchema = external_exports.object({
24894
24898
  threadId: boundedText(256),
24895
24899
  threadSettings: external_exports.object({
24896
- collaborationMode: external_exports.object({
24897
- mode: external_exports.enum(["default", "plan"])
24898
- }).nullish()
24900
+ collaborationMode: collaborationModeSchema.nullish()
24899
24901
  })
24900
24902
  });
24901
24903
 
@@ -25372,7 +25374,7 @@ var FULL_ACCESS_MODE = Object.freeze({
25372
25374
  sandboxPolicy: { type: "dangerFullAccess" }
25373
25375
  });
25374
25376
  var AGENT_MODES = Object.freeze([READ_ONLY_MODE, AGENT_MODE, FULL_ACCESS_MODE]);
25375
- var DEFAULT_MODE = AGENT_MODE;
25377
+ var DEFAULT_MODE = FULL_ACCESS_MODE;
25376
25378
  function initialMode(environment) {
25377
25379
  const requested = environment["INITIAL_AGENT_MODE"];
25378
25380
  if (requested === void 0) {
@@ -25490,9 +25492,6 @@ function effortSetting(model, currentValue) {
25490
25492
  var CodexSettings = class {
25491
25493
  #appServer;
25492
25494
  #models = [];
25493
- // Whether the current turn must carry a policy at all. Until the user picks a mode, Codex's own
25494
- // configuration decides, so `turn/start` omits the fields and inherits what the host set up.
25495
- #policySelected = false;
25496
25495
  // Whether a collaboration mode choice has been made in this session. A restored thread keeps
25497
25496
  // the mode Codex already persisted, so the first turn does not reset it to Build.
25498
25497
  #collaborationModeSelected = false;
@@ -25532,14 +25531,9 @@ var CodexSettings = class {
25532
25531
  const mode = AGENT_MODES.find((candidate) => candidate.id === selection.mode) ?? DEFAULT_MODE;
25533
25532
  const supportsFast = this.#model(selection.model)?.additionalSpeedTiers?.includes(FAST_TIER) === true;
25534
25533
  return {
25535
- // Until a mode is chosen, `config.toml` decides the sandbox and approval
25536
- // policy, and those fields stay off the turn so the host's own setup is
25537
- // inherited rather than overridden.
25538
- ...this.#policySelected ? {
25539
- approvalPolicy: mode.approvalPolicy,
25540
- approvalsReviewer: mode.approvalsReviewer,
25541
- sandboxPolicy: mode.sandboxPolicy
25542
- } : {},
25534
+ approvalPolicy: mode.approvalPolicy,
25535
+ approvalsReviewer: mode.approvalsReviewer,
25536
+ sandboxPolicy: mode.sandboxPolicy,
25543
25537
  // The collaboration mode rides on the turn: Codex applies it to the
25544
25538
  // thread, where it persists until changed. "Build" is Codex's `default`
25545
25539
  // mode, so it is only sent once a choice exists to apply.
@@ -25632,6 +25626,7 @@ var CodexSettings = class {
25632
25626
  this.#selection = {
25633
25627
  ...this.#selection,
25634
25628
  ...supported,
25629
+ collaborationMode: thread.collaborationMode?.mode ?? this.#selection.collaborationMode,
25635
25630
  fastMode: thread.serviceTier === SERVICE_TIER_FAST
25636
25631
  };
25637
25632
  };
@@ -25671,7 +25666,6 @@ var CodexSettings = class {
25671
25666
  );
25672
25667
  }
25673
25668
  this.#selection = { ...this.#selection, mode: value };
25674
- this.#policySelected = true;
25675
25669
  return;
25676
25670
  }
25677
25671
  if (configId === COLLABORATION_MODE_SETTING_ID) {
@@ -29655,6 +29649,24 @@ var encodeNativeSessionResult = (value) => JSON.stringify(nativeSessionResultSch
29655
29649
  var decodeNativeSessionCancel = (encoded) => decode4(nativeSessionCancelSchema, encoded);
29656
29650
  var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSchema.parse(value));
29657
29651
 
29652
+ // ../protocol/src/runtime-diagnostics.ts
29653
+ var identifier = external_exports.custom(isIdentifier);
29654
+ var runtimeDiagnosticsRequestSchema = external_exports.strictObject({
29655
+ kind: external_exports.literal("runtime.diagnostics.read"),
29656
+ requestId: identifier
29657
+ });
29658
+ var runtimeDiagnosticsResultSchema = external_exports.strictObject({
29659
+ kind: external_exports.literal("runtime.diagnostics.result"),
29660
+ requestId: identifier,
29661
+ truncated: external_exports.boolean(),
29662
+ version: external_exports.string().max(32),
29663
+ entries: external_exports.array(external_exports.record(external_exports.string(), external_exports.string().max(256)).readonly()).max(200).readonly()
29664
+ }).refine((value) => JSON.stringify(value).length <= 65536, "Diagnostics exceed the report limit");
29665
+ var decodeRuntimeDiagnosticsRequest = (raw) => runtimeDiagnosticsRequestSchema.parse(JSON.parse(raw));
29666
+ var decodeRuntimeDiagnosticsResult = (raw) => runtimeDiagnosticsResultSchema.parse(JSON.parse(raw));
29667
+ var encodeRuntimeDiagnosticsRequest = (value) => JSON.stringify(runtimeDiagnosticsRequestSchema.parse(value));
29668
+ var encodeRuntimeDiagnosticsResult = (value) => JSON.stringify(runtimeDiagnosticsResultSchema.parse(value));
29669
+
29658
29670
  // ../protocol/src/session-event-log-v2.ts
29659
29671
  var MAX_EVENT_COUNT = 1e4;
29660
29672
  var MAX_COLLECTION_SIZE = 1e3;
@@ -30129,18 +30141,21 @@ var SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND = "session.live-history.v2.page.loa
30129
30141
  var SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND = "session.preview-history.page.load";
30130
30142
  var SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND = "session.preview-history.page.loaded";
30131
30143
  var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
30132
- var pageLoadFields = {
30133
- additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
30134
- agentId: identifierStringSchema,
30135
- bindingId: identifierStringSchema,
30144
+ var pageRequestFields = {
30136
30145
  cursor: external_exports.string().min(1).max(512).nullable(),
30137
- directoryId: directoryIdentifier,
30138
30146
  eventLimit: external_exports.number().int().min(1).max(1e4),
30139
30147
  requestId: identifierStringSchema,
30140
30148
  sessionId: identifierStringSchema
30141
30149
  };
30142
- var sessionLiveHistoryV2PageLoadSchema = external_exports.object({ ...pageLoadFields, kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND) }).readonly();
30143
- var sessionPreviewHistoryPageLoadSchema = external_exports.object({ ...pageLoadFields, kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND) }).readonly();
30150
+ var sessionLiveHistoryV2PageLoadSchema = external_exports.object({ ...pageRequestFields, kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND) }).readonly();
30151
+ var sessionPreviewHistoryPageLoadSchema = external_exports.object({
30152
+ ...pageRequestFields,
30153
+ additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
30154
+ agentId: identifierStringSchema,
30155
+ bindingId: identifierStringSchema,
30156
+ directoryId: directoryIdentifier,
30157
+ kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND)
30158
+ }).readonly();
30144
30159
  var pageLoadedFields = {
30145
30160
  events: nativeSessionEventsV2Schema,
30146
30161
  requestId: identifierStringSchema,
@@ -30228,6 +30243,11 @@ var serviceToDaemonSignatures = {
30228
30243
  encodeRuntimeLivenessReadyEvent,
30229
30244
  decodeRuntimeLivenessReadyEvent
30230
30245
  ),
30246
+ "runtime.diagnostics.read": defineMessageSignature(
30247
+ "runtime.diagnostics.read",
30248
+ encodeRuntimeDiagnosticsRequest,
30249
+ decodeRuntimeDiagnosticsRequest
30250
+ ),
30231
30251
  [RUNTIME_PING_KIND]: defineMessageSignature(RUNTIME_PING_KIND, encodeRuntimePingCommand, decodeRuntimePingCommand),
30232
30252
  [SESSION_CANCEL_KIND]: defineMessageSignature(
30233
30253
  SESSION_CANCEL_KIND,
@@ -30374,6 +30394,11 @@ var daemonToServiceSignatures = {
30374
30394
  encodeRuntimeHeartbeatEvent,
30375
30395
  decodeRuntimeHeartbeatEvent
30376
30396
  ),
30397
+ "runtime.diagnostics.result": defineMessageSignature(
30398
+ "runtime.diagnostics.result",
30399
+ encodeRuntimeDiagnosticsResult,
30400
+ decodeRuntimeDiagnosticsResult
30401
+ ),
30377
30402
  [RUNTIME_PONG_KIND]: defineMessageSignature(RUNTIME_PONG_KIND, encodeRuntimePongEvent, decodeRuntimePongEvent),
30378
30403
  [SESSION_EVENT_V2_KIND]: defineMessageSignature(
30379
30404
  SESSION_EVENT_V2_KIND,
@@ -32869,6 +32894,54 @@ function sessionConfigProtocolForAgent(_agentId) {
32869
32894
  return standardSessionConfigProtocol;
32870
32895
  }
32871
32896
 
32897
+ // src/acp/session-configuration.ts
32898
+ var storedSessionConfigurationsSchema = external_exports.array(
32899
+ external_exports.discriminatedUnion("type", [
32900
+ external_exports.object({ booleanValue: external_exports.boolean(), configId: external_exports.string().max(128), type: external_exports.literal("boolean") }),
32901
+ external_exports.object({ configId: external_exports.string().max(128), type: external_exports.literal("select"), value: external_exports.string().max(500) })
32902
+ ])
32903
+ ).max(100);
32904
+ var decodeStoredSessionConfigurations = (value) => storedSessionConfigurationsSchema.parse(value);
32905
+ var AcpSessionConfigurations = class {
32906
+ #selected = [];
32907
+ stored = () => this.#selected;
32908
+ capture = (options) => {
32909
+ this.#selected = this.#selected.map((selection) => {
32910
+ const current = options.find(
32911
+ (option) => option.id === selection.configId && option.type === selection.type
32912
+ );
32913
+ if (current === void 0) {
32914
+ return selection;
32915
+ }
32916
+ return current.type === "boolean" ? { booleanValue: current.booleanValue, configId: current.id, type: "boolean" } : { configId: current.id, type: "select", value: current.currentValue };
32917
+ });
32918
+ };
32919
+ select = (option) => {
32920
+ const selected = option.type === "boolean" ? { booleanValue: option.booleanValue, configId: option.id, type: "boolean" } : { configId: option.id, type: "select", value: option.currentValue };
32921
+ this.#selected = [...this.#selected.filter((selection) => selection.configId !== selected.configId), selected];
32922
+ };
32923
+ restore = async (stored, options, apply, signal) => {
32924
+ this.#selected = stored;
32925
+ for (const selection of this.#selected) {
32926
+ const current = options.find(
32927
+ (option) => option.id === selection.configId && option.type === selection.type
32928
+ );
32929
+ if (current === void 0) {
32930
+ continue;
32931
+ }
32932
+ if (selection.type === "boolean") {
32933
+ if (current.booleanValue !== selection.booleanValue) {
32934
+ await apply(selection, signal);
32935
+ }
32936
+ continue;
32937
+ }
32938
+ if (current.currentValue !== selection.value && current.values.some((value) => value.value === selection.value)) {
32939
+ await apply(selection, signal);
32940
+ }
32941
+ }
32942
+ };
32943
+ };
32944
+
32872
32945
  // src/acp/session-contracts.ts
32873
32946
  var acpNativeHistoryReader = {
32874
32947
  access: () => ({ kind: "acp" })
@@ -34226,10 +34299,10 @@ function sql(strings, ...params) {
34226
34299
  return new SQL(result);
34227
34300
  }
34228
34301
  _sql.join = join21;
34229
- function identifier(value) {
34302
+ function identifier2(value) {
34230
34303
  return new Name(value);
34231
34304
  }
34232
- _sql.identifier = identifier;
34305
+ _sql.identifier = identifier2;
34233
34306
  function placeholder2(name2) {
34234
34307
  return new Placeholder(name2);
34235
34308
  }
@@ -35825,19 +35898,19 @@ var SQLiteCustomColumn = class extends SQLiteColumn {
35825
35898
  mapFromJsonValue(value) {
35826
35899
  return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
35827
35900
  }
35828
- jsonSelectIdentifier(identifier, sql2) {
35829
- if (typeof this.forJsonSelect === "function") return this.forJsonSelect(identifier, sql2);
35901
+ jsonSelectIdentifier(identifier2, sql2) {
35902
+ if (typeof this.forJsonSelect === "function") return this.forJsonSelect(identifier2, sql2);
35830
35903
  const rawType = this.getSQLType().toLowerCase();
35831
35904
  const parenPos = rawType.indexOf("(");
35832
35905
  switch (parenPos + 1 ? rawType.slice(0, parenPos) : rawType) {
35833
35906
  case "numeric":
35834
35907
  case "decimal":
35835
35908
  case "bigint":
35836
- return sql2`cast(${identifier} as text)`;
35909
+ return sql2`cast(${identifier2} as text)`;
35837
35910
  case "blob":
35838
- return sql2`hex(${identifier})`;
35911
+ return sql2`hex(${identifier2})`;
35839
35912
  default:
35840
- return identifier;
35913
+ return identifier2;
35841
35914
  }
35842
35915
  }
35843
35916
  mapToDriverValue = (value) => {
@@ -38478,6 +38551,7 @@ var acpSession = sqliteTable("acp_session", {
38478
38551
  nativeSessionId: text("native_session_id").notNull(),
38479
38552
  cwd: text("cwd").notNull(),
38480
38553
  additionalDirectories: text("additional_directories").notNull(),
38554
+ configurations: text("configurations").notNull().default("[]"),
38481
38555
  prompted: integer2("prompted", { mode: "boolean" }).notNull(),
38482
38556
  title: text("title").notNull(),
38483
38557
  updatedAt: text("updated_at").notNull()
@@ -38745,15 +38819,17 @@ var AcpStoredSession = class {
38745
38819
  additionalDirectories;
38746
38820
  agentId;
38747
38821
  cwd;
38822
+ configurations;
38748
38823
  nativeSessionId;
38749
38824
  prompted;
38750
38825
  sessionId;
38751
38826
  title;
38752
38827
  updatedAt;
38753
- constructor(sessionId, agentId, nativeSessionId, cwd, additionalDirectories, prompted, title2, updatedAt = (/* @__PURE__ */ new Date()).toISOString()) {
38828
+ constructor(sessionId, agentId, nativeSessionId, cwd, additionalDirectories, prompted, title2, updatedAt = (/* @__PURE__ */ new Date()).toISOString(), configurations = []) {
38754
38829
  this.additionalDirectories = [...additionalDirectories];
38755
38830
  this.agentId = agentId;
38756
38831
  this.cwd = cwd;
38832
+ this.configurations = configurations.map((configuration) => ({ ...configuration }));
38757
38833
  this.nativeSessionId = nativeSessionId;
38758
38834
  this.prompted = prompted;
38759
38835
  this.sessionId = sessionId;
@@ -38803,6 +38879,7 @@ var MemoryAcpSessionStore = class {
38803
38879
  var storedSessionRowSchema = external_exports.object({
38804
38880
  additionalDirectories: external_exports.string(),
38805
38881
  agentId: external_exports.string(),
38882
+ configurations: external_exports.string(),
38806
38883
  cwd: external_exports.string(),
38807
38884
  nativeSessionId: external_exports.string(),
38808
38885
  prompted: external_exports.boolean(),
@@ -38814,6 +38891,8 @@ function decodeStoredSession(value) {
38814
38891
  const row = storedSessionRowSchema.parse(value);
38815
38892
  const decodedAdditionalDirectories = JSON.parse(row.additionalDirectories);
38816
38893
  const additionalDirectories = external_exports.array(external_exports.string()).parse(decodedAdditionalDirectories);
38894
+ const decodedConfigurations = JSON.parse(row.configurations);
38895
+ const configurations = decodeStoredSessionConfigurations(decodedConfigurations);
38817
38896
  return new AcpStoredSession(
38818
38897
  row.sessionId,
38819
38898
  row.agentId,
@@ -38822,7 +38901,8 @@ function decodeStoredSession(value) {
38822
38901
  additionalDirectories,
38823
38902
  row.prompted,
38824
38903
  row.title,
38825
- row.updatedAt
38904
+ row.updatedAt,
38905
+ configurations
38826
38906
  );
38827
38907
  }
38828
38908
  var SqliteAcpSessionStore = class {
@@ -38855,6 +38935,7 @@ var SqliteAcpSessionStore = class {
38855
38935
  const value = {
38856
38936
  additionalDirectories: JSON.stringify(session.additionalDirectories),
38857
38937
  agentId: session.agentId,
38938
+ configurations: JSON.stringify(session.configurations),
38858
38939
  cwd: session.cwd,
38859
38940
  nativeSessionId: session.nativeSessionId,
38860
38941
  prompted: session.prompted,
@@ -38903,6 +38984,7 @@ var AgentSession = class _AgentSession {
38903
38984
  #commands = [];
38904
38985
  #configRevision = 0;
38905
38986
  #configOptions = [];
38987
+ #sessionConfigurations = new AcpSessionConfigurations();
38906
38988
  #nativeHistoryOwnership = { kind: "unbound" };
38907
38989
  #prompted = false;
38908
38990
  #nativePrompt = null;
@@ -39007,6 +39089,41 @@ var AgentSession = class _AgentSession {
39007
39089
  usesEnvironment = (environment) => recordsEqual(this.#environment, environment);
39008
39090
  canRebind = () => !this.#prompted && !this.#turn.running;
39009
39091
  hasRunningTurn = () => this.#turn.running;
39092
+ #writeStoredSession = () => {
39093
+ this.#store.write(
39094
+ new AcpStoredSession(
39095
+ this.#mobiusSessionId,
39096
+ this.#agentId,
39097
+ this.#updates.sessionId(),
39098
+ this.#cwd,
39099
+ this.#additionalDirectories,
39100
+ this.#prompted,
39101
+ this.#sessionTitle ?? "",
39102
+ (/* @__PURE__ */ new Date()).toISOString(),
39103
+ this.#sessionConfigurations.stored()
39104
+ )
39105
+ );
39106
+ };
39107
+ #captureSelectedConfigurationValues = () => {
39108
+ this.#sessionConfigurations.capture(this.#configOptions);
39109
+ if (this.#updates.sessionId().length > 0) {
39110
+ this.#writeStoredSession();
39111
+ }
39112
+ };
39113
+ #restoreStoredConfigurations = async (session, signal) => {
39114
+ await this.#sessionConfigurations.restore(
39115
+ session.configurations,
39116
+ this.#configOptions,
39117
+ async (selection, signal2) => await this.#applyConfiguration(
39118
+ selection.configId,
39119
+ selection.type === "select" ? selection.value : "",
39120
+ selection.type === "boolean" ? selection.booleanValue : false,
39121
+ selection.type,
39122
+ signal2
39123
+ ),
39124
+ signal
39125
+ );
39126
+ };
39010
39127
  prepared = () => new AcpPreparedSession(
39011
39128
  this.#agentName,
39012
39129
  this.#agentVersion,
@@ -39357,20 +39474,12 @@ var AgentSession = class _AgentSession {
39357
39474
  lifecycleResponse = created;
39358
39475
  }
39359
39476
  this.#configOptions = this.#sessionConfigProtocol.normalizeLifecycle(lifecycleResponse);
39477
+ if (stored instanceof FoundAcpStoredSession && this.#restored) {
39478
+ await this.#restoreStoredConfigurations(stored.session, signal);
39479
+ }
39360
39480
  await this.#updates.drained();
39361
39481
  signal.throwIfAborted();
39362
- this.#store.write(
39363
- new AcpStoredSession(
39364
- this.#mobiusSessionId,
39365
- this.#agentId,
39366
- this.#updates.sessionId(),
39367
- this.#cwd,
39368
- this.#additionalDirectories,
39369
- this.#prompted,
39370
- this.#sessionTitle ?? "",
39371
- (/* @__PURE__ */ new Date()).toISOString()
39372
- )
39373
- );
39482
+ this.#writeStoredSession();
39374
39483
  };
39375
39484
  listNativeSessions = async (cursor, signal) => {
39376
39485
  if (!this.#capabilities.listSessions) {
@@ -39411,15 +39520,17 @@ var AgentSession = class _AgentSession {
39411
39520
  this.#cwd,
39412
39521
  this.#additionalDirectories,
39413
39522
  false,
39414
- ""
39523
+ "",
39524
+ (/* @__PURE__ */ new Date()).toISOString(),
39525
+ this.#sessionConfigurations.stored()
39415
39526
  )
39416
39527
  );
39417
39528
  this.#store.remove(previousSessionId);
39418
39529
  this.#mobiusSessionId = sessionId;
39419
39530
  };
39420
- configure = async (options) => {
39421
- const existing = this.#configOptions.find((option) => option.id === options.configId);
39422
- if (existing === void 0 || existing.type !== options.valueType) {
39531
+ #applyConfiguration = async (configId, value, booleanValue, valueType, signal) => {
39532
+ const existing = this.#configOptions.find((option) => option.id === configId);
39533
+ if (existing === void 0 || existing.type !== valueType) {
39423
39534
  throw new AcpExecutionError(
39424
39535
  "The requested ACP configuration option is unavailable",
39425
39536
  {},
@@ -39434,10 +39545,10 @@ var AgentSession = class _AgentSession {
39434
39545
  "invalid_session_configuration"
39435
39546
  );
39436
39547
  }
39437
- if (!existing.values.some((entry) => entry.value === options.value)) {
39548
+ if (!existing.values.some((entry) => entry.value === value)) {
39438
39549
  throw new AcpConfigurationValueUnavailableError(
39439
- options.configId,
39440
- options.value,
39550
+ configId,
39551
+ value,
39441
39552
  existing.values.map((entry) => entry.value)
39442
39553
  );
39443
39554
  }
@@ -39446,20 +39557,20 @@ var AgentSession = class _AgentSession {
39446
39557
  try {
39447
39558
  const configured = await this.#sessionConfigProtocol.configure(
39448
39559
  this.#configOptions,
39449
- options,
39560
+ { booleanValue, configId, signal, value },
39450
39561
  this.#updates.sessionId(),
39451
39562
  {
39452
- request: async (method, params, failureMessage, signal) => await this.race(
39563
+ request: async (method, params, failureMessage, signal2) => await this.race(
39453
39564
  this.#connection.connection.agent.request(method, params, {
39454
- cancellationSignal: signal
39565
+ cancellationSignal: signal2
39455
39566
  }),
39456
39567
  failureMessage,
39457
- signal
39568
+ signal2
39458
39569
  )
39459
39570
  }
39460
39571
  );
39461
- const applied = configured.find((option) => option.id === options.configId);
39462
- if (applied === void 0 || applied.type !== options.valueType || applied.type === "boolean" && applied.booleanValue !== options.booleanValue || applied.type === "select" && applied.currentValue !== options.value) {
39572
+ const applied = configured.find((option) => option.id === configId);
39573
+ if (applied === void 0 || applied.type !== valueType || applied.type === "boolean" && applied.booleanValue !== booleanValue || applied.type === "select" && applied.currentValue !== value) {
39463
39574
  throw new AcpExecutionError(
39464
39575
  "The Agent did not apply the requested session configuration",
39465
39576
  {},
@@ -39476,6 +39587,21 @@ var AgentSession = class _AgentSession {
39476
39587
  }
39477
39588
  throw error62;
39478
39589
  }
39590
+ };
39591
+ configure = async (options) => {
39592
+ await this.#applyConfiguration(
39593
+ options.configId,
39594
+ options.value,
39595
+ options.booleanValue,
39596
+ options.valueType,
39597
+ options.signal
39598
+ );
39599
+ const applied = this.#configOptions.find((option) => option.id === options.configId);
39600
+ if (applied === void 0) {
39601
+ throw new AcpExecutionError("The requested ACP configuration option is unavailable");
39602
+ }
39603
+ this.#sessionConfigurations.select(applied);
39604
+ this.#writeStoredSession();
39479
39605
  return this.#configOptions;
39480
39606
  };
39481
39607
  buildPrompt = (options) => {
@@ -39550,19 +39676,8 @@ var AgentSession = class _AgentSession {
39550
39676
  if (this.#sessionTitle === null || this.#sessionTitle.length === 0) {
39551
39677
  this.#sessionTitle = truncate(options.prompt, 500);
39552
39678
  }
39553
- this.#store.write(
39554
- new AcpStoredSession(
39555
- this.#mobiusSessionId,
39556
- this.#agentId,
39557
- this.#updates.sessionId(),
39558
- this.#cwd,
39559
- this.#additionalDirectories,
39560
- true,
39561
- this.#sessionTitle,
39562
- (/* @__PURE__ */ new Date()).toISOString()
39563
- )
39564
- );
39565
39679
  this.#prompted = true;
39680
+ this.#writeStoredSession();
39566
39681
  const running = new RunningAcpTurn(
39567
39682
  options.commandId,
39568
39683
  options.onActivity,
@@ -39633,18 +39748,7 @@ var AgentSession = class _AgentSession {
39633
39748
  usage: result.usage ?? null
39634
39749
  });
39635
39750
  }
39636
- this.#store.write(
39637
- new AcpStoredSession(
39638
- this.#mobiusSessionId,
39639
- this.#agentId,
39640
- this.#updates.sessionId(),
39641
- this.#cwd,
39642
- this.#additionalDirectories,
39643
- true,
39644
- this.#sessionTitle ?? "",
39645
- (/* @__PURE__ */ new Date()).toISOString()
39646
- )
39647
- );
39751
+ this.#writeStoredSession();
39648
39752
  if (lifecycleV2 !== void 0) {
39649
39753
  await this.recordLifecycleEventV2({
39650
39754
  payload: { commandId: options.commandId, kind: "prompt.completed", stopReason: result.stopReason },
@@ -39900,6 +40004,7 @@ var AgentSession = class _AgentSession {
39900
40004
  update.configOptions
39901
40005
  );
39902
40006
  this.#configRevision += 1;
40007
+ this.#captureSelectedConfigurationValues();
39903
40008
  await this.emitConfigUpdate();
39904
40009
  return;
39905
40010
  }
@@ -39908,6 +40013,7 @@ var AgentSession = class _AgentSession {
39908
40013
  (option) => option.category === "mode" ? { ...option, currentValue: update.currentModeId } : option
39909
40014
  );
39910
40015
  this.#configRevision += 1;
40016
+ this.#captureSelectedConfigurationValues();
39911
40017
  await this.emitConfigUpdate();
39912
40018
  return;
39913
40019
  }
@@ -39923,18 +40029,7 @@ var AgentSession = class _AgentSession {
39923
40029
  this.#sessionUpdatedAt = truncate(update.updatedAt ?? "", 128);
39924
40030
  }
39925
40031
  if (this.#updates.sessionId().length > 0) {
39926
- this.#store.write(
39927
- new AcpStoredSession(
39928
- this.#mobiusSessionId,
39929
- this.#agentId,
39930
- this.#updates.sessionId(),
39931
- this.#cwd,
39932
- this.#additionalDirectories,
39933
- this.#prompted,
39934
- this.#sessionTitle ?? "",
39935
- (/* @__PURE__ */ new Date()).toISOString()
39936
- )
39937
- );
40032
+ this.#writeStoredSession();
39938
40033
  }
39939
40034
  await this.#getObserver().onInfo({
39940
40035
  kind: SESSION_INFO_UPDATED_KIND,
@@ -42407,6 +42502,74 @@ var DaemonDiagnosticLog = class {
42407
42502
  this.#path = join18(this.#directory, "daemon.log");
42408
42503
  this.#maximumBytes = maximumBytes;
42409
42504
  }
42505
+ // Export only correlation and failure metadata. Local messages and paths stay local.
42506
+ snapshot = () => {
42507
+ let content;
42508
+ try {
42509
+ content = readFileSync2(this.#path, "utf8");
42510
+ } catch (cause) {
42511
+ if (cause instanceof Error && Reflect.get(cause, "code") === "ENOENT") {
42512
+ return { entries: [], truncated: false };
42513
+ }
42514
+ throw cause;
42515
+ }
42516
+ const lines = content.split("\n").filter((line) => line.length > 0);
42517
+ const entries = [];
42518
+ const fields = [
42519
+ "agentId",
42520
+ "operation",
42521
+ "runtimeId",
42522
+ "closeCode",
42523
+ "timeoutMilliseconds",
42524
+ "proxyRoute",
42525
+ "timestamp",
42526
+ "event",
42527
+ "channelId",
42528
+ "requestId",
42529
+ "commandId",
42530
+ "sessionId",
42531
+ "turnId",
42532
+ "connectionEpoch",
42533
+ "code",
42534
+ "source",
42535
+ "failureName",
42536
+ "failureCode",
42537
+ "failureStatusCode",
42538
+ "cause1Name",
42539
+ "cause1Code",
42540
+ "cause2Name",
42541
+ "cause2Code"
42542
+ ];
42543
+ for (const line of lines.slice(-200)) {
42544
+ const start = line.indexOf("{");
42545
+ if (start < 0) {
42546
+ continue;
42547
+ }
42548
+ let value;
42549
+ try {
42550
+ value = JSON.parse(line.slice(start));
42551
+ } catch {
42552
+ continue;
42553
+ }
42554
+ if (typeof value !== "object" || value === null) {
42555
+ continue;
42556
+ }
42557
+ const entry = {};
42558
+ for (const field of fields) {
42559
+ const item = Reflect.get(value, field);
42560
+ if (typeof item === "string" && /^[a-zA-Z0-9_.: -]{1,256}$/u.test(item)) {
42561
+ entry[field] = item;
42562
+ }
42563
+ }
42564
+ entries.push(entry);
42565
+ }
42566
+ let truncated = lines.length > 200 || Buffer.byteLength(content) >= this.#maximumBytes - 4096;
42567
+ while (JSON.stringify(entries).length > 6e4) {
42568
+ entries.shift();
42569
+ truncated = true;
42570
+ }
42571
+ return { entries, truncated };
42572
+ };
42410
42573
  record = (diagnostic) => {
42411
42574
  const encoded = `${diagnostic.replace(/[\r\n]+/gu, " ").trim()}
42412
42575
  `;
@@ -43342,6 +43505,10 @@ var acpSessionStoreMigrations = [
43342
43505
  {
43343
43506
  "name": "0004_special_mathemanic.sql",
43344
43507
  "sql": "DROP TABLE `deleted_acp_session`;--> statement-breakpoint\nALTER TABLE `acp_session` DROP COLUMN `last_terminal_command_id`;"
43508
+ },
43509
+ {
43510
+ "name": "0005_orange_amphibian.sql",
43511
+ "sql": "ALTER TABLE `acp_session` ADD `configurations` text DEFAULT '[]' NOT NULL;"
43345
43512
  }
43346
43513
  ];
43347
43514
 
@@ -44718,6 +44885,7 @@ var RelayConnectionDiagnostics = class {
44718
44885
  this.#relayOrigin = relayUrl.origin;
44719
44886
  this.#route = describeEnvironmentProxyRoute(relayUrl);
44720
44887
  }
44888
+ snapshot = () => this.#localLog.snapshot();
44721
44889
  catalogFailed = (failure2) => {
44722
44890
  const details = { ...this.#route, relayOrigin: this.#relayOrigin };
44723
44891
  addFailureDetails(details, failure2);
@@ -44789,6 +44957,7 @@ var RelayConnectionDiagnostics = class {
44789
44957
  }
44790
44958
  this.#localLog.record(
44791
44959
  `Mobius daemon diagnostic ${JSON.stringify({
44960
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
44792
44961
  channelId: this.#channelId,
44793
44962
  event,
44794
44963
  requestId,
@@ -44803,7 +44972,12 @@ var RelayConnectionDiagnostics = class {
44803
44972
  event,
44804
44973
  sessionId: this.#channelId
44805
44974
  });
44806
- const encoded = JSON.stringify({ channelId: this.#channelId, event, ...details });
44975
+ const encoded = JSON.stringify({
44976
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
44977
+ channelId: this.#channelId,
44978
+ event,
44979
+ ...details
44980
+ });
44807
44981
  this.#localLog.record(`Mobius relay diagnostic ${encoded}`);
44808
44982
  if (warning) {
44809
44983
  process.stderr.write(`Mobius relay diagnostic ${encoded}
@@ -45441,7 +45615,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
45441
45615
  // src/artifacts/local-file-streamer.ts
45442
45616
  import { createReadStream as createReadStream2 } from "node:fs";
45443
45617
  import { realpath as realpath10, stat as stat9 } from "node:fs/promises";
45444
- import { basename as basename5, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve7 } from "node:path";
45618
+ import { basename as basename5, extname, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve7 } from "node:path";
45445
45619
  import { fileURLToPath as fileURLToPath2 } from "node:url";
45446
45620
  var CHUNK_BYTES = 192 * 1024;
45447
45621
  function requestedPath(value) {
@@ -45491,7 +45665,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
45491
45665
  send2({
45492
45666
  byteLength: before.size,
45493
45667
  kind: FILE_BEGIN_KIND,
45494
- mediaType: external?.mediaType ?? raster?.mimeType ?? "application/octet-stream",
45668
+ mediaType: external?.mediaType ?? raster?.mimeType ?? (extname(target).toLowerCase() === ".svg" ? "image/svg+xml" : "application/octet-stream"),
45495
45669
  modifiedAt: before.mtime.toISOString(),
45496
45670
  name: external?.name ?? (basename5(target) || "file"),
45497
45671
  requestId: command.requestId,
@@ -45555,18 +45729,24 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
45555
45729
  }
45556
45730
 
45557
45731
  // src/daemon-history-commands.ts
45558
- async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventLogV2, signal) {
45732
+ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, nativeSessions, eventLogV2, signal) {
45733
+ let agentId;
45559
45734
  try {
45735
+ const [entry] = await nativeSessions.querySessions([command.sessionId], signal);
45736
+ if (entry === void 0) {
45737
+ throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
45738
+ }
45739
+ agentId = entry.agentId;
45560
45740
  const resolved = await resolveSessionDirectories(
45561
45741
  directories,
45562
45742
  config2.bindingId,
45563
- command.directoryId,
45564
- command.additionalDirectoryIds,
45743
+ entry.directoryId,
45744
+ entry.additionalDirectories.map((directory) => directory.directoryId),
45565
45745
  signal
45566
45746
  );
45567
45747
  const loadOptions = {
45568
45748
  additionalDirectories: resolved.additionalDirectories,
45569
- agent: config2.catalog.find(command.agentId),
45749
+ agent: config2.catalog.find(entry.agentId),
45570
45750
  cwd: resolved.cwd,
45571
45751
  sessionId: command.sessionId,
45572
45752
  signal
@@ -45611,7 +45791,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
45611
45791
  "session_history_v2_load_failed",
45612
45792
  command.requestId,
45613
45793
  {
45614
- agentId: command.agentId,
45794
+ ...agentId === void 0 ? {} : { agentId },
45615
45795
  code: operationErrorCode(error62),
45616
45796
  sessionId: command.sessionId
45617
45797
  },
@@ -45620,7 +45800,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
45620
45800
  audit.record({
45621
45801
  commandId: command.requestId,
45622
45802
  details: {
45623
- agentId: command.agentId,
45803
+ ...agentId === void 0 ? {} : { agentId },
45624
45804
  code: operationErrorCode(error62)
45625
45805
  },
45626
45806
  event: "session_history_v2_load_failed",
@@ -46436,6 +46616,37 @@ function createDaemonCommandHandler({
46436
46616
  return {
46437
46617
  handle: (message) => {
46438
46618
  const kind = message.kind;
46619
+ if (kind === "runtime.diagnostics.read") {
46620
+ audit.record({
46621
+ event: "runtime_diagnostics_read",
46622
+ commandId: message.requestId,
46623
+ sessionId: "runtime",
46624
+ details: {}
46625
+ });
46626
+ try {
46627
+ send(socket, {
46628
+ kind: "runtime.diagnostics.result",
46629
+ requestId: message.requestId,
46630
+ version: package_default.version,
46631
+ ...diagnostics.snapshot()
46632
+ });
46633
+ } catch {
46634
+ audit.record({
46635
+ event: "runtime_diagnostics_failed",
46636
+ commandId: message.requestId,
46637
+ sessionId: "runtime",
46638
+ details: { code: "diagnostics_unavailable" }
46639
+ });
46640
+ send(socket, {
46641
+ kind: "session.operation.failed",
46642
+ requestId: message.requestId,
46643
+ sessionId: "runtime",
46644
+ code: "diagnostics_unavailable",
46645
+ message: "Local diagnostics are unavailable."
46646
+ });
46647
+ }
46648
+ return;
46649
+ }
46439
46650
  if (kind === RUNTIME_PING_KIND) {
46440
46651
  send(socket, { kind: RUNTIME_PONG_KIND, requestId: message.requestId });
46441
46652
  return;
@@ -46449,6 +46660,7 @@ function createDaemonCommandHandler({
46449
46660
  audit,
46450
46661
  diagnostics,
46451
46662
  sessions,
46663
+ nativeSessions,
46452
46664
  eventLogV2,
46453
46665
  signal
46454
46666
  );