agentfootprint 14.2.0 → 14.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/AGENTS.md +2 -2
  2. package/CAPABILITIES.md +2 -0
  3. package/ai-instructions/claude-code/SKILL.md +2 -2
  4. package/dist/adapters/observability/auditShapes.js +8 -9
  5. package/dist/adapters/observability/auditShapes.js.map +1 -1
  6. package/dist/core/Agent.js +91 -158
  7. package/dist/core/Agent.js.map +1 -1
  8. package/dist/core/agent/AgentBuilder.js +29 -69
  9. package/dist/core/agent/AgentBuilder.js.map +1 -1
  10. package/dist/core/agent/aroundTurn/errors.js +38 -0
  11. package/dist/core/agent/aroundTurn/errors.js.map +1 -0
  12. package/dist/core/agent/aroundTurn/funnel.js +164 -0
  13. package/dist/core/agent/aroundTurn/funnel.js.map +1 -0
  14. package/dist/core/agent/aroundTurn/guards.js +34 -0
  15. package/dist/core/agent/aroundTurn/guards.js.map +1 -0
  16. package/dist/core/agent/aroundTurn/index.js +13 -0
  17. package/dist/core/agent/aroundTurn/index.js.map +1 -0
  18. package/dist/core/agent/aroundTurn/readOnlyCopy.js +52 -0
  19. package/dist/core/agent/aroundTurn/readOnlyCopy.js.map +1 -0
  20. package/dist/core/agent/aroundTurn/types.js +6 -0
  21. package/dist/core/agent/aroundTurn/types.js.map +1 -0
  22. package/dist/core/agent/assessment/answerLayerOptions.js +72 -0
  23. package/dist/core/agent/assessment/answerLayerOptions.js.map +1 -0
  24. package/dist/core/agent/hostTurn.js +1 -0
  25. package/dist/core/agent/hostTurn.js.map +1 -1
  26. package/dist/core/agent/run/eventStageIds.js +6 -1
  27. package/dist/core/agent/run/eventStageIds.js.map +1 -1
  28. package/dist/core/agent/run/outputStrategySupport.js +62 -0
  29. package/dist/core/agent/run/outputStrategySupport.js.map +1 -0
  30. package/dist/core/agent/run/terminalRunError.js +44 -0
  31. package/dist/core/agent/run/terminalRunError.js.map +1 -0
  32. package/dist/core/runnerLive.js.map +1 -1
  33. package/dist/doors/time.js +11 -3
  34. package/dist/doors/time.js.map +1 -1
  35. package/dist/esm/adapters/observability/auditShapes.js +8 -9
  36. package/dist/esm/adapters/observability/auditShapes.js.map +1 -1
  37. package/dist/esm/core/Agent.d.ts +13 -27
  38. package/dist/esm/core/Agent.js +86 -153
  39. package/dist/esm/core/Agent.js.map +1 -1
  40. package/dist/esm/core/agent/AgentBuilder.d.ts +22 -0
  41. package/dist/esm/core/agent/AgentBuilder.js +27 -67
  42. package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
  43. package/dist/esm/core/agent/aroundTurn/errors.d.ts +15 -0
  44. package/dist/esm/core/agent/aroundTurn/errors.js +34 -0
  45. package/dist/esm/core/agent/aroundTurn/errors.js.map +1 -0
  46. package/dist/esm/core/agent/aroundTurn/funnel.d.ts +18 -0
  47. package/dist/esm/core/agent/aroundTurn/funnel.js +159 -0
  48. package/dist/esm/core/agent/aroundTurn/funnel.js.map +1 -0
  49. package/dist/esm/core/agent/aroundTurn/guards.d.ts +16 -0
  50. package/dist/esm/core/agent/aroundTurn/guards.js +28 -0
  51. package/dist/esm/core/agent/aroundTurn/guards.js.map +1 -0
  52. package/dist/esm/core/agent/aroundTurn/index.d.ts +4 -0
  53. package/dist/esm/core/agent/aroundTurn/index.js +4 -0
  54. package/dist/esm/core/agent/aroundTurn/index.js.map +1 -0
  55. package/dist/esm/core/agent/aroundTurn/readOnlyCopy.d.ts +12 -0
  56. package/dist/esm/core/agent/aroundTurn/readOnlyCopy.js +48 -0
  57. package/dist/esm/core/agent/aroundTurn/readOnlyCopy.js.map +1 -0
  58. package/dist/esm/core/agent/aroundTurn/types.d.ts +57 -0
  59. package/dist/esm/core/agent/aroundTurn/types.js +5 -0
  60. package/dist/esm/core/agent/aroundTurn/types.js.map +1 -0
  61. package/dist/esm/core/agent/assessment/answerLayerOptions.d.ts +21 -0
  62. package/dist/esm/core/agent/assessment/answerLayerOptions.js +67 -0
  63. package/dist/esm/core/agent/assessment/answerLayerOptions.js.map +1 -0
  64. package/dist/esm/core/agent/hostTurn.d.ts +2 -0
  65. package/dist/esm/core/agent/hostTurn.js +1 -0
  66. package/dist/esm/core/agent/hostTurn.js.map +1 -1
  67. package/dist/esm/core/agent/run/eventStageIds.d.ts +5 -0
  68. package/dist/esm/core/agent/run/eventStageIds.js +5 -0
  69. package/dist/esm/core/agent/run/eventStageIds.js.map +1 -1
  70. package/dist/esm/core/agent/run/outputStrategySupport.d.ts +26 -0
  71. package/dist/esm/core/agent/run/outputStrategySupport.js +58 -0
  72. package/dist/esm/core/agent/run/outputStrategySupport.js.map +1 -0
  73. package/dist/esm/core/agent/run/terminalRunError.d.ts +22 -0
  74. package/dist/esm/core/agent/run/terminalRunError.js +40 -0
  75. package/dist/esm/core/agent/run/terminalRunError.js.map +1 -0
  76. package/dist/esm/core/runnerLive.d.ts +3 -0
  77. package/dist/esm/core/runnerLive.js.map +1 -1
  78. package/dist/esm/doors/time.d.ts +9 -2
  79. package/dist/esm/doors/time.js +9 -2
  80. package/dist/esm/doors/time.js.map +1 -1
  81. package/dist/esm/events/dispatcher.d.ts +4 -4
  82. package/dist/esm/events/dispatcher.js +4 -4
  83. package/dist/esm/events/payloads/agent.d.ts +8 -0
  84. package/dist/esm/events/payloads.d.ts +1 -1
  85. package/dist/esm/events/registry.d.ts +4 -5
  86. package/dist/esm/events/registry.js +4 -7
  87. package/dist/esm/events/registry.js.map +1 -1
  88. package/dist/esm/hosting/errors.d.ts +18 -15
  89. package/dist/esm/hosting/errors.js +23 -22
  90. package/dist/esm/hosting/errors.js.map +1 -1
  91. package/dist/esm/hosting/index.d.ts +2 -1
  92. package/dist/esm/hosting/index.js +2 -1
  93. package/dist/esm/hosting/index.js.map +1 -1
  94. package/dist/esm/hosting/requireCapability.d.ts +8 -0
  95. package/dist/esm/hosting/requireCapability.js +16 -0
  96. package/dist/esm/hosting/requireCapability.js.map +1 -0
  97. package/dist/esm/hosting/standingAgent.js +33 -34
  98. package/dist/esm/hosting/standingAgent.js.map +1 -1
  99. package/dist/esm/index.d.ts +1 -0
  100. package/dist/esm/index.js +6 -16
  101. package/dist/esm/index.js.map +1 -1
  102. package/dist/esm/locales/timeAsk.js +1 -1
  103. package/dist/esm/locales/timeAsk.js.map +1 -1
  104. package/dist/esm/redaction/knownStrings.d.ts +3 -5
  105. package/dist/esm/redaction/knownStrings.js +2 -0
  106. package/dist/esm/redaction/knownStrings.js.map +1 -1
  107. package/dist/esm/time/readers/english/grammar.d.ts +3 -3
  108. package/dist/esm/time/readers/english/grammar.js +4 -4
  109. package/dist/esm/time/readers/english/grammar.js.map +1 -1
  110. package/dist/esm/time/readers/english.d.ts +1 -1
  111. package/dist/esm/time/readers/english.js +1 -1
  112. package/dist/esm/time/replyForm/bindings.d.ts +20 -1
  113. package/dist/esm/time/replyForm/bindings.js +31 -12
  114. package/dist/esm/time/replyForm/bindings.js.map +1 -1
  115. package/dist/events/dispatcher.js +4 -4
  116. package/dist/events/registry.js +4 -7
  117. package/dist/events/registry.js.map +1 -1
  118. package/dist/hosting/errors.js +25 -24
  119. package/dist/hosting/errors.js.map +1 -1
  120. package/dist/hosting/index.js +6 -4
  121. package/dist/hosting/index.js.map +1 -1
  122. package/dist/hosting/requireCapability.js +20 -0
  123. package/dist/hosting/requireCapability.js.map +1 -0
  124. package/dist/hosting/standingAgent.js +32 -33
  125. package/dist/hosting/standingAgent.js.map +1 -1
  126. package/dist/index.js +122 -131
  127. package/dist/index.js.map +1 -1
  128. package/dist/locales/timeAsk.js +1 -1
  129. package/dist/locales/timeAsk.js.map +1 -1
  130. package/dist/redaction/knownStrings.js +2 -0
  131. package/dist/redaction/knownStrings.js.map +1 -1
  132. package/dist/time/readers/english/grammar.js +4 -4
  133. package/dist/time/readers/english/grammar.js.map +1 -1
  134. package/dist/time/readers/english.js +1 -1
  135. package/dist/time/replyForm/bindings.js +31 -12
  136. package/dist/time/replyForm/bindings.js.map +1 -1
  137. package/dist/types/core/Agent.d.ts +13 -27
  138. package/dist/types/core/Agent.d.ts.map +1 -1
  139. package/dist/types/core/agent/AgentBuilder.d.ts +22 -0
  140. package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
  141. package/dist/types/core/agent/aroundTurn/errors.d.ts +16 -0
  142. package/dist/types/core/agent/aroundTurn/errors.d.ts.map +1 -0
  143. package/dist/types/core/agent/aroundTurn/funnel.d.ts +19 -0
  144. package/dist/types/core/agent/aroundTurn/funnel.d.ts.map +1 -0
  145. package/dist/types/core/agent/aroundTurn/guards.d.ts +17 -0
  146. package/dist/types/core/agent/aroundTurn/guards.d.ts.map +1 -0
  147. package/dist/types/core/agent/aroundTurn/index.d.ts +5 -0
  148. package/dist/types/core/agent/aroundTurn/index.d.ts.map +1 -0
  149. package/dist/types/core/agent/aroundTurn/readOnlyCopy.d.ts +13 -0
  150. package/dist/types/core/agent/aroundTurn/readOnlyCopy.d.ts.map +1 -0
  151. package/dist/types/core/agent/aroundTurn/types.d.ts +58 -0
  152. package/dist/types/core/agent/aroundTurn/types.d.ts.map +1 -0
  153. package/dist/types/core/agent/assessment/answerLayerOptions.d.ts +22 -0
  154. package/dist/types/core/agent/assessment/answerLayerOptions.d.ts.map +1 -0
  155. package/dist/types/core/agent/hostTurn.d.ts +2 -0
  156. package/dist/types/core/agent/hostTurn.d.ts.map +1 -1
  157. package/dist/types/core/agent/run/eventStageIds.d.ts +5 -0
  158. package/dist/types/core/agent/run/eventStageIds.d.ts.map +1 -1
  159. package/dist/types/core/agent/run/outputStrategySupport.d.ts +27 -0
  160. package/dist/types/core/agent/run/outputStrategySupport.d.ts.map +1 -0
  161. package/dist/types/core/agent/run/terminalRunError.d.ts +23 -0
  162. package/dist/types/core/agent/run/terminalRunError.d.ts.map +1 -0
  163. package/dist/types/core/runnerLive.d.ts +3 -0
  164. package/dist/types/core/runnerLive.d.ts.map +1 -1
  165. package/dist/types/doors/time.d.ts +9 -2
  166. package/dist/types/doors/time.d.ts.map +1 -1
  167. package/dist/types/events/dispatcher.d.ts +4 -4
  168. package/dist/types/events/payloads/agent.d.ts +8 -0
  169. package/dist/types/events/payloads/agent.d.ts.map +1 -1
  170. package/dist/types/events/payloads.d.ts +1 -1
  171. package/dist/types/events/payloads.d.ts.map +1 -1
  172. package/dist/types/events/registry.d.ts +4 -5
  173. package/dist/types/events/registry.d.ts.map +1 -1
  174. package/dist/types/hosting/errors.d.ts +18 -15
  175. package/dist/types/hosting/errors.d.ts.map +1 -1
  176. package/dist/types/hosting/index.d.ts +2 -1
  177. package/dist/types/hosting/index.d.ts.map +1 -1
  178. package/dist/types/hosting/requireCapability.d.ts +9 -0
  179. package/dist/types/hosting/requireCapability.d.ts.map +1 -0
  180. package/dist/types/hosting/standingAgent.d.ts.map +1 -1
  181. package/dist/types/index.d.ts +1 -0
  182. package/dist/types/index.d.ts.map +1 -1
  183. package/dist/types/redaction/knownStrings.d.ts +3 -5
  184. package/dist/types/redaction/knownStrings.d.ts.map +1 -1
  185. package/dist/types/time/readers/english/grammar.d.ts +3 -3
  186. package/dist/types/time/readers/english/grammar.d.ts.map +1 -1
  187. package/dist/types/time/readers/english.d.ts +1 -1
  188. package/dist/types/time/replyForm/bindings.d.ts +20 -1
  189. package/dist/types/time/replyForm/bindings.d.ts.map +1 -1
  190. package/package.json +1 -1
