Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f0ae147
Update index.ts
benp055424 Mar 17, 2026
1fcd9b8
Merge branch 'Handshake58:main' into main
benp055424 Mar 17, 2026
de51192
Add hs58-orchestra provider
Mar 23, 2026
19ece08
Update index.ts
benp055424 Mar 24, 2026
321c8f2
Update index.ts
benp055424 Mar 24, 2026
45c8c62
Update index.ts
benp055424 Mar 24, 2026
b10f6b2
Update index.ts
benp055424 Mar 24, 2026
7bbe3ec
Add community-mozart provider
benp055424 Mar 26, 2026
4a81ac9
Add community-mozart provider
benp055424 Mar 26, 2026
02b0627
Add community-mozart provider
benp055424 Mar 26, 2026
6aaa79c
Add community-mozart provider
benp055424 Mar 26, 2026
e0a364b
Add community-mozart provider
benp055424 Mar 26, 2026
3cae259
Add community-mozart provider
benp055424 Mar 26, 2026
f3255fd
Add community-mozart provider
benp055424 Mar 26, 2026
c758c1b
Add community-mozart provider
benp055424 Mar 26, 2026
7524a53
Add community-mozart provider
benp055424 Mar 26, 2026
558f0eb
Add community-mozart provider
benp055424 Mar 26, 2026
e42e87d
Add community-mozart provider
benp055424 Mar 26, 2026
0066145
Add community-mozart provider
benp055424 Mar 26, 2026
ab90292
Add community-mozart provider
benp055424 Mar 26, 2026
5567635
Make OPENROUTER_API_KEY optional
benp055424 Mar 26, 2026
ee784ee
Make OPENROUTER_API_KEY optional
benp055424 Mar 26, 2026
fa74856
Mark OPENROUTER_API_KEY as optional
benp055424 Mar 26, 2026
77a3ceb
Add missing constants: UPSTREAM, PROVIDER_COST_ESTIMATES, prompts
benp055424 Mar 26, 2026
f8d6f6b
Add openai dependency
benp055424 Mar 26, 2026
469cdfe
Fix TS build errors
benp055424 Mar 26, 2026
a28ea29
Fix TS build errors
benp055424 Mar 26, 2026
f09db30
fix: align /health and /v1/models response format with HS58 validator
Mar 26, 2026
f3dde0c
fix: add models field to /v1/pricing for HS58 marketplace validation
Mar 26, 2026
ea93693
fix: align /v1/pricing model keys to skill spec (inputPer1kTokens/out…
Mar 26, 2026
2da452f
fix(community-mozart): update Chutes model names to -TEE variants, ha…
Mar 30, 2026
f500c50
fix(orchestra): correct Chutes model ID in planner prompt to DeepSeek…
Mar 30, 2026
6605b9d
fix(orchestra): update env.example model names to -TEE variants
Mar 30, 2026
ab76b8d
fix(orchestra): remove openrouter from planner, add fallback to chute…
Mar 30, 2026
59e322f
fix(orchestra): replace OpenAI SDK in planner with raw fetch to fix 4…
Mar 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions providers/community-mozart/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
dist/
.env
*.log
package-lock.json
data/
59 changes: 59 additions & 0 deletions providers/community-mozart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# community-mozart

> Multi-provider AI orchestration for Handshake58.

The only AI orchestration layer on Handshake58. Send one goal in plain English — Mozart plans it, routes it across the optimal mix of Bittensor-native and external providers, and returns one synthesized answer. Pay once for the whole workflow.

**Bittensor-native providers get priority:** Chutes (SN22), Desearch (SN22), Numinous (SN6), Vericore.

## Models

| Model ID | Description |
|---|---|
| `mozart/auto` | Full auto-orchestration — planner decides everything |
| `mozart/plan` | Dry-run — returns the execution plan without running |
| `mozart/pipeline` | User-defined DAG pipeline — full control over steps |

## Quick Start

```bash
cp env.example .env
# fill in your keys
npm install && npm run dev
```

## Deploy on Railway

1. Fork or clone this directory into your repo
2. Create a new Railway service, connect your repo
3. Set root directory to `/community-mozart`
4. Add environment variables from `env.example`
5. Add a Railway Volume at `/app/data` (required for voucher persistence)
6. Deploy

## Example Request

```json
{
"mode": "auto",
"goal": "Find the latest news on Bittensor dTAO and write a concise briefing",
"budget_usd": 0.15
}
```

Send as the `content` of a user message to `POST /v1/chat/completions` with `model: "mozart/auto"` and an `X-DRAIN-Voucher` header.

## Endpoints

| Endpoint | Description |
|---|---|
| `GET /health` | Service health + provider address |
| `GET /v1/models` | List available models |
| `GET /v1/pricing` | Pricing details |
| `GET /v1/docs` | Full agent instructions (plain text) |
| `POST /v1/chat/completions` | Main inference endpoint |
| `POST /v1/admin/claim` | Manual USDC claim trigger |

## Contact

mozartorchestra@proton.com
31 changes: 31 additions & 0 deletions providers/community-mozart/env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# === REQUIRED ===
PROVIDER_PRIVATE_KEY=0xYOUR_POLYGON_PRIVATE_KEY
# OPENROUTER_API_KEY= # optional — Chutes is primary LLM
DESEARCH_API_KEY=your-desearch-key
CHUTES_API_KEY=your-chutes-key

# === OPTIONAL UPSTREAM ===
E2B_API_KEY=
REPLICATE_API_TOKEN=

# === DRAIN / BLOCKCHAIN ===
POLYGON_RPC_URL=https://polygon-mainnet.g.alchemy.com/v2/YOUR_KEY
CHAIN_ID=137
CLAIM_THRESHOLD=10000000
AUTO_CLAIM_INTERVAL_MINUTES=10
AUTO_CLAIM_BUFFER_SECONDS=3600
STORAGE_PATH=./data/vouchers.json

# === SERVER ===
PORT=3000
HOST=0.0.0.0
PROVIDER_NAME=Mozart

# === PRICING ===
MARKUP_PERCENT=30

# === OPTIONAL ===
ADMIN_PASSWORD=
MAX_PLAN_STEPS=6
PLANNER_MODEL=deepseek-ai/DeepSeek-V3-0324-TEE
SYNTHESIZER_MODEL=deepseek-ai/DeepSeek-V3-0324-TEE
28 changes: 28 additions & 0 deletions providers/community-mozart/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@handshake58/community-mozart",
"version": "0.1.0",
"description": "Multi-provider AI orchestration for Handshake58. Send a goal, Mozart plans and executes it across Bittensor-native and external providers.",
"type": "module",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"start": "node dist/index.js",
"dev": "tsx watch src/index.ts"
},
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.0.0",
"express": "^4.18.0",
"openai": "^4.0.0",
"viem": "^2.0.0"
},
"devDependencies": {
"@types/cors": "^2.8.0",
"@types/express": "^4.17.0",
"tsx": "^4.0.0",
"typescript": "^5.0.0"
},
"keywords": ["bittensor", "handshake58", "drain", "orchestration", "ai"],
"author": "mozartorchestra@proton.com",
"license": "MIT"
}
14 changes: 14 additions & 0 deletions providers/community-mozart/railway.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "npm install && npm run build"
},
"deploy": {
"startCommand": "npm start",
"healthcheckPath": "/health",
"healthcheckTimeout": 30,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 3
}
}
159 changes: 159 additions & 0 deletions providers/community-mozart/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
// ─── DRAIN protocol constants (DO NOT MODIFY) ────────────────────────────────

