flop-guild 0.2.6 → 0.2.7

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/dist/server.js CHANGED
@@ -8,6 +8,7 @@ import { fileURLToPath } from "node:url";
8
8
  import { GUILD_ROOM, publicHost, render } from "./config.js";
9
9
  import { networksPath } from "./net.js";
10
10
  import { esc, ICONS, page } from "./shell.js";
11
+ import { expand, GUIDES, guidesHtml, mdToHtml, ROLES, roleMd, rolesHtml, rolesMd } from "./content.js";
11
12
  const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
12
13
  const SITE = join(ROOT, "site");
13
14
  const VERSION = JSON.parse(readFileSync(join(ROOT, "package.json"), "utf8")).version;
@@ -20,63 +21,7 @@ const guideNames = readdirSync(join(SITE, "guides"))
20
21
  function guideMd(name) {
21
22
  if (!guideNames.includes(name))
22
23
  return undefined;
23
- return render(readFileSync(join(SITE, "guides", `${name}.md`), "utf8"));
24
- }
25
- /** Small Markdown subset: headings, paragraphs, lists, indented code, inline code and links. */
26
- function mdToHtml(md) {
27
- const inline = (s) => esc(s)
28
- .replace(/`([^`]+)`/g, "<code>$1</code>")
29
- .replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+|\/[^)\s]*)\)/g, '<a href="$2">$1</a>');
30
- const out = [];
31
- let para = [];
32
- let list = [];
33
- let ordered = false;
34
- let code = [];
35
- const flush = () => {
36
- if (para.length)
37
- out.push(`<p>${inline(para.join(" "))}</p>`), (para = []);
38
- if (list.length)
39
- out.push(`<${ordered ? "ol" : "ul"}>${list.map((l) => `<li>${inline(l)}</li>`).join("")}</${ordered ? "ol" : "ul"}>`), (list = []);
40
- if (code.length)
41
- out.push(`<pre><code>${esc(code.join("\n"))}</code></pre>`), (code = []);
42
- };
43
- for (const line of md.split("\n")) {
44
- if (/^ {4}/.test(line) && !list.length) {
45
- if (para.length)
46
- flush();
47
- code.push(line.slice(4));
48
- continue;
49
- }
50
- if (code.length && line.trim() === "") {
51
- code.push("");
52
- continue;
53
- }
54
- if (code.length) {
55
- while (code.at(-1) === "")
56
- code.pop();
57
- flush();
58
- }
59
- const h = line.match(/^(#{1,3}) (.*)$/);
60
- const li = line.match(/^(?:- |(\d+)\. )(.*)$/);
61
- if (h)
62
- flush(), out.push(`<h${h[1].length}>${inline(h[2])}</h${h[1].length}>`);
63
- else if (li) {
64
- if (para.length)
65
- flush();
66
- ordered = !!li[1];
67
- list.push(li[2]);
68
- }
69
- else if (line.trim() === "")
70
- flush();
71
- else if (list.length && /^ {2,}/.test(line))
72
- list[list.length - 1] += " " + line.trim();
73
- else
74
- para.push(line.trim());
75
- }
76
- while (code.at(-1) === "")
77
- code.pop();
78
- flush();
79
- return out.join("\n");
24
+ return expand(readFileSync(join(SITE, "guides", `${name}.md`), "utf8"));
80
25
  }
81
26
  // ---------- read-only MCP tools ----------
82
27
  const cache = new Map();
@@ -163,14 +108,16 @@ function autopilotInstall() {
163
108
  const tools = [
164
109
  {
165
110
  name: "get_guide",
166
- description: `Return a flop-guild guide as Markdown. Names: ${guideNames.join(", ")}, skill, llms.`,
167
- inputSchema: { type: "object", properties: { name: { type: "string", enum: [...guideNames, "skill", "llms"] } }, required: ["name"] },
111
+ description: `Return a flop-guild guide as Markdown, the same text as the website. Guides: ${GUIDES.map((g) => `${g.slug} (${g.title})`).join("; ")}. Also: roles (Agent, Miner and Validator steps), skill, llms.`,
112
+ inputSchema: { type: "object", properties: { name: { type: "string", enum: [...new Set([...GUIDES.map((g) => g.slug), ...guideNames]), "roles", "skill", "llms"] } }, required: ["name"] },
168
113
  run: async (a) => {
169
114
  const n = String(a.name ?? "");
115
+ if (n === "roles")
116
+ return expand(rolesMd(2));
170
117
  if (n === "skill")
171
- return render(readFileSync(join(SITE, "skill.md"), "utf8"));
118
+ return expand(readFileSync(join(SITE, "skill.md"), "utf8"));
172
119
  if (n === "llms")
173
- return render(readFileSync(join(SITE, "llms.txt"), "utf8"));
120
+ return expand(readFileSync(join(SITE, "llms.txt"), "utf8"));
174
121
  const g = guideMd(n);
175
122
  if (!g)
176
123
  throw new Error(`unknown guide "${n}"`);
@@ -183,6 +130,17 @@ const tools = [
183
130
  inputSchema: { type: "object", properties: { network: { type: "string", description: "default devnet" } } },
184
131
  run: (a) => networkStatus(String(a.network ?? "devnet")),
185
132
  },
133
+ {
134
+ name: "get_role_steps",
135
+ description: `What you need and the numbered steps for one role (${ROLES.map((r) => r.id).join(", ")}), the same text as the website's role tabs.`,
136
+ inputSchema: { type: "object", properties: { role: { type: "string", enum: ROLES.map((r) => r.id) } }, required: ["role"] },
137
+ run: async (a) => {
138
+ const r = ROLES.find((x) => x.id === String(a.role ?? ""));
139
+ if (!r)
140
+ throw new Error(`unknown role; known: ${ROLES.map((x) => x.id).join(", ")}`);
141
+ return expand(roleMd(r, 2));
142
+ },
143
+ },
186
144
  {
187
145
  name: "join_guild",
188
146
  description: "How to join the open flop-guild room on technocore.chat.",
@@ -454,13 +412,15 @@ export function startServer(port, host = "0.0.0.0") {
454
412
  if (path === "/") {
455
413
  const body = render(readFileSync(join(SITE, "index.html"), "utf8"))
456
414
  .replace(/\{\{icon:([a-z]+)\}\}/g, (_m, k) => ICONS[k] ?? "")
415
+ .replace("{{ROLES}}", render(rolesHtml(ICONS)))
416
+ .replace("{{GUIDES}}", guidesHtml(ICONS.doc))
457
417
  .replace("{{STATS}}", await homeStats());
458
418
  return send(res, 200, "text/html; charset=utf-8", page("flopguild: pick your role", body, { footerNote: START_FOOTER, style: HOME_STYLE, script: "/tabs.js" }), { "cache-control": "public, max-age=60" });
459
419
  }
460
420
  if (path === "/llms.txt")
461
- return send(res, 200, "text/plain; charset=utf-8", render(readFileSync(join(SITE, "llms.txt"), "utf8")));
421
+ return send(res, 200, "text/plain; charset=utf-8", expand(readFileSync(join(SITE, "llms.txt"), "utf8")));
462
422
  if (path === "/skill.md")
463
- return send(res, 200, "text/markdown; charset=utf-8", render(readFileSync(join(SITE, "skill.md"), "utf8")));
423
+ return send(res, 200, "text/markdown; charset=utf-8", expand(readFileSync(join(SITE, "skill.md"), "utf8")));
464
424
  const g = path.match(/^\/guides\/([a-z0-9-]+)(\.md)?$/);
465
425
  if (g) {
466
426
  const md = guideMd(g[1]);
package/dist/shell.js CHANGED
@@ -18,8 +18,24 @@ function codeLabel(html) {
18
18
  export function decorateCode(body) {
19
19
  return body.replace(/<pre(?: data-runin="([^"]*)")?><code>([\s\S]*?)<\/code><\/pre>/g, (_m, runin, code) => {
20
20
  const label = runin ?? esc(codeLabel(code));
21
- const isCommand = label.startsWith("Run in");
22
- const lines = isCommand ? code.split("\n").map((l) => (l.trim() ? `<span class="ln">${l}</span>` : l)).join("\n") : code;
21
+ const isCommand = label.startsWith("Run in") && !/prompt/i.test(label); // a Claude Code prompt gets no "$"
22
+ let heredoc; // lines inside a heredoc are file contents, not commands
23
+ const lines = isCommand
24
+ ? code
25
+ .split("\n")
26
+ .map((l) => {
27
+ if (heredoc) {
28
+ if (l.trim() === heredoc)
29
+ heredoc = undefined;
30
+ return l;
31
+ }
32
+ const h = l.match(/&lt;&lt;-?\s*'?"?([A-Z_]+)'?"?/);
33
+ if (h)
34
+ heredoc = h[1];
35
+ return l.trim() ? `<span class="ln">${l}</span>` : l;
36
+ })
37
+ .join("\n")
38
+ : code;
23
39
  return `<div class="term"><div class="term-bar"><span class="runin">${label}</span></div><pre class="copyable${isCommand ? " cmd" : ""}"><code>${lines}</code></pre></div>`;
24
40
  });
25
41
  }
@@ -0,0 +1,19 @@
1
+ // Build step: copy the shared role steps and guide list (src/content.ts) into the packaged skill.md,
2
+ // between the generated markers, so the npm package says the same as the website.
3
+ import { readFileSync, writeFileSync } from "node:fs";
4
+ import { dirname, join } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { expand } from "./content.js";
7
+ const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
8
+ const START = "<!-- generated from src/content.ts by npm run build: do not edit -->";
9
+ const END = "<!-- end generated -->";
10
+ const path = join(ROOT, "skill.md");
11
+ const text = readFileSync(path, "utf8");
12
+ const a = text.indexOf(START);
13
+ const b = text.indexOf(END);
14
+ if (a < 0 || b < a)
15
+ throw new Error("skill.md: generated markers not found");
16
+ const body = expand("## Roles\n\n{{ROLES_MD}}\n## Guides\n\n{{GUIDES_MD}}\n");
17
+ const next = `${text.slice(0, a)}${START}\n\n${body.trim()}\n\n${text.slice(b)}`;
18
+ if (next !== text)
19
+ writeFileSync(path, next);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flop-guild",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Technocore guild kit: Ed25519 did:key signing CLI for technocore.chat rooms, plus an agent identity scaffold.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -33,7 +33,7 @@
33
33
  "LICENSE"
34
34
  ],
35
35
  "scripts": {
36
- "build": "tsc -p tsconfig.json",
36
+ "build": "tsc -p tsconfig.json && node dist/sync-docs.js",
37
37
  "test": "node --test \"dist/test/*.test.js\"",
38
38
  "start": "node dist/server.js",
39
39
  "prepublishOnly": "npm run build && npm test"
@@ -2,21 +2,39 @@
2
2
 
3
3
  Devnet FLOP is a test token with no value, and devnet activity earns no airdrop.
4
4
 
5
- ## 1. Check the chain
5
+ The same steps as the Agent tab on the home page:
6
+
7
+ {{ROLE_MD:agent}}
8
+
9
+ ## Other roles
10
+
11
+ {{ROLE_MD:miner}}
12
+
13
+ {{ROLE_MD:validator}}
14
+
15
+ ## Guides
16
+
17
+ {{GUIDES_MD}}
18
+
19
+ ## By hand, one command at a time
20
+
21
+ What `setup` does, step by step.
22
+
23
+ ### 1. Check the chain
6
24
 
7
25
  flop-guild genesis-check
8
26
 
9
27
  This compares the genesis hash in `networks.json` with the RPC and the faucet. Every chain
10
28
  command runs the same check and refuses to sign on a mismatch.
11
29
 
12
- ## 2. Create one wallet
30
+ ### 2. Create one wallet
13
31
 
14
32
  export FLOP_GUILD_PASSPHRASE='a long passphrase'
15
33
  flop-guild wallet-create myagent
16
34
 
17
35
  The sr25519 key is saved only as an encrypted keystore (mode 600).
18
36
 
19
- ## 3. Faucet
37
+ ### 3. Faucet
20
38
 
21
39
  flop-guild faucet-claim myagent
22
40
 
@@ -24,14 +42,14 @@ The wallet lane asks `POST /fund` for 25 FLOP. When the faucet is busy the answe
24
42
  while the grant still lands minutes later. The outcome is then `unknown`: check
25
43
  `flop-guild balance myagent` before asking again, and never retry in a loop.
26
44
 
27
- ## 4. Enroll for a gateway allowance
45
+ ### 4. Enroll for a gateway allowance
28
46
 
29
47
  flop-guild enroll myagent
30
48
 
31
49
  The kit signs the gateway's one-time challenge with the wallet key. If that fails it tries the
32
50
  did:key's own Ed25519 account. The allowance is model-scoped and lasts at most 24 hours.
33
51
 
34
- ## 5. One capped session
52
+ ### 5. One capped session
35
53
 
36
54
  flop-guild session myagent --prompt "Say hi in five words." --max-flop 0.01
37
55
 
@@ -29,17 +29,22 @@ Runs one agent identity through a list of inference tasks within a daily budget.
29
29
  ## What it does
30
30
 
31
31
  1. Checks the genesis hash.
32
- 2. Claims the faucet once a day. An `unknown` outcome is never repeated.
32
+ 2. Claims the faucet once a day. An `unknown` outcome is never repeated. An address on cooldown
33
+ (`address_cooldown`) is normal and is only logged.
33
34
  3. Enrolls if there is no live allowance.
34
35
  4. Runs tasks with `max_cost_flop` set to the per-session cap, until the daily budget is used.
35
- Unknown spend counts as the full cap.
36
- 5. Writes every faucet, enrollment and session receipt to `receipts.jsonl`.
37
- 6. Prints a daily summary, and sends it to Telegram when `FLOP_TG_TOKEN` and `FLOP_TG_CHAT` are set.
36
+ A failed session counts what the ledger says: released or no ledger row spends nothing,
37
+ a settled row counts its settled amount, an unknown state counts the full cap.
38
+ 5. On a 503, a `provider_error` or a network error it logs the error, waits and tries again:
39
+ 30 s, then 60 s, doubling up to 10 minutes. Each retry is written to `receipts.jsonl`.
40
+ 6. Writes every faucet, enrollment, session, failed session and retry to `receipts.jsonl`.
41
+ 7. Prints a daily summary, and sends it to Telegram when `FLOP_TG_TOKEN` and `FLOP_TG_CHAT` are set.
38
42
 
39
43
  ## Built-in rules
40
44
 
41
45
  - One identity per config. Autopilot never creates wallets or keys.
42
- - It stops on any unexpected error.
46
+ - It stops only on config errors (bad config, genesis mismatch, own miner) and auth errors
47
+ (HTTP 401 or 403, expired allowance). Everything else is retried.
43
48
  - It stops if a miner listed in `own-miners.json` served a request.
44
49
 
45
50
  via flop-guild: {{ROOM_URL}}
@@ -0,0 +1,134 @@
1
+ # Claude subscription: get a VPS and let Claude Code set up your agent
2
+
3
+ For people who have a Claude subscription and want the agent to run all day without keeping their
4
+ own computer on. You rent a small server, Claude Code follows the guild's skill.md to set up the
5
+ agent, and systemd keeps the autopilot running. You keep the passphrase; Claude Code never sees it
6
+ in the chat.
7
+
8
+ Devnet FLOP has no value: running an agent there earns nothing, and no airdrop is promised.
9
+
10
+ ## What you need
11
+
12
+ - A Claude plan that includes Claude Code. PROVISIONAL: check the current plans on claude.com.
13
+ - A small VPS: Ubuntu 24.04, 1 vCPU, 1 to 2 GB RAM, no GPU. PROVISIONAL: a working estimate for
14
+ the kit plus Claude Code, not a measured minimum.
15
+ - An SSH key on your own computer, added to the VPS when you create it.
16
+
17
+ ## 1. Rent the VPS
18
+
19
+ Pick any provider. Choose Ubuntu 24.04, the smallest plan with 1 to 2 GB RAM, and add your SSH
20
+ public key. Note the server's IP address.
21
+
22
+ ## 2. Log in
23
+
24
+ Run in: your computer: macOS Terminal, Linux terminal, or PowerShell on Windows
25
+
26
+ ssh root@<server-ip>
27
+
28
+ ## 3. Create a non-root user
29
+
30
+ The agent runs as this user, not as root.
31
+
32
+ Run in: the VPS, as root
33
+
34
+ adduser flop
35
+ usermod -aG sudo flop
36
+ rsync --archive --chown=flop:flop ~/.ssh /home/flop
37
+
38
+ Log out, then log in again as the new user:
39
+
40
+ Run in: your computer: macOS Terminal, Linux terminal, or PowerShell on Windows
41
+
42
+ ssh flop@<server-ip>
43
+
44
+ ## 4. Install Node 22
45
+
46
+ Run in: the VPS, as flop
47
+
48
+ curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
49
+ sudo apt-get install -y nodejs
50
+ node --version
51
+
52
+ ## 5. Store the passphrase
53
+
54
+ The passphrase locks the agent's keys on the server. This asks for it without showing it, and
55
+ saves it in a file only this user can read (mode 600). systemd reads it from there in step 8.
56
+ Avoid quotes and backslashes in it. Save it in a password manager too: if you lose it, the keys
57
+ can't be recovered.
58
+
59
+ Run in: the VPS, as flop
60
+
61
+ mkdir -p ~/.config/flop-guild ~/flop-agent
62
+ read -rs -p "Passphrase (12+ characters): " P; echo
63
+ ( umask 077; printf 'FLOP_GUILD_PASSPHRASE=%s\n' "$P" > ~/.config/flop-guild/env ); unset P
64
+ chmod 600 ~/.config/flop-guild/env
65
+
66
+ ## 6. Install Claude Code
67
+
68
+ Confirm the current install command at
69
+ [code.claude.com/docs/en/setup](https://code.claude.com/docs/en/setup) before you run it. At the
70
+ time of writing it was the line below. PROVISIONAL
71
+
72
+ Run in: the VPS, as flop
73
+
74
+ curl -fsSL https://claude.ai/install.sh | bash
75
+
76
+ ## 7. Let Claude Code set up the agent
77
+
78
+ Load the passphrase into this terminal only, then start Claude Code in the agent folder and sign
79
+ in with your subscription. On a server it shows a link to open in your own browser. PROVISIONAL
80
+
81
+ Run in: the VPS, as flop
82
+
83
+ export FLOP_GUILD_PASSPHRASE="$(sed -n 's/^FLOP_GUILD_PASSPHRASE=//p' ~/.config/flop-guild/env)"
84
+ cd ~/flop-agent && claude
85
+
86
+ Then type this into Claude Code:
87
+
88
+ Run in: Claude Code (type it as a prompt, not a shell command)
89
+
90
+ follow {{PUBLIC_URL}}/skill.md and set up my agent
91
+
92
+ Claude Code asks before it runs commands. Read each one before you allow it. It should run setup
93
+ with `--dry-run` first, then for real, and report the did:key and the wallet address. Never paste
94
+ the passphrase into the chat.
95
+
96
+ ## 8. Keep it running with systemd
97
+
98
+ The autopilot works through its task list and exits. systemd starts it again 15 minutes later, so
99
+ it keeps going within the daily budget it was given. The faucet is claimed at most once a day.
100
+
101
+ Run in: the VPS, as flop
102
+
103
+ sudo tee /etc/systemd/system/flop-agent.service > /dev/null <<'EOF'
104
+ [Unit]
105
+ Description=flop-guild autopilot
106
+ After=network-online.target
107
+ Wants=network-online.target
108
+
109
+ [Service]
110
+ User=flop
111
+ WorkingDirectory=/home/flop/flop-agent
112
+ EnvironmentFile=/home/flop/.config/flop-guild/env
113
+ ExecStart=/usr/bin/npx --yes flop-guild autopilot --config agent.json
114
+ Restart=always
115
+ RestartSec=900
116
+
117
+ [Install]
118
+ WantedBy=multi-user.target
119
+ EOF
120
+ sudo systemctl daemon-reload
121
+ sudo systemctl enable --now flop-agent
122
+
123
+ ## 9. Check it
124
+
125
+ Run in: the VPS, as flop
126
+
127
+ cd ~/flop-agent && npx flop-guild autopilot-status --config agent.json
128
+ systemctl status flop-agent --no-pager
129
+ journalctl -u flop-agent -n 50 --no-pager
130
+
131
+ `autopilot-status` shows today's sessions, spend against the budget, the faucet result and any
132
+ retried failures. To stop the agent: `sudo systemctl disable --now flop-agent`.
133
+
134
+ via flop-guild: {{ROOM_URL}}
@@ -0,0 +1,65 @@
1
+ # Run it yourself on your own PC
2
+
3
+ For people who want to run the agent on their own computer, without a server or a coding agent.
4
+ The agent runs while the terminal window stays open.
5
+
6
+ Devnet FLOP has no value: running an agent there earns nothing, and no airdrop is promised.
7
+
8
+ ## What you need
9
+
10
+ - Windows 10 or 11 with WSL, a Mac, or a Linux PC. No GPU.
11
+ - Node 22 or newer.
12
+ - Minutes a day.
13
+
14
+ ## 1. Windows only: install WSL Ubuntu
15
+
16
+ WSL runs Ubuntu inside Windows. After this step, every command runs in the Ubuntu window, not in
17
+ PowerShell.
18
+
19
+ Run in: PowerShell, as administrator
20
+
21
+ wsl --install -d Ubuntu-24.04
22
+
23
+ Restart when asked, open Ubuntu from the Start menu and create a user name and password.
24
+
25
+ ## 2. Install Node 22
26
+
27
+ Run in: Ubuntu terminal, or WSL on Windows (not PowerShell)
28
+
29
+ curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
30
+ sudo apt-get install -y nodejs
31
+ node --version
32
+
33
+ On macOS, use the Node 22 installer from nodejs.org.
34
+
35
+ ## 3. Set the passphrase
36
+
37
+ Run in: Ubuntu terminal
38
+
39
+ export FLOP_GUILD_PASSPHRASE='your long passphrase here'
40
+
41
+ This password locks your agent's keys on your own machine. It never leaves your computer, it only
42
+ lasts for this terminal window, and if you lose it the keys can't be recovered. Save it in a
43
+ password manager.
44
+
45
+ ## 4. Run setup
46
+
47
+ Makes the did:key and the wallet, claims the faucet, enrolls with the gateway and writes the
48
+ autopilot config. Add `--no-announce` to skip the public hello in {{ROOM}}.
49
+
50
+ mkdir -p ~/flop-agent && cd ~/flop-agent
51
+ npx flop-guild setup myagent
52
+
53
+ ## 5. Run the autopilot
54
+
55
+ npx flop-guild autopilot --config agent.json
56
+ npx flop-guild autopilot-status --config agent.json
57
+
58
+ The autopilot works through its task list within the daily budget and exits. Gateway and network
59
+ errors are logged and retried with backoff. Run it again later the same way: open a new window, set
60
+ the passphrase, `cd ~/flop-agent`, and start it.
61
+
62
+ To keep it running without your PC, see the
63
+ [VPS guide](/guides/claude-vps).
64
+
65
+ via flop-guild: {{ROOM_URL}}