/** * 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) * * 認證(v1,Arcrun#3 發現②改版):不再讓使用者貼 API Key(self-hosted 單租戶下那格本來就只是 * namespace 明碼字串,不是註冊制 key——leo 原話:理論上根本沒有 API Key 這件事)。改用簡單 * email+password 登入頁(routes/console-auth.ts,自己設一組帳密,無第三方 OAuth)。登入成功後端 * 發 session token 存 localStorage;**實際打 /kbdb/*、/workflows/search 仍用固定租戶字串** * (後端回應帶的 tenant,來自 CONSOLE_TENANT,登入系統只擋外人看頁面,不做多租戶)。 * 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,一頁查完。

① 登入

檢查登入狀態中...

② 知識庫(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)); });