@codemation/core-nodes-ocr 0.2.7 → 0.2.8
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/CHANGELOG.md +9 -0
- package/dist/{analyzeInvoiceNode-BqZsN8iL.js → analyzeInvoiceNode-BQzww-XC.js} +1 -9
- package/dist/analyzeInvoiceNode-BQzww-XC.js.map +1 -0
- package/dist/{analyzeInvoiceNode-CmMsifbw.cjs → analyzeInvoiceNode-CW_SXNQf.cjs} +1 -9
- package/dist/analyzeInvoiceNode-CW_SXNQf.cjs.map +1 -0
- package/dist/codemation.plugin.cjs +178 -346
- package/dist/codemation.plugin.cjs.map +1 -1
- package/dist/codemation.plugin.d.cts +1 -73
- package/dist/codemation.plugin.d.ts +1 -58
- package/dist/codemation.plugin.js +179 -347
- package/dist/codemation.plugin.js.map +1 -1
- package/dist/{index-RNoZqCPr.d.ts → index-DdjAAXvy.d.ts} +9 -291
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -46
- package/dist/index.d.ts +7 -29
- package/dist/index.js +1 -1
- package/dist/metadata.json +1 -1
- package/dist/{runtimeTypes-B6RO-Yki.d.cts → runtimeTypes-D_9j5Pat.d.cts} +9 -259
- package/package.json +2 -2
- package/src/lib/analyzeWithAzure.ts +0 -9
- package/src/nodes/analyzeDocumentNode.ts +0 -9
- package/src/nodes/analyzeImageNode.ts +0 -9
- package/src/nodes/analyzeInvoiceNode.ts +0 -4
- package/dist/analyzeInvoiceNode-BqZsN8iL.js.map +0 -1
- package/dist/analyzeInvoiceNode-CmMsifbw.cjs.map +0 -1
|
@@ -3,11 +3,6 @@ import { DependencyContainer as Container, InjectionToken as TypeToken } from "t
|
|
|
3
3
|
import { ReadableStream } from "node:stream/web";
|
|
4
4
|
|
|
5
5
|
//#region ../core/src/contracts/baseTypes.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Minimal base types that have no dependencies on other contracts.
|
|
8
|
-
* Used by credentialTypes, workflowTypes, and other contract layers
|
|
9
|
-
* to avoid circular dependencies.
|
|
10
|
-
*/
|
|
11
6
|
type WorkflowId = string;
|
|
12
7
|
type NodeId = string;
|
|
13
8
|
type OutputPortKey = string;
|
|
@@ -93,13 +88,6 @@ interface TelemetrySpanScope extends TelemetryScope {
|
|
|
93
88
|
readonly traceId: string;
|
|
94
89
|
readonly spanId: string;
|
|
95
90
|
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
91
|
asNodeTelemetry(args: Readonly<{
|
|
104
92
|
nodeId: NodeId;
|
|
105
93
|
activationId: NodeActivationId;
|
|
@@ -118,30 +106,21 @@ interface ExecutionTelemetry extends TelemetryScope {
|
|
|
118
106
|
}
|
|
119
107
|
//#endregion
|
|
120
108
|
//#region ../core/src/contracts/retryPolicySpec.types.d.ts
|
|
121
|
-
/**
|
|
122
|
-
* In-process retry policy for runnable nodes. Serialized configs use the same
|
|
123
|
-
* `kind` discriminator (`JSON.stringify` / persisted workflows).
|
|
124
|
-
*
|
|
125
|
-
* `maxAttempts` is the total number of tries including the first (e.g. 3 means up to 2 delays after failures).
|
|
126
|
-
*/
|
|
127
109
|
type RetryPolicySpec = NoneRetryPolicySpec | FixedRetryPolicySpec | ExponentialRetryPolicySpec;
|
|
128
110
|
interface NoneRetryPolicySpec {
|
|
129
111
|
readonly kind: "none";
|
|
130
112
|
}
|
|
131
113
|
interface FixedRetryPolicySpec {
|
|
132
114
|
readonly kind: "fixed";
|
|
133
|
-
/** Total attempts including the first execution. Must be >= 1. */
|
|
134
115
|
readonly maxAttempts: number;
|
|
135
116
|
readonly delayMs: number;
|
|
136
117
|
}
|
|
137
118
|
interface ExponentialRetryPolicySpec {
|
|
138
119
|
readonly kind: "exponential";
|
|
139
|
-
/** Total attempts including the first execution. Must be >= 1. */
|
|
140
120
|
readonly maxAttempts: number;
|
|
141
121
|
readonly initialDelayMs: number;
|
|
142
122
|
readonly multiplier: number;
|
|
143
123
|
readonly maxDelayMs?: number;
|
|
144
|
-
/** When true, each delay is multiplied by a random factor in [1, 1.2). */
|
|
145
124
|
readonly jitter?: boolean;
|
|
146
125
|
}
|
|
147
126
|
//#endregion
|
|
@@ -157,22 +136,11 @@ type CredentialFieldSchema = Readonly<{
|
|
|
157
136
|
type: "string" | "password" | "textarea" | "json" | "boolean";
|
|
158
137
|
required?: true;
|
|
159
138
|
order?: number;
|
|
160
|
-
/**
|
|
161
|
-
* Where this field appears in the credential dialog. Use `"advanced"` for optional or
|
|
162
|
-
* power-user fields; they render inside a collapsible section (see `CredentialTypeDefinition.advancedSection`).
|
|
163
|
-
* Defaults to `"default"` when omitted.
|
|
164
|
-
*/
|
|
165
139
|
visibility?: "default" | "advanced";
|
|
166
140
|
placeholder?: string;
|
|
167
141
|
helpText?: string;
|
|
168
|
-
/** When set, host resolves this field from process.env at runtime; env wins over stored values. */
|
|
169
142
|
envVarName?: string;
|
|
170
|
-
/**
|
|
171
|
-
* When set, the dialog shows a copy action for this exact string (e.g. a static OAuth redirect URI
|
|
172
|
-
* pattern or documentation URL). Do not use for secret values.
|
|
173
|
-
*/
|
|
174
143
|
copyValue?: string;
|
|
175
|
-
/** Accessible label for the copy control (default: Copy). */
|
|
176
144
|
copyButtonLabel?: string;
|
|
177
145
|
}>;
|
|
178
146
|
type CredentialRequirement = Readonly<{
|
|
@@ -217,20 +185,9 @@ type CredentialOAuth2AuthDefinition = Readonly<{
|
|
|
217
185
|
clientSecretFieldKey?: string;
|
|
218
186
|
} | {
|
|
219
187
|
kind: "oauth2";
|
|
220
|
-
/**
|
|
221
|
-
* Free-form provider identifier for telemetry, DB rows, and Better Auth provider naming.
|
|
222
|
-
* Not used for any registry lookup — URLs come from {@link authorizeUrl} / {@link tokenUrl}.
|
|
223
|
-
*/
|
|
224
188
|
providerId: string;
|
|
225
|
-
/**
|
|
226
|
-
* Authorization endpoint. May contain `{publicFieldKey}` placeholders that the runtime
|
|
227
|
-
* substitutes from the credential's resolved public config (URL-encoded).
|
|
228
|
-
* Example: `https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/authorize`
|
|
229
|
-
*/
|
|
230
189
|
authorizeUrl: string;
|
|
231
|
-
/** Token endpoint. Same templating rules as {@link authorizeUrl}. */
|
|
232
190
|
tokenUrl: string;
|
|
233
|
-
/** Optional userinfo endpoint. Same templating rules as {@link authorizeUrl}. */
|
|
234
191
|
userInfoUrl?: string;
|
|
235
192
|
scopes: ReadonlyArray<string>;
|
|
236
193
|
scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig;
|
|
@@ -239,11 +196,8 @@ type CredentialOAuth2AuthDefinition = Readonly<{
|
|
|
239
196
|
}>;
|
|
240
197
|
type CredentialAuthDefinition = CredentialOAuth2AuthDefinition;
|
|
241
198
|
type CredentialAdvancedSectionPresentation = Readonly<{
|
|
242
|
-
/** Collapsible section title (default: "Advanced"). */
|
|
243
199
|
title?: string;
|
|
244
|
-
/** Optional short helper text shown inside the section (above the fields). */
|
|
245
200
|
description?: string;
|
|
246
|
-
/** When true, the advanced section starts expanded. Default: false (collapsed). */
|
|
247
201
|
defaultOpen?: boolean;
|
|
248
202
|
}>;
|
|
249
203
|
type CredentialTypeDefinition = Readonly<{
|
|
@@ -252,23 +206,11 @@ type CredentialTypeDefinition = Readonly<{
|
|
|
252
206
|
description?: string;
|
|
253
207
|
publicFields?: ReadonlyArray<CredentialFieldSchema>;
|
|
254
208
|
secretFields?: ReadonlyArray<CredentialFieldSchema>;
|
|
255
|
-
/**
|
|
256
|
-
* Optional labels for the collapsible block that contains every field with `visibility: "advanced"`.
|
|
257
|
-
* If omitted, the UI still shows that block with defaults (title "Advanced", collapsed).
|
|
258
|
-
*/
|
|
259
209
|
advancedSection?: CredentialAdvancedSectionPresentation;
|
|
260
210
|
supportedSourceKinds?: ReadonlyArray<CredentialMaterialSourceKind>;
|
|
261
211
|
auth?: CredentialAuthDefinition;
|
|
262
212
|
}>;
|
|
263
|
-
/**
|
|
264
|
-
* JSON-shaped credential field bag (public config, resolved secret material, etc.).
|
|
265
|
-
*/
|
|
266
213
|
type CredentialJsonRecord = Readonly<Record<string, unknown>>;
|
|
267
|
-
/**
|
|
268
|
-
* Persisted credential instance with typed `publicConfig`.
|
|
269
|
-
* Hosts may specialize `secretRef` with a stricter union while remaining
|
|
270
|
-
* assignable here for session/test callbacks.
|
|
271
|
-
*/
|
|
272
214
|
type CredentialInstanceRecord<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord> = Readonly<{
|
|
273
215
|
instanceId: CredentialInstanceId;
|
|
274
216
|
typeId: CredentialTypeId;
|
|
@@ -280,81 +222,49 @@ type CredentialInstanceRecord<TPublicConfig extends CredentialJsonRecord = Crede
|
|
|
280
222
|
setupStatus: CredentialSetupStatus;
|
|
281
223
|
createdAt: string;
|
|
282
224
|
updatedAt: string;
|
|
283
|
-
/**
|
|
284
|
-
* Pointer to where the credential material bytes live. For OSS / standalone
|
|
285
|
-
* rows this is `{source: "local", ref: instanceId}` and the bytes co-locate
|
|
286
|
-
* with the row in the workspace DB. For managed-mode rows this is
|
|
287
|
-
* `{source: "control-plane", ref: <cp_id>}` and the bytes live at CP.
|
|
288
|
-
*
|
|
289
|
-
* The seam is read through `CredentialMaterialProvider`. See
|
|
290
|
-
* `docs/design/credentials-oauth-unification.md` ("Material provider seam").
|
|
291
|
-
*/
|
|
292
225
|
material: Readonly<{
|
|
293
226
|
source: "local" | "control-plane";
|
|
294
227
|
ref: string;
|
|
295
228
|
}>;
|
|
296
229
|
}>;
|
|
297
|
-
/**
|
|
298
|
-
* Arguments passed to `CredentialType.createSession` and `CredentialType.test`.
|
|
299
|
-
* Declare `TPublicConfig` / `TMaterial` on `CredentialType` so implementations are checked
|
|
300
|
-
* against your credential shapes (similar to `NodeExecutionContext.config` for nodes).
|
|
301
|
-
*/
|
|
302
230
|
type CredentialSessionFactoryArgs<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord> = Readonly<{
|
|
303
231
|
instance: CredentialInstanceRecord<TPublicConfig>;
|
|
304
232
|
material: TMaterial;
|
|
305
233
|
publicConfig: TPublicConfig;
|
|
306
234
|
}>;
|
|
307
235
|
type CredentialSessionFactory<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord, TSession = unknown> = (args: CredentialSessionFactoryArgs<TPublicConfig, TMaterial>) => Promise<TSession>;
|
|
236
|
+
type CredentialAccessTokenSessionArgs<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord> = Readonly<{
|
|
237
|
+
accessToken: string;
|
|
238
|
+
grantedScopes: ReadonlyArray<string>;
|
|
239
|
+
publicConfig: TPublicConfig;
|
|
240
|
+
}>;
|
|
241
|
+
type CredentialAccessTokenSessionFactory<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TSession = unknown> = (args: CredentialAccessTokenSessionArgs<TPublicConfig>) => Promise<TSession>;
|
|
308
242
|
type CredentialHealthTester<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord> = (args: CredentialSessionFactoryArgs<TPublicConfig, TMaterial>) => Promise<CredentialHealth>;
|
|
309
|
-
/**
|
|
310
|
-
* Full credential type implementation: `definition` (UI/schema), `createSession`, and `test`.
|
|
311
|
-
* Use this at registration and config boundaries; `CredentialTypeDefinition` is only the schema slice.
|
|
312
|
-
*/
|
|
313
243
|
type CredentialType<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord, TSession = unknown> = Readonly<{
|
|
314
244
|
definition: CredentialTypeDefinition;
|
|
315
245
|
createSession: CredentialSessionFactory<TPublicConfig, TMaterial, TSession>;
|
|
246
|
+
createSessionFromAccessToken?: CredentialAccessTokenSessionFactory<TPublicConfig, TSession>;
|
|
316
247
|
test: CredentialHealthTester<TPublicConfig, TMaterial>;
|
|
317
248
|
}>;
|
|
318
|
-
/**
|
|
319
|
-
* Credential type with unspecified generics — used for `CodemationConfig.credentialTypes`, the host registry,
|
|
320
|
-
* and anywhere a concrete `CredentialType<YourPublic, YourMaterial, YourSession>` is placed in a heterogeneous list.
|
|
321
|
-
* Using `any` here avoids unsafe `as` casts while keeping typed `satisfies CredentialType<…>` definitions.
|
|
322
|
-
*/
|
|
323
249
|
type AnyCredentialType = CredentialType<any, any, unknown>;
|
|
324
250
|
//#endregion
|
|
325
251
|
//#region ../core/src/contracts/collectionTypes.d.ts
|
|
326
|
-
/**
|
|
327
|
-
* Represents a typed store for a single collection.
|
|
328
|
-
* All rows include auto-managed id, created_at, and updated_at fields.
|
|
329
|
-
*/
|
|
330
252
|
interface CollectionStore<TRow extends Record<string, unknown> = Record<string, unknown>> {
|
|
331
|
-
/**
|
|
332
|
-
* Insert a new row. id, created_at, and updated_at are auto-populated.
|
|
333
|
-
*/
|
|
334
253
|
insert(row: TRow): Promise<TRow & {
|
|
335
254
|
id: string;
|
|
336
255
|
created_at: Date;
|
|
337
256
|
updated_at: Date;
|
|
338
257
|
}>;
|
|
339
|
-
/**
|
|
340
|
-
* Get a single row by id.
|
|
341
|
-
*/
|
|
342
258
|
get(id: string): Promise<(TRow & {
|
|
343
259
|
id: string;
|
|
344
260
|
created_at: Date;
|
|
345
261
|
updated_at: Date;
|
|
346
262
|
}) | null>;
|
|
347
|
-
/**
|
|
348
|
-
* Find a single row matching the provided filter.
|
|
349
|
-
*/
|
|
350
263
|
findOne(filter: Partial<TRow>): Promise<(TRow & {
|
|
351
264
|
id: string;
|
|
352
265
|
created_at: Date;
|
|
353
266
|
updated_at: Date;
|
|
354
267
|
}) | null>;
|
|
355
|
-
/**
|
|
356
|
-
* List rows with optional pagination and filtering.
|
|
357
|
-
*/
|
|
358
268
|
list(opts?: {
|
|
359
269
|
limit?: number;
|
|
360
270
|
offset?: number;
|
|
@@ -367,41 +277,21 @@ interface CollectionStore<TRow extends Record<string, unknown> = Record<string,
|
|
|
367
277
|
}>;
|
|
368
278
|
total: number;
|
|
369
279
|
}>;
|
|
370
|
-
/**
|
|
371
|
-
* Update a row by id with partial data.
|
|
372
|
-
*/
|
|
373
280
|
update(id: string, patch: Partial<TRow>): Promise<TRow & {
|
|
374
281
|
id: string;
|
|
375
282
|
created_at: Date;
|
|
376
283
|
updated_at: Date;
|
|
377
284
|
}>;
|
|
378
|
-
/**
|
|
379
|
-
* Delete a row by id. Hard delete only (no soft delete).
|
|
380
|
-
*/
|
|
381
285
|
delete(id: string): Promise<{
|
|
382
286
|
deleted: boolean;
|
|
383
287
|
}>;
|
|
384
288
|
}
|
|
385
|
-
/**
|
|
386
|
-
* Runtime collections context: keyed by collection name.
|
|
387
|
-
*/
|
|
388
289
|
type CollectionsContext = Readonly<Record<string, CollectionStore>>;
|
|
389
290
|
//#endregion
|
|
390
291
|
//#region ../core/src/contracts/runTypes.d.ts
|
|
391
|
-
/**
|
|
392
|
-
* Test-suite linkage for a run. When set, this run was started by a TestSuiteOrchestrator
|
|
393
|
-
* as one test case inside a TestSuiteRun. The `IsTestRun` node and host-side persisters key
|
|
394
|
-
* off the presence of this field. Subworkflow runs inherit it from their parent run.
|
|
395
|
-
*/
|
|
396
292
|
interface RunTestContext {
|
|
397
293
|
readonly testSuiteRunId: string;
|
|
398
294
|
readonly testCaseIndex: number;
|
|
399
|
-
/**
|
|
400
|
-
* Optional human-friendly label for this test case (e.g. an email subject when fixtures
|
|
401
|
-
* are loaded from a mailbox). Resolved per item by `TestTrigger.caseLabel(item)` if set,
|
|
402
|
-
* persisted on `Run.test_case_label` so the Tests-tab tree-table can show "RFQ for batch 14"
|
|
403
|
-
* instead of "run_1777755971399_bbb86beac1396".
|
|
404
|
-
*/
|
|
405
295
|
readonly testCaseLabel?: string;
|
|
406
296
|
}
|
|
407
297
|
type NodeInputsByPort = Readonly<Record<InputPortKey, Items>>;
|
|
@@ -412,9 +302,7 @@ interface NodeExecutionError {
|
|
|
412
302
|
stack?: string;
|
|
413
303
|
details?: JsonValue;
|
|
414
304
|
}
|
|
415
|
-
/** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
|
|
416
305
|
type ConnectionInvocationId = string;
|
|
417
|
-
/** Arguments for appending a {@link ConnectionInvocationRecord} (engine fills run/workflow ids and timestamps). */
|
|
418
306
|
type ConnectionInvocationAppendArgs = Readonly<{
|
|
419
307
|
invocationId: ConnectionInvocationId;
|
|
420
308
|
connectionNodeId: NodeId;
|
|
@@ -455,11 +343,6 @@ interface Edge {
|
|
|
455
343
|
input: InputPortKey;
|
|
456
344
|
};
|
|
457
345
|
}
|
|
458
|
-
/**
|
|
459
|
-
* Named connection from a parent node to child nodes that exist in {@link WorkflowDefinition.nodes}
|
|
460
|
-
* but are not traversed by the main execution graph. Parents are commonly executable nodes, but may
|
|
461
|
-
* also be connection-owned nodes for recursive agent attachments.
|
|
462
|
-
*/
|
|
463
346
|
interface WorkflowNodeConnection {
|
|
464
347
|
readonly parentNodeId: NodeId;
|
|
465
348
|
readonly connectionName: NodeConnectionName;
|
|
@@ -470,18 +353,10 @@ interface WorkflowDefinition {
|
|
|
470
353
|
name: string;
|
|
471
354
|
nodes: NodeDefinition[];
|
|
472
355
|
edges: Edge[];
|
|
473
|
-
/**
|
|
474
|
-
* Optional metadata: which nodes are connection-owned children (e.g. AI agent `llm` / `tools` slots).
|
|
475
|
-
* When omitted, all nodes in {@link nodes} are treated as executable for topology.
|
|
476
|
-
*/
|
|
477
356
|
readonly connections?: ReadonlyArray<WorkflowNodeConnection>;
|
|
478
|
-
/** Directory + file-stem path under a workflow discovery root (for UI grouping only). */
|
|
479
357
|
discoveryPathSegments?: readonly string[];
|
|
480
|
-
/** Retention for run JSON and binaries (seconds). Host/env may supply defaults when omitted. */
|
|
481
358
|
readonly prunePolicy?: WorkflowPrunePolicySpec;
|
|
482
|
-
/** Whether to keep run data after completion. Host/env may supply defaults when omitted. */
|
|
483
359
|
readonly storagePolicy?: WorkflowStoragePolicySpec;
|
|
484
|
-
/** Invoked after a node fails permanently (retries exhausted) and node error handler did not recover. */
|
|
485
360
|
readonly workflowErrorHandler?: WorkflowErrorHandlerSpec;
|
|
486
361
|
}
|
|
487
362
|
interface NodeConfigBase {
|
|
@@ -490,83 +365,31 @@ interface NodeConfigBase {
|
|
|
490
365
|
readonly name?: string;
|
|
491
366
|
readonly id?: NodeId;
|
|
492
367
|
readonly icon?: string;
|
|
493
|
-
/**
|
|
494
|
-
* Plain-language, non-technical explanation of what this node does, surfaced in the workflow
|
|
495
|
-
* inspector / node properties sidebar. A first-class config option every authorable node accepts
|
|
496
|
-
* directly (alongside `id`), so it flows into the persisted config the mappers read. Distinct from
|
|
497
|
-
* {@link inspectorSummary} (config-derived label/value rows).
|
|
498
|
-
*/
|
|
499
368
|
readonly description?: string;
|
|
500
369
|
readonly execution?: Readonly<{
|
|
501
370
|
hint?: "local" | "worker";
|
|
502
371
|
queue?: string;
|
|
503
372
|
}>;
|
|
504
|
-
/** In-process execute retries (runnable nodes). Triggers typically omit this. */
|
|
505
373
|
readonly retryPolicy?: RetryPolicySpec;
|
|
506
|
-
/** Recover from execute failures; return outputs to continue, or rethrow to fail the node. */
|
|
507
374
|
readonly nodeErrorHandler?: NodeErrorHandlerSpec;
|
|
508
|
-
/**
|
|
509
|
-
* When true, edges carrying zero items on an output port still schedule single-input downstream nodes.
|
|
510
|
-
* Decided from the **source** node that produced the (empty) output. Default (false/undefined): empty
|
|
511
|
-
* main batches skip downstream execution and propagate the empty path.
|
|
512
|
-
*/
|
|
513
375
|
readonly continueWhenEmptyOutput?: boolean;
|
|
514
|
-
/**
|
|
515
|
-
* Declared I/O port names for canvas authoring (unioned with ports inferred from edges).
|
|
516
|
-
* Use for dynamic routers (Switch) and future error ports.
|
|
517
|
-
*/
|
|
518
376
|
readonly declaredOutputPorts?: ReadonlyArray<OutputPortKey>;
|
|
519
377
|
readonly declaredInputPorts?: ReadonlyArray<InputPortKey>;
|
|
520
378
|
getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;
|
|
521
|
-
/**
|
|
522
|
-
* Marker: this node emits {@link import("./assertionTypes").AssertionResult}-shaped items on its
|
|
523
|
-
* `main` port. The TestSuiteOrchestrator (and host-side TestAssertionPersister) listen for
|
|
524
|
-
* `nodeCompleted` events from nodes with this flag set, and persist their output items as
|
|
525
|
-
* TestAssertion records (only when the run carries a `testContext`). Set on assertion node
|
|
526
|
-
* configs (e.g. `AssertionNodeConfig`, `StringEqualsAssertionNodeConfig`).
|
|
527
|
-
*/
|
|
528
379
|
readonly emitsAssertions?: true;
|
|
529
|
-
/**
|
|
530
|
-
* Static configuration summary surfaced in the workflow inspector — the design-time
|
|
531
|
-
* "what does this node do" panel that renders before any run telemetry exists.
|
|
532
|
-
*
|
|
533
|
-
* Return 2–6 short label/value pairs derived from this config (method + url for an HTTP
|
|
534
|
-
* call, model + tool list for an agent, schedule + timezone for a cron trigger, etc.).
|
|
535
|
-
* Values are truncated by the UI; aim for one line each. Return `undefined` to opt out
|
|
536
|
-
* — the inspector hides the section when no rows are produced.
|
|
537
|
-
*
|
|
538
|
-
* Implement on the config class instance so the function can read sibling config fields.
|
|
539
|
-
* `defineNode({ inspectorSummary })` plumbs through to this.
|
|
540
|
-
*/
|
|
541
380
|
inspectorSummary?(): ReadonlyArray<NodeInspectorSummaryRow> | undefined;
|
|
542
381
|
}
|
|
543
|
-
/**
|
|
544
|
-
* One row of a node's static configuration summary. See {@link NodeConfigBase.inspectorSummary}.
|
|
545
|
-
*/
|
|
546
382
|
interface NodeInspectorSummaryRow {
|
|
547
383
|
readonly label: string;
|
|
548
384
|
readonly value: string;
|
|
549
385
|
}
|
|
550
386
|
declare const runnableNodeInputType: unique symbol;
|
|
551
387
|
declare const runnableNodeOutputType: unique symbol;
|
|
552
|
-
/**
|
|
553
|
-
* Runnable node: **`TInputJson`** is what **`inputSchema`** validates on **`item.json`** (the wire payload).
|
|
554
|
-
* **`TOutputJson`** is emitted `item.json` on outputs.
|
|
555
|
-
*/
|
|
556
388
|
interface RunnableNodeConfig<TInputJson$1 = unknown, TOutputJson$1 = unknown> extends NodeConfigBase {
|
|
557
389
|
readonly kind: "node";
|
|
558
390
|
readonly [runnableNodeInputType]?: TInputJson$1;
|
|
559
391
|
readonly [runnableNodeOutputType]?: TOutputJson$1;
|
|
560
|
-
/**
|
|
561
|
-
* Optional Zod input contract for {@link RunnableNode} when not set on the node class.
|
|
562
|
-
* Resolution order: node instance `inputSchema`, then config `inputSchema`, then `z.unknown()`.
|
|
563
|
-
*/
|
|
564
392
|
readonly inputSchema?: ZodType<TInputJson$1>;
|
|
565
|
-
/**
|
|
566
|
-
* When an activation receives **zero** input items, the engine normally runs `execute` zero times.
|
|
567
|
-
* Set to **`runOnce`** to run `execute` once with an empty `items` batch (and a synthetic wire item for schema parsing).
|
|
568
|
-
* Used by batch-style callback nodes (built-in `Callback`) so `callback([], ctx)` still runs.
|
|
569
|
-
*/
|
|
570
393
|
readonly emptyBatchExecution?: "skip" | "runOnce";
|
|
571
394
|
}
|
|
572
395
|
interface NodeDefinition {
|
|
@@ -608,27 +431,14 @@ type Items<TJson = unknown> = ReadonlyArray<Item<TJson>>;
|
|
|
608
431
|
type NodeOutputs = Partial<Record<OutputPortKey, Items>>;
|
|
609
432
|
type RunId = string;
|
|
610
433
|
type NodeActivationId = string;
|
|
611
|
-
/**
|
|
612
|
-
* One per-item iteration of a runnable node's execute loop. Refines `NodeActivationId` for
|
|
613
|
-
* per-item connection invocations and telemetry. Undefined when the executing node is a batch
|
|
614
|
-
* node or trigger that does not iterate items.
|
|
615
|
-
*/
|
|
616
434
|
type NodeIterationId = string;
|
|
617
435
|
interface ParentExecutionRef {
|
|
618
436
|
runId: RunId;
|
|
619
437
|
workflowId: WorkflowId;
|
|
620
438
|
nodeId: NodeId;
|
|
621
|
-
/** Subworkflow depth of the **spawning** run (0 = root). Passed when starting a child run. */
|
|
622
439
|
subworkflowDepth?: number;
|
|
623
|
-
/** Effective max node activations from the parent run (propagated to child policy merge). */
|
|
624
440
|
engineMaxNodeActivations?: number;
|
|
625
|
-
/** Effective max subworkflow depth from the parent run (propagated to child policy merge). */
|
|
626
441
|
engineMaxSubworkflowDepth?: number;
|
|
627
|
-
/**
|
|
628
|
-
* Test-suite linkage inherited by the child subworkflow run. Set by whichever node
|
|
629
|
-
* spawns the subworkflow when its own `ctx.testContext` is present, so assertions
|
|
630
|
-
* emitted inside a subworkflow land under the correct parent test case.
|
|
631
|
-
*/
|
|
632
442
|
testContext?: RunTestContext;
|
|
633
443
|
}
|
|
634
444
|
interface RunDataSnapshot {
|
|
@@ -636,7 +446,6 @@ interface RunDataSnapshot {
|
|
|
636
446
|
getOutputItems<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, output?: OutputPortKey): Items<TJson>;
|
|
637
447
|
getOutputItem<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, itemIndex: number, output?: OutputPortKey): Item<TJson> | undefined;
|
|
638
448
|
}
|
|
639
|
-
/** Whether to persist run execution data after the workflow finishes. */
|
|
640
449
|
type WorkflowStoragePolicyMode = "ALL" | "SUCCESS" | "ERROR" | "NEVER";
|
|
641
450
|
type WorkflowStoragePolicySpec = WorkflowStoragePolicyMode | TypeToken<WorkflowStoragePolicyResolver>;
|
|
642
451
|
interface WorkflowStoragePolicyResolver {
|
|
@@ -683,36 +492,19 @@ interface NodeErrorHandler {
|
|
|
683
492
|
type NodeErrorHandlerSpec = TypeToken<NodeErrorHandler> | NodeErrorHandler;
|
|
684
493
|
//#endregion
|
|
685
494
|
//#region ../core/src/contracts/runtimeTypes.d.ts
|
|
686
|
-
/** Opaque unique identifier for a single HumanTask instance. */
|
|
687
495
|
type HumanTaskId = string;
|
|
688
|
-
/**
|
|
689
|
-
* Minimal handle handed to the `deliver` callback so it can route to the correct
|
|
690
|
-
* inbox channel.
|
|
691
|
-
*/
|
|
692
496
|
interface HumanTaskHandle {
|
|
693
497
|
readonly taskId: HumanTaskId;
|
|
694
498
|
readonly runId: string;
|
|
695
499
|
readonly nodeId: string;
|
|
696
500
|
readonly expiresAt: Date;
|
|
697
|
-
/** TODO: real signed URL; placeholder empty string for now. */
|
|
698
501
|
readonly resumeUrl: string;
|
|
699
|
-
/**
|
|
700
|
-
* Arbitrary JSON metadata copied from `SuspensionRequest.request.metadata` at suspension time.
|
|
701
|
-
* Used by the agent runtime to round-trip the `agentCheckpoint` back to the
|
|
702
|
-
* resumed node via `ctx.resumeContext.task.metadata`.
|
|
703
|
-
*/
|
|
704
502
|
readonly metadata?: Readonly<Record<string, JsonValue>>;
|
|
705
503
|
}
|
|
706
|
-
/** Identity of the person who made a decision on the task. */
|
|
707
504
|
interface HumanTaskActor {
|
|
708
505
|
readonly actorId: string;
|
|
709
506
|
readonly displayName?: string;
|
|
710
507
|
}
|
|
711
|
-
/**
|
|
712
|
-
* Resume context injected into `NodeExecutionContext` when the engine re-activates
|
|
713
|
-
* a previously suspended node. `defineHumanApprovalNode` wraps this with parsed
|
|
714
|
-
* `TDecision`; at the engine layer `decision.value` is `unknown`.
|
|
715
|
-
*/
|
|
716
508
|
interface ResumeContext {
|
|
717
509
|
readonly decision: Readonly<{
|
|
718
510
|
kind: "decided";
|
|
@@ -753,11 +545,6 @@ interface NodeExecutionStatePublisher {
|
|
|
753
545
|
error: Error;
|
|
754
546
|
}): Promise<void>;
|
|
755
547
|
appendConnectionInvocation(args: ConnectionInvocationAppendArgs): Promise<void>;
|
|
756
|
-
/**
|
|
757
|
-
* Annotates the current snapshot for `nodeId` with the id of the child run spawned by a
|
|
758
|
-
* SubWorkflow invocation. Called from `SubWorkflowNode.execute` after `runById` resolves.
|
|
759
|
-
* The engine's subsequent `markCompleted` call preserves the value via `previous.childRunId`.
|
|
760
|
-
*/
|
|
761
548
|
setChildRunId?(args: {
|
|
762
549
|
nodeId: NodeId;
|
|
763
550
|
childRunId: RunId;
|
|
@@ -785,32 +572,16 @@ interface ExecutionBinaryService {
|
|
|
785
572
|
activationId: NodeActivationId;
|
|
786
573
|
}): NodeBinaryAttachmentService;
|
|
787
574
|
openReadStream(attachment: BinaryAttachment): Promise<BinaryStorageReadResult | undefined>;
|
|
788
|
-
/**
|
|
789
|
-
* Reads all bytes from the attachment into a contiguous `Uint8Array`.
|
|
790
|
-
* Checks `attachment.size` against `maxBytes` *before* any allocation; throws a bounded-read
|
|
791
|
-
* error when exceeded (no OOM). Throws if the stream is unavailable or the byte count mismatches.
|
|
792
|
-
*/
|
|
793
575
|
getBytes(attachment: BinaryAttachment, maxBytes?: number): Promise<Uint8Array>;
|
|
794
|
-
/**
|
|
795
|
-
* Reads the attachment and decodes the bytes as UTF-8 text.
|
|
796
|
-
* Subject to the same bounded-read safety as `getBytes`.
|
|
797
|
-
*/
|
|
798
576
|
getText(attachment: BinaryAttachment, maxBytes?: number): Promise<string>;
|
|
799
|
-
/**
|
|
800
|
-
* Reads the attachment, decodes as UTF-8 text, and parses as JSON.
|
|
801
|
-
* Throws a clear error on invalid JSON. Subject to the same bounded-read safety.
|
|
802
|
-
*/
|
|
803
577
|
getJson<T = unknown>(attachment: BinaryAttachment, maxBytes?: number): Promise<T>;
|
|
804
578
|
}
|
|
805
579
|
interface ExecutionContext {
|
|
806
580
|
runId: RunId;
|
|
807
581
|
workflowId: WorkflowId;
|
|
808
582
|
parent?: ParentExecutionRef;
|
|
809
|
-
/** This run's subworkflow depth (0 = root). */
|
|
810
583
|
subworkflowDepth: number;
|
|
811
|
-
/** Effective activation budget cap for this run (after policy merge). */
|
|
812
584
|
engineMaxNodeActivations: number;
|
|
813
|
-
/** Effective subworkflow nesting cap for this run (after policy merge). */
|
|
814
585
|
engineMaxSubworkflowDepth: number;
|
|
815
586
|
now: () => Date;
|
|
816
587
|
data: RunDataSnapshot;
|
|
@@ -818,28 +589,11 @@ interface ExecutionContext {
|
|
|
818
589
|
telemetry: ExecutionTelemetry;
|
|
819
590
|
binary: ExecutionBinaryService;
|
|
820
591
|
getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
|
|
821
|
-
/** Per-item iteration id, set by {@link NodeExecutor} on the ctx passed into runnable `execute`. */
|
|
822
592
|
iterationId?: NodeIterationId;
|
|
823
|
-
/** Item index (0-based) within the current activation's batch; set alongside {@link iterationId}. */
|
|
824
593
|
itemIndex?: number;
|
|
825
|
-
/** When set, this ctx is executing inside a sub-agent triggered by the named parent invocation. */
|
|
826
594
|
parentInvocationId?: ConnectionInvocationId;
|
|
827
|
-
/**
|
|
828
|
-
* Present iff the run was started by a TestSuiteOrchestrator. The {@link IsTestRunNode}
|
|
829
|
-
* branches on this; assertion-emitting nodes use it to decide whether to record results.
|
|
830
|
-
*/
|
|
831
595
|
testContext?: RunTestContext;
|
|
832
|
-
/**
|
|
833
|
-
* Collections registered in the codemation config, keyed by collection name.
|
|
834
|
-
*/
|
|
835
596
|
readonly collections?: CollectionsContext;
|
|
836
|
-
/**
|
|
837
|
-
* Resolve a DI token from the host container.
|
|
838
|
-
* Allows nodes to reach host-side services (e.g. `InboxChannelResolverToken`)
|
|
839
|
-
* without importing host code. Wired by `DefaultExecutionContextFactory`; throws
|
|
840
|
-
* a clear error when no resolver is configured (e.g. in unit tests that don't
|
|
841
|
-
* set up the full container).
|
|
842
|
-
*/
|
|
843
597
|
resolve<T>(token: TypeToken<T>): T;
|
|
844
598
|
}
|
|
845
599
|
interface NodeExecutionContext<TConfig extends NodeConfigBase = NodeConfigBase> extends ExecutionContext {
|
|
@@ -848,12 +602,8 @@ interface NodeExecutionContext<TConfig extends NodeConfigBase = NodeConfigBase>
|
|
|
848
602
|
config: TConfig;
|
|
849
603
|
telemetry: NodeExecutionTelemetry;
|
|
850
604
|
binary: NodeBinaryAttachmentService;
|
|
851
|
-
/**
|
|
852
|
-
* Present when this node activation is a HITL resume.
|
|
853
|
-
* The node checks `ctx.resumeContext !== undefined` and takes the resume branch.
|
|
854
|
-
*/
|
|
855
605
|
resumeContext?: ResumeContext;
|
|
856
606
|
}
|
|
857
607
|
//#endregion
|
|
858
|
-
export {
|
|
859
|
-
//# sourceMappingURL=runtimeTypes-
|
|
608
|
+
export { CredentialMaterialSourceKind as _, RunId as a, NodeId as b, Container as c, CredentialAccessTokenSessionFactory as d, CredentialAdvancedSectionPresentation as f, CredentialJsonRecord as g, CredentialHealthTester as h, RunDataSnapshot as i, TypeToken as l, CredentialFieldSchema as m, Items as n, RunnableNodeConfig as o, CredentialAuthDefinition as p, NodeActivationId as r, WorkflowDefinition as s, Item as t, AnyCredentialType as u, CredentialSessionFactory as v, WorkflowId as x, CredentialTypeId as y };
|
|
609
|
+
//# sourceMappingURL=runtimeTypes-D_9j5Pat.d.cts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemation/core-nodes-ocr",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "Azure AI Content Understanding (OCR) plugin for Codemation — prebuilt document, invoice, and image analyzers.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@azure/ai-content-understanding": "^1.0.0",
|
|
45
45
|
"@azure/core-auth": "^1.10.1",
|
|
46
46
|
"zod": "^4.3.6",
|
|
47
|
-
"@codemation/core": "0.
|
|
47
|
+
"@codemation/core": "0.15.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/node": "^25.3.5",
|
|
@@ -16,21 +16,13 @@ import { ContentUnderstandingClient } from "@azure/ai-content-understanding";
|
|
|
16
16
|
import { AzureKeyCredential } from "@azure/core-auth";
|
|
17
17
|
import type { AzureContentUnderstandingSession } from "../credentials/azureContentUnderstandingCredential";
|
|
18
18
|
|
|
19
|
-
/** Structured analyzer fields: scalars at leaves; nested objects and arrays preserved. */
|
|
20
19
|
export type OcrStructuredFields = Readonly<Record<string, unknown>>;
|
|
21
20
|
|
|
22
|
-
/** The output shape returned by all OCR analyzer nodes. */
|
|
23
21
|
export type OcrAnalysisOutput = Readonly<{
|
|
24
|
-
/** Markdown representation of the document content. */
|
|
25
22
|
content: string;
|
|
26
|
-
/** Structured fields extracted by the prebuilt analyzer. */
|
|
27
23
|
fields: OcrStructuredFields;
|
|
28
24
|
}>;
|
|
29
25
|
|
|
30
|
-
/**
|
|
31
|
-
* Analyzes a binary document using an Azure Content Understanding prebuilt analyzer.
|
|
32
|
-
* Retries on transient failures are handled by the engine via the node's `retryPolicy`.
|
|
33
|
-
*/
|
|
34
26
|
export async function analyzeWithAzure(
|
|
35
27
|
args: Readonly<{
|
|
36
28
|
session: AzureContentUnderstandingSession;
|
|
@@ -45,7 +37,6 @@ export async function analyzeWithAzure(
|
|
|
45
37
|
return mapAnalysisResult(result);
|
|
46
38
|
}
|
|
47
39
|
|
|
48
|
-
/** @internal Exported for testing — maps a raw AnalysisResult to the node output shape. */
|
|
49
40
|
export function mapAnalysisResult(result: AnalysisResult): OcrAnalysisOutput {
|
|
50
41
|
const contents = result.contents ?? [];
|
|
51
42
|
const markdownParts: string[] = [];
|
|
@@ -3,21 +3,12 @@ import type { AzureContentUnderstandingSession } from "../credentials/azureConte
|
|
|
3
3
|
import { azureContentUnderstandingCredentialType } from "../credentials/azureContentUnderstandingCredential";
|
|
4
4
|
import { analyzeWithAzure } from "../lib/analyzeWithAzure";
|
|
5
5
|
|
|
6
|
-
/** Default Azure Content Understanding prebuilt general document analyzer ID. */
|
|
7
6
|
const DEFAULT_DOCUMENT_ANALYZER_ID = "prebuilt-document";
|
|
8
7
|
|
|
9
8
|
export type AnalyzeDocumentConfig = Readonly<{
|
|
10
|
-
/** Key on `item.binary` that holds the document bytes. Default: `"data"`. */
|
|
11
9
|
binaryField?: string;
|
|
12
|
-
/** MIME type override sent to the analyzer. Falls back to attachment `mimeType` when not set. */
|
|
13
10
|
contentType?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Azure Content Understanding analyzer ID to use.
|
|
16
|
-
* Defaults to `"prebuilt-document"`. Set this to a custom analyzer ID when you have
|
|
17
|
-
* a trained model or need a different prebuilt variant.
|
|
18
|
-
*/
|
|
19
11
|
analyzerId?: string;
|
|
20
|
-
/** Max bytes the attachment may have before reading. Defaults to 50 MiB. */
|
|
21
12
|
maxBytes?: number;
|
|
22
13
|
}>;
|
|
23
14
|
|
|
@@ -3,21 +3,12 @@ import type { AzureContentUnderstandingSession } from "../credentials/azureConte
|
|
|
3
3
|
import { azureContentUnderstandingCredentialType } from "../credentials/azureContentUnderstandingCredential";
|
|
4
4
|
import { analyzeWithAzure } from "../lib/analyzeWithAzure";
|
|
5
5
|
|
|
6
|
-
/** Default Azure Content Understanding prebuilt image analyzer ID. */
|
|
7
6
|
const DEFAULT_IMAGE_ANALYZER_ID = "prebuilt-imageAnalyzer";
|
|
8
7
|
|
|
9
8
|
export type AnalyzeImageConfig = Readonly<{
|
|
10
|
-
/** Key on `item.binary` that holds the image bytes. Default: `"data"`. */
|
|
11
9
|
binaryField?: string;
|
|
12
|
-
/** MIME type override sent to the analyzer. Falls back to attachment `mimeType` when not set. */
|
|
13
10
|
contentType?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Azure Content Understanding analyzer ID to use.
|
|
16
|
-
* Defaults to `"prebuilt-imageAnalyzer"`. Set this to a custom analyzer ID when you have
|
|
17
|
-
* a trained model or need a different prebuilt variant.
|
|
18
|
-
*/
|
|
19
11
|
analyzerId?: string;
|
|
20
|
-
/** Max bytes the attachment may have before reading. Defaults to 50 MiB. */
|
|
21
12
|
maxBytes?: number;
|
|
22
13
|
}>;
|
|
23
14
|
|
|
@@ -3,15 +3,11 @@ import type { AzureContentUnderstandingSession } from "../credentials/azureConte
|
|
|
3
3
|
import { azureContentUnderstandingCredentialType } from "../credentials/azureContentUnderstandingCredential";
|
|
4
4
|
import { analyzeWithAzure } from "../lib/analyzeWithAzure";
|
|
5
5
|
|
|
6
|
-
/** Azure Content Understanding prebuilt invoice analyzer ID. */
|
|
7
6
|
const PREBUILT_INVOICE_ANALYZER_ID = "prebuilt-invoice";
|
|
8
7
|
|
|
9
8
|
export type AnalyzeInvoiceConfig = Readonly<{
|
|
10
|
-
/** Key on `item.binary` that holds the document bytes. Default: `"data"`. */
|
|
11
9
|
binaryField?: string;
|
|
12
|
-
/** MIME type override sent to the analyzer. Falls back to attachment `mimeType` when not set. */
|
|
13
10
|
contentType?: string;
|
|
14
|
-
/** Max bytes the attachment may have before reading. Defaults to 50 MiB. */
|
|
15
11
|
maxBytes?: number;
|
|
16
12
|
}>;
|
|
17
13
|
|