@codemation/core-nodes 0.4.3 → 0.6.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +215 -0
  2. package/dist/index.cjs +3485 -474
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +1763 -685
  5. package/dist/index.d.ts +1763 -685
  6. package/dist/index.js +3452 -479
  7. package/dist/index.js.map +1 -1
  8. package/package.json +8 -5
  9. package/src/authoring/defineRestNode.types.ts +204 -0
  10. package/src/chatModels/OpenAIChatModelFactory.ts +17 -8
  11. package/src/chatModels/OpenAiStrictJsonSchemaFactory.ts +123 -0
  12. package/src/credentials/ApiKeyCredentialType.ts +60 -0
  13. package/src/credentials/BasicAuthCredentialType.ts +51 -0
  14. package/src/credentials/BearerTokenCredentialType.ts +40 -0
  15. package/src/credentials/OAuth2ClientCredentialsTypeFactory.ts +117 -0
  16. package/src/credentials/OAuth2TokenExchangeFactory.ts +52 -0
  17. package/src/credentials/index.ts +4 -0
  18. package/src/http/HttpBodyBuilder.ts +90 -0
  19. package/src/http/HttpRequestExecutor.ts +150 -0
  20. package/src/http/HttpUrlBuilder.ts +22 -0
  21. package/src/http/httpRequest.types.ts +69 -0
  22. package/src/index.ts +10 -1
  23. package/src/nodes/AIAgentExecutionHelpersFactory.ts +45 -59
  24. package/src/nodes/AIAgentNode.ts +391 -288
  25. package/src/nodes/AgentMessageFactory.ts +57 -49
  26. package/src/nodes/AgentStructuredOutputRunner.ts +65 -71
  27. package/src/nodes/AgentToolExecutionCoordinator.ts +31 -16
  28. package/src/nodes/AssertionNode.ts +42 -0
  29. package/src/nodes/CronTriggerFactory.ts +45 -0
  30. package/src/nodes/CronTriggerNode.ts +40 -0
  31. package/src/nodes/HttpRequestNodeFactory.ts +99 -23
  32. package/src/nodes/IsTestRunNode.ts +25 -0
  33. package/src/nodes/NodeBackedToolRuntime.ts +40 -4
  34. package/src/nodes/TestTriggerNode.ts +33 -0
  35. package/src/nodes/WebhookTriggerFactory.ts +1 -1
  36. package/src/nodes/aggregate.ts +1 -1
  37. package/src/nodes/aiAgentSupport.types.ts +22 -2
  38. package/src/nodes/assertion.ts +42 -0
  39. package/src/nodes/collections/collectionDeleteNode.types.ts +23 -0
  40. package/src/nodes/collections/collectionFindOneNode.types.ts +26 -0
  41. package/src/nodes/collections/collectionGetNode.types.ts +26 -0
  42. package/src/nodes/collections/collectionInsertNode.types.ts +22 -0
  43. package/src/nodes/collections/collectionListNode.types.ts +30 -0
  44. package/src/nodes/collections/collectionUpdateNode.types.ts +23 -0
  45. package/src/nodes/collections/index.ts +6 -0
  46. package/src/nodes/httpRequest.ts +62 -1
  47. package/src/nodes/if.ts +1 -1
  48. package/src/nodes/isTestRun.ts +24 -0
  49. package/src/nodes/mapData.ts +1 -0
  50. package/src/nodes/merge.ts +1 -1
  51. package/src/nodes/noOp.ts +1 -0
  52. package/src/nodes/split.ts +1 -1
  53. package/src/nodes/testTrigger.ts +72 -0
  54. package/src/nodes/wait.ts +1 -0
  55. package/src/chatModels/OpenAIStructuredOutputMethodFactory.ts +0 -46
package/dist/index.cjs CHANGED
@@ -23,192 +23,561 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  //#endregion
24
24
  let __codemation_core = require("@codemation/core");
25
25
  __codemation_core = __toESM(__codemation_core);
26
- let __langchain_openai = require("@langchain/openai");
27
- __langchain_openai = __toESM(__langchain_openai);
28
- let __langchain_core_messages = require("@langchain/core/messages");
29
- __langchain_core_messages = __toESM(__langchain_core_messages);
30
- let __langchain_core_utils_types = require("@langchain/core/utils/types");
31
- __langchain_core_utils_types = __toESM(__langchain_core_utils_types);
32
- let __langchain_core_utils_json_schema = require("@langchain/core/utils/json_schema");
33
- __langchain_core_utils_json_schema = __toESM(__langchain_core_utils_json_schema);
34
- let __langchain_core_tools = require("@langchain/core/tools");
35
- __langchain_core_tools = __toESM(__langchain_core_tools);
26
+ let __ai_sdk_openai = require("@ai-sdk/openai");
27
+ __ai_sdk_openai = __toESM(__ai_sdk_openai);
36
28
  let __codemation_core_bootstrap = require("@codemation/core/bootstrap");
37
29
  __codemation_core_bootstrap = __toESM(__codemation_core_bootstrap);
30
+ let ai = require("ai");
31
+ ai = __toESM(ai);
32
+ let croner = require("croner");
33
+ croner = __toESM(croner);
38
34
 
39
- //#region \0@oxc-project+runtime@0.95.0/helpers/decorate.js
40
- function __decorate(decorators, target, key, desc) {
41
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
42
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
43
- 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;
44
- return c > 3 && r && Object.defineProperty(target, key, r), r;
45
- }
35
+ //#region src/credentials/ApiKeyCredentialType.ts
36
+ /**
37
+ * API key credential that injects a key either as an HTTP header or a query parameter.
38
+ */
39
+ const apiKeyCredentialType = (0, __codemation_core.defineCredential)({
40
+ key: "core-nodes.api-key",
41
+ label: "API Key",
42
+ description: "Authenticates requests by injecting an API key into a header or query parameter.",
43
+ public: {
44
+ placement: {
45
+ label: "Placement",
46
+ type: "string",
47
+ helpText: "Where to send the key: \"header\" (default) or \"query\".",
48
+ placeholder: "header"
49
+ },
50
+ name: {
51
+ label: "Parameter name",
52
+ type: "string",
53
+ helpText: "Header or query param name. Defaults to \"X-API-Key\" for headers, \"api_key\" for query.",
54
+ placeholder: "X-API-Key"
55
+ }
56
+ },
57
+ secret: { apiKey: {
58
+ label: "API Key",
59
+ type: "password",
60
+ required: true,
61
+ helpText: "The secret API key value."
62
+ } },
63
+ async createSession(args) {
64
+ const apiKey = String(args.material.apiKey ?? "");
65
+ if (!apiKey) throw new Error("API key credential material is incomplete: apiKey is required.");
66
+ const isQuery = String(args.publicConfig.placement ?? "header").toLowerCase() === "query";
67
+ const defaultName = isQuery ? "api_key" : "X-API-Key";
68
+ const paramName = String(args.publicConfig.name ?? "").trim() || defaultName;
69
+ return { applyToRequest: (_spec) => {
70
+ if (isQuery) return { query: { [paramName]: apiKey } };
71
+ return { headers: { [paramName]: apiKey } };
72
+ } };
73
+ },
74
+ async test(args) {
75
+ const apiKey = String(args.material.apiKey ?? "");
76
+ return {
77
+ status: apiKey.length > 0 ? "healthy" : "failing",
78
+ message: apiKey.length > 0 ? "API key is configured." : "API key is missing.",
79
+ testedAt: (/* @__PURE__ */ new Date()).toISOString()
80
+ };
81
+ }
82
+ });
46
83
 
47
84
  //#endregion
