mythos-router 1.2.0 → 1.3.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/CHANGELOG.md +39 -5
- package/README.md +24 -3
- package/dist/cache.d.ts +28 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +169 -0
- package/dist/cache.js.map +1 -0
- package/dist/cli.js +14 -1
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +20 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +85 -102
- package/dist/client.js.map +1 -1
- package/dist/commands/chat.d.ts +3 -0
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +181 -30
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/dream.d.ts.map +1 -1
- package/dist/commands/dream.js +8 -1
- package/dist/commands/dream.js.map +1 -1
- package/dist/commands/providers.d.ts +7 -0
- package/dist/commands/providers.d.ts.map +1 -0
- package/dist/commands/providers.js +142 -0
- package/dist/commands/providers.js.map +1 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +21 -1
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/anthropic.d.ts +12 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +179 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/openai.d.ts +20 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +194 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/orchestrator.d.ts +43 -0
- package/dist/providers/orchestrator.d.ts.map +1 -0
- package/dist/providers/orchestrator.js +471 -0
- package/dist/providers/orchestrator.js.map +1 -0
- package/dist/providers/pricing.d.ts +22 -0
- package/dist/providers/pricing.d.ts.map +1 -0
- package/dist/providers/pricing.js +60 -0
- package/dist/providers/pricing.js.map +1 -0
- package/dist/providers/telemetry.d.ts +49 -0
- package/dist/providers/telemetry.d.ts.map +1 -0
- package/dist/providers/telemetry.js +235 -0
- package/dist/providers/telemetry.js.map +1 -0
- package/dist/providers/types.d.ts +72 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +6 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/skills.d.ts +41 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +227 -0
- package/dist/skills.js.map +1 -0
- package/dist/swd.d.ts.map +1 -1
- package/dist/swd.js +46 -11
- package/dist/swd.js.map +1 -1
- package/dist/utils.d.ts +5 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +39 -0
- package/dist/utils.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
+
## [1.3.0] — 2026-04-26
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **Provider Observability Dashboard** — Added the `mythos providers` command. A real-time, terminal-based dashboard that surfaces EMA latency trends, success rates, circuit breaker recovery ETAs, and a live "Leader" score. Includes a zero-flicker `--watch` mode.
|
|
14
|
+
- **SQLite Telemetry Backend** — Orchestration events are now persistently streamed to a dedicated `telemetry.db` using WAL pragmas and an asynchronous batching queue to guarantee zero hot-path blocking.
|
|
15
|
+
- **Contextual Decision Tracing** — The engine no longer just routes; it explains *why*. Routing traces now explicitly capture task type (`chat`, `code`, `analysis`), input token buckets, and latency-vs-success-rate reasoning logs.
|
|
16
|
+
- **Automated Retention Policies** — The telemetry engine aggressively self-prunes history, maintaining only the last 1,000 routing events and truncating error stack traces to prevent long-term database bloat.
|
|
17
|
+
|
|
18
|
+
## [1.2.1]
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- **Multi-Provider Orchestration Engine** — Decoupled the core application from the Anthropic SDK. The system now supports fallback routing, adaptive watchdogs, circuit breakers, and EMA-based performance scoring across multiple providers.
|
|
22
|
+
- **OpenAI & DeepSeek Support** — Added a native, zero-dependency `fetch`-based provider (`OpenAIProvider`) to seamlessly support OpenAI and DeepSeek endpoints (including streaming reasoning content for `o1` and `DeepSeek-R1`).
|
|
23
|
+
- **Skills Protocol** — Modular expert plugins via zero-dependency YAML frontmatter parsing. Skills (`-s <skill>`) can inject customized instructions, modify budget multipliers, and enforce deterministic provider selection.
|
|
24
|
+
- **Deterministic Response Caching** — SQLite-backed response caching for pure-reasoning requests (like `verify` or `dream`). Bypass rule strictly ensures file-mutating responses are never cached.
|
|
25
|
+
- **Centralized Pricing Registry** — Unified token cost calculator across different providers, feeding exact financial data into the budget metrics.
|
|
26
|
+
- **Auto-Healing TDD Loop** — Bounded, error-driven autonomy. Passing `--test-cmd` will automatically execute tests after a successful SWD mutation. If tests fail, the CLI intercepts `stderr`, truncates it, identifies TS/Runtime issues, and feeds it back to Claude for a self-healing iteration.
|
|
27
|
+
- **TDD Anti-Thrashing Guards** — The orchestrator will automatically abort the healing loop if Claude attempts the exact same fix or if output remains identically broken, preventing runaway API costs.
|
|
28
|
+
- **Contributor Covenant** — Added `CODE_OF_CONDUCT.md` to formally establish community standards.
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
- **Stable Provider Fallback** — Fixed an edge case in the `ProviderOrchestrator` where identical EMA scores (e.g., at startup) could cause unpredictable provider routing due to JS `sort()` instability. The engine now explicitly respects user-configured priorities as a tie-breaker.
|
|
32
|
+
|
|
33
|
+
### Security
|
|
34
|
+
- **CodeQL Integration** — Added GitHub CodeQL scanning badge to `README.md`.
|
|
35
|
+
- **Dependency Audit** — Triaged and validated false-positive Socket.dev supply chain alerts for `@anthropic-ai/sdk`.
|
|
36
|
+
|
|
37
|
+
---
|
|
10
38
|
## [1.2.0] — 2026-04-23
|
|
11
39
|
|
|
12
40
|
### Added
|
|
@@ -137,9 +165,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
137
165
|
- **Correction Turns** — max 2 retries before yielding to human.
|
|
138
166
|
- **Dream/Verify Commands** — memory compression and drift detection.
|
|
139
167
|
|
|
140
|
-
|
|
141
|
-
[1.1
|
|
142
|
-
[1.
|
|
143
|
-
[1.1.
|
|
144
|
-
[1.1.
|
|
168
|
+
|
|
169
|
+
[1.2.1]: https://github.com/thewaltero/mythos-router/releases/tag/v1.2.1
|
|
170
|
+
[1.2.0]: https://github.com/thewaltero/mythos-router/releases/tag/v1.2.0
|
|
171
|
+
[1.1.9]: https://github.com/thewaltero/mythos-router/releases/tag/v1.1.9
|
|
172
|
+
[1.1.8]: https://github.com/thewaltero/mythos-router/releases/tag/v1.1.8
|
|
173
|
+
[1.1.7]: https://github.com/thewaltero/mythos-router/releases/tag/v1.1.7
|
|
174
|
+
[1.1.6]: https://github.com/thewaltero/mythos-router/releases/tag/v1.1.6
|
|
175
|
+
[1.1.3]: https://github.com/thewaltero/mythos-router/releases/tag/v1.1.3
|
|
176
|
+
[1.1.2]: https://github.com/thewaltero/mythos-router/releases/tag/v1.1.2
|
|
177
|
+
[1.1.1]: https://github.com/thewaltero/mythos-router/releases/tag/v1.1.1
|
|
178
|
+
[1.1.0]: https://github.com/thewaltero/mythos-router/releases/tag/v1.1.0
|
|
145
179
|
[1.0.0]: https://github.com/thewaltero/mythos-router/releases/tag/v1.0.0
|
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<img src="assets/banner.png" alt="Mythos Router Banner" width="864" />
|
|
3
3
|
|
|
4
|
+
[](https://github.com/thewaltero/mythos-router/actions/workflows/github-code-scanning/codeql)
|
|
4
5
|
[](https://www.npmjs.com/package/mythos-router)
|
|
5
6
|
[](https://nodejs.org)
|
|
6
7
|
[](https://typescriptlang.org)
|
|
@@ -12,6 +13,11 @@
|
|
|
12
13
|
## Claude Opus 4.7 · Strict Write Discipline · Zero Slop
|
|
13
14
|
**A local CLI power tool for verifiable AI-assisted coding.**
|
|
14
15
|
|
|
16
|
+
<br />
|
|
17
|
+
|
|
18
|
+
[What is this?](#what-is-this) • [Features](#features) • [Installation](#installation) • [Usage](#usage) • [Architecture](#architecture) • [Token Budget](#token-usage--budget) • [SDK](#-sdk-usage-for-agentic-systems)
|
|
19
|
+
|
|
20
|
+
|
|
15
21
|
---
|
|
16
22
|
|
|
17
23
|
### Support the project
|
|
@@ -47,9 +53,13 @@ Zero slop. Zero hallucinated state. Full adaptive thinking.
|
|
|
47
53
|
|
|
48
54
|
| Feature | Description |
|
|
49
55
|
|---------|-------------|
|
|
56
|
+
| **Multi-Provider Fallback** | Auto-routes between Anthropic, DeepSeek, and OpenAI with circuit breakers |
|
|
57
|
+
| **Skills Protocol** | Inject modular expert plugins via YAML frontmatter (`-s mcp`, `-s react`) |
|
|
58
|
+
| **Deterministic Caching** | SQLite-backed caching for zero-cost, zero-latency repetitive reasoning |
|
|
50
59
|
| **Adaptive Thinking** | Opus 4.7 with configurable effort levels (high/medium/low) |
|
|
51
60
|
| **Strict Write Discipline** | Pre/post filesystem snapshots verify every model claim |
|
|
52
61
|
| **Self-Healing Memory** | Authority-based logging with a rebuildable SQLite FTS5 search index |
|
|
62
|
+
| **Auto-Healing TDD** | Pass `--test-cmd` for bounded, error-driven autonomous repair loops |
|
|
53
63
|
| **Correction Turns** | Model gets 2 retries to match filesystem reality, then yields |
|
|
54
64
|
| **Integrity Gate** | `verify` command and startup hashing ensure zero drift |
|
|
55
65
|
| **Token Limiter** | Budget cap with graceful save — progress saved to MEMORY.md, never lose work |
|
|
@@ -91,9 +101,10 @@ As memory approaches capacity, the `dream` command delegates a compression phase
|
|
|
91
101
|
# Install globally
|
|
92
102
|
npm install -g mythos-router
|
|
93
103
|
|
|
94
|
-
# Set your API
|
|
104
|
+
# Set your API keys (Anthropic is primary, others are fallbacks)
|
|
95
105
|
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
96
|
-
|
|
106
|
+
export OPENAI_API_KEY="sk-proj-..."
|
|
107
|
+
export DEEPSEEK_API_KEY="sk-..."
|
|
97
108
|
|
|
98
109
|
# Go
|
|
99
110
|
mythos chat
|
|
@@ -122,6 +133,8 @@ npm run chat
|
|
|
122
133
|
|
|
123
134
|
```bash
|
|
124
135
|
mythos chat # Full power (high effort, Opus 4.7)
|
|
136
|
+
mythos chat -s react # Load the 'react' expert skill
|
|
137
|
+
mythos chat --test-cmd "npm test" # Enable autonomous test-driven self-healing
|
|
125
138
|
mythos chat --effort low # Budget mode (Haiku 3)
|
|
126
139
|
mythos chat --effort medium # Balanced (Sonnet 3.5)
|
|
127
140
|
mythos chat --dry-run # Preview all file changes before executing
|
|
@@ -270,6 +283,12 @@ mythos-router/
|
|
|
270
283
|
│ ├── verify.ts # Codebase ↔ Memory scanner (dry-run aware)
|
|
271
284
|
│ ├── dream.ts # Memory compression (dry-run aware)
|
|
272
285
|
│ └── stats.ts # Budget analytics reporter
|
|
286
|
+
├── src/providers/ # Multi-Provider Orchestration Engine
|
|
287
|
+
│ ├── orchestrator.ts # Adaptive routing, circuit breakers, scoring
|
|
288
|
+
│ ├── pricing.ts # Centralized token cost registry
|
|
289
|
+
│ ├── types.ts # Unified BaseProvider contracts
|
|
290
|
+
│ ├── anthropic.ts # Claude provider
|
|
291
|
+
│ └── openai.ts # Fetch-based OpenAI & DeepSeek provider
|
|
273
292
|
├── test/ # Automated test suite (node:test)
|
|
274
293
|
├── .mythosignore # SWD scan exclusions
|
|
275
294
|
├── MEMORY.md # Auto-generated agentic memory
|
|
@@ -317,7 +336,9 @@ If you prefer to keep it private, add `MEMORY.md` to your `.gitignore`.
|
|
|
317
336
|
|
|
318
337
|
| Env Variable | Required | Description |
|
|
319
338
|
|-------------|----------|-------------|
|
|
320
|
-
| `ANTHROPIC_API_KEY` | ✅ | Your Anthropic API key |
|
|
339
|
+
| `ANTHROPIC_API_KEY` | ✅ | Your Anthropic API key (Primary Provider) |
|
|
340
|
+
| `OPENAI_API_KEY` | ❌ | OpenAI API Key (Fallback Provider) |
|
|
341
|
+
| `DEEPSEEK_API_KEY` | ❌ | DeepSeek API Key (Fallback Provider, reasoning capable) |
|
|
321
342
|
|
|
322
343
|
| File | Purpose |
|
|
323
344
|
|------|---------|
|
package/dist/cache.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { UnifiedResponse } from './providers/types.js';
|
|
2
|
+
export interface CacheKeyInput {
|
|
3
|
+
model: string;
|
|
4
|
+
systemPrompt: string;
|
|
5
|
+
messages: Array<{
|
|
6
|
+
role: string;
|
|
7
|
+
content: string;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
export declare function generateCacheKey(input: CacheKeyInput): string;
|
|
11
|
+
export declare class ResponseCache {
|
|
12
|
+
private db;
|
|
13
|
+
private ttlMs;
|
|
14
|
+
private enabled;
|
|
15
|
+
constructor(ttlMs?: number, enabled?: boolean);
|
|
16
|
+
private ensureDb;
|
|
17
|
+
get(key: string): UnifiedResponse | null;
|
|
18
|
+
set(key: string, response: UnifiedResponse, model: string): void;
|
|
19
|
+
evictExpired(): number;
|
|
20
|
+
clear(): void;
|
|
21
|
+
stats(): {
|
|
22
|
+
entries: number;
|
|
23
|
+
totalHits: number;
|
|
24
|
+
oldestMs: number;
|
|
25
|
+
};
|
|
26
|
+
close(): void;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AA4B5D,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAG7D;AAGD,qBAAa,aAAa;IACxB,OAAO,CAAC,EAAE,CAAwE;IAClF,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,OAAO,CAAU;gBAEb,KAAK,GAAE,MAAuB,EAAE,OAAO,GAAE,OAAc;IAMnE,OAAO,CAAC,QAAQ;IAgChB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI;IA0BxC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAmBhE,YAAY,IAAI,MAAM;IActB,KAAK,IAAI,IAAI;IAYb,KAAK,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;IAoBjE,KAAK,IAAI,IAAI;CAMd"}
|
package/dist/cache.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// ─────────────────────────────────────────────────────────────
|
|
2
|
+
// mythos-router :: cache.ts
|
|
3
|
+
// Deterministic Response Cache — SQLite-backed
|
|
4
|
+
//
|
|
5
|
+
// Rules:
|
|
6
|
+
// - Cache is DISABLED for `chat` (external state changes)
|
|
7
|
+
// - Cache is ACTIVE for `verify` and `dream` (pure reasoning)
|
|
8
|
+
// - Tool invocations BYPASS the cache entirely
|
|
9
|
+
// - Keys use canonical JSON (sorted keys) + SHA-256
|
|
10
|
+
// - TTL-based expiration (default: 1 hour)
|
|
11
|
+
// ─────────────────────────────────────────────────────────────
|
|
12
|
+
import * as fs from 'node:fs';
|
|
13
|
+
import * as path from 'node:path';
|
|
14
|
+
import * as os from 'node:os';
|
|
15
|
+
import { createHash } from 'node:crypto';
|
|
16
|
+
// ── Constants ────────────────────────────────────────────────
|
|
17
|
+
const CACHE_DIR = path.join(os.homedir(), '.mythos-router');
|
|
18
|
+
const CACHE_DB_FILE = path.join(CACHE_DIR, 'cache.db');
|
|
19
|
+
const DEFAULT_TTL_MS = 60 * 60 * 1000; // 1 hour
|
|
20
|
+
// ── Canonical JSON Stringify (sorted keys) ───────────────────
|
|
21
|
+
// Ensures identical objects always produce the same string,
|
|
22
|
+
// regardless of key insertion order.
|
|
23
|
+
function canonicalStringify(obj) {
|
|
24
|
+
if (obj === null || typeof obj !== 'object') {
|
|
25
|
+
return JSON.stringify(obj);
|
|
26
|
+
}
|
|
27
|
+
if (Array.isArray(obj)) {
|
|
28
|
+
return '[' + obj.map(item => canonicalStringify(item)).join(',') + ']';
|
|
29
|
+
}
|
|
30
|
+
const sorted = Object.keys(obj).sort();
|
|
31
|
+
const pairs = sorted.map(key => {
|
|
32
|
+
const val = obj[key];
|
|
33
|
+
return `${JSON.stringify(key)}:${canonicalStringify(val)}`;
|
|
34
|
+
});
|
|
35
|
+
return '{' + pairs.join(',') + '}';
|
|
36
|
+
}
|
|
37
|
+
export function generateCacheKey(input) {
|
|
38
|
+
const payload = canonicalStringify(input);
|
|
39
|
+
return createHash('sha256').update(payload).digest('hex');
|
|
40
|
+
}
|
|
41
|
+
// ── Response Cache ───────────────────────────────────────────
|
|
42
|
+
export class ResponseCache {
|
|
43
|
+
db = null;
|
|
44
|
+
ttlMs;
|
|
45
|
+
enabled;
|
|
46
|
+
constructor(ttlMs = DEFAULT_TTL_MS, enabled = true) {
|
|
47
|
+
this.ttlMs = ttlMs;
|
|
48
|
+
this.enabled = enabled;
|
|
49
|
+
}
|
|
50
|
+
// ── Lazy Initialization ──────────────────────────────────
|
|
51
|
+
ensureDb() {
|
|
52
|
+
if (this.db)
|
|
53
|
+
return this.db;
|
|
54
|
+
// Dynamic import to avoid crash if sqlite is unavailable
|
|
55
|
+
try {
|
|
56
|
+
const { DatabaseSync } = require('node:sqlite');
|
|
57
|
+
if (!fs.existsSync(CACHE_DIR)) {
|
|
58
|
+
fs.mkdirSync(CACHE_DIR, { recursive: true });
|
|
59
|
+
}
|
|
60
|
+
this.db = new DatabaseSync(CACHE_DB_FILE);
|
|
61
|
+
this.db.exec(`
|
|
62
|
+
CREATE TABLE IF NOT EXISTS cache_entries (
|
|
63
|
+
key TEXT PRIMARY KEY,
|
|
64
|
+
response TEXT NOT NULL,
|
|
65
|
+
model TEXT NOT NULL,
|
|
66
|
+
created_at INTEGER NOT NULL,
|
|
67
|
+
hit_count INTEGER DEFAULT 0
|
|
68
|
+
);
|
|
69
|
+
CREATE INDEX IF NOT EXISTS idx_cache_created ON cache_entries(created_at);
|
|
70
|
+
`);
|
|
71
|
+
return this.db;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// SQLite not available — cache is a no-op
|
|
75
|
+
this.enabled = false;
|
|
76
|
+
throw new Error('SQLite not available for caching');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// ── Get cached response ──────────────────────────────────
|
|
80
|
+
get(key) {
|
|
81
|
+
if (!this.enabled)
|
|
82
|
+
return null;
|
|
83
|
+
try {
|
|
84
|
+
const db = this.ensureDb();
|
|
85
|
+
const now = Date.now();
|
|
86
|
+
const cutoff = now - this.ttlMs;
|
|
87
|
+
const stmt = db.prepare('SELECT response, created_at FROM cache_entries WHERE key = ? AND created_at > ?');
|
|
88
|
+
const row = stmt.get(key, cutoff);
|
|
89
|
+
if (!row)
|
|
90
|
+
return null;
|
|
91
|
+
// Update hit count
|
|
92
|
+
db.prepare('UPDATE cache_entries SET hit_count = hit_count + 1 WHERE key = ?').run(key);
|
|
93
|
+
return JSON.parse(row.response);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// ── Store response in cache ──────────────────────────────
|
|
100
|
+
// INVARIANT: Responses with tool calls are NEVER cached.
|
|
101
|
+
set(key, response, model) {
|
|
102
|
+
if (!this.enabled)
|
|
103
|
+
return;
|
|
104
|
+
// Tool Invocation Bypass — never cache responses with tool calls
|
|
105
|
+
if (response.toolCalls.length > 0)
|
|
106
|
+
return;
|
|
107
|
+
try {
|
|
108
|
+
const db = this.ensureDb();
|
|
109
|
+
const serialized = JSON.stringify(response);
|
|
110
|
+
db.prepare('INSERT OR REPLACE INTO cache_entries (key, response, model, created_at, hit_count) VALUES (?, ?, ?, ?, 0)').run(key, serialized, model, Date.now());
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
// Fail silently — caching is non-critical
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// ── Evict expired entries ────────────────────────────────
|
|
117
|
+
evictExpired() {
|
|
118
|
+
if (!this.enabled)
|
|
119
|
+
return 0;
|
|
120
|
+
try {
|
|
121
|
+
const db = this.ensureDb();
|
|
122
|
+
const cutoff = Date.now() - this.ttlMs;
|
|
123
|
+
const result = db.prepare('DELETE FROM cache_entries WHERE created_at <= ?').run(cutoff);
|
|
124
|
+
return result.changes ?? 0;
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
return 0;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// ── Clear entire cache ───────────────────────────────────
|
|
131
|
+
clear() {
|
|
132
|
+
if (!this.enabled)
|
|
133
|
+
return;
|
|
134
|
+
try {
|
|
135
|
+
const db = this.ensureDb();
|
|
136
|
+
db.prepare('DELETE FROM cache_entries').run();
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
// Fail silently
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// ── Stats ────────────────────────────────────────────────
|
|
143
|
+
stats() {
|
|
144
|
+
if (!this.enabled)
|
|
145
|
+
return { entries: 0, totalHits: 0, oldestMs: 0 };
|
|
146
|
+
try {
|
|
147
|
+
const db = this.ensureDb();
|
|
148
|
+
const countRow = db.prepare('SELECT COUNT(*) as cnt FROM cache_entries').get();
|
|
149
|
+
const hitsRow = db.prepare('SELECT COALESCE(SUM(hit_count), 0) as total FROM cache_entries').get();
|
|
150
|
+
const oldestRow = db.prepare('SELECT MIN(created_at) as oldest FROM cache_entries').get();
|
|
151
|
+
return {
|
|
152
|
+
entries: countRow.cnt,
|
|
153
|
+
totalHits: hitsRow.total,
|
|
154
|
+
oldestMs: oldestRow.oldest ? Date.now() - oldestRow.oldest : 0,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return { entries: 0, totalHits: 0, oldestMs: 0 };
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// ── Close ────────────────────────────────────────────────
|
|
162
|
+
close() {
|
|
163
|
+
if (this.db) {
|
|
164
|
+
this.db.close();
|
|
165
|
+
this.db = null;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,6BAA6B;AAC7B,gDAAgD;AAChD,EAAE;AACF,UAAU;AACV,2DAA2D;AAC3D,+DAA+D;AAC/D,gDAAgD;AAChD,qDAAqD;AACrD,4CAA4C;AAC5C,gEAAgE;AAEhE,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,gEAAgE;AAChE,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,gBAAgB,CAAC,CAAC;AAC5D,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AACvD,MAAM,cAAc,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,SAAS;AAEhD,gEAAgE;AAChE,4DAA4D;A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AC,EAAE,EAAE,CAAC;YACZ,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC;QACjB,CAAC;IACH,CAAC;CACF"}
|
package/dist/cli.js
CHANGED
|
@@ -8,13 +8,14 @@ import { chatCommand } from './commands/chat.js';
|
|
|
8
8
|
import { verifyCommand } from './commands/verify.js';
|
|
9
9
|
import { dreamCommand } from './commands/dream.js';
|
|
10
10
|
import { statsCommand } from './commands/stats.js';
|
|
11
|
+
import { providersCommand } from './commands/providers.js';
|
|
11
12
|
import { DEFAULT_MAX_TOKENS_PER_SESSION, DEFAULT_MAX_TURNS, } from './config.js';
|
|
12
13
|
const program = new Command();
|
|
13
14
|
program
|
|
14
15
|
.name('mythos')
|
|
15
16
|
.description('Capybara-tier CLI router — Claude Opus 4.7 with Adaptive Thinking, ' +
|
|
16
17
|
'Strict Write Discipline, and Self-Healing Memory.')
|
|
17
|
-
.version('1.
|
|
18
|
+
.version('1.3.0');
|
|
18
19
|
// ── mythos chat ──────────────────────────────────────────────
|
|
19
20
|
program
|
|
20
21
|
.command('chat')
|
|
@@ -26,6 +27,9 @@ program
|
|
|
26
27
|
.option('--dry-run', 'Preview all file operations without executing them')
|
|
27
28
|
.option('--verbose', 'Show detailed SWD traces and memory operations')
|
|
28
29
|
.option('-b, --branch <name>', 'Run session in a new git branch for sandboxed reasoning')
|
|
30
|
+
.option('-t, --test-cmd <cmd>', 'Command to run after successful SWD execution (WARNING: assumes a trusted environment and executes arbitrary shell commands)')
|
|
31
|
+
.option('--max-test-retries <n>', 'Maximum number of times Claude can attempt to fix failing tests', '3')
|
|
32
|
+
.option('-s, --skill <names...>', 'Inject specific expert skills (e.g., -s mcp -s react)')
|
|
29
33
|
.action(async (options) => {
|
|
30
34
|
await chatCommand(options);
|
|
31
35
|
});
|
|
@@ -54,6 +58,15 @@ program
|
|
|
54
58
|
.action(async (options) => {
|
|
55
59
|
await statsCommand(options);
|
|
56
60
|
});
|
|
61
|
+
// ── mythos providers ─────────────────────────────────────────
|
|
62
|
+
program
|
|
63
|
+
.command('providers')
|
|
64
|
+
.description('Live dashboard of provider health, EMA scoring, and routing decisions')
|
|
65
|
+
.option('-w, --watch', 'Auto-refresh the dashboard when metrics change')
|
|
66
|
+
.option('--verbose', 'Show full error stacks for recent failures')
|
|
67
|
+
.action(async (options) => {
|
|
68
|
+
await providersCommand(options);
|
|
69
|
+
});
|
|
57
70
|
// ── Default: show help ───────────────────────────────────────
|
|
58
71
|
if (process.argv.length <= 2) {
|
|
59
72
|
// Import banner and show it before help
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,gEAAgE;AAChE,2BAA2B;AAC3B,+CAA+C;AAC/C,gEAAgE;AAEhE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACL,8BAA8B,EAC9B,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAErB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CACV,qEAAqE;IACrE,mDAAmD,CACpD;KACA,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,gEAAgE;AAChE,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,sDAAsD,CAAC;KACnE,MAAM,CACL,sBAAsB,EACtB,8CAA8C,EAC9C,MAAM,CACP;KACA,MAAM,CACL,kBAAkB,EAClB,oCAAoC,8BAA8B,CAAC,cA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,CAAC,gBAAgB,EAAE,mCAAmC,CAAC;KAC7D,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEL,gEAAgE;AAChE,OAAO;KACJ,OAAO,CAAC,WAAW,CAAC;KACpB,WAAW,CAAC,uEAAuE,CAAC;KACpF,MAAM,CAAC,aAAa,EAAE,gDAAgD,CAAC;KACvE,MAAM,CAAC,WAAW,EAAE,4CAA4C,CAAC;KACjE,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,MAAM,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC,CAAC,CAAC;AAEL,gEAAgE;AAChE,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;IAC7B,wCAAwC;IACxC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;QACvC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACpB,OAAO,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC;KAAM,CAAC;IACN,OAAO,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,17 +1,30 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ProviderOrchestrator } from './providers/orchestrator.js';
|
|
2
2
|
import { type EffortLevel } from './config.js';
|
|
3
|
-
export
|
|
4
|
-
role: 'user' | 'assistant';
|
|
5
|
-
content: string;
|
|
6
|
-
}
|
|
3
|
+
export type { Message } from './providers/types.js';
|
|
7
4
|
export interface MythosResponse {
|
|
8
5
|
thinking: string;
|
|
9
6
|
text: string;
|
|
10
7
|
inputTokens: number;
|
|
11
8
|
outputTokens: number;
|
|
9
|
+
/** Provider metadata (new — optional for backward compat) */
|
|
10
|
+
_orchestration?: {
|
|
11
|
+
providerId: string;
|
|
12
|
+
modelId: string;
|
|
13
|
+
fallbackTriggered: boolean;
|
|
14
|
+
incomplete: boolean;
|
|
15
|
+
latencyMs: number;
|
|
16
|
+
};
|
|
12
17
|
}
|
|
18
|
+
export declare function getOrchestrator(): ProviderOrchestrator;
|
|
19
|
+
import Anthropic from '@anthropic-ai/sdk';
|
|
13
20
|
export declare function getClient(): Anthropic;
|
|
14
|
-
export declare function streamMessage(messages:
|
|
15
|
-
|
|
21
|
+
export declare function streamMessage(messages: {
|
|
22
|
+
role: 'user' | 'assistant';
|
|
23
|
+
content: string;
|
|
24
|
+
}[], effort?: EffortLevel, onThinkingDelta?: (text: string) => void, onTextDelta?: (text: string) => void): Promise<MythosResponse>;
|
|
25
|
+
export declare function sendMessage(messages: {
|
|
26
|
+
role: 'user' | 'assistant';
|
|
27
|
+
content: string;
|
|
28
|
+
}[], effort?: EffortLevel, systemOverride?: string): Promise<MythosResponse>;
|
|
16
29
|
export declare function formatTokenUsage(resp: MythosResponse): string;
|
|
17
30
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;AAIrB,YAAY,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGpD,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,cAAc,CAAC,EAAE;QACf,UAAU,EAAE,MAAM,CAAC;Q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