@memberjunction/ai-agents 6.2.0-edge.5 → 6.2.0-edge.7

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 (165) hide show
  1. package/README.md +89 -2
  2. package/dist/AgentDataPreloader.d.ts +4 -2
  3. package/dist/AgentDataPreloader.d.ts.map +1 -1
  4. package/dist/AgentDataPreloader.js +21 -12
  5. package/dist/AgentDataPreloader.js.map +1 -1
  6. package/dist/AgentRunner.d.ts +150 -5
  7. package/dist/AgentRunner.d.ts.map +1 -1
  8. package/dist/AgentRunner.js +588 -64
  9. package/dist/AgentRunner.js.map +1 -1
  10. package/dist/AgentWakeTriggerService.d.ts +183 -0
  11. package/dist/AgentWakeTriggerService.d.ts.map +1 -0
  12. package/dist/AgentWakeTriggerService.js +485 -0
  13. package/dist/AgentWakeTriggerService.js.map +1 -0
  14. package/dist/ArtifactToolManager.d.ts +1 -0
  15. package/dist/ArtifactToolManager.d.ts.map +1 -1
  16. package/dist/ArtifactToolManager.js +5 -0
  17. package/dist/ArtifactToolManager.js.map +1 -1
  18. package/dist/ConversationToolManager.d.ts +1 -1
  19. package/dist/ConversationToolManager.d.ts.map +1 -1
  20. package/dist/ConversationToolManager.js +10 -4
  21. package/dist/ConversationToolManager.js.map +1 -1
  22. package/dist/MJAIAgentRequestEntityServer.d.ts +15 -1
  23. package/dist/MJAIAgentRequestEntityServer.d.ts.map +1 -1
  24. package/dist/MJAIAgentRequestEntityServer.js +63 -3
  25. package/dist/MJAIAgentRequestEntityServer.js.map +1 -1
  26. package/dist/agent-context-injector.d.ts +21 -4
  27. package/dist/agent-context-injector.d.ts.map +1 -1
  28. package/dist/agent-context-injector.js +49 -13
  29. package/dist/agent-context-injector.js.map +1 -1
  30. package/dist/agent-memory-context-builder.js +2 -2
  31. package/dist/agent-memory-context-builder.js.map +1 -1
  32. package/dist/agent-pre-execution-rag.d.ts.map +1 -1
  33. package/dist/agent-pre-execution-rag.js +6 -8
  34. package/dist/agent-pre-execution-rag.js.map +1 -1
  35. package/dist/agent-run-watchdog.d.ts +71 -18
  36. package/dist/agent-run-watchdog.d.ts.map +1 -1
  37. package/dist/agent-run-watchdog.js +223 -90
  38. package/dist/agent-run-watchdog.js.map +1 -1
  39. package/dist/agent-types/flow-agent-type.d.ts +13 -0
  40. package/dist/agent-types/flow-agent-type.d.ts.map +1 -1
  41. package/dist/agent-types/flow-agent-type.js +165 -27
  42. package/dist/agent-types/flow-agent-type.js.map +1 -1
  43. package/dist/agent-types/loop-agent-prompt-params.d.ts +32 -5
  44. package/dist/agent-types/loop-agent-prompt-params.d.ts.map +1 -1
  45. package/dist/agent-types/loop-agent-prompt-params.js +5 -3
  46. package/dist/agent-types/loop-agent-prompt-params.js.map +1 -1
  47. package/dist/agent-types/loop-agent-response-type.d.ts +35 -4
  48. package/dist/agent-types/loop-agent-response-type.d.ts.map +1 -1
  49. package/dist/agent-types/loop-agent-response-type.js +1 -1
  50. package/dist/agent-types/loop-agent-response-type.js.map +1 -1
  51. package/dist/agent-types/loop-agent-type.d.ts +103 -9
  52. package/dist/agent-types/loop-agent-type.d.ts.map +1 -1
  53. package/dist/agent-types/loop-agent-type.js +351 -68
  54. package/dist/agent-types/loop-agent-type.js.map +1 -1
  55. package/dist/base-agent.d.ts +551 -44
  56. package/dist/base-agent.d.ts.map +1 -1
  57. package/dist/base-agent.js +2742 -549
  58. package/dist/base-agent.js.map +1 -1
  59. package/dist/bound-action-params.d.ts +57 -0
  60. package/dist/bound-action-params.d.ts.map +1 -0
  61. package/dist/bound-action-params.js +91 -0
  62. package/dist/bound-action-params.js.map +1 -0
  63. package/dist/catalog-narrowing.d.ts.map +1 -1
  64. package/dist/catalog-narrowing.js +6 -3
  65. package/dist/catalog-narrowing.js.map +1 -1
  66. package/dist/handoff-target.d.ts +80 -0
  67. package/dist/handoff-target.d.ts.map +1 -0
  68. package/dist/handoff-target.js +158 -0
  69. package/dist/handoff-target.js.map +1 -0
  70. package/dist/index.d.ts +7 -0
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +7 -0
  73. package/dist/index.js.map +1 -1
  74. package/dist/memory-cleanup-agent.d.ts.map +1 -1
  75. package/dist/memory-cleanup-agent.js +3 -0
  76. package/dist/memory-cleanup-agent.js.map +1 -1
  77. package/dist/memory-manager-agent.d.ts.map +1 -1
  78. package/dist/memory-manager-agent.js +8 -1
  79. package/dist/memory-manager-agent.js.map +1 -1
  80. package/dist/native-tools/action-tool-builder.d.ts +6 -0
  81. package/dist/native-tools/action-tool-builder.d.ts.map +1 -1
  82. package/dist/native-tools/action-tool-builder.js +21 -5
  83. package/dist/native-tools/action-tool-builder.js.map +1 -1
  84. package/dist/native-tools/agent-tools.d.ts +64 -0
  85. package/dist/native-tools/agent-tools.d.ts.map +1 -0
  86. package/dist/native-tools/agent-tools.js +23 -0
  87. package/dist/native-tools/agent-tools.js.map +1 -0
  88. package/dist/native-tools/control-tools.d.ts +40 -7
  89. package/dist/native-tools/control-tools.d.ts.map +1 -1
  90. package/dist/native-tools/control-tools.js +139 -50
  91. package/dist/native-tools/control-tools.js.map +1 -1
  92. package/dist/native-tools/framework-tools.d.ts +47 -0
  93. package/dist/native-tools/framework-tools.d.ts.map +1 -0
  94. package/dist/native-tools/framework-tools.js +187 -0
  95. package/dist/native-tools/framework-tools.js.map +1 -0
  96. package/dist/native-tools/native-control-config.d.ts +93 -0
  97. package/dist/native-tools/native-control-config.d.ts.map +1 -0
  98. package/dist/native-tools/native-control-config.js +104 -0
  99. package/dist/native-tools/native-control-config.js.map +1 -0
  100. package/dist/native-tools/tool-result-turns.d.ts +41 -8
  101. package/dist/native-tools/tool-result-turns.d.ts.map +1 -1
  102. package/dist/native-tools/tool-result-turns.js +76 -2
  103. package/dist/native-tools/tool-result-turns.js.map +1 -1
  104. package/dist/native-tools/turn-mode.d.ts +8 -0
  105. package/dist/native-tools/turn-mode.d.ts.map +1 -0
  106. package/dist/native-tools/turn-mode.js +14 -0
  107. package/dist/native-tools/turn-mode.js.map +1 -0
  108. package/dist/pipeline/pipeline-registry.d.ts +5 -12
  109. package/dist/pipeline/pipeline-registry.d.ts.map +1 -1
  110. package/dist/pipeline/pipeline-registry.js +28 -2
  111. package/dist/pipeline/pipeline-registry.js.map +1 -1
  112. package/dist/pipeline/providers/serialize.d.ts +7 -3
  113. package/dist/pipeline/providers/serialize.d.ts.map +1 -1
  114. package/dist/pipeline/providers/serialize.js +9 -5
  115. package/dist/pipeline/providers/serialize.js.map +1 -1
  116. package/dist/query-builder-agent.d.ts +20 -1
  117. package/dist/query-builder-agent.d.ts.map +1 -1
  118. package/dist/query-builder-agent.js +35 -3
  119. package/dist/query-builder-agent.js.map +1 -1
  120. package/dist/realtime/bridge-room-transcript-sink.js +3 -0
  121. package/dist/realtime/bridge-room-transcript-sink.js.map +1 -1
  122. package/dist/realtime/bridge-session-transcript-sink.js +1 -0
  123. package/dist/realtime/bridge-session-transcript-sink.js.map +1 -1
  124. package/dist/realtime/realtime-client-session-service.d.ts +22 -2
  125. package/dist/realtime/realtime-client-session-service.d.ts.map +1 -1
  126. package/dist/realtime/realtime-client-session-service.js +70 -10
  127. package/dist/realtime/realtime-client-session-service.js.map +1 -1
  128. package/dist/realtime/realtime-coagent-config.d.ts.map +1 -1
  129. package/dist/realtime/realtime-coagent-config.js +2 -28
  130. package/dist/realtime/realtime-coagent-config.js.map +1 -1
  131. package/dist/realtime/realtime-recording-capture.d.ts +1 -0
  132. package/dist/realtime/realtime-recording-capture.d.ts.map +1 -1
  133. package/dist/realtime/realtime-recording-capture.js +17 -3
  134. package/dist/realtime/realtime-recording-capture.js.map +1 -1
  135. package/dist/realtime/realtime-recording-ledger.d.ts +20 -0
  136. package/dist/realtime/realtime-recording-ledger.d.ts.map +1 -1
  137. package/dist/realtime/realtime-recording-ledger.js +16 -0
  138. package/dist/realtime/realtime-recording-ledger.js.map +1 -1
  139. package/dist/realtime/realtime-recording-opus-assembly.d.ts.map +1 -1
  140. package/dist/realtime/realtime-recording-opus-assembly.js +9 -4
  141. package/dist/realtime/realtime-recording-opus-assembly.js.map +1 -1
  142. package/dist/realtime/realtime-recording-store.d.ts +6 -5
  143. package/dist/realtime/realtime-recording-store.d.ts.map +1 -1
  144. package/dist/realtime/realtime-recording-store.js +47 -21
  145. package/dist/realtime/realtime-recording-store.js.map +1 -1
  146. package/dist/realtime/realtime-session-runner.d.ts.map +1 -1
  147. package/dist/realtime/realtime-session-runner.js +5 -7
  148. package/dist/realtime/realtime-session-runner.js.map +1 -1
  149. package/dist/realtime/realtime-turn-moderator.d.ts.map +1 -1
  150. package/dist/realtime/realtime-turn-moderator.js +1 -0
  151. package/dist/realtime/realtime-turn-moderator.js.map +1 -1
  152. package/dist/rubric-evaluation-agent-runner.js +1 -0
  153. package/dist/rubric-evaluation-agent-runner.js.map +1 -1
  154. package/dist/runtime-state-fragment.d.ts.map +1 -1
  155. package/dist/runtime-state-fragment.js +3 -0
  156. package/dist/runtime-state-fragment.js.map +1 -1
  157. package/dist/sub-agent-consult.d.ts +75 -0
  158. package/dist/sub-agent-consult.d.ts.map +1 -0
  159. package/dist/sub-agent-consult.js +193 -0
  160. package/dist/sub-agent-consult.js.map +1 -0
  161. package/dist/volatile-child-prompt.d.ts +7 -0
  162. package/dist/volatile-child-prompt.d.ts.map +1 -1
  163. package/dist/volatile-child-prompt.js +8 -0
  164. package/dist/volatile-child-prompt.js.map +1 -1
  165. package/package.json +20 -20
