返回 CodeWhale
page.tsx
根目录 / web / app / [locale] / runtime / page.tsx
1 import { Seal } from "@/components/seal";
2 import { getFacts } from "@/lib/facts";
3 import { buildPageMetadata } from "@/lib/page-meta";
4
5 const REPO_BLOB_BASE = "https://github.com/Hmbown/CodeWhale/blob/main";
6
7 export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }) {
8 const { locale } = await params;
9 const isZh = locale === "zh";
10 return buildPageMetadata({
11 path: "/runtime",
12 locale,
13 title: isZh ? "Runtime & 集成 · Codewhale" : "Runtime & Integrations · Codewhale",
14 description: isZh
15 ? "Codewhale 的本地 Runtime API、HTTP/SSE、ACP stdio 适配器、MCP 服务器、VS Code 配套扩展与消息桥接。"
16 : "Codewhale's local Runtime API, HTTP/SSE, baseline ACP stdio adapter, MCP servers, Phase 0 VS Code companion, and messaging bridges.",
17 });
18 }
19
20 interface Integration {
21 name: string;
22 desc: string;
23 descZh: string;
24 href: string;
25 }
26
27 const INTEGRATIONS: Integration[] = [
28 {
29 name: "HTTP / SSE Runtime API",
30 desc: "Full local HTTP + Server-Sent Events runtime API on 127.0.0.1:7878. Create threads, stream turns, manage background jobs, and control approval decisions — all from any HTTP client or the bundled mobile page.",
31 descZh: "完整的本地 HTTP + Server-Sent Events Runtime API,监听 127.0.0.1:7878。创建线程、流式对话、管理后台任务、控制审批决策——任意 HTTP 客户端或内置手机页面皆可调用。",
32 href: `${REPO_BLOB_BASE}/docs/RUNTIME_API.md`,
33 },
34 {
35 name: "ACP (Agent Client Protocol)",
36 desc: "Baseline JSON-RPC adapter over stdio for compatible editor clients such as Zed. It supports initialize, new session, prompt, and cancel with text responses; shell and file tools, checkpoint replay, and session loading remain on the full Runtime API.",
37 descZh: "面向 Zed 等兼容编辑器客户端的基础 JSON-RPC stdio 适配器。它支持初始化、新建会话、提示和取消,并返回文本响应;shell 与文件工具、检查点回放和会话加载仍由完整 Runtime API 提供。",
38 href: `${REPO_BLOB_BASE}/docs/RUNTIME_API.md`,
39 },
40 {
41 name: "MCP (Model Context Protocol)",
42 desc: "Connect Codewhale to external tools and services through configured MCP servers over stdio or HTTP/SSE, or expose Codewhale's own tools to another MCP client.",
43 descZh: "通过已配置的 MCP 服务器(stdio 或 HTTP/SSE)将 Codewhale 连接到外部工具和服务,或把 Codewhale 自身工具暴露给其他 MCP 客户端。",
44 href: `${REPO_BLOB_BASE}/docs/MCP.md`,
45 },
46 {
47 name: "VS Code Extension",
48 desc: "Phase 0 companion for the local runtime. It can open Codewhale in a terminal, start and check the Runtime API, and show read-only thread summaries and restore points. It does not yet provide full chat, inline edits, or editor actions.",
49 descZh: "本地 Runtime 的 Phase 0 配套扩展。它可以在终端中打开 Codewhale、启动并检查 Runtime API,以及显示只读线程摘要和还原点;目前尚不提供完整聊天、内联编辑或编辑器操作。",
50 href: "https://github.com/Hmbown/CodeWhale/tree/main/extensions/vscode",
51 },
52 {
53 name: "Telegram Bridge",
54 desc: "First-party Telegram bot bridge. Start a headless Codewhale session, then chat with it from any Telegram client — approvals, tool results, and completions surface inline.",
55 descZh: "官方 Telegram 机器人桥接。启动无头 Codewhale 会话,在任何 Telegram 客户端中与之对话——审批、工具结果和完成状态内联展示。",
56 href: "https://github.com/Hmbown/CodeWhale/tree/main/integrations/telegram-bridge",
57 },
58 {
59 name: "Feishu / Lark Bridge",
60 desc: "First-party Feishu / Lark bot bridge. Chat-native agent loop inside your Feishu workspace with approval cards, session linking, and audit trail.",
61 descZh: "官方飞书 / Lark 机器人桥接。在飞书工作区内实现聊天原生 Agent 循环,支持审批卡片、会话关联和审计日志。",
62 href: "https://github.com/Hmbown/CodeWhale/tree/main/integrations/feishu-bridge",
63 },
64 {
65 name: "Weixin Bridge (实验性)",
66 desc: "Experimental Weixin / WeChat bridge. Receive agent completions and approvals inside WeChat; early-stage and not recommended for production deployments.",
67 descZh: "实验性微信桥接。在微信中接收 Agent 完成通知和审批;早期阶段,不建议用于生产环境。",
68 href: "https://github.com/Hmbown/CodeWhale/tree/main/integrations/weixin-bridge",
69 },
70 ];
71
72 function FactRow({ label, children }: { label: string; children: React.ReactNode }) {
73 return (
74 <div className="py-3 hairline-b grid gap-1 sm:grid-cols-[10rem_1fr] sm:gap-6 sm:items-baseline">
75 <div className="eyebrow">{label}</div>
76 <div className="min-w-0 font-mono text-sm text-ink-soft break-words">{children}</div>
77 </div>
78 );
79 }
80
81 export default async function RuntimePage({ params }: { params: Promise<{ locale: string }> }) {
82 const { locale } = await params;
83 const isZh = locale === "zh";
84 const facts = await getFacts();
85
86 return (
87 <>
88 {/* Hero */}
89 <section className="site-container section">
90 <div className="flex items-baseline gap-4 mb-3">
91 <Seal char="接" />
92 <div className="eyebrow">{isZh ? "Runtime & 集成" : "Runtime & Integrations"}</div>
93 </div>
94 <h1 className="font-display tracking-crisp mb-6">
95 {isZh ? (
96 <>运行时与集成<span className="font-cjk text-indigo text-5xl ml-2">Runtime &amp; Integrations</span></>
97 ) : (
98 <>Runtime &amp; Integrations<span className="font-cjk text-indigo text-5xl ml-2">运行时与集成</span></>
99 )}
100 </h1>
101
102 <p className="max-w-2xl text-ink-soft leading-relaxed">
103 {isZh
104 ? "Codewhale 不仅是一个终端 Agent——它还是一个可通过多种协议和集成方式嵌入到你现有工作流中的本地控制平面。"
105 : "Codewhale is more than a terminal agent — it is a local control plane you can embed into your existing workflow through multiple protocols and integrations."}
106 </p>
107 </section>
108
109 {/* Runtime facts */}
110 <section className="site-container py-8 hairline-t">
111 <div className="flex items-baseline gap-4 mb-4">
112 <Seal char="数" />
113 <div className="eyebrow">{isZh ? "运行时事实" : "Runtime facts"}</div>
114 </div>
115 <div className="hairline-t">
116 <FactRow label={isZh ? "版本" : "Version"}>{facts.version ?? "—"}</FactRow>
117 <FactRow label={isZh ? "工具数量" : "Tool count"}>{facts.toolCount ?? "—"}</FactRow>
118 <FactRow label={isZh ? "沙箱后端" : "Sandbox backends"}>
119 {facts.sandboxBackends.length ? facts.sandboxBackends.join(" · ") : "—"}
120 </FactRow>
121 <FactRow label={isZh ? "Crates" : "Crates"}>
122 {facts.crates.length ? `${facts.crates.length} · ${facts.crates.join(", ")}` : "—"}
123 </FactRow>
124 <FactRow label={isZh ? "源码版本" : "Source revision"}>
125 <code className="inline break-all">{facts.sourceRevision ?? "—"}</code>
126 </FactRow>
127 </div>
128 </section>
129
130 {/* Trust boundary */}
131 <section className="site-container py-8 hairline-t">
132 <div className="flex items-baseline gap-4 mb-4">
133 <Seal char="信" />
134 <div className="eyebrow">{isZh ? "信任边界" : "Trust boundary"}</div>
135 </div>
136 <div className="grid sm:grid-cols-2 gap-6 text-sm text-ink-soft leading-relaxed">
137 <div>
138 <strong className="text-ink">{isZh ? "本机运行" : "Runs on your machine"}</strong>
139 <p className="mt-1">
140 {isZh
141 ? "Runtime API 默认仅监听 127.0.0.1。本地运行时不需要 Codewhale 账户或托管中继。"
142 : "The Runtime API binds 127.0.0.1 by default. The local runtime does not require a Codewhale account or hosted relay."}
143 </p>
144 </div>
145 <div>
146 <strong className="text-ink">{isZh ? "认证必需" : "Auth required"}</strong>
147 <p className="mt-1">
148 {isZh
149 ? "所有 Runtime API 路由(/v1/*)需要 Bearer Token。配置 CODEWHALE_RUNTIME_TOKEN 环境变量或 config.toml 中的 auth_token。"
150 : "All Runtime API routes (/v1/*) require a Bearer token. Set CODEWHALE_RUNTIME_TOKEN env var or auth_token in config.toml."}
151 </p>
152 </div>
153 <div>
154 <strong className="text-ink">{isZh ? "权限用户控制" : "Permissions user-controlled"}</strong>
155 <p className="mt-1">
156 {isZh
157 ? "远程客户端通过经过认证的 Runtime API 提交请求与审批决定。本地模式、权限姿态和沙箱策略仍然生效。"
158 : "Remote clients submit requests and approval decisions through the authenticated Runtime API. Local mode, permission posture, and sandbox policy still apply."}
159 </p>
160 </div>
161 <div>
162 <strong className="text-ink">{isZh ? "开放协议" : "Open protocols"}</strong>
163 <p className="mt-1">
164 {isZh
165 ? "HTTP/SSE Runtime API、MCP 和基础 ACP stdio 适配器分别服务于不同集成场景;请根据客户端需要选择对应接口。"
166 : "The HTTP/SSE Runtime API, MCP surface, and baseline ACP stdio adapter serve different integration needs; choose the interface your compatible client supports."}
167 </p>
168 </div>
169 </div>
170 </section>
171
172 {/* Integration cards */}
173 <section className="site-container py-10 hairline-t">
174 <div className="flex items-baseline gap-4 mb-6">
175 <Seal char="集" />
176 <h2 className="eyebrow">{isZh ? "集成方式" : "Integration surfaces"}</h2>
177 </div>
178
179 <div className="grid sm:grid-cols-2 gap-6">
180 {INTEGRATIONS.map((item) => (
181 <div key={item.name} className="hairline rounded-lg p-5 bg-paper hover:bg-paper-deep transition-colors">
182 <h3 className="font-semibold text-base mb-2">
183 <a href={item.href} target="_blank" rel="noopener noreferrer" className="body-link">
184 {item.name} ↗
185 </a>
186 </h3>
187 <p className="text-sm text-ink-soft leading-relaxed">
188 {isZh ? item.descZh : item.desc}
189 </p>
190 </div>
191 ))}
192 </div>
193 </section>
194
195 {/* Read more */}
196 <section className="site-container py-8 hairline-t">
197 <p className="text-sm text-ink-soft">
198 {isZh ? (
199 <>
200 详细实现文档:{" "}
201 <a
202 href={`${REPO_BLOB_BASE}/docs/RUNTIME_API.md`}
203 target="_blank"
204 rel="noopener noreferrer"
205 className="body-link"
206 >
207 Runtime API 与 ACP stdio 适配器 ↗
208 </a>
209 {" · "}
210 <a
211 href={`${REPO_BLOB_BASE}/docs/MCP.md`}
212 target="_blank"
213 rel="noopener noreferrer"
214 className="body-link"
215 >
216 MCP 集成 ↗
217 </a>
218 </>
219 ) : (
220 <>
221 Detailed implementation docs:{" "}
222 <a
223 href={`${REPO_BLOB_BASE}/docs/RUNTIME_API.md`}
224 target="_blank"
225 rel="noopener noreferrer"
226 className="body-link"
227 >
228 Runtime API and ACP stdio adapter ↗
229 </a>
230 {" · "}
231 <a
232 href={`${REPO_BLOB_BASE}/docs/MCP.md`}
233 target="_blank"
234 rel="noopener noreferrer"
235 className="body-link"
236 >
237 MCP integration ↗
238 </a>
239 </>
240 )}
241 </p>
242 </section>
243 </>
244 );
245 }
246
246 lines Plain Text