mythos-router 1.1.9 → 1.2.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/CHANGELOG.md +50 -5
- package/README.md +51 -18
- 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 +4 -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 +14 -0
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +363 -360
- 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/config.d.ts +10 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +32 -9
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +11 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -5
- 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 +38 -0
- package/dist/providers/orchestrator.d.ts.map +1 -0
- package/dist/providers/orchestrator.js +398 -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/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-cli.d.ts +9 -0
- package/dist/swd-cli.d.ts.map +1 -0
- package/dist/swd-cli.js +56 -0
- package/dist/swd-cli.js.map +1 -0
- package/dist/swd.d.ts +44 -32
- package/dist/swd.d.ts.map +1 -1
- package/dist/swd.js +236 -307
- 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 +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,45 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
+
## [1.2.1]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **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.
|
|
14
|
+
- **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`).
|
|
15
|
+
- **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.
|
|
16
|
+
- **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.
|
|
17
|
+
- **Centralized Pricing Registry** — Unified token cost calculator across different providers, feeding exact financial data into the budget metrics.
|
|
18
|
+
- **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.
|
|
19
|
+
- **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.
|
|
20
|
+
- **Contributor Covenant** — Added `CODE_OF_CONDUCT.md` to formally establish community standards.
|
|
21
|
+
|
|
22
|
+
### Security
|
|
23
|
+
- **CodeQL Integration** — Added GitHub CodeQL scanning badge to `README.md`.
|
|
24
|
+
- **Dependency Audit** — Triaged and validated false-positive Socket.dev supply chain alerts for `@anthropic-ai/sdk`.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
## [1.2.0] — 2026-04-23
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
- **SWDEngine v1 API** — Transactional filesystem execution kernel with `Plan → Snapshot → Execute → Verify → Rollback` lifecycle. Single entry point: `engine.run(actions)`.
|
|
31
|
+
- **ChatUI Abstraction** — Decoupled chat session logic from the terminal via a `ChatUI` interface. `ChatSession` is now a pure orchestrator, fully testable and reusable outside the CLI.
|
|
32
|
+
- **TerminalUI Implementation** — CLI-specific `ChatUI` adapter wrapping the Spinner and ANSI output.
|
|
33
|
+
- **SWD Lifecycle Hooks** — Extensibility layer (`onAction`, `onVerify`, `onRollback`) allowing consumers to inject logging, telemetry, or custom UI into the engine.
|
|
34
|
+
- **Rollback Auditability** — `SWDRunResult.rollbackErrors` field captures and reports rollback failures instead of silently swallowing them.
|
|
35
|
+
- **`swd-cli.ts`** — Separated SWD terminal presentation (verification output, dry-run preview, verbose traces) from the pure execution kernel.
|
|
36
|
+
- **Git Sandbox** — `ChatSession.setupSandbox()` for automated `mythos/` branch creation with nested-sandboxing protection.
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
- **SWD Kernel is now I/O-free** — `swd.ts` contains zero `console.log` calls. All presentation lives in `swd-cli.ts`.
|
|
40
|
+
- **`validateApiKey()` throws instead of `process.exit(1)`** — library-safe error handling.
|
|
41
|
+
- **SDK exports (`index.ts`) fully updated** — removed dead symbols (`runSWD`, `parseFileActions`, `snapshotFiles`), added `SWDEngine`, `parseActions`, `SessionBudget`, `ChatUI`, and all v1 types.
|
|
42
|
+
|
|
43
|
+
### Fixed
|
|
44
|
+
- **🔴 Snapshot memoization bug** — `InternalSessionContext.getSnapshot('after')` was returning stale cached state on multi-action same-file scenarios. After snapshots now always re-read disk state.
|
|
45
|
+
- **🔴 Broken `index.ts` exports** — SDK entry point was referencing pre-refactor symbols that no longer existed.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
10
49
|
## [1.1.9] — 2026-04-22
|
|
11
50
|
|
|
12
51
|
### Added
|
|
@@ -115,9 +154,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
115
154
|
- **Correction Turns** — max 2 retries before yielding to human.
|
|
116
155
|
- **Dream/Verify Commands** — memory compression and drift detection.
|
|
117
156
|
|
|
118
|
-
|
|
119
|
-
[1.1
|
|
120
|
-
[1.
|
|
121
|
-
[1.1.
|
|
122
|
-
[1.1.
|
|
157
|
+
|
|
158
|
+
[1.2.1]: https://github.com/thewaltero/mythos-router/releases/tag/v1.2.1
|
|
159
|
+
[1.2.0]: https://github.com/thewaltero/mythos-router/releases/tag/v1.2.0
|
|
160
|
+
[1.1.9]: https://github.com/thewaltero/mythos-router/releases/tag/v1.1.9
|
|
161
|
+
[1.1.8]: https://github.com/thewaltero/mythos-router/releases/tag/v1.1.8
|
|
162
|
+
[1.1.7]: https://github.com/thewaltero/mythos-router/releases/tag/v1.1.7
|
|
163
|
+
[1.1.6]: https://github.com/thewaltero/mythos-router/releases/tag/v1.1.6
|
|
164
|
+
[1.1.3]: https://github.com/thewaltero/mythos-router/releases/tag/v1.1.3
|
|
165
|
+
[1.1.2]: https://github.com/thewaltero/mythos-router/releases/tag/v1.1.2
|
|
166
|
+
[1.1.1]: https://github.com/thewaltero/mythos-router/releases/tag/v1.1.1
|
|
167
|
+
[1.1.0]: https://github.com/thewaltero/mythos-router/releases/tag/v1.1.0
|
|
123
168
|
[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
|
|
@@ -220,24 +233,32 @@ Data is stored locally in `~/.mythos-router/metrics.json`.
|
|
|
220
233
|
`mythos-router` exposes its Strict Write Discipline engine for programmatic use:
|
|
221
234
|
|
|
222
235
|
```typescript
|
|
223
|
-
import {
|
|
236
|
+
import { SWDEngine, parseActions } from 'mythos-router';
|
|
224
237
|
|
|
225
|
-
// 1.
|
|
226
|
-
const
|
|
238
|
+
// 1. Create an engine instance with your preferred options
|
|
239
|
+
const engine = new SWDEngine({
|
|
240
|
+
strict: true,
|
|
241
|
+
enableRollback: true,
|
|
242
|
+
onAction: (action) => console.log(`Executing: ${action.operation} ${action.path}`),
|
|
243
|
+
onVerify: (result) => console.log(`${result.status}: ${result.detail}`),
|
|
244
|
+
});
|
|
227
245
|
|
|
228
246
|
// 2. Let your agent generate code (must output [FILE_ACTION] blocks)
|
|
229
|
-
const agentOutput = await myAgent.generateCode();
|
|
247
|
+
const agentOutput = await myAgent.generateCode();
|
|
230
248
|
|
|
231
|
-
// 3.
|
|
232
|
-
const
|
|
249
|
+
// 3. Parse the agent's output and route through the SWD engine
|
|
250
|
+
const actions = parseActions(agentOutput);
|
|
251
|
+
const result = await engine.run(actions);
|
|
233
252
|
|
|
234
|
-
if (result.
|
|
253
|
+
if (result.success) {
|
|
235
254
|
console.log('✅ Agent execution verified securely');
|
|
236
255
|
} else {
|
|
237
|
-
console.log('❌ Agent hallucinated a write.
|
|
256
|
+
console.log('❌ Agent hallucinated a write. Rolled back:', result.rolledBack);
|
|
257
|
+
console.log('Errors:', result.errors);
|
|
238
258
|
}
|
|
239
259
|
```
|
|
240
260
|
|
|
261
|
+
|
|
241
262
|
---
|
|
242
263
|
|
|
243
264
|
## Architecture
|
|
@@ -246,18 +267,28 @@ if (result.verified) {
|
|
|
246
267
|
mythos-router/
|
|
247
268
|
├── src/
|
|
248
269
|
│ ├── cli.ts # Commander.js entry point
|
|
249
|
-
│ ├── config.ts # System prompt + constants + budget defaults
|
|
250
|
-
│ ├── client.ts # Anthropic SDK (adaptive thinking)
|
|
251
|
-
│ ├── budget.ts # Session budget limiter (token cap, turn cap)
|
|
252
|
-
│ ├── swd.ts #
|
|
253
|
-
│ ├──
|
|
270
|
+
│ ├── config.ts # System prompt + constants + budget defaults + validation
|
|
271
|
+
│ ├── client.ts # Anthropic SDK (adaptive thinking, streaming)
|
|
272
|
+
│ ├── budget.ts # Session budget limiter (token cap, turn cap, progress bar)
|
|
273
|
+
│ ├── swd.ts # SWD execution kernel (engine, types, parsing, snapshots)
|
|
274
|
+
│ ├── swd-cli.ts # SWD terminal presentation (verification output, dry-run)
|
|
275
|
+
│ ├── memory.ts # MEMORY.md self-healing manager (SQLite FTS5 index)
|
|
254
276
|
│ ├── metrics.ts # Global metrics store (persistent budget tracking)
|
|
255
|
-
│ ├──
|
|
277
|
+
│ ├── diff.ts # Myers' diff algorithm (zero-dependency)
|
|
278
|
+
│ ├── git.ts # Git operations (branching, committing)
|
|
279
|
+
│ ├── utils.ts # Terminal formatting, badges, prompts (zero-dep ANSI)
|
|
280
|
+
│ ├── index.ts # Public SDK exports
|
|
256
281
|
│ └── commands/
|
|
257
|
-
│ ├── chat.ts # Interactive REPL (
|
|
282
|
+
│ ├── chat.ts # Interactive REPL (ChatSession + ChatUI abstraction)
|
|
258
283
|
│ ├── verify.ts # Codebase ↔ Memory scanner (dry-run aware)
|
|
259
284
|
│ ├── dream.ts # Memory compression (dry-run aware)
|
|
260
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
|
|
261
292
|
├── test/ # Automated test suite (node:test)
|
|
262
293
|
├── .mythosignore # SWD scan exclusions
|
|
263
294
|
├── MEMORY.md # Auto-generated agentic memory
|
|
@@ -305,7 +336,9 @@ If you prefer to keep it private, add `MEMORY.md` to your `.gitignore`.
|
|
|
305
336
|
|
|
306
337
|
| Env Variable | Required | Description |
|
|
307
338
|
|-------------|----------|-------------|
|
|
308
|
-
| `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) |
|
|
309
342
|
|
|
310
343
|
| File | Purpose |
|
|
311
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;AAC5D,qCAAqC;AACrC,SAAS,kBAAkB,CAAC,GAAY;IACtC,IAAI,GAAG,KAAK,IAAI,IAAI,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AAC,EAAE,GAAG,IAAI,CAAC;QACjB,CAAC;IACH,CAAC;CACF"}
|
package/dist/cli.js
CHANGED
|
@@ -14,7 +14,7 @@ program
|
|
|
14
14
|
.name('mythos')
|
|
15
15
|
.description('Capybara-tier CLI router — Claude Opus 4.7 with Adaptive Thinking, ' +
|
|
16
16
|
'Strict Write Discipline, and Self-Healing Memory.')
|
|
17
|
-
.version('1.1
|
|
17
|
+
.version('1.2.1');
|
|
18
18
|
// ── mythos chat ──────────────────────────────────────────────
|
|
19
19
|
program
|
|
20
20
|
.command('chat')
|
|
@@ -26,6 +26,9 @@ program
|
|
|
26
26
|
.option('--dry-run', 'Preview all file operations without executing them')
|
|
27
27
|
.option('--verbose', 'Show detailed SWD traces and memory operations')
|
|
28
28
|
.option('-b, --branch <name>', 'Run session in a new git branch for sandboxed reasoning')
|
|
29
|
+
.option('-t, --test-cmd <cmd>', 'Command to run after successful SWD execution (WARNING: assumes a trusted environment and executes arbitrary shell commands)')
|
|
30
|
+
.option('--max-test-retries <n>', 'Maximum number of times Claude can attempt to fix failing tests', '3')
|
|
31
|
+
.option('-s, --skill <names...>', 'Inject specific expert skills (e.g., -s mcp -s react)')
|
|
29
32
|
.action(async (options) => {
|
|
30
33
|
await chatCommand(options);
|
|
31
34
|
});
|
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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AAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,gEAAgE,CAAC;KAC7E,MAAM,CAAC,aAAa,EAAE,mCAAmC,EAAE,KAAK,CAAC;KACjE,MAAM,CACL,WAAW,EACX,kDAAkD,CACnD;KACA,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,OAAO,CAAC;KAChB,WAAW,CAAC,uDAAuD,CAAC;KACpE,MAAM,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,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,C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