@tagma/sdk 0.4.14 → 0.4.15

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 (59) 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 +22 -56
  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/sdk.d.ts +3 -0
  17. package/dist/sdk.d.ts.map +1 -1
  18. package/dist/sdk.js +4 -0
  19. package/dist/sdk.js.map +1 -1
  20. package/dist/task-ref.d.ts +55 -0
  21. package/dist/task-ref.d.ts.map +1 -0
  22. package/dist/task-ref.js +101 -0
  23. package/dist/task-ref.js.map +1 -0
  24. package/dist/templates.d.ts +20 -0
  25. package/dist/templates.d.ts.map +1 -0
  26. package/dist/templates.js +93 -0
  27. package/dist/templates.js.map +1 -0
  28. package/dist/validate-raw.d.ts.map +1 -1
  29. package/dist/validate-raw.js +27 -53
  30. package/dist/validate-raw.js.map +1 -1
  31. package/package.json +2 -2
  32. package/scripts/preinstall.js +31 -31
  33. package/src/adapters/stdin-approval.ts +106 -106
  34. package/src/adapters/websocket-approval.ts +224 -224
  35. package/src/approval.ts +131 -131
  36. package/src/bootstrap.ts +37 -37
  37. package/src/completions/exit-code.ts +34 -34
  38. package/src/completions/file-exists.ts +66 -66
  39. package/src/completions/output-check.ts +86 -86
  40. package/src/config-ops.ts +307 -307
  41. package/src/dag.ts +24 -54
  42. package/src/drivers/claude-code.ts +250 -250
  43. package/src/engine.ts +1137 -1098
  44. package/src/hooks.ts +187 -187
  45. package/src/logger.ts +182 -182
  46. package/src/middlewares/static-context.ts +49 -45
  47. package/src/pipeline-runner.ts +156 -156
  48. package/src/prompt-doc.ts +49 -0
  49. package/src/registry.ts +242 -242
  50. package/src/runner.ts +395 -395
  51. package/src/schema.test.ts +101 -101
  52. package/src/schema.ts +338 -338
  53. package/src/sdk.ts +111 -92
  54. package/src/task-ref.ts +120 -0
  55. package/src/triggers/file.ts +164 -164
  56. package/src/triggers/manual.ts +86 -86
  57. package/src/types.ts +18 -18
  58. package/src/utils.ts +203 -203
  59. package/src/validate-raw.ts +412 -442
