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