@gobing-ai/spur 0.3.45 → 0.3.47

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.
package/spur.js CHANGED
@@ -47,7 +47,7 @@ var __export = (target, all) => {
47
47
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
48
48
  var __require = import.meta.require;
49
49
 
50
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.30/node_modules/@gobing-ai/ts-utils/dist/errors.js
50
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.31/node_modules/@gobing-ai/ts-utils/dist/errors.js
51
51
  var ErrorCode;
52
52
  var init_errors = __esm(() => {
53
53
  ErrorCode = {
@@ -58,7 +58,7 @@ var init_errors = __esm(() => {
58
58
  };
59
59
  });
60
60
 
61
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.30/node_modules/@gobing-ai/ts-utils/dist/api-response.js
61
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.31/node_modules/@gobing-ai/ts-utils/dist/api-response.js
62
62
  var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
63
63
  var init_api_response = __esm(() => {
64
64
  init_errors();
@@ -81,13 +81,13 @@ var init_api_response = __esm(() => {
81
81
  CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
82
82
  });
83
83
 
84
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.30/node_modules/@gobing-ai/ts-utils/dist/cursor.js
84
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.31/node_modules/@gobing-ai/ts-utils/dist/cursor.js
85
85
  var init_cursor = () => {};
86
86
 
87
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.30/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
87
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.31/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
88
88
  var init_event_severity = () => {};
89
89
 
90
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.30/node_modules/@gobing-ai/ts-utils/dist/object.js
90
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.31/node_modules/@gobing-ai/ts-utils/dist/object.js
91
91
  function isPlainObject(value) {
92
92
  return typeof value === "object" && value !== null && !Array.isArray(value);
93
93
  }
@@ -105,7 +105,7 @@ function deepMerge(target, source) {
105
105
  return result;
106
106
  }
107
107
 
108
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.30/node_modules/@gobing-ai/ts-utils/dist/output.js
108
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.31/node_modules/@gobing-ai/ts-utils/dist/output.js
109
109
  function processStream(name) {
110
110
  const proc = globalThis.process;
111
111
  const stream = proc?.[name];
@@ -126,7 +126,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
126
126
  }
127
127
  var defaultStdoutTarget, defaultStderrTarget;
128
128
 
129
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.30/node_modules/@gobing-ai/ts-utils/dist/index.js
129
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.31/node_modules/@gobing-ai/ts-utils/dist/index.js
130
130
  var init_dist = __esm(() => {
131
131
  init_api_response();
132
132
  init_cursor();
@@ -21749,7 +21749,7 @@ var init_zod = __esm(() => {
21749
21749
  init_external();
21750
21750
  });
21751
21751
 
21752
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+54fc8d7a745e138a/node_modules/@gobing-ai/ts-runtime/dist/config.js
21752
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+a819186233073392/node_modules/@gobing-ai/ts-runtime/dist/config.js
21753
21753
  function getProcessEnv() {
21754
21754
  return process.env;
21755
21755
  }
@@ -21827,7 +21827,7 @@ var init_config = __esm(() => {
21827
21827
  };
21828
21828
  });
21829
21829
 
21830
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+54fc8d7a745e138a/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
21830
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+a819186233073392/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
21831
21831
  import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
21832
21832
  import { dirname, resolve as resolvePath } from "path";
21833
21833
  function createNodeFileSystem(root, paths) {
@@ -21914,7 +21914,7 @@ function findProjectRoot(startDir) {
21914
21914
  }
21915
21915
  var init_file_system_node = () => {};
21916
21916
 
21917
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+54fc8d7a745e138a/node_modules/@gobing-ai/ts-runtime/dist/db-errors.js
21917
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+a819186233073392/node_modules/@gobing-ai/ts-runtime/dist/db-errors.js
21918
21918
  var DbModuleNotInstalledError;
21919
21919
  var init_db_errors = __esm(() => {
21920
21920
  DbModuleNotInstalledError = class DbModuleNotInstalledError extends Error {
@@ -29125,7 +29125,7 @@ var init_execa = __esm(() => {
29125
29125
  } = getIpcExport());
29126
29126
  });
29127
29127
 
29128
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+54fc8d7a745e138a/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
29128
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+a819186233073392/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
29129
29129
  import { isatty } from "tty";
29130
29130
  function processEventSeverity(reason, exitCode) {
29131
29131
  if (reason === "error")
@@ -29489,7 +29489,7 @@ var init_process_executor = __esm(() => {
29489
29489
  init_config();
29490
29490
  });
29491
29491
 
29492
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+54fc8d7a745e138a/node_modules/@gobing-ai/ts-runtime/dist/runtime-node-bun.js
29492
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+a819186233073392/node_modules/@gobing-ai/ts-runtime/dist/runtime-node-bun.js
29493
29493
  function getNodeFileSystem() {
29494
29494
  if (!_nodeFileSystem)
29495
29495
  _nodeFileSystem = createNodeFileSystem();
@@ -29549,7 +29549,7 @@ var init_runtime_node_bun = __esm(() => {
29549
29549
  };
29550
29550
  });
29551
29551
 
29552
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+54fc8d7a745e138a/node_modules/@gobing-ai/ts-runtime/dist/context.js
29552
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+a819186233073392/node_modules/@gobing-ai/ts-runtime/dist/context.js
29553
29553
  class RuntimeContext {
29554
29554
  scope;
29555
29555
  runtimeName;
@@ -29619,7 +29619,7 @@ var init_context = __esm(() => {
29619
29619
  init_runtime_node_bun();
29620
29620
  });
29621
29621
 
29622
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+54fc8d7a745e138a/node_modules/@gobing-ai/ts-runtime/dist/path.js
29622
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+a819186233073392/node_modules/@gobing-ai/ts-runtime/dist/path.js
29623
29623
  function normalizeSeparators(path6) {
29624
29624
  return path6.replaceAll("\\", "/");
29625
29625
  }
@@ -29680,17 +29680,17 @@ var init_path = __esm(() => {
29680
29680
  SEP = globalThis.process?.platform === "win32" ? "\\" : "/";
29681
29681
  });
29682
29682
 
29683
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+54fc8d7a745e138a/node_modules/@gobing-ai/ts-runtime/dist/schema-validation.js
29683
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+a819186233073392/node_modules/@gobing-ai/ts-runtime/dist/schema-validation.js
29684
29684
  var REMOTE_SCHEMA_MAX_BYTES;
29685
29685
  var init_schema_validation = __esm(() => {
29686
29686
  init_dist2();
29687
29687
  REMOTE_SCHEMA_MAX_BYTES = 5 * 1024 * 1024;
29688
29688
  });
29689
29689
 
29690
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+54fc8d7a745e138a/node_modules/@gobing-ai/ts-runtime/dist/types.js
29690
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+a819186233073392/node_modules/@gobing-ai/ts-runtime/dist/types.js
29691
29691
  var init_types = () => {};
29692
29692
 
29693
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+54fc8d7a745e138a/node_modules/@gobing-ai/ts-runtime/dist/index.js
29693
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+a819186233073392/node_modules/@gobing-ai/ts-runtime/dist/index.js
29694
29694
  var init_dist3 = __esm(() => {
29695
29695
  init_config();
29696
29696
  init_context();
@@ -29699,7 +29699,7 @@ var init_dist3 = __esm(() => {
29699
29699
  init_types();
29700
29700
  });
29701
29701
 
29702
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+54fc8d7a745e138a/node_modules/@gobing-ai/ts-runtime/dist/bun-sqlite.js
29702
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+a819186233073392/node_modules/@gobing-ai/ts-runtime/dist/bun-sqlite.js
29703
29703
  import { Database } from "bun:sqlite";
29704
29704
  var init_bun_sqlite = () => {};
29705
29705
 
@@ -33891,7 +33891,7 @@ var init_bun_sqlite2 = __esm(() => {
33891
33891
  init_session2();
33892
33892
  });
33893
33893
 
33894
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/schema/inbox-messages.js
33894
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/schema/inbox-messages.js
33895
33895
  var inboxMessages;
33896
33896
  var init_inbox_messages = __esm(() => {
33897
33897
  init_sqlite_core();
@@ -33910,7 +33910,7 @@ var init_inbox_messages = __esm(() => {
33910
33910
  }, (table2) => [index("idx_inbox_messages_to_status").on(table2.toId, table2.status)]);
33911
33911
  });
33912
33912
 
33913
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/schema/common.js
33913
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/schema/common.js
33914
33914
  function nowTimestamp() {
33915
33915
  return Date.now();
33916
33916
  }
@@ -33939,7 +33939,7 @@ var init_common3 = __esm(() => {
33939
33939
  appendOnlyColumns = buildAppendOnlyColumns();
33940
33940
  });
33941
33941
 
33942
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/schema/queue-jobs.js
33942
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/schema/queue-jobs.js
33943
33943
  var queueJobs;
33944
33944
  var init_queue_jobs = __esm(() => {
33945
33945
  init_sqlite_core();
@@ -33959,7 +33959,7 @@ var init_queue_jobs = __esm(() => {
33959
33959
  }, (table2) => [index("queue_jobs_ready_idx").on(table2.status, table2.nextRetryAt, table2.createdAt)]);
33960
33960
  });
33961
33961
 
33962
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/schema/runtime.js
33962
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/schema/runtime.js
33963
33963
  var exports_runtime = {};
33964
33964
  __export(exports_runtime, {
33965
33965
  queueJobs: () => queueJobs,
@@ -33970,7 +33970,7 @@ var init_runtime = __esm(() => {
33970
33970
  init_queue_jobs();
33971
33971
  });
33972
33972
 
33973
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/adapters/bun-sqlite.js
33973
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/adapters/bun-sqlite.js
33974
33974
  var exports_bun_sqlite = {};
33975
33975
  __export(exports_bun_sqlite, {
33976
33976
  BunSqliteAdapter: () => BunSqliteAdapter
@@ -34261,7 +34261,7 @@ var init_d1 = __esm(() => {
34261
34261
  init_session3();
34262
34262
  });
34263
34263
 
34264
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/adapters/d1.js
34264
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/adapters/d1.js
34265
34265
  var exports_d1 = {};
34266
34266
  __export(exports_d1, {
34267
34267
  D1Adapter: () => D1Adapter
@@ -34325,7 +34325,7 @@ var init_d12 = __esm(() => {
34325
34325
  init_runtime();
34326
34326
  });
34327
34327
 
34328
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/adapter.js
34328
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/adapter.js
34329
34329
  async function createDbAdapter(config3) {
34330
34330
  switch (config3.driver) {
34331
34331
  case "bun-sqlite": {
@@ -34365,7 +34365,7 @@ var init_drizzle_orm = __esm(() => {
34365
34365
  init_view_common();
34366
34366
  });
34367
34367
 
34368
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/query-spec.js
34368
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/query-spec.js
34369
34369
  function compilePredicate(predicate) {
34370
34370
  if ("and" in predicate) {
34371
34371
  const parts = predicate.and.map(compilePredicate).filter((p) => p !== undefined);
@@ -34403,7 +34403,7 @@ var init_query_spec = __esm(() => {
34403
34403
  };
34404
34404
  });
34405
34405
 
34406
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/base-dao.js
34406
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/base-dao.js
34407
34407
  function asSelectQuery(query) {
34408
34408
  return query;
34409
34409
  }
@@ -34445,7 +34445,7 @@ var init_base_dao = __esm(() => {
34445
34445
  init_query_spec();
34446
34446
  });
34447
34447
 
34448
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/embedded-migrations.js
34448
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/embedded-migrations.js
34449
34449
  var embeddedMigrations;
34450
34450
  var init_embedded_migrations = __esm(() => {
34451
34451
  embeddedMigrations = [
@@ -34477,7 +34477,7 @@ var init_embedded_migrations = __esm(() => {
34477
34477
  ];
34478
34478
  });
34479
34479
 
34480
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/entity-dao.js
34480
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/entity-dao.js
34481
34481
  var EntityDao;
34482
34482
  var init_entity_dao = __esm(() => {
34483
34483
  init_drizzle_orm();
@@ -34639,7 +34639,7 @@ var init_entity_dao = __esm(() => {
34639
34639
  };
34640
34640
  });
34641
34641
 
34642
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/inbox-message-dao.js
34642
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/inbox-message-dao.js
34643
34643
  function isPromiseLike(value) {
34644
34644
  return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
34645
34645
  }
@@ -34817,7 +34817,7 @@ var init_migrator2 = __esm(() => {
34817
34817
  init_migrator();
34818
34818
  });
34819
34819
 
34820
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/migrate.js
34820
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/migrate.js
34821
34821
  async function ensureJournalTable(adapter, table3) {
34822
34822
  await adapter.exec(`CREATE TABLE IF NOT EXISTS "${table3}" (` + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "hash text NOT NULL, " + "created_at numeric" + ")");
34823
34823
  }
@@ -34892,7 +34892,7 @@ var init_migrate = __esm(() => {
34892
34892
  init_embedded_migrations();
34893
34893
  });
34894
34894
 
34895
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/queue-job-dao.js
34895
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/queue-job-dao.js
34896
34896
  var QueueJobDao;
34897
34897
  var init_queue_job_dao = __esm(() => {
34898
34898
  init_drizzle_orm();
@@ -35033,7 +35033,7 @@ var init_queue_job_dao = __esm(() => {
35033
35033
  };
35034
35034
  });
35035
35035
 
35036
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/index.js
35036
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/index.js
35037
35037
  var exports_dist = {};
35038
35038
  __export(exports_dist, {
35039
35039
  embeddedMigrations: () => embeddedMigrations,
@@ -37519,7 +37519,7 @@ var init_src = __esm(() => {
37519
37519
  });
37520
37520
  });
37521
37521
 
37522
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/config.js
37522
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/config.js
37523
37523
  function parseYamlObject(text3) {
37524
37524
  let parsed;
37525
37525
  try {
@@ -37646,7 +37646,7 @@ var init_config2 = __esm(() => {
37646
37646
  };
37647
37647
  });
37648
37648
 
37649
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
37649
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
37650
37650
  import { appendFileSync as appendFileSync3, cpSync as cpSync2, createReadStream as createReadStream3, createWriteStream as createWriteStream3, existsSync as existsSync2, mkdirSync as mkdirSync2, readdirSync as readdirSync2, readFileSync as readFileSync4, realpathSync as realpathSync2, renameSync as renameSync2, rmSync as rmSync2, statSync as statSync3, writeFileSync as writeFileSync3 } from "fs";
37651
37651
  import { dirname as dirname2, resolve as resolvePath3 } from "path";
37652
37652
  function createNodeFileSystem3(root, paths) {
@@ -37733,7 +37733,7 @@ function findProjectRoot3(startDir) {
37733
37733
  }
37734
37734
  var init_file_system_node2 = () => {};
37735
37735
 
37736
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/db-errors.js
37736
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/db-errors.js
37737
37737
  var D1NotConfiguredError2, DbModuleNotInstalledError3;
37738
37738
  var init_db_errors2 = __esm(() => {
37739
37739
  D1NotConfiguredError2 = class D1NotConfiguredError2 extends Error {
@@ -37750,7 +37750,7 @@ var init_db_errors2 = __esm(() => {
37750
37750
  };
37751
37751
  });
37752
37752
 
37753
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/file-system-cf.js
37753
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/file-system-cf.js
37754
37754
  function createCfFileSystem2() {
37755
37755
  return {
37756
37756
  getProjectRoot: () => "/bundle",
@@ -37789,7 +37789,7 @@ function createCfFileSystem2() {
37789
37789
  }
37790
37790
  var UNSUPPORTED = "FileSystem is not available on Cloudflare Workers. Use D1, KV, or R2 for persistent storage.";
37791
37791
 
37792
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/runtime-cf.js
37792
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/runtime-cf.js
37793
37793
  var exports_runtime_cf = {};
37794
37794
  __export(exports_runtime_cf, {
37795
37795
  cloudflareWorkersFactory: () => cloudflareWorkersFactory2
@@ -37827,7 +37827,7 @@ var init_runtime_cf = __esm(() => {
37827
37827
  };
37828
37828
  });
37829
37829
 
37830
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
37830
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
37831
37831
  import { isatty as isatty2 } from "tty";
37832
37832
  function processEventSeverity2(reason, exitCode) {
37833
37833
  if (reason === "error")
@@ -38238,7 +38238,7 @@ var init_process_executor2 = __esm(() => {
38238
38238
  ProcessExecutor2 = NodeProcessExecutor3;
38239
38239
  });
38240
38240
 
38241
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/runtime-node-bun.js
38241
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/runtime-node-bun.js
38242
38242
  var exports_runtime_node_bun = {};
38243
38243
  __export(exports_runtime_node_bun, {
38244
38244
  nodeBunFactory: () => nodeBunFactory3,
@@ -38306,7 +38306,7 @@ var init_runtime_node_bun2 = __esm(() => {
38306
38306
  };
38307
38307
  });
38308
38308
 
38309
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/platform.js
38309
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/platform.js
38310
38310
  function isCloudflareWorkerRuntime2() {
38311
38311
  return globalThis.navigator?.userAgent?.startsWith("Cloudflare-Workers") ?? false;
38312
38312
  }
@@ -38336,7 +38336,7 @@ function _resetRuntimeFactory2() {
38336
38336
  }
38337
38337
  var _factory, _runtimeName;
38338
38338
 
38339
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/context.js
38339
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/context.js
38340
38340
  class RuntimeContext2 {
38341
38341
  scope;
38342
38342
  runtimeName;
@@ -38426,7 +38426,7 @@ var init_context2 = __esm(() => {
38426
38426
  init_runtime_node_bun2();
38427
38427
  });
38428
38428
 
38429
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/path.js
38429
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/path.js
38430
38430
  function normalizeSeparators2(path7) {
38431
38431
  return path7.replaceAll("\\", "/");
38432
38432
  }
@@ -38549,7 +38549,7 @@ var init_path2 = __esm(() => {
38549
38549
  SEP2 = globalThis.process?.platform === "win32" ? "\\" : "/";
38550
38550
  });
38551
38551
 
38552
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/fs.js
38552
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/fs.js
38553
38553
  async function ensureDirForFile2(path7, fs2 = createNodeFileSystem3()) {
38554
38554
  await fs2.ensureDir(dirnamePath(path7));
38555
38555
  }
@@ -38617,7 +38617,7 @@ var init_fs = __esm(() => {
38617
38617
  init_path2();
38618
38618
  });
38619
38619
 
38620
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/process-registry.js
38620
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/process-registry.js
38621
38621
  function allocateId() {
38622
38622
  nextIdSeq += 1;
38623
38623
  return `pe_${Date.now().toString(36)}_${nextIdSeq.toString(36)}`;
@@ -38741,7 +38741,7 @@ function createInMemoryProcessRegistry2(options) {
38741
38741
  }
38742
38742
  var nextIdSeq = 0;
38743
38743
 
38744
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/runtime-paths.js
38744
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/runtime-paths.js
38745
38745
  function ambientRuntimePaths2() {
38746
38746
  const cwd = getProcessCwd2();
38747
38747
  return { cwd, home: getHomeDir() ?? cwd };
@@ -38751,7 +38751,7 @@ var init_runtime_paths = __esm(() => {
38751
38751
  init_path2();
38752
38752
  });
38753
38753
 
38754
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/schema-validation.js
38754
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/schema-validation.js
38755
38755
  async function loadStructuredConfig(path7, options = {}) {
38756
38756
  const content = await (options.fileSystem ?? createNodeFileSystem3()).readFile(path7);
38757
38757
  return await parseStructuredConfig(content, path7, options);
@@ -39034,10 +39034,10 @@ var init_schema_validation2 = __esm(() => {
39034
39034
  defaultResolve = typeof Bun !== "undefined" ? (specifier, from) => Bun.resolveSync(specifier, from) : undefined;
39035
39035
  });
39036
39036
 
39037
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/types.js
39037
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/types.js
39038
39038
  var init_types2 = () => {};
39039
39039
 
39040
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/index.js
39040
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/index.js
39041
39041
  var exports_dist2 = {};
39042
39042
  __export(exports_dist2, {
39043
39043
  writeJsonFile: () => writeJsonFile2,
@@ -41188,7 +41188,7 @@ var init_mod = __esm(() => {
41188
41188
  init_config3();
41189
41189
  });
41190
41190
 
41191
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/logger.js
41191
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/logger.js
41192
41192
  function toLogTapeLevel(level) {
41193
41193
  return level === "warn" ? "warning" : level;
41194
41194
  }
@@ -42741,7 +42741,7 @@ var require_src = __commonJS((exports) => {
42741
42741
  };
42742
42742
  });
42743
42743
 
42744
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/telemetry/sdk.js
42744
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/telemetry/sdk.js
42745
42745
  function getTelemetryConfig(configPartial = {}) {
42746
42746
  return {
42747
42747
  enabled: configPartial.enabled ?? CONFIG_DEFAULTS.enabled,
@@ -42777,7 +42777,7 @@ var init_sdk = __esm(() => {
42777
42777
  resolvedConfig = getTelemetryConfig();
42778
42778
  });
42779
42779
 
42780
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/telemetry/tracing.js
42780
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/telemetry/tracing.js
42781
42781
  function isSuppressed(tracer2) {
42782
42782
  return tracer2 === undefined && !getResolvedConfig().enabled;
42783
42783
  }
@@ -42817,7 +42817,7 @@ var init_tracing2 = __esm(() => {
42817
42817
  import_api2 = __toESM(require_src(), 1);
42818
42818
  });
42819
42819
 
42820
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/telemetry/metrics.js
42820
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/telemetry/metrics.js
42821
42821
  function getMeter() {
42822
42822
  return import_api3.metrics.getMeter(METER_NAME, METER_VERSION);
42823
42823
  }
@@ -42914,7 +42914,7 @@ var init_metrics = __esm(() => {
42914
42914
  instruments = {};
42915
42915
  });
42916
42916
 
42917
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/event-bus/event-bus.js
42917
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/event-bus/event-bus.js
42918
42918
  function busLogger() {
42919
42919
  if (!_busLogger)
42920
42920
  _busLogger = getLogger2("event-bus");
@@ -43167,7 +43167,7 @@ var init_event_bus = __esm(() => {
43167
43167
  init_metrics();
43168
43168
  });
43169
43169
 
43170
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/event-bus/default-observers.js
43170
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/event-bus/default-observers.js
43171
43171
  function obsLogger() {
43172
43172
  if (!_obsLogger)
43173
43173
  _obsLogger = getLogger2("event-bus.observers");
@@ -43231,7 +43231,7 @@ var init_default_observers = __esm(() => {
43231
43231
  init_event_bus();
43232
43232
  });
43233
43233
 
43234
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/event-bus/file-observer.js
43234
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/event-bus/file-observer.js
43235
43235
  function parentDir(filePath) {
43236
43236
  const idx = filePath.lastIndexOf("/");
43237
43237
  return idx <= 0 ? "." : filePath.slice(0, idx);
@@ -43329,7 +43329,7 @@ var init_file_observer = __esm(() => {
43329
43329
  init_logger3();
43330
43330
  });
43331
43331
 
43332
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/internals/drain.js
43332
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/internals/drain.js
43333
43333
  function settleWithin(promise2, deadline) {
43334
43334
  const remaining = deadline - Date.now();
43335
43335
  if (remaining <= 0)
@@ -43344,7 +43344,7 @@ function settleWithin(promise2, deadline) {
43344
43344
  return settled;
43345
43345
  }
43346
43346
 
43347
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/scheduler/node.js
43347
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/scheduler/node.js
43348
43348
  function parseInterval(cron) {
43349
43349
  const trimmed = cron.trim();
43350
43350
  const num = Number(trimmed);
@@ -43438,7 +43438,7 @@ var init_node3 = __esm(() => {
43438
43438
  init_metrics();
43439
43439
  });
43440
43440
 
43441
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/scheduler-node.js
43441
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/scheduler-node.js
43442
43442
  var exports_scheduler_node = {};
43443
43443
  __export(exports_scheduler_node, {
43444
43444
  NodeSchedulerAdapter: () => NodeSchedulerAdapter
@@ -51909,7 +51909,7 @@ var init_drizzle_zod = __esm(() => {
51909
51909
  };
51910
51910
  });
51911
51911
 
51912
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/schema/drizzle-internals.js
51912
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/schema/drizzle-internals.js
51913
51913
  function sqlExpressionToText(value) {
51914
51914
  if (typeof value !== "object" || value === null || !("queryChunks" in value)) {
51915
51915
  return;
@@ -51932,7 +51932,7 @@ function getDrizzleTableName(table3) {
51932
51932
  return String(table3[nameSym]);
51933
51933
  }
51934
51934
 
51935
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/schema/ddl.js
51935
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/schema/ddl.js
51936
51936
  function quoteIdent(name) {
51937
51937
  return `"${name.replace(/"/g, '""')}"`;
51938
51938
  }
@@ -52026,7 +52026,7 @@ var init_ddl = __esm(() => {
52026
52026
  init_sqlite_core();
52027
52027
  });
52028
52028
 
52029
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/schema/define-table.js
52029
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/schema/define-table.js
52030
52030
  function defineTable(name, columns2) {
52031
52031
  const table3 = sqliteTable(name, columns2);
52032
52032
  let insert2;
@@ -52060,7 +52060,7 @@ var init_define_table = __esm(() => {
52060
52060
  init_ddl();
52061
52061
  });
52062
52062
 
52063
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.30+5312b088c68fcacf/node_modules/@gobing-ai/ts-db/dist/schema/index.js
52063
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.31+ebf6a30dac66d8ea/node_modules/@gobing-ai/ts-db/dist/schema/index.js
52064
52064
  var init_schema = __esm(() => {
52065
52065
  init_sqlite_core();
52066
52066
  init_define_table();
@@ -52143,6 +52143,61 @@ var init_artifact_dao = __esm(() => {
52143
52143
  };
52144
52144
  });
52145
52145
 
52146
+ // ../../packages/domain/src/dao/coordination-run-dao.ts
52147
+ class CoordinationRunDao {
52148
+ db;
52149
+ constructor(db2) {
52150
+ this.db = db2;
52151
+ }
52152
+ async insertStart(input) {
52153
+ await this.db.run(`INSERT INTO coordination_runs
52154
+ (spec_id, agent_kind, process_id, run_id, generation, status, started_at, completed_at, artifact_refs_json)
52155
+ VALUES (?, ?, ?, ?, ?, 'running', ?, NULL, '[]')`, input.specId, input.agentKind, input.processId, input.runId, input.generation, input.startedAt);
52156
+ }
52157
+ async updateExit(runId, status, completedAt, artifactRefsJson) {
52158
+ await this.db.run(`UPDATE coordination_runs SET status = ?, completed_at = ?, artifact_refs_json = ? WHERE run_id = ?`, status, completedAt, artifactRefsJson, runId);
52159
+ }
52160
+ async getByRunId(runId) {
52161
+ try {
52162
+ return await this.db.queryFirst(`SELECT spec_id, agent_kind, process_id, run_id, generation, status, started_at, completed_at, artifact_refs_json
52163
+ FROM coordination_runs WHERE run_id = ?`, runId) ?? null;
52164
+ } catch (error51) {
52165
+ if (error51 instanceof Error && error51.message.includes("no such table: coordination_runs")) {
52166
+ return null;
52167
+ }
52168
+ throw error51;
52169
+ }
52170
+ }
52171
+ async getLatestBySpecId(specId) {
52172
+ try {
52173
+ return await this.db.queryFirst(`SELECT spec_id, agent_kind, process_id, run_id, generation, status, started_at, completed_at, artifact_refs_json
52174
+ FROM coordination_runs
52175
+ WHERE spec_id = ?
52176
+ ORDER BY generation DESC, started_at DESC
52177
+ LIMIT 1`, specId) ?? null;
52178
+ } catch (error51) {
52179
+ if (error51 instanceof Error && error51.message.includes("no such table: coordination_runs")) {
52180
+ return null;
52181
+ }
52182
+ throw error51;
52183
+ }
52184
+ }
52185
+ async maxGeneration(specId) {
52186
+ try {
52187
+ const row = await this.db.queryFirst("SELECT MAX(generation) AS g FROM coordination_runs WHERE spec_id = ?", specId);
52188
+ return row?.g ?? null;
52189
+ } catch (error51) {
52190
+ if (error51 instanceof Error && error51.message.includes("no such table: coordination_runs")) {
52191
+ return null;
52192
+ }
52193
+ throw error51;
52194
+ }
52195
+ }
52196
+ async deleteAll() {
52197
+ await this.db.run("DELETE FROM coordination_runs");
52198
+ }
52199
+ }
52200
+
52146
52201
  // ../../packages/domain/src/dao/inbox-recent-dao.ts
52147
52202
  class InboxRecentDao {
52148
52203
  db;
@@ -52435,7 +52490,9 @@ class SystemEventDao {
52435
52490
  }
52436
52491
  async insert(input) {
52437
52492
  await this.db.run(`INSERT INTO system_events (${SYSTEM_EVENT_COLUMNS})
52438
- VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)`, input.id, input.event_name, input.occurred_at, input.actor ?? null, input.payload_json ?? null, input.run_id ?? null, input.entity_kind ?? null, input.entity_id ?? null, input.sequence ?? null);
52493
+ SELECT ?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8,
52494
+ CASE WHEN ?9 IS NULL THEN COALESCE(MAX(sequence), 0) + 1 ELSE ?9 END
52495
+ FROM system_events`, input.id, input.event_name, input.occurred_at, input.actor ?? null, input.payload_json ?? null, input.run_id ?? null, input.entity_kind ?? null, input.entity_id ?? null, input.sequence ?? null);
52439
52496
  }
52440
52497
  async pruneQuotas(quotas, prefix) {
52441
52498
  try {
@@ -52520,6 +52577,20 @@ class SystemEventDao {
52520
52577
  throw error51;
52521
52578
  }
52522
52579
  }
52580
+ async follow(afterSequence, limit = 100) {
52581
+ try {
52582
+ return await this.db.queryAll(`SELECT ${SYSTEM_EVENT_COLUMNS}
52583
+ FROM system_events
52584
+ WHERE sequence > ?1
52585
+ ORDER BY sequence ASC, id ASC
52586
+ LIMIT ?2`, afterSequence, limit);
52587
+ } catch (error51) {
52588
+ if (error51 instanceof Error && error51.message.includes("no such table: system_events")) {
52589
+ return [];
52590
+ }
52591
+ throw error51;
52592
+ }
52593
+ }
52523
52594
  async deleteAll() {
52524
52595
  await this.db.run("DELETE FROM system_events");
52525
52596
  }
@@ -52685,7 +52756,7 @@ var init_dao = __esm(() => {
52685
52756
  init_workspace_dao();
52686
52757
  });
52687
52758
 
52688
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/errors.js
52759
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/errors.js
52689
52760
  var WorkflowValidationError, FSMError, RunCollisionError, WorkflowResumeError;
52690
52761
  var init_errors6 = __esm(() => {
52691
52762
  WorkflowValidationError = class WorkflowValidationError extends Error {
@@ -52720,12 +52791,12 @@ var init_errors6 = __esm(() => {
52720
52791
  };
52721
52792
  });
52722
52793
 
52723
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/event-bus/index.js
52794
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/event-bus/index.js
52724
52795
  var init_event_bus2 = __esm(() => {
52725
52796
  init_event_bus();
52726
52797
  });
52727
52798
 
52728
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/api-client.js
52799
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/api-client.js
52729
52800
  function sanitizeUrlForObservability(url2) {
52730
52801
  try {
52731
52802
  const parsed = new URL(url2);
@@ -52956,12 +53027,12 @@ var init_api_client = __esm(() => {
52956
53027
  };
52957
53028
  });
52958
53029
 
52959
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/telemetry/index.js
53030
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/telemetry/index.js
52960
53031
  var init_telemetry = __esm(() => {
52961
53032
  init_tracing2();
52962
53033
  });
52963
53034
 
52964
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/index.js
53035
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/index.js
52965
53036
  var init_dist6 = __esm(() => {
52966
53037
  init_api_client();
52967
53038
  init_event_bus2();
@@ -52969,7 +53040,7 @@ var init_dist6 = __esm(() => {
52969
53040
  init_telemetry();
52970
53041
  });
52971
53042
 
52972
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/run-lifecycle.js
53043
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/run-lifecycle.js
52973
53044
  function runtimeBuiltins(workflowName, stateOrNodeId, runId, transitionsTaken, mode) {
52974
53045
  return {
52975
53046
  workflow: workflowName,
@@ -53253,9 +53324,101 @@ var init_run_lifecycle = __esm(() => {
53253
53324
  ];
53254
53325
  });
53255
53326
 
53256
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/schema.js
53257
- var RESERVED_VAR_NAMES, IDENTIFIER, VarsSchema, EnvSchema, ActionDefSchema, GuardDefSchema, StateMachineWorkflowDefSchema, TransitionFlowWorkflowDefSchema, WorkflowDefSchema;
53327
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/extension/capability-registry.js
53328
+ class CapabilityRegistry {
53329
+ kind;
53330
+ capabilities = new Map;
53331
+ constructor(kind) {
53332
+ this.kind = kind;
53333
+ }
53334
+ register(name, capability, origin2 = "extension") {
53335
+ this.capabilities.set(name, { capability, origin: origin2 });
53336
+ }
53337
+ has(name) {
53338
+ return this.capabilities.has(name);
53339
+ }
53340
+ get(name) {
53341
+ const entry = this.capabilities.get(name);
53342
+ if (entry === undefined) {
53343
+ throw new Error(`Unknown ${this.kind}: ${name}`);
53344
+ }
53345
+ return entry.capability;
53346
+ }
53347
+ getEntry(name) {
53348
+ return this.capabilities.get(name);
53349
+ }
53350
+ list() {
53351
+ return [...this.capabilities.keys()];
53352
+ }
53353
+ entries() {
53354
+ return [...this.capabilities.entries()];
53355
+ }
53356
+ }
53357
+
53358
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/extension/extension-path.js
53359
+ function assertRelativeExtensionPath(path9, options = {}) {
53360
+ const where = options.sourceName !== undefined ? ` declared by "${options.sourceName}"` : "";
53361
+ if (/^([/\\]|[A-Za-z]:[/\\])/.test(path9)) {
53362
+ throw new Error(`extension path "${path9}"${where} must be relative (no absolute paths)`);
53363
+ }
53364
+ if (path9.split(/[/\\]/).includes("..")) {
53365
+ throw new Error(`extension path "${path9}"${where} must not contain ".." traversal`);
53366
+ }
53367
+ }
53368
+
53369
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/extension/extension-loader.js
53370
+ import { isAbsolute, resolve } from "path";
53371
+ async function loadExtensionModules(refs, options, register) {
53372
+ if (refs.length === 0)
53373
+ return;
53374
+ if (options.allowExtensions !== true) {
53375
+ const first = refs[0];
53376
+ throw new Error(`"${first.sourceName}" declares ${first.kind} extension "${first.path}", but extensions are disabled \u2014 pass allowExtensions: true to load extension modules`);
53377
+ }
53378
+ for (const ref of refs) {
53379
+ if (!isAbsolute(ref.baseDir)) {
53380
+ throw new Error(`"${ref.sourceName}" extension baseDir "${ref.baseDir}" must be an absolute directory`);
53381
+ }
53382
+ assertRelativeExtensionPath(ref.path, { sourceName: ref.sourceName });
53383
+ const absPath = resolve(ref.baseDir, ref.path);
53384
+ if (options.realPath) {
53385
+ let realAbs;
53386
+ let realBase;
53387
+ try {
53388
+ realAbs = options.realPath(absPath);
53389
+ realBase = options.realPath(ref.baseDir);
53390
+ } catch (error51) {
53391
+ const reason = error51 instanceof Error ? error51.message : String(error51);
53392
+ throw new Error(`"${ref.sourceName}" extension "${ref.path}" cannot be canonicalized: ${reason}`);
53393
+ }
53394
+ if (realAbs !== realBase && !realAbs.startsWith(`${realBase}/`) && !realAbs.startsWith(`${realBase}\\`)) {
53395
+ throw new Error(`"${ref.sourceName}" extension "${ref.path}" resolves outside baseDir via symlink (real: "${realAbs}", base: "${realBase}") \u2014 refusing to load`);
53396
+ }
53397
+ }
53398
+ const moduleExports = await options.moduleLoader(absPath);
53399
+ const candidate = moduleExports.default ?? moduleExports.extension;
53400
+ if (candidate === null || typeof candidate !== "object" || typeof candidate.name !== "string") {
53401
+ throw new Error(`"${ref.sourceName}" extension "${ref.path}" must export an object with a string "name"`);
53402
+ }
53403
+ await register(ref, candidate);
53404
+ }
53405
+ }
53406
+ var init_extension_loader = () => {};
53407
+
53408
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/extension/index.js
53409
+ var init_extension = __esm(() => {
53410
+ init_extension_loader();
53411
+ });
53412
+
53413
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.31+c9a2e8ac7fd37b34/node_modules/@gobing-ai/ts-runtime/dist/extension.js
53414
+ var init_extension2 = __esm(() => {
53415
+ init_extension();
53416
+ });
53417
+
53418
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/schema.js
53419
+ var RESERVED_VAR_NAMES, IDENTIFIER, VarsSchema, EnvSchema, relativeExtensionPath, WorkflowExtensionsSchema, ActionDefSchema, GuardDefSchema, StateMachineWorkflowDefSchema, TransitionFlowWorkflowDefSchema, WorkflowDefSchema;
53258
53420
  var init_schema2 = __esm(() => {
53421
+ init_extension2();
53259
53422
  init_zod();
53260
53423
  RESERVED_VAR_NAMES = new Set(["task", "state", "node", "iteration", "run", "runtime"]);
53261
53424
  IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
@@ -53272,6 +53435,20 @@ var init_schema2 = __esm(() => {
53272
53435
  EnvSchema = exports_external.object({
53273
53436
  allow: exports_external.array(exports_external.string().regex(IDENTIFIER, "env.allow entries must be valid identifiers")).optional()
53274
53437
  });
53438
+ relativeExtensionPath = exports_external.string().min(1).superRefine((value, ctx) => {
53439
+ try {
53440
+ assertRelativeExtensionPath(value);
53441
+ } catch (error51) {
53442
+ ctx.addIssue({
53443
+ code: "custom",
53444
+ message: error51 instanceof Error ? error51.message : "invalid extension path"
53445
+ });
53446
+ }
53447
+ });
53448
+ WorkflowExtensionsSchema = exports_external.object({
53449
+ actions: exports_external.array(relativeExtensionPath).optional(),
53450
+ guards: exports_external.array(relativeExtensionPath).optional()
53451
+ }).strict();
53275
53452
  ActionDefSchema = exports_external.object({
53276
53453
  kind: exports_external.string().min(1),
53277
53454
  options: exports_external.record(exports_external.string(), exports_external.unknown()).optional(),
@@ -53307,7 +53484,8 @@ var init_schema2 = __esm(() => {
53307
53484
  description: exports_external.string().optional(),
53308
53485
  trigger: exports_external.string().optional(),
53309
53486
  guard: GuardDefSchema.optional()
53310
- }).strict())
53487
+ }).strict()),
53488
+ extensions: WorkflowExtensionsSchema.optional()
53311
53489
  }).strict();
53312
53490
  TransitionFlowWorkflowDefSchema = exports_external.object({
53313
53491
  $schema: exports_external.string().optional(),
@@ -53333,12 +53511,13 @@ var init_schema2 = __esm(() => {
53333
53511
  to: exports_external.string().min(1),
53334
53512
  description: exports_external.string().optional(),
53335
53513
  condition: GuardDefSchema.optional()
53336
- }).strict())
53514
+ }).strict()),
53515
+ extensions: WorkflowExtensionsSchema.optional()
53337
53516
  }).strict();
53338
53517
  WorkflowDefSchema = exports_external.union([StateMachineWorkflowDefSchema, TransitionFlowWorkflowDefSchema]);
53339
53518
  });
53340
53519
 
53341
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/config.js
53520
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/config.js
53342
53521
  async function loadWorkflowDef(path9, options = {}) {
53343
53522
  return parseWorkflowDef(await loadStructuredConfig(path9, options), path9);
53344
53523
  }
@@ -53505,62 +53684,71 @@ var init_config4 = __esm(() => {
53505
53684
  RUNTIME_TEMPLATE_NAMESPACES = new Set(RUNTIME_BUILTIN_KEYS);
53506
53685
  });
53507
53686
 
53508
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/extension/capability-registry.js
53509
- class CapabilityRegistry {
53510
- kind;
53511
- capabilities = new Map;
53512
- constructor(kind) {
53513
- this.kind = kind;
53514
- }
53515
- register(name, capability, origin2 = "extension") {
53516
- this.capabilities.set(name, { capability, origin: origin2 });
53517
- }
53518
- has(name) {
53519
- return this.capabilities.has(name);
53520
- }
53521
- get(name) {
53522
- const entry = this.capabilities.get(name);
53523
- if (entry === undefined) {
53524
- throw new Error(`Unknown ${this.kind}: ${name}`);
53687
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/extensions.js
53688
+ function collectWorkflowExtensions(sourceName, sourceDir, extensions) {
53689
+ if (extensions === undefined)
53690
+ return [];
53691
+ const refs = [];
53692
+ for (const kind of ["actions", "guards"]) {
53693
+ for (const path9 of extensions[kind] ?? []) {
53694
+ refs.push({ kind, sourceName, path: path9, baseDir: sourceDir });
53525
53695
  }
53526
- return entry.capability;
53527
- }
53528
- getEntry(name) {
53529
- return this.capabilities.get(name);
53530
- }
53531
- list() {
53532
- return [...this.capabilities.keys()];
53533
- }
53534
- entries() {
53535
- return [...this.capabilities.entries()];
53536
53696
  }
53697
+ return refs;
53537
53698
  }
53538
-
53539
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/extension/extension-path.js
53540
- function assertRelativeExtensionPath(path9, options = {}) {
53541
- const where = options.sourceName !== undefined ? ` declared by "${options.sourceName}"` : "";
53542
- if (/^([/\\]|[A-Za-z]:[/\\])/.test(path9)) {
53543
- throw new Error(`extension path "${path9}"${where} must be relative (no absolute paths)`);
53699
+ async function loadWorkflowExtensionsIntoHost(host, refs, options) {
53700
+ if (refs.length === 0)
53701
+ return;
53702
+ const sharedRefs = refs.map((ref) => ({
53703
+ kind: ref.kind,
53704
+ path: ref.path,
53705
+ baseDir: ref.baseDir,
53706
+ sourceName: ref.sourceName
53707
+ }));
53708
+ const sharedOptions = {
53709
+ allowExtensions: options.allowExtensions,
53710
+ logger: options.logger,
53711
+ moduleLoader: options.moduleLoader,
53712
+ realPath: options.realPath
53713
+ };
53714
+ await loadExtensionModules(sharedRefs, sharedOptions, async (sharedRef, extension2) => {
53715
+ await registerExtensionOnHost(host, sharedRef, extension2, options.logger);
53716
+ });
53717
+ }
53718
+ async function registerExtensionOnHost(host, ref, extension2, logger2) {
53719
+ const name = extension2.name;
53720
+ if (ref.kind === "actions") {
53721
+ const actions = extension2.actions;
53722
+ if (!Array.isArray(actions)) {
53723
+ throw new WorkflowValidationError(`"${ref.sourceName}" extension "${name}" is referenced as kind "actions" but does not export an actions[] array`);
53724
+ }
53725
+ for (const action of actions) {
53726
+ warnIfOverride(host, action.kind, "action", ref.sourceName, logger2);
53727
+ host.registerAction(action, "extension");
53728
+ }
53729
+ } else {
53730
+ const guards = extension2.guards;
53731
+ if (!Array.isArray(guards)) {
53732
+ throw new WorkflowValidationError(`"${ref.sourceName}" extension "${name}" is referenced as kind "guards" but does not export a guards[] array`);
53733
+ }
53734
+ for (const guard of guards) {
53735
+ warnIfOverride(host, guard.kind, "guard", ref.sourceName, logger2);
53736
+ host.registerGuard(guard, "extension");
53737
+ }
53544
53738
  }
53545
- if (path9.split(/[/\\]/).includes("..")) {
53546
- throw new Error(`extension path "${path9}"${where} must not contain ".." traversal`);
53739
+ }
53740
+ function warnIfOverride(host, kind, capabilityType, sourceName, logger2) {
53741
+ const origin2 = capabilityType === "action" ? host.actionOrigin(kind) : host.guardOrigin(kind);
53742
+ if (logger2 && origin2 === "builtin") {
53743
+ logger2.warn(`"${sourceName}" extension overrides built-in ${capabilityType} "${kind}"`);
53547
53744
  }
53548
53745
  }
53549
-
53550
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/extension/extension-loader.js
53551
- var init_extension_loader = () => {};
53552
-
53553
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/extension/index.js
53554
- var init_extension = __esm(() => {
53555
- init_extension_loader();
53556
- });
53557
-
53558
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.30+396850f04496a471/node_modules/@gobing-ai/ts-runtime/dist/extension.js
53559
- var init_extension2 = __esm(() => {
53560
- init_extension();
53746
+ var init_extensions = __esm(() => {
53747
+ init_extension2();
53748
+ init_errors6();
53561
53749
  });
53562
53750
 
53563
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/host.js
53751
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/host.js
53564
53752
  class WorkflowEngineHost {
53565
53753
  lifecycleBus;
53566
53754
  actions = new CapabilityRegistry("workflow action");
@@ -53730,7 +53918,7 @@ var init_host = __esm(() => {
53730
53918
  init_errors6();
53731
53919
  });
53732
53920
 
53733
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/schema-sql.js
53921
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/schema-sql.js
53734
53922
  var WORKFLOW_ENGINE_SCHEMA_SQL;
53735
53923
  var init_schema_sql = __esm(() => {
53736
53924
  WORKFLOW_ENGINE_SCHEMA_SQL = `
@@ -53803,7 +53991,7 @@ CREATE TABLE IF NOT EXISTS action_runs (
53803
53991
  `.trim();
53804
53992
  });
53805
53993
 
53806
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/persistence.js
53994
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/persistence.js
53807
53995
  async function applyWorkflowEngineSchema(db2) {
53808
53996
  for (const statement of WORKFLOW_ENGINE_SCHEMA_SQL.split(";")) {
53809
53997
  const sql4 = statement.trim();
@@ -54119,7 +54307,7 @@ var init_persistence = __esm(() => {
54119
54307
  init_schema_sql();
54120
54308
  });
54121
54309
 
54122
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/variables.js
54310
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/variables.js
54123
54311
  function mergeVars(workflowVars = {}, overrideVars = {}) {
54124
54312
  return { ...workflowVars, ...overrideVars };
54125
54313
  }
@@ -54179,7 +54367,7 @@ var init_variables = __esm(() => {
54179
54367
  TEMPLATE_REF = /\$\{([^}]+)\}/g;
54180
54368
  });
54181
54369
 
54182
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/action-step.js
54370
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/action-step.js
54183
54371
  async function runActionStep(action, vars, deps) {
54184
54372
  const { host, persistence, lifecycle, stateOrNodeId, runId } = deps;
54185
54373
  const resolved = resolveTemplates(action.options ?? {}, {
@@ -54238,7 +54426,7 @@ var init_action_step = __esm(() => {
54238
54426
  init_variables();
54239
54427
  });
54240
54428
 
54241
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/state-machine.js
54429
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/state-machine.js
54242
54430
  class StateMachineDriver {
54243
54431
  options;
54244
54432
  constructor(options) {
@@ -54374,7 +54562,7 @@ var init_state_machine = __esm(() => {
54374
54562
  EMPTY_OUTCOME = { outcome: "completed", result: undefined };
54375
54563
  });
54376
54564
 
54377
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/transition-flow.js
54565
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/transition-flow.js
54378
54566
  class TransitionFlowDriver {
54379
54567
  options;
54380
54568
  constructor(options) {
@@ -54493,7 +54681,7 @@ var init_transition_flow = __esm(() => {
54493
54681
  init_variables();
54494
54682
  });
54495
54683
 
54496
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/service.js
54684
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/service.js
54497
54685
  class WorkflowService {
54498
54686
  host;
54499
54687
  persistence;
@@ -54614,8 +54802,8 @@ class WorkflowService {
54614
54802
  async requestTransition(workflow, runId, toState, options) {
54615
54803
  let release;
54616
54804
  const previous = this.runLocks.get(runId) ?? Promise.resolve();
54617
- const next = previous.then(() => new Promise((resolve) => {
54618
- release = resolve;
54805
+ const next = previous.then(() => new Promise((resolve2) => {
54806
+ release = resolve2;
54619
54807
  }));
54620
54808
  this.runLocks.set(runId, next);
54621
54809
  await previous;
@@ -54718,16 +54906,17 @@ var init_service = __esm(() => {
54718
54906
  init_variables();
54719
54907
  });
54720
54908
 
54721
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/index.js
54909
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/index.js
54722
54910
  var init_dist7 = __esm(() => {
54723
54911
  init_config4();
54912
+ init_extensions();
54724
54913
  init_host();
54725
54914
  init_persistence();
54726
54915
  init_schema_sql();
54727
54916
  init_service();
54728
54917
  });
54729
54918
 
54730
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.30+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/hash.js
54919
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.31+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/hash.js
54731
54920
  import { createHash as createHash2 } from "crypto";
54732
54921
  function stableJson(value) {
54733
54922
  if (Array.isArray(value)) {
@@ -54744,7 +54933,7 @@ function sha256(value) {
54744
54933
  }
54745
54934
  var init_hash = () => {};
54746
54935
 
54747
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.30+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/errors.js
54936
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.31+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/errors.js
54748
54937
  var HistoryImportError;
54749
54938
  var init_errors7 = __esm(() => {
54750
54939
  HistoryImportError = class HistoryImportError extends Error {
@@ -54757,7 +54946,7 @@ var init_errors7 = __esm(() => {
54757
54946
  };
54758
54947
  });
54759
54948
 
54760
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.30+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/schema-sql.js
54949
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.31+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/schema-sql.js
54761
54950
  var HISTORY_IMPORT_SCHEMA_SQL;
54762
54951
  var init_schema_sql2 = __esm(() => {
54763
54952
  HISTORY_IMPORT_SCHEMA_SQL = `
@@ -54838,7 +55027,7 @@ CREATE INDEX IF NOT EXISTS idx_history_tool_call_message_hash
54838
55027
  `.trim();
54839
55028
  });
54840
55029
 
54841
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.30+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/mappers.js
55030
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.31+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/mappers.js
54842
55031
  function identityFieldMap(keys) {
54843
55032
  const map2 = {};
54844
55033
  for (const key of keys) {
@@ -55902,7 +56091,7 @@ var init_mappers = __esm(() => {
55902
56091
  GEMINI_SCHEMA = passthroughSchema;
55903
56092
  });
55904
56093
 
55905
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.30+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/sources.js
56094
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.31+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/sources.js
55906
56095
  function firstString(...values) {
55907
56096
  for (const value of values) {
55908
56097
  if (typeof value === "string" && value.length > 0)
@@ -56056,7 +56245,7 @@ var init_sources = __esm(() => {
56056
56245
  };
56057
56246
  });
56058
56247
 
56059
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.30+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/jsonl-importer-dao.js
56248
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.31+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/jsonl-importer-dao.js
56060
56249
  function targetTableFor(table3) {
56061
56250
  if (!VALID_TABLE_NAME.test(table3)) {
56062
56251
  throw new HistoryImportError(`Invalid history ETL target table: ${table3}`, { table: table3 });
@@ -56352,7 +56541,7 @@ var init_jsonl_importer_dao = __esm(() => {
56352
56541
  TYPED_IGNORED_KEYS = new Set(["_meta", "split_index"]);
56353
56542
  });
56354
56543
 
56355
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.30+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/redaction.js
56544
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.31+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/redaction.js
56356
56545
  function redactValue(value, rules = DEFAULT_REDACTION_RULES) {
56357
56546
  if (typeof value === "string") {
56358
56547
  return rules.reduce((current, rule) => current.replace(rule.pattern, rule.replacement), value);
@@ -56404,7 +56593,7 @@ var init_redaction = __esm(() => {
56404
56593
  ];
56405
56594
  });
56406
56595
 
56407
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.30+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/importer.js
56596
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.31+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/importer.js
56408
56597
  async function runJsonlImport(source, options) {
56409
56598
  const definition = resolveSourceDefinition(source);
56410
56599
  const resolvedSource = definition.source;
@@ -56650,7 +56839,7 @@ var init_importer = __esm(() => {
56650
56839
  init_sources();
56651
56840
  });
56652
56841
 
56653
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.30+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/opencode-importer.js
56842
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.31+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/opencode-importer.js
56654
56843
  async function runOpenCodeImport(options) {
56655
56844
  const paths = options.paths ?? ambientRuntimePaths2();
56656
56845
  const sourceDatabase = options.sourceDatabase ?? joinPath2(paths.home, ".local/share/opencode/opencode.db");
@@ -56901,14 +57090,14 @@ var init_opencode_importer = __esm(() => {
56901
57090
  init_redaction();
56902
57091
  });
56903
57092
 
56904
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.30+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/index.js
57093
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.31+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/index.js
56905
57094
  var init_dist8 = __esm(() => {
56906
57095
  init_importer();
56907
57096
  init_opencode_importer();
56908
57097
  init_schema_sql2();
56909
57098
  });
56910
57099
 
56911
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/config/extensions.js
57100
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/config/extensions.js
56912
57101
  function collectExtensions(sourceName, sourceDir, extensions) {
56913
57102
  if (extensions === undefined)
56914
57103
  return [];
@@ -56920,9 +57109,9 @@ function collectExtensions(sourceName, sourceDir, extensions) {
56920
57109
  }
56921
57110
  return refs;
56922
57111
  }
56923
- var init_extensions = () => {};
57112
+ var init_extensions2 = () => {};
56924
57113
 
56925
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/types.js
57114
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/types.js
56926
57115
  function createFinding(rule, message, filePath, extras = {}) {
56927
57116
  return {
56928
57117
  ruleId: rule.id,
@@ -56932,7 +57121,7 @@ function createFinding(rule, message, filePath, extras = {}) {
56932
57121
  ...extras
56933
57122
  };
56934
57123
  }
56935
- var SEVERITY_RANK, RuleFixConfigSchema, ConstraintRuleSchema, relativeExtensionPath, ExtensionsSchema, ConstraintRuleFileSchema, PresetDefinitionSchema;
57124
+ var SEVERITY_RANK, RuleFixConfigSchema, ConstraintRuleSchema, relativeExtensionPath2, ExtensionsSchema, ConstraintRuleFileSchema, PresetDefinitionSchema;
56936
57125
  var init_types3 = __esm(() => {
56937
57126
  init_extension2();
56938
57127
  init_zod();
@@ -56959,7 +57148,7 @@ var init_types3 = __esm(() => {
56959
57148
  exclude: exports_external.array(exports_external.string()).optional(),
56960
57149
  fix: RuleFixConfigSchema.optional()
56961
57150
  });
56962
- relativeExtensionPath = exports_external.string().min(1).superRefine((value, ctx) => {
57151
+ relativeExtensionPath2 = exports_external.string().min(1).superRefine((value, ctx) => {
56963
57152
  try {
56964
57153
  assertRelativeExtensionPath(value);
56965
57154
  } catch (error51) {
@@ -56970,10 +57159,10 @@ var init_types3 = __esm(() => {
56970
57159
  }
56971
57160
  });
56972
57161
  ExtensionsSchema = exports_external.object({
56973
- resolvers: exports_external.array(relativeExtensionPath).optional(),
56974
- evaluators: exports_external.array(relativeExtensionPath).optional(),
56975
- fixers: exports_external.array(relativeExtensionPath).optional(),
56976
- formatters: exports_external.array(relativeExtensionPath).optional()
57162
+ resolvers: exports_external.array(relativeExtensionPath2).optional(),
57163
+ evaluators: exports_external.array(relativeExtensionPath2).optional(),
57164
+ fixers: exports_external.array(relativeExtensionPath2).optional(),
57165
+ formatters: exports_external.array(relativeExtensionPath2).optional()
56977
57166
  }).strict();
56978
57167
  ConstraintRuleFileSchema = exports_external.object({
56979
57168
  $schema: exports_external.string().optional(),
@@ -56993,7 +57182,7 @@ var init_types3 = __esm(() => {
56993
57182
  });
56994
57183
  });
56995
57184
 
56996
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/config/loader.js
57185
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/config/loader.js
56997
57186
  async function loadPreset(name, options) {
56998
57187
  const merged = await buildMergedRoots(options.roots.map((root) => resolvePath4(root)), options.fileSystem);
56999
57188
  const presetPath = findMergedPreset(merged, name);
@@ -57204,11 +57393,11 @@ var FIX_MODE_AUTHORITY;
57204
57393
  var init_loader2 = __esm(() => {
57205
57394
  init_dist5();
57206
57395
  init_types3();
57207
- init_extensions();
57396
+ init_extensions2();
57208
57397
  FIX_MODE_AUTHORITY = { none: 0, suggest: 1, auto: 2 };
57209
57398
  });
57210
57399
 
57211
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/fixers/test-stub-fixer.js
57400
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/fixers/test-stub-fixer.js
57212
57401
  function normalizeFindingPath(filePath) {
57213
57402
  if (!filePath || isAbsolutePath2(filePath))
57214
57403
  return null;
@@ -57273,7 +57462,7 @@ var init_test_stub_fixer = __esm(() => {
57273
57462
  realFileSystem = createNodeFileSystem3();
57274
57463
  });
57275
57464
 
57276
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/fixers/fixers.js
57465
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/fixers/fixers.js
57277
57466
  function registerBuiltinFixers(host, exec) {
57278
57467
  const regexFixer = new RegexFixerProvider;
57279
57468
  const pathFixer = new PathFixerProvider;
@@ -57476,7 +57665,7 @@ var init_fixers = __esm(() => {
57476
57665
  };
57477
57666
  });
57478
57667
 
57479
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.30+5440cf4f2ea6f0ec/node_modules/@gobing-ai/ts-ai-runner/dist/agents/shims.js
57668
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.31+266b97de815d24f2/node_modules/@gobing-ai/ts-ai-runner/dist/agents/shims.js
57480
57669
  function getAgentSessionCapability(agent) {
57481
57670
  return AGENT_SESSION_CAPABILITY[agent];
57482
57671
  }
@@ -57768,7 +57957,7 @@ var init_shims = __esm(() => {
57768
57957
  ALIAS_TO_CANONICAL = Object.fromEntries(Object.values(AGENT_SHIMS).flatMap((shim) => (shim.aliases ?? []).map((alias3) => [alias3, shim.name])));
57769
57958
  });
57770
57959
 
57771
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.30+5440cf4f2ea6f0ec/node_modules/@gobing-ai/ts-ai-runner/dist/identity.js
57960
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.31+266b97de815d24f2/node_modules/@gobing-ai/ts-ai-runner/dist/identity.js
57772
57961
  function buildIdentityPreamble(ctx) {
57773
57962
  const sections = [
57774
57963
  `You are agent \`${ctx.agentId}\` (${ctx.agentType}) in workspace \`${ctx.workspace}\`.`
@@ -57844,7 +58033,7 @@ var init_identity = __esm(() => {
57844
58033
  init_dist5();
57845
58034
  });
57846
58035
 
57847
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.30+5440cf4f2ea6f0ec/node_modules/@gobing-ai/ts-ai-runner/dist/slash-command.js
58036
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.31+266b97de815d24f2/node_modules/@gobing-ai/ts-ai-runner/dist/slash-command.js
57848
58037
  function isClaudeStyleSlashCommand(input) {
57849
58038
  return SLASH_COMMAND_RE.test(input);
57850
58039
  }
@@ -57872,7 +58061,7 @@ var init_slash_command = __esm(() => {
57872
58061
  SLASH_COMMAND_RE = /^\/([a-zA-Z0-9._-]+):([a-zA-Z0-9._-]+)(\s.*)?$/;
57873
58062
  });
57874
58063
 
57875
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.30+5440cf4f2ea6f0ec/node_modules/@gobing-ai/ts-ai-runner/dist/ai-runner.js
58064
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.31+266b97de815d24f2/node_modules/@gobing-ai/ts-ai-runner/dist/ai-runner.js
57876
58065
  function buildCorrelationEnv(correlation) {
57877
58066
  return {
57878
58067
  [AGENT_RUN_ID_ENV]: correlation.runId,
@@ -58010,7 +58199,7 @@ var init_ai_runner = __esm(() => {
58010
58199
  init_slash_command();
58011
58200
  });
58012
58201
 
58013
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.30+5440cf4f2ea6f0ec/node_modules/@gobing-ai/ts-ai-runner/dist/agent-detector.js
58202
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.31+266b97de815d24f2/node_modules/@gobing-ai/ts-ai-runner/dist/agent-detector.js
58014
58203
  class AgentDetector {
58015
58204
  runner;
58016
58205
  timeout;
@@ -58086,7 +58275,7 @@ var init_agent_detector = __esm(() => {
58086
58275
  VERSION_PATTERN = /(?<version>\d+\.\d+(?:\.\d+)?)/;
58087
58276
  });
58088
58277
 
58089
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.30+5440cf4f2ea6f0ec/node_modules/@gobing-ai/ts-ai-runner/dist/agent-spec.js
58278
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.31+266b97de815d24f2/node_modules/@gobing-ai/ts-ai-runner/dist/agent-spec.js
58090
58279
  function validateAgentId(id) {
58091
58280
  if (!/^[a-z][a-z0-9_-]{1,63}$/.test(id)) {
58092
58281
  throw new ValueError(`Invalid agent id "${id}": expected 2-64 chars, lowercase alphanumeric, "_" or "-"`);
@@ -58183,7 +58372,7 @@ var init_agent_spec = __esm(() => {
58183
58372
  };
58184
58373
  });
58185
58374
 
58186
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.30+5440cf4f2ea6f0ec/node_modules/@gobing-ai/ts-ai-runner/dist/agents/auth-shims.js
58375
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.31+266b97de815d24f2/node_modules/@gobing-ai/ts-ai-runner/dist/agents/auth-shims.js
58187
58376
  function isNonEmpty(value) {
58188
58377
  return value !== undefined && value.trim().length > 0;
58189
58378
  }
@@ -58308,7 +58497,7 @@ var init_auth_shims = __esm(() => {
58308
58497
  };
58309
58498
  });
58310
58499
 
58311
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.30+5440cf4f2ea6f0ec/node_modules/@gobing-ai/ts-ai-runner/dist/model-health-probe.js
58500
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.31+266b97de815d24f2/node_modules/@gobing-ai/ts-ai-runner/dist/model-health-probe.js
58312
58501
  class ModelHealthProbeRegistry {
58313
58502
  probes = new Map;
58314
58503
  register(providerPrefix, probe) {
@@ -58416,7 +58605,7 @@ var init_model_health_probe = __esm(() => {
58416
58605
  };
58417
58606
  });
58418
58607
 
58419
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.30+5440cf4f2ea6f0ec/node_modules/@gobing-ai/ts-ai-runner/dist/doctor-runner.js
58608
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.31+266b97de815d24f2/node_modules/@gobing-ai/ts-ai-runner/dist/doctor-runner.js
58420
58609
  class DoctorRunner {
58421
58610
  detector;
58422
58611
  runner;
@@ -58553,15 +58742,15 @@ var init_doctor_runner = __esm(() => {
58553
58742
  init_model_health_probe();
58554
58743
  });
58555
58744
 
58556
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.30+5440cf4f2ea6f0ec/node_modules/@gobing-ai/ts-ai-runner/dist/events.js
58745
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.31+266b97de815d24f2/node_modules/@gobing-ai/ts-ai-runner/dist/events.js
58557
58746
  var init_events = () => {};
58558
58747
 
58559
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.30+5440cf4f2ea6f0ec/node_modules/@gobing-ai/ts-ai-runner/dist/messages.js
58748
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.31+266b97de815d24f2/node_modules/@gobing-ai/ts-ai-runner/dist/messages.js
58560
58749
  function formatMessage(msg) {
58561
58750
  return `[task from=${msg.fromId ?? "operator"} id=${msg.id}] ${msg.body}`;
58562
58751
  }
58563
58752
 
58564
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.30+5440cf4f2ea6f0ec/node_modules/@gobing-ai/ts-ai-runner/dist/team-agent-process.js
58753
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.31+266b97de815d24f2/node_modules/@gobing-ai/ts-ai-runner/dist/team-agent-process.js
58565
58754
  import { Buffer as Buffer5 } from "buffer";
58566
58755
 
58567
58756
  class TeamAgentProcess {
@@ -58620,8 +58809,8 @@ class TeamAgentProcess {
58620
58809
  this.warn("stdin close failed", "stop.endStdin", error51);
58621
58810
  }
58622
58811
  process11.kill("SIGTERM");
58623
- const timeout = new Promise((resolve) => {
58624
- setTimeout(() => resolve("timeout"), 5000);
58812
+ const timeout = new Promise((resolve2) => {
58813
+ setTimeout(() => resolve2("timeout"), 5000);
58625
58814
  });
58626
58815
  const result = await Promise.race([process11.exited, timeout]);
58627
58816
  if (result === "timeout") {
@@ -58695,7 +58884,7 @@ var init_team_agent_process = __esm(() => {
58695
58884
  init_dist5();
58696
58885
  });
58697
58886
 
58698
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.30+5440cf4f2ea6f0ec/node_modules/@gobing-ai/ts-ai-runner/dist/team-orchestrator.js
58887
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.31+266b97de815d24f2/node_modules/@gobing-ai/ts-ai-runner/dist/team-orchestrator.js
58699
58888
  class TeamOrchestrator {
58700
58889
  configDir;
58701
58890
  inbox;
@@ -58836,7 +59025,7 @@ var init_team_orchestrator = __esm(() => {
58836
59025
  init_team_agent_process();
58837
59026
  });
58838
59027
 
58839
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.30+5440cf4f2ea6f0ec/node_modules/@gobing-ai/ts-ai-runner/dist/index.js
59028
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.31+266b97de815d24f2/node_modules/@gobing-ai/ts-ai-runner/dist/index.js
58840
59029
  var exports_dist3 = {};
58841
59030
  __export(exports_dist3, {
58842
59031
  validateAgentId: () => validateAgentId,
@@ -58889,7 +59078,7 @@ var init_dist9 = __esm(() => {
58889
59078
  init_team_orchestrator();
58890
59079
  });
58891
59080
 
58892
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/config-access.js
59081
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/config-access.js
58893
59082
  function stringArray(value) {
58894
59083
  return Array.isArray(value) && value.every((item) => typeof item === "string") ? value : undefined;
58895
59084
  }
@@ -58927,7 +59116,7 @@ function parseInlineFlags(source) {
58927
59116
  return { flags, rest: source.slice(match[0].length) };
58928
59117
  }
58929
59118
 
58930
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/glob-match.js
59119
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/glob-match.js
58931
59120
  function matchesAny(path9, patterns) {
58932
59121
  if (patterns === undefined || patterns.length === 0)
58933
59122
  return true;
@@ -58975,7 +59164,7 @@ function escapeRegExp(value) {
58975
59164
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
58976
59165
  }
58977
59166
 
58978
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/file-discovery.js
59167
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/file-discovery.js
58979
59168
  async function discoverFiles2(options) {
58980
59169
  const fs3 = options.fs ?? createNodeFileSystem3();
58981
59170
  const allFiles = await walkDir2(options.workdir, fs3, DEFAULT_EXCLUDES);
@@ -59006,12 +59195,12 @@ var init_file_discovery = __esm(() => {
59006
59195
  DEFAULT_EXCLUDES = new Set([".git", "node_modules", "dist", ".coverage", ".astro", ".wrangler"]);
59007
59196
  });
59008
59197
 
59009
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/file-utils.js
59198
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/file-utils.js
59010
59199
  var init_file_utils = __esm(() => {
59011
59200
  init_file_discovery();
59012
59201
  });
59013
59202
 
59014
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/agent-detection-evaluator.js
59203
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/agent-detection-evaluator.js
59015
59204
  class AgentDetectionEvaluator {
59016
59205
  detector;
59017
59206
  constructor(detector = new AgentDetector) {
@@ -59039,7 +59228,7 @@ var init_agent_detection_evaluator = __esm(() => {
59039
59228
  init_file_utils();
59040
59229
  });
59041
59230
 
59042
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/coverage-gate-evaluator.js
59231
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/coverage-gate-evaluator.js
59043
59232
  class CoverageGateEvaluator {
59044
59233
  constructor() {}
59045
59234
  async evaluate(rule, context4) {
@@ -59123,7 +59312,7 @@ var init_coverage_gate_evaluator = __esm(() => {
59123
59312
  init_file_utils();
59124
59313
  });
59125
59314
 
59126
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/exit-code-evaluator.js
59315
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/exit-code-evaluator.js
59127
59316
  class ExitCodeEvaluator {
59128
59317
  executor;
59129
59318
  constructor(executor = nodeBunFactory3.createProcessExecutor()) {
@@ -59159,7 +59348,7 @@ var init_exit_code_evaluator = __esm(() => {
59159
59348
  init_file_utils();
59160
59349
  });
59161
59350
 
59162
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/forbidden-import-evaluator.js
59351
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/forbidden-import-evaluator.js
59163
59352
  class ForbiddenImportEvaluator {
59164
59353
  constructor() {}
59165
59354
  async evaluate(rule, context4) {
@@ -59240,7 +59429,7 @@ var init_forbidden_import_evaluator = __esm(() => {
59240
59429
  init_file_utils();
59241
59430
  });
59242
59431
 
59243
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/import-boundary-evaluator.js
59432
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/import-boundary-evaluator.js
59244
59433
  class ImportBoundaryEvaluator {
59245
59434
  async evaluate(rule, context4) {
59246
59435
  const config4 = rule.evaluator.config ?? {};
@@ -59333,7 +59522,7 @@ var init_import_boundary_evaluator = __esm(() => {
59333
59522
  init_file_utils();
59334
59523
  });
59335
59524
 
59336
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/path-evaluator.js
59525
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/path-evaluator.js
59337
59526
  class PathEvaluator {
59338
59527
  constructor() {}
59339
59528
  async evaluate(rule, context4) {
@@ -59394,7 +59583,7 @@ var init_path_evaluator = __esm(() => {
59394
59583
  init_file_utils();
59395
59584
  });
59396
59585
 
59397
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/regex-evaluator.js
59586
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/regex-evaluator.js
59398
59587
  class RegexEvaluator {
59399
59588
  constructor() {}
59400
59589
  async evaluate(rule, context4) {
@@ -59472,7 +59661,7 @@ var init_regex_evaluator = __esm(() => {
59472
59661
  init_file_utils();
59473
59662
  });
59474
59663
 
59475
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/ripgrep-evaluator.js
59664
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/ripgrep-evaluator.js
59476
59665
  class RipgrepEvaluator {
59477
59666
  executor;
59478
59667
  constructor(executor = nodeBunFactory3.createProcessExecutor()) {
@@ -59565,7 +59754,7 @@ var init_ripgrep_evaluator = __esm(() => {
59565
59754
  init_file_utils();
59566
59755
  });
59567
59756
 
59568
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/schema-artifact-evaluator.js
59757
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/schema-artifact-evaluator.js
59569
59758
  class SchemaArtifactEvaluator {
59570
59759
  constructor() {}
59571
59760
  async evaluate(rule, context4) {
@@ -59643,7 +59832,7 @@ var init_schema_artifact_evaluator = __esm(() => {
59643
59832
  init_file_utils();
59644
59833
  });
59645
59834
 
59646
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/secrets-scanner-evaluator.js
59835
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/secrets-scanner-evaluator.js
59647
59836
  class SecretsScannerEvaluator {
59648
59837
  constructor() {}
59649
59838
  async evaluate(rule, context4) {
@@ -59711,7 +59900,7 @@ var init_secrets_scanner_evaluator = __esm(() => {
59711
59900
  ALL_CATEGORIES = Object.keys(BUILTIN_PATTERNS);
59712
59901
  });
59713
59902
 
59714
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/sg-evaluator.js
59903
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/sg-evaluator.js
59715
59904
  class SgEvaluator {
59716
59905
  executor;
59717
59906
  constructor(executor = nodeBunFactory3.createProcessExecutor()) {
@@ -59808,7 +59997,7 @@ var init_sg_evaluator = __esm(() => {
59808
59997
  init_file_utils();
59809
59998
  });
59810
59999
 
59811
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/resolvers/test-path-resolver.js
60000
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/resolvers/test-path-resolver.js
59812
60001
  class TypeScriptTestPathResolver {
59813
60002
  name = "typescript";
59814
60003
  constructor() {}
@@ -59891,7 +60080,7 @@ function testify(rel) {
59891
60080
  return `${dir}test_${base2}`;
59892
60081
  }
59893
60082
 
59894
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/test-location-evaluator.js
60083
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/test-location-evaluator.js
59895
60084
  class TestLocationEvaluator {
59896
60085
  resolvers;
59897
60086
  constructor(resolvers) {
@@ -59966,7 +60155,7 @@ var init_test_location_evaluator = __esm(() => {
59966
60155
  TYPESCRIPT_FALLBACK = new TypeScriptTestPathResolver;
59967
60156
  });
59968
60157
 
59969
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/tsdoc-export-evaluator.js
60158
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/tsdoc-export-evaluator.js
59970
60159
  class TsdocExportEvaluator {
59971
60160
  constructor() {}
59972
60161
  async evaluate(rule, context4) {
@@ -60051,7 +60240,7 @@ var init_tsdoc_export_evaluator = __esm(() => {
60051
60240
  };
60052
60241
  });
60053
60242
 
60054
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/formatters/json.js
60243
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/formatters/json.js
60055
60244
  class JsonFormatter {
60056
60245
  constructor() {}
60057
60246
  format(result) {
@@ -60059,7 +60248,7 @@ class JsonFormatter {
60059
60248
  }
60060
60249
  }
60061
60250
 
60062
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/formatters/text.js
60251
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/formatters/text.js
60063
60252
  class TextFormatter {
60064
60253
  constructor() {}
60065
60254
  format(result) {
@@ -60073,7 +60262,7 @@ class TextFormatter {
60073
60262
  }
60074
60263
  }
60075
60264
 
60076
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/host/builtins.js
60265
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/host/builtins.js
60077
60266
  function registerBuiltins(host, executor) {
60078
60267
  const path9 = new PathEvaluator;
60079
60268
  host.evaluators.register("regex", new RegexEvaluator, "builtin");
@@ -60113,7 +60302,7 @@ var init_builtins = __esm(() => {
60113
60302
  init_tsdoc_export_evaluator();
60114
60303
  });
60115
60304
 
60116
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/host/rule-engine-host.js
60305
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/host/rule-engine-host.js
60117
60306
  class RuleEngineHost {
60118
60307
  evaluators;
60119
60308
  formatters;
@@ -60130,7 +60319,7 @@ var init_rule_engine_host = __esm(() => {
60130
60319
  init_extension2();
60131
60320
  });
60132
60321
 
60133
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/engine.js
60322
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/engine.js
60134
60323
  class RuleEngine {
60135
60324
  host;
60136
60325
  events;
@@ -60316,7 +60505,7 @@ var init_engine = __esm(() => {
60316
60505
  init_types3();
60317
60506
  });
60318
60507
 
60319
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/host/bundled-rules.js
60508
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/host/bundled-rules.js
60320
60509
  async function bundledRulesRoot() {
60321
60510
  if (cachedRoot2 !== undefined)
60322
60511
  return cachedRoot2;
@@ -60367,7 +60556,7 @@ var init_bundled_rules = __esm(() => {
60367
60556
  init_dist5();
60368
60557
  });
60369
60558
 
60370
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/persistence/db-adapter.js
60559
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/persistence/db-adapter.js
60371
60560
  class DbRulePersistenceAdapter {
60372
60561
  db;
60373
60562
  constructor(db2) {
@@ -60401,7 +60590,7 @@ class DbRulePersistenceAdapter {
60401
60590
  }
60402
60591
  }
60403
60592
 
60404
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/persistence/schema.js
60593
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/persistence/schema.js
60405
60594
  var RULE_ENGINE_SCHEMA_SQL = `
60406
60595
  CREATE TABLE IF NOT EXISTS rule_runs (
60407
60596
  id TEXT PRIMARY KEY,
@@ -60447,12 +60636,12 @@ CREATE TABLE IF NOT EXISTS rule_eval_runs (
60447
60636
  CREATE INDEX IF NOT EXISTS idx_rule_eval_runs_run_id ON rule_eval_runs (run_id);
60448
60637
  `;
60449
60638
 
60450
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/persistence/index.js
60639
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/persistence/index.js
60451
60640
  var init_persistence2 = () => {};
60452
60641
 
60453
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.30+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/index.js
60642
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.31+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/index.js
60454
60643
  var init_dist10 = __esm(() => {
60455
- init_extensions();
60644
+ init_extensions2();
60456
60645
  init_loader2();
60457
60646
  init_engine();
60458
60647
  init_fixers();
@@ -60534,7 +60723,8 @@ async function applyCliMigrations(adapter, migrations = CLI_MIGRATIONS) {
60534
60723
  }
60535
60724
  const addColumnGuard = migration.addColumnIfMissing;
60536
60725
  const shouldApplySql = addColumnGuard === undefined || !await columnExists(adapter, addColumnGuard.table, addColumnGuard.column);
60537
- if (shouldApplySql) {
60726
+ const sequenceIndexSkip = migration.id === "0011_spur_cli_system_events_sequence_idx" && !await tableExists(adapter, "system_events");
60727
+ if (shouldApplySql && !sequenceIndexSkip) {
60538
60728
  for (const statement of splitSqlStatements(migration.sql)) {
60539
60729
  await adapter.exec(statement);
60540
60730
  }
@@ -60618,6 +60808,21 @@ CREATE INDEX IF NOT EXISTS idx_system_events_occurred_at ON system_events (occur
60618
60808
  CREATE INDEX IF NOT EXISTS idx_system_events_event_name ON system_events (event_name);
60619
60809
  CREATE INDEX IF NOT EXISTS idx_system_events_run_id ON system_events (run_id);
60620
60810
  CREATE INDEX IF NOT EXISTS idx_system_events_entity ON system_events (entity_kind, entity_id);
60811
+ CREATE INDEX IF NOT EXISTS idx_system_events_sequence ON system_events (sequence);
60812
+ `, COORDINATION_RUNS_SCHEMA_SQL = `
60813
+ CREATE TABLE IF NOT EXISTS coordination_runs (
60814
+ spec_id TEXT NOT NULL,
60815
+ agent_kind TEXT NOT NULL,
60816
+ process_id TEXT,
60817
+ run_id TEXT PRIMARY KEY,
60818
+ generation INTEGER NOT NULL,
60819
+ status TEXT NOT NULL,
60820
+ started_at TEXT NOT NULL,
60821
+ completed_at TEXT,
60822
+ artifact_refs_json TEXT NOT NULL DEFAULT '[]'
60823
+ );
60824
+
60825
+ CREATE INDEX IF NOT EXISTS idx_coordination_runs_spec ON coordination_runs (spec_id, generation DESC);
60621
60826
  `, CLI_SCHEMA_SQL, RUN_PID_COLUMN_SCHEMA_SQL = `
60622
60827
  ALTER TABLE runs ADD COLUMN pid INTEGER;
60623
60828
  `, RUNS_EXTERNAL_KEY_COLUMN_SCHEMA_SQL = `
@@ -60632,6 +60837,8 @@ CREATE INDEX IF NOT EXISTS idx_system_events_run_id ON system_events (run_id);
60632
60837
  CREATE INDEX IF NOT EXISTS idx_system_events_entity ON system_events (entity_kind, entity_id);
60633
60838
  `, HISTORY_MESSAGE_RUN_INDEX_SCHEMA_SQL = `
60634
60839
  CREATE INDEX IF NOT EXISTS idx_history_message_provenance_run ON history_message (provenance, run_id);
60840
+ `, SYSTEM_EVENTS_SEQUENCE_INDEX_SCHEMA_SQL = `
60841
+ CREATE INDEX IF NOT EXISTS idx_system_events_sequence ON system_events (sequence);
60635
60842
  `, CLI_MIGRATIONS, CLI_MIGRATION_FILE_MARKER = "_spur_cli_";
60636
60843
  var init_migrations = __esm(() => {
60637
60844
  init_dist7();
@@ -60655,6 +60862,8 @@ ${INBOX_MESSAGES_SCHEMA_SQL}
60655
60862
  ${QUEUE_JOBS_SCHEMA_SQL}
60656
60863
 
60657
60864
  ${SYSTEM_EVENTS_SCHEMA_SQL}
60865
+
60866
+ ${COORDINATION_RUNS_SCHEMA_SQL}
60658
60867
  `;
60659
60868
  CLI_MIGRATIONS = [
60660
60869
  { id: "0000_spur_cli_foundation", sql: CLI_SCHEMA_SQL },
@@ -60678,11 +60887,13 @@ ${SYSTEM_EVENTS_SCHEMA_SQL}
60678
60887
  sql: SYSTEM_EVENTS_CORRELATION_COLUMNS_SCHEMA_SQL,
60679
60888
  addColumnIfMissing: { table: "system_events", column: "sequence" }
60680
60889
  },
60681
- { id: "0009_spur_cli_history_message_run_idx", sql: HISTORY_MESSAGE_RUN_INDEX_SCHEMA_SQL }
60890
+ { id: "0009_spur_cli_history_message_run_idx", sql: HISTORY_MESSAGE_RUN_INDEX_SCHEMA_SQL },
60891
+ { id: "0010_spur_cli_coordination_runs", sql: COORDINATION_RUNS_SCHEMA_SQL },
60892
+ { id: "0011_spur_cli_system_events_sequence_idx", sql: SYSTEM_EVENTS_SEQUENCE_INDEX_SCHEMA_SQL }
60682
60893
  ];
60683
60894
  });
60684
60895
 
60685
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/job-queue/db-job-queue.js
60896
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/job-queue/db-job-queue.js
60686
60897
  function queueLogger() {
60687
60898
  if (!_queueLogger)
60688
60899
  _queueLogger = getLogger2("job-queue");
@@ -60936,8 +61147,8 @@ function toJob(record2) {
60936
61147
  };
60937
61148
  }
60938
61149
  function sleep(ms) {
60939
- const { promise: promise2, resolve } = Promise.withResolvers();
60940
- setTimeout(resolve, ms);
61150
+ const { promise: promise2, resolve: resolve2 } = Promise.withResolvers();
61151
+ setTimeout(resolve2, ms);
60941
61152
  return promise2;
60942
61153
  }
60943
61154
  function positiveIntegerConfig(name, value) {
@@ -60965,7 +61176,7 @@ var init_db_job_queue = __esm(() => {
60965
61176
  init_tracing2();
60966
61177
  });
60967
61178
 
60968
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/job-queue-db.js
61179
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/job-queue-db.js
60969
61180
  var exports_job_queue_db = {};
60970
61181
  __export(exports_job_queue_db, {
60971
61182
  DBQueueConsumer: () => DBQueueConsumer,
@@ -63203,6 +63414,7 @@ __export(exports_src, {
63203
63414
  DEFAULT_TASK_VARIANT: () => DEFAULT_TASK_VARIANT,
63204
63415
  DEFAULT_LOCK_TTL_MS: () => DEFAULT_LOCK_TTL_MS,
63205
63416
  DEFAULT_DISCLOSURE_BUDGET_BYTES: () => DEFAULT_DISCLOSURE_BUDGET_BYTES,
63417
+ CoordinationRunDao: () => CoordinationRunDao,
63206
63418
  CONTEXT_LAYER_NAMES: () => CONTEXT_LAYER_NAMES,
63207
63419
  CLI_SCHEMA_SQL: () => CLI_SCHEMA_SQL,
63208
63420
  CLI_MIGRATION_FILE_MARKER: () => CLI_MIGRATION_FILE_MARKER,
@@ -63388,7 +63600,8 @@ class AgentService {
63388
63600
  }
63389
63601
  const result = outcome.result;
63390
63602
  const jsonOutput = booleanFlag(flags, "json");
63391
- this.handleRunOutput(result, jsonOutput);
63603
+ const coordination = outcome.coordination !== undefined ? await this.getCoordinationRun(outcome.coordination.occupant.runId) ?? undefined : undefined;
63604
+ this.handleRunOutput(result, jsonOutput, coordination);
63392
63605
  if (result.exitCode === 0)
63393
63606
  return 0;
63394
63607
  if (result.signal !== undefined) {
@@ -63500,6 +63713,34 @@ class AgentService {
63500
63713
  options.execution?.signal?.addEventListener("abort", onExternalAbort, { once: true });
63501
63714
  if (options.execution?.signal?.aborted === true)
63502
63715
  controller.abort();
63716
+ const specId = stringFlag(flags, "spec-id", "");
63717
+ const coordinationRunId = specId !== "" && options.execution?.correlation !== undefined ? options.execution.correlation.runId : undefined;
63718
+ let occupantRef;
63719
+ if (specId !== "" && coordinationRunId !== undefined && this.ctx.getDb !== undefined) {
63720
+ try {
63721
+ const dao2 = new CoordinationRunDao(await this.ctx.getDb());
63722
+ const generation = (await dao2.maxGeneration(specId) ?? 0) + 1;
63723
+ occupantRef = {
63724
+ specId,
63725
+ agentKind: currentAgent,
63726
+ processId: null,
63727
+ runId: coordinationRunId,
63728
+ generation
63729
+ };
63730
+ await dao2.insertStart({
63731
+ specId,
63732
+ agentKind: currentAgent,
63733
+ processId: null,
63734
+ runId: coordinationRunId,
63735
+ generation,
63736
+ startedAt: new Date().toISOString()
63737
+ });
63738
+ } catch (error51) {
63739
+ if (!jsonOutput) {
63740
+ this.ctx.output.error(`Warning: occupant persist failed: ${error51 instanceof Error ? error51.message : String(error51)}`);
63741
+ }
63742
+ }
63743
+ }
63503
63744
  let result;
63504
63745
  let invocation;
63505
63746
  let dispatchStartedAt = Date.now();
@@ -63629,6 +63870,18 @@ class AgentService {
63629
63870
  process.off("SIGTERM", onTerminate);
63630
63871
  process.off("SIGINT", onTerminate);
63631
63872
  options.execution?.signal?.removeEventListener("abort", onExternalAbort);
63873
+ if (occupantRef !== undefined && coordinationRunId !== undefined && this.ctx.getDb !== undefined) {
63874
+ try {
63875
+ const dao2 = new CoordinationRunDao(await this.ctx.getDb());
63876
+ const status = result?.exitCode === 0 ? "exited" : "errored";
63877
+ const refs = await this.resolveArtifactRefs(coordinationRunId);
63878
+ await dao2.updateExit(coordinationRunId, status, new Date().toISOString(), JSON.stringify(refs));
63879
+ } catch (error51) {
63880
+ if (!jsonOutput) {
63881
+ this.ctx.output.error(`Warning: occupant exit persist failed: ${error51 instanceof Error ? error51.message : String(error51)}`);
63882
+ }
63883
+ }
63884
+ }
63632
63885
  }
63633
63886
  if (result === undefined || invocation === undefined) {
63634
63887
  lifecycle.finish({
@@ -63644,7 +63897,12 @@ class AgentService {
63644
63897
  ...result.signal !== undefined ? { signal: result.signal } : {},
63645
63898
  ...controller.signal.aborted && result.signal === undefined ? { reason: "cancelled" } : {}
63646
63899
  });
63647
- return { ok: true, result, invocation };
63900
+ return {
63901
+ ok: true,
63902
+ result,
63903
+ invocation,
63904
+ ...occupantRef !== undefined ? { coordination: { occupant: occupantRef } } : {}
63905
+ };
63648
63906
  }
63649
63907
  defaultExecutionOptions(flags) {
63650
63908
  const runId = stringFlag(flags, "run-id", "") || crypto.randomUUID();
@@ -63887,14 +64145,71 @@ class AgentService {
63887
64145
  return null;
63888
64146
  }
63889
64147
  }
63890
- handleRunOutput(result, jsonOutput) {
64148
+ async getOccupant(by) {
64149
+ if ("agentKind" in by) {
64150
+ throw new Error("occupant_lookup_kind_rejected: address the occupant by specId, not agentKind");
64151
+ }
64152
+ if (this.ctx.getDb === undefined)
64153
+ return null;
64154
+ const dao2 = new CoordinationRunDao(await this.ctx.getDb());
64155
+ const row = await dao2.getLatestBySpecId(by.specId);
64156
+ if (row === null)
64157
+ return null;
64158
+ return {
64159
+ specId: row.spec_id,
64160
+ agentKind: row.agent_kind,
64161
+ processId: row.process_id,
64162
+ runId: row.run_id,
64163
+ generation: row.generation
64164
+ };
64165
+ }
64166
+ async getCoordinationRun(runId) {
64167
+ if (this.ctx.getDb === undefined)
64168
+ return null;
64169
+ const dao2 = new CoordinationRunDao(await this.ctx.getDb());
64170
+ const row = await dao2.getByRunId(runId);
64171
+ if (row === null)
64172
+ return null;
64173
+ return {
64174
+ occupant: {
64175
+ specId: row.spec_id,
64176
+ agentKind: row.agent_kind,
64177
+ processId: row.process_id,
64178
+ runId: row.run_id,
64179
+ generation: row.generation
64180
+ },
64181
+ status: row.status,
64182
+ startedAt: row.started_at,
64183
+ completedAt: row.completed_at,
64184
+ artifactRefs: parseArtifactRefs(row.artifact_refs_json)
64185
+ };
64186
+ }
64187
+ async resolveArtifactRefs(runId) {
64188
+ const refs = [];
64189
+ const logPath = `.spur/run/${runId}.log`;
64190
+ try {
64191
+ await createNodeFileSystem3(this.ctx.cwd).stat(logPath);
64192
+ refs.push({ kind: "log", path: logPath });
64193
+ } catch {}
64194
+ return refs;
64195
+ }
64196
+ handleRunOutput(result, jsonOutput, coordination) {
63891
64197
  if (jsonOutput) {
63892
64198
  this.ctx.output.write(toJson({
63893
64199
  exitCode: result.exitCode,
63894
64200
  stdout: result.stdout,
63895
64201
  stderr: result.stderr,
63896
64202
  ...result.signal !== undefined ? { signal: result.signal } : {},
63897
- durationMs: result.durationMs
64203
+ durationMs: result.durationMs,
64204
+ ...coordination?.occupant !== undefined ? { occupant: coordination.occupant } : {},
64205
+ ...coordination !== undefined ? {
64206
+ run: {
64207
+ status: coordination.status,
64208
+ startedAt: coordination.startedAt,
64209
+ completedAt: coordination.completedAt,
64210
+ artifactRefs: coordination.artifactRefs
64211
+ }
64212
+ } : {}
63898
64213
  }));
63899
64214
  return;
63900
64215
  }
@@ -63919,6 +64234,14 @@ function traceSafePrompt(prompt) {
63919
64234
  const safeTokens = tokens.map((token) => TRACE_SAFE_SLASH_TOKEN.test(token) ? token : "[redacted]");
63920
64235
  return [command, ...safeTokens].join(" ");
63921
64236
  }
64237
+ function parseArtifactRefs(json3) {
64238
+ try {
64239
+ const parsed = JSON.parse(json3);
64240
+ return Array.isArray(parsed) ? parsed : [];
64241
+ } catch {
64242
+ return [];
64243
+ }
64244
+ }
63922
64245
  function sanitizeInvocationArgv(argv, rawInput, traceInput) {
63923
64246
  let redactNext = false;
63924
64247
  return argv.map((arg) => {
@@ -65761,20 +66084,20 @@ var init_task_check = __esm(() => {
65761
66084
  });
65762
66085
 
65763
66086
  // ../../packages/app/src/services/corpus-check.ts
65764
- import { basename, dirname as dirname10, join as join10, relative, resolve } from "path";
66087
+ import { basename, dirname as dirname10, join as join10, relative, resolve as resolve2 } from "path";
65765
66088
  function key(e) {
65766
66089
  return `${e.kind}:${e.id}:${e.code}`;
65767
66090
  }
65768
66091
  function resolveProjectRoot(cwd) {
65769
66092
  const fs3 = createNodeFileSystem3(cwd);
65770
- let current = resolve(cwd);
66093
+ let current = resolve2(cwd);
65771
66094
  while (true) {
65772
66095
  if (fs3.exists(join10(current, ".spur", "config.yaml")) || fs3.exists(join10(current, "config", "corpus-baseline.json"))) {
65773
66096
  return current;
65774
66097
  }
65775
66098
  const parent = dirname10(current);
65776
66099
  if (parent === current)
65777
- return resolve(cwd);
66100
+ return resolve2(cwd);
65778
66101
  current = parent;
65779
66102
  }
65780
66103
  }
@@ -67368,7 +67691,7 @@ class FeatureService {
67368
67691
  const current = await this.ctx.fs.readFile(ref.filePath);
67369
67692
  const doc2 = MarkdownDocument.parse(current, "feature");
67370
67693
  if (!doc2.sectionNames.includes(sectionName)) {
67371
- throw new Error(`Feature ${id} does not contain section "${sectionName}". Available sections: ${doc2.sectionNames.join(", ")}`);
67694
+ throw new Error(`Feature ${id} does not contain section "${sectionName}". Available sections: ${doc2.sectionNames.join(", ")}. ` + "To list valid section names without a failed write: `spur task sections <wbs> list`.");
67372
67695
  }
67373
67696
  const raw = await this.ctx.fs.readFile(sourceFile);
67374
67697
  const body = stripLeadingSectionHeader(raw, sectionName);
@@ -68030,7 +68353,7 @@ import {
68030
68353
  unlinkSync as unlinkSync2,
68031
68354
  writeFileSync as writeFileSync4
68032
68355
  } from "fs";
68033
- import { dirname as dirname11, isAbsolute, join as join12, resolve as resolve2 } from "path";
68356
+ import { dirname as dirname11, isAbsolute as isAbsolute2, join as join12, resolve as resolve3 } from "path";
68034
68357
 
68035
68358
  class HistoryService {
68036
68359
  ctx;
@@ -68380,10 +68703,10 @@ function writeArtifact(artifact, opts) {
68380
68703
  }
68381
68704
  function resolveArtifactPaths(artifact, opts) {
68382
68705
  if (opts.out !== undefined) {
68383
- const out = resolve2(opts.out);
68706
+ const out = resolve3(opts.out);
68384
68707
  return { artifactPath: out, sidecarPath: `${out.replace(/\.json$/, "")}.errors.jsonl` };
68385
68708
  }
68386
- const base2 = resolve2(opts.cwd, ".spur", "reports", "history");
68709
+ const base2 = resolve3(opts.cwd, ".spur", "reports", "history");
68387
68710
  const dateDir = join12(base2, artifact.generatedAt.slice(0, 10));
68388
68711
  const name = `analyze-${selectorDigest(artifact.selector)}`;
68389
68712
  return { artifactPath: join12(dateDir, `${name}.json`), sidecarPath: join12(dateDir, `${name}.errors.jsonl`) };
@@ -68408,7 +68731,7 @@ function boundCoverage(coverage) {
68408
68731
  return { bounded: bounded2, overflow };
68409
68732
  }
68410
68733
  function updateLatestPointer(opts, artifactPath) {
68411
- const base2 = resolve2(opts.cwd, ".spur", "reports", "history");
68734
+ const base2 = resolve3(opts.cwd, ".spur", "reports", "history");
68412
68735
  const latest = join12(base2, "latest.json");
68413
68736
  mkdirSync6(base2, { recursive: true });
68414
68737
  if (existsSync5(latest))
@@ -68417,14 +68740,14 @@ function updateLatestPointer(opts, artifactPath) {
68417
68740
  }
68418
68741
  function resolveArtifactPath(explicitPath, cwd) {
68419
68742
  if (explicitPath !== undefined && explicitPath.length > 0) {
68420
- return { path: resolve2(explicitPath), resolution: "explicit" };
68743
+ return { path: resolve3(explicitPath), resolution: "explicit" };
68421
68744
  }
68422
- const latest = resolve2(cwd, ".spur", "reports", "history", "latest.json");
68745
+ const latest = resolve3(cwd, ".spur", "reports", "history", "latest.json");
68423
68746
  if (!existsSync5(latest)) {
68424
68747
  throw new Error(`No artifact path given and no latest pointer at ${latest}. ` + "Run `spur history analyze` first, or pass an explicit artifact path.");
68425
68748
  }
68426
68749
  const target = readlinkSync(latest);
68427
- const resolved = isAbsolute(target) ? target : resolve2(dirname11(latest), target);
68750
+ const resolved = isAbsolute2(target) ? target : resolve3(dirname11(latest), target);
68428
68751
  if (!existsSync5(resolved)) {
68429
68752
  throw new Error(`Latest pointer ${latest} \u2192 ${resolved}, but the target does not exist.`);
68430
68753
  }
@@ -68560,6 +68883,123 @@ class JobWorkerService {
68560
68883
  }
68561
68884
  }
68562
68885
 
68886
+ // ../../packages/app/src/services/occupant-wait.ts
68887
+ function projectLifecycle(input) {
68888
+ const { latestInvokeEvent, pendingCount } = input;
68889
+ if (latestInvokeEvent === null)
68890
+ return "unknown";
68891
+ if (latestInvokeEvent.eventName === "agent.invoke.start")
68892
+ return "working";
68893
+ if (latestInvokeEvent.eventName === "agent.invoke.exit") {
68894
+ return pendingCount === 0 ? "idle" : "unknown";
68895
+ }
68896
+ return "unknown";
68897
+ }
68898
+ function satisfies(lifecycle, until) {
68899
+ switch (until) {
68900
+ case "idle":
68901
+ return lifecycle === "idle";
68902
+ case "working":
68903
+ return lifecycle === "working";
68904
+ case "blocked":
68905
+ return false;
68906
+ default:
68907
+ return false;
68908
+ }
68909
+ }
68910
+ async function snapshotOccupant(deps, specId, opts) {
68911
+ const occupant = await deps.getOccupant(specId);
68912
+ if (occupant === null) {
68913
+ throw new WaitError("occupant_gone", `no occupant for specId "${specId}"`);
68914
+ }
68915
+ const runId = opts.runId ?? occupant.runId;
68916
+ if (opts.runId !== undefined && opts.runId !== occupant.runId) {}
68917
+ const pin = { specId, runId, generation: occupant.generation };
68918
+ const latest = await deps.latestInvokeEvent(runId);
68919
+ const pendingCount = await deps.countPending(specId);
68920
+ return {
68921
+ pin,
68922
+ lifecycle: projectLifecycle({ latestInvokeEvent: latest, pendingCount }),
68923
+ startClock: deps.now(),
68924
+ latestInvoke: latest
68925
+ };
68926
+ }
68927
+ async function waitForOccupant(deps, opts) {
68928
+ const { pin, until, signal } = opts;
68929
+ const stallMs = opts.stallMs ?? DEFAULT_STALL_MS;
68930
+ const start = deps.now();
68931
+ const deadline = opts.timeoutMs === undefined ? Number.POSITIVE_INFINITY : start + opts.timeoutMs;
68932
+ const initialSnapshot = await snapshotOccupant(deps, pin.specId, { runId: pin.runId });
68933
+ let latestInvoke = initialSnapshot.latestInvoke;
68934
+ let lastSequence = latestInvoke?.sequence ?? 0;
68935
+ let wasWorking = initialSnapshot.lifecycle === "working";
68936
+ if (until !== "invoke-exit" && satisfies(initialSnapshot.lifecycle, until)) {
68937
+ return { pin: initialSnapshot.pin, satisfied: until };
68938
+ }
68939
+ const events2 = deps.follow(lastSequence)[Symbol.asyncIterator]();
68940
+ let pending = events2.next();
68941
+ const stallBudget = opts.timeoutMs === undefined ? stallMs : Math.min(opts.timeoutMs, stallMs);
68942
+ let lastStallSequence = lastSequence;
68943
+ for (;; ) {
68944
+ if (signal?.aborted === true) {
68945
+ throw new WaitError("timeout", "wait aborted");
68946
+ }
68947
+ const clock = deps.now();
68948
+ if (clock >= deadline) {
68949
+ throw new WaitError("timeout", `wait timed out after ${opts.timeoutMs}ms`);
68950
+ }
68951
+ const next = await Promise.race([
68952
+ pending,
68953
+ deps.sleep(Math.min(POLL_INTERVAL_MS, Math.max(0, deadline - clock))).then(() => HEARTBEAT)
68954
+ ]);
68955
+ if (next === HEARTBEAT) {} else {
68956
+ if (next.done === true) {
68957
+ throw new WaitError("timeout", "wait aborted");
68958
+ }
68959
+ pending = events2.next();
68960
+ latestInvoke = { eventName: next.value.event_name, sequence: next.value.sequence };
68961
+ lastSequence = Math.max(lastSequence, next.value.sequence ?? 0);
68962
+ }
68963
+ const occupant = await deps.getOccupant(pin.specId);
68964
+ if (occupant === null) {
68965
+ throw new WaitError("occupant_gone", `occupant for specId "${pin.specId}" is gone`);
68966
+ }
68967
+ if (occupant.runId !== pin.runId) {
68968
+ throw new WaitError("run_replaced", `run ${pin.runId} replaced by ${occupant.runId}`);
68969
+ }
68970
+ if (occupant.generation > pin.generation) {
68971
+ throw new WaitError("run_replaced", `generation ${pin.generation} \u2192 ${occupant.generation}`);
68972
+ }
68973
+ const pendingCount = await deps.countPending(pin.specId);
68974
+ const lifecycle = projectLifecycle({ latestInvokeEvent: latestInvoke, pendingCount });
68975
+ if (until === "invoke-exit") {
68976
+ if (latestInvoke !== null && latestInvoke.eventName === "agent.invoke.exit") {
68977
+ return { pin, satisfied: until };
68978
+ }
68979
+ } else if (satisfies(lifecycle, until)) {
68980
+ return { pin, satisfied: until };
68981
+ }
68982
+ if (lifecycle === "working")
68983
+ wasWorking = true;
68984
+ const progressed = lastSequence > lastStallSequence;
68985
+ lastStallSequence = lastSequence;
68986
+ if (!wasWorking && !progressed && clock - start >= stallBudget) {
68987
+ throw new WaitError("wait_stalled", `no progress within ${stallBudget}ms from a non-working occupant`);
68988
+ }
68989
+ }
68990
+ }
68991
+ var WaitError, POLL_INTERVAL_MS = 100, HEARTBEAT = "heartbeat", DEFAULT_STALL_MS = 5000;
68992
+ var init_occupant_wait = __esm(() => {
68993
+ WaitError = class WaitError extends Error {
68994
+ code;
68995
+ constructor(code, message) {
68996
+ super(message);
68997
+ this.code = code;
68998
+ this.name = "WaitError";
68999
+ }
69000
+ };
69001
+ });
69002
+
68563
69003
  // ../../packages/app/src/services/pipeline-run-link.ts
68564
69004
  async function ensurePipelineRunLink(db2, wbs, options = {}) {
68565
69005
  const dao2 = new TaskRunLinkDao(db2);
@@ -69060,7 +69500,7 @@ var init_process_inventory_service = __esm(() => {
69060
69500
  import { existsSync as existsSync6, mkdirSync as mkdirSync7, readFileSync as readFileSync9, realpathSync as realpathSync3, renameSync as renameSync4, rmSync as rmSync4, writeFileSync as writeFileSync5 } from "fs";
69061
69501
  import { connect, createServer } from "net";
69062
69502
  import { homedir as homedir3 } from "os";
69063
- import { dirname as dirname12, join as join13, resolve as resolve3 } from "path";
69503
+ import { dirname as dirname12, join as join13, resolve as resolve4 } from "path";
69064
69504
  function normalizeProjectPath(pathInput) {
69065
69505
  const trimmed = pathInput.trim();
69066
69506
  let expanded = trimmed;
@@ -69069,7 +69509,7 @@ function normalizeProjectPath(pathInput) {
69069
69509
  } else if (trimmed.startsWith("~/")) {
69070
69510
  expanded = join13(homedir3(), trimmed.slice(2));
69071
69511
  } else {
69072
- expanded = resolve3(trimmed);
69512
+ expanded = resolve4(trimmed);
69073
69513
  }
69074
69514
  try {
69075
69515
  if (existsSync6(expanded)) {
@@ -69079,19 +69519,19 @@ function normalizeProjectPath(pathInput) {
69079
69519
  return expanded;
69080
69520
  }
69081
69521
  async function isPortLiveOnHost(port, host, timeoutMs) {
69082
- return new Promise((resolve4) => {
69522
+ return new Promise((resolve5) => {
69083
69523
  const socket = connect({ port, host, timeout: timeoutMs });
69084
69524
  socket.on("connect", () => {
69085
69525
  socket.destroy();
69086
- resolve4(true);
69526
+ resolve5(true);
69087
69527
  });
69088
69528
  socket.on("timeout", () => {
69089
69529
  socket.destroy();
69090
- resolve4(false);
69530
+ resolve5(false);
69091
69531
  });
69092
69532
  socket.on("error", () => {
69093
69533
  socket.destroy();
69094
- resolve4(false);
69534
+ resolve5(false);
69095
69535
  });
69096
69536
  });
69097
69537
  }
@@ -69107,12 +69547,12 @@ async function isPortLive(port, timeoutMs = 200) {
69107
69547
  async function isPortAvailable(port) {
69108
69548
  if (port <= 0 || port > 65535)
69109
69549
  return false;
69110
- return new Promise((resolve4) => {
69550
+ return new Promise((resolve5) => {
69111
69551
  const server = createServer();
69112
69552
  server.unref();
69113
- server.on("error", () => resolve4(false));
69553
+ server.on("error", () => resolve5(false));
69114
69554
  server.listen({ port, host: "127.0.0.1" }, () => {
69115
- server.close(() => resolve4(true));
69555
+ server.close(() => resolve5(true));
69116
69556
  });
69117
69557
  });
69118
69558
  }
@@ -69310,7 +69750,7 @@ var init_project_registry = __esm(() => {
69310
69750
 
69311
69751
  // ../../packages/app/src/services/project-start.ts
69312
69752
  import { existsSync as existsSync7 } from "fs";
69313
- import { basename as basename3, resolve as resolve4 } from "path";
69753
+ import { basename as basename3, resolve as resolve5 } from "path";
69314
69754
  function shQuote(value) {
69315
69755
  return `'${value.replace(/'/g, `'\\''`)}'`;
69316
69756
  }
@@ -69336,7 +69776,7 @@ function resolveSpurServeCommand() {
69336
69776
  return [process.execPath, argv1];
69337
69777
  }
69338
69778
  }
69339
- const monorepoCli = resolve4(process.cwd(), "apps/cli/src/index.ts");
69779
+ const monorepoCli = resolve5(process.cwd(), "apps/cli/src/index.ts");
69340
69780
  if (existsSync7(monorepoCli)) {
69341
69781
  return [process.execPath, monorepoCli];
69342
69782
  }
@@ -69448,7 +69888,7 @@ var init_project_start = __esm(() => {
69448
69888
 
69449
69889
  // ../../packages/app/src/services/rule-service.ts
69450
69890
  import { homedir as homedir4 } from "os";
69451
- import { delimiter, join as join14, relative as relative3, resolve as resolve5 } from "path";
69891
+ import { delimiter, join as join14, relative as relative3, resolve as resolve6 } from "path";
69452
69892
 
69453
69893
  class RuleService {
69454
69894
  context;
@@ -69634,16 +70074,16 @@ ${ruleIds.join(`
69634
70074
  if (envValue !== undefined && envValue.length > 0) {
69635
70075
  for (const entry of envValue.split(delimiter)) {
69636
70076
  if (entry.length > 0) {
69637
- layers.push({ id: "env-override", path: resolve5(cwd, entry), priority: -10 });
70077
+ layers.push({ id: "env-override", path: resolve6(cwd, entry), priority: -10 });
69638
70078
  }
69639
70079
  }
69640
70080
  }
69641
- layers.push({ id: "local", path: resolve5(cwd, LOCAL_RULES_DIR), priority: 0 });
70081
+ layers.push({ id: "local", path: resolve6(cwd, LOCAL_RULES_DIR), priority: 0 });
69642
70082
  const globalOverride = env.SPUR_GLOBAL_RULES_DIR;
69643
70083
  const hasGlobalOverride = globalOverride !== undefined && globalOverride.length > 0;
69644
70084
  layers.push({
69645
70085
  id: "global",
69646
- path: hasGlobalOverride ? resolve5(cwd, globalOverride) : join14(homedir4(), GLOBAL_RULES_DIR),
70086
+ path: hasGlobalOverride ? resolve6(cwd, globalOverride) : join14(homedir4(), GLOBAL_RULES_DIR),
69647
70087
  priority: 10
69648
70088
  });
69649
70089
  if (opts.includeBundled && !hasGlobalOverride) {
@@ -69838,7 +70278,7 @@ ${ruleIds.join(`
69838
70278
  async collectValidationErrors(source, validateSchema) {
69839
70279
  const { cwd, fs: fs3 } = this.context;
69840
70280
  if (source.kind === "file") {
69841
- const absolute = resolve5(cwd, source.value);
70281
+ const absolute = resolve6(cwd, source.value);
69842
70282
  if (!await fs3.exists(absolute))
69843
70283
  return [`File not found: ${absolute}`];
69844
70284
  try {
@@ -70363,6 +70803,7 @@ class SupervisorService {
70363
70803
  processExecutor;
70364
70804
  eventBus;
70365
70805
  configDir;
70806
+ serveUrl;
70366
70807
  teamMemberStopEmitted = new Set;
70367
70808
  ringBufferSize;
70368
70809
  processes = new Map;
@@ -70376,6 +70817,7 @@ class SupervisorService {
70376
70817
  this.eventBus = options.eventBus;
70377
70818
  this.configDir = options.configDir;
70378
70819
  this.ringBufferSize = options.ringBufferSize ?? DEFAULT_RING_BUFFER_SIZE;
70820
+ this.serveUrl = options.serveUrl;
70379
70821
  if (options.agentSpecs) {
70380
70822
  this.specsPromise = Promise.resolve(options.agentSpecs);
70381
70823
  }
@@ -70419,7 +70861,13 @@ class SupervisorService {
70419
70861
  source: "supervisor",
70420
70862
  agentId,
70421
70863
  ...teamId ? { teamId } : {},
70422
- env: Object.fromEntries(Object.entries(process.env).filter(([, v]) => v !== undefined))
70864
+ env: {
70865
+ ...Object.fromEntries(Object.entries(process.env).filter(([, v]) => v !== undefined)),
70866
+ SPUR_SPEC_ID: agentId,
70867
+ ...teamId !== null ? { SPUR_TEAM_ID: teamId } : {},
70868
+ SPUR_RUN_ID: crypto.randomUUID(),
70869
+ ...(this.serveUrl ?? process.env.SPUR_SERVE_URL) !== undefined ? { SPUR_SERVE_URL: this.serveUrl ?? process.env.SPUR_SERVE_URL } : {}
70870
+ }
70423
70871
  };
70424
70872
  const handle = this.processExecutor.runStreaming(pipeOpts);
70425
70873
  const pid = handle.pid;
@@ -70496,10 +70944,10 @@ class SupervisorService {
70496
70944
  proc.handle.kill("SIGTERM");
70497
70945
  let timedOut = false;
70498
70946
  const exitPromise = proc.handle.exited;
70499
- const timeout = new Promise((resolve6) => {
70947
+ const timeout = new Promise((resolve7) => {
70500
70948
  setTimeout(() => {
70501
70949
  timedOut = true;
70502
- resolve6();
70950
+ resolve7();
70503
70951
  }, 3000);
70504
70952
  });
70505
70953
  await Promise.race([exitPromise, timeout]);
@@ -70782,6 +71230,30 @@ var init_system_event_emitter = __esm(() => {
70782
71230
  init_system_event_tap();
70783
71231
  });
70784
71232
 
71233
+ // ../../packages/app/src/services/system-event-follow.ts
71234
+ async function* followSystemEventsAfter(getDb, opts) {
71235
+ const dao2 = new SystemEventDao(await getDb());
71236
+ let cursor2 = opts.afterSequence;
71237
+ for (;; ) {
71238
+ if (opts.signal?.aborted === true)
71239
+ return;
71240
+ const rows = await dao2.follow(cursor2, FOLLOW_BATCH_SIZE);
71241
+ for (const row of rows) {
71242
+ const sequence = row.sequence;
71243
+ if (sequence === null || sequence <= cursor2)
71244
+ continue;
71245
+ cursor2 = sequence;
71246
+ if (opts.match(row))
71247
+ yield row;
71248
+ }
71249
+ await sleep2(FOLLOW_POLL_INTERVAL_MS);
71250
+ }
71251
+ }
71252
+ var FOLLOW_POLL_INTERVAL_MS = 100, FOLLOW_BATCH_SIZE = 512, sleep2 = (ms) => new Promise((resolve7) => setTimeout(resolve7, ms));
71253
+ var init_system_event_follow = __esm(() => {
71254
+ init_src2();
71255
+ });
71256
+
70785
71257
  // ../../packages/app/src/services/task-record.ts
70786
71258
  function escapeTablePipe(s2) {
70787
71259
  return s2.replace(/\|/g, "\\|");
@@ -71057,7 +71529,7 @@ var init_task_scaffold = __esm(() => {
71057
71529
  });
71058
71530
 
71059
71531
  // ../../packages/app/src/services/task-service.ts
71060
- import { dirname as dirname14, isAbsolute as isAbsolute2, join as join15, relative as relative4 } from "path";
71532
+ import { dirname as dirname14, isAbsolute as isAbsolute3, join as join15, relative as relative4 } from "path";
71061
71533
  function patchFrontmatterField(rendered, key2, value) {
71062
71534
  const openIdx = rendered.indexOf("---");
71063
71535
  if (openIdx === -1)
@@ -71978,7 +72450,7 @@ ${block}` : block);
71978
72450
  const root = this.ctx.fs.resolve(".");
71979
72451
  const candidate = this.ctx.fs.resolve(folder);
71980
72452
  const rel = relative4(root, candidate);
71981
- if (rel.startsWith("..") || isAbsolute2(rel)) {
72453
+ if (rel.startsWith("..") || isAbsolute3(rel)) {
71982
72454
  throw new Error(`Invalid folder: ${folder} escapes the planning workspace`);
71983
72455
  }
71984
72456
  return candidate;
@@ -72311,7 +72783,7 @@ var init_task_verdict = __esm(() => {
72311
72783
  });
72312
72784
 
72313
72785
  // ../../packages/app/src/services/team-service.ts
72314
- import { join as join16, resolve as resolve6 } from "path";
72786
+ import { join as join16, resolve as resolve7 } from "path";
72315
72787
 
72316
72788
  class TeamService {
72317
72789
  ctx;
@@ -72662,10 +73134,10 @@ class TeamService {
72662
73134
  return result;
72663
73135
  }
72664
73136
  resolveWorkspaceDir(p) {
72665
- return resolve6(this.ctx.cwd, p);
73137
+ return resolve7(this.ctx.cwd, p);
72666
73138
  }
72667
73139
  isCurrentProject(workDir) {
72668
- return resolve6(this.ctx.cwd, workDir) === resolve6(this.ctx.cwd, this.ctx.cwd);
73140
+ return resolve7(this.ctx.cwd, workDir) === resolve7(this.ctx.cwd, this.ctx.cwd);
72669
73141
  }
72670
73142
  commonWorkspace(specs) {
72671
73143
  if (specs.length === 0)
@@ -73115,16 +73587,16 @@ class WorkflowSteeringController {
73115
73587
  active.state = "boundary";
73116
73588
  active.version += 1;
73117
73589
  this.publishState(active);
73118
- return await new Promise((resolve7) => {
73590
+ return await new Promise((resolve8) => {
73119
73591
  const settle = (decision) => {
73120
73592
  clearTimeout(timer);
73121
- resolve7(decision);
73593
+ resolve8(decision);
73122
73594
  };
73123
73595
  const timer = setTimeout(() => {
73124
73596
  if (active.resolve !== settle)
73125
73597
  return;
73126
73598
  active.resolve = undefined;
73127
- this.acceptDefault(active, resolve7);
73599
+ this.acceptDefault(active, resolve8);
73128
73600
  }, active.policy.timeoutMs);
73129
73601
  timer.unref?.();
73130
73602
  active.resolve = settle;
@@ -73222,7 +73694,7 @@ class WorkflowSteeringController {
73222
73694
  deadlineAt: new Date(Date.now() + deadlineMs).toISOString()
73223
73695
  });
73224
73696
  }
73225
- acceptDefault(active, resolve7) {
73697
+ acceptDefault(active, resolve8) {
73226
73698
  const command = {
73227
73699
  commandId: crypto.randomUUID(),
73228
73700
  runId: active.runId,
@@ -73247,7 +73719,7 @@ class WorkflowSteeringController {
73247
73719
  at: new Date().toISOString()
73248
73720
  };
73249
73721
  this.onAck?.(ack);
73250
- resolve7({ operation: "continue" });
73722
+ resolve8({ operation: "continue" });
73251
73723
  }
73252
73724
  accept(command, active, note) {
73253
73725
  return this.publish({
@@ -73311,7 +73783,7 @@ var init_steering = __esm(() => {
73311
73783
 
73312
73784
  // ../../packages/app/src/workflow/actions/agent-run.ts
73313
73785
  import { tmpdir } from "os";
73314
- import { dirname as dirname15, isAbsolute as isAbsolute3, join as join18 } from "path";
73786
+ import { dirname as dirname15, isAbsolute as isAbsolute4, join as join18 } from "path";
73315
73787
 
73316
73788
  class AgentRunActionRunner {
73317
73789
  observabilityBus;
@@ -73447,13 +73919,13 @@ class AgentRunActionRunner {
73447
73919
  const ok = exitCode === 0;
73448
73920
  const invocation = traced.invocation;
73449
73921
  if (capture && answerFile !== undefined) {
73450
- const target = isAbsolute3(answerFile) ? answerFile : join18(cwd, answerFile);
73922
+ const target = isAbsolute4(answerFile) ? answerFile : join18(cwd, answerFile);
73451
73923
  const fs3 = createNodeFileSystem3(cwd);
73452
73924
  await fs3.ensureDir(dirname15(target));
73453
73925
  await fs3.writeFile(target, answer);
73454
73926
  }
73455
73927
  if (ok && expectFile !== undefined) {
73456
- const target = isAbsolute3(expectFile) ? expectFile : join18(cwd, expectFile);
73928
+ const target = isAbsolute4(expectFile) ? expectFile : join18(cwd, expectFile);
73457
73929
  const fs3 = createNodeFileSystem3(cwd);
73458
73930
  if (!await fs3.exists(target)) {
73459
73931
  return {
@@ -74628,7 +75100,7 @@ var init_builtins2 = __esm(() => {
74628
75100
 
74629
75101
  // ../../packages/app/src/services/workflow-service.ts
74630
75102
  import { homedir as homedir5 } from "os";
74631
- import { join as join19, resolve as resolve7 } from "path";
75103
+ import { dirname as dirname16, join as join19, resolve as resolve8 } from "path";
74632
75104
  function signalSubprocess(pid) {
74633
75105
  if (!Number.isInteger(pid) || pid <= 1)
74634
75106
  return false;
@@ -74698,7 +75170,7 @@ class WorkflowAppService {
74698
75170
  };
74699
75171
  }
74700
75172
  async validate(file2, opts = {}) {
74701
- const absolute = resolve7(this.ctx.cwd, file2);
75173
+ const absolute = resolve8(this.ctx.cwd, file2);
74702
75174
  if (!await fileExists(absolute)) {
74703
75175
  return { ok: false, valid: false, file: file2, errors: [`File not found: ${absolute}`] };
74704
75176
  }
@@ -74732,6 +75204,7 @@ class WorkflowAppService {
74732
75204
  if (shellErrors.length > 0) {
74733
75205
  return { ok: false, valid: false, file: file2, errors: shellErrors };
74734
75206
  }
75207
+ await this.loadWorkflowExtensions(createDefaultWorkflowEngineHost(), workflow, absolute);
74735
75208
  return { ok: true, valid: true, workflow };
74736
75209
  } catch (error51) {
74737
75210
  return {
@@ -74744,10 +75217,17 @@ class WorkflowAppService {
74744
75217
  }
74745
75218
  async run(file2, opts = {}) {
74746
75219
  const eventsBus = this.ctx.events?.();
75220
+ const absolute = resolve8(this.ctx.cwd, file2);
75221
+ const embedded = this.embeddedSchemaOptions();
75222
+ const workflow = await loadWorkflowDef(absolute, {
75223
+ validateSchema: true,
75224
+ ...embedded !== undefined ? embedded : {}
75225
+ });
74747
75226
  const svc = await this.createEngineService({
74748
75227
  recordSelfPid: opts.recordSelfPid === true,
74749
75228
  events: eventsBus,
74750
- steeringController: opts.steeringController
75229
+ steeringController: opts.steeringController,
75230
+ extensions: { workflow, file: absolute }
74751
75231
  });
74752
75232
  const runId = opts.runId ?? crypto.randomUUID();
74753
75233
  const isDry = opts.dryRun === true;
@@ -74757,12 +75237,6 @@ class WorkflowAppService {
74757
75237
  ...opts.vars ?? {},
74758
75238
  __runId: runId
74759
75239
  };
74760
- const absolute = resolve7(this.ctx.cwd, file2);
74761
- const embedded = this.embeddedSchemaOptions();
74762
- const workflow = await loadWorkflowDef(absolute, {
74763
- validateSchema: true,
74764
- ...embedded !== undefined ? embedded : {}
74765
- });
74766
75240
  const result = await svc.run(workflow, {
74767
75241
  workdir: this.ctx.cwd,
74768
75242
  runId,
@@ -74793,7 +75267,7 @@ class WorkflowAppService {
74793
75267
  return;
74794
75268
  let workflowName;
74795
75269
  try {
74796
- const def = await loadWorkflowDef(resolve7(this.ctx.cwd, file2), { validateSchema: false });
75270
+ const def = await loadWorkflowDef(resolve8(this.ctx.cwd, file2), { validateSchema: false });
74797
75271
  workflowName = def.name;
74798
75272
  } catch {
74799
75273
  return;
@@ -74885,16 +75359,19 @@ class WorkflowAppService {
74885
75359
  }
74886
75360
  async continuePaused(runId, opts) {
74887
75361
  const eventsBus = this.ctx.events?.();
74888
- const svc = await this.createEngineService({ events: eventsBus });
74889
- const run = await svc.listPausedRuns();
74890
- const target = run.find((r) => r.id === runId);
74891
- if (target === undefined) {
75362
+ const row = await new RunDao(await this.ctx.getDb()).traceRowById(runId);
75363
+ if (row?.status !== "paused") {
74892
75364
  throw new Error(`Run "${runId}" is not paused (or does not exist) - nothing to continue.`);
74893
75365
  }
74894
- const workflow = await this.resolveWorkflowDefByName(target.workflow_name);
74895
- if (workflow === null) {
74896
- throw new Error(`Cannot resume run "${runId}": workflow definition "${target.workflow_name}" not found in the workflow search paths.`);
75366
+ const resolved = await this.resolveWorkflowDefByName(row.workflow_name);
75367
+ if (resolved === null) {
75368
+ throw new Error(`Cannot resume run "${runId}": workflow definition "${row.workflow_name}" not found in the workflow search paths.`);
74897
75369
  }
75370
+ const svc = await this.createEngineService({
75371
+ events: eventsBus,
75372
+ extensions: { workflow: resolved.workflow, file: resolved.path }
75373
+ });
75374
+ const workflow = resolved.workflow;
74898
75375
  const hitlVar = opts?.hitlVar ?? "__hitlAnswer";
74899
75376
  const resumeVars = opts?.hitlAnswer !== undefined ? { [hitlVar]: opts.hitlAnswer } : undefined;
74900
75377
  const result = await svc.resumeRun(workflow, runId, {
@@ -74918,10 +75395,10 @@ class WorkflowAppService {
74918
75395
  if (entry === undefined)
74919
75396
  return null;
74920
75397
  for (const layer of listing.layers) {
74921
- const abs = resolve7(layer.path, entry.path);
75398
+ const abs = resolve8(layer.path, entry.path);
74922
75399
  if (await fileExists(abs)) {
74923
75400
  try {
74924
- return await loadWorkflowDef(abs, { validateSchema: false });
75401
+ return { workflow: await loadWorkflowDef(abs, { validateSchema: false }), path: abs };
74925
75402
  } catch {}
74926
75403
  }
74927
75404
  }
@@ -74934,7 +75411,7 @@ class WorkflowAppService {
74934
75411
  const entries = [];
74935
75412
  const scannedPaths = new Set;
74936
75413
  for (const relPath of workflowPaths) {
74937
- const absPath = resolve7(projectRoot, relPath);
75414
+ const absPath = resolve8(projectRoot, relPath);
74938
75415
  layers.push({ id: "project", path: absPath });
74939
75416
  scannedPaths.add(absPath);
74940
75417
  try {
@@ -74943,7 +75420,7 @@ class WorkflowAppService {
74943
75420
  } catch {}
74944
75421
  }
74945
75422
  for (const relPath of workflowPaths) {
74946
- const absPath = resolve7(globalRoot, relPath);
75423
+ const absPath = resolve8(globalRoot, relPath);
74947
75424
  if (scannedPaths.has(absPath))
74948
75425
  continue;
74949
75426
  layers.push({ id: "global", path: absPath });
@@ -75095,6 +75572,9 @@ class WorkflowAppService {
75095
75572
  ...opts.steeringController !== undefined ? { steeringController: opts.steeringController } : {},
75096
75573
  agentConfig: agentSlice
75097
75574
  });
75575
+ if (opts.extensions !== undefined) {
75576
+ await this.loadWorkflowExtensions(host, opts.extensions.workflow, opts.extensions.file);
75577
+ }
75098
75578
  const db2 = await this.ctx.getDb();
75099
75579
  let persistence2 = new DbWorkflowPersistenceAdapter(db2);
75100
75580
  if (opts.recordSelfPid === true) {
@@ -75103,6 +75583,17 @@ class WorkflowAppService {
75103
75583
  const adapter = bus ? new ObservableWorkflowAdapter(persistence2, bus) : persistence2;
75104
75584
  return new WorkflowService(host, adapter);
75105
75585
  }
75586
+ async loadWorkflowExtensions(host, workflow, file2) {
75587
+ const refs = collectWorkflowExtensions(workflow.name, dirname16(file2), workflow.extensions);
75588
+ if (refs.length === 0)
75589
+ return;
75590
+ const nodeFs = createNodeFileSystem3();
75591
+ await loadWorkflowExtensionsIntoHost(host, refs, {
75592
+ allowExtensions: true,
75593
+ moduleLoader: async (absPath) => await import(absPath),
75594
+ realPath: (absPath) => nodeFs.realPath ? nodeFs.realPath(absPath) : absPath
75595
+ });
75596
+ }
75106
75597
  }
75107
75598
  function collectShellCommands(def) {
75108
75599
  const entries = [];
@@ -75219,7 +75710,7 @@ async function scanWorkflowFiles(rootPath, source) {
75219
75710
  async function walk3(dirPath) {
75220
75711
  const names = await fs3.readDir(dirPath);
75221
75712
  for (const name of names) {
75222
- const fullPath = resolve7(dirPath, name);
75713
+ const fullPath = resolve8(dirPath, name);
75223
75714
  const st = await fs3.stat(fullPath);
75224
75715
  if (!st)
75225
75716
  continue;
@@ -75382,7 +75873,7 @@ async function partialArtifactForAction(cwd, runId, node, ok) {
75382
75873
  if (ok !== false || !TRACE_IDENTIFIER.test(runId) || !TRACE_IDENTIFIER.test(node))
75383
75874
  return;
75384
75875
  const relativePath2 = join19(".spur", "run", `${runId}-${node}-partial.md`);
75385
- return await fileExists(resolve7(cwd, relativePath2)) ? relativePath2 : undefined;
75876
+ return await fileExists(resolve8(cwd, relativePath2)) ? relativePath2 : undefined;
75386
75877
  }
75387
75878
  var TASK_PIPELINE_WORKFLOW = "task-pipeline", EMBEDDED_SCHEMA_PREFIX = "\x00embedded-spur", SPUR_SCHEMA_MANIFEST = "@gobing-ai/spur/package.json", PIPELINE_LINK_KIND = "pipeline", TRACE_IDENTIFIER, TRACE_RESULT_FIELDS, TRACE_INVOCATION_FIELDS;
75388
75879
  var init_workflow_service = __esm(() => {
@@ -75560,7 +76051,7 @@ var init_lifecycle_adapter = __esm(() => {
75560
76051
  });
75561
76052
 
75562
76053
  // ../../packages/app/src/workflow/trace-writer.ts
75563
- import { dirname as dirname16, join as join20 } from "path";
76054
+ import { dirname as dirname17, join as join20 } from "path";
75564
76055
 
75565
76056
  class WorkflowTraceWriter {
75566
76057
  path;
@@ -75594,7 +76085,7 @@ class WorkflowTraceWriter {
75594
76085
  `;
75595
76086
  this.pending = this.pending.then(async () => {
75596
76087
  const fs3 = createNodeFileSystem3();
75597
- await fs3.ensureDir(dirname16(this.path));
76088
+ await fs3.ensureDir(dirname17(this.path));
75598
76089
  await fs3.appendFile(this.path, line);
75599
76090
  });
75600
76091
  }
@@ -75606,12 +76097,15 @@ var init_trace_writer = __esm(() => {
75606
76097
  // ../../packages/app/src/index.ts
75607
76098
  var exports_src2 = {};
75608
76099
  __export(exports_src2, {
76100
+ waitForOccupant: () => waitForOccupant,
75609
76101
  tailTokenLedgerFile: () => tailTokenLedgerFile,
75610
76102
  systemEventProjectContext: () => systemEventProjectContext,
75611
76103
  systemEventCatalogEntry: () => systemEventCatalogEntry,
75612
76104
  summarizeActionResult: () => summarizeActionResult,
75613
76105
  startRegisteredProject: () => startRegisteredProject,
76106
+ snapshotOccupant: () => snapshotOccupant,
75614
76107
  setDetachedServeSpawnForTests: () => setDetachedServeSpawnForTests,
76108
+ satisfies: () => satisfies,
75615
76109
  runHistoryReport: () => runHistoryReport,
75616
76110
  runCorpusCheck: () => runCorpusCheck,
75617
76111
  resolveWorkflowLogRetentionDays: () => resolveWorkflowLogRetentionDays,
@@ -75635,6 +76129,7 @@ __export(exports_src2, {
75635
76129
  readVerdict: () => readVerdict,
75636
76130
  pruneReports: () => pruneReports,
75637
76131
  projectStoredSystemEventEnvelope: () => projectStoredSystemEventEnvelope,
76132
+ projectLifecycle: () => projectLifecycle,
75638
76133
  parseVerdict: () => parseVerdict,
75639
76134
  parseSteeringPolicy: () => parseSteeringPolicy,
75640
76135
  parsePsOutput: () => parsePsOutput,
@@ -75653,6 +76148,7 @@ __export(exports_src2, {
75653
76148
  formatNoopMessage: () => formatNoopMessage,
75654
76149
  formatIssue: () => formatIssue,
75655
76150
  formatDenialMessage: () => formatDenialMessage,
76151
+ followSystemEventsAfter: () => followSystemEventsAfter,
75656
76152
  extractSystemEventCorrelation: () => extractSystemEventCorrelation,
75657
76153
  extractSystemEventActor: () => extractSystemEventActor,
75658
76154
  extractReviewSectionBody: () => extractReviewSectionBody,
@@ -75677,6 +76173,7 @@ __export(exports_src2, {
75677
76173
  WorkflowRunLogSink: () => WorkflowRunLogSink,
75678
76174
  WorkflowAppService: () => WorkflowAppService,
75679
76175
  WbsCollisionError: () => WbsCollisionError,
76176
+ WaitError: () => WaitError,
75680
76177
  UnsupportedProcessPlatformError: () => UnsupportedProcessPlatformError,
75681
76178
  TokenLedgerWatcher: () => TokenLedgerWatcher,
75682
76179
  TokenLedgerService: () => TokenLedgerService,
@@ -75716,6 +76213,7 @@ __export(exports_src2, {
75716
76213
  PluginService: () => PluginService,
75717
76214
  PlanningWriteService: () => PlanningWriteService,
75718
76215
  PS_LIST_ARGV: () => PS_LIST_ARGV,
76216
+ POLL_INTERVAL_MS: () => POLL_INTERVAL_MS,
75719
76217
  PLANNING_EVENT_NAMES: () => PLANNING_EVENT_NAMES,
75720
76218
  ObservableWorkflowAdapter: () => ObservableWorkflowAdapter,
75721
76219
  LockTimeoutError: () => LockTimeoutError,
@@ -75731,6 +76229,7 @@ __export(exports_src2, {
75731
76229
  FileExistsActionRunner: () => FileExistsActionRunner,
75732
76230
  FeatureService: () => FeatureService,
75733
76231
  FeatureCheckService: () => FeatureCheckService,
76232
+ FOLLOW_POLL_INTERVAL_MS: () => FOLLOW_POLL_INTERVAL_MS,
75734
76233
  FINDING_CODES: () => FINDING_CODES,
75735
76234
  FEATURE_LIFECYCLE_PROFILE: () => FEATURE_LIFECYCLE_PROFILE,
75736
76235
  FEATURE_ACTION_NAMES: () => FEATURE_ACTION_NAMES,
@@ -75738,6 +76237,7 @@ __export(exports_src2, {
75738
76237
  DuplicateFollowUpError: () => DuplicateFollowUpError,
75739
76238
  DependencyMutationError: () => DependencyMutationError,
75740
76239
  DEFAULT_SYSTEM_EVENT_RETENTION_QUOTA: () => DEFAULT_SYSTEM_EVENT_RETENTION_QUOTA,
76240
+ DEFAULT_STALL_MS: () => DEFAULT_STALL_MS,
75741
76241
  DEFAULT_RUN_LOG_MAX_BYTES: () => DEFAULT_RUN_LOG_MAX_BYTES,
75742
76242
  DEFAULT_FEATURE_MATRIX: () => DEFAULT_FEATURE_MATRIX,
75743
76243
  CorpusMigrator: () => CorpusMigrator,
@@ -75761,6 +76261,7 @@ var init_src3 = __esm(() => {
75761
76261
  init_feature_service();
75762
76262
  init_finding_codes2();
75763
76263
  init_history_service();
76264
+ init_occupant_wait();
75764
76265
  init_pipeline_run_link();
75765
76266
  init_planning_events();
75766
76267
  init_planning_write_service();
@@ -75772,6 +76273,7 @@ var init_src3 = __esm(() => {
75772
76273
  init_run_store_service();
75773
76274
  init_supervisor_service();
75774
76275
  init_system_event_emitter();
76276
+ init_system_event_follow();
75775
76277
  init_system_event_retention();
75776
76278
  init_system_event_tap();
75777
76279
  init_task_check();
@@ -75874,19 +76376,19 @@ var {
75874
76376
  init_src();
75875
76377
  init_loader();
75876
76378
 
75877
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/application-node.js
76379
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/application-node.js
75878
76380
  init_dist4();
75879
76381
  init_dist5();
75880
76382
  import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync5 } from "fs";
75881
76383
  import { dirname as dirname5 } from "path";
75882
76384
 
75883
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/application/index.js
76385
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/application/index.js
75884
76386
  init_default_observers();
75885
76387
  init_event_bus();
75886
76388
  init_file_observer();
75887
76389
  init_logger3();
75888
76390
 
75889
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/scheduler/noop.js
76391
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/scheduler/noop.js
75890
76392
  class NoopSchedulerAdapter {
75891
76393
  constructor() {}
75892
76394
  register(_cron, _action) {}
@@ -75894,7 +76396,7 @@ class NoopSchedulerAdapter {
75894
76396
  async stop() {}
75895
76397
  }
75896
76398
 
75897
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/scheduler/factory.js
76399
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/scheduler/factory.js
75898
76400
  function initScheduler(adapter, cronEntries) {
75899
76401
  const resolved = adapter ?? new NoopSchedulerAdapter;
75900
76402
  if (cronEntries) {
@@ -75905,7 +76407,7 @@ function initScheduler(adapter, cronEntries) {
75905
76407
  return resolved;
75906
76408
  }
75907
76409
 
75908
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/application/plugins/builtins.js
76410
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/application/plugins/builtins.js
75909
76411
  init_logger3();
75910
76412
  init_metrics();
75911
76413
  init_sdk();
@@ -75998,7 +76500,7 @@ function dbPlugin(db2) {
75998
76500
  };
75999
76501
  }
76000
76502
 
76001
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/application/plugins/host.js
76503
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/application/plugins/host.js
76002
76504
  init_logger3();
76003
76505
 
76004
76506
  class PluginHost {
@@ -76086,7 +76588,7 @@ class PluginHost {
76086
76588
  }
76087
76589
  }
76088
76590
 
76089
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/application/index.js
76591
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/application/index.js
76090
76592
  async function performShutdown(state, reason) {
76091
76593
  if (state.stopped)
76092
76594
  return;
@@ -76197,10 +76699,10 @@ async function runApplication(options) {
76197
76699
  }
76198
76700
  }
76199
76701
 
76200
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/application-node.js
76702
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/application-node.js
76201
76703
  init_scheduler_node();
76202
76704
 
76203
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/telemetry/otel-node.js
76705
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/telemetry/otel-node.js
76204
76706
  var import_api14 = __toESM(require_src(), 1);
76205
76707
 
76206
76708
  // ../../node_modules/.bun/@opentelemetry+exporter-metrics-otlp-http@0.218.0+e40b0dfdd726a224/node_modules/@opentelemetry/exporter-metrics-otlp-http/build/esm/OTLPMetricExporterBase.js
@@ -79216,7 +79718,7 @@ class OTLPTraceExporter extends import_otlp_exporter_base2.OTLPExporterBase {
79216
79718
  }), JsonTraceSerializer));
79217
79719
  }
79218
79720
  }
79219
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/telemetry/otel-node.js
79721
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/telemetry/otel-node.js
79220
79722
  var import_resources2 = __toESM(require_src4(), 1);
79221
79723
  var import_sdk_trace_node = __toESM(require_src8(), 1);
79222
79724
  var import_semantic_conventions = __toESM(require_src2(), 1);
@@ -79267,7 +79769,7 @@ async function shutdownNodeTelemetry() {
79267
79769
  await Promise.all(pending);
79268
79770
  }
79269
79771
 
79270
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.30+fbd4d7afac6bdd9f/node_modules/@gobing-ai/ts-infra/dist/application-node.js
79772
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.31+32e615ef8e1a2a34/node_modules/@gobing-ai/ts-infra/dist/application-node.js
79271
79773
  class ConfigValidationError extends Error {
79272
79774
  constructor(message) {
79273
79775
  super(message);
@@ -83061,6 +83563,7 @@ Font modified May 20, 2012 by patorjk to add the 0xCA0 character
83061
83563
 
83062
83564
  // src/commands/agent.ts
83063
83565
  init_src3();
83566
+ init_src2();
83064
83567
  init_dist6();
83065
83568
  init_dist5();
83066
83569
 
@@ -83145,6 +83648,10 @@ function registerAgentCommand(program2, context4) {
83145
83648
  process.off("SIGTERM", onSignal);
83146
83649
  }
83147
83650
  });
83651
+ agent.command("wait").description("Wait for a pinned occupant run to reach a lifecycle state (G4 wave 2).").argument("<specId>", "Agent spec id whose occupant to wait on").option("--run <runId>", "Pin a specific run id (default: spec latest run)").option("--until <state>", "Lifecycle state to wait for (repeatable OR)", collectUntil, []).option("--timeout <ms>", "Caller deadline in milliseconds", parseTimeout).option("--json", "Output machine-readable JSON").action(async (specId, options) => {
83652
+ const code = await runAgentWait(context4, specId, options);
83653
+ context4.setExitCode(code);
83654
+ });
83148
83655
  agent.command("create").description("Write a team agent spec to .spur/agents/<id>.yaml.").option("--type <agent-type>", "Agent spec type for create").option("--tags <a,b>", "Team identity tags").option("--system-prompt <text>", "Team identity system prompt").option("--name <name>", "Agent name").option("--workspace <path>", "Workspace path").option("--purpose <text>", "Team identity purpose").option("--auto-start", "Auto-start flag").option("--model <name>", "Agent model argument").option("--autonomy <level>", "Autonomy level").option("--no-identity-preamble", "Disable identity preamble").option("--json", "Output machine-readable JSON").argument("<id>", "Agent spec id").action(async (id, options) => {
83149
83656
  const flags = commanderOptionsToFlags(options);
83150
83657
  const code = await runAgentCreate(id, context4, flags);
@@ -83327,7 +83834,7 @@ async function drainIntoPrompt(prompt, context4, flags) {
83327
83834
  }
83328
83835
  const team = new TeamService(context4);
83329
83836
  const spec = (await team.listAgentSpecs()).find((entry) => entry.id === recipient);
83330
- const flagsOut = spec === undefined ? flags : { ...flags, agent: spec.type };
83837
+ const flagsOut = spec === undefined ? flags : { ...flags, "spec-id": spec.id, agent: spec.type };
83331
83838
  const inbox = await team.drainPending(recipient);
83332
83839
  if (inbox.count === 0)
83333
83840
  return { prompt, flags: flagsOut };
@@ -83347,16 +83854,32 @@ function parseLoopPoll(raw) {
83347
83854
  const n2 = Number.parseInt(raw, 10);
83348
83855
  return Number.isFinite(n2) && n2 > 0 ? n2 : DEFAULT_LOOP_POLL_MS;
83349
83856
  }
83857
+ var WAIT_UNTIL_STATES = new Set(["idle", "working", "invoke-exit", "blocked"]);
83858
+ function collectUntil(value, acc) {
83859
+ if (!WAIT_UNTIL_STATES.has(value)) {
83860
+ throw new Error(`invalid --until "${value}" (expected one of: ${[...WAIT_UNTIL_STATES].join(", ")})`);
83861
+ }
83862
+ return [...acc, value];
83863
+ }
83864
+ function parseTimeout(raw) {
83865
+ if (raw === undefined || typeof raw === "boolean")
83866
+ return;
83867
+ const n2 = Number.parseInt(raw, 10);
83868
+ if (!Number.isFinite(n2) || n2 <= 0) {
83869
+ throw new Error(`invalid --timeout "${raw}" (expected a positive integer ms)`);
83870
+ }
83871
+ return n2;
83872
+ }
83350
83873
  function loopSleep(ms, signal) {
83351
- return new Promise((resolve8) => {
83874
+ return new Promise((resolve9) => {
83352
83875
  if (signal?.aborted) {
83353
- resolve8();
83876
+ resolve9();
83354
83877
  return;
83355
83878
  }
83356
- const timer = setTimeout(resolve8, ms);
83879
+ const timer = setTimeout(resolve9, ms);
83357
83880
  signal?.addEventListener("abort", () => {
83358
83881
  clearTimeout(timer);
83359
- resolve8();
83882
+ resolve9();
83360
83883
  }, { once: true });
83361
83884
  });
83362
83885
  }
@@ -83367,7 +83890,7 @@ async function runAgentLoop(context4, flags, runtime = {}, deps) {
83367
83890
  return 2;
83368
83891
  }
83369
83892
  const pollMs = parseLoopPoll(flags.poll);
83370
- const sleep2 = runtime.sleep ?? ((ms) => loopSleep(ms, runtime.signal));
83893
+ const sleep3 = runtime.sleep ?? ((ms) => loopSleep(ms, runtime.signal));
83371
83894
  const svc = context4.agentService();
83372
83895
  let iteration = 0;
83373
83896
  while (!runtime.signal?.aborted && (runtime.maxIterations === undefined || iteration < runtime.maxIterations)) {
@@ -83375,12 +83898,109 @@ async function runAgentLoop(context4, flags, runtime = {}, deps) {
83375
83898
  if (prompt !== undefined) {
83376
83899
  await svc.run(prompt, rewritten, deps);
83377
83900
  } else {
83378
- await sleep2(pollMs);
83901
+ await sleep3(pollMs);
83379
83902
  }
83380
83903
  iteration++;
83381
83904
  }
83382
83905
  return 0;
83383
83906
  }
83907
+ async function readLatestInvokeEvent(dao2, runId) {
83908
+ const rows = await dao2.query({
83909
+ run_id: runId,
83910
+ names: ["agent.invoke.start", "agent.invoke.exit"],
83911
+ limit: 1
83912
+ });
83913
+ const row = rows[0];
83914
+ if (row === undefined)
83915
+ return null;
83916
+ return { eventName: row.event_name, sequence: row.sequence };
83917
+ }
83918
+ async function runAgentWait(context4, specId, options) {
83919
+ const untilList = options.until;
83920
+ if (untilList.length === 0)
83921
+ untilList.push("idle");
83922
+ if (untilList.length === 1 && untilList[0] === "blocked") {
83923
+ return waitUsageError(context4, options, "--until blocked has no first-class signal in this wave; use idle|working|invoke-exit");
83924
+ }
83925
+ const agentService = context4.agentService();
83926
+ const teamService = new TeamService(context4);
83927
+ const eventDao = new SystemEventDao(await context4.getDb());
83928
+ const controller = new AbortController;
83929
+ const onSignal = () => controller.abort();
83930
+ process.on("SIGINT", onSignal);
83931
+ process.on("SIGTERM", onSignal);
83932
+ try {
83933
+ const occupant = await agentService.getOccupant({ specId });
83934
+ if (occupant === null) {
83935
+ return waitFail(context4, options, "occupant_gone", `no occupant for specId "${specId}"`);
83936
+ }
83937
+ const runId = options.run ?? occupant.runId;
83938
+ if (options.run !== undefined && options.run !== occupant.runId) {}
83939
+ const pin = { specId, runId, generation: occupant.generation };
83940
+ let result = null;
83941
+ let firstError = null;
83942
+ for (const until of untilList) {
83943
+ try {
83944
+ result = await waitForOccupant({
83945
+ getOccupant: (id) => agentService.getOccupant({ specId: id }),
83946
+ countPending: (id) => teamService.countPending(id),
83947
+ latestInvokeEvent: (r) => readLatestInvokeEvent(eventDao, r),
83948
+ follow: (afterSequence) => followSystemEventsAfter(context4.getDb, {
83949
+ afterSequence,
83950
+ match: (row) => row.run_id === runId && (row.event_name === "agent.invoke.start" || row.event_name === "agent.invoke.exit"),
83951
+ signal: controller.signal
83952
+ }),
83953
+ now: () => Date.now(),
83954
+ sleep: (ms) => loopSleep(ms, controller.signal)
83955
+ }, {
83956
+ pin,
83957
+ until,
83958
+ timeoutMs: options.timeout,
83959
+ signal: controller.signal
83960
+ });
83961
+ break;
83962
+ } catch (error51) {
83963
+ if (error51 instanceof WaitError) {
83964
+ firstError = error51;
83965
+ if (error51.code !== "wait_stalled")
83966
+ break;
83967
+ } else {
83968
+ throw error51;
83969
+ }
83970
+ }
83971
+ }
83972
+ if (result !== null) {
83973
+ const payload = { satisfied: result.satisfied, pin: result.pin };
83974
+ if (options.json) {
83975
+ context4.output.write(toJson2(payload));
83976
+ } else {
83977
+ context4.output.write(`${pin.specId}/${pin.runId} reached ${result.satisfied}`);
83978
+ }
83979
+ return 0;
83980
+ }
83981
+ const err = firstError ?? new WaitError("wait_stalled", "no --until target satisfied");
83982
+ return waitFail(context4, options, err.code, err.message);
83983
+ } finally {
83984
+ process.off("SIGINT", onSignal);
83985
+ process.off("SIGTERM", onSignal);
83986
+ }
83987
+ }
83988
+ function waitUsageError(context4, options, message) {
83989
+ if (options.json) {
83990
+ context4.output.write(toJson2({ error: { code: "usage", message } }));
83991
+ } else {
83992
+ context4.output.error(message);
83993
+ }
83994
+ return 2;
83995
+ }
83996
+ function waitFail(context4, options, code, message) {
83997
+ if (options.json) {
83998
+ context4.output.write(toJson2({ error: { code, message } }));
83999
+ } else {
84000
+ context4.output.error(`${code}: ${message}`);
84001
+ }
84002
+ return 1;
84003
+ }
83384
84004
 
83385
84005
  // src/commands/feature.ts
83386
84006
  init_src3();
@@ -83416,7 +84036,7 @@ init_loader();
83416
84036
  init_src2();
83417
84037
  import { existsSync as existsSync10 } from "fs";
83418
84038
  import { homedir as homedir6 } from "os";
83419
- import { join as join21, resolve as resolve8 } from "path";
84039
+ import { join as join21, resolve as resolve9 } from "path";
83420
84040
 
83421
84041
  // src/workflow/resolve-spur-bin.ts
83422
84042
  import { basename as basename4 } from "path";
@@ -83437,7 +84057,7 @@ function resolveSpurBin() {
83437
84057
  var GLOBAL_CONFIG_DIR = join21(".config", "spur");
83438
84058
  function globalConfigRoot(context4) {
83439
84059
  const override = context4.env.SPUR_GLOBAL_RULES_DIR;
83440
- return override !== undefined && override.length > 0 ? resolve8(context4.cwd, override) : join21(homedir6(), GLOBAL_CONFIG_DIR);
84060
+ return override !== undefined && override.length > 0 ? resolve9(context4.cwd, override) : join21(homedir6(), GLOBAL_CONFIG_DIR);
83441
84061
  }
83442
84062
  function resolveWorkflowPath(context4, profile) {
83443
84063
  const bundledRoot = bundledConfigRoot();
@@ -83486,7 +84106,7 @@ function registerFeatureCommand(program2, context4) {
83486
84106
  context4.setExitCode(1);
83487
84107
  }
83488
84108
  });
83489
- feature.command("show").summary("Show a feature by ID.").argument("<id>", "Feature ID").option("--folder <path>", "Custom features folder").option("--json", "Output machine-readable JSON").action(async (id, options) => {
84109
+ feature.command("show").alias("get").summary("Show a feature by ID.").argument("<id>", "Feature ID").option("--folder <path>", "Custom features folder").option("--json", "Output machine-readable JSON").action(async (id, options) => {
83490
84110
  const svc = await makeService(context4, options.folder);
83491
84111
  try {
83492
84112
  const result = await svc.show(id);
@@ -83506,7 +84126,12 @@ function registerFeatureCommand(program2, context4) {
83506
84126
  context4.setExitCode(1);
83507
84127
  }
83508
84128
  });
83509
- feature.command("update").summary("Update a feature status, scalar frontmatter field, or section body.").argument("<id>", "Feature ID").argument("[status]", "New lifecycle status").option("--field <key>", "Frontmatter field to set (e.g. priority)").option("--value <value>", "New value for --field").option("--section <name>", "Section name to replace").option("--from-file <path>", "File to read section body from (requires --section)").option("--folder <path>", "Custom features folder").option("--json", "Output machine-readable JSON").action(async (id, status, options) => {
84129
+ feature.command("update").summary("Update a feature status, scalar frontmatter field, or section body.").argument("<id>", "Feature ID").argument("[status]", "New lifecycle status").addHelpText("after", [
84130
+ "Section names are validated against the closed-world canonical set; a rejected",
84131
+ "`--section` costs a failed write. List valid names first:",
84132
+ "`spur task sections <wbs> list`."
84133
+ ].join(`
84134
+ `)).option("--field <key>", "Frontmatter field to set (e.g. priority)").option("--value <value>", "New value for --field").option("--section <name>", "Section name to replace").option("--from-file <path>", "File to read section body from (requires --section)").option("--folder <path>", "Custom features folder").option("--json", "Output machine-readable JSON").action(async (id, status, options) => {
83510
84135
  const svc = await makeService(context4, options.folder);
83511
84136
  try {
83512
84137
  let result;
@@ -83842,7 +84467,7 @@ import { createRequire } from "module";
83842
84467
  var CLI_CONFIG = {
83843
84468
  binaryName: "spur",
83844
84469
  binaryLabel: "spur",
83845
- binaryVersion: "0.3.45",
84470
+ binaryVersion: "0.3.47",
83846
84471
  configDir: ".spur",
83847
84472
  configFile: ".spur/config.yaml",
83848
84473
  databaseFile: ".spur/spur.db"
@@ -84098,7 +84723,7 @@ init_loader();
84098
84723
  init_src2();
84099
84724
  init_dist10();
84100
84725
  import { homedir as homedir7 } from "os";
84101
- import { join as join22, resolve as resolve9 } from "path";
84726
+ import { join as join22, resolve as resolve10 } from "path";
84102
84727
 
84103
84728
  // src/config/scaffold-manifest.ts
84104
84729
  var SCAFFOLD_MANIFEST = [
@@ -84177,7 +84802,7 @@ If \`.spur/context/\` is absent, proceed normally. Never block work on its absen
84177
84802
  `;
84178
84803
  function globalRulesRoot(context4) {
84179
84804
  const override = context4.env.SPUR_GLOBAL_RULES_DIR;
84180
- return override !== undefined && override.length > 0 ? resolve9(context4.cwd, override) : join22(homedir7(), GLOBAL_RULES_DIR2);
84805
+ return override !== undefined && override.length > 0 ? resolve10(context4.cwd, override) : join22(homedir7(), GLOBAL_RULES_DIR2);
84181
84806
  }
84182
84807
  async function writeIfNew(context4, path9, content, force, result) {
84183
84808
  if (!force && await context4.fs.exists(path9)) {
@@ -84208,7 +84833,7 @@ async function seedGlobalConfig(context4) {
84208
84833
  if (source === null)
84209
84834
  return 0;
84210
84835
  const globalOverride = context4.env.SPUR_GLOBAL_RULES_DIR;
84211
- const target = globalOverride !== undefined && globalOverride.length > 0 ? resolve9(context4.cwd, globalOverride) : join22(homedir7(), GLOBAL_CONFIG_DIR2);
84836
+ const target = globalOverride !== undefined && globalOverride.length > 0 ? resolve10(context4.cwd, globalOverride) : join22(homedir7(), GLOBAL_CONFIG_DIR2);
84212
84837
  let written = 0;
84213
84838
  for (const relPath of listBundledConfigFiles()) {
84214
84839
  if (relPath === GLOBAL_CONFIG_EXAMPLE)
@@ -84364,11 +84989,12 @@ ${contextEntry}
84364
84989
 
84365
84990
  // src/commands/message.ts
84366
84991
  init_src3();
84992
+ init_src2();
84367
84993
  var DEFAULT_FROM = "operator";
84368
84994
  var DEFAULT_WATCH_INTERVAL_MS = 2000;
84369
84995
  function registerMessageCommand(program2, context4) {
84370
84996
  const noun = program2.command("message").summary("send and inspect durable inter-agent messages");
84371
- noun.command("send").description("Enqueue a message for an agent.").argument("<body>", "Message body").requiredOption("--to <id>", "Recipient agent id").option("--from <id>", "Sender id", DEFAULT_FROM).option("--json", "Output machine-readable JSON").action(async (body, options) => {
84997
+ noun.command("send").description("Enqueue a message for an agent. Use --wait to block until the recipient reaches a state.").argument("<body>", "Message body").requiredOption("--to <id>", "Recipient agent id").option("--from <id>", "Sender id", DEFAULT_FROM).option("--wait", "Block until the recipient occupant reaches --until (default: invoke-exit)").option("--until <state>", "Wait target for --wait: injected|invoke-exit", collectSendUntil, []).option("--timeout <ms>", "Caller deadline in milliseconds", parseTimeout2).option("--json", "Output machine-readable JSON").action(async (body, options) => {
84372
84998
  const svc = new TeamService(context4);
84373
84999
  const code = await runMessageSend(svc, context4, body, options);
84374
85000
  context4.setExitCode(code);
@@ -84414,13 +85040,100 @@ async function runMessageSend(svc, context4, body, options) {
84414
85040
  return 2;
84415
85041
  }
84416
85042
  const from = options.from || DEFAULT_FROM;
85043
+ let pinnedBeforeSend = null;
85044
+ if (options.wait === true) {
85045
+ const agentService2 = context4.agentService();
85046
+ const occupant = await agentService2.getOccupant({ specId: options.to });
85047
+ if (occupant === null) {
85048
+ return sendWaitFail(context4, options, "occupant_gone", `no occupant for specId "${options.to}"`);
85049
+ }
85050
+ pinnedBeforeSend = { specId: options.to, runId: occupant.runId, generation: occupant.generation };
85051
+ }
84417
85052
  const result = await svc.sendMessage(from, options.to, trimmed);
84418
- if (options.json) {
84419
- context4.output.write(toJson2(result));
84420
- } else {
84421
- context4.output.write(`queued ${result.msgId} \u2192 ${result.toId}`);
85053
+ if (options.wait !== true) {
85054
+ if (options.json) {
85055
+ context4.output.write(toJson2(result));
85056
+ } else {
85057
+ context4.output.write(`queued ${result.msgId} \u2192 ${result.toId}`);
85058
+ }
85059
+ return 0;
85060
+ }
85061
+ if (pinnedBeforeSend === null) {
85062
+ return sendWaitFail(context4, options, "occupant_gone", `no occupant for specId "${options.to}"`);
85063
+ }
85064
+ const pin = pinnedBeforeSend;
85065
+ const untilList = options.until;
85066
+ if (untilList.length === 0)
85067
+ untilList.push("invoke-exit");
85068
+ const agentService = context4.agentService();
85069
+ const eventDao = new SystemEventDao(await context4.getDb());
85070
+ const controller = new AbortController;
85071
+ const onSignal = () => controller.abort();
85072
+ process.on("SIGINT", onSignal);
85073
+ process.on("SIGTERM", onSignal);
85074
+ try {
85075
+ let satisfied = null;
85076
+ let firstError = null;
85077
+ for (const until of untilList) {
85078
+ if (until === "injected") {
85079
+ try {
85080
+ await waitForPendingDrain(agentService, svc, pin, options.timeout, controller.signal);
85081
+ satisfied = "injected";
85082
+ break;
85083
+ } catch (error51) {
85084
+ if (error51 instanceof WaitError) {
85085
+ firstError = error51;
85086
+ if (error51.code !== "wait_stalled")
85087
+ break;
85088
+ } else
85089
+ throw error51;
85090
+ }
85091
+ } else {
85092
+ try {
85093
+ const res = await waitForOccupant({
85094
+ getOccupant: (id) => agentService.getOccupant({ specId: id }),
85095
+ countPending: (id) => svc.countPending(id),
85096
+ latestInvokeEvent: (r) => readLatestInvokeEvent2(eventDao, r),
85097
+ follow: (afterSequence) => followSystemEventsAfter(context4.getDb, {
85098
+ afterSequence,
85099
+ match: (row) => row.run_id === pin.runId && (row.event_name === "agent.invoke.start" || row.event_name === "agent.invoke.exit"),
85100
+ signal: controller.signal
85101
+ }),
85102
+ now: () => Date.now(),
85103
+ sleep: (ms) => sendSleep(ms, controller.signal)
85104
+ }, {
85105
+ pin,
85106
+ until: "invoke-exit",
85107
+ timeoutMs: options.timeout,
85108
+ signal: controller.signal
85109
+ });
85110
+ satisfied = res.satisfied;
85111
+ break;
85112
+ } catch (error51) {
85113
+ if (error51 instanceof WaitError) {
85114
+ firstError = error51;
85115
+ if (error51.code !== "wait_stalled")
85116
+ break;
85117
+ } else
85118
+ throw error51;
85119
+ }
85120
+ }
85121
+ }
85122
+ if (satisfied !== null) {
85123
+ const payload = { msgId: result.msgId, toId: result.toId, status: result.status, wait: { satisfied } };
85124
+ if (options.json) {
85125
+ context4.output.write(toJson2(payload));
85126
+ } else {
85127
+ context4.output.write(`queued ${result.msgId} \u2192 ${result.toId} (wait: ${satisfied})`);
85128
+ }
85129
+ return 0;
85130
+ }
85131
+ const err = firstError ?? new WaitError("wait_stalled", "no --until target satisfied");
85132
+ return sendWaitFail(context4, options, err.code, err.message);
85133
+ } finally {
85134
+ process.off("SIGINT", onSignal);
85135
+ process.off("SIGTERM", onSignal);
84422
85136
  }
84423
- return 0;
84424
85137
  }
84425
85138
  async function runMessageInbox(svc, context4, options) {
84426
85139
  const inbox = await svc.getInbox(options.agent);
@@ -84456,7 +85169,7 @@ function formatInboxLine(entry) {
84456
85169
  return `${entry.id} ${entry.status} ${from} ${body} ${entry.createdAt}`;
84457
85170
  }
84458
85171
  async function runMessageWatch(svc, output2, options, runtime = {}) {
84459
- const sleep2 = runtime.sleep ?? ((ms) => defaultSleep(ms, runtime.signal));
85172
+ const sleep3 = runtime.sleep ?? ((ms) => defaultSleep(ms, runtime.signal));
84460
85173
  const seen = new Set;
84461
85174
  let iteration = 0;
84462
85175
  while (true) {
@@ -84477,19 +85190,19 @@ async function runMessageWatch(svc, output2, options, runtime = {}) {
84477
85190
  }
84478
85191
  }
84479
85192
  iteration++;
84480
- await sleep2(options.intervalMs);
85193
+ await sleep3(options.intervalMs);
84481
85194
  }
84482
85195
  }
84483
85196
  function defaultSleep(ms, signal) {
84484
- return new Promise((resolve10) => {
85197
+ return new Promise((resolve11) => {
84485
85198
  if (signal?.aborted) {
84486
- resolve10();
85199
+ resolve11();
84487
85200
  return;
84488
85201
  }
84489
- const timer = setTimeout(resolve10, ms);
85202
+ const timer = setTimeout(resolve11, ms);
84490
85203
  signal?.addEventListener("abort", () => {
84491
85204
  clearTimeout(timer);
84492
- resolve10();
85205
+ resolve11();
84493
85206
  }, { once: true });
84494
85207
  });
84495
85208
  }
@@ -84499,6 +85212,83 @@ function parseInterval2(raw) {
84499
85212
  return null;
84500
85213
  return n2;
84501
85214
  }
85215
+ var SEND_UNTIL_STATES = new Set(["injected", "invoke-exit"]);
85216
+ function collectSendUntil(value, acc) {
85217
+ if (!SEND_UNTIL_STATES.has(value)) {
85218
+ throw new Error(`invalid --until "${value}" for send --wait (expected one of: ${[...SEND_UNTIL_STATES].join(", ")})`);
85219
+ }
85220
+ return [...acc, value];
85221
+ }
85222
+ function parseTimeout2(raw) {
85223
+ if (raw === undefined || typeof raw === "boolean")
85224
+ return;
85225
+ const n2 = Number.parseInt(raw, 10);
85226
+ if (!Number.isFinite(n2) || n2 <= 0) {
85227
+ throw new Error(`invalid --timeout "${raw}" (expected a positive integer ms)`);
85228
+ }
85229
+ return n2;
85230
+ }
85231
+ function sendSleep(ms, signal) {
85232
+ return new Promise((resolve11) => {
85233
+ if (signal?.aborted) {
85234
+ resolve11();
85235
+ return;
85236
+ }
85237
+ const timer = setTimeout(resolve11, ms);
85238
+ signal?.addEventListener("abort", () => {
85239
+ clearTimeout(timer);
85240
+ resolve11();
85241
+ }, { once: true });
85242
+ });
85243
+ }
85244
+ function sendWaitFail(context4, options, code, message) {
85245
+ if (options.json) {
85246
+ context4.output.write(toJson2({ error: { code, message } }));
85247
+ } else {
85248
+ context4.output.error(`${code}: ${message}`);
85249
+ }
85250
+ return 1;
85251
+ }
85252
+ async function readLatestInvokeEvent2(dao2, runId) {
85253
+ const rows = await dao2.query({
85254
+ run_id: runId,
85255
+ names: ["agent.invoke.start", "agent.invoke.exit"],
85256
+ limit: 1
85257
+ });
85258
+ const row = rows[0];
85259
+ if (row === undefined)
85260
+ return null;
85261
+ return { eventName: row.event_name, sequence: row.sequence };
85262
+ }
85263
+ async function waitForPendingDrain(agentService, teamService, pin, timeoutMs, signal) {
85264
+ const start = Date.now();
85265
+ const deadline = timeoutMs === undefined ? Number.POSITIVE_INFINITY : start + timeoutMs;
85266
+ const stallMs = Math.min(timeoutMs ?? DEFAULT_STALL_MS, DEFAULT_STALL_MS);
85267
+ let lastPending = -1;
85268
+ for (;; ) {
85269
+ if (signal?.aborted)
85270
+ throw new WaitError("timeout", "wait aborted");
85271
+ const clock = Date.now();
85272
+ if (clock >= deadline)
85273
+ throw new WaitError("timeout", `wait timed out after ${timeoutMs}ms`);
85274
+ const occupant = await agentService.getOccupant({ specId: pin.specId });
85275
+ if (occupant === null)
85276
+ throw new WaitError("occupant_gone", `occupant for specId "${pin.specId}" is gone`);
85277
+ if (occupant.runId !== pin.runId)
85278
+ throw new WaitError("run_replaced", `run ${pin.runId} replaced`);
85279
+ if (occupant.generation > pin.generation)
85280
+ throw new WaitError("run_replaced", `generation bumped`);
85281
+ const pending = await teamService.countPending(pin.specId);
85282
+ const progressed = lastPending >= 0 && pending !== lastPending;
85283
+ if (pending === 0)
85284
+ return;
85285
+ if (lastPending >= 0 && !progressed && clock - start >= stallMs) {
85286
+ throw new WaitError("wait_stalled", `inbox not draining within ${stallMs}ms`);
85287
+ }
85288
+ lastPending = pending;
85289
+ await sendSleep(100, signal);
85290
+ }
85291
+ }
84502
85292
 
84503
85293
  // src/commands/migrate.ts
84504
85294
  init_src2();
@@ -84517,12 +85307,12 @@ function registerMigrateCommand(program2, context4) {
84517
85307
  // src/commands/projects.ts
84518
85308
  init_src3();
84519
85309
  init_dist5();
84520
- import { basename as basename5, resolve as resolve10 } from "path";
85310
+ import { basename as basename5, resolve as resolve11 } from "path";
84521
85311
  function registerProjectsCommand(program2, context4) {
84522
85312
  const projectsCmd = program2.command("projects").summary("manage the Spur multi-project registry");
84523
85313
  projectsCmd.command("add").argument("<path>", "Project root directory path").option("--name <name>", "Display name for the project").option("--json", "Output JSON response").action(async (pathArg, options) => {
84524
85314
  try {
84525
- const absolutePath = resolve10(context4.cwd, pathArg);
85315
+ const absolutePath = resolve11(context4.cwd, pathArg);
84526
85316
  if (!await context4.fs.exists(absolutePath)) {
84527
85317
  throw new Error(`Directory does not exist: ${absolutePath}`);
84528
85318
  }
@@ -84953,7 +85743,7 @@ init_src3();
84953
85743
  init_src();
84954
85744
  init_loader();
84955
85745
  init_src2();
84956
- import { basename as basename7, dirname as dirname18, isAbsolute as isAbsolute4, join as join26 } from "path";
85746
+ import { basename as basename7, dirname as dirname19, isAbsolute as isAbsolute5, join as join26 } from "path";
84957
85747
  init_dist5();
84958
85748
 
84959
85749
  // ../server/src/bootstrap.ts
@@ -85230,8 +86020,8 @@ class EventPublisher {
85230
86020
  if (bufferedEvents.length > 0) {
85231
86021
  return { done: false, value: bufferedEvents.shift() };
85232
86022
  }
85233
- return new Promise((resolve11, reject) => {
85234
- pullResolvers.push([resolve11, reject]);
86023
+ return new Promise((resolve12, reject) => {
86024
+ pullResolvers.push([resolve12, reject]);
85235
86025
  });
85236
86026
  }, async () => {
85237
86027
  unsubscribe();
@@ -93904,7 +94694,7 @@ init_src3();
93904
94694
  init_src();
93905
94695
  init_src2();
93906
94696
  init_dist5();
93907
- import { dirname as dirname17, join as join25 } from "path";
94697
+ import { dirname as dirname18, join as join25 } from "path";
93908
94698
  var NOOP_OUTPUT = { write: (_s) => {}, error: (_s) => {} };
93909
94699
 
93910
94700
  class LazyPlanningEventEmitter {
@@ -93976,7 +94766,7 @@ function createServerContext(appRt, options) {
93976
94766
  if (!dbPromise) {
93977
94767
  const created = (async () => {
93978
94768
  if (dbUrl !== IN_MEMORY_DATABASE_URL) {
93979
- await fs3.ensureDir(dirname17(dbUrl));
94769
+ await fs3.ensureDir(dirname18(dbUrl));
93980
94770
  }
93981
94771
  return createMigratedDbViaRuntime({ url: dbUrl });
93982
94772
  })();
@@ -94069,7 +94859,8 @@ function createServerContext(appRt, options) {
94069
94859
  env: options.env ?? {},
94070
94860
  output: NOOP_OUTPUT,
94071
94861
  events: bridgeEventBus(eventsBus),
94072
- processRegistry: this.processRegistry()
94862
+ processRegistry: this.processRegistry(),
94863
+ getDb: this.getDb.bind(this)
94073
94864
  });
94074
94865
  return agentSvc;
94075
94866
  },
@@ -94310,11 +95101,11 @@ async function handleFeatureActionJob(ctx, env, payload) {
94310
95101
  await runFeatureActionJob(ctx, env, payload);
94311
95102
  }
94312
95103
  async function resolveWebDistPath(configuredPath) {
94313
- const candidates = configuredPath && configuredPath.trim() !== "" ? [isAbsolute4(configuredPath) ? configuredPath : join26(process.cwd(), configuredPath)] : [
95104
+ const candidates = configuredPath && configuredPath.trim() !== "" ? [isAbsolute5(configuredPath) ? configuredPath : join26(process.cwd(), configuredPath)] : [
94314
95105
  join26(process.cwd(), "dist/web"),
94315
95106
  join26(import.meta.dir, "web"),
94316
- join26(dirname18(process.execPath), "web"),
94317
- join26(dirname18(process.execPath), "../web"),
95107
+ join26(dirname19(process.execPath), "web"),
95108
+ join26(dirname19(process.execPath), "../web"),
94318
95109
  join26(import.meta.dir, "../../../dist/web")
94319
95110
  ];
94320
95111
  for (const candidate of candidates) {
@@ -94334,7 +95125,7 @@ async function startServer(options, deps = defaultDeps) {
94334
95125
  async start(appRt) {
94335
95126
  const fs3 = deps.createNodeFileSystem(process.cwd());
94336
95127
  if (options.dbUrl && options.dbUrl !== IN_MEMORY_DATABASE_URL) {
94337
- await fs3.ensureDir(dirname18(options.dbUrl));
95128
+ await fs3.ensureDir(dirname19(options.dbUrl));
94338
95129
  }
94339
95130
  let scheduler3;
94340
95131
  if (bootConfig.scheduler.enabled) {
@@ -95018,29 +95809,83 @@ var state_machine_workflow_schema_default = {
95018
95809
  additionalProperties: false,
95019
95810
  required: ["name", "initialState", "states", "transitions"],
95020
95811
  properties: {
95021
- $schema: { type: "string" },
95022
- kind: { const: "state-machine" },
95023
- name: { type: "string", minLength: 1 },
95024
- version: { type: "string" },
95025
- description: { type: "string" },
95026
- initialState: { type: "string", minLength: 1 },
95027
- terminalStates: { type: "array", items: { type: "string", minLength: 1 } },
95812
+ $schema: {
95813
+ type: "string"
95814
+ },
95815
+ kind: {
95816
+ const: "state-machine"
95817
+ },
95818
+ name: {
95819
+ type: "string",
95820
+ minLength: 1
95821
+ },
95822
+ version: {
95823
+ type: "string"
95824
+ },
95825
+ description: {
95826
+ type: "string"
95827
+ },
95828
+ initialState: {
95829
+ type: "string",
95830
+ minLength: 1
95831
+ },
95832
+ terminalStates: {
95833
+ type: "array",
95834
+ items: {
95835
+ type: "string",
95836
+ minLength: 1
95837
+ }
95838
+ },
95028
95839
  failureStates: {
95029
95840
  type: "array",
95030
- items: { type: "string", minLength: 1 },
95841
+ items: {
95842
+ type: "string",
95843
+ minLength: 1
95844
+ },
95031
95845
  description: "Subset of terminalStates whose reach finalizes the run as failed. Absent \u21D2 every terminal is a success."
95032
95846
  },
95033
- iterationBound: { type: "integer", exclusiveMinimum: 0 },
95847
+ iterationBound: {
95848
+ type: "integer",
95849
+ exclusiveMinimum: 0
95850
+ },
95034
95851
  vars: {
95035
95852
  type: "object",
95036
- propertyNames: { pattern: "^[A-Za-z_][A-Za-z0-9_]*$" },
95037
- additionalProperties: { type: "string" }
95853
+ propertyNames: {
95854
+ pattern: "^[A-Za-z_][A-Za-z0-9_]*$"
95855
+ },
95856
+ additionalProperties: {
95857
+ type: "string"
95858
+ }
95038
95859
  },
95039
95860
  env: {
95040
95861
  type: "object",
95041
95862
  additionalProperties: false,
95042
95863
  properties: {
95043
- allow: { type: "array", items: { type: "string", pattern: "^[A-Za-z_][A-Za-z0-9_]*$" } }
95864
+ allow: {
95865
+ type: "array",
95866
+ items: {
95867
+ type: "string",
95868
+ pattern: "^[A-Za-z_][A-Za-z0-9_]*$"
95869
+ }
95870
+ }
95871
+ }
95872
+ },
95873
+ extensions: {
95874
+ type: "object",
95875
+ additionalProperties: false,
95876
+ properties: {
95877
+ actions: {
95878
+ type: "array",
95879
+ items: {
95880
+ $ref: "#/$defs/relativeExtensionPath"
95881
+ }
95882
+ },
95883
+ guards: {
95884
+ type: "array",
95885
+ items: {
95886
+ $ref: "#/$defs/relativeExtensionPath"
95887
+ }
95888
+ }
95044
95889
  }
95045
95890
  },
95046
95891
  states: {
@@ -95050,14 +95895,29 @@ var state_machine_workflow_schema_default = {
95050
95895
  additionalProperties: false,
95051
95896
  required: ["id"],
95052
95897
  properties: {
95053
- id: { type: "string", minLength: 1 },
95054
- description: { type: "string" },
95898
+ id: {
95899
+ type: "string",
95900
+ minLength: 1
95901
+ },
95902
+ description: {
95903
+ type: "string"
95904
+ },
95055
95905
  pause: {
95056
95906
  type: "boolean",
95057
95907
  description: "When true, the engine pauses the run at this state for HITL (E3); resume with `spur workflow continue`."
95058
95908
  },
95059
- onEnter: { type: "array", items: { $ref: "#/$defs/action" } },
95060
- onExit: { type: "array", items: { $ref: "#/$defs/action" } }
95909
+ onEnter: {
95910
+ type: "array",
95911
+ items: {
95912
+ $ref: "#/$defs/action"
95913
+ }
95914
+ },
95915
+ onExit: {
95916
+ type: "array",
95917
+ items: {
95918
+ $ref: "#/$defs/action"
95919
+ }
95920
+ }
95061
95921
  }
95062
95922
  }
95063
95923
  },
@@ -95068,11 +95928,23 @@ var state_machine_workflow_schema_default = {
95068
95928
  additionalProperties: false,
95069
95929
  required: ["from", "to"],
95070
95930
  properties: {
95071
- from: { type: "string", minLength: 1 },
95072
- to: { type: "string", minLength: 1 },
95073
- description: { type: "string" },
95074
- trigger: { type: "string" },
95075
- guard: { $ref: "#/$defs/guard" }
95931
+ from: {
95932
+ type: "string",
95933
+ minLength: 1
95934
+ },
95935
+ to: {
95936
+ type: "string",
95937
+ minLength: 1
95938
+ },
95939
+ description: {
95940
+ type: "string"
95941
+ },
95942
+ trigger: {
95943
+ type: "string"
95944
+ },
95945
+ guard: {
95946
+ $ref: "#/$defs/guard"
95947
+ }
95076
95948
  }
95077
95949
  }
95078
95950
  }
@@ -95083,8 +95955,14 @@ var state_machine_workflow_schema_default = {
95083
95955
  additionalProperties: false,
95084
95956
  required: ["kind"],
95085
95957
  properties: {
95086
- kind: { type: "string", minLength: 1 },
95087
- options: { type: "object", additionalProperties: true }
95958
+ kind: {
95959
+ type: "string",
95960
+ minLength: 1
95961
+ },
95962
+ options: {
95963
+ type: "object",
95964
+ additionalProperties: true
95965
+ }
95088
95966
  }
95089
95967
  },
95090
95968
  guard: {
@@ -95092,8 +95970,32 @@ var state_machine_workflow_schema_default = {
95092
95970
  additionalProperties: false,
95093
95971
  required: ["kind"],
95094
95972
  properties: {
95095
- kind: { type: "string", minLength: 1 },
95096
- options: { type: "object", additionalProperties: true }
95973
+ kind: {
95974
+ type: "string",
95975
+ minLength: 1
95976
+ },
95977
+ options: {
95978
+ type: "object",
95979
+ additionalProperties: true
95980
+ }
95981
+ }
95982
+ },
95983
+ relativeExtensionPath: {
95984
+ type: "string",
95985
+ minLength: 1,
95986
+ description: "Relative module path; absolute paths and '..' traversal are forbidden.",
95987
+ not: {
95988
+ anyOf: [
95989
+ {
95990
+ pattern: "^[/\\\\]"
95991
+ },
95992
+ {
95993
+ pattern: "^[A-Za-z]:[/\\\\]"
95994
+ },
95995
+ {
95996
+ pattern: "(^|[/\\\\])\\.\\.([/\\\\]|$)"
95997
+ }
95998
+ ]
95097
95999
  }
95098
96000
  }
95099
96001
  }
@@ -95107,24 +96009,75 @@ var transition_flow_workflow_schema_default = {
95107
96009
  additionalProperties: false,
95108
96010
  required: ["kind", "name", "initialNode", "nodes", "edges"],
95109
96011
  properties: {
95110
- $schema: { type: "string" },
95111
- kind: { const: "transition-flow" },
95112
- name: { type: "string", minLength: 1 },
95113
- version: { type: "string" },
95114
- description: { type: "string" },
95115
- initialNode: { type: "string", minLength: 1 },
95116
- terminalNodes: { type: "array", items: { type: "string", minLength: 1 } },
95117
- iterationBound: { type: "integer", exclusiveMinimum: 0 },
96012
+ $schema: {
96013
+ type: "string"
96014
+ },
96015
+ kind: {
96016
+ const: "transition-flow"
96017
+ },
96018
+ name: {
96019
+ type: "string",
96020
+ minLength: 1
96021
+ },
96022
+ version: {
96023
+ type: "string"
96024
+ },
96025
+ description: {
96026
+ type: "string"
96027
+ },
96028
+ initialNode: {
96029
+ type: "string",
96030
+ minLength: 1
96031
+ },
96032
+ terminalNodes: {
96033
+ type: "array",
96034
+ items: {
96035
+ type: "string",
96036
+ minLength: 1
96037
+ }
96038
+ },
96039
+ iterationBound: {
96040
+ type: "integer",
96041
+ exclusiveMinimum: 0
96042
+ },
95118
96043
  vars: {
95119
96044
  type: "object",
95120
- propertyNames: { pattern: "^[A-Za-z_][A-Za-z0-9_]*$" },
95121
- additionalProperties: { type: "string" }
96045
+ propertyNames: {
96046
+ pattern: "^[A-Za-z_][A-Za-z0-9_]*$"
96047
+ },
96048
+ additionalProperties: {
96049
+ type: "string"
96050
+ }
95122
96051
  },
95123
96052
  env: {
95124
96053
  type: "object",
95125
96054
  additionalProperties: false,
95126
96055
  properties: {
95127
- allow: { type: "array", items: { type: "string", pattern: "^[A-Za-z_][A-Za-z0-9_]*$" } }
96056
+ allow: {
96057
+ type: "array",
96058
+ items: {
96059
+ type: "string",
96060
+ pattern: "^[A-Za-z_][A-Za-z0-9_]*$"
96061
+ }
96062
+ }
96063
+ }
96064
+ },
96065
+ extensions: {
96066
+ type: "object",
96067
+ additionalProperties: false,
96068
+ properties: {
96069
+ actions: {
96070
+ type: "array",
96071
+ items: {
96072
+ $ref: "#/$defs/relativeExtensionPath"
96073
+ }
96074
+ },
96075
+ guards: {
96076
+ type: "array",
96077
+ items: {
96078
+ $ref: "#/$defs/relativeExtensionPath"
96079
+ }
96080
+ }
95128
96081
  }
95129
96082
  },
95130
96083
  nodes: {
@@ -95134,10 +96087,19 @@ var transition_flow_workflow_schema_default = {
95134
96087
  additionalProperties: false,
95135
96088
  required: ["id"],
95136
96089
  properties: {
95137
- id: { type: "string", minLength: 1 },
95138
- description: { type: "string" },
95139
- type: { enum: ["action", "gate", "parallel", "decision"] },
95140
- action: { $ref: "#/$defs/action" }
96090
+ id: {
96091
+ type: "string",
96092
+ minLength: 1
96093
+ },
96094
+ description: {
96095
+ type: "string"
96096
+ },
96097
+ type: {
96098
+ enum: ["action", "gate", "parallel", "decision"]
96099
+ },
96100
+ action: {
96101
+ $ref: "#/$defs/action"
96102
+ }
95141
96103
  }
95142
96104
  }
95143
96105
  },
@@ -95148,10 +96110,20 @@ var transition_flow_workflow_schema_default = {
95148
96110
  additionalProperties: false,
95149
96111
  required: ["from", "to"],
95150
96112
  properties: {
95151
- from: { type: "string", minLength: 1 },
95152
- to: { type: "string", minLength: 1 },
95153
- description: { type: "string" },
95154
- condition: { $ref: "#/$defs/guard" }
96113
+ from: {
96114
+ type: "string",
96115
+ minLength: 1
96116
+ },
96117
+ to: {
96118
+ type: "string",
96119
+ minLength: 1
96120
+ },
96121
+ description: {
96122
+ type: "string"
96123
+ },
96124
+ condition: {
96125
+ $ref: "#/$defs/guard"
96126
+ }
95155
96127
  }
95156
96128
  }
95157
96129
  }
@@ -95162,8 +96134,14 @@ var transition_flow_workflow_schema_default = {
95162
96134
  additionalProperties: false,
95163
96135
  required: ["kind"],
95164
96136
  properties: {
95165
- kind: { type: "string", minLength: 1 },
95166
- options: { type: "object", additionalProperties: true }
96137
+ kind: {
96138
+ type: "string",
96139
+ minLength: 1
96140
+ },
96141
+ options: {
96142
+ type: "object",
96143
+ additionalProperties: true
96144
+ }
95167
96145
  }
95168
96146
  },
95169
96147
  guard: {
@@ -95171,8 +96149,32 @@ var transition_flow_workflow_schema_default = {
95171
96149
  additionalProperties: false,
95172
96150
  required: ["kind"],
95173
96151
  properties: {
95174
- kind: { type: "string", minLength: 1 },
95175
- options: { type: "object", additionalProperties: true }
96152
+ kind: {
96153
+ type: "string",
96154
+ minLength: 1
96155
+ },
96156
+ options: {
96157
+ type: "object",
96158
+ additionalProperties: true
96159
+ }
96160
+ }
96161
+ },
96162
+ relativeExtensionPath: {
96163
+ type: "string",
96164
+ minLength: 1,
96165
+ description: "Relative module path; absolute paths and '..' traversal are forbidden.",
96166
+ not: {
96167
+ anyOf: [
96168
+ {
96169
+ pattern: "^[/\\\\]"
96170
+ },
96171
+ {
96172
+ pattern: "^[A-Za-z]:[/\\\\]"
96173
+ },
96174
+ {
96175
+ pattern: "(^|[/\\\\])\\.\\.([/\\\\]|$)"
96176
+ }
96177
+ ]
95176
96178
  }
95177
96179
  }
95178
96180
  }
@@ -95311,7 +96313,7 @@ function registerTaskCommand(program2, context4) {
95311
96313
  }
95312
96314
  }
95313
96315
  });
95314
- task.command("show").summary("Show a task by WBS.").argument("<wbs>", "Task WBS number").option("--folder <path>", "Custom tasks folder").option("--json", "Output machine-readable JSON").action(async (wbs, options) => {
96316
+ task.command("show").alias("get").summary("Show a task by WBS.").argument("<wbs>", "Task WBS number").option("--folder <path>", "Custom tasks folder").option("--json", "Output machine-readable JSON").action(async (wbs, options) => {
95315
96317
  const svc = await makeService2(context4, options.folder);
95316
96318
  try {
95317
96319
  const result = await svc.show(wbs);
@@ -95335,7 +96337,8 @@ ${result.content}`);
95335
96337
  "A GuardDeniedError on `testing \u2192 done` means no pipeline run is recorded for the",
95336
96338
  "task: run `/sp:dev-verify <wbs> --next` to PASS it, or record the audited bypass with",
95337
96339
  '`SPUR_PROVENANCE_OVERRIDE=1 spur task update <wbs> done --force-done --reason "\u2026"`.',
95338
- "See the gate checklist (spur-dev/references/gate-checklists.md)."
96340
+ "See the gate checklist (spur-dev/references/gate-checklists.md).",
96341
+ "Valid section names (no failed write): `spur task sections <wbs> list`."
95339
96342
  ].join(`
95340
96343
  `)).option("--section <name>", "Section name to replace").option("--from-file <path>", "File to read section body from (requires --section)").option("--feature <id>", "Set the feature_id frontmatter field (traceability edge)").option("--priority <p>", "Set the priority frontmatter field (P0\u2013P3)").option("--ac-numbering <mode>", "Set the ac_numbering frontmatter field (task-local) \u2014 opts the task into the Requirements\u2194AC coverage check").option("--no-lifecycle", "Suppress lifecycle workflow run creation (use during pipeline runs to avoid orphaned lifecycle runs)").option("--force-done", "Allow transitioning to `done` even when the verify verdict is not PASS; records an override (task 0292). Waives the verdict only \u2014 the FSM path still applies, so from an earlier status walk the hops first: `todo` \u2192 `wip` \u2192 `testing` \u2192 `done` (each hop runs the structural `spur task check`)").option("--reason <text>", "Rationale for a forced-done override (paired with --force-done; persisted as done_reason)").option("--verdict-dir <path>", "Directory holding <wbs>-verdict.json artifacts (default: .spur/run)").option("--folder <path>", "Custom tasks folder").option("--json", "Output machine-readable JSON").action(async (wbs, status, options) => {
95341
96344
  const svc = await makeService2(context4, options.folder, options.lifecycle === false);
@@ -96377,9 +97380,9 @@ init_dist7();
96377
97380
  init_dist6();
96378
97381
  init_dist5();
96379
97382
  import { closeSync as closeSync5, fstatSync as fstatSync3, openSync as openSync5, readSync as readSync3 } from "fs";
96380
- import { join as join30, resolve as resolve11 } from "path";
97383
+ import { join as join30, resolve as resolve12 } from "path";
96381
97384
  import { createInterface } from "readline";
96382
- import { setTimeout as sleep3 } from "timers/promises";
97385
+ import { setTimeout as sleep4 } from "timers/promises";
96383
97386
  function shQuote2(value2) {
96384
97387
  return `'${value2.replace(/'/g, `'\\''`)}'`;
96385
97388
  }
@@ -96413,7 +97416,7 @@ async function waitForRunRegistration(service, runId, timeoutMs = asyncRegisterT
96413
97416
  if (Date.now() >= deadline) {
96414
97417
  return false;
96415
97418
  }
96416
- await sleep3(pollMs);
97419
+ await sleep4(pollMs);
96417
97420
  }
96418
97421
  }
96419
97422
  }
@@ -96576,7 +97579,7 @@ Monitor with: spur workflow trace ${runId2} --follow`);
96576
97579
  let planPreview;
96577
97580
  if (options.plan !== false) {
96578
97581
  try {
96579
- const def = await loadWorkflowDef(resolve11(context4.cwd, file2), { validateSchema: false });
97582
+ const def = await loadWorkflowDef(resolve12(context4.cwd, file2), { validateSchema: false });
96580
97583
  planPreview = renderRunPlan(def);
96581
97584
  } catch {}
96582
97585
  }
@@ -96960,7 +97963,7 @@ function formatTimelineEvent(event2) {
96960
97963
  return lines.join(`
96961
97964
  `);
96962
97965
  }
96963
- async function followTrace(service, runId, pollMs, write, wait = (ms) => sleep3(ms)) {
97966
+ async function followTrace(service, runId, pollMs, write, wait = (ms) => sleep4(ms)) {
96964
97967
  let missingAttempts = 0;
96965
97968
  let timeline;
96966
97969
  while (true) {
@@ -97027,7 +98030,7 @@ function readRunLogChunk(logPath, offset) {
97027
98030
  closeSync5(fd);
97028
98031
  }
97029
98032
  }
97030
- async function followRunLog(service, runId, dir, pollMs, write, wait = (ms) => sleep3(ms)) {
98033
+ async function followRunLog(service, runId, dir, pollMs, write, wait = (ms) => sleep4(ms)) {
97031
98034
  const logPath = join30(dir, ".spur", "run", `${runId}.log`);
97032
98035
  let offset = 0;
97033
98036
  let everRead = false;
@@ -97075,7 +98078,7 @@ init_src3();
97075
98078
  init_src();
97076
98079
  init_src2();
97077
98080
  init_dist5();
97078
- import { dirname as dirname19, join as join31, resolve as resolve12 } from "path";
98081
+ import { dirname as dirname20, join as join31, resolve as resolve13 } from "path";
97079
98082
  import { isatty as isatty4 } from "tty";
97080
98083
 
97081
98084
  // ../../node_modules/.bun/@clack+core@1.4.1/node_modules/@clack/core/dist/index.mjs
@@ -98458,7 +99461,7 @@ class DefaultHitlResponder {
98458
99461
 
98459
99462
  // src/context.ts
98460
99463
  function createCliContext(options) {
98461
- const cwd = resolve12(options.cwd ?? process.cwd());
99464
+ const cwd = resolve13(options.cwd ?? process.cwd());
98462
99465
  const env = options.env ?? process.env;
98463
99466
  const fs3 = createNodeFileSystem3(cwd);
98464
99467
  let dbPromise;
@@ -98482,6 +99485,7 @@ function createCliContext(options) {
98482
99485
  env,
98483
99486
  output: options.output,
98484
99487
  agentConfig: options.agentConfig,
99488
+ getDb,
98485
99489
  ...serviceOptions?.events !== undefined ? { events: serviceOptions.events } : {},
98486
99490
  ...serviceOptions?.processRegistry !== undefined ? { processRegistry: serviceOptions.processRegistry } : {}
98487
99491
  }),
@@ -98500,7 +99504,7 @@ async function createMigratedDbAdapter(cwd = process.cwd(), env = process.env, d
98500
99504
  const configuredUrl = env.DATABASE_URL === undefined ? join31(cwd, DEFAULT_DATABASE_URL) : config4.database.url;
98501
99505
  const url2 = dbUrl ?? configuredUrl;
98502
99506
  if (url2 !== IN_MEMORY_DATABASE_URL) {
98503
- await createNodeFileSystem3().ensureDir(dirname19(url2));
99507
+ await createNodeFileSystem3().ensureDir(dirname20(url2));
98504
99508
  }
98505
99509
  return createMigratedDb({ url: url2 });
98506
99510
  }