@tagma/sdk 0.6.12 → 0.7.0

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 (110) hide show
  1. package/README.md +56 -15
  2. package/dist/bootstrap.d.ts +6 -6
  3. package/dist/bootstrap.d.ts.map +1 -1
  4. package/dist/bootstrap.js +5 -6
  5. package/dist/bootstrap.js.map +1 -1
  6. package/dist/config.d.ts +8 -0
  7. package/dist/config.d.ts.map +1 -0
  8. package/dist/config.js +5 -0
  9. package/dist/config.js.map +1 -0
  10. package/dist/core/dataflow.d.ts +23 -0
  11. package/dist/core/dataflow.d.ts.map +1 -0
  12. package/dist/core/dataflow.js +63 -0
  13. package/dist/core/dataflow.js.map +1 -0
  14. package/dist/core/log-prune.d.ts +16 -0
  15. package/dist/core/log-prune.d.ts.map +1 -0
  16. package/dist/core/log-prune.js +34 -0
  17. package/dist/core/log-prune.js.map +1 -0
  18. package/dist/core/preflight.d.ts +13 -0
  19. package/dist/core/preflight.d.ts.map +1 -0
  20. package/dist/core/preflight.js +61 -0
  21. package/dist/core/preflight.js.map +1 -0
  22. package/dist/core/run-context.d.ts +52 -0
  23. package/dist/core/run-context.d.ts.map +1 -0
  24. package/dist/core/run-context.js +156 -0
  25. package/dist/core/run-context.js.map +1 -0
  26. package/dist/core/run-state.d.ts +25 -0
  27. package/dist/core/run-state.d.ts.map +1 -0
  28. package/dist/core/run-state.js +93 -0
  29. package/dist/core/run-state.js.map +1 -0
  30. package/dist/core/scheduler.d.ts +13 -0
  31. package/dist/core/scheduler.d.ts.map +1 -0
  32. package/dist/core/scheduler.js +35 -0
  33. package/dist/core/scheduler.js.map +1 -0
  34. package/dist/core/task-executor.d.ts +13 -0
  35. package/dist/core/task-executor.d.ts.map +1 -0
  36. package/dist/core/task-executor.js +639 -0
  37. package/dist/core/task-executor.js.map +1 -0
  38. package/dist/core/trigger-errors.d.ts +9 -0
  39. package/dist/core/trigger-errors.d.ts.map +1 -0
  40. package/dist/core/trigger-errors.js +15 -0
  41. package/dist/core/trigger-errors.js.map +1 -0
  42. package/dist/engine.d.ts +6 -14
  43. package/dist/engine.d.ts.map +1 -1
  44. package/dist/engine.js +68 -1035
  45. package/dist/engine.js.map +1 -1
  46. package/dist/index.d.ts +9 -0
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +6 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/pipeline-definition.d.ts +3 -0
  51. package/dist/pipeline-definition.d.ts.map +1 -0
  52. package/dist/pipeline-definition.js +4 -0
  53. package/dist/pipeline-definition.js.map +1 -0
  54. package/dist/pipeline-runner.d.ts +2 -1
  55. package/dist/pipeline-runner.d.ts.map +1 -1
  56. package/dist/pipeline-runner.js +2 -2
  57. package/dist/pipeline-runner.js.map +1 -1
  58. package/dist/plugins.d.ts +5 -0
  59. package/dist/plugins.d.ts.map +1 -0
  60. package/dist/plugins.js +3 -0
  61. package/dist/plugins.js.map +1 -0
  62. package/dist/registry.d.ts +3 -19
  63. package/dist/registry.d.ts.map +1 -1
  64. package/dist/registry.js +7 -35
  65. package/dist/registry.js.map +1 -1
  66. package/dist/tagma.d.ts +24 -0
  67. package/dist/tagma.d.ts.map +1 -0
  68. package/dist/tagma.js +23 -0
  69. package/dist/tagma.js.map +1 -0
  70. package/dist/utils-api.d.ts +2 -0
  71. package/dist/utils-api.d.ts.map +1 -0
  72. package/dist/utils-api.js +2 -0
  73. package/dist/utils-api.js.map +1 -0
  74. package/dist/yaml.d.ts +4 -0
  75. package/dist/yaml.d.ts.map +1 -0
  76. package/dist/yaml.js +3 -0
  77. package/dist/yaml.js.map +1 -0
  78. package/package.json +52 -7
  79. package/src/bootstrap.ts +6 -6
  80. package/src/config.ts +26 -0
  81. package/src/core/dataflow.test.ts +167 -0
  82. package/src/core/dataflow.ts +118 -0
  83. package/src/core/log-prune.test.ts +58 -0
  84. package/src/core/log-prune.ts +43 -0
  85. package/src/core/preflight.test.ts +49 -0
  86. package/src/core/preflight.ts +89 -0
  87. package/src/core/run-context.test.ts +244 -0
  88. package/src/core/run-context.ts +207 -0
  89. package/src/core/run-state.test.ts +98 -0
  90. package/src/core/run-state.ts +122 -0
  91. package/src/core/scheduler.test.ts +83 -0
  92. package/src/core/scheduler.ts +42 -0
  93. package/src/core/task-executor.ts +803 -0
  94. package/src/core/trigger-errors.ts +15 -0
  95. package/src/engine.ts +80 -1248
  96. package/src/index.ts +28 -0
  97. package/src/pipeline-definition.ts +5 -0
  98. package/src/pipeline-runner.ts +3 -2
  99. package/src/plugin-registry.test.ts +7 -10
  100. package/src/plugins.ts +18 -0
  101. package/src/registry.ts +7 -49
  102. package/src/tagma.test.ts +84 -0
  103. package/src/tagma.ts +47 -0
  104. package/src/utils-api.ts +8 -0
  105. package/src/yaml.ts +11 -0
  106. package/dist/sdk.d.ts +0 -32
  107. package/dist/sdk.d.ts.map +0 -1
  108. package/dist/sdk.js +0 -41
  109. package/dist/sdk.js.map +0 -1
  110. package/src/sdk.ts +0 -151
