latentcode 0.0.0-stage → 0.1.0-alpha.1
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/README.md +88 -2
- package/dist/latentcode.mjs +38210 -0
- package/package.json +44 -4
package/README.md
CHANGED
|
@@ -1,3 +1,89 @@
|
|
|
1
|
-
#
|
|
1
|
+
# LatentCode
|
|
2
2
|
|
|
3
|
-
|
|
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 inside the app with `/connect`.
|
|
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
|
+
The start card shows what you are running before you type anything: the engine, the connected providers, the model, whether it asks before acting, and whether you are earning.
|
|
20
|
+
|
|
21
|
+
### Inside the app
|
|
22
|
+
|
|
23
|
+
Type `/` for the command palette.
|
|
24
|
+
|
|
25
|
+
| Command | What it does |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| `/model [name]` | Model picker: search across every provider, `tab` to filter by provider, `←` `→` to set the effort level, `ctrl+t` to test a model with your account. `✓` marks models proven to work with your account. |
|
|
28
|
+
| `/providers` | Connected providers, how each is connected (account sign-in, API key, env var, built in) and how many models it offers. |
|
|
29
|
+
| `/connect [provider]` | Connect a provider without leaving the app: paste an API key or sign in through the browser. Credentials are stored by the local engine. |
|
|
30
|
+
| `/login` | Connect the wallet Earn mode pays into: browser sign-in, or an address you control. |
|
|
31
|
+
| `/earn`, `/ads on\|off` | Earnings so far; Earn mode on or off. |
|
|
32
|
+
| `/new`, `/compact`, `/status`, `/help`, `/exit` | Session and app. |
|
|
33
|
+
|
|
34
|
+
The agent's own commands (`/init`, `/review`, `/goal`) are in the palette too.
|
|
35
|
+
|
|
36
|
+
Keys: `esc` interrupts, `↑` `↓` recall earlier prompts, `ctrl+a` / `ctrl+e` and `alt+←` / `alt+→` move in the line, `ctrl+o` opens the sponsored link, `ctrl+c` twice quits. Pasted text keeps its line breaks.
|
|
37
|
+
|
|
38
|
+
### From the shell
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
latentcode login # auth link → sign in in the browser → your Latent wallet
|
|
42
|
+
latentcode login --wallet 0x… # or an address you already control
|
|
43
|
+
latentcode status # wallet, Earn mode, balance, engine
|
|
44
|
+
latentcode auth login # connect a provider (same as /connect)
|
|
45
|
+
latentcode auth list
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
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.
|
|
49
|
+
|
|
50
|
+
### Develop
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm install && npm run build
|
|
54
|
+
node dist/latentcode.mjs
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The engine is resolved in this order: `LATENTCODE_OPENCODE_BIN`, then the pinned `@opencode/cli` dependency, then `opencode` on PATH.
|
|
58
|
+
|
|
59
|
+
### Develop against the mock ad server
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
node ../latent-market/tools/mock-ad-server.mjs --port=8898
|
|
63
|
+
LATENTCODE_ADS_SERVER=http://127.0.0.1:8898 node dist/latentcode.mjs
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Architecture
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
latentcode (this repo) opencode serve (child process, 127.0.0.1, random password)
|
|
70
|
+
├─ ui/ Ink TUI ◄─SSE── /api/event session.* / permission.* events
|
|
71
|
+
├─ engine/ server + reducer ──► /api/session/* prompt, interrupt, model, permission reply
|
|
72
|
+
└─ ads/ Earn runtime ──► Latent ad server (/ad/request, /ad/impression, /ad/click)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
- `src/engine/server.ts` starts a private `opencode serve` for each run. It is never the user's background service.
|
|
76
|
+
- `src/engine/session.ts` is a pure reducer from engine events to UI state. Tests replay a recorded opencode 2.2.0 turn.
|
|
77
|
+
- `src/engine/catalog.ts` turns the engine's flat provider and model lists into what the picker shows: providers with a plain connection label, models with size, price and effort levels.
|
|
78
|
+
- `src/boot.ts` runs start-up as named steps (engine, providers, model, safety, Earn) that the start card displays.
|
|
79
|
+
- `src/ui/` is the Ink TUI: `App.tsx` (transcript, prompt, palette, status line), `panels/` (model picker, providers and connect, wallet), and the pure helpers `editor.ts`, `markdown.ts`, `commands.ts`, `stdin.ts`.
|
|
80
|
+
- `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.
|
|
81
|
+
- `src/ads/{sanitize,classify,killswitch}.ts` are ported from `latent-market/cli/src`. Keep them in sync.
|
|
82
|
+
|
|
83
|
+
## Tests
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npm run build && npm test
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The engine is opencode (MIT, © opencode contributors), run as a separate process. LatentCode is not built by or affiliated with the opencode team.
|