@tagma/sdk 0.7.1 → 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 +109 -48
- 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 +21 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +21 -11
- package/dist/bootstrap.js.map +1 -1
- package/dist/core/run-context.d.ts +3 -0
- package/dist/core/run-context.d.ts.map +1 -1
- package/dist/core/run-context.js +2 -0
- package/dist/core/run-context.js.map +1 -1
- package/dist/core/task-executor.d.ts.map +1 -1
- package/dist/core/task-executor.js +24 -37
- package/dist/core/task-executor.js.map +1 -1
- package/dist/engine.d.ts +8 -53
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +7 -294
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- 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 +3 -3
- 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 -60
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +1 -253
- 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 +3 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +2 -0
- package/dist/runtime.js.map +1 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +1 -7
- package/dist/schema.js.map +1 -1
- package/dist/tagma.d.ts +13 -4
- package/dist/tagma.d.ts.map +1 -1
- package/dist/tagma.js +7 -2
- 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/dist/validate-raw.d.ts.map +1 -1
- package/dist/validate-raw.js +1 -101
- package/dist/validate-raw.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 +24 -15
- package/src/core/run-context.test.ts +47 -0
- package/src/core/run-context.ts +4 -0
- package/src/core/task-executor.ts +28 -45
- package/src/engine-ports-mixed.test.ts +70 -44
- package/src/engine-ports.test.ts +77 -33
- package/src/engine.ts +21 -439
- package/src/index.ts +7 -4
- 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 +207 -4
- package/src/plugins.ts +6 -3
- package/src/registry.ts +7 -298
- 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 -0
- package/src/schema-ports.test.ts +23 -0
- package/src/schema.ts +1 -7
- package/src/tagma.test.ts +234 -1
- package/src/tagma.ts +24 -4
- package/src/triggers/file.test.ts +79 -0
- package/src/triggers/file.ts +85 -118
- package/src/validate-raw.ts +1 -117
|
@@ -1,147 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
const MAX_PAYLOAD_BYTES = 4_096;
|
|
3
|
-
// Per-client rate limit: at most this many messages per window.
|
|
4
|
-
const RATE_LIMIT_MAX = 10;
|
|
5
|
-
const RATE_LIMIT_WINDOW_MS = 1_000;
|
|
6
|
-
export function attachWebSocketApprovalAdapter(gateway, options = {}) {
|
|
7
|
-
const port = options.port ?? 3000;
|
|
8
|
-
const hostname = options.hostname ?? 'localhost';
|
|
9
|
-
const requiredToken = options.token ?? null;
|
|
10
|
-
const enforceOriginCheck = options.allowAnyOrigin !== true;
|
|
11
|
-
function isLoopbackOrigin(origin) {
|
|
12
|
-
try {
|
|
13
|
-
const host = new URL(origin).hostname.toLowerCase();
|
|
14
|
-
return host === 'localhost' || host === '127.0.0.1' || host === '::1' || host === '[::1]';
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const clients = new Set();
|
|
21
|
-
const clientRates = new Map();
|
|
22
|
-
function broadcast(msg) {
|
|
23
|
-
const text = JSON.stringify(msg);
|
|
24
|
-
for (const ws of clients) {
|
|
25
|
-
ws.send(text);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const unsubscribe = gateway.subscribe((event) => {
|
|
29
|
-
switch (event.type) {
|
|
30
|
-
case 'requested':
|
|
31
|
-
broadcast({ type: 'approval_requested', request: event.request });
|
|
32
|
-
break;
|
|
33
|
-
case 'resolved':
|
|
34
|
-
broadcast({ type: 'approval_resolved', request: event.request, decision: event.decision });
|
|
35
|
-
break;
|
|
36
|
-
case 'expired':
|
|
37
|
-
broadcast({ type: 'approval_expired', request: event.request });
|
|
38
|
-
break;
|
|
39
|
-
case 'aborted':
|
|
40
|
-
broadcast({ type: 'approval_aborted', request: event.request, reason: event.reason });
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
const server = Bun.serve({
|
|
45
|
-
port,
|
|
46
|
-
hostname,
|
|
47
|
-
fetch(req, server) {
|
|
48
|
-
if (enforceOriginCheck) {
|
|
49
|
-
const origin = req.headers.get('origin');
|
|
50
|
-
if (origin && !isLoopbackOrigin(origin)) {
|
|
51
|
-
return new Response('forbidden origin', { status: 403 });
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
// M11: enforce token before any upgrade so an unauthenticated client
|
|
55
|
-
// can't even open a socket. Tokens may arrive via header or query.
|
|
56
|
-
if (requiredToken !== null) {
|
|
57
|
-
const headerToken = req.headers.get('x-tagma-token') ?? '';
|
|
58
|
-
let queryToken = '';
|
|
59
|
-
try {
|
|
60
|
-
queryToken = new URL(req.url).searchParams.get('token') ?? '';
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
/* malformed URL — leave queryToken empty */
|
|
64
|
-
}
|
|
65
|
-
const presented = headerToken || queryToken;
|
|
66
|
-
if (presented !== requiredToken) {
|
|
67
|
-
return new Response('unauthorized', { status: 401 });
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
if (server.upgrade(req))
|
|
71
|
-
return undefined;
|
|
72
|
-
return new Response('tagma-sdk WebSocket approval endpoint', { status: 426 });
|
|
73
|
-
},
|
|
74
|
-
websocket: {
|
|
75
|
-
open(ws) {
|
|
76
|
-
clients.add(ws);
|
|
77
|
-
// Sync current pending approvals to newly connected client.
|
|
78
|
-
ws.send(JSON.stringify({ type: 'pending', requests: gateway.pending() }));
|
|
79
|
-
},
|
|
80
|
-
message(ws, raw) {
|
|
81
|
-
const rawStr = typeof raw === 'string' ? raw : raw.toString();
|
|
82
|
-
// Payload size guard — reject oversized messages before parsing.
|
|
83
|
-
if (rawStr.length > MAX_PAYLOAD_BYTES) {
|
|
84
|
-
ws.send(JSON.stringify({ type: 'error', message: 'message too large' }));
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
// Per-client rate limit.
|
|
88
|
-
const now = Date.now();
|
|
89
|
-
const rate = clientRates.get(ws) ?? { count: 0, resetAt: now + RATE_LIMIT_WINDOW_MS };
|
|
90
|
-
if (now >= rate.resetAt) {
|
|
91
|
-
rate.count = 0;
|
|
92
|
-
rate.resetAt = now + RATE_LIMIT_WINDOW_MS;
|
|
93
|
-
}
|
|
94
|
-
rate.count++;
|
|
95
|
-
clientRates.set(ws, rate);
|
|
96
|
-
if (rate.count > RATE_LIMIT_MAX) {
|
|
97
|
-
ws.send(JSON.stringify({ type: 'error', message: 'rate limit exceeded' }));
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
let msg;
|
|
101
|
-
try {
|
|
102
|
-
msg = JSON.parse(rawStr);
|
|
103
|
-
}
|
|
104
|
-
catch {
|
|
105
|
-
ws.send(JSON.stringify({ type: 'error', message: 'invalid JSON' }));
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if (!isResolveMessage(msg)) {
|
|
109
|
-
ws.send(JSON.stringify({ type: 'error', message: 'unknown message type' }));
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
const ok = gateway.resolve(msg.approvalId, {
|
|
113
|
-
outcome: msg.outcome,
|
|
114
|
-
actor: msg.actor ?? 'websocket',
|
|
115
|
-
reason: msg.reason,
|
|
116
|
-
});
|
|
117
|
-
if (!ok) {
|
|
118
|
-
ws.send(JSON.stringify({
|
|
119
|
-
type: 'error',
|
|
120
|
-
message: `approval ${msg.approvalId} not found or already resolved`,
|
|
121
|
-
}));
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
close(ws) {
|
|
125
|
-
clients.delete(ws);
|
|
126
|
-
clientRates.delete(ws);
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
});
|
|
130
|
-
return {
|
|
131
|
-
port: server.port,
|
|
132
|
-
detach() {
|
|
133
|
-
unsubscribe();
|
|
134
|
-
clients.clear();
|
|
135
|
-
server.stop(true);
|
|
136
|
-
},
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
function isResolveMessage(v) {
|
|
140
|
-
if (typeof v !== 'object' || v === null)
|
|
141
|
-
return false;
|
|
142
|
-
const m = v;
|
|
143
|
-
return (m['type'] === 'resolve' &&
|
|
144
|
-
typeof m['approvalId'] === 'string' &&
|
|
145
|
-
(m['outcome'] === 'approved' || m['outcome'] === 'rejected'));
|
|
146
|
-
}
|
|
1
|
+
export * from '../runtime/adapters/websocket-approval';
|
|
147
2
|
//# sourceMappingURL=websocket-approval.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket-approval.js","sourceRoot":"","sources":["../../src/adapters/websocket-approval.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"websocket-approval.js","sourceRoot":"","sources":["../../src/adapters/websocket-approval.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC"}
|
package/dist/approval.d.ts
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export type {
|
|
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
|
-
}
|
|
1
|
+
export { InMemoryApprovalGateway } from '@tagma/core';
|
|
2
|
+
export type { ApprovalDecision, ApprovalEvent, ApprovalGateway, ApprovalListener, ApprovalOutcome, ApprovalRequest, } from '@tagma/core';
|
|
13
3
|
//# sourceMappingURL=approval.d.ts.map
|
package/dist/approval.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../src/approval.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../src/approval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,aAAa,CAAC"}
|
package/dist/approval.js
CHANGED
|
@@ -1,91 +1,2 @@
|
|
|
1
|
-
|
|
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
|
-
}
|
|
1
|
+
export { InMemoryApprovalGateway } from '@tagma/core';
|
|
91
2
|
//# sourceMappingURL=approval.js.map
|
package/dist/approval.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approval.js","sourceRoot":"","sources":["../src/approval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"approval.js","sourceRoot":"","sources":["../src/approval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/bootstrap.d.ts
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
import type { PluginRegistry } from '
|
|
1
|
+
import type { PluginRegistry } from '@tagma/core';
|
|
2
|
+
export declare const BuiltinTagmaPlugin: {
|
|
3
|
+
name: string;
|
|
4
|
+
capabilities: {
|
|
5
|
+
drivers: {
|
|
6
|
+
opencode: import("@tagma/types").DriverPlugin;
|
|
7
|
+
};
|
|
8
|
+
triggers: {
|
|
9
|
+
file: import("@tagma/types").TriggerPlugin;
|
|
10
|
+
manual: import("@tagma/types").TriggerPlugin;
|
|
11
|
+
};
|
|
12
|
+
completions: {
|
|
13
|
+
exit_code: import("@tagma/types").CompletionPlugin;
|
|
14
|
+
file_exists: import("@tagma/types").CompletionPlugin;
|
|
15
|
+
output_check: import("@tagma/types").CompletionPlugin;
|
|
16
|
+
};
|
|
17
|
+
middlewares: {
|
|
18
|
+
static_context: import("@tagma/types").MiddlewarePlugin;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
2
22
|
/**
|
|
3
23
|
* Register every built-in plugin into `target`. Hosts instantiate one
|
|
4
24
|
* PluginRegistry per workspace or SDK instance and call this once per
|
package/dist/bootstrap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAsBlD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;CAmBR,CAAC;AAExB;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAE9D"}
|
package/dist/bootstrap.js
CHANGED
|
@@ -13,6 +13,26 @@ import { FileExistsCompletion } from './completions/file-exists';
|
|
|
13
13
|
import { OutputCheckCompletion } from './completions/output-check';
|
|
14
14
|
// Built-in Middleware
|
|
15
15
|
import { StaticContextMiddleware } from './middlewares/static-context';
|
|
16
|
+
export const BuiltinTagmaPlugin = {
|
|
17
|
+
name: '@tagma/sdk/builtins',
|
|
18
|
+
capabilities: {
|
|
19
|
+
drivers: {
|
|
20
|
+
opencode: OpenCodeDriver,
|
|
21
|
+
},
|
|
22
|
+
triggers: {
|
|
23
|
+
file: FileTrigger,
|
|
24
|
+
manual: ManualTrigger,
|
|
25
|
+
},
|
|
26
|
+
completions: {
|
|
27
|
+
exit_code: ExitCodeCompletion,
|
|
28
|
+
file_exists: FileExistsCompletion,
|
|
29
|
+
output_check: OutputCheckCompletion,
|
|
30
|
+
},
|
|
31
|
+
middlewares: {
|
|
32
|
+
static_context: StaticContextMiddleware,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
16
36
|
/**
|
|
17
37
|
* Register every built-in plugin into `target`. Hosts instantiate one
|
|
18
38
|
* PluginRegistry per workspace or SDK instance and call this once per
|
|
@@ -23,16 +43,6 @@ import { StaticContextMiddleware } from './middlewares/static-context';
|
|
|
23
43
|
* handler object into N registries is cheap and safe; no cloning is needed.
|
|
24
44
|
*/
|
|
25
45
|
export function bootstrapBuiltins(target) {
|
|
26
|
-
|
|
27
|
-
target.registerPlugin('drivers', 'opencode', OpenCodeDriver);
|
|
28
|
-
// Triggers
|
|
29
|
-
target.registerPlugin('triggers', 'file', FileTrigger);
|
|
30
|
-
target.registerPlugin('triggers', 'manual', ManualTrigger);
|
|
31
|
-
// Completions
|
|
32
|
-
target.registerPlugin('completions', 'exit_code', ExitCodeCompletion);
|
|
33
|
-
target.registerPlugin('completions', 'file_exists', FileExistsCompletion);
|
|
34
|
-
target.registerPlugin('completions', 'output_check', OutputCheckCompletion);
|
|
35
|
-
// Middlewares
|
|
36
|
-
target.registerPlugin('middlewares', 'static_context', StaticContextMiddleware);
|
|
46
|
+
target.registerTagmaPlugin(BuiltinTagmaPlugin);
|
|
37
47
|
}
|
|
38
48
|
//# sourceMappingURL=bootstrap.js.map
|
package/dist/bootstrap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAGA,mBAAmB;AACnB,wEAAwE;AACxE,0EAA0E;AAC1E,iCAAiC;AACjC,kEAAkE;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,oBAAoB;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,uBAAuB;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,sBAAsB;AACtB,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,qBAAqB;IAC3B,YAAY,EAAE;QACZ,OAAO,EAAE;YACP,QAAQ,EAAE,cAAc;SACzB;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,WAAW;YACjB,MAAM,EAAE,aAAa;SACtB;QACD,WAAW,EAAE;YACX,SAAS,EAAE,kBAAkB;YAC7B,WAAW,EAAE,oBAAoB;YACjC,YAAY,EAAE,qBAAqB;SACpC;QACD,WAAW,EAAE;YACX,cAAc,EAAE,uBAAuB;SACxC;KACF;CACoB,CAAC;AAExB;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAsB;IACtD,MAAM,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -2,6 +2,7 @@ import type { AbortReason, OnFailure, PipelineConfig, RunEventPayload, TaskState
|
|
|
2
2
|
import type { Dag } from '../dag';
|
|
3
3
|
import type { UpstreamBindingData } from '../ports';
|
|
4
4
|
import { type PipelineInfo, type TaskInfo, type TrackInfo } from '../hooks';
|
|
5
|
+
import type { TagmaRuntime } from '../runtime';
|
|
5
6
|
export interface RunContextOptions {
|
|
6
7
|
readonly runId: string;
|
|
7
8
|
readonly dag: Dag;
|
|
@@ -9,6 +10,7 @@ export interface RunContextOptions {
|
|
|
9
10
|
readonly workDir: string;
|
|
10
11
|
readonly pipelineInfo: PipelineInfo;
|
|
11
12
|
readonly onEvent?: (event: RunEventPayload) => void;
|
|
13
|
+
readonly runtime: TagmaRuntime;
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
14
16
|
* Per-run state container. Owns the maps and abort tracking that
|
|
@@ -24,6 +26,7 @@ export declare class RunContext {
|
|
|
24
26
|
readonly workDir: string;
|
|
25
27
|
readonly pipelineInfo: PipelineInfo;
|
|
26
28
|
readonly onEvent?: (event: RunEventPayload) => void;
|
|
29
|
+
readonly runtime: TagmaRuntime;
|
|
27
30
|
readonly states: Map<string, TaskState>;
|
|
28
31
|
readonly sessionMap: Map<string, string>;
|
|
29
32
|
readonly normalizedMap: Map<string, string>;
|
|
@@ -1 +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;
|
|
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,YAAY,CAAC;AAU/C,MAAM,WA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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;CAcjB"}
|
package/dist/core/run-context.js
CHANGED
|
@@ -18,6 +18,7 @@ export class RunContext {
|
|
|
18
18
|
workDir;
|
|
19
19
|
pipelineInfo;
|
|
20
20
|
onEvent;
|
|
21
|
+
runtime;
|
|
21
22
|
states = new Map();
|
|
22
23
|
sessionMap = new Map();
|
|
23
24
|
normalizedMap = new Map();
|
|
@@ -34,6 +35,7 @@ export class RunContext {
|
|
|
34
35
|
this.workDir = options.workDir;
|
|
35
36
|
this.pipelineInfo = options.pipelineInfo;
|
|
36
37
|
this.onEvent = options.onEvent;
|
|
38
|
+
this.runtime = options.runtime;
|
|
37
39
|
for (const [id, node] of this.dag.nodes) {
|
|
38
40
|
this.states.set(id, {
|
|
39
41
|
config: node.task,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-context.js","sourceRoot":"","sources":["../../src/core/run-context.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,WAAW,EACX,gBAAgB,GAIjB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"run-context.js","sourceRoot":"","sources":["../../src/core/run-context.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,WAAW,EACX,gBAAgB,GAIjB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MA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AE,QAAQ,IAAI,IAAI;YACzC,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,UAAU,IAAI,IAAI;YAC7C,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,UAAU,IAAI,IAAI;YAC7C,UAAU,EAAE,KAAK,CAAC,MAAM,EAAE,SAAS,IAAI,IAAI;YAC3C,UAAU,EAAE,KAAK,CAAC,SAAS;YAC3B,WAAW,EAAE,KAAK,CAAC,UAAU;SAC9B,CAAC;IACJ,CAAC;IAED,WAAW,CAAC,MAAc;QACxB,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC;QACzC,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,MAAc,EACd,KAAsC;QAEtC,MAAM,WAAW,CACf,IAAI,CAAC,MAAM,CAAC,KAAK,EACjB,KAAK,EACL,gBAAgB,CACd,KAAK,EACL,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EACxB,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAC9B,EACD,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,eAAe,CAAC,MAAM,CAC5B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-executor.d.ts","sourceRoot":"","sources":["../../src/core/task-executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"task-executor.d.ts","sourceRoot":"","sources":["../../src/core/task-executor.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAWlD,OAAO,EAAmB,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAoBhD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;CAC3C;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0rB5E"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { resolve } from 'path';
|
|
2
|
-
import { runCommand, runSpawn } from '../runner';
|
|
3
1
|
import { parseDuration, nowISO } from '../utils';
|
|
4
2
|
import { promptDocumentFromString, serializePromptDocument, prependContext, renderInputsBlock, renderOutputSchemaBlock, } from '../prompt-doc';
|
|
5
3
|
import { resolveTaskBindingInputs, resolveTaskInputs, substituteInputs } from '../ports';
|
|
@@ -89,6 +87,7 @@ export async function executeTask(options) {
|
|
|
89
87
|
workDir: task.cwd ?? workDir,
|
|
90
88
|
signal: ctx.abortController.signal,
|
|
91
89
|
approvalGateway,
|
|
90
|
+
runtime: ctx.runtime,
|
|
92
91
|
})
|
|
93
92
|
.then((v) => {
|
|
94
93
|
if (settled)
|
|
@@ -299,9 +298,18 @@ export async function executeTask(options) {
|
|
|
299
298
|
// and keep only a bounded tail in the returned TaskResult. Filenames
|
|
300
299
|
// mirror the existing `.stderr` naming — dots in task ids are replaced
|
|
301
300
|
// so hierarchical ids (e.g. `track1.task2`) map cleanly to a flat dir.
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
301
|
+
const stdoutPath = ctx.runtime.logStore.taskOutputPath({
|
|
302
|
+
workDir,
|
|
303
|
+
runId: ctx.runId,
|
|
304
|
+
taskId,
|
|
305
|
+
stream: 'stdout',
|
|
306
|
+
});
|
|
307
|
+
const stderrPath = ctx.runtime.logStore.taskOutputPath({
|
|
308
|
+
workDir,
|
|
309
|
+
runId: ctx.runId,
|
|
310
|
+
taskId,
|
|
311
|
+
stream: 'stderr',
|
|
312
|
+
});
|
|
305
313
|
const runOpts = {
|
|
306
314
|
timeoutMs,
|
|
307
315
|
signal: ctx.abortController.signal,
|
|
@@ -321,7 +329,7 @@ export async function executeTask(options) {
|
|
|
321
329
|
log.debug(`[task:${taskId}]`, `command placeholders rendered empty: ${unresolved.join(', ')}`);
|
|
322
330
|
}
|
|
323
331
|
log.debug(`[task:${taskId}]`, `command: ${expandedCommand}`);
|
|
324
|
-
result = await runCommand(expandedCommand, task.cwd ?? workDir, runOpts);
|
|
332
|
+
result = await ctx.runtime.runCommand(expandedCommand, task.cwd ?? workDir, runOpts);
|
|
325
333
|
}
|
|
326
334
|
else {
|
|
327
335
|
// AI task: apply middleware chain against a structured PromptDocument.
|
|
@@ -361,38 +369,17 @@ export async function executeTask(options) {
|
|
|
361
369
|
const mwPlugin = registry.getHandler('middlewares', mwConfig.type);
|
|
362
370
|
const beforeBlocks = doc.contexts.length;
|
|
363
371
|
const beforeLen = serializePromptDocument(doc).length;
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
// working — that fallback loses context structure (the
|
|
367
|
-
// middleware's output becomes the new task body) but never
|
|
368
|
-
// silently drops content.
|
|
369
|
-
if (typeof mwPlugin.enhanceDoc === 'function') {
|
|
370
|
-
const next = await mwPlugin.enhanceDoc(doc, mwConfig, mwCtx);
|
|
371
|
-
if (!next ||
|
|
372
|
-
typeof next !== 'object' ||
|
|
373
|
-
!Array.isArray(next.contexts) ||
|
|
374
|
-
typeof next.task !== 'string') {
|
|
375
|
-
throw new Error(`middleware "${mwConfig.type}".enhanceDoc() returned a malformed PromptDocument`);
|
|
376
|
-
}
|
|
377
|
-
doc = next;
|
|
378
|
-
}
|
|
379
|
-
else if (typeof mwPlugin.enhance === 'function') {
|
|
380
|
-
const asString = serializePromptDocument(doc);
|
|
381
|
-
const next = await mwPlugin.enhance(asString, mwConfig, mwCtx);
|
|
382
|
-
// R3: a middleware that returns undefined / null / a non-string
|
|
383
|
-
// would silently corrupt the prompt. Fail loud.
|
|
384
|
-
if (typeof next !== 'string') {
|
|
385
|
-
throw new Error(`middleware "${mwConfig.type}".enhance() returned ${next === null ? 'null' : typeof next}, expected string`);
|
|
386
|
-
}
|
|
387
|
-
// Legacy fallback: collapse the returned string into a
|
|
388
|
-
// fresh doc. Earlier structure is folded into the string
|
|
389
|
-
// (serializePromptDocument just ran), so bytes the driver
|
|
390
|
-
// sees match the old string pipeline.
|
|
391
|
-
doc = { contexts: [], task: next };
|
|
372
|
+
if (typeof mwPlugin.enhanceDoc !== 'function') {
|
|
373
|
+
throw new Error(`middleware "${mwConfig.type}" must provide enhanceDoc`);
|
|
392
374
|
}
|
|
393
|
-
|
|
394
|
-
|
|
375
|
+
const next = await mwPlugin.enhanceDoc(doc, mwConfig, mwCtx);
|
|
376
|
+
if (!next ||
|
|
377
|
+
typeof next !== 'object' ||
|
|
378
|
+
!Array.isArray(next.contexts) ||
|
|
379
|
+
typeof next.task !== 'string') {
|
|
380
|
+
throw new Error(`middleware "${mwConfig.type}".enhanceDoc() returned a malformed PromptDocument`);
|
|
395
381
|
}
|
|
382
|
+
doc = next;
|
|
396
383
|
const afterLen = serializePromptDocument(doc).length;
|
|
397
384
|
const addedBlocks = doc.contexts.length - beforeBlocks;
|
|
398
385
|
log.debug(`[task:${taskId}]`, ` ${mwConfig.type}: ${beforeLen} → ${afterLen} chars` +
|
|
@@ -445,7 +432,7 @@ export async function executeTask(options) {
|
|
|
445
432
|
log.debug(`[task:${taskId}]`, `spawn env overrides: ${Object.keys(spec.env).join(', ')}`);
|
|
446
433
|
if (spec.stdin)
|
|
447
434
|
log.debug(`[task:${taskId}]`, `spawn stdin: ${spec.stdin.length} chars`);
|
|
448
|
-
result = await runSpawn(spec, driver, runOpts);
|
|
435
|
+
result = await ctx.runtime.runSpawn(spec, driver, runOpts);
|
|
449
436
|
}
|
|
450
437
|
// 6. Determine terminal status (without emitting yet — result must be complete first)
|
|
451
438
|
// H2: branch on failureKind so spawn errors no longer masquerade as
|