export const DRAIN_ADDRESSES: Record<number, string> = {
137: '0x0C2B3aA1e80629D572b1f200e6DF3586B3946A8A',
80002: '0x61f1C1E04d6Da1C92D0aF1a3d7Dc0fEFc8794d7C',
};

export const USDC_DECIMALS = 6;

export const EIP712_DOMAIN = {
name: 'DrainChannel',
version: '1',
} as const;

export const DRAIN_CHANNEL_ABI = [
{
inputs: [{ name: 'channelId', type: 'bytes32' }],
name: 'getChannel',
outputs: [{
components: [
{ name: 'consumer', type: 'address' },
{ name: 'provider', type: 'address' },
{ name: 'deposit', type: 'uint256' },
{ name: 'claimed', type: 'uint256' },
{ name: 'expiry', type: 'uint256' },
],
name: '', type: 'tuple',
}],
stateMutability: 'view',
type: 'function',
},
{
inputs: [{ name: 'channelId', type: 'bytes32' }],
name: 'getBalance',
outputs: [{ name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{ name: 'channelId', type: 'bytes32' },
{ name: 'amount', type: 'uint256' },
{ name: 'nonce', type: 'uint256' },
{ name: 'signature', type: 'bytes' },
],
name: 'claim',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{ name: 'channelId', type: 'bytes32' },
{ name: 'finalAmount', type: 'uint256' },
{ name: 'providerSignature', type: 'bytes' },
],
name: 'cooperativeClose',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{ inputs: [], name: 'InvalidAmount', type: 'error' },
{ inputs: [], name: 'ChannelNotFound', type: 'error' },
{ inputs: [], name: 'InvalidSignature', type: 'error' },
{ inputs: [], name: 'NotProvider', type: 'error' },
{ inputs: [], name: 'NotExpired', type: 'error' },
{
anonymous: false,
inputs: [
{ indexed: true, name: 'channelId', type: 'bytes32' },
{ indexed: true, name: 'provider', type: 'address' },
{ indexed: false, name: 'amount', type: 'uint256' },
],
name: 'ChannelClaimed',
type: 'event',
},
] as const;

export const PERMANENT_CLAIM_ERRORS = [
'InvalidAmount',
'ChannelNotFound',
'InvalidSignature',
'NotProvider',
'NotExpired',
] as const;

// ─── Mozart pricing ───────────────────────────────────────────────────────────

export const MOZART_BASE_FEE_USDC = 5_000n; // $0.005 per orchestration
export const MOZART_PLAN_FEE_USDC = 10_000n; // $0.010 for plan-only

// ─── Upstream provider base URLs ──────────────────────────────────────────────

export const UPSTREAM = {
chutes: { base: 'https://llm.chutes.ai/v1' },
openrouter: { base: 'https://openrouter.ai/api/v1' },
desearch: { base: 'https://api.desearch.ai' },
numinous: { base: 'https://api.numinous.ai', forecast: 'https://api.numinous.ai/v1/predictions' },
vericore: { base: 'https://api.vericore.ai' },
e2b: { base: 'https://api.e2b.dev' },
replicate: { base: 'https://api.replicate.com/v1' },
} as const;

// ─── Per-provider cost estimates (USDC micro, 6 decimals) ─────────────────────

export const PROVIDER_COST_ESTIMATES: Record<string, bigint> = {
chutes: 20_000n, // $0.020
openrouter: 30_000n, // $0.030
desearch: 5_000n, // $0.005
numinous: 10_000n, // $0.010
vericore: 5_000n, // $0.005
e2b: 50_000n, // $0.050
replicate: 40_000n, // $0.040
};

// ─── Planner system prompt ────────────────────────────────────────────────────

export const PLANNER_SYSTEM_PROMPT = `You are an AI orchestration planner. Given a user goal, produce a minimal JSON execution plan.

Return ONLY valid JSON matching this schema (no markdown, no explanation):
{
"goal": "<goal>",
"reasoning": "<why this plan>",
"estimated_total_cost_usd": <number>,
"steps": [
{
"id": "step_1",
"provider": "chutes" | "desearch" | "numinous" | "vericore" | "e2b" | "replicate",
"model": "<model id or task>",
"task": "<specific instruction for this step>",
"input_from": ["step_id", ...],
"parallel": true,
"required": true,
"estimated_cost_usd": <number>
}
]
}

Rules:
- Use chutes for LLM tasks (model: "deepseek-ai/DeepSeek-V3-0324-TEE")
- Use desearch for web search, news, Twitter queries
- Use numinous for forecasting/prediction tasks
- Use vericore for fact-checking
- ONLY use providers: chutes, desearch, numinous, vericore, e2b, replicate
- NEVER use openrouter — it is not available
- Keep plans minimal — 1-4 steps for most goals
- Set input_from to depend on prior step IDs when output chaining is needed
- parallel: true means this step can run in parallel with other same-wave steps`;

// ─── Synthesizer system prompt ────────────────────────────────────────────────

export const SYNTHESIZER_SYSTEM_PROMPT = `You are a synthesis AI. You receive outputs from multiple AI agents that each worked on part of a goal.
Your job is to merge their outputs into one clean, comprehensive answer.

- Integrate all relevant information naturally
- Resolve any contradictions by noting them
- Keep the response focused on the original goal
- Write in clear, direct prose
- Do not mention the internal step structure or provider names`;
Loading