mlclaw 0.2.3 → 0.3.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.
@@ -9,7 +9,9 @@ description: Use when setting up, operating, migrating, repairing, or explaining
9
9
 
10
10
  Use the `mlclaw` CLI as the source of truth. Do not hand-create Hugging Face
11
11
  Spaces, buckets, secrets, or Docker containers unless debugging a failed
12
- `mlclaw` operation. Keep credentials local to the user's machine.
12
+ `mlclaw` operation. Keep bootstrap credentials local to the user's machine.
13
+ Space OAuth credentials may be stored only through ML Claw's encrypted,
14
+ process-isolated integration store.
13
15
 
14
16
  Default to the browser Space gateway unless the user explicitly asks for local
15
17
  gateway mode.
@@ -20,24 +22,36 @@ An ML Claw deployment has:
20
22
 
21
23
  - a private Hugging Face Storage Bucket for durable OpenClaw state snapshots;
22
24
  - a private Hugging Face Docker Space for the default browser gateway;
25
+ - no explicit Space hardware request by default; Hugging Face assigns the
26
+ default free CPU hardware unless `--hardware` or a feature requiring paid
27
+ hardware is used;
23
28
  - a prebuilt `ghcr.io/osolmaz/mlclaw` runtime image by default;
24
29
  - Hugging Face OAuth enabled on the Space;
30
+ - automatic Hugging Face MCP and Research Agent integrations authorized by an
31
+ admin-only OAuth step after ordinary Hugging Face sign-in;
25
32
  - a local deployment manifest under `~/.config/mlclaw/deployments/`;
26
33
  - local secrets under `~/.config/mlclaw/secrets/`;
34
+ - app Spaces mount the private Storage Bucket read-write at
35
+ `/data/mlclaw-state` for snapshot storage without storing the user's broad
36
+ Hub token in the Space;
27
37
  - preinstalled Hugging Face tooling in the OpenClaw workspace, including
28
38
  `hf`, `hf-discover`, `uv`, HF Python libraries, and baseline Hugging Face
29
39
  Agent Skills mirrored into both `.agents/skills` and `skills`;
30
40
  - optional local Docker gateway mode for users who want the gateway on their
31
41
  own machine;
32
- - Hugging Face Router model configuration for OpenClaw inference.
42
+ - Hugging Face Router model configuration through an isolated HF Broker.
33
43
 
34
44
  The bucket is the durable state source. The live gateway is disposable. Do not
35
- mount a bucket as the live OpenClaw database filesystem.
45
+ mount a bucket as the live OpenClaw database filesystem. Space gateway mode
46
+ uses the mounted bucket only for verified snapshots; live SQLite and workspace
47
+ state stay on local container disk under
48
+ `/home/node/.local/share/mlclaw/live`.
36
49
 
37
- ML Claw seeds a managed Hugging Face tooling note into workspace `AGENTS.md` so
38
- new OpenClaw sessions see the available Hugging Face skills directly in
39
- context. If a long-running session predates the seed, start a new OpenClaw
40
- session so its skill snapshot is rebuilt.
50
+ ML Claw waits for OpenClaw's native first-run identity bootstrap to finish,
51
+ then seeds a managed Hugging Face tooling note into workspace `AGENTS.md` so
52
+ new sessions see the available Hugging Face skills directly in context. If a
53
+ long-running session predates the seed, start a new OpenClaw session so its
54
+ skill snapshot is rebuilt.
41
55
 
42
56
  ## Required Inputs
43
57
 
@@ -45,6 +59,8 @@ Collect or confirm:
45
59
 
46
60
  - Hugging Face token access: `HF_TOKEN`, `HF_TOKEN_PATH`, `$HF_HOME/token`, or
47
61
  `hf auth login`.
62
+ - The active Hugging Face token is installed as the broker-owned
63
+ `MLCLAW_BROKER_HF_TOKEN`; legacy dedicated Router tokens remain supported.
48
64
  - Agent name, unless a Telegram bot token is supplied and the user wants the
49
65
  name derived from the bot username.
50
66
  - Gateway mode:
