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
package/dist/agents/store.js
CHANGED
|
@@ -9,6 +9,7 @@ export const SESSION_STATUSES = ["open", "running", "waiting", "held", "closed"]
|
|
|
9
9
|
export function isSessionStatus(value) {
|
|
10
10
|
return SESSION_STATUSES.includes(value);
|
|
11
11
|
}
|
|
12
|
+
const HIDE_EVAL = "source <> 'eval'";
|
|
12
13
|
export function agentProjectKey(projectRoot) {
|
|
13
14
|
return createHash("sha256").update(path.resolve(projectRoot)).digest("hex").slice(0, 16);
|
|
14
15
|
}
|
|
@@ -274,6 +275,8 @@ export class AgentStore {
|
|
|
274
275
|
/** One agent's sessions, or every agent's when `agentId` is omitted. */
|
|
275
276
|
listSessions(projectKey, agentId, query) {
|
|
276
277
|
const where = ["project_key = @projectKey"];
|
|
278
|
+
if (!query.includeEval)
|
|
279
|
+
where.push(HIDE_EVAL);
|
|
277
280
|
const params = { projectKey, limit: query.limit + 1 };
|
|
278
281
|
if (agentId !== undefined) {
|
|
279
282
|
where.push("agent_id = @agentId");
|
|
@@ -327,17 +330,17 @@ export class AgentStore {
|
|
|
327
330
|
};
|
|
328
331
|
}
|
|
329
332
|
/** One visitor's sessions on one agent, newest first (public web chat). */
|
|
330
|
-
listSessionsForRef(projectKey, agentId, source, sourceRef, limit) {
|
|
333
|
+
listSessionsForRef(projectKey, agentId, source, sourceRef, limit, includeEval = false) {
|
|
331
334
|
return this.db
|
|
332
335
|
.prepare(`SELECT * FROM agent_sessions
|
|
333
|
-
WHERE project_key = ? AND agent_id = ? AND source = ? AND source_ref = ?
|
|
336
|
+
WHERE project_key = ? AND agent_id = ? AND source = ? AND source_ref = ?${includeEval ? "" : ` AND ${HIDE_EVAL}`}
|
|
334
337
|
ORDER BY updated_at DESC, session_id DESC LIMIT ?`)
|
|
335
338
|
.all(projectKey, agentId, source, sourceRef, limit).map(toSession);
|
|
336
339
|
}
|
|
337
340
|
/** Stats for one agent, or for every agent when `agentId` is omitted. */
|
|
338
|
-
sessionStats(projectKey, agentId, since) {
|
|
339
|
-
const agentFilter = agentId === undefined ? "" : " AND agent_id = @agentId";
|
|
340
|
-
const sessionAgentFilter = agentId === undefined ? "" : " AND s.agent_id = @agentId";
|
|
341
|
+
sessionStats(projectKey, agentId, since, includeEval = false) {
|
|
342
|
+
const agentFilter = (agentId === undefined ? "" : " AND agent_id = @agentId") + (includeEval ? "" : ` AND ${HIDE_EVAL}`);
|
|
343
|
+
const sessionAgentFilter = (agentId === undefined ? "" : " AND s.agent_id = @agentId") + (includeEval ? "" : ` AND s.${HIDE_EVAL}`);
|
|
341
344
|
const bind = (extra) => (agentId === undefined ? extra : { ...extra, agentId });
|
|
342
345
|
const row = this.db
|
|
343
346
|
.prepare(`SELECT COUNT(*) AS total,
|
|
@@ -367,6 +370,41 @@ export class AgentStore {
|
|
|
367
370
|
costTotal: numOrNull(turns.cost_all),
|
|
368
371
|
};
|
|
369
372
|
}
|
|
373
|
+
/** Eval sessions below a session or an eval run: those whose `source_ref` is it, and theirs, recursively. */
|
|
374
|
+
listChildSessions(parentId) {
|
|
375
|
+
return this.db
|
|
376
|
+
.prepare(`WITH RECURSIVE below(session_id) AS (
|
|
377
|
+
SELECT session_id FROM agent_sessions WHERE source = 'eval' AND source_ref = ?
|
|
378
|
+
UNION
|
|
379
|
+
SELECT s.session_id FROM agent_sessions s JOIN below b ON s.source_ref = b.session_id WHERE s.source = 'eval'
|
|
380
|
+
)
|
|
381
|
+
SELECT s.* FROM agent_sessions s JOIN below b ON b.session_id = s.session_id ORDER BY s.created_at, s.session_id`)
|
|
382
|
+
.all(parentId).map(toSession);
|
|
383
|
+
}
|
|
384
|
+
/** Root eval sessions (those pointing at an eval run, not at a parent session), optionally of given runs or older than a time. */
|
|
385
|
+
listEvalRootSessions(filter = {}) {
|
|
386
|
+
const clauses = [`source = 'eval'`, `(source_ref IS NULL OR source_ref NOT IN (SELECT session_id FROM agent_sessions))`];
|
|
387
|
+
const params = [];
|
|
388
|
+
if (filter.sourceRefs) {
|
|
389
|
+
if (filter.sourceRefs.length === 0)
|
|
390
|
+
return [];
|
|
391
|
+
clauses.push(`source_ref IN (${filter.sourceRefs.map(() => "?").join(", ")})`);
|
|
392
|
+
params.push(...filter.sourceRefs);
|
|
393
|
+
}
|
|
394
|
+
if (filter.createdBefore) {
|
|
395
|
+
clauses.push(`created_at < ?`);
|
|
396
|
+
params.push(filter.createdBefore);
|
|
397
|
+
}
|
|
398
|
+
return this.db.prepare(`SELECT * FROM agent_sessions WHERE ${clauses.join(" AND ")} ORDER BY created_at, session_id`).all(...params).map(toSession);
|
|
399
|
+
}
|
|
400
|
+
/** Delete eval sessions; messages, turns, spans, scores and approvals go with them. Never touches other sessions. */
|
|
401
|
+
deleteSessions(sessionIds) {
|
|
402
|
+
this.transaction(() => {
|
|
403
|
+
const remove = this.db.prepare(`DELETE FROM agent_sessions WHERE session_id = ? AND source = 'eval'`);
|
|
404
|
+
for (const sessionId of sessionIds)
|
|
405
|
+
remove.run(sessionId);
|
|
406
|
+
});
|
|
407
|
+
}
|
|
370
408
|
/** Ids of every session an agent has had, for releasing what a runtime holds for them. */
|
|
371
409
|
sessionIdsOf(projectKey, agentId) {
|
|
372
410
|
return this.db.prepare(`SELECT session_id FROM agent_sessions WHERE project_key = ? AND agent_id = ?`).all(projectKey, agentId).map((row) => str(row.session_id));
|
|
@@ -562,10 +600,10 @@ export class AgentStore {
|
|
|
562
600
|
.prepare(`SELECT * FROM agent_approvals WHERE session_id = ? ORDER BY created_at`)
|
|
563
601
|
.all(sessionId).map(toApproval);
|
|
564
602
|
}
|
|
565
|
-
listPendingApprovals(projectKey) {
|
|
603
|
+
listPendingApprovals(projectKey, includeEval = false) {
|
|
566
604
|
return this.db
|
|
567
605
|
.prepare(`SELECT a.*, s.agent_id FROM agent_approvals a JOIN agent_sessions s ON s.session_id = a.session_id
|
|
568
|
-
WHERE s.project_key = ? AND a.status = 'pending' ORDER BY a.created_at`)
|
|
606
|
+
WHERE s.project_key = ? AND a.status = 'pending'${includeEval ? "" : ` AND s.${HIDE_EVAL}`} ORDER BY a.created_at`)
|
|
569
607
|
.all(projectKey).map((row) => ({ ...toApproval(row), agentId: str(row.agent_id) }));
|
|
570
608
|
}
|
|
571
609
|
decideApproval(approvalId, patch) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type AgentDefinition } from "../config/loadAgent.js";
|
|
2
|
+
export type ToolClass = "read" | "write" | "shell" | "destructive" | "external" | "mcp_unknown" | "sub_agent" | "browser" | "operator_only";
|
|
3
|
+
export type ToolClassification = {
|
|
4
|
+
class: ToolClass;
|
|
5
|
+
readOnly: boolean;
|
|
6
|
+
};
|
|
7
|
+
type Grants = Pick<AgentDefinition, "tools" | "sub_agents">;
|
|
8
|
+
/**
|
|
9
|
+
* What an eval may assume about a tool. `readOnly` is true only for what is provably read-only (builtin read tools,
|
|
10
|
+
* Stageflow tools with risk `read`) or an MCP tool the eval author declares in `read_only_tools` (a declaration never changes a builtin or Stageflow tool). Sub-agents and
|
|
11
|
+
* operator-only tools are never read-only.
|
|
12
|
+
*/
|
|
13
|
+
export declare function classifyTool(_definition: Grants | undefined, toolId: string, readOnlyExtra?: readonly string[]): ToolClassification;
|
|
14
|
+
export type ToolRiskEntry = {
|
|
15
|
+
tool: string;
|
|
16
|
+
class: ToolClass;
|
|
17
|
+
readOnly: boolean;
|
|
18
|
+
};
|
|
19
|
+
/** Every tool the agent is granted with how the `read_only` policy would treat it, for the eval picker. MCP wildcards stay as `<server>.*`. */
|
|
20
|
+
export declare function toolRiskSummary(definition: Grants, readOnlyExtra?: readonly string[]): ToolRiskEntry[];
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { grantedToolIds } from "../config/loadAgent.js";
|
|
2
|
+
import { isOperatorOnlyTool, STAGEFLOW_GRANT_PREFIX, TOOL_META } from "../toolkit/meta.js";
|
|
3
|
+
import { BUILTIN_TOOL_GROUP_OF } from "./runtime/types.js";
|
|
4
|
+
function listed(toolId, readOnlyExtra) {
|
|
5
|
+
if (readOnlyExtra.includes(toolId))
|
|
6
|
+
return true;
|
|
7
|
+
const dot = toolId.indexOf(".");
|
|
8
|
+
return dot > 0 && readOnlyExtra.includes(`${toolId.slice(0, dot)}.*`);
|
|
9
|
+
}
|
|
10
|
+
function baseClass(toolId) {
|
|
11
|
+
if (toolId === "browser")
|
|
12
|
+
return "browser";
|
|
13
|
+
if (toolId.startsWith("agent:"))
|
|
14
|
+
return "sub_agent";
|
|
15
|
+
if (toolId.startsWith(STAGEFLOW_GRANT_PREFIX)) {
|
|
16
|
+
const name = toolId.slice(STAGEFLOW_GRANT_PREFIX.length);
|
|
17
|
+
const meta = TOOL_META[name];
|
|
18
|
+
if (!meta)
|
|
19
|
+
return "mcp_unknown";
|
|
20
|
+
if (isOperatorOnlyTool(name))
|
|
21
|
+
return "operator_only";
|
|
22
|
+
return meta.risk;
|
|
23
|
+
}
|
|
24
|
+
const builtin = BUILTIN_TOOL_GROUP_OF[toolId];
|
|
25
|
+
if (builtin)
|
|
26
|
+
return builtin;
|
|
27
|
+
return "mcp_unknown";
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* What an eval may assume about a tool. `readOnly` is true only for what is provably read-only (builtin read tools,
|
|
31
|
+
* Stageflow tools with risk `read`) or an MCP tool the eval author declares in `read_only_tools` (a declaration never changes a builtin or Stageflow tool). Sub-agents and
|
|
32
|
+
* operator-only tools are never read-only.
|
|
33
|
+
*/
|
|
34
|
+
export function classifyTool(_definition, toolId, readOnlyExtra = []) {
|
|
35
|
+
let cls = baseClass(toolId);
|
|
36
|
+
if (cls === "operator_only" || cls === "sub_agent")
|
|
37
|
+
return { class: cls, readOnly: false };
|
|
38
|
+
const declared = listed(toolId, readOnlyExtra);
|
|
39
|
+
if (declared && cls === "mcp_unknown")
|
|
40
|
+
cls = "read";
|
|
41
|
+
return { class: cls, readOnly: cls === "read" };
|
|
42
|
+
}
|
|
43
|
+
/** Every tool the agent is granted with how the `read_only` policy would treat it, for the eval picker. MCP wildcards stay as `<server>.*`. */
|
|
44
|
+
export function toolRiskSummary(definition, readOnlyExtra = []) {
|
|
45
|
+
const ids = new Set(grantedToolIds(definition));
|
|
46
|
+
for (const [server, tools] of Object.entries(definition.tools.mcp))
|
|
47
|
+
if (tools.includes("*"))
|
|
48
|
+
ids.add(`${server}.*`);
|
|
49
|
+
return [...ids].sort().map((tool) => ({ tool, ...classifyTool(definition, tool, readOnlyExtra) }));
|
|
50
|
+
}
|
|
@@ -9,6 +9,8 @@ import { warnMissingCaPaths } from "../preflight/tls.js";
|
|
|
9
9
|
import { runPipelinePreflight, } from "../preflight/pipelinePreflight.js";
|
|
10
10
|
import { loadPipelineOutcome } from "../config/loadPipeline.js";
|
|
11
11
|
import { MCP_CATALOG_FILENAME } from "../config/resolveStageMcpServers.js";
|
|
12
|
+
import { MIN_NODE } from "../evals/engine/promptfoo/pinned.js";
|
|
13
|
+
import { engineStatus } from "../evals/engine/promptfoo/status.js";
|
|
12
14
|
import { globalStageflowHome } from "../project/globalHome.js";
|
|
13
15
|
import { createRunStore } from "../runstore/createStore.js";
|
|
14
16
|
import { readFilesystemSize, resolveMinFreeDiskFloor, } from "../runstore/diskUsage.js";
|
|
@@ -142,6 +144,29 @@ function nodeVersionCheck() {
|
|
|
142
144
|
message: `Node ${process.version}; engines floor may differ from Pi/better-sqlite3 (not bumping engines.node)`,
|
|
143
145
|
};
|
|
144
146
|
}
|
|
147
|
+
function evalEngineCheck(home) {
|
|
148
|
+
const status = engineStatus({ home });
|
|
149
|
+
if (!status.installed) {
|
|
150
|
+
return {
|
|
151
|
+
id: "eval_engine",
|
|
152
|
+
status: "skipped",
|
|
153
|
+
message: `Eval engine not installed (optional; promptfoo ${status.pinned}). Run \`${status.installCommand}\``,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
if (!status.nodeOk) {
|
|
157
|
+
return {
|
|
158
|
+
id: "eval_engine",
|
|
159
|
+
status: "warn",
|
|
160
|
+
code: "EVAL_NODE_TOO_OLD",
|
|
161
|
+
message: `Eval engine promptfoo ${status.version} installed, but Node ${status.node} is below the ${MIN_NODE} evals need`,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
id: "eval_engine",
|
|
166
|
+
status: "pass",
|
|
167
|
+
message: `Eval engine promptfoo ${status.version}`,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
145
170
|
function discoverProviderEnvIds(env) {
|
|
146
171
|
const byLower = new Set();
|
|
147
172
|
for (const key of Object.keys(env)) {
|
|
@@ -355,6 +380,7 @@ export async function runDoctorChecks(options) {
|
|
|
355
380
|
checks.push(tlsCheck(env));
|
|
356
381
|
checks.push(await freeDiskCheck(home, env));
|
|
357
382
|
checks.push(...(await mcpCommandsCheck(cwd)));
|
|
383
|
+
checks.push(evalEngineCheck(home));
|
|
358
384
|
let preflight;
|
|
359
385
|
if (options?.pipeline !== undefined) {
|
|
360
386
|
const outcome = await loadPipelineOutcome(options.pipeline, { cwd });
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type RunNpm } from "../evals/engine/promptfoo/install.js";
|
|
2
|
+
import { type EnsureGlobalServiceResult } from "../server/ensureGlobalService.js";
|
|
3
|
+
export declare const EVAL_USAGE = "Usage:\n sf eval list [--json]\n sf eval show <id|path> [--json]\n sf eval validate [<id|path>] [--json] [--strict]\n sf eval run <id|path> [--repeats <n>] [--judge <model>] [--model <id>] [--user-model <model>] [--allow-real-tools] [--max-cost <usd>] [--case <id> ...] [--tag <tag> ...] [--label <text>] [--no-wait] [--json]\n sf eval runs [<evalId>] [--json]\n sf eval runs show <evalRunId> [--json]\n sf eval runs cancel <evalRunId>\n sf eval runs delete <evalRunId>\n sf eval sort <evalRunId> [--classifier auto|jev|judge] [--limit <n>] [--resort] [--json]\n sf eval suggestions <evalRunId> [--status pending|accepted|dismissed] [--json]\n sf eval compare <evalRunIdA> <evalRunIdB> [--json]\n sf eval datasets [--json]\n sf eval engine status [--json]\n sf eval engine install\n\n Agent evals: --model overrides the agent's model, --user-model the model that plays the user. An eval whose\n conversation.tools is real also needs --allow-real-tools.\n\n Every subcommand also accepts --project-root <id-or-path>.";
|
|
4
|
+
export type EvalCommandIo = {
|
|
5
|
+
log: (line: string) => void;
|
|
6
|
+
error: (line: string) => void;
|
|
7
|
+
};
|
|
8
|
+
export type EvalCommandOptions = {
|
|
9
|
+
cwd?: string;
|
|
10
|
+
projectRoot?: string;
|
|
11
|
+
io?: Partial<EvalCommandIo>;
|
|
12
|
+
hostBaseUrl?: string;
|
|
13
|
+
ensureService?: () => Promise<EnsureGlobalServiceResult>;
|
|
14
|
+
home?: string;
|
|
15
|
+
runNpm?: RunNpm;
|
|
16
|
+
pollIntervalMs?: number;
|
|
17
|
+
stderrIsTTY?: boolean;
|
|
18
|
+
onInterrupt?: (handler: () => void) => () => void;
|
|
19
|
+
};
|
|
20
|
+
export declare function runEvalCommand(args: string[], options?: EvalCommandOptions): Promise<number>;
|