@@ -26,6 +26,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.Agent = exports.AgentBuilder = void 0;
27
27
  const resumeAnswer_js_1 = require("./agent/resumeAnswer.js");
28
28
  const hostTurn_js_1 = require("./agent/hostTurn.js");
29
+ const index_js_1 = require("./agent/aroundTurn/index.js");
30
+ const outputStrategySupport_js_1 = require("./agent/run/outputStrategySupport.js");
31
+ const terminalRunError_js_1 = require("./agent/run/terminalRunError.js");
29
32
  const componentResources_js_1 = require("./agent/componentResources.js");
30
33
  const resumeCheckpoint_js_1 = require("./agent/resumeCheckpoint.js");
31
34
  const pauseOwnership_js_1 = require("./agent/pauseOwnership.js");
@@ -35,15 +38,10 @@ const runRedaction_js_1 = require("../redaction/runRedaction.js");
35
38
  const runValues_js_1 = require("./agent/runValues.js");
36
39
  const runnerExecution_js_1 = require("./runnerExecution.js");
37
40
  const context_js_1 = require("./agent/findings/context.js");
38
- const types_js_1 = require("../reliability/types.js");
39
41
  const extractSequence_js_1 = require("../security/extractSequence.js");
40
- const PolicyHaltError_js_1 = require("../security/PolicyHaltError.js");
41
42
  const CacheGateDecider_js_1 = require("../cache/CacheGateDecider.js");
