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
package/dist/agents/sessions.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { randomBytes } from "node:crypto";
|
|
2
2
|
import { assertDelegateAllowed } from "./delegate.js";
|
|
3
3
|
import { AgentError, isAgentError } from "./errors.js";
|
|
4
|
+
import { EVAL_SESSION_SOURCE, isEvalSession } from "./evalSession.js";
|
|
4
5
|
import { guardedStream } from "./guardrails.js";
|
|
5
6
|
import { fitHistory } from "./historyFit.js";
|
|
6
7
|
import { isToolGranted, requiresAskFirst } from "./policy.js";
|
|
8
|
+
import { scrubSecrets } from "../compaction/scrub.js";
|
|
9
|
+
import { WORKING_STATE_TOOL_NAME } from "../compaction/types.js";
|
|
7
10
|
import { prepareSpan } from "./trace.js";
|
|
8
11
|
const GROUNDEDNESS_PROMPT = (reply, evidence) => [
|
|
9
12
|
"Rate how well the ANSWER is supported by the TOOL OUTPUTS, from 0 (unsupported or contradicted) to 1 (fully supported).",
|
|
@@ -51,7 +54,8 @@ export class AgentConversation {
|
|
|
51
54
|
if (!sessionId) {
|
|
52
55
|
const opened = await service.openSession(input.projectRoot, input.agentId, {
|
|
53
56
|
source: input.source ?? "console",
|
|
54
|
-
sourceRef: input.author ?? null,
|
|
57
|
+
sourceRef: input.sourceRef !== undefined ? input.sourceRef : (input.author ?? null),
|
|
58
|
+
...(input.eval ? { eval: input.eval } : {}),
|
|
55
59
|
});
|
|
56
60
|
sessionId = opened.id;
|
|
57
61
|
input.onSessionOpened?.(sessionId);
|
|
@@ -98,9 +102,31 @@ export class AgentConversation {
|
|
|
98
102
|
service.recordSpan(input.projectRoot, span);
|
|
99
103
|
};
|
|
100
104
|
const toolStarts = new Map();
|
|
105
|
+
const childSessions = new Map();
|
|
106
|
+
const childSessionOf = (call) => (isEvalSession(active.session) ? (childSessions.get(call.id) ?? childSessions.get(call.tool)) : undefined);
|
|
101
107
|
let stopReason;
|
|
102
108
|
let gateChain = Promise.resolve();
|
|
103
109
|
const gateOne = async (call) => {
|
|
110
|
+
if (active.session.source === EVAL_SESSION_SOURCE) {
|
|
111
|
+
const gate = this.options.evalGates?.get(sessionId);
|
|
112
|
+
if (!gate)
|
|
113
|
+
return { allow: false, reason: "No eval policy is registered for this session." };
|
|
114
|
+
const decision = gate.decide(call, definition);
|
|
115
|
+
if (gate.recordOf(call.id)?.policyOutcome === "would_ask_first") {
|
|
116
|
+
const at = new Date();
|
|
117
|
+
record({
|
|
118
|
+
turnId: turn.id,
|
|
119
|
+
parentSpanId: rootId,
|
|
120
|
+
name: `approval ${call.tool}`,
|
|
121
|
+
kind: "gate",
|
|
122
|
+
status: "error",
|
|
123
|
+
startedAt: at,
|
|
124
|
+
endedAt: at,
|
|
125
|
+
attributes: { "stageflow.approval.outcome": "would_ask_first", "gen_ai.tool.name": call.tool },
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return decision;
|
|
129
|
+
}
|
|
104
130
|
if (!isToolGranted(definition, call.tool)) {
|
|
105
131
|
return { allow: false, reason: `Tool ${call.tool} is not granted to this agent.` };
|
|
106
132
|
}
|
|
@@ -162,6 +188,8 @@ export class AgentConversation {
|
|
|
162
188
|
toolStarts.set(call.id, new Date());
|
|
163
189
|
},
|
|
164
190
|
toolFinished: (call, result) => {
|
|
191
|
+
if (active.session.source === EVAL_SESSION_SOURCE)
|
|
192
|
+
this.options.evalGates?.get(sessionId)?.observeFinished(call, result);
|
|
165
193
|
const isAgent = call.tool.startsWith("agent:");
|
|
166
194
|
record({
|
|
167
195
|
turnId: turn.id,
|
|
@@ -171,8 +199,12 @@ export class AgentConversation {
|
|
|
171
199
|
status: result.ok ? "ok" : "error",
|
|
172
200
|
startedAt: toolStarts.get(call.id) ?? new Date(),
|
|
173
201
|
endedAt: new Date(),
|
|
174
|
-
attributes: {
|
|
175
|
-
|
|
202
|
+
attributes: {
|
|
203
|
+
"gen_ai.tool.name": call.tool,
|
|
204
|
+
...(isEvalSession(active.session) ? { "gen_ai.tool.call.id": call.id } : {}),
|
|
205
|
+
...(childSessionOf(call) ? { "stageflow.sub_agent.session_id": childSessionOf(call) } : {}),
|
|
206
|
+
},
|
|
207
|
+
input: call.tool === WORKING_STATE_TOOL_NAME ? scrubSecrets(toJson(call.input)) : toJson(call.input),
|
|
176
208
|
output: result.output,
|
|
177
209
|
});
|
|
178
210
|
},
|
|
@@ -193,16 +225,26 @@ export class AgentConversation {
|
|
|
193
225
|
},
|
|
194
226
|
});
|
|
195
227
|
},
|
|
196
|
-
delegate: async (agentId, message) => {
|
|
228
|
+
delegate: async (agentId, message, callId) => {
|
|
197
229
|
assertDelegateAllowed(definition, agentId, this.depth);
|
|
198
230
|
const child = new AgentConversation(this.options, this.depth + 1, controller.signal);
|
|
231
|
+
const inEval = isEvalSession(active.session);
|
|
232
|
+
const inherited = { ...service.evalOverridesOf(active.session.id) };
|
|
233
|
+
delete inherited.revision;
|
|
199
234
|
try {
|
|
200
235
|
const detail = await child.send({
|
|
201
236
|
projectRoot: input.projectRoot,
|
|
202
237
|
agentId,
|
|
203
238
|
text: message,
|
|
204
|
-
source: "agent",
|
|
239
|
+
source: inEval ? EVAL_SESSION_SOURCE : "agent",
|
|
205
240
|
author: active.session.agentId,
|
|
241
|
+
...(inEval ? { sourceRef: active.session.id, eval: inherited } : {}),
|
|
242
|
+
onSessionOpened: (childId) => {
|
|
243
|
+
childSessions.set(callId ?? `agent:${agentId}`, childId);
|
|
244
|
+
const parentGate = inEval ? this.options.evalGates?.get(sessionId) : undefined;
|
|
245
|
+
if (parentGate)
|
|
246
|
+
this.options.evalGates.set(childId, parentGate);
|
|
247
|
+
},
|
|
206
248
|
});
|
|
207
249
|
return [...detail.messages].reverse().find((m) => m.role === "assistant")?.text ?? "(no reply)";
|
|
208
250
|
}
|
|
@@ -230,7 +272,7 @@ export class AgentConversation {
|
|
|
230
272
|
const code = isAgentError(error) ? error.code : "agent.backend_failed";
|
|
231
273
|
record({ turnId: turn.id, name: `invoke_agent ${definition.id}`, kind: "agent", status: "error", startedAt, endedAt: new Date(), attributes: { "error.type": code } });
|
|
232
274
|
await service.completeTurn(input.projectRoot, turn.id, { status: "failed", errorCode: code });
|
|
233
|
-
this.exportLive(input.projectRoot, definition, turn.id);
|
|
275
|
+
this.exportLive(input.projectRoot, active.session, definition, turn.id);
|
|
234
276
|
throw error;
|
|
235
277
|
}
|
|
236
278
|
const cancelled = controller.signal.aborted;
|
|
@@ -264,10 +306,10 @@ export class AgentConversation {
|
|
|
264
306
|
errorCode: "agent.guardrail_blocked",
|
|
265
307
|
...(usage ? { usage, costUsd: usage.costUsd } : {}),
|
|
266
308
|
});
|
|
267
|
-
this.exportLive(input.projectRoot, definition, turn.id);
|
|
309
|
+
this.exportLive(input.projectRoot, active.session, definition, turn.id);
|
|
268
310
|
throw new AgentError("agent.guardrail_blocked", `Reply blocked by guardrail ${guard.pattern}`);
|
|
269
311
|
}
|
|
270
|
-
const evalScores = await this.score(input.projectRoot, definition, turn.id, rootId, result, controller.signal, cancelled || stopReason !== undefined);
|
|
312
|
+
const evalScores = await this.score(input.projectRoot, definition, turn.id, rootId, result, controller.signal, cancelled || stopReason !== undefined || isEvalSession(active.session));
|
|
271
313
|
const failed = stopReason !== undefined;
|
|
272
314
|
endRoot(cancelled ? "cancelled" : failed ? "error" : "ok");
|
|
273
315
|
const detail = await service.completeTurn(input.projectRoot, turn.id, {
|
|
@@ -277,7 +319,7 @@ export class AgentConversation {
|
|
|
277
319
|
...(usage ? { usage, costUsd: usage.costUsd } : {}),
|
|
278
320
|
...(evalScores.length > 0 ? { evalScores } : {}),
|
|
279
321
|
});
|
|
280
|
-
this.exportLive(input.projectRoot, definition, turn.id);
|
|
322
|
+
this.exportLive(input.projectRoot, active.session, definition, turn.id);
|
|
281
323
|
return detail;
|
|
282
324
|
}
|
|
283
325
|
async score(projectRoot, definition, turnId, rootId, result, signal, skip) {
|
|
@@ -305,9 +347,9 @@ export class AgentConversation {
|
|
|
305
347
|
}
|
|
306
348
|
}
|
|
307
349
|
/** Best-effort push to the configured OTLP collector; a collector outage never fails a turn. */
|
|
308
|
-
exportLive(projectRoot, definition, turnId) {
|
|
350
|
+
exportLive(projectRoot, session, definition, turnId) {
|
|
309
351
|
const sink = this.options.otlpSink;
|
|
310
|
-
if (!sink || !definition.observability.otlp || definition.observability.capture === "off")
|
|
352
|
+
if (!sink || isEvalSession(session) || !definition.observability.otlp || definition.observability.capture === "off")
|
|
311
353
|
return;
|
|
312
354
|
void (async () => {
|
|
313
355
|
try {
|
package/dist/agents/store.d.ts
CHANGED
|
@@ -149,6 +149,8 @@ export type SessionQuery = {
|
|
|
149
149
|
limit: number;
|
|
150
150
|
/** Opaque cursor from a previous page. */
|
|
151
151
|
cursor?: string;
|
|
152
|
+
/** Eval sessions are hidden unless an internal reader (eval read models, tests) asks for them. */
|
|
153
|
+
includeEval?: boolean;
|
|
152
154
|
};
|
|
153
155
|
export type SessionStats = {
|
|
154
156
|
total: number;
|
|
@@ -204,9 +206,18 @@ export declare class AgentStore {
|
|
|
204
206
|
nextCursor: string | null;
|
|
205
207
|
};
|
|
206
208
|
/** One visitor's sessions on one agent, newest first (public web chat). */
|
|
207
|
-
listSessionsForRef(projectKey: string, agentId: string, source: string, sourceRef: string, limit: number): AgentSession[];
|
|
209
|
+
listSessionsForRef(projectKey: string, agentId: string, source: string, sourceRef: string, limit: number, includeEval?: boolean): AgentSession[];
|
|
208
210
|
/** Stats for one agent, or for every agent when `agentId` is omitted. */
|
|
209
|
-
sessionStats(projectKey: string, agentId: string | undefined, since: string): SessionStats;
|
|
211
|
+
sessionStats(projectKey: string, agentId: string | undefined, since: string, includeEval?: boolean): SessionStats;
|
|
212
|
+
/** Eval sessions below a session or an eval run: those whose `source_ref` is it, and theirs, recursively. */
|
|
213
|
+
listChildSessions(parentId: string): AgentSession[];
|
|
214
|
+
/** Root eval sessions (those pointing at an eval run, not at a parent session), optionally of given runs or older than a time. */
|
|
215
|
+
listEvalRootSessions(filter?: {
|
|
216
|
+
sourceRefs?: string[];
|
|
217
|
+
createdBefore?: string;
|
|
218
|
+
}): AgentSession[];
|
|
219
|
+
/** Delete eval sessions; messages, turns, spans, scores and approvals go with them. Never touches other sessions. */
|
|
220
|
+
deleteSessions(sessionIds: string[]): void;
|
|
210
221
|
/** Ids of every session an agent has had, for releasing what a runtime holds for them. */
|
|
211
222
|
sessionIdsOf(projectKey: string, agentId: string): string[];
|
|
212
223
|
appendMessage(message: Omit<AgentMessage, "seq">): AgentMessage;
|
|
@@ -250,7 +261,7 @@ export declare class AgentStore {
|
|
|
250
261
|
getPendingApproval(sessionId: string): AgentApproval | undefined;
|
|
251
262
|
findApprovalByPayload(sessionId: string, payloadHash: string): AgentApproval | undefined;
|
|
252
263
|
listApprovals(sessionId: string): AgentApproval[];
|
|
253
|
-
listPendingApprovals(projectKey: string): Array<AgentApproval & {
|
|
264
|
+
listPendingApprovals(projectKey: string, includeEval?: boolean): Array<AgentApproval & {
|
|
254
265
|
agentId: string;
|
|
255
266
|
}>;
|
|
256
267
|
decideApproval(approvalId: string, patch: {
|
package/dist/agents/store.js
CHANGED
|
@@ -9,6 +9,7 @@ export const SESSION_STATUSES = ["open", "running", "waiting", "held", "closed"]
|
|
|
9
9
|
export function isSessionStatus(value) {
|
|
10
10
|
return SESSION_STATUSES.includes(value);
|
|
11
11
|
}
|
|
12
|
+
const HIDE_EVAL = "source <> 'eval'";
|
|
12
13
|
export function agentProjectKey(projectRoot) {
|
|
13
14
|
return createHash("sha256").update(path.resolve(projectRoot)).digest("hex").slice(0, 16);
|
|
14
15
|
}
|
|
@@ -274,6 +275,8 @@ export class AgentStore {
|
|
|
274
275
|
/** One agent's sessions, or every agent's when `agentId` is omitted. */
|
|
275
276
|
listSessions(projectKey, agentId, query) {
|
|
276
277
|
const where = ["project_key = @projectKey"];
|
|
278
|
+
if (!query.includeEval)
|
|
279
|
+
where.push(HIDE_EVAL);
|
|
277
280
|
const params = { projectKey, limit: query.limit + 1 };
|
|
278
281
|
if (agentId !== undefined) {
|
|
279
282
|
where.push("agent_id = @agentId");
|
|
@@ -327,17 +330,17 @@ export class AgentStore {
|
|
|
327
330
|
};
|
|
328
331
|
}
|
|
329
332
|
/** One visitor's sessions on one agent, newest first (public web chat). */
|
|
330
|
-
listSessionsForRef(projectKey, agentId, source, sourceRef, limit) {
|
|
333
|
+
listSessionsForRef(projectKey, agentId, source, sourceRef, limit, includeEval = false) {
|
|
331
334
|
return this.db
|
|
332
335
|
.prepare(`SELECT * FROM agent_sessions
|
|
333
|
-
WHERE project_key = ? AND agent_id = ? AND source = ? AND source_ref = ?
|
|
336
|
+
WHERE project_key = ? AND agent_id = ? AND source = ? AND source_ref = ?${includeEval ? "" : ` AND ${HIDE_EVAL}`}
|
|
334
337
|
ORDER BY updated_at DESC, session_id DESC LIMIT ?`)
|
|
335
338
|
.all(projectKey, agentId, source, sourceRef, limit).map(toSession);
|
|
336
339
|
}
|
|
337
340
|
/** Stats for one agent, or for every agent when `agentId` is omitted. */
|
|
338
|
-
sessionStats(projectKey, agentId, since) {
|
|
339
|
-
const agentFilter = agentId === undefined ? "" : " AND agent_id = @agentId";
|
|
340
|
-
const sessionAgentFilter = agentId === undefined ? "" : " AND s.agent_id = @agentId";
|
|
341
|
+
sessionStats(projectKey, agentId, since, includeEval = false) {
|
|
342
|
+
const agentFilter = (agentId === undefined ? "" : " AND agent_id = @agentId") + (includeEval ? "" : ` AND ${HIDE_EVAL}`);
|
|
343
|
+
const sessionAgentFilter = (agentId === undefined ? "" : " AND s.agent_id = @agentId") + (includeEval ? "" : ` AND s.${HIDE_EVAL}`);
|
|
341
344
|
const bind = (extra) => (agentId === undefined ? extra : { ...extra, agentId });
|
|
342
345
|
const row = this.db
|
|
343
346
|
.prepare(`SELECT COUNT(*) AS total,
|
|
@@ -367,6 +370,41 @@ export class AgentStore {
|
|
|
367
370
|
costTotal: numOrNull(turns.cost_all),
|
|
368
371
|
};
|
|
369
372
|
}
|
|
373
|
+
/** Eval sessions below a session or an eval run: those whose `source_ref` is it, and theirs, recursively. */
|
|
374
|
+
listChildSessions(parentId) {
|
|
375
|
+
return this.db
|
|
376
|
+
.prepare(`WITH RECURSIVE below(session_id) AS (
|
|
377
|
+
SELECT session_id FROM agent_sessions WHERE source = 'eval' AND source_ref = ?
|
|
378
|
+
UNION
|
|
379
|
+
SELECT s.session_id FROM agent_sessions s JOIN below b ON s.source_ref = b.session_id WHERE s.source = 'eval'
|
|
380
|
+
)
|
|
381
|
+
SELECT s.* FROM agent_sessions s JOIN below b ON b.session_id = s.session_id ORDER BY s.created_at, s.session_id`)
|
|
382
|
+
.all(parentId).map(toSession);
|
|
383
|
+
}
|
|
384
|
+
/** Root eval sessions (those pointing at an eval run, not at a parent session), optionally of given runs or older than a time. */
|
|
385
|
+
listEvalRootSessions(filter = {}) {
|
|
386
|
+
const clauses = [`source = 'eval'`, `(source_ref IS NULL OR source_ref NOT IN (SELECT session_id FROM agent_sessions))`];
|
|
387
|
+
const params = [];
|
|
388
|
+
if (filter.sourceRefs) {
|
|
389
|
+
if (filter.sourceRefs.length === 0)
|
|
390
|
+
return [];
|
|
391
|
+
clauses.push(`source_ref IN (${filter.sourceRefs.map(() => "?").join(", ")})`);
|
|
392
|
+
params.push(...filter.sourceRefs);
|
|
393
|
+
}
|
|
394
|
+
if (filter.createdBefore) {
|
|
395
|
+
clauses.push(`created_at < ?`);
|
|
396
|
+
params.push(filter.createdBefore);
|
|
397
|
+
}
|
|
398
|
+
return this.db.prepare(`SELECT * FROM agent_sessions WHERE ${clauses.join(" AND ")} ORDER BY created_at, session_id`).all(...params).map(toSession);
|
|
399
|
+
}
|
|
400
|
+
/** Delete eval sessions; messages, turns, spans, scores and approvals go with them. Never touches other sessions. */
|
|
401
|
+
deleteSessions(sessionIds) {
|
|
402
|
+
this.transaction(() => {
|
|
403
|
+
const remove = this.db.prepare(`DELETE FROM agent_sessions WHERE session_id = ? AND source = 'eval'`);
|
|
404
|
+
for (const sessionId of sessionIds)
|
|
405
|
+
remove.run(sessionId);
|
|
406
|
+
});
|
|
407
|
+
}
|
|
370
408
|
/** Ids of every session an agent has had, for releasing what a runtime holds for them. */
|
|
371
409
|
sessionIdsOf(projectKey, agentId) {
|
|
372
410
|
return this.db.prepare(`SELECT session_id FROM agent_sessions WHERE project_key = ? AND agent_id = ?`).all(projectKey, agentId).map((row) => str(row.session_id));
|
|
@@ -562,10 +600,10 @@ export class AgentStore {
|
|
|
562
600
|
.prepare(`SELECT * FROM agent_approvals WHERE session_id = ? ORDER BY created_at`)
|
|
563
601
|
.all(sessionId).map(toApproval);
|
|
564
602
|
}
|
|
565
|
-
listPendingApprovals(projectKey) {
|
|
603
|
+
listPendingApprovals(projectKey, includeEval = false) {
|
|
566
604
|
return this.db
|
|
567
605
|
.prepare(`SELECT a.*, s.agent_id FROM agent_approvals a JOIN agent_sessions s ON s.session_id = a.session_id
|
|
568
|
-
WHERE s.project_key = ? AND a.status = 'pending' ORDER BY a.created_at`)
|
|
606
|
+
WHERE s.project_key = ? AND a.status = 'pending'${includeEval ? "" : ` AND s.${HIDE_EVAL}`} ORDER BY a.created_at`)
|
|
569
607
|
.all(projectKey).map((row) => ({ ...toApproval(row), agentId: str(row.agent_id) }));
|
|
570
608
|
}
|
|
571
609
|
decideApproval(approvalId, patch) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type AgentDefinition } from "../config/loadAgent.js";
|
|
2
|
+
export type ToolClass = "read" | "write" | "shell" | "destructive" | "external" | "mcp_unknown" | "sub_agent" | "browser" | "operator_only";
|
|
3
|
+
export type ToolClassification = {
|
|
4
|
+
class: ToolClass;
|
|
5
|
+
readOnly: boolean;
|
|
6
|
+
};
|
|
7
|
+
type Grants = Pick<AgentDefinition, "tools" | "sub_agents">;
|
|
8
|
+
/**
|
|
9
|
+
* What an eval may assume about a tool. `readOnly` is true only for what is provably read-only (builtin read tools,
|
|
10
|
+
* Stageflow tools with risk `read`) or an MCP tool the eval author declares in `read_only_tools` (a declaration never changes a builtin or Stageflow tool). Sub-agents and
|
|
11
|
+
* operator-only tools are never read-only.
|
|
12
|
+
*/
|
|
13
|
+
export declare function classifyTool(_definition: Grants | undefined, toolId: string, readOnlyExtra?: readonly string[]): ToolClassification;
|
|
14
|
+
export type ToolRiskEntry = {
|
|
15
|
+
tool: string;
|
|
16
|
+
class: ToolClass;
|
|
17
|
+
readOnly: boolean;
|
|
18
|
+
};
|
|
19
|
+
/** Every tool the agent is granted with how the `read_only` policy would treat it, for the eval picker. MCP wildcards stay as `<server>.*`. */
|
|
20
|
+
export declare function toolRiskSummary(definition: Grants, readOnlyExtra?: readonly string[]): ToolRiskEntry[];
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { grantedToolIds } from "../config/loadAgent.js";
|
|
2
|
+
import { isOperatorOnlyTool, STAGEFLOW_GRANT_PREFIX, TOOL_META } from "../toolkit/meta.js";
|
|
3
|
+
import { BUILTIN_TOOL_GROUP_OF } from "./runtime/types.js";
|
|
4
|
+
function listed(toolId, readOnlyExtra) {
|
|
5
|
+
if (readOnlyExtra.includes(toolId))
|
|
6
|
+
return true;
|
|
7
|
+
const dot = toolId.indexOf(".");
|
|
8
|
+
return dot > 0 && readOnlyExtra.includes(`${toolId.slice(0, dot)}.*`);
|
|
9
|
+
}
|
|
10
|
+
function baseClass(toolId) {
|
|
11
|
+
if (toolId === "browser")
|
|
12
|
+
return "browser";
|
|
13
|
+
if (toolId.startsWith("agent:"))
|
|
14
|
+
return "sub_agent";
|
|
15
|
+
if (toolId.startsWith(STAGEFLOW_GRANT_PREFIX)) {
|
|
16
|
+
const name = toolId.slice(STAGEFLOW_GRANT_PREFIX.length);
|
|
17
|
+
const meta = TOOL_META[name];
|
|
18
|
+
if (!meta)
|
|
19
|
+
return "mcp_unknown";
|
|
20
|
+
if (isOperatorOnlyTool(name))
|
|
21
|
+
return "operator_only";
|
|
22
|
+
return meta.risk;
|
|
23
|
+
}
|
|
24
|
+
const builtin = BUILTIN_TOOL_GROUP_OF[toolId];
|
|
25
|
+
if (builtin)
|
|
26
|
+
return builtin;
|
|
27
|
+
return "mcp_unknown";
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* What an eval may assume about a tool. `readOnly` is true only for what is provably read-only (builtin read tools,
|
|
31
|
+
* Stageflow tools with risk `read`) or an MCP tool the eval author declares in `read_only_tools` (a declaration never changes a builtin or Stageflow tool). Sub-agents and
|
|
32
|
+
* operator-only tools are never read-only.
|
|
33
|
+
*/
|
|
34
|
+
export function classifyTool(_definition, toolId, readOnlyExtra = []) {
|
|
35
|
+
let cls = baseClass(toolId);
|
|
36
|
+
if (cls === "operator_only" || cls === "sub_agent")
|
|
37
|
+
return { class: cls, readOnly: false };
|
|
38
|
+
const declared = listed(toolId, readOnlyExtra);
|
|
39
|
+
if (declared && cls === "mcp_unknown")
|
|
40
|
+
cls = "read";
|
|
41
|
+
return { class: cls, readOnly: cls === "read" };
|
|
42
|
+
}
|
|
43
|
+
/** Every tool the agent is granted with how the `read_only` policy would treat it, for the eval picker. MCP wildcards stay as `<server>.*`. */
|
|
44
|
+
export function toolRiskSummary(definition, readOnlyExtra = []) {
|
|
45
|
+
const ids = new Set(grantedToolIds(definition));
|
|
46
|
+
for (const [server, tools] of Object.entries(definition.tools.mcp))
|
|
47
|
+
if (tools.includes("*"))
|
|
48
|
+
ids.add(`${server}.*`);
|
|
49
|
+
return [...ids].sort().map((tool) => ({ tool, ...classifyTool(definition, tool, readOnlyExtra) }));
|
|
50
|
+
}
|
|
@@ -9,6 +9,8 @@ import { warnMissingCaPaths } from "../preflight/tls.js";
|
|
|
9
9
|
import { runPipelinePreflight, } from "../preflight/pipelinePreflight.js";
|
|
10
10
|
import { loadPipelineOutcome } from "../config/loadPipeline.js";
|
|
11
11
|
import { MCP_CATALOG_FILENAME } from "../config/resolveStageMcpServers.js";
|
|
12
|
+
import { MIN_NODE } from "../evals/engine/promptfoo/pinned.js";
|
|
13
|
+
import { engineStatus } from "../evals/engine/promptfoo/status.js";
|
|
12
14
|
import { globalStageflowHome } from "../project/globalHome.js";
|
|
13
15
|
import { createRunStore } from "../runstore/createStore.js";
|
|
14
16
|
import { readFilesystemSize, resolveMinFreeDiskFloor, } from "../runstore/diskUsage.js";
|
|
@@ -142,6 +144,29 @@ function nodeVersionCheck() {
|
|
|
142
144
|
message: `Node ${process.version}; engines floor may differ from Pi/better-sqlite3 (not bumping engines.node)`,
|
|
143
145
|
};
|
|
144
146
|
}
|
|
147
|
+
function evalEngineCheck(home) {
|
|
148
|
+
const status = engineStatus({ home });
|
|
149
|
+
if (!status.installed) {
|
|
150
|
+
return {
|
|
151
|
+
id: "eval_engine",
|
|
152
|
+
status: "skipped",
|
|
153
|
+
message: `Eval engine not installed (optional; promptfoo ${status.pinned}). Run \`${status.installCommand}\``,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
if (!status.nodeOk) {
|
|
157
|
+
return {
|
|
158
|
+
id: "eval_engine",
|
|
159
|
+
status: "warn",
|
|
160
|
+
code: "EVAL_NODE_TOO_OLD",
|
|
161
|
+
message: `Eval engine promptfoo ${status.version} installed, but Node ${status.node} is below the ${MIN_NODE} evals need`,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
id: "eval_engine",
|
|
166
|
+
status: "pass",
|
|
167
|
+
message: `Eval engine promptfoo ${status.version}`,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
145
170
|
function discoverProviderEnvIds(env) {
|
|
146
171
|
const byLower = new Set();
|
|
147
172
|
for (const key of Object.keys(env)) {
|
|
@@ -355,6 +380,7 @@ export async function runDoctorChecks(options) {
|
|
|
355
380
|
checks.push(tlsCheck(env));
|
|
356
381
|
checks.push(await freeDiskCheck(home, env));
|
|
357
382
|
checks.push(...(await mcpCommandsCheck(cwd)));
|
|
383
|
+
checks.push(evalEngineCheck(home));
|
|
358
384
|
let preflight;
|
|
359
385
|
if (options?.pipeline !== undefined) {
|
|
360
386
|
const outcome = await loadPipelineOutcome(options.pipeline, { cwd });
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type RunNpm } from "../evals/engine/promptfoo/install.js";
|
|
2
|
+
import { type EnsureGlobalServiceResult } from "../server/ensureGlobalService.js";
|
|
3
|
+
export declare const EVAL_USAGE = "Usage:\n sf eval list [--json]\n sf eval show <id|path> [--json]\n sf eval validate [<id|path>] [--json] [--strict]\n sf eval run <id|path> [--repeats <n>] [--judge <model>] [--model <id>] [--user-model <model>] [--allow-real-tools] [--max-cost <usd>] [--case <id> ...] [--tag <tag> ...] [--label <text>] [--no-wait] [--json]\n sf eval runs [<evalId>] [--json]\n sf eval runs show <evalRunId> [--json]\n sf eval runs cancel <evalRunId>\n sf eval runs delete <evalRunId>\n sf eval sort <evalRunId> [--classifier auto|jev|judge] [--limit <n>] [--resort] [--json]\n sf eval suggestions <evalRunId> [--status pending|accepted|dismissed] [--json]\n sf eval compare <evalRunIdA> <evalRunIdB> [--json]\n sf eval datasets [--json]\n sf eval engine status [--json]\n sf eval engine install\n\n Agent evals: --model overrides the agent's model, --user-model the model that plays the user. An eval whose\n conversation.tools is real also needs --allow-real-tools.\n\n Every subcommand also accepts --project-root <id-or-path>.";
|
|
4
|
+
export type EvalCommandIo = {
|
|
5
|
+
log: (line: string) => void;
|
|
6
|
+
error: (line: string) => void;
|
|
7
|
+
};
|
|
8
|
+
export type EvalCommandOptions = {
|
|
9
|
+
cwd?: string;
|
|
10
|
+
projectRoot?: string;
|
|
11
|
+
io?: Partial<EvalCommandIo>;
|
|
12
|
+
hostBaseUrl?: string;
|
|
13
|
+
ensureService?: () => Promise<EnsureGlobalServiceResult>;
|
|
14
|
+
home?: string;
|
|
15
|
+
runNpm?: RunNpm;
|
|
16
|
+
pollIntervalMs?: number;
|
|
17
|
+
stderrIsTTY?: boolean;
|
|
18
|
+
onInterrupt?: (handler: () => void) => () => void;
|
|
19
|
+
};
|
|
20
|
+
export declare function runEvalCommand(args: string[], options?: EvalCommandOptions): Promise<number>;
|