package/README.md CHANGED
@@ -50,18 +50,21 @@ pipeline:
50
50
  **2. Run it programmatically**
51
51
 
52
52
  ```ts
53
- import { bootstrapBuiltins, loadPipeline, runPipeline, InMemoryApprovalGateway } from '@tagma/sdk';
53
+ import { createTagma } from '@tagma/sdk';
54
+ import { loadPipeline } from '@tagma/sdk/yaml';
54
55
 
55
- // Register built-in drivers, triggers, completions
56
- bootstrapBuiltins();
56
+ const tagma = createTagma();
57
57
 
58
58
  const yaml = await Bun.file('pipeline.yaml').text();
59
59
  const config = await loadPipeline(yaml, process.cwd());
60
60
 
61
- const result = await runPipeline(config, process.cwd());
61
+ const result = await tagma.run(config, { cwd: process.cwd() });
62
62
  console.log(result.success ? 'Done' : 'Failed');
63
63
  ```
64
64
 
65
+ The package root is intentionally small. Use explicit subpaths for YAML,
66
+ config editing, plugin registry helpers, and low-level dataflow utilities.
67
+
65
68
  ## Features
66
69
 
67
70
  - **Multi-track DAG execution** -- tasks run in parallel across tracks, respecting `depends_on` ordering
@@ -357,7 +360,43 @@ Tasks can declare named, typed `inputs` / `outputs`. Inputs flow in from upstrea
357
360
 
358
361
  ## API
359
362
 
360
- ### `bootstrapBuiltins()`
363
+ ### Root: `@tagma/sdk`
364
+
365
+ - `createTagma(options?)`
366
+ - `definePipeline(pipeline)`
367
+ - `PluginRegistry`
368
+ - stable pipeline/result/event types
369
+ - trigger error classes
370
+
371
+ ### YAML: `@tagma/sdk/yaml`
372
+
373
+ - `loadPipeline(yaml, workDir)`
374
+ - `parseYaml(content)`
375
+ - `resolveConfig(raw, workDir)`
376
+ - `serializePipeline(config)`
377
+ - `deresolvePipeline(config, workDir)`
378
+ - `validateConfig(config)`
379
+ - `compileYamlContent(content, options?)`
380
+
381
+ ### Plugins: `@tagma/sdk/plugins`
382
+
383
+ - `PluginRegistry`
384
+ - `bootstrapBuiltins(registry)`
385
+ - `isValidPluginName(name)`
386
+ - `readPluginManifest(packageJson)`
387
+
388
+ ### Config: `@tagma/sdk/config`
389
+
390
+ - immutable config editing helpers
391
+ - raw validation helpers
392
+ - task reference helpers
393
+
394
+ ### Ports: `@tagma/sdk/ports`
395
+
396
+ - current dataflow helpers for placeholder substitution, binding resolution,
397
+ output extraction, and prompt-port inference
398
+
399
+ ### `bootstrapBuiltins(registry)`
361
400
 
