stageflow 0.40.0 → 0.44.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/README.md +15 -4
- package/dist/agent/activity.d.ts +18 -0
- package/dist/agent/claudeAdapter.js +7 -0
- package/dist/agent/claudeTools.d.ts +27 -18
- package/dist/agent/claudeTools.js +54 -15
- package/dist/agent/compactionEvents.d.ts +34 -0
- package/dist/agent/compactionEvents.js +37 -0
- package/dist/agent/openRouterRouting.d.ts +7 -0
- package/dist/agent/openRouterRouting.js +23 -0
- package/dist/agent/piAdapter.d.ts +6 -0
- package/dist/agent/piAdapter.js +128 -27
- package/dist/agent/piSettings.d.ts +7 -0
- package/dist/agent/piSettings.js +9 -0
- package/dist/agent/sandboxPiTools.d.ts +3 -1
- package/dist/agent/sandboxPiTools.js +8 -2
- package/dist/agent/stageTurnDriver.d.ts +11 -2
- package/dist/agent/stageTurnDriver.js +45 -4
- package/dist/agent/toolOutputBudget.d.ts +15 -1
- package/dist/agent/toolOutputBudget.js +18 -0
- package/dist/agent/toolOutputBudgetExtension.d.ts +2 -0
- package/dist/agent/toolOutputBudgetExtension.js +40 -3
- package/dist/agents/authorChat.d.ts +5 -0
- package/dist/agents/authorChat.js +120 -12
- package/dist/agents/authorSessionStore.d.ts +38 -0
- package/dist/agents/authorSessionStore.js +167 -0
- package/dist/agents/chatTurn.d.ts +2 -0
- package/dist/agents/chatTurn.js +17 -1
- package/dist/agents/errors.d.ts +1 -1
- package/dist/agents/errors.js +1 -0
- package/dist/agents/evalGate.d.ts +61 -0
- package/dist/agents/evalGate.js +103 -0
- package/dist/agents/evalSession.d.ts +26 -0
- package/dist/agents/evalSession.js +29 -0
- package/dist/agents/hostContext.d.ts +4 -1
- package/dist/agents/hostContext.js +4 -1
- package/dist/agents/runtime/piRuntime.d.ts +6 -2
- package/dist/agents/runtime/piRuntime.js +50 -16
- package/dist/agents/runtime/types.d.ts +3 -1
- package/dist/agents/service.d.ts +27 -2
- package/dist/agents/service.js +91 -15
- package/dist/agents/sessions.d.ts +8 -0
- package/dist/agents/sessions.js +53 -11
- package/dist/agents/store.d.ts +14 -3
- package/dist/agents/store.js +45 -7
- package/dist/agents/toolRisk.d.ts +21 -0
- package/dist/agents/toolRisk.js +50 -0
- package/dist/cli/doctorCommand.js +26 -0
- package/dist/cli/evalCommand.d.ts +20 -0
- package/dist/cli/evalCommand.js +720 -0
- package/dist/cli/exportAllCommand.js +1 -1
- package/dist/cli/hostClient.d.ts +60 -0
- package/dist/cli/hostClient.js +71 -0
- package/dist/cli/validateOutput.d.ts +2 -2
- package/dist/cli/validateOutput.js +2 -2
- package/dist/cli.js +10 -0
- package/dist/compaction/directives.d.ts +18 -0
- package/dist/compaction/directives.js +119 -0
- package/dist/compaction/extension.d.ts +20 -0
- package/dist/compaction/extension.js +78 -0
- package/dist/compaction/mask.d.ts +18 -0
- package/dist/compaction/mask.js +155 -0
- package/dist/compaction/pin.d.ts +21 -0
- package/dist/compaction/pin.js +270 -0
- package/dist/compaction/scrub.d.ts +7 -0
- package/dist/compaction/scrub.js +26 -0
- package/dist/compaction/sessionWiring.d.ts +22 -0
- package/dist/compaction/sessionWiring.js +26 -0
- package/dist/compaction/summarize.d.ts +79 -0
- package/dist/compaction/summarize.js +171 -0
- package/dist/compaction/toolPolicy.d.ts +3 -0
- package/dist/compaction/toolPolicy.js +33 -0
- package/dist/compaction/types.d.ts +45 -0
- package/dist/compaction/types.js +7 -0
- package/dist/compaction/workingState.d.ts +56 -0
- package/dist/compaction/workingState.js +198 -0
- package/dist/config/atomicWrite.d.ts +15 -0
- package/dist/config/atomicWrite.js +43 -0
- package/dist/config/browseCatalog.d.ts +2 -0
- package/dist/config/browseCatalog.js +4 -2
- package/dist/config/createPipeline.js +2 -0
- package/dist/config/createTrigger.js +7 -1
- package/dist/config/csv.d.ts +9 -0
- package/dist/config/csv.js +81 -0
- package/dist/config/datasetAgentCheck.d.ts +18 -0
- package/dist/config/datasetAgentCheck.js +109 -0
- package/dist/config/datasetCandidates.d.ts +22 -0
- package/dist/config/datasetCandidates.js +86 -0
- package/dist/config/datasetFromSessions.d.ts +34 -0
- package/dist/config/datasetFromSessions.js +105 -0
- package/dist/config/datasetHash.d.ts +1 -0
- package/dist/config/datasetHash.js +4 -0
- package/dist/config/datasetImport.d.ts +21 -0
- package/dist/config/datasetImport.js +120 -0
- package/dist/config/datasetStageCheck.d.ts +9 -0
- package/dist/config/datasetStageCheck.js +17 -0
- package/dist/config/datasetTypes.d.ts +27 -0
- package/dist/config/datasetTypes.js +1 -0
- package/dist/config/ensureCatalogScanRoot.d.ts +4 -1
- package/dist/config/ensureCatalogScanRoot.js +8 -6
- package/dist/config/evalCatalog.d.ts +22 -0
- package/dist/config/evalCatalog.js +95 -0
- package/dist/config/evalWriteRoots.d.ts +17 -0
- package/dist/config/evalWriteRoots.js +109 -0
- package/dist/config/githubTriggerAction.d.ts +8 -0
- package/dist/config/githubTriggerAction.js +29 -0
- package/dist/config/hostConfig.js +3 -0
- package/dist/config/installEvalSample.d.ts +34 -0
- package/dist/config/installEvalSample.js +182 -0
- package/dist/config/loadDataset.d.ts +16 -0
- package/dist/config/loadDataset.js +318 -0
- package/dist/config/loadEval.d.ts +32 -0
- package/dist/config/loadEval.js +1103 -0
- package/dist/config/loadOutcome.d.ts +5 -0
- package/dist/config/loadStageflowManifest.js +64 -0
- package/dist/config/pipelineNeeds.d.ts +2 -0
- package/dist/config/pipelineNeeds.js +16 -3
- package/dist/config/pipelineRoute.js +5 -4
- package/dist/config/resolveAgentTarget.d.ts +32 -0
- package/dist/config/resolveAgentTarget.js +118 -0
- package/dist/config/resolveEvalTarget.d.ts +21 -0
- package/dist/config/resolveEvalTarget.js +89 -0
- package/dist/config/scanCatalogPaths.d.ts +1 -1
- package/dist/config/scanCatalogPaths.js +17 -5
- package/dist/config/validateCatalog.d.ts +2 -2
- package/dist/config/validateCatalog.js +21 -1
- package/dist/config/validateEval.d.ts +36 -0
- package/dist/config/validateEval.js +446 -0
- package/dist/config/writeDataset.d.ts +54 -0
- package/dist/config/writeDataset.js +186 -0
- package/dist/config/writeEval.d.ts +25 -0
- package/dist/config/writeEval.js +398 -0
- package/dist/diagnostics/checks.js +1 -1
- package/dist/envelope/assertEmittedArtifacts.d.ts +12 -0
- package/dist/envelope/assertEmittedArtifacts.js +43 -0
- package/dist/envelope/preEmitChecks.d.ts +3 -0
- package/dist/evals/agentDiff.d.ts +13 -0
- package/dist/evals/agentDiff.js +11 -0
- package/dist/evals/canonical.d.ts +3 -0
- package/dist/evals/canonical.js +24 -0
- package/dist/evals/caseTask.d.ts +3 -0
- package/dist/evals/caseTask.js +9 -0
- package/dist/evals/compare.d.ts +94 -0
- package/dist/evals/compare.js +201 -0
- package/dist/evals/constants.d.ts +62 -0
- package/dist/evals/constants.js +97 -0
- package/dist/evals/engine/FakeEngine.d.ts +33 -0
- package/dist/evals/engine/FakeEngine.js +177 -0
- package/dist/evals/engine/index.d.ts +9 -0
- package/dist/evals/engine/index.js +19 -0
- package/dist/evals/engine/promptfoo/PromptfooEngine.d.ts +52 -0
- package/dist/evals/engine/promptfoo/PromptfooEngine.js +312 -0
- package/dist/evals/engine/promptfoo/errors.d.ts +5 -0
- package/dist/evals/engine/promptfoo/errors.js +8 -0
- package/dist/evals/engine/promptfoo/generate.d.ts +30 -0
- package/dist/evals/engine/promptfoo/generate.js +345 -0
- package/dist/evals/engine/promptfoo/guard.d.ts +10 -0
- package/dist/evals/engine/promptfoo/guard.js +116 -0
- package/dist/evals/engine/promptfoo/install.d.ts +17 -0
- package/dist/evals/engine/promptfoo/install.js +73 -0
- package/dist/evals/engine/promptfoo/judgeProviders.d.ts +2 -0
- package/dist/evals/engine/promptfoo/judgeProviders.js +9 -0
- package/dist/evals/engine/promptfoo/judgeServices.d.ts +6 -0
- package/dist/evals/engine/promptfoo/judgeServices.js +41 -0
- package/dist/evals/engine/promptfoo/locate.d.ts +21 -0
- package/dist/evals/engine/promptfoo/locate.js +68 -0
- package/dist/evals/engine/promptfoo/nodeVersion.d.ts +7 -0
- package/dist/evals/engine/promptfoo/nodeVersion.js +14 -0
- package/dist/evals/engine/promptfoo/normalize.d.ts +66 -0
- package/dist/evals/engine/promptfoo/normalize.js +261 -0
- package/dist/evals/engine/promptfoo/pinned.d.ts +5 -0
- package/dist/evals/engine/promptfoo/pinned.js +5 -0
- package/dist/evals/engine/promptfoo/rubricPrompt.d.ts +14 -0
- package/dist/evals/engine/promptfoo/rubricPrompt.js +105 -0
- package/dist/evals/engine/promptfoo/runTokens.d.ts +18 -0
- package/dist/evals/engine/promptfoo/runTokens.js +31 -0
- package/dist/evals/engine/promptfoo/status.d.ts +13 -0
- package/dist/evals/engine/promptfoo/status.js +16 -0
- package/dist/evals/estimate.d.ts +56 -0
- package/dist/evals/estimate.js +66 -0
- package/dist/evals/graders/codeGrader.d.ts +6 -0
- package/dist/evals/graders/codeGrader.js +85 -0
- package/dist/evals/graders/conversationCheckGrader.d.ts +6 -0
- package/dist/evals/graders/conversationCheckGrader.js +62 -0
- package/dist/evals/graders/fieldGrader.d.ts +11 -0
- package/dist/evals/graders/fieldGrader.js +117 -0
- package/dist/evals/graders/goal.d.ts +3 -0
- package/dist/evals/graders/goal.js +14 -0
- package/dist/evals/graders/index.d.ts +18 -0
- package/dist/evals/graders/index.js +34 -0
- package/dist/evals/graders/notApplicable.d.ts +5 -0
- package/dist/evals/graders/notApplicable.js +9 -0
- package/dist/evals/graders/path.d.ts +26 -0
- package/dist/evals/graders/path.js +75 -0
- package/dist/evals/graders/referenceGrader.d.ts +5 -0
- package/dist/evals/graders/referenceGrader.js +59 -0
- package/dist/evals/graders/schemaGrader.d.ts +5 -0
- package/dist/evals/graders/schemaGrader.js +29 -0
- package/dist/evals/graders/subject.d.ts +6 -0
- package/dist/evals/graders/subject.js +33 -0
- package/dist/evals/graders/toolCallsGrader.d.ts +6 -0
- package/dist/evals/graders/toolCallsGrader.js +100 -0
- package/dist/evals/graders/transcript.d.ts +12 -0
- package/dist/evals/graders/transcript.js +57 -0
- package/dist/evals/graders/types.d.ts +20 -0
- package/dist/evals/graders/types.js +1 -0
- package/dist/evals/judgeProviders.d.ts +16 -0
- package/dist/evals/judgeProviders.js +27 -0
- package/dist/evals/lineDiff.d.ts +5 -0
- package/dist/evals/lineDiff.js +34 -0
- package/dist/evals/listStatus.d.ts +31 -0
- package/dist/evals/listStatus.js +48 -0
- package/dist/evals/manager.d.ts +187 -0
- package/dist/evals/manager.js +795 -0
- package/dist/evals/plan.d.ts +65 -0
- package/dist/evals/plan.js +621 -0
- package/dist/evals/planInternalAgent.d.ts +19 -0
- package/dist/evals/planInternalAgent.js +205 -0
- package/dist/evals/providerKeys.d.ts +1 -0
- package/dist/evals/providerKeys.js +21 -0
- package/dist/evals/read/agentTargets.d.ts +37 -0
- package/dist/evals/read/agentTargets.js +101 -0
- package/dist/evals/read/api.d.ts +208 -0
- package/dist/evals/read/api.js +363 -0
- package/dist/evals/read/compare.d.ts +4 -0
- package/dist/evals/read/compare.js +39 -0
- package/dist/evals/read/datasets.d.ts +105 -0
- package/dist/evals/read/datasets.js +318 -0
- package/dist/evals/read/list.d.ts +66 -0
- package/dist/evals/read/list.js +182 -0
- package/dist/evals/read/results.d.ts +46 -0
- package/dist/evals/read/results.js +107 -0
- package/dist/evals/read/runs.d.ts +154 -0
- package/dist/evals/read/runs.js +295 -0
- package/dist/evals/read/suggestions.d.ts +43 -0
- package/dist/evals/read/suggestions.js +73 -0
- package/dist/evals/runner/FakeAgentBackend.d.ts +40 -0
- package/dist/evals/runner/FakeAgentBackend.js +82 -0
- package/dist/evals/runner/agentCaseRunner.d.ts +24 -0
- package/dist/evals/runner/agentCaseRunner.js +388 -0
- package/dist/evals/runner/caseRunner.d.ts +8 -0
- package/dist/evals/runner/caseRunner.js +28 -0
- package/dist/evals/runner/conversationSubject.d.ts +18 -0
- package/dist/evals/runner/conversationSubject.js +123 -0
- package/dist/evals/runner/internalAgentCaseRunner.d.ts +6 -0
- package/dist/evals/runner/internalAgentCaseRunner.js +250 -0
- package/dist/evals/runner/simulatorModel.d.ts +51 -0
- package/dist/evals/runner/simulatorModel.js +58 -0
- package/dist/evals/runner/simulatorPrompt.d.ts +29 -0
- package/dist/evals/runner/simulatorPrompt.js +59 -0
- package/dist/evals/runner/stageCaseRunner.d.ts +30 -0
- package/dist/evals/runner/stageCaseRunner.js +279 -0
- package/dist/evals/runner/userDriver.d.ts +71 -0
- package/dist/evals/runner/userDriver.js +104 -0
- package/dist/evals/scoring.d.ts +34 -0
- package/dist/evals/scoring.js +67 -0
- package/dist/evals/snapshot.d.ts +191 -0
- package/dist/evals/snapshot.js +70 -0
- package/dist/evals/stageDiff.d.ts +8 -0
- package/dist/evals/stageDiff.js +48 -0
- package/dist/evals/stats.d.ts +95 -0
- package/dist/evals/stats.js +220 -0
- package/dist/evals/statsAdapter.d.ts +4 -0
- package/dist/evals/statsAdapter.js +30 -0
- package/dist/evals/statsTypes.d.ts +51 -0
- package/dist/evals/statsTypes.js +18 -0
- package/dist/evals/storeError.d.ts +5 -0
- package/dist/evals/storeError.js +8 -0
- package/dist/evals/storeTypes.d.ts +207 -0
- package/dist/evals/storeTypes.js +1 -0
- package/dist/evals/tTable.d.ts +3 -0
- package/dist/evals/tTable.js +15 -0
- package/dist/evals/triage/constants.d.ts +26 -0
- package/dist/evals/triage/constants.js +33 -0
- package/dist/evals/triage/credentials.d.ts +13 -0
- package/dist/evals/triage/credentials.js +20 -0
- package/dist/evals/triage/jevClassifier.d.ts +14 -0
- package/dist/evals/triage/jevClassifier.js +124 -0
- package/dist/evals/triage/judgeClassifier.d.ts +10 -0
- package/dist/evals/triage/judgeClassifier.js +76 -0
- package/dist/evals/triage/prompts.d.ts +16 -0
- package/dist/evals/triage/prompts.js +64 -0
- package/dist/evals/triage/service.d.ts +79 -0
- package/dist/evals/triage/service.js +217 -0
- package/dist/evals/triage/stateBuilder.d.ts +19 -0
- package/dist/evals/triage/stateBuilder.js +125 -0
- package/dist/evals/triage/types.d.ts +60 -0
- package/dist/evals/triage/types.js +8 -0
- package/dist/evals/types.d.ts +357 -0
- package/dist/evals/types.js +4 -0
- package/dist/guide/cardContract.d.ts +133 -0
- package/dist/guide/cardContract.js +156 -0
- package/dist/guide/chat.d.ts +45 -0
- package/dist/guide/chat.js +378 -0
- package/dist/guide/knowledge/index.d.ts +14 -0
- package/dist/guide/knowledge/index.js +109 -0
- package/dist/guide/knowledge/topics/agents.d.ts +2 -0
- package/dist/guide/knowledge/topics/agents.js +58 -0
- package/dist/guide/knowledge/topics/bestPractices.d.ts +2 -0
- package/dist/guide/knowledge/topics/bestPractices.js +67 -0
- package/dist/guide/knowledge/topics/connections.d.ts +2 -0
- package/dist/guide/knowledge/topics/connections.js +66 -0
- package/dist/guide/knowledge/topics/consoleMap.d.ts +2 -0
- package/dist/guide/knowledge/topics/consoleMap.js +55 -0
- package/dist/guide/knowledge/topics/evals.d.ts +2 -0
- package/dist/guide/knowledge/topics/evals.js +72 -0
- package/dist/guide/knowledge/topics/limitations.d.ts +2 -0
- package/dist/guide/knowledge/topics/limitations.js +84 -0
- package/dist/guide/knowledge/topics/mcpSkillsBrowser.d.ts +2 -0
- package/dist/guide/knowledge/topics/mcpSkillsBrowser.js +57 -0
- package/dist/guide/knowledge/topics/memories.d.ts +2 -0
- package/dist/guide/knowledge/topics/memories.js +63 -0
- package/dist/guide/knowledge/topics/modelsAndProviders.d.ts +2 -0
- package/dist/guide/knowledge/topics/modelsAndProviders.js +56 -0
- package/dist/guide/knowledge/topics/overview.d.ts +2 -0
- package/dist/guide/knowledge/topics/overview.js +56 -0
- package/dist/guide/knowledge/topics/pipelines.d.ts +2 -0
- package/dist/guide/knowledge/topics/pipelines.js +93 -0
- package/dist/guide/knowledge/topics/stages.d.ts +2 -0
- package/dist/guide/knowledge/topics/stages.js +54 -0
- package/dist/guide/knowledge/topics/tasks.d.ts +2 -0
- package/dist/guide/knowledge/topics/tasks.js +52 -0
- package/dist/guide/knowledge/topics/triggers.d.ts +2 -0
- package/dist/guide/knowledge/topics/triggers.js +68 -0
- package/dist/guide/knowledge/topics/troubleshooting.d.ts +2 -0
- package/dist/guide/knowledge/topics/troubleshooting.js +85 -0
- package/dist/guide/knowledgeTools.d.ts +2 -0
- package/dist/guide/knowledgeTools.js +56 -0
- package/dist/guide/showUi.d.ts +6 -0
- package/dist/guide/showUi.js +546 -0
- package/dist/guide/threadStore.d.ts +48 -0
- package/dist/guide/threadStore.js +189 -0
- package/dist/guide/writeRoot.d.ts +11 -0
- package/dist/guide/writeRoot.js +70 -0
- package/dist/hosted/translate.js +2 -0
- package/dist/mcp/agentTools.js +12 -0
- package/dist/mcp/catalogTools.js +18 -20
- package/dist/mcp/catalogWriteTools.d.ts +8 -0
- package/dist/mcp/catalogWriteTools.js +225 -0
- package/dist/mcp/connectionTools.d.ts +3 -0
- package/dist/mcp/connectionTools.js +85 -0
- package/dist/mcp/controlTools.js +34 -1
- package/dist/mcp/deps.d.ts +16 -0
- package/dist/mcp/evalTools.d.ts +3 -0
- package/dist/mcp/evalTools.js +943 -0
- package/dist/mcp/memoryHostTools.d.ts +3 -0
- package/dist/mcp/memoryHostTools.js +72 -0
- package/dist/mcp/pipelineAuthorTools.js +14 -1
- package/dist/mcp/server.js +6 -0
- package/dist/mcp/tools.js +8 -0
- package/dist/mcp/triggerTools.js +77 -31
- package/dist/models/response.d.ts +7 -2
- package/dist/models/response.js +6 -1
- package/dist/operatorAgent/agentAuthorContext.d.ts +1 -1
- package/dist/operatorAgent/agentAuthorContext.js +1 -1
- package/dist/operatorAgent/evalGate.d.ts +22 -0
- package/dist/operatorAgent/evalGate.js +77 -0
- package/dist/operatorAgent/fakeHost.js +10 -2
- package/dist/operatorAgent/host.js +18 -2
- package/dist/operatorAgent/index.d.ts +1 -0
- package/dist/operatorAgent/index.js +1 -0
- package/dist/operatorAgent/internalAgents.d.ts +11 -0
- package/dist/operatorAgent/internalAgents.js +13 -0
- package/dist/operatorAgent/piModel.d.ts +5 -1
- package/dist/operatorAgent/piModel.js +32 -14
- package/dist/operatorAgent/profiles/agentAuthor.d.ts +3 -1
- package/dist/operatorAgent/profiles/agentAuthor.js +201 -32
- package/dist/operatorAgent/profiles/agentAuthorPlaybook.d.ts +1 -1
- package/dist/operatorAgent/profiles/agentAuthorPlaybook.js +48 -15
- package/dist/operatorAgent/profiles/authorReadable.d.ts +2 -0
- package/dist/operatorAgent/profiles/authorReadable.js +26 -0
- package/dist/operatorAgent/profiles/guideConfirm.d.ts +21 -0
- package/dist/operatorAgent/profiles/guideConfirm.js +100 -0
- package/dist/operatorAgent/profiles/guideTools.d.ts +7 -0
- package/dist/operatorAgent/profiles/guideTools.js +123 -0
- package/dist/operatorAgent/profiles/stageflowGuide.d.ts +7 -0
- package/dist/operatorAgent/profiles/stageflowGuide.js +132 -0
- package/dist/operatorAgent/profiles/workshopAuthor.js +23 -0
- package/dist/operatorAgent/profiles/workshopAuthorPlaybook.d.ts +1 -1
- package/dist/operatorAgent/profiles/workshopAuthorPlaybook.js +9 -1
- package/dist/operatorAgent/profiles/workshopAuthorTools.d.ts +2 -0
- package/dist/operatorAgent/profiles/workshopAuthorTools.js +197 -9
- package/dist/operatorAgent/types.d.ts +23 -0
- package/dist/package-meta.d.ts +1 -1
- package/dist/package-meta.js +1 -1
- package/dist/runstore/port.d.ts +43 -0
- package/dist/runstore/retention.d.ts +2 -1
- package/dist/runstore/retention.js +3 -7
- package/dist/runstore/runStatusClock.d.ts +17 -0
- package/dist/runstore/runStatusClock.js +19 -0
- package/dist/runstore/sqlite/SqliteRunStore.d.ts +29 -0
- package/dist/runstore/sqlite/SqliteRunStore.js +144 -50
- package/dist/runstore/sqlite/evalStore.d.ts +20 -0
- package/dist/runstore/sqlite/evalStore.js +541 -0
- package/dist/runstore/sqlite/migrations/015-evals.d.ts +12 -0
- package/dist/runstore/sqlite/migrations/015-evals.js +157 -0
- package/dist/runstore/sqlite/migrations/016-eval-subject-ref.d.ts +12 -0
- package/dist/runstore/sqlite/migrations/016-eval-subject-ref.js +20 -0
- package/dist/runstore/sqlite/migrations/017-eval-result-suggestions.d.ts +11 -0
- package/dist/runstore/sqlite/migrations/017-eval-result-suggestions.js +36 -0
- package/dist/runstore/sqlite/migrations/index.js +6 -0
- package/dist/runstore/sqlite/suggestionStore.d.ts +14 -0
- package/dist/runstore/sqlite/suggestionStore.js +132 -0
- package/dist/runstore/workspaceLayout.js +6 -1
- package/dist/runtime/artifactDiskInspect.d.ts +14 -0
- package/dist/runtime/artifactDiskInspect.js +52 -0
- package/dist/runtime/artifactPath.d.ts +24 -0
- package/dist/runtime/artifactPath.js +84 -0
- package/dist/runtime/completionCheckRunner.js +15 -43
- package/dist/runtime/githubPollSource.d.ts +22 -4
- package/dist/runtime/githubPollSource.js +93 -8
- package/dist/runtime/pipelineRunner.d.ts +2 -1
- package/dist/runtime/pipelineRunner.js +2 -0
- package/dist/runtime/priorArtifactGrants.d.ts +8 -0
- package/dist/runtime/priorArtifactGrants.js +105 -0
- package/dist/runtime/runActionEligibility.d.ts +46 -0
- package/dist/runtime/runActionEligibility.js +123 -0
- package/dist/runtime/runManager.d.ts +6 -2
- package/dist/runtime/runManager.js +60 -16
- package/dist/runtime/runRetentionSweep.js +2 -2
- package/dist/runtime/runRetryCoordinator.d.ts +2 -14
- package/dist/runtime/runRetryCoordinator.js +3 -67
- package/dist/runtime/sandboxContainer.d.ts +7 -0
- package/dist/runtime/sandboxContainer.js +48 -6
- package/dist/runtime/sandboxDesk.d.ts +2 -1
- package/dist/runtime/sandboxDesk.js +11 -12
- package/dist/runtime/stageEnvironment.js +1 -0
- package/dist/runtime/stageRoots.d.ts +12 -0
- package/dist/runtime/stageSandbox.d.ts +2 -1
- package/dist/runtime/stageSandbox.js +18 -2
- package/dist/runtime/stageWorker.js +20 -0
- package/dist/server/agentAuthorRoutes.js +59 -1
- package/dist/server/bootstrap.d.ts +13 -0
- package/dist/server/bootstrap.js +69 -0
- package/dist/server/controlToken.js +3 -0
- package/dist/server/evalInternalRoutes.d.ts +14 -0
- package/dist/server/evalInternalRoutes.js +87 -0
- package/dist/server/evalRouteContext.d.ts +46 -0
- package/dist/server/evalRouteContext.js +43 -0
- package/dist/server/evalRoutes.d.ts +5 -0
- package/dist/server/evalRoutes.js +1456 -0
- package/dist/server/evalTriageRoutes.d.ts +2 -0
- package/dist/server/evalTriageRoutes.js +95 -0
- package/dist/server/guideRoutes.d.ts +5 -0
- package/dist/server/guideRoutes.js +166 -0
- package/dist/server/http.d.ts +15 -0
- package/dist/server/http.js +67 -3
- package/dist/server/internalAgentRoutes.d.ts +6 -0
- package/dist/server/internalAgentRoutes.js +12 -0
- package/dist/server/mcpHost.js +5 -0
- package/dist/toolkit/meta.d.ts +1 -1
- package/dist/toolkit/meta.js +53 -0
- package/dist/toolkit/profiles.d.ts +5 -0
- package/dist/toolkit/profiles.js +13 -1
- package/dist/tools/askOperator.js +2 -1
- package/dist/tools/emitStageEnvelope.d.ts +17 -16
- package/dist/tools/emitStageEnvelope.js +46 -32
- package/dist/tools/stageToolNames.d.ts +4 -0
- package/dist/tools/stageToolNames.js +4 -0
- package/dist/tools/workingState.d.ts +40 -0
- package/dist/tools/workingState.js +108 -0
- package/dist/tools/writeStageArtifact.d.ts +0 -9
- package/dist/tools/writeStageArtifact.js +2 -1
- package/dist/types/stageflowManifest.d.ts +6 -0
- package/dist/ui/assets/{MarkdownText-D7tYaIFO.js → MarkdownText-S5C_vemc.js} +2 -2
- package/dist/ui/assets/adapters-C0l4ruiR.js +17 -0
- package/dist/ui/assets/chat-CjnsmvqR.js +2 -0
- package/dist/ui/assets/chat-DFDd4UjS.css +2 -0
- package/dist/ui/assets/{main-BFo79krC.css → main-Del1GeLf.css} +1 -1
- package/dist/ui/assets/main-_yXVqcW9.js +277 -0
- package/dist/ui/chat.html +3 -4
- package/dist/ui/index.html +3 -4
- package/dist/workshop/chatTurn.js +1 -1
- package/dist/workshop/workshopPin.d.ts +3 -3
- package/dist/workshop/workshopPin.js +16 -15
- package/examples/README.md +2 -0
- package/examples/compaction-stress/README.md +30 -0
- package/examples/compaction-stress/check-run.mjs +53 -0
- package/examples/compaction-stress/collect-evidence.yaml +60 -0
- package/examples/compaction-stress/compaction-stress.pipeline.yaml +141 -0
- package/examples/compaction-stress/compaction-stress.task.yaml +15 -0
- package/examples/compaction-stress/generate-evidence.mjs +110 -0
- package/examples/compaction-stress/root-cause.yaml +26 -0
- package/examples/compaction-stress/stageflow.yaml +9 -0
- package/examples/compaction-stress/write-postmortem.yaml +40 -0
- package/examples/document-policy-review/README.md +35 -0
- package/examples/document-policy-review/agents/compliance.agent.yaml +42 -0
- package/examples/document-policy-review/documents/acme-vendor-sow.md +15 -0
- package/examples/document-policy-review/documents/support-runbook.md +13 -0
- package/examples/document-policy-review/policies/acceptable-use.md +13 -0
- package/examples/document-policy-review/policies/data-handling.md +17 -0
- package/examples/document-policy-review/policies/vendor-security.md +17 -0
- package/examples/evals/README.md +141 -0
- package/examples/evals/critique-sample.dataset.jsonl +8 -0
- package/examples/evals/critique-sample.eval.yaml +34 -0
- package/examples/evals/critique-sample.task.yaml +4 -0
- package/examples/evals/eval-sample.pipeline.yaml +35 -0
- package/examples/evals/guide-behavior.dataset.jsonl +15 -0
- package/examples/evals/guide-behavior.eval.yaml +35 -0
- package/examples/evals/guide-depth.dataset.jsonl +35 -0
- package/examples/evals/guide-depth.eval.yaml +169 -0
- package/examples/evals/support-sample.agent.yaml +20 -0
- package/examples/evals/support-sample.dataset.jsonl +6 -0
- package/examples/evals/support-sample.eval.yaml +38 -0
- package/examples/memory/evals/guide-behavior.dataset.jsonl +15 -0
- package/examples/memory/evals/guide-behavior.eval.yaml +35 -0
- package/examples/memory/evals/guide-depth.dataset.jsonl +35 -0
- package/examples/memory/evals/guide-depth.eval.yaml +169 -0
- package/examples/stageflow.yaml +6 -0
- package/package.json +1 -1
- package/skills/stageflow/SKILL.md +5 -2
- package/skills/stageflow/references/control-surface.md +4 -2
- package/skills/stageflow/references/evals.md +68 -0
- package/skills/stageflow-author/SKILL.md +4 -0
- package/skills/stageflow-run/SKILL.md +4 -0
- package/dist/ui/assets/AssistantRuntimeProvider-CsiPFhCT.js +0 -9
- package/dist/ui/assets/ReadonlyStore-BfXqHykm.js +0 -6
- package/dist/ui/assets/chat-BbLukq9W.js +0 -5
- package/dist/ui/assets/chat-zIZU_bP1.css +0 -2
- package/dist/ui/assets/main-CijYMeM0.js +0 -259
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { EvalApiError } from "../evals/read/api.js";
|
|
2
|
+
import { SUGGESTION_STATUSES, TRIAGE_BUCKETS, TRIAGE_MAX_LIMIT } from "../evals/triage/constants.js";
|
|
3
|
+
import { isTriageBucket, TriageService } from "../evals/triage/service.js";
|
|
4
|
+
import { audit, bad, optStringArray, readOptionalBody, runByIdOr404 } from "./evalRouteContext.js";
|
|
5
|
+
function triageOf(c) {
|
|
6
|
+
return new TriageService({ store: c.store, ...(c.triage ?? {}), loadPrices: c.triage?.loadPrices ?? c.loadPrices });
|
|
7
|
+
}
|
|
8
|
+
async function handleSort(c, id) {
|
|
9
|
+
const body = await readOptionalBody(c);
|
|
10
|
+
const row = await runByIdOr404(c, id);
|
|
11
|
+
const classifier = body.classifier ?? "auto";
|
|
12
|
+
if (classifier !== "auto" && classifier !== "jev" && classifier !== "judge") {
|
|
13
|
+
throw bad(`"classifier" must be auto, jev or judge`);
|
|
14
|
+
}
|
|
15
|
+
if (body.only_unsorted !== undefined && typeof body.only_unsorted !== "boolean")
|
|
16
|
+
throw bad(`"only_unsorted" must be a boolean`);
|
|
17
|
+
if (body.limit !== undefined &&
|
|
18
|
+
(typeof body.limit !== "number" || !Number.isInteger(body.limit) || body.limit < 1 || body.limit > TRIAGE_MAX_LIMIT)) {
|
|
19
|
+
throw bad(`"limit" must be an integer from 1 to ${TRIAGE_MAX_LIMIT}`);
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const result = await triageOf(c).sort(row, {
|
|
23
|
+
classifier: classifier,
|
|
24
|
+
...(body.only_unsorted !== undefined ? { onlyUnsorted: body.only_unsorted } : {}),
|
|
25
|
+
...(body.limit !== undefined ? { limit: body.limit } : {}),
|
|
26
|
+
});
|
|
27
|
+
audit(c, "eval_failures_sort", "ok", id);
|
|
28
|
+
c.json(c.res, 200, result);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
audit(c, "eval_failures_sort", "error", id, err instanceof EvalApiError ? err.code : "internal_error");
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function handleSuggestionsList(c, id) {
|
|
36
|
+
const row = await runByIdOr404(c, id);
|
|
37
|
+
const status = c.url.searchParams.get("status") ?? undefined;
|
|
38
|
+
if (status !== undefined && !SUGGESTION_STATUSES.includes(status)) {
|
|
39
|
+
throw bad(`"status" must be one of ${SUGGESTION_STATUSES.join(", ")}`);
|
|
40
|
+
}
|
|
41
|
+
c.json(c.res, 200, await triageOf(c).list(row, status));
|
|
42
|
+
}
|
|
43
|
+
function idsOf(body, required) {
|
|
44
|
+
const ids = optStringArray(body, "ids");
|
|
45
|
+
if (ids === undefined && required)
|
|
46
|
+
throw bad(`"ids" is required`);
|
|
47
|
+
return ids;
|
|
48
|
+
}
|
|
49
|
+
async function handleSuggestionsAccept(c, id) {
|
|
50
|
+
const body = await readOptionalBody(c);
|
|
51
|
+
const row = await runByIdOr404(c, id);
|
|
52
|
+
const ids = idsOf(body, false);
|
|
53
|
+
if (body.min_confidence !== undefined && (typeof body.min_confidence !== "number" || body.min_confidence < 0 || body.min_confidence > 1)) {
|
|
54
|
+
throw bad(`"min_confidence" must be a number from 0 to 1`);
|
|
55
|
+
}
|
|
56
|
+
if (body.bucket !== undefined && !isTriageBucket(body.bucket))
|
|
57
|
+
throw bad(`"bucket" must be one of ${TRIAGE_BUCKETS.join(", ")}`);
|
|
58
|
+
const result = await triageOf(c).accept(row, {
|
|
59
|
+
...(ids !== undefined ? { ids } : {}),
|
|
60
|
+
...(typeof body.min_confidence === "number" ? { minConfidence: body.min_confidence } : {}),
|
|
61
|
+
...(isTriageBucket(body.bucket) ? { bucket: body.bucket } : {}),
|
|
62
|
+
});
|
|
63
|
+
audit(c, "eval_suggestions_accept", "ok", id);
|
|
64
|
+
c.json(c.res, 200, result);
|
|
65
|
+
}
|
|
66
|
+
async function handleSuggestionsDismiss(c, id) {
|
|
67
|
+
const body = await readOptionalBody(c);
|
|
68
|
+
const row = await runByIdOr404(c, id);
|
|
69
|
+
const result = await triageOf(c).dismiss(row, idsOf(body, true));
|
|
70
|
+
audit(c, "eval_suggestions_dismiss", "ok", id);
|
|
71
|
+
c.json(c.res, 200, result);
|
|
72
|
+
}
|
|
73
|
+
async function handleSortStatus(c, id) {
|
|
74
|
+
c.json(c.res, 200, await triageOf(c).status(await runByIdOr404(c, id)));
|
|
75
|
+
}
|
|
76
|
+
export function matchEvalTriageRoute(c, seg) {
|
|
77
|
+
const { method, pathname } = c;
|
|
78
|
+
const m = (re) => pathname.match(re);
|
|
79
|
+
let match = m(/^\/api\/eval-runs\/([^/]+)\/failures\/sort$/);
|
|
80
|
+
if (method === "POST" && match)
|
|
81
|
+
return () => handleSort(c, seg(match[1]));
|
|
82
|
+
match = m(/^\/api\/eval-runs\/([^/]+)\/failures\/suggestions$/);
|
|
83
|
+
if (method === "GET" && match)
|
|
84
|
+
return () => handleSuggestionsList(c, seg(match[1]));
|
|
85
|
+
match = m(/^\/api\/eval-runs\/([^/]+)\/failures\/suggestions\/accept$/);
|
|
86
|
+
if (method === "POST" && match)
|
|
87
|
+
return () => handleSuggestionsAccept(c, seg(match[1]));
|
|
88
|
+
match = m(/^\/api\/eval-runs\/([^/]+)\/failures\/suggestions\/dismiss$/);
|
|
89
|
+
if (method === "POST" && match)
|
|
90
|
+
return () => handleSuggestionsDismiss(c, seg(match[1]));
|
|
91
|
+
match = m(/^\/api\/eval-runs\/([^/]+)\/failures\/status$/);
|
|
92
|
+
if (method === "GET" && match)
|
|
93
|
+
return () => handleSortStatus(c, seg(match[1]));
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import type { OperatorAgentHost } from "../operatorAgent/index.js";
|
|
3
|
+
type Json = (res: ServerResponse, status: number, body: unknown) => void;
|
|
4
|
+
export declare function handleGuideRoutes(req: IncomingMessage, method: string, pathname: string, host: OperatorAgentHost, res: ServerResponse, json: Json): Promise<boolean>;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { abortGuideTurn, GuideError, guideAgentInfo, isGuideThreadRunning, streamGuideTurn, } from "../guide/chat.js";
|
|
2
|
+
import { createGuideThread, listGuideThreads, readGuideThread, setGuideThreadModel, } from "../guide/threadStore.js";
|
|
3
|
+
async function readBody(req) {
|
|
4
|
+
const chunks = [];
|
|
5
|
+
let size = 0;
|
|
6
|
+
for await (const chunk of req) {
|
|
7
|
+
const buffer = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
|
|
8
|
+
size += buffer.length;
|
|
9
|
+
if (size > 1_500_000)
|
|
10
|
+
return { __tooLarge: true };
|
|
11
|
+
chunks.push(buffer);
|
|
12
|
+
}
|
|
13
|
+
if (chunks.length === 0)
|
|
14
|
+
return {};
|
|
15
|
+
try {
|
|
16
|
+
const parsed = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
17
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)
|
|
18
|
+
? parsed
|
|
19
|
+
: { __invalid: true };
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return { __invalid: true };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function threadSummary(record) {
|
|
26
|
+
return { id: record.id, title: record.title, updatedAt: record.updatedAt };
|
|
27
|
+
}
|
|
28
|
+
function canWrite(res) {
|
|
29
|
+
return !res.writableEnded && !res.destroyed;
|
|
30
|
+
}
|
|
31
|
+
export async function handleGuideRoutes(req, method, pathname, host, res, json) {
|
|
32
|
+
const root = pathname === "/api/guide";
|
|
33
|
+
const threads = pathname === "/api/guide/threads";
|
|
34
|
+
const threadMatch = /^\/api\/guide\/threads\/([^/]+)$/.exec(pathname);
|
|
35
|
+
const messageMatch = /^\/api\/guide\/threads\/([^/]+)\/messages$/.exec(pathname);
|
|
36
|
+
const stopMatch = /^\/api\/guide\/threads\/([^/]+)\/stop$/.exec(pathname);
|
|
37
|
+
if (!root && !threads && !threadMatch && !messageMatch && !stopMatch)
|
|
38
|
+
return false;
|
|
39
|
+
if (root && method === "GET") {
|
|
40
|
+
json(res, 200, { agent: guideAgentInfo(host) });
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
if (threads && method === "GET") {
|
|
44
|
+
json(res, 200, {
|
|
45
|
+
threads: listGuideThreads().map((thread) => ({
|
|
46
|
+
...thread,
|
|
47
|
+
status: isGuideThreadRunning(thread.id) ? "running" : "open",
|
|
48
|
+
})),
|
|
49
|
+
});
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
if (threads && method === "POST") {
|
|
53
|
+
const record = createGuideThread();
|
|
54
|
+
json(res, 201, { thread: threadSummary(record) });
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
if (stopMatch && method === "POST") {
|
|
58
|
+
const threadId = decodeURIComponent(stopMatch[1] ?? "");
|
|
59
|
+
const record = readGuideThread(threadId);
|
|
60
|
+
if (!record) {
|
|
61
|
+
json(res, 404, { code: "guide.not_found", message: "" });
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
json(res, 200, { ok: true, stopped: abortGuideTurn(threadId) });
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
if (threadMatch && method === "GET") {
|
|
68
|
+
const threadId = decodeURIComponent(threadMatch[1] ?? "");
|
|
69
|
+
const record = readGuideThread(threadId);
|
|
70
|
+
if (!record) {
|
|
71
|
+
json(res, 404, { code: "guide.not_found", message: "" });
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
json(res, 200, {
|
|
75
|
+
thread: threadSummary(record),
|
|
76
|
+
status: isGuideThreadRunning(record.id) ? "running" : "open",
|
|
77
|
+
messages: record.messages,
|
|
78
|
+
model: record.model ?? null,
|
|
79
|
+
});
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
if (threadMatch && method === "PATCH") {
|
|
83
|
+
const threadId = decodeURIComponent(threadMatch[1] ?? "");
|
|
84
|
+
const body = await readBody(req);
|
|
85
|
+
if (body.__tooLarge || body.__invalid) {
|
|
86
|
+
json(res, 400, { code: "guide.invalid", message: "" });
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
let record = readGuideThread(threadId);
|
|
90
|
+
if (!record) {
|
|
91
|
+
json(res, 404, { code: "guide.not_found", message: "" });
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
if ("model" in body) {
|
|
95
|
+
if (typeof body.model === "string") {
|
|
96
|
+
const next = setGuideThreadModel(threadId, body.model.trim() || null);
|
|
97
|
+
if (!next) {
|
|
98
|
+
json(res, 404, { code: "guide.not_found", message: "" });
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
record = next;
|
|
102
|
+
}
|
|
103
|
+
else if (body.model === null) {
|
|
104
|
+
const next = setGuideThreadModel(threadId, null);
|
|
105
|
+
if (!next) {
|
|
106
|
+
json(res, 404, { code: "guide.not_found", message: "" });
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
record = next;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
json(res, 400, { code: "guide.invalid", message: "" });
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
json(res, 200, { thread: threadSummary(record), model: record.model ?? null });
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
if (messageMatch && method === "POST") {
|
|
120
|
+
const threadId = decodeURIComponent(messageMatch[1] ?? "");
|
|
121
|
+
const body = await readBody(req);
|
|
122
|
+
if (body.__tooLarge || body.__invalid) {
|
|
123
|
+
json(res, 400, { code: "guide.invalid", message: "" });
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
const text = typeof body.text === "string" ? body.text : "";
|
|
127
|
+
let started = false;
|
|
128
|
+
try {
|
|
129
|
+
for await (const frame of streamGuideTurn({
|
|
130
|
+
host,
|
|
131
|
+
threadId,
|
|
132
|
+
text,
|
|
133
|
+
attachments: body.attachments,
|
|
134
|
+
model: typeof body.model === "string" ? body.model : undefined,
|
|
135
|
+
})) {
|
|
136
|
+
if (!canWrite(res))
|
|
137
|
+
continue;
|
|
138
|
+
if (!started) {
|
|
139
|
+
started = true;
|
|
140
|
+
res.writeHead(200, {
|
|
141
|
+
"Content-Type": "application/x-ndjson; charset=utf-8",
|
|
142
|
+
"Cache-Control": "no-store",
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
res.write(`${JSON.stringify(frame)}\n`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
const code = err instanceof GuideError ? err.code : "guide.failed";
|
|
150
|
+
const status = err instanceof GuideError ? err.status : 500;
|
|
151
|
+
if (!started && canWrite(res))
|
|
152
|
+
json(res, status, { code, message: "" });
|
|
153
|
+
else if (started && canWrite(res))
|
|
154
|
+
res.write(`${JSON.stringify({ type: "error", code, message: "" })}\n`);
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
if (!res.headersSent && canWrite(res))
|
|
158
|
+
json(res, 200, { code: "guide.failed", message: "" });
|
|
159
|
+
else if (canWrite(res))
|
|
160
|
+
res.end();
|
|
161
|
+
}
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
json(res, 405, { code: "guide.invalid", message: "" });
|
|
165
|
+
return true;
|
|
166
|
+
}
|
package/dist/server/http.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { StagePort } from "../agent/port.js";
|
|
2
2
|
import { type ProviderAuthContext } from "../agent/providerAuth.js";
|
|
3
|
+
import type { ChannelService } from "../channels/service.js";
|
|
4
|
+
import type { EvalRunManager } from "../evals/manager.js";
|
|
5
|
+
import type { MemoryHost } from "../memory/host.js";
|
|
3
6
|
import { type LiveViewRoutesOptions } from "./liveViewRoutes.js";
|
|
4
7
|
import { WorkshopChatSessionRegistry } from "../workshop/chatTurn.js";
|
|
5
8
|
import { type AgentPort } from "../operatorAgent/index.js";
|
|
@@ -10,6 +13,7 @@ import type { RunChangeBus } from "../runtime/runChangeBus.js";
|
|
|
10
13
|
import type { StageBrowserSupport } from "../browser/browserHost.js";
|
|
11
14
|
import { type AgentHostContext } from "../agents/hostContext.js";
|
|
12
15
|
import type { ConversationBackend } from "../agents/sessions.js";
|
|
16
|
+
import { type EvalServices } from "./evalInternalRoutes.js";
|
|
13
17
|
import { EmailTriggers } from "../email/triggers.js";
|
|
14
18
|
import { type AllowedHosts } from "./allowedHosts.js";
|
|
15
19
|
import { type ControlTokens } from "./controlToken.js";
|
|
@@ -68,6 +72,17 @@ export type OperatorRouteDeps = {
|
|
|
68
72
|
agentConversationBackend?: ConversationBackend;
|
|
69
73
|
/** Shared with MCP when set by bootstrap. */
|
|
70
74
|
agentHost?: AgentHostContext;
|
|
75
|
+
/** Bootstrap fills this once the operator host exists, so evals can run against it. */
|
|
76
|
+
operatorHostSlot?: {
|
|
77
|
+
current?: import("../operatorAgent/types.js").OperatorAgentHost;
|
|
78
|
+
};
|
|
79
|
+
evalRunManager?: EvalRunManager;
|
|
80
|
+
/** Wired by the eval manager; until then the internal eval callback answers 404. */
|
|
81
|
+
evalServices?: EvalServices;
|
|
82
|
+
/** Host connections. Guide and MCP use the same service the console does. */
|
|
83
|
+
channels?: ChannelService;
|
|
84
|
+
/** Host memories. Guide and MCP use the same host the console does. */
|
|
85
|
+
memories?: MemoryHost;
|
|
71
86
|
};
|
|
72
87
|
/**
|
|
73
88
|
* The full operator-console route surface: REST API (runs, stages,
|
package/dist/server/http.js
CHANGED
|
@@ -8,6 +8,10 @@ import { mapProviderAuthError } from "../agent/providerInspect.js";
|
|
|
8
8
|
import { handleProviderRoutes } from "./providerRoutes.js";
|
|
9
9
|
import { handleProjectMcpRoutes } from "./projectMcpRoutes.js";
|
|
10
10
|
import { handleTriggerRoutes } from "./triggerRoutes.js";
|
|
11
|
+
import { guideWriteRoot } from "../guide/writeRoot.js";
|
|
12
|
+
import { handleEvalRoutes } from "./evalRoutes.js";
|
|
13
|
+
import { defaultLoadJudgePrices } from "../evals/engine/promptfoo/judgeServices.js";
|
|
14
|
+
import { engineStatus as promptfooEngineStatus } from "../evals/engine/promptfoo/status.js";
|
|
11
15
|
import { readCatalogFileForHttp, writeCatalogFileForHttp, } from "./readCatalogFile.js";
|
|
12
16
|
import { applyLiveViewHeaders, createLiveViewRoutes, isLiveViewDialogPath, isLiveViewInputPath, isLiveViewPath, isLiveViewReopenTabPath, } from "./liveViewRoutes.js";
|
|
13
17
|
import { createPipeline, parseCreatePipelineBody } from "../config/createPipeline.js";
|
|
@@ -59,8 +63,11 @@ import { buildModelsResponse } from "../models/response.js";
|
|
|
59
63
|
import { createAgentHostContext } from "../agents/hostContext.js";
|
|
60
64
|
import { AgentScheduleSource, agentScheduleTickIntervalMsFromEnv, } from "../agents/scheduleSource.js";
|
|
61
65
|
import { handleAgentAuthorRoutes } from "./agentAuthorRoutes.js";
|
|
66
|
+
import { handleGuideRoutes } from "./guideRoutes.js";
|
|
67
|
+
import { handleInternalAgentRoutes } from "./internalAgentRoutes.js";
|
|
62
68
|
import { handleAgentRoutes } from "./agentRoutes.js";
|
|
63
69
|
import { handleChannelRoutes } from "./channelRoutes.js";
|
|
70
|
+
import { handleEvalInternalRoutes, isEvalInternalPath } from "./evalInternalRoutes.js";
|
|
64
71
|
import { handleMemoryRoutes } from "./memoryRoutes.js";
|
|
65
72
|
import { bootstrapStageflowHost, } from "./bootstrap.js";
|
|
66
73
|
import { assertAllowedHttpAccess, isTrustedLocalHttpRequest, resolveAllowedHosts, } from "./allowedHosts.js";
|
|
@@ -183,7 +190,7 @@ export function defaultUiDistDir() {
|
|
|
183
190
|
return path.resolve(here, "../ui");
|
|
184
191
|
}
|
|
185
192
|
export function createOperatorRoutes(deps) {
|
|
186
|
-
const { manager, store, cwd, agentDir, rootDir, providerAuthContext, uiDistDir, workshopOperatorHost, agentConversationBackend, agentHost: injectedHost, } = deps;
|
|
193
|
+
const { manager, store, cwd, agentDir, rootDir, providerAuthContext, uiDistDir, workshopOperatorHost, agentConversationBackend, agentHost: injectedHost, evalServices, } = deps;
|
|
187
194
|
const agentConnection = injectedHost ? undefined : sqliteConnectionFromStore(store);
|
|
188
195
|
const agentHost = injectedHost ??
|
|
189
196
|
(agentConnection
|
|
@@ -213,7 +220,27 @@ export function createOperatorRoutes(deps) {
|
|
|
213
220
|
resolveAgentPort({
|
|
214
221
|
cwd,
|
|
215
222
|
projectRoot: cwd,
|
|
223
|
+
guideDeps: {
|
|
224
|
+
manager,
|
|
225
|
+
store,
|
|
226
|
+
cwd,
|
|
227
|
+
agentDir,
|
|
228
|
+
projectRoot: guideWriteRoot(rootDir),
|
|
229
|
+
...(providerAuthContext ? { providerAuthContext } : {}),
|
|
230
|
+
...(deps.evalRunManager ? { evalRunManager: deps.evalRunManager } : {}),
|
|
231
|
+
...(deps.channels ? { channels: deps.channels } : {}),
|
|
232
|
+
...(deps.memories ? { memories: deps.memories } : {}),
|
|
233
|
+
...(agentHost
|
|
234
|
+
? {
|
|
235
|
+
agentService: agentHost.service,
|
|
236
|
+
agentChat: agentHost.chat,
|
|
237
|
+
agentConversationBackend: agentHost.backend,
|
|
238
|
+
}
|
|
239
|
+
: {}),
|
|
240
|
+
},
|
|
216
241
|
});
|
|
242
|
+
if (deps.operatorHostSlot)
|
|
243
|
+
deps.operatorHostSlot.current = operatorHost;
|
|
217
244
|
const workshopChatRegistry = deps.workshopChatRegistry ?? new WorkshopChatSessionRegistry(operatorHost);
|
|
218
245
|
const workshopSessionStoreRoot = () => resolveWorkshopSessionStoreRoot();
|
|
219
246
|
const workshopBuildStoreRoot = () => resolveWorkshopBuildStoreRoot();
|
|
@@ -250,10 +277,21 @@ export function createOperatorRoutes(deps) {
|
|
|
250
277
|
try {
|
|
251
278
|
if (await liveView.handle(req, res))
|
|
252
279
|
return true;
|
|
253
|
-
if (pathname
|
|
280
|
+
if (isEvalInternalPath(pathname) && (await handleEvalInternalRoutes(req, method, pathname, evalServices, res, json)))
|
|
281
|
+
return true;
|
|
282
|
+
if (pathname === "/api/agent-author/chat" ||
|
|
283
|
+
pathname === "/api/agent-author/undo" ||
|
|
284
|
+
pathname === "/api/agent-author/sessions" ||
|
|
285
|
+
pathname.startsWith("/api/agent-author/sessions/")) {
|
|
254
286
|
if (await handleAgentAuthorRoutes(req, method, pathname, cwd, operatorHost, res, json))
|
|
255
287
|
return true;
|
|
256
288
|
}
|
|
289
|
+
if (pathname === "/api/guide" || pathname.startsWith("/api/guide/")) {
|
|
290
|
+
if (await handleGuideRoutes(req, method, pathname, operatorHost, res, json))
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
if (handleInternalAgentRoutes(method, pathname, operatorHost, res, json))
|
|
294
|
+
return true;
|
|
257
295
|
if (PublicWebChat.owns(pathname)) {
|
|
258
296
|
if (!agentHost) {
|
|
259
297
|
json(res, 503, { code: "web_chat.unavailable" });
|
|
@@ -377,6 +415,9 @@ export function createOperatorRoutes(deps) {
|
|
|
377
415
|
filter.pipeline = pipeline;
|
|
378
416
|
if (callerId !== null)
|
|
379
417
|
filter.caller_id = callerId;
|
|
418
|
+
const origin = url.searchParams.get("origin");
|
|
419
|
+
if (origin === "eval" || origin === "any")
|
|
420
|
+
filter.origin = origin;
|
|
380
421
|
json(res, 200, {
|
|
381
422
|
runs: await store.listRuns(Object.keys(filter).length > 0 ? filter : undefined),
|
|
382
423
|
});
|
|
@@ -1052,7 +1093,9 @@ export function createOperatorRoutes(deps) {
|
|
|
1052
1093
|
await readJsonBody(req);
|
|
1053
1094
|
const runId = decodeURIComponent(retryMatch[1] ?? "");
|
|
1054
1095
|
const stageId = decodeURIComponent(retryMatch[2] ?? "");
|
|
1055
|
-
const result = await manager.retryStage(runId, stageId
|
|
1096
|
+
const result = await manager.retryStage(runId, stageId, {
|
|
1097
|
+
awaitRoot: false,
|
|
1098
|
+
});
|
|
1056
1099
|
if (!result.ok) {
|
|
1057
1100
|
json(res, result.status ?? 500, mapRetryStageFailure(result));
|
|
1058
1101
|
return true;
|
|
@@ -2894,6 +2937,21 @@ export function createOperatorRoutes(deps) {
|
|
|
2894
2937
|
})) {
|
|
2895
2938
|
return true;
|
|
2896
2939
|
}
|
|
2940
|
+
if (await handleEvalRoutes(req, res, {
|
|
2941
|
+
cwd,
|
|
2942
|
+
store,
|
|
2943
|
+
manager,
|
|
2944
|
+
evalRunManager: deps.evalRunManager,
|
|
2945
|
+
json,
|
|
2946
|
+
readJsonBody,
|
|
2947
|
+
auditLog,
|
|
2948
|
+
engineStatus: () => promptfooEngineStatus({ home: globalStageflowHome() }),
|
|
2949
|
+
agents: () => agentHost?.service,
|
|
2950
|
+
loadPrices: defaultLoadJudgePrices,
|
|
2951
|
+
triage: { judgeBackend: () => agentHost?.backend },
|
|
2952
|
+
})) {
|
|
2953
|
+
return true;
|
|
2954
|
+
}
|
|
2897
2955
|
if (await handleTriggerRoutes(req, res, {
|
|
2898
2956
|
cwd,
|
|
2899
2957
|
manager,
|
|
@@ -3151,6 +3209,11 @@ export async function startUiServer(options) {
|
|
|
3151
3209
|
? { workshopOperatorHost: options.workshopOperatorHost }
|
|
3152
3210
|
: {}),
|
|
3153
3211
|
...(boot.agentHost ? { agentHost: boot.agentHost } : {}),
|
|
3212
|
+
...(boot.operatorHostSlot ? { operatorHostSlot: boot.operatorHostSlot } : {}),
|
|
3213
|
+
...(boot.evalRunManager ? { evalRunManager: boot.evalRunManager } : {}),
|
|
3214
|
+
...(boot.evalServices ? { evalServices: boot.evalServices } : {}),
|
|
3215
|
+
...(boot.channels ? { channels: boot.channels } : {}),
|
|
3216
|
+
...(boot.memories ? { memories: boot.memories } : {}),
|
|
3154
3217
|
...(options.agentConversationBackend
|
|
3155
3218
|
? { agentConversationBackend: options.agentConversationBackend }
|
|
3156
3219
|
: {}),
|
|
@@ -3163,6 +3226,7 @@ export async function startUiServer(options) {
|
|
|
3163
3226
|
controlTokens,
|
|
3164
3227
|
routes,
|
|
3165
3228
|
});
|
|
3229
|
+
boot.setEvalCallbackBase?.(envelope.url);
|
|
3166
3230
|
const closeServer = envelope.server.close.bind(envelope.server);
|
|
3167
3231
|
envelope.server.close = ((callback) => closeServer(error => {
|
|
3168
3232
|
void (boot.email?.stop() ?? Promise.resolve()).then(() => callback?.(error), () => callback?.(error ?? new Error("Email host shutdown failed")));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ServerResponse } from "node:http";
|
|
2
|
+
import type { OperatorAgentHost } from "../operatorAgent/index.js";
|
|
3
|
+
type Json = (res: ServerResponse, status: number, body: unknown) => void;
|
|
4
|
+
export declare const INTERNAL_AGENTS_PATH = "/api/internal-agents";
|
|
5
|
+
export declare function handleInternalAgentRoutes(method: string, pathname: string, host: OperatorAgentHost, res: ServerResponse, json: Json, env?: NodeJS.ProcessEnv): boolean;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { describeInternalAgents, internalAgentsVisible } from "../operatorAgent/internalAgents.js";
|
|
2
|
+
export const INTERNAL_AGENTS_PATH = "/api/internal-agents";
|
|
3
|
+
export function handleInternalAgentRoutes(method, pathname, host, res, json, env = process.env) {
|
|
4
|
+
if (pathname !== INTERNAL_AGENTS_PATH || method !== "GET")
|
|
5
|
+
return false;
|
|
6
|
+
if (!internalAgentsVisible(env)) {
|
|
7
|
+
json(res, 200, { visible: false, agents: [] });
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
json(res, 200, { visible: true, agents: describeInternalAgents(host) });
|
|
11
|
+
return true;
|
|
12
|
+
}
|
package/dist/server/mcpHost.js
CHANGED
|
@@ -28,6 +28,10 @@ export async function startMcpServer(options) {
|
|
|
28
28
|
controlTokens,
|
|
29
29
|
getShutdown: () => shutdown,
|
|
30
30
|
...(boot.agentHost ? { agentHost: boot.agentHost } : {}),
|
|
31
|
+
...(boot.evalRunManager ? { evalRunManager: boot.evalRunManager } : {}),
|
|
32
|
+
...(boot.evalServices ? { evalServices: boot.evalServices } : {}),
|
|
33
|
+
...(boot.channels ? { channels: boot.channels } : {}),
|
|
34
|
+
...(boot.memories ? { memories: boot.memories } : {}),
|
|
31
35
|
});
|
|
32
36
|
const envelope = await createHttpHost({
|
|
33
37
|
boot,
|
|
@@ -39,6 +43,7 @@ export async function startMcpServer(options) {
|
|
|
39
43
|
maxConnections: options.maxConnections,
|
|
40
44
|
routes,
|
|
41
45
|
});
|
|
46
|
+
boot.setEvalCallbackBase?.(envelope.url);
|
|
42
47
|
shutdown = installShutdownController({
|
|
43
48
|
server: envelope.server,
|
|
44
49
|
host: makeDrainableHostFromOptional(envelope.manager, envelope.store),
|
package/dist/toolkit/meta.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* can import it without pulling in the runtime.
|
|
5
5
|
*/
|
|
6
6
|
export type ToolRisk = "read" | "write" | "destructive" | "external";
|
|
7
|
-
export type ToolGroupId = "discover" | "runs.read" | "runs.control" | "runs.cleanup" | "gates.read" | "gates.decide" | "triggers" | "agents.read" | "agents.manage" | "agents.cleanup" | "agents.converse" | "pipelines.author";
|
|
7
|
+
export type ToolGroupId = "discover" | "runs.read" | "runs.control" | "runs.cleanup" | "gates.read" | "gates.decide" | "triggers" | "agents.read" | "agents.manage" | "agents.cleanup" | "agents.converse" | "evals.read" | "evals.run" | "evals.write" | "evals.cleanup" | "pipelines.author" | "connections" | "connections.cleanup" | "memories" | "memories.cleanup";
|
|
8
8
|
export type ToolGroup = {
|
|
9
9
|
id: ToolGroupId;
|
|
10
10
|
title: string;
|
package/dist/toolkit/meta.js
CHANGED
|
@@ -16,6 +16,14 @@ export const TOOL_GROUPS = [
|
|
|
16
16
|
{ id: "agents.cleanup", title: "Archive agents", summary: "Archive an agent. Destructive." },
|
|
17
17
|
{ id: "agents.converse", title: "Talk to agents", summary: "Chat with an agent and stop its running turn." },
|
|
18
18
|
{ id: "pipelines.author", title: "Author pipelines and tasks", summary: "Read, create and edit pipelines, stages and tasks directly on disk." },
|
|
19
|
+
{ id: "connections", title: "Connections", summary: "List, create, test and update host connections. Secret values are stored and never returned." },
|
|
20
|
+
{ id: "connections.cleanup", title: "Remove connections", summary: "Remove a connection and its stored secrets. Destructive." },
|
|
21
|
+
{ id: "memories", title: "Memories", summary: "List, create and edit host memories and their cards." },
|
|
22
|
+
{ id: "memories.cleanup", title: "Delete memory cards", summary: "Delete one card from a host memory. Destructive." },
|
|
23
|
+
{ id: "evals.read", title: "Read evals", summary: "List evals, runs and results; validate and compare. Free." },
|
|
24
|
+
{ id: "evals.run", title: "Run evals", summary: "Start and cancel eval runs, and try one case. Calls models and costs money." },
|
|
25
|
+
{ id: "evals.write", title: "Author evals", summary: "Create and edit evals and datasets, install a sample, and review or sort suggestions." },
|
|
26
|
+
{ id: "evals.cleanup", title: "Delete eval runs", summary: "Delete an eval run and its stored results. Destructive." },
|
|
19
27
|
];
|
|
20
28
|
const t = (group, risk, operatorOnly) => ({ group, risk, ...(operatorOnly ? { operatorOnly } : {}) });
|
|
21
29
|
export const TOOL_META = {
|
|
@@ -68,6 +76,8 @@ export const TOOL_META = {
|
|
|
68
76
|
get_agent: t("agents.read", "read"),
|
|
69
77
|
validate_agent: t("agents.read", "read"),
|
|
70
78
|
list_agent_revisions: t("agents.read", "read"),
|
|
79
|
+
get_agent_revision: t("agents.read", "read"),
|
|
80
|
+
diff_agent_revisions: t("agents.read", "read"),
|
|
71
81
|
get_agent_session: t("agents.read", "read"),
|
|
72
82
|
list_agent_sessions: t("agents.read", "read"),
|
|
73
83
|
create_agent: t("agents.manage", "write"),
|
|
@@ -87,6 +97,49 @@ export const TOOL_META = {
|
|
|
87
97
|
edit_stage: t("pipelines.author", "write"),
|
|
88
98
|
create_task: t("pipelines.author", "write"),
|
|
89
99
|
edit_task: t("pipelines.author", "write"),
|
|
100
|
+
create_task_file: t("pipelines.author", "write"),
|
|
101
|
+
update_task_file: t("pipelines.author", "write"),
|
|
102
|
+
import_task_file: t("pipelines.author", "external"),
|
|
103
|
+
create_stage_file: t("pipelines.author", "write"),
|
|
104
|
+
write_catalog_file: t("pipelines.author", "write"),
|
|
105
|
+
validate_catalog_draft: t("pipelines.author", "read"),
|
|
106
|
+
list_connections: t("connections", "read"),
|
|
107
|
+
create_connection: t("connections", "write"),
|
|
108
|
+
update_connection: t("connections", "write"),
|
|
109
|
+
test_connection: t("connections", "external"),
|
|
110
|
+
validate_connection_target: t("connections", "read"),
|
|
111
|
+
remove_connection: t("connections.cleanup", "destructive"),
|
|
112
|
+
list_memories: t("memories", "read"),
|
|
113
|
+
get_memory: t("memories", "read"),
|
|
114
|
+
create_memory: t("memories", "write"),
|
|
115
|
+
write_memory: t("memories", "write"),
|
|
116
|
+
write_memory_card: t("memories", "write"),
|
|
117
|
+
delete_memory_card: t("memories.cleanup", "destructive"),
|
|
118
|
+
list_evals: t("evals.read", "read"),
|
|
119
|
+
get_eval: t("evals.read", "read"),
|
|
120
|
+
validate_eval: t("evals.read", "read"),
|
|
121
|
+
get_eval_run: t("evals.read", "read"),
|
|
122
|
+
list_eval_runs: t("evals.read", "read"),
|
|
123
|
+
get_eval_results: t("evals.read", "read"),
|
|
124
|
+
get_eval_result: t("evals.read", "read"),
|
|
125
|
+
compare_eval_runs: t("evals.read", "read"),
|
|
126
|
+
get_eval_failure_suggestions: t("evals.read", "read"),
|
|
127
|
+
get_eval_failure_sort_status: t("evals.read", "read"),
|
|
128
|
+
get_eval_run_export: t("evals.read", "read"),
|
|
129
|
+
run_eval: t("evals.run", "external"),
|
|
130
|
+
sort_eval_failures: t("evals.run", "external"),
|
|
131
|
+
cancel_eval_run: t("evals.run", "write"),
|
|
132
|
+
try_eval_case: t("evals.run", "external"),
|
|
133
|
+
create_eval: t("evals.write", "write"),
|
|
134
|
+
update_eval: t("evals.write", "write"),
|
|
135
|
+
create_dataset: t("evals.write", "write"),
|
|
136
|
+
update_dataset_cases: t("evals.write", "write"),
|
|
137
|
+
convert_dataset: t("evals.write", "write"),
|
|
138
|
+
install_eval_sample: t("evals.write", "write"),
|
|
139
|
+
put_eval_review: t("evals.write", "write"),
|
|
140
|
+
accept_eval_failure_suggestions: t("evals.write", "write"),
|
|
141
|
+
dismiss_eval_failure_suggestions: t("evals.write", "write"),
|
|
142
|
+
delete_eval_run: t("evals.cleanup", "destructive"),
|
|
90
143
|
};
|
|
91
144
|
/** The grant id the policy gate and `approvals.ask_first` use for a Stageflow tool. */
|
|
92
145
|
export const STAGEFLOW_GRANT_PREFIX = "stageflow.";
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
* Their tools are checked through the same grant-id check as any agent's tools,
|
|
4
4
|
* so there is one permission layer. The lists are literals so this module has no
|
|
5
5
|
* dependency on the profiles; tests keep them equal to the profiles' tool names.
|
|
6
|
+
* Guide is the exception: it may call every Stageflow tool a person could grant,
|
|
7
|
+
* except the ones only a person may decide.
|
|
6
8
|
*/
|
|
9
|
+
export declare const GUIDE_OWN_TOOL_NAMES: readonly ["confirm_action", "show_ui", "list_guide_topics", "read_guide_topic"];
|
|
10
|
+
/** Tool names Guide may call. Operator-only decisions stay out. */
|
|
11
|
+
export declare function stageflowGuideToolNames(): readonly string[];
|
|
7
12
|
export declare const PROFILE_GRANTS: Readonly<Record<string, {
|
|
8
13
|
prefix: string;
|
|
9
14
|
tools: readonly string[];
|
package/dist/toolkit/profiles.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
import { isOperatorOnlyTool, TOOL_META } from "./meta.js";
|
|
1
2
|
/**
|
|
2
3
|
* The Workshop and Agent-author profiles are agents with a fixed grant list.
|
|
3
4
|
* Their tools are checked through the same grant-id check as any agent's tools,
|
|
4
5
|
* so there is one permission layer. The lists are literals so this module has no
|
|
5
6
|
* dependency on the profiles; tests keep them equal to the profiles' tool names.
|
|
7
|
+
* Guide is the exception: it may call every Stageflow tool a person could grant,
|
|
8
|
+
* except the ones only a person may decide.
|
|
6
9
|
*/
|
|
10
|
+
export const GUIDE_OWN_TOOL_NAMES = ["confirm_action", "show_ui", "list_guide_topics", "read_guide_topic"];
|
|
11
|
+
/** Tool names Guide may call. Operator-only decisions stay out. */
|
|
12
|
+
export function stageflowGuideToolNames() {
|
|
13
|
+
return [...Object.keys(TOOL_META).filter((name) => !isOperatorOnlyTool(name)), ...GUIDE_OWN_TOOL_NAMES];
|
|
14
|
+
}
|
|
7
15
|
export const PROFILE_GRANTS = {
|
|
8
16
|
"workshop-author": {
|
|
9
17
|
prefix: "workshop.",
|
|
@@ -11,7 +19,11 @@ export const PROFILE_GRANTS = {
|
|
|
11
19
|
},
|
|
12
20
|
"agent-author": {
|
|
13
21
|
prefix: "agent_author.",
|
|
14
|
-
tools: ["read_project_file", "list_project_files", "list_mcp_servers", "update_agent_draft"],
|
|
22
|
+
tools: ["read_agent_draft", "read_project_file", "list_project_files", "list_mcp_servers", "list_author_catalog", "update_agent_draft"],
|
|
23
|
+
},
|
|
24
|
+
"stageflow-guide": {
|
|
25
|
+
prefix: "guide.",
|
|
26
|
+
tools: stageflowGuideToolNames(),
|
|
15
27
|
},
|
|
16
28
|
};
|
|
17
29
|
export function profileGrantIds(profileId) {
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* Do not abort the session from inside `execute`: the tool Promise is the
|
|
8
8
|
* live blocking surface until the operator answers (or stage teardown).
|
|
9
9
|
*/
|
|
10
|
+
import { ASK_OPERATOR_TOOL_NAME } from "./stageToolNames.js";
|
|
10
11
|
import { randomUUID } from "node:crypto";
|
|
11
12
|
import { Type } from "typebox";
|
|
12
13
|
import { prepareAskOperatorArguments } from "./prepareToolArguments.js";
|
|
@@ -399,7 +400,7 @@ export function createAskOperatorTool(options) {
|
|
|
399
400
|
? [...allowed].join(", ")
|
|
400
401
|
: ASK_OPERATOR_KINDS.join(", ");
|
|
401
402
|
return {
|
|
402
|
-
name:
|
|
403
|
+
name: ASK_OPERATOR_TOOL_NAME,
|
|
403
404
|
label: "Ask operator",
|
|
404
405
|
description: `Ask the operator a question and wait for their answer. Supports ${kindList} prompts. Does not complete the stage — call emit_stage_envelope when finished.`,
|
|
405
406
|
parameters: askOperatorParamsSchemaFor(allowedKinds),
|