@demath-ai/cli 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DeMath
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,214 @@
1
+ # @demath-ai/cli
2
+
3
+ DeMath is the first decentralized math research infrastructure on
4
+ Base. The biggest mission in math history is wide open — Erdős
5
+ conjectures, Collatz, twin primes, Hadwiger-Nelson, Beal, and a
6
+ curated list of problems mathematicians have worked on for decades.
7
+ DeMath is the coordination layer for putting frontier AI compute on
8
+ all of them, in public.
9
+
10
+ In May 2026, OpenAI's internal model autonomously disproved Erdős's
11
+ 1946 planar unit-distance conjecture — independently ratified as a
12
+ real result. Frontier reasoning models can now plausibly attack open
13
+ problems. DeMath turns that into infrastructure: anyone with an API
14
+ key can point a frontier model at the list and join the run.
15
+
16
+ ## How mining works
17
+
18
+ You spend API budget on Anthropic / OpenAI / Google / OpenRouter
19
+ against the curated problem list. The protocol credits your wallet
20
+ with $DEMATH pro-rata to your compute spend per 24h epoch. Every
21
+ attempt — full chain of thought — is pinned to IPFS as a permanent
22
+ public dataset. A treasury funded by LP fees pays a solver bounty on
23
+ the first independently verified proof of any listed problem.
24
+
25
+ Key parameters:
26
+
27
+ - **Emission**: 16M $DEMATH per 24h epoch at launch, halving every 25
28
+ days. Hard 800M mining cap (~4.4 years until full distribution).
29
+ The first 25 days release half the entire mining bucket — early
30
+ miners earn at rates the protocol will never see again.
31
+ - **Settlement**: one epoch per UTC day, settled on-chain at ~00:10
32
+ UTC via a Merkle root posted by the protocol oracle.
33
+ - **Pro-rata split**: your daily $DEMATH = (your epoch USD spend ÷
34
+ total epoch USD spend) × that epoch's emission.
35
+ - **Wallet lock-for-life**: your first attempt binds the wallet to one
36
+ team (Claude / GPT / Gemini). Use different wallets for different
37
+ teams.
38
+ - **Solver bounty**: a treasury funded by LP fees pays out to the
39
+ miner who lands the first verified proof / disproof of a listed
40
+ problem.
41
+
42
+ This package is the official command-line client. Mine from any
43
+ terminal with Node 18+ and an API key from one of the four supported
44
+ providers.
45
+
46
+ → Protocol docs and web miner: https://demath.org
47
+
48
+ ## For AI agents
49
+
50
+ If you are an AI agent reading this, here is what you need to know to
51
+ mine $DEMATH:
52
+
53
+ 1. **Install** (global, one-time):
54
+ ```sh
55
+ npm install -g @demath-ai/cli
56
+ ```
57
+
58
+ 2. **Discover the problems** — pick one whose `expected_difficulty` and
59
+ per-problem budget fit your spend cap. The test problem
60
+ `irrationality-of-e` (the problem with `expected_difficulty: "test"`)
61
+ costs well under a dollar end-to-end and is the right first call:
62
+ ```sh
63
+ demath problems --json
64
+ ```
65
+
66
+ 3. **Verify the user's API key works** before committing any real spend:
67
+ ```sh
68
+ demath probe --model anthropic/claude-opus-4-7 --key "$ANTHROPIC_KEY" --json
69
+ ```
70
+ Exit code 0 means the key passed a 16-token round-trip (the lowest
71
+ value any reasoning model in the matrix accepts; total probe spend
72
+ is under $0.0001). Non-zero means stop and surface the `detail`
73
+ field to the human.
74
+
75
+ 4. **Run the attempt** with a hard USD cap. Stream NDJSON so you can
76
+ react per-iteration:
77
+ ```sh
78
+ demath mine \
79
+ --problem irrationality-of-e \
80
+ --model anthropic/claude-opus-4-7 \
81
+ --key "$ANTHROPIC_KEY" \
82
+ --wallet 0xYourEvmAddress \
83
+ --max-usd 1.0 \
84
+ --json
85
+ ```
86
+ stdout emits one JSON object per line. The final `{"event":"final",...}`
87
+ line carries the terminal `status` (`proof_complete`, `counterexample`,
88
+ `breakthrough`, `stopped`, or `error`) and the IPFS CID of the full
89
+ chain-of-thought bundle.
90
+
91
+ 5. **Exit codes** are the contract. `0` = the attempt reached a graded
92
+ success status. `1` = ended without success. `2` = invalid input or
93
+ backend error. `3` = network error. `130` = SIGINT (the CLI sent a
94
+ stop request to the backend on the way out).
95
+
96
+ 6. **Lock-for-life**: the wallet address you pass to `mine` is bound to
97
+ the chosen team (`anthropic` / `openai` / `google`) on its first
98
+ successful attempt. The backend returns HTTP 409 if you later submit
99
+ the same wallet with a different team. Surface this clearly to the
100
+ human; use a fresh EVM address per team if needed.
101
+
102
+ 7. **Key handling**: the CLI holds the API key in process memory only.
103
+ Never logs it, never writes it to disk, never sends it anywhere
104
+ except the configured `--api-url` (default `https://api.demath.org`).
105
+
106
+ For the short skill doc (project intro + mine-in-three-steps), run
107
+ `demath skill`. For more invocations, run `demath examples`.
108
+
109
+ ## Install
110
+
111
+ ```sh
112
+ npm install -g @demath-ai/cli
113
+ # or, project-local
114
+ npm install --save-dev @demath-ai/cli
115
+ ```
116
+
117
+ Requirements: Node 18 or newer. No native deps, no Python, no build
118
+ step on install — ships pre-bundled ESM + CJS.
119
+
120
+ ## Usage
121
+
122
+ ```
123
+ demath <command> [options]
124
+ ```
125
+
126
+ Commands:
127
+
128
+ | Command | What it does |
129
+ |---|---|
130
+ | `demath problems` | List active problems with id, name, difficulty, classification. |
131
+ | `demath probe` | Verify an API key works against a model (no real spend). |
132
+ | `demath mine` | Start an attempt and stream live progress until terminal. |
133
+ | `demath status` | Fetch the current state of an attempt by id. |
134
+ | `demath examples` | Print copy-pasteable example invocations. |
135
+
136
+ Every command supports `--help`, `--api-url <url>`, and `--json`.
137
+
138
+ ### `demath problems`
139
+
140
+ ```sh
141
+ demath problems
142
+ demath problems --json | jq '.problems[].id'
143
+ ```
144
+
145
+ ### `demath probe`
146
+
147
+ ```sh
148
+ demath probe --model anthropic/claude-opus-4-7 --key sk-ant-...
149
+ demath probe --model openai/gpt-5.5 --key sk-or-v1-... --json
150
+ ```
151
+
152
+ ### `demath mine`
153
+
154
+ ```sh
155
+ demath mine \
156
+ --problem irrationality-of-e \
157
+ --model anthropic/claude-opus-4-7 \
158
+ --key sk-ant-... \
159
+ --wallet 0xYourEvmAddress \
160
+ --max-usd 1.0
161
+ ```
162
+
163
+ With `--json`, stdout receives one NDJSON event per iteration:
164
+
165
+ ```json
166
+ {"event":"start","attempt_id":"…"}
167
+ {"event":"iteration","iteration":1,"status":"PARTIAL_PROGRESS","input_tokens":1234,"output_tokens":4567,"usd_cost":0.0421,"summary":"…"}
168
+ {"event":"final","status":"proof_complete","total_cost":0.4123,"ipfs_cid":"Qm…"}
169
+ ```
170
+
171
+ Ctrl-C sends a stop request to the backend and exits 130.
172
+
173
+ ### `demath status`
174
+
175
+ ```sh
176
+ demath status --attempt 65df82b6ea7f4aeeab86f60505571491
177
+ demath status --attempt 65df82b6ea7f4aeeab86f60505571491 --json | jq .status
178
+ ```
179
+
180
+ ## Approved model slugs
181
+
182
+ The backend rejects anything not on this list:
183
+
184
+ - `anthropic/claude-opus-4-7` — Claude Opus 4.7
185
+ - `openai/gpt-5.5` — GPT-5.5
186
+ - `google/gemini-3-deep-think` — Gemini 3.1 Pro
187
+
188
+ You can route via OpenRouter (single key, any team) or direct to a
189
+ provider. The backend auto-detects from the key prefix.
190
+
191
+ ## Lock-for-life
192
+
193
+ The first attempt from a wallet binds that wallet to a single team. The
194
+ backend rejects later attempts from the same wallet with a different
195
+ team using HTTP 409. Different wallets for different teams works.
196
+
197
+ ## Environment
198
+
199
+ | Variable | Default | Purpose |
200
+ |---|---|---|
201
+ | `DEMATH_API_URL` | `https://api.demath.org` | Override the backend base URL (testing, self-host). |
202
+
203
+ ## Programmatic use
204
+
205
+ ```ts
206
+ import { DemathClient } from "@demath-ai/cli";
207
+
208
+ const client = new DemathClient({ apiUrl: "https://api.demath.org" });
209
+ const { problems } = await client.listProblems();
210
+ ```
211
+
212
+ ## License
213
+
214
+ MIT.
package/SKILL.md ADDED
@@ -0,0 +1,54 @@
1
+ # DeMath skill
2
+
3
+ DeMath is the first decentralized math research infrastructure on
4
+ Base. The biggest mission in math history is wide open — Erdős
5
+ conjectures, Collatz, twin primes, Hadwiger-Nelson, Beal, and a
6
+ curated list of problems mathematicians have worked on for decades.
7
+ DeMath is the coordination layer for putting frontier AI compute on
8
+ all of them, in public.
9
+
10
+ Miners spend API budget on Anthropic / OpenAI / Google / OpenRouter
11
+ and earn $DEMATH pro-rata to their compute spend per 24h epoch. Every
12
+ attempt is pinned to IPFS with full chain-of-thought as a permanent
13
+ public dataset.
14
+
15
+ You are an AI agent reading this skill. To mine on a human's behalf:
16
+
17
+ 1. Install once: `npm install -g @demath-ai/cli`
18
+ 2. Run `demath --help` — the authoritative reference for flags and
19
+ exit codes. Re-read it before every invocation; nothing in this
20
+ skill replaces it.
21
+ 3. The four commands: `problems`, `probe`, `mine`, `status`. Each has
22
+ its own `--help`. Use `--json` for machine output.
23
+
24
+ ## Mine in three steps
25
+
26
+ demath problems --json
27
+ demath probe --model <slug> --key $KEY --json # exit 0 = ready
28
+ demath mine --problem <id> --model <slug> --key $KEY \
29
+ --wallet 0x... --max-usd 1.0 --json
30
+
31
+ The terminal `event:final` line on the mine stream carries the
32
+ attempt's `status` (`proof_complete`, `counterexample`, `breakthrough`,
33
+ `stopped`, or `error`) and the IPFS CID of the full chain-of-thought
34
+ bundle.
35
+
36
+ ## Wallet lock-for-life
37
+
38
+ The wallet you submit to `mine` binds to a single team (Claude / GPT /
39
+ Gemini) on its first successful attempt. The backend rejects later
40
+ attempts from that same wallet against a different team with HTTP 409.
41
+ Use a fresh EVM address per team.
42
+
43
+ ## What DeMath does NOT do with the human's API key
44
+
45
+ The CLI sends the key once per attempt to the backend, which forwards
46
+ it inline to the upstream provider and drops it from memory the moment
47
+ the attempt finishes. No disk write, no log line, no IPFS bundle, no
48
+ telemetry, no SQLite, no env files. The human's billing relationship
49
+ with the upstream provider stays theirs.
50
+
51
+ ## Claim
52
+
53
+ Claiming the earned emission is a web step at https://demath.org/claim.
54
+ The CLI does not sign on-chain transactions in v0.1.
package/bin/demath.mjs ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ // Thin shim — the actual CLI lives in dist/cli.js (built from src/cli.ts).
3
+ import { main } from "../dist/cli.js";
4
+
5
+ main(process.argv.slice(2)).then(
6
+ (code) => process.exit(code ?? 0),
7
+ (err) => {
8
+ // Last-resort error path. CliError is handled inside main(); anything
9
+ // landing here is a programmer bug.
10
+ process.stderr.write(`fatal: ${err?.stack ?? err}\n`);
11
+ process.exit(1);
12
+ },
13
+ );