@tagma/sdk 0.7.3 → 0.7.4
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 +26 -5
- package/dist/adapters/stdin-approval.d.ts +1 -5
- package/dist/adapters/stdin-approval.d.ts.map +1 -1
- package/dist/adapters/stdin-approval.js +1 -89
- package/dist/adapters/stdin-approval.js.map +1 -1
- package/dist/adapters/websocket-approval.d.ts +1 -27
- package/dist/adapters/websocket-approval.d.ts.map +1 -1
- package/dist/adapters/websocket-approval.js +1 -146
- package/dist/adapters/websocket-approval.js.map +1 -1
- package/dist/approval.d.ts +2 -12
- package/dist/approval.d.ts.map +1 -1
- package/dist/approval.js +1 -90
- package/dist/approval.js.map +1 -1
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/core/task-executor.d.ts.map +1 -1
- package/dist/core/task-executor.js +13 -4
- package/dist/core/task-executor.js.map +1 -1
- package/dist/engine.d.ts +5 -56
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +7 -297
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +4 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +2 -60
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +1 -153
- package/dist/logger.js.map +1 -1
- package/dist/plugins.d.ts +2 -2
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +1 -1
- package/dist/plugins.js.map +1 -1
- package/dist/registry.d.ts +2 -66
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +1 -292
- package/dist/registry.js.map +1 -1
- package/dist/runner.d.ts +1 -35
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +1 -610
- package/dist/runner.js.map +1 -1
- package/dist/runtime/adapters/stdin-approval.d.ts +2 -0
- package/dist/runtime/adapters/stdin-approval.d.ts.map +1 -0
- package/dist/runtime/adapters/stdin-approval.js +2 -0
- package/dist/runtime/adapters/stdin-approval.js.map +1 -0
- package/dist/runtime/adapters/websocket-approval.d.ts +2 -0
- package/dist/runtime/adapters/websocket-approval.d.ts.map +1 -0
- package/dist/runtime/adapters/websocket-approval.js +2 -0
- package/dist/runtime/adapters/websocket-approval.js.map +1 -0
- package/dist/runtime/bun-process-runner.d.ts +2 -0
- package/dist/runtime/bun-process-runner.d.ts.map +1 -0
- package/dist/runtime/bun-process-runner.js +2 -0
- package/dist/runtime/bun-process-runner.js.map +1 -0
- package/dist/runtime.d.ts +2 -8
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +1 -7
- package/dist/runtime.js.map +1 -1
- package/dist/tagma.d.ts +3 -4
- package/dist/tagma.d.ts.map +1 -1
- package/dist/tagma.js +2 -3
- package/dist/tagma.js.map +1 -1
- package/dist/triggers/file.d.ts.map +1 -1
- package/dist/triggers/file.js +74 -107
- package/dist/triggers/file.js.map +1 -1
- package/package.json +15 -4
- package/src/adapters/stdin-approval.ts +1 -106
- package/src/adapters/websocket-approval.ts +1 -224
- package/src/approval.ts +5 -127
- package/src/bootstrap.ts +1 -1
- package/src/core/run-context.test.ts +35 -0
- package/src/core/task-executor.ts +13 -4
- package/src/engine-ports-mixed.test.ts +70 -44
- package/src/engine-ports.test.ts +77 -33
- package/src/engine.ts +18 -444
- package/src/index.ts +4 -6
- package/src/logger.ts +2 -182
- package/src/package-split.test.ts +15 -0
- package/src/pipeline-runner.test.ts +65 -12
- package/src/plugin-registry.test.ts +69 -3
- package/src/plugins.ts +2 -2
- package/src/registry.ts +7 -353
- package/src/runner.ts +1 -666
- package/src/runtime/adapters/stdin-approval.ts +1 -0
- package/src/runtime/adapters/websocket-approval.ts +1 -0
- package/src/runtime/bun-process-runner.ts +1 -0
- package/src/runtime-adapters.test.ts +10 -0
- package/src/runtime.ts +12 -20
- package/src/tagma.test.ts +162 -0
- package/src/tagma.ts +9 -4
- package/src/triggers/file.test.ts +79 -0
- package/src/triggers/file.ts +85 -118
package/src/logger.ts
CHANGED
|
@@ -1,182 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Structured record emitted for every log line. Consumers (e.g. the editor
|
|
6
|
-
* server) use this to stream process-level detail into UIs alongside the
|
|
7
|
-
* on-disk pipeline.log. `taskId` is extracted from a `[task:<id>]` prefix
|
|
8
|
-
* when the call site passes one, or overridden explicitly via the optional
|
|
9
|
-
* `taskId` argument on `section`/`quiet` (which carry no prefix).
|
|
10
|
-
*/
|
|
11
|
-
export type LogLevel = 'info' | 'warn' | 'error' | 'debug' | 'section' | 'quiet';
|
|
12
|
-
|
|
13
|
-
export interface LogRecord {
|
|
14
|
-
readonly level: LogLevel;
|
|
15
|
-
readonly taskId: string | null;
|
|
16
|
-
readonly timestamp: string;
|
|
17
|
-
readonly text: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type LogListener = (record: LogRecord) => void;
|
|
21
|
-
|
|
22
|
-
const TASK_PREFIX_RE = /\[task:([^\]]+)\]/;
|
|
23
|
-
|
|
24
|
-
function taskIdFromPrefix(prefix: string): string | null {
|
|
25
|
-
const m = TASK_PREFIX_RE.exec(prefix);
|
|
26
|
-
return m ? m[1] : null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Dual-channel logger.
|
|
31
|
-
*
|
|
32
|
-
* - `info/warn/error` → console AND file (brief, user-visible events)
|
|
33
|
-
* - `debug` → file ONLY (verbose diagnostics)
|
|
34
|
-
* - `section` → file ONLY (visual separators)
|
|
35
|
-
* - `quiet` → file ONLY (bulk payload like full stdout dumps)
|
|
36
|
-
*
|
|
37
|
-
* Log file path: <workDir>/.tagma/logs/<runId>/pipeline.log (one file per pipeline run,
|
|
38
|
-
* truncated on construction). Every line is also forwarded to the optional
|
|
39
|
-
* `onLine` callback as a structured `LogRecord`, so callers that want to
|
|
40
|
-
* stream the run process over IPC/SSE don't need to tail the file.
|
|
41
|
-
*/
|
|
42
|
-
export class Logger {
|
|
43
|
-
private readonly filePath: string;
|
|
44
|
-
private readonly runDir: string;
|
|
45
|
-
private readonly onLine: LogListener | null;
|
|
46
|
-
/** Persistent file descriptor for append writes (avoids open/close per line). */
|
|
47
|
-
private fd: number | null;
|
|
48
|
-
|
|
49
|
-
constructor(workDir: string, runId: string, onLine?: LogListener) {
|
|
50
|
-
this.runDir = resolve(workDir, '.tagma', 'logs', runId);
|
|
51
|
-
this.filePath = resolve(this.runDir, 'pipeline.log');
|
|
52
|
-
this.onLine = onLine ?? null;
|
|
53
|
-
mkdirSync(dirname(this.filePath), { recursive: true });
|
|
54
|
-
const header =
|
|
55
|
-
`# Pipeline run ${runId} @ ${new Date().toISOString()}\n` +
|
|
56
|
-
`# Host: ${process.platform} ${process.arch} Bun: ${process.versions.bun ?? 'n/a'}\n` +
|
|
57
|
-
`# Work dir: ${workDir}\n\n`;
|
|
58
|
-
writeFileSync(this.filePath, header);
|
|
59
|
-
// Open once for all subsequent appends (O_APPEND is implied by 'a' flag)
|
|
60
|
-
this.fd = openSync(this.filePath, 'a');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
info(prefix: string, message: string): void {
|
|
64
|
-
const ts = timestamp();
|
|
65
|
-
const line = `${ts} ${prefix} ${message}`;
|
|
66
|
-
// eslint-disable-next-line no-console
|
|
67
|
-
console.log(line);
|
|
68
|
-
this.emit('info', ts, line, taskIdFromPrefix(prefix));
|
|
69
|
-
this.append(line);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
warn(prefix: string, message: string): void {
|
|
73
|
-
const ts = timestamp();
|
|
74
|
-
const line = `${ts} ${prefix} WARN: ${message}`;
|
|
75
|
-
console.warn(line);
|
|
76
|
-
this.emit('warn', ts, line, taskIdFromPrefix(prefix));
|
|
77
|
-
this.append(line);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
error(prefix: string, message: string): void {
|
|
81
|
-
const ts = timestamp();
|
|
82
|
-
const line = `${ts} ${prefix} ERROR: ${message}`;
|
|
83
|
-
console.error(line);
|
|
84
|
-
this.emit('error', ts, line, taskIdFromPrefix(prefix));
|
|
85
|
-
this.append(line);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/** File-only diagnostic log line. */
|
|
89
|
-
debug(prefix: string, message: string): void {
|
|
90
|
-
const ts = timestamp();
|
|
91
|
-
const line = `${ts} ${prefix} DEBUG: ${message}`;
|
|
92
|
-
this.emit('debug', ts, line, taskIdFromPrefix(prefix));
|
|
93
|
-
this.append(line);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/** File-only visual separator with title. */
|
|
97
|
-
section(title: string, taskId?: string | null): void {
|
|
98
|
-
const ts = timestamp();
|
|
99
|
-
const text = `\n━━━ ${title} ━━━`;
|
|
100
|
-
this.emit('section', ts, text, taskId ?? null);
|
|
101
|
-
this.append(text);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/** File-only bulk payload (e.g. full stdout / stderr dumps). */
|
|
105
|
-
quiet(message: string, taskId?: string | null): void {
|
|
106
|
-
const ts = timestamp();
|
|
107
|
-
this.emit('quiet', ts, message, taskId ?? null);
|
|
108
|
-
this.append(message);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
private append(line: string): void {
|
|
112
|
-
if (this.fd === null) return;
|
|
113
|
-
try {
|
|
114
|
-
const data = line.endsWith('\n') ? line : line + '\n';
|
|
115
|
-
writeSync(this.fd, data);
|
|
116
|
-
} catch {
|
|
117
|
-
// Swallow log write failures; engine correctness shouldn't depend on logging.
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/** Close the persistent file handle. Called by the engine at run completion. */
|
|
122
|
-
close(): void {
|
|
123
|
-
if (this.fd !== null) {
|
|
124
|
-
try {
|
|
125
|
-
closeSync(this.fd);
|
|
126
|
-
} catch {
|
|
127
|
-
/* already closed */
|
|
128
|
-
}
|
|
129
|
-
this.fd = null;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
private emit(level: LogLevel, ts: string, text: string, taskId: string | null): void {
|
|
134
|
-
if (!this.onLine) return;
|
|
135
|
-
try {
|
|
136
|
-
this.onLine({ level, taskId, timestamp: ts, text });
|
|
137
|
-
} catch {
|
|
138
|
-
// Never let a listener error derail the pipeline.
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
get path(): string {
|
|
143
|
-
return this.filePath;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/** Directory that holds all artifacts for this run (pipeline.log, *.stderr, etc.). */
|
|
147
|
-
get dir(): string {
|
|
148
|
-
return this.runDir;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function timestamp(): string {
|
|
153
|
-
const d = new Date();
|
|
154
|
-
const hh = String(d.getHours()).padStart(2, '0');
|
|
155
|
-
const mm = String(d.getMinutes()).padStart(2, '0');
|
|
156
|
-
const ss = String(d.getSeconds()).padStart(2, '0');
|
|
157
|
-
const ms = String(d.getMilliseconds()).padStart(3, '0');
|
|
158
|
-
return `${hh}:${mm}:${ss}.${ms}`;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/** Return the last `n` non-empty lines of `text`, joined with newlines. */
|
|
162
|
-
export function tailLines(text: string, n: number): string {
|
|
163
|
-
if (!text) return '';
|
|
164
|
-
const lines = text.split(/\r?\n/).filter((l) => l.length > 0);
|
|
165
|
-
return lines.slice(-n).join('\n');
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Truncate a blob to at most `maxBytes` UTF-8 bytes for log embedding,
|
|
170
|
-
* appending a marker when truncation occurred.
|
|
171
|
-
* Uses TextEncoder so CJK and emoji (multi-byte) characters are counted correctly.
|
|
172
|
-
*/
|
|
173
|
-
export function clip(text: string, maxBytes = 16 * 1024): string {
|
|
174
|
-
if (!text) return '';
|
|
175
|
-
const encoder = new TextEncoder();
|
|
176
|
-
const bytes = encoder.encode(text);
|
|
177
|
-
if (bytes.length <= maxBytes) return text;
|
|
178
|
-
const omittedBytes = bytes.length - maxBytes;
|
|
179
|
-
// TextDecoder handles partial code-point boundaries safely (replacement char insertion)
|
|
180
|
-
const truncated = new TextDecoder().decode(bytes.slice(0, maxBytes));
|
|
181
|
-
return truncated + `\n…[truncated ${omittedBytes} bytes]`;
|
|
182
|
-
}
|
|
1
|
+
export { clip, Logger, tailLines } from '@tagma/core';
|
|
2
|
+
export type { LogLevel, LogListener, LogRecord } from '@tagma/core';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { PluginRegistry, InMemoryApprovalGateway } from '@tagma/core';
|
|
3
|
+
import { bunRuntime } from '@tagma/runtime-bun';
|
|
4
|
+
import { createTagma } from './index';
|
|
5
|
+
|
|
6
|
+
describe('Phase 6 package split', () => {
|
|
7
|
+
test('sdk composes the core registry and bun runtime packages', () => {
|
|
8
|
+
const runtime = bunRuntime();
|
|
9
|
+
const tagma = createTagma({ runtime, builtins: false });
|
|
10
|
+
|
|
11
|
+
expect(tagma.registry).toBeInstanceOf(PluginRegistry);
|
|
12
|
+
expect(typeof runtime.runCommand).toBe('function');
|
|
13
|
+
expect(new InMemoryApprovalGateway().pending()).toEqual([]);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
import { describe, expect, test } from 'bun:test';
|
|
2
|
-
import { mkdtempSync, rmSync
|
|
2
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { bootstrapBuiltins } from './bootstrap';
|
|
6
6
|
import { PipelineRunner } from './pipeline-runner';
|
|
7
7
|
import { PluginRegistry } from './registry';
|
|
8
|
-
import type { PipelineConfig } from './types';
|
|
8
|
+
import type { PipelineConfig, TagmaRuntime, TaskResult } from './types';
|
|
9
9
|
|
|
10
10
|
function makeDir(): string {
|
|
11
11
|
return mkdtempSync(join(tmpdir(), 'tagma-pipeline-runner-'));
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
function bindingsPipeline(dir: string): PipelineConfig {
|
|
15
|
-
const emit = join(dir, 'emit.js');
|
|
16
|
-
writeFileSync(
|
|
17
|
-
emit,
|
|
18
|
-
'process.stdout.write(JSON.stringify({ city: "Shanghai" }) + "\\n");\n',
|
|
19
|
-
);
|
|
20
|
-
const echo = join(dir, 'echo.js');
|
|
21
|
-
writeFileSync(echo, 'process.stdout.write(process.argv[2] + "\\n");\n');
|
|
22
|
-
|
|
23
15
|
return {
|
|
24
16
|
name: 'runner-snapshot',
|
|
25
17
|
tracks: [
|
|
@@ -30,14 +22,14 @@ function bindingsPipeline(dir: string): PipelineConfig {
|
|
|
30
22
|
{
|
|
31
23
|
id: 'up',
|
|
32
24
|
name: 'up',
|
|
33
|
-
command:
|
|
25
|
+
command: 'emit-city',
|
|
34
26
|
outputs: { city: { type: 'string' } },
|
|
35
27
|
},
|
|
36
28
|
{
|
|
37
29
|
id: 'down',
|
|
38
30
|
name: 'down',
|
|
39
31
|
depends_on: ['up'],
|
|
40
|
-
command:
|
|
32
|
+
command: 'echo-city "{{inputs.city}}"',
|
|
41
33
|
inputs: { city: { from: 't.up.outputs.city', type: 'string', required: true } },
|
|
42
34
|
},
|
|
43
35
|
],
|
|
@@ -46,11 +38,72 @@ function bindingsPipeline(dir: string): PipelineConfig {
|
|
|
46
38
|
};
|
|
47
39
|
}
|
|
48
40
|
|
|
41
|
+
function taskResult(stdout: string): TaskResult {
|
|
42
|
+
return {
|
|
43
|
+
exitCode: 0,
|
|
44
|
+
stdout,
|
|
45
|
+
stderr: '',
|
|
46
|
+
stdoutPath: null,
|
|
47
|
+
stderrPath: null,
|
|
48
|
+
stdoutBytes: stdout.length,
|
|
49
|
+
stderrBytes: 0,
|
|
50
|
+
durationMs: 1,
|
|
51
|
+
sessionId: null,
|
|
52
|
+
normalizedOutput: null,
|
|
53
|
+
failureKind: null,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function fakeRuntime(): TagmaRuntime {
|
|
58
|
+
return {
|
|
59
|
+
async runCommand(command) {
|
|
60
|
+
return command.startsWith('emit-city')
|
|
61
|
+
? taskResult('{"city":"Shanghai"}\n')
|
|
62
|
+
: taskResult('Shanghai\n');
|
|
63
|
+
},
|
|
64
|
+
async runSpawn() {
|
|
65
|
+
throw new Error('runSpawn should not be called');
|
|
66
|
+
},
|
|
67
|
+
async ensureDir() {
|
|
68
|
+
/* no-op */
|
|
69
|
+
},
|
|
70
|
+
async fileExists() {
|
|
71
|
+
return false;
|
|
72
|
+
},
|
|
73
|
+
async *watch() {
|
|
74
|
+
/* no-op */
|
|
75
|
+
},
|
|
76
|
+
logStore: {
|
|
77
|
+
openRunLog({ runId }) {
|
|
78
|
+
return {
|
|
79
|
+
path: `mem://${runId}/pipeline.log`,
|
|
80
|
+
dir: `mem://${runId}`,
|
|
81
|
+
append() {
|
|
82
|
+
/* memory sink */
|
|
83
|
+
},
|
|
84
|
+
close() {
|
|
85
|
+
/* memory sink */
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
taskOutputPath({ runId, taskId, stream }) {
|
|
90
|
+
return `mem://${runId}/${taskId}.${stream}`;
|
|
91
|
+
},
|
|
92
|
+
logsDir() {
|
|
93
|
+
return 'mem://logs';
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
now: () => new Date('2026-04-26T00:00:00.000Z'),
|
|
97
|
+
sleep: () => Promise.resolve(),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
49
101
|
async function run(config: PipelineConfig, dir: string): Promise<PipelineRunner> {
|
|
50
102
|
const registry = new PluginRegistry();
|
|
51
103
|
bootstrapBuiltins(registry);
|
|
52
104
|
const runner = new PipelineRunner(config, dir, {
|
|
53
105
|
registry,
|
|
106
|
+
runtime: fakeRuntime(),
|
|
54
107
|
skipPluginLoading: true,
|
|
55
108
|
});
|
|
56
109
|
|
|
@@ -2,7 +2,7 @@ import { describe, expect, test } from 'bun:test';
|
|
|
2
2
|
import { PluginRegistry } from './registry';
|
|
3
3
|
import { bootstrapBuiltins } from './bootstrap';
|
|
4
4
|
import { runPipeline } from './engine';
|
|
5
|
-
import type { DriverPlugin, TriggerPlugin, PipelineConfig } from './types';
|
|
5
|
+
import type { DriverPlugin, TriggerPlugin, PipelineConfig, TagmaRuntime, TaskResult } from './types';
|
|
6
6
|
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
7
7
|
import { tmpdir } from 'node:os';
|
|
8
8
|
import { join } from 'node:path';
|
|
@@ -28,6 +28,64 @@ function makeTrigger(name: string, marker: string[]): TriggerPlugin {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
function taskResult(stdout = 'ok\n'): TaskResult {
|
|
32
|
+
return {
|
|
33
|
+
exitCode: 0,
|
|
34
|
+
stdout,
|
|
35
|
+
stderr: '',
|
|
36
|
+
stdoutPath: null,
|
|
37
|
+
stderrPath: null,
|
|
38
|
+
stdoutBytes: stdout.length,
|
|
39
|
+
stderrBytes: 0,
|
|
40
|
+
durationMs: 1,
|
|
41
|
+
sessionId: null,
|
|
42
|
+
normalizedOutput: null,
|
|
43
|
+
failureKind: null,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function fakeRuntime(): TagmaRuntime {
|
|
48
|
+
return {
|
|
49
|
+
async runCommand() {
|
|
50
|
+
return taskResult();
|
|
51
|
+
},
|
|
52
|
+
async runSpawn() {
|
|
53
|
+
return taskResult();
|
|
54
|
+
},
|
|
55
|
+
async ensureDir() {
|
|
56
|
+
/* no-op */
|
|
57
|
+
},
|
|
58
|
+
async fileExists() {
|
|
59
|
+
return false;
|
|
60
|
+
},
|
|
61
|
+
async *watch() {
|
|
62
|
+
/* no-op */
|
|
63
|
+
},
|
|
64
|
+
logStore: {
|
|
65
|
+
openRunLog({ runId }) {
|
|
66
|
+
return {
|
|
67
|
+
path: `mem://${runId}/pipeline.log`,
|
|
68
|
+
dir: `mem://${runId}`,
|
|
69
|
+
append() {
|
|
70
|
+
/* memory sink */
|
|
71
|
+
},
|
|
72
|
+
close() {
|
|
73
|
+
/* memory sink */
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
taskOutputPath({ runId, taskId, stream }) {
|
|
78
|
+
return `mem://${runId}/${taskId}.${stream}`;
|
|
79
|
+
},
|
|
80
|
+
logsDir() {
|
|
81
|
+
return 'mem://logs';
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
now: () => new Date('2026-04-26T00:00:00.000Z'),
|
|
85
|
+
sleep: () => Promise.resolve(),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
31
89
|
describe('PluginRegistry — instance isolation', () => {
|
|
32
90
|
test('two registries do not share drivers registered under the same type', () => {
|
|
33
91
|
const regA = new PluginRegistry();
|
|
@@ -324,8 +382,16 @@ describe('runPipeline — options.registry isolation', () => {
|
|
|
324
382
|
const tmpB = mkdtempSync(join(tmpdir(), 'tagma-regB-'));
|
|
325
383
|
try {
|
|
326
384
|
const [resA, resB] = await Promise.all([
|
|
327
|
-
runPipeline(config, tmpA, {
|
|
328
|
-
|
|
385
|
+
runPipeline(config, tmpA, {
|
|
386
|
+
registry: regA,
|
|
387
|
+
runtime: fakeRuntime(),
|
|
388
|
+
skipPluginLoading: true,
|
|
389
|
+
}),
|
|
390
|
+
runPipeline(config, tmpB, {
|
|
391
|
+
registry: regB,
|
|
392
|
+
runtime: fakeRuntime(),
|
|
393
|
+
skipPluginLoading: true,
|
|
394
|
+
}),
|
|
329
395
|
]);
|
|
330
396
|
expect(resA.success).toBe(true);
|
|
331
397
|
expect(resB.success).toBe(true);
|
package/src/plugins.ts
CHANGED
|
@@ -4,8 +4,8 @@ export {
|
|
|
4
4
|
isValidPluginName,
|
|
5
5
|
PLUGIN_NAME_RE,
|
|
6
6
|
readPluginManifest,
|
|
7
|
-
} from '
|
|
8
|
-
export type { RegisteredCapability, RegisterResult } from '
|
|
7
|
+
} from '@tagma/core';
|
|
8
|
+
export type { RegisteredCapability, RegisterResult } from '@tagma/core';
|
|
9
9
|
export type {
|
|
10
10
|
CapabilityHandler,
|
|
11
11
|
PluginCategory,
|