From 981dc2508653dcc4900fc999ed524c6be4ddf366 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Jul 2026 09:08:27 +0000 Subject: [PATCH] =?UTF-8?q?feat(console):=20=E6=90=9C=E5=B0=8B/=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=8F=B0=E9=A0=81=20v0=EF=BC=88Arcrun#3=EF=BC=8CT-loo?= =?UTF-8?q?p1d=20=E9=9B=B2=E7=AB=AF=E5=A3=93=E6=B8=AC=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cypher-executor 新 route GET /console:單檔 HTML+原生 JS 薄殼,三查詢區 (KBDB/workflows/components+recipes)全打既有端點,無新業務邏輯。 components 改打「同帳號」arcrun-registry worker(WORKER_SUBDOMAIN 現算), 不硬打官方 registry.arcrun.dev,避免自架用戶查到別人的零件庫。 vectorize 狀態直接讀 KBDB 既有 mode/capability_hint,不開新 config 端點。 已部署 leo21c 帳號驗證:/console 200、三查詢 curl 皆 200 真回資料 (public-recipes 命中 telegram_send 真實紀錄)。 Co-Authored-By: Claude Fable 5 --- cypher-executor/src/index.ts | 2 + cypher-executor/src/routes/console.ts | 285 ++++++++++++++++++++++++++ 2 files changed, 287 insertions(+) create mode 100644 cypher-executor/src/routes/console.ts 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)); +});