@xdelivered/emberflow 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +153 -0
- package/bin/commands.test.ts +185 -0
- package/bin/commands.ts +306 -0
- package/bin/emberflow.mjs +38 -0
- package/bin/init.test.ts +165 -0
- package/bin/init.ts +297 -0
- package/bin/runtime.mjs +105 -0
- package/bin/runtime.test.ts +167 -0
- package/bin/skillTargets.test.ts +108 -0
- package/bin/skillTargets.ts +36 -0
- package/bin/skillTemplates.test.ts +37 -0
- package/bin/tsconfig.json +23 -0
- package/dist/bin/commands.d.ts +24 -0
- package/dist/bin/commands.js +252 -0
- package/dist/bin/init.d.ts +17 -0
- package/dist/bin/init.js +241 -0
- package/dist/bin/runtime.d.mts +39 -0
- package/dist/bin/runtime.mjs +96 -0
- package/dist/bin/skillTargets.d.ts +13 -0
- package/dist/bin/skillTargets.js +22 -0
- package/dist/server/agents/claudeAdapter.d.ts +8 -0
- package/dist/server/agents/claudeAdapter.js +190 -0
- package/dist/server/agents/claudeParse.d.ts +2 -0
- package/dist/server/agents/claudeParse.js +162 -0
- package/dist/server/agents/codexAdapter.d.ts +13 -0
- package/dist/server/agents/codexAdapter.js +174 -0
- package/dist/server/agents/codexParse.d.ts +2 -0
- package/dist/server/agents/codexParse.js +74 -0
- package/dist/server/agents/detect.d.ts +23 -0
- package/dist/server/agents/detect.js +35 -0
- package/dist/server/agents/gitScope.d.ts +24 -0
- package/dist/server/agents/gitScope.js +95 -0
- package/dist/server/agents/modelRejectionHint.d.ts +8 -0
- package/dist/server/agents/modelRejectionHint.js +12 -0
- package/dist/server/agents/prompt.d.ts +79 -0
- package/dist/server/agents/prompt.js +364 -0
- package/dist/server/agents/runManager.d.ts +90 -0
- package/dist/server/agents/runManager.js +259 -0
- package/dist/server/agents/types.d.ts +15 -0
- package/dist/server/agents/types.js +1 -0
- package/dist/server/apiStore.d.ts +60 -0
- package/dist/server/apiStore.js +249 -0
- package/dist/server/auth/enforce.d.ts +1 -0
- package/dist/server/auth/enforce.js +6 -0
- package/dist/server/auth/types.d.ts +1 -0
- package/dist/server/auth/types.js +1 -0
- package/dist/server/auth/verifiers.d.ts +1 -0
- package/dist/server/auth/verifiers.js +4 -0
- package/dist/server/authAttach.d.ts +19 -0
- package/dist/server/authAttach.js +79 -0
- package/dist/server/cli.d.ts +7 -0
- package/dist/server/cli.js +804 -0
- package/dist/server/client.d.ts +130 -0
- package/dist/server/client.js +247 -0
- package/dist/server/environments.d.ts +103 -0
- package/dist/server/environments.js +486 -0
- package/dist/server/flowStore.d.ts +37 -0
- package/dist/server/flowStore.js +117 -0
- package/dist/server/httpOperations.d.ts +32 -0
- package/dist/server/httpOperations.js +62 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1022 -0
- package/dist/server/infrastructure.d.ts +51 -0
- package/dist/server/infrastructure.js +116 -0
- package/dist/server/login.d.ts +21 -0
- package/dist/server/login.js +44 -0
- package/dist/server/mcp.d.ts +1 -0
- package/dist/server/mcp.js +182 -0
- package/dist/server/migrateFlows.d.ts +8 -0
- package/dist/server/migrateFlows.js +25 -0
- package/dist/server/mockHandler.d.ts +15 -0
- package/dist/server/mockHandler.js +35 -0
- package/dist/server/nodesPayload.d.ts +14 -0
- package/dist/server/nodesPayload.js +14 -0
- package/dist/server/normalizeFlow.d.ts +21 -0
- package/dist/server/normalizeFlow.js +48 -0
- package/dist/server/openBrowser.d.ts +8 -0
- package/dist/server/openBrowser.js +16 -0
- package/dist/server/operationResult.d.ts +12 -0
- package/dist/server/operationResult.js +26 -0
- package/dist/server/pathGuard.d.ts +1 -0
- package/dist/server/pathGuard.js +16 -0
- package/dist/server/pathSafety.d.ts +20 -0
- package/dist/server/pathSafety.js +35 -0
- package/dist/server/projectConfig.d.ts +47 -0
- package/dist/server/projectConfig.js +61 -0
- package/dist/server/projectMode.d.ts +26 -0
- package/dist/server/projectMode.js +44 -0
- package/dist/server/redact.d.ts +6 -0
- package/dist/server/redact.js +37 -0
- package/dist/server/runRegistry.d.ts +84 -0
- package/dist/server/runRegistry.js +200 -0
- package/dist/server/runtime/RuntimeAdapter.d.ts +22 -0
- package/dist/server/runtime/RuntimeAdapter.js +1 -0
- package/dist/server/runtime/expressAdapter.d.ts +19 -0
- package/dist/server/runtime/expressAdapter.js +56 -0
- package/dist/server/scenarioTest.d.ts +14 -0
- package/dist/server/scenarioTest.js +66 -0
- package/dist/server/subflowRunner.d.ts +32 -0
- package/dist/server/subflowRunner.js +72 -0
- package/dist/server/testRunner.d.ts +70 -0
- package/dist/server/testRunner.js +151 -0
- package/dist/src/config.d.ts +3 -0
- package/dist/src/config.js +2 -0
- package/dist/src/engine/authVerify.d.ts +33 -0
- package/dist/src/engine/authVerify.js +63 -0
- package/dist/src/engine/diagnostics.d.ts +62 -0
- package/dist/src/engine/diagnostics.js +148 -0
- package/dist/src/engine/executor.d.ts +151 -0
- package/dist/src/engine/executor.js +684 -0
- package/dist/src/engine/httpError.d.ts +7 -0
- package/dist/src/engine/httpError.js +14 -0
- package/dist/src/engine/index.d.ts +11 -0
- package/dist/src/engine/index.js +11 -0
- package/dist/src/engine/output.d.ts +11 -0
- package/dist/src/engine/output.js +20 -0
- package/dist/src/engine/publish.d.ts +30 -0
- package/dist/src/engine/publish.js +95 -0
- package/dist/src/engine/registry.d.ts +34 -0
- package/dist/src/engine/registry.js +67 -0
- package/dist/src/engine/scenarios.d.ts +12 -0
- package/dist/src/engine/scenarios.js +19 -0
- package/dist/src/engine/schemaCheck.d.ts +4 -0
- package/dist/src/engine/schemaCheck.js +34 -0
- package/dist/src/engine/trace.d.ts +12 -0
- package/dist/src/engine/trace.js +12 -0
- package/dist/src/engine/types.d.ts +308 -0
- package/dist/src/engine/types.js +1 -0
- package/dist/src/engine/validation.d.ts +26 -0
- package/dist/src/engine/validation.js +318 -0
- package/dist/src/flows/anomaly-flows.d.ts +23 -0
- package/dist/src/flows/anomaly-flows.js +151 -0
- package/dist/src/flows/city-sweep-flow.d.ts +10 -0
- package/dist/src/flows/city-sweep-flow.js +127 -0
- package/dist/src/flows/login-flow.d.ts +13 -0
- package/dist/src/flows/login-flow.js +145 -0
- package/dist/src/flows/pradar-flows.d.ts +5 -0
- package/dist/src/flows/pradar-flows.js +375 -0
- package/dist/src/flows/weather-flow.d.ts +12 -0
- package/dist/src/flows/weather-flow.js +150 -0
- package/dist/src/lib/pathParams.d.ts +3 -0
- package/dist/src/lib/pathParams.js +6 -0
- package/dist/src/nodes/anomaly.d.ts +2 -0
- package/dist/src/nodes/anomaly.js +556 -0
- package/dist/src/nodes/flow-control.d.ts +7 -0
- package/dist/src/nodes/flow-control.js +270 -0
- package/dist/src/nodes/index.d.ts +3 -0
- package/dist/src/nodes/index.js +20 -0
- package/dist/src/nodes/login.d.ts +7 -0
- package/dist/src/nodes/login.js +158 -0
- package/dist/src/nodes/loops.d.ts +11 -0
- package/dist/src/nodes/loops.js +60 -0
- package/dist/src/nodes/pradar/index.d.ts +7 -0
- package/dist/src/nodes/pradar/index.js +9 -0
- package/dist/src/nodes/pradar/logic.d.ts +189 -0
- package/dist/src/nodes/pradar/logic.js +370 -0
- package/dist/src/nodes/pradar/nodes.d.ts +42 -0
- package/dist/src/nodes/pradar/nodes.js +801 -0
- package/dist/src/nodes/requireAuth.d.ts +20 -0
- package/dist/src/nodes/requireAuth.js +48 -0
- package/dist/src/nodes/response.d.ts +8 -0
- package/dist/src/nodes/response.js +33 -0
- package/dist/src/nodes/weather.d.ts +33 -0
- package/dist/src/nodes/weather.js +260 -0
- package/package.json +92 -0
- package/server/agentRoute.test.ts +157 -0
- package/server/agents/__fixtures__/fake-claude-writer.mjs +23 -0
- package/server/agents/__fixtures__/fake-claude.mjs +55 -0
- package/server/agents/__fixtures__/fake-codex-writer.mjs +27 -0
- package/server/agents/__fixtures__/fake-codex.mjs +52 -0
- package/server/agents/__fixtures__/fake-version-empty.mjs +3 -0
- package/server/agents/__fixtures__/fake-version-fail.mjs +4 -0
- package/server/agents/__fixtures__/fake-version-garbage.mjs +4 -0
- package/server/agents/__fixtures__/fake-version-good.mjs +4 -0
- package/server/agents/__fixtures__/fake-version-hang.mjs +3 -0
- package/server/agents/claudeAdapter.test.ts +127 -0
- package/server/agents/claudeAdapter.ts +212 -0
- package/server/agents/claudeParse.ts +193 -0
- package/server/agents/codexAdapter.test.ts +125 -0
- package/server/agents/codexAdapter.ts +198 -0
- package/server/agents/codexParse.test.ts +58 -0
- package/server/agents/codexParse.ts +126 -0
- package/server/agents/detect.test.ts +65 -0
- package/server/agents/detect.ts +43 -0
- package/server/agents/gitScope.test.ts +129 -0
- package/server/agents/gitScope.ts +110 -0
- package/server/agents/modelRejectionHint.test.ts +30 -0
- package/server/agents/modelRejectionHint.ts +14 -0
- package/server/agents/prompt.test.ts +613 -0
- package/server/agents/prompt.ts +527 -0
- package/server/agents/runManager.test.ts +251 -0
- package/server/agents/runManager.ts +286 -0
- package/server/agents/types.ts +17 -0
- package/server/apiMount.test.ts +591 -0
- package/server/apiStore.test.ts +324 -0
- package/server/apiStore.ts +241 -0
- package/server/auth/enforce.test.ts +61 -0
- package/server/auth/enforce.ts +6 -0
- package/server/auth/types.ts +5 -0
- package/server/auth/verifiers.test.ts +37 -0
- package/server/auth/verifiers.ts +9 -0
- package/server/authAttach.test.ts +175 -0
- package/server/authAttach.ts +99 -0
- package/server/cli.ts +847 -0
- package/server/cliAuth.test.ts +229 -0
- package/server/cliCreate.test.ts +131 -0
- package/server/cliDoctor.test.ts +326 -0
- package/server/cliTest.test.ts +735 -0
- package/server/client.ts +314 -0
- package/server/demoProject.test.ts +29 -0
- package/server/diagnosticsRoute.test.ts +169 -0
- package/server/environments.test.ts +620 -0
- package/server/environments.ts +603 -0
- package/server/environmentsRoute.test.ts +385 -0
- package/server/errorWorkflow.test.ts +205 -0
- package/server/flowStore.test.ts +84 -0
- package/server/flowStore.ts +125 -0
- package/server/httpOperations.test.ts +377 -0
- package/server/httpOperations.ts +96 -0
- package/server/index.ts +1111 -0
- package/server/infrastructure.test.ts +154 -0
- package/server/infrastructure.ts +161 -0
- package/server/infrastructureRoute.test.ts +105 -0
- package/server/login.test.ts +153 -0
- package/server/login.ts +67 -0
- package/server/mcp.ts +278 -0
- package/server/migrateFlows.test.ts +55 -0
- package/server/migrateFlows.ts +23 -0
- package/server/mockHandler.test.ts +138 -0
- package/server/mockHandler.ts +52 -0
- package/server/mockRun.test.ts +367 -0
- package/server/mockServe.test.ts +467 -0
- package/server/nodesPayload.test.ts +29 -0
- package/server/nodesPayload.ts +26 -0
- package/server/normalizeFlow.test.ts +80 -0
- package/server/normalizeFlow.ts +59 -0
- package/server/openBrowser.test.ts +20 -0
- package/server/openBrowser.ts +22 -0
- package/server/operationResult.test.ts +67 -0
- package/server/operationResult.ts +27 -0
- package/server/pathGuard.test.ts +19 -0
- package/server/pathGuard.ts +12 -0
- package/server/pathSafety.test.ts +38 -0
- package/server/pathSafety.ts +33 -0
- package/server/projectConfig.test.ts +67 -0
- package/server/projectConfig.ts +101 -0
- package/server/projectMode.test.ts +106 -0
- package/server/projectMode.ts +59 -0
- package/server/redact.test.ts +88 -0
- package/server/redact.ts +35 -0
- package/server/redactEgress.test.ts +281 -0
- package/server/runRegistry.ts +270 -0
- package/server/runsAuth.test.ts +119 -0
- package/server/runtime/RuntimeAdapter.ts +24 -0
- package/server/runtime/expressAdapter.test.ts +38 -0
- package/server/runtime/expressAdapter.ts +70 -0
- package/server/scenarioTest.test.ts +148 -0
- package/server/scenarioTest.ts +88 -0
- package/server/setupStatus.test.ts +127 -0
- package/server/subflowRunner.ts +104 -0
- package/server/testRunner.ts +216 -0
- package/server/tsconfig.json +20 -0
- package/server/workflowTestRoute.test.ts +297 -0
- package/src/App.tsx +233 -0
- package/src/components/AgentConsole.tsx +461 -0
- package/src/components/BranchRulesEditor.tsx +156 -0
- package/src/components/CreateModal.tsx +275 -0
- package/src/components/Dock.tsx +487 -0
- package/src/components/EnvironmentDialog.tsx +569 -0
- package/src/components/EnvironmentPicker.tsx +357 -0
- package/src/components/EnvironmentsDialog.tsx +144 -0
- package/src/components/ExecutionPager.tsx +67 -0
- package/src/components/InfraPanel.test.tsx +103 -0
- package/src/components/InfraPanel.tsx +171 -0
- package/src/components/Inspector.tsx +1182 -0
- package/src/components/Json.tsx +50 -0
- package/src/components/JsonModal.tsx +52 -0
- package/src/components/LogMessage.tsx +61 -0
- package/src/components/NodeRunModal.tsx +213 -0
- package/src/components/RunLogPanel.tsx +397 -0
- package/src/components/RunbookView.tsx +1085 -0
- package/src/components/Scenarios.tsx +476 -0
- package/src/components/SettingsDialog.tsx +229 -0
- package/src/components/Sidebar.tsx +436 -0
- package/src/components/StatusBar.tsx +302 -0
- package/src/components/Toolbar.tsx +663 -0
- package/src/components/WelcomeDialog.test.tsx +107 -0
- package/src/components/WelcomeDialog.tsx +412 -0
- package/src/components/agentMarkdown.test.tsx +91 -0
- package/src/components/agentMarkdown.tsx +158 -0
- package/src/components/ui/badge.tsx +31 -0
- package/src/components/ui/button.tsx +46 -0
- package/src/components/ui/combobox.tsx +114 -0
- package/src/components/ui/command.tsx +82 -0
- package/src/components/ui/dialog.tsx +73 -0
- package/src/components/ui/input.tsx +20 -0
- package/src/components/ui/popover.tsx +32 -0
- package/src/components/ui/resizable.tsx +44 -0
- package/src/components/ui/tabs.tsx +36 -0
- package/src/config.ts +4 -0
- package/src/engine/authVerify.ts +81 -0
- package/src/engine/diagnostics.test.ts +437 -0
- package/src/engine/diagnostics.ts +211 -0
- package/src/engine/executor.test.ts +1339 -0
- package/src/engine/executor.ts +840 -0
- package/src/engine/httpError.test.ts +12 -0
- package/src/engine/httpError.ts +16 -0
- package/src/engine/index.ts +11 -0
- package/src/engine/output.ts +21 -0
- package/src/engine/publish.test.ts +176 -0
- package/src/engine/publish.ts +127 -0
- package/src/engine/registry.test.ts +64 -0
- package/src/engine/registry.ts +80 -0
- package/src/engine/scenarios.test.ts +55 -0
- package/src/engine/scenarios.ts +29 -0
- package/src/engine/schemaCheck.test.ts +21 -0
- package/src/engine/schemaCheck.ts +35 -0
- package/src/engine/trace.test.ts +19 -0
- package/src/engine/trace.ts +23 -0
- package/src/engine/types.test.ts +22 -0
- package/src/engine/types.ts +316 -0
- package/src/engine/validation.test.ts +314 -0
- package/src/engine/validation.ts +354 -0
- package/src/flows/anomaly-flows.test.ts +81 -0
- package/src/flows/anomaly-flows.ts +202 -0
- package/src/flows/city-sweep-flow.ts +131 -0
- package/src/flows/flows.test.ts +30 -0
- package/src/flows/login-flow.ts +150 -0
- package/src/flows/pradar-flows.test.ts +204 -0
- package/src/flows/pradar-flows.ts +419 -0
- package/src/flows/weather-flow.ts +154 -0
- package/src/globals.css +147 -0
- package/src/lib/pathParams.test.ts +24 -0
- package/src/lib/pathParams.ts +6 -0
- package/src/lib/registerLens.test.ts +79 -0
- package/src/lib/registerLens.ts +59 -0
- package/src/lib/runbookModel.test.ts +61 -0
- package/src/lib/runbookModel.ts +290 -0
- package/src/lib/runbookProjection.test.ts +417 -0
- package/src/lib/runbookProjection.ts +254 -0
- package/src/lib/useTailAnchor.ts +53 -0
- package/src/lib/utils.ts +7 -0
- package/src/main.tsx +13 -0
- package/src/nodes/anomaly.test.ts +98 -0
- package/src/nodes/anomaly.ts +637 -0
- package/src/nodes/effects-scan.test.ts +44 -0
- package/src/nodes/flow-control.test.ts +280 -0
- package/src/nodes/flow-control.ts +305 -0
- package/src/nodes/index.ts +22 -0
- package/src/nodes/login.test.ts +81 -0
- package/src/nodes/login.ts +186 -0
- package/src/nodes/loops.ts +69 -0
- package/src/nodes/pradar/index.ts +11 -0
- package/src/nodes/pradar/logic.test.ts +288 -0
- package/src/nodes/pradar/logic.ts +582 -0
- package/src/nodes/pradar/nodes.test.ts +146 -0
- package/src/nodes/pradar/nodes.ts +955 -0
- package/src/nodes/requireAuth.test.ts +75 -0
- package/src/nodes/requireAuth.ts +55 -0
- package/src/nodes/response.test.ts +33 -0
- package/src/nodes/response.ts +39 -0
- package/src/nodes/traceDetail.test.ts +39 -0
- package/src/nodes/weather.test.ts +65 -0
- package/src/nodes/weather.ts +306 -0
- package/src/store/agentClient.test.ts +103 -0
- package/src/store/agentClient.ts +131 -0
- package/src/store/apiTree.test.ts +17 -0
- package/src/store/apiTree.ts +73 -0
- package/src/store/builderStore.test.ts +1234 -0
- package/src/store/builderStore.ts +1879 -0
- package/src/store/infraClient.ts +63 -0
- package/src/store/nodeMeta.test.ts +24 -0
- package/src/store/nodeMeta.ts +21 -0
- package/src/store/persistence.test.ts +15 -0
- package/src/store/persistence.ts +54 -0
- package/src/store/serverRunner.ts +381 -0
- package/src/store/setupClient.ts +57 -0
- package/studio-dist/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
- package/studio-dist/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
- package/studio-dist/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
- package/studio-dist/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
- package/studio-dist/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
- package/studio-dist/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
- package/studio-dist/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
- package/studio-dist/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
- package/studio-dist/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- package/studio-dist/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- package/studio-dist/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- package/studio-dist/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/studio-dist/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
- package/studio-dist/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
- package/studio-dist/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
- package/studio-dist/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
- package/studio-dist/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
- package/studio-dist/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
- package/studio-dist/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
- package/studio-dist/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
- package/studio-dist/assets/index-DNJwW-hM.css +1 -0
- package/studio-dist/assets/index-O26dKRjW.js +65 -0
- package/studio-dist/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/studio-dist/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/studio-dist/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/studio-dist/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/studio-dist/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/studio-dist/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/studio-dist/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/studio-dist/favicon.svg +1 -0
- package/studio-dist/icons.svg +24 -0
- package/studio-dist/index.html +14 -0
- package/templates/skills/emberflow-basics/SKILL.md +316 -0
- package/templates/skills/emberflow-model-process/SKILL.md +209 -0
- package/templates/skills/emberflow-new-workflow/SKILL.md +211 -0
- package/templates/skills/emberflow-review-workflow/SKILL.md +148 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { cancelAgent, fetchAgentDiff, fetchAvailableAgents, revertAgent, startAgent } from './agentClient';
|
|
3
|
+
import type { AgentIntent } from './agentClient';
|
|
4
|
+
|
|
5
|
+
afterEach(() => vi.unstubAllGlobals());
|
|
6
|
+
|
|
7
|
+
const intent: AgentIntent = { action: 'edit-flow', flowId: 'f1', instruction: 'do the thing' };
|
|
8
|
+
|
|
9
|
+
describe('startAgent', () => {
|
|
10
|
+
it('posts the intent and returns the agent run id', async () => {
|
|
11
|
+
const fetchMock = vi.fn(async () => ({
|
|
12
|
+
ok: true,
|
|
13
|
+
json: async () => ({ agentRunId: 'run-1' }),
|
|
14
|
+
}));
|
|
15
|
+
vi.stubGlobal('fetch', fetchMock);
|
|
16
|
+
|
|
17
|
+
const id = await startAgent(intent, { model: 'gpt-5' });
|
|
18
|
+
|
|
19
|
+
expect(id).toBe('run-1');
|
|
20
|
+
expect(fetchMock).toHaveBeenCalledWith(
|
|
21
|
+
'/api/agent',
|
|
22
|
+
expect.objectContaining({
|
|
23
|
+
method: 'POST',
|
|
24
|
+
headers: { 'content-type': 'application/json' },
|
|
25
|
+
body: JSON.stringify({ intent, model: 'gpt-5' }),
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('throws with the server error message on failure', async () => {
|
|
31
|
+
vi.stubGlobal(
|
|
32
|
+
'fetch',
|
|
33
|
+
vi.fn(async () => ({ ok: false, status: 400, json: async () => ({ error: 'bad intent' }) })),
|
|
34
|
+
);
|
|
35
|
+
await expect(startAgent(intent)).rejects.toThrow('bad intent');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('fetchAgentDiff', () => {
|
|
40
|
+
it('returns the parsed diff body', async () => {
|
|
41
|
+
vi.stubGlobal(
|
|
42
|
+
'fetch',
|
|
43
|
+
vi.fn(async () => ({ ok: true, json: async () => ({ diff: 'diff --git', files: ['a.json'] }) })),
|
|
44
|
+
);
|
|
45
|
+
expect(await fetchAgentDiff('run-1')).toEqual({ diff: 'diff --git', files: ['a.json'] });
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('throws on a non-ok response', async () => {
|
|
49
|
+
vi.stubGlobal(
|
|
50
|
+
'fetch',
|
|
51
|
+
vi.fn(async () => ({ ok: false, status: 404, json: async () => ({ error: 'Unknown agent run: run-1' }) })),
|
|
52
|
+
);
|
|
53
|
+
await expect(fetchAgentDiff('run-1')).rejects.toThrow('Unknown agent run: run-1');
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('revertAgent', () => {
|
|
58
|
+
it('POSTs to revert and returns the reverted file list', async () => {
|
|
59
|
+
const fetchMock = vi.fn(async () => ({
|
|
60
|
+
ok: true,
|
|
61
|
+
json: async () => ({ reverted: ['flows/hello.json'] }),
|
|
62
|
+
}));
|
|
63
|
+
vi.stubGlobal('fetch', fetchMock);
|
|
64
|
+
|
|
65
|
+
expect(await revertAgent('run-1')).toEqual({ reverted: ['flows/hello.json'] });
|
|
66
|
+
expect(fetchMock).toHaveBeenCalledWith('/api/agent/run-1/revert', { method: 'POST' });
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('fetchAvailableAgents', () => {
|
|
71
|
+
it('returns the detected agent list with versions', async () => {
|
|
72
|
+
vi.stubGlobal(
|
|
73
|
+
'fetch',
|
|
74
|
+
vi.fn(async () => ({ ok: true, json: async () => ({ agents: [{ kind: 'codex', version: '0.142.5' }] }) })),
|
|
75
|
+
);
|
|
76
|
+
expect(await fetchAvailableAgents()).toEqual([{ kind: 'codex', version: '0.142.5' }]);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('returns [] on a non-ok response', async () => {
|
|
80
|
+
vi.stubGlobal('fetch', vi.fn(async () => ({ ok: false })));
|
|
81
|
+
expect(await fetchAvailableAgents()).toEqual([]);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('returns [] when the server is unreachable', async () => {
|
|
85
|
+
vi.stubGlobal('fetch', vi.fn(async () => { throw new Error('down'); }));
|
|
86
|
+
expect(await fetchAvailableAgents()).toEqual([]);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('cancelAgent', () => {
|
|
91
|
+
it('POSTs to cancel', async () => {
|
|
92
|
+
const fetchMock = vi.fn(async () => ({ ok: true, json: async () => ({ cancelled: true }) }));
|
|
93
|
+
vi.stubGlobal('fetch', fetchMock);
|
|
94
|
+
|
|
95
|
+
await cancelAgent('run-1');
|
|
96
|
+
expect(fetchMock).toHaveBeenCalledWith('/api/agent/run-1/cancel', { method: 'POST' });
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('swallows fetch failures', async () => {
|
|
100
|
+
vi.stubGlobal('fetch', vi.fn(async () => { throw new Error('down'); }));
|
|
101
|
+
await expect(cancelAgent('run-1')).resolves.toBeUndefined();
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client for the agent-run API (server/agents/*), reached through the Vite
|
|
3
|
+
* proxy at /api → 127.0.0.1:8092, same-origin as serverRunner.ts/nodeMeta.ts.
|
|
4
|
+
*
|
|
5
|
+
* NOTE ON DUPLICATION: the browser bundle cannot import from server/ (it's a
|
|
6
|
+
* Node-only tree), so `AgentEvent`/`AgentKind` (mirroring server/agents/types.ts)
|
|
7
|
+
* and `AgentIntent` (mirroring server/agents/prompt.ts) are duplicated here.
|
|
8
|
+
* Keep this shape in sync by hand if the server types change.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const BASE = '/api';
|
|
12
|
+
|
|
13
|
+
export type AgentKind = 'codex' | 'claude';
|
|
14
|
+
|
|
15
|
+
export interface DetectedAgent {
|
|
16
|
+
kind: AgentKind;
|
|
17
|
+
version: string | null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface AgentEvent {
|
|
21
|
+
type: 'started' | 'message' | 'command' | 'mcp' | 'approval-request' | 'done' | 'error';
|
|
22
|
+
text?: string; // message/error text
|
|
23
|
+
command?: string; // for 'command'
|
|
24
|
+
commandStatus?: 'in_progress' | 'completed' | 'failed';
|
|
25
|
+
exitCode?: number | null; // for 'command'
|
|
26
|
+
output?: string; // command aggregated output OR an mcp call's result
|
|
27
|
+
toolUseId?: string; // for 'command'/'mcp' (Claude) — correlates a tool_use with its later tool_result
|
|
28
|
+
approvalId?: string; // for 'approval-request' (Claude)
|
|
29
|
+
usage?: Record<string, number>; // for 'done'
|
|
30
|
+
mcpServer?: string; // for 'mcp' — e.g. 'emberflow'
|
|
31
|
+
mcpTool?: string; // for 'mcp' — e.g. 'run_operation'
|
|
32
|
+
mcpStatus?: 'in_progress' | 'completed' | 'failed';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type AgentIntent =
|
|
36
|
+
| { action: 'new-scenario'; flowId: string; instruction: string }
|
|
37
|
+
| { action: 'edit-node'; flowId: string; nodeId: string; instruction: string }
|
|
38
|
+
| { action: 'edit-flow'; flowId: string; instruction: string; scaffold?: boolean }
|
|
39
|
+
| { action: 'new-operation'; location: string; instruction: string }
|
|
40
|
+
| { action: 'setup-auth'; environment: string; instruction: string }
|
|
41
|
+
| { action: 'setup-environments'; instruction: string }
|
|
42
|
+
| { action: 'scout-infrastructure'; instruction: string }
|
|
43
|
+
| { action: 'cover-operation'; flowId: string; instruction: string }
|
|
44
|
+
| { action: 'ask'; flowId?: string; instruction: string };
|
|
45
|
+
|
|
46
|
+
export interface StartAgentOptions {
|
|
47
|
+
agent?: AgentKind;
|
|
48
|
+
model?: string;
|
|
49
|
+
reasoning?: 'low' | 'medium' | 'high';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** GET /agent/available — which agent CLIs the server detected on PATH, and their versions. Returns [] if unreachable. */
|
|
53
|
+
export async function fetchAvailableAgents(): Promise<DetectedAgent[]> {
|
|
54
|
+
try {
|
|
55
|
+
const response = await fetch(`${BASE}/agent/available`);
|
|
56
|
+
if (!response.ok) return [];
|
|
57
|
+
const { agents } = (await response.json()) as { agents: DetectedAgent[] };
|
|
58
|
+
return agents ?? [];
|
|
59
|
+
} catch {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** POST /agent — start an agent run, returns its id. */
|
|
65
|
+
export async function startAgent(intent: AgentIntent, opts?: StartAgentOptions): Promise<string> {
|
|
66
|
+
const response = await fetch(`${BASE}/agent`, {
|
|
67
|
+
method: 'POST',
|
|
68
|
+
headers: { 'content-type': 'application/json' },
|
|
69
|
+
body: JSON.stringify({ intent, ...opts }),
|
|
70
|
+
});
|
|
71
|
+
if (!response.ok) {
|
|
72
|
+
const body = (await response.json().catch(() => ({}))) as { error?: string };
|
|
73
|
+
throw new Error(body.error ?? `Failed to start agent (HTTP ${response.status})`);
|
|
74
|
+
}
|
|
75
|
+
const { agentRunId } = (await response.json()) as { agentRunId: string };
|
|
76
|
+
return agentRunId;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Subscribe to an agent run's SSE stream at /agent/:id/events. Each server
|
|
81
|
+
* event carries its own `type` field mirrored in `data`, so we listen for
|
|
82
|
+
* every AgentEvent type and hand the parsed payload straight to `onEvent`.
|
|
83
|
+
* Returns an unsubscribe function.
|
|
84
|
+
*/
|
|
85
|
+
export function streamAgent(agentRunId: string, onEvent: (event: AgentEvent) => void): () => void {
|
|
86
|
+
const source = new EventSource(`${BASE}/agent/${agentRunId}/events`);
|
|
87
|
+
const types: AgentEvent['type'][] = ['started', 'message', 'command', 'mcp', 'approval-request', 'done', 'error'];
|
|
88
|
+
for (const type of types) {
|
|
89
|
+
source.addEventListener(type, (event) => {
|
|
90
|
+
const data = JSON.parse((event as MessageEvent).data) as AgentEvent;
|
|
91
|
+
onEvent(data);
|
|
92
|
+
if (type === 'done' || type === 'error') source.close();
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
source.onerror = () => {
|
|
96
|
+
if (source.readyState === EventSource.CLOSED) {
|
|
97
|
+
onEvent({ type: 'error', text: 'Lost connection to the agent event stream' });
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return () => source.close();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface AgentDiffResult {
|
|
104
|
+
diff: string;
|
|
105
|
+
files: string[];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** GET /agent/:id/diff */
|
|
109
|
+
export async function fetchAgentDiff(agentRunId: string): Promise<AgentDiffResult> {
|
|
110
|
+
const response = await fetch(`${BASE}/agent/${agentRunId}/diff`);
|
|
111
|
+
if (!response.ok) {
|
|
112
|
+
const body = (await response.json().catch(() => ({}))) as { error?: string };
|
|
113
|
+
throw new Error(body.error ?? `Failed to fetch agent diff (HTTP ${response.status})`);
|
|
114
|
+
}
|
|
115
|
+
return (await response.json()) as AgentDiffResult;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** POST /agent/:id/revert — returns the list of reverted file paths. */
|
|
119
|
+
export async function revertAgent(agentRunId: string): Promise<{ reverted: string[] }> {
|
|
120
|
+
const response = await fetch(`${BASE}/agent/${agentRunId}/revert`, { method: 'POST' });
|
|
121
|
+
if (!response.ok) {
|
|
122
|
+
const body = (await response.json().catch(() => ({}))) as { error?: string };
|
|
123
|
+
throw new Error(body.error ?? `Failed to revert agent run (HTTP ${response.status})`);
|
|
124
|
+
}
|
|
125
|
+
return (await response.json()) as { reverted: string[] };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** POST /agent/:id/cancel */
|
|
129
|
+
export async function cancelAgent(agentRunId: string): Promise<void> {
|
|
130
|
+
await fetch(`${BASE}/agent/${agentRunId}/cancel`, { method: 'POST' }).catch(() => undefined);
|
|
131
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { expect, it } from 'vitest';
|
|
2
|
+
import { buildApiTree } from './apiTree';
|
|
3
|
+
|
|
4
|
+
it('groups operations into APIs and nested folders, sorted', () => {
|
|
5
|
+
const tree = buildApiTree([
|
|
6
|
+
{ id: 'a', name: 'Create', path: 'claims/claims/create', http: { method: 'POST', path: '/claims' } },
|
|
7
|
+
{ id: 'b', name: 'Get', path: 'claims/claims/get', http: { method: 'GET', path: '/claims/:id' } },
|
|
8
|
+
{ id: 'c', name: 'Charge', path: 'billing/charge' },
|
|
9
|
+
]);
|
|
10
|
+
expect(tree.map((a) => a.name)).toEqual(['billing', 'claims']); // sorted
|
|
11
|
+
const claims = tree.find((a) => a.name === 'claims')!;
|
|
12
|
+
expect(claims.folders[0].name).toBe('claims');
|
|
13
|
+
expect(claims.folders[0].operations.map((o) => o.id)).toEqual(['a', 'b']); // Create, Get by name
|
|
14
|
+
expect(claims.folders[0].operations[0].method).toBe('POST');
|
|
15
|
+
const billing = tree.find((a) => a.name === 'billing')!;
|
|
16
|
+
expect(billing.operations.map((o) => o.id)).toEqual(['c']); // no folder → directly under api
|
|
17
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export interface OpItem {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
path: string;
|
|
5
|
+
method?: string;
|
|
6
|
+
httpPath?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ApiTreeNode {
|
|
10
|
+
name: string;
|
|
11
|
+
folders: ApiTreeNode[];
|
|
12
|
+
operations: OpItem[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface OpInput {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
path: string;
|
|
19
|
+
http?: { method: string; path: string };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getOrCreateChild(node: ApiTreeNode, name: string): ApiTreeNode {
|
|
23
|
+
let child = node.folders.find((f) => f.name === name);
|
|
24
|
+
if (!child) {
|
|
25
|
+
child = { name, folders: [], operations: [] };
|
|
26
|
+
node.folders.push(child);
|
|
27
|
+
}
|
|
28
|
+
return child;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function sortTree(node: ApiTreeNode): void {
|
|
32
|
+
node.folders.sort((a, b) => a.name.localeCompare(b.name));
|
|
33
|
+
node.operations.sort((a, b) => a.name.localeCompare(b.name));
|
|
34
|
+
for (const folder of node.folders) {
|
|
35
|
+
sortTree(folder);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function buildApiTree(ops: OpInput[]): ApiTreeNode[] {
|
|
40
|
+
const apis = new Map<string, ApiTreeNode>();
|
|
41
|
+
|
|
42
|
+
for (const op of ops) {
|
|
43
|
+
const segments = op.path.split('/').filter(Boolean);
|
|
44
|
+
if (segments.length === 0) continue;
|
|
45
|
+
const [apiName, ...rest] = segments;
|
|
46
|
+
const folderSegments = rest.slice(0, -1);
|
|
47
|
+
|
|
48
|
+
let api = apis.get(apiName);
|
|
49
|
+
if (!api) {
|
|
50
|
+
api = { name: apiName, folders: [], operations: [] };
|
|
51
|
+
apis.set(apiName, api);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let node = api;
|
|
55
|
+
for (const segment of folderSegments) {
|
|
56
|
+
node = getOrCreateChild(node, segment);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const item: OpItem = {
|
|
60
|
+
id: op.id,
|
|
61
|
+
name: op.name,
|
|
62
|
+
path: op.path,
|
|
63
|
+
method: op.http?.method,
|
|
64
|
+
httpPath: op.http?.path,
|
|
65
|
+
};
|
|
66
|
+
node.operations.push(item);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const tree = Array.from(apis.values());
|
|
70
|
+
tree.forEach(sortTree);
|
|
71
|
+
tree.sort((a, b) => a.name.localeCompare(b.name));
|
|
72
|
+
return tree;
|
|
73
|
+
}
|