@tagma/sdk 0.4.14 → 0.4.16

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 (67) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +569 -569
  3. package/dist/dag.d.ts.map +1 -1
  4. package/dist/dag.js +58 -69
  5. package/dist/dag.js.map +1 -1
  6. package/dist/engine.d.ts.map +1 -1
  7. package/dist/engine.js +63 -37
  8. package/dist/engine.js.map +1 -1
  9. package/dist/middlewares/static-context.d.ts.map +1 -1
  10. package/dist/middlewares/static-context.js +7 -3
  11. package/dist/middlewares/static-context.js.map +1 -1
  12. package/dist/prompt-doc.d.ts +36 -0
  13. package/dist/prompt-doc.d.ts.map +1 -0
  14. package/dist/prompt-doc.js +44 -0
  15. package/dist/prompt-doc.js.map +1 -0
  16. package/dist/registry.d.ts.map +1 -1
  17. package/dist/registry.js +11 -0
  18. package/dist/registry.js.map +1 -1
  19. package/dist/sdk.d.ts +3 -0
  20. package/dist/sdk.d.ts.map +1 -1
  21. package/dist/sdk.js +4 -0
  22. package/dist/sdk.js.map +1 -1
  23. package/dist/task-ref.d.ts +55 -0
  24. package/dist/task-ref.d.ts.map +1 -0
  25. package/dist/task-ref.js +101 -0
  26. package/dist/task-ref.js.map +1 -0
  27. package/dist/task-ref.test.d.ts +2 -0
  28. package/dist/task-ref.test.d.ts.map +1 -0
  29. package/dist/task-ref.test.js +364 -0
  30. package/dist/task-ref.test.js.map +1 -0
  31. package/dist/templates.d.ts +20 -0
  32. package/dist/templates.d.ts.map +1 -0
  33. package/dist/templates.js +93 -0
  34. package/dist/templates.js.map +1 -0
  35. package/dist/validate-raw.d.ts.map +1 -1
  36. package/dist/validate-raw.js +27 -53
  37. package/dist/validate-raw.js.map +1 -1
  38. package/package.json +2 -2
  39. package/scripts/preinstall.js +31 -31
  40. package/src/adapters/stdin-approval.ts +106 -106
  41. package/src/adapters/websocket-approval.ts +224 -224
  42. package/src/approval.ts +131 -131
  43. package/src/bootstrap.ts +37 -37
  44. package/src/completions/exit-code.ts +34 -34
  45. package/src/completions/file-exists.ts +66 -66
  46. package/src/completions/output-check.ts +86 -86
  47. package/src/config-ops.ts +307 -307
  48. package/src/dag.ts +61 -67
  49. package/src/drivers/claude-code.ts +250 -250
  50. package/src/engine.ts +1137 -1098
  51. package/src/hooks.ts +187 -187
  52. package/src/logger.ts +182 -182
  53. package/src/middlewares/static-context.ts +49 -45
  54. package/src/pipeline-runner.ts +156 -156
  55. package/src/prompt-doc.ts +49 -0
  56. package/src/registry.ts +255 -242
  57. package/src/runner.ts +395 -395
  58. package/src/schema.test.ts +101 -101
  59. package/src/schema.ts +338 -338
  60. package/src/sdk.ts +111 -92
  61. package/src/task-ref.test.ts +401 -0
  62. package/src/task-ref.ts +120 -0
  63. package/src/triggers/file.ts +164 -164
  64. package/src/triggers/manual.ts +86 -86
  65. package/src/types.ts +18 -18
  66. package/src/utils.ts +203 -203
  67. package/src/validate-raw.ts +412 -442
