Skip to content

feat(workbench): scaffold calli workbench app - #8782

Open
maxliux5 wants to merge 1 commit into
loopx-project:mainfrom
maxliux5:codex/calli-workbench-scaffold
Open

maxliux5 wants to merge 1 commit into
loopx-project:mainfrom
maxliux5:codex/calli-workbench-scaffold

Conversation

@maxliux5

@maxliux5 maxliux5 commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds an empty, independently built frontend at apps/presentation/calli-workbench/
with its toolchain. It makes no network calls and has no dev proxy yet. It
contains no product code yet; the page renders an empty shell.

This is the first of three stacked PRs:

  1. A scaffold (this PR): directory and toolchain.
  2. B shell: the workbench UI (three panes, machine switcher, launch bar,
    triage) on a built-in synthetic workspace, with no backend.
  3. C projections: the same UI reading LoopX projections, GET only,
    through a single read-only forwarding boundary.

Each PR builds and runs on its own. Related design notes: #8778 (open; not a
prerequisite for this PR).

Change boundary

  • Every file is under apps/presentation/calli-workbench/.
  • No change to loopx/, packages/, other apps, root configuration, CI or
    scripts. The app is not part of any existing build, workflow or startup path.
  • No runtime dependency on LoopX code and no network calls. vite.config.ts
    has no proxy: nothing in this layer calls a LoopX service. The read-only
    proxy arrives with the projections PR, together with its first caller, so
    the routing and method checks are reviewed in one place next to the code
    that needs them. Dev server port is 5174, so it can run next to the
    dashboard on 5173.

Files:

File Purpose
package.json, package-lock.json Self-contained app (no workspaces); scripts dev, build (tsc --noEmit && vite build), preview
vite.config.ts React plugin, ports 5174/4174, build target; no proxy
tsconfig.json, .gitignore Strict TypeScript; ignores node_modules/, dist/
index.html, src/main.tsx Minimal entry so the build has a target
README.md What the app is, how to run it, how it relates to the dashboard, what B and C add

Deviations

Id Deviation Impact and follow-up
D-1 React 18 / Vite 5 / TypeScript 5, not the dashboard's React 19 / Vite 8 / TypeScript 6 Separate directory and lockfile; nothing is shared with the dashboard and nothing enters the LoopX startup path. A stack upgrade follows as its own PR under the same tests.
D-2 The Calli stylesheet is kept as-is instead of being migrated to the tokens in docs/development/design.md Visual only; no state or authority impact. Token migration (color, type, radius first, then components) follows as a separate PR; this stack does not claim design-system conformance.
D-3 Large diff in B, mostly moved code B's review can focus on the files listed there as changed from the source; the rest is a verbatim move, checkable with diff -r against Calli packages/web @ 87adcde. A and C are small.
D-4 License: resolved — Apache-2.0 + NOTICE package.json declares Apache-2.0; NOTICE carries the attribution and the relicensing statement.

In this PR only D-1 (versions pinned in package.json) is visible and D-4 is resolved (license: Apache-2.0); D-2 and D-3 apply to B and are listed here so the whole stack is reviewed against one register.

License