42
43
  const cacheStrategyFor_js_1 = require("../cache/cacheStrategyFor.js");
43
44
  const cacheSupport_js_1 = require("./agent/cacheSupport.js");
44
- const forcedToolChoice_js_1 = require("../provider-contract/forcedToolChoice.js");
45
- const nativeOutputSchema_js_1 = require("../provider-contract/nativeOutputSchema.js");
46
- const requestRefusal_js_1 = require("../provider-contract/requestRefusal.js");
47
45
  const assistantReplay_js_1 = require("./agent/assistantReplay.js");
48
46
  const skillBrains_js_1 = require("./agent/skillBrains.js");
49
47
  const conventions_js_1 = require("../lib/conventions.js");
@@ -94,7 +92,6 @@ const options_js_1 = require("./agent/window/options.js");
94
92
  const deliver_js_1 = require("./agent/stages/deliver.js");
95
93
  const providerTargets_js_1 = require("./agent/providerTargets.js");
96
94
  const injectionDelivery_js_1 = require("./agent/run/injectionDelivery.js");
97
- const errors_js_1 = require("./agent/window/errors.js");
98
95
  const checkin_js_1 = require("./checkin.js");
99
96
  const cost_js_1 = require("./cost.js");
100
97
  const buildSystemPromptSlot_js_1 = require("./slots/buildSystemPromptSlot.js");
