@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/index.js CHANGED
@@ -20967,6 +20967,24 @@ var encodeNativeSessionResult = (value) => JSON.stringify(nativeSessionResultSch
20967
20967
  var decodeNativeSessionCancel = (encoded) => decode4(nativeSessionCancelSchema, encoded);
20968
20968
  var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSchema.parse(value));
20969
20969
 
20970
+ // ../protocol/src/runtime-diagnostics.ts
20971
+ var identifier = external_exports.custom(isIdentifier);
20972
+ var runtimeDiagnosticsRequestSchema = external_exports.strictObject({
20973
+ kind: external_exports.literal("runtime.diagnostics.read"),
20974
+ requestId: identifier
20975
+ });
20976
+ var runtimeDiagnosticsResultSchema = external_exports.strictObject({
20977
+ kind: external_exports.literal("runtime.diagnostics.result"),
20978
+ requestId: identifier,
20979
+ truncated: external_exports.boolean(),
20980
+ version: external_exports.string().max(32),
20981
+ entries: external_exports.array(external_exports.record(external_exports.string(), external_exports.string().max(256)).readonly()).max(200).readonly()
20982
+ }).refine((value) => JSON.stringify(value).length <= 65536, "Diagnostics exceed the report limit");
20983
+ var decodeRuntimeDiagnosticsRequest = (raw) => runtimeDiagnosticsRequestSchema.parse(JSON.parse(raw));
20984
+ var decodeRuntimeDiagnosticsResult = (raw) => runtimeDiagnosticsResultSchema.parse(JSON.parse(raw));
20985
+ var encodeRuntimeDiagnosticsRequest = (value) => JSON.stringify(runtimeDiagnosticsRequestSchema.parse(value));
20986
+ var encodeRuntimeDiagnosticsResult = (value) => JSON.stringify(runtimeDiagnosticsResultSchema.parse(value));
20987
+
20970
20988
  // ../protocol/src/session-event-log-v2.ts
20971
20989
  var MAX_EVENT_COUNT = 1e4;
20972
20990
  var MAX_COLLECTION_SIZE = 1e3;
@@ -21441,18 +21459,21 @@ var SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND = "session.live-history.v2.page.loa
21441
21459
  var SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND = "session.preview-history.page.load";
21442
21460
  var SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND = "session.preview-history.page.loaded";
21443
21461
  var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
