@codemation/core 0.10.2 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +183 -0
  2. package/dist/CostCatalogContract-DZgcUBE4.d.cts +19 -0
  3. package/dist/{EngineRuntimeRegistration.types-ClLuY1FG.d.ts → EngineRuntimeRegistration.types-BQbS9_gs.d.ts} +2 -2
  4. package/dist/{EngineRuntimeRegistration.types-BryWi2mA.d.cts → EngineRuntimeRegistration.types-Cggm5GVY.d.cts} +8 -2
  5. package/dist/{InMemoryRunDataFactory-DeXNJt1O.d.cts → InMemoryRunDataFactory-C7YItvHG.d.cts} +9 -19
  6. package/dist/{InMemoryRunEventBusRegistry-sM4z4n_i.js → InMemoryRunEventBusRegistry-Bwunvt1T.js} +1 -1
  7. package/dist/{InMemoryRunEventBusRegistry-sM4z4n_i.js.map → InMemoryRunEventBusRegistry-Bwunvt1T.js.map} +1 -1
  8. package/dist/{InMemoryRunEventBusRegistry-VM3OWnHo.cjs → InMemoryRunEventBusRegistry-Sa86VxuV.cjs} +1 -1
  9. package/dist/{InMemoryRunEventBusRegistry-VM3OWnHo.cjs.map → InMemoryRunEventBusRegistry-Sa86VxuV.cjs.map} +1 -1
  10. package/dist/ItemsInputNormalizer-C_dpn76M.d.cts +407 -0
  11. package/dist/ItemsInputNormalizer-CwdOhSAK.cjs +43 -0
  12. package/dist/ItemsInputNormalizer-CwdOhSAK.cjs.map +1 -0
  13. package/dist/ItemsInputNormalizer-D-MH8MBs.js +36 -0
  14. package/dist/ItemsInputNormalizer-D-MH8MBs.js.map +1 -0
  15. package/dist/ItemsInputNormalizer-_Mfcd3YU.d.ts +321 -0
  16. package/dist/RunIntentService-BVur7x9n.d.ts +285 -0
  17. package/dist/RunIntentService-CEF-sFfI.d.cts +206 -0
  18. package/dist/{RunIntentService-BqNjrksF.d.cts → agentMcpTypes-ZiNbNsEi.d.cts} +1717 -1809
  19. package/dist/bootstrap/index.cjs +4 -2
  20. package/dist/bootstrap/index.d.cts +8 -3
  21. package/dist/bootstrap/index.d.ts +6 -4
  22. package/dist/bootstrap/index.js +4 -2
  23. package/dist/{bootstrap-DtjQtuvi.cjs → bootstrap-BxuTFTLB.cjs} +41 -34
  24. package/dist/bootstrap-BxuTFTLB.cjs.map +1 -0
  25. package/dist/{bootstrap-BfFKGzyj.js → bootstrap-D_Yyi0wL.js} +9 -2
  26. package/dist/bootstrap-D_Yyi0wL.js.map +1 -0
  27. package/dist/browser.cjs +16 -0
  28. package/dist/browser.d.cts +4 -0
  29. package/dist/browser.d.ts +3 -0
  30. package/dist/browser.js +4 -0
  31. package/dist/contracts-CK0x6w_G.cjs +74 -0
  32. package/dist/contracts-CK0x6w_G.cjs.map +1 -0
  33. package/dist/contracts-DXdfTdpW.js +50 -0
  34. package/dist/contracts-DXdfTdpW.js.map +1 -0
  35. package/dist/contracts.cjs +6 -0
  36. package/dist/contracts.d.cts +5 -0
  37. package/dist/contracts.d.ts +2 -0
  38. package/dist/contracts.js +3 -0
  39. package/dist/di-0Wop7z1y.js +376 -0
  40. package/dist/di-0Wop7z1y.js.map +1 -0
  41. package/dist/di-BlEKdoZS.cjs +489 -0
  42. package/dist/di-BlEKdoZS.cjs.map +1 -0
  43. package/dist/executionPersistenceContracts-BgZMRsTa.d.cts +275 -0
  44. package/dist/{index-CJQtTY_M.d.ts → index-62Ba9f7D.d.ts} +114 -320
  45. package/dist/{RunIntentService-CI-F8qQ7.d.ts → index-zWGtEhrf.d.ts} +1811 -1914
  46. package/dist/index.cjs +76 -71
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.cts +112 -656
  49. package/dist/index.d.ts +5 -3
  50. package/dist/index.js +52 -50
  51. package/dist/index.js.map +1 -1
  52. package/dist/params-B5SENSzZ.d.cts +44 -0
  53. package/dist/{runtime-_ywksLa6.cjs → runtime-DBzq5YBi.cjs} +125 -489
  54. package/dist/runtime-DBzq5YBi.cjs.map +1 -0
  55. package/dist/{runtime-DbMjpb5d.js → runtime-cxmUkk0l.js} +117 -369
  56. package/dist/runtime-cxmUkk0l.js.map +1 -0
  57. package/dist/testing.cjs +23 -21
  58. package/dist/testing.cjs.map +1 -1
  59. package/dist/testing.d.cts +4 -3
  60. package/dist/testing.d.ts +3 -2
  61. package/dist/testing.js +5 -3
  62. package/dist/testing.js.map +1 -1
  63. package/package.json +12 -17
  64. package/src/ai/AgentConnectionNodeCollector.ts +47 -5
  65. package/src/authoring/defineNode.types.ts +21 -1
  66. package/src/authoring/definePollingTrigger.types.ts +20 -0
  67. package/src/binaries/UnavailableBinaryStorage.ts +6 -0
  68. package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +9 -0
  69. package/src/browser.ts +1 -0
  70. package/src/contracts/AgentBindError.ts +11 -0
  71. package/src/contracts/CodemationTelemetryAttributeNames.ts +4 -0
  72. package/src/contracts/NoOpAgentMcpIntegration.ts +13 -0
  73. package/src/contracts/agentMcpTypes.ts +64 -0
  74. package/src/contracts/index.ts +4 -0
  75. package/src/contracts/mcpTypes.ts +29 -0
  76. package/src/contracts/runTypes.ts +8 -0
  77. package/src/contracts/runtimeTypes.ts +4 -0
  78. package/src/contracts/workflowTypes.ts +21 -0
  79. package/src/contracts.ts +3 -0
  80. package/src/credentials/OAuthFlowExecutor.types.ts +45 -0
  81. package/src/di/CoreTokens.ts +7 -0
  82. package/src/execution/InProcessRetryRunner.ts +31 -5
  83. package/src/execution/NodeExecutor.ts +27 -7
  84. package/src/execution/NodeRunStateWriter.ts +2 -0
  85. package/src/index.ts +10 -0
  86. package/src/orchestration/RunContinuationService.ts +6 -2
  87. package/src/runStorage/InMemoryBinaryStorageRegistry.ts +10 -0
  88. package/src/scheduler/InlineDrivingScheduler.ts +26 -22
  89. package/src/types/index.ts +1 -0
  90. package/src/validation/WorkflowEdgePortError.types.ts +16 -0
  91. package/src/validation/WorkflowEdgePortValidator.ts +52 -0
  92. package/src/workflow/definition/ConnectionInvocationIdFactory.ts +4 -3
  93. package/src/workflow/definition/ConnectionNodeIdFactory.ts +25 -0
  94. package/src/workflow/definition/NodeIterationIdFactory.ts +5 -3
  95. package/src/workflowSnapshots/WorkflowSnapshotCodec.ts +42 -10
  96. package/tsdown.config.ts +1 -1
  97. package/dist/bootstrap-BfFKGzyj.js.map +0 -1
  98. package/dist/bootstrap-DtjQtuvi.cjs.map +0 -1
  99. package/dist/runtime-DbMjpb5d.js.map +0 -1
  100. package/dist/runtime-_ywksLa6.cjs.map +0 -1
