@blokjs/runner 0.2.0 → 0.2.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/dist/Blok.js +11 -11
- package/dist/Blok.js.map +1 -1
- package/dist/Configuration.d.ts +21 -2
- package/dist/Configuration.js +188 -26
- package/dist/Configuration.js.map +1 -1
- package/dist/ConfigurationResolver.d.ts +9 -0
- package/dist/ConfigurationResolver.js +17 -1
- package/dist/ConfigurationResolver.js.map +1 -1
- package/dist/RunnerSteps.js +52 -9
- package/dist/RunnerSteps.js.map +1 -1
- package/dist/RuntimeAdapterNode.d.ts +32 -2
- package/dist/RuntimeAdapterNode.js +122 -27
- package/dist/RuntimeAdapterNode.js.map +1 -1
- package/dist/TriggerBase.js +35 -2
- package/dist/TriggerBase.js.map +1 -1
- package/dist/adapters/BunRuntimeAdapter.d.ts +1 -0
- package/dist/adapters/BunRuntimeAdapter.js +1 -0
- package/dist/adapters/BunRuntimeAdapter.js.map +1 -1
- package/dist/adapters/DockerRuntimeAdapter.d.ts +2 -1
- package/dist/adapters/DockerRuntimeAdapter.js +10 -1
- package/dist/adapters/DockerRuntimeAdapter.js.map +1 -1
- package/dist/adapters/HttpRuntimeAdapter.d.ts +26 -5
- package/dist/adapters/HttpRuntimeAdapter.js +97 -16
- package/dist/adapters/HttpRuntimeAdapter.js.map +1 -1
- package/dist/adapters/NodeJsRuntimeAdapter.d.ts +1 -0
- package/dist/adapters/NodeJsRuntimeAdapter.js +1 -0
- package/dist/adapters/NodeJsRuntimeAdapter.js.map +1 -1
- package/dist/adapters/RuntimeAdapter.d.ts +17 -0
- package/dist/adapters/WasmRuntimeAdapter.d.ts +1 -0
- package/dist/adapters/WasmRuntimeAdapter.js +1 -0
- package/dist/adapters/WasmRuntimeAdapter.js.map +1 -1
- package/dist/adapters/grpc/GrpcChannelOptions.d.ts +31 -0
- package/dist/adapters/grpc/GrpcChannelOptions.js +68 -0
- package/dist/adapters/grpc/GrpcChannelOptions.js.map +1 -0
- package/dist/adapters/grpc/GrpcClientPool.d.ts +43 -0
- package/dist/adapters/grpc/GrpcClientPool.js +89 -0
- package/dist/adapters/grpc/GrpcClientPool.js.map +1 -0
- package/dist/adapters/grpc/GrpcCodec.d.ts +226 -0
- package/dist/adapters/grpc/GrpcCodec.js +275 -0
- package/dist/adapters/grpc/GrpcCodec.js.map +1 -0
- package/dist/adapters/grpc/GrpcErrors.d.ts +59 -0
- package/dist/adapters/grpc/GrpcErrors.js +190 -0
- package/dist/adapters/grpc/GrpcErrors.js.map +1 -0
- package/dist/adapters/grpc/GrpcHealthChecker.d.ts +69 -0
- package/dist/adapters/grpc/GrpcHealthChecker.js +96 -0
- package/dist/adapters/grpc/GrpcHealthChecker.js.map +1 -0
- package/dist/adapters/grpc/GrpcRuntimeAdapter.d.ts +98 -0
- package/dist/adapters/grpc/GrpcRuntimeAdapter.js +478 -0
- package/dist/adapters/grpc/GrpcRuntimeAdapter.js.map +1 -0
- package/dist/adapters/grpc/index.d.ts +13 -0
- package/dist/adapters/grpc/index.js +14 -0
- package/dist/adapters/grpc/index.js.map +1 -0
- package/dist/adapters/grpc/proto/blok/runtime/v1/runtime.proto +302 -0
- package/dist/adapters/grpc/types.d.ts +97 -0
- package/dist/adapters/grpc/types.js +41 -0
- package/dist/adapters/grpc/types.js.map +1 -0
- package/dist/adapters/transport.d.ts +108 -0
- package/dist/adapters/transport.js +196 -0
- package/dist/adapters/transport.js.map +1 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/testing/WorkflowTestRunner.js +12 -0
- package/dist/testing/WorkflowTestRunner.js.map +1 -1
- package/dist/tracing/RunTracker.d.ts +23 -2
- package/dist/tracing/RunTracker.js +120 -10
- package/dist/tracing/RunTracker.js.map +1 -1
- package/dist/tracing/SqliteRunStore.js +19 -3
- package/dist/tracing/SqliteRunStore.js.map +1 -1
- package/dist/tracing/TraceRouter.js +245 -4
- package/dist/tracing/TraceRouter.js.map +1 -1
- package/dist/tracing/types.d.ts +82 -10
- package/dist/types/GlobalOptions.d.ts +9 -2
- package/dist/workflow/PersistenceHelper.d.ts +46 -0
- package/dist/workflow/PersistenceHelper.js +57 -0
- package/dist/workflow/PersistenceHelper.js.map +1 -0
- package/dist/workflow/WorkflowNormalizer.d.ts +91 -0
- package/dist/workflow/WorkflowNormalizer.js +304 -0
- package/dist/workflow/WorkflowNormalizer.js.map +1 -0
- package/package.json +10 -7
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the transport to use for a given runtime kind from the environment.
|
|
3
|
+
*
|
|
4
|
+
* Precedence (most specific wins):
|
|
5
|
+
* 1. `RUNTIME_<KIND>_TRANSPORT` — per-kind override
|
|
6
|
+
* e.g. `RUNTIME_PYTHON3_TRANSPORT=http` to opt one SDK out of gRPC.
|
|
7
|
+
* 2. `RUNTIME_TRANSPORT` — global override
|
|
8
|
+
* e.g. `RUNTIME_TRANSPORT=http` to roll back the whole runner.
|
|
9
|
+
* 3. The hard-coded default — **`grpc`** as of Phase 6 (master plan §11).
|
|
10
|
+
* Flipped from `http` to `grpc` after the cross-language parity matrix
|
|
11
|
+
* (`bun run test:parity`, 33 tests across 6 SDKs × 5 workflows) and
|
|
12
|
+
* the per-SDK §17 BlokError E2E suites stayed green for the full
|
|
13
|
+
* Phase 5 observation window.
|
|
14
|
+
*
|
|
15
|
+
* Pure function — reads `process.env` once per call so tests can override.
|
|
16
|
+
*
|
|
17
|
+
* # Why the default flip is safe
|
|
18
|
+
*
|
|
19
|
+
* - HTTP transport remains available behind `RUNTIME_TRANSPORT=http` for at
|
|
20
|
+
* least two minor versions (master plan §11 commitment).
|
|
21
|
+
* - PHP without RoadRunner (Path B from §16) sets
|
|
22
|
+
* `RUNTIME_PHP_TRANSPORT=http` per host. The forever-supported escape
|
|
23
|
+
* hatch is unaffected.
|
|
24
|
+
* - SDKs that fail to bind their gRPC listener fall through the
|
|
25
|
+
* {@link GrpcHealthChecker} circuit-breaker and surface a typed
|
|
26
|
+
* `BlokError(category=DEPENDENCY)` per §9 — no silent failure.
|
|
27
|
+
*
|
|
28
|
+
* @param kind The runtime kind (e.g. "python3").
|
|
29
|
+
* @param env Optional env source (defaults to `process.env`). Tests can
|
|
30
|
+
* pass a stub map.
|
|
31
|
+
* @returns Either `"http"` or `"grpc"`. Invalid values fall back to the
|
|
32
|
+
* Phase 6 default (`grpc`).
|
|
33
|
+
*/
|
|
34
|
+
export function resolveTransportForKind(kind, env = process.env) {
|
|
35
|
+
const perKindKey = `RUNTIME_${kind.toUpperCase()}_TRANSPORT`;
|
|
36
|
+
const perKind = env[perKindKey];
|
|
37
|
+
if (perKind === "grpc" || perKind === "http") {
|
|
38
|
+
if (perKind === "http")
|
|
39
|
+
warnDeprecatedHttpTransport(perKindKey);
|
|
40
|
+
return perKind;
|
|
41
|
+
}
|
|
42
|
+
const global = env.RUNTIME_TRANSPORT;
|
|
43
|
+
if (global === "grpc" || global === "http") {
|
|
44
|
+
if (global === "http")
|
|
45
|
+
warnDeprecatedHttpTransport("RUNTIME_TRANSPORT");
|
|
46
|
+
return global;
|
|
47
|
+
}
|
|
48
|
+
// Phase 6 default: gRPC. The flip from HTTP landed once the parity
|
|
49
|
+
// matrix had been green for the observation window.
|
|
50
|
+
return "grpc";
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Set of env-var names that have already triggered the deprecation warning
|
|
54
|
+
* in this process. Prevents log spam when many runtime kinds resolve through
|
|
55
|
+
* the same global override on each request.
|
|
56
|
+
*
|
|
57
|
+
* Exported as a reset hook for tests — production code never touches it.
|
|
58
|
+
*/
|
|
59
|
+
const _httpDeprecationWarned = new Set();
|
|
60
|
+
function warnDeprecatedHttpTransport(envKey) {
|
|
61
|
+
if (_httpDeprecationWarned.has(envKey))
|
|
62
|
+
return;
|
|
63
|
+
_httpDeprecationWarned.add(envKey);
|
|
64
|
+
console.warn(`[blok] ${envKey}=http is deprecated and will be removed in v0.4.0. Migrate to gRPC by dropping the env var (gRPC is the default since Phase 6) and ensuring your SDK process boots with BLOK_TRANSPORT=grpc.`);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Test-only — reset the per-process HTTP-transport deprecation cache so a
|
|
68
|
+
* test that flips `RUNTIME_TRANSPORT=http` can re-assert the warning fires.
|
|
69
|
+
*
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
export function _resetHttpDeprecationCache() {
|
|
73
|
+
_httpDeprecationWarned.clear();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Whether log streaming is enabled for runtime nodes. When true, the runner
|
|
77
|
+
* routes runtime nodes through `GrpcRuntimeAdapter.executeStream` instead of
|
|
78
|
+
* the unary `execute`, and `LogLine` frames flow into `RunTracker.addLog`
|
|
79
|
+
* — surfacing live in Studio's `/__blok/runs/:id/stream` SSE endpoint.
|
|
80
|
+
*
|
|
81
|
+
* Streaming is a pure additive capability: when the env var is unset, the
|
|
82
|
+
* legacy unary path runs unchanged. When enabled but the adapter doesn't
|
|
83
|
+
* support streaming (e.g. HttpRuntimeAdapter), `RuntimeAdapterNode` falls
|
|
84
|
+
* back to unary so misconfiguration never blocks execution.
|
|
85
|
+
*
|
|
86
|
+
* Recognized as truthy: `1`, `true`, `yes`, `on` (case-insensitive). Anything
|
|
87
|
+
* else (including unset, empty, `0`, `false`) returns false.
|
|
88
|
+
*/
|
|
89
|
+
export function isStreamLogsEnabled(env = process.env) {
|
|
90
|
+
return isTruthyFlag(env.BLOK_STREAM_LOGS);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Resolve the gRPC background health-check interval from the environment.
|
|
94
|
+
*
|
|
95
|
+
* `BLOK_GRPC_HEALTH_INTERVAL_MS` is the global override:
|
|
96
|
+
* - any positive integer → use that interval
|
|
97
|
+
* - `0` → disable the loop entirely (useful in tests)
|
|
98
|
+
* - unset / non-numeric → return undefined; adapter uses
|
|
99
|
+
* {@link GRPC_DEFAULTS.HEALTH_INTERVAL_MS}.
|
|
100
|
+
*/
|
|
101
|
+
export function resolveHealthCheckIntervalMs(env = process.env) {
|
|
102
|
+
const raw = env.BLOK_GRPC_HEALTH_INTERVAL_MS;
|
|
103
|
+
if (raw === undefined || raw === "")
|
|
104
|
+
return undefined;
|
|
105
|
+
const parsed = Number.parseInt(raw, 10);
|
|
106
|
+
if (Number.isNaN(parsed) || parsed < 0)
|
|
107
|
+
return undefined;
|
|
108
|
+
return parsed;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Resolve the consecutive-failure threshold for the gRPC circuit breaker.
|
|
112
|
+
*
|
|
113
|
+
* `BLOK_GRPC_HEALTH_FAILURE_THRESHOLD` overrides the default
|
|
114
|
+
* ({@link GRPC_DEFAULTS.HEALTH_FAILURE_THRESHOLD}). Values < 1 are ignored
|
|
115
|
+
* (the checker requires ≥ 1 failure to trip).
|
|
116
|
+
*/
|
|
117
|
+
export function resolveHealthCheckFailureThreshold(env = process.env) {
|
|
118
|
+
const raw = env.BLOK_GRPC_HEALTH_FAILURE_THRESHOLD;
|
|
119
|
+
if (raw === undefined || raw === "")
|
|
120
|
+
return undefined;
|
|
121
|
+
const parsed = Number.parseInt(raw, 10);
|
|
122
|
+
if (Number.isNaN(parsed) || parsed < 1)
|
|
123
|
+
return undefined;
|
|
124
|
+
return parsed;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Build a {@link TlsConfig} for a given runtime kind from environment
|
|
128
|
+
* variables. Returns `undefined` when nothing is configured (channel stays
|
|
129
|
+
* plaintext — appropriate for loopback dev).
|
|
130
|
+
*
|
|
131
|
+
* Per-kind env vars (taking precedence):
|
|
132
|
+
* - `RUNTIME_<KIND>_TLS_CA` CA cert path (PEM)
|
|
133
|
+
* - `RUNTIME_<KIND>_TLS_CLIENT_CERT` client cert path (PEM, mTLS)
|
|
134
|
+
* - `RUNTIME_<KIND>_TLS_CLIENT_KEY` client key path (PEM, mTLS)
|
|
135
|
+
* - `RUNTIME_<KIND>_TLS_SERVER_NAME` SNI override
|
|
136
|
+
* - `RUNTIME_<KIND>_TLS_INSECURE_SKIP_VERIFY=true` dev-only
|
|
137
|
+
*
|
|
138
|
+
* Global fallbacks (apply when the per-kind var is unset):
|
|
139
|
+
* - `BLOK_GRPC_TLS_CA`, `BLOK_GRPC_TLS_CLIENT_CERT`, `BLOK_GRPC_TLS_CLIENT_KEY`,
|
|
140
|
+
* `BLOK_GRPC_TLS_SERVER_NAME`, `BLOK_GRPC_TLS_INSECURE_SKIP_VERIFY`.
|
|
141
|
+
*
|
|
142
|
+
* If none of the relevant env vars are set, returns `undefined`.
|
|
143
|
+
*/
|
|
144
|
+
export function loadTlsConfigForKind(kind, env = process.env) {
|
|
145
|
+
const upperKind = kind.toUpperCase();
|
|
146
|
+
const pick = (suffix) => env[`RUNTIME_${upperKind}_TLS_${suffix}`] ?? env[`BLOK_GRPC_TLS_${suffix}`];
|
|
147
|
+
const caCertPath = pick("CA");
|
|
148
|
+
const clientCertPath = pick("CLIENT_CERT");
|
|
149
|
+
const clientKeyPath = pick("CLIENT_KEY");
|
|
150
|
+
const serverNameOverride = pick("SERVER_NAME");
|
|
151
|
+
const insecureSkipVerifyRaw = pick("INSECURE_SKIP_VERIFY");
|
|
152
|
+
const insecureSkipVerify = isTruthyFlag(insecureSkipVerifyRaw);
|
|
153
|
+
const anySet = caCertPath !== undefined ||
|
|
154
|
+
clientCertPath !== undefined ||
|
|
155
|
+
clientKeyPath !== undefined ||
|
|
156
|
+
serverNameOverride !== undefined ||
|
|
157
|
+
insecureSkipVerify;
|
|
158
|
+
if (!anySet)
|
|
159
|
+
return undefined;
|
|
160
|
+
return {
|
|
161
|
+
caCertPath,
|
|
162
|
+
clientCertPath,
|
|
163
|
+
clientKeyPath,
|
|
164
|
+
serverNameOverride,
|
|
165
|
+
insecureSkipVerify,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Whether `BLOK_GRPC_REQUIRE_TLS=true` enforces TLS on non-loopback hosts.
|
|
170
|
+
* When true, building a gRPC adapter with no TLS config against a non-loopback
|
|
171
|
+
* host throws at startup. Loopback (localhost, 127.0.0.0/8, ::1) is exempted.
|
|
172
|
+
*/
|
|
173
|
+
export function isStrictTlsEnabled(env = process.env) {
|
|
174
|
+
return isTruthyFlag(env.BLOK_GRPC_REQUIRE_TLS);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Returns true when the host is a loopback address that doesn't require
|
|
178
|
+
* TLS even under strict mode. Match is intentionally generous — covers
|
|
179
|
+
* `localhost`, the 127.x range, IPv6 loopback, and the wildcard 0.0.0.0
|
|
180
|
+
* (which dev SDKs commonly bind to).
|
|
181
|
+
*/
|
|
182
|
+
export function isLoopbackHost(host) {
|
|
183
|
+
const normalized = host.trim().toLowerCase();
|
|
184
|
+
if (normalized === "localhost" || normalized === "::1" || normalized === "0.0.0.0")
|
|
185
|
+
return true;
|
|
186
|
+
if (normalized.startsWith("127."))
|
|
187
|
+
return true;
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
function isTruthyFlag(value) {
|
|
191
|
+
if (!value)
|
|
192
|
+
return false;
|
|
193
|
+
const normalized = value.trim().toLowerCase();
|
|
194
|
+
return normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on";
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/adapters/transport.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAiB,EAAE,MAAyB,OAAO,CAAC,GAAG;IAC9F,MAAM,UAAU,GAAG,WAAW,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC;IAC7D,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC;IAChC,IAAI,OAA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AAM,MAAM,GACX,UAAU,KAAK,SAAS;QACxB,cAAc,KAAK,SAAS;QAC5B,aAAa,KAAK,SAAS;QAC3B,kBAAkB,KAAK,SAAS;QAChC,kBAAkB,CAAC;IAEpB,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAE9B,OAAO;QACN,UAAU;QACV,cAAc;QACd,aAAa;QACb,kBAAkB;QAClB,kBAAkB;KAClB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACtE,OAAO,YAAY,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;AAChD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC7C,IAAI,UAAU,KAAK,WAAW,IAAI,UAAU,KAAK,KAAK,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAChG,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/C,OAAO,KAAK,CAAC;AACd,CAAC;AAED,SAAS,YAAY,CAAC,KAAyB;IAC9C,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,OAAO,UAAU,KAAK,GAAG,IAAI,UAAU,KAAK,MAAM,IAAI,UAAU,KAAK,KAAK,IAAI,UAAU,KAAK,IAAI,CAAC;AACnG,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,13 @@ import { HttpRuntimeAdapter } from "./adapters/HttpRuntimeAdapter";
|
|
|
13
13
|
import { NodeJsRuntimeAdapter } from "./adapters/NodeJsRuntimeAdapter";
|
|
14
14
|
import type { ExecutionResult, RuntimeAdapter, RuntimeKind } from "./adapters/RuntimeAdapter";
|
|
15
15
|
import { WasmRuntimeAdapter } from "./adapters/WasmRuntimeAdapter";
|
|
16
|
+
import { DEFAULT_HEALTH_SERVICE_CONFIG, buildChannelOptions } from "./adapters/grpc/GrpcChannelOptions";
|
|
17
|
+
import { GrpcClientPool, buildCredentials } from "./adapters/grpc/GrpcClientPool";
|
|
18
|
+
import { NodeRuntimeService, bufferToJson, decodeExecuteResponse, encodeExecuteRequest, jsonToBuffer } from "./adapters/grpc/GrpcCodec";
|
|
19
|
+
import { GRPC_STATUS_MAP, categoryToGrpcStatus, toBlokError as grpcToBlokError, isServiceError } from "./adapters/grpc/GrpcErrors";
|
|
20
|
+
import { GrpcRuntimeAdapter } from "./adapters/grpc/GrpcRuntimeAdapter";
|
|
21
|
+
import { DEFAULT_GRPC_PORTS, GRPC_DEFAULTS } from "./adapters/grpc/types";
|
|
22
|
+
import { resolveTransportForKind } from "./adapters/transport";
|
|
16
23
|
import { type FnNodeDefinition, FunctionNode, defineNode } from "./defineNode";
|
|
17
24
|
import { CircuitBreaker, CircuitOpenError } from "./monitoring/CircuitBreaker";
|
|
18
25
|
import { HealthCheck } from "./monitoring/HealthCheck";
|
|
@@ -70,9 +77,12 @@ import Trigger from "./types/Trigger";
|
|
|
70
77
|
import TriggerHttp from "./types/TriggerHttp";
|
|
71
78
|
import TriggerResponse from "./types/TriggerResponse";
|
|
72
79
|
import Triggers from "./types/Triggers";
|
|
73
|
-
export { Configuration, Runner, ConfigurationResolver, DefaultLogger, LocalStorage, ResolverBase, TriggerBase, RuntimeRegistry, RuntimeAdapterNode, NodeJsRuntimeAdapter, DockerRuntimeAdapter, HttpRuntimeAdapter, BunRuntimeAdapter, WasmRuntimeAdapter, defineNode, FunctionNode, HealthCheck, RateLimiter, CircuitBreaker, CircuitOpenError, TriggerMetricsCollector, PrometheusMetricsBridge, bootstrapPrometheus, resetPrometheusBootstrap, RuntimeCatalog, RuntimeDiscovery, RuntimeHealthMonitor, RuntimeMetricsDashboard, RuntimeAutoScaler, FileWatcher, HotReloadManager, HmrDevConsole, AuthMiddleware, JWTAuthProvider, APIKeyAuthProvider, RBAC, createDefaultRBAC, ABACEngine, createDefaultABAC, AuditLogger, ConsoleAuditSink, FileAuditSink, InMemoryAuditSink, OAuthOIDCProvider, TokenCache, SecretManager, EnvironmentSecretProvider, InMemorySecretProvider, VaultSecretProvider, AWSSecretsProvider, GCPSecretProvider, OpenAPIGenerator, GraphQLSchemaGenerator, WorkflowVisualizer, NodeDependencyGraph, PerformanceProfiler, RunTracker, registerTraceRoutes, TracingLogger, traceSanitize, CostEstimator, PRICING, DEFAULT_DURATIONS, DEFAULT_MEMORY, getRuntimeCategory, SentryIntegration, InMemoryCache, NodeResultCache, NodeTestHarness, WorkflowTestRunner, TestLogger, Condition, Conditions, Config, Flow, Inputs, Node, Properties, Targets, Trigger, TriggerHttp, Triggers, ParamsDictionary, GlobalOptions, NodeMap, JsonLikeObject, BlokService, BlokResponse, IBlokResponse, RunnerSteps, Average, TriggerResponse, };
|
|
80
|
+
export { Configuration, Runner, ConfigurationResolver, DefaultLogger, LocalStorage, ResolverBase, TriggerBase, RuntimeRegistry, RuntimeAdapterNode, NodeJsRuntimeAdapter, DockerRuntimeAdapter, HttpRuntimeAdapter, BunRuntimeAdapter, WasmRuntimeAdapter, GrpcRuntimeAdapter, GrpcClientPool, buildCredentials, buildChannelOptions, NodeRuntimeService, encodeExecuteRequest, decodeExecuteResponse, jsonToBuffer, bufferToJson, GRPC_STATUS_MAP, GRPC_DEFAULTS, DEFAULT_GRPC_PORTS, DEFAULT_HEALTH_SERVICE_CONFIG, categoryToGrpcStatus, isServiceError, grpcToBlokError, resolveTransportForKind, defineNode, FunctionNode, HealthCheck, RateLimiter, CircuitBreaker, CircuitOpenError, TriggerMetricsCollector, PrometheusMetricsBridge, bootstrapPrometheus, resetPrometheusBootstrap, RuntimeCatalog, RuntimeDiscovery, RuntimeHealthMonitor, RuntimeMetricsDashboard, RuntimeAutoScaler, FileWatcher, HotReloadManager, HmrDevConsole, AuthMiddleware, JWTAuthProvider, APIKeyAuthProvider, RBAC, createDefaultRBAC, ABACEngine, createDefaultABAC, AuditLogger, ConsoleAuditSink, FileAuditSink, InMemoryAuditSink, OAuthOIDCProvider, TokenCache, SecretManager, EnvironmentSecretProvider, InMemorySecretProvider, VaultSecretProvider, AWSSecretsProvider, GCPSecretProvider, OpenAPIGenerator, GraphQLSchemaGenerator, WorkflowVisualizer, NodeDependencyGraph, PerformanceProfiler, RunTracker, registerTraceRoutes, TracingLogger, traceSanitize, CostEstimator, PRICING, DEFAULT_DURATIONS, DEFAULT_MEMORY, getRuntimeCategory, SentryIntegration, InMemoryCache, NodeResultCache, NodeTestHarness, WorkflowTestRunner, TestLogger, Condition, Conditions, Config, Flow, Inputs, Node, Properties, Targets, Trigger, TriggerHttp, Triggers, ParamsDictionary, GlobalOptions, NodeMap, JsonLikeObject, BlokService, BlokResponse, IBlokResponse, RunnerSteps, Average, TriggerResponse, };
|
|
74
81
|
export type { RuntimeAdapter, RuntimeKind, ExecutionResult, FnNodeDefinition };
|
|
75
82
|
export type { HttpRuntimeAdapterOptions } from "./adapters/HttpRuntimeAdapter";
|
|
83
|
+
export type { GrpcAdapterConfig, KeepaliveConfig, TlsConfig, Transport, } from "./adapters/grpc/types";
|
|
84
|
+
export type { DecodedExecuteResponse, DecodedLogLine, DecodedMetrics, DecodedNodeError, ExecuteRequestProto, ExecuteResponseProto, LogLineProto, MetricsProto, NodeErrorProto, NodeRefProto, RuntimeStateProto, StepInfoProto, TriggerInfoProto, WorkflowInfoProto, ExecuteOptionsProto, } from "./adapters/grpc/GrpcCodec";
|
|
85
|
+
export type { GrpcErrorContext } from "./adapters/grpc/GrpcErrors";
|
|
76
86
|
export type { HealthStatus, HealthCheckResult, DependencyHealth, DependencyCheckFn, } from "./monitoring/HealthCheck";
|
|
77
87
|
export type { RateLimitConfig, RateLimitResult } from "./monitoring/RateLimiter";
|
|
78
88
|
export type { CircuitState, CircuitBreakerConfig, CircuitBreakerStats, CircuitBreakerEvent, CircuitBreakerEventType, CircuitBreakerListener, } from "./monitoring/CircuitBreaker";
|
|
@@ -105,3 +115,5 @@ export type { LogEntry } from "./testing/TestLogger";
|
|
|
105
115
|
export type { TestContextOverrides, TestResult, TestMetrics } from "./testing/TestHarness";
|
|
106
116
|
export type { WorkflowTestConfig, WorkflowTestResult, ExecutionTrace, WorkflowExecuteOptions, } from "./testing/WorkflowTestRunner";
|
|
107
117
|
export type { WorkflowRun, WorkflowRunStatus, NodeRun, NodeRunStatus, RunEvent, RunEventType, TraceLogEntry, WorkflowSummary as TraceWorkflowSummary, WorkflowDetail as TraceWorkflowDetail, PaginatedResult, StartRunOptions, StartNodeOptions, } from "./tracing/types";
|
|
118
|
+
export { createStore, InMemoryRunStore, SqliteRunStore } from "./tracing";
|
|
119
|
+
export type { CreateStoreOptions, StoreType } from "./tracing";
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,13 @@ import { DockerRuntimeAdapter } from "./adapters/DockerRuntimeAdapter";
|
|
|
13
13
|
import { HttpRuntimeAdapter } from "./adapters/HttpRuntimeAdapter";
|
|
14
14
|
import { NodeJsRuntimeAdapter } from "./adapters/NodeJsRuntimeAdapter";
|
|
15
15
|
import { WasmRuntimeAdapter } from "./adapters/WasmRuntimeAdapter";
|
|
16
|
+
import { DEFAULT_HEALTH_SERVICE_CONFIG, buildChannelOptions } from "./adapters/grpc/GrpcChannelOptions";
|
|
17
|
+
import { GrpcClientPool, buildCredentials } from "./adapters/grpc/GrpcClientPool";
|
|
18
|
+
import { NodeRuntimeService, bufferToJson, decodeExecuteResponse, encodeExecuteRequest, jsonToBuffer, } from "./adapters/grpc/GrpcCodec";
|
|
19
|
+
import { GRPC_STATUS_MAP, categoryToGrpcStatus, toBlokError as grpcToBlokError, isServiceError, } from "./adapters/grpc/GrpcErrors";
|
|
20
|
+
import { GrpcRuntimeAdapter } from "./adapters/grpc/GrpcRuntimeAdapter";
|
|
21
|
+
import { DEFAULT_GRPC_PORTS, GRPC_DEFAULTS } from "./adapters/grpc/types";
|
|
22
|
+
import { resolveTransportForKind } from "./adapters/transport";
|
|
16
23
|
// Function-first node API
|
|
17
24
|
import { FunctionNode, defineNode } from "./defineNode";
|
|
18
25
|
import { CircuitBreaker, CircuitOpenError } from "./monitoring/CircuitBreaker";
|
|
@@ -72,6 +79,8 @@ import RunnerSteps from "./RunnerSteps";
|
|
|
72
79
|
export { Configuration, Runner, ConfigurationResolver, DefaultLogger, LocalStorage, ResolverBase, TriggerBase,
|
|
73
80
|
// Runtime adapters
|
|
74
81
|
RuntimeRegistry, RuntimeAdapterNode, NodeJsRuntimeAdapter, DockerRuntimeAdapter, HttpRuntimeAdapter, BunRuntimeAdapter, WasmRuntimeAdapter,
|
|
82
|
+
// gRPC runtime adapter
|
|
83
|
+
GrpcRuntimeAdapter, GrpcClientPool, buildCredentials, buildChannelOptions, NodeRuntimeService, encodeExecuteRequest, decodeExecuteResponse, jsonToBuffer, bufferToJson, GRPC_STATUS_MAP, GRPC_DEFAULTS, DEFAULT_GRPC_PORTS, DEFAULT_HEALTH_SERVICE_CONFIG, categoryToGrpcStatus, isServiceError, grpcToBlokError, resolveTransportForKind,
|
|
75
84
|
// Function-first API
|
|
76
85
|
defineNode, FunctionNode,
|
|
77
86
|
// Monitoring
|
|
@@ -104,4 +113,9 @@ SentryIntegration,
|
|
|
104
113
|
InMemoryCache, NodeResultCache,
|
|
105
114
|
// Testing
|
|
106
115
|
NodeTestHarness, WorkflowTestRunner, TestLogger, NodeMap, BlokService, BlokResponse, RunnerSteps, };
|
|
116
|
+
// Tracing store factory + concrete stores — exposed so the CLI's
|
|
117
|
+
// standalone `blokctl studio` mode can spin up its own SQLite-backed
|
|
118
|
+
// tracker without proxying to a live trigger. See
|
|
119
|
+
// `packages/cli/src/commands/trace/startStudio.ts` for the call site.
|
|
120
|
+
export { createStore, InMemoryRunStore, SqliteRunStore } from "./tracing";
|
|
107
121
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,mBAAmB;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,mBAAmB;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OA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@@ import { TestLogger } from "./TestLogger";
|
|
|
4
4
|
/**
|
|
5
5
|
* A mock node implementation wrapping a user-provided handler function.
|
|
6
6
|
*/
|
|
7
|
+
// biome-ignore lint/suspicious/noExplicitAny: mock node needs generic any for test flexibility
|
|
7
8
|
class MockNode extends BlokService {
|
|
9
|
+
// biome-ignore lint/suspicious/noExplicitAny: mock handler accepts arbitrary inputs/outputs
|
|
8
10
|
handler;
|
|
11
|
+
// biome-ignore lint/suspicious/noExplicitAny: mock handler accepts arbitrary inputs/outputs
|
|
9
12
|
constructor(name, handler) {
|
|
10
13
|
super();
|
|
11
14
|
this.name = name;
|
|
12
15
|
this.handler = handler;
|
|
13
16
|
}
|
|
17
|
+
// biome-ignore lint/suspicious/noExplicitAny: matches BlokService.handle signature
|
|
14
18
|
async handle(ctx, inputs) {
|
|
15
19
|
const response = new BlokResponse();
|
|
16
20
|
try {
|
|
@@ -73,9 +77,11 @@ class AutoMockNode extends MockNode {
|
|
|
73
77
|
*/
|
|
74
78
|
export class WorkflowTestRunner {
|
|
75
79
|
config;
|
|
80
|
+
// biome-ignore lint/suspicious/noExplicitAny: node registry holds heterogeneous node types
|
|
76
81
|
nodes;
|
|
77
82
|
workflow;
|
|
78
83
|
trace;
|
|
84
|
+
// biome-ignore lint/suspicious/noExplicitAny: test results hold arbitrary data
|
|
79
85
|
nodeResults;
|
|
80
86
|
constructor(config) {
|
|
81
87
|
this.config = {
|
|
@@ -94,8 +100,10 @@ export class WorkflowTestRunner {
|
|
|
94
100
|
* @param name - The node name as referenced in the workflow steps
|
|
95
101
|
* @param node - A BlokService instance or a FunctionNode from defineNode()
|
|
96
102
|
*/
|
|
103
|
+
// biome-ignore lint/suspicious/noExplicitAny: accepts heterogeneous node types for test flexibility
|
|
97
104
|
registerNode(name, node) {
|
|
98
105
|
node.name = name;
|
|
106
|
+
// biome-ignore lint/suspicious/noExplicitAny: cast required for heterogeneous node storage
|
|
99
107
|
this.nodes.set(name, node);
|
|
100
108
|
if (this.config.verbose) {
|
|
101
109
|
console.log(`[WorkflowTestRunner] Registered node: ${name}`);
|
|
@@ -110,6 +118,7 @@ export class WorkflowTestRunner {
|
|
|
110
118
|
* @param name - The node name as referenced in the workflow steps
|
|
111
119
|
* @param handler - Async function that receives (input, ctx) and returns output
|
|
112
120
|
*/
|
|
121
|
+
// biome-ignore lint/suspicious/noExplicitAny: mock handler accepts arbitrary inputs/outputs
|
|
113
122
|
mockNode(name, handler) {
|
|
114
123
|
const mockNodeInstance = new MockNode(name, handler);
|
|
115
124
|
this.nodes.set(name, mockNodeInstance);
|
|
@@ -154,6 +163,7 @@ export class WorkflowTestRunner {
|
|
|
154
163
|
* @returns WorkflowTestResult with output, trace, and per-node results
|
|
155
164
|
* @throws Error if no workflow is loaded or if a required node is not registered
|
|
156
165
|
*/
|
|
166
|
+
// biome-ignore lint/suspicious/noExplicitAny: test utility accepts arbitrary input data
|
|
157
167
|
async execute(input, options) {
|
|
158
168
|
if (!this.workflow) {
|
|
159
169
|
throw new Error("No workflow loaded. Call loadWorkflow() first.");
|
|
@@ -189,6 +199,7 @@ export class WorkflowTestRunner {
|
|
|
189
199
|
_PRIVATE_: {},
|
|
190
200
|
};
|
|
191
201
|
let workflowSuccess = true;
|
|
202
|
+
// biome-ignore lint/suspicious/noExplicitAny: error can be any type
|
|
192
203
|
let workflowError = null;
|
|
193
204
|
// Create a timeout promise
|
|
194
205
|
const timeoutPromise = new Promise((_, reject) => {
|
|
@@ -312,6 +323,7 @@ export class WorkflowTestRunner {
|
|
|
312
323
|
if (step.set_var) {
|
|
313
324
|
if (!ctx.vars)
|
|
314
325
|
ctx.vars = {};
|
|
326
|
+
// biome-ignore lint/suspicious/noExplicitAny: vars hold arbitrary workflow data
|
|
315
327
|
ctx.vars[step.name] = response.data;
|
|
316
328
|
}
|
|
317
329
|
traceEntry.success = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkflowTestRunner.js","sourceRoot":"","sources":["../../src/testing/WorkflowTestR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AAU,CAAC,CAAC;YAC5B,MAAM,KAAK,CAAC;QACb,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAE5B,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO,CAAC,GAAG,CACV,6BAA6B,SAAS,MAAM,IAAI,CAAC,IAAI,kBAAkB,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAC3G,CAAC;QACH,CAAC;IACF,CAAC;CACD"}
|
|
@@ -28,11 +28,32 @@ export declare class RunTracker extends EventEmitter {
|
|
|
28
28
|
get active(): boolean;
|
|
29
29
|
startRun(opts: StartRunOptions): WorkflowRun;
|
|
30
30
|
completeRun(runId: string, data?: unknown): void;
|
|
31
|
-
failRun(runId: string, error: Error): void;
|
|
31
|
+
failRun(runId: string, error: Error | unknown): void;
|
|
32
32
|
startNode(runId: string, opts: StartNodeOptions): NodeRun;
|
|
33
33
|
completeNode(nodeRunId: string, outputs?: unknown, nodeMetrics?: NodeRun["metrics"]): void;
|
|
34
|
-
failNode(nodeRunId: string, error: Error): void;
|
|
34
|
+
failNode(nodeRunId: string, error: Error | unknown): void;
|
|
35
35
|
skipNode(runId: string, nodeName: string, stepIndex: number, reason?: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Record a streaming `Progress` frame for an in-flight node. Overwrites
|
|
38
|
+
* any previous progress (only the latest milestone is preserved on
|
|
39
|
+
* the {@link NodeRun} record). Emits a `NODE_PROGRESS` event so SSE
|
|
40
|
+
* subscribers (Studio) get the live update too.
|
|
41
|
+
*
|
|
42
|
+
* Master plan §17 Phase 5 follow-up — wires the proto `Progress`
|
|
43
|
+
* frame from `ExecuteStream` into the trace store + Studio.
|
|
44
|
+
*
|
|
45
|
+
* @param percent 0–100; values outside the range are clamped.
|
|
46
|
+
* @param phase optional free-form phase label (may be empty).
|
|
47
|
+
*/
|
|
48
|
+
recordProgress(nodeRunId: string, percent: number, phase: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Record a streaming `PartialResult` snapshot for an in-flight node.
|
|
51
|
+
* Overwrites any previous snapshot. Emits a `NODE_PARTIAL_RESULT`
|
|
52
|
+
* event for SSE subscribers.
|
|
53
|
+
*
|
|
54
|
+
* Master plan §17 Phase 5 follow-up.
|
|
55
|
+
*/
|
|
56
|
+
recordPartialResult(nodeRunId: string, snapshot: unknown): void;
|
|
36
57
|
addLog(entry: Omit<TraceLogEntry, "id" | "timestamp">): void;
|
|
37
58
|
trackVarsUpdate(runId: string, nodeName: string, nodeId: string | undefined, vars: Record<string, unknown>): void;
|
|
38
59
|
getRun(runId: string): WorkflowRun | undefined;
|
|
@@ -5,6 +5,61 @@ import https from "node:https";
|
|
|
5
5
|
import { v4 as uuid } from "uuid";
|
|
6
6
|
import { InMemoryRunStore } from "./InMemoryRunStore";
|
|
7
7
|
import { createStore } from "./createStore";
|
|
8
|
+
/**
|
|
9
|
+
* Build a {@link RunErrorDetail} from any thrown error. When the source is
|
|
10
|
+
* a typed `BlokError` (master plan §17), all 17+ structured fields are
|
|
11
|
+
* preserved; otherwise the legacy `{message, stack}` shape falls through.
|
|
12
|
+
*
|
|
13
|
+
* Detection is duck-typed against the `category` field (BlokError carries
|
|
14
|
+
* a `category` enum value like `"DEPENDENCY"`; vanilla `Error` never
|
|
15
|
+
* does). This avoids a hard import dependency from the tracing layer
|
|
16
|
+
* onto `@blokjs/shared`.
|
|
17
|
+
*/
|
|
18
|
+
function toRunErrorDetail(error) {
|
|
19
|
+
if (error === null || error === undefined) {
|
|
20
|
+
return { message: "unknown error" };
|
|
21
|
+
}
|
|
22
|
+
if (typeof error !== "object") {
|
|
23
|
+
return { message: String(error) };
|
|
24
|
+
}
|
|
25
|
+
const e = error;
|
|
26
|
+
const detail = {
|
|
27
|
+
message: typeof e.message === "string" ? e.message : "unknown error",
|
|
28
|
+
};
|
|
29
|
+
if (typeof e.stack === "string")
|
|
30
|
+
detail.stack = e.stack;
|
|
31
|
+
// Structured BlokError fields. We accept either runner-side
|
|
32
|
+
// (`errorCode` getter on BlokError) or raw NodeErrorPayload (`code`)
|
|
33
|
+
// shapes — failNode is called with the BlokError instance, but the
|
|
34
|
+
// payload variant covers RunStore re-hydration paths.
|
|
35
|
+
const code = e.errorCode ?? e.code;
|
|
36
|
+
if (typeof code === "string" && code.length > 0)
|
|
37
|
+
detail.code = code;
|
|
38
|
+
if (typeof e.category === "string")
|
|
39
|
+
detail.category = e.category;
|
|
40
|
+
if (typeof e.severity === "string")
|
|
41
|
+
detail.severity = e.severity;
|
|
42
|
+
if (typeof e.httpStatus === "number")
|
|
43
|
+
detail.httpStatus = e.httpStatus;
|
|
44
|
+
if (typeof e.retryable === "boolean")
|
|
45
|
+
detail.retryable = e.retryable;
|
|
46
|
+
if (typeof e.retryAfterMs === "number")
|
|
47
|
+
detail.retryAfterMs = e.retryAfterMs;
|
|
48
|
+
if (typeof e.description === "string" && e.description.length > 0)
|
|
49
|
+
detail.description = e.description;
|
|
50
|
+
if (typeof e.remediation === "string" && e.remediation.length > 0)
|
|
51
|
+
detail.remediation = e.remediation;
|
|
52
|
+
if (typeof e.docUrl === "string" && e.docUrl.length > 0)
|
|
53
|
+
detail.docUrl = e.docUrl;
|
|
54
|
+
if (e.details !== undefined && e.details !== null)
|
|
55
|
+
detail.details = e.details;
|
|
56
|
+
if (e.contextSnapshot !== undefined && e.contextSnapshot !== null)
|
|
57
|
+
detail.contextSnapshot = e.contextSnapshot;
|
|
58
|
+
if (Array.isArray(e.causes) && e.causes.length > 0) {
|
|
59
|
+
detail.causes = e.causes.filter((c) => typeof c === "object" && c !== null);
|
|
60
|
+
}
|
|
61
|
+
return detail;
|
|
62
|
+
}
|
|
8
63
|
export class RunTracker extends EventEmitter {
|
|
9
64
|
store;
|
|
10
65
|
maxRuns;
|
|
@@ -41,6 +96,12 @@ export class RunTracker extends EventEmitter {
|
|
|
41
96
|
}
|
|
42
97
|
// === Workflow Lifecycle ===
|
|
43
98
|
startRun(opts) {
|
|
99
|
+
// Phase 2.1 · environment scoping. Read `BLOK_ENV` (default
|
|
100
|
+
// `production`) so every run carries the env it was triggered
|
|
101
|
+
// against. Studio's EnvChip (`useEnvScope.current`) filters
|
|
102
|
+
// list views by this field. Old runs without the field still
|
|
103
|
+
// match `production` via the post-filter default.
|
|
104
|
+
const environment = (process.env.BLOK_ENV || "production").trim() || "production";
|
|
44
105
|
const run = {
|
|
45
106
|
id: `run_${uuid().replace(/-/g, "").slice(0, 12)}`,
|
|
46
107
|
workflowName: opts.workflowName,
|
|
@@ -53,6 +114,7 @@ export class RunTracker extends EventEmitter {
|
|
|
53
114
|
completedNodes: 0,
|
|
54
115
|
tags: opts.tags,
|
|
55
116
|
metadata: opts.metadata,
|
|
117
|
+
environment,
|
|
56
118
|
};
|
|
57
119
|
this.store.saveRun(run);
|
|
58
120
|
this.emitEvent(run.id, run.workflowName, "RUN_STARTED", undefined, undefined, {
|
|
@@ -91,14 +153,11 @@ export class RunTracker extends EventEmitter {
|
|
|
91
153
|
status: "failed",
|
|
92
154
|
finishedAt,
|
|
93
155
|
durationMs,
|
|
94
|
-
error:
|
|
95
|
-
message: error.message,
|
|
96
|
-
stack: error.stack,
|
|
97
|
-
},
|
|
156
|
+
error: toRunErrorDetail(error),
|
|
98
157
|
});
|
|
99
158
|
this.emitEvent(runId, run.workflowName, "RUN_FAILED", undefined, undefined, {
|
|
100
159
|
durationMs,
|
|
101
|
-
error:
|
|
160
|
+
error: toRunErrorDetail(error),
|
|
102
161
|
});
|
|
103
162
|
}
|
|
104
163
|
// === Node Lifecycle ===
|
|
@@ -156,19 +215,17 @@ export class RunTracker extends EventEmitter {
|
|
|
156
215
|
return;
|
|
157
216
|
const finishedAt = Date.now();
|
|
158
217
|
const durationMs = finishedAt - nodeRun.startedAt;
|
|
218
|
+
const errorDetail = toRunErrorDetail(error);
|
|
159
219
|
this.store.updateNodeRun(nodeRunId, {
|
|
160
220
|
status: "failed",
|
|
161
221
|
finishedAt,
|
|
162
222
|
durationMs,
|
|
163
|
-
error:
|
|
164
|
-
message: error.message,
|
|
165
|
-
stack: error.stack,
|
|
166
|
-
},
|
|
223
|
+
error: errorDetail,
|
|
167
224
|
});
|
|
168
225
|
const run = this.store.getRun(nodeRun.runId);
|
|
169
226
|
this.emitEvent(nodeRun.runId, run?.workflowName || "", "NODE_FAILED", nodeRun.nodeName, nodeRunId, {
|
|
170
227
|
durationMs,
|
|
171
|
-
error:
|
|
228
|
+
error: errorDetail,
|
|
172
229
|
});
|
|
173
230
|
}
|
|
174
231
|
skipNode(runId, nodeName, stepIndex, reason) {
|
|
@@ -178,6 +235,59 @@ export class RunTracker extends EventEmitter {
|
|
|
178
235
|
stepIndex,
|
|
179
236
|
});
|
|
180
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Record a streaming `Progress` frame for an in-flight node. Overwrites
|
|
240
|
+
* any previous progress (only the latest milestone is preserved on
|
|
241
|
+
* the {@link NodeRun} record). Emits a `NODE_PROGRESS` event so SSE
|
|
242
|
+
* subscribers (Studio) get the live update too.
|
|
243
|
+
*
|
|
244
|
+
* Master plan §17 Phase 5 follow-up — wires the proto `Progress`
|
|
245
|
+
* frame from `ExecuteStream` into the trace store + Studio.
|
|
246
|
+
*
|
|
247
|
+
* @param percent 0–100; values outside the range are clamped.
|
|
248
|
+
* @param phase optional free-form phase label (may be empty).
|
|
249
|
+
*/
|
|
250
|
+
recordProgress(nodeRunId, percent, phase) {
|
|
251
|
+
const nodeRun = this.store.getNodeRun(nodeRunId);
|
|
252
|
+
if (!nodeRun)
|
|
253
|
+
return;
|
|
254
|
+
const clamped = Math.max(0, Math.min(100, Math.round(percent)));
|
|
255
|
+
const updatedAt = Date.now();
|
|
256
|
+
this.store.updateNodeRun(nodeRunId, {
|
|
257
|
+
progress: {
|
|
258
|
+
percent: clamped,
|
|
259
|
+
phase: phase ?? "",
|
|
260
|
+
updatedAt,
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
const run = this.store.getRun(nodeRun.runId);
|
|
264
|
+
this.emitEvent(nodeRun.runId, run?.workflowName || "", "NODE_PROGRESS", nodeRun.nodeName, nodeRunId, {
|
|
265
|
+
percent: clamped,
|
|
266
|
+
phase: phase ?? "",
|
|
267
|
+
updatedAt,
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Record a streaming `PartialResult` snapshot for an in-flight node.
|
|
272
|
+
* Overwrites any previous snapshot. Emits a `NODE_PARTIAL_RESULT`
|
|
273
|
+
* event for SSE subscribers.
|
|
274
|
+
*
|
|
275
|
+
* Master plan §17 Phase 5 follow-up.
|
|
276
|
+
*/
|
|
277
|
+
recordPartialResult(nodeRunId, snapshot) {
|
|
278
|
+
const nodeRun = this.store.getNodeRun(nodeRunId);
|
|
279
|
+
if (!nodeRun)
|
|
280
|
+
return;
|
|
281
|
+
const updatedAt = Date.now();
|
|
282
|
+
this.store.updateNodeRun(nodeRunId, {
|
|
283
|
+
partialResult: { snapshot, updatedAt },
|
|
284
|
+
});
|
|
285
|
+
const run = this.store.getRun(nodeRun.runId);
|
|
286
|
+
this.emitEvent(nodeRun.runId, run?.workflowName || "", "NODE_PARTIAL_RESULT", nodeRun.nodeName, nodeRunId, {
|
|
287
|
+
snapshot,
|
|
288
|
+
updatedAt,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
181
291
|
// === Logging ===
|
|
182
292
|
addLog(entry) {
|
|
183
293
|
const log = {
|