Files
Arcrun/registry/components/kbdb_get/component.contract.yaml
T
Leo 497f92a268 feat(arcrun): recipe system + resumable workflow + component registry canon
Three new platform capabilities + one component (kbdb_get) to enable
real AI workflow execution through cypher binding YAML.

## Recipe System (容器 + Recipe 模式)
SDD: .agents/specs/recipe-system/

- prompt_recipe schema (Zod): fragments + inputs + assembly + output
- recipe-expander.ts: expand recipe ref → real prompt by fetching KBDB blocks
  + pulling context fields with transforms (pluck_content / extract_field / etc)
- 7 transform whitelist: json_array / to_string / join / markdown_list /
  extract_field / first / pluck_content
- graph-executor hooks: detect node.data.recipe → expand → inject into ctx
- output JSON parser (with markdown fence stripping for Claude-wrapped JSON)
- Stored in RECIPES KV under prompt_recipe:{name}

## Resumable Workflow (webhook callback resume)
SDD: .agents/specs/resumable-workflow/

- WorkflowPaused class + paused-runs.ts (persist/load/consume in EXEC_CONTEXT KV, 24h TTL)
- graph-executor: detect {pending:true, task_id} → persist state → throw WorkflowPaused
- cypher-handlers: catch → return {success:true, paused:true, task_id, run_id}
- POST /workflows/resume route: consume KV state → resumeFromPaused()
- Auto-inject callback_url for claude_api nodes (PUBLIC_BASE_URL or default cypher.arcrun.dev)
- claude_api/main.go: forward callback_url to Mira daemon, default timeout 25s→120s
- Idempotent (consume = load+delete)

## Component Registry Canon
SDD: .agents/specs/component-registry-canon/

- Add POST /components/index-only endpoint (metadata-only, no wasm/sandbox)
- Backfill script (mjs): scan registry/components/*/contract.yaml → submit to KV
- register-component.sh: SSOT for local + CI hook (deploy.yml change in next commit)
- Drop R2 dead storage from submitComponent + types + wrangler
- Schema relaxed: category enum + auth/ai/platform; cold_start 50→500ms; size 2→8MB

## kbdb_get component
- registry/components/kbdb_get/: TinyGo WASM, two modes (block_id / page_name list)
- .component-builds/kbdb_get/: WASI shim worker (kbdb-get.arcrun.dev)

End-to-end validation: AI uses MCP execute_workflow with recipe ref →
cypher-executor expands prompt from KBDB schema/skill blocks + drafts →
claude_api calls Mira daemon → daemon callback fires resume route →
workflow continues. Verified with real 2KB+ Karpathy LLM Wiki draft.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 15:52:19 +08:00

70 lines
2.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
canonical_id: "kbdb_get"
display_name: "KBDB 讀取"
category: "data"
version: "v1"
wasi_target: "preview1"
stability: "floating"
runtime_compat:
- "cf-workers"
- "workerd"
- "wazero"
constraints:
max_size_kb: 2048
max_cold_start_ms: 50
no_network_syscall: false
no_filesystem_syscall: true
io_model: "stdin_stdout_json"
input_schema:
type: object
required: [api_key]
properties:
api_key:
type: string
description: KBDB partner keypk_live_xxx 或 ak_xxx
block_id:
type: string
description: 取單一 block。給 block_id 走 GET /blocks/{id},與 page_name 二擇一
page_name:
type: string
description: 按 page_name 查列表。走 GET /blocks?page_name=...&limit=N
limit:
type: integer
description: page_name 模式下的最大筆數,預設 50
default: 50
kbdb_url:
type: string
description: KBDB API base(選填,預設 https://kbdb.finally.click
default: "https://kbdb.finally.click"
output_schema:
type: object
properties:
success:
type: boolean
blocks:
type: array
description: page_name 模式回多個 blockblock_id 模式回 1 個(仍包成陣列方便下游 foreach)
items:
type: object
count:
type: integer
description: blocks.length
error:
type: string
gherkin_tests:
- scenario: "缺 api_key"
given: '{"page_name":"x"}'
then_contains: '{"success":false'
- scenario: "block_id 與 page_name 都沒給"
given: '{"api_key":"pk_live_x"}'
then_contains: '{"success":false'
tags: [data, storage, kbdb, get, query, primitive]
description: "從 KBDB 讀 block。支援兩種模式:(1) block_id 取單一 block(2) page_name 取列表。透過 host function http_request 呼叫 KBDB GET /blocks 或 /blocks/:id。Mira wiki 合成 / 各 source workflow 讀草稿 / 查 wiki schema 都走這條。"
config_example: |
read_schema: # 取單一 block
api_key: "{{secret.kbdb_key}}"
page_name: "mira-wiki-schema"
read_drafts: # 取列表
api_key: "{{secret.kbdb_key}}"
page_name: "{{prev.entity_name}}"
limit: 100