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.
- package/AGENTS.md +2 -2
- package/CAPABILITIES.md +2 -0
- package/ai-instructions/claude-code/SKILL.md +2 -2
- package/dist/adapters/observability/auditShapes.js +8 -9
- package/dist/adapters/observability/auditShapes.js.map +1 -1
- package/dist/core/Agent.js +91 -158
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/agent/AgentBuilder.js +29 -69
- package/dist/core/agent/AgentBuilder.js.map +1 -1
- package/dist/core/agent/aroundTurn/errors.js +38 -0
- package/dist/core/agent/aroundTurn/errors.js.map +1 -0
- package/dist/core/agent/aroundTurn/funnel.js +164 -0
- package/dist/core/agent/aroundTurn/funnel.js.map +1 -0
- package/dist/core/agent/aroundTurn/guards.js +34 -0
- package/dist/core/agent/aroundTurn/guards.js.map +1 -0
- package/dist/core/agent/aroundTurn/index.js +13 -0
- package/dist/core/agent/aroundTurn/index.js.map +1 -0
- package/dist/core/agent/aroundTurn/readOnlyCopy.js +52 -0
- package/dist/core/agent/aroundTurn/readOnlyCopy.js.map +1 -0
- package/dist/core/agent/aroundTurn/types.js +6 -0
- package/dist/core/agent/aroundTurn/types.js.map +1 -0
- package/dist/core/agent/assessment/answerLayerOptions.js +72 -0
- package/dist/core/agent/assessment/answerLayerOptions.js.map +1 -0
- package/dist/core/agent/hostTurn.js +1 -0
- package/dist/core/agent/hostTurn.js.map +1 -1
- package/dist/core/agent/run/eventStageIds.js +6 -1
- package/dist/core/agent/run/eventStageIds.js.map +1 -1
- package/dist/core/agent/run/outputStrategySupport.js +62 -0
- package/dist/core/agent/run/outputStrategySupport.js.map +1 -0
- package/dist/core/agent/run/terminalRunError.js +44 -0
- package/dist/core/agent/run/terminalRunError.js.map +1 -0
- package/dist/core/runnerLive.js.map +1 -1
- package/dist/doors/time.js +11 -3
- package/dist/doors/time.js.map +1 -1
- package/dist/esm/adapters/observability/auditShapes.js +8 -9
- package/dist/esm/adapters/observability/auditShapes.js.map +1 -1
- package/dist/esm/core/Agent.d.ts +13 -27
- package/dist/esm/core/Agent.js +86 -153
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/agent/AgentBuilder.d.ts +22 -0
- package/dist/esm/core/agent/AgentBuilder.js +27 -67
- package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
- package/dist/esm/core/agent/aroundTurn/errors.d.ts +15 -0
- package/dist/esm/core/agent/aroundTurn/errors.js +34 -0
- package/dist/esm/core/agent/aroundTurn/errors.js.map +1 -0
- package/dist/esm/core/agent/aroundTurn/funnel.d.ts +18 -0
- package/dist/esm/core/agent/aroundTurn/funnel.js +159 -0
- package/dist/esm/core/agent/aroundTurn/funnel.js.map +1 -0
- package/dist/esm/core/agent/aroundTurn/guards.d.ts +16 -0
- package/dist/esm/core/agent/aroundTurn/guards.js +28 -0
- package/dist/esm/core/agent/aroundTurn/guards.js.map +1 -0
- package/dist/esm/core/agent/aroundTurn/index.d.ts +4 -0
- package/dist/esm/core/agent/aroundTurn/index.js +4 -0
- package/dist/esm/core/agent/aroundTurn/index.js.map +1 -0
- package/dist/esm/core/agent/aroundTurn/readOnlyCopy.d.ts +12 -0
- package/dist/esm/core/agent/aroundTurn/readOnlyCopy.js +48 -0
- package/dist/esm/core/agent/aroundTurn/readOnlyCopy.js.map +1 -0
- package/dist/esm/core/agent/aroundTurn/types.d.ts +57 -0
- package/dist/esm/core/agent/aroundTurn/types.js +5 -0
- package/dist/esm/core/agent/aroundTurn/types.js.map +1 -0
- package/dist/esm/core/agent/assessment/answerLayerOptions.d.ts +21 -0
- package/dist/esm/core/agent/assessment/answerLayerOptions.js +67 -0
- package/dist/esm/core/agent/assessment/answerLayerOptions.js.map +1 -0
- package/dist/esm/core/agent/hostTurn.d.ts +2 -0
- package/dist/esm/core/agent/hostTurn.js +1 -0
- package/dist/esm/core/agent/hostTurn.js.map +1 -1
- package/dist/esm/core/agent/run/eventStageIds.d.ts +5 -0
- package/dist/esm/core/agent/run/eventStageIds.js +5 -0
- package/dist/esm/core/agent/run/eventStageIds.js.map +1 -1
- package/dist/esm/core/agent/run/outputStrategySupport.d.ts +26 -0
- package/dist/esm/core/agent/run/outputStrategySupport.js +58 -0
- package/dist/esm/core/agent/run/outputStrategySupport.js.map +1 -0
- package/dist/esm/core/agent/run/terminalRunError.d.ts +22 -0
- package/dist/esm/core/agent/run/terminalRunError.js +40 -0
- package/dist/esm/core/agent/run/terminalRunError.js.map +1 -0
- package/dist/esm/core/runnerLive.d.ts +3 -0
- package/dist/esm/core/runnerLive.js.map +1 -1
- package/dist/esm/doors/time.d.ts +9 -2
- package/dist/esm/doors/time.js +9 -2
- package/dist/esm/doors/time.js.map +1 -1
- package/dist/esm/events/dispatcher.d.ts +4 -4
- package/dist/esm/events/dispatcher.js +4 -4
- package/dist/esm/events/payloads/agent.d.ts +8 -0
- package/dist/esm/events/payloads.d.ts +1 -1
- package/dist/esm/events/registry.d.ts +4 -5
- package/dist/esm/events/registry.js +4 -7
- package/dist/esm/events/registry.js.map +1 -1
- package/dist/esm/hosting/errors.d.ts +18 -15
- package/dist/esm/hosting/errors.js +23 -22
- package/dist/esm/hosting/errors.js.map +1 -1
- package/dist/esm/hosting/index.d.ts +2 -1
- package/dist/esm/hosting/index.js +2 -1
- package/dist/esm/hosting/index.js.map +1 -1
- package/dist/esm/hosting/requireCapability.d.ts +8 -0
- package/dist/esm/hosting/requireCapability.js +16 -0
- package/dist/esm/hosting/requireCapability.js.map +1 -0
- package/dist/esm/hosting/standingAgent.js +33 -34
- package/dist/esm/hosting/standingAgent.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +6 -16
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/locales/timeAsk.js +1 -1
- package/dist/esm/locales/timeAsk.js.map +1 -1
- package/dist/esm/redaction/knownStrings.d.ts +3 -5
- package/dist/esm/redaction/knownStrings.js +2 -0
- package/dist/esm/redaction/knownStrings.js.map +1 -1
- package/dist/esm/time/readers/english/grammar.d.ts +3 -3
- package/dist/esm/time/readers/english/grammar.js +4 -4
- package/dist/esm/time/readers/english/grammar.js.map +1 -1
- package/dist/esm/time/readers/english.d.ts +1 -1
- package/dist/esm/time/readers/english.js +1 -1
- package/dist/esm/time/replyForm/bindings.d.ts +20 -1
- package/dist/esm/time/replyForm/bindings.js +31 -12
- package/dist/esm/time/replyForm/bindings.js.map +1 -1
- package/dist/events/dispatcher.js +4 -4
- package/dist/events/registry.js +4 -7
- package/dist/events/registry.js.map +1 -1
- package/dist/hosting/errors.js +25 -24
- package/dist/hosting/errors.js.map +1 -1
- package/dist/hosting/index.js +6 -4
- package/dist/hosting/index.js.map +1 -1
- package/dist/hosting/requireCapability.js +20 -0
- package/dist/hosting/requireCapability.js.map +1 -0
- package/dist/hosting/standingAgent.js +32 -33
- package/dist/hosting/standingAgent.js.map +1 -1
- package/dist/index.js +122 -131
- package/dist/index.js.map +1 -1
- package/dist/locales/timeAsk.js +1 -1
- package/dist/locales/timeAsk.js.map +1 -1
- package/dist/redaction/knownStrings.js +2 -0
- package/dist/redaction/knownStrings.js.map +1 -1
- package/dist/time/readers/english/grammar.js +4 -4
- package/dist/time/readers/english/grammar.js.map +1 -1
- package/dist/time/readers/english.js +1 -1
- package/dist/time/replyForm/bindings.js +31 -12
- package/dist/time/replyForm/bindings.js.map +1 -1
- package/dist/types/core/Agent.d.ts +13 -27
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/agent/AgentBuilder.d.ts +22 -0
- package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
- package/dist/types/core/agent/aroundTurn/errors.d.ts +16 -0
- package/dist/types/core/agent/aroundTurn/errors.d.ts.map +1 -0
- package/dist/types/core/agent/aroundTurn/funnel.d.ts +19 -0
- package/dist/types/core/agent/aroundTurn/funnel.d.ts.map +1 -0
- package/dist/types/core/agent/aroundTurn/guards.d.ts +17 -0
- package/dist/types/core/agent/aroundTurn/guards.d.ts.map +1 -0
- package/dist/types/core/agent/aroundTurn/index.d.ts +5 -0
- package/dist/types/core/agent/aroundTurn/index.d.ts.map +1 -0
- package/dist/types/core/agent/aroundTurn/readOnlyCopy.d.ts +13 -0
- package/dist/types/core/agent/aroundTurn/readOnlyCopy.d.ts.map +1 -0
- package/dist/types/core/agent/aroundTurn/types.d.ts +58 -0
- package/dist/types/core/agent/aroundTurn/types.d.ts.map +1 -0
- package/dist/types/core/agent/assessment/answerLayerOptions.d.ts +22 -0
- package/dist/types/core/agent/assessment/answerLayerOptions.d.ts.map +1 -0
- package/dist/types/core/agent/hostTurn.d.ts +2 -0
- package/dist/types/core/agent/hostTurn.d.ts.map +1 -1
- package/dist/types/core/agent/run/eventStageIds.d.ts +5 -0
- package/dist/types/core/agent/run/eventStageIds.d.ts.map +1 -1
- package/dist/types/core/agent/run/outputStrategySupport.d.ts +27 -0
- package/dist/types/core/agent/run/outputStrategySupport.d.ts.map +1 -0
- package/dist/types/core/agent/run/terminalRunError.d.ts +23 -0
- package/dist/types/core/agent/run/terminalRunError.d.ts.map +1 -0
- package/dist/types/core/runnerLive.d.ts +3 -0
- package/dist/types/core/runnerLive.d.ts.map +1 -1
- package/dist/types/doors/time.d.ts +9 -2
- package/dist/types/doors/time.d.ts.map +1 -1
- package/dist/types/events/dispatcher.d.ts +4 -4
- package/dist/types/events/payloads/agent.d.ts +8 -0
- package/dist/types/events/payloads/agent.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +1 -1
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/events/registry.d.ts +4 -5
- package/dist/types/events/registry.d.ts.map +1 -1
- package/dist/types/hosting/errors.d.ts +18 -15
- package/dist/types/hosting/errors.d.ts.map +1 -1
- package/dist/types/hosting/index.d.ts +2 -1
- package/dist/types/hosting/index.d.ts.map +1 -1
- package/dist/types/hosting/requireCapability.d.ts +9 -0
- package/dist/types/hosting/requireCapability.d.ts.map +1 -0
- package/dist/types/hosting/standingAgent.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/redaction/knownStrings.d.ts +3 -5
- package/dist/types/redaction/knownStrings.d.ts.map +1 -1
- package/dist/types/time/readers/english/grammar.d.ts +3 -3
- package/dist/types/time/readers/english/grammar.d.ts.map +1 -1
- package/dist/types/time/readers/english.d.ts +1 -1
- package/dist/types/time/replyForm/bindings.d.ts +20 -1
- package/dist/types/time/replyForm/bindings.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/core/Agent.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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,
|
|
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 (`
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
!
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
2964
|
-
|
|
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:
|
|
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,
|
|
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
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
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
|