@codemation/core 0.10.2 → 0.11.1
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 +183 -0
- package/dist/CostCatalogContract-DZgcUBE4.d.cts +19 -0
- package/dist/{EngineRuntimeRegistration.types-ClLuY1FG.d.ts → EngineRuntimeRegistration.types-BQbS9_gs.d.ts} +2 -2
- package/dist/{EngineRuntimeRegistration.types-BryWi2mA.d.cts → EngineRuntimeRegistration.types-Cggm5GVY.d.cts} +8 -2
- package/dist/{InMemoryRunDataFactory-DeXNJt1O.d.cts → InMemoryRunDataFactory-C7YItvHG.d.cts} +9 -19
- package/dist/{InMemoryRunEventBusRegistry-sM4z4n_i.js → InMemoryRunEventBusRegistry-Bwunvt1T.js} +1 -1
- package/dist/{InMemoryRunEventBusRegistry-sM4z4n_i.js.map → InMemoryRunEventBusRegistry-Bwunvt1T.js.map} +1 -1
- package/dist/{InMemoryRunEventBusRegistry-VM3OWnHo.cjs → InMemoryRunEventBusRegistry-Sa86VxuV.cjs} +1 -1
- package/dist/{InMemoryRunEventBusRegistry-VM3OWnHo.cjs.map → InMemoryRunEventBusRegistry-Sa86VxuV.cjs.map} +1 -1
- package/dist/ItemsInputNormalizer-C_dpn76M.d.cts +407 -0
- package/dist/ItemsInputNormalizer-CwdOhSAK.cjs +43 -0
- package/dist/ItemsInputNormalizer-CwdOhSAK.cjs.map +1 -0
- package/dist/ItemsInputNormalizer-D-MH8MBs.js +36 -0
- package/dist/ItemsInputNormalizer-D-MH8MBs.js.map +1 -0
- package/dist/ItemsInputNormalizer-_Mfcd3YU.d.ts +321 -0
- package/dist/RunIntentService-BVur7x9n.d.ts +285 -0
- package/dist/RunIntentService-CEF-sFfI.d.cts +206 -0
- package/dist/{RunIntentService-BqNjrksF.d.cts → agentMcpTypes-ZiNbNsEi.d.cts} +1717 -1809
- package/dist/bootstrap/index.cjs +4 -2
- package/dist/bootstrap/index.d.cts +8 -3
- package/dist/bootstrap/index.d.ts +6 -4
- package/dist/bootstrap/index.js +4 -2
- package/dist/{bootstrap-DtjQtuvi.cjs → bootstrap-BxuTFTLB.cjs} +41 -34
- package/dist/bootstrap-BxuTFTLB.cjs.map +1 -0
- package/dist/{bootstrap-BfFKGzyj.js → bootstrap-D_Yyi0wL.js} +9 -2
- package/dist/bootstrap-D_Yyi0wL.js.map +1 -0
- package/dist/browser.cjs +16 -0
- package/dist/browser.d.cts +4 -0
- package/dist/browser.d.ts +3 -0
- package/dist/browser.js +4 -0
- package/dist/contracts-CK0x6w_G.cjs +74 -0
- package/dist/contracts-CK0x6w_G.cjs.map +1 -0
- package/dist/contracts-DXdfTdpW.js +50 -0
- package/dist/contracts-DXdfTdpW.js.map +1 -0
- package/dist/contracts.cjs +6 -0
- package/dist/contracts.d.cts +5 -0
- package/dist/contracts.d.ts +2 -0
- package/dist/contracts.js +3 -0
- package/dist/di-0Wop7z1y.js +376 -0
- package/dist/di-0Wop7z1y.js.map +1 -0
- package/dist/di-BlEKdoZS.cjs +489 -0
- package/dist/di-BlEKdoZS.cjs.map +1 -0
- package/dist/executionPersistenceContracts-BgZMRsTa.d.cts +275 -0
- package/dist/{index-CJQtTY_M.d.ts → index-62Ba9f7D.d.ts} +114 -320
- package/dist/{RunIntentService-CI-F8qQ7.d.ts → index-zWGtEhrf.d.ts} +1811 -1914
- package/dist/index.cjs +76 -71
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +112 -656
- package/dist/index.d.ts +5 -3
- package/dist/index.js +52 -50
- package/dist/index.js.map +1 -1
- package/dist/params-B5SENSzZ.d.cts +44 -0
- package/dist/{runtime-_ywksLa6.cjs → runtime-DBzq5YBi.cjs} +125 -489
- package/dist/runtime-DBzq5YBi.cjs.map +1 -0
- package/dist/{runtime-DbMjpb5d.js → runtime-cxmUkk0l.js} +117 -369
- package/dist/runtime-cxmUkk0l.js.map +1 -0
- package/dist/testing.cjs +23 -21
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +4 -3
- package/dist/testing.d.ts +3 -2
- package/dist/testing.js +5 -3
- package/dist/testing.js.map +1 -1
- package/package.json +12 -17
- package/src/ai/AgentConnectionNodeCollector.ts +47 -5
- package/src/authoring/defineNode.types.ts +21 -1
- package/src/authoring/definePollingTrigger.types.ts +20 -0
- package/src/binaries/UnavailableBinaryStorage.ts +6 -0
- package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +9 -0
- package/src/browser.ts +1 -0
- package/src/contracts/AgentBindError.ts +11 -0
- package/src/contracts/CodemationTelemetryAttributeNames.ts +4 -0
- package/src/contracts/NoOpAgentMcpIntegration.ts +13 -0
- package/src/contracts/agentMcpTypes.ts +64 -0
- package/src/contracts/index.ts +4 -0
- package/src/contracts/mcpTypes.ts +29 -0
- package/src/contracts/runTypes.ts +8 -0
- package/src/contracts/runtimeTypes.ts +4 -0
- package/src/contracts/workflowTypes.ts +21 -0
- package/src/contracts.ts +3 -0
- package/src/credentials/OAuthFlowExecutor.types.ts +45 -0
- package/src/di/CoreTokens.ts +7 -0
- package/src/execution/InProcessRetryRunner.ts +31 -5
- package/src/execution/NodeExecutor.ts +27 -7
- package/src/execution/NodeRunStateWriter.ts +2 -0
- package/src/index.ts +10 -0
- package/src/orchestration/RunContinuationService.ts +6 -2
- package/src/runStorage/InMemoryBinaryStorageRegistry.ts +10 -0
- package/src/scheduler/InlineDrivingScheduler.ts +26 -22
- package/src/types/index.ts +1 -0
- package/src/validation/WorkflowEdgePortError.types.ts +16 -0
- package/src/validation/WorkflowEdgePortValidator.ts +52 -0
- package/src/workflow/definition/ConnectionInvocationIdFactory.ts +4 -3
- package/src/workflow/definition/ConnectionNodeIdFactory.ts +25 -0
- package/src/workflow/definition/NodeIterationIdFactory.ts +5 -3
- package/src/workflowSnapshots/WorkflowSnapshotCodec.ts +42 -10
- package/tsdown.config.ts +1 -1
- package/dist/bootstrap-BfFKGzyj.js.map +0 -1
- package/dist/bootstrap-DtjQtuvi.cjs.map +0 -1
- package/dist/runtime-DbMjpb5d.js.map +0 -1
- package/dist/runtime-_ywksLa6.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DependencyContainer as Container, DependencyContainer as DependencyContainer$1, Disposable, InjectionToken as InjectionToken$1, InjectionToken as TypeToken, Lifecycle, RegistrationOptions, container, delay, inject, injectAll, injectable, instanceCachingFactory, instancePerContainerCachingFactory, predicateAwareClassFactory, registry, singleton } from "tsyringe";
|
|
2
1
|
import { ReadableStream } from "node:stream/web";
|
|
3
2
|
import { ZodType } from "zod";
|
|
3
|
+
import { DependencyContainer as Container, DependencyContainer as DependencyContainer$1, Disposable, InjectionToken as InjectionToken$1, InjectionToken as TypeToken, Lifecycle, RegistrationOptions, container, delay, inject, injectAll, injectable, instanceCachingFactory, instancePerContainerCachingFactory, predicateAwareClassFactory, registry, singleton } from "tsyringe";
|
|
4
4
|
|
|
5
5
|
//#region src/contracts/baseTypes.d.ts
|
|
6
6
|
/**
|
|
@@ -15,2028 +15,1936 @@ type InputPortKey = string;
|
|
|
15
15
|
type PersistedTokenId = string;
|
|
16
16
|
type NodeConnectionName = string;
|
|
17
17
|
//#endregion
|
|
18
|
-
//#region src/
|
|
18
|
+
//#region src/triggers/polling/PollingTriggerDedupWindow.d.ts
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* Merges processed-ID windows for polling triggers, capping the total to avoid unbounded growth.
|
|
21
|
+
* Plugin code receives an instance of this class via {@link PollingTriggerHandle.dedup}.
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
declare class PollingTriggerDedupWindow {
|
|
24
|
+
static readonly defaultCapN = 2000;
|
|
25
|
+
merge(previous: ReadonlyArray<string>, incoming: ReadonlyArray<string>, capN?: number): ReadonlyArray<string>;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/triggers/polling/PollingTriggerLogger.d.ts
|
|
24
29
|
/**
|
|
25
|
-
*
|
|
26
|
-
* {@link
|
|
27
|
-
*
|
|
28
|
-
* the orchestrator pulls from the iterable they return and dispatches one run per item.
|
|
30
|
+
* Minimal logger surface for the polling-trigger runtime.
|
|
31
|
+
* Hosts supply this via {@link EngineDeps.pollingTriggerLogger};
|
|
32
|
+
* when absent the runtime is silent.
|
|
29
33
|
*/
|
|
30
|
-
interface
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
interface PollingTriggerLogger {
|
|
35
|
+
info(message: string): void;
|
|
36
|
+
warn(message: string): void;
|
|
37
|
+
error(message: string, exception?: Error): void;
|
|
38
|
+
debug(message: string): void;
|
|
39
|
+
}
|
|
40
|
+
declare class NoOpPollingTriggerLogger implements PollingTriggerLogger {
|
|
41
|
+
info(): void;
|
|
42
|
+
warn(): void;
|
|
43
|
+
error(): void;
|
|
44
|
+
debug(): void;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/contracts/credentialTypes.d.ts
|
|
48
|
+
type CredentialTypeId = string;
|
|
49
|
+
type CredentialInstanceId = string;
|
|
50
|
+
type CredentialMaterialSourceKind = "db" | "env" | "code";
|
|
51
|
+
type CredentialSetupStatus = "draft" | "ready";
|
|
52
|
+
type CredentialHealthStatus = "unknown" | "healthy" | "failing";
|
|
53
|
+
type CredentialFieldSchema = Readonly<{
|
|
54
|
+
key: string;
|
|
55
|
+
label: string;
|
|
56
|
+
type: "string" | "password" | "textarea" | "json" | "boolean";
|
|
57
|
+
required?: true;
|
|
58
|
+
order?: number;
|
|
35
59
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
60
|
+
* Where this field appears in the credential dialog. Use `"advanced"` for optional or
|
|
61
|
+
* power-user fields; they render inside a collapsible section (see `CredentialTypeDefinition.advancedSection`).
|
|
62
|
+
* Defaults to `"default"` when omitted.
|
|
39
63
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* A trigger config that emits **test cases**. Each item yielded by {@link generateItems}
|
|
46
|
-
* becomes one workflow run (with `executionOptions.testContext` set), so 10 yielded items
|
|
47
|
-
* → 10 runs marked under the same TestSuiteRun.
|
|
48
|
-
*
|
|
49
|
-
* The trigger is otherwise a normal {@link TriggerNodeConfig} (so the canvas treats it like
|
|
50
|
-
* any other trigger), but its `triggerKind` is `"test"` so the live activation policy skips it.
|
|
51
|
-
*/
|
|
52
|
-
interface TestTriggerNodeConfig<TOutputJson$1 = unknown> extends TriggerNodeConfig<TOutputJson$1, undefined> {
|
|
53
|
-
readonly triggerKind: "test";
|
|
64
|
+
visibility?: "default" | "advanced";
|
|
65
|
+
placeholder?: string;
|
|
66
|
+
helpText?: string;
|
|
67
|
+
/** When set, host resolves this field from process.env at runtime; env wins over stored values. */
|
|
68
|
+
envVarName?: string;
|
|
54
69
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* and dispatches one run per item, with concurrency capped by {@link concurrency} (default 4).
|
|
70
|
+
* When set, the dialog shows a copy action for this exact string (e.g. a static OAuth redirect URI
|
|
71
|
+
* pattern or documentation URL). Do not use for secret values.
|
|
58
72
|
*/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
|
|
73
|
+
copyValue?: string;
|
|
74
|
+
/** Accessible label for the copy control (default: Copy). */
|
|
75
|
+
copyButtonLabel?: string;
|
|
76
|
+
}>;
|
|
77
|
+
type CredentialRequirement = Readonly<{
|
|
78
|
+
slotKey: string;
|
|
79
|
+
label: string;
|
|
80
|
+
acceptedTypes: ReadonlyArray<CredentialTypeId>;
|
|
81
|
+
optional?: true;
|
|
82
|
+
helpText?: string;
|
|
83
|
+
helpUrl?: string;
|
|
84
|
+
}>;
|
|
85
|
+
type CredentialBindingKey = Readonly<{
|
|
86
|
+
workflowId: WorkflowId;
|
|
87
|
+
nodeId: NodeId;
|
|
88
|
+
slotKey: string;
|
|
89
|
+
}>;
|
|
90
|
+
type CredentialBinding = Readonly<{
|
|
91
|
+
key: CredentialBindingKey;
|
|
92
|
+
instanceId: CredentialInstanceId;
|
|
93
|
+
updatedAt: string;
|
|
94
|
+
}>;
|
|
95
|
+
type CredentialHealth = Readonly<{
|
|
96
|
+
status: CredentialHealthStatus;
|
|
97
|
+
message?: string;
|
|
98
|
+
testedAt?: string;
|
|
99
|
+
expiresAt?: string;
|
|
100
|
+
details?: Readonly<Record<string, unknown>>;
|
|
101
|
+
}>;
|
|
102
|
+
type OAuth2ProviderFromPublicConfig = Readonly<{
|
|
103
|
+
authorizeUrlFieldKey: string;
|
|
104
|
+
tokenUrlFieldKey: string;
|
|
105
|
+
userInfoUrlFieldKey?: string;
|
|
106
|
+
}>;
|
|
107
|
+
type CredentialOAuth2ScopesFromPublicConfig = Readonly<{
|
|
108
|
+
presetFieldKey: string;
|
|
109
|
+
presetScopes: Readonly<Record<string, ReadonlyArray<string>>>;
|
|
110
|
+
customPresetKey?: string;
|
|
111
|
+
customScopesFieldKey?: string;
|
|
112
|
+
}>;
|
|
113
|
+
type CredentialOAuth2AuthDefinition = Readonly<{
|
|
114
|
+
kind: "oauth2";
|
|
115
|
+
providerId: string;
|
|
116
|
+
scopes: ReadonlyArray<string>;
|
|
117
|
+
scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig;
|
|
118
|
+
clientIdFieldKey?: string;
|
|
119
|
+
clientSecretFieldKey?: string;
|
|
120
|
+
} | {
|
|
121
|
+
kind: "oauth2";
|
|
122
|
+
providerFromPublicConfig: OAuth2ProviderFromPublicConfig;
|
|
123
|
+
scopes: ReadonlyArray<string>;
|
|
124
|
+
scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig;
|
|
125
|
+
clientIdFieldKey?: string;
|
|
126
|
+
clientSecretFieldKey?: string;
|
|
127
|
+
} | {
|
|
128
|
+
kind: "oauth2";
|
|
62
129
|
/**
|
|
63
|
-
* Free-form
|
|
64
|
-
*
|
|
65
|
-
* remember which mailbox / folder / fixture file the cases originate from.
|
|
66
|
-
*
|
|
67
|
-
* Example: `"All emails in the Gmail label \"test/triage-fixtures\" — 14 messages as of 2026-05-03."`
|
|
130
|
+
* Free-form provider identifier for telemetry, DB rows, and Better Auth provider naming.
|
|
131
|
+
* Not used for any registry lookup — URLs come from {@link authorizeUrl} / {@link tokenUrl}.
|
|
68
132
|
*/
|
|
69
|
-
|
|
133
|
+
providerId: string;
|
|
70
134
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* `undefined` to fall back to "Case #N".
|
|
135
|
+
* Authorization endpoint. May contain `{publicFieldKey}` placeholders that the runtime
|
|
136
|
+
* substitutes from the credential's resolved public config (URL-encoded).
|
|
137
|
+
* Example: `https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/authorize`
|
|
75
138
|
*/
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
139
|
+
authorizeUrl: string;
|
|
140
|
+
/** Token endpoint. Same templating rules as {@link authorizeUrl}. */
|
|
141
|
+
tokenUrl: string;
|
|
142
|
+
/** Optional userinfo endpoint. Same templating rules as {@link authorizeUrl}. */
|
|
143
|
+
userInfoUrl?: string;
|
|
144
|
+
scopes: ReadonlyArray<string>;
|
|
145
|
+
scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig;
|
|
146
|
+
clientIdFieldKey?: string;
|
|
147
|
+
clientSecretFieldKey?: string;
|
|
148
|
+
}>;
|
|
149
|
+
type CredentialAuthDefinition = CredentialOAuth2AuthDefinition;
|
|
150
|
+
type CredentialAdvancedSectionPresentation = Readonly<{
|
|
151
|
+
/** Collapsible section title (default: "Advanced"). */
|
|
152
|
+
title?: string;
|
|
153
|
+
/** Optional short helper text shown inside the section (above the fields). */
|
|
154
|
+
description?: string;
|
|
155
|
+
/** When true, the advanced section starts expanded. Default: false (collapsed). */
|
|
156
|
+
defaultOpen?: boolean;
|
|
157
|
+
}>;
|
|
158
|
+
type CredentialTypeDefinition = Readonly<{
|
|
159
|
+
typeId: CredentialTypeId;
|
|
160
|
+
displayName: string;
|
|
161
|
+
description?: string;
|
|
162
|
+
publicFields?: ReadonlyArray<CredentialFieldSchema>;
|
|
163
|
+
secretFields?: ReadonlyArray<CredentialFieldSchema>;
|
|
164
|
+
/**
|
|
165
|
+
* Optional labels for the collapsible block that contains every field with `visibility: "advanced"`.
|
|
166
|
+
* If omitted, the UI still shows that block with defaults (title "Advanced", collapsed).
|
|
167
|
+
*/
|
|
168
|
+
advancedSection?: CredentialAdvancedSectionPresentation;
|
|
169
|
+
supportedSourceKinds?: ReadonlyArray<CredentialMaterialSourceKind>;
|
|
170
|
+
auth?: CredentialAuthDefinition;
|
|
171
|
+
}>;
|
|
80
172
|
/**
|
|
81
|
-
*
|
|
82
|
-
* - `running`: workflow still in flight
|
|
83
|
-
* - `succeeded`: workflow completed AND all assertions passed (or no assertions)
|
|
84
|
-
* - `failed`: workflow failed OR (workflow completed but ≥1 assertion failed)
|
|
85
|
-
* - `errored` / `cancelled`: workflow itself errored or was cancelled
|
|
173
|
+
* JSON-shaped credential field bag (public config, resolved secret material, etc.).
|
|
86
174
|
*/
|
|
87
|
-
type
|
|
88
|
-
/**
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
kind: "nodeQueued";
|
|
105
|
-
runId: RunId;
|
|
106
|
-
workflowId: WorkflowId;
|
|
107
|
-
parent?: ParentExecutionRef;
|
|
108
|
-
at: string;
|
|
109
|
-
snapshot: NodeExecutionSnapshot;
|
|
110
|
-
}> | Readonly<{
|
|
111
|
-
kind: "nodeStarted";
|
|
112
|
-
runId: RunId;
|
|
113
|
-
workflowId: WorkflowId;
|
|
114
|
-
parent?: ParentExecutionRef;
|
|
115
|
-
at: string;
|
|
116
|
-
snapshot: NodeExecutionSnapshot;
|
|
117
|
-
}> | Readonly<{
|
|
118
|
-
kind: "nodeCompleted";
|
|
119
|
-
runId: RunId;
|
|
120
|
-
workflowId: WorkflowId;
|
|
121
|
-
parent?: ParentExecutionRef;
|
|
122
|
-
at: string;
|
|
123
|
-
snapshot: NodeExecutionSnapshot;
|
|
124
|
-
}> | Readonly<{
|
|
125
|
-
kind: "nodeFailed";
|
|
126
|
-
runId: RunId;
|
|
127
|
-
workflowId: WorkflowId;
|
|
128
|
-
parent?: ParentExecutionRef;
|
|
129
|
-
at: string;
|
|
130
|
-
snapshot: NodeExecutionSnapshot;
|
|
131
|
-
}> | Readonly<{
|
|
132
|
-
kind: "connectionInvocationStarted";
|
|
133
|
-
runId: RunId;
|
|
134
|
-
workflowId: WorkflowId;
|
|
135
|
-
parent?: ParentExecutionRef;
|
|
136
|
-
at: string;
|
|
137
|
-
record: ConnectionInvocationRecord;
|
|
138
|
-
}> | Readonly<{
|
|
139
|
-
kind: "connectionInvocationCompleted";
|
|
140
|
-
runId: RunId;
|
|
141
|
-
workflowId: WorkflowId;
|
|
142
|
-
parent?: ParentExecutionRef;
|
|
143
|
-
at: string;
|
|
144
|
-
record: ConnectionInvocationRecord;
|
|
145
|
-
}> | Readonly<{
|
|
146
|
-
kind: "connectionInvocationFailed";
|
|
147
|
-
runId: RunId;
|
|
148
|
-
workflowId: WorkflowId;
|
|
149
|
-
parent?: ParentExecutionRef;
|
|
150
|
-
at: string;
|
|
151
|
-
record: ConnectionInvocationRecord;
|
|
152
|
-
}> | Readonly<{
|
|
153
|
-
kind: "testSuiteStarted";
|
|
154
|
-
testSuiteRunId: TestSuiteRunId;
|
|
155
|
-
workflowId: WorkflowId;
|
|
156
|
-
triggerNodeId: string;
|
|
157
|
-
triggerNodeName?: string;
|
|
158
|
-
concurrency: number;
|
|
159
|
-
at: string;
|
|
160
|
-
}> | Readonly<{
|
|
161
|
-
kind: "testSuiteFinished";
|
|
162
|
-
testSuiteRunId: TestSuiteRunId;
|
|
163
|
-
workflowId: WorkflowId;
|
|
164
|
-
status: TestSuiteRunStatus;
|
|
165
|
-
totalCases: number;
|
|
166
|
-
passedCases: number;
|
|
167
|
-
failedCases: number;
|
|
168
|
-
at: string;
|
|
169
|
-
}> | Readonly<{
|
|
170
|
-
kind: "testCaseStarted";
|
|
171
|
-
testSuiteRunId: TestSuiteRunId;
|
|
172
|
-
testCaseIndex: number;
|
|
173
|
-
runId: RunId;
|
|
174
|
-
workflowId: WorkflowId;
|
|
175
|
-
testCaseLabel?: string;
|
|
176
|
-
at: string;
|
|
177
|
-
}> | Readonly<{
|
|
178
|
-
kind: "testCaseCompleted";
|
|
179
|
-
testSuiteRunId: TestSuiteRunId;
|
|
180
|
-
testCaseIndex: number;
|
|
181
|
-
runId: RunId;
|
|
182
|
-
workflowId: WorkflowId;
|
|
183
|
-
status: TestCaseRunStatus;
|
|
184
|
-
at: string;
|
|
175
|
+
type CredentialJsonRecord = Readonly<Record<string, unknown>>;
|
|
176
|
+
/**
|
|
177
|
+
* Persisted credential instance with typed `publicConfig`.
|
|
178
|
+
* Hosts may specialize `secretRef` with a stricter union while remaining
|
|
179
|
+
* assignable here for session/test callbacks.
|
|
180
|
+
*/
|
|
181
|
+
type CredentialInstanceRecord<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord> = Readonly<{
|
|
182
|
+
instanceId: CredentialInstanceId;
|
|
183
|
+
typeId: CredentialTypeId;
|
|
184
|
+
displayName: string;
|
|
185
|
+
sourceKind: CredentialMaterialSourceKind;
|
|
186
|
+
publicConfig: TPublicConfig;
|
|
187
|
+
secretRef: CredentialJsonRecord;
|
|
188
|
+
tags: ReadonlyArray<string>;
|
|
189
|
+
setupStatus: CredentialSetupStatus;
|
|
190
|
+
createdAt: string;
|
|
191
|
+
updatedAt: string;
|
|
185
192
|
}>;
|
|
186
|
-
|
|
187
|
-
|
|
193
|
+
/**
|
|
194
|
+
* Arguments passed to `CredentialType.createSession` and `CredentialType.test`.
|
|
195
|
+
* Declare `TPublicConfig` / `TMaterial` on `CredentialType` so implementations are checked
|
|
196
|
+
* against your credential shapes (similar to `NodeExecutionContext.config` for nodes).
|
|
197
|
+
*/
|
|
198
|
+
type CredentialSessionFactoryArgs<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord> = Readonly<{
|
|
199
|
+
instance: CredentialInstanceRecord<TPublicConfig>;
|
|
200
|
+
material: TMaterial;
|
|
201
|
+
publicConfig: TPublicConfig;
|
|
202
|
+
}>;
|
|
203
|
+
type CredentialSessionFactory<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord, TSession = unknown> = (args: CredentialSessionFactoryArgs<TPublicConfig, TMaterial>) => Promise<TSession>;
|
|
204
|
+
type CredentialHealthTester<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord> = (args: CredentialSessionFactoryArgs<TPublicConfig, TMaterial>) => Promise<CredentialHealth>;
|
|
205
|
+
/**
|
|
206
|
+
* Full credential type implementation: `definition` (UI/schema), `createSession`, and `test`.
|
|
207
|
+
* Use this at registration and config boundaries; `CredentialTypeDefinition` is only the schema slice.
|
|
208
|
+
*/
|
|
209
|
+
type CredentialType<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord, TSession = unknown> = Readonly<{
|
|
210
|
+
definition: CredentialTypeDefinition;
|
|
211
|
+
createSession: CredentialSessionFactory<TPublicConfig, TMaterial, TSession>;
|
|
212
|
+
test: CredentialHealthTester<TPublicConfig, TMaterial>;
|
|
213
|
+
}>;
|
|
214
|
+
/**
|
|
215
|
+
* Credential type with unspecified generics — used for `CodemationConfig.credentialTypes`, the host registry,
|
|
216
|
+
* and anywhere a concrete `CredentialType<YourPublic, YourMaterial, YourSession>` is placed in a heterogeneous list.
|
|
217
|
+
* Using `any` here avoids unsafe `as` casts while keeping typed `satisfies CredentialType<…>` definitions.
|
|
218
|
+
*/
|
|
219
|
+
type AnyCredentialType = CredentialType<any, any, unknown>;
|
|
220
|
+
interface CredentialSessionService {
|
|
221
|
+
getSession<TSession = unknown>(args: Readonly<{
|
|
222
|
+
workflowId: WorkflowId;
|
|
223
|
+
nodeId: NodeId;
|
|
224
|
+
slotKey: string;
|
|
225
|
+
}>): Promise<TSession>;
|
|
188
226
|
}
|
|
189
|
-
interface
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
subscribeToWorkflow(workflowId: WorkflowId, onEvent: (event: RunEvent) => void): Promise<RunEventSubscription>;
|
|
227
|
+
interface CredentialTypeRegistry {
|
|
228
|
+
listTypes(): ReadonlyArray<CredentialTypeDefinition>;
|
|
229
|
+
getType(typeId: CredentialTypeId): CredentialTypeDefinition | undefined;
|
|
193
230
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
readonly defaultMaxSubworkflowDepth: number;
|
|
200
|
-
readonly hardMaxSubworkflowDepth: number;
|
|
231
|
+
declare class CredentialUnboundError extends Error {
|
|
232
|
+
readonly bindingKey: CredentialBindingKey;
|
|
233
|
+
readonly acceptedTypes: ReadonlyArray<CredentialTypeId>;
|
|
234
|
+
constructor(bindingKey: CredentialBindingKey, acceptedTypes?: ReadonlyArray<CredentialTypeId>);
|
|
235
|
+
private static createMessage;
|
|
201
236
|
}
|
|
202
|
-
|
|
203
|
-
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region src/contracts/collectionTypes.d.ts
|
|
204
239
|
/**
|
|
205
|
-
*
|
|
240
|
+
* Represents a typed store for a single collection.
|
|
241
|
+
* All rows include auto-managed id, created_at, and updated_at fields.
|
|
206
242
|
*/
|
|
207
|
-
|
|
208
|
-
private readonly config;
|
|
209
|
-
constructor(config?: EngineExecutionLimitsPolicyConfig);
|
|
243
|
+
interface CollectionStore<TRow extends Record<string, unknown> = Record<string, unknown>> {
|
|
210
244
|
/**
|
|
211
|
-
*
|
|
212
|
-
* Replaces a separate one-method factory for root-run bootstrap.
|
|
245
|
+
* Insert a new row. id, created_at, and updated_at are auto-populated.
|
|
213
246
|
*/
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
247
|
+
insert(row: TRow): Promise<TRow & {
|
|
248
|
+
id: string;
|
|
249
|
+
created_at: Date;
|
|
250
|
+
updated_at: Date;
|
|
251
|
+
}>;
|
|
252
|
+
/**
|
|
253
|
+
* Get a single row by id.
|
|
254
|
+
*/
|
|
255
|
+
get(id: string): Promise<(TRow & {
|
|
256
|
+
id: string;
|
|
257
|
+
created_at: Date;
|
|
258
|
+
updated_at: Date;
|
|
259
|
+
}) | null>;
|
|
260
|
+
/**
|
|
261
|
+
* Find a single row matching the provided filter.
|
|
262
|
+
*/
|
|
263
|
+
findOne(filter: Partial<TRow>): Promise<(TRow & {
|
|
264
|
+
id: string;
|
|
265
|
+
created_at: Date;
|
|
266
|
+
updated_at: Date;
|
|
267
|
+
}) | null>;
|
|
268
|
+
/**
|
|
269
|
+
* List rows with optional pagination and filtering.
|
|
270
|
+
*/
|
|
271
|
+
list(opts?: {
|
|
272
|
+
limit?: number;
|
|
273
|
+
offset?: number;
|
|
274
|
+
where?: Partial<TRow>;
|
|
275
|
+
}): Promise<{
|
|
276
|
+
rows: ReadonlyArray<TRow & {
|
|
277
|
+
id: string;
|
|
278
|
+
created_at: Date;
|
|
279
|
+
updated_at: Date;
|
|
280
|
+
}>;
|
|
281
|
+
total: number;
|
|
282
|
+
}>;
|
|
283
|
+
/**
|
|
284
|
+
* Update a row by id with partial data.
|
|
285
|
+
*/
|
|
286
|
+
update(id: string, patch: Partial<TRow>): Promise<TRow & {
|
|
287
|
+
id: string;
|
|
288
|
+
created_at: Date;
|
|
289
|
+
updated_at: Date;
|
|
290
|
+
}>;
|
|
291
|
+
/**
|
|
292
|
+
* Delete a row by id. Hard delete only (no soft delete).
|
|
293
|
+
*/
|
|
294
|
+
delete(id: string): Promise<{
|
|
295
|
+
deleted: boolean;
|
|
296
|
+
}>;
|
|
217
297
|
}
|
|
218
|
-
//#endregion
|
|
219
|
-
//#region src/di/CoreTokens.d.ts
|
|
220
|
-
declare const CoreTokens: {
|
|
221
|
-
readonly PersistedWorkflowTokenRegistry: TypeToken<PersistedWorkflowTokenRegistryLike>;
|
|
222
|
-
readonly CredentialSessionService: TypeToken<CredentialSessionService>;
|
|
223
|
-
readonly CredentialTypeRegistry: TypeToken<CredentialTypeRegistry>;
|
|
224
|
-
readonly WorkflowRunnerService: TypeToken<WorkflowRunnerService>;
|
|
225
|
-
readonly LiveWorkflowRepository: TypeToken<LiveWorkflowRepository>;
|
|
226
|
-
readonly WorkflowRepository: TypeToken<WorkflowRepository>;
|
|
227
|
-
readonly NodeResolver: TypeToken<NodeResolver>;
|
|
228
|
-
readonly WorkflowNodeInstanceFactory: TypeToken<WorkflowNodeInstanceFactory>;
|
|
229
|
-
readonly RunIdFactory: TypeToken<RunIdFactory>;
|
|
230
|
-
readonly ActivationIdFactory: TypeToken<ActivationIdFactory>;
|
|
231
|
-
readonly WorkflowExecutionRepository: TypeToken<WorkflowExecutionRepository>;
|
|
232
|
-
readonly TriggerSetupStateRepository: TypeToken<TriggerSetupStateRepository>;
|
|
233
|
-
readonly NodeActivationScheduler: TypeToken<NodeActivationScheduler>;
|
|
234
|
-
readonly RunDataFactory: TypeToken<RunDataFactory>;
|
|
235
|
-
readonly ExecutionContextFactory: TypeToken<ExecutionContextFactory>;
|
|
236
|
-
readonly RunEventBus: TypeToken<RunEventBus>;
|
|
237
|
-
readonly BinaryStorage: TypeToken<BinaryStorage>;
|
|
238
|
-
readonly WebhookBasePath: TypeToken<string>;
|
|
239
|
-
/** Engine execution limits (defaults + optional host overrides). Consumers may bind a custom instance to override. */
|
|
240
|
-
readonly EngineExecutionLimitsPolicy: TypeToken<EngineExecutionLimitsPolicy>;
|
|
241
|
-
readonly WorkflowActivationPolicy: TypeToken<WorkflowActivationPolicy>;
|
|
242
|
-
};
|
|
243
|
-
//#endregion
|
|
244
|
-
//#region src/contracts/runTypes.d.ts
|
|
245
298
|
/**
|
|
246
|
-
*
|
|
247
|
-
* as one test case inside a TestSuiteRun. The `IsTestRun` node and host-side persisters key
|
|
248
|
-
* off the presence of this field. Subworkflow runs inherit it from their parent run.
|
|
299
|
+
* Runtime collections context: keyed by collection name.
|
|
249
300
|
*/
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
readonly
|
|
301
|
+
type CollectionsContext = Readonly<Record<string, CollectionStore>>;
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region src/contracts/CostTrackingTelemetryContract.d.ts
|
|
304
|
+
type CostTrackingComponent = "chat" | "ocr" | "rag";
|
|
305
|
+
declare const CostTrackingTelemetryMetricNames: {
|
|
306
|
+
readonly usage: "codemation.cost.usage";
|
|
307
|
+
readonly estimatedCost: "codemation.cost.estimated";
|
|
308
|
+
};
|
|
309
|
+
declare const CostTrackingTelemetryAttributeNames: {
|
|
310
|
+
readonly component: "cost.component";
|
|
311
|
+
readonly provider: "cost.provider";
|
|
312
|
+
readonly operation: "cost.operation";
|
|
313
|
+
readonly pricingKey: "cost.pricing_key";
|
|
314
|
+
readonly usageUnit: "cost.usage_unit";
|
|
315
|
+
readonly currency: "cost.currency";
|
|
316
|
+
readonly currencyScale: "cost.currency_scale";
|
|
317
|
+
readonly estimateKind: "cost.estimate_kind";
|
|
318
|
+
};
|
|
319
|
+
interface CostTrackingUsageRecord {
|
|
320
|
+
readonly component: CostTrackingComponent;
|
|
321
|
+
readonly provider: string;
|
|
322
|
+
readonly operation: string;
|
|
323
|
+
readonly pricingKey: string;
|
|
324
|
+
readonly usageUnit: string;
|
|
325
|
+
readonly quantity: number;
|
|
326
|
+
readonly modelName?: string;
|
|
327
|
+
readonly attributes?: TelemetryAttributes;
|
|
260
328
|
}
|
|
261
|
-
interface
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
mode?: "manual" | "debug";
|
|
267
|
-
sourceWorkflowId?: WorkflowId;
|
|
268
|
-
sourceRunId?: RunId;
|
|
269
|
-
derivedFromRunId?: RunId;
|
|
270
|
-
isMutable?: boolean;
|
|
271
|
-
/** Set by the engine for this run: 0 = root, 1 = first child subworkflow, … */
|
|
272
|
-
subworkflowDepth?: number;
|
|
273
|
-
/** Effective cap after engine policy merge (successful node completions per run). */
|
|
274
|
-
maxNodeActivations?: number;
|
|
275
|
-
/** Effective cap after engine policy merge (subworkflow nesting). */
|
|
276
|
-
maxSubworkflowDepth?: number;
|
|
277
|
-
/** Present iff started by a TestSuiteOrchestrator; propagates to subworkflow runs via {@link ParentExecutionRef.testContext}. */
|
|
278
|
-
testContext?: RunTestContext;
|
|
329
|
+
interface CostTrackingPriceQuote {
|
|
330
|
+
readonly currency: string;
|
|
331
|
+
readonly currencyScale: number;
|
|
332
|
+
readonly estimatedAmountMinor: number;
|
|
333
|
+
readonly estimateKind: "catalog";
|
|
279
334
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
335
|
+
interface CostTrackingTelemetry {
|
|
336
|
+
captureUsage(args: CostTrackingUsageRecord): Promise<CostTrackingPriceQuote | undefined>;
|
|
337
|
+
forScope(scope: TelemetryScope): CostTrackingTelemetry;
|
|
283
338
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
nodeId: NodeId;
|
|
289
|
-
}>;
|
|
290
|
-
interface RunStateResetRequest {
|
|
291
|
-
clearFromNodeId: NodeId;
|
|
339
|
+
interface CostTrackingTelemetryFactory {
|
|
340
|
+
create(args: Readonly<{
|
|
341
|
+
telemetry: ExecutionTelemetry;
|
|
342
|
+
}>): CostTrackingTelemetry;
|
|
292
343
|
}
|
|
293
|
-
|
|
294
|
-
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region src/contracts/NoOpTelemetryArtifactReference.d.ts
|
|
346
|
+
declare class NoOpTelemetryArtifactReference {
|
|
347
|
+
static readonly value: TelemetryArtifactReference;
|
|
295
348
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
tokenName?: string;
|
|
303
|
-
configTokenName?: string;
|
|
304
|
-
config: unknown;
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region src/contracts/NoOpTelemetrySpanScope.d.ts
|
|
351
|
+
declare class NoOpTelemetrySpanScope {
|
|
352
|
+
static readonly value: TelemetrySpanScope;
|
|
353
|
+
/** Internal: the shared no-op {@link NodeExecutionTelemetry} that {@link NoOpNodeExecutionTelemetry} re-exposes. */
|
|
354
|
+
static readonly nodeExecutionTelemetryValue: NodeExecutionTelemetry;
|
|
305
355
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
edges: ReadonlyArray<Edge>;
|
|
311
|
-
/** When the snapshot was built from a live workflow definition that configured a workflow error handler. */
|
|
312
|
-
workflowErrorHandlerConfigured?: boolean;
|
|
313
|
-
/** Connection metadata for child nodes not in the execution graph (e.g. AI agent attachments). */
|
|
314
|
-
connections?: ReadonlyArray<WorkflowNodeConnection>;
|
|
356
|
+
//#endregion
|
|
357
|
+
//#region src/contracts/NoOpNodeExecutionTelemetry.d.ts
|
|
358
|
+
declare class NoOpNodeExecutionTelemetry {
|
|
359
|
+
static readonly value: NodeExecutionTelemetry;
|
|
315
360
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
361
|
+
//#endregion
|
|
362
|
+
//#region src/contracts/NoOpExecutionTelemetry.d.ts
|
|
363
|
+
declare class NoOpExecutionTelemetry {
|
|
364
|
+
static readonly value: ExecutionTelemetry;
|
|
320
365
|
}
|
|
321
|
-
|
|
322
|
-
|
|
366
|
+
//#endregion
|
|
367
|
+
//#region src/contracts/NoOpExecutionTelemetryFactory.d.ts
|
|
368
|
+
declare class NoOpExecutionTelemetryFactory implements ExecutionTelemetryFactory {
|
|
369
|
+
create(_: Readonly<{
|
|
370
|
+
runId: RunId;
|
|
371
|
+
workflowId: WorkflowId;
|
|
372
|
+
parent?: ParentExecutionRef;
|
|
373
|
+
policySnapshot?: PersistedRunPolicySnapshot;
|
|
374
|
+
}>): ExecutionTelemetry;
|
|
323
375
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region src/contracts/CodemationTelemetryAttributeNames.d.ts
|
|
378
|
+
declare class CodemationTelemetryAttributeNames {
|
|
379
|
+
static readonly workflowId = "codemation.workflow.id";
|
|
380
|
+
static readonly runId = "codemation.run.id";
|
|
381
|
+
static readonly nodeId = "codemation.node.id";
|
|
382
|
+
static readonly activationId = "codemation.activation.id";
|
|
383
|
+
static readonly nodeType = "codemation.node.type";
|
|
384
|
+
static readonly nodeRole = "codemation.node.role";
|
|
385
|
+
static readonly workflowFolder = "codemation.workflow.folder";
|
|
386
|
+
static readonly connectionInvocationId = "codemation.connection.invocation_id";
|
|
387
|
+
static readonly toolName = "codemation.tool.name";
|
|
388
|
+
static readonly traceParentRunId = "codemation.parent.run.id";
|
|
389
|
+
/** Per-item iteration that emitted this span/metric. Set on spans recorded inside a runnable per-item loop. */
|
|
390
|
+
static readonly iterationId = "codemation.iteration.id";
|
|
391
|
+
/** Item index (0-based) of the iteration. */
|
|
392
|
+
static readonly iterationIndex = "codemation.iteration.index";
|
|
393
|
+
/** Set when this span/metric was recorded under a sub-agent triggered by an outer LLM/tool call. */
|
|
394
|
+
static readonly parentInvocationId = "codemation.parent.invocation_id";
|
|
395
|
+
/** MCP server id on spans created for callTool invocations. */
|
|
396
|
+
static readonly mcpServerId = "mcp.server_id";
|
|
397
|
+
/** MCP tool name on spans created for callTool invocations. */
|
|
398
|
+
static readonly mcpToolName = "mcp.tool_name";
|
|
338
399
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
name
|
|
343
|
-
|
|
344
|
-
|
|
400
|
+
//#endregion
|
|
401
|
+
//#region src/contracts/GenAiTelemetryAttributeNames.d.ts
|
|
402
|
+
declare class GenAiTelemetryAttributeNames {
|
|
403
|
+
static readonly operationName = "gen_ai.operation.name";
|
|
404
|
+
static readonly requestModel = "gen_ai.request.model";
|
|
405
|
+
static readonly usageInputTokens = "gen_ai.usage.input_tokens";
|
|
406
|
+
static readonly usageOutputTokens = "gen_ai.usage.output_tokens";
|
|
407
|
+
static readonly usageTotalTokens = "gen_ai.usage.total_tokens";
|
|
408
|
+
static readonly usageCacheReadInputTokens = "gen_ai.usage.cache_read.input_tokens";
|
|
409
|
+
static readonly usageCacheCreationInputTokens = "gen_ai.usage.cache_creation.input_tokens";
|
|
410
|
+
static readonly usageReasoningTokens = "codemation.gen_ai.usage.reasoning_tokens";
|
|
345
411
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
412
|
+
//#endregion
|
|
413
|
+
//#region src/contracts/CodemationTelemetryMetricNames.d.ts
|
|
414
|
+
declare class CodemationTelemetryMetricNames {
|
|
415
|
+
static readonly agentTurns = "codemation.ai.turns";
|
|
416
|
+
static readonly agentToolCalls = "codemation.ai.tool_calls";
|
|
417
|
+
static readonly gmailMessagesEmitted = "codemation.gmail.messages_emitted";
|
|
418
|
+
static readonly gmailAttachments = "codemation.gmail.attachments";
|
|
419
|
+
static readonly gmailAttachmentBytes = "codemation.gmail.attachment_bytes";
|
|
420
|
+
}
|
|
421
|
+
//#endregion
|
|
422
|
+
//#region src/contracts/telemetryTypes.d.ts
|
|
423
|
+
type TelemetryAttributePrimitive = string | number | boolean | null;
|
|
424
|
+
interface TelemetryAttributes {
|
|
425
|
+
readonly [key: string]: TelemetryAttributePrimitive | undefined;
|
|
426
|
+
}
|
|
427
|
+
interface TelemetryMetricRecord {
|
|
428
|
+
readonly name: string;
|
|
429
|
+
readonly value: number;
|
|
430
|
+
readonly unit?: string;
|
|
431
|
+
readonly attributes?: TelemetryAttributes;
|
|
432
|
+
}
|
|
433
|
+
interface TelemetrySpanEventRecord {
|
|
434
|
+
readonly name: string;
|
|
435
|
+
readonly occurredAt?: Date;
|
|
436
|
+
readonly attributes?: TelemetryAttributes;
|
|
437
|
+
}
|
|
438
|
+
interface TelemetryArtifactAttachment {
|
|
439
|
+
readonly kind: string;
|
|
440
|
+
readonly contentType: string;
|
|
441
|
+
readonly previewText?: string;
|
|
442
|
+
readonly previewJson?: JsonValue;
|
|
443
|
+
readonly payloadText?: string;
|
|
444
|
+
readonly payloadJson?: JsonValue;
|
|
445
|
+
readonly bytes?: number;
|
|
446
|
+
readonly truncated?: boolean;
|
|
447
|
+
readonly expiresAt?: Date;
|
|
448
|
+
}
|
|
449
|
+
interface TelemetryArtifactReference {
|
|
450
|
+
readonly artifactId: string;
|
|
451
|
+
readonly traceId?: string;
|
|
452
|
+
readonly spanId?: string;
|
|
453
|
+
}
|
|
454
|
+
interface TelemetrySpanEnd {
|
|
455
|
+
readonly status?: "ok" | "error";
|
|
456
|
+
readonly statusMessage?: string;
|
|
457
|
+
readonly endedAt?: Date;
|
|
458
|
+
readonly attributes?: TelemetryAttributes;
|
|
459
|
+
}
|
|
460
|
+
interface TelemetryChildSpanStart {
|
|
461
|
+
readonly name: string;
|
|
462
|
+
readonly kind?: "internal" | "client";
|
|
463
|
+
readonly startedAt?: Date;
|
|
464
|
+
readonly attributes?: TelemetryAttributes;
|
|
465
|
+
}
|
|
466
|
+
interface TelemetryScope {
|
|
467
|
+
readonly traceId?: string;
|
|
468
|
+
readonly spanId?: string;
|
|
469
|
+
readonly costTracking?: CostTrackingTelemetry;
|
|
470
|
+
addSpanEvent(args: TelemetrySpanEventRecord): Promise<void> | void;
|
|
471
|
+
recordMetric(args: TelemetryMetricRecord): Promise<void> | void;
|
|
472
|
+
attachArtifact(args: TelemetryArtifactAttachment): Promise<TelemetryArtifactReference> | TelemetryArtifactReference;
|
|
473
|
+
}
|
|
474
|
+
interface TelemetrySpanScope extends TelemetryScope {
|
|
475
|
+
readonly traceId: string;
|
|
476
|
+
readonly spanId: string;
|
|
477
|
+
end(args?: TelemetrySpanEnd): Promise<void> | void;
|
|
361
478
|
/**
|
|
362
|
-
*
|
|
363
|
-
*
|
|
479
|
+
* Lift this span into a {@link NodeExecutionTelemetry} scoped to a different (nodeId, activationId).
|
|
480
|
+
* Children created via the returned telemetry's `startChildSpan` get this span as their parent.
|
|
481
|
+
*
|
|
482
|
+
* Used at the sub-agent boundary so that nested runtime telemetry parents under the agent.tool.call
|
|
483
|
+
* span instead of the orchestrator's node-level span.
|
|
364
484
|
*/
|
|
365
|
-
|
|
485
|
+
asNodeTelemetry(args: Readonly<{
|
|
486
|
+
nodeId: NodeId;
|
|
487
|
+
activationId: NodeActivationId;
|
|
488
|
+
}>): NodeExecutionTelemetry;
|
|
366
489
|
}
|
|
367
|
-
|
|
368
|
-
|
|
490
|
+
interface NodeExecutionTelemetry extends ExecutionTelemetry, TelemetrySpanScope {
|
|
491
|
+
startChildSpan(args: TelemetryChildSpanStart): TelemetrySpanScope;
|
|
492
|
+
}
|
|
493
|
+
interface ExecutionTelemetry extends TelemetryScope {
|
|
494
|
+
readonly traceId: string;
|
|
495
|
+
readonly spanId: string;
|
|
496
|
+
forNode(args: Readonly<{
|
|
497
|
+
nodeId: NodeId;
|
|
498
|
+
activationId: NodeActivationId;
|
|
499
|
+
}>): NodeExecutionTelemetry;
|
|
500
|
+
}
|
|
501
|
+
interface ExecutionTelemetryFactory {
|
|
502
|
+
create(args: Readonly<{
|
|
503
|
+
runId: RunId;
|
|
504
|
+
workflowId: WorkflowId;
|
|
505
|
+
parent?: ParentExecutionRef;
|
|
506
|
+
policySnapshot?: PersistedRunPolicySnapshot;
|
|
507
|
+
}>): ExecutionTelemetry;
|
|
508
|
+
}
|
|
509
|
+
//#endregion
|
|
510
|
+
//#region src/contracts/workflowActivationPolicy.d.ts
|
|
369
511
|
/**
|
|
370
|
-
*
|
|
371
|
-
*
|
|
512
|
+
* Host-controlled policy: when false, trigger {@link TriggerNode} setup is skipped and webhook routes
|
|
513
|
+
* for that workflow are not registered (see engine trigger runtime + webhook matcher).
|
|
372
514
|
*/
|
|
373
|
-
interface
|
|
374
|
-
|
|
375
|
-
readonly runId: RunId;
|
|
376
|
-
readonly workflowId: WorkflowId;
|
|
377
|
-
readonly connectionNodeId: NodeId;
|
|
378
|
-
readonly parentAgentNodeId: NodeId;
|
|
379
|
-
readonly parentAgentActivationId: NodeActivationId;
|
|
380
|
-
readonly status: NodeExecutionStatus;
|
|
381
|
-
readonly managedInput?: JsonValue;
|
|
382
|
-
readonly managedOutput?: JsonValue;
|
|
383
|
-
readonly error?: NodeExecutionError;
|
|
384
|
-
readonly queuedAt?: string;
|
|
385
|
-
readonly startedAt?: string;
|
|
386
|
-
readonly finishedAt?: string;
|
|
387
|
-
readonly updatedAt: string;
|
|
388
|
-
/** Per-item iteration id minted by the engine when this invocation occurred inside a runnable node's per-item loop. */
|
|
389
|
-
readonly iterationId?: NodeIterationId;
|
|
390
|
-
/** Item index (0-based) of the iteration that produced this invocation. */
|
|
391
|
-
readonly itemIndex?: number;
|
|
392
|
-
/** When set, this invocation was produced inside a sub-agent triggered by the named parent invocation. */
|
|
393
|
-
readonly parentInvocationId?: ConnectionInvocationId;
|
|
394
|
-
}
|
|
395
|
-
/** Arguments for appending a {@link ConnectionInvocationRecord} (engine fills run/workflow ids and timestamps). */
|
|
396
|
-
type ConnectionInvocationAppendArgs = Readonly<{
|
|
397
|
-
invocationId: ConnectionInvocationId;
|
|
398
|
-
connectionNodeId: NodeId;
|
|
399
|
-
parentAgentNodeId: NodeId;
|
|
400
|
-
parentAgentActivationId: NodeActivationId;
|
|
401
|
-
status: NodeExecutionStatus;
|
|
402
|
-
managedInput?: JsonValue;
|
|
403
|
-
managedOutput?: JsonValue;
|
|
404
|
-
error?: NodeExecutionError;
|
|
405
|
-
queuedAt?: string;
|
|
406
|
-
startedAt?: string;
|
|
407
|
-
finishedAt?: string;
|
|
408
|
-
iterationId?: NodeIterationId;
|
|
409
|
-
itemIndex?: number;
|
|
410
|
-
parentInvocationId?: ConnectionInvocationId;
|
|
411
|
-
}>;
|
|
412
|
-
interface RunCurrentState {
|
|
413
|
-
outputsByNode: Record<NodeId, NodeOutputs>;
|
|
414
|
-
nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
|
|
415
|
-
/** Append-only history of connection-scoped invocations (LLM/tool) for inspector and canvas. */
|
|
416
|
-
connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
|
|
417
|
-
mutableState?: PersistedMutableRunState;
|
|
515
|
+
interface WorkflowActivationPolicy {
|
|
516
|
+
isActive(workflowId: WorkflowId): boolean;
|
|
418
517
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
parent?: ParentExecutionRef;
|
|
423
|
-
executionOptions?: RunExecutionOptions;
|
|
424
|
-
workflowSnapshot?: PersistedWorkflowSnapshot;
|
|
425
|
-
mutableState?: PersistedMutableRunState;
|
|
426
|
-
currentState?: RunCurrentState;
|
|
427
|
-
stopCondition?: RunStopCondition;
|
|
428
|
-
reset?: RunStateResetRequest;
|
|
518
|
+
/** Default for tests and harnesses: every workflow is treated as active (legacy behavior). */
|
|
519
|
+
declare class AllWorkflowsActiveWorkflowActivationPolicy implements WorkflowActivationPolicy {
|
|
520
|
+
isActive(_workflowId: WorkflowId): boolean;
|
|
429
521
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
clearedNodeIds: ReadonlyArray<NodeId>;
|
|
439
|
-
preservedPinnedNodeIds: ReadonlyArray<NodeId>;
|
|
522
|
+
//#endregion
|
|
523
|
+
//#region src/contracts/webhookTypes.d.ts
|
|
524
|
+
type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
525
|
+
interface WebhookControlSignal {
|
|
526
|
+
readonly __webhookControl: true;
|
|
527
|
+
readonly kind: "respondNow" | "respondNowAndContinue";
|
|
528
|
+
readonly responseItems: Items;
|
|
529
|
+
readonly continueItems?: Items;
|
|
440
530
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
startedAt: string;
|
|
446
|
-
status: RunStatus;
|
|
447
|
-
/**
|
|
448
|
-
* Test-case status for runs dispatched as part of a TestSuiteRun. Carries the
|
|
449
|
-
* assertion-rollup-corrected outcome the test orchestrator persists onto the row, so the
|
|
450
|
-
* executions list can show "failed" for a run whose workflow completed cleanly but whose
|
|
451
|
-
* assertions caught regressions. Absent for non-test runs and legacy rows.
|
|
452
|
-
*/
|
|
453
|
-
testCaseStatus?: TestCaseRunStatus;
|
|
454
|
-
/** ISO timestamp when the run finished (derived from node snapshots or store `updatedAt`); omit while running/pending. */
|
|
455
|
-
finishedAt?: string;
|
|
456
|
-
parent?: ParentExecutionRef;
|
|
457
|
-
executionOptions?: RunExecutionOptions;
|
|
531
|
+
interface WebhookTriggerRoutingDiagnostics {
|
|
532
|
+
warn(message: string): void;
|
|
533
|
+
/** Inactive workflows omitted from the webhook route index (optional; host should wire for clarity at boot/reload). */
|
|
534
|
+
info?(message: string): void;
|
|
458
535
|
}
|
|
459
|
-
interface
|
|
460
|
-
runId: RunId;
|
|
461
|
-
activationId: NodeActivationId;
|
|
536
|
+
interface TriggerInstanceId {
|
|
462
537
|
workflowId: WorkflowId;
|
|
463
538
|
nodeId: NodeId;
|
|
464
|
-
itemsIn: number;
|
|
465
|
-
inputsByPort: NodeInputsByPort;
|
|
466
|
-
receiptId: string;
|
|
467
|
-
queue?: string;
|
|
468
|
-
batchId?: string;
|
|
469
|
-
enqueuedAt: string;
|
|
470
|
-
}
|
|
471
|
-
interface PersistedRunSchedulingState {
|
|
472
|
-
pending?: PendingNodeExecution;
|
|
473
|
-
queue: RunQueueEntry[];
|
|
474
539
|
}
|
|
475
|
-
|
|
476
|
-
|
|
540
|
+
/** Match for an incoming HTTP request: user-defined URL segment + workflow trigger node. */
|
|
541
|
+
interface WebhookInvocationMatch {
|
|
542
|
+
/** Same value as the webhook trigger's configured endpoint key (URL segment under the webhook base path). */
|
|
543
|
+
endpointPath: string;
|
|
477
544
|
workflowId: WorkflowId;
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
/** Optimistic concurrency / CAS on the run aggregate (repository may increment on save). */
|
|
482
|
-
revision?: number;
|
|
483
|
-
parent?: ParentExecutionRef;
|
|
484
|
-
executionOptions?: RunExecutionOptions;
|
|
485
|
-
control?: PersistedRunControlState;
|
|
486
|
-
workflowSnapshot?: PersistedWorkflowSnapshot;
|
|
487
|
-
mutableState?: PersistedMutableRunState;
|
|
488
|
-
/** Frozen at createRun from workflow + runtime defaults for prune/storage decisions. */
|
|
489
|
-
policySnapshot?: PersistedRunPolicySnapshot;
|
|
490
|
-
/** Successful node completions so far (for activation budget). */
|
|
491
|
-
engineCounters?: EngineRunCounters;
|
|
492
|
-
status: RunStatus;
|
|
493
|
-
pending?: PendingNodeExecution;
|
|
494
|
-
queue: RunQueueEntry[];
|
|
495
|
-
outputsByNode: Record<NodeId, NodeOutputs>;
|
|
496
|
-
nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
|
|
497
|
-
/** Append-only history of connection invocations (LLM/tool) nested under owning nodes. */
|
|
498
|
-
connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
|
|
499
|
-
}
|
|
500
|
-
interface WorkflowExecutionRepository {
|
|
501
|
-
createRun(args: {
|
|
502
|
-
runId: RunId;
|
|
503
|
-
workflowId: WorkflowId;
|
|
504
|
-
startedAt: string;
|
|
505
|
-
parent?: ParentExecutionRef;
|
|
506
|
-
executionOptions?: RunExecutionOptions;
|
|
507
|
-
control?: PersistedRunControlState;
|
|
508
|
-
workflowSnapshot?: PersistedWorkflowSnapshot;
|
|
509
|
-
mutableState?: PersistedMutableRunState;
|
|
510
|
-
policySnapshot?: PersistedRunPolicySnapshot;
|
|
511
|
-
engineCounters?: EngineRunCounters;
|
|
512
|
-
}): Promise<void>;
|
|
513
|
-
load(runId: RunId): Promise<PersistedRunState | undefined>;
|
|
514
|
-
loadSchedulingState(runId: RunId): Promise<PersistedRunSchedulingState | undefined>;
|
|
515
|
-
save(state: PersistedRunState): Promise<void>;
|
|
516
|
-
deleteRun?(runId: RunId): Promise<void>;
|
|
517
|
-
}
|
|
518
|
-
interface WorkflowExecutionListingRepository {
|
|
519
|
-
listRuns(args?: Readonly<{
|
|
520
|
-
workflowId?: WorkflowId;
|
|
521
|
-
limit?: number;
|
|
522
|
-
}>): Promise<ReadonlyArray<RunSummary>>;
|
|
523
|
-
}
|
|
524
|
-
/** Runs eligible for retention-based pruning (completed or failed, older than cutoff). */
|
|
525
|
-
interface RunPruneCandidate {
|
|
526
|
-
readonly runId: RunId;
|
|
527
|
-
readonly workflowId: WorkflowId;
|
|
528
|
-
readonly startedAt: string;
|
|
529
|
-
readonly finishedAt: string;
|
|
530
|
-
}
|
|
531
|
-
interface WorkflowExecutionPruneRepository {
|
|
532
|
-
listRunsOlderThan(args: Readonly<{
|
|
533
|
-
nowIso: string;
|
|
534
|
-
defaultRetentionSeconds: number;
|
|
535
|
-
limit?: number;
|
|
536
|
-
}>): Promise<ReadonlyArray<RunPruneCandidate>>;
|
|
545
|
+
nodeId: NodeId;
|
|
546
|
+
methods: ReadonlyArray<HttpMethod>;
|
|
547
|
+
parseJsonBody?: (body: unknown) => unknown;
|
|
537
548
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
startedAt: string;
|
|
542
|
-
status: "completed";
|
|
543
|
-
outputs: Items;
|
|
549
|
+
/** Result of resolving an HTTP method + endpoint path against the catalog webhook index (404 vs 405 vs match). */
|
|
550
|
+
type WebhookTriggerResolution = {
|
|
551
|
+
status: "notFound";
|
|
544
552
|
} | {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
startedAt: string;
|
|
548
|
-
status: "pending";
|
|
549
|
-
pending: PendingNodeExecution;
|
|
553
|
+
status: "methodNotAllowed";
|
|
554
|
+
match: WebhookInvocationMatch;
|
|
550
555
|
} | {
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
startedAt: string;
|
|
554
|
-
status: "failed";
|
|
555
|
-
error: {
|
|
556
|
-
message: string;
|
|
557
|
-
};
|
|
556
|
+
status: "ok";
|
|
557
|
+
match: WebhookInvocationMatch;
|
|
558
558
|
};
|
|
559
|
-
type WebhookRunResult = Readonly<{
|
|
560
|
-
runId: RunId;
|
|
561
|
-
workflowId: WorkflowId;
|
|
562
|
-
startedAt: string;
|
|
563
|
-
runStatus: "pending" | "completed";
|
|
564
|
-
response: Items;
|
|
565
|
-
}>;
|
|
566
|
-
interface PersistedWorkflowTokenRegistryLike {
|
|
567
|
-
register(type: TypeToken<unknown>, packageId: string, persistedNameOverride?: string): string;
|
|
568
|
-
getTokenId(type: TypeToken<unknown>): string | undefined;
|
|
569
|
-
resolve(tokenId: string): TypeToken<unknown> | undefined;
|
|
570
|
-
registerFromWorkflows?(workflows: ReadonlyArray<WorkflowDefinition>): void;
|
|
571
|
-
}
|
|
572
|
-
interface RunCompletionNotifier {
|
|
573
|
-
resolveRunCompletion(result: RunResult): void;
|
|
574
|
-
resolveWebhookResponse(result: WebhookRunResult): void;
|
|
575
|
-
}
|
|
576
|
-
interface RunEventPublisherDeps {
|
|
577
|
-
eventBus?: RunEventBus;
|
|
578
|
-
}
|
|
579
|
-
//#endregion
|
|
580
|
-
//#region src/triggers/polling/PollingTriggerDedupWindow.d.ts
|
|
581
559
|
/**
|
|
582
|
-
*
|
|
583
|
-
* Plugin code receives an instance of this class via {@link PollingTriggerHandle.dedup}.
|
|
560
|
+
* Resolves webhook routes from workflow definitions (catalog-backed index, no registration at trigger setup).
|
|
584
561
|
*/
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
562
|
+
interface WebhookTriggerMatcher {
|
|
563
|
+
match(args: {
|
|
564
|
+
endpointPath: string;
|
|
565
|
+
method: HttpMethod;
|
|
566
|
+
}): WebhookInvocationMatch | undefined;
|
|
567
|
+
lookup(endpointPath: string): WebhookInvocationMatch | undefined;
|
|
568
|
+
onEngineWorkflowsLoaded?(): void;
|
|
569
|
+
onEngineStopped?(): void;
|
|
570
|
+
/** Rebuild route index after activation changes without stopping the engine. */
|
|
571
|
+
reloadWebhookRoutes?(): void;
|
|
588
572
|
}
|
|
589
573
|
//#endregion
|
|
590
|
-
//#region src/
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
* Hosts supply this via {@link EngineDeps.pollingTriggerLogger};
|
|
594
|
-
* when absent the runtime is silent.
|
|
595
|
-
*/
|
|
596
|
-
interface PollingTriggerLogger {
|
|
597
|
-
info(message: string): void;
|
|
598
|
-
warn(message: string): void;
|
|
599
|
-
error(message: string, exception?: Error): void;
|
|
600
|
-
debug(message: string): void;
|
|
601
|
-
}
|
|
602
|
-
declare class NoOpPollingTriggerLogger implements PollingTriggerLogger {
|
|
603
|
-
info(): void;
|
|
604
|
-
warn(): void;
|
|
605
|
-
error(): void;
|
|
606
|
-
debug(): void;
|
|
607
|
-
}
|
|
608
|
-
//#endregion
|
|
609
|
-
//#region src/contracts/credentialTypes.d.ts
|
|
610
|
-
type CredentialTypeId = string;
|
|
611
|
-
type CredentialInstanceId = string;
|
|
612
|
-
type CredentialMaterialSourceKind = "db" | "env" | "code";
|
|
613
|
-
type CredentialSetupStatus = "draft" | "ready";
|
|
614
|
-
type CredentialHealthStatus = "unknown" | "healthy" | "failing";
|
|
615
|
-
type CredentialFieldSchema = Readonly<{
|
|
616
|
-
key: string;
|
|
617
|
-
label: string;
|
|
618
|
-
type: "string" | "password" | "textarea" | "json" | "boolean";
|
|
619
|
-
required?: true;
|
|
620
|
-
order?: number;
|
|
621
|
-
/**
|
|
622
|
-
* Where this field appears in the credential dialog. Use `"advanced"` for optional or
|
|
623
|
-
* power-user fields; they render inside a collapsible section (see `CredentialTypeDefinition.advancedSection`).
|
|
624
|
-
* Defaults to `"default"` when omitted.
|
|
625
|
-
*/
|
|
626
|
-
visibility?: "default" | "advanced";
|
|
627
|
-
placeholder?: string;
|
|
628
|
-
helpText?: string;
|
|
629
|
-
/** When set, host resolves this field from process.env at runtime; env wins over stored values. */
|
|
630
|
-
envVarName?: string;
|
|
631
|
-
/**
|
|
632
|
-
* When set, the dialog shows a copy action for this exact string (e.g. a static OAuth redirect URI
|
|
633
|
-
* pattern or documentation URL). Do not use for secret values.
|
|
634
|
-
*/
|
|
635
|
-
copyValue?: string;
|
|
636
|
-
/** Accessible label for the copy control (default: Copy). */
|
|
637
|
-
copyButtonLabel?: string;
|
|
638
|
-
}>;
|
|
639
|
-
type CredentialRequirement = Readonly<{
|
|
640
|
-
slotKey: string;
|
|
641
|
-
label: string;
|
|
642
|
-
acceptedTypes: ReadonlyArray<CredentialTypeId>;
|
|
643
|
-
optional?: true;
|
|
644
|
-
helpText?: string;
|
|
645
|
-
helpUrl?: string;
|
|
646
|
-
}>;
|
|
647
|
-
type CredentialBindingKey = Readonly<{
|
|
648
|
-
workflowId: WorkflowId;
|
|
649
|
-
nodeId: NodeId;
|
|
650
|
-
slotKey: string;
|
|
651
|
-
}>;
|
|
652
|
-
type CredentialBinding = Readonly<{
|
|
653
|
-
key: CredentialBindingKey;
|
|
654
|
-
instanceId: CredentialInstanceId;
|
|
655
|
-
updatedAt: string;
|
|
656
|
-
}>;
|
|
657
|
-
type CredentialHealth = Readonly<{
|
|
658
|
-
status: CredentialHealthStatus;
|
|
659
|
-
message?: string;
|
|
660
|
-
testedAt?: string;
|
|
661
|
-
expiresAt?: string;
|
|
662
|
-
details?: Readonly<Record<string, unknown>>;
|
|
663
|
-
}>;
|
|
664
|
-
type OAuth2ProviderFromPublicConfig = Readonly<{
|
|
665
|
-
authorizeUrlFieldKey: string;
|
|
666
|
-
tokenUrlFieldKey: string;
|
|
667
|
-
userInfoUrlFieldKey?: string;
|
|
668
|
-
}>;
|
|
669
|
-
type CredentialOAuth2ScopesFromPublicConfig = Readonly<{
|
|
670
|
-
presetFieldKey: string;
|
|
671
|
-
presetScopes: Readonly<Record<string, ReadonlyArray<string>>>;
|
|
672
|
-
customPresetKey?: string;
|
|
673
|
-
customScopesFieldKey?: string;
|
|
674
|
-
}>;
|
|
675
|
-
type CredentialOAuth2AuthDefinition = Readonly<{
|
|
676
|
-
kind: "oauth2";
|
|
677
|
-
providerId: string;
|
|
678
|
-
scopes: ReadonlyArray<string>;
|
|
679
|
-
scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig;
|
|
680
|
-
clientIdFieldKey?: string;
|
|
681
|
-
clientSecretFieldKey?: string;
|
|
682
|
-
} | {
|
|
683
|
-
kind: "oauth2";
|
|
684
|
-
providerFromPublicConfig: OAuth2ProviderFromPublicConfig;
|
|
685
|
-
scopes: ReadonlyArray<string>;
|
|
686
|
-
scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig;
|
|
687
|
-
clientIdFieldKey?: string;
|
|
688
|
-
clientSecretFieldKey?: string;
|
|
689
|
-
} | {
|
|
690
|
-
kind: "oauth2";
|
|
691
|
-
/**
|
|
692
|
-
* Free-form provider identifier for telemetry, DB rows, and Better Auth provider naming.
|
|
693
|
-
* Not used for any registry lookup — URLs come from {@link authorizeUrl} / {@link tokenUrl}.
|
|
694
|
-
*/
|
|
695
|
-
providerId: string;
|
|
696
|
-
/**
|
|
697
|
-
* Authorization endpoint. May contain `{publicFieldKey}` placeholders that the runtime
|
|
698
|
-
* substitutes from the credential's resolved public config (URL-encoded).
|
|
699
|
-
* Example: `https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/authorize`
|
|
700
|
-
*/
|
|
701
|
-
authorizeUrl: string;
|
|
702
|
-
/** Token endpoint. Same templating rules as {@link authorizeUrl}. */
|
|
703
|
-
tokenUrl: string;
|
|
704
|
-
/** Optional userinfo endpoint. Same templating rules as {@link authorizeUrl}. */
|
|
705
|
-
userInfoUrl?: string;
|
|
706
|
-
scopes: ReadonlyArray<string>;
|
|
707
|
-
scopesFromPublicConfig?: CredentialOAuth2ScopesFromPublicConfig;
|
|
708
|
-
clientIdFieldKey?: string;
|
|
709
|
-
clientSecretFieldKey?: string;
|
|
710
|
-
}>;
|
|
711
|
-
type CredentialAuthDefinition = CredentialOAuth2AuthDefinition;
|
|
712
|
-
type CredentialAdvancedSectionPresentation = Readonly<{
|
|
713
|
-
/** Collapsible section title (default: "Advanced"). */
|
|
714
|
-
title?: string;
|
|
715
|
-
/** Optional short helper text shown inside the section (above the fields). */
|
|
716
|
-
description?: string;
|
|
717
|
-
/** When true, the advanced section starts expanded. Default: false (collapsed). */
|
|
718
|
-
defaultOpen?: boolean;
|
|
719
|
-
}>;
|
|
720
|
-
type CredentialTypeDefinition = Readonly<{
|
|
721
|
-
typeId: CredentialTypeId;
|
|
722
|
-
displayName: string;
|
|
723
|
-
description?: string;
|
|
724
|
-
publicFields?: ReadonlyArray<CredentialFieldSchema>;
|
|
725
|
-
secretFields?: ReadonlyArray<CredentialFieldSchema>;
|
|
726
|
-
/**
|
|
727
|
-
* Optional labels for the collapsible block that contains every field with `visibility: "advanced"`.
|
|
728
|
-
* If omitted, the UI still shows that block with defaults (title "Advanced", collapsed).
|
|
729
|
-
*/
|
|
730
|
-
advancedSection?: CredentialAdvancedSectionPresentation;
|
|
731
|
-
supportedSourceKinds?: ReadonlyArray<CredentialMaterialSourceKind>;
|
|
732
|
-
auth?: CredentialAuthDefinition;
|
|
733
|
-
}>;
|
|
734
|
-
/**
|
|
735
|
-
* JSON-shaped credential field bag (public config, resolved secret material, etc.).
|
|
736
|
-
*/
|
|
737
|
-
type CredentialJsonRecord = Readonly<Record<string, unknown>>;
|
|
738
|
-
/**
|
|
739
|
-
* Persisted credential instance with typed `publicConfig`.
|
|
740
|
-
* Hosts may specialize `secretRef` with a stricter union while remaining
|
|
741
|
-
* assignable here for session/test callbacks.
|
|
742
|
-
*/
|
|
743
|
-
type CredentialInstanceRecord<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord> = Readonly<{
|
|
744
|
-
instanceId: CredentialInstanceId;
|
|
745
|
-
typeId: CredentialTypeId;
|
|
746
|
-
displayName: string;
|
|
747
|
-
sourceKind: CredentialMaterialSourceKind;
|
|
748
|
-
publicConfig: TPublicConfig;
|
|
749
|
-
secretRef: CredentialJsonRecord;
|
|
750
|
-
tags: ReadonlyArray<string>;
|
|
751
|
-
setupStatus: CredentialSetupStatus;
|
|
752
|
-
createdAt: string;
|
|
753
|
-
updatedAt: string;
|
|
754
|
-
}>;
|
|
755
|
-
/**
|
|
756
|
-
* Arguments passed to `CredentialType.createSession` and `CredentialType.test`.
|
|
757
|
-
* Declare `TPublicConfig` / `TMaterial` on `CredentialType` so implementations are checked
|
|
758
|
-
* against your credential shapes (similar to `NodeExecutionContext.config` for nodes).
|
|
759
|
-
*/
|
|
760
|
-
type CredentialSessionFactoryArgs<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord> = Readonly<{
|
|
761
|
-
instance: CredentialInstanceRecord<TPublicConfig>;
|
|
762
|
-
material: TMaterial;
|
|
763
|
-
publicConfig: TPublicConfig;
|
|
764
|
-
}>;
|
|
765
|
-
type CredentialSessionFactory<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord, TSession = unknown> = (args: CredentialSessionFactoryArgs<TPublicConfig, TMaterial>) => Promise<TSession>;
|
|
766
|
-
type CredentialHealthTester<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord> = (args: CredentialSessionFactoryArgs<TPublicConfig, TMaterial>) => Promise<CredentialHealth>;
|
|
767
|
-
/**
|
|
768
|
-
* Full credential type implementation: `definition` (UI/schema), `createSession`, and `test`.
|
|
769
|
-
* Use this at registration and config boundaries; `CredentialTypeDefinition` is only the schema slice.
|
|
770
|
-
*/
|
|
771
|
-
type CredentialType<TPublicConfig extends CredentialJsonRecord = CredentialJsonRecord, TMaterial extends CredentialJsonRecord = CredentialJsonRecord, TSession = unknown> = Readonly<{
|
|
772
|
-
definition: CredentialTypeDefinition;
|
|
773
|
-
createSession: CredentialSessionFactory<TPublicConfig, TMaterial, TSession>;
|
|
774
|
-
test: CredentialHealthTester<TPublicConfig, TMaterial>;
|
|
775
|
-
}>;
|
|
776
|
-
/**
|
|
777
|
-
* Credential type with unspecified generics — used for `CodemationConfig.credentialTypes`, the host registry,
|
|
778
|
-
* and anywhere a concrete `CredentialType<YourPublic, YourMaterial, YourSession>` is placed in a heterogeneous list.
|
|
779
|
-
* Using `any` here avoids unsafe `as` casts while keeping typed `satisfies CredentialType<…>` definitions.
|
|
780
|
-
*/
|
|
781
|
-
type AnyCredentialType = CredentialType<any, any, unknown>;
|
|
782
|
-
interface CredentialSessionService {
|
|
783
|
-
getSession<TSession = unknown>(args: Readonly<{
|
|
574
|
+
//#region src/contracts/runtimeTypes.d.ts
|
|
575
|
+
interface WorkflowRunnerService {
|
|
576
|
+
runById(args: {
|
|
784
577
|
workflowId: WorkflowId;
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
578
|
+
startAt?: NodeId;
|
|
579
|
+
items: Items;
|
|
580
|
+
parent?: ParentExecutionRef;
|
|
581
|
+
}): Promise<RunResult>;
|
|
788
582
|
}
|
|
789
|
-
interface
|
|
790
|
-
|
|
791
|
-
getType(typeId: CredentialTypeId): CredentialTypeDefinition | undefined;
|
|
583
|
+
interface WorkflowRunnerResolver {
|
|
584
|
+
resolve(): WorkflowRunnerService | undefined;
|
|
792
585
|
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
constructor(bindingKey: CredentialBindingKey, acceptedTypes?: ReadonlyArray<CredentialTypeId>);
|
|
797
|
-
private static createMessage;
|
|
586
|
+
interface WorkflowRepository {
|
|
587
|
+
list(): ReadonlyArray<WorkflowDefinition>;
|
|
588
|
+
get(workflowId: WorkflowId): WorkflowDefinition | undefined;
|
|
798
589
|
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
interface
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
})
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
}) | null>;
|
|
830
|
-
/**
|
|
831
|
-
* List rows with optional pagination and filtering.
|
|
832
|
-
*/
|
|
833
|
-
list(opts?: {
|
|
834
|
-
limit?: number;
|
|
835
|
-
offset?: number;
|
|
836
|
-
where?: Partial<TRow>;
|
|
837
|
-
}): Promise<{
|
|
838
|
-
rows: ReadonlyArray<TRow & {
|
|
839
|
-
id: string;
|
|
840
|
-
created_at: Date;
|
|
841
|
-
updated_at: Date;
|
|
842
|
-
}>;
|
|
843
|
-
total: number;
|
|
844
|
-
}>;
|
|
845
|
-
/**
|
|
846
|
-
* Update a row by id with partial data.
|
|
847
|
-
*/
|
|
848
|
-
update(id: string, patch: Partial<TRow>): Promise<TRow & {
|
|
849
|
-
id: string;
|
|
850
|
-
created_at: Date;
|
|
851
|
-
updated_at: Date;
|
|
852
|
-
}>;
|
|
590
|
+
interface LiveWorkflowRepository extends WorkflowRepository {
|
|
591
|
+
setWorkflows(workflows: ReadonlyArray<WorkflowDefinition>): void;
|
|
592
|
+
}
|
|
593
|
+
interface NodeResolver {
|
|
594
|
+
resolve<T>(token: TypeToken<T>): T;
|
|
595
|
+
}
|
|
596
|
+
interface NodeExecutionStatePublisher {
|
|
597
|
+
markQueued(args: {
|
|
598
|
+
nodeId: NodeId;
|
|
599
|
+
activationId?: NodeActivationId;
|
|
600
|
+
inputsByPort?: NodeInputsByPort;
|
|
601
|
+
}): Promise<void>;
|
|
602
|
+
markRunning(args: {
|
|
603
|
+
nodeId: NodeId;
|
|
604
|
+
activationId?: NodeActivationId;
|
|
605
|
+
inputsByPort?: NodeInputsByPort;
|
|
606
|
+
}): Promise<void>;
|
|
607
|
+
markCompleted(args: {
|
|
608
|
+
nodeId: NodeId;
|
|
609
|
+
activationId?: NodeActivationId;
|
|
610
|
+
inputsByPort?: NodeInputsByPort;
|
|
611
|
+
outputs?: NodeOutputs;
|
|
612
|
+
}): Promise<void>;
|
|
613
|
+
markFailed(args: {
|
|
614
|
+
nodeId: NodeId;
|
|
615
|
+
activationId?: NodeActivationId;
|
|
616
|
+
inputsByPort?: NodeInputsByPort;
|
|
617
|
+
error: Error;
|
|
618
|
+
}): Promise<void>;
|
|
619
|
+
appendConnectionInvocation(args: ConnectionInvocationAppendArgs): Promise<void>;
|
|
853
620
|
/**
|
|
854
|
-
*
|
|
621
|
+
* Annotates the current snapshot for `nodeId` with the id of the child run spawned by a
|
|
622
|
+
* SubWorkflow invocation. Called from `SubWorkflowNode.execute` after `runById` resolves.
|
|
623
|
+
* The engine's subsequent `markCompleted` call preserves the value via `previous.childRunId`.
|
|
855
624
|
*/
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
625
|
+
setChildRunId?(args: {
|
|
626
|
+
nodeId: NodeId;
|
|
627
|
+
childRunId: RunId;
|
|
628
|
+
}): Promise<void>;
|
|
859
629
|
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
//#endregion
|
|
865
|
-
//#region src/contracts/CostTrackingTelemetryContract.d.ts
|
|
866
|
-
type CostTrackingComponent = "chat" | "ocr" | "rag";
|
|
867
|
-
declare const CostTrackingTelemetryMetricNames: {
|
|
868
|
-
readonly usage: "codemation.cost.usage";
|
|
869
|
-
readonly estimatedCost: "codemation.cost.estimated";
|
|
870
|
-
};
|
|
871
|
-
declare const CostTrackingTelemetryAttributeNames: {
|
|
872
|
-
readonly component: "cost.component";
|
|
873
|
-
readonly provider: "cost.provider";
|
|
874
|
-
readonly operation: "cost.operation";
|
|
875
|
-
readonly pricingKey: "cost.pricing_key";
|
|
876
|
-
readonly usageUnit: "cost.usage_unit";
|
|
877
|
-
readonly currency: "cost.currency";
|
|
878
|
-
readonly currencyScale: "cost.currency_scale";
|
|
879
|
-
readonly estimateKind: "cost.estimate_kind";
|
|
880
|
-
};
|
|
881
|
-
interface CostTrackingUsageRecord {
|
|
882
|
-
readonly component: CostTrackingComponent;
|
|
883
|
-
readonly provider: string;
|
|
884
|
-
readonly operation: string;
|
|
885
|
-
readonly pricingKey: string;
|
|
886
|
-
readonly usageUnit: string;
|
|
887
|
-
readonly quantity: number;
|
|
888
|
-
readonly modelName?: string;
|
|
889
|
-
readonly attributes?: TelemetryAttributes;
|
|
630
|
+
type BinaryBody = ReadableStream<Uint8Array> | AsyncIterable<Uint8Array> | Uint8Array | ArrayBuffer;
|
|
631
|
+
interface BinaryStorageWriteRequest {
|
|
632
|
+
storageKey: string;
|
|
633
|
+
body: BinaryBody;
|
|
890
634
|
}
|
|
891
|
-
interface
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
readonly estimateKind: "catalog";
|
|
635
|
+
interface BinaryStorageWriteResult {
|
|
636
|
+
storageKey: string;
|
|
637
|
+
size: number;
|
|
638
|
+
sha256?: string;
|
|
896
639
|
}
|
|
897
|
-
interface
|
|
898
|
-
|
|
899
|
-
|
|
640
|
+
interface BinaryStorageReadResult {
|
|
641
|
+
body: ReadableStream<Uint8Array>;
|
|
642
|
+
size?: number;
|
|
900
643
|
}
|
|
901
|
-
interface
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
}>): CostTrackingTelemetry;
|
|
644
|
+
interface BinaryStorageStatResult {
|
|
645
|
+
exists: boolean;
|
|
646
|
+
size?: number;
|
|
905
647
|
}
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
648
|
+
interface BinaryStorage {
|
|
649
|
+
readonly driverName: string;
|
|
650
|
+
write(args: BinaryStorageWriteRequest): Promise<BinaryStorageWriteResult>;
|
|
651
|
+
openReadStream(storageKey: string): Promise<BinaryStorageReadResult | undefined>;
|
|
652
|
+
stat(storageKey: string): Promise<BinaryStorageStatResult>;
|
|
653
|
+
delete(storageKey: string): Promise<void>;
|
|
654
|
+
/** Deletes multiple objects in bulk. Keys are batched internally. */
|
|
655
|
+
deleteMany(storageKeys: ReadonlyArray<string>): Promise<void>;
|
|
656
|
+
/** Lists all keys sharing a common prefix. Returns keys in arbitrary order. */
|
|
657
|
+
listByPrefix(prefix: string): Promise<ReadonlyArray<string>>;
|
|
910
658
|
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
659
|
+
interface BinaryAttachmentCreateRequest {
|
|
660
|
+
name: string;
|
|
661
|
+
body: BinaryBody;
|
|
662
|
+
mimeType: string;
|
|
663
|
+
filename?: string;
|
|
664
|
+
previewKind?: BinaryAttachment["previewKind"];
|
|
917
665
|
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
static readonly value: NodeExecutionTelemetry;
|
|
666
|
+
interface NodeBinaryAttachmentService extends ExecutionBinaryService {
|
|
667
|
+
attach(args: BinaryAttachmentCreateRequest): Promise<BinaryAttachment>;
|
|
668
|
+
withAttachment<TJson>(item: Item<TJson>, name: string, attachment: BinaryAttachment): Item<TJson>;
|
|
922
669
|
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
670
|
+
interface ExecutionBinaryService {
|
|
671
|
+
forNode(args: {
|
|
672
|
+
nodeId: NodeId;
|
|
673
|
+
activationId: NodeActivationId;
|
|
674
|
+
}): NodeBinaryAttachmentService;
|
|
675
|
+
openReadStream(attachment: BinaryAttachment): Promise<BinaryStorageReadResult | undefined>;
|
|
927
676
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
677
|
+
interface ExecutionContext {
|
|
678
|
+
runId: RunId;
|
|
679
|
+
workflowId: WorkflowId;
|
|
680
|
+
parent?: ParentExecutionRef;
|
|
681
|
+
/** This run's subworkflow depth (0 = root). */
|
|
682
|
+
subworkflowDepth: number;
|
|
683
|
+
/** Effective activation budget cap for this run (after policy merge). */
|
|
684
|
+
engineMaxNodeActivations: number;
|
|
685
|
+
/** Effective subworkflow nesting cap for this run (after policy merge). */
|
|
686
|
+
engineMaxSubworkflowDepth: number;
|
|
687
|
+
now: () => Date;
|
|
688
|
+
data: RunDataSnapshot;
|
|
689
|
+
nodeState?: NodeExecutionStatePublisher;
|
|
690
|
+
telemetry: ExecutionTelemetry;
|
|
691
|
+
binary: ExecutionBinaryService;
|
|
692
|
+
getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
|
|
693
|
+
/** Per-item iteration id, set by {@link NodeExecutor} on the ctx passed into runnable `execute`. */
|
|
694
|
+
iterationId?: NodeIterationId;
|
|
695
|
+
/** Item index (0-based) within the current activation's batch; set alongside {@link iterationId}. */
|
|
696
|
+
itemIndex?: number;
|
|
697
|
+
/** When set, this ctx is executing inside a sub-agent triggered by the named parent invocation. */
|
|
698
|
+
parentInvocationId?: ConnectionInvocationId;
|
|
699
|
+
/**
|
|
700
|
+
* Present iff the run was started by a TestSuiteOrchestrator. The {@link IsTestRunNode}
|
|
701
|
+
* branches on this; assertion-emitting nodes use it to decide whether to record results.
|
|
702
|
+
*/
|
|
703
|
+
testContext?: RunTestContext;
|
|
704
|
+
/**
|
|
705
|
+
* Collections registered in the codemation config, keyed by collection name.
|
|
706
|
+
*/
|
|
707
|
+
readonly collections?: CollectionsContext;
|
|
708
|
+
}
|
|
709
|
+
interface ExecutionContextFactory {
|
|
710
|
+
create(args: {
|
|
932
711
|
runId: RunId;
|
|
933
712
|
workflowId: WorkflowId;
|
|
934
713
|
parent?: ParentExecutionRef;
|
|
935
714
|
policySnapshot?: PersistedRunPolicySnapshot;
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
static readonly nodeType = "codemation.node.type";
|
|
946
|
-
static readonly nodeRole = "codemation.node.role";
|
|
947
|
-
static readonly workflowFolder = "codemation.workflow.folder";
|
|
948
|
-
static readonly connectionInvocationId = "codemation.connection.invocation_id";
|
|
949
|
-
static readonly toolName = "codemation.tool.name";
|
|
950
|
-
static readonly traceParentRunId = "codemation.parent.run.id";
|
|
951
|
-
/** Per-item iteration that emitted this span/metric. Set on spans recorded inside a runnable per-item loop. */
|
|
952
|
-
static readonly iterationId = "codemation.iteration.id";
|
|
953
|
-
/** Item index (0-based) of the iteration. */
|
|
954
|
-
static readonly iterationIndex = "codemation.iteration.index";
|
|
955
|
-
/** Set when this span/metric was recorded under a sub-agent triggered by an outer LLM/tool call. */
|
|
956
|
-
static readonly parentInvocationId = "codemation.parent.invocation_id";
|
|
957
|
-
}
|
|
958
|
-
//#endregion
|
|
959
|
-
//#region src/contracts/GenAiTelemetryAttributeNames.d.ts
|
|
960
|
-
declare class GenAiTelemetryAttributeNames {
|
|
961
|
-
static readonly operationName = "gen_ai.operation.name";
|
|
962
|
-
static readonly requestModel = "gen_ai.request.model";
|
|
963
|
-
static readonly usageInputTokens = "gen_ai.usage.input_tokens";
|
|
964
|
-
static readonly usageOutputTokens = "gen_ai.usage.output_tokens";
|
|
965
|
-
static readonly usageTotalTokens = "gen_ai.usage.total_tokens";
|
|
966
|
-
static readonly usageCacheReadInputTokens = "gen_ai.usage.cache_read.input_tokens";
|
|
967
|
-
static readonly usageCacheCreationInputTokens = "gen_ai.usage.cache_creation.input_tokens";
|
|
968
|
-
static readonly usageReasoningTokens = "codemation.gen_ai.usage.reasoning_tokens";
|
|
715
|
+
subworkflowDepth: number;
|
|
716
|
+
engineMaxNodeActivations: number;
|
|
717
|
+
engineMaxSubworkflowDepth: number;
|
|
718
|
+
data: RunDataSnapshot;
|
|
719
|
+
nodeState?: NodeExecutionStatePublisher;
|
|
720
|
+
telemetry?: ExecutionTelemetry;
|
|
721
|
+
getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
|
|
722
|
+
testContext?: RunTestContext;
|
|
723
|
+
}): ExecutionContext;
|
|
969
724
|
}
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
static readonly gmailAttachments = "codemation.gmail.attachments";
|
|
977
|
-
static readonly gmailAttachmentBytes = "codemation.gmail.attachment_bytes";
|
|
725
|
+
interface NodeExecutionContext<TConfig extends NodeConfigBase = NodeConfigBase> extends ExecutionContext {
|
|
726
|
+
nodeId: NodeId;
|
|
727
|
+
activationId: NodeActivationId;
|
|
728
|
+
config: TConfig;
|
|
729
|
+
telemetry: NodeExecutionTelemetry;
|
|
730
|
+
binary: NodeBinaryAttachmentService;
|
|
978
731
|
}
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
732
|
+
interface PollingTriggerHandle {
|
|
733
|
+
/**
|
|
734
|
+
* Start the polling loop. The runtime registers its own cleanup handle so callers do not need to
|
|
735
|
+
* call {@link TriggerSetupContext.registerCleanup} for the loop.
|
|
736
|
+
* @returns The state returned by the first cycle (or `undefined` when the overlap guard fired).
|
|
737
|
+
*/
|
|
738
|
+
start<TState, TItem>(args: {
|
|
739
|
+
intervalMs: number;
|
|
740
|
+
seedState?: TState;
|
|
741
|
+
runCycle: (cycleCtx: {
|
|
742
|
+
previousState: TState | undefined;
|
|
743
|
+
signal: AbortSignal;
|
|
744
|
+
}) => Promise<{
|
|
745
|
+
items: Items<TItem>;
|
|
746
|
+
nextState: TState;
|
|
747
|
+
}>;
|
|
748
|
+
}): Promise<TState | undefined>;
|
|
749
|
+
/** Convenience dedup-window helper. */
|
|
750
|
+
readonly dedup: PollingTriggerDedupWindow;
|
|
984
751
|
}
|
|
985
|
-
interface
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
752
|
+
interface TriggerSetupContext<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>, TSetupState$1 extends JsonValue | undefined = TriggerNodeSetupState<TConfig>> extends ExecutionContext {
|
|
753
|
+
trigger: TriggerInstanceId;
|
|
754
|
+
config: TConfig;
|
|
755
|
+
previousState: TSetupState$1;
|
|
756
|
+
registerCleanup(cleanup: TriggerCleanupHandle): void;
|
|
757
|
+
emit(items: Items): Promise<void>;
|
|
758
|
+
/** Generic polling-trigger surface. Pre-binds trigger id, emit, and registerCleanup. */
|
|
759
|
+
readonly polling: PollingTriggerHandle;
|
|
990
760
|
}
|
|
991
|
-
interface
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
761
|
+
interface TriggerTestItemsContext<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>, TSetupState$1 extends JsonValue | undefined = TriggerNodeSetupState<TConfig>> extends ExecutionContext {
|
|
762
|
+
trigger: TriggerInstanceId;
|
|
763
|
+
nodeId: NodeId;
|
|
764
|
+
config: TConfig;
|
|
765
|
+
previousState: TSetupState$1;
|
|
995
766
|
}
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
readonly expiresAt?: Date;
|
|
767
|
+
/**
|
|
768
|
+
* Trigger setup state is intentionally engine-owned so future ownership and
|
|
769
|
+
* leader-election metadata can be coordinated centrally rather than pushed into
|
|
770
|
+
* package-level setup code.
|
|
771
|
+
*/
|
|
772
|
+
interface PersistedTriggerSetupState<TState extends JsonValue | undefined = JsonValue | undefined> {
|
|
773
|
+
trigger: TriggerInstanceId;
|
|
774
|
+
updatedAt: string;
|
|
775
|
+
state: TState;
|
|
1006
776
|
}
|
|
1007
|
-
interface
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
777
|
+
interface TriggerSetupStateRepository {
|
|
778
|
+
load(trigger: TriggerInstanceId): Promise<PersistedTriggerSetupState | undefined>;
|
|
779
|
+
save(state: PersistedTriggerSetupState): Promise<void>;
|
|
780
|
+
delete(trigger: TriggerInstanceId): Promise<void>;
|
|
1011
781
|
}
|
|
1012
|
-
interface
|
|
1013
|
-
|
|
1014
|
-
readonly statusMessage?: string;
|
|
1015
|
-
readonly endedAt?: Date;
|
|
1016
|
-
readonly attributes?: TelemetryAttributes;
|
|
782
|
+
interface TriggerCleanupHandle {
|
|
783
|
+
stop(): Promise<void> | void;
|
|
1017
784
|
}
|
|
1018
|
-
interface
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
readonly startedAt?: Date;
|
|
1022
|
-
readonly attributes?: TelemetryAttributes;
|
|
785
|
+
interface EngineHost {
|
|
786
|
+
credentialSessions: CredentialSessionService;
|
|
787
|
+
workflows?: WorkflowRunnerService;
|
|
1023
788
|
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
789
|
+
/**
|
|
790
|
+
* Per-item runnable node: return JSON, an array to fan-out on `main`, an explicit `Item`, or {@link emitPorts}
|
|
791
|
+
* for multi-port emission. Engine applies `inputSchema.parse(item.json)` and passes the result as `args.input`
|
|
792
|
+
* (wire `item.json` is unchanged). Transform helpers may opt into binary preservation, while routers and
|
|
793
|
+
* pass-through nodes should return explicit items when they need to preserve full item state.
|
|
794
|
+
*/
|
|
795
|
+
interface RunnableNodeExecuteArgs<TConfig extends RunnableNodeConfig<any, any> = RunnableNodeConfig<any, any>, TInputJson$1 = unknown> {
|
|
796
|
+
readonly input: TInputJson$1;
|
|
797
|
+
readonly item: Item;
|
|
798
|
+
readonly itemIndex: number;
|
|
799
|
+
readonly items: Items;
|
|
800
|
+
readonly ctx: NodeExecutionContext<TConfig>;
|
|
1031
801
|
}
|
|
1032
|
-
interface
|
|
1033
|
-
readonly
|
|
1034
|
-
readonly spanId: string;
|
|
1035
|
-
end(args?: TelemetrySpanEnd): Promise<void> | void;
|
|
802
|
+
interface RunnableNode<TConfig extends RunnableNodeConfig<any, any> = RunnableNodeConfig<any, any>, TInputJson$1 = unknown, _TOutputJson = unknown> {
|
|
803
|
+
readonly kind: "node";
|
|
1036
804
|
/**
|
|
1037
|
-
*
|
|
1038
|
-
* Children created via the returned telemetry's `startChildSpan` get this span as their parent.
|
|
805
|
+
* Declared output ports (e.g. `["main"]`).
|
|
1039
806
|
*
|
|
1040
|
-
*
|
|
1041
|
-
*
|
|
807
|
+
* Prefer describing dynamic router ports (Switch) and fixed multi-ports (If true/false)
|
|
808
|
+
* via {@link NodeConfigBase.declaredOutputPorts}. Engine defaults to `["main"]` when omitted.
|
|
1042
809
|
*/
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
}
|
|
1048
|
-
interface NodeExecutionTelemetry extends ExecutionTelemetry, TelemetrySpanScope {
|
|
1049
|
-
startChildSpan(args: TelemetryChildSpanStart): TelemetrySpanScope;
|
|
810
|
+
readonly outputPorts?: ReadonlyArray<OutputPortKey>;
|
|
811
|
+
/** When omitted, engine uses {@link RunnableNodeConfig.inputSchema} or `z.unknown()`. */
|
|
812
|
+
readonly inputSchema?: ZodType<TInputJson$1>;
|
|
813
|
+
execute(args: RunnableNodeExecuteArgs<TConfig, TInputJson$1>): Promise<unknown> | unknown;
|
|
1050
814
|
}
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
815
|
+
/** @deprecated Use {@link RunnableNode} */
|
|
816
|
+
type ItemNode<TConfig extends RunnableNodeConfig<any, any> = RunnableNodeConfig<any, any>, TInputJson$1 = unknown, TOutputJson$1 = unknown> = RunnableNode<TConfig, TInputJson$1, TOutputJson$1>;
|
|
817
|
+
interface MultiInputNode<TConfig extends NodeConfigBase = NodeConfigBase> {
|
|
818
|
+
kind: "node";
|
|
819
|
+
/**
|
|
820
|
+
* Declared output ports (typically `["main"]`).
|
|
821
|
+
*
|
|
822
|
+
* Prefer describing ports for authoring/canvas via {@link NodeConfigBase.declaredOutputPorts}.
|
|
823
|
+
* Engine defaults to `["main"]` when omitted.
|
|
824
|
+
*/
|
|
825
|
+
outputPorts?: ReadonlyArray<OutputPortKey>;
|
|
826
|
+
executeMulti(inputsByPort: NodeInputsByPort, ctx: NodeExecutionContext<TConfig>): Promise<NodeOutputs>;
|
|
1058
827
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
}>): ExecutionTelemetry;
|
|
828
|
+
type TriggerSetupStateFor<TConfig extends TriggerNodeConfig<any, any>> = TriggerNodeSetupState<TConfig>;
|
|
829
|
+
interface TriggerNode<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>> {
|
|
830
|
+
kind: "trigger";
|
|
831
|
+
outputPorts: readonly ["main"];
|
|
832
|
+
setup(ctx: TriggerSetupContext<TConfig>): Promise<TriggerSetupStateFor<TConfig>>;
|
|
833
|
+
execute(items: Items, ctx: NodeExecutionContext<TConfig>): Promise<NodeOutputs>;
|
|
1066
834
|
}
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
/**
|
|
1070
|
-
* Host-controlled policy: when false, trigger {@link TriggerNode} setup is skipped and webhook routes
|
|
1071
|
-
* for that workflow are not registered (see engine trigger runtime + webhook matcher).
|
|
1072
|
-
*/
|
|
1073
|
-
interface WorkflowActivationPolicy {
|
|
1074
|
-
isActive(workflowId: WorkflowId): boolean;
|
|
835
|
+
interface TestableTriggerNode<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>> extends TriggerNode<TConfig> {
|
|
836
|
+
getTestItems(ctx: TriggerTestItemsContext<TConfig>): Promise<Items>;
|
|
1075
837
|
}
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
838
|
+
type ExecutableTriggerNode<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>> = TriggerNode<TConfig>;
|
|
839
|
+
interface NodeExecutionRequest {
|
|
840
|
+
runId: RunId;
|
|
841
|
+
activationId: NodeActivationId;
|
|
842
|
+
workflowId: WorkflowId;
|
|
843
|
+
nodeId: NodeId;
|
|
844
|
+
input: Items;
|
|
845
|
+
parent?: ParentExecutionRef;
|
|
846
|
+
queue?: string;
|
|
847
|
+
executionOptions?: RunExecutionOptions;
|
|
1079
848
|
}
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
readonly kind: "respondNow" | "respondNowAndContinue";
|
|
1086
|
-
readonly responseItems: Items;
|
|
1087
|
-
readonly continueItems?: Items;
|
|
849
|
+
interface NodeExecutionScheduler {
|
|
850
|
+
enqueue(request: NodeExecutionRequest): Promise<{
|
|
851
|
+
receiptId: string;
|
|
852
|
+
}>;
|
|
853
|
+
cancel?(receiptId: string): Promise<void>;
|
|
1088
854
|
}
|
|
1089
|
-
interface
|
|
1090
|
-
|
|
1091
|
-
/** Inactive workflows omitted from the webhook route index (optional; host should wire for clarity at boot/reload). */
|
|
1092
|
-
info?(message: string): void;
|
|
855
|
+
interface NodeExecutionRequestHandler {
|
|
856
|
+
handleNodeExecutionRequest(request: NodeExecutionRequest): Promise<void>;
|
|
1093
857
|
}
|
|
1094
|
-
|
|
858
|
+
type NodeActivationRequestBase = Readonly<{
|
|
859
|
+
runId: RunId;
|
|
860
|
+
activationId: NodeActivationId;
|
|
1095
861
|
workflowId: WorkflowId;
|
|
1096
862
|
nodeId: NodeId;
|
|
863
|
+
parent?: ParentExecutionRef;
|
|
864
|
+
executionOptions?: RunExecutionOptions;
|
|
865
|
+
batchId?: string;
|
|
866
|
+
ctx: NodeExecutionContext;
|
|
867
|
+
}>;
|
|
868
|
+
type NodeActivationRequest = (NodeActivationRequestBase & Readonly<{
|
|
869
|
+
kind: "single";
|
|
870
|
+
input: Items;
|
|
871
|
+
}>) | (NodeActivationRequestBase & Readonly<{
|
|
872
|
+
kind: "multi";
|
|
873
|
+
inputsByPort: NodeInputsByPort;
|
|
874
|
+
}>);
|
|
875
|
+
interface NodeActivationReceipt {
|
|
876
|
+
receiptId: string;
|
|
877
|
+
mode?: "local" | "worker";
|
|
878
|
+
queue?: string;
|
|
1097
879
|
}
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
endpointPath: string;
|
|
1102
|
-
workflowId: WorkflowId;
|
|
1103
|
-
nodeId: NodeId;
|
|
1104
|
-
methods: ReadonlyArray<HttpMethod>;
|
|
1105
|
-
parseJsonBody?: (body: unknown) => unknown;
|
|
880
|
+
interface PreparedNodeActivationDispatch {
|
|
881
|
+
readonly receipt: NodeActivationReceipt;
|
|
882
|
+
dispatch(): Promise<void>;
|
|
1106
883
|
}
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
884
|
+
interface NodeActivationContinuation {
|
|
885
|
+
markNodeRunning(args: {
|
|
886
|
+
runId: RunId;
|
|
887
|
+
activationId: NodeActivationId;
|
|
888
|
+
nodeId: NodeId;
|
|
889
|
+
inputsByPort: NodeInputsByPort;
|
|
890
|
+
}): Promise<void>;
|
|
891
|
+
resumeFromNodeResult(args: {
|
|
892
|
+
runId: RunId;
|
|
893
|
+
activationId: NodeActivationId;
|
|
894
|
+
nodeId: NodeId;
|
|
895
|
+
outputs: NodeOutputs;
|
|
896
|
+
}): Promise<RunResult>;
|
|
897
|
+
resumeFromNodeError(args: {
|
|
898
|
+
runId: RunId;
|
|
899
|
+
activationId: NodeActivationId;
|
|
900
|
+
nodeId: NodeId;
|
|
901
|
+
error: Error;
|
|
902
|
+
}): Promise<RunResult>;
|
|
903
|
+
}
|
|
904
|
+
interface NodeActivationScheduler {
|
|
905
|
+
setContinuation?(continuation: NodeActivationContinuation): void;
|
|
906
|
+
prepareDispatch(request: NodeActivationRequest): Promise<PreparedNodeActivationDispatch>;
|
|
907
|
+
cancel?(receiptId: string): Promise<void>;
|
|
908
|
+
}
|
|
909
|
+
interface WorkflowNodeInstanceFactory {
|
|
910
|
+
createNodes(workflow: WorkflowDefinition): ReadonlyMap<NodeId, unknown>;
|
|
911
|
+
createByType(type: TypeToken<unknown>): unknown;
|
|
1130
912
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
interface WorkflowRunnerService {
|
|
1134
|
-
runById(args: {
|
|
1135
|
-
workflowId: WorkflowId;
|
|
1136
|
-
startAt?: NodeId;
|
|
1137
|
-
items: Items;
|
|
1138
|
-
parent?: ParentExecutionRef;
|
|
1139
|
-
}): Promise<RunResult>;
|
|
913
|
+
interface NodeExecutor {
|
|
914
|
+
execute(request: NodeActivationRequest): Promise<NodeOutputs>;
|
|
1140
915
|
}
|
|
1141
|
-
interface
|
|
1142
|
-
|
|
916
|
+
interface WorkflowSnapshotFactory {
|
|
917
|
+
create(workflow: WorkflowDefinition): PersistedWorkflowSnapshot;
|
|
1143
918
|
}
|
|
1144
|
-
interface
|
|
1145
|
-
|
|
1146
|
-
|
|
919
|
+
interface WorkflowSnapshotResolver {
|
|
920
|
+
resolve(args: {
|
|
921
|
+
workflowId: WorkflowId;
|
|
922
|
+
workflowSnapshot?: PersistedWorkflowSnapshot;
|
|
923
|
+
}): WorkflowDefinition | undefined;
|
|
1147
924
|
}
|
|
1148
|
-
|
|
1149
|
-
|
|
925
|
+
/** Optional host wiring for trigger lifecycle logs (boot skip + activation sync). */
|
|
926
|
+
interface TriggerRuntimeDiagnostics {
|
|
927
|
+
info(message: string): void;
|
|
928
|
+
warn(message: string): void;
|
|
1150
929
|
}
|
|
1151
|
-
interface
|
|
1152
|
-
|
|
930
|
+
interface EngineDeps {
|
|
931
|
+
credentialSessions: CredentialSessionService;
|
|
932
|
+
liveWorkflowRepository: LiveWorkflowRepository;
|
|
933
|
+
workflowRepository: WorkflowRepository;
|
|
934
|
+
/** When {@link AllWorkflowsActiveWorkflowActivationPolicy}, all workflows behave as active (tests). */
|
|
935
|
+
workflowActivationPolicy: WorkflowActivationPolicy;
|
|
936
|
+
nodeResolver: NodeResolver;
|
|
937
|
+
triggerSetupStateRepository: TriggerSetupStateRepository;
|
|
938
|
+
webhookTriggerMatcher: WebhookTriggerMatcher;
|
|
939
|
+
runIdFactory: RunIdFactory;
|
|
940
|
+
activationIdFactory: ActivationIdFactory;
|
|
941
|
+
workflowExecutionRepository: WorkflowExecutionRepository;
|
|
942
|
+
activationScheduler: NodeActivationScheduler;
|
|
943
|
+
runDataFactory: RunDataFactory;
|
|
944
|
+
executionContextFactory: ExecutionContextFactory;
|
|
945
|
+
executionTelemetryFactory?: ExecutionTelemetryFactory;
|
|
946
|
+
nodeExecutor: NodeExecutor;
|
|
947
|
+
eventBus?: RunEventBus;
|
|
948
|
+
tokenRegistry: PersistedWorkflowTokenRegistryLike;
|
|
949
|
+
workflowNodeInstanceFactory: WorkflowNodeInstanceFactory;
|
|
950
|
+
/** Defaults for prune/storage snapshot when workflow omits explicit policy fields. */
|
|
951
|
+
workflowPolicyRuntimeDefaults?: WorkflowPolicyRuntimeDefaults;
|
|
952
|
+
/** When set, logs inactive-workflow skips at boot and trigger start/stop on activation changes. */
|
|
953
|
+
triggerRuntimeDiagnostics?: TriggerRuntimeDiagnostics;
|
|
954
|
+
/** When set, the polling-trigger runtime uses this logger for cycle info/debug/error. */
|
|
955
|
+
pollingTriggerLogger?: PollingTriggerLogger;
|
|
1153
956
|
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
markCompleted(args: {
|
|
1166
|
-
nodeId: NodeId;
|
|
1167
|
-
activationId?: NodeActivationId;
|
|
1168
|
-
inputsByPort?: NodeInputsByPort;
|
|
1169
|
-
outputs?: NodeOutputs;
|
|
1170
|
-
}): Promise<void>;
|
|
1171
|
-
markFailed(args: {
|
|
1172
|
-
nodeId: NodeId;
|
|
1173
|
-
activationId?: NodeActivationId;
|
|
1174
|
-
inputsByPort?: NodeInputsByPort;
|
|
1175
|
-
error: Error;
|
|
1176
|
-
}): Promise<void>;
|
|
1177
|
-
appendConnectionInvocation(args: ConnectionInvocationAppendArgs): Promise<void>;
|
|
1178
|
-
/**
|
|
1179
|
-
* Annotates the current snapshot for `nodeId` with the id of the child run spawned by a
|
|
1180
|
-
* SubWorkflow invocation. Called from `SubWorkflowNode.execute` after `runById` resolves.
|
|
1181
|
-
* The engine's subsequent `markCompleted` call preserves the value via `previous.childRunId`.
|
|
1182
|
-
*/
|
|
1183
|
-
setChildRunId?(args: {
|
|
1184
|
-
nodeId: NodeId;
|
|
1185
|
-
childRunId: RunId;
|
|
1186
|
-
}): Promise<void>;
|
|
957
|
+
//#endregion
|
|
958
|
+
//#region src/contracts/retryPolicySpec.types.d.ts
|
|
959
|
+
/**
|
|
960
|
+
* In-process retry policy for runnable nodes. Serialized configs use the same
|
|
961
|
+
* `kind` discriminator (`JSON.stringify` / persisted workflows).
|
|
962
|
+
*
|
|
963
|
+
* `maxAttempts` is the total number of tries including the first (e.g. 3 means up to 2 delays after failures).
|
|
964
|
+
*/
|
|
965
|
+
type RetryPolicySpec = NoneRetryPolicySpec | FixedRetryPolicySpec | ExponentialRetryPolicySpec;
|
|
966
|
+
interface NoneRetryPolicySpec {
|
|
967
|
+
readonly kind: "none";
|
|
1187
968
|
}
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
969
|
+
interface FixedRetryPolicySpec {
|
|
970
|
+
readonly kind: "fixed";
|
|
971
|
+
/** Total attempts including the first execution. Must be >= 1. */
|
|
972
|
+
readonly maxAttempts: number;
|
|
973
|
+
readonly delayMs: number;
|
|
1192
974
|
}
|
|
1193
|
-
interface
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
975
|
+
interface ExponentialRetryPolicySpec {
|
|
976
|
+
readonly kind: "exponential";
|
|
977
|
+
/** Total attempts including the first execution. Must be >= 1. */
|
|
978
|
+
readonly maxAttempts: number;
|
|
979
|
+
readonly initialDelayMs: number;
|
|
980
|
+
readonly multiplier: number;
|
|
981
|
+
readonly maxDelayMs?: number;
|
|
982
|
+
/** When true, each delay is multiplied by a random factor in [1, 1.2). */
|
|
983
|
+
readonly jitter?: boolean;
|
|
1197
984
|
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
985
|
+
//#endregion
|
|
986
|
+
//#region src/contracts/workflowTypes.d.ts
|
|
987
|
+
type NodeIdRef<TJson = unknown> = NodeId & Readonly<{
|
|
988
|
+
__codemationNodeJson?: TJson;
|
|
989
|
+
}>;
|
|
990
|
+
type NodeKind = "trigger" | "node";
|
|
991
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
992
|
+
interface JsonObject {
|
|
993
|
+
readonly [key: string]: JsonValue;
|
|
1201
994
|
}
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
995
|
+
type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
996
|
+
type JsonArray = ReadonlyArray<JsonValue>;
|
|
997
|
+
/** JSON value that is not a top-level array (nested arrays inside objects are allowed). */
|
|
998
|
+
type JsonNonArray = JsonPrimitive | JsonObject;
|
|
999
|
+
interface Edge {
|
|
1000
|
+
from: {
|
|
1001
|
+
nodeId: NodeId;
|
|
1002
|
+
output: OutputPortKey;
|
|
1003
|
+
};
|
|
1004
|
+
to: {
|
|
1005
|
+
nodeId: NodeId;
|
|
1006
|
+
input: InputPortKey;
|
|
1007
|
+
};
|
|
1205
1008
|
}
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1009
|
+
/**
|
|
1010
|
+
* Named connection from a parent node to child nodes that exist in {@link WorkflowDefinition.nodes}
|
|
1011
|
+
* but are not traversed by the main execution graph. Parents are commonly executable nodes, but may
|
|
1012
|
+
* also be connection-owned nodes for recursive agent attachments.
|
|
1013
|
+
*/
|
|
1014
|
+
interface WorkflowNodeConnection {
|
|
1015
|
+
readonly parentNodeId: NodeId;
|
|
1016
|
+
readonly connectionName: NodeConnectionName;
|
|
1017
|
+
readonly childNodeIds: ReadonlyArray<NodeId>;
|
|
1212
1018
|
}
|
|
1213
|
-
interface
|
|
1019
|
+
interface WorkflowDefinition {
|
|
1020
|
+
id: WorkflowId;
|
|
1214
1021
|
name: string;
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1022
|
+
nodes: NodeDefinition[];
|
|
1023
|
+
edges: Edge[];
|
|
1024
|
+
/**
|
|
1025
|
+
* Optional metadata: which nodes are connection-owned children (e.g. AI agent `llm` / `tools` slots).
|
|
1026
|
+
* When omitted, all nodes in {@link nodes} are treated as executable for topology.
|
|
1027
|
+
*/
|
|
1028
|
+
readonly connections?: ReadonlyArray<WorkflowNodeConnection>;
|
|
1029
|
+
/** Directory + file-stem path under a workflow discovery root (for UI grouping only). */
|
|
1030
|
+
discoveryPathSegments?: readonly string[];
|
|
1031
|
+
/** Retention for run JSON and binaries (seconds). Host/env may supply defaults when omitted. */
|
|
1032
|
+
readonly prunePolicy?: WorkflowPrunePolicySpec;
|
|
1033
|
+
/** Whether to keep run data after completion. Host/env may supply defaults when omitted. */
|
|
1034
|
+
readonly storagePolicy?: WorkflowStoragePolicySpec;
|
|
1035
|
+
/** Invoked after a node fails permanently (retries exhausted) and node error handler did not recover. */
|
|
1036
|
+
readonly workflowErrorHandler?: WorkflowErrorHandlerSpec;
|
|
1223
1037
|
}
|
|
1224
|
-
interface
|
|
1225
|
-
|
|
1038
|
+
interface WorkflowGraph {
|
|
1039
|
+
next(nodeId: NodeId, output: OutputPortKey): ReadonlyArray<Readonly<{
|
|
1226
1040
|
nodeId: NodeId;
|
|
1227
|
-
|
|
1228
|
-
}
|
|
1229
|
-
openReadStream(attachment: BinaryAttachment): Promise<BinaryStorageReadResult | undefined>;
|
|
1041
|
+
input: InputPortKey;
|
|
1042
|
+
}>>;
|
|
1230
1043
|
}
|
|
1231
|
-
interface
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
iterationId?: NodeIterationId;
|
|
1249
|
-
/** Item index (0-based) within the current activation's batch; set alongside {@link iterationId}. */
|
|
1250
|
-
itemIndex?: number;
|
|
1251
|
-
/** When set, this ctx is executing inside a sub-agent triggered by the named parent invocation. */
|
|
1252
|
-
parentInvocationId?: ConnectionInvocationId;
|
|
1044
|
+
interface WorkflowGraphFactory {
|
|
1045
|
+
create(def: WorkflowDefinition): WorkflowGraph;
|
|
1046
|
+
}
|
|
1047
|
+
interface NodeConfigBase {
|
|
1048
|
+
readonly kind: NodeKind;
|
|
1049
|
+
readonly type: TypeToken<unknown>;
|
|
1050
|
+
readonly name?: string;
|
|
1051
|
+
readonly id?: NodeId;
|
|
1052
|
+
readonly icon?: string;
|
|
1053
|
+
readonly execution?: Readonly<{
|
|
1054
|
+
hint?: "local" | "worker";
|
|
1055
|
+
queue?: string;
|
|
1056
|
+
}>;
|
|
1057
|
+
/** In-process execute retries (runnable nodes). Triggers typically omit this. */
|
|
1058
|
+
readonly retryPolicy?: RetryPolicySpec;
|
|
1059
|
+
/** Recover from execute failures; return outputs to continue, or rethrow to fail the node. */
|
|
1060
|
+
readonly nodeErrorHandler?: NodeErrorHandlerSpec;
|
|
1253
1061
|
/**
|
|
1254
|
-
*
|
|
1255
|
-
*
|
|
1062
|
+
* When true, edges carrying zero items on an output port still schedule single-input downstream nodes.
|
|
1063
|
+
* Decided from the **source** node that produced the (empty) output. Default (false/undefined): empty
|
|
1064
|
+
* main batches skip downstream execution and propagate the empty path.
|
|
1256
1065
|
*/
|
|
1257
|
-
|
|
1066
|
+
readonly continueWhenEmptyOutput?: boolean;
|
|
1258
1067
|
/**
|
|
1259
|
-
*
|
|
1068
|
+
* Declared I/O port names for canvas authoring (unioned with ports inferred from edges).
|
|
1069
|
+
* Use for dynamic routers (Switch) and future error ports.
|
|
1070
|
+
*/
|
|
1071
|
+
readonly declaredOutputPorts?: ReadonlyArray<OutputPortKey>;
|
|
1072
|
+
readonly declaredInputPorts?: ReadonlyArray<InputPortKey>;
|
|
1073
|
+
getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;
|
|
1074
|
+
/**
|
|
1075
|
+
* Marker: this node emits {@link import("./assertionTypes").AssertionResult}-shaped items on its
|
|
1076
|
+
* `main` port. The TestSuiteOrchestrator (and host-side TestAssertionPersister) listen for
|
|
1077
|
+
* `nodeCompleted` events from nodes with this flag set, and persist their output items as
|
|
1078
|
+
* TestAssertion records (only when the run carries a `testContext`). Set on assertion node
|
|
1079
|
+
* configs (e.g. `AssertionNodeConfig`, `StringEqualsAssertionNodeConfig`).
|
|
1260
1080
|
*/
|
|
1261
|
-
readonly
|
|
1262
|
-
}
|
|
1263
|
-
interface ExecutionContextFactory {
|
|
1264
|
-
create(args: {
|
|
1265
|
-
runId: RunId;
|
|
1266
|
-
workflowId: WorkflowId;
|
|
1267
|
-
parent?: ParentExecutionRef;
|
|
1268
|
-
policySnapshot?: PersistedRunPolicySnapshot;
|
|
1269
|
-
subworkflowDepth: number;
|
|
1270
|
-
engineMaxNodeActivations: number;
|
|
1271
|
-
engineMaxSubworkflowDepth: number;
|
|
1272
|
-
data: RunDataSnapshot;
|
|
1273
|
-
nodeState?: NodeExecutionStatePublisher;
|
|
1274
|
-
telemetry?: ExecutionTelemetry;
|
|
1275
|
-
getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
|
|
1276
|
-
testContext?: RunTestContext;
|
|
1277
|
-
}): ExecutionContext;
|
|
1278
|
-
}
|
|
1279
|
-
interface NodeExecutionContext<TConfig extends NodeConfigBase = NodeConfigBase> extends ExecutionContext {
|
|
1280
|
-
nodeId: NodeId;
|
|
1281
|
-
activationId: NodeActivationId;
|
|
1282
|
-
config: TConfig;
|
|
1283
|
-
telemetry: NodeExecutionTelemetry;
|
|
1284
|
-
binary: NodeBinaryAttachmentService;
|
|
1285
|
-
}
|
|
1286
|
-
interface PollingTriggerHandle {
|
|
1081
|
+
readonly emitsAssertions?: true;
|
|
1287
1082
|
/**
|
|
1288
|
-
*
|
|
1289
|
-
*
|
|
1290
|
-
*
|
|
1083
|
+
* Static configuration summary surfaced in the workflow inspector — the design-time
|
|
1084
|
+
* "what does this node do" panel that renders before any run telemetry exists.
|
|
1085
|
+
*
|
|
1086
|
+
* Return 2–6 short label/value pairs derived from this config (method + url for an HTTP
|
|
1087
|
+
* call, model + tool list for an agent, schedule + timezone for a cron trigger, etc.).
|
|
1088
|
+
* Values are truncated by the UI; aim for one line each. Return `undefined` to opt out
|
|
1089
|
+
* — the inspector hides the section when no rows are produced.
|
|
1090
|
+
*
|
|
1091
|
+
* Implement on the config class instance so the function can read sibling config fields.
|
|
1092
|
+
* `defineNode({ inspectorSummary })` plumbs through to this.
|
|
1291
1093
|
*/
|
|
1292
|
-
|
|
1293
|
-
intervalMs: number;
|
|
1294
|
-
seedState?: TState;
|
|
1295
|
-
runCycle: (cycleCtx: {
|
|
1296
|
-
previousState: TState | undefined;
|
|
1297
|
-
signal: AbortSignal;
|
|
1298
|
-
}) => Promise<{
|
|
1299
|
-
items: Items<TItem>;
|
|
1300
|
-
nextState: TState;
|
|
1301
|
-
}>;
|
|
1302
|
-
}): Promise<TState | undefined>;
|
|
1303
|
-
/** Convenience dedup-window helper. */
|
|
1304
|
-
readonly dedup: PollingTriggerDedupWindow;
|
|
1305
|
-
}
|
|
1306
|
-
interface TriggerSetupContext<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>, TSetupState$1 extends JsonValue | undefined = TriggerNodeSetupState<TConfig>> extends ExecutionContext {
|
|
1307
|
-
trigger: TriggerInstanceId;
|
|
1308
|
-
config: TConfig;
|
|
1309
|
-
previousState: TSetupState$1;
|
|
1310
|
-
registerCleanup(cleanup: TriggerCleanupHandle): void;
|
|
1311
|
-
emit(items: Items): Promise<void>;
|
|
1312
|
-
/** Generic polling-trigger surface. Pre-binds trigger id, emit, and registerCleanup. */
|
|
1313
|
-
readonly polling: PollingTriggerHandle;
|
|
1314
|
-
}
|
|
1315
|
-
interface TriggerTestItemsContext<TConfig extends TriggerNodeConfig<any, any> = TriggerNodeConfig<any, any>, TSetupState$1 extends JsonValue | undefined = TriggerNodeSetupState<TConfig>> extends ExecutionContext {
|
|
1316
|
-
trigger: TriggerInstanceId;
|
|
1317
|
-
nodeId: NodeId;
|
|
1318
|
-
config: TConfig;
|
|
1319
|
-
previousState: TSetupState$1;
|
|
1094
|
+
inspectorSummary?(): ReadonlyArray<NodeInspectorSummaryRow> | undefined;
|
|
1320
1095
|
}
|
|
1321
1096
|
/**
|
|
1322
|
-
*
|
|
1323
|
-
* leader-election metadata can be coordinated centrally rather than pushed into
|
|
1324
|
-
* package-level setup code.
|
|
1097
|
+
* One row of a node's static configuration summary. See {@link NodeConfigBase.inspectorSummary}.
|
|
1325
1098
|
*/
|
|
1326
|
-
interface
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
state: TState;
|
|
1330
|
-
}
|
|
1331
|
-
interface TriggerSetupStateRepository {
|
|
1332
|
-
load(trigger: TriggerInstanceId): Promise<PersistedTriggerSetupState | undefined>;
|
|
1333
|
-
save(state: PersistedTriggerSetupState): Promise<void>;
|
|
1334
|
-
delete(trigger: TriggerInstanceId): Promise<void>;
|
|
1335
|
-
}
|
|
1336
|
-
interface TriggerCleanupHandle {
|
|
1337
|
-
stop(): Promise<void> | void;
|
|
1338
|
-
}
|
|
1339
|
-
interface EngineHost {
|
|
1340
|
-
credentialSessions: CredentialSessionService;
|
|
1341
|
-
workflows?: WorkflowRunnerService;
|
|
1099
|
+
interface NodeInspectorSummaryRow {
|
|
1100
|
+
readonly label: string;
|
|
1101
|
+
readonly value: string;
|
|
1342
1102
|
}
|
|
1103
|
+
declare const runnableNodeInputType: unique symbol;
|
|
1104
|
+
declare const runnableNodeOutputType: unique symbol;
|
|
1105
|
+
declare const triggerNodeOutputType: unique symbol;
|
|
1343
1106
|
/**
|
|
1344
|
-
*
|
|
1345
|
-
*
|
|
1346
|
-
* (wire `item.json` is unchanged). Transform helpers may opt into binary preservation, while routers and
|
|
1347
|
-
* pass-through nodes should return explicit items when they need to preserve full item state.
|
|
1107
|
+
* Runnable node: **`TInputJson`** is what **`inputSchema`** validates on **`item.json`** (the wire payload).
|
|
1108
|
+
* **`TOutputJson`** is emitted `item.json` on outputs.
|
|
1348
1109
|
*/
|
|
1349
|
-
interface
|
|
1350
|
-
readonly input: TInputJson$1;
|
|
1351
|
-
readonly item: Item;
|
|
1352
|
-
readonly itemIndex: number;
|
|
1353
|
-
readonly items: Items;
|
|
1354
|
-
readonly ctx: NodeExecutionContext<TConfig>;
|
|
1355
|
-
}
|
|
1356
|
-
interface RunnableNode<TConfig extends RunnableNodeConfig<any, any> = RunnableNodeConfig<any, any>, TInputJson$1 = unknown, _TOutputJson = unknown> {
|
|
1110
|
+
interface RunnableNodeConfig<TInputJson$1 = unknown, TOutputJson$1 = unknown> extends NodeConfigBase {
|
|
1357
1111
|
readonly kind: "node";
|
|
1112
|
+
readonly [runnableNodeInputType]?: TInputJson$1;
|
|
1113
|
+
readonly [runnableNodeOutputType]?: TOutputJson$1;
|
|
1358
1114
|
/**
|
|
1359
|
-
*
|
|
1360
|
-
*
|
|
1361
|
-
* Prefer describing dynamic router ports (Switch) and fixed multi-ports (If true/false)
|
|
1362
|
-
* via {@link NodeConfigBase.declaredOutputPorts}. Engine defaults to `["main"]` when omitted.
|
|
1115
|
+
* Optional Zod input contract for {@link RunnableNode} when not set on the node class.
|
|
1116
|
+
* Resolution order: node instance `inputSchema`, then config `inputSchema`, then `z.unknown()`.
|
|
1363
1117
|
*/
|
|
1364
|
-
readonly outputPorts?: ReadonlyArray<OutputPortKey>;
|
|
1365
|
-
/** When omitted, engine uses {@link RunnableNodeConfig.inputSchema} or `z.unknown()`. */
|
|
1366
1118
|
readonly inputSchema?: ZodType<TInputJson$1>;
|
|
1367
|
-
|
|
1119
|
+
/**
|
|
1120
|
+
* When an activation receives **zero** input items, the engine normally runs `execute` zero times.
|
|
1121
|
+
* Set to **`runOnce`** to run `execute` once with an empty `items` batch (and a synthetic wire item for schema parsing).
|
|
1122
|
+
* Used by batch-style callback nodes (built-in `Callback`) so `callback([], ctx)` still runs.
|
|
1123
|
+
*/
|
|
1124
|
+
readonly emptyBatchExecution?: "skip" | "runOnce";
|
|
1368
1125
|
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1126
|
+
declare const triggerNodeSetupStateType: unique symbol;
|
|
1127
|
+
interface TriggerNodeConfig<TOutputJson$1 = unknown, TSetupState$1 extends JsonValue | undefined = undefined> extends NodeConfigBase {
|
|
1128
|
+
readonly kind: "trigger";
|
|
1129
|
+
readonly [triggerNodeOutputType]?: TOutputJson$1;
|
|
1130
|
+
readonly [triggerNodeSetupStateType]?: TSetupState$1;
|
|
1373
1131
|
/**
|
|
1374
|
-
*
|
|
1375
|
-
*
|
|
1376
|
-
*
|
|
1377
|
-
* Engine defaults to `["main"]` when omitted.
|
|
1132
|
+
* Distinguishes triggers driven by the live activation policy (webhooks, cron, polling) from
|
|
1133
|
+
* triggers driven only by the {@link TestSuiteOrchestrator}. `WorkflowActivation` skips
|
|
1134
|
+
* `"test"` triggers; the orchestrator skips `"live"` triggers. Defaults to `"live"` when omitted.
|
|
1378
1135
|
*/
|
|
1379
|
-
|
|
1380
|
-
executeMulti(inputsByPort: NodeInputsByPort, ctx: NodeExecutionContext<TConfig>): Promise<NodeOutputs>;
|
|
1136
|
+
readonly triggerKind?: "live" | "test";
|
|
1381
1137
|
}
|
|
1382
|
-
type
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1138
|
+
type RunnableNodeInputJson<TConfig extends RunnableNodeConfig<any, any>> = TConfig extends RunnableNodeConfig<infer TInputJson, any> ? TInputJson : never;
|
|
1139
|
+
type RunnableNodeOutputJson<TConfig extends RunnableNodeConfig<any, any>> = TConfig extends RunnableNodeConfig<any, infer TOutputJson> ? TOutputJson : never;
|
|
1140
|
+
type TriggerNodeOutputJson<TConfig extends TriggerNodeConfig<any, any>> = TConfig extends TriggerNodeConfig<infer TOutputJson, any> ? TOutputJson : never;
|
|
1141
|
+
type TriggerNodeSetupState<TConfig extends TriggerNodeConfig<any, any>> = TConfig extends TriggerNodeConfig<any, infer TSetupState> ? TSetupState : never;
|
|
1142
|
+
interface NodeDefinition {
|
|
1143
|
+
id: NodeId;
|
|
1144
|
+
kind: NodeKind;
|
|
1145
|
+
type: TypeToken<unknown>;
|
|
1146
|
+
name?: string;
|
|
1147
|
+
config: NodeConfigBase;
|
|
1388
1148
|
}
|
|
1389
|
-
interface
|
|
1390
|
-
|
|
1149
|
+
interface NodeRef {
|
|
1150
|
+
id: NodeId;
|
|
1151
|
+
kind: NodeKind;
|
|
1152
|
+
name?: string;
|
|
1391
1153
|
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1154
|
+
declare function nodeRef<TJson>(nodeId: NodeId): NodeIdRef<TJson>;
|
|
1155
|
+
type PairedItemRef = Readonly<{
|
|
1156
|
+
nodeId: NodeId;
|
|
1157
|
+
output: OutputPortKey;
|
|
1158
|
+
itemIndex: number;
|
|
1159
|
+
}>;
|
|
1160
|
+
type BinaryPreviewKind = "image" | "audio" | "video" | "download";
|
|
1161
|
+
type BinaryAttachment = Readonly<{
|
|
1162
|
+
id: string;
|
|
1163
|
+
storageKey: string;
|
|
1164
|
+
mimeType: string;
|
|
1165
|
+
size: number;
|
|
1166
|
+
storageDriver: string;
|
|
1167
|
+
previewKind: BinaryPreviewKind;
|
|
1168
|
+
createdAt: string;
|
|
1394
1169
|
runId: RunId;
|
|
1170
|
+
workflowId: WorkflowId;
|
|
1171
|
+
nodeId: NodeId;
|
|
1395
1172
|
activationId: NodeActivationId;
|
|
1173
|
+
filename?: string;
|
|
1174
|
+
sha256?: string;
|
|
1175
|
+
}>;
|
|
1176
|
+
type ItemBinary = Readonly<Record<string, BinaryAttachment>>;
|
|
1177
|
+
type Item<TJson = unknown> = Readonly<{
|
|
1178
|
+
json: TJson;
|
|
1179
|
+
binary?: ItemBinary;
|
|
1180
|
+
meta?: Readonly<Record<string, unknown>>;
|
|
1181
|
+
paired?: ReadonlyArray<PairedItemRef>;
|
|
1182
|
+
}>;
|
|
1183
|
+
type Items<TJson = unknown> = ReadonlyArray<Item<TJson>>;
|
|
1184
|
+
type NodeOutputs = Partial<Record<OutputPortKey, Items>>;
|
|
1185
|
+
type RunId = string;
|
|
1186
|
+
type NodeActivationId = string;
|
|
1187
|
+
/**
|
|
1188
|
+
* One per-item iteration of a runnable node's execute loop. Refines `NodeActivationId` for
|
|
1189
|
+
* per-item connection invocations and telemetry. Undefined when the executing node is a batch
|
|
1190
|
+
* node or trigger that does not iterate items.
|
|
1191
|
+
*/
|
|
1192
|
+
type NodeIterationId = string;
|
|
1193
|
+
interface ParentExecutionRef {
|
|
1194
|
+
runId: RunId;
|
|
1396
1195
|
workflowId: WorkflowId;
|
|
1397
1196
|
nodeId: NodeId;
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1197
|
+
/** Subworkflow depth of the **spawning** run (0 = root). Passed when starting a child run. */
|
|
1198
|
+
subworkflowDepth?: number;
|
|
1199
|
+
/** Effective max node activations from the parent run (propagated to child policy merge). */
|
|
1200
|
+
engineMaxNodeActivations?: number;
|
|
1201
|
+
/** Effective max subworkflow depth from the parent run (propagated to child policy merge). */
|
|
1202
|
+
engineMaxSubworkflowDepth?: number;
|
|
1203
|
+
/**
|
|
1204
|
+
* Test-suite linkage inherited by the child subworkflow run. Set by whichever node
|
|
1205
|
+
* spawns the subworkflow when its own `ctx.testContext` is present, so assertions
|
|
1206
|
+
* emitted inside a subworkflow land under the correct parent test case.
|
|
1207
|
+
*/
|
|
1208
|
+
testContext?: RunTestContext;
|
|
1402
1209
|
}
|
|
1403
|
-
interface
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
cancel?(receiptId: string): Promise<void>;
|
|
1210
|
+
interface RunDataSnapshot {
|
|
1211
|
+
getOutputs(nodeId: NodeId): NodeOutputs | undefined;
|
|
1212
|
+
getOutputItems<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, output?: OutputPortKey): Items<TJson>;
|
|
1213
|
+
getOutputItem<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, itemIndex: number, output?: OutputPortKey): Item<TJson> | undefined;
|
|
1408
1214
|
}
|
|
1409
|
-
interface
|
|
1410
|
-
|
|
1215
|
+
interface MutableRunData extends RunDataSnapshot {
|
|
1216
|
+
setOutputs(nodeId: NodeId, outputs: NodeOutputs): void;
|
|
1217
|
+
dump(): Record<NodeId, NodeOutputs>;
|
|
1411
1218
|
}
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
parent?: ParentExecutionRef;
|
|
1418
|
-
executionOptions?: RunExecutionOptions;
|
|
1419
|
-
batchId?: string;
|
|
1420
|
-
ctx: NodeExecutionContext;
|
|
1421
|
-
}>;
|
|
1422
|
-
type NodeActivationRequest = (NodeActivationRequestBase & Readonly<{
|
|
1423
|
-
kind: "single";
|
|
1424
|
-
input: Items;
|
|
1425
|
-
}>) | (NodeActivationRequestBase & Readonly<{
|
|
1426
|
-
kind: "multi";
|
|
1427
|
-
inputsByPort: NodeInputsByPort;
|
|
1428
|
-
}>);
|
|
1429
|
-
interface NodeActivationReceipt {
|
|
1430
|
-
receiptId: string;
|
|
1431
|
-
mode?: "local" | "worker";
|
|
1432
|
-
queue?: string;
|
|
1219
|
+
interface RunDataFactory {
|
|
1220
|
+
create(initial?: Record<NodeId, NodeOutputs>): MutableRunData;
|
|
1221
|
+
}
|
|
1222
|
+
interface RunIdFactory {
|
|
1223
|
+
makeRunId(): RunId;
|
|
1433
1224
|
}
|
|
1434
|
-
interface
|
|
1435
|
-
|
|
1436
|
-
dispatch(): Promise<void>;
|
|
1225
|
+
interface ActivationIdFactory {
|
|
1226
|
+
makeActivationId(): NodeActivationId;
|
|
1437
1227
|
}
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
nodeId: NodeId;
|
|
1449
|
-
outputs: NodeOutputs;
|
|
1450
|
-
}): Promise<RunResult>;
|
|
1451
|
-
resumeFromNodeError(args: {
|
|
1452
|
-
runId: RunId;
|
|
1453
|
-
activationId: NodeActivationId;
|
|
1228
|
+
type UpstreamRefPlaceholder = `$${number}`;
|
|
1229
|
+
declare const branchRef: (index: number) => UpstreamRefPlaceholder;
|
|
1230
|
+
type ExecutionMode = "local" | "worker";
|
|
1231
|
+
interface NodeSchedulerDecision {
|
|
1232
|
+
mode: ExecutionMode;
|
|
1233
|
+
queue?: string;
|
|
1234
|
+
}
|
|
1235
|
+
interface NodeOffloadPolicy {
|
|
1236
|
+
decide(args: {
|
|
1237
|
+
workflowId: WorkflowId;
|
|
1454
1238
|
nodeId: NodeId;
|
|
1455
|
-
|
|
1456
|
-
}):
|
|
1239
|
+
config: NodeConfigBase;
|
|
1240
|
+
}): NodeSchedulerDecision;
|
|
1457
1241
|
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1242
|
+
/** Whether to persist run execution data after the workflow finishes. */
|
|
1243
|
+
type WorkflowStoragePolicyMode = "ALL" | "SUCCESS" | "ERROR" | "NEVER";
|
|
1244
|
+
type WorkflowStoragePolicySpec = WorkflowStoragePolicyMode | TypeToken<WorkflowStoragePolicyResolver>;
|
|
1245
|
+
interface WorkflowStoragePolicyResolver {
|
|
1246
|
+
shouldPersist(args: WorkflowStoragePolicyDecisionArgs): boolean | Promise<boolean>;
|
|
1462
1247
|
}
|
|
1463
|
-
interface
|
|
1464
|
-
|
|
1465
|
-
|
|
1248
|
+
interface WorkflowStoragePolicyDecisionArgs {
|
|
1249
|
+
readonly runId: RunId;
|
|
1250
|
+
readonly workflowId: WorkflowId;
|
|
1251
|
+
readonly workflow: WorkflowDefinition;
|
|
1252
|
+
readonly finalStatus: "completed" | "failed";
|
|
1253
|
+
readonly startedAt: string;
|
|
1254
|
+
readonly finishedAt: string;
|
|
1466
1255
|
}
|
|
1467
|
-
interface
|
|
1468
|
-
|
|
1256
|
+
interface WorkflowPrunePolicySpec {
|
|
1257
|
+
readonly runDataRetentionSeconds?: number;
|
|
1258
|
+
readonly binaryRetentionSeconds?: number;
|
|
1259
|
+
readonly telemetrySpanRetentionSeconds?: number;
|
|
1260
|
+
readonly telemetryArtifactRetentionSeconds?: number;
|
|
1261
|
+
readonly telemetryMetricRetentionSeconds?: number;
|
|
1469
1262
|
}
|
|
1470
|
-
interface
|
|
1471
|
-
|
|
1263
|
+
interface PersistedRunPolicySnapshot {
|
|
1264
|
+
readonly retentionSeconds?: number;
|
|
1265
|
+
readonly binaryRetentionSeconds?: number;
|
|
1266
|
+
readonly telemetrySpanRetentionSeconds?: number;
|
|
1267
|
+
readonly telemetryArtifactRetentionSeconds?: number;
|
|
1268
|
+
readonly telemetryMetricRetentionSeconds?: number;
|
|
1269
|
+
readonly storagePolicy: WorkflowStoragePolicyMode;
|
|
1472
1270
|
}
|
|
1473
|
-
interface
|
|
1474
|
-
|
|
1475
|
-
workflowId: WorkflowId;
|
|
1476
|
-
workflowSnapshot?: PersistedWorkflowSnapshot;
|
|
1477
|
-
}): WorkflowDefinition | undefined;
|
|
1271
|
+
interface WorkflowErrorHandler {
|
|
1272
|
+
onError(ctx: WorkflowErrorContext): void | Promise<void>;
|
|
1478
1273
|
}
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1274
|
+
interface WorkflowErrorContext {
|
|
1275
|
+
readonly runId: RunId;
|
|
1276
|
+
readonly workflowId: WorkflowId;
|
|
1277
|
+
readonly workflow: WorkflowDefinition;
|
|
1278
|
+
readonly failedNodeId: NodeId;
|
|
1279
|
+
readonly error: Error;
|
|
1280
|
+
readonly startedAt: string;
|
|
1281
|
+
readonly finishedAt: string;
|
|
1483
1282
|
}
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
/** Defaults for prune/storage snapshot when workflow omits explicit policy fields. */
|
|
1505
|
-
workflowPolicyRuntimeDefaults?: WorkflowPolicyRuntimeDefaults;
|
|
1506
|
-
/** When set, logs inactive-workflow skips at boot and trigger start/stop on activation changes. */
|
|
1507
|
-
triggerRuntimeDiagnostics?: TriggerRuntimeDiagnostics;
|
|
1508
|
-
/** When set, the polling-trigger runtime uses this logger for cycle info/debug/error. */
|
|
1509
|
-
pollingTriggerLogger?: PollingTriggerLogger;
|
|
1283
|
+
type WorkflowErrorHandlerSpec = TypeToken<WorkflowErrorHandler> | WorkflowErrorHandler;
|
|
1284
|
+
interface NodeErrorHandlerArgs<TConfig extends NodeConfigBase = NodeConfigBase> {
|
|
1285
|
+
readonly kind: "single" | "multi";
|
|
1286
|
+
readonly items: Items;
|
|
1287
|
+
readonly inputsByPort: Readonly<Record<InputPortKey, Items>> | undefined;
|
|
1288
|
+
readonly ctx: NodeExecutionContext<TConfig>;
|
|
1289
|
+
readonly error: Error;
|
|
1290
|
+
}
|
|
1291
|
+
interface NodeErrorHandler {
|
|
1292
|
+
handle<TConfig extends NodeConfigBase>(args: NodeErrorHandlerArgs<TConfig>): Promise<NodeOutputs>;
|
|
1293
|
+
}
|
|
1294
|
+
type NodeErrorHandlerSpec = TypeToken<NodeErrorHandler> | NodeErrorHandler;
|
|
1295
|
+
/** Runtime defaults when workflow omits prune/storage fields (typically from host env). */
|
|
1296
|
+
interface WorkflowPolicyRuntimeDefaults {
|
|
1297
|
+
readonly retentionSeconds?: number;
|
|
1298
|
+
readonly binaryRetentionSeconds?: number;
|
|
1299
|
+
readonly telemetrySpanRetentionSeconds?: number;
|
|
1300
|
+
readonly telemetryArtifactRetentionSeconds?: number;
|
|
1301
|
+
readonly telemetryMetricRetentionSeconds?: number;
|
|
1302
|
+
readonly storagePolicy?: WorkflowStoragePolicyMode;
|
|
1510
1303
|
}
|
|
1511
1304
|
//#endregion
|
|
1512
|
-
//#region src/contracts/
|
|
1305
|
+
//#region src/contracts/testTriggerTypes.d.ts
|
|
1513
1306
|
/**
|
|
1514
|
-
*
|
|
1515
|
-
*
|
|
1307
|
+
* Identifier minted by the host (or in-memory test runner) for one execution of a test suite.
|
|
1308
|
+
* One TestSuiteRun produces N child workflow runs, one per item yielded by `generateItems`.
|
|
1309
|
+
*/
|
|
1310
|
+
type TestSuiteRunId = string;
|
|
1311
|
+
/**
|
|
1312
|
+
* Setup context passed to a {@link TestTriggerNodeConfig.generateItems} callback. Distinct from
|
|
1313
|
+
* {@link import("./runtimeTypes").TriggerSetupContext} on purpose: test triggers are not
|
|
1314
|
+
* activated by the live trigger lifecycle (webhooks, cron, polling) and never call `emit` —
|
|
1315
|
+
* the orchestrator pulls from the iterable they return and dispatches one run per item.
|
|
1316
|
+
*/
|
|
1317
|
+
interface TestTriggerSetupContext<TConfig extends TestTriggerNodeConfig<unknown> = TestTriggerNodeConfig<unknown>> {
|
|
1318
|
+
readonly workflowId: WorkflowId;
|
|
1319
|
+
readonly nodeId: NodeId;
|
|
1320
|
+
readonly config: TConfig;
|
|
1321
|
+
readonly testSuiteRunId: TestSuiteRunId;
|
|
1322
|
+
/**
|
|
1323
|
+
* Resolves a credential session for a slot declared on this trigger's
|
|
1324
|
+
* {@link import("./workflowTypes").NodeConfigBase.getCredentialRequirements}. Same contract as
|
|
1325
|
+
* {@link import("./runtimeTypes").ExecutionContext.getCredential}.
|
|
1326
|
+
*/
|
|
1327
|
+
getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
|
|
1328
|
+
/** AbortSignal raised when the suite is cancelled — long-running pulls should bail out. */
|
|
1329
|
+
readonly signal: AbortSignal;
|
|
1330
|
+
}
|
|
1331
|
+
/**
|
|
1332
|
+
* A trigger config that emits **test cases**. Each item yielded by {@link generateItems}
|
|
1333
|
+
* becomes one workflow run (with `executionOptions.testContext` set), so 10 yielded items
|
|
1334
|
+
* → 10 runs marked under the same TestSuiteRun.
|
|
1516
1335
|
*
|
|
1517
|
-
*
|
|
1336
|
+
* The trigger is otherwise a normal {@link TriggerNodeConfig} (so the canvas treats it like
|
|
1337
|
+
* any other trigger), but its `triggerKind` is `"test"` so the live activation policy skips it.
|
|
1518
1338
|
*/
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1339
|
+
interface TestTriggerNodeConfig<TOutputJson$1 = unknown> extends TriggerNodeConfig<TOutputJson$1, undefined> {
|
|
1340
|
+
readonly triggerKind: "test";
|
|
1341
|
+
/**
|
|
1342
|
+
* Author-supplied async iterable of items, evaluated lazily. Implementations may fetch from
|
|
1343
|
+
* credentialed APIs, read fixture files, or yield hard-coded items. The orchestrator iterates
|
|
1344
|
+
* and dispatches one run per item, with concurrency capped by {@link concurrency} (default 4).
|
|
1345
|
+
*/
|
|
1346
|
+
generateItems(ctx: TestTriggerSetupContext<TestTriggerNodeConfig<TOutputJson$1>>): AsyncIterable<Item<TOutputJson$1>>;
|
|
1347
|
+
/** Per-suite-run cap on simultaneously-executing test cases. Default: 4. */
|
|
1348
|
+
readonly concurrency?: number;
|
|
1349
|
+
/**
|
|
1350
|
+
* Free-form description of where the test cases come from — surfaced in the node properties
|
|
1351
|
+
* panel and the suite-detail header so authors revisiting the workflow six months later
|
|
1352
|
+
* remember which mailbox / folder / fixture file the cases originate from.
|
|
1353
|
+
*
|
|
1354
|
+
* Example: `"All emails in the Gmail label \"test/triage-fixtures\" — 14 messages as of 2026-05-03."`
|
|
1355
|
+
*/
|
|
1356
|
+
readonly description?: string;
|
|
1357
|
+
/**
|
|
1358
|
+
* Resolves a human-readable label for one yielded test case (e.g. email subject). The
|
|
1359
|
+
* orchestrator calls this once per yielded item, persists the result on the run, and the
|
|
1360
|
+
* Tests-tab UI uses it to render the case row instead of the opaque runId. Return
|
|
1361
|
+
* `undefined` to fall back to "Case #N".
|
|
1362
|
+
*/
|
|
1363
|
+
caseLabel?(item: Item<TOutputJson$1>): string | undefined;
|
|
1522
1364
|
}
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1365
|
+
//#endregion
|
|
1366
|
+
//#region src/events/runEvents.d.ts
|
|
1367
|
+
/**
|
|
1368
|
+
* Outcome of a single test case (one workflow run dispatched by the test-suite orchestrator).
|
|
1369
|
+
* - `running`: workflow still in flight
|
|
1370
|
+
* - `succeeded`: workflow completed AND all assertions passed (or no assertions)
|
|
1371
|
+
* - `failed`: workflow failed OR (workflow completed but ≥1 assertion failed)
|
|
1372
|
+
* - `errored` / `cancelled`: workflow itself errored or was cancelled
|
|
1373
|
+
*/
|
|
1374
|
+
type TestCaseRunStatus = "running" | "succeeded" | "failed" | "errored" | "cancelled";
|
|
1375
|
+
/** Aggregate outcome of a TestSuiteRun. */
|
|
1376
|
+
type TestSuiteRunStatus = "succeeded" | "failed" | "partial" | "errored" | "cancelled";
|
|
1377
|
+
type RunEvent = Readonly<{
|
|
1378
|
+
kind: "runCreated";
|
|
1379
|
+
runId: RunId;
|
|
1380
|
+
workflowId: WorkflowId;
|
|
1381
|
+
parent?: ParentExecutionRef;
|
|
1382
|
+
at: string;
|
|
1383
|
+
}> | Readonly<{
|
|
1384
|
+
kind: "runSaved";
|
|
1385
|
+
runId: RunId;
|
|
1386
|
+
workflowId: WorkflowId;
|
|
1387
|
+
parent?: ParentExecutionRef;
|
|
1388
|
+
at: string;
|
|
1389
|
+
state: PersistedRunState;
|
|
1390
|
+
}> | Readonly<{
|
|
1391
|
+
kind: "nodeQueued";
|
|
1392
|
+
runId: RunId;
|
|
1393
|
+
workflowId: WorkflowId;
|
|
1394
|
+
parent?: ParentExecutionRef;
|
|
1395
|
+
at: string;
|
|
1396
|
+
snapshot: NodeExecutionSnapshot;
|
|
1397
|
+
}> | Readonly<{
|
|
1398
|
+
kind: "nodeStarted";
|
|
1399
|
+
runId: RunId;
|
|
1400
|
+
workflowId: WorkflowId;
|
|
1401
|
+
parent?: ParentExecutionRef;
|
|
1402
|
+
at: string;
|
|
1403
|
+
snapshot: NodeExecutionSnapshot;
|
|
1404
|
+
}> | Readonly<{
|
|
1405
|
+
kind: "nodeCompleted";
|
|
1406
|
+
runId: RunId;
|
|
1407
|
+
workflowId: WorkflowId;
|
|
1408
|
+
parent?: ParentExecutionRef;
|
|
1409
|
+
at: string;
|
|
1410
|
+
snapshot: NodeExecutionSnapshot;
|
|
1411
|
+
}> | Readonly<{
|
|
1412
|
+
kind: "nodeFailed";
|
|
1413
|
+
runId: RunId;
|
|
1414
|
+
workflowId: WorkflowId;
|
|
1415
|
+
parent?: ParentExecutionRef;
|
|
1416
|
+
at: string;
|
|
1417
|
+
snapshot: NodeExecutionSnapshot;
|
|
1418
|
+
}> | Readonly<{
|
|
1419
|
+
kind: "connectionInvocationStarted";
|
|
1420
|
+
runId: RunId;
|
|
1421
|
+
workflowId: WorkflowId;
|
|
1422
|
+
parent?: ParentExecutionRef;
|
|
1423
|
+
at: string;
|
|
1424
|
+
record: ConnectionInvocationRecord;
|
|
1425
|
+
}> | Readonly<{
|
|
1426
|
+
kind: "connectionInvocationCompleted";
|
|
1427
|
+
runId: RunId;
|
|
1428
|
+
workflowId: WorkflowId;
|
|
1429
|
+
parent?: ParentExecutionRef;
|
|
1430
|
+
at: string;
|
|
1431
|
+
record: ConnectionInvocationRecord;
|
|
1432
|
+
}> | Readonly<{
|
|
1433
|
+
kind: "connectionInvocationFailed";
|
|
1434
|
+
runId: RunId;
|
|
1435
|
+
workflowId: WorkflowId;
|
|
1436
|
+
parent?: ParentExecutionRef;
|
|
1437
|
+
at: string;
|
|
1438
|
+
record: ConnectionInvocationRecord;
|
|
1439
|
+
}> | Readonly<{
|
|
1440
|
+
kind: "testSuiteStarted";
|
|
1441
|
+
testSuiteRunId: TestSuiteRunId;
|
|
1442
|
+
workflowId: WorkflowId;
|
|
1443
|
+
triggerNodeId: string;
|
|
1444
|
+
triggerNodeName?: string;
|
|
1445
|
+
concurrency: number;
|
|
1446
|
+
at: string;
|
|
1447
|
+
}> | Readonly<{
|
|
1448
|
+
kind: "testSuiteFinished";
|
|
1449
|
+
testSuiteRunId: TestSuiteRunId;
|
|
1450
|
+
workflowId: WorkflowId;
|
|
1451
|
+
status: TestSuiteRunStatus;
|
|
1452
|
+
totalCases: number;
|
|
1453
|
+
passedCases: number;
|
|
1454
|
+
failedCases: number;
|
|
1455
|
+
at: string;
|
|
1456
|
+
}> | Readonly<{
|
|
1457
|
+
kind: "testCaseStarted";
|
|
1458
|
+
testSuiteRunId: TestSuiteRunId;
|
|
1459
|
+
testCaseIndex: number;
|
|
1460
|
+
runId: RunId;
|
|
1461
|
+
workflowId: WorkflowId;
|
|
1462
|
+
testCaseLabel?: string;
|
|
1463
|
+
at: string;
|
|
1464
|
+
}> | Readonly<{
|
|
1465
|
+
kind: "testCaseCompleted";
|
|
1466
|
+
testSuiteRunId: TestSuiteRunId;
|
|
1467
|
+
testCaseIndex: number;
|
|
1468
|
+
runId: RunId;
|
|
1469
|
+
workflowId: WorkflowId;
|
|
1470
|
+
status: TestCaseRunStatus;
|
|
1471
|
+
at: string;
|
|
1472
|
+
}>;
|
|
1473
|
+
interface RunEventSubscription {
|
|
1474
|
+
close(): Promise<void>;
|
|
1528
1475
|
}
|
|
1529
|
-
interface
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
readonly initialDelayMs: number;
|
|
1534
|
-
readonly multiplier: number;
|
|
1535
|
-
readonly maxDelayMs?: number;
|
|
1536
|
-
/** When true, each delay is multiplied by a random factor in [1, 1.2). */
|
|
1537
|
-
readonly jitter?: boolean;
|
|
1476
|
+
interface RunEventBus {
|
|
1477
|
+
publish(event: RunEvent): Promise<void>;
|
|
1478
|
+
subscribe(onEvent: (event: RunEvent) => void): Promise<RunEventSubscription>;
|
|
1479
|
+
subscribeToWorkflow(workflowId: WorkflowId, onEvent: (event: RunEvent) => void): Promise<RunEventSubscription>;
|
|
1538
1480
|
}
|
|
1539
1481
|
//#endregion
|
|
1540
|
-
//#region src/
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
interface JsonObject {
|
|
1547
|
-
readonly [key: string]: JsonValue;
|
|
1548
|
-
}
|
|
1549
|
-
type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
1550
|
-
type JsonArray = ReadonlyArray<JsonValue>;
|
|
1551
|
-
/** JSON value that is not a top-level array (nested arrays inside objects are allowed). */
|
|
1552
|
-
type JsonNonArray = JsonPrimitive | JsonObject;
|
|
1553
|
-
interface Edge {
|
|
1554
|
-
from: {
|
|
1555
|
-
nodeId: NodeId;
|
|
1556
|
-
output: OutputPortKey;
|
|
1557
|
-
};
|
|
1558
|
-
to: {
|
|
1559
|
-
nodeId: NodeId;
|
|
1560
|
-
input: InputPortKey;
|
|
1561
|
-
};
|
|
1482
|
+
//#region src/policies/executionLimits/EngineExecutionLimitsPolicy.d.ts
|
|
1483
|
+
interface EngineExecutionLimitsPolicyConfig {
|
|
1484
|
+
readonly defaultMaxNodeActivations: number;
|
|
1485
|
+
readonly hardMaxNodeActivations: number;
|
|
1486
|
+
readonly defaultMaxSubworkflowDepth: number;
|
|
1487
|
+
readonly hardMaxSubworkflowDepth: number;
|
|
1562
1488
|
}
|
|
1489
|
+
/** Framework defaults for {@link EngineExecutionLimitsPolicy} (merged with host `runtime.engineExecutionLimits`). */
|
|
1490
|
+
declare const ENGINE_EXECUTION_LIMITS_DEFAULTS: EngineExecutionLimitsPolicyConfig;
|
|
1563
1491
|
/**
|
|
1564
|
-
*
|
|
1565
|
-
* but are not traversed by the main execution graph. Parents are commonly executable nodes, but may
|
|
1566
|
-
* also be connection-owned nodes for recursive agent attachments.
|
|
1492
|
+
* Resolves per-run execution limits: defaults, hard ceilings, and subworkflow depth for new runs.
|
|
1567
1493
|
*/
|
|
1568
|
-
|
|
1569
|
-
readonly
|
|
1570
|
-
|
|
1571
|
-
readonly childNodeIds: ReadonlyArray<NodeId>;
|
|
1572
|
-
}
|
|
1573
|
-
interface WorkflowDefinition {
|
|
1574
|
-
id: WorkflowId;
|
|
1575
|
-
name: string;
|
|
1576
|
-
nodes: NodeDefinition[];
|
|
1577
|
-
edges: Edge[];
|
|
1494
|
+
declare class EngineExecutionLimitsPolicy {
|
|
1495
|
+
private readonly config;
|
|
1496
|
+
constructor(config?: EngineExecutionLimitsPolicyConfig);
|
|
1578
1497
|
/**
|
|
1579
|
-
*
|
|
1580
|
-
*
|
|
1498
|
+
* Effective options for a new root run (depth 0): defaults merged with engine ceilings.
|
|
1499
|
+
* Replaces a separate one-method factory for root-run bootstrap.
|
|
1581
1500
|
*/
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
/** Retention for run JSON and binaries (seconds). Host/env may supply defaults when omitted. */
|
|
1586
|
-
readonly prunePolicy?: WorkflowPrunePolicySpec;
|
|
1587
|
-
/** Whether to keep run data after completion. Host/env may supply defaults when omitted. */
|
|
1588
|
-
readonly storagePolicy?: WorkflowStoragePolicySpec;
|
|
1589
|
-
/** Invoked after a node fails permanently (retries exhausted) and node error handler did not recover. */
|
|
1590
|
-
readonly workflowErrorHandler?: WorkflowErrorHandlerSpec;
|
|
1591
|
-
}
|
|
1592
|
-
interface WorkflowGraph {
|
|
1593
|
-
next(nodeId: NodeId, output: OutputPortKey): ReadonlyArray<Readonly<{
|
|
1594
|
-
nodeId: NodeId;
|
|
1595
|
-
input: InputPortKey;
|
|
1596
|
-
}>>;
|
|
1597
|
-
}
|
|
1598
|
-
interface WorkflowGraphFactory {
|
|
1599
|
-
create(def: WorkflowDefinition): WorkflowGraph;
|
|
1501
|
+
createRootExecutionOptions(): RunExecutionOptions;
|
|
1502
|
+
mergeExecutionOptionsForNewRun(parent: ParentExecutionRef | undefined, user: RunExecutionOptions | undefined): RunExecutionOptions;
|
|
1503
|
+
private capNumber;
|
|
1600
1504
|
}
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
readonly
|
|
1605
|
-
readonly
|
|
1606
|
-
readonly
|
|
1607
|
-
readonly
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
readonly
|
|
1613
|
-
|
|
1614
|
-
readonly
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
readonly
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
readonly declaredOutputPorts?: ReadonlyArray<OutputPortKey>;
|
|
1626
|
-
readonly declaredInputPorts?: ReadonlyArray<InputPortKey>;
|
|
1627
|
-
getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;
|
|
1505
|
+
//#endregion
|
|
1506
|
+
//#region src/di/CoreTokens.d.ts
|
|
1507
|
+
declare const CoreTokens: {
|
|
1508
|
+
readonly PersistedWorkflowTokenRegistry: TypeToken<PersistedWorkflowTokenRegistryLike>;
|
|
1509
|
+
readonly CredentialSessionService: TypeToken<CredentialSessionService>;
|
|
1510
|
+
readonly CredentialTypeRegistry: TypeToken<CredentialTypeRegistry>;
|
|
1511
|
+
readonly WorkflowRunnerService: TypeToken<WorkflowRunnerService>;
|
|
1512
|
+
readonly LiveWorkflowRepository: TypeToken<LiveWorkflowRepository>;
|
|
1513
|
+
readonly WorkflowRepository: TypeToken<WorkflowRepository>;
|
|
1514
|
+
readonly NodeResolver: TypeToken<NodeResolver>;
|
|
1515
|
+
readonly WorkflowNodeInstanceFactory: TypeToken<WorkflowNodeInstanceFactory>;
|
|
1516
|
+
readonly RunIdFactory: TypeToken<RunIdFactory>;
|
|
1517
|
+
readonly ActivationIdFactory: TypeToken<ActivationIdFactory>;
|
|
1518
|
+
readonly WorkflowExecutionRepository: TypeToken<WorkflowExecutionRepository>;
|
|
1519
|
+
readonly TriggerSetupStateRepository: TypeToken<TriggerSetupStateRepository>;
|
|
1520
|
+
readonly NodeActivationScheduler: TypeToken<NodeActivationScheduler>;
|
|
1521
|
+
readonly RunDataFactory: TypeToken<RunDataFactory>;
|
|
1522
|
+
readonly ExecutionContextFactory: TypeToken<ExecutionContextFactory>;
|
|
1523
|
+
readonly RunEventBus: TypeToken<RunEventBus>;
|
|
1524
|
+
readonly BinaryStorage: TypeToken<BinaryStorage>;
|
|
1525
|
+
readonly WebhookBasePath: TypeToken<string>;
|
|
1526
|
+
/** Engine execution limits (defaults + optional host overrides). Consumers may bind a custom instance to override. */
|
|
1527
|
+
readonly EngineExecutionLimitsPolicy: TypeToken<EngineExecutionLimitsPolicy>;
|
|
1528
|
+
readonly WorkflowActivationPolicy: TypeToken<WorkflowActivationPolicy>;
|
|
1628
1529
|
/**
|
|
1629
|
-
*
|
|
1630
|
-
*
|
|
1631
|
-
*
|
|
1632
|
-
* TestAssertion records (only when the run carries a `testContext`). Set on assertion node
|
|
1633
|
-
* configs (e.g. `AssertionNodeConfig`, `StringEqualsAssertionNodeConfig`).
|
|
1530
|
+
* Optional. When registered, AIAgentNode uses it to resolve mcpServers bindings,
|
|
1531
|
+
* validate scopes, open pool connections, and prepare the MCP ToolSet map.
|
|
1532
|
+
* Not registered in the default core bootstrap — the host provides the implementation.
|
|
1634
1533
|
*/
|
|
1635
|
-
readonly
|
|
1636
|
-
}
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
declare const triggerNodeOutputType: unique symbol;
|
|
1534
|
+
readonly AgentMcpIntegration: TypeToken<AgentMcpIntegration>;
|
|
1535
|
+
};
|
|
1536
|
+
//#endregion
|
|
1537
|
+
//#region src/contracts/runTypes.d.ts
|
|
1640
1538
|
/**
|
|
1641
|
-
*
|
|
1642
|
-
*
|
|
1539
|
+
* Test-suite linkage for a run. When set, this run was started by a TestSuiteOrchestrator
|
|
1540
|
+
* as one test case inside a TestSuiteRun. The `IsTestRun` node and host-side persisters key
|
|
1541
|
+
* off the presence of this field. Subworkflow runs inherit it from their parent run.
|
|
1643
1542
|
*/
|
|
1644
|
-
interface
|
|
1645
|
-
readonly
|
|
1646
|
-
readonly
|
|
1647
|
-
readonly [runnableNodeOutputType]?: TOutputJson$1;
|
|
1648
|
-
/**
|
|
1649
|
-
* Optional Zod input contract for {@link RunnableNode} when not set on the node class.
|
|
1650
|
-
* Resolution order: node instance `inputSchema`, then config `inputSchema`, then `z.unknown()`.
|
|
1651
|
-
*/
|
|
1652
|
-
readonly inputSchema?: ZodType<TInputJson$1>;
|
|
1543
|
+
interface RunTestContext {
|
|
1544
|
+
readonly testSuiteRunId: string;
|
|
1545
|
+
readonly testCaseIndex: number;
|
|
1653
1546
|
/**
|
|
1654
|
-
*
|
|
1655
|
-
*
|
|
1656
|
-
*
|
|
1547
|
+
* Optional human-friendly label for this test case (e.g. an email subject when fixtures
|
|
1548
|
+
* are loaded from a mailbox). Resolved per item by `TestTrigger.caseLabel(item)` if set,
|
|
1549
|
+
* persisted on `Run.test_case_label` so the Tests-tab tree-table can show "RFQ for batch 14"
|
|
1550
|
+
* instead of "run_1777755971399_bbb86beac1396".
|
|
1657
1551
|
*/
|
|
1658
|
-
readonly
|
|
1552
|
+
readonly testCaseLabel?: string;
|
|
1553
|
+
}
|
|
1554
|
+
interface RunExecutionOptions {
|
|
1555
|
+
/** Run-intent override: force the inline scheduler and bypass node-level offload decisions. */
|
|
1556
|
+
localOnly?: boolean;
|
|
1557
|
+
/** Marks runs started from webhook handling so orchestration can apply webhook-specific continuation rules. */
|
|
1558
|
+
webhook?: boolean;
|
|
1559
|
+
mode?: "manual" | "debug";
|
|
1560
|
+
sourceWorkflowId?: WorkflowId;
|
|
1561
|
+
sourceRunId?: RunId;
|
|
1562
|
+
derivedFromRunId?: RunId;
|
|
1563
|
+
isMutable?: boolean;
|
|
1564
|
+
/** Set by the engine for this run: 0 = root, 1 = first child subworkflow, … */
|
|
1565
|
+
subworkflowDepth?: number;
|
|
1566
|
+
/** Effective cap after engine policy merge (successful node completions per run). */
|
|
1567
|
+
maxNodeActivations?: number;
|
|
1568
|
+
/** Effective cap after engine policy merge (subworkflow nesting). */
|
|
1569
|
+
maxSubworkflowDepth?: number;
|
|
1570
|
+
/** Present iff started by a TestSuiteOrchestrator; propagates to subworkflow runs via {@link ParentExecutionRef.testContext}. */
|
|
1571
|
+
testContext?: RunTestContext;
|
|
1572
|
+
}
|
|
1573
|
+
/** Engine-owned counters persisted with the run (worker-safe). */
|
|
1574
|
+
interface EngineRunCounters {
|
|
1575
|
+
completedNodeActivations: number;
|
|
1659
1576
|
}
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
* `"test"` triggers; the orchestrator skips `"live"` triggers. Defaults to `"live"` when omitted.
|
|
1669
|
-
*/
|
|
1670
|
-
readonly triggerKind?: "live" | "test";
|
|
1577
|
+
type RunStopCondition = Readonly<{
|
|
1578
|
+
kind: "workflowCompleted";
|
|
1579
|
+
}> | Readonly<{
|
|
1580
|
+
kind: "nodeCompleted";
|
|
1581
|
+
nodeId: NodeId;
|
|
1582
|
+
}>;
|
|
1583
|
+
interface RunStateResetRequest {
|
|
1584
|
+
clearFromNodeId: NodeId;
|
|
1671
1585
|
}
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
type TriggerNodeOutputJson<TConfig extends TriggerNodeConfig<any, any>> = TConfig extends TriggerNodeConfig<infer TOutputJson, any> ? TOutputJson : never;
|
|
1675
|
-
type TriggerNodeSetupState<TConfig extends TriggerNodeConfig<any, any>> = TConfig extends TriggerNodeConfig<any, infer TSetupState> ? TSetupState : never;
|
|
1676
|
-
interface NodeDefinition {
|
|
1677
|
-
id: NodeId;
|
|
1678
|
-
kind: NodeKind;
|
|
1679
|
-
type: TypeToken<unknown>;
|
|
1680
|
-
name?: string;
|
|
1681
|
-
config: NodeConfigBase;
|
|
1586
|
+
interface PersistedRunControlState {
|
|
1587
|
+
stopCondition?: RunStopCondition;
|
|
1682
1588
|
}
|
|
1683
|
-
interface
|
|
1589
|
+
interface PersistedWorkflowSnapshotNode {
|
|
1684
1590
|
id: NodeId;
|
|
1685
1591
|
kind: NodeKind;
|
|
1686
1592
|
name?: string;
|
|
1593
|
+
nodeTokenId: PersistedTokenId;
|
|
1594
|
+
configTokenId: PersistedTokenId;
|
|
1595
|
+
tokenName?: string;
|
|
1596
|
+
configTokenName?: string;
|
|
1597
|
+
config: unknown;
|
|
1598
|
+
/** Pre-computed static configuration summary; populated by WorkflowSnapshotCodec. */
|
|
1599
|
+
inspectorSummary?: ReadonlyArray<Readonly<{
|
|
1600
|
+
label: string;
|
|
1601
|
+
value: string;
|
|
1602
|
+
}>>;
|
|
1687
1603
|
}
|
|
1688
|
-
|
|
1689
|
-
|
|
1604
|
+
interface PersistedWorkflowSnapshot {
|
|
1605
|
+
id: WorkflowId;
|
|
1606
|
+
name: string;
|
|
1607
|
+
nodes: ReadonlyArray<PersistedWorkflowSnapshotNode>;
|
|
1608
|
+
edges: ReadonlyArray<Edge>;
|
|
1609
|
+
/** When the snapshot was built from a live workflow definition that configured a workflow error handler. */
|
|
1610
|
+
workflowErrorHandlerConfigured?: boolean;
|
|
1611
|
+
/** Connection metadata for child nodes not in the execution graph (e.g. AI agent attachments). */
|
|
1612
|
+
connections?: ReadonlyArray<WorkflowNodeConnection>;
|
|
1613
|
+
}
|
|
1614
|
+
type PinnedNodeOutputsByPort = Readonly<Record<OutputPortKey, Items>>;
|
|
1615
|
+
interface PersistedMutableNodeState {
|
|
1616
|
+
pinnedOutputsByPort?: PinnedNodeOutputsByPort;
|
|
1617
|
+
lastDebugInput?: Items;
|
|
1618
|
+
}
|
|
1619
|
+
interface PersistedMutableRunState {
|
|
1620
|
+
nodesById: Readonly<Record<NodeId, PersistedMutableNodeState>>;
|
|
1621
|
+
}
|
|
1622
|
+
type NodeInputsByPort = Readonly<Record<InputPortKey, Items>>;
|
|
1623
|
+
interface RunQueueEntry {
|
|
1690
1624
|
nodeId: NodeId;
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1625
|
+
input: Items;
|
|
1626
|
+
toInput?: InputPortKey;
|
|
1627
|
+
batchId?: string;
|
|
1628
|
+
from?: Readonly<{
|
|
1629
|
+
nodeId: NodeId;
|
|
1630
|
+
output: OutputPortKey;
|
|
1631
|
+
}>;
|
|
1632
|
+
collect?: Readonly<{
|
|
1633
|
+
expectedInputs: ReadonlyArray<InputPortKey>;
|
|
1634
|
+
received: Readonly<Record<InputPortKey, Items>>;
|
|
1635
|
+
}>;
|
|
1636
|
+
}
|
|
1637
|
+
type NodeExecutionStatus = "pending" | "queued" | "running" | "completed" | "failed" | "skipped";
|
|
1638
|
+
interface NodeExecutionError {
|
|
1639
|
+
message: string;
|
|
1640
|
+
name?: string;
|
|
1641
|
+
stack?: string;
|
|
1642
|
+
details?: JsonValue;
|
|
1643
|
+
}
|
|
1644
|
+
interface NodeExecutionSnapshot {
|
|
1703
1645
|
runId: RunId;
|
|
1704
1646
|
workflowId: WorkflowId;
|
|
1705
1647
|
nodeId: NodeId;
|
|
1706
|
-
activationId
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1648
|
+
activationId?: NodeActivationId;
|
|
1649
|
+
parent?: ParentExecutionRef;
|
|
1650
|
+
status: NodeExecutionStatus;
|
|
1651
|
+
usedPinnedOutput?: boolean;
|
|
1652
|
+
queuedAt?: string;
|
|
1653
|
+
startedAt?: string;
|
|
1654
|
+
finishedAt?: string;
|
|
1655
|
+
updatedAt: string;
|
|
1656
|
+
inputsByPort?: NodeInputsByPort;
|
|
1657
|
+
outputs?: NodeOutputs;
|
|
1658
|
+
error?: NodeExecutionError;
|
|
1659
|
+
/**
|
|
1660
|
+
* When the node is a SubWorkflow invocation, the run id of the child run it spawned.
|
|
1661
|
+
* Populated after the child run completes so the UI can deep-link to that specific execution.
|
|
1662
|
+
*/
|
|
1663
|
+
childRunId?: RunId;
|
|
1664
|
+
}
|
|
1665
|
+
/** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
|
|
1666
|
+
type ConnectionInvocationId = string;
|
|
1721
1667
|
/**
|
|
1722
|
-
* One
|
|
1723
|
-
*
|
|
1724
|
-
* node or trigger that does not iterate items.
|
|
1668
|
+
* One logical LLM or tool call under an owning workflow node (e.g. AI agent).
|
|
1669
|
+
* The owning node defines what {@link managedInput} and {@link managedOutput} contain.
|
|
1725
1670
|
*/
|
|
1726
|
-
|
|
1727
|
-
|
|
1671
|
+
interface ConnectionInvocationRecord {
|
|
1672
|
+
readonly invocationId: ConnectionInvocationId;
|
|
1673
|
+
readonly runId: RunId;
|
|
1674
|
+
readonly workflowId: WorkflowId;
|
|
1675
|
+
readonly connectionNodeId: NodeId;
|
|
1676
|
+
readonly parentAgentNodeId: NodeId;
|
|
1677
|
+
readonly parentAgentActivationId: NodeActivationId;
|
|
1678
|
+
readonly status: NodeExecutionStatus;
|
|
1679
|
+
readonly managedInput?: JsonValue;
|
|
1680
|
+
readonly managedOutput?: JsonValue;
|
|
1681
|
+
/** Short human-readable description of what this invocation is doing right now (e.g. `"calling search_messages"`). Rendered as a sub-line on the canvas node card. */
|
|
1682
|
+
readonly statusLabel?: string;
|
|
1683
|
+
/** Stable identifier for the thing this invocation acts on (e.g. an MCP tool name like `"search_messages"`). Persists across status transitions so the inspector can show it on completed/failed entries too. Connection nodes that ARE the tool (e.g. node-backed agent tools) leave this unset — the parent node id already identifies the subject. */
|
|
1684
|
+
readonly subjectName?: string;
|
|
1685
|
+
readonly error?: NodeExecutionError;
|
|
1686
|
+
readonly queuedAt?: string;
|
|
1687
|
+
readonly startedAt?: string;
|
|
1688
|
+
readonly finishedAt?: string;
|
|
1689
|
+
readonly updatedAt: string;
|
|
1690
|
+
/** Per-item iteration id minted by the engine when this invocation occurred inside a runnable node's per-item loop. */
|
|
1691
|
+
readonly iterationId?: NodeIterationId;
|
|
1692
|
+
/** Item index (0-based) of the iteration that produced this invocation. */
|
|
1693
|
+
readonly itemIndex?: number;
|
|
1694
|
+
/** When set, this invocation was produced inside a sub-agent triggered by the named parent invocation. */
|
|
1695
|
+
readonly parentInvocationId?: ConnectionInvocationId;
|
|
1696
|
+
}
|
|
1697
|
+
/** Arguments for appending a {@link ConnectionInvocationRecord} (engine fills run/workflow ids and timestamps). */
|
|
1698
|
+
type ConnectionInvocationAppendArgs = Readonly<{
|
|
1699
|
+
invocationId: ConnectionInvocationId;
|
|
1700
|
+
connectionNodeId: NodeId;
|
|
1701
|
+
parentAgentNodeId: NodeId;
|
|
1702
|
+
parentAgentActivationId: NodeActivationId;
|
|
1703
|
+
status: NodeExecutionStatus;
|
|
1704
|
+
managedInput?: JsonValue;
|
|
1705
|
+
managedOutput?: JsonValue;
|
|
1706
|
+
statusLabel?: string;
|
|
1707
|
+
subjectName?: string;
|
|
1708
|
+
error?: NodeExecutionError;
|
|
1709
|
+
queuedAt?: string;
|
|
1710
|
+
startedAt?: string;
|
|
1711
|
+
finishedAt?: string;
|
|
1712
|
+
iterationId?: NodeIterationId;
|
|
1713
|
+
itemIndex?: number;
|
|
1714
|
+
parentInvocationId?: ConnectionInvocationId;
|
|
1715
|
+
}>;
|
|
1716
|
+
interface RunCurrentState {
|
|
1717
|
+
outputsByNode: Record<NodeId, NodeOutputs>;
|
|
1718
|
+
nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
|
|
1719
|
+
/** Append-only history of connection-scoped invocations (LLM/tool) for inspector and canvas. */
|
|
1720
|
+
connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
|
|
1721
|
+
mutableState?: PersistedMutableRunState;
|
|
1722
|
+
}
|
|
1723
|
+
interface CurrentStateExecutionRequest {
|
|
1724
|
+
workflow: WorkflowDefinition;
|
|
1725
|
+
items?: Items;
|
|
1726
|
+
parent?: ParentExecutionRef;
|
|
1727
|
+
executionOptions?: RunExecutionOptions;
|
|
1728
|
+
workflowSnapshot?: PersistedWorkflowSnapshot;
|
|
1729
|
+
mutableState?: PersistedMutableRunState;
|
|
1730
|
+
currentState?: RunCurrentState;
|
|
1731
|
+
stopCondition?: RunStopCondition;
|
|
1732
|
+
reset?: RunStateResetRequest;
|
|
1733
|
+
}
|
|
1734
|
+
interface ExecutionFrontierPlan {
|
|
1735
|
+
rootNodeId?: NodeId;
|
|
1736
|
+
rootNodeInput?: Items;
|
|
1737
|
+
queue: RunQueueEntry[];
|
|
1738
|
+
currentState: RunCurrentState;
|
|
1739
|
+
stopCondition: RunStopCondition;
|
|
1740
|
+
satisfiedNodeIds: ReadonlyArray<NodeId>;
|
|
1741
|
+
skippedNodeIds: ReadonlyArray<NodeId>;
|
|
1742
|
+
clearedNodeIds: ReadonlyArray<NodeId>;
|
|
1743
|
+
preservedPinnedNodeIds: ReadonlyArray<NodeId>;
|
|
1744
|
+
}
|
|
1745
|
+
type RunStatus = "running" | "pending" | "completed" | "failed";
|
|
1746
|
+
interface RunSummary {
|
|
1728
1747
|
runId: RunId;
|
|
1729
1748
|
workflowId: WorkflowId;
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
subworkflowDepth?: number;
|
|
1733
|
-
/** Effective max node activations from the parent run (propagated to child policy merge). */
|
|
1734
|
-
engineMaxNodeActivations?: number;
|
|
1735
|
-
/** Effective max subworkflow depth from the parent run (propagated to child policy merge). */
|
|
1736
|
-
engineMaxSubworkflowDepth?: number;
|
|
1749
|
+
startedAt: string;
|
|
1750
|
+
status: RunStatus;
|
|
1737
1751
|
/**
|
|
1738
|
-
* Test-
|
|
1739
|
-
*
|
|
1740
|
-
*
|
|
1752
|
+
* Test-case status for runs dispatched as part of a TestSuiteRun. Carries the
|
|
1753
|
+
* assertion-rollup-corrected outcome the test orchestrator persists onto the row, so the
|
|
1754
|
+
* executions list can show "failed" for a run whose workflow completed cleanly but whose
|
|
1755
|
+
* assertions caught regressions. Absent for non-test runs and legacy rows.
|
|
1741
1756
|
*/
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
getOutputItem<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, itemIndex: number, output?: OutputPortKey): Item<TJson> | undefined;
|
|
1748
|
-
}
|
|
1749
|
-
interface MutableRunData extends RunDataSnapshot {
|
|
1750
|
-
setOutputs(nodeId: NodeId, outputs: NodeOutputs): void;
|
|
1751
|
-
dump(): Record<NodeId, NodeOutputs>;
|
|
1752
|
-
}
|
|
1753
|
-
interface RunDataFactory {
|
|
1754
|
-
create(initial?: Record<NodeId, NodeOutputs>): MutableRunData;
|
|
1757
|
+
testCaseStatus?: TestCaseRunStatus;
|
|
1758
|
+
/** ISO timestamp when the run finished (derived from node snapshots or store `updatedAt`); omit while running/pending. */
|
|
1759
|
+
finishedAt?: string;
|
|
1760
|
+
parent?: ParentExecutionRef;
|
|
1761
|
+
executionOptions?: RunExecutionOptions;
|
|
1755
1762
|
}
|
|
1756
|
-
interface
|
|
1757
|
-
|
|
1763
|
+
interface PendingNodeExecution {
|
|
1764
|
+
runId: RunId;
|
|
1765
|
+
activationId: NodeActivationId;
|
|
1766
|
+
workflowId: WorkflowId;
|
|
1767
|
+
nodeId: NodeId;
|
|
1768
|
+
itemsIn: number;
|
|
1769
|
+
inputsByPort: NodeInputsByPort;
|
|
1770
|
+
receiptId: string;
|
|
1771
|
+
queue?: string;
|
|
1772
|
+
batchId?: string;
|
|
1773
|
+
enqueuedAt: string;
|
|
1758
1774
|
}
|
|
1759
|
-
interface
|
|
1760
|
-
|
|
1775
|
+
interface PersistedRunSchedulingState {
|
|
1776
|
+
pending?: PendingNodeExecution;
|
|
1777
|
+
queue: RunQueueEntry[];
|
|
1761
1778
|
}
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1779
|
+
interface PersistedRunState {
|
|
1780
|
+
runId: RunId;
|
|
1781
|
+
workflowId: WorkflowId;
|
|
1782
|
+
startedAt: string;
|
|
1783
|
+
/** Canonical terminal time for listings and retention when persisted on the run root. */
|
|
1784
|
+
finishedAt?: string;
|
|
1785
|
+
/** Optimistic concurrency / CAS on the run aggregate (repository may increment on save). */
|
|
1786
|
+
revision?: number;
|
|
1787
|
+
parent?: ParentExecutionRef;
|
|
1788
|
+
executionOptions?: RunExecutionOptions;
|
|
1789
|
+
control?: PersistedRunControlState;
|
|
1790
|
+
workflowSnapshot?: PersistedWorkflowSnapshot;
|
|
1791
|
+
mutableState?: PersistedMutableRunState;
|
|
1792
|
+
/** Frozen at createRun from workflow + runtime defaults for prune/storage decisions. */
|
|
1793
|
+
policySnapshot?: PersistedRunPolicySnapshot;
|
|
1794
|
+
/** Successful node completions so far (for activation budget). */
|
|
1795
|
+
engineCounters?: EngineRunCounters;
|
|
1796
|
+
status: RunStatus;
|
|
1797
|
+
pending?: PendingNodeExecution;
|
|
1798
|
+
queue: RunQueueEntry[];
|
|
1799
|
+
outputsByNode: Record<NodeId, NodeOutputs>;
|
|
1800
|
+
nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
|
|
1801
|
+
/** Append-only history of connection invocations (LLM/tool) nested under owning nodes. */
|
|
1802
|
+
connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
|
|
1768
1803
|
}
|
|
1769
|
-
interface
|
|
1770
|
-
|
|
1804
|
+
interface WorkflowExecutionRepository {
|
|
1805
|
+
createRun(args: {
|
|
1806
|
+
runId: RunId;
|
|
1771
1807
|
workflowId: WorkflowId;
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1808
|
+
startedAt: string;
|
|
1809
|
+
parent?: ParentExecutionRef;
|
|
1810
|
+
executionOptions?: RunExecutionOptions;
|
|
1811
|
+
control?: PersistedRunControlState;
|
|
1812
|
+
workflowSnapshot?: PersistedWorkflowSnapshot;
|
|
1813
|
+
mutableState?: PersistedMutableRunState;
|
|
1814
|
+
policySnapshot?: PersistedRunPolicySnapshot;
|
|
1815
|
+
engineCounters?: EngineRunCounters;
|
|
1816
|
+
}): Promise<void>;
|
|
1817
|
+
load(runId: RunId): Promise<PersistedRunState | undefined>;
|
|
1818
|
+
loadSchedulingState(runId: RunId): Promise<PersistedRunSchedulingState | undefined>;
|
|
1819
|
+
save(state: PersistedRunState): Promise<void>;
|
|
1820
|
+
deleteRun?(runId: RunId): Promise<void>;
|
|
1775
1821
|
}
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1822
|
+
interface WorkflowExecutionListingRepository {
|
|
1823
|
+
listRuns(args?: Readonly<{
|
|
1824
|
+
workflowId?: WorkflowId;
|
|
1825
|
+
limit?: number;
|
|
1826
|
+
}>): Promise<ReadonlyArray<RunSummary>>;
|
|
1781
1827
|
}
|
|
1782
|
-
|
|
1828
|
+
/** Runs eligible for retention-based pruning (completed or failed, older than cutoff). */
|
|
1829
|
+
interface RunPruneCandidate {
|
|
1783
1830
|
readonly runId: RunId;
|
|
1784
1831
|
readonly workflowId: WorkflowId;
|
|
1785
|
-
readonly workflow: WorkflowDefinition;
|
|
1786
|
-
readonly finalStatus: "completed" | "failed";
|
|
1787
1832
|
readonly startedAt: string;
|
|
1788
1833
|
readonly finishedAt: string;
|
|
1789
1834
|
}
|
|
1790
|
-
interface
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
}
|
|
1797
|
-
interface PersistedRunPolicySnapshot {
|
|
1798
|
-
readonly retentionSeconds?: number;
|
|
1799
|
-
readonly binaryRetentionSeconds?: number;
|
|
1800
|
-
readonly telemetrySpanRetentionSeconds?: number;
|
|
1801
|
-
readonly telemetryArtifactRetentionSeconds?: number;
|
|
1802
|
-
readonly telemetryMetricRetentionSeconds?: number;
|
|
1803
|
-
readonly storagePolicy: WorkflowStoragePolicyMode;
|
|
1804
|
-
}
|
|
1805
|
-
interface WorkflowErrorHandler {
|
|
1806
|
-
onError(ctx: WorkflowErrorContext): void | Promise<void>;
|
|
1807
|
-
}
|
|
1808
|
-
interface WorkflowErrorContext {
|
|
1809
|
-
readonly runId: RunId;
|
|
1810
|
-
readonly workflowId: WorkflowId;
|
|
1811
|
-
readonly workflow: WorkflowDefinition;
|
|
1812
|
-
readonly failedNodeId: NodeId;
|
|
1813
|
-
readonly error: Error;
|
|
1814
|
-
readonly startedAt: string;
|
|
1815
|
-
readonly finishedAt: string;
|
|
1835
|
+
interface WorkflowExecutionPruneRepository {
|
|
1836
|
+
listRunsOlderThan(args: Readonly<{
|
|
1837
|
+
nowIso: string;
|
|
1838
|
+
defaultRetentionSeconds: number;
|
|
1839
|
+
limit?: number;
|
|
1840
|
+
}>): Promise<ReadonlyArray<RunPruneCandidate>>;
|
|
1816
1841
|
}
|
|
1817
|
-
type
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1842
|
+
type RunResult = {
|
|
1843
|
+
runId: RunId;
|
|
1844
|
+
workflowId: WorkflowId;
|
|
1845
|
+
startedAt: string;
|
|
1846
|
+
status: "completed";
|
|
1847
|
+
outputs: Items;
|
|
1848
|
+
} | {
|
|
1849
|
+
runId: RunId;
|
|
1850
|
+
workflowId: WorkflowId;
|
|
1851
|
+
startedAt: string;
|
|
1852
|
+
status: "pending";
|
|
1853
|
+
pending: PendingNodeExecution;
|
|
1854
|
+
} | {
|
|
1855
|
+
runId: RunId;
|
|
1856
|
+
workflowId: WorkflowId;
|
|
1857
|
+
startedAt: string;
|
|
1858
|
+
status: "failed";
|
|
1859
|
+
error: {
|
|
1860
|
+
message: string;
|
|
1861
|
+
};
|
|
1862
|
+
};
|
|
1863
|
+
type WebhookRunResult = Readonly<{
|
|
1864
|
+
runId: RunId;
|
|
1865
|
+
workflowId: WorkflowId;
|
|
1866
|
+
startedAt: string;
|
|
1867
|
+
runStatus: "pending" | "completed";
|
|
1868
|
+
response: Items;
|
|
1869
|
+
}>;
|
|
1870
|
+
interface PersistedWorkflowTokenRegistryLike {
|
|
1871
|
+
register(type: TypeToken<unknown>, packageId: string, persistedNameOverride?: string): string;
|
|
1872
|
+
getTokenId(type: TypeToken<unknown>): string | undefined;
|
|
1873
|
+
resolve(tokenId: string): TypeToken<unknown> | undefined;
|
|
1874
|
+
registerFromWorkflows?(workflows: ReadonlyArray<WorkflowDefinition>): void;
|
|
1824
1875
|
}
|
|
1825
|
-
interface
|
|
1826
|
-
|
|
1876
|
+
interface RunCompletionNotifier {
|
|
1877
|
+
resolveRunCompletion(result: RunResult): void;
|
|
1878
|
+
resolveWebhookResponse(result: WebhookRunResult): void;
|
|
1827
1879
|
}
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
interface WorkflowPolicyRuntimeDefaults {
|
|
1831
|
-
readonly retentionSeconds?: number;
|
|
1832
|
-
readonly binaryRetentionSeconds?: number;
|
|
1833
|
-
readonly telemetrySpanRetentionSeconds?: number;
|
|
1834
|
-
readonly telemetryArtifactRetentionSeconds?: number;
|
|
1835
|
-
readonly telemetryMetricRetentionSeconds?: number;
|
|
1836
|
-
readonly storagePolicy?: WorkflowStoragePolicyMode;
|
|
1880
|
+
interface RunEventPublisherDeps {
|
|
1881
|
+
eventBus?: RunEventBus;
|
|
1837
1882
|
}
|
|
1838
1883
|
//#endregion
|
|
1839
|
-
//#region src/
|
|
1840
|
-
interface EngineTriggerRuntime {
|
|
1841
|
-
startTriggers(): Promise<void>;
|
|
1842
|
-
stop(): Promise<void>;
|
|
1843
|
-
syncWorkflowTriggersForActivation(workflowId: WorkflowId): Promise<void>;
|
|
1844
|
-
createTriggerTestItems(args: {
|
|
1845
|
-
workflow: WorkflowDefinition;
|
|
1846
|
-
nodeId: NodeId;
|
|
1847
|
-
}): Promise<Items | undefined>;
|
|
1848
|
-
}
|
|
1849
|
-
interface EngineRunStartService {
|
|
1850
|
-
runWorkflow(wf: WorkflowDefinition, startAt: NodeId, items: Items, parent?: ParentExecutionRef, executionOptions?: RunExecutionOptions, persistedStateOverrides?: Readonly<{
|
|
1851
|
-
workflowSnapshot?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["workflowSnapshot"];
|
|
1852
|
-
mutableState?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["mutableState"];
|
|
1853
|
-
}>): Promise<RunResult>;
|
|
1854
|
-
runWorkflowFromState(request: CurrentStateExecutionRequest): Promise<RunResult>;
|
|
1855
|
-
}
|
|
1856
|
-
interface EngineRunContinuationService {
|
|
1857
|
-
markNodeRunning(args: {
|
|
1858
|
-
runId: RunId;
|
|
1859
|
-
activationId: NodeActivationId;
|
|
1860
|
-
nodeId: NodeId;
|
|
1861
|
-
inputsByPort: NodeInputsByPort;
|
|
1862
|
-
}): Promise<void>;
|
|
1863
|
-
resumeFromNodeResult(args: {
|
|
1864
|
-
runId: RunId;
|
|
1865
|
-
activationId: NodeActivationId;
|
|
1866
|
-
nodeId: NodeId;
|
|
1867
|
-
outputs: NodeOutputs;
|
|
1868
|
-
}): Promise<RunResult>;
|
|
1869
|
-
resumeFromNodeError(args: {
|
|
1870
|
-
runId: RunId;
|
|
1871
|
-
activationId: NodeActivationId;
|
|
1872
|
-
nodeId: NodeId;
|
|
1873
|
-
error: Error;
|
|
1874
|
-
}): Promise<RunResult>;
|
|
1875
|
-
resumeFromStepResult(args: {
|
|
1876
|
-
runId: RunId;
|
|
1877
|
-
activationId: NodeActivationId;
|
|
1878
|
-
nodeId: NodeId;
|
|
1879
|
-
outputs: NodeOutputs;
|
|
1880
|
-
}): Promise<RunResult>;
|
|
1881
|
-
resumeFromStepError(args: {
|
|
1882
|
-
runId: RunId;
|
|
1883
|
-
activationId: NodeActivationId;
|
|
1884
|
-
nodeId: NodeId;
|
|
1885
|
-
error: Error;
|
|
1886
|
-
}): Promise<RunResult>;
|
|
1887
|
-
waitForCompletion(runId: RunId): Promise<Extract<RunResult, {
|
|
1888
|
-
status: "completed" | "failed";
|
|
1889
|
-
}>>;
|
|
1890
|
-
waitForWebhookResponse(runId: RunId): Promise<WebhookRunResult>;
|
|
1891
|
-
}
|
|
1892
|
-
interface EngineNodeExecutionRequestHandler {
|
|
1893
|
-
handleNodeExecutionRequest(request: NodeExecutionRequest): Promise<void>;
|
|
1894
|
-
}
|
|
1895
|
-
interface EngineFacadeDeps {
|
|
1896
|
-
liveWorkflowRepository: LiveWorkflowRepository;
|
|
1897
|
-
tokenRegistry: PersistedWorkflowTokenRegistryLike;
|
|
1898
|
-
webhookTriggerMatcher: WebhookTriggerMatcher;
|
|
1899
|
-
workflowSnapshotResolver: WorkflowSnapshotResolver;
|
|
1900
|
-
triggerRuntime: EngineTriggerRuntime;
|
|
1901
|
-
runStartService: EngineRunStartService;
|
|
1902
|
-
runContinuationService: EngineRunContinuationService;
|
|
1903
|
-
nodeExecutionRequestHandler: EngineNodeExecutionRequestHandler;
|
|
1904
|
-
}
|
|
1884
|
+
//#region src/contracts/agentMcpTypes.d.ts
|
|
1905
1885
|
/**
|
|
1906
|
-
*
|
|
1907
|
-
*
|
|
1908
|
-
* The
|
|
1886
|
+
* Emitted as a span event when a credential is missing required scopes
|
|
1887
|
+
* (bind-time) or when callTool returns a permission error (runtime).
|
|
1888
|
+
* The credential type id can be looked up from the credential instance when needed.
|
|
1909
1889
|
*/
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
getTokenRegistry(): EngineFacadeDeps["tokenRegistry"];
|
|
1915
|
-
resolveWorkflowSnapshot(args: {
|
|
1916
|
-
workflowId: WorkflowId;
|
|
1917
|
-
workflowSnapshot?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["workflowSnapshot"];
|
|
1918
|
-
}): WorkflowDefinition | undefined;
|
|
1919
|
-
startTriggers(): Promise<void>;
|
|
1920
|
-
syncWorkflowTriggersForActivation(workflowId: WorkflowId): Promise<void>;
|
|
1921
|
-
start(workflows: WorkflowDefinition[]): Promise<void>;
|
|
1922
|
-
stop(): Promise<void>;
|
|
1923
|
-
resolveWebhookTrigger(args: {
|
|
1924
|
-
endpointPath: string;
|
|
1925
|
-
method: HttpMethod;
|
|
1926
|
-
}): WebhookTriggerResolution;
|
|
1927
|
-
createTriggerTestItems(args: {
|
|
1928
|
-
workflow: WorkflowDefinition;
|
|
1929
|
-
nodeId: NodeId;
|
|
1930
|
-
}): Promise<Items | undefined>;
|
|
1931
|
-
runWorkflow(wf: WorkflowDefinition, startAt: NodeId, items: Items, parent?: ParentExecutionRef, executionOptions?: RunExecutionOptions, persistedStateOverrides?: Readonly<{
|
|
1932
|
-
workflowSnapshot?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["workflowSnapshot"];
|
|
1933
|
-
mutableState?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["mutableState"];
|
|
1934
|
-
}>): Promise<RunResult>;
|
|
1935
|
-
runWorkflowFromState(request: CurrentStateExecutionRequest): Promise<RunResult>;
|
|
1936
|
-
markNodeRunning(args: {
|
|
1937
|
-
runId: RunId;
|
|
1938
|
-
activationId: NodeActivationId;
|
|
1939
|
-
nodeId: NodeId;
|
|
1940
|
-
inputsByPort: NodeInputsByPort;
|
|
1941
|
-
}): Promise<void>;
|
|
1942
|
-
resumeFromNodeResult(args: {
|
|
1943
|
-
runId: RunId;
|
|
1944
|
-
activationId: NodeActivationId;
|
|
1945
|
-
nodeId: NodeId;
|
|
1946
|
-
outputs: NodeOutputs;
|
|
1947
|
-
}): Promise<RunResult>;
|
|
1948
|
-
resumeFromNodeError(args: {
|
|
1949
|
-
runId: RunId;
|
|
1950
|
-
activationId: NodeActivationId;
|
|
1951
|
-
nodeId: NodeId;
|
|
1952
|
-
error: Error;
|
|
1953
|
-
}): Promise<RunResult>;
|
|
1954
|
-
resumeFromStepResult(args: {
|
|
1955
|
-
runId: RunId;
|
|
1956
|
-
activationId: NodeActivationId;
|
|
1957
|
-
nodeId: NodeId;
|
|
1958
|
-
outputs: NodeOutputs;
|
|
1959
|
-
}): Promise<RunResult>;
|
|
1960
|
-
resumeFromStepError(args: {
|
|
1961
|
-
runId: RunId;
|
|
1962
|
-
activationId: NodeActivationId;
|
|
1963
|
-
nodeId: NodeId;
|
|
1964
|
-
error: Error;
|
|
1965
|
-
}): Promise<RunResult>;
|
|
1966
|
-
waitForCompletion(runId: RunId): Promise<Extract<RunResult, {
|
|
1967
|
-
status: "completed" | "failed";
|
|
1968
|
-
}>>;
|
|
1969
|
-
waitForWebhookResponse(runId: RunId): Promise<WebhookRunResult>;
|
|
1970
|
-
handleNodeExecutionRequest(request: NodeExecutionRequest): Promise<void>;
|
|
1971
|
-
}
|
|
1972
|
-
//#endregion
|
|
1973
|
-
//#region src/runtime/InMemoryLiveWorkflowRepository.d.ts
|
|
1974
|
-
declare class InMemoryLiveWorkflowRepository implements LiveWorkflowRepository {
|
|
1975
|
-
private readonly workflowsById;
|
|
1976
|
-
setWorkflows(workflows: ReadonlyArray<WorkflowDefinition>): void;
|
|
1977
|
-
list(): ReadonlyArray<WorkflowDefinition>;
|
|
1978
|
-
get(workflowId: WorkflowId): WorkflowDefinition | undefined;
|
|
1890
|
+
interface NeedsReconsentEvent {
|
|
1891
|
+
readonly serverId: string;
|
|
1892
|
+
readonly credentialInstanceId: string;
|
|
1893
|
+
readonly missingScopesHint?: readonly string[];
|
|
1979
1894
|
}
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
workflow: WorkflowDefinition;
|
|
1997
|
-
nodeId: NodeId;
|
|
1998
|
-
currentState: RunCurrentState;
|
|
1999
|
-
items?: Items;
|
|
2000
|
-
synthesizeTriggerItems?: boolean;
|
|
2001
|
-
parent?: CurrentStateExecutionRequest["parent"];
|
|
2002
|
-
executionOptions?: RunExecutionOptions;
|
|
2003
|
-
workflowSnapshot?: CurrentStateExecutionRequest["workflowSnapshot"];
|
|
2004
|
-
mutableState?: CurrentStateExecutionRequest["mutableState"];
|
|
2005
|
-
};
|
|
2006
|
-
type MatchedWebhookRunIntent = {
|
|
2007
|
-
endpointPath: string;
|
|
2008
|
-
method: HttpMethod;
|
|
2009
|
-
requestItem: Items[number];
|
|
2010
|
-
};
|
|
2011
|
-
type WebhookMatchRunIntent = {
|
|
2012
|
-
match: WebhookInvocationMatch;
|
|
2013
|
-
requestItem: Items[number];
|
|
2014
|
-
};
|
|
2015
|
-
declare class RunIntentService {
|
|
2016
|
-
private readonly engine;
|
|
2017
|
-
private readonly workflowRepository;
|
|
2018
|
-
constructor(engine: Engine, workflowRepository: WorkflowRepository);
|
|
2019
|
-
startWorkflow(args: StartWorkflowIntent): Promise<RunResult>;
|
|
2020
|
-
rerunFromNode(args: RerunFromNodeIntent): Promise<RunResult>;
|
|
2021
|
-
private resolveStartWorkflowItems;
|
|
2022
|
-
private resolveRerunItems;
|
|
2023
|
-
private resolveStartWorkflowTriggerNodeId;
|
|
2024
|
-
private resolveRerunTriggerNodeId;
|
|
2025
|
-
private firstTriggerNodeId;
|
|
2026
|
-
private isTriggerNode;
|
|
2027
|
-
private hasNonEmptyItems;
|
|
2028
|
-
resolveWebhookTrigger(args: {
|
|
2029
|
-
endpointPath: string;
|
|
2030
|
-
method: HttpMethod;
|
|
2031
|
-
}): WebhookTriggerResolution;
|
|
2032
|
-
runMatchedWebhook(args: MatchedWebhookRunIntent): Promise<WebhookRunResult>;
|
|
2033
|
-
runWebhookMatch(args: WebhookMatchRunIntent): Promise<WebhookRunResult>;
|
|
1895
|
+
/**
|
|
1896
|
+
* An opaque MCP tool map: keyed by serverId → (toolName → tool definition).
|
|
1897
|
+
* Typed as unknown so core does not depend on the AI SDK's ToolSet type.
|
|
1898
|
+
* AIAgentNode (in core-nodes, which does depend on ai) casts this to
|
|
1899
|
+
* ReadonlyMap<string, ToolSet> before passing to DeferredMetaToolStrategyFactory.
|
|
1900
|
+
*/
|
|
1901
|
+
type AgentMcpToolMap = ReadonlyMap<string, Readonly<Record<string, unknown>>>;
|
|
1902
|
+
/**
|
|
1903
|
+
* Contract implemented by the host. Resolves MCP server bindings for an agent run
|
|
1904
|
+
* via the standard credential-binding table (one slot per declared server, keyed
|
|
1905
|
+
* by `(workflowId, mcpConnectionNodeId, "credential")`), and returns a ready-to-use
|
|
1906
|
+
* tool map with wrapped execute callbacks for telemetry and 403 detection.
|
|
1907
|
+
* Core-nodes imports this interface so AIAgentNode can inject it without
|
|
1908
|
+
* depending on the host.
|
|
1909
|
+
*/
|
|
1910
|
+
interface AgentMcpIntegration {
|
|
2034
1911
|
/**
|
|
2035
|
-
*
|
|
2036
|
-
*
|
|
1912
|
+
* Look up the credential binding per server, validate scopes, open pool
|
|
1913
|
+
* connections, and return a tool map keyed by serverId. Each tool's
|
|
1914
|
+
* execute callback includes:
|
|
1915
|
+
* - Telemetry child span (mcp.server_id, mcp.tool_name attributes)
|
|
1916
|
+
* - 403/permission error detection → emits a NeedsReconsentEvent span event
|
|
1917
|
+
*
|
|
1918
|
+
* Throws `AgentBindError` on validation failures (missing server, unbound
|
|
1919
|
+
* credential slot, missing credential instance, insufficient scopes).
|
|
2037
1920
|
*/
|
|
2038
|
-
|
|
1921
|
+
prepareMcpTools(args: {
|
|
1922
|
+
readonly workflowId: WorkflowId;
|
|
1923
|
+
readonly agentNodeId: NodeId;
|
|
1924
|
+
readonly serverIds: ReadonlyArray<string>;
|
|
1925
|
+
readonly pinnedMcpTools: readonly string[];
|
|
1926
|
+
readonly emitSpanEvent: (event: TelemetrySpanEventRecord) => void;
|
|
1927
|
+
readonly startChildSpan: (args: {
|
|
1928
|
+
readonly name: string;
|
|
1929
|
+
readonly attributes?: Record<string, string>;
|
|
1930
|
+
}) => {
|
|
1931
|
+
readonly end: (args?: {
|
|
1932
|
+
status?: "ok" | "error";
|
|
1933
|
+
statusMessage?: string;
|
|
1934
|
+
}) => void;
|
|
1935
|
+
};
|
|
1936
|
+
/** Per-MCP-tool-call invocation appender. Optional; when omitted the wrapper emits only telemetry spans. */
|
|
1937
|
+
readonly appendMcpInvocation?: (args: ConnectionInvocationAppendArgs) => Promise<void>;
|
|
1938
|
+
/** Agent activation id to attach to each invocation record (used by canvas + inspector grouping). */
|
|
1939
|
+
readonly parentAgentActivationId?: NodeActivationId;
|
|
1940
|
+
/** Per-item iteration id when the agent runs inside a per-item loop. */
|
|
1941
|
+
readonly iterationId?: NodeIterationId;
|
|
1942
|
+
/** Item index (0-based) of the iteration that owns these tool calls. */
|
|
1943
|
+
readonly itemIndex?: number;
|
|
1944
|
+
/** Parent invocation id when this agent is itself executing as a sub-agent. */
|
|
1945
|
+
readonly parentInvocationId?: ConnectionInvocationId;
|
|
1946
|
+
}): Promise<AgentMcpToolMap>;
|
|
2039
1947
|
}
|
|
2040
1948
|
//#endregion
|
|
2041
|
-
export {
|
|
2042
|
-
//# sourceMappingURL=
|
|
1949
|
+
export { instancePerContainerCachingFactory as $, NodeExecutor as $n, CostTrackingTelemetryAttributeNames as $r, TriggerNodeConfig as $t, RunResult as A, OAuth2ProviderFromPublicConfig as Ai, BinaryStorageStatResult as An, ExecutionTelemetryFactory as Ar, NodeConfigBase as At, Container as B, LiveWorkflowRepository as Bn, TelemetrySpanEventRecord as Br, NodeOutputs as Bt, PinnedNodeOutputsByPort as C, CredentialSessionService as Ci, FixedRetryPolicySpec as Cn, WebhookInvocationMatch as Cr, JsonArray as Ct, RunExecutionOptions as D, CredentialTypeId as Di, BinaryBody as Dn, AllWorkflowsActiveWorkflowActivationPolicy as Dr, JsonValue as Dt, RunEventPublisherDeps as E, CredentialTypeDefinition as Ei, BinaryAttachmentCreateRequest as En, WebhookTriggerRoutingDiagnostics as Er, JsonPrimitive as Et, RunTestContext as F, NodeConnectionName as Fi, ExecutableTriggerNode as Fn, TelemetryAttributes as Fr, NodeIdRef as Ft, RegistrationOptions as G, NodeActivationRequestBase as Gn, NoOpExecutionTelemetryFactory as Gr, PersistedRunPolicySnapshot as Gt, Disposable as H, NodeActivationContinuation as Hn, CodemationTelemetryMetricNames as Hr, NodeSchedulerDecision as Ht, WebhookRunResult as I, NodeId as Ii, ExecutionBinaryService as In, TelemetryChildSpanStart as Ir, NodeInspectorSummaryRow as It, delay as J, NodeExecutionContext as Jn, NoOpTelemetrySpanScope as Jr, RunId as Jt, TypeToken as K, NodeActivationScheduler as Kn, NoOpExecutionTelemetry as Kr, RunDataFactory as Kt, WorkflowExecutionListingRepository as L, OutputPortKey as Li, ExecutionContext as Ln, TelemetryMetricRecord as Lr, NodeIterationId as Lt, RunStatus as M, PollingTriggerLogger as Mi, BinaryStorageWriteResult as Mn, TelemetryArtifactAttachment as Mr, NodeErrorHandler as Mt, RunStopCondition as N, PollingTriggerDedupWindow as Ni, EngineDeps as Nn, TelemetryArtifactReference as Nr, NodeErrorHandlerArgs as Nt, RunPruneCandidate as O, CredentialTypeRegistry as Oi, BinaryStorage as On, WorkflowActivationPolicy as Or, MutableRunData as Ot, RunSummary as P, InputPortKey as Pi, EngineHost as Pn, TelemetryAttributePrimitive as Pr, NodeErrorHandlerSpec as Pt, instanceCachingFactory as Q, NodeExecutionStatePublisher as Qn, CostTrackingTelemetry as Qr, RunnableNodeOutputJson as Qt, WorkflowExecutionPruneRepository as R, PersistedTokenId as Ri, ExecutionContextFactory as Rn, TelemetryScope as Rr, NodeKind as Rt, PersistedWorkflowTokenRegistryLike as S, CredentialSessionFactoryArgs as Si, ExponentialRetryPolicySpec as Sn, WebhookControlSignal as Sr, Items as St, RunCurrentState as T, CredentialType as Ti, RetryPolicySpec as Tn, WebhookTriggerResolution as Tr, JsonObject as Tt, InjectionToken$1 as U, NodeActivationReceipt as Un, GenAiTelemetryAttributeNames as Ur, PairedItemRef as Ut, DependencyContainer$1 as V, MultiInputNode as Vn, TelemetrySpanScope as Vr, NodeRef as Vt, Lifecycle as W, NodeActivationRequest as Wn, CodemationTelemetryAttributeNames as Wr, ParentExecutionRef as Wt, injectAll as X, NodeExecutionRequestHandler as Xn, CostTrackingComponent as Xr, RunnableNodeConfig as Xt, inject as Y, NodeExecutionRequest as Yn, NoOpTelemetryArtifactReference as Yr, RunIdFactory as Yt, injectable as Z, NodeExecutionScheduler as Zn, CostTrackingPriceQuote as Zr, RunnableNodeInputJson as Zt, PersistedRunControlState as _, CredentialMaterialSourceKind as _i, nodeRef as _n, WorkflowRunnerService as _r, BinaryPreviewKind as _t, ConnectionInvocationId as a, AnyCredentialType as ai, WorkflowErrorHandler as an, RunnableNodeExecuteArgs as ar, EngineExecutionLimitsPolicy as at, PersistedWorkflowSnapshot as b, CredentialRequirement as bi, triggerNodeOutputType as bn, HttpMethod as br, Item as bt, EngineRunCounters as c, CredentialBinding as ci, WorkflowGraphFactory as cn, TriggerNode as cr, RunEventBus as ct, NodeExecutionSnapshot as d, CredentialHealth as di, WorkflowPrunePolicySpec as dn, TriggerSetupStateFor as dr, TestSuiteRunStatus as dt, CostTrackingTelemetryFactory as ei, TriggerNodeOutputJson as en, NodeResolver as er, predicateAwareClassFactory as et, NodeExecutionStatus as f, CredentialHealthStatus as fi, WorkflowStoragePolicyDecisionArgs as fn, TriggerSetupStateRepository as fr, TestSuiteRunId as ft, PersistedMutableRunState as g, CredentialJsonRecord as gi, branchRef as gn, WorkflowRunnerResolver as gr, BinaryAttachment as gt, PersistedMutableNodeState as h, CredentialInstanceRecord as hi, WorkflowStoragePolicySpec as hn, WorkflowRepository as hr, ActivationIdFactory as ht, ConnectionInvocationAppendArgs as i, CollectionsContext as ii, WorkflowErrorContext as in, RunnableNode as ir, ENGINE_EXECUTION_LIMITS_DEFAULTS as it, RunStateResetRequest as j, NoOpPollingTriggerLogger as ji, BinaryStorageWriteRequest as jn, NodeExecutionTelemetry as jr, NodeDefinition as jt, RunQueueEntry as k, CredentialUnboundError as ki, BinaryStorageReadResult as kn, ExecutionTelemetry as kr, NodeActivationId as kt, ExecutionFrontierPlan as l, CredentialBindingKey as li, WorkflowNodeConnection as ln, TriggerRuntimeDiagnostics as lr, RunEventSubscription as lt, PendingNodeExecution as m, CredentialInstanceId as mi, WorkflowStoragePolicyResolver as mn, WorkflowNodeInstanceFactory as mr, TestTriggerSetupContext as mt, AgentMcpToolMap as n, CostTrackingUsageRecord as ni, UpstreamRefPlaceholder as nn, PollingTriggerHandle as nr, singleton as nt, ConnectionInvocationRecord as o, CredentialAdvancedSectionPresentation as oi, WorkflowErrorHandlerSpec as on, TestableTriggerNode as or, EngineExecutionLimitsPolicyConfig as ot, NodeInputsByPort as p, CredentialHealthTester as pi, WorkflowStoragePolicyMode as pn, TriggerTestItemsContext as pr, TestTriggerNodeConfig as pt, container as q, NodeBinaryAttachmentService as qn, NoOpNodeExecutionTelemetry as qr, RunDataSnapshot as qt, NeedsReconsentEvent as r, CollectionStore as ri, WorkflowDefinition as rn, PreparedNodeActivationDispatch as rr, CoreTokens as rt, CurrentStateExecutionRequest as s, CredentialAuthDefinition as si, WorkflowGraph as sn, TriggerCleanupHandle as sr, RunEvent as st, AgentMcpIntegration as t, CostTrackingTelemetryMetricNames as ti, TriggerNodeSetupState as tn, PersistedTriggerSetupState as tr, registry as tt, NodeExecutionError as u, CredentialFieldSchema as ui, WorkflowPolicyRuntimeDefaults as un, TriggerSetupContext as ur, TestCaseRunStatus as ut, PersistedRunSchedulingState as v, CredentialOAuth2AuthDefinition as vi, runnableNodeInputType as vn, WorkflowSnapshotFactory as vr, Edge as vt, RunCompletionNotifier as w, CredentialSetupStatus as wi, NoneRetryPolicySpec as wn, WebhookTriggerMatcher as wr, JsonNonArray as wt, PersistedWorkflowSnapshotNode as x, CredentialSessionFactory as xi, triggerNodeSetupStateType as xn, TriggerInstanceId as xr, ItemBinary as xt, PersistedRunState as y, CredentialOAuth2ScopesFromPublicConfig as yi, runnableNodeOutputType as yn, WorkflowSnapshotResolver as yr, ExecutionMode as yt, WorkflowExecutionRepository as z, WorkflowId as zi, ItemNode as zn, TelemetrySpanEnd as zr, NodeOffloadPolicy as zt };
|
|
1950
|
+
//# sourceMappingURL=agentMcpTypes-ZiNbNsEi.d.cts.map
|