@kognai/clawrouter-x402 0.1.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/LICENSE +12 -0
- package/dist/clawrouter-x402/src/clawrouter-v2.d.ts +87 -0
- package/dist/clawrouter-x402/src/clawrouter-v2.js +811 -0
- package/dist/clawrouter-x402/src/index.d.ts +21 -0
- package/dist/clawrouter-x402/src/index.js +45 -0
- package/dist/orchestrator-core/src/lib/acp.d.ts +61 -0
- package/dist/orchestrator-core/src/lib/acp.js +425 -0
- package/dist/orchestrator-core/src/lib/engine-paths.d.ts +13 -0
- package/dist/orchestrator-core/src/lib/engine-paths.js +32 -0
- package/dist/orchestrator-core/src/lib/model-router-contract.d.ts +91 -0
- package/dist/orchestrator-core/src/lib/model-router-contract.js +19 -0
- package/dist/orchestrator-core/src/lib/wallet-state.d.ts +26 -0
- package/dist/orchestrator-core/src/lib/wallet-state.js +85 -0
- package/package.json +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Copyright (c) 2026 Kognai / SkinGem. All rights reserved.
|
|
2
|
+
|
|
3
|
+
PROPRIETARY AND CONFIDENTIAL
|
|
4
|
+
|
|
5
|
+
This software and its source code are the exclusive property of Kognai / SkinGem.
|
|
6
|
+
Unauthorized copying, distribution, modification, sublicensing, or use of this
|
|
7
|
+
software, in whole or in part, is strictly prohibited without the express prior
|
|
8
|
+
written permission of Kognai / SkinGem.
|
|
9
|
+
|
|
10
|
+
This software is provided to authorized parties solely for use within the Kognai
|
|
11
|
+
ecosystem. Any use outside of this scope requires a separate written agreement
|
|
12
|
+
with Kognai / SkinGem.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* clawrouter-v2.ts — ClawRouter Universal LLM Gateway v2.0
|
|
3
|
+
*
|
|
4
|
+
* THE SINGLE DOOR every LLM call passes through (ClawRouter Spec v2.0).
|
|
5
|
+
* Execution Protocol Section 17: ClawRouter Mandatory Gateway Rule.
|
|
6
|
+
*
|
|
7
|
+
* Routing Matrix:
|
|
8
|
+
* T0 NANO → qwen3:0.6b (local) — classification, templating
|
|
9
|
+
* T1 LOCAL → qwen3:4b (local) — QA, supervision, aggregation
|
|
10
|
+
* T2 POWER → qwen3:14b (local) — primary execution engine
|
|
11
|
+
* T2.5 EXEC → Gemini Flash (API) — cloud-quality, no constitutional
|
|
12
|
+
* T3 APEX → Claude Sonnet (API) — constitutional judge only
|
|
13
|
+
*
|
|
14
|
+
* Rules:
|
|
15
|
+
* - constitutional_flag=true → always T3 APEX
|
|
16
|
+
* - Local tiers (T0/T1/T2) → Ollama direct ($0)
|
|
17
|
+
* - Cloud tiers (T2.5/T3) → OpenClaw gateway at :18789
|
|
18
|
+
* - QCG pre-compression for cloud tiers when context > 5000 tokens
|
|
19
|
+
* - NO agent holds API keys — keys only in ClawRouter/.env
|
|
20
|
+
*
|
|
21
|
+
* @see ~/Documents/Kognai/Master Documents/clawrouter_spec_v2.docx
|
|
22
|
+
* @see ~/Documents/Kognai/Master Documents/execution_protocol_sections_17_18.docx
|
|
23
|
+
*/
|
|
24
|
+
import type { TierClass, TextComplexity, CreativeModality, CreativeQuality, ClawRouterV2Request, ClawRouterV2Response } from '../../orchestrator-core/src/lib/model-router-contract';
|
|
25
|
+
export type { TierClass, TextComplexity, CreativeModality, CreativeQuality, ClawRouterV2Request, ClawRouterV2Response, };
|
|
26
|
+
interface CostLogEntry {
|
|
27
|
+
timestamp: string;
|
|
28
|
+
agent_id: string;
|
|
29
|
+
task_type: string;
|
|
30
|
+
tier: string;
|
|
31
|
+
model: string;
|
|
32
|
+
local: boolean;
|
|
33
|
+
cost_usd: number;
|
|
34
|
+
input_tokens: number;
|
|
35
|
+
output_tokens: number;
|
|
36
|
+
qcg_compressed: boolean;
|
|
37
|
+
tokens_saved: number;
|
|
38
|
+
}
|
|
39
|
+
export declare function getCostLog(): readonly CostLogEntry[];
|
|
40
|
+
export declare function getDailyCostDigest(): {
|
|
41
|
+
total_usd: number;
|
|
42
|
+
by_tier: Record<string, number>;
|
|
43
|
+
by_agent: Record<string, number>;
|
|
44
|
+
tokens_saved_by_qcg: number;
|
|
45
|
+
call_count: number;
|
|
46
|
+
};
|
|
47
|
+
export declare function getMeterStats(): {
|
|
48
|
+
recipient: `0x${string}`;
|
|
49
|
+
enabled: boolean;
|
|
50
|
+
settled: number;
|
|
51
|
+
failed: number;
|
|
52
|
+
totalAtomicSettled: number;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Route an LLM call through ClawRouter v2.0.
|
|
56
|
+
* This is the ONLY function any agent should call for LLM inference.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* const result = await routeCall({
|
|
60
|
+
* task_type: 'code_review',
|
|
61
|
+
* tier_class: 'text',
|
|
62
|
+
* complexity: 'power',
|
|
63
|
+
* context_tokens: 3000,
|
|
64
|
+
* constitutional_flag: false,
|
|
65
|
+
* agent_id: 'cto-agent',
|
|
66
|
+
* payload: { system: '...', prompt: '...' }
|
|
67
|
+
* });
|
|
68
|
+
*/
|
|
69
|
+
export declare function routeCall(req: ClawRouterV2Request): Promise<ClawRouterV2Response>;
|
|
70
|
+
export declare function callLLM(prompt: string, opts?: {
|
|
71
|
+
systemPrompt?: string;
|
|
72
|
+
complexity?: TextComplexity;
|
|
73
|
+
constitutional?: boolean;
|
|
74
|
+
agentId?: string;
|
|
75
|
+
taskType?: string;
|
|
76
|
+
maxTokens?: number;
|
|
77
|
+
}): Promise<{
|
|
78
|
+
content: string;
|
|
79
|
+
model: string;
|
|
80
|
+
tier: string;
|
|
81
|
+
cost_usd: number;
|
|
82
|
+
}>;
|
|
83
|
+
export declare function clawRouterHealthCheck(): Promise<{
|
|
84
|
+
ollama: boolean;
|
|
85
|
+
gateway: boolean;
|
|
86
|
+
models: string[];
|
|
87
|
+
}>;
|