@@ -112,8 +109,7 @@ const failFastRecord_js_1 = require("../reliability/failFastRecord.js");
112
109
  const terminalVerdict_js_1 = require("./terminalVerdict.js");
113
110
  const breakFinal_js_1 = require("./agent/stages/breakFinal.js");
114
111
  const gate_js_1 = require("./agent/evidence/gate.js");
115
- const errors_js_2 = require("./agent/evidence/errors.js");
116
- const types_js_2 = require("../provider-contract/types.js");
112
+ const types_js_1 = require("../provider-contract/types.js");
117
113
  const skillTarget_js_1 = require("../security/skillTarget.js");
118
114
  const buildInjectionEngineSubflow_js_1 = require("../injection-engine/buildInjectionEngineSubflow.js");
119
115
  const pickEntry_js_1 = require("./agent/stages/pickEntry.js");
@@ -137,10 +133,10 @@ const recheck_js_1 = require("./agent/negativeClaims/recheck.js");
137
133
  const answerValidation_js_1 = require("./agent/stages/answerValidation.js");
138
134
  const messagePhase_js_1 = require("./agent/middleware/messagePhase.js");
139
135
  const answerCoverage_js_1 = require("./agent/stages/answerCoverage.js");
140
- const index_js_1 = require("../answer-validation/index.js");
136
+ const index_js_2 = require("../answer-validation/index.js");
141
137
  const seed_js_1 = require("./agent/stages/seed.js");
142
138
  const callLLM_js_1 = require("./agent/stages/callLLM.js");
143
- const index_js_2 = require("./agent/stages/toolCalls/index.js");
139
+ const index_js_3 = require("./agent/stages/toolCalls/index.js");
144
140
  const toolResolver_js_1 = require("./agent/stages/toolResolver.js");
145
141
  const route_js_2 = require("./agent/stages/route.js");
146
142
  const declare_js_1 = require("../tools/declare.js");
