@blokjs/runner 0.2.1 → 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 +8 -5
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
import { BlokError, ErrorCategory, ErrorSeverity } from "@blokjs/shared";
|
|
2
|
+
import { Metadata } from "@grpc/grpc-js";
|
|
3
|
+
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
4
|
+
import { GrpcClientPool } from "./GrpcClientPool";
|
|
5
|
+
import { decodeExecuteEvent, decodeExecuteResponse, encodeExecuteRequest, } from "./GrpcCodec";
|
|
6
|
+
import { toBlokError } from "./GrpcErrors";
|
|
7
|
+
import { GrpcHealthChecker } from "./GrpcHealthChecker";
|
|
8
|
+
import { GRPC_DEFAULTS } from "./types";
|
|
9
|
+
/**
|
|
10
|
+
* Runtime adapter that executes a node by calling
|
|
11
|
+
* `blok.runtime.v1.NodeRuntime/Execute` over gRPC.
|
|
12
|
+
*
|
|
13
|
+
* Sibling to {@link HttpRuntimeAdapter}. Implements the same
|
|
14
|
+
* {@link RuntimeAdapter} interface, so {@link Configuration} can swap between
|
|
15
|
+
* transports based on env without any caller change.
|
|
16
|
+
*
|
|
17
|
+
* Single Responsibility: orchestrate the unary `Execute` RPC.
|
|
18
|
+
*
|
|
19
|
+
* Encoding/decoding is delegated to {@link GrpcCodec}; error mapping to
|
|
20
|
+
* {@link GrpcErrors}; client lifetime to {@link GrpcClientPool}; channel
|
|
21
|
+
* options to {@link GrpcChannelOptions}.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const adapter = new GrpcRuntimeAdapter({
|
|
25
|
+
* kind: "python3",
|
|
26
|
+
* host: "localhost",
|
|
27
|
+
* port: 10007,
|
|
28
|
+
* defaultDeadlineMs: 30_000,
|
|
29
|
+
* maxMessageBytes: 16 * 1024 * 1024,
|
|
30
|
+
* keepalive: { timeMs: 10000, timeoutMs: 5000, permitWithoutCalls: true },
|
|
31
|
+
* });
|
|
32
|
+
* const result = await adapter.execute(node, ctx);
|
|
33
|
+
*/
|
|
34
|
+
export class GrpcRuntimeAdapter {
|
|
35
|
+
kind;
|
|
36
|
+
transport = "grpc";
|
|
37
|
+
config;
|
|
38
|
+
pool;
|
|
39
|
+
ownsPool;
|
|
40
|
+
healthChecker;
|
|
41
|
+
tracer;
|
|
42
|
+
constructor(config, pool) {
|
|
43
|
+
this.kind = config.kind;
|
|
44
|
+
this.config = config;
|
|
45
|
+
this.pool = pool ?? new GrpcClientPool();
|
|
46
|
+
this.ownsPool = pool === undefined;
|
|
47
|
+
this.healthChecker = this.buildHealthChecker();
|
|
48
|
+
// `@opentelemetry/api` returns a no-op tracer when no OTEL SDK is
|
|
49
|
+
// registered in the host process, so this is zero-cost when OTEL
|
|
50
|
+
// isn't in use. When the host has OTEL set up, RPC spans nest
|
|
51
|
+
// under whatever span is active when `execute()` is called
|
|
52
|
+
// (typically the workflow span from `TriggerBase`).
|
|
53
|
+
this.tracer = trace.getTracer("@blokjs/runner.grpc", "1.0.0");
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Lazily start the background health-check loop. Operators can disable
|
|
57
|
+
* the loop with `healthCheckIntervalMs: 0`. Tests typically construct
|
|
58
|
+
* adapters without starting the loop and use {@link checkHealth}
|
|
59
|
+
* directly.
|
|
60
|
+
*/
|
|
61
|
+
startHealthCheck() {
|
|
62
|
+
this.healthChecker?.start();
|
|
63
|
+
}
|
|
64
|
+
buildHealthChecker() {
|
|
65
|
+
const intervalMs = this.config.healthCheckIntervalMs ?? GRPC_DEFAULTS.HEALTH_INTERVAL_MS;
|
|
66
|
+
if (intervalMs <= 0)
|
|
67
|
+
return null;
|
|
68
|
+
const threshold = this.config.healthCheckFailureThreshold ?? GRPC_DEFAULTS.HEALTH_FAILURE_THRESHOLD;
|
|
69
|
+
return new GrpcHealthChecker(() => this.checkHealth(), {
|
|
70
|
+
intervalMs,
|
|
71
|
+
failureThreshold: threshold,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/** Build a typed `BlokError(category=DEPENDENCY)` for short-circuited calls. */
|
|
75
|
+
circuitOpenError(node) {
|
|
76
|
+
return BlokError.dependency({
|
|
77
|
+
code: "GRPC_RUNTIME_UNAVAILABLE",
|
|
78
|
+
message: `Runtime ${this.kind} unavailable — circuit breaker is open after consecutive Health failures`,
|
|
79
|
+
description: `The background health probe could not reach ${this.config.host}:${this.config.port} for the configured failure threshold. Calls fail fast until a probe succeeds.`,
|
|
80
|
+
remediation: "Check the SDK process is running and reachable, then wait for the next health probe to recover the circuit.",
|
|
81
|
+
retryable: true,
|
|
82
|
+
retryAfterMs: this.config.healthCheckIntervalMs ?? GRPC_DEFAULTS.HEALTH_INTERVAL_MS,
|
|
83
|
+
contextSnapshot: {
|
|
84
|
+
kind: this.kind,
|
|
85
|
+
host: this.config.host,
|
|
86
|
+
port: this.config.port,
|
|
87
|
+
node: node.name,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
async execute(node, ctx) {
|
|
92
|
+
const startTime = performance.now();
|
|
93
|
+
// Fail fast when the circuit breaker has tripped — avoids stacking up
|
|
94
|
+
// blocked calls on top of a known-unhealthy SDK.
|
|
95
|
+
if (this.healthChecker && !this.healthChecker.isAvailable()) {
|
|
96
|
+
return {
|
|
97
|
+
success: false,
|
|
98
|
+
data: null,
|
|
99
|
+
errors: this.circuitOpenError(node),
|
|
100
|
+
metrics: { duration_ms: performance.now() - startTime, request_bytes: 0 },
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const stepInfo = readStepInfo(ctx);
|
|
104
|
+
const deadlineMs = readPerCallDeadline(ctx) ?? this.config.defaultDeadlineMs;
|
|
105
|
+
const request = encodeExecuteRequest(node, ctx, stepInfo.index, stepInfo.total, stepInfo.depth, deadlineMs);
|
|
106
|
+
const requestBytes = approximateRequestBytes(request);
|
|
107
|
+
const client = this.pool.get(this.config);
|
|
108
|
+
// Span attributes follow the OTEL gRPC semantic conventions so traces
|
|
109
|
+
// from this adapter compose with general-purpose tooling out of the
|
|
110
|
+
// box. The span is a child of whatever is active in `context.active()`
|
|
111
|
+
// when `execute()` is called.
|
|
112
|
+
const span = this.tracer.startSpan(`grpc.${this.kind}.Execute`, {
|
|
113
|
+
attributes: {
|
|
114
|
+
"rpc.system": "grpc",
|
|
115
|
+
"rpc.service": "blok.runtime.v1.NodeRuntime",
|
|
116
|
+
"rpc.method": "Execute",
|
|
117
|
+
"net.peer.name": this.config.host,
|
|
118
|
+
"net.peer.port": this.config.port,
|
|
119
|
+
"blok.runtime.kind": this.kind,
|
|
120
|
+
"blok.node.name": node.name,
|
|
121
|
+
"blok.request.bytes": requestBytes,
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
try {
|
|
125
|
+
const response = await this.unaryExecute(client, request, deadlineMs);
|
|
126
|
+
const decoded = decodeExecuteResponse(response);
|
|
127
|
+
const result = this.toExecutionResult(decoded, requestBytes, performance.now() - startTime);
|
|
128
|
+
span.setAttribute("blok.response.bytes", result.metrics?.response_bytes ?? 0);
|
|
129
|
+
span.setStatus({ code: result.success ? SpanStatusCode.OK : SpanStatusCode.ERROR });
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
const blokError = toBlokError(err, this.errorContext(node));
|
|
134
|
+
span.recordException(blokError);
|
|
135
|
+
span.setStatus({ code: SpanStatusCode.ERROR, message: blokError.message });
|
|
136
|
+
return {
|
|
137
|
+
success: false,
|
|
138
|
+
data: null,
|
|
139
|
+
errors: blokError,
|
|
140
|
+
metrics: {
|
|
141
|
+
duration_ms: performance.now() - startTime,
|
|
142
|
+
request_bytes: requestBytes,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
span.end();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Open a server-streaming `ExecuteStream` call and return both an
|
|
152
|
+
* AsyncIterable of decoded events AND a promise that resolves to the
|
|
153
|
+
* final {@link ExecutionResult} once the stream completes.
|
|
154
|
+
*
|
|
155
|
+
* Phase 5 capability: SDKs may emit `NodeStarted`, `LogLine`, `Progress`,
|
|
156
|
+
* and `PartialResult` events while a node executes; the stream always
|
|
157
|
+
* terminates with a single `final` event carrying the same
|
|
158
|
+
* {@link ExecuteResponseProto} that unary `Execute` would return.
|
|
159
|
+
*
|
|
160
|
+
* SDKs that don't implement streaming respond with gRPC `UNIMPLEMENTED`;
|
|
161
|
+
* the returned promise rejects with a {@link BlokError} of category
|
|
162
|
+
* `INTERNAL` (mapped from `UNIMPLEMENTED`) and the iterable yields nothing.
|
|
163
|
+
*
|
|
164
|
+
* Callers should consume the iterable in parallel with awaiting the
|
|
165
|
+
* promise — events are pushed live, while the promise gives the typed
|
|
166
|
+
* result for the rest of the runner pipeline.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* const { events, result } = adapter.executeStream(node, ctx);
|
|
170
|
+
* for await (const ev of events) {
|
|
171
|
+
* if (ev.type === "log") tracker.appendLog(ev.log);
|
|
172
|
+
* }
|
|
173
|
+
* const final = await result;
|
|
174
|
+
*/
|
|
175
|
+
executeStream(node, ctx) {
|
|
176
|
+
const startTime = performance.now();
|
|
177
|
+
// Mirror the unary fast-fail path so streaming callers see the same
|
|
178
|
+
// circuit-breaker behavior. Returns an empty iterable + a pre-resolved
|
|
179
|
+
// failure result so consumers' `for await` and `await result` patterns
|
|
180
|
+
// both terminate immediately.
|
|
181
|
+
if (this.healthChecker && !this.healthChecker.isAvailable()) {
|
|
182
|
+
const blokError = this.circuitOpenError(node);
|
|
183
|
+
const empty = {
|
|
184
|
+
[Symbol.asyncIterator]: async function* () {
|
|
185
|
+
/* nothing to yield */
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
return {
|
|
189
|
+
events: empty,
|
|
190
|
+
result: Promise.resolve({
|
|
191
|
+
success: false,
|
|
192
|
+
data: null,
|
|
193
|
+
errors: blokError,
|
|
194
|
+
metrics: { duration_ms: performance.now() - startTime, request_bytes: 0 },
|
|
195
|
+
}),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
const stepInfo = readStepInfo(ctx);
|
|
199
|
+
const deadlineMs = readPerCallDeadline(ctx) ?? this.config.defaultDeadlineMs;
|
|
200
|
+
const request = encodeExecuteRequest(node, ctx, stepInfo.index, stepInfo.total, stepInfo.depth, deadlineMs);
|
|
201
|
+
// Opt the SDK into emitting log frames (proto ExecuteOptions.stream_logs).
|
|
202
|
+
request.options = { ...request.options, streamLogs: true };
|
|
203
|
+
const requestBytes = approximateRequestBytes(request);
|
|
204
|
+
const client = this.pool.get(this.config);
|
|
205
|
+
const call = this.openExecuteStream(client, request, deadlineMs);
|
|
206
|
+
// Streaming span lives for the lifetime of the call; ended in the
|
|
207
|
+
// same `settle()` path that resolves the result promise so timing
|
|
208
|
+
// captures the full server-streaming arc rather than just the first
|
|
209
|
+
// frame.
|
|
210
|
+
const span = this.tracer.startSpan(`grpc.${this.kind}.ExecuteStream`, {
|
|
211
|
+
attributes: {
|
|
212
|
+
"rpc.system": "grpc",
|
|
213
|
+
"rpc.service": "blok.runtime.v1.NodeRuntime",
|
|
214
|
+
"rpc.method": "ExecuteStream",
|
|
215
|
+
"net.peer.name": this.config.host,
|
|
216
|
+
"net.peer.port": this.config.port,
|
|
217
|
+
"blok.runtime.kind": this.kind,
|
|
218
|
+
"blok.node.name": node.name,
|
|
219
|
+
"blok.request.bytes": requestBytes,
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
let finalDecoded = null;
|
|
223
|
+
const errorContext = this.errorContext(node);
|
|
224
|
+
const failureResult = (err) => {
|
|
225
|
+
const blokError = err instanceof BlokError ? err : toBlokError(err, errorContext);
|
|
226
|
+
return {
|
|
227
|
+
success: false,
|
|
228
|
+
data: null,
|
|
229
|
+
errors: blokError,
|
|
230
|
+
metrics: {
|
|
231
|
+
duration_ms: performance.now() - startTime,
|
|
232
|
+
request_bytes: requestBytes,
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
const events = decodedEventsFromCall(call, (decoded) => {
|
|
237
|
+
if (decoded.type === "final")
|
|
238
|
+
finalDecoded = decoded.response;
|
|
239
|
+
});
|
|
240
|
+
const result = new Promise((resolve) => {
|
|
241
|
+
let settled = false;
|
|
242
|
+
const settle = (value) => {
|
|
243
|
+
if (settled)
|
|
244
|
+
return;
|
|
245
|
+
settled = true;
|
|
246
|
+
if (value.success) {
|
|
247
|
+
span.setAttribute("blok.response.bytes", value.metrics?.response_bytes ?? 0);
|
|
248
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
if (value.errors instanceof BlokError)
|
|
252
|
+
span.recordException(value.errors);
|
|
253
|
+
span.setStatus({
|
|
254
|
+
code: SpanStatusCode.ERROR,
|
|
255
|
+
message: value.errors instanceof Error ? value.errors.message : "stream failure",
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
span.end();
|
|
259
|
+
resolve(value);
|
|
260
|
+
};
|
|
261
|
+
call.on("error", (err) => settle(failureResult(err)));
|
|
262
|
+
call.on("end", () => {
|
|
263
|
+
if (finalDecoded) {
|
|
264
|
+
settle(this.toExecutionResult(finalDecoded, requestBytes, performance.now() - startTime));
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
settle(failureResult(new Error("ExecuteStream ended without a final frame")));
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
return { events, result };
|
|
272
|
+
}
|
|
273
|
+
openExecuteStream(client, request, deadlineMs) {
|
|
274
|
+
const metadata = new Metadata();
|
|
275
|
+
const deadline = new Date(Date.now() + deadlineMs);
|
|
276
|
+
const callable = client.ExecuteStream;
|
|
277
|
+
return callable.call(client, request, metadata, { deadline });
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Probe the SDK with `Health/Check`. Used by the health-check loop in
|
|
281
|
+
* `TriggerBase` and by the circuit breaker. Returns false on any failure
|
|
282
|
+
* (network, deadline, NOT_SERVING) — never throws.
|
|
283
|
+
*/
|
|
284
|
+
async checkHealth() {
|
|
285
|
+
const client = this.pool.get(this.config);
|
|
286
|
+
try {
|
|
287
|
+
const status = await this.unaryHealth(client);
|
|
288
|
+
return status === "SERVING";
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Close the underlying client pool and stop the health-check loop.
|
|
296
|
+
* Pool close is only effective when the pool is owned by this adapter.
|
|
297
|
+
*/
|
|
298
|
+
close() {
|
|
299
|
+
this.healthChecker?.stop();
|
|
300
|
+
if (this.ownsPool)
|
|
301
|
+
this.pool.close();
|
|
302
|
+
}
|
|
303
|
+
// =========================================================================
|
|
304
|
+
// Private RPC helpers
|
|
305
|
+
// =========================================================================
|
|
306
|
+
unaryExecute(client, request, deadlineMs) {
|
|
307
|
+
const metadata = new Metadata();
|
|
308
|
+
const deadline = new Date(Date.now() + deadlineMs);
|
|
309
|
+
return new Promise((resolve, reject) => {
|
|
310
|
+
const callable = client.Execute;
|
|
311
|
+
callable.call(client, request, metadata, { deadline }, (err, response) => {
|
|
312
|
+
if (err)
|
|
313
|
+
reject(err);
|
|
314
|
+
else
|
|
315
|
+
resolve(response);
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
unaryHealth(client) {
|
|
320
|
+
return new Promise((resolve, reject) => {
|
|
321
|
+
const callable = client.Health;
|
|
322
|
+
callable.call(client, { service: "blok.runtime.v1.NodeRuntime" }, (err, response) => {
|
|
323
|
+
if (err)
|
|
324
|
+
reject(err);
|
|
325
|
+
else
|
|
326
|
+
resolve(response.status);
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
// =========================================================================
|
|
331
|
+
// Private mappers
|
|
332
|
+
// =========================================================================
|
|
333
|
+
toExecutionResult(decoded, requestBytes, wallDurationMs) {
|
|
334
|
+
return {
|
|
335
|
+
success: decoded.success,
|
|
336
|
+
data: decoded.data,
|
|
337
|
+
errors: decoded.error
|
|
338
|
+
? // The decoded NodeError is rich; the adapter pipeline expects an
|
|
339
|
+
// `unknown | null` where instances of `GlobalError` are passed through.
|
|
340
|
+
// We don't construct a BlokError here because `toBlokError` is the
|
|
341
|
+
// authoritative entry point; payload-driven errors arrive via the
|
|
342
|
+
// gRPC `Status.details` path in `unaryExecute`'s catch branch. When
|
|
343
|
+
// an SDK returns success=false on the response body itself, we wrap
|
|
344
|
+
// the decoded payload as a structured error.
|
|
345
|
+
this.decodedErrorToBlokError(decoded.error)
|
|
346
|
+
: null,
|
|
347
|
+
logs: decoded.logs.map((l) => `[${l.level}] ${l.message}`),
|
|
348
|
+
metrics: {
|
|
349
|
+
duration_ms: decoded.metrics.durationMs > 0 ? decoded.metrics.durationMs : wallDurationMs,
|
|
350
|
+
cpu_ms: decoded.metrics.cpuMs,
|
|
351
|
+
memory_bytes: decoded.metrics.memoryBytes,
|
|
352
|
+
request_bytes: requestBytes,
|
|
353
|
+
response_bytes: decoded.metrics.responseBytes,
|
|
354
|
+
},
|
|
355
|
+
vars: decoded.varsDelta,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
decodedErrorToBlokError(decoded) {
|
|
359
|
+
return BlokError.fromJSON({
|
|
360
|
+
code: decoded.code,
|
|
361
|
+
category: coerceCategory(decoded.category),
|
|
362
|
+
severity: coerceSeverity(decoded.severity),
|
|
363
|
+
node: decoded.node,
|
|
364
|
+
sdk: decoded.sdk,
|
|
365
|
+
sdkVersion: decoded.sdkVersion,
|
|
366
|
+
runtimeKind: decoded.runtimeKind,
|
|
367
|
+
at: new Date(decoded.at).toISOString(),
|
|
368
|
+
message: decoded.message,
|
|
369
|
+
description: decoded.description,
|
|
370
|
+
remediation: decoded.remediation,
|
|
371
|
+
docUrl: decoded.docUrl,
|
|
372
|
+
causes: decoded.causes.map((c) => ({
|
|
373
|
+
code: c.code,
|
|
374
|
+
category: coerceCategory(c.category),
|
|
375
|
+
severity: coerceSeverity(c.severity),
|
|
376
|
+
node: c.node,
|
|
377
|
+
sdk: c.sdk,
|
|
378
|
+
sdkVersion: c.sdkVersion,
|
|
379
|
+
runtimeKind: c.runtimeKind,
|
|
380
|
+
at: new Date(c.at).toISOString(),
|
|
381
|
+
message: c.message,
|
|
382
|
+
description: c.description,
|
|
383
|
+
remediation: c.remediation,
|
|
384
|
+
docUrl: c.docUrl,
|
|
385
|
+
causes: [],
|
|
386
|
+
stack: c.stack,
|
|
387
|
+
contextSnapshot: c.contextSnapshot,
|
|
388
|
+
httpStatus: c.httpStatus,
|
|
389
|
+
retryable: c.retryable,
|
|
390
|
+
retryAfterMs: c.retryAfterMs,
|
|
391
|
+
details: c.details,
|
|
392
|
+
})),
|
|
393
|
+
stack: decoded.stack,
|
|
394
|
+
contextSnapshot: decoded.contextSnapshot,
|
|
395
|
+
httpStatus: decoded.httpStatus,
|
|
396
|
+
retryable: decoded.retryable,
|
|
397
|
+
retryAfterMs: decoded.retryAfterMs,
|
|
398
|
+
details: decoded.details,
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
errorContext(node) {
|
|
402
|
+
return {
|
|
403
|
+
node: node.name,
|
|
404
|
+
sdk: `blok-${this.kind}`,
|
|
405
|
+
sdkVersion: "",
|
|
406
|
+
runtimeKind: `runtime.${this.kind}`,
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Coerce an unvalidated string into a known {@link ErrorCategory}, falling
|
|
412
|
+
* back to `INTERNAL` when the SDK reports a value the runner doesn't know.
|
|
413
|
+
*/
|
|
414
|
+
function coerceCategory(raw) {
|
|
415
|
+
const known = Object.values(ErrorCategory);
|
|
416
|
+
return known.includes(raw) ? raw : ErrorCategory.INTERNAL;
|
|
417
|
+
}
|
|
418
|
+
/** Coerce an unvalidated string into a known {@link ErrorSeverity}, defaulting to ERROR. */
|
|
419
|
+
function coerceSeverity(raw) {
|
|
420
|
+
const known = Object.values(ErrorSeverity);
|
|
421
|
+
return known.includes(raw) ? raw : ErrorSeverity.ERROR;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Read step metadata from `ctx._stepInfo` if populated by `RunnerSteps`.
|
|
425
|
+
* Defaults to a single top-level step when absent — keeps the adapter usable
|
|
426
|
+
* standalone (e.g. in tests).
|
|
427
|
+
*/
|
|
428
|
+
function readStepInfo(ctx) {
|
|
429
|
+
const meta = ctx._stepInfo;
|
|
430
|
+
return {
|
|
431
|
+
index: meta?.index ?? 0,
|
|
432
|
+
total: meta?.total ?? 1,
|
|
433
|
+
depth: meta?.depth ?? 0,
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
/** Read per-call deadline override from `ctx._stepDeadlineMs` if present. */
|
|
437
|
+
function readPerCallDeadline(ctx) {
|
|
438
|
+
const value = ctx._stepDeadlineMs;
|
|
439
|
+
return typeof value === "number" && value > 0 ? value : undefined;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Wrap a `ClientReadableStream` of {@link ExecuteEventProto} as an
|
|
443
|
+
* AsyncIterable of decoded events. Empty oneof frames are silently skipped.
|
|
444
|
+
*
|
|
445
|
+
* Each decoded event is also handed to `tap` so the caller (the adapter) can
|
|
446
|
+
* snapshot terminal frames without needing to consume the iterable itself.
|
|
447
|
+
*
|
|
448
|
+
* Errors and stream end are NOT signalled through the iterable — callers
|
|
449
|
+
* await the companion `result` promise for the typed terminal value.
|
|
450
|
+
*/
|
|
451
|
+
async function* decodedEventsFromCall(call, tap) {
|
|
452
|
+
try {
|
|
453
|
+
for await (const raw of call) {
|
|
454
|
+
const decoded = decodeExecuteEvent(raw);
|
|
455
|
+
if (decoded === null)
|
|
456
|
+
continue;
|
|
457
|
+
tap(decoded);
|
|
458
|
+
yield decoded;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
catch {
|
|
462
|
+
// The companion `result` promise carries the typed error; this catch
|
|
463
|
+
// just terminates the iterable without bubbling up the raw gRPC error.
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Cheap approximation of the on-wire request size. Sums the byte-buffer
|
|
468
|
+
* fields plus a small constant for the typed envelope. Good enough for
|
|
469
|
+
* observability; real wire size is reported in `Metrics.request_bytes`
|
|
470
|
+
* (when the SDK populates it).
|
|
471
|
+
*/
|
|
472
|
+
function approximateRequestBytes(request) {
|
|
473
|
+
return (request.inputs.length +
|
|
474
|
+
request.state.previousOutput.length +
|
|
475
|
+
request.state.vars.length +
|
|
476
|
+
request.trigger.body.length);
|
|
477
|
+
}
|
|
478
|
+
//# sourceMappingURL=GrpcRuntimeAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GrpcRuntimeAdapter.js","sourceRoot":"","sources":["../../../src/adapters/grpc/GrpcRuntimeAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgB,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEvF,OAAO,EAAe,QAAQ,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,cAAc,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAGxE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAMN,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAyB,WAAW,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBA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,OAAO,CAAC,MAAM,CAAC,MAAM;QACrB,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM;QACnC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM;QACzB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAC3B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public exports for the gRPC runtime adapter.
|
|
3
|
+
*
|
|
4
|
+
* Consumers should import from `@blokjs/runner` (the package barrel)
|
|
5
|
+
* rather than reaching into this directory directly.
|
|
6
|
+
*/
|
|
7
|
+
export { GrpcRuntimeAdapter } from "./GrpcRuntimeAdapter";
|
|
8
|
+
export { GrpcClientPool, buildCredentials } from "./GrpcClientPool";
|
|
9
|
+
export { GrpcHealthChecker, type HealthCheckerOptions, type HealthProbe, } from "./GrpcHealthChecker";
|
|
10
|
+
export { GRPC_STATUS_MAP, type GrpcErrorContext, categoryToGrpcStatus, isServiceError, toBlokError, } from "./GrpcErrors";
|
|
11
|
+
export { NodeRuntimeService, bufferToJson, decodeExecuteEvent, decodeExecuteResponse, encodeExecuteRequest, jsonToBuffer, type DecodedExecuteEvent, type DecodedExecuteResponse, type DecodedLogLine, type DecodedMetrics, type DecodedNodeError, type ExecuteEventProto, type ExecuteRequestProto, type ExecuteResponseProto, type LogLineProto, type MetricsProto, type NodeErrorProto, type NodeRefProto, type RuntimeStateProto, type StepInfoProto, type TriggerInfoProto, type WorkflowInfoProto, type ExecuteOptionsProto, } from "./GrpcCodec";
|
|
12
|
+
export { buildChannelOptions, DEFAULT_HEALTH_SERVICE_CONFIG } from "./GrpcChannelOptions";
|
|
13
|
+
export { DEFAULT_GRPC_PORTS, GRPC_DEFAULTS, type GrpcAdapterConfig, type KeepaliveConfig, type TlsConfig, type Transport, } from "./types";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public exports for the gRPC runtime adapter.
|
|
3
|
+
*
|
|
4
|
+
* Consumers should import from `@blokjs/runner` (the package barrel)
|
|
5
|
+
* rather than reaching into this directory directly.
|
|
6
|
+
*/
|
|
7
|
+
export { GrpcRuntimeAdapter } from "./GrpcRuntimeAdapter";
|
|
8
|
+
export { GrpcClientPool, buildCredentials } from "./GrpcClientPool";
|
|
9
|
+
export { GrpcHealthChecker, } from "./GrpcHealthChecker";
|
|
10
|
+
export { GRPC_STATUS_MAP, categoryToGrpcStatus, isServiceError, toBlokError, } from "./GrpcErrors";
|
|
11
|
+
export { NodeRuntimeService, bufferToJson, decodeExecuteEvent, decodeExecuteResponse, encodeExecuteRequest, jsonToBuffer, } from "./GrpcCodec";
|
|
12
|
+
export { buildChannelOptions, DEFAULT_HEALTH_SERVICE_CONFIG } from "./GrpcChannelOptions";
|
|
13
|
+
export { DEFAULT_GRPC_PORTS, GRPC_DEFAULTS, } from "./types";
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/grpc/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EACN,iBAAiB,GAGjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,eAAe,EAEf,oBAAoB,EACpB,cAAc,EACd,WAAW,GACX,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,GAkBZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EACN,kBAAkB,EAClB,aAAa,GAKb,MAAM,SAAS,CAAC"}
|