agentfootprint 8.0.0 → 8.2.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 +14 -9
- package/README.md +11 -7
- package/ai-instructions/claude-code/SKILL.md +1 -1
- package/ai-instructions/clinerules +1 -1
- package/ai-instructions/copilot-instructions.md +1 -1
- package/ai-instructions/cursor/agentfootprint.md +1 -1
- package/ai-instructions/kiro/agentfootprint.md +1 -1
- package/ai-instructions/windsurfrules +1 -1
- package/dist/adapters/llm/OllamaProvider.js +628 -0
- package/dist/adapters/llm/OllamaProvider.js.map +1 -0
- package/dist/adapters/llm/OpenAIProvider.js +12 -21
- package/dist/adapters/llm/OpenAIProvider.js.map +1 -1
- package/dist/adapters/llm/createProvider.js +35 -6
- package/dist/adapters/llm/createProvider.js.map +1 -1
- package/dist/core/Agent.js +44 -1
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/agent/stages/seed.js +10 -0
- package/dist/core/agent/stages/seed.js.map +1 -1
- package/dist/core/agent/stages/window.js +21 -0
- package/dist/core/agent/stages/window.js.map +1 -1
- package/dist/core/agent/window/errors.js +4 -3
- package/dist/core/agent/window/errors.js.map +1 -1
- package/dist/core/agent/window/folded.js +98 -0
- package/dist/core/agent/window/folded.js.map +1 -0
- package/dist/core/agent/window/index.js +9 -1
- package/dist/core/agent/window/index.js.map +1 -1
- package/dist/core/agent/window/options.js +18 -2
- package/dist/core/agent/window/options.js.map +1 -1
- package/dist/core/agent/window/strategies/slidingWindow.js +2 -2
- package/dist/core/agent/window/strategies/summarizeOldest.js +25 -2
- package/dist/core/agent/window/strategies/summarizeOldest.js.map +1 -1
- package/dist/core/agent/window/summarize.js +27 -1
- package/dist/core/agent/window/summarize.js.map +1 -1
- package/dist/core/agent/window/types.js +6 -0
- package/dist/core/agent/window/types.js.map +1 -1
- package/dist/core/runCheckpoint.js +9 -1
- package/dist/core/runCheckpoint.js.map +1 -1
- package/dist/esm/adapters/llm/OllamaProvider.d.ts +182 -0
- package/dist/esm/adapters/llm/OllamaProvider.js +622 -0
- package/dist/esm/adapters/llm/OllamaProvider.js.map +1 -0
- package/dist/esm/adapters/llm/OpenAIProvider.d.ts +0 -12
- package/dist/esm/adapters/llm/OpenAIProvider.js +11 -19
- package/dist/esm/adapters/llm/OpenAIProvider.js.map +1 -1
- package/dist/esm/adapters/llm/createProvider.d.ts +25 -8
- package/dist/esm/adapters/llm/createProvider.js +35 -6
- package/dist/esm/adapters/llm/createProvider.js.map +1 -1
- package/dist/esm/core/Agent.d.ts +17 -0
- package/dist/esm/core/Agent.js +44 -1
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/agent/stages/seed.d.ts +11 -0
- package/dist/esm/core/agent/stages/seed.js +10 -0
- package/dist/esm/core/agent/stages/seed.js.map +1 -1
- package/dist/esm/core/agent/stages/window.d.ts +13 -0
- package/dist/esm/core/agent/stages/window.js +21 -0
- package/dist/esm/core/agent/stages/window.js.map +1 -1
- package/dist/esm/core/agent/types.d.ts +15 -1
- package/dist/esm/core/agent/window/errors.js +4 -3
- package/dist/esm/core/agent/window/errors.js.map +1 -1
- package/dist/esm/core/agent/window/folded.d.ts +90 -0
- package/dist/esm/core/agent/window/folded.js +92 -0
- package/dist/esm/core/agent/window/folded.js.map +1 -0
- package/dist/esm/core/agent/window/index.d.ts +7 -1
- package/dist/esm/core/agent/window/index.js +6 -0
- package/dist/esm/core/agent/window/index.js.map +1 -1
- package/dist/esm/core/agent/window/options.d.ts +7 -1
- package/dist/esm/core/agent/window/options.js +17 -1
- package/dist/esm/core/agent/window/options.js.map +1 -1
- package/dist/esm/core/agent/window/strategies/slidingWindow.d.ts +2 -2
- package/dist/esm/core/agent/window/strategies/slidingWindow.js +2 -2
- package/dist/esm/core/agent/window/strategies/summarizeOldest.d.ts +4 -2
- package/dist/esm/core/agent/window/strategies/summarizeOldest.js +25 -2
- package/dist/esm/core/agent/window/strategies/summarizeOldest.js.map +1 -1
- package/dist/esm/core/agent/window/strategy.d.ts +26 -1
- package/dist/esm/core/agent/window/summarize.d.ts +11 -0
- package/dist/esm/core/agent/window/summarize.js +27 -1
- package/dist/esm/core/agent/window/summarize.js.map +1 -1
- package/dist/esm/core/agent/window/types.d.ts +106 -1
- package/dist/esm/core/agent/window/types.js +6 -0
- package/dist/esm/core/agent/window/types.js.map +1 -1
- package/dist/esm/core/runCheckpoint.d.ts +32 -1
- package/dist/esm/core/runCheckpoint.js +9 -1
- package/dist/esm/core/runCheckpoint.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +6 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/providers.d.ts +13 -5
- package/dist/esm/providers.js +13 -5
- package/dist/esm/providers.js.map +1 -1
- package/dist/esm/thinking/OllamaThinkingHandler.d.ts +60 -0
- package/dist/esm/thinking/OllamaThinkingHandler.js +107 -0
- package/dist/esm/thinking/OllamaThinkingHandler.js.map +1 -0
- package/dist/esm/thinking/index.d.ts +1 -0
- package/dist/esm/thinking/index.js +1 -0
- package/dist/esm/thinking/index.js.map +1 -1
- package/dist/esm/thinking/registry.js +2 -0
- package/dist/esm/thinking/registry.js.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/providers.js +16 -6
- package/dist/providers.js.map +1 -1
- package/dist/thinking/OllamaThinkingHandler.js +111 -0
- package/dist/thinking/OllamaThinkingHandler.js.map +1 -0
- package/dist/thinking/index.js +4 -1
- package/dist/thinking/index.js.map +1 -1
- package/dist/thinking/registry.js +2 -0
- package/dist/thinking/registry.js.map +1 -1
- package/dist/types/adapters/llm/OllamaProvider.d.ts +183 -0
- package/dist/types/adapters/llm/OllamaProvider.d.ts.map +1 -0
- package/dist/types/adapters/llm/OpenAIProvider.d.ts +0 -12
- package/dist/types/adapters/llm/OpenAIProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/createProvider.d.ts +25 -8
- package/dist/types/adapters/llm/createProvider.d.ts.map +1 -1
- package/dist/types/core/Agent.d.ts +17 -0
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/agent/stages/seed.d.ts +11 -0
- package/dist/types/core/agent/stages/seed.d.ts.map +1 -1
- package/dist/types/core/agent/stages/window.d.ts +13 -0
- package/dist/types/core/agent/stages/window.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +15 -1
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/agent/window/errors.d.ts.map +1 -1
- package/dist/types/core/agent/window/folded.d.ts +91 -0
- package/dist/types/core/agent/window/folded.d.ts.map +1 -0
- package/dist/types/core/agent/window/index.d.ts +7 -1
- package/dist/types/core/agent/window/index.d.ts.map +1 -1
- package/dist/types/core/agent/window/options.d.ts +7 -1
- package/dist/types/core/agent/window/options.d.ts.map +1 -1
- package/dist/types/core/agent/window/strategies/slidingWindow.d.ts +2 -2
- package/dist/types/core/agent/window/strategies/summarizeOldest.d.ts +4 -2
- package/dist/types/core/agent/window/strategies/summarizeOldest.d.ts.map +1 -1
- package/dist/types/core/agent/window/strategy.d.ts +26 -1
- package/dist/types/core/agent/window/strategy.d.ts.map +1 -1
- package/dist/types/core/agent/window/summarize.d.ts +11 -0
- package/dist/types/core/agent/window/summarize.d.ts.map +1 -1
- package/dist/types/core/agent/window/types.d.ts +106 -1
- package/dist/types/core/agent/window/types.d.ts.map +1 -1
- package/dist/types/core/runCheckpoint.d.ts +32 -1
- package/dist/types/core/runCheckpoint.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/providers.d.ts +13 -5
- package/dist/types/providers.d.ts.map +1 -1
- package/dist/types/thinking/OllamaThinkingHandler.d.ts +61 -0
- package/dist/types/thinking/OllamaThinkingHandler.d.ts.map +1 -0
- package/dist/types/thinking/index.d.ts +1 -0
- package/dist/types/thinking/index.d.ts.map +1 -1
- package/dist/types/thinking/registry.d.ts.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OllamaProvider — local models over Ollama's native `/api/chat`.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: Adapter (GoF) + Ports-and-Adapters (Cockburn 2005).
|
|
6
|
+
* Role: Outer ring — translates `LLMRequest`/`LLMResponse` to/from
|
|
7
|
+
* Ollama's native chat wire. Knows nothing about agents,
|
|
8
|
+
* recorders, or compositions.
|
|
9
|
+
* Emits: N/A.
|
|
10
|
+
*
|
|
11
|
+
* ─── Why this exists, and why it talks the native wire ───────────────
|
|
12
|
+
*
|
|
13
|
+
* The adapter ladder is `mock()` → a local model → a paid API, and the
|
|
14
|
+
* strongest version of "the test run and the production run are the same
|
|
15
|
+
* code path" is one where the middle step costs nothing and needs no API
|
|
16
|
+
* key. Through 8.0.0 the middle step needed BOTH a competitor's SDK
|
|
17
|
+
* (`npm install openai`, because `ollama()` was a thin wrapper over
|
|
18
|
+
* `openai({ baseURL })`) and a tolerance for failures labelled `[openai]`.
|
|
19
|
+
* That is not a free rung.
|
|
20
|
+
*
|
|
21
|
+
* So this file owns the wire:
|
|
22
|
+
*
|
|
23
|
+
* • ZERO dependencies — one `fetch` POST and NDJSON. Nothing to install
|
|
24
|
+
* beyond Ollama itself. (Same choice, same reasons, as the two
|
|
25
|
+
* `Browser*Provider` adapters.)
|
|
26
|
+
* • HONEST REFUSALS — a typed {@link OllamaUnavailableError} that names
|
|
27
|
+
* the address it tried and the command to run. Owning the fetch and
|
|
28
|
+
* the status code is what makes that possible; through an SDK you get
|
|
29
|
+
* whatever the SDK decided to throw.
|
|
30
|
+
* • REAL TOKEN COUNTS — `/api/chat` returns `prompt_eval_count` /
|
|
31
|
+
* `eval_count` on every response, streaming or not, with no opt-in
|
|
32
|
+
* flag. Through the OpenAI-compatible endpoint a streamed local call
|
|
33
|
+
* reported ZERO tokens, which silently disarmed `.compaction()` and
|
|
34
|
+
* `costBudget` (see `CompactionUnmeasurableError`, whose message names
|
|
35
|
+
* this exact case).
|
|
36
|
+
* • STRUCTURED THINKING — `message.thinking` is a first-class field on
|
|
37
|
+
* this wire; the OpenAI-compatible layer renames it to a non-standard
|
|
38
|
+
* `reasoning` key that no OpenAI adapter reads. See
|
|
39
|
+
* `OllamaThinkingHandler`.
|
|
40
|
+
*
|
|
41
|
+
* Want the SDK path instead? It is still there and still supported:
|
|
42
|
+
* `openai({ baseURL: 'http://localhost:11434/v1', apiKey: 'ollama' })`.
|
|
43
|
+
*
|
|
44
|
+
* ─── Ceilings (stated, not worked around) ────────────────────────────
|
|
45
|
+
*
|
|
46
|
+
* • TOOL CALLING IS MODEL-DEPENDENT. Ollama forwards a `tools` array to
|
|
47
|
+
* any model; a model that was not trained for tools simply answers in
|
|
48
|
+
* prose and no tool call ever arrives. This adapter does not preflight
|
|
49
|
+
* `/api/show` capabilities to refuse first — a wrong refusal is worse
|
|
50
|
+
* than a weak answer, and the metadata is less reliable than the
|
|
51
|
+
* ceiling being written down. Pick a tool-capable model.
|
|
52
|
+
* • NO FORCED TOOL CHOICE. Ollama does not support `tool_choice` on
|
|
53
|
+
* either wire, so `carriesForcedToolChoice` is `false` and an agent
|
|
54
|
+
* using `.outputSchema(parser, { strategy: 'tool-forced' })` refuses at
|
|
55
|
+
* run start, naming this provider.
|
|
56
|
+
* • NO MULTI-MODAL. The wire carries `images`; `LLMMessage.content` is a
|
|
57
|
+
* string. Same ceiling as every other adapter here.
|
|
58
|
+
* • NO PROMPT CACHING — resolves to the NoOp cache strategy.
|
|
59
|
+
* • NO `providerRef`. The native wire returns no response id, and a
|
|
60
|
+
* fabricated one would point at nothing.
|
|
61
|
+
*/
|
|
62
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
|
+
exports.OllamaProvider = exports.ollama = exports.OllamaUnavailableError = void 0;
|
|
64
|
+
// ─── Errors ─────────────────────────────────────────────────────────
|
|
65
|
+
/**
|
|
66
|
+
* The two failures a local runtime actually has, told in words that
|
|
67
|
+
* contain the fix.
|
|
68
|
+
*
|
|
69
|
+
* Both are things the person at the keyboard can resolve in one command,
|
|
70
|
+
* which is exactly why they get a type instead of a wrapped
|
|
71
|
+
* `ECONNREFUSED` or a bare `404`. `reason` is the discriminator; the
|
|
72
|
+
* message already reads as instructions.
|
|
73
|
+
*/
|
|
74
|
+
class OllamaUnavailableError extends Error {
|
|
75
|
+
name = 'OllamaUnavailableError';
|
|
76
|
+
/** Which of the two situations this is. */
|
|
77
|
+
reason;
|
|
78
|
+
/** The address that was tried — the thing to check or change. */
|
|
79
|
+
baseUrl;
|
|
80
|
+
/** The model asked for. Absent when the daemon never answered at all. */
|
|
81
|
+
model;
|
|
82
|
+
/** Models this machine DOES have, when the daemon could tell us. */
|
|
83
|
+
availableModels;
|
|
84
|
+
constructor(init) {
|
|
85
|
+
super(buildUnavailableMessage(init));
|
|
86
|
+
this.reason = init.reason;
|
|
87
|
+
this.baseUrl = init.baseUrl;
|
|
88
|
+
if (init.model !== undefined)
|
|
89
|
+
this.model = init.model;
|
|
90
|
+
if (init.availableModels !== undefined)
|
|
91
|
+
this.availableModels = init.availableModels;
|
|
92
|
+
if (init.cause !== undefined)
|
|
93
|
+
this.cause = init.cause;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.OllamaUnavailableError = OllamaUnavailableError;
|
|
97
|
+
function buildUnavailableMessage(init) {
|
|
98
|
+
if (init.reason === 'daemon-unreachable') {
|
|
99
|
+
return (`ollama: nothing is answering at ${init.baseUrl}. ` +
|
|
100
|
+
`Start it with \`ollama serve\` (or open the Ollama app); install it from ` +
|
|
101
|
+
`https://ollama.com/download. ` +
|
|
102
|
+
`Running somewhere else? Pass ollama('<model>', { baseUrl: '...' }) or set OLLAMA_HOST.`);
|
|
103
|
+
}
|
|
104
|
+
const model = init.model ?? '(unnamed)';
|
|
105
|
+
const have = init.availableModels && init.availableModels.length > 0
|
|
106
|
+
? ` Models on this machine: ${init.availableModels.join(', ')}.`
|
|
107
|
+
: '';
|
|
108
|
+
return (`ollama: model '${model}' is not pulled on the machine at ${init.baseUrl}. ` +
|
|
109
|
+
`Run: ollama pull ${model}.${have}`);
|
|
110
|
+
}
|
|
111
|
+
const DEFAULT_BASE_URL = 'http://localhost:11434';
|
|
112
|
+
const DEFAULT_MODEL = 'llama3.2';
|
|
113
|
+
const DEFAULT_TIMEOUT_MS = 10_000;
|
|
114
|
+
/** Request `model` values that mean "whatever this provider was configured with". */
|
|
115
|
+
const MODEL_SHORTHANDS = new Set(['ollama']);
|
|
116
|
+
/**
|
|
117
|
+
* Which roles this wire carries inside `messages`.
|
|
118
|
+
*
|
|
119
|
+
* Ollama's native chat takes the system prompt as a message like any
|
|
120
|
+
* other (there is no separate top-level `system` field), so all three
|
|
121
|
+
* roles survive the trip.
|
|
122
|
+
*/
|
|
123
|
+
const CARRIES_IN_MESSAGES = Object.freeze(['system', 'user', 'assistant']);
|
|
124
|
+
function ollama(modelOrOptions, maybeOptions) {
|
|
125
|
+
const options = typeof modelOrOptions === 'string' ? maybeOptions ?? {} : modelOrOptions ?? {};
|
|
126
|
+
const positionalModel = typeof modelOrOptions === 'string' ? modelOrOptions : undefined;
|
|
127
|
+
const baseUrl = resolveBaseUrl(options);
|
|
128
|
+
const defaultModel = positionalModel ?? options.defaultModel ?? DEFAULT_MODEL;
|
|
129
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
130
|
+
const fetchImpl = options._fetch ?? ((...args) => fetch(...args));
|
|
131
|
+
const chatUrl = `${baseUrl}/api/chat`;
|
|
132
|
+
const cfg = {
|
|
133
|
+
defaultModel,
|
|
134
|
+
...(options.defaultMaxTokens !== undefined && { defaultMaxTokens: options.defaultMaxTokens }),
|
|
135
|
+
...(options.think !== undefined && { think: options.think }),
|
|
136
|
+
...(options.keepAlive !== undefined && { keepAlive: options.keepAlive }),
|
|
137
|
+
};
|
|
138
|
+
// Tool-call ids are synthesized per provider instance — see toLLMToolCall
|
|
139
|
+
// for why this wire needs that at all.
|
|
140
|
+
let toolCallSeq = 0;
|
|
141
|
+
const nextToolCallId = () => `ollama-call-${++toolCallSeq}`;
|
|
142
|
+
const post = async (body, req) => {
|
|
143
|
+
const response = await fetchUntilHeaders(fetchImpl, chatUrl, {
|
|
144
|
+
method: 'POST',
|
|
145
|
+
headers: { 'content-type': 'application/json' },
|
|
146
|
+
body: JSON.stringify(body),
|
|
147
|
+
}, { timeoutMs, baseUrl, ...(req.signal && { signal: req.signal }) });
|
|
148
|
+
if (!response.ok) {
|
|
149
|
+
throw await describeFailure(response, body.model, baseUrl, fetchImpl, timeoutMs);
|
|
150
|
+
}
|
|
151
|
+
return response;
|
|
152
|
+
};
|
|
153
|
+
const provider = {
|
|
154
|
+
name: 'ollama',
|
|
155
|
+
carriesInMessages: CARRIES_IN_MESSAGES,
|
|
156
|
+
// Ollama supports no forced tool choice on either of its wires. Absence
|
|
157
|
+
// would mean the same thing; saying it out loud documents that this was
|
|
158
|
+
// checked rather than forgotten.
|
|
159
|
+
carriesForcedToolChoice: false,
|
|
160
|
+
async complete(req) {
|
|
161
|
+
const body = buildBody(req, cfg, false);
|
|
162
|
+
const response = await post(body, req);
|
|
163
|
+
const json = (await response.json());
|
|
164
|
+
return fromOllamaResponse(json, nextToolCallId);
|
|
165
|
+
},
|
|
166
|
+
async *stream(req) {
|
|
167
|
+
const body = buildBody(req, cfg, true);
|
|
168
|
+
const response = await post(body, req);
|
|
169
|
+
if (!response.body)
|
|
170
|
+
throw new Error('[ollama] response has no body');
|
|
171
|
+
const textParts = [];
|
|
172
|
+
const thinkingParts = [];
|
|
173
|
+
const toolCalls = [];
|
|
174
|
+
let doneReason = 'stop';
|
|
175
|
+
let promptEvalCount = 0;
|
|
176
|
+
let evalCount = 0;
|
|
177
|
+
let tokenIndex = 0;
|
|
178
|
+
for await (const chunk of parseNdjson(response.body)) {
|
|
179
|
+
const frame = chunk;
|
|
180
|
+
// Counts ride the terminal frame, whose `message.content` is empty —
|
|
181
|
+
// read them before any content guard, or the only token counts the
|
|
182
|
+
// stream reports are thrown away (the failure that made streamed
|
|
183
|
+
// local calls report zero and disarmed `.compaction()`).
|
|
184
|
+
if (typeof frame.prompt_eval_count === 'number')
|
|
185
|
+
promptEvalCount = frame.prompt_eval_count;
|
|
186
|
+
if (typeof frame.eval_count === 'number')
|
|
187
|
+
evalCount = frame.eval_count;
|
|
188
|
+
if (frame.done_reason)
|
|
189
|
+
doneReason = frame.done_reason;
|
|
190
|
+
const message = frame.message;
|
|
191
|
+
if (message) {
|
|
192
|
+
if (message.tool_calls && message.tool_calls.length > 0) {
|
|
193
|
+
// Ollama emits each tool call whole, not as an assembled delta.
|
|
194
|
+
toolCalls.push(...message.tool_calls);
|
|
195
|
+
}
|
|
196
|
+
if (message.thinking) {
|
|
197
|
+
thinkingParts.push(message.thinking);
|
|
198
|
+
yield { tokenIndex, content: '', done: false, thinkingDelta: message.thinking };
|
|
199
|
+
tokenIndex++;
|
|
200
|
+
}
|
|
201
|
+
if (message.content) {
|
|
202
|
+
textParts.push(message.content);
|
|
203
|
+
yield { tokenIndex, content: message.content, done: false };
|
|
204
|
+
tokenIndex++;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (frame.done)
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
const content = textParts.join('');
|
|
211
|
+
const rawThinking = describeThinking(content, thinkingParts.join(''));
|
|
212
|
+
const authoritative = {
|
|
213
|
+
content,
|
|
214
|
+
toolCalls: toolCalls.map((tc) => toLLMToolCall(tc, nextToolCallId)),
|
|
215
|
+
usage: { input: promptEvalCount, output: evalCount },
|
|
216
|
+
stopReason: normalizeStopReason(doneReason, toolCalls.length > 0),
|
|
217
|
+
...(rawThinking && { rawThinking }),
|
|
218
|
+
};
|
|
219
|
+
yield { tokenIndex, content: '', done: true, response: authoritative };
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
return provider;
|
|
223
|
+
}
|
|
224
|
+
exports.ollama = ollama;
|
|
225
|
+
/**
|
|
226
|
+
* Class form for consumers who prefer `new OllamaProvider(...)`.
|
|
227
|
+
*/
|
|
228
|
+
class OllamaProvider {
|
|
229
|
+
name = 'ollama';
|
|
230
|
+
carriesInMessages = CARRIES_IN_MESSAGES;
|
|
231
|
+
carriesForcedToolChoice = false;
|
|
232
|
+
inner;
|
|
233
|
+
constructor(model, options) {
|
|
234
|
+
this.inner =
|
|
235
|
+
typeof model === 'string' ? ollama(model, options) : ollama(model);
|
|
236
|
+
}
|
|
237
|
+
// `hooks` is FORWARDED, not dropped — see LLMCallHooks in adapters/types.ts.
|
|
238
|
+
complete(req, hooks) {
|
|
239
|
+
return this.inner.complete(req, hooks);
|
|
240
|
+
}
|
|
241
|
+
stream(req, hooks) {
|
|
242
|
+
if (!this.inner.stream)
|
|
243
|
+
throw new Error('stream() unavailable');
|
|
244
|
+
return this.inner.stream(req, hooks);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
exports.OllamaProvider = OllamaProvider;
|
|
248
|
+
// ─── Internals ──────────────────────────────────────────────────────
|
|
249
|
+
/**
|
|
250
|
+
* Resolve where Ollama lives, accepting every spelling that has ever been
|
|
251
|
+
* valid here plus Ollama's own `OLLAMA_HOST` convention.
|
|
252
|
+
*
|
|
253
|
+
* A `/v1` suffix is trimmed rather than rejected: through 8.0.0 the
|
|
254
|
+
* factory built `${host}/v1` for the OpenAI-compatible endpoint, and a
|
|
255
|
+
* config carrying that URL means the same machine.
|
|
256
|
+
*/
|
|
257
|
+
function resolveBaseUrl(options) {
|
|
258
|
+
const raw = options.baseUrl ??
|
|
259
|
+
options.host ??
|
|
260
|
+
options.baseURL ??
|
|
261
|
+
(typeof process !== 'undefined' ? process.env?.OLLAMA_HOST : undefined) ??
|
|
262
|
+
DEFAULT_BASE_URL;
|
|
263
|
+
const withScheme = /^https?:\/\//i.test(raw) ? raw : `http://${raw}`;
|
|
264
|
+
return withScheme.replace(/\/+$/, '').replace(/\/v1$/i, '');
|
|
265
|
+
}
|
|
266
|
+
function buildBody(req, cfg, stream) {
|
|
267
|
+
const model = MODEL_SHORTHANDS.has(req.model) ? cfg.defaultModel : req.model;
|
|
268
|
+
const body = {
|
|
269
|
+
model,
|
|
270
|
+
messages: toOllamaMessages(req.messages, req.systemPrompt),
|
|
271
|
+
stream,
|
|
272
|
+
};
|
|
273
|
+
if (req.tools && req.tools.length > 0)
|
|
274
|
+
body.tools = req.tools.map(toOllamaTool);
|
|
275
|
+
// Two ways to ask for thinking: the provider-wide option (which can name a
|
|
276
|
+
// level) and the per-request field the agent's `.thinking({ budget })` sets.
|
|
277
|
+
// The request cannot express a level, so it turns thinking on and leaves the
|
|
278
|
+
// configured level in place. `budget` has no equivalent on this wire —
|
|
279
|
+
// Ollama does not take a reasoning-token cap — so it is deliberately dropped
|
|
280
|
+
// rather than mistranslated into `num_predict`, which caps the ANSWER.
|
|
281
|
+
if (cfg.think !== undefined)
|
|
282
|
+
body.think = cfg.think;
|
|
283
|
+
else if (req.thinking !== undefined)
|
|
284
|
+
body.think = true;
|
|
285
|
+
if (cfg.keepAlive !== undefined)
|
|
286
|
+
body.keep_alive = cfg.keepAlive;
|
|
287
|
+
const maxTokens = req.maxTokens ?? cfg.defaultMaxTokens;
|
|
288
|
+
const options = {};
|
|
289
|
+
if (maxTokens !== undefined)
|
|
290
|
+
options.num_predict = maxTokens;
|
|
291
|
+
if (req.temperature !== undefined)
|
|
292
|
+
options.temperature = req.temperature;
|
|
293
|
+
if (req.stop && req.stop.length > 0)
|
|
294
|
+
options.stop = [...req.stop];
|
|
295
|
+
if (Object.keys(options).length > 0)
|
|
296
|
+
body.options = options;
|
|
297
|
+
// `req.toolChoice` is intentionally NOT translated: Ollama supports no
|
|
298
|
+
// forced tool choice, `carriesForcedToolChoice` says so, and the agent
|
|
299
|
+
// refuses before it ever reaches here.
|
|
300
|
+
return body;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* messages → Ollama messages.
|
|
304
|
+
*
|
|
305
|
+
* Roles map 1:1. The system prompt is prepended as an ordinary `system`
|
|
306
|
+
* message (this wire has no separate system field). Assistant turns carry
|
|
307
|
+
* their `tool_calls` back so the model can see its own requests; tool
|
|
308
|
+
* results carry `tool_name`, which is how this wire correlates a result
|
|
309
|
+
* with the call that asked for it.
|
|
310
|
+
*/
|
|
311
|
+
function toOllamaMessages(messages, systemPrompt) {
|
|
312
|
+
const result = [];
|
|
313
|
+
if (systemPrompt)
|
|
314
|
+
result.push({ role: 'system', content: systemPrompt });
|
|
315
|
+
for (const m of messages) {
|
|
316
|
+
if (m.role === 'system' || m.role === 'user') {
|
|
317
|
+
result.push({ role: m.role, content: m.content });
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
if (m.role === 'assistant') {
|
|
321
|
+
const msg = { role: 'assistant', content: m.content };
|
|
322
|
+
if (m.toolCalls && m.toolCalls.length > 0) {
|
|
323
|
+
msg.tool_calls = m.toolCalls.map((tc) => ({
|
|
324
|
+
...(tc.id && { id: tc.id }),
|
|
325
|
+
function: { name: tc.name, arguments: { ...tc.args } },
|
|
326
|
+
}));
|
|
327
|
+
}
|
|
328
|
+
result.push(msg);
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
if (m.role === 'tool') {
|
|
332
|
+
// `tool_name` is what this wire matches on. The agent always sets
|
|
333
|
+
// `toolName`; a hand-built history might not, so fall back to looking
|
|
334
|
+
// the id up in the assistant turn that requested it.
|
|
335
|
+
const toolName = m.toolName ?? nameForToolCallId(messages, m.toolCallId);
|
|
336
|
+
result.push({
|
|
337
|
+
role: 'tool',
|
|
338
|
+
content: m.content,
|
|
339
|
+
...(toolName && { tool_name: toolName }),
|
|
340
|
+
...(m.toolCallId && { tool_call_id: m.toolCallId }),
|
|
341
|
+
});
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return result;
|
|
346
|
+
}
|
|
347
|
+
function nameForToolCallId(messages, toolCallId) {
|
|
348
|
+
if (!toolCallId)
|
|
349
|
+
return undefined;
|
|
350
|
+
for (const m of messages) {
|
|
351
|
+
if (m.role !== 'assistant' || !m.toolCalls)
|
|
352
|
+
continue;
|
|
353
|
+
for (const tc of m.toolCalls) {
|
|
354
|
+
if (tc.id === toolCallId)
|
|
355
|
+
return tc.name;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return undefined;
|
|
359
|
+
}
|
|
360
|
+
function toOllamaTool(schema) {
|
|
361
|
+
return {
|
|
362
|
+
type: 'function',
|
|
363
|
+
function: {
|
|
364
|
+
name: schema.name,
|
|
365
|
+
description: schema.description,
|
|
366
|
+
parameters: { ...schema.inputSchema },
|
|
367
|
+
},
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function fromOllamaResponse(response, nextToolCallId) {
|
|
371
|
+
const message = response.message;
|
|
372
|
+
const wireToolCalls = message?.tool_calls ?? [];
|
|
373
|
+
const toolCalls = wireToolCalls.map((tc) => toLLMToolCall(tc, nextToolCallId));
|
|
374
|
+
const content = message?.content ?? '';
|
|
375
|
+
const rawThinking = describeThinking(content, message?.thinking);
|
|
376
|
+
return {
|
|
377
|
+
content,
|
|
378
|
+
toolCalls,
|
|
379
|
+
usage: {
|
|
380
|
+
input: response.prompt_eval_count ?? 0,
|
|
381
|
+
output: response.eval_count ?? 0,
|
|
382
|
+
},
|
|
383
|
+
stopReason: normalizeStopReason(response.done_reason ?? 'stop', toolCalls.length > 0),
|
|
384
|
+
// No `providerRef` — this wire returns no response id, and inventing
|
|
385
|
+
// one would hand consumers a reference that resolves to nothing.
|
|
386
|
+
...(rawThinking && { rawThinking }),
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Where the model's reasoning ended up, labelled for the handler.
|
|
391
|
+
*
|
|
392
|
+
* `message.thinking` is the good case — Ollama lifted the reasoning out of
|
|
393
|
+
* the answer because we asked it to. Failing that, a reasoning model that
|
|
394
|
+
* was NOT asked leaves `<think>…</think>` sitting in the answer text; we
|
|
395
|
+
* notice and say so, and we pass the answer through UNCHANGED. Editing a
|
|
396
|
+
* model's answer behind its back is a meaning change and belongs to the
|
|
397
|
+
* application, not to an adapter. See `OllamaThinkingHandler`.
|
|
398
|
+
*/
|
|
399
|
+
function describeThinking(content, thinkingField) {
|
|
400
|
+
if (thinkingField && thinkingField.length > 0) {
|
|
401
|
+
return { kind: 'field', thinking: thinkingField };
|
|
402
|
+
}
|
|
403
|
+
if (content.includes('<think'))
|
|
404
|
+
return { kind: 'inline', content };
|
|
405
|
+
return undefined;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* One wire tool call → the port's shape.
|
|
409
|
+
*
|
|
410
|
+
* Two wire facts handled here:
|
|
411
|
+
* • `id` is optional and most models omit it, but the whole tool
|
|
412
|
+
* round-trip in this library is keyed by id. So an id is SYNTHESIZED
|
|
413
|
+
* when missing — unique per provider instance, which is all the
|
|
414
|
+
* correlation needs, and the name still rides `tool_name` on the way
|
|
415
|
+
* back regardless.
|
|
416
|
+
* • `arguments` is already a JSON OBJECT here (OpenAI sends a string),
|
|
417
|
+
* so there is nothing to parse. A string is still tolerated in case a
|
|
418
|
+
* proxy in the middle reshaped it.
|
|
419
|
+
*/
|
|
420
|
+
function toLLMToolCall(tc, nextToolCallId) {
|
|
421
|
+
return {
|
|
422
|
+
id: tc.id && tc.id.length > 0 ? tc.id : nextToolCallId(),
|
|
423
|
+
name: tc.function?.name ?? '',
|
|
424
|
+
args: coerceArgs(tc.function?.arguments),
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
function coerceArgs(args) {
|
|
428
|
+
if (args === undefined || args === null)
|
|
429
|
+
return {};
|
|
430
|
+
if (typeof args === 'string') {
|
|
431
|
+
if (args.length === 0)
|
|
432
|
+
return {};
|
|
433
|
+
try {
|
|
434
|
+
const parsed = JSON.parse(args);
|
|
435
|
+
return typeof parsed === 'object' && parsed !== null
|
|
436
|
+
? parsed
|
|
437
|
+
: {};
|
|
438
|
+
}
|
|
439
|
+
catch {
|
|
440
|
+
// Malformed args are rare but observed on small local models. Surface
|
|
441
|
+
// empty rather than crash — the tool-call event still fires, so the
|
|
442
|
+
// problem is visible in the trace.
|
|
443
|
+
return {};
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
return { ...args };
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* `done_reason` → the port's stop vocabulary.
|
|
450
|
+
*
|
|
451
|
+
* Ollama reports `stop` even when the turn ended in tool calls, so the
|
|
452
|
+
* presence of tool calls is what distinguishes `tool_use` — the same
|
|
453
|
+
* correction Ollama's own OpenAI-compat layer makes.
|
|
454
|
+
*/
|
|
455
|
+
function normalizeStopReason(raw, hasToolCalls) {
|
|
456
|
+
if (hasToolCalls && (raw === 'stop' || raw === ''))
|
|
457
|
+
return 'tool_use';
|
|
458
|
+
switch (raw) {
|
|
459
|
+
case 'stop':
|
|
460
|
+
return 'stop';
|
|
461
|
+
case 'length':
|
|
462
|
+
return 'max_tokens';
|
|
463
|
+
default:
|
|
464
|
+
return raw;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
/** Parse an NDJSON body — one JSON object per line. */
|
|
468
|
+
async function* parseNdjson(body) {
|
|
469
|
+
const reader = body.getReader();
|
|
470
|
+
const decoder = new TextDecoder();
|
|
471
|
+
let buf = '';
|
|
472
|
+
try {
|
|
473
|
+
for (;;) {
|
|
474
|
+
const { value, done } = await reader.read();
|
|
475
|
+
if (done)
|
|
476
|
+
break;
|
|
477
|
+
buf += decoder.decode(value, { stream: true });
|
|
478
|
+
let idx;
|
|
479
|
+
while ((idx = buf.indexOf('\n')) >= 0) {
|
|
480
|
+
const line = buf.slice(0, idx).trim();
|
|
481
|
+
buf = buf.slice(idx + 1);
|
|
482
|
+
if (!line)
|
|
483
|
+
continue;
|
|
484
|
+
try {
|
|
485
|
+
yield JSON.parse(line);
|
|
486
|
+
}
|
|
487
|
+
catch {
|
|
488
|
+
/* skip malformed line */
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
// A final line with no trailing newline still counts.
|
|
493
|
+
const tail = buf.trim();
|
|
494
|
+
if (tail) {
|
|
495
|
+
try {
|
|
496
|
+
yield JSON.parse(tail);
|
|
497
|
+
}
|
|
498
|
+
catch {
|
|
499
|
+
/* skip malformed tail */
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
finally {
|
|
504
|
+
reader.releaseLock();
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* POST, but never hang waiting for a daemon that is not there.
|
|
509
|
+
*
|
|
510
|
+
* The timer bounds the wait for RESPONSE HEADERS and is cleared the moment
|
|
511
|
+
* they arrive, so a model that takes four minutes to write a long answer is
|
|
512
|
+
* unaffected — `fetch` resolves on headers, and the body streams afterwards.
|
|
513
|
+
*
|
|
514
|
+
* The deadline is a RACE, not just an `AbortSignal`. Aborting is the polite
|
|
515
|
+
* request — it releases the socket and is what a real `fetch` acts on — but a
|
|
516
|
+
* promise that never settles is exactly the failure this guards against, and
|
|
517
|
+
* "never hangs" cannot be a promise the caller's `fetch` implementation gets
|
|
518
|
+
* to break on our behalf. So the timeout wins on its own.
|
|
519
|
+
*
|
|
520
|
+
* A caller's own `AbortSignal` is forwarded and, if IT is what fired, the
|
|
521
|
+
* abort is re-thrown as an abort rather than blamed on the daemon.
|
|
522
|
+
*/
|
|
523
|
+
async function fetchUntilHeaders(fetchImpl, url, init, opts) {
|
|
524
|
+
const controller = new AbortController();
|
|
525
|
+
let timedOut = false;
|
|
526
|
+
let timer;
|
|
527
|
+
const onCallerAbort = () => controller.abort();
|
|
528
|
+
opts.signal?.addEventListener('abort', onCallerAbort, { once: true });
|
|
529
|
+
const deadline = new Promise((_resolve, reject) => {
|
|
530
|
+
timer = setTimeout(() => {
|
|
531
|
+
timedOut = true;
|
|
532
|
+
controller.abort();
|
|
533
|
+
reject(new OllamaUnavailableError({ reason: 'daemon-unreachable', baseUrl: opts.baseUrl }));
|
|
534
|
+
}, opts.timeoutMs);
|
|
535
|
+
});
|
|
536
|
+
try {
|
|
537
|
+
return await Promise.race([fetchImpl(url, { ...init, signal: controller.signal }), deadline]);
|
|
538
|
+
}
|
|
539
|
+
catch (err) {
|
|
540
|
+
if (err instanceof OllamaUnavailableError)
|
|
541
|
+
throw err; // the deadline fired
|
|
542
|
+
if (opts.signal?.aborted && !timedOut)
|
|
543
|
+
throw err; // the caller's call, not ours
|
|
544
|
+
// Timed out, or connection refused / DNS failure / TLS failure — either
|
|
545
|
+
// way, nothing answered at that address.
|
|
546
|
+
throw new OllamaUnavailableError({
|
|
547
|
+
reason: 'daemon-unreachable',
|
|
548
|
+
baseUrl: opts.baseUrl,
|
|
549
|
+
cause: err,
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
finally {
|
|
553
|
+
if (timer !== undefined)
|
|
554
|
+
clearTimeout(timer);
|
|
555
|
+
opts.signal?.removeEventListener('abort', onCallerAbort);
|
|
556
|
+
// When the fetch wins the race, the deadline promise may still reject with
|
|
557
|
+
// nobody listening. Swallow it deliberately: the answer already arrived, so
|
|
558
|
+
// an unhandled-rejection warning here would be noise about a non-event.
|
|
559
|
+
deadline.catch(() => undefined);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Turn a non-2xx into the most actionable error available.
|
|
564
|
+
*
|
|
565
|
+
* A 404 from `/api/chat` means the model is not on this machine. Before
|
|
566
|
+
* saying so we ask `/api/tags` — a cheap local call — so the message can
|
|
567
|
+
* also name what IS here, which is usually enough to spot a typo. If that
|
|
568
|
+
* lookup fails too, the `ollama pull` instruction stands on its own.
|
|
569
|
+
*/
|
|
570
|
+
async function describeFailure(response, model, baseUrl, fetchImpl, timeoutMs) {
|
|
571
|
+
const bodyText = await safeText(response);
|
|
572
|
+
if (response.status === 404) {
|
|
573
|
+
const availableModels = await listPulledModels(fetchImpl, baseUrl, timeoutMs);
|
|
574
|
+
return new OllamaUnavailableError({
|
|
575
|
+
reason: 'model-not-pulled',
|
|
576
|
+
baseUrl,
|
|
577
|
+
model,
|
|
578
|
+
...(availableModels && { availableModels }),
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
const detail = extractErrorText(bodyText);
|
|
582
|
+
return Object.assign(new Error(`[ollama] ${response.status} ${response.statusText}${detail ? ` — ${detail}` : ''}`.trim()), { name: 'OllamaProviderError', status: response.status });
|
|
583
|
+
}
|
|
584
|
+
async function listPulledModels(fetchImpl, baseUrl, timeoutMs) {
|
|
585
|
+
const controller = new AbortController();
|
|
586
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
587
|
+
try {
|
|
588
|
+
const response = await fetchImpl(`${baseUrl}/api/tags`, { signal: controller.signal });
|
|
589
|
+
if (!response.ok)
|
|
590
|
+
return undefined;
|
|
591
|
+
const json = (await response.json());
|
|
592
|
+
const names = (json.models ?? [])
|
|
593
|
+
.map((m) => m.name ?? m.model)
|
|
594
|
+
.filter((n) => typeof n === 'string' && n.length > 0);
|
|
595
|
+
return names.length > 0 ? names : undefined;
|
|
596
|
+
}
|
|
597
|
+
catch {
|
|
598
|
+
// Best-effort enrichment. Its failure must never replace the error we
|
|
599
|
+
// are already in the middle of reporting.
|
|
600
|
+
return undefined;
|
|
601
|
+
}
|
|
602
|
+
finally {
|
|
603
|
+
clearTimeout(timer);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
async function safeText(response) {
|
|
607
|
+
try {
|
|
608
|
+
return await response.text();
|
|
609
|
+
}
|
|
610
|
+
catch {
|
|
611
|
+
return '';
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
/** Native errors are `{"error": "..."}`; fall back to the raw text. */
|
|
615
|
+
function extractErrorText(bodyText) {
|
|
616
|
+
if (!bodyText)
|
|
617
|
+
return '';
|
|
618
|
+
try {
|
|
619
|
+
const parsed = JSON.parse(bodyText);
|
|
620
|
+
if (typeof parsed.error === 'string' && parsed.error.length > 0)
|
|
621
|
+
return parsed.error;
|
|
622
|
+
}
|
|
623
|
+
catch {
|
|
624
|
+
/* not JSON — fall through */
|
|
625
|
+
}
|
|
626
|
+
return bodyText.slice(0, 200);
|
|
627
|
+
}
|
|
628
|
+
//# sourceMappingURL=OllamaProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OllamaProvider.js","sourceRoot":"","sources":["../../../src/adapters/llm/OllamaProvider.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;;;AAuFH,uEAAuE;AAEvE;;;;;;;;GAQG;AACH,MAAa,sBAAuB,SAAQ,KAAK;IAC7B,IAAI,GAAG,wBAAwB,CAAC;IAClD,2CAA2C;IAClC,MAAM,CAA4C;IAC3D,iEAAiE;IACxD,OAAO,CAAS;IACzB,yEAAyE;IAChE,KAAK,CAAU;IACxB,oEAAoE;IAC3D,eAAe,CAAqB;IAE7C,YAAY,IAMX;QACC,KAAK,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACtD,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS;YAAE,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QACpF,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IACxD,CAAC;CACF;AAzBD,wDAyBC;AAED,SAAS,uBAAuB,CAAC,IAKhC;IACC,IAAI,IAAI,CAAC,MAAM,KAAK,oBAAoB,EAAE,CAAC;QACzC,OAAO,CACL,mCAAmC,IAAI,CAAC,OAAO,IAAI;YACnD,2EAA2E;YA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