@nodetool-ai/execution 0.8.1 → 0.8.2
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 +23 -127
- package/dist/.nodetool-build-stamp +1 -1
- package/dist/app-debug/app-spec.d.ts.map +1 -1
- package/dist/app-debug/app-spec.js +3 -0
- package/dist/app-debug/app-spec.js.map +1 -1
- package/dist/app-debug/application-target.d.ts +1 -1
- package/dist/app-debug/application-target.d.ts.map +1 -1
- package/dist/app-debug/application-target.js +5 -3
- package/dist/app-debug/application-target.js.map +1 -1
- package/dist/app-debug/index.d.ts +4 -2
- package/dist/app-debug/index.d.ts.map +1 -1
- package/dist/app-debug/index.js +3 -2
- package/dist/app-debug/index.js.map +1 -1
- package/dist/app-debug/run-recording.d.ts +20 -0
- package/dist/app-debug/run-recording.d.ts.map +1 -0
- package/dist/app-debug/run-recording.js +105 -0
- package/dist/app-debug/run-recording.js.map +1 -0
- package/dist/app-debug/runtime.d.ts +2 -0
- package/dist/app-debug/runtime.d.ts.map +1 -1
- package/dist/app-debug/runtime.js +14 -3
- package/dist/app-debug/runtime.js.map +1 -1
- package/dist/app-debug/simulate.d.ts +10 -1
- package/dist/app-debug/simulate.d.ts.map +1 -1
- package/dist/app-debug/simulate.js +57 -26
- package/dist/app-debug/simulate.js.map +1 -1
- package/dist/app-debug/summarize.d.ts +1 -0
- package/dist/app-debug/summarize.d.ts.map +1 -1
- package/dist/app-debug/summarize.js +1 -0
- package/dist/app-debug/summarize.js.map +1 -1
- package/dist/app-debug/types.d.ts +6 -4
- package/dist/app-debug/types.d.ts.map +1 -1
- package/dist/app-run-generation.d.ts +8 -0
- package/dist/app-run-generation.d.ts.map +1 -0
- package/dist/app-run-generation.js +61 -0
- package/dist/app-run-generation.js.map +1 -0
- package/dist/browser-app-run.d.ts +10 -0
- package/dist/browser-app-run.d.ts.map +1 -0
- package/dist/browser-app-run.js +108 -0
- package/dist/browser-app-run.js.map +1 -0
- package/dist/browser-run-spans.d.ts +4 -0
- package/dist/browser-run-spans.d.ts.map +1 -0
- package/dist/browser-run-spans.js +115 -0
- package/dist/browser-run-spans.js.map +1 -0
- package/dist/browser-trace-policy.d.ts +12 -0
- package/dist/browser-trace-policy.d.ts.map +1 -0
- package/dist/browser-trace-policy.js +40 -0
- package/dist/browser-trace-policy.js.map +1 -0
- package/dist/cost-ledger.d.ts +3 -0
- package/dist/cost-ledger.d.ts.map +1 -1
- package/dist/cost-ledger.js +23 -2
- package/dist/cost-ledger.js.map +1 -1
- package/dist/debug/types.d.ts +1 -0
- package/dist/debug/types.d.ts.map +1 -1
- package/dist/generation-lifecycle.d.ts +5 -4
- package/dist/generation-lifecycle.d.ts.map +1 -1
- package/dist/generation-lifecycle.js +71 -10
- package/dist/generation-lifecycle.js.map +1 -1
- package/dist/generation-recovery-worker.d.ts.map +1 -1
- package/dist/generation-recovery-worker.js +2 -0
- package/dist/generation-recovery-worker.js.map +1 -1
- package/dist/generation-tracker.d.ts +2 -15
- package/dist/generation-tracker.d.ts.map +1 -1
- package/dist/generation-tracker.js +92 -6
- package/dist/generation-tracker.js.map +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/js-script-debug/index.d.ts +1 -0
- package/dist/js-script-debug/index.d.ts.map +1 -1
- package/dist/js-script-debug/index.js +1 -0
- package/dist/js-script-debug/index.js.map +1 -1
- package/dist/js-script-debug/type-check.d.ts +16 -0
- package/dist/js-script-debug/type-check.d.ts.map +1 -0
- package/dist/js-script-debug/type-check.js +139 -0
- package/dist/js-script-debug/type-check.js.map +1 -0
- package/dist/js-script-debug/validate.d.ts +8 -0
- package/dist/js-script-debug/validate.d.ts.map +1 -1
- package/dist/js-script-debug/validate.js +4 -0
- package/dist/js-script-debug/validate.js.map +1 -1
- package/dist/message-stream.d.ts +1 -32
- package/dist/message-stream.d.ts.map +1 -1
- package/dist/message-stream.js +1 -57
- package/dist/message-stream.js.map +1 -1
- package/dist/preflight.d.ts +43 -2
- package/dist/preflight.d.ts.map +1 -1
- package/dist/preflight.js +78 -4
- package/dist/preflight.js.map +1 -1
- package/dist/run-trace-store.d.ts +9 -0
- package/dist/run-trace-store.d.ts.map +1 -0
- package/dist/run-trace-store.js +57 -0
- package/dist/run-trace-store.js.map +1 -0
- package/dist/runs.d.ts +16 -0
- package/dist/runs.d.ts.map +1 -0
- package/dist/runs.js +431 -0
- package/dist/runs.js.map +1 -0
- package/dist/service/app-debug-service.d.ts +4 -2
- package/dist/service/app-debug-service.d.ts.map +1 -1
- package/dist/service/app-debug-service.js +73 -31
- package/dist/service/app-debug-service.js.map +1 -1
- package/dist/service/app-operation.d.ts +38 -0
- package/dist/service/app-operation.d.ts.map +1 -0
- package/dist/service/app-operation.js +269 -0
- package/dist/service/app-operation.js.map +1 -0
- package/dist/service/app-run-server.d.ts +3 -1
- package/dist/service/app-run-server.d.ts.map +1 -1
- package/dist/service/app-run-server.js +22 -14
- package/dist/service/app-run-server.js.map +1 -1
- package/dist/service/index.d.ts +4 -0
- package/dist/service/index.d.ts.map +1 -1
- package/dist/service/index.js +2 -0
- package/dist/service/index.js.map +1 -1
- package/dist/service/run-trace-lifecycle.d.ts +34 -0
- package/dist/service/run-trace-lifecycle.d.ts.map +1 -0
- package/dist/service/run-trace-lifecycle.js +135 -0
- package/dist/service/run-trace-lifecycle.js.map +1 -0
- package/dist/service/workflow-run.d.ts +5 -16
- package/dist/service/workflow-run.d.ts.map +1 -1
- package/dist/service/workflow-run.js +54 -52
- package/dist/service/workflow-run.js.map +1 -1
- package/dist/session.d.ts +1 -1
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +109 -100
- package/dist/session.js.map +1 -1
- package/dist/sketch-debug/markdown.d.ts.map +1 -1
- package/dist/sketch-debug/markdown.js +1 -0
- package/dist/sketch-debug/markdown.js.map +1 -1
- package/dist/sketch-debug/report.d.ts.map +1 -1
- package/dist/sketch-debug/report.js +4 -4
- package/dist/sketch-debug/report.js.map +1 -1
- package/dist/sketch-debug/types.d.ts +2 -0
- package/dist/sketch-debug/types.d.ts.map +1 -1
- package/dist/timeline-debug/frame-geometry.d.ts +118 -0
- package/dist/timeline-debug/frame-geometry.d.ts.map +1 -0
- package/dist/timeline-debug/frame-geometry.js +231 -0
- package/dist/timeline-debug/frame-geometry.js.map +1 -0
- package/dist/timeline-debug/index.d.ts +1 -0
- package/dist/timeline-debug/index.d.ts.map +1 -1
- package/dist/timeline-debug/index.js +1 -0
- package/dist/timeline-debug/index.js.map +1 -1
- package/dist/timeline-debug/legibility.d.ts +8 -4
- package/dist/timeline-debug/legibility.d.ts.map +1 -1
- package/dist/timeline-debug/legibility.js +47 -18
- package/dist/timeline-debug/legibility.js.map +1 -1
- package/dist/timeline-debug/score.d.ts +110 -0
- package/dist/timeline-debug/score.d.ts.map +1 -0
- package/dist/timeline-debug/score.js +231 -0
- package/dist/timeline-debug/score.js.map +1 -0
- package/dist/timeline-debug/showcase.d.ts +12 -0
- package/dist/timeline-debug/showcase.d.ts.map +1 -1
- package/dist/timeline-debug/showcase.js +669 -13
- package/dist/timeline-debug/showcase.js.map +1 -1
- package/dist/timeline-debug/validate.d.ts.map +1 -1
- package/dist/timeline-debug/validate.js +121 -2
- package/dist/timeline-debug/validate.js.map +1 -1
- package/dist/types.d.ts +18 -10
- package/dist/types.d.ts.map +1 -1
- package/package.json +13 -13
package/dist/message-stream.js
CHANGED
|
@@ -1,58 +1,2 @@
|
|
|
1
|
-
|
|
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
|
-
}
|
|
1
|
+
export { MessageStream, DEFAULT_MESSAGE_BUFFER_LIMIT } from "@nodetool-ai/kernel";
|
|
58
2
|
//# sourceMappingURL=message-stream.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-stream.js","sourceRoot":"","sources":["../src/message-stream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"message-stream.js","sourceRoot":"","sources":["../src/message-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/preflight.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type NodeDescriptor } from "@nodetool-ai/protocol";
|
|
1
2
|
/** Provider/model catalogs the preflight checks a graph's selections against. */
|
|
2
3
|
export interface RunModelCatalogs {
|
|
3
4
|
listProviderIds: () => readonly string[];
|
|
@@ -9,6 +10,26 @@ export declare const RUNTIME_CATALOGS: RunModelCatalogs;
|
|
|
9
10
|
export declare function modelSelectionErrors(graph: {
|
|
10
11
|
nodes?: unknown;
|
|
11
12
|
}, catalogs?: RunModelCatalogs): string[];
|
|
13
|
+
/** The part of a node registry the unset-model check reads. */
|
|
14
|
+
export interface NodeModelValidator {
|
|
15
|
+
validateNode: (descriptor: NodeDescriptor, connectedHandles: ReadonlySet<string>) => ReadonlyArray<{
|
|
16
|
+
code?: string;
|
|
17
|
+
message: string;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Model properties a graph leaves unselected, one message each.
|
|
22
|
+
*
|
|
23
|
+
* A workflow may be saved with a generator whose model is not picked yet (a
|
|
24
|
+
* board that plans generations), so this is where an unpicked model is
|
|
25
|
+
* refused: before the run, instead of at the node after everything upstream
|
|
26
|
+
* of it ran and billed. A property fed by a data edge is supplied at run time,
|
|
27
|
+
* and a bypassed node never runs, so neither is reported.
|
|
28
|
+
*/
|
|
29
|
+
export declare function unsetModelErrors(graph: {
|
|
30
|
+
nodes?: unknown;
|
|
31
|
+
edges?: unknown;
|
|
32
|
+
}, registry: NodeModelValidator): string[];
|
|
12
33
|
/** How the preflight resolves a credential — the way the coming run will. */
|
|
13
34
|
export interface CredentialResolver {
|
|
14
35
|
resolveSecret: (key: string) => Promise<string | null | undefined> | string | null | undefined;
|
|
@@ -43,7 +64,7 @@ export type ProviderConfigurationChecker = (graph: {
|
|
|
43
64
|
}, resolver: CredentialResolver) => Promise<readonly string[]> | readonly string[];
|
|
44
65
|
/** A checker over an explicit provider list, for a host with its own registry. */
|
|
45
66
|
export declare function providerConfigurationChecker(providerIds: readonly string[]): ProviderConfigurationChecker;
|
|
46
|
-
export type PreflightIssueKind = "model" | "credential";
|
|
67
|
+
export type PreflightIssueKind = "unset_model" | "model" | "credential";
|
|
47
68
|
/** One reason a run was refused before it started. */
|
|
48
69
|
export interface ExecutionPreflightIssue {
|
|
49
70
|
kind: PreflightIssueKind;
|
|
@@ -64,14 +85,34 @@ export declare class ExecutionPreflightError extends Error {
|
|
|
64
85
|
export declare function isExecutionPreflightError(value: unknown): value is ExecutionPreflightError;
|
|
65
86
|
export interface PreflightOptions {
|
|
66
87
|
catalogs?: RunModelCatalogs;
|
|
88
|
+
/**
|
|
89
|
+
* The run's params. An input node the run fills is checked with the value
|
|
90
|
+
* it receives, so a default the run replaces never refuses it.
|
|
91
|
+
*/
|
|
92
|
+
params?: Record<string, unknown>;
|
|
67
93
|
providerConfiguration?: ProviderConfigurationChecker;
|
|
68
94
|
/** Resolves a credential the way the coming run will. */
|
|
69
95
|
resolveSecret: CredentialResolver["resolveSecret"];
|
|
96
|
+
/**
|
|
97
|
+
* Node registry for the unset-model check. Without one, unpicked models are
|
|
98
|
+
* left to the kernel's own node validation.
|
|
99
|
+
*/
|
|
100
|
+
registry?: NodeModelValidator;
|
|
70
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* `graph` with each input node's value replaced by the param the run passes
|
|
104
|
+
* for it, by the rule the kernel dispatches inputs with: a `nodetool.input.*`
|
|
105
|
+
* node takes the param under its `name`, and an undefined param keeps the
|
|
106
|
+
* default.
|
|
107
|
+
*/
|
|
108
|
+
export declare function withRunParams<G extends {
|
|
109
|
+
nodes?: unknown;
|
|
110
|
+
edges?: unknown;
|
|
111
|
+
}>(graph: G, params: Record<string, unknown> | undefined): G;
|
|
71
112
|
/**
|
|
72
113
|
* Every reason to refuse `graph`, model selections first.
|
|
73
114
|
*
|
|
74
|
-
* A graph whose model selections are
|
|
115
|
+
* A graph whose model selections are unset or unhonourable stops there: a
|
|
75
116
|
* provider that is not registered has no credentials to check, so running the
|
|
76
117
|
* second check would only add noise to a refusal that is already decided.
|
|
77
118
|
*/
|
package/dist/preflight.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../src/preflight.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../src/preflight.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAcxE,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,+DAA+D;AAC/D,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,CACZ,UAAU,EAAE,cAAc,EAC1B,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,KAClC,aAAa,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC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AAC,IAAI,CAAC,CAGf"}
|
package/dist/preflight.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* model-selection check rather than guessed at.
|
|
15
15
|
*/
|
|
16
16
|
import { rewriteBypassedNodes } from "@nodetool-ai/kernel";
|
|
17
|
+
import { isDataEdge } from "@nodetool-ai/protocol";
|
|
17
18
|
import { collectModelProviders, collectModelSelectionIssues } from "@nodetool-ai/node-sdk";
|
|
18
19
|
import { getProviderSecretKey, isProviderConfigured, listOfflineModelIds, listRegisteredProviderIds } from "@nodetool-ai/runtime";
|
|
19
20
|
import { normalizeGraph } from "./normalize-graph.js";
|
|
@@ -32,6 +33,42 @@ export function modelSelectionErrors(graph, catalogs = RUNTIME_CATALOGS) {
|
|
|
32
33
|
.filter((issue) => issue.severity === "error")
|
|
33
34
|
.map((issue) => `Node "${issue.nodeId}" (${issue.nodeType}): ${issue.message}`);
|
|
34
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Model properties a graph leaves unselected, one message each.
|
|
38
|
+
*
|
|
39
|
+
* A workflow may be saved with a generator whose model is not picked yet (a
|
|
40
|
+
* board that plans generations), so this is where an unpicked model is
|
|
41
|
+
* refused: before the run, instead of at the node after everything upstream
|
|
42
|
+
* of it ran and billed. A property fed by a data edge is supplied at run time,
|
|
43
|
+
* and a bypassed node never runs, so neither is reported.
|
|
44
|
+
*/
|
|
45
|
+
export function unsetModelErrors(graph, registry) {
|
|
46
|
+
const nodes = graph.nodes;
|
|
47
|
+
if (!Array.isArray(nodes))
|
|
48
|
+
return [];
|
|
49
|
+
const effectiveGraph = rewriteBypassedNodes(normalizeGraph({
|
|
50
|
+
nodes: nodes.filter(isRecord),
|
|
51
|
+
edges: Array.isArray(graph.edges) ? graph.edges.filter(isRecord) : []
|
|
52
|
+
}));
|
|
53
|
+
const connected = new Map();
|
|
54
|
+
for (const edge of effectiveGraph.edges) {
|
|
55
|
+
if (!isDataEdge(edge))
|
|
56
|
+
continue;
|
|
57
|
+
const handles = connected.get(edge.target) ?? new Set();
|
|
58
|
+
handles.add(edge.targetHandle);
|
|
59
|
+
connected.set(edge.target, handles);
|
|
60
|
+
}
|
|
61
|
+
const errors = [];
|
|
62
|
+
for (const node of effectiveGraph.nodes) {
|
|
63
|
+
const issues = registry.validateNode(node, connected.get(node.id) ?? new Set());
|
|
64
|
+
for (const issue of issues) {
|
|
65
|
+
if (issue.code !== "unset_model")
|
|
66
|
+
continue;
|
|
67
|
+
errors.push(`Node "${node.id}" (${node.type}): ${issue.message}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return errors;
|
|
71
|
+
}
|
|
35
72
|
/**
|
|
36
73
|
* Providers a graph selects whose required credentials this runtime cannot
|
|
37
74
|
* resolve, one message each.
|
|
@@ -80,13 +117,14 @@ export function providerConfigurationChecker(providerIds) {
|
|
|
80
117
|
return (graph, resolver) => unconfiguredProviderErrors(graph, resolver, providerIds);
|
|
81
118
|
}
|
|
82
119
|
const HEADINGS = {
|
|
120
|
+
unset_model: "Workflow leaves model properties unselected. Pick a model on each before running:",
|
|
83
121
|
model: "Workflow selects providers or models this runtime cannot honour:",
|
|
84
122
|
credential: "Workflow selects providers whose credentials are not configured:"
|
|
85
123
|
};
|
|
86
124
|
/** The refusal text every host prints — one section per issue kind. */
|
|
87
125
|
export function formatPreflightDetail(issues) {
|
|
88
126
|
const sections = [];
|
|
89
|
-
for (const kind of ["model", "credential"]) {
|
|
127
|
+
for (const kind of ["unset_model", "model", "credential"]) {
|
|
90
128
|
const messages = issues
|
|
91
129
|
.filter((issue) => issue.kind === kind)
|
|
92
130
|
.map((issue) => issue.message);
|
|
@@ -112,17 +150,53 @@ export class ExecutionPreflightError extends Error {
|
|
|
112
150
|
export function isExecutionPreflightError(value) {
|
|
113
151
|
return value instanceof ExecutionPreflightError;
|
|
114
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* `graph` with each input node's value replaced by the param the run passes
|
|
155
|
+
* for it, by the rule the kernel dispatches inputs with: a `nodetool.input.*`
|
|
156
|
+
* node takes the param under its `name`, and an undefined param keeps the
|
|
157
|
+
* default.
|
|
158
|
+
*/
|
|
159
|
+
export function withRunParams(graph, params) {
|
|
160
|
+
const nodes = graph.nodes;
|
|
161
|
+
if (!params || !Array.isArray(nodes))
|
|
162
|
+
return graph;
|
|
163
|
+
return {
|
|
164
|
+
...graph,
|
|
165
|
+
nodes: nodes.map((node) => {
|
|
166
|
+
if (!isRecord(node) ||
|
|
167
|
+
typeof node.type !== "string" ||
|
|
168
|
+
!node.type.startsWith("nodetool.input.")) {
|
|
169
|
+
return node;
|
|
170
|
+
}
|
|
171
|
+
const properties = isRecord(node.properties) ? node.properties : {};
|
|
172
|
+
const propertyName = typeof properties.name === "string" ? properties.name.trim() : "";
|
|
173
|
+
const name = propertyName ||
|
|
174
|
+
(typeof node.name === "string" ? node.name : String(node.id));
|
|
175
|
+
if (!Object.hasOwn(params, name) || params[name] === undefined) {
|
|
176
|
+
return node;
|
|
177
|
+
}
|
|
178
|
+
return { ...node, properties: { ...properties, value: params[name] } };
|
|
179
|
+
})
|
|
180
|
+
};
|
|
181
|
+
}
|
|
115
182
|
/**
|
|
116
183
|
* Every reason to refuse `graph`, model selections first.
|
|
117
184
|
*
|
|
118
|
-
* A graph whose model selections are
|
|
185
|
+
* A graph whose model selections are unset or unhonourable stops there: a
|
|
119
186
|
* provider that is not registered has no credentials to check, so running the
|
|
120
187
|
* second check would only add noise to a refusal that is already decided.
|
|
121
188
|
*/
|
|
122
189
|
export async function collectPreflightIssues(graph, options) {
|
|
190
|
+
graph = withRunParams(graph, options.params);
|
|
191
|
+
const unset = options.registry
|
|
192
|
+
? unsetModelErrors(graph, options.registry)
|
|
193
|
+
: [];
|
|
123
194
|
const models = modelSelectionErrors(graph, options.catalogs);
|
|
124
|
-
if (models.length > 0) {
|
|
125
|
-
return
|
|
195
|
+
if (unset.length > 0 || models.length > 0) {
|
|
196
|
+
return [
|
|
197
|
+
...unset.map((message) => ({ kind: "unset_model", message })),
|
|
198
|
+
...models.map((message) => ({ kind: "model", message }))
|
|
199
|
+
];
|
|
126
200
|
}
|
|
127
201
|
const checker = options.providerConfiguration ?? unconfiguredProviderErrors;
|
|
128
202
|
const credentials = await checker(graph, {
|
package/dist/preflight.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../src/preflight.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAC5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAW3C,0DAA0D;AAC1D,MAAM,CAAC,MAAM,gBAAgB,GAAqB;IAChD,eAAe,EAAE,GAAG,EAAE,CAAC,yBAAyB,EAAE;IAClD,YAAY,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,CACpC,mBAAmB,CAAC,QAAQ,EAAE,SAAS,CAAC;CAC3C,CAAC;AAEF,0EAA0E;AAC1E,MAAM,UAAU,oBAAoB,CAClC,KAA0B,EAC1B,QAAQ,GAAqB,gBAAgB;IAE7C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,OAAO,2BAA2B,CAAC,EAAE,KAAK,EAAE,KAAgB,EAAE,EAAE,QAAQ,CAAC;SACtE,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,OAAO,CAAC;SAC7C,GAAG,CACF,CAAC,KAA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AM,GAAG,CAAC;QAAE,MAAM,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { StoredRunTraceUpdate } from "@nodetool-ai/protocol";
|
|
2
|
+
export type RunTraceUpdateListener = (userId: string, update: StoredRunTraceUpdate) => void;
|
|
3
|
+
/** Subscribe to committed, sanitized snapshots. Transport hosts still enforce ownership. */
|
|
4
|
+
export declare function subscribeRunTraceUpdates(listener: RunTraceUpdateListener): () => void;
|
|
5
|
+
/** Publish only records already committed and sanitized by the run store. */
|
|
6
|
+
export declare function publishCommittedRunTraceUpdate(userId: string, update: StoredRunTraceUpdate): void;
|
|
7
|
+
/** Install the database bridge even if an external sink initialized telemetry first. */
|
|
8
|
+
export declare function ensureRunTraceTelemetry(): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=run-trace-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-trace-store.d.ts","sourceRoot":"","sources":["../src/run-trace-store.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElE,MAAM,MAAM,sBAAsB,GAAG,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,oBAAoB,KACzB,IAAI,CAAC;AAKV,4FAA4F;AAC5F,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,sBAAsB,GAAG,MAAM,IAAI,CAGrF;AAED,6EAA6E;AAC7E,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAKjG;AAoCD,wFAAwF;AACxF,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAM7D"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { getRegisteredTrace, getRunTrace, markRunTraceIncomplete, sanitizeRunTraceRecord, writeRunTraceUpdate } from "@nodetool-ai/models";
|
|
2
|
+
import { configureRunTraceStore, initTelemetry } from "@nodetool-ai/runtime";
|
|
3
|
+
const listeners = new Set();
|
|
4
|
+
let configured = false;
|
|
5
|
+
/** Subscribe to committed, sanitized snapshots. Transport hosts still enforce ownership. */
|
|
6
|
+
export function subscribeRunTraceUpdates(listener) {
|
|
7
|
+
listeners.add(listener);
|
|
8
|
+
return () => { listeners.delete(listener); };
|
|
9
|
+
}
|
|
10
|
+
/** Publish only records already committed and sanitized by the run store. */
|
|
11
|
+
export function publishCommittedRunTraceUpdate(userId, update) {
|
|
12
|
+
for (const listener of listeners) {
|
|
13
|
+
try {
|
|
14
|
+
listener(userId, update);
|
|
15
|
+
}
|
|
16
|
+
catch { /* A disconnected reader cannot fail durable recording. */ }
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const adapter = {
|
|
20
|
+
lookup: getRegisteredTrace,
|
|
21
|
+
sanitize: sanitizeRunTraceRecord,
|
|
22
|
+
async write(updates) {
|
|
23
|
+
for (const write of updates) {
|
|
24
|
+
const registration = write.userId && write.runId
|
|
25
|
+
? await getRunTrace(write.userId, write.runId)
|
|
26
|
+
: await getRegisteredTrace(write.update.record.trace_id);
|
|
27
|
+
if (!registration || registration.trace_id !== write.update.record.trace_id) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const committed = await writeRunTraceUpdate(registration.user_id, registration.id, write.update, {
|
|
31
|
+
secretValues: write.secretValues,
|
|
32
|
+
contentSuppressed: write.contentSuppressed,
|
|
33
|
+
isRoot: write.isRoot
|
|
34
|
+
});
|
|
35
|
+
if (!committed) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
publishCommittedRunTraceUpdate(registration.user_id, committed);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
async markIncomplete(traceId, reason) {
|
|
42
|
+
const registration = await getRegisteredTrace(traceId);
|
|
43
|
+
if (registration) {
|
|
44
|
+
await markRunTraceIncomplete(registration.user_id, traceId, reason);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
async flush() { }
|
|
48
|
+
};
|
|
49
|
+
/** Install the database bridge even if an external sink initialized telemetry first. */
|
|
50
|
+
export async function ensureRunTraceTelemetry() {
|
|
51
|
+
if (!configured) {
|
|
52
|
+
configureRunTraceStore(adapter);
|
|
53
|
+
configured = true;
|
|
54
|
+
}
|
|
55
|
+
await initTelemetry();
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=run-trace-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-trace-store.js","sourceRoot":"","sources":["../src/run-trace-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,aAAa,EAEd,MAAM,sBAAsB,CAAC;AAQ9B,MAAM,SAAS,GAAG,IAAI,GAAG,EAA0B,CAAC;AACpD,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB,4FAA4F;AAC5F,MAAM,UAAU,wBAAwB,CAAC,QAAgC;IACvE,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxB,OAAO,GAAG,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,8BAA8B,CAAC,MAAc,EAAE,MAA4B;IACzF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC;YAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,CAAC;QACjC,MAAM,CAAC,CAAC,0DAA0D,CAAC,CAAC;IACtE,CAAC;AACH,CAAC;AAED,MAAM,OAAO,GAAkB;IAC7B,MAAM,EAAE,kBAAkB;IAC1B,QAAQ,EAAE,sBAAsB;IAChC,KAAK,CAAC,K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ChB,sBAAsB,CAAC,OAAO,CAAC,CAAC;QAChC,UAAU,GAAG,IAAI,CAAC;IACpB,CAAC;IACD,MAAM,aAAa,EAAE,CAAC;AACxB,CAAC"}
|
package/dist/runs.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type RunListOptions, type RunGetOptions, type RunTraceOptions, type RunLogsOptions, type RunAwaitOptions, type RunUpdatesOptions, type GetRunResult, type ListRunsResult, type GetRunTraceResult, type GetRunLogsResult, type RunUpdatesResult, type RunTraceRegistration } from "@nodetool-ai/protocol";
|
|
2
|
+
export declare class RunsError extends Error {
|
|
3
|
+
readonly code: "not_found" | "ambiguous" | "invalid_input" | "timeout" | "aborted";
|
|
4
|
+
constructor(code: "not_found" | "ambiguous" | "invalid_input" | "timeout" | "aborted", message: string);
|
|
5
|
+
}
|
|
6
|
+
export declare function findRunForSource(userId: string, kind: RunTraceRegistration["kind"], sourceId: string): Promise<RunTraceRegistration | null>;
|
|
7
|
+
export declare function listRuns(userId: string, options?: RunListOptions): Promise<ListRunsResult>;
|
|
8
|
+
export declare function getRun(userId: string, id: string, options?: RunGetOptions): Promise<GetRunResult>;
|
|
9
|
+
export declare function getRunTrace(userId: string, id: string, options?: RunTraceOptions): Promise<GetRunTraceResult>;
|
|
10
|
+
export declare function getRunLogs(userId: string, id: string, options?: RunLogsOptions): Promise<GetRunLogsResult>;
|
|
11
|
+
/** Polling reads latest snapshots. It deliberately never promises append-only replay. */
|
|
12
|
+
export declare function readRunUpdates(userId: string, id: string, options?: RunUpdatesOptions): Promise<RunUpdatesResult>;
|
|
13
|
+
export declare function awaitRun(userId: string, id: string, options?: RunAwaitOptions & {
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
}): Promise<GetRunResult>;
|
|
16
|
+
//# sourceMappingURL=runs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../src/runs.ts"],"names":[],"mappings":"AAEA,OA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