@hexabot-ai/agentic 3.5.0-beta.0 → 3.6.0-beta.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 (145) hide show
  1. package/README.md +12 -3
  2. package/dist/cjs/action/abstract-action.js +51 -35
  3. package/dist/cjs/bindings/base-binding.js +229 -211
  4. package/dist/cjs/checkpoint.js +1 -1
  5. package/dist/cjs/context.js +2 -3
  6. package/dist/cjs/dsl.types.js +44 -90
  7. package/dist/cjs/errors.js +13 -1
  8. package/dist/cjs/index.js +3 -1
  9. package/dist/cjs/resume-payload.js +11 -1
  10. package/dist/cjs/runner-runtime-control.js +39 -27
  11. package/dist/cjs/step-executors/conditional-executor.js +2 -7
  12. package/dist/cjs/step-executors/loop-executor.js +14 -28
  13. package/dist/cjs/step-executors/parallel-executor.js +14 -25
  14. package/dist/cjs/step-executors/scope.js +25 -0
  15. package/dist/cjs/step-executors/skip-helpers.js +26 -34
  16. package/dist/cjs/step-executors/task-executor.js +58 -69
  17. package/dist/cjs/utils/flow-steps.js +41 -0
  18. package/dist/cjs/utils/naming.js +10 -10
  19. package/dist/cjs/utils/object-path.js +51 -0
  20. package/dist/cjs/utils/timeout.js +16 -39
  21. package/dist/cjs/validation-issue.js +14 -1
  22. package/dist/cjs/workflow-compiler.js +52 -96
  23. package/dist/cjs/workflow-fingerprint.js +22 -11
  24. package/dist/cjs/workflow-runner.js +19 -25
  25. package/dist/cjs/workflow-values.js +9 -7
  26. package/dist/cjs/workflow.js +44 -103
  27. package/dist/esm/action/abstract-action.js +51 -35
  28. package/dist/esm/bindings/base-binding.js +229 -211
  29. package/dist/esm/checkpoint.js +2 -2
  30. package/dist/esm/context.js +2 -3
  31. package/dist/esm/dsl.types.js +42 -88
  32. package/dist/esm/errors.js +11 -0
  33. package/dist/esm/index.js +2 -2
  34. package/dist/esm/resume-payload.js +10 -1
  35. package/dist/esm/runner-runtime-control.js +39 -27
  36. package/dist/esm/step-executors/conditional-executor.js +2 -7
  37. package/dist/esm/step-executors/loop-executor.js +14 -28
  38. package/dist/esm/step-executors/parallel-executor.js +14 -25
  39. package/dist/esm/step-executors/scope.js +21 -0
  40. package/dist/esm/step-executors/skip-helpers.js +27 -35
  41. package/dist/esm/step-executors/task-executor.js +58 -69
  42. package/dist/esm/utils/flow-steps.js +37 -0
  43. package/dist/esm/utils/naming.js +9 -9
  44. package/dist/esm/utils/object-path.js +46 -0
  45. package/dist/esm/utils/timeout.js +16 -39
  46. package/dist/esm/validation-issue.js +11 -0
  47. package/dist/esm/workflow-compiler.js +50 -95
  48. package/dist/esm/workflow-fingerprint.js +22 -11
  49. package/dist/esm/workflow-runner.js +21 -27
  50. package/dist/esm/workflow-values.js +7 -6
  51. package/dist/esm/workflow.js +43 -103
  52. package/dist/types/action/abstract-action.d.ts +7 -1
  53. package/dist/types/action/abstract-action.d.ts.map +1 -1
  54. package/dist/types/bindings/base-binding.d.ts +10 -0
  55. package/dist/types/bindings/base-binding.d.ts.map +1 -1
  56. package/dist/types/context.d.ts +2 -3
  57. package/dist/types/context.d.ts.map +1 -1
  58. package/dist/types/dsl.types.d.ts +7 -12
  59. package/dist/types/dsl.types.d.ts.map +1 -1
  60. package/dist/types/errors.d.ts +9 -0
  61. package/dist/types/errors.d.ts.map +1 -1
  62. package/dist/types/index.d.ts +2 -2
  63. package/dist/types/index.d.ts.map +1 -1
  64. package/dist/types/resume-payload.d.ts +7 -0
  65. package/dist/types/resume-payload.d.ts.map +1 -1
  66. package/dist/types/runner-runtime-control.d.ts.map +1 -1
  67. package/dist/types/step-executors/conditional-executor.d.ts.map +1 -1
  68. package/dist/types/step-executors/loop-executor.d.ts +2 -4
  69. package/dist/types/step-executors/loop-executor.d.ts.map +1 -1
  70. package/dist/types/step-executors/parallel-executor.d.ts.map +1 -1
  71. package/dist/types/step-executors/scope.d.ts +12 -0
  72. package/dist/types/step-executors/scope.d.ts.map +1 -0
  73. package/dist/types/step-executors/skip-helpers.d.ts +2 -8
  74. package/dist/types/step-executors/skip-helpers.d.ts.map +1 -1
  75. package/dist/types/step-executors/task-executor.d.ts.map +1 -1
  76. package/dist/types/utils/flow-steps.d.ts +16 -0
  77. package/dist/types/utils/flow-steps.d.ts.map +1 -0
  78. package/dist/types/utils/naming.d.ts +7 -7
  79. package/dist/types/utils/naming.d.ts.map +1 -1
  80. package/dist/types/utils/object-path.d.ts +11 -0
  81. package/dist/types/utils/object-path.d.ts.map +1 -0
  82. package/dist/types/utils/timeout.d.ts.map +1 -1
  83. package/dist/types/validation-issue.d.ts +13 -0
  84. package/dist/types/validation-issue.d.ts.map +1 -1
  85. package/dist/types/workflow-compiler.d.ts +15 -1
  86. package/dist/types/workflow-compiler.d.ts.map +1 -1
  87. package/dist/types/workflow-fingerprint.d.ts.map +1 -1
  88. package/dist/types/workflow-runner.d.ts +2 -0
  89. package/dist/types/workflow-runner.d.ts.map +1 -1
  90. package/dist/types/workflow-values.d.ts +2 -0
  91. package/dist/types/workflow-values.d.ts.map +1 -1
  92. package/dist/types/workflow.d.ts +2 -1
  93. package/dist/types/workflow.d.ts.map +1 -1
  94. package/examples/defs-bindings-agent/actions/ai-agent.ts +5 -3
  95. package/examples/defs-bindings-agent/actions/{caculate-score.ts → calculate-score.ts} +8 -8
  96. package/examples/defs-bindings-agent/actions/index.ts +2 -2
  97. package/examples/defs-bindings-agent/workflow.yml +2 -2
  98. package/examples/full/workflow.yml +20 -15
  99. package/examples/suspend-resume/workflow.yml +6 -3
  100. package/package.json +8 -5
  101. package/src/__tests__/checkpoint.test.ts +6 -1
  102. package/src/__tests__/resume-payload.test.ts +29 -0
  103. package/src/__tests__/test-helpers.ts +1 -1
  104. package/src/__tests__/validation.test.ts +330 -0
  105. package/src/__tests__/workflow-compiler.test.ts +278 -3
  106. package/src/__tests__/workflow-definition-path.test.ts +2 -0
  107. package/src/__tests__/workflow-fingerprint.test.ts +65 -0
  108. package/src/__tests__/workflow-runner.test.ts +280 -5
  109. package/src/__tests__/workflow-values.test.ts +13 -0
  110. package/src/__tests__/workflow.test.ts +4 -2
  111. package/src/action/__tests__/abstract-action-timing.test.ts +92 -0
  112. package/src/action/abstract-action.ts +67 -40
  113. package/src/bindings/base-binding.test.ts +470 -0
  114. package/src/bindings/base-binding.ts +344 -267
  115. package/src/checkpoint.ts +2 -4
  116. package/src/context.ts +2 -3
  117. package/src/dsl.types.ts +75 -154
  118. package/src/errors.ts +15 -0
  119. package/src/index.ts +2 -0
  120. package/src/resume-payload.ts +13 -3
  121. package/src/runner-runtime-control.ts +52 -29
  122. package/src/step-executors/conditional-executor.ts +3 -7
  123. package/src/step-executors/loop-executor.test.ts +55 -0
  124. package/src/step-executors/loop-executor.ts +16 -50
  125. package/src/step-executors/parallel-executor.ts +14 -37
  126. package/src/step-executors/scope.ts +30 -0
  127. package/src/step-executors/skip-helpers.test.ts +133 -0
  128. package/src/step-executors/skip-helpers.ts +43 -76
  129. package/src/step-executors/task-executor.test.ts +130 -1
  130. package/src/step-executors/task-executor.ts +109 -79
  131. package/src/utils/flow-steps.test.ts +121 -0
  132. package/src/utils/flow-steps.ts +62 -0
  133. package/src/utils/naming.test.ts +50 -0
  134. package/src/utils/naming.ts +11 -11
  135. package/src/utils/object-path.test.ts +70 -0
  136. package/src/utils/object-path.ts +67 -0
  137. package/src/utils/timeout.test.ts +152 -0
  138. package/src/utils/timeout.ts +26 -44
  139. package/src/validation-issue.test.ts +70 -0
  140. package/src/validation-issue.ts +27 -0
  141. package/src/workflow-compiler.ts +118 -180
  142. package/src/workflow-fingerprint.ts +23 -12
  143. package/src/workflow-runner.ts +28 -27
  144. package/src/workflow-values.ts +9 -7
  145. package/src/workflow.ts +58 -140