48
- //#region src/chatModels/OpenAIChatModelFactory.ts
49
- let OpenAIChatModelFactory = class OpenAIChatModelFactory$1 {
85
+ //#region src/credentials/BasicAuthCredentialType.ts
86
+ /**
87
+ * HTTP Basic authentication credential.
88
+ * Session sets `Authorization: Basic <base64(username:password)>`.
89
+ */
90
+ const basicAuthCredentialType = (0, __codemation_core.defineCredential)({
91
+ key: "core-nodes.basic-auth",
92
+ label: "Basic Auth",
93
+ description: "Authenticates requests using HTTP Basic Authentication (username + password).",
94
+ public: { username: {
95
+ label: "Username",
96
+ type: "string",
97
+ required: true,
98
+ helpText: "The username for HTTP Basic Authentication."
99
+ } },
100
+ secret: { password: {
101
+ label: "Password",
102
+ type: "password",
103
+ required: true,
104
+ helpText: "The password for HTTP Basic Authentication."
105
+ } },
106
+ async createSession(args) {
107
+ const username = String(args.publicConfig.username ?? "");
108
+ const password = String(args.material.password ?? "");
109
+ if (!username) throw new Error("Basic Auth credential is incomplete: username is required.");
110
+ const encoded = Buffer.from(`${username}:${password}`).toString("base64");
111
+ return { applyToRequest: (_spec) => ({ headers: { authorization: `Basic ${encoded}` } }) };
112
+ },
113
+ async test(args) {
114
+ const username = String(args.publicConfig.username ?? "");
115
+ const password = String(args.material.password ?? "");
116
+ const ok = username.length > 0 && password.length > 0;
117
+ return {
118
+ status: ok ? "healthy" : "failing",
119
+ message: ok ? "Basic Auth credentials are configured." : "Username or password is missing.",
120
+ testedAt: (/* @__PURE__ */ new Date()).toISOString()
121
+ };
122
+ }
123
+ });
124
+
125
+ //#endregion
126
+ //#region src/credentials/BearerTokenCredentialType.ts
127
+ /**
128
+ * Simple Bearer token credential.
129
+ * Session sets `Authorization: Bearer <token>` on every request.
130
+ */
131
+ const bearerTokenCredentialType = (0, __codemation_core.defineCredential)({
132
+ key: "core-nodes.bearer-token",
133
+ label: "Bearer Token",
134
+ description: "Authenticates requests using a static Bearer token in the Authorization header.",
135
+ public: {},
136
+ secret: { token: {
137
+ label: "Token",
138
+ type: "password",
139
+ required: true,
140
+ helpText: "The Bearer token to include in the Authorization header."
141
+ } },
142
+ async createSession(args) {
143
+ const token = String(args.material.token ?? "");
144
+ if (!token) throw new Error("Bearer token credential material is incomplete: token is required.");
145
+ return { applyToRequest: (_spec) => ({ headers: { authorization: `Bearer ${token}` } }) };
146
+ },
147
+ async test(args) {
148
+ const token = String(args.material.token ?? "");
149
+ return {
150
+ status: token.length > 0 ? "healthy" : "failing",
151
+ message: token.length > 0 ? "Bearer token is configured." : "Token is missing.",
152
+ testedAt: (/* @__PURE__ */ new Date()).toISOString()
153
+ };
154
+ }
155
+ });
156
+
157
+ //#endregion
158
+ //#region src/credentials/OAuth2TokenExchangeFactory.ts
159
+ var OAuth2TokenExchangeFactory = class {
50
160
  async create(args) {
51
- const session = await args.ctx.getCredential(args.config.credentialSlotKey);
52
- return new __langchain_openai.ChatOpenAI({
53
- apiKey: session.apiKey,
54
- model: args.config.model,
55
- temperature: args.config.options?.temperature,
56
- maxTokens: args.config.options?.maxTokens,
57
- configuration: session.baseUrl ? { baseURL: session.baseUrl } : void 0
161
+ const body = new URLSearchParams({
162
+ grant_type: "client_credentials",
163
+ client_id: args.clientId
58
164
  });
165
+ if (args.scopes) body.set("scope", args.scopes);
166
+ if (args.audience) body.set("audience", args.audience);
167
+ const encoded = Buffer.from(`${args.clientId}:${args.clientSecret}`).toString("base64");
168
+ const response = await globalThis.fetch(args.tokenUrl, {
169
+ method: "POST",
170
+ headers: {
171
+ "content-type": "application/x-www-form-urlencoded",
172
+ authorization: `Basic ${encoded}`
173
+ },
174
+ body: body.toString()
175
+ });
176
+ if (!response.ok) {
177
+ const text = await response.text().catch(() => "");
178
+ throw new Error(`Token exchange failed (${response.status} ${response.statusText}): ${text}`);
179
+ }
180
+ const json = await response.json();
181
+ const token = String(json["access_token"] ?? "");
182
+ if (!token) throw new Error("Token exchange response did not include an access_token.");
183
+ return token;
59
184
  }
60
185
  };
61
- OpenAIChatModelFactory = __decorate([(0, __codemation_core.chatModel)({ packageName: "@codemation/core-nodes" })], OpenAIChatModelFactory);
62
186
 
63
187
  //#endregion
64
- //#region src/chatModels/OpenAIStructuredOutputMethodFactory.ts
65
- var _OpenAIStructuredOutputMethodFactory;
66
- let OpenAIStructuredOutputMethodFactory = class OpenAIStructuredOutputMethodFactory$1 {
67
- static {
68
- _OpenAIStructuredOutputMethodFactory = this;
188
+ //#region src/credentials/OAuth2ClientCredentialsTypeFactory.ts
189
+ /**
190
+ * OAuth2 client-credentials flow credential.
191
+ *
192
+ * This is a machine-to-machine flow: no user redirect occurs. The session
193
+ * POSTs to the configured `tokenUrl` with `client_credentials` grant, caches
194
+ * the resulting access token for the duration of the session, and injects it
195
+ * as `Authorization: Bearer <token>` on each request.
196
+ *
197
+ * Token caching is per-session only (one createSession call = one token fetch
198
+ * at most). Cross-session caching would require host-level state and is out of
199
+ * scope here. Because the engine creates a fresh session per execution, a new
200
+ * token is fetched once per node activation.
201
+ *
202
+ * NOTE: `auth` is intentionally omitted from the definition. The OAuth2
203
+ * `auth: { kind: "oauth2" }` shape signals an authorization-code / user-redirect
204
+ * flow; using it here would cause the host UI to render an OAuth consent button
205
+ * that goes nowhere. Client-credentials is a purely server-side flow.
206
+ */
207
+ const oauth2ClientCredentialsType = (0, __codemation_core.defineCredential)({
208
+ key: "core-nodes.oauth2-client-credentials",
209
+ label: "OAuth2 Client Credentials",
210
+ description: "Machine-to-machine OAuth2 using the client_credentials grant. Exchanges client ID and secret for a bearer token before each workflow execution.",
211
+ public: {
212
+ tokenUrl: {
213
+ label: "Token URL",
214
+ type: "string",
215
+ required: true,
216
+ helpText: "The token endpoint URL, e.g. https://auth.example.com/oauth/token."
217
+ },
218
+ scopes: {
219
+ label: "Scopes",
220
+ type: "string",
221
+ helpText: "Space-separated list of OAuth2 scopes to request (optional)."
222
+ },
223
+ audience: {
224
+ label: "Audience",
225
+ type: "string",
226
+ helpText: "Optional audience parameter sent to the token endpoint.",
227
+ visibility: "advanced"
228
+ }
229
+ },
230
+ secret: {
231
+ clientId: {
232
+ label: "Client ID",
233
+ type: "string",
234
+ required: true
235
+ },
236
+ clientSecret: {
237
+ label: "Client Secret",
238
+ type: "password",
239
+ required: true
240
+ }
241
+ },
242
+ async createSession(args) {
243
+ const tokenUrl = String(args.publicConfig.tokenUrl ?? "");
244
+ const clientId = String(args.material.clientId ?? "");
245
+ const clientSecret = String(args.material.clientSecret ?? "");
246
+ if (!tokenUrl || !clientId || !clientSecret) throw new Error("OAuth2 client credentials are incomplete: tokenUrl, clientId, and clientSecret are required.");
247
+ const accessToken = await new OAuth2TokenExchangeFactory().create({
248
+ tokenUrl,
249
+ clientId,
250
+ clientSecret,
251
+ scopes: String(args.publicConfig.scopes ?? ""),
252
+ audience: String(args.publicConfig.audience ?? "")
253
+ });
254
+ return { applyToRequest: (_spec) => ({ headers: { authorization: `Bearer ${accessToken}` } }) };
255
+ },
256
+ async test(args) {
257
+ const tokenUrl = String(args.publicConfig.tokenUrl ?? "");
258
+ const clientId = String(args.material.clientId ?? "");
259
+ const clientSecret = String(args.material.clientSecret ?? "");
260
+ if (!tokenUrl || !clientId || !clientSecret) return {
261
+ status: "failing",
262
+ message: "tokenUrl, clientId, and clientSecret are all required.",
263
+ testedAt: (/* @__PURE__ */ new Date()).toISOString()
264
+ };
265
+ try {
266
+ await new OAuth2TokenExchangeFactory().create({
267
+ tokenUrl,
268
+ clientId,
269
+ clientSecret,
270
+ scopes: String(args.publicConfig.scopes ?? ""),
271
+ audience: String(args.publicConfig.audience ?? "")
272
+ });
273
+ return {
274
+ status: "healthy",
275
+ message: "Token exchange succeeded.",
276
+ testedAt: (/* @__PURE__ */ new Date()).toISOString()
277
+ };
278
+ } catch (error) {
279
+ return {
280
+ status: "failing",
281
+ message: error instanceof Error ? error.message : String(error),
282
+ testedAt: (/* @__PURE__ */ new Date()).toISOString()
283
+ };
284
+ }
69
285
  }
70
- static isoDatePattern = /^\d{4}-\d{2}-\d{2}$/;
71
- create(chatModelConfig) {
72
- if (chatModelConfig.type !== OpenAIChatModelFactory) return;
73
- const model = this.readModelName(chatModelConfig);
74
- if (!model) return {
75
- method: "functionCalling",
76
- strict: true
286
+ });
287
+
288
+ //#endregion
289
+ //#region src/http/HttpRequestExecutor.ts
290
+ /**
291
+ * Executes a single HTTP request described by {@link HttpRequestSpec}.
292
+ *
293
+ * - Credential sessions provide header/query deltas via `applyToRequest`.
294
+ * - Body encoding is delegated to {@link HttpBodyBuilder}.
295
+ * - URL query merging is delegated to {@link HttpUrlBuilder}.
296
+ * - Binary response bodies: when `download.mode` triggers binary attach, the
297
+ * `bodyBinaryName` field is set in the result but the body is NOT read here.
298
+ * Callers that need binary attachment should use `buildRequest` to get the
299
+ * resolved URL + init and make the fetch + binary attach themselves.
300
+ *
301
+ * Collaborators (`fetch`, body builder, url builder) are injected so callers
302
+ * own construction at composition roots and tests can supply deterministic stubs.
303
+ */
304
+ var HttpRequestExecutor = class {
305
+ constructor(fetchFn, bodyBuilder, urlBuilder) {
306
+ this.fetchFn = fetchFn;
307
+ this.bodyBuilder = bodyBuilder;
308
+ this.urlBuilder = urlBuilder;
309
+ }
310
+ /**
311
+ * Builds the fetch init (headers, query, body) from the spec + credential delta,
312
+ * returning both the resolved URL and the RequestInit so callers can make the
313
+ * actual fetch call themselves (useful for streaming / binary attach).
314
+ */
315
+ async buildRequest(spec, item) {
316
+ const credentialDelta = spec.credential?.applyToRequest(spec) ?? {};
317
+ const mergedHeaders = {
318
+ ...spec.headers ?? {},
319
+ ...credentialDelta.headers ?? {}
320
+ };
321
+ const mergedQuery = {
322
+ ...spec.query ?? {},
323
+ ...credentialDelta.query ?? {}
77
324
  };
325
+ const encodedBody = await this.bodyBuilder.build(spec.body, item, spec.ctx);
326
+ if (encodedBody && encodedBody.contentType) mergedHeaders["content-type"] = encodedBody.contentType;
327
+ return {
328
+ url: this.urlBuilder.build(spec.url, mergedQuery),
329
+ init: {
330
+ method: spec.method,
331
+ headers: mergedHeaders,
332
+ ...encodedBody ? { body: encodedBody.body } : {}
333
+ }
334
+ };
335
+ }
336
+ /**
337
+ * Executes an HTTP request and returns parsed result.
338
+ * For binary downloads (when `shouldAttachBody` is true), the body is NOT consumed
339
+ * and callers must call `ctx.binary.attach` directly using the resolved URL + init
340
+ * (available via `buildRequest`).
341
+ */
342
+ async execute(spec, item) {
343
+ const { url: resolvedUrl, init } = await this.buildRequest(spec, item);
344
+ const response = await this.fetchFn(resolvedUrl, init);
345
+ const responseHeaders = this.readHeaders(response.headers);
346
+ const mimeType = this.resolveMimeType(responseHeaders);
347
+ const downloadMode = spec.download?.mode ?? "auto";
348
+ const binaryName = spec.download?.binaryName ?? "body";
349
+ const shouldDownload = this.shouldAttachBody(downloadMode, mimeType);
350
+ const isJson = this.isJsonMimeType(mimeType);
351
+ let json;
352
+ let text;
353
+ let bodyBinaryName;
354
+ if (shouldDownload) bodyBinaryName = binaryName;
355
+ else if (isJson) try {
356
+ json = await response.json();
357
+ } catch {
358
+ text = await response.text();
359
+ }
360
+ else text = await response.text();
78
361
  return {
79
- method: this.supportsJsonSchema(model) ? "jsonSchema" : "functionCalling",
80
- strict: true
362
+ url: resolvedUrl,
363
+ method: spec.method.toUpperCase(),
364
+ status: response.status,
365
+ ok: response.ok,
366
+ statusText: response.statusText,
367
+ mimeType,
368
+ headers: responseHeaders,
369
+ ...json !== void 0 ? { json } : {},
370
+ ...text !== void 0 ? { text } : {},
371
+ ...bodyBinaryName !== void 0 ? { bodyBinaryName } : {}
81
372
  };
82
373
  }
83
- readModelName(chatModelConfig) {
84
- const candidate = chatModelConfig;
85
- return typeof candidate.model === "string" ? candidate.model : void 0;
374
+ readHeaders(headers) {
375
+ const values = {};
376
+ headers.forEach((value, key) => {
377
+ values[key] = value;
378
+ });
379
+ return values;
380
+ }
381
+ resolveMimeType(headers) {
382
+ const contentType = headers["content-type"];
383
+ if (!contentType) return "application/octet-stream";
384
+ return contentType.split(";")[0]?.trim() || "application/octet-stream";
86
385
  }
87
- supportsJsonSchema(model) {
88
- if (model === "gpt-4o" || model === "gpt-4o-mini") return true;
89
- return this.supportsSnapshotAtOrAfter(model, "gpt-4o-", "2024-08-06") || this.supportsSnapshotAtOrAfter(model, "gpt-4o-mini-", "2024-07-18");
386
+ isJsonMimeType(mimeType) {
387
+ return mimeType === "application/json" || mimeType.endsWith("+json");
90
388
  }
91
- supportsSnapshotAtOrAfter(model, prefix, minimumSnapshotDate) {
92
- if (!model.startsWith(prefix)) return false;
93
- const snapshotDate = model.slice(prefix.length);
94
- return _OpenAIStructuredOutputMethodFactory.isoDatePattern.test(snapshotDate) && snapshotDate >= minimumSnapshotDate;
389
+ shouldAttachBody(mode, mimeType) {
390
+ if (mode === "always") return true;
391
+ if (mode === "never") return false;
392
+ return mimeType.startsWith("image/") || mimeType.startsWith("audio/") || mimeType.startsWith("video/") || mimeType === "application/pdf";
95
393
  }
96
394
  };
97
- OpenAIStructuredOutputMethodFactory = _OpenAIStructuredOutputMethodFactory = __decorate([(0, __codemation_core.injectable)()], OpenAIStructuredOutputMethodFactory);
98
395
 
99
396
  //#endregion
100
- //#region src/chatModels/openAiChatModelConfig.ts
101
- var OpenAIChatModelConfig = class {
102
- type = OpenAIChatModelFactory;
103
- presentation;
104
- provider = "openai";
105
- modelName;
106
- constructor(name, model, credentialSlotKey = "openai", presentationIn, options) {
107
- this.name = name;
108
- this.model = model;
109
- this.credentialSlotKey = credentialSlotKey;
110
- this.options = options;
111
- this.modelName = model;
112
- this.presentation = presentationIn ?? {
113
- icon: "builtin:openai",
114
- label: name
397
+ //#region src/http/HttpBodyBuilder.ts
398
+ /**
399
+ * Builds a fetch-compatible `BodyInit` + Content-Type pair from an {@link HttpBodySpec}.
400
+ * Multipart binaries are read from `item.binary` via `ctx.binary.openReadStream`.
401
+ */
402
+ var HttpBodyBuilder = class {
403
+ async build(spec, item, ctx) {
404
+ if (!spec || spec.kind === "none") return;
405
+ if (spec.kind === "json") return {
406
+ body: JSON.stringify(spec.data),
407
+ contentType: "application/json"
115
408
  };
116
- }
117
- getCredentialRequirements() {
118
- return [{
119
- slotKey: this.credentialSlotKey,
120
- label: "OpenAI API key",
121
- acceptedTypes: ["openai.apiKey"]
122
- }];
409
+ if (spec.kind === "form") {
410
+ const params = new URLSearchParams();
411
+ for (const [key, value] of Object.entries(spec.data)) params.append(key, value);
412
+ return {
413
+ body: params.toString(),
414
+ contentType: "application/x-www-form-urlencoded"
415
+ };
416
+ }
417
+ if (spec.kind === "multipart") {
418
+ const formData = new FormData();
419
+ for (const [key, value] of Object.entries(spec.fields)) formData.append(key, value);
420
+ if (spec.binaries) for (const [fieldName, binaryRef] of Object.entries(spec.binaries)) {
421
+ const attachment = item.binary?.[binaryRef];
422
+ if (attachment) {
423
+ const readResult = await ctx.binary.openReadStream(attachment);
424
+ if (readResult) {
425
+ const reader = readResult.body.getReader();
426
+ const chunks = [];
427
+ let done = false;
428
+ while (!done) {
429
+ const result = await reader.read();
430
+ done = result.done;
431
+ if (result.value) chunks.push(result.value);
432
+ }
433
+ const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
434
+ const merged = new Uint8Array(totalLength);
435
+ let offset = 0;
436
+ for (const chunk of chunks) {
437
+ merged.set(chunk, offset);
438
+ offset += chunk.length;
439
+ }
440
+ const blob = new Blob([merged], { type: attachment.mimeType });
441
+ formData.append(fieldName, blob, attachment.filename ?? binaryRef);
442
+ }
443
+ }
444
+ }
445
+ return {
446
+ body: formData,
447
+ contentType: ""
448
+ };
449
+ }
123
450
  }
124
451
  };
125
452
 
126
453
  //#endregion
127
- //#region src/chatModels/OpenAiChatModelPresetsFactory.ts
454
+ //#region src/http/HttpUrlBuilder.ts
128
455
  /**
129
- * Default OpenAI chat model configs for scaffolds and demos (icon + label match {@link OpenAIChatModelConfig} defaults).
130
- * Prefer importing {@link openAiChatModelPresets} from here or from the consumer template re-export
131
- * instead of repeating {@link OpenAIChatModelConfig} construction in app workflows.
456
+ * Merges query parameters into a base URL.
457
+ * Handles both scalar and array values, and preserves any existing params.
132
458
  */
133
- var OpenAiChatModelPresets = class {
134
- demoGpt4oMini = new OpenAIChatModelConfig("OpenAI", "gpt-4o-mini");
135
- demoGpt41 = new OpenAIChatModelConfig("OpenAI", "gpt-4.1");
459
+ var HttpUrlBuilder = class {
460
+ build(baseUrl, query) {
461
+ if (!query || Object.keys(query).length === 0) return baseUrl;
462
+ const parsed = new URL(baseUrl);
463
+ for (const [key, value] of Object.entries(query)) if (Array.isArray(value)) for (const entry of value) parsed.searchParams.append(key, entry);
464
+ else parsed.searchParams.append(key, value);
465
+ return parsed.toString();
466
+ }
136
467
  };
137
- const openAiChatModelPresets = new OpenAiChatModelPresets();
138
468
 
139
469
  //#endregion
140
- //#region src/nodes/AgentMessageFactory.ts
141
- var AgentMessageFactory = class {
142
- static createPromptMessages(messages) {
143
- return messages.map((message) => this.createPromptMessage(message));
144
- }
145
- static createSystemPrompt(systemMessage) {
146
- return new __langchain_core_messages.SystemMessage(systemMessage);
147
- }
148
- static createUserPrompt(prompt) {
149
- return new __langchain_core_messages.HumanMessage(prompt);
150
- }
151
- static createAssistantPrompt(prompt) {
152
- return new __langchain_core_messages.AIMessage(prompt);
153
- }
154
- static createToolMessage(toolCallId, content) {
155
- return new __langchain_core_messages.ToolMessage({
156
- tool_call_id: toolCallId,
157
- content
158
- });
159
- }
160
- static extractContent(message) {
161
- if (typeof message === "string") return message;
162
- if (!this.isRecord(message)) return String(message);
163
- const content = message.content;
164
- if (typeof content === "string") return content;
165
- if (Array.isArray(content)) return content.map((part) => {
166
- if (typeof part === "string") return part;
167
- if (this.isRecord(part) && typeof part.text === "string") return part.text;
168
- return JSON.stringify(part);
169
- }).join("\n");
170
- return JSON.stringify(content);
171
- }
172
- static extractToolCalls(message) {
173
- if (!this.isRecord(message)) return [];
174
- const toolCalls = message.tool_calls;
175
- if (!Array.isArray(toolCalls)) return [];
176
- return toolCalls.filter((toolCall) => this.isRecord(toolCall) && typeof toolCall.name === "string").map((toolCall) => ({
177
- id: typeof toolCall.id === "string" ? toolCall.id : void 0,
178
- name: toolCall.name,
179
- input: this.isRecord(toolCall) && "args" in toolCall ? toolCall.args : void 0
180
- }));
181
- }
182
- static isRecord(value) {
183
- return typeof value === "object" && value !== null;
184
- }
185
- static createPromptMessage(message) {
186
- if (message.role === "system") return this.createSystemPrompt(message.content);
187
- if (message.role === "assistant") return this.createAssistantPrompt(message.content);
188
- return this.createUserPrompt(message.content);
189
- }
190
- };
470
+ //#region src/authoring/defineRestNode.types.ts
471
+ /**
472
+ * Substitutes `{name}` placeholders in a path template using values from `params`.
473
+ */
474
+ function substitutePath(template, params) {
475
+ return template.replace(/\{([^}]+)}/g, (_match, key) => {
476
+ const value = params[key];
477
+ return value !== void 0 ? String(value) : `{${key}}`;
478
+ });
479
+ }
480
+ /**
481
+ * Declarative helper for creating thin API-wrapper nodes.
482
+ *
483
+ * Usage:
484
+ * ```ts
485
+ * export const postMessage = defineRestNode({
486
+ * key: "slack.post-message",
487
+ * title: "Send Slack message",
488
+ * icon: "si:slack",
489
+ * api: { baseUrl: "https://slack.com/api", path: "/chat.postMessage", method: "POST" },
490
+ * credentials: { auth: bearerTokenCredentialType },
491
+ * inputSchema: z.object({ channel: z.string(), text: z.string() }),
492
+ * request: ({ input }) => ({
493
+ * body: { kind: "json", data: { channel: input.channel, text: input.text } },
494
+ * }),
495
+ * response: ({ json }) => ({ messageTs: (json as any).ts }),
496
+ * });
497
+ * ```
498
+ *
499
+ * - `defineRestNode` is a thin wrapper over `defineNode`; it does not introduce a new runtime kind.
500
+ * - Credential sessions are resolved via the `credentials` binding map (same as `defineNode`).
501
+ * - Path `{placeholder}` substitution is applied from `input` keys before the request is made.
502
+ * - Non-2xx responses throw an `Error` by default (`errorPolicy: "throw"`).
503
+ */
504
+ function defineRestNode(options) {
505
+ const errorPolicy = options.errorPolicy ?? "throw";
506
+ return (0, __codemation_core.defineNode)({
507
+ key: options.key,
508
+ title: options.title,
509
+ description: options.description,
510
+ icon: options.icon,
511
+ credentials: options.credentials,
512
+ inputSchema: options.inputSchema,
513
+ async execute({ input, item, ctx }, { credentials }) {
514
+ const credentialSlot = options.credentials ? Object.keys(options.credentials)[0] : void 0;
515
+ const credential = credentialSlot ? await credentials[credentialSlot]?.() : void 0;
516
+ const inputRecord = input ?? {};
517
+ const requestShape = options.request ? await options.request({ input }) : {};
518
+ const pathParams = {
519
+ ...inputRecord,
520
+ ...requestShape.pathParams ?? {}
521
+ };
522
+ const resolvedPath = substitutePath(options.api.path, pathParams);
523
+ const resolvedUrl = `${options.api.baseUrl}${resolvedPath}`;
524
+ const result = await new HttpRequestExecutor(globalThis.fetch, new HttpBodyBuilder(), new HttpUrlBuilder()).execute({
525
+ url: resolvedUrl,
526
+ method: (options.api.method ?? "GET").toUpperCase(),
527
+ headers: requestShape.headers,
528
+ query: requestShape.query,
529
+ body: requestShape.body,
530
+ credential,
531
+ ctx
532
+ }, item);
533
+ if (errorPolicy === "throw" && !result.ok) throw new Error(`HTTP ${result.status} ${result.statusText} for ${result.method} ${result.url}`);
534
+ const responseCtx = {
535
+ status: result.status,
536
+ ok: result.ok,
537
+ statusText: result.statusText,
538
+ mimeType: result.mimeType,
539
+ headers: result.headers,
540
+ ...result.json !== void 0 ? { json: result.json } : {},
541
+ ...result.text !== void 0 ? { text: result.text } : {}
542
+ };
543
+ if (options.response) return await options.response({
544
+ ...responseCtx,
545
+ input
546
+ });
547
+ return { json: responseCtx };
548
+ }
549
+ });
550
+ }
191
551
 
192
552
  //#endregion
193
- //#region src/nodes/AgentOutputFactory.ts
194
- var AgentOutputFactory = class {
195
- static fromUnknown(value) {
196
- return { main: [{ json: value }] };
197
- }
198
- static replaceJson(item, value) {
553
+ //#region \0@oxc-project+runtime@0.95.0/helpers/decorate.js
554
+ function __decorate(decorators, target, key, desc) {
555
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
556
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
557
+ 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;
558
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
559
+ }
560
+
561
+ //#endregion
562
+ //#region src/chatModels/OpenAIChatModelFactory.ts
563
+ let OpenAIChatModelFactory = class OpenAIChatModelFactory$1 {
564
+ async create(args) {
565
+ const session = await args.ctx.getCredential(args.config.credentialSlotKey);
199
566
  return {
200
- ...item,
201
- json: value
567
+ languageModel: (0, __ai_sdk_openai.createOpenAI)({
568
+ apiKey: session.apiKey,
569
+ baseURL: session.baseUrl
570
+ }).chat(args.config.model),
571
+ modelName: args.config.model,
572
+ provider: "openai",
573
+ defaultCallOptions: {
574
+ maxOutputTokens: args.config.options?.maxTokens,
575
+ temperature: args.config.options?.temperature
576
+ }
202
577
  };
203
578
  }
204
- static fromAgentContent(content) {
205
- try {
206
- return JSON.parse(content);
207
- } catch {
208
- return { output: content };
209
- }
210
- }
211
579
  };
580
+ OpenAIChatModelFactory = __decorate([(0, __codemation_core.chatModel)({ packageName: "@codemation/core-nodes" })], OpenAIChatModelFactory);
212
581
 
213
582
  //#endregion
214
583
  //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.js
@@ -299,10 +668,21 @@ function cleanRegex(source) {
299
668
  const end = source.endsWith("$") ? source.length - 1 : source.length;
300
669
  return source.slice(start, end);
301
670
  }
671
+ function floatSafeRemainder(val, step) {
672
+ const valDecCount = (val.toString().split(".")[1] || "").length;
673
+ const stepString = step.toString();
674
+ let stepDecCount = (stepString.split(".")[1] || "").length;
675
+ if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
676
+ const match = stepString.match(/\d?e-(\d?)/);
677
+ if (match?.[1]) stepDecCount = Number.parseInt(match[1]);
678
+ }
679
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
680
+ return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
681
+ }
302
682
  const EVALUATING = Symbol("evaluating");
303
- function defineLazy(object, key, getter) {
683
+ function defineLazy(object$1, key, getter) {
304
684
  let value = void 0;
305
- Object.defineProperty(object, key, {
685
+ Object.defineProperty(object$1, key, {
306
686
  get() {
307
687
  if (value === EVALUATING) return;
308
688
  if (value === void 0) {
@@ -312,11 +692,19 @@ function defineLazy(object, key, getter) {
312
692
  return value;
313
693
  },
314
694
  set(v) {
315
- Object.defineProperty(object, key, { value: v });
695
+ Object.defineProperty(object$1, key, { value: v });
316
696
  },
317
697
  configurable: true
318
698
  });
319
699
  }
700
+ function assignProp(target, prop, value) {
701
+ Object.defineProperty(target, prop, {
702
+ value,
703
+ writable: true,
704
+ enumerable: true,
705
+ configurable: true
706
+ });
707
+ }
320
708
  function mergeDefs(...defs) {
321
709
  const mergedDescriptors = {};
322
710
  for (const def of defs) {
@@ -325,6 +713,12 @@ function mergeDefs(...defs) {
325
713
  }
326
714
  return Object.defineProperties({}, mergedDescriptors);
327
715
  }
716
+ function esc(str) {
717
+ return JSON.stringify(str);
718
+ }
719
+ function slugify(input) {
720
+ return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
721
+ }
328
722
  const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
329
723
  function isObject(data) {
330
724
  return typeof data === "object" && data !== null && !Array.isArray(data);
@@ -353,6 +747,14 @@ function shallowClone(o) {
353
747
  if (Array.isArray(o)) return [...o];
354
748
  return o;
355
749
  }
750
+ const propertyKeyTypes = new Set([
751
+ "string",
752
+ "number",
753
+ "symbol"
754
+ ]);
755
+ function escapeRegex(str) {
756
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
757
+ }
356
758
  function clone(inst, def, params) {
357
759
  const cl = new inst._zod.constr(def ?? inst._zod.def);
358
760
  if (!def || params?.parent) cl._zod.parent = inst;
@@ -373,6 +775,11 @@ function normalizeParams(_params) {
373
775
  };
374
776
  return params;
375
777
  }
778
+ function optionalKeys(shape) {
779
+ return Object.keys(shape).filter((k) => {
780
+ return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
781
+ });
782
+ }
376
783
  const NUMBER_FORMAT_RANGES = {
377
784
  safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
378
785
  int32: [-2147483648, 2147483647],
@@ -380,6 +787,130 @@ const NUMBER_FORMAT_RANGES = {
380
787
  float32: [-34028234663852886e22, 34028234663852886e22],
381
788
  float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
382
789
  };
790
+ function pick(schema, mask) {
791
+ const currDef = schema._zod.def;
792
+ const checks = currDef.checks;
793
+ if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
794
+ return clone(schema, mergeDefs(schema._zod.def, {
795
+ get shape() {
796
+ const newShape = {};
797
+ for (const key in mask) {
798
+ if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
799
+ if (!mask[key]) continue;
800
+ newShape[key] = currDef.shape[key];
801
+ }
802
+ assignProp(this, "shape", newShape);
803
+ return newShape;
804
+ },
805
+ checks: []
806
+ }));
807
+ }
808
+ function omit(schema, mask) {
809
+ const currDef = schema._zod.def;
810
+ const checks = currDef.checks;
811
+ if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
812
+ return clone(schema, mergeDefs(schema._zod.def, {
813
+ get shape() {
814
+ const newShape = { ...schema._zod.def.shape };
815
+ for (const key in mask) {
816
+ if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
817
+ if (!mask[key]) continue;
818
+ delete newShape[key];
819
+ }
820
+ assignProp(this, "shape", newShape);
821
+ return newShape;
822
+ },
823
+ checks: []
824
+ }));
825
+ }
826
+ function extend(schema, shape) {
827
+ if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
828
+ const checks = schema._zod.def.checks;
829
+ if (checks && checks.length > 0) {
830
+ const existingShape = schema._zod.def.shape;
831
+ for (const key in shape) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
832
+ }
833
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
834
+ const _shape = {
835
+ ...schema._zod.def.shape,
836
+ ...shape
837
+ };
838
+ assignProp(this, "shape", _shape);
839
+ return _shape;
840
+ } }));
841
+ }
842
+ function safeExtend(schema, shape) {
843
+ if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
844
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
845
+ const _shape = {
846
+ ...schema._zod.def.shape,
847
+ ...shape
848
+ };
849
+ assignProp(this, "shape", _shape);
850
+ return _shape;
851
+ } }));
852
+ }
853
+ function merge(a, b) {
854
+ return clone(a, mergeDefs(a._zod.def, {
855
+ get shape() {
856
+ const _shape = {
857
+ ...a._zod.def.shape,
858
+ ...b._zod.def.shape
859
+ };
860
+ assignProp(this, "shape", _shape);
861
+ return _shape;
862
+ },
863
+ get catchall() {
864
+ return b._zod.def.catchall;
865
+ },
866
+ checks: []
867
+ }));
868
+ }
869
+ function partial(Class, schema, mask) {
870
+ const checks = schema._zod.def.checks;
871
+ if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
872
+ return clone(schema, mergeDefs(schema._zod.def, {
873
+ get shape() {
874
+ const oldShape = schema._zod.def.shape;
875
+ const shape = { ...oldShape };
876
+ if (mask) for (const key in mask) {
877
+ if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
878
+ if (!mask[key]) continue;
879
+ shape[key] = Class ? new Class({
880
+ type: "optional",
881
+ innerType: oldShape[key]
882
+ }) : oldShape[key];
883
+ }
884
+ else for (const key in oldShape) shape[key] = Class ? new Class({
885
+ type: "optional",
886
+ innerType: oldShape[key]
887
+ }) : oldShape[key];
888
+ assignProp(this, "shape", shape);
889
+ return shape;
890
+ },
891
+ checks: []
892
+ }));
893
+ }
894
+ function required(Class, schema, mask) {
895
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
896
+ const oldShape = schema._zod.def.shape;
897
+ const shape = { ...oldShape };
898
+ if (mask) for (const key in mask) {
899
+ if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
900
+ if (!mask[key]) continue;
901
+ shape[key] = new Class({
902
+ type: "nonoptional",
903
+ innerType: oldShape[key]
904
+ });
905
+ }
906
+ else for (const key in oldShape) shape[key] = new Class({
907
+ type: "nonoptional",
908
+ innerType: oldShape[key]
909
+ });
910
+ assignProp(this, "shape", shape);
911
+ return shape;
912
+ } }));
913
+ }
383
914
  function aborted(x, startIndex = 0) {
384
915
  if (x.aborted === true) return true;
385
916
  for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
@@ -585,6 +1116,64 @@ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
585
1116
  };
586
1117
  const safeDecodeAsync$1 = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
587
1118
 
1119
+ //#endregion
1120
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/regexes.js
1121
+ const cuid = /^[cC][^\s-]{8,}$/;
1122
+ const cuid2 = /^[0-9a-z]+$/;
1123
+ const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
1124
+ const xid = /^[0-9a-vA-V]{20}$/;
1125
+ const ksuid = /^[A-Za-z0-9]{27}$/;
1126
+ const nanoid = /^[a-zA-Z0-9_-]{21}$/;
1127
+ /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
1128
+ const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
1129
+ /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
1130
+ const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
1131
+ /** Returns a regex for validating an RFC 9562/4122 UUID.
1132
+ *
1133
+ * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
1134
+ const uuid = (version$1) => {
1135
+ if (!version$1) return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
1136
+ return /* @__PURE__ */ new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version$1}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
1137
+ };
1138
+ /** Practical email validation */
1139
+ const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
1140
+ const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
1141
+ function emoji() {
1142
+ return new RegExp(_emoji$1, "u");
1143
+ }
1144
+ const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
1145
+ const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
1146
+ const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
1147
+ const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
1148
+ const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
1149
+ const base64url = /^[A-Za-z0-9_-]*$/;
1150
+ const e164 = /^\+[1-9]\d{6,14}$/;
1151
+ const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
1152
+ const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
1153
+ function timeSource(args) {
1154
+ const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
1155
+ return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
1156
+ }
1157
+ function time$1(args) {
1158
+ return /* @__PURE__ */ new RegExp(`^${timeSource(args)}$`);
1159
+ }
1160
+ function datetime$1(args) {
1161
+ const time$2 = timeSource({ precision: args.precision });
1162
+ const opts = ["Z"];
1163
+ if (args.local) opts.push("");
1164
+ if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
1165
+ const timeRegex = `${time$2}(?:${opts.join("|")})`;
1166
+ return /* @__PURE__ */ new RegExp(`^${dateSource}T(?:${timeRegex})$`);
1167
+ }
1168
+ const string$1 = (params) => {
1169
+ const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
1170
+ return /* @__PURE__ */ new RegExp(`^${regex}$`);
1171
+ };
1172
+ const integer = /^-?\d+$/;
1173
+ const number$1 = /^-?\d+(?:\.\d+)?$/;
1174
+ const lowercase = /^[^A-Z]*$/;
1175
+ const uppercase = /^[^a-z]*$/;
1176
+
588
1177
  //#endregion
589
1178
  //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.js
590
1179
  const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
@@ -593,33 +1182,172 @@ const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
593
1182
  inst._zod.def = def;
594
1183
  (_a$1 = inst._zod).onattach ?? (_a$1.onattach = []);
595
1184
  });
596
- const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
597
- var _a$1;
1185
+ const numericOriginMap = {
1186
+ number: "number",
1187
+ bigint: "bigint",
1188
+ object: "date"
1189
+ };
1190
+ const $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
598
1191
  $ZodCheck.init(inst, def);
599
- (_a$1 = inst._zod.def).when ?? (_a$1.when = (payload) => {
600
- const val = payload.value;
601
- return !nullish(val) && val.length !== void 0;
602
- });
1192
+ const origin = numericOriginMap[typeof def.value];
603
1193
  inst._zod.onattach.push((inst$1) => {
604
- const curr = inst$1._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
605
- if (def.maximum < curr) inst$1._zod.bag.maximum = def.maximum;
1194
+ const bag = inst$1._zod.bag;
1195
+ const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
1196
+ if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
1197
+ else bag.exclusiveMaximum = def.value;
606
1198
  });
607
1199
  inst._zod.check = (payload) => {
608
- const input = payload.value;
609
- if (input.length <= def.maximum) return;
610
- const origin = getLengthableOrigin(input);
1200
+ if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
611
1201
  payload.issues.push({
612
1202
  origin,
613
1203
  code: "too_big",
614
- maximum: def.maximum,
615
- inclusive: true,
616
- input,
1204
+ maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
1205
+ input: payload.value,
1206
+ inclusive: def.inclusive,
617
1207
  inst,
618
1208
  continue: !def.abort
619
1209
  });
620
1210
  };
621
1211
  });
622
- const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
1212
+ const $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
1213
+ $ZodCheck.init(inst, def);
1214
+ const origin = numericOriginMap[typeof def.value];
1215
+ inst._zod.onattach.push((inst$1) => {
1216
+ const bag = inst$1._zod.bag;
1217
+ const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
1218
+ if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
1219
+ else bag.exclusiveMinimum = def.value;
1220
+ });
1221
+ inst._zod.check = (payload) => {
1222
+ if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
1223
+ payload.issues.push({
1224
+ origin,
1225
+ code: "too_small",
1226
+ minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
1227
+ input: payload.value,
1228
+ inclusive: def.inclusive,
1229
+ inst,
1230
+ continue: !def.abort
1231
+ });
1232
+ };
1233
+ });
1234
+ const $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
1235
+ $ZodCheck.init(inst, def);
1236
+ inst._zod.onattach.push((inst$1) => {
1237
+ var _a$1;
1238
+ (_a$1 = inst$1._zod.bag).multipleOf ?? (_a$1.multipleOf = def.value);
1239
+ });
1240
+ inst._zod.check = (payload) => {
1241
+ if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
1242
+ if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
1243
+ payload.issues.push({
1244
+ origin: typeof payload.value,
1245
+ code: "not_multiple_of",
1246
+ divisor: def.value,
1247
+ input: payload.value,
1248
+ inst,
1249
+ continue: !def.abort
1250
+ });
1251
+ };
1252
+ });
1253
+ const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat", (inst, def) => {
1254
+ $ZodCheck.init(inst, def);
1255
+ def.format = def.format || "float64";
1256
+ const isInt = def.format?.includes("int");
1257
+ const origin = isInt ? "int" : "number";
1258
+ const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
1259
+ inst._zod.onattach.push((inst$1) => {
1260
+ const bag = inst$1._zod.bag;
1261
+ bag.format = def.format;
1262
+ bag.minimum = minimum;
1263
+ bag.maximum = maximum;
1264
+ if (isInt) bag.pattern = integer;
1265
+ });
1266
+ inst._zod.check = (payload) => {
1267
+ const input = payload.value;
1268
+ if (isInt) {
1269
+ if (!Number.isInteger(input)) {
1270
+ payload.issues.push({
1271
+ expected: origin,
1272
+ format: def.format,
1273
+ code: "invalid_type",
1274
+ continue: false,
1275
+ input,
1276
+ inst
1277
+ });
1278
+ return;
1279
+ }
1280
+ if (!Number.isSafeInteger(input)) {
1281
+ if (input > 0) payload.issues.push({
1282
+ input,
1283
+ code: "too_big",
1284
+ maximum: Number.MAX_SAFE_INTEGER,
1285
+ note: "Integers must be within the safe integer range.",
1286
+ inst,
1287
+ origin,
1288
+ inclusive: true,
1289
+ continue: !def.abort
1290
+ });
1291
+ else payload.issues.push({
1292
+ input,
1293
+ code: "too_small",
1294
+ minimum: Number.MIN_SAFE_INTEGER,
1295
+ note: "Integers must be within the safe integer range.",
1296
+ inst,
1297
+ origin,
1298
+ inclusive: true,
1299
+ continue: !def.abort
1300
+ });
1301
+ return;
1302
+ }
1303
+ }
1304
+ if (input < minimum) payload.issues.push({
1305
+ origin: "number",
1306
+ input,
1307
+ code: "too_small",
1308
+ minimum,
1309
+ inclusive: true,
1310
+ inst,
1311
+ continue: !def.abort
1312
+ });
1313
+ if (input > maximum) payload.issues.push({
1314
+ origin: "number",
1315
+ input,
1316
+ code: "too_big",
1317
+ maximum,
1318
+ inclusive: true,
1319
+ inst,
1320
+ continue: !def.abort
1321
+ });
1322
+ };
1323
+ });
1324
+ const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
1325
+ var _a$1;
1326
+ $ZodCheck.init(inst, def);
1327
+ (_a$1 = inst._zod.def).when ?? (_a$1.when = (payload) => {
1328
+ const val = payload.value;
1329
+ return !nullish(val) && val.length !== void 0;
1330
+ });
1331
+ inst._zod.onattach.push((inst$1) => {
1332
+ const curr = inst$1._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
1333
+ if (def.maximum < curr) inst$1._zod.bag.maximum = def.maximum;
1334
+ });
1335
+ inst._zod.check = (payload) => {
1336
+ const input = payload.value;
1337
+ if (input.length <= def.maximum) return;
1338
+ const origin = getLengthableOrigin(input);
1339
+ payload.issues.push({
1340
+ origin,
1341
+ code: "too_big",
1342
+ maximum: def.maximum,
1343
+ inclusive: true,
1344
+ input,
1345
+ inst,
1346
+ continue: !def.abort
1347
+ });
1348
+ };
1349
+ });
1350
+ const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
623
1351
  var _a$1;
624
1352
  $ZodCheck.init(inst, def);
625
1353
  (_a$1 = inst._zod.def).when ?? (_a$1.when = (payload) => {
@@ -681,6 +1409,123 @@ const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEqual
681
1409
  });
682
1410
  };
683
1411
  });
1412
+ const $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
1413
+ var _a$1, _b;
1414
+ $ZodCheck.init(inst, def);
1415
+ inst._zod.onattach.push((inst$1) => {
1416
+ const bag = inst$1._zod.bag;
1417
+ bag.format = def.format;
1418
+ if (def.pattern) {
1419
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1420
+ bag.patterns.add(def.pattern);
1421
+ }
1422
+ });
1423
+ if (def.pattern) (_a$1 = inst._zod).check ?? (_a$1.check = (payload) => {
1424
+ def.pattern.lastIndex = 0;
1425
+ if (def.pattern.test(payload.value)) return;
1426
+ payload.issues.push({
1427
+ origin: "string",
1428
+ code: "invalid_format",
1429
+ format: def.format,
1430
+ input: payload.value,
1431
+ ...def.pattern ? { pattern: def.pattern.toString() } : {},
1432
+ inst,
1433
+ continue: !def.abort
1434
+ });
1435
+ });
1436
+ else (_b = inst._zod).check ?? (_b.check = () => {});
1437
+ });
1438
+ const $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
1439
+ $ZodCheckStringFormat.init(inst, def);
1440
+ inst._zod.check = (payload) => {
1441
+ def.pattern.lastIndex = 0;
1442
+ if (def.pattern.test(payload.value)) return;
1443
+ payload.issues.push({
1444
+ origin: "string",
1445
+ code: "invalid_format",
1446
+ format: "regex",
1447
+ input: payload.value,
1448
+ pattern: def.pattern.toString(),
1449
+ inst,
1450
+ continue: !def.abort
1451
+ });
1452
+ };
1453
+ });
1454
+ const $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
1455
+ def.pattern ?? (def.pattern = lowercase);
1456
+ $ZodCheckStringFormat.init(inst, def);
1457
+ });
1458
+ const $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
1459
+ def.pattern ?? (def.pattern = uppercase);
1460
+ $ZodCheckStringFormat.init(inst, def);
1461
+ });
1462
+ const $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
1463
+ $ZodCheck.init(inst, def);
1464
+ const escapedRegex = escapeRegex(def.includes);
1465
+ const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
1466
+ def.pattern = pattern;
1467
+ inst._zod.onattach.push((inst$1) => {
1468
+ const bag = inst$1._zod.bag;
1469
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1470
+ bag.patterns.add(pattern);
1471
+ });
1472
+ inst._zod.check = (payload) => {
1473
+ if (payload.value.includes(def.includes, def.position)) return;
1474
+ payload.issues.push({
1475
+ origin: "string",
1476
+ code: "invalid_format",
1477
+ format: "includes",
1478
+ includes: def.includes,
1479
+ input: payload.value,
1480
+ inst,
1481
+ continue: !def.abort
1482
+ });
1483
+ };
1484
+ });
1485
+ const $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
1486
+ $ZodCheck.init(inst, def);
1487
+ const pattern = /* @__PURE__ */ new RegExp(`^${escapeRegex(def.prefix)}.*`);
1488
+ def.pattern ?? (def.pattern = pattern);
1489
+ inst._zod.onattach.push((inst$1) => {
1490
+ const bag = inst$1._zod.bag;
1491
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1492
+ bag.patterns.add(pattern);
1493
+ });
1494
+ inst._zod.check = (payload) => {
1495
+ if (payload.value.startsWith(def.prefix)) return;
1496
+ payload.issues.push({
1497
+ origin: "string",
1498
+ code: "invalid_format",
1499
+ format: "starts_with",
1500
+ prefix: def.prefix,
1501
+ input: payload.value,
1502
+ inst,
1503
+ continue: !def.abort
1504
+ });
1505
+ };
1506
+ });
1507
+ const $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
1508
+ $ZodCheck.init(inst, def);
1509
+ const pattern = /* @__PURE__ */ new RegExp(`.*${escapeRegex(def.suffix)}$`);
1510
+ def.pattern ?? (def.pattern = pattern);
1511
+ inst._zod.onattach.push((inst$1) => {
1512
+ const bag = inst$1._zod.bag;
1513
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1514
+ bag.patterns.add(pattern);
1515
+ });
1516
+ inst._zod.check = (payload) => {
1517
+ if (payload.value.endsWith(def.suffix)) return;
1518
+ payload.issues.push({
1519
+ origin: "string",
1520
+ code: "invalid_format",
1521
+ format: "ends_with",
1522
+ suffix: def.suffix,
1523
+ input: payload.value,
1524
+ inst,
1525
+ continue: !def.abort
1526
+ });
1527
+ };
1528
+ });
684
1529
  const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
