@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/runtime.js CHANGED
@@ -20941,6 +20941,24 @@ var encodeNativeSessionResult = (value) => JSON.stringify(nativeSessionResultSch
20941
20941
  var decodeNativeSessionCancel = (encoded) => decode4(nativeSessionCancelSchema, encoded);
20942
20942
  var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSchema.parse(value));
20943
20943
 
20944
+ // ../protocol/src/runtime-diagnostics.ts
20945
+ var identifier = external_exports.custom(isIdentifier);
20946
+ var runtimeDiagnosticsRequestSchema = external_exports.strictObject({
20947
+ kind: external_exports.literal("runtime.diagnostics.read"),
20948
+ requestId: identifier
20949
+ });
20950
+ var runtimeDiagnosticsResultSchema = external_exports.strictObject({
20951
+ kind: external_exports.literal("runtime.diagnostics.result"),
20952
+ requestId: identifier,
20953
+ truncated: external_exports.boolean(),
20954
+ version: external_exports.string().max(32),
20955
+ entries: external_exports.array(external_exports.record(external_exports.string(), external_exports.string().max(256)).readonly()).max(200).readonly()
20956
+ }).refine((value) => JSON.stringify(value).length <= 65536, "Diagnostics exceed the report limit");
20957
+ var decodeRuntimeDiagnosticsRequest = (raw) => runtimeDiagnosticsRequestSchema.parse(JSON.parse(raw));
20958
+ var decodeRuntimeDiagnosticsResult = (raw) => runtimeDiagnosticsResultSchema.parse(JSON.parse(raw));
20959
+ var encodeRuntimeDiagnosticsRequest = (value) => JSON.stringify(runtimeDiagnosticsRequestSchema.parse(value));
20960
+ var encodeRuntimeDiagnosticsResult = (value) => JSON.stringify(runtimeDiagnosticsResultSchema.parse(value));
20961
+
20944
20962
  // ../protocol/src/session-event-log-v2.ts
20945
20963
  var MAX_EVENT_COUNT = 1e4;
20946
20964
  var MAX_COLLECTION_SIZE = 1e3;
@@ -21415,18 +21433,21 @@ var SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND = "session.live-history.v2.page.loa
21415
21433
  var SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND = "session.preview-history.page.load";
21416
21434
  var SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND = "session.preview-history.page.loaded";
21417
21435
  var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
