@plurnk/plurnk-providers 0.12.0 → 0.14.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/README.md +6 -6
- package/SPEC.md +22 -9
- package/dist/OpenAICompat.d.ts +1 -0
- package/dist/OpenAICompat.d.ts.map +1 -1
- package/dist/OpenAICompat.js +69 -3
- package/dist/OpenAICompat.js.map +1 -1
- package/dist/standardProviders.d.ts +3 -2
- package/dist/standardProviders.d.ts.map +1 -1
- package/dist/standardProviders.js +54 -33
- package/dist/standardProviders.js.map +1 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ The framework calls `YourClass.fromEnv(env, model)` (sync or async) and expects
|
|
|
33
33
|
|
|
34
34
|
### 3. What `generate` receives — and returns
|
|
35
35
|
|
|
36
|
-
`generate({ messages, runId, signal?, grammar?, maxTokens? }) → Promise<ProviderResponse>`. Return **raw** wire output: `content` unparsed (the consumer parses the plurnk DSL — never parse it yourself), `reasoning` is the wire-reported CoT only. Honor `signal`. The provider never mutates `messages` or injects turns. `grammar` (GBNF) is attached only by backends that support it; all others ignore it (SPEC §13).
|
|
36
|
+
`generate({ messages, runId, signal?, grammar?, maxTokens?, attributions?, client? }) → Promise<ProviderResponse>`. Return **raw** wire output: `content` unparsed (the consumer parses the plurnk DSL — never parse it yourself), `reasoning` is the wire-reported CoT only. Honor `signal`. The provider never mutates `messages` or injects turns. `grammar` (GBNF) is attached only by backends that support it; all others ignore it (SPEC §13). When a grammar *is* transported, the provider verifies the backend actually enforced it — non-conforming output rejects with a `grammar_unenforced` `ProviderError` (a conformance check via `@plurnk/gbnf`, never a plurnk-DSL parse). `attributions`/`client` are per-turn first-party metadata, forwarded as `Plurnk-*` headers **only** by a provider configured with `firstPartyMetadata` (the plurnk endpoint); every other provider drops them, so they can never reach a third-party backend (SPEC §11).
|
|
37
37
|
|
|
38
38
|
## Discovery & trust
|
|
39
39
|
|
|
@@ -47,16 +47,16 @@ First-party daughters install flat via [`@plurnk/plurnk-providers-all`](https://
|
|
|
47
47
|
|
|
48
48
|
## Exports
|
|
49
49
|
|
|
50
|
-
- `Provider`, `ChatMessage`, `ProviderResponse`, `ProviderAssistant`, `ProviderUsage`, `FinishReason`, `ProviderFactory` (+ `Discovery`, `DiscoverOptions`) — types.
|
|
51
|
-
- `parseAliasesFromEnv`, `resolveActiveAlias`, `instantiateProvider`, `loadActiveProvider`, `discover` — alias-cascade resolution + two-tier provider instantiation. Tier 1 is the standard table; tier 2 is a scope-agnostic `node_modules` scan for `plurnk.kind:"provider"` packages — first-party daughters (flat via `@plurnk/plurnk-providers-all`) and third-party providers under any scope, gated by the host `PLURNK_PLUGINS_TRUSTED_ONLY` allowlist. The framework is contract-only (SPEC §5).
|
|
52
|
-
- `OpenAICompatProvider` (+ `OpenAICompatConfig`, `ReasoningStyle`, `effortFromBudget`) — shared OpenAI-compatible transport spine; siblings extend it (SPEC §11). Transports GBNF grammar-
|
|
53
|
-
- `chatCompletionStream`, `OpenAiHttpError`, `StreamResponse` — the shared SSE client.
|
|
50
|
+
- `Provider`, `ChatMessage`, `ProviderResponse`, `ProviderAssistant`, `ProviderUsage`, `FinishReason`, `ProviderFactory`, `ProviderAlias` (+ `Discovery`, `DiscoverOptions`) — types.
|
|
51
|
+
- `parseAliasesFromEnv`, `resolveActiveAlias`, `instantiateProvider`, `loadActiveProvider`, `discover`, `resetDiscoveryCache` — alias-cascade resolution + two-tier provider instantiation (`resetDiscoveryCache` clears the memoized tier-2 scan; for tests). Tier 1 is the standard table; tier 2 is a scope-agnostic `node_modules` scan for `plurnk.kind:"provider"` packages — first-party daughters (flat via `@plurnk/plurnk-providers-all`) and third-party providers under any scope, gated by the host `PLURNK_PLUGINS_TRUSTED_ONLY` allowlist. The framework is contract-only (SPEC §5).
|
|
52
|
+
- `OpenAICompatProvider` (+ `OpenAICompatConfig`, `ReasoningStyle`, `GrammarStyle`, `effortFromBudget`) — shared OpenAI-compatible transport spine; siblings extend it (SPEC §11). Transports a GBNF grammar via `grammarStyle` — `llamacpp` (top-level `grammar` field) or `response_format` (Fireworks); `none` drops it — and verifies the backend enforced it against `@plurnk/gbnf`, rejecting non-conforming output as `grammar_unenforced` (SPEC §13).
|
|
53
|
+
- `chatCompletionStream`, `chatCompletion`, `OpenAiHttpError`, `StreamResponse` — the shared SSE client (`chatCompletion` is the non-streaming variant).
|
|
54
54
|
- `parseRequiredInt`, `parseOptionalInt`, `requireEnv`, `reasoningBudgetFromEnv` — env helpers (SPEC §4; all required-with-named-errors, no in-code defaults).
|
|
55
55
|
- `normalizeUsage`, `computeCost` (+ `RawUsage`, `TokenRates`) — usage normalization to the §2 invariant and the single cost formula (SPEC §11).
|
|
56
56
|
- `ProviderError`, `classifyProviderError`, `toProviderError`, `providerSource` (+ `TelemetryEvent`, `ProviderTelemetryKind`) — the TelemetryEvent envelope for transport failures (SPEC §12).
|
|
57
57
|
- `tokenizerFor`, `tokenizerByPublisher`, `parseTokenizerFamily` (+ `TokenizerFamily`, `CountTokens`) — synchronous tokenizer strategies.
|
|
58
58
|
- `STANDARD_PROVIDERS`, `isStandardProvider`, `standardProviderFromEnv` — pure-config OpenAI-compatible providers (no sibling package needed).
|
|
59
|
-
- `Mock` — reference implementation + test fixture (dual-purpose).
|
|
59
|
+
- `Mock` (+ `mockDefaultUsage`) — reference implementation + test fixture (dual-purpose).
|
|
60
60
|
|
|
61
61
|
## Tests
|
|
62
62
|
|
package/SPEC.md
CHANGED
|
@@ -39,8 +39,11 @@ interface Provider {
|
|
|
39
39
|
// grammar-constrained sampling (§13) — attached verbatim by capable
|
|
40
40
|
// backends, ignored by all others. `maxTokens` is the consumer's per-call
|
|
41
41
|
// output ceiling (wire `max_tokens`); absent means the server default,
|
|
42
|
-
// which is typically UNBOUNDED.
|
|
43
|
-
|
|
42
|
+
// which is typically UNBOUNDED. `attributions`/`client` are optional
|
|
43
|
+
// first-party metadata, forwarded as `Plurnk-*` headers ONLY by a provider
|
|
44
|
+
// configured with `firstPartyMetadata` (the plurnk endpoint) and dropped by
|
|
45
|
+
// every other — structurally unable to reach a third-party backend (§11).
|
|
46
|
+
generate(args: { messages: ChatMessage[]; runId: string; signal?: AbortSignal; grammar?: string; maxTokens?: number; attributions?: string[]; client?: string }): Promise<ProviderResponse>;
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
interface ProviderResponse {
|
|
@@ -76,6 +79,7 @@ Usage invariant: `total = prompt + completion + reasoning`; `cached ⊆ prompt`;
|
|
|
76
79
|
- `contextSize` resolves to `null` when provider can't determine the model's context window. Consumer treats null as "no budget info available."
|
|
77
80
|
- `generate` rejects on signal abort — does NOT resolve with partial content.
|
|
78
81
|
- `generate` transports `grammar` verbatim when the backend supports grammar-constrained sampling, and silently ignores it otherwise (§13). The provider never chooses or modifies the grammar.
|
|
82
|
+
- `generate` **verifies enforcement** when it transported a grammar: it validates the returned `content` against that grammar and rejects with a `grammar_unenforced` `ProviderError` if the backend did not actually constrain the output (§13). This is a grammar-**conformance** check against the grammar the provider already holds — *not* a plurnk-DSL parse (that stays consumer-side, below) — so it remains backend- and DSL-agnostic.
|
|
79
83
|
- **Backend affinity is the provider's internal guarantee, keyed by `runId`.** The consumer says *which run this is*, never *which backend resource serves it* — raw resource identifiers (slot integers, connections) never cross the contract in either direction. On slot-pinning backends (llama-server `--parallel N>1`), the provider keeps each run sticky to one slot and spreads distinct runs across slots, so each concurrent run keeps its KV-cache prefix warm (un-pinned routing is the server's similarity heuristic — slot hops re-pay full prefills). Backends without affinity semantics ignore `runId` entirely.
|
|
80
84
|
|
|
81
85
|
## §3 `fromEnv(env, model)` factory
|
|
@@ -104,7 +108,7 @@ The consumer's instantiation path calls `mod.default.fromEnv(env, alias.model)`
|
|
|
104
108
|
|
|
105
109
|
Each provider's `fromEnv` reads these:
|
|
106
110
|
|
|
107
|
-
- **`PLURNK_PROVIDERS_REASONING_BUDGET`** — REQUIRED integer `>= -1`. One knob carries the whole side-channel-reasoning space: **`0`** off, **`-1`** on/adaptive (no cap — model/backend decides depth), **`N>0`** on/capped at `N`. The provider maps this single intent to the active backend's mechanism — llama-server `chat_template_kwargs: { enable_thinking }` (always emitted; the explicit FALSE is the only working off-switch — llama-server ignores `think` and per-request budgets, and its `--reasoning-budget` default otherwise keeps the channel live, fatal under an active grammar, §13), Ollama `think`, relay `include_reasoning`, cloud `reasoning_effort` (tier from `N`; adaptive `-1` omits the field, letting the API pick its depth), Anthropic `thinking: { type: "adaptive" }` (`-1`) / `budget_tokens` (`N`). For native backends the magnitude is irrelevant — only zero vs non-zero matters. Consumers state intent, never mechanism. (
|
|
111
|
+
- **`PLURNK_PROVIDERS_REASONING_BUDGET`** — REQUIRED integer `>= -1`. One knob carries the whole side-channel-reasoning space: **`0`** off, **`-1`** on/adaptive (no cap — model/backend decides depth), **`N>0`** on/capped at `N`. The provider maps this single intent to the active backend's mechanism — llama-server `chat_template_kwargs: { enable_thinking }` (always emitted; the explicit FALSE is the only working off-switch — llama-server ignores `think` and per-request budgets, and its `--reasoning-budget` default otherwise keeps the channel live, fatal under an active grammar, §13), Ollama `think`, relay `include_reasoning`, cloud `reasoning_effort` (tier from `N`; adaptive `-1` omits the field, letting the API pick its depth), Anthropic `thinking: { type: "adaptive" }` (`-1`) / `budget_tokens` (`N`). For native backends the magnitude is irrelevant — only zero vs non-zero matters. Consumers state intent, never mechanism. (In-DSL `<<PLAN>>` reasoning has **no provider footprint** and no operator knob: `PLAN` is a required element of the canonical plurnk grammar the consumer attaches via `generate`'s `grammar`. The provider transports that grammar verbatim and never forces, prefills, or toggles `PLAN`.)
|
|
108
112
|
|
|
109
113
|
Read via `reasoningBudgetFromEnv` and **fail hard when unset** — configuration lives in the operator's env (the consumer's `.env.example` declares every var); the framework never defaults a knob in code.
|
|
110
114
|
- **`PLURNK_FETCH_TIMEOUT`** — service-wide ms ceiling on any single outbound request (**per attempt**, not shared across retries). Each `fromEnv` reads and passes as `AbortSignal.timeout`. Per-provider override envs are NOT part of the contract.
|
|
@@ -134,7 +138,7 @@ This package's exported resolution surface:
|
|
|
134
138
|
|
|
135
139
|
**Two-tier provider resolution — owned entirely by this package.** A provider name resolves in this order:
|
|
136
140
|
|
|
137
|
-
1. **Standard provider** (`§11`) — if `isStandardProvider(name)`, instantiated directly via `standardProviderFromEnv(name, env, model)`. No package is imported. Covers every plain OpenAI-compatible endpoint (`openai`, `groq`, `deepseek`, `mistral`, `together`, `fireworks`, `deepinfra`, `anthropic`, `bedrock`, `plurnk`, …) — including first-party Claude (Anthropic's compat endpoint, bearer auth, the `thinking` reasoning param), AWS Bedrock (its compat endpoint, Bedrock-API-key bearer, region
|
|
141
|
+
1. **Standard provider** (`§11`) — if `isStandardProvider(name)`, instantiated directly via `standardProviderFromEnv(name, env, model)`. No package is imported. Covers every plain OpenAI-compatible endpoint (`openai`, `groq`, `deepseek`, `mistral`, `together`, `fireworks`, `deepinfra`, `anthropic`, `bedrock`, `plurnk`, …) — including first-party Claude (Anthropic's compat endpoint, bearer auth, the `thinking` reasoning param), AWS Bedrock (its compat endpoint at the `/openai/v1` path, Bedrock-API-key bearer; the base is `BEDROCK_BASE_URL` if set, else derived as `https://bedrock-runtime.{region}.amazonaws.com/openai/v1` from the standard `AWS_REGION`/`AWS_DEFAULT_REGION`), and the **`plurnk` hosted model** (a deliberately plain remote OpenAI endpoint at `model.plurnk.ai`, overridable via `PLURNK_BASE_URL` — it reads its *server-controlled* context window from upstream but sends no grammar and no tuning; the backend's model/window/grammar are the router's concern, invisible to the open-source client, so a 32k→48k or grammar change is a one-line server decision, never a client release); none needs a daughter. `plurnk` authenticates with a single optional bearer (`PLURNK_API_KEY`, sent only when set — the key identifies the account server-side), like any other standard bearer. A spec's `apiKeyVar`/`baseUrlVar` may be a **list** of accepted env-var aliases — the conventional names the wild uses for one credential/base (e.g. `deepinfra` → `DEEPINFRA_API_KEY` / `DEEPINFRA_API_TOKEN` / `DEEPINFRA_TOKEN`; `openai` base → `OPENAI_BASE_URL` / `OPENAI_API_BASE`). First set non-empty wins; a required key unset across *all* aliases fails hard naming each. This is alias resolution over operator-set values, never a fabricated default. (An entry MAY instead supply a custom `headersFromEnv` builder for auth a bearer can't express — multi-header/credential schemes — or a `baseUrlFromEnv` builder to template the base from env, as bedrock does.) The standard table is **authoritative**: a scanned package whose name duplicates a standard one is shadowed (tier 1 returns first).
|
|
138
142
|
2. **Discovered package** — otherwise, a **scope-agnostic `node_modules` scan** (`discover()`) maps the provider name to the installed package that declares `plurnk: { kind: "provider", name }`, which is dynamic-imported and `fromEnv(env, model)`-called. Covers first-party daughters with real runtime surface (`openrouter`, `ollama`, `google`, `xai`, `cloudflare`, the planned `vertex`/`cohere`) **and any third-party provider published under its own scope** (`@acme/llm-provider-foo`) — no involvement from us, no `@plurnk` scope assumption. Two installed packages claiming the same name → fail-hard naming both. Unknown name → fail-hard. The scan runs once per process and is memoized.
|
|
139
143
|
|
|
140
144
|
Discovery honors the host **trust gate** `PLURNK_PLUGINS_TRUSTED_ONLY` — the same env var the execs/mimes/schemes families read (plurnk-service#229, #15). OFF (unset/empty/`0`) trusts every installed provider; ON (any value) trusts `@plurnk/*` plus a comma-separated allowlist and declines the rest. A declined package is recorded in `skipped` (never registered, never thrown), so requesting its name yields a precise *untrusted* error rather than *unknown*.
|
|
@@ -143,7 +147,7 @@ The framework is **contract-only** — it does **not** depend on its daughters.
|
|
|
143
147
|
|
|
144
148
|
## §6 Engine → provider guarantees (consumer side)
|
|
145
149
|
|
|
146
|
-
- `messages` is a complete prompt. Consumer has pre-assembled all sections. Provider does not add, reorder, or inject turns — the wire `messages` are exactly what the consumer passed. (
|
|
150
|
+
- `messages` is a complete prompt. Consumer has pre-assembled all sections. Provider does not add, reorder, or inject turns — the wire `messages` are exactly what the consumer passed. (The provider injects no `PLAN` turn — `PLAN` is part of the consumer's grammar contract, §4.)
|
|
147
151
|
- Every `generate` carries `runId` — the run's stable, opaque identity. Same run → same string across its turns; distinct runs → distinct strings.
|
|
148
152
|
- `signal` is wired to the run's AbortController.
|
|
149
153
|
- `generate` is single-call per turn. No parallel calls on the same instance.
|
|
@@ -211,6 +215,7 @@ A sibling package satisfies the contract when:
|
|
|
211
215
|
11. No DB access, no imports from `@plurnk/plurnk-service`.
|
|
212
216
|
12. No runtime import of `@plurnk/plurnk-grammar` parser entry points.
|
|
213
217
|
13. `generate` invoked with `grammar` against a backend without grammar support sends no grammar-related wire fields and does not error (§13).
|
|
218
|
+
14. `generate` that transported a grammar and received conforming output resolves; output the grammar rejects (or an incomplete match) rejects with a `grammar_unenforced` `ProviderError` (§13). (Inherited from `OpenAICompatProvider`; bespoke siblings on a non-compat transport implement it.)
|
|
214
219
|
|
|
215
220
|
Sibling-specific behavioral tests (wire-format compliance, model-family quirks, retry logic) live in each package's own test surface.
|
|
216
221
|
|
|
@@ -229,6 +234,7 @@ The framework ships the transport spine every OpenAI-compatible provider had bee
|
|
|
229
234
|
reasoningBudget, reasoningStyle, // "none" | "think" | "include_reasoning" | "effort" | "template" | "anthropic"
|
|
230
235
|
countTokens, costFor, // strategies; default heuristic / free
|
|
231
236
|
grammarStyle, // "none" | "llamacpp" | "response_format" — GBNF wire shape (§13); default "none"
|
|
237
|
+
gbnfDebug, // PLURNK_GBNF_DEBUG: validate a grammar locally + throw on invalid, but DON'T send it (§13); default false
|
|
232
238
|
streaming, // SSE transport; default true (false → one non-streamed JSON)
|
|
233
239
|
supportsSlotPinning, slotCount, // INTERNAL slot-affinity wiring (run→id_slot); never consumer-facing
|
|
234
240
|
});
|
|
@@ -236,7 +242,7 @@ The framework ships the transport spine every OpenAI-compatible provider had bee
|
|
|
236
242
|
|
|
237
243
|
The `openai` standard provider sets `grammarStyle: "llamacpp"`, `supportsSlotPinning`, and `slotCount` from the same llama-server fingerprint (`/v1/models` `meta` block + `/props`). The run→slot mapping lives inside `OpenAICompatProvider`: sticky per `runId`, round-robin across new runs, LRU-bounded.
|
|
238
244
|
|
|
239
|
-
- **`chatCompletionStream` / `OpenAiHttpError` / `StreamResponse`** — the SSE
|
|
245
|
+
- **`chatCompletionStream` / `chatCompletion` / `OpenAiHttpError` / `StreamResponse`** — the shared HTTP client (`chatCompletionStream` for SSE, `chatCompletion` for the non-streamed JSON the `streaming: false` path uses). One shared copy.
|
|
240
246
|
- **`normalizeUsage(raw)` / `computeCost(usage, {input, output, cached})`** — usage normalization to the §2 invariant (handles both reasoning-reporting conventions) and the single cost formula (bills `completion + reasoning` at the output rate). `OpenAICompatProvider` applies `normalizeUsage` automatically; siblings pass their per-token rates to `computeCost` in their `costFor`.
|
|
241
247
|
- **`parseRequiredInt` / `parseOptionalInt` / `requireEnv`** — env helpers; each takes a provider `label` for error prefixing.
|
|
242
248
|
- **`tokenizerFor(family)` / `tokenizerByPublisher(model, table, index)` / `parseTokenizerFamily(...)`** — synchronous tokenizer strategies (`heuristic` | `cl100k` | `llama`) and per-publisher dispatch for relay providers.
|
|
@@ -259,7 +265,7 @@ Transport failures surface as a `ProviderError` (extends `Error`, so existing ca
|
|
|
259
265
|
```
|
|
260
266
|
|
|
261
267
|
- `source` is `provider:<vendor>` (schema pattern `^[a-z]+(:[a-z][a-z0-9-]*)?$`); standard providers set it from their name, siblings via the `source` config field (default `"provider"`).
|
|
262
|
-
- `kind` ∈ `rate_limit | network_failure | model_refused | invalid_response | unauthorized | quota_exceeded`. HTTP status maps: 401/403→`unauthorized`, 402→`quota_exceeded`, 429→`rate_limit`, ≥500→`network_failure`, other 4xx→`invalid_response`; timeouts/fetch errors→`network_failure`. (`model_refused` is response-level — minted consumer-side from a `content_filter` finish reason, not from a thrown error.)
|
|
268
|
+
- `kind` ∈ `rate_limit | network_failure | model_refused | invalid_response | unauthorized | quota_exceeded | grammar_unenforced`. HTTP status maps: 401/403→`unauthorized`, 402→`quota_exceeded`, 429→`rate_limit`, ≥500→`network_failure`, other 4xx→`invalid_response`; timeouts/fetch errors→`network_failure`. (`model_refused` is response-level — minted consumer-side from a `content_filter` finish reason, not from a thrown error.) **`grammar_unenforced`** is response-level too: the provider mints it when a transported grammar was not enforced by the backend (§13); terminal, never retried.
|
|
263
269
|
- `message` is terse and factual (no guidance prose); `position` is `null` (provider failures aren't localizable into prior content).
|
|
264
270
|
- **Caller-initiated abort is NOT telemetry** — an aborted `signal` rethrows the original abort, never a `ProviderError`.
|
|
265
271
|
|
|
@@ -270,14 +276,14 @@ The `TelemetryEvent` shape is mirrored **locally** (`./telemetry.ts`), structura
|
|
|
270
276
|
`@plurnk/plurnk-grammar` ships `@plurnk/plurnk-grammar/plurnk.gbnf` — a generated llama.cpp grammar constraining sampling to the canonical plurnk form. Ownership splits three ways:
|
|
271
277
|
|
|
272
278
|
- **plurnk-grammar** owns the artifact (canonical-form GBNF, `L(GBNF) ⊂ L(ANTLR)` invariant, tests).
|
|
273
|
-
- **This layer** owns capability detection
|
|
279
|
+
- **This layer** owns capability detection, transport, **and enforcement verification**: `generate({ …, grammar })` attaches the string **verbatim** as the `grammar` body field when the backend supports it, sends no grammar-related field otherwise (cloud APIs reject unknown params), and — when it did transport a grammar — checks that the response actually conforms. The provider never chooses or modifies the grammar.
|
|
274
280
|
- **The consumer** owns policy: whether to constrain a given call, and which root variant to send (e.g. the `root ::= statement` single-statement substitution that forces EOS at the close tag — the shipped `statement+` root never forces EOS, so greedy generation runs to `max_tokens`).
|
|
275
281
|
|
|
276
282
|
**Sampling guard.** Greedy decoding under hard constraint masks degenerates into repetition loops at `repeat_penalty: 1.0`, so `OpenAICompatProvider` sends a per-request `repeat_penalty: 1.15` floor alongside every attached grammar — never relying on server launch flags. (Probed live on llama.cpp b894 + gemma-4-26B; reference: plurnk-grammar `test/llama/gbnf-live.test.ts`.)
|
|
277
283
|
|
|
278
284
|
**The cap is the consumer's required guard.** The repeat-penalty floor suppresses short repetition cycles, NOT long-cycle degeneration: under the multi-op root (optional EOS) at near-greedy temperatures, a constrained emission can answer correctly in its first tokens and then loop to the **context wall** (observed live: 30,736 junk tokens to `finish_reason: length`, minutes of decode reading as a "hang", with the junk echoed into the next turn's prompt — providers#10). No layer defaults a cap: the wire default is unbounded (`n_predict: -1`) and the provider transports policy, never invents it. A consumer enabling constrained sampling MUST pass `maxTokens` (or send a root variant that forces EOS).
|
|
279
285
|
|
|
280
|
-
**Native reasoning and the grammar are mutually exclusive; in-DSL reasoning is the working pattern.** The GBNF masks every sampled token. With NATIVE thinking live (llama-server's own `--reasoning-budget` default, or `enable_thinking: true`), the server auto-gates the grammar past the think block — reasoning flows free — but content-channel enforcement then **leaks** (unconstrained prose, degenerates) or content never arrives; explicit `grammar_lazy`/`grammar_triggers` are ignored on the chat-completions path. The constrained configuration therefore requires the native channel **explicitly closed** — `PLURNK_PROVIDERS_REASONING_BUDGET=0`, which the `template` style emits as `enable_thinking: false`; mere field omission leaves the server default live, and think-inviting tasks then break the loop. With the channel closed, the model
|
|
286
|
+
**Native reasoning and the grammar are mutually exclusive; in-DSL reasoning is the working pattern.** The GBNF masks every sampled token. With NATIVE thinking live (llama-server's own `--reasoning-budget` default, or `enable_thinking: true`), the server auto-gates the grammar past the think block — reasoning flows free — but content-channel enforcement then **leaks** (unconstrained prose, degenerates) or content never arrives; explicit `grammar_lazy`/`grammar_triggers` are ignored on the chat-completions path. The constrained configuration therefore requires the native channel **explicitly closed** — `PLURNK_PROVIDERS_REASONING_BUDGET=0`, which the `template` style emits as `enable_thinking: false`; mere field omission leaves the server default live, and think-inviting tasks then break the loop. With the channel closed, the model reasons **inside the DSL**: the canonical grammar's required `PLAN` statement is a free-text body the model fills with genuine step-by-step reasoning before acting (probed live, b894+gemma: correct chain-of-thought inside `<<PLAN:…:PLAN`, then a clean `SEND`, `finish_reason: stop`). The `PLAN` element belongs to the consumer's grammar contract; the provider's only job is closing the native channel deterministically.
|
|
281
287
|
|
|
282
288
|
**Grammar transport — same GBNF, different wire shapes (`grammarStyle`, default `"none"`).** Backends carry the *same* grammar string differently:
|
|
283
289
|
- **`"llamacpp"`** — top-level `grammar` field + the repeat-penalty floor (§9). Detected from the §11 probe: only llama-server rows on `GET /v1/models` carry a `meta` block. This is any local llama-server (e.g. the generic `openai` provider fronting llama.cpp). `model.plurnk.ai` deliberately opts out via `detectLlamaServer: false` — it reads a window but is treated as a plain OpenAI endpoint, so it is never fingerprinted and never receives a grammar (the router injects its own).
|
|
@@ -286,4 +292,11 @@ The `TelemetryEvent` shape is mirrored **locally** (`./telemetry.ts`), structura
|
|
|
286
292
|
|
|
287
293
|
vLLM/Deepinfra was probed and does **not** expose working GBNF over its OpenAI-compat surface (`guided_grammar` silently ignored; `response_format` accepts only `'text'`) — deliberately left `"none"`. Bespoke siblings opt in via config when their backend qualifies. Capability stays provider-internal.
|
|
288
294
|
|
|
295
|
+
**Enforcement verification (the response side).** Transporting the grammar is necessary but not sufficient — a backend can silently drop the `grammar` field, mislabel the constrained channel (the Fireworks `reasoning_content` case above), or leak unconstrained prose. So when `generate` *did* transport a grammar (`grammarStyle !== "none"`), it validates the returned `content` against that grammar with **`@plurnk/gbnf`** — a zero-dependency, faithful TypeScript port of llama.cpp's own grammar engine, differentially tested against the compiled C validator, hence authoritative for the `llamacpp` path. (This is `@plurnk/gbnf`, the generic GBNF *validator* — **not** `@plurnk/plurnk-grammar`, the plurnk artifact + parser the framework still never depends on; §11.) The check is a grammar-**conformance** test against a string the provider already holds, carrying zero plurnk-DSL semantics, so it does not breach §7/§8 (no `content`→`PlurnkStatement[]` parse).
|
|
296
|
+
|
|
297
|
+
- **Strict.** Any non-`accept` verdict fails hard with a `grammar_unenforced` `ProviderError` (§12): a `reject` (a code point the grammar forbids — the constraint was not applied) *and* an `incomplete` (a valid prefix that never reached a terminal state — truncated or leaked output). The message names the diverging code point / what the grammar expected.
|
|
298
|
+
- **Verify gap is non-fatal.** If the validator cannot even parse the grammar the backend accepted (a port-vs-llama.cpp divergence), `generate` does **not** fail a transport that may have worked — it skips the check and emits a `process` warning (`code: "PLURNK_GRAMMAR_UNVERIFIABLE"`). That gap is a validator bug to fix, not a backend failure.
|
|
299
|
+
|
|
300
|
+
**Debug mode — validate the grammar without passing it to the model (`PLURNK_GBNF_DEBUG`).** An optional, off-by-default toggle (`0`/empty = off; any other value = on; the standard-provider config field is `gbnfDebug`). When on and a grammar would be transported, `generate` validates it with `@plurnk/gbnf` **before any wire call** and **throws fail-hard on a malformed grammar** — and the grammar is **not** sent to the model (the request runs unconstrained, and enforcement verification is skipped, since nothing was constrained). It catches invalid grammars (e.g. while editing the plurnk grammar) without a model round-trip; leave it off in production, where a constrained call should actually constrain.
|
|
301
|
+
|
|
289
302
|
Zero grammar dependency (§11) is preserved: the GBNF string arrives per call; this package never imports the artifact.
|
package/dist/OpenAICompat.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAICompat.d.ts","sourceRoot":"","sources":["../src/OpenAICompat.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAgB,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"OpenAICompat.d.ts","sourceRoot":"","sources":["../src/OpenAICompat.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAgB,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAqBvG,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,GAAG,mBAAmB,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAC;AAY1G,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,iBAAiB,CAAC;AAEnE,MAAM,MAAM,kBAAkB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;I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AC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAwErQ"}
|
package/dist/OpenAICompat.js
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
// Pure-config providers come from ./standardProviders.ts with no sibling at all.
|
|
10
10
|
import { chatCompletionStream, chatCompletion, OpenAiHttpError } from "./openaiStream.js";
|
|
11
11
|
import { normalizeUsage } from "./usage.js";
|
|
12
|
-
import { toProviderError, classifyProviderError } from "./telemetry.js";
|
|
12
|
+
import { toProviderError, classifyProviderError, ProviderError } from "./telemetry.js";
|
|
13
|
+
import { validateGbnf } from "@plurnk/gbnf";
|
|
13
14
|
// Sampling guard under an active grammar (SPEC §13): greedy decoding under
|
|
14
15
|
// hard constraint masks degenerates into repetition loops at the server
|
|
15
16
|
// default of 1.0, so the floor rides per-request with every attached grammar —
|
|
@@ -49,6 +50,19 @@ export const effortFromBudget = (budget) => {
|
|
|
49
50
|
return "high";
|
|
50
51
|
};
|
|
51
52
|
const heuristicTokens = (text) => (text.length === 0 ? 0 : Math.ceil(text.length / 4));
|
|
53
|
+
// Render a non-accept verdict into a terse, factual grammar_unenforced message
|
|
54
|
+
// (SPEC §12 message policy: no guidance prose). `reject` names the diverging code
|
|
55
|
+
// point + what the grammar would have accepted; `incomplete` names the valid-prefix
|
|
56
|
+
// length that never reached a terminal state.
|
|
57
|
+
const describeUnenforced = (v) => {
|
|
58
|
+
if (v.status === "reject") {
|
|
59
|
+
const expected = v.expected.length > 0
|
|
60
|
+
? v.expected.map((e) => `${e.rule} accepts ${e.accepts}`).join(", ")
|
|
61
|
+
: "end of input";
|
|
62
|
+
return `grammar not enforced: output rejected by the transported grammar at code point ${v.pos} (${JSON.stringify(v.char)}); expected ${expected}`;
|
|
63
|
+
}
|
|
64
|
+
return `grammar not enforced: output is an incomplete match of the transported grammar — a valid prefix of ${v.pos} code points that never terminated`;
|
|
65
|
+
};
|
|
52
66
|
export default class OpenAICompatProvider {
|
|
53
67
|
#model;
|
|
54
68
|
#url;
|
|
@@ -61,6 +75,7 @@ export default class OpenAICompatProvider {
|
|
|
61
75
|
#costFor;
|
|
62
76
|
#source;
|
|
63
77
|
#grammarStyle;
|
|
78
|
+
#gbnfDebug;
|
|
64
79
|
#streaming;
|
|
65
80
|
#firstPartyMetadata;
|
|
66
81
|
#supportsSlotPinning;
|
|
@@ -79,6 +94,7 @@ export default class OpenAICompatProvider {
|
|
|
79
94
|
this.#costFor = config.costFor ?? (() => 0);
|
|
80
95
|
this.#source = config.source ?? "provider";
|
|
81
96
|
this.#grammarStyle = config.grammarStyle ?? "none";
|
|
97
|
+
this.#gbnfDebug = config.gbnfDebug ?? false;
|
|
82
98
|
this.#streaming = config.streaming ?? true;
|
|
83
99
|
this.#firstPartyMetadata = config.firstPartyMetadata ?? false;
|
|
84
100
|
this.#supportsSlotPinning = config.supportsSlotPinning ?? false;
|
|
@@ -162,17 +178,63 @@ export default class OpenAICompatProvider {
|
|
|
162
178
|
h["Plurnk-Client"] = client;
|
|
163
179
|
return h;
|
|
164
180
|
}
|
|
181
|
+
// Enforcement verification (SPEC §13). When a grammar was actually transported
|
|
182
|
+
// (grammarStyle !== "none"), the backend MUST have constrained the output;
|
|
183
|
+
// some silently drop the grammar field or mislabel the channel, and without
|
|
184
|
+
// this check we would return unconstrained output as if enforced. STRICT: any
|
|
185
|
+
// non-accept verdict (reject, or an incomplete/never-terminated match) is a
|
|
186
|
+
// grammar_unenforced failure. A grammar our own validator can't parse — even
|
|
187
|
+
// though the backend accepted it (a port-vs-llama.cpp gap) — is a non-fatal
|
|
188
|
+
// verify gap: warn, don't fail a transport that may have worked. This is a
|
|
189
|
+
// conformance check against the grammar we already hold, NOT a plurnk-DSL
|
|
190
|
+
// parse (§8) — it stays grammar-generic and backend-agnostic.
|
|
191
|
+
#verifyGrammarEnforced(grammar, content) {
|
|
192
|
+
let verdict;
|
|
193
|
+
try {
|
|
194
|
+
verdict = validateGbnf(grammar, content);
|
|
195
|
+
}
|
|
196
|
+
catch (cause) {
|
|
197
|
+
process.emitWarning(`${this.#source}: could not verify grammar enforcement — the transported grammar did not parse in @plurnk/gbnf (${cause.message})`, { code: "PLURNK_GRAMMAR_UNVERIFIABLE" });
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (verdict.status === "accept")
|
|
201
|
+
return;
|
|
202
|
+
throw new ProviderError(this.#source, "grammar_unenforced", describeUnenforced(verdict));
|
|
203
|
+
}
|
|
204
|
+
// PLURNK_GBNF_DEBUG (SPEC §13): validate the supplied GBNF locally and fail
|
|
205
|
+
// hard if it's malformed, BEFORE any wire call — and the grammar is NOT
|
|
206
|
+
// transported, so the request runs unconstrained. A debug aid to catch invalid
|
|
207
|
+
// grammars (e.g. while editing the plurnk grammar) without a model round-trip;
|
|
208
|
+
// off in production. `validateGbnf(grammar, "")` parses the grammar + resolves
|
|
209
|
+
// its root, throwing iff the grammar itself is invalid (the empty input's
|
|
210
|
+
// verdict is irrelevant — we only care that parsing succeeded).
|
|
211
|
+
#assertGrammarValid(grammar) {
|
|
212
|
+
try {
|
|
213
|
+
validateGbnf(grammar, "");
|
|
214
|
+
}
|
|
215
|
+
catch (cause) {
|
|
216
|
+
throw new Error(`grammar validation (PLURNK_GBNF_DEBUG): invalid GBNF — ${cause.message}`, { cause });
|
|
217
|
+
}
|
|
218
|
+
}
|
|
165
219
|
async generate({ messages, runId, signal, grammar, maxTokens, attributions, client }) {
|
|
166
220
|
// Boundary validation (SPEC §2): the run identity is required.
|
|
167
221
|
if (runId === undefined || runId.length === 0)
|
|
168
222
|
throw new Error("generate: runId is required — the run's stable, opaque identity");
|
|
169
223
|
// Reject before any wire call when already aborted (SPEC §10.8).
|
|
170
224
|
signal?.throwIfAborted();
|
|
225
|
+
// Grammar handling (SPEC §13). PLURNK_GBNF_DEBUG validates the supplied
|
|
226
|
+
// grammar locally and throws on a malformed one, WITHOUT transporting it —
|
|
227
|
+
// the request then runs unconstrained (and skips enforcement). Otherwise the
|
|
228
|
+
// grammar is sent when the backend supports it (grammarStyle !== "none").
|
|
229
|
+
const wantGrammar = grammar !== undefined && this.#grammarStyle !== "none";
|
|
230
|
+
if (wantGrammar && this.#gbnfDebug)
|
|
231
|
+
this.#assertGrammarValid(grammar);
|
|
232
|
+
const sendGrammar = wantGrammar && !this.#gbnfDebug ? grammar : undefined;
|
|
171
233
|
const body = {
|
|
172
234
|
model: this.#model,
|
|
173
235
|
messages,
|
|
174
236
|
...this.#reasoningBody(),
|
|
175
|
-
...this.#grammarBody(
|
|
237
|
+
...this.#grammarBody(sendGrammar),
|
|
176
238
|
...(maxTokens !== undefined ? { max_tokens: maxTokens } : {}),
|
|
177
239
|
...this.#slotBody(runId),
|
|
178
240
|
};
|
|
@@ -186,7 +248,7 @@ export default class OpenAICompatProvider {
|
|
|
186
248
|
// constrained output mislabeled as reasoning_content, yet returns it as
|
|
187
249
|
// content non-streamed. The atomic dump is correct either way, so the
|
|
188
250
|
// demotion is scoped to exactly that request, not the whole provider.
|
|
189
|
-
const grammarBreaksStream =
|
|
251
|
+
const grammarBreaksStream = sendGrammar !== undefined && this.#grammarStyle === "response_format";
|
|
190
252
|
const transport = this.#streaming && !grammarBreaksStream ? chatCompletionStream : chatCompletion;
|
|
191
253
|
// Per-request headers = static auth/routing + any first-party telemetry.
|
|
192
254
|
const metaHeaders = this.#metadataHeaders(attributions, client);
|
|
@@ -211,6 +273,10 @@ export default class OpenAICompatProvider {
|
|
|
211
273
|
await sleepWithAbort(retryAfter ?? RETRY_BASE_DELAY_MS * 2 ** attempt, signal);
|
|
212
274
|
}
|
|
213
275
|
}
|
|
276
|
+
// Verify the backend honored the grammar we transported (§13) before the
|
|
277
|
+
// content reaches the consumer — only when we actually sent one.
|
|
278
|
+
if (sendGrammar !== undefined)
|
|
279
|
+
this.#verifyGrammarEnforced(sendGrammar, raw.content);
|
|
214
280
|
return {
|
|
215
281
|
assistant: {
|
|
216
282
|
content: raw.content,
|
package/dist/OpenAICompat.js.map
CHANGED
|
@@ -1 +1 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O,IAAI,IAAI,CAAC,cAAc;oBAAE,MAAM,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBACrG,MAAM,UAAU,GAAG,GAAG,YAAY,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;gBAC1E,MAAM,cAAc,CAAC,UAAU,IAAI,mBAAmB,GAAG,CAAC,IAAI,OAAO,EAAE,MAAM,CAAC,CAAC;YACnF,CAAC;QACL,CAAC;QAED,yEAAyE;QACzE,iEAAiE;QACjE,IAAI,WAAW,KAAK,SAAS;YAAE,IAAI,CAAC,sBAAsB,CAAC,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QAErF,OAAO;YACH,SAAS,EAAE;gBACP,OAAO,EAAE,GAAG,CAAC,OAAO;gBACpB,SAAS,EAAE,GAAG,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI;gBAC1E,KAAK,EAAE,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC;gBAChC,YAAY,EAAE,qBAAqB,CAAC,GAAG,CAAC,aAAa,CAAC;gBACtD,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM;aAClC;YACD,YAAY,EAAE,GAAG;SACpB,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -2,11 +2,12 @@ import type { Provider } from "./types.ts";
|
|
|
2
2
|
import { type ReasoningStyle, type GrammarStyle } from "./OpenAICompat.ts";
|
|
3
3
|
import { type TokenizerFamily } from "./tokenizers.ts";
|
|
4
4
|
type StandardProviderSpec = {
|
|
5
|
-
apiKeyVar?: string;
|
|
5
|
+
apiKeyVar?: string | readonly string[];
|
|
6
6
|
apiKeyRequired?: boolean;
|
|
7
7
|
headersFromEnv?: (env: NodeJS.ProcessEnv) => Record<string, string>;
|
|
8
8
|
baseUrl?: string;
|
|
9
|
-
baseUrlVar?: string;
|
|
9
|
+
baseUrlVar?: string | readonly string[];
|
|
10
|
+
baseUrlFromEnv?: (env: NodeJS.ProcessEnv) => string | undefined;
|
|
10
11
|
chatPath: string;
|
|
11
12
|
flexBaseStrip?: boolean;
|
|
12
13
|
reasoningStyle: ReasoningStyle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standardProviders.d.ts","sourceRoot":"","sources":["../src/standardProviders.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,QAAQ,EAAiB,MAAM,YAAY,CAAC;AAC1D,OAA6B,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjG,OAAO,EAAsC,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAK3F,KAAK,oBAAoB,GAAG;
|
|
1
|
+
{"version":3,"file":"standardProviders.d.ts","sourceRoot":"","sources":["../src/standardProviders.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,QAAQ,EAAiB,MAAM,YAAY,CAAC;AAC1D,OAA6B,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjG,OAAO,EAAsC,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAK3F,KAAK,oBAAoB,GAAG;IAOxB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IACvC,cAAc,CAAC,EAAE,OAAO,CAAC;IAKzB,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAIpE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IAIxC,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,KAAK,MAAM,GAAG,SAAS,CAAC;IAEhE,QAAQ,EAAE,MAAM,CAAC;IAIjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,cAAc,CAAC;IAK/B,YAAY,CAAC,EAAE,YAAY,CAAC;IAK5B,SAAS,CAAC,EAAE,OAAO,CAAC;IAKpB,WAAW,CAAC,EAAE,MAAM,CAAC;IAOrB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,gBAAgB,EAAE,eAAe,CAAC;IAClC,eAAe,EAAE,MAAM,CAAC;IAOxB,SAAS,CAAC,EAAE,OAAO,CAAC;IAQpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAGF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAyF5E,CAAC;AAEH,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,KAAG,OAAqC,CAAC;AAqFxF,eAAO,MAAM,uBAAuB,GAAU,MAAM,MAAM,EAAE,KAAK,MAAM,CAAC,UAAU,EAAE,OAAO,MAAM,KAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAkF1H,CAAC"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// ones (openrouter, ollama, google, xai, cloudflare, third-party). The scan
|
|
10
10
|
// resolves the package specifier — it is NOT a hardcoded @plurnk/ pattern.
|
|
11
11
|
import OpenAICompatProvider from "./OpenAICompat.js";
|
|
12
|
-
import { parseRequiredInt, parseOptionalInt,
|
|
12
|
+
import { parseRequiredInt, parseOptionalInt, reasoningBudgetFromEnv } from "./env.js";
|
|
13
13
|
import { parseTokenizerFamily, tokenizerFor } from "./tokenizers.js";
|
|
14
14
|
import { providerSource } from "./telemetry.js";
|
|
15
15
|
import { computeCost } from "./usage.js";
|
|
@@ -21,7 +21,7 @@ export const STANDARD_PROVIDERS = Object.freeze({
|
|
|
21
21
|
// Replaces the former @plurnk/plurnk-providers-openai sibling verbatim.
|
|
22
22
|
openai: {
|
|
23
23
|
apiKeyVar: "OPENAI_API_KEY", apiKeyRequired: false,
|
|
24
|
-
baseUrlVar: "OPENAI_BASE_URL", chatPath: "/v1/chat/completions", flexBaseStrip: true,
|
|
24
|
+
baseUrlVar: ["OPENAI_BASE_URL", "OPENAI_API_BASE"], chatPath: "/v1/chat/completions", flexBaseStrip: true,
|
|
25
25
|
reasoningStyle: "think", tokenizerDefault: "heuristic", tokenizerEnvVar: "OPENAI_TOKENIZER",
|
|
26
26
|
probeNctx: true,
|
|
27
27
|
},
|
|
@@ -51,7 +51,7 @@ export const STANDARD_PROVIDERS = Object.freeze({
|
|
|
51
51
|
reasoningStyle: "none", grammarStyle: "response_format", modelPrefix: "accounts/fireworks/models/", tokenizerDefault: "heuristic", tokenizerEnvVar: "FIREWORKS_TOKENIZER",
|
|
52
52
|
},
|
|
53
53
|
deepinfra: {
|
|
54
|
-
apiKeyVar: "DEEPINFRA_API_KEY", apiKeyRequired: true,
|
|
54
|
+
apiKeyVar: ["DEEPINFRA_API_KEY", "DEEPINFRA_API_TOKEN", "DEEPINFRA_TOKEN"], apiKeyRequired: true,
|
|
55
55
|
baseUrl: "https://api.deepinfra.com/v1/openai", baseUrlVar: "DEEPINFRA_BASE_URL", chatPath: "/chat/completions",
|
|
56
56
|
reasoningStyle: "none", tokenizerDefault: "heuristic", tokenizerEnvVar: "DEEPINFRA_TOKENIZER",
|
|
57
57
|
},
|
|
@@ -65,16 +65,24 @@ export const STANDARD_PROVIDERS = Object.freeze({
|
|
|
65
65
|
},
|
|
66
66
|
// AWS Bedrock via its OpenAI-compat chat-completions endpoint, authed with a
|
|
67
67
|
// Bedrock API key as a bearer token (SigV4 is optional, not required). The
|
|
68
|
-
// base
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
68
|
+
// base is region-templated: BEDROCK_BASE_URL overrides, else it's derived
|
|
69
|
+
// from the standard AWS_REGION / AWS_DEFAULT_REGION as
|
|
70
|
+
// https://bedrock-runtime.{region}.amazonaws.com/openai/v1 — so an operator
|
|
71
|
+
// with AWS creds already exported needs no extra var. (Note the OpenAI-compat
|
|
72
|
+
// path is /openai/v1, not /v1.) Multi-model relay (Claude, gpt-oss, Llama, …)
|
|
73
|
+
// → no single reasoning toggle. Model ids are inference profiles like
|
|
74
|
+
// `us.anthropic.claude-sonnet-4-6`, which the models.dev catalog does NOT key
|
|
75
|
+
// on — so bedrock has no catalog context/cost; set PLURNK_PROVIDER_CONTEXT_SIZE
|
|
76
|
+
// for a context window (a catalog inference-profile mapping is a follow-on, #19).
|
|
75
77
|
bedrock: {
|
|
76
78
|
apiKeyVar: "AWS_BEARER_TOKEN_BEDROCK", apiKeyRequired: true,
|
|
77
79
|
baseUrlVar: "BEDROCK_BASE_URL", chatPath: "/chat/completions",
|
|
80
|
+
baseUrlFromEnv: (env) => {
|
|
81
|
+
const region = firstSet(env, ["AWS_REGION", "AWS_DEFAULT_REGION"]);
|
|
82
|
+
if (region === undefined)
|
|
83
|
+
throw new Error("bedrock provider: BEDROCK_BASE_URL must be set, or AWS_REGION / AWS_DEFAULT_REGION to derive it");
|
|
84
|
+
return `https://bedrock-runtime.${region}.amazonaws.com/openai/v1`;
|
|
85
|
+
},
|
|
78
86
|
reasoningStyle: "none", tokenizerDefault: "heuristic", tokenizerEnvVar: "BEDROCK_TOKENIZER",
|
|
79
87
|
},
|
|
80
88
|
// The plurnk hosted model — deliberately the most boring OpenAI-compatible
|
|
@@ -86,47 +94,57 @@ export const STANDARD_PROVIDERS = Object.freeze({
|
|
|
86
94
|
// upstream (probeNctx), so a 32k→48k change is a one-line server decision,
|
|
87
95
|
// never a client release — but `detectLlamaServer: false` keeps it a plain
|
|
88
96
|
// remote OpenAI server that can't be flipped into grammar/slot behavior.
|
|
89
|
-
// Base URL defaults to model.plurnk.ai, overridable via PLURNK_BASE_URL.
|
|
90
|
-
//
|
|
91
|
-
// sent only when set
|
|
97
|
+
// Base URL defaults to model.plurnk.ai, overridable via PLURNK_BASE_URL. Auth
|
|
98
|
+
// is a single OPTIONAL bearer PLURNK_API_KEY — the key identifies the account
|
|
99
|
+
// server-side, so there is no separate account header; sent only when set,
|
|
100
|
+
// exactly like any other standard bearer (a keyless local server gets none).
|
|
101
|
+
// firstPartyMetadata forwards attribution/client headers.
|
|
92
102
|
plurnk: {
|
|
93
103
|
baseUrl: "https://model.plurnk.ai/v1", baseUrlVar: "PLURNK_BASE_URL", chatPath: "/chat/completions",
|
|
94
|
-
|
|
95
|
-
const h = {};
|
|
96
|
-
const key = env.PLURNK_KEY ?? "";
|
|
97
|
-
const account = env.PLURNK_ACCOUNT ?? "";
|
|
98
|
-
if (key.length > 0)
|
|
99
|
-
h.Authorization = `Bearer ${key}`;
|
|
100
|
-
if (account.length > 0)
|
|
101
|
-
h["Plurnk-Account"] = account;
|
|
102
|
-
return h;
|
|
103
|
-
},
|
|
104
|
+
apiKeyVar: "PLURNK_API_KEY", apiKeyRequired: false,
|
|
104
105
|
reasoningStyle: "none", grammarStyle: "none", tokenizerDefault: "heuristic", tokenizerEnvVar: "PLURNK_TOKENIZER",
|
|
105
106
|
probeNctx: true, detectLlamaServer: false, firstPartyMetadata: true,
|
|
106
107
|
},
|
|
107
108
|
});
|
|
108
109
|
export const isStandardProvider = (name) => name in STANDARD_PROVIDERS;
|
|
110
|
+
// Normalize a single-or-list env-var spec to a list, and return the first env
|
|
111
|
+
// var that is set non-empty (the accepted-alias resolution — first wins).
|
|
112
|
+
const asList = (v) => v === undefined ? [] : typeof v === "string" ? [v] : v;
|
|
113
|
+
const firstSet = (env, names) => {
|
|
114
|
+
for (const name of names) {
|
|
115
|
+
const value = env[name];
|
|
116
|
+
if (value !== undefined && value.length > 0)
|
|
117
|
+
return value;
|
|
118
|
+
}
|
|
119
|
+
return undefined;
|
|
120
|
+
};
|
|
109
121
|
const resolveUrl = (spec, env, label) => {
|
|
110
|
-
|
|
111
|
-
const base =
|
|
122
|
+
// override var(s) → env-derived template → fixed default.
|
|
123
|
+
const base = firstSet(env, asList(spec.baseUrlVar)) ?? spec.baseUrlFromEnv?.(env) ?? spec.baseUrl;
|
|
112
124
|
if (base === undefined || base.length === 0) {
|
|
113
|
-
|
|
125
|
+
const names = asList(spec.baseUrlVar);
|
|
126
|
+
throw new Error(`${label} provider: ${names.length > 0 ? names.join(" or ") : "base URL"} must be set`);
|
|
114
127
|
}
|
|
115
128
|
const trimmed = spec.flexBaseStrip === true ? base.replace(/\/v1\/?$/, "") : base.replace(/\/$/, "");
|
|
116
129
|
return `${trimmed}${spec.chatPath}`;
|
|
117
130
|
};
|
|
118
131
|
// Auth/routing headers. A custom builder (multi-credential auth) wins; otherwise
|
|
119
|
-
// the
|
|
120
|
-
//
|
|
132
|
+
// the bearer from the first accepted alias that is set: required → fail-hard
|
|
133
|
+
// naming every accepted var, optional → omitted when none set (a keyless server
|
|
134
|
+
// then receives no Authorization header).
|
|
121
135
|
const resolveHeaders = (spec, env, label) => {
|
|
122
136
|
if (spec.headersFromEnv !== undefined)
|
|
123
137
|
return spec.headersFromEnv(env);
|
|
124
|
-
|
|
138
|
+
const names = asList(spec.apiKeyVar);
|
|
139
|
+
if (names.length === 0)
|
|
140
|
+
return {};
|
|
141
|
+
const apiKey = firstSet(env, names);
|
|
142
|
+
if (apiKey === undefined) {
|
|
143
|
+
if (spec.apiKeyRequired === true)
|
|
144
|
+
throw new Error(`${label} provider: ${names.join(" or ")} must be set`);
|
|
125
145
|
return {};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
: env[spec.apiKeyVar] ?? "";
|
|
129
|
-
return apiKey.length > 0 ? { Authorization: `Bearer ${apiKey}` } : {};
|
|
146
|
+
}
|
|
147
|
+
return { Authorization: `Bearer ${apiKey}` };
|
|
130
148
|
};
|
|
131
149
|
const probeModels = async (chatUrl, headers, model, fetchTimeoutMs) => {
|
|
132
150
|
const modelsUrl = chatUrl.replace(/\/chat\/completions$/, "/models");
|
|
@@ -236,6 +254,9 @@ export const standardProviderFromEnv = async (name, env, model) => {
|
|
|
236
254
|
costFor,
|
|
237
255
|
source: providerSource(name),
|
|
238
256
|
grammarStyle,
|
|
257
|
+
// Optional debug toggle (off by default): validate a transported grammar
|
|
258
|
+
// locally and throw on invalid, without sending it to the model (§13).
|
|
259
|
+
gbnfDebug: env.PLURNK_GBNF_DEBUG !== undefined && env.PLURNK_GBNF_DEBUG !== "" && env.PLURNK_GBNF_DEBUG !== "0",
|
|
239
260
|
streaming: spec.streaming,
|
|
240
261
|
firstPartyMetadata: spec.firstPartyMetadata,
|
|
241
262
|
supportsSlotPinning,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standardProviders.js","sourceRoot":"","sources":["../src/standardProviders.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,8EAA8E;AAC9E,2EAA2E;AAC3E,8EAA8E;AAC9E,6DAA6D;AAC7D,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,2EAA2E;AAG3E,OAAO,oBAAgE,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"standardProviders.js","sourceRoot":"","sources":["../src/standardProviders.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,8EAA8E;AAC9E,2EAA2E;AAC3E,8EAA8E;AAC9E,6DAA6D;AAC7D,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,2EAA2E;AAG3E,OAAO,oBAAgE,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAwB,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,MAAM,E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WAAW,GAAG,GAAG;YAC9B,MAAM,EAAE,CAAC,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG;SACzD,CAAC,CAAC;IAEP,OAAO,IAAI,oBAAoB,CAAC;QAC5B,KAAK,EAAE,SAAS;QAChB,GAAG;QACH,OAAO;QACP,WAAW;QACX,cAAc;QACd,eAAe,EAAE,sBAAsB,CAAC,GAAG,EAAE,IAAI,CAAC;QAClD,aAAa,EAAE,gBAAgB,CAAC,GAAG,CAAC,8BAA8B,EAAE,gCAAgC,EAAE,IAAI,CAAC;QAC3G,cAAc;QACd,WAAW,EAAE,YAAY,CAAC,MAAM,CAAC;QACjC,OAAO;QACP,MAAM,EAAE,cAAc,CAAC,IAAI,CAAC;QAC5B,YAAY;QACZ,yEAAyE;QACzE,uEAAuE;QACvE,SAAS,EAAE,GAAG,CAAC,iBAAiB,KAAK,SAAS,IAAI,GAAG,CAAC,iBAAiB,KAAK,EAAE,IAAI,GAAG,CAAC,iBAAiB,KAAK,GAAG;QAC/G,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;QAC3C,mBAAmB;QACnB,SAAS;KACZ,CAAC,CAAC;AACP,CAAC,CAAC"}
|
package/dist/telemetry.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type TelemetryEvent = {
|
|
|
4
4
|
message?: string | null;
|
|
5
5
|
position?: null;
|
|
6
6
|
};
|
|
7
|
-
export type ProviderTelemetryKind = "rate_limit" | "network_failure" | "model_refused" | "invalid_response" | "unauthorized" | "quota_exceeded";
|
|
7
|
+
export type ProviderTelemetryKind = "rate_limit" | "network_failure" | "model_refused" | "invalid_response" | "unauthorized" | "quota_exceeded" | "grammar_unenforced";
|
|
8
8
|
export declare const providerSource: (vendor: string) => string;
|
|
9
9
|
export declare class ProviderError extends Error {
|
|
10
10
|
readonly source: string;
|
package/dist/telemetry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,cAAc,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,IAAI,CAAC;CACnB,CAAC;AAGF,MAAM,MAAM,qBAAqB,GAC3B,YAAY,GACZ,iBAAiB,GACjB,eAAe,GACf,kBAAkB,GAClB,cAAc,GACd,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,cAAc,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,IAAI,CAAC;CACnB,CAAC;AAGF,MAAM,MAAM,qBAAqB,GAC3B,YAAY,GACZ,iBAAiB,GACjB,eAAe,GACf,kBAAkB,GAClB,cAAc,GACd,gBAAgB,GAIhB,oBAAoB,CAAC;AAG3B,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,KAAG,MAA8B,CAAC;AAK/E,qBAAa,aAAc,SAAQ,KAAK;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;gBAEnB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;IAQnI,gBAAgB,IAAI,cAAc;CAGrC;AAID,eAAO,MAAM,qBAAqB,GAAI,KAAK,OAAO,KAAG;IAAE,IAAI,EAAE,qBAAqB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAalG,CAAC;AAIF,eAAO,MAAM,eAAe,GAAI,KAAK,OAAO,EAAE,QAAQ,MAAM,KAAG,aAK9D,CAAC"}
|
package/dist/telemetry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,gFAAgF;AAChF,iEAAiE;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,gFAAgF;AAChF,iEAAiE;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAyBpD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,YAAY,MAAM,EAAE,CAAC;AAE/E,8EAA8E;AAC9E,mEAAmE;AACnE,+CAA+C;AAC/C,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC3B,MAAM,CAAS;IACf,IAAI,CAAwB;IAC5B,MAAM,CAAgB;IAE/B,YAAY,MAAc,EAAE,IAA2B,EAAE,OAAe,EAAE,UAAuD,EAAE;QAC/H,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACnF,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,I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D,CAAC,CAAC;AAEF,+EAA+E;AAC/E,oDAAoD;AACpD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAY,EAAE,MAAc,EAAiB,EAAE;IAC3E,IAAI,GAAG,YAAY,aAAa;QAAE,OAAO,GAAG,CAAC;IAC7C,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,GAAG,YAAY,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;IAClE,OAAO,IAAI,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;AAC5E,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plurnk/plurnk-providers",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Framework + contract for
|
|
3
|
+
"version": "0.14.0",
|
|
4
|
+
"description": "Framework + contract for plurnk LLM transports: built-in standard OpenAI-compatible providers plus scope-agnostic discovery of first-party and third-party provider packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plurnk",
|
|
7
7
|
"llm",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"typescript": "^6.0.3"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
+
"@plurnk/gbnf": "0.1.1",
|
|
53
54
|
"@plurnk/plurnk-models": "0.1.0",
|
|
54
55
|
"gpt-tokenizer": "^3.4.0",
|
|
55
56
|
"llama-tokenizer-js": "^1.2.2"
|