685
1530
  $ZodCheck.init(inst, def);
686
1531
  inst._zod.check = (payload) => {
@@ -688,6 +1533,38 @@ const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (i
688
1533
  };
689
1534
  });
690
1535
 
1536
+ //#endregion
1537
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/doc.js
1538
+ var Doc = class {
1539
+ constructor(args = []) {
1540
+ this.content = [];
1541
+ this.indent = 0;
1542
+ if (this) this.args = args;
1543
+ }
1544
+ indented(fn) {
1545
+ this.indent += 1;
1546
+ fn(this);
1547
+ this.indent -= 1;
1548
+ }
1549
+ write(arg) {
1550
+ if (typeof arg === "function") {
1551
+ arg(this, { execution: "sync" });
1552
+ arg(this, { execution: "async" });
1553
+ return;
1554
+ }
1555
+ const lines = arg.split("\n").filter((x) => x);
1556
+ const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
1557
+ const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
1558
+ for (const line of dedented) this.content.push(line);
1559
+ }
1560
+ compile() {
1561
+ const F = Function;
1562
+ const args = this?.args;
1563
+ const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
1564
+ return new F(...args, lines.join("\n"));
1565
+ }
1566
+ };
1567
+
691
1568
  //#endregion
692
1569
  //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.js
693
1570
  const version = {
@@ -786,10 +1663,308 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
786
1663
  version: 1
787
1664
  }));
788
1665
  });
1666
+ const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
1667
+ $ZodType.init(inst, def);
1668
+ inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
1669
+ inst._zod.parse = (payload, _) => {
1670
+ if (def.coerce) try {
1671
+ payload.value = String(payload.value);
1672
+ } catch (_$1) {}
1673
+ if (typeof payload.value === "string") return payload;
1674
+ payload.issues.push({
1675
+ expected: "string",
1676
+ code: "invalid_type",
1677
+ input: payload.value,
1678
+ inst
1679
+ });
1680
+ return payload;
1681
+ };
1682
+ });
1683
+ const $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
1684
+ $ZodCheckStringFormat.init(inst, def);
1685
+ $ZodString.init(inst, def);
1686
+ });
1687
+ const $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
1688
+ def.pattern ?? (def.pattern = guid);
1689
+ $ZodStringFormat.init(inst, def);
1690
+ });
1691
+ const $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
1692
+ if (def.version) {
1693
+ const v = {
1694
+ v1: 1,
1695
+ v2: 2,
1696
+ v3: 3,
1697
+ v4: 4,
1698
+ v5: 5,
1699
+ v6: 6,
1700
+ v7: 7,
1701
+ v8: 8
1702
+ }[def.version];
1703
+ if (v === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
1704
+ def.pattern ?? (def.pattern = uuid(v));
1705
+ } else def.pattern ?? (def.pattern = uuid());
1706
+ $ZodStringFormat.init(inst, def);
1707
+ });
1708
+ const $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
1709
+ def.pattern ?? (def.pattern = email);
1710
+ $ZodStringFormat.init(inst, def);
1711
+ });
1712
+ const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
1713
+ $ZodStringFormat.init(inst, def);
1714
+ inst._zod.check = (payload) => {
1715
+ try {
1716
+ const trimmed = payload.value.trim();
1717
+ const url = new URL(trimmed);
1718
+ if (def.hostname) {
1719
+ def.hostname.lastIndex = 0;
1720
+ if (!def.hostname.test(url.hostname)) payload.issues.push({
1721
+ code: "invalid_format",
1722
+ format: "url",
1723
+ note: "Invalid hostname",
1724
+ pattern: def.hostname.source,
1725
+ input: payload.value,
1726
+ inst,
1727
+ continue: !def.abort
1728
+ });
1729
+ }
1730
+ if (def.protocol) {
1731
+ def.protocol.lastIndex = 0;
1732
+ if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
1733
+ code: "invalid_format",
1734
+ format: "url",
1735
+ note: "Invalid protocol",
1736
+ pattern: def.protocol.source,
1737
+ input: payload.value,
1738
+ inst,
1739
+ continue: !def.abort
1740
+ });
1741
+ }
1742
+ if (def.normalize) payload.value = url.href;
1743
+ else payload.value = trimmed;
1744
+ return;
1745
+ } catch (_) {
1746
+ payload.issues.push({
1747
+ code: "invalid_format",
1748
+ format: "url",
1749
+ input: payload.value,
1750
+ inst,
1751
+ continue: !def.abort
1752
+ });
1753
+ }
1754
+ };
1755
+ });
1756
+ const $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
1757
+ def.pattern ?? (def.pattern = emoji());
1758
+ $ZodStringFormat.init(inst, def);
1759
+ });
1760
+ const $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
1761
+ def.pattern ?? (def.pattern = nanoid);
1762
+ $ZodStringFormat.init(inst, def);
1763
+ });
1764
+ const $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
1765
+ def.pattern ?? (def.pattern = cuid);
1766
+ $ZodStringFormat.init(inst, def);
1767
+ });
1768
+ const $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
1769
+ def.pattern ?? (def.pattern = cuid2);
1770
+ $ZodStringFormat.init(inst, def);
1771
+ });
1772
+ const $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
1773
+ def.pattern ?? (def.pattern = ulid);
1774
+ $ZodStringFormat.init(inst, def);
1775
+ });
1776
+ const $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
1777
+ def.pattern ?? (def.pattern = xid);
1778
+ $ZodStringFormat.init(inst, def);
1779
+ });
1780
+ const $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
1781
+ def.pattern ?? (def.pattern = ksuid);
1782
+ $ZodStringFormat.init(inst, def);
1783
+ });
1784
+ const $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
1785
+ def.pattern ?? (def.pattern = datetime$1(def));
1786
+ $ZodStringFormat.init(inst, def);
1787
+ });
1788
+ const $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
1789
+ def.pattern ?? (def.pattern = date$1);
1790
+ $ZodStringFormat.init(inst, def);
1791
+ });
1792
+ const $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
1793
+ def.pattern ?? (def.pattern = time$1(def));
1794
+ $ZodStringFormat.init(inst, def);
1795
+ });
1796
+ const $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
1797
+ def.pattern ?? (def.pattern = duration$1);
1798
+ $ZodStringFormat.init(inst, def);
1799
+ });
1800
+ const $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
1801
+ def.pattern ?? (def.pattern = ipv4);
1802
+ $ZodStringFormat.init(inst, def);
1803
+ inst._zod.bag.format = `ipv4`;
1804
+ });
1805
+ const $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
1806
+ def.pattern ?? (def.pattern = ipv6);
1807
+ $ZodStringFormat.init(inst, def);
1808
+ inst._zod.bag.format = `ipv6`;
1809
+ inst._zod.check = (payload) => {
1810
+ try {
1811
+ new URL(`http://[${payload.value}]`);
1812
+ } catch {
1813
+ payload.issues.push({
1814
+ code: "invalid_format",
1815
+ format: "ipv6",
1816
+ input: payload.value,
1817
+ inst,
1818
+ continue: !def.abort
1819
+ });
1820
+ }
1821
+ };
1822
+ });
1823
+ const $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
1824
+ def.pattern ?? (def.pattern = cidrv4);
1825
+ $ZodStringFormat.init(inst, def);
1826
+ });
1827
+ const $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
1828
+ def.pattern ?? (def.pattern = cidrv6);
1829
+ $ZodStringFormat.init(inst, def);
1830
+ inst._zod.check = (payload) => {
1831
+ const parts = payload.value.split("/");
1832
+ try {
1833
+ if (parts.length !== 2) throw new Error();
1834
+ const [address, prefix] = parts;
1835
+ if (!prefix) throw new Error();
1836
+ const prefixNum = Number(prefix);
1837
+ if (`${prefixNum}` !== prefix) throw new Error();
1838
+ if (prefixNum < 0 || prefixNum > 128) throw new Error();
1839
+ new URL(`http://[${address}]`);
1840
+ } catch {
1841
+ payload.issues.push({
1842
+ code: "invalid_format",
1843
+ format: "cidrv6",
1844
+ input: payload.value,
1845
+ inst,
1846
+ continue: !def.abort
1847
+ });
1848
+ }
1849
+ };
1850
+ });
1851
+ function isValidBase64(data) {
1852
+ if (data === "") return true;
1853
+ if (data.length % 4 !== 0) return false;
1854
+ try {
1855
+ atob(data);
1856
+ return true;
1857
+ } catch {
1858
+ return false;
1859
+ }
1860
+ }
1861
+ const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
1862
+ def.pattern ?? (def.pattern = base64);
1863
+ $ZodStringFormat.init(inst, def);
1864
+ inst._zod.bag.contentEncoding = "base64";
1865
+ inst._zod.check = (payload) => {
1866
+ if (isValidBase64(payload.value)) return;
1867
+ payload.issues.push({
1868
+ code: "invalid_format",
1869
+ format: "base64",
1870
+ input: payload.value,
1871
+ inst,
1872
+ continue: !def.abort
1873
+ });
1874
+ };
1875
+ });
1876
+ function isValidBase64URL(data) {
1877
+ if (!base64url.test(data)) return false;
1878
+ const base64$1 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
1879
+ return isValidBase64(base64$1.padEnd(Math.ceil(base64$1.length / 4) * 4, "="));
1880
+ }
1881
+ const $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
1882
+ def.pattern ?? (def.pattern = base64url);
1883
+ $ZodStringFormat.init(inst, def);
1884
+ inst._zod.bag.contentEncoding = "base64url";
1885
+ inst._zod.check = (payload) => {
1886
+ if (isValidBase64URL(payload.value)) return;
1887
+ payload.issues.push({
1888
+ code: "invalid_format",
1889
+ format: "base64url",
1890
+ input: payload.value,
1891
+ inst,
1892
+ continue: !def.abort
1893
+ });
1894
+ };
1895
+ });
1896
+ const $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
1897
+ def.pattern ?? (def.pattern = e164);
1898
+ $ZodStringFormat.init(inst, def);
1899
+ });
1900
+ function isValidJWT(token, algorithm = null) {
1901
+ try {
1902
+ const tokensParts = token.split(".");
1903
+ if (tokensParts.length !== 3) return false;
1904
+ const [header] = tokensParts;
1905
+ if (!header) return false;
1906
+ const parsedHeader = JSON.parse(atob(header));
1907
+ if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
1908
+ if (!parsedHeader.alg) return false;
1909
+ if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
1910
+ return true;
1911
+ } catch {
1912
+ return false;
1913
+ }
1914
+ }
1915
+ const $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
1916
+ $ZodStringFormat.init(inst, def);
1917
+ inst._zod.check = (payload) => {
1918
+ if (isValidJWT(payload.value, def.alg)) return;
1919
+ payload.issues.push({
1920
+ code: "invalid_format",
1921
+ format: "jwt",
1922
+ input: payload.value,
1923
+ inst,
1924
+ continue: !def.abort
1925
+ });
1926
+ };
1927
+ });
1928
+ const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
1929
+ $ZodType.init(inst, def);
1930
+ inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
1931
+ inst._zod.parse = (payload, _ctx) => {
1932
+ if (def.coerce) try {
1933
+ payload.value = Number(payload.value);
1934
+ } catch (_) {}
1935
+ const input = payload.value;
1936
+ if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
1937
+ const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
1938
+ payload.issues.push({
1939
+ expected: "number",
1940
+ code: "invalid_type",
1941
+ input,
1942
+ inst,
1943
+ ...received ? { received } : {}
1944
+ });
1945
+ return payload;
1946
+ };
1947
+ });
1948
+ const $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, def) => {
1949
+ $ZodCheckNumberFormat.init(inst, def);
1950
+ $ZodNumber.init(inst, def);
1951
+ });
789
1952
  const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
790
1953
  $ZodType.init(inst, def);
791
1954
  inst._zod.parse = (payload) => payload;
792
1955
  });
1956
+ const $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
1957
+ $ZodType.init(inst, def);
1958
+ inst._zod.parse = (payload, _ctx) => {
1959
+ payload.issues.push({
1960
+ expected: "never",
1961
+ code: "invalid_type",
1962
+ input: payload.value,
1963
+ inst
1964
+ });
1965
+ return payload;
1966
+ };
1967
+ });
793
1968
  function handleArrayResult(result, final, index) {
794
1969
  if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
795
1970
  final.value[index] = result.value;
@@ -818,8 +1993,209 @@ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
818
1993
  if (result instanceof Promise) proms.push(result.then((result$1) => handleArrayResult(result$1, payload, i)));
819
1994
  else handleArrayResult(result, payload, i);
820
1995
  }
821
- if (proms.length) return Promise.all(proms).then(() => payload);
822
- return payload;
1996
+ if (proms.length) return Promise.all(proms).then(() => payload);
1997
+ return payload;
1998
+ };
1999
+ });
2000
+ function handlePropertyResult(result, final, key, input, isOptionalOut) {
2001
+ if (result.issues.length) {
2002
+ if (isOptionalOut && !(key in input)) return;
2003
+ final.issues.push(...prefixIssues(key, result.issues));
2004
+ }
2005
+ if (result.value === void 0) {
2006
+ if (key in input) final.value[key] = void 0;
2007
+ } else final.value[key] = result.value;
2008
+ }
2009
+ function normalizeDef(def) {
2010
+ const keys = Object.keys(def.shape);
2011
+ for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
2012
+ const okeys = optionalKeys(def.shape);
2013
+ return {
2014
+ ...def,
2015
+ keys,
2016
+ keySet: new Set(keys),
2017
+ numKeys: keys.length,
2018
+ optionalKeys: new Set(okeys)
2019
+ };
2020
+ }
2021
+ function handleCatchall(proms, input, payload, ctx, def, inst) {
2022
+ const unrecognized = [];
2023
+ const keySet = def.keySet;
2024
+ const _catchall = def.catchall._zod;
2025
+ const t = _catchall.def.type;
2026
+ const isOptionalOut = _catchall.optout === "optional";
2027
+ for (const key in input) {
2028
+ if (keySet.has(key)) continue;
2029
+ if (t === "never") {
2030
+ unrecognized.push(key);
2031
+ continue;
2032
+ }
2033
+ const r = _catchall.run({
2034
+ value: input[key],
2035
+ issues: []
2036
+ }, ctx);
2037
+ if (r instanceof Promise) proms.push(r.then((r$1) => handlePropertyResult(r$1, payload, key, input, isOptionalOut)));
2038
+ else handlePropertyResult(r, payload, key, input, isOptionalOut);
2039
+ }
2040
+ if (unrecognized.length) payload.issues.push({
2041
+ code: "unrecognized_keys",
2042
+ keys: unrecognized,
2043
+ input,
2044
+ inst
2045
+ });
2046
+ if (!proms.length) return payload;
2047
+ return Promise.all(proms).then(() => {
2048
+ return payload;
2049
+ });
2050
+ }
2051
+ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
2052
+ $ZodType.init(inst, def);
2053
+ if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
2054
+ const sh = def.shape;
2055
+ Object.defineProperty(def, "shape", { get: () => {
2056
+ const newSh = { ...sh };
2057
+ Object.defineProperty(def, "shape", { value: newSh });
2058
+ return newSh;
2059
+ } });
2060
+ }
2061
+ const _normalized = cached(() => normalizeDef(def));
2062
+ defineLazy(inst._zod, "propValues", () => {
2063
+ const shape = def.shape;
2064
+ const propValues = {};
2065
+ for (const key in shape) {
2066
+ const field = shape[key]._zod;
2067
+ if (field.values) {
2068
+ propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
2069
+ for (const v of field.values) propValues[key].add(v);
2070
+ }
2071
+ }
2072
+ return propValues;
2073
+ });
2074
+ const isObject$1 = isObject;
2075
+ const catchall = def.catchall;
2076
+ let value;
2077
+ inst._zod.parse = (payload, ctx) => {
2078
+ value ?? (value = _normalized.value);
2079
+ const input = payload.value;
2080
+ if (!isObject$1(input)) {
2081
+ payload.issues.push({
2082
+ expected: "object",
2083
+ code: "invalid_type",
2084
+ input,
2085
+ inst
2086
+ });
2087
+ return payload;
2088
+ }
2089
+ payload.value = {};
2090
+ const proms = [];
2091
+ const shape = value.shape;
2092
+ for (const key of value.keys) {
2093
+ const el = shape[key];
2094
+ const isOptionalOut = el._zod.optout === "optional";
2095
+ const r = el._zod.run({
2096
+ value: input[key],
2097
+ issues: []
2098
+ }, ctx);
2099
+ if (r instanceof Promise) proms.push(r.then((r$1) => handlePropertyResult(r$1, payload, key, input, isOptionalOut)));
2100
+ else handlePropertyResult(r, payload, key, input, isOptionalOut);
2101
+ }
2102
+ if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
2103
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
2104
+ };
2105
+ });
2106
+ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
2107
+ $ZodObject.init(inst, def);
2108
+ const superParse = inst._zod.parse;
2109
+ const _normalized = cached(() => normalizeDef(def));
2110
+ const generateFastpass = (shape) => {
2111
+ const doc = new Doc([
2112
+ "shape",
2113
+ "payload",
2114
+ "ctx"
2115
+ ]);
2116
+ const normalized = _normalized.value;
2117
+ const parseStr = (key) => {
2118
+ const k = esc(key);
2119
+ return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
2120
+ };
2121
+ doc.write(`const input = payload.value;`);
2122
+ const ids = Object.create(null);
2123
+ let counter = 0;
2124
+ for (const key of normalized.keys) ids[key] = `key_${counter++}`;
2125
+ doc.write(`const newResult = {};`);
2126
+ for (const key of normalized.keys) {
2127
+ const id = ids[key];
2128
+ const k = esc(key);
2129
+ const isOptionalOut = shape[key]?._zod?.optout === "optional";
2130
+ doc.write(`const ${id} = ${parseStr(key)};`);
2131
+ if (isOptionalOut) doc.write(`
2132
+ if (${id}.issues.length) {
2133
+ if (${k} in input) {
2134
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2135
+ ...iss,
2136
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
2137
+ })));
2138
+ }
2139
+ }
2140
+
2141
+ if (${id}.value === undefined) {
2142
+ if (${k} in input) {
2143
+ newResult[${k}] = undefined;
2144
+ }
2145
+ } else {
2146
+ newResult[${k}] = ${id}.value;
2147
+ }
2148
+
2149
+ `);
2150
+ else doc.write(`
2151
+ if (${id}.issues.length) {
2152
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2153
+ ...iss,
2154
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
2155
+ })));
2156
+ }
2157
+
2158
+ if (${id}.value === undefined) {
2159
+ if (${k} in input) {
2160
+ newResult[${k}] = undefined;
2161
+ }
2162
+ } else {
2163
+ newResult[${k}] = ${id}.value;
2164
+ }
2165
+
2166
+ `);
2167
+ }
2168
+ doc.write(`payload.value = newResult;`);
2169
+ doc.write(`return payload;`);
2170
+ const fn = doc.compile();
2171
+ return (payload, ctx) => fn(shape, payload, ctx);
2172
+ };
2173
+ let fastpass;
2174
+ const isObject$1 = isObject;
2175
+ const jit = !globalConfig.jitless;
2176
+ const allowsEval$1 = allowsEval;
2177
+ const fastEnabled = jit && allowsEval$1.value;
2178
+ const catchall = def.catchall;
2179
+ let value;
2180
+ inst._zod.parse = (payload, ctx) => {
2181
+ value ?? (value = _normalized.value);
2182
+ const input = payload.value;
2183
+ if (!isObject$1(input)) {
2184
+ payload.issues.push({
2185
+ expected: "object",
2186
+ code: "invalid_type",
2187
+ input,
2188
+ inst
2189
+ });
2190
+ return payload;
2191
+ }
2192
+ if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
2193
+ if (!fastpass) fastpass = generateFastpass(def.shape);
2194
+ payload = fastpass(payload, ctx);
2195
+ if (!catchall) return payload;
2196
+ return handleCatchall([], input, payload, ctx, value, inst);
2197
+ }
2198
+ return superParse(payload, ctx);
823
2199
  };
824
2200
  });
825
2201
  function handleUnionResults(results, final, inst, ctx) {
@@ -977,6 +2353,115 @@ function handleIntersectionResults(result, left, right) {
977
2353
  result.value = merged.data;
978
2354
  return result;
979
2355
  }
2356
+ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
2357
+ $ZodType.init(inst, def);
2358
+ inst._zod.parse = (payload, ctx) => {
2359
+ const input = payload.value;
2360
+ if (!isPlainObject(input)) {
2361
+ payload.issues.push({
2362
+ expected: "record",
2363
+ code: "invalid_type",
2364
+ input,
2365
+ inst
2366
+ });
2367
+ return payload;
2368
+ }
2369
+ const proms = [];
2370
+ const values = def.keyType._zod.values;
2371
+ if (values) {
2372
+ payload.value = {};
2373
+ const recordKeys = /* @__PURE__ */ new Set();
2374
+ for (const key of values) if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
2375
+ recordKeys.add(typeof key === "number" ? key.toString() : key);
2376
+ const result = def.valueType._zod.run({
2377
+ value: input[key],
2378
+ issues: []
2379
+ }, ctx);
2380
+ if (result instanceof Promise) proms.push(result.then((result$1) => {
2381
+ if (result$1.issues.length) payload.issues.push(...prefixIssues(key, result$1.issues));
2382
+ payload.value[key] = result$1.value;
2383
+ }));
2384
+ else {
2385
+ if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
2386
+ payload.value[key] = result.value;
2387
+ }
2388
+ }
2389
+ let unrecognized;
2390
+ for (const key in input) if (!recordKeys.has(key)) {
2391
+ unrecognized = unrecognized ?? [];
2392
+ unrecognized.push(key);
2393
+ }
2394
+ if (unrecognized && unrecognized.length > 0) payload.issues.push({
2395
+ code: "unrecognized_keys",
2396
+ input,
2397
+ inst,
2398
+ keys: unrecognized
2399
+ });
2400
+ } else {
2401
+ payload.value = {};
2402
+ for (const key of Reflect.ownKeys(input)) {
2403
+ if (key === "__proto__") continue;
2404
+ let keyResult = def.keyType._zod.run({
2405
+ value: key,
2406
+ issues: []
2407
+ }, ctx);
2408
+ if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
2409
+ if (typeof key === "string" && number$1.test(key) && keyResult.issues.length) {
2410
+ const retryResult = def.keyType._zod.run({
2411
+ value: Number(key),
2412
+ issues: []
2413
+ }, ctx);
2414
+ if (retryResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
2415
+ if (retryResult.issues.length === 0) keyResult = retryResult;
2416
+ }
2417
+ if (keyResult.issues.length) {
2418
+ if (def.mode === "loose") payload.value[key] = input[key];
2419
+ else payload.issues.push({
2420
+ code: "invalid_key",
2421
+ origin: "record",
2422
+ issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
2423
+ input: key,
2424
+ path: [key],
2425
+ inst
2426
+ });
2427
+ continue;
2428
+ }
2429
+ const result = def.valueType._zod.run({
2430
+ value: input[key],
2431
+ issues: []
2432
+ }, ctx);
2433
+ if (result instanceof Promise) proms.push(result.then((result$1) => {
2434
+ if (result$1.issues.length) payload.issues.push(...prefixIssues(key, result$1.issues));
2435
+ payload.value[keyResult.value] = result$1.value;
2436
+ }));
2437
+ else {
2438
+ if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
2439
+ payload.value[keyResult.value] = result.value;
2440
+ }
2441
+ }
2442
+ }
2443
+ if (proms.length) return Promise.all(proms).then(() => payload);
2444
+ return payload;
2445
+ };
2446
+ });
2447
+ const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
2448
+ $ZodType.init(inst, def);
2449
+ const values = getEnumValues(def.entries);
2450
+ const valuesSet = new Set(values);
2451
+ inst._zod.values = valuesSet;
2452
+ inst._zod.pattern = /* @__PURE__ */ new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
2453
+ inst._zod.parse = (payload, _ctx) => {
2454
+ const input = payload.value;
2455
+ if (valuesSet.has(input)) return payload;
2456
+ payload.issues.push({
2457
+ code: "invalid_value",
2458
+ values,
2459
+ input,
2460
+ inst
2461
+ });
2462
+ return payload;
2463
+ };
2464
+ });
980
2465
  const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
981
2466
  $ZodType.init(inst, def);
