@moxt-ai/mobius 0.0.324 → 0.0.326

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 (41) hide show
  1. package/dist/cli/handler/daemon/upgrade.d.ts.map +1 -1
  2. package/dist/cli/handler/daemon/upgrade.js +2 -5
  3. package/dist/cli/handler/daemon/upgrade.js.map +1 -1
  4. package/dist/cli.js +349 -291
  5. package/dist/cli.js.map +4 -4
  6. package/dist/daemon/lifecycle/manager-client.d.ts +1 -1
  7. package/dist/daemon/lifecycle/manager-client.d.ts.map +1 -1
  8. package/dist/daemon/lifecycle/manager-client.js +9 -1
  9. package/dist/daemon/lifecycle/manager-client.js.map +1 -1
  10. package/dist/daemon/lifecycle/worker.js +2 -2
  11. package/dist/daemon/lifecycle/worker.js.map +1 -1
  12. package/dist/daemon/pairing/pair-local-machine.d.ts +1 -0
  13. package/dist/daemon/pairing/pair-local-machine.d.ts.map +1 -1
  14. package/dist/daemon/pairing/pair-local-machine.js +10 -3
  15. package/dist/daemon/pairing/pair-local-machine.js.map +1 -1
  16. package/dist/generated/acp-session-store-migrations.d.ts +3 -0
  17. package/dist/generated/acp-session-store-migrations.d.ts.map +1 -1
  18. package/dist/generated/acp-session-store-migrations.js +5 -1
  19. package/dist/generated/acp-session-store-migrations.js.map +1 -1
  20. package/dist/runtime/command/registry/prompt.d.ts.map +1 -1
  21. package/dist/runtime/command/registry/prompt.js +10 -0
  22. package/dist/runtime/command/registry/prompt.js.map +1 -1
  23. package/dist/runtime.js +63 -73
  24. package/dist/runtime.js.map +4 -4
  25. package/dist/schema/acp-session-store/execution-identity.d.ts +57 -0
  26. package/dist/schema/acp-session-store/execution-identity.d.ts.map +1 -0
  27. package/dist/schema/acp-session-store/execution-identity.js +8 -0
  28. package/dist/schema/acp-session-store/execution-identity.js.map +1 -0
  29. package/dist/schema/acp-session-store/index.d.ts +1 -0
  30. package/dist/schema/acp-session-store/index.d.ts.map +1 -1
  31. package/dist/schema/acp-session-store/index.js +1 -0
  32. package/dist/schema/acp-session-store/index.js.map +1 -1
  33. package/dist/session/turn/execution-receipts.d.ts +3 -1
  34. package/dist/session/turn/execution-receipts.d.ts.map +1 -1
  35. package/dist/session/turn/execution-receipts.js +10 -4
  36. package/dist/session/turn/execution-receipts.js.map +1 -1
  37. package/dist/storage/session/execution-receipt-table.d.ts +5 -0
  38. package/dist/storage/session/execution-receipt-table.d.ts.map +1 -1
  39. package/dist/storage/session/execution-receipt-table.js +32 -6
  40. package/dist/storage/session/execution-receipt-table.js.map +1 -1
  41. package/package.json +1 -1
package/dist/runtime.js CHANGED
@@ -22175,12 +22175,12 @@ var contentFields = { annotations: annotationsSchema.nullable().optional() };
22175
22175
  var textContentSchema = external_exports.object({ ...contentFields, text: boundedString2, type: external_exports.literal("text") }).readonly();
22176
22176
  var imageContentSchema = external_exports.object({
22177
22177
  ...contentFields,
22178
- data: boundedString2,
22178
+ data: external_exports.string(),
22179
22179
  mimeType: shortString,
22180
22180
  type: external_exports.literal("image"),
22181
22181
  uri: boundedString2.nullable().optional()
22182
22182
  }).readonly();
