latentcode 0.0.0-stage → 0.1.0-alpha.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 +73 -2
  2. package/dist/latentcode.mjs +35947 -0
  3. package/package.json +44 -4
package/README.md CHANGED
@@ -1,3 +1,74 @@
1
- # Temporary Holding Version
1
+ # LatentCode
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Terminal coding agent that pays you for its idle time.
4
+
5
+ - **Bring your own model access.** API keys or a provider subscription where the provider allows third-party clients. Connect them with `latentcode auth login`.
6
+ - **Earn mode.** While the agent works, one clearly labelled sponsored line sits in the working bar. You earn USDC from it on your Latent wallet, the same wallet the other Latent surfaces use.
7
+ - **The model is never for sale.** Ads never enter the model's context or output, and the agent never recommends sponsored tools. The only targeting signal that leaves your machine is a coarse category slug (for example `backend`), classified locally.
8
+ - **Real attention.** An impression is billed once, and only after the ad has been on screen for 2 s while the terminal is focused (xterm focus events, DEC 1004).
9
+
10
+ ## Install (alpha)
11
+
12
+ Requires Node ≥ 20. The opencode engine comes with the package. It is pinned to the version LatentCode is tested against, so nothing else needs installing.
13
+
14
+ ```bash
15
+ npx latentcode # or: npm i -g latentcode && latentcode
16
+ latentcode [project-dir] [--model provider/id] [--no-ads] [--auto]
17
+ ```
18
+
19
+ Connect a model provider (API key or a subscription):
20
+
21
+ ```bash
22
+ latentcode auth login
23
+ latentcode auth list
24
+ ```
25
+
26
+ Connect a wallet once:
27
+
28
+ ```bash
29
+ latentcode login # auth link → sign in in the browser → your Latent wallet
30
+ latentcode login --wallet 0x… # or an address you already control
31
+ latentcode status # wallet, Earn mode, balance, engine
32
+ ```
33
+
34
+ The wallet lives in `~/.latent-protocol/config.json`, shared with the other Latent surfaces. A wallet set up with `npx latent-protocol init` works as is.
35
+
36
+ Inside the app: `/help`, `/model`, `/ads on|off`, `/earn`, `/new`, `/exit`. Press `esc` to interrupt and `ctrl+o` to open the sponsored link.
37
+
38
+ ### Develop
39
+
40
+ ```bash
41
+ npm install && npm run build
42
+ node dist/latentcode.mjs
43
+ ```
44
+
45
+ The engine is resolved in this order: `LATENTCODE_OPENCODE_BIN`, then the pinned `@opencode/cli` dependency, then `opencode` on PATH.
46
+
47
+ ### Develop against the mock ad server
48
+
49
+ ```bash
50
+ node ../latent-market/tools/mock-ad-server.mjs --port=8898
51
+ LATENTCODE_ADS_SERVER=http://127.0.0.1:8898 node dist/latentcode.mjs
52
+ ```
53
+
54
+ ## Architecture
55
+
56
+ ```
57
+ latentcode (this repo) opencode serve (child process, 127.0.0.1, random password)
58
+ ├─ ui/ Ink TUI ◄─SSE── /api/event session.* / permission.* events
59
+ ├─ engine/ server + reducer ──► /api/session/* prompt, interrupt, model, permission reply
60
+ └─ ads/ Earn runtime ──► Latent ad server (/ad/request, /ad/impression, /ad/click)
61
+ ```
62
+
63
+ - `src/engine/server.ts` starts a private `opencode serve` for each run. It is never the user's background service.
64
+ - `src/engine/session.ts` is a pure reducer from engine events to UI state. Tests replay a recorded opencode 2.2.0 turn.
65
+ - `src/ads/controller.ts` holds the ad lifecycle: fetch when work starts, accrue focused visible time, bill once, rotate after 30 s, hide when idle.
66
+ - `src/ads/{sanitize,classify,killswitch}.ts` are ported from `latent-market/cli/src`. Keep them in sync.
67
+
68
+ ## Tests
69
+
70
+ ```bash
71
+ npm run build && npm test
72
+ ```
73
+
74
+ The engine is opencode (MIT, © opencode contributors), run as a separate process. LatentCode is not built by or affiliated with the opencode team.