@gobing-ai/spur 0.3.10 → 0.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/config/rules/typescript/guarded-happy-dom-register.yaml +14 -36
  2. package/config/workflows/feature-dev.yaml +5 -5
  3. package/config/workflows/idea-pipeline.yaml +2 -2
  4. package/config/workflows/task-pipeline.yaml +1 -1
  5. package/package.json +9 -9
  6. package/schemas/spur-config.schema.json +64 -0
  7. package/spur.js +1634 -301
  8. package/web/_astro/{BoardApp.C6AZyK1W.js → BoardApp.CqBOrPzf.js} +106 -106
  9. package/web/_astro/BoardApp.XG2FoRlA.js +1 -0
  10. package/web/_astro/{TaskDetail.qCmrwQkG.js → TaskDetail.BmxycoeS.js} +1 -1
  11. package/web/_astro/{arc.CbRppOdF.js → arc.-ZkWbWcN.js} +1 -1
  12. package/web/_astro/{architectureDiagram-3BPJPVTR.9PfIcrsr.js → architectureDiagram-3BPJPVTR.fJ8ETc6n.js} +1 -1
  13. package/web/_astro/{blockDiagram-GPEHLZMM.D8X1aH9F.js → blockDiagram-GPEHLZMM.CdhoveXr.js} +1 -1
  14. package/web/_astro/{c4Diagram-AAUBKEIU.BnAemEBs.js → c4Diagram-AAUBKEIU.CWv7Jy0p.js} +1 -1
  15. package/web/_astro/channel.BrBVc6tg.js +1 -0
  16. package/web/_astro/{chunk-2J33WTMH.DzOqcSmH.js → chunk-2J33WTMH.CvYWDwal.js} +1 -1
  17. package/web/_astro/{chunk-4BX2VUAB.AqtW-DKu.js → chunk-4BX2VUAB.BVp_y1oc.js} +1 -1
  18. package/web/_astro/{chunk-55IACEB6.BIRjE6jR.js → chunk-55IACEB6.CQCviGQk.js} +1 -1
  19. package/web/_astro/{chunk-727SXJPM.CgDzPlSk.js → chunk-727SXJPM.B3E6Bisv.js} +1 -1
  20. package/web/_astro/{chunk-AQP2D5EJ.DjOW-ScW.js → chunk-AQP2D5EJ.BvWfYj9E.js} +1 -1
  21. package/web/_astro/{chunk-FMBD7UC4.wdJmHym6.js → chunk-FMBD7UC4.DcLP2Ypw.js} +1 -1
  22. package/web/_astro/{chunk-ND2GUHAM.C-Ho8u3p.js → chunk-ND2GUHAM.DvXZJEqI.js} +1 -1
  23. package/web/_astro/{chunk-QZHKN3VN.BF1HouUh.js → chunk-QZHKN3VN.D4rK2HTI.js} +1 -1
  24. package/web/_astro/{classDiagram-4FO5ZUOK.DAyOMMHn.js → classDiagram-4FO5ZUOK.DSCYtdVf.js} +1 -1
  25. package/web/_astro/{classDiagram-v2-Q7XG4LA2.DAyOMMHn.js → classDiagram-v2-Q7XG4LA2.DSCYtdVf.js} +1 -1
  26. package/web/_astro/{cose-bilkent-S5V4N54A.CNoutjqT.js → cose-bilkent-S5V4N54A.Bf7HMV4Q.js} +1 -1
  27. package/web/_astro/{dagre-BM42HDAG.yQbaJnir.js → dagre-BM42HDAG.DsBoJTBN.js} +1 -1
  28. package/web/_astro/{diagram-2AECGRRQ.Y-0ZX0wP.js → diagram-2AECGRRQ.BMVxdKV3.js} +1 -1
  29. package/web/_astro/{diagram-5GNKFQAL.Co7hW1JF.js → diagram-5GNKFQAL.BllW5zst.js} +1 -1
  30. package/web/_astro/{diagram-KO2AKTUF.BW6g9zEB.js → diagram-KO2AKTUF.CNHoSD6q.js} +1 -1
  31. package/web/_astro/{diagram-LMA3HP47.5laYcnBs.js → diagram-LMA3HP47.DZT6otFZ.js} +1 -1
  32. package/web/_astro/{diagram-OG6HWLK6.DOXfn0B3.js → diagram-OG6HWLK6.EwFWHBRO.js} +1 -1
  33. package/web/_astro/{erDiagram-TEJ5UH35.B65zPLW1.js → erDiagram-TEJ5UH35.CaXPcR5W.js} +1 -1
  34. package/web/_astro/{flowDiagram-I6XJVG4X.EyV3nzyc.js → flowDiagram-I6XJVG4X.FEcfML44.js} +1 -1
  35. package/web/_astro/{ganttDiagram-6RSMTGT7.Dbg3JgqV.js → ganttDiagram-6RSMTGT7.Bs7t3AQM.js} +1 -1
  36. package/web/_astro/{gitGraphDiagram-PVQCEYII.C_h4o8Bn.js → gitGraphDiagram-PVQCEYII.DmxLV9JC.js} +1 -1
  37. package/web/_astro/index.BOgTYz24.css +1 -0
  38. package/web/_astro/{infoDiagram-5YYISTIA.DmMa9Qku.js → infoDiagram-5YYISTIA.E7_NrFUE.js} +1 -1
  39. package/web/_astro/{ishikawaDiagram-YF4QCWOH.GWMrgoLC.js → ishikawaDiagram-YF4QCWOH.Bs5Q4r-U.js} +1 -1
  40. package/web/_astro/{journeyDiagram-JHISSGLW.BWABlU6N.js → journeyDiagram-JHISSGLW.D3U7T1y1.js} +1 -1
  41. package/web/_astro/{kanban-definition-UN3LZRKU.MbfHFA2-.js → kanban-definition-UN3LZRKU.DfdWsO2E.js} +1 -1
  42. package/web/_astro/{linear.BmIHCCO9.js → linear.CAqUTUf3.js} +1 -1
  43. package/web/_astro/{mermaid.core.CpHEEQAK.js → mermaid.core.ZlPUJ21K.js} +4 -4
  44. package/web/_astro/{mindmap-definition-RKZ34NQL.DYK94Ave.js → mindmap-definition-RKZ34NQL.ClTJkcTG.js} +1 -1
  45. package/web/_astro/{pieDiagram-4H26LBE5.CnEGAkqK.js → pieDiagram-4H26LBE5.B9kJfBw_.js} +1 -1
  46. package/web/_astro/{quadrantDiagram-W4KKPZXB.CsByTJjg.js → quadrantDiagram-W4KKPZXB.CtTJH5Fo.js} +1 -1
  47. package/web/_astro/{requirementDiagram-4Y6WPE33.AL6ZRSrQ.js → requirementDiagram-4Y6WPE33.WVLq9rr2.js} +1 -1
  48. package/web/_astro/{sankeyDiagram-5OEKKPKP.BLAeuWlE.js → sankeyDiagram-5OEKKPKP.L_XUdyqe.js} +1 -1
  49. package/web/_astro/{sequenceDiagram-3UESZ5HK.BGpsvxUR.js → sequenceDiagram-3UESZ5HK.DCdtsEdj.js} +1 -1
  50. package/web/_astro/{stateDiagram-AJRCARHV.BBk0gd25.js → stateDiagram-AJRCARHV.-Koi9kLh.js} +1 -1
  51. package/web/_astro/{stateDiagram-v2-BHNVJYJU.BrqvmSUS.js → stateDiagram-v2-BHNVJYJU.DHXu_l8w.js} +1 -1
  52. package/web/_astro/{timeline-definition-PNZ67QCA.DkZf5CQT.js → timeline-definition-PNZ67QCA.Czotaq0j.js} +1 -1
  53. package/web/_astro/{vennDiagram-CIIHVFJN.BZvWwMZF.js → vennDiagram-CIIHVFJN.BfEI3zhc.js} +1 -1
  54. package/web/_astro/{wardley-L42UT6IY.HfB08mt3.js → wardley-L42UT6IY.C33mahwT.js} +1 -1
  55. package/web/_astro/{wardleyDiagram-YWT4CUSO.DgpZzmgA.js → wardleyDiagram-YWT4CUSO.D8IzxB1w.js} +1 -1
  56. package/web/_astro/{xychartDiagram-2RQKCTM6.BlgrPsbQ.js → xychartDiagram-2RQKCTM6.D-cfi9uT.js} +1 -1
  57. package/web/index.html +2 -2
  58. package/web/_astro/BoardApp.EXjc9f_0.js +0 -1
  59. package/web/_astro/channel.DDlSVLNA.js +0 -1
  60. package/web/_astro/index.BSoQ0ZL0.css +0 -1
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.8/node_modules/@gobing-ai/ts-utils/dist/errors.js
50
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.10/node_modules/@gobing-ai/ts-utils/dist/errors.js
51
51
  function isAppError(error) {
52
52
  return error instanceof AppError;
53
53
  }
@@ -75,7 +75,7 @@ var init_errors = __esm(() => {
75
75
  };
76
76
  });
77
77
 
78
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.8/node_modules/@gobing-ai/ts-utils/dist/api-response.js
78
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.10/node_modules/@gobing-ai/ts-utils/dist/api-response.js
79
79
  var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