22183
- var audioContentSchema = external_exports.object({ ...contentFields, data: boundedString2, mimeType: shortString, type: external_exports.literal("audio") }).readonly();
22183
+ var audioContentSchema = external_exports.object({ ...contentFields, data: external_exports.string(), mimeType: shortString, type: external_exports.literal("audio") }).readonly();
22184
22184
  var externalImageContentSchema = external_exports.object({
22185
22185
  ...contentFields,
22186
22186
  byteLength: external_exports.number().int().positive().safe(),
@@ -22221,7 +22221,7 @@ var textResourceSchema = external_exports.object({
22221
22221
  uri: boundedString2
22222
22222
  }).readonly();
22223
22223
  var blobResourceSchema = external_exports.object({
22224
- blob: boundedString2,
22224
+ blob: external_exports.string(),
22225
22225
  mimeType: shortString.nullable().optional(),
22226
22226
  uri: boundedString2
22227
22227
  }).readonly();
@@ -26741,6 +26741,10 @@ var acpSessionStoreMigrations = [
26741
26741
  {
26742
26742
  "name": "0007_busy_excalibur.sql",
26743
26743
  "sql": "CREATE TABLE `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 `state` text NOT NULL,\n `started` integer NOT NULL,\n `outcome` text,\n `updated_at` text NOT NULL\n);\n"
26744
+ },
26745
+ {
26746
+ "name": "0008_execution_identity.sql",
26747
+ "sql": "CREATE TABLE `execution_identity` (\n `command_id` text PRIMARY KEY NOT NULL,\n `session_id` text NOT NULL,\n `command_hash` text NOT NULL\n);\n"
26744
26748
  }
26745
26749
  ];
26746
26750
 
@@ -32382,7 +32386,7 @@ import { fetch as fetch3 } from "undici";
32382
32386
  // package.json
32383
32387
  var package_default = {
32384
32388
  name: "@moxt-ai/mobius",
32385
- version: "0.0.324",
32389
+ version: "0.0.326",
32386
32390
  description: "Mobius CLI for pairing and running local AI agent services.",
32387
32391
  type: "module",
32388
32392
  bin: {
@@ -83135,59 +83139,6 @@ async function openRuntimeInstallationStore(options, signal) {
83135
83139
  return await RuntimeInstallationStore.open(options, signal);
83136
83140
  }
83137
83141
 
83138
- // src/daemon/control/local-client.ts
83139
- var MAXIMUM_MESSAGE_BYTES = 64 * 1024;
83140
- var managerPlatform = platformSupportFor(process.platform);
83141
-
83142
- // src/daemon/control/protocol.ts
83143
- var workerLaunch = external_exports.object({
83144
- executable: external_exports.string().min(1),
83145
- entry: external_exports.string().min(1),
83146
- version: external_exports.string().min(1).max(128)
83147
- }).readonly();
83148
- var transition = {
83149
- id: external_exports.string().min(1).max(256),
83150
- context: external_exports.string().max(256),
83151
- previous: workerLaunch,
83152
- next: workerLaunch
83153
- };
83154
- var daemonSwitchState = external_exports.discriminatedUnion("kind", [
83155
- external_exports.object({ ...transition, kind: external_exports.literal("switching") }),
83156
- external_exports.object({ ...transition, kind: external_exports.literal("switched") }),
83157
- external_exports.object({
83158
- ...transition,
83159
- kind: external_exports.literal("rolled-back"),
83160
- code: external_exports.string(),
83161
- message: external_exports.string(),
83162
- stdout: external_exports.string().max(4096),
83163
- stderr: external_exports.string().max(4096),
83164
- retryAfter: external_exports.number().int().nonnegative()
83165
- })
83166
- ]).readonly();
83167
- var lifecycleCommand = external_exports.discriminatedUnion("kind", [
83168
- external_exports.object({ kind: external_exports.literal("status") }),
83169
- external_exports.object({ kind: external_exports.literal("ensure"), launch: workerLaunch }),
83170
- external_exports.object({ kind: external_exports.literal("stop") }),
83171
- external_exports.object({
83172
- kind: external_exports.literal("switch"),
83173
- id: external_exports.string().min(1).max(256),
83174
- context: external_exports.string().max(256),
83175
- launch: workerLaunch
83176
- }),
83177
- external_exports.object({ kind: external_exports.literal("switch-status"), wait: external_exports.boolean() })
83178
- ]).readonly();
83179
- var lifecycleResponse = external_exports.discriminatedUnion("kind", [
83180
- external_exports.object({
83181
- kind: external_exports.literal("status"),
83182
- protocolVersion: external_exports.literal(2),
83183
- worker: external_exports.object({ pid: external_exports.number().int().positive(), version: external_exports.string() }).readonly().nullable()
83184
- }),
83185
- external_exports.object({ kind: external_exports.literal("switch-status"), state: daemonSwitchState.nullable() }),
83186
- external_exports.object({ kind: external_exports.literal("stopped") }),
83187
- external_exports.object({ kind: external_exports.literal("switching") }),
83188
- external_exports.object({ kind: external_exports.literal("error"), code: external_exports.string(), message: external_exports.string() })
83189
- ]).readonly();
83190
-
83191
83142
  // src/daemon/pairing/pair-local-machine.ts
83192
83143
  var PAIRING_TIMEOUT_MILLISECONDS = 2e4;
83193
83144
  var PAIRING_CODE_PATTERN = /^[A-HJ-NP-Z2-9]{4}(?:-[A-HJ-NP-Z2-9]{4}){4}$/;
@@ -83441,6 +83392,13 @@ var acpSession = sqliteTable("acp_session", {
83441
83392
  updatedAt: text("updated_at").notNull()
83442
83393
  });
83443
83394
 
83395
+ // src/schema/acp-session-store/execution-identity.ts
83396
+ var executionIdentity = sqliteTable("execution_identity", {
83397
+ commandId: text("command_id").primaryKey(),
83398
+ sessionId: text("session_id").notNull(),
83399
+ commandHash: text("command_hash").notNull()
83400
+ });
83401
+
83444
83402
  // src/schema/acp-session-store/execution-receipt.ts
83445
83403
  var executionReceipt = sqliteTable("execution_receipt", {
83446
83404
  commandId: text("command_id").primaryKey(),
@@ -83511,11 +83469,16 @@ var receiptSchema = external_exports.discriminatedUnion("state", [
83511
83469
  outcome: external_exports.string().nullable()
83512
83470
  })
83513
83471
  ]).readonly();
83472
+ var identitySchema = external_exports.object({ sessionId: external_exports.string(), commandHash: external_exports.string() }).readonly();
83514
83473
  var ExecutionReceiptTable = class {
83515
83474
  #database;
83516
83475
  constructor(database) {
83517
83476
  this.#database = database;
83518
83477
  }
83478
+ identity = (commandId) => {
83479
+ const row = this.#database.orm.select({ sessionId: executionIdentity.sessionId, commandHash: executionIdentity.commandHash }).from(executionIdentity).where(eq(executionIdentity.commandId, commandId)).get();
83480
+ return row === void 0 ? void 0 : identitySchema.parse(row);
83481
+ };
83519
83482
  list = () => receiptSchema.array().parse(
83520
83483
  this.#database.orm.select().from(executionReceipt).orderBy(asc(executionReceipt.updatedAt), asc(executionReceipt.commandId)).all()
83521
83484
  );
@@ -83532,7 +83495,7 @@ var ExecutionReceiptTable = class {
83532
83495
  )
83533
83496
  ).orderBy(desc(executionReceipt.updatedAt), desc(executionReceipt.commandId)).limit(1024).all();
83534
83497
  if (retained.length === 1024) {
83535
- this.#database.orm.delete(executionReceipt).where(
83498
+ this.#remove(
83536
83499
  and(
83537
83500
  eq(executionReceipt.sessionId, receipt.sessionId),
83538
83501
  inArray(executionReceipt.state, ["succeeded", "failed", "cancelled"]),
@@ -83541,12 +83504,25 @@ var ExecutionReceiptTable = class {
83541
83504
  retained.map((row) => row.commandId)
83542
83505
  )
83543
83506
  )
83544
- ).run();
83507
+ );
83545
83508
  }
83546
83509
  });
