Skip to content

fix(agent): seed CLAWBOX.md so the agent knows device conventions - #82

Merged
KrasimirKralev merged 2 commits into
ID-Robots:betafrom
KrasimirKralev:fix/seed-clawbox-workspace-guide
Apr 19, 2026
Merged

fix(agent): seed CLAWBOX.md so the agent knows device conventions#82
KrasimirKralev merged 2 commits into
ID-Robots:betafrom
KrasimirKralev:fix/seed-clawbox-workspace-guide

Conversation

@KrasimirKralev

@KrasimirKralev KrasimirKralev commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

Summary

The OpenClaw agent's session-start context (AGENTS.md, BOOTSTRAP.md, etc.) has no ClawBox-specific guidance. Observed failure mode earlier today: user installed self-improving-agent via the App Store, asked the agent to confirm — the agent read-checked /home/clawbox/.npm-global/lib/node_modules/openclaw/skills (the npm package's built-in skills dir), saw nothing, and confidently reported the skill as not installed. The skill was actually at ~/.openclaw/workspace/skills/self-improving-agent/ the whole time.

Same class of problem applies to the desktop-Chromium integration and to skill installs:

  • Agent doesn't know the browser_* MCP tools exist → defaults to ui_open_app("browser") which opens the Setup panel, not a browsing session.
  • When asked to install a skill the agent might copy files into the skills dir manually instead of using app_install — which skips the App Store registration + gateway reload the user needs to see / uninstall it from the UI.

What changed

  1. New config/clawbox-workspace-guide.md documents:

    • Where user-installed skills live (~/.openclaw/workspace/skills/) and do NOT live (the npm-global path)
    • Skill install/uninstall must go through app_install / app_uninstall (so the App Store UI stays consistent + gateway reload actually fires)
    • Full browser_* MCP tool inventory with the standard launch → screenshot → click/type workflow, plus the "do not use ui_open_app("browser")" caveat
    • ui_* / app_* / webapp_* tools inventory
    • File-system + network pointers
  2. scripts/gateway-pre-start.sh now seeds this file as ~/.openclaw/workspace/CLAWBOX.md when:

    • The workspace dir exists (avoids racing first-boot OpenClaw init)
    • Shipped template differs from on-disk copy (cmp -s) — so later agent/user edits aren't clobbered on every restart
  3. Also appends a one-liner reference to AGENTS.md (when it exists and doesn't already mention CLAWBOX.md), so the agent's normal session-start bootstrap loads our guide without us having to overwrite AGENTS.md.

Test plan

  • bash -n syntax clean
  • First run on Jetson: seeded CLAWBOX.md + appended AGENTS.md reference
  • Second run: both checks logged "skipping" (idempotent)
  • AGENTS.md now ends with ## ClawBox integration section pointing at CLAWBOX.md
  • Next fresh session with the chat agent: ask "do I have skill X?" — should check the workspace skills path, not node_modules
  • CodeRabbit review

Summary by CodeRabbit

Release Notes

  • Documentation

    • Added ClawBox integration guide documenting user skill installation via App Store, browser automation workflows, device control tools, workspace configuration, and reference points for workspace integration.
  • Chores

    • Enhanced workspace initialization to automatically seed integration documentation for agent context loading.

…x conventions

Root cause: the OpenClaw agent's session-start context (AGENTS.md,
BOOTSTRAP.md, etc.) knows nothing about ClawBox-specific device
conventions. When the user asks 'is skill X installed?', the agent
falls back to guessing paths and looks in
/home/clawbox/.npm-global/lib/node_modules/openclaw/skills — the
package's built-in skills directory, not where the App Store writes
user-installed skills (~/.openclaw/workspace/skills/). It then
reports 'skill not installed' despite the file being on disk. Same
class of problem for browser automation (agent doesn't know
browser_* MCP tools exist) and for skill installation (agent would
copy files manually instead of going through app_install).

Adds config/clawbox-workspace-guide.md — a concise markdown file
that documents:

- Where user-installed skills live (~/.openclaw/workspace/skills/)
  and explicitly where they do NOT live (the npm-global path)
- That skill install/uninstall must go through app_install /
  app_uninstall (so the App Store UI stays consistent and gateway
  reload actually fires)
- The full browser_* MCP tool set with a standard launch → screenshot
  → click/type → screenshot workflow, plus the 'do not use
  ui_open_app(browser)' caveat (that opens the Setup panel)
- The ui_*, app_*, webapp_* tools inventory for UI operations
- File-system + network pointers (project dir, config path, device
  URLs)

gateway-pre-start.sh now seeds this file as
~/.openclaw/workspace/CLAWBOX.md whenever:

- The workspace dir exists (so we don't race the first gateway boot
  before OpenClaw has initialized it)
