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,22 @@
|
|
|
1
|
+
import type { RunStore } from "../runstore/port.js";
|
|
2
|
+
import type { NewDatasetCase } from "./writeDataset.js";
|
|
3
|
+
export type CandidateTarget = {
|
|
4
|
+
stageId: string;
|
|
5
|
+
pipelinePath?: string;
|
|
6
|
+
};
|
|
7
|
+
export type DatasetCandidate = {
|
|
8
|
+
runId: string;
|
|
9
|
+
finishedAt: string;
|
|
10
|
+
preview: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function standalonePipelineId(stageId: string): string;
|
|
13
|
+
export declare function listDatasetCandidates(input: {
|
|
14
|
+
store: RunStore;
|
|
15
|
+
target: CandidateTarget;
|
|
16
|
+
limit: number;
|
|
17
|
+
}): Promise<DatasetCandidate[]>;
|
|
18
|
+
export declare function casesFromRuns(input: {
|
|
19
|
+
store: RunStore;
|
|
20
|
+
runIds: readonly string[];
|
|
21
|
+
target: CandidateTarget;
|
|
22
|
+
}): Promise<NewDatasetCase[]>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { parse as parseYaml } from "yaml";
|
|
3
|
+
import { EvalsWriteError } from "./atomicWrite.js";
|
|
4
|
+
const PREVIEW_CHARS = 160;
|
|
5
|
+
const SHORT_ID_CHARS = 8;
|
|
6
|
+
export function standalonePipelineId(stageId) {
|
|
7
|
+
return `standalone-${stageId}`;
|
|
8
|
+
}
|
|
9
|
+
function isPlain(value) {
|
|
10
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11
|
+
}
|
|
12
|
+
function isCandidateRun(meta, target) {
|
|
13
|
+
if (meta.origin === "eval" || meta.status !== "succeeded")
|
|
14
|
+
return false;
|
|
15
|
+
if (meta.pipeline_id === standalonePipelineId(target.stageId))
|
|
16
|
+
return true;
|
|
17
|
+
if (target.pipelinePath === undefined || meta.pipeline_path === undefined)
|
|
18
|
+
return false;
|
|
19
|
+
if (path.resolve(meta.pipeline_path) !== path.resolve(target.pipelinePath))
|
|
20
|
+
return false;
|
|
21
|
+
return meta.pipeline_dag?.roots.includes(target.stageId) ?? false;
|
|
22
|
+
}
|
|
23
|
+
async function recordedInput(store, runId) {
|
|
24
|
+
const detail = await store.readRun(runId);
|
|
25
|
+
let task;
|
|
26
|
+
try {
|
|
27
|
+
task = parseYaml(detail.task_yaml);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
if (!isPlain(task) || !isPlain(task.input))
|
|
33
|
+
return undefined;
|
|
34
|
+
return task.input;
|
|
35
|
+
}
|
|
36
|
+
export async function listDatasetCandidates(input) {
|
|
37
|
+
const { store, target, limit } = input;
|
|
38
|
+
const pipelines = [standalonePipelineId(target.stageId)];
|
|
39
|
+
if (target.pipelinePath !== undefined)
|
|
40
|
+
pipelines.push(target.pipelinePath);
|
|
41
|
+
const summaries = (await Promise.all(pipelines.map((pipeline) => store.listRuns({ pipeline, status: "succeeded" })))).flat();
|
|
42
|
+
const seen = new Set();
|
|
43
|
+
const ordered = summaries
|
|
44
|
+
.filter((s) => (seen.has(s.run_id) ? false : (seen.add(s.run_id), true)))
|
|
45
|
+
.sort((a, b) => (b.finished_at ?? b.created_at).localeCompare(a.finished_at ?? a.created_at));
|
|
46
|
+
const items = [];
|
|
47
|
+
for (const summary of ordered) {
|
|
48
|
+
if (items.length >= limit)
|
|
49
|
+
break;
|
|
50
|
+
const meta = await store.readRunMeta(summary.run_id);
|
|
51
|
+
if (!isCandidateRun(meta, target))
|
|
52
|
+
continue;
|
|
53
|
+
const recorded = await recordedInput(store, summary.run_id);
|
|
54
|
+
if (recorded === undefined)
|
|
55
|
+
continue;
|
|
56
|
+
items.push({
|
|
57
|
+
runId: summary.run_id,
|
|
58
|
+
finishedAt: summary.finished_at ?? summary.created_at,
|
|
59
|
+
preview: JSON.stringify(recorded).slice(0, PREVIEW_CHARS),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return items;
|
|
63
|
+
}
|
|
64
|
+
export async function casesFromRuns(input) {
|
|
65
|
+
const { store, target } = input;
|
|
66
|
+
const cases = [];
|
|
67
|
+
for (const runId of input.runIds) {
|
|
68
|
+
let meta;
|
|
69
|
+
try {
|
|
70
|
+
meta = await store.readRunMeta(runId);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
throw new EvalsWriteError("DATASET_CASE_OP_INVALID", `run ${runId} not found`);
|
|
74
|
+
}
|
|
75
|
+
const recorded = isCandidateRun(meta, target) ? await recordedInput(store, runId) : undefined;
|
|
76
|
+
if (recorded === undefined) {
|
|
77
|
+
throw new EvalsWriteError("DATASET_CASE_OP_INVALID", `run ${runId} is not a completed run of stage "${target.stageId}" with a recorded input`);
|
|
78
|
+
}
|
|
79
|
+
cases.push({
|
|
80
|
+
title: `Run ${runId.slice(0, SHORT_ID_CHARS)}`,
|
|
81
|
+
input: recorded,
|
|
82
|
+
metadata: { source_run: runId },
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return cases;
|
|
86
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AgentSessionDetail } from "../agents/service.js";
|
|
2
|
+
import type { AgentSessionListItem, SessionQuery } from "../agents/store.js";
|
|
3
|
+
import type { NewDatasetCase } from "./writeDataset.js";
|
|
4
|
+
/** The slice of `AgentService` that turns past sessions into scenarios. */
|
|
5
|
+
export type SessionsSource = {
|
|
6
|
+
listSessions(projectRoot: string, agentId: string, query: SessionQuery): Promise<{
|
|
7
|
+
sessions: AgentSessionListItem[];
|
|
8
|
+
nextCursor: string | null;
|
|
9
|
+
}>;
|
|
10
|
+
getSession(projectRoot: string, sessionId: string): Promise<AgentSessionDetail>;
|
|
11
|
+
};
|
|
12
|
+
export type SessionCandidate = {
|
|
13
|
+
session_id: string;
|
|
14
|
+
updated_at: string;
|
|
15
|
+
preview: string;
|
|
16
|
+
turns: number;
|
|
17
|
+
tools: string[];
|
|
18
|
+
};
|
|
19
|
+
export declare class SessionCaseError extends Error {
|
|
20
|
+
}
|
|
21
|
+
/** Finished (idle or closed), non-eval sessions of the agent that have at least one user message, newest first. */
|
|
22
|
+
export declare function listSessionCandidates(input: {
|
|
23
|
+
sessions: SessionsSource;
|
|
24
|
+
projectRoot: string;
|
|
25
|
+
agentId: string;
|
|
26
|
+
limit: number;
|
|
27
|
+
}): Promise<SessionCandidate[]>;
|
|
28
|
+
/** One `script` scenario per session: its user messages, plus the tools it called as the expected tools. */
|
|
29
|
+
export declare function casesFromSessions(input: {
|
|
30
|
+
sessions: SessionsSource;
|
|
31
|
+
projectRoot: string;
|
|
32
|
+
agentId: string;
|
|
33
|
+
sessionIds: readonly string[];
|
|
34
|
+
}): Promise<NewDatasetCase[]>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { isAgentError } from "../agents/errors.js";
|
|
2
|
+
export class SessionCaseError extends Error {
|
|
3
|
+
}
|
|
4
|
+
const PREVIEW_CHARS = 160;
|
|
5
|
+
const SCRIPT_MAX_MESSAGES = 40;
|
|
6
|
+
const SCRIPT_MAX_CHARS = 4000;
|
|
7
|
+
const SESSION_TAG = "from-session";
|
|
8
|
+
function userMessages(detail) {
|
|
9
|
+
return detail.messages
|
|
10
|
+
.filter((m) => m.role === "user" && m.text.trim() !== "")
|
|
11
|
+
.map((m) => m.text.slice(0, SCRIPT_MAX_CHARS))
|
|
12
|
+
.slice(0, SCRIPT_MAX_MESSAGES);
|
|
13
|
+
}
|
|
14
|
+
function toolNames(detail) {
|
|
15
|
+
const names = new Set();
|
|
16
|
+
for (const span of detail.spans) {
|
|
17
|
+
if (span.kind !== "tool")
|
|
18
|
+
continue;
|
|
19
|
+
const name = span.attributes["gen_ai.tool.name"];
|
|
20
|
+
if (typeof name === "string" && name !== "")
|
|
21
|
+
names.add(name);
|
|
22
|
+
}
|
|
23
|
+
return [...names];
|
|
24
|
+
}
|
|
25
|
+
function shortId(sessionId) {
|
|
26
|
+
return sessionId.replace(/^ses_/, "").slice(0, 8);
|
|
27
|
+
}
|
|
28
|
+
function isFinishedStatus(status) {
|
|
29
|
+
return status === "open" || status === "closed";
|
|
30
|
+
}
|
|
31
|
+
function isFinishedUserSession(detail, agentId) {
|
|
32
|
+
const { session } = detail;
|
|
33
|
+
return session.agentId === agentId && session.source !== "eval" && isFinishedStatus(session.status);
|
|
34
|
+
}
|
|
35
|
+
/** Finished (idle or closed), non-eval sessions of the agent that have at least one user message, newest first. */
|
|
36
|
+
export async function listSessionCandidates(input) {
|
|
37
|
+
const { sessions, projectRoot, agentId, limit } = input;
|
|
38
|
+
const items = [];
|
|
39
|
+
let cursor;
|
|
40
|
+
do {
|
|
41
|
+
let page;
|
|
42
|
+
try {
|
|
43
|
+
page = await sessions.listSessions(projectRoot, agentId, {
|
|
44
|
+
limit: Math.max(limit, 25),
|
|
45
|
+
...(cursor !== undefined ? { cursor } : {}),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
if (isAgentError(err))
|
|
50
|
+
throw new SessionCaseError(`Agent "${agentId}" was not found`);
|
|
51
|
+
throw err;
|
|
52
|
+
}
|
|
53
|
+
for (const row of page.sessions) {
|
|
54
|
+
if (row.source === "eval" || !isFinishedStatus(row.status))
|
|
55
|
+
continue;
|
|
56
|
+
if (row.lastTurnStatus === "running" || row.lastTurnStatus === "waiting")
|
|
57
|
+
continue;
|
|
58
|
+
const detail = await sessions.getSession(projectRoot, row.id);
|
|
59
|
+
const messages = userMessages(detail);
|
|
60
|
+
if (messages.length === 0)
|
|
61
|
+
continue;
|
|
62
|
+
items.push({
|
|
63
|
+
session_id: row.id,
|
|
64
|
+
updated_at: row.updatedAt,
|
|
65
|
+
preview: messages[0].replace(/\s+/g, " ").slice(0, PREVIEW_CHARS),
|
|
66
|
+
turns: messages.length,
|
|
67
|
+
tools: toolNames(detail),
|
|
68
|
+
});
|
|
69
|
+
if (items.length >= limit)
|
|
70
|
+
return items;
|
|
71
|
+
}
|
|
72
|
+
cursor = page.nextCursor ?? undefined;
|
|
73
|
+
} while (cursor !== undefined);
|
|
74
|
+
return items;
|
|
75
|
+
}
|
|
76
|
+
/** One `script` scenario per session: its user messages, plus the tools it called as the expected tools. */
|
|
77
|
+
export async function casesFromSessions(input) {
|
|
78
|
+
const { sessions, projectRoot, agentId } = input;
|
|
79
|
+
const cases = [];
|
|
80
|
+
for (const sessionId of input.sessionIds) {
|
|
81
|
+
let detail;
|
|
82
|
+
try {
|
|
83
|
+
detail = await sessions.getSession(projectRoot, sessionId);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
if (isAgentError(err))
|
|
87
|
+
throw new SessionCaseError(`Session "${sessionId}" was not found`);
|
|
88
|
+
throw err;
|
|
89
|
+
}
|
|
90
|
+
if (!isFinishedUserSession(detail, agentId)) {
|
|
91
|
+
throw new SessionCaseError(`Session "${sessionId}" is not a finished session of agent "${agentId}"`);
|
|
92
|
+
}
|
|
93
|
+
const script = userMessages(detail);
|
|
94
|
+
if (script.length === 0)
|
|
95
|
+
throw new SessionCaseError(`Session "${sessionId}" has no user messages`);
|
|
96
|
+
cases.push({
|
|
97
|
+
title: detail.session.title ?? `Session ${shortId(sessionId)}`,
|
|
98
|
+
input: { mode: "script", script, opening: script[0] },
|
|
99
|
+
expected: { tools: toolNames(detail) },
|
|
100
|
+
tags: [SESSION_TAG],
|
|
101
|
+
metadata: { source_session: sessionId },
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return cases;
|
|
105
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function datasetContentHash(cases: readonly unknown[]): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DatasetCase } from "./datasetTypes.js";
|
|
2
|
+
export type UploadMappingEntry = {
|
|
3
|
+
column: string;
|
|
4
|
+
split?: string;
|
|
5
|
+
} | null;
|
|
6
|
+
export type UploadMapping = Record<string, UploadMappingEntry>;
|
|
7
|
+
export type UploadPreviewRow = {
|
|
8
|
+
index: number;
|
|
9
|
+
case: DatasetCase;
|
|
10
|
+
status: "ready" | "skipped";
|
|
11
|
+
reason?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function nextIdNumber(existingIds: Iterable<string>): number;
|
|
14
|
+
export declare function formatId(n: number): string;
|
|
15
|
+
export type UploadMappingOptions = {
|
|
16
|
+
/** Also map the top-level `title` and `tags` targets (agent datasets). */
|
|
17
|
+
caseMeta?: boolean;
|
|
18
|
+
/** Extra check on the built case; a returned text skips the row with that reason. */
|
|
19
|
+
check?: (draft: DatasetCase) => string | undefined;
|
|
20
|
+
};
|
|
21
|
+
export declare function applyUploadMapping(rows: ReadonlyArray<Record<string, string>>, mapping: UploadMapping, inputSchema: unknown, existingIds: Iterable<string>, options?: UploadMappingOptions): UploadPreviewRow[];
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { payloadInstanceMismatch } from "../envelope/payloadSchema.js";
|
|
2
|
+
const REASON_MAX = 160;
|
|
3
|
+
const ID_NUMBER_RE = /^c(\d+)$/;
|
|
4
|
+
function trimReason(message) {
|
|
5
|
+
const flat = message.replace(/\s+/g, " ").trim();
|
|
6
|
+
return flat.length > REASON_MAX ? flat.slice(0, REASON_MAX) : flat;
|
|
7
|
+
}
|
|
8
|
+
export function nextIdNumber(existingIds) {
|
|
9
|
+
let max = 0;
|
|
10
|
+
for (const id of existingIds) {
|
|
11
|
+
const m = ID_NUMBER_RE.exec(id);
|
|
12
|
+
if (m)
|
|
13
|
+
max = Math.max(max, Number(m[1]));
|
|
14
|
+
}
|
|
15
|
+
return max + 1;
|
|
16
|
+
}
|
|
17
|
+
export function formatId(n) {
|
|
18
|
+
return `c${String(n).padStart(3, "0")}`;
|
|
19
|
+
}
|
|
20
|
+
function schemaPropertyType(inputSchema, name) {
|
|
21
|
+
if (inputSchema === null || typeof inputSchema !== "object")
|
|
22
|
+
return undefined;
|
|
23
|
+
const props = inputSchema.properties;
|
|
24
|
+
if (props === null || typeof props !== "object")
|
|
25
|
+
return undefined;
|
|
26
|
+
const prop = props[name];
|
|
27
|
+
if (prop === null || typeof prop !== "object")
|
|
28
|
+
return undefined;
|
|
29
|
+
const type = prop.type;
|
|
30
|
+
return typeof type === "string" ? type : undefined;
|
|
31
|
+
}
|
|
32
|
+
function parseCell(cell, schemaType, split, name) {
|
|
33
|
+
if (split !== undefined) {
|
|
34
|
+
return {
|
|
35
|
+
value: cell
|
|
36
|
+
.split(split)
|
|
37
|
+
.map((part) => part.trim())
|
|
38
|
+
.filter((part) => part !== ""),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (schemaType === "number" || schemaType === "integer") {
|
|
42
|
+
const trimmed = cell.trim();
|
|
43
|
+
const n = trimmed === "" ? Number.NaN : Number(trimmed);
|
|
44
|
+
if (!Number.isFinite(n) || (schemaType === "integer" && !Number.isInteger(n))) {
|
|
45
|
+
return { error: `${name} is not ${schemaType === "integer" ? "an integer" : "a number"}` };
|
|
46
|
+
}
|
|
47
|
+
return { value: n };
|
|
48
|
+
}
|
|
49
|
+
if (schemaType === "boolean") {
|
|
50
|
+
const lowered = cell.trim().toLowerCase();
|
|
51
|
+
if (lowered === "true")
|
|
52
|
+
return { value: true };
|
|
53
|
+
if (lowered === "false")
|
|
54
|
+
return { value: false };
|
|
55
|
+
return { error: `${name} is not a boolean` };
|
|
56
|
+
}
|
|
57
|
+
return { value: cell };
|
|
58
|
+
}
|
|
59
|
+
export function applyUploadMapping(rows, mapping, inputSchema, existingIds, options = {}) {
|
|
60
|
+
let nextId = nextIdNumber(existingIds);
|
|
61
|
+
const entries = Object.entries(mapping).filter((e) => e[1] !== null);
|
|
62
|
+
return rows.map((row, index) => {
|
|
63
|
+
const input = {};
|
|
64
|
+
const expected = {};
|
|
65
|
+
let parseError;
|
|
66
|
+
let title;
|
|
67
|
+
let tags;
|
|
68
|
+
for (const [target, entry] of entries) {
|
|
69
|
+
if (options.caseMeta === true && (target === "title" || target === "tags")) {
|
|
70
|
+
const raw = row[entry.column];
|
|
71
|
+
if (raw === undefined || raw.trim() === "")
|
|
72
|
+
continue;
|
|
73
|
+
if (target === "title")
|
|
74
|
+
title = raw.trim();
|
|
75
|
+
else
|
|
76
|
+
tags = (entry.split !== undefined ? raw.split(entry.split) : raw.split(",")).map((t) => t.trim()).filter((t) => t !== "");
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const dot = target.indexOf(".");
|
|
80
|
+
const base = dot === -1 ? target : target.slice(0, dot);
|
|
81
|
+
const name = dot === -1 ? "" : target.slice(dot + 1);
|
|
82
|
+
if ((base !== "input" && base !== "expected") || name === "")
|
|
83
|
+
continue;
|
|
84
|
+
const cell = row[entry.column];
|
|
85
|
+
if (cell === undefined || cell === "")
|
|
86
|
+
continue;
|
|
87
|
+
const schemaType = base === "input" ? schemaPropertyType(inputSchema, name) : undefined;
|
|
88
|
+
const parsed = parseCell(cell, schemaType, entry.split, name);
|
|
89
|
+
if ("error" in parsed) {
|
|
90
|
+
parseError ??= parsed.error;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
(base === "input" ? input : expected)[name] = parsed.value;
|
|
94
|
+
}
|
|
95
|
+
const draft = { id: "", input };
|
|
96
|
+
if (Object.keys(expected).length > 0)
|
|
97
|
+
draft.expected = expected;
|
|
98
|
+
if (title !== undefined)
|
|
99
|
+
draft.title = title;
|
|
100
|
+
if (tags !== undefined && tags.length > 0)
|
|
101
|
+
draft.tags = tags;
|
|
102
|
+
let reason = parseError;
|
|
103
|
+
if (reason === undefined && inputSchema !== undefined) {
|
|
104
|
+
try {
|
|
105
|
+
reason = payloadInstanceMismatch(input, inputSchema);
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
reason = err instanceof Error ? err.message : String(err);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (reason === undefined && options.check)
|
|
112
|
+
reason = options.check(draft);
|
|
113
|
+
if (reason !== undefined) {
|
|
114
|
+
return { index, case: draft, status: "skipped", reason: trimReason(reason) };
|
|
115
|
+
}
|
|
116
|
+
draft.id = formatId(nextId);
|
|
117
|
+
nextId += 1;
|
|
118
|
+
return { index, case: draft, status: "ready" };
|
|
119
|
+
});
|
|
120
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type DatasetStageCheckResult = {
|
|
2
|
+
caseId: string;
|
|
3
|
+
valid: boolean;
|
|
4
|
+
message?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function checkDatasetAgainstStage(cases: ReadonlyArray<{
|
|
7
|
+
id: string;
|
|
8
|
+
input: Record<string, unknown>;
|
|
9
|
+
}>, inputSchema: unknown): DatasetStageCheckResult[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { payloadInstanceMismatch } from "../envelope/payloadSchema.js";
|
|
2
|
+
export function checkDatasetAgainstStage(cases, inputSchema) {
|
|
3
|
+
return cases.map((c) => {
|
|
4
|
+
if (inputSchema === undefined)
|
|
5
|
+
return { caseId: c.id, valid: true };
|
|
6
|
+
let message;
|
|
7
|
+
try {
|
|
8
|
+
message = payloadInstanceMismatch(c.input, inputSchema);
|
|
9
|
+
}
|
|
10
|
+
catch (err) {
|
|
11
|
+
message = err instanceof Error ? err.message : String(err);
|
|
12
|
+
}
|
|
13
|
+
return message === undefined
|
|
14
|
+
? { caseId: c.id, valid: true }
|
|
15
|
+
: { caseId: c.id, valid: false, message };
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ValidationFinding } from "./validateCatalog.js";
|
|
2
|
+
export type DatasetFormat = "jsonl" | "json" | "csv";
|
|
3
|
+
export type DatasetCase = {
|
|
4
|
+
id: string;
|
|
5
|
+
input: Record<string, unknown>;
|
|
6
|
+
title?: string;
|
|
7
|
+
expected?: unknown;
|
|
8
|
+
tags?: string[];
|
|
9
|
+
goal?: string;
|
|
10
|
+
metadata?: Record<string, unknown>;
|
|
11
|
+
};
|
|
12
|
+
export type DatasetLimits = {
|
|
13
|
+
maxCases: number;
|
|
14
|
+
maxCaseBytes: number;
|
|
15
|
+
maxFileBytes: number;
|
|
16
|
+
};
|
|
17
|
+
export type ParseDatasetResult = {
|
|
18
|
+
cases: DatasetCase[];
|
|
19
|
+
findings: ValidationFinding[];
|
|
20
|
+
contentHash: string;
|
|
21
|
+
};
|
|
22
|
+
export type DatasetLoadResult = ParseDatasetResult & {
|
|
23
|
+
path: string;
|
|
24
|
+
relPath: string;
|
|
25
|
+
format: DatasetFormat | undefined;
|
|
26
|
+
fileBytes: number;
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { CatalogRootKind } from "./resolveCatalogRoots.js";
|
|
2
2
|
/** Directory scanned for workshop-authored pipelines and tasks. */
|
|
3
3
|
export declare const WORKSHOP_PACKAGE_ROOT = "workshop";
|
|
4
|
+
/** Directory the Guide always uses for pipeline packages and their stage files. */
|
|
5
|
+
export declare const GUIDE_PIPELINES_ROOT = "pipelines";
|
|
4
6
|
export declare function normalizeCatalogDir(directory: string): string;
|
|
5
7
|
/** Untitled workshop saves land here so Run can see them without a new catalog edit. */
|
|
6
8
|
export declare function defaultWorkshopPackageDirectory(pipelineId: string | undefined, catalogRootKind?: CatalogRootKind): string;
|
|
@@ -14,4 +16,5 @@ export declare function catalogScanRootForDirectory(directory: string): string;
|
|
|
14
16
|
* Make sure `stageflow.yaml` scans `directory` for both pipelines and tasks.
|
|
15
17
|
* Returns true when the manifest changed. Missing or unreadable manifests are left alone.
|
|
16
18
|
*/
|
|
17
|
-
export
|
|
19
|
+
export type CatalogScanKey = "pipelines" | "tasks" | "evals" | "datasets";
|
|
20
|
+
export declare function ensureCatalogScanRoot(projectRoot: string, directory: string, keys?: readonly CatalogScanKey[]): Promise<boolean>;
|
|
@@ -3,6 +3,8 @@ import { isSeq, parseDocument } from "yaml";
|
|
|
3
3
|
import { manifestPathForProject } from "./loadStageflowManifest.js";
|
|
4
4
|
/** Directory scanned for workshop-authored pipelines and tasks. */
|
|
5
5
|
export const WORKSHOP_PACKAGE_ROOT = "workshop";
|
|
6
|
+
/** Directory the Guide always uses for pipeline packages and their stage files. */
|
|
7
|
+
export const GUIDE_PIPELINES_ROOT = "pipelines";
|
|
6
8
|
export function normalizeCatalogDir(directory) {
|
|
7
9
|
return directory.replace(/\\/g, "/").replace(/^\.\/+/, "").replace(/\/+$/, "");
|
|
8
10
|
}
|
|
@@ -30,6 +32,10 @@ export function catalogScanRootForDirectory(directory) {
|
|
|
30
32
|
normalized.startsWith(`${WORKSHOP_PACKAGE_ROOT}/`)) {
|
|
31
33
|
return WORKSHOP_PACKAGE_ROOT;
|
|
32
34
|
}
|
|
35
|
+
if (normalized === GUIDE_PIPELINES_ROOT ||
|
|
36
|
+
normalized.startsWith(`${GUIDE_PIPELINES_ROOT}/`)) {
|
|
37
|
+
return GUIDE_PIPELINES_ROOT;
|
|
38
|
+
}
|
|
33
39
|
return normalized;
|
|
34
40
|
}
|
|
35
41
|
function isCovered(entries, root) {
|
|
@@ -38,11 +44,7 @@ function isCovered(entries, root) {
|
|
|
38
44
|
return root === normalized || root.startsWith(`${normalized}/`);
|
|
39
45
|
});
|
|
40
46
|
}
|
|
41
|
-
|
|
42
|
-
* Make sure `stageflow.yaml` scans `directory` for both pipelines and tasks.
|
|
43
|
-
* Returns true when the manifest changed. Missing or unreadable manifests are left alone.
|
|
44
|
-
*/
|
|
45
|
-
export async function ensureCatalogScanRoot(projectRoot, directory) {
|
|
47
|
+
export async function ensureCatalogScanRoot(projectRoot, directory, keys = ["pipelines", "tasks"]) {
|
|
46
48
|
const root = catalogScanRootForDirectory(directory);
|
|
47
49
|
if (!root || root.split("/").includes(".."))
|
|
48
50
|
return false;
|
|
@@ -56,7 +58,7 @@ export async function ensureCatalogScanRoot(projectRoot, directory) {
|
|
|
56
58
|
}
|
|
57
59
|
const doc = parseDocument(text);
|
|
58
60
|
let changed = false;
|
|
59
|
-
for (const key of
|
|
61
|
+
for (const key of keys) {
|
|
60
62
|
const seq = doc.getIn(["catalog", key]);
|
|
61
63
|
if (!isSeq(seq))
|
|
62
64
|
continue;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { LoadedManifest } from "../types/stageflowManifest.js";
|
|
2
|
+
import { type LoadedEval } from "./loadEval.js";
|
|
3
|
+
import type { LoadOutcome } from "./loadOutcome.js";
|
|
4
|
+
import type { ValidationFinding } from "./validateCatalog.js";
|
|
5
|
+
import { type DatasetReport } from "./validateEval.js";
|
|
6
|
+
export type CatalogFileRef = {
|
|
7
|
+
absPath: string;
|
|
8
|
+
relPath: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function listEvalFiles(manifest: LoadedManifest): Promise<CatalogFileRef[]>;
|
|
11
|
+
export declare function listDatasetFiles(manifest: LoadedManifest): Promise<CatalogFileRef[]>;
|
|
12
|
+
export type EvalCatalogEntry = {
|
|
13
|
+
absPath: string;
|
|
14
|
+
relPath: string;
|
|
15
|
+
outcome: LoadOutcome<LoadedEval>;
|
|
16
|
+
findings: ValidationFinding[];
|
|
17
|
+
};
|
|
18
|
+
export type LoadEvalCatalogOptions = {
|
|
19
|
+
isKnownModel?: (id: string) => Promise<boolean>;
|
|
20
|
+
datasetReportFor?: (loaded: LoadedEval) => Promise<DatasetReport | undefined>;
|
|
21
|
+
};
|
|
22
|
+
export declare function loadEvalCatalog(manifest: LoadedManifest, options?: LoadEvalCatalogOptions): Promise<EvalCatalogEntry[]>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { stat } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { isInsideProjectRoot } from "./catalogRelativePath.js";
|
|
4
|
+
import { getModelCatalog } from "../models/catalog.js";
|
|
5
|
+
import { loadDatasetFile } from "./loadDataset.js";
|
|
6
|
+
import { loadEvalOutcome, resolveEvalPaths } from "./loadEval.js";
|
|
7
|
+
import { scanCatalogPaths } from "./scanCatalogPaths.js";
|
|
8
|
+
import { evalFindingsFromIssues, validateEval, } from "./validateEval.js";
|
|
9
|
+
async function listFiles(manifest, kind) {
|
|
10
|
+
const absPaths = await scanCatalogPaths(manifest, kind);
|
|
11
|
+
return absPaths.map((absPath) => ({
|
|
12
|
+
absPath,
|
|
13
|
+
relPath: path.relative(manifest.projectRoot, absPath).split(path.sep).join("/"),
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
export function listEvalFiles(manifest) {
|
|
17
|
+
return listFiles(manifest, "eval");
|
|
18
|
+
}
|
|
19
|
+
export async function listDatasetFiles(manifest) {
|
|
20
|
+
const scanned = await listFiles(manifest, "dataset");
|
|
21
|
+
const referenced = await datasetsReferencedByEvals(manifest, scanned);
|
|
22
|
+
return [...scanned, ...referenced].sort((a, b) => (a.relPath < b.relPath ? -1 : a.relPath > b.relPath ? 1 : 0));
|
|
23
|
+
}
|
|
24
|
+
async function datasetsReferencedByEvals(manifest, scanned) {
|
|
25
|
+
const seen = new Set(scanned.map((ref) => path.resolve(ref.absPath)));
|
|
26
|
+
const extra = [];
|
|
27
|
+
for (const ref of await listFiles(manifest, "eval")) {
|
|
28
|
+
const outcome = await loadEvalOutcome(ref.absPath, manifest.projectRoot);
|
|
29
|
+
if (!outcome.ok)
|
|
30
|
+
continue;
|
|
31
|
+
const abs = path.resolve(resolveEvalPaths(outcome.value.file, outcome.value.path).datasetPath);
|
|
32
|
+
if (seen.has(abs) || !isInsideProjectRoot(manifest.projectRoot, abs))
|
|
33
|
+
continue;
|
|
34
|
+
try {
|
|
35
|
+
if (!(await stat(abs)).isFile())
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
seen.add(abs);
|
|
42
|
+
extra.push({
|
|
43
|
+
absPath: abs,
|
|
44
|
+
relPath: path.relative(manifest.projectRoot, abs).split(path.sep).join("/"),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return extra;
|
|
48
|
+
}
|
|
49
|
+
export async function loadEvalCatalog(manifest, options = {}) {
|
|
50
|
+
const refs = await listEvalFiles(manifest);
|
|
51
|
+
const { projectRoot } = manifest;
|
|
52
|
+
const isKnownModel = options.isKnownModel ??
|
|
53
|
+
(async (id) => {
|
|
54
|
+
try {
|
|
55
|
+
const { models } = await getModelCatalog(projectRoot).snapshot();
|
|
56
|
+
return models.length === 0 || models.includes(id);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const datasetReportFor = options.datasetReportFor ??
|
|
63
|
+
(async (evalFile) => {
|
|
64
|
+
const { datasetPath } = resolveEvalPaths(evalFile.file, evalFile.path);
|
|
65
|
+
try {
|
|
66
|
+
await stat(datasetPath);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
return loadDatasetFile(datasetPath, { root: projectRoot });
|
|
72
|
+
});
|
|
73
|
+
const loaded = await Promise.all(refs.map(async (ref) => ({ ref, outcome: await loadEvalOutcome(ref.absPath, projectRoot) })));
|
|
74
|
+
const evals = loaded.flatMap(({ ref, outcome }) => outcome.ok ? [{ id: outcome.value.id, absPath: ref.absPath }] : []);
|
|
75
|
+
const entries = [];
|
|
76
|
+
for (const { ref, outcome } of loaded) {
|
|
77
|
+
let findings;
|
|
78
|
+
if (outcome.ok) {
|
|
79
|
+
const datasetReport = await datasetReportFor(outcome.value);
|
|
80
|
+
findings = await validateEval(outcome.value, {
|
|
81
|
+
projectRoot,
|
|
82
|
+
evals,
|
|
83
|
+
isKnownModel,
|
|
84
|
+
...(datasetReport !== undefined ? { datasetReport } : {}),
|
|
85
|
+
});
|
|
86
|
+
if (datasetReport !== undefined)
|
|
87
|
+
findings.push(...datasetReport.findings);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
findings = evalFindingsFromIssues(ref.relPath, outcome.issues);
|
|
91
|
+
}
|
|
92
|
+
entries.push({ absPath: ref.absPath, relPath: ref.relPath, outcome, findings });
|
|
93
|
+
}
|
|
94
|
+
return entries;
|
|
95
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { LoadedManifest } from "../types/stageflowManifest.js";
|
|
2
|
+
import { type CatalogFileRef } from "./evalCatalog.js";
|
|
3
|
+
export type WriteRootKind = "evals" | "datasets" | "pipelines";
|
|
4
|
+
export declare function manifestForWrite(projectRoot: string): Promise<LoadedManifest>;
|
|
5
|
+
export declare function explicitRoots(manifest: LoadedManifest, kind: WriteRootKind): string[] | undefined;
|
|
6
|
+
export type WriteDir = {
|
|
7
|
+
absDir: string;
|
|
8
|
+
relDir: string;
|
|
9
|
+
explicitDirectory: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function resolveWriteDir(projectRoot: string, manifest: LoadedManifest, kind: WriteRootKind, directory?: string): Promise<WriteDir>;
|
|
12
|
+
export declare function assertInsideProject(projectRoot: string, absPath: string, what: string): void;
|
|
13
|
+
export declare function evalStem(fileName: string): string;
|
|
14
|
+
export declare function datasetStem(fileName: string): string;
|
|
15
|
+
export declare function findEvalFile(projectRoot: string, id: string, manifest?: LoadedManifest): Promise<CatalogFileRef | undefined>;
|
|
16
|
+
export declare function datasetIdsFor(refs: readonly CatalogFileRef[]): Map<string, string>;
|
|
17
|
+
export declare function findDatasetFile(projectRoot: string, id: string, manifest?: LoadedManifest): Promise<CatalogFileRef | undefined>;
|