83547
83510
  };
83548
83511
  remove = (commandId) => {
83549
- this.#database.orm.delete(executionReceipt).where(eq(executionReceipt.commandId, commandId)).run();
83512
+ this.#database.transaction(() => this.#remove(eq(executionReceipt.commandId, commandId)));
83513
+ };
83514
+ #remove = (condition) => {
83515
+ if (condition === void 0) {
83516
+ throw new Error("Execution receipt removal requires a scope");
83517
+ }
83518
+ this.#database.orm.insert(executionIdentity).select(
83519
+ this.#database.orm.select({
83520
+ commandId: executionReceipt.commandId,
83521
+ sessionId: executionReceipt.sessionId,
83522
+ commandHash: executionReceipt.commandHash
83523
+ }).from(executionReceipt).where(and(condition, eq(executionReceipt.started, true)))
83524
+ ).onConflictDoNothing().run();
83525
+ this.#database.orm.delete(executionReceipt).where(condition).run();
83550
83526
  };
83551
83527
  };
83552
83528
 
@@ -84494,7 +84470,7 @@ async function restoreSession(session, signal, recovery, origin) {
84494
84470
  session.store.remove(session.sessionId);
84495
84471
  stored = session.metrics.measureSync("session-state-read", () => session.store.read(session.sessionId));
84496
84472
  }
