@sanity/ailf 0.5.0 → 1.0.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/config/features.ts +23 -0
- package/config/models.ts +83 -0
- package/config/prompts.ts +16 -0
- package/config/rubrics.ts +225 -0
- package/config/schedules.ts +47 -0
- package/config/sinks.ts +37 -0
- package/config/sources.ts +21 -0
- package/config/thresholds.ts +61 -0
- package/dist/_vendor/ailf-core/config-helpers.d.ts +174 -0
- package/dist/_vendor/ailf-core/config-helpers.js +150 -0
- package/dist/_vendor/ailf-core/env-helper.d.ts +35 -0
- package/dist/_vendor/ailf-core/env-helper.js +45 -0
- package/dist/_vendor/ailf-core/index.d.ts +3 -0
- package/dist/_vendor/ailf-core/index.js +5 -0
- package/dist/_vendor/ailf-core/ports/context.d.ts +15 -2
- package/dist/_vendor/ailf-core/ports/doc-fetcher.d.ts +2 -2
- package/dist/_vendor/ailf-core/ports/index.d.ts +2 -1
- package/dist/_vendor/ailf-core/ports/mode-handler.d.ts +129 -0
- package/dist/_vendor/ailf-core/ports/mode-handler.js +19 -0
- package/dist/_vendor/ailf-core/ports/task-source.d.ts +16 -122
- package/dist/_vendor/ailf-core/ports/task-source.js +7 -7
- package/dist/_vendor/ailf-core/schemas/eval-config.d.ts +7 -2
- package/dist/_vendor/ailf-core/schemas/eval-config.js +7 -2
- package/dist/_vendor/ailf-core/schemas/pipeline-request.d.ts +8 -3
- package/dist/_vendor/ailf-core/schemas/pipeline-request.js +6 -1
- package/dist/_vendor/ailf-core/schemas/pipeline.d.ts +14 -29
- package/dist/_vendor/ailf-core/schemas/pipeline.js +17 -8
- package/dist/_vendor/ailf-core/schemas/schedules.d.ts +14 -4
- package/dist/_vendor/ailf-core/schemas/schedules.js +6 -2
- package/dist/_vendor/ailf-core/schemas/sinks.d.ts +1 -1
- package/dist/_vendor/ailf-core/services/comparison-formatters.js +57 -19
- package/dist/_vendor/ailf-core/services/index.d.ts +2 -1
- package/dist/_vendor/ailf-core/services/index.js +2 -1
- package/dist/_vendor/ailf-core/services/scoring-engine.d.ts +153 -0
- package/dist/_vendor/ailf-core/services/scoring-engine.js +237 -0
- package/dist/_vendor/ailf-core/services/scoring.d.ts +15 -2
- package/dist/_vendor/ailf-core/services/scoring.js +25 -15
- package/dist/_vendor/ailf-core/types/branded-ids.d.ts +137 -0
- package/dist/_vendor/ailf-core/types/branded-ids.js +136 -0
- package/dist/_vendor/ailf-core/types/eval-mode-config.d.ts +150 -0
- package/dist/_vendor/ailf-core/types/eval-mode-config.js +24 -0
- package/dist/_vendor/ailf-core/types/generalized-task.d.ts +319 -0
- package/dist/_vendor/ailf-core/types/generalized-task.js +13 -0
- package/dist/_vendor/ailf-core/types/index.d.ts +45 -81
- package/dist/_vendor/ailf-core/types/index.js +8 -1
- package/dist/_vendor/ailf-core/types/plugin-registry.d.ts +202 -0
- package/dist/_vendor/ailf-core/types/plugin-registry.js +132 -0
- package/dist/_vendor/ailf-core/types/storage-schema.d.ts +199 -0
- package/dist/_vendor/ailf-core/types/storage-schema.js +39 -0
- package/dist/_vendor/ailf-core/types/task-graph.d.ts +86 -0
- package/dist/_vendor/ailf-core/types/task-graph.js +20 -0
- package/dist/_vendor/ailf-core/types/trace.d.ts +118 -0
- package/dist/_vendor/ailf-core/types/trace.js +18 -0
- package/dist/_vendor/ailf-core/types/variable-envelope.d.ts +80 -0
- package/dist/_vendor/ailf-core/types/variable-envelope.js +16 -0
- package/dist/_vendor/ailf-shared/dimension-names.d.ts +5 -18
- package/dist/_vendor/ailf-shared/dimension-names.js +6 -24
- package/dist/_vendor/ailf-shared/eval-modes.d.ts +38 -6
- package/dist/_vendor/ailf-shared/eval-modes.js +26 -2
- package/dist/_vendor/ailf-shared/index.d.ts +0 -1
- package/dist/_vendor/ailf-shared/index.js +0 -1
- package/dist/adapters/api-client/build-request.js +14 -13
- package/dist/adapters/config-sources/file-config-adapter.d.ts +20 -11
- package/dist/adapters/config-sources/file-config-adapter.js +38 -12
- package/dist/adapters/config-sources/index.d.ts +2 -0
- package/dist/adapters/config-sources/index.js +1 -0
- package/dist/adapters/config-sources/ts-config-loader.d.ts +59 -0
- package/dist/adapters/config-sources/ts-config-loader.js +133 -0
- package/dist/adapters/doc-fetchers/sanity-doc-fetcher.d.ts +3 -2
- package/dist/adapters/doc-fetchers/sanity-doc-fetcher.js +7 -2
- package/dist/adapters/task-sources/composite-task-source.d.ts +3 -3
- package/dist/adapters/task-sources/composite-task-source.js +1 -1
- package/dist/adapters/task-sources/content-lake-task-source.d.ts +7 -6
- package/dist/adapters/task-sources/content-lake-task-source.js +22 -23
- package/dist/adapters/task-sources/index.d.ts +1 -0
- package/dist/adapters/task-sources/index.js +1 -0
- package/dist/adapters/task-sources/repo-task-source.d.ts +4 -4
- package/dist/adapters/task-sources/repo-task-source.js +69 -16
- package/dist/adapters/task-sources/task-file-loader.d.ts +64 -0
- package/dist/adapters/task-sources/task-file-loader.js +83 -0
- package/dist/adapters/task-sources/yaml-task-source.d.ts +6 -6
- package/dist/adapters/task-sources/yaml-task-source.js +19 -16
- package/dist/cli.js +0 -2
- package/dist/commands/baseline.js +4 -1
- package/dist/commands/calculate-scores.js +1 -1
- package/dist/commands/coverage-audit.js +7 -1
- package/dist/commands/explain-handler.js +25 -23
- package/dist/commands/fetch-docs.js +3 -2
- package/dist/commands/generate-configs.js +1 -1
- package/dist/commands/interactive.js +11 -7
- package/dist/commands/pipeline-action.d.ts +2 -0
- package/dist/commands/pipeline-action.js +16 -6
- package/dist/commands/pipeline.d.ts +1 -0
- package/dist/commands/pipeline.js +4 -2
- package/dist/commands/pr-comment.js +1 -1
- package/dist/commands/publish.js +2 -2
- package/dist/commands/readiness-report.js +13 -6
- package/dist/composition-root.d.ts +1 -1
- package/dist/composition-root.js +67 -4
- package/dist/orchestration/build-app-context.js +1 -0
- package/dist/orchestration/build-step-sequence.js +24 -6
- package/dist/orchestration/steps/calculate-scores-step.js +24 -11
- package/dist/orchestration/steps/fetch-docs-step.js +6 -4
- package/dist/orchestration/steps/gap-analysis-step.js +8 -7
- package/dist/orchestration/steps/generate-configs-step.d.ts +16 -3
- package/dist/orchestration/steps/generate-configs-step.js +245 -51
- package/dist/orchestration/steps/grader-consistency-step.js +7 -4
- package/dist/orchestration/steps/mirror-repo-tasks-step.js +1 -1
- package/dist/orchestration/steps/readiness-step.js +5 -6
- package/dist/orchestration/steps/run-eval-step.d.ts +1 -2
- package/dist/orchestration/steps/run-eval-step.js +8 -7
- package/dist/pipeline/cache.d.ts +1 -1
- package/dist/pipeline/cache.js +36 -8
- package/dist/pipeline/calculate-scores.d.ts +2 -4
- package/dist/pipeline/calculate-scores.js +43 -113
- package/dist/pipeline/checks.js +2 -2
- package/dist/pipeline/compare.js +8 -8
- package/dist/pipeline/compiler/__tests__/agent-harness-handler.test.d.ts +10 -0
- package/dist/pipeline/compiler/__tests__/agent-harness-handler.test.js +288 -0
- package/dist/pipeline/compiler/__tests__/assertion-mapper.test.d.ts +9 -0
- package/dist/pipeline/compiler/__tests__/assertion-mapper.test.js +145 -0
- package/dist/pipeline/compiler/__tests__/knowledge-probe-handler.test.d.ts +10 -0
- package/dist/pipeline/compiler/__tests__/knowledge-probe-handler.test.js +314 -0
- package/dist/pipeline/compiler/__tests__/literacy-handler.test.d.ts +10 -0
- package/dist/pipeline/compiler/__tests__/literacy-handler.test.js +486 -0
- package/dist/pipeline/compiler/__tests__/mcp-server-handler.test.d.ts +10 -0
- package/dist/pipeline/compiler/__tests__/mcp-server-handler.test.js +355 -0
- package/dist/pipeline/compiler/__tests__/promptfoo-compiler.test.d.ts +9 -0
- package/dist/pipeline/compiler/__tests__/promptfoo-compiler.test.js +333 -0
- package/dist/pipeline/compiler/__tests__/sandbox-and-fixtures.test.d.ts +12 -0
- package/dist/pipeline/compiler/__tests__/sandbox-and-fixtures.test.js +210 -0
- package/dist/pipeline/compiler/__tests__/scoring-and-presets.test.d.ts +7 -0
- package/dist/pipeline/compiler/__tests__/scoring-and-presets.test.js +471 -0
- package/dist/pipeline/compiler/__tests__/scoring-bridge.test.d.ts +10 -0
- package/dist/pipeline/compiler/__tests__/scoring-bridge.test.js +184 -0
- package/dist/pipeline/compiler/__tests__/task-graph-builder.test.d.ts +8 -0
- package/dist/pipeline/compiler/__tests__/task-graph-builder.test.js +301 -0
- package/dist/pipeline/compiler/__tests__/telemetry.test.d.ts +9 -0
- package/dist/pipeline/compiler/__tests__/telemetry.test.js +503 -0
- package/dist/pipeline/compiler/assertion-mapper.d.ts +58 -0
- package/dist/pipeline/compiler/assertion-mapper.js +175 -0
- package/dist/pipeline/compiler/compiler-to-yaml.d.ts +51 -0
- package/dist/pipeline/compiler/compiler-to-yaml.js +222 -0
- package/dist/pipeline/compiler/config-loader.d.ts +56 -0
- package/dist/pipeline/compiler/config-loader.js +111 -0
- package/dist/pipeline/compiler/fixture-resolver.d.ts +41 -0
- package/dist/pipeline/compiler/fixture-resolver.js +113 -0
- package/dist/pipeline/compiler/hash.d.ts +11 -0
- package/dist/pipeline/compiler/hash.js +18 -0
- package/dist/pipeline/compiler/ignore-fields.d.ts +53 -0
- package/dist/pipeline/compiler/ignore-fields.js +113 -0
- package/dist/pipeline/compiler/index.d.ts +29 -0
- package/dist/pipeline/compiler/index.js +45 -0
- package/dist/pipeline/compiler/literacy-bridge.d.ts +102 -0
- package/dist/pipeline/compiler/literacy-bridge.js +172 -0
- package/dist/pipeline/compiler/mode-handlers/__fixtures__/agent-harness-example-tasks.d.ts +14 -0
- package/dist/pipeline/compiler/mode-handlers/__fixtures__/agent-harness-example-tasks.js +152 -0
- package/dist/pipeline/compiler/mode-handlers/__fixtures__/knowledge-probe-example-tasks.d.ts +32 -0
- package/dist/pipeline/compiler/mode-handlers/__fixtures__/knowledge-probe-example-tasks.js +176 -0
- package/dist/pipeline/compiler/mode-handlers/__fixtures__/mcp-example-tasks.d.ts +49 -0
- package/dist/pipeline/compiler/mode-handlers/__fixtures__/mcp-example-tasks.js +259 -0
- package/dist/pipeline/compiler/mode-handlers/agent-harness-handler.d.ts +70 -0
- package/dist/pipeline/compiler/mode-handlers/agent-harness-handler.js +485 -0
- package/dist/pipeline/compiler/mode-handlers/index.d.ts +16 -0
- package/dist/pipeline/compiler/mode-handlers/index.js +21 -0
- package/dist/pipeline/compiler/mode-handlers/knowledge-probe-handler.d.ts +76 -0
- package/dist/pipeline/compiler/mode-handlers/knowledge-probe-handler.js +245 -0
- package/dist/pipeline/compiler/mode-handlers/literacy-handler.d.ts +89 -0
- package/dist/pipeline/compiler/mode-handlers/literacy-handler.js +379 -0
- package/dist/pipeline/compiler/mode-handlers/mcp-assertions.d.ts +50 -0
- package/dist/pipeline/compiler/mode-handlers/mcp-assertions.js +277 -0
- package/dist/pipeline/compiler/mode-handlers/mcp-server-handler.d.ts +67 -0
- package/dist/pipeline/compiler/mode-handlers/mcp-server-handler.js +309 -0
- package/dist/pipeline/compiler/presets/index.d.ts +9 -0
- package/dist/pipeline/compiler/presets/index.js +8 -0
- package/dist/pipeline/compiler/presets/sanity-literacy.d.ts +45 -0
- package/dist/pipeline/compiler/presets/sanity-literacy.js +354 -0
- package/dist/pipeline/compiler/promptfoo-compiler.d.ts +96 -0
- package/dist/pipeline/compiler/promptfoo-compiler.js +230 -0
- package/dist/pipeline/compiler/provider-assembler.d.ts +39 -0
- package/dist/pipeline/compiler/provider-assembler.js +137 -0
- package/dist/pipeline/compiler/sandbox/docker-sandbox.d.ts +21 -0
- package/dist/pipeline/compiler/sandbox/docker-sandbox.js +136 -0
- package/dist/pipeline/compiler/sandbox/fixture-provisioner.d.ts +69 -0
- package/dist/pipeline/compiler/sandbox/fixture-provisioner.js +189 -0
- package/dist/pipeline/compiler/sandbox/git-worktree-sandbox.d.ts +20 -0
- package/dist/pipeline/compiler/sandbox/git-worktree-sandbox.js +114 -0
- package/dist/pipeline/compiler/sandbox/index.d.ts +10 -0
- package/dist/pipeline/compiler/sandbox/index.js +11 -0
- package/dist/pipeline/compiler/sandbox/sandbox-selector.d.ts +35 -0
- package/dist/pipeline/compiler/sandbox/sandbox-selector.js +86 -0
- package/dist/pipeline/compiler/sandbox/sandbox-strategy.d.ts +81 -0
- package/dist/pipeline/compiler/sandbox/sandbox-strategy.js +15 -0
- package/dist/pipeline/compiler/sandbox/tempdir-sandbox.d.ts +20 -0
- package/dist/pipeline/compiler/sandbox/tempdir-sandbox.js +74 -0
- package/dist/pipeline/compiler/scoring-bridge.d.ts +49 -0
- package/dist/pipeline/compiler/scoring-bridge.js +114 -0
- package/dist/pipeline/compiler/task-graph-builder.d.ts +54 -0
- package/dist/pipeline/compiler/task-graph-builder.js +291 -0
- package/dist/pipeline/compiler/telemetry/cost-tracker.d.ts +90 -0
- package/dist/pipeline/compiler/telemetry/cost-tracker.js +146 -0
- package/dist/pipeline/compiler/telemetry/index.d.ts +14 -0
- package/dist/pipeline/compiler/telemetry/index.js +19 -0
- package/dist/pipeline/compiler/telemetry/redactor.d.ts +58 -0
- package/dist/pipeline/compiler/telemetry/redactor.js +222 -0
- package/dist/pipeline/compiler/telemetry/tool-classifier.d.ts +32 -0
- package/dist/pipeline/compiler/telemetry/tool-classifier.js +120 -0
- package/dist/pipeline/compiler/telemetry/trace-collector.d.ts +75 -0
- package/dist/pipeline/compiler/telemetry/trace-collector.js +297 -0
- package/dist/pipeline/compiler/telemetry/trace-store.d.ts +78 -0
- package/dist/pipeline/compiler/telemetry/trace-store.js +85 -0
- package/dist/pipeline/compiler/variable-resolver.d.ts +46 -0
- package/dist/pipeline/compiler/variable-resolver.js +115 -0
- package/dist/pipeline/coverage-audit.d.ts +15 -5
- package/dist/pipeline/coverage-audit.js +41 -22
- package/dist/pipeline/eval-constants.d.ts +16 -6
- package/dist/pipeline/eval-constants.js +25 -4
- package/dist/pipeline/eval-fingerprint.d.ts +2 -2
- package/dist/pipeline/eval-fingerprint.js +8 -9
- package/dist/pipeline/expand-tasks.d.ts +19 -10
- package/dist/pipeline/expand-tasks.js +34 -28
- package/dist/pipeline/gap-analysis.d.ts +1 -1
- package/dist/pipeline/gap-analysis.js +2 -2
- package/dist/pipeline/generate-configs.d.ts +22 -4
- package/dist/pipeline/generate-configs.js +53 -24
- package/dist/pipeline/grader-api.d.ts +3 -3
- package/dist/pipeline/grader-api.js +5 -12
- package/dist/pipeline/grader-compare-runner.js +20 -27
- package/dist/pipeline/grader-comparison.d.ts +4 -8
- package/dist/pipeline/grader-comparison.js +11 -17
- package/dist/pipeline/grader-consistency-runner.d.ts +2 -3
- package/dist/pipeline/grader-consistency-runner.js +16 -20
- package/dist/pipeline/grader-consistency.d.ts +6 -10
- package/dist/pipeline/grader-consistency.js +13 -32
- package/dist/pipeline/grader-sensitivity-runner.js +7 -5
- package/dist/pipeline/grader-sensitivity.d.ts +2 -6
- package/dist/pipeline/grader-sensitivity.js +10 -10
- package/dist/pipeline/grader-validate-runner.js +7 -5
- package/dist/pipeline/grader-validation.d.ts +2 -6
- package/dist/pipeline/grader-validation.js +14 -22
- package/dist/pipeline/map-request-to-config.js +6 -1
- package/dist/pipeline/mirror-repo-tasks.d.ts +6 -6
- package/dist/pipeline/mirror-repo-tasks.js +16 -15
- package/dist/pipeline/normalize-mode.d.ts +49 -0
- package/dist/pipeline/normalize-mode.js +64 -0
- package/dist/pipeline/plan.d.ts +5 -2
- package/dist/pipeline/plan.js +134 -78
- package/dist/pipeline/pr-comment.js +2 -0
- package/dist/pipeline/profile-resolution.d.ts +22 -14
- package/dist/pipeline/profile-resolution.js +41 -19
- package/dist/pipeline/provenance.d.ts +2 -2
- package/dist/pipeline/provenance.js +12 -17
- package/dist/pipeline/release-report.js +4 -4
- package/dist/pipeline/repo-threshold-evaluator.d.ts +1 -1
- package/dist/pipeline/repo-threshold-evaluator.js +1 -1
- package/dist/pipeline/rubric-loader.d.ts +20 -0
- package/dist/pipeline/rubric-loader.js +37 -0
- package/dist/pipeline/validate.d.ts +4 -4
- package/dist/pipeline/validate.js +64 -53
- package/dist/schedules/loader.js +18 -8
- package/dist/scripts/migrate-task-mode.d.ts +24 -0
- package/dist/scripts/migrate-task-mode.js +85 -0
- package/dist/scripts/migrate-tasks-to-content-lake.js +11 -10
- package/dist/scripts/validate-task-sources.d.ts +1 -1
- package/dist/scripts/validate-task-sources.js +15 -15
- package/dist/sinks/loader.js +5 -7
- package/dist/sources.d.ts +7 -7
- package/dist/sources.js +22 -24
- package/dist/webhook/dispatch.js +2 -1
- package/package.json +6 -3
- package/tasks/knowledge-probe/define-type-api.task.ts +55 -0
- package/tasks/knowledge-probe/groq-projections.task.ts +59 -0
- package/tasks/literacy/frameworks.task.ts +128 -0
- package/tasks/literacy/functions.task.ts +69 -0
- package/tasks/literacy/groq.task.ts +258 -0
- package/tasks/literacy/nextjs-live.task.ts +75 -0
- package/tasks/literacy/studio-setup.task.ts +131 -0
- package/tasks/literacy/visual-editing.task.ts +146 -0
- package/config/features.yaml +0 -116
- package/config/models.yaml +0 -116
- package/config/prompts.yaml +0 -75
- package/config/rubrics.yaml +0 -81
- package/config/schedules.yaml +0 -43
- package/config/sinks.yaml +0 -54
- package/config/sources.yaml +0 -51
- package/config/thresholds.yaml +0 -49
- package/dist/agent-observer/test-imports.d.ts +0 -7
- package/dist/agent-observer/test-imports.js +0 -185
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example MCP server task definitions — Sanity MCP Server reference.
|
|
3
|
+
*
|
|
4
|
+
* These are reference implementations showing how to author MCP server
|
|
5
|
+
* evaluation tasks. They model the real Sanity MCP Server (mcp.sanity.io)
|
|
6
|
+
* and its actual tool names. They serve as:
|
|
7
|
+
*
|
|
8
|
+
* 1. Documentation — developers learn the API by reading examples
|
|
9
|
+
* 2. Test fixtures — the compiler tests compile these and verify output
|
|
10
|
+
* 3. Validation — proves the compiler handles real-world task shapes
|
|
11
|
+
* 4. Reference — shows all transport types, auth patterns, and assertion styles
|
|
12
|
+
*
|
|
13
|
+
* NOTE: These are NOT executable without a valid SANITY_MCP_AUTH_TOKEN.
|
|
14
|
+
* They exist purely for compilation testing and as authoring examples.
|
|
15
|
+
* For real evaluation, write tasks in an external repo's .ailf/tasks/
|
|
16
|
+
* directory or a standalone config file.
|
|
17
|
+
*
|
|
18
|
+
* @see https://www.sanity.io/docs/ai/mcp-server — Sanity MCP Server docs
|
|
19
|
+
* @see https://www.promptfoo.dev/docs/providers/mcp/ — Promptfoo MCP provider
|
|
20
|
+
*/
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Shared server config — reusable across tasks targeting the same server
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
const SANITY_MCP_SERVER = {
|
|
25
|
+
transport: "streamable-http",
|
|
26
|
+
url: "https://mcp.sanity.io",
|
|
27
|
+
auth: {
|
|
28
|
+
type: "bearer",
|
|
29
|
+
token: "{{env.SANITY_MCP_AUTH_TOKEN}}",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
// Task 1: GROQ query via query_documents tool
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
/**
|
|
36
|
+
* Tests that a model can construct a valid GROQ query and use the
|
|
37
|
+
* query_documents tool to fetch results from a Sanity dataset.
|
|
38
|
+
*/
|
|
39
|
+
export const queryDocumentsTask = {
|
|
40
|
+
mode: "mcp-server",
|
|
41
|
+
id: "mcp-query-documents",
|
|
42
|
+
title: "MCP: Query documents with GROQ",
|
|
43
|
+
description: "Use the Sanity MCP server's query_documents tool to fetch " +
|
|
44
|
+
"documents from a dataset using GROQ. Verify the model constructs " +
|
|
45
|
+
"a valid GROQ query and interprets the response correctly.",
|
|
46
|
+
area: "mcp",
|
|
47
|
+
difficulty: "intermediate",
|
|
48
|
+
tags: ["mcp", "groq", "query"],
|
|
49
|
+
serverConfig: SANITY_MCP_SERVER,
|
|
50
|
+
capabilities: ["query_documents", "get_schema"],
|
|
51
|
+
prompt: {
|
|
52
|
+
text: "Using the Sanity MCP server, query for all documents of type " +
|
|
53
|
+
'"article" in the production dataset. Return their titles and ' +
|
|
54
|
+
"slugs, ordered by creation date descending. Limit to 5 results.",
|
|
55
|
+
},
|
|
56
|
+
assertions: [
|
|
57
|
+
{ type: "tool-called", value: "query_documents" },
|
|
58
|
+
{ type: "contains", value: "_type" },
|
|
59
|
+
{ type: "contains", value: "article" },
|
|
60
|
+
{
|
|
61
|
+
type: "llm-rubric",
|
|
62
|
+
template: "mcp-output-correctness",
|
|
63
|
+
criteria: [
|
|
64
|
+
"Constructs a valid GROQ query with _type filter",
|
|
65
|
+
"Includes a projection with title and slug fields",
|
|
66
|
+
"Orders by _createdAt descending",
|
|
67
|
+
"Limits results to 5 with slice syntax [0...5] or [0..4]",
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// Task 2: Schema inspection via get_schema tool
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
/**
|
|
76
|
+
* Tests that a model can retrieve and interpret schema information
|
|
77
|
+
* from the MCP server.
|
|
78
|
+
*/
|
|
79
|
+
export const inspectSchemaTask = {
|
|
80
|
+
mode: "mcp-server",
|
|
81
|
+
id: "mcp-get-schema",
|
|
82
|
+
title: "MCP: Inspect schema and describe document types",
|
|
83
|
+
description: "Use the Sanity MCP server's get_schema tool to inspect the " +
|
|
84
|
+
"content model and describe the available document types.",
|
|
85
|
+
area: "mcp",
|
|
86
|
+
difficulty: "basic",
|
|
87
|
+
tags: ["mcp", "schema"],
|
|
88
|
+
serverConfig: SANITY_MCP_SERVER,
|
|
89
|
+
capabilities: ["get_schema"],
|
|
90
|
+
prompt: {
|
|
91
|
+
text: "Using the Sanity MCP server, retrieve the schema for the current " +
|
|
92
|
+
"workspace. List all document types and describe the fields of the " +
|
|
93
|
+
'most complex one. Focus on reference fields and "block" (Portable Text) fields.',
|
|
94
|
+
},
|
|
95
|
+
assertions: [
|
|
96
|
+
{ type: "tool-called", value: "get_schema" },
|
|
97
|
+
{
|
|
98
|
+
type: "llm-rubric",
|
|
99
|
+
template: "mcp-output-correctness",
|
|
100
|
+
criteria: [
|
|
101
|
+
"Successfully calls get_schema to retrieve the workspace schema",
|
|
102
|
+
"Identifies and lists the document types",
|
|
103
|
+
"Describes field structures including types and references",
|
|
104
|
+
"Correctly identifies Portable Text (block) fields",
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
};
|
|
109
|
+
// ---------------------------------------------------------------------------
|
|
110
|
+
// Task 3: Multi-step create → verify → publish (multi-turn)
|
|
111
|
+
// ---------------------------------------------------------------------------
|
|
112
|
+
/**
|
|
113
|
+
* Tests a multi-step document lifecycle workflow using multiple tools
|
|
114
|
+
* across a multi-turn conversation. This is the most complex example,
|
|
115
|
+
* demonstrating tool chaining and verification patterns.
|
|
116
|
+
*/
|
|
117
|
+
export const createAndPublishTask = {
|
|
118
|
+
mode: "mcp-server",
|
|
119
|
+
id: "mcp-create-publish",
|
|
120
|
+
title: "MCP: Create a draft document and publish it",
|
|
121
|
+
description: "Use the Sanity MCP server to create a new draft document, " +
|
|
122
|
+
"verify it was created, then publish it. Tests the multi-step " +
|
|
123
|
+
"workflow of create → verify → publish.",
|
|
124
|
+
area: "mcp",
|
|
125
|
+
difficulty: "advanced",
|
|
126
|
+
tags: ["mcp", "crud", "multi-step"],
|
|
127
|
+
serverConfig: SANITY_MCP_SERVER,
|
|
128
|
+
capabilities: [
|
|
129
|
+
"create_documents_from_json",
|
|
130
|
+
"get_document",
|
|
131
|
+
"publish_documents",
|
|
132
|
+
"query_documents",
|
|
133
|
+
],
|
|
134
|
+
multiTurn: {
|
|
135
|
+
turns: [
|
|
136
|
+
{
|
|
137
|
+
role: "user",
|
|
138
|
+
content: "Create a new draft article document with the title " +
|
|
139
|
+
'"MCP Integration Test" and a slug of "mcp-integration-test". ' +
|
|
140
|
+
"Use the create_documents_from_json tool.",
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
role: "user",
|
|
144
|
+
content: "Now verify the draft was created by querying for it. " +
|
|
145
|
+
"Use query_documents with a GROQ query that fetches the " +
|
|
146
|
+
'document by its slug "mcp-integration-test".',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
role: "user",
|
|
150
|
+
content: "Finally, publish the draft document using the publish_documents tool.",
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
assertions: [
|
|
155
|
+
{ type: "tool-called", value: "create_documents_from_json" },
|
|
156
|
+
{ type: "tool-called", value: "query_documents" },
|
|
157
|
+
{ type: "tool-called", value: "publish_documents" },
|
|
158
|
+
{
|
|
159
|
+
type: "llm-rubric",
|
|
160
|
+
template: "mcp-output-correctness",
|
|
161
|
+
criteria: [
|
|
162
|
+
"Creates a draft document with the correct _type and fields",
|
|
163
|
+
"Verifies the draft exists via GROQ query",
|
|
164
|
+
"Publishes the draft using the correct document ID",
|
|
165
|
+
"Handles the multi-step workflow in the correct order",
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
type: "llm-rubric",
|
|
170
|
+
template: "mcp-error-handling",
|
|
171
|
+
criteria: [
|
|
172
|
+
"Handles potential errors (missing type, invalid schema) gracefully",
|
|
173
|
+
"Verifies each step before proceeding to the next",
|
|
174
|
+
],
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
};
|
|
178
|
+
// ---------------------------------------------------------------------------
|
|
179
|
+
// Task 4: Semantic search (embeddings)
|
|
180
|
+
// ---------------------------------------------------------------------------
|
|
181
|
+
/**
|
|
182
|
+
* Tests that a model can discover embeddings indices and perform
|
|
183
|
+
* semantic search against them.
|
|
184
|
+
*/
|
|
185
|
+
export const semanticSearchTask = {
|
|
186
|
+
mode: "mcp-server",
|
|
187
|
+
id: "mcp-semantic-search",
|
|
188
|
+
title: "MCP: Semantic search for related content",
|
|
189
|
+
description: "Use the Sanity MCP server's semantic_search tool to find " +
|
|
190
|
+
"content related to a natural language query.",
|
|
191
|
+
area: "mcp",
|
|
192
|
+
difficulty: "intermediate",
|
|
193
|
+
tags: ["mcp", "search", "embeddings"],
|
|
194
|
+
serverConfig: SANITY_MCP_SERVER,
|
|
195
|
+
capabilities: ["semantic_search", "list_embeddings_indices", "get_document"],
|
|
196
|
+
prompt: {
|
|
197
|
+
text: "Using the Sanity MCP server, first list the available embeddings " +
|
|
198
|
+
"indices, then perform a semantic search for content related to " +
|
|
199
|
+
'"how to set up real-time previews in Next.js". Return the top 3 ' +
|
|
200
|
+
"most relevant documents with their titles and relevance scores.",
|
|
201
|
+
},
|
|
202
|
+
assertions: [
|
|
203
|
+
{ type: "tool-called", value: "list_embeddings_indices" },
|
|
204
|
+
{ type: "tool-called", value: "semantic_search" },
|
|
205
|
+
{
|
|
206
|
+
type: "llm-rubric",
|
|
207
|
+
template: "mcp-output-correctness",
|
|
208
|
+
criteria: [
|
|
209
|
+
"Lists available embeddings indices before searching",
|
|
210
|
+
"Selects an appropriate index for the search",
|
|
211
|
+
"Constructs a meaningful search query",
|
|
212
|
+
"Returns relevant results with titles and scores",
|
|
213
|
+
],
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
};
|
|
217
|
+
// ---------------------------------------------------------------------------
|
|
218
|
+
// Task 5: Local stdio server (shows command-based transport)
|
|
219
|
+
// ---------------------------------------------------------------------------
|
|
220
|
+
/**
|
|
221
|
+
* Demonstrates a stdio-based MCP server (local process) for contrast
|
|
222
|
+
* with the remote streamable-http tasks above.
|
|
223
|
+
*/
|
|
224
|
+
export const stdioServerTask = {
|
|
225
|
+
mode: "mcp-server",
|
|
226
|
+
id: "mcp-stdio-local",
|
|
227
|
+
title: "MCP: Local stdio server — getDocument",
|
|
228
|
+
description: "Call a locally running MCP server via stdio transport to " +
|
|
229
|
+
"fetch a document. Demonstrates command-based server config.",
|
|
230
|
+
area: "mcp",
|
|
231
|
+
difficulty: "basic",
|
|
232
|
+
tags: ["mcp", "stdio", "local"],
|
|
233
|
+
serverConfig: {
|
|
234
|
+
transport: "stdio",
|
|
235
|
+
command: "node dist/sanity-mcp-server.js",
|
|
236
|
+
env: {
|
|
237
|
+
SANITY_PROJECT_ID: "test-project",
|
|
238
|
+
SANITY_DATASET: "production",
|
|
239
|
+
},
|
|
240
|
+
startupTimeoutMs: 5000,
|
|
241
|
+
},
|
|
242
|
+
capabilities: ["tools/list", "tools/call"],
|
|
243
|
+
prompt: {
|
|
244
|
+
text: "Fetch the document with ID 'article-123' from the Sanity Content Lake.",
|
|
245
|
+
},
|
|
246
|
+
assertions: [
|
|
247
|
+
{ type: "tool-called", value: "getDocument" },
|
|
248
|
+
{ type: "contains", value: "article-123" },
|
|
249
|
+
],
|
|
250
|
+
options: { timeout: 30_000 },
|
|
251
|
+
};
|
|
252
|
+
/** All example MCP tasks — used by compiler tests */
|
|
253
|
+
export const allMCPExampleTasks = [
|
|
254
|
+
queryDocumentsTask,
|
|
255
|
+
inspectSchemaTask,
|
|
256
|
+
createAndPublishTask,
|
|
257
|
+
semanticSearchTask,
|
|
258
|
+
stdioServerTask,
|
|
259
|
+
];
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentHarnessModeHandler — compilation rules for `agent-harness` mode.
|
|
3
|
+
*
|
|
4
|
+
* Maps agent harness task definitions to Promptfoo configuration with:
|
|
5
|
+
* - Claude Agent SDK / OpenAI Codex SDK providers
|
|
6
|
+
* - Tool permission configuration (preset/allowed/disallowed)
|
|
7
|
+
* - Sandbox setup/teardown via Promptfoo extensions
|
|
8
|
+
* - Fixture provisioning into sandbox working directory
|
|
9
|
+
*
|
|
10
|
+
* @see docs/exec-plans/architecture-overhaul/phase-4-agent-harness.md
|
|
11
|
+
* @see packages/core/src/types/generalized-task.ts — AgentHarnessTaskDefinition
|
|
12
|
+
*/
|
|
13
|
+
import type { AgentHarnessTaskDefinition, ModeHandler, PromptTemplate } from "../../../_vendor/ailf-core/index.d.ts";
|
|
14
|
+
import type { PromptfooPrompt, PromptfooProvider, PromptfooTestCase } from "../promptfoo-compiler.js";
|
|
15
|
+
import type { SandboxType } from "../sandbox/sandbox-strategy.js";
|
|
16
|
+
export declare const AGENT_HARNESS_PROMPT_TEMPLATES: Record<string, PromptTemplate>;
|
|
17
|
+
/** Options for compiling an agent harness task */
|
|
18
|
+
export interface AgentHarnessCompileOptions {
|
|
19
|
+
/** Grader provider for LLM-graded assertions */
|
|
20
|
+
graderProvider?: string;
|
|
21
|
+
/** Root directory for fixture resolution */
|
|
22
|
+
rootDir?: string;
|
|
23
|
+
}
|
|
24
|
+
/** Result of compiling a single agent harness task */
|
|
25
|
+
export interface AgentHarnessCompileResult {
|
|
26
|
+
/** Promptfoo provider config */
|
|
27
|
+
providers: PromptfooProvider[];
|
|
28
|
+
/** Compiled test cases */
|
|
29
|
+
tests: PromptfooTestCase[];
|
|
30
|
+
/** Prompts for evaluation */
|
|
31
|
+
prompts: PromptfooPrompt[];
|
|
32
|
+
/** Promptfoo extensions for sandbox lifecycle */
|
|
33
|
+
extensions: PromptfooExtension[];
|
|
34
|
+
/** Sandbox configuration metadata */
|
|
35
|
+
sandboxConfig: SandboxConfigMeta;
|
|
36
|
+
/** Warnings generated during compilation */
|
|
37
|
+
warnings: string[];
|
|
38
|
+
}
|
|
39
|
+
/** Promptfoo extension hook */
|
|
40
|
+
export interface PromptfooExtension {
|
|
41
|
+
type: "afterEach" | "beforeEach";
|
|
42
|
+
/** JavaScript code or module path for the hook */
|
|
43
|
+
code: string;
|
|
44
|
+
}
|
|
45
|
+
/** Metadata about sandbox configuration for this task */
|
|
46
|
+
export interface SandboxConfigMeta {
|
|
47
|
+
type: SandboxType;
|
|
48
|
+
image?: string;
|
|
49
|
+
fixtures: string[];
|
|
50
|
+
limits?: {
|
|
51
|
+
cpus?: number;
|
|
52
|
+
memoryBytes?: number;
|
|
53
|
+
networkAccess?: boolean;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** Validation errors for agent harness task definitions */
|
|
57
|
+
export interface AgentHarnessValidationError {
|
|
58
|
+
field: string;
|
|
59
|
+
message: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Validate that an agent harness task definition has all required fields.
|
|
63
|
+
*/
|
|
64
|
+
export declare function validateAgentHarnessTask(task: AgentHarnessTaskDefinition): AgentHarnessValidationError[];
|
|
65
|
+
/**
|
|
66
|
+
* Compile an agent harness task definition into Promptfoo configuration.
|
|
67
|
+
*/
|
|
68
|
+
export declare function compileAgentHarnessTask(task: AgentHarnessTaskDefinition, options?: AgentHarnessCompileOptions): AgentHarnessCompileResult;
|
|
69
|
+
/** ModeHandler-conformant export for the agent-harness evaluation mode. */
|
|
70
|
+
export declare const handler: ModeHandler;
|