@@ -10,8 +10,11 @@
10
10
  * @author MemberJunction.com
11
11
  * @since 2.49.0
12
12
  */
13
- import { MJAIAgentTypeEntity, MJTemplateParamEntity, MJAIAgentRelationshipEntity, MJAIAgentNoteEntity, MJAIAgentExampleEntity, MJAISkillEntity, MJAIVendorEntity, MJAIPromptRunEntity, type ConversationBranchRow } from '@memberjunction/core-entities';
13
+ import { MJAIAgentEntity, MJAIAgentTypeEntity, MJTemplateParamEntity, MJAIAgentRelationshipEntity, MJAIAgentConfigurationEntity, MJAIAgentNoteEntity, MJAIAgentExampleEntity, MJAISkillEntity, MJAIVendorEntity, MJAIPromptRunEntity, type ConversationBranchRow } from '@memberjunction/core-entities';
14
14
  import { type NativeToolBinding } from './native-tools/control-tools.js';
15
+ import { type NativeControlConfig } from './native-tools/native-control-config.js';
16
+ import type { AgentToolDefinition } from './native-tools/agent-tools.js';
17
+ import { type NativeToolResult } from './native-tools/tool-result-turns.js';
15
18
  import { MJAIAgentRunEntityExtended, MJAIAgentRunStepEntityExtended, MJAIPromptEntityExtended, MJAIAgentEntityExtended, MJAIModelEntityExtended, MJAIPromptRunEntityExtended } from "@memberjunction/ai-core-plus";
16
19
  import { UserInfo, IMetadataProvider } from '@memberjunction/core';
17
20
  import { AIDecisionRunResult } from '@memberjunction/ai-prompts';
@@ -26,7 +29,7 @@ import { CompactionOutcome, EffectiveContextBudget } from './ConversationCompact
26
29
  import { ConversationToolCall, ConversationToolExecutionResult, ConversationToolSummaryHost } from './ConversationToolManager.js';
27
30
  import { CarryForwardStepRecord, StoppedRunStepRecord } from './tool-result-format.js';
28
31
  import { AgentPreExecutionRAGResult } from './agent-pre-execution-rag.js';
29
- import { AIPromptParams, AIPromptRunResult, ExecuteAgentParams, AgentTreeBudget, AgentConfiguration, ExecuteAgentResult, AgentAction, AgentSubAgentRequest, BaseAgentNextStep, MessageLifecycleEvent, AgentChatMessage, AgentChatMessageMetadata, AIModelSelectionInfo, ActionChange, ActionChangeScope, SubAgentChange, MediaOutput, FileOutputRef, SecondaryScopeConfig, SecondaryScopeValue, AgentResponseForm, AgentPipelineRequest, AgentSkillActivationRequest, AgentSkillInvocation, SkillAvailabilityPurpose, AgentDecisionRequest, AgentDecisionResult, AgentDecisionAnswerSummary, StopContinuationMode } from '@memberjunction/ai-core-plus';
32
+ import { AIPromptParams, AIPromptRunResult, ExecuteAgentParams, AgentTreeBudget, AgentConfiguration, ExecuteAgentResult, AgentAction, AgentSubAgentRequest, BaseAgentNextStep, MessageLifecycleEvent, AgentChatMessage, AgentChatMessageMetadata, AgentToolCallRequest, AIModelSelectionInfo, ActionChange, ActionChangeScope, SubAgentChange, MediaOutput, FileOutputRef, SecondaryScopeConfig, SecondaryScopeValue, AgentResponseForm, AgentPipelineRequest, AgentSkillActivationRequest, AgentSkillInvocation, SkillAvailabilityPurpose, AgentDecisionRequest, AgentDecisionResult, AgentDecisionAnswerSummary, StopContinuationMode } from '@memberjunction/ai-core-plus';
30
33
  import { MJActionEntityExtended, ActionResult, ActionParam, AIDirective } from '@memberjunction/actions-base';
31
34
  import { RuntimeStateDateTime, RuntimeStateScratchpad } from './runtime-state-fragment.js';
32
35
  import { ScratchpadManager } from './ScratchpadManager.js';
@@ -79,6 +82,11 @@ export interface ActionResultCrushConfig {
79
82
  * applies. Opt in per agent type via the `crushCodeLang` prompt param or a subclass override.
80
83
  */
81
84
  codeLang: CodeLang | undefined;
85
+ /**
86
+ * Actions whose results are never crushed, by Action name — large exact payloads such as code
87
+ * or specifications the model must read verbatim. Set with the `uncrushedActions` prompt param.
88
+ */
89
+ exemptActions?: ReadonlySet<string>;
82
90
  }
83
91
  /**
84
92
  * Options for {@link BaseAgent.ExecuteSingleAction}.
@@ -96,6 +104,12 @@ export interface ExecuteSingleActionOptions {
96
104
  * call too.
97
105
  */
98
106
  skipCircuitBreaker?: boolean;
107
+ /**
108
+ * The run step (`MJ: AI Agent Run Steps`) this call is recorded under, named in the audit lines
109
+ * written when a bound parameter (`ExecuteAgentParams.boundActionParams`) overrides a value the
110
+ * model sent or refuses the call. Set by the actions step; a direct caller may leave it out.
111
+ */
112
+ StepID?: string;
99
113
  }
100
114
  /**
101
115
  * Which circuit-breaker rule blocked an action call without dispatching it.
@@ -111,6 +125,18 @@ export interface ExecuteSingleActionOptions {
111
125
  * across any arguments.
112
126
  */
113
127
  export type ActionCircuitBreakerReason = 'fatal' | 'audience' | 'identical-arguments' | 'attempts-exhausted';
128
+ /**
129
+ * What {@link BaseAgent.classifyActionFailure} names for a failed action: the breaker rule that fired, a refusal by
130
+ * the user's agent policy (`'policy'` — governance, not a parameter error, so the guidance must not tell the model
131
+ * to adjust its arguments and retry), or a plain `'warning'`.
132
+ */
133
+ export type ActionFailureClass = ActionCircuitBreakerReason | 'policy' | 'warning';
134
+ /** Result code of a call the user's agent policy denies outright (`checkUserActionPolicy`). */
135
+ export declare const POLICY_DENIED_RESULT_CODE = "POLICY_DENIED";
136
+ /** Result code of a call the user's agent policy allows only with the user's approval. */
137
+ export declare const POLICY_APPROVAL_REQUIRED_RESULT_CODE = "POLICY_APPROVAL_REQUIRED";
138
+ /** Result code of a call the user's agent policy defers to its next allowed time window. */
139
+ export declare const POLICY_DEFERRED_RESULT_CODE = "POLICY_DEFERRED_OUTSIDE_TIME_WINDOW";
114
140
  /** Identical-arguments rule: this many failures with the same arguments block further identical calls. */
115
141
  export declare const IDENTICAL_FAILURE_THRESHOLD = 2;
116
142
  /** Attempt budget: this many consecutive failures, across any arguments, disable the action for the run. */
