stageflow 0.40.0 → 0.42.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 +3 -1
- package/dist/agents/authorChat.d.ts +4 -0
- package/dist/agents/authorChat.js +113 -12
- package/dist/agents/authorSessionStore.d.ts +35 -0
- package/dist/agents/authorSessionStore.js +152 -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 +3 -0
- package/dist/agents/hostContext.js +4 -1
- package/dist/agents/runtime/piRuntime.d.ts +1 -1
- package/dist/agents/runtime/piRuntime.js +4 -4
- package/dist/agents/runtime/types.d.ts +3 -1
- package/dist/agents/service.d.ts +27 -2
- package/dist/agents/service.js +88 -13
- package/dist/agents/sessions.d.ts +8 -0
- package/dist/agents/sessions.js +50 -10
- 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/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/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 +2 -1
- package/dist/config/ensureCatalogScanRoot.js +2 -6
- package/dist/config/evalCatalog.d.ts +22 -0
- package/dist/config/evalCatalog.js +67 -0
- package/dist/config/evalWriteRoots.d.ts +17 -0
- package/dist/config/evalWriteRoots.js +109 -0
- package/dist/config/hostConfig.js +1 -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 +1085 -0
- package/dist/config/loadOutcome.d.ts +5 -0
- package/dist/config/loadStageflowManifest.js +64 -0
- 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 +1 -1
- package/dist/config/validateCatalog.js +9 -1
- package/dist/config/validateEval.d.ts +36 -0
- package/dist/config/validateEval.js +405 -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/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 +60 -0
- package/dist/evals/constants.js +95 -0
- package/dist/evals/engine/FakeEngine.d.ts +33 -0
- package/dist/evals/engine/FakeEngine.js +176 -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 +311 -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 +342 -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 +103 -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 +174 -0
- package/dist/evals/manager.js +787 -0
- package/dist/evals/plan.d.ts +58 -0
- package/dist/evals/plan.js +602 -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 +196 -0
- package/dist/evals/read/api.js +358 -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 +173 -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 +149 -0
- package/dist/evals/read/runs.js +289 -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 +7 -0
- package/dist/evals/runner/caseRunner.js +17 -0
- package/dist/evals/runner/conversationSubject.d.ts +18 -0
- package/dist/evals/runner/conversationSubject.js +123 -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 +183 -0
- package/dist/evals/snapshot.js +65 -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 +347 -0
- package/dist/evals/types.js +1 -0
- package/dist/mcp/deps.d.ts +7 -0
- package/dist/mcp/evalTools.d.ts +3 -0
- package/dist/mcp/evalTools.js +280 -0
- package/dist/mcp/server.js +1 -0
- package/dist/mcp/tools.js +2 -0
- 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/piModel.js +17 -4
- package/dist/operatorAgent/profiles/agentAuthor.d.ts +3 -1
- package/dist/operatorAgent/profiles/agentAuthor.js +145 -20
- 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/package-meta.d.ts +1 -1
- package/dist/package-meta.js +1 -1
- package/dist/runstore/port.d.ts +43 -0
- package/dist/runstore/sqlite/SqliteRunStore.d.ts +28 -0
- package/dist/runstore/sqlite/SqliteRunStore.js +99 -5
- 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/runtime/pipelineRunner.d.ts +2 -1
- package/dist/runtime/pipelineRunner.js +2 -0
- package/dist/runtime/runManager.d.ts +2 -1
- package/dist/runtime/runManager.js +8 -6
- package/dist/runtime/runRetentionSweep.js +2 -2
- package/dist/server/agentAuthorRoutes.js +50 -1
- package/dist/server/bootstrap.d.ts +8 -0
- package/dist/server/bootstrap.js +56 -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 +1427 -0
- package/dist/server/evalTriageRoutes.d.ts +2 -0
- package/dist/server/evalTriageRoutes.js +95 -0
- package/dist/server/http.d.ts +5 -0
- package/dist/server/http.js +32 -2
- package/dist/server/mcpHost.js +3 -0
- package/dist/toolkit/meta.d.ts +1 -1
- package/dist/toolkit/meta.js +15 -0
- package/dist/toolkit/profiles.js +1 -1
- package/dist/types/stageflowManifest.d.ts +6 -0
- package/dist/ui/assets/AssistantRuntimeProvider-qIX1xNoH.js +9 -0
- package/dist/ui/assets/{MarkdownText-D7tYaIFO.js → MarkdownText-BTrOqu5J.js} +1 -1
- package/dist/ui/assets/chat-Df_wCpak.js +5 -0
- package/dist/ui/assets/chat-P7KQznHm.css +2 -0
- package/dist/ui/assets/{main-BFo79krC.css → main-CHlmTNJe.css} +1 -1
- package/dist/ui/assets/main-CvVfxmMd.js +271 -0
- package/dist/ui/chat.html +3 -3
- package/dist/ui/index.html +3 -3
- package/examples/README.md +2 -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 +123 -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/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/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/chat-BbLukq9W.js +0 -5
- package/dist/ui/assets/chat-zIZU_bP1.css +0 -2
- package/dist/ui/assets/main-CijYMeM0.js +0 -259
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { EvalApiError } from "../evals/read/api.js";
|
|
2
|
+
import { SUGGESTION_STATUSES, TRIAGE_BUCKETS, TRIAGE_MAX_LIMIT } from "../evals/triage/constants.js";
|
|
3
|
+
import { isTriageBucket, TriageService } from "../evals/triage/service.js";
|
|
4
|
+
import { audit, bad, optStringArray, readOptionalBody, runByIdOr404 } from "./evalRouteContext.js";
|
|
5
|
+
function triageOf(c) {
|
|
6
|
+
return new TriageService({ store: c.store, ...(c.triage ?? {}), loadPrices: c.triage?.loadPrices ?? c.loadPrices });
|
|
7
|
+
}
|
|
8
|
+
async function handleSort(c, id) {
|
|
9
|
+
const body = await readOptionalBody(c);
|
|
10
|
+
const row = await runByIdOr404(c, id);
|
|
11
|
+
const classifier = body.classifier ?? "auto";
|
|
12
|
+
if (classifier !== "auto" && classifier !== "jev" && classifier !== "judge") {
|
|
13
|
+
throw bad(`"classifier" must be auto, jev or judge`);
|
|
14
|
+
}
|
|
15
|
+
if (body.only_unsorted !== undefined && typeof body.only_unsorted !== "boolean")
|
|
16
|
+
throw bad(`"only_unsorted" must be a boolean`);
|
|
17
|
+
if (body.limit !== undefined &&
|
|
18
|
+
(typeof body.limit !== "number" || !Number.isInteger(body.limit) || body.limit < 1 || body.limit > TRIAGE_MAX_LIMIT)) {
|
|
19
|
+
throw bad(`"limit" must be an integer from 1 to ${TRIAGE_MAX_LIMIT}`);
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const result = await triageOf(c).sort(row, {
|
|
23
|
+
classifier: classifier,
|
|
24
|
+
...(body.only_unsorted !== undefined ? { onlyUnsorted: body.only_unsorted } : {}),
|
|
25
|
+
...(body.limit !== undefined ? { limit: body.limit } : {}),
|
|
26
|
+
});
|
|
27
|
+
audit(c, "eval_failures_sort", "ok", id);
|
|
28
|
+
c.json(c.res, 200, result);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
audit(c, "eval_failures_sort", "error", id, err instanceof EvalApiError ? err.code : "internal_error");
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function handleSuggestionsList(c, id) {
|
|
36
|
+
const row = await runByIdOr404(c, id);
|
|
37
|
+
const status = c.url.searchParams.get("status") ?? undefined;
|
|
38
|
+
if (status !== undefined && !SUGGESTION_STATUSES.includes(status)) {
|
|
39
|
+
throw bad(`"status" must be one of ${SUGGESTION_STATUSES.join(", ")}`);
|
|
40
|
+
}
|
|
41
|
+
c.json(c.res, 200, await triageOf(c).list(row, status));
|
|
42
|
+
}
|
|
43
|
+
function idsOf(body, required) {
|
|
44
|
+
const ids = optStringArray(body, "ids");
|
|
45
|
+
if (ids === undefined && required)
|
|
46
|
+
throw bad(`"ids" is required`);
|
|
47
|
+
return ids;
|
|
48
|
+
}
|
|
49
|
+
async function handleSuggestionsAccept(c, id) {
|
|
50
|
+
const body = await readOptionalBody(c);
|
|
51
|
+
const row = await runByIdOr404(c, id);
|
|
52
|
+
const ids = idsOf(body, false);
|
|
53
|
+
if (body.min_confidence !== undefined && (typeof body.min_confidence !== "number" || body.min_confidence < 0 || body.min_confidence > 1)) {
|
|
54
|
+
throw bad(`"min_confidence" must be a number from 0 to 1`);
|
|
55
|
+
}
|
|
56
|
+
if (body.bucket !== undefined && !isTriageBucket(body.bucket))
|
|
57
|
+
throw bad(`"bucket" must be one of ${TRIAGE_BUCKETS.join(", ")}`);
|
|
58
|
+
const result = await triageOf(c).accept(row, {
|
|
59
|
+
...(ids !== undefined ? { ids } : {}),
|
|
60
|
+
...(typeof body.min_confidence === "number" ? { minConfidence: body.min_confidence } : {}),
|
|
61
|
+
...(isTriageBucket(body.bucket) ? { bucket: body.bucket } : {}),
|
|
62
|
+
});
|
|
63
|
+
audit(c, "eval_suggestions_accept", "ok", id);
|
|
64
|
+
c.json(c.res, 200, result);
|
|
65
|
+
}
|
|
66
|
+
async function handleSuggestionsDismiss(c, id) {
|
|
67
|
+
const body = await readOptionalBody(c);
|
|
68
|
+
const row = await runByIdOr404(c, id);
|
|
69
|
+
const result = await triageOf(c).dismiss(row, idsOf(body, true));
|
|
70
|
+
audit(c, "eval_suggestions_dismiss", "ok", id);
|
|
71
|
+
c.json(c.res, 200, result);
|
|
72
|
+
}
|
|
73
|
+
async function handleSortStatus(c, id) {
|
|
74
|
+
c.json(c.res, 200, await triageOf(c).status(await runByIdOr404(c, id)));
|
|
75
|
+
}
|
|
76
|
+
export function matchEvalTriageRoute(c, seg) {
|
|
77
|
+
const { method, pathname } = c;
|
|
78
|
+
const m = (re) => pathname.match(re);
|
|
79
|
+
let match = m(/^\/api\/eval-runs\/([^/]+)\/failures\/sort$/);
|
|
80
|
+
if (method === "POST" && match)
|
|
81
|
+
return () => handleSort(c, seg(match[1]));
|
|
82
|
+
match = m(/^\/api\/eval-runs\/([^/]+)\/failures\/suggestions$/);
|
|
83
|
+
if (method === "GET" && match)
|
|
84
|
+
return () => handleSuggestionsList(c, seg(match[1]));
|
|
85
|
+
match = m(/^\/api\/eval-runs\/([^/]+)\/failures\/suggestions\/accept$/);
|
|
86
|
+
if (method === "POST" && match)
|
|
87
|
+
return () => handleSuggestionsAccept(c, seg(match[1]));
|
|
88
|
+
match = m(/^\/api\/eval-runs\/([^/]+)\/failures\/suggestions\/dismiss$/);
|
|
89
|
+
if (method === "POST" && match)
|
|
90
|
+
return () => handleSuggestionsDismiss(c, seg(match[1]));
|
|
91
|
+
match = m(/^\/api\/eval-runs\/([^/]+)\/failures\/status$/);
|
|
92
|
+
if (method === "GET" && match)
|
|
93
|
+
return () => handleSortStatus(c, seg(match[1]));
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
package/dist/server/http.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { StagePort } from "../agent/port.js";
|
|
2
2
|
import { type ProviderAuthContext } from "../agent/providerAuth.js";
|
|
3
|
+
import type { EvalRunManager } from "../evals/manager.js";
|
|
3
4
|
import { type LiveViewRoutesOptions } from "./liveViewRoutes.js";
|
|
4
5
|
import { WorkshopChatSessionRegistry } from "../workshop/chatTurn.js";
|
|
5
6
|
import { type AgentPort } from "../operatorAgent/index.js";
|
|
@@ -10,6 +11,7 @@ import type { RunChangeBus } from "../runtime/runChangeBus.js";
|
|
|
10
11
|
import type { StageBrowserSupport } from "../browser/browserHost.js";
|
|
11
12
|
import { type AgentHostContext } from "../agents/hostContext.js";
|
|
12
13
|
import type { ConversationBackend } from "../agents/sessions.js";
|
|
14
|
+
import { type EvalServices } from "./evalInternalRoutes.js";
|
|
13
15
|
import { EmailTriggers } from "../email/triggers.js";
|
|
14
16
|
import { type AllowedHosts } from "./allowedHosts.js";
|
|
15
17
|
import { type ControlTokens } from "./controlToken.js";
|
|
@@ -68,6 +70,9 @@ export type OperatorRouteDeps = {
|
|
|
68
70
|
agentConversationBackend?: ConversationBackend;
|
|
69
71
|
/** Shared with MCP when set by bootstrap. */
|
|
70
72
|
agentHost?: AgentHostContext;
|
|
73
|
+
evalRunManager?: EvalRunManager;
|
|
74
|
+
/** Wired by the eval manager; until then the internal eval callback answers 404. */
|
|
75
|
+
evalServices?: EvalServices;
|
|
71
76
|
};
|
|
72
77
|
/**
|
|
73
78
|
* The full operator-console route surface: REST API (runs, stages,
|
package/dist/server/http.js
CHANGED
|
@@ -8,6 +8,9 @@ import { mapProviderAuthError } from "../agent/providerInspect.js";
|
|
|
8
8
|
import { handleProviderRoutes } from "./providerRoutes.js";
|
|
9
9
|
import { handleProjectMcpRoutes } from "./projectMcpRoutes.js";
|
|
10
10
|
import { handleTriggerRoutes } from "./triggerRoutes.js";
|
|
11
|
+
import { handleEvalRoutes } from "./evalRoutes.js";
|
|
12
|
+
import { defaultLoadJudgePrices } from "../evals/engine/promptfoo/judgeServices.js";
|
|
13
|
+
import { engineStatus as promptfooEngineStatus } from "../evals/engine/promptfoo/status.js";
|
|
11
14
|
import { readCatalogFileForHttp, writeCatalogFileForHttp, } from "./readCatalogFile.js";
|
|
12
15
|
import { applyLiveViewHeaders, createLiveViewRoutes, isLiveViewDialogPath, isLiveViewInputPath, isLiveViewPath, isLiveViewReopenTabPath, } from "./liveViewRoutes.js";
|
|
13
16
|
import { createPipeline, parseCreatePipelineBody } from "../config/createPipeline.js";
|
|
@@ -61,6 +64,7 @@ import { AgentScheduleSource, agentScheduleTickIntervalMsFromEnv, } from "../age
|
|
|
61
64
|
import { handleAgentAuthorRoutes } from "./agentAuthorRoutes.js";
|
|
62
65
|
import { handleAgentRoutes } from "./agentRoutes.js";
|
|
63
66
|
import { handleChannelRoutes } from "./channelRoutes.js";
|
|
67
|
+
import { handleEvalInternalRoutes, isEvalInternalPath } from "./evalInternalRoutes.js";
|
|
64
68
|
import { handleMemoryRoutes } from "./memoryRoutes.js";
|
|
65
69
|
import { bootstrapStageflowHost, } from "./bootstrap.js";
|
|
66
70
|
import { assertAllowedHttpAccess, isTrustedLocalHttpRequest, resolveAllowedHosts, } from "./allowedHosts.js";
|
|
@@ -183,7 +187,7 @@ export function defaultUiDistDir() {
|
|
|
183
187
|
return path.resolve(here, "../ui");
|
|
184
188
|
}
|
|
185
189
|
export function createOperatorRoutes(deps) {
|
|
186
|
-
const { manager, store, cwd, agentDir, rootDir, providerAuthContext, uiDistDir, workshopOperatorHost, agentConversationBackend, agentHost: injectedHost, } = deps;
|
|
190
|
+
const { manager, store, cwd, agentDir, rootDir, providerAuthContext, uiDistDir, workshopOperatorHost, agentConversationBackend, agentHost: injectedHost, evalServices, } = deps;
|
|
187
191
|
const agentConnection = injectedHost ? undefined : sqliteConnectionFromStore(store);
|
|
188
192
|
const agentHost = injectedHost ??
|
|
189
193
|
(agentConnection
|
|
@@ -250,7 +254,12 @@ export function createOperatorRoutes(deps) {
|
|
|
250
254
|
try {
|
|
251
255
|
if (await liveView.handle(req, res))
|
|
252
256
|
return true;
|
|
253
|
-
if (pathname
|
|
257
|
+
if (isEvalInternalPath(pathname) && (await handleEvalInternalRoutes(req, method, pathname, evalServices, res, json)))
|
|
258
|
+
return true;
|
|
259
|
+
if (pathname === "/api/agent-author/chat" ||
|
|
260
|
+
pathname === "/api/agent-author/undo" ||
|
|
261
|
+
pathname === "/api/agent-author/sessions" ||
|
|
262
|
+
pathname.startsWith("/api/agent-author/sessions/")) {
|
|
254
263
|
if (await handleAgentAuthorRoutes(req, method, pathname, cwd, operatorHost, res, json))
|
|
255
264
|
return true;
|
|
256
265
|
}
|
|
@@ -377,6 +386,9 @@ export function createOperatorRoutes(deps) {
|
|
|
377
386
|
filter.pipeline = pipeline;
|
|
378
387
|
if (callerId !== null)
|
|
379
388
|
filter.caller_id = callerId;
|
|
389
|
+
const origin = url.searchParams.get("origin");
|
|
390
|
+
if (origin === "eval" || origin === "any")
|
|
391
|
+
filter.origin = origin;
|
|
380
392
|
json(res, 200, {
|
|
381
393
|
runs: await store.listRuns(Object.keys(filter).length > 0 ? filter : undefined),
|
|
382
394
|
});
|
|
@@ -2894,6 +2906,21 @@ export function createOperatorRoutes(deps) {
|
|
|
2894
2906
|
})) {
|
|
2895
2907
|
return true;
|
|
2896
2908
|
}
|
|
2909
|
+
if (await handleEvalRoutes(req, res, {
|
|
2910
|
+
cwd,
|
|
2911
|
+
store,
|
|
2912
|
+
manager,
|
|
2913
|
+
evalRunManager: deps.evalRunManager,
|
|
2914
|
+
json,
|
|
2915
|
+
readJsonBody,
|
|
2916
|
+
auditLog,
|
|
2917
|
+
engineStatus: () => promptfooEngineStatus({ home: globalStageflowHome() }),
|
|
2918
|
+
agents: () => agentHost?.service,
|
|
2919
|
+
loadPrices: defaultLoadJudgePrices,
|
|
2920
|
+
triage: { judgeBackend: () => agentHost?.backend },
|
|
2921
|
+
})) {
|
|
2922
|
+
return true;
|
|
2923
|
+
}
|
|
2897
2924
|
if (await handleTriggerRoutes(req, res, {
|
|
2898
2925
|
cwd,
|
|
2899
2926
|
manager,
|
|
@@ -3151,6 +3178,8 @@ export async function startUiServer(options) {
|
|
|
3151
3178
|
? { workshopOperatorHost: options.workshopOperatorHost }
|
|
3152
3179
|
: {}),
|
|
3153
3180
|
...(boot.agentHost ? { agentHost: boot.agentHost } : {}),
|
|
3181
|
+
...(boot.evalRunManager ? { evalRunManager: boot.evalRunManager } : {}),
|
|
3182
|
+
...(boot.evalServices ? { evalServices: boot.evalServices } : {}),
|
|
3154
3183
|
...(options.agentConversationBackend
|
|
3155
3184
|
? { agentConversationBackend: options.agentConversationBackend }
|
|
3156
3185
|
: {}),
|
|
@@ -3163,6 +3192,7 @@ export async function startUiServer(options) {
|
|
|
3163
3192
|
controlTokens,
|
|
3164
3193
|
routes,
|
|
3165
3194
|
});
|
|
3195
|
+
boot.setEvalCallbackBase?.(envelope.url);
|
|
3166
3196
|
const closeServer = envelope.server.close.bind(envelope.server);
|
|
3167
3197
|
envelope.server.close = ((callback) => closeServer(error => {
|
|
3168
3198
|
void (boot.email?.stop() ?? Promise.resolve()).then(() => callback?.(error), () => callback?.(error ?? new Error("Email host shutdown failed")));
|
package/dist/server/mcpHost.js
CHANGED
|
@@ -28,6 +28,8 @@ export async function startMcpServer(options) {
|
|
|
28
28
|
controlTokens,
|
|
29
29
|
getShutdown: () => shutdown,
|
|
30
30
|
...(boot.agentHost ? { agentHost: boot.agentHost } : {}),
|
|
31
|
+
...(boot.evalRunManager ? { evalRunManager: boot.evalRunManager } : {}),
|
|
32
|
+
...(boot.evalServices ? { evalServices: boot.evalServices } : {}),
|
|
31
33
|
});
|
|
32
34
|
const envelope = await createHttpHost({
|
|
33
35
|
boot,
|
|
@@ -39,6 +41,7 @@ export async function startMcpServer(options) {
|
|
|
39
41
|
maxConnections: options.maxConnections,
|
|
40
42
|
routes,
|
|
41
43
|
});
|
|
44
|
+
boot.setEvalCallbackBase?.(envelope.url);
|
|
42
45
|
shutdown = installShutdownController({
|
|
43
46
|
server: envelope.server,
|
|
44
47
|
host: makeDrainableHostFromOptional(envelope.manager, envelope.store),
|
package/dist/toolkit/meta.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* can import it without pulling in the runtime.
|
|
5
5
|
*/
|
|
6
6
|
export type ToolRisk = "read" | "write" | "destructive" | "external";
|
|
7
|
-
export type ToolGroupId = "discover" | "runs.read" | "runs.control" | "runs.cleanup" | "gates.read" | "gates.decide" | "triggers" | "agents.read" | "agents.manage" | "agents.cleanup" | "agents.converse" | "pipelines.author";
|
|
7
|
+
export type ToolGroupId = "discover" | "runs.read" | "runs.control" | "runs.cleanup" | "gates.read" | "gates.decide" | "triggers" | "agents.read" | "agents.manage" | "agents.cleanup" | "agents.converse" | "evals.read" | "evals.run" | "pipelines.author";
|
|
8
8
|
export type ToolGroup = {
|
|
9
9
|
id: ToolGroupId;
|
|
10
10
|
title: string;
|
package/dist/toolkit/meta.js
CHANGED
|
@@ -16,6 +16,8 @@ export const TOOL_GROUPS = [
|
|
|
16
16
|
{ id: "agents.cleanup", title: "Archive agents", summary: "Archive an agent. Destructive." },
|
|
17
17
|
{ id: "agents.converse", title: "Talk to agents", summary: "Chat with an agent and stop its running turn." },
|
|
18
18
|
{ id: "pipelines.author", title: "Author pipelines and tasks", summary: "Read, create and edit pipelines, stages and tasks directly on disk." },
|
|
19
|
+
{ id: "evals.read", title: "Read evals", summary: "List evals, runs and results; validate and compare. Free." },
|
|
20
|
+
{ id: "evals.run", title: "Run evals", summary: "Start and cancel eval runs. Calls models and costs money." },
|
|
19
21
|
];
|
|
20
22
|
const t = (group, risk, operatorOnly) => ({ group, risk, ...(operatorOnly ? { operatorOnly } : {}) });
|
|
21
23
|
export const TOOL_META = {
|
|
@@ -87,6 +89,19 @@ export const TOOL_META = {
|
|
|
87
89
|
edit_stage: t("pipelines.author", "write"),
|
|
88
90
|
create_task: t("pipelines.author", "write"),
|
|
89
91
|
edit_task: t("pipelines.author", "write"),
|
|
92
|
+
list_evals: t("evals.read", "read"),
|
|
93
|
+
get_eval: t("evals.read", "read"),
|
|
94
|
+
validate_eval: t("evals.read", "read"),
|
|
95
|
+
get_eval_run: t("evals.read", "read"),
|
|
96
|
+
list_eval_runs: t("evals.read", "read"),
|
|
97
|
+
get_eval_results: t("evals.read", "read"),
|
|
98
|
+
get_eval_result: t("evals.read", "read"),
|
|
99
|
+
compare_eval_runs: t("evals.read", "read"),
|
|
100
|
+
get_eval_failure_suggestions: t("evals.read", "read"),
|
|
101
|
+
get_eval_failure_sort_status: t("evals.read", "read"),
|
|
102
|
+
run_eval: t("evals.run", "external"),
|
|
103
|
+
sort_eval_failures: t("evals.run", "external"),
|
|
104
|
+
cancel_eval_run: t("evals.run", "write"),
|
|
90
105
|
};
|
|
91
106
|
/** The grant id the policy gate and `approvals.ask_first` use for a Stageflow tool. */
|
|
92
107
|
export const STAGEFLOW_GRANT_PREFIX = "stageflow.";
|
package/dist/toolkit/profiles.js
CHANGED
|
@@ -11,7 +11,7 @@ export const PROFILE_GRANTS = {
|
|
|
11
11
|
},
|
|
12
12
|
"agent-author": {
|
|
13
13
|
prefix: "agent_author.",
|
|
14
|
-
tools: ["read_project_file", "list_project_files", "list_mcp_servers", "update_agent_draft"],
|
|
14
|
+
tools: ["read_agent_draft", "read_project_file", "list_project_files", "list_mcp_servers", "list_author_catalog", "update_agent_draft"],
|
|
15
15
|
},
|
|
16
16
|
};
|
|
17
17
|
export function profileGrantIds(profileId) {
|
|
@@ -3,10 +3,14 @@ export type StageflowManifestCatalog = {
|
|
|
3
3
|
pipelines: string[];
|
|
4
4
|
tasks: string[];
|
|
5
5
|
triggers?: string[];
|
|
6
|
+
evals?: string[];
|
|
7
|
+
datasets?: string[];
|
|
6
8
|
patterns?: {
|
|
7
9
|
pipeline?: string;
|
|
8
10
|
task?: string;
|
|
9
11
|
trigger?: string;
|
|
12
|
+
eval?: string;
|
|
13
|
+
dataset?: string | string[];
|
|
10
14
|
};
|
|
11
15
|
exclude?: string[];
|
|
12
16
|
};
|
|
@@ -26,5 +30,7 @@ export type LoadedManifest = {
|
|
|
26
30
|
pipeline: string;
|
|
27
31
|
task: string;
|
|
28
32
|
trigger: string;
|
|
33
|
+
eval: string;
|
|
34
|
+
dataset: string[];
|
|
29
35
|
};
|
|
30
36
|
};
|