@@ -1,86 +1,86 @@
1
- import type { CompletionPlugin, CompletionContext, TaskResult } from '../types';
2
- import { shellArgs, parseDuration } from '../utils';
3
-
4
- const DEFAULT_TIMEOUT_MS = 30_000;
5
-
6
- export const OutputCheckCompletion: CompletionPlugin = {
7
- name: 'output_check',
8
- schema: {
9
- description: 'Pipe task stdout into a shell command; mark success when that command exits 0.',
10
- fields: {
11
- check: {
12
- type: 'string',
13
- required: true,
14
- description: 'Shell command to run. Task stdout is piped to its stdin.',
15
- placeholder: "grep -q 'PASS'",
16
- },
17
- timeout: {
18
- type: 'duration',
19
- default: '30s',
20
- description: 'Maximum time to wait for the check command.',
21
- placeholder: '30s',
22
- },
23
- },
24
- },
25
-
26
- async check(
27
- config: Record<string, unknown>,
28
- result: TaskResult,
29
- ctx: CompletionContext,
30
- ): Promise<boolean> {
31
- const checkCmd = config.check as string;
32
- if (!checkCmd) throw new Error('output_check completion: "check" is required');
33
-
34
- const timeoutMs =
35
- config.timeout != null ? parseDuration(String(config.timeout)) : DEFAULT_TIMEOUT_MS;
36
-
37
- const controller = new AbortController();
38
- const timer = setTimeout(() => controller.abort(), timeoutMs);
39
-
40
- // Wire pipeline abort signal into the check process so external abort
41
- // terminates the child instead of leaving it running undetected.
42
- const onAbort = () => controller.abort();
43
- if (ctx.signal) {
44
- if (ctx.signal.aborted) {
45
- controller.abort();
46
- } else {
47
- ctx.signal.addEventListener('abort', onAbort, { once: true });
48
- }
49
- }
50
-
51
- const proc = Bun.spawn(shellArgs(checkCmd) as string[], {
52
- cwd: ctx.workDir,
53
- stdin: 'pipe',
54
- stdout: 'pipe',
55
- stderr: 'pipe',
56
- signal: controller.signal,
57
- });
58
-
59
- try {
60
- if (proc.stdin) {
61
- try {
62
- proc.stdin.write(result.stdout);
63
- proc.stdin.end(); // no await — consistent with runner.ts; proc.exited handles sync
64
- } catch (err: unknown) {
65
- // EPIPE is expected when the check process exits before reading all of stdin
66
- // (e.g. `grep -q` exits on first match). Anything else is a real failure.
67
- const code = (err as NodeJS.ErrnoException)?.code;
68
- if (code !== 'EPIPE') throw err;
69
- }
70
- }
71
-
72
- // Consume stderr concurrently with waiting for exit to prevent pipe-buffer
73
- // deadlock when check script emits more than ~64 KB of stderr output.
74
- const [exitCode, stderr] = await Promise.all([proc.exited, new Response(proc.stderr).text()]);
75
-
76
- if (exitCode !== 0 && stderr.trim()) {
77
- console.warn(`[output_check] "${checkCmd}" exit=${exitCode}: ${stderr.trim()}`);
78
- }
79
-
80
- return exitCode === 0;
81
- } finally {
82
- clearTimeout(timer);
83
- if (ctx.signal) ctx.signal.removeEventListener('abort', onAbort);
84
- }
85
- },
86
- };
1
+ import type { CompletionPlugin, CompletionContext, TaskResult } from '../types';
2
+ import { shellArgs, parseDuration } from '../utils';
3
+
4
+ const DEFAULT_TIMEOUT_MS = 30_000;
5
+
6
+ export const OutputCheckCompletion: CompletionPlugin = {
7
+ name: 'output_check',
8
+ schema: {
9
+ description: 'Pipe task stdout into a shell command; mark success when that command exits 0.',
10
+ fields: {
11
+ check: {
12
+ type: 'string',
13
+ required: true,
14
+ description: 'Shell command to run. Task stdout is piped to its stdin.',
15
+ placeholder: "grep -q 'PASS'",
16
+ },
17
+ timeout: {
18
+ type: 'duration',
19
+ default: '30s',
20
+ description: 'Maximum time to wait for the check command.',
21
+ placeholder: '30s',
22
+ },
23
+ },
24
+ },
25
+
26
+ async check(
27
+ config: Record<string, unknown>,
28
+ result: TaskResult,
29
+ ctx: CompletionContext,
30
+ ): Promise<boolean> {
31
+ const checkCmd = config.check as string;
32
+ if (!checkCmd) throw new Error('output_check completion: "check" is required');
33
+
34
+ const timeoutMs =
35
+ config.timeout != null ? parseDuration(String(config.timeout)) : DEFAULT_TIMEOUT_MS;
36
+
37
+ const controller = new AbortController();
38
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
39
+
40
+ // Wire pipeline abort signal into the check process so external abort
41
+ // terminates the child instead of leaving it running undetected.
42
+ const onAbort = () => controller.abort();
43
+ if (ctx.signal) {
44
+ if (ctx.signal.aborted) {
45
+ controller.abort();
46
+ } else {
47
+ ctx.signal.addEventListener('abort', onAbort, { once: true });
48
+ }
49
+ }
50
+
51
+ const proc = Bun.spawn(shellArgs(checkCmd) as string[], {
52
+ cwd: ctx.workDir,
53
+ stdin: 'pipe',
54
+ stdout: 'pipe',
55
+ stderr: 'pipe',
56
+ signal: controller.signal,
57
+ });
58
+
59
+ try {
60
+ if (proc.stdin) {
61
+ try {
62
+ proc.stdin.write(result.stdout);
63
+ proc.stdin.end(); // no await — consistent with runner.ts; proc.exited handles sync
64
+ } catch (err: unknown) {
65
+ // EPIPE is expected when the check process exits before reading all of stdin
66
+ // (e.g. `grep -q` exits on first match). Anything else is a real failure.
67
+ const code = (err as NodeJS.ErrnoException)?.code;
68
+ if (code !== 'EPIPE') throw err;
69
+ }
70
+ }
71
+
72
+ // Consume stderr concurrently with waiting for exit to prevent pipe-buffer
73
+ // deadlock when check script emits more than ~64 KB of stderr output.
74
+ const [exitCode, stderr] = await Promise.all([proc.exited, new Response(proc.stderr).text()]);
75
+
76
+ if (exitCode !== 0 && stderr.trim()) {
77
+ console.warn(`[output_check] "${checkCmd}" exit=${exitCode}: ${stderr.trim()}`);
78
+ }
79
+
80
+ return exitCode === 0;
81
+ } finally {
82
+ clearTimeout(timer);
83
+ if (ctx.signal) ctx.signal.removeEventListener('abort', onAbort);
84
+ }
85
+ },
86
+ };