@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,18 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* definePollingTrigger — declarative helper for authoring polling triggers.
|
|
3
|
-
*
|
|
4
|
-
* Mirrors the ergonomics of `defineNode` / `defineRestNode` / `defineCredential`.
|
|
5
|
-
* Plugin authors supply a `poll` function plus metadata; the helper synthesises the
|
|
6
|
-
* two internal classes (`DefinedPollingTriggerRuntime` + `DefinedPollingTriggerConfig`)
|
|
7
|
-
* that the engine's trigger machinery requires. Internal classes, DI annotations, and
|
|
8
|
-
* `PollingTriggerRuntime` wiring are hidden from the plugin-author surface entirely.
|
|
9
|
-
*/
|
|
10
1
|
import type {
|
|
11
2
|
Items,
|
|
3
|
+
JsonObject,
|
|
12
4
|
JsonValue,
|
|
13
5
|
NodeExecutionContext,
|
|
14
6
|
NodeInspectorSummaryRow,
|
|
15
7
|
NodeOutputs,
|
|
8
|
+
PollingTriggerConfig,
|
|
16
9
|
TestableTriggerNode,
|
|
17
10
|
TriggerNodeConfig,
|
|
18
11
|
TriggerSetupContext,
|
|
@@ -21,6 +14,7 @@ import type {
|
|
|
21
14
|
} from "..";
|
|
22
15
|
import type { CredentialJsonRecord, CredentialRequirement } from "../contracts/credentialTypes";
|
|
23
16
|
import type { DefinedNodeCredentialAccessors, DefinedNodeCredentialBindings } from "./defineNode.types";
|
|
17
|
+
import type { NodeBaseOptions } from "./nodeBaseOptions.types";
|
|
24
18
|
import { node as persistedNode } from "../runtime-types/runtimeTypeDecorators.types";
|
|
25
19
|
import {
|
|
26
20
|
definedNodeCredentialRequirementFactory,
|
|
@@ -28,15 +22,8 @@ import {
|
|
|
28
22
|
} from "./definePollingTriggerInternals";
|
|
29
23
|
import type { ZodType } from "zod";
|
|
30
24
|
|
|
31
|
-
// ---------------------------------------------------------------------------
|
|
32
|
-
// Public types
|
|
33
|
-
// ---------------------------------------------------------------------------
|
|
34
|
-
|
|
35
25
|
type MaybePromise<TValue> = TValue | Promise<TValue>;
|
|
36
26
|
|
|
37
|
-
/**
|
|
38
|
-
* Context passed into the `poll` callback on each tick.
|
|
39
|
-
*/
|
|
40
27
|
export interface DefinePollingTriggerPollContext<
|
|
41
28
|
TConfig extends CredentialJsonRecord,
|
|
42
29
|
TState extends JsonValue | undefined,
|
|
@@ -47,36 +34,17 @@ export interface DefinePollingTriggerPollContext<
|
|
|
47
34
|
readonly credentials: DefinedNodeCredentialAccessors<TBindings>;
|
|
48
35
|
}
|
|
49
36
|
|
|
50
|
-
/**
|
|
51
|
-
* What `poll` must return each tick.
|
|
52
|
-
*/
|
|
53
37
|
export interface DefinePollingTriggerPollResult<TItemJson, TState extends JsonValue | undefined> {
|
|
54
|
-
/**
|
|
55
|
-
* New items to emit. Each item may carry an optional `dedupKey`; duplicate keys are
|
|
56
|
-
* filtered out against a rolling dedup window (managed internally by the runtime).
|
|
57
|
-
* Items without a `dedupKey` are always emitted.
|
|
58
|
-
*/
|
|
59
38
|
readonly items: ReadonlyArray<{ json: TItemJson; dedupKey?: string }>;
|
|
60
|
-
/** Persisted as the trigger's setup state for the next tick. */
|
|
61
39
|
readonly nextState: TState;
|
|
62
40
|
}
|
|
63
41
|
|
|
64
|
-
/**
|
|
65
|
-
* Context passed into the `execute` callback for post-emit enrichment (e.g. fetching
|
|
66
|
-
* attachment bytes). Mirrors `NodeExecutionContext` so plugin authors use familiar patterns.
|
|
67
|
-
*/
|
|
68
42
|
export type DefinePollingTriggerExecuteContext<TConfig extends TriggerNodeConfig<any, any>> =
|
|
69
43
|
NodeExecutionContext<TConfig>;
|
|
70
44
|
|
|
71
|
-
/**
|
|
72
|
-
* Context passed into the `testItems` callback.
|
|
73
|
-
*/
|
|
74
45
|
export type DefinePollingTriggerTestItemsContext<TConfig extends TriggerNodeConfig<any, any>> =
|
|
75
46
|
TriggerTestItemsContext<TConfig>;
|
|
76
47
|
|
|
77
|
-
/**
|
|
78
|
-
* Options accepted by `definePollingTrigger`.
|
|
79
|
-
*/
|
|
80
48
|
export interface DefinePollingTriggerOptions<
|
|
81
49
|
TKey extends string,
|
|
82
50
|
TConfig extends CredentialJsonRecord,
|
|
@@ -84,77 +52,30 @@ export interface DefinePollingTriggerOptions<
|
|
|
84
52
|
TState extends JsonValue | undefined,
|
|
85
53
|
TBindings extends DefinedNodeCredentialBindings | undefined = undefined,
|
|
86
54
|
> {
|
|
87
|
-
/**
|
|
88
|
-
* Unique node-token-id-style key, e.g. `"msgraph-mail.on-new-mail"`.
|
|
89
|
-
* Used as the persisted runtime type name — must be stable across deployments.
|
|
90
|
-
*/
|
|
91
55
|
readonly key: TKey;
|
|
56
|
+
readonly packageName?: string;
|
|
92
57
|
readonly title: string;
|
|
93
58
|
readonly description?: string;
|
|
94
|
-
/** Canvas icon (same contract as `NodeConfigBase.icon`). */
|
|
95
59
|
readonly icon?: string;
|
|
96
|
-
/**
|
|
97
|
-
* Zod schema for the trigger's user-facing configuration.
|
|
98
|
-
* When provided, the returned `create()` method is typed against the inferred config type.
|
|
99
|
-
*/
|
|
100
60
|
readonly configSchema?: ZodType<TConfig>;
|
|
101
|
-
/** Credential bindings keyed by slot (same format as `defineNode`). */
|
|
102
61
|
readonly credentials?: TBindings;
|
|
103
|
-
/**
|
|
104
|
-
* Static configuration summary surfaced in the workflow inspector — see
|
|
105
|
-
* {@link import("../contracts/workflowTypes").NodeConfigBase.inspectorSummary}.
|
|
106
|
-
*
|
|
107
|
-
* Receives the static config; returns 2–6 short label/value pairs (or `undefined` to skip).
|
|
108
|
-
*/
|
|
109
62
|
readonly inspectorSummary?: (
|
|
110
63
|
args: Readonly<{ config: TConfig }>,
|
|
111
64
|
) => ReadonlyArray<NodeInspectorSummaryRow> | undefined;
|
|
112
|
-
/**
|
|
113
|
-
* Called once when the trigger arms (or re-arms after a server restart) to provide the
|
|
114
|
-
* initial value for `state` when no persisted state exists.
|
|
115
|
-
*/
|
|
116
65
|
initialState?(): TState;
|
|
117
|
-
/**
|
|
118
|
-
* Polling interval in milliseconds. The runtime enforces a minimum of 25 ms.
|
|
119
|
-
* @default 60_000
|
|
120
|
-
*/
|
|
121
66
|
readonly pollIntervalMs?: number;
|
|
122
|
-
/**
|
|
123
|
-
* The per-tick poll logic. Called by the runtime each interval.
|
|
124
|
-
* Must return new items plus the next persisted state.
|
|
125
|
-
*/
|
|
126
67
|
poll(
|
|
127
68
|
pollCtx: DefinePollingTriggerPollContext<TConfig, TState, TBindings>,
|
|
128
69
|
): MaybePromise<DefinePollingTriggerPollResult<TItemJson, TState>>;
|
|
129
|
-
/**
|
|
130
|
-
* Optional post-emit enrichment step (runs in the normal node-execute phase after the
|
|
131
|
-
* trigger fires and the workflow run starts). Use for expensive per-item work such as
|
|
132
|
-
* fetching attachment bytes via `ctx.binary.attach`. When omitted, the trigger passes
|
|
133
|
-
* items through unchanged.
|
|
134
|
-
*/
|
|
135
70
|
execute?(
|
|
136
71
|
items: Items<TItemJson>,
|
|
137
72
|
ctx: NodeExecutionContext<DefinedPollingTriggerConfig<TConfig, TItemJson>>,
|
|
138
73
|
): MaybePromise<NodeOutputs>;
|
|
139
|
-
/**
|
|
140
|
-
* Optional implementation for the workflow UI's "Test" button. Should return a small
|
|
141
|
-
* sample of current items without consulting or mutating polling state.
|
|
142
|
-
*/
|
|
143
74
|
testItems?(
|
|
144
75
|
ctx: TriggerTestItemsContext<DefinedPollingTriggerConfig<TConfig, TItemJson>>,
|
|
145
76
|
): MaybePromise<Items<TItemJson>>;
|
|
146
77
|
}
|
|
147
78
|
|
|
148
|
-
// ---------------------------------------------------------------------------
|
|
149
|
-
// DefinedPollingTrigger (returned object)
|
|
150
|
-
// ---------------------------------------------------------------------------
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* The object returned by `definePollingTrigger`. Register it via
|
|
154
|
-
* `definePlugin({ nodes: [myTrigger] })` or call `.register(ctx)` directly.
|
|
155
|
-
*
|
|
156
|
-
* `poll` is also directly callable for unit-testing — no runtime needed.
|
|
157
|
-
*/
|
|
158
79
|
export interface DefinedPollingTrigger<
|
|
159
80
|
TKey extends string,
|
|
160
81
|
TConfig extends CredentialJsonRecord,
|
|
@@ -166,43 +87,27 @@ export interface DefinedPollingTrigger<
|
|
|
166
87
|
readonly key: TKey;
|
|
167
88
|
readonly title: string;
|
|
168
89
|
readonly description?: string;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
*/
|
|
175
|
-
create(cfg: TConfig, name?: string, id?: string): DefinedPollingTriggerConfig<TConfig, TItemJson>;
|
|
176
|
-
/**
|
|
177
|
-
* Test seam: call `poll` directly without starting the runtime.
|
|
178
|
-
* Returns `{ items, nextState }` just like the real runtime receives.
|
|
179
|
-
*/
|
|
90
|
+
create(
|
|
91
|
+
cfg: TConfig,
|
|
92
|
+
name?: string,
|
|
93
|
+
idOrOptions?: string | NodeBaseOptions,
|
|
94
|
+
): DefinedPollingTriggerConfig<TConfig, TItemJson>;
|
|
180
95
|
poll(
|
|
181
96
|
pollCtx: Omit<DefinePollingTriggerPollContext<TConfig, TState, TBindings>, "credentials"> & {
|
|
182
97
|
credentials?: DefinedNodeCredentialAccessors<TBindings>;
|
|
183
98
|
},
|
|
184
99
|
): MaybePromise<DefinePollingTriggerPollResult<TItemJson, TState>>;
|
|
185
|
-
/** Registers the synthesised runtime class with the plugin container. */
|
|
186
100
|
register(context: { registerNode<TValue>(token: TypeToken<TValue>, implementation?: TypeToken<TValue>): void }): void;
|
|
187
101
|
}
|
|
188
102
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* TriggerNodeConfig produced by `DefinedPollingTrigger.create(...)`.
|
|
195
|
-
* Holds user configuration and credential requirements for the engine.
|
|
196
|
-
* The setup state type is opaque `JsonValue | undefined` — the runtime
|
|
197
|
-
* uses an internal wrapped shape that plugin authors never see.
|
|
198
|
-
*/
|
|
199
|
-
export class DefinedPollingTriggerConfig<TConfig extends CredentialJsonRecord, TItemJson> implements TriggerNodeConfig<
|
|
200
|
-
TItemJson,
|
|
201
|
-
JsonValue | undefined
|
|
202
|
-
> {
|
|
103
|
+
export class DefinedPollingTriggerConfig<TConfig extends CredentialJsonRecord, TItemJson>
|
|
104
|
+
implements TriggerNodeConfig<TItemJson, JsonValue | undefined>, PollingTriggerConfig
|
|
105
|
+
{
|
|
203
106
|
readonly kind = "trigger" as const;
|
|
204
107
|
readonly type: TypeToken<unknown>;
|
|
205
108
|
readonly icon: string | undefined;
|
|
109
|
+
readonly id?: string;
|
|
110
|
+
readonly description?: string;
|
|
206
111
|
|
|
207
112
|
constructor(
|
|
208
113
|
public readonly name: string,
|
|
@@ -210,29 +115,37 @@ export class DefinedPollingTriggerConfig<TConfig extends CredentialJsonRecord, T
|
|
|
210
115
|
typeToken: TypeToken<unknown>,
|
|
211
116
|
icon: string | undefined,
|
|
212
117
|
private readonly credentialRequirements: ReadonlyArray<CredentialRequirement>,
|
|
213
|
-
|
|
118
|
+
idOrOptions?: string | NodeBaseOptions,
|
|
214
119
|
private readonly inspectorSummaryFn?: (
|
|
215
120
|
args: Readonly<{ config: TConfig }>,
|
|
216
121
|
) => ReadonlyArray<NodeInspectorSummaryRow> | undefined,
|
|
122
|
+
private readonly defaultPollIntervalMs?: number,
|
|
217
123
|
) {
|
|
218
124
|
this.type = typeToken;
|
|
219
125
|
this.icon = icon;
|
|
126
|
+
const resolved = typeof idOrOptions === "string" ? { id: idOrOptions } : idOrOptions;
|
|
127
|
+
this.id = resolved?.id;
|
|
128
|
+
this.description = resolved?.description;
|
|
220
129
|
}
|
|
221
130
|
|
|
222
131
|
getCredentialRequirements(): ReadonlyArray<CredentialRequirement> {
|
|
223
132
|
return this.credentialRequirements;
|
|
224
133
|
}
|
|
225
134
|
|
|
135
|
+
getTriggerPollConfig(): Readonly<{ config: JsonObject; pollIntervalMs?: number }> {
|
|
136
|
+
const cfgPollInterval = (this.cfg as Partial<{ pollIntervalMs: number }>).pollIntervalMs;
|
|
137
|
+
const resolvedInterval = cfgPollInterval ?? this.defaultPollIntervalMs;
|
|
138
|
+
return {
|
|
139
|
+
config: this.cfg as unknown as JsonObject,
|
|
140
|
+
pollIntervalMs: resolvedInterval,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
226
144
|
inspectorSummary(): ReadonlyArray<NodeInspectorSummaryRow> | undefined {
|
|
227
145
|
return this.inspectorSummaryFn?.({ config: this.cfg });
|
|
228
146
|
}
|
|
229
147
|
}
|
|
230
148
|
|
|
231
|
-
// ---------------------------------------------------------------------------
|
|
232
|
-
// Internal wrapped state helpers
|
|
233
|
-
// ---------------------------------------------------------------------------
|
|
234
|
-
|
|
235
|
-
/** Opaque shape stored in the trigger setup state repository. @internal */
|
|
236
149
|
interface InternalWrappedState {
|
|
237
150
|
readonly userState: JsonValue | undefined;
|
|
238
151
|
readonly seenKeys: ReadonlyArray<string>;
|
|
@@ -247,32 +160,6 @@ function isWrappedState(value: unknown): value is InternalWrappedState {
|
|
|
247
160
|
);
|
|
248
161
|
}
|
|
249
162
|
|
|
250
|
-
// ---------------------------------------------------------------------------
|
|
251
|
-
// Implementation factory
|
|
252
|
-
// ---------------------------------------------------------------------------
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Declarative helper for authoring polling triggers.
|
|
256
|
-
*
|
|
257
|
-
* ```ts
|
|
258
|
-
* export const onNewMail = definePollingTrigger({
|
|
259
|
-
* key: "my-plugin.on-new-mail",
|
|
260
|
-
* title: "On new mail",
|
|
261
|
-
* configSchema: z.object({ folder: z.string() }),
|
|
262
|
-
* credentials: { auth: myOAuthCredentialType },
|
|
263
|
-
* initialState: () => ({ lastSeenId: undefined }),
|
|
264
|
-
* pollIntervalMs: 60_000,
|
|
265
|
-
* async poll({ config, state, credentials }) {
|
|
266
|
-
* const session = await credentials.auth();
|
|
267
|
-
* const messages = await fetchMessages(session, config.folder, state.lastSeenId);
|
|
268
|
-
* return {
|
|
269
|
-
* items: messages.map(m => ({ json: m, dedupKey: m.id })),
|
|
270
|
-
* nextState: { lastSeenId: messages[0]?.id ?? state.lastSeenId },
|
|
271
|
-
* };
|
|
272
|
-
* },
|
|
273
|
-
* });
|
|
274
|
-
* ```
|
|
275
|
-
*/
|
|
276
163
|
export function definePollingTrigger<
|
|
277
164
|
TKey extends string,
|
|
278
165
|
TConfig extends CredentialJsonRecord,
|
|
@@ -287,10 +174,6 @@ export function definePollingTrigger<
|
|
|
287
174
|
|
|
288
175
|
type TConfig_ = DefinedPollingTriggerConfig<TConfig, TItemJson>;
|
|
289
176
|
|
|
290
|
-
// ---------------------------------------------------------------------------
|
|
291
|
-
// Synthesised runtime class (implements TestableTriggerNode)
|
|
292
|
-
// ---------------------------------------------------------------------------
|
|
293
|
-
|
|
294
177
|
const DefinedPollingTriggerRuntime = class implements TestableTriggerNode<TConfig_> {
|
|
295
178
|
readonly kind = "trigger" as const;
|
|
296
179
|
readonly outputPorts = ["main"] as const;
|
|
@@ -300,7 +183,6 @@ export function definePollingTrigger<
|
|
|
300
183
|
const intervalMs =
|
|
301
184
|
(cfg as Partial<{ pollIntervalMs: number }>).pollIntervalMs ?? options.pollIntervalMs ?? DEFAULT_INTERVAL_MS;
|
|
302
185
|
|
|
303
|
-
// Unwrap previously persisted state, or create the initial wrapped state.
|
|
304
186
|
const persisted = ctx.previousState;
|
|
305
187
|
const existingWrapped: InternalWrappedState | undefined = isWrappedState(persisted) ? persisted : undefined;
|
|
306
188
|
const seedWrapped: InternalWrappedState = existingWrapped ?? {
|
|
@@ -326,7 +208,6 @@ export function definePollingTrigger<
|
|
|
326
208
|
credentials: credentialAccessors,
|
|
327
209
|
});
|
|
328
210
|
|
|
329
|
-
// Dedup: filter items whose dedupKey is already seen
|
|
330
211
|
const newItems: Array<{ json: TItemJson }> = [];
|
|
331
212
|
const newKeys: string[] = [];
|
|
332
213
|
for (const item of pollResult.items) {
|
|
@@ -339,7 +220,6 @@ export function definePollingTrigger<
|
|
|
339
220
|
newItems.push({ json: item.json });
|
|
340
221
|
}
|
|
341
222
|
|
|
342
|
-
// Merge keys, cap the window at 2000 to bound state size
|
|
343
223
|
const allKeys = [...wrapped.seenKeys, ...newKeys];
|
|
344
224
|
const cappedKeys = allKeys.length > 2000 ? allKeys.slice(allKeys.length - 2000) : allKeys;
|
|
345
225
|
|
|
@@ -373,11 +253,7 @@ export function definePollingTrigger<
|
|
|
373
253
|
}
|
|
374
254
|
};
|
|
375
255
|
|
|
376
|
-
persistedNode({ name: options.key })(DefinedPollingTriggerRuntime);
|
|
377
|
-
|
|
378
|
-
// ---------------------------------------------------------------------------
|
|
379
|
-
// Returned definition object
|
|
380
|
-
// ---------------------------------------------------------------------------
|
|
256
|
+
persistedNode({ name: options.key, packageName: options.packageName })(DefinedPollingTriggerRuntime);
|
|
381
257
|
|
|
382
258
|
const definition: DefinedPollingTrigger<TKey, TConfig, TItemJson, TState, TBindings> = {
|
|
383
259
|
kind: "defined-polling-trigger",
|
|
@@ -385,17 +261,22 @@ export function definePollingTrigger<
|
|
|
385
261
|
title: options.title,
|
|
386
262
|
description: options.description,
|
|
387
263
|
|
|
388
|
-
create(
|
|
264
|
+
create(
|
|
265
|
+
cfg: TConfig,
|
|
266
|
+
name = options.title,
|
|
267
|
+
idOrOptions?: string | NodeBaseOptions,
|
|
268
|
+
): DefinedPollingTriggerConfig<TConfig, TItemJson> {
|
|
389
269
|
return new DefinedPollingTriggerConfig<TConfig, TItemJson>(
|
|
390
270
|
name,
|
|
391
271
|
cfg,
|
|
392
272
|
DefinedPollingTriggerRuntime,
|
|
393
273
|
options.icon,
|
|
394
274
|
credentialRequirements,
|
|
395
|
-
|
|
275
|
+
idOrOptions,
|
|
396
276
|
options.inspectorSummary as
|
|
397
277
|
| ((args: Readonly<{ config: TConfig }>) => ReadonlyArray<NodeInspectorSummaryRow> | undefined)
|
|
398
278
|
| undefined,
|
|
279
|
+
options.pollIntervalMs,
|
|
399
280
|
);
|
|
400
281
|
},
|
|
401
282
|
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared internal helpers for defineNode and definePollingTrigger.
|
|
3
|
-
* Not part of the public API — import only from authoring helpers.
|
|
4
|
-
*/
|
|
5
1
|
import type { AnyCredentialType, CredentialRequirement, CredentialTypeId } from "../contracts/credentialTypes";
|
|
6
2
|
import type { NodeExecutionContext } from "../contracts/runtimeTypes";
|
|
7
3
|
import type { RunnableNodeConfig } from "../contracts/workflowTypes";
|
package/src/authoring/index.ts
CHANGED
|
@@ -2,19 +2,6 @@ import type { BinaryAttachment, BinaryStorage } from "../types";
|
|
|
2
2
|
import type { BinaryStorageReadResult } from "../types";
|
|
3
3
|
import { BINARY_DEFAULT_MAX_BYTES } from "../contracts/runtimeTypes";
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Reads all bytes from an already-opened binary stream into a contiguous `Uint8Array`.
|
|
7
|
-
*
|
|
8
|
-
* Safety contract:
|
|
9
|
-
* - `attachment.size` is checked against `maxBytes` *before* any allocation (no OOM).
|
|
10
|
-
* - A single buffer of exactly `attachment.size` is pre-allocated; the stream fills it
|
|
11
|
-
* directly — no chunks array, no doubling.
|
|
12
|
-
* - A byte-count mismatch between the declared size and actual stream content is an error.
|
|
13
|
-
*
|
|
14
|
-
* This is the single canonical implementation; `ExecutionBinaryService.getBytes`,
|
|
15
|
-
* `getText`, and `getJson` all delegate here. The per-package `readBinaryBody` helpers
|
|
16
|
-
* in `core-nodes` and `core-nodes-ocr` have been removed in favour of this function.
|
|
17
|
-
*/
|
|
18
5
|
export async function boundedReadBinary(
|
|
19
6
|
result: BinaryStorageReadResult,
|
|
20
7
|
attachment: BinaryAttachment,
|
|
@@ -49,7 +36,6 @@ export async function boundedReadBinary(
|
|
|
49
36
|
return out;
|
|
50
37
|
}
|
|
51
38
|
|
|
52
|
-
/** Shared implementation of `getBytes` used by both binary-service classes. */
|
|
53
39
|
export async function readBinaryAsBytes(
|
|
54
40
|
storage: BinaryStorage,
|
|
55
41
|
attachment: BinaryAttachment,
|
|
@@ -62,7 +48,6 @@ export async function readBinaryAsBytes(
|
|
|
62
48
|
return boundedReadBinary(result, attachment, maxBytes);
|
|
63
49
|
}
|
|
64
50
|
|
|
65
|
-
/** Shared implementation of `getText` used by both binary-service classes. */
|
|
66
51
|
export async function readBinaryAsText(
|
|
67
52
|
storage: BinaryStorage,
|
|
68
53
|
attachment: BinaryAttachment,
|
|
@@ -72,7 +57,6 @@ export async function readBinaryAsText(
|
|
|
72
57
|
return new TextDecoder().decode(bytes);
|
|
73
58
|
}
|
|
74
59
|
|
|
75
|
-
/** Shared implementation of `getJson` used by both binary-service classes. */
|
|
76
60
|
export async function readBinaryAsJson<T = unknown>(
|
|
77
61
|
storage: BinaryStorage,
|
|
78
62
|
attachment: BinaryAttachment,
|
package/src/bootstrap/index.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** Composition-root engine graph and advanced runtime wiring. Not part of the main `@codemation/core` barrel. */
|
|
2
1
|
export { Engine } from "../orchestration/Engine";
|
|
3
2
|
export {
|
|
4
3
|
AbortControllerFactory,
|
|
@@ -57,4 +56,11 @@ export {
|
|
|
57
56
|
WorkflowStoragePolicyEvaluator,
|
|
58
57
|
type EngineExecutionLimitsPolicyConfig,
|
|
59
58
|
} from "../policies";
|
|
60
|
-
export {
|
|
59
|
+
export {
|
|
60
|
+
MissingRuntimeParityGuard,
|
|
61
|
+
MissingRuntimeTriggerToken,
|
|
62
|
+
PersistedWorkflowTokenRegistry,
|
|
63
|
+
WorkflowParityMismatchError,
|
|
64
|
+
type MissingRuntimeNodeDetail,
|
|
65
|
+
} from "../workflowSnapshots";
|
|
66
|
+
export { WorkflowSnapshotCodec } from "../workflowSnapshots/WorkflowSnapshotCodec";
|
|
@@ -33,11 +33,6 @@ import { Engine } from "../../orchestration/Engine";
|
|
|
33
33
|
import type { EngineRuntimeRegistrationOptions } from "./EngineRuntimeRegistration.types";
|
|
34
34
|
import type { WebhookTriggerMatcherProvider } from "./EngineRuntimeRegistration.types";
|
|
35
35
|
|
|
36
|
-
/**
|
|
37
|
-
* Container-first entry: call on a host/test container **after** workflow, run, node, and credential
|
|
38
|
-
* ports are registered. The registrar owns the default inline scheduler, engine binding,
|
|
39
|
-
* and intent-surface wiring so hosts only override the seams they actually replace.
|
|
40
|
-
*/
|
|
41
36
|
export class EngineRuntimeRegistrar {
|
|
42
37
|
register(container: DependencyContainer, options?: EngineRuntimeRegistrationOptions): void {
|
|
43
38
|
this.registerSupportFactories(container);
|
|
@@ -5,42 +5,19 @@ import type { TriggerRuntimeDiagnostics } from "../../contracts/runtimeTypes";
|
|
|
5
5
|
import type { WorkflowPolicyRuntimeDefaults } from "../../contracts/workflowTypes";
|
|
6
6
|
import type { EngineExecutionLimitsPolicyConfig } from "../../policies/executionLimits/EngineExecutionLimitsPolicy";
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Creates the webhook route matcher used by {@link import("../api/Engine").Engine}.
|
|
10
|
-
* Hosts may supply logging/diagnostics; tests often use the default factory without diagnostics.
|
|
11
|
-
*/
|
|
12
8
|
export interface WebhookTriggerMatcherProvider {
|
|
13
9
|
createMatcher(container: DependencyContainer): WebhookTriggerMatcher;
|
|
14
10
|
}
|
|
15
11
|
|
|
16
|
-
/**
|
|
17
|
-
* Supplies optional trigger-runtime logging (inactive workflow skips, activation sync).
|
|
18
|
-
*/
|
|
19
12
|
export interface TriggerRuntimeDiagnosticsProvider {
|
|
20
13
|
create(container: DependencyContainer): TriggerRuntimeDiagnostics | undefined;
|
|
21
14
|
}
|
|
22
15
|
|
|
23
16
|
export interface EngineRuntimeRegistrationOptions {
|
|
24
|
-
/**
|
|
25
|
-
* Static limits merged into the factory when the policy token is first resolved.
|
|
26
|
-
* Prefer {@link resolveEngineExecutionLimits} when limits can change after registration (e.g. host `useRuntimeConfig`).
|
|
27
|
-
*/
|
|
28
17
|
engineExecutionLimits?: Partial<EngineExecutionLimitsPolicyConfig>;
|
|
29
|
-
/**
|
|
30
|
-
* Called when the limits policy is first resolved; overrides {@link engineExecutionLimits} when both are set.
|
|
31
|
-
* Use this for host wiring so `runtime.engineExecutionLimits` applied after `registerCoreInfrastructure` is honored.
|
|
32
|
-
*/
|
|
33
18
|
resolveEngineExecutionLimits?: () => Partial<EngineExecutionLimitsPolicyConfig> | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* When {@link webhookTriggerMatcherProvider} is omitted, the registrar builds
|
|
36
|
-
* {@link import("../../runtime/WorkflowRepositoryWebhookTriggerMatcher").WorkflowRepositoryWebhookTriggerMatcher}
|
|
37
|
-
* using this optional routing diagnostics surface.
|
|
38
|
-
*/
|
|
39
19
|
webhookTriggerRoutingDiagnostics?: WebhookTriggerRoutingDiagnostics;
|
|
40
|
-
/** Overrides default webhook matcher construction (e.g. host-injected loggers). */
|
|
41
20
|
webhookTriggerMatcherProvider?: WebhookTriggerMatcherProvider;
|
|
42
|
-
/** Overrides default trigger diagnostics (undefined when omitted). */
|
|
43
21
|
triggerRuntimeDiagnosticsProvider?: TriggerRuntimeDiagnosticsProvider;
|
|
44
|
-
/** Runtime retention/storage defaults used when workflows omit prune/storage policy fields. */
|
|
45
22
|
workflowPolicyRuntimeDefaults?: WorkflowPolicyRuntimeDefaults;
|
|
46
23
|
}
|
package/src/browser.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Thrown at agent bind time when mcpServers declarations cannot be resolved.
|
|
3
|
-
* Causes include: unknown server id, missing credential instance, insufficient scopes,
|
|
4
|
-
* and ambiguous shorthand binding (multiple credential instances match).
|
|
5
|
-
*/
|
|
6
1
|
export class AgentBindError extends Error {
|
|
7
2
|
constructor(message: string) {
|
|
8
3
|
super(message);
|
package/src/contracts/Clock.ts
CHANGED
|
@@ -9,24 +9,14 @@ export class CodemationTelemetryAttributeNames {
|
|
|
9
9
|
static readonly connectionInvocationId = "codemation.connection.invocation_id";
|
|
10
10
|
static readonly toolName = "codemation.tool.name";
|
|
11
11
|
static readonly traceParentRunId = "codemation.parent.run.id";
|
|
12
|
-
/** Per-item iteration that emitted this span/metric. Set on spans recorded inside a runnable per-item loop. */
|
|
13
12
|
static readonly iterationId = "codemation.iteration.id";
|
|
14
|
-
/** Item index (0-based) of the iteration. */
|
|
15
13
|
static readonly iterationIndex = "codemation.iteration.index";
|
|
16
|
-
/** Set when this span/metric was recorded under a sub-agent triggered by an outer LLM/tool call. */
|
|
17
14
|
static readonly parentInvocationId = "codemation.parent.invocation_id";
|
|
18
|
-
/** MCP server id on spans created for callTool invocations. */
|
|
19
15
|
static readonly mcpServerId = "mcp.server_id";
|
|
20
|
-
/** MCP tool name on spans created for callTool invocations. */
|
|
21
16
|
static readonly mcpToolName = "mcp.tool_name";
|
|
22
|
-
/** Terminal node-execution status (e.g. `"hitl-approved"`, `"hitl-rejected"`) on HITL outcome spans. */
|
|
23
17
|
static readonly nodeExecutionStatus = "codemation.node.execution_status";
|
|
24
|
-
/** Populated on run-halted spans; discriminates the halt reason (e.g. `"hitl-rejected"`). */
|
|
25
18
|
static readonly runHaltReason = "codemation.run.halt_reason";
|
|
26
|
-
/** Human task ID on `hitl.task.*` span events. */
|
|
27
19
|
static readonly hitlTaskId = "codemation.hitl.task_id";
|
|
28
|
-
/** HITL channel name (e.g. `"inbox"`, `"control-plane-inbox"`) on `hitl.task.*` span events. */
|
|
29
20
|
static readonly hitlChannel = "codemation.hitl.channel";
|
|
30
|
-
/** Decision outcome (e.g. `"approved"`, `"rejected"`) on `hitl.task.decided` span events. */
|
|
31
21
|
static readonly hitlDecisionStatus = "codemation.hitl.decision_status";
|
|
32
22
|
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { AgentMcpIntegration, AgentMcpToolMap } from "./agentMcpTypes";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* No-op implementation of AgentMcpIntegration.
|
|
5
|
-
* Registered by the core engine runtime as a fallback when the host does not
|
|
6
|
-
* supply a real implementation (e.g. in unit tests or headless engine setups).
|
|
7
|
-
* Always returns an empty tool map so the agent runs with node-backed tools only.
|
|
8
|
-
*/
|
|
9
3
|
export class NoOpAgentMcpIntegration implements AgentMcpIntegration {
|
|
10
4
|
async prepareMcpTools(): Promise<AgentMcpToolMap> {
|
|
11
5
|
return new Map();
|
|
@@ -11,12 +11,6 @@ import type {
|
|
|
11
11
|
} from "./telemetryTypes";
|
|
12
12
|
import { NoOpTelemetryArtifactReference } from "./NoOpTelemetryArtifactReference";
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
* Standalone no-op {@link NodeExecutionTelemetry} value used as the return for `asNodeTelemetry`.
|
|
16
|
-
*
|
|
17
|
-
* Defined here (instead of in `NoOpNodeExecutionTelemetry.ts`) so that {@link NoOpTelemetrySpanScope}
|
|
18
|
-
* can return it without importing the other module — both no-ops share this leaf.
|
|
19
|
-
*/
|
|
20
14
|
const noOpNodeExecutionTelemetry: NodeExecutionTelemetry = {
|
|
21
15
|
traceId: "00000000000000000000000000000000",
|
|
22
16
|
spanId: "0000000000000000",
|
|
@@ -53,6 +47,5 @@ const noOpTelemetrySpanScope: TelemetrySpanScope = {
|
|
|
53
47
|
|
|
54
48
|
export class NoOpTelemetrySpanScope {
|
|
55
49
|
static readonly value: TelemetrySpanScope = noOpTelemetrySpanScope;
|
|
56
|
-
/** Internal: the shared no-op {@link NodeExecutionTelemetry} that {@link NoOpNodeExecutionTelemetry} re-exposes. */
|
|
57
50
|
static readonly nodeExecutionTelemetryValue: NodeExecutionTelemetry = noOpNodeExecutionTelemetry;
|
|
58
51
|
}
|
|
@@ -15,9 +15,7 @@ export class RetryPolicy implements FixedRetryPolicySpec {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
/** Default for HTTP-style transient failures: 3 tries, 1s between attempts. */
|
|
19
18
|
static readonly defaultForHttp: FixedRetryPolicySpec = { kind: "fixed", maxAttempts: 3, delayMs: 1000 };
|
|
20
19
|
|
|
21
|
-
/** Default for LLM / agent calls: 3 tries, 2s fixed backoff. */
|
|
22
20
|
static readonly defaultForAiAgent: FixedRetryPolicySpec = { kind: "fixed", maxAttempts: 3, delayMs: 2000 };
|
|
23
21
|
}
|
|
@@ -3,44 +3,15 @@ import type { ConnectionInvocationAppendArgs, ConnectionInvocationId } from "./r
|
|
|
3
3
|
import type { TelemetrySpanEventRecord } from "./telemetryTypes";
|
|
4
4
|
import type { NodeActivationId, NodeIterationId } from "./workflowTypes";
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Emitted as a span event when a credential is missing required scopes
|
|
8
|
-
* (bind-time) or when callTool returns a permission error (runtime).
|
|
9
|
-
* The credential type id can be looked up from the credential instance when needed.
|
|
10
|
-
*/
|
|
11
6
|
export interface NeedsReconsentEvent {
|
|
12
7
|
readonly serverId: string;
|
|
13
8
|
readonly credentialInstanceId: string;
|
|
14
9
|
readonly missingScopesHint?: readonly string[];
|
|
15
10
|
}
|
|
16
11
|
|
|
17
|
-
/**
|
|
18
|
-
* An opaque MCP tool map: keyed by serverId → (toolName → tool definition).
|
|
19
|
-
* Typed as unknown so core does not depend on the AI SDK's ToolSet type.
|
|
20
|
-
* AIAgentNode (in core-nodes, which does depend on ai) casts this to
|
|
21
|
-
* ReadonlyMap<string, ToolSet> before passing to DeferredMetaToolStrategyFactory.
|
|
22
|
-
*/
|
|
23
12
|
export type AgentMcpToolMap = ReadonlyMap<string, Readonly<Record<string, unknown>>>;
|
|
24
13
|
|
|
25
|
-
/**
|
|
26
|
-
* Contract implemented by the host. Resolves MCP server bindings for an agent run
|
|
27
|
-
* via the standard credential-binding table (one slot per declared server, keyed
|
|
28
|
-
* by `(workflowId, mcpConnectionNodeId, "credential")`), and returns a ready-to-use
|
|
29
|
-
* tool map with wrapped execute callbacks for telemetry and 403 detection.
|
|
30
|
-
* Core-nodes imports this interface so AIAgentNode can inject it without
|
|
31
|
-
* depending on the host.
|
|
32
|
-
*/
|
|
33
14
|
export interface AgentMcpIntegration {
|
|
34
|
-
/**
|
|
35
|
-
* Look up the credential binding per server, validate scopes, open pool
|
|
36
|
-
* connections, and return a tool map keyed by serverId. Each tool's
|
|
37
|
-
* execute callback includes:
|
|
38
|
-
* - Telemetry child span (mcp.server_id, mcp.tool_name attributes)
|
|
39
|
-
* - 403/permission error detection → emits a NeedsReconsentEvent span event
|
|
40
|
-
*
|
|
41
|
-
* Throws `AgentBindError` on validation failures (missing server, unbound
|
|
42
|
-
* credential slot, missing credential instance, insufficient scopes).
|
|
43
|
-
*/
|
|
44
15
|
prepareMcpTools(args: {
|
|
45
16
|
readonly workflowId: WorkflowId;
|
|
46
17
|
readonly agentNodeId: NodeId;
|
|
@@ -50,15 +21,10 @@ export interface AgentMcpIntegration {
|
|
|
50
21
|
readonly startChildSpan: (args: { readonly name: string; readonly attributes?: Record<string, string> }) => {
|
|
51
22
|
readonly end: (args?: { status?: "ok" | "error"; statusMessage?: string }) => void;
|
|
52
23
|
};
|
|
53
|
-
/** Per-MCP-tool-call invocation appender. Optional; when omitted the wrapper emits only telemetry spans. */
|
|
54
24
|
readonly appendMcpInvocation?: (args: ConnectionInvocationAppendArgs) => Promise<void>;
|
|
55
|
-
/** Agent activation id to attach to each invocation record (used by canvas + inspector grouping). */
|
|
56
25
|
readonly parentAgentActivationId?: NodeActivationId;
|
|
57
|
-
/** Per-item iteration id when the agent runs inside a per-item loop. */
|
|
58
26
|
readonly iterationId?: NodeIterationId;
|
|
59
|
-
/** Item index (0-based) of the iteration that owns these tool calls. */
|
|
60
27
|
readonly itemIndex?: number;
|
|
61
|
-
/** Parent invocation id when this agent is itself executing as a sub-agent. */
|
|
62
28
|
readonly parentInvocationId?: ConnectionInvocationId;
|
|
63
29
|
}): Promise<AgentMcpToolMap>;
|
|
64
30
|
}
|