@moxt-ai/mobius 0.0.380 → 0.0.381

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 (88) hide show
  1. package/dist/{chunk-7HMKMNG4.js → chunk-HJN27I4Y.js} +99 -107
  2. package/dist/{chunk-7HMKMNG4.js.map → chunk-HJN27I4Y.js.map} +4 -4
  3. package/dist/{chunk-ZY3EYZYU.js → chunk-ICRGF5ZU.js} +2 -2
  4. package/dist/{chunk-ZY3EYZYU.js.map → chunk-ICRGF5ZU.js.map} +1 -1
  5. package/dist/{chunk-VQT2JYQE.js → chunk-VKU6W3IQ.js} +2 -2
  6. package/dist/cli/handler/version/index.d.ts.map +1 -1
  7. package/dist/cli/handler/version/index.js +0 -6
  8. package/dist/cli/handler/version/index.js.map +1 -1
  9. package/dist/{cli-QH5RSLX3.js → cli-BI5CRENK.js} +34 -71
  10. package/dist/cli-BI5CRENK.js.map +7 -0
  11. package/dist/cli.js +3 -3
  12. package/dist/daemon/lifecycle/manager-client.d.ts.map +1 -1
  13. package/dist/daemon/lifecycle/manager-client.js +1 -4
  14. package/dist/daemon/lifecycle/manager-client.js.map +1 -1
  15. package/dist/daemon/lifecycle/worker.js +2 -2
  16. package/dist/daemon/lifecycle/worker.js.map +1 -1
  17. package/dist/daemon/upgrades/data.d.ts +1 -3
  18. package/dist/daemon/upgrades/data.d.ts.map +1 -1
  19. package/dist/daemon/upgrades/data.js +11 -30
  20. package/dist/daemon/upgrades/data.js.map +1 -1
  21. package/dist/engine/acp/harness/codex/app-server-protocol.d.ts +3 -0
  22. package/dist/engine/acp/harness/codex/app-server-protocol.d.ts.map +1 -1
  23. package/dist/engine/acp/harness/codex/app-server-protocol.js +1 -0
  24. package/dist/engine/acp/harness/codex/app-server-protocol.js.map +1 -1
  25. package/dist/engine/acp/harness/codex/borrowed-agent.d.ts.map +1 -1
  26. package/dist/engine/acp/harness/codex/borrowed-agent.js +26 -4
  27. package/dist/engine/acp/harness/codex/borrowed-agent.js.map +1 -1
  28. package/dist/engine/generated/acp-session-store-migrations.d.ts +6 -0
  29. package/dist/engine/generated/acp-session-store-migrations.d.ts.map +1 -1
  30. package/dist/engine/generated/acp-session-store-migrations.js +9 -1
  31. package/dist/engine/generated/acp-session-store-migrations.js.map +1 -1
  32. package/dist/engine/runtime/catalog/publish-agent-catalog.d.ts.map +1 -1
  33. package/dist/engine/runtime/catalog/publish-agent-catalog.js +0 -2
  34. package/dist/engine/runtime/catalog/publish-agent-catalog.js.map +1 -1
  35. package/dist/engine/runtime/command/registry/session.d.ts.map +1 -1
  36. package/dist/engine/runtime/command/registry/session.js +2 -3
  37. package/dist/engine/runtime/command/registry/session.js.map +1 -1
  38. package/dist/engine/runtime/connection/runtime-installation-store.d.ts.map +1 -1
  39. package/dist/engine/runtime/connection/runtime-installation-store.js +1 -9
  40. package/dist/engine/runtime/connection/runtime-installation-store.js.map +1 -1
  41. package/dist/engine/runtime/pairing.d.ts.map +1 -1
  42. package/dist/engine/runtime/pairing.js +0 -2
  43. package/dist/engine/runtime/pairing.js.map +1 -1
  44. package/dist/engine/runtime/relay/liveness.js +5 -5
  45. package/dist/engine/runtime/relay/liveness.js.map +1 -1
  46. package/dist/engine/runtime/relay/run-relay-connection.d.ts.map +1 -1
  47. package/dist/engine/runtime/relay/run-relay-connection.js +0 -1
  48. package/dist/engine/runtime/relay/run-relay-connection.js.map +1 -1
  49. package/dist/engine/schema/acp-session-store/execution-receipt.d.ts +1 -17
  50. package/dist/engine/schema/acp-session-store/execution-receipt.d.ts.map +1 -1
  51. package/dist/engine/schema/acp-session-store/execution-receipt.js +1 -4
  52. package/dist/engine/schema/acp-session-store/execution-receipt.js.map +1 -1
  53. package/dist/engine/session/api/session-api.d.ts +2 -1
  54. package/dist/engine/session/api/session-api.d.ts.map +1 -1
  55. package/dist/engine/session/api/session-api.js.map +1 -1
  56. package/dist/engine/session/live/agent-session.js +2 -2
  57. package/dist/engine/session/live/agent-session.js.map +1 -1
  58. package/dist/engine/session/manager/session-manager.d.ts.map +1 -1
  59. package/dist/engine/session/manager/session-manager.js +3 -0
  60. package/dist/engine/session/manager/session-manager.js.map +1 -1
  61. package/dist/engine/session/native/native-session-browser.d.ts.map +1 -1
  62. package/dist/engine/session/native/native-session-browser.js +1 -0
  63. package/dist/engine/session/native/native-session-browser.js.map +1 -1
  64. package/dist/engine/session/prompt/apply-session-configuration.d.ts.map +1 -1
  65. package/dist/engine/session/prompt/apply-session-configuration.js +1 -0
  66. package/dist/engine/session/prompt/apply-session-configuration.js.map +1 -1
  67. package/dist/engine/storage/session/execution-receipt-table.d.ts.map +1 -1
  68. package/dist/engine/storage/session/execution-receipt-table.js +8 -43
  69. package/dist/engine/storage/session/execution-receipt-table.js.map +1 -1
  70. package/dist/engine/storage/sqlite/local-databases.d.ts.map +1 -1
  71. package/dist/engine/storage/sqlite/local-databases.js +27 -5
  72. package/dist/engine/storage/sqlite/local-databases.js.map +1 -1
  73. package/dist/engine/storage/sqlite/local-sqlite-database.d.ts +0 -5
  74. package/dist/engine/storage/sqlite/local-sqlite-database.d.ts.map +1 -1
  75. package/dist/engine/storage/sqlite/local-sqlite-database.js +0 -9
  76. package/dist/engine/storage/sqlite/local-sqlite-database.js.map +1 -1
  77. package/dist/engine.js +2 -2
  78. package/dist/storage/daemon/version-data.d.ts +2 -6
  79. package/dist/storage/daemon/version-data.d.ts.map +1 -1
  80. package/dist/storage/daemon/version-data.js +4 -26
  81. package/dist/storage/daemon/version-data.js.map +1 -1
  82. package/dist/storage/state-root-layout.d.ts +1 -5
  83. package/dist/storage/state-root-layout.d.ts.map +1 -1
  84. package/dist/storage/state-root-layout.js +1 -5
  85. package/dist/storage/state-root-layout.js.map +1 -1
  86. package/package.json +2 -2
  87. package/dist/cli-QH5RSLX3.js.map +0 -7
  88. /package/dist/{chunk-VQT2JYQE.js.map → chunk-VKU6W3IQ.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  __export,
4
4
  __using,
5
5
  package_default
6
- } from "./chunk-ZY3EYZYU.js";
6
+ } from "./chunk-ICRGF5ZU.js";
7
7
 
