@tagma/sdk 0.4.11 → 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.
- package/README.md +572 -566
- package/dist/adapters/websocket-approval.d.ts.map +1 -1
- package/dist/adapters/websocket-approval.js +3 -1
- package/dist/adapters/websocket-approval.js.map +1 -1
- package/dist/approval.d.ts.map +1 -1
- package/dist/approval.js.map +1 -1
- package/dist/completions/exit-code.d.ts.map +1 -1
- package/dist/completions/exit-code.js.map +1 -1
- package/dist/completions/file-exists.d.ts.map +1 -1
- package/dist/completions/file-exists.js.map +1 -1
- package/dist/completions/output-check.js +2 -7
- package/dist/completions/output-check.js.map +1 -1
- package/dist/config-ops.d.ts.map +1 -1
- package/dist/config-ops.js +24 -26
- package/dist/config-ops.js.map +1 -1
- package/dist/dag.d.ts.map +1 -1
- package/dist/dag.js +1 -1
- package/dist/dag.js.map +1 -1
- package/dist/drivers/claude-code.d.ts.map +1 -1
- package/dist/drivers/claude-code.js +10 -5
- package/dist/drivers/claude-code.js.map +1 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +63 -29
- package/dist/engine.js.map +1 -1
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +1 -3
- package/dist/hooks.js.map +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +4 -2
- package/dist/logger.js.map +1 -1
- package/dist/pipeline-runner.d.ts.map +1 -1
- package/dist/pipeline-runner.js +10 -4
- package/dist/pipeline-runner.js.map +1 -1
- package/dist/registry.d.ts +11 -1
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +28 -3
- package/dist/registry.js.map +1 -1
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +18 -13
- package/dist/runner.js.map +1 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +39 -14
- package/dist/schema.js.map +1 -1
- package/dist/schema.test.js +5 -1
- package/dist/schema.test.js.map +1 -1
- package/dist/sdk.d.ts +2 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +1 -1
- package/dist/sdk.js.map +1 -1
- package/dist/triggers/file.d.ts.map +1 -1
- package/dist/triggers/file.js +11 -4
- package/dist/triggers/file.js.map +1 -1
- package/dist/triggers/manual.d.ts.map +1 -1
- package/dist/triggers/manual.js +2 -1
- package/dist/triggers/manual.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +63 -8
- package/dist/utils.js.map +1 -1
- package/dist/validate-raw.d.ts.map +1 -1
- package/dist/validate-raw.js +60 -11
- package/dist/validate-raw.js.map +1 -1
- package/package.json +2 -2
- package/scripts/preinstall.js +1 -1
- package/src/adapters/stdin-approval.ts +106 -106
- package/src/adapters/websocket-approval.ts +224 -220
- package/src/approval.ts +131 -125
- package/src/bootstrap.ts +37 -37
- package/src/completions/exit-code.ts +34 -30
- package/src/completions/file-exists.ts +66 -60
- package/src/completions/output-check.ts +86 -86
- package/src/config-ops.ts +307 -322
- package/src/dag.ts +234 -228
- package/src/drivers/claude-code.ts +250 -240
- package/src/engine.ts +1098 -928
- package/src/hooks.ts +187 -179
- package/src/logger.ts +182 -178
- package/src/middlewares/static-context.ts +45 -45
- package/src/pipeline-runner.ts +156 -150
- package/src/registry.ts +51 -23
- package/src/runner.ts +395 -397
- package/src/schema.test.ts +5 -1
- package/src/schema.ts +338 -298
- package/src/sdk.ts +91 -81
- package/src/triggers/file.ts +33 -14
- package/src/triggers/manual.ts +86 -81
- package/src/types.ts +18 -18
- package/src/utils.ts +202 -140
- package/src/validate-raw.ts +442 -389
|
@@ -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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
+
};
|