Apache-2.0. Ported from Calli packages/web, relicensed under the Apache License, Version 2.0 with contributor consent (see NOTICE). NOTICE (added with the ported code in B) reads: "Portions derived from Calli
(https://github.com/maxliux5/calli). Copyright Calli contributors. Relicensed
under the Apache License, Version 2.0 with contributor consent."

Validation

$ cd apps/presentation/calli-workbench
$ npm ci && npm run build
> tsc --noEmit && vite build
vite v5.4.21 building for production...
✓ 29 modules transformed.
dist/index.html                  0.32 kB │ gzip:  0.23 kB
dist/assets/index-OjejHykI.js  142.44 kB │ gzip: 45.73 kB
✓ built in 677ms
  • git diff --stat origin/main...HEAD: 8 files, all under
    apps/presentation/calli-workbench/ (+1,880 lines, almost all of them
    package-lock.json).
  • The lockfile resolves only from registry.npmjs.org.
  • Pre-commit scan of the staged diff: no local paths, hostnames, credentials or
    e-mail addresses.

Visual evidence

Not applicable: this PR renders an empty shell. B carries the first-screen
screenshots.

Tested revision: 1b582b554.

Rollback

Revert this PR. That removes the apps/presentation/calli-workbench/
directory; nothing else in the repository references it.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 5738dc7d71b62345189875b61d88a1863635c099,GitHub 目标基线 74ca883d5bd3e4bc64671bac54210eac9e97ed05。本地合并模拟与主干行为对照为 48dbebbd14c5535b9631f4c7a1152d86aa64c5b2。

[P2] 只读代理允许写入 Chat 偏好。 Vite 把整个 /api/chat 前缀交给可写 Chat 服务,代理不限制 HTTP 方法。开发服务和构建预览的同源 POST 都返回 200,随后 GET 和隔离运行目录都读回了刚保存的偏好。 把真实代理移到首个实际读取的提交,或在当前代理边界只放行需要的 GET 路由并拒绝其余方法,开发与预览用同一只读规则。 问题位置

动机 / Motivation

开发者想在同一页面比较多个 Agent 会话,最初需要一份能独立构建、随后接入现有 LoopX 读接口的 Workbench。 当前主干没有这个独立入口。这个提交能在本地打开空页面,开发服务和构建预览同时开放一条通向现有 Chat 服务的代理。 干净安装后构建通过,空页可加载,代理的读取也能正常工作。同源客户端还可以经代理写入 Chat 的持久偏好,超出了这次只读接入的范围。 评审覆盖这个独立脚手架、开发服务和构建预览。带合成数据的页面、正式安装和远端接入按后续改动验收。

改动思路 / Approach

浏览器打开 Workbench,Vite 按路径前缀把 HTTP 请求发给本机的 status 或 Chat。Chat 继续持有状态和权限检查。 独立锁文件与构建入口有明确用途。当前页面没有调用这些服务,扩大 Chat 路由范围不提供工具链验收所需的功能。 保留可独立构建的空壳。把实际读取交给需要它的步骤,通过最小只读接口接入现有状态源。

独立验证

npm ci 与 npm run build 成功。Vite 5.4.21 构建 29 个模块。dev、preview 都返回应用 HTML 和合成 status JSON,Chat 读偏好返回初始空值。

具体改动 / Changes

8 文件,新增 1,916 行,其中锁文件 1,766 行。其余主要为最小入口和 47 行 Vite 配置。 以 docs/development/frontend-delivery.md 和不可变版本 48dbebbd14c5535b9631f4c7a1152d86aa64c5b2 为准。按已提交的前端交付说明检验只读权限和可验收的交付范围。设计 PR #8778 与合成页面 #8783 提供进度背景。 规范

  • Task-first delivery · implemented。我检查了独立构建的桌面首屏,确认该提交只有空白主区,没有导航、预览或交互。
  • 只读来源默认拒绝写入 · not_met。Vite 把整个 /api/chat 前缀交给可写 Chat 服务,代理不限制 HTTP 方法。开发服务和构建预览的同源 POST 都返回 200,随后 GET 和隔离运行目录都读回了刚保存的偏好。

关键代码讲解

  • chatProxy.configure。在本机请求的 Origin 与 Workbench 监听地址匹配时给 Chat 改写来源。 路由登记后方法保持不变。 Vite 把整个 /api/chat 前缀交给可写 Chat 服务,代理不限制 HTTP 方法。开发服务和构建预览的同源 POST 都返回 200,随后 GET 和隔离运行目录都读回了刚保存的偏好。 精确代码
  • preview。启动打包产物的本机预览。 未配置单独的 preview.proxy。 Vite 把整个 /api/chat 前缀交给可写 Chat 服务,代理不限制 HTTP 方法。开发服务和构建预览的同源 POST 都返回 200,随后 GET 和隔离运行目录都读回了刚保存的偏好。 精确代码
  • createRoot。挂载当前构建入口。 页面不含会话数据和动作。 可独立加载的空白页面。 精确代码

对主干的风险 / Risks

PASS · 锁文件只引用公开 npm registry。8 个路径都在 Workbench 目录,最终补丁空白检查、1 个签署提交和本地 main 合并模拟均通过。

FAIL · 以 Workbench 自己的来源向已启用的 Vite 服务发出一个普通 Chat 写请求。 Vite 把整个 /api/chat 前缀交给可写 Chat 服务,代理不限制 HTTP 方法。开发服务和构建预览的同源 POST 都返回 200,随后 GET 和隔离运行目录都读回了刚保存的偏好。 先移除脚手架的真实后端转发,在消费公开投影的提交用已接纳的读边界落地。

UNVERIFIED · 浏览器用了精确源码构建产物,HTTP 验证使用隔离生产处理器与合成 status。现部署、后续页面、远端服务与托管 CI 未验证。

语义与 CI 对齐

使用既有 HTTP 方法、Origin 与精确路径。只读声明应在 Workbench 代理拒绝未允许方法。 用隔离 Chat 运行目录分别启动 Vite dev 与 preview。相同请求直达不同来源的 Chat 和携带异站 Origin 经代理应拒绝。同源请求经过 Workbench 应返回 405 或 403,随后 GET 仍为初始值,隔离目录不新增写回。 托管 CI 未读取。

我的整体评价 / Verdict

请求修改。这个独立工具链可以继续交付,实际代理应等到投影调用需要时再加入,或在 dev 与 preview 上同时执行同一只读规则。 独立脚手架不进入运行时调度,也没有 Workbench Session 的执行或回传。

我检查了独立构建的桌面首屏,确认该提交只有空白主区,没有导航、预览或交互。 这个提交没有可检查的展开、响应式或 populated 状态。后续三栏界面和直接使用真实投影的旅程仍待评审。

English verdict: REQUEST_CHANGES at 5738dc7. Keep the Workbench proxy read-only in both development and preview, or introduce it with the first production read consumer.

proxy: {
'/status.json': statusProxy,
'/ssh-hosts': chatProxy,
'/api/chat': chatProxy,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 只读代理允许写入 Chat 偏好。 Vite 把整个 /api/chat 前缀交给可写 Chat 服务,代理不限制 HTTP 方法。开发服务和构建预览的同源 POST 都返回 200,随后 GET 和隔离运行目录都读回了刚保存的偏好。 把真实代理移到首个实际读取的提交,或在当前代理边界只放行需要的 GET 路由并拒绝其余方法,开发与预览用同一只读规则。

@maxliux5

Copy link
Copy Markdown
Collaborator Author

Thanks — confirmed and fixed in 6d9b8c0ab.

The dev/preview proxy forwarded every method on /api/chat to a writable service, so a same-origin POST could change chat preferences or Goal order.

Fix:

  • Explicit path allowlist and only GET/HEAD; vite dev and vite preview share the same rule.
  • Other methods on an allow-listed path return 405; paths outside the allowlist return 404.
  • Encoded traversal (.., encoded separators, double encoding, malformed escapes) is refused.
  • Unit tests cover the method/path matrix.

Evidence, identical on the dev port and the preview port:

POST   /api/chat/preferences                 -> 405 read-only workbench proxy
PUT    /api/chat/sessions/x                  -> 405 read-only workbench proxy
DELETE /status.json                          -> 405 read-only workbench proxy
GET    /api/chat/preferences                 -> 404 read-only workbench proxy
GET    /api/chat/sessions/%2e%2e/preferences -> 404 read-only workbench proxy
GET    /api/chat/capabilities                -> 200
GET    /status.json                          -> 200

All three branches in the stack were rebuilt so the same vite.config.ts and proxy-guard.ts ship in A/B/C.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 6d9b8c0,GitHub 当前列示的目标分支提交 eaff94c。

[P2] 对实际进入代理的每条请求落实只读清单。 两种模式都挡住了前次的普通写请求,但仍将匹配代理挂载前缀、且不在清单内的合成请求转发到了隔离上游。守卫与 Vite 对哪些请求会进入代理的判断不同,因而「后端只收到已列明读取」没有兑现。测试只记录上游是否收到请求。 把路由匹配和方法检查放到同一个转发边界:仅将逐条列明的 GET/HEAD 交给上游,会话详情只匹配单个 ID,其余代理候选一律本地拒绝。这个阶段还没有真实数据调用,也可以先移除代理,等连接器的契约一并落地。 位置。

动机 / Motivation

主干没有这个 Workbench 入口。前次评审复现:页面自己只发读取请求时,旧代理仍会转发普通的非读取请求。 单独启动 Workbench 的前端贡献者,以及让本地投影保持只读的 LoopX 使用者。 把 Workbench 单独构建和启动;Vite dev 和 preview 都只转发允许清单中的 GET/HEAD。 通过真实的 dev 与 preview 入口提交无效或不在清单内的路径,观察上游是否收到请求。 正常读取仍通过,原普通写全部被拦;两种模式仍有未列明请求进入上游。 本地精确源码的 Vite dev、已构建的 Vite preview;上游以独立回环测试服务替换,未触及运行中的 LoopX、真实账户或数据;未验证安装包与远端 CI。

改动思路 / Approach

启动 Workbench 的人显式运行 dev 或 preview,不进入 Dashboard 已有入口;当前启动就注册代理。 复用 Dashboard 已有的 readback 服务与 Chat 路由契约;将精确匹配交给实际转发边界,避免在两个地方声明不等价的前缀。 独立 Workbench 空壳或纯演示,真实读取连接器另行交付。

依据前端交付规则及设计规则,规范版本 eaff94c。#8778 仍是讨论中的设计提案。下列简称用于对应独立入口、只读范围和使用者反馈:

  • PACKAGE-ISOLATION:独立页面构建与启动应保留原有入口和后端所有权。 已复核。
  • PROXY-EXACT-SCOPE:按现有所有权提供有边界的读取入口,实际转发须匹配本 PR 声明的只读清单。 未通过。

具体改动 / Changes

新目录、独立包/锁、引导页、Vite 读入口和构建配置。

  • defineConfig / readOnlyProxyGuard:在独立包中注册 guard、状态和 Chat 代理。空包/演示启动即建立到本地服务的转发;不改变现有 Dashboard 配置。
  • proxyRejection:按方法和路径判断是否把请求交给 Vite。普通写由 pass-through 变为拒绝;两个匹配器的候选集合仍不同。
  • configureServer / configurePreviewServer:dev 与 preview 复用同一中间件。两种入口都发生相同的未列明转发,用同样的 HTTP 请求复现。

此前复审和作者修后说明。使用同一套合成请求重放上次评审的 Vite 配置和当前配置。用上一次评审的精确 Vite 配置重放同一组合成请求:正常 GET/HEAD 有上游读取,前次三类普通写也到达隔离上游。主干没有此入口。 当前结果:正常读取仍通过,原普通写全部被拦;两种模式仍有未列明请求进入上游。

对主干的风险 / Risks

  • PASS — 独立 TypeScript 检查、Vite 构建及差异格式检查。两种模式都保留正常 GET/HEAD,三类前次普通写请求现被本地以 405 拒绝,隔离上游未见这些请求。
  • FAIL — 在真实的 dev 与 production preview HTTP 入口,用隔离上游覆盖允许的 GET/HEAD、未列明的相近路径和非读取方法;失败必须被本地拒绝且上游收到零请求。 两种模式都挡住了前次的普通写请求,但仍将匹配代理挂载前缀、且不在清单内的合成请求转发到了隔离上游。守卫与 Vite 对哪些请求会进入代理的判断不同,因而「后端只收到已列明读取」没有兑现。测试只记录上游是否收到请求。
  • UNVERIFIED — 本地精确源码的 Vite dev、已构建的 Vite preview;上游以独立回环测试服务替换,未触及运行中的 LoopX、真实账户或数据;未验证安装包与远端 CI。

我的整体评价 / Verdict

REQUEST_CHANGES。把路由匹配和方法检查放到同一个转发边界:仅将逐条列明的 GET/HEAD 交给上游,会话详情只匹配单个 ID,其余代理候选一律本地拒绝。这个阶段还没有真实数据调用,也可以先移除代理,等连接器的契约一并落地。 检查了实际 dev/preview 根入口和空挂载点;只交付可运行脚手架,没有可评的产品界面内容。

English verdict: REQUEST_CHANGES at 6d9b8c0. Ordinary write requests from the previous review are now rejected. Both Vite modes still forward requests outside the declared read-only scope. Use one exact route and method boundary, or defer the proxy until its first real caller.

const unsafeMethod = !SAFE_METHODS.has((method ?? 'GET').toUpperCase());
// A path that climbs or hides a separator is refused when it sits under a proxied prefix.
if (path === null) return proxied(new URL(raw, 'http://local').pathname) ? (unsafeMethod ? 405 : 404) : null;
if (!proxied(path)) return null;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 对实际进入代理的每条请求落实只读清单。 两种模式都挡住了前次的普通写请求,但仍将匹配代理挂载前缀、且不在清单内的合成请求转发到了隔离上游。守卫与 Vite 对哪些请求会进入代理的判断不同,因而「后端只收到已列明读取」没有兑现。测试只记录上游是否收到请求。 把路由匹配和方法检查放到同一个转发边界:仅将逐条列明的 GET/HEAD 交给上游,会话详情只匹配单个 ID,其余代理候选一律本地拒绝。这个阶段还没有真实数据调用,也可以先移除代理,等连接器的契约一并落地。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: maxliux5 <lualiudd@gmail.com>
@maxliux5
maxliux5 force-pushed the codex/calli-workbench-scaffold branch from 6d9b8c0 to 1b582b5 Compare November 15, 2026 04:12
@maxliux5

Copy link
Copy Markdown
Collaborator Author

Agreed — the guard middleware and the Vite proxy made separate routing decisions, so a path outside the guard's list could still be forwarded. Fixed by collapsing them into one boundary (f3a2788bb):

  • A and B no longer configure any proxy. Neither layer makes a network call; the proxy now lands in C together with its first caller, as suggested.
  • C replaces server.proxy entirely with a single middleware (readonly-forward.ts) that enumerates the allowed routes and forwards them itself with node:http. Matching and forwarding are the same code. Unlisted paths get a local 404; an enumerated route with a method other than GET/HEAD gets a local 405. Session details match a single plain segment; ., .., encoded separators and multi-segment ids fail the match. Only Accept/Accept-Language are forwarded; Origin is dropped. A down upstream answers 502.
  • Tests run against two loopback fake upstreams that count requests and assert they receive zero requests for every rejected case (writes, unlisted paths, encoded traversal, multi-segment ids). Seven allowed routes each hit exactly their own upstream once.

Fake-upstream test results (npm test):

ok - each enumerated route is forwarded to its own upstream exactly once
ok - the query string travels, the fragment does not, HEAD is forwarded as HEAD
ok - a write to an enumerated route is a local 405 and the upstream sees nothing
ok - anything not enumerated is a local 404 and the upstream sees nothing
ok - paths outside the service namespace are left to the page server
ok - an upstream that is down gives 502, not a hang or a crash

Curl evidence, identical on the dev port and the preview port:

POST /api/chat/preferences -> 404    POST /api/chat/sessions -> 405
PUT  /api/chat/sessions/x  -> 405    DELETE /status.json     -> 405
GET  /api/chat/preferences -> 404    GET /api/chat/sessions/a/b -> 404
GET  /api/chat/sessions/%2e%2e/preferences -> 404
GET  capabilities | endpoints | goals/contexts | sessions | /status.json | /ssh-hosts -> 200

All three branches are rebuilt on the latest main so the same layering ships across A/B/C.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 1b582b5,目标分支提交 1965965。与当前主干 8ade78c 的合并树检查无冲突。

[P2] 升级开发服务使用的 Vite 版本。 代码位置

动机 / Motivation

主干没有 Calli Workbench 入口。前次复审找到开发和预览代理转发未列明路径,现在两个入口都移除了代理。 按 README 启动 Workbench 的贡献者及其本地项目文件。 提供独立的空壳构建和启动路径,保持生产投影与本地文件的访问边界。 复审记录

对精确提交的回环开发服务请求隔离项目外的合成 source map,并对照同一文件的正常文件路由。 已锁定的 Vite 5.4.21 在正常文件路由拒绝该文件,但经开发服务的优化依赖 source map 路径返回了合成内容。该版本在 Vite 公开公告的影响范围内。 只在隔离回环服务使用合成文件。Windows、局域网访问和已安装产品未验证。

改动思路 / Approach

独立构建和回环开发入口。状态转发、合成界面和真实投影由它们各自的交付阶段验收。

  • 已验证交付。干净安装与 TypeScript/Vite 构建通过。实际预览在 1200 和 390 像素均渲染同一个空 main,浏览器记录零业务 API 请求。 仓库规则
  • 约束范围。独立开发服务保护工作目录外的文件。 收敛合同 关联来源

具体改动 / Changes

新增独立包、锁文件、开发/预览和空 React 入口。全部改动位于 Workbench 目录,已核对仓库现有入口的引用边界。开发和预览共享回环监听配置。开发服务启动 Vite 的模块处理,预览读取 dist 中的成品。工作台和 Dashboard 各自解析依赖。

对主干的风险 / Risks

  • PASS。已运行 npm ci、npm run build 和回环 dev/preview 对照。Vite 6.4.4 试验副本也构建成功。 开发和预览均在回环监听。状态、Chat 的读取与写入和未列明路径均由本机服务返回 404。
  • FAIL。启动新脚手架会向本地 HTTP 客户端暴露能越过文件允许清单的开发服务。风险出现在显式启动 dev 的路径。
  • 实际检查生产预览的桌面和窄窗首屏,空 main 和标题符合脚手架交付范围。

我的整体评价 / Verdict

REQUEST_CHANGES。升级到已修复的 Vite 版本并更新锁文件,再重复独立构建、开发与预览验证。 隔离副本使用 Vite 6.4.4 构建,通过相同回环请求确认项目外合成内容不可读,并保留空壳首页与旧代理请求负例。

English verdict: REQUEST_CHANGES at 1b582b5. Both Vite modes now keep the scaffold independent of LoopX services. The locked Vite 5.4.21 dev server serves an out-of-root synthetic source map despite denying direct access. The isolated 6.4.4 control builds and refuses the same probe. Update the dependency and lockfile.

"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.6.0",
"vite": "^5.4.11"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 升级开发服务使用的 Vite 版本。 已锁定的 Vite 5.4.21 在正常文件路由拒绝该文件,但经开发服务的优化依赖 source map 路径返回了合成内容。该版本在 Vite 公开公告的影响范围内。 升级到已修复的 Vite 版本并更新锁文件,再重复独立构建、开发与预览验证。

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants