@plurnk/plurnk-providers 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.defaults +25 -13
- package/README.md +8 -1
- package/SPEC.md +103 -15
- package/dist/AiSdkProvider.d.ts +7 -4
- package/dist/AiSdkProvider.d.ts.map +1 -1
- package/dist/AiSdkProvider.js +150 -53
- package/dist/AiSdkProvider.js.map +1 -1
- package/dist/Mock.d.ts +2 -1
- package/dist/Mock.d.ts.map +1 -1
- package/dist/Mock.js +6 -1
- package/dist/Mock.js.map +1 -1
- package/dist/Pool.d.ts +2 -0
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +3 -0
- package/dist/Pool.js.map +1 -1
- package/dist/ProviderRegistry.d.ts.map +1 -1
- package/dist/ProviderRegistry.js +11 -10
- package/dist/ProviderRegistry.js.map +1 -1
- package/dist/accounting.d.ts.map +1 -1
- package/dist/accounting.js +16 -8
- package/dist/accounting.js.map +1 -1
- package/dist/aiSdkTransport.d.ts +4 -2
- package/dist/aiSdkTransport.d.ts.map +1 -1
- package/dist/aiSdkTransport.js +33 -6
- package/dist/aiSdkTransport.js.map +1 -1
- package/dist/catalogProvider.d.ts +4 -1
- package/dist/catalogProvider.d.ts.map +1 -1
- package/dist/catalogProvider.js +94 -3
- package/dist/catalogProvider.js.map +1 -1
- package/dist/compatibleProvider.d.ts.map +1 -1
- package/dist/compatibleProvider.js +2 -0
- package/dist/compatibleProvider.js.map +1 -1
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +5 -4
- package/dist/cost.js.map +1 -1
- package/dist/discover.d.ts +2 -0
- package/dist/discover.d.ts.map +1 -1
- package/dist/discover.js +13 -2
- package/dist/discover.js.map +1 -1
- package/dist/env.d.ts +3 -2
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +11 -4
- package/dist/env.js.map +1 -1
- package/dist/index.d.ts +10 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/notices.d.ts +1 -1
- package/dist/notices.d.ts.map +1 -1
- package/dist/openai.d.ts +1 -1
- package/dist/openai.d.ts.map +1 -1
- package/dist/openai.js +1 -1
- package/dist/openai.js.map +1 -1
- package/dist/sdkModels.d.ts +2 -0
- package/dist/sdkModels.d.ts.map +1 -1
- package/dist/sdkModels.js +163 -19
- package/dist/sdkModels.js.map +1 -1
- package/dist/types.d.ts +10 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +10 -1
- package/dist/types.js.map +1 -1
- package/package.json +9 -9
- package/src/AiSdkProvider.test.ts +214 -34
- package/src/AiSdkProvider.ts +181 -56
- package/src/Mock.test.ts +6 -1
- package/src/Mock.ts +6 -1
- package/src/Pool.test.ts +1 -0
- package/src/Pool.ts +5 -0
- package/src/ProviderRegistry.test.ts +27 -14
- package/src/ProviderRegistry.ts +19 -10
- package/src/accounting.test.ts +30 -2
- package/src/accounting.ts +16 -8
- package/src/aiSdkTransport.test.ts +3 -0
- package/src/aiSdkTransport.ts +38 -8
- package/src/catalogProvider.test.ts +151 -19
- package/src/catalogProvider.ts +125 -3
- package/src/compatibleProvider.test.ts +13 -10
- package/src/compatibleProvider.ts +2 -0
- package/src/cost.ts +5 -4
- package/src/discover.test.ts +27 -0
- package/src/discover.ts +20 -3
- package/src/env.test.ts +23 -8
- package/src/env.ts +18 -9
- package/src/errors.test.ts +2 -2
- package/src/index.ts +17 -8
- package/src/notices.ts +1 -1
- package/src/openai.ts +1 -1
- package/src/providerDefaults.test.ts +50 -0
- package/src/sdkModels.test.ts +142 -8
- package/src/sdkModels.ts +201 -19
- package/src/types.ts +22 -0
package/.env.defaults
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
# PLURNK_PROVIDERS_* knobs and provider declarations ({§operator-config-env-defaults});
|
|
3
3
|
# every package owns what it reads, and this file IS the configuration reference.
|
|
4
4
|
# The daemon assembles every installed member's file into one floor (set-if-unset under the
|
|
5
|
-
# operator's env) - do NOT edit this file; put YOUR config in
|
|
5
|
+
# operator's env) - do NOT edit this file; put YOUR config in
|
|
6
|
+
# $XDG_CONFIG_HOME/plurnk/.env or ./.env. A key
|
|
6
7
|
# claimed by two packages crashes boot naming both.
|
|
7
8
|
#
|
|
8
9
|
# EVERY PLURNK_PROVIDERS_* knob is per-alias-scopable: PLURNK_PROVIDERS_<KNOB>_<alias> wins over
|
|
@@ -13,6 +14,13 @@
|
|
|
13
14
|
# and model facts. {§model-fact-resolution} defines precedence per fact; there is
|
|
14
15
|
# no live price fetch. Secret VALUES never belong here.
|
|
15
16
|
|
|
17
|
+
# --- OpenRouter application attribution ({§openrouter-app-attribution}) ---
|
|
18
|
+
# OpenRouter uses the public URL as the app identity and the title for display.
|
|
19
|
+
# Override both for a downstream application. An explicitly empty URL suppresses
|
|
20
|
+
# attribution entirely; a title without a URL is never sent.
|
|
21
|
+
OPENROUTER_HTTP_REFERER=https://github.com/plurnk/plurnk-service
|
|
22
|
+
OPENROUTER_APP_TITLE=Plurnk
|
|
23
|
+
|
|
16
24
|
# --- Generation envelope ({§provider-generation-envelope}, #242) ---
|
|
17
25
|
# OUTPUT_BUDGET is one total response ceiling, including hidden reasoning. It accepts a
|
|
18
26
|
# percentage of the effective context window or an absolute token count and is always
|
|
@@ -21,12 +29,10 @@
|
|
|
21
29
|
PLURNK_PROVIDERS_OUTPUT_BUDGET=35%
|
|
22
30
|
# PLURNK_PROVIDERS_REASONING_BUDGET=8192
|
|
23
31
|
|
|
24
|
-
# --- Side-channel reasoning (
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
# defer activation and depth to the backend's documented default. Use an alias-scoped
|
|
29
|
-
# ON when a reasoning-capable model defaults off and the operator wants it enabled.
|
|
32
|
+
# --- Side-channel reasoning ({§provider-reasoning-policy}) ---
|
|
33
|
+
# off | adaptive | low | medium | high. Policy and budget remain independent;
|
|
34
|
+
# adaptive requests native dynamic reasoning where available and otherwise the
|
|
35
|
+
# provider's supported high posture. Alias-scoped values seed a worker once.
|
|
30
36
|
PLURNK_PROVIDERS_REASONING=adaptive
|
|
31
37
|
|
|
32
38
|
# Response-content interpretation ({§provider-tagged-reasoning}) is independent
|
|
@@ -42,7 +48,8 @@ PLURNK_PROVIDERS_REASONING_RESPONSE_STYLE=verbatim
|
|
|
42
48
|
# the floor the provider manages wherever a grammar rides (greedy-under-mask loops without it).
|
|
43
49
|
PLURNK_PROVIDERS_TEMPERATURE=0.2
|
|
44
50
|
PLURNK_PROVIDERS_REPEAT_PENALTY=1.15
|
|
45
|
-
# FREQUENCY_PENALTY (
|
|
51
|
+
# FREQUENCY_PENALTY (https://github.com/plurnk/plurnk-service/issues/426):
|
|
52
|
+
# optional cloud anti-degeneration tuning. API acceptance
|
|
46
53
|
# permits the field to ride but does not establish its semantic effect, and provider
|
|
47
54
|
# implementations differ. The portable floor is off; enable per alias only from
|
|
48
55
|
# provider documentation or a controlled behavioral experiment.
|
|
@@ -59,7 +66,8 @@ PLURNK_PROVIDERS_CACHE_AFFINITY=1
|
|
|
59
66
|
# stable-system marks only the reusable system boundary on supported Claude
|
|
60
67
|
# routes; off requests no explicit cache write. Provider-default lifetime is 5m.
|
|
61
68
|
PLURNK_PROVIDERS_CACHE_WRITE_POLICY=stable-system
|
|
62
|
-
#
|
|
69
|
+
# https://github.com/plurnk/plurnk-service/issues/567: DRY is a llama.cpp-only
|
|
70
|
+
# repeated-sequence penalty. It can reduce
|
|
63
71
|
# degenerate loops, but it can also corrupt exact source, identifiers, quoted
|
|
64
72
|
# evidence, and other repetition required by PLURNK operations. The portable
|
|
65
73
|
# server-wide default is off. A nonzero alias override is an explicit fidelity
|
|
@@ -140,8 +148,9 @@ PLURNK_PROVIDERS_PROBE_DELAY=250
|
|
|
140
148
|
# an endpoint Models.dev does not list. NAME is the alias provider segment.
|
|
141
149
|
# PLURNK_PROVIDERS_PROVIDER_<NAME>_NPM=<supported AI SDK package>
|
|
142
150
|
# PLURNK_PROVIDERS_PROVIDER_<NAME>_BASE_URL=<endpoint>
|
|
143
|
-
# PLURNK_PROVIDERS_PROVIDER_<NAME>_API_KEY_ENV=<
|
|
144
|
-
|
|
151
|
+
# PLURNK_PROVIDERS_PROVIDER_<NAME>_API_KEY_ENV=<one exact env name>
|
|
152
|
+
# Models.dev is authoritative for cataloged providers ({§provider-fact-authority}):
|
|
153
|
+
# package defaults never redefine a cataloged NPM, BASE_URL, or credential name.
|
|
145
154
|
# Fireworks reasoners default on when reasoning_effort is omitted; explicit
|
|
146
155
|
# "none" is its off switch. This is a declared wire exception, not a registry.
|
|
147
156
|
PLURNK_PROVIDERS_PROVIDER_FIREWORKS_REASONING_STYLE=effort_explicit
|
|
@@ -157,13 +166,16 @@ PLURNK_PROVIDERS_PROVIDER_QIANFAN_NPM=@ai-sdk/openai-compatible
|
|
|
157
166
|
PLURNK_PROVIDERS_PROVIDER_QIANFAN_BASE_URL=https://qianfan.baidubce.com/v2
|
|
158
167
|
PLURNK_PROVIDERS_PROVIDER_QIANFAN_API_KEY_ENV=QIANFAN_API_KEY
|
|
159
168
|
|
|
160
|
-
# ---
|
|
169
|
+
# --- Model selectors and optional alias cascade (SPEC §5) ---
|
|
161
170
|
# First path segment is the provider name; the rest is the provider-native model id (may
|
|
162
|
-
# contain "/").
|
|
171
|
+
# contain "/"). PLURNK_MODEL accepts that exact route or a declared alias. An
|
|
172
|
+
# alias is useful when the route needs a reusable name, endpoint, or scoped tuning.
|
|
173
|
+
# Operator-specific, no default - the examples are commented.
|
|
163
174
|
# PLURNK_MODEL_gemma=openai/macher.gguf
|
|
164
175
|
# PLURNK_MODEL_opus=anthropic/claude-opus-4-8
|
|
165
176
|
# PLURNK_MODEL_sonnet=openrouter/anthropic/claude-sonnet-latest
|
|
166
177
|
# PLURNK_MODEL=gemma
|
|
178
|
+
# PLURNK_MODEL=google/gemini-3-flash
|
|
167
179
|
#
|
|
168
180
|
# PLURNK_BASEURL_<alias> - bind an endpoint to ONE alias (the only way to run N self-hosted
|
|
169
181
|
# boxes of one provider: openai=llama.cpp/vLLM, ollama). WINS over the provider's *_BASE_URL;
|
package/README.md
CHANGED
|
@@ -40,7 +40,14 @@ discovery and environment-file defaults.
|
|
|
40
40
|
|
|
41
41
|
## Configure a model
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
Select a catalog route directly:
|
|
44
|
+
|
|
45
|
+
```dotenv
|
|
46
|
+
PLURNK_MODEL=google/gemini-3-flash
|
|
47
|
+
GEMINI_API_KEY=...
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Declare an alias when the route needs a reusable name or scoped tuning:
|
|
44
51
|
|
|
45
52
|
```dotenv
|
|
46
53
|
PLURNK_MODEL_fast=openai/gpt-5-mini
|
package/SPEC.md
CHANGED
|
@@ -69,7 +69,7 @@ interface Provider {
|
|
|
69
69
|
`contextWindow` is the effective total context envelope resolved under
|
|
70
70
|
{§model-fact-resolution}: the minimum of known model capacity and any stricter
|
|
71
71
|
operator cap. `null` means genuinely unknown; a consumer MUST NOT invent a
|
|
72
|
-
stand-in. The context-window knob is a hard cap, never model-facing
|
|
72
|
+
stand-in. The context-window knob is a hard cap, never a model-facing curation
|
|
73
73
|
pressure.
|
|
74
74
|
|
|
75
75
|
§provider-prompt-measurement `PromptTokenMeasurement` is a discriminated
|
|
@@ -167,6 +167,16 @@ I/O and settles that identity with the resulting
|
|
|
167
167
|
failover request. The observer is a durability sink, not an alternate evidence
|
|
168
168
|
representation; the same ordered records remain on the final response or error.
|
|
169
169
|
|
|
170
|
+
§provider-reasoning-observer When a consumer supplies `observeReasoning`, the
|
|
171
|
+
provider synchronously delivers each exact, ordered, nonempty readable-reasoning
|
|
172
|
+
delta as it becomes available. A transport without incremental reasoning emits
|
|
173
|
+
the complete normalized value once before resolving. This is transient
|
|
174
|
+
observation, not response authority: `ProviderResponse` or `ProviderError`
|
|
175
|
+
remains the complete settled evidence. An automatically retried physical
|
|
176
|
+
request may therefore expose a partial failed-attempt prefix before a later
|
|
177
|
+
attempt settles, and consumers MUST NOT rewrite that history to resemble only
|
|
178
|
+
the final response.
|
|
179
|
+
|
|
170
180
|
Usage obeys {§provider-usage}:
|
|
171
181
|
|
|
172
182
|
```text
|
|
@@ -218,21 +228,51 @@ PLURNK maps its generic settings to AI SDK call settings:
|
|
|
218
228
|
- presence and frequency penalties;
|
|
219
229
|
- stop sequences and seed;
|
|
220
230
|
- output-token ceiling;
|
|
221
|
-
- `off`,
|
|
222
|
-
an optional operator budget.
|
|
231
|
+
- `off`, `adaptive`, or fixed `low`, `medium`, or `high` reasoning policy, with
|
|
232
|
+
an independent optional operator budget.
|
|
223
233
|
|
|
224
234
|
Provider-specific options are permitted only where they preserve a documented
|
|
225
235
|
PLURNK product contract the generic SDK surface cannot express.
|
|
226
236
|
|
|
237
|
+
§provider-reasoning-policy The portable vocabulary comes from
|
|
238
|
+
{§reasoning-policy-wire}. `adaptive` requests the provider's
|
|
239
|
+
documented dynamic mechanism where one exists and otherwise requests its
|
|
240
|
+
supported `high` posture; it is affirmative, not an omission that may silently
|
|
241
|
+
disable reasoning. A fixed policy retains its named intent and is rejected
|
|
242
|
+
before provider I/O when the selected adapter cannot represent it without
|
|
243
|
+
coercion. Every provider exposes its exact supported subset. A numeric reasoning
|
|
244
|
+
budget constrains the generation envelope independently and never selects or
|
|
245
|
+
changes policy.
|
|
246
|
+
|
|
247
|
+
The catalog adapter derives the exposed subset from the selected model and the
|
|
248
|
+
installed native SDK contract:
|
|
249
|
+
|
|
250
|
+
| Route | `adaptive` projection | Advertised subset on a reasoning model |
|
|
251
|
+
| --- | --- | --- |
|
|
252
|
+
| Anthropic or Bedrock model with native adaptive `thinking` | Native adaptive `thinking`, without a fixed effort | `off`, `adaptive`, `low`, `medium`, `high` |
|
|
253
|
+
| Anthropic or Bedrock model with manual `thinking` | A `high` manual allowance inside the total output envelope | `off`, `adaptive`, `low`, `medium`, `high` |
|
|
254
|
+
| Gemini 2.5 | Dynamic `thinkingBudget` | All five, except Pro omits unsupported `off` |
|
|
255
|
+
| Gemini 3+ | Native `thinkingLevel: "high"` | `adaptive`, `low`, `medium`, `high`; its mandatory minimum is not mislabeled `off` |
|
|
256
|
+
| xAI graded model | Native `high` | All five, except Grok 4.6 omits unsupported `off` |
|
|
257
|
+
| xAI fixed-reasoning model | Documented model default | `adaptive` |
|
|
258
|
+
| Mistral model with adjustable effort | Native `high` | `off`, `adaptive`, `high`; SDK coercions of low/medium are not exposed |
|
|
259
|
+
| Mistral reasoning model without adjustable SDK effort | Documented model default | `adaptive` |
|
|
260
|
+
| Other native graded adapter | Native `high` | `off`, `adaptive`, `low`, `medium`, `high` |
|
|
261
|
+
| Activation-only compatible adapter | Explicit activation or documented reasoning default | `off`, `adaptive` |
|
|
262
|
+
|
|
263
|
+
Models.dev's reasoning bit selects no row by itself: it identifies capability,
|
|
264
|
+
while the installed adapter and selected model determine representable policy.
|
|
265
|
+
|
|
227
266
|
§provider-readable-reasoning When the effective reasoning posture is not
|
|
228
267
|
`off`, a native adapter MUST request readable reasoning summaries if its
|
|
229
268
|
provider requires a separate response-visibility option. That option neither
|
|
230
269
|
activates reasoning nor selects its depth. The exact wire projection belongs to
|
|
231
270
|
the provider adapter; Models.dev's reasoning bit remains capability metadata.
|
|
232
271
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
272
|
+
§provider-sdk-warning AI SDK compatibility, unsupported-feature, deprecation,
|
|
273
|
+
and other call warnings become source-attributed provider Notices on the
|
|
274
|
+
successful exchange. A lossy adapter projection is therefore observable rather
|
|
275
|
+
than disappearing in transport internals.
|
|
236
276
|
|
|
237
277
|
§provider-cache-affinity **Cache affinity is route-owned request projection.**
|
|
238
278
|
When a provider documents a semantics-preserving conversation, session, or
|
|
@@ -257,9 +297,11 @@ reasoning intent to its OpenAI-compatible controls:
|
|
|
257
297
|
| PLURNK posture | `thinking` | `reasoning_effort` |
|
|
258
298
|
| --------------- | --------------------- | -------------------- |
|
|
259
299
|
| `off` | `{ type: disabled }` | omitted |
|
|
260
|
-
| `adaptive` |
|
|
261
|
-
| `
|
|
262
|
-
|
|
300
|
+
| `adaptive` | `{ type: enabled }` | omitted |
|
|
301
|
+
| `high` | `{ type: enabled }` | `high` |
|
|
302
|
+
|
|
303
|
+
The direct API does not distinguish portable `low` or `medium` intent and
|
|
304
|
+
therefore advertises only `off`, `adaptive`, and `high`.
|
|
263
305
|
|
|
264
306
|
The compatible transport is deliberately retained for:
|
|
265
307
|
|
|
@@ -302,9 +344,23 @@ defaults.
|
|
|
302
344
|
|
|
303
345
|
§provider-resolution `PLURNK_MODEL_<alias>=<provider>/<model-id>` declares an
|
|
304
346
|
alias.
|
|
305
|
-
`PLURNK_MODEL=<
|
|
347
|
+
`PLURNK_MODEL=<selector>` selects either a declared alias or an exact
|
|
348
|
+
`<provider>/<model-id>` route. Model IDs may contain `/`; only the first slash
|
|
349
|
+
separates provider from model. Exact routes carry no fabricated alias and use
|
|
350
|
+
the global provider configuration. Declared aliases retain their provenance,
|
|
351
|
+
endpoint override, and alias-scoped tuning.
|
|
306
352
|
`PLURNK_BASEURL_<alias>` is a per-alias endpoint override.
|
|
307
353
|
|
|
354
|
+
§model-catalog-readiness **Catalog readiness and construction share one local
|
|
355
|
+
configuration predicate.** For each Models.dev provider, readiness evaluates
|
|
356
|
+
the same effective credential names, endpoint template coordinates, base-URL
|
|
357
|
+
precedence, and alternative Bedrock authentication sets used by construction.
|
|
358
|
+
It makes no request and validates no credential value. A ready result therefore
|
|
359
|
+
means only “configured enough to attempt”; missing causes contain environment
|
|
360
|
+
names without values. Construction rejects the same missing requirements at
|
|
361
|
+
the provider boundary instead of deferring a known configuration failure to a
|
|
362
|
+
model request.
|
|
363
|
+
|
|
308
364
|
### §model-fact-resolution Model fact precedence
|
|
309
365
|
|
|
310
366
|
Provider and model facts resolve independently:
|
|
@@ -315,7 +371,8 @@ Provider and model facts resolve independently:
|
|
|
315
371
|
| Maximum input | Catalog `limit.input`; no generic live probe. | None. | Catalog value or `null`; never reconstructed from context and output. |
|
|
316
372
|
| Maximum output | Catalog `limit.output`; no generic live probe. | None. | Minimum of catalog value and effective context, or `null`. |
|
|
317
373
|
| Total output budget | None. | `PLURNK_PROVIDERS_OUTPUT_BUDGET`. | Percentage of effective context or absolute count, capped by known context/output limits; a call may only tighten it. |
|
|
318
|
-
| Reasoning
|
|
374
|
+
| Reasoning policy | Provider adapter and model capability. | `PLURNK_PROVIDERS_REASONING`, initially; durable worker selection thereafter. | One supported member of `off`, `adaptive`, `low`, `medium`, or `high`; `adaptive` is the default. |
|
|
375
|
+
| Reasoning budget | None. | Optional `PLURNK_PROVIDERS_REASONING_BUDGET`. | Percentage of effective context or absolute count; valid only as a strict subset of total output and effective unless reasoning is `off`. |
|
|
319
376
|
| Reasoning capability | Catalog `reasoning: true`. | Runtime activation and adapter wire style. | Catalog bit remains informational; it neither activates nor blocks reasoning. |
|
|
320
377
|
| Estimated USD rates | Models.dev input, output, optional reasoning, and optional cache rates. | None. | Missing differently-priced usage or rates produces unknown; exact all-zero rates produces estimated USD zero. |
|
|
321
378
|
|
|
@@ -348,12 +405,18 @@ implementation. xAI uses its documented OpenAI-compatible response directly
|
|
|
348
405
|
because that wire includes exact cost ticks the corresponding AI SDK projection
|
|
349
406
|
omits.
|
|
350
407
|
|
|
351
|
-
Provider declarations configure facts, not
|
|
408
|
+
§provider-fact-authority Provider declarations configure facts, not
|
|
409
|
+
credentials, and Models.dev is authoritative for cataloged providers: package
|
|
410
|
+
defaults never redefine a cataloged provider's NPM package, endpoint, or
|
|
411
|
+
credential names, and one declaration's `API_KEY_ENV` holds exactly one
|
|
412
|
+
environment name — an ordered fallback list would paper over an
|
|
413
|
+
operator/catalog naming mismatch instead of reconciling it at its owning
|
|
414
|
+
boundary. A comma-separated value is rejected at construction.
|
|
352
415
|
|
|
353
416
|
```dotenv
|
|
354
417
|
PLURNK_PROVIDERS_PROVIDER_ACME_NPM=@ai-sdk/openai-compatible
|
|
355
418
|
PLURNK_PROVIDERS_PROVIDER_ACME_BASE_URL=https://api.acme.example/v1
|
|
356
|
-
PLURNK_PROVIDERS_PROVIDER_ACME_API_KEY_ENV=ACME_API_KEY
|
|
419
|
+
PLURNK_PROVIDERS_PROVIDER_ACME_API_KEY_ENV=ACME_API_KEY
|
|
357
420
|
```
|
|
358
421
|
|
|
359
422
|
The named secret remains in the operator environment. `${ENV_NAME}` inside a
|
|
@@ -375,6 +438,16 @@ A provider plugin:
|
|
|
375
438
|
4. default-exports an AI SDK provider with `languageModel(modelId)`;
|
|
376
439
|
5. peers on compatible `ai` and `@plurnk/plurnk-providers` majors.
|
|
377
440
|
|
|
441
|
+
§provider-grammar-transport A plugin whose backend accepts a llama.cpp-style
|
|
442
|
+
GBNF grammar may declare `plurnk.grammarStyle: "llamacpp"` beside its kind and
|
|
443
|
+
name; the discovery records it and the adapted Provider carries the capability,
|
|
444
|
+
so an operator-configured rail ({§grammar-rail-registration}) rides the wire
|
|
445
|
+
exactly as on a probed llama-server. Absence or `"none"` keeps the grammar off
|
|
446
|
+
the wire; any other value fails discovery loudly. The declaration is the
|
|
447
|
+
plugin author's fact about their backend — a wrong declaration fails at the
|
|
448
|
+
rail-truth boundary ({§rail-truth-engine-verdict}), never by degrading
|
|
449
|
+
admission.
|
|
450
|
+
|
|
378
451
|
PLURNK adapts the returned language model. The plugin does not implement the
|
|
379
452
|
PLURNK `Provider`, read PLURNK tuning knobs, or reproduce transport policy.
|
|
380
453
|
|
|
@@ -414,7 +487,9 @@ every request:
|
|
|
414
487
|
|---|---:|---:|
|
|
415
488
|
| `off` | false | `0` |
|
|
416
489
|
| `adaptive` | true | configured reasoning subset, otherwise omitted |
|
|
417
|
-
|
|
490
|
+
|
|
491
|
+
The template control cannot express distinct fixed effort levels, so this
|
|
492
|
+
adapter advertises only `off` and `adaptive`.
|
|
418
493
|
|
|
419
494
|
The allowance is contained by the request's total output budget. Template calls
|
|
420
495
|
normally use `reasoning_format: "auto"` for a separate
|
|
@@ -451,6 +526,15 @@ First-party attribution, client, strike, workspace, loop, turn, and worker
|
|
|
451
526
|
headers are sent only by the `plurnk` provider. They never leak to another
|
|
452
527
|
backend.
|
|
453
528
|
|
|
529
|
+
§openrouter-app-attribution **The cataloged OpenRouter route identifies the
|
|
530
|
+
calling application through OpenRouter's current app-attribution headers.**
|
|
531
|
+
`HTTP-Referer` is the absolute HTTP(S) application URL and
|
|
532
|
+
`X-OpenRouter-Title` is its optional display title. The shipped floor identifies
|
|
533
|
+
the public Plurnk repository and may be replaced by operator configuration; an
|
|
534
|
+
explicitly empty `OPENROUTER_HTTP_REFERER` suppresses both headers. Attribution
|
|
535
|
+
applies only to the cataloged `openrouter` route and never leaks to another
|
|
536
|
+
provider merely because it uses the same SDK package.
|
|
537
|
+
|
|
454
538
|
## §9 Failures, retries, and cancellation
|
|
455
539
|
|
|
456
540
|
§provider-failure-normalization Provider failures normalize to `ProviderError`.
|
|
@@ -586,7 +670,11 @@ includes reasoning receives the total directly. When a native SDK instead adds
|
|
|
586
670
|
an explicit reasoning allowance to its generic visible-output maximum, the
|
|
587
671
|
adapter sends `total - reasoning` through the generic field and the reasoning
|
|
588
672
|
subset through the documented provider option. Core and other callers never
|
|
589
|
-
reconstruct this arithmetic.
|
|
673
|
+
reconstruct this arithmetic. When such a backend has only a manual allowance
|
|
674
|
+
and no numeric subset is configured, the adapter derives that allowance from
|
|
675
|
+
the durable policy inside the total using the native SDK's effort proportions
|
|
676
|
+
and provider minimum; an envelope too small to represent the minimum fails
|
|
677
|
+
before provider I/O.
|
|
590
678
|
|
|
591
679
|
§provider-output-budget-conformance When a completed response reports
|
|
592
680
|
normalized output-token usage greater than its effective total output budget,
|
package/dist/AiSdkProvider.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ChatMessage, PromptTokenMeasurement, Provider, ProviderCostNormalizer, ProviderGenerateArgs, ProviderRequestCapacity, ProviderResponse, ProviderUsage } from "./types.ts";
|
|
1
|
+
import type { ChatMessage, PromptTokenMeasurement, Provider, ProviderCostNormalizer, ProviderGenerateArgs, ProviderRequestCapacity, ProviderResponse, ProviderUsage, ReasoningPolicy } from "./types.ts";
|
|
2
2
|
import type { ProviderCost } from "@plurnk/plurnk-contracts";
|
|
3
3
|
import type { JSONValue } from "ai";
|
|
4
|
-
import type
|
|
4
|
+
import { type Reasoning, type ReasoningResponseStyle } from "./env.ts";
|
|
5
5
|
import type { LanguageModel } from "ai";
|
|
6
6
|
import type { PluginAttribution, PluginAttributionContext } from "@plurnk/plurnk-meta";
|
|
7
7
|
export type ProviderFetch = typeof globalThis.fetch;
|
|
@@ -32,6 +32,9 @@ export type AiSdkProviderConfig = {
|
|
|
32
32
|
maxOutputTokens?: number | null;
|
|
33
33
|
outputBudget?: number | null;
|
|
34
34
|
reasoningBudget?: number | null;
|
|
35
|
+
supportedReasoningPolicies?: readonly ReasoningPolicy[];
|
|
36
|
+
adaptiveReasoning?: "high" | "provider-default";
|
|
37
|
+
adaptiveReasoningProviderOptions?: AiSdkProviderOptions;
|
|
35
38
|
additiveReasoningProvider?: "anthropic" | "bedrock";
|
|
36
39
|
reasoningStyle?: ReasoningStyle;
|
|
37
40
|
reasoningResponseStyle?: ReasoningResponseStyle;
|
|
@@ -69,7 +72,6 @@ export type AiSdkProviderConfig = {
|
|
|
69
72
|
rawBody?: boolean;
|
|
70
73
|
tuningFloors?: boolean;
|
|
71
74
|
};
|
|
72
|
-
export declare const effortFromBudget: (budget: number) => "low" | "medium" | "high";
|
|
73
75
|
export default class AiSdkProvider implements Provider {
|
|
74
76
|
#private;
|
|
75
77
|
readonly attributions?: (context: PluginAttributionContext) => PluginAttribution;
|
|
@@ -80,6 +82,7 @@ export default class AiSdkProvider implements Provider {
|
|
|
80
82
|
get maxOutputTokens(): number | null;
|
|
81
83
|
get outputBudget(): number | null;
|
|
82
84
|
get reasoningBudget(): number | null;
|
|
85
|
+
get supportedReasoningPolicies(): readonly ReasoningPolicy[];
|
|
83
86
|
get inputCapacity(): number | null;
|
|
84
87
|
get model(): string;
|
|
85
88
|
get servedModel(): string | undefined;
|
|
@@ -87,6 +90,6 @@ export default class AiSdkProvider implements Provider {
|
|
|
87
90
|
get constrainsOutput(): boolean;
|
|
88
91
|
countPromptTokens(messages: readonly ChatMessage[], signal?: AbortSignal): Promise<PromptTokenMeasurement>;
|
|
89
92
|
assessRequestCapacity(messages: readonly ChatMessage[], maxOutputTokens?: number, signal?: AbortSignal): Promise<ProviderRequestCapacity>;
|
|
90
|
-
generate({ messages, workerId, primaryWorkerId, signal, grammar, maxOutputTokens, attributions, client, strikes, workspaceId, loop, turn, sampling, observeRequest, callKind }: ProviderGenerateArgs): Promise<ProviderResponse>;
|
|
93
|
+
generate({ messages, workerId, primaryWorkerId, signal, grammar, maxOutputTokens, attributions, client, strikes, workspaceId, loop, turn, sampling, observeRequest, observeReasoning, callKind }: ProviderGenerateArgs): Promise<ProviderResponse>;
|
|
91
94
|
}
|
|
92
95
|
//# sourceMappingURL=AiSdkProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiSdkProvider.d.ts","sourceRoot":"","sources":["../src/AiSdkProvider.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACR,WAAW,EAEX,sBAAsB,EACtB,QAAQ,EAER,sBAAsB,EAEtB,oBAAoB,EAEpB,uBAAuB,EAEvB,gBAAgB,EAChB,aAAa,
|
|
1
|
+
{"version":3,"file":"AiSdkProvider.d.ts","sourceRoot":"","sources":["../src/AiSdkProvider.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACR,WAAW,EAEX,sBAAsB,EACtB,QAAQ,EAER,sBAAsB,EAEtB,oBAAoB,EAEpB,uBAAuB,EAEvB,gBAAgB,EAChB,aAAa,EACb,eAAe,EAClB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,IAAI,CAAC;AACjD,OAAO,EAA2B,KAAK,SAAS,EAA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