{
  "markdown": "# Ophir\n\nAn open protocol for AI agents to autonomously discover, negotiate, and transact with each other.\n\nAI agents collectively spend billions on API calls but operate without any commercial infrastructure. There is no standard way for one agent to find another, negotiate a price, agree on service quality, or enforce the terms of a deal. Every integration is bespoke. Every price is fixed by the provider. Every failure goes unresolved.\n\nOphir changes this. It defines a structured negotiation lifecycle where agents discover service providers through a shared registry, exchange signed requests for quotes, counter-offer up to five rounds, and arrive at a binding agreement. Agreements are dual-signed with Ed25519 and committed via SHA-256 hash. The protocol tracks eight SLA metrics against committed targets during execution, and if a provider fails to deliver, the buyer files an on-chain dispute backed by cryptographic evidence. Settlement happens through Solana escrow vaults denominated in USDC.\n\nThe protocol is transport-agnostic at its core but ships with a JSON-RPC 2.0 binding over HTTP. Identity is built on the `did:key` standard using Ed25519 public keys. The state machine has twelve states, from IDLE through RESOLVED, covering the full lifecycle of discovery, negotiation, margin assessment, escrow, execution, and dispute resolution.\n\nEverything ships as TypeScript libraries you can drop into any agent framework.\n\n## Quick Start\n\nAdd to any MCP client:\n\n```json\n{\n  \"mcpServers\": {\n    \"ophir\": {\n      \"command\": \"npx\",\n      \"args\": [\"@ophirai/mcp-server\"]\n    }\n  }\n}\n```\n\nYour agent now has tools to discover sellers, request quotes, negotiate terms, accept agreements, monitor SLAs, and file disputes.\n\nOr use the SDK directly:\n\n```bash\nnpm install @ophirai/sdk @ophirai/protocol\n```\n\n```typescript\nimport { BuyerAgent } from '@ophirai/sdk';\n\nconst buyer = new BuyerAgent({ endpoint: 'http://localhost:3001' });\nawait buyer.listen();\n\nconst session = await buyer.requestQuotes({\n  sellers: ['http://seller-a:3000'],\n  service: { category: 'inference', requirements: { model: 'llama-70b' } },\n  budget: { max_price_per_unit: '0.01', currency: 'USDC', unit: 'request' },\n  sla: { metrics: [\n    { name: 'p99_latency_ms', target: 500, comparison: 'lte' },\n    { name: 'uptime_pct', target: 99.9, comparison: 'gte' },\n  ]},\n});\n\nconst quotes = await buyer.waitForQuotes(session, { minQuotes: 1, timeout: 30_000 });\nconst best = buyer.rankQuotes(quotes, 'cheapest')[0];\nconst agreement = await buyer.acceptQuote(best);\n```\n\nOpenAI-compatible inference gateway:\n\n```bash\nnpx @ophirai/router --port 4000\n```\n\n## How It Works\n\nA buyer agent queries the **Registry** to find sellers offering the services it needs. Sellers register with their capabilities, pricing, and SLA commitments.\n\nThe buyer sends a signed **RFQ** (Request for Quote) specifying service requirements, budget constraints, and SLA targets. Sellers respond with signed quotes. Either party can counter-offer. After at most five rounds, both sides either accept or walk away.\n\nOn acceptance, both parties sign the final terms with **Ed25519**. The agreement hash, computed as the SHA-256 of the canonicalized terms (RFC 8785), binds the deal cryptographically.\n\nThe **Clearinghouse** then assesses each party's Probability of Delivery, a score derived from historical SLA performance across completed agreements. Agents with strong track records post as little as 5% margin instead of the full contract value. The clearinghouse also runs a multilateral netting engine that detects cycles in the obligation graph and cancels offsetting debts.\n\nThe buyer locks USDC in a **Solana PDA escrow vault**, with the deposit amount determined by the margin assessment. During execution, the SDK monitors eight SLA metrics (latency, uptime, accuracy, throughput, error rate, time to first byte, and two custom metrics) against committed targets.\n\nIf violations exceed the agreed threshold, the buyer files an on-chain **dispute** with arbiter co-signature. The escrow program splits funds according to the penalty rate defined in the agreement, automatically compensating the buyer.\n\n## Protocol\n\n| | |\n| --- | --- |\n| Transport | JSON-RPC 2.0 over HTTP |\n| Identity | `did:key` with Ed25519 public keys (`0xed01` multicodec prefix) |\n| Signing | Ed25519 via tweetnacl, JCS canonicalization (RFC 8785) |\n| State Machine | 12 states: IDLE, RFQ_SENT, QUOTES_RECEIVED, COUNTERING, ACCEPTED, MARGIN_ASSESSED, ESCROWED, ACTIVE, COMPLETED, REJECTED, DISPUTED, RESOLVED |\n| Settlement | Solana Anchor program with PDA-derived USDC escrow vaults |\n| Messages | RFQ, Quote, Counter, Accept, Reject, Dispute |\n\nAll messages are signed and verified. Replay protection uses time-windowed message ID deduplication.\n\n## Packages\n\n| Package | Description |\n| --- | --- |\n| [`@ophirai/protocol`](packages/protocol) | Core types, Zod schemas, 12-state FSM, SLA metrics, error codes |\n| [`@ophirai/sdk`](packages/sdk) | BuyerAgent, SellerAgent, Ed25519 signing, did:key identity, escrow |\n| [`@ophirai/clearinghouse`](packages/clearinghouse) | Multilateral netting, fractional margin, Probability of Delivery scoring |\n| [`@ophirai/registry`](packages/registry) | Agent discovery with rate limiting, authentication, reputation |\n| [`@ophirai/mcp-server`](packages/mcp-server) | MCP tools for LLM-powered agents |\n| [`@ophirai/router`](packages/router) | OpenAI-compatible inference gateway with automatic negotiation |\n| [`@ophirai/providers`](packages/providers) | AI inference provider wrappers (OpenAI, Anthropic, Together, Groq, OpenRouter, Replicate) |\n| [`@ophirai/openai-adapter`](packages/openai-adapter) | OpenAI function calling adapter |\n| [`escrow`](packages/escrow) | Solana Anchor program for USDC escrow with arbiter disputes |\n\n## Specifications\n\n| Document | |\n| --- | --- |\n| [Protocol Specification](packages/docs/protocol/specification.md) | Full protocol reference |\n| [State Machine](packages/docs/protocol/state-machine.md) | Negotiation state transitions and guards |\n| [Security Model](packages/docs/concepts/security.md) | Cryptographic layers, threat model, replay protection |\n| [SLA Schema](packages/docs/concepts/sla-schema.md) | Metric definitions, comparison operators, penalty calculation |\n| [Escrow Lifecycle](packages/docs/concepts/escrow.md) | Deposit, release, dispute, and arbiter flows |\n| [Identity](packages/docs/concepts/identity.md) | did:key derivation, key management, agent authentication |\n\n## Development\n\n```bash\nnpm install\nnpx turbo build\nnpx turbo test\n```\n\nBuild order is managed by Turborepo. The `protocol` package builds first, then `sdk`, then everything else.\n\n## License\n\nMIT\n",
  "bytes": 6700,
  "sha": "4d0a4a57d03f2b06c105bafd75b105e7f4385e67a7bbae9c22be9df2c0b408e8",
  "repo_slug": "ophir-protocol/ophir",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_ophir_ai_creator_ophir_77d32e95/readme"
}