Files
Arcrun/registry/components/code/DEPLOY.md
Leo efa0b0578c feat(code): Workers 就緒化(裁定 A)—— singlefile variant + 純 JS SHA-256 prelude
- 沙箱改用 quickjs-emscripten singlefile variant(wasm 內嵌 base64、同步載入),
  CF Workers 相容;sandbox.mjs 成 Node/Worker 共用 runtime-agnostic 核心。
- sha256 curated builtin 改「純 JS SHA-256 prelude 字串注入」,去掉 node:crypto /
  async Web Crypto host-call,Node/Worker 皆決定性(card content_hash 逐字等價)。
- index.ts 成可部署 Worker host(Hono,POST /→runCode),自足不走 TinyGo 模板流程。
- 補 wrangler.toml(arcrun-code / code.arcrun.dev)、tsconfig、DEPLOY.md。
- contract stability 修為 floating(過 registry zod schema 驗證)。
- 單測 12/12 全綠(含 card→envelope 與原模組 planCard 逐欄全等)。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJiLCRUU2o3aSpPEzVCt2o
2026-07-06 04:39:28 +00:00

2.1 KiB
Raw Permalink Blame History

code 零件 —— 部署清單(過閘用;本輪不執行)

封裝=Aquickjs-emscripten singlefile variant)。code自足 Worker,不走 deploy-logic-components.sh(那條是 TinyGo-wasm 專用)。以下由 leo 過閘後執行。

1. 部署 code Workerwrangler,禁 acr update

cd registry/components/code
npm install              # 裝 hono + quickjs-emscripten-core + singlefile variant
npm test                 # 12 測試須綠(部署前 gate
npx wrangler deploy      # → arcrun-coderoute code.arcrun.dev/*
  • Worker 名:arcrun-coderoutecode.arcrun.dev/*(見 wrangler.toml)。
  • 無需注入任何 secret/envcode 零件不碰網路/envWorker 本身零 binding。
  • 冷啟:quickjs wasm 內嵌 base64、同步 instantiate;首個請求 instantiate 一次後 module 快取。

2. 註冊到 registry index

REGISTRY_URL=https://registry.arcrun.dev bash registry/scripts/register-component.sh code
  • contract 已過 zod schema 驗證(stability: floatingcategory: logicio_model: stdin_stdout_jsongherkin_tests ≥2)。
  • sandbox_limits / config_example 為 yaml 內文件欄位,registry index 會 strip(不影響)。

3. 冒煙驗證(部署後)

# 基本
curl -s https://code.arcrun.dev/ | jq          # {ok:true, component:"code"}
curl -s -X POST https://code.arcrun.dev/ -H 'content-type: application/json' \
  -d '{"code":"return {sum: input.a + input.b};","input":{"a":2,"b":40}}' | jq
# → {"success":true,"data":{"sum":42}}
# 隔離
curl -s -X POST https://code.arcrun.dev/ -H 'content-type: application/json' \
  -d '{"code":"return typeof fetch;","input":{}}' | jq
# → {"success":true,"data":"undefined"}

4. 依賴的下游(Arcrun#8 workflow —— 另一分支)

code 零件是 km_wiki_ingest_drain workflow 的前置。workflow 在 feat/issue-8-mechanical-wiki-ingest 分支,以 component: code 引用本零件(registry 解析), 不需本零件檔案同分支。issue-8 的部署與 notes 寫入量見該分支 DEPLOY.md / 本輪回報的「一次過閘清單」。