8
8
  // src/engine/runtime/relay/runtime-revocation.ts
9
9
  var runtimeRevocationCloseCode = 1008;
@@ -20262,8 +20262,7 @@ var sessionConfigureCommandSchema = external_exports.object({
20262
20262
  ...sessionIdentityFields,
20263
20263
  booleanValue: external_exports.boolean(),
20264
20264
  configId: external_exports.string().min(1).max(128),
20265
- // Omitted by legacy clients: explicit edits retain last-write-wins behavior.
20266
- expectedConfigurationRevision: identifierStringSchema.optional(),
20265
+ expectedConfigurationRevision: identifierStringSchema,
20267
20266
  kind: external_exports.literal(SESSION_CONFIGURE_KIND),
20268
20267
  requestId: identifierStringSchema,
20269
20268
  value: external_exports.string().max(500),
@@ -20271,8 +20270,8 @@ var sessionConfigureCommandSchema = external_exports.object({
20271
20270
  }).readonly();
20272
20271
  var sessionConfigUpdatedEventSchema = external_exports.object({
20273
20272
  configOptions: sessionConfigOptionsSchema,
20274
- // An opaque Runtime generation token; absent on older Runtimes.
20275
- configurationRevision: identifierStringSchema.optional(),
20273
+ // An opaque Runtime generation token.
20274
+ configurationRevision: identifierStringSchema,
20276
20275
  kind: external_exports.literal(SESSION_CONFIG_UPDATED_KIND),
20277
20276
  requestId: identifierStringSchema,
20278
20277
  sessionId: identifierStringSchema
@@ -20291,8 +20290,8 @@ var sessionConfigReadCommandSchema = external_exports.object({
20291
20290
  }).readonly();
20292
20291
  var sessionConfigReadResultSchema = external_exports.object({
20293
20292
  configOptions: sessionConfigOptionsSchema,
20294
- // An opaque Runtime generation token; absent on older Runtimes.
20295
- configurationRevision: identifierStringSchema.optional(),
20293
+ // An opaque Runtime generation token.
20294
+ configurationRevision: identifierStringSchema,
20296
20295
  kind: external_exports.literal(SESSION_CONFIG_READ_RESULT_KIND),
20297
20296
  requestId: identifierStringSchema,
20298
20297
  sessionId: identifierStringSchema
@@ -20826,8 +20825,8 @@ var sessionEventLogPageSchema = external_exports.object({
20826
20825
  sessionGenerationId: identifierStringSchema,
20827
20826
  tailCursor: external_exports.string().max(512),
20828
20827
  // The generation-scoped live position covered by this snapshot, including
20829
- // coalesced and omitted events. Absent only on older Runtime versions.
20830
- throughPosition: positionSchema.optional(),
20828
+ // coalesced and omitted events.
20829
+ throughPosition: positionSchema,
20831
20830
  truncated: external_exports.boolean(),
20832
20831
  version: external_exports.literal(2)
20833
20832
  }).readonly();
@@ -21139,7 +21138,7 @@ var sessionReadyEventSchema = external_exports.object({
21139
21138
  capabilities: sessionCapabilitiesSchema,
21140
21139
  commands: external_exports.array(sessionCommandSchema).max(500).readonly(),
21141
21140
  configOptions: sessionConfigOptionsSchema,
21142
- configurationRevision: identifierStringSchema.optional(),
21141
+ configurationRevision: identifierStringSchema,
21143
21142
  directoryId: DIRECTORY_IDENTIFIER,
21144
21143
  directoryLabel: external_exports.string().min(1).max(MAX_WORKSPACE_PATH_LENGTH),
21145
21144
  kind: external_exports.literal(SESSION_READY_KIND),
@@ -21266,7 +21265,7 @@ function decodeSessionPromptCommand(encoded) {
21266
21265
  const hasSessionConfigurations = Object.hasOwn(value, "sessionConfigurations");
21267
21266
  assertKind(value, SESSION_PROMPT_KIND);
21268
21267
  const prompt = readText(value, "prompt", MAX_PROMPT_LENGTH);
21269
- const attachments = !Object.hasOwn(value, "attachments") && Array.isArray(value["images"]) && Array.isArray(value["resources"]) ? [] : decodePromptAttachmentsValue(value["attachments"]);
21268
+ const attachments = decodePromptAttachmentsValue(value["attachments"]);
21270
21269
  const attachmentBytes = attachments.reduce((total, attachment) => total + attachment.byteLength, 0);
21271
21270
  if (attachmentBytes > MAX_PROMPT_ATTACHMENT_BYTES) {
21272
21271
  throw new ProtocolMessageError("Prompt attachments are too large");
@@ -21332,15 +21331,7 @@ function decodeSessionPromptDispositionCommand(encoded) {
21332
21331
  };
21333
21332
  }
21334
21333
  function encodeSessionPromptCommand(message) {
21335
- const command = decodeSessionPromptCommand(JSON.stringify(message));
21336
- return JSON.stringify({
21337
- ...command,
21338
- // Keep text prompts compatible with the previous Runtime release while
21339
- // attachments move to the content-key protocol. Older Runtimes ignore
21340
- // `attachments` and require both legacy arrays to be present.
21341
- images: [],
21342
- resources: []
21343
- });
21334
+ return JSON.stringify(decodeSessionPromptCommand(JSON.stringify(message)));
21344
21335
  }
21345
21336
  function encodeSessionCancelCommand(message) {
21346
21337
  return JSON.stringify(decodeSessionCancelCommand(JSON.stringify(message)));
@@ -21467,8 +21458,8 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
21467
21458
  command: commandDeliverySchema.optional().catch(void 0),
21468
21459
  // Absent from older Runtimes and while the last started command is still running.
21469
21460
  lastTurn: lastTurnOutcomeSchema.optional().catch(void 0),
21470
- // Runtime-owned support; older Relays strip this field before exposing the snapshot.
21471
- queuedCancellation: external_exports.literal("before-start").optional().catch(void 0)
21461
+ // The Runtime withdraws a queued command only before it starts.
21462
+ queuedCancellation: external_exports.literal("before-start")
21472
21463
  }).readonly(),
21473
21464
  external_exports.object({
21474
21465
  ...resultEnvelope,
@@ -21539,7 +21530,7 @@ var wireNativeSessionEventsSchema = external_exports.object({
21539
21530
  nextCursor: external_exports.string().min(1).max(512).nullable(),
21540
21531
  sessionGenerationId: identifierStringSchema,
21541
21532
  tailCursor: external_exports.string().max(512),
21542
- throughPosition: external_exports.string().regex(/^(0|[1-9][0-9]*)$/u).optional(),
21533
+ throughPosition: external_exports.string().regex(/^(0|[1-9][0-9]*)$/u),
21543
21534
  truncated: external_exports.boolean(),
21544
21535
  version: external_exports.literal(2)
21545
21536
  }).passthrough().readonly(),
@@ -22724,11 +22715,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
22724
22715
  connection.runtimeCredential,
22725
22716
  connection.runtimeId
22726
22717
  );
22727
- if (isRecord3(record2) && record2["version"] === 5) {
22728
- await writeJsonAtomically(this.connectionPath(connectionId2), { ...record2, activation }, signal);
22729
- } else {
22730
- await this.overwriteConnection(updated, signal);
22731
- }
22718
+ await this.overwriteConnection(updated, signal);
22732
22719
  return updated;
22733
22720
  };
22734
22721
  removeConnection = async (connectionId2, signal) => {
@@ -68444,6 +68431,7 @@ var threadStartResponseSchema = external_exports.object({
68444
68431
  var threadTurnSchema = external_exports.object({
68445
68432
  id: boundedText(256).optional(),
68446
68433
  status: turnStatusSchema.optional(),
68434
+ completedAt: external_exports.number().nullish(),
68447
68435
  error: external_exports.object({ message: external_exports.string().transform((message) => message.slice(0, 4096)) }).nullish(),
68448
68436
  items: external_exports.array(external_exports.unknown()).max(1e5)
68449
68437
  });
@@ -68751,7 +68739,19 @@ var CodexAppServerClient = class {
68751
68739
 
68752
68740
  // src/engine/acp/harness/codex/borrowed-agent.ts
68753
68741
  import { randomUUID as randomUUID7 } from "node:crypto";
68754
- import { setTimeout as setTimeout2 } from "node:timers/promises";
68742
+
68743
+ // src/engine/util/timer.ts
68744
+ var SystemTimer = class {
68745
+ schedule = (callback, milliseconds) => {
68746
+ const timeout = setTimeout(callback, milliseconds);
68747
+ return {
68748
+ cancel: () => {
68749
+ clearTimeout(timeout);
68750
+ }
68751
+ };
68752
+ };
68753
+ };
68754
+ var systemTimer = new SystemTimer();
68755
68755
 
68756
68756
  // src/engine/acp/harness/codex/items.ts
68757
68757
  import { pathToFileURL } from "node:url";
@@ -69039,6 +69039,23 @@ var queuePageSchema = external_exports.object({
69039
69039
  data: external_exports.array(external_exports.object({ id: external_exports.string().min(1), clientUserMessageId: external_exports.string().min(1) })).max(100),
69040
69040
  nextCursor: external_exports.string().nullish()
69041
69041
  });
69042
+ function turnRunning(turn) {
69043
+ return turn.status === "inProgress" || turn.status === "interrupted" && turn.completedAt == null;
69044
+ }
69045
+ function waitForNextPoll(timer, signal) {
69046
+ signal.throwIfAborted();
69047
+ return new Promise((resolve19, reject2) => {
69048
+ const poll = timer.schedule(() => {
69049
+ signal.removeEventListener("abort", abort);
69050
+ resolve19();
69051
+ }, POLL_INTERVAL);
69052
+ const abort = () => {
69053
+ poll.cancel();
69054
+ reject2(signal.reason);
69055
+ };
69056
+ signal.addEventListener("abort", abort, { once: true });
69057
+ });
69058
+ }
69042
69059
  var CodexBorrowedAcpAgent = class {
69043
69060
  steeringSupported = false;
69044
69061
  #client;
@@ -69069,7 +69086,7 @@ var CodexBorrowedAcpAgent = class {
69069
69086
  const signal = this.#closed.signal;
69070
69087
  try {
69071
69088
  for (; ; ) {
69072
- await setTimeout2(POLL_INTERVAL, void 0, { signal });
69089
+ await waitForNextPoll(systemTimer, signal);
69073
69090
  await this.#refresh(signal, false);
69074
69091
  }
69075
69092
  } catch (cause) {
@@ -69140,7 +69157,7 @@ var CodexBorrowedAcpAgent = class {
69140
69157
  this.#seen.set(key, text2);
69141
69158
  continue;
69142
69159
  }
69143
- if (item.type === "plan" && turn.status === "inProgress") {
69160
+ if (item.type === "plan" && turnRunning(turn)) {
69144
69161
  continue;
69145
69162
  }
69146
69163
  const previous = this.#seen.get(key);
@@ -69169,7 +69186,7 @@ var CodexBorrowedAcpAgent = class {
69169
69186
  }
69170
69187
  }
69171
69188
  }
69172
- if (matches && turn.status !== void 0 && turn.status !== "inProgress") {
69189
+ if (matches && turn.status !== void 0 && !turnRunning(turn)) {
69173
69190
  if (turn.status === "failed") {
69174
69191
  this.#pending?.completion.reject(
69175
69192
  new AcpExecutionError("The owning Codex turn failed", {}, "codex_turn_failed")
@@ -78181,7 +78198,9 @@ import { join as join23 } from "node:path";
78181
78198
 
78182
78199
  // src/engine/storage/sqlite/local-databases.ts
78183
78200
  import { createHash as createHash4 } from "node:crypto";
78201
+ import { existsSync as existsSync9 } from "node:fs";
78184
78202
  import { join as join22 } from "node:path";
78203
+ import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
78185
78204
 
78186
78205
  // src/engine/generated/acp-session-store-migrations.ts
78187
78206
  var acpSessionStoreMigrations = [
@@ -78224,6 +78243,14 @@ var acpSessionStoreMigrations = [
78224
78243
  {
78225
78244
  "name": "0009_receipt_admission_order.sql",
78226
78245
  "sql": "ALTER TABLE `execution_receipt` ADD `admission_order` integer;"
78246
+ },
78247
+ {
78248
+ "name": "0010_receipt_admission_order_backfill.sql",
78249
+ "sql": "-- Receipts written before admission order existed are ordered by their last update, after every ordered receipt.\nUPDATE `execution_receipt` SET `admission_order` = `ordered`.`admission_order`\nFROM (\n SELECT\n `command_id`,\n (SELECT coalesce(max(`admission_order`), 0) FROM `execution_receipt`)\n + row_number() OVER (ORDER BY `updated_at`, `command_id`) AS `admission_order`\n FROM `execution_receipt`\n WHERE `admission_order` IS NULL\n) AS `ordered`\nWHERE `execution_receipt`.`command_id` = `ordered`.`command_id`;\n"
78250
+ },
78251
+ {
78252
+ "name": "0011_receipt_admission_order_required.sql",
78253
+ "sql": 'PRAGMA foreign_keys=OFF;--> statement-breakpoint\nCREATE TABLE `__new_execution_receipt` (\n `command_id` text PRIMARY KEY NOT NULL,\n `session_id` text NOT NULL,\n `command_hash` text NOT NULL,\n `attempt_id` text NOT NULL,\n `admission_order` integer NOT NULL,\n `started` integer NOT NULL,\n `outcome` text,\n `updated_at` text NOT NULL\n);\n--> statement-breakpoint\nINSERT INTO `__new_execution_receipt`("command_id", "session_id", "command_hash", "attempt_id", "admission_order", "started", "outcome", "updated_at") SELECT "command_id", "session_id", "command_hash", "attempt_id", "admission_order", "started", "outcome", "updated_at" FROM `execution_receipt`;--> statement-breakpoint\nDROP TABLE `execution_receipt`;--> statement-breakpoint\nALTER TABLE `__new_execution_receipt` RENAME TO `execution_receipt`;--> statement-breakpoint\nPRAGMA foreign_keys=ON;'
78227
78254
  }
78228
78255
  ];
78229
78256
 
@@ -83136,13 +83163,6 @@ var LocalSqliteDatabase = class {
83136
83163
  throw new Error(`The ${label} migration is unavailable`);
83137
83164
  }
83138
83165
  this.transaction(() => {
83139
- if (migration.compatibleColumn !== void 0) {
83140
- const { table, column } = migration.compatibleColumn;
83141
- if (this.#sqlite.prepare("SELECT name FROM pragma_table_info(?) WHERE name = ?").get(table, column) === void 0) {
83142
- this.#sqlite.exec(migration.sql);
83143
- }
83144
- return;
83145
- }
83146
83166
  this.#sqlite.exec(migration.sql);
83147
83167
  this.#sqlite.exec(`PRAGMA user_version = ${index2 + 1}`);
83148
83168
  });
@@ -83177,16 +83197,25 @@ function channelSessionDatabasePaths(stateDirectory, channelId) {
83177
83197
  sessions: join22(stateDirectory, "sessions", `${channelHash}.sqlite`)
83178
83198
  };
83179
83199
  }
83180
- var openAcpSessionDatabase = (path7) => new LocalSqliteDatabase(
83181
- path7,
83182
- "ACP Session database",
83183
- acpSessionStoreMigrations.map(
83184
- (migration) => migration.name === "0009_receipt_admission_order.sql" ? {
83185
- ...migration,
83186
- compatibleColumn: { table: "execution_receipt", column: "admission_order" }
83187
- } : migration
83188
- )
83189
- );
83200
+ function recordAppliedAdmissionOrder(path7) {
83201
+ if (!existsSync9(path7)) {
83202
+ return;
83203
+ }
83204
+ const database = new DatabaseSync3(path7);
83205
+ try {
83206
+ const version2 = database.prepare("PRAGMA user_version").get()?.["user_version"];
83207
+ const column = database.prepare("SELECT name FROM pragma_table_info('execution_receipt') WHERE name = 'admission_order'").get();
83208
+ if (version2 === 9 && column !== void 0) {
83209
+ database.exec("PRAGMA user_version = 10");
83210
+ }
83211
+ } finally {
83212
+ database.close();
83213
+ }
83214
+ }
83215
+ var openAcpSessionDatabase = (path7) => {
83216
+ recordAppliedAdmissionOrder(path7);
83217
+ return new LocalSqliteDatabase(path7, "ACP Session database", acpSessionStoreMigrations);
83218
+ };
83190
83219
  var openSessionEventCacheDatabase = (path7) => new LocalSqliteDatabase(path7, "V2 Session event cache", sessionEventCacheMigrations, [
83191
83220
  "PRAGMA journal_mode = WAL",
83192
83221
  "PRAGMA synchronous = OFF",
@@ -84463,11 +84492,9 @@ async function publishAgentCatalog(config2, signal) {
84463
84492
  agents: catalog.agents.map((agent) => ({
84464
84493
  agentPath: agent.agentIdentity.requestedPath,
84465
84494
  agentVersion: agent.agentVersion,
84466
- agentSettingsDiscovery: true,
84467
84495
  capabilities: agent.capabilities,
84468
84496
  id: agent.id,
84469
- label: agent.label,
84470
- sessionTurnConfiguration: true
84497
+ label: agent.label
84471
84498
  }))
84472
84499
  }),
84473
84500
  dispatcher: environmentProxyDispatcher,
@@ -84781,11 +84808,9 @@ async function claimPairing(options, defaultWorkspace, localAgents, signal) {
84781
84808
  const agents = localAgents.map((agent) => ({
84782
84809
  agentPath: agent.agentIdentity.requestedPath,
84783
84810
  agentVersion: agent.agentVersion,
84784
- agentSettingsDiscovery: true,
84785
84811
  capabilities: agent.capabilities,
84786
84812
  id: agent.id,
84787
- label: agent.label,
84788
- sessionTurnConfiguration: true
84813
+ label: agent.label
84789
84814
  }));
84790
84815
  const endpoint = options.pairingId.length > 0 ? mobiusApiUrl(options.relayOrigin, `/v1/runtime-pairings/${encodeURIComponent(options.pairingId)}/redeem`) : mobiusApiUrl(options.relayOrigin, "/pairings/claim");
84791
84816
  let response;
@@ -84934,10 +84959,7 @@ var executionReceipt = sqliteTable("execution_receipt", {
84934
84959
  sessionId: text("session_id").notNull(),
84935
84960
  commandHash: text("command_hash").notNull(),
84936
84961
  attemptId: text("attempt_id").notNull(),
84937
- // Nullable only for receipts written by older Runtimes; assigned before recovery.
84938
- admissionOrder: integer2("admission_order"),
84939
- // Compatibility projection for older Runtimes; started and outcome own the facts.
84940
- state: text("state").notNull(),
84962
+ admissionOrder: integer2("admission_order").notNull(),
84941
84963
  started: integer2("started", { mode: "boolean" }).notNull(),
84942
84964
  outcome: text("outcome"),
84943
84965
  updatedAt: text("updated_at").notNull()
@@ -84996,16 +85018,6 @@ var receiptSchema = external_exports.object({
84996
85018
  outcome: external_exports.string().nullable()
84997
85019
  }).readonly();
84998
85020
  var identitySchema = external_exports.object({ sessionId: external_exports.string(), commandHash: external_exports.string() }).readonly();
84999
- function legacyState(receipt) {
85000
- if (receipt.outcome === null) {
85001
- return receipt.started ? "running" : "dispatching";
85002
- }
85003
- const event = decodeKnownSessionEventPayload(JSON.parse(receipt.outcome));
85004
- if (event === null) {
85005
- return "failed";
85006
- }
85007
- return event.type === "lifecycle-metadata" && event.payload.kind === "prompt.completed" ? event.payload.stopReason === "cancelled" ? "cancelled" : "succeeded" : "failed";
85008
- }
85009
85021
  var ExecutionReceiptTable = class {
85010
85022
  #database;
85011
85023
  constructor(database) {
@@ -85015,21 +85027,9 @@ var ExecutionReceiptTable = class {
85015
85027
  const row = this.#database.orm.select({ sessionId: executionIdentity.sessionId, commandHash: executionIdentity.commandHash }).from(executionIdentity).where(eq2(executionIdentity.commandId, commandId)).get();
85016
85028
  return row === void 0 ? void 0 : identitySchema.parse(row);
85017
85029
  };
85018
- list = () => this.#database.transaction(() => {
85019
- const rows = this.#database.orm.select().from(executionReceipt).orderBy(asc(executionReceipt.updatedAt), asc(executionReceipt.commandId)).all();
85020
- let latestOrder = rows.reduce((latest, row) => Math.max(latest, row.admissionOrder ?? 0), 0);
85021
- return rows.map((row) => {
85022
- if (row.admissionOrder !== null) {
85023
- return receiptSchema.parse(row);
85024
- }
85025
- const admissionOrder = ++latestOrder;
85026
- this.#database.orm.update(executionReceipt).set({ admissionOrder }).where(eq2(executionReceipt.commandId, row.commandId)).run();
85027
- return receiptSchema.parse({ ...row, admissionOrder });
85028
- }).sort((left, right) => left.admissionOrder - right.admissionOrder);
85029
- });
85030
+ list = () => this.#database.orm.select().from(executionReceipt).orderBy(asc(executionReceipt.admissionOrder), asc(executionReceipt.commandId)).all().map((row) => receiptSchema.parse(row));
85030
85031
  save = (receipt, terminalLimit) => this.#database.transaction(() => {
85031
- const row = { ...receipt, state: legacyState(receipt) };
85032
- this.#database.orm.insert(executionReceipt).values(row).onConflictDoUpdate({ target: executionReceipt.commandId, set: row }).run();
85032
+ this.#database.orm.insert(executionReceipt).values(receipt).onConflictDoUpdate({ target: executionReceipt.commandId, set: receipt }).run();
85033
85033
  if (receipt.outcome === null) {
85034
85034
  return [];
85035
85035
  }
@@ -85041,7 +85041,7 @@ var ExecutionReceiptTable = class {
85041
85041
  isNotNull(executionReceipt.outcome),
85042
85042
  notInArray(
85043
85043
  executionReceipt.commandId,
85044
- retained.map((row2) => row2.commandId)
85044
+ retained.map((row) => row.commandId)
85045
85045
  )
85046
85046
  )
85047
85047
  );
@@ -86600,10 +86600,10 @@ var AgentSession = class _AgentSession {
86600
86600
  await this.#publishConfiguration();
86601
86601
  }
86602
86602
  };
86603
- // The revision check and Agent mutation share one queue, including legacy callers.
86603
+ // The revision check and Agent mutation share one queue, including settings the Runtime applies itself.
86604
86604
  // A lost response may have committed: reread after a conflict, never replay an edit blindly.
86605
86605
  configure = async (options) => this.#configurationChanges.run(async (signal) => {
86606
- if (options.expectedConfigurationRevision !== void 0 && options.expectedConfigurationRevision !== this.#configRevision) {
86606
+ if (options.expectedConfigurationRevision !== null && options.expectedConfigurationRevision !== this.#configRevision) {
86607
86607
  throw new AcpExecutionError(
86608
86608
  "Session settings changed. Review the current settings before applying your selection again.",
86609
86609
  {},
@@ -87255,6 +87255,7 @@ var SessionManager2 = class {
87255
87255
  ...options,
87256
87256
  booleanValue: desired.booleanValue,
87257
87257
  configId: desired.id,
87258
+ expectedConfigurationRevision: null,
87258
87259
  requestId: `execution-prepare-${desired.id}`,
87259
87260
  value: "",
87260
87261
  valueType: "boolean"
@@ -87267,6 +87268,7 @@ var SessionManager2 = class {
87267
87268
  ...options,
87268
87269
  booleanValue: false,
87269
87270
  configId: desired.id,
87271
+ expectedConfigurationRevision: null,
87270
87272
  requestId: `execution-prepare-${desired.id}`,
87271
87273
  value: desired.currentValue,
87272
87274
  valueType: "select"
@@ -87412,6 +87414,7 @@ var SessionManager2 = class {
87412
87414
  ...options2,
87413
87415
  booleanValue: false,
87414
87416
  configId: modelOption2?.id ?? "model",
87417
+ expectedConfigurationRevision: null,
87415
87418
  requestId: "agent-settings-model",
87416
87419
  sessionId: `agent-settings-${crypto.randomUUID()}`,
87417
87420
  value: model,
@@ -88151,6 +88154,7 @@ var NativeSessionService = class {
88151
88154
  capabilities: opened.prepared.capabilities,
88152
88155
  commands: opened.prepared.commands,
88153
88156
  configOptions: opened.prepared.configOptions,
88157
+ configurationRevision: opened.prepared.configurationRevision,
88154
88158
  directoryId: target.directoryId,
88155
88159
  directoryLabel: target.directoryLabel,
88156
88160
  kind: "session.ready",
@@ -89728,19 +89732,6 @@ var LocalExternalContentStore = class {
89728
89732
  };
89729
89733
  };
89730
89734
 
89731
- // src/engine/util/timer.ts
89732
- var SystemTimer = class {
89733
- schedule = (callback, milliseconds) => {
89734
- const timeout = setTimeout(callback, milliseconds);
89735
- return {
89736
- cancel: () => {
89737
- clearTimeout(timeout);
89738
- }
89739
- };
89740
- };
89741
- };
89742
- var systemTimer = new SystemTimer();
89743
-
89744
89735
  // src/engine/session/process/process-capacity.ts
89745
89736
  var AcpProcessCapacityLease = class {
89746
89737
  #releaseCapacity;
@@ -91699,6 +91690,7 @@ async function applySessionConfigurationSelection(sessions, options, selection,
91699
91690
  agent,
91700
91691
  booleanValue: selection.booleanValue,
91701
91692
  configId: selection.configId,
91693
+ expectedConfigurationRevision: null,
91702
91694
  cwd,
91703
91695
  requestId: `cfg_${randomUUID18()}`,
91704
91696
  sessionId,
@@ -92058,6 +92050,7 @@ async function prepareSession(command, recovery, closed, config2, resolveAgent,
92058
92050
  ...preparation,
92059
92051
  booleanValue: configuration.booleanValue,
92060
92052
  configId: configuration.configId,
92053
+ expectedConfigurationRevision: null,
92061
92054
  requestId: command.requestId,
92062
92055
  value: configuration.value,
92063
92056
  valueType: configuration.valueType
@@ -92234,7 +92227,7 @@ async function executeSessionConfigure(socket, command, config2, resolveAgent, d
92234
92227
  ...await resolveAgent(command.agentId, signal, command.sessionId),
92235
92228
  booleanValue: command.booleanValue,
92236
92229
  configId: command.configId,
92237
- ...command.expectedConfigurationRevision === void 0 ? {} : { expectedConfigurationRevision: command.expectedConfigurationRevision },
92230
+ expectedConfigurationRevision: command.expectedConfigurationRevision,
92238
92231
  cwd: resolved.cwd,
92239
92232
  requestId: command.requestId,
92240
92233
  sessionId: command.sessionId,
@@ -92637,7 +92630,7 @@ var HEARTBEAT_ACK_TIMEOUT_MILLISECONDS = 1e4;
92637
92630
  var HEARTBEAT_INTERVAL_MILLISECONDS = 2e4;
92638
92631
  var RelayLivenessState = class {
92639
92632
  };
92640
- var UnsupportedRelayLivenessState = class extends RelayLivenessState {
92633
+ var NotStartedRelayLivenessState = class extends RelayLivenessState {
92641
92634
  };
92642
92635
  var AwaitingHeartbeatAckState = class extends RelayLivenessState {
92643
92636
  timeout;
@@ -92658,7 +92651,7 @@ var FinishedRelayLivenessState = class extends RelayLivenessState {
92658
92651
  var RelayConnectionLiveness = class {
92659
92652
  #timer;
92660
92653
  #transport;
92661
- #state = new UnsupportedRelayLivenessState();
92654
+ #state = new NotStartedRelayLivenessState();
92662
92655
  constructor(timer, transport) {
92663
92656
  this.#timer = timer;
92664
92657
  this.#transport = transport;
@@ -92677,13 +92670,13 @@ var RelayConnectionLiveness = class {
92677
92670
  this.#state.timeout.cancel();
92678
92671
  } else if (this.#state instanceof WaitingForHeartbeatState) {
92679
92672
  this.#state.schedule.cancel();
92680
- } else if (!(this.#state instanceof UnsupportedRelayLivenessState) && !(this.#state instanceof FinishedRelayLivenessState)) {
92673
+ } else if (!(this.#state instanceof NotStartedRelayLivenessState) && !(this.#state instanceof FinishedRelayLivenessState)) {
92681
92674
  throw new Error("Unknown relay liveness state");
92682
92675
  }
92683
92676
  this.#state = new FinishedRelayLivenessState();
92684
92677
  };
92685
92678
  start = () => {
92686
- if (this.#state instanceof UnsupportedRelayLivenessState) {
92679
+ if (this.#state instanceof NotStartedRelayLivenessState) {
92687
92680
  this.#sendHeartbeat();
92688
92681
  return;
92689
92682
  }
@@ -92709,7 +92702,7 @@ var RelayConnectionLiveness = class {
92709
92702
  #sendHeartbeat = () => {
92710
92703
  if (this.#state instanceof WaitingForHeartbeatState) {
92711
92704
  this.#state.schedule.cancel();
92712
- } else if (!(this.#state instanceof UnsupportedRelayLivenessState)) {
92705
+ } else if (!(this.#state instanceof NotStartedRelayLivenessState)) {
92713
92706
  if (this.#state instanceof FinishedRelayLivenessState) {
92714
92707
  return;
92715
92708
  }
@@ -92759,7 +92752,6 @@ async function runRelayConnection({
92759
92752
  timer
92760
92753
  }) {
92761
92754
  const relayUrl = new URL(config2.relayUrl);
92762
- relayUrl.searchParams.set("liveness", "1");
92763
92755
  const relay = await connectRelay(relayUrl, signal, (failure2, source) => {
92764
92756
  diagnostics.transportFailed(connectionEpoch, failure2, source);
92765
92757
  });
@@ -93591,4 +93583,4 @@ export {
93591
93583
  * MIT Licensed
93592
93584
  *)
93593
93585
  */
93594
- //# sourceMappingURL=chunk-7HMKMNG4.js.map
93586
+ //# sourceMappingURL=chunk-HJN27I4Y.js.map