@n8n/expression-runtime 0.15.0 → 0.17.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 (63) hide show
  1. package/dist/bundle/runtime.esm.js +17 -17
  2. package/dist/bundle/runtime.esm.js.map +3 -3
  3. package/dist/bundle/runtime.iife.js +17 -17
  4. package/dist/bundle/runtime.iife.js.map +3 -3
  5. package/dist/cjs/bridge/bridge-messages.d.ts +460 -0
  6. package/dist/cjs/bridge/bridge-messages.d.ts.map +1 -1
  7. package/dist/cjs/bridge/bridge-messages.js +183 -1
  8. package/dist/cjs/bridge/bridge-messages.js.map +1 -1
  9. package/dist/cjs/bridge/isolated-vm-bridge.d.ts +94 -13
  10. package/dist/cjs/bridge/isolated-vm-bridge.d.ts.map +1 -1
  11. package/dist/cjs/bridge/isolated-vm-bridge.js +151 -61
  12. package/dist/cjs/bridge/isolated-vm-bridge.js.map +1 -1
  13. package/dist/cjs/build.tsbuildinfo +1 -1
  14. package/dist/cjs/extensions/boolean-extensions.d.ts +1 -1
  15. package/dist/cjs/pool/idle-scaling-pool.js +2 -2
  16. package/dist/cjs/pool/idle-scaling-pool.js.map +1 -1
  17. package/dist/cjs/runtime/context.d.ts +1 -4
  18. package/dist/cjs/runtime/context.d.ts.map +1 -1
  19. package/dist/cjs/runtime/context.js +122 -13
  20. package/dist/cjs/runtime/context.js.map +1 -1
  21. package/dist/cjs/runtime/index.d.ts +1 -1
  22. package/dist/cjs/runtime/index.d.ts.map +1 -1
  23. package/dist/cjs/runtime/jmespath.d.ts +5 -3
  24. package/dist/cjs/runtime/jmespath.d.ts.map +1 -1
  25. package/dist/cjs/runtime/jmespath.js +5 -3
  26. package/dist/cjs/runtime/jmespath.js.map +1 -1
  27. package/dist/cjs/runtime/lazy-proxy.d.ts +7 -5
  28. package/dist/cjs/runtime/lazy-proxy.d.ts.map +1 -1
  29. package/dist/cjs/runtime/lazy-proxy.js +8 -16
  30. package/dist/cjs/runtime/lazy-proxy.js.map +1 -1
  31. package/dist/cjs/types/evaluator.d.ts +69 -4
  32. package/dist/cjs/types/evaluator.d.ts.map +1 -1
  33. package/dist/cjs/types/evaluator.js.map +1 -1
  34. package/dist/esm/bridge/bridge-messages.d.ts +460 -0
  35. package/dist/esm/bridge/bridge-messages.d.ts.map +1 -1
  36. package/dist/esm/bridge/bridge-messages.js +182 -0
  37. package/dist/esm/bridge/bridge-messages.js.map +1 -1
  38. package/dist/esm/bridge/isolated-vm-bridge.d.ts +94 -13
  39. package/dist/esm/bridge/isolated-vm-bridge.d.ts.map +1 -1
  40. package/dist/esm/bridge/isolated-vm-bridge.js +151 -61
  41. package/dist/esm/bridge/isolated-vm-bridge.js.map +1 -1
  42. package/dist/esm/build.tsbuildinfo +1 -1
  43. package/dist/esm/extensions/boolean-extensions.d.ts +1 -1
  44. package/dist/esm/pool/idle-scaling-pool.js +2 -2
  45. package/dist/esm/pool/idle-scaling-pool.js.map +1 -1
  46. package/dist/esm/runtime/context.d.ts +1 -4
  47. package/dist/esm/runtime/context.d.ts.map +1 -1
  48. package/dist/esm/runtime/context.js +122 -13
  49. package/dist/esm/runtime/context.js.map +1 -1
  50. package/dist/esm/runtime/index.d.ts +1 -1
  51. package/dist/esm/runtime/index.d.ts.map +1 -1
  52. package/dist/esm/runtime/jmespath.d.ts +5 -3
  53. package/dist/esm/runtime/jmespath.d.ts.map +1 -1
  54. package/dist/esm/runtime/jmespath.js +5 -3
  55. package/dist/esm/runtime/jmespath.js.map +1 -1
  56. package/dist/esm/runtime/lazy-proxy.d.ts +7 -5
  57. package/dist/esm/runtime/lazy-proxy.d.ts.map +1 -1
  58. package/dist/esm/runtime/lazy-proxy.js +8 -16
  59. package/dist/esm/runtime/lazy-proxy.js.map +1 -1
  60. package/dist/esm/types/evaluator.d.ts +69 -4
  61. package/dist/esm/types/evaluator.d.ts.map +1 -1
  62. package/dist/esm/types/evaluator.js.map +1 -1
  63. package/package.json +7 -5
