@nodetool-ai/execution 0.8.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 +129 -0
- package/dist/.nodetool-build-stamp +1 -0
- package/dist/app-debug/app-spec.d.ts +94 -0
- package/dist/app-debug/app-spec.d.ts.map +1 -0
- package/dist/app-debug/app-spec.js +710 -0
- package/dist/app-debug/app-spec.js.map +1 -0
- package/dist/app-debug/application-target.d.ts +53 -0
- package/dist/app-debug/application-target.d.ts.map +1 -0
- package/dist/app-debug/application-target.js +126 -0
- package/dist/app-debug/application-target.js.map +1 -0
- package/dist/app-debug/bundle-target.d.ts +21 -0
- package/dist/app-debug/bundle-target.d.ts.map +1 -0
- package/dist/app-debug/bundle-target.js +51 -0
- package/dist/app-debug/bundle-target.js.map +1 -0
- package/dist/app-debug/graph-shape.d.ts +14 -0
- package/dist/app-debug/graph-shape.d.ts.map +1 -0
- package/dist/app-debug/graph-shape.js +23 -0
- package/dist/app-debug/graph-shape.js.map +1 -0
- package/dist/app-debug/index.d.ts +26 -0
- package/dist/app-debug/index.d.ts.map +1 -0
- package/dist/app-debug/index.js +19 -0
- package/dist/app-debug/index.js.map +1 -0
- package/dist/app-debug/markdown.d.ts +6 -0
- package/dist/app-debug/markdown.d.ts.map +1 -0
- package/dist/app-debug/markdown.js +133 -0
- package/dist/app-debug/markdown.js.map +1 -0
- package/dist/app-debug/runtime.d.ts +267 -0
- package/dist/app-debug/runtime.d.ts.map +1 -0
- package/dist/app-debug/runtime.js +633 -0
- package/dist/app-debug/runtime.js.map +1 -0
- package/dist/app-debug/script-operation.d.ts +58 -0
- package/dist/app-debug/script-operation.d.ts.map +1 -0
- package/dist/app-debug/script-operation.js +44 -0
- package/dist/app-debug/script-operation.js.map +1 -0
- package/dist/app-debug/simulate.d.ts +85 -0
- package/dist/app-debug/simulate.d.ts.map +1 -0
- package/dist/app-debug/simulate.js +991 -0
- package/dist/app-debug/simulate.js.map +1 -0
- package/dist/app-debug/summarize.d.ts +64 -0
- package/dist/app-debug/summarize.d.ts.map +1 -0
- package/dist/app-debug/summarize.js +65 -0
- package/dist/app-debug/summarize.js.map +1 -0
- package/dist/app-debug/types.d.ts +343 -0
- package/dist/app-debug/types.d.ts.map +1 -0
- package/dist/app-debug/types.js +2 -0
- package/dist/app-debug/types.js.map +1 -0
- package/dist/cost-ledger.d.ts +147 -0
- package/dist/cost-ledger.d.ts.map +1 -0
- package/dist/cost-ledger.js +288 -0
- package/dist/cost-ledger.js.map +1 -0
- package/dist/debug/collector.d.ts +28 -0
- package/dist/debug/collector.d.ts.map +1 -0
- package/dist/debug/collector.js +284 -0
- package/dist/debug/collector.js.map +1 -0
- package/dist/debug/index.d.ts +15 -0
- package/dist/debug/index.d.ts.map +1 -0
- package/dist/debug/index.js +16 -0
- package/dist/debug/index.js.map +1 -0
- package/dist/debug/types.d.ts +179 -0
- package/dist/debug/types.d.ts.map +1 -0
- package/dist/debug/types.js +11 -0
- package/dist/debug/types.js.map +1 -0
- package/dist/debug/verdict.d.ts +27 -0
- package/dist/debug/verdict.d.ts.map +1 -0
- package/dist/debug/verdict.js +51 -0
- package/dist/debug/verdict.js.map +1 -0
- package/dist/executor-resolver.d.ts +13 -0
- package/dist/executor-resolver.d.ts.map +1 -0
- package/dist/executor-resolver.js +13 -0
- package/dist/executor-resolver.js.map +1 -0
- package/dist/fal-output-decoder.d.ts +36 -0
- package/dist/fal-output-decoder.d.ts.map +1 -0
- package/dist/fal-output-decoder.js +129 -0
- package/dist/fal-output-decoder.js.map +1 -0
- package/dist/generation-lifecycle.d.ts +54 -0
- package/dist/generation-lifecycle.d.ts.map +1 -0
- package/dist/generation-lifecycle.js +431 -0
- package/dist/generation-lifecycle.js.map +1 -0
- package/dist/generation-recovery-worker.d.ts +100 -0
- package/dist/generation-recovery-worker.d.ts.map +1 -0
- package/dist/generation-recovery-worker.js +995 -0
- package/dist/generation-recovery-worker.js.map +1 -0
- package/dist/generation-tracker.d.ts +83 -0
- package/dist/generation-tracker.d.ts.map +1 -0
- package/dist/generation-tracker.js +436 -0
- package/dist/generation-tracker.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/js-script-debug/index.d.ts +13 -0
- package/dist/js-script-debug/index.d.ts.map +1 -0
- package/dist/js-script-debug/index.js +12 -0
- package/dist/js-script-debug/index.js.map +1 -0
- package/dist/js-script-debug/markdown.d.ts +6 -0
- package/dist/js-script-debug/markdown.d.ts.map +1 -0
- package/dist/js-script-debug/markdown.js +62 -0
- package/dist/js-script-debug/markdown.js.map +1 -0
- package/dist/js-script-debug/outputs.d.ts +20 -0
- package/dist/js-script-debug/outputs.d.ts.map +1 -0
- package/dist/js-script-debug/outputs.js +30 -0
- package/dist/js-script-debug/outputs.js.map +1 -0
- package/dist/js-script-debug/report.d.ts +15 -0
- package/dist/js-script-debug/report.d.ts.map +1 -0
- package/dist/js-script-debug/report.js +90 -0
- package/dist/js-script-debug/report.js.map +1 -0
- package/dist/js-script-debug/types.d.ts +63 -0
- package/dist/js-script-debug/types.d.ts.map +1 -0
- package/dist/js-script-debug/types.js +10 -0
- package/dist/js-script-debug/types.js.map +1 -0
- package/dist/js-script-debug/validate.d.ts +38 -0
- package/dist/js-script-debug/validate.d.ts.map +1 -0
- package/dist/js-script-debug/validate.js +137 -0
- package/dist/js-script-debug/validate.js.map +1 -0
- package/dist/message-stream.d.ts +33 -0
- package/dist/message-stream.d.ts.map +1 -0
- package/dist/message-stream.js +58 -0
- package/dist/message-stream.js.map +1 -0
- package/dist/normalize-graph.d.ts +13 -0
- package/dist/normalize-graph.d.ts.map +1 -0
- package/dist/normalize-graph.js +63 -0
- package/dist/normalize-graph.js.map +1 -0
- package/dist/output-names.d.ts +13 -0
- package/dist/output-names.d.ts.map +1 -0
- package/dist/output-names.js +13 -0
- package/dist/output-names.js.map +1 -0
- package/dist/predicates.d.ts +6 -0
- package/dist/predicates.d.ts.map +1 -0
- package/dist/predicates.js +6 -0
- package/dist/predicates.js.map +1 -0
- package/dist/preflight.d.ts +87 -0
- package/dist/preflight.d.ts.map +1 -0
- package/dist/preflight.js +139 -0
- package/dist/preflight.js.map +1 -0
- package/dist/provider-secret-key.d.ts +3 -0
- package/dist/provider-secret-key.d.ts.map +1 -0
- package/dist/provider-secret-key.js +7 -0
- package/dist/provider-secret-key.js.map +1 -0
- package/dist/service/app-debug-service.d.ts +78 -0
- package/dist/service/app-debug-service.d.ts.map +1 -0
- package/dist/service/app-debug-service.js +201 -0
- package/dist/service/app-debug-service.js.map +1 -0
- package/dist/service/app-run-server.d.ts +28 -0
- package/dist/service/app-run-server.d.ts.map +1 -0
- package/dist/service/app-run-server.js +104 -0
- package/dist/service/app-run-server.js.map +1 -0
- package/dist/service/debug-sessions.d.ts +158 -0
- package/dist/service/debug-sessions.d.ts.map +1 -0
- package/dist/service/debug-sessions.js +358 -0
- package/dist/service/debug-sessions.js.map +1 -0
- package/dist/service/index.d.ts +22 -0
- package/dist/service/index.d.ts.map +1 -0
- package/dist/service/index.js +17 -0
- package/dist/service/index.js.map +1 -0
- package/dist/service/job-progress.d.ts +40 -0
- package/dist/service/job-progress.d.ts.map +1 -0
- package/dist/service/job-progress.js +53 -0
- package/dist/service/job-progress.js.map +1 -0
- package/dist/service/workflow-run.d.ts +279 -0
- package/dist/service/workflow-run.d.ts.map +1 -0
- package/dist/service/workflow-run.js +598 -0
- package/dist/service/workflow-run.js.map +1 -0
- package/dist/service/workflow-workspace.d.ts +89 -0
- package/dist/service/workflow-workspace.d.ts.map +1 -0
- package/dist/service/workflow-workspace.js +160 -0
- package/dist/service/workflow-workspace.js.map +1 -0
- package/dist/session.d.ts +62 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +353 -0
- package/dist/session.js.map +1 -0
- package/dist/sketch-debug/index.d.ts +11 -0
- package/dist/sketch-debug/index.d.ts.map +1 -0
- package/dist/sketch-debug/index.js +10 -0
- package/dist/sketch-debug/index.js.map +1 -0
- package/dist/sketch-debug/markdown.d.ts +6 -0
- package/dist/sketch-debug/markdown.d.ts.map +1 -0
- package/dist/sketch-debug/markdown.js +93 -0
- package/dist/sketch-debug/markdown.js.map +1 -0
- package/dist/sketch-debug/report.d.ts +15 -0
- package/dist/sketch-debug/report.d.ts.map +1 -0
- package/dist/sketch-debug/report.js +98 -0
- package/dist/sketch-debug/report.js.map +1 -0
- package/dist/sketch-debug/types.d.ts +62 -0
- package/dist/sketch-debug/types.d.ts.map +1 -0
- package/dist/sketch-debug/types.js +10 -0
- package/dist/sketch-debug/types.js.map +1 -0
- package/dist/sketch-debug/validate.d.ts +14 -0
- package/dist/sketch-debug/validate.d.ts.map +1 -0
- package/dist/sketch-debug/validate.js +478 -0
- package/dist/sketch-debug/validate.js.map +1 -0
- package/dist/supervisor.d.ts +45 -0
- package/dist/supervisor.d.ts.map +1 -0
- package/dist/supervisor.js +97 -0
- package/dist/supervisor.js.map +1 -0
- package/dist/timeline-debug/index.d.ts +11 -0
- package/dist/timeline-debug/index.d.ts.map +1 -0
- package/dist/timeline-debug/index.js +10 -0
- package/dist/timeline-debug/index.js.map +1 -0
- package/dist/timeline-debug/legibility.d.ts +23 -0
- package/dist/timeline-debug/legibility.d.ts.map +1 -0
- package/dist/timeline-debug/legibility.js +240 -0
- package/dist/timeline-debug/legibility.js.map +1 -0
- package/dist/timeline-debug/markdown.d.ts +6 -0
- package/dist/timeline-debug/markdown.d.ts.map +1 -0
- package/dist/timeline-debug/markdown.js +103 -0
- package/dist/timeline-debug/markdown.js.map +1 -0
- package/dist/timeline-debug/motion.d.ts +20 -0
- package/dist/timeline-debug/motion.d.ts.map +1 -0
- package/dist/timeline-debug/motion.js +362 -0
- package/dist/timeline-debug/motion.js.map +1 -0
- package/dist/timeline-debug/report.d.ts +16 -0
- package/dist/timeline-debug/report.d.ts.map +1 -0
- package/dist/timeline-debug/report.js +100 -0
- package/dist/timeline-debug/report.js.map +1 -0
- package/dist/timeline-debug/showcase.d.ts +7 -0
- package/dist/timeline-debug/showcase.d.ts.map +1 -0
- package/dist/timeline-debug/showcase.js +347 -0
- package/dist/timeline-debug/showcase.js.map +1 -0
- package/dist/timeline-debug/types.d.ts +64 -0
- package/dist/timeline-debug/types.d.ts.map +1 -0
- package/dist/timeline-debug/types.js +10 -0
- package/dist/timeline-debug/types.js.map +1 -0
- package/dist/timeline-debug/validate.d.ts +24 -0
- package/dist/timeline-debug/validate.d.ts.map +1 -0
- package/dist/timeline-debug/validate.js +1432 -0
- package/dist/timeline-debug/validate.js.map +1 -0
- package/dist/types.d.ts +211 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +103 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/js-script-debug/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EAEzB,MAAM,iDAAiD,CAAC;AAezD,SAAS,KAAK,CAAC,MAAqC;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;IACpE,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC;IACxE,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACvD,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB,CAC1B,GAAqB,EACrB,sBAAiD;IAEjD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,IAAI,KAAK,EAAE,IAAI,GAAG,CAAC,OAAO,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C,CAAC,CAAC;IAEJ,MAAM,MAAM,GAAG,CAAC,GAAG,WAAW,EAAE,GAAG,UAAU,CAAC,CAAC;IAE/C,MAAM,SAAS,GAAG,uBAAuB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpD,4EAA4E;IAC5E,oEAAoE;IACpE,MAAM,MAAM,GAAG,SAAS;QACtB,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,mBAAmB,CAAC,GAAG,EAAE,sBAAsB,CAAC,CAAC;IACrD,IAAI,MAAM;QAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEhC,MAAM,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;IAEjD,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC5C,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YAC/B,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC3C,MAAM,CAAC,IAAI,CAAC;oBACV,QAAQ,EAAE,SAAS;oBACnB,IAAI,EAAE,0BAA0B;oBAChC,OAAO,EAAE,oBAAoB,IAAI,0CAA0C;iBAC5E,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turns `ProcessingContext`'s push-based `addMessageListener` into a pull-based
|
|
3
|
+
* `AsyncIterable<ProcessingMessage>`. Modeled on the queue/wake pattern in
|
|
4
|
+
* `packages/workflow-runner/src/run.ts`'s `runWorkflow` generator — the one
|
|
5
|
+
* other place in the repo already streams a kernel run as an async sequence.
|
|
6
|
+
*
|
|
7
|
+
* The queue is bounded. A caller that opts into capture (see
|
|
8
|
+
* `ExecutionSessionOptions.captureMessages`) but never iterates would
|
|
9
|
+
* otherwise retain every message of the run — including real-time audio
|
|
10
|
+
* chunks, which the kernel's own message retention deliberately avoids
|
|
11
|
+
* holding (roughly 25 MB/minute). Past the limit the stream stops queueing
|
|
12
|
+
* and the iterator throws, so a non-draining consumer fails loudly instead of
|
|
13
|
+
* growing until the run ends.
|
|
14
|
+
*/
|
|
15
|
+
import type { ProcessingContext } from "@nodetool-ai/runtime";
|
|
16
|
+
import type { ProcessingMessage } from "@nodetool-ai/protocol";
|
|
17
|
+
/** Queued messages allowed to pile up before the stream gives up. */
|
|
18
|
+
export declare const DEFAULT_MESSAGE_BUFFER_LIMIT = 10000;
|
|
19
|
+
export declare class MessageStream implements AsyncIterable<ProcessingMessage> {
|
|
20
|
+
private readonly queue;
|
|
21
|
+
private waiter;
|
|
22
|
+
private closed;
|
|
23
|
+
private overflowedAt;
|
|
24
|
+
private readonly limit;
|
|
25
|
+
private readonly unsubscribe;
|
|
26
|
+
/** `limit` of 0 (or a negative number) means unbounded. */
|
|
27
|
+
constructor(context: ProcessingContext, limit?: number);
|
|
28
|
+
private wake;
|
|
29
|
+
/** Stop feeding new messages into the queue. Already-queued messages still drain. */
|
|
30
|
+
close(): void;
|
|
31
|
+
[Symbol.asyncIterator](): AsyncIterator<ProcessingMessage>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=message-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-stream.d.ts","sourceRoot":"","sources":["../src/message-stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,qEAAqE;AACrE,eAAO,MAAM,4BAA4B,QAAS,CAAC;AAEnD,qBAAa,aAAc,YAAW,aAAa,CAAC,iBAAiB,CAAC;IACpE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA2B;IACjD,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAa;IAEzC,2DAA2D;IAC3D,YAAY,OAAO,EAAE,iBAAiB,EAAE,KAAK,SAA+B,EAa3E;IAED,OAAO,CAAC,IAAI;IAMZ,qFAAqF;IACrF,KAAK,IAAI,IAAI,CAKZ;IAEM,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAmBhE;CACF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** Queued messages allowed to pile up before the stream gives up. */
|
|
2
|
+
export const DEFAULT_MESSAGE_BUFFER_LIMIT = 10_000;
|
|
3
|
+
export class MessageStream {
|
|
4
|
+
queue = [];
|
|
5
|
+
waiter = null;
|
|
6
|
+
closed = false;
|
|
7
|
+
overflowedAt = null;
|
|
8
|
+
limit;
|
|
9
|
+
unsubscribe;
|
|
10
|
+
/** `limit` of 0 (or a negative number) means unbounded. */
|
|
11
|
+
constructor(context, limit = DEFAULT_MESSAGE_BUFFER_LIMIT) {
|
|
12
|
+
this.limit = limit > 0 ? limit : Number.POSITIVE_INFINITY;
|
|
13
|
+
this.unsubscribe = context.addMessageListener((message) => {
|
|
14
|
+
if (this.queue.length >= this.limit) {
|
|
15
|
+
if (this.overflowedAt === null) {
|
|
16
|
+
this.overflowedAt = this.queue.length;
|
|
17
|
+
this.unsubscribe();
|
|
18
|
+
}
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
this.queue.push(message);
|
|
22
|
+
this.wake();
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
wake() {
|
|
26
|
+
const w = this.waiter;
|
|
27
|
+
this.waiter = null;
|
|
28
|
+
w?.();
|
|
29
|
+
}
|
|
30
|
+
/** Stop feeding new messages into the queue. Already-queued messages still drain. */
|
|
31
|
+
close() {
|
|
32
|
+
if (this.closed)
|
|
33
|
+
return;
|
|
34
|
+
this.closed = true;
|
|
35
|
+
this.unsubscribe();
|
|
36
|
+
this.wake();
|
|
37
|
+
}
|
|
38
|
+
async *[Symbol.asyncIterator]() {
|
|
39
|
+
for (;;) {
|
|
40
|
+
while (this.queue.length > 0) {
|
|
41
|
+
yield this.queue.shift();
|
|
42
|
+
}
|
|
43
|
+
if (this.overflowedAt !== null) {
|
|
44
|
+
throw new Error(`ExecutionSession message stream overflowed after ${this.overflowedAt} ` +
|
|
45
|
+
`queued messages (limit ${this.limit}) — the consumer fell behind, ` +
|
|
46
|
+
"so messages past that point were dropped rather than retained. " +
|
|
47
|
+
"Iterate `session.messages` as the run progresses, or raise " +
|
|
48
|
+
"`limits.messageBufferLimit`.");
|
|
49
|
+
}
|
|
50
|
+
if (this.closed)
|
|
51
|
+
return;
|
|
52
|
+
await new Promise((resolve) => {
|
|
53
|
+
this.waiter = resolve;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=message-stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-stream.js","sourceRoot":"","sources":["../src/message-stream.ts"],"names":[],"mappings":"AAiBA,qEAAqE;AACrE,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC;AAEnD,MAAM,OAAO,aAAa;IACP,KAAK,GAAwB,EAAE,CAAC;IACzC,MAAM,GAAwB,IAAI,CAAC;IACnC,MAAM,GAAG,KAAK,CAAC;IACf,YAAY,GAAkB,IAAI,CAAC;IAC1B,KAAK,CAAS;IACd,WAAW,CAAa;IAEzC,2DAA2D;IAC3D,YAAY,OAA0B,EAAE,KAAK,GAAG,4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ACb,oDAAoD,IAAI,CAAC,YAAY,GAAG;oBACtE,0BAA0B,IAAI,CAAC,KAAK,gCAAgC;oBACpE,iEAAiE;oBACjE,6DAA6D;oBAC7D,8BAA8B,CACjC,CAAC;YACJ,CAAC;YACD,IAAI,IAAI,CAAC,MAAM;gBAAE,OAAO;YACxB,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;gBAClC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;YACxB,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GraphData } from "@nodetool-ai/protocol";
|
|
2
|
+
import type { RawGraphInput } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Present an already-typed graph as the facade's raw input.
|
|
5
|
+
*
|
|
6
|
+
* `RawGraphInput` describes saved-graph JSON, so its elements are indexable
|
|
7
|
+
* records; `NodeDescriptor` and `Edge` are not. A shallow copy per element
|
|
8
|
+
* bridges the two without asserting one is the other — the normalizer copies
|
|
9
|
+
* every element anyway, so nothing is paid twice.
|
|
10
|
+
*/
|
|
11
|
+
export declare function toRawGraphInput(graph: GraphData): RawGraphInput;
|
|
12
|
+
export declare function normalizeGraph(graph: RawGraphInput): GraphData;
|
|
13
|
+
//# sourceMappingURL=normalize-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-graph.d.ts","sourceRoot":"","sources":["../src/normalize-graph.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAQ,SAAS,EAAkB,MAAM,uBAAuB,CAAC;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,GAAG,aAAa,CAK/D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,CA4C9D"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize a raw saved graph into the kernel's descriptor contract: node
|
|
3
|
+
* properties under `properties` (the editor stores them under `data`), edges
|
|
4
|
+
* carrying `edge_type`, and editor-only nodes (Comment/Group/Reroute) pruned
|
|
5
|
+
* the way the web editor prunes them at serialize time.
|
|
6
|
+
*
|
|
7
|
+
* Ported from `packages/websocket/src/headless-job-runner.ts`'s
|
|
8
|
+
* `normalizeRunnableGraph` / `packages/cli/src/debug/server-runner.ts`'s
|
|
9
|
+
* inline filter — the two call sites this logic drifted between before this
|
|
10
|
+
* package existed.
|
|
11
|
+
*/
|
|
12
|
+
import { isEditorOnlyType } from "@nodetool-ai/node-sdk";
|
|
13
|
+
/**
|
|
14
|
+
* Present an already-typed graph as the facade's raw input.
|
|
15
|
+
*
|
|
16
|
+
* `RawGraphInput` describes saved-graph JSON, so its elements are indexable
|
|
17
|
+
* records; `NodeDescriptor` and `Edge` are not. A shallow copy per element
|
|
18
|
+
* bridges the two without asserting one is the other — the normalizer copies
|
|
19
|
+
* every element anyway, so nothing is paid twice.
|
|
20
|
+
*/
|
|
21
|
+
export function toRawGraphInput(graph) {
|
|
22
|
+
return {
|
|
23
|
+
nodes: graph.nodes.map((n) => Object.fromEntries(Object.entries(n))),
|
|
24
|
+
edges: graph.edges.map((e) => Object.fromEntries(Object.entries(e)))
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function normalizeGraph(graph) {
|
|
28
|
+
// `RawGraphInput` declares two arrays; the stored row or file behind it has
|
|
29
|
+
// never been checked against that, and a non-array used to reach `.filter()`.
|
|
30
|
+
if (!Array.isArray(graph?.nodes) || !Array.isArray(graph?.edges)) {
|
|
31
|
+
throw new Error("Invalid workflow: nodes and edges must be arrays");
|
|
32
|
+
}
|
|
33
|
+
const executable = graph.nodes.filter((n) => !isEditorOnlyType(String(n["type"] ?? "")));
|
|
34
|
+
const keep = new Set(executable.map((n) => String(n["id"] ?? "")));
|
|
35
|
+
const nodes = executable.map((n) => {
|
|
36
|
+
const record = { ...n };
|
|
37
|
+
if (record["properties"] === undefined && record["data"] !== undefined) {
|
|
38
|
+
const { data, ...rest } = record;
|
|
39
|
+
// SAFETY: the editor stores a node's inputs under `data` and the kernel
|
|
40
|
+
// reads them under `properties`; renaming that one key is the only
|
|
41
|
+
// difference between a saved node and a NodeDescriptor.
|
|
42
|
+
return { ...rest, properties: data };
|
|
43
|
+
}
|
|
44
|
+
// SAFETY: a saved node that already carries `properties` is a
|
|
45
|
+
// NodeDescriptor as stored — `id` and `type` are written on every save.
|
|
46
|
+
return record;
|
|
47
|
+
});
|
|
48
|
+
const edges = graph.edges
|
|
49
|
+
.filter((e) => keep.has(String(e["source"] ?? "")) &&
|
|
50
|
+
keep.has(String(e["target"] ?? "")))
|
|
51
|
+
.map((e) => {
|
|
52
|
+
const record = { ...e };
|
|
53
|
+
const rawEdgeType = record["edge_type"] ?? record["type"];
|
|
54
|
+
const edge_type = rawEdgeType === "control" ? "control" : "data";
|
|
55
|
+
const { type: _type, ...rest } = record;
|
|
56
|
+
// SAFETY: `keep` above already proved this edge's source and target are
|
|
57
|
+
// strings naming retained nodes; `edge_type` is normalized just above,
|
|
58
|
+
// and Edge carries an index signature for whatever else was saved.
|
|
59
|
+
return { ...rest, edge_type };
|
|
60
|
+
});
|
|
61
|
+
return { nodes, edges };
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=normalize-graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-graph.js","sourceRoot":"","sources":["../src/normalize-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,KAAgB;IAC9C,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,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U,EAAE,IAAI,EAAoB,CAAC;QACzD,CAAC;QACD,8DAA8D;QAC9D,wEAAwE;QACxE,OAAO,MAAwB,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,MAAM,KAAK,GAAW,KAAK,CAAC,KAAK;SAC9B,MAAM,CACL,CAAC,CAAC,EAAE,EAAE,CACJ,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CACtC;SACA,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,MAAM,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1D,MAAM,SAAS,GAAG,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;QACjE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QACxC,wEAAwE;QACxE,uEAAuE;QACvE,mEAAmE;QACnE,OAAO,EAAE,GAAG,IAAI,EAAE,SAAS,EAAU,CAAC;IACxC,CAAC,CAAC,CAAC;IAEL,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renames terminal Output-node keys to their public `properties.name` before
|
|
3
|
+
* the run starts. The kernel keys terminal outputs by `node.name`; SDK/API
|
|
4
|
+
* callers that need `output_update`/terminal-result addressing to agree with
|
|
5
|
+
* their declared interface names set `requireTerminalResult`.
|
|
6
|
+
*
|
|
7
|
+
* Ported from `websocket-client-session.ts`'s `startJobInner`
|
|
8
|
+
* (`req.require_terminal_result` branch) — the only site that did this
|
|
9
|
+
* before this package existed.
|
|
10
|
+
*/
|
|
11
|
+
import type { HydratedGraphData } from "@nodetool-ai/protocol";
|
|
12
|
+
export declare function rewriteOutputNames(graph: HydratedGraphData): void;
|
|
13
|
+
//# sourceMappingURL=output-names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-names.d.ts","sourceRoot":"","sources":["../src/output-names.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG/D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CASjE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isNonBlankString } from "./predicates.js";
|
|
2
|
+
export function rewriteOutputNames(graph) {
|
|
3
|
+
for (const node of graph.nodes) {
|
|
4
|
+
if (!node.type.startsWith("nodetool.output."))
|
|
5
|
+
continue;
|
|
6
|
+
const properties = node.properties;
|
|
7
|
+
const publicName = properties?.["name"];
|
|
8
|
+
if (isNonBlankString(publicName)) {
|
|
9
|
+
node.name = publicName;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=output-names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-names.js","sourceRoot":"","sources":["../src/output-names.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,UAAU,kBAAkB,CAAC,KAAwB;IACzD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC;YAAE,SAAS;QACxD,MAAM,UAAU,GAAG,IAAI,CAAC,UAA4C,CAAC;QACrE,MAAM,UAAU,GAAG,UAAU,EAAE,CAAC,MAAM,CAAC,CAAC;QACxC,IAAI,gBAAgB,CAAC,UAAU,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACzB,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace's named type predicates, re-exported for the debug harnesses'
|
|
3
|
+
* call sites. The definitions live in `@nodetool-ai/protocol`.
|
|
4
|
+
*/
|
|
5
|
+
export { isBoolean, isFiniteNumber, isNonBlankString, isNonEmptyString, isNumber, isObjectLike, isPositiveFiniteNumber, isRecord, isString, isCallable as isFunctionValue } from "@nodetool-ai/protocol";
|
|
6
|
+
//# sourceMappingURL=predicates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predicates.d.ts","sourceRoot":"","sources":["../src/predicates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,sBAAsB,EACtB,QAAQ,EACR,QAAQ,EACR,UAAU,IAAI,eAAe,EAC9B,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace's named type predicates, re-exported for the debug harnesses'
|
|
3
|
+
* call sites. The definitions live in `@nodetool-ai/protocol`.
|
|
4
|
+
*/
|
|
5
|
+
export { isBoolean, isFiniteNumber, isNonBlankString, isNonEmptyString, isNumber, isObjectLike, isPositiveFiniteNumber, isRecord, isString, isCallable as isFunctionValue } from "@nodetool-ai/protocol";
|
|
6
|
+
//# sourceMappingURL=predicates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predicates.js","sourceRoot":"","sources":["../src/predicates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,sBAAsB,EACtB,QAAQ,EACR,QAAQ,EACR,UAAU,IAAI,eAAe,EAC9B,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/** Provider/model catalogs the preflight checks a graph's selections against. */
|
|
2
|
+
export interface RunModelCatalogs {
|
|
3
|
+
listProviderIds: () => readonly string[];
|
|
4
|
+
listModelIds: (provider: string, modelType: string) => readonly string[] | undefined;
|
|
5
|
+
}
|
|
6
|
+
/** The catalogs of the process-wide provider registry. */
|
|
7
|
+
export declare const RUNTIME_CATALOGS: RunModelCatalogs;
|
|
8
|
+
/** Model selections in a graph that no configured provider can honour. */
|
|
9
|
+
export declare function modelSelectionErrors(graph: {
|
|
10
|
+
nodes?: unknown;
|
|
11
|
+
}, catalogs?: RunModelCatalogs): string[];
|
|
12
|
+
/** How the preflight resolves a credential — the way the coming run will. */
|
|
13
|
+
export interface CredentialResolver {
|
|
14
|
+
resolveSecret: (key: string) => Promise<string | null | undefined> | string | null | undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Providers a graph selects whose required credentials this runtime cannot
|
|
18
|
+
* resolve, one message each.
|
|
19
|
+
*
|
|
20
|
+
* The provider registry knows exactly which kwargs are load-bearing (an empty
|
|
21
|
+
* declaration means "resolve from store, then env"), and a provider built
|
|
22
|
+
* without one throws the `*_API_KEY is required` error mid-run that this check
|
|
23
|
+
* exists to front-run. Unregistered ids are skipped: the model-selection check
|
|
24
|
+
* already reports those as errors, and guessing at an unknown provider's
|
|
25
|
+
* credentials would be noise.
|
|
26
|
+
*/
|
|
27
|
+
export declare function unconfiguredProviderErrors(graph: {
|
|
28
|
+
nodes?: unknown;
|
|
29
|
+
edges?: unknown;
|
|
30
|
+
}, resolver: CredentialResolver, providerIds?: readonly string[]): Promise<string[]>;
|
|
31
|
+
/**
|
|
32
|
+
* How the preflight decides whether a provider a graph selects is configured.
|
|
33
|
+
*
|
|
34
|
+
* Defaults to {@link unconfiguredProviderErrors} over the process-wide
|
|
35
|
+
* provider registry. A host whose providers are not in that registry (a
|
|
36
|
+
* cassette, a fake, an in-process custom provider) supplies its own — together
|
|
37
|
+
* with its own {@link RunModelCatalogs}, since the two checks read the same
|
|
38
|
+
* registry.
|
|
39
|
+
*/
|
|
40
|
+
export type ProviderConfigurationChecker = (graph: {
|
|
41
|
+
nodes?: unknown;
|
|
42
|
+
edges?: unknown;
|
|
43
|
+
}, resolver: CredentialResolver) => Promise<readonly string[]> | readonly string[];
|
|
44
|
+
/** A checker over an explicit provider list, for a host with its own registry. */
|
|
45
|
+
export declare function providerConfigurationChecker(providerIds: readonly string[]): ProviderConfigurationChecker;
|
|
46
|
+
export type PreflightIssueKind = "model" | "credential";
|
|
47
|
+
/** One reason a run was refused before it started. */
|
|
48
|
+
export interface ExecutionPreflightIssue {
|
|
49
|
+
kind: PreflightIssueKind;
|
|
50
|
+
message: string;
|
|
51
|
+
}
|
|
52
|
+
/** The refusal text every host prints — one section per issue kind. */
|
|
53
|
+
export declare function formatPreflightDetail(issues: readonly ExecutionPreflightIssue[]): string;
|
|
54
|
+
/**
|
|
55
|
+
* The refusal contract shared by `ExecutionSession`, the run service, and the
|
|
56
|
+
* CLI adapters: a typed error whose `issues` are machine-readable and whose
|
|
57
|
+
* `message` is the text a host prints verbatim.
|
|
58
|
+
*/
|
|
59
|
+
export declare class ExecutionPreflightError extends Error {
|
|
60
|
+
readonly name = "ExecutionPreflightError";
|
|
61
|
+
readonly issues: readonly ExecutionPreflightIssue[];
|
|
62
|
+
constructor(issues: readonly ExecutionPreflightIssue[]);
|
|
63
|
+
}
|
|
64
|
+
export declare function isExecutionPreflightError(value: unknown): value is ExecutionPreflightError;
|
|
65
|
+
export interface PreflightOptions {
|
|
66
|
+
catalogs?: RunModelCatalogs;
|
|
67
|
+
providerConfiguration?: ProviderConfigurationChecker;
|
|
68
|
+
/** Resolves a credential the way the coming run will. */
|
|
69
|
+
resolveSecret: CredentialResolver["resolveSecret"];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Every reason to refuse `graph`, model selections first.
|
|
73
|
+
*
|
|
74
|
+
* A graph whose model selections are already unhonourable stops there: a
|
|
75
|
+
* provider that is not registered has no credentials to check, so running the
|
|
76
|
+
* second check would only add noise to a refusal that is already decided.
|
|
77
|
+
*/
|
|
78
|
+
export declare function collectPreflightIssues(graph: {
|
|
79
|
+
nodes?: unknown;
|
|
80
|
+
edges?: unknown;
|
|
81
|
+
}, options: PreflightOptions): Promise<ExecutionPreflightIssue[]>;
|
|
82
|
+
/** {@link collectPreflightIssues}, as a refusal. */
|
|
83
|
+
export declare function assertPreflight(graph: {
|
|
84
|
+
nodes?: unknown;
|
|
85
|
+
edges?: unknown;
|
|
86
|
+
}, options: PreflightOptions): Promise<void>;
|
|
87
|
+
//# sourceMappingURL=preflight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../src/preflight.ts"],"names":[],"mappings":"AA6BA,iFAAiF;AACjF,MAAM,WAAW,gBAAgB;IAC/B,eAAe,EAAE,MAAM,SAAS,MAAM,EAAE,CAAC;IACzC,YAAY,EAAE,CACZ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,KACd,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CACpC;AAED,0DAA0D;AAC1D,eAAO,MAAM,gBAAgB,EAAE,gBAI9B,CAAC;AAEF,0EAA0E;AAC1E,wBAAgB,oBAAoB,CAClC,KAAK,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,EAC1B,QAAQ,GAAE,gBAAmC,GAC5C,MAAM,EAAE,CAQV;AAED,6EAA6E;AAC7E,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,CACb,GAAG,EAAE,MAAM,KACR,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAC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,CAAC;IACrD,yDAAyD;IACzD,aAAa,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;CACpD;AAED;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,EAC3C,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAUpC;AAED,oDAAoD;AACpD,wBAAsB,eAAe,CACnC,KAAK,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,EAC3C,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,IAAI,CAAC,CAGf"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run preflight — the checks that must refuse a graph *before* anything is
|
|
3
|
+
* paid for.
|
|
4
|
+
*
|
|
5
|
+
* A graph that names a provider this runtime does not have, or a model that
|
|
6
|
+
* provider does not offer, or a credential nobody stored, fails at the node
|
|
7
|
+
* that needs it — after the upstream half of the graph has already run and
|
|
8
|
+
* billed. Both checks front-run that failure, and both live here (rather than
|
|
9
|
+
* in the run service) so `ExecutionSession` can call them without importing
|
|
10
|
+
* the models database.
|
|
11
|
+
*
|
|
12
|
+
* Both fail toward silence: an empty provider registry means the registry
|
|
13
|
+
* could not be reached, and an unregistered provider id is left to the
|
|
14
|
+
* model-selection check rather than guessed at.
|
|
15
|
+
*/
|
|
16
|
+
import { rewriteBypassedNodes } from "@nodetool-ai/kernel";
|
|
17
|
+
import { collectModelProviders, collectModelSelectionIssues } from "@nodetool-ai/node-sdk";
|
|
18
|
+
import { getProviderSecretKey, isProviderConfigured, listOfflineModelIds, listRegisteredProviderIds } from "@nodetool-ai/runtime";
|
|
19
|
+
import { normalizeGraph } from "./normalize-graph.js";
|
|
20
|
+
import { isRecord } from "./predicates.js";
|
|
21
|
+
/** The catalogs of the process-wide provider registry. */
|
|
22
|
+
export const RUNTIME_CATALOGS = {
|
|
23
|
+
listProviderIds: () => listRegisteredProviderIds(),
|
|
24
|
+
listModelIds: (provider, modelType) => listOfflineModelIds(provider, modelType)
|
|
25
|
+
};
|
|
26
|
+
/** Model selections in a graph that no configured provider can honour. */
|
|
27
|
+
export function modelSelectionErrors(graph, catalogs = RUNTIME_CATALOGS) {
|
|
28
|
+
const nodes = graph.nodes;
|
|
29
|
+
if (!Array.isArray(nodes))
|
|
30
|
+
return [];
|
|
31
|
+
return collectModelSelectionIssues({ nodes: nodes }, catalogs)
|
|
32
|
+
.filter((issue) => issue.severity === "error")
|
|
33
|
+
.map((issue) => `Node "${issue.nodeId}" (${issue.nodeType}): ${issue.message}`);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Providers a graph selects whose required credentials this runtime cannot
|
|
37
|
+
* resolve, one message each.
|
|
38
|
+
*
|
|
39
|
+
* The provider registry knows exactly which kwargs are load-bearing (an empty
|
|
40
|
+
* declaration means "resolve from store, then env"), and a provider built
|
|
41
|
+
* without one throws the `*_API_KEY is required` error mid-run that this check
|
|
42
|
+
* exists to front-run. Unregistered ids are skipped: the model-selection check
|
|
43
|
+
* already reports those as errors, and guessing at an unknown provider's
|
|
44
|
+
* credentials would be noise.
|
|
45
|
+
*/
|
|
46
|
+
export async function unconfiguredProviderErrors(graph, resolver, providerIds = listRegisteredProviderIds()) {
|
|
47
|
+
const nodes = graph.nodes;
|
|
48
|
+
if (!Array.isArray(nodes))
|
|
49
|
+
return [];
|
|
50
|
+
const graphNodes = nodes.filter(isRecord);
|
|
51
|
+
const graphEdges = Array.isArray(graph.edges)
|
|
52
|
+
? graph.edges.filter(isRecord)
|
|
53
|
+
: [];
|
|
54
|
+
const effectiveGraph = rewriteBypassedNodes(normalizeGraph({ nodes: graphNodes, edges: graphEdges }));
|
|
55
|
+
const known = new Set(providerIds);
|
|
56
|
+
const errors = [];
|
|
57
|
+
for (const provider of collectModelProviders({
|
|
58
|
+
nodes: effectiveGraph.nodes,
|
|
59
|
+
edges: effectiveGraph.edges
|
|
60
|
+
})) {
|
|
61
|
+
if (!known.has(provider))
|
|
62
|
+
continue;
|
|
63
|
+
if (await isProviderConfigured(provider, (key) => resolver.resolveSecret(key))) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const keyName = getProviderSecretKey(provider);
|
|
67
|
+
errors.push(keyName
|
|
68
|
+
? `Provider "${provider}" needs "${keyName}", which is not set on ` +
|
|
69
|
+
"this server. Store the secret " +
|
|
70
|
+
`"${keyName}" for this user (Settings → Credentials), or switch ` +
|
|
71
|
+
"the model to a provider you have configured."
|
|
72
|
+
: `Provider "${provider}" is missing its required configuration ` +
|
|
73
|
+
"(base URL or credential) on this server. Complete it in " +
|
|
74
|
+
"Settings → Providers before running.");
|
|
75
|
+
}
|
|
76
|
+
return errors;
|
|
77
|
+
}
|
|
78
|
+
/** A checker over an explicit provider list, for a host with its own registry. */
|
|
79
|
+
export function providerConfigurationChecker(providerIds) {
|
|
80
|
+
return (graph, resolver) => unconfiguredProviderErrors(graph, resolver, providerIds);
|
|
81
|
+
}
|
|
82
|
+
const HEADINGS = {
|
|
83
|
+
model: "Workflow selects providers or models this runtime cannot honour:",
|
|
84
|
+
credential: "Workflow selects providers whose credentials are not configured:"
|
|
85
|
+
};
|
|
86
|
+
/** The refusal text every host prints — one section per issue kind. */
|
|
87
|
+
export function formatPreflightDetail(issues) {
|
|
88
|
+
const sections = [];
|
|
89
|
+
for (const kind of ["model", "credential"]) {
|
|
90
|
+
const messages = issues
|
|
91
|
+
.filter((issue) => issue.kind === kind)
|
|
92
|
+
.map((issue) => issue.message);
|
|
93
|
+
if (messages.length > 0) {
|
|
94
|
+
sections.push(`${HEADINGS[kind]}\n${messages.join("\n")}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return sections.join("\n\n");
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The refusal contract shared by `ExecutionSession`, the run service, and the
|
|
101
|
+
* CLI adapters: a typed error whose `issues` are machine-readable and whose
|
|
102
|
+
* `message` is the text a host prints verbatim.
|
|
103
|
+
*/
|
|
104
|
+
export class ExecutionPreflightError extends Error {
|
|
105
|
+
name = "ExecutionPreflightError";
|
|
106
|
+
issues;
|
|
107
|
+
constructor(issues) {
|
|
108
|
+
super(formatPreflightDetail(issues));
|
|
109
|
+
this.issues = issues;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export function isExecutionPreflightError(value) {
|
|
113
|
+
return value instanceof ExecutionPreflightError;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Every reason to refuse `graph`, model selections first.
|
|
117
|
+
*
|
|
118
|
+
* A graph whose model selections are already unhonourable stops there: a
|
|
119
|
+
* provider that is not registered has no credentials to check, so running the
|
|
120
|
+
* second check would only add noise to a refusal that is already decided.
|
|
121
|
+
*/
|
|
122
|
+
export async function collectPreflightIssues(graph, options) {
|
|
123
|
+
const models = modelSelectionErrors(graph, options.catalogs);
|
|
124
|
+
if (models.length > 0) {
|
|
125
|
+
return models.map((message) => ({ kind: "model", message }));
|
|
126
|
+
}
|
|
127
|
+
const checker = options.providerConfiguration ?? unconfiguredProviderErrors;
|
|
128
|
+
const credentials = await checker(graph, {
|
|
129
|
+
resolveSecret: options.resolveSecret
|
|
130
|
+
});
|
|
131
|
+
return credentials.map((message) => ({ kind: "credential", message }));
|
|
132
|
+
}
|
|
133
|
+
/** {@link collectPreflightIssues}, as a refusal. */
|
|
134
|
+
export async function assertPreflight(graph, options) {
|
|
135
|
+
const issues = await collectPreflightIssues(graph, options);
|
|
136
|
+
if (issues.length > 0)
|
|
137
|
+
throw new ExecutionPreflightError(issues);
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=preflight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../src/preflight.ts"],"names":[],"mappings":"AAAA;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L's configured key for both its node and generic provider IDs. */
|
|
2
|
+
export function providerBillingSecretKey(provider) {
|
|
3
|
+
return provider === "fal_ai"
|
|
4
|
+
? "FAL_API_KEY"
|
|
5
|
+
: `${provider.toUpperCase()}_API_KEY`;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=provider-secret-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-secret-key.js","sourceRoot":"","sources":["../src/provider-secret-key.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,MAAM,UAAU,wBAAwB,CAAC,QAAgB;IACvD,OAAO,QAAQ,KAAK,QAAQ;QAC1B,CAAC,CAAC,aAAa;QACf,CAAC,CAAC,GAAG,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nodetool app debug` as a service — the engine behind
|
|
3
|
+
* `POST /api/applications/debug` and the `debug_app` agent tool.
|
|
4
|
+
*
|
|
5
|
+
* The simulation itself is `simulateApp`, unchanged: this module supplies the
|
|
6
|
+
* three things it cannot get for itself — the target (an application row, or
|
|
7
|
+
* the document the caller posted inline), the workflow loader its operations
|
|
8
|
+
* resolve against, and a kernel runner for the runs.
|
|
9
|
+
*
|
|
10
|
+
* The inline `document` path is the one that matters for an editor assistant.
|
|
11
|
+
* A draft lives in the browser until the user saves, so anything keyed on
|
|
12
|
+
* `application_id` grades a stale row — a verdict that lies exactly when the
|
|
13
|
+
* assistant is mid-edit.
|
|
14
|
+
*
|
|
15
|
+
* A run with `run: true` executes real workflows, so it can take minutes:
|
|
16
|
+
* `poll: true` fronts it with the same session registry a build uses. A
|
|
17
|
+
* simulation parks no escalations, so its session only ever reports `running`
|
|
18
|
+
* or `done`.
|
|
19
|
+
*/
|
|
20
|
+
import type { JsScriptOperationRunner } from "../app-debug/script-operation.js";
|
|
21
|
+
import type { NodeRegistry } from "@nodetool-ai/node-sdk";
|
|
22
|
+
import type { StorageAdapter } from "@nodetool-ai/runtime";
|
|
23
|
+
import type { AppWorkflowRecord, InteractionStep } from "../app-debug/index.js";
|
|
24
|
+
/**
|
|
25
|
+
* A refusal the caller turns into its own transport error. `code` is the
|
|
26
|
+
* vocabulary the HTTP layer maps onto `ApiErrorCode`; nothing here knows about
|
|
27
|
+
* Fastify or tRPC.
|
|
28
|
+
*/
|
|
29
|
+
export declare class AppServiceError extends Error {
|
|
30
|
+
readonly code: "invalid_input" | "not_found";
|
|
31
|
+
constructor(code: "invalid_input" | "not_found", message: string);
|
|
32
|
+
}
|
|
33
|
+
/** The request body of `POST /api/applications/debug`. */
|
|
34
|
+
export interface AppDebugRequest {
|
|
35
|
+
/** A saved application, read from the row. Either this or `document`. */
|
|
36
|
+
application_id?: string;
|
|
37
|
+
/** The live draft, verbatim. Either this or `application_id`. */
|
|
38
|
+
document?: unknown;
|
|
39
|
+
/** Reactive values applied before the interactions, keyed by input name. */
|
|
40
|
+
params?: Record<string, unknown>;
|
|
41
|
+
/** The interaction script. Omitted, the app's natural run trigger fires. */
|
|
42
|
+
interact?: InteractionStep[];
|
|
43
|
+
/** Execute workflow runs (default true). false = static wiring check only. */
|
|
44
|
+
run?: boolean;
|
|
45
|
+
/** Per-run timeout, ms. */
|
|
46
|
+
timeout_ms?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Return a session id as soon as the simulation starts instead of holding
|
|
49
|
+
* the request open for it. The caller then polls the debug-session endpoints.
|
|
50
|
+
*/
|
|
51
|
+
poll?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/** Test seams. Production passes none of these. */
|
|
54
|
+
export interface AppDebugDeps {
|
|
55
|
+
registry?: NodeRegistry;
|
|
56
|
+
/** Load a workflow's graph by id, scoped to the user. */
|
|
57
|
+
loadWorkflow?: (userId: string, id: string) => Promise<AppWorkflowRecord | null>;
|
|
58
|
+
/** Load an application row by id. */
|
|
59
|
+
loadApplication?: (userId: string, id: string) => Promise<{
|
|
60
|
+
id: string;
|
|
61
|
+
name: string;
|
|
62
|
+
document: unknown;
|
|
63
|
+
} | null>;
|
|
64
|
+
/**
|
|
65
|
+
* Execute a script operation. Running a sandbox body lives above this
|
|
66
|
+
* package, so a host that wants script operations passes one in; without it
|
|
67
|
+
* such an operation reports as unexecutable instead of being skipped.
|
|
68
|
+
*/
|
|
69
|
+
runScript?: JsScriptOperationRunner;
|
|
70
|
+
/** The store `asset://<id>` inputs in the app's workflows resolve through. */
|
|
71
|
+
assetStorage?: StorageAdapter | null;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Debug an app. Resolves with the compacted report (plus the session id), or —
|
|
75
|
+
* with `poll: true` — with the session id as soon as the run is under way.
|
|
76
|
+
*/
|
|
77
|
+
export declare function runApplicationDebug(userId: string, body: AppDebugRequest, defaultRegistry: NodeRegistry, deps?: AppDebugDeps): Promise<Record<string, unknown>>;
|
|
78
|
+
//# sourceMappingURL=app-debug-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-debug-service.d.ts","sourceRoot":"","sources":["../../src/service/app-debug-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAUH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAO3D,OAAO,KAAK,EAEV,iBAAiB,EACjB,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAc/B;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IAEtC,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW;IAD9C,YACW,IAAI,EAAE,eAAe,GAAG,WAAW,EAC5C,OAAO,EAAE,MAAM,EAIhB;CACF;AAED,0DAA0D;AAC1D,MAAM,WAAW,eAAe;IAC9B,yEAAyE;IACzE,cAAc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