@smithers-orchestrator/server 0.16.0

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/src/index.d.ts ADDED
@@ -0,0 +1,953 @@
1
+ import * as _smithers_db_adapter_RunRow from '@smithers-orchestrator/db/adapter/RunRow';
2
+ import * as node_http from 'node:http';
3
+ import { IncomingMessage as IncomingMessage$1, ServerResponse as ServerResponse$1 } from 'node:http';
4
+ import * as _smithers_observability_SmithersEvent from '@smithers-orchestrator/observability/SmithersEvent';
5
+ import * as _smithers_components_SmithersWorkflow from '@smithers-orchestrator/components/SmithersWorkflow';
6
+ import { SmithersWorkflow as SmithersWorkflow$1 } from '@smithers-orchestrator/components/SmithersWorkflow';
7
+ import { Effect } from 'effect';
8
+ import * as _smithers_db_adapter from '@smithers-orchestrator/db/adapter';
9
+ import { SmithersDb as SmithersDb$4 } from '@smithers-orchestrator/db/adapter';
10
+ import * as hono_types from 'hono/types';
11
+ import { Hono } from 'hono';
12
+ import * as effect_Fiber from 'effect/Fiber';
13
+ import * as _smithers_protocol_errors from '@smithers-orchestrator/protocol/errors';
14
+ import * as _smithers_devtools_snapshotSerializer from '@smithers-orchestrator/devtools/snapshotSerializer';
15
+ import * as _smithers_protocol_devtools from '@smithers-orchestrator/protocol/devtools';
16
+ import * as _smithers_engine_effect_DiffBundle from '@smithers-orchestrator/engine/effect/DiffBundle';
17
+ import { DiffBundle } from '@smithers-orchestrator/engine/effect/DiffBundle';
18
+ import { selectOutputRow } from '@smithers-orchestrator/db/output';
19
+ import * as _smithers_time_travel_jumpToFrame from '@smithers-orchestrator/time-travel/jumpToFrame';
20
+ export { JumpToFrameError } from '@smithers-orchestrator/time-travel/jumpToFrame';
21
+
22
+ type ServerOptions$1 = {
23
+ port?: number;
24
+ db?: unknown;
25
+ authToken?: string;
26
+ maxBodyBytes?: number;
27
+ rootDir?: string;
28
+ allowNetwork?: boolean;
29
+ };
30
+
31
+ type ResponseFrame$1 = {
32
+ type: "res";
33
+ id: string;
34
+ ok: boolean;
35
+ payload?: unknown;
36
+ error?: {
37
+ code: string;
38
+ message: string;
39
+ };
40
+ };
41
+
42
+ type RequestFrame$1 = {
43
+ type: "req";
44
+ id: string;
45
+ method: string;
46
+ params?: unknown;
47
+ };
48
+
49
+ type GatewayWebhookSignalConfig$1 = {
50
+ name: string;
51
+ correlationIdPath?: string;
52
+ runIdPath?: string;
53
+ payloadPath?: string;
54
+ };
55
+
56
+ type GatewayWebhookRunConfig$1 = {
57
+ enabled?: boolean;
58
+ inputPath?: string;
59
+ };
60
+
61
+ type GatewayWebhookConfig$1 = {
62
+ secret: string;
63
+ signatureHeader?: string;
64
+ signaturePrefix?: string;
65
+ signal?: GatewayWebhookSignalConfig$1;
66
+ run?: GatewayWebhookRunConfig$1;
67
+ };
68
+
69
+ type GatewayTokenGrant$1 = {
70
+ role: string;
71
+ scopes: string[];
72
+ userId?: string;
73
+ };
74
+
75
+ type GatewayAuthConfig$1 = {
76
+ mode: "token";
77
+ tokens: Record<string, GatewayTokenGrant$1>;
78
+ } | {
79
+ mode: "jwt";
80
+ issuer: string;
81
+ audience: string | string[];
82
+ secret: string;
83
+ scopesClaim?: string;
84
+ roleClaim?: string;
85
+ userClaim?: string;
86
+ defaultRole?: string;
87
+ defaultScopes?: string[];
88
+ clockSkewSeconds?: number;
89
+ } | {
90
+ mode: "trusted-proxy";
91
+ trustedHeaders?: string[];
92
+ allowedOrigins?: string[];
93
+ defaultRole?: string;
94
+ defaultScopes?: string[];
95
+ };
96
+
97
+ type GatewayDefaults$1 = {
98
+ cliAgentTools?: "all" | "explicit-only";
99
+ };
100
+
101
+ type GatewayOptions$1 = {
102
+ protocol?: number;
103
+ features?: string[];
104
+ heartbeatMs?: number;
105
+ auth?: GatewayAuthConfig$1;
106
+ defaults?: GatewayDefaults$1;
107
+ maxBodyBytes?: number;
108
+ maxPayload?: number;
109
+ maxConnections?: number;
110
+ };
111
+
112
+ type ConnectRequest$1 = {
113
+ minProtocol: number;
114
+ maxProtocol: number;
115
+ client: {
116
+ id: string;
117
+ version: string;
118
+ platform: string;
119
+ };
120
+ auth?: {
121
+ token: string;
122
+ } | {
123
+ password: string;
124
+ };
125
+ subscribe?: string[];
126
+ };
127
+
128
+ type HelloResponse$1 = {
129
+ protocol: number;
130
+ features: string[];
131
+ policy: {
132
+ heartbeatMs: number;
133
+ };
134
+ auth: {
135
+ sessionToken: string;
136
+ role: string;
137
+ scopes: string[];
138
+ userId: string | null;
139
+ };
140
+ snapshot: {
141
+ runs: unknown[];
142
+ approvals: unknown[];
143
+ stateVersion: number;
144
+ };
145
+ };
146
+
147
+ type EventFrame$1 = {
148
+ type: "event";
149
+ event: string;
150
+ payload?: unknown;
151
+ seq: number;
152
+ stateVersion: number;
153
+ };
154
+
155
+ /**
156
+ * @param {unknown} method
157
+ * @returns {string}
158
+ */
159
+ declare function validateGatewayMethodName(method: unknown): string;
160
+ /**
161
+ * @param {unknown} raw
162
+ * @returns {RequestFrame}
163
+ */
164
+ declare function parseGatewayRequestFrame(raw: unknown, maxPayloadBytes?: number): RequestFrame;
165
+ /**
166
+ * @param {unknown} value
167
+ * @returns {number}
168
+ */
169
+ declare function getGatewayInputDepth(value: unknown): number;
170
+ /**
171
+ * @param {unknown} value
172
+ * @returns {number}
173
+ */
174
+ declare function assertGatewayInputDepthWithinBounds(value: unknown, maxDepth?: number): number;
175
+ /**
176
+ * @param {string | undefined} code
177
+ */
178
+ declare function statusForRpcError(code: string | undefined): 401 | 403 | 404 | 400 | 409 | 413 | 429 | 501 | 500;
179
+ declare const GATEWAY_RPC_MAX_PAYLOAD_BYTES: 1048576;
180
+ declare const GATEWAY_RPC_MAX_DEPTH: 32;
181
+ declare const GATEWAY_RPC_MAX_ARRAY_LENGTH: 256;
182
+ declare const GATEWAY_RPC_MAX_STRING_LENGTH: number;
183
+ declare const GATEWAY_METHOD_NAME_MAX_LENGTH: 64;
184
+ declare const GATEWAY_FRAME_ID_MAX_LENGTH: 128;
185
+ declare const GATEWAY_RPC_INPUT_MAX_BYTES: 1048576;
186
+ declare const GATEWAY_RPC_INPUT_MAX_DEPTH: 32;
187
+ declare class Gateway {
188
+ /**
189
+ * @param {GatewayOptions} [options]
190
+ */
191
+ constructor(options?: GatewayOptions);
192
+ protocol: number;
193
+ features: string[];
194
+ heartbeatMs: number;
195
+ maxBodyBytes: number;
196
+ maxPayload: number;
197
+ maxConnections: number;
198
+ auth: GatewayAuthConfig$1 | undefined;
199
+ defaults: GatewayDefaults$1 | undefined;
200
+ workflows: Map<any, any>;
201
+ connections: Set<any>;
202
+ runRegistry: Map<any, any>;
203
+ activeRuns: Map<any, any>;
204
+ inflightRuns: Map<any, any>;
205
+ devtoolsSubscribers: Map<any, any>;
206
+ /** Absolute active subscriber count per runId (gauge source of truth). */
207
+ devtoolsSubscriberCounts: Map<any, any>;
208
+ /** Flagged subscriber IDs that should force a snapshot on their next emit. */
209
+ devtoolsInvalidateFlags: Set<any>;
210
+ server: null;
211
+ wsServer: null;
212
+ schedulerTimer: null;
213
+ stateVersion: number;
214
+ startedAtMs: number;
215
+ authModeLabel(): string;
216
+ /**
217
+ * @param {string} [runId]
218
+ * @returns {number}
219
+ */
220
+ getDevToolsSubscriberCount(runId?: string): number;
221
+ /**
222
+ * Record a single subscribe attempt outcome. Centralised so that invalid
223
+ * runId, missing run, SeqOutOfRange, etc. still update
224
+ * `smithers_devtools_subscribe_total{result="error"}`.
225
+ *
226
+ * @param {"ok" | "error"} result
227
+ */
228
+ recordDevToolsSubscribeAttempt(result: "ok" | "error"): void;
229
+ /**
230
+ * Push the absolute active-subscriber count to the Prometheus gauge. The
231
+ * `runId` is hashed for bounded cardinality.
232
+ *
233
+ * @param {string} runId
234
+ */
235
+ publishDevToolsActiveSubscribersGauge(runId: string): void;
236
+ /**
237
+ * @param {ConnectionState} connection
238
+ * @param {string} streamId
239
+ * @param {string} runId
240
+ * @returns {AbortController}
241
+ */
242
+ registerDevToolsSubscriber(connection: ConnectionState, streamId: string, runId: string): AbortController;
243
+ /**
244
+ * @param {ConnectionState} connection
245
+ * @param {string} streamId
246
+ * @param {Record<string, unknown>} [details]
247
+ */
248
+ unregisterDevToolsSubscriber(connection: ConnectionState, streamId: string, details?: Record<string, unknown>): void;
249
+ /**
250
+ * Flag every active subscriber for `runId` to rebaseline on its next emit.
251
+ * Called when the gateway observes `TimeTravelJumped` for that run.
252
+ *
253
+ * @param {string} runId
254
+ */
255
+ invalidateDevToolsSubscribersForRun(runId: string): void;
256
+ /**
257
+ * Authorize a devtools request against the connection's `subscribe` set.
258
+ *
259
+ * If the client provided a `subscribe` filter at `connect` time, the run
260
+ * must be in that set before any DB lookup happens.
261
+ *
262
+ * @param {ConnectionState | null | undefined} connection
263
+ * @param {string} runId
264
+ * @returns {boolean}
265
+ */
266
+ isDevToolsRunAuthorized(connection: ConnectionState | null | undefined, runId: string): boolean;
267
+ /**
268
+ * @param {ConnectionState} connection
269
+ */
270
+ cleanupDevToolsSubscribers(connection: ConnectionState): void;
271
+ /**
272
+ * @param {GatewayTransport} transport
273
+ * @param {string} frameType
274
+ * @param {GatewayMetricLabels} [labels]
275
+ */
276
+ recordMessageReceived(transport: GatewayTransport, frameType: string, labels?: GatewayMetricLabels): void;
277
+ /**
278
+ * @param {GatewayTransport} transport
279
+ * @param {string} frameType
280
+ * @param {GatewayMetricLabels} [labels]
281
+ */
282
+ recordMessageSent(transport: GatewayTransport, frameType: string, labels?: GatewayMetricLabels): void;
283
+ /**
284
+ * @param {GatewayTransport} transport
285
+ * @param {"success" | "failure"} outcome
286
+ * @param {GatewayRequestContext} context
287
+ * @param {Record<string, unknown>} [details]
288
+ * @param {"debug" | "info" | "warning"} [level]
289
+ */
290
+ recordAuthEvent(transport: GatewayTransport, outcome: "success" | "failure", context: GatewayRequestContext, details?: Record<string, unknown>, level?: "debug" | "info" | "warning"): void;
291
+ /**
292
+ * @param {GatewayRequestContext} context
293
+ * @param {RequestFrame} frame
294
+ * @param {() => Promise<ResponseFrame>} handler
295
+ * @returns {Promise<ResponseFrame>}
296
+ */
297
+ executeRpc(context: GatewayRequestContext, frame: RequestFrame, handler: () => Promise<ResponseFrame>): Promise<ResponseFrame>;
298
+ /**
299
+ * @param {GatewayRequestContext} context
300
+ * @param {RequestFrame} frame
301
+ * @param {ResponseFrame} response
302
+ * @returns {Effect.Effect<void>}
303
+ */
304
+ rpcSuccessEffect(context: GatewayRequestContext, frame: RequestFrame, response: ResponseFrame): Effect.Effect<void>;
305
+ /**
306
+ * @param {ServerResponse} res
307
+ * @param {number} status
308
+ * @param {ResponseFrame} response
309
+ */
310
+ sendHttpRpcResponse(res: ServerResponse, status: number, response: ResponseFrame): void;
311
+ /**
312
+ * @param {SmithersDb} adapter
313
+ * @param {string} runId
314
+ * @param {string} signalName
315
+ * @param {string | null} correlationId
316
+ */
317
+ runWaitsForSignal(adapter: SmithersDb$4, runId: string, signalName: string, correlationId: string | null): Promise<boolean>;
318
+ /**
319
+ * @param {RegisteredWorkflow} entry
320
+ * @param {string} signalName
321
+ * @param {string | null} correlationId
322
+ * @param {string} [explicitRunId]
323
+ */
324
+ findMatchingWebhookRuns(entry: RegisteredWorkflow, signalName: string, correlationId: string | null, explicitRunId?: string): Promise<any[]>;
325
+ /**
326
+ * @param {IncomingMessage} req
327
+ * @param {ServerResponse} res
328
+ * @param {string} workflowKey
329
+ */
330
+ handleWebhook(req: IncomingMessage, res: ServerResponse, workflowKey: string): Promise<void>;
331
+ /**
332
+ * @param {string} key
333
+ * @param {SmithersWorkflow} workflow
334
+ * @param {{ schedule?: string; webhook?: GatewayWebhookConfig }} [options]
335
+ * @returns {this}
336
+ */
337
+ register(key: string, workflow: SmithersWorkflow, options?: {
338
+ schedule?: string;
339
+ webhook?: GatewayWebhookConfig;
340
+ }): this;
341
+ /**
342
+ * @param {{ port?: number; host?: string }} [options]
343
+ */
344
+ listen(options?: {
345
+ port?: number;
346
+ host?: string;
347
+ }): Promise<node_http.Server<typeof node_http.IncomingMessage, typeof node_http.ServerResponse>>;
348
+ close(): Promise<void>;
349
+ startScheduler(): void;
350
+ syncRegisteredSchedules(): Promise<void>;
351
+ processDueCrons(): Promise<void>;
352
+ /**
353
+ * @param {string} workflowKey
354
+ * @param {Record<string, unknown>} input
355
+ * @param {RunStartAuthContext} auth
356
+ * @param {string} [runId]
357
+ * @param {{ resume?: boolean }} [options]
358
+ */
359
+ startRun(workflowKey: string, input: Record<string, unknown>, auth: RunStartAuthContext, runId?: string, options?: {
360
+ resume?: boolean;
361
+ }): Promise<{
362
+ runId: string;
363
+ workflow: string;
364
+ }>;
365
+ /**
366
+ * @param {string} runId
367
+ * @param {string} workflowKey
368
+ * @param {SmithersDb} adapter
369
+ * @param {RunStartAuthContext} auth
370
+ */
371
+ resumeRunIfNeeded(runId: string, workflowKey: string, adapter: SmithersDb$4, auth: RunStartAuthContext): Promise<void>;
372
+ /**
373
+ * @param {WebSocket} ws
374
+ * @param {IncomingMessage} req
375
+ */
376
+ handleSocket(ws: WebSocket, req: IncomingMessage): void;
377
+ /**
378
+ * @param {ConnectionState} connection
379
+ */
380
+ startHeartbeat(connection: ConnectionState): void;
381
+ /**
382
+ * @param {ConnectionState} connection
383
+ * @param {IncomingMessage} req
384
+ * @param {string} id
385
+ * @param {unknown} params
386
+ * @returns {Promise<ResponseFrame>}
387
+ */
388
+ handleConnect(connection: ConnectionState, req: IncomingMessage, id: string, params: unknown): Promise<ResponseFrame>;
389
+ /**
390
+ * @param {IncomingMessage} req
391
+ * @param {ConnectRequest} request
392
+ * @returns {Promise< | { ok: true; role: string; scopes: string[]; userId?: string } | { ok: false; code: string; message: string } >}
393
+ */
394
+ authenticate(req: IncomingMessage, request: ConnectRequest): Promise<{
395
+ ok: true;
396
+ role: string;
397
+ scopes: string[];
398
+ userId?: string;
399
+ } | {
400
+ ok: false;
401
+ code: string;
402
+ message: string;
403
+ }>;
404
+ /**
405
+ * @param {IncomingMessage} req
406
+ * @param {string | null} token
407
+ * @returns {Promise< | { ok: true; role: string; scopes: string[]; userId?: string } | { ok: false; code: string; message: string } >}
408
+ */
409
+ authenticateRequest(req: IncomingMessage, token: string | null): Promise<{
410
+ ok: true;
411
+ role: string;
412
+ scopes: string[];
413
+ userId?: string;
414
+ } | {
415
+ ok: false;
416
+ code: string;
417
+ message: string;
418
+ }>;
419
+ /**
420
+ * @param {IncomingMessage} req
421
+ * @param {ServerResponse} res
422
+ */
423
+ handleHttpRpc(req: IncomingMessage, res: ServerResponse): Promise<void>;
424
+ /**
425
+ * @param {ConnectionState} connection
426
+ * @param {ResponseFrame} frame
427
+ */
428
+ sendResponse(connection: ConnectionState, frame: ResponseFrame): void;
429
+ /**
430
+ * @param {ConnectionState} connection
431
+ * @param {string} event
432
+ * @param {unknown} [payload]
433
+ */
434
+ sendEvent(connection: ConnectionState, event: string, payload?: unknown, stateVersion?: number): void;
435
+ /**
436
+ * @param {string} event
437
+ * @param {unknown} [payload]
438
+ */
439
+ broadcastEvent(event: string, payload?: unknown): void;
440
+ buildSnapshot(): Promise<{
441
+ runs: any[];
442
+ approvals: {
443
+ runId: any;
444
+ nodeId: any;
445
+ iteration: any;
446
+ requestTitle: any;
447
+ requestSummary: any;
448
+ requestedAtMs: any;
449
+ approvalMode: any;
450
+ options: any;
451
+ allowedScopes: any;
452
+ allowedUsers: any;
453
+ autoApprove: any;
454
+ }[];
455
+ stateVersion: number;
456
+ }>;
457
+ /**
458
+ * @param {SmithersWorkflow} workflow
459
+ * @returns {SmithersDb}
460
+ */
461
+ adapterForWorkflow(workflow: SmithersWorkflow): SmithersDb$4;
462
+ /**
463
+ * @param {string} [status]
464
+ */
465
+ listRunsAcrossWorkflows(limit?: number, status?: string): Promise<any[]>;
466
+ listPendingApprovals(): Promise<{
467
+ runId: any;
468
+ nodeId: any;
469
+ iteration: any;
470
+ requestTitle: any;
471
+ requestSummary: any;
472
+ requestedAtMs: any;
473
+ approvalMode: any;
474
+ options: any;
475
+ allowedScopes: any;
476
+ allowedUsers: any;
477
+ autoApprove: any;
478
+ }[]>;
479
+ listCrons(): Promise<any[]>;
480
+ /**
481
+ * @param {string} cronId
482
+ */
483
+ findCron(cronId: string): Promise<{
484
+ cron: any;
485
+ workflowKey: any;
486
+ adapter: SmithersDb$4;
487
+ } | null>;
488
+ /**
489
+ * @param {string} runId
490
+ * @returns {Promise<ResolvedRun | null>}
491
+ */
492
+ resolveRun(runId: string): Promise<ResolvedRun | null>;
493
+ /**
494
+ * @param {SmithersEvent} event
495
+ */
496
+ handleSmithersEvent(event: SmithersEvent$1): void;
497
+ /**
498
+ * @param {SmithersEvent} event
499
+ * @returns {{ event: string; payload: unknown } | null}
500
+ */
501
+ mapEvent(event: SmithersEvent$1): {
502
+ event: string;
503
+ payload: unknown;
504
+ } | null;
505
+ /**
506
+ * @param {GatewayRequestContext} connection
507
+ * @param {RequestFrame} frame
508
+ * @returns {Promise<ResponseFrame>}
509
+ */
510
+ routeRequest(connection: GatewayRequestContext, frame: RequestFrame): Promise<ResponseFrame>;
511
+ }
512
+ type EventFrame = EventFrame$1;
513
+ type GatewayDefaults = GatewayDefaults$1;
514
+ type GatewayTokenGrant = GatewayTokenGrant$1;
515
+ type HelloResponse = HelloResponse$1;
516
+ type GatewayWebhookRunConfig = GatewayWebhookRunConfig$1;
517
+ type GatewayWebhookSignalConfig = GatewayWebhookSignalConfig$1;
518
+ type ConnectRequest = ConnectRequest$1;
519
+ type GatewayAuthConfig = GatewayAuthConfig$1;
520
+ type GatewayOptions = GatewayOptions$1;
521
+ type GatewayWebhookConfig = GatewayWebhookConfig$1;
522
+ type IncomingMessage = node_http.IncomingMessage;
523
+ type RequestFrame = RequestFrame$1;
524
+ type ResponseFrame = ResponseFrame$1;
525
+ type ServerResponse = node_http.ServerResponse;
526
+ type SmithersWorkflow = _smithers_components_SmithersWorkflow.SmithersWorkflow<unknown>;
527
+ type SmithersEvent$1 = _smithers_observability_SmithersEvent.SmithersEvent;
528
+ type GatewayMetricLabels = Record<string, string | number | null | undefined>;
529
+ type GatewayTransport = "ws" | "http";
530
+ type GatewayRequestContext = {
531
+ connectionId?: string;
532
+ role?: string;
533
+ scopes?: string[];
534
+ userId?: string | null;
535
+ origin?: string;
536
+ transport?: GatewayTransport;
537
+ };
538
+ type ConnectionState = {
539
+ id: string;
540
+ ws?: unknown;
541
+ role: string;
542
+ scopes: string[];
543
+ userId: string | null;
544
+ subscribe?: Set<string>;
545
+ heartbeat?: unknown;
546
+ lastActivity?: number;
547
+ closed?: boolean;
548
+ } & Record<string, unknown>;
549
+ type RunStartAuthContext = {
550
+ role: string;
551
+ scopes: string[];
552
+ userId?: string | null;
553
+ connectionId?: string;
554
+ };
555
+ type RegisteredWorkflow = {
556
+ workflow: SmithersWorkflow;
557
+ adapter: SmithersDb$4;
558
+ key: string;
559
+ schedule?: string;
560
+ webhook?: GatewayWebhookConfig;
561
+ };
562
+ type ResolvedRun = {
563
+ runId: string;
564
+ workflowKey: string;
565
+ workflow: SmithersWorkflow;
566
+ adapter: SmithersDb$4;
567
+ };
568
+
569
+ type ServeOptions$1 = {
570
+ workflow: SmithersWorkflow$1<unknown>;
571
+ adapter: SmithersDb$4;
572
+ runId: string;
573
+ abort: AbortController;
574
+ authToken?: string;
575
+ metrics?: boolean;
576
+ };
577
+
578
+ /**
579
+ * @param {ServeOptions} opts
580
+ */
581
+ declare function createServeApp(opts: ServeOptions): Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
582
+ type ServeOptions = ServeOptions$1;
583
+
584
+ /**
585
+ * @template A, E, R
586
+ * @param {Effect.Effect<A, E, R>} effect
587
+ * @param {{ signal?: AbortSignal }} [options]
588
+ */
589
+ declare function runPromise<A, E, R>(effect: Effect.Effect<A, E, R>, options?: {
590
+ signal?: AbortSignal;
591
+ }): Promise<A>;
592
+ /**
593
+ * @template A, E, R
594
+ * @param {Effect.Effect<A, E, R>} effect
595
+ */
596
+ declare function runFork<A, E, R>(effect: Effect.Effect<A, E, R>): effect_Fiber.RuntimeFiber<A, E>;
597
+ /**
598
+ * @template A, E, R
599
+ * @param {Effect.Effect<A, E, R>} effect
600
+ */
601
+ declare function runSync<A, E, R>(effect: Effect.Effect<A, E, R>): A;
602
+
603
+ declare const NODE_OUTPUT_MAX_BYTES: number;
604
+
605
+ declare const NODE_OUTPUT_WARN_BYTES: 1048576;
606
+
607
+ /** @typedef {import("@smithers-orchestrator/protocol/errors").NodeOutputErrorCode} NodeOutputErrorCode */
608
+ declare class NodeOutputRouteError extends Error {
609
+ /**
610
+ * @param {NodeOutputErrorCode} code
611
+ * @param {string} message
612
+ */
613
+ constructor(code: NodeOutputErrorCode, message: string);
614
+ /** @type {NodeOutputErrorCode} */
615
+ code: NodeOutputErrorCode;
616
+ }
617
+ type NodeOutputErrorCode = _smithers_protocol_errors.NodeOutputErrorCode;
618
+
619
+ /**
620
+ * @returns {DevToolsNode}
621
+ */
622
+ declare function emptyDevToolsRoot(): DevToolsNode;
623
+ /**
624
+ * @param {string} runId
625
+ * @returns {string}
626
+ */
627
+ declare function validateRunId(runId: string): string;
628
+ /**
629
+ * @param {unknown} frameNo
630
+ * @param {number} latestFrameNo
631
+ * @returns {number}
632
+ */
633
+ declare function validateRequestedFrameNo(frameNo: unknown, latestFrameNo: number): number;
634
+ /**
635
+ * @param {unknown} xml
636
+ * @param {(warning: SnapshotSerializerWarning) => void} [onWarning]
637
+ * @returns {DevToolsNode}
638
+ */
639
+ declare function parseXmlToDevToolsRoot(xml: unknown, onWarning?: (warning: SnapshotSerializerWarning$1) => void): DevToolsNode;
640
+ /**
641
+ * @param {{
642
+ * runId: string;
643
+ * frameNo: number;
644
+ * xmlJson: string;
645
+ * onWarning?: (warning: SnapshotSerializerWarning) => void;
646
+ * }} input
647
+ * @returns {DevToolsSnapshot}
648
+ */
649
+ declare function snapshotFromFrameRow(input: {
650
+ runId: string;
651
+ frameNo: number;
652
+ xmlJson: string;
653
+ onWarning?: (warning: SnapshotSerializerWarning$1) => void;
654
+ }): DevToolsSnapshot;
655
+ /**
656
+ * Validate a frameNo input before any DB or reconciler call so that oversized
657
+ * or malformed numeric inputs never reach the adapter.
658
+ *
659
+ * @param {unknown} frameNo
660
+ * @returns {void}
661
+ */
662
+ declare function validateFrameNoInput(frameNo: unknown): void;
663
+ /**
664
+ * Validate a fromSeq input before any DB or reconciler call.
665
+ *
666
+ * @param {unknown} fromSeq
667
+ * @returns {void}
668
+ */
669
+ declare function validateFromSeqInput(fromSeq: unknown): void;
670
+ /**
671
+ * @param {{
672
+ * adapter: SmithersDb;
673
+ * runId: string;
674
+ * frameNo?: number;
675
+ * onWarning?: (warning: SnapshotSerializerWarning) => void;
676
+ * }} input
677
+ * @returns {Promise<DevToolsSnapshot>}
678
+ */
679
+ declare function getDevToolsSnapshotRoute(input: {
680
+ adapter: SmithersDb$3;
681
+ runId: string;
682
+ frameNo?: number;
683
+ onWarning?: (warning: SnapshotSerializerWarning$1) => void;
684
+ }): Promise<DevToolsSnapshot>;
685
+ /** @typedef {import("@smithers-orchestrator/db/adapter").SmithersDb} SmithersDb */
686
+ /** @typedef {import("@smithers-orchestrator/protocol/devtools").DevToolsNode} DevToolsNode */
687
+ /** @typedef {import("@smithers-orchestrator/protocol/devtools").DevToolsSnapshot} DevToolsSnapshot */
688
+ /** @typedef {import("@smithers-orchestrator/protocol/devtools").DevToolsNodeType} DevToolsNodeType */
689
+ /** @typedef {import("@smithers-orchestrator/devtools/snapshotSerializer").SnapshotSerializerWarning} SnapshotSerializerWarning */
690
+ declare const DEVTOOLS_RUN_ID_PATTERN: RegExp;
691
+ declare const DEVTOOLS_MAX_FRAME_NO: 2147483647;
692
+ declare const DEVTOOLS_TREE_MAX_DEPTH: 256;
693
+ declare class DevToolsRouteError extends Error {
694
+ /**
695
+ * @param {string} code
696
+ * @param {string} message
697
+ * @param {string} [hint]
698
+ */
699
+ constructor(code: string, message: string, hint?: string);
700
+ code: string;
701
+ hint: string | undefined;
702
+ }
703
+ declare const DEVTOOLS_EMPTY_ROOT_ID: 0;
704
+ type SmithersDb$3 = _smithers_db_adapter.SmithersDb;
705
+ type DevToolsNode = _smithers_protocol_devtools.DevToolsNode;
706
+ type DevToolsSnapshot = _smithers_protocol_devtools.DevToolsSnapshot;
707
+ type DevToolsNodeType = _smithers_protocol_devtools.DevToolsNodeType;
708
+ type SnapshotSerializerWarning$1 = _smithers_devtools_snapshotSerializer.SnapshotSerializerWarning;
709
+
710
+ type DiffSummary$1 = {
711
+ filesChanged: number;
712
+ added: number;
713
+ removed: number;
714
+ files: Array<{
715
+ path: string;
716
+ added: number;
717
+ removed: number;
718
+ }>;
719
+ };
720
+
721
+ type GetNodeDiffStatPayload = {
722
+ seq: number;
723
+ baseRef: string;
724
+ summary: DiffSummary$1;
725
+ };
726
+ type GetNodeDiffRoutePayload = DiffBundle | GetNodeDiffStatPayload;
727
+ type GetNodeDiffRouteResult$1 = {
728
+ ok: true;
729
+ payload: GetNodeDiffRoutePayload;
730
+ } | {
731
+ ok: false;
732
+ error: {
733
+ code: string;
734
+ message: string;
735
+ };
736
+ };
737
+
738
+ /**
739
+ * @param {{
740
+ * runId: unknown;
741
+ * nodeId: unknown;
742
+ * iteration: unknown;
743
+ * resolveRun: (runId: string) => Promise<{ adapter: SmithersDb } | null>;
744
+ * emitEffect?: (effect: Effect.Effect<void>) => Promise<unknown>;
745
+ * computeDiffBundleImpl?: (baseRef: string, cwd: string, seq?: number) => Promise<import("@smithers-orchestrator/engine/effect/DiffBundle").DiffBundle>;
746
+ * computeDiffBundleBetweenRefsImpl?: (baseRef: string, targetRef: string, cwd: string, seq?: number) => Promise<import("@smithers-orchestrator/engine/effect/DiffBundle").DiffBundle>;
747
+ * getCurrentPointerImpl?: (cwd: string) => Promise<string | null>;
748
+ * resolveCommitPointerImpl?: (pointer: string, cwd: string) => Promise<string | null>;
749
+ * restorePointerImpl?: (pointer: string, cwd: string) => Promise<{ success: boolean; error?: string }>;
750
+ * nowMs?: () => number;
751
+ * stat?: boolean;
752
+ * }} opts
753
+ * @returns {Promise<GetNodeDiffRouteResult>}
754
+ */
755
+ declare function getNodeDiffRoute({ runId: rawRunId, nodeId: rawNodeId, iteration: rawIteration, resolveRun, emitEffect, computeDiffBundleImpl, computeDiffBundleBetweenRefsImpl, getCurrentPointerImpl, resolveCommitPointerImpl, restorePointerImpl, nowMs, stat, }: {
756
+ runId: unknown;
757
+ nodeId: unknown;
758
+ iteration: unknown;
759
+ resolveRun: (runId: string) => Promise<{
760
+ adapter: SmithersDb$2;
761
+ } | null>;
762
+ emitEffect?: (effect: Effect.Effect<void>) => Promise<unknown>;
763
+ computeDiffBundleImpl?: (baseRef: string, cwd: string, seq?: number) => Promise<_smithers_engine_effect_DiffBundle.DiffBundle>;
764
+ computeDiffBundleBetweenRefsImpl?: (baseRef: string, targetRef: string, cwd: string, seq?: number) => Promise<_smithers_engine_effect_DiffBundle.DiffBundle>;
765
+ getCurrentPointerImpl?: (cwd: string) => Promise<string | null>;
766
+ resolveCommitPointerImpl?: (pointer: string, cwd: string) => Promise<string | null>;
767
+ restorePointerImpl?: (pointer: string, cwd: string) => Promise<{
768
+ success: boolean;
769
+ error?: string;
770
+ }>;
771
+ nowMs?: () => number;
772
+ stat?: boolean;
773
+ }): Promise<GetNodeDiffRouteResult>;
774
+ type SmithersDb$2 = _smithers_db_adapter.SmithersDb;
775
+ type AttemptRow = _smithers_db_adapter.AttemptRow;
776
+ type GetNodeDiffRouteResult = GetNodeDiffRouteResult$1;
777
+ type DiffSummary = DiffSummary$1;
778
+
779
+ /** @typedef {import("@smithers-orchestrator/db/adapter").SmithersDb} SmithersDb */
780
+ /** @typedef {import("@smithers-orchestrator/db/adapter").AttemptRow} AttemptRow */
781
+ /** @typedef {import("./GetNodeDiffRouteResult.js").GetNodeDiffRouteResult} GetNodeDiffRouteResult */
782
+ /** @typedef {import("./DiffSummary.js").DiffSummary} DiffSummary */
783
+ declare const RUN_ID_PATTERN: RegExp;
784
+ declare const NODE_ID_PATTERN: RegExp;
785
+ declare const ITERATION_MAX: 2147483647;
786
+ /**
787
+ * Compute a lightweight per-file / total summary of a DiffBundle without
788
+ * retaining full patch text. Counts lines starting with "+"/"-" excluding
789
+ * file headers ("+++"/"---").
790
+ *
791
+ * @param {{ patches?: Array<{ path: string; diff?: string }> }} bundle
792
+ * @returns {DiffSummary}
793
+ */
794
+ declare function summarizeBundle(bundle: {
795
+ patches?: Array<{
796
+ path: string;
797
+ diff?: string;
798
+ }>;
799
+ }): DiffSummary;
800
+
801
+ type NodeOutputResponse$1 = {
802
+ status: "produced" | "pending" | "failed";
803
+ row: Record<string, unknown> | null;
804
+ schema: {
805
+ fields: Array<{
806
+ name: string;
807
+ type: "string" | "number" | "boolean" | "object" | "array" | "null" | "unknown";
808
+ optional: boolean;
809
+ nullable: boolean;
810
+ description?: string;
811
+ enum?: readonly unknown[];
812
+ }>;
813
+ } | null;
814
+ partial?: Record<string, unknown> | null;
815
+ };
816
+
817
+ /**
818
+ * Resolve per-node output row plus schema hints for DevTools rendering.
819
+ *
820
+ * @param {{
821
+ * runId: unknown;
822
+ * nodeId: unknown;
823
+ * iteration: unknown;
824
+ * resolveRun: (runId: string) => Promise<{ workflow: import("@smithers-orchestrator/components/SmithersWorkflow").SmithersWorkflow<unknown>; adapter: import("@smithers-orchestrator/db/adapter").SmithersDb } | null>;
825
+ * selectOutputRowImpl?: typeof selectOutputRow;
826
+ * emitEffect?: (effect: Effect.Effect<void>) => Promise<unknown>;
827
+ * }} params
828
+ * @returns {Promise<NodeOutputResponse>}
829
+ */
830
+ declare function getNodeOutputRoute(params: {
831
+ runId: unknown;
832
+ nodeId: unknown;
833
+ iteration: unknown;
834
+ resolveRun: (runId: string) => Promise<{
835
+ workflow: _smithers_components_SmithersWorkflow.SmithersWorkflow<unknown>;
836
+ adapter: _smithers_db_adapter.SmithersDb;
837
+ } | null>;
838
+ selectOutputRowImpl?: typeof selectOutputRow;
839
+ emitEffect?: (effect: Effect.Effect<void>) => Promise<unknown>;
840
+ }): Promise<NodeOutputResponse>;
841
+ type NodeOutputResponse = NodeOutputResponse$1;
842
+
843
+ /** @typedef {import("@smithers-orchestrator/db/adapter").SmithersDb} SmithersDb */
844
+ /** @typedef {import("@smithers-orchestrator/observability/SmithersEvent").SmithersEvent} SmithersEvent */
845
+ /** @typedef {import("@smithers-orchestrator/time-travel/jumpToFrame").JumpResult} JumpResult */
846
+ /**
847
+ * Gateway wrapper around time-travel jump orchestration.
848
+ *
849
+ * The gateway has no direct hook into the engine's in-memory reconciler
850
+ * (reconciler state is DB-backed: frames, nodes, attempts). We wire real
851
+ * capture/restore/rebuild functions that operate on the run's DB state so
852
+ * that the transaction rollback path inside jumpToFrame has meaningful
853
+ * inputs, and callers can plug in an in-memory reconciler if they have one.
854
+ *
855
+ * @param {{
856
+ * adapter: SmithersDb;
857
+ * runId: unknown;
858
+ * frameNo: unknown;
859
+ * confirm?: unknown;
860
+ * caller?: string;
861
+ * pauseRunLoop?: () => Promise<void> | void;
862
+ * resumeRunLoop?: () => Promise<void> | void;
863
+ * emitEvent?: (event: SmithersEvent) => Promise<void> | void;
864
+ * captureReconcilerState?: () => Promise<unknown> | unknown;
865
+ * restoreReconcilerState?: (snapshot: unknown) => Promise<void> | void;
866
+ * rebuildReconcilerState?: (xmlJson: string) => Promise<void> | void;
867
+ * onLog?: (level: "info" | "warn" | "error", message: string, fields?: Record<string, unknown>) => Promise<void> | void;
868
+ * }} input
869
+ * @returns {Promise<JumpResult>}
870
+ */
871
+ declare function jumpToFrameRoute(input: {
872
+ adapter: SmithersDb$1;
873
+ runId: unknown;
874
+ frameNo: unknown;
875
+ confirm?: unknown;
876
+ caller?: string;
877
+ pauseRunLoop?: () => Promise<void> | void;
878
+ resumeRunLoop?: () => Promise<void> | void;
879
+ emitEvent?: (event: SmithersEvent) => Promise<void> | void;
880
+ captureReconcilerState?: () => Promise<unknown> | unknown;
881
+ restoreReconcilerState?: (snapshot: unknown) => Promise<void> | void;
882
+ rebuildReconcilerState?: (xmlJson: string) => Promise<void> | void;
883
+ onLog?: (level: "info" | "warn" | "error", message: string, fields?: Record<string, unknown>) => Promise<void> | void;
884
+ }): Promise<JumpResult>;
885
+
886
+ type SmithersDb$1 = _smithers_db_adapter.SmithersDb;
887
+ type SmithersEvent = _smithers_observability_SmithersEvent.SmithersEvent;
888
+ type JumpResult = _smithers_time_travel_jumpToFrame.JumpResult;
889
+
890
+ /**
891
+ * @param {{
892
+ * adapter: SmithersDb;
893
+ * runId: string;
894
+ * fromSeq?: number;
895
+ * subscriberId?: string;
896
+ * pollIntervalMs?: number;
897
+ * maxBufferedEvents?: number;
898
+ * signal?: AbortSignal;
899
+ * invalidateSnapshot?: () => boolean;
900
+ * onWarning?: (warning: SnapshotSerializerWarning) => void;
901
+ * onLog?: (level: "debug" | "info" | "warn" | "error", message: string, fields: Record<string, unknown>) => void;
902
+ * onEvent?: (event: DevToolsEvent, stats: { bytes: number; durationMs: number; opCount?: number; frameNo?: number }) => void;
903
+ * onClose?: (summary: { eventsDelivered: number; durationMs: number; errorCode?: string }) => void;
904
+ * }} input
905
+ * @returns {AsyncIterable<DevToolsEvent>}
906
+ */
907
+ declare function streamDevToolsRoute(input: {
908
+ adapter: SmithersDb;
909
+ runId: string;
910
+ fromSeq?: number;
911
+ subscriberId?: string;
912
+ pollIntervalMs?: number;
913
+ maxBufferedEvents?: number;
914
+ signal?: AbortSignal;
915
+ invalidateSnapshot?: () => boolean;
916
+ onWarning?: (warning: SnapshotSerializerWarning) => void;
917
+ onLog?: (level: "debug" | "info" | "warn" | "error", message: string, fields: Record<string, unknown>) => void;
918
+ onEvent?: (event: DevToolsEvent, stats: {
919
+ bytes: number;
920
+ durationMs: number;
921
+ opCount?: number;
922
+ frameNo?: number;
923
+ }) => void;
924
+ onClose?: (summary: {
925
+ eventsDelivered: number;
926
+ durationMs: number;
927
+ errorCode?: string;
928
+ }) => void;
929
+ }): AsyncIterable<DevToolsEvent>;
930
+ /** @typedef {import("@smithers-orchestrator/db/adapter").SmithersDb} SmithersDb */
931
+ /** @typedef {import("@smithers-orchestrator/protocol/devtools").DevToolsEvent} DevToolsEvent */
932
+ /** @typedef {import("@smithers-orchestrator/protocol/devtools").DevToolsSnapshot} DevToolsSnapshot */
933
+ /** @typedef {import("@smithers-orchestrator/devtools/snapshotSerializer").SnapshotSerializerWarning} SnapshotSerializerWarning */
934
+ declare const DEVTOOLS_REBASELINE_INTERVAL: 50;
935
+ declare const DEVTOOLS_BACKPRESSURE_LIMIT: 1000;
936
+ declare const DEVTOOLS_POLL_INTERVAL_MS: 25;
937
+ type SmithersDb = _smithers_db_adapter.SmithersDb;
938
+ type DevToolsEvent = _smithers_protocol_devtools.DevToolsEvent;
939
+ type SnapshotSerializerWarning = _smithers_devtools_snapshotSerializer.SnapshotSerializerWarning;
940
+
941
+ /**
942
+ * @param {ServerOptions} [opts]
943
+ */
944
+ declare function startServerEffect(opts?: ServerOptions): Effect.Effect<node_http.Server<typeof IncomingMessage$1, typeof ServerResponse$1>, never, never>;
945
+ /**
946
+ * @param {ServerOptions} [opts]
947
+ */
948
+ declare function startServer(opts?: ServerOptions): node_http.Server<typeof IncomingMessage$1, typeof ServerResponse$1>;
949
+
950
+ type RunRow = _smithers_db_adapter_RunRow.RunRow;
951
+ type ServerOptions = ServerOptions$1;
952
+
953
+ export { type AttemptRow, type ConnectRequest, type ConnectionState, DEVTOOLS_BACKPRESSURE_LIMIT, DEVTOOLS_EMPTY_ROOT_ID, DEVTOOLS_MAX_FRAME_NO, DEVTOOLS_POLL_INTERVAL_MS, DEVTOOLS_REBASELINE_INTERVAL, DEVTOOLS_RUN_ID_PATTERN, DEVTOOLS_TREE_MAX_DEPTH, type DevToolsEvent, type DevToolsNode, type DevToolsNodeType, DevToolsRouteError, type DiffSummary, type EventFrame, GATEWAY_FRAME_ID_MAX_LENGTH, GATEWAY_METHOD_NAME_MAX_LENGTH, GATEWAY_RPC_INPUT_MAX_BYTES, GATEWAY_RPC_INPUT_MAX_DEPTH, GATEWAY_RPC_MAX_ARRAY_LENGTH, GATEWAY_RPC_MAX_DEPTH, GATEWAY_RPC_MAX_PAYLOAD_BYTES, GATEWAY_RPC_MAX_STRING_LENGTH, Gateway, type GatewayAuthConfig, type GatewayDefaults, type GatewayMetricLabels, type GatewayOptions, type GatewayRequestContext, type GatewayTokenGrant, type GatewayTransport, type GatewayWebhookConfig, type GatewayWebhookRunConfig, type GatewayWebhookSignalConfig, type GetNodeDiffRouteResult, type HelloResponse, ITERATION_MAX, type IncomingMessage, type JumpResult, NODE_ID_PATTERN, NODE_OUTPUT_MAX_BYTES, NODE_OUTPUT_WARN_BYTES, type NodeOutputErrorCode, type NodeOutputResponse, NodeOutputRouteError, RUN_ID_PATTERN, type RegisteredWorkflow, type RequestFrame, type ResolvedRun, type ResponseFrame, type RunRow, type RunStartAuthContext, type ServeOptions, type ServerOptions, type ServerResponse, type SmithersWorkflow, assertGatewayInputDepthWithinBounds, createServeApp, emptyDevToolsRoot, getDevToolsSnapshotRoute, getGatewayInputDepth, getNodeDiffRoute, getNodeOutputRoute, jumpToFrameRoute, parseGatewayRequestFrame, parseXmlToDevToolsRoot, runFork, runPromise, runSync, snapshotFromFrameRow, startServer, startServerEffect, statusForRpcError, streamDevToolsRoute, summarizeBundle, validateFrameNoInput, validateFromSeqInput, validateGatewayMethodName, validateRequestedFrameNo, validateRunId };