@sanity/ailf 3.5.1 → 3.7.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/dist/_vendor/ailf-core/types/generalized-task.d.ts +23 -0
- package/dist/_vendor/ailf-core/types/index.d.ts +1 -1
- package/dist/adapters/task-sources/content-lake-task-source.d.ts +8 -3
- package/dist/adapters/task-sources/content-lake-task-source.js +36 -8
- package/dist/adapters/task-sources/index.d.ts +1 -1
- package/dist/adapters/task-sources/index.js +1 -1
- package/dist/adapters/task-sources/repo-schemas.d.ts +1209 -41
- package/dist/adapters/task-sources/repo-schemas.js +188 -44
- package/package.json +1 -1
|
@@ -341,3 +341,26 @@ export interface CustomTaskDefinition extends TaskCommonFields {
|
|
|
341
341
|
* when authoring tasks.
|
|
342
342
|
*/
|
|
343
343
|
export type GeneralizedTaskDefinition = LiteracyTaskDefinition | MCPServerTaskDefinition | AgentHarnessTaskDefinition | KnowledgeProbeTaskDefinition | CustomTaskDefinition;
|
|
344
|
+
/**
|
|
345
|
+
* The subset of task modes that can be authored as `ailf.task` documents in
|
|
346
|
+
* the Content Lake (Sanity Studio). Today exactly `"literacy"`.
|
|
347
|
+
*
|
|
348
|
+
* Expanding this set is a deliberate decision: execution-bound fields
|
|
349
|
+
* (filesystem handles, local commands, sandbox config, module paths) cannot
|
|
350
|
+
* round-trip through Content Lake, so not every mode belongs here. Adding a
|
|
351
|
+
* mode requires a new or superseding ADR and a coordinated schema update
|
|
352
|
+
* across the domain type, Studio schema, and `ContentLakeTaskSource` adapter
|
|
353
|
+
* per the `ailf-schema-sync` skill.
|
|
354
|
+
*
|
|
355
|
+
* @see docs/decisions/D0038-content-lake-authorable-task-modes.md
|
|
356
|
+
*/
|
|
357
|
+
export type ContentLakeAuthorableMode = "literacy";
|
|
358
|
+
/**
|
|
359
|
+
* The slice of `GeneralizedTaskDefinition` authorable in the Content Lake,
|
|
360
|
+
* derived mechanically from `ContentLakeAuthorableMode`. Used as the return
|
|
361
|
+
* type of `ContentLakeTaskSource` so the adapter's mode literal is
|
|
362
|
+
* type-checked against the boundary rather than a loose cast.
|
|
363
|
+
*/
|
|
364
|
+
export type ContentLakeAuthorableTask = Extract<GeneralizedTaskDefinition, {
|
|
365
|
+
mode: ContentLakeAuthorableMode;
|
|
366
|
+
}>;
|
|
@@ -25,7 +25,7 @@ export type { VariableDeclaration, VariableEnvelope, VariableProvenance, Variabl
|
|
|
25
25
|
export type { EvalTrace, ToolCallCategory, ToolCallRecord, TraceEvent, TraceSpan, TraceTokenUsage, } from "./trace.js";
|
|
26
26
|
export type { ArtifactId, AssociationAxis, AssociationValues, Brand, EntryKey, Err, FixtureId, IdValidationError, NewReportId, Ok, ProviderId, PromptId, Result, ResultId, RubricId, RunFingerprint, RunId, SuiteId, TaskId, TaskSlug, TraceId, } from "./branded-ids.js";
|
|
27
27
|
export { err, fixtureId, generateRunId, ok, providerId, resultId, runId, suiteId, taskId, traceId, } from "./branded-ids.js";
|
|
28
|
-
export type { AgentHarnessTaskDefinition, CustomTaskDefinition, GeneralizedAssertionDefinition, GeneralizedDocRef, GeneralizedTaskDefinition, GeneralizedTemplatedAssertion, GeneralizedValueAssertion, IdDocRef, KnowledgeProbeTaskDefinition, LiteracyTaskDefinition, MCPServerTaskDefinition, PathDocRef, PerspectiveDocRef, RubricRef, SlugDocRef, TaskCommonFields, TaskDifficulty, TaskOptions, TaskProviderConfig, TaskStatus, } from "./generalized-task.js";
|
|
28
|
+
export type { AgentHarnessTaskDefinition, ContentLakeAuthorableMode, ContentLakeAuthorableTask, CustomTaskDefinition, GeneralizedAssertionDefinition, GeneralizedDocRef, GeneralizedTaskDefinition, GeneralizedTemplatedAssertion, GeneralizedValueAssertion, IdDocRef, KnowledgeProbeTaskDefinition, LiteracyTaskDefinition, MCPServerTaskDefinition, PathDocRef, PerspectiveDocRef, RubricRef, SlugDocRef, TaskCommonFields, TaskDifficulty, TaskOptions, TaskProviderConfig, TaskStatus, } from "./generalized-task.js";
|
|
29
29
|
type DocumentRef = _DocumentRef;
|
|
30
30
|
/** Aggregated retrieval metrics for a feature area */
|
|
31
31
|
export interface AreaRetrievalMetrics {
|
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
* Adapter: Load task definitions from the Sanity Content Lake.
|
|
3
3
|
*
|
|
4
4
|
* Fetches ailf.task documents via GROQ and maps them to
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* `ContentLakeAuthorableTask` — the subset of `GeneralizedTaskDefinition`
|
|
6
|
+
* authorable in Studio per D0038. Today that subset is exactly the
|
|
7
|
+
* literacy variant.
|
|
8
|
+
*
|
|
9
|
+
* The pipeline never knows which adapter loaded the tasks; the
|
|
10
|
+
* `TaskSource` port widens the return type back to
|
|
11
|
+
* `GeneralizedTaskDefinition[]`.
|
|
7
12
|
*
|
|
8
13
|
* Wired in the composition root as the default task source.
|
|
9
14
|
*
|
|
10
15
|
* @see packages/core/src/ports/task-source.ts — TaskSource port
|
|
11
|
-
* @see docs/
|
|
16
|
+
* @see docs/decisions/D0038-content-lake-authorable-task-modes.md
|
|
12
17
|
*/
|
|
13
18
|
import type { SanityClient } from "@sanity/client";
|
|
14
19
|
import type { FilterOptions, GeneralizedTaskDefinition, TaskSource } from "../../_vendor/ailf-core/index.d.ts";
|
|
@@ -2,14 +2,20 @@
|
|
|
2
2
|
* Adapter: Load task definitions from the Sanity Content Lake.
|
|
3
3
|
*
|
|
4
4
|
* Fetches ailf.task documents via GROQ and maps them to
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* `ContentLakeAuthorableTask` — the subset of `GeneralizedTaskDefinition`
|
|
6
|
+
* authorable in Studio per D0038. Today that subset is exactly the
|
|
7
|
+
* literacy variant.
|
|
8
|
+
*
|
|
9
|
+
* The pipeline never knows which adapter loaded the tasks; the
|
|
10
|
+
* `TaskSource` port widens the return type back to
|
|
11
|
+
* `GeneralizedTaskDefinition[]`.
|
|
7
12
|
*
|
|
8
13
|
* Wired in the composition root as the default task source.
|
|
9
14
|
*
|
|
10
15
|
* @see packages/core/src/ports/task-source.ts — TaskSource port
|
|
11
|
-
* @see docs/
|
|
16
|
+
* @see docs/decisions/D0038-content-lake-authorable-task-modes.md
|
|
12
17
|
*/
|
|
18
|
+
import { ContentLakeAuthorableTaskSchema } from "./repo-schemas.js";
|
|
13
19
|
// ---------------------------------------------------------------------------
|
|
14
20
|
// GROQ query — fetches ailf.task documents with resolved references
|
|
15
21
|
// ---------------------------------------------------------------------------
|
|
@@ -47,11 +53,15 @@ const TASKS_QUERY = /* groq */ `
|
|
|
47
53
|
&& (!defined($tags) || count((tags)[@ in $tags]) > 0)
|
|
48
54
|
] | order(coalesce(area->areaId.current, featureArea->areaId.current) asc, id.current asc) {
|
|
49
55
|
"taskId": id.current,
|
|
50
|
-
//
|
|
51
|
-
// the
|
|
56
|
+
// The coalesce on title preserves back-compat: older documents that used
|
|
57
|
+
// the description field as the task label (before title was required)
|
|
58
|
+
// still read cleanly. New documents have title and description as
|
|
59
|
+
// distinct fields.
|
|
52
60
|
"title": coalesce(title, description),
|
|
61
|
+
description,
|
|
53
62
|
"areaId": coalesce(area->areaId.current, featureArea->areaId.current),
|
|
54
63
|
"promptText": coalesce(promptText, taskPrompt),
|
|
64
|
+
status,
|
|
55
65
|
docCoverage,
|
|
56
66
|
"contextDocs": coalesce(contextDocs, canonicalDocs)[] {
|
|
57
67
|
refType,
|
|
@@ -86,9 +96,25 @@ export class ContentLakeTaskSource {
|
|
|
86
96
|
}
|
|
87
97
|
const definitions = [];
|
|
88
98
|
for (const entry of raw) {
|
|
89
|
-
const mapped =
|
|
99
|
+
const mapped = mapToAuthorableTask(entry);
|
|
90
100
|
if (!mapped)
|
|
91
101
|
continue;
|
|
102
|
+
// Runtime gate (W0073): every mapped task must satisfy the domain
|
|
103
|
+
// schema before it flows into the pipeline. Throws loudly on drift so
|
|
104
|
+
// a Studio document that strays from GeneralizedTaskDefinition
|
|
105
|
+
// surfaces at load time rather than corrupting downstream state.
|
|
106
|
+
const parsed = ContentLakeAuthorableTaskSchema.safeParse(mapped);
|
|
107
|
+
if (!parsed.success) {
|
|
108
|
+
const issues = parsed.error.issues
|
|
109
|
+
.slice(0, 5)
|
|
110
|
+
.map((i) => ` [${i.path.join(".")}]: ${i.message}`)
|
|
111
|
+
.join("\n");
|
|
112
|
+
const more = parsed.error.issues.length > 5
|
|
113
|
+
? `\n …and ${parsed.error.issues.length - 5} more issue(s)`
|
|
114
|
+
: "";
|
|
115
|
+
throw new Error(`ContentLakeTaskSource: ailf.task "${mapped.id}" failed domain ` +
|
|
116
|
+
`schema validation:\n${issues}${more}`);
|
|
117
|
+
}
|
|
92
118
|
definitions.push(mapped);
|
|
93
119
|
}
|
|
94
120
|
if (definitions.length === 0 && !filter) {
|
|
@@ -115,14 +141,14 @@ function buildGroqParams(filter) {
|
|
|
115
141
|
// Mapping: Content Lake → LiteracyTaskDefinition
|
|
116
142
|
// ---------------------------------------------------------------------------
|
|
117
143
|
/**
|
|
118
|
-
* Map a Content Lake ailf.task document
|
|
144
|
+
* Map a Content Lake ailf.task document to a `ContentLakeAuthorableTask`.
|
|
119
145
|
*
|
|
120
146
|
* Returns null if the document is missing required fields (taskId,
|
|
121
147
|
* title, areaId, promptText). These are required by the
|
|
122
148
|
* Studio schema, but defensive coding handles edge cases (drafts,
|
|
123
149
|
* partially-created documents, etc.).
|
|
124
150
|
*/
|
|
125
|
-
function
|
|
151
|
+
function mapToAuthorableTask(raw) {
|
|
126
152
|
// Required fields — skip malformed documents
|
|
127
153
|
if (!raw.taskId || !raw.title || !raw.areaId || !raw.promptText) {
|
|
128
154
|
return null;
|
|
@@ -172,6 +198,8 @@ function mapToLiteracyTask(raw) {
|
|
|
172
198
|
referenceSolution: "",
|
|
173
199
|
...(baseline ? { baseline } : {}),
|
|
174
200
|
...(raw.tags?.length ? { tags: raw.tags } : {}),
|
|
201
|
+
...(raw.status ? { status: raw.status } : {}),
|
|
202
|
+
...(raw.description ? { description: raw.description } : {}),
|
|
175
203
|
};
|
|
176
204
|
}
|
|
177
205
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { CompositeTaskSource } from "./composite-task-source.js";
|
|
2
2
|
export { ContentLakeTaskSource } from "./content-lake-task-source.js";
|
|
3
|
-
export { CanonicalTaskFileSchema, CanonicalTaskSchema, CURATED_ASSERTION_TYPES, detectLegacyFieldNames, parseCanonicalTaskFile, parseRepoConfig, RepoConfigSchema, RUBRIC_TEMPLATE_NAMES, type CanonicalTask, type CuratedAssertionType, type RepoConfig, type RubricTemplateName, } from "./repo-schemas.js";
|
|
3
|
+
export { CanonicalTaskFileSchema, CanonicalTaskSchema, ContentLakeAuthorableTaskSchema, CURATED_ASSERTION_TYPES, detectLegacyFieldNames, parseCanonicalTaskFile, parseRepoConfig, RepoConfigSchema, RUBRIC_TEMPLATE_NAMES, type CanonicalTask, type ContentLakeAuthorableTaskParsed, type CuratedAssertionType, type RepoConfig, type RubricTemplateName, } from "./repo-schemas.js";
|
|
4
4
|
export { RepoTaskSource } from "./repo-task-source.js";
|
|
5
5
|
export { detectTriggerContext, resolveTrigger, type ResolvedTrigger, type TriggerContext, } from "./repo-trigger.js";
|
|
6
6
|
export { formatValidationResult, validateCanonicalTasks, type ValidationMessage, type ValidationResult, } from "./repo-validation.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { CompositeTaskSource } from "./composite-task-source.js";
|
|
2
2
|
export { ContentLakeTaskSource } from "./content-lake-task-source.js";
|
|
3
|
-
export { CanonicalTaskFileSchema, CanonicalTaskSchema, CURATED_ASSERTION_TYPES, detectLegacyFieldNames, parseCanonicalTaskFile, parseRepoConfig, RepoConfigSchema, RUBRIC_TEMPLATE_NAMES, } from "./repo-schemas.js";
|
|
3
|
+
export { CanonicalTaskFileSchema, CanonicalTaskSchema, ContentLakeAuthorableTaskSchema, CURATED_ASSERTION_TYPES, detectLegacyFieldNames, parseCanonicalTaskFile, parseRepoConfig, RepoConfigSchema, RUBRIC_TEMPLATE_NAMES, } from "./repo-schemas.js";
|
|
4
4
|
export { RepoTaskSource } from "./repo-task-source.js";
|
|
5
5
|
export { detectTriggerContext, resolveTrigger, } from "./repo-trigger.js";
|
|
6
6
|
export { formatValidationResult, validateCanonicalTasks, } from "./repo-validation.js";
|