@@ -77,6 +77,287 @@ export declare const getNodeAllMessage: z.ZodObject<{
77
77
  branchIndex?: number | undefined;
78
78
  runIndex?: number | undefined;
79
79
  }>;
80
+ /**
81
+ * `$input.first()` — fetch the first item of the current node's input.
82
+ * Host enforces zero arguments; the schema has no fields besides `type`.
83
+ */
84
+ export declare const getInputFirstMessage: z.ZodObject<{
85
+ type: z.ZodLiteral<"getInputFirst">;
86
+ }, "strict", z.ZodTypeAny, {
87
+ type: "getInputFirst";
88
+ }, {
89
+ type: "getInputFirst";
90
+ }>;
91
+ /**
92
+ * `$input.last()` — fetch the last item of the current node's input.
93
+ */
94
+ export declare const getInputLastMessage: z.ZodObject<{
95
+ type: z.ZodLiteral<"getInputLast">;
96
+ }, "strict", z.ZodTypeAny, {
97
+ type: "getInputLast";
98
+ }, {
99
+ type: "getInputLast";
100
+ }>;
101
+ /**
102
+ * `$input.all()` — fetch every item of the current node's input.
103
+ */
104
+ export declare const getInputAllMessage: z.ZodObject<{
105
+ type: z.ZodLiteral<"getInputAll">;
106
+ }, "strict", z.ZodTypeAny, {
107
+ type: "getInputAll";
108
+ }, {
109
+ type: "getInputAll";
110
+ }>;
111
+ /**
112
+ * `$items(nodeName?, outputIndex?, runIndex?)` — fetch the execution data of
113
+ * a node by name (or the current node's input if `nodeName` is omitted).
114
+ *
115
+ * `runIndex` accepts negative values: the host uses `-1` as a sentinel for
116
+ * "latest run" (see `WorkflowDataProxy.$items` —
117
+ * `runIndex === undefined ? -1 : runIndex`). The schema uses
118
+ * `z.number().int()` without `.nonnegative()` so expressions can pass `-1`
119
+ * explicitly if they need to.
120
+ */
121
+ export declare const getItemsMessage: z.ZodObject<{
122
+ type: z.ZodLiteral<"getItems">;
123
+ nodeName: z.ZodOptional<z.ZodString>;
124
+ outputIndex: z.ZodOptional<z.ZodNumber>;
125
+ runIndex: z.ZodOptional<z.ZodNumber>;
126
+ }, "strict", z.ZodTypeAny, {
127
+ type: "getItems";
128
+ nodeName?: string | undefined;
129
+ runIndex?: number | undefined;
130
+ outputIndex?: number | undefined;
131
+ }, {
132
+ type: "getItems";
133
+ nodeName?: string | undefined;
134
+ runIndex?: number | undefined;
135
+ outputIndex?: number | undefined;
136
+ }>;
137
+ /**
138
+ * `$fromAI(name, description?, type?, defaultValue?)` — the AI-builder
139
+ * placeholder accessor (aliases: `$fromAi`, `$fromai`).
140
+ *
141
+ * Two deliberate looseness points in this schema, both to preserve host
142
+ * contract / parity:
143
+ *
144
+ * 1. `name` is `z.string().optional()` (not required) so a call missing
145
+ * the argument or passing an empty string reaches the host, which
146
+ * throws the user-friendly `ExpressionError("Add a key, e.g. $fromAI('placeholder_name')")`.
147
+ * Requiring it here would replace that error with a generic zod
148
+ * message. The host also validates the regex `[a-zA-Z0-9_-]{0,64}`;
149
+ * we don't pre-empt that either.
150
+ * 2. `defaultValue` is `z.unknown()` because the host accepts any value
151
+ * as the fallback return (`handleFromAi` returns it directly via
152
+ * `??`). Structured-clone at the bridge boundary still prevents
153
+ * functions and other non-cloneable values from crossing.
154
+ *
155
+ * `description` and `type` are forwarded even though the host currently
156
+ * ignores them (`_description`, `_type`), so the protocol matches the
157
+ * documented call signature.
158
+ */
159
+ export declare const fromAiMessage: z.ZodObject<{
160
+ type: z.ZodLiteral<"fromAi">;
161
+ name: z.ZodOptional<z.ZodString>;
162
+ description: z.ZodOptional<z.ZodString>;
163
+ valueType: z.ZodOptional<z.ZodString>;
164
+ defaultValue: z.ZodUnknown;
165
+ }, "strict", z.ZodTypeAny, {
166
+ type: "fromAi";
167
+ name?: string | undefined;
168
+ description?: string | undefined;
169
+ valueType?: string | undefined;
170
+ defaultValue?: unknown;
171
+ }, {
172
+ type: "fromAi";
173
+ name?: string | undefined;
174
+ description?: string | undefined;
175
+ valueType?: string | undefined;
176
+ defaultValue?: unknown;
177
+ }>;
178
+ /**
179
+ * `$('NodeName').pairedItem(itemIndex?)` / `.itemMatching(itemIndex)` /
180
+ * `.item` — resolve the paired item for a referenced node.
181
+ *
182
+ * All three host-side surface forms share one internal resolver
183
+ * (`pairedItemMethod` in `WorkflowDataProxy`), but the resolver closes
184
+ * over the literal property name the bridge accessed on the host proxy
185
+ * — so the error message and getter-vs-method form depend on *which*
186
+ * property the bridge reads. Three separate discriminators, each
187
+ * mapping a handler to a fixed literal property name, are the only way
188
+ * to preserve the host's friendly errors (e.g. "Missing item index for
189
+ * .itemMatching()") and the `.item` getter semantics without
190
+ * duplicating logic in-isolate.
191
+ *
192
+ * `itemIndex` is optional on all three at the schema level; the host
193
+ * throws the appropriate `ExpressionError` when it's missing for
194
+ * `.itemMatching()`, and applies the current-itemIndex default for
195
+ * `.pairedItem` and `.item`.
196
+ */
197
+ export declare const getNodePairedItemMessage: z.ZodObject<{
198
+ type: z.ZodLiteral<"getNodePairedItem">;
199
+ nodeName: z.ZodString;
200
+ itemIndex: z.ZodOptional<z.ZodNumber>;
201
+ }, "strict", z.ZodTypeAny, {
202
+ type: "getNodePairedItem";
203
+ nodeName: string;
204
+ itemIndex?: number | undefined;
205
+ }, {
206
+ type: "getNodePairedItem";
207
+ nodeName: string;
208
+ itemIndex?: number | undefined;
209
+ }>;
210
+ /**
211
+ * `itemIndex` is `.optional()` even though `.itemMatching()` requires it
212
+ * at the host. The host's `pairedItemMethod` closure throws the friendly
213
+ * `"Missing item index for .itemMatching()"` error when the field is
214
+ * absent — keeping the schema permissive lets that host error surface
215
+ * verbatim instead of being replaced by a generic zod parse failure.
216
+ */
217
+ export declare const getNodeItemMatchingMessage: z.ZodObject<{
218
+ type: z.ZodLiteral<"getNodeItemMatching">;
219
+ nodeName: z.ZodString;
220
+ itemIndex: z.ZodOptional<z.ZodNumber>;
221
+ }, "strict", z.ZodTypeAny, {
222
+ type: "getNodeItemMatching";
223
+ nodeName: string;
224
+ itemIndex?: number | undefined;
225
+ }, {
226
+ type: "getNodeItemMatching";
227
+ nodeName: string;
228
+ itemIndex?: number | undefined;
229
+ }>;
230
+ export declare const getNodeItemMessage: z.ZodObject<{
231
+ type: z.ZodLiteral<"getNodeItem">;
232
+ nodeName: z.ZodString;
233
+ }, "strict", z.ZodTypeAny, {
234
+ type: "getNodeItem";
235
+ nodeName: string;
236
+ }, {
237
+ type: "getNodeItem";
238
+ nodeName: string;
239
+ }>;
240
+ /**
241
+ * `$evaluateExpression(expression, itemIndex?)` — evaluate a nested
242
+ * expression string at runtime against the same execution context.
243
+ *
244
+ * The host recursively invokes the expression engine on the `expression`
245
+ * string — under the VM engine this re-enters the bridge with a fresh
246
+ * evaluation. `itemIndex` is optional and defaults to the current item;
247
+ * the schema mirrors the existing "nonnegative int" constraint used by
248
+ * the node-data RPCs.
249
+ */
250
+ export declare const evaluateExpressionMessage: z.ZodObject<{
251
+ type: z.ZodLiteral<"evaluateExpression">;
252
+ expression: z.ZodString;
253
+ itemIndex: z.ZodOptional<z.ZodNumber>;
254
+ }, "strict", z.ZodTypeAny, {
255
+ type: "evaluateExpression";
256
+ expression: string;
257
+ itemIndex?: number | undefined;
258
+ }, {
259
+ type: "evaluateExpression";
260
+ expression: string;
261
+ itemIndex?: number | undefined;
262
+ }>;
263
+ /**
264
+ * `$getPairedItem(destinationNodeName, incomingSourceData, initialPairedItem)` —
265
+ * traverse the paired-item ancestry chain back to the named upstream node
266
+ * and return the matching execution item.
267
+ *
268
+ * Two host-side fields are deliberately omitted from the schema:
269
+ * - `usedMethodName` defaults to `$getPairedItem` on the host; the isolate
270
+ * has no reason to spoof a different method name in the error path.
271
+ * - `nodeBeforeLast` is an internal recursion argument; only the host
272
+ * itself sets it during the recursive walk.
273
+ *
274
+ * `incomingSourceData` is nullable because the host's signature accepts
275
+ * `ISourceData | null` (and throws a paired-item-not-found error when null).
276
+ */
277
+ export declare const getPairedItemMessage: z.ZodObject<{
278
+ type: z.ZodLiteral<"getPairedItem">;
279
+ destinationNodeName: z.ZodString;
280
+ incomingSourceData: z.ZodNullable<z.ZodObject<{
281
+ previousNode: z.ZodString;
282
+ previousNodeOutput: z.ZodOptional<z.ZodNumber>;
283
+ previousNodeRun: z.ZodOptional<z.ZodNumber>;
284
+ }, "strict", z.ZodTypeAny, {
285
+ previousNode: string;
286
+ previousNodeOutput?: number | undefined;
287
+ previousNodeRun?: number | undefined;
288
+ }, {
289
+ previousNode: string;
290
+ previousNodeOutput?: number | undefined;
291
+ previousNodeRun?: number | undefined;
292
+ }>>;
293
+ initialPairedItem: z.ZodObject<{
294
+ item: z.ZodNumber;
295
+ input: z.ZodOptional<z.ZodNumber>;
296
+ sourceOverwrite: z.ZodOptional<z.ZodObject<{
297
+ previousNode: z.ZodString;
298
+ previousNodeOutput: z.ZodOptional<z.ZodNumber>;
299
+ previousNodeRun: z.ZodOptional<z.ZodNumber>;
300
+ }, "strict", z.ZodTypeAny, {
301
+ previousNode: string;
302
+ previousNodeOutput?: number | undefined;
303
+ previousNodeRun?: number | undefined;
304
+ }, {
305
+ previousNode: string;
306
+ previousNodeOutput?: number | undefined;
307
+ previousNodeRun?: number | undefined;
308
+ }>>;
309
+ }, "strict", z.ZodTypeAny, {
310
+ item: number;
311
+ input?: number | undefined;
312
+ sourceOverwrite?: {
313
+ previousNode: string;
314
+ previousNodeOutput?: number | undefined;
315
+ previousNodeRun?: number | undefined;
316
+ } | undefined;
317
+ }, {
318
+ item: number;
319
+ input?: number | undefined;
320
+ sourceOverwrite?: {
321
+ previousNode: string;
322
+ previousNodeOutput?: number | undefined;
323
+ previousNodeRun?: number | undefined;
324
+ } | undefined;
325
+ }>;
326
+ }, "strict", z.ZodTypeAny, {
327
+ type: "getPairedItem";
328
+ destinationNodeName: string;
329
+ incomingSourceData: {
330
+ previousNode: string;
331
+ previousNodeOutput?: number | undefined;
332
+ previousNodeRun?: number | undefined;
333
+ } | null;
334
+ initialPairedItem: {
335
+ item: number;
336
+ input?: number | undefined;
337
+ sourceOverwrite?: {
338
+ previousNode: string;
339
+ previousNodeOutput?: number | undefined;
340
+ previousNodeRun?: number | undefined;
341
+ } | undefined;
342
+ };
343
+ }, {
344
+ type: "getPairedItem";
345
+ destinationNodeName: string;
346
+ incomingSourceData: {
347
+ previousNode: string;
348
+ previousNodeOutput?: number | undefined;
349
+ previousNodeRun?: number | undefined;
350
+ } | null;
351
+ initialPairedItem: {
352
+ item: number;
353
+ input?: number | undefined;
354
+ sourceOverwrite?: {
355
+ previousNode: string;
356
+ previousNodeOutput?: number | undefined;
357
+ previousNodeRun?: number | undefined;
358
+ } | undefined;
359
+ };
360
+ }>;
80
361
  /**
81
362
  * The full set of messages the bridge will accept. Discriminator is `type`.
82
363
  *
@@ -129,6 +410,185 @@ export declare const bridgeMessageSchema: z.ZodDiscriminatedUnion<"type", [z.Zod
129
410
  nodeName: string;
130
411
  branchIndex?: number | undefined;
131
412
  runIndex?: number | undefined;
413
+ }>, z.ZodObject<{
414
+ type: z.ZodLiteral<"getInputFirst">;
415
+ }, "strict", z.ZodTypeAny, {
416
+ type: "getInputFirst";
417
+ }, {
418
+ type: "getInputFirst";
419
+ }>, z.ZodObject<{
420
+ type: z.ZodLiteral<"getInputLast">;
421
+ }, "strict", z.ZodTypeAny, {
422
+ type: "getInputLast";
423
+ }, {
424
+ type: "getInputLast";
425
+ }>, z.ZodObject<{
426
+ type: z.ZodLiteral<"getInputAll">;
427
+ }, "strict", z.ZodTypeAny, {
428
+ type: "getInputAll";
429
+ }, {
430
+ type: "getInputAll";
431
+ }>, z.ZodObject<{
432
+ type: z.ZodLiteral<"getItems">;
433
+ nodeName: z.ZodOptional<z.ZodString>;
434
+ outputIndex: z.ZodOptional<z.ZodNumber>;
435
+ runIndex: z.ZodOptional<z.ZodNumber>;
436
+ }, "strict", z.ZodTypeAny, {
437
+ type: "getItems";
438
+ nodeName?: string | undefined;
439
+ runIndex?: number | undefined;
440
+ outputIndex?: number | undefined;
441
+ }, {
442
+ type: "getItems";
443
+ nodeName?: string | undefined;
444
+ runIndex?: number | undefined;
445
+ outputIndex?: number | undefined;
446
+ }>, z.ZodObject<{
447
+ type: z.ZodLiteral<"fromAi">;
448
+ name: z.ZodOptional<z.ZodString>;
449
+ description: z.ZodOptional<z.ZodString>;
450
+ valueType: z.ZodOptional<z.ZodString>;
451
+ defaultValue: z.ZodUnknown;
452
+ }, "strict", z.ZodTypeAny, {
453
+ type: "fromAi";
454
+ name?: string | undefined;
455
+ description?: string | undefined;
456
+ valueType?: string | undefined;
457
+ defaultValue?: unknown;
458
+ }, {
459
+ type: "fromAi";
460
+ name?: string | undefined;
461
+ description?: string | undefined;
462
+ valueType?: string | undefined;
463
+ defaultValue?: unknown;
464
+ }>, z.ZodObject<{
465
+ type: z.ZodLiteral<"getNodePairedItem">;
466
+ nodeName: z.ZodString;
467
+ itemIndex: z.ZodOptional<z.ZodNumber>;
468
+ }, "strict", z.ZodTypeAny, {
469
+ type: "getNodePairedItem";
470
+ nodeName: string;
471
+ itemIndex?: number | undefined;
472
+ }, {
473
+ type: "getNodePairedItem";
474
+ nodeName: string;
475
+ itemIndex?: number | undefined;
476
+ }>, z.ZodObject<{
477
+ type: z.ZodLiteral<"getNodeItemMatching">;
478
+ nodeName: z.ZodString;
479
+ itemIndex: z.ZodOptional<z.ZodNumber>;
480
+ }, "strict", z.ZodTypeAny, {
481
+ type: "getNodeItemMatching";
482
+ nodeName: string;
483
+ itemIndex?: number | undefined;
484
+ }, {
485
+ type: "getNodeItemMatching";
486
+ nodeName: string;
487
+ itemIndex?: number | undefined;
488
+ }>, z.ZodObject<{
489
+ type: z.ZodLiteral<"getNodeItem">;
490
+ nodeName: z.ZodString;
491
+ }, "strict", z.ZodTypeAny, {
492
+ type: "getNodeItem";
493
+ nodeName: string;
494
+ }, {
495
+ type: "getNodeItem";
496
+ nodeName: string;
497
+ }>, z.ZodObject<{
498
+ type: z.ZodLiteral<"evaluateExpression">;
499
+ expression: z.ZodString;
500
+ itemIndex: z.ZodOptional<z.ZodNumber>;
501
+ }, "strict", z.ZodTypeAny, {
502
+ type: "evaluateExpression";
503
+ expression: string;
504
+ itemIndex?: number | undefined;
505
+ }, {
506
+ type: "evaluateExpression";
507
+ expression: string;
508
+ itemIndex?: number | undefined;
509
+ }>, z.ZodObject<{
510
+ type: z.ZodLiteral<"getPairedItem">;
511
+ destinationNodeName: z.ZodString;
512
+ incomingSourceData: z.ZodNullable<z.ZodObject<{
513
+ previousNode: z.ZodString;
514
+ previousNodeOutput: z.ZodOptional<z.ZodNumber>;
515
+ previousNodeRun: z.ZodOptional<z.ZodNumber>;
516
+ }, "strict", z.ZodTypeAny, {
517
+ previousNode: string;
518
+ previousNodeOutput?: number | undefined;
519
+ previousNodeRun?: number | undefined;
520
+ }, {
521
+ previousNode: string;
522
+ previousNodeOutput?: number | undefined;
523
+ previousNodeRun?: number | undefined;
524
+ }>>;
525
+ initialPairedItem: z.ZodObject<{
526
+ item: z.ZodNumber;
527
+ input: z.ZodOptional<z.ZodNumber>;
528
+ sourceOverwrite: z.ZodOptional<z.ZodObject<{
529
+ previousNode: z.ZodString;
530
+ previousNodeOutput: z.ZodOptional<z.ZodNumber>;
531
+ previousNodeRun: z.ZodOptional<z.ZodNumber>;
532
+ }, "strict", z.ZodTypeAny, {
533
+ previousNode: string;
534
+ previousNodeOutput?: number | undefined;
535
+ previousNodeRun?: number | undefined;
536
+ }, {
537
+ previousNode: string;
538
+ previousNodeOutput?: number | undefined;
539
+ previousNodeRun?: number | undefined;
540
+ }>>;
541
+ }, "strict", z.ZodTypeAny, {
542
+ item: number;
543
+ input?: number | undefined;
544
+ sourceOverwrite?: {
545
+ previousNode: string;
546
+ previousNodeOutput?: number | undefined;
547
+ previousNodeRun?: number | undefined;
548
+ } | undefined;
549
+ }, {
550
+ item: number;
551
+ input?: number | undefined;
552
+ sourceOverwrite?: {
553
+ previousNode: string;
554
+ previousNodeOutput?: number | undefined;
555
+ previousNodeRun?: number | undefined;
556
+ } | undefined;
557
+ }>;
558
+ }, "strict", z.ZodTypeAny, {
559
+ type: "getPairedItem";
560
+ destinationNodeName: string;
561
+ incomingSourceData: {
562
+ previousNode: string;
563
+ previousNodeOutput?: number | undefined;
564
+ previousNodeRun?: number | undefined;
565
+ } | null;
566
+ initialPairedItem: {
567
+ item: number;
568
+ input?: number | undefined;
569
+ sourceOverwrite?: {
570
+ previousNode: string;
571
+ previousNodeOutput?: number | undefined;
572
+ previousNodeRun?: number | undefined;
573
+ } | undefined;
574
+ };
575
+ }, {
576
+ type: "getPairedItem";
577
+ destinationNodeName: string;
578
+ incomingSourceData: {
579
+ previousNode: string;
580
+ previousNodeOutput?: number | undefined;
581
+ previousNodeRun?: number | undefined;
582
+ } | null;
583
+ initialPairedItem: {
584
+ item: number;
585
+ input?: number | undefined;
586
+ sourceOverwrite?: {
587
+ previousNode: string;
588
+ previousNodeOutput?: number | undefined;
589
+ previousNodeRun?: number | undefined;
590
+ } | undefined;
591
+ };
132
592
  }>]>;
133
593
  export type BridgeMessage = z.infer<typeof bridgeMessageSchema>;
134
594
  //# sourceMappingURL=bridge-messages.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-messages.d.ts","sourceRoot":"","sources":["../../../src/bridge/bridge-messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;EAOtB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;EAOrB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;EAOpB,CAAC;AAEX;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAI9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
1
+ {"version":3,"file":"bridge-messages.d.ts","sourceRoot":"","sources":["../../../src/bridge/bridge-messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;EAOtB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;EAOrB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;EAOpB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;EAA0D,CAAC;AAE5F;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;EAAyD,CAAC;AAE1F;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;EAAwD,CAAC;AAExF;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;EAOlB,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;EAShB,CAAC;AAEX;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;EAM3B,CAAC;AAEX;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;EAM7B,CAAC;AAEX,eAAO,MAAM,kBAAkB;;;;;;;;;EAKrB,CAAC;AAEX;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;EAM5B,CAAC;AA4BX;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOvB,CAAC;AAEX;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAc9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -27,7 +27,7 @@
27
27
  })(function (require, exports) {
28
28
  "use strict";
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.bridgeMessageSchema = exports.getNodeAllMessage = exports.getNodeLastMessage = exports.getNodeFirstMessage = void 0;
30
+ exports.bridgeMessageSchema = exports.getPairedItemMessage = exports.evaluateExpressionMessage = exports.getNodeItemMessage = exports.getNodeItemMatchingMessage = exports.getNodePairedItemMessage = exports.fromAiMessage = exports.getItemsMessage = exports.getInputAllMessage = exports.getInputLastMessage = exports.getInputFirstMessage = exports.getNodeAllMessage = exports.getNodeLastMessage = exports.getNodeFirstMessage = void 0;
31
31
  const zod_1 = require("zod");
32
32
  /**
33
33
  * `$('NodeName').first(branchIndex?, runIndex?)` — fetch the first item of
@@ -65,6 +65,178 @@
65
65
  runIndex: zod_1.z.number().int().nonnegative().optional(),
66
66
  })
67
67
  .strict();
68
+ /**
69
+ * `$input.first()` — fetch the first item of the current node's input.
70
+ * Host enforces zero arguments; the schema has no fields besides `type`.
71
+ */
72
+ exports.getInputFirstMessage = zod_1.z.object({ type: zod_1.z.literal('getInputFirst') }).strict();
73
+ /**
74
+ * `$input.last()` — fetch the last item of the current node's input.
75
+ */
76
+ exports.getInputLastMessage = zod_1.z.object({ type: zod_1.z.literal('getInputLast') }).strict();
77
+ /**
78
+ * `$input.all()` — fetch every item of the current node's input.
79
+ */
80
+ exports.getInputAllMessage = zod_1.z.object({ type: zod_1.z.literal('getInputAll') }).strict();
81
+ /**
82
+ * `$items(nodeName?, outputIndex?, runIndex?)` — fetch the execution data of
83
+ * a node by name (or the current node's input if `nodeName` is omitted).
84
+ *
85
+ * `runIndex` accepts negative values: the host uses `-1` as a sentinel for
86
+ * "latest run" (see `WorkflowDataProxy.$items` —
87
+ * `runIndex === undefined ? -1 : runIndex`). The schema uses
88
+ * `z.number().int()` without `.nonnegative()` so expressions can pass `-1`
89
+ * explicitly if they need to.
90
+ */
91
+ exports.getItemsMessage = zod_1.z
92
+ .object({
93
+ type: zod_1.z.literal('getItems'),
94
+ nodeName: zod_1.z.string().optional(),
95
+ outputIndex: zod_1.z.number().int().nonnegative().optional(),
96
+ runIndex: zod_1.z.number().int().optional(),
97
+ })
98
+ .strict();
99
+ /**
100
+ * `$fromAI(name, description?, type?, defaultValue?)` — the AI-builder
101
+ * placeholder accessor (aliases: `$fromAi`, `$fromai`).
102
+ *
103
+ * Two deliberate looseness points in this schema, both to preserve host
104
+ * contract / parity:
105
+ *
106
+ * 1. `name` is `z.string().optional()` (not required) so a call missing
107
+ * the argument or passing an empty string reaches the host, which
108
+ * throws the user-friendly `ExpressionError("Add a key, e.g. $fromAI('placeholder_name')")`.
109
+ * Requiring it here would replace that error with a generic zod
110
+ * message. The host also validates the regex `[a-zA-Z0-9_-]{0,64}`;
111
+ * we don't pre-empt that either.
112
+ * 2. `defaultValue` is `z.unknown()` because the host accepts any value
113
+ * as the fallback return (`handleFromAi` returns it directly via
114
+ * `??`). Structured-clone at the bridge boundary still prevents
115
+ * functions and other non-cloneable values from crossing.
116
+ *
117
+ * `description` and `type` are forwarded even though the host currently
118
+ * ignores them (`_description`, `_type`), so the protocol matches the
119
+ * documented call signature.
120
+ */
121
+ exports.fromAiMessage = zod_1.z
122
+ .object({
123
+ type: zod_1.z.literal('fromAi'),
124
+ name: zod_1.z.string().optional(),
125
+ description: zod_1.z.string().optional(),
126
+ valueType: zod_1.z.string().optional(),
127
+ // `z.unknown()` already accepts `undefined`, so no `.optional()` needed.
128
+ defaultValue: zod_1.z.unknown(),
129
+ })
130
+ .strict();
131
+ /**
132
+ * `$('NodeName').pairedItem(itemIndex?)` / `.itemMatching(itemIndex)` /
133
+ * `.item` — resolve the paired item for a referenced node.
134
+ *
135
+ * All three host-side surface forms share one internal resolver
136
+ * (`pairedItemMethod` in `WorkflowDataProxy`), but the resolver closes
137
+ * over the literal property name the bridge accessed on the host proxy
138
+ * — so the error message and getter-vs-method form depend on *which*
139
+ * property the bridge reads. Three separate discriminators, each
140
+ * mapping a handler to a fixed literal property name, are the only way
141
+ * to preserve the host's friendly errors (e.g. "Missing item index for
142
+ * .itemMatching()") and the `.item` getter semantics without
143
+ * duplicating logic in-isolate.
144
+ *
145
+ * `itemIndex` is optional on all three at the schema level; the host
146
+ * throws the appropriate `ExpressionError` when it's missing for
147
+ * `.itemMatching()`, and applies the current-itemIndex default for
148
+ * `.pairedItem` and `.item`.
149
+ */
150
+ exports.getNodePairedItemMessage = zod_1.z
151
+ .object({
152
+ type: zod_1.z.literal('getNodePairedItem'),
153
+ nodeName: zod_1.z.string(),
154
+ itemIndex: zod_1.z.number().int().nonnegative().optional(),
155
+ })
156
+ .strict();
157
+ /**
158
+ * `itemIndex` is `.optional()` even though `.itemMatching()` requires it
159
+ * at the host. The host's `pairedItemMethod` closure throws the friendly
160
+ * `"Missing item index for .itemMatching()"` error when the field is
161
+ * absent — keeping the schema permissive lets that host error surface
162
+ * verbatim instead of being replaced by a generic zod parse failure.
163
+ */
164
+ exports.getNodeItemMatchingMessage = zod_1.z
165
+ .object({
166
+ type: zod_1.z.literal('getNodeItemMatching'),
167
+ nodeName: zod_1.z.string(),
168
+ itemIndex: zod_1.z.number().int().nonnegative().optional(),
169
+ })
170
+ .strict();
171
+ exports.getNodeItemMessage = zod_1.z
172
+ .object({
173
+ type: zod_1.z.literal('getNodeItem'),
174
+ nodeName: zod_1.z.string(),
175
+ })
176
+ .strict();
177
+ /**
178
+ * `$evaluateExpression(expression, itemIndex?)` — evaluate a nested
179
+ * expression string at runtime against the same execution context.
180
+ *
181
+ * The host recursively invokes the expression engine on the `expression`
182
+ * string — under the VM engine this re-enters the bridge with a fresh
183
+ * evaluation. `itemIndex` is optional and defaults to the current item;
184
+ * the schema mirrors the existing "nonnegative int" constraint used by
185
+ * the node-data RPCs.
186
+ */
187
+ exports.evaluateExpressionMessage = zod_1.z
188
+ .object({
189
+ type: zod_1.z.literal('evaluateExpression'),
190
+ expression: zod_1.z.string(),
191
+ itemIndex: zod_1.z.number().int().nonnegative().optional(),
192
+ })
193
+ .strict();
194
+ /**
195
+ * `ISourceData` — the source record that accompanies a paired-item
196
+ * traversal step. Mirrors the host interface used by
197
+ * `WorkflowDataProxy.getPairedItem`.
198
+ */
199
+ const sourceDataSchema = zod_1.z
200
+ .object({
201
+ previousNode: zod_1.z.string(),
202
+ previousNodeOutput: zod_1.z.number().int().nonnegative().optional(),
203
+ previousNodeRun: zod_1.z.number().int().nonnegative().optional(),
204
+ })
205
+ .strict();
206
+ /**
207
+ * `IPairedItemData` — one paired-item record. `sourceOverwrite` lets a
208
+ * node override the upstream source while the helper walks the ancestry
209
+ * chain; the field is optional and recurses through the same schema.
210
+ */
211
+ const pairedItemDataSchema = zod_1.z
212
+ .object({
213
+ item: zod_1.z.number().int().nonnegative(),
214
+ input: zod_1.z.number().int().nonnegative().optional(),
215
+ sourceOverwrite: sourceDataSchema.optional(),
216
+ })
217
+ .strict();
218
+ /**
219
+ * `$getPairedItem(destinationNodeName, incomingSourceData, initialPairedItem)` —
220
+ * traverse the paired-item ancestry chain back to the named upstream node
221
+ * and return the matching execution item.
222
+ *
223
+ * Two host-side fields are deliberately omitted from the schema:
224
+ * - `usedMethodName` defaults to `$getPairedItem` on the host; the isolate
225
+ * has no reason to spoof a different method name in the error path.
226
+ * - `nodeBeforeLast` is an internal recursion argument; only the host
227
+ * itself sets it during the recursive walk.
228
+ *
229
+ * `incomingSourceData` is nullable because the host's signature accepts
230
+ * `ISourceData | null` (and throws a paired-item-not-found error when null).
231
+ */
232
+ exports.getPairedItemMessage = zod_1.z
233
+ .object({
234
+ type: zod_1.z.literal('getPairedItem'),
235
+ destinationNodeName: zod_1.z.string(),
236
+ incomingSourceData: sourceDataSchema.nullable(),
237
+ initialPairedItem: pairedItemDataSchema,
238
+ })
239
+ .strict();
68
240
  /**
69
241
  * The full set of messages the bridge will accept. Discriminator is `type`.
70
242
  *
@@ -76,6 +248,16 @@
76
248
  exports.getNodeFirstMessage,
77
249
  exports.getNodeLastMessage,
78
250
  exports.getNodeAllMessage,
251
+ exports.getInputFirstMessage,
252
+ exports.getInputLastMessage,
253
+ exports.getInputAllMessage,
254
+ exports.getItemsMessage,
255
+ exports.fromAiMessage,
256
+ exports.getNodePairedItemMessage,
257
+ exports.getNodeItemMatchingMessage,
258
+ exports.getNodeItemMessage,
259
+ exports.evaluateExpressionMessage,
260
+ exports.getPairedItemMessage,
79
261
  ]);
80
262
  });
81
263
  //# sourceMappingURL=bridge-messages.js.map