@@ -185,6 +201,11 @@ Known useful router-compatible choices:
185
201
  - `huggingface/deepseek-ai/DeepSeek-V4-Pro:deepinfra`: higher-quality long-context DeepSeek V4 option.
186
202
  - `huggingface/MiniMaxAI/MiniMax-M3:together`: long-context MiniMax option with tool and structured-output support.
187
203
 
204
+ Fireworks alternatives using the `:fireworks-ai` suffix are curated for GLM
205
+ 5.2, Kimi K2.7 Code, GPT-OSS 120B and 20B, DeepSeek V4 Flash and Pro, and
206
+ MiniMax M3. The Router catalog does not currently expose the Gemma 4 or Qwen
207
+ 3.6 presets through Fireworks.
208
+
188
209
  Do not assume every Hub model is a Router chat model. If exact current model
189
210
  availability matters, check the Hugging Face Router catalog or run a direct
190
211
  chat-completions probe.
@@ -224,14 +245,30 @@ mlclaw gateway start <agent>
224
245
 
225
246
  After signing into the Space, use the ML Claw control UI:
226
247
 
227
- - `/mlclaw/settings` chooses Router model/provider rows and changes the Space
228
- `OPENCLAW_MODEL` and `MLCLAW_MODEL_CHOICES`.
229
- - `/mlclaw/status` shows runtime, bucket, model, and OAuth status.
230
- - `/mlclaw/credentials` stores an OpenAI API key.
231
-
232
- The OpenAI key is stored as a Hugging Face Space Secret when possible and as a
233
- 0600 runtime file for immediate use. The key must never be logged or returned
234
- to the browser.
248
+ - `/mlclaw/settings` chooses Router model/provider rows. App Spaces without a
249
+ Hub token save the selection into snapshotted runtime state and restart only
250
+ OpenClaw; the CLI remains responsible for privileged Space variable changes.
251
+ - `/mlclaw/status` shows runtime, bucket, model, OAuth, and integration status.
252
+ - `/mlclaw/credentials` connects or disconnects Hugging Face MCP and Research
253
+ Agent access, and stores an OpenAI API key.
254
+
255
+ The trusted ML Claw wrapper stores Hugging Face OAuth tokens encrypted on the
256
+ mounted private state volume. OpenClaw runs as a separate unprivileged Unix
257
+ user and receives only local MCP server URLs plus an internal capability
258
+ header; never place the OAuth token in OpenClaw config or environment.
259
+
260
+ After migrating to a local gateway, the MCP proxy uses the local deployment's
261
+ Hugging Face token inside the trusted wrapper instead of requiring the Space's
262
+ OAuth client. Migrating back resumes the encrypted OAuth credential retained
263
+ in the private bucket. OpenClaw receives only a generated HF Broker agent
264
+ credential; it never receives the broader local Hub token or the broker
265
+ operator credential.
266
+
267
+ The OpenAI key is stored as a 0600 runtime file for immediate use. For
268
+ restart-durable OpenAI credentials, use the local `mlclaw` CLI or Space
269
+ settings to set a Space Secret; do not put the user's broad Hub token into the
270
+ Space just so the browser app can mutate secrets. The key must never be logged
271
+ or returned to the browser.
235
272
 
236
273
  ## Branding
237
274
 
@@ -262,7 +299,9 @@ them through `/assets/brand/logo`, `/favicon.svg`, `/favicon-32.png`,
262
299
 
263
300
  ## State Safety
264
301
 
265
- OpenClaw uses local disk. The bucket stores verified snapshots only. On boot,
266
- the runtime restores the newest valid snapshot. During runtime and shutdown,
267
- `hf-state-sync` uploads new snapshots. Secrets are kept outside the snapshot
268
- path.
302
+ OpenClaw uses local disk. In Space gateway mode, the private bucket is mounted
303
+ at `/data/mlclaw-state`, but it stores verified snapshots only. On boot, the
304
+ runtime restores the newest valid snapshot into
305
+ `/home/node/.local/share/mlclaw/live`. During runtime and shutdown,
306
+ `hf-state-sync` writes new snapshots back to the mounted bucket. Secrets are
307
+ kept outside the snapshot path.
package/Dockerfile CHANGED
@@ -1,6 +1,32 @@
1
- ARG OPENCLAW_VERSION=2026.7.1-beta.2
1
+ ARG OPENCLAW_VERSION=2026.7.1-beta.5
2
2
  ARG OPENCLAW_BASE_IMAGE=ghcr.io/openclaw/openclaw:${OPENCLAW_VERSION}
