@cerebriline/llms 0.0.0-stage → 4.100.240

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 (204) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +15 -2
  3. package/dist/catalog/catalog-cline-recommended.d.ts +14 -0
  4. package/dist/catalog/catalog-cline-recommended.d.ts.map +1 -0
  5. package/dist/catalog/catalog-live.d.ts +64 -0
  6. package/dist/catalog/catalog-live.d.ts.map +1 -0
  7. package/dist/catalog/catalog.generated-access.d.ts +5 -0
  8. package/dist/catalog/catalog.generated-access.d.ts.map +1 -0
  9. package/dist/catalog/catalog.generated.d.ts +17 -0
  10. package/dist/catalog/catalog.generated.d.ts.map +1 -0
  11. package/dist/catalog/model-filters.d.ts +9 -0
  12. package/dist/catalog/model-filters.d.ts.map +1 -0
  13. package/dist/catalog/model-id-aliases.d.ts +11 -0
  14. package/dist/catalog/model-id-aliases.d.ts.map +1 -0
  15. package/dist/catalog/model-operation.d.ts +27 -0
  16. package/dist/catalog/model-operation.d.ts.map +1 -0
  17. package/dist/catalog/types.d.ts +367 -0
  18. package/dist/catalog/types.d.ts.map +1 -0
  19. package/dist/index.browser.d.ts +12 -0
  20. package/dist/index.browser.d.ts.map +1 -0
  21. package/dist/index.browser.js +16 -0
  22. package/dist/index.d.ts +30 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +272 -0
  25. package/dist/models.d.ts +10 -0
  26. package/dist/models.d.ts.map +1 -0
  27. package/dist/models.js +241 -0
  28. package/dist/providers/agent-slots.d.ts +100 -0
  29. package/dist/providers/agent-slots.d.ts.map +1 -0
  30. package/dist/providers/ai-sdk.d.ts +158 -0
  31. package/dist/providers/ai-sdk.d.ts.map +1 -0
  32. package/dist/providers/async.d.ts +2 -0
  33. package/dist/providers/async.d.ts.map +1 -0
  34. package/dist/providers/billing.d.ts +5 -0
  35. package/dist/providers/billing.d.ts.map +1 -0
  36. package/dist/providers/builtin-types.d.ts +34 -0
  37. package/dist/providers/builtin-types.d.ts.map +1 -0
  38. package/dist/providers/builtins-runtime.d.ts +3 -0
  39. package/dist/providers/builtins-runtime.d.ts.map +1 -0
  40. package/dist/providers/builtins.d.ts +30 -0
  41. package/dist/providers/builtins.d.ts.map +1 -0
  42. package/dist/providers/compat.d.ts +75 -0
  43. package/dist/providers/compat.d.ts.map +1 -0
  44. package/dist/providers/config.d.ts +521 -0
  45. package/dist/providers/config.d.ts.map +1 -0
  46. package/dist/providers/error-classification.d.ts +23 -0
  47. package/dist/providers/error-classification.d.ts.map +1 -0
  48. package/dist/providers/errors.d.ts +33 -0
  49. package/dist/providers/errors.d.ts.map +1 -0
  50. package/dist/providers/factory-registry.d.ts +92 -0
  51. package/dist/providers/factory-registry.d.ts.map +1 -0
  52. package/dist/providers/format.d.ts +2 -0
  53. package/dist/providers/format.d.ts.map +1 -0
  54. package/dist/providers/gateway.d.ts +123 -0
  55. package/dist/providers/gateway.d.ts.map +1 -0
  56. package/dist/providers/handler.d.ts +75 -0
  57. package/dist/providers/handler.d.ts.map +1 -0
  58. package/dist/providers/http.d.ts +10 -0
  59. package/dist/providers/http.d.ts.map +1 -0
  60. package/dist/providers/ids.d.ts +77 -0
  61. package/dist/providers/ids.d.ts.map +1 -0
  62. package/dist/providers/messages.d.ts +5 -0
  63. package/dist/providers/messages.d.ts.map +1 -0
  64. package/dist/providers/middleware/backoff.d.ts +11 -0
  65. package/dist/providers/middleware/backoff.d.ts.map +1 -0
  66. package/dist/providers/middleware/retry-empty-response.d.ts +74 -0
  67. package/dist/providers/middleware/retry-empty-response.d.ts.map +1 -0
  68. package/dist/providers/middleware/retry-rate-limit.d.ts +49 -0
  69. package/dist/providers/middleware/retry-rate-limit.d.ts.map +1 -0
  70. package/dist/providers/middleware/split-tool-images.d.ts +32 -0
  71. package/dist/providers/middleware/split-tool-images.d.ts.map +1 -0
  72. package/dist/providers/middleware/stream-part-classification.d.ts +33 -0
  73. package/dist/providers/middleware/stream-part-classification.d.ts.map +1 -0
  74. package/dist/providers/model-capabilities.d.ts +15 -0
  75. package/dist/providers/model-capabilities.d.ts.map +1 -0
  76. package/dist/providers/model-facts.d.ts +115 -0
  77. package/dist/providers/model-facts.d.ts.map +1 -0
  78. package/dist/providers/model-operations.d.ts +78 -0
  79. package/dist/providers/model-operations.d.ts.map +1 -0
  80. package/dist/providers/model-registry.d.ts +25 -0
  81. package/dist/providers/model-registry.d.ts.map +1 -0
  82. package/dist/providers/model-tools.d.ts +22 -0
  83. package/dist/providers/model-tools.d.ts.map +1 -0
  84. package/dist/providers/openai-codex-models.d.ts +11 -0
  85. package/dist/providers/openai-codex-models.d.ts.map +1 -0
  86. package/dist/providers/provider-ids.generated.d.ts +13 -0
  87. package/dist/providers/provider-ids.generated.d.ts.map +1 -0
  88. package/dist/providers/provider-keys.d.ts +13 -0
  89. package/dist/providers/provider-keys.d.ts.map +1 -0
  90. package/dist/providers/provider-request-capture.d.ts +10 -0
  91. package/dist/providers/provider-request-capture.d.ts.map +1 -0
  92. package/dist/providers/providers.generated.d.ts +19 -0
  93. package/dist/providers/providers.generated.d.ts.map +1 -0
  94. package/dist/providers/reasoning-history.d.ts +140 -0
  95. package/dist/providers/reasoning-history.d.ts.map +1 -0
  96. package/dist/providers/registry.d.ts +19 -0
  97. package/dist/providers/registry.d.ts.map +1 -0
  98. package/dist/providers/request-headers.d.ts +30 -0
  99. package/dist/providers/request-headers.d.ts.map +1 -0
  100. package/dist/providers/request-timings.d.ts +20 -0
  101. package/dist/providers/request-timings.d.ts.map +1 -0
  102. package/dist/providers/routing/anthropic-compatible.d.ts +35 -0
  103. package/dist/providers/routing/anthropic-compatible.d.ts.map +1 -0
  104. package/dist/providers/routing/bedrock-cache-point.d.ts +26 -0
  105. package/dist/providers/routing/bedrock-cache-point.d.ts.map +1 -0
  106. package/dist/providers/routing/generic-compatible.d.ts +10 -0
  107. package/dist/providers/routing/generic-compatible.d.ts.map +1 -0
  108. package/dist/providers/routing/glm-thinking.d.ts +16 -0
  109. package/dist/providers/routing/glm-thinking.d.ts.map +1 -0
  110. package/dist/providers/routing/minimax-thinking.d.ts +6 -0
  111. package/dist/providers/routing/minimax-thinking.d.ts.map +1 -0
  112. package/dist/providers/routing/portable-reasoning.d.ts +11 -0
  113. package/dist/providers/routing/portable-reasoning.d.ts.map +1 -0
  114. package/dist/providers/routing/provider-option-rules.d.ts +13 -0
  115. package/dist/providers/routing/provider-option-rules.d.ts.map +1 -0
  116. package/dist/providers/routing/provider-options-types.d.ts +57 -0
  117. package/dist/providers/routing/provider-options-types.d.ts.map +1 -0
  118. package/dist/providers/routing/provider-options.d.ts +27 -0
  119. package/dist/providers/routing/provider-options.d.ts.map +1 -0
  120. package/dist/providers/routing/reasoning-codecs.d.ts +4 -0
  121. package/dist/providers/routing/reasoning-codecs.d.ts.map +1 -0
  122. package/dist/providers/routing/reasoning-options.d.ts +8 -0
  123. package/dist/providers/routing/reasoning-options.d.ts.map +1 -0
  124. package/dist/providers/routing/utils.d.ts +31 -0
  125. package/dist/providers/routing/utils.d.ts.map +1 -0
  126. package/dist/providers/sdk-warnings.d.ts +14 -0
  127. package/dist/providers/sdk-warnings.d.ts.map +1 -0
  128. package/dist/providers/server-health.d.ts +66 -0
  129. package/dist/providers/server-health.d.ts.map +1 -0
  130. package/dist/providers/stream.d.ts +124 -0
  131. package/dist/providers/stream.d.ts.map +1 -0
  132. package/dist/providers/types.d.ts +10 -0
  133. package/dist/providers/types.d.ts.map +1 -0
  134. package/dist/providers/url.d.ts +3 -0
  135. package/dist/providers/url.d.ts.map +1 -0
  136. package/dist/providers/utils.d.ts +2 -0
  137. package/dist/providers/utils.d.ts.map +1 -0
  138. package/dist/providers/vendors/anthropic.d.ts +4 -0
  139. package/dist/providers/vendors/anthropic.d.ts.map +1 -0
  140. package/dist/providers/vendors/bedrock.d.ts +24 -0
  141. package/dist/providers/vendors/bedrock.d.ts.map +1 -0
  142. package/dist/providers/vendors/cline.d.ts +37 -0
  143. package/dist/providers/vendors/cline.d.ts.map +1 -0
  144. package/dist/providers/vendors/community.d.ts +8 -0
  145. package/dist/providers/vendors/community.d.ts.map +1 -0
  146. package/dist/providers/vendors/google.d.ts +12 -0
  147. package/dist/providers/vendors/google.d.ts.map +1 -0
  148. package/dist/providers/vendors/llamacpp-sampling.d.ts +130 -0
  149. package/dist/providers/vendors/llamacpp-sampling.d.ts.map +1 -0
  150. package/dist/providers/vendors/llamacpp-timings.d.ts +33 -0
  151. package/dist/providers/vendors/llamacpp-timings.d.ts.map +1 -0
  152. package/dist/providers/vendors/minimax-thinking.d.ts +5 -0
  153. package/dist/providers/vendors/minimax-thinking.d.ts.map +1 -0
  154. package/dist/providers/vendors/mistral.d.ts +4 -0
  155. package/dist/providers/vendors/mistral.d.ts.map +1 -0
  156. package/dist/providers/vendors/ollama-account.d.ts +128 -0
  157. package/dist/providers/vendors/ollama-account.d.ts.map +1 -0
  158. package/dist/providers/vendors/ollama-reachability.d.ts +42 -0
  159. package/dist/providers/vendors/ollama-reachability.d.ts.map +1 -0
  160. package/dist/providers/vendors/ollama-stall-watchdog.d.ts +86 -0
  161. package/dist/providers/vendors/ollama-stall-watchdog.d.ts.map +1 -0
  162. package/dist/providers/vendors/ollama-tool-images.d.ts +67 -0
  163. package/dist/providers/vendors/ollama-tool-images.d.ts.map +1 -0
  164. package/dist/providers/vendors/ollama.d.ts +256 -0
  165. package/dist/providers/vendors/ollama.d.ts.map +1 -0
  166. package/dist/providers/vendors/openai-compatible.d.ts +16 -0
  167. package/dist/providers/vendors/openai-compatible.d.ts.map +1 -0
  168. package/dist/providers/vendors/openai.d.ts +4 -0
  169. package/dist/providers/vendors/openai.d.ts.map +1 -0
  170. package/dist/providers/vendors/opencoti-agent-window.d.ts +44 -0
  171. package/dist/providers/vendors/opencoti-agent-window.d.ts.map +1 -0
  172. package/dist/providers/vendors/opencoti-kv-pressure.d.ts +322 -0
  173. package/dist/providers/vendors/opencoti-kv-pressure.d.ts.map +1 -0
  174. package/dist/providers/vendors/opencoti-liveness.d.ts +177 -0
  175. package/dist/providers/vendors/opencoti-liveness.d.ts.map +1 -0
  176. package/dist/providers/vendors/opencoti-window.d.ts +56 -0
  177. package/dist/providers/vendors/opencoti-window.d.ts.map +1 -0
  178. package/dist/providers/vendors/opencoti.d.ts +335 -0
  179. package/dist/providers/vendors/opencoti.d.ts.map +1 -0
  180. package/dist/providers/vendors/polykv-lead.d.ts +94 -0
  181. package/dist/providers/vendors/polykv-lead.d.ts.map +1 -0
  182. package/dist/providers/vendors/polykv-swarm.d.ts +705 -0
  183. package/dist/providers/vendors/polykv-swarm.d.ts.map +1 -0
  184. package/dist/providers/vendors/polykv.d.ts +958 -0
  185. package/dist/providers/vendors/polykv.d.ts.map +1 -0
  186. package/dist/providers/vendors/types.d.ts +176 -0
  187. package/dist/providers/vendors/types.d.ts.map +1 -0
  188. package/dist/providers/vendors/vertex.d.ts +4 -0
  189. package/dist/providers/vendors/vertex.d.ts.map +1 -0
  190. package/dist/providers/vendors/xollama-engine.d.ts +57 -0
  191. package/dist/providers/vendors/xollama-engine.d.ts.map +1 -0
  192. package/dist/providers/vendors/xollama.d.ts +188 -0
  193. package/dist/providers/vendors/xollama.d.ts.map +1 -0
  194. package/dist/providers.browser.d.ts +3 -0
  195. package/dist/providers.browser.d.ts.map +1 -0
  196. package/dist/providers.browser.js +16 -0
  197. package/dist/providers.d.ts +12 -0
  198. package/dist/providers.d.ts.map +1 -0
  199. package/dist/providers.js +272 -0
  200. package/dist/services/langfuse-telemetry.d.ts +19 -0
  201. package/dist/services/langfuse-telemetry.d.ts.map +1 -0
  202. package/dist/transcription.d.ts +53 -0
  203. package/dist/transcription.d.ts.map +1 -0
  204. package/package.json +84 -5
