@codemation/core-nodes-ocr 0.2.2 → 0.2.4

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.
@@ -1,6 +1,6 @@
1
1
  import { ZodType, z } from "zod";
2
- import { ReadableStream } from "node:stream/web";
3
2
  import { DependencyContainer as Container, InjectionToken as TypeToken } from "tsyringe";
3
+ import { ReadableStream as ReadableStream$1 } from "node:stream/web";
4
4
 
5
5
  //#region ../core/src/contracts/baseTypes.d.ts
6
6
  /**
@@ -14,6 +14,166 @@ type OutputPortKey = string;
14
14
  type InputPortKey = string;
15
15
  type NodeConnectionName = string;
16
16
  //#endregion
17
+ //#region ../core/src/contracts/CostTrackingTelemetryContract.d.ts
18
+ type CostTrackingComponent = "chat" | "ocr" | "rag";
19
+ interface CostTrackingUsageRecord {
20
+ readonly component: CostTrackingComponent;
21
+ readonly provider: string;
22
+ readonly operation: string;
23
+ readonly pricingKey: string;
24
+ readonly usageUnit: string;
25
+ readonly quantity: number;
26
+ readonly modelName?: string;
27
+ readonly attributes?: TelemetryAttributes;
28
+ }
29
+ interface CostTrackingPriceQuote {
30
+ readonly currency: string;
31
+ readonly currencyScale: number;
32
+ readonly estimatedAmountMinor: number;
33
+ readonly estimateKind: "catalog";
34
+ }
35
+ interface CostTrackingTelemetry {
36
+ captureUsage(args: CostTrackingUsageRecord): Promise<CostTrackingPriceQuote | undefined>;
37
+ forScope(scope: TelemetryScope): CostTrackingTelemetry;
38
+ }
39
+ //#endregion
40
+ //#region ../core/src/contracts/telemetryTypes.d.ts
41
+ type TelemetryAttributePrimitive = string | number | boolean | null;
42
+ interface TelemetryAttributes {
43
+ readonly [key: string]: TelemetryAttributePrimitive | undefined;
44
+ }
45
+ interface TelemetryMetricRecord {
46
+ readonly name: string;
47
+ readonly value: number;
48
+ readonly unit?: string;
49
+ readonly attributes?: TelemetryAttributes;
50
+ }
51
+ interface TelemetrySpanEventRecord {
52
+ readonly name: string;
53
+ readonly occurredAt?: Date;
54
+ readonly attributes?: TelemetryAttributes;
55
+ }
56
+ interface TelemetryArtifactAttachment {
57
+ readonly kind: string;
58
+ readonly contentType: string;
59
+ readonly previewText?: string;
60
+ readonly previewJson?: JsonValue;
61
+ readonly payloadText?: string;
62
+ readonly payloadJson?: JsonValue;
63
+ readonly bytes?: number;
64
+ readonly truncated?: boolean;
65
+ readonly expiresAt?: Date;
66
+ }
67
+ interface TelemetryArtifactReference {
68
+ readonly artifactId: string;
69
+ readonly traceId?: string;
70
+ readonly spanId?: string;
71
+ }
72
+ interface TelemetrySpanEnd {
73
+ readonly status?: "ok" | "error";
74
+ readonly statusMessage?: string;
75
+ readonly endedAt?: Date;
76
+ readonly attributes?: TelemetryAttributes;
77
+ }
78
+ interface TelemetryChildSpanStart {
79
+ readonly name: string;
80
+ readonly kind?: "internal" | "client";
81
+ readonly startedAt?: Date;
82
+ readonly attributes?: TelemetryAttributes;
83
+ }
84
+ interface TelemetryScope {
85
+ readonly traceId?: string;
86
+ readonly spanId?: string;
87
+ readonly costTracking?: CostTrackingTelemetry;
88
+ addSpanEvent(args: TelemetrySpanEventRecord): Promise<void> | void;
89
+ recordMetric(args: TelemetryMetricRecord): Promise<void> | void;
90
+ attachArtifact(args: TelemetryArtifactAttachment): Promise<TelemetryArtifactReference> | TelemetryArtifactReference;
91
+ }
92
+ interface TelemetrySpanScope extends TelemetryScope {
93
+ readonly traceId: string;
94
+ readonly spanId: string;
95
+ end(args?: TelemetrySpanEnd): Promise<void> | void;
96
+ /**
97
+ * Lift this span into a {@link NodeExecutionTelemetry} scoped to a different (nodeId, activationId).
98
+ * Children created via the returned telemetry's `startChildSpan` get this span as their parent.
99
+ *
100
+ * Used at the sub-agent boundary so that nested runtime telemetry parents under the agent.tool.call
101
+ * span instead of the orchestrator's node-level span.
102
+ */
103
+ asNodeTelemetry(args: Readonly<{
104
+ nodeId: NodeId;
105
+ activationId: NodeActivationId;
106
+ }>): NodeExecutionTelemetry;
107
+ }
108
+ interface NodeExecutionTelemetry extends ExecutionTelemetry, TelemetrySpanScope {
109
+ startChildSpan(args: TelemetryChildSpanStart): TelemetrySpanScope;
110
+ }
111
+ interface ExecutionTelemetry extends TelemetryScope {
112
+ readonly traceId: string;
113
+ readonly spanId: string;
114
+ forNode(args: Readonly<{
115
+ nodeId: NodeId;
116
+ activationId: NodeActivationId;
117
+ }>): NodeExecutionTelemetry;
118
+ }
119
+ //#endregion
120
+ //#region ../core/src/contracts/itemExpr.d.ts
121
+ declare const ITEM_EXPR_BRAND: unique symbol;
122
+ type ItemExprResolvedContext = Readonly<{
123
+ runId: RunId;
124
+ workflowId: WorkflowId;
125
+ nodeId: NodeId;
126
+ activationId: NodeActivationId;
127
+ data: RunDataSnapshot;
128
+ }>;
129
+ /**
130
+ * Context aligned with former {@link ItemInputMapperContext} — use **`data`** to read any completed upstream node.
131
+ */
132
+ type ItemExprContext = ItemExprResolvedContext;
133
+ type ItemExprArgs<TItemJson = unknown> = Readonly<{
134
+ item: Item<TItemJson>;
135
+ itemIndex: number;
136
+ items: Items<TItemJson>;
137
+ ctx: ItemExprContext;
138
+ }>;
139
+ type ItemExprCallback<T, TItemJson = unknown> = (args: ItemExprArgs<TItemJson>) => T | Promise<T>;
140
+ type ItemExpr<T, TItemJson = unknown> = Readonly<{
141
+ readonly [ITEM_EXPR_BRAND]: true;
142
+ readonly fn: ItemExprCallback<T, TItemJson>;
143
+ }>;
144
+ //#endregion
145
+ //#region ../core/src/contracts/params.d.ts
146
+ type Expr<T, TItemJson = unknown> = ItemExpr<T, TItemJson>;
147
+ type ParamDeep<T, TItemJson = unknown> = Expr<T, TItemJson> | (T extends readonly (infer U)[] ? ReadonlyArray<ParamDeep<U, TItemJson>> : never) | (T extends object ? { [K in keyof T]: ParamDeep<T[K], TItemJson> } : T);
148
+ //#endregion
149
+ //#region ../core/src/contracts/retryPolicySpec.types.d.ts
150
+ /**
151
+ * In-process retry policy for runnable nodes. Serialized configs use the same
152
+ * `kind` discriminator (`JSON.stringify` / persisted workflows).
153
+ *
154
+ * `maxAttempts` is the total number of tries including the first (e.g. 3 means up to 2 delays after failures).
155
+ */
156
+ type RetryPolicySpec = NoneRetryPolicySpec | FixedRetryPolicySpec | ExponentialRetryPolicySpec;
157
+ interface NoneRetryPolicySpec {
158
+ readonly kind: "none";
159
+ }
160
+ interface FixedRetryPolicySpec {
161
+ readonly kind: "fixed";
162
+ /** Total attempts including the first execution. Must be >= 1. */
163
+ readonly maxAttempts: number;
164
+ readonly delayMs: number;
165
+ }
166
+ interface ExponentialRetryPolicySpec {
167
+ readonly kind: "exponential";
168
+ /** Total attempts including the first execution. Must be >= 1. */
169
+ readonly maxAttempts: number;
170
+ readonly initialDelayMs: number;
171
+ readonly multiplier: number;
172
+ readonly maxDelayMs?: number;
173
+ /** When true, each delay is multiplied by a random factor in [1, 1.2). */
174
+ readonly jitter?: boolean;
175
+ }
176
+ //#endregion
17
177
  //#region ../core/src/contracts/credentialTypes.d.ts
