opencrowd 0.1.0 → 0.2.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.
Files changed (3) hide show
  1. package/README.md +105 -116
  2. package/bundle/opencrowd.js +43318 -15995
  3. package/package.json +4 -10
package/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
  # OpenCrowd
2
2
 
3
- **A CLI agent with its own wallet.** Give it a task and a budget; it finds paid
4
- [x402](https://www.x402.org/) services on the open market, pays for them in
5
- USDC on Base, and gets the job done — asking you before it spends on anything
6
- new, and writing every cent to a local ledger.
3
+ **A local CLI agent with its own USDC wallet.** Give it a task and a local
4
+ spend cap; it uses local tools when it can, buys external capabilities
5
+ through one enforced purchase lifecycle when it can't, and records work,
6
+ costs, receipts, and reviews on your machine.
7
7
 
8
8
  [![CI](https://github.com/sr33j/opencrowd/actions/workflows/ci.yml/badge.svg)](https://github.com/sr33j/opencrowd/actions/workflows/ci.yml)
9
9
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
10
10
 
11
- ![OpenCrowd demo: the agent asks permission, pays an x402 service, and accounts for every cent](docs/demo.gif)
11
+ ![OpenCrowd demo: the agent asks approval, pays a service, and accounts for every cent](docs/demo.gif)
12
12
 
13
13
  ## Try it in 60 seconds (no crypto required)
14
14
 
@@ -16,169 +16,158 @@ new, and writing every cent to a local ledger.
16
16
  npx opencrowd --demo
17
17
  ```
18
18
 
19
- Demo mode runs the full loop — service discovery, payment, artifacts, ledger —
20
- against a mock wallet, mock x402 services, and a mock LLM. No real money moves.
19
+ Demo mode runs the real enforced lifecycle — discovery, inspection,
20
+ reputation check, approval, payment, receipt, required review — over
21
+ in-memory mock adapters. No real money moves and nothing touches the
22
+ network.
21
23
 
22
- ## Run it for real
24
+ ## Installation and startup
23
25
 
24
26
  ```sh
25
- npx opencrowd
27
+ npm install -g opencrowd # or: npx opencrowd
28
+ opencrowd
26
29
  ```
27
30
 
31
+ The TUI renders immediately from local state; the AgentCash and CrowdCode
32
+ vendors, wallet balance, and model catalog initialize concurrently in the
33
+ background. `opencrowd doctor` diagnoses local dependencies, provider
34
+ authentication, the wallet, vendor connections, and the network explicitly.
35
+
28
36
  First launch is two steps — there is no wallet setup:
29
37
 
30
- 1. **Fund the wallet** — it already exists (created automatically, shared
31
- with the AgentCash and CrowdCode tools so everything draws one balance).
32
- Scan the QR or tap the MetaMask link to send a few dollars of USDC on
33
- Base. The wallet is the agent's entire blast radius: it can never spend
34
- more than you put in.
38
+ 1. **Fund the wallet** — it already exists (AgentCash creates it
39
+ automatically at `~/.agentcash/wallet.json`; OpenCrowd, AgentCash, and
40
+ CrowdCode all draw one balance). Scan the QR or tap the MetaMask link to
41
+ send a few dollars of USDC on Base. The wallet is the agent's entire
42
+ blast radius: it can never spend more than you put in.
35
43
  2. **Give it a task** — type what you want. The agent discovers paid
36
- x402/MPP services through its connectors, checks their CrowdCode
37
- reputation, and pays per call.
44
+ x402/MPP services, checks their CrowdCode reputation, and pays per call
45
+ through the enforced lifecycle.
38
46
 
39
47
  ```text
40
- ❯ find an x402 service that returns live weather and get today's forecast
48
+ ❯ find a service that returns live weather and get today's forecast
41
49
 
42
- → search_services query="live weather forecast"
43
- ← search_services found 7 candidates; top: WeatherStation ($0.02 USDC)
44
- $ paid $0.02 → api.weatherstation.xyz (HTTP 200) · saved forecast.json
50
+ → find_paid_service "live weather forecast"
51
+ → inspect_paid_service POST api.weatherstation.xyz/forecast
52
+ $ paid $0.02 → api.weatherstation.xyz (paid_success) · saved forecast.json
53
+ → review_paid_service rating=5
45
54
 
46
55
  Today: 72°F, clear. Full forecast saved to artifacts.
47
56
  summary: spent $0.05, remaining $19.95, services 1, artifacts 1
48
57
  ```
49
58
 
50
- The LLM itself is paid the same way: OpenCrowd uses an x402-metered,
51
- OpenAI-compatible route funded from the same wallet — no API keys, no
52
- subscriptions.
53
-
54
- ## Safety model
59
+ ## Providers
55
60
 
56
- Real money demands real guardrails. The defaults:
61
+ The default provider is the **x402 token proxy** (`x402ProxyUrl`, an
62
+ OpenAI-compatible route metered with x402 micropayments): requests pass
63
+ through unchallenged, and when the route demands payment (HTTP 402) the
64
+ challenge is signed with the shared AgentCash wallet — upto-style, so the
65
+ service settles actual usage against a quoted ceiling. No API keys, no
66
+ prepaid balance, OpenRouter-grade serving latency.
57
67
 
58
- - **`ask_first` permission mode** — the agent must show you the service URL,
59
- reason, and cost caps before its first payment to any service. Approve with
60
- one key. Shift+tab toggles to `yolo` (auto-approve) when you want speed.
61
- - **Session budgets** — default `min($20, wallet balance)`, enforced locally
62
- with reserve/finalize accounting around every paid call. Unused budget never
63
- leaves the wallet.
64
- - **Burner-wallet design** — the agent has its own low-value wallet, never
65
- your main one. Worst case is bounded by what you deposited.
66
- - **Full ledger** — every LLM call, service payment, and top-up lands in
67
- `sessions/<id>/ledger.csv` with costs, tx hashes, and artifacts.
68
- - **No telemetry** — everything stays on your machine.
68
+ **Venice** is the wallet-native backup (`opencrowd config set provider
69
+ venice` or `/provider venice`): SIWX authentication, prepaid Venice credit
70
+ topped up with USDC, at most one bounded automatic top-up per exhausted
71
+ call. **OpenRouter** direct is also available with `OPENROUTER_API_KEY`.
72
+ There is no automatic fallback between providers — switching is always an
73
+ explicit choice, and a provider failure surfaces with a remediation
74
+ message.
69
75
 
70
- Read [SECURITY.md](SECURITY.md) for the full threat model, including how we
71
- treat marketplace content as prompt-injection input.
76
+ Model preferences are per provider (`auto` resolves from the live catalog at
77
+ session start; resolved IDs are recorded on the session so `run --session`
78
+ reproduces them exactly). Change the running session with `/provider`,
79
+ `/model`, and `/submodel`; change future-session defaults with
80
+ `opencrowd config set`.
72
81
 
73
- ## Use it from Claude, Codex, or any MCP client
82
+ ## Wallet
74
83
 
75
- OpenCrowd doubles as an MCP server, so your existing coding agent can search
76
- the bazaar, make x402 payments, and manage budgets using OpenCrowd's wallet:
84
+ There is one wallet: AgentCash's. OpenCrowd shows public addresses,
85
+ balances, and funding links (`/wallet`, `/fund`) and never manages, copies,
86
+ or exports keys. See [SECURITY.md](SECURITY.md) for the enforcement model.
77
87
 
78
- ```sh
79
- claude mcp add opencrowd -- npx -y opencrowd mcp
80
- ```
88
+ ## Budget
81
89
 
82
- Or in any MCP client config:
90
+ The session budget is a local cumulative cap on value consumed — LLM
91
+ inference and paid services both count against it. Reservations are local,
92
+ a budget change never moves money, and the cap can never drop below already
93
+ finalized spend. Defaults come from configuration
94
+ (`opencrowd config set budget 20`); session creation never needs a network
95
+ lookup.
83
96
 
84
- ```json
85
- {
86
- "mcpServers": {
87
- "opencrowd": { "command": "npx", "args": ["-y", "opencrowd", "mcp"] }
88
- }
89
- }
90
- ```
97
+ ## Approval
91
98
 
92
- There's also a localhost HTTP API: `opencrowd api --port 8787`.
99
+ Approval governs external service purchases only (LLM calls are governed by
100
+ the budget):
93
101
 
94
- Here's Claude Code discovering a live weather service on the Bazaar and paying
95
- it 0.001 USDC on Base through OpenCrowd — real money, real on-chain settlement:
102
+ - `ask` (default) — a human approves each new service: allow once,
103
+ always-allow with per-call/session caps, deny, or block.
104
+ - `auto` — no prompts; blocks, caps, reputation checks, the payment
105
+ lifecycle, and the budget still apply.
106
+ - `off` — external purchases are prohibited; local tools and inference keep
107
+ working.
96
108
 
97
- ![Claude Code paying a real x402 service through the OpenCrowd MCP server](docs/mcp-demo.gif)
109
+ Stored rules are managed with `/approvals`. Every confirmed paid call —
110
+ success or failure — requires a signed CrowdCode review before the next
111
+ purchase; pending reviews survive restarts.
98
112
 
99
113
  ## Commands
100
114
 
101
- Inside the interactive UI (`/help` shows this live):
102
-
103
- | Command | What it does |
104
- | --- | --- |
105
- | `/budget <usd>` | Set the local session spend cap |
106
- | `/mode ask_first\|yolo\|blocked` | Set permission mode (shift+tab toggles) |
107
- | `/wallet list\|balance\|use\|fund\|export` | Manage the shared payment wallet |
108
- | `/models list\|set <model>` | Pick the x402 LLM model |
109
- | `/search "<query>"` | Search the x402 service bazaar |
110
- | `/permissions list\|allow\|block <url>` | Manage allowed/blocked services |
111
- | `/ledger show` | Show this session's spend ledger |
112
- | `/summary` | Spend and artifacts so far |
113
-
114
- One-shot and scripting forms:
115
+ The generated, drift-checked reference is [docs/commands.md](docs/commands.md)
116
+ (`/help` and `opencrowd --help` render the same registry). One-shot and
117
+ scripting forms:
115
118
 
116
119
  ```sh
117
120
  opencrowd run --budget 1.00 "Find a service and summarize options"
118
121
  opencrowd run --session <session-id> "Follow up on the previous result"
119
- opencrowd run --headless --prompt "..." --output json # programmatic run contract
120
- opencrowd search --json "stock price"
122
+ opencrowd config show
121
123
  opencrowd wallet balance
122
- opencrowd wallet send 0x... 5.00 --network base # send USDC anywhere (confirmed interactively)
124
+ opencrowd doctor
123
125
  opencrowd evals gaia --tier smoke --harness opencrowd,claude,codex
124
126
  ```
125
127
 
126
- `wallet send` signs a plain ERC-20 USDC transfer with the shared wallet key
127
- (the wallet needs a one-time ~$0.20 ETH deposit for gas; x402 payments stay
128
- gasless). It requires an interactive confirmation and is never retried
129
- automatically. `evals gaia` runs the GAIA validation split
130
- against OpenCrowd — and optionally Claude Code and Codex with the same prompt
131
- template and scorer — reporting accuracy and cost per question (OpenCrowd's
132
- cost is measured on-chain spend; comparators are estimates).
128
+ ## Headless runs
129
+
130
+ ```sh
131
+ opencrowd run --headless --prompt "..." --output json
132
+ ```
133
+
134
+ Headless execution never waits for UI input: the approval mode comes from
135
+ `--approval ask|auto|off` (or the configured default), and in `ask` mode
136
+ un-ruled purchases are denied with a clear error instead of hanging. The
137
+ JSON output includes the outcome, final message, spend split, turn count,
138
+ resolved model policy, artifacts, and service calls — the same contract the
139
+ eval runner uses.
133
140
 
134
141
  ## Local state
135
142
 
136
143
  | What | Where |
137
144
  | --- | --- |
138
- | Config | `~/.config/opencrowd/config.json` |
139
- | Wallet metadata | `~/.config/opencrowd/wallets.json` (no secrets) |
140
- | Seed phrases | OS credential store (Keychain on macOS) |
141
- | Service permissions | `~/.config/opencrowd/permissions.json` |
142
- | Sessions, ledger, artifacts | `./sessions/<session-id>/` |
145
+ | Config (defaults for future sessions) | `~/.config/opencrowd/config.json` |
146
+ | Wallet | `~/.agentcash/wallet.json` (owned by AgentCash; never copied) |
147
+ | Approval rules | `~/.config/opencrowd/approvals.json` |
148
+ | Sessions, conversation, ledger, artifacts | `./sessions/<session-id>/` |
149
+ | Purchase receipts (append-only) | `./sessions/<session-id>/purchases.jsonl` |
143
150
 
144
151
  Conversations persist per session and are automatically compacted when they
145
- outgrow the model's context window (archives kept under `sessions/<id>/context/`).
146
-
147
- ## Configuration notes
148
-
149
- - **Model**: defaults to `openai/gpt-5.6-sol` on an x402-metered OpenRouter
150
- route (`x402LlmBaseUrl` points at any OpenAI-compatible x402 endpoint).
151
- `opencrowd models list` then `models set <model>` to change it.
152
- - **Model policy / subagents**: `modelPolicy` in config (`{"mode": "auto"|"manual",
153
- "main": "<model>|auto", "subagent": "<model>|auto"}`) pairs the main loop
154
- with a subagent model, both paid over the same x402 route. Defaults:
155
- `openai/gpt-5.6-sol` main, `openai/gpt-5.6-luna` subagents. The main loop
156
- gets `spawn_subagent`/`check_subagents` tools (local tools only, one level
157
- deep, parallel with background mode); resolution is recorded per session
158
- for reproducibility. Auto mode refuses to run if the catalog has no
159
- frontier-tier model.
160
- - **Connectors**: paid capability comes from vendor MCP servers (AgentCash
161
- for wallet/payments, CrowdCode for reputation), configured under
162
- `mcpServers` in config with pinned versions. Their tools are ingested
163
- verbatim (`agentcash_fetch`, `crowdcode_get_service_score`, ...) and their
164
- own instructions become prompt context. When connectors are unreachable the
165
- runtime falls back to the legacy Bazaar path.
166
- - **Discovery (legacy fallback)**: Coinbase CDP Bazaar; custom bazaar URLs
167
- supported in config.
168
- - **Env overrides**: `OPENCROWD_BUDGET_CENTS`, `OPENCROWD_PERMISSION_MODE`,
169
- `OPENCROWD_SHELL_ENABLED`, `OPENCROWD_CONFIG_DIR`, `OPENCROWD_TEST_MODE`.
152
+ outgrow the model's context window (archives kept under
153
+ `sessions/<id>/context/`). `/clear` archives context while keeping the
154
+ session's spend, models, and policy; `/new` starts fresh.
170
155
 
171
156
  ## Development
172
157
 
173
158
  ```sh
174
159
  npm install
175
- npm run build
160
+ npm run typecheck
176
161
  npm test
162
+ npm run smoke # build + bundle + demo + headless smoke tests
163
+ npm run deadcode # knip: unused files, exports, dependencies
177
164
  ```
178
165
 
179
- Monorepo layout: `packages/core` (wallets, x402, sessions, budgets, ledger),
180
- `packages/agent-runtime` (LLM loop + tools + subagents), `packages/evals`
181
- (GAIA benchmark runner), `packages/mcp`, `packages/local-api`, `apps/cli`
182
- (the `opencrowd` binary and TUI).
166
+ Package layout (see [docs/architecture.md](docs/architecture.md) for the
167
+ full contract): `packages/core` (vendor-neutral sessions, budget, storage,
168
+ tool contracts), `packages/economy` (typed AgentCash/CrowdCode adapters and
169
+ the enforced purchase lifecycle), `packages/agent-runtime` (LLM loop,
170
+ providers, subagents, DI runtime), `packages/evals` (GAIA benchmark
171
+ runner), `apps/cli` (the `opencrowd` binary, TUI, and command registry).
183
172
 
184
173
  See [CONTRIBUTING.md](CONTRIBUTING.md). Licensed [MIT](LICENSE).