362
401
  Registers all built-in plugins (opencode driver, file/manual triggers, completion checks, static-context middleware).
363
402
 
@@ -365,7 +404,7 @@ Registers all built-in plugins (opencode driver, file/manual triggers, completio
365
404
 
366
405
  Parses YAML, resolves inheritance, and validates the configuration.
367
406
 
368
- ### `runPipeline(config, workDir, options?): Promise<EngineResult>`
407
+ ### `createTagma().run(config, options): Promise<EngineResult>`
369
408
 
370
409
  Executes the pipeline. Returns `{ success, runId, logPath, summary, states }`.
371
410
 
@@ -431,11 +470,11 @@ throw new TriggerBlockedError('Access denied by policy');
431
470
  throw new TriggerTimeoutError('File did not appear within 30s');
432
471
  ```
433
472
 
434
- ### `loadPlugins(names: string[]): Promise<void>`
473
+ ### `PluginRegistry.loadPlugins(names): Promise<void>`
435
474
 
436
475
  Dynamically loads and registers external plugin packages.
437
476
 
438
- ### `registerPlugin(category, type, handler): void`
477
+ ### `PluginRegistry.registerPlugin(category, type, handler): void`
439
478
 
440
479
  Registers a plugin handler manually. Idempotent — duplicate registrations are silently ignored.
441
480
 
@@ -462,15 +501,15 @@ export const HttpTrigger: TriggerPlugin = {
462
501
 
463
502
  The schema is purely descriptive — plugins still perform their own runtime validation. Supported field types: `string`, `number`, `boolean`, `enum`, `path`, `duration`, `number-or-list`. Each field can declare `required`, `default`, `description`, `enum`, `min`/`max`, `placeholder`. Built-in plugins (`file`/`manual` triggers; `exit_code`/`file_exists`/`output_check` completions; `static_context` middleware) all ship with schemas so editors can generate forms out of the box.
464
503
 
465
- ### `getHandler(category, type): PluginType`
504
+ ### `PluginRegistry.getHandler(category, type): PluginType`
466
505
 
467
506
  Retrieves a registered plugin handler. Throws if the plugin is not registered.
468
507
 
469
- ### `hasHandler(category, type): boolean`
508
+ ### `PluginRegistry.hasHandler(category, type): boolean`
470
509
 
471
510
  Returns `true` if a handler is registered for the given category and type.
472
511
 
473
- ### `listRegistered(category): string[]`
512
+ ### `PluginRegistry.listRegistered(category): string[]`
474
513
 
475
514
  Lists all registered handler type names for a plugin category (`'drivers'`, `'triggers'`, `'completions'`, `'middlewares'`).
476
515
 
@@ -504,8 +543,10 @@ import {
504
543
  removeTask,
505
544
  moveTask,
506
545
  transferTask,
546
+ } from '@tagma/sdk/config';
547
+ import {
507
548
  serializePipeline,
508
- } from '@tagma/sdk';
549
+ } from '@tagma/sdk/yaml';
509
550
 
510
551
  // Build a config programmatically
511
552
  let config = createEmptyPipeline('my-pipeline');
@@ -662,14 +703,14 @@ logger.section('Title'); // file only — visual separator
662
703
  logger.quiet(bulkText); // file only — bulk payload
663
704
  logger.path; // log file path
664
705
  logger.dir; // run artifact directory
665
- logger.close(); // close the persistent file handle (called automatically by runPipeline at run completion)
706
+ logger.close(); // close the persistent file handle (called automatically when Tagma.run completes)
666
707
  ```
667
708
 
668
709
  Pass an optional third argument to stream every appended line out as a
669
- structured `LogRecord` `runPipeline` uses this to emit `task_log` events:
710
+ structured `LogRecord`; the engine uses this to emit `task_log` events:
670
711
 
671
712
  ```ts
672
- import { Logger, type LogRecord } from '@tagma/sdk';
713
+ import { Logger, type LogRecord } from '@tagma/sdk/logger';
673
714
 
674
715
  const logger = new Logger(workDir, runId, (record: LogRecord) => {
675
716
  // record = { level, taskId, timestamp, text }
@@ -1,12 +1,12 @@
1
- import { type PluginRegistry } from './registry';
1
+ import type { PluginRegistry } from './registry';
2
2
  /**
3
- * Register every built-in plugin into `target` (defaults to the process-wide
4
- * default registry). Multi-tenant hosts instantiate one PluginRegistry per
5
- * workspace and call this once per instance so each workspace sees the same
6
- * built-ins without sharing registration state.
3
+ * Register every built-in plugin into `target`. Hosts instantiate one
4
+ * PluginRegistry per workspace or SDK instance and call this once per
5
+ * instance so each workspace sees the same built-ins without sharing
6
+ * registration state.
7
7
  *
8
8
  * Built-in handlers are stateless module singletons — registering the same
9
9
  * handler object into N registries is cheap and safe; no cloning is needed.
10
10
  */
11
- export declare function bootstrapBuiltins(target?: PluginRegistry): void;
11
+ export declare function bootstrapBuiltins(target: PluginRegistry): void;
12
12
  //# sourceMappingURL=bootstrap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAqBlE;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,cAAgC,GAAG,IAAI,CAehF"}
1
+ {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAqBjD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAe9D"}
package/dist/bootstrap.js CHANGED
@@ -1,4 +1,3 @@
1
- import { defaultRegistry } from './registry';
2
1
  // Built-in Drivers
3
2
  // Only opencode is built in. Other drivers (codex, claude-code) ship as
4
3
  // workspace plugins under packages/ and must be declared in pipeline.yaml
@@ -15,15 +14,15 @@ import { OutputCheckCompletion } from './completions/output-check';
15
14
  // Built-in Middleware
16
15
  import { StaticContextMiddleware } from './middlewares/static-context';
17
16
  /**
18
- * Register every built-in plugin into `target` (defaults to the process-wide
19
- * default registry). Multi-tenant hosts instantiate one PluginRegistry per
20
- * workspace and call this once per instance so each workspace sees the same
21
- * built-ins without sharing registration state.
17
+ * Register every built-in plugin into `target`. Hosts instantiate one
18
+ * PluginRegistry per workspace or SDK instance and call this once per
19
+ * instance so each workspace sees the same built-ins without sharing
20
+ * registration state.
22
21
  *
23
22
  * Built-in handlers are stateless module singletons — registering the same
24
23
  * handler object into N registries is cheap and safe; no cloning is needed.
25
24
  */
26
- export function bootstrapBuiltins(target = defaultRegistry) {
25
+ export function bootstrapBuiltins(target) {
27
26
  // Drivers
28
27
  target.registerPlugin('drivers', 'opencode', OpenCodeDriver);
29
28
  // Triggers
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAuB,MAAM,YAAY,CAAC;AAElE,mBAAmB;AACnB,wEAAwE;AACxE,0EAA0E;AAC1E,iCAAiC;AACjC,kEAAkE;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,oBAAoB;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,uBAAuB;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B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AqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,sBAAsB;AACtB,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAsB;IACtD,UAAU;IACV,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;IAE7D,WAAW;IACX,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IACvD,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;IAE3D,cAAc;IACd,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,WAAW,EAAE,kBAAkB,CAAC,CAAC;IACtE,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,aAAa,EAAE,oBAAoB,CAAC,CAAC;IAC1E,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,cAAc,EAAE,qBAAqB,CAAC,CAAC;IAE5E,cAAc;IACd,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,gBAAgB,EAAE,uBAAuB,CAAC,CAAC;AAClF,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { createEmptyPipeline, setPipelineField, upsertTrack, removeTrack, moveTrack, updateTrack, upsertTask, removeTask, moveTask, transferTask, } from './config-ops';
2
+ export { validateRaw } from './validate-raw';
3
+ export type { ValidationError, KnownPluginTypes } from './validate-raw';
4
+ export { buildRawDag } from './dag';
5
+ export type { RawDag, RawDagNode } from './dag';
6
+ export { TASK_ID_RE, isValidTaskId, qualifyTaskId, isQualifiedRef, buildTaskIndex, resolveTaskRef, AMBIGUOUS, } from './task-ref';
7
+ export type { TaskIndex, RefResolution } from './task-ref';
8
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,SAAS,EACT,WAAW,EACX,UAAU,EACV,UAAU,EACV,QAAQ,EACR,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EACL,UAAU,EACV,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,cAAc,EACd,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
package/dist/config.js ADDED
@@ -0,0 +1,5 @@
1
+ export { createEmptyPipeline, setPipelineField, upsertTrack, removeTrack, moveTrack, updateTrack, upsertTask, removeTask, moveTask, transferTask, } from './config-ops';
2
+ export { validateRaw } from './validate-raw';
3
+ export { buildRawDag } from './dag';
4
+ export { TASK_ID_RE, isValidTaskId, qualifyTaskId, isQualifiedRef, buildTaskIndex, resolveTaskRef, AMBIGUOUS, } from './task-ref';
5
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,SAAS,EACT,WAAW,EACX,UAAU,EACV,UAAU,EACV,QAAQ,EACR,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,EACL,UAAU,EACV,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,cAAc,EACd,SAAS,GACV,MAAM,YAAY,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { TaskConfig, TaskPorts, TaskResult } from '../types';
2
+ import type { RunContext } from './run-context';
3
+ export type EffectivePortsResult = {
4
+ readonly kind: 'ready';
5
+ readonly isPromptTask: boolean;
6
+ readonly effectivePorts: TaskPorts | undefined;
7
+ } | {
8
+ readonly kind: 'blocked';
9
+ readonly reason: string;
10
+ };
11
+ export declare function inferEffectivePorts(ctx: RunContext, taskId: string): EffectivePortsResult;
12
+ export interface ExtractSuccessfulOutputsOptions {
13
+ readonly task: TaskConfig;
14
+ readonly effectivePorts: TaskPorts | undefined;
15
+ readonly result: TaskResult;
16
+ }
17
+ export interface ExtractSuccessfulOutputsResult {
18
+ readonly outputs: Readonly<Record<string, unknown>> | null;
19
+ readonly bindingDiagnostic: string | null;
20
+ readonly portDiagnostic: string | null;
21
+ }
22
+ export declare function extractSuccessfulOutputs(options: ExtractSuccessfulOutputsOptions): ExtractSuccessfulOutputsResult;
23
+ //# sourceMappingURL=dataflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataflow.d.ts","sourceRoot":"","sources":["../../src/core/dataflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAMlE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAchD,MAAM,MAAM,oBAAoB,GAC5B;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,SAAS,GAAG,SAAS,CAAC;CAChD,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAEN,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,UAAU,EACf,MAAM,EAAE,MAAM,GACb,oBAAoB,CAoCtB;AAED,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,cAAc,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/C,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B;AAED,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAC3D,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CACxC;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,+BAA+B,GACvC,8BAA8B,CA+BhC"}
@@ -0,0 +1,63 @@
1
+ import { extractTaskBindingOutputs, extractTaskOutputs, inferPromptPorts, } from '../ports';
2
+ function isPromptTaskConfig(task) {
3
+ return task.prompt !== undefined && task.command === undefined;
4
+ }
5
+ function isCommandTaskConfig(task) {
6
+ return task.command !== undefined && task.prompt === undefined;
7
+ }
8
+ export function inferEffectivePorts(ctx, taskId) {
9
+ const node = ctx.dag.nodes.get(taskId);
10
+ const task = node.task;
11
+ const isPromptTask = isPromptTaskConfig(task);
12
+ if (!isPromptTask) {
13
+ return { kind: 'ready', isPromptTask: false, effectivePorts: task.ports };
14
+ }
15
+ const inference = inferPromptPorts({
16
+ upstreams: node.dependsOn.map((upstreamId) => {
17
+ const upstream = ctx.dag.nodes.get(upstreamId);
18
+ const isUpstreamCommand = upstream ? isCommandTaskConfig(upstream.task) : false;
19
+ return {
20
+ taskId: upstreamId,
21
+ outputs: isUpstreamCommand ? upstream?.task.ports?.outputs : undefined,
22
+ };
23
+ }),
24
+ downstreams: (ctx.directDownstreams.get(taskId) ?? []).map((downstreamId) => {
25
+ const downstream = ctx.dag.nodes.get(downstreamId);
26
+ const isDownstreamCommand = downstream ? isCommandTaskConfig(downstream.task) : false;
27
+ return {
28
+ taskId: downstreamId,
29
+ inputs: isDownstreamCommand ? downstream?.task.ports?.inputs : undefined,
30
+ };
31
+ }),
32
+ });
33
+ if (inference.inputConflicts.length > 0 || inference.outputConflicts.length > 0) {
34
+ const lines = [];
35
+ for (const conflict of inference.inputConflicts)
36
+ lines.push(conflict.reason);
37
+ for (const conflict of inference.outputConflicts)
38
+ lines.push(conflict.reason);
39
+ return { kind: 'blocked', reason: lines.join('\n') };
40
+ }
41
+ return { kind: 'ready', isPromptTask: true, effectivePorts: inference.ports };
42
+ }
43
+ export function extractSuccessfulOutputs(options) {
44
+ const { task, effectivePorts, result } = options;
45
+ let extractedOutputs = null;
46
+ const bindingExtraction = extractTaskBindingOutputs(task.outputs, result.stdout, result.stderr, result.normalizedOutput);
47
+ if (task.outputs && Object.keys(task.outputs).length > 0) {
48
+ extractedOutputs = bindingExtraction.outputs;
49
+ }
50
+ const portExtraction = extractTaskOutputs(effectivePorts, result.stdout, result.normalizedOutput);
51
+ if (effectivePorts?.outputs && effectivePorts.outputs.length > 0) {
52
+ extractedOutputs = {
53
+ ...(extractedOutputs ?? {}),
54
+ ...portExtraction.outputs,
55
+ };
56
+ }
57
+ return {
58
+ outputs: extractedOutputs,
59
+ bindingDiagnostic: bindingExtraction.diagnostic,
60
+ portDiagnostic: portExtraction.diagnostic,
61
+ };
62
+ }
63
+ //# sourceMappingURL=dataflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataflow.js","sourceRoot":"","sources":["../../src/core/dataflow.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAGlB,SAAS,kBAAkB,CACzB,IAAgB;IAEhB,OAAO,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC;AACjE,CAAC;AAED,SAAS,mBAAmB,CAC1B,IA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IAAI,IAAI,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzD,gBAAgB,GAAG,iBAAiB,CAAC,OAAO,CAAC;IAC/C,CAAC;IAED,MAAM,cAAc,GAAG,kBAAkB,CACvC,cAAc,EACd,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,gBAAgB,CACxB,CAAC;IACF,IAAI,cAAc,EAAE,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjE,gBAAgB,GAAG;YACjB,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC;YAC3B,GAAG,cAAc,CAAC,OAAO;SAC1B,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,gBAAgB;QACzB,iBAAiB,EAAE,iBAAiB,CAAC,UAAU;QAC/C,cAAc,EAAE,cAAc,CAAC,UAAU;KAC1C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Delete the oldest subdirectories under `logsDir`, keeping only the
3
+ * most recent `keep` total runs (including the currently-live run
4
+ * identified by `excludeRunId`). Directories are sorted
5
+ * lexicographically; because runIds are prefixed with a base-36
6
+ * timestamp, lexicographic order equals chronological order.
7
+ *
8
+ * `excludeRunId` is always skipped from deletion even if it would
9
+ * otherwise be pruned — this prevents a concurrent run from removing a
10
+ * live log directory that is still in use.
11
+ *
12
+ * The live run occupies one slot out of `keep`, so the maximum number
13
+ * of *historical* dirs to retain is `keep - 1`.
14
+ */
15
+ export declare function pruneLogDirs(logsDir: string, keep: number, excludeRunId: string): Promise<void>;
16
+ //# sourceMappingURL=log-prune.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-prune.d.ts","sourceRoot":"","sources":["../../src/core/log-prune.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAqBf"}
@@ -0,0 +1,34 @@
1
+ import { readdir, rm } from 'node:fs/promises';
2
+ import { resolve } from 'node:path';
3
+ /**
4
+ * Delete the oldest subdirectories under `logsDir`, keeping only the
5
+ * most recent `keep` total runs (including the currently-live run
6
+ * identified by `excludeRunId`). Directories are sorted
7
+ * lexicographically; because runIds are prefixed with a base-36
8
+ * timestamp, lexicographic order equals chronological order.
9
+ *
10
+ * `excludeRunId` is always skipped from deletion even if it would
11
+ * otherwise be pruned — this prevents a concurrent run from removing a
12
+ * live log directory that is still in use.
13
+ *
14
+ * The live run occupies one slot out of `keep`, so the maximum number
15
+ * of *historical* dirs to retain is `keep - 1`.
16
+ */
17
+ export async function pruneLogDirs(logsDir, keep, excludeRunId) {
18
+ let entries;
19
+ try {
20
+ entries = await readdir(logsDir);
21
+ }
22
+ catch {
23
+ return; // logsDir doesn't exist yet
24
+ }
25
+ const runDirs = entries
26
+ .filter((e) => e.startsWith('run_') && e !== excludeRunId)
27
+ .sort();
28
+ const historyKeep = Math.max(0, keep - 1);
29
+ const toDelete = runDirs.slice(0, Math.max(0, runDirs.length - historyKeep));
30
+ await Promise.all(toDelete.map((dir) => rm(resolve(logsDir, dir), { recursive: true, force: true }).catch(() => {
31
+ // Ignore deletion errors — stale dirs are better than a crash
32
+ })));
33
+ }
34
+ //# sourceMappingURL=log-prune.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-prune.js","sourceRoot":"","sources":["../../src/core/log-prune.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAAe,EACf,IAAY,EACZ,YAAoB;IAEpB,IAAI,OAAiB,CAAC;IACtB,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,4BAA4B;IACtC,CAAC;IAED,MAAM,OAAO,GAAG,OAAO;SACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,YAAY,CAAC;SACzD,IAAI,EAAE,CAAC;IACV,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC;IAE7E,MAAM,OAAO,CAAC,GAAG,CACf,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CACnB,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;QACrE,8DAA8D;IAChE,CAAC,CAAC,CACH,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { PipelineConfig } from '../types';
2
+ import type { Dag } from '../dag';
3
+ import type { PluginRegistry } from '../registry';
4
+ /**
5
+ * Validate that every plugin referenced by the pipeline (drivers,
6
+ * triggers, completions, middlewares) is registered, and that
7
+ * `continue_from` is only used between drivers that can hand off via
8
+ * sessionResume or text-injection. Throws with all errors aggregated
9
+ * into one message so the caller sees every misconfiguration in a
10
+ * single pass.
11
+ */
12
+ export declare function preflight(config: PipelineConfig, dag: Dag, registry: PluginRegistry): void;
13
+ //# sourceMappingURL=preflight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/core/preflight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA4B,MAAM,UAAU,CAAC;AACzE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQlD;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,cAAc,GACvB,IAAI,CAkEN"}
@@ -0,0 +1,61 @@
1
+ function isCommandOnly(task) {
2
+ return task.command !== undefined && task.prompt === undefined;
3
+ }
4
+ /**
5
+ * Validate that every plugin referenced by the pipeline (drivers,
6
+ * triggers, completions, middlewares) is registered, and that
7
+ * `continue_from` is only used between drivers that can hand off via
8
+ * sessionResume or text-injection. Throws with all errors aggregated
9
+ * into one message so the caller sees every misconfiguration in a
10
+ * single pass.
11
+ */
12
+ export function preflight(config, dag, registry) {
13
+ const errors = [];
14
+ for (const [, node] of dag.nodes) {
15
+ const task = node.task;
16
+ const track = node.track;
17
+ const driverName = task.driver ?? track.driver ?? config.driver ?? 'opencode';
18
+ const isCommand = isCommandOnly(task);
19
+ if (!isCommand && !registry.hasHandler('drivers', driverName)) {
20
+ errors.push(`Task "${node.taskId}": driver "${driverName}" not registered`);
21
+ }
22
+ if (task.trigger && !registry.hasHandler('triggers', task.trigger.type)) {
23
+ errors.push(`Task "${node.taskId}": trigger type "${task.trigger.type}" not registered`);
24
+ }
25
+ if (task.completion && !registry.hasHandler('completions', task.completion.type)) {
26
+ errors.push(`Task "${node.taskId}": completion type "${task.completion.type}" not registered`);
27
+ }
28
+ const mws = task.middlewares ?? track.middlewares ?? [];
29
+ for (const mw of mws) {
30
+ if (!registry.hasHandler('middlewares', mw.type)) {
31
+ errors.push(`Task "${node.taskId}": middleware type "${mw.type}" not registered`);
32
+ }
33
+ }
34
+ if (task.continue_from && registry.hasHandler('drivers', driverName)) {
35
+ const driver = registry.getHandler('drivers', driverName);
36
+ if (!driver.capabilities.sessionResume) {
37
+ const upstreamId = node.resolvedContinueFrom;
38
+ if (upstreamId) {
39
+ const upstream = dag.nodes.get(upstreamId);
40
+ if (upstream) {
41
+ const upstreamDriverName = upstream.task.driver ?? upstream.track.driver ?? config.driver ?? 'opencode';
42
+ const upstreamDriver = registry.hasHandler('drivers', upstreamDriverName)
43
+ ? registry.getHandler('drivers', upstreamDriverName)
44
+ : null;
45
+ const canNormalize = typeof upstreamDriver?.parseResult === 'function';
46
+ if (!canNormalize) {
47
+ errors.push(`Task "${node.taskId}" uses continue_from: "${task.continue_from}", ` +
48
+ `but upstream task "${upstreamId}" its driver ` +
49
+ `does not implement parseResult for text-injection handoff. ` +
50
+ `Use a driver with parseResult, or remove continue_from.`);
51
+ }
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
57
+ if (errors.length > 0) {
58
+ throw new Error(`Preflight validation failed:\n - ${errors.join('\n - ')}`);
59
+ }
60
+ }
61
+ //# sourceMappingURL=preflight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/core/preflight.ts"],"names":[],"mappings":"AAIA,SAAS,aAAa,CACpB,IAAgB;IAEhB,OAAO,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC;AACjE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CACvB,MAAsB,EACtB,GAAQ,EACR,QAAwB;IAExB,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,KAAK,MAAM,CAAC,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,MAAM,UAAU,GAAG,IAAI,CAAC,MA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ason, OnFailure, PipelineConfig, RunEventPayload, TaskState, TaskStatus } from '../types';
2
+ import type { Dag } from '../dag';
3
+ import type { UpstreamBindingData } from '../ports';
4
+ import { type PipelineInfo, type TaskInfo, type TrackInfo } from '../hooks';
5
+ export interface RunContextOptions {
6
+ readonly runId: string;
7
+ readonly dag: Dag;
8
+ readonly config: PipelineConfig;
9
+ readonly workDir: string;
10
+ readonly pipelineInfo: PipelineInfo;
11
+ readonly onEvent?: (event: RunEventPayload) => void;
12
+ }
13
+ /**
14
+ * Per-run state container. Owns the maps and abort tracking that
15
+ * `runPipeline` previously held as closure locals, plus the small
16
+ * methods that read/write that state. Scheduler, dataflow, and
17
+ * task-executor extractions in later phases pass `ctx` instead of
18
+ * relying on closure capture.
19
+ */
20
+ export declare class RunContext {
21
+ readonly runId: string;
22
+ readonly dag: Dag;
23
+ readonly config: PipelineConfig;
24
+ readonly workDir: string;
25
+ readonly pipelineInfo: PipelineInfo;
26
+ readonly onEvent?: (event: RunEventPayload) => void;
27
+ readonly states: Map<string, TaskState>;
28
+ readonly sessionMap: Map<string, string>;
29
+ readonly normalizedMap: Map<string, string>;
30
+ readonly outputValuesMap: Map<string, Readonly<Record<string, unknown>>>;
31
+ readonly bindingDataMap: Map<string, UpstreamBindingData>;
32
+ readonly resolvedInputsMap: Map<string, Readonly<Record<string, unknown>>>;
33
+ readonly directDownstreams: Map<string, string[]>;
34
+ readonly abortController: AbortController;
35
+ abortReason: AbortReason | null;
36
+ constructor(options: RunContextOptions);
37
+ emit(event: RunEventPayload): void;
38
+ setTaskStatus(taskId: string, newStatus: TaskStatus): void;
39
+ getOnFailure(taskId: string): OnFailure;
40
+ isDependencySatisfied(depId: string): 'satisfied' | 'unsatisfied' | 'skip';
41
+ /**
42
+ * H3: stop_all marks every still-waiting task across every track as
43
+ * skipped and aborts in-flight tasks via the shared signal. The
44
+ * terminal lock in setTaskStatus prevents any later re-transition
45
+ * should a completed running task try to overwrite the skipped state.
46
+ */
47
+ applyStopAll(): void;
48
+ buildTaskInfoObj(taskId: string): TaskInfo;
49
+ trackInfoOf(taskId: string): TrackInfo;
50
+ fireHook(taskId: string, event: 'task_success' | 'task_failure'): Promise<void>;
51
+ }
52
+ //# sourceMappingURL=run-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-context.d.ts","sourceRoot":"","sources":["../../src/core/run-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EAET,cAAc,EACd,eAAe,EAEf,SAAS,EACT,UAAU,EACX,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,SAAS,EACf,MAAM,UAAU,CAAC;AAUlB,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;CACrD;AAED;;;;;;GAMG;AACH,qBAAa,UAAU;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAEpD,QAAQ,CAAC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