@positronic/core 0.0.75 → 0.0.76

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 (53) hide show
  1. package/dist/src/dsl/brain-runner.js +7 -6
  2. package/dist/src/dsl/brain-state-machine.js +43 -14
  3. package/dist/src/dsl/builder/brain.js +85 -27
  4. package/dist/src/dsl/constants.js +2 -2
  5. package/dist/src/dsl/execution/event-stream.js +921 -354
  6. package/dist/src/dsl/iterate-result.js +161 -0
  7. package/dist/src/dsl/signal-validation.js +5 -5
  8. package/dist/src/index.js +1 -0
  9. package/dist/src/tools/index.js +0 -3
  10. package/dist/types/dsl/brain-runner.d.ts.map +1 -1
  11. package/dist/types/dsl/brain-state-machine.d.ts +11 -4
  12. package/dist/types/dsl/brain-state-machine.d.ts.map +1 -1
  13. package/dist/types/dsl/brain.d.ts +1 -1
  14. package/dist/types/dsl/brain.d.ts.map +1 -1
  15. package/dist/types/dsl/builder/brain.d.ts +58 -5
  16. package/dist/types/dsl/builder/brain.d.ts.map +1 -1
  17. package/dist/types/dsl/constants.d.ts +1 -1
  18. package/dist/types/dsl/create-brain.d.ts +14 -14
  19. package/dist/types/dsl/create-brain.d.ts.map +1 -1
  20. package/dist/types/dsl/definitions/blocks.d.ts +14 -4
  21. package/dist/types/dsl/definitions/blocks.d.ts.map +1 -1
  22. package/dist/types/dsl/definitions/events.d.ts +8 -6
  23. package/dist/types/dsl/definitions/events.d.ts.map +1 -1
  24. package/dist/types/dsl/definitions/run-params.d.ts +3 -1
  25. package/dist/types/dsl/definitions/run-params.d.ts.map +1 -1
  26. package/dist/types/dsl/duration.d.ts.map +1 -1
  27. package/dist/types/dsl/example-webhook.d.ts.map +1 -1
  28. package/dist/types/dsl/execution/event-stream.d.ts +19 -3
  29. package/dist/types/dsl/execution/event-stream.d.ts.map +1 -1
  30. package/dist/types/dsl/iterate-result.d.ts +13 -0
  31. package/dist/types/dsl/iterate-result.d.ts.map +1 -0
  32. package/dist/types/dsl/pages.d.ts.map +1 -1
  33. package/dist/types/dsl/signal-validation.d.ts.map +1 -1
  34. package/dist/types/dsl/types.d.ts +1 -3
  35. package/dist/types/dsl/types.d.ts.map +1 -1
  36. package/dist/types/dsl/webhook.d.ts +4 -0
  37. package/dist/types/dsl/webhook.d.ts.map +1 -1
  38. package/dist/types/index.d.ts +6 -5
  39. package/dist/types/index.d.ts.map +1 -1
  40. package/dist/types/store/index.d.ts +1 -1
  41. package/dist/types/store/index.d.ts.map +1 -1
  42. package/dist/types/store/types.d.ts +2 -2
  43. package/dist/types/store/types.d.ts.map +1 -1
  44. package/dist/types/tools/index.d.ts.map +1 -1
  45. package/dist/types/ui/generate-page-html.d.ts.map +1 -1
  46. package/dist/types/ui/generate-ui.d.ts.map +1 -1
  47. package/dist/types/ui/parse-form-data.d.ts.map +1 -1
  48. package/dist/types/ui/types.d.ts.map +1 -1
  49. package/dist/types/ui/validate-form.d.ts.map +1 -1
  50. package/dist/types/yaml/data-validator.d.ts.map +1 -1
  51. package/dist/types/yaml/parser.d.ts.map +1 -1
  52. package/dist/types/yaml/type-inference.d.ts.map +1 -1
  53. package/package.json +1 -1
@@ -281,7 +281,7 @@ import { DEFAULT_ENV } from './brain.js';
281
281
  * Adds agent context to the deepest level.
282
282
  * Webhook response is no longer passed here - it comes from signals during execution.