982
2467
  inst._zod.parse = (payload, ctx) => {
@@ -1246,14 +2731,353 @@ var $ZodRegistry = class {
1246
2731
  function registry() {
1247
2732
  return new $ZodRegistry();
1248
2733
  }
1249
- (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
1250
- const globalRegistry = globalThis.__zod_globalRegistry;
1251
-
1252
- //#endregion
1253
- //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/api.js
2734
+ (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2735
+ const globalRegistry = globalThis.__zod_globalRegistry;
2736
+
2737
+ //#endregion
2738
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/api.js
2739
+ /* @__NO_SIDE_EFFECTS__ */
2740
+ function _string(Class, params) {
2741
+ return new Class({
2742
+ type: "string",
2743
+ ...normalizeParams(params)
2744
+ });
2745
+ }
2746
+ /* @__NO_SIDE_EFFECTS__ */
2747
+ function _email(Class, params) {
2748
+ return new Class({
2749
+ type: "string",
2750
+ format: "email",
2751
+ check: "string_format",
2752
+ abort: false,
2753
+ ...normalizeParams(params)
2754
+ });
2755
+ }
2756
+ /* @__NO_SIDE_EFFECTS__ */
2757
+ function _guid(Class, params) {
2758
+ return new Class({
2759
+ type: "string",
2760
+ format: "guid",
2761
+ check: "string_format",
2762
+ abort: false,
2763
+ ...normalizeParams(params)
2764
+ });
2765
+ }
2766
+ /* @__NO_SIDE_EFFECTS__ */
2767
+ function _uuid(Class, params) {
2768
+ return new Class({
2769
+ type: "string",
2770
+ format: "uuid",
2771
+ check: "string_format",
2772
+ abort: false,
2773
+ ...normalizeParams(params)
2774
+ });
2775
+ }
2776
+ /* @__NO_SIDE_EFFECTS__ */
2777
+ function _uuidv4(Class, params) {
2778
+ return new Class({
2779
+ type: "string",
2780
+ format: "uuid",
2781
+ check: "string_format",
2782
+ abort: false,
2783
+ version: "v4",
2784
+ ...normalizeParams(params)
2785
+ });
2786
+ }
2787
+ /* @__NO_SIDE_EFFECTS__ */
2788
+ function _uuidv6(Class, params) {
2789
+ return new Class({
2790
+ type: "string",
2791
+ format: "uuid",
2792
+ check: "string_format",
2793
+ abort: false,
2794
+ version: "v6",
2795
+ ...normalizeParams(params)
2796
+ });
2797
+ }
2798
+ /* @__NO_SIDE_EFFECTS__ */
2799
+ function _uuidv7(Class, params) {
2800
+ return new Class({
2801
+ type: "string",
2802
+ format: "uuid",
2803
+ check: "string_format",
2804
+ abort: false,
2805
+ version: "v7",
2806
+ ...normalizeParams(params)
2807
+ });
2808
+ }
2809
+ /* @__NO_SIDE_EFFECTS__ */
2810
+ function _url(Class, params) {
2811
+ return new Class({
2812
+ type: "string",
2813
+ format: "url",
2814
+ check: "string_format",
2815
+ abort: false,
2816
+ ...normalizeParams(params)
2817
+ });
2818
+ }
2819
+ /* @__NO_SIDE_EFFECTS__ */
2820
+ function _emoji(Class, params) {
2821
+ return new Class({
2822
+ type: "string",
2823
+ format: "emoji",
2824
+ check: "string_format",
2825
+ abort: false,
2826
+ ...normalizeParams(params)
2827
+ });
2828
+ }
2829
+ /* @__NO_SIDE_EFFECTS__ */
2830
+ function _nanoid(Class, params) {
2831
+ return new Class({
2832
+ type: "string",
2833
+ format: "nanoid",
2834
+ check: "string_format",
2835
+ abort: false,
2836
+ ...normalizeParams(params)
2837
+ });
2838
+ }
2839
+ /* @__NO_SIDE_EFFECTS__ */
2840
+ function _cuid(Class, params) {
2841
+ return new Class({
2842
+ type: "string",
2843
+ format: "cuid",
2844
+ check: "string_format",
2845
+ abort: false,
2846
+ ...normalizeParams(params)
2847
+ });
2848
+ }
2849
+ /* @__NO_SIDE_EFFECTS__ */
2850
+ function _cuid2(Class, params) {
2851
+ return new Class({
2852
+ type: "string",
2853
+ format: "cuid2",
2854
+ check: "string_format",
2855
+ abort: false,
2856
+ ...normalizeParams(params)
2857
+ });
2858
+ }
2859
+ /* @__NO_SIDE_EFFECTS__ */
2860
+ function _ulid(Class, params) {
2861
+ return new Class({
2862
+ type: "string",
2863
+ format: "ulid",
2864
+ check: "string_format",
2865
+ abort: false,
2866
+ ...normalizeParams(params)
2867
+ });
2868
+ }
2869
+ /* @__NO_SIDE_EFFECTS__ */
2870
+ function _xid(Class, params) {
2871
+ return new Class({
2872
+ type: "string",
2873
+ format: "xid",
2874
+ check: "string_format",
2875
+ abort: false,
2876
+ ...normalizeParams(params)
2877
+ });
2878
+ }
2879
+ /* @__NO_SIDE_EFFECTS__ */
2880
+ function _ksuid(Class, params) {
2881
+ return new Class({
2882
+ type: "string",
2883
+ format: "ksuid",
2884
+ check: "string_format",
2885
+ abort: false,
2886
+ ...normalizeParams(params)
2887
+ });
2888
+ }
2889
+ /* @__NO_SIDE_EFFECTS__ */
2890
+ function _ipv4(Class, params) {
2891
+ return new Class({
2892
+ type: "string",
2893
+ format: "ipv4",
2894
+ check: "string_format",
2895
+ abort: false,
2896
+ ...normalizeParams(params)
2897
+ });
2898
+ }
2899
+ /* @__NO_SIDE_EFFECTS__ */
2900
+ function _ipv6(Class, params) {
2901
+ return new Class({
2902
+ type: "string",
2903
+ format: "ipv6",
2904
+ check: "string_format",
2905
+ abort: false,
2906
+ ...normalizeParams(params)
2907
+ });
2908
+ }
2909
+ /* @__NO_SIDE_EFFECTS__ */
2910
+ function _cidrv4(Class, params) {
2911
+ return new Class({
2912
+ type: "string",
2913
+ format: "cidrv4",
2914
+ check: "string_format",
2915
+ abort: false,
2916
+ ...normalizeParams(params)
2917
+ });
2918
+ }
2919
+ /* @__NO_SIDE_EFFECTS__ */
2920
+ function _cidrv6(Class, params) {
2921
+ return new Class({
2922
+ type: "string",
2923
+ format: "cidrv6",
2924
+ check: "string_format",
2925
+ abort: false,
2926
+ ...normalizeParams(params)
2927
+ });
2928
+ }
2929
+ /* @__NO_SIDE_EFFECTS__ */
2930
+ function _base64(Class, params) {
2931
+ return new Class({
2932
+ type: "string",
2933
+ format: "base64",
2934
+ check: "string_format",
2935
+ abort: false,
2936
+ ...normalizeParams(params)
2937
+ });
2938
+ }
2939
+ /* @__NO_SIDE_EFFECTS__ */
2940
+ function _base64url(Class, params) {
2941
+ return new Class({
2942
+ type: "string",
2943
+ format: "base64url",
2944
+ check: "string_format",
2945
+ abort: false,
2946
+ ...normalizeParams(params)
2947
+ });
2948
+ }
2949
+ /* @__NO_SIDE_EFFECTS__ */
2950
+ function _e164(Class, params) {
2951
+ return new Class({
2952
+ type: "string",
2953
+ format: "e164",
2954
+ check: "string_format",
2955
+ abort: false,
2956
+ ...normalizeParams(params)
2957
+ });
2958
+ }
2959
+ /* @__NO_SIDE_EFFECTS__ */
2960
+ function _jwt(Class, params) {
2961
+ return new Class({
2962
+ type: "string",
2963
+ format: "jwt",
2964
+ check: "string_format",
2965
+ abort: false,
2966
+ ...normalizeParams(params)
2967
+ });
2968
+ }
2969
+ /* @__NO_SIDE_EFFECTS__ */
2970
+ function _isoDateTime(Class, params) {
2971
+ return new Class({
2972
+ type: "string",
2973
+ format: "datetime",
2974
+ check: "string_format",
2975
+ offset: false,
2976
+ local: false,
2977
+ precision: null,
2978
+ ...normalizeParams(params)
2979
+ });
2980
+ }
2981
+ /* @__NO_SIDE_EFFECTS__ */
2982
+ function _isoDate(Class, params) {
2983
+ return new Class({
2984
+ type: "string",
2985
+ format: "date",
2986
+ check: "string_format",
2987
+ ...normalizeParams(params)
2988
+ });
2989
+ }
2990
+ /* @__NO_SIDE_EFFECTS__ */
2991
+ function _isoTime(Class, params) {
2992
+ return new Class({
2993
+ type: "string",
2994
+ format: "time",
2995
+ check: "string_format",
2996
+ precision: null,
2997
+ ...normalizeParams(params)
2998
+ });
2999
+ }
3000
+ /* @__NO_SIDE_EFFECTS__ */
3001
+ function _isoDuration(Class, params) {
3002
+ return new Class({
3003
+ type: "string",
3004
+ format: "duration",
3005
+ check: "string_format",
3006
+ ...normalizeParams(params)
3007
+ });
3008
+ }
3009
+ /* @__NO_SIDE_EFFECTS__ */
3010
+ function _number(Class, params) {
3011
+ return new Class({
3012
+ type: "number",
3013
+ checks: [],
3014
+ ...normalizeParams(params)
3015
+ });
3016
+ }
3017
+ /* @__NO_SIDE_EFFECTS__ */
3018
+ function _int(Class, params) {
3019
+ return new Class({
3020
+ type: "number",
3021
+ check: "number_format",
3022
+ abort: false,
3023
+ format: "safeint",
3024
+ ...normalizeParams(params)
3025
+ });
3026
+ }
3027
+ /* @__NO_SIDE_EFFECTS__ */
3028
+ function _unknown(Class) {
3029
+ return new Class({ type: "unknown" });
3030
+ }
3031
+ /* @__NO_SIDE_EFFECTS__ */
3032
+ function _never(Class, params) {
3033
+ return new Class({
3034
+ type: "never",
3035
+ ...normalizeParams(params)
3036
+ });
3037
+ }
3038
+ /* @__NO_SIDE_EFFECTS__ */
3039
+ function _lt(value, params) {
3040
+ return new $ZodCheckLessThan({
3041
+ check: "less_than",
3042
+ ...normalizeParams(params),
3043
+ value,
3044
+ inclusive: false
3045
+ });
3046
+ }
3047
+ /* @__NO_SIDE_EFFECTS__ */
3048
+ function _lte(value, params) {
3049
+ return new $ZodCheckLessThan({
3050
+ check: "less_than",
3051
+ ...normalizeParams(params),
3052
+ value,
3053
+ inclusive: true
3054
+ });
3055
+ }
3056
+ /* @__NO_SIDE_EFFECTS__ */
3057
+ function _gt(value, params) {
3058
+ return new $ZodCheckGreaterThan({
3059
+ check: "greater_than",
3060
+ ...normalizeParams(params),
3061
+ value,
3062
+ inclusive: false
3063
+ });
3064
+ }
3065
+ /* @__NO_SIDE_EFFECTS__ */
3066
+ function _gte(value, params) {
3067
+ return new $ZodCheckGreaterThan({
3068
+ check: "greater_than",
3069
+ ...normalizeParams(params),
3070
+ value,
3071
+ inclusive: true
3072
+ });
3073
+ }
1254
3074
  /* @__NO_SIDE_EFFECTS__ */
1255
- function _unknown(Class) {
1256
- return new Class({ type: "unknown" });
3075
+ function _multipleOf(value, params) {
3076
+ return new $ZodCheckMultipleOf({
3077
+ check: "multiple_of",
3078
+ ...normalizeParams(params),
3079
+ value
3080
+ });
1257
3081
  }
1258
3082
  /* @__NO_SIDE_EFFECTS__ */
1259
3083
  function _maxLength(maximum, params) {
@@ -1280,6 +3104,58 @@ function _length(length, params) {
1280
3104
  });
1281
3105
  }
1282
3106
  /* @__NO_SIDE_EFFECTS__ */
3107
+ function _regex(pattern, params) {
3108
+ return new $ZodCheckRegex({
3109
+ check: "string_format",
3110
+ format: "regex",
3111
+ ...normalizeParams(params),
3112
+ pattern
3113
+ });
3114
+ }
3115
+ /* @__NO_SIDE_EFFECTS__ */
3116
+ function _lowercase(params) {
3117
+ return new $ZodCheckLowerCase({
3118
+ check: "string_format",
3119
+ format: "lowercase",
3120
+ ...normalizeParams(params)
3121
+ });
3122
+ }
3123
+ /* @__NO_SIDE_EFFECTS__ */
3124
+ function _uppercase(params) {
3125
+ return new $ZodCheckUpperCase({
3126
+ check: "string_format",
3127
+ format: "uppercase",
3128
+ ...normalizeParams(params)
3129
+ });
3130
+ }
3131
+ /* @__NO_SIDE_EFFECTS__ */
3132
+ function _includes(includes, params) {
3133
+ return new $ZodCheckIncludes({
3134
+ check: "string_format",
3135
+ format: "includes",
3136
+ ...normalizeParams(params),
3137
+ includes
3138
+ });
3139
+ }
3140
+ /* @__NO_SIDE_EFFECTS__ */
3141
+ function _startsWith(prefix, params) {
3142
+ return new $ZodCheckStartsWith({
3143
+ check: "string_format",
3144
+ format: "starts_with",
3145
+ ...normalizeParams(params),
3146
+ prefix
3147
+ });
3148
+ }
3149
+ /* @__NO_SIDE_EFFECTS__ */
3150
+ function _endsWith(suffix, params) {
3151
+ return new $ZodCheckEndsWith({
3152
+ check: "string_format",
3153
+ format: "ends_with",
3154
+ ...normalizeParams(params),
3155
+ suffix
3156
+ });
3157
+ }
3158
+ /* @__NO_SIDE_EFFECTS__ */
1283
3159
  function _overwrite(tx) {
1284
3160
  return new $ZodCheckOverwrite({
1285
3161
  check: "overwrite",
@@ -1287,6 +3163,26 @@ function _overwrite(tx) {
1287
3163
  });
1288
3164
  }
1289
3165
  /* @__NO_SIDE_EFFECTS__ */
3166
+ function _normalize(form) {
3167
+ return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
3168
+ }
3169
+ /* @__NO_SIDE_EFFECTS__ */
3170
+ function _trim() {
3171
+ return /* @__PURE__ */ _overwrite((input) => input.trim());
3172
+ }
3173
+ /* @__NO_SIDE_EFFECTS__ */
3174
+ function _toLowerCase() {
3175
+ return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
3176
+ }
3177
+ /* @__NO_SIDE_EFFECTS__ */
3178
+ function _toUpperCase() {
3179
+ return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
3180
+ }
3181
+ /* @__NO_SIDE_EFFECTS__ */
3182
+ function _slugify() {
3183
+ return /* @__PURE__ */ _overwrite((input) => slugify(input));
3184
+ }
3185
+ /* @__NO_SIDE_EFFECTS__ */
1290
3186
  function _array(Class, element, params) {
1291
3187
  return new Class({
1292
3188
  type: "array",
@@ -2130,58 +4026,40 @@ let AIAgentExecutionHelpersFactory = class AIAgentExecutionHelpersFactory$1 {
2130
4026
  createConnectionCredentialExecutionContextFactory(credentialSessions) {
2131
4027
  return new ConnectionCredentialExecutionContextFactory(credentialSessions);
2132
4028
  }
2133
- createDynamicStructuredTool(entry, toolCredentialContext, item, itemIndex, items) {
2134
- if (entry.runtime.inputSchema == null) throw new Error(`Cannot create LangChain tool "${entry.config.name}": missing inputSchema (broken tool runtime resolution).`);
2135
- const schemaForOpenAi = this.createJsonSchemaRecord(entry.runtime.inputSchema, {
2136
- schemaName: entry.config.name,
2137
- requireObjectRoot: true
2138
- });
2139
- return new __langchain_core_tools.DynamicStructuredTool({
2140
- name: entry.config.name,
2141
- description: entry.config.description ?? entry.runtime.defaultDescription,
2142
- schema: schemaForOpenAi,
2143
- func: async (input) => {
2144
- const result = await entry.runtime.execute({
2145
- config: entry.config,
2146
- input,
2147
- ctx: toolCredentialContext,
2148
- item,
2149
- itemIndex,
2150
- items
2151
- });
2152
- return JSON.stringify(result);
2153
- }
2154
- });
2155
- }
2156
4029
  /**
2157
- * Produces a plain JSON Schema object for OpenAI tool parameters and LangChain tool invocation:
2158
- * - **Zod** `toJSONSchema(..., { target: "draft-07" })` so shapes match what `@cfworker/json-schema`
2159
- * expects (`required` must be an array; draft 2020-12 output can break validation).
2160
- * - Otherwise LangChain `toJsonSchema` (Standard Schema + JSON passthrough); if the result is still Zod
2161
- * (duplicate `zod` copies), fall back to Zod `toJSONSchema` with draft-07.
2162
- * - Strip root `$schema` for OpenAI; normalize invalid `required` keywords for cfworker; ensure `properties`.
4030
+ * Produces a plain JSON Schema object (`draft-07`) from a Zod schema, as needed by
4031
+ * OpenAI tool-parameter schemas and the structured-output repair prompt.
4032
+ * - Prefers the schema's **instance** `toJSONSchema(...)` method so we stay inside the Zod
4033
+ * instance that created the schema (works across consumer/framework tsx namespaces see
4034
+ * {@link ZodInstanceToJsonSchema}). Falls back to the framework-imported module function.
4035
+ * - Strips root `$schema` (OpenAI ignores it).
4036
+ * - Sanitizes `required` for cfworker json-schema compatibility (must be a string array or absent).
2163
4037
  */
2164
4038
  createJsonSchemaRecord(inputSchema, options) {
2165
- const draft07Params = { target: "draft-07" };
2166
- let converted;
2167
- if ((0, __langchain_core_utils_types.isInteropZodSchema)(inputSchema)) converted = toJSONSchema(inputSchema, draft07Params);
2168
- else {
2169
- converted = (0, __langchain_core_utils_json_schema.toJsonSchema)(inputSchema);
2170
- if ((0, __langchain_core_utils_types.isInteropZodSchema)(converted)) converted = toJSONSchema(inputSchema, draft07Params);
2171
- }
2172
- const { $schema: _draftSchemaOmitted,...rest } = converted;
2173
- if (options.requireObjectRoot && rest.type !== "object") throw new Error(`Cannot create LangChain tool "${options.schemaName}": tool input schema must be a JSON Schema object type (got type=${String(rest.type)}).`);
2174
- if (options.requireObjectRoot && rest.properties !== void 0 && (typeof rest.properties !== "object" || Array.isArray(rest.properties))) throw new Error(`Cannot create LangChain tool "${options.schemaName}": tool input schema "properties" must be an object (got ${JSON.stringify(rest.properties)}).`);
4039
+ const { $schema: _draftSchemaOmitted,...rest } = this.convertZodSchemaToJsonSchema(inputSchema, { target: "draft-07" });
4040
+ if (options.requireObjectRoot && rest.type !== "object") throw new Error(`Cannot create tool "${options.schemaName}": tool input schema must be a JSON Schema object type (got type=${String(rest.type)}).`);
4041
+ if (options.requireObjectRoot && rest.properties !== void 0 && (typeof rest.properties !== "object" || Array.isArray(rest.properties))) throw new Error(`Cannot create tool "${options.schemaName}": tool input schema "properties" must be an object (got ${JSON.stringify(rest.properties)}).`);
2175
4042
  if (options.requireObjectRoot && rest.properties === void 0) rest.properties = {};
2176
4043
  this.sanitizeJsonSchemaRequiredKeywordsForCfworker(rest);
2177
4044
  return rest;
2178
4045
  }
2179
4046
  /**
4047
+ * Runs Zod's `toJSONSchema` via the schema's own instance method when available, so consumer
4048
+ * schemas loaded under a different tsx namespace still convert correctly. If the caller handed us
4049
+ * a payload that lacks that method (e.g. a plain JSON Schema record or a Zod instance whose
4050
+ * prototype was stripped), we fall back to the framework-bundled module function.
4051
+ */
4052
+ convertZodSchemaToJsonSchema(inputSchema, params) {
4053
+ const candidate = inputSchema.toJSONSchema;
4054
+ if (typeof candidate === "function") return candidate.call(inputSchema, params);
4055
+ return toJSONSchema(inputSchema, params);
4056
+ }
4057
+ /**
2180
4058
  * `@cfworker/json-schema` iterates `schema.required` with `for...of`; it must be a string array or absent.
2181
4059
  */
2182
- sanitizeJsonSchemaRequiredKeywordsForCfworker(node$16) {
2183
- if (!node$16 || typeof node$16 !== "object" || Array.isArray(node$16)) return;
2184
- const o = node$16;
4060
+ sanitizeJsonSchemaRequiredKeywordsForCfworker(node$20) {
4061
+ if (!node$20 || typeof node$20 !== "object" || Array.isArray(node$20)) return;
4062
+ const o = node$20;
2185
4063
  const req = o.required;
2186
4064
  if (req !== void 0 && !Array.isArray(req)) delete o.required;
2187
4065
  else if (Array.isArray(req)) {
@@ -2223,6 +4101,214 @@ function __decorateParam(paramIndex, decorator) {
2223
4101
  };
2224
4102
  }
2225
4103
 
4104
+ //#endregion
4105
+ //#region src/chatModels/OpenAiStrictJsonSchemaFactory.ts
4106
+ var _ref$5;
4107
+ let OpenAiStrictJsonSchemaFactory = class OpenAiStrictJsonSchemaFactory$1 {
4108
+ constructor(executionHelpers) {
4109
+ this.executionHelpers = executionHelpers;
4110
+ }
4111
+ createStructuredOutputRecord(schema, options) {
4112
+ const record$1 = this.executionHelpers.createJsonSchemaRecord(schema, {
4113
+ schemaName: options.schemaName,
4114
+ requireObjectRoot: false
4115
+ });
4116
+ this.strictifyRecursive(record$1);
4117
+ if (options.title !== void 0) record$1.title = options.title;
4118
+ return record$1;
4119
+ }
4120
+ strictifyRecursive(node$20) {
4121
+ if (!node$20 || typeof node$20 !== "object" || Array.isArray(node$20)) return;
4122
+ const o = node$20;
4123
+ this.stripOpenAiRejectedKeywords(o);
4124
+ if (this.isObjectNode(o)) {
4125
+ const props = this.readPropertiesObject(o);
4126
+ o.properties = props;
4127
+ o.additionalProperties = false;
4128
+ o.required = Object.keys(props);
4129
+ for (const value of Object.values(props)) this.strictifyRecursive(value);
4130
+ }
4131
+ this.recurseIntoComposites(o);
4132
+ }
4133
+ stripOpenAiRejectedKeywords(o) {
4134
+ delete o["$schema"];
4135
+ delete o["unevaluatedProperties"];
4136
+ delete o["default"];
4137
+ }
4138
+ isObjectNode(o) {
4139
+ const typeIsObject = o.type === "object" || Array.isArray(o.type) && o.type.includes("object");
4140
+ const hasObjectProperties = o.properties !== void 0 && typeof o.properties === "object" && !Array.isArray(o.properties);
4141
+ return typeIsObject || hasObjectProperties;
4142
+ }
4143
+ readPropertiesObject(o) {
4144
+ if (o.properties && typeof o.properties === "object" && !Array.isArray(o.properties)) return o.properties;
4145
+ return {};
4146
+ }
4147
+ recurseIntoComposites(o) {
4148
+ for (const key of [
4149
+ "allOf",
4150
+ "anyOf",
4151
+ "oneOf",
4152
+ "prefixItems"
4153
+ ]) {
4154
+ const branch = o[key];
4155
+ if (Array.isArray(branch)) for (const sub of branch) this.strictifyRecursive(sub);
4156
+ }
4157
+ if (o.not) this.strictifyRecursive(o.not);
4158
+ if (o.items) if (Array.isArray(o.items)) for (const sub of o.items) this.strictifyRecursive(sub);
4159
+ else this.strictifyRecursive(o.items);
4160
+ for (const key of [
4161
+ "if",
4162
+ "then",
4163
+ "else"
4164
+ ]) if (o[key]) this.strictifyRecursive(o[key]);
4165
+ for (const key of ["$defs", "definitions"]) {
4166
+ const defs = o[key];
4167
+ if (defs && typeof defs === "object" && !Array.isArray(defs)) for (const sub of Object.values(defs)) this.strictifyRecursive(sub);
4168
+ }
4169
+ }
4170
+ };
4171
+ OpenAiStrictJsonSchemaFactory = __decorate([
4172
+ (0, __codemation_core.injectable)(),
4173
+ __decorateParam(0, (0, __codemation_core.inject)(AIAgentExecutionHelpersFactory)),
4174
+ __decorateMetadata("design:paramtypes", [typeof (_ref$5 = typeof AIAgentExecutionHelpersFactory !== "undefined" && AIAgentExecutionHelpersFactory) === "function" ? _ref$5 : Object])
4175
+ ], OpenAiStrictJsonSchemaFactory);
4176
+
4177
+ //#endregion
4178
+ //#region src/chatModels/openAiChatModelConfig.ts
4179
+ var OpenAIChatModelConfig = class {
4180
+ type = OpenAIChatModelFactory;
4181
+ presentation;
4182
+ provider = "openai";
4183
+ modelName;
4184
+ constructor(name, model, credentialSlotKey = "openai", presentationIn, options) {
4185
+ this.name = name;
4186
+ this.model = model;
4187
+ this.credentialSlotKey = credentialSlotKey;
4188
+ this.options = options;
4189
+ this.modelName = model;
4190
+ this.presentation = presentationIn ?? {
4191
+ icon: "builtin:openai",
4192
+ label: name
4193
+ };
4194
+ }
4195
+ getCredentialRequirements() {
4196
+ return [{
4197
+ slotKey: this.credentialSlotKey,
4198
+ label: "OpenAI API key",
4199
+ acceptedTypes: ["openai.apiKey"]
4200
+ }];
4201
+ }
4202
+ };
4203
+
4204
+ //#endregion
4205
+ //#region src/chatModels/OpenAiChatModelPresetsFactory.ts
4206
+ /**
4207
+ * Default OpenAI chat model configs for scaffolds and demos (icon + label match {@link OpenAIChatModelConfig} defaults).
4208
+ * Prefer importing {@link openAiChatModelPresets} from here or from the consumer template re-export
4209
+ * instead of repeating {@link OpenAIChatModelConfig} construction in app workflows.
4210
+ */
4211
+ var OpenAiChatModelPresets = class {
4212
+ demoGpt4oMini = new OpenAIChatModelConfig("OpenAI", "gpt-4o-mini");
4213
+ demoGpt41 = new OpenAIChatModelConfig("OpenAI", "gpt-4.1");
4214
+ };
4215
+ const openAiChatModelPresets = new OpenAiChatModelPresets();
4216
+
4217
+ //#endregion
4218
+ //#region src/nodes/AgentMessageFactory.ts
4219
+ /**
4220
+ * AI-SDK-shaped message construction for the AIAgent stack. Emits plain `ModelMessage[]`
4221
+ * ( `{ role: 'system' | 'user' | 'assistant' | 'tool', content: ... }` ) as consumed by
4222
+ * `generateText({ messages })` from the `ai` package.
4223
+ */
4224
+ var AgentMessageFactory = class AgentMessageFactory {
4225
+ static createPromptMessages(messages) {
4226
+ return messages.map((message) => this.createPromptMessage(message));
4227
+ }
4228
+ /**
4229
+ * Builds the assistant message that contains optional text plus one or more tool-call parts,
4230
+ * matching the shape AI SDK emits between steps.
4231
+ */
4232
+ static createAssistantWithToolCalls(text, toolCalls) {
4233
+ const content = [];
4234
+ if (text && text.length > 0) content.push({
4235
+ type: "text",
4236
+ text
4237
+ });
4238
+ for (const toolCall of toolCalls) content.push({
4239
+ type: "tool-call",
4240
+ toolCallId: toolCall.id ?? toolCall.name,
4241
+ toolName: toolCall.name,
4242
+ input: toolCall.input ?? {}
4243
+ });
4244
+ return {
4245
+ role: "assistant",
4246
+ content
4247
+ };
4248
+ }
4249
+ /**
4250
+ * Builds the `{ role: "tool", content: [{ type: "tool-result", ... }, ...] }` message returned
4251
+ * to the model after each tool round.
4252
+ */
4253
+ static createToolResultsMessage(executedToolCalls) {
4254
+ return {
4255
+ role: "tool",
4256
+ content: executedToolCalls.map((executed) => ({
4257
+ type: "tool-result",
4258
+ toolCallId: executed.toolCallId,
4259
+ toolName: executed.toolName,
4260
+ output: {
4261
+ type: "json",
4262
+ value: AgentMessageFactory.toToolResultJson(executed.result)
4263
+ }
4264
+ }))
4265
+ };
4266
+ }
4267
+ static toToolResultJson(value) {
4268
+ if (value === void 0) return null;
4269
+ try {
4270
+ return JSON.parse(JSON.stringify(value));
4271
+ } catch {
4272
+ return String(value);
4273
+ }
4274
+ }
4275
+ static createPromptMessage(message) {
4276
+ if (message.role === "system") return {
4277
+ role: "system",
4278
+ content: message.content
4279
+ };
4280
+ if (message.role === "assistant") return {
4281
+ role: "assistant",
4282
+ content: message.content
4283
+ };
4284
+ return {
4285
+ role: "user",
4286
+ content: message.content
4287
+ };
4288
+ }
4289
+ };
4290
+
4291
+ //#endregion
4292
+ //#region src/nodes/AgentOutputFactory.ts
4293
+ var AgentOutputFactory = class {
4294
+ static fromUnknown(value) {
4295
+ return { main: [{ json: value }] };
4296
+ }
4297
+ static replaceJson(item, value) {
4298
+ return {
4299
+ ...item,
4300
+ json: value
4301
+ };
4302
+ }
4303
+ static fromAgentContent(content) {
4304
+ try {
4305
+ return JSON.parse(content);
4306
+ } catch {
4307
+ return { output: content };
4308
+ }
4309
+ }
4310
+ };
4311
+
2226
4312
  //#endregion
2227
4313
  //#region src/nodes/AgentStructuredOutputRepairPromptFactory.ts
2228
4314
  var _ref$4, _AgentStructuredOutputRepairPromptFactory;
@@ -2263,6 +4349,37 @@ AgentStructuredOutputRepairPromptFactory = _AgentStructuredOutputRepairPromptFac
2263
4349
  __decorateMetadata("design:paramtypes", [typeof (_ref$4 = typeof AIAgentExecutionHelpersFactory !== "undefined" && AIAgentExecutionHelpersFactory) === "function" ? _ref$4 : Object])
2264
4350
  ], AgentStructuredOutputRepairPromptFactory);
2265
4351
 
4352
+ //#endregion
4353
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/iso.js
4354
+ const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
4355
+ $ZodISODateTime.init(inst, def);
4356
+ ZodStringFormat.init(inst, def);
4357
+ });
4358
+ function datetime(params) {
4359
+ return _isoDateTime(ZodISODateTime, params);
4360
+ }
4361
+ const ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
4362
+ $ZodISODate.init(inst, def);
4363
+ ZodStringFormat.init(inst, def);
4364
+ });
4365
+ function date(params) {
4366
+ return _isoDate(ZodISODate, params);
4367
+ }
4368
+ const ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
4369
+ $ZodISOTime.init(inst, def);
4370
+ ZodStringFormat.init(inst, def);
4371
+ });
4372
+ function time(params) {
4373
+ return _isoTime(ZodISOTime, params);
4374
+ }
4375
+ const ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
4376
+ $ZodISODuration.init(inst, def);
4377
+ ZodStringFormat.init(inst, def);
4378
+ });
4379
+ function duration(params) {
4380
+ return _isoDuration(ZodISODuration, params);
4381
+ }
4382
+
2266
4383
  //#endregion
2267
4384
  //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/errors.js
2268
4385
  const initializer = (inst, issues) => {
@@ -2380,6 +4497,181 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
2380
4497
  inst.apply = (fn) => fn(inst);
2381
4498
  return inst;
2382
4499
  });
4500
+ /** @internal */
4501
+ const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
4502
+ $ZodString.init(inst, def);
4503
+ ZodType.init(inst, def);
4504
+ inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
4505
+ const bag = inst._zod.bag;
4506
+ inst.format = bag.format ?? null;
4507
+ inst.minLength = bag.minimum ?? null;
4508
+ inst.maxLength = bag.maximum ?? null;
4509
+ inst.regex = (...args) => inst.check(_regex(...args));
4510
+ inst.includes = (...args) => inst.check(_includes(...args));
4511
+ inst.startsWith = (...args) => inst.check(_startsWith(...args));
4512
+ inst.endsWith = (...args) => inst.check(_endsWith(...args));
4513
+ inst.min = (...args) => inst.check(_minLength(...args));
4514
+ inst.max = (...args) => inst.check(_maxLength(...args));
4515
+ inst.length = (...args) => inst.check(_length(...args));
4516
+ inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
4517
+ inst.lowercase = (params) => inst.check(_lowercase(params));
4518
+ inst.uppercase = (params) => inst.check(_uppercase(params));
4519
+ inst.trim = () => inst.check(_trim());
4520
+ inst.normalize = (...args) => inst.check(_normalize(...args));
4521
+ inst.toLowerCase = () => inst.check(_toLowerCase());
4522
+ inst.toUpperCase = () => inst.check(_toUpperCase());
4523
+ inst.slugify = () => inst.check(_slugify());
4524
+ });
4525
+ const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
4526
+ $ZodString.init(inst, def);
4527
+ _ZodString.init(inst, def);
4528
+ inst.email = (params) => inst.check(_email(ZodEmail, params));
4529
+ inst.url = (params) => inst.check(_url(ZodURL, params));
4530
+ inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
4531
+ inst.emoji = (params) => inst.check(_emoji(ZodEmoji, params));
4532
+ inst.guid = (params) => inst.check(_guid(ZodGUID, params));
4533
+ inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
4534
+ inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
4535
+ inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
4536
+ inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
4537
+ inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
4538
+ inst.guid = (params) => inst.check(_guid(ZodGUID, params));
4539
+ inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
4540
+ inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
4541
+ inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
4542
+ inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
4543
+ inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
4544
+ inst.xid = (params) => inst.check(_xid(ZodXID, params));
4545
+ inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
4546
+ inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
4547
+ inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
4548
+ inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
4549
+ inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
4550
+ inst.e164 = (params) => inst.check(_e164(ZodE164, params));
4551
+ inst.datetime = (params) => inst.check(datetime(params));
4552
+ inst.date = (params) => inst.check(date(params));
4553
+ inst.time = (params) => inst.check(time(params));
4554
+ inst.duration = (params) => inst.check(duration(params));
4555
+ });
4556
+ function string(params) {
4557
+ return _string(ZodString, params);
4558
+ }
4559
+ const ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
4560
+ $ZodStringFormat.init(inst, def);
4561
+ _ZodString.init(inst, def);
4562
+ });
4563
+ const ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (inst, def) => {
4564
+ $ZodEmail.init(inst, def);
4565
+ ZodStringFormat.init(inst, def);
4566
+ });
4567
+ const ZodGUID = /* @__PURE__ */ $constructor("ZodGUID", (inst, def) => {
4568
+ $ZodGUID.init(inst, def);
4569
+ ZodStringFormat.init(inst, def);
4570
+ });
4571
+ const ZodUUID = /* @__PURE__ */ $constructor("ZodUUID", (inst, def) => {
4572
+ $ZodUUID.init(inst, def);
4573
+ ZodStringFormat.init(inst, def);
4574
+ });
4575
+ const ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
4576
+ $ZodURL.init(inst, def);
4577
+ ZodStringFormat.init(inst, def);
4578
+ });
4579
+ const ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
4580
+ $ZodEmoji.init(inst, def);
4581
+ ZodStringFormat.init(inst, def);
4582
+ });
4583
+ const ZodNanoID = /* @__PURE__ */ $constructor("ZodNanoID", (inst, def) => {
4584
+ $ZodNanoID.init(inst, def);
4585
+ ZodStringFormat.init(inst, def);
4586
+ });
4587
+ const ZodCUID = /* @__PURE__ */ $constructor("ZodCUID", (inst, def) => {
4588
+ $ZodCUID.init(inst, def);
4589
+ ZodStringFormat.init(inst, def);
4590
+ });
4591
+ const ZodCUID2 = /* @__PURE__ */ $constructor("ZodCUID2", (inst, def) => {
4592
+ $ZodCUID2.init(inst, def);
4593
+ ZodStringFormat.init(inst, def);
4594
+ });
4595
+ const ZodULID = /* @__PURE__ */ $constructor("ZodULID", (inst, def) => {
4596
+ $ZodULID.init(inst, def);
4597
+ ZodStringFormat.init(inst, def);
4598
+ });
4599
+ const ZodXID = /* @__PURE__ */ $constructor("ZodXID", (inst, def) => {
4600
+ $ZodXID.init(inst, def);
4601
+ ZodStringFormat.init(inst, def);
4602
+ });
4603
+ const ZodKSUID = /* @__PURE__ */ $constructor("ZodKSUID", (inst, def) => {
4604
+ $ZodKSUID.init(inst, def);
4605
+ ZodStringFormat.init(inst, def);
4606
+ });
4607
+ const ZodIPv4 = /* @__PURE__ */ $constructor("ZodIPv4", (inst, def) => {
4608
+ $ZodIPv4.init(inst, def);
4609
+ ZodStringFormat.init(inst, def);
4610
+ });
4611
+ const ZodIPv6 = /* @__PURE__ */ $constructor("ZodIPv6", (inst, def) => {
4612
+ $ZodIPv6.init(inst, def);
4613
+ ZodStringFormat.init(inst, def);
4614
+ });
4615
+ const ZodCIDRv4 = /* @__PURE__ */ $constructor("ZodCIDRv4", (inst, def) => {
4616
+ $ZodCIDRv4.init(inst, def);
4617
+ ZodStringFormat.init(inst, def);
4618
+ });
4619
+ const ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (inst, def) => {
4620
+ $ZodCIDRv6.init(inst, def);
4621
+ ZodStringFormat.init(inst, def);
4622
+ });
4623
+ const ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
4624
+ $ZodBase64.init(inst, def);
4625
+ ZodStringFormat.init(inst, def);
4626
+ });
4627
+ const ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
4628
+ $ZodBase64URL.init(inst, def);
4629
+ ZodStringFormat.init(inst, def);
4630
+ });
4631
+ const ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
4632
+ $ZodE164.init(inst, def);
4633
+ ZodStringFormat.init(inst, def);
4634
+ });
4635
+ const ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
4636
+ $ZodJWT.init(inst, def);
4637
+ ZodStringFormat.init(inst, def);
4638
+ });
4639
+ const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
4640
+ $ZodNumber.init(inst, def);
4641
+ ZodType.init(inst, def);
4642
+ inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
4643
+ inst.gt = (value, params) => inst.check(_gt(value, params));
4644
+ inst.gte = (value, params) => inst.check(_gte(value, params));
4645
+ inst.min = (value, params) => inst.check(_gte(value, params));
4646
+ inst.lt = (value, params) => inst.check(_lt(value, params));
4647
+ inst.lte = (value, params) => inst.check(_lte(value, params));
4648
+ inst.max = (value, params) => inst.check(_lte(value, params));
4649
+ inst.int = (params) => inst.check(int(params));
4650
+ inst.safe = (params) => inst.check(int(params));
4651
+ inst.positive = (params) => inst.check(_gt(0, params));
4652
+ inst.nonnegative = (params) => inst.check(_gte(0, params));
4653
+ inst.negative = (params) => inst.check(_lt(0, params));
4654
+ inst.nonpositive = (params) => inst.check(_lte(0, params));
4655
+ inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
4656
+ inst.step = (value, params) => inst.check(_multipleOf(value, params));
4657
+ inst.finite = () => inst;
4658
+ const bag = inst._zod.bag;
4659
+ inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
4660
+ inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
4661
+ inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
4662
+ inst.isFinite = true;
4663
+ inst.format = bag.format ?? null;
4664
+ });
4665
+ function number(params) {
4666
+ return _number(ZodNumber, params);
4667
+ }
4668
+ const ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
4669
+ $ZodNumberFormat.init(inst, def);
4670
+ ZodNumber.init(inst, def);
4671
+ });
4672
+ function int(params) {
4673
+ return _int(ZodNumberFormat, params);
4674
+ }
2383
4675
  const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
2384
4676
  $ZodUnknown.init(inst, def);
2385
4677
  ZodType.init(inst, def);
@@ -2388,6 +4680,14 @@ const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
2388
4680
  function unknown() {
2389
4681
  return _unknown(ZodUnknown);
2390
4682
  }
4683
+ const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
4684
+ $ZodNever.init(inst, def);
4685
+ ZodType.init(inst, def);
4686
+ inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
4687
+ });
4688
+ function never(params) {
4689
+ return _never(ZodNever, params);
4690
+ }
2391
4691
  const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
2392
4692
  $ZodArray.init(inst, def);
2393
4693
  ZodType.init(inst, def);
@@ -2402,6 +4702,53 @@ const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
2402
4702
  function array(element, params) {
2403
4703
  return _array(ZodArray, element, params);
2404
4704
  }
4705
+ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
4706
+ $ZodObjectJIT.init(inst, def);
4707
+ ZodType.init(inst, def);
4708
+ inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
4709
+ defineLazy(inst, "shape", () => {
4710
+ return def.shape;
4711
+ });
4712
+ inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
4713
+ inst.catchall = (catchall) => inst.clone({
4714
+ ...inst._zod.def,
4715
+ catchall
4716
+ });
4717
+ inst.passthrough = () => inst.clone({
4718
+ ...inst._zod.def,
4719
+ catchall: unknown()
4720
+ });
4721
+ inst.loose = () => inst.clone({
4722
+ ...inst._zod.def,
4723
+ catchall: unknown()
4724
+ });
4725
+ inst.strict = () => inst.clone({
4726
+ ...inst._zod.def,
4727
+ catchall: never()
4728
+ });
4729
+ inst.strip = () => inst.clone({
4730
+ ...inst._zod.def,
4731
+ catchall: void 0
4732
+ });
4733
+ inst.extend = (incoming) => {
4734
+ return extend(inst, incoming);
4735
+ };
4736
+ inst.safeExtend = (incoming) => {
4737
+ return safeExtend(inst, incoming);
4738
+ };
4739
+ inst.merge = (other) => merge(inst, other);
4740
+ inst.pick = (mask) => pick(inst, mask);
4741
+ inst.omit = (mask) => omit(inst, mask);
4742
+ inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
4743
+ inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
4744
+ });
4745
+ function object(shape, params) {
4746
+ return new ZodObject({
4747
+ type: "object",
4748
+ shape: shape ?? {},
4749
+ ...normalizeParams(params)
4750
+ });
4751
+ }
2405
4752
  const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
2406
4753
  $ZodUnion.init(inst, def);
2407
4754
  ZodType.init(inst, def);
@@ -2427,6 +4774,58 @@ function intersection(left, right) {
2427
4774
  right
2428
4775
  });
2429
4776
  }
4777
+ const ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
4778
+ $ZodRecord.init(inst, def);
4779
+ ZodType.init(inst, def);
4780
+ inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
4781
+ inst.keyType = def.keyType;
4782
+ inst.valueType = def.valueType;
4783
+ });
4784
+ function record(keyType, valueType, params) {
4785
+ return new ZodRecord({
4786
+ type: "record",
4787
+ keyType,
4788
+ valueType,
4789
+ ...normalizeParams(params)
4790
+ });
4791
+ }
4792
+ const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
4793
+ $ZodEnum.init(inst, def);
4794
+ ZodType.init(inst, def);
4795
+ inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
4796
+ inst.enum = def.entries;
4797
+ inst.options = Object.values(def.entries);
4798
+ const keys = new Set(Object.keys(def.entries));
4799
+ inst.extract = (values, params) => {
4800
+ const newEntries = {};
4801
+ for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
4802
+ else throw new Error(`Key ${value} not found in enum`);
4803
+ return new ZodEnum({
4804
+ ...def,
4805
+ checks: [],
4806
+ ...normalizeParams(params),
4807
+ entries: newEntries
4808
+ });
4809
+ };
4810
+ inst.exclude = (values, params) => {
4811
+ const newEntries = { ...def.entries };
4812
+ for (const value of values) if (keys.has(value)) delete newEntries[value];
4813
+ else throw new Error(`Key ${value} not found in enum`);
4814
+ return new ZodEnum({
4815
+ ...def,
4816
+ checks: [],
4817
+ ...normalizeParams(params),
4818
+ entries: newEntries
4819
+ });
4820
+ };
4821
+ });
4822
+ function _enum(values, params) {
4823
+ return new ZodEnum({
4824
+ type: "enum",
4825
+ entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values,
4826
+ ...normalizeParams(params)
4827
+ });
4828
+ }
2430
4829
  const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
2431
4830
  $ZodTransform.init(inst, def);
2432
4831
  ZodType.init(inst, def);
@@ -2601,31 +5000,26 @@ let AgentStructuredOutputRunner = class AgentStructuredOutputRunner$1 {
2601
5000
  _AgentStructuredOutputRunner = this;
2602
5001
  }
2603
5002
  static repairAttemptCount = 2;