3
- ARG MLCLAW_RUNTIME_IMAGE=ghcr.io/osolmaz/mlclaw:0.2.3-openclaw-2026.7.1-beta.2
3
+ ARG BROKERKIT_PLUGIN_VERSION=0.1.0
4
+ ARG BROKERKIT_VERSION=fcfc5f2304436d952b18e7c9583bb378d1952776
5
+ ARG MLCLAW_RUNTIME_IMAGE=ghcr.io/osolmaz/mlclaw:0.3.1-openclaw-2026.7.1-beta.5
6
+
7
+ FROM golang:1.26.5-bookworm AS hf-broker-build
8
+ ARG BROKERKIT_VERSION
9
+ RUN git init /src \
10
+ && git -C /src fetch --depth=1 https://github.com/osolmaz/brokerkit.git "$BROKERKIT_VERSION" \
11
+ && git -C /src checkout --detach FETCH_HEAD \
12
+ && test "$(git -C /src rev-parse HEAD)" = "$BROKERKIT_VERSION" \
13
+ && cd /src \
14
+ && GOWORK=off go build -trimpath -o /out/hf-broker ./brokers/huggingface/cmd/hf-broker
15
+
16
+ FROM node:24-bookworm-slim AS brokerkit-plugin-build
17
+ ARG BROKERKIT_VERSION
18
+ RUN apt-get update \
19
+ && apt-get install -y --no-install-recommends ca-certificates git \
20
+ && rm -rf /var/lib/apt/lists/* \
21
+ && git init /src \
22
+ && git -C /src fetch --depth=1 https://github.com/osolmaz/brokerkit.git "$BROKERKIT_VERSION" \
23
+ && git -C /src checkout --detach FETCH_HEAD \
24
+ && test "$(git -C /src rev-parse HEAD)" = "$BROKERKIT_VERSION"
25
+ WORKDIR /src
26
+ RUN corepack enable \
27
+ && pnpm install --frozen-lockfile \
28
+ && pnpm --filter openclaw-brokerkit build \
29
+ && pnpm --filter openclaw-brokerkit pack --pack-destination /out
4
30
 
5
31
  # Stage 1: build the state-sync bundle so the runtime image needs no dev deps.
6
32
  FROM node:24-bookworm-slim AS sync-build
@@ -17,7 +43,8 @@ LABEL org.opencontainers.image.description="ML Claw runtime for OpenClaw on Hugg
17
43
  USER root
18
44
  # zstd: snapshot archives. gosu: drop privileges after preparing mounted volumes.
19
45
  RUN apt-get update \
20
- && apt-get install -y --no-install-recommends gosu python3 python3-pip python3-venv zstd \
46
+ && apt-get install -y --no-install-recommends ca-certificates gosu python3 python3-pip python3-venv zstd \
47
+ && useradd --system --home-dir /var/lib/hf-broker --create-home --shell /usr/sbin/nologin hf-broker \
21
48
  && rm -rf /var/lib/apt/lists/*
22
49
  RUN python3 -m pip install --break-system-packages --no-cache-dir \
23
50
  "huggingface_hub==1.19.0" \
@@ -31,10 +58,18 @@ RUN python3 -m pip install --break-system-packages --no-cache-dir \
31
58
  "uvicorn==0.49.0" \
32
59
  "uv==0.11.28" \
33
60
  "hf-discover==1.3.7"
61
+ ARG BROKERKIT_PLUGIN_VERSION
62
+ COPY --from=brokerkit-plugin-build /out/openclaw-brokerkit-${BROKERKIT_PLUGIN_VERSION}.tgz /tmp/openclaw-brokerkit.tgz
63
+ RUN npm install --omit=dev --omit=peer --no-audit --no-fund --prefix /opt/openclaw-plugins \
64
+ /tmp/openclaw-brokerkit.tgz \
65
+ && rm /tmp/openclaw-brokerkit.tgz \
66
+ && test -f /opt/openclaw-plugins/node_modules/openclaw-brokerkit/openclaw.plugin.json
34
67
 
35
68
  COPY --from=sync-build /build/dist/hf-state-sync.js /app/hf-state-sync.js
36
69
  COPY --from=sync-build /build/dist/hf-tooling-seed.js /app/hf-tooling-seed.js
37
70
  COPY --from=sync-build /build/dist/mlclaw-space-runtime.js /app/mlclaw-space-runtime.js
71
+ COPY --from=hf-broker-build /out/hf-broker /usr/local/bin/hf-broker
72
+ COPY hf-broker.scope.json /app/hf-broker.scope.json
38
73
  COPY --chown=node:node openclaw.default.json /app/openclaw.default.json
39
74
  COPY --chown=node:node entrypoint.sh /app/entrypoint.sh
40
75
  COPY --chown=node:node assets/ /app/assets/
@@ -43,15 +78,18 @@ RUN chmod +x /app/entrypoint.sh
43
78
 
44
79
  USER root
45
80
 
46
- # Live state on local disk; the bucket is reached only through the TS client.
81
+ # Live state stays on local disk; Space bucket volumes are mounted separately for snapshots.
47
82
  ENV PORT=7860
48
83
  ENV MLCLAW_OPENCLAW_PORT=7861
84
+ ENV MLCLAW_OPENCLAW_UID=1000
85
+ ENV MLCLAW_OPENCLAW_GID=1000
49
86
  ENV OPENCLAW_GATEWAY_PORT=7861
50
- ENV OPENCLAW_LIVE_DIR=/tmp/openclaw-live
51
- ENV OPENCLAW_STATE_DIR=/tmp/openclaw-live/.openclaw
52
- ENV OPENCLAW_WORKSPACE_DIR=/tmp/openclaw-live/workspace
53
- ENV OPENCLAW_CONFIG_PATH=/tmp/openclaw-live/.openclaw/openclaw.json
87
+ ENV OPENCLAW_LIVE_DIR=/home/node/.local/share/mlclaw/live
88
+ ENV OPENCLAW_STATE_DIR=/home/node/.local/share/mlclaw/live/.openclaw
89
+ ENV OPENCLAW_WORKSPACE_DIR=/home/node/.local/share/mlclaw/live/workspace
90
+ ENV OPENCLAW_CONFIG_PATH=/home/node/.local/share/mlclaw/live/.openclaw/openclaw.json
54
91
  ENV OPENCLAW_DISABLE_BONJOUR=1
92
+ ENV MLCLAW_BROKERKIT_PLUGIN_PATH=/opt/openclaw-plugins/node_modules/openclaw-brokerkit
55
93
  ARG MLCLAW_RUNTIME_IMAGE
56
94
  ENV MLCLAW_RUNTIME_IMAGE=$MLCLAW_RUNTIME_IMAGE
57
95
 
package/README.md CHANGED
@@ -12,6 +12,12 @@ The browser never receives an OpenClaw gateway token. ML Claw authenticates the
12
12
  signed-in Hugging Face user, then proxies HTTP and WebSocket traffic to
13
13
  OpenClaw on loopback using OpenClaw trusted-proxy auth.
14
14
 
15
+ After signing in, an administrator can authorize the hosted Hugging Face MCP
16
+ server and Research Agent with the same Hugging Face account. Ordinary users
17
+ grant only identity scopes. Integration credentials stay in the trusted ML
18
+ Claw wrapper; the unprivileged OpenClaw process receives only loopback MCP
19
+ access.
20
+
15
21
  ## Install
16
22
 
17
23
  With Node.js:
@@ -37,6 +43,13 @@ You need a Hugging Face account and a token available through `HF_TOKEN`,
37
43
  `HF_TOKEN_PATH`, `$HF_HOME/token`, or `hf auth login`. You never paste that
38
44
  token into someone else's app; the bootstrapper runs locally.
39
45
 
46
+ ML Claw places the active Hugging Face token behind an in-container HF Broker.
47
+ The broker owns the real token; OpenClaw receives only a separate agent
48
+ credential that can call the broker's typed, policy-checked routes. It cannot
49
+ read the token or use the admin-only operator API. Existing dedicated inference
50
+ tokens remain supported through `MLCLAW_ROUTER_TOKEN`, `HF_ROUTER_TOKEN`, or
51
+ `--router-token-file` during migration.
52
+
40
53
  ## Default Flow
41
54
 
42
55
  ```bash
@@ -47,9 +60,15 @@ This creates:
47
60
 
48
61
  - a private Storage Bucket for OpenClaw state;
49
62
  - a private Docker Space for the browser gateway;
63
+ - no explicit Space hardware request; Hugging Face uses the default free CPU
64
+ hardware unless you pass `--hardware`;
50
65
  - a Docker Space that starts from the prebuilt `ghcr.io/osolmaz/mlclaw` image;
51
- - Hugging Face OAuth metadata in the Space README;
52
- - Space variables and write-only secrets for state sync and session signing;
66
+ - Hugging Face OAuth metadata for browser auth, Hugging Face MCP, and Research
67
+ Agent access in the Space README;
68
+ - Space variables, a bucket volume mount for state sync, and separate
69
+ write-only secrets for session signing and OAuth credential encryption;
70
+ - an `MLCLAW_BROKER_HF_TOKEN` Space secret consumed only by the isolated HF
71
+ Broker process;
53
72
  - a local deployment manifest under `~/.config/mlclaw`.
54
73
 
55
74
  Open the Space, sign in with your Hugging Face account, and use the OpenClaw
@@ -83,6 +102,11 @@ Recommended router-compatible options:
83
102
  - `huggingface/deepseek-ai/DeepSeek-V4-Pro:deepinfra`: higher-quality long-context DeepSeek V4 option.
84
103
  - `huggingface/MiniMaxAI/MiniMax-M3:together`: long-context MiniMax option with tool and structured-output support.
85
104
 
105
+ Fireworks alternatives are also included for GLM 5.2, Kimi K2.7 Code,
106
+ GPT-OSS 120B and 20B, DeepSeek V4 Flash and Pro, and MiniMax M3. Use the
107
+ provider suffix `:fireworks-ai`. The current Router catalog does not expose the
108
+ Gemma 4 or Qwen 3.6 presets through Fireworks.
109
+
86
110
  ## Optional Telegram
87
111
 
88
112
  Telegram is optional. If you provide a Telegram bot token, ML Claw calls
@@ -121,6 +145,10 @@ mlclaw gateway migrate mlclaw --to local
121
145
  mlclaw gateway migrate mlclaw --to space
122
146
  ```
123
147
 
148
+ The local MCP proxy uses the Hugging Face token kept in the local deployment
149
+ environment. The trusted wrapper does not need the Space OAuth client, and the
150
+ encrypted Space OAuth credential remains in the bucket for migration back.
151
+
124
152
  Useful operations:
125
153
 
126
154
  ```bash
@@ -158,7 +186,9 @@ It never reads secret values and never modifies bucket contents.
158
186
 
159
187
  `mlclaw update` also refreshes the generated Space Dockerfile and runtime
160
188
  metadata, so older Spaces can move to the current implementation without
161
- recreating their bucket.
189
+ recreating their bucket. For legacy deployments, ML Claw installs the active
190
+ local Hugging Face credential as `MLCLAW_BROKER_HF_TOKEN`, removes stale direct
191
+ token secrets, and restarts the Space with the broker boundary enabled.
162
192
 
163
193
  ## Browser Settings
164
194
 
@@ -172,8 +202,21 @@ Use the browser control UI for:
172
202
 
173
203
  - `/mlclaw/settings`: choose Router model/provider rows, update `OPENCLAW_MODEL`
174
204
  and `MLCLAW_MODEL_CHOICES`, and request a Space restart.
175
- - `/mlclaw/status`: inspect runtime, bucket, model, and OAuth status.
176
- - `/mlclaw/credentials`: submit an OpenAI API key.
205
+ - `/mlclaw/status`: inspect runtime, bucket, model, OAuth, and integration status.
206
+
207
+ OpenClaw's BrokerKit plugin adds an **Approvals** tab to the gateway. The tab
208
+ merges every BrokerKit-compatible backend configured in
209
+ `MLCLAW_OPERATOR_BROKERS_FILE` and lets administrators inspect, approve, deny,
210
+ cancel, or revoke requests. The plugin registers the Gateway tab, while ML Claw
211
+ serves the immutable packaged UI from its trusted HTTP boundary and gives it a
212
+ small launcher inside the Gateway. Decisions open in an unframeable protected
213
+ document with a renewable, short-lived, admin-bound browser token. Broker
214
+ operator tokens remain in backend-only files and are never sent to the browser
215
+ or OpenClaw. See
216
+ [Operator Broker Configuration](docs/operator-brokers-config.md).
217
+
218
+ - `/mlclaw/credentials`: connect or disconnect Hugging Face MCP and Research
219
+ Agent access, or submit an OpenAI API key.
177
220
  - `/mlclaw/logout`: clear the ML Claw session cookie.
178
221
 
179
222
  The same control UI is linked from the OpenClaw gateway. Settings changes
@@ -215,21 +258,36 @@ After signing into the Space, open:
215
258
  ```
216
259
 
217
260
  Submit an OpenAI API key there if you want OpenClaw to use OpenAI-compatible
218
- models. ML Claw stores the key as a Hugging Face Space Secret when possible,
219
- writes a 0600 runtime file for immediate use, and restarts the internal
220
- OpenClaw gateway with `OPENAI_API_KEY` set. The key is never returned to the
221
- browser.
261
+ models. ML Claw writes a `0600` runtime file for immediate use and an encrypted
262
+ durable credential protected by `MLCLAW_CREDENTIAL_KEY`, then restarts the
263
+ internal OpenClaw gateway with `OPENAI_API_KEY` set. When trusted Hub authority
264
+ is available, it also stores the key as a write-only Space secret. The key is
265
+ never returned to the browser, exposed to the agent except as its intended
266
+ OpenAI credential, or stored as plaintext in the state bucket. App Spaces do
267
+ not keep broad Hugging Face authority in the web control process.
222
268
 
223
269
  ## How State Works
224
270
 
225
- OpenClaw runs against local disk inside the active runtime. The Storage Bucket
226
- is not mounted as a live filesystem. Instead, `hf-state-sync` restores the
227
- newest verified snapshot on boot and uploads verified snapshots during runtime
228
- and shutdown.
229
-
230
- That keeps SQLite off network-mounted storage while preserving the agent's
231
- memory across Space rebuilds, local container replacement, and gateway
232
- migration.
271
+ OpenClaw runs against local disk inside the active runtime. In Space gateway
272
+ mode, ML Claw mounts the private Storage Bucket at `/data/mlclaw-state` and
273
+ uses that mounted directory only for verified snapshots. The live OpenClaw
274
+ state stays on local container disk at
275
+ `/home/node/.local/share/mlclaw/live`.
276
+
277
+ That keeps SQLite off bucket-backed storage while preserving the agent's memory
278
+ across Space rebuilds, local container replacement, and gateway migration. The
279
+ Space does not use `HF_TOKEN` or `HUGGINGFACE_HUB_TOKEN` secrets. Its broad
280
+ credential is stored as `MLCLAW_BROKER_HF_TOKEN`, written to a broker-owned
281
+ `0600` file during startup, and removed from child-process environments.
282
+ OpenClaw uses only the generated broker agent credential. Broker grant and
283
+ event state and encrypted control credentials live under the root-owned
284
+ `/var/lib/mlclaw-protected` tree. They are included in the durable snapshot
285
+ through a root-only `.mlclaw-protected` staging step, then restored outside the
286
+ agent-owned live directory before OpenClaw starts. Rebuildable Git mirrors, the
287
+ broad token, and operator credentials are never included in snapshots.
288
+ Local gateways pass the broad credential only to the trusted state-sync
289
+ supervisor for bucket I/O and to the trusted MCP integration proxy through a
290
+ protected token file. Neither path passes it to OpenClaw.
233
291
 
234
292
  ## Costs
235
293