|
|
@@ -2,12 +2,13 @@ import { render } from "solid-js/web"
|
|
|
import { AppBaseProviders } from "../../src/app"
|
|
|
import { PlatformProvider, type Platform } from "../../src/context/platform"
|
|
|
import PaasWorkspace from "../../src/pages/paas"
|
|
|
-import type { PaasPlatform, PaasRequest } from "../../src/paas"
|
|
|
+import type { PaasPlatform, PaasProgress, PaasRequest } from "../../src/paas"
|
|
|
import { PanelFixture } from "./panel-fixture"
|
|
|
import "../../src/index.css"
|
|
|
|
|
|
// Synthetic transport, real workbench. No model or developer service is started.
|
|
|
const calls: PaasRequest[] = []
|
|
|
+const progress: Array<(event: PaasProgress) => void> = []
|
|
|
const agent = { id: "research", name: "科研助手", description: "研究规划与验证", current_version: 1 }
|
|
|
const run: Record<string, unknown> = {
|
|
|
run_id: "run_1",
|
|
|
@@ -43,8 +44,30 @@ const api: PaasPlatform = {
|
|
|
},
|
|
|
disconnect: async () => {},
|
|
|
chooseFiles: async () => [{ file_id: "file_1", name: "材料.pdf" }],
|
|
|
+ onProgress: (listener) => {
|
|
|
+ progress.push(listener)
|
|
|
+ return () => progress.splice(progress.indexOf(listener), 1)
|
|
|
+ },
|
|
|
request: async (request) => {
|
|
|
calls.push(request)
|
|
|
+ if (request.action === "execute") {
|
|
|
+ progress.forEach((listener) =>
|
|
|
+ listener({
|
|
|
+ executionID: request.executionID ?? "",
|
|
|
+ type: "tool_call",
|
|
|
+ tool: "file_search",
|
|
|
+ content: "查找材料目录",
|
|
|
+ }),
|
|
|
+ )
|
|
|
+ progress.forEach((listener) =>
|
|
|
+ listener({
|
|
|
+ executionID: request.executionID ?? "",
|
|
|
+ type: "tool_result",
|
|
|
+ tool: "file_search",
|
|
|
+ content: "找到 2 份材料",
|
|
|
+ }),
|
|
|
+ )
|
|
|
+ }
|
|
|
if (request.action === "agents") return { agents: [agent] }
|
|
|
if (request.action === "run-options") throw new Error("HTTP 404")
|
|
|
if (request.action === "threads") return { threads: [{ id: "thread_1", title: "已有研究" }] }
|