@@ -0,0 +1,256 @@
1
+ import type { BasicLogger, GatewayProviderContext, GatewayResolvedProviderConfig, GatewayStreamRequest } from "@cerebriline/shared";
2
+ import { type CallSettings } from "ai";
3
+ import type { ProviderSamplingOptions } from "../config";
4
+ import type { ProviderFactoryResult } from "./types";
5
+ /** See {@link OLLAMA_DEFAULT_CONTEXT_WINDOW} — re-exported under the wire-format name. */
6
+ export declare const OLLAMA_DEFAULT_NUM_CTX = 32768;
7
+ /**
8
+ * Normalize a configured base URL to the `baseURL` this provider expects.
9
+ *
10
+ * The API prefix belongs *in* the base URL here: the package appends bare
11
+ * paths (`/chat`, `/show`) and its own default is
12
+ * `http://127.0.0.1:11434/api`. This is the opposite of the `ollama` client
13
+ * the previous provider used, which took a bare origin as its `host` and
14
+ * appended `/api/...` itself — so returning an origin sends every request to
15
+ * `/chat`, which Ollama answers with a plain `404 page not found`.
16
+ *
17
+ * Users configure hosts like `http://localhost:11434` or `https://ollama.com`;
18
+ * configs saved by the 4.0.0 OpenAI-compatible routing may carry a `/v1`
19
+ * suffix, and native-API configs an `/api` one. All three normalize to the
20
+ * same origin, and `/api` is then appended exactly once.
21
+ */
22
+ export declare function normalizeOllamaBaseUrl(baseUrl: string | undefined): string | undefined;
23
+ /**
24
+ * Resolve the `num_ctx` to request from the resolved model's context window.
25
+ * `num_ctx` stays an Ollama wire-format detail: callers express intent through
26
+ * the provider-neutral model `contextWindow` (from the model catalog or the
27
+ * user's configured context window), and this boundary maps it onto the wire.
28
+ */
29
+ export declare function readOllamaNumCtx(context: GatewayProviderContext): number;
30
+ /** The model's own `num_ctx`, if it has been looked up and it has one. */
31
+ export declare function readDeclaredNumCtx(baseUrl: string | undefined, modelId: string | undefined): number | undefined;
32
+ /** The architecture the model declares, if it has been looked up. */
33
+ export declare function readDeclaredFamily(baseUrl: string | undefined, modelId: string | undefined): string | undefined;
34
+ /** The trained window, if it has been looked up and the model declares one. */
35
+ export declare function readDeclaredTrainedCtx(baseUrl: string | undefined, modelId: string | undefined): number | undefined;
36
+ /** Parse the architecture's `*.context_length` out of `/api/show`. */
37
+ export declare function parseDeclaredTrainedCtx(payload: unknown): number | undefined;
38
+ /**
39
+ * The window to load a model with, from every source the server offers.
40
+ *
41
+ * In order, and the order is the point:
42
+ *
43
+ * 1. `parameters.num_ctx` -- the Modelfile's own value. It is what the runner
44
+ * will use, so nothing may overrule it.
45
+ * 2. For a **cloud** model only, the `context_length` the recommendations list
46
+ * publishes, then the trained window from `/api/show`. A cloud model has no
47
+ * `num_ctx` to read and no local memory to run out of; the 32k default was
48
+ * costing a 262k model seven eighths of its context and compacting against a
49
+ * window eight times too small.
50
+ * 3. Nothing, and the caller falls back to {@link OLLAMA_DEFAULT_NUM_CTX}
51
+ * exactly as it did before.
52
+ *
53
+ * Both host applications must read this rather than `readDeclaredNumCtx`: the
54
+ * wire's `num_ctx` and the compaction budget are derived from one value in this
55
+ * fork, and they have drifted apart once per host every time they were not.
56
+ */
57
+ export declare function readResolvedOllamaWindow(baseUrl: string | undefined, modelId: string | undefined): number | undefined;
58
+ /** Parse `details.family` out of what `/api/show` returns. */
59
+ export declare function parseDeclaredFamily(payload: unknown): string | undefined;
60
+ /** The model's own `temperature` parameter, if it has been looked up and it has one. */
61
+ export declare function readDeclaredTemperature(baseUrl: string | undefined, modelId: string | undefined): number | undefined;
62
+ /** Parse `temperature` out of the `parameters` block `/api/show` returns. */
63
+ export declare function parseDeclaredTemperature(payload: unknown): number | undefined;
64
+ /**
65
+ * The model's own `think_budget_message`, if it has been looked up and it has
66
+ * one: what the server appends to reasoning it cuts at the budget. The
67
+ * capped-thinking detector matches it at the end of a think to tell a turn the
68
+ * server cut from one that simply thought for a long time.
69
+ */
70
+ export declare function readDeclaredThinkBudgetMessage(baseUrl: string | undefined, modelId: string | undefined): string | undefined;
71
+ /**
72
+ * Parse `think_budget_message` out of the `parameters` block. The value is
73
+ * prose, so it is quoted, with the Modelfile's backslash escapes.
74
+ */
75
+ export declare function parseDeclaredThinkBudgetMessage(payload: unknown): string | undefined;
76
+ /** The think budget the server resolves for a request, from `/api/show`. */
77
+ export interface OllamaThinkBudget {
78
+ /** The level or count the server reported it from. */
79
+ level: string;
80
+ budgetTokens: number;
81
+ }
82
+ /**
83
+ * Ask the server what think budget it will hold a request to.
84
+ *
85
+ * `/api/show` given the request's `think` and options answers with
86
+ * `think_budget_tokens` on the think-budget builds, which is the number the
87
+ * server enforces -- a level's share of `min(num_predict, num_ctx)`, or the
88
+ * model's own `think_budget` where no level outranks it. Asked rather than
89
+ * computed so every host states the number the server enforces. An older
90
+ * build answers without the field: nothing to report, which is `undefined`
91
+ * rather than a guess.
92
+ */
93
+ export declare function probeOllamaThinkBudget(baseUrl: string | undefined, modelId: string, query: {
94
+ think?: string;
95
+ numPredict?: number;
96
+ numCtx?: number;
97
+ }, fetchImpl: typeof fetch, attempts?: number): Promise<OllamaThinkBudget | undefined>;
98
+ /** Parse `num_ctx` out of the `parameters` block `/api/show` returns. */
99
+ export declare function parseDeclaredNumCtx(payload: unknown): number | undefined;
100
+ /**
101
+ * Ask the server what the model's own context window is, once per model.
102
+ *
103
+ * Awaited by the factory rather than left to the first request: resolving it
104
+ * late would send turn one at the default and every later turn at the real
105
+ * value, and a changed `num_ctx` makes Ollama reload the model mid-task.
106
+ *
107
+ * Failure is not an error. A server that does not answer, or answers something
108
+ * this cannot read, leaves the entry null and the caller falls back exactly as
109
+ * it did before.
110
+ */
111
+ export declare function primeDeclaredNumCtx(baseUrl: string | undefined, modelId: string | undefined, fetchImpl: typeof fetch, logger?: BasicLogger): Promise<void>;
112
+ /** Test seam: forget every looked-up window and family. */
113
+ export declare function resetDeclaredNumCtx(): void;
114
+ /**
115
+ * Resolve the `num_predict` to request from the resolved model's output cap.
116
+ *
117
+ * `ollama-ai-provider-v2` names `num_predict` in its provider-options schema
118
+ * and nowhere else: it never derives one from the request's
119
+ * `maxOutputTokens`. So the per-turn cap the agent computes — and states in the
120
+ * system prompt — reached Ollama on no request at all, and two things followed
121
+ * from that.
122
+ *
123
+ * The cap itself was not enforced. Worse, Ollama sizes the thinking budget from
124
+ * `min(num_predict, num_ctx)`: with no `num_predict` the whole context window is
125
+ * the base, so a 128k-context model on effort `medium` (one quarter) was
126
+ * allowed 32,000 thinking tokens while the prompt told it 8,000 — the figure
127
+ * `/api/show` reports when asked with the cap the session believes it is
128
+ * sending. Measured on a real session: single thinking blocks of ~16,000
129
+ * tokens, twice the stated bound, and runs ending on "reached the maximum
130
+ * output token limit" with the entire allowance spent reasoning and no tool
131
+ * call emitted.
132
+ *
133
+ * Sending it makes both numbers true at once, which is the point: the bound in
134
+ * the prompt is only worth stating if the server holds the model to it.
135
+ */
136
+ export declare function readOllamaNumPredict(request: Pick<GatewayStreamRequest, "maxTokens">, context: GatewayProviderContext): number | undefined;
137
+ /**
138
+ * Time to wait for the response to start when no timeout is configured.
139
+ *
140
+ * Deliberately generous: Ollama holds `/api/chat` open while it cold-loads
141
+ * the model and only sends response headers once loading finishes, so with a
142
+ * large model (or a large `num_ctx`, which this vendor requests) the first
143
+ * request of a session routinely takes minutes before the stream starts.
144
+ * A tight budget here turns every cold load into a user-facing timeout error
145
+ * (see cline/cline#12829 — the legacy handler's 30s default was only
146
+ * tolerable because its retry decorator silently re-issued the request until
147
+ * the model was loaded). Unreachable servers are not this timeout's job:
148
+ * connection-level failures (refused, DNS) reject on their own immediately,
149
+ * and users can always cancel a request from the UI. This only bounds the
150
+ * accepted-but-silent case, and 5 minutes matches the header-timeout default
151
+ * other AI SDK-based agents use.
152
+ */
153
+ export declare const OLLAMA_DEFAULT_TIMEOUT_MS = 300000;
154
+ /**
155
+ * Read the configured request timeout (the legacy `requestTimeoutMs`
156
+ * setting); zero/invalid values fall back to the default.
157
+ */
158
+ export declare function readOllamaTimeoutMs(config: GatewayResolvedProviderConfig): number;
159
+ /**
160
+ * Supply the dispatcher instead of having this module find one.
161
+ *
162
+ * For hosts that bundle: the injected value is used as-is and no import is
163
+ * attempted. Passing `undefined` clears an earlier injection and lets the
164
+ * import run again, which is what tests need between cases.
165
+ */
166
+ export declare function setOllamaNoStreamTimeoutDispatcher(dispatcher: unknown): void;
167
+ /**
168
+ * Whether a dispatcher is in force, for hosts that want to say so in a log.
169
+ *
170
+ * Exported because the absence of one is invisible from the outside and was
171
+ * invisible for four releases: the wrapper works either way, and the only
172
+ * symptom is a timeout minutes later that looks like a network fault.
173
+ */
174
+ export declare function hasOllamaNoStreamTimeoutDispatcher(): boolean;
175
+ export declare function setOllamaFetch(value: typeof fetch | undefined): void;
176
+ export declare function hasOllamaFetch(): boolean;
177
+ /**
178
+ * The same two facts, for the other vendors that talk to a local server.
179
+ *
180
+ * The undici problem is not Ollama's -- it belongs to any endpoint whose
181
+ * prefill can outrun a five-minute header timeout, which is every local engine
182
+ * serving a long agentic prompt. The state stays here rather than being
183
+ * duplicated: one dispatcher, one fetch, one place a host installs them. The
184
+ * names are the debt from this having been an Ollama-only concern first.
185
+ */
186
+ export declare function resolveLocalStreamDispatcher(): Promise<unknown>;
187
+ /** The fetch known to honour `init.dispatcher`, if a host handed one over. */
188
+ export declare function localStreamFetch(): typeof fetch | undefined;
189
+ export declare function withOllamaResponseTimeout(baseFetch: typeof fetch, timeoutMs: number, dispatcher?: unknown, options?: {
190
+ logger?: BasicLogger;
191
+ }): typeof fetch;
192
+ /**
193
+ * Translate configured sampling parameters onto the wire.
194
+ *
195
+ * Only fields the user actually set are sent. An unset field is not a zero: a
196
+ * local model carries a sampler in its Modelfile — often one that was tuned and
197
+ * measured against that quant — and a client that sends a complete set on every
198
+ * request silently replaces it. An empty `stop` list is dropped for the same
199
+ * reason.
200
+ */
201
+ export declare function buildOllamaSamplingOptions(sampling: ProviderSamplingOptions | undefined): Record<string, unknown>;
202
+ /** Read the sampling parameters carried on the resolved provider config. */
203
+ export declare function readOllamaSamplingOptions(config: GatewayResolvedProviderConfig): ProviderSamplingOptions | undefined;
204
+ export declare function createOllamaProviderModule(config: GatewayResolvedProviderConfig, context: GatewayProviderContext): Promise<ProviderFactoryResult>;
205
+ /**
206
+ * The effort to offer where a level has to be named and none was chosen.
207
+ *
208
+ * `medium` rather than the strongest: asking a model to think is not asking it
209
+ * to think as hard as it can. On Ollama an effort level also bounds how much of
210
+ * the response the model may spend inside the thinking block, so the middle of
211
+ * the scale is the reading that leaves room for an answer.
212
+ *
213
+ * It is deliberately **not** sent for a request that named no level. A level is
214
+ * a budget here, and it outranks the model's own `PARAMETER think_budget`, so
215
+ * naming one on the user's behalf silently overrides the model — see
216
+ * `provider.ollama.native-options`, which sends a bare `think: true` instead.
217
+ */
218
+ export declare const OLLAMA_DEFAULT_REASONING_EFFORT: "medium";
219
+ /**
220
+ * Ollama's stream config: the shared one, plus a level whenever the request did
221
+ * not settle on one.
222
+ *
223
+ * The AI SDK's vocabulary is a scale of efforts — `none`, `minimal`, `low`,
224
+ * `medium`, `high`, `xhigh` — with no plain "on". `provider-default` is the
225
+ * nearest thing, but it means "whatever the model was constructed with", and
226
+ * this vendor constructs models with no reasoning setting precisely so
227
+ * reasoning stays a per-request decision.
228
+ *
229
+ * A request that named no level gets no level from here. It used to get
230
+ * `medium`, on the reasoning that an absent config means "never asked" rather
231
+ * than "off" — which is still true, and still matters: with `think` absent a
232
+ * reasoning model thinks into `content` instead, measured as a turn at ~51k
233
+ * input with 32,000 output tokens available ending on "Model reached the
234
+ * maximum output token limit before completing the turn".
235
+ *
236
+ * What was wrong was answering that with a level. On Ollama a level *is* a
237
+ * budget and it outranks the model's own `PARAMETER think_budget`, so the
238
+ * default capped an unbounded model at 2,000 tokens and halved a model that
239
+ * declared `high`. Saying "think" without saying how much is now
240
+ * `provider.ollama.native-options`'s job, as a bare `think: true`; the
241
+ * measurements are in the comment there.
242
+ *
243
+ * This function keeps only the half that is genuinely top-level: a level the
244
+ * user chose, passed through untouched, and `"none"` for an explicit off. The
245
+ * portable resolver's `medium`-for-`enabled: true` is cleared, because that is
246
+ * the synthesis this exists to undo.
247
+ *
248
+ * An explicit `enabled: false` still means off — it reaches
249
+ * `buildAiSdkStreamConfig` as `"none"`, so `config.reasoning` is already set
250
+ * and this leaves it alone. Only the unset case is filled in, and only here:
251
+ * Ollama is the provider whose wire format has a `think` field, so it is the
252
+ * provider that has to say what silence means.
253
+ *
254
+ */
255
+ export declare function buildOllamaStreamConfig(request: GatewayStreamRequest, context: GatewayProviderContext): Partial<CallSettings>;
256
+ //# sourceMappingURL=ollama.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ollama.d.ts","sourceRoot":"","sources":["../../../src/providers/vendors/ollama.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EACX,WAAW,EACX,sBAAsB,EACtB,6BAA6B,EAC7B,oBAAoB,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,IAAI,CAAC;AAI1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAuBzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAerD,0FAA0F;AAC1F,eAAO,MAAM,sBAAsB,QAAgC,CAAC;AAEpE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACrC,OAAO,EAAE,MAAM,GAAG,SAAS,GACzB,MAAM,GAAG,SAAS,CAMpB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,CAaxE;AAuBD,0EAA0E;AAC1E,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,GACzB,MAAM,GAAG,SAAS,CAKpB;AAiBD,qEAAqE;AACrE,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,GACzB,MAAM,GAAG,SAAS,CAKpB;AAkBD,+EAA+E;AAC/E,wBAAgB,sBAAsB,CACrC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,GACzB,MAAM,GAAG,SAAS,CAKpB;AAED,sEAAsE;AACtE,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAiB5E;AAED;;;;;;;;;;;;;;;;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;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACzC,QAAQ,EAAE,uBAAuB,GAAG,SAAS,GAC3C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA2BzB;AAED,4EAA4E;AAC5E,wBAAgB,yBAAyB,CACxC,MAAM,EAAE,6BAA6B,GACnC,uBAAuB,GAAG,SAAS,CAKrC;AAED,wBAAsB,0BAA0B,CAC/C,MAAM,EAAE,6BAA6B,EACrC,OAAO,EAAE,sBAAsB,GAC7B,OAAO,CAAC,qBAAqB,CAAC,CAyKhC;AAqFD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,+BAA+B,EAAG,QAAiB,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,uBAAuB,CACtC,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,sBAAsB,GAC7B,OAAO,CAAC,YAAY,CAAC,CAwBvB"}
@@ -0,0 +1,16 @@
1
+ import type { GatewayProviderContext, GatewayResolvedProviderConfig } from "@cerebriline/shared";
2
+ import type { ProviderFactoryResult } from "./types";
3
+ /**
4
+ * OpenAI's chat-completions API rejects `max_tokens` for reasoning-era
5
+ * models ("Unsupported parameter: 'max_tokens' is not supported with this
6
+ * model. Use 'max_completion_tokens' instead."). Rename the parameter only
7
+ * for model ids that require it: OpenAI, Azure OpenAI, and the major
8
+ * OpenAI-compatible gateways (OpenRouter, LiteLLM) all accept
9
+ * `max_completion_tokens`, while older third-party servers that only know
10
+ * `max_tokens` do not serve o-series/gpt-5 model ids — so every other
11
+ * request keeps its exact current wire format.
12
+ */
13
+ export declare function withMaxCompletionTokensForReasoningModels(body: Record<string, unknown>): Record<string, unknown>;
14
+ export declare function createSuccessDataResponseFetch(baseFetch: typeof fetch): typeof fetch;
15
+ export declare function createOpenAICompatibleProviderModule(config: GatewayResolvedProviderConfig, context: GatewayProviderContext): Promise<ProviderFactoryResult>;
16
+ //# sourceMappingURL=openai-compatible.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-compatible.d.ts","sourceRoot":"","sources":["../../../src/providers/vendors/openai-compatible.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,sBAAsB,EACtB,6BAA6B,EAC7B,MAAM,eAAe,CAAC;AAQvB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AA8HrD;;;;;;;;;GASG;AACH,wBAAgB,yCAAyC,CACxD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAezB;AAaD,wBAAgB,8BAA8B,CAC7C,SAAS,EAAE,OAAO,KAAK,GACrB,OAAO,KAAK,CA0Cd;AAED,wBAAsB,oCAAoC,CACzD,MAAM,EAAE,6BAA6B,EACrC,OAAO,EAAE,sBAAsB,GAC7B,OAAO,CAAC,qBAAqB,CAAC,CAmFhC"}
@@ -0,0 +1,4 @@
1
+ import type { GatewayProviderContext, GatewayResolvedProviderConfig } from "@cerebriline/shared";
2
+ import type { ProviderFactoryResult } from "./types";
3
+ export declare function createOpenAIProviderModule(config: GatewayResolvedProviderConfig, context: GatewayProviderContext): Promise<ProviderFactoryResult>;
4
+ //# sourceMappingURL=openai.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/providers/vendors/openai.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,sBAAsB,EACtB,6BAA6B,EAC7B,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAcrD,wBAAsB,0BAA0B,CAC/C,MAAM,EAAE,6BAA6B,EACrC,OAAO,EAAE,sBAAsB,GAC7B,OAAO,CAAC,qBAAqB,CAAC,CAyEhC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * "Agent window": the floor an agent's opencoti session accepts, per node.
3
+ *
4
+ * Ruled 2026-09-25. A node's slider is a share between two ends -- 100% is the
5
+ * node's context window, 0% the minimum one turn needs (system prompt + tool
6
+ * schemas + the output cap, thinking included) -- so "50%" means the same
7
+ * thing whatever window the node is set to. The session asks for the node's
8
+ * window (`num_ctx`) and floors at that share (`num_ctx_min`); the engine
9
+ * grants the largest window that fits, never below the floor
10
+ * (`ctx_min_negotiation_v1`), and below it the refusal is waited out.
11
+ *
12
+ * The floor is computed here, at the wire, because this is the one place both
13
+ * halves of the minimum are exact: the system turn and the tool schemas are in
14
+ * the body as they will be charged, and the output cap is the `max_tokens` the
15
+ * gateway resolved for this request. The arithmetic is `@cerebriline/shared`'s, the
16
+ * same the settings panel shows.
17
+ */
18
+ /** What a node says about its agents' windows, carried on the provider config. */
19
+ export interface OpencotiAgentWindowOptions {
20
+ /** 0..100; see `normalizeAgentWindowShare`. */
21
+ sharePercent?: number;
22
+ }
23
+ /** The node's window and its share, once both are known. */
24
+ export interface OpencotiAgentWindow {
25
+ contextWindow: number;
26
+ sharePercent?: number;
27
+ }
28
+ /**
29
+ * The agent window for this request, or `undefined` when the provider config
30
+ * carries none or there is no window to take a share of.
31
+ *
32
+ * The window is the model's as the connection resolved it -- for an agent
33
+ * node, the node's own (the host puts it there, ahead of any catalog figure).
34
+ */
35
+ export declare function readOpencotiAgentWindow(section: unknown, contextWindow: number | undefined): OpencotiAgentWindow | undefined;
36
+ /** The cap on the wire: `max_tokens`, its newer spelling, or llama.cpp's. */
37
+ export declare function wireOutputCap(body: Record<string, unknown>): number | undefined;
38
+ /**
39
+ * The floor for this request: `minimum + share × (window − minimum)`, with the
40
+ * minimum measured off the body -- its system turn, its tool schemas, and its
41
+ * output cap (`fallbackOutputCap` when the body declares none).
42
+ */
43
+ export declare function agentWindowFloorForBody(body: Record<string, unknown>, window: OpencotiAgentWindow, fallbackOutputCap?: number): number | undefined;
44
+ //# sourceMappingURL=opencoti-agent-window.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencoti-agent-window.d.ts","sourceRoot":"","sources":["../../../src/providers/vendors/opencoti-agent-window.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAQH,kFAAkF;AAClF,MAAM,WAAW,0BAA0B;IAC1C,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,4DAA4D;AAC5D,MAAM,WAAW,mBAAmB;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAKD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACtC,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,MAAM,GAAG,SAAS,GAC/B,mBAAmB,GAAG,SAAS,CAWjC;AAkBD,6EAA6E;AAC7E,wBAAgB,aAAa,CAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,MAAM,GAAG,SAAS,CAQpB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,EAAE,mBAAmB,EAC3B,iBAAiB,CAAC,EAAE,MAAM,GACxB,MAAM,GAAG,SAAS,CA2BpB"}