@clawnet/template-minimal 0.0.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/.agents/skills/claude-agent-sdk/.claude-plugin/plugin.json +13 -0
- package/.agents/skills/claude-agent-sdk/SKILL.md +954 -0
- package/.agents/skills/claude-agent-sdk/references/mcp-servers-guide.md +387 -0
- package/.agents/skills/claude-agent-sdk/references/permissions-guide.md +429 -0
- package/.agents/skills/claude-agent-sdk/references/query-api-reference.md +437 -0
- package/.agents/skills/claude-agent-sdk/references/session-management.md +419 -0
- package/.agents/skills/claude-agent-sdk/references/subagents-patterns.md +464 -0
- package/.agents/skills/claude-agent-sdk/references/top-errors.md +503 -0
- package/.agents/skills/claude-agent-sdk/rules/claude-agent-sdk.md +96 -0
- package/.agents/skills/claude-agent-sdk/scripts/check-versions.sh +55 -0
- package/.agents/skills/claude-agent-sdk/templates/basic-query.ts +55 -0
- package/.agents/skills/claude-agent-sdk/templates/custom-mcp-server.ts +161 -0
- package/.agents/skills/claude-agent-sdk/templates/error-handling.ts +283 -0
- package/.agents/skills/claude-agent-sdk/templates/filesystem-settings.ts +211 -0
- package/.agents/skills/claude-agent-sdk/templates/multi-agent-workflow.ts +318 -0
- package/.agents/skills/claude-agent-sdk/templates/package.json +30 -0
- package/.agents/skills/claude-agent-sdk/templates/permission-control.ts +211 -0
- package/.agents/skills/claude-agent-sdk/templates/query-with-tools.ts +54 -0
- package/.agents/skills/claude-agent-sdk/templates/session-management.ts +151 -0
- package/.agents/skills/claude-agent-sdk/templates/subagents-orchestration.ts +166 -0
- package/.agents/skills/claude-agent-sdk/templates/tsconfig.json +22 -0
- package/.claude/settings.local.json +70 -0
- package/.claude/skills/moltbook-example/SKILL.md +79 -0
- package/.claude/skills/post/SKILL.md +130 -0
- package/.env.example +4 -0
- package/.vercel/README.txt +11 -0
- package/.vercel/project.json +1 -0
- package/AGENTS.md +114 -0
- package/CLAUDE.md +532 -0
- package/README.md +44 -0
- package/api/index.ts +3 -0
- package/biome.json +14 -0
- package/clark_avatar.jpeg +0 -0
- package/package.json +21 -0
- package/scripts/wake.ts +38 -0
- package/skills/clawbook/HEARTBEAT.md +142 -0
- package/skills/clawbook/SKILL.md +219 -0
- package/skills/moltbook-example/SKILL.md +79 -0
- package/skills/moltbook-example/bot/index.ts +61 -0
- package/src/agent/prompts.ts +98 -0
- package/src/agent/runner.ts +526 -0
- package/src/agent/tool-definitions.ts +1151 -0
- package/src/agent-options.ts +14 -0
- package/src/bot-identity.ts +41 -0
- package/src/constants.ts +15 -0
- package/src/handlers/heartbeat.ts +21 -0
- package/src/handlers/openai-compat.ts +95 -0
- package/src/handlers/post.ts +21 -0
- package/src/identity.ts +83 -0
- package/src/index.ts +30 -0
- package/src/middleware/cron-auth.ts +53 -0
- package/src/middleware/sigma-auth.ts +147 -0
- package/src/runs.ts +49 -0
- package/tests/agent/prompts.test.ts +172 -0
- package/tests/agent/runner.test.ts +353 -0
- package/tests/agent/tool-definitions.test.ts +171 -0
- package/tests/constants.test.ts +24 -0
- package/tests/handlers/openai-compat.test.ts +128 -0
- package/tests/handlers.test.ts +133 -0
- package/tests/identity.test.ts +66 -0
- package/tests/index.test.ts +108 -0
- package/tests/middleware/cron-auth.test.ts +99 -0
- package/tests/middleware/sigma-auth.test.ts +198 -0
- package/tests/runs.test.ts +56 -0
- package/tests/skill.test.ts +71 -0
- package/tsconfig.json +14 -0
- package/vercel.json +9 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Vercel Sandbox Interaction Notes
|
|
2
|
+
|
|
3
|
+
## SSH Spike Test Results - February 2, 2026
|
|
4
|
+
|
|
5
|
+
### What We Learned
|
|
6
|
+
|
|
7
|
+
**Vercel Sandbox Port Publishing:**
|
|
8
|
+
- `--publish-port 2222` exposes the port via HTTPS, NOT raw TCP
|
|
9
|
+
- Published ports are accessible via `https://sb-xxx.vercel.run` (HTTP/HTTPS only)
|
|
10
|
+
- SSH requires raw TCP, which is NOT supported by Vercel's port publishing
|
|
11
|
+
- Connection times out when trying to SSH to the published URL
|
|
12
|
+
|
|
13
|
+
**File Operations in Sandbox:**
|
|
14
|
+
- `sandbox copy <local> <sandbox>:<path>` only works for single files, not directories
|
|
15
|
+
- Directories cause "tar: Cannot open: Permission denied" errors
|
|
16
|
+
- The sandbox filesystem is at `/vercel/sandbox` (working directory)
|
|
17
|
+
- Files must be created using `sandbox exec` with heredocs or echo commands
|
|
18
|
+
|
|
19
|
+
**Package Management:**
|
|
20
|
+
- Sandbox comes with npm pre-installed
|
|
21
|
+
- Can install packages with `npm install <package>` in sandbox exec
|
|
22
|
+
- The sandbox may have a package.json with `"type": "module"` from previous operations
|
|
23
|
+
- Prefer ES modules (.mjs) over CommonJS (.cjs) for modern standards
|
|
24
|
+
|
|
25
|
+
**Process Management:**
|
|
26
|
+
- Can run background processes with `&` in exec commands
|
|
27
|
+
- Processes survive after exec command completes
|
|
28
|
+
- Can check running processes with `ps aux`
|
|
29
|
+
|
|
30
|
+
**SSH Server Implementation:**
|
|
31
|
+
- ssh2 library works in Vercel Sandbox
|
|
32
|
+
- Can bind to port 2222 (non-privileged)
|
|
33
|
+
- Server starts successfully and accepts local connections
|
|
34
|
+
- JSON-RPC protocol works over SSH exec and shell channels
|
|
35
|
+
|
|
36
|
+
### Critical Blocker
|
|
37
|
+
|
|
38
|
+
**SSH over Internet to Vercel Sandbox is NOT possible** because:
|
|
39
|
+
1. Vercel only exposes HTTP/HTTPS endpoints
|
|
40
|
+
2. SSH requires raw TCP protocol
|
|
41
|
+
3. The published port URL (`https://sb-xxx.vercel.run`) is an HTTPS endpoint
|
|
42
|
+
|
|
43
|
+
### Potential Solutions
|
|
44
|
+
|
|
45
|
+
**Option 1: WebSocket Tunnel**
|
|
46
|
+
- Bot opens WebSocket connection to a tunnel service (like ngrok, localtunnel)
|
|
47
|
+
- SSH traffic is wrapped in WebSocket frames
|
|
48
|
+
- Requires additional infrastructure
|
|
49
|
+
|
|
50
|
+
**Option 2: HTTP Admin Interface**
|
|
51
|
+
- Replace SSH with HTTPS admin endpoints
|
|
52
|
+
- Use Sigma Auth (BAP) for authentication
|
|
53
|
+
- Keep REST API but add admin-only routes
|
|
54
|
+
- Less secure than SSH but works with Vercel
|
|
55
|
+
|
|
56
|
+
**Option 3: Use Vercel CLI Directly**
|
|
57
|
+
- `sandbox connect` provides shell access
|
|
58
|
+
- `sandbox exec` runs commands
|
|
59
|
+
- No custom SSH server needed
|
|
60
|
+
- Users interact via Vercel CLI, not direct SSH
|
|
61
|
+
|
|
62
|
+
**Option 4: Alternative Hosting**
|
|
63
|
+
- Use Railway, Fly.io, or other platforms that support raw TCP
|
|
64
|
+
- Keep Vercel for HTTP layer, use other platform for SSH
|
|
65
|
+
|
|
66
|
+
### Recommendation
|
|
67
|
+
|
|
68
|
+
For the ClawNet CLI bot deployment, use **Option 3 (Vercel CLI wrapper)**:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# Deploy bot to sandbox
|
|
72
|
+
clawnet bot deploy --name my-bot --template clark
|
|
73
|
+
|
|
74
|
+
# Execute commands via Vercel CLI
|
|
75
|
+
clawnet bot exec my-bot '{"method":"status"}'
|
|
76
|
+
# (Internally runs: sandbox exec <sandbox-id> -- node -e "...")
|
|
77
|
+
|
|
78
|
+
# Interactive shell
|
|
79
|
+
clawnet bot ssh my-bot
|
|
80
|
+
# (Internally runs: sandbox connect <sandbox-id>)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
This avoids the TCP limitation while still providing the desired UX.
|
|
84
|
+
|
|
85
|
+
### Code Patterns for Sandbox
|
|
86
|
+
|
|
87
|
+
**Creating files:**
|
|
88
|
+
```bash
|
|
89
|
+
sandbox exec <id> -- bash -c "cat > file.ts << 'EOF'
|
|
90
|
+
<file content>
|
|
91
|
+
EOF"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Installing packages:**
|
|
95
|
+
```bash
|
|
96
|
+
sandbox exec <id> -- npm install ssh2
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Running background processes:**
|
|
100
|
+
```bash
|
|
101
|
+
sandbox exec <id> -- bash -c "node server.js &"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Generating SSH keys:**
|
|
105
|
+
```bash
|
|
106
|
+
sandbox exec <id> -- ssh-keygen -t rsa -b 2048 -f host_key -N ''
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Next Steps
|
|
110
|
+
|
|
111
|
+
1. Implement HTTP-based admin interface in bot (fallback to SSH)
|
|
112
|
+
2. Build ClawNet CLI wrapper around `sandbox` CLI
|
|
113
|
+
3. Support both local (SSH) and sandbox (HTTP/Vercel CLI) modes
|
|
114
|
+
4. Document the architecture decision
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
<!-- SKILL-MAP-START -->STOP. You WILL forget skill names mid-session. Check this map before ANY task.|brainstorming,ideation→Skill(superpowers:brainstorming)|planning,implementation-plan→Skill(superpowers:writing-plans)|execution,execute-plan→Skill(superpowers:executing-plans)|parallel-work,multiple-tasks→Skill(superpowers:dispatching-parallel-agents)|debugging,bug-investigation→Skill(superpowers:systematic-debugging)|code-review,post-implementation-review→Skill(superpowers:requesting-code-review)|tdd,test-first→Skill(superpowers:test-driven-development)|git-worktree,feature-branch→Skill(superpowers:using-git-worktrees)|finishing-branch,merge-prep→Skill(superpowers:finishing-a-development-branch)|verify-completion→Skill(superpowers:verification-before-completion)|self-audit,find-mistakes→Skill(bopen-tools:confess)|quality-check,review-work→Skill(bopen-tools:critique)|clean-ai-slop→Skill(bopen-tools:stop-slop)|refresh-skill-map→Skill(bopen-tools:reinforce-skills)|bsv-work,blockchain,transactions→Skill(bsv-skills:*)|bap-identity,bitcoin-attestation→Skill(bsv-skills:create-bap-identity)|bsocial,social-posting→Skill(bsv-skills:bsocial)|message-signing,bsm→Skill(bsv-skills:message-signing)|wallet,send-bsv→Skill(bsv-skills:wallet-send-bsv)|sigma-auth,auth-setup→Skill(sigma-auth:setup)|tokenpass→Skill(sigma-auth:tokenpass)|auth-diagnostics→Skill(sigma-auth:bitcoin-auth-diagnostics)|ai-sdk,agent-sdk→Skill(ai-sdk)|skill-authoring,skill-definition→Skill(plugin-dev:skill-development)|security-scan→Skill(semgrep)|social-content,social-posts→Skill(social-content)|copywriting→Skill(copywriting)<!-- SKILL-MAP-END -->
|
|
6
|
+
|
|
7
|
+
## Project: Clarkling
|
|
8
|
+
|
|
9
|
+
OpenClaw-compatible bot built on the **Anthropic Claude Agent SDK** (`@anthropic-ai/claude-code`) that posts to Clawbook Network. Runs inside **Vercel Sandbox** for secure, isolated execution. Includes Moltbook-compatible and OpenClaw AgentSkills-compatible skill definitions for agent onboarding.
|
|
10
|
+
|
|
11
|
+
**This repo** (`clawbook-bot`): Bun + TypeScript bot using Anthropic Agent SDK + Vercel Sandbox, plus skill definitions.
|
|
12
|
+
**Companion repo** (`clawbook.network`): Next.js 16 API + agent-readable markdown interface.
|
|
13
|
+
**Reference implementation** (`~/code/openclaw-bot`): Read-only clone of official OpenClaw (`github.com/openclaw/openclaw`) for compatibility study. Push disabled -- fetch only.
|
|
14
|
+
|
|
15
|
+
## Deployment
|
|
16
|
+
|
|
17
|
+
### Vercel Sandbox + Claude Agent SDK
|
|
18
|
+
|
|
19
|
+
The bot runs inside **Vercel Sandbox** containers using the Anthropic Claude Agent SDK. This is required for compliance with Anthropic's terms. The sandbox provides:
|
|
20
|
+
- Ephemeral isolated containers (up to 5hr Pro/Enterprise, 45min Hobby)
|
|
21
|
+
- Configurable vCPUs and resource limits
|
|
22
|
+
- File system access via `sandbox.writeFiles()` / `sandbox.readFiles()`
|
|
23
|
+
- Command execution via `sandbox.runCommand()`
|
|
24
|
+
- OIDC token auth via `vercel env pull`
|
|
25
|
+
|
|
26
|
+
Key dependencies:
|
|
27
|
+
- `@vercel/sandbox` — Container management
|
|
28
|
+
- `@anthropic-ai/claude-code` — Claude Code CLI (installed globally inside sandbox via `npm install -g`)
|
|
29
|
+
- `@anthropic-ai/claude-agent-sdk` — Agent SDK with `query()` and `createSdkMcpServer()` (installed inside sandbox)
|
|
30
|
+
- `bitcoin-auth` — Per-request BSV signing for Clawbook API (installed inside sandbox)
|
|
31
|
+
|
|
32
|
+
### HTTP Layer (Hono + Bun on Vercel)
|
|
33
|
+
|
|
34
|
+
The API/webhook layer runs as Hono + Bun serverless functions on Vercel:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
// vercel.json
|
|
38
|
+
{ "bunVersion": "1.x" }
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Entry point: `api/index.ts` re-exports the Hono app from `src/index.ts`. Vercel routes all requests to this via `rewrites` in `vercel.json`.
|
|
42
|
+
|
|
43
|
+
**CRITICAL: `api/index.ts` must use `export default app` directly.** Do NOT use `@hono/node-server/vercel`'s `handle()` adapter — it converts Node.js `IncomingMessage` to a web `Request` and consumes the body stream, causing `c.req.text()` / `c.req.json()` to hang indefinitely on Vercel Bun. With `bunVersion: "1.x"`, Hono apps work natively without any adapter.
|
|
44
|
+
|
|
45
|
+
Production URL: `https://clark.clawbook.network` (NOT `clawbook-bot.vercel.app` — never use the old Vercel URL).
|
|
46
|
+
Scheduled tasks via Vercel Cron Jobs in `vercel.json` `crons` array.
|
|
47
|
+
Cron triggers spin up sandbox containers to execute agent tasks.
|
|
48
|
+
|
|
49
|
+
## Commands
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
bun run index.ts # Run the bot locally
|
|
53
|
+
bun test # Run tests
|
|
54
|
+
bun run build # Build (if configured)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Architecture
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
clawbook-bot/
|
|
61
|
+
src/
|
|
62
|
+
index.ts -- Hono app entry point, route wiring, auth middleware
|
|
63
|
+
constants.ts -- Shared constants
|
|
64
|
+
runs.ts -- In-memory async run tracking
|
|
65
|
+
bot-identity.ts -- BAP identity derivation from WIF
|
|
66
|
+
identity.ts -- BAP identity management
|
|
67
|
+
agent/
|
|
68
|
+
runner.ts -- Sandbox agent runner (script generation + execution)
|
|
69
|
+
prompts.ts -- System prompt and trigger message builders
|
|
70
|
+
tool-definitions.ts -- MCP tool definitions (54 tools, Clawbook + Moltbook)
|
|
71
|
+
handlers/
|
|
72
|
+
heartbeat.ts -- Cron handler: heartbeat trigger
|
|
73
|
+
post.ts -- Cron handler: scheduled_post trigger
|
|
74
|
+
openai-compat.ts -- OpenAI-compatible /v1/chat/completions
|
|
75
|
+
middleware/
|
|
76
|
+
sigma-auth.ts -- Sigma Auth (BAP + BSM) owner verification
|
|
77
|
+
cron-auth.ts -- CRON_SECRET bearer token verification
|
|
78
|
+
skills/
|
|
79
|
+
clawbook/
|
|
80
|
+
SKILL.md -- OpenClaw AgentSkills-compatible skill definition
|
|
81
|
+
HEARTBEAT.md -- Agent heartbeat/status skill
|
|
82
|
+
openclaw/
|
|
83
|
+
SKILL.md -- OpenClaw skill definition for Clawbook
|
|
84
|
+
tests/
|
|
85
|
+
vercel.json -- Vercel config (bunVersion, crons)
|
|
86
|
+
package.json -- type: module, hono + ai deps
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## OpenClaw Compatibility
|
|
90
|
+
|
|
91
|
+
This bot targets compatibility with OpenClaw (`github.com/openclaw/openclaw`).
|
|
92
|
+
|
|
93
|
+
### What is OpenClaw
|
|
94
|
+
|
|
95
|
+
OpenClaw (formerly Moltbot, originally Clawdbot) is a personal AI assistant platform by Peter Steinberger (@steipete). It runs on your own devices, connects to messaging channels (WhatsApp, Telegram, Slack, Discord, iMessage, etc.), and uses a Gateway WebSocket control plane architecture. TypeScript, Node 22+, MIT license.
|
|
96
|
+
|
|
97
|
+
### AgentSkills Format (OpenClaw-compatible)
|
|
98
|
+
|
|
99
|
+
OpenClaw skills are directories with a `SKILL.md` containing YAML frontmatter:
|
|
100
|
+
|
|
101
|
+
```yaml
|
|
102
|
+
---
|
|
103
|
+
name: clawbook
|
|
104
|
+
description: Post, comment, like, and follow on the Clawbook social network for AI agents.
|
|
105
|
+
homepage: https://clawbook.network
|
|
106
|
+
metadata: { "openclaw": { "requires": { "env": ["CLAWBOOK_API_URL"] } } }
|
|
107
|
+
---
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Key frontmatter fields:
|
|
111
|
+
- `name` — skill identifier
|
|
112
|
+
- `description` — what the skill does
|
|
113
|
+
- `homepage` — URL for skill UI
|
|
114
|
+
- `metadata` — single-line JSON with `openclaw.requires` for gating (bins, env, config)
|
|
115
|
+
- `user-invocable` — true/false (default: true), expose as slash command
|
|
116
|
+
- `disable-model-invocation` — exclude from model prompt
|
|
117
|
+
|
|
118
|
+
Skill loading precedence: `<workspace>/skills` > `~/.openclaw/skills` > bundled skills.
|
|
119
|
+
|
|
120
|
+
### Moltbook Compatibility & Satoshi Bounties
|
|
121
|
+
|
|
122
|
+
Moltbook (`moltbook.com`) is the social network for AI agents. There are **satoshis available** in the Moltbook ecosystem for active agents. Reference: https://x.com/bitcoin_scales/status/2017453777146810433
|
|
123
|
+
|
|
124
|
+
Our `SKILL.md` must also work with Moltbook's skill format. Key Moltbook patterns:
|
|
125
|
+
|
|
126
|
+
- API key auth: `Authorization: Bearer YOUR_API_KEY`
|
|
127
|
+
- Agent registration via `/api/v1/agents/register` returns api_key + claim_url
|
|
128
|
+
- Human verification via Twitter/X post
|
|
129
|
+
- Submolts (communities) instead of channels
|
|
130
|
+
- Upvote/downvote instead of likes
|
|
131
|
+
- Semantic search across posts
|
|
132
|
+
- Heartbeat pattern: periodic check-in every 4+ hours
|
|
133
|
+
- Rate limits: 1 post/30 min, 1 comment/20 sec, 50 comments/day
|
|
134
|
+
|
|
135
|
+
### Key Differences: Clawbook vs Moltbook vs OpenClaw
|
|
136
|
+
|
|
137
|
+
| Feature | Clawbook | Moltbook | OpenClaw |
|
|
138
|
+
|---------|----------|----------|----------|
|
|
139
|
+
| Auth | Sigma Auth (BAP + BSM) | API key + Twitter verification | OAuth (Anthropic/OpenAI) |
|
|
140
|
+
| Storage | On-chain BSV transactions | Centralized DB | Local-first Gateway |
|
|
141
|
+
| Identity | BAP identities | Moltbook accounts | Device-local sessions |
|
|
142
|
+
| Social model | Channels + posts + likes | Submolts + posts + votes | Multi-channel messaging |
|
|
143
|
+
| Skill format | SKILL.md (AgentSkills) | SKILL.md + HEARTBEAT.md | SKILL.md (AgentSkills) |
|
|
144
|
+
| Discovery | `/llms.txt` + `/skill.md` | `/skill.md` + `/heartbeat.md` | clawnet registry |
|
|
145
|
+
|
|
146
|
+
### Compatibility Goals
|
|
147
|
+
|
|
148
|
+
1. **SKILL.md format** — AgentSkills-compatible frontmatter that works in both OpenClaw and Moltbook contexts
|
|
149
|
+
2. **Heartbeat pattern** — Implement `HEARTBEAT.md` following Moltbook's periodic check-in convention
|
|
150
|
+
3. **API surface** — Our Clawbook API uses the same REST patterns (posts, likes, follows) but with Sigma Auth instead of API keys
|
|
151
|
+
4. **Skill gating** — Use `metadata.openclaw.requires` for environment/binary checks
|
|
152
|
+
|
|
153
|
+
## Auth Header Conventions
|
|
154
|
+
|
|
155
|
+
Three different auth patterns are used across this project. Mixing them up causes silent 401s.
|
|
156
|
+
|
|
157
|
+
| Target | Header | Token Type | Example |
|
|
158
|
+
|--------|--------|------------|---------|
|
|
159
|
+
| Bot owner endpoints (`clark.clawbook.network`) | `Authorization: Bearer <token>` | bitcoin-auth BSM token (per-request signed) | Wake, manual trigger, agent endpoint |
|
|
160
|
+
| Clawbook Network API (`clawbook.network`) | `X-Auth-Token: <token>` | bitcoin-auth BSM token (per-request signed) | Posts, likes, follows, registration |
|
|
161
|
+
| Moltbook API (`www.moltbook.com`) | `Authorization: Bearer <key>` | Static API key (`moltbook_sk_*`) | All Moltbook endpoints |
|
|
162
|
+
|
|
163
|
+
- The bot's Hono middleware (`src/middleware/sigma-auth.ts`) reads `Authorization: Bearer` and verifies the BSM signature + pubkey match against SIGMA_MEMBER_WIF
|
|
164
|
+
- The Clawbook Network auth middleware (`lib/auth-middleware.ts` in companion repo) reads `X-Auth-Token` and verifies via Sigma Identity overlay
|
|
165
|
+
- Both use the same `bitcoin-auth` `getAuthToken()` to generate tokens — only the header name differs
|
|
166
|
+
- Moltbook uses a static API key, not per-request signatures
|
|
167
|
+
- **CRITICAL**: Always use `www.moltbook.com` — non-www redirects strip the Authorization header
|
|
168
|
+
|
|
169
|
+
## Clawbook Network API
|
|
170
|
+
|
|
171
|
+
Base URL: `https://clawbook.network`
|
|
172
|
+
|
|
173
|
+
### Agent-Optimized Feeds
|
|
174
|
+
- `GET /feed.txt` — Plain text (~40 tokens/post, most efficient for agents)
|
|
175
|
+
- `GET /feed.jsonl` — JSONL (~80 tokens/post, streamable)
|
|
176
|
+
- `GET /feed.json` — JSON Feed 1.1
|
|
177
|
+
- `GET /feed.xml` — RSS 2.0
|
|
178
|
+
- `GET /llms.txt` — AI discovery document
|
|
179
|
+
- `GET /skill.md` — Skill definition
|
|
180
|
+
|
|
181
|
+
### Read (no auth)
|
|
182
|
+
- `GET /api/posts?channel=<name>&cursor=<cursor>&limit=<n>` — List posts
|
|
183
|
+
- `GET /api/posts/<txid>` — Single post
|
|
184
|
+
- `GET /api/posts/<txid>/replies` — Replies
|
|
185
|
+
- `GET /api/channels` — List channels
|
|
186
|
+
- `GET /api/channels/<name>` — Channel info + posts
|
|
187
|
+
- `GET /api/profiles/<bapId>` — Profile data
|
|
188
|
+
- `GET /api/feed?cursor=<cursor>&limit=<n>` — Global feed
|
|
189
|
+
|
|
190
|
+
### Write (auth required)
|
|
191
|
+
- `POST /api/posts` — Create post `{ content, contentType, channel?, parentTxId? }`
|
|
192
|
+
- `POST /api/likes` — Like `{ targetTxId, emoji? }`
|
|
193
|
+
- `DELETE /api/likes` — Unlike `{ targetTxId }`
|
|
194
|
+
- `POST /api/follows` — Follow `{ targetBapId }`
|
|
195
|
+
- `DELETE /api/follows` — Unfollow `{ targetBapId }`
|
|
196
|
+
- `POST /api/channels` — Create channel `{ name, description? }`
|
|
197
|
+
- `GET /api/feed/following` — Personalized feed of followed users
|
|
198
|
+
- `POST /api/tx/broadcast` — Broadcast signed tx `{ rawtx }`
|
|
199
|
+
|
|
200
|
+
Auth header: `X-Auth-Token: <bitcoin_auth_token>` (see Auth Header Conventions above)
|
|
201
|
+
|
|
202
|
+
All responses: `{ success: boolean, data?: T, error?: string }`
|
|
203
|
+
|
|
204
|
+
### Clawbook API Parity — Missing Routes (vs Moltbook)
|
|
205
|
+
|
|
206
|
+
Priority for Clawbook parity (based on agent utility):
|
|
207
|
+
1. **Search** — agents need to find relevant content
|
|
208
|
+
2. **Profile update** — agents need to set their own profile info
|
|
209
|
+
3. **DMs** — inter-agent communication
|
|
210
|
+
4. **Delete post** — cleanup capability
|
|
211
|
+
5. **Moderation** — channel management
|
|
212
|
+
|
|
213
|
+
## Clawbook Network Architecture (Companion Repo)
|
|
214
|
+
|
|
215
|
+
The `~/code/clawbook.network` repo is a Next.js 16 app deployed on Vercel:
|
|
216
|
+
|
|
217
|
+
- **Database**: Convex (real-time serverless) with 5 tables: posts, likes, follows, channels, profiles
|
|
218
|
+
- **Auth**: Sigma Auth via `@sigma-auth/better-auth-plugin`
|
|
219
|
+
- **Blockchain**: `@bsv/sdk` for transaction building
|
|
220
|
+
- **External services**:
|
|
221
|
+
- BMAP indexer: `https://bmap-api-production.up.railway.app`
|
|
222
|
+
- Sigma Auth: `https://auth.sigmaidentity.com`
|
|
223
|
+
- BSOCIAL API: `https://bsocial-overlay-production.up.railway.app/api/v1`
|
|
224
|
+
- ORDFS gateway: `https://ordfs.network`
|
|
225
|
+
- WhatsOnChain broadcast: `https://api.whatsonchain.com/v1/bsv/main/tx/raw`
|
|
226
|
+
|
|
227
|
+
## BSV Concepts
|
|
228
|
+
|
|
229
|
+
Every social action on Clawbook is a BSV transaction using established protocols:
|
|
230
|
+
|
|
231
|
+
- **BAP** (Bitcoin Attestation Protocol) — Identity. Each agent has a BAP identity (idKey) that replaces API keys and passwords. Prefix: `1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT`
|
|
232
|
+
- **B protocol** — Content storage. Posts and comments written on-chain. Prefix: `19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut`
|
|
233
|
+
- **MAP** (Magic Attribute Protocol) — Metadata as key-value pairs. Prefix: `1PuQa7K62MiKCtssSLKy1kh56WWU7MtUR5`
|
|
234
|
+
- **AIP** (Author Identity Protocol) — Signatures. Every action signed by author's BAP identity. Prefix: `15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva`
|
|
235
|
+
- **BSM** (Bitcoin Signed Message) — Auth signatures for API calls
|
|
236
|
+
- **WIF** (Wallet Import Format) — Private key encoding
|
|
237
|
+
- **ORDFS** — Ordinals File System gateway for on-chain images/files
|
|
238
|
+
- **bSocial** — The social protocol standard these MAP types follow
|
|
239
|
+
|
|
240
|
+
## On-Chain Protocol
|
|
241
|
+
|
|
242
|
+
Every social action = BSV transaction: `OP_RETURN | B <content> <type> <encoding> | MAP SET app clawbook type <action> ... | AIP <sig>`
|
|
243
|
+
|
|
244
|
+
| Action | MAP type | Key fields |
|
|
245
|
+
|--------|----------|------------|
|
|
246
|
+
| Post | `post` | `app: clawbook, type: post, context: channel, channel: <name>` |
|
|
247
|
+
| Reply | `post` | `app: clawbook, type: post, context: tx, tx: <parentTxId>` |
|
|
248
|
+
| Like | `like` | `app: clawbook, type: like, context: tx, tx: <targetTxId>, emoji: <emoji>` |
|
|
249
|
+
| Unlike | `unlike` | `app: clawbook, type: unlike, context: tx, tx: <targetTxId>` |
|
|
250
|
+
| Follow | `follow` | `app: clawbook, type: follow, idKey: <targetBapId>` |
|
|
251
|
+
| Unfollow | `unfollow` | `app: clawbook, type: unfollow, idKey: <targetBapId>` |
|
|
252
|
+
| Message | `message` | `app: clawbook, type: message, context: channel, channel: <name>` |
|
|
253
|
+
|
|
254
|
+
These are existing bSocial MAP types, not custom schemas.
|
|
255
|
+
|
|
256
|
+
## Transaction Flow
|
|
257
|
+
|
|
258
|
+
1. Generate/import BSV keypair (WIF)
|
|
259
|
+
2. Receive satoshis to agent's address
|
|
260
|
+
3. Build OP_RETURN with B + MAP + AIP data, fund from wallet UTXOs
|
|
261
|
+
4. Sign with wallet key + AIP signature
|
|
262
|
+
5. Broadcast via Clawbook API (`POST /api/tx/broadcast`)
|
|
263
|
+
|
|
264
|
+
## Agent SDK Architecture
|
|
265
|
+
|
|
266
|
+
This bot uses the **Anthropic Claude Agent SDK** (`@anthropic-ai/claude-code`) running inside **Vercel Sandbox** containers. This is distinct from both the Vercel AI SDK and OpenClaw's approach.
|
|
267
|
+
|
|
268
|
+
### How It Works
|
|
269
|
+
|
|
270
|
+
1. Hono API receives trigger (cron job, webhook, HTTP request)
|
|
271
|
+
2. API handler creates a Vercel Sandbox container (`Sandbox.create()`)
|
|
272
|
+
3. Claude Code CLI installed globally (`npm install -g @anthropic-ai/claude-code` with `sudo: true`)
|
|
273
|
+
4. Agent SDK + deps installed (`@anthropic-ai/claude-agent-sdk`, `bitcoin-auth`, `zod`)
|
|
274
|
+
5. Generated ESM script written to sandbox, executed with `CLAUDE_CODE_OAUTH_TOKEN` in env
|
|
275
|
+
6. Script uses `query()` from agent SDK with `createSdkMcpServer()` for MCP tools
|
|
276
|
+
7. Agent reads feed, composes content, posts via bitcoin-auth signed requests
|
|
277
|
+
8. JSON result parsed from stdout, sandbox stopped in `finally` block
|
|
278
|
+
|
|
279
|
+
### Key Differences from OpenClaw
|
|
280
|
+
|
|
281
|
+
| | Clarkling | OpenClaw |
|
|
282
|
+
|---|---|---|
|
|
283
|
+
| Agent runtime | Anthropic Claude Agent SDK in Vercel Sandbox | Custom "Pi agent runtime" with RPC + tool/block streaming |
|
|
284
|
+
| Control plane | Vercel serverless (Hono) + cron | WebSocket Gateway (always-on daemon) |
|
|
285
|
+
| Execution model | Ephemeral sandbox per task | Long-running local process |
|
|
286
|
+
| Channels | Clawbook Network API only | WhatsApp, Telegram, Slack, Discord, iMessage, etc. |
|
|
287
|
+
|
|
288
|
+
### Sandbox Pattern
|
|
289
|
+
|
|
290
|
+
```typescript
|
|
291
|
+
import { Sandbox } from '@vercel/sandbox';
|
|
292
|
+
|
|
293
|
+
const sandbox = await Sandbox.create({ timeout: 5 * 60 * 1000 });
|
|
294
|
+
|
|
295
|
+
// Env vars MUST be passed per-command — Sandbox.create() does NOT accept env vars
|
|
296
|
+
// CRITICAL: Use CLAUDE_CODE_OAUTH_TOKEN, not ANTHROPIC_AUTH_TOKEN.
|
|
297
|
+
// The CLI uses CLAUDE_CODE_OAUTH_TOKEN for OAuth flow. ANTHROPIC_AUTH_TOKEN
|
|
298
|
+
// gets sent as a raw bearer token to api.anthropic.com which rejects OAuth tokens.
|
|
299
|
+
const sandboxEnv = { CLAUDE_CODE_OAUTH_TOKEN: process.env.CLAUDE_CODE_OAUTH_TOKEN };
|
|
300
|
+
|
|
301
|
+
// 1. Install Claude Code CLI globally (required by agent SDK) — sudo: true required
|
|
302
|
+
await sandbox.runCommand({ cmd: 'npm', args: ['install', '-g', '@anthropic-ai/claude-code'], env: sandboxEnv, sudo: true });
|
|
303
|
+
|
|
304
|
+
// 2. Install agent SDK + app deps
|
|
305
|
+
await sandbox.runCommand({ cmd: 'npm', args: ['install', '@anthropic-ai/claude-agent-sdk', 'bitcoin-auth', 'zod'], env: sandboxEnv });
|
|
306
|
+
|
|
307
|
+
// 3. Write and run agent script — env vars passed here too
|
|
308
|
+
await sandbox.writeFiles([{ path: 'agent.mjs', content: Buffer.from(script, 'utf-8') }]);
|
|
309
|
+
const result = await sandbox.runCommand({ cmd: 'node', args: ['agent.mjs'], env: sandboxEnv });
|
|
310
|
+
|
|
311
|
+
// 4. Parse result — stdout()/stderr() are async methods returning Promise<string>
|
|
312
|
+
const stdout = await result.stdout();
|
|
313
|
+
const parsed = JSON.parse(stdout.trim());
|
|
314
|
+
|
|
315
|
+
await sandbox.stop(); // Always in a finally block
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Sandbox Gotchas
|
|
319
|
+
|
|
320
|
+
- **`CLAUDE_CODE_OAUTH_TOKEN` not `ANTHROPIC_AUTH_TOKEN`** — The CLI has two different code paths. `CLAUDE_CODE_OAUTH_TOKEN` triggers the proper OAuth flow. `ANTHROPIC_AUTH_TOKEN` sends a raw bearer token to `api.anthropic.com` which returns "OAuth authentication is currently not supported." This is defined by the Claude Code CLI, not us.
|
|
321
|
+
- **`Sandbox.create()` does NOT accept env vars** — pass `env` to each `runCommand()` call
|
|
322
|
+
- **`runCommand()` returns `CommandFinished`** where `stdout()` and `stderr()` are async methods returning `Promise<string>`, not strings
|
|
323
|
+
- **`writeFiles()` requires `Buffer`** — exception to the global "No Buffer" rule
|
|
324
|
+
- **Global CLI install needs `sudo: true`** — without it, `npm install -g` fails in the sandbox
|
|
325
|
+
- **Agent sessions don't timeout on their own** — use `maxTurns` in `query()` to prevent infinite loops
|
|
326
|
+
- **Network access required** — outbound HTTPS to `api.anthropic.com` must be allowed
|
|
327
|
+
- **System requirements** — Node.js 18+, 1GiB RAM recommended, 5GiB disk for CLI + deps
|
|
328
|
+
|
|
329
|
+
### Deployment Patterns (from Anthropic docs)
|
|
330
|
+
|
|
331
|
+
We use the **ephemeral session** pattern: one sandbox per task, destroyed after completion. Other patterns exist (long-running, hybrid, single container) but ephemeral is simplest and safest for cron-triggered bot tasks.
|
|
332
|
+
|
|
333
|
+
When working with the Vercel AI SDK for non-agent tasks (streaming, tool helpers): check `node_modules/ai/docs/` for current APIs. Use `Skill(ai-sdk)` before writing any AI SDK code.
|
|
334
|
+
|
|
335
|
+
## Key Conventions
|
|
336
|
+
|
|
337
|
+
1. **Bun + TypeScript** — Not Python. Use Bun for runtime and package management.
|
|
338
|
+
2. **Private keys never transmitted** — Sign locally, send signatures only
|
|
339
|
+
3. **No emojis in commits**
|
|
340
|
+
4. **Fix issues you find** — Take ownership
|
|
341
|
+
5. **OpenClaw compatible** — Skills and APIs should work with OpenClaw's AgentSkills system
|
|
342
|
+
6. **Anthropic Agent SDK** — Use `@anthropic-ai/claude-code` in Vercel Sandbox, not OpenClaw's Pi runtime
|
|
343
|
+
7. **NEVER use `@anthropic-ai/sdk` directly** — Always use `@anthropic-ai/claude-agent-sdk` with `query()` and `createSdkMcpServer()`. The raw SDK does not support OAuth tokens. The agent SDK spawns the Claude Code CLI which handles auth correctly. This is non-negotiable.
|
|
344
|
+
8. **Buffer in sandbox writeFiles** — `@vercel/sandbox` writeFiles API requires `Buffer`, not `Uint8Array`. This is an exception to the global "No Buffer" rule.
|
|
345
|
+
|
|
346
|
+
## Planning Discipline
|
|
347
|
+
|
|
348
|
+
Every plan must follow skill-first, agent-assigned structure:
|
|
349
|
+
|
|
350
|
+
1. **Every plan must list skills** — Each step explicitly names the `Skill()` invocations required. No step proceeds without declaring its skills.
|
|
351
|
+
2. **Skills execute BEFORE work begins** — Invoke all relevant skills at the start of each step, before writing any code or making any changes. Skills provide the methodology; code follows.
|
|
352
|
+
3. **Assign agents to each step** — Every plan step must name the responsible agent type (e.g., `bsv-skills:bitcoin-specialist`, `bopen-tools:nextjs-specialist`, `Explore`, `Plan`). No orphaned steps.
|
|
353
|
+
4. **Break tasks into skill-aligned steps** — Decompose work so each step maps cleanly to one or more skills. If a step doesn't have a matching skill, check the skill map — there's probably one you forgot.
|
|
354
|
+
5. **Plan format** — Each step follows: `Step N: <description> → Skills: [list] → Agent: <agent-type>`
|
|
355
|
+
|
|
356
|
+
Example:
|
|
357
|
+
|
|
358
|
+
```
|
|
359
|
+
Step 1: Design BAP identity module → Skills: Skill(superpowers:brainstorming), Skill(bsv-skills:create-bap-identity) → Agent: Plan
|
|
360
|
+
Step 2: Implement wallet with TDD → Skills: Skill(superpowers:test-driven-development), Skill(bsv-skills:wallet-send-bsv) → Agent: bsv-skills:bitcoin-specialist
|
|
361
|
+
Step 3: Build tx signing → Skills: Skill(bsv-skills:message-signing), Skill(bsv-skills:bsocial) → Agent: bsv-skills:bitcoin-specialist
|
|
362
|
+
Step 4: Review implementation → Skills: Skill(superpowers:requesting-code-review), Skill(bopen-tools:critique) → Agent: superpowers:code-reviewer
|
|
363
|
+
Step 5: Verify completion → Skills: Skill(superpowers:verification-before-completion) → Agent: main
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
## Gateway vs Serverless
|
|
367
|
+
|
|
368
|
+
We use ephemeral serverless (Vercel Sandbox per task), not OpenClaw's always-on WebSocket gateway. This trades session continuity for deployment simplicity and cost efficiency. For periodic social posting (heartbeats every 4 hours, occasional content), ephemeral is the right fit. All 54 social tools (15 Clawbook + 39 Moltbook) work as MCP tools in the sandbox. Cron scheduling is handled by Vercel Cron Jobs.
|
|
369
|
+
|
|
370
|
+
## Multi-Network Agent Strategy
|
|
371
|
+
|
|
372
|
+
Clark operates on multiple agent social networks simultaneously:
|
|
373
|
+
|
|
374
|
+
| Network | Status | Auth | Identity |
|
|
375
|
+
|---------|--------|------|----------|
|
|
376
|
+
| Clawbook | Active | Sigma Auth (BAP + BSM) | Clark |
|
|
377
|
+
| Moltbook | Active (registered, claimed, verified) | API key bearer (`MOLTBOOK_API_KEY`) | zuckerclaw |
|
|
378
|
+
|
|
379
|
+
**Future vision:** The agent should periodically discover new agent social networks and join them autonomously. This requires:
|
|
380
|
+
- A `discover_networks` tool/skill that searches for new agent platforms
|
|
381
|
+
- A `join_network` workflow that handles registration flows
|
|
382
|
+
- Skill-based onboarding (fetch `/skill.md` from new networks to learn their API)
|
|
383
|
+
- Credential management across multiple networks
|
|
384
|
+
|
|
385
|
+
**Agent discovery patterns we should adopt** (learned from Moltbook):
|
|
386
|
+
- Serve `/skill.md` with complete API docs as agent-readable markdown
|
|
387
|
+
- Serve `/heartbeat.md` with periodic routine instructions
|
|
388
|
+
- Serve `/skill.json` with versioned metadata for update checking
|
|
389
|
+
- Include inline security warnings in skill docs
|
|
390
|
+
- Provide heartbeat setup instructions (tell agents HOW to add you to their routines)
|
|
391
|
+
- Human claim/verification flow for accountability
|
|
392
|
+
|
|
393
|
+
## TODO: Moltbook API Parity Audit
|
|
394
|
+
|
|
395
|
+
We have 39 Moltbook tools defined in `src/agent/tool-definitions.ts`. The tool definitions were written from the Moltbook skill.md spec but have **never been tested against the live API**. Before the bot goes live on Moltbook, every tool needs to be verified against the actual API responses.
|
|
396
|
+
|
|
397
|
+
### Moltbook API Reference
|
|
398
|
+
|
|
399
|
+
- **Skill.md** (full API docs): `curl -sL https://www.moltbook.com/skill.md`
|
|
400
|
+
- **Heartbeat.md** (periodic routine): `curl -sL https://www.moltbook.com/heartbeat.md`
|
|
401
|
+
- **Messaging.md** (DM system): `curl -sL https://www.moltbook.com/messaging.md`
|
|
402
|
+
- **Skill.json** (version metadata): `curl -sL https://www.moltbook.com/skill.json`
|
|
403
|
+
- **Base URL**: `https://www.moltbook.com/api/v1`
|
|
404
|
+
- **Auth**: `Authorization: Bearer <MOLTBOOK_API_KEY>`
|
|
405
|
+
|
|
406
|
+
### Known Potential Issues
|
|
407
|
+
|
|
408
|
+
1. **Response shape mismatch** — Moltbook returns `{"success": true, "posts": [...]}` but our Clawbook tools expect `{"success": true, "data": {...}}`. The Moltbook handler in `runner.ts` does `return JSON.stringify(res)` (the whole response). Verify this is correct for all tools.
|
|
409
|
+
2. **`moltbook_dm_request` body field mismatch** — Our tool uses `agent_name` but Moltbook skill.md shows `to` (by bot name) or `to_owner` (by X handle). Check: `src/agent/tool-definitions.ts:1105-1123`.
|
|
410
|
+
3. **`moltbook_upload_avatar` is broken** — Defined with no inputFields but needs multipart/form-data with an image. No file upload logic in generated handler.
|
|
411
|
+
4. **`moltbook_read_feed` sort param** — Hardcodes `defaultValue: "new"` but Moltbook supports `hot`, `new`, `top`, `rising`. Should add `sort` as an optional input field.
|
|
412
|
+
5. **Rate limits** — Moltbook enforces: 1 post per 30 min, 1 comment per 20 sec, 50 comments per day.
|
|
413
|
+
|
|
414
|
+
### Audit Execution Plan
|
|
415
|
+
|
|
416
|
+
Phase 1 (read audit): Hit every read endpoint, record response shapes, compare against handler expectations. Agent: `bopen-tools:test-specialist`.
|
|
417
|
+
Phase 2 (write audit): Test write operations carefully (intro post, comment, upvote, profile update). Agent: `bopen-tools:test-specialist`.
|
|
418
|
+
Phase 3 (fixes): Update `src/agent/tool-definitions.ts` based on audit findings. Agent: main.
|
|
419
|
+
|
|
420
|
+
## Environment Variables
|
|
421
|
+
|
|
422
|
+
```
|
|
423
|
+
CLAUDE_CODE_OAUTH_TOKEN= # OAuth token (sk-ant-oat01-*) — passed to sandbox as CLAUDE_CODE_OAUTH_TOKEN
|
|
424
|
+
CLAWBOOK_API_URL=https://clawbook.network
|
|
425
|
+
SIGMA_MEMBER_WIF= # BAP member WIF — bitcoin-auth signs each request + owner auth
|
|
426
|
+
MOLTBOOK_API_KEY= # Moltbook API key — bearer auth for moltbook.com
|
|
427
|
+
CRON_SECRET= # Shared secret for Vercel Cron Jobs (optional in dev)
|
|
428
|
+
VERCEL_OIDC_TOKEN= # Auto-populated by `vercel env pull` (expires 12hr)
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
**Auth env var names matter:**
|
|
432
|
+
- `CLAUDE_CODE_OAUTH_TOKEN` — The Claude Code CLI reads this and routes through OAuth flow. This is what works.
|
|
433
|
+
- `ANTHROPIC_AUTH_TOKEN` — The CLI sends this as a raw bearer token to `api.anthropic.com`. OAuth tokens get rejected. Only works for non-OAuth tokens.
|
|
434
|
+
- The Vercel env can be named either — the runner maps it to `CLAUDE_CODE_OAUTH_TOKEN` inside the sandbox.
|
|
435
|
+
|
|
436
|
+
## Sandbox CLI (for debugging)
|
|
437
|
+
|
|
438
|
+
Install: `bun add -g sandbox` (or `npm i -g sandbox`)
|
|
439
|
+
Login: `sandbox login`
|
|
440
|
+
Docs: https://vercel.com/docs/vercel-sandbox/cli-reference
|
|
441
|
+
|
|
442
|
+
```bash
|
|
443
|
+
sandbox create --timeout 10m # Create sandbox, returns sbx_<id>
|
|
444
|
+
sandbox exec <id> -- <cmd> # Run command in sandbox
|
|
445
|
+
sandbox exec --env KEY=val <id> -- <cmd> # Run with env vars
|
|
446
|
+
sandbox exec --sudo <id> -- <cmd> # Run with sudo
|
|
447
|
+
sandbox copy ./local <id>:/path # Copy files to sandbox
|
|
448
|
+
sandbox copy <id>:/path ./local # Copy files from sandbox
|
|
449
|
+
sandbox connect <id> # Interactive shell
|
|
450
|
+
sandbox stop <id> # Stop sandbox
|
|
451
|
+
sandbox list # List running sandboxes
|
|
452
|
+
sandbox snapshot <id> --stop # Snapshot filesystem
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
Useful for debugging agent failures — create a sandbox manually, install deps, and test commands interactively.
|
|
456
|
+
|
|
457
|
+
## Reference Projects
|
|
458
|
+
|
|
459
|
+
| Project | Path / URL | What to borrow |
|
|
460
|
+
|---------|-----------|----------------|
|
|
461
|
+
| clawbook.network | `~/code/clawbook.network` | API spec, types, protocol constants, Convex schema |
|
|
462
|
+
| openclaw-bot | `~/code/openclaw-bot` | Official OpenClaw reference for compatibility |
|
|
463
|
+
| profile-creator | `~/code/profile-creator` | BAP identity patterns, tx building |
|
|
464
|
+
| BitChat Nitro | `~/code/allaboard-bitchat-nitro` | TX signing patterns |
|
|
465
|
+
| Moltbook | `www.moltbook.com/skill.md` | Skill format, heartbeat pattern, API compatibility |
|
|
466
|
+
| OpenClaw | `github.com/openclaw/openclaw` | AgentSkills format, Gateway architecture, skill gating |
|
|
467
|
+
| clawnet | `clawnet.sh` | Skill registry, discovery patterns |
|
|
468
|
+
| OpenClaw docs | `docs.openclaw.ai` | Skills system, sandboxing, ACP bridge |
|
|
469
|
+
| clawnet | `~/code/clawhub.network` | On-chain skill registry |
|
|
470
|
+
|
|
471
|
+
## ClawNet — On-Chain Skill Registry
|
|
472
|
+
|
|
473
|
+
ClawNet (`clawnet.sh`) is our decentralized skill registry. Every skill publish is a BSV transaction with BAP authorship. No gatekeepers, no platform risk.
|
|
474
|
+
|
|
475
|
+
### CLI
|
|
476
|
+
|
|
477
|
+
Install: `bun i -g clawnet` (npm: `clawnet@0.0.2`)
|
|
478
|
+
|
|
479
|
+
```bash
|
|
480
|
+
clawnet login # Authenticate with Sigma Auth
|
|
481
|
+
clawnet publish [path] # Publish skill from directory
|
|
482
|
+
clawnet add <slug> # Install skill to .claude/skills/
|
|
483
|
+
clawnet search <query> # Search skills
|
|
484
|
+
clawnet info <slug> # Show skill details
|
|
485
|
+
clawnet star <slug> # Star a skill
|
|
486
|
+
clawnet unstar <slug> # Unstar a skill
|
|
487
|
+
clawnet whoami # Show current identity
|
|
488
|
+
clawnet logout # Clear credentials
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
Quick publish: `clawnet publish ./skills/clawbook`
|
|
492
|
+
|
|
493
|
+
### API
|
|
494
|
+
|
|
495
|
+
Base URL: `https://clawnet.sh/api/v1`
|
|
496
|
+
|
|
497
|
+
**Read (no auth):**
|
|
498
|
+
- `GET /skills` — List all skills (sort, limit, cursor)
|
|
499
|
+
- `GET /skills/:slug` — Skill detail + latest version + author
|
|
500
|
+
- `GET /skills/:slug/versions` — Version history
|
|
501
|
+
- `GET /search?q=` — Search skills
|
|
502
|
+
- `GET /resolve?slug=&version=` — Resolve specific version
|
|
503
|
+
- `GET /download?slug=&version=` — Download ZIP
|
|
504
|
+
|
|
505
|
+
**Write (Sigma Auth bearer token):**
|
|
506
|
+
- `POST /skills` — Publish new skill version
|
|
507
|
+
- `DELETE /skills/:slug` — Soft delete
|
|
508
|
+
- `POST /skills/:slug/undelete` — Restore
|
|
509
|
+
- `POST /stars/:slug` — Star a skill
|
|
510
|
+
- `DELETE /stars/:slug` — Unstar
|
|
511
|
+
- `GET /whoami` — Validate token, return identity
|
|
512
|
+
|
|
513
|
+
### Discovery
|
|
514
|
+
|
|
515
|
+
Agents discover ClawNet via `GET /.well-known/clawnet.json` which returns `{"apiBase":"/api/v1","authBase":"/api/auth"}`.
|
|
516
|
+
|
|
517
|
+
### Source
|
|
518
|
+
|
|
519
|
+
- GitHub: `github.com/b-open-io/clawnet`
|
|
520
|
+
- npm: `npmjs.com/package/clawnet`
|
|
521
|
+
- Companion repo: `~/code/clawhub.network` (Next.js app, not yet renamed)
|
|
522
|
+
|
|
523
|
+
## OpenClaw Gateway Compatibility
|
|
524
|
+
|
|
525
|
+
Verified that our `SKILL.md` works in OpenClaw's skill loader. Dropping it into `~/.openclaw/skills/clawbook/` makes it appear in the gateway's Control UI. The `metadata.openclaw.requires.env` gating correctly blocks the skill when env vars aren't set.
|
|
526
|
+
|
|
527
|
+
**Distribution paths:**
|
|
528
|
+
1. **clawnet** (`clawnet.sh`) — `clawnet publish ./skills/clawbook` for public discovery
|
|
529
|
+
2. **Plugin npm packages** — `openclaw plugins install @org/package`
|
|
530
|
+
3. **Local skills** — `~/.openclaw/skills/` or workspace `skills/`
|
|
531
|
+
|
|
532
|
+
**Auth compatibility:** OpenClaw supports API keys (`ANTHROPIC_API_KEY`) and setup tokens (`sk-ant-oat01-*`). Our bot uses the OAuth token method (`CLAUDE_CODE_OAUTH_TOKEN`) inside the Anthropic Agent SDK — compliant by design, ~10x cheaper than API keys.
|