@@ -239,6 +265,10 @@ export declare class BaseAgent {
239
265
  * @private
240
266
  */
241
267
  private _lastVolatileStateMessage;
268
+ /** The previous request's outgoing messages, as {@link messageFingerprint}s. */
269
+ private _lastSentFingerprints;
270
+ /** The previous request's system-prompt-and-tools fingerprint, from the prompt runner. */
271
+ private _lastSentPrefix;
242
272
  /**
243
273
  * The trailing-state retention mode once it has been decided for this run, frozen at the first
244
274
  * model selection so the layout never flips again mid-run. Undefined until then (turn 1 only).
@@ -388,6 +418,53 @@ export declare class BaseAgent {
388
418
  protected checkActionCircuitBreaker(params: ExecuteAgentParams, action: AgentAction, actionEntity: MJActionEntityExtended, normalizedParams: string): CircuitBreakerActionResult | null;
389
419
  /** The failed {@link ActionResult} a blocked call returns in place of dispatching. */
390
420
  protected buildBlockedActionResult(actionEntity: MJActionEntityExtended, reason: ActionCircuitBreakerReason, message: string): CircuitBreakerActionResult;
421
+ /**
422
+ * Applies the run's bound parameters to one call (`ExecuteAgentParams.boundActionParams`): a bound
423
+ * value replaces whatever the model sent under its name, and the override is logged with the run and
424
+ * step IDs. The rules are {@link ApplyBoundActionParams}'s; this adds only the log line.
425
+ */
426
+ private applyActionBindings;
427
+ /** "run <id>, step <id>" for an audit line. */
428
+ private whereInRun;
429
+ /**
430
+ * The `ActionParam` array for one dispatch. Coerced against each param's declared schema on every
431
+ * path — envelope, native and flow — so `"640"` reaches an integer param as 640 whichever protocol
432
+ * produced it, while bound parameters keep their exact host-supplied value and carry the `Bound`
433
+ * marker into the execution log.
434
+ */
435
+ private toActionParams;
436
+ /**
437
+ * A call its bindings refuse. The reason (a required parameter bound to nothing, or a binding that
438
+ * names no input of the action) is logged for the operator with the run and step IDs. The model is
439
+ * told only that the action is unavailable, because naming the parameter would reveal what is being
440
+ * hidden; and the action is locked out for the rest of the run the way a fatal configuration failure
441
+ * is, so the circuit breaker short-circuits every later call instead of the model being told to
442
+ * "adjust its parameters" for a refusal it cannot fix.
443
+ */
444
+ private refuseBoundAction;
445
+ /** True when the run binds a parameter on at least one of these actions. */
446
+ private bindsAnyAction;
447
+ /** True when the run has any bound action parameters at all. */
448
+ private hasBoundActionParams;
449
+ /**
450
+ * The error that fails a run at its start when `boundActionParams` names an action that does not
451
+ * exist, so a host that keyed by name or mistyped an ID finds out at once rather than having the
452
+ * parameter it meant to hide shown to the model. Root run only: a sub-agent inherits bindings that
453
+ * were already checked. Needs the action engine configured (Phase 1 of {@link Execute}).
454
+ */
455
+ private boundActionParamsError;
456
+ /**
457
+ * Gives a run that continues another (`lastRunId`) the earlier run's stored bindings, when its caller
458
+ * passed none (an empty object counts as none, as everywhere else). Fails closed: a prior run that
459
+ * can't be read, or whose stored bindings don't parse, fails this run rather than starting it unbound.
460
+ */
461
+ private inheritBoundActionParams;
462
+ /**
463
+ * The model's parameters for one action as the progress line and the model-facing invocation record
464
+ * show them: minus any name the run binds, since a value the model wrote for a bound parameter was
465
+ * discarded and must not be shown as if it had been used. With no bindings, `Object.entries(aa.params)`.
466
+ */
467
+ private shownActionParamEntries;
391
468
  /**
392
469
  * Names the rule behind a failed action summary so the directive matches what actually
393
470
  * happened. A blocked call reports the rule that blocked it. A dispatched failure is fatal if
@@ -397,7 +474,13 @@ export declare class BaseAgent {
397
474
  * the action is blocked whatever the arguments are, and telling the model to change them
398
475
  * would send it in circles.
399
476
  */
400
- protected classifyActionFailure(summary: ActionResultSummary): ActionCircuitBreakerReason | 'warning';
477
+ protected classifyActionFailure(summary: ActionResultSummary): ActionFailureClass;
478
+ /**
479
+ * The guidance line for a call the user's agent policy refused. The default `[WARNING/ACTION_FAILURE]`
480
+ * line tells the model to adjust its parameters and try again, up to the budget; a refusal is not a
481
+ * parameter error, and a retry burns the budget without ever succeeding.
482
+ */
483
+ private formatPolicyRefusalDirective;
401
484
  /** The guidance line appended to the history for one failed action. */
402
485
  protected formatActionFailureDirective(summary: ActionResultSummary): string;
403
486
  /**
@@ -498,6 +581,15 @@ export declare class BaseAgent {
498
581
  * @private
499
582
  */
500
583
  private _feedbackRequestId;
584
+ /**
585
+ * Stores the handoff outcome when a Handoff step fires.
586
+ * Populated by executeHandoffStep(), returned in ExecuteAgentResult.handoff.
587
+ */
588
+ private _handoffResult;
589
+ /**
590
+ * Stores the target agent resolved during validateHandoffNextStep() for executeHandoffStep().
591
+ */
592
+ private _resolvedHandoffTarget;
501
593
  private _resolvedStorageAccountId;
502
594
  /**
503
595
  * Most recent artifactDirective returned by a child or related sub-agent during this run.
@@ -538,14 +630,14 @@ export declare class BaseAgent {
538
630
  * // Note: If no presets configured, returns empty array - agent will use default behavior
539
631
  * ```
540
632
  */
541
- GetConfigurationPresets(agentId: string): import("@memberjunction/core-entities").MJAIAgentConfigurationEntity[];
633
+ GetConfigurationPresets(agentId: string): MJAIAgentConfigurationEntity[];
542
634
  /**
543
635
  * Gets the default configuration preset for an agent.
544
636
  *
545
637
  * @param agentId - The ID of the agent to get the default preset for
546
638
  * @returns The default preset, or undefined if none configured
547
639
  */
548
- GetDefaultConfigurationPreset(agentId: string): import("@memberjunction/core-entities").MJAIAgentConfigurationEntity;
640
+ GetDefaultConfigurationPreset(agentId: string): MJAIAgentConfigurationEntity;
549
641
  /**
550
642
  * Promotes media outputs to the agent's final outputs.
551
643
  * Call this method to add generated images, audio, or video to the agent's outputs.
@@ -630,19 +722,20 @@ export declare class BaseAgent {
630
722
  private interceptLargeBinaryContent;
631
723
  /**
632
724
  * Substitutes `${media:<refId>}` placeholders in a string with the actual
633
- * data URI (`data:<mime>;base64,<bytes>`) of the matching intercepted media item.
725
+ * data URI (`data:<mime>;base64,<bytes>`) or stored `fileId` (for `fileId`-only
726
+ * media items) of the matching intercepted media item.
634
727
  *
635
728
  * Used for payload / actionable-command resolution at the terminal step, where the
636
- * LLM wants to embed image (or other media) data inline at a specific position in
637
- * its structured output rather than as a trailing attachment card. The string
638
- * variant of placeholder resolution; recursive walker lives in
639
- * {@link resolveMediaPlaceholdersInPayload}.
729
+ * LLM wants to embed image (or other media) data or a stored file ID inline at a
730
+ * specific position in its structured output rather than only as a trailing
731
+ * attachment card. The string variant of placeholder resolution; recursive walker
732
+ * lives in {@link resolveMediaPlaceholdersInPayload}.
640
733
  *
641
734
  * This function only does substitution — it has no persistence side effects.
642
735
  *
643
736
  * @param text - The string that may contain media placeholders
644
- * @returns String with placeholders resolved to actual data URIs (or the original
645
- * placeholder if the refId is unknown — defensive, shouldn't happen)
737
+ * @returns String with placeholders resolved to data URIs or stored file IDs (or the
738
+ * original placeholder if the refId is unknown — defensive, shouldn't happen)
646
739
  * @private
647
740
  * @since 3.1.0
648
741
  */
@@ -763,6 +856,12 @@ export declare class BaseAgent {
763
856
  * "Run Ad-hoc Query". Left undefined on the envelope path so the loop can tell the two apart.
764
857
  */
765
858
  protected _nativeToolBindings: ReadonlyMap<string, NativeToolBinding> | undefined;
859
+ /** Results of the agent-tool calls the current prompt step ran, waiting for their call turn to be replayed. */
860
+ private _pendingAgentToolResults;
861
+ /** conversation_tool calls made on the current prompt turn, for the per-turn cap. */
862
+ private _conversationToolTurn;
863
+ /** The parsed native control configuration, and the `TypeConfiguration` it was parsed from. */
864
+ private _nativeControl;
766
865
  /** the model turn whose assistant call message has already been replayed into history (by reference). */
767
866
  private _lastNativeTurnAppended;
768
867
  /**
@@ -796,6 +895,14 @@ export declare class BaseAgent {
796
895
  * @private
797
896
  */
798
897
  private _effectiveSubAgents;
898
+ /**
899
+ * True once gatherPromptTemplateData() has computed {@link _effectiveActions} and
900
+ * {@link _effectiveSubAgents} for this run. An empty list is then authoritative: a host's
901
+ * `actionChanges` that remove every action leave the run with none, instead of falling back to
902
+ * the agent's database configuration as an uncomputed list does.
903
+ * @private
904
+ */
905
+ private _effectiveCatalogComputed;
799
906
  /**
800
907
  * The merged agent-type prompt params of the current step. Populated during
801
908
  * gatherPromptTemplateData() and read by the finishIf gate, which runs in executeActionsStep()
@@ -931,6 +1038,29 @@ export declare class BaseAgent {
931
1038
  * @private
932
1039
  */
933
1040
  private _validationRetryCount;
1041
+ /**
1042
+ * Per-parent-run consultation round counter keyed by `subAgentEntity.ID`.
1043
+ * Tracks how many times each sub-agent has returned `FinalStep === 'Chat'`
1044
+ * under `ChatHandlingOption = 'Consult'` during this run.
1045
+ * Reset at the start of each agent run.
1046
+ * @private
1047
+ */
1048
+ private _subAgentConsultRounds;
1049
+ /**
1050
+ * Open sub-agent consultations keyed by `childRunId`.
1051
+ * Populated when a child sub-agent pauses with `FinalStep === 'Chat'` under `'Consult'`,
1052
+ * and removed when the parent resumes that child run.
1053
+ * Reset at the start of each agent run.
1054
+ * @private
1055
+ */
1056
+ private _openSubAgentConsults;
1057
+ /**
1058
+ * Tracks whether we have already logged the warning that `'Consult'` is not
1059
+ * supported on agent types where `InjectLoopResultsAsMessage` is `false`.
1060
+ * Reset at the start of each agent run.
1061
+ * @private
1062
+ */
1063
+ private _loggedConsultUnsupportedAgentType;
934
1064
  /**
935
1065
  * Counter tracking the number of context recovery attempts made in this run.
936
1066
  * Context recovery removes/compacts old messages when context length is exceeded.
@@ -1039,6 +1169,12 @@ export declare class BaseAgent {
1039
1169
  */
1040
1170
  protected get DefaultAgentTimeoutMS(): number;
1041
1171
  Execute<C = any, R = any>(params: ExecuteAgentParams<C>): Promise<ExecuteAgentResult<R>>;
1172
+ /**
1173
+ * {@link Execute}'s per-run teardown, called from its top-level `finally` on every exit path.
1174
+ * The run leaves the watchdog first, before the subclass {@link finalizeRun} hook, so a hook
1175
+ * that throws can never leave a finished run being heart-beaten for the life of the process.
1176
+ */
1177
+ private endRun;
1042
1178
  /**
1043
1179
  * Fails the run at its start, before any prompt: marks the already-created AgentRun Failed with the message
1044
1180
  * (so it never shows as a phantom "running" record) and throws, which {@link Execute} turns into a failure
@@ -1084,7 +1220,8 @@ export declare class BaseAgent {
1084
1220
  * (`TaskGraphAgentRunner`) that carries neither the audience nor the scope. So graphs are withheld when the
1085
1221
  * audience adds a reader, and when the run's validated scope carries a tenant or a secondary dimension
1086
1222
  * (`ActionRunScopeIsBounded`): a model-written Scoped Search node would search outside the run's tenant, and an
1087
- * agent node would drop it.
1223
+ * agent node would drop it. Likewise when the host assigned the run's search scopes (`SearchScopeIDs`): a graph's
1224
+ * Scoped Search node would fall back to the agent's own search access.
1088
1225
  */
1089
1226
  private taskGraphWithholdingReason;
1090
1227
  /** Whether this run withholds task graphs ({@link taskGraphWithholdingReason}). */
@@ -1096,9 +1233,18 @@ export declare class BaseAgent {
1096
1233
  */
1097
1234
  private taskGraphRefusal;
1098
1235
  /**
1099
- * What this run's prompt leaves out: task graphs ({@link taskGraphWithholdingReason}), and — when the audience adds a
1100
- * reader — the caller's own browser and view (`CallerContext`): client tools run in the caller's browser and what they
1101
- * return reaches the room, and the app context (`data.appContext`, with its `AdditionalContext`) is the caller's screen.
1236
+ * Whether this run withholds Handoff (`enableHandoff` off and the `handoff` response section hidden).
1237
+ * True when the run has a `parentRun` (sub-agents cannot transfer the conversation), has no
1238
+ * `conversationDetailId` (there is no conversation reply row to hand over), has no `handoffChain`
1239
+ * (the host does not carry out handoffs), or runs for an anonymous/widget guest without a trusted
1240
+ * host allow-list (`TrustReservedRunData === true` and `HostAllowedAgentIDs(params.data)` defined).
1241
+ */
1242
+ private runWithholdsHandoff;
1243
+ /**
1244
+ * What this run's prompt leaves out: task graphs ({@link taskGraphWithholdingReason}), handoff
1245
+ * ({@link runWithholdsHandoff}), and — when the audience adds a reader — the caller's own browser
1246
+ * and view (`CallerContext`): client tools run in the caller's browser and what they return reaches
1247
+ * the room, and the app context (`data.appContext`, with its `AdditionalContext`) is the caller's screen.
1102
1248
  */
1103
1249
  private promptWithholding;
1104
1250
  /**
@@ -1120,6 +1266,11 @@ export declare class BaseAgent {
1120
1266
  * response section hidden). A copy, never a write: the input may be the process-wide cached base.
1121
1267
  */
1122
1268
  private withoutTaskGraphs;
1269
+ /**
1270
+ * A copy of the agent-type prompt params with handoff withheld (`enableHandoff` off and the `handoff`
1271
+ * response section hidden). A copy, never a write: the input may be the process-wide cached base.
1272
+ */
1273
+ private withoutHandoff;
1123
1274
  /**
1124
1275
  * Why a session-driven (realtime / voice / bridge) run is refused, or null. A live session speaks and calls
1125
1276
  * tools outside the gates that hold a run to its audience, so a run whose audience adds a reader is refused.
@@ -1871,8 +2022,14 @@ export declare class BaseAgent {
1871
2022
  * action results as ONE tool turn — a tool_result block per call, paired by id — when the
1872
2023
  * turn's results go back natively; otherwise the markdown user message as before. An action that
1873
2024
  * cannot be paired with a call id keeps the markdown message for itself.
2025
+ *
2026
+ * A failed action's guidance (from `failureGuidance`) rides inside its own error result, where
2027
+ * the model reads it as part of that call's outcome rather than as a separate instruction.
2028
+ *
2029
+ * @returns The summaries answered as native tool results — the caller still owes the rest any
2030
+ * guidance, as a message
1874
2031
  */
1875
- protected appendActionResults(params: ExecuteAgentParams, summaries: ActionResultSummary[], resultsMessage: string, metadata: AgentChatMessageMetadata | undefined, previousDecision: BaseAgentNextStep): void;
2032
+ protected appendActionResults(params: ExecuteAgentParams, summaries: ActionResultSummary[], resultsMessage: string, metadata: AgentChatMessageMetadata | undefined, previousDecision: BaseAgentNextStep, failureGuidance?: ReadonlyMap<ActionResultSummary, string>): ReadonlySet<ActionResultSummary>;
1876
2033
  /**
1877
2034
  * Answers any tool call the turn's own result path left dangling, immediately before the
1878
2035
  * history goes back to the model.
@@ -1891,12 +2048,89 @@ export declare class BaseAgent {
1891
2048
  * message the branch itself appended (the retry instructions, the chat question).
1892
2049
  */
1893
2050
  protected reconcileUnansweredToolCalls(params: ExecuteAgentParams): void;
2051
+ /**
2052
+ * Appends a tool turn answering the latest call turn. When that call turn is already followed
2053
+ * by a tool turn — declined calls, or agent-tool results, answered first — the results join it,
2054
+ * because Anthropic takes every result for a call turn from the one message that follows it.
2055
+ */
2056
+ protected PushToolResultTurn(params: ExecuteAgentParams, results: AgentChatMessage): void;
2057
+ /** The index of the most recent assistant turn that made tool calls, or -1. */
2058
+ private static lastToolCallTurnIndex;
2059
+ /** The call ids that already have a `tool_result` in some message after the call turn. */
2060
+ private static toolCallIdsAnsweredAfter;
2061
+ /**
2062
+ * Places a tool turn immediately after the assistant turn whose calls it answers.
2063
+ *
2064
+ * Anthropic requires every result for a call turn in the single message that follows it, and
2065
+ * OpenAI requires the call turn to be followed by its tool messages — so a result appended after
2066
+ * a retry message that already sits behind the call is rejected by both. When the message right
2067
+ * after the call turn is already a tool turn, the results merge into it instead of opening a
2068
+ * second one.
2069
+ */
2070
+ private static insertToolResultsAfterCallTurn;
1894
2071
  /**
1895
2072
  * a tool turn can never be REMOVED from history — that orphans the assistant call it
1896
2073
  * answers, which every provider rejects. Expiry and recovery stub its blocks instead.
1897
2074
  */
1898
2075
  private stubToolTurn;
1899
2076
  protected applyNativeTools(promptParams: AIPromptParams, params: ExecuteAgentParams): void;
2077
+ /**
2078
+ * The agent's own native tools — tools that read and write this agent's state, such as
2079
+ * `write_section` / `edit_section`. None by default; a driver class overrides this.
2080
+ *
2081
+ * Declared beside the agent's Actions whenever the run declares native tools, and dispatched in
2082
+ * every native mode. Each call runs as a `Tool` run step, in the order the model made the calls,
2083
+ * and its {@link AgentToolResult.PayloadChange} is applied before the next call runs. See
2084
+ * {@link AgentToolDefinition} for the contract.
2085
+ *
2086
+ * @param params The run parameters
2087
+ * @returns The tools to declare this turn
2088
+ */
2089
+ protected GetAgentTools(params: ExecuteAgentParams): AgentToolDefinition[];
2090
+ /**
2091
+ * Which framework capabilities a native-only agent gets as tools this turn — the same gates the
2092
+ * hybrid prompt applies to the matching envelope fields and their documentation.
2093
+ */
2094
+ private frameworkToolAvailability;
2095
+ /** The capabilities behind the framework tools, bound to this run. */
2096
+ private frameworkToolHost;
2097
+ private applyScratchpadFromTool;
2098
+ private writeMemoryFromTool;
2099
+ private runArtifactToolFromTool;
2100
+ private runConversationToolFromTool;
2101
+ private runDecisionsFromTool;
2102
+ /**
2103
+ * Runs the turn's agent-tool calls in order, each as its own `Tool` run step, threading the
2104
+ * payload through them so successive edits compose.
2105
+ *
2106
+ * @param calls The calls, in the order the model made them
2107
+ * @param payload The payload before the first call
2108
+ * @param params The run parameters
2109
+ * @returns The payload after the last call, and one result per call, in call order
2110
+ */
2111
+ protected ExecuteAgentToolCallsAsSteps<P>(calls: AgentToolCallRequest[], payload: P, params: ExecuteAgentParams): Promise<{
2112
+ payload: P;
2113
+ results: NativeToolResult[];
2114
+ }>;
2115
+ /** One agent-tool call as a `Tool` run step: run it, apply its payload change, record both. */
2116
+ private executeAgentToolCallAsStep;
2117
+ /** Calls the tool's handler; an undeclared tool or a thrown error becomes an error result. */
2118
+ private runAgentTool;
2119
+ /**
2120
+ * Applies an agent tool's payload change through PayloadManager, under the agent's
2121
+ * `PayloadSelfWritePaths`. A change that touches a path the agent may not write is rejected
2122
+ * whole — a partial write would leave the payload in a state the tool never described — and
2123
+ * the reason goes back to the model as the call's error result.
2124
+ *
2125
+ * @param partial Apply the allowed parts and report the rest, as a single `payload_change_request`
2126
+ * on a turn always has; the model wrote that change itself, path by path
2127
+ */
2128
+ private applyAgentToolPayloadChange;
2129
+ /**
2130
+ * Answers the turn's agent-tool calls, directly after the call turn the loop just replayed. When
2131
+ * the turn's results do not go back natively, the results become one user message instead.
2132
+ */
2133
+ private appendAgentToolResults;
1900
2134
  /**
1901
2135
  * The `tool_choice` for this turn (§8.3).
1902
2136
  *
@@ -1923,13 +2157,28 @@ export declare class BaseAgent {
1923
2157
  * address them. That belongs to the prompt, and is why the native-mode Actions section names
1924
2158
  * the cases explicitly.
1925
2159
  *
2160
+ * **A text-terminal agent** (`NativeControl.Terminal: 'text'`) declares no `complete_task`: its
2161
+ * answer is the plain-text reply, and its state changes went through its own tools on earlier
2162
+ * turns. Its final turn is `'none'`, which asks for exactly that reply.
2163
+ *
1926
2164
  * Subclasses may narrow this further; the base contract is that a forced terminal choice must
1927
2165
  * never be relaxed to `'auto'` on a turn the framework has already decided is terminal.
1928
2166
  *
1929
2167
  * @param params The run parameters, for the per-run iteration override
1930
- * @returns `{ name: 'complete_task' }` on the final permitted iteration, otherwise `'auto'`
2168
+ * @returns On the final permitted iteration, `{ name: 'complete_task' }`, or `'none'` for a
2169
+ * text-terminal agent; otherwise `'auto'`
1931
2170
  */
1932
2171
  protected resolveToolChoiceForTurn(params: ExecuteAgentParams): ChatToolChoice;
2172
+ /**
2173
+ * The agent's native control configuration — which control tools it declares and how its run
2174
+ * ends — from the `NativeControl` block of its `TypeConfiguration`. Defaults when there is none.
2175
+ *
2176
+ * Parsed once per distinct configuration; anything unusable is logged once and falls back to its
2177
+ * default, so a typo never fails a run.
2178
+ *
2179
+ * @param params The run parameters, for the agent
2180
+ */
2181
+ protected GetNativeControlConfig(params: ExecuteAgentParams): NativeControlConfig;
1933
2182
  /**
1934
2183
  * Whether the turn currently being prepared is the last one this run will be allowed.
1935
2184
  *
@@ -1951,6 +2200,33 @@ export declare class BaseAgent {
1951
2200
  */
1952
2201
  protected isFinalPermittedIteration(params: ExecuteAgentParams): boolean;
1953
2202
  protected preparePromptParams<P>(config: AgentConfiguration, payload: P, params: ExecuteAgentParams): Promise<AIPromptParams>;
2203
+ /**
2204
+ * Drops replayed reasoning that the history before it no longer matches.
2205
+ *
2206
+ * A driver with `ReplayedReasoningRequiresStablePrefix` accepts a replayed reasoning block
2207
+ * only while every message before it is exactly what was sent when the block was produced.
2208
+ * Expiry, compaction, message expansion and context recovery all rewrite earlier messages,
2209
+ * and each would make the request fail. So the outgoing messages are compared with the
2210
+ * previous request's: from the first message that was changed or removed, every call turn's
2211
+ * reasoning is dropped — in this request and in the history, so later requests stay
2212
+ * consistent. Messages the previous request did not have (the model's reply, new results)
2213
+ * are not a change.
2214
+ */
2215
+ private dropReasoningBehindChangedHistory;
2216
+ /** Whether this run replays reasoning to a driver that binds it to an unchanged request prefix. */
2217
+ private replaysPrefixBoundReasoning;
2218
+ /**
2219
+ * Keeps the system-prompt-and-tools fingerprint of the request just sent, for the next one. When
2220
+ * it changed, the runner sent this request without replayed reasoning; the history drops it too,
2221
+ * so no later request replays a block made under the old prompt or tools.
2222
+ *
2223
+ * A result with no fingerprint (a request that failed before or while it was sent, such as a
2224
+ * failover that ran out of candidates) leaves the baseline as it was. Clearing it would let the
2225
+ * next request skip the comparison and replay thinking made under a prompt or tools it no longer has.
2226
+ */
2227
+ private trackSentPrefix;
2228
+ /** What makes a message the same message to a provider — reasoning aside, which only this check removes. */
2229
+ private static messageFingerprint;
1954
2230
  /**
1955
2231
  * In append-only mode, restores turn 1's volatile state fragment if mode resolution
1956
2232
  * was deferred until after turn 1 (e.g. dynamic model selection).
@@ -1992,10 +2268,14 @@ export declare class BaseAgent {
1992
2268
  * Which providers are which is METADATA, not code: the `PrefixPromptCache` flag in the model
1993
2269
  * catalog's `ModelConfiguration` cascade (Model Types < Models < Vendors' `Configuration.ModelDefaults`
1994
2270
  * < Model Vendors), read through {@link resolvePrefixPromptCache}. `true` means append-only;
1995
- * anything else means replace.
1996
- *
1997
- * Decided ONCE per run. An explicit `trailingStateMode` or a runtime model override answers
1998
- * immediately. Otherwise the answer is frozen at the first model selection and reused for every
2271
+ * anything else means replace. One exception comes from the driver, not the catalog: a run that
2272
+ * declares native tools to a driver whose replayed reasoning needs the history before it
2273
+ * unchanged is append-only too (see {@link ResolveAppendOnlyState}).
2274
+ *
2275
+ * Decided ONCE per run. An explicit `trailingStateMode` answers immediately, and so does a runtime
2276
+ * model override that names a vendor, or whose catalog says the cache is a byte-prefix cache.
2277
+ * Otherwise (no override, or one that names no vendor and whose catalog does not say yes) the
2278
+ * answer is frozen at the first model selection and reused for every
1999
2279
  * later turn, so a failover to another vendor cannot flip the layout mid-run — a flip after turn 2
2000
2280
  * would leave stale fragments in the history or, worse, restore the wrong turn's fragment. On turn 1,
2001
2281
  * before any selection is known, the answer is replace-in-place: turn 1's fragment is kept and, if
@@ -2005,6 +2285,16 @@ export declare class BaseAgent {
2005
2285
  * guessing from them mis-pins runs that end up selecting another vendor.
2006
2286
  */
2007
2287
  protected shouldUseAppendOnlyTrailingState(promptParams: AIPromptParams): boolean;
2288
+ /**
2289
+ * Whether this run keeps its runtime-state fragments (append-only): the model sits behind a
2290
+ * byte-prefix prompt cache, or the run declares native tools to a driver whose replayed
2291
+ * reasoning is accepted only while the history before it is unchanged. In replace mode each
2292
+ * request drops the previous fragment, and a thinking block produced after it would be replayed
2293
+ * behind a changed history and rejected.
2294
+ */
2295
+ protected ResolveAppendOnlyState(model: MJAIModelEntityExtended | undefined, vendor: MJAIVendorEntity | undefined): boolean;
2296
+ /** Whether the driver serving `model` on `vendor` binds replayed reasoning to the unchanged history before it. */
2297
+ protected DriverRequiresStableReasoningPrefix(model: MJAIModelEntityExtended | undefined, vendor: MJAIVendorEntity | undefined): boolean;
2008
2298
  /**
2009
2299
  * Whether a model, as served by a vendor, sits behind a byte-prefix prompt cache
2010
2300
  * (`LLM.PrefixPromptCache`), read from the model catalog's `ModelConfiguration` cascade —
@@ -2155,6 +2445,22 @@ export declare class BaseAgent {
2155
2445
  */
2156
2446
  protected getRequestedSubAgents<P, C>(nextStep: BaseAgentNextStep<P, C> | undefined | null): AgentSubAgentRequest<C>[];
2157
2447
  protected validateSubAgentNextStep<P>(params: ExecuteAgentParams, nextStep: BaseAgentNextStep<P>, currentPayload: P, agentRun: MJAIAgentRunEntityExtended, currentStep: MJAIAgentRunStepEntityExtended): Promise<BaseAgentNextStep<P>>;
2448
+ /**
2449
+ * Strips an optional `delegate_to_` native sub-agent tool prefix when a model running
2450
+ * with native tool calling references a sub-agent by its declared tool name inside an
2451
+ * envelope primitive (`Sub-Agent`, `ForEach`, `While`, or `Tasks`).
2452
+ */
2453
+ protected stripSubAgentToolPrefix(rawName: string): string;
2454
+ /**
2455
+ * Resolves a unique entity from `pool` whose sanitized native tool name matches `rawName`.
2456
+ * Returns `{ ambiguous }` when multiple entities collide on the same sanitized name.
2457
+ */
2458
+ protected matchNamedBySanitizedToolName<T extends {
2459
+ Name?: string | null;
2460
+ }>(rawName: string, pool: readonly T[], stripSubAgentPrefix?: boolean): {
2461
+ match?: T;
2462
+ ambiguous?: T[];
2463
+ };
2158
2464
  /**
2159
2465
  * Builds a compact hint listing the current user's permitted runnable agents when a
2160
2466
  * task-graph or folded sub-agent step references an unknown or inaccessible agent name.
@@ -2164,11 +2470,9 @@ export declare class BaseAgent {
2164
2470
  * Validates a `'Tasks'` next step before `executeTasksStep` submits the graph.
2165
2471
  *
2166
2472
  * Verifies that every referenced `Agent` (including `ForEach`/`While` loop sub-agents) is
2167
- * active and runnable by `params.contextUser`, and that every referenced `Action` is active.
2168
- * When an agent or action name is unknown or inaccessible, converts the step to a self-correcting
2169
- * `Retry` with the user's permitted runnable agent list instead of letting `TaskGraphService.Submit`
2170
- * terminate the entire agent run as `Failed`. Never reveals whether an invalid agent name was
2171
- * nonexistent versus restricted by permissions.
2473
+ * active and runnable by `params.contextUser`, and that every referenced `Action` (including
2474
+ * multi-step `steps[]` loop bodies) is active. Accepts sanitized native tool names
2475
+ * (`calculate_expression`, `delegate_to_query_builder`) and canonicalizes them in place.
2172
2476
  */
2173
2477
  protected validateTasksNextStep<P>(params: ExecuteAgentParams, nextStep: BaseAgentNextStep<P>, _currentPayload: P, _agentRun: MJAIAgentRunEntityExtended, _currentStep: MJAIAgentRunStepEntityExtended): Promise<BaseAgentNextStep<P>>;
2174
2478
  /**
@@ -2181,7 +2485,8 @@ export declare class BaseAgent {
2181
2485
  protected validateActionsNextStep<P>(params: ExecuteAgentParams, nextStep: BaseAgentNextStep<P>, currentPayload: P, agentRun: MJAIAgentRunEntityExtended, currentStep: MJAIAgentRunStepEntityExtended): Promise<BaseAgentNextStep<P>>;
2182
2486
  /**
2183
2487
  * Gets the effective actions for validation, using runtime changes if available.
2184
- * Falls back to database-configured actions if _effectiveActions is empty.
2488
+ * Falls back to database-configured actions only when the list was never computed for this run;
2489
+ * a computed empty list (a host's actionChanges removed every action) is returned as-is.
2185
2490
  *
2186
2491
  * @param agentId - The ID of the agent to get actions for
2187
2492
  * @returns Array of effective actions available to the agent
@@ -2189,9 +2494,35 @@ export declare class BaseAgent {
2189
2494
  * @since 2.123.0
2190
2495
  */
2191
2496
  protected getEffectiveActionsForValidation(agentId: string): MJActionEntityExtended[];
2497
+ /**
2498
+ * Returns active actions referenced directly by an agent's Flow steps (`AIAgentStep.ActionID`
2499
+ * plus any `steps[].name` inside a `ForEach`/`While` Flow step's `Configuration` JSON).
2500
+ * Flow agents bind actions on `AIAgentStep` rather than `AIAgentAction`, so in-run Flow loops
2501
+ * need these actions in scope alongside {@link getEffectiveActionsForValidation}.
2502
+ */
2503
+ private getFlowStepActions;
2504
+ /**
2505
+ * Combines {@link getEffectiveActionsForValidation} with {@link getFlowStepActions} (deduplicated
2506
+ * by `ID`) so both Loop agents (strictly `AIAgentAction` / `_effectiveActions`) and Flow agents
2507
+ * (`AIAgentStep` / `Configuration.steps[]`) resolve permitted actions consistently.
2508
+ */
2509
+ private getAvailableActionsForAgent;
2510
+ /**
2511
+ * Resolves an action name against `pool` without mutating caller objects:
2512
+ * 1) exact case-insensitive match, 2) unambiguous sanitized native tool-name match,
2513
+ * 3) unambiguous CONTAINS partial match.
2514
+ */
2515
+ private resolveActionEntityForAgent;
2516
+ /**
2517
+ * Returns a deep-cloned `TaskGraphSpec` with sanitized native tool names (`calculate_expression`,
2518
+ * `delegate_to_query_builder`) canonicalized to exact metadata names before durable submission,
2519
+ * without mutating the caller's `spec`.
2520
+ */
2521
+ private canonicalizeTaskGraphSpec;
2192
2522
  /**
2193
2523
  * Gets the effective sub-agents for validation, using runtime subAgentChanges if available.
2194
- * Falls back to the database-configured relationship set if _effectiveSubAgents is empty.
2524
+ * Falls back to the database-configured relationship set only when the list was never computed
2525
+ * for this run; a computed empty list is returned as-is.
2195
2526
  * Mirrors {@link getEffectiveActionsForValidation}.
2196
2527
  *
2197
2528
  * @param agentId - The ID of the agent to get sub-agents for
@@ -2217,6 +2548,17 @@ export declare class BaseAgent {
2217
2548
  * @protected
2218
2549
  */
2219
2550
  protected validatePlanNextStep<P>(params: ExecuteAgentParams, nextStep: BaseAgentNextStep<P>, currentPayload: P, agentRun: MJAIAgentRunEntityExtended, currentStep: MJAIAgentRunStepEntityExtended): Promise<BaseAgentNextStep<P>>;
2551
+ /**
2552
+ * Validates a `'Handoff'` next step: re-checks the runtime withholding conditions (sub-agent run,
2553
+ * missing `conversationDetailId`, or missing `handoffChain`) and validates the requested target
2554
+ * via {@link ResolveHandoffTarget} (Active status, `'view'` and `'run'` permissions, direct
2555
+ * discoverability, host allow-list, cycle check, and hop limit). On refusal, writes a Failed
2556
+ * `'Handoff'` step and returns a `'Retry'` step naming up to 20 candidate agents; on approval,
2557
+ * stores the resolved target ID and name for {@link executeHandoffStep}.
2558
+ *
2559
+ * @protected
2560
+ */
2561
+ protected validateHandoffNextStep<P>(params: ExecuteAgentParams, nextStep: BaseAgentNextStep<P>, _currentPayload: P, _agentRun: MJAIAgentRunEntityExtended, _currentStep: MJAIAgentRunStepEntityExtended): Promise<BaseAgentNextStep<P>>;
2220
2562
  /**
2221
2563
  * Validates that the Success next step is valid and can be executed by the current agent. Subclasses can override
2222
2564
  * this method to implement custom validation logic if needed.
@@ -2253,16 +2595,50 @@ export declare class BaseAgent {
2253
2595
  * @returns
2254
2596
  */
2255
2597
  protected validateRetryNextStep<P>(params: ExecuteAgentParams, nextStep: BaseAgentNextStep<P>, currentPayload: P, agentRun: MJAIAgentRunEntityExtended, currentStep: MJAIAgentRunStepEntityExtended): Promise<BaseAgentNextStep<P>>;
2598
+ /**
2599
+ * Resolves the effective `ChatHandlingOption` for a sub-agent execution:
2600
+ * `relationship?.ChatHandlingOption ?? parentAgent.ChatHandlingOption ?? null`.
2601
+ * @private
2602
+ */
2603
+ private resolveSubAgentChatHandlingOption;
2604
+ /**
2605
+ * Returns `true` only when `resolvedOption === 'Consult'` AND the parent agent's
2606
+ * type supports injecting loop/consult messages into conversation history
2607
+ * (`this.AgentTypeInstance?.InjectLoopResultsAsMessage !== false`).
2608
+ *
2609
+ * When `resolvedOption === 'Consult'` and `this.AgentTypeInstance?.InjectLoopResultsAsMessage === false`
2610
+ * (e.g., a Flow parent), logs a warning once per run and returns `false` so `'Consult'`
2611
+ * is treated as `null` (propagate).
2612
+ * @private
2613
+ */
2614
+ private isSubAgentConsultActive;
2615
+ /**
2616
+ * Resolves the sub-agent `ChatHandlingOption` and downgrades `'Consult'` to `null`
2617
+ * when `isSubAgentConsultActive` returns `false` (e.g., on Flow parents).
2618
+ * @private
2619
+ */
2620
+ private effectiveSubAgentChatHandlingOption;
2621
+ /**
2622
+ * Side-effect-free check used during prompt and native-tool construction to determine
2623
+ * whether `'Consult'` is active for a specific sub-agent of `parentAgent`.
2624
+ * @private
2625
+ */
2626
+ private isSubAgentConsultEnabledForSubAgent;
2256
2627
  /**
2257
2628
  * Validates that the Chat next step is valid and can be executed by the current agent.
2258
- * Implements ChatHandlingOption remapping logic - if the agent has ChatHandlingOption set,
2259
- * the Chat step is remapped to the specified value (Success, Fail, or Retry).
2629
+ * Implements ChatHandlingOption remapping logic - if the agent (or sub-agent relationship)
2630
+ * has ChatHandlingOption set:
2631
+ * - `'Consult'`: leaves the Chat step unchanged (an agent's own Chat propagates to its caller;
2632
+ * sub-agent Consult is intercepted before this validator).
2633
+ * - `'Success'` / `'Failed'`: remaps `step` while preserving `terminate: true` to end the run.
2634
+ * - `'Retry'`: remaps `step` to `'Retry'`, sets `terminate: false` so the loop continues, and
2635
+ * populates `errorMessage` so the unproductive-retry safety net bounds repeated Chat attempts.
2260
2636
  * Subclasses can override this method to implement custom validation logic if needed.
2261
2637
  * @param params
2262
2638
  * @param nextStep
2263
2639
  * @returns
2264
2640
  */
2265
- protected validateChatNextStep<P>(params: ExecuteAgentParams, nextStep: BaseAgentNextStep<P>, currentPayload: P, agentRun: MJAIAgentRunEntityExtended, currentStep: MJAIAgentRunStepEntityExtended): Promise<BaseAgentNextStep<P>>;
2641
+ protected validateChatNextStep<P>(params: ExecuteAgentParams, nextStep: BaseAgentNextStep<P>, currentPayload: P, agentRun: MJAIAgentRunEntityExtended, currentStep: MJAIAgentRunStepEntityExtended, chatHandlingOption?: MJAIAgentEntity['ChatHandlingOption']): Promise<BaseAgentNextStep<P>>;
2266
2642
  /**
2267
2643
  * Checks execution guardrails and modifies next step if limits are exceeded.
2268
2644
  * This method is called after validation but before execution of non-terminal steps.
@@ -2525,6 +2901,34 @@ export declare class BaseAgent {
2525
2901
  * @protected
2526
2902
  */
2527
2903
  protected processNextStep<P>(nextStep: BaseAgentNextStep<P>, params: ExecuteAgentParams, agentType: MJAIAgentTypeEntity, promptResult: AIPromptRunResult, currentPayload: P, currentStep: MJAIAgentRunStepEntityExtended): Promise<BaseAgentNextStep<P>>;
2904
+ /**
2905
+ * A completion refused with a payload change in hand: the change is discarded (the prompt step
2906
+ * commits it only for an accepted completion), so the refusal the model reads says so, and asks
2907
+ * for the change again with the next completion. Otherwise the model would take the change as
2908
+ * saved and its work would be lost. The change is removed from the step, so nothing later
2909
+ * applies it. Any other step is returned as it is.
2910
+ */
2911
+ private noteDiscardedCompletionChange;
2912
+ /**
2913
+ * Answers a retried native tool-call turn in the protocol itself: every call gets an `is_error`
2914
+ * result carrying the retry reason, and no user message follows.
2915
+ *
2916
+ * The call turn was just replayed by `appendNativeAssistantTurn`, so the result turn lands
2917
+ * directly behind it — the adjacency Anthropic and OpenAI both require. Calls the turn already
2918
+ * answered (its agent tools ran and reported) keep their results; the rest join that tool turn.
2919
+ * Returns false when the turn's results do not go back natively, or no call is left to answer;
2920
+ * the caller then sends the reason as a user message, and `reconcileUnansweredToolCalls`
2921
+ * closes any call still open.
2922
+ */
2923
+ private answerNativeRetryTurn;
2924
+ /**
2925
+ * A turn that wrote and then asked or completed, where a write failed: the question or
2926
+ * completion is declined, and the turn becomes a plain "go again" Retry. The model made that
2927
+ * call expecting its writes to land, so it reads the failure and decides again.
2928
+ *
2929
+ * @returns The step to process — `step` itself when nothing failed or it is not terminal
2930
+ */
2931
+ private declineTerminalAfterFailedWrite;
2528
2932
  /** The tool name the model used for a call on this turn — `payload_change_request` when it cannot be found. */
2529
2933
  private nativeToolNameForCall;
2530
2934
  /**
@@ -2596,6 +3000,20 @@ export declare class BaseAgent {
2596
3000
  * @protected
2597
3001
  */
2598
3002
  protected applyStoppedRunContinuation(params: ExecuteAgentParams, continuation: StoppedRunContinuation | null, continuationMessage: ChatMessage | undefined): void;
3003
+ /**
3004
+ * Loads unanswered sub-agent consultations (`OutputData.consult`) from `params.lastRunId` when that
3005
+ * prior run paused with `FinalStep === 'Chat'` (and was not stopped by the user). Runs at any depth
3006
+ * so a middle agent resumed via `resumeRunId` also reloads its own open child consults. Fail-soft.
3007
+ * @private
3008
+ */
3009
+ private loadOpenConsults;
3010
+ /**
3011
+ * Restores reloaded open sub-agent consults into `this._openSubAgentConsults` (so `resumeRunId`
3012
+ * validation accepts them) and splices a `sub-agent-consult` reminder message immediately before
3013
+ * `continuationMessage` (the caller's answer). Fail-soft.
3014
+ * @private
3015
+ */
3016
+ private applyOpenConsults;
2599
3017
  /**
2600
3018
  * The full-stack half of {@link applyStoppedRunContinuation}: true when the stopped run's turns were
2601
3019
  * spliced in. Any failure leaves the messages untouched and returns false, so the caller carries
@@ -2899,6 +3317,8 @@ export declare class BaseAgent {
2899
3317
  * @protected
2900
3318
  */
2901
3319
  protected capStandaloneToolResultText(text: string): string;
3320
+ /** Where and for whom a memory write lands — shared by the envelope field and the native tool. */
3321
+ private memoryWriteOptions;
2902
3322
  /**
2903
3323
  * Executes a batch of in-flight memory writes, recording each as its own
2904
3324
  * `Tool` AIAgentRunStep (a sibling of the Prompt step that requested them)
@@ -3444,8 +3864,6 @@ export declare class BaseAgent {
3444
3864
  * class (never the key), so a run's log shows which action drew which credential.
3445
3865
  */
3446
3866
  private buildRuntimeAPIKeyResolver;
3447
- /** The model's arguments as the engine's input parameters. */
3448
- private toEngineActionParams;
3449
3867
  /**
3450
3868
  * The action context for one dispatch: the agent's own context object, by reference (do NOT spread —
3451
3869
  * spreading destroys class instances, losing getters/methods on typed contexts like SkipAgentContext),
@@ -3484,11 +3902,17 @@ export declare class BaseAgent {
3484
3902
  * The full ActionResult objects are returned, allowing the caller to access result codes, output parameters,
3485
3903
  * and other execution details.
3486
3904
  *
3905
+ * The run's bound parameters (`ExecuteAgentParams.boundActionParams`) are applied first: a bound value
3906
+ * replaces whatever the model sent under its name, and a call the bindings refuse (a required parameter
3907
+ * bound to nothing, a binding naming no input of the action) returns a blocked `'fatal'` result without
3908
+ * dispatching and locks the action out for the rest of the run.
3909
+ *
3487
3910
  * @param {ExecuteAgentParams} params - Parameters from agent execution for context passing
3488
3911
  * @param {AgentAction} action - Action to execute
3489
3912
  * @param {UserInfo} [contextUser] - Optional user context for permissions
3490
3913
  * @param {ExecuteSingleActionOptions} [options] - `skipCircuitBreaker` bypasses the run-scoped
3491
- * circuit breaker for callers that do their own failure accounting (the pipeline executor)
3914
+ * circuit breaker for callers that do their own failure accounting (the pipeline executor);
3915
+ * `StepID` names the run step in the audit lines a bound parameter writes
3492
3916
  *
3493
3917
  * @returns {Promise<ActionResult>} ActionResult object from the action execution
3494
3918
  *
@@ -3545,11 +3969,12 @@ export declare class BaseAgent {
3545
3969
  * @param {AgentSubAgentRequest} subAgentRequest - Sub-agent request details
3546
3970
  * @param {MJAIAgentEntityExtended} subAgent - The sub-agent entity
3547
3971
  * @param {ChatMessage | undefined} contextMessage - Optional context from SubAgentContextPaths
3972
+ * @param {string | null | undefined} consultQuestion - Optional open-consult question when resuming a child run
3548
3973
  * @returns {ChatMessage[]} Prepared message array for sub-agent execution
3549
3974
  *
3550
3975
  * @protected
3551
3976
  */
3552
- protected prepareSubAgentMessages(params: ExecuteAgentParams, subAgentRequest: AgentSubAgentRequest, subAgent: MJAIAgentEntityExtended, contextMessage?: ChatMessage): ChatMessage[];
3977
+ protected prepareSubAgentMessages(params: ExecuteAgentParams, subAgentRequest: AgentSubAgentRequest, subAgent: MJAIAgentEntityExtended, contextMessage?: ChatMessage, consultQuestion?: string | null): ChatMessage[];
3553
3978
  /**
3554
3979
  * Executes a sub-agent synchronously.
3555
3980
  *
@@ -3577,6 +4002,17 @@ export declare class BaseAgent {
3577
4002
  * ```
3578
4003
  */
3579
4004
  protected ExecuteSubAgent<SC = any, SR = any>(params: ExecuteAgentParams<SC>, subAgentRequest: AgentSubAgentRequest<SC>, subAgent: MJAIAgentEntityExtended, stepEntity: MJAIAgentRunStepEntityExtended, payload?: SR, contextMessage?: ChatMessage, stepCount?: number): Promise<ExecuteAgentResult<SR>>;
4005
+ /**
4006
+ * Resolves the configuration to pass to a sub-agent run in precedence order:
4007
+ * 1. Per-call `subAgentRequest.presetName` -> matching Active preset of `subAgent`.
4008
+ * 2. Active `AIAgentRelationship.ConfigurationPresetID` -> that preset if Active and owned by `subAgent`;
4009
+ * otherwise logs a warning and falls through.
4010
+ * 3. Inherit `params.configurationId`.
4011
+ *
4012
+ * When a preset is selected, `configurationId` is `preset.AIConfigurationID ?? undefined` (a NULL
4013
+ * `AIConfigurationID` means default rows and intentionally does NOT inherit `params.configurationId`).
4014
+ */
4015
+ private resolveSubAgentConfiguration;
3580
4016
  /**
3581
4017
  * A sub-agent request's template parameters without the host-only run-data keys
3582
4018
  * (`HOST_ONLY_AGENT_RUN_DATA_KEYS` in `@memberjunction/ai-core-plus`: the reserved scope family and
@@ -3619,7 +4055,11 @@ export declare class BaseAgent {
3619
4055
  * Produces ~75% fewer tokens than the previous JSON format while preserving
3620
4056
  * all information the LLM needs to invoke actions correctly.
3621
4057
  *
4058
+ * A parameter the run binds (`ExecuteAgentParams.boundActionParams`) is left out, so the model is
4059
+ * never told it exists. With no bindings the output is the cached catalog's, unchanged.
4060
+ *
3622
4061
  * @param {MJActionEntityExtended[]} actions - Array of action entities
4062
+ * @param {BoundActionParams} [boundActionParams] - The run's bindings, when it has any
3623
4063
  * @returns {string} Markdown formatted string with action details
3624
4064
  * @private
3625
4065
  */
@@ -3665,7 +4105,7 @@ export declare class BaseAgent {
3665
4105
  * like one the loop wrote. See the Actions step for why it is a user-role annotation.
3666
4106
  * @protected
3667
4107
  */
3668
- protected buildActionInvocationMessage(actions: AgentAction[]): string;
4108
+ protected buildActionInvocationMessage(actions: AgentAction[], params: ExecuteAgentParams): string;
3669
4109
  /**
3670
4110
  * The action-results message body: a header naming any failures, then each result in the
3671
4111
  * compact markdown shape. Shared by the live Actions step and the stopped-run resume.
@@ -4144,6 +4584,28 @@ export declare class BaseAgent {
4144
4584
  *
4145
4585
  * @private
4146
4586
  */
4587
+ /** Whether a step is a completion that carries a payload change, which is held until the completion is accepted. */
4588
+ private static carriesCompletionChange;
4589
+ /**
4590
+ * Applies a turn's `payloadChangeRequest` to `current` and returns the result; `current` is not
4591
+ * changed. Honours `PayloadSelfWritePaths`. A brand-new artifact whose payload is still the one
4592
+ * inherited from a prior run (or that uses `replaceElements`) is built on an empty object, so
4593
+ * keys from the previous artifact cannot bleed in.
4594
+ */
4595
+ private applyTurnPayloadChange;
4596
+ /**
4597
+ * The payload a completion would leave behind: the committed payload with the completion's
4598
+ * change applied. Success validation (the minimum-execution check, then `FinalPayloadValidation`)
4599
+ * checks this draft, and it becomes the payload only if the completion is accepted. The
4600
+ * opt-in payload change check is not asked here: it never runs on a step that ends the run.
4601
+ */
4602
+ private buildCompletionDraft;
4603
+ /**
4604
+ * The payload a turn leaves behind. A held completion draft is committed only when the step is
4605
+ * still `Success` after validation; on a refusal the committed payload stands (a subclass that
4606
+ * set a payload of its own still wins). Without a draft, a subclass's `newPayload` wins as before.
4607
+ */
4608
+ private resolveTurnPayload;
4147
4609
  private executePromptStep;
4148
4610
  /**
4149
4611
  * Computes the upstream and downstream paths for a sub-agent based on the agent's payload paths.
@@ -4334,6 +4796,23 @@ export declare class BaseAgent {
4334
4796
  */
4335
4797
  private recordParallelStepCompletion;
4336
4798
  private executeParallelSubAgents;
4799
+ /**
4800
+ * Pushes a sub-agent result or consult message to the parent's conversation history,
4801
+ * answering natively-invoked `delegate_to_*` calls as a tool-result turn when applicable
4802
+ * and applying expiration defaults / overrides.
4803
+ *
4804
+ * @private
4805
+ */
4806
+ private pushSubAgentConversationMessage;
4807
+ /**
4808
+ * Unified handler for a single sub-agent (child, related, or runtime-granted) that
4809
+ * finished with `FinalStep === 'Chat'`. Resolves `ChatHandlingOption` for the pairing,
4810
+ * runs the consult flow when `'Consult'` is active and within the per-sub-agent round
4811
+ * bound, and otherwise finalizes the step and delegates to `validateChatNextStep`.
4812
+ *
4813
+ * @private
4814
+ */
4815
+ private handleSingleSubAgentChatStep;
4337
4816
  /**
4338
4817
  * Executes a related sub-agent step (AgentRelationships) and tracks it.
4339
4818
  * Related agents use message-based communication with independent payloads.
@@ -4697,6 +5176,14 @@ export declare class BaseAgent {
4697
5176
  * @protected
4698
5177
  */
4699
5178
  protected executeTasksStep(params: ExecuteAgentParams, previousDecision: BaseAgentNextStep): Promise<BaseAgentNextStep>;
5179
+ /**
5180
+ * Executes a `'Handoff'` next step: records the `'Handoff'` step entity with the resolved
5181
+ * target agent ID, stores {@link _handoffResult} for {@link ExecuteAgentResult.handoff},
5182
+ * and ends this run `'Success'` with the handoff message so the host can invoke the target agent.
5183
+ *
5184
+ * @protected
5185
+ */
5186
+ protected executeHandoffStep(params: ExecuteAgentParams, previousDecision: BaseAgentNextStep): Promise<BaseAgentNextStep>;
4700
5187
  /**
4701
5188
  * Records a constant-folded task graph (D9) without submitting it.
4702
5189
  *
@@ -4793,10 +5280,10 @@ export declare class BaseAgent {
4793
5280
  * - If there's a responseForm with fields, uses "Information"
4794
5281
  * - Otherwise defaults to "Information"
4795
5282
  *
4796
- * Caches the request type lookup for the duration of this agent execution.
5283
+ * Request types come from the AI engine's cached `MJ: AI Agent Request Types` rows
5284
+ * (`AIEngineBase.ResolveAgentRequestTypeID`), the same source the agent actions use.
4797
5285
  * @private
4798
5286
  */
4799
- private _requestTypeCache;
4800
5287
  private resolveRequestTypeId;
4801
5288
  /**
4802
5289
  * Inspects an AgentResponseForm to determine the best request type name.
@@ -4807,13 +5294,19 @@ export declare class BaseAgent {
4807
5294
  private detectRequestTypeName;
4808
5295
  /**
4809
5296
  * Executes a ForEach loop with actual for loop
4810
- * @private
4811
5297
  */
4812
5298
  private executeForEachLoop;
4813
5299
  private validateWhileOperation;
4814
- private validateForEachOperation;
4815
- protected validateActionInAgent(actionName: string): string | null;
4816
- protected validateSubAgentInAgent(subAgentName: string): string | null;
5300
+ private validateForEachHeader;
5301
+ /**
5302
+ * Validates the loop body arm (`action` | `steps` | `subAgent`) shared by `ForEach` and `While`.
5303
+ * Structural validation is delegated to CorePlus {@link ValidateLoopOperationStructure} so in-turn
5304
+ * and durable loops enforce one identical contract; runtime action/sub-agent membership is checked
5305
+ * here without mutating `op`.
5306
+ */
5307
+ private validateLoopBodyOperation;
5308
+ protected validateActionInAgent(actionName: string, agentId?: string): string | null;
5309
+ protected validateSubAgentInAgent(subAgentName: string, agentId?: string): string | null;
4817
5310
  /**
4818
5311
  * Helper: Validate and extract collection from payload
4819
5312
  * Strips "payload." prefix if present (for LLM convenience)
@@ -4848,6 +5341,15 @@ export declare class BaseAgent {
4848
5341
  * This ensures payload changes are applied in order even when iterations ran in parallel.
4849
5342
  */
4850
5343
  private applyForEachResultsSequentially;
5344
+ private extractActionOutputObject;
5345
+ private applyLoopOutputFold;
5346
+ /**
5347
+ * Executes an ordered sequence of `LoopBodyActionStep` actions inside a single `ForEach` or `While`
5348
+ * iteration, chaining step outputs under `steps.<id>.*` / `steps.step_<index>.*`, evaluating optional
5349
+ * per-step `condition` expressions, folding optional per-step `outputMapping` onto the working payload,
5350
+ * and halting remaining steps in the pass if any step fails.
5351
+ */
5352
+ private executeLoopStepsIteration;
4851
5353
  /**
4852
5354
  * Helper: Execute single ForEach iteration
4853
5355
  */
@@ -4916,7 +5418,6 @@ export declare class BaseAgent {
4916
5418
  private createFailedStep;
4917
5419
  /**
4918
5420
  * Executes a While loop with actual while loop
4919
- * @private
4920
5421
  */
4921
5422
  private executeWhileLoop;
4922
5423
  /**
@@ -5370,6 +5871,12 @@ export declare class BaseAgent {
5370
5871
  * ({@link validateAndApplySecondaryScopes}), and `null` for whatever the run does not carry.
5371
5872
  */
5372
5873
  private validatedRunScope;
5874
+ /**
5875
+ * The search scopes the host assigned this run ({@link ExecuteAgentParams.SearchScopeIDs}): trimmed, de-duplicated,
5876
+ * in the host's order, or `null` for none. Read from the first-class parameter only — never from `data`, which a
5877
+ * caller could otherwise use to hand an agent a scope its own SearchScopeAccess refuses.
5878
+ */
5879
+ private hostSearchScopeIDs;
5373
5880
  /**
5374
5881
  * Writes the validated run scope onto the run row: the primary entity resolved to its ID (logged when it is
5375
5882
  * not in metadata), the tenant record ID and the secondary dimensions as JSON. A secondary-only scope on an