@gobing-ai/spur 0.2.3 → 0.2.5

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 (27) hide show
  1. package/package.json +15 -10
  2. package/schemas/preset.schema.json +54 -0
  3. package/schemas/rule-file.schema.json +49 -0
  4. package/schemas/state-machine-workflow.schema.json +79 -0
  5. package/schemas/transition-flow-workflow.schema.json +78 -0
  6. package/spur-cli/config/rules/boundary/dao-boundary.yaml +1 -0
  7. package/spur-cli/config/rules/migration/rg-dialect.yaml +1 -0
  8. package/spur-cli/config/rules/quality/coverage-gate.yaml +1 -0
  9. package/spur-cli/config/rules/quality/tsdoc-exports.yaml +1 -0
  10. package/spur-cli/config/rules/recommended-post-check.yaml +1 -0
  11. package/spur-cli/config/rules/recommended-pre-check.yaml +1 -0
  12. package/spur-cli/config/rules/rg-migration.yaml +1 -0
  13. package/spur-cli/config/rules/strict/http-boundaries.yaml +1 -0
  14. package/spur-cli/config/rules/strict/rule-files-structural.yaml +1 -0
  15. package/spur-cli/config/rules/strict/runtime-boundaries.yaml +1 -0
  16. package/spur-cli/config/rules/strict-check.yaml +1 -0
  17. package/spur-cli/config/rules/structure/protected-files.yaml +1 -0
  18. package/spur-cli/config/rules/structure/test-focus-skip.yaml +1 -0
  19. package/spur-cli/config/rules/structure/test-location.yaml +1 -0
  20. package/spur-cli/config/rules/surface/check-cli-surface.yaml +1 -0
  21. package/spur-cli/config/rules/typescript/bun-tooling.yaml +1 -0
  22. package/spur-cli/config/rules/typescript/no-biome-suppressions.yaml +1 -0
  23. package/spur-cli/config/rules/typescript/no-debugger.yaml +1 -0
  24. package/spur-cli/config/rules/typescript/output-boundaries.yaml +1 -0
  25. package/spur-cli/config/workflows/basic.yaml +1 -0
  26. package/spur-cli/config/workflows/feature-dev.yaml +117 -0
  27. package/spur.js +2281 -169
package/spur.js CHANGED
@@ -2157,7 +2157,7 @@ var require_extra_typings = __commonJS((exports, module) => {
2157
2157
  exports.createArgument = (name, description) => new commander.Argument(name, description);
2158
2158
  });
2159
2159
 
2160
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.3.7/node_modules/@gobing-ai/ts-utils/dist/errors.js
2160
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.3.11/node_modules/@gobing-ai/ts-utils/dist/errors.js
2161
2161
  var ErrorCode;
