@tagma/core 0.1.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 +22 -0
- package/dist/approval.d.ts +13 -0
- package/dist/approval.d.ts.map +1 -0
- package/dist/approval.js +91 -0
- package/dist/approval.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 +55 -0
- package/dist/core/run-context.d.ts.map +1 -0
- package/dist/core/run-context.js +158 -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 +610 -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/dag.d.ts +45 -0
- package/dist/dag.d.ts.map +1 -0
- package/dist/dag.js +177 -0
- package/dist/dag.js.map +1 -0
- package/dist/engine.d.ts +63 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +297 -0
- package/dist/engine.js.map +1 -0
- package/dist/hooks.d.ts +73 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +74 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +59 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +138 -0
- package/dist/logger.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/ports.d.ts +200 -0
- package/dist/ports.d.ts.map +1 -0
- package/dist/ports.js +690 -0
- package/dist/ports.js.map +1 -0
- package/dist/prompt-doc.d.ts +70 -0
- package/dist/prompt-doc.d.ts.map +1 -0
- package/dist/prompt-doc.js +154 -0
- package/dist/prompt-doc.js.map +1 -0
- package/dist/registry.d.ts +67 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +293 -0
- package/dist/registry.js.map +1 -0
- package/dist/task-ref.d.ts +55 -0
- package/dist/task-ref.d.ts.map +1 -0
- package/dist/task-ref.js +103 -0
- package/dist/task-ref.js.map +1 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +14 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +13 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +203 -0
- package/dist/utils.js.map +1 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @tagma/core
|
|
2
|
+
|
|
3
|
+
Runtime-independent orchestration core for Tagma pipelines.
|
|
4
|
+
|
|
5
|
+
This package owns pipeline DAG execution, plugin registries, approval gateways, lifecycle events, logging abstractions, dataflow helpers, prompt document helpers, and the `TagmaRuntime` interface. It does not provide a concrete process runner or file watcher; hosts must pass a runtime implementation to `runPipeline()`.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { PluginRegistry, runPipeline } from '@tagma/core';
|
|
9
|
+
import { bunRuntime } from '@tagma/runtime-bun';
|
|
10
|
+
|
|
11
|
+
const registry = new PluginRegistry();
|
|
12
|
+
const result = await runPipeline(config, process.cwd(), {
|
|
13
|
+
registry,
|
|
14
|
+
runtime: bunRuntime(),
|
|
15
|
+
});
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Use `@tagma/sdk` for the Bun-first convenience API with built-ins registered by default.
|
|
19
|
+
|
|
20
|
+
## Publishing
|
|
21
|
+
|
|
22
|
+
`@tagma/core` is a public npm dependency of `@tagma/runtime-bun` and `@tagma/sdk`. Publish it after `@tagma/types` and before runtime or SDK packages.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ApprovalRequest, ApprovalDecision, ApprovalListener, ApprovalGateway } from './types';
|
|
2
|
+
export type { ApprovalRequest, ApprovalDecision, ApprovalOutcome, ApprovalEvent, ApprovalListener, ApprovalGateway, } from './types';
|
|
3
|
+
export declare class InMemoryApprovalGateway implements ApprovalGateway {
|
|
4
|
+
private readonly pendingMap;
|
|
5
|
+
private readonly listeners;
|
|
6
|
+
request(req: Omit<ApprovalRequest, 'id' | 'createdAt'>): Promise<ApprovalDecision>;
|
|
7
|
+
resolve(approvalId: string, decision: Omit<ApprovalDecision, 'approvalId' | 'decidedAt'>): boolean;
|
|
8
|
+
pending(): readonly ApprovalRequest[];
|
|
9
|
+
subscribe(listener: ApprovalListener): () => void;
|
|
10
|
+
abortAll(reason: string): void;
|
|
11
|
+
private emit;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=approval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../src/approval.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAEhB,gBAAgB,EAChB,eAAe,EAChB,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,eAAe,GAChB,MAAM,SAAS,CAAC;AAUjB,qBAAa,uBAAwB,YAAW,eAAe;IAC7D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmC;IAC9D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA+B;IAEzD,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkClF,OAAO,CACL,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,IAAI,CAAC,gBAAgB,EAAE,YAAY,GAAG,WAAW,CAAC,GAC3D,OAAO;IAkBV,OAAO,IAAI,SAAS,eAAe,EAAE;IAIrC,SAAS,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,IAAI;IAOjD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAe9B,OAAO,CAAC,IAAI;CASb"}
|
package/dist/approval.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { randomUUID } from 'crypto';
|
|
2
|
+
import { nowISO } from './utils';
|
|
3
|
+
export class InMemoryApprovalGateway {
|
|
4
|
+
pendingMap = new Map();
|
|
5
|
+
listeners = new Set();
|
|
6
|
+
request(req) {
|
|
7
|
+
const full = {
|
|
8
|
+
id: randomUUID(),
|
|
9
|
+
createdAt: nowISO(),
|
|
10
|
+
taskId: req.taskId,
|
|
11
|
+
trackId: req.trackId,
|
|
12
|
+
message: req.message,
|
|
13
|
+
timeoutMs: req.timeoutMs,
|
|
14
|
+
metadata: req.metadata,
|
|
15
|
+
};
|
|
16
|
+
return new Promise((resolvePromise) => {
|
|
17
|
+
let timer = null;
|
|
18
|
+
if (full.timeoutMs > 0) {
|
|
19
|
+
timer = setTimeout(() => {
|
|
20
|
+
const entry = this.pendingMap.get(full.id);
|
|
21
|
+
if (!entry)
|
|
22
|
+
return;
|
|
23
|
+
this.pendingMap.delete(full.id);
|
|
24
|
+
const decision = {
|
|
25
|
+
approvalId: full.id,
|
|
26
|
+
outcome: 'timeout',
|
|
27
|
+
reason: `Approval timed out after ${full.timeoutMs}ms`,
|
|
28
|
+
decidedAt: nowISO(),
|
|
29
|
+
};
|
|
30
|
+
this.emit({ type: 'expired', request: full });
|
|
31
|
+
resolvePromise(decision);
|
|
32
|
+
}, full.timeoutMs);
|
|
33
|
+
}
|
|
34
|
+
this.pendingMap.set(full.id, { request: full, settle: resolvePromise, timer });
|
|
35
|
+
this.emit({ type: 'requested', request: full });
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
resolve(approvalId, decision) {
|
|
39
|
+
const entry = this.pendingMap.get(approvalId);
|
|
40
|
+
if (!entry)
|
|
41
|
+
return false;
|
|
42
|
+
this.pendingMap.delete(approvalId);
|
|
43
|
+
if (entry.timer)
|
|
44
|
+
clearTimeout(entry.timer);
|
|
45
|
+
const full = {
|
|
46
|
+
approvalId,
|
|
47
|
+
outcome: decision.outcome,
|
|
48
|
+
actor: decision.actor,
|
|
49
|
+
reason: decision.reason,
|
|
50
|
+
decidedAt: nowISO(),
|
|
51
|
+
};
|
|
52
|
+
this.emit({ type: 'resolved', request: entry.request, decision: full });
|
|
53
|
+
entry.settle(full);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
pending() {
|
|
57
|
+
return Array.from(this.pendingMap.values()).map((e) => e.request);
|
|
58
|
+
}
|
|
59
|
+
subscribe(listener) {
|
|
60
|
+
this.listeners.add(listener);
|
|
61
|
+
return () => {
|
|
62
|
+
this.listeners.delete(listener);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
abortAll(reason) {
|
|
66
|
+
const entries = Array.from(this.pendingMap.entries());
|
|
67
|
+
this.pendingMap.clear();
|
|
68
|
+
for (const [id, entry] of entries) {
|
|
69
|
+
if (entry.timer)
|
|
70
|
+
clearTimeout(entry.timer);
|
|
71
|
+
this.emit({ type: 'aborted', request: entry.request, reason });
|
|
72
|
+
entry.settle({
|
|
73
|
+
approvalId: id,
|
|
74
|
+
outcome: 'aborted',
|
|
75
|
+
reason,
|
|
76
|
+
decidedAt: nowISO(),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
emit(event) {
|
|
81
|
+
for (const listener of this.listeners) {
|
|
82
|
+
try {
|
|
83
|
+
listener(event);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
console.error('[approval gateway] listener error:', err);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=approval.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approval.js","sourceRoot":"","sources":["../src/approval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAmCjC,MAAM,OAAO,uBAAuB;IACjB,UAAU,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC7C,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;IAEzD,OAAO,CAAC,GAA8C;QACpD,MAAM,IAAI,GAAoB;YAC5B,EAAE,EAAE,UAAU,EAAE;YAChB,SAAS,EAAE,MAAM,EAAE;YACnB,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,QAAQ,EAAE,GAAG,CAAC,QAAQ;SACvB,CAAC;QAEF,OAAO,IAAI,OAAO,CAAmB,CAAC,cAAc,EAAE,EAAE;YACtD,IAAI,KAAK,GAAyC,IAAI,CAAC;YACvD,IAAI,IAAI,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC;gBACvB,KAAK,GAAG,UAAU,CA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AE;gBACd,OAAO,EAAE,SAAS;gBAClB,MAAM;gBACN,SAAS,EAAE,MAAM,EAAE;aACpB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAEO,IAAI,CAAC,KAAoB;QAC/B,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,IAAI,CAAC;gBACH,QAAQ,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,GAAG,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TaskConfig, TaskPorts, TaskResult } from '../types';
|
|
2
|
+
import type { RunContext } from './run-context';
|
|
3
|
+
export type EffectivePortsResult = {
|
|
4
|
+
readonly kind: 'ready';
|
|
5
|
+
readonly isPromptTask: boolean;
|
|
6
|
+
readonly effectivePorts: TaskPorts | undefined;
|
|
7
|
+
} | {
|
|
8
|
+
readonly kind: 'blocked';
|
|
9
|
+
readonly reason: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function inferEffectivePorts(ctx: RunContext, taskId: string): EffectivePortsResult;
|
|
12
|
+
export interface ExtractSuccessfulOutputsOptions {
|
|
13
|
+
readonly task: TaskConfig;
|
|
14
|
+
readonly effectivePorts: TaskPorts | undefined;
|
|
15
|
+
readonly result: TaskResult;
|
|
16
|
+
}
|
|
17
|
+
export interface ExtractSuccessfulOutputsResult {
|
|
18
|
+
readonly outputs: Readonly<Record<string, unknown>> | null;
|
|
19
|
+
readonly bindingDiagnostic: string | null;
|
|
20
|
+
readonly portDiagnostic: string | null;
|
|
21
|
+
}
|
|
22
|
+
export declare function extractSuccessfulOutputs(options: ExtractSuccessfulOutputsOptions): ExtractSuccessfulOutputsResult;
|
|
23
|
+
//# sourceMappingURL=dataflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataflow.d.ts","sourceRoot":"","sources":["../../src/core/dataflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,UAAU,EAGV,SAAS,EACT,UAAU,EACX,MAAM,UAAU,CAAC;AAMlB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAgDhD,MAAM,MAAM,oBAAoB,GAC5B;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,SAAS,GAAG,SAAS,CAAC;CAChD,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAEN,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,UAAU,EACf,MAAM,EAAE,MAAM,GACb,oBAAoB,CAoCtB;AAED,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,cAAc,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/C,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B;AAED,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAC3D,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CACxC;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,+BAA+B,GACvC,8BAA8B,CAiChC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { extractTaskBindingOutputs, extractTaskOutputs, inferPromptPorts, } from '../ports';
|
|
2
|
+
function isPromptTaskConfig(task) {
|
|
3
|
+
return task.prompt !== undefined && task.command === undefined;
|
|
4
|
+
}
|
|
5
|
+
function isCommandTaskConfig(task) {
|
|
6
|
+
return task.command !== undefined && task.prompt === undefined;
|
|
7
|
+
}
|
|
8
|
+
function inputBindingsToPorts(bindings) {
|
|
9
|
+
if (!bindings || Object.keys(bindings).length === 0)
|
|
10
|
+
return undefined;
|
|
11
|
+
return Object.entries(bindings).map(([name, binding]) => ({
|
|
12
|
+
name,
|
|
13
|
+
type: binding.type ?? 'json',
|
|
14
|
+
...(binding.description ? { description: binding.description } : {}),
|
|
15
|
+
...(binding.required !== undefined ? { required: binding.required } : {}),
|
|
16
|
+
...(binding.default !== undefined ? { default: binding.default } : {}),
|
|
17
|
+
...(binding.enum ? { enum: [...binding.enum] } : {}),
|
|
18
|
+
...(binding.from ? { from: binding.from } : {}),
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
function outputBindingsToPorts(bindings) {
|
|
22
|
+
if (!bindings || Object.keys(bindings).length === 0)
|
|
23
|
+
return undefined;
|
|
24
|
+
return Object.entries(bindings).map(([name, binding]) => ({
|
|
25
|
+
name,
|
|
26
|
+
type: binding.type ?? 'json',
|
|
27
|
+
...(binding.description ? { description: binding.description } : {}),
|
|
28
|
+
...(binding.default !== undefined ? { default: binding.default } : {}),
|
|
29
|
+
...(binding.enum ? { enum: [...binding.enum] } : {}),
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
function taskBindingsAsPorts(task) {
|
|
33
|
+
const inputs = inputBindingsToPorts(task.inputs);
|
|
34
|
+
const outputs = outputBindingsToPorts(task.outputs);
|
|
35
|
+
if (!inputs && !outputs)
|
|
36
|
+
return undefined;
|
|
37
|
+
return {
|
|
38
|
+
...(inputs ? { inputs } : {}),
|
|
39
|
+
...(outputs ? { outputs } : {}),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function inferEffectivePorts(ctx, taskId) {
|
|
43
|
+
const node = ctx.dag.nodes.get(taskId);
|
|
44
|
+
const task = node.task;
|
|
45
|
+
const isPromptTask = isPromptTaskConfig(task);
|
|
46
|
+
if (!isPromptTask) {
|
|
47
|
+
return { kind: 'ready', isPromptTask: false, effectivePorts: taskBindingsAsPorts(task) };
|
|
48
|
+
}
|
|
49
|
+
const inference = inferPromptPorts({
|
|
50
|
+
upstreams: node.dependsOn.map((upstreamId) => {
|
|
51
|
+
const upstream = ctx.dag.nodes.get(upstreamId);
|
|
52
|
+
const isUpstreamCommand = upstream ? isCommandTaskConfig(upstream.task) : false;
|
|
53
|
+
return {
|
|
54
|
+
taskId: upstreamId,
|
|
55
|
+
outputs: isUpstreamCommand ? outputBindingsToPorts(upstream?.task.outputs) : undefined,
|
|
56
|
+
};
|
|
57
|
+
}),
|
|
58
|
+
downstreams: (ctx.directDownstreams.get(taskId) ?? []).map((downstreamId) => {
|
|
59
|
+
const downstream = ctx.dag.nodes.get(downstreamId);
|
|
60
|
+
const isDownstreamCommand = downstream ? isCommandTaskConfig(downstream.task) : false;
|
|
61
|
+
return {
|
|
62
|
+
taskId: downstreamId,
|
|
63
|
+
inputs: isDownstreamCommand ? inputBindingsToPorts(downstream?.task.inputs) : undefined,
|
|
64
|
+
};
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
67
|
+
if (inference.inputConflicts.length > 0 || inference.outputConflicts.length > 0) {
|
|
68
|
+
const lines = [];
|
|
69
|
+
for (const conflict of inference.inputConflicts)
|
|
70
|
+
lines.push(conflict.reason);
|
|
71
|
+
for (const conflict of inference.outputConflicts)
|
|
72
|
+
lines.push(conflict.reason);
|
|
73
|
+
return { kind: 'blocked', reason: lines.join('\n') };
|
|
74
|
+
}
|
|
75
|
+
return { kind: 'ready', isPromptTask: true, effectivePorts: inference.ports };
|
|
76
|
+
}
|
|
77
|
+
export function extractSuccessfulOutputs(options) {
|
|
78
|
+
const { task, effectivePorts, result } = options;
|
|
79
|
+
let extractedOutputs = null;
|
|
80
|
+
const bindingExtraction = extractTaskBindingOutputs(task.outputs, result.stdout, result.stderr, result.normalizedOutput);
|
|
81
|
+
if (task.outputs && Object.keys(task.outputs).length > 0) {
|
|
82
|
+
extractedOutputs = bindingExtraction.outputs;
|
|
83
|
+
}
|
|
84
|
+
if ((!task.outputs || Object.keys(task.outputs).length === 0) && effectivePorts?.outputs?.length) {
|
|
85
|
+
const portExtraction = extractTaskOutputs(effectivePorts, result.stdout, result.normalizedOutput);
|
|
86
|
+
extractedOutputs = portExtraction.outputs;
|
|
87
|
+
return {
|
|
88
|
+
outputs: extractedOutputs,
|
|
89
|
+
bindingDiagnostic: bindingExtraction.diagnostic,
|
|
90
|
+
portDiagnostic: portExtraction.diagnostic,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
outputs: extractedOutputs,
|
|
95
|
+
bindingDiagnostic: bindingExtraction.diagnostic,
|
|
96
|
+
portDiagnostic: null,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=dataflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataflow.js","sourceRoot":"","sources":["../../src/core/dataflow.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAGlB,SAAS,kBAAkB,CACzB,IAAgB;IAEhB,OAAO,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC;AACjE,CAAC;AAED,SAAS,mBAAmB,CAC1B,IAAgB;IAEhB,OAAO,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC;AACjE,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAuC;IACnE,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACtE,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,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,GAAG,cAAc,CAAC,OAAO,CAAC;QAC1C,OAAO;YACL,OAAO,EAAE,gBAAgB;YACzB,iBAAiB,EAAE,iBAAiB,CAAC,UAAU;YAC/C,cAAc,EAAE,cAAc,CAAC,UAAU;SAC1C,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,gBAAgB;QACzB,iBAAiB,EAAE,iBAAiB,CAAC,UAAU;QAC/C,cAAc,EAAE,IAAI;KACrB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delete the oldest subdirectories under `logsDir`, keeping only the
|
|
3
|
+
* most recent `keep` total runs (including the currently-live run
|
|
4
|
+
* identified by `excludeRunId`). Directories are sorted
|
|
5
|
+
* lexicographically; because runIds are prefixed with a base-36
|
|
6
|
+
* timestamp, lexicographic order equals chronological order.
|
|
7
|
+
*
|
|
8
|
+
* `excludeRunId` is always skipped from deletion even if it would
|
|
9
|
+
* otherwise be pruned — this prevents a concurrent run from removing a
|
|
10
|
+
* live log directory that is still in use.
|
|
11
|
+
*
|
|
12
|
+
* The live run occupies one slot out of `keep`, so the maximum number
|
|
13
|
+
* of *historical* dirs to retain is `keep - 1`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function pruneLogDirs(logsDir: string, keep: number, excludeRunId: string): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=log-prune.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-prune.d.ts","sourceRoot":"","sources":["../../src/core/log-prune.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAqBf"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { readdir, rm } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Delete the oldest subdirectories under `logsDir`, keeping only the
|
|
5
|
+
* most recent `keep` total runs (including the currently-live run
|
|
6
|
+
* identified by `excludeRunId`). Directories are sorted
|
|
7
|
+
* lexicographically; because runIds are prefixed with a base-36
|
|
8
|
+
* timestamp, lexicographic order equals chronological order.
|
|
9
|
+
*
|
|
10
|
+
* `excludeRunId` is always skipped from deletion even if it would
|
|
11
|
+
* otherwise be pruned — this prevents a concurrent run from removing a
|
|
12
|
+
* live log directory that is still in use.
|
|
13
|
+
*
|
|
14
|
+
* The live run occupies one slot out of `keep`, so the maximum number
|
|
15
|
+
* of *historical* dirs to retain is `keep - 1`.
|
|
16
|
+
*/
|
|
17
|
+
export async function pruneLogDirs(logsDir, keep, excludeRunId) {
|
|
18
|
+
let entries;
|
|
19
|
+
try {
|
|
20
|
+
entries = await readdir(logsDir);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return; // logsDir doesn't exist yet
|
|
24
|
+
}
|
|
25
|
+
const runDirs = entries
|
|
26
|
+
.filter((e) => e.startsWith('run_') && e !== excludeRunId)
|
|
27
|
+
.sort();
|
|
28
|
+
const historyKeep = Math.max(0, keep - 1);
|
|
29
|
+
const toDelete = runDirs.slice(0, Math.max(0, runDirs.length - historyKeep));
|
|
30
|
+
await Promise.all(toDelete.map((dir) => rm(resolve(logsDir, dir), { recursive: true, force: true }).catch(() => {
|
|
31
|
+
// Ignore deletion errors — stale dirs are better than a crash
|
|
32
|
+
})));
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=log-prune.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-prune.js","sourceRoot":"","sources":["../../src/core/log-prune.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAAe,EACf,IAAY,EACZ,YAAoB;IAEpB,IAAI,OAAiB,CAAC;IACtB,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,4BAA4B;IACtC,CAAC;IAED,MAAM,OAAO,GAAG,OAAO;SACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,YAAY,CAAC;SACzD,IAAI,EAAE,CAAC;IACV,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC;IAE7E,MAAM,OAAO,CAAC,GAAG,CACf,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CACnB,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;QACrE,8DAA8D;IAChE,CAAC,CAAC,CACH,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PipelineConfig } from '../types';
|
|
2
|
+
import type { Dag } from '../dag';
|
|
3
|
+
import type { PluginRegistry } from '../registry';
|
|
4
|
+
/**
|
|
5
|
+
* Validate that every plugin referenced by the pipeline (drivers,
|
|
6
|
+
* triggers, completions, middlewares) is registered, and that
|
|
7
|
+
* `continue_from` is only used between drivers that can hand off via
|
|
8
|
+
* sessionResume or text-injection. Throws with all errors aggregated
|
|
9
|
+
* into one message so the caller sees every misconfiguration in a
|
|
10
|
+
* single pass.
|
|
11
|
+
*/
|
|
12
|
+
export declare function preflight(config: PipelineConfig, dag: Dag, registry: PluginRegistry): void;
|
|
13
|
+
//# sourceMappingURL=preflight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/core/preflight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA4B,MAAM,UAAU,CAAC;AACzE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQlD;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,cAAc,GACvB,IAAI,CAkEN"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
function isCommandOnly(task) {
|
|
2
|
+
return task.command !== undefined && task.prompt === undefined;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Validate that every plugin referenced by the pipeline (drivers,
|
|
6
|
+
* triggers, completions, middlewares) is registered, and that
|
|
7
|
+
* `continue_from` is only used between drivers that can hand off via
|
|
8
|
+
* sessionResume or text-injection. Throws with all errors aggregated
|
|
9
|
+
* into one message so the caller sees every misconfiguration in a
|
|
10
|
+
* single pass.
|
|
11
|
+
*/
|
|
12
|
+
export function preflight(config, dag, registry) {
|
|
13
|
+
const errors = [];
|
|
14
|
+
for (const [, node] of dag.nodes) {
|
|
15
|
+
const task = node.task;
|
|
16
|
+
const track = node.track;
|
|
17
|
+
const driverName = task.driver ?? track.driver ?? config.driver ?? 'opencode';
|
|
18
|
+
const isCommand = isCommandOnly(task);
|
|
19
|
+
if (!isCommand && !registry.hasHandler('drivers', driverName)) {
|
|
20
|
+
errors.push(`Task "${node.taskId}": driver "${driverName}" not registered`);
|
|
21
|
+
}
|
|
22
|
+
if (task.trigger && !registry.hasHandler('triggers', task.trigger.type)) {
|
|
23
|
+
errors.push(`Task "${node.taskId}": trigger type "${task.trigger.type}" not registered`);
|
|
24
|
+
}
|
|
25
|
+
if (task.completion && !registry.hasHandler('completions', task.completion.type)) {
|
|
26
|
+
errors.push(`Task "${node.taskId}": completion type "${task.completion.type}" not registered`);
|
|
27
|
+
}
|
|
28
|
+
const mws = task.middlewares ?? track.middlewares ?? [];
|
|
29
|
+
for (const mw of mws) {
|
|
30
|
+
if (!registry.hasHandler('middlewares', mw.type)) {
|
|
31
|
+
errors.push(`Task "${node.taskId}": middleware type "${mw.type}" not registered`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (task.continue_from && registry.hasHandler('drivers', driverName)) {
|
|
35
|
+
const driver = registry.getHandler('drivers', driverName);
|
|
36
|
+
if (!driver.capabilities.sessionResume) {
|
|
37
|
+
const upstreamId = node.resolvedContinueFrom;
|
|
38
|
+
if (upstreamId) {
|
|
39
|
+
const upstream = dag.nodes.get(upstreamId);
|
|
40
|
+
if (upstream) {
|
|
41
|
+
const upstreamDriverName = upstream.task.driver ?? upstream.track.driver ?? config.driver ?? 'opencode';
|
|
42
|
+
const upstreamDriver = registry.hasHandler('drivers', upstreamDriverName)
|
|
43
|
+
? registry.getHandler('drivers', upstreamDriverName)
|
|
44
|
+
: null;
|
|
45
|
+
const canNormalize = typeof upstreamDriver?.parseResult === 'function';
|
|
46
|
+
if (!canNormalize) {
|
|
47
|
+
errors.push(`Task "${node.taskId}" uses continue_from: "${task.continue_from}", ` +
|
|
48
|
+
`but upstream task "${upstreamId}" its driver ` +
|
|
49
|
+
`does not implement parseResult for text-injection handoff. ` +
|
|
50
|
+
`Use a driver with parseResult, or remove continue_from.`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (errors.length > 0) {
|
|
58
|
+
throw new Error(`Preflight validation failed:\n - ${errors.join('\n - ')}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=preflight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/core/preflight.ts"],"names":[],"mappings":"AAIA,SAAS,aAAa,CACpB,IAAgB;IAEhB,OAAO,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC;AACjE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CACvB,MAAsB,EACtB,GAAQ,EACR,QAAwB;IAExB,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,KAAK,MAAM,CAAC,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,UAAU,CAAC;QAE9E,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QAEtC,IAAI,CAAC,SAAS,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,CAAC;YAC9D,MAAM,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,MAAM,cAAc,UAAU,kBAAkB,CAAC,CAAC;QAC9E,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACxE,MAAM,CAAC,IAAI,CACT,SAAS,IAAI,CAAC,MAAM,oBAAoB,IAAI,CAAC,OAAO,CAAC,IAAI,kBAAkB,CAC5E,CAAC;QACJ,CAAC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kBAAkB,CAAC;4BACvE,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAe,SAAS,EAAE,kBAAkB,CAAC;4BAClE,CAAC,CAAC,IAAI,CAAC;wBACT,MAAM,YAAY,GAAG,OAAO,cAAc,EAAE,WAAW,KAAK,UAAU,CAAC;wBAEvE,IAAI,CAAC,YAAY,EAAE,CAAC;4BAClB,MAAM,CAAC,IAAI,CACT,SAAS,IAAI,CAAC,MAAM,0BAA0B,IAAI,CAAC,aAAa,KAAK;gCACnE,sBAAsB,UAAU,eAAe;gCAC/C,6DAA6D;gCAC7D,yDAAyD,CAC5D,CAAC;wBACJ,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,qCAAqC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AbortReason, OnFailure, PipelineConfig, RunEventPayload, TaskState, TaskStatus } from '../types';
|
|
2
|
+
import type { Dag } from '../dag';
|
|
3
|
+
import type { UpstreamBindingData } from '../ports';
|
|
4
|
+
import { type PipelineInfo, type TaskInfo, type TrackInfo } from '../hooks';
|
|
5
|
+
import type { TagmaRuntime } from '../types';
|
|
6
|
+
export interface RunContextOptions {
|
|
7
|
+
readonly runId: string;
|
|
8
|
+
readonly dag: Dag;
|
|
9
|
+
readonly config: PipelineConfig;
|
|
10
|
+
readonly workDir: string;
|
|
11
|
+
readonly pipelineInfo: PipelineInfo;
|
|
12
|
+
readonly onEvent?: (event: RunEventPayload) => void;
|
|
13
|
+
readonly runtime: TagmaRuntime;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Per-run state container. Owns the maps and abort tracking that
|
|
17
|
+
* `runPipeline` previously held as closure locals, plus the small
|
|
18
|
+
* methods that read/write that state. Scheduler, dataflow, and
|
|
19
|
+
* task-executor extractions in later phases pass `ctx` instead of
|
|
20
|
+
* relying on closure capture.
|
|
21
|
+
*/
|
|
22
|
+
export declare class RunContext {
|
|
23
|
+
readonly runId: string;
|
|
24
|
+
readonly dag: Dag;
|
|
25
|
+
readonly config: PipelineConfig;
|
|
26
|
+
readonly workDir: string;
|
|
27
|
+
readonly pipelineInfo: PipelineInfo;
|
|
28
|
+
readonly onEvent?: (event: RunEventPayload) => void;
|
|
29
|
+
readonly runtime: TagmaRuntime;
|
|
30
|
+
readonly states: Map<string, TaskState>;
|
|
31
|
+
readonly sessionMap: Map<string, string>;
|
|
32
|
+
readonly normalizedMap: Map<string, string>;
|
|
33
|
+
readonly outputValuesMap: Map<string, Readonly<Record<string, unknown>>>;
|
|
34
|
+
readonly bindingDataMap: Map<string, UpstreamBindingData>;
|
|
35
|
+
readonly resolvedInputsMap: Map<string, Readonly<Record<string, unknown>>>;
|
|
36
|
+
readonly directDownstreams: Map<string, string[]>;
|
|
37
|
+
readonly abortController: AbortController;
|
|
38
|
+
abortReason: AbortReason | null;
|
|
39
|
+
constructor(options: RunContextOptions);
|
|
40
|
+
emit(event: RunEventPayload): void;
|
|
41
|
+
setTaskStatus(taskId: string, newStatus: TaskStatus): void;
|
|
42
|
+
getOnFailure(taskId: string): OnFailure;
|
|
43
|
+
isDependencySatisfied(depId: string): 'satisfied' | 'unsatisfied' | 'skip';
|
|
44
|
+
/**
|
|
45
|
+
* H3: stop_all marks every still-waiting task across every track as
|
|
46
|
+
* skipped and aborts in-flight tasks via the shared signal. The
|
|
47
|
+
* terminal lock in setTaskStatus prevents any later re-transition
|
|
48
|
+
* should a completed running task try to overwrite the skipped state.
|
|
49
|
+
*/
|
|
50
|
+
applyStopAll(): void;
|
|
51
|
+
buildTaskInfoObj(taskId: string): TaskInfo;
|
|
52
|
+
trackInfoOf(taskId: string): TrackInfo;
|
|
53
|
+
fireHook(taskId: string, event: 'task_success' | 'task_failure'): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=run-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-context.d.ts","sourceRoot":"","sources":["../../src/core/run-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EAET,cAAc,EACd,eAAe,EAEf,SAAS,EACT,UAAU,EACX,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,SAAS,EACf,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAU7C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IACpD,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;CAChC;AAED;;;;;;GAMG;AACH,qBAAa,UAAU;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IACpD,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAE/B,QAAQ,CAAC,MAAM,yBAAgC;IAC/C,QAAQ,CAAC,UAAU,sBAA6B;IAChD,QAAQ,CAAC,aAAa,sBAA6B;IACnD,QAAQ,CAAC,eAAe,iDAAwD;IAChF,QAAQ,CAAC,cAAc,mCAA0C;IACjE,QAAQ,CAAC,iBAAiB,iDAAwD;IAClF,QAAQ,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAClD,QAAQ,CAAC,eAAe,kBAAyB;IACjD,WAAW,EAAE,WAAW,GAAG,IAAI,CAAQ;gBAE3B,OAAO,EAAE,iBAAiB;IA8BtC,IAAI,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI;IAIlC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,GAAG,IAAI;IAmC1D,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;IAIvC,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,GAAG,MAAM;IAiB1E;;;;;OAKG;IACH,YAAY,IAAI,IAAI;IAWpB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ;IAgB1C,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;IAKhC,QAAQ,CACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,cAAc,GAAG,cAAc,GACrC,OAAO,CAAC,IAAI,CAAC;CAejB"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { executeHook, buildTaskContext, } from '../hooks';
|
|
2
|
+
import { isTerminal } from './run-state';
|
|
3
|
+
import { nowISO } from '../utils';
|
|
4
|
+
function isPromptTaskConfig(task) {
|
|
5
|
+
return task.prompt !== undefined && task.command === undefined;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Per-run state container. Owns the maps and abort tracking that
|
|
9
|
+
* `runPipeline` previously held as closure locals, plus the small
|
|
10
|
+
* methods that read/write that state. Scheduler, dataflow, and
|
|
11
|
+
* task-executor extractions in later phases pass `ctx` instead of
|
|
12
|
+
* relying on closure capture.
|
|
13
|
+
*/
|
|
14
|
+
export class RunContext {
|
|
15
|
+
runId;
|
|
16
|
+
dag;
|
|
17
|
+
config;
|
|
18
|
+
workDir;
|
|
19
|
+
pipelineInfo;
|
|
20
|
+
onEvent;
|
|
21
|
+
runtime;
|
|
22
|
+
states = new Map();
|
|
23
|
+
sessionMap = new Map();
|
|
24
|
+
normalizedMap = new Map();
|
|
25
|
+
outputValuesMap = new Map();
|
|
26
|
+
bindingDataMap = new Map();
|
|
27
|
+
resolvedInputsMap = new Map();
|
|
28
|
+
directDownstreams;
|
|
29
|
+
abortController = new AbortController();
|
|
30
|
+
abortReason = null;
|
|
31
|
+
constructor(options) {
|
|
32
|
+
this.runId = options.runId;
|
|
33
|
+
this.dag = options.dag;
|
|
34
|
+
this.config = options.config;
|
|
35
|
+
this.workDir = options.workDir;
|
|
36
|
+
this.pipelineInfo = options.pipelineInfo;
|
|
37
|
+
this.onEvent = options.onEvent;
|
|
38
|
+
this.runtime = options.runtime;
|
|
39
|
+
for (const [id, node] of this.dag.nodes) {
|
|
40
|
+
this.states.set(id, {
|
|
41
|
+
config: node.task,
|
|
42
|
+
trackConfig: node.track,
|
|
43
|
+
status: 'idle',
|
|
44
|
+
result: null,
|
|
45
|
+
startedAt: null,
|
|
46
|
+
finishedAt: null,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
this.directDownstreams = new Map();
|
|
50
|
+
for (const [id] of this.dag.nodes)
|
|
51
|
+
this.directDownstreams.set(id, []);
|
|
52
|
+
for (const [id, node] of this.dag.nodes) {
|
|
53
|
+
for (const upstream of node.dependsOn) {
|
|
54
|
+
const list = this.directDownstreams.get(upstream);
|
|
55
|
+
if (list)
|
|
56
|
+
list.push(id);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
emit(event) {
|
|
61
|
+
this.onEvent?.(event);
|
|
62
|
+
}
|
|
63
|
+
setTaskStatus(taskId, newStatus) {
|
|
64
|
+
const state = this.states.get(taskId);
|
|
65
|
+
// Terminal lock: once a task reaches a terminal state it must not be
|
|
66
|
+
// re-transitioned. This prevents stop_all from marking running tasks as
|
|
67
|
+
// skipped and then having their in-flight processTask promise overwrite
|
|
68
|
+
// that with success/failed, producing an invalid double transition.
|
|
69
|
+
if (isTerminal(state.status))
|
|
70
|
+
return;
|
|
71
|
+
state.status = newStatus;
|
|
72
|
+
const result = state.result;
|
|
73
|
+
const cfg = state.config;
|
|
74
|
+
this.emit({
|
|
75
|
+
type: 'task_update',
|
|
76
|
+
runId: this.runId,
|
|
77
|
+
taskId,
|
|
78
|
+
status: newStatus,
|
|
79
|
+
startedAt: state.startedAt ?? undefined,
|
|
80
|
+
finishedAt: state.finishedAt ?? undefined,
|
|
81
|
+
durationMs: result?.durationMs,
|
|
82
|
+
exitCode: result?.exitCode,
|
|
83
|
+
stdout: result?.stdout,
|
|
84
|
+
stderr: result?.stderr,
|
|
85
|
+
stdoutPath: result?.stdoutPath ?? null,
|
|
86
|
+
stderrPath: result?.stderrPath ?? null,
|
|
87
|
+
stdoutBytes: result?.stdoutBytes ?? null,
|
|
88
|
+
stderrBytes: result?.stderrBytes ?? null,
|
|
89
|
+
sessionId: result?.sessionId ?? null,
|
|
90
|
+
normalizedOutput: result?.normalizedOutput ?? null,
|
|
91
|
+
inputs: this.resolvedInputsMap.get(taskId) ?? null,
|
|
92
|
+
outputs: this.outputValuesMap.get(taskId) ?? null,
|
|
93
|
+
resolvedDriver: cfg.driver ?? null,
|
|
94
|
+
resolvedModel: cfg.model ?? null,
|
|
95
|
+
resolvedPermissions: cfg.permissions ?? null,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
getOnFailure(taskId) {
|
|
99
|
+
return this.dag.nodes.get(taskId)?.track.on_failure ?? 'skip_downstream';
|
|
100
|
+
}
|
|
101
|
+
isDependencySatisfied(depId) {
|
|
102
|
+
const depState = this.states.get(depId);
|
|
103
|
+
if (!depState)
|
|
104
|
+
return 'skip';
|
|
105
|
+
switch (depState.status) {
|
|
106
|
+
case 'success':
|
|
107
|
+
return 'satisfied';
|
|
108
|
+
case 'skipped':
|
|
109
|
+
return 'skip';
|
|
110
|
+
case 'failed':
|
|
111
|
+
case 'timeout':
|
|
112
|
+
case 'blocked':
|
|
113
|
+
return this.getOnFailure(depId) === 'ignore' ? 'satisfied' : 'skip';
|
|
114
|
+
default:
|
|
115
|
+
return 'unsatisfied';
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* H3: stop_all marks every still-waiting task across every track as
|
|
120
|
+
* skipped and aborts in-flight tasks via the shared signal. The
|
|
121
|
+
* terminal lock in setTaskStatus prevents any later re-transition
|
|
122
|
+
* should a completed running task try to overwrite the skipped state.
|
|
123
|
+
*/
|
|
124
|
+
applyStopAll() {
|
|
125
|
+
if (this.abortReason === null)
|
|
126
|
+
this.abortReason = 'stop_all';
|
|
127
|
+
this.abortController.abort();
|
|
128
|
+
for (const [id, state] of this.states) {
|
|
129
|
+
if (state.status === 'waiting') {
|
|
130
|
+
state.finishedAt = nowISO();
|
|
131
|
+
this.setTaskStatus(id, 'skipped');
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
buildTaskInfoObj(taskId) {
|
|
136
|
+
const state = this.states.get(taskId);
|
|
137
|
+
return {
|
|
138
|
+
id: taskId,
|
|
139
|
+
name: state.config.name,
|
|
140
|
+
type: isPromptTaskConfig(state.config) ? 'ai' : 'command',
|
|
141
|
+
status: state.status,
|
|
142
|
+
exit_code: state.result?.exitCode ?? null,
|
|
143
|
+
duration_ms: state.result?.durationMs ?? null,
|
|
144
|
+
stderr_path: state.result?.stderrPath ?? null,
|
|
145
|
+
session_id: state.result?.sessionId ?? null,
|
|
146
|
+
started_at: state.startedAt,
|
|
147
|
+
finished_at: state.finishedAt,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
trackInfoOf(taskId) {
|
|
151
|
+
const node = this.dag.nodes.get(taskId);
|
|
152
|
+
return { id: node.track.id, name: node.track.name };
|
|
153
|
+
}
|
|
154
|
+
async fireHook(taskId, event) {
|
|
155
|
+
await executeHook(this.config.hooks, event, buildTaskContext(event, this.pipelineInfo, this.trackInfoOf(taskId), this.buildTaskInfoObj(taskId)), this.runtime, this.workDir, this.abortController.signal);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=run-context.js.map
|