2604
- constructor(repairPromptFactory, openAiStructuredOutputMethodFactory) {
5003
+ static structuredOutputSchemaName = "agent_output";
5004
+ constructor(repairPromptFactory, openAiStrictJsonSchemaFactory) {
2605
5005
  this.repairPromptFactory = repairPromptFactory;
2606
- this.openAiStructuredOutputMethodFactory = openAiStructuredOutputMethodFactory;
5006
+ this.openAiStrictJsonSchemaFactory = openAiStrictJsonSchemaFactory;
2607
5007
  }
2608
5008
  async resolve(args) {
2609
5009
  let lastFailure;
2610
- if (args.rawFinalResponse) {
2611
- const directResult = this.tryParseAndValidate(AgentMessageFactory.extractContent(args.rawFinalResponse), args.schema);
2612
- if (directResult.ok) return directResult.value;
2613
- lastFailure = directResult;
2614
- } else if (!this.supportsNativeStructuredOutput(args.model)) {
2615
- const rawResponse = await args.invokeTextModel(args.conversation);
2616
- const directResult = this.tryParseAndValidate(AgentMessageFactory.extractContent(rawResponse), args.schema);
5010
+ if (args.rawFinalText !== void 0) {
5011
+ const directResult = this.tryParseAndValidate(args.rawFinalText, args.schema);
2617
5012
  if (directResult.ok) return directResult.value;
2618
5013
  lastFailure = directResult;
2619
5014
  }
2620
5015
  try {
2621
- const nativeStructuredModel = this.createStructuredOutputModel(args.model, args.chatModelConfig, args.schema);
2622
- if (nativeStructuredModel) {
2623
- const nativeResult = this.tryValidateStructuredValue(await args.invokeStructuredModel(nativeStructuredModel, args.conversation), args.schema);
2624
- if (nativeResult.ok) return nativeResult.value;
2625
- lastFailure = nativeResult;
2626
- }
5016
+ const structuredOptions = this.resolveStructuredOutputOptions(args.chatModelConfig);
5017
+ const schemaForModel = this.resolveOutputSchemaForModel(args.schema, structuredOptions);
5018
+ const nativeResult = this.tryValidateStructuredValue(await args.invokeStructuredModel(schemaForModel, args.conversation, structuredOptions), args.schema);
5019
+ if (nativeResult.ok) return nativeResult.value;
5020
+ lastFailure = nativeResult;
2627
5021
  } catch (error) {
2628
- lastFailure = {
5022
+ lastFailure = lastFailure ?? {
2629
5023
  ok: false,
2630
5024
  invalidContent: "",
2631
5025
  validationError: `Native structured output failed: ${this.summarizeError(error)}`
@@ -2649,22 +5043,26 @@ let AgentStructuredOutputRunner = class AgentStructuredOutputRunner$1 {
2649
5043
  validationError: failure.validationError
2650
5044
  }))];
2651
5045
  const repairResponse = await args.invokeTextModel(repairMessages);
2652
- const repairResult = this.tryParseAndValidate(AgentMessageFactory.extractContent(repairResponse), args.schema);
5046
+ const repairResult = this.tryParseAndValidate(repairResponse.text, args.schema);
2653
5047
  if (repairResult.ok) return repairResult.value;
2654
5048
  failure = repairResult;
2655
5049
  }
2656
5050
  throw new Error(`Structured output required for AIAgent "${args.agentName}" (${args.nodeId}) but validation still failed after ${_AgentStructuredOutputRunner.repairAttemptCount} repair attempts: ${failure.validationError}`);
2657
5051
  }
2658
- createStructuredOutputModel(model, chatModelConfig, schema) {
2659
- if (!this.supportsNativeStructuredOutput(model)) return;
2660
- const options = this.getStructuredOutputOptions(chatModelConfig);
2661
- return model.withStructuredOutput(schema, options);
2662
- }
2663
- getStructuredOutputOptions(chatModelConfig) {
2664
- return this.openAiStructuredOutputMethodFactory.create(chatModelConfig) ?? { strict: true };
5052
+ /**
5053
+ * Chooses strict mode for OpenAI chat-model configs, off otherwise. Extendable in future for
5054
+ * other providers that adopt the same "supply a JSON Schema record directly" contract.
5055
+ */
5056
+ resolveStructuredOutputOptions(chatModelConfig) {
5057
+ if (chatModelConfig.type !== OpenAIChatModelFactory) return;
5058
+ return {
5059
+ strict: true,
5060
+ schemaName: _AgentStructuredOutputRunner.structuredOutputSchemaName
5061
+ };
2665
5062
  }
2666
- supportsNativeStructuredOutput(model) {
2667
- return typeof model.withStructuredOutput === "function";
5063
+ resolveOutputSchemaForModel(schema, options) {
5064
+ if (!options?.strict) return schema;
5065
+ return this.openAiStrictJsonSchemaFactory.createStructuredOutputRecord(schema, { schemaName: options.schemaName ?? _AgentStructuredOutputRunner.structuredOutputSchemaName });
2668
5066
  }
2669
5067
  tryParseAndValidate(content, schema) {
2670
5068
  try {
@@ -2698,7 +5096,7 @@ let AgentStructuredOutputRunner = class AgentStructuredOutputRunner$1 {
2698
5096
  }
2699
5097
  toJson(value) {
2700
5098
  try {
2701
- return JSON.stringify(value);
5099
+ return JSON.stringify(value) ?? String(value);
2702
5100
  } catch (error) {
2703
5101
  return `<<unserializable: ${this.summarizeError(error)}>>`;
2704
5102
  }
@@ -2707,8 +5105,8 @@ let AgentStructuredOutputRunner = class AgentStructuredOutputRunner$1 {
2707
5105
  AgentStructuredOutputRunner = _AgentStructuredOutputRunner = __decorate([
2708
5106
  (0, __codemation_core.injectable)(),
2709
5107
  __decorateParam(0, (0, __codemation_core.inject)(AgentStructuredOutputRepairPromptFactory)),
2710
- __decorateParam(1, (0, __codemation_core.inject)(OpenAIStructuredOutputMethodFactory)),
2711
- __decorateMetadata("design:paramtypes", [typeof (_ref$3 = typeof AgentStructuredOutputRepairPromptFactory !== "undefined" && AgentStructuredOutputRepairPromptFactory) === "function" ? _ref$3 : Object, typeof (_ref2$3 = typeof OpenAIStructuredOutputMethodFactory !== "undefined" && OpenAIStructuredOutputMethodFactory) === "function" ? _ref2$3 : Object])
5108
+ __decorateParam(1, (0, __codemation_core.inject)(OpenAiStrictJsonSchemaFactory)),
5109
+ __decorateMetadata("design:paramtypes", [typeof (_ref$3 = typeof AgentStructuredOutputRepairPromptFactory !== "undefined" && AgentStructuredOutputRepairPromptFactory) === "function" ? _ref$3 : Object, typeof (_ref2$3 = typeof OpenAiStrictJsonSchemaFactory !== "undefined" && OpenAiStrictJsonSchemaFactory) === "function" ? _ref2$3 : Object])
2712
5110
  ], AgentStructuredOutputRunner);
2713
5111
 
2714
5112
  //#endregion
@@ -2845,7 +5243,7 @@ let AgentToolExecutionCoordinator = class AgentToolExecutionCoordinator$1 {
2845
5243
  async executePlannedToolCall(args) {
2846
5244
  const { plannedToolCall, ctx } = args;
2847
5245
  const toolCallInputsByPort = AgentToolCallPortMap.fromInput(plannedToolCall.toolCall.input ?? {});
2848
- const invocationId = __codemation_core.ConnectionInvocationIdFactory.create();
5246
+ const invocationId = plannedToolCall.invocationId;
2849
5247
  const startedAt = /* @__PURE__ */ new Date();
2850
5248
  const span = ctx.telemetry.startChildSpan({
2851
5249
  name: "agent.tool.call",
@@ -2853,7 +5251,10 @@ let AgentToolExecutionCoordinator = class AgentToolExecutionCoordinator$1 {
2853
5251
  startedAt,
2854
5252
  attributes: {
2855
5253
  [__codemation_core.CodemationTelemetryAttributeNames.connectionInvocationId]: invocationId,
2856
- [__codemation_core.CodemationTelemetryAttributeNames.toolName]: plannedToolCall.binding.config.name
5254
+ [__codemation_core.CodemationTelemetryAttributeNames.toolName]: plannedToolCall.binding.config.name,
5255
+ ...ctx.iterationId ? { [__codemation_core.CodemationTelemetryAttributeNames.iterationId]: ctx.iterationId } : {},
5256
+ ...typeof ctx.itemIndex === "number" ? { [__codemation_core.CodemationTelemetryAttributeNames.iterationIndex]: ctx.itemIndex } : {},
5257
+ ...ctx.parentInvocationId ? { [__codemation_core.CodemationTelemetryAttributeNames.parentInvocationId]: ctx.parentInvocationId } : {}
2857
5258
  }
2858
5259
  });
2859
5260
  await ctx.nodeState?.markRunning({
@@ -2861,9 +5262,24 @@ let AgentToolExecutionCoordinator = class AgentToolExecutionCoordinator$1 {
2861
5262
  activationId: ctx.activationId,
2862
5263
  inputsByPort: toolCallInputsByPort
2863
5264
  });
5265
+ await ctx.nodeState?.appendConnectionInvocation({
5266
+ invocationId,
5267
+ connectionNodeId: plannedToolCall.nodeId,
5268
+ parentAgentNodeId: ctx.nodeId,
5269
+ parentAgentActivationId: ctx.activationId,
5270
+ status: "running",
5271
+ managedInput: this.toJsonValue(plannedToolCall.toolCall.input),
5272
+ queuedAt: startedAt.toISOString(),
5273
+ startedAt: startedAt.toISOString(),
5274
+ iterationId: ctx.iterationId,
5275
+ parentInvocationId: ctx.parentInvocationId
5276
+ });
2864
5277
  try {
2865
- const serialized = await plannedToolCall.binding.langChainTool.invoke(plannedToolCall.toolCall.input ?? {});
2866
- const result = this.parseToolOutput(serialized);
5278
+ const result = await plannedToolCall.binding.execute(plannedToolCall.toolCall.input ?? {}, {
5279
+ parentSpan: span,
5280
+ parentInvocationId: invocationId
5281
+ });
5282
+ const serialized = typeof result === "string" ? result : JSON.stringify(result);
2867
5283
  const finishedAt = /* @__PURE__ */ new Date();
2868
5284
  await ctx.nodeState?.markCompleted({
2869
5285
  nodeId: plannedToolCall.nodeId,
@@ -2895,7 +5311,9 @@ let AgentToolExecutionCoordinator = class AgentToolExecutionCoordinator$1 {
2895
5311
  managedOutput: this.toJsonValue(result),
2896
5312
  queuedAt: startedAt.toISOString(),
2897
5313
  startedAt: startedAt.toISOString(),
2898
- finishedAt: finishedAt.toISOString()
5314
+ finishedAt: finishedAt.toISOString(),
5315
+ iterationId: ctx.iterationId,
5316
+ parentInvocationId: ctx.parentInvocationId
2899
5317
  });
2900
5318
  return {
2901
5319
  toolName: plannedToolCall.binding.config.name,
@@ -2907,7 +5325,7 @@ let AgentToolExecutionCoordinator = class AgentToolExecutionCoordinator$1 {
2907
5325
  const classification = this.errorClassifier.classify({
2908
5326
  error,
2909
5327
  toolName: plannedToolCall.binding.config.name,
2910
- schema: plannedToolCall.binding.langChainTool.schema
5328
+ schema: plannedToolCall.binding.inputSchema
2911
5329
  });
2912
5330
  if (classification.kind !== "repairable_validation_error") {
2913
5331
  const effectiveError = classification.effectiveError;
@@ -3036,7 +5454,9 @@ let AgentToolExecutionCoordinator = class AgentToolExecutionCoordinator$1 {
3036
5454
  },
3037
5455
  queuedAt: args.startedAt.toISOString(),
3038
5456
  startedAt: args.startedAt.toISOString(),
3039
- finishedAt: finishedAt.toISOString()
5457
+ finishedAt: finishedAt.toISOString(),
5458
+ iterationId: args.ctx.iterationId,
5459
+ parentInvocationId: args.ctx.parentInvocationId
3040
5460
  });
3041
5461
  }
3042
5462
  createRepairPayload(args) {
@@ -3070,14 +5490,6 @@ let AgentToolExecutionCoordinator = class AgentToolExecutionCoordinator$1 {
3070
5490
  if (!firstIssue) return `Your previous tool call for "${toolName}" was invalid and did not match the expected schema.`;
3071
5491
  return `Your previous tool call for "${toolName}" was invalid because field "${firstIssue.path.length > 0 ? firstIssue.path.join(".") : "<root>"}" failed validation: ${firstIssue.message}`;
3072
5492
  }
3073
- parseToolOutput(serialized) {
3074
- if (typeof serialized !== "string") return serialized;
3075
- try {
3076
- return JSON.parse(serialized);
3077
- } catch {
3078
- return serialized;
3079
- }
3080
- }
3081
5493
  toJsonValue(value) {
3082
5494
  if (value === void 0) return;
3083
5495
  return JSON.parse(JSON.stringify(value));
@@ -3105,13 +5517,14 @@ AgentToolExecutionCoordinator = __decorate([
3105
5517
 
3106
5518
  //#endregion
3107
5519
  //#region src/nodes/NodeBackedToolRuntime.ts
3108
- var _ref$1, _ref2$1, _ref3$1;
5520
+ var _ref$1, _ref2$1, _ref3$1, _ref4$1;
3109
5521
  let NodeBackedToolRuntime = class NodeBackedToolRuntime$1 {
3110
- constructor(nodeResolver, itemExprResolver, outputNormalizer, outputBehaviorResolver) {
5522
+ constructor(nodeResolver, itemExprResolver, outputNormalizer, outputBehaviorResolver, childExecutionScopeFactory) {
3111
5523
  this.nodeResolver = nodeResolver;
3112
5524
  this.itemExprResolver = itemExprResolver;
3113
5525
  this.outputNormalizer = outputNormalizer;
3114
5526
  this.outputBehaviorResolver = outputBehaviorResolver;
5527
+ this.childExecutionScopeFactory = childExecutionScopeFactory;
3115
5528
  }
3116
5529
  async execute(config$1, args) {
3117
5530
  const nodeInput = config$1.toNodeItem({
@@ -3122,10 +5535,7 @@ let NodeBackedToolRuntime = class NodeBackedToolRuntime$1 {
3122
5535
  ctx: args.ctx,
3123
5536
  node: config$1.node
3124
5537
  });
3125
- const nodeCtx = {
3126
- ...args.ctx,
3127
- config: config$1.node
3128
- };
5538
+ const nodeCtx = this.resolveNodeCtx(config$1, args);
3129
5539
  const resolvedNode = this.nodeResolver.resolve(config$1.node.type);
3130
5540
  const outputs = await this.executeResolvedNode(resolvedNode, nodeInput, nodeCtx);
3131
5541
  return config$1.toToolOutput({
@@ -3138,6 +5548,35 @@ let NodeBackedToolRuntime = class NodeBackedToolRuntime$1 {
3138
5548
  outputs
3139
5549
  });
3140
5550
  }
5551
+ /**
5552
+ * Returns a re-rooted child ctx for nested-agent tools (so their LLM/tool connection ids derive
5553
+ * from the tool connection node, telemetry parents under the tool-call span, and connection
5554
+ * invocations carry `parentInvocationId`). Plain runnable tools (non-agent) keep the orchestrator
5555
+ * ctx with only `config` swapped — no nesting concern.
5556
+ *
5557
+ * The caller (`AIAgentNode.createItemScopedTools`) already wraps the orchestrator ctx via
5558
+ * `ConnectionCredentialExecutionContextFactory.forConnectionNode`, so `args.ctx.nodeId` is the
5559
+ * tool's own connection node id (e.g. `AIAgentNode:2__conn__tool__searchInMail`). We pass that
5560
+ * through as the sub-agent's `nodeId`; deriving another `toolConnectionNodeId(args.ctx.nodeId,
5561
+ * config.name)` here would prepend a duplicate `__conn__tool__<name>` segment and exponentially
5562
+ * deepen ids on each invocation, which also breaks credential resolution because user-provided
5563
+ * bindings sit on the single-level connection node id.
5564
+ */
5565
+ resolveNodeCtx(config$1, args) {
5566
+ const isNestedAgent = __codemation_core.AgentConfigInspector.isAgentNodeConfig(config$1.node);
5567
+ const hooks = args.hooks;
5568
+ if (!isNestedAgent || !hooks?.parentSpan || !hooks.parentInvocationId) return {
5569
+ ...args.ctx,
5570
+ config: config$1.node
5571
+ };
5572
+ return this.childExecutionScopeFactory.forSubAgent({
5573
+ parentCtx: args.ctx,
5574
+ childNodeId: args.ctx.nodeId,
5575
+ childConfig: config$1.node,
5576
+ parentInvocationId: hooks.parentInvocationId,
5577
+ parentSpan: hooks.parentSpan
5578
+ });
5579
+ }
3141
5580
  async executeResolvedNode(resolvedNode, nodeInput, ctx) {
3142
5581
  if (this.isMultiInputNode(resolvedNode)) return await resolvedNode.executeMulti({ in: [nodeInput] }, ctx);
3143
5582
  if (this.isRunnableNode(resolvedNode)) {
@@ -3175,11 +5614,13 @@ NodeBackedToolRuntime = __decorate([
3175
5614
  __decorateParam(1, (0, __codemation_core.inject)(__codemation_core.ItemExprResolver)),
3176
5615
  __decorateParam(2, (0, __codemation_core.inject)(__codemation_core.NodeOutputNormalizer)),
3177
5616
  __decorateParam(3, (0, __codemation_core.inject)(__codemation_core.RunnableOutputBehaviorResolver)),
5617
+ __decorateParam(4, (0, __codemation_core.inject)(__codemation_core.ChildExecutionScopeFactory)),
3178
5618
  __decorateMetadata("design:paramtypes", [
3179
5619
  Object,
3180
5620
  typeof (_ref$1 = typeof __codemation_core.ItemExprResolver !== "undefined" && __codemation_core.ItemExprResolver) === "function" ? _ref$1 : Object,
3181
5621
  typeof (_ref2$1 = typeof __codemation_core.NodeOutputNormalizer !== "undefined" && __codemation_core.NodeOutputNormalizer) === "function" ? _ref2$1 : Object,
3182
- typeof (_ref3$1 = typeof __codemation_core.RunnableOutputBehaviorResolver !== "undefined" && __codemation_core.RunnableOutputBehaviorResolver) === "function" ? _ref3$1 : Object
5622
+ typeof (_ref3$1 = typeof __codemation_core.RunnableOutputBehaviorResolver !== "undefined" && __codemation_core.RunnableOutputBehaviorResolver) === "function" ? _ref3$1 : Object,
5623
+ typeof (_ref4$1 = typeof __codemation_core.ChildExecutionScopeFactory !== "undefined" && __codemation_core.ChildExecutionScopeFactory) === "function" ? _ref4$1 : Object
3183
5624
  ])
3184
5625
  ], NodeBackedToolRuntime);
3185
5626
 
@@ -3197,14 +5638,8 @@ var _ref, _ref2, _ref3, _ref4;
3197
5638
  let AIAgentNode = class AIAgentNode$1 {
3198
5639
  kind = "node";
3199
5640
  outputPorts = ["main"];
3200
- /**
3201
- * Engine validates {@link RunnableNodeConfig.inputSchema} (Zod) on {@code item.json} before enqueue, then resolves
3202
- * per-item **`itemExpr`** leaves on config before {@link #execute}. Prefer modeling prompts as
3203
- * {@code { messages: [{ role, content }, ...] }} (on input or config) so persisted inputs are visible in the UI.
3204
- */
3205
5641
  inputSchema = unknown();
3206
5642
  connectionCredentialExecutionContextFactory;
3207
- /** One resolved model/tools bundle per activation context (same ctx across items in a batch). */
3208
5643
  preparedByExecutionContext = /* @__PURE__ */ new WeakMap();
3209
5644
  constructor(nodeResolver, credentialSessions, nodeBackedToolRuntime, executionHelpers, structuredOutputRunner, toolExecutionCoordinator) {
3210
5645
  this.nodeResolver = nodeResolver;
@@ -3235,9 +5670,6 @@ let AIAgentNode = class AIAgentNode$1 {
3235
5670
  throw error;
3236
5671
  }
3237
5672
  }
3238
- /**
3239
- * Resolves the chat model and tools once per activation, then reuses for every item in the batch.
3240
- */
3241
5673
  async prepareExecution(ctx) {
3242
5674
  const chatModelFactory = this.nodeResolver.resolve(ctx.config.chatModel.type);
3243
5675
  const languageModelCredentialContext = this.connectionCredentialExecutionContextFactory.forConnectionNode(ctx, {
@@ -3255,9 +5687,6 @@ let AIAgentNode = class AIAgentNode$1 {
3255
5687
  languageModelConnectionNodeId: __codemation_core.ConnectionNodeIdFactory.languageModelConnectionNodeId(ctx.nodeId)
3256
5688
  };
3257
5689
  }
3258
- /**
3259
- * One item: build prompts, optionally bind tools, run the multi-turn loop, map the final model message to workflow JSON.
3260
- */
3261
5690
  async runAgentForItem(prepared, item, itemIndex, items) {
3262
5691
  const { ctx } = prepared;
3263
5692
  const itemInputsByPort = AgentItemPortMap.fromItem(item);
@@ -3271,8 +5700,8 @@ let AIAgentNode = class AIAgentNode$1 {
3271
5700
  conversation,
3272
5701
  agentName: this.getAgentDisplayName(ctx),
3273
5702
  nodeId: ctx.nodeId,
3274
- invokeTextModel: async (messages) => await this.invokeModel(prepared.model, prepared.languageModelConnectionNodeId, messages, ctx, itemInputsByPort, prepared.guardrails.modelInvocationOptions),
3275
- invokeStructuredModel: async (structuredModel, messages) => await this.invokeStructuredModel(structuredModel, prepared.languageModelConnectionNodeId, messages, ctx, itemInputsByPort, prepared.guardrails.modelInvocationOptions)
5703
+ invokeTextModel: async (messages) => await this.invokeTextTurn(prepared, itemInputsByPort, messages, []),
5704
+ invokeStructuredModel: async (schema, messages, structuredOptions) => await this.invokeStructuredTurn(prepared, itemInputsByPort, schema, messages, structuredOptions)
3276
5705
  });
3277
5706
  await ctx.telemetry.recordMetric({
3278
5707
  name: __codemation_core.CodemationTelemetryMetricNames.agentTurns,
@@ -3284,13 +5713,11 @@ let AIAgentNode = class AIAgentNode$1 {
3284
5713
  });
3285
5714
  return this.buildOutputItem(item, structuredOutput);
3286
5715
  }
3287
- const modelWithTools = this.bindToolsToModel(prepared.model, itemScopedTools);
3288
5716
  const loopResult = await this.runTurnLoopUntilFinalAnswer({
3289
5717
  prepared,
3290
5718
  itemInputsByPort,
3291
5719
  itemScopedTools,
3292
- conversation,
3293
- modelWithTools
5720
+ conversation
3294
5721
  });
3295
5722
  await ctx.telemetry.recordMetric({
3296
5723
  name: __codemation_core.CodemationTelemetryMetricNames.agentTurns,
@@ -3300,30 +5727,34 @@ let AIAgentNode = class AIAgentNode$1 {
3300
5727
  name: __codemation_core.CodemationTelemetryMetricNames.agentToolCalls,
3301
5728
  value: loopResult.toolCallCount
3302
5729
  });
3303
- const outputJson = await this.resolveFinalOutputJson(prepared, itemInputsByPort, conversation, loopResult.finalResponse, itemScopedTools.length > 0);
5730
+ const outputJson = await this.resolveFinalOutputJson(prepared, itemInputsByPort, conversation, loopResult.finalText, itemScopedTools.length > 0);
3304
5731
  return this.buildOutputItem(item, outputJson);
3305
5732
  }
3306
5733
  /**
3307
- * Repeatedly invokes the model until it returns without tool calls, or guardrails end the loop.
5734
+ * Multi-turn loop:
5735
+ * - Each turn is a single `generateText` call with tools exposed but **not auto-executed**
5736
+ * (we control tool dispatch so that {@link AgentToolExecutionCoordinator} drives repair /
5737
+ * connection-invocation recording / transient-error handling exactly like before).
5738
+ * - When the model returns no tool calls the loop ends with the model's text as the final answer.
5739
+ * - Respects `guardrails.maxTurns` and `guardrails.onTurnLimitReached`.
3308
5740
  */
3309
5741
  async runTurnLoopUntilFinalAnswer(args) {
3310
- const { prepared, itemInputsByPort, itemScopedTools, conversation, modelWithTools } = args;
3311
- const { ctx, guardrails, languageModelConnectionNodeId } = prepared;
3312
- let finalResponse;
5742
+ const { prepared, itemInputsByPort, itemScopedTools, conversation } = args;
5743
+ const { ctx, guardrails } = prepared;
5744
+ let finalText = "";
3313
5745
  let toolCallCount = 0;
3314
5746
  let turnCount = 0;
3315
5747
  const repairAttemptsByToolName = /* @__PURE__ */ new Map();
3316
5748
  for (let turn = 1; turn <= guardrails.maxTurns; turn++) {
3317
5749
  turnCount = turn;
3318
- const response = await this.invokeModel(modelWithTools, languageModelConnectionNodeId, conversation, ctx, itemInputsByPort, guardrails.modelInvocationOptions);
3319
- finalResponse = response;
3320
- const toolCalls = AgentMessageFactory.extractToolCalls(response);
3321
- if (toolCalls.length === 0) break;
5750
+ const result = await this.invokeTextTurn(prepared, itemInputsByPort, conversation, itemScopedTools);
5751
+ finalText = result.text;
5752
+ if (result.toolCalls.length === 0) break;
3322
5753
  if (this.cannotExecuteAnotherToolRound(turn, guardrails)) {
3323
5754
  this.finishOrThrowWhenTurnCapHitWithToolCalls(ctx, guardrails);
3324
5755
  break;
3325
5756
  }
3326
- const plannedToolCalls = this.planToolCalls(itemScopedTools, toolCalls, ctx.nodeId);
5757
+ const plannedToolCalls = this.planToolCalls(itemScopedTools, result.toolCalls, ctx.nodeId);
3327
5758
  toolCallCount += plannedToolCalls.length;
3328
5759
  await this.markQueuedTools(plannedToolCalls, ctx);
3329
5760
  const executedToolCalls = await this.toolExecutionCoordinator.execute({
@@ -3332,11 +5763,10 @@ let AIAgentNode = class AIAgentNode$1 {
3332
5763
  agentName: this.getAgentDisplayName(ctx),
3333
5764
  repairAttemptsByToolName
3334
5765
  });
3335
- this.appendAssistantAndToolMessages(conversation, response, executedToolCalls);
5766
+ this.appendAssistantAndToolMessages(conversation, result.assistantMessage, result.text, result.toolCalls, executedToolCalls);
3336
5767
  }
3337
- if (!finalResponse) throw new Error(`AIAgent "${ctx.config.name ?? ctx.nodeId}" did not produce a model response.`);
3338
5768
  return {
3339
- finalResponse,
5769
+ finalText,
3340
5770
  turnCount,
3341
5771
  toolCallCount
3342
5772
  };
@@ -3348,30 +5778,30 @@ let AIAgentNode = class AIAgentNode$1 {
3348
5778
  if (guardrails.onTurnLimitReached === "respondWithLastMessage") return;
3349
5779
  throw new Error(`AIAgent "${ctx.config.name ?? ctx.nodeId}" reached maxTurns=${guardrails.maxTurns} before producing a final response.`);
3350
5780
  }
3351
- appendAssistantAndToolMessages(conversation, assistantMessage, executedToolCalls) {
3352
- conversation.push(assistantMessage, ...executedToolCalls.map((toolCall) => AgentMessageFactory.createToolMessage(toolCall.toolCallId, toolCall.serialized)));
5781
+ appendAssistantAndToolMessages(conversation, assistantMessage, text, toolCalls, executedToolCalls) {
5782
+ conversation.push(assistantMessage ?? AgentMessageFactory.createAssistantWithToolCalls(text, toolCalls), AgentMessageFactory.createToolResultsMessage(executedToolCalls));
3353
5783
  }
3354
- async resolveFinalOutputJson(prepared, itemInputsByPort, conversation, finalResponse, wasToolEnabledRun) {
3355
- if (!prepared.ctx.config.outputSchema) return AgentOutputFactory.fromAgentContent(AgentMessageFactory.extractContent(finalResponse));
5784
+ async resolveFinalOutputJson(prepared, itemInputsByPort, conversation, finalText, wasToolEnabledRun) {
5785
+ if (!prepared.ctx.config.outputSchema) return AgentOutputFactory.fromAgentContent(finalText);
5786
+ const conversationWithFinal = wasToolEnabledRun ? [...conversation, {
5787
+ role: "assistant",
5788
+ content: finalText
5789
+ }] : conversation;
3356
5790
  return await this.structuredOutputRunner.resolve({
3357
5791
  model: prepared.model,
3358
5792
  chatModelConfig: prepared.ctx.config.chatModel,
3359
5793
  schema: prepared.ctx.config.outputSchema,
3360
- conversation: wasToolEnabledRun ? [...conversation, finalResponse] : conversation,
3361
- rawFinalResponse: finalResponse,
5794
+ conversation: conversationWithFinal,
5795
+ rawFinalText: finalText,
3362
5796
  agentName: this.getAgentDisplayName(prepared.ctx),
3363
5797
  nodeId: prepared.ctx.nodeId,
3364
- invokeTextModel: async (messages) => await this.invokeModel(prepared.model, prepared.languageModelConnectionNodeId, messages, prepared.ctx, itemInputsByPort, prepared.guardrails.modelInvocationOptions),
3365
- invokeStructuredModel: async (structuredModel, messages) => await this.invokeStructuredModel(structuredModel, prepared.languageModelConnectionNodeId, messages, prepared.ctx, itemInputsByPort, prepared.guardrails.modelInvocationOptions)
5798
+ invokeTextModel: async (messages) => await this.invokeTextTurn(prepared, itemInputsByPort, messages, []),
5799
+ invokeStructuredModel: async (schema, messages, structuredOptions) => await this.invokeStructuredTurn(prepared, itemInputsByPort, schema, messages, structuredOptions)
3366
5800
  });
3367
5801
  }
3368
5802
  buildOutputItem(item, outputJson) {
3369
5803
  return AgentOutputFactory.replaceJson(item, outputJson);
3370
5804
  }
3371
- bindToolsToModel(model, itemScopedTools) {
3372
- if (itemScopedTools.length === 0 || !model.bindTools) return model;
3373
- return model.bindTools(itemScopedTools.map((entry) => entry.langChainTool));
3374
- }
3375
5805
  resolveTools(toolConfigs) {
3376
5806
  const resolvedTools = toolConfigs.map((config$1) => ({
3377
5807
  config: config$1,
@@ -3390,38 +5820,120 @@ let AIAgentNode = class AIAgentNode$1 {
3390
5820
  connectionNodeId: __codemation_core.ConnectionNodeIdFactory.toolConnectionNodeId(ctx.nodeId, entry.config.name),
3391
5821
  getCredentialRequirements: () => entry.config.getCredentialRequirements?.() ?? []
3392
5822
  });
3393
- const langChainTool = this.executionHelpers.createDynamicStructuredTool(entry, toolCredentialContext, item, itemIndex, items);
3394
5823
  return {
3395
5824
  config: entry.config,
3396
- langChainTool
5825
+ inputSchema: entry.runtime.inputSchema,
5826
+ execute: async (input, hooks) => {
5827
+ const validated = entry.runtime.inputSchema.parse(input);
5828
+ return await entry.runtime.execute({
5829
+ config: entry.config,
5830
+ input: validated,
5831
+ ctx: toolCredentialContext,
5832
+ item,
5833
+ itemIndex,
5834
+ items,
5835
+ hooks
5836
+ });
5837
+ }
3397
5838
  };
3398
5839
  });
3399
5840
  }
3400
- async invokeModel(model, nodeId, messages, ctx, inputsByPort, options) {
5841
+ /**
5842
+ * Builds an AI SDK {@link ToolSet} where every tool ships a pre-converted JSON Schema (via
5843
+ * {@link jsonSchema}) — not the raw Zod schema — and carries **no** `execute`. Two reasons:
5844
+ *
5845
+ * 1. Codemation owns tool dispatch + the per-tool repair loop (see {@link AgentToolExecutionCoordinator}),
5846
+ * so the AI SDK must surface tool calls back to us instead of auto-running them.
5847
+ * 2. The AI SDK's `asSchema` helper discriminates between Zod v3 / Zod v4 / Standard Schema via
5848
+ * runtime feature-detection (`~standard`, `_zod`, etc.). Handing it a pre-built
5849
+ * {@link jsonSchema} record — which is tagged with `Symbol.for('vercel.ai.schema')` — skips all
5850
+ * of that detection and guarantees the provider receives a draft-07 JSON Schema with
5851
+ * `additionalProperties: false` at every object depth (see {@link OpenAiStrictJsonSchemaFactory}
5852
+ * for the same logic applied to structured-output schemas). Codemation still runs its own Zod
5853
+ * validation on tool inputs before execute — the schema handed to the model is advisory.
5854
+ */
5855
+ buildToolSet(itemScopedTools) {
5856
+ if (itemScopedTools.length === 0) return void 0;
5857
+ const toolSet = {};
5858
+ for (const entry of itemScopedTools) {
5859
+ const schemaRecord = this.executionHelpers.createJsonSchemaRecord(entry.inputSchema, {
5860
+ schemaName: entry.config.name,
5861
+ requireObjectRoot: true
5862
+ });
5863
+ toolSet[entry.config.name] = {
5864
+ description: entry.config.description,
5865
+ inputSchema: (0, ai.jsonSchema)(schemaRecord)
5866
+ };
5867
+ }
5868
+ return toolSet;
5869
+ }
5870
+ /**
5871
+ * One `generateText` turn (no auto tool execution) with Codemation-owned child-span telemetry
5872
+ * and connection-invocation state recording.
5873
+ */
5874
+ async invokeTextTurn(prepared, itemInputsByPort, messages, itemScopedTools) {
3401
5875
  const invocationId = __codemation_core.ConnectionInvocationIdFactory.create();
3402
5876
  const startedAt = /* @__PURE__ */ new Date();
3403
5877
  const summarizedInput = this.summarizeLlmMessages(messages);
5878
+ const { ctx, model, languageModelConnectionNodeId, guardrails } = prepared;
3404
5879
  const span = this.createModelInvocationSpan(ctx, invocationId, startedAt);
3405
5880
  await ctx.nodeState?.markQueued({
3406
- nodeId,
5881
+ nodeId: languageModelConnectionNodeId,
3407
5882
  activationId: ctx.activationId,
3408
- inputsByPort
5883
+ inputsByPort: itemInputsByPort
5884
+ });
5885
+ await ctx.nodeState?.appendConnectionInvocation({
5886
+ invocationId,
5887
+ connectionNodeId: languageModelConnectionNodeId,
5888
+ parentAgentNodeId: ctx.nodeId,
5889
+ parentAgentActivationId: ctx.activationId,
5890
+ status: "queued",
5891
+ managedInput: summarizedInput,
5892
+ queuedAt: startedAt.toISOString(),
5893
+ iterationId: ctx.iterationId,
5894
+ itemIndex: ctx.itemIndex,
5895
+ parentInvocationId: ctx.parentInvocationId
3409
5896
  });
3410
5897
  await ctx.nodeState?.markRunning({
3411
- nodeId,
5898
+ nodeId: languageModelConnectionNodeId,
3412
5899
  activationId: ctx.activationId,
3413
- inputsByPort
5900
+ inputsByPort: itemInputsByPort
5901
+ });
5902
+ await ctx.nodeState?.appendConnectionInvocation({
5903
+ invocationId,
5904
+ connectionNodeId: languageModelConnectionNodeId,
5905
+ parentAgentNodeId: ctx.nodeId,
5906
+ parentAgentActivationId: ctx.activationId,
5907
+ status: "running",
5908
+ managedInput: summarizedInput,
5909
+ queuedAt: startedAt.toISOString(),
5910
+ startedAt: startedAt.toISOString(),
5911
+ iterationId: ctx.iterationId,
5912
+ itemIndex: ctx.itemIndex,
5913
+ parentInvocationId: ctx.parentInvocationId
3414
5914
  });
3415
5915
  try {
3416
- const response = await model.invoke(messages, options);
5916
+ const tools = this.buildToolSet(itemScopedTools);
5917
+ const callOptions = this.resolveCallOptions(model, guardrails.modelInvocationOptions);
5918
+ const result = await (0, ai.generateText)({
5919
+ model: model.languageModel,
5920
+ messages: [...messages],
5921
+ tools,
5922
+ toolChoice: tools ? "auto" : void 0,
5923
+ maxOutputTokens: callOptions.maxOutputTokens,
5924
+ temperature: callOptions.temperature,
5925
+ providerOptions: callOptions.providerOptions,
5926
+ maxRetries: 0
5927
+ });
5928
+ const turnResult = this.extractTurnResult(result);
3417
5929
  const finishedAt = /* @__PURE__ */ new Date();
5930
+ const managedOutput = this.summarizeTurnOutput(turnResult);
3418
5931
  await ctx.nodeState?.markCompleted({
3419
- nodeId,
5932
+ nodeId: languageModelConnectionNodeId,
3420
5933
  activationId: ctx.activationId,
3421
- inputsByPort,
3422
- outputs: AgentOutputFactory.fromUnknown({ content: AgentMessageFactory.extractContent(response) })
5934
+ inputsByPort: itemInputsByPort,
5935
+ outputs: AgentOutputFactory.fromUnknown(managedOutput)
3423
5936
  });
3424
- const content = AgentMessageFactory.extractContent(response);
3425
5937
  await span.attachArtifact({
3426
5938
  kind: "ai.messages",
3427
5939
  contentType: "application/json",
@@ -3430,26 +5942,29 @@ let AIAgentNode = class AIAgentNode$1 {
3430
5942
  await span.attachArtifact({
3431
5943
  kind: "ai.response",
3432
5944
  contentType: "application/json",
3433
- previewJson: content
5945
+ previewJson: turnResult.text
3434
5946
  });
3435
- await this.recordModelUsageMetrics(span, response, ctx);
5947
+ await this.recordModelUsageMetrics(span, turnResult.usage, ctx);
3436
5948
  await span.end({
3437
5949
  status: "ok",
3438
5950
  endedAt: finishedAt
3439
5951
  });
3440
5952
  await ctx.nodeState?.appendConnectionInvocation({
3441
5953
  invocationId,
3442
- connectionNodeId: nodeId,
5954
+ connectionNodeId: languageModelConnectionNodeId,
3443
5955
  parentAgentNodeId: ctx.nodeId,
3444
5956
  parentAgentActivationId: ctx.activationId,
3445
5957
  status: "completed",
3446
5958
  managedInput: summarizedInput,
3447
- managedOutput: content,
5959
+ managedOutput,
3448
5960
  queuedAt: startedAt.toISOString(),
3449
5961
  startedAt: startedAt.toISOString(),
3450
- finishedAt: finishedAt.toISOString()
5962
+ finishedAt: finishedAt.toISOString(),
5963
+ iterationId: ctx.iterationId,
5964
+ itemIndex: ctx.itemIndex,
5965
+ parentInvocationId: ctx.parentInvocationId
3451
5966
  });
3452
- return response;
5967
+ return turnResult;
3453
5968
  } catch (error) {
3454
5969
  await span.end({
3455
5970
  status: "error",
@@ -3460,36 +5975,78 @@ let AIAgentNode = class AIAgentNode$1 {
3460
5975
  error,
3461
5976
  invocationId,
3462
5977
  startedAt,
3463
- nodeId,
5978
+ nodeId: languageModelConnectionNodeId,
3464
5979
  ctx,
3465
- inputsByPort,
3466
- managedInput: this.summarizeLlmMessages(messages)
5980
+ inputsByPort: itemInputsByPort,
5981
+ managedInput: summarizedInput
3467
5982
  });
3468
5983
  }
3469
5984
  }
3470
- async invokeStructuredModel(model, nodeId, messages, ctx, inputsByPort, options) {
5985
+ /**
5986
+ * Structured-output turn: runs `generateText({ output: Output.object({ schema }) })` via the
5987
+ * structured-output runner. We keep this as a separate helper because the runner needs the raw
5988
+ * validated value (not just text) back, and must be able to retry on Zod failures.
5989
+ */
5990
+ async invokeStructuredTurn(prepared, itemInputsByPort, schema, messages, structuredOptions) {
3471
5991
  const invocationId = __codemation_core.ConnectionInvocationIdFactory.create();
3472
5992
  const startedAt = /* @__PURE__ */ new Date();
3473
5993
  const summarizedInput = this.summarizeLlmMessages(messages);
5994
+ const { ctx, model, languageModelConnectionNodeId, guardrails } = prepared;
3474
5995
  const span = this.createModelInvocationSpan(ctx, invocationId, startedAt);
3475
5996
  await ctx.nodeState?.markQueued({
3476
- nodeId,
5997
+ nodeId: languageModelConnectionNodeId,
3477
5998
  activationId: ctx.activationId,
3478
- inputsByPort
5999
+ inputsByPort: itemInputsByPort
6000
+ });
6001
+ await ctx.nodeState?.appendConnectionInvocation({
6002
+ invocationId,
6003
+ connectionNodeId: languageModelConnectionNodeId,
6004
+ parentAgentNodeId: ctx.nodeId,
6005
+ parentAgentActivationId: ctx.activationId,
6006
+ status: "queued",
6007
+ managedInput: summarizedInput,
6008
+ queuedAt: startedAt.toISOString(),
6009
+ iterationId: ctx.iterationId,
6010
+ itemIndex: ctx.itemIndex,
6011
+ parentInvocationId: ctx.parentInvocationId
3479
6012
  });
3480
6013
  await ctx.nodeState?.markRunning({
3481
- nodeId,
6014
+ nodeId: languageModelConnectionNodeId,
3482
6015
  activationId: ctx.activationId,
3483
- inputsByPort
6016
+ inputsByPort: itemInputsByPort
6017
+ });
6018
+ await ctx.nodeState?.appendConnectionInvocation({
6019
+ invocationId,
6020
+ connectionNodeId: languageModelConnectionNodeId,
6021
+ parentAgentNodeId: ctx.nodeId,
6022
+ parentAgentActivationId: ctx.activationId,
6023
+ status: "running",
6024
+ managedInput: summarizedInput,
6025
+ queuedAt: startedAt.toISOString(),
6026
+ startedAt: startedAt.toISOString(),
6027
+ iterationId: ctx.iterationId,
6028
+ itemIndex: ctx.itemIndex,
6029
+ parentInvocationId: ctx.parentInvocationId
3484
6030
  });
3485
6031
  try {
3486
- const response = await model.invoke(messages, options);
6032
+ const callOptions = this.resolveCallOptions(model, guardrails.modelInvocationOptions);
6033
+ const outputSchema = structuredOptions?.strict && !this.isZodSchema(schema) ? ai.Output.object({ schema: (0, ai.jsonSchema)(schema) }) : ai.Output.object({ schema });
6034
+ const result = await (0, ai.generateText)({
6035
+ model: model.languageModel,
6036
+ messages: [...messages],
6037
+ experimental_output: outputSchema,
6038
+ maxOutputTokens: callOptions.maxOutputTokens,
6039
+ temperature: callOptions.temperature,
6040
+ providerOptions: callOptions.providerOptions,
6041
+ maxRetries: 0
6042
+ });
6043
+ const turnResult = this.extractTurnResult(result);
3487
6044
  const finishedAt = /* @__PURE__ */ new Date();
3488
6045
  await ctx.nodeState?.markCompleted({
3489
- nodeId,
6046
+ nodeId: languageModelConnectionNodeId,
3490
6047
  activationId: ctx.activationId,
3491
- inputsByPort,
3492
- outputs: AgentOutputFactory.fromUnknown(response)
6048
+ inputsByPort: itemInputsByPort,
6049
+ outputs: AgentOutputFactory.fromUnknown(result.experimental_output)
3493
6050
  });
3494
6051
  await span.attachArtifact({
3495
6052
  kind: "ai.messages",
@@ -3499,26 +6056,29 @@ let AIAgentNode = class AIAgentNode$1 {
3499
6056
  await span.attachArtifact({
3500
6057
  kind: "ai.response.structured",
3501
6058
  contentType: "application/json",
3502
- previewJson: this.resultToJsonValue(response)
6059
+ previewJson: this.resultToJsonValue(result.experimental_output)
3503
6060
  });
3504
- await this.recordModelUsageMetrics(span, response, ctx);
6061
+ await this.recordModelUsageMetrics(span, turnResult.usage, ctx);
3505
6062
  await span.end({
3506
6063
  status: "ok",
3507
6064
  endedAt: finishedAt
3508
6065
  });
3509
6066
  await ctx.nodeState?.appendConnectionInvocation({
3510
6067
  invocationId,
3511
- connectionNodeId: nodeId,
6068
+ connectionNodeId: languageModelConnectionNodeId,
3512
6069
  parentAgentNodeId: ctx.nodeId,
3513
6070
  parentAgentActivationId: ctx.activationId,
3514
6071
  status: "completed",
3515
6072
  managedInput: summarizedInput,
3516
- managedOutput: this.resultToJsonValue(response),
6073
+ managedOutput: this.resultToJsonValue(result.experimental_output),
3517
6074
  queuedAt: startedAt.toISOString(),
3518
6075
  startedAt: startedAt.toISOString(),
3519
- finishedAt: finishedAt.toISOString()
6076
+ finishedAt: finishedAt.toISOString(),
6077
+ iterationId: ctx.iterationId,
6078
+ itemIndex: ctx.itemIndex,
6079
+ parentInvocationId: ctx.parentInvocationId
3520
6080
  });
3521
- return response;
6081
+ return result.experimental_output;
3522
6082
  } catch (error) {
3523
6083
  await span.end({
3524
6084
  status: "error",
@@ -3529,13 +6089,77 @@ let AIAgentNode = class AIAgentNode$1 {
3529
6089
  error,
3530
6090
  invocationId,
3531
6091
  startedAt,
3532
- nodeId,
6092
+ nodeId: languageModelConnectionNodeId,
3533
6093
  ctx,
3534
- inputsByPort,
3535
- managedInput: this.summarizeLlmMessages(messages)
6094
+ inputsByPort: itemInputsByPort,
6095
+ managedInput: summarizedInput
3536
6096
  });
3537
6097
  }
3538
6098
  }
6099
+ isZodSchema(schema) {
6100
+ return typeof schema.parse === "function";
6101
+ }
6102
+ resolveCallOptions(model, overrides) {
6103
+ const defaults = model.defaultCallOptions ?? {};
6104
+ return {
6105
+ maxOutputTokens: overrides?.maxTokens ?? defaults.maxOutputTokens,
6106
+ temperature: defaults.temperature,
6107
+ providerOptions: overrides?.providerOptions ?? defaults.providerOptions
6108
+ };
6109
+ }
6110
+ /**
6111
+ * Build a no-code-friendly output payload for an LLM round.
6112
+ *
6113
+ * Always includes `content` (matching the canvas snapshot shape used elsewhere) and adds a
6114
+ * `toolCalls` array when the round produced tool calls so the execution inspector surfaces the
6115
+ * planned calls instead of just an empty `""` for tool-only rounds.
6116
+ */
6117
+ summarizeTurnOutput(turnResult) {
6118
+ if (turnResult.toolCalls.length === 0) return { content: turnResult.text };
6119
+ const toolCalls = turnResult.toolCalls.map((toolCall) => ({
6120
+ name: toolCall.name,
6121
+ args: this.resultToJsonValue(toolCall.input) ?? null
6122
+ }));
6123
+ return {
6124
+ content: turnResult.text,
6125
+ toolCalls
6126
+ };
6127
+ }
6128
+ extractTurnResult(result) {
6129
+ const usage = this.extractUsageFromResult(result);
6130
+ const text = result.text;
6131
+ const toolCalls = result.toolCalls.map((toolCall) => ({
6132
+ id: toolCall.toolCallId,
6133
+ name: toolCall.toolName,
6134
+ input: toolCall.input
6135
+ }));
6136
+ return {
6137
+ assistantMessage: this.extractAssistantMessage(result),
6138
+ text,
6139
+ toolCalls,
6140
+ usage
6141
+ };
6142
+ }
6143
+ extractAssistantMessage(result) {
6144
+ const assistantMessages = result.response.messages.filter((m) => m.role === "assistant");
6145
+ return assistantMessages[assistantMessages.length - 1];
6146
+ }
6147
+ extractUsageFromResult(result) {
6148
+ const usage = result.usage;
6149
+ const inputTokens = this.toFiniteNumber(usage.inputTokens);
6150
+ const outputTokens = this.toFiniteNumber(usage.outputTokens);
6151
+ return {
6152
+ inputTokens,
6153
+ outputTokens,
6154
+ totalTokens: this.toFiniteNumber(usage.totalTokens) ?? (inputTokens !== void 0 && outputTokens !== void 0 ? inputTokens + outputTokens : void 0),
6155
+ cachedInputTokens: this.toFiniteNumber(usage.cachedInputTokens),
6156
+ reasoningTokens: this.toFiniteNumber(usage.reasoningTokens)
6157
+ };
6158
+ }
6159
+ toFiniteNumber(value) {
6160
+ if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
6161
+ return value;
6162
+ }
3539
6163
  createModelInvocationSpan(ctx, invocationId, startedAt) {
3540
6164
  return ctx.telemetry.startChildSpan({
3541
6165
  name: "gen_ai.chat.completion",
@@ -3544,13 +6168,22 @@ let AIAgentNode = class AIAgentNode$1 {
3544
6168
  attributes: {
3545
6169
  [__codemation_core.CodemationTelemetryAttributeNames.connectionInvocationId]: invocationId,
3546
6170
  [__codemation_core.GenAiTelemetryAttributeNames.operationName]: "chat",
3547
- [__codemation_core.GenAiTelemetryAttributeNames.requestModel]: this.resolveChatModelName(ctx.config.chatModel)
6171
+ [__codemation_core.GenAiTelemetryAttributeNames.requestModel]: this.resolveChatModelName(ctx.config.chatModel),
6172
+ ...ctx.iterationId ? { [__codemation_core.CodemationTelemetryAttributeNames.iterationId]: ctx.iterationId } : {},
6173
+ ...typeof ctx.itemIndex === "number" ? { [__codemation_core.CodemationTelemetryAttributeNames.iterationIndex]: ctx.itemIndex } : {},
6174
+ ...ctx.parentInvocationId ? { [__codemation_core.CodemationTelemetryAttributeNames.parentInvocationId]: ctx.parentInvocationId } : {}
3548
6175
  }
3549
6176
  });
3550
6177
  }
3551
- async recordModelUsageMetrics(span, response, ctx) {
3552
- const usage = this.extractModelUsageMetrics(response);
3553
- for (const [name, value] of Object.entries(usage)) {
6178
+ async recordModelUsageMetrics(span, usage, ctx) {
6179
+ const entries = [
6180
+ [__codemation_core.GenAiTelemetryAttributeNames.usageInputTokens, usage.inputTokens],
6181
+ [__codemation_core.GenAiTelemetryAttributeNames.usageOutputTokens, usage.outputTokens],
6182
+ [__codemation_core.GenAiTelemetryAttributeNames.usageTotalTokens, usage.totalTokens],
6183
+ [__codemation_core.GenAiTelemetryAttributeNames.usageCacheReadInputTokens, usage.cachedInputTokens],
6184
+ [__codemation_core.GenAiTelemetryAttributeNames.usageReasoningTokens, usage.reasoningTokens]
6185
+ ];
6186
+ for (const [name, value] of entries) {
3554
6187
  if (value === void 0) continue;
3555
6188
  await span.recordMetric({
3556
6189
  name,
@@ -3565,99 +6198,49 @@ let AIAgentNode = class AIAgentNode$1 {
3565
6198
  const provider = ctx.config.chatModel.provider;
3566
6199
  const pricingKey = ctx.config.chatModel.modelName;
3567
6200
  if (!provider || !pricingKey) return;
3568
- const inputTokens = usage[__codemation_core.GenAiTelemetryAttributeNames.usageInputTokens];
3569
- const outputTokens = usage[__codemation_core.GenAiTelemetryAttributeNames.usageOutputTokens];
3570
- if (inputTokens !== void 0) await costTracking.captureUsage({
6201
+ if (usage.inputTokens !== void 0) await costTracking.captureUsage({
3571
6202
  component: "chat",
3572
6203
  provider,
3573
6204
  operation: "completion.input",
3574
6205
  pricingKey,
3575
6206
  usageUnit: "input_tokens",
3576
- quantity: inputTokens,
6207
+ quantity: usage.inputTokens,
3577
6208
  modelName: pricingKey
3578
6209
  });
3579
- if (outputTokens !== void 0) await costTracking.captureUsage({
6210
+ if (usage.outputTokens !== void 0) await costTracking.captureUsage({
3580
6211
  component: "chat",
3581
6212
  provider,
3582
6213
  operation: "completion.output",
3583
6214
  pricingKey,
3584
6215
  usageUnit: "output_tokens",
3585
- quantity: outputTokens,
6216
+ quantity: usage.outputTokens,
3586
6217
  modelName: pricingKey
3587
6218
  });
3588
6219
  }
3589
6220
  resolveChatModelName(chatModel$1) {
3590
6221
  return chatModel$1.modelName ?? chatModel$1.name;
3591
6222
  }
3592
- extractModelUsageMetrics(response) {
3593
- const usage = this.extractUsageObject(response);
3594
- const inputTokens = this.readUsageNumber(usage, [
3595
- "input_tokens",
3596
- "inputTokens",
3597
- "prompt_tokens",
3598
- "promptTokens"
3599
- ]);
3600
- const outputTokens = this.readUsageNumber(usage, [
3601
- "output_tokens",
3602
- "outputTokens",
3603
- "completion_tokens",
3604
- "completionTokens"
3605
- ]);
3606
- const totalTokens = this.readUsageNumber(usage, ["total_tokens", "totalTokens"]) ?? (inputTokens !== void 0 && outputTokens !== void 0 ? inputTokens + outputTokens : void 0);
3607
- const cachedInputTokens = this.readUsageNumber(usage, [
3608
- "cache_read_input_tokens",
3609
- "cacheReadInputTokens",
3610
- "input_token_details.cached_tokens"
3611
- ]);
3612
- const reasoningTokens = this.readUsageNumber(usage, [
3613
- "reasoning_tokens",
3614
- "reasoningTokens",
3615
- "output_token_details.reasoning_tokens"
3616
- ]);
3617
- return {
3618
- [__codemation_core.GenAiTelemetryAttributeNames.usageInputTokens]: inputTokens,
3619
- [__codemation_core.GenAiTelemetryAttributeNames.usageOutputTokens]: outputTokens,
3620
- [__codemation_core.GenAiTelemetryAttributeNames.usageTotalTokens]: totalTokens,
3621
- [__codemation_core.GenAiTelemetryAttributeNames.usageCacheReadInputTokens]: cachedInputTokens,
3622
- [__codemation_core.GenAiTelemetryAttributeNames.usageReasoningTokens]: reasoningTokens
3623
- };
3624
- }
3625
- extractUsageObject(response) {
3626
- if (!this.isRecord(response)) return;
3627
- const usageMetadata = response["usage_metadata"];
3628
- if (this.isRecord(usageMetadata)) return usageMetadata;
3629
- const responseMetadata = response["response_metadata"];
3630
- if (this.isRecord(responseMetadata)) {
3631
- const tokenUsage = responseMetadata["tokenUsage"];
3632
- if (this.isRecord(tokenUsage)) return tokenUsage;
3633
- const usage = responseMetadata["usage"];
3634
- if (this.isRecord(usage)) return usage;
3635
- }
3636
- }
3637
- readUsageNumber(source, keys) {
3638
- for (const key of keys) {
3639
- const value = this.readNestedUsageValue(source, key);
3640
- if (typeof value === "number" && Number.isFinite(value)) return value;
3641
- }
3642
- }
3643
- readNestedUsageValue(source, dottedKey) {
3644
- if (!source) return;
3645
- let current = source;
3646
- for (const segment of dottedKey.split(".")) {
3647
- if (!this.isRecord(current)) return;
3648
- current = current[segment];
3649
- }
3650
- return current;
3651
- }
3652
- isRecord(value) {
3653
- return typeof value === "object" && value !== null;
3654
- }
3655
6223
  async markQueuedTools(plannedToolCalls, ctx) {
3656
- for (const plannedToolCall of plannedToolCalls) await ctx.nodeState?.markQueued({
3657
- nodeId: plannedToolCall.nodeId,
3658
- activationId: ctx.activationId,
3659
- inputsByPort: AgentToolCallPortMap.fromInput(plannedToolCall.toolCall.input ?? {})
3660
- });
6224
+ const queuedAt = (/* @__PURE__ */ new Date()).toISOString();
6225
+ for (const plannedToolCall of plannedToolCalls) {
6226
+ await ctx.nodeState?.markQueued({
6227
+ nodeId: plannedToolCall.nodeId,
6228
+ activationId: ctx.activationId,
6229
+ inputsByPort: AgentToolCallPortMap.fromInput(plannedToolCall.toolCall.input ?? {})
6230
+ });
6231
+ await ctx.nodeState?.appendConnectionInvocation({
6232
+ invocationId: plannedToolCall.invocationId,
6233
+ connectionNodeId: plannedToolCall.nodeId,
6234
+ parentAgentNodeId: ctx.nodeId,
6235
+ parentAgentActivationId: ctx.activationId,
6236
+ status: "queued",
6237
+ managedInput: this.resultToJsonValue(plannedToolCall.toolCall.input),
6238
+ queuedAt,
6239
+ iterationId: ctx.iterationId,
6240
+ itemIndex: ctx.itemIndex,
6241
+ parentInvocationId: ctx.parentInvocationId
6242
+ });
6243
+ }
3661
6244
  }
3662
6245
  planToolCalls(bindings, toolCalls, parentNodeId) {
3663
6246
  const invocationCountByToolName = /* @__PURE__ */ new Map();
@@ -3670,7 +6253,8 @@ let AIAgentNode = class AIAgentNode$1 {
3670
6253
  binding,
3671
6254
  toolCall,
3672
6255
  invocationIndex,
3673
- nodeId: __codemation_core.ConnectionNodeIdFactory.toolConnectionNodeId(parentNodeId, binding.config.name)
6256
+ nodeId: __codemation_core.ConnectionNodeIdFactory.toolConnectionNodeId(parentNodeId, binding.config.name),
6257
+ invocationId: __codemation_core.ConnectionInvocationIdFactory.create()
3674
6258
  };
3675
6259
  });
3676
6260
  }
@@ -3698,7 +6282,10 @@ let AIAgentNode = class AIAgentNode$1 {
3698
6282
  },
3699
6283
  queuedAt: args.startedAt.toISOString(),
3700
6284
  startedAt: args.startedAt.toISOString(),
3701
- finishedAt: finishedAt.toISOString()
6285
+ finishedAt: finishedAt.toISOString(),
6286
+ iterationId: args.ctx.iterationId,
6287
+ itemIndex: args.ctx.itemIndex,
6288
+ parentInvocationId: args.ctx.parentInvocationId
3702
6289
  });
3703
6290
  return effectiveError;
3704
6291
  }
@@ -3711,7 +6298,7 @@ let AIAgentNode = class AIAgentNode$1 {
3711
6298
  };
3712
6299
  }
3713
6300
  resultToJsonValue(value) {
3714
- if (value === void 0) return;
6301
+ if (value === void 0) return void 0;
3715
6302
  const json = JSON.stringify(value);
3716
6303
  return JSON.parse(json);
3717
6304
  }
@@ -3726,7 +6313,7 @@ let AIAgentNode = class AIAgentNode$1 {
3726
6313
  resolveToolRuntime(config$1) {
3727
6314
  if (this.isNodeBackedToolConfig(config$1)) {
3728
6315
  const inputSchema = config$1.getInputSchema();
3729
- if (inputSchema == null) throw new Error(`AIAgent tool "${config$1.name}": node-backed tool is missing inputSchema (cannot build LangChain tool).`);
6316
+ if (inputSchema == null) throw new Error(`AIAgent tool "${config$1.name}": node-backed tool is missing inputSchema (cannot build AI SDK tool).`);
3730
6317
  return {
3731
6318
  defaultDescription: `Run workflow node "${config$1.node.name ?? config$1.name}" as an AI tool.`,
3732
6319
  inputSchema,
@@ -3735,7 +6322,7 @@ let AIAgentNode = class AIAgentNode$1 {
3735
6322
  }
3736
6323
  if (this.isCallableToolConfig(config$1)) {
3737
6324
  const inputSchema = config$1.getInputSchema();
3738
- if (inputSchema == null) throw new Error(`AIAgent tool "${config$1.name}": callable tool is missing inputSchema (cannot build LangChain tool).`);
6325
+ if (inputSchema == null) throw new Error(`AIAgent tool "${config$1.name}": callable tool is missing inputSchema (cannot build AI SDK tool).`);
3739
6326
  return {
3740
6327
  defaultDescription: config$1.description ?? `Callable tool "${config$1.name}".`,
3741
6328
  inputSchema,
@@ -3753,17 +6340,9 @@ let AIAgentNode = class AIAgentNode$1 {
3753
6340
  execute: async (args) => await Promise.resolve(tool.execute(args))
3754
6341
  };
3755
6342
  }
3756
- /**
3757
- * Consumer apps can resolve two copies of `@codemation/core`, breaking `instanceof NodeBackedToolConfig` and
3758
- * sending node-backed tools down the plugin-tool branch with `inputSchema: undefined` (LangChain then crashes in
3759
- * json-schema validation). {@link NodeBackedToolConfig#toolKind} is stable across copies.
3760
- */
3761
6343
  isNodeBackedToolConfig(config$1) {
3762
6344
  return config$1 instanceof __codemation_core.NodeBackedToolConfig || typeof config$1 === "object" && config$1 !== null && config$1.toolKind === "nodeBacked";
3763
6345
  }
3764
- /**
3765
- * Callable tools use {@link CallableToolConfig#toolKind} for cross-package / JSON round-trip safety.
3766
- */
3767
6346
  isCallableToolConfig(config$1) {
3768
6347
  return config$1 instanceof __codemation_core.CallableToolConfig || typeof config$1 === "object" && config$1 !== null && config$1.toolKind === "callable";
3769
6348
  }
@@ -3834,6 +6413,52 @@ var AIAgent = class {
3834
6413
  }
3835
6414
  };
3836
6415
 
6416
+ //#endregion
6417
+ //#region src/nodes/AssertionNode.ts
6418
+ let AssertionNode = class AssertionNode$1 {
6419
+ kind = "node";
6420
+ outputPorts = ["main"];
6421
+ async execute(args) {
6422
+ const ctx = args.ctx;
6423
+ const config$1 = ctx.config;
6424
+ try {
6425
+ return [...await config$1.assertions(args.item, ctx)];
6426
+ } catch (err) {
6427
+ const message = err instanceof Error ? err.message : String(err);
6428
+ return [{
6429
+ name: config$1.name ?? "assertion",
6430
+ score: 0,
6431
+ errored: true,
6432
+ message
6433
+ }];
6434
+ }
6435
+ }
6436
+ };
6437
+ AssertionNode = __decorate([(0, __codemation_core.node)({ packageName: "@codemation/core-nodes" })], AssertionNode);
6438
+
6439
+ //#endregion
6440
+ //#region src/nodes/assertion.ts
6441
+ /**
6442
+ * Generic assertion node — the "callback" form. For declarative shorthands (StringEquals,
6443
+ * JudgeByAgent) compose this with helpers added in later phases. Sets `emitsAssertions: true`
6444
+ * so host-side persisters know to record its outputs as `TestAssertion` rows.
6445
+ */
6446
+ var Assertion = class {
6447
+ kind = "node";
6448
+ type = AssertionNode;
6449
+ icon;
6450
+ name;
6451
+ id;
6452
+ emitsAssertions = true;
6453
+ assertions;
6454
+ constructor(options) {
6455
+ this.name = options.name ?? "Assertion";
6456
+ this.id = options.id;
6457
+ this.icon = options.icon ?? "lucide:check-circle";
6458
+ this.assertions = options.assertions;
6459
+ }
6460
+ };
6461
+
3837
6462
  //#endregion
3838
6463
  //#region src/nodes/CallbackResultNormalizerFactory.ts
3839
6464
  var CallbackResultNormalizer = class {
@@ -3903,32 +6528,79 @@ let HttpRequestNode = class HttpRequestNode$1 {
3903
6528
  }
3904
6529
  async executeItem(item, ctx) {
3905
6530
  const url = this.resolveUrl(item, ctx);
3906
- const response = await fetch(url, { method: ctx.config.method });
6531
+ const credential = await this.resolveCredential(ctx);
6532
+ const spec = {
6533
+ url,
6534
+ method: ctx.config.method,
6535
+ headers: ctx.config.args.headers,
6536
+ query: ctx.config.args.query,
6537
+ body: ctx.config.args.body,
6538
+ credential,
6539
+ download: {
6540
+ mode: ctx.config.downloadMode,
6541
+ binaryName: ctx.config.binaryName
6542
+ },
6543
+ ctx
6544
+ };
6545
+ const { url: resolvedUrl, init } = await new HttpRequestExecutor(globalThis.fetch, new HttpBodyBuilder(), new HttpUrlBuilder()).buildRequest(spec, item);
6546
+ const response = await globalThis.fetch(resolvedUrl, init);
3907
6547
  const headers = this.readHeaders(response.headers);
3908
6548
  const mimeType = this.resolveMimeType(headers);
3909
- const bodyBinaryName = ctx.config.binaryName;
3910
- const shouldAttachBody = this.shouldAttachBody(ctx.config.downloadMode, mimeType);
3911
- let outputItem = { json: {
3912
- url,
6549
+ const binaryName = ctx.config.binaryName;
6550
+ if (this.shouldAttachBody(ctx.config.downloadMode, mimeType)) {
6551
+ const outputJson = {
6552
+ url: resolvedUrl,
6553
+ method: ctx.config.method,
6554
+ ok: response.ok,
6555
+ status: response.status,
6556
+ statusText: response.statusText,
6557
+ mimeType,
6558
+ headers,
6559
+ bodyBinaryName: binaryName
6560
+ };
6561
+ const attachment = await ctx.binary.attach({
6562
+ name: binaryName,
6563
+ body: response.body ? response.body : new Uint8Array(await response.arrayBuffer()),
6564
+ mimeType,
6565
+ filename: this.resolveFilename(resolvedUrl, headers)
6566
+ });
6567
+ let outputItem = { json: outputJson };
6568
+ outputItem = ctx.binary.withAttachment(outputItem, binaryName, attachment);
6569
+ return outputItem;
6570
+ }
6571
+ const isJson = this.isJsonMimeType(mimeType);
6572
+ let json;
6573
+ let text;
6574
+ if (isJson) try {
6575
+ json = await response.json();
6576
+ } catch {
6577
+ text = await response.text();
6578
+ }
6579
+ else text = await response.text();
6580
+ return { json: {
6581
+ url: resolvedUrl,
3913
6582
  method: ctx.config.method,
3914
6583
  ok: response.ok,
3915
6584
  status: response.status,
3916
6585
  statusText: response.statusText,
3917
6586
  mimeType,
3918
6587
  headers,
3919
- ...shouldAttachBody ? { bodyBinaryName } : {}
6588
+ ...json !== void 0 ? { json } : {},
6589
+ ...text !== void 0 ? { text } : {}
3920
6590
  } };
3921
- if (!shouldAttachBody) return outputItem;
3922
- const attachment = await ctx.binary.attach({
3923
- name: bodyBinaryName,
3924
- body: response.body ? response.body : new Uint8Array(await response.arrayBuffer()),
3925
- mimeType,
3926
- filename: this.resolveFilename(url, headers)
3927
- });
3928
- outputItem = ctx.binary.withAttachment(outputItem, bodyBinaryName, attachment);
3929
- return outputItem;
6591
+ }
6592
+ async resolveCredential(ctx) {
6593
+ const slotKey = ctx.config.args.credentialSlot;
6594
+ if (!slotKey) return;
6595
+ try {
6596
+ return await ctx.getCredential(slotKey);
6597
+ } catch {
6598
+ return;
6599
+ }
3930
6600
  }
3931
6601
  resolveUrl(item, ctx) {
6602
+ const literalUrl = ctx.config.args.url;
6603
+ if (literalUrl && literalUrl.trim().length > 0) return literalUrl.trim();
3932
6604
  const candidate = this.asRecord(item.json)[ctx.config.urlField];
3933
6605
  if (typeof candidate !== "string" || candidate.trim() === "") throw new Error(`HttpRequest node expected item.json.${ctx.config.urlField} to contain a URL string.`);
3934
6606
  return candidate;
@@ -3949,6 +6621,9 @@ let HttpRequestNode = class HttpRequestNode$1 {
3949
6621
  if (!contentType) return "application/octet-stream";
3950
6622
  return contentType.split(";")[0]?.trim() || "application/octet-stream";
3951
6623
  }
6624
+ isJsonMimeType(mimeType) {
6625
+ return mimeType === "application/json" || mimeType.endsWith("+json");
6626
+ }
3952
6627
  shouldAttachBody(mode, mimeType) {
3953
6628
  if (mode === "always") return true;
3954
6629
  if (mode === "never") return false;
@@ -3975,10 +6650,21 @@ HttpRequestNode = __decorate([(0, __codemation_core.node)({ packageName: "@codem
3975
6650
 
3976
6651
  //#endregion
3977
6652
  //#region src/nodes/httpRequest.ts
6653
+ /**
6654
+ * The built-in HTTP request credential type IDs accepted by the `HttpRequest` node.
6655
+ * These match the four generic credential types shipped with `@codemation/core-nodes`.
6656
+ */
6657
+ const HTTP_REQUEST_ACCEPTED_CREDENTIAL_TYPES = [
6658
+ bearerTokenCredentialType.definition.typeId,
6659
+ apiKeyCredentialType.definition.typeId,
6660
+ basicAuthCredentialType.definition.typeId,
6661
+ oauth2ClientCredentialsType.definition.typeId
6662
+ ];
3978
6663
  var HttpRequest = class {
3979
6664
  kind = "node";
3980
6665
  type = HttpRequestNode;
3981
6666
  execution = { hint: "local" };
6667
+ icon = "lucide:globe";
3982
6668
  constructor(name, args = {}, retryPolicy = __codemation_core.RetryPolicy.defaultForHttp) {
3983
6669
  this.name = name;
3984
6670
  this.args = args;
@@ -3999,6 +6685,16 @@ var HttpRequest = class {
3999
6685
  get downloadMode() {
4000
6686
  return this.args.downloadMode ?? "auto";
4001
6687
  }
6688
+ getCredentialRequirements() {
6689
+ if (!this.args.credentialSlot) return [];
6690
+ return [{
6691
+ slotKey: this.args.credentialSlot,
6692
+ label: "Authentication",
6693
+ acceptedTypes: HTTP_REQUEST_ACCEPTED_CREDENTIAL_TYPES,
6694
+ optional: true,
6695
+ helpText: "Optional credential for authenticating the HTTP request."
6696
+ }];
6697
+ }
4002
6698
  };
4003
6699
 
4004
6700
  //#endregion
@@ -4020,7 +6716,7 @@ var Aggregate = class {
4020
6716
  type = AggregateNode;
4021
6717
  execution = { hint: "local" };
4022
6718
  keepBinaries = true;
4023
- icon = "lucide:layers";
6719
+ icon = "builtin:aggregate-rows";
4024
6720
  constructor(name, aggregate, id) {
4025
6721
  this.name = name;
4026
6722
  this.aggregate = aggregate;
@@ -4115,7 +6811,7 @@ var If = class {
4115
6811
  kind = "node";
4116
6812
  type = IfNode;
4117
6813
  execution = { hint: "local" };
4118
- icon = "lucide:split";
6814
+ icon = "lucide:split@rot=90";
4119
6815
  declaredOutputPorts = ["true", "false"];
4120
6816
  constructor(name, predicate, id) {
4121
6817
  this.name = name;
@@ -4124,6 +6820,40 @@ var If = class {
4124
6820
  }
4125
6821
  };
4126
6822
 
6823
+ //#endregion
6824
+ //#region src/nodes/IsTestRunNode.ts
6825
+ let IsTestRunNode = class IsTestRunNode$1 {
6826
+ kind = "node";
6827
+ execute(args) {
6828
+ const isTest = args.ctx.testContext !== void 0;
6829
+ return (0, __codemation_core.emitPorts)({
6830
+ true: isTest ? [args.item] : [],
6831
+ false: isTest ? [] : [args.item]
6832
+ });
6833
+ }
6834
+ };
6835
+ IsTestRunNode = __decorate([(0, __codemation_core.node)({ packageName: "@codemation/core-nodes" })], IsTestRunNode);
6836
+
6837
+ //#endregion
6838
+ //#region src/nodes/isTestRun.ts
6839
+ /**
6840
+ * Branches per-item on whether the current run is a test run. Output ports: `true`, `false`.
6841
+ * The wire payload is unchanged — this is a router, not a transform.
6842
+ */
6843
+ var IsTestRun = class {
6844
+ kind = "node";
6845
+ type = IsTestRunNode;
6846
+ execution = { hint: "local" };
6847
+ icon = "lucide:flask-conical";
6848
+ declaredOutputPorts = ["true", "false"];
6849
+ name;
6850
+ id;
6851
+ constructor(name = "Is test run?", id) {
6852
+ this.name = name;
6853
+ this.id = id;
6854
+ }
6855
+ };
6856
+
4127
6857
  //#endregion
4128
6858
  //#region src/nodes/SwitchNode.ts
4129
6859
  let SwitchNode = class SwitchNode$1 {
@@ -4180,7 +6910,7 @@ var Split = class {
4180
6910
  * Mirrors {@link MapData}'s empty-output behavior.
4181
6911
  */
4182
6912
  continueWhenEmptyOutput = true;
4183
- icon = "lucide:ungroup";
6913
+ icon = "builtin:split-rows";
4184
6914
  constructor(name, getElements, id) {
4185
6915
  this.name = name;
4186
6916
  this.getElements = getElements;
@@ -4188,6 +6918,75 @@ var Split = class {
4188
6918
  }
4189
6919
  };
4190
6920
 
6921
+ //#endregion
6922
+ //#region src/nodes/CronTriggerNode.ts
6923
+ let CronTriggerNode = class CronTriggerNode$1 {
6924
+ kind = "trigger";
6925
+ outputPorts = ["main"];
6926
+ async setup(ctx) {
6927
+ const job = ctx.config.createJob(async (self) => {
6928
+ const scheduledFor = self.currentRun()?.toISOString() ?? ctx.now().toISOString();
6929
+ await ctx.emit([{ json: {
6930
+ firedAt: ctx.now().toISOString(),
6931
+ scheduledFor
6932
+ } }]);
6933
+ });
6934
+ ctx.registerCleanup({ stop: () => {
6935
+ job.stop();
6936
+ } });
6937
+ }
6938
+ async execute(items, _ctx) {
6939
+ return { main: items };
6940
+ }
6941
+ async getTestItems(ctx) {
6942
+ const nowIso = ctx.now().toISOString();
6943
+ return [{ json: {
6944
+ firedAt: nowIso,
6945
+ scheduledFor: nowIso
6946
+ } }];
6947
+ }
6948
+ };
6949
+ CronTriggerNode = __decorate([(0, __codemation_core.node)({ packageName: "@codemation/core-nodes" })], CronTriggerNode);
6950
+
6951
+ //#endregion
6952
+ //#region src/nodes/CronTriggerFactory.ts
6953
+ /**
6954
+ * Schedules a workflow on a standard cron expression.
6955
+ *
6956
+ * Each tick emits one item: `{ firedAt: string, scheduledFor: string }` — both ISO-8601 timestamps.
6957
+ * `firedAt` is the wall-clock moment the callback ran; `scheduledFor` is the cron-computed
6958
+ * firing instant (these differ when the job was delayed).
6959
+ *
6960
+ * Timezone defaults to UTC when omitted — cron without an explicit TZ is a DST footgun.
6961
+ */
6962
+ var CronTrigger = class {
6963
+ kind = "trigger";
6964
+ type = CronTriggerNode;
6965
+ icon = "lucide:clock";
6966
+ id;
6967
+ constructor(name, args, id) {
6968
+ this.name = name;
6969
+ this.args = args;
6970
+ new croner.Cron(args.schedule, {
6971
+ paused: true,
6972
+ timezone: args.timezone
6973
+ });
6974
+ this.id = id;
6975
+ }
6976
+ get schedule() {
6977
+ return this.args.schedule;
6978
+ }
6979
+ get timezone() {
6980
+ return this.args.timezone;
6981
+ }
6982
+ createJob(callback) {
6983
+ return new croner.Cron(this.args.schedule, {
6984
+ timezone: this.args.timezone,
6985
+ protect: true
6986
+ }, callback);
6987
+ }
6988
+ };
6989
+
4191
6990
  //#endregion
4192
6991
  //#region src/nodes/ManualTriggerNode.ts
4193
6992
  let ManualTriggerNode = class ManualTriggerNode$1 {
@@ -4251,6 +7050,7 @@ var MapData = class {
4251
7050
  execution = { hint: "local" };
4252
7051
  /** Zero mapped items should still allow downstream nodes to run. */
4253
7052
  continueWhenEmptyOutput = true;
7053
+ icon = "lucide:square-pen";
4254
7054
  keepBinaries;
4255
7055
  constructor(name, map, options = {}) {
4256
7056
  this.name = name;
@@ -4320,7 +7120,7 @@ MergeNode = __decorate([(0, __codemation_core.node)({ packageName: "@codemation/
4320
7120
  var Merge = class {
4321
7121
  kind = "node";
4322
7122
  type = MergeNode;
4323
- icon = "lucide:git-merge";
7123
+ icon = "lucide:merge@rot=90";
4324
7124
  constructor(name, cfg = { mode: "passThrough" }, id) {
4325
7125
  this.name = name;
4326
7126
  this.cfg = cfg;
@@ -4345,6 +7145,7 @@ var NoOp = class {
4345
7145
  kind = "node";
4346
7146
  type = NoOpNode;
4347
7147
  execution = { hint: "local" };
7148
+ icon = "lucide:circle-dashed";
4348
7149
  constructor(name = "NoOp", id) {
4349
7150
  this.name = name;
4350
7151
  this.id = id;
@@ -4417,6 +7218,52 @@ var SubWorkflow = class {
4417
7218
  }
4418
7219
  };
4419
7220
 
7221
+ //#endregion
7222
+ //#region src/nodes/TestTriggerNode.ts
7223
+ let TestTriggerNode = class TestTriggerNode$1 {
7224
+ kind = "trigger";
7225
+ outputPorts = ["main"];
7226
+ async setup(_ctx) {}
7227
+ async execute(items, _ctx) {
7228
+ return { main: items };
7229
+ }
7230
+ };
7231
+ TestTriggerNode = __decorate([(0, __codemation_core.node)({ packageName: "@codemation/core-nodes" })], TestTriggerNode);
7232
+
7233
+ //#endregion
7234
+ //#region src/nodes/testTrigger.ts
7235
+ /**
7236
+ * Trigger config for a test fixture source. Drop one (or more) of these on the canvas alongside
7237
+ * a workflow's live triggers; clicking "Run tests" on the Tests tab invokes
7238
+ * {@link TestTriggerOptions.generateItems} via the TestSuiteOrchestrator.
7239
+ */
7240
+ var TestTrigger = class {
7241
+ kind = "trigger";
7242
+ triggerKind = "test";
7243
+ type = TestTriggerNode;
7244
+ icon;
7245
+ name;
7246
+ id;
7247
+ concurrency;
7248
+ description;
7249
+ generateItems;
7250
+ caseLabel;
7251
+ credentialRequirements;
7252
+ constructor(options) {
7253
+ this.name = options.name ?? "Test trigger";
7254
+ this.id = options.id;
7255
+ this.icon = options.icon ?? "lucide:flask-conical";
7256
+ this.concurrency = options.concurrency;
7257
+ this.description = options.description;
7258
+ this.credentialRequirements = options.credentialRequirements ?? [];
7259
+ this.generateItems = options.generateItems;
7260
+ this.caseLabel = options.caseLabel;
7261
+ }
7262
+ getCredentialRequirements() {
7263
+ return this.credentialRequirements;
7264
+ }
7265
+ };
7266
+
4420
7267
  //#endregion
4421
7268
  //#region src/nodes/WaitDurationFactory.ts
4422
7269
  var WaitDuration = class {
@@ -4450,6 +7297,7 @@ var Wait = class {
4450
7297
  execution = { hint: "local" };
4451
7298
  /** Pass-through empty batches should still advance to downstream nodes. */
4452
7299
  continueWhenEmptyOutput = true;
7300
+ icon = "lucide:hourglass";
4453
7301
  constructor(name, milliseconds, id) {
4454
7302
  this.name = name;
4455
7303
  this.milliseconds = milliseconds;
@@ -4500,7 +7348,7 @@ WebhookTriggerNode = __decorate([(0, __codemation_core.node)({ packageName: "@co
4500
7348
  var WebhookTrigger = class WebhookTrigger {
4501
7349
  kind = "trigger";
4502
7350
  type = WebhookTriggerNode;
4503
- icon = "lucide:globe";
7351
+ icon = "lucide:webhook";
4504
7352
  constructor(name, args, handler = WebhookTrigger.defaultHandler, id) {
4505
7353
  this.name = name;
4506
7354
  this.args = args;
@@ -4596,10 +7444,10 @@ var WorkflowDefinedNodeResolver = class {
4596
7444
  //#endregion
4597
7445
  //#region src/workflowAuthoring/WorkflowDurationParser.types.ts
4598
7446
  var WorkflowDurationParser = class {
4599
- static parse(duration) {
4600
- if (typeof duration === "number") return Number.isFinite(duration) && duration > 0 ? Math.floor(duration) : 0;
4601
- const match = duration.trim().toLowerCase().match(/^(\d+)(ms|s|m|h)$/);
4602
- if (!match) throw new Error(`Unsupported wait duration "${duration}". Use a number of milliseconds or values like "500ms", "2s", "5m".`);
7447
+ static parse(duration$2) {
7448
+ if (typeof duration$2 === "number") return Number.isFinite(duration$2) && duration$2 > 0 ? Math.floor(duration$2) : 0;
7449
+ const match = duration$2.trim().toLowerCase().match(/^(\d+)(ms|s|m|h)$/);
7450
+ if (!match) throw new Error(`Unsupported wait duration "${duration$2}". Use a number of milliseconds or values like "500ms", "2s", "5m".`);
4603
7451
  const value = Number(match[1]);
4604
7452
  const unit = match[2];
4605
7453
  if (unit === "ms") return value;
@@ -4625,8 +7473,8 @@ var WorkflowBranchBuilder = class WorkflowBranchBuilder {
4625
7473
  }
4626
7474
  wait(nameOrDuration, durationOrUndefined, id) {
4627
7475
  const name = typeof nameOrDuration === "string" && durationOrUndefined !== void 0 ? nameOrDuration : "Wait";
4628
- const duration = durationOrUndefined ?? nameOrDuration;
4629
- return this.then(new Wait(name, WorkflowDurationParser.parse(duration), id));
7476
+ const duration$2 = durationOrUndefined ?? nameOrDuration;
7477
+ return this.then(new Wait(name, WorkflowDurationParser.parse(duration$2), id));
4630
7478
  }
4631
7479
  split(nameOrGetter, getElementsOrUndefined, id) {
4632
7480
  const name = typeof nameOrGetter === "string" ? nameOrGetter : "Split";
@@ -4671,8 +7519,8 @@ var WorkflowChain = class WorkflowChain {
4671
7519
  }
4672
7520
  wait(nameOrDuration, durationOrUndefined, id) {
4673
7521
  const name = typeof nameOrDuration === "string" && durationOrUndefined !== void 0 ? nameOrDuration : "Wait";
4674
- const duration = durationOrUndefined ?? nameOrDuration;
4675
- return this.then(new Wait(name, WorkflowDurationParser.parse(duration), id));
7522
+ const duration$2 = durationOrUndefined ?? nameOrDuration;
7523
+ return this.then(new Wait(name, WorkflowDurationParser.parse(duration$2), id));
4676
7524
  }
4677
7525
  split(nameOrGetter, getElementsOrUndefined, id) {
4678
7526
  const name = typeof nameOrGetter === "string" ? nameOrGetter : "Split";
@@ -4772,9 +7620,9 @@ var AIAgentConnectionWorkflowExpander = class {
4772
7620
  const connectionsByParentAndName = this.createConnectionsByParentAndName(workflow$1);
4773
7621
  const extraNodes = [];
4774
7622
  let connectionsChanged = false;
4775
- for (const node$16 of workflow$1.nodes) {
4776
- if (node$16.type !== AIAgentNode || !__codemation_core.AgentConfigInspector.isAgentNodeConfig(node$16.config)) continue;
4777
- for (const connectionNode of __codemation_core.AgentConnectionNodeCollector.collect(node$16.id, node$16.config)) {
7623
+ for (const node$20 of workflow$1.nodes) {
7624
+ if (node$20.type !== AIAgentNode || !__codemation_core.AgentConfigInspector.isAgentNodeConfig(node$20.config)) continue;
7625
+ for (const connectionNode of __codemation_core.AgentConnectionNodeCollector.collect(node$20.id, node$20.config)) {
4778
7626
  if (!existingChildIds.has(connectionNode.nodeId)) {
4779
7627
  this.assertNoIdCollision(workflow$1, extraNodes, existingChildIds, connectionNode.nodeId);
4780
7628
  extraNodes.push({
@@ -4853,6 +7701,129 @@ var ConnectionCredentialNodeConfigFactory = class {
4853
7701
  }
4854
7702
  };
4855
7703
 
7704
+ //#endregion
7705
+ //#region src/nodes/collections/collectionInsertNode.types.ts
7706
+ const collectionInsertNode = (0, __codemation_core.defineNode)({
7707
+ key: "collection-insert",
7708
+ title: "Collection: Insert",
7709
+ description: "Insert a new row into a collection.",
7710
+ icon: "lucide:boxes",
7711
+ configSchema: object({
7712
+ collectionName: string(),
7713
+ data: record(string(), unknown())
7714
+ }),
7715
+ async execute(_args, { config: config$1, execution }) {
7716
+ const store = execution.collections?.[config$1.collectionName];
7717
+ if (!store) throw new Error(`Collection "${config$1.collectionName}" is not registered. Add defineCollection to your codemation config.`);
7718
+ return await store.insert(config$1.data);
7719
+ }
7720
+ });
7721
+
7722
+ //#endregion
7723
+ //#region src/nodes/collections/collectionGetNode.types.ts
7724
+ const collectionGetNode = (0, __codemation_core.defineNode)({
7725
+ key: "collection-get",
7726
+ title: "Collection: Get",
7727
+ description: "Get a single row by id from a collection.",
7728
+ icon: "lucide:layers",
7729
+ configSchema: object({
7730
+ collectionName: string(),
7731
+ id: string()
7732
+ }),
7733
+ async execute(_args, { config: config$1, execution }) {
7734
+ const store = execution.collections?.[config$1.collectionName];
7735
+ if (!store) throw new Error(`Collection "${config$1.collectionName}" is not registered. Add defineCollection to your codemation config.`);
7736
+ const row = await store.get(config$1.id);
7737
+ if (row === null) return [];
7738
+ return row;
7739
+ }
7740
+ });
7741
+
7742
+ //#endregion
7743
+ //#region src/nodes/collections/collectionFindOneNode.types.ts
7744
+ const collectionFindOneNode = (0, __codemation_core.defineNode)({
7745
+ key: "collection-find-one",
7746
+ title: "Collection: Find One",
7747
+ description: "Find a single row matching a filter in a collection.",
7748
+ icon: "lucide:filter",
7749
+ configSchema: object({
7750
+ collectionName: string(),
7751
+ where: record(string(), unknown())
7752
+ }),
7753
+ async execute(_args, { config: config$1, execution }) {
7754
+ const store = execution.collections?.[config$1.collectionName];
7755
+ if (!store) throw new Error(`Collection "${config$1.collectionName}" is not registered. Add defineCollection to your codemation config.`);
7756
+ const row = await store.findOne(config$1.where);
7757
+ if (row === null) return [];
7758
+ return row;
7759
+ }
7760
+ });
7761
+
7762
+ //#endregion
7763
+ //#region src/nodes/collections/collectionListNode.types.ts
7764
+ const collectionListNode = (0, __codemation_core.defineNode)({
7765
+ key: "collection-list",
7766
+ title: "Collection: List",
7767
+ description: "List rows from a collection with optional pagination and filtering.",
7768
+ icon: "lucide:split",
7769
+ configSchema: object({
7770
+ collectionName: string(),
7771
+ limit: number().int().positive().optional(),
7772
+ offset: number().int().nonnegative().optional(),
7773
+ where: record(string(), unknown()).optional()
7774
+ }),
7775
+ async execute(_args, { config: config$1, execution }) {
7776
+ const store = execution.collections?.[config$1.collectionName];
7777
+ if (!store) throw new Error(`Collection "${config$1.collectionName}" is not registered. Add defineCollection to your codemation config.`);
7778
+ const { rows } = await store.list({
7779
+ limit: config$1.limit,
7780
+ offset: config$1.offset,
7781
+ where: config$1.where
7782
+ });
7783
+ return [...rows];
7784
+ }
7785
+ });
7786
+
7787
+ //#endregion
7788
+ //#region src/nodes/collections/collectionUpdateNode.types.ts
7789
+ const collectionUpdateNode = (0, __codemation_core.defineNode)({
7790
+ key: "collection-update",
7791
+ title: "Collection: Update",
7792
+ description: "Update a row by id in a collection.",
7793
+ icon: "lucide:square-pen",
7794
+ configSchema: object({
7795
+ collectionName: string(),
7796
+ id: string(),
7797
+ patch: record(string(), unknown())
7798
+ }),
7799
+ async execute(_args, { config: config$1, execution }) {
7800
+ const store = execution.collections?.[config$1.collectionName];
7801
+ if (!store) throw new Error(`Collection "${config$1.collectionName}" is not registered. Add defineCollection to your codemation config.`);
7802
+ return await store.update(config$1.id, config$1.patch);
7803
+ }
7804
+ });
7805
+
7806
+ //#endregion
7807
+ //#region src/nodes/collections/collectionDeleteNode.types.ts
7808
+ const collectionDeleteNode = (0, __codemation_core.defineNode)({
7809
+ key: "collection-delete",
7810
+ title: "Collection: Delete",
7811
+ description: "Delete a row by id from a collection.",
7812
+ icon: "lucide:braces",
7813
+ configSchema: object({
7814
+ collectionName: string(),
7815
+ id: string()
7816
+ }),
7817
+ async execute(_args, { config: config$1, execution }) {
7818
+ const store = execution.collections?.[config$1.collectionName];
7819
+ if (!store) throw new Error(`Collection "${config$1.collectionName}" is not registered. Add defineCollection to your codemation config.`);
7820
+ return {
7821
+ deleted: (await store.delete(config$1.id)).deleted,
7822
+ id: config$1.id
7823
+ };
7824
+ }
7825
+ });
7826
+
4856
7827
  //#endregion
4857
7828
  exports.AIAgent = AIAgent;
4858
7829
  exports.AIAgentConnectionWorkflowExpander = AIAgentConnectionWorkflowExpander;
@@ -4910,6 +7881,13 @@ Object.defineProperty(exports, 'AggregateNode', {
4910
7881
  return AggregateNode;
4911
7882
  }
4912
7883
  });
7884
+ exports.Assertion = Assertion;
7885
+ Object.defineProperty(exports, 'AssertionNode', {
7886
+ enumerable: true,
7887
+ get: function () {
7888
+ return AssertionNode;
7889
+ }
7890
+ });
4913
7891
  exports.Callback = Callback;
4914
7892
  Object.defineProperty(exports, 'CallbackNode', {
4915
7893
  enumerable: true,
@@ -4927,6 +7905,13 @@ Object.defineProperty(exports, 'ConnectionCredentialNode', {
4927
7905
  });
4928
7906
  exports.ConnectionCredentialNodeConfig = ConnectionCredentialNodeConfig;
4929
7907
  exports.ConnectionCredentialNodeConfigFactory = ConnectionCredentialNodeConfigFactory;
7908
+ exports.CronTrigger = CronTrigger;
7909
+ Object.defineProperty(exports, 'CronTriggerNode', {
7910
+ enumerable: true,
7911
+ get: function () {
7912
+ return CronTriggerNode;
7913
+ }
7914
+ });
4930
7915
  exports.Filter = Filter;
4931
7916
  Object.defineProperty(exports, 'FilterNode', {
4932
7917
  enumerable: true,
@@ -4934,6 +7919,7 @@ Object.defineProperty(exports, 'FilterNode', {
4934
7919
  return FilterNode;
4935
7920
  }
4936
7921
  });
7922
+ exports.HTTP_REQUEST_ACCEPTED_CREDENTIAL_TYPES = HTTP_REQUEST_ACCEPTED_CREDENTIAL_TYPES;
4937
7923
  exports.HttpRequest = HttpRequest;
4938
7924
  Object.defineProperty(exports, 'HttpRequestNode', {
4939
7925
  enumerable: true,
@@ -4948,6 +7934,13 @@ Object.defineProperty(exports, 'IfNode', {
4948
7934
  return IfNode;
4949
7935
  }
4950
7936
  });
7937
+ exports.IsTestRun = IsTestRun;
7938
+ Object.defineProperty(exports, 'IsTestRunNode', {
7939
+ enumerable: true,
7940
+ get: function () {
7941
+ return IsTestRunNode;
7942
+ }
7943
+ });
4951
7944
  exports.ManualTrigger = ManualTrigger;
4952
7945
  Object.defineProperty(exports, 'ManualTriggerNode', {
4953
7946
  enumerable: true,
@@ -4983,13 +7976,13 @@ Object.defineProperty(exports, 'OpenAIChatModelFactory', {
4983
7976
  return OpenAIChatModelFactory;
4984
7977
  }
4985
7978
  });
4986
- Object.defineProperty(exports, 'OpenAIStructuredOutputMethodFactory', {
7979
+ exports.OpenAiChatModelPresets = OpenAiChatModelPresets;
7980
+ Object.defineProperty(exports, 'OpenAiStrictJsonSchemaFactory', {
4987
7981
  enumerable: true,
4988
7982
  get: function () {
4989
- return OpenAIStructuredOutputMethodFactory;
7983
+ return OpenAiStrictJsonSchemaFactory;
4990
7984
  }
4991
7985
  });
4992
- exports.OpenAiChatModelPresets = OpenAiChatModelPresets;
4993
7986
  exports.Split = Split;
4994
7987
  Object.defineProperty(exports, 'SplitNode', {
4995
7988
  enumerable: true,
@@ -5011,6 +8004,13 @@ Object.defineProperty(exports, 'SwitchNode', {
5011
8004
  return SwitchNode;
5012
8005
  }
5013
8006
  });
8007
+ exports.TestTrigger = TestTrigger;
8008
+ Object.defineProperty(exports, 'TestTriggerNode', {
8009
+ enumerable: true,
8010
+ get: function () {
8011
+ return TestTriggerNode;
8012
+ }
8013
+ });
5014
8014
  exports.Wait = Wait;
5015
8015
  exports.WaitDuration = WaitDuration;
5016
8016
  Object.defineProperty(exports, 'WaitNode', {
@@ -5031,7 +8031,18 @@ Object.defineProperty(exports, 'WebhookTriggerNode', {
5031
8031
  exports.WorkflowAuthoringBuilder = WorkflowAuthoringBuilder;
5032
8032
  exports.WorkflowBranchBuilder = WorkflowBranchBuilder;
5033
8033
  exports.WorkflowChain = WorkflowChain;
8034
+ exports.apiKeyCredentialType = apiKeyCredentialType;
8035
+ exports.basicAuthCredentialType = basicAuthCredentialType;
8036
+ exports.bearerTokenCredentialType = bearerTokenCredentialType;
8037
+ exports.collectionDeleteNode = collectionDeleteNode;
8038
+ exports.collectionFindOneNode = collectionFindOneNode;
8039
+ exports.collectionGetNode = collectionGetNode;
8040
+ exports.collectionInsertNode = collectionInsertNode;
8041
+ exports.collectionListNode = collectionListNode;
8042
+ exports.collectionUpdateNode = collectionUpdateNode;
5034
8043
  exports.createWorkflowBuilder = createWorkflowBuilder;
8044
+ exports.defineRestNode = defineRestNode;
8045
+ exports.oauth2ClientCredentialsType = oauth2ClientCredentialsType;
5035
8046
  exports.openAiChatModelPresets = openAiChatModelPresets;
5036
8047
  exports.registerCoreNodes = registerCoreNodes;
5037
8048
  exports.workflow = workflow;