mlclaw 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.
- package/.agents/skills/mlclaw/SKILL.md +214 -0
- package/.agents/skills/mlclaw/agents/openai.yaml +4 -0
- package/.gitattributes +35 -0
- package/Dockerfile +45 -0
- package/LICENSE +21 -0
- package/README.md +206 -0
- package/assets/mlclaw.svg +143 -0
- package/dist/hf-state-sync.js +9532 -0
- package/dist/mlclaw-space-runtime.js +5010 -0
- package/dist/mlclaw.mjs +16502 -0
- package/entrypoint.sh +87 -0
- package/mlclaw.ps1 +108 -0
- package/mlclaw.sh +117 -0
- package/openclaw.default.json +67 -0
- package/package.json +66 -0
- package/scripts/configure-huggingface-model.mjs +86 -0
- package/scripts/configure-telegram.mjs +55 -0
- package/scripts/report-telegram-probe.mjs +18 -0
- package/space/README.md +42 -0
- package/src/hf-bucket-client/client.ts +217 -0
- package/src/hf-state-sync/archive.ts +137 -0
- package/src/hf-state-sync/cli.ts +92 -0
- package/src/hf-state-sync/hub.ts +81 -0
- package/src/hf-state-sync/manifest.ts +67 -0
- package/src/hf-state-sync/paths.ts +73 -0
- package/src/hf-state-sync/restore.ts +109 -0
- package/src/hf-state-sync/snapshot.ts +133 -0
- package/src/hf-state-sync/sqlite.ts +57 -0
- package/src/hf-state-sync/supervise.ts +256 -0
- package/src/vendor/hfjs-xet/error.ts +52 -0
- package/src/vendor/hfjs-xet/types/public.ts +207 -0
- package/src/vendor/hfjs-xet/utils/ChunkCache.ts +102 -0
- package/src/vendor/hfjs-xet/utils/RangeList.ts +182 -0
- package/src/vendor/hfjs-xet/utils/SplicedBlob.ts +249 -0
- package/src/vendor/hfjs-xet/utils/XetBlob.ts +732 -0
- package/src/vendor/hfjs-xet/utils/checkCredentials.ts +21 -0
- package/src/vendor/hfjs-xet/utils/combineUint8Arrays.ts +13 -0
- package/src/vendor/hfjs-xet/utils/createXorbs.ts +782 -0
- package/src/vendor/hfjs-xet/utils/shardParser.ts +152 -0
- package/src/vendor/hfjs-xet/utils/sum.ts +9 -0
- package/src/vendor/hfjs-xet/utils/uploadShards.ts +443 -0
- package/src/vendor/hfjs-xet/utils/xetWriteToken.ts +101 -0
- package/src/vendor/hfjs-xet/vendor/lz4js/index.ts +540 -0
- package/src/vendor/hfjs-xet/vendor/lz4js/util.ts +57 -0
- package/src/vendor/hfjs-xet/vendor/lz4js/xxh32.ts +99 -0
- package/src/vendor/hfjs-xet/vendor/type-fest/basic.ts +34 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mlclaw
|
|
3
|
+
description: Use when setting up, operating, migrating, repairing, or explaining an OpenClaw deployment on Hugging Face with the ML Claw `mlclaw` CLI. Covers the browser Space gateway, Hugging Face OAuth, local gateway mode, private Storage Buckets, Telegram as an optional connector, Docker context pinning, model selection through the Hugging Face Router, OpenAI API key setup, costs, diagnostics, and state safety.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ML Claw
|
|
7
|
+
|
|
8
|
+
## Core Rule
|
|
9
|
+
|
|
10
|
+
Use the `mlclaw` CLI as the source of truth. Do not hand-create Hugging Face
|
|
11
|
+
Spaces, buckets, secrets, or Docker containers unless debugging a failed
|
|
12
|
+
`mlclaw` operation. Keep credentials local to the user's machine.
|
|
13
|
+
|
|
14
|
+
Default to the browser Space gateway unless the user explicitly asks for local
|
|
15
|
+
gateway mode.
|
|
16
|
+
|
|
17
|
+
## What ML Claw Creates
|
|
18
|
+
|
|
19
|
+
An ML Claw deployment has:
|
|
20
|
+
|
|
21
|
+
- a private Hugging Face Storage Bucket for durable OpenClaw state snapshots;
|
|
22
|
+
- a private Hugging Face Docker Space for the default browser gateway;
|
|
23
|
+
- Hugging Face OAuth enabled on the Space;
|
|
24
|
+
- a local deployment manifest under `~/.config/mlclaw/deployments/`;
|
|
25
|
+
- local secrets under `~/.config/mlclaw/secrets/`;
|
|
26
|
+
- optional local Docker gateway mode for users who want the gateway on their
|
|
27
|
+
own machine;
|
|
28
|
+
- Hugging Face Router model configuration for OpenClaw inference.
|
|
29
|
+
|
|
30
|
+
The bucket is the durable state source. The live gateway is disposable. Do not
|
|
31
|
+
mount a bucket as the live OpenClaw database filesystem.
|
|
32
|
+
|
|
33
|
+
## Required Inputs
|
|
34
|
+
|
|
35
|
+
Collect or confirm:
|
|
36
|
+
|
|
37
|
+
- Hugging Face token access: `HF_TOKEN`, `HF_TOKEN_PATH`, `$HF_HOME/token`, or
|
|
38
|
+
`hf auth login`.
|
|
39
|
+
- Agent name, unless a Telegram bot token is supplied and the user wants the
|
|
40
|
+
name derived from the bot username.
|
|
41
|
+
- Gateway mode:
|
|
42
|
+
- `space`: default browser gateway, private Space, HF OAuth protected.
|
|
43
|
+
- `local`: Docker gateway on the user's machine.
|
|
44
|
+
- Optional model override.
|
|
45
|
+
- Optional Docker context for local mode.
|
|
46
|
+
- Optional Telegram bot token and allowed user ID.
|
|
47
|
+
- Optional explicit owner, name, or bucket only when the user needs them.
|
|
48
|
+
|
|
49
|
+
If a Telegram token is provided, ML Claw calls Telegram `getMe`, removes a
|
|
50
|
+
trailing `_bot` from the bot username, and can derive the agent, bucket, and
|
|
51
|
+
Space names from that.
|
|
52
|
+
|
|
53
|
+
## Install And Run
|
|
54
|
+
|
|
55
|
+
With Node.js:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npx mlclaw bootstrap --name research
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Without Node.js on macOS/Linux:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
bash <(curl -fsSL https://raw.githubusercontent.com/osolmaz/mlclaw/main/mlclaw.sh) --name research
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
On Windows PowerShell:
|
|
68
|
+
|
|
69
|
+
```powershell
|
|
70
|
+
irm https://raw.githubusercontent.com/osolmaz/mlclaw/main/mlclaw.ps1 | iex
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
For repo-local development, use:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npm install
|
|
77
|
+
npm run build
|
|
78
|
+
node dist/mlclaw.mjs --help
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Recommended First Setup: Browser Space Gateway
|
|
82
|
+
|
|
83
|
+
Interactive:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npx mlclaw bootstrap --name research
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Automation:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npx mlclaw bootstrap \
|
|
93
|
+
--name research \
|
|
94
|
+
--model huggingface/google/gemma-4-26B-A4B-it \
|
|
95
|
+
--yes
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
After the Space builds, open it in the browser and sign in with the user's
|
|
99
|
+
Hugging Face account. The Space server proxies authenticated browser traffic to
|
|
100
|
+
OpenClaw on loopback using trusted-proxy auth. Do not ask the user for an
|
|
101
|
+
OpenClaw gateway token for the browser Space path.
|
|
102
|
+
|
|
103
|
+
Create a public Space only when the user explicitly asks for a public demo or
|
|
104
|
+
template-style deployment:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npx mlclaw bootstrap --name research --public-space
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Optional Telegram
|
|
111
|
+
|
|
112
|
+
Telegram is optional and should not be required for the default setup.
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
npx mlclaw bootstrap \
|
|
116
|
+
--telegram-token-file ~/secrets/research_bot.env \
|
|
117
|
+
--telegram-user-id 1234567890 \
|
|
118
|
+
--hardware cpu-upgrade \
|
|
119
|
+
--sleep-time -1
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Free Hugging Face Spaces intentionally block outbound TLS to some messaging
|
|
123
|
+
APIs for anti-abuse reasons. Telegram/Discord connectivity from a Space
|
|
124
|
+
requires upgraded paid Space hardware today. Local gateway mode avoids that
|
|
125
|
+
restriction because messaging traffic originates from the user's machine.
|
|
126
|
+
|
|
127
|
+
## Local Gateway Mode
|
|
128
|
+
|
|
129
|
+
Use local gateway mode when the user wants the gateway on their machine:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
npx mlclaw bootstrap --gateway local --name research
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
If the user has multiple Docker engines, pin the intended context:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
npx mlclaw bootstrap \
|
|
139
|
+
--gateway local \
|
|
140
|
+
--name research \
|
|
141
|
+
--docker-context desktop-linux
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Common Docker contexts on macOS are `desktop-linux`, `colima`, and `orbstack`.
|
|
145
|
+
After bootstrap, local gateway commands use the pinned context from the
|
|
146
|
+
manifest even if the shell's current Docker context changes.
|
|
147
|
+
|
|
148
|
+
## Model Selection
|
|
149
|
+
|
|
150
|
+
The `--model` value is the OpenClaw model identifier. For Hugging Face Router
|
|
151
|
+
models, use the `huggingface/` prefix.
|
|
152
|
+
|
|
153
|
+
Default/recommended:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
npx mlclaw bootstrap \
|
|
157
|
+
--name research \
|
|
158
|
+
--model huggingface/google/gemma-4-26B-A4B-it
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Known useful router-compatible choices:
|
|
162
|
+
|
|
163
|
+
- `huggingface/google/gemma-4-26B-A4B-it`: default quality target.
|
|
164
|
+
- `huggingface/Qwen/Qwen3.6-35B-A3B`: stronger Qwen option with tool support.
|
|
165
|
+
- `huggingface/Qwen/Qwen3-8B`: cheaper small-model option.
|
|
166
|
+
|
|
167
|
+
Do not assume every Hub model is a Router chat model. If exact current model
|
|
168
|
+
availability matters, check the Hugging Face Router catalog or run a direct
|
|
169
|
+
chat-completions probe.
|
|
170
|
+
|
|
171
|
+
## Operating A Deployment
|
|
172
|
+
|
|
173
|
+
Check status:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
mlclaw gateway status <agent>
|
|
177
|
+
mlclaw doctor <owner/space>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Update a Space:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
mlclaw update <owner/space>
|
|
184
|
+
mlclaw doctor <owner/space> --fix
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Move gateway location without losing state:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
mlclaw gateway migrate <agent> --to local
|
|
191
|
+
mlclaw gateway migrate <agent> --to space
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Local gateway lifecycle:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
mlclaw gateway logs <agent>
|
|
198
|
+
mlclaw gateway stop <agent>
|
|
199
|
+
mlclaw gateway start <agent>
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## OpenAI Credentials
|
|
203
|
+
|
|
204
|
+
After signing into the Space, use `/mlclaw/openai` to submit an OpenAI API key.
|
|
205
|
+
The key is stored as a Hugging Face Space Secret when possible and as a 0600
|
|
206
|
+
runtime file for immediate use. The key must never be logged or returned to
|
|
207
|
+
the browser.
|
|
208
|
+
|
|
209
|
+
## State Safety
|
|
210
|
+
|
|
211
|
+
OpenClaw uses local disk. The bucket stores verified snapshots only. On boot,
|
|
212
|
+
the runtime restores the newest valid snapshot. During runtime and shutdown,
|
|
213
|
+
`hf-state-sync` uploads new snapshots. Secrets are kept outside the snapshot
|
|
214
|
+
path.
|
package/.gitattributes
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
|
2
|
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
|
3
|
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
|
4
|
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
|
5
|
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
|
6
|
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
|
7
|
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
|
8
|
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
|
9
|
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
|
10
|
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
|
11
|
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
|
12
|
+
*.model filter=lfs diff=lfs merge=lfs -text
|
|
13
|
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
|
14
|
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
|
15
|
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
|
16
|
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
|
17
|
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
|
18
|
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
|
19
|
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
|
20
|
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
|
21
|
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
|
22
|
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
|
23
|
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
|
24
|
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
|
25
|
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
|
26
|
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
27
|
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
|
28
|
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
|
29
|
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
|
30
|
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
|
31
|
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
|
32
|
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
|
33
|
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
|
34
|
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
|
35
|
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
package/Dockerfile
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Stage 1: build the state-sync bundle so the runtime image needs no dev deps.
|
|
2
|
+
FROM node:24-bookworm-slim AS sync-build
|
|
3
|
+
WORKDIR /build
|
|
4
|
+
COPY package.json package-lock.json tsconfig.json ./
|
|
5
|
+
COPY src ./src
|
|
6
|
+
RUN npm ci --no-audit --no-fund && npm run build
|
|
7
|
+
|
|
8
|
+
FROM ghcr.io/openclaw/openclaw:latest
|
|
9
|
+
|
|
10
|
+
LABEL org.opencontainers.image.source="https://github.com/osolmaz/mlclaw"
|
|
11
|
+
LABEL org.opencontainers.image.description="ML Claw runtime for OpenClaw on Hugging Face"
|
|
12
|
+
|
|
13
|
+
USER root
|
|
14
|
+
# zstd: snapshot archives. gosu: drop privileges after preparing mounted volumes.
|
|
15
|
+
RUN apt-get update \
|
|
16
|
+
&& apt-get install -y --no-install-recommends gosu zstd \
|
|
17
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
18
|
+
|
|
19
|
+
COPY --from=sync-build /build/dist/hf-state-sync.js /app/hf-state-sync.js
|
|
20
|
+
COPY --from=sync-build /build/dist/mlclaw-space-runtime.js /app/mlclaw-space-runtime.js
|
|
21
|
+
COPY --chown=node:node openclaw.default.json /app/openclaw.default.json
|
|
22
|
+
COPY --chown=node:node entrypoint.sh /app/entrypoint.sh
|
|
23
|
+
COPY --chown=node:node assets/ /app/assets/
|
|
24
|
+
COPY --chown=node:node scripts/ /app/scripts/
|
|
25
|
+
RUN chmod +x /app/entrypoint.sh
|
|
26
|
+
|
|
27
|
+
USER root
|
|
28
|
+
|
|
29
|
+
# Live state on local disk; the bucket is reached only through the TS client.
|
|
30
|
+
ENV PORT=7860
|
|
31
|
+
ENV MLCLAW_OPENCLAW_PORT=7861
|
|
32
|
+
ENV OPENCLAW_GATEWAY_PORT=7861
|
|
33
|
+
ENV OPENCLAW_LIVE_DIR=/tmp/openclaw-live
|
|
34
|
+
ENV OPENCLAW_STATE_DIR=/tmp/openclaw-live/.openclaw
|
|
35
|
+
ENV OPENCLAW_WORKSPACE_DIR=/tmp/openclaw-live/workspace
|
|
36
|
+
ENV OPENCLAW_CONFIG_PATH=/tmp/openclaw-live/.openclaw/openclaw.json
|
|
37
|
+
ENV OPENCLAW_DISABLE_BONJOUR=1
|
|
38
|
+
ARG MLCLAW_RUNTIME_IMAGE=ghcr.io/osolmaz/mlclaw-runtime:latest
|
|
39
|
+
ENV MLCLAW_RUNTIME_IMAGE=$MLCLAW_RUNTIME_IMAGE
|
|
40
|
+
|
|
41
|
+
EXPOSE 7860
|
|
42
|
+
|
|
43
|
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=5 CMD node -e "const port=process.env.PORT||'7860'; fetch('http://127.0.0.1:'+port+'/health').then((r)=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
|
|
44
|
+
|
|
45
|
+
CMD ["/app/entrypoint.sh"]
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Onur Solmaz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/osolmaz/mlclaw/main/assets/mlclaw.svg" alt="ML Claw" width="180">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# ML Claw
|
|
6
|
+
|
|
7
|
+
ML Claw deploys an OpenClaw agent on Hugging Face with durable state in a
|
|
8
|
+
private Storage Bucket. The default deployment is a private Hugging Face Space
|
|
9
|
+
with a browser gateway protected by Hugging Face OAuth.
|
|
10
|
+
|
|
11
|
+
The browser never receives an OpenClaw gateway token. ML Claw authenticates the
|
|
12
|
+
signed-in Hugging Face user, then proxies HTTP and WebSocket traffic to
|
|
13
|
+
OpenClaw on loopback using OpenClaw trusted-proxy auth.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
With Node.js:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx mlclaw bootstrap
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Without Node.js, the launcher fetches a pinned Node runtime into your user
|
|
24
|
+
cache and runs the same npm package:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
bash <(curl -fsSL https://raw.githubusercontent.com/osolmaz/mlclaw/main/mlclaw.sh)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
On Windows:
|
|
31
|
+
|
|
32
|
+
```powershell
|
|
33
|
+
irm https://raw.githubusercontent.com/osolmaz/mlclaw/main/mlclaw.ps1 | iex
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
You need a Hugging Face account and a token available through `HF_TOKEN`,
|
|
37
|
+
`HF_TOKEN_PATH`, `$HF_HOME/token`, or `hf auth login`. You never paste that
|
|
38
|
+
token into someone else's app; the bootstrapper runs locally.
|
|
39
|
+
|
|
40
|
+
## Default Flow
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npx mlclaw bootstrap --name research
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This creates:
|
|
47
|
+
|
|
48
|
+
- a private Storage Bucket for OpenClaw state;
|
|
49
|
+
- a private Docker Space for the browser gateway;
|
|
50
|
+
- a self-contained Space runtime generated from the installed `mlclaw` package;
|
|
51
|
+
- Hugging Face OAuth metadata in the Space README;
|
|
52
|
+
- Space variables and write-only secrets for state sync and session signing;
|
|
53
|
+
- a local deployment manifest under `~/.config/mlclaw`.
|
|
54
|
+
|
|
55
|
+
Open the Space, sign in with your Hugging Face account, and use the OpenClaw
|
|
56
|
+
browser gateway directly.
|
|
57
|
+
|
|
58
|
+
Create a public Space only when you explicitly want a public demo or template:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npx mlclaw bootstrap --name research --public-space
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Choose a Hugging Face Router model with `--model`:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npx mlclaw bootstrap \
|
|
68
|
+
--name research \
|
|
69
|
+
--model huggingface/google/gemma-4-26B-A4B-it
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Recommended router-compatible options:
|
|
73
|
+
|
|
74
|
+
- `huggingface/google/gemma-4-26B-A4B-it`: default quality target.
|
|
75
|
+
- `huggingface/Qwen/Qwen3.6-35B-A3B`: stronger Qwen option with tool support.
|
|
76
|
+
- `huggingface/Qwen/Qwen3-8B`: cheaper small-model option.
|
|
77
|
+
|
|
78
|
+
## Optional Telegram
|
|
79
|
+
|
|
80
|
+
Telegram is optional. If you provide a Telegram bot token, ML Claw calls
|
|
81
|
+
Telegram `getMe`, removes a trailing `_bot` from the username, and can derive
|
|
82
|
+
the Space and bucket names from the bot username.
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npx mlclaw bootstrap \
|
|
86
|
+
--telegram-token-file ~/secrets/research_bot.env \
|
|
87
|
+
--telegram-user-id 1234567890 \
|
|
88
|
+
--hardware cpu-upgrade \
|
|
89
|
+
--sleep-time -1
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Hugging Face free Spaces intentionally block outbound TLS to some messaging
|
|
93
|
+
APIs. Telegram/Discord connectivity therefore requires upgraded paid Space
|
|
94
|
+
hardware today. ML Claw warns before requesting paid hardware; pass `--yes`
|
|
95
|
+
only for automation.
|
|
96
|
+
|
|
97
|
+
## Local Gateway Mode
|
|
98
|
+
|
|
99
|
+
You can run the gateway locally instead of inside a Space:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npx mlclaw bootstrap --gateway local --name research
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Local mode uses Docker on your machine and the same private Storage Bucket.
|
|
106
|
+
It avoids Hugging Face messaging egress limits because Telegram traffic comes
|
|
107
|
+
from your network.
|
|
108
|
+
|
|
109
|
+
Move between local and Space without losing state:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
mlclaw gateway migrate research --to local
|
|
113
|
+
mlclaw gateway migrate research --to space
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Useful operations:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
mlclaw gateway status research
|
|
120
|
+
mlclaw gateway logs research
|
|
121
|
+
mlclaw gateway stop research
|
|
122
|
+
mlclaw gateway start research
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Local Docker deployments are pinned to the Docker context used at bootstrap
|
|
126
|
+
time. Rebind explicitly if you move between Docker Desktop, OrbStack, Colima,
|
|
127
|
+
or another Docker engine:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
mlclaw gateway rebind research --docker-context desktop-linux
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Update and Repair
|
|
134
|
+
|
|
135
|
+
Update an existing Space to the current ML Claw implementation:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
mlclaw update your-hf-username/research
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Check a deployment and apply safe configuration repairs:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
mlclaw doctor your-hf-username/research
|
|
145
|
+
mlclaw doctor your-hf-username/research --fix
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
`doctor --fix` may update Space variables and missing session-secret plumbing.
|
|
149
|
+
It never reads secret values and never modifies bucket contents.
|
|
150
|
+
|
|
151
|
+
`mlclaw update` also refreshes the generated Space runtime files, so older
|
|
152
|
+
Spaces can move to the current implementation without recreating their bucket.
|
|
153
|
+
|
|
154
|
+
## OpenAI Credentials
|
|
155
|
+
|
|
156
|
+
After signing into the Space, open:
|
|
157
|
+
|
|
158
|
+
```text
|
|
159
|
+
/mlclaw/openai
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Submit an OpenAI API key there if you want OpenClaw to use OpenAI-compatible
|
|
163
|
+
models. ML Claw stores the key as a Hugging Face Space Secret when possible,
|
|
164
|
+
writes a 0600 runtime file for immediate use, and restarts the internal
|
|
165
|
+
OpenClaw gateway with `OPENAI_API_KEY` set. The key is never returned to the
|
|
166
|
+
browser.
|
|
167
|
+
|
|
168
|
+
## How State Works
|
|
169
|
+
|
|
170
|
+
OpenClaw runs against local disk inside the active runtime. The Storage Bucket
|
|
171
|
+
is not mounted as a live filesystem. Instead, `hf-state-sync` restores the
|
|
172
|
+
newest verified snapshot on boot and uploads verified snapshots during runtime
|
|
173
|
+
and shutdown.
|
|
174
|
+
|
|
175
|
+
That keeps SQLite off network-mounted storage while preserving the agent's
|
|
176
|
+
memory across Space rebuilds, local container replacement, and gateway
|
|
177
|
+
migration.
|
|
178
|
+
|
|
179
|
+
## Costs
|
|
180
|
+
|
|
181
|
+
- Browser Space gateway: `cpu-basic` is enough for the default browser gateway.
|
|
182
|
+
- Telegram/Discord from a Space: requires paid upgraded Space hardware today.
|
|
183
|
+
- Inference: requests use your Hugging Face Inference Providers credits, then
|
|
184
|
+
provider pay-as-you-go pricing.
|
|
185
|
+
|
|
186
|
+
## Development
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
npm install
|
|
190
|
+
npm run build
|
|
191
|
+
npm run typecheck
|
|
192
|
+
npm test
|
|
193
|
+
npm run pack:check
|
|
194
|
+
npm run check:secrets
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Core directories:
|
|
198
|
+
|
|
199
|
+
- `src/mlclaw/`: CLI and Hub orchestration.
|
|
200
|
+
- `src/mlclaw-space-runtime/`: Space OAuth proxy and browser gateway wrapper.
|
|
201
|
+
- `src/hf-state-sync/`: snapshot/restore supervisor.
|
|
202
|
+
- `src/hf-bucket-client/`: TypeScript Storage Bucket client.
|
|
203
|
+
|
|
204
|
+
## License
|
|
205
|
+
|
|
206
|
+
[MIT](LICENSE)
|