@@ -0,0 +1,407 @@
1
+ import { At as NodeConfigBase, Bt as NodeOutputs, Dt as JsonValue, Fi as NodeConnectionName, Ii as NodeId, Jn as NodeExecutionContext, K as TypeToken, St as Items, Vr as TelemetrySpanScope, Xt as RunnableNodeConfig, Zt as RunnableNodeInputJson, a as ConnectionInvocationId, bi as CredentialRequirement, bt as Item, y as PersistedRunState } from "./agentMcpTypes-ZiNbNsEi.cjs";
2
+ import { t as Expr } from "./params-B5SENSzZ.cjs";
3
+ import { ZodType, input, output } from "zod";
4
+
5
+ //#region src/contracts/mcpTypes.d.ts
6
+ type McpServerTransport = "http";
7
+ interface McpServerDeclaration {
8
+ /** Globally unique slug, e.g. "gmail". Workflow authors reference this. */
9
+ id: string;
10
+ displayName: string;
11
+ description: string;
12
+ transport: McpServerTransport;
13
+ url: string;
14
+ /**
15
+ * Credential types accepted by this MCP server, matching CredentialRequirement.acceptedTypes.
16
+ * Absent or empty means no credential is required.
17
+ */
18
+ acceptedCredentialTypes?: ReadonlyArray<string>;
19
+ /**
20
+ * Documentation only in MVP. The bind-time validator checks
21
+ * requiredScopes ⊆ CredentialInstance.scopesGranted.
22
+ */
23
+ requiredScopes?: string[];
24
+ /** Non-secret static headers merged onto every MCP request. */
25
+ staticHeaders?: Record<string, string>;
26
+ /**
27
+ * Overrides for tool descriptions advertised by the MCP server.
28
+ * Applied by the connection pool after tools/list.
29
+ * Key: exact tool name as returned by the server.
30
+ */
31
+ toolDescriptionOverrides?: Record<string, string>;
32
+ }
33
+ //#endregion
34
+ //#region src/contracts/runFinishedAtFactory.d.ts
35
+ type RunFinishedAtSource = Pick<PersistedRunState, "status" | "nodeSnapshotsByNodeId" | "finishedAt">;
36
+ /** Derives workflow end time from persisted run root or node snapshots for run listings. */
37
+ declare class RunFinishedAtFactory {
38
+ static resolveIso(state: RunFinishedAtSource): string | undefined;
39
+ }
40
+ //#endregion
41
+ //#region src/workflow/definition/ConnectionNodeIdFactory.d.ts
42
+ /**
43
+ * Deterministic ids for workflow connection-owned child nodes (LLM slot, tools, etc.).
44
+ * These are stable across loads.
45
+ */
46
+ declare class ConnectionNodeIdFactory {
47
+ static readonly connectionSegment: "__conn__";
48
+ static languageModelConnectionNodeId(parentNodeId: NodeId): NodeId;
49
+ static toolConnectionNodeId(parentNodeId: NodeId, toolName: string): NodeId;
50
+ static mcpConnectionNodeId(parentNodeId: NodeId, serverId: string): NodeId;
51
+ static isMcpConnectionNodeId(nodeId: NodeId): boolean;
52
+ static parseMcpConnectionNodeId(nodeId: NodeId): Readonly<{
53
+ parentNodeId: NodeId;
54
+ serverId: string;
55
+ }> | undefined;
56
+ static isLanguageModelConnectionNodeId(nodeId: NodeId): boolean;
57
+ static isToolConnectionNodeId(nodeId: NodeId): boolean;
58
+ static parseLanguageModelConnectionNodeId(nodeId: NodeId): Readonly<{
59
+ parentNodeId: NodeId;
60
+ }> | undefined;
61
+ static parseToolConnectionNodeId(nodeId: NodeId): Readonly<{
62
+ parentNodeId: NodeId;
63
+ normalizedToolName: string;
64
+ }> | undefined;
65
+ /** True when `nodeId` is a connection-owned child of `parentNodeId` (LLM or tool slot). */
66
+ static isConnectionOwnedDescendantOf(parentNodeId: NodeId, nodeId: NodeId): boolean;
67
+ /** Normalizes a tool display name to a stable id segment. */
68
+ static normalizeToolName(toolName: string): string;
69
+ }
70
+ //#endregion
71
+ //#region src/workflow/definition/NodeIterationIdFactory.d.ts
72
+ /**
73
+ * Unique ids for one per-item iteration of a runnable node's execute loop.
74
+ *
75
+ * Activations are per-batch (one scheduled execution of a node, possibly with N items).
76
+ * Iterations refine that to one identifier per item-index inside the batch loop, so per-item
77
+ * connection invocations and telemetry can be grouped without time-window heuristics.
78
+ *
79
+ * Uses Web Crypto's `randomUUID` (Node 19+ and all modern browsers) so this module is safe
80
+ * to include in the browser entry. Importing `node:crypto` here previously leaked into the
81
+ * canvas client bundle through `browser.ts` and OOM'd consumers' Turbopack builds.
82
+ */
83
+ declare class NodeIterationIdFactory {
84
+ static create(): string;
85
+ /** Deterministic id for tests when a stable sequence is needed. */
86
+ static createForTest(seed: string, sequence: number): string;
87
+ /** Deterministic id derived from a connection node id (for sub-agent / tool-call scopes). */
88
+ static createForConnection(connectionNodeId: NodeId, sequence: number): string;
89
+ }
90
+ //#endregion
91
+ //#region src/ai/NodeBackedToolConfig.d.ts
92
+ declare class NodeBackedToolConfig<TNodeConfig extends RunnableNodeConfig<any, any>, TInputSchema extends ZodSchemaAny, TOutputSchema extends ZodSchemaAny> implements ToolConfig {
93
+ readonly name: string;
94
+ readonly node: TNodeConfig;
95
+ readonly type: TypeToken<unknown>;
96
+ readonly toolKind: "nodeBacked";
97
+ readonly description?: string;
98
+ readonly presentation?: AgentCanvasPresentation;
99
+ private readonly inputSchemaValue;
100
+ private readonly outputSchemaValue;
101
+ private readonly mapInputValue?;
102
+ private readonly mapOutputValue?;
103
+ constructor(name: string, node: TNodeConfig, options: NodeBackedToolConfigOptions<TNodeConfig, TInputSchema, TOutputSchema>);
104
+ getCredentialRequirements(): ReadonlyArray<CredentialRequirement>;
105
+ getInputSchema(): TInputSchema;
106
+ getOutputSchema(): TOutputSchema;
107
+ toNodeItem(args: NodeBackedToolInputMapperArgs<TNodeConfig, input<TInputSchema>>): Item<RunnableNodeInputJson<TNodeConfig>>;
108
+ toToolOutput(args: NodeBackedToolOutputMapperArgs<TNodeConfig, input<TInputSchema>>): output<TOutputSchema>;
109
+ private readDefaultToolOutput;
110
+ private isItem;
111
+ }
112
+ //#endregion
113
+ //#region src/ai/CallableToolConfig.d.ts
114
+ type CallableToolExecuteHandler<TInputSchema extends ZodSchemaAny, TOutputSchema extends ZodSchemaAny> = (args: ToolExecuteArgs<CallableToolConfig<TInputSchema, TOutputSchema>, input<TInputSchema>>) => Promise<output<TOutputSchema>> | output<TOutputSchema>;
115
+ type CallableToolConfigOptions<TInputSchema extends ZodSchemaAny, TOutputSchema extends ZodSchemaAny> = Readonly<{
116
+ name: string;
117
+ description?: string;
118
+ presentation?: AgentCanvasPresentation;
119
+ inputSchema: TInputSchema;
120
+ outputSchema: TOutputSchema;
121
+ /**
122
+ * Optional credential slots for this tool (same contract as other {@link ToolConfig} shapes).
123
+ */
124
+ credentialRequirements?: ReadonlyArray<CredentialRequirement>;
125
+ execute: CallableToolExecuteHandler<TInputSchema, TOutputSchema>;
126
+ }>;
127
+ /**
128
+ * Inline callable agent tool: DSL sugar over {@link ToolConfig} without a separate {@link NodeResolver}-registered {@link Tool} class.
129
+ */
130
+ declare class CallableToolConfig<TInputSchema extends ZodSchemaAny, TOutputSchema extends ZodSchemaAny> implements ToolConfig {
131
+ readonly name: string;
132
+ readonly type: TypeToken<unknown>;
133
+ readonly toolKind: "callable";
134
+ readonly description?: string;
135
+ readonly presentation?: AgentCanvasPresentation;
136
+ private readonly inputSchemaValue;
137
+ private readonly outputSchemaValue;
138
+ private readonly credentialRequirementsValue?;
139
+ private readonly executeHandler;
140
+ constructor(name: string, options: CallableToolConfigOptions<TInputSchema, TOutputSchema>);
141
+ getCredentialRequirements(): ReadonlyArray<CredentialRequirement>;
142
+ getInputSchema(): TInputSchema;
143
+ getOutputSchema(): TOutputSchema;
144
+ /**
145
+ * Parses tool input and output with the configured Zod schemas.
146
+ */
147
+ executeTool(args: ToolExecuteArgs<CallableToolConfig<TInputSchema, TOutputSchema>, input<TInputSchema>>): Promise<output<TOutputSchema>>;
148
+ private parseInput;
149
+ private parseOutput;
150
+ private decorateValidationError;
151
+ }
152
+ //#endregion
153
+ //#region src/ai/CallableToolFactory.d.ts
154
+ declare class CallableToolFactoryImpl {
155
+ callableTool<TInputSchema extends ZodSchemaAny, TOutputSchema extends ZodSchemaAny>(options: CallableToolConfigOptions<TInputSchema, TOutputSchema>): CallableToolConfig<TInputSchema, TOutputSchema>;
156
+ }
157
+ declare const CallableToolFactory: CallableToolFactoryImpl;
158
+ //#endregion
159
+ //#region src/ai/CallableToolKindToken.d.ts
160
+ /**
161
+ * Shared {@link import("../di").TypeToken} marker for {@link CallableToolConfig}.
162
+ * Callable tools are not registered in {@link NodeResolver}; this class only satisfies {@link ToolConfig#type}.
163
+ */
164
+ declare class CallableToolKindToken {}
165
+ //#endregion
166
+ //#region src/ai/AgentToolFactory.d.ts
167
+ declare class AgentToolFactoryImpl {
168
+ asTool<TNodeConfig extends RunnableNodeConfig<any, any>, TInputSchema extends ZodSchemaAny, TOutputSchema extends ZodSchemaAny>(node: TNodeConfig, options: Readonly<{
169
+ name?: string;
170
+ } & NodeBackedToolConfigOptions<TNodeConfig, TInputSchema, TOutputSchema>>): NodeBackedToolConfig<TNodeConfig, TInputSchema, TOutputSchema>;
171
+ private withDefaultAgentInputMapper;
172
+ private mergeAgentToolInputWithCurrentItem;
173
+ private isMergeableRecord;
174
+ }
175
+ declare const AgentToolFactory: AgentToolFactoryImpl;
176
+ //#endregion
177
+ //#region src/ai/AgentMessageConfigNormalizerFactory.d.ts
178
+ declare class AgentMessageConfigNormalizer {
179
+ /**
180
+ * Prefer {@code input.messages} when present (ItemNode / engine-mapped payloads); otherwise resolve from
181
+ * {@link AgentNodeConfig.messages} templates.
182
+ */
183
+ static resolveFromInputOrConfig<TInputJson, TOutputJson>(input: unknown, config: AgentNodeConfig<TInputJson, TOutputJson>, args: AgentMessageBuildArgs<TInputJson>): ReadonlyArray<AgentMessageDto>;
184
+ static normalize<TInputJson, TOutputJson>(config: AgentNodeConfig<TInputJson, TOutputJson>, args: AgentMessageBuildArgs<TInputJson>): ReadonlyArray<AgentMessageDto>;
185
+ private static tryMessagesFromStructuredInput;
186
+ private static normalizeRichMessages;
187
+ private static lineToDto;
188
+ }
189
+ //#endregion
190
+ //#region src/ai/AgentConfigInspectorFactory.d.ts
191
+ declare class AgentConfigInspector {
192
+ static isAgentNodeConfig(config: NodeConfigBase | undefined): config is AgentNodeConfig<any, any>;
193
+ private static hasCompatibleMessageConfiguration;
194
+ }
195
+ //#endregion
196
+ //#region src/ai/AiHost.d.ts
197
+ interface AgentCanvasPresentation<TIcon extends string = string> {
198
+ readonly label?: string;
199
+ readonly icon?: TIcon;
200
+ }
201
+ type ZodSchemaAny = ZodType<any, any, any>;
202
+ interface ToolConfig {
203
+ readonly type: TypeToken<unknown>;
204
+ readonly name: string;
205
+ readonly description?: string;
206
+ readonly presentation?: AgentCanvasPresentation;
207
+ getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;
208
+ }
209
+ type ToolExecuteArgs<TConfig extends ToolConfig = ToolConfig, TInput = unknown> = Readonly<{
210
+ config: TConfig;
211
+ input: TInput;
212
+ ctx: NodeExecutionContext<any>;
213
+ item: Item;
214
+ itemIndex: number;
215
+ items: Items;
216
+ /**
217
+ * Optional sub-agent boundary hooks: when present, the live `agent.tool.call` span and the
218
+ * planned tool-call invocationId are forwarded so node-backed runtimes can re-root their child
219
+ * execution scope. Plain function tools may safely ignore these hooks.
220
+ */
221
+ hooks?: Readonly<{
222
+ parentSpan?: TelemetrySpanScope;
223
+ parentInvocationId?: ConnectionInvocationId;
224
+ }>;
225
+ }>;
226
+ interface Tool<TConfig extends ToolConfig = ToolConfig, TInputSchema extends ZodSchemaAny = ZodSchemaAny, TOutputSchema extends ZodSchemaAny = ZodSchemaAny> {
227
+ readonly defaultDescription: string;
228
+ readonly inputSchema: TInputSchema;
229
+ readonly outputSchema: TOutputSchema;
230
+ execute(args: ToolExecuteArgs<TConfig, input<TInputSchema>>): Promise<output<TOutputSchema>> | output<TOutputSchema>;
231
+ }
232
+ type AgentTool<TInputSchema extends ZodSchemaAny = ZodSchemaAny, TOutputSchema extends ZodSchemaAny = ZodSchemaAny> = Tool<ToolConfig, TInputSchema, TOutputSchema>;
233
+ type AgentToolExecuteArgs<TInput = unknown> = ToolExecuteArgs<ToolConfig, TInput>;
234
+ type AgentToolToken = TypeToken<Tool<ToolConfig, ZodSchemaAny, ZodSchemaAny>>;
235
+ type AgentMessageRole = "system" | "user" | "assistant";
236
+ type AgentMessageBuildArgs<TInputJson = unknown> = Readonly<{
237
+ item: Item<TInputJson>;
238
+ itemIndex: number;
239
+ items: Items<TInputJson>;
240
+ ctx: NodeExecutionContext<any>;
241
+ }>;
242
+ interface AgentMessageDto {
243
+ readonly role: AgentMessageRole;
244
+ readonly content: string;
245
+ }
246
+ type AgentMessageTemplateContent<TInputJson = unknown> = string | ((args: AgentMessageBuildArgs<TInputJson>) => string);
247
+ interface AgentMessageTemplate<TInputJson = unknown> {
248
+ readonly role: AgentMessageRole;
249
+ readonly content: AgentMessageTemplateContent<TInputJson>;
250
+ }
251
+ /** A single prompt line: fixed DTO or template with optional function `content`. */
252
+ type AgentMessageLine<TInputJson = unknown> = AgentMessageDto | AgentMessageTemplate<TInputJson>;
253
+ /**
254
+ * Message list for an agent. Prefer a **plain array** of `{ role, content }` (optionally with function `content` for templates).
255
+ * Use the object form only when you need `buildMessages` to append messages after optional `prompt` lines.
256
+ */
257
+ type AgentMessageConfig<TInputJson = unknown> = Expr<ReadonlyArray<AgentMessageLine<TInputJson>>, TInputJson> | ReadonlyArray<AgentMessageLine<TInputJson>> | {
258
+ readonly prompt?: ReadonlyArray<AgentMessageLine<TInputJson>>;
259
+ readonly buildMessages?: (args: AgentMessageBuildArgs<TInputJson>) => ReadonlyArray<AgentMessageDto>;
260
+ };
261
+ type AgentTurnLimitBehavior = "error" | "respondWithLastMessage";
262
+ interface AgentModelInvocationOptions {
263
+ readonly maxTokens?: number;
264
+ readonly providerOptions?: Readonly<Record<string, JsonValue>>;
265
+ }
266
+ interface AgentGuardrailConfig {
267
+ readonly maxTurns?: number;
268
+ readonly onTurnLimitReached?: AgentTurnLimitBehavior;
269
+ readonly modelInvocationOptions?: AgentModelInvocationOptions;
270
+ }
271
+ /** Defaults aligned with common tool-agent iteration limits (many products use ~10 max rounds). */
272
+ declare const AgentGuardrailDefaults: {
273
+ readonly maxTurns: 10;
274
+ readonly onTurnLimitReached: AgentTurnLimitBehavior;
275
+ };
276
+ interface AgentToolDefinition {
277
+ readonly name: string;
278
+ readonly description: string;
279
+ readonly inputSchema: ZodSchemaAny;
280
+ }
281
+ type AgentToolCall = Readonly<{
282
+ id?: string;
283
+ name: string;
284
+ input: unknown;
285
+ }>;
286
+ type AgentToolCallPlanner<_TNodeConfig = unknown> = (item: Item, index: number, items: Items, ctx: NodeExecutionContext<any>) => ReadonlyArray<AgentToolCall>;
287
+ interface ChatModelConfig {
288
+ readonly type: TypeToken<ChatModelFactory<ChatModelConfig>>;
289
+ readonly name: string;
290
+ readonly provider?: string;
291
+ readonly modelName?: string;
292
+ readonly presentation?: AgentCanvasPresentation;
293
+ getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;
294
+ }
295
+ /**
296
+ * Provider-neutral chat language model wrapper returned by a {@link ChatModelFactory}.
297
+ *
298
+ * Thin adapter around an AI SDK `LanguageModelV2` (from `@ai-sdk/provider`) plus the call-site
299
+ * defaults Codemation needs at every generate/stream: the provider label, the model name used for
300
+ * pricing / telemetry, and the default invocation options (max output tokens, temperature,
301
+ * provider-specific overrides).
302
+ *
303
+ * The consumer (AIAgentNode / AgentStructuredOutputRunner) passes `languageModel` directly into
304
+ * `generateText({ model, ... })` from the `ai` package.
305
+ */
306
+ interface ChatLanguageModel {
307
+ /** AI SDK `LanguageModelV2` instance (kept `unknown` to avoid leaking the SDK type into `@codemation/core`). */
308
+ readonly languageModel: unknown;
309
+ /** Stable pricing/telemetry key — e.g. `"gpt-4.1-nano"`. */
310
+ readonly modelName: string;
311
+ /** Provider label — e.g. `"openai"`. Used for cost tracking. */
312
+ readonly provider?: string;
313
+ /** Defaults merged into every call. Consumers may override per-invocation. */
314
+ readonly defaultCallOptions?: ChatLanguageModelCallOptions;
315
+ }
316
+ interface ChatLanguageModelCallOptions {
317
+ readonly maxOutputTokens?: number;
318
+ readonly temperature?: number;
319
+ readonly providerOptions?: Readonly<Record<string, Readonly<Record<string, JsonValue>>>>;
320
+ }
321
+ /**
322
+ * Options for a structured-output generate call. Mirrors
323
+ * `generateText({ output: Output.object(...) })` from the `ai` package.
324
+ */
325
+ interface StructuredOutputOptions {
326
+ /** Optional schema name — used by some providers as the JSON schema name attribute. */
327
+ readonly schemaName?: string;
328
+ /** When `true`, the consumer should pass a strict-mode-compatible JSON Schema record. */
329
+ readonly strict?: boolean;
330
+ }
331
+ interface ChatModelFactory<TConfig extends ChatModelConfig = ChatModelConfig> {
332
+ create(args: Readonly<{
333
+ config: TConfig;
334
+ ctx: NodeExecutionContext<any>;
335
+ }>): Promise<ChatLanguageModel> | ChatLanguageModel;
336
+ }
337
+ type NodeBackedToolInputMapperArgs<TNodeConfig extends RunnableNodeConfig<any, any>, TToolInput = unknown> = Readonly<{
338
+ input: TToolInput;
339
+ item: Item;
340
+ itemIndex: number;
341
+ items: Items;
342
+ ctx: NodeExecutionContext<any>;
343
+ node: TNodeConfig;
344
+ }>;
345
+ type NodeBackedToolOutputMapperArgs<TNodeConfig extends RunnableNodeConfig<any, any>, TToolInput = unknown> = Readonly<{
346
+ input: TToolInput;
347
+ item: Item;
348
+ itemIndex: number;
349
+ items: Items;
350
+ ctx: NodeExecutionContext<any>;
351
+ node: TNodeConfig;
352
+ outputs: NodeOutputs;
353
+ }>;
354
+ type NodeBackedToolInputMapper<TNodeConfig extends RunnableNodeConfig<any, any>, TToolInput = unknown> = (args: NodeBackedToolInputMapperArgs<TNodeConfig, TToolInput>) => Item<RunnableNodeInputJson<TNodeConfig>> | RunnableNodeInputJson<TNodeConfig>;
355
+ type NodeBackedToolOutputMapper<TNodeConfig extends RunnableNodeConfig<any, any>, TToolInput = unknown, TToolOutput = unknown> = (args: NodeBackedToolOutputMapperArgs<TNodeConfig, TToolInput>) => TToolOutput;
356
+ type NodeBackedToolConfigOptions<TNodeConfig extends RunnableNodeConfig<any, any>, TInputSchema extends ZodSchemaAny, TOutputSchema extends ZodSchemaAny> = Readonly<{
357
+ description?: string;
358
+ presentation?: AgentCanvasPresentation;
359
+ inputSchema: TInputSchema;
360
+ outputSchema: TOutputSchema;
361
+ mapInput?: NodeBackedToolInputMapper<TNodeConfig, input<TInputSchema>>;
362
+ mapOutput?: NodeBackedToolOutputMapper<TNodeConfig, input<TInputSchema>, output<TOutputSchema>>;
363
+ }>;
364
+ interface AgentNodeConfig<TInputJson = unknown, TOutputJson = unknown> extends RunnableNodeConfig<TInputJson, TOutputJson> {
365
+ readonly messages: AgentMessageConfig<TInputJson>;
366
+ readonly chatModel: ChatModelConfig;
367
+ readonly tools?: ReadonlyArray<ToolConfig>;
368
+ readonly guardrails?: AgentGuardrailConfig;
369
+ readonly outputSchema?: ZodType<TOutputJson>;
370
+ }
371
+ type AgentAttachmentRole = "languageModel" | "tool" | "nestedAgent";
372
+ //#endregion
373
+ //#region src/ai/AgentConnectionNodeCollector.d.ts
374
+ type AgentConnectionNodeRole = "languageModel" | "tool" | "nestedAgent";
375
+ type AgentConnectionCredentialSource = Readonly<{
376
+ getCredentialRequirements?(): ReadonlyArray<CredentialRequirement>;
377
+ }>;
378
+ type AgentConnectionNodeDescriptor = Readonly<{
379
+ nodeId: NodeId;
380
+ parentNodeId: NodeId;
381
+ connectionName: NodeConnectionName;
382
+ role: AgentConnectionNodeRole;
383
+ name: string;
384
+ typeName: string;
385
+ icon?: string;
386
+ credentialSource: AgentConnectionCredentialSource;
387
+ }>;
388
+ type McpServerResolver = (id: string) => McpServerDeclaration | undefined;
389
+ type AgentConnectionNodeCollectorApi = Readonly<{
390
+ collect(parentNodeId: NodeId, agentConfig: AgentNodeConfig<any, any>, mcpServerResolver?: McpServerResolver): ReadonlyArray<AgentConnectionNodeDescriptor>;
391
+ }>;
392
+ declare const AgentConnectionNodeCollector: AgentConnectionNodeCollectorApi;
393
+ //#endregion
394
+ //#region src/serialization/ItemsInputNormalizer.d.ts
395
+ /**
396
+ * Normalizes external inputs into the engine's canonical `Items` shape.
397
+ * Used at host and builder boundaries where callers may provide either a raw value,
398
+ * a single item-like object, or an array of item-like values.
399
+ */
400
+ declare class ItemsInputNormalizer {
401
+ normalize(raw: unknown): Items;
402
+ private normalizeItem;
403
+ private isItem;
404
+ }
405
+ //#endregion
406
+ export { McpServerDeclaration as $, ChatModelFactory as A, ZodSchemaAny as B, AgentToolDefinition as C, ChatLanguageModel as D, AgentTurnLimitBehavior as E, NodeBackedToolOutputMapperArgs as F, CallableToolFactory as G, AgentMessageConfigNormalizer as H, StructuredOutputOptions as I, CallableToolExecuteHandler as J, CallableToolConfig as K, Tool as L, NodeBackedToolInputMapper as M, NodeBackedToolInputMapperArgs as N, ChatLanguageModelCallOptions as O, NodeBackedToolOutputMapper as P, RunFinishedAtFactory as Q, ToolConfig as R, AgentToolCallPlanner as S, AgentToolToken as T, AgentToolFactory as U, AgentConfigInspector as V, CallableToolKindToken as W, NodeIterationIdFactory as X, NodeBackedToolConfig as Y, ConnectionNodeIdFactory as Z, AgentMessageTemplateContent as _, AgentConnectionNodeRole as a, AgentTool as b, AgentCanvasPresentation as c, AgentMessageBuildArgs as d, McpServerTransport as et, AgentMessageConfig as f, AgentMessageTemplate as g, AgentMessageRole as h, AgentConnectionNodeDescriptor as i, NodeBackedToolConfigOptions as j, ChatModelConfig as k, AgentGuardrailConfig as l, AgentMessageLine as m, AgentConnectionCredentialSource as n, McpServerResolver as o, AgentMessageDto as p, CallableToolConfigOptions as q, AgentConnectionNodeCollector as r, AgentAttachmentRole as s, ItemsInputNormalizer as t, AgentGuardrailDefaults as u, AgentModelInvocationOptions as v, AgentToolExecuteArgs as w, AgentToolCall as x, AgentNodeConfig as y, ToolExecuteArgs as z };
407
+ //# sourceMappingURL=ItemsInputNormalizer-C_dpn76M.d.cts.map
@@ -0,0 +1,43 @@
1
+ const require_di = require('./di-BlEKdoZS.cjs');
2
+ let tsyringe = require("tsyringe");
3
+ tsyringe = require_di.__toESM(tsyringe);
4
+
5
+ //#region \0@oxc-project+runtime@0.95.0/helpers/decorate.js
6
+ function __decorate(decorators, target, key, desc) {
7
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
11
+ }
12
+
13
+ //#endregion
14
+ //#region src/serialization/ItemsInputNormalizer.ts
15
+ let ItemsInputNormalizer = class ItemsInputNormalizer$1 {
16
+ normalize(raw) {
17
+ if (raw === void 0 || raw === null) return [];
18
+ if (Array.isArray(raw)) return raw.map((value) => this.normalizeItem(value));
19
+ return [this.normalizeItem(raw)];
20
+ }
21
+ normalizeItem(raw) {
22
+ if (!this.isItem(raw)) return { json: raw };
23
+ return {
24
+ json: raw.json,
25
+ ...raw.binary === void 0 ? {} : { binary: raw.binary },
26
+ ...raw.meta === void 0 ? {} : { meta: raw.meta },
27
+ ...raw.paired === void 0 ? {} : { paired: raw.paired }
28
+ };
29
+ }
30
+ isItem(raw) {
31
+ return typeof raw === "object" && raw !== null && Object.prototype.hasOwnProperty.call(raw, "json");
32
+ }
33
+ };
34
+ ItemsInputNormalizer = __decorate([(0, tsyringe.injectable)()], ItemsInputNormalizer);
35
+
36
+ //#endregion
37
+ Object.defineProperty(exports, 'ItemsInputNormalizer', {
38
+ enumerable: true,
39
+ get: function () {
40
+ return ItemsInputNormalizer;
41
+ }
42
+ });
43
+ //# sourceMappingURL=ItemsInputNormalizer-CwdOhSAK.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ItemsInputNormalizer-CwdOhSAK.cjs","names":["ItemsInputNormalizer"],"sources":["../src/serialization/ItemsInputNormalizer.ts"],"sourcesContent":["import type { Item, Items } from \"../contracts/workflowTypes\";\nimport { injectable } from \"../di\";\n\n/**\n * Normalizes external inputs into the engine's canonical `Items` shape.\n * Used at host and builder boundaries where callers may provide either a raw value,\n * a single item-like object, or an array of item-like values.\n */\n@injectable()\nexport class ItemsInputNormalizer {\n normalize(raw: unknown): Items {\n if (raw === undefined || raw === null) {\n return [];\n }\n if (Array.isArray(raw)) {\n return raw.map((value) => this.normalizeItem(value));\n }\n return [this.normalizeItem(raw)];\n }\n\n private normalizeItem(raw: unknown): Item {\n if (!this.isItem(raw)) {\n return { json: raw };\n }\n return {\n json: raw.json,\n ...(raw.binary === undefined ? {} : { binary: raw.binary }),\n ...(raw.meta === undefined ? {} : { meta: raw.meta }),\n ...(raw.paired === undefined ? {} : { paired: raw.paired }),\n };\n }\n\n private isItem(raw: unknown): raw is Item {\n return typeof raw === \"object\" && raw !== null && Object.prototype.hasOwnProperty.call(raw, \"json\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AASO,iCAAMA,uBAAqB;CAChC,UAAU,KAAqB;AAC7B,MAAI,QAAQ,UAAa,QAAQ,KAC/B,QAAO,EAAE;AAEX,MAAI,MAAM,QAAQ,IAAI,CACpB,QAAO,IAAI,KAAK,UAAU,KAAK,cAAc,MAAM,CAAC;AAEtD,SAAO,CAAC,KAAK,cAAc,IAAI,CAAC;;CAGlC,AAAQ,cAAc,KAAoB;AACxC,MAAI,CAAC,KAAK,OAAO,IAAI,CACnB,QAAO,EAAE,MAAM,KAAK;AAEtB,SAAO;GACL,MAAM,IAAI;GACV,GAAI,IAAI,WAAW,SAAY,EAAE,GAAG,EAAE,QAAQ,IAAI,QAAQ;GAC1D,GAAI,IAAI,SAAS,SAAY,EAAE,GAAG,EAAE,MAAM,IAAI,MAAM;GACpD,GAAI,IAAI,WAAW,SAAY,EAAE,GAAG,EAAE,QAAQ,IAAI,QAAQ;GAC3D;;CAGH,AAAQ,OAAO,KAA2B;AACxC,SAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,OAAO,UAAU,eAAe,KAAK,KAAK,OAAO;;;6DAzB1F"}
@@ -0,0 +1,36 @@
1
+ import { a as injectable } from "./di-0Wop7z1y.js";
2
+
3
+ //#region \0@oxc-project+runtime@0.95.0/helpers/decorate.js
4
+ function __decorate(decorators, target, key, desc) {
5
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
8
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
9
+ }
10
+
11
+ //#endregion
12
+ //#region src/serialization/ItemsInputNormalizer.ts
13
+ let ItemsInputNormalizer = class ItemsInputNormalizer$1 {
14
+ normalize(raw) {
15
+ if (raw === void 0 || raw === null) return [];
16
+ if (Array.isArray(raw)) return raw.map((value) => this.normalizeItem(value));
17
+ return [this.normalizeItem(raw)];
18
+ }
19
+ normalizeItem(raw) {
20
+ if (!this.isItem(raw)) return { json: raw };
21
+ return {
22
+ json: raw.json,
23
+ ...raw.binary === void 0 ? {} : { binary: raw.binary },
24
+ ...raw.meta === void 0 ? {} : { meta: raw.meta },
25
+ ...raw.paired === void 0 ? {} : { paired: raw.paired }
26
+ };
27
+ }
28
+ isItem(raw) {
29
+ return typeof raw === "object" && raw !== null && Object.prototype.hasOwnProperty.call(raw, "json");
30
+ }
31
+ };
32
+ ItemsInputNormalizer = __decorate([injectable()], ItemsInputNormalizer);
33
+
34
+ //#endregion
35
+ export { ItemsInputNormalizer as t };
36
+ //# sourceMappingURL=ItemsInputNormalizer-D-MH8MBs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ItemsInputNormalizer-D-MH8MBs.js","names":["ItemsInputNormalizer"],"sources":["../src/serialization/ItemsInputNormalizer.ts"],"sourcesContent":["import type { Item, Items } from \"../contracts/workflowTypes\";\nimport { injectable } from \"../di\";\n\n/**\n * Normalizes external inputs into the engine's canonical `Items` shape.\n * Used at host and builder boundaries where callers may provide either a raw value,\n * a single item-like object, or an array of item-like values.\n */\n@injectable()\nexport class ItemsInputNormalizer {\n normalize(raw: unknown): Items {\n if (raw === undefined || raw === null) {\n return [];\n }\n if (Array.isArray(raw)) {\n return raw.map((value) => this.normalizeItem(value));\n }\n return [this.normalizeItem(raw)];\n }\n\n private normalizeItem(raw: unknown): Item {\n if (!this.isItem(raw)) {\n return { json: raw };\n }\n return {\n json: raw.json,\n ...(raw.binary === undefined ? {} : { binary: raw.binary }),\n ...(raw.meta === undefined ? {} : { meta: raw.meta }),\n ...(raw.paired === undefined ? {} : { paired: raw.paired }),\n };\n }\n\n private isItem(raw: unknown): raw is Item {\n return typeof raw === \"object\" && raw !== null && Object.prototype.hasOwnProperty.call(raw, \"json\");\n }\n}\n"],"mappings":";;;;;;;;;;;;AASO,iCAAMA,uBAAqB;CAChC,UAAU,KAAqB;AAC7B,MAAI,QAAQ,UAAa,QAAQ,KAC/B,QAAO,EAAE;AAEX,MAAI,MAAM,QAAQ,IAAI,CACpB,QAAO,IAAI,KAAK,UAAU,KAAK,cAAc,MAAM,CAAC;AAEtD,SAAO,CAAC,KAAK,cAAc,IAAI,CAAC;;CAGlC,AAAQ,cAAc,KAAoB;AACxC,MAAI,CAAC,KAAK,OAAO,IAAI,CACnB,QAAO,EAAE,MAAM,KAAK;AAEtB,SAAO;GACL,MAAM,IAAI;GACV,GAAI,IAAI,WAAW,SAAY,EAAE,GAAG,EAAE,QAAQ,IAAI,QAAQ;GAC1D,GAAI,IAAI,SAAS,SAAY,EAAE,GAAG,EAAE,MAAM,IAAI,MAAM;GACpD,GAAI,IAAI,WAAW,SAAY,EAAE,GAAG,EAAE,QAAQ,IAAI,QAAQ;GAC3D;;CAGH,AAAQ,OAAO,KAA2B;AACxC,SAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,OAAO,UAAU,eAAe,KAAK,KAAK,OAAO;;;mCAzBtG,YAAY"}