@kindgi/agents 0.0.0-bootstrap.0 → 0.1.1
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/LICENSE +201 -0
- package/README.md +131 -2
- package/dist/agent-turn-flow.d.ts +57 -0
- package/dist/agent-turn-flow.d.ts.map +1 -0
- package/dist/agent-turn-flow.js +172 -0
- package/dist/agent-turn-flow.js.map +1 -0
- package/dist/conversation-binding.d.ts +111 -0
- package/dist/conversation-binding.d.ts.map +1 -0
- package/dist/conversation-binding.js +4 -0
- package/dist/conversation-binding.js.map +1 -0
- package/dist/define.d.ts +180 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +361 -0
- package/dist/define.js.map +1 -0
- package/dist/errors.d.ts +62 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +4 -0
- package/dist/errors.js.map +1 -0
- package/dist/guardrails-gate.d.ts +169 -0
- package/dist/guardrails-gate.d.ts.map +1 -0
- package/dist/guardrails-gate.js +202 -0
- package/dist/guardrails-gate.js.map +1 -0
- package/dist/handlers/budget-check.d.ts +22 -0
- package/dist/handlers/budget-check.d.ts.map +1 -0
- package/dist/handlers/budget-check.js +109 -0
- package/dist/handlers/budget-check.js.map +1 -0
- package/dist/handlers/build-initial-messages.d.ts +17 -0
- package/dist/handlers/build-initial-messages.d.ts.map +1 -0
- package/dist/handlers/build-initial-messages.js +86 -0
- package/dist/handlers/build-initial-messages.js.map +1 -0
- package/dist/handlers/compose-result.d.ts +10 -0
- package/dist/handlers/compose-result.d.ts.map +1 -0
- package/dist/handlers/compose-result.js +79 -0
- package/dist/handlers/compose-result.js.map +1 -0
- package/dist/handlers/constants.d.ts +8 -0
- package/dist/handlers/constants.d.ts.map +1 -0
- package/dist/handlers/constants.js +10 -0
- package/dist/handlers/constants.js.map +1 -0
- package/dist/handlers/context.d.ts +210 -0
- package/dist/handlers/context.d.ts.map +1 -0
- package/dist/handlers/context.js +4 -0
- package/dist/handlers/context.js.map +1 -0
- package/dist/handlers/dispatch-tools.d.ts +15 -0
- package/dist/handlers/dispatch-tools.d.ts.map +1 -0
- package/dist/handlers/dispatch-tools.js +511 -0
- package/dist/handlers/dispatch-tools.js.map +1 -0
- package/dist/handlers/errors.d.ts +133 -0
- package/dist/handlers/errors.d.ts.map +1 -0
- package/dist/handlers/errors.js +134 -0
- package/dist/handlers/errors.js.map +1 -0
- package/dist/handlers/evaluate-guardrails.d.ts +14 -0
- package/dist/handlers/evaluate-guardrails.d.ts.map +1 -0
- package/dist/handlers/evaluate-guardrails.js +128 -0
- package/dist/handlers/evaluate-guardrails.js.map +1 -0
- package/dist/handlers/final-iteration.d.ts +7 -0
- package/dist/handlers/final-iteration.d.ts.map +1 -0
- package/dist/handlers/final-iteration.js +26 -0
- package/dist/handlers/final-iteration.js.map +1 -0
- package/dist/handlers/index.d.ts +5 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +41 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/handlers/model-call.d.ts +13 -0
- package/dist/handlers/model-call.d.ts.map +1 -0
- package/dist/handlers/model-call.js +136 -0
- package/dist/handlers/model-call.js.map +1 -0
- package/dist/handlers/persist-final-message.d.ts +14 -0
- package/dist/handlers/persist-final-message.d.ts.map +1 -0
- package/dist/handlers/persist-final-message.js +54 -0
- package/dist/handlers/persist-final-message.js.map +1 -0
- package/dist/handlers/persist-provenance.d.ts +12 -0
- package/dist/handlers/persist-provenance.d.ts.map +1 -0
- package/dist/handlers/persist-provenance.js +34 -0
- package/dist/handlers/persist-provenance.js.map +1 -0
- package/dist/handlers/persist-user-message.d.ts +15 -0
- package/dist/handlers/persist-user-message.d.ts.map +1 -0
- package/dist/handlers/persist-user-message.js +59 -0
- package/dist/handlers/persist-user-message.js.map +1 -0
- package/dist/handlers/public-types.d.ts +201 -0
- package/dist/handlers/public-types.d.ts.map +1 -0
- package/dist/handlers/public-types.js +4 -0
- package/dist/handlers/public-types.js.map +1 -0
- package/dist/handlers/rehydrate.d.ts +8 -0
- package/dist/handlers/rehydrate.d.ts.map +1 -0
- package/dist/handlers/rehydrate.js +94 -0
- package/dist/handlers/rehydrate.js.map +1 -0
- package/dist/handlers/render-prompt.d.ts +12 -0
- package/dist/handlers/render-prompt.d.ts.map +1 -0
- package/dist/handlers/render-prompt.js +41 -0
- package/dist/handlers/render-prompt.js.map +1 -0
- package/dist/handlers/resolve-tools.d.ts +10 -0
- package/dist/handlers/resolve-tools.d.ts.map +1 -0
- package/dist/handlers/resolve-tools.js +55 -0
- package/dist/handlers/resolve-tools.js.map +1 -0
- package/dist/handlers/result-shape.d.ts +94 -0
- package/dist/handlers/result-shape.d.ts.map +1 -0
- package/dist/handlers/result-shape.js +19 -0
- package/dist/handlers/result-shape.js.map +1 -0
- package/dist/handlers/run-retrievals.d.ts +10 -0
- package/dist/handlers/run-retrievals.d.ts.map +1 -0
- package/dist/handlers/run-retrievals.js +64 -0
- package/dist/handlers/run-retrievals.js.map +1 -0
- package/dist/handlers/run-snapshot.d.ts +4 -0
- package/dist/handlers/run-snapshot.d.ts.map +1 -0
- package/dist/handlers/run-snapshot.js +26 -0
- package/dist/handlers/run-snapshot.js.map +1 -0
- package/dist/handlers/setup.d.ts +25 -0
- package/dist/handlers/setup.d.ts.map +1 -0
- package/dist/handlers/setup.js +231 -0
- package/dist/handlers/setup.js.map +1 -0
- package/dist/handlers/structured-output.d.ts +38 -0
- package/dist/handlers/structured-output.d.ts.map +1 -0
- package/dist/handlers/structured-output.js +89 -0
- package/dist/handlers/structured-output.js.map +1 -0
- package/dist/handlers/tool-errors.d.ts +56 -0
- package/dist/handlers/tool-errors.d.ts.map +1 -0
- package/dist/handlers/tool-errors.js +73 -0
- package/dist/handlers/tool-errors.js.map +1 -0
- package/dist/handlers/tool-hitl.d.ts +45 -0
- package/dist/handlers/tool-hitl.d.ts.map +1 -0
- package/dist/handlers/tool-hitl.js +81 -0
- package/dist/handlers/tool-hitl.js.map +1 -0
- package/dist/handlers/turn-environment.d.ts +26 -0
- package/dist/handlers/turn-environment.d.ts.map +1 -0
- package/dist/handlers/turn-environment.js +154 -0
- package/dist/handlers/turn-environment.js.map +1 -0
- package/dist/hitl-policy.d.ts +45 -0
- package/dist/hitl-policy.d.ts.map +1 -0
- package/dist/hitl-policy.js +74 -0
- package/dist/hitl-policy.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/invoke.d.ts +36 -0
- package/dist/invoke.d.ts.map +1 -0
- package/dist/invoke.js +228 -0
- package/dist/invoke.js.map +1 -0
- package/dist/migrations-dir.d.ts +11 -0
- package/dist/migrations-dir.d.ts.map +1 -0
- package/dist/migrations-dir.js +14 -0
- package/dist/migrations-dir.js.map +1 -0
- package/dist/project-run-result.d.ts +23 -0
- package/dist/project-run-result.d.ts.map +1 -0
- package/dist/project-run-result.js +116 -0
- package/dist/project-run-result.js.map +1 -0
- package/dist/prompt.d.ts +83 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +119 -0
- package/dist/prompt.js.map +1 -0
- package/dist/provenance-emit.d.ts +44 -0
- package/dist/provenance-emit.d.ts.map +1 -0
- package/dist/provenance-emit.js +51 -0
- package/dist/provenance-emit.js.map +1 -0
- package/dist/registry.d.ts +38 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +125 -0
- package/dist/registry.js.map +1 -0
- package/dist/retrieval.d.ts +47 -0
- package/dist/retrieval.d.ts.map +1 -0
- package/dist/retrieval.js +155 -0
- package/dist/retrieval.js.map +1 -0
- package/dist/run-snapshot-binding.d.ts +77 -0
- package/dist/run-snapshot-binding.d.ts.map +1 -0
- package/dist/run-snapshot-binding.js +4 -0
- package/dist/run-snapshot-binding.js.map +1 -0
- package/dist/schema.d.ts +497 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +133 -0
- package/dist/schema.js.map +1 -0
- package/dist/streaming.d.ts +118 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/streaming.js +17 -0
- package/dist/streaming.js.map +1 -0
- package/dist/tenant-policy.d.ts +16 -0
- package/dist/tenant-policy.d.ts.map +1 -0
- package/dist/tenant-policy.js +77 -0
- package/dist/tenant-policy.js.map +1 -0
- package/dist/types.d.ts +435 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/versioning.d.ts +29 -0
- package/dist/versioning.d.ts.map +1 -0
- package/dist/versioning.js +58 -0
- package/dist/versioning.js.map +1 -0
- package/migrations/0000_sparkling_talkback.sql +18 -0
- package/migrations/0001_tired_warhawk.sql +16 -0
- package/migrations/0002_violet_ezekiel.sql +2 -0
- package/migrations/meta/0000_snapshot.json +172 -0
- package/migrations/meta/0001_snapshot.json +275 -0
- package/migrations/meta/0002_snapshot.json +287 -0
- package/migrations/meta/_journal.json +27 -0
- package/package.json +76 -4
- package/src/agent-turn-flow.ts +183 -0
- package/src/conversation-binding.ts +147 -0
- package/src/define.ts +572 -0
- package/src/errors.ts +80 -0
- package/src/guardrails-gate.ts +342 -0
- package/src/handlers/budget-check.ts +143 -0
- package/src/handlers/build-initial-messages.ts +103 -0
- package/src/handlers/compose-result.ts +90 -0
- package/src/handlers/constants.ts +10 -0
- package/src/handlers/context.ts +226 -0
- package/src/handlers/dispatch-tools.ts +633 -0
- package/src/handlers/errors.ts +282 -0
- package/src/handlers/evaluate-guardrails.ts +153 -0
- package/src/handlers/final-iteration.ts +30 -0
- package/src/handlers/index.ts +63 -0
- package/src/handlers/model-call.ts +151 -0
- package/src/handlers/persist-final-message.ts +67 -0
- package/src/handlers/persist-provenance.ts +39 -0
- package/src/handlers/persist-user-message.ts +70 -0
- package/src/handlers/public-types.ts +209 -0
- package/src/handlers/rehydrate.ts +161 -0
- package/src/handlers/render-prompt.ts +46 -0
- package/src/handlers/resolve-tools.ts +68 -0
- package/src/handlers/result-shape.ts +113 -0
- package/src/handlers/run-retrievals.ts +77 -0
- package/src/handlers/run-snapshot.ts +44 -0
- package/src/handlers/setup.ts +269 -0
- package/src/handlers/structured-output.ts +117 -0
- package/src/handlers/tool-errors.ts +122 -0
- package/src/handlers/tool-hitl.ts +126 -0
- package/src/handlers/turn-environment.ts +191 -0
- package/src/hitl-policy.ts +128 -0
- package/src/index.ts +154 -0
- package/src/invoke.ts +299 -0
- package/src/migrations-dir.ts +17 -0
- package/src/project-run-result.ts +131 -0
- package/src/prompt.ts +185 -0
- package/src/provenance-emit.ts +100 -0
- package/src/registry.ts +164 -0
- package/src/retrieval.ts +219 -0
- package/src/run-snapshot-binding.ts +87 -0
- package/src/schema.ts +154 -0
- package/src/streaming.ts +153 -0
- package/src/tenant-policy.ts +78 -0
- package/src/types.ts +453 -0
- package/src/versioning.ts +77 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
ModelInfo,
|
|
6
|
+
ModelMessage,
|
|
7
|
+
ModelProvider,
|
|
8
|
+
ModelToolDefinition,
|
|
9
|
+
TenantPolicy,
|
|
10
|
+
} from '@kindgi/capabilities';
|
|
11
|
+
import type { Guardrail } from '@kindgi/guardrails';
|
|
12
|
+
import type { ProvenanceBuilder } from '@kindgi/provenance';
|
|
13
|
+
import type { Tool } from '@kindgi/tools';
|
|
14
|
+
|
|
15
|
+
import type { EvaluationResult } from '@kindgi/guardrails';
|
|
16
|
+
|
|
17
|
+
import type { EffectiveHitlPolicy } from '../hitl-policy.js';
|
|
18
|
+
import type { ProvenanceBindings } from '../provenance-emit.js';
|
|
19
|
+
import type { Agent, Conversation, ConversationMessage, RetrievedFact } from '../types.js';
|
|
20
|
+
|
|
21
|
+
import type { HitlBindings, InvokeAgentBindings, InvokeAgentInput } from './public-types.js';
|
|
22
|
+
import type { ToolErrorPolicy } from './tool-errors.js';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Per-invocation closure state shared across every node handler. This is
|
|
26
|
+
* a mutable container populated by earlier nodes and read by later
|
|
27
|
+
* nodes. Kernel journal entries record the coarse node-level inputs and
|
|
28
|
+
* outputs; this object carries the finer-grained runtime state that is
|
|
29
|
+
* either not JSON-serializable (functions, ModelProvider instances,
|
|
30
|
+
* ProvenanceBuilder) or expensive to reserialize per node.
|
|
31
|
+
*
|
|
32
|
+
* One `TurnContext` lives for the duration of one `invokeAgent` call.
|
|
33
|
+
*/
|
|
34
|
+
export interface TurnContext {
|
|
35
|
+
readonly input: InvokeAgentInput;
|
|
36
|
+
readonly bindings: InvokeAgentBindings;
|
|
37
|
+
/**
|
|
38
|
+
* Composed abort signal: fires when the wall-clock timer expires OR
|
|
39
|
+
* when the caller-provided abortSignal fires. Handlers pass this into
|
|
40
|
+
* long-running I/O.
|
|
41
|
+
*/
|
|
42
|
+
readonly turnAbort: AbortController;
|
|
43
|
+
/**
|
|
44
|
+
* Millisecond timestamp when `invokeAgent` was called. Used to
|
|
45
|
+
* compute `usage.durationMs` inside `compose-result`.
|
|
46
|
+
*/
|
|
47
|
+
readonly startedAt: number;
|
|
48
|
+
/**
|
|
49
|
+
* Populated by `setup` — the loaded conversation row.
|
|
50
|
+
*/
|
|
51
|
+
conversation?: Conversation;
|
|
52
|
+
/**
|
|
53
|
+
* Populated by `setup` — resolved tools (per-name map + model
|
|
54
|
+
* definitions).
|
|
55
|
+
*/
|
|
56
|
+
tools?: {
|
|
57
|
+
readonly definitions: readonly ModelToolDefinition[];
|
|
58
|
+
/**
|
|
59
|
+
* Per-tool resolved binding: the exact `Tool` instance the runtime
|
|
60
|
+
* dispatches, the `resolvedVersion` picked by `resolve` on the
|
|
61
|
+
* tenant's registry (`toolRegistry.forTenant`)
|
|
62
|
+
* (captured for provenance + telemetry so a replay can pin against
|
|
63
|
+
* the same version), and the `requestedRange` the agent binding
|
|
64
|
+
* declared.
|
|
65
|
+
*/
|
|
66
|
+
readonly byName: ReadonlyMap<
|
|
67
|
+
string,
|
|
68
|
+
{
|
|
69
|
+
readonly tool: Tool;
|
|
70
|
+
readonly resolvedVersion: string;
|
|
71
|
+
readonly requestedRange: string;
|
|
72
|
+
}
|
|
73
|
+
>;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Populated by `setup` — the provider the router picked for the
|
|
77
|
+
* agent's first capability.
|
|
78
|
+
*/
|
|
79
|
+
provider?: ModelProvider;
|
|
80
|
+
/**
|
|
81
|
+
* Populated by `setup` alongside `provider` — the specific
|
|
82
|
+
* `ModelInfo` within that provider the router picked. Threaded into
|
|
83
|
+
* `ModelCallInput.model` on every invocation this turn.
|
|
84
|
+
*/
|
|
85
|
+
model?: ModelInfo;
|
|
86
|
+
/**
|
|
87
|
+
* Populated by `setup` — resolved guardrails for the final-response gate.
|
|
88
|
+
*/
|
|
89
|
+
guardrails?: readonly Guardrail[];
|
|
90
|
+
/**
|
|
91
|
+
* Populated by `persist-user-message` — the persisted user message row.
|
|
92
|
+
*/
|
|
93
|
+
userMessage?: ConversationMessage;
|
|
94
|
+
/**
|
|
95
|
+
* Populated by `render-prompt` — the rendered system-instructions
|
|
96
|
+
* string that seeds the first model call.
|
|
97
|
+
*/
|
|
98
|
+
renderedPrompt?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Populated by `run-retrievals` — facts pulled by declared intents.
|
|
101
|
+
*/
|
|
102
|
+
retrieved?: readonly RetrievedFact[];
|
|
103
|
+
/**
|
|
104
|
+
* Populated by `persist-final-message` — the terminal assistant
|
|
105
|
+
* message. `compose-result` reads it back for the returned
|
|
106
|
+
* `AgentTurnResult.response`.
|
|
107
|
+
*/
|
|
108
|
+
finalMessage?: ConversationMessage;
|
|
109
|
+
/**
|
|
110
|
+
* Populated by `dispatch-tools` and `persist-final-message` — the
|
|
111
|
+
* ordered list of every message appended during this turn. Starts
|
|
112
|
+
* with the user message; then intermediate assistant + tool
|
|
113
|
+
* messages; then the final assistant message.
|
|
114
|
+
*/
|
|
115
|
+
appended: ConversationMessage[];
|
|
116
|
+
/**
|
|
117
|
+
* Cumulative usage across all model calls this turn. Updated by
|
|
118
|
+
* `model-call`; read by `budget-check` and `compose-result`.
|
|
119
|
+
*/
|
|
120
|
+
usage: {
|
|
121
|
+
steps: number;
|
|
122
|
+
promptTokens: number;
|
|
123
|
+
completionTokens: number;
|
|
124
|
+
totalCostUsd: number;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Provider + model of the most recent model call (the one that
|
|
128
|
+
* produced the final response). Set by `model-call`; `compose-result`
|
|
129
|
+
* surfaces it as `AgentTurnResult.provider`.
|
|
130
|
+
*/
|
|
131
|
+
lastProvider?: { readonly id: string; readonly model: string };
|
|
132
|
+
/**
|
|
133
|
+
* Provenance builder — undefined when the caller didn't wire one.
|
|
134
|
+
*/
|
|
135
|
+
provenance?: ProvenanceBuilder;
|
|
136
|
+
/**
|
|
137
|
+
* Provenance bindings kept for reference (needed by
|
|
138
|
+
* `persist-provenance` for `emit` + `keyProvider` details).
|
|
139
|
+
*/
|
|
140
|
+
provenanceBindings?: ProvenanceBindings;
|
|
141
|
+
/**
|
|
142
|
+
* The persisted provenance snapshot (post `persist-provenance`).
|
|
143
|
+
* Present only when the builder was wired AND persistence succeeded.
|
|
144
|
+
*/
|
|
145
|
+
persistedProvenance?: import('@kindgi/provenance').Provenance;
|
|
146
|
+
/**
|
|
147
|
+
* The tenant policy this turn's model was routed under (bound policy
|
|
148
|
+
* merged with the policy registry's). Populated by `setup`; guardrail
|
|
149
|
+
* judges route under it too.
|
|
150
|
+
*/
|
|
151
|
+
tenantPolicy?: TenantPolicy;
|
|
152
|
+
/**
|
|
153
|
+
* How this turn retries failed tool calls: the agent's `toolErrors`
|
|
154
|
+
* (or the default) capped by the tenant's `tool-errors` policy.
|
|
155
|
+
* Populated by `setup`.
|
|
156
|
+
*/
|
|
157
|
+
toolErrorPolicy?: ToolErrorPolicy;
|
|
158
|
+
/**
|
|
159
|
+
* The turn's approval (HITL) rules: the agent's, held to the tenant's
|
|
160
|
+
* `hitl` policy. Populated at the start of the turn (`setup`, or the
|
|
161
|
+
* rebuild of a resumed turn) by `resolveTurnHitlPolicy`.
|
|
162
|
+
*/
|
|
163
|
+
hitlPolicy?: EffectiveHitlPolicy;
|
|
164
|
+
/**
|
|
165
|
+
* Set when the turn resumes after a park in `dispatch-tools` (a
|
|
166
|
+
* tool-call approval): the messages that step stored before it parked.
|
|
167
|
+
* The step runs again, and takes its assistant message and the results
|
|
168
|
+
* of calls that already ran from here instead of storing (and running)
|
|
169
|
+
* them again. Populated by `rehydrateTurnContext`.
|
|
170
|
+
*/
|
|
171
|
+
storedBeforePark?: ConversationMessage[];
|
|
172
|
+
/**
|
|
173
|
+
* Warnings + other (non-halt) guardrail violations from the
|
|
174
|
+
* final-response gate. Read by `compose-result` to populate
|
|
175
|
+
* `AgentTurnResult.violations`.
|
|
176
|
+
*/
|
|
177
|
+
nonBlockingViolations?: readonly EvaluationResult[];
|
|
178
|
+
/**
|
|
179
|
+
* Reason recorded when `turnAbort` fires. Used to distinguish
|
|
180
|
+
* external cancellation from wall-clock timeout in the projected
|
|
181
|
+
* error.
|
|
182
|
+
*/
|
|
183
|
+
abortReason: 'external' | 'timeout' | undefined;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Iteration output shape produced by the loop body's `budget-check`
|
|
188
|
+
* node (and by extension, the loop's `$loop-end` output). Mirrors the
|
|
189
|
+
* `iterationOutputSchema` declared in `agent-turn-flow.ts`.
|
|
190
|
+
*/
|
|
191
|
+
export interface AgentTurnIterationOutput {
|
|
192
|
+
readonly finishReason: 'stop' | 'length' | 'tool-use' | 'content-filter' | 'error';
|
|
193
|
+
readonly message: ModelMessage;
|
|
194
|
+
readonly iterationAppended: readonly ConversationMessage[];
|
|
195
|
+
readonly iterationUsage: {
|
|
196
|
+
readonly promptTokens: number;
|
|
197
|
+
readonly completionTokens: number;
|
|
198
|
+
readonly costUsd: number;
|
|
199
|
+
};
|
|
200
|
+
readonly provider: { readonly id: string; readonly model: string };
|
|
201
|
+
readonly finishedTurn: boolean;
|
|
202
|
+
readonly nextMessages: readonly ModelMessage[];
|
|
203
|
+
/**
|
|
204
|
+
* Set by `dispatch-tools` when a tool invocation surfaces an
|
|
205
|
+
* `unresolved-tool` / `tool-invocation-failed`, or by
|
|
206
|
+
* `budget-check` when the cost cap is exceeded. `compose-result`
|
|
207
|
+
* inspects it and short-circuits the run into an error result.
|
|
208
|
+
*/
|
|
209
|
+
readonly errorPayload?: {
|
|
210
|
+
readonly code:
|
|
211
|
+
| 'unresolved-tool'
|
|
212
|
+
| 'tool-invocation-failed'
|
|
213
|
+
| 'budget-exceeded'
|
|
214
|
+
| 'agent-turn-aborted'
|
|
215
|
+
| 'model-invocation-failed';
|
|
216
|
+
readonly message: string;
|
|
217
|
+
readonly extra?: Readonly<Record<string, unknown>>;
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Public re-export helper for callers building test doubles. Kept in
|
|
223
|
+
* this module to avoid making `context.ts` a circular hub — everything
|
|
224
|
+
* a handler needs is imported through here.
|
|
225
|
+
*/
|
|
226
|
+
export type { Agent, HitlBindings, InvokeAgentBindings, InvokeAgentInput, TenantPolicy };
|