@@ -0,0 +1,470 @@
1
+ /*
2
+ * Hexabot — Fair Core License (FCL-1.0-ALv2)
3
+ * Copyright (c) 2026 Hexastack.
4
+ * Full terms: see LICENSE.md.
5
+ */
6
+
7
+ import { z } from 'zod';
8
+
9
+ import {
10
+ mountTaskBindings,
11
+ validateAndResolveBindings,
12
+ type BindingKindSchemas,
13
+ type DefLike,
14
+ } from './base-binding';
15
+
16
+ const kinds: BindingKindSchemas = {
17
+ tools: {
18
+ schema: z.record(z.string(), z.unknown()),
19
+ multiple: true,
20
+ supportedBindings: ['model'],
21
+ },
22
+ model: {
23
+ schema: z.strictObject({ name: z.string() }),
24
+ multiple: false,
25
+ },
26
+ };
27
+ const validate = (
28
+ defs: Record<string, DefLike>,
29
+ options?: Parameters<typeof validateAndResolveBindings>[1],
30
+ ) => validateAndResolveBindings({ defs }, options ?? { bindingKinds: kinds });
31
+ const codes = (defs: Record<string, DefLike>, options?: object) =>
32
+ validate(defs, options).issues.map(({ code, message }) => ({
33
+ code,
34
+ message,
35
+ }));
36
+
37
+ describe('validateAndResolveBindings', () => {
38
+ it('accepts a workflow without defs', () => {
39
+ expect(
40
+ validateAndResolveBindings({} as { defs: Record<string, DefLike> }),
41
+ ).toEqual({ issues: [], resolvedDefs: {} });
42
+ });
43
+
44
+ it('takes a bare binding kind registry as options', () => {
45
+ const result = validateAndResolveBindings(
46
+ { defs: { gpt: { kind: 'model', settings: { name: 'gpt' } } } },
47
+ kinds,
48
+ );
49
+
50
+ expect(result).toEqual({
51
+ issues: [],
52
+ resolvedDefs: {
53
+ gpt: { kind: 'model', payload: { settings: { name: 'gpt' } } },
54
+ },
55
+ });
56
+ });
57
+
58
+ it('requires a registry once a workflow declares bindings', () => {
59
+ expect(
60
+ codes(
61
+ { step: { kind: 'task', action: 'run', bindings: { model: 'gpt' } } },
62
+ {},
63
+ ),
64
+ ).toEqual([
65
+ {
66
+ code: 'binding_registry_required',
67
+ message:
68
+ 'Workflows that declare non-task defs or nested bindings require a non-empty "bindingKinds" registry.',
69
+ },
70
+ {
71
+ code: 'unknown_binding_kind',
72
+ message: 'defs.step.bindings.model: Unknown binding kind "model".',
73
+ },
74
+ ]);
75
+ });
76
+
77
+ describe('supported binding kinds', () => {
78
+ it('lets a task without action mount nothing', () => {
79
+ expect(
80
+ codes({
81
+ step: { kind: 'task', bindings: { model: 'gpt' } },
82
+ gpt: { kind: 'model', settings: { name: 'gpt' } },
83
+ }),
84
+ ).toEqual([
85
+ {
86
+ code: 'binding_unsupported',
87
+ message:
88
+ 'defs.step.bindings.model: "task" does not support binding kind "model". Supported binding kinds: <none>.',
89
+ },
90
+ ]);
91
+ });
92
+
93
+ it('reads the kinds a def may mount from its binding kind', () => {
94
+ expect(
95
+ codes({
96
+ lookup: {
97
+ kind: 'tools',
98
+ settings: {},
99
+ bindings: { model: 'gpt', tools: ['other'] },
100
+ },
101
+ other: { kind: 'tools', settings: {} },
102
+ gpt: { kind: 'model', settings: { name: 'gpt' } },
103
+ }),
104
+ ).toEqual([
105
+ {
106
+ code: 'binding_unsupported',
107
+ message:
108
+ 'defs.lookup.bindings.tools: "tools" does not support binding kind "tools". Supported binding kinds: model.',
109
+ },
110
+ ]);
111
+ });
112
+
113
+ it('reads the kinds a def may mount from its action when one is given', () => {
114
+ const defs = {
115
+ step: { kind: 'task', action: 'run', bindings: { model: 'gpt' } },
116
+ gpt: { kind: 'model', settings: { name: 'gpt' } },
117
+ };
118
+
119
+ expect(
120
+ codes(defs, {
121
+ bindingKinds: kinds,
122
+ actions: { run: { supportedBindings: ['model'] } },
123
+ }),
124
+ ).toEqual([]);
125
+ expect(
126
+ codes(defs, { bindingKinds: kinds, actions: { run: {} } }),
127
+ ).toEqual([
128
+ {
129
+ code: 'binding_unsupported',
130
+ message:
131
+ 'defs.step.bindings.model: "run" does not support binding kind "model". Supported binding kinds: <none>.',
132
+ },
133
+ ]);
134
+ });
135
+
136
+ it('does not judge the bindings of an action without a catalog', () => {
137
+ expect(
138
+ codes({
139
+ step: { kind: 'task', action: 'run', bindings: { model: 'gpt' } },
140
+ gpt: { kind: 'model', settings: { name: 'gpt' } },
141
+ }),
142
+ ).toEqual([]);
143
+ });
144
+
145
+ it('lets a def of an unknown kind mount nothing', () => {
146
+ expect(
147
+ codes({
148
+ remote: { kind: 'mcp', settings: {}, bindings: { model: 'gpt' } },
149
+ gpt: { kind: 'model', settings: { name: 'gpt' } },
150
+ }),
151
+ ).toEqual([
152
+ {
153
+ code: 'unknown_binding_kind',
154
+ message: 'defs.remote.kind: Unknown binding kind "mcp".',
155
+ },
156
+ {
157
+ code: 'binding_unsupported',
158
+ message:
159
+ 'defs.remote.bindings.model: "mcp" does not support binding kind "model". Supported binding kinds: <none>.',
160
+ },
161
+ ]);
162
+ });
163
+ });
164
+
165
+ describe('binding entry issues', () => {
166
+ const issueAt = (bindingKind: string, code: string, message: string) => ({
167
+ code,
168
+ message: `defs.step.bindings.${bindingKind}: ${message}`,
169
+ path: ['defs', 'step', 'bindings', bindingKind],
170
+ bindingKind,
171
+ });
172
+
173
+ it('locates every issue of a binding entry on that entry', () => {
174
+ const { issues } = validate(
175
+ {
176
+ step: {
177
+ kind: 'task',
178
+ action: 'run',
179
+ bindings: {
180
+ memory: 'notes',
181
+ model: ['gpt'],
182
+ tools: 'lookup',
183
+ },
184
+ },
185
+ gpt: { kind: 'model', settings: { name: 'gpt' } },
186
+ lookup: { kind: 'tools', settings: {} },
187
+ },
188
+ { bindingKinds: kinds, actions: { run: {} } },
189
+ );
190
+
191
+ expect(issues).toEqual([
192
+ issueAt(
193
+ 'memory',
194
+ 'unknown_binding_kind',
195
+ 'Unknown binding kind "memory".',
196
+ ),
197
+ issueAt(
198
+ 'model',
199
+ 'binding_ref',
200
+ 'Expected a single def reference string for binding kind "model".',
201
+ ),
202
+ issueAt(
203
+ 'tools',
204
+ 'binding_ref',
205
+ 'Expected an array of def references for binding kind "tools".',
206
+ ),
207
+ ]);
208
+ });
209
+
210
+ it('reports unsupported kinds, duplicates and bad references on the entry', () => {
211
+ const { issues } = validate(
212
+ {
213
+ step: {
214
+ kind: 'task',
215
+ action: 'run',
216
+ bindings: { tools: ['a', 'b', 'a', 'b', 'gpt', 'ghost'] },
217
+ },
218
+ a: { kind: 'tools', settings: {} },
219
+ b: { kind: 'tools', settings: {} },
220
+ gpt: { kind: 'model', settings: { name: 'gpt' } },
221
+ },
222
+ {
223
+ bindingKinds: kinds,
224
+ actions: { run: { supportedBindings: ['model', 'memory'] } },
225
+ },
226
+ );
227
+
228
+ expect(issues).toEqual([
229
+ issueAt(
230
+ 'tools',
231
+ 'binding_unsupported',
232
+ '"run" does not support binding kind "tools". Supported binding kinds: model, memory.',
233
+ ),
234
+ issueAt('tools', 'binding_ref', 'Duplicate def reference(s): a, b'),
235
+ issueAt(
236
+ 'tools',
237
+ 'binding_ref',
238
+ 'Def "gpt" has kind "model" and cannot be mounted as "tools".',
239
+ ),
240
+ issueAt('tools', 'binding_ref', 'Unknown def reference "ghost".'),
241
+ ]);
242
+ });
243
+ });
244
+
245
+ describe('missing actions', () => {
246
+ it('reports the missing action of a def whose settings are valid', () => {
247
+ expect(
248
+ codes(
249
+ { lookup: { kind: 'tools', action: 'ghost', settings: {} } },
250
+ { bindingKinds: kinds, actions: {} },
251
+ ),
252
+ ).toEqual([
253
+ {
254
+ code: 'missing_action',
255
+ message:
256
+ 'defs.lookup.action: No action implementation provided for "ghost".',
257
+ },
258
+ ]);
259
+ });
260
+
261
+ it('reports the missing action of a def of an unknown kind, after its kind', () => {
262
+ expect(
263
+ codes(
264
+ { remote: { kind: 'mcp', action: 'ghost', settings: {} } },
265
+ { bindingKinds: kinds, actions: {} },
266
+ ),
267
+ ).toEqual([
268
+ {
269
+ code: 'unknown_binding_kind',
270
+ message: 'defs.remote.kind: Unknown binding kind "mcp".',
271
+ },
272
+ {
273
+ code: 'missing_action',
274
+ message:
275
+ 'defs.remote.action: No action implementation provided for "ghost".',
276
+ },
277
+ ]);
278
+ });
279
+
280
+ it('lets a def other than a task leave its action empty', () => {
281
+ expect(
282
+ codes(
283
+ { lookup: { kind: 'tools', action: '', settings: {} } },
284
+ { bindingKinds: kinds, actions: {} },
285
+ ),
286
+ ).toEqual([]);
287
+ });
288
+ });
289
+
290
+ describe('def settings', () => {
291
+ it('checks settings against the kind, then against the action', () => {
292
+ const actions = {
293
+ lookup_action: { settingSchema: z.object({ limit: z.number() }) },
294
+ };
295
+
296
+ expect(
297
+ codes(
298
+ {
299
+ gpt: { kind: 'model', settings: {} },
300
+ lookup: { kind: 'tools', action: 'lookup_action', settings: {} },
301
+ search: {
302
+ kind: 'tools',
303
+ action: 'lookup_action',
304
+ settings: { limit: 3 },
305
+ },
306
+ },
307
+ { bindingKinds: kinds, actions },
308
+ ),
309
+ ).toEqual([
310
+ {
311
+ code: 'binding_settings',
312
+ message:
313
+ 'defs.gpt.settings.name: Invalid input: expected string, received undefined',
314
+ },
315
+ {
316
+ code: 'binding_settings',
317
+ message:
318
+ 'defs.lookup.settings.limit: Invalid input: expected number, received undefined',
319
+ },
320
+ ]);
321
+ });
322
+
323
+ it('skips the action check when the action declares no settings schema', () => {
324
+ expect(
325
+ codes(
326
+ { lookup: { kind: 'tools', action: 'lookup_action', settings: {} } },
327
+ { bindingKinds: kinds, actions: { lookup_action: {} } },
328
+ ),
329
+ ).toEqual([]);
330
+ });
331
+
332
+ it('locates settings issues on the root of the settings', () => {
333
+ expect(
334
+ validate({ gpt: { kind: 'model', settings: 'gpt' } }).issues,
335
+ ).toEqual([
336
+ {
337
+ code: 'binding_settings',
338
+ message:
339
+ 'defs.gpt.settings.<root>: Invalid input: expected object, received string',
340
+ path: ['defs', 'gpt', 'settings'],
341
+ },
342
+ ]);
343
+ });
344
+
345
+ it('does not mount a def whose settings do not match its kind', () => {
346
+ expect(
347
+ validate({
348
+ gpt: { kind: 'model', settings: {} },
349
+ lookup: { kind: 'tools', settings: {}, bindings: { model: 'gpt' } },
350
+ }).resolvedDefs,
351
+ ).toEqual({ lookup: { kind: 'tools', payload: { settings: {} } } });
352
+ });
353
+ });
354
+
355
+ describe('resolved defs', () => {
356
+ it('mounts nested bindings, the action and the description', () => {
357
+ const { resolvedDefs } = validate({
358
+ lookup: {
359
+ kind: 'tools',
360
+ action: 'lookup_action',
361
+ description: 'Looks things up',
362
+ settings: { depth: 1 },
363
+ bindings: { model: 'gpt' },
364
+ },
365
+ gpt: { kind: 'model', settings: { name: 'gpt' } },
366
+ });
367
+
368
+ expect(resolvedDefs).toEqual({
369
+ gpt: { kind: 'model', payload: { settings: { name: 'gpt' } } },
370
+ lookup: {
371
+ kind: 'tools',
372
+ payload: {
373
+ settings: { depth: 1 },
374
+ action: 'lookup_action',
375
+ description: 'Looks things up',
376
+ bindings: { model: { settings: { name: 'gpt' } } },
377
+ },
378
+ },
379
+ });
380
+ });
381
+
382
+ it('leaves a def reached through a cycle out of the def that reached it', () => {
383
+ const { resolvedDefs } = validate(
384
+ {
385
+ alpha: { kind: 'tools', settings: {}, bindings: { tools: ['beta'] } },
386
+ beta: { kind: 'tools', settings: {}, bindings: { tools: ['alpha'] } },
387
+ },
388
+ {
389
+ bindingKinds: {
390
+ tools: { ...kinds.tools, supportedBindings: ['tools'] },
391
+ },
392
+ },
393
+ );
394
+
395
+ expect(resolvedDefs).toEqual({
396
+ alpha: {
397
+ kind: 'tools',
398
+ payload: {
399
+ settings: {},
400
+ bindings: {
401
+ tools: {
402
+ beta: { settings: {} },
403
+ },
404
+ },
405
+ },
406
+ },
407
+ beta: { kind: 'tools', payload: { settings: {} } },
408
+ });
409
+ });
410
+ });
411
+ });
412
+
413
+ describe('mountTaskBindings', () => {
414
+ const resolvedDefs = {
415
+ gpt: { kind: 'model', payload: { settings: { name: 'gpt' } } },
416
+ lookup: { kind: 'tools', payload: { settings: {} } },
417
+ };
418
+
419
+ it('mounts nothing without bindings', () => {
420
+ expect(mountTaskBindings(undefined, resolvedDefs, kinds)).toEqual({});
421
+ });
422
+
423
+ it('mounts one payload for a single-ref kind and a map otherwise', () => {
424
+ expect(
425
+ mountTaskBindings(
426
+ { model: 'gpt', tools: ['lookup', 'missing'] },
427
+ resolvedDefs,
428
+ kinds,
429
+ ),
430
+ ).toEqual({
431
+ model: { settings: { name: 'gpt' } },
432
+ tools: { lookup: { settings: {} } },
433
+ });
434
+ });
435
+
436
+ it('tells single from multiple references by their shape without a registry', () => {
437
+ expect(
438
+ mountTaskBindings({ model: 'gpt', tools: ['lookup'] }, resolvedDefs),
439
+ ).toEqual({
440
+ model: { settings: { name: 'gpt' } },
441
+ tools: { lookup: { settings: {} } },
442
+ });
443
+ });
444
+
445
+ it('leaves out kinds whose references resolve to nothing', () => {
446
+ expect(
447
+ mountTaskBindings({ model: '', tools: ['missing'] }, resolvedDefs, kinds),
448
+ ).toEqual({});
449
+ expect(mountTaskBindings({ model: [] }, resolvedDefs, kinds)).toEqual({});
450
+ });
451
+
452
+ it('resolves references the resolved defs do not hold yet', () => {
453
+ const resolveDef = jest.fn((defName: string) =>
454
+ defName === 'late' ? { settings: { late: true } } : undefined,
455
+ );
456
+
457
+ expect(
458
+ mountTaskBindings(
459
+ { tools: ['lookup', 'late'] },
460
+ resolvedDefs,
461
+ kinds,
462
+ resolveDef,
463
+ ),
464
+ ).toEqual({
465
+ tools: { lookup: { settings: {} }, late: { settings: { late: true } } },
466
+ });
467
+ expect(resolveDef).toHaveBeenCalledTimes(1);
468
+ expect(resolveDef).toHaveBeenCalledWith('late');
469
+ });
470
+ });