toolgz 0.2.1 → 0.2.2

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.
Files changed (2) hide show
  1. package/README.md +13 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -668,7 +668,7 @@ compress(all, {
668
668
  **The model calls `t` or `q` and my dispatcher explodes.**
669
669
  You're dispatching on every tool call. Only `kind === "call"` is real; `meta`
670
670
  and `error` are toolgz's own tools and must be answered, not dispatched. See
671
- 5](#5-handling-the-three-outcomes).
671
+ 2](#2-handling-the-three-outcomes).
672
672
 
673
673
  **`resolve()` returns `error: unknown parameter "x"`.**
674
674
  The model invented a parameter. Feed `r.message` back as an error tool result —
@@ -689,7 +689,7 @@ wrong-case enum value shows the exact accepted spelling. Feed them straight back
689
689
  and the retry usually lands first time.
690
690
 
691
691
  **`cache_read_input_tokens` is always 0.**
692
- Something in your prefix varies per request. See [§7](#7-prompt-caching).
692
+ Something in your prefix varies per request. See [§4](#4-prompt-caching).
693
693
 
694
694
  **Gemini rejects my schema.**
695
695
  Use `forGemini`, which strips the keywords Gemini won't accept. If a new one
@@ -760,12 +760,14 @@ number can be recomputed rather than trusted.
760
760
 
761
761
  | Option | Type | Default | Notes |
762
762
  |---|---|---|---|
763
- | `level` | `0 \| 1 \| 2 \| 3` | `1` | see [§3](#3-which-level-should-i-use) |
763
+ | `level` | `0 \| 1 \| 2 \| 3` | `1` | see [Which level to use](#which-level-to-use) |
764
764
  | `mapStyle` | `"name+required" \| "explicit" \| "signature"` | `"name+required"` | level 3 only |
765
765
  | `namespaceOf` | `(name) => {ns, op}` | split on first `_`/`.` | levels 2–3 grouping |
766
766
  | `aliasOf` | `(ns) => string` | identity | level 2 tool naming |
767
767
  | `searchLimit` | `number` | `8` | max results from a `q` search |
768
768
  | `validate` | `boolean` | `true` | **leave this on** |
769
+ | `model` | `string` | — | exact model id; picks the measured style. Omit and nothing changes |
770
+ | `objective` | `"occupancy" \| "cost"` | `"occupancy"` | what the pick optimises. Only `cost` has entries |
769
771
 
770
772
  Returns:
771
773
 
@@ -776,7 +778,8 @@ Returns:
776
778
  | `cachePreamble` | `boolean` | whether the preamble should sit behind a breakpoint |
777
779
  | `resolve(name, args)` | `→ Resolution` | translate a model call back |
778
780
  | `codeFor(name)` | `→ string` | real name → level-3 code; throws below level 3 |
779
- | `stats` | `CompressStats` | `level`, `toolCount`, `wireToolCount`, `savedPct`, |
781
+ | `stats` | `CompressStats` | `level`, `mapStyle`, `requestedMapStyle`, `fallbackReason`, `toolCount`, `wireToolCount`, `originalChars`, `compressedChars`, `savedPct` |
782
+ | `encodeCallForTest(name, args)` | `→ {name, args}` | build the raw call a model would emit; test aid |
780
783
 
781
784
  ### `recommendLevel(tools, namespaceOf?) → Recommendation`
782
785
 
@@ -791,6 +794,11 @@ Returns:
791
794
  | `forOpenAIResponses(c)` → `{ tools, systemPreamble }` | `/v1/responses` | **flat** `{type, name, …}` — required for tools + reasoning |
792
795
  | `forGemini(c)` → `{ tools, systemPreamble }` | `generateContent` | one `functionDeclarations` array |
793
796
 
797
+ Also exported: `recommendLevel(tools)` → `{ level, reason }`; `selectMapStyle(options)`
798
+ → `{ mapStyle, requestedMapStyle?, fallbackReason? }` (pure, so you can see a pick
799
+ without compressing); and `POLICY`, `BROKEN`, `CONSERVATIVE_DEFAULT` — the measured
800
+ table, so a style choice is never a black box.
801
+
794
802
  ### Renderers (exported for tooling)
795
803
 
796
804
  - `signatureLine(tool, nameOverride?)` → `"name(a,b?:x|y)"`
@@ -851,7 +859,7 @@ and it does not get deleted.
851
859
  ## Development
852
860
 
853
861
  ```bash
854
- npm test # 245 tests, offline, no cost
862
+ npm test # 251 tests, offline, no cost
855
863
  npm run build # tsc → dist/ with .d.ts
856
864
 
857
865
  npx tsx bench/harness/run-multi.ts --provider=all --reps=3 --variants # costs money
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolgz",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Compress LLM tool definitions to reclaim context window. Measured across Anthropic, OpenAI, Google and xAI.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {