@moxt-ai/mobius 0.0.325 → 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 (28) hide show
  1. package/dist/cli.js +63 -12
  2. package/dist/cli.js.map +4 -4
  3. package/dist/generated/acp-session-store-migrations.d.ts +3 -0
  4. package/dist/generated/acp-session-store-migrations.d.ts.map +1 -1
  5. package/dist/generated/acp-session-store-migrations.js +5 -1
  6. package/dist/generated/acp-session-store-migrations.js.map +1 -1
  7. package/dist/runtime/command/registry/prompt.d.ts.map +1 -1
  8. package/dist/runtime/command/registry/prompt.js +10 -0
  9. package/dist/runtime/command/registry/prompt.js.map +1 -1
  10. package/dist/runtime.js +54 -11
  11. package/dist/runtime.js.map +4 -4
  12. package/dist/schema/acp-session-store/execution-identity.d.ts +57 -0
  13. package/dist/schema/acp-session-store/execution-identity.d.ts.map +1 -0
  14. package/dist/schema/acp-session-store/execution-identity.js +8 -0
  15. package/dist/schema/acp-session-store/execution-identity.js.map +1 -0
  16. package/dist/schema/acp-session-store/index.d.ts +1 -0
  17. package/dist/schema/acp-session-store/index.d.ts.map +1 -1
  18. package/dist/schema/acp-session-store/index.js +1 -0
  19. package/dist/schema/acp-session-store/index.js.map +1 -1
  20. package/dist/session/turn/execution-receipts.d.ts +3 -1
  21. package/dist/session/turn/execution-receipts.d.ts.map +1 -1
  22. package/dist/session/turn/execution-receipts.js +10 -4
  23. package/dist/session/turn/execution-receipts.js.map +1 -1
  24. package/dist/storage/session/execution-receipt-table.d.ts +5 -0
  25. package/dist/storage/session/execution-receipt-table.d.ts.map +1 -1
  26. package/dist/storage/session/execution-receipt-table.js +32 -6
  27. package/dist/storage/session/execution-receipt-table.js.map +1 -1
  28. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2086,7 +2086,7 @@ var init_package = __esm({
2086
2086
  "package.json"() {
2087
2087
  package_default = {
2088
2088
  name: "@moxt-ai/mobius",
2089
- version: "0.0.325",
2089
+ version: "0.0.326",
2090
2090
  description: "Mobius CLI for pairing and running local AI agent services.",
2091
2091
  type: "module",
2092
2092
  bin: {
@@ -75069,12 +75069,12 @@ var init_event_log = __esm({
75069
75069
  textContentSchema = external_exports.object({ ...contentFields, text: boundedString2, type: external_exports.literal("text") }).readonly();
75070
75070
  imageContentSchema = external_exports.object({
75071
75071
  ...contentFields,
75072
- data: boundedString2,
75072
+ data: external_exports.string(),
75073
75073
  mimeType: shortString,
75074
75074
  type: external_exports.literal("image"),
75075
75075
  uri: boundedString2.nullable().optional()
75076
75076
  }).readonly();
75077
- audioContentSchema = external_exports.object({ ...contentFields, data: boundedString2, mimeType: shortString, type: external_exports.literal("audio") }).readonly();
75077
+ audioContentSchema = external_exports.object({ ...contentFields, data: external_exports.string(), mimeType: shortString, type: external_exports.literal("audio") }).readonly();
75078
75078
  externalImageContentSchema = external_exports.object({
75079
75079
  ...contentFields,
75080
75080
  byteLength: external_exports.number().int().positive().safe(),
@@ -75115,7 +75115,7 @@ var init_event_log = __esm({
75115
75115
  uri: boundedString2
75116
75116
  }).readonly();
75117
75117
  blobResourceSchema = external_exports.object({
75118
- blob: boundedString2,
75118
+ blob: external_exports.string(),
75119
75119
  mimeType: shortString.nullable().optional(),
75120
75120
  uri: boundedString2
75121
75121
  }).readonly();
@@ -84023,6 +84023,10 @@ var init_acp_session_store_migrations = __esm({
84023
84023
  {
84024
84024
  "name": "0007_busy_excalibur.sql",
84025
84025
  "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"
84026
+ },
84027
+ {
84028
+ "name": "0008_execution_identity.sql",
84029
+ "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"
84026
84030
  }
84027
84031
  ];
84028
84032
  }
@@ -93330,6 +93334,20 @@ var init_acp_session = __esm({
93330
93334
  }
93331
93335
  });
93332
93336
 
93337
+ // src/schema/acp-session-store/execution-identity.ts
93338
+ var executionIdentity;
93339
+ var init_execution_identity = __esm({
93340
+ "src/schema/acp-session-store/execution-identity.ts"() {
93341
+ "use strict";
93342
+ init_sqlite_core();
93343
+ executionIdentity = sqliteTable("execution_identity", {
93344
+ commandId: text("command_id").primaryKey(),
93345
+ sessionId: text("session_id").notNull(),
93346
+ commandHash: text("command_hash").notNull()
93347
+ });
93348
+ }
93349
+ });
93350
+
93333
93351
  // src/schema/acp-session-store/execution-receipt.ts
93334
93352
  var executionReceipt;
93335
93353
  var init_execution_receipt = __esm({
@@ -93367,6 +93385,7 @@ var init_acp_session_store = __esm({
93367
93385
  "src/schema/acp-session-store/index.ts"() {
93368
93386
  "use strict";
93369
93387
  init_acp_session();
93388
+ init_execution_identity();
93370
93389
  init_execution_receipt();
93371
93390
  init_session_live_event_position_allocation();
93372
93391
  }
@@ -93417,7 +93436,7 @@ var init_acp_session_table = __esm({
93417
93436
  });
93418
93437
 
93419
93438
  // src/storage/session/execution-receipt-table.ts
93420
- var receiptFields, receiptSchema, ExecutionReceiptTable;
93439
+ var receiptFields, receiptSchema, identitySchema, ExecutionReceiptTable;
93421
93440
  var init_execution_receipt_table = __esm({
93422
93441
  "src/storage/session/execution-receipt-table.ts"() {
93423
93442
  "use strict";
@@ -93440,11 +93459,16 @@ var init_execution_receipt_table = __esm({
93440
93459
  outcome: external_exports.string().nullable()
93441
93460
  })
93442
93461
  ]).readonly();
93462
+ identitySchema = external_exports.object({ sessionId: external_exports.string(), commandHash: external_exports.string() }).readonly();
93443
93463
  ExecutionReceiptTable = class {
93444
93464
  #database;
93445
93465
  constructor(database) {
93446
93466
  this.#database = database;
93447
93467
  }
93468
+ identity = (commandId) => {
93469
+ const row = this.#database.orm.select({ sessionId: executionIdentity.sessionId, commandHash: executionIdentity.commandHash }).from(executionIdentity).where(eq2(executionIdentity.commandId, commandId)).get();
93470
+ return row === void 0 ? void 0 : identitySchema.parse(row);
93471
+ };
93448
93472
  list = () => receiptSchema.array().parse(
93449
93473
  this.#database.orm.select().from(executionReceipt).orderBy(asc(executionReceipt.updatedAt), asc(executionReceipt.commandId)).all()
93450
93474
  );
@@ -93461,7 +93485,7 @@ var init_execution_receipt_table = __esm({
93461
93485
  )
93462
93486
  ).orderBy(desc(executionReceipt.updatedAt), desc(executionReceipt.commandId)).limit(1024).all();
93463
93487
  if (retained.length === 1024) {
93464
- this.#database.orm.delete(executionReceipt).where(
93488
+ this.#remove(
93465
93489
  and(
93466
93490
  eq2(executionReceipt.sessionId, receipt.sessionId),
93467
93491
  inArray(executionReceipt.state, ["succeeded", "failed", "cancelled"]),
@@ -93470,12 +93494,25 @@ var init_execution_receipt_table = __esm({
93470
93494
  retained.map((row) => row.commandId)
93471
93495
  )
93472
93496
  )
93473
- ).run();
93497
+ );
93474
93498
  }
93475
93499
  });
93476
93500
  };
93477
93501
  remove = (commandId) => {
93478
- this.#database.orm.delete(executionReceipt).where(eq2(executionReceipt.commandId, commandId)).run();
93502
+ this.#database.transaction(() => this.#remove(eq2(executionReceipt.commandId, commandId)));
93503
+ };
93504
+ #remove = (condition) => {
93505
+ if (condition === void 0) {
93506
+ throw new Error("Execution receipt removal requires a scope");
93507
+ }
93508
+ this.#database.orm.insert(executionIdentity).select(
93509
+ this.#database.orm.select({
93510
+ commandId: executionReceipt.commandId,
93511
+ sessionId: executionReceipt.sessionId,
93512
+ commandHash: executionReceipt.commandHash
93513
+ }).from(executionReceipt).where(and(condition, eq2(executionReceipt.started, true)))
93514
+ ).onConflictDoNothing().run();
93515
+ this.#database.orm.delete(executionReceipt).where(condition).run();
93479
93516
  };
93480
93517
  };
93481
93518
  }
@@ -96875,7 +96912,7 @@ var init_execution_receipts = __esm({
96875
96912
  constructor(table, onCount = () => void 0) {
96876
96913
  this.#onCount = onCount;
96877
96914
  this.#table = table;
96878
- for (const row of table?.list() ?? []) {
96915
+ for (const row of table.list()) {
96879
96916
  this.#executions.set(row.commandId, row);
96880
96917
  this.#recoveredCommands.add(row.commandId);
96881
96918
  if (!isTerminal(row.state)) {
@@ -96891,7 +96928,7 @@ var init_execution_receipts = __esm({
96891
96928
  }
96892
96929
  #save = (commandId, receipt) => {
96893
96930
  if (!this.#closing) {
96894
- this.#table?.save({ ...receipt, commandId, updatedAt: (/* @__PURE__ */ new Date()).toISOString() });
96931
+ this.#table.save({ ...receipt, commandId, updatedAt: (/* @__PURE__ */ new Date()).toISOString() });
96895
96932
  }
96896
96933
  const previous = this.#executions.get(commandId);
96897
96934
  const wasActive = previous !== void 0 && !isTerminal(previous.state);
@@ -96967,9 +97004,9 @@ var init_execution_receipts = __esm({
96967
97004
  let existing = this.#executions.get(commandId);
96968
97005
  const previous = this.outcome(commandId);
96969
97006
  if (existing?.sessionId === sessionId && !existing.started && previous?.type === "lifecycle-metadata" && previous.payload.kind === "prompt.failed-before-start" && previous.payload.code === "runtime_restarted") {
97007
+ this.#table.remove(commandId);
96970
97008
  this.#executions.delete(commandId);
96971
97009
  this.#recoveredCommands.delete(commandId);
96972
- this.#table?.remove(commandId);
96973
97010
  this.#terminalCountBySession.set(
96974
97011
  sessionId,
96975
97012
  Math.max(0, (this.#terminalCountBySession.get(sessionId) ?? 1) - 1)
@@ -96988,6 +97025,10 @@ var init_execution_receipts = __esm({
96988
97025
  outcome: this.#recoveredCommands.has(commandId) ? this.outcome(commandId) : void 0
96989
97026
  };
96990
97027
  }
97028
+ const identity2 = this.#table.identity(commandId);
97029
+ if (identity2 !== void 0) {
97030
+ return identity2.sessionId === sessionId && identity2.commandHash === commandHash ? { kind: "expired" } : { kind: "conflict" };
97031
+ }
96991
97032
  const attemptId = randomUUID14();
96992
97033
  this.#save(commandId, {
96993
97034
  attemptId,
@@ -97038,9 +97079,9 @@ var init_execution_receipts = __esm({
97038
97079
  }
97039
97080
  for (const [commandId, receipt] of this.#executions) {
97040
97081
  if (receipt.sessionId === sessionId && isTerminal(receipt.state)) {
97082
+ this.#table.remove(commandId);
97041
97083
  this.#executions.delete(commandId);
97042
97084
  this.#recoveredCommands.delete(commandId);
97043
- this.#table?.remove(commandId);
97044
97085
  const remaining = (this.#terminalCountBySession.get(sessionId) ?? 1) - 1;
97045
97086
  if (remaining > 0) {
97046
97087
  this.#terminalCountBySession.set(sessionId, remaining);
@@ -100448,6 +100489,16 @@ var init_prompt2 = __esm({
100448
100489
  }
100449
100490
  return;
100450
100491
  }
100492
+ if (receipt.kind === "expired") {
100493
+ send(context.socket, {
100494
+ code: "command_result_expired",
100495
+ requestId: message.commandId,
100496
+ kind: "session.operation.failed",
100497
+ message: "This command already started. Its execution result is no longer available; it will not run again.",
100498
+ sessionId: message.sessionId
100499
+ });
100500
+ return;
100501
+ }
100451
100502
  const turn = context.sessionTurns.start(message, receipt.attemptId);
100452
100503
  context.eventProjection.requested(message);
100453
100504
  const queueChanged = () => {