@@ -1,101 +1,101 @@
1
- import { describe, expect, test } from 'bun:test';
2
- import yaml from 'js-yaml';
3
- import type { PipelineConfig, RawPipelineConfig } from './types';
4
- import { deresolvePipeline, serializePipeline } from './schema';
5
-
6
- function parsePipelineYaml(content: string): RawPipelineConfig {
7
- const doc = yaml.load(content) as { pipeline: RawPipelineConfig };
8
- return doc.pipeline;
9
- }
10
-
11
- describe('completion default serialization', () => {
12
- test('serializePipeline omits default exit_code completions from raw configs', () => {
13
- const raw: RawPipelineConfig = {
14
- name: 'Serialize Defaults',
15
- tracks: [
16
- {
17
- id: 'track_a',
18
- name: 'Track A',
19
- tasks: [
20
- { id: 'task_1', prompt: 'hello', completion: { type: 'exit_code' } },
21
- { id: 'task_2', prompt: 'world', completion: { type: 'exit_code', expect: 0 } },
22
- { id: 'task_3', prompt: 'keep me', completion: { type: 'exit_code', expect: 2 } },
23
- ],
24
- },
25
- ],
26
- };
27
-
28
- const parsed = parsePipelineYaml(serializePipeline(raw));
29
- expect(parsed.tracks[0].tasks[0].completion).toBeUndefined();
30
- expect(parsed.tracks[0].tasks[1].completion).toBeUndefined();
31
- expect(parsed.tracks[0].tasks[2].completion).toEqual({ type: 'exit_code', expect: 2 });
32
- });
33
-
34
- test('serializePipeline preserves non-default completion plugins', () => {
35
- const raw: RawPipelineConfig = {
36
- name: 'Serialize Explicit',
37
- tracks: [
38
- {
39
- id: 'track_a',
40
- name: 'Track A',
41
- tasks: [
42
- {
43
- id: 'task_1',
44
- prompt: 'check file',
45
- completion: { type: 'file_exists', path: './out.txt' },
46
- },
47
- ],
48
- },
49
- ],
50
- };
51
-
52
- const parsed = parsePipelineYaml(serializePipeline(raw));
53
- expect(parsed.tracks[0].tasks[0].completion).toEqual({
54
- type: 'file_exists',
55
- path: './out.txt',
56
- });
57
- });
58
-
59
- test('deresolvePipeline also omits the default exit_code completion', () => {
60
- const resolved: PipelineConfig = {
61
- name: 'Deresolve Defaults',
62
- tracks: [
63
- {
64
- id: 'track_a',
65
- name: 'Track A',
66
- driver: 'claude-code',
67
- permissions: { read: true, write: false, execute: false },
68
- on_failure: 'skip_downstream',
69
- cwd: 'D:/workspace',
70
- tasks: [
71
- {
72
- id: 'task_1',
73
- name: 'Task 1',
74
- prompt: 'hello',
75
- driver: 'claude-code',
76
- permissions: { read: true, write: false, execute: false },
77
- cwd: 'D:/workspace',
78
- completion: { type: 'exit_code', expect: 0 },
79
- },
80
- {
81
- id: 'task_2',
82
- name: 'Task 2',
83
- prompt: 'custom',
84
- driver: 'claude-code',
85
- permissions: { read: true, write: false, execute: false },
86
- cwd: 'D:/workspace',
87
- completion: { type: 'output_check', check: 'test -f ./done.txt' },
88
- },
89
- ],
90
- },
91
- ],
92
- };
93
-
94
- const raw = deresolvePipeline(resolved, 'D:/workspace');
95
- expect(raw.tracks[0].tasks[0].completion).toBeUndefined();
96
- expect(raw.tracks[0].tasks[1].completion).toEqual({
97
- type: 'output_check',
98
- check: 'test -f ./done.txt',
99
- });
100
- });
101
- });
1
+ import { describe, expect, test } from 'bun:test';
2
+ import yaml from 'js-yaml';
3
+ import type { PipelineConfig, RawPipelineConfig } from './types';
4
+ import { deresolvePipeline, serializePipeline } from './schema';
5
+
6
+ function parsePipelineYaml(content: string): RawPipelineConfig {
7
+ const doc = yaml.load(content) as { pipeline: RawPipelineConfig };
8
+ return doc.pipeline;
9
+ }
10
+
11
+ describe('completion default serialization', () => {
12
+ test('serializePipeline omits default exit_code completions from raw configs', () => {
13
+ const raw: RawPipelineConfig = {
14
+ name: 'Serialize Defaults',
15
+ tracks: [
16
+ {
17
+ id: 'track_a',
18
+ name: 'Track A',
19
+ tasks: [
20
+ { id: 'task_1', prompt: 'hello', completion: { type: 'exit_code' } },
21
+ { id: 'task_2', prompt: 'world', completion: { type: 'exit_code', expect: 0 } },
22
+ { id: 'task_3', prompt: 'keep me', completion: { type: 'exit_code', expect: 2 } },
23
+ ],
24
+ },
25
+ ],
26
+ };
27
+
28
+ const parsed = parsePipelineYaml(serializePipeline(raw));
29
+ expect(parsed.tracks[0].tasks[0].completion).toBeUndefined();
30
+ expect(parsed.tracks[0].tasks[1].completion).toBeUndefined();
31
+ expect(parsed.tracks[0].tasks[2].completion).toEqual({ type: 'exit_code', expect: 2 });
32
+ });
33
+
34
+ test('serializePipeline preserves non-default completion plugins', () => {
35
+ const raw: RawPipelineConfig = {
36
+ name: 'Serialize Explicit',
37
+ tracks: [
38
+ {
39
+ id: 'track_a',
40
+ name: 'Track A',
41
+ tasks: [
42
+ {
43
+ id: 'task_1',
44
+ prompt: 'check file',
45
+ completion: { type: 'file_exists', path: './out.txt' },
46
+ },
47
+ ],
48
+ },
49
+ ],
50
+ };
51
+
52
+ const parsed = parsePipelineYaml(serializePipeline(raw));
53
+ expect(parsed.tracks[0].tasks[0].completion).toEqual({
54
+ type: 'file_exists',
55
+ path: './out.txt',
56
+ });
57
+ });
58
+
59
+ test('deresolvePipeline also omits the default exit_code completion', () => {
60
+ const resolved: PipelineConfig = {
61
+ name: 'Deresolve Defaults',
62
+ tracks: [
63
+ {
64
+ id: 'track_a',
65
+ name: 'Track A',
66
+ driver: 'claude-code',
67
+ permissions: { read: true, write: false, execute: false },
68
+ on_failure: 'skip_downstream',
69
+ cwd: 'D:/workspace',
70
+ tasks: [
71
+ {
72
+ id: 'task_1',
73
+ name: 'Task 1',
74
+ prompt: 'hello',
75
+ driver: 'claude-code',
76
+ permissions: { read: true, write: false, execute: false },
77
+ cwd: 'D:/workspace',
78
+ completion: { type: 'exit_code', expect: 0 },
79
+ },
80
+ {
81
+ id: 'task_2',
82
+ name: 'Task 2',
83
+ prompt: 'custom',
84
+ driver: 'claude-code',
85
+ permissions: { read: true, write: false, execute: false },
86
+ cwd: 'D:/workspace',
87
+ completion: { type: 'output_check', check: 'test -f ./done.txt' },
88
+ },
89
+ ],
90
+ },
91
+ ],
92
+ };
93
+
94
+ const raw = deresolvePipeline(resolved, 'D:/workspace');
95
+ expect(raw.tracks[0].tasks[0].completion).toBeUndefined();
96
+ expect(raw.tracks[0].tasks[1].completion).toEqual({
97
+ type: 'output_check',
98
+ check: 'test -f ./done.txt',
99
+ });
100
+ });
101
+ });