@@ -386,6 +382,8 @@ class Agent extends RunnerBase_js_1.RunnerBase {
386
382
  /** The message chain (`.messageMiddleware()`), in declaration order. Empty
387
383
  * keeps seed synchronous and prepare-final untouched. */
388
384
  messageMiddleware;
385
+ /** `.aroundTurn()`, or undefined: the funnel then adds nothing to a turn. */
386
+ aroundTurnPort;
389
387
  /** Snapshot read-tracking policy (#18/#14) — forwarded to the internal
390
388
  * executor. Agent default is `'summary'` (cheap markers), NOT
391
389
  * footprintjs's `'full'`. See AgentOptions.readTracking. */
@@ -660,7 +658,7 @@ class Agent extends RunnerBase_js_1.RunnerBase {
660
658
  negativeClaimsConfig;
661
659
  typedNegativeClaimsConfig;
662
660
  applicationAnswerValidation;
663
- constructor(opts, systemPromptValue, registry, voice, injections = [], memories = [], outputSchemaParser, toolProvider, systemPromptCachePolicy = 'always', cachingDisabled = false, cacheStrategy, outputFallbackCfg, reliabilityConfig, thinkingHandlerValue, thinkingBudgetValue, skillGraphNextSkill, skillGraphReachable, skillGraphScoreEntries, checkInOptions, runConfigFn, windowStrategy, toolMiddleware, messageMiddleware, outputEnforcement, skillGraphEdgeTargets, skillGraphExplainNextSkill, skillGraphIsTree, skillGraphSupersededEntries, skillGraphCascade, skillBrains, evidenceGate, limitsTravelWithTheAnswer, recipes, skillGraphDeclared, mapsPlan, claimContract, answerValidationConfig, systemPromptCacheExplicit = false, negativeClaimsConfig, scriptTravel) {
661
+ constructor(opts, systemPromptValue, registry, voice, injections = [], memories = [], outputSchemaParser, toolProvider, systemPromptCachePolicy = 'always', cachingDisabled = false, cacheStrategy, outputFallbackCfg, reliabilityConfig, thinkingHandlerValue, thinkingBudgetValue, skillGraphNextSkill, skillGraphReachable, skillGraphScoreEntries, checkInOptions, runConfigFn, windowStrategy, toolMiddleware, messageMiddleware, outputEnforcement, skillGraphEdgeTargets, skillGraphExplainNextSkill, skillGraphIsTree, skillGraphSupersededEntries, skillGraphCascade, skillBrains, evidenceGate, limitsTravelWithTheAnswer, recipes, skillGraphDeclared, mapsPlan, claimContract, answerValidationConfig, systemPromptCacheExplicit = false, negativeClaimsConfig, scriptTravel, aroundTurn) {
664
662
  super();
665
663
  // Which conversation this instance's self-explain evidence belongs to —
666
664
  // held in a module registry, not on the class, so it is not public API
@@ -682,7 +680,7 @@ class Agent extends RunnerBase_js_1.RunnerBase {
682
680
  answerValidationConfig ??
683
681
  (this.typedNegativeClaimsConfig === undefined
684
682
  ? undefined
685
- : (0, index_js_1.resolveAnswerValidation)({
683
+ : (0, index_js_2.resolveAnswerValidation)({
686
684
  id: 'negative-claims',
687
685
  version: '1',
688
686
  mode: 'observe',
@@ -799,7 +797,7 @@ class Agent extends RunnerBase_js_1.RunnerBase {
799
797
  if (opts.answerLayer === true)
800
798
  this.answerLayerOption = {};
801
799
  else if (typeof opts.answerLayer === 'object' && opts.answerLayer !== null) {
802
- // The builder judged the option (`AgentBuilder.ts` · `answerLayerArm`); `true` is 'always'.
800
+ // The builder judged the option (`assessment/answerLayerOptions.ts` · `answerLayerArm`); `true` is 'always'.
803
801
  const line = opts.answerLayer.standingLine;
804
802
  this.answerLayerOption =
805
803
  line === true
@@ -872,6 +870,7 @@ class Agent extends RunnerBase_js_1.RunnerBase {
872
870
  // call that provably never ran from one whose outcome is not known.
873
871
  (0, consentRequest_js_1.registerConsentLedger)(this, this.decisionLedger);
874
872
  this.messageMiddleware = messageMiddleware ?? [];
873
+ this.aroundTurnPort = aroundTurn;
875
874
  // Default 'summary' — measurement-gated (#18): stageReads values have
876
875
  // zero consumers across af/lens/eui, and 'full' clones ~18MB of unread
877
876
  // data per 200 iterations. Consumers opt into 'full' explicitly.
@@ -1120,6 +1119,10 @@ class Agent extends RunnerBase_js_1.RunnerBase {
1120
1119
  return {
1121
1120
  recorder: observers.recorder,
1122
1121
  bindScope: (scope) => {
1122
+ // No entry: mounted in a run this agent did not start. Refused as its
1123
+ // first stage opens, where the mounting run's recorders hear the name.
1124
+ if (entry === undefined)
1125
+ (0, index_js_1.refuseMountedWrapper)(this.aroundTurnPort);
1123
1126
  const run = this.runExecution().forScope(scope);
1124
1127
  value.resources?.bindReporter((status) => (0, runRedaction_js_1.captureLateEmitter)(scope, eventStageIds_js_1.TOOL_TEARDOWN_STAGE_ID)?.('agentfootprint.tools.resource_restore', status));
1125
1128
  (0, runRedaction_js_1.bindScopeComputation)(scope, {
@@ -1141,6 +1144,7 @@ class Agent extends RunnerBase_js_1.RunnerBase {
1141
1144
  resume: (run, checkpoint, input, options) => this.resumeOwned(run, checkpoint, input, options),
1142
1145
  prepareResume: (checkpoint) => this.noteResumeTakenUp(checkpoint),
1143
1146
  checkpoint: (run) => this.checkpointFor(run),
1147
+ replaced: () => (0, index_js_1.replacedTurnMethods)(this, OWN_TURN_METHODS),
1144
1148
  }),
1145
1149
  pause: {
1146
1150
  capture: (outcome) => (0, pauseOwnership_js_1.capturePauseOwnership)(this.runExecution().selected()?.value, outcome),
@@ -1525,39 +1529,42 @@ class Agent extends RunnerBase_js_1.RunnerBase {
1525
1529
  throw new Error(`Agent.runTyped: this agent has no outputSchema. Use ` +
1526
1530
  `Agent.create({...}).outputSchema(parser).build() to enable typed output.`);
1527
1531
  }
1528
- const out = await this.runOwned(invocation, input, options);
1529
- if (typeof out !== 'string') {
1530
- throw new Error('Agent.runTyped: run paused — typed mode does not support pauses. ' +
1531
- 'Use agent.run() + agent.parseOutput(...) after resume.');
1532
- }
1533
- // `strategy: 'native'`: an answer whose last attempt failed on a refusal
1534
- // or truncation stop is refused here even when its text parses — the
1535
- // format did not hold for it (outputEnforcement.ts · nativeStopFailure).
1536
- // FIRST, before any delivery path. It takes the same path a parse failure
1537
- // takes, `.outputFallback()` included.
1538
- const stopped = this.outputEnforcement?.outputFormat !== undefined ? this.outputContractUnmet() : undefined;
1539
- if (stopped?.stopReason !== undefined) {
1540
- return this.settleTypedFailure(out, new outputSchema_js_1.OutputSchemaError(stopped.error, { rawOutput: out, stage: stopped.stage }), invocation);
1541
- }
1542
- if (this.answerValidationConfig !== undefined) {
1543
- // The validator judged the schema's JSON output. Do not run a transforming
1544
- // or stateful parser again and hand back a value the validator never saw.
1545
- if (this.answerValidation()?.schemaAccepted !== true) {
1546
- throw new outputSchema_js_1.OutputSchemaError('Answer validation could not establish a JSON schema result.', {
1547
- rawOutput: out,
1548
- stage: 'schema-validate',
1549
- });
1550
- }
1551
- return (0, outputSchema_js_1.applyOutputSchema)(out, { parse: (value) => value });
1552
- }
1553
- try {
1554
- return (0, outputSchema_js_1.applyOutputSchema)(out, this.outputSchemaParser);
1555
- }
1556
- catch (error) {
1557
- return this.settleTypedFailure(out, error, invocation);
1558
- }
1532
+ return this.runTurn(invocation, input, options, async (turnInput) => this.typedOutcome(invocation, await this.runLeg(invocation, turnInput, options)));
1559
1533
  });
1560
1534
  }
1535
+ /** What `runTyped` makes of the answer: inside the turn, so a wrapper's context reaches it. */
1536
+ async typedOutcome(invocation, out) {
1537
+ if (typeof out !== 'string') {
1538
+ throw new Error('Agent.runTyped: run paused — typed mode does not support pauses. ' +
1539
+ 'Use agent.run() + agent.parseOutput(...) after resume.');
1540
+ }
1541
+ // `strategy: 'native'`: an answer whose last attempt failed on a refusal
1542
+ // or truncation stop is refused here even when its text parses — the
1543
+ // format did not hold for it (outputEnforcement.ts · nativeStopFailure).
1544
+ // FIRST, before any delivery path. It takes the same path a parse failure
1545
+ // takes, `.outputFallback()` included.
1546
+ const stopped = this.outputEnforcement?.outputFormat !== undefined ? this.outputContractUnmet() : undefined;
1547
+ if (stopped?.stopReason !== undefined) {
1548
+ return this.settleTypedFailure(out, new outputSchema_js_1.OutputSchemaError(stopped.error, { rawOutput: out, stage: stopped.stage }), invocation);
1549
+ }
1550
+ if (this.answerValidationConfig !== undefined) {
1551
+ // The validator judged the schema's JSON output. Do not run a transforming
1552
+ // or stateful parser again and hand back a value the validator never saw.
1553
+ if (this.answerValidation()?.schemaAccepted !== true) {
1554
+ throw new outputSchema_js_1.OutputSchemaError('Answer validation could not establish a JSON schema result.', {
1555
+ rawOutput: out,
1556
+ stage: 'schema-validate',
1557
+ });
1558
+ }
1559
+ return (0, outputSchema_js_1.applyOutputSchema)(out, { parse: (value) => value });
1560
+ }
1561
+ try {
1562
+ return (0, outputSchema_js_1.applyOutputSchema)(out, this.outputSchemaParser);
1563
+ }
1564
+ catch (error) {
1565
+ return this.settleTypedFailure(out, error, invocation);
1566
+ }
1567
+ }
1561
1568
  /**
1562
1569
  * Answer one turn.
1563
1570
  *
@@ -1598,7 +1605,25 @@ class Agent extends RunnerBase_js_1.RunnerBase {
1598
1605
  async run(input, options) {
1599
1606
  return this.runExecution().withRun((invocation) => this.runOwned(invocation, input, options));
1600
1607
  }
1601
- async runOwned(invocation, input, options) {
1608
+ runOwned(invocation, input, options) {
1609
+ return this.runTurn(invocation, input, options, (turnInput) => this.runLeg(invocation, turnInput, options));
1610
+ }
1611
+ /** The funnel, for a new turn. Every top-level run enters here, inside its lease. */
1612
+ runTurn(invocation, input, options, leg) {
1613
+ return (0, index_js_1.throughAroundTurn)(this.aroundTurnPort, { kind: 'run', input, options }, (changes) => leg((0, index_js_1.runInputWith)(input, options, changes)), (failure) => this.noteAroundTurnFailed(invocation, failure));
1614
+ }
1615
+ /** A wrapper failed after its run: the outcome stands, and the record says so. */
1616
+ noteAroundTurnFailed(invocation, payload) {
1617
+ const meta = { runtimeStageId: eventStageIds_js_1.AROUND_TURN_STAGE_ID };
1618
+ this.getDispatcher().dispatch({
1619
+ type: 'agentfootprint.agent.around_turn_failed',
1620
+ payload,
1621
+ meta: invocation.run.origin === undefined
1622
+ ? { ...this.minimalMeta(), ...meta }
1623
+ : (0, eventMeta_js_1.buildEventMeta)(meta, invocation.context()),
1624
+ });
1625
+ }
1626
+ async runLeg(invocation, input, options) {
1602
1627
  invocation.value.hadAdmitted = invocation.previous?.value.hadAdmitted === true;
1603
1628
  // Normalize or refuse BEFORE anything is created. A bare string is the
1604
1629
  // message; anything that is not a message is named and refused here
@@ -1736,45 +1761,8 @@ class Agent extends RunnerBase_js_1.RunnerBase {
1736
1761
  catch (cause) {
1737
1762
  // A THROWN pause is still a pause — see `endRunToolSessions`.
1738
1763
  // Wrap recoverable errors with the last-known-good checkpoint.
1739
- // Don't wrap intentional terminal signals — let them propagate as
1740
- // their typed shapes so callers can `instanceof` them:
1741
- // • PauseSignal — askHuman pause, not a failure
1742
- // • PolicyHaltError — policy-driven termination; resuming would
1743
- // immediately re-trigger the same halt (the synthetic
1744
- // tool_result is already in history)
1745
- // • ReliabilityFailFastError — finalizeResult constructs and
1746
- // throws this AFTER the chart returns cleanly, so it never
1747
- // enters this catch (kept here for documentation only)
1748
- const isTerminalTypedError = cause instanceof Error &&
1749
- (cause.name === 'PauseSignal' ||
1750
- cause instanceof PolicyHaltError_js_1.PolicyHaltError ||
1751
- cause instanceof types_js_1.ReliabilityFailFastError ||
1752
- // A provider that reports no usage will report none on resume
1753
- // either — wrapping this in a checkpoint would invite the caller to
1754
- // retry into the same wall.
1755
- cause instanceof errors_js_1.CompactionUnmeasurableError ||
1756
- // A forced-output capability refusal is terminal even after a
1757
- // correction turn: a checkpoint cannot repair this model contract.
1758
- (0, requestRefusal_js_1.isRequestRefusal)(cause) ||
1759
- // 8.6.0 — a consent block is answered by a PERSON at the identity
1760
- // provider, not by replaying the run. Wrapping it in a crash
1761
- // checkpoint would hand the caller a retry handle for a wall, and
1762
- // would bury the `authorizationUrl` one `.cause` deep where the
1763
- // person who has to click it will not look.
1764
- cause instanceof CredentialConsentRequiredError_js_1.CredentialConsentRequiredError ||
1765
- // 9.35.0 — an evidence refusal is a VERDICT, not a crash: the run
1766
- // finished, the loop already spent its one revision, and resuming
1767
- // would put the same model in front of the same evidence. Wrapping
1768
- // it would hand the caller a retry handle for a wall and bury the
1769
- // named values one `.cause` deep, where the person deciding what to
1770
- // do about them will not look.
1771
- cause instanceof errors_js_2.UnsupportedValuesError ||
1772
- cause instanceof index_js_1.AnswerValidationError ||
1773
- // 9.60.0 — a dead checker is a WIRING verdict on this build, not a
1774
- // recoverable run state: resuming would run the same dead wiring.
1775
- cause.name === 'CheckerDeadError');
1776
1764
  if (cause instanceof Error &&
1777
- !isTerminalTypedError &&
1765
+ !(0, terminalRunError_js_1.isTerminalRunError)(cause) &&
1778
1766
  !invocation.value.checkpointObservationFailed &&
1779
1767
  tracker.history.length > 0) {
1780
1768
  // Observation beats the heuristic: if a bracket was open, it says
@@ -2052,7 +2040,11 @@ class Agent extends RunnerBase_js_1.RunnerBase {
2052
2040
  this.noteResumeTakenUp(checkpoint);
2053
2041
  return this.runExecution().withRun((invocation) => (0, pauseOwnership_js_1.preservePendingQuestion)(invocation.previous?.value, () => invocation.value.resources?.answer.consumed === true, () => this.resumeOwned(invocation, checkpoint, input, options)));
2054
2042
  }
2055
- async resumeOwned(invocation, checkpoint, input, options) {
2043
+ /** The funnel, for an answered pause. Inside the lease and `preservePendingQuestion`. */
2044
+ resumeOwned(invocation, checkpoint, input, options) {
2045
+ return (0, index_js_1.throughAroundTurn)(this.aroundTurnPort, { kind: 'resume', checkpoint, answer: input, options }, () => this.resumeLeg(invocation, checkpoint, input, options), (failure) => this.noteAroundTurnFailed(invocation, failure));
2046
+ }
2047
+ async resumeLeg(invocation, checkpoint, input, options) {
2056
2048
  // Taken up, before anything can refuse: from here every use of a consent
2057
2049
  // decision passes through the one spend a door watching this pause sees
2058
2050
  // (`consentRequest.ts` · `watchDecisionUse`) — so a resume that fails
@@ -2829,7 +2821,7 @@ class Agent extends RunnerBase_js_1.RunnerBase {
2829
2821
  * always did.
2830
2822
  */
2831
2823
  governsSkillVisibility() {
2832
- return (0, types_js_2.checkerGoverns)(this.permissionChecker, 'skill_read');
2824
+ return (0, types_js_1.checkerGoverns)(this.permissionChecker, 'skill_read');
2833
2825
  }
2834
2826
  // FOLD (resolver) · computes "which skill ids may this caller be told about".
2835
2827
  // The OWNER of the published fact is src/injection-engine/buildInjectionEngineSubflow.ts · hiddenSkillIdsOf
@@ -2892,76 +2884,15 @@ class Agent extends RunnerBase_js_1.RunnerBase {
2892
2884
  assertDeliverableRoles() {
2893
2885
  (0, injectionDelivery_js_1.assertInjectionDelivery)(this.injections, (0, providerTargets_js_1.providerTargets)(this.provider, this.model, this.reliabilityConfig?.providers).map((target) => target.provider));
2894
2886
  }
2895
- /**
2896
- * Refuse, at run start, a `'tool-forced'` output strategy on a provider
2897
- * that does not put a forced tool choice on its wire (7.26).
2898
- *
2899
- * Run start rather than build time for the reason `assertDeliverableRoles`
2900
- * gives one method up: a decorated provider (`withFallback`, `withRetry`,
2901
- * a breaker) is only the thing it is once composed, and `withFallback`
2902
- * publishes the AND of its pair.
2903
- *
2904
- * Refusal rather than a quiet fall back to `'instruct'`, because the two
2905
- * are not interchangeable: one constrains the shape at generation, the
2906
- * other asks for it in prose. An agent that silently got the second while
2907
- * its config said the first would be a promise the recording could not
2908
- * even show was broken.
2909
- */
2910
- assertForcedToolChoiceSupported() {
2911
- if (this.outputEnforcement?.schemaTool === undefined)
2912
- return;
2913
- const first = this.reliabilityConfig?.providers?.[0];
2914
- const provider = first?.provider ?? this.provider;
2915
- const model = first?.model ?? this.model;
2916
- if (provider.carriesForcedToolChoice === true) {
2917
- // Configuration resolves the actual model at seed, after this check.
2918
- // Keep the early wire refusal, but let callLLM judge that final model.
2919
- if ((first === undefined && this.runConfigFn !== undefined) ||
2920
- (0, forcedToolChoice_js_1.forcedToolChoiceFor)(provider, model))
2921
- return;
2922
- throw new forcedToolChoice_js_1.UnsupportedToolChoiceError({ provider: provider.name, model });
2923
- }
2924
- throw new Error(`Agent: .outputSchema(parser, { strategy: 'tool-forced' }) needs a provider that puts ` +
2925
- `a forced tool choice on its wire, and '${provider.name}' does not declare one. ` +
2926
- `Anthropic, Bedrock, real OpenAI/Azure and the mock do; an OpenAI-COMPATIBLE endpoint ` +
2927
- `behind a custom baseURL (Ollama, vLLM, …) deliberately does not, because what that ` +
2928
- `server does with tool_choice is not this library's to promise. Use ` +
2929
- `{ strategy: 'instruct', retries: N } on this provider — it works on every wire — or ` +
2930
- `run the forced strategy on a provider that declares the capability.`);
2931
- }
2932
- /**
2933
- * Refuse, at run start, a `'native'` output strategy on a provider that
2934
- * does not put a structured-output format on its wire, or on a model that
2935
- * does not take one — the `assertForcedToolChoiceSupported` twin, for the
2936
- * same reasons: run start because a decorated provider is only what it is
2937
- * once composed; a refusal because `'instruct'` asks in prose for what this
2938
- * strategy constrains at decoding, and a quiet swap would be config that
2939
- * lies.
2940
- */
2941
- assertNativeOutputSchemaSupported() {
2942
- if (this.outputEnforcement?.outputFormat === undefined ||
2943
- this.outputEnforcement.nativeOutputAuto === true)
2944
- return;
2945
- const first = this.reliabilityConfig?.providers?.[0];
2946
- const provider = first?.provider ?? this.provider;
2947
- const model = first?.model ?? this.model;
2948
- if (provider.carriesNativeOutputSchema === true) {
2949
- // A configured agent resolves its model at seed; callLLM judges it there.
2950
- if ((first === undefined && this.runConfigFn !== undefined) ||
2951
- (0, nativeOutputSchema_js_1.nativeOutputSchemaFor)(provider, model))
2952
- return;
2953
- throw new nativeOutputSchema_js_1.UnsupportedNativeOutputError({ provider: provider.name, model });
2954
- }
2955
- throw new Error(`Agent: .outputSchema(parser, { strategy: 'native' }) needs a provider that puts a ` +
2956
- `structured-output format on its wire, and '${provider.name}' does not declare one. ` +
2957
- `anthropic(), browserAnthropic() and the mock do; the Bedrock and gateway adapters do ` +
2958
- `not in this release. Use { strategy: 'instruct', retries: N } on this provider — it ` +
2959
- `works on every wire — or run the native strategy on a provider that declares it.`);
2960
- }
2961
2887
  prepareAgentRun(invocation, runOptions, request) {
2962
2888
  this.assertDeliverableRoles();
2963
- this.assertForcedToolChoiceSupported();
2964
- this.assertNativeOutputSchemaSupported();
2889
+ (0, outputStrategySupport_js_1.assertOutputStrategySupported)({
2890
+ enforcement: this.outputEnforcement,
2891
+ provider: this.provider,
2892
+ model: this.model,
2893
+ providers: this.reliabilityConfig?.providers,
2894
+ modelResolvedAtSeed: this.runConfigFn !== undefined,
2895
+ });
2965
2896
  const correlationId = runOptions?.correlationId;
2966
2897
  const traceId = runOptions?.traceId ?? runOptions?.env?.traceId;
2967
2898
  const sessionId = runOptions?.sessionId;
@@ -4373,7 +4304,7 @@ class Agent extends RunnerBase_js_1.RunnerBase {
4373
4304
  ...(this.externalToolProvider && { providerToolCache: values.providerToolCache }),
4374
4305
  servedTools: values.servedTools,
4375
4306
  toolClaimants,
4376
- notServed: index_js_2.notServedResult,
4307
+ notServed: index_js_3.notServedResult,
4377
4308
  });
4378
4309
  const resolveForLayer = (scope) => resolverForValues(this.runExecution().forScope(scope).value);
4379
4310
  const displayNameOfFor = this.externalToolProvider !== undefined ||
@@ -4801,7 +4732,7 @@ class Agent extends RunnerBase_js_1.RunnerBase {
4801
4732
  return terminalRouteDecider;
4802
4733
  };
4803
4734
  const terminalRouteDecider = (0, runnerExecution_js_1.bindRunnerStage)((scope) => this.runExecution().forScope(scope), (run) => (run.value.route ??= routeFor(run)));
4804
- const toolCallsFor = (run) => (0, index_js_2.buildToolCallsHandler)({
4735
+ const toolCallsFor = (run) => (0, index_js_3.buildToolCallsHandler)({
4805
4736
  registryByName,
4806
4737
  // WHICH SKILLS DECLARE EACH TOOL NAME (9.86.0) — read by the unknown-tool
4807
4738
  // roster so a role that may not see a skill is not told the names of the
@@ -5271,7 +5202,9 @@ class Agent extends RunnerBase_js_1.RunnerBase {
5271
5202
  }
5272
5203
  }
5273
5204
  exports.Agent = Agent;
5274
- // AgentBuilder extracted to ./agent/AgentBuilder.ts (v2.11.2).
5275
- // Re-export so the 28+ existing import sites continue to work unchanged.
5276
- // Validators + helpers extracted to ./agent/validators.ts (v2.11.1).
5205
+ /** The class's own turn doors, captured at load: patching the prototype later still counts. */
5206
+ const OWN_TURN_METHODS = Object.freeze({
5207
+ run: Agent.prototype.run,
5208
+ resume: Agent.prototype.resume,
5209
+ });
5277
5210
  //# sourceMappingURL=Agent.js.map