80
80
  var init_api_response = __esm(() => {
81
81
  init_errors();
@@ -98,10 +98,10 @@ var init_api_response = __esm(() => {
98
98
  CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
99
99
  });
100
100
 
101
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.8/node_modules/@gobing-ai/ts-utils/dist/cursor.js
101
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.10/node_modules/@gobing-ai/ts-utils/dist/cursor.js
102
102
  var init_cursor = () => {};
103
103
 
104
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.8/node_modules/@gobing-ai/ts-utils/dist/object.js
104
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.10/node_modules/@gobing-ai/ts-utils/dist/object.js
105
105
  function isPlainObject(value) {
106
106
  return typeof value === "object" && value !== null && !Array.isArray(value);
107
107
  }
@@ -117,7 +117,7 @@ function deepMerge(target, source) {
117
117
  return result;
118
118
  }
119
119
 
120
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.8/node_modules/@gobing-ai/ts-utils/dist/output.js
120
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.10/node_modules/@gobing-ai/ts-utils/dist/output.js
121
121
  function processStream(name) {
122
122
  const proc = globalThis.process;
123
123
  const stream = proc?.[name];
@@ -138,7 +138,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
138
138
  }
139
139
  var defaultStdoutTarget, defaultStderrTarget;
140
140
 
141
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.8/node_modules/@gobing-ai/ts-utils/dist/index.js
141
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.4.10/node_modules/@gobing-ai/ts-utils/dist/index.js
142
142
  var init_dist = __esm(() => {
143
143
  init_api_response();
144
144
  init_cursor();
@@ -21760,7 +21760,10 @@ var init_zod = __esm(() => {
21760
21760
  init_external();
21761
21761
  });
21762
21762
 
21763
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+25c63b82bf4f1018/node_modules/@gobing-ai/ts-runtime/dist/config.js
21763
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+170d5985e987c687/node_modules/@gobing-ai/ts-runtime/dist/config.js
21764
+ function getProcessEnv() {
21765
+ return process.env;
21766
+ }
21764
21767
  function interpolateEnv(value) {
21765
21768
  return value.replace(ENV_INTERPOLATION_RE, (_match, name) => process.env[name] ?? `\${${name}}`);
21766
21769
  }
@@ -21835,7 +21838,7 @@ var init_config = __esm(() => {
21835
21838
  };
21836
21839
  });
21837
21840
 
21838
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+25c63b82bf4f1018/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
21841
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+170d5985e987c687/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
21839
21842
  import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
21840
21843
  import { dirname, resolve as resolvePath } from "path";
21841
21844
  function createNodeFileSystem(root) {
@@ -21922,6 +21925,17 @@ function findProjectRoot(startDir) {
21922
21925
  }
21923
21926
  var init_file_system_node = () => {};
21924
21927
 
21928
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+170d5985e987c687/node_modules/@gobing-ai/ts-runtime/dist/db-errors.js
21929
+ var DbModuleNotInstalledError;
21930
+ var init_db_errors = __esm(() => {
21931
+ DbModuleNotInstalledError = class DbModuleNotInstalledError extends Error {
21932
+ constructor(message = "@gobing-ai/ts-db is not installed. It is an optional peer of @gobing-ai/ts-runtime, required only for createDbAdapter on node-bun. Install it (`bun add @gobing-ai/ts-db`) or, when bundling, mark `@gobing-ai/ts-db` external.", options) {
21933
+ super(message, options);
21934
+ this.name = "DbModuleNotInstalledError";
21935
+ }
21936
+ };
21937
+ });
21938
+
21925
21939
  // ../../node_modules/.bun/is-plain-obj@4.1.0/node_modules/is-plain-obj/index.js
21926
21940
  function isPlainObject4(value) {
21927
21941
  if (typeof value !== "object" || value === null) {
@@ -29102,10 +29116,10 @@ var init_execa = __esm(() => {
29102
29116
  } = getIpcExport());
29103
29117
  });
29104
29118
 
29105
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+25c63b82bf4f1018/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
29119
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+170d5985e987c687/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
29106
29120
  import { isatty } from "tty";
29107
29121
 
29108
- class ProcessExecutor {
29122
+ class NodeProcessExecutor {
29109
29123
  config;
29110
29124
  constructor(config2 = {}) {
29111
29125
  this.config = config2;
@@ -29126,13 +29140,21 @@ class ProcessExecutor {
29126
29140
  signal: options.signal
29127
29141
  });
29128
29142
  const startedAt = Date.now();
29143
+ const startedIso = new Date(startedAt).toISOString();
29144
+ const registryId = this.beginRegistry(options.command, args, {
29145
+ label: options.label,
29146
+ source: options.source ?? "one-shot",
29147
+ teamId: options.teamId,
29148
+ agentId: options.agentId,
29149
+ startedAt: startedIso
29150
+ });
29129
29151
  this.emitProcessEvent("process.started", {
29130
29152
  command: options.command,
29131
29153
  args,
29132
29154
  exitCode: null,
29133
29155
  durationMs: 0,
29134
29156
  reason: "exit",
29135
- timestamp: new Date(startedAt).toISOString(),
29157
+ timestamp: startedIso,
29136
29158
  ...options.label !== undefined ? { label: options.label } : {}
29137
29159
  });
29138
29160
  try {
@@ -29146,6 +29168,7 @@ class ProcessExecutor {
29146
29168
  ...result.signalDescription !== undefined ? { signal: result.signalDescription } : {},
29147
29169
  durationMs: result.durationMs
29148
29170
  };
29171
+ this.completeRegistry(registryId, processResult.exitCode);
29149
29172
  this.emitExitedFromResult(options, processResult, result);
29150
29173
  return processResult;
29151
29174
  } catch (error51) {
@@ -29159,6 +29182,7 @@ class ProcessExecutor {
29159
29182
  ...failed.signalDescription !== undefined ? { signal: failed.signalDescription } : failed.signal !== undefined ? { signal: failed.signal } : {},
29160
29183
  durationMs: failed.durationMs ?? Date.now() - startedAt
29161
29184
  };
29185
+ this.completeRegistry(registryId, processResult.exitCode);
29162
29186
  this.emitExitedFromResult(options, processResult, error51, error51);
29163
29187
  if (options.rejectOnError)
29164
29188
  throw error51;
@@ -29172,15 +29196,23 @@ class ProcessExecutor {
29172
29196
  }).catch(() => {
29173
29197
  return;
29174
29198
  });
29199
+ const startedAt = Date.now();
29200
+ const startedIso = new Date(startedAt).toISOString();
29201
+ const registryId = this.beginRegistry(options.command, args, {
29202
+ label: options.label,
29203
+ source: options.source ?? "other",
29204
+ teamId: options.teamId,
29205
+ agentId: options.agentId,
29206
+ startedAt: startedIso
29207
+ });
29175
29208
  try {
29176
- const startedAt = Date.now();
29177
29209
  this.emitProcessEvent("process.started", {
29178
29210
  command: options.command,
29179
29211
  args,
29180
29212
  exitCode: null,
29181
29213
  durationMs: 0,
29182
29214
  reason: "exit",
29183
- timestamp: new Date(startedAt).toISOString(),
29215
+ timestamp: startedIso,
29184
29216
  ...options.label !== undefined ? { label: options.label } : {}
29185
29217
  });
29186
29218
  const subprocess = Bun.spawn({
@@ -29191,13 +29223,20 @@ class ProcessExecutor {
29191
29223
  ...options.cwd !== undefined ? { cwd: options.cwd } : {},
29192
29224
  ...options.env !== undefined ? { env: options.env } : {}
29193
29225
  });
29194
- return new ObservedPipeProcess(new BunPipeProcess(subprocess), this.config.events, {
29226
+ const pipe2 = new BunPipeProcess(subprocess);
29227
+ if (pipe2.pid !== null) {
29228
+ this.config.registry?.update(registryId, { pid: pipe2.pid });
29229
+ }
29230
+ return new ObservedPipeProcess(pipe2, this.config.events, {
29195
29231
  command: options.command,
29196
29232
  args,
29197
29233
  startedAt,
29234
+ registry: this.config.registry,
29235
+ registryId,
29198
29236
  ...options.label !== undefined ? { label: options.label } : {}
29199
29237
  });
29200
29238
  } catch (error51) {
29239
+ this.completeRegistry(registryId, null);
29201
29240
  this.emitProcessEvent("process.exited", {
29202
29241
  command: options.command,
29203
29242
  args,
@@ -29216,6 +29255,28 @@ class ProcessExecutor {
29216
29255
  return await fn();
29217
29256
  return await this.config.tracer.traceAsync(name, async () => await fn());
29218
29257
  }
29258
+ beginRegistry(command, args, meta3) {
29259
+ const registry2 = this.config.registry;
29260
+ if (!registry2)
29261
+ return "";
29262
+ return registry2.begin({
29263
+ command,
29264
+ args,
29265
+ source: meta3.source,
29266
+ startedAt: meta3.startedAt,
29267
+ ...meta3.label !== undefined ? { label: meta3.label } : {},
29268
+ ...meta3.teamId !== undefined ? { teamId: meta3.teamId } : {},
29269
+ ...meta3.agentId !== undefined ? { agentId: meta3.agentId } : {}
29270
+ });
29271
+ }
29272
+ completeRegistry(id, exitCode, pid) {
29273
+ if (!id || !this.config.registry)
29274
+ return;
29275
+ this.config.registry.complete(id, {
29276
+ exitCode,
29277
+ ...pid !== undefined ? { pid } : {}
29278
+ });
29279
+ }
29219
29280
  emitExitedFromResult(options, result, completion, error51) {
29220
29281
  const reason = isTimedOut(completion) ? "timeout" : result.signal !== undefined ? "signal" : error51 ? "error" : "exit";
29221
29282
  this.emitProcessEvent("process.exited", {
@@ -29242,6 +29303,12 @@ class ObservedPipeProcess {
29242
29303
  constructor(inner, events, context) {
29243
29304
  this.inner = inner;
29244
29305
  this.exited = inner.exited.then((exitCode) => {
29306
+ if (context.registry && context.registryId) {
29307
+ context.registry.complete(context.registryId, {
29308
+ exitCode,
29309
+ ...inner.pid !== null ? { pid: inner.pid } : {}
29310
+ });
29311
+ }
29245
29312
  events?.emit("process.exited", {
29246
29313
  command: context.command,
29247
29314
  args: context.args,
@@ -29342,7 +29409,67 @@ var init_process_executor = __esm(() => {
29342
29409
  init_execa();
29343
29410
  });
29344
29411
 
29345
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+25c63b82bf4f1018/node_modules/@gobing-ai/ts-runtime/dist/context.js
29412
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+170d5985e987c687/node_modules/@gobing-ai/ts-runtime/dist/runtime-node-bun.js
29413
+ function getNodeFileSystem() {
29414
+ if (!_nodeFileSystem)
29415
+ _nodeFileSystem = createNodeFileSystem();
29416
+ return _nodeFileSystem;
29417
+ }
29418
+ async function loadNodeConfig(options) {
29419
+ const fs = getNodeFileSystem();
29420
+ const raw = await readYamlConfig(fs);
29421
+ return buildConfigFromObject(raw ?? {}, options);
29422
+ }
29423
+ async function readYamlConfig(fs) {
29424
+ const candidates = [getProcessEnv().CONFIG_PATH, "config/config.yaml", "config/config.example.yaml"].filter((p) => typeof p === "string" && p.length > 0);
29425
+ for (const candidate of candidates) {
29426
+ const resolved = fs.resolve(candidate);
29427
+ if (await fs.exists(resolved)) {
29428
+ const content = await fs.readFile(resolved);
29429
+ try {
29430
+ return $parse(content);
29431
+ } catch {}
29432
+ }
29433
+ }
29434
+ return null;
29435
+ }
29436
+ var _nodeFileSystem, nodeBunFactory;
29437
+ var init_runtime_node_bun = __esm(() => {
29438
+ init_dist2();
29439
+ init_config();
29440
+ init_db_errors();
29441
+ init_file_system_node();
29442
+ init_process_executor();
29443
+ nodeBunFactory = {
29444
+ runtimeName: "node-bun",
29445
+ capabilities: {
29446
+ hasFilesystem: true,
29447
+ hasProcessExecution: true,
29448
+ hasPersistentStorage: true,
29449
+ hasSqlDatabase: true
29450
+ },
29451
+ createFileSystem: () => getNodeFileSystem(),
29452
+ createProcessExecutor: (config2) => new NodeProcessExecutor(config2),
29453
+ async loadConfig(options) {
29454
+ return loadNodeConfig(options);
29455
+ },
29456
+ async createDbAdapter(config2) {
29457
+ const tsDbSpec = "@gobing-ai/ts-db";
29458
+ let mod;
29459
+ try {
29460
+ mod = await import(tsDbSpec);
29461
+ } catch (cause) {
29462
+ throw new DbModuleNotInstalledError(undefined, { cause });
29463
+ }
29464
+ if (typeof mod.createDbAdapter !== "function") {
29465
+ throw new DbModuleNotInstalledError("@gobing-ai/ts-db is installed but does not export createDbAdapter \u2014 the installed version may be incompatible or partial.");
29466
+ }
29467
+ return mod.createDbAdapter({ driver: "bun-sqlite", url: config2.url });
29468
+ }
29469
+ };
29470
+ });
29471
+
29472
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+170d5985e987c687/node_modules/@gobing-ai/ts-runtime/dist/context.js
29346
29473
  class RuntimeContext {
29347
29474
  scope;
29348
29475
  runtimeName;
@@ -29360,7 +29487,7 @@ class RuntimeContext {
29360
29487
  this.register("config", options.services?.config ?? buildConfigFromObject({}));
29361
29488
  this.register("fileSystem", options.services?.fileSystem ?? createNodeFileSystem());
29362
29489
  if (this.capabilities.hasProcessExecution && options.services?.processExecutor === undefined) {
29363
- this.register("processExecutor", new ProcessExecutor);
29490
+ this.register("processExecutor", nodeBunFactory.createProcessExecutor());
29364
29491
  }
29365
29492
  for (const [key, value] of Object.entries(options.services ?? {})) {
29366
29493
  if (value !== undefined) {
@@ -29409,10 +29536,10 @@ function isDisposable(value) {
29409
29536
  var init_context = __esm(() => {
29410
29537
  init_config();
29411
29538
  init_file_system_node();
29412
- init_process_executor();
29539
+ init_runtime_node_bun();
29413
29540
  });
29414
29541
 
29415
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+25c63b82bf4f1018/node_modules/@gobing-ai/ts-runtime/dist/path.js
29542
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+170d5985e987c687/node_modules/@gobing-ai/ts-runtime/dist/path.js
29416
29543
  function normalizeSeparators(path6) {
29417
29544
  return path6.replaceAll("\\", "/");
29418
29545
  }
@@ -29473,17 +29600,17 @@ var init_path = __esm(() => {
29473
29600
  SEP = globalThis.process?.platform === "win32" ? "\\" : "/";
29474
29601
  });
29475
29602
 
29476
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+25c63b82bf4f1018/node_modules/@gobing-ai/ts-runtime/dist/schema-validation.js
29603
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+170d5985e987c687/node_modules/@gobing-ai/ts-runtime/dist/schema-validation.js
29477
29604
  var REMOTE_SCHEMA_MAX_BYTES;
29478
29605
  var init_schema_validation = __esm(() => {
29479
29606
  init_dist2();
29480
29607
  REMOTE_SCHEMA_MAX_BYTES = 5 * 1024 * 1024;
29481
29608
  });
29482
29609
 
29483
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+25c63b82bf4f1018/node_modules/@gobing-ai/ts-runtime/dist/types.js
29610
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+170d5985e987c687/node_modules/@gobing-ai/ts-runtime/dist/types.js
29484
29611
  var init_types = () => {};
29485
29612
 
29486
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+25c63b82bf4f1018/node_modules/@gobing-ai/ts-runtime/dist/index.js
29613
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+170d5985e987c687/node_modules/@gobing-ai/ts-runtime/dist/index.js
29487
29614
  var init_dist3 = __esm(() => {
29488
29615
  init_config();
29489
29616
  init_context();
@@ -29492,7 +29619,7 @@ var init_dist3 = __esm(() => {
29492
29619
  init_types();
29493
29620
  });
29494
29621
 
29495
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+25c63b82bf4f1018/node_modules/@gobing-ai/ts-runtime/dist/bun-sqlite.js
29622
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+170d5985e987c687/node_modules/@gobing-ai/ts-runtime/dist/bun-sqlite.js
29496
29623
  import { Database } from "bun:sqlite";
29497
29624
  var init_bun_sqlite = () => {};
29498
29625
 
@@ -33684,7 +33811,7 @@ var init_bun_sqlite2 = __esm(() => {
33684
33811
  init_session2();
33685
33812
  });
33686
33813
 
33687
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/schema/inbox-messages.js
33814
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/schema/inbox-messages.js
33688
33815
  var inboxMessages;
33689
33816
  var init_inbox_messages = __esm(() => {
33690
33817
  init_sqlite_core();
@@ -33703,7 +33830,7 @@ var init_inbox_messages = __esm(() => {
33703
33830
  }, (table2) => [index("idx_inbox_messages_to_status").on(table2.toId, table2.status)]);
33704
33831
  });
33705
33832
 
33706
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/schema/common.js
33833
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/schema/common.js
33707
33834
  function nowTimestamp() {
33708
33835
  return Date.now();
33709
33836
  }
@@ -33732,7 +33859,7 @@ var init_common3 = __esm(() => {
33732
33859
  appendOnlyColumns = buildAppendOnlyColumns();
33733
33860
  });
33734
33861
 
33735
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/schema/queue-jobs.js
33862
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/schema/queue-jobs.js
33736
33863
  var queueJobs;
33737
33864
  var init_queue_jobs = __esm(() => {
33738
33865
  init_sqlite_core();
@@ -33752,7 +33879,7 @@ var init_queue_jobs = __esm(() => {
33752
33879
  }, (table2) => [index("queue_jobs_ready_idx").on(table2.status, table2.nextRetryAt, table2.createdAt)]);
33753
33880
  });
33754
33881
 
33755
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/schema/runtime.js
33882
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/schema/runtime.js
33756
33883
  var exports_runtime = {};
33757
33884
  __export(exports_runtime, {
33758
33885
  queueJobs: () => queueJobs,
@@ -33763,7 +33890,7 @@ var init_runtime = __esm(() => {
33763
33890
  init_queue_jobs();
33764
33891
  });
33765
33892
 
33766
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/adapters/bun-sqlite.js
33893
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/adapters/bun-sqlite.js
33767
33894
  var exports_bun_sqlite = {};
33768
33895
  __export(exports_bun_sqlite, {
33769
33896
  BunSqliteAdapter: () => BunSqliteAdapter
@@ -34052,7 +34179,7 @@ var init_d1 = __esm(() => {
34052
34179
  init_session3();
34053
34180
  });
34054
34181
 
34055
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/adapters/d1.js
34182
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/adapters/d1.js
34056
34183
  var exports_d1 = {};
34057
34184
  __export(exports_d1, {
34058
34185
  D1Adapter: () => D1Adapter
@@ -34116,7 +34243,7 @@ var init_d12 = __esm(() => {
34116
34243
  init_runtime();
34117
34244
  });
34118
34245
 
34119
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/adapter.js
34246
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/adapter.js
34120
34247
  async function createDbAdapter(config3) {
34121
34248
  switch (config3.driver) {
34122
34249
  case "bun-sqlite": {
@@ -34156,7 +34283,7 @@ var init_drizzle_orm = __esm(() => {
34156
34283
  init_view_common();
34157
34284
  });
34158
34285
 
34159
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/query-spec.js
34286
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/query-spec.js
34160
34287
  function compilePredicate(predicate) {
34161
34288
  if ("and" in predicate) {
34162
34289
  const parts = predicate.and.map(compilePredicate).filter((p) => p !== undefined);
@@ -34194,7 +34321,7 @@ var init_query_spec = __esm(() => {
34194
34321
  };
34195
34322
  });
34196
34323
 
34197
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/base-dao.js
34324
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/base-dao.js
34198
34325
  function asSelectQuery(query) {
34199
34326
  return query;
34200
34327
  }
@@ -34236,7 +34363,7 @@ var init_base_dao = __esm(() => {
34236
34363
  init_query_spec();
34237
34364
  });
34238
34365
 
34239
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/embedded-migrations.js
34366
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/embedded-migrations.js
34240
34367
  var embeddedMigrations;
34241
34368
  var init_embedded_migrations = __esm(() => {
34242
34369
  embeddedMigrations = [
@@ -34268,7 +34395,7 @@ var init_embedded_migrations = __esm(() => {
34268
34395
  ];
34269
34396
  });
34270
34397
 
34271
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/entity-dao.js
34398
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/entity-dao.js
34272
34399
  var EntityDao;
34273
34400
  var init_entity_dao = __esm(() => {
34274
34401
  init_drizzle_orm();
@@ -34430,18 +34557,24 @@ var init_entity_dao = __esm(() => {
34430
34557
  };
34431
34558
  });
34432
34559
 
34433
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/inbox-message-dao.js
34560
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/inbox-message-dao.js
34561
+ function isPromiseLike(value) {
34562
+ return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
34563
+ }
34434
34564
  var InboxMessageDao;
34435
34565
  var init_inbox_message_dao = __esm(() => {
34436
34566
  init_drizzle_orm();
34437
34567
  init_entity_dao();
34438
34568
  init_inbox_messages();
34439
34569
  InboxMessageDao = class InboxMessageDao extends EntityDao {
34440
- constructor(adapter) {
34570
+ events;
34571
+ constructor(adapter, options = {}) {
34441
34572
  super(adapter, inboxMessages, [inboxMessages.id], "inbox_messages");
34573
+ this.events = options.events;
34442
34574
  }
34443
34575
  async enqueue(fromId, toId, body, inReplyTo) {
34444
34576
  const id = crypto.randomUUID();
34577
+ const now = this.now();
34445
34578
  await this.create({
34446
34579
  id,
34447
34580
  fromId,
@@ -34449,8 +34582,17 @@ var init_inbox_message_dao = __esm(() => {
34449
34582
  body,
34450
34583
  status: "queued",
34451
34584
  injectAttempts: 0,
34585
+ createdAt: now,
34586
+ updatedAt: now,
34452
34587
  ...inReplyTo !== undefined ? { inReplyTo } : {}
34453
34588
  });
34589
+ this.emitEvent("message.enqueued", {
34590
+ id,
34591
+ fromId,
34592
+ toId,
34593
+ ...inReplyTo !== undefined ? { inReplyTo } : {},
34594
+ timestamp: now
34595
+ });
34454
34596
  return id;
34455
34597
  }
34456
34598
  async drainPending(toId) {
@@ -34467,19 +34609,48 @@ var init_inbox_message_dao = __esm(() => {
34467
34609
  ORDER BY created_at
34468
34610
  )
34469
34611
  AND ${inboxMessages.status} = 'queued'`).returning();
34612
+ for (const row of rows) {
34613
+ this.emitEvent("message.injected", {
34614
+ id: row.id,
34615
+ fromId: row.fromId,
34616
+ toId: row.toId,
34617
+ inReplyTo: row.inReplyTo,
34618
+ injectAttempts: row.injectAttempts,
34619
+ timestamp: now
34620
+ });
34621
+ }
34470
34622
  return rows;
34471
34623
  }
34472
34624
  async markDelivered(msgId) {
34473
- await this.update(msgId, {
34625
+ const now = this.now();
34626
+ const updated = await this.update(msgId, {
34474
34627
  status: "delivered",
34475
- deliveredAt: this.now()
34628
+ deliveredAt: now
34476
34629
  });
34630
+ if (updated) {
34631
+ this.emitEvent("message.delivered", {
34632
+ id: updated.id,
34633
+ fromId: updated.fromId,
34634
+ toId: updated.toId,
34635
+ deliveredAt: now,
34636
+ timestamp: now
34637
+ });
34638
+ }
34477
34639
  }
34478
34640
  async markFailed(msgId, error51) {
34479
- await this.update(msgId, {
34641
+ const updated = await this.update(msgId, {
34480
34642
  status: "failed",
34481
34643
  injectError: error51
34482
34644
  });
34645
+ if (updated) {
34646
+ this.emitEvent("message.failed", {
34647
+ id: updated.id,
34648
+ fromId: updated.fromId,
34649
+ toId: updated.toId,
34650
+ error: error51,
34651
+ timestamp: updated.updatedAt
34652
+ });
34653
+ }
34483
34654
  }
34484
34655
  async inbox(toId, limit, offset) {
34485
34656
  return this.list({
@@ -34500,6 +34671,16 @@ var init_inbox_message_dao = __esm(() => {
34500
34671
  async getById(id) {
34501
34672
  return this.findBy(inboxMessages.id, id);
34502
34673
  }
34674
+ emitEvent(event, ...args) {
34675
+ if (!this.events)
34676
+ return;
34677
+ try {
34678
+ const pending = this.events.emit(event, ...args);
34679
+ if (isPromiseLike(pending)) {
34680
+ Promise.resolve(pending).catch(() => {});
34681
+ }
34682
+ } catch {}
34683
+ }
34503
34684
  };
34504
34685
  });
34505
34686
 
@@ -34549,7 +34730,7 @@ var init_migrator2 = __esm(() => {
34549
34730
  init_migrator();
34550
34731
  });
34551
34732
 
34552
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/migrate.js
34733
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/migrate.js
34553
34734
  async function ensureJournalTable(adapter, table3) {
34554
34735
  await adapter.exec(`CREATE TABLE IF NOT EXISTS "${table3}" (` + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "hash text NOT NULL, " + "created_at numeric" + ")");
34555
34736
  }
@@ -34624,7 +34805,7 @@ var init_migrate = __esm(() => {
34624
34805
  init_embedded_migrations();
34625
34806
  });
34626
34807
 
34627
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/queue-job-dao.js
34808
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/queue-job-dao.js
34628
34809
  var QueueJobDao;
34629
34810
  var init_queue_job_dao = __esm(() => {
34630
34811
  init_drizzle_orm();
@@ -34765,7 +34946,7 @@ var init_queue_job_dao = __esm(() => {
34765
34946
  };
34766
34947
  });
34767
34948
 
34768
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/index.js
34949
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/index.js
34769
34950
  var exports_dist = {};
34770
34951
  __export(exports_dist, {
34771
34952
  embeddedMigrations: () => embeddedMigrations,
@@ -36904,6 +37085,18 @@ var require_extra_typings = __commonJS((exports, module) => {
36904
37085
  function folderPathWithDefault(defaultPath) {
36905
37086
  return exports_external.preprocess((v) => v == null ? undefined : v, exports_external.string().default(defaultPath));
36906
37087
  }
37088
+ function normalizeMember(member) {
37089
+ return typeof member === "string" ? { executor: member } : { ...member };
37090
+ }
37091
+ function resolveExecutor(name, agentConfig, opts) {
37092
+ const exec = agentConfig?.executors?.find((entry) => entry.name === name);
37093
+ if (exec !== undefined)
37094
+ return { agent: exec.agent, model: exec.model };
37095
+ if (opts?.isCanonicalAgent === undefined || opts.isCanonicalAgent(name)) {
37096
+ return { agent: name };
37097
+ }
37098
+ throw new Error(`Unknown executor or agent reference: "${name}"`);
37099
+ }
36907
37100
  function parseEnvBoolean(value) {
36908
37101
  if (value === undefined || value === "")
36909
37102
  return;
@@ -36932,7 +37125,7 @@ function buildConfigFromEnv(env = process.env) {
36932
37125
  }
36933
37126
  });
36934
37127
  }
36935
- var SPUR_ENV_VARS, SPUR_LOG_LEVELS, DEFAULT_TASKS_DIR = "docs/tasks", DEFAULT_FEATURES_DIR = "docs/features", DEFAULT_DATABASE_URL = ".spur/spur.db", IN_MEMORY_DATABASE_URL = ":memory:", folderConfigSchema, tasksConfigSchema, featuresConfigSchema, AgentExecutorConfigSchema, AgentConfigSchema, RulesConfigSchema, WorkflowsConfigSchema, RedactionConfigSchema, spurConfigSchema, configSchema2;
37128
+ var SPUR_ENV_VARS, SPUR_LOG_LEVELS, DEFAULT_TASKS_DIR = "docs/tasks", DEFAULT_FEATURES_DIR = "docs/features", DEFAULT_DATABASE_URL = ".spur/spur.db", IN_MEMORY_DATABASE_URL = ":memory:", folderConfigSchema, tasksConfigSchema, featuresConfigSchema, AgentExecutorConfigSchema, AGENT_ID_REGEX, TeamMemberConfigSchema, TeamConfigSchema, AgentConfigSchema, RulesConfigSchema, WorkflowsConfigSchema, RedactionConfigSchema, spurConfigSchema, configSchema2;
36936
37129
  var init_src = __esm(() => {
36937
37130
  init_zod();
36938
37131
  SPUR_ENV_VARS = {
@@ -36959,24 +37152,81 @@ var init_src = __esm(() => {
36959
37152
  agent: exports_external.string().min(1),
36960
37153
  model: exports_external.string().min(1).optional()
36961
37154
  });
37155
+ AGENT_ID_REGEX = /^[a-z][a-z0-9_-]{1,63}$/;
37156
+ TeamMemberConfigSchema = exports_external.union([
37157
+ exports_external.string().min(1),
37158
+ exports_external.object({
37159
+ executor: exports_external.string().min(1),
37160
+ id: exports_external.string().min(1).optional(),
37161
+ purpose: exports_external.string().optional(),
37162
+ workspace: exports_external.string().min(1).optional(),
37163
+ model: exports_external.string().min(1).optional(),
37164
+ autonomy: exports_external.string().optional(),
37165
+ systemPrompt: exports_external.string().optional(),
37166
+ command: exports_external.array(exports_external.string().min(1)).optional(),
37167
+ autostart: exports_external.boolean().optional()
37168
+ })
37169
+ ]);
37170
+ TeamConfigSchema = exports_external.object({
37171
+ name: exports_external.string().min(1),
37172
+ work_dir: exports_external.string().min(1),
37173
+ autostart: exports_external.boolean().optional(),
37174
+ members: exports_external.array(TeamMemberConfigSchema).min(1)
37175
+ });
36962
37176
  AgentConfigSchema = exports_external.object({
36963
37177
  default: exports_external.string().optional(),
36964
37178
  executors: exports_external.array(AgentExecutorConfigSchema).optional(),
36965
- "default-by-phase": exports_external.record(exports_external.string(), exports_external.string()).optional()
37179
+ "default-by-phase": exports_external.record(exports_external.string(), exports_external.string()).optional(),
37180
+ team: exports_external.record(exports_external.string(), TeamConfigSchema).optional()
36966
37181
  }).superRefine((value, ctx) => {
36967
37182
  const executors = value.executors;
36968
- if (executors === undefined)
36969
- return;
36970
- const seen = new Set;
36971
- for (const [index2, executor] of executors.entries()) {
36972
- if (seen.has(executor.name)) {
36973
- ctx.addIssue({
36974
- code: exports_external.ZodIssueCode.custom,
36975
- message: `Duplicate executor name: ${executor.name}`,
36976
- path: ["executors", index2, "name"]
36977
- });
37183
+ if (executors !== undefined) {
37184
+ const seen = new Set;
37185
+ for (const [index2, executor] of executors.entries()) {
37186
+ if (seen.has(executor.name)) {
37187
+ ctx.addIssue({
37188
+ code: exports_external.ZodIssueCode.custom,
37189
+ message: `Duplicate executor name: ${executor.name}`,
37190
+ path: ["executors", index2, "name"]
37191
+ });
37192
+ }
37193
+ seen.add(executor.name);
36978
37194
  }
36979
- seen.add(executor.name);
37195
+ }
37196
+ const team = value.team;
37197
+ if (team === undefined)
37198
+ return;
37199
+ const seenComposed = new Set;
37200
+ for (const [teamId, teamConfig] of Object.entries(team)) {
37201
+ const seenLocal = new Set;
37202
+ teamConfig.members.forEach((member, index2) => {
37203
+ const ref = normalizeMember(member);
37204
+ const localId = ref.id ?? ref.executor;
37205
+ if (seenLocal.has(localId)) {
37206
+ ctx.addIssue({
37207
+ code: exports_external.ZodIssueCode.custom,
37208
+ message: `Duplicate team member id: ${localId} in team "${teamId}"`,
37209
+ path: ["team", teamId, "members", index2]
37210
+ });
37211
+ }
37212
+ seenLocal.add(localId);
37213
+ const composedId = `${teamId}-${localId}`;
37214
+ if (!AGENT_ID_REGEX.test(composedId)) {
37215
+ ctx.addIssue({
37216
+ code: exports_external.ZodIssueCode.custom,
37217
+ message: `Invalid composed agent id "${composedId}": team key "${teamId}" + member "${localId}" must match ^[a-z][a-z0-9_-]{1,63}$ (2-64 chars, lowercase).`,
37218
+ path: ["team", teamId, "members", index2]
37219
+ });
37220
+ }
37221
+ if (seenComposed.has(composedId)) {
37222
+ ctx.addIssue({
37223
+ code: exports_external.ZodIssueCode.custom,
37224
+ message: `Composed agent id "${composedId}" collides across teams \u2014 every <teamId>-<localId> must be globally unique (a hyphenated team key can overlap another team's member id).`,
37225
+ path: ["team", teamId, "members", index2]
37226
+ });
37227
+ }
37228
+ seenComposed.add(composedId);
37229
+ });
36980
37230
  }
36981
37231
  });
36982
37232
  RulesConfigSchema = exports_external.object({
@@ -37018,7 +37268,7 @@ var init_src = __esm(() => {
37018
37268
  });
37019
37269
  });
37020
37270
 
37021
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/config.js
37271
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/config.js
37022
37272
  function parseYamlObject(text3) {
37023
37273
  let parsed;
37024
37274
  try {
@@ -37042,7 +37292,7 @@ function getNodeEnv() {
37042
37292
  function isTestEnv() {
37043
37293
  return getNodeEnv() === "test";
37044
37294
  }
37045
- function getProcessEnv() {
37295
+ function getProcessEnv2() {
37046
37296
  return process.env;
37047
37297
  }
37048
37298
  function getDatabaseUrl() {
@@ -37145,7 +37395,7 @@ var init_config2 = __esm(() => {
37145
37395
  };
37146
37396
  });
37147
37397
 
37148
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
37398
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
37149
37399
  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";
37150
37400
  import { dirname as dirname2, resolve as resolvePath3 } from "path";
37151
37401
  function createNodeFileSystem3(root) {
@@ -37232,16 +37482,16 @@ function findProjectRoot3(startDir) {
37232
37482
  }
37233
37483
  var init_file_system_node2 = () => {};
37234
37484
 
37235
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/db-errors.js
37236
- var D1NotConfiguredError2, DbModuleNotInstalledError2;
37237
- var init_db_errors = __esm(() => {
37485
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/db-errors.js
37486
+ var D1NotConfiguredError2, DbModuleNotInstalledError3;
37487
+ var init_db_errors2 = __esm(() => {
37238
37488
  D1NotConfiguredError2 = class D1NotConfiguredError2 extends Error {
37239
37489
  constructor(message = "D1 DbAdapter is not yet implemented; see the ts-db D1 round.") {
37240
37490
  super(message);
37241
37491
  this.name = "D1NotConfiguredError";
37242
37492
  }
37243
37493
  };
37244
- DbModuleNotInstalledError2 = class DbModuleNotInstalledError2 extends Error {
37494
+ DbModuleNotInstalledError3 = class DbModuleNotInstalledError3 extends Error {
37245
37495
  constructor(message = "@gobing-ai/ts-db is not installed. It is an optional peer of @gobing-ai/ts-runtime, required only for createDbAdapter on node-bun. Install it (`bun add @gobing-ai/ts-db`) or, when bundling, mark `@gobing-ai/ts-db` external.", options) {
37246
37496
  super(message, options);
37247
37497
  this.name = "DbModuleNotInstalledError";
@@ -37249,7 +37499,7 @@ var init_db_errors = __esm(() => {
37249
37499
  };
37250
37500
  });
37251
37501
 
37252
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/file-system-cf.js
37502
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/file-system-cf.js
37253
37503
  function createCfFileSystem2() {
37254
37504
  return {
37255
37505
  getProjectRoot: () => "/bundle",
@@ -37288,7 +37538,7 @@ function createCfFileSystem2() {
37288
37538
  }
37289
37539
  var UNSUPPORTED = "FileSystem is not available on Cloudflare Workers. Use D1, KV, or R2 for persistent storage.";
37290
37540
 
37291
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/runtime-cf.js
37541
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/runtime-cf.js
37292
37542
  var exports_runtime_cf = {};
37293
37543
  __export(exports_runtime_cf, {
37294
37544
  cloudflareWorkersFactory: () => cloudflareWorkersFactory2
@@ -37297,7 +37547,7 @@ var CONFIG_YAML_BINDING = "CONFIG_YAML", cloudflareWorkersFactory2;
37297
37547
  var init_runtime_cf = __esm(() => {
37298
37548
  init_dist2();
37299
37549
  init_config2();
37300
- init_db_errors();
37550
+ init_db_errors2();
37301
37551
  cloudflareWorkersFactory2 = {
37302
37552
  runtimeName: "cloudflare-workers",
37303
37553
  capabilities: {
@@ -37326,10 +37576,10 @@ var init_runtime_cf = __esm(() => {
37326
37576
  };
37327
37577
  });
37328
37578
 
37329
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
37579
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
37330
37580
  import { isatty as isatty2 } from "tty";
37331
37581
 
37332
- class ProcessExecutor3 {
37582
+ class NodeProcessExecutor3 {
37333
37583
  config;
37334
37584
  constructor(config3 = {}) {
37335
37585
  this.config = config3;
@@ -37350,13 +37600,21 @@ class ProcessExecutor3 {
37350
37600
  signal: options.signal
37351
37601
  });
37352
37602
  const startedAt = Date.now();
37603
+ const startedIso = new Date(startedAt).toISOString();
37604
+ const registryId = this.beginRegistry(options.command, args, {
37605
+ label: options.label,
37606
+ source: options.source ?? "one-shot",
37607
+ teamId: options.teamId,
37608
+ agentId: options.agentId,
37609
+ startedAt: startedIso
37610
+ });
37353
37611
  this.emitProcessEvent("process.started", {
37354
37612
  command: options.command,
37355
37613
  args,
37356
37614
  exitCode: null,
37357
37615
  durationMs: 0,
37358
37616
  reason: "exit",
37359
- timestamp: new Date(startedAt).toISOString(),
37617
+ timestamp: startedIso,
37360
37618
  ...options.label !== undefined ? { label: options.label } : {}
37361
37619
  });
37362
37620
  try {
@@ -37370,6 +37628,7 @@ class ProcessExecutor3 {
37370
37628
  ...result.signalDescription !== undefined ? { signal: result.signalDescription } : {},
37371
37629
  durationMs: result.durationMs
37372
37630
  };
37631
+ this.completeRegistry(registryId, processResult.exitCode);
37373
37632
  this.emitExitedFromResult(options, processResult, result);
37374
37633
  return processResult;
37375
37634
  } catch (error51) {
@@ -37383,6 +37642,7 @@ class ProcessExecutor3 {
37383
37642
  ...failed.signalDescription !== undefined ? { signal: failed.signalDescription } : failed.signal !== undefined ? { signal: failed.signal } : {},
37384
37643
  durationMs: failed.durationMs ?? Date.now() - startedAt
37385
37644
  };
37645
+ this.completeRegistry(registryId, processResult.exitCode);
37386
37646
  this.emitExitedFromResult(options, processResult, error51, error51);
37387
37647
  if (options.rejectOnError)
37388
37648
  throw error51;
@@ -37396,15 +37656,23 @@ class ProcessExecutor3 {
37396
37656
  }).catch(() => {
37397
37657
  return;
37398
37658
  });
37659
+ const startedAt = Date.now();
37660
+ const startedIso = new Date(startedAt).toISOString();
37661
+ const registryId = this.beginRegistry(options.command, args, {
37662
+ label: options.label,
37663
+ source: options.source ?? "other",
37664
+ teamId: options.teamId,
37665
+ agentId: options.agentId,
37666
+ startedAt: startedIso
37667
+ });
37399
37668
  try {
37400
- const startedAt = Date.now();
37401
37669
  this.emitProcessEvent("process.started", {
37402
37670
  command: options.command,
37403
37671
  args,
37404
37672
  exitCode: null,
37405
37673
  durationMs: 0,
37406
37674
  reason: "exit",
37407
- timestamp: new Date(startedAt).toISOString(),
37675
+ timestamp: startedIso,
37408
37676
  ...options.label !== undefined ? { label: options.label } : {}
37409
37677
  });
37410
37678
  const subprocess = Bun.spawn({
@@ -37415,13 +37683,20 @@ class ProcessExecutor3 {
37415
37683
  ...options.cwd !== undefined ? { cwd: options.cwd } : {},
37416
37684
  ...options.env !== undefined ? { env: options.env } : {}
37417
37685
  });
37418
- return new ObservedPipeProcess2(new BunPipeProcess2(subprocess), this.config.events, {
37686
+ const pipe2 = new BunPipeProcess2(subprocess);
37687
+ if (pipe2.pid !== null) {
37688
+ this.config.registry?.update(registryId, { pid: pipe2.pid });
37689
+ }
37690
+ return new ObservedPipeProcess2(pipe2, this.config.events, {
37419
37691
  command: options.command,
37420
37692
  args,
37421
37693
  startedAt,
37694
+ registry: this.config.registry,
37695
+ registryId,
37422
37696
  ...options.label !== undefined ? { label: options.label } : {}
37423
37697
  });
37424
37698
  } catch (error51) {
37699
+ this.completeRegistry(registryId, null);
37425
37700
  this.emitProcessEvent("process.exited", {
37426
37701
  command: options.command,
37427
37702
  args,
@@ -37440,6 +37715,28 @@ class ProcessExecutor3 {
37440
37715
  return await fn();
37441
37716
  return await this.config.tracer.traceAsync(name, async () => await fn());
37442
37717
  }
37718
+ beginRegistry(command, args, meta3) {
37719
+ const registry2 = this.config.registry;
37720
+ if (!registry2)
37721
+ return "";
37722
+ return registry2.begin({
37723
+ command,
37724
+ args,
37725
+ source: meta3.source,
37726
+ startedAt: meta3.startedAt,
37727
+ ...meta3.label !== undefined ? { label: meta3.label } : {},
37728
+ ...meta3.teamId !== undefined ? { teamId: meta3.teamId } : {},
37729
+ ...meta3.agentId !== undefined ? { agentId: meta3.agentId } : {}
37730
+ });
37731
+ }
37732
+ completeRegistry(id, exitCode, pid) {
37733
+ if (!id || !this.config.registry)
37734
+ return;
37735
+ this.config.registry.complete(id, {
37736
+ exitCode,
37737
+ ...pid !== undefined ? { pid } : {}
37738
+ });
37739
+ }
37443
37740
  emitExitedFromResult(options, result, completion, error51) {
37444
37741
  const reason = isTimedOut2(completion) ? "timeout" : result.signal !== undefined ? "signal" : error51 ? "error" : "exit";
37445
37742
  this.emitProcessEvent("process.exited", {
@@ -37466,6 +37763,12 @@ class ObservedPipeProcess2 {
37466
37763
  constructor(inner, events, context2) {
37467
37764
  this.inner = inner;
37468
37765
  this.exited = inner.exited.then((exitCode) => {
37766
+ if (context2.registry && context2.registryId) {
37767
+ context2.registry.complete(context2.registryId, {
37768
+ exitCode,
37769
+ ...inner.pid !== null ? { pid: inner.pid } : {}
37770
+ });
37771
+ }
37469
37772
  events?.emit("process.exited", {
37470
37773
  command: context2.command,
37471
37774
  args: context2.args,
@@ -37607,34 +37910,33 @@ function isTimedOut2(error51) {
37607
37910
  function errorMessage2(error51) {
37608
37911
  return error51 instanceof Error ? error51.message : String(error51);
37609
37912
  }
37610
- var NodeProcessExecutor2;
37913
+ var ProcessExecutor2;
37611
37914
  var init_process_executor2 = __esm(() => {
37612
37915
  init_execa();
37613
- NodeProcessExecutor2 = class NodeProcessExecutor2 extends ProcessExecutor3 {
37614
- };
37916
+ ProcessExecutor2 = NodeProcessExecutor3;
37615
37917
  });
37616
37918
 
37617
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/runtime-node-bun.js
37919
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/runtime-node-bun.js
37618
37920
  var exports_runtime_node_bun = {};
37619
37921
  __export(exports_runtime_node_bun, {
37620
- nodeBunFactory: () => nodeBunFactory2,
37922
+ nodeBunFactory: () => nodeBunFactory3,
37621
37923
  _resetNodeFileSystem: () => _resetNodeFileSystem2
37622
37924
  });
37623
- function getNodeFileSystem() {
37624
- if (!_nodeFileSystem)
37625
- _nodeFileSystem = createNodeFileSystem3();
37626
- return _nodeFileSystem;
37925
+ function getNodeFileSystem2() {
37926
+ if (!_nodeFileSystem2)
37927
+ _nodeFileSystem2 = createNodeFileSystem3();
37928
+ return _nodeFileSystem2;
37627
37929
  }
37628
37930
  function _resetNodeFileSystem2() {
37629
- _nodeFileSystem = undefined;
37931
+ _nodeFileSystem2 = undefined;
37630
37932
  }
37631
- async function loadNodeConfig(options) {
37632
- const fs2 = getNodeFileSystem();
37633
- const raw = await readYamlConfig(fs2);
37933
+ async function loadNodeConfig2(options) {
37934
+ const fs2 = getNodeFileSystem2();
37935
+ const raw = await readYamlConfig2(fs2);
37634
37936
  return buildConfigFromObject2(raw ?? {}, options);
37635
37937
  }
37636
- async function readYamlConfig(fs2) {
37637
- const candidates = [getProcessEnv().CONFIG_PATH, "config/config.yaml", "config/config.example.yaml"].filter((p) => typeof p === "string" && p.length > 0);
37938
+ async function readYamlConfig2(fs2) {
37939
+ const candidates = [getProcessEnv2().CONFIG_PATH, "config/config.yaml", "config/config.example.yaml"].filter((p) => typeof p === "string" && p.length > 0);
37638
37940
  for (const candidate of candidates) {
37639
37941
  const resolved = fs2.resolve(candidate);
37640
37942
  if (await fs2.exists(resolved)) {
@@ -37646,14 +37948,14 @@ async function readYamlConfig(fs2) {
37646
37948
  }
37647
37949
  return null;
37648
37950
  }
37649
- var _nodeFileSystem, nodeBunFactory2;
37650
- var init_runtime_node_bun = __esm(() => {
37951
+ var _nodeFileSystem2, nodeBunFactory3;
37952
+ var init_runtime_node_bun2 = __esm(() => {
37651
37953
  init_dist2();
37652
37954
  init_config2();
37653
- init_db_errors();
37955
+ init_db_errors2();
37654
37956
  init_file_system_node2();
37655
37957
  init_process_executor2();
37656
- nodeBunFactory2 = {
37958
+ nodeBunFactory3 = {
37657
37959
  runtimeName: "node-bun",
37658
37960
  capabilities: {
37659
37961
  hasFilesystem: true,
@@ -37661,10 +37963,10 @@ var init_runtime_node_bun = __esm(() => {
37661
37963
  hasPersistentStorage: true,
37662
37964
  hasSqlDatabase: true
37663
37965
  },
37664
- createFileSystem: () => getNodeFileSystem(),
37665
- createProcessExecutor: (config3) => new ProcessExecutor3(config3),
37966
+ createFileSystem: () => getNodeFileSystem2(),
37967
+ createProcessExecutor: (config3) => new NodeProcessExecutor3(config3),
37666
37968
  async loadConfig(options) {
37667
- return loadNodeConfig(options);
37969
+ return loadNodeConfig2(options);
37668
37970
  },
37669
37971
  async createDbAdapter(config3) {
37670
37972
  const tsDbSpec = "@gobing-ai/ts-db";
@@ -37672,17 +37974,17 @@ var init_runtime_node_bun = __esm(() => {
37672
37974
  try {
37673
37975
  mod = await import(tsDbSpec);
37674
37976
  } catch (cause) {
37675
- throw new DbModuleNotInstalledError2(undefined, { cause });
37977
+ throw new DbModuleNotInstalledError3(undefined, { cause });
37676
37978
  }
37677
37979
  if (typeof mod.createDbAdapter !== "function") {
37678
- throw new DbModuleNotInstalledError2("@gobing-ai/ts-db is installed but does not export createDbAdapter \u2014 the installed version may be incompatible or partial.");
37980
+ throw new DbModuleNotInstalledError3("@gobing-ai/ts-db is installed but does not export createDbAdapter \u2014 the installed version may be incompatible or partial.");
37679
37981
  }
37680
37982
  return mod.createDbAdapter({ driver: "bun-sqlite", url: config3.url });
37681
37983
  }
37682
37984
  };
37683
37985
  });
37684
37986
 
37685
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/platform.js
37987
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/platform.js
37686
37988
  function isCloudflareWorkerRuntime2() {
37687
37989
  return globalThis.navigator?.userAgent?.startsWith("Cloudflare-Workers") ?? false;
37688
37990
  }
@@ -37694,8 +37996,8 @@ async function loadRuntimeFactory2() {
37694
37996
  const { cloudflareWorkersFactory: cloudflareWorkersFactory3 } = await Promise.resolve().then(() => (init_runtime_cf(), exports_runtime_cf));
37695
37997
  factory = cloudflareWorkersFactory3;
37696
37998
  } else {
37697
- const { nodeBunFactory: nodeBunFactory3 } = await Promise.resolve().then(() => (init_runtime_node_bun(), exports_runtime_node_bun));
37698
- factory = nodeBunFactory3;
37999
+ const { nodeBunFactory: nodeBunFactory4 } = await Promise.resolve().then(() => (init_runtime_node_bun2(), exports_runtime_node_bun));
38000
+ factory = nodeBunFactory4;
37699
38001
  }
37700
38002
  _factory = factory;
37701
38003
  return factory;
@@ -37712,7 +38014,7 @@ function _resetRuntimeFactory2() {
37712
38014
  }
37713
38015
  var _factory, _runtimeName;
37714
38016
 
37715
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/context.js
38017
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/context.js
37716
38018
  class RuntimeContext2 {
37717
38019
  scope;
37718
38020
  runtimeName;
@@ -37730,7 +38032,7 @@ class RuntimeContext2 {
37730
38032
  this.register("config", options.services?.config ?? buildConfigFromObject2({}));
37731
38033
  this.register("fileSystem", options.services?.fileSystem ?? createNodeFileSystem3());
37732
38034
  if (this.capabilities.hasProcessExecution && options.services?.processExecutor === undefined) {
37733
- this.register("processExecutor", new ProcessExecutor3);
38035
+ this.register("processExecutor", nodeBunFactory3.createProcessExecutor());
37734
38036
  }
37735
38037
  for (const [key, value] of Object.entries(options.services ?? {})) {
37736
38038
  if (value !== undefined) {
@@ -37799,10 +38101,10 @@ function createRuntimeContext(options = {}) {
37799
38101
  var init_context2 = __esm(() => {
37800
38102
  init_config2();
37801
38103
  init_file_system_node2();
37802
- init_process_executor2();
38104
+ init_runtime_node_bun2();
37803
38105
  });
37804
38106
 
37805
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/path.js
38107
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/path.js
37806
38108
  function normalizeSeparators2(path7) {
37807
38109
  return path7.replaceAll("\\", "/");
37808
38110
  }
@@ -37925,7 +38227,7 @@ var init_path2 = __esm(() => {
37925
38227
  SEP2 = globalThis.process?.platform === "win32" ? "\\" : "/";
37926
38228
  });
37927
38229
 
37928
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/fs.js
38230
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/fs.js
37929
38231
  async function ensureDirForFile2(path7, fs2 = createNodeFileSystem3()) {
37930
38232
  await fs2.ensureDir(dirnamePath(path7));
37931
38233
  }
@@ -37976,7 +38278,131 @@ var init_fs = __esm(() => {
37976
38278
  init_path2();
37977
38279
  });
37978
38280
 
37979
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/schema-validation.js
38281
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/process-registry.js
38282
+ function allocateId() {
38283
+ nextIdSeq += 1;
38284
+ return `pe_${Date.now().toString(36)}_${nextIdSeq.toString(36)}`;
38285
+ }
38286
+
38287
+ class InMemoryProcessRegistry2 {
38288
+ maxEntries;
38289
+ byId = new Map;
38290
+ order = [];
38291
+ listeners = new Set;
38292
+ constructor(options = {}) {
38293
+ this.maxEntries = options.maxEntries ?? 1000;
38294
+ }
38295
+ listExecutions(filter) {
38296
+ const out = [];
38297
+ for (const id of this.order) {
38298
+ const exec = this.byId.get(id);
38299
+ if (!exec)
38300
+ continue;
38301
+ if (filter?.source !== undefined && exec.source !== filter.source)
38302
+ continue;
38303
+ if (filter?.running === true && exec.status !== "running")
38304
+ continue;
38305
+ if (filter?.running === false && exec.status !== "exited")
38306
+ continue;
38307
+ if (filter?.teamId !== undefined && exec.teamId !== filter.teamId)
38308
+ continue;
38309
+ if (filter?.agentId !== undefined && exec.agentId !== filter.agentId)
38310
+ continue;
38311
+ out.push(exec);
38312
+ }
38313
+ return out;
38314
+ }
38315
+ getExecution(id) {
38316
+ return this.byId.get(id);
38317
+ }
38318
+ subscribe(listener) {
38319
+ this.listeners.add(listener);
38320
+ return () => {
38321
+ this.listeners.delete(listener);
38322
+ };
38323
+ }
38324
+ begin(input) {
38325
+ const id = allocateId();
38326
+ const execution = {
38327
+ id,
38328
+ command: input.command,
38329
+ args: Object.freeze([...input.args ?? []]),
38330
+ source: input.source ?? "other",
38331
+ startedAt: input.startedAt ?? new Date().toISOString(),
38332
+ status: "running",
38333
+ ...input.label !== undefined ? { label: input.label } : {},
38334
+ ...input.teamId !== undefined ? { teamId: input.teamId } : {},
38335
+ ...input.agentId !== undefined ? { agentId: input.agentId } : {},
38336
+ ...input.pid !== undefined ? { pid: input.pid } : {}
38337
+ };
38338
+ this.byId.set(id, execution);
38339
+ this.order.push(id);
38340
+ this.enforceCap();
38341
+ this.emit({ type: "started", execution });
38342
+ return id;
38343
+ }
38344
+ update(id, patch) {
38345
+ const current = this.byId.get(id);
38346
+ if (!current)
38347
+ return;
38348
+ const next = {
38349
+ ...current,
38350
+ ...patch.pid !== undefined ? { pid: patch.pid } : {},
38351
+ ...patch.label !== undefined ? { label: patch.label } : {}
38352
+ };
38353
+ this.byId.set(id, next);
38354
+ this.emit({ type: "updated", execution: next });
38355
+ }
38356
+ complete(id, update2 = {}) {
38357
+ const current = this.byId.get(id);
38358
+ if (!current)
38359
+ return;
38360
+ if (current.status === "exited") {
38361
+ if (update2.pid !== undefined && current.pid === undefined) {
38362
+ const patched = { ...current, pid: update2.pid };
38363
+ this.byId.set(id, patched);
38364
+ this.emit({ type: "updated", execution: patched });
38365
+ }
38366
+ return;
38367
+ }
38368
+ const next = {
38369
+ ...current,
38370
+ status: "exited",
38371
+ exitedAt: update2.exitedAt ?? new Date().toISOString(),
38372
+ exitCode: update2.exitCode !== undefined ? update2.exitCode : null,
38373
+ ...update2.pid !== undefined ? { pid: update2.pid } : {}
38374
+ };
38375
+ this.byId.set(id, next);
38376
+ this.emit({ type: "exited", execution: next });
38377
+ }
38378
+ clear() {
38379
+ this.byId.clear();
38380
+ this.order.length = 0;
38381
+ }
38382
+ emit(event) {
38383
+ for (const listener of this.listeners) {
38384
+ try {
38385
+ listener(event);
38386
+ } catch {}
38387
+ }
38388
+ }
38389
+ enforceCap() {
38390
+ while (this.order.length > this.maxEntries) {
38391
+ let dropIdx = this.order.findIndex((id) => this.byId.get(id)?.status === "exited");
38392
+ if (dropIdx < 0)
38393
+ dropIdx = 0;
38394
+ const [removed] = this.order.splice(dropIdx, 1);
38395
+ if (removed !== undefined)
38396
+ this.byId.delete(removed);
38397
+ }
38398
+ }
38399
+ }
38400
+ function createInMemoryProcessRegistry2(options) {
38401
+ return new InMemoryProcessRegistry2(options);
38402
+ }
38403
+ var nextIdSeq = 0;
38404
+
38405
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/schema-validation.js
37980
38406
  async function loadStructuredConfig(path7, options = {}) {
37981
38407
  const content = await (options.fileSystem ?? createNodeFileSystem3()).readFile(path7);
37982
38408
  return await parseStructuredConfig(content, path7, options);
@@ -38253,10 +38679,10 @@ var init_schema_validation2 = __esm(() => {
38253
38679
  defaultResolve = typeof Bun !== "undefined" ? (specifier, from) => Bun.resolveSync(specifier, from) : undefined;
38254
38680
  });
38255
38681
 
38256
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/types.js
38682
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/types.js
38257
38683
  var init_types2 = () => {};
38258
38684
 
38259
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/index.js
38685
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/index.js
38260
38686
  var exports_dist2 = {};
38261
38687
  __export(exports_dist2, {
38262
38688
  writeJsonFile: () => writeJsonFile2,
@@ -38271,7 +38697,7 @@ __export(exports_dist2, {
38271
38697
  parseStructuredConfig: () => parseStructuredConfig,
38272
38698
  parseConfigYaml: () => parseConfigYaml,
38273
38699
  normalizeSeparators: () => normalizeSeparators2,
38274
- nodeBunFactory: () => nodeBunFactory2,
38700
+ nodeBunFactory: () => nodeBunFactory3,
38275
38701
  loadStructuredConfig: () => loadStructuredConfig,
38276
38702
  loadRuntimeFactory: () => loadRuntimeFactory2,
38277
38703
  joinPath: () => joinPath2,
@@ -38280,7 +38706,7 @@ __export(exports_dist2, {
38280
38706
  isAbsolutePath: () => isAbsolutePath2,
38281
38707
  interpolateTree: () => interpolateTree2,
38282
38708
  interpolateEnv: () => interpolateEnv2,
38283
- getProcessEnv: () => getProcessEnv,
38709
+ getProcessEnv: () => getProcessEnv2,
38284
38710
  getProcessCwd: () => getProcessCwd2,
38285
38711
  getNodeEnv: () => getNodeEnv,
38286
38712
  getHomeDir: () => getHomeDir,
@@ -38293,6 +38719,7 @@ __export(exports_dist2, {
38293
38719
  createRuntimeContext: () => createRuntimeContext,
38294
38720
  createNodeFileSystem: () => createNodeFileSystem3,
38295
38721
  createLogStream: () => createLogStream2,
38722
+ createInMemoryProcessRegistry: () => createInMemoryProcessRegistry2,
38296
38723
  createCfFileSystem: () => createCfFileSystem2,
38297
38724
  configSchema: () => configSchema3,
38298
38725
  cloudflareWorkersFactory: () => cloudflareWorkersFactory2,
@@ -38307,9 +38734,10 @@ __export(exports_dist2, {
38307
38734
  StructuredConfigSchemaError: () => StructuredConfigSchemaError,
38308
38735
  SEP: () => SEP2,
38309
38736
  RuntimeContext: () => RuntimeContext2,
38310
- ProcessExecutor: () => ProcessExecutor3,
38311
- NodeProcessExecutor: () => NodeProcessExecutor2,
38312
- DbModuleNotInstalledError: () => DbModuleNotInstalledError2,
38737
+ ProcessExecutor: () => ProcessExecutor2,
38738
+ NodeProcessExecutor: () => NodeProcessExecutor3,
38739
+ InMemoryProcessRegistry: () => InMemoryProcessRegistry2,
38740
+ DbModuleNotInstalledError: () => DbModuleNotInstalledError3,
38313
38741
  D1NotConfiguredError: () => D1NotConfiguredError2,
38314
38742
  ConfigLoadError: () => ConfigLoadError2,
38315
38743
  BunSyncProcessExecutor: () => BunSyncProcessExecutor2,
@@ -38317,12 +38745,12 @@ __export(exports_dist2, {
38317
38745
  });
38318
38746
  var init_dist5 = __esm(() => {
38319
38747
  init_context2();
38320
- init_db_errors();
38748
+ init_db_errors2();
38321
38749
  init_file_system_node2();
38322
38750
  init_fs();
38323
38751
  init_process_executor2();
38324
38752
  init_runtime_cf();
38325
- init_runtime_node_bun();
38753
+ init_runtime_node_bun2();
38326
38754
  init_process_executor2();
38327
38755
  init_config2();
38328
38756
  init_context2();
@@ -38467,6 +38895,27 @@ async function loadSpurConfig(cwd = process.cwd(), opts) {
38467
38895
  promise2.catch(() => spurConfigCache.delete(key));
38468
38896
  return promise2;
38469
38897
  }
38898
+ function expandTilde(path8) {
38899
+ if (path8 === "~")
38900
+ return homedir();
38901
+ if (path8.startsWith("~/"))
38902
+ return join2(homedir(), path8.slice(2));
38903
+ return path8;
38904
+ }
38905
+ function expandTeamTildes(config4) {
38906
+ const teams = config4.agent?.team;
38907
+ if (teams === undefined)
38908
+ return config4;
38909
+ const expanded = {};
38910
+ for (const [teamId, team] of Object.entries(teams)) {
38911
+ expanded[teamId] = {
38912
+ ...team,
38913
+ work_dir: expandTilde(team.work_dir),
38914
+ members: team.members.map((member) => typeof member === "string" || member.workspace === undefined ? member : { ...member, workspace: expandTilde(member.workspace) })
38915
+ };
38916
+ }
38917
+ return { ...config4, agent: { ...config4.agent, team: expanded } };
38918
+ }
38470
38919
  async function loadSpurConfigFile(configPath, opts, validateJsonSchema2) {
38471
38920
  let raw;
38472
38921
  if (validateJsonSchema2) {
@@ -38490,7 +38939,7 @@ async function loadSpurConfigFile(configPath, opts, validateJsonSchema2) {
38490
38939
  const text3 = await nodeFs.readFile(resolved);
38491
38940
  raw = $parse(text3) ?? {};
38492
38941
  }
38493
- return spurConfigSchema.parse(raw);
38942
+ return expandTeamTildes(spurConfigSchema.parse(raw));
38494
38943
  }
38495
38944
  async function loadStructuredSpurConfig(configPath, opts) {
38496
38945
  const validateJsonSchema2 = opts?.validateJsonSchema ?? true;
@@ -40382,7 +40831,7 @@ var init_mod = __esm(() => {
40382
40831
  init_config3();
40383
40832
  });
40384
40833
 
40385
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/logger.js
40834
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/logger.js
40386
40835
  function toLogTapeLevel(level) {
40387
40836
  return level === "warn" ? "warning" : level;
40388
40837
  }
@@ -41935,7 +42384,7 @@ var require_src = __commonJS((exports) => {
41935
42384
  };
41936
42385
  });
41937
42386
 
41938
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/telemetry/sdk.js
42387
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/telemetry/sdk.js
41939
42388
  function getTelemetryConfig(configPartial = {}) {
41940
42389
  return {
41941
42390
  enabled: configPartial.enabled ?? CONFIG_DEFAULTS.enabled,
@@ -41971,7 +42420,7 @@ var init_sdk = __esm(() => {
41971
42420
  resolvedConfig = getTelemetryConfig();
41972
42421
  });
41973
42422
 
41974
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/telemetry/tracing.js
42423
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/telemetry/tracing.js
41975
42424
  function isSuppressed(tracer2) {
41976
42425
  return tracer2 === undefined && !getResolvedConfig().enabled;
41977
42426
  }
@@ -42011,7 +42460,7 @@ var init_tracing2 = __esm(() => {
42011
42460
  import_api2 = __toESM(require_src(), 1);
42012
42461
  });
42013
42462
 
42014
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/telemetry/metrics.js
42463
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/telemetry/metrics.js
42015
42464
  function getMeter() {
42016
42465
  return import_api3.metrics.getMeter(METER_NAME, METER_VERSION);
42017
42466
  }
@@ -42108,7 +42557,7 @@ var init_metrics = __esm(() => {
42108
42557
  instruments = {};
42109
42558
  });
42110
42559
 
42111
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/event-bus/event-bus.js
42560
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/event-bus/event-bus.js
42112
42561
  function busLogger() {
42113
42562
  if (!_busLogger)
42114
42563
  _busLogger = getLogger2("event-bus");
@@ -42353,7 +42802,7 @@ var init_event_bus = __esm(() => {
42353
42802
  init_metrics();
42354
42803
  });
42355
42804
 
42356
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/event-bus/default-observers.js
42805
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/event-bus/default-observers.js
42357
42806
  function obsLogger() {
42358
42807
  if (!_obsLogger)
42359
42808
  _obsLogger = getLogger2("event-bus.observers");
@@ -42417,7 +42866,105 @@ var init_default_observers = __esm(() => {
42417
42866
  init_event_bus();
42418
42867
  });
42419
42868
 
42420
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/scheduler/node.js
42869
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/event-bus/file-observer.js
42870
+ function parentDir(filePath) {
42871
+ const idx = filePath.lastIndexOf("/");
42872
+ return idx <= 0 ? "." : filePath.slice(0, idx);
42873
+ }
42874
+ function isPromiseLike2(value) {
42875
+ return value !== null && typeof value === "object" && "then" in value;
42876
+ }
42877
+ function attachFileObserver(lifecycleBus, filePath, writer) {
42878
+ const logger2 = getLogger2("event-bus.file-observer");
42879
+ const ensureResult = writer.ensureDir(parentDir(filePath));
42880
+ let ready = !isPromiseLike2(ensureResult);
42881
+ let pending = isPromiseLike2(ensureResult);
42882
+ let setupFailed = false;
42883
+ let sequence = 0;
42884
+ let writeChain = isPromiseLike2(ensureResult) ? Promise.resolve(ensureResult).then(() => {
42885
+ ready = true;
42886
+ }).catch((error51) => {
42887
+ setupFailed = true;
42888
+ logger2.warn("failed to prepare event bus file observer directory", {
42889
+ filePath,
42890
+ error: error51 instanceof Error ? error51.message : String(error51)
42891
+ });
42892
+ }) : Promise.resolve();
42893
+ function setPending(next) {
42894
+ const current = ++sequence;
42895
+ pending = true;
42896
+ writeChain = next.catch((error51) => {
42897
+ logger2.warn("failed to append event bus lifecycle event", {
42898
+ filePath,
42899
+ error: error51 instanceof Error ? error51.message : String(error51)
42900
+ });
42901
+ }).finally(() => {
42902
+ if (sequence === current)
42903
+ pending = false;
42904
+ });
42905
+ }
42906
+ function writeLine2(line) {
42907
+ const content = `${JSON.stringify(line)}
42908
+ `;
42909
+ if (setupFailed)
42910
+ return;
42911
+ if (ready && !pending) {
42912
+ const result = writer.appendFile(filePath, content);
42913
+ if (isPromiseLike2(result)) {
42914
+ setPending(Promise.resolve(result));
42915
+ }
42916
+ return;
42917
+ }
42918
+ setPending(writeChain.then(() => {
42919
+ if (setupFailed)
42920
+ return;
42921
+ return writer.appendFile(filePath, content);
42922
+ }));
42923
+ }
42924
+ lifecycleBus.on("bus.emit.done", (d) => {
42925
+ const payload = d.detail !== null && typeof d.detail === "object" && !Array.isArray(d.detail) ? d.detail : undefined;
42926
+ writeLine2({
42927
+ ts: new Date().toISOString(),
42928
+ lifecycle: "bus.emit.done",
42929
+ event: d.event,
42930
+ syncCount: d.syncCount,
42931
+ asyncCount: d.asyncCount,
42932
+ emitDurationMs: d.emitDurationMs,
42933
+ errors: d.errors,
42934
+ ...payload && Object.keys(payload).length > 0 ? { payload } : {}
42935
+ });
42936
+ });
42937
+ lifecycleBus.on("bus.emit.noop", (d) => {
42938
+ writeLine2({
42939
+ ts: new Date().toISOString(),
42940
+ lifecycle: "bus.emit.noop",
42941
+ event: d.event
42942
+ });
42943
+ });
42944
+ lifecycleBus.on("bus.handler.error", (d) => {
42945
+ writeLine2({
42946
+ ts: new Date().toISOString(),
42947
+ lifecycle: "bus.handler.error",
42948
+ event: d.event,
42949
+ mode: d.mode,
42950
+ error: d.error
42951
+ });
42952
+ });
42953
+ lifecycleBus.on("bus.handler.async.enqueued", (d) => {
42954
+ writeLine2({
42955
+ ts: new Date().toISOString(),
42956
+ lifecycle: "bus.handler.async.enqueued",
42957
+ event: d.event,
42958
+ jobId: d.jobId,
42959
+ handlerCount: d.handlerCount
42960
+ });
42961
+ });
42962
+ }
42963
+ var init_file_observer = __esm(() => {
42964
+ init_logger3();
42965
+ });
42966
+
42967
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/scheduler/node.js
42421
42968
  function parseInterval(cron) {
42422
42969
  const trimmed = cron.trim();
42423
42970
  const num = Number(trimmed);
@@ -42491,7 +43038,7 @@ var init_node3 = __esm(() => {
42491
43038
  init_metrics();
42492
43039
  });
42493
43040
 
42494
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/scheduler-node.js
43041
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/scheduler-node.js
42495
43042
  var exports_scheduler_node = {};
42496
43043
  __export(exports_scheduler_node, {
42497
43044
  NodeSchedulerAdapter: () => NodeSchedulerAdapter
@@ -45425,10 +45972,10 @@ var require_default_service_name = __commonJS((exports) => {
45425
45972
  var require_utils5 = __commonJS((exports) => {
45426
45973
  Object.defineProperty(exports, "__esModule", { value: true });
45427
45974
  exports.isPromiseLike = undefined;
45428
- var isPromiseLike = (val) => {
45975
+ var isPromiseLike3 = (val) => {
45429
45976
  return val !== null && typeof val === "object" && typeof val.then === "function";
45430
45977
  };
45431
- exports.isPromiseLike = isPromiseLike;
45978
+ exports.isPromiseLike = isPromiseLike3;
45432
45979
  });
45433
45980
 
45434
45981
  // ../../node_modules/.bun/@opentelemetry+resources@2.7.1+e40b0dfdd726a224/node_modules/@opentelemetry/resources/build/src/ResourceImpl.js
@@ -48747,7 +49294,12 @@ var init_errors5 = __esm(() => {
48747
49294
  };
48748
49295
  });
48749
49296
 
48750
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/api-client.js
49297
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/event-bus/index.js
49298
+ var init_event_bus2 = __esm(() => {
49299
+ init_event_bus();
49300
+ });
49301
+
49302
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/api-client.js
48751
49303
  function sanitizeUrlForObservability(url2) {
48752
49304
  try {
48753
49305
  const parsed = new URL(url2);
@@ -48809,7 +49361,7 @@ class APIClient {
48809
49361
  this.defaultHeaders = config4.defaultHeaders ?? {};
48810
49362
  this.timeout = config4.timeout ?? 30000;
48811
49363
  this.fetchFn = config4.fetch ?? globalThis.fetch;
48812
- this.events = config4.events;
49364
+ this.events = config4.events ?? (config4.lifecycleBus ? new EventBus({ lifecycleBus: config4.lifecycleBus }) : undefined);
48813
49365
  }
48814
49366
  buildUrl(path9) {
48815
49367
  return `${this.baseUrl}${path9.startsWith("/") ? path9 : `/${path9}`}`;
@@ -48960,6 +49512,7 @@ class APIClient {
48960
49512
  }
48961
49513
  var import_api15, import_semantic_conventions2, APIError;
48962
49514
  var init_api_client = __esm(() => {
49515
+ init_event_bus2();
48963
49516
  init_metrics();
48964
49517
  init_tracing2();
48965
49518
  import_api15 = __toESM(require_src(), 1);
@@ -48976,17 +49529,12 @@ var init_api_client = __esm(() => {
48976
49529
  };
48977
49530
  });
48978
49531
 
48979
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/event-bus/index.js
48980
- var init_event_bus2 = __esm(() => {
48981
- init_event_bus();
48982
- });
48983
-
48984
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/telemetry/index.js
49532
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/telemetry/index.js
48985
49533
  var init_telemetry = __esm(() => {
48986
49534
  init_tracing2();
48987
49535
  });
48988
49536
 
48989
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/index.js
49537
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/index.js
48990
49538
  var init_dist6 = __esm(() => {
48991
49539
  init_api_client();
48992
49540
  init_event_bus2();
@@ -48994,7 +49542,7 @@ var init_dist6 = __esm(() => {
48994
49542
  init_telemetry();
48995
49543
  });
48996
49544
 
48997
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.8+2e11ad5b9561782b/node_modules/@gobing-ai/ts-ai-runner/dist/agents/shims.js
49545
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.10+443204d2f30aef7a/node_modules/@gobing-ai/ts-ai-runner/dist/agents/shims.js
48998
49546
  function resolveAgentName(input) {
48999
49547
  if (isCanonicalName(input))
49000
49548
  return input;
@@ -49245,7 +49793,7 @@ var init_shims = __esm(() => {
49245
49793
  ALIAS_TO_CANONICAL = Object.fromEntries(Object.values(AGENT_SHIMS).flatMap((shim) => (shim.aliases ?? []).map((alias3) => [alias3, shim.name])));
49246
49794
  });
49247
49795
 
49248
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.8+2e11ad5b9561782b/node_modules/@gobing-ai/ts-ai-runner/dist/identity.js
49796
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.10+443204d2f30aef7a/node_modules/@gobing-ai/ts-ai-runner/dist/identity.js
49249
49797
  function buildIdentityPreamble(ctx) {
49250
49798
  const sections = [
49251
49799
  `You are agent \`${ctx.agentId}\` (${ctx.agentType}) in workspace \`${ctx.workspace}\`.`
@@ -49305,7 +49853,7 @@ var init_identity = __esm(() => {
49305
49853
  init_dist5();
49306
49854
  });
49307
49855
 
49308
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.8+2e11ad5b9561782b/node_modules/@gobing-ai/ts-ai-runner/dist/slash-command.js
49856
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.10+443204d2f30aef7a/node_modules/@gobing-ai/ts-ai-runner/dist/slash-command.js
49309
49857
  function isClaudeStyleSlashCommand(input) {
49310
49858
  return SLASH_COMMAND_RE.test(input);
49311
49859
  }
@@ -49333,19 +49881,22 @@ var init_slash_command = __esm(() => {
49333
49881
  SLASH_COMMAND_RE = /^\/([a-zA-Z0-9._-]+):([a-zA-Z0-9._-]+)(\s.*)?$/;
49334
49882
  });
49335
49883
 
49336
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.8+2e11ad5b9561782b/node_modules/@gobing-ai/ts-ai-runner/dist/ai-runner.js
49884
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.10+443204d2f30aef7a/node_modules/@gobing-ai/ts-ai-runner/dist/ai-runner.js
49337
49885
  class AiRunner {
49338
49886
  processExecutor;
49339
49887
  defaultCwd;
49340
49888
  defaultTimeout;
49341
49889
  logger;
49342
49890
  events;
49891
+ processEvents;
49343
49892
  constructor(options = {}) {
49344
- this.processExecutor = options.processExecutor ?? new NodeProcessExecutor2({
49345
- ...options.processEvents !== undefined ? {
49893
+ const processEvents = options.processEvents ?? (options.lifecycleBus ? new EventBus({ lifecycleBus: options.lifecycleBus }) : undefined);
49894
+ const events = options.events ?? (options.lifecycleBus ? new EventBus({ lifecycleBus: options.lifecycleBus }) : undefined);
49895
+ this.processExecutor = options.processExecutor ?? nodeBunFactory3.createProcessExecutor({
49896
+ ...processEvents !== undefined ? {
49346
49897
  events: {
49347
49898
  emit: (event, detail) => {
49348
- options.processEvents?.emit(event, detail);
49899
+ processEvents?.emit(event, detail);
49349
49900
  }
49350
49901
  }
49351
49902
  } : {},
@@ -49356,7 +49907,8 @@ class AiRunner {
49356
49907
  this.defaultCwd = options.defaultCwd;
49357
49908
  this.defaultTimeout = options.defaultTimeout;
49358
49909
  this.logger = options.logger ?? getLogger2("ai-runner");
49359
- this.events = options.events;
49910
+ this.events = events;
49911
+ this.processEvents = processEvents;
49360
49912
  }
49361
49913
  runHelpCommand(agent, options = {}) {
49362
49914
  return this.invoke(agent, "help", getAgentShim(agent).getHelpCommand(), options, true);
@@ -49447,7 +49999,7 @@ var init_ai_runner = __esm(() => {
49447
49999
  init_slash_command();
49448
50000
  });
49449
50001
 
49450
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.8+2e11ad5b9561782b/node_modules/@gobing-ai/ts-ai-runner/dist/agent-detector.js
50002
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.10+443204d2f30aef7a/node_modules/@gobing-ai/ts-ai-runner/dist/agent-detector.js
49451
50003
  class AgentDetector {
49452
50004
  runner;
49453
50005
  timeout;
@@ -49523,7 +50075,7 @@ var init_agent_detector = __esm(() => {
49523
50075
  VERSION_PATTERN = /(?<version>\d+\.\d+(?:\.\d+)?)/;
49524
50076
  });
49525
50077
 
49526
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.8+2e11ad5b9561782b/node_modules/@gobing-ai/ts-ai-runner/dist/agent-spec.js
50078
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.10+443204d2f30aef7a/node_modules/@gobing-ai/ts-ai-runner/dist/agent-spec.js
49527
50079
  function validateAgentId(id) {
49528
50080
  if (!/^[a-z][a-z0-9_-]{1,63}$/.test(id)) {
49529
50081
  throw new ValueError(`Invalid agent id "${id}": expected 2-64 chars, lowercase alphanumeric, "_" or "-"`);
@@ -49620,12 +50172,12 @@ var init_agent_spec = __esm(() => {
49620
50172
  };
49621
50173
  });
49622
50174
 
49623
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.8+2e11ad5b9561782b/node_modules/@gobing-ai/ts-ai-runner/dist/agents/auth-shims.js
50175
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.10+443204d2f30aef7a/node_modules/@gobing-ai/ts-ai-runner/dist/agents/auth-shims.js
49624
50176
  function isNonEmpty(value) {
49625
50177
  return value !== undefined && value.trim().length > 0;
49626
50178
  }
49627
50179
  async function isAuthenticated(agent, ctx) {
49628
- const env = ctx.env ?? getProcessEnv();
50180
+ const env = ctx.env ?? getProcessEnv2();
49629
50181
  const fs3 = ctx.fileSystem;
49630
50182
  const timeout = ctx.timeout ?? DEFAULT_AUTH_TIMEOUT_MS;
49631
50183
  const home = env.HOME || env.USERPROFILE || "";
@@ -49725,7 +50277,7 @@ var init_auth_shims = __esm(() => {
49725
50277
  };
49726
50278
  });
49727
50279
 
49728
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.8+2e11ad5b9561782b/node_modules/@gobing-ai/ts-ai-runner/dist/model-health-probe.js
50280
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.10+443204d2f30aef7a/node_modules/@gobing-ai/ts-ai-runner/dist/model-health-probe.js
49729
50281
  class ModelHealthProbeRegistry {
49730
50282
  probes = new Map;
49731
50283
  register(providerPrefix, probe) {
@@ -49833,7 +50385,7 @@ var init_model_health_probe = __esm(() => {
49833
50385
  };
49834
50386
  });
49835
50387
 
49836
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.8+2e11ad5b9561782b/node_modules/@gobing-ai/ts-ai-runner/dist/doctor-runner.js
50388
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.10+443204d2f30aef7a/node_modules/@gobing-ai/ts-ai-runner/dist/doctor-runner.js
49837
50389
  class DoctorRunner {
49838
50390
  detector;
49839
50391
  runner;
@@ -49848,7 +50400,7 @@ class DoctorRunner {
49848
50400
  this.runner = options.runner ?? new AiRunner;
49849
50401
  this.detector = options.agentDetector ?? new AgentDetector({ runner: this.runner });
49850
50402
  this.timeout = options.timeout ?? DEFAULT_TIMEOUT_MS2;
49851
- this.env = options.env ?? getProcessEnv();
50403
+ this.env = options.env ?? getProcessEnv2();
49852
50404
  this.fs = options.fileSystem ?? createNodeFileSystem3();
49853
50405
  this.logger = options.logger ?? getLogger2("doctor");
49854
50406
  this.executors = options.executors ?? [];
@@ -49970,15 +50522,15 @@ var init_doctor_runner = __esm(() => {
49970
50522
  init_model_health_probe();
49971
50523
  });
49972
50524
 
49973
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.8+2e11ad5b9561782b/node_modules/@gobing-ai/ts-ai-runner/dist/events.js
50525
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.10+443204d2f30aef7a/node_modules/@gobing-ai/ts-ai-runner/dist/events.js
49974
50526
  var init_events = () => {};
49975
50527
 
49976
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.8+2e11ad5b9561782b/node_modules/@gobing-ai/ts-ai-runner/dist/messages.js
50528
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.10+443204d2f30aef7a/node_modules/@gobing-ai/ts-ai-runner/dist/messages.js
49977
50529
  function formatMessage(msg) {
49978
50530
  return `[task from=${msg.fromId ?? "operator"} id=${msg.id}] ${msg.body}`;
49979
50531
  }
49980
50532
 
49981
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.8+2e11ad5b9561782b/node_modules/@gobing-ai/ts-ai-runner/dist/team-agent-process.js
50533
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.10+443204d2f30aef7a/node_modules/@gobing-ai/ts-ai-runner/dist/team-agent-process.js
49982
50534
  import { Buffer as Buffer5 } from "buffer";
49983
50535
 
49984
50536
  class TeamAgentProcess {
@@ -49997,7 +50549,7 @@ class TeamAgentProcess {
49997
50549
  this.command = options.command;
49998
50550
  this.env = options.env;
49999
50551
  this.cwd = options.cwd ?? options.spec.workspace;
50000
- this.processExecutor = options.processExecutor ?? new ProcessExecutor3;
50552
+ this.processExecutor = options.processExecutor ?? nodeBunFactory3.createProcessExecutor();
50001
50553
  this.logger = options.logger ?? getLogger2("team-agent");
50002
50554
  }
50003
50555
  async start() {
@@ -50112,7 +50664,7 @@ var init_team_agent_process = __esm(() => {
50112
50664
  init_dist5();
50113
50665
  });
50114
50666
 
50115
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.8+2e11ad5b9561782b/node_modules/@gobing-ai/ts-ai-runner/dist/team-orchestrator.js
50667
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.10+443204d2f30aef7a/node_modules/@gobing-ai/ts-ai-runner/dist/team-orchestrator.js
50116
50668
  class TeamOrchestrator {
50117
50669
  configDir;
50118
50670
  inbox;
@@ -50124,7 +50676,7 @@ class TeamOrchestrator {
50124
50676
  this.configDir = configDir;
50125
50677
  this.inbox = inbox;
50126
50678
  this.processFactory = options.processFactory ?? ((processOptions) => new TeamAgentProcess(processOptions));
50127
- this.events = options.events ?? new EventBus;
50679
+ this.events = options.events ?? (options.lifecycleBus ? new EventBus({ lifecycleBus: options.lifecycleBus }) : new EventBus);
50128
50680
  }
50129
50681
  async loadSpecs() {
50130
50682
  this.specs = await loadAgentSpecs(this.configDir);
@@ -50241,7 +50793,7 @@ var init_team_orchestrator = __esm(() => {
50241
50793
  init_team_agent_process();
50242
50794
  });
50243
50795
 
50244
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.8+2e11ad5b9561782b/node_modules/@gobing-ai/ts-ai-runner/dist/index.js
50796
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.4.10+443204d2f30aef7a/node_modules/@gobing-ai/ts-ai-runner/dist/index.js
50245
50797
  var exports_dist3 = {};
50246
50798
  __export(exports_dist3, {
50247
50799
  validateAgentId: () => validateAgentId,
@@ -50310,7 +50862,12 @@ class AgentService {
50310
50862
  }
50311
50863
  async resolve(flags, deps) {
50312
50864
  const outputPolicy = { mode: "buffered" };
50313
- const runner = deps?.runner ?? new AiRunner({ processExecutor: new NodeProcessExecutor2({ output: outputPolicy }) });
50865
+ const runner = deps?.runner ?? new AiRunner({
50866
+ processExecutor: new NodeProcessExecutor3({
50867
+ output: outputPolicy,
50868
+ ...this.ctx.processRegistry !== undefined ? { registry: this.ctx.processRegistry } : {}
50869
+ })
50870
+ });
50314
50871
  const detector = deps?.detector ?? new AgentDetector({ runner });
50315
50872
  const doctorRunner = deps?.doctorRunner ?? new DoctorRunner({ agentDetector: detector, runner, env: this.ctx.env });
50316
50873
  return this.resolveAgent(undefined, flags, doctorRunner);
@@ -50405,7 +50962,10 @@ class AgentService {
50405
50962
  const jsonOutput = silent || booleanFlag(flags, "json");
50406
50963
  const outputPolicy = jsonOutput ? { mode: "buffered" } : { mode: "stream", isTTY: isatty3(1) };
50407
50964
  const runner = deps?.runner ?? new AiRunner({
50408
- processExecutor: new NodeProcessExecutor2({ output: outputPolicy }),
50965
+ processExecutor: new NodeProcessExecutor3({
50966
+ output: outputPolicy,
50967
+ ...this.ctx.processRegistry !== undefined ? { registry: this.ctx.processRegistry } : {}
50968
+ }),
50409
50969
  ...this.ctx.events !== undefined ? { events: bridgeEventBus(this.ctx.events) } : {},
50410
50970
  ...this.ctx.events !== undefined ? { processEvents: bridgeEventBus(this.ctx.events) } : {}
50411
50971
  });
@@ -51156,7 +51716,10 @@ function tryParseFeature(content) {
51156
51716
  if (!content.includes("Feature:") && !content.includes("Scenario:")) {
51157
51717
  return null;
51158
51718
  }
51159
- return parseFeature(content);
51719
+ const toParse = content.includes("Feature:") || !content.includes("Scenario:") ? content : `Feature: __coverage_wrapper__
51720
+
51721
+ ${content}`;
51722
+ return parseFeature(toParse);
51160
51723
  }
51161
51724
  var init_coverage = () => {};
51162
51725
 
@@ -51698,7 +52261,7 @@ var init_drizzle_zod = __esm(() => {
51698
52261
  };
51699
52262
  });
51700
52263
 
51701
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/schema/drizzle-internals.js
52264
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/schema/drizzle-internals.js
51702
52265
  function sqlExpressionToText(value) {
51703
52266
  if (typeof value !== "object" || value === null || !("queryChunks" in value)) {
51704
52267
  return;
@@ -51721,7 +52284,7 @@ function getDrizzleTableName(table3) {
51721
52284
  return String(table3[nameSym]);
51722
52285
  }
51723
52286
 
51724
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/schema/ddl.js
52287
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/schema/ddl.js
51725
52288
  function quoteIdent(name) {
51726
52289
  return `"${name.replace(/"/g, '""')}"`;
51727
52290
  }
@@ -51815,7 +52378,7 @@ var init_ddl = __esm(() => {
51815
52378
  init_sqlite_core();
51816
52379
  });
51817
52380
 
51818
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/schema/define-table.js
52381
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/schema/define-table.js
51819
52382
  function defineTable(name, columns2) {
51820
52383
  const table3 = sqliteTable(name, columns2);
51821
52384
  let insert2;
@@ -51849,7 +52412,7 @@ var init_define_table = __esm(() => {
51849
52412
  init_ddl();
51850
52413
  });
51851
52414
 
51852
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.8+6416bade0e3e2531/node_modules/@gobing-ai/ts-db/dist/schema/index.js
52415
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.4.10+86b80a818ad2648a/node_modules/@gobing-ai/ts-db/dist/schema/index.js
51853
52416
  var init_schema = __esm(() => {
51854
52417
  init_sqlite_core();
51855
52418
  init_define_table();
@@ -51952,6 +52515,27 @@ class InboxRecentDao {
51952
52515
  throw error51;
51953
52516
  }
51954
52517
  }
52518
+ async countReplies(ids) {
52519
+ const result = new Map;
52520
+ if (ids.length === 0)
52521
+ return result;
52522
+ const placeholders = ids.map((_, i2) => `?${i2 + 1}`).join(", ");
52523
+ try {
52524
+ const rows = await this.db.queryAll(`SELECT in_reply_to, COUNT(*) AS n
52525
+ FROM inbox_messages
52526
+ WHERE in_reply_to IS NOT NULL AND in_reply_to IN (${placeholders})
52527
+ GROUP BY in_reply_to`, ...ids);
52528
+ for (const row of rows) {
52529
+ result.set(row.in_reply_to, row.n);
52530
+ }
52531
+ } catch (error51) {
52532
+ if (error51 instanceof Error && error51.message.includes("no such table: inbox_messages")) {
52533
+ return result;
52534
+ }
52535
+ throw error51;
52536
+ }
52537
+ return result;
52538
+ }
51955
52539
  }
51956
52540
 
51957
52541
  // ../../packages/domain/src/schema/phase-runs.ts
@@ -52404,7 +52988,7 @@ var init_dao = __esm(() => {
52404
52988
  init_workspace_dao();
52405
52989
  });
52406
52990
 
52407
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/errors.js
52991
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/errors.js
52408
52992
  var WorkflowValidationError, FSMError, RunCollisionError, WorkflowResumeError;
52409
52993
  var init_errors6 = __esm(() => {
52410
52994
  WorkflowValidationError = class WorkflowValidationError extends Error {
@@ -52439,7 +53023,7 @@ var init_errors6 = __esm(() => {
52439
53023
  };
52440
53024
  });
52441
53025
 
52442
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/run-lifecycle.js
53026
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/run-lifecycle.js
52443
53027
  function runtimeBuiltins(workflowName, stateOrNodeId, runId, transitionsTaken, mode) {
52444
53028
  return {
52445
53029
  workflow: workflowName,
@@ -52452,7 +53036,7 @@ function runtimeBuiltins(workflowName, stateOrNodeId, runId, transitionsTaken, m
52452
53036
  runtime: mode
52453
53037
  };
52454
53038
  }
52455
- function allowedEnv(names, source = getProcessEnv()) {
53039
+ function allowedEnv(names, source = getProcessEnv2()) {
52456
53040
  return Object.fromEntries(names.flatMap((name) => source[name] === undefined ? [] : [[name, source[name]]]));
52457
53041
  }
52458
53042
 
@@ -52470,7 +53054,7 @@ class RunLifecycle {
52470
53054
  this.runId = runId;
52471
53055
  this.externalKey = externalKey;
52472
53056
  this.persistence = deps.persistence;
52473
- this.events = deps.events;
53057
+ this.events = deps.events ?? (deps.lifecycleBus ? new EventBus({ lifecycleBus: deps.lifecycleBus }) : undefined);
52474
53058
  this.logger = (deps.logger ?? getLogger2("workflow")).child({ runId, workflow: workflowName, mode });
52475
53059
  }
52476
53060
  static forExternalTransition(workflowName, runId, deps, externalKey) {
@@ -52688,7 +53272,7 @@ var init_run_lifecycle = __esm(() => {
52688
53272
  ];
52689
53273
  });
52690
53274
 
52691
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/schema.js
53275
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/schema.js
52692
53276
  var RESERVED_VAR_NAMES, IDENTIFIER, VarsSchema, EnvSchema, ActionDefSchema, GuardDefSchema, StateMachineWorkflowDefSchema, TransitionFlowWorkflowDefSchema, WorkflowDefSchema;
52693
53277
  var init_schema2 = __esm(() => {
52694
53278
  init_zod();
@@ -52772,7 +53356,7 @@ var init_schema2 = __esm(() => {
52772
53356
  WorkflowDefSchema = exports_external.union([StateMachineWorkflowDefSchema, TransitionFlowWorkflowDefSchema]);
52773
53357
  });
52774
53358
 
52775
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/config.js
53359
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/config.js
52776
53360
  async function loadWorkflowDef(path9, options = {}) {
52777
53361
  return parseWorkflowDef(await loadStructuredConfig(path9, options), path9);
52778
53362
  }
@@ -52931,7 +53515,7 @@ var init_config4 = __esm(() => {
52931
53515
  RUNTIME_TEMPLATE_NAMESPACES = new Set(RUNTIME_BUILTIN_KEYS);
52932
53516
  });
52933
53517
 
52934
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/extension/capability-registry.js
53518
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/extension/capability-registry.js
52935
53519
  class CapabilityRegistry {
52936
53520
  kind;
52937
53521
  capabilities = new Map;
@@ -52962,7 +53546,7 @@ class CapabilityRegistry {
52962
53546
  }
52963
53547
  }
52964
53548
 
52965
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/extension/extension-path.js
53549
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/extension/extension-path.js
52966
53550
  function assertRelativeExtensionPath(path9, options = {}) {
52967
53551
  const where = options.sourceName !== undefined ? ` declared by "${options.sourceName}"` : "";
52968
53552
  if (/^([/\\]|[A-Za-z]:[/\\])/.test(path9)) {
@@ -52973,23 +53557,27 @@ function assertRelativeExtensionPath(path9, options = {}) {
52973
53557
  }
52974
53558
  }
52975
53559
 
52976
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/extension/extension-loader.js
53560
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/extension/extension-loader.js
52977
53561
  var init_extension_loader = () => {};
52978
53562
 
52979
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/extension/index.js
53563
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/extension/index.js
52980
53564
  var init_extension = __esm(() => {
52981
53565
  init_extension_loader();
52982
53566
  });
52983
53567
 
52984
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.8+e943d2626789fd3c/node_modules/@gobing-ai/ts-runtime/dist/extension.js
53568
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.4.10+f5990ac4de041c52/node_modules/@gobing-ai/ts-runtime/dist/extension.js
52985
53569
  var init_extension2 = __esm(() => {
52986
53570
  init_extension();
52987
53571
  });
52988
53572
 
52989
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/host.js
53573
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/host.js
52990
53574
  class WorkflowEngineHost {
53575
+ lifecycleBus;
52991
53576
  actions = new CapabilityRegistry("workflow action");
52992
53577
  guards = new CapabilityRegistry("workflow guard");
53578
+ constructor(lifecycleBus) {
53579
+ this.lifecycleBus = lifecycleBus;
53580
+ }
52993
53581
  registerAction(action, origin2 = "extension") {
52994
53582
  this.actions.register(action.kind, action, origin2);
52995
53583
  return this;
@@ -53032,11 +53620,11 @@ class WorkflowEngineHost {
53032
53620
  }
53033
53621
  }
53034
53622
  function createDefaultWorkflowEngineHost(options = {}) {
53035
- const host = new WorkflowEngineHost;
53623
+ const host = new WorkflowEngineHost(options.lifecycleBus);
53036
53624
  host.registerAction(new NoteActionRunner, "builtin");
53037
- host.registerAction(new ShellActionRunner(options.processExecutor ?? new NodeProcessExecutor2), "builtin");
53625
+ host.registerAction(new ShellActionRunner(options.processExecutor ?? nodeBunFactory3.createProcessExecutor()), "builtin");
53038
53626
  host.registerAction(new EventEmitActionRunner, "builtin");
53039
- host.registerGuard(new ShellGuardRunner(options.processExecutor ?? new NodeProcessExecutor2), "builtin");
53627
+ host.registerGuard(new ShellGuardRunner(options.processExecutor ?? nodeBunFactory3.createProcessExecutor()), "builtin");
53040
53628
  host.registerGuard({ kind: "always", evaluate: async () => true }, "builtin");
53041
53629
  host.registerGuard({ kind: "never", evaluate: async () => false }, "builtin");
53042
53630
  host.registerGuard({
@@ -53151,7 +53739,7 @@ var init_host = __esm(() => {
53151
53739
  init_errors6();
53152
53740
  });
53153
53741
 
53154
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/schema-sql.js
53742
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/schema-sql.js
53155
53743
  var WORKFLOW_ENGINE_SCHEMA_SQL;
53156
53744
  var init_schema_sql = __esm(() => {
53157
53745
  WORKFLOW_ENGINE_SCHEMA_SQL = `
@@ -53224,7 +53812,7 @@ CREATE TABLE IF NOT EXISTS action_runs (
53224
53812
  `.trim();
53225
53813
  });
53226
53814
 
53227
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/persistence.js
53815
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/persistence.js
53228
53816
  async function applyWorkflowEngineSchema(db2) {
53229
53817
  for (const statement of WORKFLOW_ENGINE_SCHEMA_SQL.split(";")) {
53230
53818
  const sql4 = statement.trim();
@@ -53492,7 +54080,7 @@ var init_persistence = __esm(() => {
53492
54080
  init_schema_sql();
53493
54081
  });
53494
54082
 
53495
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/variables.js
54083
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/variables.js
53496
54084
  function mergeVars(workflowVars = {}, overrideVars = {}) {
53497
54085
  return { ...workflowVars, ...overrideVars };
53498
54086
  }
@@ -53552,7 +54140,7 @@ var init_variables = __esm(() => {
53552
54140
  TEMPLATE_REF = /\$\{([^}]+)\}/g;
53553
54141
  });
53554
54142
 
53555
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/action-step.js
54143
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/action-step.js
53556
54144
  async function runActionStep(action, vars, deps) {
53557
54145
  const { host, persistence, lifecycle, stateOrNodeId, runId } = deps;
53558
54146
  const resolved = resolveTemplates(action.options ?? {}, {
@@ -53609,7 +54197,7 @@ var init_action_step = __esm(() => {
53609
54197
  init_variables();
53610
54198
  });
53611
54199
 
53612
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/state-machine.js
54200
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/state-machine.js
53613
54201
  class StateMachineDriver {
53614
54202
  options;
53615
54203
  constructor(options) {
@@ -53743,7 +54331,7 @@ var init_state_machine = __esm(() => {
53743
54331
  EMPTY_OUTCOME = { outcome: "completed", result: undefined };
53744
54332
  });
53745
54333
 
53746
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/transition-flow.js
54334
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/transition-flow.js
53747
54335
  class TransitionFlowDriver {
53748
54336
  options;
53749
54337
  constructor(options) {
@@ -53861,23 +54449,35 @@ var init_transition_flow = __esm(() => {
53861
54449
  init_variables();
53862
54450
  });
53863
54451
 
53864
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/service.js
54452
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/service.js
53865
54453
  class WorkflowService {
53866
54454
  host;
53867
54455
  persistence;
53868
54456
  runLocks = new Map;
53869
- constructor(host, persistence) {
54457
+ lifecycleBus;
54458
+ constructor(host, persistence, lifecycleBus) {
53870
54459
  this.host = host;
53871
54460
  this.persistence = persistence;
54461
+ this.lifecycleBus = lifecycleBus ?? host.lifecycleBus;
54462
+ }
54463
+ resolveEvents(events2) {
54464
+ return events2 ?? (this.lifecycleBus ? new EventBus({ lifecycleBus: this.lifecycleBus }) : undefined);
53872
54465
  }
53873
54466
  async load(path9) {
53874
54467
  return await loadWorkflowDef(path9);
53875
54468
  }
53876
54469
  async run(workflow, options = {}) {
54470
+ const events2 = this.resolveEvents(options.events);
53877
54471
  if (workflow.kind === "transition-flow") {
53878
- return await new TransitionFlowDriver({ host: this.host, persistence: this.persistence }).run(workflow, options);
54472
+ return await new TransitionFlowDriver({ host: this.host, persistence: this.persistence }).run(workflow, {
54473
+ ...options,
54474
+ events: events2
54475
+ });
53879
54476
  }
53880
- return await new StateMachineDriver({ host: this.host, persistence: this.persistence }).run(workflow, options);
54477
+ return await new StateMachineDriver({ host: this.host, persistence: this.persistence }).run(workflow, {
54478
+ ...options,
54479
+ events: events2
54480
+ });
53881
54481
  }
53882
54482
  async runFile(path9, options = {}) {
53883
54483
  return await this.run(await this.load(path9), options);
@@ -53920,7 +54520,7 @@ class WorkflowService {
53920
54520
  const run = await this.persistence.loadRun(runId);
53921
54521
  const extKey = run?.external_key ?? undefined;
53922
54522
  const result = await this.persistence.reseedRun(runId, newState);
53923
- options?.events?.emit("workflow.run.reseeded", {
54523
+ this.resolveEvents(options?.events)?.emit("workflow.run.reseeded", {
53924
54524
  runId,
53925
54525
  fromState: result.fromState ?? "",
53926
54526
  toState: result.toState,
@@ -53941,17 +54541,18 @@ class WorkflowService {
53941
54541
  }
53942
54542
  const extKey = run.external_key ?? undefined;
53943
54543
  await this.persistence.finalizeRun(runId, "running", "");
53944
- options?.events?.emit("workflow.run.resumed", { runId, node: currentState, externalKey: extKey });
54544
+ const events2 = this.resolveEvents(options?.events);
54545
+ events2?.emit("workflow.run.resumed", { runId, node: currentState, externalKey: extKey });
53945
54546
  if (workflow.kind === "transition-flow") {
53946
54547
  return await new TransitionFlowDriver({
53947
54548
  host: this.host,
53948
54549
  persistence: this.persistence
53949
- }).resume(workflow, runId, currentState, extKey, options);
54550
+ }).resume(workflow, runId, currentState, extKey, { ...options, events: events2 });
53950
54551
  }
53951
54552
  return await new StateMachineDriver({
53952
54553
  host: this.host,
53953
54554
  persistence: this.persistence
53954
- }).resume(workflow, runId, currentState, extKey, options);
54555
+ }).resume(workflow, runId, currentState, extKey, { ...options, events: events2 });
53955
54556
  }
53956
54557
  async listPausedRuns(options) {
53957
54558
  return await this.persistence.listPausedRuns(options);
@@ -53984,10 +54585,11 @@ class WorkflowService {
53984
54585
  detail: `No state recorded for run "${runId}"`
53985
54586
  };
53986
54587
  }
53987
- const lifecycle = RunLifecycle.forExternalTransition(workflow.name, runId, { persistence: this.persistence, events: options?.events }, extKey);
54588
+ const events2 = this.resolveEvents(options?.events);
54589
+ const lifecycle = RunLifecycle.forExternalTransition(workflow.name, runId, { persistence: this.persistence, events: events2 }, extKey);
53988
54590
  const transition = workflow.transitions.find((t) => t.from === currentState && t.to === toState);
53989
54591
  if (transition === undefined) {
53990
- return this.denyTransition(options, runId, currentState, toState, extKey, {
54592
+ return this.denyTransition(events2, runId, currentState, toState, extKey, {
53991
54593
  reason: "no-such-transition",
53992
54594
  detail: `No transition from "${currentState}" to "${toState}"`
53993
54595
  });
@@ -54005,7 +54607,7 @@ class WorkflowService {
54005
54607
  });
54006
54608
  lifecycle.guardEvaluated(currentState, toState, transition.guard.kind, guardResult.passed);
54007
54609
  if (!guardResult.passed) {
54008
- return this.denyTransition(options, runId, currentState, toState, extKey, {
54610
+ return this.denyTransition(events2, runId, currentState, toState, extKey, {
54009
54611
  reason: "guard-failed",
54010
54612
  detail: `Guard "${transition.guard.kind}" denied transition from "${currentState}" to "${toState}"`,
54011
54613
  guardKind: transition.guard.kind,
@@ -54015,7 +54617,7 @@ class WorkflowService {
54015
54617
  }
54016
54618
  const trigger = transition.trigger ?? null;
54017
54619
  await lifecycle.commitHop(currentState, toState, trigger, 0);
54018
- options?.events?.emit("workflow.transition.requested", {
54620
+ events2?.emit("workflow.transition.requested", {
54019
54621
  runId,
54020
54622
  from: currentState,
54021
54623
  to: toState,
@@ -54024,8 +54626,8 @@ class WorkflowService {
54024
54626
  });
54025
54627
  return { allowed: true, fromState: currentState, toState };
54026
54628
  }
54027
- denyTransition(options, runId, from, to, externalKey, denial) {
54028
- options?.events?.emit("workflow.transition.denied", {
54629
+ denyTransition(events2, runId, from, to, externalKey, denial) {
54630
+ events2?.emit("workflow.transition.denied", {
54029
54631
  runId,
54030
54632
  from,
54031
54633
  to,
@@ -54036,6 +54638,7 @@ class WorkflowService {
54036
54638
  }
54037
54639
  }
54038
54640
  var init_service = __esm(() => {
54641
+ init_dist6();
54039
54642
  init_config4();
54040
54643
  init_errors6();
54041
54644
  init_run_lifecycle();
@@ -54044,7 +54647,7 @@ var init_service = __esm(() => {
54044
54647
  init_variables();
54045
54648
  });
54046
54649
 
54047
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/index.js
54650
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/index.js
54048
54651
  var init_dist8 = __esm(() => {
54049
54652
  init_config4();
54050
54653
  init_host();
@@ -54053,7 +54656,7 @@ var init_dist8 = __esm(() => {
54053
54656
  init_service();
54054
54657
  });
54055
54658
 
54056
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.8+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/errors.js
54659
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.10+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/errors.js
54057
54660
  var HistoryImportError;
54058
54661
  var init_errors7 = __esm(() => {
54059
54662
  HistoryImportError = class HistoryImportError extends Error {
@@ -54066,7 +54669,7 @@ var init_errors7 = __esm(() => {
54066
54669
  };
54067
54670
  });
54068
54671
 
54069
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.8+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/hash.js
54672
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.10+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/hash.js
54070
54673
  import { createHash } from "crypto";
54071
54674
  function stableJson(value) {
54072
54675
  if (Array.isArray(value)) {
@@ -54083,7 +54686,7 @@ function sha256(value) {
54083
54686
  }
54084
54687
  var init_hash = () => {};
54085
54688
 
54086
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.8+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/redaction.js
54689
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.10+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/redaction.js
54087
54690
  function redactValue(value, rules = DEFAULT_REDACTION_RULES) {
54088
54691
  if (typeof value === "string") {
54089
54692
  return rules.reduce((current, rule) => current.replace(rule.pattern, rule.replacement), value);
@@ -54120,7 +54723,7 @@ var init_redaction = __esm(() => {
54120
54723
  ];
54121
54724
  });
54122
54725
 
54123
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.8+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/schema-sql.js
54726
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.10+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/schema-sql.js
54124
54727
  var HISTORY_IMPORT_SCHEMA_SQL;
54125
54728
  var init_schema_sql2 = __esm(() => {
54126
54729
  HISTORY_IMPORT_SCHEMA_SQL = `
@@ -54207,7 +54810,7 @@ CREATE TABLE IF NOT EXISTS history_etl_openclaw (
54207
54810
  `.trim();
54208
54811
  });
54209
54812
 
54210
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.8+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/sources.js
54813
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.10+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/sources.js
54211
54814
  function firstString(...values) {
54212
54815
  for (const value of values) {
54213
54816
  if (typeof value === "string" && value.length > 0)
@@ -54295,7 +54898,7 @@ var init_sources = __esm(() => {
54295
54898
  };
54296
54899
  });
54297
54900
 
54298
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.8+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/importer.js
54901
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.10+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/importer.js
54299
54902
  async function applyHistoryImportSchema(db2) {
54300
54903
  for (const statement of HISTORY_IMPORT_SCHEMA_SQL.split(";")) {
54301
54904
  const sql4 = statement.trim();
@@ -54532,13 +55135,13 @@ var init_importer = __esm(() => {
54532
55135
  VALID_TABLE_NAME = /^history_etl_[a-z_]+$/;
54533
55136
  });
54534
55137
 
54535
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.8+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/index.js
55138
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.4.10+d5c29f764bf0e6e0/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/index.js
54536
55139
  var init_dist9 = __esm(() => {
54537
55140
  init_importer();
54538
55141
  init_schema_sql2();
54539
55142
  });
54540
55143
 
54541
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/config/extensions.js
55144
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/config/extensions.js
54542
55145
  function collectExtensions(sourceName, sourceDir, extensions) {
54543
55146
  if (extensions === undefined)
54544
55147
  return [];
@@ -54554,7 +55157,7 @@ var init_extensions = __esm(() => {
54554
55157
  init_dist5();
54555
55158
  });
54556
55159
 
54557
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/types.js
55160
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/types.js
54558
55161
  function createFinding(rule, message, filePath, extras = {}) {
54559
55162
  return {
54560
55163
  ruleId: rule.id,
@@ -54625,7 +55228,7 @@ var init_types3 = __esm(() => {
54625
55228
  });
54626
55229
  });
54627
55230
 
54628
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/config/loader.js
55231
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/config/loader.js
54629
55232
  async function loadPreset(name, options) {
54630
55233
  const merged = await buildMergedRoots(options.roots.map((root) => resolvePath4(root)), options.fileSystem);
54631
55234
  const presetPath = findMergedPreset(merged, name);
@@ -54840,7 +55443,7 @@ var init_loader2 = __esm(() => {
54840
55443
  FIX_MODE_AUTHORITY = { none: 0, suggest: 1, auto: 2 };
54841
55444
  });
54842
55445
 
54843
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/fixers/test-stub-fixer.js
55446
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/fixers/test-stub-fixer.js
54844
55447
  function normalizeFindingPath(filePath) {
54845
55448
  if (!filePath || isAbsolutePath2(filePath))
54846
55449
  return null;
@@ -54905,7 +55508,7 @@ var init_test_stub_fixer = __esm(() => {
54905
55508
  realFileSystem = createNodeFileSystem3();
54906
55509
  });
54907
55510
 
54908
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/fixers/fixers.js
55511
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/fixers/fixers.js
54909
55512
  function registerBuiltinFixers(host, exec) {
54910
55513
  const regexFixer = new RegexFixerProvider;
54911
55514
  const pathFixer = new PathFixerProvider;
@@ -55108,7 +55711,7 @@ var init_fixers = __esm(() => {
55108
55711
  };
55109
55712
  });
55110
55713
 
55111
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/config-access.js
55714
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/config-access.js
55112
55715
  function stringArray(value) {
55113
55716
  return Array.isArray(value) && value.every((item) => typeof item === "string") ? value : undefined;
55114
55717
  }
@@ -55146,7 +55749,7 @@ function parseInlineFlags(source) {
55146
55749
  return { flags, rest: source.slice(match[0].length) };
55147
55750
  }
55148
55751
 
55149
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/glob-match.js
55752
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/glob-match.js
55150
55753
  function matchesAny(path9, patterns) {
55151
55754
  if (patterns === undefined || patterns.length === 0)
55152
55755
  return true;
@@ -55194,7 +55797,7 @@ function escapeRegExp(value) {
55194
55797
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
55195
55798
  }
55196
55799
 
55197
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/file-discovery.js
55800
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/file-discovery.js
55198
55801
  async function discoverFiles2(options) {
55199
55802
  const fs3 = options.fs ?? createNodeFileSystem3();
55200
55803
  const allFiles = await walkDir2(options.workdir, fs3, DEFAULT_EXCLUDES);
@@ -55222,12 +55825,12 @@ var init_file_discovery = __esm(() => {
55222
55825
  DEFAULT_EXCLUDES = new Set([".git", "node_modules", "dist", ".coverage", ".astro", ".wrangler"]);
55223
55826
  });
55224
55827
 
55225
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/file-utils.js
55828
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/file-utils.js
55226
55829
  var init_file_utils = __esm(() => {
55227
55830
  init_file_discovery();
55228
55831
  });
55229
55832
 
55230
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/agent-detection-evaluator.js
55833
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/agent-detection-evaluator.js
55231
55834
  class AgentDetectionEvaluator {
55232
55835
  detector;
55233
55836
  constructor(detector = new AgentDetector) {
@@ -55255,7 +55858,7 @@ var init_agent_detection_evaluator = __esm(() => {
55255
55858
  init_file_utils();
55256
55859
  });
55257
55860
 
55258
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/coverage-gate-evaluator.js
55861
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/coverage-gate-evaluator.js
55259
55862
  class CoverageGateEvaluator {
55260
55863
  constructor() {}
55261
55864
  async evaluate(rule, context4) {
@@ -55339,10 +55942,10 @@ var init_coverage_gate_evaluator = __esm(() => {
55339
55942
  init_file_utils();
55340
55943
  });
55341
55944
 
55342
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/exit-code-evaluator.js
55945
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/exit-code-evaluator.js
55343
55946
  class ExitCodeEvaluator {
55344
55947
  executor;
55345
- constructor(executor = new NodeProcessExecutor2) {
55948
+ constructor(executor = nodeBunFactory3.createProcessExecutor()) {
55346
55949
  this.executor = executor;
55347
55950
  }
55348
55951
  async evaluate(rule, context4) {
@@ -55375,7 +55978,7 @@ var init_exit_code_evaluator = __esm(() => {
55375
55978
  init_file_utils();
55376
55979
  });
55377
55980
 
55378
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/forbidden-import-evaluator.js
55981
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/forbidden-import-evaluator.js
55379
55982
  class ForbiddenImportEvaluator {
55380
55983
  constructor() {}
55381
55984
  async evaluate(rule, context4) {
@@ -55456,7 +56059,7 @@ var init_forbidden_import_evaluator = __esm(() => {
55456
56059
  init_file_utils();
55457
56060
  });
55458
56061
 
55459
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/import-boundary-evaluator.js
56062
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/import-boundary-evaluator.js
55460
56063
  class ImportBoundaryEvaluator {
55461
56064
  async evaluate(rule, context4) {
55462
56065
  const config4 = rule.evaluator.config ?? {};
@@ -55549,7 +56152,7 @@ var init_import_boundary_evaluator = __esm(() => {
55549
56152
  init_file_utils();
55550
56153
  });
55551
56154
 
55552
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/path-evaluator.js
56155
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/path-evaluator.js
55553
56156
  class PathEvaluator {
55554
56157
  constructor() {}
55555
56158
  async evaluate(rule, context4) {
@@ -55610,7 +56213,7 @@ var init_path_evaluator = __esm(() => {
55610
56213
  init_file_utils();
55611
56214
  });
55612
56215
 
55613
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/regex-evaluator.js
56216
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/regex-evaluator.js
55614
56217
  class RegexEvaluator {
55615
56218
  constructor() {}
55616
56219
  async evaluate(rule, context4) {
@@ -55688,10 +56291,10 @@ var init_regex_evaluator = __esm(() => {
55688
56291
  init_file_utils();
55689
56292
  });
55690
56293
 
55691
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/ripgrep-evaluator.js
56294
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/ripgrep-evaluator.js
55692
56295
  class RipgrepEvaluator {
55693
56296
  executor;
55694
- constructor(executor = new NodeProcessExecutor2) {
56297
+ constructor(executor = nodeBunFactory3.createProcessExecutor()) {
55695
56298
  this.executor = executor;
55696
56299
  }
55697
56300
  async evaluate(rule, context4) {
@@ -55781,7 +56384,7 @@ var init_ripgrep_evaluator = __esm(() => {
55781
56384
  init_file_utils();
55782
56385
  });
55783
56386
 
55784
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/schema-artifact-evaluator.js
56387
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/schema-artifact-evaluator.js
55785
56388
  class SchemaArtifactEvaluator {
55786
56389
  constructor() {}
55787
56390
  async evaluate(rule, context4) {
@@ -55859,7 +56462,7 @@ var init_schema_artifact_evaluator = __esm(() => {
55859
56462
  init_file_utils();
55860
56463
  });
55861
56464
 
55862
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/secrets-scanner-evaluator.js
56465
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/secrets-scanner-evaluator.js
55863
56466
  class SecretsScannerEvaluator {
55864
56467
  constructor() {}
55865
56468
  async evaluate(rule, context4) {
@@ -55927,10 +56530,10 @@ var init_secrets_scanner_evaluator = __esm(() => {
55927
56530
  ALL_CATEGORIES = Object.keys(BUILTIN_PATTERNS);
55928
56531
  });
55929
56532
 
55930
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/sg-evaluator.js
56533
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/sg-evaluator.js
55931
56534
  class SgEvaluator {
55932
56535
  executor;
55933
- constructor(executor = new NodeProcessExecutor2) {
56536
+ constructor(executor = nodeBunFactory3.createProcessExecutor()) {
55934
56537
  this.executor = executor;
55935
56538
  }
55936
56539
  async evaluate(rule, context4) {
@@ -56024,7 +56627,7 @@ var init_sg_evaluator = __esm(() => {
56024
56627
  init_file_utils();
56025
56628
  });
56026
56629
 
56027
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/resolvers/test-path-resolver.js
56630
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/resolvers/test-path-resolver.js
56028
56631
  class TypeScriptTestPathResolver {
56029
56632
  name = "typescript";
56030
56633
  constructor() {}
@@ -56107,7 +56710,7 @@ function testify(rel) {
56107
56710
  return `${dir}test_${base2}`;
56108
56711
  }
56109
56712
 
56110
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/test-location-evaluator.js
56713
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/test-location-evaluator.js
56111
56714
  class TestLocationEvaluator {
56112
56715
  resolvers;
56113
56716
  constructor(resolvers) {
@@ -56182,7 +56785,7 @@ var init_test_location_evaluator = __esm(() => {
56182
56785
  TYPESCRIPT_FALLBACK = new TypeScriptTestPathResolver;
56183
56786
  });
56184
56787
 
56185
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/tsdoc-export-evaluator.js
56788
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/tsdoc-export-evaluator.js
56186
56789
  class TsdocExportEvaluator {
56187
56790
  constructor() {}
56188
56791
  async evaluate(rule, context4) {
@@ -56267,7 +56870,7 @@ var init_tsdoc_export_evaluator = __esm(() => {
56267
56870
  };
56268
56871
  });
56269
56872
 
56270
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/formatters/json.js
56873
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/formatters/json.js
56271
56874
  class JsonFormatter {
56272
56875
  constructor() {}
56273
56876
  format(result) {
@@ -56275,7 +56878,7 @@ class JsonFormatter {
56275
56878
  }
56276
56879
  }
56277
56880
 
56278
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/formatters/text.js
56881
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/formatters/text.js
56279
56882
  class TextFormatter {
56280
56883
  constructor() {}
56281
56884
  format(result) {
@@ -56289,7 +56892,7 @@ class TextFormatter {
56289
56892
  }
56290
56893
  }
56291
56894
 
56292
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/host/builtins.js
56895
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/host/builtins.js
56293
56896
  function registerBuiltins(host, executor) {
56294
56897
  const path9 = new PathEvaluator;
56295
56898
  host.evaluators.register("regex", new RegexEvaluator, "builtin");
@@ -56329,7 +56932,7 @@ var init_builtins = __esm(() => {
56329
56932
  init_tsdoc_export_evaluator();
56330
56933
  });
56331
56934
 
56332
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/host/rule-engine-host.js
56935
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/host/rule-engine-host.js
56333
56936
  class RuleEngineHost {
56334
56937
  evaluators;
56335
56938
  formatters;
@@ -56346,7 +56949,7 @@ var init_rule_engine_host = __esm(() => {
56346
56949
  init_extension2();
56347
56950
  });
56348
56951
 
56349
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/engine.js
56952
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/engine.js
56350
56953
  class RuleEngine {
56351
56954
  host;
56352
56955
  events;
@@ -56359,7 +56962,7 @@ class RuleEngine {
56359
56962
  this.host = options.host ?? new RuleEngineHost;
56360
56963
  registerBuiltins(this.host, options.processExecutor);
56361
56964
  registerBuiltinFixers(this.host, options.processExecutor);
56362
- this.events = options.events;
56965
+ this.events = options.events ?? (options.lifecycleBus ? new EventBus({ lifecycleBus: options.lifecycleBus }) : undefined);
56363
56966
  this.logger = options.logger ?? getLogger2("rule-engine");
56364
56967
  this.persistence = options.persistence;
56365
56968
  this.runId = options.runId ?? crypto.randomUUID();
@@ -56517,7 +57120,7 @@ var init_engine = __esm(() => {
56517
57120
  init_types3();
56518
57121
  });
56519
57122
 
56520
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/host/bundled-rules.js
57123
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/host/bundled-rules.js
56521
57124
  async function bundledRulesRoot() {
56522
57125
  if (cachedRoot2 !== undefined)
56523
57126
  return cachedRoot2;
@@ -56568,7 +57171,7 @@ var init_bundled_rules = __esm(() => {
56568
57171
  init_dist5();
56569
57172
  });
56570
57173
 
56571
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/persistence/db-adapter.js
57174
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/persistence/db-adapter.js
56572
57175
  class DbRulePersistenceAdapter {
56573
57176
  db;
56574
57177
  constructor(db2) {
@@ -56602,7 +57205,7 @@ class DbRulePersistenceAdapter {
56602
57205
  }
56603
57206
  }
56604
57207
 
56605
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/persistence/schema.js
57208
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/persistence/schema.js
56606
57209
  var RULE_ENGINE_SCHEMA_SQL = `
56607
57210
  CREATE TABLE IF NOT EXISTS rule_runs (
56608
57211
  id TEXT PRIMARY KEY,
@@ -56648,10 +57251,10 @@ CREATE TABLE IF NOT EXISTS rule_eval_runs (
56648
57251
  CREATE INDEX IF NOT EXISTS idx_rule_eval_runs_run_id ON rule_eval_runs (run_id);
56649
57252
  `;
56650
57253
 
56651
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/persistence/index.js
57254
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/persistence/index.js
56652
57255
  var init_persistence2 = () => {};
56653
57256
 
56654
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.8+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/index.js
57257
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.4.10+eb8900f44f4776f9/node_modules/@gobing-ai/ts-rule-engine/dist/index.js
56655
57258
  var init_dist10 = __esm(() => {
56656
57259
  init_extensions();
56657
57260
  init_loader2();
@@ -56850,7 +57453,7 @@ ${SYSTEM_EVENTS_SCHEMA_SQL}
56850
57453
  ];
56851
57454
  });
56852
57455
 
56853
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/job-queue/db-job-queue.js
57456
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/job-queue/db-job-queue.js
56854
57457
  function queueLogger() {
56855
57458
  if (!_queueLogger)
56856
57459
  _queueLogger = getLogger2("job-queue");
@@ -57078,7 +57681,7 @@ var init_db_job_queue = __esm(() => {
57078
57681
  init_tracing2();
57079
57682
  });
57080
57683
 
57081
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/job-queue-db.js
57684
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/job-queue-db.js
57082
57685
  var exports_job_queue_db = {};
57083
57686
  __export(exports_job_queue_db, {
57084
57687
  DBQueueConsumer: () => DBQueueConsumer,
@@ -60515,7 +61118,7 @@ var init_rule_service = __esm(() => {
60515
61118
  function defaultWrapperArgv(agentId) {
60516
61119
  return {
60517
61120
  command: process.execPath,
60518
- args: [process.argv[1] ?? "apps/cli/src/index.ts", "agent", "run", "--agent", agentId, "--drain", "--continue"]
61121
+ args: [process.argv[1] ?? "apps/cli/src/index.ts", "agent", "loop", "--agent", agentId]
60519
61122
  };
60520
61123
  }
60521
61124
 
@@ -60528,6 +61131,8 @@ class SupervisorService {
60528
61131
  ringBuffers = new Map;
60529
61132
  specsPromise;
60530
61133
  frameSeq = 0;
61134
+ restartAttempts = new Map;
61135
+ restartTimers = new Map;
60531
61136
  constructor(options) {
60532
61137
  this.processExecutor = options.processExecutor;
60533
61138
  this.eventBus = options.eventBus;
@@ -60565,12 +61170,17 @@ class SupervisorService {
60565
61170
  throw new Error(`No agent spec found for "${agentId}"`);
60566
61171
  }
60567
61172
  const { command, args } = this.resolveCommand(spec);
61173
+ const teamTag = spec.tags.find((t) => t.startsWith("team:"));
61174
+ const teamId = teamTag ? teamTag.slice("team:".length) : null;
60568
61175
  const frames = [];
60569
61176
  this.ringBuffers.set(agentId, frames);
60570
61177
  const pipeOpts = {
60571
61178
  command,
60572
61179
  args,
60573
61180
  label: `agent:${agentId}`,
61181
+ source: "supervisor",
61182
+ agentId,
61183
+ ...teamId ? { teamId } : {},
60574
61184
  env: Object.fromEntries(Object.entries(process.env).filter(([, v]) => v !== undefined))
60575
61185
  };
60576
61186
  const handle = this.processExecutor.runStreaming(pipeOpts);
@@ -60580,22 +61190,47 @@ class SupervisorService {
60580
61190
  pid,
60581
61191
  status: "running",
60582
61192
  startedAt: new Date().toISOString(),
60583
- ringBuffer: frames
61193
+ ringBuffer: frames,
61194
+ teamId,
61195
+ agentType: spec.type
60584
61196
  };
60585
61197
  this.processes.set(agentId, { handle, entry });
61198
+ this.restartAttempts.delete(agentId);
60586
61199
  this.pipeStream(handle.stdout, "stdout", agentId, frames);
60587
61200
  this.pipeStream(handle.stderr, "stderr", agentId, frames);
60588
- this.emit("process.spawned", { agentId, pid });
60589
- handle.exited.then((code) => {
60590
- entry.status = "exited";
61201
+ this.emit("process.spawned", {
61202
+ agentId,
61203
+ pid,
61204
+ teamId,
61205
+ agentType: spec.type
61206
+ });
61207
+ handle.exited.then(async (code) => {
60591
61208
  entry.exitCode = code;
60592
- const keepForMs = 60000;
60593
- setTimeout(() => {
60594
- if (this.processes.get(agentId)?.entry === entry) {
60595
- this.processes.delete(agentId);
60596
- }
60597
- }, keepForMs);
60598
- this.emit("process.exited", { agentId, pid, exitCode: code });
61209
+ this.emit("process.exited", {
61210
+ agentId,
61211
+ pid,
61212
+ exitCode: code,
61213
+ teamId: entry.teamId ?? null,
61214
+ ...entry.agentType ? { agentType: entry.agentType } : {}
61215
+ });
61216
+ if (code === 0 || entry.status === "stopped") {
61217
+ entry.status = "exited";
61218
+ this.scheduleCleanup(agentId, entry);
61219
+ return;
61220
+ }
61221
+ const attempts = (this.restartAttempts.get(agentId) ?? 0) + 1;
61222
+ this.restartAttempts.set(agentId, attempts);
61223
+ if (attempts > MAX_RESTART_ATTEMPTS) {
61224
+ entry.status = "errored";
61225
+ this.scheduleCleanup(agentId, entry);
61226
+ return;
61227
+ }
61228
+ entry.status = "errored";
61229
+ const delay = attempts >= RESTART_BACKOFF_SCHEDULE.length ? MAX_RESTART_BACKOFF : RESTART_BACKOFF_SCHEDULE[attempts - 1] ?? 1000;
61230
+ this.restartTimers.set(agentId, setTimeout(() => {
61231
+ this.restartTimers.delete(agentId);
61232
+ this.start(agentId).catch(() => {});
61233
+ }, delay));
60599
61234
  });
60600
61235
  return entry;
60601
61236
  }
@@ -60618,7 +61253,18 @@ class SupervisorService {
60618
61253
  await proc.handle.exited.catch(() => {});
60619
61254
  }
60620
61255
  proc.entry.status = "stopped";
60621
- this.emit("process.stopped", { agentId, pid: proc.entry.pid });
61256
+ const timer = this.restartTimers.get(agentId);
61257
+ if (timer) {
61258
+ clearTimeout(timer);
61259
+ this.restartTimers.delete(agentId);
61260
+ }
61261
+ this.restartAttempts.delete(agentId);
61262
+ this.emit("process.stopped", {
61263
+ agentId,
61264
+ pid: proc.entry.pid,
61265
+ teamId: proc.entry.teamId ?? null,
61266
+ ...proc.entry.agentType ? { agentType: proc.entry.agentType } : {}
61267
+ });
60622
61268
  }
60623
61269
  async startAutostart(ids) {
60624
61270
  const results = [];
@@ -60638,12 +61284,22 @@ class SupervisorService {
60638
61284
  const running = Array.from(this.processes.keys()).filter((id) => this.processes.get(id)?.entry.status === "running");
60639
61285
  await Promise.all(running.map((id) => this.stop(id)));
60640
61286
  }
61287
+ scheduleCleanup(agentId, entry) {
61288
+ const keepForMs = 60000;
61289
+ setTimeout(() => {
61290
+ if (this.processes.get(agentId)?.entry === entry) {
61291
+ this.processes.delete(agentId);
61292
+ }
61293
+ }, keepForMs);
61294
+ }
60641
61295
  async loadSpecs() {
60642
61296
  this.specsPromise ??= Promise.resolve().then(() => (init_dist7(), exports_dist3)).then((m) => m.loadAgentSpecs(this.configDir));
60643
61297
  return this.specsPromise;
60644
61298
  }
60645
61299
  resolveCommand(spec) {
60646
- const raw = spec.command;
61300
+ const configCommand = Array.isArray(spec.config?.command) ? spec.config.command : undefined;
61301
+ const topLevel = spec.command;
61302
+ const raw = configCommand ?? topLevel;
60647
61303
  if (raw && raw.length > 0) {
60648
61304
  return { command: raw[0] ?? "", args: raw.slice(1) };
60649
61305
  }
@@ -60690,7 +61346,10 @@ class SupervisorService {
60690
61346
  } catch {}
60691
61347
  }
60692
61348
  }
60693
- var DEFAULT_RING_BUFFER_SIZE = 500;
61349
+ var DEFAULT_RING_BUFFER_SIZE = 500, MAX_RESTART_ATTEMPTS = 5, RESTART_BACKOFF_SCHEDULE, MAX_RESTART_BACKOFF = 30000;
61350
+ var init_supervisor_service = __esm(() => {
61351
+ RESTART_BACKOFF_SCHEDULE = [1000, 2000, 4000, 8000, 16000];
61352
+ });
60694
61353
 
60695
61354
  // ../../packages/app/src/services/system-event-tap.ts
60696
61355
  function registerSystemEventTap(bus, dao2, logger3, options = {}) {
@@ -60748,9 +61407,11 @@ function safeStringify(event2) {
60748
61407
  }
60749
61408
  function extractSystemEventActor(event2) {
60750
61409
  if (event2 && typeof event2 === "object") {
60751
- const candidate = event2.actor;
60752
- if (typeof candidate === "string")
60753
- return candidate;
61410
+ const obj = event2;
61411
+ if (typeof obj.actor === "string" && obj.actor.length > 0)
61412
+ return obj.actor;
61413
+ if (typeof obj.agentId === "string" && obj.agentId.length > 0)
61414
+ return obj.agentId;
60754
61415
  }
60755
61416
  return null;
60756
61417
  }
@@ -60821,6 +61482,10 @@ function hasPopulatedPriorityTable(body) {
60821
61482
  }
60822
61483
  return false;
60823
61484
  }
61485
+ function extractReviewSectionBody(markdown) {
61486
+ const match = markdown.match(/^### Review[ \t]*\n([\s\S]*?)(?=^### |Z)/m);
61487
+ return match ? match[1] ?? "" : null;
61488
+ }
60824
61489
  function isReviewScaffold(body) {
60825
61490
  if (isPlaceholderBody(body))
60826
61491
  return true;
@@ -62371,22 +63036,77 @@ class TeamService {
62371
63036
  count: rows.length
62372
63037
  };
62373
63038
  }
62374
- async listRecent(limit = 50) {
62375
- const dao2 = await this.inboxRecentDao();
62376
- const rows = await dao2.listRecent(limit);
63039
+ async drainPending(agentId) {
63040
+ validateAgentId(agentId);
63041
+ const dao2 = await this.inboxDao();
63042
+ const rows = await dao2.drainPending(agentId);
62377
63043
  return {
62378
63044
  messages: rows.map((row) => ({
62379
63045
  id: row.id,
62380
- fromId: row.from_id,
62381
- toId: row.to_id,
63046
+ fromId: row.fromId,
62382
63047
  body: row.body,
62383
63048
  status: row.status,
62384
- createdAt: new Date(row.created_at).toISOString(),
62385
- inReplyTo: row.in_reply_to
63049
+ createdAt: new Date(row.createdAt).toISOString(),
63050
+ inReplyTo: row.inReplyTo
62386
63051
  })),
62387
63052
  count: rows.length
62388
63053
  };
62389
63054
  }
63055
+ async countPending(agentId) {
63056
+ validateAgentId(agentId);
63057
+ const dao2 = await this.inboxDao();
63058
+ return dao2.countPending(agentId);
63059
+ }
63060
+ async listRecent(limit = 50) {
63061
+ const dao2 = await this.inboxRecentDao();
63062
+ const rows = await dao2.listRecent(limit);
63063
+ if (rows.length === 0) {
63064
+ return { messages: [], count: 0 };
63065
+ }
63066
+ const [teams, specs] = await Promise.all([this.listTeams(), this.listAgentSpecs()]);
63067
+ const identityById = new Map;
63068
+ for (const team of teams) {
63069
+ for (const spec of team.specs) {
63070
+ identityById.set(spec.id, {
63071
+ agentId: spec.id,
63072
+ teamId: team.teamId,
63073
+ teamName: team.name,
63074
+ memberLabel: spec.name,
63075
+ agentType: spec.type
63076
+ });
63077
+ }
63078
+ }
63079
+ for (const spec of specs) {
63080
+ if (!identityById.has(spec.id)) {
63081
+ identityById.set(spec.id, {
63082
+ agentId: spec.id,
63083
+ memberLabel: spec.name,
63084
+ agentType: spec.type
63085
+ });
63086
+ }
63087
+ }
63088
+ const replyCounts = await dao2.countReplies(rows.map((r) => r.id));
63089
+ const resolveEndpoint = (agentId) => identityById.get(agentId) ?? { agentId };
63090
+ return {
63091
+ messages: rows.map((row) => {
63092
+ const replyCount = replyCounts.get(row.id) ?? 0;
63093
+ return {
63094
+ id: row.id,
63095
+ fromId: row.from_id,
63096
+ toId: row.to_id,
63097
+ body: row.body,
63098
+ status: row.status,
63099
+ createdAt: new Date(row.created_at).toISOString(),
63100
+ inReplyTo: row.in_reply_to,
63101
+ ...row.from_id !== null ? { from: resolveEndpoint(row.from_id) } : {},
63102
+ to: resolveEndpoint(row.to_id),
63103
+ hasReply: replyCount > 0,
63104
+ replyCount
63105
+ };
63106
+ }),
63107
+ count: rows.length
63108
+ };
63109
+ }
62390
63110
  async replyToMessage(msgId, body) {
62391
63111
  const dao2 = await this.inboxDao();
62392
63112
  const original = await dao2.getById(msgId);
@@ -62471,6 +63191,131 @@ class TeamService {
62471
63191
  peers
62472
63192
  });
62473
63193
  }
63194
+ async listTeams() {
63195
+ const specs = await loadAgentSpecs(this.configDir);
63196
+ const config4 = await this.loadTeamConfig();
63197
+ const teams = new Map;
63198
+ if (config4?.agent?.team) {
63199
+ for (const [teamId, teamConfig] of Object.entries(config4.agent.team)) {
63200
+ teams.set(teamId, {
63201
+ teamId,
63202
+ name: teamConfig.name,
63203
+ members: [],
63204
+ specs: []
63205
+ });
63206
+ }
63207
+ }
63208
+ const untethered = [];
63209
+ for (const spec of specs) {
63210
+ const teamTag = spec.tags?.find((t) => t.startsWith("team:"));
63211
+ if (teamTag) {
63212
+ const teamId = teamTag.slice("team:".length);
63213
+ const entry = teams.get(teamId);
63214
+ if (entry) {
63215
+ entry.specs.push(spec);
63216
+ } else {
63217
+ teams.set(teamId, {
63218
+ teamId,
63219
+ name: teamId,
63220
+ members: [],
63221
+ specs: [spec]
63222
+ });
63223
+ }
63224
+ } else {
63225
+ untethered.push(spec);
63226
+ }
63227
+ }
63228
+ if (untethered.length > 0) {
63229
+ teams.set("__untethered__", {
63230
+ teamId: "__untethered__",
63231
+ name: "Untethered",
63232
+ members: [],
63233
+ specs: untethered
63234
+ });
63235
+ }
63236
+ return Array.from(teams.values());
63237
+ }
63238
+ async materializeTeam(teamId, opts) {
63239
+ const config4 = await this.loadTeamConfig();
63240
+ const teamConfig = config4?.agent?.team?.[teamId];
63241
+ if (!teamConfig) {
63242
+ throw new Error(`Team "${teamId}" not found in agent.team config`);
63243
+ }
63244
+ const agentConfig = config4?.agent;
63245
+ const specs = await loadAgentSpecs(this.configDir);
63246
+ const existingTeamSpecs = specs.filter((s) => s.tags?.includes(`team:${teamId}`) && s.tags?.includes("spur:generated"));
63247
+ const desiredMembers = teamConfig.members.map((m) => normalizeMember(m));
63248
+ const desiredIds = new Set;
63249
+ const toUpsert = [];
63250
+ for (const member of desiredMembers) {
63251
+ const localId = member.id ?? member.executor;
63252
+ const composedId = `${teamId}-${localId}`;
63253
+ desiredIds.add(composedId);
63254
+ const existing = specs.find((s) => s.id === composedId);
63255
+ if (existing && !existing.tags?.includes("spur:generated"))
63256
+ continue;
63257
+ const resolved = resolveExecutor(member.executor, agentConfig);
63258
+ const spec = {
63259
+ id: composedId,
63260
+ name: member.purpose ?? composedId,
63261
+ type: resolved.agent,
63262
+ workspace: member.workspace ?? teamConfig.work_dir,
63263
+ purpose: member.purpose && member.purpose.length > 0 ? member.purpose : `${resolved.agent} agent`,
63264
+ tags: [`team:${teamId}`, "spur:generated"],
63265
+ config: {
63266
+ ...resolved.model !== undefined ? { model: resolved.model } : {},
63267
+ ...member.systemPrompt !== undefined ? { systemPrompt: member.systemPrompt } : {},
63268
+ ...member.command !== undefined ? { command: member.command } : {},
63269
+ ...member.autonomy !== undefined ? { autonomy: member.autonomy } : {}
63270
+ },
63271
+ ...member.autostart !== undefined ? { autoStart: member.autostart } : {}
63272
+ };
63273
+ toUpsert.push(spec);
63274
+ }
63275
+ const orphaned = existingTeamSpecs.filter((s) => !desiredIds.has(s.id));
63276
+ if (opts?.check) {
63277
+ return {
63278
+ teamId,
63279
+ upserted: toUpsert.map((s) => s.id),
63280
+ orphaned: orphaned.map((s) => s.id),
63281
+ written: false
63282
+ };
63283
+ }
63284
+ for (const spec of toUpsert) {
63285
+ await saveAgentSpec(spec, this.configDir);
63286
+ }
63287
+ for (const spec of orphaned) {
63288
+ await deleteAgentSpec(spec.id, this.configDir);
63289
+ }
63290
+ return {
63291
+ teamId,
63292
+ upserted: toUpsert.map((s) => s.id),
63293
+ orphaned: orphaned.map((s) => s.id),
63294
+ written: true
63295
+ };
63296
+ }
63297
+ async teardownTeam(teamId, opts) {
63298
+ const specs = await loadAgentSpecs(this.configDir);
63299
+ const teamSpecs = specs.filter((s) => s.tags?.includes(`team:${teamId}`));
63300
+ const generated = teamSpecs.filter((s) => s.tags?.includes("spur:generated"));
63301
+ if (opts?.purge) {
63302
+ for (const spec of generated) {
63303
+ await deleteAgentSpec(spec.id, this.configDir);
63304
+ }
63305
+ }
63306
+ return {
63307
+ teamId,
63308
+ purged: opts?.purge ? generated.map((s) => s.id) : [],
63309
+ stopped: teamSpecs.map((s) => s.id)
63310
+ };
63311
+ }
63312
+ async loadTeamConfig() {
63313
+ try {
63314
+ return await loadSpurConfig(this.ctx.cwd);
63315
+ } catch {
63316
+ return null;
63317
+ }
63318
+ }
62474
63319
  async inboxDao() {
62475
63320
  const db2 = await this.ctx.getDb();
62476
63321
  return new InboxMessageDao(db2);
@@ -62511,7 +63356,31 @@ class TeamService {
62511
63356
  return null;
62512
63357
  }
62513
63358
  }
63359
+ function resolveAutostartSet(config4, envAutostart) {
63360
+ const ids = new Set;
63361
+ const teams = config4?.agent?.team;
63362
+ if (teams) {
63363
+ for (const [teamId, teamConfig] of Object.entries(teams)) {
63364
+ for (const member of teamConfig.members) {
63365
+ const ref = normalizeMember(member);
63366
+ const localId = ref.id ?? ref.executor;
63367
+ const composedId = `${teamId}-${localId}`;
63368
+ const effective = ref.autostart ?? teamConfig.autostart ?? false;
63369
+ if (effective)
63370
+ ids.add(composedId);
63371
+ }
63372
+ }
63373
+ }
63374
+ if (envAutostart) {
63375
+ for (const id of envAutostart.split(",").map((s) => s.trim()).filter(Boolean)) {
63376
+ ids.add(id);
63377
+ }
63378
+ }
63379
+ return Array.from(ids).sort();
63380
+ }
62514
63381
  var init_team_service = __esm(() => {
63382
+ init_src();
63383
+ init_loader();
62515
63384
  init_src2();
62516
63385
  init_dist7();
62517
63386
  init_planning_folders();
@@ -64014,6 +64883,8 @@ var init_workflow_service = __esm(() => {
64014
64883
  });
64015
64884
 
64016
64885
  // ../../packages/app/src/workflow/lifecycle-adapter.ts
64886
+ import { readFile as readFile3 } from "fs/promises";
64887
+
64017
64888
  class LifecycleAdapter {
64018
64889
  opts;
64019
64890
  workflowCache;
@@ -64049,6 +64920,15 @@ class LifecycleAdapter {
64049
64920
  };
64050
64921
  }
64051
64922
  }
64923
+ const reviewDenial = await this.checkReviewReadyForDone(ref);
64924
+ if (reviewDenial !== null) {
64925
+ return {
64926
+ allowed: false,
64927
+ from: currentStatus,
64928
+ to,
64929
+ report: reviewDenial
64930
+ };
64931
+ }
64052
64932
  }
64053
64933
  const existing = await svc.findRunByKey(profile.workflowName, externalKey);
64054
64934
  const runId = existing?.id ?? createId("run");
@@ -64099,6 +64979,27 @@ class LifecycleAdapter {
64099
64979
  vars: { ...workflow.vars, [this.opts.profile.varKey]: id, spurBin: this.opts.spurBin }
64100
64980
  };
64101
64981
  }
64982
+ async checkReviewReadyForDone(ref) {
64983
+ const markdown = await this.loadTaskMarkdown(ref);
64984
+ if (markdown === null) {
64985
+ return null;
64986
+ }
64987
+ const reviewBody = extractReviewSectionBody(markdown);
64988
+ if (reviewBody === null || !hasPopulatedPriorityTable(reviewBody)) {
64989
+ return `Review L3 gate failed for task ${ref.id}: ### Review must contain a populated ` + `P1\u2013P4 priority findings table before testing\u2192done (strict-core). ` + `Author the table via /sp:dev-review, then re-run the done transition.`;
64990
+ }
64991
+ return null;
64992
+ }
64993
+ async loadTaskMarkdown(ref) {
64994
+ if (this.opts.readTaskMarkdown) {
64995
+ return this.opts.readTaskMarkdown(ref);
64996
+ }
64997
+ try {
64998
+ return await readFile3(ref.filePath, "utf8");
64999
+ } catch {
65000
+ return null;
65001
+ }
65002
+ }
64102
65003
  formatDenial(detail, guardReport) {
64103
65004
  if (guardReport === undefined || guardReport === null)
64104
65005
  return detail;
@@ -64110,6 +65011,7 @@ var TASK_LIFECYCLE_PROFILE, FEATURE_LIFECYCLE_PROFILE;
64110
65011
  var init_lifecycle_adapter = __esm(() => {
64111
65012
  init_src2();
64112
65013
  init_dist8();
65014
+ init_task_check();
64113
65015
  TASK_LIFECYCLE_PROFILE = {
64114
65016
  linkKind: "lifecycle",
64115
65017
  workflowName: "task-lifecycle",
@@ -64158,6 +65060,7 @@ __export(exports_src2, {
64158
65060
  tailTokenLedgerFile: () => tailTokenLedgerFile,
64159
65061
  systemEventCatalogEntry: () => systemEventCatalogEntry,
64160
65062
  resolvePlanningFolders: () => resolvePlanningFolders,
65063
+ resolveAutostartSet: () => resolveAutostartSet,
64161
65064
  renderTesting: () => renderTesting,
64162
65065
  renderStepLine: () => renderStepLine,
64163
65066
  renderSolutionFromDiff: () => renderSolutionFromDiff,
@@ -64173,7 +65076,9 @@ __export(exports_src2, {
64173
65076
  normalizeSystemEventPayload: () => normalizeSystemEventPayload,
64174
65077
  hitlConfirmDefault: () => hitlConfirmDefault,
64175
65078
  hitlAutoApproveEnabled: () => hitlAutoApproveEnabled,
65079
+ hasPopulatedPriorityTable: () => hasPopulatedPriorityTable,
64176
65080
  extractSystemEventActor: () => extractSystemEventActor,
65081
+ extractReviewSectionBody: () => extractReviewSectionBody,
64177
65082
  deriveVerdict: () => deriveVerdict,
64178
65083
  createPsProcessInspector: () => createPsProcessInspector,
64179
65084
  clampToolUseLimit: () => clampToolUseLimit,
@@ -64242,6 +65147,7 @@ var init_src3 = __esm(() => {
64242
65147
  init_process_inspector();
64243
65148
  init_process_inventory_service();
64244
65149
  init_rule_service();
65150
+ init_supervisor_service();
64245
65151
  init_system_event_emitter();
64246
65152
  init_system_event_tap();
64247
65153
  init_task_check();
@@ -64338,18 +65244,19 @@ var {
64338
65244
  init_src();
64339
65245
  init_loader();
64340
65246
 
64341
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/application-node.js
65247
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/application-node.js
64342
65248
  init_dist4();
64343
65249
  init_dist5();
64344
65250
  import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync5 } from "fs";
64345
65251
  import { dirname as dirname5 } from "path";
64346
65252
 
64347
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/application/index.js
65253
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/application/index.js
64348
65254
  init_default_observers();
64349
65255
  init_event_bus();
65256
+ init_file_observer();
64350
65257
  init_logger3();
64351
65258
 
64352
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/scheduler/noop.js
65259
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/scheduler/noop.js
64353
65260
  class NoopSchedulerAdapter {
64354
65261
  constructor() {}
64355
65262
  register(_cron, _action) {}
@@ -64357,7 +65264,7 @@ class NoopSchedulerAdapter {
64357
65264
  async stop() {}
64358
65265
  }
64359
65266
 
64360
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/scheduler/factory.js
65267
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/scheduler/factory.js
64361
65268
  function initScheduler(adapter, cronEntries) {
64362
65269
  const resolved = adapter ?? new NoopSchedulerAdapter;
64363
65270
  if (cronEntries) {
@@ -64368,7 +65275,7 @@ function initScheduler(adapter, cronEntries) {
64368
65275
  return resolved;
64369
65276
  }
64370
65277
 
64371
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/application/plugins/builtins.js
65278
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/application/plugins/builtins.js
64372
65279
  init_logger3();
64373
65280
  init_metrics();
64374
65281
  init_sdk();
@@ -64461,7 +65368,7 @@ function dbPlugin(db2) {
64461
65368
  };
64462
65369
  }
64463
65370
 
64464
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/application/plugins/host.js
65371
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/application/plugins/host.js
64465
65372
  init_logger3();
64466
65373
 
64467
65374
  class PluginHost {
@@ -64549,7 +65456,7 @@ class PluginHost {
64549
65456
  }
64550
65457
  }
64551
65458
 
64552
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/application/index.js
65459
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/application/index.js
64553
65460
  async function performShutdown(state, reason) {
64554
65461
  if (state.stopped)
64555
65462
  return;
@@ -64584,6 +65491,9 @@ async function runApplication(options) {
64584
65491
  const eventsEnabled = options.config?.events?.enabled ?? true;
64585
65492
  const eventsLifecycle = options.config?.events?.lifecycle ?? true;
64586
65493
  const eventsDefaultObservers = options.config?.events?.defaultObservers ?? true;
65494
+ const eventsFileObserver = options.config?.events?.fileObserver ?? true;
65495
+ const fileObserverWriter = options.services?.fileObserverWriter;
65496
+ const eventsFilePath = options.config?.events?.filePath ?? (fileObserverWriter !== undefined ? "logs/system-events.jsonl" : undefined);
64587
65497
  const state = {
64588
65498
  app: undefined,
64589
65499
  stopped: false,
@@ -64596,6 +65506,13 @@ async function runApplication(options) {
64596
65506
  if (lifecycleBus && eventsDefaultObservers) {
64597
65507
  attachDefaultObservers(lifecycleBus);
64598
65508
  }
65509
+ let fileObserverAttached = false;
65510
+ let fileObserverPath;
65511
+ if (lifecycleBus && eventsFileObserver && eventsFilePath !== undefined && fileObserverWriter !== undefined) {
65512
+ attachFileObserver(lifecycleBus, eventsFilePath, fileObserverWriter);
65513
+ fileObserverAttached = true;
65514
+ fileObserverPath = eventsFilePath;
65515
+ }
64599
65516
  const events = options.services?.events ?? options.config?.events?.bus ?? new EventBus({ lifecycleBus });
64600
65517
  const db2 = options.services?.db;
64601
65518
  let scheduler3;
@@ -64609,7 +65526,13 @@ async function runApplication(options) {
64609
65526
  pluginHost.register(telemetryPlugin(telemetryConfig));
64610
65527
  const resolvedConfig2 = {
64611
65528
  logging: loggingConfig,
64612
- events: { enabled: eventsEnabled, lifecycle: eventsLifecycle, defaultObservers: eventsDefaultObservers },
65529
+ events: {
65530
+ enabled: eventsEnabled,
65531
+ lifecycle: eventsLifecycle,
65532
+ defaultObservers: eventsDefaultObservers,
65533
+ fileObserver: fileObserverAttached,
65534
+ ...fileObserverPath !== undefined ? { filePath: fileObserverPath } : {}
65535
+ },
64613
65536
  telemetry: telemetryConfig,
64614
65537
  scheduler: schedulerConfig
64615
65538
  };
@@ -64644,10 +65567,10 @@ async function runApplication(options) {
64644
65567
  }
64645
65568
  }
64646
65569
 
64647
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/application-node.js
65570
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/application-node.js
64648
65571
  init_scheduler_node();
64649
65572
 
64650
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/telemetry/otel-node.js
65573
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/telemetry/otel-node.js
64651
65574
  var import_api14 = __toESM(require_src(), 1);
64652
65575
 
64653
65576
  // ../../node_modules/.bun/@opentelemetry+exporter-metrics-otlp-http@0.218.0+e40b0dfdd726a224/node_modules/@opentelemetry/exporter-metrics-otlp-http/build/esm/OTLPMetricExporterBase.js
@@ -67663,7 +68586,7 @@ class OTLPTraceExporter extends import_otlp_exporter_base2.OTLPExporterBase {
67663
68586
  }), JsonTraceSerializer));
67664
68587
  }
67665
68588
  }
67666
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/telemetry/otel-node.js
68589
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/telemetry/otel-node.js
67667
68590
  var import_resources2 = __toESM(require_src4(), 1);
67668
68591
  var import_sdk_trace_node = __toESM(require_src8(), 1);
67669
68592
  var import_semantic_conventions = __toESM(require_src2(), 1);
@@ -67714,7 +68637,7 @@ async function shutdownNodeTelemetry() {
67714
68637
  await Promise.all(pending);
67715
68638
  }
67716
68639
 
67717
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.8+e2482bee662d08ad/node_modules/@gobing-ai/ts-infra/dist/application-node.js
68640
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.4.10+8e607bbe3266e5fa/node_modules/@gobing-ai/ts-infra/dist/application-node.js
67718
68641
  class ConfigValidationError extends Error {
67719
68642
  constructor(message) {
67720
68643
  super(message);
@@ -67794,10 +68717,12 @@ async function runNodeApplication(options) {
67794
68717
  const yamlLog = yamlBootstrap.logging;
67795
68718
  const yamlTel = yamlBootstrap.telemetry;
67796
68719
  const yamlSched = yamlBootstrap.scheduler;
68720
+ const yamlEvents = yamlBootstrap.events;
67797
68721
  const databaseOpts = yamlBootstrap.database ?? {};
67798
68722
  const loggingOpts = { ...yamlLog, ...options.config?.logging };
67799
68723
  const telemetryOpts = { ...yamlTel, ...options.config?.telemetry };
67800
68724
  const schedulerOpts = { ...yamlSched, ...options.config?.scheduler };
68725
+ const eventsOpts = { ...yamlEvents, ...options.config?.events };
67801
68726
  const logFilePath = yamlBootstrap.logging?.filePath;
67802
68727
  const loggingConfig = typeof logFilePath === "string" ? { ...loggingOpts, fileSink: createFileSink(logFilePath) } : loggingOpts;
67803
68728
  const schedulerConfig = {};
@@ -67842,10 +68767,31 @@ async function runNodeApplication(options) {
67842
68767
  throw new ConfigValidationError(`database.enabled is true but driver ${driver3 ? `"${driver3}"` : "is missing"} is not supported ` + `(expected "bun-sqlite"). Provide a supported driver or inject a DbAdapter via services.db.`);
67843
68768
  }
67844
68769
  }
68770
+ const injectedFileSystem = createNodeFileSystem3();
68771
+ const fileObserverWriter = options.services?.fileObserverWriter ?? {
68772
+ ensureDir: (dir) => {
68773
+ mkdirSync3(dir, { recursive: true });
68774
+ },
68775
+ appendFile: (path8, content) => {
68776
+ appendFileSync4(path8, content);
68777
+ }
68778
+ };
68779
+ const eventsFilePath = eventsOpts.filePath ?? injectedFileSystem.resolve("logs", "system-events.jsonl");
68780
+ const eventsConfig = {
68781
+ ...eventsOpts,
68782
+ filePath: eventsFilePath,
68783
+ ...eventsOpts.fileObserver === false ? {} : { fileObserver: true }
68784
+ };
67845
68785
  return await runApplication({
67846
- config: { ...options.config, logging: loggingConfig, telemetry: telemetryOpts, scheduler: schedulerConfig },
68786
+ config: {
68787
+ ...options.config,
68788
+ logging: loggingConfig,
68789
+ telemetry: telemetryOpts,
68790
+ scheduler: schedulerConfig,
68791
+ events: eventsConfig
68792
+ },
67847
68793
  appConfig: loadedAppConfig,
67848
- services: { ...options.services, ...dbAdapter ? { db: dbAdapter } : {} },
68794
+ services: { ...options.services, fileObserverWriter, ...dbAdapter ? { db: dbAdapter } : {} },
67849
68795
  start: options.start,
67850
68796
  stop: options.stop,
67851
68797
  plugins: plugins.length ? plugins : undefined
@@ -71516,6 +72462,20 @@ function registerAgentCommand(program2, context4) {
71516
72462
  const code = await runAgentRun(prompt, context4, flags);
71517
72463
  context4.setExitCode(code);
71518
72464
  });
72465
+ agent.command("loop").description("Run the persistent self-draining loop for a team member (used by the supervisor).").requiredOption("--agent <id>", "Agent spec id / message recipient").option("--poll <ms>", "Idle poll interval in milliseconds", String(DEFAULT_LOOP_POLL_MS)).action(async (options) => {
72466
+ const controller = new AbortController;
72467
+ const onSignal = () => controller.abort();
72468
+ process.on("SIGINT", onSignal);
72469
+ process.on("SIGTERM", onSignal);
72470
+ try {
72471
+ const flags = commanderOptionsToFlags(options);
72472
+ const code = await runAgentLoop(context4, flags, { signal: controller.signal });
72473
+ context4.setExitCode(code);
72474
+ } finally {
72475
+ process.off("SIGINT", onSignal);
72476
+ process.off("SIGTERM", onSignal);
72477
+ }
72478
+ });
71519
72479
  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) => {
71520
72480
  const flags = commanderOptionsToFlags(options);
71521
72481
  const code = await runAgentCreate(id, context4, flags);
@@ -71680,7 +72640,7 @@ async function drainIntoPrompt(prompt, context4, flags) {
71680
72640
  const team = new TeamService(context4);
71681
72641
  const spec = (await team.listAgentSpecs()).find((entry) => entry.id === recipient);
71682
72642
  const flagsOut = spec === undefined ? flags : { ...flags, agent: spec.type };
71683
- const inbox = await team.getInbox(recipient);
72643
+ const inbox = await team.drainPending(recipient);
71684
72644
  if (inbox.count === 0)
71685
72645
  return { prompt, flags: flagsOut };
71686
72646
  const header = inbox.messages.map((m) => `- ${m.fromId ?? "operator"}: ${m.body}`).join(`
@@ -71692,6 +72652,47 @@ ${header}`;
71692
72652
  ${prompt}`;
71693
72653
  return { prompt: merged, flags: flagsOut };
71694
72654
  }
72655
+ var DEFAULT_LOOP_POLL_MS = 2000;
72656
+ function parseLoopPoll(raw) {
72657
+ if (typeof raw !== "string")
72658
+ return DEFAULT_LOOP_POLL_MS;
72659
+ const n2 = Number.parseInt(raw, 10);
72660
+ return Number.isFinite(n2) && n2 > 0 ? n2 : DEFAULT_LOOP_POLL_MS;
72661
+ }
72662
+ function loopSleep(ms, signal) {
72663
+ return new Promise((resolve4) => {
72664
+ if (signal?.aborted) {
72665
+ resolve4();
72666
+ return;
72667
+ }
72668
+ const timer = setTimeout(resolve4, ms);
72669
+ signal?.addEventListener("abort", () => {
72670
+ clearTimeout(timer);
72671
+ resolve4();
72672
+ }, { once: true });
72673
+ });
72674
+ }
72675
+ async function runAgentLoop(context4, flags, runtime = {}, deps) {
72676
+ const recipient = typeof flags.agent === "string" ? flags.agent : "";
72677
+ if (recipient === "" || recipient === "auto") {
72678
+ context4.output.error("agent loop requires an explicit --agent <id>");
72679
+ return 2;
72680
+ }
72681
+ const pollMs = parseLoopPoll(flags.poll);
72682
+ const sleep2 = runtime.sleep ?? ((ms) => loopSleep(ms, runtime.signal));
72683
+ const svc = context4.agentService();
72684
+ let iteration = 0;
72685
+ while (!runtime.signal?.aborted && (runtime.maxIterations === undefined || iteration < runtime.maxIterations)) {
72686
+ const { prompt, flags: rewritten } = await drainIntoPrompt(undefined, context4, { ...flags, drain: true });
72687
+ if (prompt !== undefined) {
72688
+ await svc.run(prompt, rewritten, deps);
72689
+ } else {
72690
+ await sleep2(pollMs);
72691
+ }
72692
+ iteration++;
72693
+ }
72694
+ return 0;
72695
+ }
71695
72696
 
71696
72697
  // src/commands/feature.ts
71697
72698
  init_src3();
@@ -72121,7 +73122,7 @@ import { join as join15, resolve as resolve5 } from "path";
72121
73122
  var CLI_CONFIG = {
72122
73123
  binaryName: "spur",
72123
73124
  binaryLabel: "spur",
72124
- binaryVersion: "0.3.10",
73125
+ binaryVersion: "0.3.12",
72125
73126
  configDir: ".spur",
72126
73127
  configFile: ".spur/config.yaml",
72127
73128
  databaseFile: ".spur/spur.db"
@@ -78148,9 +79149,11 @@ init_event_names();
78148
79149
  // ../server/src/modules/events/index.ts
78149
79150
  function extractSystemEventActor2(event2) {
78150
79151
  if (event2 && typeof event2 === "object") {
78151
- const candidate = event2.actor;
78152
- if (typeof candidate === "string")
78153
- return candidate;
79152
+ const obj = event2;
79153
+ if (typeof obj.actor === "string" && obj.actor.length > 0)
79154
+ return obj.actor;
79155
+ if (typeof obj.agentId === "string" && obj.agentId.length > 0)
79156
+ return obj.agentId;
78154
79157
  }
78155
79158
  return null;
78156
79159
  }
@@ -78762,6 +79765,7 @@ var featureModule = {
78762
79765
  };
78763
79766
 
78764
79767
  // ../server/src/modules/health/index.ts
79768
+ import { basename as basename3 } from "path";
78765
79769
  var startedAt = Date.now();
78766
79770
  var healthModule = {
78767
79771
  name: "health",
@@ -78786,6 +79790,9 @@ var healthModule = {
78786
79790
  }
78787
79791
  return c3.json({ status: "error", db: "unreachable" }, 503);
78788
79792
  });
79793
+ app.get("/api/project", (c3) => {
79794
+ return c3.json({ name: ctx ? basename3(ctx.cwd) : null });
79795
+ });
78789
79796
  }
78790
79797
  };
78791
79798
 
@@ -79135,9 +80142,29 @@ var teamModule = {
79135
80142
  pid: p2.pid,
79136
80143
  status: p2.status,
79137
80144
  startedAt: p2.startedAt,
79138
- exitCode: p2.exitCode ?? null
80145
+ exitCode: p2.exitCode ?? null,
80146
+ teamId: p2.teamId ?? null
79139
80147
  }));
79140
- return c3.json({ processes, count: processes.length });
80148
+ const executions = ctx.processRegistry().listExecutions().map((e) => ({
80149
+ id: e.id,
80150
+ label: e.label ?? e.command,
80151
+ command: e.command,
80152
+ args: [...e.args],
80153
+ pid: e.pid ?? null,
80154
+ status: e.status,
80155
+ startedAt: e.startedAt,
80156
+ exitedAt: e.exitedAt ?? null,
80157
+ exitCode: e.exitCode ?? null,
80158
+ source: e.source,
80159
+ teamId: e.teamId ?? null,
80160
+ agentId: e.agentId ?? null
80161
+ }));
80162
+ return c3.json({
80163
+ processes,
80164
+ count: processes.length,
80165
+ executions,
80166
+ executionsCount: executions.length
80167
+ });
79141
80168
  });
79142
80169
  app.post("/api/team/agents/:id/start", async (c3) => {
79143
80170
  const id = c3.req.param("id");
@@ -79254,6 +80281,81 @@ var teamModule = {
79254
80281
  "Cache-Control": "no-cache"
79255
80282
  });
79256
80283
  });
80284
+ app.get("/api/team/teams", async (c3) => {
80285
+ if (!ctx.teamService)
80286
+ return c3.json({ error: "team API requires Bun server context" }, 503);
80287
+ const svc = ctx.teamService();
80288
+ const supervisor = ctx.supervisor();
80289
+ const teams = await svc.listTeams();
80290
+ const processes = supervisor.list();
80291
+ const enriched = teams.map((team) => ({
80292
+ teamId: team.teamId,
80293
+ name: team.name,
80294
+ members: team.specs.map((spec) => {
80295
+ const proc = processes.find((p2) => p2.agentId === spec.id);
80296
+ const configModel = spec.config?.model;
80297
+ return {
80298
+ id: spec.id,
80299
+ type: spec.type,
80300
+ status: proc?.status ?? "unknown",
80301
+ autoStart: spec.autoStart === true,
80302
+ ...typeof configModel === "string" && configModel.length > 0 ? { model: configModel } : {},
80303
+ ...proc?.pid !== undefined ? { pid: proc.pid } : {}
80304
+ };
80305
+ })
80306
+ }));
80307
+ return c3.json({ teams: enriched, count: enriched.length });
80308
+ });
80309
+ app.post("/api/team/:team/up", async (c3) => {
80310
+ if (!ctx.teamService)
80311
+ return c3.json({ error: "team API requires Bun server context" }, 503);
80312
+ const teamId = c3.req.param("team");
80313
+ const check2 = c3.req.query("check") === "true";
80314
+ const svc = ctx.teamService();
80315
+ const materialized = await svc.materializeTeam(teamId, { check: check2 });
80316
+ if (check2) {
80317
+ return c3.json({ materialized, started: [] });
80318
+ }
80319
+ const supervisor = ctx.supervisor();
80320
+ const autostartIds = new Set((await svc.listAgentSpecs()).filter((spec) => spec.autoStart === true).map((spec) => spec.id));
80321
+ const started = [];
80322
+ for (const id of materialized.upserted) {
80323
+ if (!autostartIds.has(id))
80324
+ continue;
80325
+ try {
80326
+ const entry = await supervisor.start(id);
80327
+ started.push({ id, ok: true, ...entry.pid !== null ? { pid: entry.pid } : {} });
80328
+ } catch {
80329
+ started.push({ id, ok: false });
80330
+ }
80331
+ }
80332
+ return c3.json({ materialized, started });
80333
+ });
80334
+ app.post("/api/team/:team/down", async (c3) => {
80335
+ if (!ctx.teamService)
80336
+ return c3.json({ error: "team API requires Bun server context" }, 503);
80337
+ const teamId = c3.req.param("team");
80338
+ const purge = c3.req.query("purge") === "true";
80339
+ const svc = ctx.teamService();
80340
+ const supervisor = ctx.supervisor();
80341
+ const teams = await svc.listTeams();
80342
+ const team = teams.find((t) => t.teamId === teamId);
80343
+ const stopped = [];
80344
+ if (team) {
80345
+ for (const spec of team.specs) {
80346
+ const proc = supervisor.get(spec.id);
80347
+ if (proc?.status === "running") {
80348
+ await supervisor.stop(spec.id);
80349
+ stopped.push(spec.id);
80350
+ }
80351
+ }
80352
+ }
80353
+ const result = await svc.teardownTeam(teamId, { purge });
80354
+ return c3.json({ stopped, purged: result.purged });
80355
+ });
80356
+ app.get("/api/team/health", (c3) => {
80357
+ return c3.json({ ok: true });
80358
+ });
79257
80359
  }
79258
80360
  };
79259
80361
 
@@ -81339,6 +82441,7 @@ function createServerContext(appRt, options) {
81339
82441
  let teamSvc;
81340
82442
  let supervisorSvc;
81341
82443
  let processInventorySvc;
82444
+ let processRegistrySvc;
81342
82445
  let tokenLedgerSvc;
81343
82446
  let agentSvc;
81344
82447
  let ruleSvc;
@@ -81409,9 +82512,13 @@ function createServerContext(appRt, options) {
81409
82512
  }
81410
82513
  return teamSvc;
81411
82514
  },
82515
+ processRegistry() {
82516
+ processRegistrySvc ??= createInMemoryProcessRegistry2();
82517
+ return processRegistrySvc;
82518
+ },
81412
82519
  supervisor() {
81413
82520
  if (!supervisorSvc) {
81414
- const pe = new ProcessExecutor3;
82521
+ const pe = new NodeProcessExecutor3({ registry: this.processRegistry() });
81415
82522
  supervisorSvc = new SupervisorService({
81416
82523
  processExecutor: pe,
81417
82524
  eventBus: bridgeEventBus(eventsBus),
@@ -81441,7 +82548,8 @@ function createServerContext(appRt, options) {
81441
82548
  cwd,
81442
82549
  env: options.env ?? {},
81443
82550
  output: NOOP_OUTPUT,
81444
- events: bridgeEventBus(eventsBus)
82551
+ events: bridgeEventBus(eventsBus),
82552
+ processRegistry: this.processRegistry()
81445
82553
  });
81446
82554
  return agentSvc;
81447
82555
  },
@@ -81661,11 +82769,13 @@ async function startServer(options, deps = defaultDeps) {
81661
82769
  bootConfig
81662
82770
  });
81663
82771
  let jobWorker;
81664
- if (bootConfig.teamAutostart.length > 0) {
82772
+ const autostartConfig = await loadSpurConfig(process.cwd()).catch(() => null);
82773
+ const autostartIds = resolveAutostartSet(autostartConfig, env.SPUR_TEAM_AUTOSTART);
82774
+ if (autostartIds.length > 0) {
81665
82775
  try {
81666
82776
  const supervisor = ctx.supervisor();
81667
- await supervisor.startAutostart(bootConfig.teamAutostart);
81668
- appRt.logger.info("Autostart agents spawned", { ids: bootConfig.teamAutostart });
82777
+ await supervisor.startAutostart(autostartIds);
82778
+ appRt.logger.info("Autostart agents spawned", { ids: autostartIds });
81669
82779
  } catch (error51) {
81670
82780
  appRt.logger.error("Autostart failed \u2014 server will continue but supervised agents are not running", {
81671
82781
  error: String(error51)
@@ -81818,7 +82928,7 @@ function errorMessage4(error51) {
81818
82928
  // src/git-context.ts
81819
82929
  init_dist5();
81820
82930
  async function gitContext(cwd) {
81821
- const executor = new NodeProcessExecutor2({ defaultTimeout: 5000, defaultMaxOutput: 128000 });
82931
+ const executor = new NodeProcessExecutor3({ defaultTimeout: 5000, defaultMaxOutput: 128000 });
81822
82932
  const root = await executor.run({
81823
82933
  command: "git",
81824
82934
  args: ["rev-parse", "--show-toplevel"],
@@ -82118,6 +83228,70 @@ var spur_config_schema_default = {
82118
83228
  additionalProperties: {
82119
83229
  type: "string"
82120
83230
  }
83231
+ },
83232
+ team: {
83233
+ type: "object",
83234
+ description: "Declarative agent teams keyed by team id (the map key is the teamId). Each team materializes a roster of agent specs (feature M). Mirrors @gobing-ai/spur-config TeamConfigSchema (Zod is SSOT).",
83235
+ additionalProperties: {
83236
+ type: "object",
83237
+ required: ["name", "work_dir", "members"],
83238
+ properties: {
83239
+ name: {
83240
+ type: "string",
83241
+ minLength: 1,
83242
+ description: "Human-readable team label."
83243
+ },
83244
+ work_dir: {
83245
+ type: "string",
83246
+ minLength: 1,
83247
+ description: "Default member workspace. A leading `~` is tilde-expanded at load."
83248
+ },
83249
+ autostart: {
83250
+ type: "boolean",
83251
+ description: "Team-wide autostart default; per-member autostart overrides (effective = member.autostart ?? team.autostart ?? false)."
83252
+ },
83253
+ members: {
83254
+ type: "array",
83255
+ minItems: 1,
83256
+ description: "Roster of member references (>= 1). A bare string is shorthand for { executor: <string> }; the composed agent id is <teamId>-<id ?? executor>.",
83257
+ items: {
83258
+ oneOf: [
83259
+ { type: "string", minLength: 1 },
83260
+ {
83261
+ type: "object",
83262
+ required: ["executor"],
83263
+ properties: {
83264
+ executor: {
83265
+ type: "string",
83266
+ minLength: 1,
83267
+ description: "Executor name \u2014 resolved against agent.executors first, else a raw canonical agent type."
83268
+ },
83269
+ id: {
83270
+ type: "string",
83271
+ minLength: 1,
83272
+ description: "Local member id; composed id is <teamId>-<id ?? executor> (must match ^[a-z][a-z0-9_-]{1,63}$)."
83273
+ },
83274
+ purpose: { type: "string" },
83275
+ workspace: {
83276
+ type: "string",
83277
+ minLength: 1,
83278
+ description: "Per-member workspace override. A leading `~` is tilde-expanded at load."
83279
+ },
83280
+ model: { type: "string", minLength: 1 },
83281
+ autonomy: { type: "string" },
83282
+ systemPrompt: { type: "string" },
83283
+ command: {
83284
+ type: "array",
83285
+ items: { type: "string", minLength: 1 }
83286
+ },
83287
+ autostart: { type: "boolean" }
83288
+ }
83289
+ }
83290
+ ]
83291
+ }
83292
+ }
83293
+ }
83294
+ }
82121
83295
  }
82122
83296
  }
82123
83297
  },
@@ -82757,6 +83931,46 @@ ${result.wbs} (${result.status}): ${result.pass ? "PASS" : "FAIL"}`);
82757
83931
  context4.setExitCode(1);
82758
83932
  }
82759
83933
  });
83934
+ task.command("run-link").summary("Record a pipeline provenance link for a task (used by --next auto chains to satisfy testing\u2192done guard).").argument("<wbs>", "Task WBS number").option("--source <source>", "Link source identifier (e.g. next-auto)", "chain").option("--run-id <id>", "Explicit run_id (auto-generated when omitted)").option("--json", "Output machine-readable JSON").action(async (wbs, options) => {
83935
+ try {
83936
+ const db2 = await context4.getDb();
83937
+ const dao2 = new TaskRunLinkDao(db2);
83938
+ const existing = await dao2.listByWbs(wbs, 20);
83939
+ if (existing.some((row) => row.kind === "pipeline")) {
83940
+ const entry = existing.find((row) => row.kind === "pipeline");
83941
+ if (!entry) {
83942
+ context4.output.error(`Pipeline link lookup inconsistent for ${wbs}`);
83943
+ context4.setExitCode(1);
83944
+ return;
83945
+ }
83946
+ const result2 = {
83947
+ id: entry.id,
83948
+ wbs: entry.wbs,
83949
+ runId: entry.run_id,
83950
+ kind: entry.kind,
83951
+ existed: true
83952
+ };
83953
+ if (options.json) {
83954
+ context4.output.write(toJson2(result2));
83955
+ } else {
83956
+ context4.output.write(`Pipeline run-link already exists for ${wbs} (${entry.id}). Skipped.`);
83957
+ }
83958
+ return;
83959
+ }
83960
+ const id = createId("trl");
83961
+ const runId = options.runId ?? `chain:${options.source}:${wbs}:${Date.now()}`;
83962
+ await dao2.insert({ id, wbs, run_id: runId, kind: "pipeline", created_at: new Date().toISOString() });
83963
+ const result = { id, wbs, runId, kind: "pipeline" };
83964
+ if (options.json) {
83965
+ context4.output.write(toJson2(result));
83966
+ } else {
83967
+ context4.output.write(`Recorded pipeline run-link ${id} for task ${wbs} (source: ${options.source})`);
83968
+ }
83969
+ } catch (err) {
83970
+ context4.output.error(String(err));
83971
+ context4.setExitCode(1);
83972
+ }
83973
+ });
82760
83974
  }
82761
83975
  async function makeService2(context4, folderOverride, noLifecycle = false) {
82762
83976
  const foldersConfig = (await resolvePlanningFolders(context4.fs)).foldersConfig;
@@ -82893,8 +84107,16 @@ function registerTeamCommand(program2, context4) {
82893
84107
  const code = await runTeamAssign(taskId, agentId, context4);
82894
84108
  context4.setExitCode(code);
82895
84109
  });
82896
- noun.command("status").description("List agent specs and their run status.").option("--json", "Output machine-readable JSON").action(async (options) => {
82897
- const code = await runTeamStatus(options, context4);
84110
+ noun.command("status").description("List agent specs and their run status; --by-team groups by team (0258 R4).").option("--json", "Output machine-readable JSON").option("--by-team", "Group specs by their agent.team.<id> membership").option("--server <url>", "Server API URL for live run status", DEFAULT_SERVER).action(async (options) => {
84111
+ const code = options.byTeam ? await runTeamStatusGrouped(options, context4) : await runTeamStatus(options, context4);
84112
+ context4.setExitCode(code);
84113
+ });
84114
+ noun.command("up").description("Materialize a team roster into agent specs; best-effort start when spur serve is reachable.").argument("<team>", "Team id (agent.team.<team>)").option("--check", "Dry-run: show the add/prune diff without writing").option("--server <url>", "Server API URL", DEFAULT_SERVER).option("--json", "Output machine-readable JSON").action(async (team, options) => {
84115
+ const code = await runTeamUp(team, options, context4);
84116
+ context4.setExitCode(code);
84117
+ });
84118
+ noun.command("down").description("Tear down a team: stop members; --purge also removes generated specs.").argument("<team>", "Team id").option("--purge", "Also delete spur:generated specs (never manual / ref:)").option("--server <url>", "Server API URL", DEFAULT_SERVER).option("--json", "Output machine-readable JSON").action(async (team, options) => {
84119
+ const code = await runTeamDown(team, options, context4);
82898
84120
  context4.setExitCode(code);
82899
84121
  });
82900
84122
  noun.command("start").description("Start a supervised agent process (requires spur serve).").argument("<agent-id>", "Agent spec id").option("--server <url>", "Server API URL", DEFAULT_SERVER).option("--json", "Output machine-readable JSON").action(async (agentId, options) => {
@@ -82916,18 +84138,59 @@ async function runTeamStatus(options, context4) {
82916
84138
  const svc = new TeamService(context4);
82917
84139
  const json3 = options.json === true;
82918
84140
  const status = await svc.getStatus();
82919
- if (json3) {
82920
- context4.output.write(toJson2(status));
82921
- return 0;
82922
- }
82923
84141
  if (status.agents.length === 0) {
82924
84142
  context4.output.write("No agent specs found in .spur/agents/");
82925
84143
  return 0;
82926
84144
  }
84145
+ const live = await fetchServerProcesses(options.server);
84146
+ if (live === null) {
84147
+ context4.output.error(`Cannot reach server at ${options.server} \u2014 showing local specs as stopped. Is spur serve running?`);
84148
+ } else {
84149
+ for (const agent of status.agents) {
84150
+ const proc = live.get(agent.id);
84151
+ if (proc) {
84152
+ agent.status = proc.status;
84153
+ agent.pid = proc.pid ?? undefined;
84154
+ }
84155
+ }
84156
+ }
84157
+ if (json3) {
84158
+ context4.output.write(toJson2(status));
84159
+ return 0;
84160
+ }
82927
84161
  context4.output.write(status.agents.map(formatStatusLine).join(`
82928
84162
  `));
82929
84163
  return 0;
82930
84164
  }
84165
+ function mapServerStatus(status) {
84166
+ switch (status) {
84167
+ case "running":
84168
+ return "running";
84169
+ case "errored":
84170
+ return "errored";
84171
+ case "stopped":
84172
+ case "exited":
84173
+ return "stopped";
84174
+ default:
84175
+ return "unknown";
84176
+ }
84177
+ }
84178
+ async function fetchServerProcesses(server) {
84179
+ try {
84180
+ const url2 = `${server}/team/processes`;
84181
+ const res = await teamFetch(url2, { method: "GET" });
84182
+ if (!res.ok)
84183
+ return null;
84184
+ const body = await res.json();
84185
+ const map3 = new Map;
84186
+ for (const proc of body.processes ?? []) {
84187
+ map3.set(proc.agentId, { status: mapServerStatus(proc.status), pid: proc.pid ?? null });
84188
+ }
84189
+ return map3;
84190
+ } catch {
84191
+ return null;
84192
+ }
84193
+ }
82931
84194
  async function performTeamStart(agentId, options) {
82932
84195
  try {
82933
84196
  const url2 = `${options.server}/team/agents/${encodeURIComponent(agentId)}/start`;
@@ -82992,6 +84255,76 @@ function formatStatusLine(agent) {
82992
84255
  const pid = agent.pid === undefined ? "" : ` pid=${agent.pid}`;
82993
84256
  return `${agent.status} ${agent.id} ${agent.type} ${agent.purpose}${pid}`;
82994
84257
  }
84258
+ async function runTeamStatusGrouped(options, context4) {
84259
+ const teams = await new TeamService(context4).listTeams();
84260
+ if (options.json === true) {
84261
+ context4.output.write(toJson2({ teams }));
84262
+ return 0;
84263
+ }
84264
+ if (teams.length === 0) {
84265
+ context4.output.write("No teams or agent specs found");
84266
+ return 0;
84267
+ }
84268
+ context4.output.write(teams.map(formatTeamBlock).join(`
84269
+ `));
84270
+ return 0;
84271
+ }
84272
+ function formatTeamBlock(team) {
84273
+ const header = team.name && team.name !== team.teamId ? `# ${team.teamId} (${team.name})` : `# ${team.teamId}`;
84274
+ const rows = team.specs.map((spec) => ` ${spec.id} ${spec.type} ${spec.purpose}`);
84275
+ return [header, ...rows].join(`
84276
+ `);
84277
+ }
84278
+ async function runTeamUp(team, options, context4) {
84279
+ const svc = new TeamService(context4);
84280
+ let result;
84281
+ try {
84282
+ result = await svc.materializeTeam(team, { check: options.check === true });
84283
+ } catch (error51) {
84284
+ context4.output.error(error51 instanceof Error ? error51.message : String(error51));
84285
+ return 1;
84286
+ }
84287
+ const started = [];
84288
+ if (options.check !== true && result.upserted.length > 0) {
84289
+ const specs = await svc.listAgentSpecs();
84290
+ const autostart = specs.filter((spec) => spec.autoStart === true && result.upserted.includes(spec.id));
84291
+ for (const spec of autostart) {
84292
+ const res = await performTeamStart(spec.id, { server: options.server });
84293
+ if ("ok" in res && res.ok === true)
84294
+ started.push(spec.id);
84295
+ }
84296
+ }
84297
+ if (options.json === true) {
84298
+ context4.output.write(toJson2({ ...result, started }));
84299
+ } else {
84300
+ const verb = options.check === true ? "would materialize" : "materialized";
84301
+ const startNote = started.length > 0 ? `, started ${started.length}` : "";
84302
+ context4.output.write(`team ${team}: ${verb} ${result.upserted.length} member(s), prune ${result.orphaned.length}${startNote}`);
84303
+ }
84304
+ return 0;
84305
+ }
84306
+ async function runTeamDown(team, options, context4) {
84307
+ const svc = new TeamService(context4);
84308
+ let result;
84309
+ try {
84310
+ result = await svc.teardownTeam(team, { purge: options.purge === true });
84311
+ } catch (error51) {
84312
+ context4.output.error(error51 instanceof Error ? error51.message : String(error51));
84313
+ return 1;
84314
+ }
84315
+ const stopped = [];
84316
+ for (const id of result.stopped) {
84317
+ const res = await performTeamStop(id, { server: options.server });
84318
+ if ("ok" in res && res.ok === true)
84319
+ stopped.push(id);
84320
+ }
84321
+ if (options.json === true) {
84322
+ context4.output.write(toJson2({ ...result, stopped }));
84323
+ } else {
84324
+ context4.output.write(`team ${team}: stopped ${stopped.length}, purged ${result.purged.length}`);
84325
+ }
84326
+ return 0;
84327
+ }
82995
84328
 
82996
84329
  // src/commands/workflow.ts
82997
84330
  init_src3();