@plurnk/plurnk-providers 0.4.0 → 0.5.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 CHANGED
@@ -10,7 +10,7 @@ Framework + contract for `@plurnk/plurnk-providers-*` sibling packages (LLM tran
10
10
  ## Exports
11
11
 
12
12
  - `Provider`, `ChatMessage`, `ProviderResponse`, `ProviderAssistant`, `ProviderUsage`, `FinishReason`, `ProviderFactory` — types.
13
- - `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. The framework is contract-only (SPEC §5).
13
+ - `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).
14
14
  - `OpenAICompatProvider` (+ `OpenAICompatConfig`, `ReasoningStyle`, `effortFromBudget`) — shared OpenAI-compatible transport spine; siblings extend it (SPEC §11). Transports GBNF grammar-constrained sampling for capable backends (SPEC §13).
15
15
  - `chatCompletionStream`, `OpenAiHttpError`, `StreamResponse` — the shared SSE client.
16
16
  - `parseRequiredInt`, `parseOptionalInt`, `requireEnv`, `reasoningBudgetFromEnv`, `planFromEnv` — env helpers (SPEC §4; all required-with-named-errors, no in-code defaults).
package/SPEC.md CHANGED
@@ -86,7 +86,7 @@ Default export MUST have a static `fromEnv(env, model)` factory:
86
86
  class OpenAI {
87
87
  static fromEnv(env: NodeJS.ProcessEnv, model: string): OpenAI | Promise<OpenAI> {
88
88
  // Read provider-specific env (OPENAI_BASE_URL, OPENAI_API_KEY, ...)
89
- // plus universal operator knobs (PLURNK_PROVIDERS_REASON_LEVEL, PLURNK_FETCH_TIMEOUT,
89
+ // plus universal operator knobs (PLURNK_PROVIDERS_REASONING_BUDGET, PLURNK_FETCH_TIMEOUT,
90
90
  // PLURNK_PROVIDER_CONTEXT_SIZE).
91
91
  return new OpenAI({ /* ... */ });
92
92
  }
@@ -96,7 +96,7 @@ class OpenAI {
96
96
 
97
97
  The consumer's instantiation path calls `mod.default.fromEnv(env, alias.model)` generically (§5).
98
98
 
99
- `fromEnv` MAY be sync or async; return type `Provider | Promise<Provider>`.
99
+ `fromEnv` MAY be sync or async; return type `Provider | Promise<Provider>`. (Why a factory, where execs/mimes use a base class + constructor injection and schemes a `static manifest`: a provider often **async-probes** at construction — model catalog, context window, slot count — which a constructor can't express. The factory is the seam for that probe.)
100
100
 
101
101
  `fromEnv` MUST fail fast with a clear error if required env is missing — name the env var the operator needs to set.
102
102
 
@@ -129,14 +129,16 @@ This package's exported resolution surface:
129
129
  - `instantiateProvider(name, env, model)` — full two-tier resolution (below).
130
130
  - `loadActiveProvider(env)` — boot convenience: active alias → `instantiateProvider`.
131
131
  - `standardProviderFromEnv(name, env, model)` / `isStandardProvider(name)` — the tier-1 internals, still exported.
132
- - `discover({ cwd?, packageDirs? })` — the tier-2 scan: a `Map<name, packageSpecifier>` of every installed provider package. Exported so a consumer can enumerate available providers (first-party + third-party) without instantiating them.
132
+ - `discover({ cwd?, packageDirs?, env? })` — the tier-2 scan: a `Discovery` (`{ registry, skipped }`, each a `Map<name, packageSpecifier>`) of every installed provider package, partitioned by the trust gate. Exported so a consumer can enumerate trusted providers — and see which were declined — without instantiating them.
133
133
 
134
134
  **Two-tier provider resolution — owned entirely by this package.** A provider name resolves in this order:
135
135
 
136
136
  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`, …). The standard table is **authoritative**: a scanned package whose name duplicates a standard one is shadowed (tier 1 returns first).
137
137
  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 `anthropic`/`bedrock`/`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.
138
138
 
139
- The framework is **contract-only** — it does **not** depend on its daughters. First-party daughters install flat via the [`@plurnk/plurnk-providers-all`](https://github.com/plurnk/plurnk-providers-all) aggregator (a code-free package depping the five daughters directly), so npm hoists them to the top of `node_modules` where the scan finds them; a consumer installs `@plurnk/plurnk-providers` + `@plurnk/plurnk-providers-all`. Each daughter declares the framework as a `peerDependency` (`0.3.x`) so one shared copy lives in the tree (class identity for `instanceof ProviderError` included). This mirrors `@plurnk/plurnk-execs` + `@plurnk/plurnk-execs-all`, which proved that framework-aggregates-daughters (execs `0.4.2`) nests the daughters and breaks the scan — reverted at `0.4.3` to exactly this flat-aggregator shape (#12/#14).
139
+ 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*.
140
+
141
+ The framework is **contract-only** — it does **not** depend on its daughters. First-party daughters install flat via the [`@plurnk/plurnk-providers-all`](https://github.com/plurnk/plurnk-providers-all) aggregator (a code-free package depping the five daughters directly), so npm hoists them to the top of `node_modules` where the scan finds them; a consumer installs `@plurnk/plurnk-providers` + `@plurnk/plurnk-providers-all`. Each daughter declares the framework as a `peerDependency` (`0.5.x`) so one shared copy lives in the tree (class identity for `instanceof ProviderError` included). This mirrors `@plurnk/plurnk-execs` + `@plurnk/plurnk-execs-all`, which proved that framework-aggregates-daughters (execs `0.4.2`) nests the daughters and breaks the scan — reverted at `0.4.3` to exactly this flat-aggregator shape (#12/#14).
140
142
 
141
143
  ## §6 Engine → provider guarantees (consumer side)
142
144
 
@@ -223,7 +225,7 @@ The framework ships the transport spine every OpenAI-compatible provider had bee
223
225
  fetchTimeoutMs,
224
226
  headers, // fully-resolved request headers (incl. auth)
225
227
  contextSize, // number | null
226
- reasonBudget, reasoningStyle, // "none" | "think" | "include_reasoning" | "effort"
228
+ reasoningBudget, reasoningStyle, // "none" | "think" | "include_reasoning" | "effort" | "template"
227
229
  countTokens, costFor, // strategies; default heuristic / free
228
230
  supportsGrammar, // backend accepts a `grammar` body field (§13); default false
229
231
  supportsSlotPinning, slotCount, // INTERNAL slot-affinity wiring (run→id_slot); never consumer-facing
@@ -236,7 +238,7 @@ The framework ships the transport spine every OpenAI-compatible provider had bee
236
238
  - **`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`.
237
239
  - **`parseRequiredInt` / `parseOptionalInt` / `requireEnv`** — env helpers; each takes a provider `label` for error prefixing.
238
240
  - **`tokenizerFor(family)` / `tokenizerByPublisher(model, table, index)` / `parseTokenizerFamily(...)`** — synchronous tokenizer strategies (`heuristic` | `cl100k` | `llama`) and per-publisher dispatch for relay providers.
239
- - **`effortFromBudget(budget)`** — the shared `PLURNK_PROVIDERS_REASON_LEVEL` → `low|medium|high` breakpoints.
241
+ - **`effortFromBudget(budget)`** — the shared `PLURNK_PROVIDERS_REASONING_BUDGET` → `low|medium|high` breakpoints.
240
242
 
241
243
  A **bespoke sibling** therefore reduces to a thin class whose `fromEnv` probes whatever it needs (model catalog, pricing, context window), builds the config, and returns `new OpenAICompatProvider(config)`. A **standard provider** (§5 tier 1) needs no sibling at all — it's a frozen entry in `STANDARD_PROVIDERS` describing its key var, base URL, reasoning style, and tokenizer; `standardProviderFromEnv(name, env, model)` (async — returns `Promise<Provider | null>`) does the rest.
242
244
 
@@ -1,9 +1,9 @@
1
1
  import type { Provider, ProviderAlias } from "./types.ts";
2
- import { type DiscoverOptions } from "./discover.ts";
2
+ import { type DiscoverOptions, type Discovery } from "./discover.ts";
3
3
  export declare const parseAliasesFromEnv: (env?: NodeJS.ProcessEnv) => ProviderAlias[];
4
4
  export declare const resolveActiveAlias: (env?: NodeJS.ProcessEnv) => ProviderAlias | null;
5
5
  type ImportModule = (specifier: string) => Promise<unknown>;
6
- type DiscoverFn = (options?: DiscoverOptions) => Promise<Map<string, string>>;
6
+ type DiscoverFn = (options?: DiscoverOptions) => Promise<Discovery>;
7
7
  export declare const instantiateProvider: (name: string, env: NodeJS.ProcessEnv, model: string, importImpl?: ImportModule, discoverFn?: DiscoverFn) => Promise<Provider>;
8
8
  export declare const resetDiscoveryCache: () => void;
9
9
  export declare const loadActiveProvider: (env?: NodeJS.ProcessEnv, importImpl?: ImportModule, discoverFn?: DiscoverFn) => Promise<Provider>;
@@ -1 +1 @@
1
- {"version":3,"file":"ProviderRegistry.d.ts","sourceRoot":"","sources":["../src/ProviderRegistry.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAmB,MAAM,YAAY,CAAC;AAE3E,OAAO,EAAY,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAE/D,eAAO,MAAM,mBAAmB,GAAI,MAAK,MAAM,CAAC,UAAwB,KAAG,aAAa,EAkBvF,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,MAAK,MAAM,CAAC,UAAwB,KAA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AAC,UAAU,EACtB,OAAO,MAAM,EACb,aAAY,YAA2B,EACvC,aAAY,UAAqB,KAClC,OAAO,CAAC,QAAQ,CA0BlB,CAAC;AAGF,eAAO,MAAM,mBAAmB,QAAO,IAAmC,CAAC;AAG3E,eAAO,MAAM,kBAAkB,GAC3B,MAAK,MAAM,CAAC,UAAwB,EACpC,aAAY,YAA2B,EACvC,aAAY,UAAqB,KAClC,OAAO,CAAC,QAAQ,CAMlB,CAAC"}
@@ -51,17 +51,18 @@ export const resolveActiveAlias = (env = process.env) => {
51
51
  };
52
52
  const importModule = (specifier) => import(__rewriteRelativeImportExtension(specifier));
53
53
  // The node_modules scan is filesystem work that never changes within a process,
54
- // so it runs once and the name→package map is memoized. A long-lived daemon
55
- // pays one scan at first bespoke instantiation; every later run reuses it.
54
+ // so it runs once and the result is memoized. A long-lived daemon pays one scan
55
+ // at first bespoke instantiation; every later run reuses it. The trust gate is
56
+ // boot config, so the env from the first scan stands for the process.
56
57
  let discoveredCache = null;
57
- const providerPackages = async (discoverFn) => {
58
- discoveredCache ??= await discoverFn();
58
+ const providerPackages = async (discoverFn, env) => {
59
+ discoveredCache ??= await discoverFn({ env });
59
60
  return discoveredCache;
60
61
  };
61
62
  // Two-tier resolution (SPEC §5): tier 1 standard table → tier 2 discovered
62
- // package (scope-agnostic scan) → fail-hard. The standard table is authoritative
63
- // — a scanned package whose name duplicates a standard one is shadowed here
64
- // (never reached), since tier 1 returns first.
63
+ // package (scope-agnostic scan, trust-gated) → fail-hard. The standard table is
64
+ // authoritative — a scanned package whose name duplicates a standard one is
65
+ // shadowed here (never reached), since tier 1 returns first.
65
66
  export const instantiateProvider = async (name, env, model, importImpl = importModule, discoverFn = discover) => {
66
67
  if (isStandardProvider(name)) {
67
68
  const standard = await standardProviderFromEnv(name, env, model);
@@ -69,8 +70,13 @@ export const instantiateProvider = async (name, env, model, importImpl = importM
69
70
  throw new Error(`provider "${name}": standard registry resolution failed`);
70
71
  return standard;
71
72
  }
72
- const specifier = (await providerPackages(discoverFn)).get(name);
73
+ const { registry, skipped } = await providerPackages(discoverFn, env);
74
+ const specifier = registry.get(name);
73
75
  if (specifier === undefined) {
76
+ const declined = skipped.get(name);
77
+ if (declined !== undefined) {
78
+ throw new Error(`provider "${name}" resolves to ${declined}, but it is untrusted under PLURNK_PLUGINS_TRUSTED_ONLY — add it to the allowlist (or publish under @plurnk/)`);
79
+ }
74
80
  throw new Error(`unknown provider "${name}": not a standard provider, and no installed package declares plurnk.kind:"provider" with name "${name}"`);
75
81
  }
76
82
  let mod;
@@ -1 +1 @@
1
- {"version":3,"file":"ProviderRegistry.js","sourceRoot":"","sources":["../src/ProviderRegistry.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,yEAAyE;AACzE,mCAAmC;AACnC,EAAE;AACF,+EAA+E;AAC/E,yEAAyE;AACzE,6EAA6E;AAC7E,+EAA+E;AAC/E,4EAA4E;AAC5E,wCAAwC;;;;;;;;;AAGxC,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAwB,MAAM,eAAe,CAAC;AAE/D,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,MAAyB,OAAO,CAAC,GAAG,EAAmB,EAAE;IACzF,MAAM,GAAG,GAAoB,EAAE,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,SAAS;QACxD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC;YAAE,SAAS;QAC/C,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACnD,IAAI,QAAQ,CAAC,M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,KAAK,CAAC,uGAAuG,CAAC,CAAC;IAC7H,CAAC;IACD,OAAO,mBAAmB,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AACzF,CAAC,CAAC"}
@@ -1,6 +1,11 @@
1
1
  export type DiscoverOptions = {
2
2
  cwd?: string;
3
3
  packageDirs?: string[];
4
+ env?: NodeJS.ProcessEnv;
4
5
  };
5
- export declare const discover: (options?: DiscoverOptions) => Promise<Map<string, string>>;
6
+ export type Discovery = {
7
+ registry: Map<string, string>;
8
+ skipped: Map<string, string>;
9
+ };
10
+ export declare const discover: (options?: DiscoverOptions) => Promise<Discovery>;
6
11
  //# sourceMappingURL=discover.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAoBA,MAAM,MAAM,eAAe,GAAG;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAU,UAAS,eAAoB,KAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAiBzF,CAAC"}
1
+ {"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAyBA,MAAM,MAAM,eAAe,GAAG;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CAC3B,CAAC;AAGF,MAAM,MAAM,SAAS,GAAG;IACpB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC,CAAC;AAYF,eAAO,MAAM,QAAQ,GAAU,UAAS,eAAoB,KAAG,OAAO,CAAC,SAAS,CAuB/E,CAAC"}
package/dist/discover.js CHANGED
@@ -1,12 +1,29 @@
1
1
  import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
+ // OFF (unset/empty/"0") → every installed provider is trusted (no regression).
4
+ // ON (any value) → `@plurnk/*` always trusted, plus a comma-separated allowlist
5
+ // of additionally-trusted package names ("1" = on with zero third-party).
6
+ const isTrusted = (packageName, env) => {
7
+ const gate = env.PLURNK_PLUGINS_TRUSTED_ONLY;
8
+ if (gate === undefined || gate === "" || gate === "0")
9
+ return true;
10
+ if (packageName.startsWith("@plurnk/"))
11
+ return true;
12
+ return gate.split(",").map((s) => s.trim()).includes(packageName);
13
+ };
3
14
  export const discover = async (options = {}) => {
4
15
  const dirs = options.packageDirs ?? await defaultPackageDirs(options.cwd ?? process.cwd());
16
+ const env = options.env ?? process.env;
5
17
  const registry = new Map();
18
+ const skipped = new Map();
6
19
  for (const dir of dirs) {
7
20
  const info = await readProviderInfo(dir);
8
21
  if (info === null)
9
22
  continue;
23
+ if (!isTrusted(info.packageName, env)) {
24
+ skipped.set(info.name, info.packageName); // declined — not a collision candidate
25
+ continue;
26
+ }
10
27
  const existing = registry.get(info.name);
11
28
  if (existing !== undefined) {
12
29
  throw new Error(`provider name collision: '${info.name}' claimed by both `
@@ -14,7 +31,7 @@ export const discover = async (options = {}) => {
14
31
  }
15
32
  registry.set(info.name, info.packageName);
16
33
  }
17
- return registry;
34
+ return { registry, skipped };
18
35
  };
19
36
  // Enumerate every installed package directory — scoped and unscoped — under
20
37
  // `<cwd>/node_modules`. Unreadable node_modules (e.g. nothing installed) → [].
@@ -1 +1 @@
1
- {"version":3,"file":"discover.js","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAwB7B,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,UAA2B,EAA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AO,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;AAC9D,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export type { ChatMessage, FinishReason, Provider, ProviderAlias, ProviderAssistant, ProviderFactory, ProviderResponse, ProviderUsage, } from "./types.ts";
2
2
  export { parseAliasesFromEnv, resolveActiveAlias, instantiateProvider, loadActiveProvider, resetDiscoveryCache, } from "./ProviderRegistry.ts";
3
3
  export { discover } from "./discover.ts";
4
- export type { DiscoverOptions } from "./discover.ts";
4
+ export type { DiscoverOptions, Discovery } from "./discover.ts";
5
5
  export { default as OpenAICompatProvider, effortFromBudget } from "./OpenAICompat.ts";
6
6
  export type { OpenAICompatConfig, ReasoningStyle } from "./OpenAICompat.ts";
7
7
  export { chatCompletionStream, OpenAiHttpError } from "./openaiStream.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,aAAa,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACH,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,GACtB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAIrD,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACtF,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC1E,YAAY,EAAE,cAAc,EAA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OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACtF,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC1E,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClG,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC3F,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzD,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACvG,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEzG,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plurnk/plurnk-providers",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Framework + contract for the @plurnk/plurnk-providers-* LLM transport family.",
5
5
  "keywords": [
6
6
  "plurnk",