84497
- let lifecycleResponse2;
84473
+ let lifecycleResponse;
84498
84474
  if (origin?.kind === "fork") {
84499
84475
  if (!session.capabilities.unstableForkSession) {
84500
84476
  throw new AcpExecutionError(
@@ -84540,7 +84516,7 @@ async function restoreSession(session, signal, recovery, origin) {
84540
84516
  if (recovery.kind === "execution-only") {
84541
84517
  session.startExecutionOnlyCapture();
84542
84518
  }
84543
- lifecycleResponse2 = forked;
84519
+ lifecycleResponse = forked;
84544
84520
  } else if (stored instanceof FoundStoredSession && stored.session.agentId === session.agentId && stored.session.cwd === session.cwd && arraysEqual(stored.session.additionalDirectories, session.additionalDirectories)) {
84545
84521
  session.selectNativeSession(stored.session.nativeSessionId);
84546
84522
  session.setPrompted(stored.session.prompted);
@@ -84554,13 +84530,13 @@ async function restoreSession(session, signal, recovery, origin) {
84554
84530
  "native_history_unsupported"
84555
84531
  );
84556
84532
  }
84557
- lifecycleResponse2 = await session.metrics.measure(
84533
+ lifecycleResponse = await session.metrics.measure(
84558
84534
  "session-load",
84559
84535
  async () => (await session.loadSession(signal, "ACP agent exited while loading a session")).response
84560
84536
  );
84561
84537
  } else if (recovery.kind === "execution-only") {
84562
84538
  try {
84563
- lifecycleResponse2 = await session.metrics.measure(
84539
+ lifecycleResponse = await session.metrics.measure(
84564
84540
  "session-resume",
84565
84541
  async () => await session.race(
84566
84542
  session.agentRequest(
@@ -84590,7 +84566,7 @@ async function restoreSession(session, signal, recovery, origin) {
84590
84566
  }
84591
84567
  session.startExecutionOnlyCapture();
84592
84568
  } else if (session.capabilities.resumeSession) {
84593
- lifecycleResponse2 = await session.metrics.measure(
84569
+ lifecycleResponse = await session.metrics.measure(
84594
84570
  "session-resume",
84595
84571
  async () => await session.race(
84596
84572
  session.agentRequest(
@@ -84608,7 +84584,7 @@ async function restoreSession(session, signal, recovery, origin) {
84608
84584
  )
84609
84585
  );
84610
84586
  } else if (session.capabilities.loadSession) {
84611
- lifecycleResponse2 = await session.metrics.measure(
84587
+ lifecycleResponse = await session.metrics.measure(
84612
84588
  "session-load",
84613
84589
  async () => (await session.loadSession(signal, "ACP agent exited while loading a session")).response
84614
84590
  );
@@ -84651,10 +84627,10 @@ async function restoreSession(session, signal, recovery, origin) {
84651
84627
  if (recovery.kind === "execution-only") {
84652
84628
  session.startExecutionOnlyCapture();
84653
84629
  }
84654
- lifecycleResponse2 = created;
84630
+ lifecycleResponse = created;
84655
84631
  }
84656
- session.restrictSessionCapabilities(lifecycleResponse2);
84657
- session.setConfigOptions(session.sessionConfigProtocol.normalizeLifecycle(lifecycleResponse2));
84632
+ session.restrictSessionCapabilities(lifecycleResponse);
84633
+ session.setConfigOptions(session.sessionConfigProtocol.normalizeLifecycle(lifecycleResponse));
84658
84634
  if (stored instanceof FoundStoredSession && session.restored) {
84659
84635
  await session.restoreStoredConfigurations(stored.session, signal);
84660
84636
  }
@@ -86777,7 +86753,7 @@ var ExecutionReceipts = class {
86777
86753
  constructor(table, onCount = () => void 0) {
86778
86754
  this.#onCount = onCount;
86779
86755
  this.#table = table;
86780
- for (const row of table?.list() ?? []) {
86756
+ for (const row of table.list()) {
86781
86757
  this.#executions.set(row.commandId, row);
86782
86758
  this.#recoveredCommands.add(row.commandId);
86783
86759
  if (!isTerminal(row.state)) {
@@ -86793,7 +86769,7 @@ var ExecutionReceipts = class {
86793
86769
  }
86794
86770
  #save = (commandId, receipt) => {
86795
86771
  if (!this.#closing) {
86796
- this.#table?.save({ ...receipt, commandId, updatedAt: (/* @__PURE__ */ new Date()).toISOString() });
86772
+ this.#table.save({ ...receipt, commandId, updatedAt: (/* @__PURE__ */ new Date()).toISOString() });
86797
86773
  }
86798
86774
  const previous = this.#executions.get(commandId);
86799
86775
  const wasActive = previous !== void 0 && !isTerminal(previous.state);
@@ -86869,9 +86845,9 @@ var ExecutionReceipts = class {
86869
86845
  let existing = this.#executions.get(commandId);
86870
86846
  const previous = this.outcome(commandId);
86871
86847
  if (existing?.sessionId === sessionId && !existing.started && previous?.type === "lifecycle-metadata" && previous.payload.kind === "prompt.failed-before-start" && previous.payload.code === "runtime_restarted") {
86848
+ this.#table.remove(commandId);
86872
86849
  this.#executions.delete(commandId);
86873
86850
  this.#recoveredCommands.delete(commandId);
86874
- this.#table?.remove(commandId);
86875
86851
  this.#terminalCountBySession.set(
86876
86852
  sessionId,
86877
86853
  Math.max(0, (this.#terminalCountBySession.get(sessionId) ?? 1) - 1)
@@ -86890,6 +86866,10 @@ var ExecutionReceipts = class {
86890
86866
  outcome: this.#recoveredCommands.has(commandId) ? this.outcome(commandId) : void 0
86891
86867
  };
86892
86868
  }
86869
+ const identity2 = this.#table.identity(commandId);
86870
+ if (identity2 !== void 0) {
86871
+ return identity2.sessionId === sessionId && identity2.commandHash === commandHash ? { kind: "expired" } : { kind: "conflict" };
86872
+ }
86893
86873
  const attemptId = randomUUID13();
86894
86874
  this.#save(commandId, {
86895
86875
  attemptId,
@@ -86940,9 +86920,9 @@ var ExecutionReceipts = class {
86940
86920
  }
86941
86921
  for (const [commandId, receipt] of this.#executions) {
86942
86922
  if (receipt.sessionId === sessionId && isTerminal(receipt.state)) {
86923
+ this.#table.remove(commandId);
86943
86924
  this.#executions.delete(commandId);
86944
86925
  this.#recoveredCommands.delete(commandId);
86945
- this.#table?.remove(commandId);
86946
86926
  const remaining = (this.#terminalCountBySession.get(sessionId) ?? 1) - 1;
86947
86927
  if (remaining > 0) {
86948
86928
  this.#terminalCountBySession.set(sessionId, remaining);
@@ -90171,6 +90151,16 @@ var sessionPromptCommand = {
90171
90151
  }
90172
90152
  return;
90173
90153
  }
90154
+ if (receipt.kind === "expired") {
90155
+ send(context.socket, {
90156
+ code: "command_result_expired",
90157
+ requestId: message.commandId,
90158
+ kind: "session.operation.failed",
90159
+ message: "This command already started. Its execution result is no longer available; it will not run again.",
90160
+ sessionId: message.sessionId
90161
+ });
90162
+ return;
90163
+ }
90174
90164
  const turn = context.sessionTurns.start(message, receipt.attemptId);
90175
90165
  context.eventProjection.requested(message);
90176
90166
  const queueChanged = () => {