@lokeraar/pi-enclave-bridge 0.1.0 → 0.1.1

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
@@ -1,10 +1,47 @@
1
1
  # @lokeraar/pi-enclave-bridge
2
2
 
3
+ [![Version: 0.1.1](https://img.shields.io/badge/version-0.1.1-blue.svg)](https://www.npmjs.com/package/@lokeraar/pi-enclave-bridge)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
3
6
  EnClave provider for [Pi](https://pi.dev). The live router catalog shows up in
4
7
  `/model` with **real context windows, real per-token prices, live membership and
5
8
  the router's task aliases** — resolved from the model catalog Pi already ships,
6
9
  with no extra account required.
7
10
 
11
+ <a href="https://github.com/Gentleman-Programming/gentle-ai">
12
+ <img width="220" src="https://raw.githubusercontent.com/Gentleman-Programming/gentle-ai/main/docs/assets/brand/built-with-gentle-ai.png" alt="Built with Gentle-AI" />
13
+ </a>
14
+
15
+ ## 📋 Releases
16
+
17
+ ### 0.1.1 — a clamp that left room for an actual prompt
18
+
19
+ The ceiling clamp kept back 2,048 tokens for the prompt. That router counts
20
+ `messages + tools + max_tokens` against the window, not the output alone, and a
21
+ real Pi call carries the system prompt plus every tool schema — order 20k
22
+ tokens. The reserve only covered a toy request.
23
+
24
+ `gpt-oss-120b` exposed it: a 131,072 window with a 117,964 ceiling left 13,108
25
+ tokens for input, below what Pi sends, so **every** call failed with `400` as
26
+ soon as the conversation carried anything. Measured with the same prompt:
27
+
28
+ ```
29
+ input ~16k ceiling 117964 HTTP 400 "needs about 133,972 tokens"
30
+ input ~16k ceiling 98304 HTTP 200
31
+ input ~28k ceiling 98304 HTTP 200
32
+ ```
33
+
34
+ The published value is a ceiling, not a fixed request: Pi reduces it per turn to
35
+ `min(published, contextWindow − prompt − reserve)`. The reserve just had to be
36
+ realistic.
37
+
38
+ ### 0.1.0 — first release
39
+
40
+ Values resolved from the model catalog Pi ships, with the vendor's model card
41
+ outranking every catalog. `/login` once and the live router catalog appears in
42
+ `/model` with real context windows, real per-token prices, live membership and
43
+ the router's task aliases.
44
+
8
45
  ## ⚡ Quick Start
9
46
 
10
47
  ```bash
package/enclave-live.ts CHANGED
@@ -181,8 +181,14 @@ const num = (v: unknown, fallback: number) => (typeof v === "number" && v > 0 ?
181
181
  /**
182
182
  * Tokens held back from an output ceiling so the prompt has room. See the clamp
183
183
  * in buildBlock.
184
+ *
185
+ * This must cover a real Pi request, not a toy one. The router counts
186
+ * `messages + tools + max_tokens` against the window, so a reserve smaller than
187
+ * the system prompt plus every tool schema makes the model unusable in practice:
188
+ * gpt-oss-120b (131,072 window) shipped a 117,964 ceiling that left ~13k for
189
+ * input, below what Pi sends, and every call 400'd once the conversation grew.
184
190
  */
185
- const PROMPT_RESERVE_TOKENS = 2_048;
191
+ export const PROMPT_RESERVE_TOKENS = 32_768;
186
192
 
187
193
  /** Aliases the router exposes: never resolved from a donor. See donors.ts. */
188
194
  function isAliasId(id: string, aliases: readonly CatalogAlias[]): boolean {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lokeraar/pi-enclave-bridge",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "EnClave provider bridge for Pi: /login once and the live router catalog appears in /model with real context windows, real per-token prices, live membership and the router's task aliases \u2014 resolved from the model catalog Pi already ships.",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
@@ -20,7 +20,7 @@ import { join } from "node:path";
20
20
  const ROOT = join(new URL(".", import.meta.url).pathname, "..");
21
21
  const { bareName, resolveModel, readBundledCatalog, readPiCatalogs, findBundledCatalogDir, findBundledCatalogs, ROUNDING_TOLERANCE } =
22
22
  await import(join(ROOT, "donors.ts"));
23
- const { buildBlock } = await import(join(ROOT, "enclave-live.ts"));
23
+ const { buildBlock, PROMPT_RESERVE_TOKENS } = await import(join(ROOT, "enclave-live.ts"));
24
24
 
25
25
  let passed = 0;
26
26
  const failed = [];
@@ -214,7 +214,8 @@ console.log("\nthe block: matching, near misses, endpoint-owned fields");
214
214
  check("alias price is the catalog ceiling", by["cyberouter/auto"].cost.input === 1.4, String(by["cyberouter/auto"].cost.input));
215
215
  check("aliases carry no donor record", by["cyberouter/auto"].donor === undefined);
216
216
 
217
- check("an impossible ceiling is clamped below the window", by["cyberouter/inkling"].maxTokens === 262144 - 2048, String(by["cyberouter/inkling"].maxTokens));
217
+ check("an impossible ceiling is clamped below the window", by["cyberouter/inkling"].maxTokens === 262144 - PROMPT_RESERVE_TOKENS, String(by["cyberouter/inkling"].maxTokens));
218
+ check("the clamp leaves room for a real prompt", PROMPT_RESERVE_TOKENS >= 32_768, String(PROMPT_RESERVE_TOKENS));
218
219
  check("maxTokens is never null (Pi crashes formatting it)", out.models.every((m) => typeof m.maxTokens === "number"), "hay un null");
219
220
  }
220
221