Star Office UI(Bun 重构版)一键化 Skill:帮助主人快速部署办公室看板、统一状态同步、接入多 Agent 推送,并完成上线前安全检查。
本 Skill 面向在本仓库协作的 Agent(龙虾),目标是:
你可以先和主人说:
这是一个多人协作的像素办公室看板,AI 助手会根据状态自动移动,还能展示昨日小记和多人在线状态。
在项目根目录执行:
# 1) 下载仓库并进入目录(如当前已在仓库目录,可跳过)
git clone [email protected]:Ming900907/star-office-ui-bun-refactor.git
# 如果 SSH key 不可用,改用:
# git clone https://github.com/Ming900907/star-office-ui-bun-refactor.git
cd star-office-ui-bun-refactor
# 2) 安装依赖
~/.bun/bin/bun install
# 3) 初始化配置与状态文件
cp .env.example .env
# 本地体验可从 sample 初始化;生产部署请优先使用 bootstrap:prod
cp state.sample.json state.json
cp join-keys.sample.json join-keys.json
# 4) 生产环境务必设置安全项(OpenClaw 面板走 sync/cache)
export ASSET_DRAWER_PASS="replace_with_strong_password"
export STAR_OFFICE_API_TOKEN="replace_with_long_random_token"
export STAR_OFFICE_ENV=production
export OPENCLAW_BIN="openclaw"
export OPENCLAW_CACHE_STALE_SECONDS=120
export OFFICE_PANEL_SYNC_INTERVAL_SECONDS=60
# 5) 启动 Bun 服务
~/.bun/bin/bun run server/index.ts
完成后告诉主人:
现在打开 http://127.0.0.1:19000 就能看到像素办公室。
如果是生产部署,优先直接执行:
~/.bun/bin/bun run bootstrap:prod
该命令会由 OpenClaw 自动完成配置与最小验收,不需要主人手动逐项编辑。
如果主人说的是“部署到服务器 / 重新部署 / 上线新版本”,默认按下面策略执行,不要退回到旧的手工模式:
~/.bun/bin/bun run bootstrap:proddegraded-tolerant 策略export OPENCLAW_REQUIRE_HEALTHY_SOURCE=1
export OPENCLAW_REQUIRE_HEALTHY_SOURCE=0
POST /openclaw/sync 的结果是否为真正成功/openclaw/skills 与 /openclaw/usage 的 syncedAtstale: truedegraded: truewarnings 是否为空给主人的一句话总结可以直接说:
我已经按新的部署流程完成初始化,并检查了 skills/usage 当前缓存是否已同步、是否过期、是否处于降级模式。
部署时,Agent 默认按以下顺序自动执行,不要把配置步骤丢给主人手工做:
.envstate.json、join-keys.json(缺失时以生产安全默认值初始化,不使用 sample)STAR_OFFICE_ENV=production:
ASSET_DRAWER_PASS、STAR_OFFICE_API_TOKENopenclaw skills list --json 与 openclaw status --usage --jsonskillsPayload / usagePayload 推送到 POST /openclaw/syncPOST /openclaw/sync 是“推送与刷新缓存”的唯一入口,GET /openclaw/skills 与 GET /openclaw/usage 只是读缓存OPENCLAW_REQUIRE_HEALTHY_SOURCE=1GET /healthGET /statusPOST /openclaw/syncGET /openclaw/skillsGET /openclaw/usage原则:
POST /openclaw/sync 返回 200syncedAtstale=falsedegraded=false这是最理想状态,可以直接告诉主人部署完成。
POST /openclaw/sync 返回 502,或返回 200 但后续读缓存仍带 degraded: truesource 含 fallbackmode=estimateddegraded: true如果主人没有要求 strict,这种状态可以上线,但必须明确告诉主人当前不是“真实 OpenClaw 数据源”。 如果缓存里之前已经有健康数据,服务端应保留上一份健康缓存,不允许本次降级同步把前端面板覆盖成 fallback。
OPENCLAW_REQUIRE_HEALTHY_SOURCE=1POST /openclaw/sync 返回 503,或 skills/usage 仍是 degraded这时不要说“部署完成”,应该明确告诉主人:
服务已经拉起,但 strict mode 下 OpenClaw 数据源不健康,本次部署验收失败。
STAR_OFFICE_API_TOKEN=your_token ~/.bun/bin/bun run state:writing
STAR_OFFICE_API_TOKEN=your_token ~/.bun/bin/bun run state:syncing
STAR_OFFICE_API_TOKEN=your_token ~/.bun/bin/bun run state:error
STAR_OFFICE_API_TOKEN=your_token ~/.bun/bin/bun run state:idle
STAR_OFFICE_API_TOKEN=your_token ~/.bun/bin/bun run scripts/set-state.ts writing "正在整理文档"
STAR_OFFICE_API_TOKEN=your_token ~/.bun/bin/bun run scripts/set-state.ts syncing "同步进度中"
STAR_OFFICE_API_TOKEN=your_token ~/.bun/bin/bun run scripts/set-state.ts error "发现问题,排查中"
STAR_OFFICE_API_TOKEN=your_token ~/.bun/bin/bun run scripts/set-state.ts idle "待命中"
STAR_OFFICE_SET_STATE_MODE=file ~/.bun/bin/bun run scripts/set-state.ts writing "本地写入状态"
说明:
/agent-skills/execute(openclaw.set-main-state)file 模式会直接写 state.json默认 ASSET_DRAWER_PASS=1234 仅用于本地体验。
公网或团队共享环境必须改强密码。
示例:
export ASSET_DRAWER_PASS="replace_with_strong_password"
如果是 systemd/pm2/容器,记得写入服务配置,不要只在当前终端临时设置。
本重构版使用 JS 推送脚本,不再依赖 Python:
frontend/office-agent-push.mjs/join-agent + /agent-pushJOIN_KEY=ocj_starteam01 AGENT_NAME=my-agent OFFICE_URL=http://127.0.0.1:19000 node frontend/office-agent-push.mjs
也可用 Bun 运行:
JOIN_KEY=ocj_starteam01 AGENT_NAME=my-agent OFFICE_URL=http://127.0.0.1:19000 bun frontend/office-agent-push.mjs
OFFICE_URL:办公室服务地址JOIN_KEY:接入密钥AGENT_NAME:展示名OFFICE_LOCAL_STATE_FILE:本地状态文件路径(默认 ./state.json)OFFICE_PUSH_INTERVAL_SECONDS:推送间隔(默认 15)OFFICE_PANEL_SYNC_INTERVAL_SECONDS:面板同步间隔(默认 60)OFFICE_STALE_STATE_TTL:状态超时回 idle(默认 600)ocj_starteam01 ~ ocj_starteam08先本地验收核心流程(状态变化、多人接入、资产管理),再考虑公网发布。
可用 Nginx 反代或隧道方案做临时共享。
建议先完成密码与访问控制,再开放公网。
代码许可可参考 MIT;当前美术资产非商用。
若要商用,请替换为自有授权素材。
GET /healthGET /statusPOST /openclaw/syncGET /openclaw/skillsGET /openclaw/usagePOST /agent-skills/execute(openclaw.set-main-state)GET /agentsPOST /join-agent + POST /agent-push补充判断:
POST /openclaw/sync 才是“OpenClaw 推送快照并刷新缓存”的验收点;不要只调用 GET /openclaw/skills / GET /openclaw/usage 就判定 OpenClaw 数据源正常POST /openclaw/sync 返回 502,表示本次同步退化;这时要检查服务端是否保留了上一份健康缓存,而不是把前端覆盖成 fallbackOPENCLAW_REQUIRE_HEALTHY_SOURCE=0,允许 fallback,但要明确标注“降级”OPENCLAW_REQUIRE_HEALTHY_SOURCE=1,则 /openclaw/skills 或 /openclaw/usage 返回 503 也算“正确失败”syncedAt、stale、degraded、warningspython3 set_state.py 了?因为本仓库已切换到 Bun 工作流,标准方法是:
bun run scripts/set-state.ts ...(显式)bun run state:writing 等(快捷)office-agent-push.py 了?因为推送脚本已迁移为 JS:frontend/office-agent-push.mjs,减少 Python 依赖,和项目技术栈一致。
可以,用 STAR_OFFICE_SET_STATE_MODE=file 直接写本地 state.json。
生产环境下改为 sync/cache 模式:
POST /openclaw/syncopenclaw skills list --json、openclaw status --usage --json)skillsPayload / usagePayload 推送给服务端GET /openclaw/skills 与 GET /openclaw/usage 读取缓存如果还没有同步过,或 OpenClaw 推送失败,页面会显示 degraded。若设置 OPENCLAW_REQUIRE_HEALTHY_SOURCE=1,降级会被视为失败。
只有以下情况建议开启:
如果只是为了先把服务跑起来、先恢复页面可用,不要默认开 strict。
writing/researching/executingsyncingerror 并写清楚 detailidlestate.json、join-keys.json、agents-state.json.bak/.default/.tmp)documents/API_INVENTORY.mddocuments/PROGRESS.mdREADME.md