18
178
  type CredentialTypeId = string;
19
179
  type CredentialInstanceId = string;
@@ -149,6 +309,19 @@ type CredentialInstanceRecord<TPublicConfig extends CredentialJsonRecord = Crede
149
309
  setupStatus: CredentialSetupStatus;
150
310
  createdAt: string;
151
311
  updatedAt: string;
312
+ /**
313
+ * Pointer to where the credential material bytes live. For OSS / standalone
314
+ * rows this is `{source: "local", ref: instanceId}` and the bytes co-locate
315
+ * with the row in the workspace DB. For managed-mode rows this is
316
+ * `{source: "control-plane", ref: <cp_id>}` and the bytes live at CP.
317
+ *
318
+ * The seam is read through `CredentialMaterialProvider`. See
319
+ * `docs/design/credentials-oauth-unification.md` ("Material provider seam").
320
+ */
321
+ material: Readonly<{
322
+ source: "local" | "control-plane";
323
+ ref: string;
324
+ }>;
152
325
  }>;
153
326
  /**
154
327
  * Arguments passed to `CredentialType.createSession` and `CredentialType.test`.
@@ -178,81 +351,177 @@ type CredentialType<TPublicConfig extends CredentialJsonRecord = CredentialJsonR
178
351
  */
179
352
  type AnyCredentialType = CredentialType<any, any, unknown>;
180
353
  //#endregion
181
- //#region ../core/src/contracts/runTypes.d.ts
182
- /**
183
- * Test-suite linkage for a run. When set, this run was started by a TestSuiteOrchestrator
184
- * as one test case inside a TestSuiteRun. The `IsTestRun` node and host-side persisters key
185
- * off the presence of this field. Subworkflow runs inherit it from their parent run.
186
- */
187
- interface RunTestContext {
188
- readonly testSuiteRunId: string;
189
- readonly testCaseIndex: number;
354
+ //#region ../core/src/contracts/mcpTypes.d.ts
355
+ type McpServerTransport = "http";
356
+ interface McpServerDeclaration {
357
+ /** Globally unique slug, e.g. "gmail". Workflow authors reference this. */
358
+ id: string;
359
+ displayName: string;
360
+ description: string;
361
+ transport: McpServerTransport;
362
+ url: string;
190
363
  /**
191
- * Optional human-friendly label for this test case (e.g. an email subject when fixtures
192
- * are loaded from a mailbox). Resolved per item by `TestTrigger.caseLabel(item)` if set,
193
- * persisted on `Run.test_case_label` so the Tests-tab tree-table can show "RFQ for batch 14"
194
- * instead of "run_1777755971399_bbb86beac1396".
364
+ * Credential types accepted by this MCP server, matching CredentialRequirement.acceptedTypes.
365
+ * Absent or empty means no credential is required.
195
366
  */
196
- readonly testCaseLabel?: string;
197
- }
198
- type NodeInputsByPort = Readonly<Record<InputPortKey, Items>>;
199
- type NodeExecutionStatus = "pending" | "queued" | "running" | "completed" | "failed" | "skipped";
200
- interface NodeExecutionError {
201
- message: string;
202
- name?: string;
203
- stack?: string;
204
- details?: JsonValue;
367
+ acceptedCredentialTypes?: ReadonlyArray<string>;
368
+ /**
369
+ * Documentation only in MVP. The bind-time validator checks
370
+ * requiredScopes CredentialInstance.scopesGranted.
371
+ */
372
+ requiredScopes?: string[];
373
+ /** Non-secret static headers merged onto every MCP request. */
374
+ staticHeaders?: Record<string, string>;
375
+ /**
376
+ * Overrides for tool descriptions advertised by the MCP server.
377
+ * Applied by the connection pool after tools/list.
378
+ * Key: exact tool name as returned by the server.
379
+ */
380
+ toolDescriptionOverrides?: Record<string, string>;
205
381
  }
206
- /** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
207
- type ConnectionInvocationId = string;
208
- /** Arguments for appending a {@link ConnectionInvocationRecord} (engine fills run/workflow ids and timestamps). */
209
- type ConnectionInvocationAppendArgs = Readonly<{
210
- invocationId: ConnectionInvocationId;
211
- connectionNodeId: NodeId;
212
- parentAgentNodeId: NodeId;
213
- parentAgentActivationId: NodeActivationId;
214
- status: NodeExecutionStatus;
215
- managedInput?: JsonValue;
216
- managedOutput?: JsonValue;
217
- statusLabel?: string;
218
- subjectName?: string;
219
- error?: NodeExecutionError;
220
- queuedAt?: string;
221
- startedAt?: string;
222
- finishedAt?: string;
223
- iterationId?: NodeIterationId;
224
- itemIndex?: number;
225
- parentInvocationId?: ConnectionInvocationId;
226
- }>;
227
382
  //#endregion
228
- //#region ../core/src/contracts/retryPolicySpec.types.d.ts
383
+ //#region ../core/src/contracts/collectionTypes.d.ts
229
384
  /**
230
- * In-process retry policy for runnable nodes. Serialized configs use the same
231
- * `kind` discriminator (`JSON.stringify` / persisted workflows).
232
- *
233
- * `maxAttempts` is the total number of tries including the first (e.g. 3 means up to 2 delays after failures).
385
+ * Represents a typed store for a single collection.
386
+ * All rows include auto-managed id, created_at, and updated_at fields.
234
387
  */
235
- type RetryPolicySpec = NoneRetryPolicySpec | FixedRetryPolicySpec | ExponentialRetryPolicySpec;
236
- interface NoneRetryPolicySpec {
237
- readonly kind: "none";
238
- }
239
- interface FixedRetryPolicySpec {
240
- readonly kind: "fixed";
241
- /** Total attempts including the first execution. Must be >= 1. */
242
- readonly maxAttempts: number;
243
- readonly delayMs: number;
244
- }
245
- interface ExponentialRetryPolicySpec {
246
- readonly kind: "exponential";
247
- /** Total attempts including the first execution. Must be >= 1. */
248
- readonly maxAttempts: number;
249
- readonly initialDelayMs: number;
250
- readonly multiplier: number;
251
- readonly maxDelayMs?: number;
252
- /** When true, each delay is multiplied by a random factor in [1, 1.2). */
253
- readonly jitter?: boolean;
388
+ interface CollectionStore<TRow extends Record<string, unknown> = Record<string, unknown>> {
389
+ /**
390
+ * Insert a new row. id, created_at, and updated_at are auto-populated.
391
+ */
392
+ insert(row: TRow): Promise<TRow & {
393
+ id: string;
394
+ created_at: Date;
395
+ updated_at: Date;
396
+ }>;
397
+ /**
398
+ * Get a single row by id.
399
+ */
400
+ get(id: string): Promise<(TRow & {
401
+ id: string;
402
+ created_at: Date;
403
+ updated_at: Date;
404
+ }) | null>;
405
+ /**
406
+ * Find a single row matching the provided filter.
407
+ */
408
+ findOne(filter: Partial<TRow>): Promise<(TRow & {
409
+ id: string;
410
+ created_at: Date;
411
+ updated_at: Date;
412
+ }) | null>;
413
+ /**
414
+ * List rows with optional pagination and filtering.
415
+ */
416
+ list(opts?: {
417
+ limit?: number;
418
+ offset?: number;
419
+ where?: Partial<TRow>;
420
+ }): Promise<{
421
+ rows: ReadonlyArray<TRow & {
422
+ id: string;
423
+ created_at: Date;
424
+ updated_at: Date;
425
+ }>;
426
+ total: number;
427
+ }>;
428
+ /**
429
+ * Update a row by id with partial data.
430
+ */
431
+ update(id: string, patch: Partial<TRow>): Promise<TRow & {
432
+ id: string;
433
+ created_at: Date;
434
+ updated_at: Date;
435
+ }>;
436
+ /**
437
+ * Delete a row by id. Hard delete only (no soft delete).
438
+ */
439
+ delete(id: string): Promise<{
440
+ deleted: boolean;
441
+ }>;
442
+ }
443
+ /**
444
+ * Runtime collections context: keyed by collection name.
445
+ */
446
+ type CollectionsContext = Readonly<Record<string, CollectionStore>>;
447
+ //#endregion
448
+ //#region ../core/src/authoring/defineNode.types.d.ts
449
+ type ResolvableCredentialType = AnyCredentialType | CredentialTypeId;
450
+ type DefinedNodeCredentialBinding = ResolvableCredentialType | Readonly<{
451
+ readonly type: ResolvableCredentialType | ReadonlyArray<ResolvableCredentialType>;
452
+ readonly label?: string;
453
+ readonly optional?: true;
454
+ readonly helpText?: string;
455
+ readonly helpUrl?: string;
456
+ }>;
457
+ type DefinedNodeCredentialBindings = Readonly<Record<string, DefinedNodeCredentialBinding>>;
458
+ type DefinedNodeConfigInput<TConfigResolved extends CredentialJsonRecord, TItemJson> = ParamDeep<TConfigResolved, TItemJson>;
459
+ interface DefinedNode<TKey$1 extends string, TConfig$1 extends CredentialJsonRecord, TInputJson$1, TOutputJson$1, _TBindings extends DefinedNodeCredentialBindings | undefined = undefined> {
460
+ readonly kind: "defined-node";
461
+ readonly key: TKey$1;
462
+ readonly title: string;
463
+ readonly description?: string;
464
+ create<TConfigItemJson = TInputJson$1>(config: DefinedNodeConfigInput<TConfig$1, TConfigItemJson>, name?: string, id?: string): RunnableNodeConfig<TInputJson$1, TOutputJson$1>;
465
+ register(context: {
466
+ registerNode<TValue>(token: TypeToken<TValue>, implementation?: TypeToken<TValue>): void;
467
+ }): void;
254
468
  }
255
469
  //#endregion
470
+ //#region ../core/src/policies/executionLimits/EngineExecutionLimitsPolicy.d.ts
471
+ interface EngineExecutionLimitsPolicyConfig {
472
+ readonly defaultMaxNodeActivations: number;
473
+ readonly hardMaxNodeActivations: number;
474
+ readonly defaultMaxSubworkflowDepth: number;
475
+ readonly hardMaxSubworkflowDepth: number;
476
+ }
477
+ //#endregion
478
+ //#region ../core/src/contracts/runTypes.d.ts
479
+ /**
480
+ * Test-suite linkage for a run. When set, this run was started by a TestSuiteOrchestrator
481
+ * as one test case inside a TestSuiteRun. The `IsTestRun` node and host-side persisters key
482
+ * off the presence of this field. Subworkflow runs inherit it from their parent run.
483
+ */
484
+ interface RunTestContext {
485
+ readonly testSuiteRunId: string;
486
+ readonly testCaseIndex: number;
487
+ /**
488
+ * Optional human-friendly label for this test case (e.g. an email subject when fixtures
489
+ * are loaded from a mailbox). Resolved per item by `TestTrigger.caseLabel(item)` if set,
490
+ * persisted on `Run.test_case_label` so the Tests-tab tree-table can show "RFQ for batch 14"
491
+ * instead of "run_1777755971399_bbb86beac1396".
492
+ */
493
+ readonly testCaseLabel?: string;
494
+ }
495
+ type NodeInputsByPort = Readonly<Record<InputPortKey, Items>>;
496
+ type NodeExecutionStatus = "pending" | "queued" | "running" | "completed" | "failed" | "skipped" | "hitl-approved" | "hitl-rejected" | "hitl-timeout" | "hitl-auto-accepted" | "hitl-cancelled";
497
+ interface NodeExecutionError {
498
+ message: string;
499
+ name?: string;
500
+ stack?: string;
501
+ details?: JsonValue;
502
+ }
503
+ /** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
504
+ type ConnectionInvocationId = string;
505
+ /** Arguments for appending a {@link ConnectionInvocationRecord} (engine fills run/workflow ids and timestamps). */
506
+ type ConnectionInvocationAppendArgs = Readonly<{
507
+ invocationId: ConnectionInvocationId;
508
+ connectionNodeId: NodeId;
509
+ parentAgentNodeId: NodeId;
510
+ parentAgentActivationId: NodeActivationId;
511
+ status: NodeExecutionStatus;
512
+ managedInput?: JsonValue;
513
+ managedOutput?: JsonValue;
514
+ statusLabel?: string;
515
+ subjectName?: string;
516
+ error?: NodeExecutionError;
517
+ queuedAt?: string;
518
+ startedAt?: string;
519
+ finishedAt?: string;
520
+ iterationId?: NodeIterationId;
521
+ itemIndex?: number;
522
+ parentInvocationId?: ConnectionInvocationId;
523
+ }>;
524
+ //#endregion
256
525
  //#region ../core/src/contracts/workflowTypes.d.ts
257
526
  type NodeIdRef<TJson = unknown> = NodeId & Readonly<{
258
527
  __codemationNodeJson?: TJson;
@@ -494,212 +763,53 @@ interface NodeErrorHandler {
494
763
  }
495
764
  type NodeErrorHandlerSpec = TypeToken<NodeErrorHandler> | NodeErrorHandler;
496
765
  //#endregion
497
- //#region ../core/src/contracts/CostTrackingTelemetryContract.d.ts
498
- type CostTrackingComponent = "chat" | "ocr" | "rag";
499
- interface CostTrackingUsageRecord {
500
- readonly component: CostTrackingComponent;
501
- readonly provider: string;
502
- readonly operation: string;
503
- readonly pricingKey: string;
504
- readonly usageUnit: string;
505
- readonly quantity: number;
506
- readonly modelName?: string;
507
- readonly attributes?: TelemetryAttributes;
508
- }
509
- interface CostTrackingPriceQuote {
510
- readonly currency: string;
511
- readonly currencyScale: number;
512
- readonly estimatedAmountMinor: number;
513
- readonly estimateKind: "catalog";
514
- }
515
- interface CostTrackingTelemetry {
516
- captureUsage(args: CostTrackingUsageRecord): Promise<CostTrackingPriceQuote | undefined>;
517
- forScope(scope: TelemetryScope): CostTrackingTelemetry;
518
- }
519
- //#endregion
520
- //#region ../core/src/contracts/telemetryTypes.d.ts
521
- type TelemetryAttributePrimitive = string | number | boolean | null;
522
- interface TelemetryAttributes {
523
- readonly [key: string]: TelemetryAttributePrimitive | undefined;
524
- }
525
- interface TelemetryMetricRecord {
526
- readonly name: string;
527
- readonly value: number;
528
- readonly unit?: string;
529
- readonly attributes?: TelemetryAttributes;
530
- }
531
- interface TelemetrySpanEventRecord {
532
- readonly name: string;
533
- readonly occurredAt?: Date;
534
- readonly attributes?: TelemetryAttributes;
535
- }
536
- interface TelemetryArtifactAttachment {
537
- readonly kind: string;
538
- readonly contentType: string;
539
- readonly previewText?: string;
540
- readonly previewJson?: JsonValue;
541
- readonly payloadText?: string;
542
- readonly payloadJson?: JsonValue;
543
- readonly bytes?: number;
544
- readonly truncated?: boolean;
545
- readonly expiresAt?: Date;
546
- }
547
- interface TelemetryArtifactReference {
548
- readonly artifactId: string;
549
- readonly traceId?: string;
550
- readonly spanId?: string;
551
- }
552
- interface TelemetrySpanEnd {
553
- readonly status?: "ok" | "error";
554
- readonly statusMessage?: string;
555
- readonly endedAt?: Date;
556
- readonly attributes?: TelemetryAttributes;
557
- }
558
- interface TelemetryChildSpanStart {
559
- readonly name: string;
560
- readonly kind?: "internal" | "client";
561
- readonly startedAt?: Date;
562
- readonly attributes?: TelemetryAttributes;
563
- }
564
- interface TelemetryScope {
565
- readonly traceId?: string;
566
- readonly spanId?: string;
567
- readonly costTracking?: CostTrackingTelemetry;
568
- addSpanEvent(args: TelemetrySpanEventRecord): Promise<void> | void;
569
- recordMetric(args: TelemetryMetricRecord): Promise<void> | void;
570
- attachArtifact(args: TelemetryArtifactAttachment): Promise<TelemetryArtifactReference> | TelemetryArtifactReference;
571
- }
572
- interface TelemetrySpanScope extends TelemetryScope {
573
- readonly traceId: string;
574
- readonly spanId: string;
575
- end(args?: TelemetrySpanEnd): Promise<void> | void;
576
- /**
577
- * Lift this span into a {@link NodeExecutionTelemetry} scoped to a different (nodeId, activationId).
578
- * Children created via the returned telemetry's `startChildSpan` get this span as their parent.
579
- *
580
- * Used at the sub-agent boundary so that nested runtime telemetry parents under the agent.tool.call
581
- * span instead of the orchestrator's node-level span.
582
- */
583
- asNodeTelemetry(args: Readonly<{
584
- nodeId: NodeId;
585
- activationId: NodeActivationId;
586
- }>): NodeExecutionTelemetry;
587
- }
588
- interface NodeExecutionTelemetry extends ExecutionTelemetry, TelemetrySpanScope {
589
- startChildSpan(args: TelemetryChildSpanStart): TelemetrySpanScope;
590
- }
591
- interface ExecutionTelemetry extends TelemetryScope {
592
- readonly traceId: string;
593
- readonly spanId: string;
594
- forNode(args: Readonly<{
595
- nodeId: NodeId;
596
- activationId: NodeActivationId;
597
- }>): NodeExecutionTelemetry;
598
- }
599
- //#endregion
600
- //#region ../core/src/contracts/mcpTypes.d.ts
601
- type McpServerTransport = "http";
602
- interface McpServerDeclaration {
603
- /** Globally unique slug, e.g. "gmail". Workflow authors reference this. */
604
- id: string;
605
- displayName: string;
606
- description: string;
607
- transport: McpServerTransport;
608
- url: string;
609
- /**
610
- * Credential types accepted by this MCP server, matching CredentialRequirement.acceptedTypes.
611
- * Absent or empty means no credential is required.
612
- */
613
- acceptedCredentialTypes?: ReadonlyArray<string>;
614
- /**
615
- * Documentation only in MVP. The bind-time validator checks
616
- * requiredScopes ⊆ CredentialInstance.scopesGranted.
617
- */
618
- requiredScopes?: string[];
619
- /** Non-secret static headers merged onto every MCP request. */
620
- staticHeaders?: Record<string, string>;
621
- /**
622
- * Overrides for tool descriptions advertised by the MCP server.
623
- * Applied by the connection pool after tools/list.
624
- * Key: exact tool name as returned by the server.
625
- */
626
- toolDescriptionOverrides?: Record<string, string>;
627
- }
628
- //#endregion
629
- //#region ../core/src/contracts/collectionTypes.d.ts
766
+ //#region ../core/src/contracts/runtimeTypes.d.ts
767
+ /** Opaque unique identifier for a single HumanTask instance. */
768
+ type HumanTaskId = string;
630
769
  /**
631
- * Represents a typed store for a single collection.
632
- * All rows include auto-managed id, created_at, and updated_at fields.
770
+ * Minimal handle handed to the `deliver` callback so it can route to the correct
771
+ * inbox channel.
633
772
  */
634
- interface CollectionStore<TRow extends Record<string, unknown> = Record<string, unknown>> {
635
- /**
636
- * Insert a new row. id, created_at, and updated_at are auto-populated.
637
- */
638
- insert(row: TRow): Promise<TRow & {
639
- id: string;
640
- created_at: Date;
641
- updated_at: Date;
642
- }>;
773
+ interface HumanTaskHandle {
774
+ readonly taskId: HumanTaskId;
775
+ readonly runId: string;
776
+ readonly nodeId: string;
777
+ readonly expiresAt: Date;
778
+ /** TODO: real signed URL; placeholder empty string for now. */
779
+ readonly resumeUrl: string;
643
780
  /**
644
- * Get a single row by id.
781
+ * Arbitrary JSON metadata copied from `SuspensionRequest.request.metadata` at suspension time.
782
+ * Used by the agent runtime to round-trip the `agentCheckpoint` back to the
783
+ * resumed node via `ctx.resumeContext.task.metadata`.
645
784
  */
646
- get(id: string): Promise<(TRow & {
647
- id: string;
648
- created_at: Date;
649
- updated_at: Date;
650
- }) | null>;
651
- /**
652
- * Find a single row matching the provided filter.
653
- */
654
- findOne(filter: Partial<TRow>): Promise<(TRow & {
655
- id: string;
656
- created_at: Date;
657
- updated_at: Date;
658
- }) | null>;
659
- /**
660
- * List rows with optional pagination and filtering.
661
- */
662
- list(opts?: {
663
- limit?: number;
664
- offset?: number;
665
- where?: Partial<TRow>;
666
- }): Promise<{
667
- rows: ReadonlyArray<TRow & {
668
- id: string;
669
- created_at: Date;
670
- updated_at: Date;
671
- }>;
672
- total: number;
673
- }>;
674
- /**
675
- * Update a row by id with partial data.
676
- */
677
- update(id: string, patch: Partial<TRow>): Promise<TRow & {
678
- id: string;
679
- created_at: Date;
680
- updated_at: Date;
681
- }>;
682
- /**
683
- * Delete a row by id. Hard delete only (no soft delete).
684
- */
685
- delete(id: string): Promise<{
686
- deleted: boolean;
687
- }>;
785
+ readonly metadata?: Readonly<Record<string, JsonValue>>;
786
+ }
787
+ /** Identity of the person who made a decision on the task. */
788
+ interface HumanTaskActor {
789
+ readonly actorId: string;
790
+ readonly displayName?: string;
688
791
  }
689
792
  /**
690
- * Runtime collections context: keyed by collection name.
793
+ * Resume context injected into `NodeExecutionContext` when the engine re-activates
794
+ * a previously suspended node. `defineHumanApprovalNode` wraps this with parsed
795
+ * `TDecision`; at the engine layer `decision.value` is `unknown`.
691
796
  */
692
- type CollectionsContext = Readonly<Record<string, CollectionStore>>;
693
- //#endregion
694
- //#region ../core/src/policies/executionLimits/EngineExecutionLimitsPolicy.d.ts
695
- interface EngineExecutionLimitsPolicyConfig {
696
- readonly defaultMaxNodeActivations: number;
697
- readonly hardMaxNodeActivations: number;
698
- readonly defaultMaxSubworkflowDepth: number;
699
- readonly hardMaxSubworkflowDepth: number;
797
+ interface ResumeContext {
798
+ readonly decision: Readonly<{
799
+ kind: "decided";
800
+ value: unknown;
801
+ actor: HumanTaskActor;
802
+ decidedAt: Date;
803
+ }> | Readonly<{
804
+ kind: "timed_out";
805
+ at: Date;
806
+ }> | Readonly<{
807
+ kind: "auto_accepted";
808
+ at: Date;
809
+ }>;
810
+ readonly delivery: JsonValue;
811
+ readonly task: HumanTaskHandle;
700
812
  }
701
- //#endregion
702
- //#region ../core/src/contracts/runtimeTypes.d.ts
703
813
  interface NodeExecutionStatePublisher {
704
814
  markQueued(args: {
705
815
  nodeId: NodeId;
@@ -734,9 +844,9 @@ interface NodeExecutionStatePublisher {
734
844
  childRunId: RunId;
735
845
  }): Promise<void>;
736
846
  }
737
- type BinaryBody = ReadableStream<Uint8Array> | AsyncIterable<Uint8Array> | Uint8Array | ArrayBuffer;
847
+ type BinaryBody = ReadableStream$1<Uint8Array> | AsyncIterable<Uint8Array> | Uint8Array | ArrayBuffer;
738
848
  interface BinaryStorageReadResult {
739
- body: ReadableStream<Uint8Array>;
849
+ body: ReadableStream$1<Uint8Array>;
740
850
  size?: number;
741
851
  }
742
852
  interface BinaryAttachmentCreateRequest {
@@ -756,6 +866,22 @@ interface ExecutionBinaryService {
756
866
  activationId: NodeActivationId;
757
867
  }): NodeBinaryAttachmentService;
758
868
  openReadStream(attachment: BinaryAttachment): Promise<BinaryStorageReadResult | undefined>;
869
+ /**
870
+ * Reads all bytes from the attachment into a contiguous `Uint8Array`.
871
+ * Checks `attachment.size` against `maxBytes` *before* any allocation; throws a bounded-read
872
+ * error when exceeded (no OOM). Throws if the stream is unavailable or the byte count mismatches.
873
+ */
874
+ getBytes(attachment: BinaryAttachment, maxBytes?: number): Promise<Uint8Array>;
875
+ /**
876
+ * Reads the attachment and decodes the bytes as UTF-8 text.
877
+ * Subject to the same bounded-read safety as `getBytes`.
878
+ */
879
+ getText(attachment: BinaryAttachment, maxBytes?: number): Promise<string>;
880
+ /**
881
+ * Reads the attachment, decodes as UTF-8 text, and parses as JSON.
882
+ * Throws a clear error on invalid JSON. Subject to the same bounded-read safety.
883
+ */
884
+ getJson<T = unknown>(attachment: BinaryAttachment, maxBytes?: number): Promise<T>;
759
885
  }
760
886
  interface ExecutionContext {
761
887
  runId: RunId;
@@ -788,6 +914,14 @@ interface ExecutionContext {
788
914
  * Collections registered in the codemation config, keyed by collection name.
789
915
  */
790
916
  readonly collections?: CollectionsContext;
917
+ /**
918
+ * Resolve a DI token from the host container.
919
+ * Allows nodes to reach host-side services (e.g. `InboxChannelResolverToken`)
920
+ * without importing host code. Wired by `DefaultExecutionContextFactory`; throws
921
+ * a clear error when no resolver is configured (e.g. in unit tests that don't
922
+ * set up the full container).
923
+ */
924
+ resolve<T>(token: TypeToken<T>): T;
791
925
  }
792
926
  interface NodeExecutionContext<TConfig$1 extends NodeConfigBase = NodeConfigBase> extends ExecutionContext {
793
927
  nodeId: NodeId;
@@ -795,57 +929,11 @@ interface NodeExecutionContext<TConfig$1 extends NodeConfigBase = NodeConfigBase
795
929
  config: TConfig$1;
796
930
  telemetry: NodeExecutionTelemetry;
797
931
  binary: NodeBinaryAttachmentService;
798
- }
799
- //#endregion
800
- //#region ../core/src/contracts/itemExpr.d.ts
801
- declare const ITEM_EXPR_BRAND: unique symbol;
802
- type ItemExprResolvedContext = Readonly<{
803
- runId: RunId;
804
- workflowId: WorkflowId;
805
- nodeId: NodeId;
806
- activationId: NodeActivationId;
807
- data: RunDataSnapshot;
808
- }>;
809
- /**
810
- * Context aligned with former {@link ItemInputMapperContext} — use **`data`** to read any completed upstream node.
811
- */
812
- type ItemExprContext = ItemExprResolvedContext;
813
- type ItemExprArgs<TItemJson = unknown> = Readonly<{
814
- item: Item<TItemJson>;
815
- itemIndex: number;
816
- items: Items<TItemJson>;
817
- ctx: ItemExprContext;
818
- }>;
819
- type ItemExprCallback<T, TItemJson = unknown> = (args: ItemExprArgs<TItemJson>) => T | Promise<T>;
820
- type ItemExpr<T, TItemJson = unknown> = Readonly<{
821
- readonly [ITEM_EXPR_BRAND]: true;
822
- readonly fn: ItemExprCallback<T, TItemJson>;
823
- }>;
824
- //#endregion
825
- //#region ../core/src/contracts/params.d.ts
826
- type Expr<T, TItemJson = unknown> = ItemExpr<T, TItemJson>;
827
- type ParamDeep<T, TItemJson = unknown> = Expr<T, TItemJson> | (T extends readonly (infer U)[] ? ReadonlyArray<ParamDeep<U, TItemJson>> : never) | (T extends object ? { [K in keyof T]: ParamDeep<T[K], TItemJson> } : T);
828
- //#endregion
829
- //#region ../core/src/authoring/defineNode.types.d.ts
830
- type ResolvableCredentialType = AnyCredentialType | CredentialTypeId;
831
- type DefinedNodeCredentialBinding = ResolvableCredentialType | Readonly<{
832
- readonly type: ResolvableCredentialType | ReadonlyArray<ResolvableCredentialType>;
833
- readonly label?: string;
834
- readonly optional?: true;
835
- readonly helpText?: string;
836
- readonly helpUrl?: string;
837
- }>;
838
- type DefinedNodeCredentialBindings = Readonly<Record<string, DefinedNodeCredentialBinding>>;
839
- type DefinedNodeConfigInput<TConfigResolved extends CredentialJsonRecord, TItemJson> = ParamDeep<TConfigResolved, TItemJson>;
840
- interface DefinedNode<TKey$1 extends string, TConfig$1 extends CredentialJsonRecord, TInputJson$1, TOutputJson$1, _TBindings extends DefinedNodeCredentialBindings | undefined = undefined> {
841
- readonly kind: "defined-node";
842
- readonly key: TKey$1;
843
- readonly title: string;
844
- readonly description?: string;
845
- create<TConfigItemJson = TInputJson$1>(config: DefinedNodeConfigInput<TConfig$1, TConfigItemJson>, name?: string, id?: string): RunnableNodeConfig<TInputJson$1, TOutputJson$1>;
846
- register(context: {
847
- registerNode<TValue>(token: TypeToken<TValue>, implementation?: TypeToken<TValue>): void;
848
- }): void;
932
+ /**
933
+ * Present when this node activation is a HITL resume.
934
+ * The node checks `ctx.resumeContext !== undefined` and takes the resume branch.
935
+ */
936
+ resumeContext?: ResumeContext;
849
937
  }
850
938
  //#endregion
851
939
  //#region ../core/src/authoring/defineCollection.types.d.ts
@@ -872,5 +960,5 @@ interface DefinedCollection<TDefinition extends CollectionDefinition = Collectio
872
960
  }): void;
873
961
  }
874
962
  //#endregion
875
- export { TypeToken as a, WorkflowDefinition as c, CredentialAuthDefinition as d, CredentialFieldSchema as f, CredentialTypeId as g, CredentialSessionFactory as h, Container as i, AnyCredentialType as l, CredentialMaterialSourceKind as m, DefinedCollection as n, EngineExecutionLimitsPolicyConfig as o, CredentialHealthTester as p, DefinedNode as r, McpServerDeclaration as s, CollectionDefinition as t, CredentialAdvancedSectionPresentation as u };
876
- //# sourceMappingURL=index-C2KJPzqN.d.ts.map
963
+ export { TypeToken as a, McpServerDeclaration as c, CredentialAuthDefinition as d, CredentialFieldSchema as f, CredentialTypeId as g, CredentialSessionFactory as h, Container as i, AnyCredentialType as l, CredentialMaterialSourceKind as m, DefinedCollection as n, EngineExecutionLimitsPolicyConfig as o, CredentialHealthTester as p, WorkflowDefinition as r, DefinedNode as s, CollectionDefinition as t, CredentialAdvancedSectionPresentation as u };
964
+ //# sourceMappingURL=index-DF2ht42F.d.ts.map