From cc3f2b576cc4585e82db00509964c70e587c3b44 Mon Sep 17 00:00:00 2001 From: Scott Wei Date: Fri, 8 May 2026 17:30:07 +0800 Subject: [PATCH] refactor(workflow): decouple agent context from CAS and fix monorepo checks Move CAS access into extract dependencies so AgentContext stays state-only, and clean up type/lint/check regressions across CLI/dashboard to keep full check green. Co-authored-by: Cursor --- biome.json | 2 +- .../src/commands/serve/routes-live.ts | 7 +-- packages/dashboard/src/api.ts | 8 ++- packages/dashboard/src/app.tsx | 14 +++-- .../dashboard/src/components/run-dialog.tsx | 27 ++++++++-- packages/dashboard/src/components/sidebar.tsx | 10 +++- .../dashboard/src/components/status-bar.tsx | 1 + .../src/components/thread-detail.tsx | 13 +++-- .../dashboard/src/components/thread-list.tsx | 4 +- .../src/components/workflow-list.tsx | 8 ++- packages/dashboard/src/hooks.ts | 1 + packages/dashboard/vite.config.ts | 1 + .../__tests__/create-llm-adapter.test.ts | 10 +--- .../src/engine/create-workflow.ts | 1 - packages/workflow-runtime/src/index.ts | 2 +- packages/workflow-runtime/src/types.ts | 1 - .../__tests__/solve-issue-template.test.ts | 53 +++++++++---------- .../__tests__/build-agent-prompt.test.ts | 53 +++++-------------- .../src/build-agent-prompt.ts | 17 +----- .../__tests__/workflow-as-agent.test.ts | 1 - packages/workflow/src/engine/engine.ts | 11 ++-- packages/workflow/src/extract/extract-fn.ts | 15 ++++-- tsconfig.json | 1 + 23 files changed, 131 insertions(+), 130 deletions(-) diff --git a/biome.json b/biome.json index 61030ca..34776b4 100644 --- a/biome.json +++ b/biome.json @@ -1,7 +1,7 @@ { "$schema": "https://biomejs.dev/schemas/2.4.14/schema.json", "files": { - "includes": ["**", "!**/dist", "!**/node_modules"] + "includes": ["**", "!**/dist", "!**/node_modules", "!packages/workflow/workflow"] }, "assist": { "actions": { "source": { "organizeImports": "on" } } }, "formatter": { diff --git a/packages/cli-workflow/src/commands/serve/routes-live.ts b/packages/cli-workflow/src/commands/serve/routes-live.ts index 8301ea3..c28dd1c 100644 --- a/packages/cli-workflow/src/commands/serve/routes-live.ts +++ b/packages/cli-workflow/src/commands/serve/routes-live.ts @@ -60,8 +60,9 @@ export function createLiveRoutes(storageRoot: string): Hono { if (dataPath === null) { return c.json({ error: `thread not found: ${threadId}` }, 404); } + const resolvedDataPath = dataPath; - const infoPath = join(dirname(dataPath), `${threadId}.info.jsonl`); + const infoPath = join(dirname(resolvedDataPath), `${threadId}.info.jsonl`); return streamSSE(c, async (stream) => { const dataState: PumpState = { contentOffset: 0, carry: "" }; @@ -71,7 +72,7 @@ export function createLiveRoutes(storageRoot: string): Hono { async function pumpData(): Promise { let text: string; try { - text = await readFile(dataPath, "utf8"); + text = await readFile(resolvedDataPath, "utf8"); } catch { return false; } @@ -131,7 +132,7 @@ export function createLiveRoutes(storageRoot: string): Hono { const controller = new AbortController(); let completed = false; - const dataWatcher = watch(dataPath, async () => { + const dataWatcher = watch(resolvedDataPath, async () => { if (completed) return; const finished = await pumpData(); if (finished) { diff --git a/packages/dashboard/src/api.ts b/packages/dashboard/src/api.ts index 6bf0410..4afe307 100644 --- a/packages/dashboard/src/api.ts +++ b/packages/dashboard/src/api.ts @@ -7,7 +7,7 @@ async function postJson(path: string, body: unknown): Promise { body: JSON.stringify(body), }); if (!res.ok) { - const err = await res.json().catch(() => ({ error: res.statusText })) as { error: string }; + const err = (await res.json().catch(() => ({ error: res.statusText }))) as { error: string }; throw new Error(err.error || `API ${res.status}`); } return res.json() as Promise; @@ -59,7 +59,11 @@ export function getThread(id: string): Promise<{ records: ThreadRecord[] }> { return fetchJson(`/threads/${id}`); } -export function runThread(workflow: string, prompt: string, maxRounds: number = 10): Promise<{ threadId: string }> { +export function runThread( + workflow: string, + prompt: string, + maxRounds: number = 10, +): Promise<{ threadId: string }> { return postJson("/threads", { workflow, prompt, maxRounds }); } diff --git a/packages/dashboard/src/app.tsx b/packages/dashboard/src/app.tsx index 6cf9b9d..0d65b8c 100644 --- a/packages/dashboard/src/app.tsx +++ b/packages/dashboard/src/app.tsx @@ -1,10 +1,10 @@ import { useState } from "react"; -import { Sidebar } from "./components/sidebar.tsx"; -import { ThreadList } from "./components/thread-list.tsx"; -import { ThreadDetail } from "./components/thread-detail.tsx"; -import { WorkflowList } from "./components/workflow-list.tsx"; -import { StatusBar } from "./components/status-bar.tsx"; import { RunDialog } from "./components/run-dialog.tsx"; +import { Sidebar } from "./components/sidebar.tsx"; +import { StatusBar } from "./components/status-bar.tsx"; +import { ThreadDetail } from "./components/thread-detail.tsx"; +import { ThreadList } from "./components/thread-list.tsx"; +import { WorkflowList } from "./components/workflow-list.tsx"; type View = "threads" | "workflows"; @@ -19,9 +19,7 @@ export function App() {
setShowRun(true)} />
- {view === "threads" && !selectedThread && ( - - )} + {view === "threads" && !selectedThread && } {view === "threads" && selectedThread && ( setSelectedThread(null)} /> )} diff --git a/packages/dashboard/src/components/run-dialog.tsx b/packages/dashboard/src/components/run-dialog.tsx index d4362c3..84a79d5 100644 --- a/packages/dashboard/src/components/run-dialog.tsx +++ b/packages/dashboard/src/components/run-dialog.tsx @@ -41,10 +41,15 @@ export function RunDialog({ onClose, onCreated }: Props) {

Run Thread

-
-