@tagma/sdk 0.4.12 → 0.4.13

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 (88) hide show
  1. package/README.md +572 -566
  2. package/dist/adapters/websocket-approval.d.ts.map +1 -1
  3. package/dist/adapters/websocket-approval.js +3 -1
  4. package/dist/adapters/websocket-approval.js.map +1 -1
  5. package/dist/approval.d.ts.map +1 -1
  6. package/dist/approval.js.map +1 -1
  7. package/dist/completions/exit-code.d.ts.map +1 -1
  8. package/dist/completions/exit-code.js.map +1 -1
  9. package/dist/completions/file-exists.d.ts.map +1 -1
  10. package/dist/completions/file-exists.js.map +1 -1
  11. package/dist/completions/output-check.js +2 -7
  12. package/dist/completions/output-check.js.map +1 -1
  13. package/dist/config-ops.d.ts.map +1 -1
  14. package/dist/config-ops.js +24 -26
  15. package/dist/config-ops.js.map +1 -1
  16. package/dist/dag.d.ts.map +1 -1
  17. package/dist/dag.js +1 -1
  18. package/dist/dag.js.map +1 -1
  19. package/dist/drivers/claude-code.d.ts.map +1 -1
  20. package/dist/drivers/claude-code.js +10 -5
  21. package/dist/drivers/claude-code.js.map +1 -1
  22. package/dist/engine.d.ts.map +1 -1
  23. package/dist/engine.js +54 -27
  24. package/dist/engine.js.map +1 -1
  25. package/dist/hooks.d.ts.map +1 -1
  26. package/dist/hooks.js +1 -3
  27. package/dist/hooks.js.map +1 -1
  28. package/dist/logger.d.ts.map +1 -1
  29. package/dist/logger.js +4 -2
  30. package/dist/logger.js.map +1 -1
  31. package/dist/pipeline-runner.d.ts.map +1 -1
  32. package/dist/pipeline-runner.js +10 -4
  33. package/dist/pipeline-runner.js.map +1 -1
  34. package/dist/registry.d.ts +11 -1
  35. package/dist/registry.d.ts.map +1 -1
  36. package/dist/registry.js +28 -3
  37. package/dist/registry.js.map +1 -1
  38. package/dist/runner.d.ts.map +1 -1
  39. package/dist/runner.js +18 -13
  40. package/dist/runner.js.map +1 -1
  41. package/dist/schema.d.ts.map +1 -1
  42. package/dist/schema.js +14 -14
  43. package/dist/schema.js.map +1 -1
  44. package/dist/schema.test.js +5 -1
  45. package/dist/schema.test.js.map +1 -1
  46. package/dist/sdk.d.ts +2 -2
  47. package/dist/sdk.d.ts.map +1 -1
  48. package/dist/sdk.js +1 -1
  49. package/dist/sdk.js.map +1 -1
  50. package/dist/triggers/file.d.ts.map +1 -1
  51. package/dist/triggers/file.js +11 -4
  52. package/dist/triggers/file.js.map +1 -1
  53. package/dist/triggers/manual.d.ts.map +1 -1
  54. package/dist/triggers/manual.js +2 -1
  55. package/dist/triggers/manual.js.map +1 -1
  56. package/dist/utils.d.ts.map +1 -1
  57. package/dist/utils.js +13 -6
  58. package/dist/utils.js.map +1 -1
  59. package/dist/validate-raw.d.ts.map +1 -1
  60. package/dist/validate-raw.js +40 -11
  61. package/dist/validate-raw.js.map +1 -1
  62. package/package.json +2 -2
  63. package/scripts/preinstall.js +1 -1
  64. package/src/adapters/stdin-approval.ts +106 -106
  65. package/src/adapters/websocket-approval.ts +224 -220
  66. package/src/approval.ts +131 -125
  67. package/src/bootstrap.ts +37 -37
  68. package/src/completions/exit-code.ts +34 -30
  69. package/src/completions/file-exists.ts +66 -60
  70. package/src/completions/output-check.ts +86 -86
  71. package/src/config-ops.ts +307 -322
  72. package/src/dag.ts +234 -228
  73. package/src/drivers/claude-code.ts +250 -240
  74. package/src/engine.ts +1098 -935
  75. package/src/hooks.ts +187 -179
  76. package/src/logger.ts +182 -178
  77. package/src/middlewares/static-context.ts +45 -45
  78. package/src/pipeline-runner.ts +156 -150
  79. package/src/registry.ts +51 -23
  80. package/src/runner.ts +395 -397
  81. package/src/schema.test.ts +5 -1
  82. package/src/schema.ts +338 -328
  83. package/src/sdk.ts +91 -81
  84. package/src/triggers/file.ts +33 -14
  85. package/src/triggers/manual.ts +86 -81
  86. package/src/types.ts +18 -18
  87. package/src/utils.ts +202 -191
  88. package/src/validate-raw.ts +442 -409
@@ -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(config: Record<string, unknown>, result: TaskResult, ctx: CompletionContext): Promise<boolean> {
27
- const checkCmd = config.check as string;
28
- if (!checkCmd) throw new Error('output_check completion: "check" is required');
29
-
30
- const timeoutMs = config.timeout != null
31
- ? parseDuration(String(config.timeout))
32
- : DEFAULT_TIMEOUT_MS;
33
-
34
- const controller = new AbortController();
35
- const timer = setTimeout(() => controller.abort(), timeoutMs);
36
-
37
- // Wire pipeline abort signal into the check process so external abort
38
- // terminates the child instead of leaving it running undetected.
39
- const onAbort = () => controller.abort();
40
- if (ctx.signal) {
41
- if (ctx.signal.aborted) {
42
- controller.abort();
43
- } else {
44
- ctx.signal.addEventListener('abort', onAbort, { once: true });
45
- }
46
- }
47
-
48
- const proc = Bun.spawn(shellArgs(checkCmd) as string[], {
49
- cwd: ctx.workDir,
50
- stdin: 'pipe',
51
- stdout: 'pipe',
52
- stderr: 'pipe',
53
- signal: controller.signal,
54
- });
55
-
56
- try {
57
- if (proc.stdin) {
58
- try {
59
- proc.stdin.write(result.stdout);
60
- proc.stdin.end(); // no await — consistent with runner.ts; proc.exited handles sync
61
- } catch (err: unknown) {
62
- // EPIPE is expected when the check process exits before reading all of stdin
63
- // (e.g. `grep -q` exits on first match). Anything else is a real failure.
64
- const code = (err as NodeJS.ErrnoException)?.code;
65
- if (code !== 'EPIPE') throw err;
66
- }
67
- }
68
-
69
- // Consume stderr concurrently with waiting for exit to prevent pipe-buffer
70
- // deadlock when check script emits more than ~64 KB of stderr output.
71
- const [exitCode, stderr] = await Promise.all([
72
- proc.exited,
73
- new Response(proc.stderr).text(),
74
- ]);
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
+ };