@codemation/core 0.13.2 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +167 -0
- package/dist/{CostCatalogContract-Dxq1BTyi.d.cts → CostCatalogContract-Dwo-ZamG.d.cts} +2 -2
- package/dist/EngineRuntimeRegistration.types-BiNasx3G.d.cts +54 -0
- package/dist/EngineRuntimeRegistration.types-Dq4ucrdo.d.ts +21 -0
- package/dist/{InMemoryRunDataFactory-Csy2evr_.d.cts → InMemoryRunDataFactory-D2U9azmZ.d.cts} +4 -20
- package/dist/{InMemoryRunEventBusRegistry-Sa86VxuV.cjs → InMemoryRunEventBusRegistry-DO0WM9Lw.cjs} +1 -1
- package/dist/{InMemoryRunEventBusRegistry-Sa86VxuV.cjs.map → InMemoryRunEventBusRegistry-DO0WM9Lw.cjs.map} +1 -1
- package/dist/{InMemoryRunEventBusRegistry-Bwunvt1T.js → InMemoryRunEventBusRegistry-Layt2xgm.js} +1 -1
- package/dist/{InMemoryRunEventBusRegistry-Bwunvt1T.js.map → InMemoryRunEventBusRegistry-Layt2xgm.js.map} +1 -1
- package/dist/{ItemsInputNormalizer-Bi8m-Ijs.d.cts → ItemsInputNormalizer-A5txcOWX.d.cts} +3 -98
- package/dist/{ItemsInputNormalizer-BbQTSEkZ.cjs → ItemsInputNormalizer-C1fv3sMW.cjs} +2 -2
- package/dist/ItemsInputNormalizer-C1fv3sMW.cjs.map +1 -0
- package/dist/{ItemsInputNormalizer-BYljnXU0.d.ts → ItemsInputNormalizer-D2vrMrX1.d.ts} +2 -62
- package/dist/{ItemsInputNormalizer-CSZGMgl3.js → ItemsInputNormalizer-fUYo4GLV.js} +2 -2
- package/dist/ItemsInputNormalizer-fUYo4GLV.js.map +1 -0
- package/dist/{RunIntentService-BitgkKaT.d.cts → RunIntentService-DKxuHTUz.d.cts} +2 -15
- package/dist/{RunIntentService-DYpqfu6D.d.ts → RunIntentService-DrpKli2k.d.ts} +2 -22
- package/dist/{agentMcpTypes-DGIwk6Ue.d.cts → agentMcpTypes-BHX4RQCC.d.cts} +25 -518
- package/dist/bootstrap/index.cjs +9 -5
- package/dist/bootstrap/index.d.cts +32 -106
- package/dist/bootstrap/index.d.ts +18 -17
- package/dist/bootstrap/index.js +6 -5
- package/dist/{bootstrap-DIv-vloi.cjs → bootstrap-CTB53rEF.cjs} +9 -60
- package/dist/bootstrap-CTB53rEF.cjs.map +1 -0
- package/dist/{bootstrap-Bkd-Nfbn.js → bootstrap-DmqKheCI.js} +6 -57
- package/dist/bootstrap-DmqKheCI.js.map +1 -0
- package/dist/browser.cjs +12 -11
- package/dist/browser.d.cts +4 -4
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +3 -2
- package/dist/contracts-7L1wJHdk.cjs +569 -0
- package/dist/contracts-7L1wJHdk.cjs.map +1 -0
- package/dist/contracts-CjJ5CZ7N.js +447 -0
- package/dist/contracts-CjJ5CZ7N.js.map +1 -0
- package/dist/contracts.cjs +9 -2
- package/dist/contracts.d.cts +5 -5
- package/dist/contracts.d.ts +2 -2
- package/dist/contracts.js +3 -2
- package/dist/{executionPersistenceContracts-CN9d7AnL.d.cts → deploymentManifestTypes-B8CDmZZK.d.cts} +65 -81
- package/dist/di-C6Ubf9o5.cjs +179 -0
- package/dist/di-C6Ubf9o5.cjs.map +1 -0
- package/dist/di-Cjiil7U-.js +114 -0
- package/dist/di-Cjiil7U-.js.map +1 -0
- package/dist/{index-rllWL4r-.d.ts → index-CRv3_pY3.d.ts} +112 -808
- package/dist/{index-BSQ2LoIh.d.ts → index-mnLS0iQl.d.ts} +39 -372
- package/dist/index.cjs +53 -111
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -438
- package/dist/index.d.ts +5 -5
- package/dist/index.js +28 -94
- package/dist/index.js.map +1 -1
- package/dist/{params-DRUr0F5v.d.cts → params-CrK4iuG1.d.cts} +3 -13
- package/dist/{runtime-CWPdvJpC.js → runtime-CBFDpmiz.js} +112 -648
- package/dist/runtime-CBFDpmiz.js.map +1 -0
- package/dist/{runtime-_VdHwGkJ.cjs → runtime-Due-FOZ2.cjs} +137 -717
- package/dist/runtime-Due-FOZ2.cjs.map +1 -0
- package/dist/testing.cjs +8 -40
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +3 -32
- package/dist/testing.d.ts +3 -32
- package/dist/testing.js +6 -38
- package/dist/testing.js.map +1 -1
- package/dist/{di-LP2qSHkY.cjs → workflowTypes-BW6Hhee7.cjs} +4 -230
- package/dist/workflowTypes-BW6Hhee7.cjs.map +1 -0
- package/dist/{di-tom0pM2h.js → workflowTypes-DZtBTmKf.js} +3 -163
- package/dist/workflowTypes-DZtBTmKf.js.map +1 -0
- package/package.json +1 -1
- package/src/ai/AgentConnectionNodeCollector.ts +0 -4
- package/src/ai/AgentMessageConfigNormalizerFactory.ts +0 -4
- package/src/ai/AiHost.ts +0 -38
- package/src/ai/CallableToolConfig.ts +0 -9
- package/src/ai/CallableToolKindToken.ts +0 -4
- package/src/authoring/callableTool.types.ts +0 -3
- package/src/authoring/defineCollection.types.ts +0 -11
- package/src/authoring/defineHumanApprovalNode.types.ts +0 -116
- package/src/authoring/defineNode.types.ts +18 -32
- package/src/authoring/definePollingTrigger.types.ts +36 -155
- package/src/authoring/definePollingTriggerInternals.ts +0 -4
- package/src/authoring/index.ts +1 -0
- package/src/authoring/nodeBaseOptions.types.ts +4 -0
- package/src/binaries/boundedReadBinary.types.ts +0 -16
- package/src/bootstrap/index.ts +8 -2
- package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +0 -5
- package/src/bootstrap/runtime/EngineRuntimeRegistration.types.ts +0 -23
- package/src/browser.ts +0 -3
- package/src/contracts/AgentBindError.ts +0 -5
- package/src/contracts/Clock.ts +0 -1
- package/src/contracts/CodemationTelemetryAttributeNames.ts +0 -10
- package/src/contracts/NoOpAgentMcpIntegration.ts +0 -6
- package/src/contracts/NoOpTelemetrySpanScope.ts +0 -7
- package/src/contracts/RetryPolicy.ts +0 -2
- package/src/contracts/agentMcpTypes.ts +0 -34
- package/src/contracts/assertionTypes.ts +0 -33
- package/src/contracts/baseTypes.ts +0 -6
- package/src/contracts/collectionTypes.ts +0 -25
- package/src/contracts/credentialTypes.ts +13 -60
- package/src/contracts/deploymentManifestTypes.ts +158 -0
- package/src/contracts/dispatchTypes.ts +29 -0
- package/src/contracts/executionPersistenceContracts.ts +0 -33
- package/src/contracts/hitlSeamTypes.ts +0 -14
- package/src/contracts/humanTaskStoreTypes.ts +0 -2
- package/src/contracts/inboxChannelTypes.ts +0 -9
- package/src/contracts/index.ts +3 -0
- package/src/contracts/itemExpr.ts +7 -21
- package/src/contracts/itemMeta.ts +0 -3
- package/src/contracts/mcpTypes.ts +0 -16
- package/src/contracts/retryPolicySpec.types.ts +0 -10
- package/src/contracts/runFinishedAtFactory.ts +0 -1
- package/src/contracts/runTypes.ts +0 -74
- package/src/contracts/runtimeTypes.ts +4 -131
- package/src/contracts/telemetryTypes.ts +0 -7
- package/src/contracts/testTriggerTypes.ts +0 -43
- package/src/contracts/triggerInvokerTypes.ts +6 -0
- package/src/contracts/webhookTypes.ts +0 -8
- package/src/contracts/workflowActivationPolicy.ts +0 -5
- package/src/contracts/workflowTypes.ts +5 -80
- package/src/contracts/workspaceFileTypes.ts +10 -42
- package/src/contracts.ts +18 -10
- package/src/credentials/CredentialMaterialProvider.types.ts +0 -28
- package/src/credentials/ManagedCredentialMaterialWriteError.ts +0 -6
- package/src/credentials/ManagedMaterialFetchError.ts +0 -6
- package/src/credentials/OAuthFlowExecutor.types.ts +0 -15
- package/src/di/CoreTokens.ts +2 -6
- package/src/events/ConnectionInvocationEventPublisher.ts +0 -7
- package/src/events/NodeEventPublisher.ts +0 -1
- package/src/events/runEvents.ts +0 -8
- package/src/execution/ActivationEnqueueService.ts +0 -10
- package/src/execution/ChildExecutionScopeFactory.ts +0 -13
- package/src/execution/FanInMergeByOriginMerger.ts +0 -11
- package/src/execution/InProcessRetryRunner.ts +0 -1
- package/src/execution/ItemExprResolver.ts +0 -3
- package/src/execution/NodeActivationRequestComposer.ts +0 -3
- package/src/execution/NodeActivationRequestInputPreparer.ts +0 -5
- package/src/execution/NodeExecutionSnapshotFactory.ts +0 -1
- package/src/execution/NodeExecutor.ts +1 -17
- package/src/execution/NodeOutputNormalizer.ts +8 -1
- package/src/execution/NodeSuspensionHandler.ts +1 -39
- package/src/execution/PersistedRunStateTerminalBuilder.ts +0 -5
- package/src/execution/RunSuspendedError.ts +0 -10
- package/src/execution/RunnableOutputBehaviorResolver.ts +12 -0
- package/src/execution/WorkflowRunExecutionContextFactory.ts +0 -3
- package/src/index.ts +10 -2
- package/src/orchestration/AbortControllerFactory.ts +0 -4
- package/src/orchestration/Engine.ts +0 -9
- package/src/orchestration/NodeExecutionRequestHandlerService.ts +3 -4
- package/src/orchestration/RunContinuationService.ts +7 -39
- package/src/orchestration/RunStartService.ts +0 -7
- package/src/orchestration/TestSuiteOrchestrator.ts +0 -18
- package/src/orchestration/TestSuiteRunIdFactory.ts +0 -4
- package/src/orchestration/TriggerRuntimeService.ts +3 -2
- package/src/planning/CurrentStateFrontierPlanner.ts +0 -1
- package/src/planning/RunQueuePlanner.ts +0 -6
- package/src/policies/executionLimits/EngineExecutionLimitsPolicy.ts +0 -8
- package/src/policies/executionLimits/EngineExecutionLimitsPolicyFactory.ts +0 -3
- package/src/runStorage/RunSummaryMapper.ts +0 -1
- package/src/runtime/EngineFactory.ts +6 -11
- package/src/runtime/RunIntentService.ts +0 -4
- package/src/runtime/WorkflowRepositoryWebhookTriggerMatcher.ts +0 -4
- package/src/runtime-types/InjectableRuntimeDecoratorComposerRegistry.ts +0 -4
- package/src/runtime-types/PersistedRuntimeTypeMetadataStoreRegistry.ts +0 -4
- package/src/runtime-types/PersistedRuntimeTypeNameResolver.ts +0 -1
- package/src/runtime-types/persistedRuntimeTypeModelRegistry.ts +0 -4
- package/src/runtime-types/runtimeTypeDecorators.types.ts +0 -12
- package/src/scheduler/ConfigDrivenOffloadPolicy.ts +0 -1
- package/src/scheduler/DefaultDrivingScheduler.ts +0 -6
- package/src/scheduler/InlineDrivingScheduler.ts +0 -13
- package/src/serialization/ItemsInputNormalizer.ts +0 -5
- package/src/testing/CapturingScheduler.ts +0 -3
- package/src/testing/EngineTestKitRunIdFactory.ts +0 -3
- package/src/testing/ItemHarnessNode.ts +0 -3
- package/src/testing/ItemHarnessNodeConfig.ts +0 -4
- package/src/testing/PrefixedSequentialIdGenerator.ts +0 -3
- package/src/testing/RegistrarEngineTestKit.types.ts +0 -2
- package/src/testing/RejectingCredentialSessionService.ts +0 -4
- package/src/testing/SubWorkflowRunnerTestNode.ts +0 -3
- package/src/testing/WorkflowTestHarnessManualTrigger.ts +0 -3
- package/src/testing/WorkflowTestKitBuilder.ts +0 -4
- package/src/testing/WorkflowTestKitRunNodeWorkflowFactory.ts +0 -3
- package/src/testing.ts +0 -3
- package/src/triggers/polling/PollingTriggerDedupWindow.ts +0 -4
- package/src/triggers/polling/PollingTriggerLogger.ts +0 -5
- package/src/triggers/polling/PollingTriggerRuntime.ts +0 -5
- package/src/types/index.ts +0 -6
- package/src/validation/WorkflowEdgePortValidator.ts +0 -5
- package/src/workflow/definition/ConnectionInvocationIdFactory.ts +0 -7
- package/src/workflow/definition/ConnectionNodeIdFactory.ts +0 -6
- package/src/workflow/definition/NodeIterationIdFactory.ts +0 -13
- package/src/workflow/definition/WorkflowExecutableNodeClassifier.ts +0 -6
- package/src/workflow/dsl/ChainCursorResolver.ts +8 -15
- package/src/workflow/dsl/NodeIdSlugifier.ts +0 -9
- package/src/workflow/dsl/WhenBuilder.ts +49 -2
- package/src/workflow/dsl/WorkflowDefinitionError.ts +0 -9
- package/src/workflow/dsl/workflowBuilderTypes.ts +5 -0
- package/src/workflowSnapshots/MissingRuntimeParityGuard.ts +24 -0
- package/src/workflowSnapshots/PersistedWorkflowTokenRegistry.ts +0 -6
- package/src/workflowSnapshots/WorkflowParityMismatchError.ts +18 -0
- package/src/workflowSnapshots/WorkflowSnapshotCodec.ts +1 -5
- package/src/workflowSnapshots/index.ts +3 -0
- package/dist/EngineRuntimeRegistration.types-CqcTWexS.d.cts +0 -81
- package/dist/EngineRuntimeRegistration.types-Cr75cSfL.d.ts +0 -44
- package/dist/ItemsInputNormalizer-BbQTSEkZ.cjs.map +0 -1
- package/dist/ItemsInputNormalizer-CSZGMgl3.js.map +0 -1
- package/dist/bootstrap-Bkd-Nfbn.js.map +0 -1
- package/dist/bootstrap-DIv-vloi.cjs.map +0 -1
- package/dist/contracts-CK0x6w_G.cjs +0 -74
- package/dist/contracts-CK0x6w_G.cjs.map +0 -1
- package/dist/contracts-DXdfTdpW.js +0 -50
- package/dist/contracts-DXdfTdpW.js.map +0 -1
- package/dist/di-LP2qSHkY.cjs.map +0 -1
- package/dist/di-tom0pM2h.js.map +0 -1
- package/dist/runtime-CWPdvJpC.js.map +0 -1
- package/dist/runtime-_VdHwGkJ.cjs.map +0 -1
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { NodeExecutionContext } from "./runtimeTypes";
|
|
2
2
|
import type { Item, Items, NodeActivationId, NodeId, RunDataSnapshot, RunId, WorkflowId } from "./workflowTypes";
|
|
3
3
|
|
|
4
|
-
const ITEM_EXPR_BRAND = Symbol.for("codemation.itemExpr");
|
|
5
|
-
|
|
6
4
|
export type ItemExprResolvedContext = Readonly<{
|
|
7
5
|
runId: RunId;
|
|
8
6
|
workflowId: WorkflowId;
|
|
@@ -11,9 +9,6 @@ export type ItemExprResolvedContext = Readonly<{
|
|
|
11
9
|
data: RunDataSnapshot;
|
|
12
10
|
}>;
|
|
13
11
|
|
|
14
|
-
/**
|
|
15
|
-
* Context aligned with former {@link ItemInputMapperContext} — use **`data`** to read any completed upstream node.
|
|
16
|
-
*/
|
|
17
12
|
export type ItemExprContext = ItemExprResolvedContext;
|
|
18
13
|
|
|
19
14
|
export type ItemExprArgs<TItemJson = unknown> = Readonly<{
|
|
@@ -26,12 +21,12 @@ export type ItemExprArgs<TItemJson = unknown> = Readonly<{
|
|
|
26
21
|
export type ItemExprCallback<T, TItemJson = unknown> = (args: ItemExprArgs<TItemJson>) => T | Promise<T>;
|
|
27
22
|
|
|
28
23
|
export type ItemExpr<T, TItemJson = unknown> = Readonly<{
|
|
29
|
-
readonly
|
|
24
|
+
readonly __codemationItemExpr: "codemation.itemExpr";
|
|
30
25
|
readonly fn: ItemExprCallback<T, TItemJson>;
|
|
31
26
|
}>;
|
|
32
27
|
|
|
33
28
|
export function itemExpr<T, TItemJson = unknown>(fn: ItemExprCallback<T, TItemJson>): ItemExpr<T, TItemJson> {
|
|
34
|
-
return {
|
|
29
|
+
return { __codemationItemExpr: "codemation.itemExpr", fn };
|
|
35
30
|
}
|
|
36
31
|
|
|
37
32
|
export function isItemExpr<T, TItemJson = unknown>(value: unknown): value is ItemExpr<T, TItemJson> {
|
|
@@ -39,14 +34,7 @@ export function isItemExpr<T, TItemJson = unknown>(value: unknown): value is Ite
|
|
|
39
34
|
return false;
|
|
40
35
|
}
|
|
41
36
|
const v = value as Record<PropertyKey, unknown>;
|
|
42
|
-
if (v[
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
// Support snapshot-hydrated itemExpr wrappers where the symbol brand was lost but the callback survived.
|
|
46
|
-
// Workflow snapshot hydration currently restores function-valued fields (like `fn`) but may drop symbol-keyed brands.
|
|
47
|
-
// We treat the minimal `{ fn: Function }` shape as an itemExpr wrapper to keep runnable configs working.
|
|
48
|
-
const keys = Object.keys(v);
|
|
49
|
-
if (keys.length === 1 && keys[0] === "fn" && typeof (v as { fn?: unknown }).fn === "function") {
|
|
37
|
+
if (v["__codemationItemExpr"] === "codemation.itemExpr" && typeof v["fn"] === "function") {
|
|
50
38
|
return true;
|
|
51
39
|
}
|
|
52
40
|
for (const sym of Object.getOwnPropertySymbols(v)) {
|
|
@@ -54,6 +42,10 @@ export function isItemExpr<T, TItemJson = unknown>(value: unknown): value is Ite
|
|
|
54
42
|
return true;
|
|
55
43
|
}
|
|
56
44
|
}
|
|
45
|
+
const keys = Object.keys(v);
|
|
46
|
+
if (keys.length === 1 && keys[0] === "fn" && typeof (v as { fn?: unknown }).fn === "function") {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
57
49
|
return false;
|
|
58
50
|
}
|
|
59
51
|
|
|
@@ -79,9 +71,6 @@ function containsItemExprInUnknown(value: unknown, seen: WeakSet<object> = new W
|
|
|
79
71
|
return false;
|
|
80
72
|
}
|
|
81
73
|
|
|
82
|
-
/**
|
|
83
|
-
* Deep-resolves {@link itemExpr} leaves. Returns a new graph (does not mutate the original config object).
|
|
84
|
-
*/
|
|
85
74
|
export async function resolveItemExprsInUnknown(
|
|
86
75
|
value: unknown,
|
|
87
76
|
args: ItemExprArgs,
|
|
@@ -117,9 +106,6 @@ export async function resolveItemExprsInUnknown(
|
|
|
117
106
|
return out;
|
|
118
107
|
}
|
|
119
108
|
|
|
120
|
-
/**
|
|
121
|
-
* Clones runnable config (best-effort) so per-item {@link itemExpr} resolution never mutates shared instances.
|
|
122
|
-
*/
|
|
123
109
|
export async function resolveItemExprsForExecution(
|
|
124
110
|
config: unknown,
|
|
125
111
|
nodeCtx: NodeExecutionContext,
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type { Item } from "./workflowTypes";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Reads `meta._cm.originIndex` when present (used for fan-in merge-by-origin and Merge routing).
|
|
5
|
-
*/
|
|
6
3
|
export function getOriginIndexFromItem(item: Item): number | undefined {
|
|
7
4
|
const meta = item.meta as Record<string, unknown> | undefined;
|
|
8
5
|
const cm = meta?._cm as Record<string, unknown> | undefined;
|
|
@@ -1,29 +1,13 @@
|
|
|
1
1
|
export type McpServerTransport = "http";
|
|
2
|
-
// "stdio" is a self-host-only escape hatch (CODEMATION_ALLOW_STDIO_MCP=true); not typed here for managed.
|
|
3
2
|
|
|
4
3
|
export interface McpServerDeclaration {
|
|
5
|
-
/** Globally unique slug, e.g. "gmail". Workflow authors reference this. */
|
|
6
4
|
id: string;
|
|
7
5
|
displayName: string;
|
|
8
6
|
description: string;
|
|
9
7
|
transport: McpServerTransport;
|
|
10
8
|
url: string;
|
|
11
|
-
/**
|
|
12
|
-
* Credential types accepted by this MCP server, matching CredentialRequirement.acceptedTypes.
|
|
13
|
-
* Absent or empty means no credential is required.
|
|
14
|
-
*/
|
|
15
9
|
acceptedCredentialTypes?: ReadonlyArray<string>;
|
|
16
|
-
/**
|
|
17
|
-
* Documentation only in MVP. The bind-time validator checks
|
|
18
|
-
* requiredScopes ⊆ CredentialInstance.scopesGranted.
|
|
19
|
-
*/
|
|
20
10
|
requiredScopes?: string[];
|
|
21
|
-
/** Non-secret static headers merged onto every MCP request. */
|
|
22
11
|
staticHeaders?: Record<string, string>;
|
|
23
|
-
/**
|
|
24
|
-
* Overrides for tool descriptions advertised by the MCP server.
|
|
25
|
-
* Applied by the connection pool after tools/list.
|
|
26
|
-
* Key: exact tool name as returned by the server.
|
|
27
|
-
*/
|
|
28
12
|
toolDescriptionOverrides?: Record<string, string>;
|
|
29
13
|
}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-process retry policy for runnable nodes. Serialized configs use the same
|
|
3
|
-
* `kind` discriminator (`JSON.stringify` / persisted workflows).
|
|
4
|
-
*
|
|
5
|
-
* `maxAttempts` is the total number of tries including the first (e.g. 3 means up to 2 delays after failures).
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
export type RetryPolicySpec = NoneRetryPolicySpec | FixedRetryPolicySpec | ExponentialRetryPolicySpec;
|
|
9
2
|
|
|
10
3
|
export interface NoneRetryPolicySpec {
|
|
@@ -13,18 +6,15 @@ export interface NoneRetryPolicySpec {
|
|
|
13
6
|
|
|
14
7
|
export interface FixedRetryPolicySpec {
|
|
15
8
|
readonly kind: "fixed";
|
|
16
|
-
/** Total attempts including the first execution. Must be >= 1. */
|
|
17
9
|
readonly maxAttempts: number;
|
|
18
10
|
readonly delayMs: number;
|
|
19
11
|
}
|
|
20
12
|
|
|
21
13
|
export interface ExponentialRetryPolicySpec {
|
|
22
14
|
readonly kind: "exponential";
|
|
23
|
-
/** Total attempts including the first execution. Must be >= 1. */
|
|
24
15
|
readonly maxAttempts: number;
|
|
25
16
|
readonly initialDelayMs: number;
|
|
26
17
|
readonly multiplier: number;
|
|
27
18
|
readonly maxDelayMs?: number;
|
|
28
|
-
/** When true, each delay is multiplied by a random factor in [1, 1.2). */
|
|
29
19
|
readonly jitter?: boolean;
|
|
30
20
|
}
|
|
@@ -2,7 +2,6 @@ import type { PersistedRunState } from "./runTypes";
|
|
|
2
2
|
|
|
3
3
|
type RunFinishedAtSource = Pick<PersistedRunState, "status" | "nodeSnapshotsByNodeId" | "finishedAt">;
|
|
4
4
|
|
|
5
|
-
/** Derives workflow end time from persisted run root or node snapshots for run listings. */
|
|
6
5
|
export class RunFinishedAtFactory {
|
|
7
6
|
static resolveIso(state: RunFinishedAtSource): string | undefined {
|
|
8
7
|
if (state.finishedAt && state.status !== "running" && state.status !== "pending") {
|
|
@@ -20,44 +20,26 @@ import type {
|
|
|
20
20
|
WorkflowNodeConnection,
|
|
21
21
|
} from "./workflowTypes";
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
* Test-suite linkage for a run. When set, this run was started by a TestSuiteOrchestrator
|
|
25
|
-
* as one test case inside a TestSuiteRun. The `IsTestRun` node and host-side persisters key
|
|
26
|
-
* off the presence of this field. Subworkflow runs inherit it from their parent run.
|
|
27
|
-
*/
|
|
28
23
|
export interface RunTestContext {
|
|
29
24
|
readonly testSuiteRunId: string;
|
|
30
25
|
readonly testCaseIndex: number;
|
|
31
|
-
/**
|
|
32
|
-
* Optional human-friendly label for this test case (e.g. an email subject when fixtures
|
|
33
|
-
* are loaded from a mailbox). Resolved per item by `TestTrigger.caseLabel(item)` if set,
|
|
34
|
-
* persisted on `Run.test_case_label` so the Tests-tab tree-table can show "RFQ for batch 14"
|
|
35
|
-
* instead of "run_1777755971399_bbb86beac1396".
|
|
36
|
-
*/
|
|
37
26
|
readonly testCaseLabel?: string;
|
|
38
27
|
}
|
|
39
28
|
|
|
40
29
|
export interface RunExecutionOptions {
|
|
41
|
-
/** Run-intent override: force the inline scheduler and bypass node-level offload decisions. */
|
|
42
30
|
localOnly?: boolean;
|
|
43
|
-
/** Marks runs started from webhook handling so orchestration can apply webhook-specific continuation rules. */
|
|
44
31
|
webhook?: boolean;
|
|
45
32
|
mode?: "manual" | "debug";
|
|
46
33
|
sourceWorkflowId?: WorkflowId;
|
|
47
34
|
sourceRunId?: RunId;
|
|
48
35
|
derivedFromRunId?: RunId;
|
|
49
36
|
isMutable?: boolean;
|
|
50
|
-
/** Set by the engine for this run: 0 = root, 1 = first child subworkflow, … */
|
|
51
37
|
subworkflowDepth?: number;
|
|
52
|
-
/** Effective cap after engine policy merge (successful node completions per run). */
|
|
53
38
|
maxNodeActivations?: number;
|
|
54
|
-
/** Effective cap after engine policy merge (subworkflow nesting). */
|
|
55
39
|
maxSubworkflowDepth?: number;
|
|
56
|
-
/** Present iff started by a TestSuiteOrchestrator; propagates to subworkflow runs via {@link ParentExecutionRef.testContext}. */
|
|
57
40
|
testContext?: RunTestContext;
|
|
58
41
|
}
|
|
59
42
|
|
|
60
|
-
/** Engine-owned counters persisted with the run (worker-safe). */
|
|
61
43
|
export interface EngineRunCounters {
|
|
62
44
|
completedNodeActivations: number;
|
|
63
45
|
}
|
|
@@ -88,7 +70,6 @@ export interface PersistedWorkflowSnapshotNode {
|
|
|
88
70
|
tokenName?: string;
|
|
89
71
|
configTokenName?: string;
|
|
90
72
|
config: unknown;
|
|
91
|
-
/** Pre-computed static configuration summary; populated by WorkflowSnapshotCodec. */
|
|
92
73
|
inspectorSummary?: ReadonlyArray<Readonly<{ label: string; value: string }>>;
|
|
93
74
|
}
|
|
94
75
|
|
|
@@ -97,9 +78,7 @@ export interface PersistedWorkflowSnapshot {
|
|
|
97
78
|
name: string;
|
|
98
79
|
nodes: ReadonlyArray<PersistedWorkflowSnapshotNode>;
|
|
99
80
|
edges: ReadonlyArray<Edge>;
|
|
100
|
-
/** When the snapshot was built from a live workflow definition that configured a workflow error handler. */
|
|
101
81
|
workflowErrorHandlerConfigured?: boolean;
|
|
102
|
-
/** Connection metadata for child nodes not in the execution graph (e.g. AI agent attachments). */
|
|
103
82
|
connections?: ReadonlyArray<WorkflowNodeConnection>;
|
|
104
83
|
}
|
|
105
84
|
|
|
@@ -163,20 +142,11 @@ export interface NodeExecutionSnapshot {
|
|
|
163
142
|
inputsByPort?: NodeInputsByPort;
|
|
164
143
|
outputs?: NodeOutputs;
|
|
165
144
|
error?: NodeExecutionError;
|
|
166
|
-
/**
|
|
167
|
-
* When the node is a SubWorkflow invocation, the run id of the child run it spawned.
|
|
168
|
-
* Populated after the child run completes so the UI can deep-link to that specific execution.
|
|
169
|
-
*/
|
|
170
145
|
childRunId?: RunId;
|
|
171
146
|
}
|
|
172
147
|
|
|
173
|
-
/** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
|
|
174
148
|
export type ConnectionInvocationId = string;
|
|
175
149
|
|
|
176
|
-
/**
|
|
177
|
-
* One logical LLM or tool call under an owning workflow node (e.g. AI agent).
|
|
178
|
-
* The owning node defines what {@link managedInput} and {@link managedOutput} contain.
|
|
179
|
-
*/
|
|
180
150
|
export interface ConnectionInvocationRecord {
|
|
181
151
|
readonly invocationId: ConnectionInvocationId;
|
|
182
152
|
readonly runId: RunId;
|
|
@@ -187,24 +157,18 @@ export interface ConnectionInvocationRecord {
|
|
|
187
157
|
readonly status: NodeExecutionStatus;
|
|
188
158
|
readonly managedInput?: JsonValue;
|
|
189
159
|
readonly managedOutput?: JsonValue;
|
|
190
|
-
/** 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. */
|
|
191
160
|
readonly statusLabel?: string;
|
|
192
|
-
/** 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. */
|
|
193
161
|
readonly subjectName?: string;
|
|
194
162
|
readonly error?: NodeExecutionError;
|
|
195
163
|
readonly queuedAt?: string;
|
|
196
164
|
readonly startedAt?: string;
|
|
197
165
|
readonly finishedAt?: string;
|
|
198
166
|
readonly updatedAt: string;
|
|
199
|
-
/** Per-item iteration id minted by the engine when this invocation occurred inside a runnable node's per-item loop. */
|
|
200
167
|
readonly iterationId?: NodeIterationId;
|
|
201
|
-
/** Item index (0-based) of the iteration that produced this invocation. */
|
|
202
168
|
readonly itemIndex?: number;
|
|
203
|
-
/** When set, this invocation was produced inside a sub-agent triggered by the named parent invocation. */
|
|
204
169
|
readonly parentInvocationId?: ConnectionInvocationId;
|
|
205
170
|
}
|
|
206
171
|
|
|
207
|
-
/** Arguments for appending a {@link ConnectionInvocationRecord} (engine fills run/workflow ids and timestamps). */
|
|
208
172
|
export type ConnectionInvocationAppendArgs = Readonly<{
|
|
209
173
|
invocationId: ConnectionInvocationId;
|
|
210
174
|
connectionNodeId: NodeId;
|
|
@@ -227,7 +191,6 @@ export type ConnectionInvocationAppendArgs = Readonly<{
|
|
|
227
191
|
export interface RunCurrentState {
|
|
228
192
|
outputsByNode: Record<NodeId, NodeOutputs>;
|
|
229
193
|
nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
|
|
230
|
-
/** Append-only history of connection-scoped invocations (LLM/tool) for inspector and canvas. */
|
|
231
194
|
connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
|
|
232
195
|
mutableState?: PersistedMutableRunState;
|
|
233
196
|
}
|
|
@@ -258,7 +221,6 @@ export interface ExecutionFrontierPlan {
|
|
|
258
221
|
|
|
259
222
|
export type RunStatus = "running" | "pending" | "completed" | "failed" | "suspended" | "halted";
|
|
260
223
|
|
|
261
|
-
/** Reason a run transitioned to {@link RunStatus} `"halted"`. */
|
|
262
224
|
export type RunHaltReason = "hitl-rejected" | "hitl-timeout" | "hitl-cancelled";
|
|
263
225
|
|
|
264
226
|
export interface RunSummary {
|
|
@@ -266,14 +228,7 @@ export interface RunSummary {
|
|
|
266
228
|
workflowId: WorkflowId;
|
|
267
229
|
startedAt: string;
|
|
268
230
|
status: RunStatus;
|
|
269
|
-
/**
|
|
270
|
-
* Test-case status for runs dispatched as part of a TestSuiteRun. Carries the
|
|
271
|
-
* assertion-rollup-corrected outcome the test orchestrator persists onto the row, so the
|
|
272
|
-
* executions list can show "failed" for a run whose workflow completed cleanly but whose
|
|
273
|
-
* assertions caught regressions. Absent for non-test runs and legacy rows.
|
|
274
|
-
*/
|
|
275
231
|
testCaseStatus?: TestCaseRunStatus;
|
|
276
|
-
/** ISO timestamp when the run finished (derived from node snapshots or store `updatedAt`); omit while running/pending. */
|
|
277
232
|
finishedAt?: string;
|
|
278
233
|
parent?: ParentExecutionRef;
|
|
279
234
|
executionOptions?: RunExecutionOptions;
|
|
@@ -297,34 +252,20 @@ export interface PersistedRunSchedulingState {
|
|
|
297
252
|
queue: RunQueueEntry[];
|
|
298
253
|
}
|
|
299
254
|
|
|
300
|
-
/** One persisted suspension entry per suspended item. */
|
|
301
255
|
export interface PersistedSuspensionEntry {
|
|
302
|
-
/** Opaque task identifier (UUID v4). */
|
|
303
256
|
readonly taskId: string;
|
|
304
257
|
readonly nodeId: NodeId;
|
|
305
258
|
readonly activationId: NodeActivationId;
|
|
306
259
|
readonly itemIndex: number;
|
|
307
|
-
/** SHA-256 hex digest of the decision schema JSON (for schema-drift detection). */
|
|
308
260
|
readonly decisionSchemaHash: string;
|
|
309
|
-
/** Serialized return value from `SuspensionRequest.deliver` (stored on the HumanTask row). */
|
|
310
261
|
readonly deliveryRef: JsonValue;
|
|
311
|
-
/** ISO timestamp when the task expires. */
|
|
312
262
|
readonly timeoutAt: string;
|
|
313
263
|
readonly onTimeout: "halt" | "auto-accept";
|
|
314
264
|
}
|
|
315
265
|
|
|
316
|
-
/**
|
|
317
|
-
* When a node is re-activated after suspension, the engine writes the resume context here
|
|
318
|
-
* so `NodeExecutionRequestHandlerService` can splice `resumeContext` into ctx.
|
|
319
|
-
* Cleared once the re-activation is consumed.
|
|
320
|
-
*/
|
|
321
266
|
export interface PendingResumeEntry {
|
|
322
267
|
readonly activationId: NodeActivationId;
|
|
323
268
|
readonly nodeId: NodeId;
|
|
324
|
-
/**
|
|
325
|
-
* Typed as `unknown` here to avoid a circular import between runTypes ↔ runtimeTypes.
|
|
326
|
-
* `NodeExecutionRequestHandlerService` casts this to `ResumeContext` from runtimeTypes.
|
|
327
|
-
*/
|
|
328
269
|
readonly resumeContext: unknown;
|
|
329
270
|
}
|
|
330
271
|
|
|
@@ -332,37 +273,23 @@ export interface PersistedRunState {
|
|
|
332
273
|
runId: RunId;
|
|
333
274
|
workflowId: WorkflowId;
|
|
334
275
|
startedAt: string;
|
|
335
|
-
/** Canonical terminal time for listings and retention when persisted on the run root. */
|
|
336
276
|
finishedAt?: string;
|
|
337
|
-
/** Optimistic concurrency / CAS on the run aggregate (repository may increment on save). */
|
|
338
277
|
revision?: number;
|
|
339
278
|
parent?: ParentExecutionRef;
|
|
340
279
|
executionOptions?: RunExecutionOptions;
|
|
341
280
|
control?: PersistedRunControlState;
|
|
342
281
|
workflowSnapshot?: PersistedWorkflowSnapshot;
|
|
343
282
|
mutableState?: PersistedMutableRunState;
|
|
344
|
-
/** Frozen at createRun from workflow + runtime defaults for prune/storage decisions. */
|
|
345
283
|
policySnapshot?: PersistedRunPolicySnapshot;
|
|
346
|
-
/** Successful node completions so far (for activation budget). */
|
|
347
284
|
engineCounters?: EngineRunCounters;
|
|
348
285
|
status: RunStatus;
|
|
349
|
-
/** Populated when `status === "halted"` to discriminate why the run was halted. */
|
|
350
286
|
reason?: RunHaltReason;
|
|
351
287
|
pending?: PendingNodeExecution;
|
|
352
288
|
queue: RunQueueEntry[];
|
|
353
289
|
outputsByNode: Record<NodeId, NodeOutputs>;
|
|
354
290
|
nodeSnapshotsByNodeId: Record<NodeId, NodeExecutionSnapshot>;
|
|
355
|
-
/** Append-only history of connection invocations (LLM/tool) nested under owning nodes. */
|
|
356
291
|
connectionInvocations?: ReadonlyArray<ConnectionInvocationRecord>;
|
|
357
|
-
/**
|
|
358
|
-
* One entry per outstanding HITL suspension (per-item).
|
|
359
|
-
* Present and non-empty iff `status === "suspended"`.
|
|
360
|
-
*/
|
|
361
292
|
suspension?: ReadonlyArray<PersistedSuspensionEntry>;
|
|
362
|
-
/**
|
|
363
|
-
* Written by `resumeRun()` so `NodeExecutionRequestHandlerService` can splice `resumeContext`
|
|
364
|
-
* into the ctx when re-executing the suspended node. Cleared once consumed.
|
|
365
|
-
*/
|
|
366
293
|
pendingResume?: PendingResumeEntry;
|
|
367
294
|
}
|
|
368
295
|
|
|
@@ -389,7 +316,6 @@ export interface WorkflowExecutionListingRepository {
|
|
|
389
316
|
listRuns(args?: Readonly<{ workflowId?: WorkflowId; limit?: number }>): Promise<ReadonlyArray<RunSummary>>;
|
|
390
317
|
}
|
|
391
318
|
|
|
392
|
-
/** Runs eligible for retention-based pruning (completed or failed, older than cutoff). */
|
|
393
319
|
export interface RunPruneCandidate {
|
|
394
320
|
readonly runId: RunId;
|
|
395
321
|
readonly workflowId: WorkflowId;
|
|
@@ -19,56 +19,30 @@ import type { WorkflowActivationPolicy } from "./workflowActivationPolicy";
|
|
|
19
19
|
import type { TriggerInstanceId, WebhookTriggerMatcher } from "./webhookTypes";
|
|
20
20
|
import type { ZodType } from "zod";
|
|
21
21
|
|
|
22
|
-
// ---------------------------------------------------------------------------
|
|
23
|
-
// HITL primitives
|
|
24
|
-
// ---------------------------------------------------------------------------
|
|
25
|
-
|
|
26
|
-
/** Opaque unique identifier for a single HumanTask instance. */
|
|
27
22
|
export type HumanTaskId = string;
|
|
28
23
|
|
|
29
|
-
/**
|
|
30
|
-
* Duration string — ISO 8601 duration ("PT24H") or shorthand ("24h").
|
|
31
|
-
* Parsed by the timeout job; stored as-is in the suspension record.
|
|
32
|
-
*/
|
|
33
24
|
export type Duration = string;
|
|
34
25
|
|
|
35
|
-
/**
|
|
36
|
-
* Minimal handle handed to the `deliver` callback so it can route to the correct
|
|
37
|
-
* inbox channel.
|
|
38
|
-
*/
|
|
39
26
|
export interface HumanTaskHandle {
|
|
40
27
|
readonly taskId: HumanTaskId;
|
|
41
28
|
readonly runId: string;
|
|
42
29
|
readonly nodeId: string;
|
|
43
30
|
readonly expiresAt: Date;
|
|
44
|
-
/** TODO: real signed URL; placeholder empty string for now. */
|
|
45
31
|
readonly resumeUrl: string;
|
|
46
|
-
/**
|
|
47
|
-
* Arbitrary JSON metadata copied from `SuspensionRequest.request.metadata` at suspension time.
|
|
48
|
-
* Used by the agent runtime to round-trip the `agentCheckpoint` back to the
|
|
49
|
-
* resumed node via `ctx.resumeContext.task.metadata`.
|
|
50
|
-
*/
|
|
51
32
|
readonly metadata?: Readonly<Record<string, import("./workflowTypes").JsonValue>>;
|
|
52
33
|
}
|
|
53
34
|
|
|
54
|
-
/** Human-readable description surface shown to the reviewer. */
|
|
55
35
|
export interface HumanTaskSubject {
|
|
56
36
|
readonly title: string;
|
|
57
37
|
readonly summary: string;
|
|
58
38
|
readonly attributes?: import("./workflowTypes").JsonValue;
|
|
59
39
|
}
|
|
60
40
|
|
|
61
|
-
/** Identity of the person who made a decision on the task. */
|
|
62
41
|
export interface HumanTaskActor {
|
|
63
42
|
readonly actorId: string;
|
|
64
43
|
readonly displayName?: string;
|
|
65
44
|
}
|
|
66
45
|
|
|
67
|
-
/**
|
|
68
|
-
* Resume context injected into `NodeExecutionContext` when the engine re-activates
|
|
69
|
-
* a previously suspended node. `defineHumanApprovalNode` wraps this with parsed
|
|
70
|
-
* `TDecision`; at the engine layer `decision.value` is `unknown`.
|
|
71
|
-
*/
|
|
72
46
|
export interface ResumeContext {
|
|
73
47
|
readonly decision:
|
|
74
48
|
| Readonly<{ kind: "decided"; value: unknown; actor: HumanTaskActor; decidedAt: Date }>
|
|
@@ -78,25 +52,6 @@ export interface ResumeContext {
|
|
|
78
52
|
readonly task: HumanTaskHandle;
|
|
79
53
|
}
|
|
80
54
|
|
|
81
|
-
/**
|
|
82
|
-
* Thrown by a node's `execute()` to request durable suspension of the current item.
|
|
83
|
-
* The engine catches this, persists the suspension entry, calls `deliver`, and
|
|
84
|
-
* continues to the next item (per-item semantics).
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```ts
|
|
88
|
-
* throw new SuspensionRequest({
|
|
89
|
-
* decisionSchema: z.object({ approved: z.boolean() }),
|
|
90
|
-
* timeout: "PT24H",
|
|
91
|
-
* onTimeout: "halt",
|
|
92
|
-
* subject: { title: "Approve invoice", summary: "Invoice #1234 needs approval" },
|
|
93
|
-
* deliver: async (handle) => {
|
|
94
|
-
* await notifySlack(handle);
|
|
95
|
-
* return { channel: "slack", ts: "..." };
|
|
96
|
-
* },
|
|
97
|
-
* });
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
55
|
export class SuspensionRequest<
|
|
101
56
|
TDecision = unknown,
|
|
102
57
|
TDelivery extends import("./workflowTypes").JsonValue = import("./workflowTypes").JsonValue,
|
|
@@ -111,8 +66,6 @@ export class SuspensionRequest<
|
|
|
111
66
|
deliver: (handle: HumanTaskHandle) => Promise<TDelivery>;
|
|
112
67
|
}>,
|
|
113
68
|
) {
|
|
114
|
-
// Extending Error so wrappers like InProcessRetryRunner preserve identity
|
|
115
|
-
// (`instanceof SuspensionRequest`) instead of coercing via String(thrown).
|
|
116
69
|
super(`SuspensionRequest(${request.subject?.title ?? "untitled"})`);
|
|
117
70
|
this.name = "SuspensionRequest";
|
|
118
71
|
}
|
|
@@ -190,11 +143,6 @@ export interface NodeExecutionStatePublisher {
|
|
|
190
143
|
error: Error;
|
|
191
144
|
}): Promise<void>;
|
|
192
145
|
appendConnectionInvocation(args: ConnectionInvocationAppendArgs): Promise<void>;
|
|
193
|
-
/**
|
|
194
|
-
* Annotates the current snapshot for `nodeId` with the id of the child run spawned by a
|
|
195
|
-
* SubWorkflow invocation. Called from `SubWorkflowNode.execute` after `runById` resolves.
|
|
196
|
-
* The engine's subsequent `markCompleted` call preserves the value via `previous.childRunId`.
|
|
197
|
-
*/
|
|
198
146
|
setChildRunId?(args: { nodeId: NodeId; childRunId: RunId }): Promise<void>;
|
|
199
147
|
}
|
|
200
148
|
|
|
@@ -227,9 +175,7 @@ export interface BinaryStorage {
|
|
|
227
175
|
openReadStream(storageKey: string): Promise<BinaryStorageReadResult | undefined>;
|
|
228
176
|
stat(storageKey: string): Promise<BinaryStorageStatResult>;
|
|
229
177
|
delete(storageKey: string): Promise<void>;
|
|
230
|
-
/** Deletes multiple objects in bulk. Keys are batched internally. */
|
|
231
178
|
deleteMany(storageKeys: ReadonlyArray<string>): Promise<void>;
|
|
232
|
-
/** Lists all keys sharing a common prefix. Returns keys in arbitrary order. */
|
|
233
179
|
listByPrefix(prefix: string): Promise<ReadonlyArray<string>>;
|
|
234
180
|
}
|
|
235
181
|
|
|
@@ -246,27 +192,13 @@ export interface NodeBinaryAttachmentService extends ExecutionBinaryService {
|
|
|
246
192
|
withAttachment<TJson>(item: Item<TJson>, name: string, attachment: BinaryAttachment): Item<TJson>;
|
|
247
193
|
}
|
|
248
194
|
|
|
249
|
-
/** Default maximum bytes read into memory by the bounded helpers (50 MiB). */
|
|
250
195
|
export const BINARY_DEFAULT_MAX_BYTES = 50 * 1024 * 1024;
|
|
251
196
|
|
|
252
197
|
export interface ExecutionBinaryService {
|
|
253
198
|
forNode(args: { nodeId: NodeId; activationId: NodeActivationId }): NodeBinaryAttachmentService;
|
|
254
199
|
openReadStream(attachment: BinaryAttachment): Promise<BinaryStorageReadResult | undefined>;
|
|
255
|
-
/**
|
|
256
|
-
* Reads all bytes from the attachment into a contiguous `Uint8Array`.
|
|
257
|
-
* Checks `attachment.size` against `maxBytes` *before* any allocation; throws a bounded-read
|
|
258
|
-
* error when exceeded (no OOM). Throws if the stream is unavailable or the byte count mismatches.
|
|
259
|
-
*/
|
|
260
200
|
getBytes(attachment: BinaryAttachment, maxBytes?: number): Promise<Uint8Array>;
|
|
261
|
-
/**
|
|
262
|
-
* Reads the attachment and decodes the bytes as UTF-8 text.
|
|
263
|
-
* Subject to the same bounded-read safety as `getBytes`.
|
|
264
|
-
*/
|
|
265
201
|
getText(attachment: BinaryAttachment, maxBytes?: number): Promise<string>;
|
|
266
|
-
/**
|
|
267
|
-
* Reads the attachment, decodes as UTF-8 text, and parses as JSON.
|
|
268
|
-
* Throws a clear error on invalid JSON. Subject to the same bounded-read safety.
|
|
269
|
-
*/
|
|
270
202
|
getJson<T = unknown>(attachment: BinaryAttachment, maxBytes?: number): Promise<T>;
|
|
271
203
|
}
|
|
272
204
|
|
|
@@ -274,11 +206,8 @@ export interface ExecutionContext {
|
|
|
274
206
|
runId: RunId;
|
|
275
207
|
workflowId: WorkflowId;
|
|
276
208
|
parent?: ParentExecutionRef;
|
|
277
|
-
/** This run's subworkflow depth (0 = root). */
|
|
278
209
|
subworkflowDepth: number;
|
|
279
|
-
/** Effective activation budget cap for this run (after policy merge). */
|
|
280
210
|
engineMaxNodeActivations: number;
|
|
281
|
-
/** Effective subworkflow nesting cap for this run (after policy merge). */
|
|
282
211
|
engineMaxSubworkflowDepth: number;
|
|
283
212
|
now: () => Date;
|
|
284
213
|
data: RunDataSnapshot;
|
|
@@ -286,28 +215,11 @@ export interface ExecutionContext {
|
|
|
286
215
|
telemetry: ExecutionTelemetry;
|
|
287
216
|
binary: ExecutionBinaryService;
|
|
288
217
|
getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
|
|
289
|
-
/** Per-item iteration id, set by {@link NodeExecutor} on the ctx passed into runnable `execute`. */
|
|
290
218
|
iterationId?: NodeIterationId;
|
|
291
|
-
/** Item index (0-based) within the current activation's batch; set alongside {@link iterationId}. */
|
|
292
219
|
itemIndex?: number;
|
|
293
|
-
/** When set, this ctx is executing inside a sub-agent triggered by the named parent invocation. */
|
|
294
220
|
parentInvocationId?: ConnectionInvocationId;
|
|
295
|
-
/**
|
|
296
|
-
* Present iff the run was started by a TestSuiteOrchestrator. The {@link IsTestRunNode}
|
|
297
|
-
* branches on this; assertion-emitting nodes use it to decide whether to record results.
|
|
298
|
-
*/
|
|
299
221
|
testContext?: RunTestContext;
|
|
300
|
-
/**
|
|
301
|
-
* Collections registered in the codemation config, keyed by collection name.
|
|
302
|
-
*/
|
|
303
222
|
readonly collections?: CollectionsContext;
|
|
304
|
-
/**
|
|
305
|
-
* Resolve a DI token from the host container.
|
|
306
|
-
* Allows nodes to reach host-side services (e.g. `InboxChannelResolverToken`)
|
|
307
|
-
* without importing host code. Wired by `DefaultExecutionContextFactory`; throws
|
|
308
|
-
* a clear error when no resolver is configured (e.g. in unit tests that don't
|
|
309
|
-
* set up the full container).
|
|
310
|
-
*/
|
|
311
223
|
resolve<T>(token: TypeToken<T>): T;
|
|
312
224
|
}
|
|
313
225
|
|
|
@@ -334,19 +246,10 @@ export interface NodeExecutionContext<TConfig extends NodeConfigBase = NodeConfi
|
|
|
334
246
|
config: TConfig;
|
|
335
247
|
telemetry: NodeExecutionTelemetry;
|
|
336
248
|
binary: NodeBinaryAttachmentService;
|
|
337
|
-
/**
|
|
338
|
-
* Present when this node activation is a HITL resume.
|
|
339
|
-
* The node checks `ctx.resumeContext !== undefined` and takes the resume branch.
|
|
340
|
-
*/
|
|
341
249
|
resumeContext?: ResumeContext;
|
|
342
250
|
}
|
|
343
251
|
|
|
344
|
-
export interface
|
|
345
|
-
/**
|
|
346
|
-
* Start the polling loop. The runtime registers its own cleanup handle so callers do not need to
|
|
347
|
-
* call {@link TriggerSetupContext.registerCleanup} for the loop.
|
|
348
|
-
* @returns The state returned by the first cycle (or `undefined` when the overlap guard fired).
|
|
349
|
-
*/
|
|
252
|
+
export interface TriggerPollingPort {
|
|
350
253
|
start<TState, TItem>(args: {
|
|
351
254
|
intervalMs: number;
|
|
352
255
|
seedState?: TState;
|
|
@@ -355,7 +258,9 @@ export interface PollingTriggerHandle {
|
|
|
355
258
|
signal: AbortSignal;
|
|
356
259
|
}) => Promise<{ items: Items<TItem>; nextState: TState }>;
|
|
357
260
|
}): Promise<TState | undefined>;
|
|
358
|
-
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export interface PollingTriggerHandle extends TriggerPollingPort {
|
|
359
264
|
readonly dedup: import("../triggers/polling/PollingTriggerDedupWindow").PollingTriggerDedupWindow;
|
|
360
265
|
}
|
|
361
266
|
|
|
@@ -368,7 +273,6 @@ export interface TriggerSetupContext<
|
|
|
368
273
|
previousState: TSetupState;
|
|
369
274
|
registerCleanup(cleanup: TriggerCleanupHandle): void;
|
|
370
275
|
emit(items: Items): Promise<void>;
|
|
371
|
-
/** Generic polling-trigger surface. Pre-binds trigger id, emit, and registerCleanup. */
|
|
372
276
|
readonly polling: PollingTriggerHandle;
|
|
373
277
|
}
|
|
374
278
|
|
|
@@ -382,12 +286,6 @@ export interface TriggerTestItemsContext<
|
|
|
382
286
|
previousState: TSetupState;
|
|
383
287
|
}
|
|
384
288
|
|
|
385
|
-
/**
|
|
386
|
-
* Trigger setup state is intentionally engine-owned so future ownership and
|
|
387
|
-
* leader-election metadata can be coordinated centrally rather than pushed into
|
|
388
|
-
* package-level setup code.
|
|
389
|
-
*/
|
|
390
|
-
|
|
391
289
|
export interface PersistedTriggerSetupState<TState extends JsonValue | undefined = JsonValue | undefined> {
|
|
392
290
|
trigger: TriggerInstanceId;
|
|
393
291
|
updatedAt: string;
|
|
@@ -409,12 +307,6 @@ export interface EngineHost {
|
|
|
409
307
|
workflows?: WorkflowRunnerService;
|
|
410
308
|
}
|
|
411
309
|
|
|
412
|
-
/**
|
|
413
|
-
* Per-item runnable node: return JSON, an array to fan-out on `main`, an explicit `Item`, or {@link emitPorts}
|
|
414
|
-
* for multi-port emission. Engine applies `inputSchema.parse(item.json)` and passes the result as `args.input`
|
|
415
|
-
* (wire `item.json` is unchanged). Transform helpers may opt into binary preservation, while routers and
|
|
416
|
-
* pass-through nodes should return explicit items when they need to preserve full item state.
|
|
417
|
-
*/
|
|
418
310
|
export interface RunnableNodeExecuteArgs<
|
|
419
311
|
TConfig extends RunnableNodeConfig<any, any> = RunnableNodeConfig<any, any>,
|
|
420
312
|
TInputJson = unknown,
|
|
@@ -432,19 +324,11 @@ export interface RunnableNode<
|
|
|
432
324
|
_TOutputJson = unknown,
|
|
433
325
|
> {
|
|
434
326
|
readonly kind: "node";
|
|
435
|
-
/**
|
|
436
|
-
* Declared output ports (e.g. `["main"]`).
|
|
437
|
-
*
|
|
438
|
-
* Prefer describing dynamic router ports (Switch) and fixed multi-ports (If true/false)
|
|
439
|
-
* via {@link NodeConfigBase.declaredOutputPorts}. Engine defaults to `["main"]` when omitted.
|
|
440
|
-
*/
|
|
441
327
|
readonly outputPorts?: ReadonlyArray<OutputPortKey>;
|
|
442
|
-
/** When omitted, engine uses {@link RunnableNodeConfig.inputSchema} or `z.unknown()`. */
|
|
443
328
|
readonly inputSchema?: ZodType<TInputJson>;
|
|
444
329
|
execute(args: RunnableNodeExecuteArgs<TConfig, TInputJson>): Promise<unknown> | unknown;
|
|
445
330
|
}
|
|
446
331
|
|
|
447
|
-
/** @deprecated Use {@link RunnableNode} */
|
|
448
332
|
export type ItemNode<
|
|
449
333
|
TConfig extends RunnableNodeConfig<any, any> = RunnableNodeConfig<any, any>,
|
|
450
334
|
TInputJson = unknown,
|
|
@@ -453,12 +337,6 @@ export type ItemNode<
|
|
|
453
337
|
|
|
454
338
|
export interface MultiInputNode<TConfig extends NodeConfigBase = NodeConfigBase> {
|
|
455
339
|
kind: "node";
|
|
456
|
-
/**
|
|
457
|
-
* Declared output ports (typically `["main"]`).
|
|
458
|
-
*
|
|
459
|
-
* Prefer describing ports for authoring/canvas via {@link NodeConfigBase.declaredOutputPorts}.
|
|
460
|
-
* Engine defaults to `["main"]` when omitted.
|
|
461
|
-
*/
|
|
462
340
|
outputPorts?: ReadonlyArray<OutputPortKey>;
|
|
463
341
|
executeMulti(inputsByPort: NodeInputsByPort, ctx: NodeExecutionContext<TConfig>): Promise<NodeOutputs>;
|
|
464
342
|
}
|
|
@@ -582,7 +460,6 @@ export interface WorkflowSnapshotResolver {
|
|
|
582
460
|
}): WorkflowDefinition | undefined;
|
|
583
461
|
}
|
|
584
462
|
|
|
585
|
-
/** Optional host wiring for trigger lifecycle logs (boot skip + activation sync). */
|
|
586
463
|
export interface TriggerRuntimeDiagnostics {
|
|
587
464
|
info(message: string): void;
|
|
588
465
|
warn(message: string): void;
|
|
@@ -592,7 +469,6 @@ export interface EngineDeps {
|
|
|
592
469
|
credentialSessions: CredentialSessionService;
|
|
593
470
|
liveWorkflowRepository: LiveWorkflowRepository;
|
|
594
471
|
workflowRepository: WorkflowRepository;
|
|
595
|
-
/** When {@link AllWorkflowsActiveWorkflowActivationPolicy}, all workflows behave as active (tests). */
|
|
596
472
|
workflowActivationPolicy: WorkflowActivationPolicy;
|
|
597
473
|
nodeResolver: NodeResolver;
|
|
598
474
|
triggerSetupStateRepository: TriggerSetupStateRepository;
|
|
@@ -608,10 +484,7 @@ export interface EngineDeps {
|
|
|
608
484
|
eventBus?: RunEventBus;
|
|
609
485
|
tokenRegistry: PersistedWorkflowTokenRegistryLike;
|
|
610
486
|
workflowNodeInstanceFactory: WorkflowNodeInstanceFactory;
|
|
611
|
-
/** Defaults for prune/storage snapshot when workflow omits explicit policy fields. */
|
|
612
487
|
workflowPolicyRuntimeDefaults?: WorkflowPolicyRuntimeDefaults;
|
|
613
|
-
/** When set, logs inactive-workflow skips at boot and trigger start/stop on activation changes. */
|
|
614
488
|
triggerRuntimeDiagnostics?: TriggerRuntimeDiagnostics;
|
|
615
|
-
/** When set, the polling-trigger runtime uses this logger for cycle info/debug/error. */
|
|
616
489
|
pollingTriggerLogger?: import("../triggers/polling/PollingTriggerLogger").PollingTriggerLogger;
|
|
617
490
|
}
|