2162
2162
  var init_errors = __esm(() => {
2163
2163
  ErrorCode = {
@@ -2168,7 +2168,7 @@ var init_errors = __esm(() => {
2168
2168
  };
2169
2169
  });
2170
2170
 
2171
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.3.7/node_modules/@gobing-ai/ts-utils/dist/api-response.js
2171
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.3.11/node_modules/@gobing-ai/ts-utils/dist/api-response.js
2172
2172
  var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
2173
2173
  var init_api_response = __esm(() => {
2174
2174
  init_errors();
@@ -2191,10 +2191,10 @@ var init_api_response = __esm(() => {
2191
2191
  CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
2192
2192
  });
2193
2193
 
2194
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.3.7/node_modules/@gobing-ai/ts-utils/dist/cursor.js
2194
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.3.11/node_modules/@gobing-ai/ts-utils/dist/cursor.js
2195
2195
  var init_cursor = () => {};
2196
2196
 
2197
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.3.7/node_modules/@gobing-ai/ts-utils/dist/object.js
2197
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.3.11/node_modules/@gobing-ai/ts-utils/dist/object.js
2198
2198
  function isPlainObject(value) {
2199
2199
  return typeof value === "object" && value !== null && !Array.isArray(value);
2200
2200
  }
@@ -2210,7 +2210,7 @@ function deepMerge(target, source) {
2210
2210
  return result;
2211
2211
  }
2212
2212
 
2213
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.3.7/node_modules/@gobing-ai/ts-utils/dist/output.js
2213
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.3.11/node_modules/@gobing-ai/ts-utils/dist/output.js
2214
2214
  function processStream(name) {
2215
2215
  const proc = globalThis.process;
2216
2216
  const stream = proc?.[name];
@@ -2231,7 +2231,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
2231
2231
  }
2232
2232
  var defaultStdoutTarget, defaultStderrTarget;
2233
2233
 
2234
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.3.7/node_modules/@gobing-ai/ts-utils/dist/index.js
2234
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.3.11/node_modules/@gobing-ai/ts-utils/dist/index.js
2235
2235
  var init_dist = __esm(() => {
2236
2236
  init_api_response();
2237
2237
  init_cursor();
@@ -23853,7 +23853,7 @@ var init_zod = __esm(() => {
23853
23853
  init_external();
23854
23854
  });
23855
23855
 
23856
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.7/node_modules/@gobing-ai/ts-runtime/dist/config.js
23856
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.11/node_modules/@gobing-ai/ts-runtime/dist/config.js
23857
23857
  function parseYamlObject(text) {
23858
23858
  let parsed;
23859
23859
  try {
@@ -23956,7 +23956,7 @@ var init_config = __esm(() => {
23956
23956
  };
23957
23957
  });
23958
23958
 
23959
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.7/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
23959
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.11/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
23960
23960
  import { appendFileSync, cpSync, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "fs";
23961
23961
  import { dirname, resolve as resolvePath } from "path";
23962
23962
  function createNodeFileSystem(root) {
@@ -31205,7 +31205,7 @@ var init_execa = __esm(() => {
31205
31205
  } = getIpcExport());
31206
31206
  });
31207
31207
 
31208
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.7/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
31208
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.11/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
31209
31209
  import { isatty } from "tty";
31210
31210
 
31211
31211
  class ProcessExecutor {
@@ -31446,7 +31446,7 @@ var init_process_executor = __esm(() => {
31446
31446
  };
31447
31447
  });
31448
31448
 
31449
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.7/node_modules/@gobing-ai/ts-runtime/dist/context.js
31449
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.11/node_modules/@gobing-ai/ts-runtime/dist/context.js
31450
31450
  class RuntimeContext {
31451
31451
  scope;
31452
31452
  runtimeName;
@@ -31515,7 +31515,7 @@ var init_context = __esm(() => {
31515
31515
  init_process_executor();
31516
31516
  });
31517
31517
 
31518
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.7/node_modules/@gobing-ai/ts-runtime/dist/path.js
31518
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.11/node_modules/@gobing-ai/ts-runtime/dist/path.js
31519
31519
  function normalizeSeparators(path6) {
31520
31520
  return path6.replaceAll("\\", "/");
31521
31521
  }
@@ -31623,7 +31623,7 @@ var init_path = __esm(() => {
31623
31623
  SEP = globalThis.process?.platform === "win32" ? "\\" : "/";
31624
31624
  });
31625
31625
 
31626
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.7/node_modules/@gobing-ai/ts-runtime/dist/fs.js
31626
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.11/node_modules/@gobing-ai/ts-runtime/dist/fs.js
31627
31627
  import { mkdirSync as mkdirSync2, readdirSync as readdirSync2, readFileSync as readFileSync4, rmSync as rmSync2, statSync as statSync3, writeFileSync as writeFileSync3 } from "fs";
31628
31628
  function nodeFsPromises() {
31629
31629
  fsPromisesModule ??= import("fs/promises");
@@ -31805,7 +31805,7 @@ var init_fs = __esm(() => {
31805
31805
  activeFileSystem = new NodeFileSystem;
31806
31806
  });
31807
31807
 
31808
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.7/node_modules/@gobing-ai/ts-runtime/dist/schema-validation.js
31808
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.11/node_modules/@gobing-ai/ts-runtime/dist/schema-validation.js
31809
31809
  async function loadStructuredConfig(path6, options = {}) {
31810
31810
  const content = await (options.fileSystem ?? getFs()).readFile(path6);
31811
31811
  return await parseStructuredConfig(content, path6, options);
@@ -32085,10 +32085,10 @@ var init_schema_validation = __esm(() => {
32085
32085
  defaultResolve = typeof Bun !== "undefined" ? (specifier, from) => Bun.resolveSync(specifier, from) : undefined;
32086
32086
  });
32087
32087
 
32088
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.7/node_modules/@gobing-ai/ts-runtime/dist/types.js
32088
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.11/node_modules/@gobing-ai/ts-runtime/dist/types.js
32089
32089
  var init_types = () => {};
32090
32090
 
32091
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.7/node_modules/@gobing-ai/ts-runtime/dist/index.js
32091
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.11/node_modules/@gobing-ai/ts-runtime/dist/index.js
32092
32092
  var init_dist3 = __esm(() => {
32093
32093
  init_file_system_node();
32094
32094
  init_fs();
@@ -32101,7 +32101,7 @@ var init_dist3 = __esm(() => {
32101
32101
  init_types();
32102
32102
  });
32103
32103
 
32104
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.7/node_modules/@gobing-ai/ts-runtime/dist/bun-sqlite.js
32104
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.11/node_modules/@gobing-ai/ts-runtime/dist/bun-sqlite.js
32105
32105
  import { Database } from "bun:sqlite";
32106
32106
  var init_bun_sqlite = () => {};
32107
32107
 
@@ -36327,7 +36327,7 @@ var init_bun_sqlite2 = __esm(() => {
36327
36327
  init_session2();
36328
36328
  });
36329
36329
 
36330
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.7+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/inbox-messages.js
36330
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.11+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/inbox-messages.js
36331
36331
  var inboxMessages;
36332
36332
  var init_inbox_messages = __esm(() => {
36333
36333
  init_sqlite_core();
@@ -36346,7 +36346,7 @@ var init_inbox_messages = __esm(() => {
36346
36346
  }, (table2) => [index("idx_inbox_messages_to_status").on(table2.toId, table2.status)]);
36347
36347
  });
36348
36348
 
36349
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.7+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/common.js
36349
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.11+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/common.js
36350
36350
  function nowTimestamp() {
36351
36351
  return Date.now();
36352
36352
  }
@@ -36375,7 +36375,7 @@ var init_common3 = __esm(() => {
36375
36375
  appendOnlyColumns = buildAppendOnlyColumns();
36376
36376
  });
36377
36377
 
36378
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.7+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/queue-jobs.js
36378
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.11+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/queue-jobs.js
36379
36379
  var queueJobs;
36380
36380
  var init_queue_jobs = __esm(() => {
36381
36381
  init_sqlite_core();
@@ -36395,7 +36395,7 @@ var init_queue_jobs = __esm(() => {
36395
36395
  }, (table2) => [index("queue_jobs_ready_idx").on(table2.status, table2.nextRetryAt, table2.createdAt)]);
36396
36396
  });
36397
36397
 
36398
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.7+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/runtime.js
36398
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.11+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/runtime.js
36399
36399
  var exports_runtime = {};
36400
36400
  __export(exports_runtime, {
36401
36401
  queueJobs: () => queueJobs,
@@ -36406,7 +36406,7 @@ var init_runtime = __esm(() => {
36406
36406
  init_queue_jobs();
36407
36407
  });
36408
36408
 
36409
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.7+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/adapters/bun-sqlite.js
36409
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.11+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/adapters/bun-sqlite.js
36410
36410
  var exports_bun_sqlite = {};
36411
36411
  __export(exports_bun_sqlite, {
36412
36412
  BunSqliteAdapter: () => BunSqliteAdapter
@@ -36685,7 +36685,7 @@ var init_d1 = __esm(() => {
36685
36685
  init_session3();
36686
36686
  });
36687
36687
 
36688
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.7+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/adapters/d1.js
36688
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.11+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/adapters/d1.js
36689
36689
  var exports_d1 = {};
36690
36690
  __export(exports_d1, {
36691
36691
  D1Adapter: () => D1Adapter
@@ -43905,8 +43905,8 @@ var require_Tracer = __commonJS((exports) => {
43905
43905
  const parentSpan = api6.trace.getSpan(context3);
43906
43906
  if ((0, core_1.isTracingSuppressed)(context3)) {
43907
43907
  api6.diag.debug("Instrumentation suppressed, returning Noop Span");
43908
- const nonRecordingSpan = api6.trace.wrapSpanContext(api6.INVALID_SPAN_CONTEXT);
43909
- return nonRecordingSpan;
43908
+ const nonRecordingSpan2 = api6.trace.wrapSpanContext(api6.INVALID_SPAN_CONTEXT);
43909
+ return nonRecordingSpan2;
43910
43910
  }
43911
43911
  const parentSpanContext = parentSpan?.spanContext();
43912
43912
  const spanId = this._idGenerator.generateSpanId();
@@ -43935,8 +43935,8 @@ var require_Tracer = __commonJS((exports) => {
43935
43935
  const spanContext = { traceId, spanId, traceFlags, traceState };
43936
43936
  if (samplingResult.decision === api6.SamplingDecision.NOT_RECORD) {
43937
43937
  api6.diag.debug("Recording is off, propagating context in a non-recording span");
43938
- const nonRecordingSpan = api6.trace.wrapSpanContext(spanContext);
43939
- return nonRecordingSpan;
43938
+ const nonRecordingSpan2 = api6.trace.wrapSpanContext(spanContext);
43939
+ return nonRecordingSpan2;
43940
43940
  }
43941
43941
  const initAttributes = (0, core_1.sanitizeAttributes)(Object.assign(attributes, samplingResult.attributes));
43942
43942
  const span = new Span_1.SpanImpl({
@@ -44432,6 +44432,64 @@ var require_src8 = __commonJS((exports) => {
44432
44432
  } });
44433
44433
  });
44434
44434
 
44435
+ // ../../node_modules/.bun/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
44436
+ var require_src9 = __commonJS((exports, module) => {
44437
+ var ESC2 = "\x1B";
44438
+ var CSI2 = `${ESC2}[`;
44439
+ var beep = "\x07";
44440
+ var cursor2 = {
44441
+ to(x, y) {
44442
+ if (!y)
44443
+ return `${CSI2}${x + 1}G`;
44444
+ return `${CSI2}${y + 1};${x + 1}H`;
44445
+ },
44446
+ move(x, y) {
44447
+ let ret = "";
44448
+ if (x < 0)
44449
+ ret += `${CSI2}${-x}D`;
44450
+ else if (x > 0)
44451
+ ret += `${CSI2}${x}C`;
44452
+ if (y < 0)
44453
+ ret += `${CSI2}${-y}A`;
44454
+ else if (y > 0)
44455
+ ret += `${CSI2}${y}B`;
44456
+ return ret;
44457
+ },
44458
+ up: (count3 = 1) => `${CSI2}${count3}A`,
44459
+ down: (count3 = 1) => `${CSI2}${count3}B`,
44460
+ forward: (count3 = 1) => `${CSI2}${count3}C`,
44461
+ backward: (count3 = 1) => `${CSI2}${count3}D`,
44462
+ nextLine: (count3 = 1) => `${CSI2}E`.repeat(count3),
44463
+ prevLine: (count3 = 1) => `${CSI2}F`.repeat(count3),
44464
+ left: `${CSI2}G`,
44465
+ hide: `${CSI2}?25l`,
44466
+ show: `${CSI2}?25h`,
44467
+ save: `${ESC2}7`,
44468
+ restore: `${ESC2}8`
44469
+ };
44470
+ var scroll = {
44471
+ up: (count3 = 1) => `${CSI2}S`.repeat(count3),
44472
+ down: (count3 = 1) => `${CSI2}T`.repeat(count3)
44473
+ };
44474
+ var erase = {
44475
+ screen: `${CSI2}2J`,
44476
+ up: (count3 = 1) => `${CSI2}1J`.repeat(count3),
44477
+ down: (count3 = 1) => `${CSI2}J`.repeat(count3),
44478
+ line: `${CSI2}2K`,
44479
+ lineEnd: `${CSI2}K`,
44480
+ lineStart: `${CSI2}1K`,
44481
+ lines(count3) {
44482
+ let clear = "";
44483
+ for (let i2 = 0;i2 < count3; i2++)
44484
+ clear += this.line + (i2 < count3 - 1 ? cursor2.up() : "");
44485
+ if (count3)
44486
+ clear += cursor2.left;
44487
+ return clear;
44488
+ }
44489
+ };
44490
+ module.exports = { cursor: cursor2, scroll, erase, beep };
44491
+ });
44492
+
44435
44493
  // ../../node_modules/.bun/@commander-js+extra-typings@14.0.0+952b9027c0112832/node_modules/@commander-js/extra-typings/esm.mjs
44436
44494
  var import__ = __toESM(require_extra_typings(), 1);
44437
44495
  var {
@@ -44448,11 +44506,11 @@ var {
44448
44506
  Help
44449
44507
  } = import__.default;
44450
44508
 
44451
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.7+b9070756b93f12a8/node_modules/@gobing-ai/ts-infra/dist/application-node.js
44509
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.11+b297f31fc53502e3/node_modules/@gobing-ai/ts-infra/dist/application-node.js
44452
44510
  import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync5 } from "fs";
44453
44511
  import { dirname as dirname2 } from "path";
44454
44512
 
44455
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.7+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/adapter.js
44513
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.11+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/adapter.js
44456
44514
  async function createDbAdapter(config3) {
44457
44515
  switch (config3.driver) {
44458
44516
  case "bun-sqlite": {
@@ -44468,7 +44526,7 @@ async function createDbAdapter(config3) {
44468
44526
  }
44469
44527
  }
44470
44528
  }
44471
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.7+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/query-spec.js
44529
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.11+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/query-spec.js
44472
44530
  var COMPARISON_BUILDERS = {
44473
44531
  eq: (col, value) => eq(col, value),
44474
44532
  ne: (col, value) => ne(col, value),
@@ -44502,7 +44560,7 @@ function compileOrderBy(orderBy) {
44502
44560
  return orderBy.map((term) => term.dir === "desc" ? desc(term.col) : asc(term.col));
44503
44561
  }
44504
44562
 
44505
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.7+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/base-dao.js
44563
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.11+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/base-dao.js
44506
44564
  function asSelectQuery(query) {
44507
44565
  return query;
44508
44566
  }
@@ -44541,7 +44599,7 @@ class BaseDao {
44541
44599
  }
44542
44600
  }
44543
44601
 
44544
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.7+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/entity-dao.js
44602
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.11+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/entity-dao.js
44545
44603
  class EntityDao extends BaseDao {
44546
44604
  table;
44547
44605
  primaryKey;
@@ -44696,7 +44754,7 @@ class EntityDao extends BaseDao {
44696
44754
  return { and: [where, active] };
44697
44755
  }
44698
44756
  }
44699
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.7+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/inbox-message-dao.js
44757
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.11+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/inbox-message-dao.js
44700
44758
  init_inbox_messages();
44701
44759
 
44702
44760
  class InboxMessageDao extends EntityDao {
@@ -44764,7 +44822,7 @@ class InboxMessageDao extends EntityDao {
44764
44822
  return this.findBy(inboxMessages.id, id);
44765
44823
  }
44766
44824
  }
44767
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.7+b9070756b93f12a8/node_modules/@gobing-ai/ts-infra/dist/application-node.js
44825
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.11+b297f31fc53502e3/node_modules/@gobing-ai/ts-infra/dist/application-node.js
44768
44826
  init_dist3();
44769
44827
  // ../../node_modules/.bun/@logtape+logtape@2.1.1/node_modules/@logtape/logtape/dist/context.js
44770
44828
  var categoryPrefixSymbol = Symbol.for("logtape.categoryPrefix");
@@ -46537,7 +46595,7 @@ var ConfigError = class extends Error {
46537
46595
  }
46538
46596
  };
46539
46597
 
46540
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.7+b9070756b93f12a8/node_modules/@gobing-ai/ts-infra/dist/logger.js
46598
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.11+b297f31fc53502e3/node_modules/@gobing-ai/ts-infra/dist/logger.js
46541
46599
  var ROOT_CATEGORY = "app";
46542
46600
  function toLogTapeLevel(level) {
46543
46601
  return level === "warn" ? "warning" : level;
@@ -46584,10 +46642,10 @@ async function initializeLogger(options = {}) {
46584
46642
  const lowestLevel = toLogTapeLevel(level);
46585
46643
  const formatter = json2 ? getJsonLinesFormatter() : getTextFormatter();
46586
46644
  const sinks = {};
46587
- if (enableConsole) {
46645
+ if (!muted && enableConsole) {
46588
46646
  sinks.console = getConsoleSink({ formatter });
46589
46647
  }
46590
- if (fileSink) {
46648
+ if (!muted && fileSink) {
46591
46649
  sinks.file = (record2) => {
46592
46650
  fileSink(formatter(record2));
46593
46651
  };
@@ -46607,10 +46665,10 @@ async function initializeLogger(options = {}) {
46607
46665
  }
46608
46666
  }
46609
46667
 
46610
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.7+b9070756b93f12a8/node_modules/@gobing-ai/ts-infra/dist/telemetry/tracing.js
46668
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.11+b297f31fc53502e3/node_modules/@gobing-ai/ts-infra/dist/telemetry/tracing.js
46611
46669
  var import_api2 = __toESM(require_src(), 1);
46612
46670
 
46613
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.7+b9070756b93f12a8/node_modules/@gobing-ai/ts-infra/dist/telemetry/sdk.js
46671
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.11+b297f31fc53502e3/node_modules/@gobing-ai/ts-infra/dist/telemetry/sdk.js
46614
46672
  var import_api = __toESM(require_src(), 1);
46615
46673
  var CONFIG_DEFAULTS = {
46616
46674
  enabled: true,
@@ -46629,6 +46687,9 @@ var TRACER_NAME = "@gobing-ai/ts-infra";
46629
46687
  var TRACER_VERSION = "0.1.0";
46630
46688
  var telemetryInitialized = false;
46631
46689
  var resolvedConfig = getTelemetryConfig();
46690
+ function getResolvedConfig() {
46691
+ return resolvedConfig;
46692
+ }
46632
46693
  function initTelemetry(config3) {
46633
46694
  if (telemetryInitialized)
46634
46695
  return;
@@ -46643,8 +46704,16 @@ function getTracer() {
46643
46704
  return import_api.trace.getTracer(TRACER_NAME, TRACER_VERSION);
46644
46705
  }
46645
46706
 
46646
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.7+b9070756b93f12a8/node_modules/@gobing-ai/ts-infra/dist/telemetry/tracing.js
46707
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.11+b297f31fc53502e3/node_modules/@gobing-ai/ts-infra/dist/telemetry/tracing.js
46708
+ function isSuppressed(tracer2) {
46709
+ return tracer2 === undefined && !getResolvedConfig().enabled;
46710
+ }
46711
+ function nonRecordingSpan() {
46712
+ return import_api2.trace.wrapSpanContext(import_api2.INVALID_SPAN_CONTEXT);
46713
+ }
46647
46714
  async function traceAsync(name, fn, options, tracer2) {
46715
+ if (isSuppressed(tracer2))
46716
+ return fn(nonRecordingSpan());
46648
46717
  const resolvedTracer = tracer2 ?? getTracer();
46649
46718
  return resolvedTracer.startActiveSpan(name, options ?? {}, async (span) => {
46650
46719
  try {
@@ -46670,7 +46739,7 @@ function addSpanEvent(name, attributes) {
46670
46739
  }
46671
46740
  }
46672
46741
 
46673
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.7+b9070756b93f12a8/node_modules/@gobing-ai/ts-infra/dist/telemetry/metrics.js
46742
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.11+b297f31fc53502e3/node_modules/@gobing-ai/ts-infra/dist/telemetry/metrics.js
46674
46743
  var import_api3 = __toESM(require_src(), 1);
46675
46744
  var metricsInitialized = false;
46676
46745
  var METER_NAME = "@gobing-ai/ts-infra";
@@ -46679,13 +46748,29 @@ function getMeter() {
46679
46748
  return import_api3.metrics.getMeter(METER_NAME, METER_VERSION);
46680
46749
  }
46681
46750
  var instruments = {};
46751
+ var _noopCounter;
46752
+ var _noopHistogram;
46753
+ function noopCounter() {
46754
+ if (!_noopCounter)
46755
+ _noopCounter = import_api3.createNoopMeter().createCounter("noop");
46756
+ return _noopCounter;
46757
+ }
46758
+ function noopHistogram() {
46759
+ if (!_noopHistogram)
46760
+ _noopHistogram = import_api3.createNoopMeter().createHistogram("noop");
46761
+ return _noopHistogram;
46762
+ }
46682
46763
  function getOrCreateCounter(key, name, description, unit = "{operation}") {
46764
+ if (!getResolvedConfig().enabled)
46765
+ return noopCounter();
46683
46766
  if (!instruments[key]) {
46684
46767
  instruments[key] = getMeter().createCounter(name, { description, unit });
46685
46768
  }
46686
46769
  return instruments[key];
46687
46770
  }
46688
46771
  function getOrCreateHistogram(key, name, description, unit = "ms") {
46772
+ if (!getResolvedConfig().enabled)
46773
+ return noopHistogram();
46689
46774
  if (!instruments[key]) {
46690
46775
  instruments[key] = getMeter().createHistogram(name, { description, unit });
46691
46776
  }
@@ -46752,7 +46837,7 @@ function shutdownMetrics() {
46752
46837
  return Promise.resolve();
46753
46838
  }
46754
46839
 
46755
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.7+b9070756b93f12a8/node_modules/@gobing-ai/ts-infra/dist/event-bus/event-bus.js
46840
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.11+b297f31fc53502e3/node_modules/@gobing-ai/ts-infra/dist/event-bus/event-bus.js
46756
46841
  var _busLogger;
46757
46842
  function busLogger() {
46758
46843
  if (!_busLogger)
@@ -46763,17 +46848,20 @@ function busLogger() {
46763
46848
  class EventBus {
46764
46849
  syncHandlers = new Map;
46765
46850
  asyncHandlers = new Map;
46766
- asyncHandlerIds = new WeakMap;
46851
+ asyncHandlerIds = new Map;
46852
+ asyncHandlersById = new Map;
46767
46853
  jobQueue;
46768
46854
  lifecycleBus;
46855
+ logger;
46769
46856
  nextAsyncHandlerId = 0;
46770
46857
  constructor(opts) {
46771
46858
  this.jobQueue = opts?.jobQueue ?? null;
46772
46859
  this.lifecycleBus = opts?.lifecycleBus ?? null;
46860
+ this.logger = opts?.logger;
46773
46861
  }
46774
46862
  on(event, handler, opts) {
46775
46863
  if (opts?.async) {
46776
- this.registerAsync(event, handler);
46864
+ this.registerAsync(event, handler, opts.name);
46777
46865
  } else {
46778
46866
  this.registerSync(event, handler);
46779
46867
  }
@@ -46799,15 +46887,23 @@ class EventBus {
46799
46887
  if (asyncSet.size === 0) {
46800
46888
  this.asyncHandlers.delete(event);
46801
46889
  }
46890
+ this.releaseAsyncIdIfUnsubscribed(handler);
46802
46891
  }
46803
46892
  }
46804
46893
  removeAllListeners(event) {
46805
46894
  if (event !== undefined) {
46806
46895
  this.syncHandlers.delete(event);
46896
+ const asyncSet = this.asyncHandlers.get(event);
46807
46897
  this.asyncHandlers.delete(event);
46898
+ if (asyncSet) {
46899
+ for (const handler of asyncSet)
46900
+ this.releaseAsyncIdIfUnsubscribed(handler);
46901
+ }
46808
46902
  } else {
46809
46903
  this.syncHandlers.clear();
46810
46904
  this.asyncHandlers.clear();
46905
+ this.asyncHandlerIds.clear();
46906
+ this.asyncHandlersById.clear();
46811
46907
  }
46812
46908
  }
46813
46909
  async emit(event, ...args) {
@@ -46816,6 +46912,11 @@ class EventBus {
46816
46912
  let syncCount = 0;
46817
46913
  let asyncCount = 0;
46818
46914
  let errors5 = 0;
46915
+ this.logger?.debug("event.emit", {
46916
+ event: eventName,
46917
+ syncHandlers: this.syncHandlers.get(event)?.size ?? 0,
46918
+ asyncHandlers: this.asyncHandlers.get(event)?.size ?? 0
46919
+ });
46819
46920
  const syncSet = this.syncHandlers.get(event);
46820
46921
  if (syncSet) {
46821
46922
  syncCount = syncSet.size;
@@ -46899,13 +47000,21 @@ class EventBus {
46899
47000
  }
46900
47001
  set2.add(handler);
46901
47002
  }
46902
- registerAsync(event, handler) {
47003
+ registerAsync(event, handler, name) {
46903
47004
  let set2 = this.asyncHandlers.get(event);
46904
47005
  if (!set2) {
46905
47006
  set2 = new Set;
46906
47007
  this.asyncHandlers.set(event, set2);
46907
47008
  }
46908
47009
  set2.add(handler);
47010
+ if (!this.asyncHandlerIds.has(handler)) {
47011
+ const id = name ?? `handler-${++this.nextAsyncHandlerId}`;
47012
+ if (this.asyncHandlersById.has(id)) {
47013
+ throw new Error(`Duplicate async handler name: "${id}"`);
47014
+ }
47015
+ this.asyncHandlerIds.set(handler, id);
47016
+ this.asyncHandlersById.set(id, handler);
47017
+ }
46909
47018
  }
46910
47019
  getAsyncHandlerId(handler) {
46911
47020
  const existing = this.asyncHandlerIds.get(handler);
@@ -46913,8 +47022,30 @@ class EventBus {
46913
47022
  return existing;
46914
47023
  const id = `handler-${++this.nextAsyncHandlerId}`;
46915
47024
  this.asyncHandlerIds.set(handler, id);
47025
+ this.asyncHandlersById.set(id, handler);
46916
47026
  return id;
46917
47027
  }
47028
+ releaseAsyncIdIfUnsubscribed(handler) {
47029
+ for (const set2 of this.asyncHandlers.values()) {
47030
+ if (set2.has(handler))
47031
+ return;
47032
+ }
47033
+ const id = this.asyncHandlerIds.get(handler);
47034
+ if (id !== undefined) {
47035
+ this.asyncHandlerIds.delete(handler);
47036
+ this.asyncHandlersById.delete(id);
47037
+ }
47038
+ }
47039
+ createJobHandler() {
47040
+ return async (job) => {
47041
+ const { event, args, handlerId } = job.payload;
47042
+ const handler = this.asyncHandlersById.get(handlerId);
47043
+ if (!handler) {
47044
+ throw new Error(`No async handler registered for id "${handlerId}" (event "${event}")`);
47045
+ }
47046
+ await handler(...args);
47047
+ };
47048
+ }
46918
47049
  publishEmitDone(detail) {
46919
47050
  if (this.lifecycleBus) {
46920
47051
  try {
@@ -46947,7 +47078,7 @@ class EventBus {
46947
47078
  }
46948
47079
  }
46949
47080
 
46950
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.7+b9070756b93f12a8/node_modules/@gobing-ai/ts-infra/dist/event-bus/default-observers.js
47081
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.11+b297f31fc53502e3/node_modules/@gobing-ai/ts-infra/dist/event-bus/default-observers.js
46951
47082
  var _obsLogger;
46952
47083
  function obsLogger() {
46953
47084
  if (!_obsLogger)
@@ -47006,7 +47137,7 @@ function attachDefaultObservers(lifecycleBus) {
47006
47137
  attachTelemetryObserver(lifecycleBus);
47007
47138
  }
47008
47139
 
47009
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.7+b9070756b93f12a8/node_modules/@gobing-ai/ts-infra/dist/scheduler/noop.js
47140
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.11+b297f31fc53502e3/node_modules/@gobing-ai/ts-infra/dist/scheduler/noop.js
47010
47141
  class NoopSchedulerAdapter {
47011
47142
  constructor() {}
47012
47143
  register(_cron, _action) {}
@@ -47014,7 +47145,7 @@ class NoopSchedulerAdapter {
47014
47145
  async stop() {}
47015
47146
  }
47016
47147
 
47017
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.7+b9070756b93f12a8/node_modules/@gobing-ai/ts-infra/dist/scheduler/factory.js
47148
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.11+b297f31fc53502e3/node_modules/@gobing-ai/ts-infra/dist/scheduler/factory.js
47018
47149
  function initScheduler(adapter, cronEntries) {
47019
47150
  const resolved = adapter ?? new NoopSchedulerAdapter;
47020
47151
  if (cronEntries) {
@@ -47025,7 +47156,7 @@ function initScheduler(adapter, cronEntries) {
47025
47156
  return resolved;
47026
47157
  }
47027
47158
 
47028
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.7+b9070756b93f12a8/node_modules/@gobing-ai/ts-infra/dist/application/plugins/builtins.js
47159
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.11+b297f31fc53502e3/node_modules/@gobing-ai/ts-infra/dist/application/plugins/builtins.js
47029
47160
  function telemetryPlugin(config3) {
47030
47161
  return {
47031
47162
  name: "builtin:telemetry",
@@ -47033,21 +47164,21 @@ function telemetryPlugin(config3) {
47033
47164
  failFast: true,
47034
47165
  onLoad: async () => {},
47035
47166
  onStart: async () => {
47167
+ initTelemetry({
47168
+ enabled: config3.enabled,
47169
+ serviceName: config3.serviceName,
47170
+ environment: config3.environment,
47171
+ dbStatementDebug: config3.dbStatementDebug
47172
+ });
47036
47173
  if (config3.enabled) {
47037
- initTelemetry({
47038
- enabled: config3.enabled,
47039
- serviceName: config3.serviceName,
47040
- environment: config3.environment,
47041
- dbStatementDebug: config3.dbStatementDebug
47042
- });
47043
47174
  initMetrics();
47044
47175
  }
47045
47176
  },
47046
47177
  onStop: async () => {
47047
47178
  if (config3.enabled) {
47048
47179
  shutdownMetrics();
47049
- await shutdownTelemetry();
47050
47180
  }
47181
+ await shutdownTelemetry();
47051
47182
  }
47052
47183
  };
47053
47184
  }
@@ -47115,7 +47246,7 @@ function dbPlugin(db2) {
47115
47246
  };
47116
47247
  }
47117
47248
 
47118
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.7+b9070756b93f12a8/node_modules/@gobing-ai/ts-infra/dist/application/plugins/host.js
47249
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.11+b297f31fc53502e3/node_modules/@gobing-ai/ts-infra/dist/application/plugins/host.js
47119
47250
  class PluginHost {
47120
47251
  logger;
47121
47252
  events;
@@ -47201,7 +47332,7 @@ class PluginHost {
47201
47332
  }
47202
47333
  }
47203
47334
 
47204
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.7+b9070756b93f12a8/node_modules/@gobing-ai/ts-infra/dist/application/index.js
47335
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.11+b297f31fc53502e3/node_modules/@gobing-ai/ts-infra/dist/application/index.js
47205
47336
  async function performShutdown(state, reason) {
47206
47337
  if (state.stopped)
47207
47338
  return;
@@ -47248,7 +47379,7 @@ async function runApplication(options) {
47248
47379
  if (lifecycleBus && eventsDefaultObservers) {
47249
47380
  attachDefaultObservers(lifecycleBus);
47250
47381
  }
47251
- const events = options.services?.events ? options.services.events : new EventBus({ lifecycleBus });
47382
+ const events = options.services?.events ?? options.config?.events?.bus ?? new EventBus({ lifecycleBus });
47252
47383
  const db2 = options.services?.db;
47253
47384
  let scheduler3;
47254
47385
  if (schedulerConfig.enabled) {
@@ -47296,19 +47427,24 @@ async function runApplication(options) {
47296
47427
  }
47297
47428
  }
47298
47429
 
47299
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.7+b9070756b93f12a8/node_modules/@gobing-ai/ts-infra/dist/scheduler/node.js
47430
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.11+b297f31fc53502e3/node_modules/@gobing-ai/ts-infra/dist/scheduler/node.js
47300
47431
  function parseInterval(cron) {
47301
- const num = Number(cron);
47302
- if (!Number.isNaN(num))
47303
- return num;
47304
- const parts = cron.trim().split(/\s+/);
47305
- if (parts.length === 5 && parts[0] === "*") {
47306
- return 60000;
47307
- }
47308
- const match = parts[0]?.match(/^\*\/(\d+)$/);
47309
- if (match) {
47310
- return Number(match[1]) * 60000;
47432
+ const trimmed = cron.trim();
47433
+ const num = Number(trimmed);
47434
+ if (trimmed !== "" && !Number.isNaN(num)) {
47435
+ if (num > 0)
47436
+ return num;
47437
+ } else {
47438
+ const parts = trimmed.split(/\s+/);
47439
+ if (parts.length === 5 && parts[0] === "*") {
47440
+ return 60000;
47441
+ }
47442
+ const match = parts[0]?.match(/^\*\/(\d+)$/);
47443
+ if (match && Number(match[1]) > 0) {
47444
+ return Number(match[1]) * 60000;
47445
+ }
47311
47446
  }
47447
+ getLogger2("scheduler.node").warn("Unsupported cron expression \u2014 falling back to a 60s interval", { cron });
47312
47448
  return 60000;
47313
47449
  }
47314
47450
 
@@ -47360,7 +47496,7 @@ class NodeSchedulerAdapter {
47360
47496
  }
47361
47497
  }
47362
47498
  }
47363
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.7+b9070756b93f12a8/node_modules/@gobing-ai/ts-infra/dist/telemetry/otel-node.js
47499
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.11+b297f31fc53502e3/node_modules/@gobing-ai/ts-infra/dist/telemetry/otel-node.js
47364
47500
  var import_api14 = __toESM(require_src(), 1);
47365
47501
 
47366
47502
  // ../../node_modules/.bun/@opentelemetry+exporter-metrics-otlp-http@0.218.0+e40b0dfdd726a224/node_modules/@opentelemetry/exporter-metrics-otlp-http/build/esm/OTLPMetricExporterBase.js
@@ -50376,7 +50512,7 @@ class OTLPTraceExporter extends import_otlp_exporter_base2.OTLPExporterBase {
50376
50512
  }), JsonTraceSerializer));
50377
50513
  }
50378
50514
  }
50379
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.7+b9070756b93f12a8/node_modules/@gobing-ai/ts-infra/dist/telemetry/otel-node.js
50515
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.11+b297f31fc53502e3/node_modules/@gobing-ai/ts-infra/dist/telemetry/otel-node.js
50380
50516
  var import_resources2 = __toESM(require_src4(), 1);
50381
50517
  var import_sdk_trace_node = __toESM(require_src8(), 1);
50382
50518
  var import_semantic_conventions = __toESM(require_src2(), 1);
@@ -50427,7 +50563,7 @@ async function shutdownNodeTelemetry() {
50427
50563
  await Promise.all(pending);
50428
50564
  }
50429
50565
 
50430
- // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.7+b9070756b93f12a8/node_modules/@gobing-ai/ts-infra/dist/application-node.js
50566
+ // ../../node_modules/.bun/@gobing-ai+ts-infra@0.3.11+b297f31fc53502e3/node_modules/@gobing-ai/ts-infra/dist/application-node.js
50431
50567
  class ConfigValidationError extends Error {
50432
50568
  constructor(message) {
50433
50569
  super(message);
@@ -50522,18 +50658,19 @@ async function runNodeApplication(options) {
50522
50658
  }
50523
50659
  const plugins = [];
50524
50660
  let dbAdapter = options.services?.db;
50525
- const rawTel = { ...telemetryOpts };
50526
- if (rawTel.enabled !== false && rawTel.endpoint) {
50661
+ const otlpEndpoint = telemetryOpts.endpoint;
50662
+ if (telemetryOpts.enabled !== false && otlpEndpoint) {
50663
+ const otlpHeaders = telemetryOpts.headers;
50664
+ const serviceName = telemetryOpts.serviceName ?? "ts-libs";
50527
50665
  plugins.push({
50528
50666
  name: "builtin:node-telemetry",
50529
50667
  version: "0.0.0",
50530
50668
  failFast: true,
50531
- onLoad: async () => {},
50532
- onStart: async () => {
50669
+ onLoad: async () => {
50533
50670
  initNodeTelemetry({
50534
- serviceName: rawTel.serviceName ?? "ts-libs",
50535
- endpoint: rawTel.endpoint,
50536
- headers: rawTel.headers
50671
+ serviceName,
50672
+ endpoint: otlpEndpoint,
50673
+ ...otlpHeaders ? { headers: otlpHeaders } : {}
50537
50674
  });
50538
50675
  },
50539
50676
  onStop: async () => {
@@ -54197,7 +54334,7 @@ Font modified May 20, 2012 by patorjk to add the 0xCA0 character
54197
54334
  import { stat } from "fs/promises";
54198
54335
  import { isatty as isatty2 } from "tty";
54199
54336
 
54200
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.7+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/agents/shims.js
54337
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.11+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/agents/shims.js
54201
54338
  var claudeShim = {
54202
54339
  name: "claude",
54203
54340
  command: "claude",
@@ -54333,10 +54470,10 @@ function isAgentName(value) {
54333
54470
  function getAgentShim(agent) {
54334
54471
  return AGENT_SHIMS[agent];
54335
54472
  }
54336
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.7+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/ai-runner.js
54473
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.11+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/ai-runner.js
54337
54474
  init_dist3();
54338
54475
 
54339
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.7+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/identity.js
54476
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.11+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/identity.js
54340
54477
  function buildIdentityPreamble(ctx) {
54341
54478
  const sections = [
54342
54479
  `You are agent \`${ctx.agentId}\` (${ctx.agentType}) in workspace \`${ctx.workspace}\`.`
@@ -54377,7 +54514,7 @@ function buildIdentityPreamble(ctx) {
54377
54514
  `;
54378
54515
  }
54379
54516
 
54380
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.7+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/slash-command.js
54517
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.11+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/slash-command.js
54381
54518
  var SLASH_COMMAND_RE = /^\/([a-zA-Z0-9._-]+):([a-zA-Z0-9._-]+)(\s.*)?$/;
54382
54519
  function isClaudeStyleSlashCommand(input) {
54383
54520
  return SLASH_COMMAND_RE.test(input);
@@ -54401,7 +54538,7 @@ function translateSlashCommand(agent, input) {
54401
54538
  }
54402
54539
  }
54403
54540
 
54404
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.7+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/ai-runner.js
54541
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.11+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/ai-runner.js
54405
54542
  class AiRunner {
54406
54543
  processExecutor;
54407
54544
  defaultCwd;
@@ -54503,7 +54640,7 @@ function hasIdentityOptions(options) {
54503
54640
  return options.purpose !== undefined || options.systemPrompt !== undefined || options.taskId !== undefined || options.peers !== undefined && options.peers.length > 0;
54504
54641
  }
54505
54642
 
54506
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.7+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/agent-detector.js
54643
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.11+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/agent-detector.js
54507
54644
  var DEFAULT_TIMEOUT_MS = 5000;
54508
54645
  var VERSION_PATTERN = /(?<version>\d+\.\d+(?:\.\d+)?)/;
54509
54646
 
@@ -54565,7 +54702,7 @@ function unavailable(name, error51) {
54565
54702
  return { name, installed: false, version: null, channels: [], error: error51 };
54566
54703
  }
54567
54704
 
54568
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.7+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/agent-spec.js
54705
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.11+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/agent-spec.js
54569
54706
  init_dist3();
54570
54707
 
54571
54708
  class ValueError extends Error {
@@ -54660,7 +54797,7 @@ function requireRecord(source, key, fileName) {
54660
54797
  return value;
54661
54798
  }
54662
54799
 
54663
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.7+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/doctor-runner.js
54800
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.11+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/doctor-runner.js
54664
54801
  init_dist3();
54665
54802
  var DEFAULT_TIMEOUT_MS2 = 5000;
54666
54803
  var AUTH_PATTERNS = {
@@ -54779,12 +54916,12 @@ ${result.stderr}`;
54779
54916
  }
54780
54917
  }
54781
54918
 
54782
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.7+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/messages.js
54919
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.11+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/messages.js
54783
54920
  function formatMessage(msg) {
54784
54921
  return `[task from=${msg.fromId ?? "operator"} id=${msg.id}] ${msg.body}`;
54785
54922
  }
54786
54923
 
54787
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.7+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/team-agent-process.js
54924
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.11+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/team-agent-process.js
54788
54925
  import { Buffer as Buffer5 } from "buffer";
54789
54926
  init_dist3();
54790
54927
 
@@ -54915,7 +55052,7 @@ class TeamAgentProcess {
54915
55052
  }
54916
55053
  }
54917
55054
 
54918
- // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.7+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/team-orchestrator.js
55055
+ // ../../node_modules/.bun/@gobing-ai+ts-ai-runner@0.3.11+fbd66d84c9f9ab42/node_modules/@gobing-ai/ts-ai-runner/dist/team-orchestrator.js
54919
55056
  class TeamOrchestrator {
54920
55057
  configDir;
54921
55058
  inbox;
@@ -55419,11 +55556,11 @@ function etlToCostRecord(payload, source) {
55419
55556
  costUsd: 0
55420
55557
  };
55421
55558
  }
55422
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.7+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/index.js
55559
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.11+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/index.js
55423
55560
  init_sqlite_core();
55424
55561
  init_common3();
55425
55562
 
55426
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.7+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/define-table.js
55563
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.11+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/define-table.js
55427
55564
  init_sqlite_core();
55428
55565
 
55429
55566
  // ../../node_modules/.bun/drizzle-orm@0.38.4+a0473b45aab9bf33/node_modules/drizzle-orm/mysql-core/columns/common.js
@@ -55534,10 +55671,10 @@ function p(e) {
55534
55671
  return m2 || (m2 = exports_external.any()), m2;
55535
55672
  }
55536
55673
 
55537
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.7+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/ddl.js
55674
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.11+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/ddl.js
55538
55675
  init_sqlite_core();
55539
55676
 
55540
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.7+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/drizzle-internals.js
55677
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.11+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/drizzle-internals.js
55541
55678
  function sqlExpressionToText(value) {
55542
55679
  if (typeof value !== "object" || value === null || !("queryChunks" in value)) {
55543
55680
  return;
@@ -55560,7 +55697,7 @@ function getDrizzleTableName(table2) {
55560
55697
  return String(table2[nameSym]);
55561
55698
  }
55562
55699
 
55563
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.7+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/ddl.js
55700
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.11+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/ddl.js
55564
55701
  function quoteIdent(name) {
55565
55702
  return `"${name.replace(/"/g, '""')}"`;
55566
55703
  }
@@ -55651,7 +55788,7 @@ function generateCreateTableSql(table2) {
55651
55788
  )`;
55652
55789
  }
55653
55790
 
55654
- // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.7+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/define-table.js
55791
+ // ../../node_modules/.bun/@gobing-ai+ts-db@0.3.11+30cfa7dfb09a2dc3/node_modules/@gobing-ai/ts-db/dist/schema/define-table.js
55655
55792
  function defineTable(name, columns2) {
55656
55793
  const table2 = sqliteTable(name, columns2);
55657
55794
  let insert2;
@@ -55769,10 +55906,10 @@ var workflowStates = workflowStatesTable.table;
55769
55906
  import { readdir as readdir2 } from "fs/promises";
55770
55907
  import { join as join2 } from "path";
55771
55908
 
55772
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.7+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/config.js
55909
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.11+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/config.js
55773
55910
  init_dist3();
55774
55911
 
55775
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.7+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/errors.js
55912
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.11+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/errors.js
55776
55913
  class WorkflowValidationError extends Error {
55777
55914
  details;
55778
55915
  constructor(message, details) {
@@ -55798,7 +55935,7 @@ class RunCollisionError extends Error {
55798
55935
  }
55799
55936
  }
55800
55937
 
55801
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.7+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/run-lifecycle.js
55938
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.11+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/run-lifecycle.js
55802
55939
  init_dist3();
55803
55940
  var RUNTIME_BUILTIN_KEYS = [
55804
55941
  "workflow",
@@ -55859,13 +55996,11 @@ class RunLifecycle {
55859
55996
  await this.persistence.savePhase(this.runId, stateOrNodeId, "running");
55860
55997
  addSpanEvent("workflow.node.enter", { node: stateOrNodeId, transitionsTaken });
55861
55998
  this.events?.emit("workflow.node.enter", { node: stateOrNodeId, transitionsTaken });
55862
- this.logger.debug("entered", { node: stateOrNodeId, transitionsTaken });
55863
55999
  }
55864
56000
  async recordTransition(from, to, trigger) {
55865
56001
  await this.persistence.saveTransition(this.runId, from, to, trigger);
55866
56002
  addSpanEvent("workflow.node.transition", { from, to, ...trigger === null ? {} : { trigger } });
55867
56003
  this.events?.emit("workflow.node.transition", { from, to, trigger });
55868
- this.logger.debug("transition", { from, to, trigger });
55869
56004
  }
55870
56005
  async done(finalState, transitionsTaken) {
55871
56006
  await this.persistence.savePhase(this.runId, finalState, "done");
@@ -55928,7 +56063,7 @@ class RunLifecycle {
55928
56063
  }
55929
56064
  }
55930
56065
 
55931
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.7+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/schema.js
56066
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.11+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/schema.js
55932
56067
  init_zod();
55933
56068
  var RESERVED_VAR_NAMES = new Set(["task", "state", "node", "iteration", "run", "runtime"]);
55934
56069
  var IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
@@ -56007,7 +56142,7 @@ var TransitionFlowWorkflowDefSchema = exports_external.object({
56007
56142
  }).strict();
56008
56143
  var WorkflowDefSchema = exports_external.union([StateMachineWorkflowDefSchema, TransitionFlowWorkflowDefSchema]);
56009
56144
 
56010
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.7+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/config.js
56145
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.11+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/config.js
56011
56146
  async function loadWorkflowDef(path8, options = {}) {
56012
56147
  return parseWorkflowDef(await loadStructuredConfig(path8, options), path8);
56013
56148
  }
@@ -56158,10 +56293,10 @@ function throwIfErrors(workflow, errors5) {
56158
56293
  throw new WorkflowValidationError(`Workflow "${workflow.name}" is invalid: ${errors5.join("; ")}`, errors5);
56159
56294
  }
56160
56295
  }
56161
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.7+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/host.js
56296
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.11+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/host.js
56162
56297
  init_dist3();
56163
56298
 
56164
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.7/node_modules/@gobing-ai/ts-runtime/dist/extension/capability-registry.js
56299
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.11/node_modules/@gobing-ai/ts-runtime/dist/extension/capability-registry.js
56165
56300
  class CapabilityRegistry {
56166
56301
  kind;
56167
56302
  capabilities = new Map;
@@ -56192,7 +56327,7 @@ class CapabilityRegistry {
56192
56327
  }
56193
56328
  }
56194
56329
 
56195
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.7/node_modules/@gobing-ai/ts-runtime/dist/extension/extension-path.js
56330
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.3.11/node_modules/@gobing-ai/ts-runtime/dist/extension/extension-path.js
56196
56331
  function assertRelativeExtensionPath(path8, options = {}) {
56197
56332
  const where = options.sourceName !== undefined ? ` declared by "${options.sourceName}"` : "";
56198
56333
  if (/^([/\\]|[A-Za-z]:[/\\])/.test(path8)) {
@@ -56203,7 +56338,7 @@ function assertRelativeExtensionPath(path8, options = {}) {
56203
56338
  }
56204
56339
  }
56205
56340
 
56206
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.7+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/host.js
56341
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.11+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/host.js
56207
56342
  class WorkflowEngineHost {
56208
56343
  actions = new CapabilityRegistry("workflow action");
56209
56344
  guards = new CapabilityRegistry("workflow guard");
@@ -56248,6 +56383,7 @@ function createDefaultWorkflowEngineHost(options = {}) {
56248
56383
  const host = new WorkflowEngineHost;
56249
56384
  host.registerAction(new NoteActionRunner, "builtin");
56250
56385
  host.registerAction(new ShellActionRunner(options.processExecutor ?? new NodeProcessExecutor), "builtin");
56386
+ host.registerAction(new EventEmitActionRunner, "builtin");
56251
56387
  host.registerGuard({ kind: "always", evaluate: async () => true }, "builtin");
56252
56388
  host.registerGuard({ kind: "never", evaluate: async () => false }, "builtin");
56253
56389
  host.registerGuard({
@@ -56259,8 +56395,22 @@ function createDefaultWorkflowEngineHost(options = {}) {
56259
56395
 
56260
56396
  class NoteActionRunner {
56261
56397
  kind = "note";
56262
- async execute(options) {
56263
- return { ok: true, data: { message: String(options.message ?? "") } };
56398
+ async execute(options, context3) {
56399
+ const message = String(options.message ?? "");
56400
+ context3?.events?.emit("workflow.hitl.note", { node: context3.stateOrNodeId, message });
56401
+ return { ok: true, data: { message } };
56402
+ }
56403
+ }
56404
+
56405
+ class EventEmitActionRunner {
56406
+ kind = "event.emit";
56407
+ async execute(options, context3) {
56408
+ const name = String(options.name ?? "");
56409
+ if (!name)
56410
+ return { ok: false, error: 'event.emit requires a non-empty "name" option' };
56411
+ const payload = options.payload ?? {};
56412
+ context3?.events?.emit("workflow.custom", { name, payload });
56413
+ return { ok: true, data: { name, payload } };
56264
56414
  }
56265
56415
  }
56266
56416
 
@@ -56272,10 +56422,12 @@ class ShellActionRunner {
56272
56422
  }
56273
56423
  async execute(options, context3) {
56274
56424
  const command = stringOption(options, "command");
56275
- const args = arrayOption(options, "args");
56425
+ const explicitArgs = arrayOption(options, "args");
56426
+ const usesShell = explicitArgs.length === 0;
56427
+ const spawn2 = usesShell ? { command: "/bin/sh", args: ["-c", command] } : { command, args: explicitArgs };
56276
56428
  const result = await this.processExecutor.run({
56277
- command,
56278
- args,
56429
+ command: spawn2.command,
56430
+ args: spawn2.args,
56279
56431
  cwd: stringOption(options, "cwd", context3.workdir),
56280
56432
  rejectOnError: false,
56281
56433
  forceBuffered: true
@@ -56303,7 +56455,7 @@ function arrayOption(options, key) {
56303
56455
  return value;
56304
56456
  throw new WorkflowValidationError(`Action option "${key}" must be a string array`);
56305
56457
  }
56306
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.7+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/schema-sql.js
56458
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.11+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/schema-sql.js
56307
56459
  var WORKFLOW_ENGINE_SCHEMA_SQL = `
56308
56460
  CREATE TABLE IF NOT EXISTS runs (
56309
56461
  id TEXT PRIMARY KEY,
@@ -56353,7 +56505,7 @@ CREATE TABLE IF NOT EXISTS workflow_states (
56353
56505
  );
56354
56506
  `.trim();
56355
56507
 
56356
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.7+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/persistence.js
56508
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.11+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/persistence.js
56357
56509
  async function applyWorkflowEngineSchema(db2) {
56358
56510
  for (const statement of WORKFLOW_ENGINE_SCHEMA_SQL.split(";")) {
56359
56511
  const sql3 = statement.trim();
@@ -56435,11 +56587,21 @@ class MemoryWorkflowPersistenceAdapter {
56435
56587
  return [...this.runs.values()];
56436
56588
  }
56437
56589
  }
56438
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.7+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/variables.js
56590
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.11+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/variables.js
56439
56591
  var TEMPLATE_REF = /\$\{([^}]+)\}/g;
56440
56592
  function mergeVars(workflowVars = {}, overrideVars = {}) {
56441
56593
  return { ...workflowVars, ...overrideVars };
56442
56594
  }
56595
+ function mergeSetVars(vars, setVars) {
56596
+ if (setVars === undefined)
56597
+ return vars;
56598
+ const filtered = {};
56599
+ for (const [key, value] of Object.entries(setVars)) {
56600
+ if (typeof value === "string")
56601
+ filtered[key] = value;
56602
+ }
56603
+ return mergeVars(vars, filtered);
56604
+ }
56443
56605
  function resolveTemplates(value, context3) {
56444
56606
  if (typeof value === "string") {
56445
56607
  return resolveTemplateString(value, context3);
@@ -56481,7 +56643,7 @@ function resolveOnErrorPolicy(actionOnError, workflowDefault, runOptionOverride)
56481
56643
  return actionOnError ?? workflowDefault ?? runOptionOverride ?? "fail";
56482
56644
  }
56483
56645
 
56484
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.7+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/state-machine.js
56646
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.11+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/state-machine.js
56485
56647
  class StateMachineDriver {
56486
56648
  options;
56487
56649
  constructor(options) {
@@ -56494,7 +56656,7 @@ class StateMachineDriver {
56494
56656
  const runId = lifecycle.runId;
56495
56657
  const states = new Map(workflow.states.map((state) => [state.id, state]));
56496
56658
  const terminal = new Set(workflow.terminalStates ?? []);
56497
- const vars = mergeVars(workflow.vars, options.vars);
56659
+ let vars = mergeVars(workflow.vars, options.vars);
56498
56660
  const env = allowedEnv(workflow.env?.allow ?? [], options.env);
56499
56661
  let current = states.get(workflow.initialState);
56500
56662
  let transitionsTaken = 0;
@@ -56508,6 +56670,8 @@ class StateMachineDriver {
56508
56670
  const enter = await this.runActions(current.onEnter ?? [], workflow.name, current.id, runId, vars, env, options, transitionsTaken, lifecycle, defaultOnError);
56509
56671
  if (enter.result !== undefined)
56510
56672
  lastActionResult = enter.result;
56673
+ if (enter.result?.setVars)
56674
+ vars = mergeSetVars(vars, enter.result.setVars);
56511
56675
  if (enter.outcome === "terminal") {
56512
56676
  return await lifecycle.done(current.id, transitionsTaken);
56513
56677
  }
@@ -56530,6 +56694,8 @@ class StateMachineDriver {
56530
56694
  const exit = await this.runActions(current.onExit ?? [], workflow.name, current.id, runId, vars, env, options, transitionsTaken, lifecycle, defaultOnError);
56531
56695
  if (exit.result !== undefined)
56532
56696
  lastActionResult = exit.result;
56697
+ if (exit.result?.setVars)
56698
+ vars = mergeSetVars(vars, exit.result.setVars);
56533
56699
  if (exit.outcome === "fail")
56534
56700
  return await lifecycle.fail(current.id, transitionsTaken, exit.result?.error);
56535
56701
  transitionsTaken += 1;
@@ -56560,7 +56726,8 @@ class StateMachineDriver {
56560
56726
  stateOrNodeId: stateId,
56561
56727
  vars,
56562
56728
  env,
56563
- metadata: options.metadata
56729
+ metadata: options.metadata,
56730
+ events: options.events
56564
56731
  });
56565
56732
  } finally {
56566
56733
  lifecycle.actionDone(stateId, action.kind, Date.now() - actionStartMs, last?.ok ?? false);
@@ -56587,7 +56754,7 @@ async function firstPassingTransition(transitions, host, context3) {
56587
56754
  return;
56588
56755
  }
56589
56756
 
56590
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.7+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/transition-flow.js
56757
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.11+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/transition-flow.js
56591
56758
  class TransitionFlowDriver {
56592
56759
  options;
56593
56760
  constructor(options) {
@@ -56600,7 +56767,7 @@ class TransitionFlowDriver {
56600
56767
  const runId = lifecycle.runId;
56601
56768
  const nodes = new Map(workflow.nodes.map((node) => [node.id, node]));
56602
56769
  const terminal = new Set(workflow.terminalNodes ?? []);
56603
- const vars = mergeVars(workflow.vars, options.vars);
56770
+ let vars = mergeVars(workflow.vars, options.vars);
56604
56771
  const env = allowedEnv(workflow.env?.allow ?? [], options.env);
56605
56772
  let current = nodes.get(workflow.initialNode);
56606
56773
  let transitionsTaken = 0;
@@ -56627,11 +56794,14 @@ class TransitionFlowDriver {
56627
56794
  stateOrNodeId: current.id,
56628
56795
  vars,
56629
56796
  env,
56630
- metadata: options.metadata
56797
+ metadata: options.metadata,
56798
+ events: options.events
56631
56799
  });
56632
56800
  } finally {
56633
56801
  lifecycle.actionDone(current.id, current.action.kind, Date.now() - actionStartMs, lastActionResult?.ok ?? false);
56634
56802
  }
56803
+ if (lastActionResult.setVars)
56804
+ vars = mergeSetVars(vars, lastActionResult.setVars);
56635
56805
  if (!lastActionResult.ok) {
56636
56806
  const policy = resolveOnErrorPolicy(current.action.onError, defaultOnError, options.onError);
56637
56807
  if (policy === "fail") {
@@ -56678,7 +56848,7 @@ async function firstPassingEdge(edges, host, context3) {
56678
56848
  return;
56679
56849
  }
56680
56850
 
56681
- // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.7+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/service.js
56851
+ // ../../node_modules/.bun/@gobing-ai+ts-dual-workflow-engine@0.3.11+3f1a4ed45f5d8e5a/node_modules/@gobing-ai/ts-dual-workflow-engine/dist/service.js
56682
56852
  class WorkflowService {
56683
56853
  host;
56684
56854
  persistence;
@@ -56702,10 +56872,10 @@ class WorkflowService {
56702
56872
  return await this.persistence.listRuns();
56703
56873
  }
56704
56874
  }
56705
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.3.7+7d2c76e58a76f847/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/importer.js
56875
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.3.11+7d2c76e58a76f847/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/importer.js
56706
56876
  init_dist3();
56707
56877
 
56708
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.3.7+7d2c76e58a76f847/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/errors.js
56878
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.3.11+7d2c76e58a76f847/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/errors.js
56709
56879
  class HistoryImportError extends Error {
56710
56880
  details;
56711
56881
  constructor(message, details) {
@@ -56715,7 +56885,7 @@ class HistoryImportError extends Error {
56715
56885
  }
56716
56886
  }
56717
56887
 
56718
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.3.7+7d2c76e58a76f847/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/hash.js
56888
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.3.11+7d2c76e58a76f847/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/hash.js
56719
56889
  import { createHash } from "crypto";
56720
56890
  function stableJson(value) {
56721
56891
  if (Array.isArray(value)) {
@@ -56731,7 +56901,7 @@ function sha256(value) {
56731
56901
  return createHash("sha256").update(stableJson(value)).digest("hex");
56732
56902
  }
56733
56903
 
56734
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.3.7+7d2c76e58a76f847/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/redaction.js
56904
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.3.11+7d2c76e58a76f847/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/redaction.js
56735
56905
  var DEFAULT_REDACTION_RULES = [
56736
56906
  {
56737
56907
  name: "api-key",
@@ -56765,7 +56935,7 @@ function redactRecord(record2, rules = DEFAULT_REDACTION_RULES) {
56765
56935
  return redactValue(record2, rules);
56766
56936
  }
56767
56937
 
56768
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.3.7+7d2c76e58a76f847/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/schema-sql.js
56938
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.3.11+7d2c76e58a76f847/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/schema-sql.js
56769
56939
  var HISTORY_IMPORT_SCHEMA_SQL = `
56770
56940
  CREATE TABLE IF NOT EXISTS history_import_checkpoint (
56771
56941
  source TEXT NOT NULL,
@@ -56849,7 +57019,7 @@ CREATE TABLE IF NOT EXISTS history_etl_openclaw (
56849
57019
  );
56850
57020
  `.trim();
56851
57021
 
56852
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.3.7+7d2c76e58a76f847/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/sources.js
57022
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.3.11+7d2c76e58a76f847/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/sources.js
56853
57023
  init_zod();
56854
57024
  var sourceRecordSchema = exports_external.object({
56855
57025
  source_record_id: exports_external.string().min(1),
@@ -56934,7 +57104,7 @@ function getSourceDefinition(source) {
56934
57104
  return SOURCE_DEFINITIONS[source];
56935
57105
  }
56936
57106
 
56937
- // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.3.7+7d2c76e58a76f847/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/importer.js
57107
+ // ../../node_modules/.bun/@gobing-ai+ts-llm-jsonl-importer@0.3.11+7d2c76e58a76f847/node_modules/@gobing-ai/ts-llm-jsonl-importer/dist/importer.js
56938
57108
  var VALID_TABLE_NAME = /^history_etl_[a-z_]+$/;
56939
57109
  async function applyHistoryImportSchema(db2) {
56940
57110
  for (const statement of HISTORY_IMPORT_SCHEMA_SQL.split(";")) {
@@ -57387,7 +57557,7 @@ function buildConfigFromEnv(env = process.env) {
57387
57557
  });
57388
57558
  }
57389
57559
 
57390
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/config/extensions.js
57560
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/config/extensions.js
57391
57561
  init_dist3();
57392
57562
  function collectExtensions(sourceName, sourceDir, extensions) {
57393
57563
  if (extensions === undefined)
@@ -57401,10 +57571,10 @@ function collectExtensions(sourceName, sourceDir, extensions) {
57401
57571
  return refs;
57402
57572
  }
57403
57573
 
57404
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/config/loader.js
57574
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/config/loader.js
57405
57575
  init_dist3();
57406
57576
 
57407
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/types.js
57577
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/types.js
57408
57578
  init_zod();
57409
57579
  var SEVERITY_RANK = {
57410
57580
  error: 3,
@@ -57471,7 +57641,7 @@ var PresetDefinitionSchema = exports_external.object({
57471
57641
  extensions: ExtensionsSchema.optional()
57472
57642
  });
57473
57643
 
57474
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/config/loader.js
57644
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/config/loader.js
57475
57645
  async function loadPreset(name, options) {
57476
57646
  const merged = await buildMergedRoots(options.roots.map((root) => resolvePath2(root)));
57477
57647
  const presetPath = findMergedPreset(merged, name);
@@ -57681,10 +57851,10 @@ function normalizeRule(rule, _sourceDir) {
57681
57851
  };
57682
57852
  }
57683
57853
 
57684
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/fixers/fixers.js
57854
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/fixers/fixers.js
57685
57855
  init_dist3();
57686
57856
 
57687
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/fixers/test-stub-fixer.js
57857
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/fixers/test-stub-fixer.js
57688
57858
  init_dist3();
57689
57859
  var realFileSystem = new NodeFileSystem;
57690
57860
  function normalizeFindingPath(filePath) {
@@ -57746,7 +57916,7 @@ class TestStubFixer {
57746
57916
  }
57747
57917
  }
57748
57918
 
57749
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/fixers/fixers.js
57919
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/fixers/fixers.js
57750
57920
  var FIX_MODE_RANK = {
57751
57921
  none: 0,
57752
57922
  suggest: 1,
@@ -57946,7 +58116,7 @@ function getLineRange(source, oneBasedLine) {
57946
58116
  return { start, end: newline === -1 ? source.length : newline };
57947
58117
  }
57948
58118
 
57949
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/file-utils.js
58119
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/file-utils.js
57950
58120
  init_dist3();
57951
58121
  var DEFAULT_EXCLUDES = new Set([".git", "node_modules", "dist", ".coverage", ".astro", ".wrangler"]);
57952
58122
  async function discoverFiles2(options) {
@@ -58049,7 +58219,7 @@ function parseInlineFlags(source) {
58049
58219
  return { flags, rest: source.slice(match[0].length) };
58050
58220
  }
58051
58221
 
58052
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/agent-detection-evaluator.js
58222
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/agent-detection-evaluator.js
58053
58223
  class AgentDetectionEvaluator {
58054
58224
  detector;
58055
58225
  constructor(detector = new AgentDetector) {
@@ -58072,7 +58242,7 @@ class AgentDetectionEvaluator {
58072
58242
  }
58073
58243
  }
58074
58244
 
58075
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/coverage-gate-evaluator.js
58245
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/coverage-gate-evaluator.js
58076
58246
  init_dist3();
58077
58247
  class CoverageGateEvaluator {
58078
58248
  fs;
@@ -58154,7 +58324,7 @@ function normalizeLcovSourcePath(workdir, filePath) {
58154
58324
  return normalized.replaceAll("\\", "/");
58155
58325
  }
58156
58326
 
58157
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/exit-code-evaluator.js
58327
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/exit-code-evaluator.js
58158
58328
  init_dist3();
58159
58329
  class ExitCodeEvaluator {
58160
58330
  executor;
@@ -58186,7 +58356,7 @@ class ExitCodeEvaluator {
58186
58356
  }
58187
58357
  }
58188
58358
 
58189
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/forbidden-import-evaluator.js
58359
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/forbidden-import-evaluator.js
58190
58360
  class ForbiddenImportEvaluator {
58191
58361
  async evaluate(rule, context3) {
58192
58362
  const config3 = rule.evaluator.config ?? {};
@@ -58258,7 +58428,7 @@ function compileEntry(entry) {
58258
58428
  return { regex: new RegExp(entry.pattern), label: entry.pattern };
58259
58429
  }
58260
58430
 
58261
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/import-boundary-evaluator.js
58431
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/import-boundary-evaluator.js
58262
58432
  class ImportBoundaryEvaluator {
58263
58433
  async evaluate(rule, context3) {
58264
58434
  const config3 = rule.evaluator.config ?? {};
@@ -58345,7 +58515,7 @@ function isStringArray(value) {
58345
58515
  return Array.isArray(value) && value.every((item) => typeof item === "string");
58346
58516
  }
58347
58517
 
58348
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/path-evaluator.js
58518
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/path-evaluator.js
58349
58519
  init_dist3();
58350
58520
  class PathEvaluator {
58351
58521
  fs;
@@ -58403,7 +58573,7 @@ class PathEvaluator {
58403
58573
  }
58404
58574
  }
58405
58575
 
58406
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/regex-evaluator.js
58576
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/regex-evaluator.js
58407
58577
  class RegexEvaluator {
58408
58578
  constructor() {}
58409
58579
  async evaluate(rule, context3) {
@@ -58474,7 +58644,7 @@ function lineForOffset(content, offset) {
58474
58644
  return line;
58475
58645
  }
58476
58646
 
58477
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/ripgrep-evaluator.js
58647
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/ripgrep-evaluator.js
58478
58648
  init_dist3();
58479
58649
  class RipgrepEvaluator {
58480
58650
  executor;
@@ -58558,7 +58728,7 @@ function requireFindings(rule, pattern, stdout) {
58558
58728
  return findings;
58559
58729
  }
58560
58730
 
58561
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/schema-artifact-evaluator.js
58731
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/schema-artifact-evaluator.js
58562
58732
  init_dist3();
58563
58733
  class SchemaArtifactEvaluator {
58564
58734
  fs;
@@ -58634,7 +58804,7 @@ class SchemaArtifactEvaluator {
58634
58804
  }
58635
58805
  }
58636
58806
 
58637
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/secrets-scanner-evaluator.js
58807
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/secrets-scanner-evaluator.js
58638
58808
  var ASSIGN = "\\s*[=:]\\s*";
58639
58809
  var QUOTED = (body) => `["'\`]${body}["'\`]`;
58640
58810
  var keyworded = (keywords, value) => `(?i)(${keywords})${ASSIGN}${QUOTED(value)}`;
@@ -58699,7 +58869,7 @@ function compile(source) {
58699
58869
  return new RegExp(rest, flags);
58700
58870
  }
58701
58871
 
58702
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/sg-evaluator.js
58872
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/sg-evaluator.js
58703
58873
  init_dist3();
58704
58874
  class SgEvaluator {
58705
58875
  executor;
@@ -58792,7 +58962,7 @@ function parseSgJson(stdout) {
58792
58962
  return results;
58793
58963
  }
58794
58964
 
58795
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/resolvers/test-path-resolver.js
58965
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/resolvers/test-path-resolver.js
58796
58966
  class TypeScriptTestPathResolver {
58797
58967
  name = "typescript";
58798
58968
  constructor() {}
@@ -58875,7 +59045,7 @@ function testify(rel) {
58875
59045
  return `${dir}test_${base2}`;
58876
59046
  }
58877
59047
 
58878
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/test-location-evaluator.js
59048
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/test-location-evaluator.js
58879
59049
  class TestLocationEvaluator {
58880
59050
  resolvers;
58881
59051
  constructor(resolvers) {
@@ -58943,7 +59113,7 @@ class TestLocationEvaluator {
58943
59113
  }
58944
59114
  var TYPESCRIPT_FALLBACK = new TypeScriptTestPathResolver;
58945
59115
 
58946
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/tsdoc-export-evaluator.js
59116
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/evaluators/tsdoc-export-evaluator.js
58947
59117
  var VALID_KINDS = ["function", "class", "type", "const", "enum", "interface"];
58948
59118
  var KIND_PATTERN = {
58949
59119
  function: /^export\s+(?:default\s+)?(?:async\s+)?function\s*\*?\s+([A-Za-z0-9_$]+)/,
@@ -59012,7 +59182,7 @@ function precededByJsdoc(lines, declarationLine) {
59012
59182
  return false;
59013
59183
  }
59014
59184
 
59015
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/formatters/json.js
59185
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/formatters/json.js
59016
59186
  class JsonFormatter {
59017
59187
  constructor() {}
59018
59188
  format(result) {
@@ -59020,7 +59190,7 @@ class JsonFormatter {
59020
59190
  }
59021
59191
  }
59022
59192
 
59023
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/formatters/text.js
59193
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/formatters/text.js
59024
59194
  class TextFormatter {
59025
59195
  constructor() {}
59026
59196
  format(result) {
@@ -59034,7 +59204,7 @@ class TextFormatter {
59034
59204
  }
59035
59205
  }
59036
59206
 
59037
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/host/builtins.js
59207
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/host/builtins.js
59038
59208
  function registerBuiltins(host, executor) {
59039
59209
  const path8 = new PathEvaluator;
59040
59210
  host.evaluators.register("regex", new RegexEvaluator, "builtin");
@@ -59059,7 +59229,7 @@ function registerBuiltins(host, executor) {
59059
59229
  host.formatters.register("json", new JsonFormatter, "builtin");
59060
59230
  }
59061
59231
 
59062
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/host/rule-engine-host.js
59232
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/host/rule-engine-host.js
59063
59233
  class RuleEngineHost {
59064
59234
  evaluators;
59065
59235
  formatters;
@@ -59073,7 +59243,7 @@ class RuleEngineHost {
59073
59243
  }
59074
59244
  }
59075
59245
 
59076
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/engine.js
59246
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/engine.js
59077
59247
  class RuleEngine {
59078
59248
  host;
59079
59249
  events;
@@ -59196,7 +59366,7 @@ function effectiveFixMode(ruleMode, requestedMode) {
59196
59366
  return FIX_MODE_RANK[ruleMode] <= FIX_MODE_RANK[requestedMode] ? ruleMode : requestedMode;
59197
59367
  }
59198
59368
 
59199
- // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.7+944fd3b6f711b021/node_modules/@gobing-ai/ts-rule-engine/dist/host/bundled-rules.js
59369
+ // ../../node_modules/.bun/@gobing-ai+ts-rule-engine@0.3.11+fe1d37f180adfcae/node_modules/@gobing-ai/ts-rule-engine/dist/host/bundled-rules.js
59200
59370
  init_dist3();
59201
59371
  var BUNDLED_RULES_DIR = "rules";
59202
59372
  var cachedRoot2;
@@ -59891,6 +60061,528 @@ ${nextBody}
59891
60061
  // ../../packages/app/src/services/workflow-service.ts
59892
60062
  import { access as access2 } from "fs/promises";
59893
60063
  import { resolve as resolve2 } from "path";
60064
+
60065
+ // ../../packages/app/src/workflow/builtins.ts
60066
+ init_dist3();
60067
+
60068
+ // ../../packages/app/src/workflow/actions/agent-run.ts
60069
+ var KIND = "agent.run";
60070
+
60071
+ class AgentRunActionRunner {
60072
+ kind = KIND;
60073
+ agentService;
60074
+ constructor(agentService) {
60075
+ this.agentService = agentService;
60076
+ }
60077
+ async execute(options, context3) {
60078
+ const input = asOptionalString(options.input);
60079
+ const agent = asOptionalString(options.agent);
60080
+ const model = asOptionalString(options.model);
60081
+ const mode = asOptionalString(options.mode) ?? "text";
60082
+ const cwd = asOptionalString(options.cwd) ?? context3.workdir ?? ".";
60083
+ let continueFlag = asOptionalBoolean(options.continue);
60084
+ const latch = context3.vars.__agentSession;
60085
+ if (continueFlag === undefined && latch === "open") {
60086
+ continueFlag = true;
60087
+ }
60088
+ if (input === undefined && !continueFlag) {
60089
+ return {
60090
+ ok: false,
60091
+ error: `agent.run: input is required (use continue: true for resume-only, or provide a prompt)`
60092
+ };
60093
+ }
60094
+ const flags = {};
60095
+ if (agent !== undefined)
60096
+ flags.agent = agent;
60097
+ if (model !== undefined)
60098
+ flags.model = model;
60099
+ flags.mode = mode;
60100
+ if (cwd !== "")
60101
+ flags.cwd = cwd;
60102
+ if (continueFlag !== undefined)
60103
+ flags.continue = continueFlag;
60104
+ const exitCode = await this.agentService.run(input, flags);
60105
+ const ok = exitCode === 0;
60106
+ return {
60107
+ ok,
60108
+ data: { exitCode, agent: agent ?? "<default>" },
60109
+ error: ok ? undefined : `agent.run (${agent ?? "default"}) exited with code ${exitCode}`,
60110
+ setVars: ok ? { __agentSession: "open" } : undefined
60111
+ };
60112
+ }
60113
+ }
60114
+ function asOptionalString(value) {
60115
+ if (value === undefined || value === null)
60116
+ return;
60117
+ return String(value);
60118
+ }
60119
+ function asOptionalBoolean(value) {
60120
+ if (value === undefined || value === null)
60121
+ return;
60122
+ if (typeof value === "boolean")
60123
+ return value;
60124
+ if (value === "true")
60125
+ return true;
60126
+ if (value === "false")
60127
+ return false;
60128
+ return;
60129
+ }
60130
+
60131
+ // ../../packages/app/src/workflow/actions/file-exists.ts
60132
+ init_dist3();
60133
+ var KIND2 = "file.exists";
60134
+
60135
+ class FileExistsActionRunner {
60136
+ kind = KIND2;
60137
+ fileSystem;
60138
+ constructor(fileSystem) {
60139
+ this.fileSystem = fileSystem;
60140
+ }
60141
+ async execute(options, context3) {
60142
+ const rawPath = options.path;
60143
+ if (typeof rawPath !== "string") {
60144
+ return { ok: false, error: "file.exists: path is required" };
60145
+ }
60146
+ const negate = asBoolean(options.negate) ?? false;
60147
+ const resolved = joinPath(context3.workdir ?? ".", rawPath);
60148
+ const exists2 = await this.fileSystem.exists(resolved);
60149
+ const ok = negate ? !exists2 : exists2;
60150
+ return {
60151
+ ok,
60152
+ data: { exists: exists2, path: resolved },
60153
+ error: ok ? undefined : `file.exists: ${exists2 ? "file exists (negated)" : "file not found"}: ${resolved}`
60154
+ };
60155
+ }
60156
+ }
60157
+ function asBoolean(value) {
60158
+ if (value === undefined || value === null)
60159
+ return;
60160
+ if (typeof value === "boolean")
60161
+ return value;
60162
+ if (value === "true")
60163
+ return true;
60164
+ if (value === "false")
60165
+ return false;
60166
+ return;
60167
+ }
60168
+
60169
+ // ../../packages/app/src/workflow/actions/file-read.ts
60170
+ init_dist3();
60171
+ var KIND3 = "file.read";
60172
+
60173
+ class FileReadActionRunner {
60174
+ kind = KIND3;
60175
+ fileSystem;
60176
+ constructor(fileSystem) {
60177
+ this.fileSystem = fileSystem;
60178
+ }
60179
+ async execute(options, context3) {
60180
+ const rawPath = options.path;
60181
+ if (typeof rawPath !== "string") {
60182
+ return { ok: false, error: "file.read: path is required" };
60183
+ }
60184
+ const maxSize = asNumber(options.maxSize);
60185
+ const resolved = joinPath(context3.workdir ?? ".", rawPath);
60186
+ const stat2 = await this.fileSystem.stat(resolved);
60187
+ if (stat2 === null) {
60188
+ return { ok: false, error: `file.read: file not found: ${resolved}` };
60189
+ }
60190
+ if (maxSize !== undefined && stat2.size > maxSize) {
60191
+ return { ok: false, error: `file.read: file too large (${stat2.size} > ${maxSize}): ${resolved}` };
60192
+ }
60193
+ const content = await this.fileSystem.readFile(resolved);
60194
+ return {
60195
+ ok: true,
60196
+ data: { content, size: stat2.size, path: resolved }
60197
+ };
60198
+ }
60199
+ }
60200
+ function asNumber(value) {
60201
+ if (typeof value !== "number" || Number.isNaN(value))
60202
+ return;
60203
+ return value;
60204
+ }
60205
+
60206
+ // ../../packages/app/src/workflow/actions/hitl-confirm.ts
60207
+ var KIND4 = "hitl.confirm";
60208
+
60209
+ class HitlConfirmActionRunner {
60210
+ kind = KIND4;
60211
+ responder;
60212
+ constructor(responder) {
60213
+ this.responder = responder;
60214
+ }
60215
+ async execute(options, context3) {
60216
+ const prompt = asString2(options.prompt);
60217
+ if (prompt === undefined) {
60218
+ return { ok: false, error: "hitl.confirm: prompt is required" };
60219
+ }
60220
+ const varName = asString2(options.var) ?? "__hitlAnswer";
60221
+ const answer = await this.responder.respond({
60222
+ kind: "confirm",
60223
+ prompt,
60224
+ runId: context3.runId,
60225
+ node: context3.stateOrNodeId
60226
+ });
60227
+ if (answer.cancelled || answer.value === "cancel") {
60228
+ return { ok: false, error: "hitl.confirm cancelled" };
60229
+ }
60230
+ return {
60231
+ ok: true,
60232
+ data: { answer: answer.value },
60233
+ setVars: { [varName]: answer.value }
60234
+ };
60235
+ }
60236
+ }
60237
+ function asString2(value) {
60238
+ if (value === undefined || value === null)
60239
+ return;
60240
+ return String(value);
60241
+ }
60242
+
60243
+ // ../../packages/app/src/workflow/actions/hitl-input.ts
60244
+ var KIND5 = "hitl.input";
60245
+
60246
+ class HitlInputActionRunner {
60247
+ kind = KIND5;
60248
+ responder;
60249
+ constructor(responder) {
60250
+ this.responder = responder;
60251
+ }
60252
+ async execute(options, context3) {
60253
+ const prompt = asString3(options.prompt);
60254
+ if (prompt === undefined) {
60255
+ return { ok: false, error: "hitl.input: prompt is required" };
60256
+ }
60257
+ const varName = asString3(options.var) ?? "__hitlInput";
60258
+ const answer = await this.responder.respond({
60259
+ kind: "input",
60260
+ prompt,
60261
+ runId: context3.runId,
60262
+ node: context3.stateOrNodeId
60263
+ });
60264
+ if (answer.cancelled) {
60265
+ return { ok: false, error: "hitl.input cancelled" };
60266
+ }
60267
+ return {
60268
+ ok: true,
60269
+ data: { answer: answer.value },
60270
+ setVars: { [varName]: answer.value }
60271
+ };
60272
+ }
60273
+ }
60274
+ function asString3(value) {
60275
+ if (value === undefined || value === null)
60276
+ return;
60277
+ return String(value);
60278
+ }
60279
+
60280
+ // ../../packages/app/src/workflow/actions/hitl-select.ts
60281
+ var KIND6 = "hitl.select";
60282
+
60283
+ class HitlSelectActionRunner {
60284
+ kind = KIND6;
60285
+ responder;
60286
+ constructor(responder) {
60287
+ this.responder = responder;
60288
+ }
60289
+ async execute(options, context3) {
60290
+ const prompt = asString4(options.prompt);
60291
+ if (prompt === undefined) {
60292
+ return { ok: false, error: "hitl.select: prompt is required" };
60293
+ }
60294
+ const choiceList = asStringArray(options.options);
60295
+ if (choiceList === undefined || choiceList.length === 0) {
60296
+ return { ok: false, error: "hitl.select: options is required and must be non-empty" };
60297
+ }
60298
+ const varName = asString4(options.var) ?? "__hitlAnswer";
60299
+ const answer = await this.responder.respond({
60300
+ kind: "select",
60301
+ prompt,
60302
+ options: choiceList,
60303
+ runId: context3.runId,
60304
+ node: context3.stateOrNodeId
60305
+ });
60306
+ if (answer.cancelled) {
60307
+ return { ok: false, error: "hitl.select cancelled" };
60308
+ }
60309
+ return {
60310
+ ok: true,
60311
+ data: { answer: answer.value },
60312
+ setVars: { [varName]: answer.value }
60313
+ };
60314
+ }
60315
+ }
60316
+ function asString4(value) {
60317
+ if (value === undefined || value === null)
60318
+ return;
60319
+ return String(value);
60320
+ }
60321
+ function asStringArray(value) {
60322
+ if (!Array.isArray(value))
60323
+ return;
60324
+ return value.map((v) => String(v));
60325
+ }
60326
+
60327
+ // ../../packages/app/src/workflow/actions/http-request.ts
60328
+ var KIND7 = "http.request";
60329
+ var ALLOWED_METHODS = {
60330
+ GET: true,
60331
+ POST: true,
60332
+ PUT: true,
60333
+ PATCH: true,
60334
+ DELETE: true,
60335
+ HEAD: true,
60336
+ OPTIONS: true
60337
+ };
60338
+ var DEFAULT_TIMEOUT_MS3 = 30000;
60339
+ var MAX_TIMEOUT_MS = 120000;
60340
+ var DEFAULT_MAX_RESPONSE_BYTES = 1048576;
60341
+ var HEADER_NAME_RE = /^[!#$%&'*+\-.^_`|~0-9a-zA-Z]+$/;
60342
+ var HEADER_VALUE_RE = /^[ \t]*[!-~\x80-\xff][\t -~\x80-\xff]*$/;
60343
+ var PRIVATE_IP_PATTERNS = [
60344
+ /^127\./,
60345
+ /^10\./,
60346
+ /^172\.(1[6-9]|2\d|3[01])\./,
60347
+ /^192\.168\./,
60348
+ /^169\.254\./,
60349
+ /^0\./,
60350
+ /^100\.(6[4-9]|[7-9]\d|1[01]\d|12[0-7])\./,
60351
+ /^fc|^fd|^fe80:/i,
60352
+ /^::1$/,
60353
+ /^::$/
60354
+ ];
60355
+ function resolveTemplate(value, vars) {
60356
+ return value.replace(/\$\{(vars\.)?(\w+)\}/g, (_match, _prefix, key) => {
60357
+ return vars[key] ?? "";
60358
+ });
60359
+ }
60360
+ function isPrivateHost(hostname3) {
60361
+ const normalized = hostname3.startsWith("[") ? hostname3.slice(1, -1) : hostname3;
60362
+ return PRIVATE_IP_PATTERNS.some((re) => re.test(normalized));
60363
+ }
60364
+ function redactHeaders(message) {
60365
+ return message.replace(/"?headers"?\s*[: ]\s*\{[^}]+\}/gi, "headers <redacted>");
60366
+ }
60367
+
60368
+ class HttpRequestActionRunner {
60369
+ kind = KIND7;
60370
+ requester;
60371
+ allowlist;
60372
+ constructor(requester, allowlist) {
60373
+ this.requester = requester;
60374
+ this.allowlist = allowlist;
60375
+ }
60376
+ async execute(options, context3) {
60377
+ const rawUrl = asRequiredString(options.url, "url");
60378
+ const method = (asOptionalString2(options.method) ?? "GET").toUpperCase();
60379
+ const rawHeaders = asRecord(options.headers) ?? {};
60380
+ const rawBody = asOptionalString2(options.body);
60381
+ const failOnStatus = asNumberArray(options.failOnStatus);
60382
+ const timeoutMs = asNumber2(options.timeoutMs) ?? DEFAULT_TIMEOUT_MS3;
60383
+ const maxResponseBytes = asNumber2(options.maxResponseBytes) ?? DEFAULT_MAX_RESPONSE_BYTES;
60384
+ const redirect = asOptionalString2(options.redirect);
60385
+ const bodyVar = asOptionalString2(options.bodyVar);
60386
+ const statusVar = asOptionalString2(options.statusVar);
60387
+ const headersVar = asOptionalString2(options.headersVar);
60388
+ if (!Object.hasOwn(ALLOWED_METHODS, method)) {
60389
+ return { ok: false, error: `http.request: unsupported method: ${method}` };
60390
+ }
60391
+ if (timeoutMs <= 0 || timeoutMs > MAX_TIMEOUT_MS) {
60392
+ return {
60393
+ ok: false,
60394
+ error: `http.request: timeoutMs must be 1\u2013${MAX_TIMEOUT_MS}, got ${timeoutMs}`
60395
+ };
60396
+ }
60397
+ if (maxResponseBytes <= 0) {
60398
+ return { ok: false, error: `http.request: maxResponseBytes must be positive, got ${maxResponseBytes}` };
60399
+ }
60400
+ let url2;
60401
+ let body;
60402
+ let headers;
60403
+ try {
60404
+ url2 = resolveTemplate(rawUrl, context3.vars);
60405
+ body = rawBody !== undefined ? resolveTemplate(rawBody, context3.vars) : undefined;
60406
+ headers = {};
60407
+ for (const [key, value] of Object.entries(rawHeaders)) {
60408
+ if (!HEADER_NAME_RE.test(key)) {
60409
+ throw new Error(`invalid header name: ${JSON.stringify(key)}`);
60410
+ }
60411
+ if (!HEADER_VALUE_RE.test(value)) {
60412
+ throw new Error(`invalid header value for ${JSON.stringify(key)}`);
60413
+ }
60414
+ headers[key] = resolveTemplate(value, context3.vars);
60415
+ }
60416
+ } catch (err) {
60417
+ return { ok: false, error: `http.request: ${err.message}` };
60418
+ }
60419
+ let parsed;
60420
+ try {
60421
+ parsed = new URL(url2);
60422
+ } catch {
60423
+ return { ok: false, error: redactHeaders(`http.request: invalid URL: ${url2}`) };
60424
+ }
60425
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
60426
+ return {
60427
+ ok: false,
60428
+ error: `http.request: only http/https schemes allowed, got: ${parsed.protocol.replace(":", "")}`
60429
+ };
60430
+ }
60431
+ if (parsed.username || parsed.password) {
60432
+ return { ok: false, error: `http.request: URLs with embedded credentials are not allowed` };
60433
+ }
60434
+ if (this.allowlist.size === 0) {
60435
+ return {
60436
+ ok: false,
60437
+ error: `http.request: no host allowlist configured \u2014 outbound HTTP is denied by default`
60438
+ };
60439
+ }
60440
+ const origin2 = parsed.origin;
60441
+ const hostname3 = parsed.hostname;
60442
+ if (!this.allowlist.has(origin2) && !this.allowlist.has(hostname3)) {
60443
+ return {
60444
+ ok: false,
60445
+ error: `http.request: host not in allowlist: ${hostname3}`
60446
+ };
60447
+ }
60448
+ if (isPrivateHost(hostname3) && !this.allowlist.has(hostname3) && !this.allowlist.has(origin2)) {
60449
+ return {
60450
+ ok: false,
60451
+ error: `http.request: private/internal host not allowed unless explicitly in allowlist: ${hostname3}`
60452
+ };
60453
+ }
60454
+ let rawResponse;
60455
+ try {
60456
+ rawResponse = await this.requester.rawRequest(method, url2, body, {
60457
+ headers,
60458
+ timeout: timeoutMs,
60459
+ redirect: redirect ?? "manual",
60460
+ maxResponseBytes
60461
+ });
60462
+ } catch (err) {
60463
+ const message = err instanceof Error ? err.message : String(err);
60464
+ return { ok: false, error: redactHeaders(`http.request: ${message}`) };
60465
+ }
60466
+ const status = rawResponse.status;
60467
+ const ok = !failOnStatus.includes(status);
60468
+ const setVars = {};
60469
+ if (statusVar)
60470
+ setVars[statusVar] = String(status);
60471
+ if (bodyVar)
60472
+ setVars[bodyVar] = rawResponse.body;
60473
+ if (headersVar)
60474
+ setVars[headersVar] = JSON.stringify(rawResponse.headers);
60475
+ return {
60476
+ ok,
60477
+ data: { status, headers: rawResponse.headers, body: rawResponse.body },
60478
+ error: ok ? undefined : `http.request: status ${status} is in failOnStatus`,
60479
+ setVars: Object.keys(setVars).length > 0 ? setVars : undefined
60480
+ };
60481
+ }
60482
+ }
60483
+ function asRequiredString(value, name) {
60484
+ if (typeof value !== "string" || value.length === 0) {
60485
+ throw new Error(`${name} is required`);
60486
+ }
60487
+ return value;
60488
+ }
60489
+ function asOptionalString2(value) {
60490
+ if (value === undefined || value === null)
60491
+ return;
60492
+ return String(value);
60493
+ }
60494
+ function asNumber2(value) {
60495
+ if (typeof value !== "number" || Number.isNaN(value))
60496
+ return;
60497
+ return value;
60498
+ }
60499
+ function asRecord(value) {
60500
+ if (value === undefined || value === null)
60501
+ return;
60502
+ if (typeof value !== "object" || Array.isArray(value))
60503
+ return;
60504
+ const record2 = value;
60505
+ const result = {};
60506
+ for (const [key, val] of Object.entries(record2)) {
60507
+ if (typeof val === "string") {
60508
+ result[key] = val;
60509
+ }
60510
+ }
60511
+ return result;
60512
+ }
60513
+ function asNumberArray(value) {
60514
+ if (!Array.isArray(value))
60515
+ return [];
60516
+ return value.filter((v) => typeof v === "number" && !Number.isNaN(v));
60517
+ }
60518
+
60519
+ // ../../packages/app/src/workflow/utils.ts
60520
+ var identity5 = (s) => s;
60521
+ var NO_COLOR = {
60522
+ enabled: false,
60523
+ dim: identity5,
60524
+ red: identity5,
60525
+ green: identity5,
60526
+ yellow: identity5,
60527
+ cyan: identity5
60528
+ };
60529
+
60530
+ // ../../packages/app/src/workflow/actions/rule-check.ts
60531
+ var KIND8 = "rule.check";
60532
+
60533
+ class RuleCheckActionRunner {
60534
+ kind = KIND8;
60535
+ ruleService;
60536
+ constructor(ruleService) {
60537
+ this.ruleService = ruleService;
60538
+ }
60539
+ async execute(options, _context) {
60540
+ const preset = asString5(options.preset) ?? "recommended-pre-check";
60541
+ const rule = asString5(options.rule);
60542
+ const failOn = asString5(options.failOn) ?? "error";
60543
+ const result = await this.ruleService.evaluate({
60544
+ preset,
60545
+ failOn,
60546
+ ...rule !== undefined ? { rule } : {},
60547
+ json: true,
60548
+ verbose: false,
60549
+ color: NO_COLOR,
60550
+ fixMode: "none"
60551
+ });
60552
+ const ok = result.exitCode === 0;
60553
+ return {
60554
+ ok,
60555
+ data: {
60556
+ findings: result.findings,
60557
+ preset: result.preset,
60558
+ ruleCount: result.ruleCount
60559
+ },
60560
+ error: ok ? undefined : `rule.check failed: ${result.findings.length} finding(s) at/above ${failOn}`
60561
+ };
60562
+ }
60563
+ }
60564
+ function asString5(value) {
60565
+ if (value === undefined || value === null)
60566
+ return;
60567
+ return String(value);
60568
+ }
60569
+
60570
+ // ../../packages/app/src/workflow/builtins.ts
60571
+ function registerSpurBuiltins(host, options) {
60572
+ const fileSystem = options.fileSystem ?? createNodeFileSystem();
60573
+ host.registerAction(new AgentRunActionRunner(options.agentService), "builtin");
60574
+ host.registerAction(new RuleCheckActionRunner(options.ruleService), "builtin");
60575
+ host.registerAction(new FileExistsActionRunner(fileSystem), "builtin");
60576
+ host.registerAction(new FileReadActionRunner(fileSystem), "builtin");
60577
+ host.registerAction(new HitlConfirmActionRunner(options.hitlResponder), "builtin");
60578
+ host.registerAction(new HitlSelectActionRunner(options.hitlResponder), "builtin");
60579
+ host.registerAction(new HitlInputActionRunner(options.hitlResponder), "builtin");
60580
+ if (options.httpRequester) {
60581
+ host.registerAction(new HttpRequestActionRunner(options.httpRequester, options.hostAllowlist ?? new Set), "builtin");
60582
+ }
60583
+ }
60584
+
60585
+ // ../../packages/app/src/services/workflow-service.ts
59894
60586
  class WorkflowAppService {
59895
60587
  ctx;
59896
60588
  constructor(ctx) {
@@ -59915,11 +60607,12 @@ class WorkflowAppService {
59915
60607
  };
59916
60608
  }
59917
60609
  }
59918
- async run(file2, runId) {
60610
+ async run(file2, opts = {}) {
59919
60611
  const svc = await this.createEngineService();
59920
60612
  const result = await svc.runFile(file2, {
59921
60613
  workdir: this.ctx.cwd,
59922
- runId: runId ?? crypto.randomUUID()
60614
+ runId: opts.runId ?? crypto.randomUUID(),
60615
+ ...opts.vars ? { vars: opts.vars } : {}
59923
60616
  });
59924
60617
  return result;
59925
60618
  }
@@ -59929,7 +60622,15 @@ class WorkflowAppService {
59929
60622
  return { runs: runs2 };
59930
60623
  }
59931
60624
  async createEngineService() {
59932
- return new WorkflowService(createDefaultWorkflowEngineHost(), new DbWorkflowPersistenceAdapter(await this.ctx.getDb()));
60625
+ const host = createDefaultWorkflowEngineHost();
60626
+ registerSpurBuiltins(host, {
60627
+ agentService: this.ctx.agentService(),
60628
+ ruleService: this.ctx.ruleService(),
60629
+ hitlResponder: this.ctx.hitlResponder(),
60630
+ httpRequester: this.ctx.httpRequester?.(),
60631
+ hostAllowlist: this.ctx.hostAllowlist?.()
60632
+ });
60633
+ return new WorkflowService(host, new DbWorkflowPersistenceAdapter(await this.ctx.getDb()));
59933
60634
  }
59934
60635
  }
59935
60636
  async function fileExists(path8) {
@@ -60188,7 +60889,7 @@ import { join as join6, resolve as resolve3 } from "path";
60188
60889
  var CLI_CONFIG = {
60189
60890
  binaryName: "spur",
60190
60891
  binaryLabel: "spur",
60191
- binaryVersion: "0.2.3",
60892
+ binaryVersion: "0.2.5",
60192
60893
  configDir: ".spur",
60193
60894
  configFile: ".spur/config.yaml",
60194
60895
  databaseFile: ".spur/spur.db"
@@ -60740,11 +61441,39 @@ function formatStatusLine(agent) {
60740
61441
  }
60741
61442
 
60742
61443
  // src/commands/workflow.ts
61444
+ function parseVars(raw) {
61445
+ if (raw === undefined) {
61446
+ return;
61447
+ }
61448
+ let parsed;
61449
+ try {
61450
+ parsed = JSON.parse(raw);
61451
+ } catch {
61452
+ throw new Error(`--vars must be a valid JSON object: ${raw}`);
61453
+ }
61454
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
61455
+ throw new Error(`--vars must be a JSON object, e.g. '{"taskId":"0042"}'`);
61456
+ }
61457
+ const vars = {};
61458
+ for (const [key, value] of Object.entries(parsed)) {
61459
+ if (typeof value !== "string") {
61460
+ throw new Error(`--vars values must be strings; "${key}" is ${typeof value}`);
61461
+ }
61462
+ vars[key] = value;
61463
+ }
61464
+ return vars;
61465
+ }
60743
61466
  function registerWorkflowCommand(program2, context3) {
61467
+ const makeSvc = (json2) => new WorkflowAppService({
61468
+ cwd: context3.cwd,
61469
+ getDb: () => context3.getDb(),
61470
+ agentService: () => context3.agentService(),
61471
+ ruleService: () => context3.ruleService(),
61472
+ hitlResponder: () => context3.hitlResponder(json2)
61473
+ });
60744
61474
  const workflow = program2.command("workflow").summary("validate and execute workflow YAML files");
60745
61475
  workflow.command("validate").description("Validate a workflow definition.").argument("<file>", "Workflow YAML file").option("--no-schema", "Skip schema validation").option("--json", "Output machine-readable JSON where supported").action(async (file2, options) => {
60746
- const svc = new WorkflowAppService({ cwd: context3.cwd, getDb: () => context3.getDb() });
60747
- const result = await svc.validate(file2, { validateSchema: options.schema });
61476
+ const result = await makeSvc().validate(file2, { validateSchema: options.schema });
60748
61477
  if (options.json) {
60749
61478
  context3.output.write(toJson2(result));
60750
61479
  } else if (result.valid) {
@@ -60756,15 +61485,14 @@ ${result.errors.map((m2) => ` - ${m2}`).join(`
60756
61485
  }
60757
61486
  context3.setExitCode(result.valid ? 0 : 1);
60758
61487
  });
60759
- workflow.command("run").description("Execute a workflow definition.").argument("<file>", "Workflow YAML file").option("--run-id <id>", "Persisted run id for workflow run").option("--json", "Output machine-readable JSON where supported").action(async (file2, options) => {
60760
- const svc = new WorkflowAppService({ cwd: context3.cwd, getDb: () => context3.getDb() });
60761
- const result = await svc.run(file2, options.runId || undefined);
61488
+ workflow.command("run").description("Execute a workflow definition.").argument("<file>", "Workflow YAML file").option("--run-id <id>", "Persisted run id for workflow run").option("--vars <json>", `Per-run variable overrides as a JSON object, e.g. '{"taskId":"0042"}'`).option("--json", "Output machine-readable JSON where supported").action(async (file2, options) => {
61489
+ const vars = parseVars(options.vars);
61490
+ const result = await makeSvc(options.json).run(file2, { runId: options.runId || undefined, vars });
60762
61491
  context3.output.write(options.json ? toJson2(result) : `workflow ${result.status}: ${result.workflowName} -> ${result.finalState}`);
60763
61492
  context3.setExitCode(result.status === "done" ? 0 : 1);
60764
61493
  });
60765
61494
  workflow.command("list").description("List persisted workflow runs.").option("--json", "Output machine-readable JSON where supported").action(async (options) => {
60766
- const svc = new WorkflowAppService({ cwd: context3.cwd, getDb: () => context3.getDb() });
60767
- const { runs: runs2 } = await svc.list();
61495
+ const { runs: runs2 } = await makeSvc().list();
60768
61496
  if (options.json) {
60769
61497
  context3.output.write(toJson2({ runs: runs2 }));
60770
61498
  } else {
@@ -60982,7 +61710,1388 @@ var SpurAppConfigSchema = exports_external.object({
60982
61710
 
60983
61711
  // src/context.ts
60984
61712
  import { dirname as dirname5, join as join10, resolve as resolve4 } from "path";
61713
+ import { isatty as isatty3 } from "tty";
60985
61714
  init_dist3();
61715
+
61716
+ // ../../node_modules/.bun/@clack+core@1.4.1/node_modules/@clack/core/dist/index.mjs
61717
+ import { styleText } from "util";
61718
+ import { stdout, stdin } from "process";
61719
+ import l__default from "readline";
61720
+
61721
+ // ../../node_modules/.bun/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
61722
+ var getCodePointsLength = (() => {
61723
+ const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
61724
+ return (input) => {
61725
+ let surrogatePairsNr = 0;
61726
+ SURROGATE_PAIR_RE.lastIndex = 0;
61727
+ while (SURROGATE_PAIR_RE.test(input)) {
61728
+ surrogatePairsNr += 1;
61729
+ }
61730
+ return input.length - surrogatePairsNr;
61731
+ };
61732
+ })();
61733
+ var isFullWidth = (x) => {
61734
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
61735
+ };
61736
+ var isWideNotCJKTNotEmoji = (x) => {
61737
+ return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
61738
+ };
61739
+
61740
+ // ../../node_modules/.bun/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
61741
+ var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
61742
+ var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
61743
+ var CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu;
61744
+ var TAB_RE = /\t{1,1000}/y;
61745
+ var EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
61746
+ var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
61747
+ var MODIFIER_RE = /\p{M}+/gu;
61748
+ var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
61749
+ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
61750
+ const LIMIT = truncationOptions.limit ?? Infinity;
61751
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
61752
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
61753
+ const ANSI_WIDTH = 0;
61754
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
61755
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
61756
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
61757
+ const FULL_WIDTH_WIDTH = 2;
61758
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
61759
+ const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
61760
+ const PARSE_BLOCKS = [
61761
+ [LATIN_RE, REGULAR_WIDTH],
61762
+ [ANSI_RE, ANSI_WIDTH],
61763
+ [CONTROL_RE, CONTROL_WIDTH],
61764
+ [TAB_RE, TAB_WIDTH],
61765
+ [EMOJI_RE, EMOJI_WIDTH],
61766
+ [CJKT_WIDE_RE, WIDE_WIDTH]
61767
+ ];
61768
+ let indexPrev = 0;
61769
+ let index2 = 0;
61770
+ let length = input.length;
61771
+ let lengthExtra = 0;
61772
+ let truncationEnabled = false;
61773
+ let truncationIndex = length;
61774
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
61775
+ let unmatchedStart = 0;
61776
+ let unmatchedEnd = 0;
61777
+ let width = 0;
61778
+ let widthExtra = 0;
61779
+ outer:
61780
+ while (true) {
61781
+ if (unmatchedEnd > unmatchedStart || index2 >= length && index2 > indexPrev) {
61782
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index2);
61783
+ lengthExtra = 0;
61784
+ for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
61785
+ const codePoint = char.codePointAt(0) || 0;
61786
+ if (isFullWidth(codePoint)) {
61787
+ widthExtra = FULL_WIDTH_WIDTH;
61788
+ } else if (isWideNotCJKTNotEmoji(codePoint)) {
61789
+ widthExtra = WIDE_WIDTH;
61790
+ } else {
61791
+ widthExtra = REGULAR_WIDTH;
61792
+ }
61793
+ if (width + widthExtra > truncationLimit) {
61794
+ truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
61795
+ }
61796
+ if (width + widthExtra > LIMIT) {
61797
+ truncationEnabled = true;
61798
+ break outer;
61799
+ }
61800
+ lengthExtra += char.length;
61801
+ width += widthExtra;
61802
+ }
61803
+ unmatchedStart = unmatchedEnd = 0;
61804
+ }
61805
+ if (index2 >= length) {
61806
+ break outer;
61807
+ }
61808
+ for (let i2 = 0, l = PARSE_BLOCKS.length;i2 < l; i2++) {
61809
+ const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i2];
61810
+ BLOCK_RE.lastIndex = index2;
61811
+ if (BLOCK_RE.test(input)) {
61812
+ lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index2, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index2;
61813
+ widthExtra = lengthExtra * BLOCK_WIDTH;
61814
+ if (width + widthExtra > truncationLimit) {
61815
+ truncationIndex = Math.min(truncationIndex, index2 + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
61816
+ }
61817
+ if (width + widthExtra > LIMIT) {
61818
+ truncationEnabled = true;
61819
+ break outer;
61820
+ }
61821
+ width += widthExtra;
61822
+ unmatchedStart = indexPrev;
61823
+ unmatchedEnd = index2;
61824
+ index2 = indexPrev = BLOCK_RE.lastIndex;
61825
+ continue outer;
61826
+ }
61827
+ }
61828
+ index2 += 1;
61829
+ }
61830
+ return {
61831
+ width: truncationEnabled ? truncationLimit : width,
61832
+ index: truncationEnabled ? truncationIndex : length,
61833
+ truncated: truncationEnabled,
61834
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
61835
+ };
61836
+ };
61837
+ var dist_default = getStringTruncatedWidth;
61838
+
61839
+ // ../../node_modules/.bun/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
61840
+ var NO_TRUNCATION2 = {
61841
+ limit: Infinity,
61842
+ ellipsis: "",
61843
+ ellipsisWidth: 0
61844
+ };
61845
+ var fastStringWidth = (input, options = {}) => {
61846
+ return dist_default(input, NO_TRUNCATION2, options).width;
61847
+ };
61848
+ var dist_default2 = fastStringWidth;
61849
+
61850
+ // ../../node_modules/.bun/fast-wrap-ansi@0.2.2/node_modules/fast-wrap-ansi/lib/main.js
61851
+ var ESC = "\x1B";
61852
+ var CSI = "\x9B";
61853
+ var END_CODE = 39;
61854
+ var ANSI_ESCAPE_BELL = "\x07";
61855
+ var ANSI_CSI = "[";
61856
+ var ANSI_OSC = "]";
61857
+ var ANSI_SGR_TERMINATOR = "m";
61858
+ var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
61859
+ var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
61860
+ var getClosingCode = (openingCode) => {
61861
+ if (openingCode >= 30 && openingCode <= 37)
61862
+ return 39;
61863
+ if (openingCode >= 90 && openingCode <= 97)
61864
+ return 39;
61865
+ if (openingCode >= 40 && openingCode <= 47)
61866
+ return 49;
61867
+ if (openingCode >= 100 && openingCode <= 107)
61868
+ return 49;
61869
+ if (openingCode === 1 || openingCode === 2)
61870
+ return 22;
61871
+ if (openingCode === 3)
61872
+ return 23;
61873
+ if (openingCode === 4)
61874
+ return 24;
61875
+ if (openingCode === 7)
61876
+ return 27;
61877
+ if (openingCode === 8)
61878
+ return 28;
61879
+ if (openingCode === 9)
61880
+ return 29;
61881
+ if (openingCode === 0)
61882
+ return 0;
61883
+ return;
61884
+ };
61885
+ var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
61886
+ var wrapAnsiHyperlink = (url2) => `${ESC}${ANSI_ESCAPE_LINK}${url2}${ANSI_ESCAPE_BELL}`;
61887
+ var wrapWord = (rows, word, columns2) => {
61888
+ const characters = word[Symbol.iterator]();
61889
+ let isInsideEscape = false;
61890
+ let isInsideLinkEscape = false;
61891
+ let lastRow = rows.at(-1);
61892
+ let visible = lastRow === undefined ? 0 : dist_default2(lastRow);
61893
+ let currentCharacter = characters.next();
61894
+ let nextCharacter = characters.next();
61895
+ let rawCharacterIndex = 0;
61896
+ while (!currentCharacter.done) {
61897
+ const character = currentCharacter.value;
61898
+ const characterLength = dist_default2(character);
61899
+ if (visible + characterLength <= columns2) {
61900
+ rows[rows.length - 1] += character;
61901
+ } else {
61902
+ rows.push(character);
61903
+ visible = 0;
61904
+ }
61905
+ if (character === ESC || character === CSI) {
61906
+ isInsideEscape = true;
61907
+ isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
61908
+ }
61909
+ if (isInsideEscape) {
61910
+ if (isInsideLinkEscape) {
61911
+ if (character === ANSI_ESCAPE_BELL) {
61912
+ isInsideEscape = false;
61913
+ isInsideLinkEscape = false;
61914
+ }
61915
+ } else if (character === ANSI_SGR_TERMINATOR) {
61916
+ isInsideEscape = false;
61917
+ }
61918
+ } else {
61919
+ visible += characterLength;
61920
+ if (visible === columns2 && !nextCharacter.done) {
61921
+ rows.push("");
61922
+ visible = 0;
61923
+ }
61924
+ }
61925
+ currentCharacter = nextCharacter;
61926
+ nextCharacter = characters.next();
61927
+ rawCharacterIndex += character.length;
61928
+ }
61929
+ lastRow = rows.at(-1);
61930
+ if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
61931
+ rows[rows.length - 2] += rows.pop();
61932
+ }
61933
+ };
61934
+ var stringVisibleTrimSpacesRight = (string4) => {
61935
+ const words = string4.split(" ");
61936
+ let last = words.length;
61937
+ while (last) {
61938
+ if (dist_default2(words[last - 1])) {
61939
+ break;
61940
+ }
61941
+ last--;
61942
+ }
61943
+ if (last === words.length) {
61944
+ return string4;
61945
+ }
61946
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
61947
+ };
61948
+ var exec = (string4, columns2, options = {}) => {
61949
+ if (options.trim !== false && string4.trim() === "") {
61950
+ return "";
61951
+ }
61952
+ let returnValue = "";
61953
+ let escapeCode;
61954
+ let escapeUrl;
61955
+ const words = string4.split(" ");
61956
+ let rows = [""];
61957
+ let rowLength = 0;
61958
+ for (let index2 = 0;index2 < words.length; index2++) {
61959
+ const word = words[index2];
61960
+ if (options.trim !== false) {
61961
+ const row = rows.at(-1) ?? "";
61962
+ const trimmed = row.trimStart();
61963
+ if (row.length !== trimmed.length) {
61964
+ rows[rows.length - 1] = trimmed;
61965
+ rowLength = dist_default2(trimmed);
61966
+ }
61967
+ }
61968
+ if (index2 !== 0) {
61969
+ if (rowLength >= columns2 && (options.wordWrap === false || options.trim === false)) {
61970
+ rows.push("");
61971
+ rowLength = 0;
61972
+ }
61973
+ if (rowLength || options.trim === false) {
61974
+ rows[rows.length - 1] += " ";
61975
+ rowLength++;
61976
+ }
61977
+ }
61978
+ const wordLength = dist_default2(word);
61979
+ if (options.hard && wordLength > columns2) {
61980
+ const remainingColumns = columns2 - rowLength;
61981
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns2);
61982
+ const breaksStartingNextLine = Math.floor((wordLength - 1) / columns2);
61983
+ if (breaksStartingNextLine < breaksStartingThisLine) {
61984
+ rows.push("");
61985
+ }
61986
+ wrapWord(rows, word, columns2);
61987
+ rowLength = dist_default2(rows.at(-1) ?? "");
61988
+ continue;
61989
+ }
61990
+ if (rowLength + wordLength > columns2 && rowLength && wordLength) {
61991
+ if (options.wordWrap === false && rowLength < columns2) {
61992
+ wrapWord(rows, word, columns2);
61993
+ rowLength = dist_default2(rows.at(-1) ?? "");
61994
+ continue;
61995
+ }
61996
+ rows.push("");
61997
+ rowLength = 0;
61998
+ }
61999
+ if (rowLength + wordLength > columns2 && options.wordWrap === false) {
62000
+ wrapWord(rows, word, columns2);
62001
+ rowLength = dist_default2(rows.at(-1) ?? "");
62002
+ continue;
62003
+ }
62004
+ rows[rows.length - 1] += word;
62005
+ rowLength += wordLength;
62006
+ }
62007
+ if (options.trim !== false) {
62008
+ rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
62009
+ }
62010
+ const preString = rows.join(`
62011
+ `);
62012
+ let inSurrogate = false;
62013
+ for (let i2 = 0;i2 < preString.length; i2++) {
62014
+ const character = preString[i2];
62015
+ returnValue += character;
62016
+ if (!inSurrogate) {
62017
+ inSurrogate = character >= "\uD800" && character <= "\uDBFF";
62018
+ if (inSurrogate) {
62019
+ continue;
62020
+ }
62021
+ } else {
62022
+ inSurrogate = false;
62023
+ }
62024
+ if (character === ESC || character === CSI) {
62025
+ GROUP_REGEX.lastIndex = i2 + 1;
62026
+ const groupsResult = GROUP_REGEX.exec(preString);
62027
+ const groups = groupsResult?.groups;
62028
+ if (groups?.code !== undefined) {
62029
+ const code = Number.parseFloat(groups.code);
62030
+ escapeCode = code === END_CODE ? undefined : code;
62031
+ } else if (groups?.uri !== undefined) {
62032
+ escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
62033
+ }
62034
+ }
62035
+ if (preString[i2 + 1] === `
62036
+ `) {
62037
+ if (escapeUrl) {
62038
+ returnValue += wrapAnsiHyperlink("");
62039
+ }
62040
+ const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
62041
+ if (escapeCode && closingCode) {
62042
+ returnValue += wrapAnsiCode(closingCode);
62043
+ }
62044
+ } else if (character === `
62045
+ `) {
62046
+ if (escapeCode && getClosingCode(escapeCode)) {
62047
+ returnValue += wrapAnsiCode(escapeCode);
62048
+ }
62049
+ if (escapeUrl) {
62050
+ returnValue += wrapAnsiHyperlink(escapeUrl);
62051
+ }
62052
+ }
62053
+ }
62054
+ return returnValue;
62055
+ };
62056
+ var CRLF_OR_LF = /\r?\n/;
62057
+ function wrapAnsi(string4, columns2, options) {
62058
+ return String(string4).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns2, options)).join(`
62059
+ `);
62060
+ }
62061
+
62062
+ // ../../node_modules/.bun/@clack+core@1.4.1/node_modules/@clack/core/dist/index.mjs
62063
+ var import_sisteransi = __toESM(require_src9(), 1);
62064
+ function findCursor(s, o2, l) {
62065
+ if (!l.some((r) => !r.disabled))
62066
+ return s;
62067
+ const t = s + o2, n2 = Math.max(l.length - 1, 0), e = t < 0 ? n2 : t > n2 ? 0 : t;
62068
+ return l[e].disabled ? findCursor(e, o2 < 0 ? -1 : 1, l) : e;
62069
+ }
62070
+ function findTextCursor(s, o2, l, i2) {
62071
+ const t = i2.split(`
62072
+ `);
62073
+ let n2 = 0, e = s;
62074
+ for (const r of t) {
62075
+ if (e <= r.length)
62076
+ break;
62077
+ e -= r.length + 1, n2++;
62078
+ }
62079
+ for (n2 = Math.max(0, Math.min(t.length - 1, n2 + l)), e = Math.min(e, t[n2].length) + o2;e < 0 && n2 > 0; )
62080
+ n2--, e += t[n2].length + 1;
62081
+ for (;e > t[n2].length && n2 < t.length - 1; )
62082
+ e -= t[n2].length + 1, n2++;
62083
+ e = Math.max(0, Math.min(t[n2].length, e));
62084
+ let h2 = 0;
62085
+ for (let r = 0;r < n2; r++)
62086
+ h2 += t[r].length + 1;
62087
+ return h2 + e;
62088
+ }
62089
+ var a$2 = ["up", "down", "left", "right", "space", "enter", "cancel"];
62090
+ var t = [
62091
+ "January",
62092
+ "February",
62093
+ "March",
62094
+ "April",
62095
+ "May",
62096
+ "June",
62097
+ "July",
62098
+ "August",
62099
+ "September",
62100
+ "October",
62101
+ "November",
62102
+ "December"
62103
+ ];
62104
+ var settings = {
62105
+ actions: new Set(a$2),
62106
+ aliases: /* @__PURE__ */ new Map([
62107
+ ["k", "up"],
62108
+ ["j", "down"],
62109
+ ["h", "left"],
62110
+ ["l", "right"],
62111
+ ["\x03", "cancel"],
62112
+ ["escape", "cancel"]
62113
+ ]),
62114
+ messages: {
62115
+ cancel: "Canceled",
62116
+ error: "Something went wrong"
62117
+ },
62118
+ withGuide: true,
62119
+ date: {
62120
+ monthNames: [...t],
62121
+ messages: {
62122
+ required: "Please enter a valid date",
62123
+ invalidMonth: "There are only 12 months in a year",
62124
+ invalidDay: (n2, e) => `There are only ${n2} days in ${e}`,
62125
+ afterMin: (n2) => `Date must be on or after ${n2.toISOString().slice(0, 10)}`,
62126
+ beforeMax: (n2) => `Date must be on or before ${n2.toISOString().slice(0, 10)}`
62127
+ }
62128
+ }
62129
+ };
62130
+ function isActionKey(n2, e) {
62131
+ if (typeof n2 == "string")
62132
+ return settings.aliases.get(n2) === e;
62133
+ for (const s of n2)
62134
+ if (s !== undefined && isActionKey(s, e))
62135
+ return true;
62136
+ return false;
62137
+ }
62138
+ function diffLines(i2, s) {
62139
+ if (i2 === s)
62140
+ return;
62141
+ const e = i2.split(`
62142
+ `), t2 = s.split(`
62143
+ `), r = Math.max(e.length, t2.length), f2 = [];
62144
+ for (let n2 = 0;n2 < r; n2++)
62145
+ e[n2] !== t2[n2] && f2.push(n2);
62146
+ return {
62147
+ lines: f2,
62148
+ numLinesBefore: e.length,
62149
+ numLinesAfter: t2.length,
62150
+ numLines: r
62151
+ };
62152
+ }
62153
+ var R = globalThis.process.platform.startsWith("win");
62154
+ var CANCEL_SYMBOL = Symbol("clack:cancel");
62155
+ function isCancel(e) {
62156
+ return e === CANCEL_SYMBOL;
62157
+ }
62158
+ function setRawMode(e, r) {
62159
+ const o2 = e;
62160
+ o2.isTTY && o2.setRawMode(r);
62161
+ }
62162
+ var getColumns = (e) => ("columns" in e) && typeof e.columns == "number" ? e.columns : 80;
62163
+ var getRows = (e) => ("rows" in e) && typeof e.rows == "number" ? e.rows : 20;
62164
+ function wrapTextWithPrefix(e, r, o2, t2 = o2, s = o2, n2) {
62165
+ const f2 = getColumns(e ?? stdout);
62166
+ return wrapAnsi(r, f2 - o2.length, {
62167
+ hard: true,
62168
+ trim: false
62169
+ }).split(`
62170
+ `).map((c4, i2, m2) => {
62171
+ const d = n2 ? n2(c4, i2) : c4;
62172
+ return i2 === 0 ? `${t2}${d}` : i2 === m2.length - 1 ? `${s}${d}` : `${o2}${d}`;
62173
+ }).join(`
62174
+ `);
62175
+ }
62176
+ function runValidation(e, n2) {
62177
+ if ("~standard" in e) {
62178
+ const a2 = e["~standard"].validate(n2);
62179
+ if (a2 instanceof Promise)
62180
+ throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
62181
+ return a2.issues?.at(0)?.message;
62182
+ }
62183
+ return e(n2);
62184
+ }
62185
+
62186
+ class V {
62187
+ input;
62188
+ output;
62189
+ _abortSignal;
62190
+ rl;
62191
+ opts;
62192
+ _render;
62193
+ _track = false;
62194
+ _prevFrame = "";
62195
+ _subscribers = /* @__PURE__ */ new Map;
62196
+ _cursor = 0;
62197
+ state = "initial";
62198
+ error = "";
62199
+ value;
62200
+ userInput = "";
62201
+ constructor(t2, e = true) {
62202
+ const { input: i2 = stdin, output: n2 = stdout, render: s, signal: r, ...o2 } = t2;
62203
+ this.opts = o2, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r, this.input = i2, this.output = n2;
62204
+ }
62205
+ unsubscribe() {
62206
+ this._subscribers.clear();
62207
+ }
62208
+ setSubscriber(t2, e) {
62209
+ const i2 = this._subscribers.get(t2) ?? [];
62210
+ i2.push(e), this._subscribers.set(t2, i2);
62211
+ }
62212
+ on(t2, e) {
62213
+ this.setSubscriber(t2, { cb: e });
62214
+ }
62215
+ once(t2, e) {
62216
+ this.setSubscriber(t2, { cb: e, once: true });
62217
+ }
62218
+ emit(t2, ...e) {
62219
+ const i2 = this._subscribers.get(t2) ?? [], n2 = [];
62220
+ for (const s of i2)
62221
+ s.cb(...e), s.once && n2.push(() => i2.splice(i2.indexOf(s), 1));
62222
+ for (const s of n2)
62223
+ s();
62224
+ }
62225
+ prompt() {
62226
+ return new Promise((t2) => {
62227
+ if (this._abortSignal) {
62228
+ if (this._abortSignal.aborted)
62229
+ return this.state = "cancel", this.close(), t2(CANCEL_SYMBOL);
62230
+ this._abortSignal.addEventListener("abort", () => {
62231
+ this.state = "cancel", this.close();
62232
+ }, { once: true });
62233
+ }
62234
+ this.rl = l__default.createInterface({
62235
+ input: this.input,
62236
+ tabSize: 2,
62237
+ prompt: "",
62238
+ escapeCodeTimeout: 50,
62239
+ terminal: true
62240
+ }), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
62241
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
62242
+ }), this.once("cancel", () => {
62243
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
62244
+ });
62245
+ });
62246
+ }
62247
+ _isActionKey(t2, e) {
62248
+ return t2 === "\t";
62249
+ }
62250
+ _shouldSubmit(t2, e) {
62251
+ return true;
62252
+ }
62253
+ _setValue(t2) {
62254
+ this.value = t2, this.emit("value", this.value);
62255
+ }
62256
+ _setUserInput(t2, e) {
62257
+ this.userInput = t2 ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
62258
+ }
62259
+ _clearUserInput() {
62260
+ this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
62261
+ }
62262
+ onKeypress(t2, e) {
62263
+ if (this._track && e.name !== "return" && (e.name && this._isActionKey(t2, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t2 && (t2.toLowerCase() === "y" || t2.toLowerCase() === "n") && this.emit("confirm", t2.toLowerCase() === "y"), this.emit("key", t2, e), e?.name === "return" && this._shouldSubmit(t2, e)) {
62264
+ if (this.opts.validate) {
62265
+ const i2 = runValidation(this.opts.validate, this.value);
62266
+ i2 && (this.error = i2 instanceof Error ? i2.message : i2, this.state = "error", this.rl?.write(this.userInput));
62267
+ }
62268
+ this.state !== "error" && (this.state = "submit");
62269
+ }
62270
+ isActionKey([t2, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
62271
+ }
62272
+ close() {
62273
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
62274
+ `), setRawMode(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
62275
+ }
62276
+ restoreCursor() {
62277
+ const t2 = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
62278
+ `).length - 1;
62279
+ this.output.write(import_sisteransi.cursor.move(-999, t2 * -1));
62280
+ }
62281
+ render() {
62282
+ const t2 = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
62283
+ hard: true,
62284
+ trim: false
62285
+ });
62286
+ if (t2 !== this._prevFrame) {
62287
+ if (this.state === "initial")
62288
+ this.output.write(import_sisteransi.cursor.hide);
62289
+ else {
62290
+ const e = diffLines(this._prevFrame, t2), i2 = getRows(this.output);
62291
+ if (this.restoreCursor(), e) {
62292
+ const n2 = Math.max(0, e.numLinesAfter - i2), s = Math.max(0, e.numLinesBefore - i2);
62293
+ let r = e.lines.find((o2) => o2 >= n2);
62294
+ if (r === undefined) {
62295
+ this._prevFrame = t2;
62296
+ return;
62297
+ }
62298
+ if (e.lines.length === 1) {
62299
+ this.output.write(import_sisteransi.cursor.move(0, r - s)), this.output.write(import_sisteransi.erase.lines(1));
62300
+ const o2 = t2.split(`
62301
+ `);
62302
+ this.output.write(o2[r]), this._prevFrame = t2, this.output.write(import_sisteransi.cursor.move(0, o2.length - r - 1));
62303
+ return;
62304
+ } else if (e.lines.length > 1) {
62305
+ if (n2 < s)
62306
+ r = n2;
62307
+ else {
62308
+ const h2 = r - s;
62309
+ h2 > 0 && this.output.write(import_sisteransi.cursor.move(0, h2));
62310
+ }
62311
+ this.output.write(import_sisteransi.erase.down());
62312
+ const f2 = t2.split(`
62313
+ `).slice(r);
62314
+ this.output.write(f2.join(`
62315
+ `)), this._prevFrame = t2;
62316
+ return;
62317
+ }
62318
+ }
62319
+ this.output.write(import_sisteransi.erase.down());
62320
+ }
62321
+ this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
62322
+ }
62323
+ }
62324
+ }
62325
+ function p$1(l, e) {
62326
+ if (l === undefined || e.length === 0)
62327
+ return 0;
62328
+ const i2 = e.findIndex((s) => s.value === l);
62329
+ return i2 !== -1 ? i2 : 0;
62330
+ }
62331
+ function g(l, e) {
62332
+ return (e.label ?? String(e.value)).toLowerCase().includes(l.toLowerCase());
62333
+ }
62334
+ function m2(l, e) {
62335
+ if (e)
62336
+ return l ? e : e[0];
62337
+ }
62338
+ var T$1 = class T extends V {
62339
+ filteredOptions;
62340
+ multiple;
62341
+ isNavigating = false;
62342
+ selectedValues = [];
62343
+ focusedValue;
62344
+ #e = 0;
62345
+ #s = "";
62346
+ #t;
62347
+ #i;
62348
+ #n;
62349
+ get cursor() {
62350
+ return this.#e;
62351
+ }
62352
+ get userInputWithCursor() {
62353
+ if (!this.userInput)
62354
+ return styleText(["inverse", "hidden"], "_");
62355
+ if (this._cursor >= this.userInput.length)
62356
+ return `${this.userInput}\u2588`;
62357
+ const e = this.userInput.slice(0, this._cursor), [t2, ...i2] = this.userInput.slice(this._cursor);
62358
+ return `${e}${styleText("inverse", t2)}${i2.join("")}`;
62359
+ }
62360
+ get options() {
62361
+ return typeof this.#i == "function" ? this.#i() : this.#i;
62362
+ }
62363
+ constructor(e) {
62364
+ super(e), this.#i = e.options, this.#n = e.placeholder;
62365
+ const t2 = this.options;
62366
+ this.filteredOptions = [...t2], this.multiple = e.multiple === true, this.#t = typeof e.options == "function" ? e.filter : e.filter ?? g;
62367
+ let i2;
62368
+ if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i2 = e.initialValue : i2 = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i2 = [this.options[0].value]), i2)
62369
+ for (const s of i2) {
62370
+ const n2 = t2.findIndex((o2) => o2.value === s);
62371
+ n2 !== -1 && (this.toggleSelected(s), this.#e = n2);
62372
+ }
62373
+ this.focusedValue = this.options[this.#e]?.value, this.on("key", (s, n2) => this.#l(s, n2)), this.on("userInput", (s) => this.#u(s));
62374
+ }
62375
+ _isActionKey(e, t2) {
62376
+ return e === "\t" || this.multiple && this.isNavigating && t2.name === "space" && e !== undefined && e !== "";
62377
+ }
62378
+ #l(e, t2) {
62379
+ const i2 = t2.name === "up", s = t2.name === "down", n2 = t2.name === "return", o2 = this.userInput === "" || this.userInput === "\t", u2 = this.#n, h2 = this.options, f2 = u2 !== undefined && u2 !== "" && h2.some((r) => !r.disabled && (this.#t ? this.#t(u2, r) : true));
62380
+ if (t2.name === "tab" && o2 && f2) {
62381
+ this.userInput === "\t" && this._clearUserInput(), this._setUserInput(u2, true), this.isNavigating = false;
62382
+ return;
62383
+ }
62384
+ i2 || s ? (this.#e = findCursor(this.#e, i2 ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n2 ? this.value = m2(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (t2.name === "tab" || this.isNavigating && t2.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
62385
+ }
62386
+ deselectAll() {
62387
+ this.selectedValues = [];
62388
+ }
62389
+ toggleSelected(e) {
62390
+ this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((t2) => t2 !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
62391
+ }
62392
+ #u(e) {
62393
+ if (e !== this.#s) {
62394
+ this.#s = e;
62395
+ const t2 = this.options;
62396
+ e && this.#t ? this.filteredOptions = t2.filter((n2) => this.#t?.(e, n2)) : this.filteredOptions = [...t2];
62397
+ const i2 = p$1(this.focusedValue, this.filteredOptions);
62398
+ this.#e = findCursor(i2, 0, this.filteredOptions);
62399
+ const s = this.filteredOptions[this.#e];
62400
+ s && !s.disabled ? this.focusedValue = s.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
62401
+ }
62402
+ }
62403
+ };
62404
+ var _ = {
62405
+ Y: { type: "year", len: 4 },
62406
+ M: { type: "month", len: 2 },
62407
+ D: { type: "day", len: 2 }
62408
+ };
62409
+ function M(r) {
62410
+ return [...r].map((t2) => _[t2]);
62411
+ }
62412
+ function P(r) {
62413
+ const i2 = new Intl.DateTimeFormat(r, {
62414
+ year: "numeric",
62415
+ month: "2-digit",
62416
+ day: "2-digit"
62417
+ }).formatToParts(new Date(2000, 0, 15)), s = [];
62418
+ let n2 = "/";
62419
+ for (const e of i2)
62420
+ e.type === "literal" ? n2 = e.value.trim() || e.value : (e.type === "year" || e.type === "month" || e.type === "day") && s.push({ type: e.type, len: e.type === "year" ? 4 : 2 });
62421
+ return { segments: s, separator: n2 };
62422
+ }
62423
+ function p2(r) {
62424
+ return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
62425
+ }
62426
+ function f2(r) {
62427
+ return {
62428
+ year: p2(r.year),
62429
+ month: p2(r.month),
62430
+ day: p2(r.day)
62431
+ };
62432
+ }
62433
+ function c4(r, t2) {
62434
+ return new Date(r || 2001, t2 || 1, 0).getDate();
62435
+ }
62436
+ function b2(r) {
62437
+ const { year: t2, month: i2, day: s } = f2(r);
62438
+ if (!t2 || t2 < 0 || t2 > 9999 || !i2 || i2 < 1 || i2 > 12 || !s || s < 1)
62439
+ return;
62440
+ const n2 = new Date(Date.UTC(t2, i2 - 1, s));
62441
+ if (!(n2.getUTCFullYear() !== t2 || n2.getUTCMonth() !== i2 - 1 || n2.getUTCDate() !== s))
62442
+ return { year: t2, month: i2, day: s };
62443
+ }
62444
+ function C(r) {
62445
+ const t2 = b2(r);
62446
+ return t2 ? new Date(Date.UTC(t2.year, t2.month - 1, t2.day)) : undefined;
62447
+ }
62448
+ function T2(r, t2, i2, s) {
62449
+ const n2 = i2 ? {
62450
+ year: i2.getUTCFullYear(),
62451
+ month: i2.getUTCMonth() + 1,
62452
+ day: i2.getUTCDate()
62453
+ } : null, e = s ? {
62454
+ year: s.getUTCFullYear(),
62455
+ month: s.getUTCMonth() + 1,
62456
+ day: s.getUTCDate()
62457
+ } : null;
62458
+ return r === "year" ? { min: n2?.year ?? 1, max: e?.year ?? 9999 } : r === "month" ? {
62459
+ min: n2 && t2.year === n2.year ? n2.month : 1,
62460
+ max: e && t2.year === e.year ? e.month : 12
62461
+ } : {
62462
+ min: n2 && t2.year === n2.year && t2.month === n2.month ? n2.day : 1,
62463
+ max: e && t2.year === e.year && t2.month === e.month ? e.day : c4(t2.year, t2.month)
62464
+ };
62465
+ }
62466
+
62467
+ class U extends V {
62468
+ #i;
62469
+ #o;
62470
+ #t;
62471
+ #h;
62472
+ #u;
62473
+ #e = { segmentIndex: 0, positionInSegment: 0 };
62474
+ #n = true;
62475
+ #s = null;
62476
+ inlineError = "";
62477
+ get segmentCursor() {
62478
+ return { ...this.#e };
62479
+ }
62480
+ get segmentValues() {
62481
+ return { ...this.#t };
62482
+ }
62483
+ get segments() {
62484
+ return this.#i;
62485
+ }
62486
+ get separator() {
62487
+ return this.#o;
62488
+ }
62489
+ get formattedValue() {
62490
+ return this.#l(this.#t);
62491
+ }
62492
+ #l(t2) {
62493
+ return this.#i.map((i2) => t2[i2.type]).join(this.#o);
62494
+ }
62495
+ #r() {
62496
+ this._setUserInput(this.#l(this.#t)), this._setValue(C(this.#t) ?? undefined);
62497
+ }
62498
+ constructor(t2) {
62499
+ const i2 = t2.format ? { segments: M(t2.format), separator: t2.separator ?? "/" } : P(t2.locale), s = t2.separator ?? i2.separator, n2 = t2.format ? M(t2.format) : i2.segments, e = t2.initialValue ?? t2.defaultValue, m3 = e ? {
62500
+ year: String(e.getUTCFullYear()).padStart(4, "0"),
62501
+ month: String(e.getUTCMonth() + 1).padStart(2, "0"),
62502
+ day: String(e.getUTCDate()).padStart(2, "0")
62503
+ } : { year: "____", month: "__", day: "__" }, o2 = n2.map((a2) => m3[a2.type]).join(s);
62504
+ super({ ...t2, initialUserInput: o2 }, false), this.#i = n2, this.#o = s, this.#t = m3, this.#h = t2.minDate, this.#u = t2.maxDate, this.#r(), this.on("cursor", (a2) => this.#f(a2)), this.on("key", (a2, u2) => this.#y(a2, u2)), this.on("finalize", () => this.#p(t2));
62505
+ }
62506
+ #a() {
62507
+ const t2 = Math.max(0, Math.min(this.#e.segmentIndex, this.#i.length - 1)), i2 = this.#i[t2];
62508
+ if (i2)
62509
+ return this.#e.positionInSegment = Math.max(0, Math.min(this.#e.positionInSegment, i2.len - 1)), { segment: i2, index: t2 };
62510
+ }
62511
+ #m(t2) {
62512
+ this.inlineError = "", this.#s = null;
62513
+ const i2 = this.#a();
62514
+ i2 && (this.#e.segmentIndex = Math.max(0, Math.min(this.#i.length - 1, i2.index + t2)), this.#e.positionInSegment = 0, this.#n = true);
62515
+ }
62516
+ #d(t2) {
62517
+ const i2 = this.#a();
62518
+ if (!i2)
62519
+ return;
62520
+ const { segment: s } = i2, n2 = this.#t[s.type], e = !n2 || n2.replace(/_/g, "") === "", m3 = Number.parseInt((n2 || "0").replace(/_/g, "0"), 10) || 0, o2 = T2(s.type, f2(this.#t), this.#h, this.#u);
62521
+ let a2;
62522
+ e ? a2 = t2 === 1 ? o2.min : o2.max : a2 = Math.max(Math.min(o2.max, m3 + t2), o2.min), this.#t = {
62523
+ ...this.#t,
62524
+ [s.type]: a2.toString().padStart(s.len, "0")
62525
+ }, this.#n = true, this.#s = null, this.#r();
62526
+ }
62527
+ #f(t2) {
62528
+ if (t2)
62529
+ switch (t2) {
62530
+ case "right":
62531
+ return this.#m(1);
62532
+ case "left":
62533
+ return this.#m(-1);
62534
+ case "up":
62535
+ return this.#d(1);
62536
+ case "down":
62537
+ return this.#d(-1);
62538
+ }
62539
+ }
62540
+ #y(t2, i2) {
62541
+ if (i2?.name === "backspace" || i2?.sequence === "\x7F" || i2?.sequence === "\b" || t2 === "\x7F" || t2 === "\b") {
62542
+ this.inlineError = "";
62543
+ const n2 = this.#a();
62544
+ if (!n2)
62545
+ return;
62546
+ if (!this.#t[n2.segment.type].replace(/_/g, "")) {
62547
+ this.#m(-1);
62548
+ return;
62549
+ }
62550
+ this.#t[n2.segment.type] = "_".repeat(n2.segment.len), this.#n = true, this.#e.positionInSegment = 0, this.#r();
62551
+ return;
62552
+ }
62553
+ if (i2?.name === "tab") {
62554
+ this.inlineError = "";
62555
+ const n2 = this.#a();
62556
+ if (!n2)
62557
+ return;
62558
+ const e = i2.shift ? -1 : 1, m3 = n2.index + e;
62559
+ m3 >= 0 && m3 < this.#i.length && (this.#e.segmentIndex = m3, this.#e.positionInSegment = 0, this.#n = true);
62560
+ return;
62561
+ }
62562
+ if (t2 && /^[0-9]$/.test(t2)) {
62563
+ const n2 = this.#a();
62564
+ if (!n2)
62565
+ return;
62566
+ const { segment: e } = n2, m3 = !this.#t[e.type].replace(/_/g, "");
62567
+ if (this.#n && this.#s !== null && !m3) {
62568
+ const h2 = this.#s + t2, d = { ...this.#t, [e.type]: h2 }, g2 = this.#g(d, e);
62569
+ if (g2) {
62570
+ this.inlineError = g2, this.#s = null, this.#n = false;
62571
+ return;
62572
+ }
62573
+ this.inlineError = "", this.#t[e.type] = h2, this.#s = null, this.#n = false, this.#r(), n2.index < this.#i.length - 1 && (this.#e.segmentIndex = n2.index + 1, this.#e.positionInSegment = 0, this.#n = true);
62574
+ return;
62575
+ }
62576
+ this.#n && !m3 && (this.#t[e.type] = "_".repeat(e.len), this.#e.positionInSegment = 0), this.#n = false, this.#s = null;
62577
+ const o2 = this.#t[e.type], a2 = o2.indexOf("_"), u2 = a2 >= 0 ? a2 : Math.min(this.#e.positionInSegment, e.len - 1);
62578
+ if (u2 < 0 || u2 >= e.len)
62579
+ return;
62580
+ let l = o2.slice(0, u2) + t2 + o2.slice(u2 + 1), D = false;
62581
+ if (u2 === 0 && o2 === "__" && (e.type === "month" || e.type === "day")) {
62582
+ const h2 = Number.parseInt(t2, 10);
62583
+ l = `0${t2}`, D = h2 <= (e.type === "month" ? 1 : 2);
62584
+ }
62585
+ if (e.type === "year" && (l = (o2.replace(/_/g, "") + t2).padStart(e.len, "_")), !l.includes("_")) {
62586
+ const h2 = { ...this.#t, [e.type]: l }, d = this.#g(h2, e);
62587
+ if (d) {
62588
+ this.inlineError = d;
62589
+ return;
62590
+ }
62591
+ }
62592
+ this.inlineError = "", this.#t[e.type] = l;
62593
+ const y = l.includes("_") ? undefined : b2(this.#t);
62594
+ if (y) {
62595
+ const { year: h2, month: d } = y, g2 = c4(h2, d);
62596
+ this.#t = {
62597
+ year: String(Math.max(0, Math.min(9999, h2))).padStart(4, "0"),
62598
+ month: String(Math.max(1, Math.min(12, d))).padStart(2, "0"),
62599
+ day: String(Math.max(1, Math.min(g2, y.day))).padStart(2, "0")
62600
+ };
62601
+ }
62602
+ this.#r();
62603
+ const S = l.indexOf("_");
62604
+ D ? (this.#n = true, this.#s = t2) : S >= 0 ? this.#e.positionInSegment = S : a2 >= 0 && n2.index < this.#i.length - 1 ? (this.#e.segmentIndex = n2.index + 1, this.#e.positionInSegment = 0, this.#n = true) : this.#e.positionInSegment = Math.min(u2 + 1, e.len - 1);
62605
+ }
62606
+ }
62607
+ #g(t2, i2) {
62608
+ const { month: s, day: n2 } = f2(t2);
62609
+ if (i2.type === "month" && (s < 0 || s > 12))
62610
+ return settings.date.messages.invalidMonth;
62611
+ if (i2.type === "day" && (n2 < 0 || n2 > 31))
62612
+ return settings.date.messages.invalidDay(31, "any month");
62613
+ }
62614
+ #p(t2) {
62615
+ const { year: i2, month: s, day: n2 } = f2(this.#t);
62616
+ if (i2 && s && n2) {
62617
+ const e = c4(i2, s);
62618
+ this.#t = {
62619
+ ...this.#t,
62620
+ day: String(Math.min(n2, e)).padStart(2, "0")
62621
+ };
62622
+ }
62623
+ this.value = C(this.#t) ?? t2.defaultValue ?? undefined;
62624
+ }
62625
+ }
62626
+ var u$1 = class u2 extends V {
62627
+ options;
62628
+ cursor = 0;
62629
+ #t;
62630
+ getGroupItems(t2) {
62631
+ return this.options.filter((r) => r.group === t2);
62632
+ }
62633
+ isGroupSelected(t2) {
62634
+ const r = this.getGroupItems(t2), e = this.value;
62635
+ return e === undefined ? false : r.every((s) => e.includes(s.value));
62636
+ }
62637
+ toggleValue() {
62638
+ const t2 = this.options[this.cursor];
62639
+ if (this.value === undefined && (this.value = []), t2.group === true) {
62640
+ const r = t2.value, e = this.getGroupItems(r);
62641
+ this.isGroupSelected(r) ? this.value = this.value.filter((s) => e.findIndex((i2) => i2.value === s) === -1) : this.value = [...this.value, ...e.map((s) => s.value)], this.value = Array.from(new Set(this.value));
62642
+ } else {
62643
+ const r = this.value.includes(t2.value);
62644
+ this.value = r ? this.value.filter((e) => e !== t2.value) : [...this.value, t2.value];
62645
+ }
62646
+ }
62647
+ constructor(t2) {
62648
+ super(t2, false);
62649
+ const { options: r } = t2;
62650
+ this.#t = t2.selectableGroups !== false, this.options = Object.entries(r).flatMap(([e, s]) => [
62651
+ { value: e, group: true, label: e },
62652
+ ...s.map((i2) => ({ ...i2, group: e }))
62653
+ ]), this.value = [...t2.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: e }) => e === t2.cursorAt), this.#t ? 0 : 1), this.on("cursor", (e) => {
62654
+ switch (e) {
62655
+ case "left":
62656
+ case "up": {
62657
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
62658
+ const s = this.options[this.cursor]?.group === true;
62659
+ !this.#t && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
62660
+ break;
62661
+ }
62662
+ case "down":
62663
+ case "right": {
62664
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
62665
+ const s = this.options[this.cursor]?.group === true;
62666
+ !this.#t && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
62667
+ break;
62668
+ }
62669
+ case "space":
62670
+ this.toggleValue();
62671
+ break;
62672
+ }
62673
+ });
62674
+ }
62675
+ };
62676
+ var o$1 = /* @__PURE__ */ new Set(["up", "down", "left", "right"]);
62677
+
62678
+ class h2 extends V {
62679
+ #s = false;
62680
+ #t;
62681
+ focused = "editor";
62682
+ get userInputWithCursor() {
62683
+ if (this.state === "submit")
62684
+ return this.userInput;
62685
+ const t2 = this.userInput;
62686
+ if (this.cursor >= t2.length)
62687
+ return `${t2}\u2588`;
62688
+ const s = t2.slice(0, this.cursor), r = t2[this.cursor], e = t2.slice(this.cursor + 1);
62689
+ return r === `
62690
+ ` ? `${s}\u2588
62691
+ ${e}` : `${s}${styleText("inverse", r)}${e}`;
62692
+ }
62693
+ get cursor() {
62694
+ return this._cursor;
62695
+ }
62696
+ #r(t2) {
62697
+ if (this.userInput.length === 0) {
62698
+ this._setUserInput(t2);
62699
+ return;
62700
+ }
62701
+ this._setUserInput(this.userInput.slice(0, this.cursor) + t2 + this.userInput.slice(this.cursor));
62702
+ }
62703
+ #i(t2) {
62704
+ const s = this.value ?? "";
62705
+ switch (t2) {
62706
+ case "up":
62707
+ this._cursor = findTextCursor(this._cursor, 0, -1, s);
62708
+ return;
62709
+ case "down":
62710
+ this._cursor = findTextCursor(this._cursor, 0, 1, s);
62711
+ return;
62712
+ case "left":
62713
+ this._cursor = findTextCursor(this._cursor, -1, 0, s);
62714
+ return;
62715
+ case "right":
62716
+ this._cursor = findTextCursor(this._cursor, 1, 0, s);
62717
+ return;
62718
+ }
62719
+ }
62720
+ _shouldSubmit(t2, s) {
62721
+ if (this.#t)
62722
+ return this.focused === "submit" ? true : (this.#r(`
62723
+ `), this._cursor++, false);
62724
+ const r = this.#s;
62725
+ return this.#s = true, r ? (this.userInput[this.cursor - 1] === `
62726
+ ` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#r(`
62727
+ `), this._cursor++, false);
62728
+ }
62729
+ constructor(t2) {
62730
+ super(t2, false), this.#t = t2.showSubmit ?? false, this.on("key", (s, r) => {
62731
+ if (r?.name && o$1.has(r.name)) {
62732
+ this.#i(r.name);
62733
+ return;
62734
+ }
62735
+ if (s === "\t" && this.#t) {
62736
+ this.focused = this.focused === "editor" ? "submit" : "editor";
62737
+ return;
62738
+ }
62739
+ if (r?.name !== "return") {
62740
+ if (this.#s = false, r?.name === "backspace" && this.cursor > 0) {
62741
+ this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--;
62742
+ return;
62743
+ }
62744
+ if (r?.name === "delete" && this.cursor < this.userInput.length) {
62745
+ this._setUserInput(this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1));
62746
+ return;
62747
+ }
62748
+ s && (this.#t && this.focused === "submit" && (this.focused = "editor"), this.#r(s ?? ""), this._cursor++);
62749
+ }
62750
+ }), this.on("userInput", (s) => {
62751
+ this._setValue(s);
62752
+ }), this.on("finalize", () => {
62753
+ this.value || (this.value = t2.defaultValue), this.value === undefined && (this.value = "");
62754
+ });
62755
+ }
62756
+ }
62757
+ class a2 extends V {
62758
+ options;
62759
+ cursor = 0;
62760
+ get _selectedValue() {
62761
+ return this.options[this.cursor];
62762
+ }
62763
+ changeValue() {
62764
+ this.value = this._selectedValue.value;
62765
+ }
62766
+ constructor(t2) {
62767
+ super(t2, false), this.options = t2.options;
62768
+ const i2 = this.options.findIndex(({ value: s }) => s === t2.initialValue), e = i2 === -1 ? 0 : i2;
62769
+ this.cursor = this.options[e].disabled ? findCursor(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (s) => {
62770
+ switch (s) {
62771
+ case "left":
62772
+ case "up":
62773
+ this.cursor = findCursor(this.cursor, -1, this.options);
62774
+ break;
62775
+ case "down":
62776
+ case "right":
62777
+ this.cursor = findCursor(this.cursor, 1, this.options);
62778
+ break;
62779
+ }
62780
+ this.changeValue();
62781
+ });
62782
+ }
62783
+ }
62784
+ class n2 extends V {
62785
+ get userInputWithCursor() {
62786
+ if (this.state === "submit")
62787
+ return this.userInput;
62788
+ const t2 = this.userInput;
62789
+ if (this.cursor >= t2.length)
62790
+ return `${this.userInput}\u2588`;
62791
+ const e = t2.slice(0, this.cursor), [s, ...r] = t2.slice(this.cursor);
62792
+ return `${e}${styleText("inverse", s)}${r.join("")}`;
62793
+ }
62794
+ get cursor() {
62795
+ return this._cursor;
62796
+ }
62797
+ constructor(t2) {
62798
+ super({
62799
+ ...t2,
62800
+ initialUserInput: t2.initialUserInput ?? t2.initialValue
62801
+ }), this.on("userInput", (e) => {
62802
+ this._setValue(e);
62803
+ }), this.on("finalize", () => {
62804
+ this.value || (this.value = t2.defaultValue), this.value === undefined && (this.value = "");
62805
+ });
62806
+ }
62807
+ }
62808
+
62809
+ // ../../node_modules/.bun/@clack+prompts@1.5.1/node_modules/@clack/prompts/dist/index.mjs
62810
+ import { styleText as styleText2, stripVTControlCharacters as stripVTControlCharacters2 } from "util";
62811
+ import process$1 from "process";
62812
+ var import_sisteransi2 = __toESM(require_src9(), 1);
62813
+ function isUnicodeSupported2() {
62814
+ if (process$1.platform !== "win32") {
62815
+ return process$1.env.TERM !== "linux";
62816
+ }
62817
+ return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
62818
+ }
62819
+ var unicode = isUnicodeSupported2();
62820
+ var unicodeOr = (e, o3) => unicode ? e : o3;
62821
+ var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
62822
+ var S_STEP_CANCEL = unicodeOr("\u25A0", "x");
62823
+ var S_STEP_ERROR = unicodeOr("\u25B2", "x");
62824
+ var S_STEP_SUBMIT = unicodeOr("\u25C7", "o");
62825
+ var S_BAR_START = unicodeOr("\u250C", "T");
62826
+ var S_BAR = unicodeOr("\u2502", "|");
62827
+ var S_BAR_END = unicodeOr("\u2514", "\u2014");
62828
+ var S_BAR_START_RIGHT = unicodeOr("\u2510", "T");
62829
+ var S_BAR_END_RIGHT = unicodeOr("\u2518", "\u2014");
62830
+ var S_RADIO_ACTIVE = unicodeOr("\u25CF", ">");
62831
+ var S_RADIO_INACTIVE = unicodeOr("\u25CB", " ");
62832
+ var S_CHECKBOX_ACTIVE = unicodeOr("\u25FB", "[\u2022]");
62833
+ var S_CHECKBOX_SELECTED = unicodeOr("\u25FC", "[+]");
62834
+ var S_CHECKBOX_INACTIVE = unicodeOr("\u25FB", "[ ]");
62835
+ var S_PASSWORD_MASK = unicodeOr("\u25AA", "\u2022");
62836
+ var S_BAR_H = unicodeOr("\u2500", "-");
62837
+ var S_CORNER_TOP_RIGHT = unicodeOr("\u256E", "+");
62838
+ var S_CONNECT_LEFT = unicodeOr("\u251C", "+");
62839
+ var S_CORNER_BOTTOM_RIGHT = unicodeOr("\u256F", "+");
62840
+ var S_CORNER_BOTTOM_LEFT = unicodeOr("\u2570", "+");
62841
+ var S_CORNER_TOP_LEFT = unicodeOr("\u256D", "+");
62842
+ var S_INFO = unicodeOr("\u25CF", "\u2022");
62843
+ var S_SUCCESS = unicodeOr("\u25C6", "*");
62844
+ var S_WARN = unicodeOr("\u25B2", "!");
62845
+ var S_ERROR = unicodeOr("\u25A0", "x");
62846
+ var symbol2 = (e) => {
62847
+ switch (e) {
62848
+ case "initial":
62849
+ case "active":
62850
+ return styleText2("cyan", S_STEP_ACTIVE);
62851
+ case "cancel":
62852
+ return styleText2("red", S_STEP_CANCEL);
62853
+ case "error":
62854
+ return styleText2("yellow", S_STEP_ERROR);
62855
+ case "submit":
62856
+ return styleText2("green", S_STEP_SUBMIT);
62857
+ }
62858
+ };
62859
+ var symbolBar = (e) => {
62860
+ switch (e) {
62861
+ case "initial":
62862
+ case "active":
62863
+ return styleText2("cyan", S_BAR);
62864
+ case "cancel":
62865
+ return styleText2("red", S_BAR);
62866
+ case "error":
62867
+ return styleText2("yellow", S_BAR);
62868
+ case "submit":
62869
+ return styleText2("green", S_BAR);
62870
+ }
62871
+ };
62872
+ var E$1 = (l, o3, g2, c5, h3, O = false) => {
62873
+ let r2 = o3, w = 0;
62874
+ if (O)
62875
+ for (let i2 = c5 - 1;i2 >= g2 && (r2 -= l[i2].length, w++, !(r2 <= h3)); i2--)
62876
+ ;
62877
+ else
62878
+ for (let i2 = g2;i2 < c5 && (r2 -= l[i2].length, w++, !(r2 <= h3)); i2++)
62879
+ ;
62880
+ return { lineCount: r2, removals: w };
62881
+ };
62882
+ var limitOptions = ({
62883
+ cursor: l,
62884
+ options: o3,
62885
+ style: g2,
62886
+ output: c5 = process.stdout,
62887
+ maxItems: h3 = Number.POSITIVE_INFINITY,
62888
+ columnPadding: O = 0,
62889
+ rowPadding: r2 = 4
62890
+ }) => {
62891
+ const i2 = getColumns(c5) - O, I = getRows(c5), C2 = styleText2("dim", "..."), x = Math.max(I - r2, 0), m3 = Math.max(Math.min(h3, x), 5);
62892
+ let p3 = 0;
62893
+ l >= m3 - 3 && (p3 = Math.max(Math.min(l - m3 + 3, o3.length - m3), 0));
62894
+ let f3 = m3 < o3.length && p3 > 0, u4 = m3 < o3.length && p3 + m3 < o3.length;
62895
+ const W = Math.min(p3 + m3, o3.length), e = [];
62896
+ let d = 0;
62897
+ f3 && d++, u4 && d++;
62898
+ const v = p3 + (f3 ? 1 : 0), P2 = W - (u4 ? 1 : 0);
62899
+ for (let t2 = v;t2 < P2; t2++) {
62900
+ const n3 = wrapAnsi(g2(o3[t2], t2 === l), i2, {
62901
+ hard: true,
62902
+ trim: false
62903
+ }).split(`
62904
+ `);
62905
+ e.push(n3), d += n3.length;
62906
+ }
62907
+ if (d > x) {
62908
+ let t2 = 0, n3 = 0, s = d;
62909
+ const M2 = l - v;
62910
+ let a3 = x;
62911
+ const T3 = () => E$1(e, s, 0, M2, a3), L = () => E$1(e, s, M2 + 1, e.length, a3, true);
62912
+ f3 ? ({ lineCount: s, removals: t2 } = T3(), s > a3 && (u4 || (a3 -= 1), { lineCount: s, removals: n3 } = L())) : (u4 || (a3 -= 1), { lineCount: s, removals: n3 } = L(), s > a3 && (a3 -= 1, { lineCount: s, removals: t2 } = T3())), t2 > 0 && (f3 = true, e.splice(0, t2)), n3 > 0 && (u4 = true, e.splice(e.length - n3, n3));
62913
+ }
62914
+ const b3 = [];
62915
+ f3 && b3.push(C2);
62916
+ for (const t2 of e)
62917
+ for (const n3 of t2)
62918
+ b3.push(n3);
62919
+ return u4 && b3.push(C2), b3;
62920
+ };
62921
+ var u4 = {
62922
+ light: unicodeOr("\u2500", "-"),
62923
+ heavy: unicodeOr("\u2501", "="),
62924
+ block: unicodeOr("\u2588", "#")
62925
+ };
62926
+ var c5 = (e, a3) => e.includes(`
62927
+ `) ? e.split(`
62928
+ `).map((t2) => a3(t2)).join(`
62929
+ `) : a3(e);
62930
+ var select3 = (e) => {
62931
+ const a3 = (t2, d) => {
62932
+ const s = t2.label ?? String(t2.value);
62933
+ switch (d) {
62934
+ case "disabled":
62935
+ return `${styleText2("gray", S_RADIO_INACTIVE)} ${c5(s, (n3) => styleText2("gray", n3))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint ?? "disabled"})`)}` : ""}`;
62936
+ case "selected":
62937
+ return `${c5(s, (n3) => styleText2("dim", n3))}`;
62938
+ case "active":
62939
+ return `${styleText2("green", S_RADIO_ACTIVE)} ${s}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}`;
62940
+ case "cancelled":
62941
+ return `${c5(s, (n3) => styleText2(["strikethrough", "dim"], n3))}`;
62942
+ default:
62943
+ return `${styleText2("dim", S_RADIO_INACTIVE)} ${c5(s, (n3) => styleText2("dim", n3))}`;
62944
+ }
62945
+ };
62946
+ return new a2({
62947
+ options: e.options,
62948
+ signal: e.signal,
62949
+ input: e.input,
62950
+ output: e.output,
62951
+ initialValue: e.initialValue,
62952
+ render() {
62953
+ const t2 = e.withGuide ?? settings.withGuide, d = `${symbol2(this.state)} `, s = `${symbolBar(this.state)} `, n3 = wrapTextWithPrefix(e.output, e.message, s, d), u5 = `${t2 ? `${styleText2("gray", S_BAR)}
62954
+ ` : ""}${n3}
62955
+ `;
62956
+ switch (this.state) {
62957
+ case "submit": {
62958
+ const r2 = t2 ? `${styleText2("gray", S_BAR)} ` : "", l = wrapTextWithPrefix(e.output, a3(this.options[this.cursor], "selected"), r2);
62959
+ return `${u5}${l}`;
62960
+ }
62961
+ case "cancel": {
62962
+ const r2 = t2 ? `${styleText2("gray", S_BAR)} ` : "", l = wrapTextWithPrefix(e.output, a3(this.options[this.cursor], "cancelled"), r2);
62963
+ return `${u5}${l}${t2 ? `
62964
+ ${styleText2("gray", S_BAR)}` : ""}`;
62965
+ }
62966
+ default: {
62967
+ const r2 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", l = t2 ? styleText2("cyan", S_BAR_END) : "", g2 = u5.split(`
62968
+ `).length, h3 = t2 ? 2 : 1;
62969
+ return `${u5}${r2}${limitOptions({
62970
+ output: e.output,
62971
+ cursor: this.cursor,
62972
+ options: this.options,
62973
+ maxItems: e.maxItems,
62974
+ columnPadding: r2.length,
62975
+ rowPadding: g2 + h3,
62976
+ style: (p3, b3) => a3(p3, p3.disabled ? "disabled" : b3 ? "active" : "inactive")
62977
+ }).join(`
62978
+ ${r2}`)}
62979
+ ${l}
62980
+ `;
62981
+ }
62982
+ }
62983
+ }
62984
+ }).prompt();
62985
+ };
62986
+ var i2 = `${styleText2("gray", S_BAR)} `;
62987
+ var text3 = (t2) => new n2({
62988
+ validate: t2.validate,
62989
+ placeholder: t2.placeholder,
62990
+ defaultValue: t2.defaultValue,
62991
+ initialValue: t2.initialValue,
62992
+ output: t2.output,
62993
+ signal: t2.signal,
62994
+ input: t2.input,
62995
+ render() {
62996
+ const i3 = t2?.withGuide ?? settings.withGuide, s = `${`${i3 ? `${styleText2("gray", S_BAR)}
62997
+ ` : ""}${symbol2(this.state)} `}${t2.message}
62998
+ `, c6 = t2.placeholder ? styleText2("inverse", t2.placeholder[0]) + styleText2("dim", t2.placeholder.slice(1)) : styleText2(["inverse", "hidden"], "_"), o3 = this.userInput ? this.userInputWithCursor : c6, a3 = this.value ?? "";
62999
+ switch (this.state) {
63000
+ case "error": {
63001
+ const n3 = this.error ? ` ${styleText2("yellow", this.error)}` : "", r2 = i3 ? `${styleText2("yellow", S_BAR)} ` : "", d = i3 ? styleText2("yellow", S_BAR_END) : "";
63002
+ return `${s.trim()}
63003
+ ${r2}${o3}
63004
+ ${d}${n3}
63005
+ `;
63006
+ }
63007
+ case "submit": {
63008
+ const n3 = a3 ? ` ${styleText2("dim", a3)}` : "", r2 = i3 ? styleText2("gray", S_BAR) : "";
63009
+ return `${s}${r2}${n3}`;
63010
+ }
63011
+ case "cancel": {
63012
+ const n3 = a3 ? ` ${styleText2(["strikethrough", "dim"], a3)}` : "", r2 = i3 ? styleText2("gray", S_BAR) : "";
63013
+ return `${s}${r2}${n3}${a3.trim() ? `
63014
+ ${r2}` : ""}`;
63015
+ }
63016
+ default: {
63017
+ const n3 = i3 ? `${styleText2("cyan", S_BAR)} ` : "", r2 = i3 ? styleText2("cyan", S_BAR_END) : "";
63018
+ return `${s}${n3}${o3}
63019
+ ${r2}
63020
+ `;
63021
+ }
63022
+ }
63023
+ }
63024
+ }).prompt();
63025
+
63026
+ // src/workflow/hitl/clack-responder.ts
63027
+ class ClackHitlResponder {
63028
+ constructor() {}
63029
+ async respond(request) {
63030
+ switch (request.kind) {
63031
+ case "confirm": {
63032
+ const result = await select3({
63033
+ message: request.prompt,
63034
+ options: [
63035
+ { value: "yes", label: "Yes" },
63036
+ { value: "no", label: "No" },
63037
+ { value: "cancel", label: "Cancel" }
63038
+ ]
63039
+ });
63040
+ if (isCancel(result)) {
63041
+ return { value: "cancel", cancelled: true };
63042
+ }
63043
+ return { value: result };
63044
+ }
63045
+ case "select": {
63046
+ const options = (request.options ?? []).map((opt) => ({ value: opt, label: opt }));
63047
+ const result = await select3({
63048
+ message: request.prompt,
63049
+ options
63050
+ });
63051
+ if (isCancel(result)) {
63052
+ return { value: "", cancelled: true };
63053
+ }
63054
+ return { value: result };
63055
+ }
63056
+ case "input": {
63057
+ const result = await text3({
63058
+ message: request.prompt
63059
+ });
63060
+ if (isCancel(result)) {
63061
+ return { value: "", cancelled: true };
63062
+ }
63063
+ return { value: result ?? "" };
63064
+ }
63065
+ }
63066
+ }
63067
+ }
63068
+
63069
+ // src/workflow/hitl/default-responder.ts
63070
+ class DefaultHitlResponder {
63071
+ config;
63072
+ constructor(config3 = {}) {
63073
+ this.config = {
63074
+ confirmDefault: config3.confirmDefault ?? "yes",
63075
+ selectDefaultIndex: config3.selectDefaultIndex ?? 0,
63076
+ inputDefault: config3.inputDefault ?? ""
63077
+ };
63078
+ }
63079
+ async respond(request) {
63080
+ switch (request.kind) {
63081
+ case "confirm":
63082
+ return { value: this.config.confirmDefault };
63083
+ case "select": {
63084
+ const options = request.options ?? [];
63085
+ const idx = Math.max(0, Math.min(this.config.selectDefaultIndex, options.length - 1));
63086
+ return { value: options[idx] ?? "" };
63087
+ }
63088
+ case "input":
63089
+ return { value: this.config.inputDefault };
63090
+ }
63091
+ }
63092
+ }
63093
+
63094
+ // src/context.ts
60986
63095
  function createCliContext(options) {
60987
63096
  const cwd = resolve4(options.cwd ?? process.cwd());
60988
63097
  const env = options.env ?? process.env;
@@ -61001,7 +63110,10 @@ function createCliContext(options) {
61001
63110
  getDb: async () => {
61002
63111
  dbPromise ??= createMigratedDbAdapter(cwd, env, options.dbUrl);
61003
63112
  return dbPromise;
61004
- }
63113
+ },
63114
+ agentService: () => new AgentService({ cwd, env, output: options.output }),
63115
+ ruleService: () => new RuleService({ cwd, env, fs: fs2, output: options.output }),
63116
+ hitlResponder: (json2) => isatty3(1) && json2 !== true ? new ClackHitlResponder : new DefaultHitlResponder
61005
63117
  };
61006
63118
  }
61007
63119
  function noopSetExitCode(_code) {}