clusterchat 0.0.0-stage → 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.
Files changed (3) hide show
  1. package/README.md +109 -2
  2. package/dist/clusterchat.js +10924 -0
  3. package/package.json +21 -4
package/README.md CHANGED
@@ -1,3 +1,110 @@
1
- # Temporary Holding Version
1
+ # clusterchat
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
+ Use a [ClusterChat](https://clusterchat.io) cluster from Claude Code, opencode and
4
+ other coding agents. `clusterchat connect` joins a cluster as a chat-only peer
5
+ (no GPU needed) and serves the Anthropic and OpenAI APIs on localhost, so your
6
+ agent runs on the open model your group's GPUs are serving.
7
+
8
+ ```bash
9
+ npm install -g clusterchat
10
+ clusterchat connect 'https://clusterchat.io/chat#mesh=<code>&model=qwen3.5-4b'
11
+ ```
12
+
13
+ Copy the invite link from the cluster's page (Invite → the command is shown
14
+ there too). **Keep it in quotes**: unquoted, the shell cuts it at `&` and you
15
+ join a different, empty cluster. `connect` prints which cluster it joined and
16
+ how many GPUs serve it, so a wrong link shows up straight away.
17
+
18
+ For the public demo, say so explicitly. The GPUs serving the demo belong to
19
+ strangers, and they see your prompts, so don't send them private code:
20
+
21
+ ```bash
22
+ clusterchat connect demo
23
+ ```
24
+
25
+ Needs Node 18 or newer. Options: `--port` (4747), `--host` (127.0.0.1).
26
+
27
+ ## Point your agent at it
28
+
29
+ `connect` prints these lines with the cluster's model filled in.
30
+ `clusterchat setup <tool>` prints one of them again while `connect` is running.
31
+
32
+ **Claude Code**
33
+
34
+ ```bash
35
+ ANTHROPIC_BASE_URL=http://127.0.0.1:4747 ANTHROPIC_AUTH_TOKEN=clusterchat \
36
+ ANTHROPIC_MODEL=qwen3.5-4b ANTHROPIC_SMALL_FAST_MODEL=qwen3.5-4b claude
37
+ ```
38
+
39
+ **opencode**: put the provider in `opencode.json` (in your project, or
40
+ `~/.config/opencode/opencode.json`). It makes the cluster's model the default;
41
+ `/models` switches back and forth:
42
+
43
+ ```bash
44
+ clusterchat setup opencode > opencode.json
45
+ ```
46
+
47
+ Anything else that speaks the OpenAI Chat Completions API can use
48
+ `http://127.0.0.1:4747/v1`.
49
+
50
+ ## What to expect
51
+
52
+ - **Context.** Claude Code's system prompt and tool definitions are about 20K
53
+ tokens. Use a cluster created with a 32K context; a smaller one refuses the
54
+ first request as too long. opencode needs less.
55
+ - **The first request is slow, the rest aren't.** Agents resend the whole
56
+ conversation every time. The client remembers the last few chats it ran,
57
+ and a request that continues one feeds only its new messages, so only the
58
+ first request prefills the system prompt.
59
+ - **One request at a time.** Concurrent requests queue.
60
+ - **Text and tool calls.** Images are replaced by "[image omitted]", and
61
+ thinking is off.
62
+
63
+ ## Self-hosting
64
+
65
+ Nothing to configure. The client takes the server from the invite link's
66
+ address, and the weights and TURN relay from what that server tells it, so
67
+ your own server's links work as they are, `http://localhost` included.
68
+
69
+ - **Your public demo**: `clusterchat connect demo --server https://your.host`,
70
+ or set `CLUSTERCHAT_SERVER=https://your.host` once.
71
+ - **Modified code**: run the client from your checkout, `node cli/bin.js
72
+ connect …` (run `npm install` in `cli/` first), or `npm link` in `cli/` for a
73
+ `clusterchat` command. If the server and client protocol versions differ,
74
+ the client says so instead of failing quietly.
75
+
76
+ ## Adding a protocol, tool or model format
77
+
78
+ Each is one file plus a line in [`plugins.js`](plugins.js). Nothing else
79
+ changes.
80
+
81
+ - **A model's chat format** (`templates/`): `render(messages, { tools, system,
82
+ first })` returns the prompt text, and `parser(tools)` reads a reply as it
83
+ grows into text and tool calls. Chosen by the checkpoint manifest's
84
+ `chat_format`. See [`templates/qwen.js`](templates/qwen.js).
85
+ - **An API** (`protocols/`): `{ name, routes: { 'POST /path': handler }, fail }`.
86
+ A handler translates the request into the core's shape, runs
87
+ `cluster.chat(req)`, and writes its events back in its own wire format. See
88
+ [`protocols/openai.js`](protocols/openai.js).
89
+ - **A tool** (`harnesses/`): `{ name, label, protocol, setup(url, info) }`,
90
+ where `setup` returns the lines that point the tool here. See
91
+ [`harnesses/claude-code.js`](harnesses/claude-code.js).
92
+
93
+ The shape every protocol translates to is at the top of [`core.js`](core.js):
94
+
95
+ ```js
96
+ // req: { system, tools: [{ name, description, schema }], messages, maxTokens, temperature, signal }
97
+ // messages: [{ role: 'user' | 'assistant' | 'tool', text, calls?: [{ id, name, args }], callId? }]
98
+ for await (const ev of cluster.chat(req)) {
99
+ // { type: 'start' } | { type: 'text', text } | { type: 'call', id, name, args }
100
+ // | { type: 'end', stop: 'end' | 'length' | 'tool' | 'stopped', usage: { input, output, cached } }
101
+ }
102
+ ```
103
+
104
+ Tests: `node tools/cli.test.mjs` (no GPU) checks the Qwen template against
105
+ the checkpoint's own Jinja template and every protocol against a fake cluster.
106
+ `node tools/cli.gpu.mjs` runs the client against a local cluster on a real GPU.
107
+
108
+ ## License
109
+
110
+ AGPL-3.0, like the rest of [ClusterChat](https://github.com/l-wn/ClusterChat).