6a75117ba3
kbdb-base SDD §7.5(公庫/私庫雙向機制,richblack 2026-06-07 拍板)。
## KBDB Base worker(新)
- kbdb/:D1-only 核心三表(entries/templates/entry_values)+ CRUD + LIKE search
+ recipe-stats 端點(市場數據)+ 0001_base.sql migration(含 recipe_stat seed)
## Phase 2.3:init 建 D1 + 套 migration
- cli cf-api.ts 加 listD1Databases/ensureD1Database;init 建 arcrun-kbdb D1
- deploy.ts 部署後對 D1 套 0001_base.sql(CF /d1/query API,idempotent)+ 注入 database_id
## Phase 5.1:recipe 成功記錄(市場數據來源)
- GraphExecutor 收集本次用到的 recipe uuid(usedRecipeKeys)
- executeWebhookGraph 執行結束一次性記 per-uuid 成功/失敗到 KBDB(fire-and-forget)
## Phase 7.5:recipe UUID 身份 + app-store 模型
- recipe 領 uuid=唯一身份;canonical_id/author/公私=屬性(§7.5.5)
- recipe:{uuid} + idx:canonical/installed/hash;resolveRecipe 向後相容不破執行鏈
- POST /recipes/submit=領新 uuid 新增作者版本(非覆蓋,app-store)
- GET /public-recipes 搜尋(多作者+per-uuid 市場星數)/ :id pull(選市場最佳)
- 落空→found:false 創作引導(§7.5.6 閉環)
- POST /recipes/migrate-uuid 一次性轉舊 key(增量寫不刪舊、冪等)
- init-seed 用 UUID(author=system)
## 薄殼(rule 07 §5:CLI + MCP 覆蓋同組能力)
- CLI: acr recipe search/pull/submit-p(config 加 DEFAULT_PUBLIC_LIBRARY_URL)
- MCP: arcrun_recipe_search/pull/submit_p/push/list/delete(補齊漂移)
## 壓測修正
- api-recipe-seeds: google_sheets_append PUT→POST(:append 正確動詞,階段12)
四 worker tsc 全綠(cypher/cli/kbdb/mcp)。
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
124 lines
5.3 KiB
TypeScript
124 lines
5.3 KiB
TypeScript
/**
|
||
* api-recipe-seeds.ts(server 端,唯一真相)
|
||
*
|
||
* 現役 API recipe 的種子定義。self-host 新帳號裝好後,POST /init/seed 端點把這些灌進空的 RECIPES KV。
|
||
*
|
||
* API recipe = http_request + 固定設定(endpoint/method 模板)。
|
||
* 不需 deploy Worker,cypher-executor 執行時直接 fetch(見 routes/recipes.ts)。
|
||
*
|
||
* 為何放在 cypher-executor/src(薄殼原則 rule 07 + 壓測 §5.5):
|
||
* - 「裝好之後預設有哪些 recipe」是 API 的能力,不是 CLI 的。seed 應由 API 端點完成
|
||
* (POST /init/seed),CLI/MCP 只呼叫一次。種子資料是這個能力的一部分,故放 server。
|
||
* - 種子的 endpoint 字串(sheets.googleapis.com 等)是 recipe 的「資料欄位」(宣告打哪),
|
||
* 非 TS 裡的呼叫實作;真正呼叫仍走零件 / http_request。rule 02 §2.2 hook 已對本檔加例外
|
||
* (richblack 2026-06-06 授權,與 auth-recipe-seeds.ts 同理由)。
|
||
*
|
||
* 來源:2026-06-01 從 prod cypher.arcrun.dev/recipes 逐一查得的現役定義。
|
||
* 對應 SDD:.agents/specs/arcrun/sdk-and-website/self-hosted-init.md §5
|
||
*
|
||
* KBDB recipe(kbdb_*)採 Supabase 模式(richblack 2026-06-02):
|
||
* 進 seed = 展示能力(引子)。使用者要用 → 去 arcrun 取統一 API Key 當 credential。
|
||
* FOLLOW-UP(KBDB 端):endpoint 現為 kbdb.finally.click,KBDB 應改用統一對外網址;
|
||
* KBDB 改網址後同步更新此處。seed 先照現況進。
|
||
*/
|
||
|
||
export interface ApiRecipeSeed {
|
||
canonical_id: string;
|
||
display_name: string;
|
||
description?: string;
|
||
endpoint: string;
|
||
method: string;
|
||
auth_service?: string;
|
||
}
|
||
|
||
export const API_RECIPE_SEEDS: ApiRecipeSeed[] = [
|
||
// ── KBDB(Supabase 模式,auth_service=kbdb static_key)──
|
||
{
|
||
canonical_id: 'kbdb_get',
|
||
display_name: 'KBDB Get',
|
||
description: 'GET 讀取 block / 查詢。_path 帶查詢路徑。auth: kbdb static_key。',
|
||
endpoint: 'https://kbdb.finally.click{{_path}}',
|
||
method: 'GET',
|
||
auth_service: 'kbdb',
|
||
},
|
||
{
|
||
canonical_id: 'kbdb_create_block',
|
||
display_name: 'KBDB Create Block',
|
||
description: 'POST /blocks 建立 block。body 帶 block 欄位(content/type/page_name/source/user_id 等)。auth: kbdb static_key。',
|
||
endpoint: 'https://kbdb.finally.click/blocks',
|
||
method: 'POST',
|
||
auth_service: 'kbdb',
|
||
},
|
||
{
|
||
canonical_id: 'kbdb_patch_block',
|
||
display_name: 'KBDB Patch Block',
|
||
description: 'PATCH /blocks/:id 局部更新。_path 帶 /blocks/{id},body 帶要改的欄位。auth: kbdb static_key。',
|
||
endpoint: 'https://kbdb.finally.click{{_path}}',
|
||
method: 'PATCH',
|
||
auth_service: 'kbdb',
|
||
},
|
||
{
|
||
canonical_id: 'kbdb_delete',
|
||
display_name: 'KBDB Delete',
|
||
description: 'DELETE /blocks/:id 刪除 block。_path 帶 /blocks/{id}。auth: kbdb static_key。',
|
||
endpoint: 'https://kbdb.finally.click{{_path}}',
|
||
method: 'DELETE',
|
||
auth_service: 'kbdb',
|
||
},
|
||
{
|
||
canonical_id: 'kbdb_ingest',
|
||
display_name: 'KBDB Ingest',
|
||
description: 'POST /blocks/ingest 批次寫入。body 帶 input。auth: kbdb static_key。',
|
||
endpoint: 'https://kbdb.finally.click/blocks/ingest',
|
||
method: 'POST',
|
||
auth_service: 'kbdb',
|
||
},
|
||
|
||
// ── Google(service_account)──
|
||
{
|
||
canonical_id: 'gmail_send',
|
||
display_name: 'Gmail Send',
|
||
description: '寄 Gmail。POST messages/send,body 帶 raw(base64url MIME)。auth: google service_account。',
|
||
endpoint: 'https://gmail.googleapis.com/gmail/v1/users/me/messages/send',
|
||
method: 'POST',
|
||
auth_service: 'google_gmail_sa',
|
||
},
|
||
{
|
||
canonical_id: 'google_sheets_append',
|
||
display_name: 'Google Sheets Append',
|
||
// 壓測階段 12 修正:append 官方 API 是 POST .../values/{range}:append(PUT 是 values.update 覆寫的動詞),
|
||
// 種子寫死 PUT 導致每個 self-host 用戶 seed 到壞 recipe(PUT :append → Google 400)。
|
||
// body 形狀屬工作流,泛用種子不寫死欄位 → 由工作流的 _path + body 處理(body_from 機制待 §13.4 補)。
|
||
description: '追加一列到 Sheets。POST .../values/{range}:append?valueInputOption=RAW,body 帶 {values:[[...]]}。auth: google service_account。',
|
||
endpoint: 'https://sheets.googleapis.com{{_path}}',
|
||
method: 'POST',
|
||
auth_service: 'google_sheets_sa',
|
||
},
|
||
{
|
||
canonical_id: 'google_sheets_read',
|
||
display_name: 'Google Sheets Read',
|
||
description: '讀 Sheets。GET values。_path 帶完整路徑。auth: google service_account。',
|
||
endpoint: 'https://sheets.googleapis.com{{_path}}',
|
||
method: 'GET',
|
||
auth_service: 'google_sheets_sa',
|
||
},
|
||
|
||
// ── 訊息(static_key)──
|
||
{
|
||
canonical_id: 'telegram_send',
|
||
display_name: 'Telegram Send',
|
||
description: 'Telegram sendMessage。token 在 URL path({{auth.bot_token}}),body 帶 chat_id+text。auth: static_key path 注入。',
|
||
endpoint: 'https://api.telegram.org/bot{{auth.bot_token}}/sendMessage',
|
||
method: 'POST',
|
||
auth_service: 'telegram',
|
||
},
|
||
{
|
||
canonical_id: 'line_notify_send',
|
||
display_name: 'LINE Notify',
|
||
description: 'LINE Notify 推訊息。POST notify,body 帶 message(form-urlencoded)。auth: static_key Bearer line token。',
|
||
endpoint: 'https://notify-api.line.me/api/notify',
|
||
method: 'POST',
|
||
auth_service: 'line_notify',
|
||
},
|
||
];
|