zidane 5.6.15 → 5.7.4
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/README.md +3 -1
- package/dist/{agent-CkJp_ZOR.d.ts → agent-BNS2nx_T.d.ts} +535 -15
- package/dist/agent-BNS2nx_T.d.ts.map +1 -0
- package/dist/chat/pure.d.ts +4 -0
- package/dist/chat/pure.js +3 -0
- package/dist/chat.d.ts +31 -661
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +5 -3
- package/dist/chat.js.map +1 -1
- package/dist/contexts/docker.d.ts +1 -1
- package/dist/contexts/docker.d.ts.map +1 -1
- package/dist/contexts/docker.js.map +1 -1
- package/dist/{contexts-BOtMvzli.js → contexts-BD2U_xpi.js} +2 -2
- package/dist/{contexts-BOtMvzli.js.map → contexts-BD2U_xpi.js.map} +1 -1
- package/dist/contexts.d.ts +3 -3
- package/dist/contexts.js +1 -1
- package/dist/edit-utils-DnfNoj16.js +574 -0
- package/dist/edit-utils-DnfNoj16.js.map +1 -0
- package/dist/{errors-DdZXnyXE.js → errors-CoQnKRf1.js} +32 -2
- package/dist/{errors-DdZXnyXE.js.map → errors-CoQnKRf1.js.map} +1 -1
- package/dist/fetch-url-CPxfiXDa.js +518 -0
- package/dist/fetch-url-CPxfiXDa.js.map +1 -0
- package/dist/{image-sniff-CmlNMPMr.js → image-sniff-B7uFSNO1.js} +1 -1
- package/dist/{image-sniff-CmlNMPMr.js.map → image-sniff-B7uFSNO1.js.map} +1 -1
- package/dist/{index-CtIS28mN.d.ts → index-CZOwAJIX.d.ts} +2 -2
- package/dist/index-CZOwAJIX.d.ts.map +1 -0
- package/dist/{index-CsWckg9p.d.ts → index-Ck_AWt8P.d.ts} +3 -4
- package/dist/index-Ck_AWt8P.d.ts.map +1 -0
- package/dist/{index-BXQC3I4d.d.ts → index-KiS7w0dC.d.ts} +3 -3
- package/dist/index-KiS7w0dC.d.ts.map +1 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +13 -12
- package/dist/index.js.map +1 -1
- package/dist/{interpolate-C55ZIcKz.js → interpolate-TySiqKzc.js} +23 -23
- package/dist/{interpolate-C55ZIcKz.js.map → interpolate-TySiqKzc.js.map} +1 -1
- package/dist/{login-CY9uShjX.js → login-BDeqENSe.js} +7 -58
- package/dist/login-BDeqENSe.js.map +1 -0
- package/dist/{mcp-DDOc8hOM.js → mcp-Kqzz-Rs_.js} +5 -5
- package/dist/{mcp-DDOc8hOM.js.map → mcp-Kqzz-Rs_.js.map} +1 -1
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +1 -1
- package/dist/{messages-B-tuI2Ur.js → messages-CvRQTdbR.js} +93 -30
- package/dist/messages-CvRQTdbR.js.map +1 -0
- package/dist/{presets-CMkLtFFW.js → presets-JuOnSI-i.js} +2 -2
- package/dist/{presets-CMkLtFFW.js.map → presets-JuOnSI-i.js.map} +1 -1
- package/dist/presets.d.ts +3 -3
- package/dist/presets.js +1 -1
- package/dist/{providers-CRQQDuxx.js → providers-h4HJPbbv.js} +485 -31
- package/dist/providers-h4HJPbbv.js.map +1 -0
- package/dist/providers.d.ts +2 -2
- package/dist/providers.js +3 -3
- package/dist/restate.d.ts +1 -1
- package/dist/restate.d.ts.map +1 -1
- package/dist/restate.js.map +1 -1
- package/dist/session/sqlite.d.ts +1 -1
- package/dist/session/sqlite.d.ts.map +1 -1
- package/dist/session/sqlite.js +1 -1
- package/dist/session/sqlite.js.map +1 -1
- package/dist/{session-BCT6eYxo.js → session-BzLou2_-.js} +2 -2
- package/dist/{session-BCT6eYxo.js.map → session-BzLou2_-.js.map} +1 -1
- package/dist/session.d.ts +2 -2
- package/dist/session.js +2 -2
- package/dist/skills.d.ts +3 -3
- package/dist/skills.js +1 -1
- package/dist/skills.js.map +1 -1
- package/dist/{stats-CIv4j3Sz.js → stats-DAKBEKjc.js} +12 -2
- package/dist/stats-DAKBEKjc.js.map +1 -0
- package/dist/{stdio-loader-OOOXzUvm.js → stdio-loader-Ce68wUmM.js} +4 -4
- package/dist/stdio-loader-Ce68wUmM.js.map +1 -0
- package/dist/tool-formatters-CU-j3a3e.d.ts +1471 -0
- package/dist/tool-formatters-CU-j3a3e.d.ts.map +1 -0
- package/dist/tools/fetch-url.d.ts +70 -0
- package/dist/tools/fetch-url.d.ts.map +1 -0
- package/dist/tools/fetch-url.js +2 -0
- package/dist/tools/web-search.d.ts +7 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +190 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/{tools-0Kolu2bY.js → tools-BGtJK0vo.js} +1365 -420
- package/dist/tools-BGtJK0vo.js.map +1 -0
- package/dist/tools.d.ts +3 -3
- package/dist/tools.js +1 -1
- package/dist/{turn-operations-DkLoiyF4.js → transcript-anchors-BTSZAPVc.js} +147 -2713
- package/dist/transcript-anchors-BTSZAPVc.js.map +1 -0
- package/dist/{transcript-anchors-C8IqWH4x.d.ts → transcript-anchors-DX90kXc4.d.ts} +13 -1299
- package/dist/transcript-anchors-DX90kXc4.d.ts.map +1 -0
- package/dist/tui.d.ts +58 -28
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +1348 -422
- package/dist/tui.js.map +1 -1
- package/dist/turn-operations-CCHfR9eC.js +1938 -0
- package/dist/turn-operations-CCHfR9eC.js.map +1 -0
- package/dist/turn-operations-DDIl4YVk.d.ts +658 -0
- package/dist/turn-operations-DDIl4YVk.d.ts.map +1 -0
- package/dist/{types-oKPBdCmL.js → types-BPw_i5vb.js} +1 -1
- package/dist/types-BPw_i5vb.js.map +1 -0
- package/dist/{types-2PMY5Rlc.d.ts → types-CEAMIUXw.d.ts} +1 -1
- package/dist/types-CEAMIUXw.d.ts.map +1 -0
- package/dist/types.d.ts +4 -4
- package/dist/types.js +3 -3
- package/docs/CHAT.md +53 -6
- package/docs/SKILL.md +3 -0
- package/docs/TUI.md +7 -0
- package/package.json +18 -2
- package/dist/agent-CkJp_ZOR.d.ts.map +0 -1
- package/dist/index-BXQC3I4d.d.ts.map +0 -1
- package/dist/index-CsWckg9p.d.ts.map +0 -1
- package/dist/index-CtIS28mN.d.ts.map +0 -1
- package/dist/login-CY9uShjX.js.map +0 -1
- package/dist/messages-B-tuI2Ur.js.map +0 -1
- package/dist/providers-CRQQDuxx.js.map +0 -1
- package/dist/stats-CIv4j3Sz.js.map +0 -1
- package/dist/stdio-loader-OOOXzUvm.js.map +0 -1
- package/dist/tools-0Kolu2bY.js.map +0 -1
- package/dist/transcript-anchors-C8IqWH4x.d.ts.map +0 -1
- package/dist/turn-operations-DkLoiyF4.js.map +0 -1
- package/dist/types-2PMY5Rlc.d.ts.map +0 -1
- package/dist/types-oKPBdCmL.js.map +0 -1
|
@@ -1,9 +1,231 @@
|
|
|
1
|
-
import { a as ExecutionContext, o as ExecutionHandle } from "./types-
|
|
1
|
+
import { a as ExecutionContext, o as ExecutionHandle } from "./types-CEAMIUXw.js";
|
|
2
2
|
import { Hookable } from "hookable";
|
|
3
|
+
import { OAuthCredentials, getOAuthApiKey } from "@earendil-works/pi-ai/oauth";
|
|
3
4
|
import { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
4
5
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
5
6
|
import Anthropic from "@anthropic-ai/sdk";
|
|
6
7
|
|
|
8
|
+
//#region src/chat/context-breakdown.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Context-usage breakdown — pure transforms.
|
|
11
|
+
*
|
|
12
|
+
* Turns a {@link ContextSnapshot} (the raw pieces the agent assembled for a
|
|
13
|
+
* run: system prompt, wire tools, deferred tools, MCP tools/instructions,
|
|
14
|
+
* skills catalog, ...) plus the real last-turn token total into a categorized
|
|
15
|
+
* {@link ContextBreakdown} the TUI panel / GUI popover render.
|
|
16
|
+
*
|
|
17
|
+
* No React, no node — a browser-context renderer imports these via
|
|
18
|
+
* `zidane/chat/pure`. The snapshot is captured main-side (TUI direct, GUI in
|
|
19
|
+
* `main/chat`) because building it reads provider/agent state; only the pure
|
|
20
|
+
* shaping lives here.
|
|
21
|
+
*
|
|
22
|
+
* Accuracy: per-category counts are estimates when no provider `countTokens`
|
|
23
|
+
* is available — the heuristic ({@link estimateTokens}, ~4 bytes/token) sizes
|
|
24
|
+
* each static segment and the bar is reconciled so it always sums to the real
|
|
25
|
+
* last-turn total (`conversation = realTotal - sum(static)`). When a provider
|
|
26
|
+
* exposes exact counts (Anthropic, OpenAI), the caller passes them in via
|
|
27
|
+
* {@link ContextSnapshot.exact} and the corresponding categories drop their
|
|
28
|
+
* `estimated` flag. Exact buckets (free space, autocompact buffer) are never
|
|
29
|
+
* estimated.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Stable identifiers for each breakdown category. Drives swatch color +
|
|
33
|
+
* ordering in both UIs. `*Deferred` buckets are tools/MCP that exist but are
|
|
34
|
+
* NOT currently on the wire (lazy disclosure); `autocompactBuffer` is the
|
|
35
|
+
* reserved output headroom; `freeSpace` is the remaining window.
|
|
36
|
+
*/
|
|
37
|
+
type ContextCategoryId = 'systemPrompt' | 'rules' | 'tools' | 'mcpTools' | 'mcpInstructions' | 'skills' | 'subagentDefs' | 'conversation' | 'mcpToolsDeferred' | 'toolsDeferred' | 'autocompactBuffer' | 'freeSpace';
|
|
38
|
+
/**
|
|
39
|
+
* Exact last-turn token usage split (provider-reported — always exact). Drives
|
|
40
|
+
* the cache breakdown shown below the categories. `cacheRead + cacheCreation +
|
|
41
|
+
* input` equals the live context total (`used`).
|
|
42
|
+
*/
|
|
43
|
+
interface ContextUsageSplit {
|
|
44
|
+
/** Fresh, uncached input tokens this turn. */
|
|
45
|
+
input: number;
|
|
46
|
+
/** Tokens served from the prompt cache (the cached prefix). */
|
|
47
|
+
cacheRead: number;
|
|
48
|
+
/** Tokens written to the cache this turn. */
|
|
49
|
+
cacheCreation: number;
|
|
50
|
+
/** Assistant output tokens (not part of the input window; informational). */
|
|
51
|
+
output: number;
|
|
52
|
+
}
|
|
53
|
+
/** One expandable child row under a category (e.g. a single MCP tool / memory file). */
|
|
54
|
+
interface ContextItem {
|
|
55
|
+
/** Stable-ish key for rendering (tool name, file path). */
|
|
56
|
+
id: string;
|
|
57
|
+
/** Display label. */
|
|
58
|
+
label: string;
|
|
59
|
+
/** Token count for this item. */
|
|
60
|
+
tokens: number;
|
|
61
|
+
/** True when `tokens` came from the heuristic rather than an exact count. */
|
|
62
|
+
estimated: boolean;
|
|
63
|
+
}
|
|
64
|
+
/** One category row in the breakdown. */
|
|
65
|
+
interface ContextCategory {
|
|
66
|
+
id: ContextCategoryId;
|
|
67
|
+
/** Display label (e.g. "Tool definitions"). */
|
|
68
|
+
label: string;
|
|
69
|
+
/** Token count for the category. */
|
|
70
|
+
tokens: number;
|
|
71
|
+
/** True when `tokens` came from the heuristic rather than an exact count. */
|
|
72
|
+
estimated: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* True for buckets that are NOT counted against the live window total
|
|
75
|
+
* (deferred tools, free space, autocompact buffer) — the UI renders these
|
|
76
|
+
* dimmed / below a divider, mirroring Claude Code's layout.
|
|
77
|
+
*/
|
|
78
|
+
deferred?: boolean;
|
|
79
|
+
/** Optional expandable child rows (per MCP tool, per memory file, ...). */
|
|
80
|
+
items?: ContextItem[];
|
|
81
|
+
}
|
|
82
|
+
/** The shaped, render-ready breakdown. */
|
|
83
|
+
interface ContextBreakdown {
|
|
84
|
+
/** Model id the snapshot was built for. */
|
|
85
|
+
modelId: string;
|
|
86
|
+
/**
|
|
87
|
+
* Real last-turn context size (provider-reported `input + cacheRead +
|
|
88
|
+
* cacheCreation`) — the SAME number the footer/orb shows. The non-deferred
|
|
89
|
+
* categories always sum to this.
|
|
90
|
+
*/
|
|
91
|
+
used: number;
|
|
92
|
+
/** Effective window (raw - output reserve), the bar's denominator. */
|
|
93
|
+
effectiveWindow: number;
|
|
94
|
+
/** `used / effectiveWindow`, clamped to [0, 1]. */
|
|
95
|
+
fraction: number;
|
|
96
|
+
/** Live categories (sum to `used`) followed by deferred + free-space buckets. */
|
|
97
|
+
categories: ContextCategory[];
|
|
98
|
+
/** True when ANY live category is estimated (drives the panel's footnote). */
|
|
99
|
+
hasEstimates: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Exact last-turn usage split (cache read / write / fresh input / output),
|
|
102
|
+
* when the host supplied it. Always exact — rendered as an informational
|
|
103
|
+
* section below the categories. Absent when no usage is available yet.
|
|
104
|
+
*/
|
|
105
|
+
usage?: ContextUsageSplit;
|
|
106
|
+
/**
|
|
107
|
+
* Names of currently-active skills. Informational — an activated skill's body
|
|
108
|
+
* lands in the conversation (tool-results), so its tokens are already counted
|
|
109
|
+
* under Conversation; this just surfaces "which skills are loaded". Empty/absent
|
|
110
|
+
* when none are active.
|
|
111
|
+
*/
|
|
112
|
+
activeSkills?: string[];
|
|
113
|
+
}
|
|
114
|
+
/** Host-supplied options for `agent.getContextBreakdown`. */
|
|
115
|
+
interface ContextBreakdownOptions {
|
|
116
|
+
/**
|
|
117
|
+
* Effective context window (`rawWindow - outputReserve`) for the active
|
|
118
|
+
* model, resolved by the host via the chat model registry. Drives free-space
|
|
119
|
+
* + fraction. When omitted, defaults to `used` (no headroom shown).
|
|
120
|
+
*/
|
|
121
|
+
effectiveWindow?: number;
|
|
122
|
+
/**
|
|
123
|
+
* Active model id — used for the exact `countTokens` call + the header label.
|
|
124
|
+
* Only consulted on the PRE-RUN path (no snapshot yet); once a run has fired,
|
|
125
|
+
* the snapshot's own model wins. When omitted, the provider default is used.
|
|
126
|
+
*/
|
|
127
|
+
model?: string;
|
|
128
|
+
/** Tokens reserved for output (autocompact buffer). Defaults to 0. */
|
|
129
|
+
autocompactBuffer?: number;
|
|
130
|
+
/**
|
|
131
|
+
* Auto-compact threshold as a fraction of the window (0–1), when enabled.
|
|
132
|
+
* When set, the "Autocompact buffer" bucket represents the ENTIRE tail from
|
|
133
|
+
* the threshold to the end of the window (`(1 − threshold) × window`) rather
|
|
134
|
+
* than just the reserved-output tokens — so the bar/row show exactly where
|
|
135
|
+
* compaction fires. When omitted, `autocompactBuffer` is used as-is.
|
|
136
|
+
*/
|
|
137
|
+
compactThreshold?: number;
|
|
138
|
+
/** Abort signal forwarded to the provider's `countTokens`. */
|
|
139
|
+
signal?: AbortSignal;
|
|
140
|
+
}
|
|
141
|
+
/** Tools grouped by MCP server, for the expandable per-server rows. */
|
|
142
|
+
interface ContextMcpGroup {
|
|
143
|
+
server: string;
|
|
144
|
+
/** Wire tool specs for this server (their JSON size is measured). */
|
|
145
|
+
tools: {
|
|
146
|
+
name: string;
|
|
147
|
+
json: string;
|
|
148
|
+
}[];
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Exact per-segment counts from a provider's `countTokens`, when available.
|
|
152
|
+
* Each field is the count of the cumulative payload up to and including that
|
|
153
|
+
* segment, so categories are derived by differencing (see
|
|
154
|
+
* {@link buildContextBreakdown}). Any subset may be present; missing fields
|
|
155
|
+
* fall back to the heuristic for that category.
|
|
156
|
+
*/
|
|
157
|
+
interface ContextExactCounts {
|
|
158
|
+
/** Tokens for system prompt alone. */
|
|
159
|
+
system?: number;
|
|
160
|
+
/** Tokens for system + tools (so tools = systemAndTools - system). */
|
|
161
|
+
systemAndTools?: number;
|
|
162
|
+
/** Tokens for the full payload (system + tools + messages) = the real total. */
|
|
163
|
+
full?: number;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Raw inputs captured at agent prompt-assembly time. Everything here is what
|
|
167
|
+
* actually went on (or was withheld from) the wire for the last run.
|
|
168
|
+
*/
|
|
169
|
+
interface ContextSnapshot {
|
|
170
|
+
modelId: string;
|
|
171
|
+
/** Full rendered system prompt (marker-stripped, as sent). */
|
|
172
|
+
system: string;
|
|
173
|
+
/**
|
|
174
|
+
* Host-composed base system BEFORE the agent appended skills / searchable /
|
|
175
|
+
* MCP-instructions catalogs. Includes the rules block. The "System prompt"
|
|
176
|
+
* (base doctrine) bucket = base − rules − env-noise. Defaults to `system`
|
|
177
|
+
* when not provided (back-compat).
|
|
178
|
+
*/
|
|
179
|
+
baseSystem?: string;
|
|
180
|
+
/** Rendered AGENTS.md/CLAUDE.md rules block (a substring of `baseSystem`). */
|
|
181
|
+
rulesBlock?: string;
|
|
182
|
+
/** Source files behind the rules block, for per-file rows. */
|
|
183
|
+
rulesFiles?: {
|
|
184
|
+
path: string;
|
|
185
|
+
source: string;
|
|
186
|
+
}[];
|
|
187
|
+
/** Wire tool specs currently disclosed to the model, as JSON strings. */
|
|
188
|
+
toolsJson: string[];
|
|
189
|
+
/** Lazy tool entries NOT currently disclosed (deferred), as JSON strings. */
|
|
190
|
+
deferredToolsJson: string[];
|
|
191
|
+
/** MCP tools grouped by server (disclosed ones). */
|
|
192
|
+
mcpGroups: ContextMcpGroup[];
|
|
193
|
+
/** Deferred (undisclosed) MCP tools grouped by server. */
|
|
194
|
+
deferredMcpGroups: ContextMcpGroup[];
|
|
195
|
+
/** Rendered MCP instructions block, if any. */
|
|
196
|
+
mcpInstructions?: string;
|
|
197
|
+
/** Rendered skills catalog text, if any. */
|
|
198
|
+
skillsCatalog?: string;
|
|
199
|
+
/** Searchable / subagent (spawn) tool definitions text, if any. */
|
|
200
|
+
subagentDefs?: string;
|
|
201
|
+
/** Memory / rules files in context. */
|
|
202
|
+
/** Real last-turn total (input + cacheRead + cacheCreation). */
|
|
203
|
+
used: number;
|
|
204
|
+
/** Effective window (raw - output reserve). */
|
|
205
|
+
effectiveWindow: number;
|
|
206
|
+
/** Tokens reserved for output (autocompact buffer). */
|
|
207
|
+
autocompactBuffer: number;
|
|
208
|
+
/** Exact per-segment counts from the provider, when available. */
|
|
209
|
+
exact?: ContextExactCounts;
|
|
210
|
+
/** Exact last-turn usage split, when available (passed straight through). */
|
|
211
|
+
usage?: ContextUsageSplit;
|
|
212
|
+
/** Names of currently-active skills (passed straight through). */
|
|
213
|
+
activeSkills?: string[];
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Shape a {@link ContextSnapshot} into a render-ready {@link ContextBreakdown}.
|
|
217
|
+
*
|
|
218
|
+
* Live categories (system prompt, tools, MCP tools/instructions, skills,
|
|
219
|
+
* memory, subagent defs, conversation) sum to `snapshot.used` — `conversation`
|
|
220
|
+
* absorbs the remainder so the bar matches the provider-reported total exactly.
|
|
221
|
+
* Deferred + autocompact + free-space buckets follow.
|
|
222
|
+
*
|
|
223
|
+
* When `snapshot.exact` carries provider counts, the matching categories use
|
|
224
|
+
* them (system, tools) and drop their `estimated` flag; everything else stays
|
|
225
|
+
* on the heuristic.
|
|
226
|
+
*/
|
|
227
|
+
declare function buildContextBreakdown(snapshot: ContextSnapshot): ContextBreakdown;
|
|
228
|
+
//#endregion
|
|
7
229
|
//#region src/errors.d.ts
|
|
8
230
|
/**
|
|
9
231
|
* Typed error classes for agent runs.
|
|
@@ -629,6 +851,12 @@ interface AgentBehavior {
|
|
|
629
851
|
maxTokens?: number;
|
|
630
852
|
/** Thinking token budget — overrides the level-based default when set */
|
|
631
853
|
thinkingBudget?: number;
|
|
854
|
+
/**
|
|
855
|
+
* Default model-specific options applied to every run, keyed by option id
|
|
856
|
+
* (e.g. `{ fast: true }`). A per-run {@link AgentRunOptions.modelOptions}
|
|
857
|
+
* takes precedence when set. See `StreamOptions.modelOptions`.
|
|
858
|
+
*/
|
|
859
|
+
modelOptions?: Record<string, boolean>;
|
|
632
860
|
/** JSON Schema for structured output enforcement */
|
|
633
861
|
schema?: Record<string, unknown>;
|
|
634
862
|
/**
|
|
@@ -1146,6 +1374,40 @@ interface AgentBehavior {
|
|
|
1146
1374
|
* Default: `false`.
|
|
1147
1375
|
*/
|
|
1148
1376
|
strictToolPairing?: boolean;
|
|
1377
|
+
/**
|
|
1378
|
+
* Egress allowlist for the web tools (`fetch_url`, `web_search`). When set
|
|
1379
|
+
* to a non-empty list, those tools refuse any request whose target host
|
|
1380
|
+
* isn't covered — on `fetch_url` this is checked for the initial URL AND
|
|
1381
|
+
* every redirect hop (alongside the SSRF blocklist); on `web_search` it
|
|
1382
|
+
* gates the keyless DuckDuckGo / Tavily / Brave backends so a sandboxed or
|
|
1383
|
+
* compliance-bound host can pin egress to approved domains.
|
|
1384
|
+
*
|
|
1385
|
+
* Matching is host-suffix based and case-insensitive: an entry `example.com`
|
|
1386
|
+
* matches `example.com` and any subdomain (`docs.example.com`), but not
|
|
1387
|
+
* `notexample.com`. Ports are ignored (match on hostname only). Leading
|
|
1388
|
+
* dots are tolerated (`.example.com` ≡ `example.com`).
|
|
1389
|
+
*
|
|
1390
|
+
* Default: `undefined` (no allowlist — every public host is reachable,
|
|
1391
|
+
* subject to the SSRF blocklist). An empty array is treated the same as
|
|
1392
|
+
* `undefined` so a host can't accidentally lock itself out with `[]`.
|
|
1393
|
+
*/
|
|
1394
|
+
fetchUrlAllowHosts?: readonly string[];
|
|
1395
|
+
/**
|
|
1396
|
+
* Enable an in-process response cache for the `fetch_url` tool, with this
|
|
1397
|
+
* TTL in milliseconds. Keyed on the requested URL string. When a fan-out
|
|
1398
|
+
* re-fetches the same page within the window (e.g. spidering a docs site
|
|
1399
|
+
* across parallel tool calls), the cached body is returned without a second
|
|
1400
|
+
* network round-trip.
|
|
1401
|
+
*
|
|
1402
|
+
* The cache is bounded by entry count and total bytes (fixed internal caps)
|
|
1403
|
+
* and is **process-local** — it never persists across restarts and is not
|
|
1404
|
+
* shared between agents. Only successful `2xx` text responses are cached;
|
|
1405
|
+
* redirects, errors, and aborts are not.
|
|
1406
|
+
*
|
|
1407
|
+
* Default: `undefined` / `0` → caching disabled (every call is a fresh
|
|
1408
|
+
* fetch — the stateless default). Set e.g. `900_000` (15 min) to enable.
|
|
1409
|
+
*/
|
|
1410
|
+
fetchUrlCacheTtlMs?: number;
|
|
1149
1411
|
}
|
|
1150
1412
|
/**
|
|
1151
1413
|
* One block of a multimodal user prompt.
|
|
@@ -1289,6 +1551,32 @@ type SessionContentBlock = {
|
|
|
1289
1551
|
* embedded signatures, so the sender drops the block on mismatch.
|
|
1290
1552
|
*/
|
|
1291
1553
|
model?: string;
|
|
1554
|
+
} | {
|
|
1555
|
+
/**
|
|
1556
|
+
* Anthropic server-side tool invocation block (currently `web_search`).
|
|
1557
|
+
* Captured opaquely so the model's reasoning chain stays intact across
|
|
1558
|
+
* turns — Anthropic's docs require `encrypted_content` and
|
|
1559
|
+
* `encrypted_index` to be passed back on follow-up turns or citation
|
|
1560
|
+
* context is lost. Dropped on cross-provider sends.
|
|
1561
|
+
*/
|
|
1562
|
+
type: 'server_tool_use';
|
|
1563
|
+
producer: 'anthropic';
|
|
1564
|
+
id: string;
|
|
1565
|
+
name: string;
|
|
1566
|
+
input: Record<string, unknown>;
|
|
1567
|
+
} | {
|
|
1568
|
+
/**
|
|
1569
|
+
* Anthropic server-side tool result block. Pairs with `server_tool_use`
|
|
1570
|
+
* and carries the search hits Anthropic injected into the assistant
|
|
1571
|
+
* message. The full content array is preserved as `unknown[]` so
|
|
1572
|
+
* `encrypted_content` / `encrypted_index` survive a session round-trip
|
|
1573
|
+
* verbatim.
|
|
1574
|
+
*/
|
|
1575
|
+
type: 'server_tool_result';
|
|
1576
|
+
producer: 'anthropic';
|
|
1577
|
+
toolUseId: string;
|
|
1578
|
+
toolName: string;
|
|
1579
|
+
content: unknown;
|
|
1292
1580
|
} | {
|
|
1293
1581
|
/**
|
|
1294
1582
|
* Compaction marker. Inserted by `compactConversation()` to replace a
|
|
@@ -1344,7 +1632,28 @@ interface AgentRunOptions {
|
|
|
1344
1632
|
*/
|
|
1345
1633
|
prompt?: string | PromptPart[];
|
|
1346
1634
|
system?: string;
|
|
1635
|
+
/**
|
|
1636
|
+
* Optional metadata describing which named sections the host baked into
|
|
1637
|
+
* `system` (e.g. the rendered AGENTS.md/CLAUDE.md "Rules" block). Purely
|
|
1638
|
+
* informational — used by `agent.getContextBreakdown()` to attribute system-
|
|
1639
|
+
* prompt tokens to a "Rules" bucket the agent can't otherwise isolate from
|
|
1640
|
+
* the opaque base string. Does not affect what's sent to the model.
|
|
1641
|
+
*/
|
|
1642
|
+
contextSections?: {
|
|
1643
|
+
/** Rendered user-instructions / rules block text (a substring of `system`). */rulesBlock?: string; /** Source files behind the rules block, for per-file breakdown rows. */
|
|
1644
|
+
rulesFiles?: {
|
|
1645
|
+
path: string;
|
|
1646
|
+
source: string;
|
|
1647
|
+
}[];
|
|
1648
|
+
};
|
|
1347
1649
|
thinking?: ThinkingLevel;
|
|
1650
|
+
/**
|
|
1651
|
+
* Enabled model-specific options for this run, keyed by option id (e.g.
|
|
1652
|
+
* `{ fast: true }` for Anthropic's fast mode). Options the active model
|
|
1653
|
+
* doesn't declare are silently ignored by the provider. Overrides
|
|
1654
|
+
* {@link AgentBehavior.modelOptions} when both are set.
|
|
1655
|
+
*/
|
|
1656
|
+
modelOptions?: Record<string, boolean>;
|
|
1348
1657
|
/** Abort signal — when triggered, the agent stops after the current turn */
|
|
1349
1658
|
signal?: AbortSignal;
|
|
1350
1659
|
/** Behavior overrides for this run (overrides agent defaults) */
|
|
@@ -1663,6 +1972,14 @@ interface OAuthRefreshHookContext {
|
|
|
1663
1972
|
}
|
|
1664
1973
|
type SessionEndStatus = 'completed' | 'aborted' | 'error';
|
|
1665
1974
|
//#endregion
|
|
1975
|
+
//#region src/providers/oauth.d.ts
|
|
1976
|
+
interface OAuthParams {
|
|
1977
|
+
apiKey?: string;
|
|
1978
|
+
access?: string;
|
|
1979
|
+
refresh?: string;
|
|
1980
|
+
expires?: number;
|
|
1981
|
+
}
|
|
1982
|
+
//#endregion
|
|
1666
1983
|
//#region src/providers/anthropic.d.ts
|
|
1667
1984
|
/**
|
|
1668
1985
|
* Server-side context-management config — the body of `context_management` on
|
|
@@ -1676,11 +1993,7 @@ interface AnthropicContextManagement {
|
|
|
1676
1993
|
edits?: Array<Record<string, unknown>>;
|
|
1677
1994
|
[key: string]: unknown;
|
|
1678
1995
|
}
|
|
1679
|
-
interface AnthropicParams {
|
|
1680
|
-
apiKey?: string;
|
|
1681
|
-
access?: string;
|
|
1682
|
-
refresh?: string;
|
|
1683
|
-
expires?: number;
|
|
1996
|
+
interface AnthropicParams extends OAuthParams {
|
|
1684
1997
|
defaultModel?: string;
|
|
1685
1998
|
/**
|
|
1686
1999
|
* Optional override for the Anthropic SDK base URL. Honored end-to-end — headers and
|
|
@@ -1784,14 +2097,82 @@ interface CerebrasParams {
|
|
|
1784
2097
|
*/
|
|
1785
2098
|
declare function cerebras(params?: CerebrasParams): Provider;
|
|
1786
2099
|
//#endregion
|
|
1787
|
-
//#region src/providers/
|
|
1788
|
-
|
|
1789
|
-
|
|
2100
|
+
//#region src/providers/cursor.d.ts
|
|
2101
|
+
/**
|
|
2102
|
+
* Cursor provider (OAuth).
|
|
2103
|
+
*
|
|
2104
|
+
* Auth is fully wired: `bun run auth --cursor` (or the TUI wizard) logs in via
|
|
2105
|
+
* Cursor's poll-based PKCE flow and persists credentials; this provider resolves
|
|
2106
|
+
* + refreshes the OAuth token on every turn via {@link resolveOAuthApiKey}.
|
|
2107
|
+
*
|
|
2108
|
+
* Inference is **not** wired yet. Cursor does not expose an OpenAI-compatible
|
|
2109
|
+
* HTTP endpoint — it speaks a protobuf/Connect agent protocol over HTTP/2 to
|
|
2110
|
+
* `api2.cursor.sh`. Implementing `stream()` requires porting that transport
|
|
2111
|
+
* (generated protobuf schemas + an HTTP/2 streaming client) in-process, which
|
|
2112
|
+
* is intentionally left as a follow-up. Until then `stream()` resolves the
|
|
2113
|
+
* token (proving auth works) and then throws a clear, actionable error.
|
|
2114
|
+
*
|
|
2115
|
+
* The `openaiCompat` base supplies the message-format helpers (`formatTools`,
|
|
2116
|
+
* `userMessage`, `toolResultsMessage`, …) so the provider satisfies the full
|
|
2117
|
+
* `Provider` contract and slots into the registry; only `stream` is overridden.
|
|
2118
|
+
*/
|
|
2119
|
+
interface CursorParams {
|
|
2120
|
+
/** Bypass OAuth resolution with an explicit token (mainly for tests). */
|
|
1790
2121
|
apiKey?: string;
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
2122
|
+
defaultModel?: string;
|
|
2123
|
+
}
|
|
2124
|
+
declare function cursor(params?: CursorParams): Provider;
|
|
2125
|
+
//#endregion
|
|
2126
|
+
//#region src/providers/local.d.ts
|
|
2127
|
+
interface LocalParams {
|
|
2128
|
+
/**
|
|
2129
|
+
* Base URL of the local OpenAI-compatible server. `/chat/completions` is
|
|
2130
|
+
* appended. Examples:
|
|
2131
|
+
* - Ollama: `http://localhost:11434/v1`
|
|
2132
|
+
* - vLLM: `http://localhost:8000/v1`
|
|
2133
|
+
* - LM Studio: `http://localhost:1234/v1`
|
|
2134
|
+
* - Lemonade: `http://localhost:8000/api/v1`
|
|
2135
|
+
* - llama.cpp: `http://localhost:8080/v1`
|
|
2136
|
+
*
|
|
2137
|
+
* Resolution order: explicit `params.baseURL` > `LOCAL_LLM_BASE_URL` env >
|
|
2138
|
+
* throw.
|
|
2139
|
+
*/
|
|
2140
|
+
baseURL?: string;
|
|
2141
|
+
/**
|
|
2142
|
+
* Optional bearer key. Most local servers don't authenticate; some (vLLM
|
|
2143
|
+
* with `--api-key`, gateway proxies, llama.cpp with `--api-key`) do.
|
|
2144
|
+
* Falls back to `LOCAL_LLM_API_KEY`, then to a placeholder string accepted
|
|
2145
|
+
* by unauthenticated endpoints.
|
|
2146
|
+
*/
|
|
2147
|
+
apiKey?: string;
|
|
2148
|
+
/**
|
|
2149
|
+
* Default model id. Local runtimes have no fixed catalogue — whatever the
|
|
2150
|
+
* user has loaded (e.g. `llama3.1:8b`, `qwen2.5-coder`, a HF repo path).
|
|
2151
|
+
* Falls back to `LOCAL_LLM_DEFAULT_MODEL`.
|
|
2152
|
+
*/
|
|
2153
|
+
defaultModel?: string;
|
|
2154
|
+
/**
|
|
2155
|
+
* Provider capability flags. Defaults to text-only — typical OSS local
|
|
2156
|
+
* deployment. Override when pointing at a vision-capable runtime (e.g.
|
|
2157
|
+
* Ollama serving a multimodal model, vLLM with a VLM).
|
|
2158
|
+
*/
|
|
2159
|
+
capabilities?: ProviderCapabilities;
|
|
2160
|
+
}
|
|
2161
|
+
/**
|
|
2162
|
+
* Local OpenAI-compatible LLM provider.
|
|
2163
|
+
*
|
|
2164
|
+
* Thin wrapper around {@link openaiCompat} for self-hosted runtimes that
|
|
2165
|
+
* speak the standard `POST /chat/completions` + SSE dialect: Ollama, vLLM,
|
|
2166
|
+
* LM Studio, Lemonade, llama.cpp's server, text-generation-webui, etc.
|
|
2167
|
+
*
|
|
2168
|
+
* Caching and reasoning are left off — local runtimes typically strict-
|
|
2169
|
+
* validate the request schema and would 400 on the extra fields. Override
|
|
2170
|
+
* `capabilities` when pointing at a vision-capable deployment.
|
|
2171
|
+
*/
|
|
2172
|
+
declare function local(params?: LocalParams): Provider;
|
|
2173
|
+
//#endregion
|
|
2174
|
+
//#region src/providers/openai.d.ts
|
|
2175
|
+
interface OpenAIParams extends OAuthParams {
|
|
1795
2176
|
accountId?: string;
|
|
1796
2177
|
defaultModel?: string;
|
|
1797
2178
|
transport?: 'sse' | 'websocket' | 'auto';
|
|
@@ -2112,11 +2493,51 @@ interface ProviderCapabilities {
|
|
|
2112
2493
|
* URLs in user messages.
|
|
2113
2494
|
*/
|
|
2114
2495
|
imageInToolResult?: boolean;
|
|
2496
|
+
/**
|
|
2497
|
+
* Provider executes web search server-side as a "server tool" — the model
|
|
2498
|
+
* issues searches and receives results without a `tool_use` / `tool_result`
|
|
2499
|
+
* round-trip on our wire. When set, the provider's `formatTools` recognizes
|
|
2500
|
+
* a canonical tool named `web_search` and rewrites it to the provider's
|
|
2501
|
+
* native server-tool shape (e.g. Anthropic's `web_search_20250305`),
|
|
2502
|
+
* dropping the client-side `ToolDef` from the function-tools list so the
|
|
2503
|
+
* model uses the server-side path instead.
|
|
2504
|
+
*
|
|
2505
|
+
* The client-side `web_search` `ToolDef` remains the cross-provider
|
|
2506
|
+
* fallback for providers that don't set this flag.
|
|
2507
|
+
*/
|
|
2508
|
+
nativeWebSearch?: {
|
|
2509
|
+
/** Cap on server-side search invocations per turn. Provider-specific default when omitted. */maxUses?: number;
|
|
2510
|
+
};
|
|
2115
2511
|
}
|
|
2116
2512
|
interface StreamCallbacks {
|
|
2117
2513
|
onText: (delta: string) => void;
|
|
2118
2514
|
onThinking?: (delta: string) => void;
|
|
2119
2515
|
onOAuthRefresh?: (ctx: OAuthRefreshHookContext) => void | Promise<void>;
|
|
2516
|
+
/**
|
|
2517
|
+
* Fires mid-stream when a provider that executes tools server-side closes
|
|
2518
|
+
* a server-tool-invocation content block (currently: Anthropic's
|
|
2519
|
+
* `web_search_20250305`). Lets the loop surface the call into the
|
|
2520
|
+
* transcript at the moment the model issued it — without waiting for the
|
|
2521
|
+
* full assistant message to finalize. Shape is intentionally generic so
|
|
2522
|
+
* future server tools (web_fetch, code_execution) reuse the same wire.
|
|
2523
|
+
*/
|
|
2524
|
+
onServerToolUse?: (block: {
|
|
2525
|
+
id: string;
|
|
2526
|
+
name: string;
|
|
2527
|
+
input: Record<string, unknown>;
|
|
2528
|
+
}) => void;
|
|
2529
|
+
/**
|
|
2530
|
+
* Pairs with {@link onServerToolUse} — fires when the provider closes the
|
|
2531
|
+
* matching server-tool-result block (e.g. Anthropic's
|
|
2532
|
+
* `web_search_tool_result`). `content` is the raw block payload
|
|
2533
|
+
* (either an error object or an array of result entries); consumers
|
|
2534
|
+
* format it for display.
|
|
2535
|
+
*/
|
|
2536
|
+
onServerToolResult?: (block: {
|
|
2537
|
+
toolUseId: string;
|
|
2538
|
+
toolName: string;
|
|
2539
|
+
content: unknown;
|
|
2540
|
+
}) => void;
|
|
2120
2541
|
}
|
|
2121
2542
|
interface TurnResult {
|
|
2122
2543
|
/** Full assistant turn as a SessionMessage */
|
|
@@ -2129,6 +2550,19 @@ interface TurnResult {
|
|
|
2129
2550
|
done: boolean;
|
|
2130
2551
|
usage: TurnUsage;
|
|
2131
2552
|
}
|
|
2553
|
+
/**
|
|
2554
|
+
* Payload for {@link Provider.countTokens} — the input half of a request whose
|
|
2555
|
+
* token footprint we want measured WITHOUT running inference. Mirrors the
|
|
2556
|
+
* subset of {@link StreamOptions} that contributes to input tokens.
|
|
2557
|
+
*/
|
|
2558
|
+
interface TokenCountPayload {
|
|
2559
|
+
model: string;
|
|
2560
|
+
/** System prompt as passed to `stream` (provider re-renders for the wire). */
|
|
2561
|
+
system: string;
|
|
2562
|
+
/** Wire-formatted tool specs (already through `provider.formatTools`). */
|
|
2563
|
+
tools: unknown[];
|
|
2564
|
+
messages: SessionMessage[];
|
|
2565
|
+
}
|
|
2132
2566
|
interface StreamOptions {
|
|
2133
2567
|
model: string;
|
|
2134
2568
|
system: string;
|
|
@@ -2139,6 +2573,13 @@ interface StreamOptions {
|
|
|
2139
2573
|
thinking?: ThinkingLevel;
|
|
2140
2574
|
/** Exact thinking token budget — overrides the level-based default when set */
|
|
2141
2575
|
thinkingBudget?: number;
|
|
2576
|
+
/**
|
|
2577
|
+
* Enabled model-specific options (the `id`s of {@link ModelInfo.options} the
|
|
2578
|
+
* user toggled on), e.g. `{ fast: true }` for Anthropic's fast mode. Each
|
|
2579
|
+
* provider interprets the keys it recognizes and ignores the rest; an option
|
|
2580
|
+
* the active model doesn't declare is a silent no-op.
|
|
2581
|
+
*/
|
|
2582
|
+
modelOptions?: Record<string, boolean>;
|
|
2142
2583
|
/** Force tool selection behavior */
|
|
2143
2584
|
toolChoice?: {
|
|
2144
2585
|
type: 'auto' | 'required' | 'tool';
|
|
@@ -2188,6 +2629,18 @@ interface Provider {
|
|
|
2188
2629
|
* route it to one of the typed error classes.
|
|
2189
2630
|
*/
|
|
2190
2631
|
classifyError?: (err: unknown) => ClassifiedError | null;
|
|
2632
|
+
/**
|
|
2633
|
+
* Exact input-token count for a payload, WITHOUT running inference — backs
|
|
2634
|
+
* the context-usage breakdown's exact mode. Implemented by providers with a
|
|
2635
|
+
* free server-side count endpoint (Anthropic `messages.countTokens`, OpenAI
|
|
2636
|
+
* `responses.input_tokens.count`).
|
|
2637
|
+
*
|
|
2638
|
+
* Returns the token count, or `null` when counting is unavailable/unreachable
|
|
2639
|
+
* under the active auth (e.g. an OAuth backend that doesn't expose the
|
|
2640
|
+
* endpoint) — callers fall back to the heuristic in that case. Absent on
|
|
2641
|
+
* providers with no count endpoint (Cerebras, OpenRouter).
|
|
2642
|
+
*/
|
|
2643
|
+
countTokens?: (payload: TokenCountPayload, signal?: AbortSignal) => Promise<number | null>;
|
|
2191
2644
|
}
|
|
2192
2645
|
//#endregion
|
|
2193
2646
|
//#region src/session/messages.d.ts
|
|
@@ -3393,6 +3846,37 @@ interface AgentHooks {
|
|
|
3393
3846
|
delta: string;
|
|
3394
3847
|
thinking: string;
|
|
3395
3848
|
}) => void;
|
|
3849
|
+
/**
|
|
3850
|
+
* Fires mid-stream when a provider that executes a tool server-side
|
|
3851
|
+
* (currently: Anthropic's `web_search_20250305`) closes the
|
|
3852
|
+
* server-tool-invocation content block. Symmetric with `tool:before` for
|
|
3853
|
+
* function tools — surface the call into the transcript at the moment the
|
|
3854
|
+
* model issued it, without waiting for the assistant message to finalize.
|
|
3855
|
+
*
|
|
3856
|
+
* Shape is intentionally generic so future server tools reuse the same
|
|
3857
|
+
* hook. `id` is the block's tool-use id (echoed back to the provider on
|
|
3858
|
+
* follow-up turns); pair with `stream:server_tool_result` via that id.
|
|
3859
|
+
*
|
|
3860
|
+
* Observational — handlers cannot block or substitute, since the call
|
|
3861
|
+
* has already executed server-side by the time we see it.
|
|
3862
|
+
*/
|
|
3863
|
+
'stream:server_tool_use': (ctx: StreamHookContext & {
|
|
3864
|
+
id: string;
|
|
3865
|
+
name: string;
|
|
3866
|
+
input: Record<string, unknown>;
|
|
3867
|
+
}) => void;
|
|
3868
|
+
/**
|
|
3869
|
+
* Pairs with {@link AgentHooks['stream:server_tool_use']} — fires when the
|
|
3870
|
+
* provider closes the matching server-tool-result block. `content` is the
|
|
3871
|
+
* raw block payload (either an error object or an array of result entries
|
|
3872
|
+
* carrying `encrypted_content` / `encrypted_index`); consumers format it
|
|
3873
|
+
* for display.
|
|
3874
|
+
*/
|
|
3875
|
+
'stream:server_tool_result': (ctx: StreamHookContext & {
|
|
3876
|
+
toolUseId: string;
|
|
3877
|
+
toolName: string;
|
|
3878
|
+
content: unknown;
|
|
3879
|
+
}) => void;
|
|
3396
3880
|
/**
|
|
3397
3881
|
* Fires when the provider's stream rejects BEFORE `stream:end` — provider
|
|
3398
3882
|
* errors, network blips, malformed `tools` payloads (400 invalid_request_error).
|
|
@@ -3725,6 +4209,22 @@ interface AgentHooks {
|
|
|
3725
4209
|
childId: string;
|
|
3726
4210
|
depth: number;
|
|
3727
4211
|
}) => void;
|
|
4212
|
+
/** Bubbled `stream:server_tool_use` from a subagent. See {@link AgentHooks['stream:server_tool_use']}. */
|
|
4213
|
+
'child:stream:server_tool_use': (ctx: StreamHookContext & {
|
|
4214
|
+
id: string;
|
|
4215
|
+
name: string;
|
|
4216
|
+
input: Record<string, unknown>;
|
|
4217
|
+
childId: string;
|
|
4218
|
+
depth: number;
|
|
4219
|
+
}) => void;
|
|
4220
|
+
/** Bubbled `stream:server_tool_result` from a subagent. See {@link AgentHooks['stream:server_tool_result']}. */
|
|
4221
|
+
'child:stream:server_tool_result': (ctx: StreamHookContext & {
|
|
4222
|
+
toolUseId: string;
|
|
4223
|
+
toolName: string;
|
|
4224
|
+
content: unknown;
|
|
4225
|
+
childId: string;
|
|
4226
|
+
depth: number;
|
|
4227
|
+
}) => void;
|
|
3728
4228
|
/** Bubbled `stream:error` from a subagent's turn. See {@link AgentHooks['stream:error']}. */
|
|
3729
4229
|
'child:stream:error': (ctx: StreamHookContext & {
|
|
3730
4230
|
err: unknown;
|
|
@@ -4440,6 +4940,26 @@ interface Agent {
|
|
|
4440
4940
|
* model / capability defaults, construct a new provider.
|
|
4441
4941
|
*/
|
|
4442
4942
|
readonly meta: Readonly<Record<string, unknown>>;
|
|
4943
|
+
/**
|
|
4944
|
+
* Categorized context-window usage — system prompt, rules, skills, MCP
|
|
4945
|
+
* tools/instructions, subagent defs, tool definitions, conversation, deferred
|
|
4946
|
+
* buckets, autocompact buffer, and free space. Computed on demand (the host
|
|
4947
|
+
* opens a panel / popover). Available even before the first run: when no run
|
|
4948
|
+
* snapshot exists yet it assembles a skills-only pre-run view (no MCP connect),
|
|
4949
|
+
* so it never returns `null` for a live agent — only after `destroy()`.
|
|
4950
|
+
*
|
|
4951
|
+
* Per-category counts are heuristic estimates reconciled so the live
|
|
4952
|
+
* categories sum to the real last-turn total; when the provider exposes
|
|
4953
|
+
* {@link Provider.countTokens} (Anthropic, OpenAI), the system/tools buckets
|
|
4954
|
+
* use exact counts and drop their `estimated` flag. One network round-trip
|
|
4955
|
+
* on the exact path; the host decides when to call it.
|
|
4956
|
+
*
|
|
4957
|
+
* The host supplies `effectiveWindow` (the model's `rawWindow -
|
|
4958
|
+
* outputReserve`, resolved via the chat model registry which the agent core
|
|
4959
|
+
* deliberately doesn't depend on). When omitted, free-space / fraction are
|
|
4960
|
+
* computed against `used` only (bar still renders, just without headroom).
|
|
4961
|
+
*/
|
|
4962
|
+
getContextBreakdown: (opts?: ContextBreakdownOptions) => Promise<ContextBreakdown | null>;
|
|
4443
4963
|
/**
|
|
4444
4964
|
* TC39 explicit-resource-management `await using` sink — alias for
|
|
4445
4965
|
* {@link Agent.destroy}. Lets hosts write:
|
|
@@ -4474,5 +4994,5 @@ declare function createAgent({
|
|
|
4474
4994
|
clock: agentClock
|
|
4475
4995
|
}: AgentOptions): Agent;
|
|
4476
4996
|
//#endregion
|
|
4477
|
-
export { autoDetectAndConvert as $,
|
|
4478
|
-
//# sourceMappingURL=agent-
|
|
4997
|
+
export { autoDetectAndConvert as $, McpToolSchema as $t, SkillSource as A, ClassifiedError as An, openaiCompat as At, createRemoteStore as B, ContextItem as Bn, anthropic as Bt, getReadState as C, AgentAbortedError as Cn, OpenRouterParams as Ct, SkillConfig as D, AgentToolNotAllowedError as Dn, OpenAICompatParams as Dt, resolveReadStateMap as E, AgentProviderError as En, OpenAICompatHttpError as Et, SessionRun as F, ContextBreakdown as Fn, CursorParams as Ft, EnsureToolResultPairingOptions as G, AgentStats as Gt, FileMapAdapter as H, ContextSnapshot as Hn, AgentBehavior as Ht, SessionStore as I, ContextBreakdownOptions as In, cursor as It, PairingRepairMode as J, DEFAULT_AGENT_CLOCK as Jt, ORPHANED_TOOL_RESULT_MARKER as K, ChildRunStats as Kt, createSession as L, ContextCategory as Ln, CerebrasParams as Lt, CreateSessionOptions as M, errorMessage as Mn, openai as Mt, Session as N, matchesContextExceeded as Nn, LocalParams as Nt, SkillDiagnostic as O, AgentToolPairingError as On, classifyOpenAICompatError as Ot, SessionData as P, toTypedError as Pn, local as Pt, TurnInterruptionState as Q, McpToolHookContext as Qt, loadSession as R, ContextCategoryId as Rn, cerebras as Rt, ReadStateMap as S, toolResultToText as Sn, sanitizeToolSpecs as St, readStateKey as T, AgentContextExceededError as Tn, OpenAICompatAuthHeader as Tt, FileMapStoreOptions as U, ContextUsageSplit as Un, AgentClock as Ut, createMemoryStore as V, ContextMcpGroup as Vn, applyAnthropicCacheBreakpoints as Vt, createFileMapStore as W, buildContextBreakdown as Wn, AgentRunOptions as Wt, TOOL_USE_INTERRUPTED_MARKER as X, DedupToolConfig as Xt, SYNTHETIC_TOOL_RESULT_PLACEHOLDER as Y, DedupHasher as Yt, ToWireMessagesOptions as Z, McpServerConfig as Zt, resultToString as _, ToolResultImageContent as _n, TurnResult as _t, createAgent as a, RetryConfig as an, fromOpenAI as at, ToolMap as b, TurnUsage as bn, SchemaSanitizeResult as bt, DeactivationReason as c, SessionEndStatus as cn, toWireMessages as ct, createSkillActivationState as d, SessionTurn as dn, StreamCallbacks as dt, OAuthRefreshHookContext as en, detectTurnInterruption as et, ConnectMcpServersOptions as f, SpawnHookContext as fn, StreamOptions as ft, normalizeMcpServers as g, ToolResultContent as gn, ToolSpec as gt, normalizeMcpBlocks as h, ToolHookContext as hn, ToolResult as ht, AgentOptions as i, PromptTextPart as in, fromAnthropic as it, SkillsConfig as j, ClassifiedErrorKind as jn, OpenAIParams as jt, SkillResource as k, CONTEXT_EXCEEDED_MESSAGE_PATTERNS as kn, mapOAIFinishReason as kt, SkillActivationState as l, SessionHookContext as ln, Provider as lt, connectMcpServers as m, ThinkingLevel as mn, ToolCall as mt, AgentHookMap as n, PromptImagePart as nn, ensureToolResultPairing as nt, ActivationVia as o, RunHookMap as on, toAnthropic as ot, McpConnection as p, StreamHookContext as pn, TokenCountPayload as pt, PairingRepair as q, CompactFunction as qt, AgentHooks as r, PromptPart as rn, filterUnresolvedToolUses as rt, ActiveSkill as s, SessionContentBlock as sn, toOpenAI as st, Agent as t, PromptDocumentPart as tn, ensureEndsWithUserMessage as tt, SkillActivationStateOptions as u, SessionMessage as un, ProviderCapabilities as ut, ToolContext as v, ToolResultTextContent as vn, SchemaSanitizeOptions as vt, hashContent as w, AgentBudgetExceededError as wn, openrouter as wt, ReadStateEntry as x, toolOutputByteLength as xn, sanitizeToolSchema as xt, ToolDef as y, TurnFinishReason as yn, SchemaSanitizeProfile as yt, RemoteStoreOptions as z, ContextExactCounts as zn, AnthropicParams as zt };
|
|
4998
|
+
//# sourceMappingURL=agent-BNS2nx_T.d.ts.map
|