tokensafe 1.3.8 → 1.3.9
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 +32 -29
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/src/license_manager.py +6 -4
- package/src/version_checker.py +1 -1
package/README.md
CHANGED
|
@@ -62,9 +62,9 @@ Traditional AI code interactions suffer from massive context bloat:
|
|
|
62
62
|
- **Subagent Deduplication Firewall:** Detects repeated file reads across subagents and agent swarms, serving cached AST slices directly from SQLite session memory (`SUBAGENT_DEDUP`) with zero redundant overhead.
|
|
63
63
|
- **AST Diff Slicer & Lockfile Stripper:** Compresses code review diffs by stripping noisy lockfiles (`package-lock.json`, `pnpm-lock.yaml`, `yarn.lock`, `Cargo.lock`) and minified assets, condensing diffs to 2 lines of context (`git diff -U2`) for up to 96% token savings.
|
|
64
64
|
- **God Nodes & Architectural Hub Detection:** Calculates Degree Centrality to identify structural project hubs and injects topology awareness into agent sessions without expensive file crawling.
|
|
65
|
-
- **TOCP Prompt Distillation:** Intercepts prompts and distills intent into lean S-Expressions
|
|
65
|
+
- **TOCP Prompt Distillation:** Intercepts prompts and distills intent into lean S-Expressions (`-40% to -70%`). Solo & Team tiers include **Managed Cloud Distillation** out of the box via TokenSafe Cloud (`gemini-flash-lite-latest`) with **zero API keys required**. Free tier includes a zero-overhead 9-language Local Regex Compactor. Enterprise on-premise Docker deployments support custom BYOK keys (`TOKENSAFE_SELF_HOSTED=1`).
|
|
66
66
|
- **Token Arbitrage Guard & Output Ceiling:** Eliminates LLM compiler arbitrage loss with a dual defense: inputs $< 100$ tokens route to instant zero-cost local regex heuristics ($0$ LLM tokens), while inputs $\ge 100$ tokens are clamped to a strict $60$-token max output ceiling.
|
|
67
|
-
- **
|
|
67
|
+
- **Three-Tier Distillation Cache:** Three-tier L1 In-Memory LRU + L2 Persistent SQLite cache (`metrics.db`) + L3 Shared Team Cloud Cache with normalized SHA-256 hashing guarantees sub-millisecond zero-cost replays for recurring developer commands.
|
|
68
68
|
- **Shared Team Cache (L3 Cloud Monorepo Cache):** Synchronizes compiled prompt intents and AST skeletons across all developers and CI agents on an engineering team. Teammates querying the same files or command patterns get instant 0ms warm cache hits with zero LLM API calls.
|
|
69
69
|
- **API Surface Map Generator:** Generates high-density `tokensafe-out/API_SURFACE.md` (~1.5k tokens) for instant agent codebase onboarding.
|
|
70
70
|
- **Predictive Dependency Prefetcher:** Attaches imported symbol signatures to eliminate downstream exploratory `read_file` roundtrips.
|
|
@@ -133,36 +133,39 @@ How TokenSafe complements or supersedes static graph tools like **Graphify** (`g
|
|
|
133
133
|
|
|
134
134
|
---
|
|
135
135
|
|
|
136
|
-
## 🤖
|
|
136
|
+
## 🤖 Prompt Distillation: Managed Cloud & Three-Tier Cache Architecture
|
|
137
137
|
|
|
138
|
-
TokenSafe features an intelligent
|
|
138
|
+
TokenSafe features an intelligent prompt compiler that distills verbose developer prompts into lean TOCP S-Expressions (`-40% to -70% tokens`).
|
|
139
139
|
|
|
140
|
-
### 1.
|
|
140
|
+
### 1. Zero-Config Managed Cloud vs. Self-Hosted Docker BYOK
|
|
141
141
|
|
|
142
|
-
|
|
|
142
|
+
| Deployment Mode | Supported Tier | Distillation Engine | Required API Keys | Cost & Setup |
|
|
143
143
|
|---|---|---|---|---|
|
|
144
|
-
| **
|
|
145
|
-
| **
|
|
146
|
-
| **
|
|
147
|
-
| **Anthropic Claude** | `claude-3-5-haiku-20241022` | $0.80 / $4.00 / M | `ANTHROPIC_API_KEY` | 4 |
|
|
148
|
-
| **Custom / Unified** | Any OpenAI/Anthropic gateway | Custom | `TOKENSAFE_UPSTREAM_KEY` | 5 |
|
|
144
|
+
| **TokenSafe Cloud (SaaS)** ⚡ | **Solo Developer & Team** | **Google Gemini Flash-Lite** (`gemini-flash-lite-latest`) | **None (Zero Keys Required)** | **Included in subscription** (0ms config, unlimited neural distillation) |
|
|
145
|
+
| **Local Regex Compactor** | **Community (Free)** | **Deterministic Multilingual Regex** (9 languages) | **None** | **100% Free** (0ms latency, 0 external tokens, 500k tokens/mo) |
|
|
146
|
+
| **Self-Hosted Docker** 🐳 | **Enterprise / Team** | **BYOK Multi-Provider** (Gemini, DeepSeek, OpenAI, Claude) | `GEMINI_API_KEY`, `DEEPSEEK_API_KEY`, etc. | Requires `TOKENSAFE_SELF_HOSTED=1` in private VPC container |
|
|
149
147
|
|
|
150
|
-
> **
|
|
148
|
+
> **Zero Configuration for Solo & Team**: You do not need to register for Google AI Studio, OpenAI, or DeepSeek API accounts. TokenSafe Cloud handles high-throughput neural distillation automatically with enterprise-grade sub-second turnaround.
|
|
151
149
|
|
|
152
|
-
### 2. Token Arbitrage Guard &
|
|
150
|
+
### 2. Token Arbitrage Guard & Three-Tier Cache Architecture
|
|
153
151
|
|
|
154
152
|
To prevent compiler cost overhead from exceeding token savings, TokenSafe applies a 3-stage defense:
|
|
155
153
|
|
|
156
|
-
1. **Smart Gating Threshold (`llm_distill_min_tokens: 100`)**: Prompts under 100 tokens bypass
|
|
157
|
-
2. **Output Token Ceiling (`distill_max_tokens: 60`)**: Caps
|
|
158
|
-
3. **
|
|
159
|
-
- **
|
|
160
|
-
- **
|
|
154
|
+
1. **Smart Gating Threshold (`llm_distill_min_tokens: 100`)**: Prompts under 100 tokens bypass cloud calls entirely and use instant zero-cost local regex heuristics ($0$ tokens, $< 1\text{ms}$).
|
|
155
|
+
2. **Output Token Ceiling (`distill_max_tokens: 60`)**: Caps distillation output at 60 tokens, eliminating verbose chain-of-thought inflation and token arbitrage loss.
|
|
156
|
+
3. **Three-Tier Distillation Cache Hierarchy**:
|
|
157
|
+
- **L1 (In-Memory LRU)**: Sub-millisecond instant hit for active developer session loops.
|
|
158
|
+
- **L2 (Persistent SQLite)**: Stores SHA-256 normalized prompt hashes in `data/metrics.db` across agent restarts. Recurring commands (`git commit`, `run tests`, `fix lint`) cost 0 tokens.
|
|
159
|
+
- **L3 (Shared Team Cache)**: *Team Tier.* Synchronizes compiled prompt intents and AST skeletons to TokenSafe Cloud (`/api/team/cache`). When one engineer or CI runner executes a prompt or reads a file, all teammates immediately hit warm 0ms cache.
|
|
161
160
|
|
|
162
|
-
### 3. Configuration
|
|
161
|
+
### 3. Configuration & Provider Inspection
|
|
163
162
|
|
|
164
|
-
|
|
163
|
+
Check your license status, active distillation mode, and cache stats anytime:
|
|
164
|
+
```bash
|
|
165
|
+
tokensafe providers
|
|
166
|
+
```
|
|
165
167
|
|
|
168
|
+
For custom self-hosted environments (`TOKENSAFE_SELF_HOSTED=1`), configure your preferred provider in `data/config.json`:
|
|
166
169
|
```json
|
|
167
170
|
{
|
|
168
171
|
"preferred_provider": "gemini",
|
|
@@ -199,12 +202,12 @@ Verified across 8 real-world production software engineering scenarios (131,604
|
|
|
199
202
|
|
|
200
203
|
## 💎 Pricing & 7-Day Free Trial
|
|
201
204
|
|
|
202
|
-
| Tier | Price | Highlights |
|
|
203
|
-
|
|
204
|
-
| **
|
|
205
|
-
| **Solo Developer** | **$9 / month** | **7-Day Free Trial**,
|
|
206
|
-
| **Engineering Team** | **$29 /
|
|
207
|
-
| **Enterprise** | Custom | On-Premise Nuitka C-compiled Docker Proxy, Custom Compliance, SAML SSO |
|
|
205
|
+
| Tier | Price | Monthly Token Savings | Highlights |
|
|
206
|
+
|---|---|---|---|
|
|
207
|
+
| **Community (Free)** | **$0** (Free Forever) | **500,000 tokens / mo** | 9-Language Local Regex Compactor, Local AST Skeletonizer CLI, Secret Redactor, Local HTML & SQLite Dashboard |
|
|
208
|
+
| **Solo Developer** | **$9 / month** | **Unlimited** | **7-Day Free Trial**, **Managed Cloud Distillation (Gemini Flash-Lite, Zero Keys Required)**, Subagent Swarm Firewall, Cascading Window Governor, Prompt Cache Normalizer |
|
|
209
|
+
| **Engineering Team** | **$29 / seat / mo** | **Unlimited** | **7-Day Free Trial**, Everything in Solo + **Shared Team Cache (L3 Monorepo Cloud Cache)**, Friday Team ROI Digest & Leaderboards, Team Seat Quota Console, Self-Hosted Docker Proxy |
|
|
210
|
+
| **Enterprise** | Custom | **Unlimited** | On-Premise Nuitka C-compiled Docker Proxy (`TOKENSAFE_SELF_HOSTED=1` BYOK), Custom Compliance, SAML SSO |
|
|
208
211
|
|
|
209
212
|
👉 **[Start your 7-Day Free Trial on our website](https://tokensafe.dev#pricing)**
|
|
210
213
|
|
|
@@ -407,9 +410,9 @@ TokenSafe is built on an **Open-Core** model designed to give every developer im
|
|
|
407
410
|
|
|
408
411
|
| Plan | Price | Monthly Token Savings | Capabilities |
|
|
409
412
|
| :--- | :---: | :---: | :--- |
|
|
410
|
-
| **Community (Free)** | **$0** forever | **500,000 tokens / mo** | Multilingual Local Regex Compactor, AST Slicer, Output Guard, Loop Guard, Local SQLite & HTML Dashboard |
|
|
411
|
-
| **Solo Developer** | **$9 / mo** | **Unlimited** |
|
|
412
|
-
| **Engineering Team** | **$29 / seat / mo** | **Unlimited** | Everything in Solo + **Shared Team Cache (
|
|
413
|
+
| **Community (Free)** | **$0** forever | **500,000 tokens / mo** | Multilingual Local Regex Compactor (9 languages), AST Slicer, Output Guard, Loop Guard, Local SQLite & HTML Dashboard |
|
|
414
|
+
| **Solo Developer** | **$9 / mo** | **Unlimited** | **Managed Cloud Distillation (Gemini Flash-Lite, Zero Keys Required)**, Subagent Swarm Firewall, Cascading Governor, Multi-turn History Fold |
|
|
415
|
+
| **Engineering Team** | **$29 / seat / mo** | **Unlimited** | Everything in Solo + **Shared Team Cache (L3 Monorepo Cloud Cache)**, Friday Team ROI Digest, Cloud Organization Console, Seat Quota Management, Self-Hosted Docker Proxy |
|
|
413
416
|
|
|
414
417
|
> [!TIP]
|
|
415
418
|
> **500,000 free tokens / month** are included out of the box with zero registration. When your monthly community limit is reached, basic regex compaction continues safely, and you can unlock unlimited Solo optimization anytime at [tokensafe.dev](https://tokensafe.dev/#pricing) or activate via `tokensafe activate <key>`.
|
package/package.json
CHANGED
package/plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agy-token-optimizer",
|
|
3
3
|
"displayName": "TokenSafe",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.9",
|
|
5
5
|
"description": "Zero-Loss Token Economy & Context Optimizer for AI Agents. Compresses prompts, slices AST/tool outputs, and prevents stuck loops.",
|
|
6
6
|
"logo": "assets/logo.svg",
|
|
7
7
|
"author": {
|
package/src/license_manager.py
CHANGED
|
@@ -18,9 +18,9 @@ DATA_DIR = os.path.join(PROJECT_ROOT, "data")
|
|
|
18
18
|
LICENSE_FILE = os.path.join(DATA_DIR, "license.json")
|
|
19
19
|
|
|
20
20
|
# Master Public Key for client-side offline verification (RFC 8032 Ed25519)
|
|
21
|
-
DEFAULT_ED25519_PUBLIC_KEY = "
|
|
22
|
-
# Private key for cloud server signing (never distributed to
|
|
23
|
-
DEFAULT_ED25519_PRIVATE_KEY = os.environ.get("TOKENSAFE_PRIVATE_KEY", "
|
|
21
|
+
DEFAULT_ED25519_PUBLIC_KEY = "beb27bc42a723943822ea1ba5d50b7abb55e430cb691518b0b05edef889d0132"
|
|
22
|
+
# Private key for cloud server signing (never distributed to client, loaded strictly from environment)
|
|
23
|
+
DEFAULT_ED25519_PRIVATE_KEY = os.environ.get("TOKENSAFE_PRIVATE_KEY", "")
|
|
24
24
|
# Rotated HMAC salt for backward compatibility with TS1 legacy licenses
|
|
25
25
|
ROTATED_HMAC_SALT = os.environ.get("TOKENSAFE_HMAC_SALT", "ts-sec-rotated-7b3f9c2d1e0a4f5b6829e1c3a70428e5")
|
|
26
26
|
DEFAULT_SIGNING_SALT = ROTATED_HMAC_SALT
|
|
@@ -166,7 +166,9 @@ class LicenseManager:
|
|
|
166
166
|
payload_b64 = base64.urlsafe_b64encode(payload_bytes).decode("ascii").rstrip("=")
|
|
167
167
|
|
|
168
168
|
if version == 2:
|
|
169
|
-
priv_hex = signing_key or DEFAULT_ED25519_PRIVATE_KEY
|
|
169
|
+
priv_hex = signing_key or os.environ.get("TOKENSAFE_PRIVATE_KEY") or DEFAULT_ED25519_PRIVATE_KEY
|
|
170
|
+
if not priv_hex:
|
|
171
|
+
raise ValueError("TOKENSAFE_PRIVATE_KEY environment variable is required to generate license signatures.")
|
|
170
172
|
priv_bytes = bytes.fromhex(priv_hex)
|
|
171
173
|
pub_bytes = bytes.fromhex(DEFAULT_ED25519_PUBLIC_KEY)
|
|
172
174
|
sig_raw = _ed25519_sign_bytes(payload_bytes, priv_bytes, pub_bytes)
|
package/src/version_checker.py
CHANGED
|
@@ -14,7 +14,7 @@ import urllib.request
|
|
|
14
14
|
import urllib.error
|
|
15
15
|
from typing import Dict, Any, Optional, Tuple
|
|
16
16
|
|
|
17
|
-
CURRENT_VERSION = "1.3.
|
|
17
|
+
CURRENT_VERSION = "1.3.9"
|
|
18
18
|
CACHE_TTL = 86400 # 24 hours
|
|
19
19
|
|
|
20
20
|
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|