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,191 @@
|
|
|
1
|
+
export type SnapshotOverrides = {
|
|
2
|
+
repeats: number | null;
|
|
3
|
+
judge: string | null;
|
|
4
|
+
model: string | null;
|
|
5
|
+
max_cost_usd: number | null;
|
|
6
|
+
case_ids: string[] | null;
|
|
7
|
+
tags: string[] | null;
|
|
8
|
+
only_failed_from: string | null;
|
|
9
|
+
user_model?: string | null;
|
|
10
|
+
tools?: string | null;
|
|
11
|
+
approvals?: string | null;
|
|
12
|
+
};
|
|
13
|
+
export type SnapshotGrader = {
|
|
14
|
+
id: string;
|
|
15
|
+
type: string;
|
|
16
|
+
hash: string;
|
|
17
|
+
version_ordinal: number;
|
|
18
|
+
weight: number;
|
|
19
|
+
must_pass: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type StageSnapshotTarget = {
|
|
22
|
+
kind: "stage";
|
|
23
|
+
pipeline_path: string | null;
|
|
24
|
+
stage_id: string | null;
|
|
25
|
+
file: string | null;
|
|
26
|
+
stage_version_hash: string;
|
|
27
|
+
stage_definition: Record<string, unknown>;
|
|
28
|
+
model: string;
|
|
29
|
+
model_tier: string;
|
|
30
|
+
input_schema_hash: string | null;
|
|
31
|
+
output_schema_hash: string | null;
|
|
32
|
+
};
|
|
33
|
+
export type AgentLimitSet = {
|
|
34
|
+
max_turns: number | null;
|
|
35
|
+
session_minutes: number | null;
|
|
36
|
+
cost_usd: number | null;
|
|
37
|
+
always_on: boolean;
|
|
38
|
+
};
|
|
39
|
+
export type AgentSnapshotTarget = {
|
|
40
|
+
kind: "agent";
|
|
41
|
+
agent_id: string;
|
|
42
|
+
revision: number;
|
|
43
|
+
definition_hash: string;
|
|
44
|
+
definition: Record<string, unknown>;
|
|
45
|
+
model: string;
|
|
46
|
+
model_tier: string;
|
|
47
|
+
tools: Array<{
|
|
48
|
+
id: string;
|
|
49
|
+
risk: string;
|
|
50
|
+
class: string;
|
|
51
|
+
}>;
|
|
52
|
+
ask_first: string[];
|
|
53
|
+
sub_agents: Array<{
|
|
54
|
+
id: string;
|
|
55
|
+
revision: number;
|
|
56
|
+
}>;
|
|
57
|
+
limits_override: {
|
|
58
|
+
agent: AgentLimitSet;
|
|
59
|
+
effective: AgentLimitSet;
|
|
60
|
+
capture: string;
|
|
61
|
+
otlp: boolean;
|
|
62
|
+
groundedness: boolean;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export type ConversationSettings = {
|
|
66
|
+
mode: string;
|
|
67
|
+
max_turns: number;
|
|
68
|
+
turn_timeout_ms: number;
|
|
69
|
+
tools: string;
|
|
70
|
+
approvals: string;
|
|
71
|
+
read_only_tools: string[];
|
|
72
|
+
real_tools_confirmed: boolean;
|
|
73
|
+
user_model: string;
|
|
74
|
+
user_model_from_judge: boolean;
|
|
75
|
+
simulator_prompt_version: number;
|
|
76
|
+
};
|
|
77
|
+
export type InternalAgentSnapshotTarget = {
|
|
78
|
+
kind: "internal_agent";
|
|
79
|
+
profile_id: string;
|
|
80
|
+
title: string;
|
|
81
|
+
playbook_hash: string;
|
|
82
|
+
tools: string[];
|
|
83
|
+
model: string;
|
|
84
|
+
};
|
|
85
|
+
export type ConfigSnapshot = {
|
|
86
|
+
snapshot_version: number;
|
|
87
|
+
eval: {
|
|
88
|
+
id: string;
|
|
89
|
+
path: string;
|
|
90
|
+
hash: string;
|
|
91
|
+
definition: Record<string, unknown>;
|
|
92
|
+
};
|
|
93
|
+
overrides: SnapshotOverrides;
|
|
94
|
+
target: StageSnapshotTarget | AgentSnapshotTarget | InternalAgentSnapshotTarget;
|
|
95
|
+
dataset: {
|
|
96
|
+
path: string;
|
|
97
|
+
hash: string;
|
|
98
|
+
format: string;
|
|
99
|
+
case_count: number;
|
|
100
|
+
cases_run: number;
|
|
101
|
+
cases_skipped: number;
|
|
102
|
+
skipped_case_ids: string[];
|
|
103
|
+
};
|
|
104
|
+
graders: SnapshotGrader[];
|
|
105
|
+
settings: {
|
|
106
|
+
repeats: number;
|
|
107
|
+
pass_threshold: number;
|
|
108
|
+
judge: string;
|
|
109
|
+
judge_same_as_stage: boolean;
|
|
110
|
+
max_cost_usd: number;
|
|
111
|
+
concurrency: number;
|
|
112
|
+
suite_type: string;
|
|
113
|
+
conversation?: ConversationSettings;
|
|
114
|
+
};
|
|
115
|
+
engine: {
|
|
116
|
+
name: string;
|
|
117
|
+
version: string;
|
|
118
|
+
rubric_prompt_version: number;
|
|
119
|
+
node_version: string;
|
|
120
|
+
};
|
|
121
|
+
stageflow_version: string;
|
|
122
|
+
};
|
|
123
|
+
/** Every fingerprint input, as the exact value fingerprinted, so two runs can be diffed by key. */
|
|
124
|
+
export type ConfigComponents = {
|
|
125
|
+
stage: string;
|
|
126
|
+
model: string;
|
|
127
|
+
dataset: string;
|
|
128
|
+
case_ids: string[] | null;
|
|
129
|
+
graders: Record<string, string>;
|
|
130
|
+
judge: string;
|
|
131
|
+
repeats: number;
|
|
132
|
+
pass_threshold: number;
|
|
133
|
+
engine: {
|
|
134
|
+
name: string;
|
|
135
|
+
version: string;
|
|
136
|
+
};
|
|
137
|
+
rubric_prompt_version: number;
|
|
138
|
+
agent?: AgentComponent;
|
|
139
|
+
};
|
|
140
|
+
/** Agent-only fingerprint inputs; absent for stage runs so stage payloads hash identically. */
|
|
141
|
+
export type AgentComponent = {
|
|
142
|
+
revision: number;
|
|
143
|
+
mode: string;
|
|
144
|
+
max_turns: number;
|
|
145
|
+
turn_timeout_ms: number;
|
|
146
|
+
tools: string;
|
|
147
|
+
approvals: string;
|
|
148
|
+
read_only_tools: string[];
|
|
149
|
+
user_model: string | null;
|
|
150
|
+
simulator_prompt_version: number;
|
|
151
|
+
};
|
|
152
|
+
export type ComponentsInput = {
|
|
153
|
+
stageVersionHash: string;
|
|
154
|
+
model: string;
|
|
155
|
+
datasetHash: string;
|
|
156
|
+
caseIds: readonly string[] | null;
|
|
157
|
+
graders: ReadonlyArray<{
|
|
158
|
+
id: string;
|
|
159
|
+
hash: string;
|
|
160
|
+
}>;
|
|
161
|
+
judge: string;
|
|
162
|
+
repeats: number;
|
|
163
|
+
passThreshold: number;
|
|
164
|
+
engine: {
|
|
165
|
+
name: string;
|
|
166
|
+
version: string;
|
|
167
|
+
};
|
|
168
|
+
rubricPromptVersion?: number;
|
|
169
|
+
agent?: AgentComponent;
|
|
170
|
+
};
|
|
171
|
+
export declare function buildComponents(input: ComponentsInput): ConfigComponents;
|
|
172
|
+
/** First 8 hex of sha256 over the canonical fingerprint payload. */
|
|
173
|
+
export declare function computeFingerprint(components: ConfigComponents): string;
|
|
174
|
+
export type SnapshotInput = {
|
|
175
|
+
evalId: string;
|
|
176
|
+
evalPath: string;
|
|
177
|
+
evalHash: string;
|
|
178
|
+
evalDefinition: Record<string, unknown>;
|
|
179
|
+
overrides: SnapshotOverrides;
|
|
180
|
+
target: Omit<StageSnapshotTarget, "kind"> | Omit<AgentSnapshotTarget, "kind"> | Omit<InternalAgentSnapshotTarget, "kind">;
|
|
181
|
+
dataset: ConfigSnapshot["dataset"];
|
|
182
|
+
graders: SnapshotGrader[];
|
|
183
|
+
settings: ConfigSnapshot["settings"];
|
|
184
|
+
engine: {
|
|
185
|
+
name: string;
|
|
186
|
+
version: string;
|
|
187
|
+
nodeVersion: string;
|
|
188
|
+
};
|
|
189
|
+
stageflowVersion: string;
|
|
190
|
+
};
|
|
191
|
+
export declare function buildSnapshot(input: SnapshotInput): ConfigSnapshot;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { canonicalJson, sha256Hex } from "./canonical.js";
|
|
2
|
+
import { CONFIG_SNAPSHOT_VERSION, CONVERSATION_RUBRIC_PROMPT_VERSION, RUBRIC_PROMPT_VERSION } from "./constants.js";
|
|
3
|
+
export function buildComponents(input) {
|
|
4
|
+
const graders = {};
|
|
5
|
+
for (const grader of [...input.graders].sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0))) {
|
|
6
|
+
graders[grader.id] = grader.hash;
|
|
7
|
+
}
|
|
8
|
+
const agent = input.agent;
|
|
9
|
+
return {
|
|
10
|
+
stage: input.stageVersionHash,
|
|
11
|
+
model: input.model,
|
|
12
|
+
dataset: input.datasetHash,
|
|
13
|
+
case_ids: input.caseIds === null ? null : [...input.caseIds].sort(),
|
|
14
|
+
graders,
|
|
15
|
+
judge: input.judge,
|
|
16
|
+
repeats: input.repeats,
|
|
17
|
+
pass_threshold: input.passThreshold,
|
|
18
|
+
engine: { name: input.engine.name, version: input.engine.version },
|
|
19
|
+
rubric_prompt_version: input.rubricPromptVersion ?? (agent ? CONVERSATION_RUBRIC_PROMPT_VERSION : RUBRIC_PROMPT_VERSION),
|
|
20
|
+
...(agent ? { agent: { ...agent, read_only_tools: [...agent.read_only_tools].sort() } } : {}),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** First 8 hex of sha256 over the canonical fingerprint payload. */
|
|
24
|
+
export function computeFingerprint(components) {
|
|
25
|
+
const payload = {
|
|
26
|
+
stage_version_hash: components.stage,
|
|
27
|
+
model: components.model,
|
|
28
|
+
dataset_hash: components.dataset,
|
|
29
|
+
case_ids: components.case_ids,
|
|
30
|
+
graders: Object.entries(components.graders)
|
|
31
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
32
|
+
.map(([id, hash]) => ({ id, hash })),
|
|
33
|
+
repeats: components.repeats,
|
|
34
|
+
pass_threshold: components.pass_threshold,
|
|
35
|
+
judge: components.judge,
|
|
36
|
+
engine: components.engine,
|
|
37
|
+
rubric_prompt_version: components.rubric_prompt_version,
|
|
38
|
+
...(components.agent ? { agent: components.agent } : {}),
|
|
39
|
+
};
|
|
40
|
+
return sha256Hex(canonicalJson(payload)).slice(0, 8);
|
|
41
|
+
}
|
|
42
|
+
export function buildSnapshot(input) {
|
|
43
|
+
const internalTarget = "profile_id" in input.target ? input.target : null;
|
|
44
|
+
const agentTarget = !internalTarget && "agent_id" in input.target ? input.target : null;
|
|
45
|
+
return {
|
|
46
|
+
snapshot_version: CONFIG_SNAPSHOT_VERSION,
|
|
47
|
+
eval: {
|
|
48
|
+
id: input.evalId,
|
|
49
|
+
path: input.evalPath,
|
|
50
|
+
hash: input.evalHash,
|
|
51
|
+
definition: input.evalDefinition,
|
|
52
|
+
},
|
|
53
|
+
overrides: input.overrides,
|
|
54
|
+
target: internalTarget
|
|
55
|
+
? { kind: "internal_agent", ...internalTarget }
|
|
56
|
+
: agentTarget
|
|
57
|
+
? { kind: "agent", ...agentTarget }
|
|
58
|
+
: { kind: "stage", ...input.target },
|
|
59
|
+
dataset: input.dataset,
|
|
60
|
+
graders: input.graders,
|
|
61
|
+
settings: input.settings,
|
|
62
|
+
engine: {
|
|
63
|
+
name: input.engine.name,
|
|
64
|
+
version: input.engine.version,
|
|
65
|
+
rubric_prompt_version: agentTarget || internalTarget ? CONVERSATION_RUBRIC_PROMPT_VERSION : RUBRIC_PROMPT_VERSION,
|
|
66
|
+
node_version: input.engine.nodeVersion,
|
|
67
|
+
},
|
|
68
|
+
stageflow_version: input.stageflowVersion,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type DiffLine } from "./lineDiff.js";
|
|
2
|
+
export interface StageDiff {
|
|
3
|
+
changed_keys: string[];
|
|
4
|
+
system_prompt_diff: DiffLine[] | null;
|
|
5
|
+
}
|
|
6
|
+
type Json = unknown;
|
|
7
|
+
export declare function stageDiff(defA: Record<string, Json>, defB: Record<string, Json>): StageDiff;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { lineDiff } from "./lineDiff.js";
|
|
2
|
+
function canonical(value) {
|
|
3
|
+
if (value === undefined)
|
|
4
|
+
return "undefined";
|
|
5
|
+
return JSON.stringify(sortKeys(value));
|
|
6
|
+
}
|
|
7
|
+
function sortKeys(value) {
|
|
8
|
+
if (Array.isArray(value))
|
|
9
|
+
return value.map(sortKeys);
|
|
10
|
+
if (value && typeof value === "object") {
|
|
11
|
+
const obj = value;
|
|
12
|
+
return Object.fromEntries(Object.keys(obj)
|
|
13
|
+
.sort()
|
|
14
|
+
.map((k) => [k, sortKeys(obj[k])]));
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
function asRecord(value) {
|
|
19
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
20
|
+
? value
|
|
21
|
+
: {};
|
|
22
|
+
}
|
|
23
|
+
export function stageDiff(defA, defB) {
|
|
24
|
+
const keys = [...new Set([...Object.keys(defA), ...Object.keys(defB)])].sort();
|
|
25
|
+
const changed = [];
|
|
26
|
+
for (const key of keys) {
|
|
27
|
+
if (canonical(defA[key]) === canonical(defB[key]))
|
|
28
|
+
continue;
|
|
29
|
+
if (key === "io") {
|
|
30
|
+
const ioA = asRecord(defA.io);
|
|
31
|
+
const ioB = asRecord(defB.io);
|
|
32
|
+
const parts = ["input", "output"].filter((p) => canonical(ioA[p]) !== canonical(ioB[p]));
|
|
33
|
+
if (parts.length === 0)
|
|
34
|
+
changed.push("io");
|
|
35
|
+
else
|
|
36
|
+
for (const p of parts)
|
|
37
|
+
changed.push(`io.${p}`);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
changed.push(key);
|
|
41
|
+
}
|
|
42
|
+
const promptChanged = changed.includes("system_prompt");
|
|
43
|
+
const text = (v) => (typeof v === "string" ? v : v === undefined ? "" : canonical(v));
|
|
44
|
+
return {
|
|
45
|
+
changed_keys: changed,
|
|
46
|
+
system_prompt_diff: promptChanged ? lineDiff(text(defA.system_prompt), text(defB.system_prompt)) : null,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type GradeRecord, type GraderRef, type PreviousRunLite, type ResultRecord } from "./statsTypes.js";
|
|
2
|
+
export interface ComputeStatsInput {
|
|
3
|
+
results: ResultRecord[];
|
|
4
|
+
grades: GradeRecord[];
|
|
5
|
+
graders: GraderRef[];
|
|
6
|
+
repeats: number;
|
|
7
|
+
passThreshold: number;
|
|
8
|
+
reviewsTags?: Map<string, string[]>;
|
|
9
|
+
previousRun?: PreviousRunLite | null;
|
|
10
|
+
targetKind?: "stage" | "agent";
|
|
11
|
+
}
|
|
12
|
+
export interface CaseStat {
|
|
13
|
+
caseId: string;
|
|
14
|
+
executed: number;
|
|
15
|
+
passed: number;
|
|
16
|
+
p: number;
|
|
17
|
+
flags: boolean[];
|
|
18
|
+
meanScore: number | null;
|
|
19
|
+
}
|
|
20
|
+
export interface Interval {
|
|
21
|
+
low: number;
|
|
22
|
+
high: number;
|
|
23
|
+
}
|
|
24
|
+
export declare const LOWEST_CASES_LIMIT = 5;
|
|
25
|
+
export interface LowestCase {
|
|
26
|
+
case_id: string;
|
|
27
|
+
mean_score: number;
|
|
28
|
+
worst_repeat_index: number;
|
|
29
|
+
}
|
|
30
|
+
export interface GraderStat {
|
|
31
|
+
grader_id: string;
|
|
32
|
+
type: string;
|
|
33
|
+
hash: string;
|
|
34
|
+
graded: number;
|
|
35
|
+
passed: number;
|
|
36
|
+
pass_rate: number | null;
|
|
37
|
+
mean_raw: number | null;
|
|
38
|
+
min_raw: number | null;
|
|
39
|
+
max_raw: number | null;
|
|
40
|
+
errors: number;
|
|
41
|
+
delta: number | null;
|
|
42
|
+
grader_changed: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface FailingCase {
|
|
45
|
+
case_id: string;
|
|
46
|
+
pass_rate: number;
|
|
47
|
+
mean_score: number | null;
|
|
48
|
+
passes: boolean[];
|
|
49
|
+
}
|
|
50
|
+
export interface Stats {
|
|
51
|
+
cases_counted: number;
|
|
52
|
+
results_executed: number;
|
|
53
|
+
results_passed: number;
|
|
54
|
+
errored: number;
|
|
55
|
+
pass_rate: number | null;
|
|
56
|
+
pass_rate_ci: Interval | null;
|
|
57
|
+
mean_score: number | null;
|
|
58
|
+
score_spread: number | null;
|
|
59
|
+
reliability: number | null;
|
|
60
|
+
pass_any: number | null;
|
|
61
|
+
flaky_cases: string[];
|
|
62
|
+
latency_p50: number | null;
|
|
63
|
+
latency_p95: number | null;
|
|
64
|
+
latency_max: number | null;
|
|
65
|
+
cost_stage: number;
|
|
66
|
+
cost_judge: number;
|
|
67
|
+
cost_total: number;
|
|
68
|
+
cost_per_result: number | null;
|
|
69
|
+
tokens_in: number;
|
|
70
|
+
tokens_out: number;
|
|
71
|
+
judge_tokens_in: number;
|
|
72
|
+
judge_tokens_out: number;
|
|
73
|
+
by_grader: GraderStat[];
|
|
74
|
+
score_histogram: {
|
|
75
|
+
bins: number[];
|
|
76
|
+
threshold: number;
|
|
77
|
+
};
|
|
78
|
+
failure_types: {
|
|
79
|
+
by_tag: Record<string, number>;
|
|
80
|
+
untagged: number;
|
|
81
|
+
};
|
|
82
|
+
failing_cases: FailingCase[];
|
|
83
|
+
mean_turns?: number | null;
|
|
84
|
+
mean_tool_calls?: number | null;
|
|
85
|
+
}
|
|
86
|
+
export declare function isExecuted(result: ResultRecord): boolean;
|
|
87
|
+
export declare function mean(values: number[]): number | null;
|
|
88
|
+
export declare function sampleSd(values: number[]): number | null;
|
|
89
|
+
export declare function passFraction(passed: number, executed: number): number | null;
|
|
90
|
+
export declare function lowestCases(grades: GradeRecord[], limit?: number): LowestCase[];
|
|
91
|
+
export declare function percentile(sorted: number[], q: number): number | null;
|
|
92
|
+
export declare function clusteredCi(center: number, perCase: number[], lo: number, hi: number): Interval | null;
|
|
93
|
+
export declare function buildCaseStats(results: ResultRecord[]): CaseStat[];
|
|
94
|
+
export declare function computeByGrader(graders: GraderRef[], grades: GradeRecord[], previousRun: PreviousRunLite | null | undefined): GraderStat[];
|
|
95
|
+
export declare function computeStats(input: ComputeStatsInput): Stats;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { tQuantile } from "./tTable.js";
|
|
2
|
+
import { EXECUTED_RESULT_STATUSES, resultKey, } from "./statsTypes.js";
|
|
3
|
+
export const LOWEST_CASES_LIMIT = 5;
|
|
4
|
+
const EPS = 1e-9;
|
|
5
|
+
export function isExecuted(result) {
|
|
6
|
+
return EXECUTED_RESULT_STATUSES.includes(result.status);
|
|
7
|
+
}
|
|
8
|
+
export function mean(values) {
|
|
9
|
+
if (values.length === 0)
|
|
10
|
+
return null;
|
|
11
|
+
return values.reduce((a, b) => a + b, 0) / values.length;
|
|
12
|
+
}
|
|
13
|
+
export function sampleSd(values) {
|
|
14
|
+
if (values.length < 2)
|
|
15
|
+
return null;
|
|
16
|
+
const m = values.reduce((a, b) => a + b, 0) / values.length;
|
|
17
|
+
const ss = values.reduce((a, b) => a + (b - m) ** 2, 0);
|
|
18
|
+
return Math.sqrt(ss / (values.length - 1));
|
|
19
|
+
}
|
|
20
|
+
export function passFraction(passed, executed) {
|
|
21
|
+
return executed > 0 ? passed / executed : null;
|
|
22
|
+
}
|
|
23
|
+
export function lowestCases(grades, limit = LOWEST_CASES_LIMIT) {
|
|
24
|
+
const byCase = new Map();
|
|
25
|
+
for (const g of grades) {
|
|
26
|
+
if (g.status !== "graded" || g.score === null)
|
|
27
|
+
continue;
|
|
28
|
+
const list = byCase.get(g.caseId);
|
|
29
|
+
if (list)
|
|
30
|
+
list.push({ repeat: g.repeatIndex, score: g.score });
|
|
31
|
+
else
|
|
32
|
+
byCase.set(g.caseId, [{ repeat: g.repeatIndex, score: g.score }]);
|
|
33
|
+
}
|
|
34
|
+
const rows = [...byCase.entries()].map(([caseId, list]) => {
|
|
35
|
+
const worst = [...list].sort((a, b) => a.score - b.score || a.repeat - b.repeat)[0];
|
|
36
|
+
return {
|
|
37
|
+
case_id: caseId,
|
|
38
|
+
mean_score: mean(list.map((item) => item.score)),
|
|
39
|
+
worst_repeat_index: worst.repeat,
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
rows.sort((a, b) => a.mean_score - b.mean_score || (a.case_id < b.case_id ? -1 : a.case_id > b.case_id ? 1 : 0));
|
|
43
|
+
return rows.slice(0, limit);
|
|
44
|
+
}
|
|
45
|
+
export function percentile(sorted, q) {
|
|
46
|
+
if (sorted.length === 0)
|
|
47
|
+
return null;
|
|
48
|
+
const rank = Math.ceil(Math.round(q * sorted.length * 1e9) / 1e9);
|
|
49
|
+
return sorted[Math.min(sorted.length, Math.max(1, rank)) - 1];
|
|
50
|
+
}
|
|
51
|
+
export function clusteredCi(center, perCase, lo, hi) {
|
|
52
|
+
const n = perCase.length;
|
|
53
|
+
if (n < 2)
|
|
54
|
+
return null;
|
|
55
|
+
const pBar = perCase.reduce((a, b) => a + b, 0) / n;
|
|
56
|
+
const ss = perCase.reduce((a, b) => a + (b - pBar) ** 2, 0);
|
|
57
|
+
const se = Math.sqrt(ss / (n * (n - 1)));
|
|
58
|
+
const half = tQuantile(n - 1) * se;
|
|
59
|
+
return { low: Math.max(lo, center - half), high: Math.min(hi, center + half) };
|
|
60
|
+
}
|
|
61
|
+
export function buildCaseStats(results) {
|
|
62
|
+
const byCase = new Map();
|
|
63
|
+
for (const r of results) {
|
|
64
|
+
if (!isExecuted(r))
|
|
65
|
+
continue;
|
|
66
|
+
const list = byCase.get(r.caseId);
|
|
67
|
+
if (list)
|
|
68
|
+
list.push(r);
|
|
69
|
+
else
|
|
70
|
+
byCase.set(r.caseId, [r]);
|
|
71
|
+
}
|
|
72
|
+
const out = [];
|
|
73
|
+
for (const [caseId, list] of byCase) {
|
|
74
|
+
list.sort((a, b) => a.repeatIndex - b.repeatIndex);
|
|
75
|
+
const passed = list.filter((r) => r.passed === 1).length;
|
|
76
|
+
const scores = list
|
|
77
|
+
.filter((r) => r.status === "completed" && r.score !== null)
|
|
78
|
+
.map((r) => r.score);
|
|
79
|
+
out.push({
|
|
80
|
+
caseId,
|
|
81
|
+
executed: list.length,
|
|
82
|
+
passed,
|
|
83
|
+
p: passFraction(passed, list.length),
|
|
84
|
+
flags: list.map((r) => r.passed === 1),
|
|
85
|
+
meanScore: mean(scores),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return out;
|
|
89
|
+
}
|
|
90
|
+
function sum(values) {
|
|
91
|
+
let total = 0;
|
|
92
|
+
for (const v of values)
|
|
93
|
+
total += v ?? 0;
|
|
94
|
+
return total;
|
|
95
|
+
}
|
|
96
|
+
export function computeByGrader(graders, grades, previousRun) {
|
|
97
|
+
return graders.map((g) => {
|
|
98
|
+
const own = grades.filter((x) => x.graderId === g.id);
|
|
99
|
+
const graded = own.filter((x) => x.status === "graded");
|
|
100
|
+
const passed = graded.filter((x) => x.passed === 1).length;
|
|
101
|
+
const raws = graded.map((x) => x.rawValue).filter((v) => v !== null);
|
|
102
|
+
const passRate = graded.length > 0 ? passed / graded.length : null;
|
|
103
|
+
const prev = previousRun?.graders.find((p) => p.graderId === g.id);
|
|
104
|
+
const sameHash = prev !== undefined && prev.hash === g.hash;
|
|
105
|
+
const delta = sameHash && passRate !== null && prev.passRate !== null
|
|
106
|
+
? (passRate - prev.passRate) * 100
|
|
107
|
+
: null;
|
|
108
|
+
return {
|
|
109
|
+
grader_id: g.id,
|
|
110
|
+
type: g.type,
|
|
111
|
+
hash: g.hash,
|
|
112
|
+
graded: graded.length,
|
|
113
|
+
passed,
|
|
114
|
+
pass_rate: passRate,
|
|
115
|
+
mean_raw: mean(raws),
|
|
116
|
+
min_raw: raws.length > 0 ? Math.min(...raws) : null,
|
|
117
|
+
max_raw: raws.length > 0 ? Math.max(...raws) : null,
|
|
118
|
+
errors: own.length - graded.length,
|
|
119
|
+
delta,
|
|
120
|
+
grader_changed: prev !== undefined && !sameHash,
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
export function computeStats(input) {
|
|
125
|
+
const executed = input.results.filter(isExecuted);
|
|
126
|
+
const executedKeys = new Set(executed.map((r) => resultKey(r.caseId, r.repeatIndex)));
|
|
127
|
+
const grades = input.grades.filter((g) => executedKeys.has(resultKey(g.caseId, g.repeatIndex)));
|
|
128
|
+
const cases = buildCaseStats(executed);
|
|
129
|
+
const completed = executed.filter((r) => r.status === "completed");
|
|
130
|
+
const resultsExecuted = executed.length;
|
|
131
|
+
const resultsPassed = executed.filter((r) => r.passed === 1).length;
|
|
132
|
+
const passRate = resultsExecuted > 0 ? resultsPassed / resultsExecuted : null;
|
|
133
|
+
const passRateCi = passRate === null
|
|
134
|
+
? null
|
|
135
|
+
: clusteredCi(passRate, cases.map((c) => c.p), 0, 1);
|
|
136
|
+
const scores = completed.filter((r) => r.score !== null).map((r) => r.score);
|
|
137
|
+
const spreads = [];
|
|
138
|
+
for (const c of cases) {
|
|
139
|
+
const caseScores = completed
|
|
140
|
+
.filter((r) => r.caseId === c.caseId && r.score !== null)
|
|
141
|
+
.map((r) => r.score);
|
|
142
|
+
const sd = sampleSd(caseScores);
|
|
143
|
+
if (sd !== null)
|
|
144
|
+
spreads.push(sd);
|
|
145
|
+
}
|
|
146
|
+
const repeatedCases = cases.filter((c) => c.executed >= 2);
|
|
147
|
+
const reliability = input.repeats > 1 && repeatedCases.length > 0
|
|
148
|
+
? repeatedCases.filter((c) => c.passed === c.executed).length / repeatedCases.length
|
|
149
|
+
: null;
|
|
150
|
+
const passAny = input.repeats > 1 && repeatedCases.length > 0
|
|
151
|
+
? repeatedCases.filter((c) => c.passed >= 1).length / repeatedCases.length
|
|
152
|
+
: null;
|
|
153
|
+
const flaky = repeatedCases.filter((c) => c.passed > 0 && c.passed < c.executed).map((c) => c.caseId);
|
|
154
|
+
const latencies = completed
|
|
155
|
+
.map((r) => r.latencyMs)
|
|
156
|
+
.filter((v) => v !== null)
|
|
157
|
+
.sort((a, b) => a - b);
|
|
158
|
+
const costStage = sum(executed.map((r) => r.costUsd));
|
|
159
|
+
const costJudge = sum(grades.map((g) => g.judgeCostUsd));
|
|
160
|
+
const costTotal = costStage + costJudge;
|
|
161
|
+
const bins = new Array(10).fill(0);
|
|
162
|
+
for (const s of scores) {
|
|
163
|
+
const idx = Math.min(9, Math.max(0, Math.floor(s * 10 + EPS)));
|
|
164
|
+
bins[idx] += 1;
|
|
165
|
+
}
|
|
166
|
+
const byTag = {};
|
|
167
|
+
let untagged = 0;
|
|
168
|
+
for (const r of executed) {
|
|
169
|
+
if (r.passed === 1)
|
|
170
|
+
continue;
|
|
171
|
+
const tags = [...new Set(input.reviewsTags?.get(resultKey(r.caseId, r.repeatIndex)) ?? [])];
|
|
172
|
+
if (tags.length === 0)
|
|
173
|
+
untagged += 1;
|
|
174
|
+
for (const tag of tags)
|
|
175
|
+
byTag[tag] = (byTag[tag] ?? 0) + 1;
|
|
176
|
+
}
|
|
177
|
+
const failing = cases
|
|
178
|
+
.filter((c) => c.passed < c.executed)
|
|
179
|
+
.sort((a, b) => a.p - b.p ||
|
|
180
|
+
(a.meanScore ?? 0) - (b.meanScore ?? 0) ||
|
|
181
|
+
(a.caseId < b.caseId ? -1 : a.caseId > b.caseId ? 1 : 0))
|
|
182
|
+
.map((c) => ({
|
|
183
|
+
case_id: c.caseId,
|
|
184
|
+
pass_rate: c.p,
|
|
185
|
+
mean_score: c.meanScore,
|
|
186
|
+
passes: c.flags,
|
|
187
|
+
}));
|
|
188
|
+
const turnValues = executed.flatMap((r) => (r.turns != null ? [r.turns] : []));
|
|
189
|
+
const toolCallValues = executed.flatMap((r) => (r.toolCalls != null ? [r.toolCalls] : []));
|
|
190
|
+
const hasAgentData = input.targetKind === "agent" || input.results.some((r) => r.turns != null || r.toolCalls != null);
|
|
191
|
+
return {
|
|
192
|
+
cases_counted: cases.length,
|
|
193
|
+
results_executed: resultsExecuted,
|
|
194
|
+
results_passed: resultsPassed,
|
|
195
|
+
errored: executed.filter((r) => r.status === "error").length,
|
|
196
|
+
pass_rate: passRate,
|
|
197
|
+
pass_rate_ci: passRateCi,
|
|
198
|
+
mean_score: mean(scores),
|
|
199
|
+
score_spread: mean(spreads),
|
|
200
|
+
reliability,
|
|
201
|
+
pass_any: passAny,
|
|
202
|
+
flaky_cases: flaky,
|
|
203
|
+
latency_p50: percentile(latencies, 0.5),
|
|
204
|
+
latency_p95: percentile(latencies, 0.95),
|
|
205
|
+
latency_max: latencies.length > 0 ? latencies[latencies.length - 1] : null,
|
|
206
|
+
cost_stage: costStage,
|
|
207
|
+
cost_judge: costJudge,
|
|
208
|
+
cost_total: costTotal,
|
|
209
|
+
cost_per_result: resultsExecuted > 0 ? costTotal / resultsExecuted : null,
|
|
210
|
+
tokens_in: sum(executed.map((r) => r.tokensIn)),
|
|
211
|
+
tokens_out: sum(executed.map((r) => r.tokensOut)),
|
|
212
|
+
judge_tokens_in: sum(grades.map((g) => g.judgeTokensIn)),
|
|
213
|
+
judge_tokens_out: sum(grades.map((g) => g.judgeTokensOut)),
|
|
214
|
+
by_grader: computeByGrader(input.graders, grades, input.previousRun),
|
|
215
|
+
score_histogram: { bins, threshold: input.passThreshold },
|
|
216
|
+
failure_types: { by_tag: byTag, untagged },
|
|
217
|
+
failing_cases: failing,
|
|
218
|
+
...(hasAgentData ? { mean_turns: mean(turnValues), mean_tool_calls: mean(toolCallValues) } : {}),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EvalResultRow, EvalResultWithGrades } from "./storeTypes.js";
|
|
2
|
+
import type { GradeRecord, ResultRecord } from "./statsTypes.js";
|
|
3
|
+
export declare function toResultRecord(row: EvalResultRow): ResultRecord;
|
|
4
|
+
export declare function toGradeRecords(row: EvalResultWithGrades): GradeRecord[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function toResultRecord(row) {
|
|
2
|
+
return {
|
|
3
|
+
caseId: row.caseId,
|
|
4
|
+
repeatIndex: row.repeatIndex,
|
|
5
|
+
status: row.status,
|
|
6
|
+
latencyMs: row.latencyMs,
|
|
7
|
+
costUsd: row.costUsd,
|
|
8
|
+
tokensIn: row.tokensIn,
|
|
9
|
+
tokensOut: row.tokensOut,
|
|
10
|
+
score: row.score,
|
|
11
|
+
passed: row.passed ? 1 : 0,
|
|
12
|
+
...(row.turns !== null && row.turns !== undefined ? { turns: row.turns } : {}),
|
|
13
|
+
...(row.toolCallCount !== null && row.toolCallCount !== undefined ? { toolCalls: row.toolCallCount } : {}),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function toGradeRecords(row) {
|
|
17
|
+
return row.grades.map((g) => ({
|
|
18
|
+
caseId: g.caseId,
|
|
19
|
+
repeatIndex: g.repeatIndex,
|
|
20
|
+
graderId: g.graderId,
|
|
21
|
+
graderType: g.graderType,
|
|
22
|
+
status: g.status,
|
|
23
|
+
passed: g.passed === null ? null : g.passed ? 1 : 0,
|
|
24
|
+
score: g.score,
|
|
25
|
+
rawValue: g.rawValue,
|
|
26
|
+
judgeCostUsd: g.judgeCostUsd,
|
|
27
|
+
judgeTokensIn: g.judgeTokensIn,
|
|
28
|
+
judgeTokensOut: g.judgeTokensOut,
|
|
29
|
+
}));
|
|
30
|
+
}
|