21418
- var pageLoadFields = {
21419
- additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
21420
- agentId: identifierStringSchema,
21421
- bindingId: identifierStringSchema,
21436
+ var pageRequestFields = {
21422
21437
  cursor: external_exports.string().min(1).max(512).nullable(),
21423
- directoryId: directoryIdentifier,
21424
21438
  eventLimit: external_exports.number().int().min(1).max(1e4),
21425
21439
  requestId: identifierStringSchema,
21426
21440
  sessionId: identifierStringSchema
21427
21441
  };
21428
- var sessionLiveHistoryV2PageLoadSchema = external_exports.object({ ...pageLoadFields, kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND) }).readonly();
21429
- var sessionPreviewHistoryPageLoadSchema = external_exports.object({ ...pageLoadFields, kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND) }).readonly();
21442
+ var sessionLiveHistoryV2PageLoadSchema = external_exports.object({ ...pageRequestFields, kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND) }).readonly();
21443
+ var sessionPreviewHistoryPageLoadSchema = external_exports.object({
21444
+ ...pageRequestFields,
21445
+ additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
21446
+ agentId: identifierStringSchema,
21447
+ bindingId: identifierStringSchema,
21448
+ directoryId: directoryIdentifier,
21449
+ kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND)
21450
+ }).readonly();
21430
21451
  var pageLoadedFields = {
21431
21452
  events: nativeSessionEventsV2Schema,
21432
21453
  requestId: identifierStringSchema,
@@ -21514,6 +21535,11 @@ var serviceToDaemonSignatures = {
21514
21535
  encodeRuntimeLivenessReadyEvent,
21515
21536
  decodeRuntimeLivenessReadyEvent
21516
21537
  ),
21538
+ "runtime.diagnostics.read": defineMessageSignature(
21539
+ "runtime.diagnostics.read",
21540
+ encodeRuntimeDiagnosticsRequest,
21541
+ decodeRuntimeDiagnosticsRequest
21542
+ ),
21517
21543
  [RUNTIME_PING_KIND]: defineMessageSignature(RUNTIME_PING_KIND, encodeRuntimePingCommand, decodeRuntimePingCommand),
21518
21544
  [SESSION_CANCEL_KIND]: defineMessageSignature(
21519
21545
  SESSION_CANCEL_KIND,
@@ -21660,6 +21686,11 @@ var daemonToServiceSignatures = {
21660
21686
  encodeRuntimeHeartbeatEvent,
21661
21687
  decodeRuntimeHeartbeatEvent
21662
21688
  ),
21689
+ "runtime.diagnostics.result": defineMessageSignature(
21690
+ "runtime.diagnostics.result",
21691
+ encodeRuntimeDiagnosticsResult,
21692
+ decodeRuntimeDiagnosticsResult
21693
+ ),
21663
21694
  [RUNTIME_PONG_KIND]: defineMessageSignature(RUNTIME_PONG_KIND, encodeRuntimePongEvent, decodeRuntimePongEvent),
21664
21695
  [SESSION_EVENT_V2_KIND]: defineMessageSignature(
21665
21696
  SESSION_EVENT_V2_KIND,
@@ -23334,7 +23365,11 @@ var threadTurnSchema = external_exports.object({
23334
23365
  items: external_exports.array(external_exports.unknown()).max(1e5)
23335
23366
  });
23336
23367
  var threadTurnsSchema = external_exports.array(threadTurnSchema).max(1e5);
23368
+ var collaborationModeSchema = external_exports.object({
23369
+ mode: external_exports.enum(["default", "plan"])
23370
+ });
23337
23371
  var threadLifecycleResponseSchema = external_exports.object({
23372
+ collaborationMode: collaborationModeSchema.nullish(),
23338
23373
  model: boundedText(256).nullish(),
23339
23374
  reasoningEffort: boundedText(256).nullish(),
23340
23375
  serviceTier: boundedText(256).nullish(),
@@ -23379,9 +23414,7 @@ var modelListResponseSchema = external_exports.object({
23379
23414
  var threadSettingsUpdatedSchema = external_exports.object({
23380
23415
  threadId: boundedText(256),
23381
23416
  threadSettings: external_exports.object({
23382
- collaborationMode: external_exports.object({
23383
- mode: external_exports.enum(["default", "plan"])
23384
- }).nullish()
23417
+ collaborationMode: collaborationModeSchema.nullish()
23385
23418
  })
23386
23419
  });
23387
23420
 
@@ -23858,7 +23891,7 @@ var FULL_ACCESS_MODE = Object.freeze({
23858
23891
  sandboxPolicy: { type: "dangerFullAccess" }
23859
23892
  });
23860
23893
  var AGENT_MODES = Object.freeze([READ_ONLY_MODE, AGENT_MODE, FULL_ACCESS_MODE]);
23861
- var DEFAULT_MODE = AGENT_MODE;
23894
+ var DEFAULT_MODE = FULL_ACCESS_MODE;
23862
23895
  function initialMode(environment) {
23863
23896
  const requested = environment["INITIAL_AGENT_MODE"];
23864
23897
  if (requested === void 0) {
@@ -23976,9 +24009,6 @@ function effortSetting(model, currentValue) {
23976
24009
  var CodexSettings = class {
23977
24010
  #appServer;
23978
24011
  #models = [];
23979
- // Whether the current turn must carry a policy at all. Until the user picks a mode, Codex's own
23980
- // configuration decides, so `turn/start` omits the fields and inherits what the host set up.
23981
- #policySelected = false;
23982
24012
  // Whether a collaboration mode choice has been made in this session. A restored thread keeps
23983
24013
  // the mode Codex already persisted, so the first turn does not reset it to Build.
23984
24014
  #collaborationModeSelected = false;
@@ -24018,14 +24048,9 @@ var CodexSettings = class {
24018
24048
  const mode = AGENT_MODES.find((candidate) => candidate.id === selection.mode) ?? DEFAULT_MODE;
24019
24049
  const supportsFast = this.#model(selection.model)?.additionalSpeedTiers?.includes(FAST_TIER) === true;
24020
24050
  return {
24021
- // Until a mode is chosen, `config.toml` decides the sandbox and approval
24022
- // policy, and those fields stay off the turn so the host's own setup is
24023
- // inherited rather than overridden.
24024
- ...this.#policySelected ? {
24025
- approvalPolicy: mode.approvalPolicy,
24026
- approvalsReviewer: mode.approvalsReviewer,
24027
- sandboxPolicy: mode.sandboxPolicy
24028
- } : {},
24051
+ approvalPolicy: mode.approvalPolicy,
24052
+ approvalsReviewer: mode.approvalsReviewer,
24053
+ sandboxPolicy: mode.sandboxPolicy,
24029
24054
  // The collaboration mode rides on the turn: Codex applies it to the
24030
24055
  // thread, where it persists until changed. "Build" is Codex's `default`
24031
24056
  // mode, so it is only sent once a choice exists to apply.
@@ -24118,6 +24143,7 @@ var CodexSettings = class {
24118
24143
  this.#selection = {
24119
24144
  ...this.#selection,
24120
24145
  ...supported,
24146
+ collaborationMode: thread.collaborationMode?.mode ?? this.#selection.collaborationMode,
24121
24147
  fastMode: thread.serviceTier === SERVICE_TIER_FAST
24122
24148
  };
24123
24149
  };
@@ -24157,7 +24183,6 @@ var CodexSettings = class {
24157
24183
  );
24158
24184
  }
24159
24185
  this.#selection = { ...this.#selection, mode: value };
24160
- this.#policySelected = true;
24161
24186
  return;
24162
24187
  }
24163
24188
  if (configId === COLLABORATION_MODE_SETTING_ID) {
@@ -28501,6 +28526,54 @@ function sessionConfigProtocolForAgent(_agentId) {
28501
28526
  return standardSessionConfigProtocol;
28502
28527
  }
28503
28528
 
28529
+ // src/acp/session-configuration.ts
28530
+ var storedSessionConfigurationsSchema = external_exports.array(
28531
+ external_exports.discriminatedUnion("type", [
28532
+ external_exports.object({ booleanValue: external_exports.boolean(), configId: external_exports.string().max(128), type: external_exports.literal("boolean") }),
28533
+ external_exports.object({ configId: external_exports.string().max(128), type: external_exports.literal("select"), value: external_exports.string().max(500) })
28534
+ ])
28535
+ ).max(100);
28536
+ var decodeStoredSessionConfigurations = (value) => storedSessionConfigurationsSchema.parse(value);
28537
+ var AcpSessionConfigurations = class {
28538
+ #selected = [];
28539
+ stored = () => this.#selected;
28540
+ capture = (options) => {
28541
+ this.#selected = this.#selected.map((selection) => {
28542
+ const current = options.find(
28543
+ (option) => option.id === selection.configId && option.type === selection.type
28544
+ );
28545
+ if (current === void 0) {
28546
+ return selection;
28547
+ }
28548
+ return current.type === "boolean" ? { booleanValue: current.booleanValue, configId: current.id, type: "boolean" } : { configId: current.id, type: "select", value: current.currentValue };
28549
+ });
28550
+ };
28551
+ select = (option) => {
28552
+ const selected = option.type === "boolean" ? { booleanValue: option.booleanValue, configId: option.id, type: "boolean" } : { configId: option.id, type: "select", value: option.currentValue };
28553
+ this.#selected = [...this.#selected.filter((selection) => selection.configId !== selected.configId), selected];
28554
+ };
28555
+ restore = async (stored, options, apply, signal) => {
28556
+ this.#selected = stored;
28557
+ for (const selection of this.#selected) {
28558
+ const current = options.find(
28559
+ (option) => option.id === selection.configId && option.type === selection.type
28560
+ );
28561
+ if (current === void 0) {
28562
+ continue;
28563
+ }
28564
+ if (selection.type === "boolean") {
28565
+ if (current.booleanValue !== selection.booleanValue) {
28566
+ await apply(selection, signal);
28567
+ }
28568
+ continue;
28569
+ }
28570
+ if (current.currentValue !== selection.value && current.values.some((value) => value.value === selection.value)) {
28571
+ await apply(selection, signal);
28572
+ }
28573
+ }
28574
+ };
28575
+ };
28576
+
28504
28577
  // src/acp/session-contracts.ts
28505
28578
  var acpNativeHistoryReader = {
28506
28579
  access: () => ({ kind: "acp" })
@@ -29858,10 +29931,10 @@ function sql(strings, ...params) {
29858
29931
  return new SQL(result);
29859
29932
  }
29860
29933
  _sql.join = join20;
29861
- function identifier(value) {
29934
+ function identifier2(value) {
29862
29935
  return new Name(value);
29863
29936
  }
29864
- _sql.identifier = identifier;
29937
+ _sql.identifier = identifier2;
29865
29938
  function placeholder2(name2) {
29866
29939
  return new Placeholder(name2);
29867
29940
  }
@@ -31457,19 +31530,19 @@ var SQLiteCustomColumn = class extends SQLiteColumn {
31457
31530
  mapFromJsonValue(value) {
31458
31531
  return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
31459
31532
  }
31460
- jsonSelectIdentifier(identifier, sql2) {
31461
- if (typeof this.forJsonSelect === "function") return this.forJsonSelect(identifier, sql2);
31533
+ jsonSelectIdentifier(identifier2, sql2) {
31534
+ if (typeof this.forJsonSelect === "function") return this.forJsonSelect(identifier2, sql2);
31462
31535
  const rawType = this.getSQLType().toLowerCase();
31463
31536
  const parenPos = rawType.indexOf("(");
31464
31537
  switch (parenPos + 1 ? rawType.slice(0, parenPos) : rawType) {
31465
31538
  case "numeric":
31466
31539
  case "decimal":
31467
31540
  case "bigint":
31468
- return sql2`cast(${identifier} as text)`;
31541
+ return sql2`cast(${identifier2} as text)`;
31469
31542
  case "blob":
31470
- return sql2`hex(${identifier})`;
31543
+ return sql2`hex(${identifier2})`;
31471
31544
  default:
31472
- return identifier;
31545
+ return identifier2;
31473
31546
  }
31474
31547
  }
31475
31548
  mapToDriverValue = (value) => {
@@ -34110,6 +34183,7 @@ var acpSession = sqliteTable("acp_session", {
34110
34183
  nativeSessionId: text("native_session_id").notNull(),
34111
34184
  cwd: text("cwd").notNull(),
34112
34185
  additionalDirectories: text("additional_directories").notNull(),
34186
+ configurations: text("configurations").notNull().default("[]"),
34113
34187
  prompted: integer2("prompted", { mode: "boolean" }).notNull(),
34114
34188
  title: text("title").notNull(),
34115
34189
  updatedAt: text("updated_at").notNull()
@@ -34377,15 +34451,17 @@ var AcpStoredSession = class {
34377
34451
  additionalDirectories;
34378
34452
  agentId;
34379
34453
  cwd;
34454
+ configurations;
34380
34455
  nativeSessionId;
34381
34456
  prompted;
34382
34457
  sessionId;
34383
34458
  title;
34384
34459
  updatedAt;
34385
- constructor(sessionId, agentId, nativeSessionId, cwd, additionalDirectories, prompted, title2, updatedAt = (/* @__PURE__ */ new Date()).toISOString()) {
34460
+ constructor(sessionId, agentId, nativeSessionId, cwd, additionalDirectories, prompted, title2, updatedAt = (/* @__PURE__ */ new Date()).toISOString(), configurations = []) {
34386
34461
  this.additionalDirectories = [...additionalDirectories];
34387
34462
  this.agentId = agentId;
34388
34463
  this.cwd = cwd;
34464
+ this.configurations = configurations.map((configuration) => ({ ...configuration }));
34389
34465
  this.nativeSessionId = nativeSessionId;
34390
34466
  this.prompted = prompted;
34391
34467
  this.sessionId = sessionId;
@@ -34435,6 +34511,7 @@ var MemoryAcpSessionStore = class {
34435
34511
  var storedSessionRowSchema = external_exports.object({
34436
34512
  additionalDirectories: external_exports.string(),
34437
34513
  agentId: external_exports.string(),
34514
+ configurations: external_exports.string(),
34438
34515
  cwd: external_exports.string(),
34439
34516
  nativeSessionId: external_exports.string(),
34440
34517
  prompted: external_exports.boolean(),
@@ -34446,6 +34523,8 @@ function decodeStoredSession(value) {
34446
34523
  const row = storedSessionRowSchema.parse(value);
34447
34524
  const decodedAdditionalDirectories = JSON.parse(row.additionalDirectories);
34448
34525
  const additionalDirectories = external_exports.array(external_exports.string()).parse(decodedAdditionalDirectories);
34526
+ const decodedConfigurations = JSON.parse(row.configurations);
34527
+ const configurations = decodeStoredSessionConfigurations(decodedConfigurations);
34449
34528
  return new AcpStoredSession(
34450
34529
  row.sessionId,
34451
34530
  row.agentId,
@@ -34454,7 +34533,8 @@ function decodeStoredSession(value) {
34454
34533
  additionalDirectories,
34455
34534
  row.prompted,
34456
34535
  row.title,
34457
- row.updatedAt
34536
+ row.updatedAt,
34537
+ configurations
34458
34538
  );
34459
34539
  }
34460
34540
  var SqliteAcpSessionStore = class {
@@ -34487,6 +34567,7 @@ var SqliteAcpSessionStore = class {
34487
34567
  const value = {
34488
34568
  additionalDirectories: JSON.stringify(session.additionalDirectories),
34489
34569
  agentId: session.agentId,
34570
+ configurations: JSON.stringify(session.configurations),
34490
34571
  cwd: session.cwd,
34491
34572
  nativeSessionId: session.nativeSessionId,
34492
34573
  prompted: session.prompted,
@@ -34535,6 +34616,7 @@ var AgentSession = class _AgentSession {
34535
34616
  #commands = [];
34536
34617
  #configRevision = 0;
34537
34618
  #configOptions = [];
34619
+ #sessionConfigurations = new AcpSessionConfigurations();
34538
34620
  #nativeHistoryOwnership = { kind: "unbound" };
34539
34621
  #prompted = false;
34540
34622
  #nativePrompt = null;
@@ -34639,6 +34721,41 @@ var AgentSession = class _AgentSession {
34639
34721
  usesEnvironment = (environment) => recordsEqual(this.#environment, environment);
34640
34722
  canRebind = () => !this.#prompted && !this.#turn.running;
34641
34723
  hasRunningTurn = () => this.#turn.running;
34724
+ #writeStoredSession = () => {
34725
+ this.#store.write(
34726
+ new AcpStoredSession(
34727
+ this.#mobiusSessionId,
34728
+ this.#agentId,
34729
+ this.#updates.sessionId(),
34730
+ this.#cwd,
34731
+ this.#additionalDirectories,
34732
+ this.#prompted,
34733
+ this.#sessionTitle ?? "",
34734
+ (/* @__PURE__ */ new Date()).toISOString(),
34735
+ this.#sessionConfigurations.stored()
34736
+ )
34737
+ );
34738
+ };
34739
+ #captureSelectedConfigurationValues = () => {
34740
+ this.#sessionConfigurations.capture(this.#configOptions);
34741
+ if (this.#updates.sessionId().length > 0) {
34742
+ this.#writeStoredSession();
34743
+ }
34744
+ };
34745
+ #restoreStoredConfigurations = async (session, signal) => {
34746
+ await this.#sessionConfigurations.restore(
34747
+ session.configurations,
34748
+ this.#configOptions,
34749
+ async (selection, signal2) => await this.#applyConfiguration(
34750
+ selection.configId,
34751
+ selection.type === "select" ? selection.value : "",
34752
+ selection.type === "boolean" ? selection.booleanValue : false,
34753
+ selection.type,
34754
+ signal2
34755
+ ),
34756
+ signal
34757
+ );
34758
+ };
34642
34759
  prepared = () => new AcpPreparedSession(
34643
34760
  this.#agentName,
34644
34761
  this.#agentVersion,
@@ -34989,20 +35106,12 @@ var AgentSession = class _AgentSession {
34989
35106
  lifecycleResponse = created;
34990
35107
  }
34991
35108
  this.#configOptions = this.#sessionConfigProtocol.normalizeLifecycle(lifecycleResponse);
35109
+ if (stored instanceof FoundAcpStoredSession && this.#restored) {
35110
+ await this.#restoreStoredConfigurations(stored.session, signal);
35111
+ }
34992
35112
  await this.#updates.drained();
34993
35113
  signal.throwIfAborted();
34994
- this.#store.write(
34995
- new AcpStoredSession(
34996
- this.#mobiusSessionId,
34997
- this.#agentId,
34998
- this.#updates.sessionId(),
34999
- this.#cwd,
35000
- this.#additionalDirectories,
35001
- this.#prompted,
35002
- this.#sessionTitle ?? "",
35003
- (/* @__PURE__ */ new Date()).toISOString()
35004
- )
35005
- );
35114
+ this.#writeStoredSession();
35006
35115
  };
35007
35116
  listNativeSessions = async (cursor, signal) => {
35008
35117
  if (!this.#capabilities.listSessions) {
@@ -35043,15 +35152,17 @@ var AgentSession = class _AgentSession {
35043
35152
  this.#cwd,
35044
35153
  this.#additionalDirectories,
35045
35154
  false,
35046
- ""
35155
+ "",
35156
+ (/* @__PURE__ */ new Date()).toISOString(),
35157
+ this.#sessionConfigurations.stored()
35047
35158
  )
35048
35159
  );
35049
35160
  this.#store.remove(previousSessionId);
35050
35161
  this.#mobiusSessionId = sessionId;
35051
35162
  };
35052
- configure = async (options) => {
35053
- const existing = this.#configOptions.find((option) => option.id === options.configId);
35054
- if (existing === void 0 || existing.type !== options.valueType) {
35163
+ #applyConfiguration = async (configId, value, booleanValue, valueType, signal) => {
35164
+ const existing = this.#configOptions.find((option) => option.id === configId);
35165
+ if (existing === void 0 || existing.type !== valueType) {
35055
35166
  throw new AcpExecutionError(
35056
35167
  "The requested ACP configuration option is unavailable",
35057
35168
  {},
@@ -35066,10 +35177,10 @@ var AgentSession = class _AgentSession {
35066
35177
  "invalid_session_configuration"
35067
35178
  );
35068
35179
  }
35069
- if (!existing.values.some((entry) => entry.value === options.value)) {
35180
+ if (!existing.values.some((entry) => entry.value === value)) {
35070
35181
  throw new AcpConfigurationValueUnavailableError(
35071
- options.configId,
35072
- options.value,
35182
+ configId,
35183
+ value,
35073
35184
  existing.values.map((entry) => entry.value)
35074
35185
  );
35075
35186
  }
@@ -35078,20 +35189,20 @@ var AgentSession = class _AgentSession {
35078
35189
  try {
35079
35190
  const configured = await this.#sessionConfigProtocol.configure(
35080
35191
  this.#configOptions,
35081
- options,
35192
+ { booleanValue, configId, signal, value },
35082
35193
  this.#updates.sessionId(),
35083
35194
  {
35084
- request: async (method, params, failureMessage, signal) => await this.race(
35195
+ request: async (method, params, failureMessage, signal2) => await this.race(
35085
35196
  this.#connection.connection.agent.request(method, params, {
35086
- cancellationSignal: signal
35197
+ cancellationSignal: signal2
35087
35198
  }),
35088
35199
  failureMessage,
35089
- signal
35200
+ signal2
35090
35201
  )
35091
35202
  }
35092
35203
  );
35093
- const applied = configured.find((option) => option.id === options.configId);
35094
- if (applied === void 0 || applied.type !== options.valueType || applied.type === "boolean" && applied.booleanValue !== options.booleanValue || applied.type === "select" && applied.currentValue !== options.value) {
35204
+ const applied = configured.find((option) => option.id === configId);
35205
+ if (applied === void 0 || applied.type !== valueType || applied.type === "boolean" && applied.booleanValue !== booleanValue || applied.type === "select" && applied.currentValue !== value) {
35095
35206
  throw new AcpExecutionError(
35096
35207
  "The Agent did not apply the requested session configuration",
35097
35208
  {},
@@ -35108,6 +35219,21 @@ var AgentSession = class _AgentSession {
35108
35219
  }
35109
35220
  throw error62;
35110
35221
  }
35222
+ };
35223
+ configure = async (options) => {
35224
+ await this.#applyConfiguration(
35225
+ options.configId,
35226
+ options.value,
35227
+ options.booleanValue,
35228
+ options.valueType,
35229
+ options.signal
35230
+ );
35231
+ const applied = this.#configOptions.find((option) => option.id === options.configId);
35232
+ if (applied === void 0) {
35233
+ throw new AcpExecutionError("The requested ACP configuration option is unavailable");
35234
+ }
35235
+ this.#sessionConfigurations.select(applied);
35236
+ this.#writeStoredSession();
35111
35237
  return this.#configOptions;
35112
35238
  };
35113
35239
  buildPrompt = (options) => {
@@ -35182,19 +35308,8 @@ var AgentSession = class _AgentSession {
35182
35308
  if (this.#sessionTitle === null || this.#sessionTitle.length === 0) {
35183
35309
  this.#sessionTitle = truncate(options.prompt, 500);
35184
35310
  }
35185
- this.#store.write(
35186
- new AcpStoredSession(
35187
- this.#mobiusSessionId,
35188
- this.#agentId,
35189
- this.#updates.sessionId(),
35190
- this.#cwd,
35191
- this.#additionalDirectories,
35192
- true,
35193
- this.#sessionTitle,
35194
- (/* @__PURE__ */ new Date()).toISOString()
35195
- )
35196
- );
35197
35311
  this.#prompted = true;
35312
+ this.#writeStoredSession();
35198
35313
  const running = new RunningAcpTurn(
35199
35314
  options.commandId,
35200
35315
  options.onActivity,
@@ -35265,18 +35380,7 @@ var AgentSession = class _AgentSession {
35265
35380
  usage: result.usage ?? null
35266
35381
  });
35267
35382
  }
35268
- this.#store.write(
35269
- new AcpStoredSession(
35270
- this.#mobiusSessionId,
35271
- this.#agentId,
35272
- this.#updates.sessionId(),
35273
- this.#cwd,
35274
- this.#additionalDirectories,
35275
- true,
35276
- this.#sessionTitle ?? "",
35277
- (/* @__PURE__ */ new Date()).toISOString()
35278
- )
35279
- );
35383
+ this.#writeStoredSession();
35280
35384
  if (lifecycleV2 !== void 0) {
35281
35385
  await this.recordLifecycleEventV2({
35282
35386
  payload: { commandId: options.commandId, kind: "prompt.completed", stopReason: result.stopReason },
@@ -35532,6 +35636,7 @@ var AgentSession = class _AgentSession {
35532
35636
  update.configOptions
35533
35637
  );
35534
35638
  this.#configRevision += 1;
35639
+ this.#captureSelectedConfigurationValues();
35535
35640
  await this.emitConfigUpdate();
35536
35641
  return;
35537
35642
  }
@@ -35540,6 +35645,7 @@ var AgentSession = class _AgentSession {
35540
35645
  (option) => option.category === "mode" ? { ...option, currentValue: update.currentModeId } : option
35541
35646
  );
35542
35647
  this.#configRevision += 1;
35648
+ this.#captureSelectedConfigurationValues();
35543
35649
  await this.emitConfigUpdate();
35544
35650
  return;
35545
35651
  }
@@ -35555,18 +35661,7 @@ var AgentSession = class _AgentSession {
35555
35661
  this.#sessionUpdatedAt = truncate(update.updatedAt ?? "", 128);
35556
35662
  }
35557
35663
  if (this.#updates.sessionId().length > 0) {
35558
- this.#store.write(
35559
- new AcpStoredSession(
35560
- this.#mobiusSessionId,
35561
- this.#agentId,
35562
- this.#updates.sessionId(),
35563
- this.#cwd,
35564
- this.#additionalDirectories,
35565
- this.#prompted,
35566
- this.#sessionTitle ?? "",
35567
- (/* @__PURE__ */ new Date()).toISOString()
35568
- )
35569
- );
35664
+ this.#writeStoredSession();
35570
35665
  }
35571
35666
  await this.#getObserver().onInfo({
35572
35667
  kind: SESSION_INFO_UPDATED_KIND,
@@ -38039,6 +38134,74 @@ var DaemonDiagnosticLog = class {
38039
38134
  this.#path = join17(this.#directory, "daemon.log");
38040
38135
  this.#maximumBytes = maximumBytes;
38041
38136
  }
38137
+ // Export only correlation and failure metadata. Local messages and paths stay local.
38138
+ snapshot = () => {
38139
+ let content;
38140
+ try {
38141
+ content = readFileSync2(this.#path, "utf8");
38142
+ } catch (cause) {
38143
+ if (cause instanceof Error && Reflect.get(cause, "code") === "ENOENT") {
38144
+ return { entries: [], truncated: false };
38145
+ }
38146
+ throw cause;
38147
+ }
38148
+ const lines = content.split("\n").filter((line) => line.length > 0);
38149
+ const entries = [];
38150
+ const fields = [
38151
+ "agentId",
38152
+ "operation",
38153
+ "runtimeId",
38154
+ "closeCode",
38155
+ "timeoutMilliseconds",
38156
+ "proxyRoute",
38157
+ "timestamp",
38158
+ "event",
38159
+ "channelId",
38160
+ "requestId",
38161
+ "commandId",
38162
+ "sessionId",
38163
+ "turnId",
38164
+ "connectionEpoch",
38165
+ "code",
38166
+ "source",
38167
+ "failureName",
38168
+ "failureCode",
38169
+ "failureStatusCode",
38170
+ "cause1Name",
38171
+ "cause1Code",
38172
+ "cause2Name",
38173
+ "cause2Code"
38174
+ ];
38175
+ for (const line of lines.slice(-200)) {
38176
+ const start = line.indexOf("{");
38177
+ if (start < 0) {
38178
+ continue;
38179
+ }
38180
+ let value;
38181
+ try {
38182
+ value = JSON.parse(line.slice(start));
38183
+ } catch {
38184
+ continue;
38185
+ }
38186
+ if (typeof value !== "object" || value === null) {
38187
+ continue;
38188
+ }
38189
+ const entry = {};
38190
+ for (const field of fields) {
38191
+ const item = Reflect.get(value, field);
38192
+ if (typeof item === "string" && /^[a-zA-Z0-9_.: -]{1,256}$/u.test(item)) {
38193
+ entry[field] = item;
38194
+ }
38195
+ }
38196
+ entries.push(entry);
38197
+ }
38198
+ let truncated = lines.length > 200 || Buffer.byteLength(content) >= this.#maximumBytes - 4096;
38199
+ while (JSON.stringify(entries).length > 6e4) {
38200
+ entries.shift();
38201
+ truncated = true;
38202
+ }
38203
+ return { entries, truncated };
38204
+ };
38042
38205
  record = (diagnostic) => {
38043
38206
  const encoded = `${diagnostic.replace(/[\r\n]+/gu, " ").trim()}
38044
38207
  `;
@@ -38974,6 +39137,10 @@ var acpSessionStoreMigrations = [
38974
39137
  {
38975
39138
  "name": "0004_special_mathemanic.sql",
38976
39139
  "sql": "DROP TABLE `deleted_acp_session`;--> statement-breakpoint\nALTER TABLE `acp_session` DROP COLUMN `last_terminal_command_id`;"
39140
+ },
39141
+ {
39142
+ "name": "0005_orange_amphibian.sql",
39143
+ "sql": "ALTER TABLE `acp_session` ADD `configurations` text DEFAULT '[]' NOT NULL;"
38977
39144
  }
38978
39145
  ];
38979
39146
 
@@ -40350,6 +40517,7 @@ var RelayConnectionDiagnostics = class {
40350
40517
  this.#relayOrigin = relayUrl.origin;
40351
40518
  this.#route = describeEnvironmentProxyRoute(relayUrl);
40352
40519
  }
40520
+ snapshot = () => this.#localLog.snapshot();
40353
40521
  catalogFailed = (failure2) => {
40354
40522
  const details = { ...this.#route, relayOrigin: this.#relayOrigin };
40355
40523
  addFailureDetails(details, failure2);
@@ -40421,6 +40589,7 @@ var RelayConnectionDiagnostics = class {
40421
40589
  }
40422
40590
  this.#localLog.record(
40423
40591
  `Mobius daemon diagnostic ${JSON.stringify({
40592
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
40424
40593
  channelId: this.#channelId,
40425
40594
  event,
40426
40595
  requestId,
@@ -40435,7 +40604,12 @@ var RelayConnectionDiagnostics = class {
40435
40604
  event,
40436
40605
  sessionId: this.#channelId
40437
40606
  });
40438
- const encoded = JSON.stringify({ channelId: this.#channelId, event, ...details });
40607
+ const encoded = JSON.stringify({
40608
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
40609
+ channelId: this.#channelId,
40610
+ event,
40611
+ ...details
40612
+ });
40439
40613
  this.#localLog.record(`Mobius relay diagnostic ${encoded}`);
40440
40614
  if (warning) {
40441
40615
  process.stderr.write(`Mobius relay diagnostic ${encoded}
@@ -40453,6 +40627,82 @@ import { WebSocket as WebSocket7 } from "undici";
40453
40627
  // src/daemon-command-handler.ts
40454
40628
  import { WebSocket as WebSocket5 } from "undici";
40455
40629
 
40630
+ // package.json
40631
+ var package_default = {
40632
+ name: "@moxt-ai/mobius",
40633
+ version: "0.0.192",
40634
+ description: "Mobius CLI for pairing and running local AI agent services.",
40635
+ type: "module",
40636
+ bin: {
40637
+ mobius: "dist/cli.js"
40638
+ },
40639
+ types: "./src/index.ts",
40640
+ exports: {
40641
+ ".": "./src/index.ts",
40642
+ "./runtime": "./src/runtime.ts"
40643
+ },
40644
+ files: [
40645
+ "dist"
40646
+ ],
40647
+ engines: {
40648
+ node: ">=22.13.0"
40649
+ },
40650
+ publishConfig: {
40651
+ access: "public",
40652
+ types: "./dist/index.d.ts",
40653
+ exports: {
40654
+ ".": {
40655
+ types: "./dist/index.d.ts",
40656
+ import: "./dist/index.js"
40657
+ },
40658
+ "./runtime": {
40659
+ types: "./dist/runtime.d.ts",
40660
+ import: "./dist/runtime.js"
40661
+ }
40662
+ }
40663
+ },
40664
+ repository: {
40665
+ type: "git",
40666
+ url: "git+https://github.com/moxt-ai/mobius.git",
40667
+ directory: "packages/cli"
40668
+ },
40669
+ scripts: {
40670
+ build: "tsc --project tsconfig.build.json && esbuild src/cli.ts src/index.ts src/runtime.ts --bundle --platform=node --format=esm --sourcemap --outdir=dist --external:@agentclientprotocol/* --external:undici",
40671
+ dev: "node --watch src/cli.ts",
40672
+ prepack: "pnpm build",
40673
+ start: "node dist/cli.js",
40674
+ typecheck: "tsc --project tsconfig.json && tsc --project tests/tsconfig.json",
40675
+ "test:controlled": "vitest run tests/sessions tests/runtime --maxWorkers=4",
40676
+ "test:agents": "vitest run tests/agents --maxWorkers=2"
40677
+ },
40678
+ dependencies: {
40679
+ "@agentclientprotocol/sdk": "^1.4.0",
40680
+ commander: "15.0.0",
40681
+ undici: "8.10.2",
40682
+ zod: "^4.6.5"
40683
+ },
40684
+ devDependencies: {
40685
+ "@moxt-ai/mobius-protocol": "workspace:*",
40686
+ "@types/node": "^24.13.5",
40687
+ "drizzle-kit": "1.0.0-rc.4",
40688
+ "drizzle-orm": "1.0.0-rc.4",
40689
+ esbuild: "0.28.2",
40690
+ "@moxt-ai/mobius-sdk": "workspace:*",
40691
+ "@moxt-ai/mobius-test": "workspace:*",
40692
+ valibot: "1.5.0",
40693
+ ws: "^8.21.3",
40694
+ "@types/ws": "^8.18.1"
40695
+ },
40696
+ main: "dist/index.js",
40697
+ keywords: [],
40698
+ author: "",
40699
+ license: "ISC",
40700
+ bugs: {
40701
+ url: "https://github.com/moxt-ai/mobius/issues"
40702
+ },
40703
+ homepage: "https://github.com/moxt-ai/mobius#readme"
40704
+ };
40705
+
40456
40706
  // src/agent-catalog/handle-agent-settings-discovery.ts
40457
40707
  import { WebSocket as WebSocket3 } from "undici";
40458
40708
 
@@ -41073,7 +41323,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
41073
41323
  // src/artifacts/local-file-streamer.ts
41074
41324
  import { createReadStream as createReadStream2 } from "node:fs";
41075
41325
  import { realpath as realpath9, stat as stat8 } from "node:fs/promises";
41076
- import { basename as basename4, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve5 } from "node:path";
41326
+ import { basename as basename4, extname, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve5 } from "node:path";
41077
41327
  import { fileURLToPath as fileURLToPath2 } from "node:url";
41078
41328
  var CHUNK_BYTES = 192 * 1024;
41079
41329
  function requestedPath(value) {
@@ -41123,7 +41373,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
41123
41373
  send2({
41124
41374
  byteLength: before.size,
41125
41375
  kind: FILE_BEGIN_KIND,
41126
- mediaType: external?.mediaType ?? raster?.mimeType ?? "application/octet-stream",
41376
+ mediaType: external?.mediaType ?? raster?.mimeType ?? (extname(target).toLowerCase() === ".svg" ? "image/svg+xml" : "application/octet-stream"),
41127
41377
  modifiedAt: before.mtime.toISOString(),
41128
41378
  name: external?.name ?? (basename4(target) || "file"),
41129
41379
  requestId: command.requestId,
@@ -41187,18 +41437,24 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
41187
41437
  }
41188
41438
 
41189
41439
  // src/daemon-history-commands.ts
41190
- async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventLogV2, signal) {
41440
+ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, nativeSessions, eventLogV2, signal) {
41441
+ let agentId;
41191
41442
  try {
41443
+ const [entry] = await nativeSessions.querySessions([command.sessionId], signal);
41444
+ if (entry === void 0) {
41445
+ throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
41446
+ }
41447
+ agentId = entry.agentId;
41192
41448
  const resolved = await resolveSessionDirectories(
41193
41449
  directories,
41194
41450
  config2.bindingId,
41195
- command.directoryId,
41196
- command.additionalDirectoryIds,
41451
+ entry.directoryId,
41452
+ entry.additionalDirectories.map((directory) => directory.directoryId),
41197
41453
  signal
41198
41454
  );
41199
41455
  const loadOptions = {
41200
41456
  additionalDirectories: resolved.additionalDirectories,
41201
- agent: config2.catalog.find(command.agentId),
41457
+ agent: config2.catalog.find(entry.agentId),
41202
41458
  cwd: resolved.cwd,
41203
41459
  sessionId: command.sessionId,
41204
41460
  signal
@@ -41243,7 +41499,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
41243
41499
  "session_history_v2_load_failed",
41244
41500
  command.requestId,
41245
41501
  {
41246
- agentId: command.agentId,
41502
+ ...agentId === void 0 ? {} : { agentId },
41247
41503
  code: operationErrorCode(error62),
41248
41504
  sessionId: command.sessionId
41249
41505
  },
@@ -41252,7 +41508,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
41252
41508
  audit.record({
41253
41509
  commandId: command.requestId,
41254
41510
  details: {
41255
- agentId: command.agentId,
41511
+ ...agentId === void 0 ? {} : { agentId },
41256
41512
  code: operationErrorCode(error62)
41257
41513
  },
41258
41514
  event: "session_history_v2_load_failed",
@@ -42068,6 +42324,37 @@ function createDaemonCommandHandler({
42068
42324
  return {
42069
42325
  handle: (message) => {
42070
42326
  const kind = message.kind;
42327
+ if (kind === "runtime.diagnostics.read") {
42328
+ audit.record({
42329
+ event: "runtime_diagnostics_read",
42330
+ commandId: message.requestId,
42331
+ sessionId: "runtime",
42332
+ details: {}
42333
+ });
42334
+ try {
42335
+ send(socket, {
42336
+ kind: "runtime.diagnostics.result",
42337
+ requestId: message.requestId,
42338
+ version: package_default.version,
42339
+ ...diagnostics.snapshot()
42340
+ });
42341
+ } catch {
42342
+ audit.record({
42343
+ event: "runtime_diagnostics_failed",
42344
+ commandId: message.requestId,
42345
+ sessionId: "runtime",
42346
+ details: { code: "diagnostics_unavailable" }
42347
+ });
42348
+ send(socket, {
42349
+ kind: "session.operation.failed",
42350
+ requestId: message.requestId,
42351
+ sessionId: "runtime",
42352
+ code: "diagnostics_unavailable",
42353
+ message: "Local diagnostics are unavailable."
42354
+ });
42355
+ }
42356
+ return;
42357
+ }
42071
42358
  if (kind === RUNTIME_PING_KIND) {
42072
42359
  send(socket, { kind: RUNTIME_PONG_KIND, requestId: message.requestId });
42073
42360
  return;
@@ -42081,6 +42368,7 @@ function createDaemonCommandHandler({
42081
42368
  audit,
42082
42369
  diagnostics,
42083
42370
  sessions,
42371
+ nativeSessions,
42084
42372
  eventLogV2,
42085
42373
  signal
42086
42374
  );