- The shipped template differs from the on-disk copy (cmp -s), so
  edits the agent or user made locally aren't clobbered on every
  restart

Also appends a one-line reference to AGENTS.md (if it exists and
doesn't already mention CLAWBOX.md), so the agent's default
session-start bootstrap flow naturally loads our guide.

Verified on Jetson: first run seeded both files, second run logged
'skipping' for both (idempotent), syntax clean via bash -n.
@KrasimirKralev
KrasimirKralev requested a review from a team as a code owner April 18, 2026 20:41
@coderabbitai

coderabbitai Bot commented Apr 18, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@KrasimirKralev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 50 minutes and 33 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 50 minutes and 33 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d4caf428-0d6e-4d77-99b3-342575e3a20b

📥 Commits

Reviewing files that changed from the base of the PR and between 00be3e7 and 9d06c19.

📒 Files selected for processing (2)
  • config/clawbox-workspace-guide.md
  • scripts/gateway-pre-start.sh
📝 Walkthrough

Walkthrough

A new ClawBox workspace integration guide is added as documentation, along with a shell script modification that automatically seeds this guide into the workspace during gateway startup, conditionally appending references to session-start context files.

Changes

Cohort / File(s) Summary
Documentation
config/clawbox-workspace-guide.md
New integration guide documenting user-installed skills directory location, control-flow for skill management via ClawBox MCP server tools, Chromium browser workflow, and relevant UI/app management tools with filesystem and device URL references.
Workspace Setup
scripts/gateway-pre-start.sh
Adds conditional logic to copy the workspace guide into the OpenClaw workspace directory and idempotently append ClawBox integration reference to session-start context file when applicable.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A guide hops into the workspace bright,
With ClawBox wisdom, all shiny and right,
The gateway script seeds it with care so true,
Through idempotent checks—no duplicates, phew!
thumpity-thump 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly reflects the main change: seeding a ClawBox guidance document so the agent understands device conventions.
Description check ✅ Passed The description covers the motivation, changes, and test plan comprehensively; however, the PR description checklist items are mostly unchecked and some testing remains pending.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@config/clawbox-workspace-guide.md`:
- Line 54: The doc entry for the ui_open_app built-in is using the wrong Browser
Setup app ID; update the description to use the actual app ID "browser" (not
"browser-setup") so agents call ui_open_app with appId === "browser", matching
the MCP special-case that detects Browser Setup by checking appId === "browser";
ensure the table row for `ui_open_app` mentions the supported app IDs and
explicitly lists "browser" for Browser Setup to avoid mismatched calls.
- Around line 9-13: Update the doc to say the agent should check the configured
workspace value (agents.defaults.workspace) as resolved by the openclaw config
resolver (the logic in openclaw-config that reads ~/.openclaw/openclaw.json and
falls back to ~/.openclaw/workspace) rather than assuming only the default path,
and clarify that built-in npm package skills
(/home/clawbox/.npm-global/…/openclaw/skills) are still not to be checked;
explicitly mention agents.defaults.workspace and the config resolution so
readers know where the runtime path comes from.

In `@scripts/gateway-pre-start.sh`:
- Around line 178-184: The script currently hard-codes CLAWBOX_WORKSPACE and
always replaces CLAWBOX.md when sources differ, which overwrites local edits;
change it to use the resolved workspace value (the same source used by
openclaw-config.ts — i.e., use the agents.defaults.workspace resolution instead
of "/home/clawbox/.openclaw/workspace") and make seeding idempotent by only
installing CLAWBOX.md if the destination does not exist (do not copy when files
differ), ensure variables CLAWBOX_WORKSPACE, CLAWBOX_GUIDE_SRC and
CLAWBOX_GUIDE_DST remain properly quoted, and add minimal error handling around
install (check source exists and return non-zero on failure) so the script
preserves local edits and uses the canonical workspace location.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 747b7067-f91e-4167-a7b8-7a076068af54

📥 Commits

Reviewing files that changed from the base of the PR and between bcfaf9a and 00be3e7.

📒 Files selected for processing (2)
  • config/clawbox-workspace-guide.md
  • scripts/gateway-pre-start.sh

Comment thread config/clawbox-workspace-guide.md Outdated
Comment thread config/clawbox-workspace-guide.md Outdated
Comment thread scripts/gateway-pre-start.sh Outdated
@KrasimirKralev

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 18, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

…esolve workspace, seed-if-missing

Three findings on PR ID-Robots#82, all addressed:

1. CLAWBOX.md documented the ui_open_app app ID as 'browser-setup' in
   the tools table, but the MCP special-case in clawbox-mcp.ts checks
   appId === 'browser' for the Browser Setup panel. An agent following
   the doc literally would have passed an unknown app ID. The table
   entry now lists the actual built-in IDs (chat, files, settings,
   store, vnc, terminal, browser) and explicitly notes that 'browser'
   opens the Setup panel — not a real browsing session — and points
   back to the browser_* section for real web browsing.

2. The skills-path section and the pre-start script both hard-coded
   ~/.openclaw/workspace/skills/ as the answer to 'where do skills
   live?'. The actual source of truth is agents.defaults.workspace in
   openclaw.json (with a fallback to ~/.openclaw/workspace when
   unset), which is what getSkillsDir() on the ClawBox API side reads.
   Guide now describes that resolution and gateway-pre-start.sh
   computes the workspace via Python: reads agents.defaults.workspace,
   expands ~, treats relative paths as relative to ~/.openclaw, and
   falls back to the default on missing/invalid config.

3. CLAWBOX.md was being overwritten on every gateway start whenever
   its content differed from the shipped template (cmp -s check).
   That clobbers any local customization the user or agent has made.
   Switched to seed-if-missing: only write when the file doesn't
   exist. Operators who want to pull in an updated template can
   delete the on-disk copy; next gateway start re-seeds.
@KrasimirKralev

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 19, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@KrasimirKralev
KrasimirKralev merged commit 1f55a39 into ID-Robots:beta Apr 19, 2026
5 checks passed
KrasimirKralev added a commit to KrasimirKralev/clawbox that referenced this pull request Apr 19, 2026
14 tests had been red on beta since before the Gemma/provider-switch
work in PRs ID-Robots#82/ID-Robots#83 landed. Three separate root causes:

1. Test mocks drifted from the configure route's real imports.
   The route now calls `applyModelOverrideToAllAgentSessions` and
   `parseFullyQualifiedModel` (added in ID-Robots#83 for session sweeping),
   plus four functions from `@/lib/llamacpp` and one from
   `@/lib/local-ai-runtime`. Tests mocked none of these, so the
   first request-time call to any of them threw and the route
   returned 500 — producing the "expected 200 to be 500" cascade.
   Added the missing mocks with real-shape implementations.

2. vitest-under-bun clears mock implementations along with call
   history in `vi.clearAllMocks()`. Factory defaults set inside
   `vi.mock(...)` survive `vi.resetModules` but not `mockClear`.
   Tests passed in isolation, failed in sequence. Re-apply the
   implementations in `beforeEach` so each test starts with a
   consistent mock surface.

3. The ai-models-step component test relied on `llamaCppIsActive`
   defaulting true, but the panel only sets it true when
   `currentProviderId === "llamacpp"`. Without that prop the
   "Gemma 4 is already configured" pill never rendered. Added the
   prop.

Extras during simplifier pass:
- Mirror real `parseFullyQualifiedModel` logic byte-for-byte
  (`idx <= 0 || idx === fq.length - 1`) so trailing-slash inputs
  reject as expected. Fixed drift in `chat-model.test.ts` too.
- Extract shared proxy-URL constant via `vi.hoisted` to avoid
  duplicating the magic string across two mock factories.

Result: 93/93 files, 1069/1069 tests pass — CI signal restored.
KrasimirKralev added a commit that referenced this pull request Apr 19, 2026
…90)

14 tests had been red on beta since before the Gemma/provider-switch
work in PRs #82/#83 landed. Three separate root causes:

1. Test mocks drifted from the configure route's real imports.
   The route now calls `applyModelOverrideToAllAgentSessions` and
   `parseFullyQualifiedModel` (added in #83 for session sweeping),
   plus four functions from `@/lib/llamacpp` and one from
   `@/lib/local-ai-runtime`. Tests mocked none of these, so the
   first request-time call to any of them threw and the route
   returned 500 — producing the "expected 200 to be 500" cascade.
   Added the missing mocks with real-shape implementations.

2. vitest-under-bun clears mock implementations along with call
   history in `vi.clearAllMocks()`. Factory defaults set inside
   `vi.mock(...)` survive `vi.resetModules` but not `mockClear`.
   Tests passed in isolation, failed in sequence. Re-apply the
   implementations in `beforeEach` so each test starts with a
   consistent mock surface.

3. The ai-models-step component test relied on `llamaCppIsActive`
   defaulting true, but the panel only sets it true when
   `currentProviderId === "llamacpp"`. Without that prop the
   "Gemma 4 is already configured" pill never rendered. Added the
   prop.

Extras during simplifier pass:
- Mirror real `parseFullyQualifiedModel` logic byte-for-byte
  (`idx <= 0 || idx === fq.length - 1`) so trailing-slash inputs
  reject as expected. Fixed drift in `chat-model.test.ts` too.
- Extract shared proxy-URL constant via `vi.hoisted` to avoid
  duplicating the magic string across two mock factories.

Result: 93/93 files, 1069/1069 tests pass — CI signal restored.
This was referenced May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant