| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619 |
- import { NativeSideNoteFixture } from "./sidenote-native-fixture"
- import { createStore } from "solid-js/store"
- import { Show } from "solid-js"
- 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 { PaasProjectBackup, PaasPlatform, PaasRequest, PaasProgress, PaasUploadProgress } from "../../src/paas"
- import { PanelFixture } from "./panel-fixture"
- import "../../src/index.css"
- // Synthetic transport, real workbench. No model or developer service is started.
- document.body.setAttribute("data-lambda-workbench", "")
- const calls: PaasRequest[] = []
- const query = new URLSearchParams(location.search)
- const filesMode = query.has("files")
- const completedMode = query.has("completed")
- const agent = { id: "research", name: "科研助手", description: "研究规划与验证", current_version: 1 }
- const unusedAgent = { id: "unused", name: "未使用智能体", description: "从未开始过会话", current_version: 1 }
- const workspaceAgent = { id: "workspace", name: "工作区助手", description: "文件与命令", current_version: 1 }
- const groupedAgents = [
- agent,
- { id: "data67", name: "data67", description: "数据分析", current_version: 1 },
- workspaceAgent,
- { id: "reviewer", name: "顶刊审稿助手", description: "论文评审", current_version: 1 },
- { id: "pipeline", name: "Research67 三阶段研究草稿流水线", description: "完整研究流程", current_version: 1 },
- { id: "internal-evidence", name: "本体证据补全员", description: "补充证据", current_version: 1 },
- ]
- const agents = query.has("groups")
- ? [agent, unusedAgent]
- : query.has("agent-groups")
- ? groupedAgents
- : query.has("workspace")
- ? [agent, workspaceAgent]
- : [agent]
- const run: Record<string, unknown> = {
- run_id: "run_1",
- agent_id: agent.id,
- thread_id: "thread_1",
- created_at: "2026-11-29T09:00:00Z",
- status: completedMode ? "completed" : "waiting_human",
- ...(completedMode ? { completed_at: "2026-11-29T09:00:30Z" } : {}),
- output: [
- "## 研究计划",
- "已整理材料并生成以下步骤:",
- "",
- "1. 明确验证假设与指标",
- "2. 复核数据来源与样本量",
- "",
- "> 执行完成不代表科研结论已验证。",
- "",
- "| 阶段 | 产出 |",
- "| --- | --- |",
- "| 探索 | 证据清单 |",
- "| 验证 | 对照实验 |",
- "",
- "```python",
- 'print("研究计划")',
- "```",
- "",
- "[查看平台任务](https://research.example/tasks/run_1)",
- ].join("\n"),
- pending_approval: { approval_id: "approval_1", prompt: "是否执行验证?" },
- artifacts: filesMode
- ? [
- { artifact_id: "artifact_1", name: "研究计划成果.pdf" },
- { artifact_id: "artifact_2", name: "manifest.json" },
- { artifact_id: "artifact_3", name: "manifest.json" },
- ]
- : [{ artifact_id: "artifact_1", name: "研究计划成果.pdf" }],
- events: [
- { type: "tool_call", tool: "file_search", content: "查找材料目录" },
- { type: "tool_result", tool: "file_search", content: "找到 2 份材料" },
- ],
- }
- if (query.has("sidenotes")) {
- run.output = [
- "## 搜索更新", "", "已将 `search.ts` 改为子序列匹配,并加入快捷键。", "",
- "无需迁移数据。仅完成单元测试,界面交互尚未验证。", "", "```sidenotes",
- "- 做法 | search.ts | 使用子序列匹配处理非连续字符。",
- "- 假设 | 快捷键 | 默认使用系统常见的组合键。",
- "- 依据 | 无需迁移数据 | 只改动匹配函数,未修改存储结构。",
- "- 存疑 | 界面交互尚未验证 | 尚未运行浏览器端到端测试。",
- "- 取舍 | 子序列匹配 | 优先选择易维护的实现,未引入编辑距离。",
- ...(query.has("malformed-notes") ? ["unknown | 正文 | 保留这段未知格式"] : []),
- "```",
- ].join("\n")
- }
- if (query.has("recovery")) {
- run.status = "failed"
- run.error = { code: "SERVICE_RESTARTED", message: "服务中断" }
- run.recovery_available = true
- run.pending_approval = null
- }
- const progress = new Set<(event: PaasProgress) => void>()
- const uploads = new Set<(event: PaasUploadProgress) => void>()
- const uxRuns = new Map<string, Record<string, unknown>>()
- const ux = {
- enabled: new URLSearchParams(location.search).has("ux"),
- uploads: 0,
- holdRun: "",
- holdThread: "",
- threadError: "",
- held: false,
- connectError: "",
- catalogError: "",
- emptyCatalog: false,
- configVersion: "version-1",
- configError: false,
- draftError: false,
- permissions: undefined as string[] | undefined,
- verifyError: "",
- receiptError: "",
- previewError: "",
- previewText: "",
- filesError: "",
- previewName: "",
- directoryError: "",
- directories: [] as string[],
- scopeError: false,
- holdDirectory: false,
- releaseDirectory: () => {},
- checks: [{ kind: "model", name: "test-model", required: true, status: "not_checked" }] as Record<string, unknown>[],
- external: [] as string[],
- release: () => {},
- add: (value: Record<string, unknown>) => uxRuns.set(String(value.run_id), value),
- update: (id: string, value: Record<string, unknown>) => Object.assign(uxRuns.get(id) || {}, value),
- progress: (event: PaasProgress) => progress.forEach((listener) => listener(event)),
- run: (id: string) => uxRuns.get(id),
- }
- Object.assign(window, { paasUX: ux })
- let researchConfig = {
- researchWorkflow: "research67-scientific-v1",
- model: { provider: "deepseek", name: "deepseek-chat" },
- scientific: { token_budget: 500000, max_actual_tokens: 1000000, max_rounds: 4, max_wall_seconds: 3600 },
- }
- const plugin = {
- managerProjects: {} as Record<string, unknown>,
- localTools: [] as Record<string, unknown>[],
- packageVersion: "1.0.0",
- blocked: false,
- inspectError: false,
- failRefreshAfterSave: false,
- failPackRefresh: false,
- failManagerRefresh: false,
- failAfterLocalSave: false,
- inspectTools: [{name:"echo",description:"本地回显"}] as Record<string,unknown>[],
- packsError: false,
- version: 1,
- config: {
- type: "react",
- mcp: { localTools: ["read_file"], onlineTool: { original: ["existing"] } },
- app: { mcp: { custom: { nodes: { original: { url: "https://original.example/mcp" } } } } },
- } as Record<string, unknown>,
- added: [] as Record<string, unknown>[],
- packs: [
- {
- id: "literature",
- version: "1.0.0",
- name: "文献助手",
- description: "检索材料,整理有出处的阅读报告。",
- permission_summary: "读取选定材料、检索文献",
- dependencies: [{ kind:"mcp",name: "模型连接", required: true }],
- },
- ],
- }
- Object.assign(window, { paasPlugins: plugin })
- const artifactUX = { failFiles: false, holdFiles: false, held: false, release: () => {} }
- Object.assign(window, { artifactUX })
- const setupUX = { started: false, fail: "", saved: false }
- const transferUX = { backup: undefined as PaasProjectBackup | undefined, runs: [] as { agentID: string; runID: string }[] }
- Object.assign(window, { transferUX })
- const api: PaasPlatform = {
- ...(query.has("transfer") ? {
- backupProject: async (data: PaasProjectBackup, runs: { agentID: string; runID: string }[]) => { transferUX.backup = data; transferUX.runs = runs; return { path: "/backup/project.zip", missing: [] } },
- restoreProject: async () => ({ data: transferUX.backup || { format: "lambda-agent-project" as const, version: 1 as const, name: "备份项目", chats: [{ title: "历史研究", agentID: "research", name: "科研助手", draft: "下一步", messages: [{ role: "assistant" as const, text: "备份中的成果" }] }] }, path: "/backup/restored", missing: [] }),
- } : {}),
- ...(query.has("setup")
- ? {
- localRuntime: {
- status: async () => ({
- phase: setupUX.started ? ("ready" as const) : ("idle" as const),
- available: true,
- message: setupUX.started ? "本机服务已就绪。" : "尚未启动本机服务。",
- }),
- start: async () => {
- setupUX.started = true
- },
- choose: async () => true,
- },
- }
- : {}),
- readDraft: async (kind, id, scope) => {
- if (ux.draftError) throw new Error("草稿暂不可读")
- return JSON.parse(localStorage.getItem(`test-draft:${scope}:${kind}:${id}`) || "null")
- },
- writeDraft: async (kind, id, value, scope) => {
- const key = `test-draft:${scope}:${kind}:${id}`
- if (value == null) localStorage.removeItem(key)
- else localStorage.setItem(key, JSON.stringify(value))
- },
- connect: async (input) => {
- if (!input && setupUX.started) input = { url: "http://127.0.0.1:8400", apiKey: "setup" }
- if (!input) throw new Error("未找到本机 AgentPaaS 凭证,请手动连接。")
- if (ux.connectError) throw new Error(ux.connectError)
- return { url: input.url, remembered: true, scope: `test-${input.apiKey}`, permissions: ux.permissions }
- },
- disconnect: async () => {},
- onProgress: (listener) => {
- progress.add(listener)
- return () => progress.delete(listener)
- },
- onUploadProgress: (listener) => {
- uploads.add(listener)
- return () => uploads.delete(listener)
- },
- ...(ux.enabled
- ? {
- selectFiles: async () => [
- { selectionID: "one", name: "成功.txt", size: 10 },
- { selectionID: "two", name: "重试.txt", size: 10 },
- ],
- }
- : {}),
- chooseFiles: async () => [{ file_id: "file_1", name: "材料.pdf" }],
- request: async (request) => {
- calls.push(request)
- if (request.action === "delete-agent") return {ok:true}
- if (request.action === "attach-artifact") return { file_id: "continued-file", name: request.name }
- if (request.action === "recover") {
- if (!request.retryInterrupted) throw new Error("PIPELINE_RETRY_REQUIRES_ACK:请核对中断步骤")
- run.status = "running"
- run.recovery_available = false
- run.pending_approval = null
- return { ...run }
- }
- if (request.action === "desktop-self-check") return { checked_at: "2026-12-02T08:00:00Z", sha256: "fixture-digest", checks: [{ name: "执行服务认证", status: "passed" }, { name: "独立目录写入、列举与读取", status: "passed" }, { name: "真实模型与科研质量", status: "not_checked" }] }
- if (request.action === "desktop-setup")
- return {
- version: 1,
- executor_linked: true,
- providers: [
- ...(query.has("fresh-models") ? [
- {id: "anthropic", name: "Anthropic", models: [], base_url: "https://api.anthropic.com", configured: false, credential_source: "none"},
- {id: "ollama", name: "Ollama", models: [], base_url: "http://127.0.0.1:11434", configured: false, no_key_required: true},
- ] : []),
- {
- id: "deepseek",
- name: "DeepSeek",
- models: ["deepseek-chat"],
- base_url: "https://api.deepseek.com/v1",
- configured: setupUX.saved,
- },
- ],
- }
- if (request.action === "save-provider") {
- setupUX.saved = true
- return { ok: true }
- }
- if (request.action === "apply-model") {
- if (request.agentID === "unused") throw new Error("配置版本已变更,请重试")
- return { ok: true }
- }
- if (request.action === "save-tool-credential") return { name: "DESKTOP_TOOL_" + "A".repeat(64) }
- if (request.action === "download-batch")
- return { saved: request.files.length, results: request.files.map((file) => ({ name: file.name, saved: true })) }
- if (request.action === "run-files") {
- if (artifactUX.failFiles) throw new Error("测试:文件列表暂不可用")
- if (artifactUX.holdFiles) {
- artifactUX.held = true
- await new Promise<void>((resolve) => {
- artifactUX.release = () => {
- artifactUX.held = false
- resolve()
- }
- })
- }
- }
- if (request.action === "verify") {
- if (ux.verifyError) throw new Error(ux.verifyError)
- return { checks: ux.checks }
- }
- if (request.action === "agents" && ux.catalogError) throw new Error(ux.catalogError)
- if (request.action === "agents" && ux.emptyCatalog) return { agents: [] }
- if (query.has("plugins")) {
- if(request.action === "plugin-resources") return {knowledge:[{id:"kb-demo",name:"演示知识库"}],skill:[],mcp:[{id:"original",name:"已有连接"}]}
- if(request.action === "plugin-detail" && plugin.failManagerRefresh) throw new Error("详情暂不可用")
- if(request.action === "plugin-detail") return {agent_id:request.agentID,updated_at:String(plugin.version),pack:{id:"literature",version:plugin.packageVersion},latest_version:"2.0.0",installed_versions:[{version:"1.0.0"},{version:"2.0.0"}],versions:[{version:plugin.version,is_current:true,changelog:"当前配置"},{version:0,is_current:false,changelog:"初始配置"}],projects:plugin.managerProjects,connections:["original","literature"],local_tools:plugin.localTools,resources:[{kind:"知识库",name:"演示知识库"}],desktop_ui:{panels:[{id:"help",title:"使用说明",text:"所有结果在当前工作台交付。"}],commands:[{id:"review",title:"审阅材料",prompt:"请审阅 {{topic}}",fields:[{id:"topic",label:"研究主题",required:true}]}]}}
- if(request.action === "plugin-project") {if(request.expectedUpdatedAt!==String(plugin.version))throw new Error("版本已变化,请刷新。"); if(request.inherit)delete plugin.managerProjects[request.projectID];else plugin.managerProjects[request.projectID]={enabled:request.enabled,connections:request.connections};plugin.version++;return {ok:true}}
- if(request.action === "plugin-version") {plugin.packageVersion=request.version || "1.0.0";plugin.version++;return {ok:true}}
- if(request.action === "plugin-export") return request.preview === false ? {saved:true,name:"demo.zip"} : {files:[{name:"manifest.yml",size:300},{name:"agent.yml",size:500}],removed:["model.apiKey"]}
- if(request.action === "local-tool") {
- if(plugin.inspectError)throw new Error("本地工具未正常响应")
- if(request.save){
- const id=request.connectionID || `desktop_local${plugin.localTools.length}`
- plugin.localTools=[...plugin.localTools.filter((t)=>t.id!==id),{id,name:request.name,command_argv:request.commandArgv,enabled:request.enabled,tools:request.tools}]
- plugin.version++
- if(plugin.failAfterLocalSave)plugin.failManagerRefresh=true
- }
- return {tools:plugin.inspectTools,message:"启动检测通过,检测进程已关闭。"}
- }
- if(request.action === "plugin-local-state") {plugin.localTools=request.remove?[]:plugin.localTools.map((t)=>({...t,enabled:request.enabled}));plugin.version++;return {ok:true}}
- if (request.action === "agents") return { agents: [...agents, ...plugin.added] }
- if (request.action === "packs") {
- if (plugin.packsError) throw new Error("目录暂不可用")
- return { agentpacks: plugin.packs }
- }
- if (request.action === "preflight-pack")
- return { ready: !plugin.blocked, missing: plugin.blocked ? [{ name: "模型连接", reason: "尚未配置" }] : [] }
- if (request.action === "create-agent") {
- const id = `added_${plugin.added.length + 1}`
- plugin.added.push({
- id,
- name: request.name,
- description: "文献阅读与报告",
- agent_template: request.packID,
- current_version: 1,
- })
- return { agent_id: id }
- }
- if (request.action === "install-pack") {
- if (plugin.failPackRefresh) plugin.packsError = true
- return { installed: { id: "literature", version: "1.0.0" } }
- }
- if (request.action === "remove-pack") {
- plugin.packs = []
- if (plugin.failPackRefresh) plugin.packsError = true
- return { deleted: true }
- }
- if (request.action === "inspect-tool")
- return plugin.inspectError
- ? { status: "unreachable", message: "未能读取工具清单,请检查地址后重试。" }
- : {
- status: "ok",
- tools: [
- { name: "papers", description: "按关键词查找文献" },
- { name: "metadata", description: "读取文献元数据" },
- ],
- }
- if (request.action === "agent") {
- if (ux.configError) throw new Error("配置服务暂时不可用")
- return {
- ...agent,
- id: request.agentID,
- config: structuredClone(plugin.config),
- updated_at: String(plugin.version),
- }
- }
- if (request.action === "update-agent") {
- if (request.update.expected_updated_at !== String(plugin.version))
- throw new Error("配置版本已更新,请重新读取。")
- plugin.config = structuredClone(request.update.config || {})
- plugin.version++
- if (plugin.failRefreshAfterSave) ux.configError = true
- return { saved: true }
- }
- }
- if (request.action === "task-scope") {
- if (ux.scopeError) throw new Error("scope unavailable")
- return { agent_id: request.agentID, version: "1", local_tools: ["ReadFile", "WriteFile", "Bash"], external_tools: [{ connection: "literature", name: "Search" }], shell_access: true, shared_across_projects: true }
- }
- if (ux.enabled) {
- if (request.action === "agent" && ux.configError) throw new Error("配置服务暂时不可用")
- if (request.action === "agent")
- return {
- ...agent,
- config: structuredClone(researchConfig),
- updated_at: ux.configVersion,
- can_update_metadata: true,
- }
- if (request.action === "update-agent") {
- if (request.update.expected_updated_at !== ux.configVersion) throw new Error("配置版本已更新,请重新读取。")
- researchConfig = request.update.config as typeof researchConfig
- return { saved: true }
- }
- if (request.action === "knowledge") return { items: [] }
- if (request.action === "upload-selected" || request.action === "upload-file") {
- ux.uploads++
- uploads.forEach((listener) => listener({ uploadID: request.uploadID!, sent: 10, total: 10 }))
- if (request.action === "upload-selected" && request.selectionID === "two" && ux.uploads === 2)
- throw new Error("上传暂时失败")
- return {
- file_id: `file_${ux.uploads}`,
- name:
- request.action === "upload-file" ? request.name : request.selectionID === "one" ? "成功.txt" : "重试.txt",
- }
- }
- if (request.action === "file-capabilities") return { direct_upload_max_bytes: 100000 }
- if (request.action === "threads") return { threads: [] }
- if (request.action === "thread-runs") {
- if (ux.threadError) throw new Error(ux.threadError)
- const value = structuredClone({
- thread_id: request.threadID,
- runs: [...uxRuns.values()].filter((row) => row.thread_id === request.threadID),
- })
- if (ux.holdThread === request.threadID) {
- ux.holdThread = ""
- ux.held = true
- await new Promise<void>((resolve) => {
- ux.release = () => {
- ux.held = false
- resolve()
- }
- })
- }
- return value
- }
- if (request.action === "lookup-request") {
- if (ux.receiptError) throw new Error(ux.receiptError)
- const run = [...uxRuns.values()].find((row) => row.request_key === request.requestID)
- return run ? { found: true, run: { ...run } } : { found: false, state: "not_observed", retry_safe: false }
- }
- if (request.action === "execute") {
- if (request.input === "模拟网络中断") throw new Error("连接中断,提交结果未知")
- const id = `ux_${uxRuns.size + 1}`
- const value = {
- run_id: id,
- thread_id: request.threadID || `thread_${id}`,
- agent_id: request.agentID,
- status: "running",
- input: request.input,
- output: "",
- created_at: new Date().toISOString(),
- request_key: request.requestID,
- }
- uxRuns.set(id, value)
- if (request.input === "回执丢失但任务已创建") throw new Error("连接中断,回执未收到")
- progress.forEach((listener) =>
- listener({ executionID: request.executionID!, type: "started", runID: id, threadID: value.thread_id }),
- )
- return { ...value }
- }
- if (request.action === "history") {
- const all = [...uxRuns.values()].reverse(),
- offset = request.offset || 0
- const recent = all.slice(offset, offset + 20)
- const active = request.includeActive
- ? all.filter(
- (row) =>
- !["completed", "failed", "partial", "cancelled", "needs_clarification"].includes(String(row.status)),
- )
- : []
- return {
- runs: [...new Map([...recent, ...active].map((row) => [row.run_id, { ...row }])).values()],
- pagination_supported: true,
- active_included: !!request.includeActive,
- next_offset: offset + 20 < all.length ? offset + 20 : null,
- }
- }
- if (request.action === "run") {
- const value = structuredClone(uxRuns.get(request.runID))
- if (ux.holdRun === request.runID) {
- ux.holdRun = ""
- ux.held = true
- await new Promise<void>((resolve) => {
- ux.release = () => {
- ux.held = false
- resolve()
- }
- })
- }
- return value || {}
- }
- }
- if (request.action === "verify")
- return { checks: [{ kind: "model", name: "科研模型", status: request.checkModel ? "passed" : "not_checked" }] }
- if (request.action === "agents") return { agents }
- if (request.action === "run-options") throw new Error("HTTP 404")
- if (request.action === "threads")
- return {
- threads: request.agentID === unusedAgent.id ? [] : [{ id: "thread_1", title: "已有研究" }],
- }
- if (request.action === "thread-runs") return { thread_id: "thread_1", runs: [{ ...run, input: "分析材料" }] }
- if (request.action === "execute" && request.input === "持续研究") {
- run.status = "running"
- run.pending_approval = null
- }
- 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 === "execute" || request.action === "run") return { ...run }
- if (request.action === "pause") {
- run.status = "paused"
- run.checkpoint_id = "checkpoint_1"
- return { ...run }
- }
- if (request.action === "resume") {
- run.status = "running"
- return { ...run }
- }
- if (request.action === "cancel") {
- run.status = "cancelled"
- return { ...run }
- }
- if (request.action === "confirm") {
- run.status = "completed"
- run.pending_approval = null
- run.output = "研究计划已完成"
- return { ...run }
- }
- if (request.action === "run-files" && ux.filesError) throw new Error(ux.filesError)
- if (request.action === "run-files")
- return {
- files: [
- { name: "研究计划.pdf", path: "final/研究计划.pdf" },
- { name: ux.previewName || "研究计划.md", path: "final/研究计划.md" },
- ...(filesMode
- ? [
- { name: "config.yml", path: "work/config.yml" },
- { name: "sample-input.csv", path: "input/sample-input.csv", purpose: "input", downloadable: true },
- { name: "trace.json", path: "work/trace.json" },
- { name: "analysis.py", path: "work/analysis.py" },
- ]
- : []),
- ],
- }
- if (request.action === "preview-file") {
- if (ux.previewError) throw new Error(ux.previewError)
- if (/\.md$/i.test(request.name))
- return {
- name: request.name,
- mime: "text/markdown",
- size: 46,
- text: ux.previewText || "## 可预览的研究计划\n\n这是 Agent 生成并保存在工作区的 Markdown 文档。",
- }
- return { name: request.name, mime: "application/pdf", size: 4, data: new Uint8Array([37, 80, 68, 70]) }
- }
- if (request.action === "export-report")
- return {
- saved: true,
- name: `研究报告.${request.format || "md"}`,
- path: `/tmp/研究报告.${request.format || "md"}`,
- }
- if (request.action === "download") return { saved: true, name: "研究计划.pdf", path: "/tmp/研究计划.pdf" }
- if (request.action === "history") return { runs: [{ ...run, input: "分析材料" }] }
- return {}
- },
- }
- Object.assign(window, { paasTestCalls: calls })
- const platform: Platform = {
- revealPath: async () => true,
- platform: "desktop",
- os: new URLSearchParams(location.search).get("os") === "windows" ? "windows" : "macos",
- openDirectoryPickerDialog: async () => {
- if (ux.directoryError) throw new Error(ux.directoryError)
- if (ux.directories.length) return ux.directories.shift()
- if (ux.holdDirectory)
- await new Promise<void>((resolve) => {
- ux.releaseDirectory = resolve
- })
- return "D:/Research/optics"
- },
- paas: api,
- openExternal: (url) => {
- ux.external.push(url)
- },
- restart: async () => {},
- notify: async () => {},
- }
- const [code, setCode] = createStore({ active: false, mounted: false, directory: "" })
- const managed = new URLSearchParams(location.search).has("managed")
- render(
- () => (
- <PlatformProvider value={platform}>
- <AppBaseProviders locale="zh">
- {query.has("native-sidenote") ? <NativeSideNoteFixture /> : new URLSearchParams(location.search).has("panel") ? (
- <PanelFixture />
- ) : (
- <PaasWorkspace
- standalone
- developerActive={code.active}
- onCloseDeveloper={() => setCode("active", false)}
- onOpenDeveloper={
- query.has("unified")
- ? (directory) => setCode({ active: true, mounted: true, directory: directory || "" })
- : undefined
- }
- developerContent={
- <Show when={code.mounted}>
- <section aria-label="代码测试区">
- <span>{code.directory}</span>
- <input aria-label="代码草稿" />
- </section>
- </Show>
- }
- deployment={
- managed
- ? {
- edition: "team",
- platformUrl: "https://team.example",
- allowCustomPlatform: false,
- modelPolicy: "managed",
- permissionsDefault: "allow",
- }
- : undefined
- }
- />
- )}
- </AppBaseProviders>
- </PlatformProvider>
- ),
- document.getElementById("root")!,
- )
|