283
283
  * This is internal to BrainRunner - external consumers don't need to know about ResumeContext.
284
- */ function executionStackToResumeContext(stack, agentContext, batchContext) {
284
+ */ function executionStackToResumeContext(stack, agentContext, iterateContext, currentPage) {
285
285
  if (stack.length === 0) {
286
286
  throw new Error('Cannot convert empty execution stack to ResumeContext');
287
287
  }
@@ -290,12 +290,13 @@ import { DEFAULT_ENV } from './brain.js';
290
290
  for(var i = stack.length - 1; i >= 0; i--){
291
291
  var entry = stack[i];
292
292
  if (i === stack.length - 1) {
293
- // Deepest level - add agent context and batch progress (webhook response comes from signals now)
293
+ // Deepest level - add agent context, iterate progress, and page context
294
294
  context = {
295
295
  stepIndex: entry.stepIndex,
296
296
  state: entry.state,
297
297
  agentContext: agentContext !== null && agentContext !== void 0 ? agentContext : undefined,
298
- batchProgress: batchContext !== null && batchContext !== void 0 ? batchContext : undefined
298
+ iterateProgress: iterateContext !== null && iterateContext !== void 0 ? iterateContext : undefined,
299
+ currentPage: currentPage !== null && currentPage !== void 0 ? currentPage : undefined
299
300
  };
300
301
  } else {
301
302
  // Outer level - wrap inner context
@@ -427,13 +428,13 @@ export var BrainRunner = /*#__PURE__*/ function() {
427
428
  * Webhook response data comes from signals, not as a parameter.
428
429
  */ function resume(brain, options) {
429
430
  return _async_to_generator(function() {
430
- var machine, brainRunId, brainOptions, endAfter, signal, currentUser, _machine_context, executionStack, agentContext, batchContext, resumeContext;
431
+ var machine, brainRunId, brainOptions, endAfter, signal, currentUser, _machine_context, executionStack, agentContext, iterateContext, currentPage, resumeContext;
431
432
  return _ts_generator(this, function(_state) {
432
433
  machine = options.machine, brainRunId = options.brainRunId, brainOptions = options.options, endAfter = options.endAfter, signal = options.signal, currentUser = options.currentUser;
433
434
  // Build ResumeContext from machine's execution stack
434
435
  // Webhook response comes from signals during execution, not from resume parameters
435
- _machine_context = machine.context, executionStack = _machine_context.executionStack, agentContext = _machine_context.agentContext, batchContext = _machine_context.batchContext;
436
- resumeContext = executionStackToResumeContext(executionStack, agentContext, batchContext);
436
+ _machine_context = machine.context, executionStack = _machine_context.executionStack, agentContext = _machine_context.agentContext, iterateContext = _machine_context.iterateContext, currentPage = _machine_context.currentPage;
437
+ resumeContext = executionStackToResumeContext(executionStack, agentContext, iterateContext, currentPage);
437
438
  return [
438
439
  2,
439
440
  this.execute(brain, {
@@ -101,6 +101,7 @@ import { applyPatches } from './json-patch.js';
101
101
  brainRunId: entry.brainRunId,
102
102
  brainTitle: entry.brainTitle,
103
103
  brainDescription: entry.brainDescription,
104
+ options: entry.options,
104
105
  parentStepId: entry.parentStepId,
105
106
  steps: entry.steps,
106
107
  innerBrain: innerBrain,
@@ -125,7 +126,8 @@ var createInitialContext = function(opts) {
125
126
  currentState: (_opts_initialState = opts === null || opts === void 0 ? void 0 : opts.initialState) !== null && _opts_initialState !== void 0 ? _opts_initialState : {},
126
127
  options: (_opts_options = opts === null || opts === void 0 ? void 0 : opts.options) !== null && _opts_options !== void 0 ? _opts_options : {},
127
128
  agentContext: null,
128
- batchContext: null,
129
+ iterateContext: null,
130
+ currentPage: null,
129
131
  status: STATUS.PENDING,
130
132
  isTopLevel: false,
131
133
  isRunning: false,
@@ -190,7 +192,7 @@ var updateDerivedState = function(ctx, executionState) {
190
192
  // Reducers - Update context on transitions
191
193
  // ============================================================================
192
194
  var startBrain = reduce(function(ctx, param) {
193
- var brainRunId = param.brainRunId, brainTitle = param.brainTitle, brainDescription = param.brainDescription, initialState = param.initialState;
195
+ var brainRunId = param.brainRunId, brainTitle = param.brainTitle, brainDescription = param.brainDescription, options = param.options, initialState = param.initialState;
194
196
  var currentStepId = ctx.currentStepId, depth = ctx.depth, existingBrainRunId = ctx.brainRunId, currentState = ctx.currentState, brains = ctx.brains, brainIdStack = ctx.brainIdStack, executionStack = ctx.executionStack;
195
197
  var newDepth = depth + 1;
196
198
  var brainInitialState = initialState !== null && initialState !== void 0 ? initialState : currentState;
@@ -200,6 +202,7 @@ var startBrain = reduce(function(ctx, param) {
200
202
  brainRunId: brainRunId,
201
203
  brainTitle: brainTitle,
202
204
  brainDescription: brainDescription,
205
+ options: options,
203
206
  parentStepId: currentStepId,
204
207
  parentBrainId: parentBrainId,
205
208
  steps: [],
@@ -276,6 +279,19 @@ var errorBrain = reduce(function(ctx, param) {
276
279
  });
277
280
  return updateDerivedState(newCtx, 'error');
278
281
  });
282
+ var completeInnerBrainError = reduce(function(ctx, param) {
283
+ var error = param.error;
284
+ var depth = ctx.depth, brainIdStack = ctx.brainIdStack, executionStack = ctx.executionStack;
285
+ if (brainIdStack.length === 0) return ctx;
286
+ var newCtx = _object_spread_props(_object_spread({}, ctx), {
287
+ brainIdStack: brainIdStack.slice(0, -1),
288
+ executionStack: executionStack.slice(0, -1),
289
+ depth: depth - 1,
290
+ error: error,
291
+ agentContext: null
292
+ });
293
+ return updateDerivedState(newCtx, 'running');
294
+ });
279
295
  var cancelBrain = reduce(function(ctx) {
280
296
  return updateDerivedState(ctx, 'cancelled');
281
297
  });
@@ -319,7 +335,8 @@ var startStep = reduce(function(ctx, param) {
319
335
  });
320
336
  });
321
337
  var completeStep = reduce(function(ctx, param) {
322
- var stepId = param.stepId, stepTitle = param.stepTitle, patch = param.patch, halted = param.halted;
338
+ var stepId = param.stepId, stepTitle = param.stepTitle, patch = param.patch, halted = param.halted, pageContext = param.pageContext;
339
+ var _ctx_iterateContext;
323
340
  var brains = ctx.brains, brainIdStack = ctx.brainIdStack, executionStack = ctx.executionStack, depth = ctx.depth, currentState = ctx.currentState, topLevelStepCount = ctx.topLevelStepCount;
324
341
  if (brainIdStack.length === 0) return ctx;
325
342
  // === NEW: Update flat structures ===
@@ -374,12 +391,19 @@ var completeStep = reduce(function(ctx, param) {
374
391
  ]);
375
392
  newStepCount = topLevelStepCount + 1;
376
393
  }
394
+ // Only clear iterateContext when the iterate step itself completes,
395
+ // not when inner brain steps complete during iteration
396
+ var newIterateContext = ((_ctx_iterateContext = ctx.iterateContext) === null || _ctx_iterateContext === void 0 ? void 0 : _ctx_iterateContext.stepId) === stepId ? null : ctx.iterateContext;
397
+ // Track page context: set when UI step completes (has pageContext),
398
+ // clear when the next step completes (page is ephemeral)
399
+ var newCurrentPage = pageContext !== null && pageContext !== void 0 ? pageContext : null;
377
400
  return _object_spread_props(_object_spread({}, ctx), {
378
401
  brains: newBrains,
379
402
  executionStack: newExecutionStack,
380
403
  currentState: newState1,
381
404
  topLevelStepCount: newStepCount,
382
- batchContext: null
405
+ iterateContext: newIterateContext,
406
+ currentPage: newCurrentPage
383
407
  });
384
408
  });
385
409
  var webhookPause = reduce(function(ctx, param) {
@@ -442,15 +466,17 @@ var passthrough = function() {
442
466
  return ctx;
443
467
  });
444
468
  };
445
- // Reducer for BATCH_CHUNK_COMPLETE - merges chunk results into batchContext
446
- var batchChunkComplete = reduce(function(ctx, payload) {
447
- var existing = ctx.batchContext;
469
+ // Reducer for ITERATE_ITEM_COMPLETE - appends a single item result into iterateContext
470
+ var iterateItemComplete = reduce(function(ctx, payload) {
471
+ var existing = ctx.iterateContext;
448
472
  var newResults = (existing === null || existing === void 0 ? void 0 : existing.accumulatedResults) ? _to_consumable_array(existing.accumulatedResults) : [];
449
- for(var i = 0; i < payload.chunkResults.length; i++){
450
- newResults[payload.chunkStartIndex + i] = payload.chunkResults[i];
451
- }
473
+ newResults[payload.itemIndex] = payload.result != null ? [
474
+ payload.item,
475
+ payload.result
476
+ ] : undefined;
452
477
  return _object_spread_props(_object_spread({}, ctx), {
453
- batchContext: {
478
+ iterateContext: {
479
+ stepId: payload.stepId,
454
480
  accumulatedResults: newResults,
455
481
  processedCount: payload.processedCount,
456
482
  totalItems: payload.totalItems,
@@ -559,13 +585,14 @@ var makeBrainMachine = function(initialContext) {
559
585
  transition(BRAIN_EVENTS.START, 'running', startBrain), // Outer brain complete -> terminal
560
586
  transition(BRAIN_EVENTS.COMPLETE, 'complete', isOuterBrain, completeBrain), // Inner brain complete -> stay running
561
587
  transition(BRAIN_EVENTS.COMPLETE, 'running', isInnerBrain, completeBrain), // Error (only outer brain errors are terminal)
562
- transition(BRAIN_EVENTS.ERROR, 'error', isOuterBrain, errorBrain), // Cancelled
588
+ transition(BRAIN_EVENTS.ERROR, 'error', isOuterBrain, errorBrain), // Inner brain error -> stay running (pop the inner brain off the stack)
589
+ transition(BRAIN_EVENTS.ERROR, 'running', isInnerBrain, completeInnerBrainError), // Cancelled
563
590
  transition(BRAIN_EVENTS.CANCELLED, 'cancelled', cancelBrain), // Paused (by signal)
564
591
  transition(BRAIN_EVENTS.PAUSED, 'paused', pauseBrain), // Webhook -> waiting (for non-agent webhooks)
565
592
  transition(BRAIN_EVENTS.WEBHOOK, 'waiting', webhookPause), // Webhook response (for resume from non-agent webhook)
566
593
  transition(BRAIN_EVENTS.WEBHOOK_RESPONSE, 'running', webhookResponse), // Step events
567
- transition(BRAIN_EVENTS.STEP_START, 'running', startStep), transition(BRAIN_EVENTS.STEP_COMPLETE, 'running', completeStep), transition(BRAIN_EVENTS.STEP_STATUS, 'running', stepStatus), // Batch chunk complete - stays in running, accumulates results
568
- transition(BRAIN_EVENTS.BATCH_CHUNK_COMPLETE, 'running', batchChunkComplete), // AGENT_START transitions to the agentLoop state
594
+ transition(BRAIN_EVENTS.STEP_START, 'running', startStep), transition(BRAIN_EVENTS.STEP_COMPLETE, 'running', completeStep), transition(BRAIN_EVENTS.STEP_STATUS, 'running', stepStatus), // Iterate item complete - stays in running, accumulates results
595
+ transition(BRAIN_EVENTS.ITERATE_ITEM_COMPLETE, 'running', iterateItemComplete), // AGENT_START transitions to the agentLoop state
569
596
  transition(BRAIN_EVENTS.AGENT_START, 'agentLoop', agentStart)),
570
597
  // Explicit agent loop state - isolates agent execution logic
571
598
  agentLoop: state.apply(void 0, // Spread agent micro-transitions
@@ -579,6 +606,8 @@ var makeBrainMachine = function(initialContext) {
579
606
  transition(BRAIN_EVENTS.WEBHOOK, 'waiting', webhookPause),
580
607
  // Error handling
581
608
  transition(BRAIN_EVENTS.ERROR, 'error', isOuterBrain, errorBrain),
609
+ // Inner brain error -> back to running (pop inner brain, clear agentContext)
610
+ transition(BRAIN_EVENTS.ERROR, 'running', isInnerBrain, completeInnerBrainError),
582
611
  transition(BRAIN_EVENTS.CANCELLED, 'cancelled', cancelBrain)
583
612
  ])),
584
613
  paused: state(transition(BRAIN_EVENTS.CANCELLED, 'cancelled', cancelBrain), // RESUMED transitions out of paused state without creating a new brain
@@ -388,6 +388,7 @@ export var Brain = /*#__PURE__*/ function() {
388
388
  _define_property(this, "optionsSchema", void 0);
389
389
  _define_property(this, "components", void 0);
390
390
  _define_property(this, "defaultTools", void 0);
391
+ _define_property(this, "extraTools", void 0);
391
392
  _define_property(this, "memoryProvider", void 0);
392
393
  _define_property(this, "storeSchema", void 0);
393
394
  this.title = title;
@@ -447,6 +448,7 @@ export var Brain = /*#__PURE__*/ function() {
447
448
  nextBrain.optionsSchema = this.optionsSchema;
448
449
  nextBrain.components = this.components;
449
450
  nextBrain.defaultTools = this.defaultTools;
451
+ nextBrain.extraTools = this.extraTools;
450
452
  nextBrain.memoryProvider = this.memoryProvider;
451
453
  nextBrain.storeSchema = this.storeSchema;
452
454
  return nextBrain;
@@ -460,6 +462,7 @@ export var Brain = /*#__PURE__*/ function() {
460
462
  nextBrain.services = this.services;
461
463
  nextBrain.components = this.components;
462
464
  nextBrain.defaultTools = this.defaultTools;
465
+ nextBrain.extraTools = this.extraTools;
463
466
  nextBrain.memoryProvider = this.memoryProvider;
464
467
  nextBrain.storeSchema = this.storeSchema;
465
468
  return nextBrain;
@@ -486,6 +489,7 @@ export var Brain = /*#__PURE__*/ function() {
486
489
  nextBrain.services = this.services;
487
490
  nextBrain.components = components;
488
491
  nextBrain.defaultTools = this.defaultTools;
492
+ nextBrain.extraTools = this.extraTools;
489
493
  nextBrain.memoryProvider = this.memoryProvider;
490
494
  nextBrain.storeSchema = this.storeSchema;
491
495
  return nextBrain;
@@ -520,6 +524,31 @@ export var Brain = /*#__PURE__*/ function() {
520
524
  },
521
525
  {
522
526
  /**
527
+ * Add extra tools on top of whatever default tools are already configured.
528
+ * Unlike `withTools()` which replaces defaults, this merges additively.
529
+ *
530
+ * @param tools - Record of additional tool definitions
531
+ *
532
+ * @example
533
+ * ```typescript
534
+ * const myBrain = createBrain({ defaultTools })
535
+ * ('my-brain')
536
+ * .withExtraTools({ myCustomTool })
537
+ * .brain('agent', ({ tools }) => ({
538
+ * system: 'You are helpful',
539
+ * prompt: 'Do something',
540
+ * tools // includes both defaults and myCustomTool
541
+ * }));
542
+ * ```
543
+ */ key: "withExtraTools",
544
+ value: function withExtraTools(tools) {
545
+ var next = this.nextBrain();
546
+ next.extraTools = tools;
547
+ return next;
548
+ }
549
+ },
550
+ {
551
+ /**
523
552
  * Configure a memory provider for this brain.
524
553
  * When configured, steps receive a scoped memory instance in their context.
525
554
  *
@@ -573,6 +602,7 @@ export var Brain = /*#__PURE__*/ function() {
573
602
  nextBrain.services = this.services;
574
603
  nextBrain.components = this.components;
575
604
  nextBrain.defaultTools = this.defaultTools;
605
+ nextBrain.extraTools = this.extraTools;
576
606
  nextBrain.memoryProvider = this.memoryProvider;
577
607
  nextBrain.storeSchema = storeSchema;
578
608
  return nextBrain;
@@ -619,10 +649,32 @@ export var Brain = /*#__PURE__*/ function() {
619
649
  {
620
650
  // Implementation
621
651
  key: "brain",
622
- value: function brain(title, innerBrainOrConfig, action, initialState) {
652
+ value: function brain(title, innerBrainOrConfig, actionOrIterateConfig, initialState) {
653
+ // Detect iterate config: 3rd arg is an object with `over` property
654
+ var isIterateConfig = actionOrIterateConfig && (typeof actionOrIterateConfig === "undefined" ? "undefined" : _type_of(actionOrIterateConfig)) === 'object' && 'over' in actionOrIterateConfig;
623
655
  // Case 1: Nested brain instance
624
656
  if (innerBrainOrConfig && (typeof innerBrainOrConfig === "undefined" ? "undefined" : _type_of(innerBrainOrConfig)) === 'object' && 'type' in innerBrainOrConfig && innerBrainOrConfig.type === 'brain') {
625
- var nestedBlock = {
657
+ if (isIterateConfig) {
658
+ // Case 1b: Nested brain with iterate
659
+ var iterateConfig = actionOrIterateConfig;
660
+ var nestedBlock = {
661
+ type: 'brain',
662
+ title: title,
663
+ innerBrain: innerBrainOrConfig,
664
+ initialState: function() {
665
+ return {};
666
+ },
667
+ action: function() {
668
+ return {};
669
+ },
670
+ iterateConfig: iterateConfig
671
+ };
672
+ this.blocks.push(nestedBlock);
673
+ return this.nextBrain();
674
+ }
675
+ // Case 1a: Single nested brain (existing behavior)
676
+ var action = actionOrIterateConfig;
677
+ var nestedBlock1 = {
626
678
  type: 'brain',
627
679
  title: title,
628
680
  innerBrain: innerBrainOrConfig,
@@ -637,26 +689,39 @@ export var Brain = /*#__PURE__*/ function() {
637
689
  });
638
690
  }
639
691
  };
640
- this.blocks.push(nestedBlock);
692
+ this.blocks.push(nestedBlock1);
641
693
  return this.nextBrain();
642
694
  }
643
695
  // Case 2 & 3: Agent config (object or function)
644
- var configFn = typeof innerBrainOrConfig === 'function' ? innerBrainOrConfig : function() {
696
+ if (isIterateConfig) {
697
+ // Agent config with iterate — configFn receives (item, params)
698
+ var iterateConfig1 = actionOrIterateConfig;
699
+ var configFn = innerBrainOrConfig;
700
+ var agentBlock = {
701
+ type: 'agent',
702
+ title: title,
703
+ configFn: configFn,
704
+ iterateConfig: iterateConfig1
705
+ };
706
+ this.blocks.push(agentBlock);
707
+ return this.nextBrain();
708
+ }
709
+ var configFn1 = typeof innerBrainOrConfig === 'function' ? innerBrainOrConfig : function() {
645
710
  return innerBrainOrConfig;
646
711
  };
647
- var agentBlock = {
712
+ var agentBlock1 = {
648
713
  type: 'agent',
649
714
  title: title,
650
- configFn: configFn
715
+ configFn: configFn1
651
716
  };
652
- this.blocks.push(agentBlock);
717
+ this.blocks.push(agentBlock1);
653
718
  return this.nextBrain();
654
719
  }
655
720
  },
656
721
  {
657
722
  // Implementation
658
723
  key: "prompt",
659
- value: function prompt(title, config, batchConfig) {
724
+ value: function prompt(title, config, iterateConfig) {
660
725
  // Schema-less prompt - returns text response for next step
661
726
  if (!config.outputSchema) {
662
727
  var textSchema = z.object({
@@ -706,8 +771,8 @@ export var Brain = /*#__PURE__*/ function() {
706
771
  }
707
772
  // At this point, outputSchema is guaranteed to exist (schema-less case returned early)
708
773
  var outputSchema = config.outputSchema;
709
- if (batchConfig) {
710
- // Batch mode - store config on block for event-stream to execute with per-item events
774
+ if (iterateConfig) {
775
+ // Iterate mode - store config on block for event-stream to execute with per-item events
711
776
  var promptBlock1 = {
712
777
  type: 'step',
713
778
  title: title,
@@ -722,14 +787,13 @@ export var Brain = /*#__PURE__*/ function() {
722
787
  });
723
788
  })();
724
789
  },
725
- batchConfig: {
726
- over: batchConfig.over,
727
- error: batchConfig.error,
790
+ iterateConfig: {
791
+ over: iterateConfig.over,
792
+ error: iterateConfig.error,
728
793
  template: config.template,
729
794
  schema: outputSchema.schema,
730
795
  schemaName: outputSchema.name,
731
- client: config.client,
732
- concurrency: batchConfig.concurrency
796
+ client: config.client
733
797
  }
734
798
  };
735
799
  this.blocks.push(promptBlock1);
@@ -849,21 +913,11 @@ export var Brain = /*#__PURE__*/ function() {
849
913
  value: // Implementation signature
850
914
  function run(params) {
851
915
  return _wrap_async_generator(function() {
852
- var _this, title, description, blocks, validatedOptions, store, stream;
916
+ var _this, title, description, blocks, store, stream;
853
917
  return _ts_generator(this, function(_state) {
854
918
  switch(_state.label){
855
919
  case 0:
856
920
  _this = this, title = _this.title, description = _this.description, blocks = _this.blocks;
857
- if (this.optionsSchema) {
858
- // Just call parse - Zod handles defaults automatically
859
- validatedOptions = this.optionsSchema.parse(params.options || {});
860
- } else {
861
- // If no schema is defined but options are provided, throw error
862
- if (params.options && Object.keys(params.options).length > 0) {
863
- throw new Error("Brain '".concat(this.title, "' received options but no schema was defined. Use withOptionsSchema() to define a schema for options."));
864
- }
865
- validatedOptions = {};
866
- }
867
921
  // Build store if withStore() was called and a store provider is given
868
922
  store = this.storeSchema && params.storeProvider ? params.storeProvider({
869
923
  schema: this.storeSchema,
@@ -875,10 +929,12 @@ export var Brain = /*#__PURE__*/ function() {
875
929
  description: description,
876
930
  blocks: blocks
877
931
  }, params), {
878
- options: validatedOptions,
932
+ options: params.options || {},
933
+ optionsSchema: this.optionsSchema,
879
934
  services: this.services,
880
935
  components: this.components,
881
936
  defaultTools: this.defaultTools,
937
+ extraTools: this.extraTools,
882
938
  memoryProvider: this.memoryProvider,
883
939
  store: store
884
940
  }));
@@ -916,6 +972,8 @@ export var Brain = /*#__PURE__*/ function() {
916
972
  nextBrain.components = this.components;
917
973
  // Copy defaultTools to the next brain
918
974
  nextBrain.defaultTools = this.defaultTools;
975
+ // Copy extraTools to the next brain
976
+ nextBrain.extraTools = this.extraTools;
919
977
  // Copy memoryProvider to the next brain
920
978
  nextBrain.memoryProvider = this.memoryProvider;
921
979
  // Copy store schema to the next brain
@@ -25,8 +25,8 @@ export var BRAIN_EVENTS = {
25
25
  AGENT_WEBHOOK: 'agent:webhook',
26
26
  AGENT_RAW_RESPONSE_MESSAGE: 'agent:raw_response_message',
27
27
  AGENT_USER_MESSAGE: 'agent:user_message',
28
- // Batch prompt events (prompt with `over`)
29
- BATCH_CHUNK_COMPLETE: 'batch:chunk_complete'
28
+ // Iterate events (prompt/brain with `over`)
29
+ ITERATE_ITEM_COMPLETE: 'iterate:item_complete'
30
30
  };
31
31
  export var STATUS = {
32
32
  PENDING: 'pending',