t159 步驟4 意圖節點→真實零件/recipe 替換+/cypher/search 加 target 指定搜尋對象
CP arcrun-usable 步驟 4(目的:AI 只要填 payload——系統把「傳到 telegram」
翻成 http_request+recipe telegram_send)+leo 07-31 追加:
「難道我不能指定要搜尋工作流或節點或 recipe 嗎?」
替換(只動 discover,t158「部署≠發現」邊界不碰):
- 兩庫 exact 落空後,在 t158 一次抓好的清單記憶體內媒合,零新增 round-trip
- 規則 A 服務詞→recipe:名字全部服務詞命中同一 recipe 且唯一才換
(google_slides_create 不被 google_sheets 誤吃)
- 規則 B 強欄位斷詞→零件:canonical/display/aliases 強命中×10+弱命中,
需至少一強命中且分數唯一最高(aes_encrypt 無強命中不換)
- 換到=status resolved+substitution{from,componentId,recipe,reason},
cypher 圖節點直接帶真實 componentId;換不到照舊 not_found+3.7 指路
target 參數(各走既有機制,不新造第二套搜尋):
- triplets+target=component|recipe=只查該庫
- query+target=名字搜尋:component→registry /components/search(=MCP
arcrun_search_components 同路);recipe→私庫 RECIPES KV(回應註明公庫走
arcrun_recipe_search);workflow→新抽 lib/workflow-search.ts,
GET /workflows/search 與 target=workflow 共用(=arcrun_search_workflows 同路)
- 防呆:compile+target 400/target=workflow 吃 query 不吃 triplets/非法 target 400
驗(本地 wrangler dev,registry 種 20 合約+init/seed 10 recipe):
- 「判斷有沒有新資料 >> ON_SUCCESS >> 傳到 telegram」→ if_control(resolved)
+telegram_send(substitution.componentId=http_request)=feature 06 驗法過
- 機械考 27/27 全綠(01 組×5+03 組×4 迴歸+06 組×8+target×8+compile 迴歸×2)
- 冷啟第一發 94ms、熱 8–13ms(t158 病史對照:舊 25.7s);compile 39ms unchecked 照舊
- tsc 全綠;vitest 9 failed/179 passed=t158 基線完全相同
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* workflow-search — 本租戶 workflow 名字搜尋的**唯一一條路**
|
||||
*
|
||||
* 既有機制(workflow-discovery 3.1):轉發 KBDB /entries/search
|
||||
* (entry_type=workflow + owner_id=apiKey 租戶隔離;優先 semantic,KBDB 未開
|
||||
* Vectorize 自動降級 keyword + capability_hint)。
|
||||
*
|
||||
* 為什麼抽成共用(leo 07-31:「search 節點名稱和 search 工作流名稱是同一個?
|
||||
* 難道我不能指定要搜尋工作流或節點或 recipe 嗎?」+「外部 API 只有一條一致的路」鐵律):
|
||||
* - GET /workflows/search(MCP arcrun_search_workflows 走的路)
|
||||
* - POST /cypher/search { target: "workflow", query }(discover 入口指定搜尋對象)
|
||||
* 兩個入口共用本函式 ⇒ 行為必然一致,改一處兩邊同步。
|
||||
*
|
||||
* 已知缺口(如實透傳,不掩蓋):workflow_metadata 無 description slot——
|
||||
* 無 description 的 workflow 沒有 search entry、搜不到;補救走
|
||||
* POST /workflows/backfill-search-entries(有 description 的補 entry、沒有的誠實列出)。
|
||||
*
|
||||
* flag 安全:主動 pull,無輪詢/排程。
|
||||
*/
|
||||
|
||||
export type WorkflowSearchEnv = {
|
||||
KBDB_BASE_URL?: string;
|
||||
KBDB_INTERNAL_TOKEN?: string;
|
||||
};
|
||||
|
||||
export type WorkflowSearchMode = 'semantic' | 'keyword';
|
||||
|
||||
/**
|
||||
* 打 KBDB /entries/search(本租戶、entry_type=workflow)。
|
||||
* 回原始 Response——GET /workflows/search 直接 stream 透傳(既有行為,一字不改);
|
||||
* target=workflow 的呼叫端自行 json() 解析。
|
||||
*/
|
||||
export async function fetchTenantWorkflowSearch(
|
||||
env: WorkflowSearchEnv,
|
||||
apiKey: string,
|
||||
q: string,
|
||||
mode: WorkflowSearchMode = 'semantic',
|
||||
): Promise<Response> {
|
||||
const base = (env.KBDB_BASE_URL ?? 'https://arcrun-kbdb.uncle6-me.workers.dev').replace(/\/$/, '');
|
||||
const headers: Record<string, string> = { 'Content-Type': 'application/json' };
|
||||
if (env.KBDB_INTERNAL_TOKEN) headers['Authorization'] = `Bearer ${env.KBDB_INTERNAL_TOKEN}`;
|
||||
const params = new URLSearchParams({
|
||||
q,
|
||||
owner_id: apiKey, // 租戶隔離(只搜本租戶的 workflow)
|
||||
entry_type: 'workflow', // base 通用 filter(Q4),只回 workflow entry
|
||||
mode,
|
||||
});
|
||||
return fetch(`${base}/entries/search?${params.toString()}`, { headers });
|
||||
}
|
||||
Reference in New Issue
Block a user