@cerebriline/llms 0.0.0-stage → 4.100.241
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +15 -2
- package/dist/catalog/catalog-cline-recommended.d.ts +14 -0
- package/dist/catalog/catalog-cline-recommended.d.ts.map +1 -0
- package/dist/catalog/catalog-live.d.ts +64 -0
- package/dist/catalog/catalog-live.d.ts.map +1 -0
- package/dist/catalog/catalog.generated-access.d.ts +5 -0
- package/dist/catalog/catalog.generated-access.d.ts.map +1 -0
- package/dist/catalog/catalog.generated.d.ts +17 -0
- package/dist/catalog/catalog.generated.d.ts.map +1 -0
- package/dist/catalog/model-filters.d.ts +9 -0
- package/dist/catalog/model-filters.d.ts.map +1 -0
- package/dist/catalog/model-id-aliases.d.ts +11 -0
- package/dist/catalog/model-id-aliases.d.ts.map +1 -0
- package/dist/catalog/model-operation.d.ts +27 -0
- package/dist/catalog/model-operation.d.ts.map +1 -0
- package/dist/catalog/types.d.ts +367 -0
- package/dist/catalog/types.d.ts.map +1 -0
- package/dist/index.browser.d.ts +12 -0
- package/dist/index.browser.d.ts.map +1 -0
- package/dist/index.browser.js +16 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +272 -0
- package/dist/models.d.ts +10 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +241 -0
- package/dist/providers/agent-slots.d.ts +100 -0
- package/dist/providers/agent-slots.d.ts.map +1 -0
- package/dist/providers/ai-sdk.d.ts +158 -0
- package/dist/providers/ai-sdk.d.ts.map +1 -0
- package/dist/providers/async.d.ts +2 -0
- package/dist/providers/async.d.ts.map +1 -0
- package/dist/providers/billing.d.ts +5 -0
- package/dist/providers/billing.d.ts.map +1 -0
- package/dist/providers/builtin-types.d.ts +34 -0
- package/dist/providers/builtin-types.d.ts.map +1 -0
- package/dist/providers/builtins-runtime.d.ts +3 -0
- package/dist/providers/builtins-runtime.d.ts.map +1 -0
- package/dist/providers/builtins.d.ts +30 -0
- package/dist/providers/builtins.d.ts.map +1 -0
- package/dist/providers/compat.d.ts +75 -0
- package/dist/providers/compat.d.ts.map +1 -0
- package/dist/providers/config.d.ts +521 -0
- package/dist/providers/config.d.ts.map +1 -0
- package/dist/providers/error-classification.d.ts +23 -0
- package/dist/providers/error-classification.d.ts.map +1 -0
- package/dist/providers/errors.d.ts +33 -0
- package/dist/providers/errors.d.ts.map +1 -0
- package/dist/providers/factory-registry.d.ts +92 -0
- package/dist/providers/factory-registry.d.ts.map +1 -0
- package/dist/providers/format.d.ts +2 -0
- package/dist/providers/format.d.ts.map +1 -0
- package/dist/providers/gateway.d.ts +123 -0
- package/dist/providers/gateway.d.ts.map +1 -0
- package/dist/providers/handler.d.ts +75 -0
- package/dist/providers/handler.d.ts.map +1 -0
- package/dist/providers/http.d.ts +10 -0
- package/dist/providers/http.d.ts.map +1 -0
- package/dist/providers/ids.d.ts +77 -0
- package/dist/providers/ids.d.ts.map +1 -0
- package/dist/providers/messages.d.ts +5 -0
- package/dist/providers/messages.d.ts.map +1 -0
- package/dist/providers/middleware/backoff.d.ts +11 -0
- package/dist/providers/middleware/backoff.d.ts.map +1 -0
- package/dist/providers/middleware/retry-empty-response.d.ts +74 -0
- package/dist/providers/middleware/retry-empty-response.d.ts.map +1 -0
- package/dist/providers/middleware/retry-rate-limit.d.ts +49 -0
- package/dist/providers/middleware/retry-rate-limit.d.ts.map +1 -0
- package/dist/providers/middleware/split-tool-images.d.ts +32 -0
- package/dist/providers/middleware/split-tool-images.d.ts.map +1 -0
- package/dist/providers/middleware/stream-part-classification.d.ts +33 -0
- package/dist/providers/middleware/stream-part-classification.d.ts.map +1 -0
- package/dist/providers/model-capabilities.d.ts +15 -0
- package/dist/providers/model-capabilities.d.ts.map +1 -0
- package/dist/providers/model-facts.d.ts +115 -0
- package/dist/providers/model-facts.d.ts.map +1 -0
- package/dist/providers/model-operations.d.ts +78 -0
- package/dist/providers/model-operations.d.ts.map +1 -0
- package/dist/providers/model-registry.d.ts +25 -0
- package/dist/providers/model-registry.d.ts.map +1 -0
- package/dist/providers/model-tools.d.ts +22 -0
- package/dist/providers/model-tools.d.ts.map +1 -0
- package/dist/providers/openai-codex-models.d.ts +11 -0
- package/dist/providers/openai-codex-models.d.ts.map +1 -0
- package/dist/providers/provider-ids.generated.d.ts +13 -0
- package/dist/providers/provider-ids.generated.d.ts.map +1 -0
- package/dist/providers/provider-keys.d.ts +13 -0
- package/dist/providers/provider-keys.d.ts.map +1 -0
- package/dist/providers/provider-request-capture.d.ts +10 -0
- package/dist/providers/provider-request-capture.d.ts.map +1 -0
- package/dist/providers/providers.generated.d.ts +19 -0
- package/dist/providers/providers.generated.d.ts.map +1 -0
- package/dist/providers/reasoning-history.d.ts +140 -0
- package/dist/providers/reasoning-history.d.ts.map +1 -0
- package/dist/providers/registry.d.ts +19 -0
- package/dist/providers/registry.d.ts.map +1 -0
- package/dist/providers/request-headers.d.ts +30 -0
- package/dist/providers/request-headers.d.ts.map +1 -0
- package/dist/providers/request-timings.d.ts +20 -0
- package/dist/providers/request-timings.d.ts.map +1 -0
- package/dist/providers/routing/anthropic-compatible.d.ts +35 -0
- package/dist/providers/routing/anthropic-compatible.d.ts.map +1 -0
- package/dist/providers/routing/bedrock-cache-point.d.ts +26 -0
- package/dist/providers/routing/bedrock-cache-point.d.ts.map +1 -0
- package/dist/providers/routing/generic-compatible.d.ts +10 -0
- package/dist/providers/routing/generic-compatible.d.ts.map +1 -0
- package/dist/providers/routing/glm-thinking.d.ts +16 -0
- package/dist/providers/routing/glm-thinking.d.ts.map +1 -0
- package/dist/providers/routing/minimax-thinking.d.ts +6 -0
- package/dist/providers/routing/minimax-thinking.d.ts.map +1 -0
- package/dist/providers/routing/portable-reasoning.d.ts +11 -0
- package/dist/providers/routing/portable-reasoning.d.ts.map +1 -0
- package/dist/providers/routing/provider-option-rules.d.ts +13 -0
- package/dist/providers/routing/provider-option-rules.d.ts.map +1 -0
- package/dist/providers/routing/provider-options-types.d.ts +57 -0
- package/dist/providers/routing/provider-options-types.d.ts.map +1 -0
- package/dist/providers/routing/provider-options.d.ts +27 -0
- package/dist/providers/routing/provider-options.d.ts.map +1 -0
- package/dist/providers/routing/reasoning-codecs.d.ts +4 -0
- package/dist/providers/routing/reasoning-codecs.d.ts.map +1 -0
- package/dist/providers/routing/reasoning-options.d.ts +8 -0
- package/dist/providers/routing/reasoning-options.d.ts.map +1 -0
- package/dist/providers/routing/utils.d.ts +31 -0
- package/dist/providers/routing/utils.d.ts.map +1 -0
- package/dist/providers/sdk-warnings.d.ts +14 -0
- package/dist/providers/sdk-warnings.d.ts.map +1 -0
- package/dist/providers/server-health.d.ts +66 -0
- package/dist/providers/server-health.d.ts.map +1 -0
- package/dist/providers/stream.d.ts +124 -0
- package/dist/providers/stream.d.ts.map +1 -0
- package/dist/providers/types.d.ts +10 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/url.d.ts +3 -0
- package/dist/providers/url.d.ts.map +1 -0
- package/dist/providers/utils.d.ts +2 -0
- package/dist/providers/utils.d.ts.map +1 -0
- package/dist/providers/vendors/anthropic.d.ts +4 -0
- package/dist/providers/vendors/anthropic.d.ts.map +1 -0
- package/dist/providers/vendors/bedrock.d.ts +24 -0
- package/dist/providers/vendors/bedrock.d.ts.map +1 -0
- package/dist/providers/vendors/cline.d.ts +37 -0
- package/dist/providers/vendors/cline.d.ts.map +1 -0
- package/dist/providers/vendors/community.d.ts +8 -0
- package/dist/providers/vendors/community.d.ts.map +1 -0
- package/dist/providers/vendors/google.d.ts +12 -0
- package/dist/providers/vendors/google.d.ts.map +1 -0
- package/dist/providers/vendors/llamacpp-sampling.d.ts +130 -0
- package/dist/providers/vendors/llamacpp-sampling.d.ts.map +1 -0
- package/dist/providers/vendors/llamacpp-timings.d.ts +33 -0
- package/dist/providers/vendors/llamacpp-timings.d.ts.map +1 -0
- package/dist/providers/vendors/minimax-thinking.d.ts +5 -0
- package/dist/providers/vendors/minimax-thinking.d.ts.map +1 -0
- package/dist/providers/vendors/mistral.d.ts +4 -0
- package/dist/providers/vendors/mistral.d.ts.map +1 -0
- package/dist/providers/vendors/ollama-account.d.ts +128 -0
- package/dist/providers/vendors/ollama-account.d.ts.map +1 -0
- package/dist/providers/vendors/ollama-reachability.d.ts +42 -0
- package/dist/providers/vendors/ollama-reachability.d.ts.map +1 -0
- package/dist/providers/vendors/ollama-stall-watchdog.d.ts +86 -0
- package/dist/providers/vendors/ollama-stall-watchdog.d.ts.map +1 -0
- package/dist/providers/vendors/ollama-tool-images.d.ts +67 -0
- package/dist/providers/vendors/ollama-tool-images.d.ts.map +1 -0
- package/dist/providers/vendors/ollama.d.ts +256 -0
- package/dist/providers/vendors/ollama.d.ts.map +1 -0
- package/dist/providers/vendors/openai-compatible.d.ts +16 -0
- package/dist/providers/vendors/openai-compatible.d.ts.map +1 -0
- package/dist/providers/vendors/openai.d.ts +4 -0
- package/dist/providers/vendors/openai.d.ts.map +1 -0
- package/dist/providers/vendors/opencoti-agent-window.d.ts +44 -0
- package/dist/providers/vendors/opencoti-agent-window.d.ts.map +1 -0
- package/dist/providers/vendors/opencoti-kv-pressure.d.ts +322 -0
- package/dist/providers/vendors/opencoti-kv-pressure.d.ts.map +1 -0
- package/dist/providers/vendors/opencoti-liveness.d.ts +177 -0
- package/dist/providers/vendors/opencoti-liveness.d.ts.map +1 -0
- package/dist/providers/vendors/opencoti-window.d.ts +56 -0
- package/dist/providers/vendors/opencoti-window.d.ts.map +1 -0
- package/dist/providers/vendors/opencoti.d.ts +335 -0
- package/dist/providers/vendors/opencoti.d.ts.map +1 -0
- package/dist/providers/vendors/polykv-lead.d.ts +94 -0
- package/dist/providers/vendors/polykv-lead.d.ts.map +1 -0
- package/dist/providers/vendors/polykv-swarm.d.ts +705 -0
- package/dist/providers/vendors/polykv-swarm.d.ts.map +1 -0
- package/dist/providers/vendors/polykv.d.ts +958 -0
- package/dist/providers/vendors/polykv.d.ts.map +1 -0
- package/dist/providers/vendors/types.d.ts +176 -0
- package/dist/providers/vendors/types.d.ts.map +1 -0
- package/dist/providers/vendors/vertex.d.ts +4 -0
- package/dist/providers/vendors/vertex.d.ts.map +1 -0
- package/dist/providers/vendors/xollama-engine.d.ts +57 -0
- package/dist/providers/vendors/xollama-engine.d.ts.map +1 -0
- package/dist/providers/vendors/xollama.d.ts +188 -0
- package/dist/providers/vendors/xollama.d.ts.map +1 -0
- package/dist/providers.browser.d.ts +3 -0
- package/dist/providers.browser.d.ts.map +1 -0
- package/dist/providers.browser.js +16 -0
- package/dist/providers.d.ts +12 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +272 -0
- package/dist/services/langfuse-telemetry.d.ts +19 -0
- package/dist/services/langfuse-telemetry.d.ts.map +1 -0
- package/dist/transcription.d.ts +53 -0
- package/dist/transcription.d.ts.map +1 -0
- package/package.json +84 -5
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many requests an endpoint will serve at once, and what that means for
|
|
3
|
+
* how many delegated agents may run.
|
|
4
|
+
*
|
|
5
|
+
* A local server has a fixed number of slots -- `OLLAMA_NUM_PARALLEL` for
|
|
6
|
+
* Ollama, `--parallel N` for llama.cpp and opencoti -- and a request that finds
|
|
7
|
+
* none free is not refused, it is *queued*. Nothing reports that. The run looks
|
|
8
|
+
* slow rather than blocked, and the more agents are spawned the worse it gets,
|
|
9
|
+
* because they are queueing behind each other on one server. A hosted provider
|
|
10
|
+
* has the same shape with a different cause: a plan allows so many concurrent
|
|
11
|
+
* requests and the rest wait or fail.
|
|
12
|
+
*
|
|
13
|
+
* The number cannot be discovered in general -- a plan's allowance is not on
|
|
14
|
+
* the wire, and Ollama does not report `OLLAMA_NUM_PARALLEL` -- so it is
|
|
15
|
+
* configured per profile beside the context window. One is the honest default:
|
|
16
|
+
* it is what `--parallel` and a basic plan give you, and it is the value under
|
|
17
|
+
* which nothing queues unexpectedly.
|
|
18
|
+
*/
|
|
19
|
+
/** Below this a profile could serve nothing. */
|
|
20
|
+
export declare const MIN_PARALLEL_SESSIONS = 1;
|
|
21
|
+
/**
|
|
22
|
+
* A guard against a typo, not a statement about what a server can do.
|
|
23
|
+
*
|
|
24
|
+
* This was 10, chosen on 2026-08-10 on the reasoning that "ten concurrent
|
|
25
|
+
* agents on one endpoint is already past where any local server holds its
|
|
26
|
+
* per-session throughput". That was a claim about local llama.cpp servers, and
|
|
27
|
+
* it stopped being the whole picture twice over:
|
|
28
|
+
*
|
|
29
|
+
* - A **hosted** provider's concurrency is whatever the plan allows, which is
|
|
30
|
+
* routinely more than ten and is not ours to cap.
|
|
31
|
+
* - An **elastic** opencoti grows `slots_live` past `--parallel` on demand, so
|
|
32
|
+
* there is no fixed local count to be past in the first place.
|
|
33
|
+
*
|
|
34
|
+
* And it was binding in practice: a tester's profile sat at exactly 10, which
|
|
35
|
+
* is what a cap looks like when it is the thing choosing the number.
|
|
36
|
+
*
|
|
37
|
+
* So the bound is now only wide enough to catch a slipped digit. The real
|
|
38
|
+
* refusal belongs to the endpoint, which knows its own admission; ours is a
|
|
39
|
+
* ceiling the user opted into, and leaving the field empty asks for none.
|
|
40
|
+
*/
|
|
41
|
+
export declare const MAX_PARALLEL_SESSIONS = 64;
|
|
42
|
+
/** What a profile that has never been told otherwise is worth. */
|
|
43
|
+
export declare const DEFAULT_PARALLEL_SESSIONS = 1;
|
|
44
|
+
/**
|
|
45
|
+
* Reads a stored `parallelSessions` into the range a server could honour.
|
|
46
|
+
*
|
|
47
|
+
* `undefined` for anything unusable rather than the default, so a caller can
|
|
48
|
+
* tell "not configured" from "configured as 1" -- the settings panel shows an
|
|
49
|
+
* empty field for the first and a 1 for the second.
|
|
50
|
+
*/
|
|
51
|
+
export declare function normalizeParallelSessions(value: unknown): number | undefined;
|
|
52
|
+
export interface AgentSlotLimit {
|
|
53
|
+
/**
|
|
54
|
+
* Most delegated agents that may run at once.
|
|
55
|
+
*
|
|
56
|
+
* `0` means no cap of ours -- which is not "as many as you like" but
|
|
57
|
+
* "something else decides", and the only thing that says it today is PolyKV.
|
|
58
|
+
* Zero rather than `undefined` on purpose: this value is stored on the
|
|
59
|
+
* session config, where `undefined` has to keep meaning "no host resolved
|
|
60
|
+
* one, leave every previous behaviour alone".
|
|
61
|
+
*/
|
|
62
|
+
limit: number;
|
|
63
|
+
/**
|
|
64
|
+
* With `limit: 0`, what lifted the cap. `"polykv"` is the engine admitting
|
|
65
|
+
* each agent itself, which is where agents take turns asking (one waiting
|
|
66
|
+
* for admission per node). `"elastic"` is elastic slots without pools: no
|
|
67
|
+
* admission to wait on, and agents join together.
|
|
68
|
+
*/
|
|
69
|
+
admission?: "polykv" | "elastic";
|
|
70
|
+
/** Why, in one line, for the log. Never a value the caller branches on. */
|
|
71
|
+
reason: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* How many delegated agents may run at once against this endpoint.
|
|
75
|
+
*
|
|
76
|
+
* The exception is an *elastic* opencoti, by either of the two mechanisms that
|
|
77
|
+
* make it one. Under PolyKV, agents attach to a KV pool and share a slot, and
|
|
78
|
+
* whether one more may start is decided by the engine's admission control
|
|
79
|
+
* against measured KV headroom -- `can_admit`, and a 429 with a `retry-after`
|
|
80
|
+
* when the answer is no. Under the elastic slot controller the server grows
|
|
81
|
+
* `slots_live` toward `slots_max` as load arrives. Either way the slot count is
|
|
82
|
+
* not a number this side can compute, and counting would refuse work the server
|
|
83
|
+
* would have taken.
|
|
84
|
+
*
|
|
85
|
+
* Which is why the configured count changes meaning rather than being ignored
|
|
86
|
+
* there. On a fixed server it *describes* the server, and its absence has to
|
|
87
|
+
* mean one, because a request that finds no free slot queues silently and
|
|
88
|
+
* nothing reports that. On an elastic one nothing needs describing, so the
|
|
89
|
+
* field becomes a ceiling the user asked for -- the engine may well be willing
|
|
90
|
+
* to take more, and a number in that box says don't. Absent, the engine decides
|
|
91
|
+
* alone. Discarding the number because the engine has an opinion would make the
|
|
92
|
+
* field unusable on exactly the servers someone would reach for it on.
|
|
93
|
+
*/
|
|
94
|
+
export declare function resolveAgentSlotLimit(input: {
|
|
95
|
+
providerId: string | undefined;
|
|
96
|
+
baseUrl?: string;
|
|
97
|
+
parallelSessions?: unknown;
|
|
98
|
+
fetch?: typeof fetch;
|
|
99
|
+
}): Promise<AgentSlotLimit>;
|
|
100
|
+
//# sourceMappingURL=agent-slots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-slots.d.ts","sourceRoot":"","sources":["../../src/providers/agent-slots.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AAEH,gDAAgD;AAChD,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,kEAAkE;AAClE,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAS5E;AAED,MAAM,WAAW,cAAc;IAC9B;;;;;;;;OAQG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,SAAS,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IACjC,2EAA2E;IAC3E,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,qBAAqB,CAAC,KAAK,EAAE;IAClD,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACrB,GAAG,OAAO,CAAC,cAAc,CAAC,CA6B1B"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { AgentModelEvent, GatewayProviderContext, GatewayProviderFactory, GatewayResolvedProviderConfig, GatewayStreamRequest } from "@cerebriline/shared";
|
|
2
|
+
import { type CallSettings } from "ai";
|
|
3
|
+
import type { AiSdkStreamTotalUsage, AiSdkStreamUsage, ProviderFactoryResult } from "./vendors/types";
|
|
4
|
+
interface GatewayNormalizedUsage {
|
|
5
|
+
inputTokens: number;
|
|
6
|
+
/**
|
|
7
|
+
* The prompt of the request that was actually accepted, when a turn made
|
|
8
|
+
* more than one.
|
|
9
|
+
*
|
|
10
|
+
* `inputTokens` is the billed sum across every attempt, because a
|
|
11
|
+
* discarded attempt was charged. It is not the size of the context, and
|
|
12
|
+
* the token calibration, the compaction trigger and the context meter all
|
|
13
|
+
* read the size of the context. See `withAggregatedUsage` in
|
|
14
|
+
* `middleware/retry-empty-response.ts` for what the two numbers cost when
|
|
15
|
+
* they are conflated.
|
|
16
|
+
*
|
|
17
|
+
* Absent on a turn that did not retry, where the two are the same number.
|
|
18
|
+
*/
|
|
19
|
+
requestInputTokens?: number;
|
|
20
|
+
outputTokens: number;
|
|
21
|
+
cacheReadTokens: number;
|
|
22
|
+
cacheWriteTokens: number;
|
|
23
|
+
reasoningTokenCount?: number;
|
|
24
|
+
totalCost?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Map the gateway's reasoning intent onto the AI SDK's own per-request
|
|
28
|
+
* `reasoning` call option.
|
|
29
|
+
*
|
|
30
|
+
* The two vocabularies are the same except for `max`, which the SDK does not
|
|
31
|
+
* have and which means the same thing as `xhigh` here. `enabled: false` is
|
|
32
|
+
* `none` — an explicit instruction to reason as little as possible, which is
|
|
33
|
+
* different from expressing no preference.
|
|
34
|
+
*
|
|
35
|
+
* Returns `undefined` when the request expresses no preference, leaving the
|
|
36
|
+
* SDK on `provider-default` so a model configured with a reasoning setting
|
|
37
|
+
* keeps it.
|
|
38
|
+
*/
|
|
39
|
+
export declare function toAiSdkReasoning(reasoning: GatewayStreamRequest["reasoning"]): CallSettings["reasoning"];
|
|
40
|
+
export declare function buildAiSdkStreamConfig(request: GatewayStreamRequest, _context: GatewayProviderContext): Partial<CallSettings>;
|
|
41
|
+
interface RepairableToolCall {
|
|
42
|
+
toolCallId: string;
|
|
43
|
+
toolName: string;
|
|
44
|
+
input: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The tool name hiding at the end of a name the provider mis-sliced.
|
|
48
|
+
*
|
|
49
|
+
* Measured (mann1x/cline#60, GLM 5.3-Flash through Ollama Cloud): a ~2,000
|
|
50
|
+
* character "tool name" consisting of a code block the model had written,
|
|
51
|
+
* then the sentence `Let me re-read the current state of modifySkill and the
|
|
52
|
+
* rest:`, then `<tool_call>`, then `read_files` — a real tool, called
|
|
53
|
+
* correctly, that the turn was failed over.
|
|
54
|
+
*
|
|
55
|
+
* Only the tail after the last marker is considered, and only when it is a
|
|
56
|
+
* bare identifier that names a tool this run actually has. Anything else and
|
|
57
|
+
* we have not found the call, we have found more of the same text.
|
|
58
|
+
*/
|
|
59
|
+
export declare function recoverToolNameFromMarker(toolName: string, isAvailable: (name: string) => boolean): string | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Last-chance repair for tool calls whose arguments are not valid JSON
|
|
62
|
+
* (truncated payloads, single quotes, unescaped newlines — common with
|
|
63
|
+
* weaker models). Runs the raw argument text through the shared jsonrepair
|
|
64
|
+
* strategies; already-valid JSON is not repairable here, and returning null
|
|
65
|
+
* preserves the AI SDK's original error behavior.
|
|
66
|
+
*
|
|
67
|
+
* An unknown tool name gets one narrower treatment first — see
|
|
68
|
+
* {@link repairLeakedToolName} — and is otherwise still left to fail.
|
|
69
|
+
*/
|
|
70
|
+
export declare function repairMalformedToolCall<T extends RepairableToolCall>({ toolCall, tools, error, }: {
|
|
71
|
+
toolCall: T;
|
|
72
|
+
tools?: Record<string, unknown>;
|
|
73
|
+
error: unknown;
|
|
74
|
+
}): Promise<T | null>;
|
|
75
|
+
/**
|
|
76
|
+
* How often a streaming tool call's progress is reported. Each report travels
|
|
77
|
+
* to every agent row and the hub's event stream, so per-token would be a flood;
|
|
78
|
+
* this is often enough that a live call never reads as idle.
|
|
79
|
+
*/
|
|
80
|
+
export declare const TOOL_INPUT_PROGRESS_MS = 500;
|
|
81
|
+
export declare function normalizeUsage(usageValue: AiSdkStreamUsage | AiSdkStreamTotalUsage | Record<string, unknown> | undefined, providerMetadata?: unknown, pricingValue?: unknown): GatewayNormalizedUsage;
|
|
82
|
+
/**
|
|
83
|
+
* Wrap a vendor-constructed model with the transient-failure retry
|
|
84
|
+
* middleware (empty responses + pre-content network interruptions).
|
|
85
|
+
*
|
|
86
|
+
* All-empty turns (no text, no reasoning, no tool call) are a cross-provider
|
|
87
|
+
* phenomenon: production telemetry shows them on hosted backends (openrouter,
|
|
88
|
+
* cline, generic OpenAI-compatible endpoints), not just local Ollama. An
|
|
89
|
+
* empty assistant turn is a hard failure in the agent runtime ("Model
|
|
90
|
+
* returned empty response"), so a single transient flake kills the task.
|
|
91
|
+
* The same telemetry shows mid-stream network deaths (UND_ERR_SOCKET,
|
|
92
|
+
* body/headers timeouts, ECONNRESET) as the dominant network-class run
|
|
93
|
+
* killer — the AI SDK's own retry covers only request initiation, so once a
|
|
94
|
+
* stream has started nothing else retries. Retrying here — the one
|
|
95
|
+
* composition point every AI SDK vendor flows through — turns those flakes
|
|
96
|
+
* into non-events while leaving the runtime's loud failure in place for
|
|
97
|
+
* models that are persistently empty or connections that are truly down.
|
|
98
|
+
*
|
|
99
|
+
* Applied as the *outermost* wrap so each retry re-runs the vendor's full
|
|
100
|
+
* request pipeline, including any vendor-level middleware attached inside
|
|
101
|
+
* `provider.operations.language(...)`. Vendors opt out or tune attempts through
|
|
102
|
+
* `ProviderFactoryResult.retryEmptyResponses`.
|
|
103
|
+
*/
|
|
104
|
+
export declare function withEmptyResponseRetry(model: unknown, retryEmptyResponses: ProviderFactoryResult["retryEmptyResponses"], logger: GatewayProviderContext["logger"]): unknown;
|
|
105
|
+
/**
|
|
106
|
+
* Wrap a model so an admission refusal waits rather than failing the turn.
|
|
107
|
+
*
|
|
108
|
+
* Applied *inside* `withEmptyResponseRetry`, so a refusal that lands on one of
|
|
109
|
+
* that middleware's own re-dials is paced too. Inert unless the server refuses:
|
|
110
|
+
* a provider that never sends `429` sees a request byte-identical to the one it
|
|
111
|
+
* saw before, and the wrapper costs one function call.
|
|
112
|
+
*
|
|
113
|
+
* `maxRetryAfterMs` is read from the provider's PolyKV section because that is
|
|
114
|
+
* where the user can see and change it, but the middleware itself is not
|
|
115
|
+
* opencoti-specific -- `429` + `Retry-After` is ordinary HTTP, and every
|
|
116
|
+
* llama.cpp endpoint reaches us through the same `openai-compatible` vendor,
|
|
117
|
+
* which sets no `isRetryable` and so gets no retry from the AI SDK at all.
|
|
118
|
+
*/
|
|
119
|
+
export declare function withRateLimitRetry(model: unknown, config: GatewayResolvedProviderConfig | undefined, logger: GatewayProviderContext["logger"]): unknown;
|
|
120
|
+
/**
|
|
121
|
+
* The upstream request, aborted whenever its response is abandoned unfinished.
|
|
122
|
+
*
|
|
123
|
+
* Reading a response to its end or its error is not the same as closing the
|
|
124
|
+
* connection it came on. `streamText` tees its base stream for every consumer,
|
|
125
|
+
* and a tee cancels its source only when BOTH branches are cancelled: when
|
|
126
|
+
* {@link emitAiSdkEvents} stops at an error part -- or the agent loop stops
|
|
127
|
+
* reading, on a failed turn or a watchdog -- the branch it read is cancelled
|
|
128
|
+
* and the other one, which nobody reads, keeps the HTTP response open. The
|
|
129
|
+
* server never sees a disconnect and generates to the end. Measured on a
|
|
130
|
+
* 75-agent swarm (4.100.195): five slots decoding 13k+ tokens at ~30 tok/s
|
|
131
|
+
* for agents already marked failed, each holding a 262k-cell KV booking that
|
|
132
|
+
* starved every other agent.
|
|
133
|
+
*
|
|
134
|
+
* So each turn gets its own signal, following the caller's, and aborted here
|
|
135
|
+
* when the turn ends in anything but a clean `finish`: an error finish, a
|
|
136
|
+
* throw, or a consumer that returns early. Aborting the fetch is what closes
|
|
137
|
+
* the connection (undici destroys the socket), which is what stops the server.
|
|
138
|
+
* Every provider built here gets it, and every opencoti request path with it
|
|
139
|
+
* -- lead, worker, keepalive or not -- since each passes `init.signal` on.
|
|
140
|
+
*/
|
|
141
|
+
export declare function abortWhenAbandoned(request: GatewayStreamRequest, run: (request: GatewayStreamRequest) => AsyncIterable<AgentModelEvent> | Promise<AsyncIterable<AgentModelEvent>>): AsyncGenerator<AgentModelEvent>;
|
|
142
|
+
export declare const createOpenAIProvider: GatewayProviderFactory;
|
|
143
|
+
export declare const createClineProvider: GatewayProviderFactory;
|
|
144
|
+
export declare const createOpenAICompatibleProvider: GatewayProviderFactory;
|
|
145
|
+
export declare const createAnthropicProvider: GatewayProviderFactory;
|
|
146
|
+
export declare const createGoogleProvider: GatewayProviderFactory;
|
|
147
|
+
export declare const createVertexProvider: GatewayProviderFactory;
|
|
148
|
+
export declare const createBedrockProvider: GatewayProviderFactory;
|
|
149
|
+
export declare const createMistralProvider: GatewayProviderFactory;
|
|
150
|
+
export declare const createClaudeCodeProvider: GatewayProviderFactory;
|
|
151
|
+
export declare const createOpenAICodexProvider: GatewayProviderFactory;
|
|
152
|
+
export declare const createOpenCodeProvider: GatewayProviderFactory;
|
|
153
|
+
export declare const createDifyProvider: GatewayProviderFactory;
|
|
154
|
+
export declare const createOllamaProvider: GatewayProviderFactory;
|
|
155
|
+
export declare const createOpencotiProvider: GatewayProviderFactory;
|
|
156
|
+
export declare const createSapAiCoreProvider: GatewayProviderFactory;
|
|
157
|
+
export {};
|
|
158
|
+
//# sourceMappingURL=ai-sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-sdk.d.ts","sourceRoot":"","sources":["../../src/providers/ai-sdk.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEX,eAAe,EAEf,sBAAsB,EACtB,sBAAsB,EACtB,6BAA6B,EAC7B,oBAAoB,EAWpB,MAAM,eAAe,CAAC;AAoBvB,OAAO,EACN,KAAK,YAAY,EAQjB,MAAM,IAAI,CAAC;AAqCZ,OAAO,KAAK,EAGX,qBAAqB,E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AAC7E,eAAO,MAAM,sBAAsB,wBAAkC,CAAC;AACtE,eAAO,MAAM,kBAAkB,wBAA8B,CAAC;AAC9D,eAAO,MAAM,oBAAoB,wBAAgC,CAAC;AAClE,eAAO,MAAM,sBAAsB,wBAAkC,CAAC;AACtE,eAAO,MAAM,uBAAuB,wBAAmC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/providers/async.ts"],"names":[],"mappings":"AAAA,wBAAuB,eAAe,CAAC,CAAC,EACvC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GACnC,aAAa,CAAC,CAAC,CAAC,CAIlB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type GatewayUsageCostDisplay } from "@cerebriline/shared";
|
|
2
|
+
export type ProviderUsageCostDisplay = GatewayUsageCostDisplay;
|
|
3
|
+
export declare function resolveProviderUsageCostDisplay(providerId: string): ProviderUsageCostDisplay;
|
|
4
|
+
export declare function shouldShowProviderUsageCost(providerId: string): boolean;
|
|
5
|
+
//# sourceMappingURL=billing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../src/providers/billing.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,uBAAuB,EAE5B,MAAM,eAAe,CAAC;AAIvB,MAAM,MAAM,wBAAwB,GAAG,uBAAuB,CAAC;AAqB/D,wBAAgB,+BAA+B,CAC9C,UAAU,EAAE,MAAM,GAChB,wBAAwB,CAK1B;AAED,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAEvE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { GatewayModelOperationCapability, GatewayModelToolCapability, GatewayProviderMetadata, GatewayProviderSettings, ProviderCapability, ProviderConfigField } from "@cerebriline/shared";
|
|
2
|
+
import type { ModelInfo, ProviderClient, ProviderProtocol } from "../catalog/types";
|
|
3
|
+
export type ProviderFamily = "cline" | "openai" | "openai-compatible" | "anthropic" | "google" | "vertex" | "bedrock" | "mistral" | "claude-code" | "openai-codex" | "opencode" | "dify" | "ollama" | "opencoti" | "sap-ai-core";
|
|
4
|
+
export type ProviderApiLine = "china" | "international";
|
|
5
|
+
export interface BuiltinSpec {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
family: ProviderFamily;
|
|
10
|
+
protocol?: ProviderProtocol;
|
|
11
|
+
client?: ProviderClient;
|
|
12
|
+
modelToolCapabilities?: readonly GatewayModelToolCapability[];
|
|
13
|
+
modelOperationCapabilities?: readonly GatewayModelOperationCapability[];
|
|
14
|
+
capabilities?: ProviderCapability[];
|
|
15
|
+
popular?: number;
|
|
16
|
+
modelsProviderId?: string;
|
|
17
|
+
defaultModelId?: string;
|
|
18
|
+
modelsFactory?: () => Record<string, ModelInfo>;
|
|
19
|
+
env?: readonly ("browser" | "node")[];
|
|
20
|
+
apiKeyEnv?: readonly string[];
|
|
21
|
+
modelsSourceUrl?: string;
|
|
22
|
+
docsUrl?: string;
|
|
23
|
+
defaults?: GatewayProviderSettings;
|
|
24
|
+
/**
|
|
25
|
+
* Regional endpoint routing facts: base URL per API line. Used when the
|
|
26
|
+
* caller selects an `apiLine` without an explicit base URL. The line that
|
|
27
|
+
* matches `defaults.baseUrl` is included so the mapping is exhaustive and
|
|
28
|
+
* self-documenting.
|
|
29
|
+
*/
|
|
30
|
+
apiLineBaseUrls?: Readonly<Partial<Record<ProviderApiLine, string>>>;
|
|
31
|
+
configFields?: readonly ProviderConfigField[];
|
|
32
|
+
metadata?: GatewayProviderMetadata;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=builtin-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtin-types.d.ts","sourceRoot":"","sources":["../../src/providers/builtin-types.ts"],"names":[],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AAQ,CAAC,EAAE,uBAAuB,CAAC;IACnC;;;;;OAKG;IACH,eAAe,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IACrE,YAAY,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC9C,QAAQ,CAAC,EAAE,uBAAuB,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins-runtime.d.ts","sourceRoot":"","sources":["../../src/providers/builtins-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEX,2BAA2B,EAC3B,MAAM,eAAe,CAAC;AAsGvB,eAAO,MAAM,8BAA8B,EAAE,2BAA2B,EAsBpE,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type GatewayProviderManifest } from "@cerebriline/shared";
|
|
2
|
+
import type { ModelCollection } from "../catalog/types";
|
|
3
|
+
import type { BuiltinSpec, ProviderApiLine } from "./builtin-types";
|
|
4
|
+
export declare const DEFAULT_INTERNAL_OCA_BASE_URL = "https://code-internal.aiservice.us-chicago-1.oci.oraclecloud.com/20250206/app/litellm";
|
|
5
|
+
export declare const DEFAULT_EXTERNAL_OCA_BASE_URL = "https://code.aiservice.us-chicago-1.oci.oraclecloud.com/20250206/app/litellm";
|
|
6
|
+
/**
|
|
7
|
+
* Context window requested from Ollama when neither the resolved model nor
|
|
8
|
+
* the user's configuration supplies one. Matches the pre-SDK-migration
|
|
9
|
+
* handler default; deliberately larger than Ollama's 4096 server default,
|
|
10
|
+
* which cannot fit Cline's agentic prompts. Single source of truth — the
|
|
11
|
+
* vendor, the VS Code session factory, and the settings UI all import this.
|
|
12
|
+
*/
|
|
13
|
+
export declare const OLLAMA_DEFAULT_CONTEXT_WINDOW = 32768;
|
|
14
|
+
export type { BuiltinSpec, ProviderApiLine, ProviderFamily, } from "./builtin-types";
|
|
15
|
+
export declare const BUILTIN_SPECS: BuiltinSpec[];
|
|
16
|
+
export declare function isProviderApiLine(value: unknown): value is ProviderApiLine;
|
|
17
|
+
/**
|
|
18
|
+
* Resolve the regional base URL for a provider's selected API line (e.g.
|
|
19
|
+
* Qwen/Moonshot/Z.AI/MiniMax "china" vs "international" endpoints). Returns
|
|
20
|
+
* undefined when the provider has no regional endpoints or the api line is
|
|
21
|
+
* not a recognized value. Callers must let an explicit user-configured base
|
|
22
|
+
* URL win over this resolution.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveProviderApiLineBaseUrl(providerId: string, apiLine: unknown): string | undefined;
|
|
25
|
+
export declare function toManifest(spec: BuiltinSpec): GatewayProviderManifest;
|
|
26
|
+
/** Static manifests used for synchronous capability checks before providers load. */
|
|
27
|
+
export declare const BUILTIN_PROVIDER_MANIFESTS_BY_ID: Readonly<Record<string, GatewayProviderManifest>>;
|
|
28
|
+
export declare const BUILTIN_PROVIDER_COLLECTION_LIST: ModelCollection[];
|
|
29
|
+
export declare const BUILTIN_PROVIDER_COLLECTIONS_BY_ID: Record<string, ModelCollection>;
|
|
30
|
+
//# sourceMappingURL=builtins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins.d.ts","sourceRoot":"","sources":["../../src/providers/builtins.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,KAAK,uBAAuB,EAO5B,MAAM,eAAe,CAAC;AAQvB,OAAO,KAAK,EACX,eAAe,EAIf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACX,WAAW,EACX,eAAe,EAEf,MAAM,iBAAiB,CAAC;AA4BzB,eAAO,MAAM,6BAA6B,0FAC8C,CAAC;AACzF,eAAO,MAAM,6BAA6B,iFACqC,CAAC;AA+BhF;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,QAAQ,CAAC;AAEnD,YAAY,EACX,WAAW,EACX,eAAe,EACf,cAAc,GACd,MAAM,iBAAiB,CAAC;AAypCzB,eAAO,MAAM,aAAa,EAAE,WAAW,EAGtC,CAAC;AAWF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAE1E;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC5C,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,OAAO,GACd,MAAM,GAAG,SAAS,CAOpB;AAiDD,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,uBAAuB,CAuDrE;AAED,qFAAqF;AACrF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CACtD,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAGvC,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,eAAe,EACzB,CAAC;AAEtC,eAAO,MAAM,kCAAkC,EAAE,MAAM,CACtD,MAAM,EACN,eAAe,CAMf,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { GatewayModelDefinition, GatewayStreamRequest } from "@cerebriline/shared";
|
|
2
|
+
import { type ApiHandler, type Message, type ProviderConfig } from "./types";
|
|
3
|
+
export declare function toGatewayRequestMessages(messages: Message[]): GatewayStreamRequest["messages"];
|
|
4
|
+
declare function buildGatewayModels(providerId: string, config: ProviderConfig): Omit<GatewayModelDefinition, "providerId">[] | undefined;
|
|
5
|
+
export declare function buildGatewayConfig(config: ProviderConfig): {
|
|
6
|
+
providerId: string;
|
|
7
|
+
apiKey: string | undefined;
|
|
8
|
+
baseUrl: string | undefined;
|
|
9
|
+
headers: Record<string, string> | undefined;
|
|
10
|
+
timeoutMs: number | undefined;
|
|
11
|
+
fetch: typeof fetch | undefined;
|
|
12
|
+
defaultModelId: string;
|
|
13
|
+
models: Omit<GatewayModelDefinition, "providerId">[] | undefined;
|
|
14
|
+
reasoningHistory: import("@cerebriline/shared").ReasoningHistorySetting | undefined;
|
|
15
|
+
reasoningInline: boolean | undefined;
|
|
16
|
+
options: {
|
|
17
|
+
clientId?: string;
|
|
18
|
+
clientSecret?: string;
|
|
19
|
+
tokenUrl?: string;
|
|
20
|
+
resourceGroup?: string;
|
|
21
|
+
deploymentId?: string;
|
|
22
|
+
useOrchestrationMode?: boolean;
|
|
23
|
+
api?: "orchestration" | "foundation-models";
|
|
24
|
+
defaultSettings?: Record<string, unknown>;
|
|
25
|
+
hostname?: string;
|
|
26
|
+
port?: number;
|
|
27
|
+
autoStartServer?: boolean;
|
|
28
|
+
serverTimeout?: number;
|
|
29
|
+
modelSettings?: Record<string, unknown>;
|
|
30
|
+
region: string | undefined;
|
|
31
|
+
project: string | undefined;
|
|
32
|
+
projectId: string | undefined;
|
|
33
|
+
location: string | undefined;
|
|
34
|
+
accessKeyId: string | undefined;
|
|
35
|
+
secretAccessKey: string | undefined;
|
|
36
|
+
sessionToken: string | undefined;
|
|
37
|
+
authentication: "iam" | "profile" | "api-key" | "apikey" | undefined;
|
|
38
|
+
profile: string | undefined;
|
|
39
|
+
endpoint: string | undefined;
|
|
40
|
+
customModelBaseId: string | undefined;
|
|
41
|
+
apiVersion: string | undefined;
|
|
42
|
+
useIdentity: boolean | undefined;
|
|
43
|
+
mode: "external" | "internal" | undefined;
|
|
44
|
+
usePromptCache: boolean | undefined;
|
|
45
|
+
polykvLeadPool?: boolean | undefined;
|
|
46
|
+
polykvBooking?: {
|
|
47
|
+
numCtx: number;
|
|
48
|
+
} | undefined;
|
|
49
|
+
polykvWorker?: {
|
|
50
|
+
sessionId: string;
|
|
51
|
+
group: string;
|
|
52
|
+
layers: number;
|
|
53
|
+
attachOnly?: boolean;
|
|
54
|
+
owner?: string;
|
|
55
|
+
} | undefined;
|
|
56
|
+
polykvSessionId?: string | undefined;
|
|
57
|
+
agentWindow?: {
|
|
58
|
+
sharePercent?: number;
|
|
59
|
+
} | undefined;
|
|
60
|
+
sampling: import("./config").ProviderSamplingOptions | undefined;
|
|
61
|
+
polykv: import("./config").PolykvOptions | undefined;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export declare function createGatewayApiHandler(config: ProviderConfig): ApiHandler;
|
|
65
|
+
export declare function createGatewayApiHandlerAsync(config: ProviderConfig): Promise<ApiHandler>;
|
|
66
|
+
/**
|
|
67
|
+
* Internal test hook. Not part of the public API; production callers go
|
|
68
|
+
* through `createGatewayApiHandler(Async)`.
|
|
69
|
+
*/
|
|
70
|
+
export declare const _testing: {
|
|
71
|
+
buildGatewayConfig: typeof buildGatewayConfig;
|
|
72
|
+
buildGatewayModels: typeof buildGatewayModels;
|
|
73
|
+
};
|
|
74
|
+
export {};
|
|
75
|
+
//# sourceMappingURL=compat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["../../src/providers/compat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEX,sBAAsB,EAGtB,oBAAoB,EACpB,MAAM,eAAe,CAAC;AA6BvB,OAAO,EACN,KAAK,UAAU,EAIf,KAAK,OAAO,EAEZ,KAAK,cAAc,EAGnB,MAAM,SAAS,CAAC;AAkOjB,wBAAgB,wBAAwB,CACvC,QAAQ,EAAE,OAAO,EAAE,GACjB,oBAAoB,CAAC,UAAU,CAAC,CAiGlC;AA6CD,iBAAS,kBAAkB,CAC1B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,cAAc,GACpB,IAAI,CAAC,sBAAsB,EAAE,YAAY,CAAC,EAAE,GAAG,SAAS,CAkE1D;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiExD;AAgKD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,cAAc,GAAG,UAAU,CAE1E;AAED,wBAAsB,4BAA4B,CACjD,MAAM,EAAE,cAAc,GACpB,OAAO,CAAC,UAAU,CAAC,CAqCrB;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ;;;CAGpB,CAAC"}
|