21444
- var pageLoadFields = {
21445
- additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
21446
- agentId: identifierStringSchema,
21447
- bindingId: identifierStringSchema,
21462
+ var pageRequestFields = {
21448
21463
  cursor: external_exports.string().min(1).max(512).nullable(),
21449
- directoryId: directoryIdentifier,
21450
21464
  eventLimit: external_exports.number().int().min(1).max(1e4),
21451
21465
  requestId: identifierStringSchema,
21452
21466
  sessionId: identifierStringSchema
21453
21467
  };
21454
- var sessionLiveHistoryV2PageLoadSchema = external_exports.object({ ...pageLoadFields, kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND) }).readonly();
21455
- var sessionPreviewHistoryPageLoadSchema = external_exports.object({ ...pageLoadFields, kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND) }).readonly();
21468
+ var sessionLiveHistoryV2PageLoadSchema = external_exports.object({ ...pageRequestFields, kind: external_exports.literal(SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND) }).readonly();
21469
+ var sessionPreviewHistoryPageLoadSchema = external_exports.object({
21470
+ ...pageRequestFields,
21471
+ additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
21472
+ agentId: identifierStringSchema,
21473
+ bindingId: identifierStringSchema,
21474
+ directoryId: directoryIdentifier,
21475
+ kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND)
21476
+ }).readonly();
21456
21477
  var pageLoadedFields = {
21457
21478
  events: nativeSessionEventsV2Schema,
21458
21479
  requestId: identifierStringSchema,
@@ -21540,6 +21561,11 @@ var serviceToDaemonSignatures = {
21540
21561
  encodeRuntimeLivenessReadyEvent,
21541
21562
  decodeRuntimeLivenessReadyEvent
21542
21563
  ),
21564
+ "runtime.diagnostics.read": defineMessageSignature(
21565
+ "runtime.diagnostics.read",
21566
+ encodeRuntimeDiagnosticsRequest,
21567
+ decodeRuntimeDiagnosticsRequest
21568
+ ),
21543
21569
  [RUNTIME_PING_KIND]: defineMessageSignature(RUNTIME_PING_KIND, encodeRuntimePingCommand, decodeRuntimePingCommand),
21544
21570
  [SESSION_CANCEL_KIND]: defineMessageSignature(
21545
21571
  SESSION_CANCEL_KIND,
@@ -21686,6 +21712,11 @@ var daemonToServiceSignatures = {
21686
21712
  encodeRuntimeHeartbeatEvent,
21687
21713
  decodeRuntimeHeartbeatEvent
21688
21714
  ),
21715
+ "runtime.diagnostics.result": defineMessageSignature(
21716
+ "runtime.diagnostics.result",
21717
+ encodeRuntimeDiagnosticsResult,
21718
+ decodeRuntimeDiagnosticsResult
21719
+ ),
21689
21720
  [RUNTIME_PONG_KIND]: defineMessageSignature(RUNTIME_PONG_KIND, encodeRuntimePongEvent, decodeRuntimePongEvent),
21690
21721
  [SESSION_EVENT_V2_KIND]: defineMessageSignature(
21691
21722
  SESSION_EVENT_V2_KIND,
@@ -24156,6 +24187,54 @@ function sessionConfigProtocolForAgent(_agentId) {
24156
24187
  return standardSessionConfigProtocol;
24157
24188
  }
24158
24189
 
24190
+ // src/acp/session-configuration.ts
24191
+ var storedSessionConfigurationsSchema = external_exports.array(
24192
+ external_exports.discriminatedUnion("type", [
24193
+ external_exports.object({ booleanValue: external_exports.boolean(), configId: external_exports.string().max(128), type: external_exports.literal("boolean") }),
24194
+ external_exports.object({ configId: external_exports.string().max(128), type: external_exports.literal("select"), value: external_exports.string().max(500) })
24195
+ ])
24196
+ ).max(100);
24197
+ var decodeStoredSessionConfigurations = (value) => storedSessionConfigurationsSchema.parse(value);
24198
+ var AcpSessionConfigurations = class {
24199
+ #selected = [];
24200
+ stored = () => this.#selected;
24201
+ capture = (options) => {
24202
+ this.#selected = this.#selected.map((selection) => {
24203
+ const current = options.find(
24204
+ (option) => option.id === selection.configId && option.type === selection.type
24205
+ );
24206
+ if (current === void 0) {
24207
+ return selection;
24208
+ }
24209
+ return current.type === "boolean" ? { booleanValue: current.booleanValue, configId: current.id, type: "boolean" } : { configId: current.id, type: "select", value: current.currentValue };
24210
+ });
24211
+ };
24212
+ select = (option) => {
24213
+ const selected = option.type === "boolean" ? { booleanValue: option.booleanValue, configId: option.id, type: "boolean" } : { configId: option.id, type: "select", value: option.currentValue };
24214
+ this.#selected = [...this.#selected.filter((selection) => selection.configId !== selected.configId), selected];
24215
+ };
24216
+ restore = async (stored, options, apply, signal) => {
24217
+ this.#selected = stored;
24218
+ for (const selection of this.#selected) {
24219
+ const current = options.find(
24220
+ (option) => option.id === selection.configId && option.type === selection.type
24221
+ );
24222
+ if (current === void 0) {
24223
+ continue;
24224
+ }
24225
+ if (selection.type === "boolean") {
24226
+ if (current.booleanValue !== selection.booleanValue) {
24227
+ await apply(selection, signal);
24228
+ }
24229
+ continue;
24230
+ }
24231
+ if (current.currentValue !== selection.value && current.values.some((value) => value.value === selection.value)) {
24232
+ await apply(selection, signal);
24233
+ }
24234
+ }
24235
+ };
24236
+ };
24237
+
24159
24238
  // src/acp/session-contracts.ts
24160
24239
  var acpNativeHistoryReader = {
24161
24240
  access: () => ({ kind: "acp" })
@@ -25570,10 +25649,10 @@ function sql(strings, ...params) {
25570
25649
  return new SQL(result);
25571
25650
  }
25572
25651
  _sql.join = join20;
25573
- function identifier(value) {
25652
+ function identifier2(value) {
25574
25653
  return new Name(value);
25575
25654
  }
25576
- _sql.identifier = identifier;
25655
+ _sql.identifier = identifier2;
25577
25656
  function placeholder2(name2) {
25578
25657
  return new Placeholder(name2);
25579
25658
  }
@@ -27169,19 +27248,19 @@ var SQLiteCustomColumn = class extends SQLiteColumn {
27169
27248
  mapFromJsonValue(value) {
27170
27249
  return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
27171
27250
  }
27172
- jsonSelectIdentifier(identifier, sql2) {
27173
- if (typeof this.forJsonSelect === "function") return this.forJsonSelect(identifier, sql2);
27251
+ jsonSelectIdentifier(identifier2, sql2) {
27252
+ if (typeof this.forJsonSelect === "function") return this.forJsonSelect(identifier2, sql2);
27174
27253
  const rawType = this.getSQLType().toLowerCase();
27175
27254
  const parenPos = rawType.indexOf("(");
27176
27255
  switch (parenPos + 1 ? rawType.slice(0, parenPos) : rawType) {
27177
27256
  case "numeric":
27178
27257
  case "decimal":
27179
27258
  case "bigint":
27180
- return sql2`cast(${identifier} as text)`;
27259
+ return sql2`cast(${identifier2} as text)`;
27181
27260
  case "blob":
27182
- return sql2`hex(${identifier})`;
27261
+ return sql2`hex(${identifier2})`;
27183
27262
  default:
27184
- return identifier;
27263
+ return identifier2;
27185
27264
  }
27186
27265
  }
27187
27266
  mapToDriverValue = (value) => {
@@ -29822,6 +29901,7 @@ var acpSession = sqliteTable("acp_session", {
29822
29901
  nativeSessionId: text("native_session_id").notNull(),
29823
29902
  cwd: text("cwd").notNull(),
29824
29903
  additionalDirectories: text("additional_directories").notNull(),
29904
+ configurations: text("configurations").notNull().default("[]"),
29825
29905
  prompted: integer2("prompted", { mode: "boolean" }).notNull(),
29826
29906
  title: text("title").notNull(),
29827
29907
  updatedAt: text("updated_at").notNull()
@@ -30089,15 +30169,17 @@ var AcpStoredSession = class {
30089
30169
  additionalDirectories;
30090
30170
  agentId;
30091
30171
  cwd;
30172
+ configurations;
30092
30173
  nativeSessionId;
30093
30174
  prompted;
30094
30175
  sessionId;
30095
30176
  title;
30096
30177
  updatedAt;
30097
- constructor(sessionId, agentId, nativeSessionId, cwd, additionalDirectories, prompted, title2, updatedAt = (/* @__PURE__ */ new Date()).toISOString()) {
30178
+ constructor(sessionId, agentId, nativeSessionId, cwd, additionalDirectories, prompted, title2, updatedAt = (/* @__PURE__ */ new Date()).toISOString(), configurations = []) {
30098
30179
  this.additionalDirectories = [...additionalDirectories];
30099
30180
  this.agentId = agentId;
30100
30181
  this.cwd = cwd;
30182
+ this.configurations = configurations.map((configuration) => ({ ...configuration }));
30101
30183
  this.nativeSessionId = nativeSessionId;
30102
30184
  this.prompted = prompted;
30103
30185
  this.sessionId = sessionId;
@@ -30147,6 +30229,7 @@ var MemoryAcpSessionStore = class {
30147
30229
  var storedSessionRowSchema = external_exports.object({
30148
30230
  additionalDirectories: external_exports.string(),
30149
30231
  agentId: external_exports.string(),
30232
+ configurations: external_exports.string(),
30150
30233
  cwd: external_exports.string(),
30151
30234
  nativeSessionId: external_exports.string(),
30152
30235
  prompted: external_exports.boolean(),
@@ -30158,6 +30241,8 @@ function decodeStoredSession(value) {
30158
30241
  const row = storedSessionRowSchema.parse(value);
30159
30242
  const decodedAdditionalDirectories = JSON.parse(row.additionalDirectories);
30160
30243
  const additionalDirectories = external_exports.array(external_exports.string()).parse(decodedAdditionalDirectories);
30244
+ const decodedConfigurations = JSON.parse(row.configurations);
30245
+ const configurations = decodeStoredSessionConfigurations(decodedConfigurations);
30161
30246
  return new AcpStoredSession(
30162
30247
  row.sessionId,
30163
30248
  row.agentId,
@@ -30166,7 +30251,8 @@ function decodeStoredSession(value) {
30166
30251
  additionalDirectories,
30167
30252
  row.prompted,
30168
30253
  row.title,
30169
- row.updatedAt
30254
+ row.updatedAt,
30255
+ configurations
30170
30256
  );
30171
30257
  }
30172
30258
  var SqliteAcpSessionStore = class {
@@ -30199,6 +30285,7 @@ var SqliteAcpSessionStore = class {
30199
30285
  const value = {
30200
30286
  additionalDirectories: JSON.stringify(session.additionalDirectories),
30201
30287
  agentId: session.agentId,
30288
+ configurations: JSON.stringify(session.configurations),
30202
30289
  cwd: session.cwd,
30203
30290
  nativeSessionId: session.nativeSessionId,
30204
30291
  prompted: session.prompted,
@@ -30247,6 +30334,7 @@ var AgentSession = class _AgentSession {
30247
30334
  #commands = [];
30248
30335
  #configRevision = 0;
30249
30336
  #configOptions = [];
30337
+ #sessionConfigurations = new AcpSessionConfigurations();
30250
30338
  #nativeHistoryOwnership = { kind: "unbound" };
30251
30339
  #prompted = false;
30252
30340
  #nativePrompt = null;
@@ -30351,6 +30439,41 @@ var AgentSession = class _AgentSession {
30351
30439
  usesEnvironment = (environment) => recordsEqual(this.#environment, environment);
30352
30440
  canRebind = () => !this.#prompted && !this.#turn.running;
30353
30441
  hasRunningTurn = () => this.#turn.running;
30442
+ #writeStoredSession = () => {
30443
+ this.#store.write(
30444
+ new AcpStoredSession(
30445
+ this.#mobiusSessionId,
30446
+ this.#agentId,
30447
+ this.#updates.sessionId(),
30448
+ this.#cwd,
30449
+ this.#additionalDirectories,
30450
+ this.#prompted,
30451
+ this.#sessionTitle ?? "",
30452
+ (/* @__PURE__ */ new Date()).toISOString(),
30453
+ this.#sessionConfigurations.stored()
30454
+ )
30455
+ );
30456
+ };
30457
+ #captureSelectedConfigurationValues = () => {
30458
+ this.#sessionConfigurations.capture(this.#configOptions);
30459
+ if (this.#updates.sessionId().length > 0) {
30460
+ this.#writeStoredSession();
30461
+ }
30462
+ };
30463
+ #restoreStoredConfigurations = async (session, signal) => {
30464
+ await this.#sessionConfigurations.restore(
30465
+ session.configurations,
30466
+ this.#configOptions,
30467
+ async (selection, signal2) => await this.#applyConfiguration(
30468
+ selection.configId,
30469
+ selection.type === "select" ? selection.value : "",
30470
+ selection.type === "boolean" ? selection.booleanValue : false,
30471
+ selection.type,
30472
+ signal2
30473
+ ),
30474
+ signal
30475
+ );
30476
+ };
30354
30477
  prepared = () => new AcpPreparedSession(
30355
30478
  this.#agentName,
30356
30479
  this.#agentVersion,
@@ -30701,20 +30824,12 @@ var AgentSession = class _AgentSession {
30701
30824
  lifecycleResponse = created;
30702
30825
  }
30703
30826
  this.#configOptions = this.#sessionConfigProtocol.normalizeLifecycle(lifecycleResponse);
30827
+ if (stored instanceof FoundAcpStoredSession && this.#restored) {
30828
+ await this.#restoreStoredConfigurations(stored.session, signal);
30829
+ }
30704
30830
  await this.#updates.drained();
30705
30831
  signal.throwIfAborted();
30706
- this.#store.write(
30707
- new AcpStoredSession(
30708
- this.#mobiusSessionId,
30709
- this.#agentId,
30710
- this.#updates.sessionId(),
30711
- this.#cwd,
30712
- this.#additionalDirectories,
30713
- this.#prompted,
30714
- this.#sessionTitle ?? "",
30715
- (/* @__PURE__ */ new Date()).toISOString()
30716
- )
30717
- );
30832
+ this.#writeStoredSession();
30718
30833
  };
30719
30834
  listNativeSessions = async (cursor, signal) => {
30720
30835
  if (!this.#capabilities.listSessions) {
@@ -30755,15 +30870,17 @@ var AgentSession = class _AgentSession {
30755
30870
  this.#cwd,
30756
30871
  this.#additionalDirectories,
30757
30872
  false,
30758
- ""
30873
+ "",
30874
+ (/* @__PURE__ */ new Date()).toISOString(),
30875
+ this.#sessionConfigurations.stored()
30759
30876
  )
30760
30877
  );
30761
30878
  this.#store.remove(previousSessionId);
30762
30879
  this.#mobiusSessionId = sessionId;
30763
30880
  };
30764
- configure = async (options) => {
30765
- const existing = this.#configOptions.find((option) => option.id === options.configId);
30766
- if (existing === void 0 || existing.type !== options.valueType) {
30881
+ #applyConfiguration = async (configId, value, booleanValue, valueType, signal) => {
30882
+ const existing = this.#configOptions.find((option) => option.id === configId);
30883
+ if (existing === void 0 || existing.type !== valueType) {
30767
30884
  throw new AcpExecutionError(
30768
30885
  "The requested ACP configuration option is unavailable",
30769
30886
  {},
@@ -30778,10 +30895,10 @@ var AgentSession = class _AgentSession {
30778
30895
  "invalid_session_configuration"
30779
30896
  );
30780
30897
  }
30781
- if (!existing.values.some((entry) => entry.value === options.value)) {
30898
+ if (!existing.values.some((entry) => entry.value === value)) {
30782
30899
  throw new AcpConfigurationValueUnavailableError(
30783
- options.configId,
30784
- options.value,
30900
+ configId,
30901
+ value,
30785
30902
  existing.values.map((entry) => entry.value)
30786
30903
  );
30787
30904
  }
@@ -30790,20 +30907,20 @@ var AgentSession = class _AgentSession {
30790
30907
  try {
30791
30908
  const configured = await this.#sessionConfigProtocol.configure(
30792
30909
  this.#configOptions,
30793
- options,
30910
+ { booleanValue, configId, signal, value },
30794
30911
  this.#updates.sessionId(),
30795
30912
  {
30796
- request: async (method, params, failureMessage, signal) => await this.race(
30913
+ request: async (method, params, failureMessage, signal2) => await this.race(
30797
30914
  this.#connection.connection.agent.request(method, params, {
30798
- cancellationSignal: signal
30915
+ cancellationSignal: signal2
30799
30916
  }),
30800
30917
  failureMessage,
30801
- signal
30918
+ signal2
30802
30919
  )
30803
30920
  }
30804
30921
  );
30805
- const applied = configured.find((option) => option.id === options.configId);
30806
- if (applied === void 0 || applied.type !== options.valueType || applied.type === "boolean" && applied.booleanValue !== options.booleanValue || applied.type === "select" && applied.currentValue !== options.value) {
30922
+ const applied = configured.find((option) => option.id === configId);
30923
+ if (applied === void 0 || applied.type !== valueType || applied.type === "boolean" && applied.booleanValue !== booleanValue || applied.type === "select" && applied.currentValue !== value) {
30807
30924
  throw new AcpExecutionError(
30808
30925
  "The Agent did not apply the requested session configuration",
30809
30926
  {},
@@ -30820,6 +30937,21 @@ var AgentSession = class _AgentSession {
30820
30937
  }
30821
30938
  throw error62;
30822
30939
  }
30940
+ };
30941
+ configure = async (options) => {
30942
+ await this.#applyConfiguration(
30943
+ options.configId,
30944
+ options.value,
30945
+ options.booleanValue,
30946
+ options.valueType,
30947
+ options.signal
30948
+ );
30949
+ const applied = this.#configOptions.find((option) => option.id === options.configId);
30950
+ if (applied === void 0) {
30951
+ throw new AcpExecutionError("The requested ACP configuration option is unavailable");
30952
+ }
30953
+ this.#sessionConfigurations.select(applied);
30954
+ this.#writeStoredSession();
30823
30955
  return this.#configOptions;
30824
30956
  };
30825
30957
  buildPrompt = (options) => {
@@ -30894,19 +31026,8 @@ var AgentSession = class _AgentSession {
30894
31026
  if (this.#sessionTitle === null || this.#sessionTitle.length === 0) {
30895
31027
  this.#sessionTitle = truncate2(options.prompt, 500);
30896
31028
  }
30897
- this.#store.write(
30898
- new AcpStoredSession(
30899
- this.#mobiusSessionId,
30900
- this.#agentId,
30901
- this.#updates.sessionId(),
30902
- this.#cwd,
30903
- this.#additionalDirectories,
30904
- true,
30905
- this.#sessionTitle,
30906
- (/* @__PURE__ */ new Date()).toISOString()
30907
- )
30908
- );
30909
31029
  this.#prompted = true;
31030
+ this.#writeStoredSession();
30910
31031
  const running = new RunningAcpTurn(
30911
31032
  options.commandId,
30912
31033
  options.onActivity,
@@ -30977,18 +31098,7 @@ var AgentSession = class _AgentSession {
30977
31098
  usage: result.usage ?? null
30978
31099
  });
30979
31100
  }
30980
- this.#store.write(
30981
- new AcpStoredSession(
30982
- this.#mobiusSessionId,
30983
- this.#agentId,
30984
- this.#updates.sessionId(),
30985
- this.#cwd,
30986
- this.#additionalDirectories,
30987
- true,
30988
- this.#sessionTitle ?? "",
30989
- (/* @__PURE__ */ new Date()).toISOString()
30990
- )
30991
- );
31101
+ this.#writeStoredSession();
30992
31102
  if (lifecycleV2 !== void 0) {
30993
31103
  await this.recordLifecycleEventV2({
30994
31104
  payload: { commandId: options.commandId, kind: "prompt.completed", stopReason: result.stopReason },
@@ -31244,6 +31354,7 @@ var AgentSession = class _AgentSession {
31244
31354
  update.configOptions
31245
31355
  );
31246
31356
  this.#configRevision += 1;
31357
+ this.#captureSelectedConfigurationValues();
31247
31358
  await this.emitConfigUpdate();
31248
31359
  return;
31249
31360
  }
@@ -31252,6 +31363,7 @@ var AgentSession = class _AgentSession {
31252
31363
  (option) => option.category === "mode" ? { ...option, currentValue: update.currentModeId } : option
31253
31364
  );
31254
31365
  this.#configRevision += 1;
31366
+ this.#captureSelectedConfigurationValues();
31255
31367
  await this.emitConfigUpdate();
31256
31368
  return;
31257
31369
  }
@@ -31267,18 +31379,7 @@ var AgentSession = class _AgentSession {
31267
31379
  this.#sessionUpdatedAt = truncate2(update.updatedAt ?? "", 128);
31268
31380
  }
31269
31381
  if (this.#updates.sessionId().length > 0) {
31270
- this.#store.write(
31271
- new AcpStoredSession(
31272
- this.#mobiusSessionId,
31273
- this.#agentId,
31274
- this.#updates.sessionId(),
31275
- this.#cwd,
31276
- this.#additionalDirectories,
31277
- this.#prompted,
31278
- this.#sessionTitle ?? "",
31279
- (/* @__PURE__ */ new Date()).toISOString()
31280
- )
31281
- );
31382
+ this.#writeStoredSession();
31282
31383
  }
31283
31384
  await this.#getObserver().onInfo({
31284
31385
  kind: SESSION_INFO_UPDATED_KIND,
@@ -33844,7 +33945,11 @@ var threadTurnSchema = external_exports.object({
33844
33945
  items: external_exports.array(external_exports.unknown()).max(1e5)
33845
33946
  });
33846
33947
  var threadTurnsSchema = external_exports.array(threadTurnSchema).max(1e5);
33948
+ var collaborationModeSchema = external_exports.object({
33949
+ mode: external_exports.enum(["default", "plan"])
33950
+ });
33847
33951
  var threadLifecycleResponseSchema = external_exports.object({
33952
+ collaborationMode: collaborationModeSchema.nullish(),
33848
33953
  model: boundedText(256).nullish(),
33849
33954
  reasoningEffort: boundedText(256).nullish(),
33850
33955
  serviceTier: boundedText(256).nullish(),
@@ -33889,9 +33994,7 @@ var modelListResponseSchema = external_exports.object({
33889
33994
  var threadSettingsUpdatedSchema = external_exports.object({
33890
33995
  threadId: boundedText(256),
33891
33996
  threadSettings: external_exports.object({
33892
- collaborationMode: external_exports.object({
33893
- mode: external_exports.enum(["default", "plan"])
33894
- }).nullish()
33997
+ collaborationMode: collaborationModeSchema.nullish()
33895
33998
  })
33896
33999
  });
33897
34000
 
@@ -34368,7 +34471,7 @@ var FULL_ACCESS_MODE = Object.freeze({
34368
34471
  sandboxPolicy: { type: "dangerFullAccess" }
34369
34472
  });
34370
34473
  var AGENT_MODES = Object.freeze([READ_ONLY_MODE, AGENT_MODE, FULL_ACCESS_MODE]);
34371
- var DEFAULT_MODE = AGENT_MODE;
34474
+ var DEFAULT_MODE = FULL_ACCESS_MODE;
34372
34475
  function initialMode(environment) {
34373
34476
  const requested = environment["INITIAL_AGENT_MODE"];
34374
34477
  if (requested === void 0) {
@@ -34486,9 +34589,6 @@ function effortSetting(model, currentValue) {
34486
34589
  var CodexSettings = class {
34487
34590
  #appServer;
34488
34591
  #models = [];
34489
- // Whether the current turn must carry a policy at all. Until the user picks a mode, Codex's own
34490
- // configuration decides, so `turn/start` omits the fields and inherits what the host set up.
34491
- #policySelected = false;
34492
34592
  // Whether a collaboration mode choice has been made in this session. A restored thread keeps
34493
34593
  // the mode Codex already persisted, so the first turn does not reset it to Build.
34494
34594
  #collaborationModeSelected = false;
@@ -34528,14 +34628,9 @@ var CodexSettings = class {
34528
34628
  const mode = AGENT_MODES.find((candidate) => candidate.id === selection.mode) ?? DEFAULT_MODE;
34529
34629
  const supportsFast = this.#model(selection.model)?.additionalSpeedTiers?.includes(FAST_TIER) === true;
34530
34630
  return {
34531
- // Until a mode is chosen, `config.toml` decides the sandbox and approval
34532
- // policy, and those fields stay off the turn so the host's own setup is
34533
- // inherited rather than overridden.
34534
- ...this.#policySelected ? {
34535
- approvalPolicy: mode.approvalPolicy,
34536
- approvalsReviewer: mode.approvalsReviewer,
34537
- sandboxPolicy: mode.sandboxPolicy
34538
- } : {},
34631
+ approvalPolicy: mode.approvalPolicy,
34632
+ approvalsReviewer: mode.approvalsReviewer,
34633
+ sandboxPolicy: mode.sandboxPolicy,
34539
34634
  // The collaboration mode rides on the turn: Codex applies it to the
34540
34635
  // thread, where it persists until changed. "Build" is Codex's `default`
34541
34636
  // mode, so it is only sent once a choice exists to apply.
@@ -34628,6 +34723,7 @@ var CodexSettings = class {
34628
34723
  this.#selection = {
34629
34724
  ...this.#selection,
34630
34725
  ...supported,
34726
+ collaborationMode: thread.collaborationMode?.mode ?? this.#selection.collaborationMode,
34631
34727
  fastMode: thread.serviceTier === SERVICE_TIER_FAST
34632
34728
  };
34633
34729
  };
@@ -34667,7 +34763,6 @@ var CodexSettings = class {
34667
34763
  );
34668
34764
  }
34669
34765
  this.#selection = { ...this.#selection, mode: value };
34670
- this.#policySelected = true;
34671
34766
  return;
34672
34767
  }
34673
34768
  if (configId === COLLABORATION_MODE_SETTING_ID) {
@@ -38923,6 +39018,74 @@ var DaemonDiagnosticLog = class {
38923
39018
  this.#path = join18(this.#directory, "daemon.log");
38924
39019
  this.#maximumBytes = maximumBytes;
38925
39020
  }
39021
+ // Export only correlation and failure metadata. Local messages and paths stay local.
39022
+ snapshot = () => {
39023
+ let content;
39024
+ try {
39025
+ content = readFileSync2(this.#path, "utf8");
39026
+ } catch (cause) {
39027
+ if (cause instanceof Error && Reflect.get(cause, "code") === "ENOENT") {
39028
+ return { entries: [], truncated: false };
39029
+ }
39030
+ throw cause;
39031
+ }
39032
+ const lines = content.split("\n").filter((line) => line.length > 0);
39033
+ const entries = [];
39034
+ const fields = [
39035
+ "agentId",
39036
+ "operation",
39037
+ "runtimeId",
39038
+ "closeCode",
39039
+ "timeoutMilliseconds",
39040
+ "proxyRoute",
39041
+ "timestamp",
39042
+ "event",
39043
+ "channelId",
39044
+ "requestId",
39045
+ "commandId",
39046
+ "sessionId",
39047
+ "turnId",
39048
+ "connectionEpoch",
39049
+ "code",
39050
+ "source",
39051
+ "failureName",
39052
+ "failureCode",
39053
+ "failureStatusCode",
39054
+ "cause1Name",
39055
+ "cause1Code",
39056
+ "cause2Name",
39057
+ "cause2Code"
39058
+ ];
39059
+ for (const line of lines.slice(-200)) {
39060
+ const start = line.indexOf("{");
39061
+ if (start < 0) {
39062
+ continue;
39063
+ }
39064
+ let value;
39065
+ try {
39066
+ value = JSON.parse(line.slice(start));
39067
+ } catch {
39068
+ continue;
39069
+ }
39070
+ if (typeof value !== "object" || value === null) {
39071
+ continue;
39072
+ }
39073
+ const entry = {};
39074
+ for (const field of fields) {
39075
+ const item = Reflect.get(value, field);
39076
+ if (typeof item === "string" && /^[a-zA-Z0-9_.: -]{1,256}$/u.test(item)) {
39077
+ entry[field] = item;
39078
+ }
39079
+ }
39080
+ entries.push(entry);
39081
+ }
39082
+ let truncated = lines.length > 200 || Buffer.byteLength(content) >= this.#maximumBytes - 4096;
39083
+ while (JSON.stringify(entries).length > 6e4) {
39084
+ entries.shift();
39085
+ truncated = true;
39086
+ }
39087
+ return { entries, truncated };
39088
+ };
38926
39089
  record = (diagnostic) => {
38927
39090
  const encoded = `${diagnostic.replace(/[\r\n]+/gu, " ").trim()}
38928
39091
  `;
@@ -39858,6 +40021,10 @@ var acpSessionStoreMigrations = [
39858
40021
  {
39859
40022
  "name": "0004_special_mathemanic.sql",
39860
40023
  "sql": "DROP TABLE `deleted_acp_session`;--> statement-breakpoint\nALTER TABLE `acp_session` DROP COLUMN `last_terminal_command_id`;"
40024
+ },
40025
+ {
40026
+ "name": "0005_orange_amphibian.sql",
40027
+ "sql": "ALTER TABLE `acp_session` ADD `configurations` text DEFAULT '[]' NOT NULL;"
39861
40028
  }
39862
40029
  ];
39863
40030
 
@@ -41234,6 +41401,7 @@ var RelayConnectionDiagnostics = class {
41234
41401
  this.#relayOrigin = relayUrl.origin;
41235
41402
  this.#route = describeEnvironmentProxyRoute(relayUrl);
41236
41403
  }
41404
+ snapshot = () => this.#localLog.snapshot();
41237
41405
  catalogFailed = (failure2) => {
41238
41406
  const details = { ...this.#route, relayOrigin: this.#relayOrigin };
41239
41407
  addFailureDetails(details, failure2);
@@ -41305,6 +41473,7 @@ var RelayConnectionDiagnostics = class {
41305
41473
  }
41306
41474
  this.#localLog.record(
41307
41475
  `Mobius daemon diagnostic ${JSON.stringify({
41476
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
41308
41477
  channelId: this.#channelId,
41309
41478
  event,
41310
41479
  requestId,
@@ -41319,7 +41488,12 @@ var RelayConnectionDiagnostics = class {
41319
41488
  event,
41320
41489
  sessionId: this.#channelId
41321
41490
  });
41322
- const encoded = JSON.stringify({ channelId: this.#channelId, event, ...details });
41491
+ const encoded = JSON.stringify({
41492
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
41493
+ channelId: this.#channelId,
41494
+ event,
41495
+ ...details
41496
+ });
41323
41497
  this.#localLog.record(`Mobius relay diagnostic ${encoded}`);
41324
41498
  if (warning) {
41325
41499
  process.stderr.write(`Mobius relay diagnostic ${encoded}
@@ -41337,6 +41511,82 @@ import { WebSocket as WebSocket7 } from "undici";
41337
41511
  // src/daemon-command-handler.ts
41338
41512
  import { WebSocket as WebSocket5 } from "undici";
41339
41513
 
41514
+ // package.json
41515
+ var package_default = {
41516
+ name: "@moxt-ai/mobius",
41517
+ version: "0.0.192",
41518
+ description: "Mobius CLI for pairing and running local AI agent services.",
41519
+ type: "module",
41520
+ bin: {
41521
+ mobius: "dist/cli.js"
41522
+ },
41523
+ types: "./src/index.ts",
41524
+ exports: {
41525
+ ".": "./src/index.ts",
41526
+ "./runtime": "./src/runtime.ts"
41527
+ },
41528
+ files: [
41529
+ "dist"
41530
+ ],
41531
+ engines: {
41532
+ node: ">=22.13.0"
41533
+ },
41534
+ publishConfig: {
41535
+ access: "public",
41536
+ types: "./dist/index.d.ts",
41537
+ exports: {
41538
+ ".": {
41539
+ types: "./dist/index.d.ts",
41540
+ import: "./dist/index.js"
41541
+ },
41542
+ "./runtime": {
41543
+ types: "./dist/runtime.d.ts",
41544
+ import: "./dist/runtime.js"
41545
+ }
41546
+ }
41547
+ },
41548
+ repository: {
41549
+ type: "git",
41550
+ url: "git+https://github.com/moxt-ai/mobius.git",
41551
+ directory: "packages/cli"
41552
+ },
41553
+ scripts: {
41554
+ 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",
41555
+ dev: "node --watch src/cli.ts",
41556
+ prepack: "pnpm build",
41557
+ start: "node dist/cli.js",
41558
+ typecheck: "tsc --project tsconfig.json && tsc --project tests/tsconfig.json",
41559
+ "test:controlled": "vitest run tests/sessions tests/runtime --maxWorkers=4",
41560
+ "test:agents": "vitest run tests/agents --maxWorkers=2"
41561
+ },
41562
+ dependencies: {
41563
+ "@agentclientprotocol/sdk": "^1.4.0",
41564
+ commander: "15.0.0",
41565
+ undici: "8.10.2",
41566
+ zod: "^4.6.5"
41567
+ },
41568
+ devDependencies: {
41569
+ "@moxt-ai/mobius-protocol": "workspace:*",
41570
+ "@types/node": "^24.13.5",
41571
+ "drizzle-kit": "1.0.0-rc.4",
41572
+ "drizzle-orm": "1.0.0-rc.4",
41573
+ esbuild: "0.28.2",
41574
+ "@moxt-ai/mobius-sdk": "workspace:*",
41575
+ "@moxt-ai/mobius-test": "workspace:*",
41576
+ valibot: "1.5.0",
41577
+ ws: "^8.21.3",
41578
+ "@types/ws": "^8.18.1"
41579
+ },
41580
+ main: "dist/index.js",
41581
+ keywords: [],
41582
+ author: "",
41583
+ license: "ISC",
41584
+ bugs: {
41585
+ url: "https://github.com/moxt-ai/mobius/issues"
41586
+ },
41587
+ homepage: "https://github.com/moxt-ai/mobius#readme"
41588
+ };
41589
+
41340
41590
  // src/agent-catalog/handle-agent-settings-discovery.ts
41341
41591
  import { WebSocket as WebSocket3 } from "undici";
41342
41592
 
@@ -41957,7 +42207,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
41957
42207
  // src/artifacts/local-file-streamer.ts
41958
42208
  import { createReadStream as createReadStream2 } from "node:fs";
41959
42209
  import { realpath as realpath10, stat as stat9 } from "node:fs/promises";
41960
- import { basename as basename5, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve7 } from "node:path";
42210
+ import { basename as basename5, extname, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve7 } from "node:path";
41961
42211
  import { fileURLToPath as fileURLToPath2 } from "node:url";
41962
42212
  var CHUNK_BYTES = 192 * 1024;
41963
42213
  function requestedPath(value) {
@@ -42007,7 +42257,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
42007
42257
  send2({
42008
42258
  byteLength: before.size,
42009
42259
  kind: FILE_BEGIN_KIND,
42010
- mediaType: external?.mediaType ?? raster?.mimeType ?? "application/octet-stream",
42260
+ mediaType: external?.mediaType ?? raster?.mimeType ?? (extname(target).toLowerCase() === ".svg" ? "image/svg+xml" : "application/octet-stream"),
42011
42261
  modifiedAt: before.mtime.toISOString(),
42012
42262
  name: external?.name ?? (basename5(target) || "file"),
42013
42263
  requestId: command.requestId,
@@ -42071,18 +42321,24 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
42071
42321
  }
42072
42322
 
42073
42323
  // src/daemon-history-commands.ts
42074
- async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventLogV2, signal) {
42324
+ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, nativeSessions, eventLogV2, signal) {
42325
+ let agentId;
42075
42326
  try {
42327
+ const [entry] = await nativeSessions.querySessions([command.sessionId], signal);
42328
+ if (entry === void 0) {
42329
+ throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
42330
+ }
42331
+ agentId = entry.agentId;
42076
42332
  const resolved = await resolveSessionDirectories(
42077
42333
  directories,
42078
42334
  config2.bindingId,
42079
- command.directoryId,
42080
- command.additionalDirectoryIds,
42335
+ entry.directoryId,
42336
+ entry.additionalDirectories.map((directory) => directory.directoryId),
42081
42337
  signal
42082
42338
  );
42083
42339
  const loadOptions = {
42084
42340
  additionalDirectories: resolved.additionalDirectories,
42085
- agent: config2.catalog.find(command.agentId),
42341
+ agent: config2.catalog.find(entry.agentId),
42086
42342
  cwd: resolved.cwd,
42087
42343
  sessionId: command.sessionId,
42088
42344
  signal
@@ -42127,7 +42383,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
42127
42383
  "session_history_v2_load_failed",
42128
42384
  command.requestId,
42129
42385
  {
42130
- agentId: command.agentId,
42386
+ ...agentId === void 0 ? {} : { agentId },
42131
42387
  code: operationErrorCode(error62),
42132
42388
  sessionId: command.sessionId
42133
42389
  },
@@ -42136,7 +42392,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
42136
42392
  audit.record({
42137
42393
  commandId: command.requestId,
42138
42394
  details: {
42139
- agentId: command.agentId,
42395
+ ...agentId === void 0 ? {} : { agentId },
42140
42396
  code: operationErrorCode(error62)
42141
42397
  },
42142
42398
  event: "session_history_v2_load_failed",
@@ -42952,6 +43208,37 @@ function createDaemonCommandHandler({
42952
43208
  return {
42953
43209
  handle: (message) => {
42954
43210
  const kind = message.kind;
43211
+ if (kind === "runtime.diagnostics.read") {
43212
+ audit.record({
43213
+ event: "runtime_diagnostics_read",
43214
+ commandId: message.requestId,
43215
+ sessionId: "runtime",
43216
+ details: {}
43217
+ });
43218
+ try {
43219
+ send(socket, {
43220
+ kind: "runtime.diagnostics.result",
43221
+ requestId: message.requestId,
43222
+ version: package_default.version,
43223
+ ...diagnostics.snapshot()
43224
+ });
43225
+ } catch {
43226
+ audit.record({
43227
+ event: "runtime_diagnostics_failed",
43228
+ commandId: message.requestId,
43229
+ sessionId: "runtime",
43230
+ details: { code: "diagnostics_unavailable" }
43231
+ });
43232
+ send(socket, {
43233
+ kind: "session.operation.failed",
43234
+ requestId: message.requestId,
43235
+ sessionId: "runtime",
43236
+ code: "diagnostics_unavailable",
43237
+ message: "Local diagnostics are unavailable."
43238
+ });
43239
+ }
43240
+ return;
43241
+ }
42955
43242
  if (kind === RUNTIME_PING_KIND) {
42956
43243
  send(socket, { kind: RUNTIME_PONG_KIND, requestId: message.requestId });
42957
43244
  return;
@@ -42965,6 +43252,7 @@ function createDaemonCommandHandler({
42965
43252
  audit,
42966
43253
  diagnostics,
42967
43254
  sessions,
43255
+ nativeSessions,
42968
43256
  eventLogV2,
42969
43257
  signal
42970
43258
  );