diff --git a/cypher-executor/src/index.ts b/cypher-executor/src/index.ts index c97fd30..6cd92e4 100644 --- a/cypher-executor/src/index.ts +++ b/cypher-executor/src/index.ts @@ -21,6 +21,7 @@ import { resumeRouter } from './routes/resume'; import { executionsRouter } from './routes/executions'; import { initSeedRouter } from './routes/init-seed'; import { kbdbProxyRouter } from './routes/kbdb-proxy'; +import { consoleRouter } from './routes/console'; const app = new Hono<{ Bindings: Bindings }>(); @@ -50,6 +51,7 @@ app.route('/', resumeRouter); app.route('/', executionsRouter); // LI SDD M2.1: /executions/* + /workflows/:name/executions app.route('/', initSeedRouter); // 薄殼原則:seed recipe 是 API 行為(rule 07,壓測 §4.1) app.route('/', kbdbProxyRouter); // kbdb-base 9.5:KBDB 資料層 proxy(讓 CLI 透過 cypher 達 KBDB,純轉發) +app.route('/', consoleRouter); // Arcrun#3:搜尋/控制台頁 v0(單檔 HTML+原生 JS,薄殼) // Worker 導出(fetch + scheduled) // scheduled handler 對應 wrangler.toml [triggers].crons,每分鐘 tick; diff --git a/cypher-executor/src/routes/console.ts b/cypher-executor/src/routes/console.ts new file mode 100644 index 0000000..45dddb9 --- /dev/null +++ b/cypher-executor/src/routes/console.ts @@ -0,0 +1,285 @@ +/** + * arcrun 控制台頁 v0(Gitea Arcrun#3,2026-07-02 leo 交辦) + * + * 薄殼(rule 07):單檔 HTML + 原生 JS,無框架、無 build step,零業務邏輯—— + * 只 fetch 既有 API 並渲染。缺端點不在這裡拼裝補,回報 issue。 + * + * 三個查詢區各打「既有」端點,單一真相源(禁硬編清單重演 parts.ts stale 教訓): + * - 知識庫:同源 GET /kbdb/search(kbdb-proxy.ts,X-Arcrun-API-Key) + * - workflows:同源 GET /workflows/search(webhooks-named.ts,同 header) + * - components/recipes:components 打「同帳號」的 arcrun-registry worker(跟 MCP + * COMPONENT_REGISTRY service binding 同一顆——self-hosted 各自一份,不是硬打官方 + * registry.arcrun.dev,否則自架用戶查到的是別人的零件庫)。URL 用既有 WORKER_SUBDOMAIN + * env var 現算(同 KBDB_BASE_URL 那套 arcrun-{name}.{subdomain}.workers.dev 慣例), + * 不新增 binding;CORS 該 worker已開;不需 auth。 + * recipes 打同源 GET /public-recipes(recipes.ts,公庫,不需 auth) + * + * 認證:頁面請用戶貼一次 X-Arcrun-API-Key(self-hosted=namespace 明碼),存 localStorage。 + * knowledge/workflows 兩區需要;components/recipes 是公開資料,不需要。 + * + * config 區(v0 唯讀):vectorize 狀態不是新端點——直接讀「知識庫」查詢回應本身的 mode/ + * capability_hint(kbdb entries.ts 既有機制:要求 semantic、缺 Vectorize 就誠實降級並帶 hint)。 + */ +import { Hono } from 'hono'; +import type { Bindings } from '../types'; + +export const consoleRouter = new Hono<{ Bindings: Bindings }>(); + +function renderConsoleHtml(registryBase: string): string { + return ` + + + + +arcrun Console + + + +
+

arcrun Console

+

裝了就有的搜尋台——知識庫 / workflows / components & recipes,一頁查完。

+
+
+
+

① API Key

+
+ + +
+
存在瀏覽器 localStorage,不送去別的地方。知識庫/workflows 查詢需要它;components/recipes 是公庫資料不用。
+
+ +
+

② 知識庫(KBDB)

+
+ + +
+
+ +
+ +
+

③ Workflows

+
+ + +
+
+ +
+ +
+

④ Components & Recipes

+
+ + +
+
+
Components
+ +
Recipes
+ +
+
+ + + + +`; +} + +// GET /console — 控制台頁 v0(Arcrun#3)。registry base 現算:同帳號 arcrun-registry worker +// (WORKER_SUBDOMAIN 沿用既有 KBDB_BASE_URL 那套組法),沒設就退回官方公開 registry。 +consoleRouter.get('/console', (c) => { + const subdomain = c.env.WORKER_SUBDOMAIN; + const registryBase = subdomain + ? `https://arcrun-registry.${subdomain}.workers.dev` + : 'https://registry.arcrun.dev'; + return c.html(renderConsoleHtml(registryBase)); +});