@tagma/sdk 0.6.12 → 0.7.1
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 +56 -15
- package/dist/bootstrap.d.ts +6 -6
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +5 -6
- package/dist/bootstrap.js.map +1 -1
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +5 -0
- package/dist/config.js.map +1 -0
- package/dist/core/dataflow.d.ts +23 -0
- package/dist/core/dataflow.d.ts.map +1 -0
- package/dist/core/dataflow.js +99 -0
- package/dist/core/dataflow.js.map +1 -0
- package/dist/core/log-prune.d.ts +16 -0
- package/dist/core/log-prune.d.ts.map +1 -0
- package/dist/core/log-prune.js +34 -0
- package/dist/core/log-prune.js.map +1 -0
- package/dist/core/preflight.d.ts +13 -0
- package/dist/core/preflight.d.ts.map +1 -0
- package/dist/core/preflight.js +61 -0
- package/dist/core/preflight.js.map +1 -0
- package/dist/core/run-context.d.ts +52 -0
- package/dist/core/run-context.d.ts.map +1 -0
- package/dist/core/run-context.js +156 -0
- package/dist/core/run-context.js.map +1 -0
- package/dist/core/run-state.d.ts +25 -0
- package/dist/core/run-state.d.ts.map +1 -0
- package/dist/core/run-state.js +93 -0
- package/dist/core/run-state.js.map +1 -0
- package/dist/core/scheduler.d.ts +13 -0
- package/dist/core/scheduler.d.ts.map +1 -0
- package/dist/core/scheduler.js +35 -0
- package/dist/core/scheduler.js.map +1 -0
- package/dist/core/task-executor.d.ts +13 -0
- package/dist/core/task-executor.d.ts.map +1 -0
- package/dist/core/task-executor.js +623 -0
- package/dist/core/task-executor.js.map +1 -0
- package/dist/core/trigger-errors.d.ts +9 -0
- package/dist/core/trigger-errors.d.ts.map +1 -0
- package/dist/core/trigger-errors.js +15 -0
- package/dist/core/trigger-errors.js.map +1 -0
- package/dist/engine.d.ts +6 -14
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +68 -1035
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/pipeline-definition.d.ts +3 -0
- package/dist/pipeline-definition.d.ts.map +1 -0
- package/dist/pipeline-definition.js +4 -0
- package/dist/pipeline-definition.js.map +1 -0
- package/dist/pipeline-runner.d.ts +2 -1
- package/dist/pipeline-runner.d.ts.map +1 -1
- package/dist/pipeline-runner.js +2 -2
- package/dist/pipeline-runner.js.map +1 -1
- package/dist/plugins.d.ts +5 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +3 -0
- package/dist/plugins.js.map +1 -0
- package/dist/ports.d.ts +4 -0
- package/dist/ports.d.ts.map +1 -1
- package/dist/ports.js +27 -4
- package/dist/ports.js.map +1 -1
- package/dist/registry.d.ts +3 -19
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +7 -35
- package/dist/registry.js.map +1 -1
- package/dist/tagma.d.ts +24 -0
- package/dist/tagma.d.ts.map +1 -0
- package/dist/tagma.js +23 -0
- package/dist/tagma.js.map +1 -0
- package/dist/utils-api.d.ts +2 -0
- package/dist/utils-api.d.ts.map +1 -0
- package/dist/utils-api.js +2 -0
- package/dist/utils-api.js.map +1 -0
- package/dist/validate-raw.d.ts +4 -4
- package/dist/validate-raw.js +91 -132
- package/dist/validate-raw.js.map +1 -1
- package/dist/yaml.d.ts +4 -0
- package/dist/yaml.d.ts.map +1 -0
- package/dist/yaml.js +3 -0
- package/dist/yaml.js.map +1 -0
- package/package.json +53 -8
- package/src/bootstrap.ts +6 -6
- package/src/config.ts +26 -0
- package/src/core/dataflow.test.ts +166 -0
- package/src/core/dataflow.ts +161 -0
- package/src/core/log-prune.test.ts +58 -0
- package/src/core/log-prune.ts +43 -0
- package/src/core/preflight.test.ts +49 -0
- package/src/core/preflight.ts +89 -0
- package/src/core/run-context.test.ts +244 -0
- package/src/core/run-context.ts +207 -0
- package/src/core/run-state.test.ts +98 -0
- package/src/core/run-state.ts +122 -0
- package/src/core/scheduler.test.ts +83 -0
- package/src/core/scheduler.ts +42 -0
- package/src/core/task-executor.ts +769 -0
- package/src/core/trigger-errors.ts +15 -0
- package/src/engine-ports-mixed.test.ts +68 -411
- package/src/engine-ports.test.ts +37 -341
- package/src/engine.ts +80 -1248
- package/src/index.ts +28 -0
- package/src/pipeline-definition.ts +5 -0
- package/src/pipeline-runner.test.ts +5 -9
- package/src/pipeline-runner.ts +3 -2
- package/src/plugin-registry.test.ts +7 -10
- package/src/plugins.ts +18 -0
- package/src/ports.test.ts +80 -0
- package/src/ports.ts +36 -4
- package/src/registry.ts +7 -49
- package/src/schema-ports.test.ts +41 -214
- package/src/tagma.test.ts +84 -0
- package/src/tagma.ts +47 -0
- package/src/utils-api.ts +8 -0
- package/src/validate-raw-ports.test.ts +80 -393
- package/src/validate-raw.ts +93 -137
- package/src/yaml.ts +11 -0
- package/dist/sdk.d.ts +0 -32
- package/dist/sdk.d.ts.map +0 -1
- package/dist/sdk.js +0 -41
- package/dist/sdk.js.map +0 -1
- package/src/sdk.ts +0 -151
package/src/index.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { createTagma } from './tagma';
|
|
2
|
+
export type { CreateTagmaOptions, Tagma, TagmaRunOptions } from './tagma';
|
|
3
|
+
export { definePipeline } from './pipeline-definition';
|
|
4
|
+
export { PluginRegistry } from './registry';
|
|
5
|
+
export { TriggerBlockedError, TriggerTimeoutError } from './engine';
|
|
6
|
+
export type { EngineResult, RunEventPayload } from './engine';
|
|
7
|
+
export { RUN_PROTOCOL_VERSION, TASK_LOG_CAP } from './types';
|
|
8
|
+
export type {
|
|
9
|
+
PipelineConfig,
|
|
10
|
+
RawPipelineConfig,
|
|
11
|
+
RawTrackConfig,
|
|
12
|
+
RawTaskConfig,
|
|
13
|
+
TrackConfig,
|
|
14
|
+
TaskConfig,
|
|
15
|
+
RunSnapshotPayload,
|
|
16
|
+
WireRunEvent,
|
|
17
|
+
RunTaskState,
|
|
18
|
+
TaskLogLine,
|
|
19
|
+
ApprovalRequestInfo,
|
|
20
|
+
TaskStatus,
|
|
21
|
+
ApprovalRequest,
|
|
22
|
+
PluginCategory,
|
|
23
|
+
DriverPlugin,
|
|
24
|
+
TriggerPlugin,
|
|
25
|
+
CompletionPlugin,
|
|
26
|
+
MiddlewarePlugin,
|
|
27
|
+
RunEventPayload as PipelineRunEventPayload,
|
|
28
|
+
} from '@tagma/types';
|
|
@@ -11,7 +11,7 @@ function makeDir(): string {
|
|
|
11
11
|
return mkdtempSync(join(tmpdir(), 'tagma-pipeline-runner-'));
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function
|
|
14
|
+
function bindingsPipeline(dir: string): PipelineConfig {
|
|
15
15
|
const emit = join(dir, 'emit.js');
|
|
16
16
|
writeFileSync(
|
|
17
17
|
emit,
|
|
@@ -31,18 +31,14 @@ function portsPipeline(dir: string): PipelineConfig {
|
|
|
31
31
|
id: 'up',
|
|
32
32
|
name: 'up',
|
|
33
33
|
command: `node "${emit}"`,
|
|
34
|
-
|
|
35
|
-
outputs: [{ name: 'city', type: 'string' }],
|
|
36
|
-
},
|
|
34
|
+
outputs: { city: { type: 'string' } },
|
|
37
35
|
},
|
|
38
36
|
{
|
|
39
37
|
id: 'down',
|
|
40
38
|
name: 'down',
|
|
41
39
|
depends_on: ['up'],
|
|
42
40
|
command: `node "${echo}" "{{inputs.city}}"`,
|
|
43
|
-
|
|
44
|
-
inputs: [{ name: 'city', type: 'string', required: true }],
|
|
45
|
-
},
|
|
41
|
+
inputs: { city: { from: 't.up.outputs.city', type: 'string', required: true } },
|
|
46
42
|
},
|
|
47
43
|
],
|
|
48
44
|
},
|
|
@@ -67,7 +63,7 @@ describe('PipelineRunner task snapshot', () => {
|
|
|
67
63
|
test('getTasks reflects task_update inputs and outputs', async () => {
|
|
68
64
|
const dir = makeDir();
|
|
69
65
|
try {
|
|
70
|
-
const runner = await run(
|
|
66
|
+
const runner = await run(bindingsPipeline(dir), dir);
|
|
71
67
|
|
|
72
68
|
const tasks = runner.getTasks();
|
|
73
69
|
const up = tasks.get('t.up');
|
|
@@ -82,7 +78,7 @@ describe('PipelineRunner task snapshot', () => {
|
|
|
82
78
|
test('getTasks folds streamed task logs into the task snapshot', async () => {
|
|
83
79
|
const dir = makeDir();
|
|
84
80
|
try {
|
|
85
|
-
const runner = await run(
|
|
81
|
+
const runner = await run(bindingsPipeline(dir), dir);
|
|
86
82
|
|
|
87
83
|
const tasks = runner.getTasks();
|
|
88
84
|
const up = tasks.get('t.up');
|
package/src/pipeline-runner.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
//
|
|
14
14
|
// const runners = new Map<string, PipelineRunner>();
|
|
15
15
|
//
|
|
16
|
-
// const runner = new PipelineRunner(config, workDir);
|
|
16
|
+
// const runner = new PipelineRunner(config, workDir, { registry });
|
|
17
17
|
// runner.subscribe(event => ipcEmit('run_event', event));
|
|
18
18
|
// runner.start();
|
|
19
19
|
// runners.set(runner.instanceId, runner);
|
|
@@ -29,6 +29,7 @@ import { generateRunId } from './utils';
|
|
|
29
29
|
export type { EngineResult };
|
|
30
30
|
|
|
31
31
|
export type PipelineRunnerStatus = 'idle' | 'running' | 'done' | 'aborted';
|
|
32
|
+
export type PipelineRunnerOptions = Omit<RunPipelineOptions, 'signal' | 'onEvent'>;
|
|
32
33
|
|
|
33
34
|
export class PipelineRunner {
|
|
34
35
|
/**
|
|
@@ -57,7 +58,7 @@ export class PipelineRunner {
|
|
|
57
58
|
constructor(
|
|
58
59
|
private readonly config: PipelineConfig,
|
|
59
60
|
private readonly workDir: string,
|
|
60
|
-
private readonly opts:
|
|
61
|
+
private readonly opts: PipelineRunnerOptions,
|
|
61
62
|
) {
|
|
62
63
|
this.instanceId = generateRunId();
|
|
63
64
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from 'bun:test';
|
|
2
|
-
import { PluginRegistry
|
|
2
|
+
import { PluginRegistry } from './registry';
|
|
3
3
|
import { bootstrapBuiltins } from './bootstrap';
|
|
4
4
|
import { runPipeline } from './engine';
|
|
5
5
|
import type { DriverPlugin, TriggerPlugin, PipelineConfig } from './types';
|
|
@@ -80,7 +80,7 @@ describe('PluginRegistry — instance isolation', () => {
|
|
|
80
80
|
expect(reg.getHandler<DriverPlugin>('drivers', 'mock').name).toBe('two');
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
test('bootstrapBuiltins(target) populates a specific instance
|
|
83
|
+
test('bootstrapBuiltins(target) populates a specific instance', () => {
|
|
84
84
|
const fresh = new PluginRegistry();
|
|
85
85
|
expect(fresh.hasHandler('drivers', 'opencode')).toBe(false);
|
|
86
86
|
|
|
@@ -222,13 +222,9 @@ describe('runPipeline — options.registry isolation', () => {
|
|
|
222
222
|
}
|
|
223
223
|
});
|
|
224
224
|
|
|
225
|
-
test('
|
|
226
|
-
// bootstrapBuiltins into default happens in most host callers; do it
|
|
227
|
-
// explicitly here so the test is independent of module-load order.
|
|
228
|
-
bootstrapBuiltins(defaultRegistry);
|
|
229
|
-
|
|
225
|
+
test('runPipeline rejects missing explicit registry', async () => {
|
|
230
226
|
const config: PipelineConfig = {
|
|
231
|
-
name: '
|
|
227
|
+
name: 'missing-registry',
|
|
232
228
|
tracks: [
|
|
233
229
|
{
|
|
234
230
|
id: 't',
|
|
@@ -239,8 +235,9 @@ describe('runPipeline — options.registry isolation', () => {
|
|
|
239
235
|
};
|
|
240
236
|
const tmp = mkdtempSync(join(tmpdir(), 'tagma-default-'));
|
|
241
237
|
try {
|
|
242
|
-
|
|
243
|
-
|
|
238
|
+
await expect(
|
|
239
|
+
runPipeline(config, tmp, { skipPluginLoading: true } as never),
|
|
240
|
+
).rejects.toThrow(/requires options\.registry/);
|
|
244
241
|
} finally {
|
|
245
242
|
rmSync(tmp, { recursive: true, force: true });
|
|
246
243
|
}
|
package/src/plugins.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { bootstrapBuiltins } from './bootstrap';
|
|
2
|
+
export {
|
|
3
|
+
PluginRegistry,
|
|
4
|
+
isValidPluginName,
|
|
5
|
+
PLUGIN_NAME_RE,
|
|
6
|
+
readPluginManifest,
|
|
7
|
+
} from './registry';
|
|
8
|
+
export type { RegisterResult } from './registry';
|
|
9
|
+
export type {
|
|
10
|
+
PluginCategory,
|
|
11
|
+
PluginModule,
|
|
12
|
+
PluginManifest,
|
|
13
|
+
DriverPlugin,
|
|
14
|
+
TriggerPlugin,
|
|
15
|
+
CompletionPlugin,
|
|
16
|
+
MiddlewarePlugin,
|
|
17
|
+
} from './types';
|
|
18
|
+
|
package/src/ports.test.ts
CHANGED
|
@@ -249,6 +249,59 @@ describe('resolveTaskInputs', () => {
|
|
|
249
249
|
// ─── resolveTaskBindingInputs ────────────────────────────────────────
|
|
250
250
|
|
|
251
251
|
describe('resolveTaskBindingInputs', () => {
|
|
252
|
+
test('coerces typed unified inputs from upstream outputs', () => {
|
|
253
|
+
const t = task({
|
|
254
|
+
id: 'downstream',
|
|
255
|
+
command: 'echo',
|
|
256
|
+
inputs: {
|
|
257
|
+
id: { from: 't.up.outputs.id', type: 'number', required: true },
|
|
258
|
+
enabled: { value: 'true', type: 'boolean' },
|
|
259
|
+
},
|
|
260
|
+
});
|
|
261
|
+
const upstream = new Map([
|
|
262
|
+
[
|
|
263
|
+
't.up',
|
|
264
|
+
{
|
|
265
|
+
outputs: { id: '42' },
|
|
266
|
+
stdout: '',
|
|
267
|
+
stderr: '',
|
|
268
|
+
normalizedOutput: null,
|
|
269
|
+
exitCode: 0,
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
]);
|
|
273
|
+
const res = resolveTaskBindingInputs(t, upstream, ['t.up']);
|
|
274
|
+
expect(res.kind).toBe('ready');
|
|
275
|
+
if (res.kind !== 'ready') return;
|
|
276
|
+
expect(res.inputs).toEqual({ id: 42, enabled: true });
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
test('blocks typed unified input coercion failures', () => {
|
|
280
|
+
const t = task({
|
|
281
|
+
id: 'downstream',
|
|
282
|
+
command: 'echo',
|
|
283
|
+
inputs: {
|
|
284
|
+
id: { from: 't.up.outputs.id', type: 'number', required: true },
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
const upstream = new Map([
|
|
288
|
+
[
|
|
289
|
+
't.up',
|
|
290
|
+
{
|
|
291
|
+
outputs: { id: 'not-a-number' },
|
|
292
|
+
stdout: '',
|
|
293
|
+
stderr: '',
|
|
294
|
+
normalizedOutput: null,
|
|
295
|
+
exitCode: 0,
|
|
296
|
+
},
|
|
297
|
+
],
|
|
298
|
+
]);
|
|
299
|
+
const res = resolveTaskBindingInputs(t, upstream, ['t.up']);
|
|
300
|
+
expect(res.kind).toBe('blocked');
|
|
301
|
+
if (res.kind !== 'blocked') return;
|
|
302
|
+
expect(res.typeErrors).toEqual([{ input: 'id', reason: 'expected number, got string' }]);
|
|
303
|
+
});
|
|
304
|
+
|
|
252
305
|
test('resolves literal values and defaults without requiring ports', () => {
|
|
253
306
|
const t = task({
|
|
254
307
|
id: 'downstream',
|
|
@@ -387,6 +440,33 @@ describe('extractTaskOutputs', () => {
|
|
|
387
440
|
// ─── extractTaskBindingOutputs ───────────────────────────────────────
|
|
388
441
|
|
|
389
442
|
describe('extractTaskBindingOutputs', () => {
|
|
443
|
+
test('coerces typed unified outputs from final-line JSON', () => {
|
|
444
|
+
const r = extractTaskBindingOutputs(
|
|
445
|
+
{
|
|
446
|
+
id: { type: 'number' },
|
|
447
|
+
ok: { from: 'json.success', type: 'boolean' },
|
|
448
|
+
},
|
|
449
|
+
'log\n{"id":"42","success":"true"}\n',
|
|
450
|
+
'',
|
|
451
|
+
null,
|
|
452
|
+
);
|
|
453
|
+
expect(r.outputs).toEqual({ id: 42, ok: true });
|
|
454
|
+
expect(r.diagnostic).toBeNull();
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
test('diagnoses typed unified output coercion failures', () => {
|
|
458
|
+
const r = extractTaskBindingOutputs(
|
|
459
|
+
{
|
|
460
|
+
id: { type: 'number' },
|
|
461
|
+
},
|
|
462
|
+
'{"id":"nope"}',
|
|
463
|
+
'',
|
|
464
|
+
null,
|
|
465
|
+
);
|
|
466
|
+
expect(r.outputs).toEqual({});
|
|
467
|
+
expect(r.diagnostic).toContain('"id": expected number, got string');
|
|
468
|
+
});
|
|
469
|
+
|
|
390
470
|
test('extracts loose outputs from final-line JSON by default', () => {
|
|
391
471
|
const r = extractTaskBindingOutputs(
|
|
392
472
|
{
|
package/src/ports.ts
CHANGED
|
@@ -270,6 +270,7 @@ export type BindingInputResolution =
|
|
|
270
270
|
readonly kind: 'blocked';
|
|
271
271
|
readonly missingRequired: readonly string[];
|
|
272
272
|
readonly ambiguous: readonly { input: string; producers: readonly string[] }[];
|
|
273
|
+
readonly typeErrors: readonly { input: string; reason: string }[];
|
|
273
274
|
readonly reason: string;
|
|
274
275
|
};
|
|
275
276
|
|
|
@@ -287,6 +288,7 @@ export function resolveTaskBindingInputs(
|
|
|
287
288
|
const missingRequired: string[] = [];
|
|
288
289
|
const missingOptional: string[] = [];
|
|
289
290
|
const ambiguous: { input: string; producers: string[] }[] = [];
|
|
291
|
+
const typeErrors: { input: string; reason: string }[] = [];
|
|
290
292
|
|
|
291
293
|
for (const [name, binding] of Object.entries(bindings)) {
|
|
292
294
|
let value: unknown;
|
|
@@ -321,10 +323,16 @@ export function resolveTaskBindingInputs(
|
|
|
321
323
|
continue;
|
|
322
324
|
}
|
|
323
325
|
|
|
324
|
-
|
|
326
|
+
const coerced = coerceBindingValue(binding, value);
|
|
327
|
+
if (coerced.kind === 'error') {
|
|
328
|
+
typeErrors.push({ input: name, reason: coerced.reason });
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
inputs[name] = coerced.value;
|
|
325
333
|
}
|
|
326
334
|
|
|
327
|
-
if (missingRequired.length > 0 || ambiguous.length > 0) {
|
|
335
|
+
if (missingRequired.length > 0 || ambiguous.length > 0 || typeErrors.length > 0) {
|
|
328
336
|
const lines: string[] = [];
|
|
329
337
|
if (missingRequired.length > 0) {
|
|
330
338
|
lines.push(`missing required binding input(s): ${missingRequired.join(', ')}`);
|
|
@@ -335,7 +343,10 @@ export function resolveTaskBindingInputs(
|
|
|
335
343
|
`(${amb.producers.join(', ')}) — use "taskId.outputs.${amb.input}"`,
|
|
336
344
|
);
|
|
337
345
|
}
|
|
338
|
-
|
|
346
|
+
for (const te of typeErrors) {
|
|
347
|
+
lines.push(`binding input "${te.input}": ${te.reason}`);
|
|
348
|
+
}
|
|
349
|
+
return { kind: 'blocked', missingRequired, ambiguous, typeErrors, reason: lines.join('\n') };
|
|
339
350
|
}
|
|
340
351
|
|
|
341
352
|
return { kind: 'ready', inputs, missingOptional };
|
|
@@ -494,6 +505,21 @@ function coerceValue(port: PortDef, raw: unknown): Coercion {
|
|
|
494
505
|
}
|
|
495
506
|
}
|
|
496
507
|
|
|
508
|
+
function coerceBindingValue(
|
|
509
|
+
binding: { readonly type?: PortType; readonly enum?: readonly string[] },
|
|
510
|
+
raw: unknown,
|
|
511
|
+
): Coercion {
|
|
512
|
+
if (!binding.type) return { kind: 'ok', value: raw };
|
|
513
|
+
return coerceValue(
|
|
514
|
+
{
|
|
515
|
+
name: 'binding',
|
|
516
|
+
type: binding.type,
|
|
517
|
+
...(binding.enum ? { enum: binding.enum } : {}),
|
|
518
|
+
},
|
|
519
|
+
raw,
|
|
520
|
+
);
|
|
521
|
+
}
|
|
522
|
+
|
|
497
523
|
function describe(v: unknown): string {
|
|
498
524
|
if (v === null) return 'null';
|
|
499
525
|
if (Array.isArray(v)) return 'array';
|
|
@@ -630,7 +656,13 @@ export function extractTaskBindingOutputs(
|
|
|
630
656
|
continue;
|
|
631
657
|
}
|
|
632
658
|
|
|
633
|
-
|
|
659
|
+
const coerced = coerceBindingValue(binding, value);
|
|
660
|
+
if (coerced.kind === 'error') {
|
|
661
|
+
missing.push(`"${name}": ${coerced.reason}`);
|
|
662
|
+
continue;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
outputs[name] = coerced.value;
|
|
634
666
|
}
|
|
635
667
|
|
|
636
668
|
return {
|
package/src/registry.ts
CHANGED
|
@@ -37,7 +37,7 @@ function singularCategory(category: PluginCategory): string {
|
|
|
37
37
|
* registration time rather than crashing the engine mid-run.
|
|
38
38
|
*
|
|
39
39
|
* For drivers we materialize `capabilities` and assert each field is a
|
|
40
|
-
* boolean
|
|
40
|
+
* boolean �?otherwise a plugin author can write
|
|
41
41
|
* get capabilities() { throw new Error('boom') }
|
|
42
42
|
* and pass the basic typeof check, then crash preflight when the engine
|
|
43
43
|
* touches `driver.capabilities.sessionResume`. (R8)
|
|
@@ -55,7 +55,7 @@ function validateContract(category: PluginCategory, handler: unknown): void {
|
|
|
55
55
|
if (typeof h.buildCommand !== 'function') {
|
|
56
56
|
throw new Error(`drivers plugin "${h.name}" must export buildCommand()`);
|
|
57
57
|
}
|
|
58
|
-
// Materialize capabilities
|
|
58
|
+
// Materialize capabilities �?this triggers any throwing getter NOW
|
|
59
59
|
// instead of during preflight.
|
|
60
60
|
let caps: unknown;
|
|
61
61
|
try {
|
|
@@ -132,7 +132,7 @@ export function isValidPluginName(name: unknown): name is string {
|
|
|
132
132
|
*
|
|
133
133
|
* Returns the strongly-typed manifest if the field is present and
|
|
134
134
|
* well-formed (`category` is one of the four known categories and `type`
|
|
135
|
-
* is a non-empty string). Returns `null` if the field is absent
|
|
135
|
+
* is a non-empty string). Returns `null` if the field is absent �?that
|
|
136
136
|
* is the host's signal that the package is a library, not a plugin.
|
|
137
137
|
*
|
|
138
138
|
* Throws if the field is present but malformed: that's a packaging bug
|
|
@@ -170,9 +170,7 @@ export function readPluginManifest(pkgJson: unknown): PluginManifest | null {
|
|
|
170
170
|
/**
|
|
171
171
|
* Instance-scoped plugin registry. Each workspace in a multi-tenant sidecar
|
|
172
172
|
* owns its own PluginRegistry, so installing/uninstalling a driver in one
|
|
173
|
-
* workspace cannot clobber another.
|
|
174
|
-
* exported at the bottom of this file preserves the historical free-function
|
|
175
|
-
* API (registerPlugin / getHandler / …) for CLI and single-tenant hosts.
|
|
173
|
+
* workspace cannot clobber another.
|
|
176
174
|
*/
|
|
177
175
|
export class PluginRegistry {
|
|
178
176
|
private readonly registries = {
|
|
@@ -216,12 +214,12 @@ export class PluginRegistry {
|
|
|
216
214
|
if (wasReplaced) {
|
|
217
215
|
// D18: surface silent shadowing. Hot-reload flows legitimately replace
|
|
218
216
|
// handlers; installing two different plugin packages that both claim
|
|
219
|
-
// the same (category, type) does not
|
|
217
|
+
// the same (category, type) does not �?the second wins and breaks the
|
|
220
218
|
// first's consumers with no audit trail. A console.warn is cheap,
|
|
221
219
|
// respects existing callers that rely on 'replaced', and gives ops a
|
|
222
220
|
// grep-able signal when registrations collide unexpectedly.
|
|
223
221
|
console.warn(
|
|
224
|
-
`[tagma-sdk] registerPlugin: replaced existing ${category}/${type}
|
|
222
|
+
`[tagma-sdk] registerPlugin: replaced existing ${category}/${type} �?` +
|
|
225
223
|
`check for duplicate plugin packages claiming the same type.`,
|
|
226
224
|
);
|
|
227
225
|
}
|
|
@@ -231,8 +229,7 @@ export class PluginRegistry {
|
|
|
231
229
|
/**
|
|
232
230
|
* Remove a plugin from the in-process registry. Returns true if a plugin
|
|
233
231
|
* was actually removed. Note: ESM module caching is not affected, so
|
|
234
|
-
* re-importing the same file after unregister will yield the cached module
|
|
235
|
-
* callers wanting a fresh load must restart the host process.
|
|
232
|
+
* re-importing the same file after unregister will yield the cached module �? * callers wanting a fresh load must restart the host process.
|
|
236
233
|
*/
|
|
237
234
|
unregisterPlugin(category: PluginCategory, type: string): boolean {
|
|
238
235
|
if (!VALID_CATEGORIES.has(category)) return false;
|
|
@@ -299,42 +296,3 @@ export class PluginRegistry {
|
|
|
299
296
|
}
|
|
300
297
|
}
|
|
301
298
|
}
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Process-wide default registry. Preserves the historical free-function API
|
|
305
|
-
* for CLI and single-tenant hosts. Multi-tenant hosts (the editor sidecar
|
|
306
|
-
* after the one-sidecar refactor) build their own `PluginRegistry` per
|
|
307
|
-
* workspace and pass it through `RunPipelineOptions.registry`.
|
|
308
|
-
*/
|
|
309
|
-
export const defaultRegistry = new PluginRegistry();
|
|
310
|
-
|
|
311
|
-
export function registerPlugin<T extends PluginType>(
|
|
312
|
-
category: PluginCategory,
|
|
313
|
-
type: string,
|
|
314
|
-
handler: T,
|
|
315
|
-
): RegisterResult {
|
|
316
|
-
return defaultRegistry.registerPlugin(category, type, handler);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
export function unregisterPlugin(category: PluginCategory, type: string): boolean {
|
|
320
|
-
return defaultRegistry.unregisterPlugin(category, type);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
export function getHandler<T extends PluginType>(category: PluginCategory, type: string): T {
|
|
324
|
-
return defaultRegistry.getHandler<T>(category, type);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
export function hasHandler(category: PluginCategory, type: string): boolean {
|
|
328
|
-
return defaultRegistry.hasHandler(category, type);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
export function listRegistered(category: PluginCategory): string[] {
|
|
332
|
-
return defaultRegistry.listRegistered(category);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
export function loadPlugins(
|
|
336
|
-
pluginNames: readonly string[],
|
|
337
|
-
resolveFrom?: string,
|
|
338
|
-
): Promise<void> {
|
|
339
|
-
return defaultRegistry.loadPlugins(pluginNames, resolveFrom);
|
|
340
|
-
}
|