import assert from "node:assert/strict"; import fs from "node:fs"; import path from "node:path"; const root = path.resolve(import.meta.dirname, ".."); const read = (...parts) => fs.readFileSync(path.join(root, ...parts), "utf8"); const packageJson = JSON.parse(read("package.json")); const streamHook = read("client", "src", "sections", "superAgent", "hooks", "useSuperAgentStream.js"); const container = read("client", "src", "sections", "superAgent", "container", "index.jsx"); const conversation = read("client", "src", "sections", "superAgent", "components", "SuperAgentConversation.jsx"); const runLog = read("client", "src", "sections", "superAgent", "components", "AgentRunLog.jsx"); const generatedInterrupt = read("client", "src", "sections", "superAgent", "components", "GeneratedUiInterrupt.jsx"); const checkpointUtils = read("client", "src", "sections", "superAgent", "utils", "checkpoint.js"); const workspaceHost = read("client", "src", "sections", "superAgent", "components", "workspace", "WorkspaceHost.jsx"); const listWorkspace = read("client", "src", "sections", "superAgent", "components", "workspace", "ListWorkspace.jsx"); const jsonRender = read("client", "src", "sections", "superAgent", "components", "JsonRenderMessage.jsx"); const apiRoutes = read("..", "api", "app", "routes", "superAgent.js"); assert.equal(packageJson.dependencies["@langchain/react"], "1.0.29"); assert.match(streamHook, /useStream\(\{/); assert.match(streamHook, /buildSuperAgentServiceUrl/); assert.match(streamHook, /apiUrl:\s*getSuperAgentApiUrl\(\)/); assert.ok(streamHook.includes("/api/v1")); assert.match(streamHook, /Authorization:\s*`Bearer \$\{token\}`/); assert.doesNotMatch(streamHook, /onCustomEvent/); assert.match(streamHook, /ROOT_PUMP_CHANNELS/); assert.match(streamHook, /"custom"/); assert.match(streamHook, /attachment_ids:/); assert.match(streamHook, /const stopRun =/); assert.match(streamHook, /disconnect:\s*stream\.disconnect/); assert.match(streamHook, /eventRequestControllersRef/); assert.match(streamHook, /isLifecycleWatcherRequest/); assert.match(streamHook, /status: 204/); assert.match(streamHook, /currentThread\.close/); assert.match(streamHook, /event\?\.method === "input\.requested"/); assert.match(streamHook, /runtimeInterrupts/); assert.doesNotMatch(container, /useSuperAgentChat/); assert.doesNotMatch(container, /respondSuperAgentCheckpoint/); assert.doesNotMatch(container, /sendSuperAgentChat/); const generatedDecisionStart = container.indexOf("const response = {"); const generatedDecisionEnd = container.indexOf("};", generatedDecisionStart); const generatedDecision = container.slice(generatedDecisionStart, generatedDecisionEnd); assert.doesNotMatch(generatedDecision, /interrupt_id:/); assert.doesNotMatch(generatedDecision, /namespace:/); assert.doesNotMatch(container, /stream-tool-log-/); assert.doesNotMatch(container, /正在思考/); assert.doesNotMatch(runLog, /正在处理|showProcessingStatus/); assert.doesNotMatch(conversation, /BodyProgressGroup|isBodyProgressMessage/); assert.match(conversation, /super-streaming-suffix/); assert.match(generatedInterrupt, /onOpenWorkspace/); assert.match(generatedInterrupt, /disabled = false/); assert.doesNotMatch(generatedInterrupt, /待填写/); assert.match(checkpointUtils, /buildGeneratedUiWorkspaceCheckpoint/); assert.match(checkpointUtils, /buildGeneratedUiCorrectedValues/); assert.match(checkpointUtils, /__generatedFieldLabels/); assert.match(listWorkspace, /getItemFieldLabel/); assert.match(workspaceHost, /submitLabel/); assert.match(container, /if \(submitted\) closeWorkspace\(\)/); assert.match(streamHook, /awaiting_interrupt/); assert.match(streamHook, /isWaitingForInterrupt/); assert.match(container, /refreshSessionContentWorkspace/); assert.match(container, /syncSessionProgressSections/); assert.match(conversation, /toolCalls=\{item\.toolCalls\}/); assert.match(jsonRender, /toolCall\?\.name === "publish_ui"/); assert.doesNotMatch(jsonRender, /```json-render|JSON_RENDER_FENCE/); assert.match(apiRoutes, /'\/api\/chat'/); assert.match(apiRoutes, /'\/api\/checkpoint\/respond'/);