latentcode 0.1.0-alpha.1 → 0.1.0-alpha.11
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 +65 -7
- package/dist/latentcode.mjs +2507 -676
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
Terminal coding agent that pays you for its idle time.
|
|
4
4
|
|
|
5
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.**
|
|
6
|
+
- **Earn mode.** A clearly labelled sponsored slot sits in the status dock under the input, next to your model, provider, credit balance and session earnings. It appears while the agent works and stays after the reply; a view counts after 10 s with the terminal focused (idle time counts only while you are active). You earn Latent Credit from it on your Latent wallet (the same wallet the other Latent surfaces use): $1 of model usage per credit with a bonus when you keep it — spend it on the Latent provider, or sell it for USDC on Base.
|
|
7
|
+
- **Latent provider (via Venice).** `/login` connects it: Venice models paid from your credits at Venice list price (1 credit = $1 of list usage). The model picker lists it first, then your own Venice key, your subscriptions and the rest; Latent prices read in credits per 1M tokens, and the dock shows what the session spent in credits.
|
|
8
|
+
- **Overflow.** When a subscription or key hits its usage limit and you have credit, LatentCode offers to carry on with the closest Latent model (`enter` switches and continues, `s` only switches, `esc` stays). Once per model per session; `/model` switches back.
|
|
7
9
|
- **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
|
|
10
|
+
- **Real attention.** An impression is billed once, and only after the ad has been on screen for 10 s while the terminal is focused (xterm focus events, DEC 1004) — the ad server's view floor, the same rule as every other Latent surface. A turn that ends earlier keeps the ad for the next turn instead of wasting it. Only impressions the server confirms count toward the session tally.
|
|
11
|
+
- **Clickable.** In terminals with hyperlinks (iTerm2, Ghostty, Kitty, WezTerm, VS Code, Windows Terminal) the sponsored copy itself is a link; elsewhere the short URL is shown beside it. A coloured monogram badge (stable per brand) leads the line in every terminal. `ctrl+o` works everywhere. Every click goes through the ad server's tracked redirect. `LATENTCODE_LINKS=osc8|plain|hybrid` overrides the detection.
|
|
9
12
|
|
|
10
13
|
## Install (alpha)
|
|
11
14
|
|
|
@@ -24,15 +27,45 @@ Type `/` for the command palette.
|
|
|
24
27
|
|
|
25
28
|
| Command | What it does |
|
|
26
29
|
| --- | --- |
|
|
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. |
|
|
30
|
+
| `/model [name]` | Model picker, Latent first: 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
31
|
| `/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. |
|
|
32
|
+
| `/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. The last entry, **+ Custom provider…** (or `/connect custom`), adds any OpenAI- or Anthropic-compatible endpoint — see below. |
|
|
33
|
+
| `/mcp [add …]` | MCP servers and their status. Shared with OpenCode: servers in your OpenCode config (global or the project's `opencode.json`) run here too. `enter` connects or signs in, `s` stops one for this session, `a` adds, `x` twice removes from the config. |
|
|
30
34
|
| `/login` | Connect the wallet Earn mode pays into: browser sign-in, or an address you control. |
|
|
31
35
|
| `/earn`, `/ads on\|off` | Earnings so far; Earn mode on or off. |
|
|
32
36
|
| `/new`, `/compact`, `/status`, `/help`, `/exit` | Session and app. |
|
|
33
37
|
|
|
34
38
|
The agent's own commands (`/init`, `/review`, `/goal`) are in the palette too.
|
|
35
39
|
|
|
40
|
+
### Custom providers
|
|
41
|
+
|
|
42
|
+
`/connect` → **+ Custom provider…** adds an endpoint the engine does not know by name: a self-hosted gateway, a reseller, vLLM, Ollama, LM Studio. It asks for
|
|
43
|
+
|
|
44
|
+
1. a name (shown in the model picker),
|
|
45
|
+
2. the API style — **OpenAI-compatible** (`/chat/completions`) or **Anthropic-compatible** (`/messages`),
|
|
46
|
+
3. the base URL, usually ending in `/v1`,
|
|
47
|
+
4. an API key (optional — leave empty for local servers),
|
|
48
|
+
5. the model ids, comma-separated — or leave empty to import every model from the endpoint's `/models` list.
|
|
49
|
+
|
|
50
|
+
The endpoint is written to the `providers` section of the engine's global config (`~/.config/opencode/opencode.json`, or `opencode.jsonc` if that is the one you have) and the engine reloads it without a restart. The key goes into the engine's credential store, not into the config file. Adding a provider with the same name again updates it. Then pick a model with `/model`, or start with `latentcode --model <id>/<model>`.
|
|
51
|
+
|
|
52
|
+
The same entry can be written by hand:
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"providers": {
|
|
57
|
+
"my-gateway": {
|
|
58
|
+
"name": "My Gateway",
|
|
59
|
+
"package": "@opencode/ai/providers/openai-compatible",
|
|
60
|
+
"settings": { "baseURL": "https://api.example.com/v1" },
|
|
61
|
+
"models": { "gpt-4.1": { "name": "gpt-4.1" } }
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
For an Anthropic-style endpoint the package is `@opencode/ai/providers/anthropic-compatible`.
|
|
68
|
+
|
|
36
69
|
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
70
|
|
|
38
71
|
### From the shell
|
|
@@ -43,8 +76,19 @@ latentcode login --wallet 0x… # or an address you already control
|
|
|
43
76
|
latentcode status # wallet, Earn mode, balance, engine
|
|
44
77
|
latentcode auth login # connect a provider (same as /connect)
|
|
45
78
|
latentcode auth list
|
|
79
|
+
latentcode mcp list # MCP servers and their status
|
|
80
|
+
latentcode mcp add context7 https://mcp.context7.com/mcp
|
|
81
|
+
latentcode mcp add pw -- npx -y @playwright/mcp@latest
|
|
82
|
+
latentcode mcp remove pw
|
|
83
|
+
latentcode mcp auth linear # sign in to a server that needs it
|
|
46
84
|
```
|
|
47
85
|
|
|
86
|
+
`mcp add` takes the same arguments as `opencode mcp add` (`--header k=v` for a remote server, `--env k=v` for a local one) and writes the global OpenCode config unless you pass `--project`.
|
|
87
|
+
|
|
88
|
+
### Dashboard sync
|
|
89
|
+
|
|
90
|
+
Once you have signed in (`latentcode login`), LatentCode tells latentprotocol.xyz/app/code which providers and MCP servers this machine has, so the dashboard can show them. It sends names, kinds, model counts and states only: never a key, URL, header, command or environment value. It sends once at start-up and then only when something changes. Turn it off with `"sync": false` in `~/.latent-protocol/config.json`.
|
|
91
|
+
|
|
48
92
|
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
93
|
|
|
50
94
|
### Develop
|
|
@@ -54,7 +98,21 @@ npm install && npm run build
|
|
|
54
98
|
node dist/latentcode.mjs
|
|
55
99
|
```
|
|
56
100
|
|
|
57
|
-
The engine is resolved in this order: `LATENTCODE_OPENCODE_BIN`, then the pinned `@opencode/cli` dependency, then `opencode` on PATH.
|
|
101
|
+
The engine is resolved in this order: `LATENTCODE_OPENCODE_BIN`, then the pinned `@opencode/cli` dependency, then `opencode` on PATH. An engine outside the pinned major.minor line still starts, but the start card and `latentcode status` warn about it.
|
|
102
|
+
|
|
103
|
+
### Engine upgrades
|
|
104
|
+
|
|
105
|
+
The engine is pinned to an exact `@opencode/cli` version and only changes in a LatentCode release. Before a bump, run the contract check against the new version:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
npm run build
|
|
109
|
+
npm run engine:check -- --version 2.5.0 # or --bin /path/to/opencode
|
|
110
|
+
npm run engine:check -- --model opencode/<id> # when the free models are out of quota
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
It drives LatentCode's own engine client and reducer: catalog, integrations, config reload with a custom provider, commands, MCP, and one real shell turn with the ask-before-shell rules. Exit code 0 = all good, 1 = a check failed, 2 = everything ran except the shell turn (no free model answered).
|
|
114
|
+
|
|
115
|
+
The `OpenCode watch` workflow runs this every Monday against the newest `@opencode/cli`. When a version past the pin appears it opens an `opencode-watch` issue with the result and pings Telegram, once per version. The bump itself is a normal PR.
|
|
58
116
|
|
|
59
117
|
### Develop against the mock ad server
|
|
60
118
|
|
|
@@ -73,11 +131,11 @@ latentcode (this repo) opencode serve (child process, 127.0.0.1, rand
|
|
|
73
131
|
```
|
|
74
132
|
|
|
75
133
|
- `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.
|
|
134
|
+
- `src/engine/session.ts` is a pure reducer from engine events to UI state. Tests replay a recorded opencode 2.2.0 turn; `npm run engine:check` runs a live one.
|
|
77
135
|
- `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
136
|
- `src/boot.ts` runs start-up as named steps (engine, providers, model, safety, Earn) that the start card displays.
|
|
79
137
|
- `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
|
|
138
|
+
- `src/ads/controller.ts` holds the ad lifecycle: fetch when work starts, accrue focused visible time, bill once at the 10 s view floor, rotate after 10 s, hide when idle (an un-billed ad is held for the next turn while its token is valid). `src/ads/adline.ts` is the shared line format: `Brand — body`, the tracked click link, and the OSC 8 / plain-URL choice per terminal.
|
|
81
139
|
- `src/ads/{sanitize,classify,killswitch}.ts` are ported from `latent-market/cli/src`. Keep them in sync.
|
|
82
140
|
|
|
83
141
|
## Tests
|