@treeseed/sdk 0.13.0-rc.118 → 0.13.0-rc.119
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/.treeseed-build-complete.json +1 -1
- package/dist/agent-capacity/contracts/capacity/assignments/agent-execution.d.ts +4199 -0
- package/dist/agent-capacity/contracts/capacity/assignments/agent-execution.js +155 -0
- package/dist/agent-capacity/contracts/capacity/assignments/assignment-records.d.ts +7 -1
- package/dist/agent-capacity/contracts/capacity/workdays/workday-allocation.d.ts +199 -0
- package/dist/agent-capacity/contracts/capacity/workdays/workday-allocation.js +96 -0
- package/dist/agent-capacity/contracts/operations/agent-team-clone.d.ts +218 -0
- package/dist/agent-capacity/contracts/operations/agent-team-clone.js +57 -0
- package/dist/agent-capacity/contracts/support/decision-work.d.ts +1 -24
- package/dist/agent-capacity/contracts/support/execution-graph.d.ts +1087 -0
- package/dist/agent-capacity/contracts/support/execution-graph.js +120 -0
- package/dist/agent-capacity/validation/activity-profile.d.ts +1 -1
- package/dist/agent-capacity/validation/activity-profile.js +3 -272
- package/dist/agent-capacity/validation/agent-definition-schema.d.ts +2699 -8867
- package/dist/agent-capacity/validation/agent-definition-schema.js +67 -159
- package/dist/agent-capacity/validation/agent-lab-forensics-schema.d.ts +3 -3
- package/dist/agent-capacity/validation/assignment-records.js +1 -1
- package/dist/agent-capacity/validation/execution/execution-graph.d.ts +1 -0
- package/dist/agent-capacity/validation/execution/execution-graph.js +16 -0
- package/dist/agent-capacity/validation/index.d.ts +2 -1
- package/dist/agent-capacity/validation/index.js +2 -1
- package/dist/capacity/agents/agent-capacity.d.ts +5 -1
- package/dist/capacity/agents/agent-capacity.js +4 -1
- package/dist/capacity-provider/client.d.ts +1 -43
- package/dist/capacity-provider/client.js +1 -22
- package/dist/capacity-provider/sandbox-contracts.d.ts +4 -4
- package/dist/capacity-provider/sandbox.d.ts +0 -1
- package/dist/capacity-provider/sandbox.js +0 -1
- package/dist/capacity-provider/source-workspace.d.ts +19 -171
- package/dist/capacity-provider/source-workspace.js +7 -24
- package/dist/content/contracts.d.ts +1 -1
- package/dist/content/validation/agent-operational-content-schemas.d.ts +24 -695
- package/dist/content/validation/agent-operational-content-schemas.js +11 -54
- package/dist/content/validation/auxiliary-content-schemas.d.ts +58 -58
- package/dist/content/validation/content-model-schemas.d.ts +8617 -18610
- package/dist/content/validation/content-model-schemas.js +160 -43
- package/dist/content/validation/portable-content-data.d.ts +369 -1681
- package/dist/content/validation/portable-content-data.js +5 -4
- package/dist/model-registry/agent-operational-models.d.ts +1 -1
- package/dist/model-registry/agent-operational-models.js +0 -3
- package/dist/model-registry/build-builtin-model-registry.js +44 -72
- package/dist/operator-contracts/canonical-command-tree.js +62 -179
- package/dist/operator-contracts/catalog/agents/agent-team-clone-operations.d.ts +75 -0
- package/dist/operator-contracts/catalog/agents/agent-team-clone-operations.js +42 -0
- package/dist/operator-contracts/catalog/commands/command-tree-builders.d.ts +60 -0
- package/dist/operator-contracts/catalog/commands/command-tree-builders.js +191 -0
- package/dist/operator-contracts/catalog/communication-operations.d.ts +1 -1
- package/dist/operator-contracts/catalog/execution/execution-operations.d.ts +36 -0
- package/dist/operator-contracts/catalog/execution/execution-operations.js +39 -0
- package/dist/operator-contracts/catalog/inbox-operations.d.ts +5 -1
- package/dist/operator-contracts/command-tree.js +1 -0
- package/dist/operator-contracts/control-plane-operations.d.ts +136 -73
- package/dist/operator-contracts/control-plane-operations.js +19 -40
- package/dist/operator-contracts/inbox/contracts.d.ts +12 -0
- package/dist/operator-contracts/inbox/contracts.js +5 -1
- package/dist/operator-contracts/mcp.js +1 -1
- package/dist/operator-contracts/workday-lifecycle.d.ts +6 -8
- package/dist/operator-contracts/workday-lifecycle.js +3 -3
- package/dist/sdk-types/support/sdk-model-names.d.ts +1 -1
- package/dist/sdk-types/support/sdk-model-names.js +0 -3
- package/dist/secrets-capability/shared-resources.d.ts +6 -6
- package/dist/types/agents/agent-activity-profile.d.ts +39 -77
- package/dist/types/agents/agent-activity-profile.js +23 -0
- package/dist/types/agents/execution-run-ref.d.ts +1 -8
- package/package.json +1 -1
- package/dist/agent-capacity/authority/agent-authority-presets.d.ts +0 -13
- package/dist/agent-capacity/authority/agent-authority-presets.js +0 -107
- package/dist/agent-capacity/contracts/operations/workflow-promotion.d.ts +0 -24
- package/dist/agent-capacity/contracts/operations/workflow-promotion.js +0 -0
- package/dist/agent-capacity/validation/workflow-promotion.d.ts +0 -2
- package/dist/agent-capacity/validation/workflow-promotion.js +0 -34
- package/dist/capacity-provider/source/candidate.d.ts +0 -1275
- package/dist/capacity-provider/source/candidate.js +0 -72
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { activityProfileSchema } from "../../validation/agent-definition-schema.js";
|
|
3
|
+
import { estimateSchema, exactEntityReferenceSchema } from "../capacity/assignments/agent-execution.js";
|
|
4
|
+
const identifier = z.string().trim().min(1).max(200).regex(/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/u);
|
|
5
|
+
const slug = z.string().trim().min(1).max(100).regex(/^[a-z0-9]+(?:[._/-][a-z0-9]+)*$/u);
|
|
6
|
+
const uniqueIds = z.array(identifier).superRefine((items, context) => {
|
|
7
|
+
if (new Set(items).size !== items.length) context.addIssue({ code: z.ZodIssueCode.custom, message: "Values must be unique." });
|
|
8
|
+
});
|
|
9
|
+
const conditionDefinitionSchema = z.object({
|
|
10
|
+
conditionType: z.enum(["question", "external", "authority", "lifecycle"]),
|
|
11
|
+
subjectRef: exactEntityReferenceSchema,
|
|
12
|
+
expectedState: identifier
|
|
13
|
+
}).strict();
|
|
14
|
+
const executionNodeSchema = z.object({
|
|
15
|
+
schemaVersion: z.literal("treeseed.execution-node/v1"),
|
|
16
|
+
id: identifier,
|
|
17
|
+
teamId: identifier,
|
|
18
|
+
projectId: identifier,
|
|
19
|
+
workdayId: identifier.optional(),
|
|
20
|
+
workItemId: slug.optional(),
|
|
21
|
+
kind: z.enum(["planning", "estimating", "acting", "reviewing", "reporting", "communication", "condition"]),
|
|
22
|
+
pairRole: z.enum(["actor", "reviewer"]).nullable(),
|
|
23
|
+
sourceRef: exactEntityReferenceSchema,
|
|
24
|
+
authorityRefs: z.array(exactEntityReferenceSchema).optional(),
|
|
25
|
+
ruleRevision: z.number().int().positive(),
|
|
26
|
+
nodeRevision: z.number().int().positive(),
|
|
27
|
+
agentClass: z.string().regex(/^[a-z][a-z0-9-]*$/u).optional(),
|
|
28
|
+
status: z.enum(["proposed", "blocked", "ready", "assigned", "running", "completed", "failed", "cancelled", "stale"]),
|
|
29
|
+
estimate: estimateSchema.optional(),
|
|
30
|
+
requiredCapabilities: uniqueIds.optional(),
|
|
31
|
+
requestedPermissions: activityProfileSchema.shape.permissions.optional(),
|
|
32
|
+
workspace: z.enum(["read-only", "treedx", "git"]).optional(),
|
|
33
|
+
acceptanceCriteria: z.array(z.string().trim().min(1)).min(1).optional(),
|
|
34
|
+
maximumReviewCycles: z.number().int().positive().optional(),
|
|
35
|
+
condition: conditionDefinitionSchema.optional(),
|
|
36
|
+
graphRevisionCreated: z.number().int().positive(),
|
|
37
|
+
graphRevisionUpdated: z.number().int().positive()
|
|
38
|
+
}).strict().superRefine((node, context) => {
|
|
39
|
+
const assignable = ["agentClass", "estimate", "requiredCapabilities", "requestedPermissions", "workspace"];
|
|
40
|
+
if (node.kind === "condition") {
|
|
41
|
+
if (!node.condition) context.addIssue({ code: z.ZodIssueCode.custom, path: ["condition"], message: "Condition nodes require condition." });
|
|
42
|
+
for (const key of assignable) if (node[key] !== void 0) context.addIssue({ code: z.ZodIssueCode.custom, path: [key], message: `Condition nodes cannot define ${key}.` });
|
|
43
|
+
} else {
|
|
44
|
+
for (const key of assignable) if (node[key] === void 0) context.addIssue({ code: z.ZodIssueCode.custom, path: [key], message: `Assignable nodes require ${key}.` });
|
|
45
|
+
if (node.condition) context.addIssue({ code: z.ZodIssueCode.custom, path: ["condition"], message: "Assignable nodes cannot define condition." });
|
|
46
|
+
}
|
|
47
|
+
if (node.pairRole && !(node.workItemId && node.maximumReviewCycles)) context.addIssue({ code: z.ZodIssueCode.custom, message: "Actor and Reviewer nodes require workItemId and maximumReviewCycles." });
|
|
48
|
+
if (node.graphRevisionUpdated < node.graphRevisionCreated) context.addIssue({ code: z.ZodIssueCode.custom, path: ["graphRevisionUpdated"], message: "Updated revision cannot precede created revision." });
|
|
49
|
+
});
|
|
50
|
+
const executionEdgeSchema = z.object({
|
|
51
|
+
schemaVersion: z.literal("treeseed.execution-edge/v1"),
|
|
52
|
+
id: identifier,
|
|
53
|
+
teamId: identifier,
|
|
54
|
+
fromNodeId: identifier,
|
|
55
|
+
toNodeId: identifier,
|
|
56
|
+
provenance: z.enum(["profile-agent", "profile-event", "work-item", "review-pair", "governance"]),
|
|
57
|
+
sourceRef: exactEntityReferenceSchema.optional(),
|
|
58
|
+
graphRevisionCreated: z.number().int().positive(),
|
|
59
|
+
graphRevisionRemoved: z.number().int().positive().optional()
|
|
60
|
+
}).strict().refine((edge) => edge.fromNodeId !== edge.toNodeId, { message: "Execution edges cannot be self-referential." });
|
|
61
|
+
const graphChangeSetSchema = z.object({
|
|
62
|
+
added: uniqueIds,
|
|
63
|
+
changed: uniqueIds,
|
|
64
|
+
completed: uniqueIds,
|
|
65
|
+
blocked: uniqueIds,
|
|
66
|
+
stale: uniqueIds,
|
|
67
|
+
removedEdges: uniqueIds,
|
|
68
|
+
addedEdges: uniqueIds
|
|
69
|
+
}).strict();
|
|
70
|
+
const graphRevisionSchema = z.object({
|
|
71
|
+
schemaVersion: z.literal("treeseed.graph-revision/v1"),
|
|
72
|
+
teamId: identifier,
|
|
73
|
+
revision: z.number().int().positive(),
|
|
74
|
+
ruleRevision: z.number().int().positive(),
|
|
75
|
+
changedSourceRefs: z.array(exactEntityReferenceSchema).min(1),
|
|
76
|
+
graphDigest: z.string().regex(/^sha256:[a-f0-9]{64}$/u),
|
|
77
|
+
changes: graphChangeSetSchema,
|
|
78
|
+
createdAt: z.string().datetime({ offset: true })
|
|
79
|
+
}).strict();
|
|
80
|
+
function validateExecutionGraph(nodes, edges) {
|
|
81
|
+
const diagnostics = [];
|
|
82
|
+
const nodeIds = /* @__PURE__ */ new Set();
|
|
83
|
+
for (const [index, candidate] of nodes.entries()) {
|
|
84
|
+
const parsed = executionNodeSchema.safeParse(candidate);
|
|
85
|
+
if (!parsed.success) diagnostics.push(...parsed.error.issues.map((issue) => ({ code: `execution_node_${issue.code}`, path: `nodes.${index}.${issue.path.join(".")}`, message: issue.message })));
|
|
86
|
+
if (nodeIds.has(candidate.id)) diagnostics.push({ code: "execution_node_duplicate", path: `nodes.${index}.id`, message: `Node ${candidate.id} is duplicated.` });
|
|
87
|
+
nodeIds.add(candidate.id);
|
|
88
|
+
}
|
|
89
|
+
const activeEdges = edges.filter((edge) => edge.graphRevisionRemoved === void 0);
|
|
90
|
+
const edgeIds = /* @__PURE__ */ new Set();
|
|
91
|
+
for (const [index, candidate] of edges.entries()) {
|
|
92
|
+
const parsed = executionEdgeSchema.safeParse(candidate);
|
|
93
|
+
if (!parsed.success) diagnostics.push(...parsed.error.issues.map((issue) => ({ code: `execution_edge_${issue.code}`, path: `edges.${index}.${issue.path.join(".")}`, message: issue.message })));
|
|
94
|
+
if (!nodeIds.has(candidate.fromNodeId) || !nodeIds.has(candidate.toNodeId)) diagnostics.push({ code: "execution_edge_endpoint_missing", path: `edges.${index}`, message: "Both edge endpoints must exist." });
|
|
95
|
+
if (edgeIds.has(candidate.id)) diagnostics.push({ code: "execution_edge_duplicate", path: `edges.${index}.id`, message: `Edge ${candidate.id} is duplicated.` });
|
|
96
|
+
edgeIds.add(candidate.id);
|
|
97
|
+
}
|
|
98
|
+
const outgoing = new Map([...nodeIds].map((id) => [id, []]));
|
|
99
|
+
for (const edge of activeEdges) outgoing.get(edge.fromNodeId)?.push(edge.toNodeId);
|
|
100
|
+
const visiting = /* @__PURE__ */ new Set(), visited = /* @__PURE__ */ new Set();
|
|
101
|
+
const cyclic = (id) => {
|
|
102
|
+
if (visiting.has(id)) return true;
|
|
103
|
+
if (visited.has(id)) return false;
|
|
104
|
+
visiting.add(id);
|
|
105
|
+
if ((outgoing.get(id) ?? []).some(cyclic)) return true;
|
|
106
|
+
visiting.delete(id);
|
|
107
|
+
visited.add(id);
|
|
108
|
+
return false;
|
|
109
|
+
};
|
|
110
|
+
if ([...nodeIds].some(cyclic)) diagnostics.push({ code: "execution_graph_cycle", path: "edges", message: "Execution graph must be acyclic." });
|
|
111
|
+
return { ok: diagnostics.length === 0, diagnostics };
|
|
112
|
+
}
|
|
113
|
+
export {
|
|
114
|
+
conditionDefinitionSchema,
|
|
115
|
+
executionEdgeSchema,
|
|
116
|
+
executionNodeSchema,
|
|
117
|
+
graphChangeSetSchema,
|
|
118
|
+
graphRevisionSchema,
|
|
119
|
+
validateExecutionGraph
|
|
120
|
+
};
|
|
@@ -1,276 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { compileAgentAuthoritySnapshot } from "../authority/agent-authority-presets.js";
|
|
3
|
-
const PROFILE_KEYS = /* @__PURE__ */ new Set(["activityType", "enabled", "handler", "prompt", "branchPolicy", "contextQueryRefs", "contextQuerySetRefs", "instructionTemplateRefs", "capabilityRequirements", "permissions", "authorityPresets", "artifactTriggers", "closeoutPolicy", "tools", "signals", "outputs", "planningIntent", "questionPolicy", "execution"]);
|
|
4
|
-
const PROMPT_KEYS = /* @__PURE__ */ new Set(["system", "task", "templates"]);
|
|
5
|
-
const TOOL_KEYS = /* @__PURE__ */ new Set(["allowed", "denied"]);
|
|
6
|
-
const SIGNAL_KEYS = /* @__PURE__ */ new Set(["subscribesTo", "publishes"]);
|
|
7
|
-
const SUBSCRIPTION_KEYS = /* @__PURE__ */ new Set(["contract", "groupScope", "filters", "cardinality", "producerPolicy", "quorum"]);
|
|
8
|
-
const OUTPUT_KEYS = /* @__PURE__ */ new Set(["messageTypes", "modelMutations"]);
|
|
9
|
-
const EXECUTION_KEYS = /* @__PURE__ */ new Set(["reasoningEffort", "maxRuntimeSeconds", "preparationSeconds", "closeoutSeconds", "closeoutWarningSeconds", "maxRetries", "verificationRequired", "maxTotalTokens", "warningTokens", "maxCostAmount", "costCurrency", "nativeLimits", "pricingGeneration", "enforcementConfidence", "allowedPaths", "forbiddenPaths"]);
|
|
10
|
-
const CONTENT_ACCESS_KEYS = /* @__PURE__ */ new Set(["content", "commit", "repository", "network", "shell"]);
|
|
11
|
-
const MODEL_PERMISSION_KEYS = /* @__PURE__ */ new Set(["operations", "filters"]);
|
|
12
|
-
const QUESTION_KEYS = /* @__PURE__ */ new Set(["defaultAnswerPolicy", "blockExecutionWhenCreated"]);
|
|
13
|
-
const PLANNING_INTENT_KEYS = /* @__PURE__ */ new Set(["objective", "proposalTypes", "artifactKind", "subjectModel", "subjectId", "includeWorkdayArtifacts", "stage", "stages", "requiresArtifactKinds"]);
|
|
14
|
-
const PLANNING_STAGE_KEYS = /* @__PURE__ */ new Set(["stage", "promptTask", "signals"]);
|
|
15
|
-
const QUESTION_POLICY_KEYS = /* @__PURE__ */ new Set(["kind", "teamId", "requiredRoles", "allowedRoles", "allowedAgentIds", "allowedAgentClasses", "allowedActivityProfiles", "teamMemberId", "projectId", "agentSlug"]);
|
|
16
|
-
const BRANCH_KEYS = {
|
|
17
|
-
"read-only": /* @__PURE__ */ new Set(["kind", "base"]),
|
|
18
|
-
"main-planning-content": /* @__PURE__ */ new Set(["kind", "base"]),
|
|
19
|
-
"staging-content": /* @__PURE__ */ new Set(["kind", "base"]),
|
|
20
|
-
"assignment-feature": /* @__PURE__ */ new Set(["kind", "base", "target", "prefix", "branchNameTemplate", "worktree", "updateBaseBeforeRun", "mergeTargetBeforeSave"]),
|
|
21
|
-
"staging-release": /* @__PURE__ */ new Set(["kind", "base", "target"])
|
|
22
|
-
};
|
|
23
|
-
function record(value) {
|
|
24
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
25
|
-
}
|
|
26
|
-
function strings(value) {
|
|
27
|
-
return Array.isArray(value) && value.every((entry) => typeof entry === "string" && entry.trim().length > 0) && new Set(value).size === value.length;
|
|
28
|
-
}
|
|
29
|
-
function exactRefs(value) {
|
|
30
|
-
return Array.isArray(value) && value.every((entry) => record(entry) && typeof entry.id === "string" && entry.id.trim() && Number.isInteger(entry.revision) && Number(entry.revision) > 0) && new Set(value.map((entry) => `${entry.id}@${entry.revision}`)).size === value.length;
|
|
31
|
-
}
|
|
32
|
-
function unknownKeys(value, allowed, path, add) {
|
|
33
|
-
for (const key of Object.keys(value)) if (!allowed.has(key)) add("agent_activity_unknown_field", `${path}.${key}`, `Unknown activity-profile field ${path}.${key}.`);
|
|
34
|
-
}
|
|
1
|
+
import { activityProfilesSchema, diagnosticsFromZod } from "./agent-definition-schema.js";
|
|
35
2
|
function validateAgentActivityProfilesConfiguration(value) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
if (!record(value)) return { ok: false, diagnostics: [{ code: "agent_activity_profiles_invalid", path: "activityProfiles", message: "activityProfiles must be an object." }] };
|
|
39
|
-
let enabled = 0;
|
|
40
|
-
for (const [activity, raw] of Object.entries(value)) {
|
|
41
|
-
const path = `activityProfiles.${activity}`;
|
|
42
|
-
if (!AGENT_ACTIVITY_TYPES.includes(activity)) {
|
|
43
|
-
add("agent_activity_type_invalid", path, `Unsupported activity type ${activity}.`);
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
if (!record(raw)) {
|
|
47
|
-
add("agent_activity_profile_invalid", path, `${path} must be an object.`);
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
unknownKeys(raw, PROFILE_KEYS, path, add);
|
|
51
|
-
if (raw.activityType !== void 0 && raw.activityType !== activity) add("agent_activity_type_mismatch", `${path}.activityType`, "activityType must match its activityProfiles key.");
|
|
52
|
-
if (typeof raw.enabled !== "boolean") add("agent_activity_enabled_invalid", `${path}.enabled`, "enabled must be boolean.");
|
|
53
|
-
else if (raw.enabled) enabled += 1;
|
|
54
|
-
if (typeof raw.handler !== "string" || !AGENT_HANDLER_KINDS.includes(raw.handler)) add("agent_activity_handler_invalid", `${path}.handler`, "handler must name a supported built-in handler.");
|
|
55
|
-
if (!record(raw.prompt)) add("agent_activity_prompt_invalid", `${path}.prompt`, "prompt must be an object.");
|
|
56
|
-
else {
|
|
57
|
-
unknownKeys(raw.prompt, PROMPT_KEYS, `${path}.prompt`, add);
|
|
58
|
-
if (typeof raw.prompt.system !== "string" || !raw.prompt.system.trim()) add("agent_activity_system_prompt_required", `${path}.prompt.system`, "prompt.system is required.");
|
|
59
|
-
if (raw.prompt.task !== void 0 && typeof raw.prompt.task !== "string") add("agent_activity_task_prompt_invalid", `${path}.prompt.task`, "prompt.task must be a string.");
|
|
60
|
-
if (raw.prompt.templates !== void 0 && (!record(raw.prompt.templates) || Object.values(raw.prompt.templates).some((entry) => typeof entry !== "string"))) add("agent_activity_templates_invalid", `${path}.prompt.templates`, "prompt.templates must map names to strings.");
|
|
61
|
-
}
|
|
62
|
-
validateBranch(raw.branchPolicy, `${path}.branchPolicy`, add);
|
|
63
|
-
validateStringLists(raw.tools, TOOL_KEYS, ["allowed"], `${path}.tools`, add);
|
|
64
|
-
validateSignals(raw.signals, `${path}.signals`, add);
|
|
65
|
-
validateStringLists(raw.outputs, OUTPUT_KEYS, ["messageTypes", "modelMutations"], `${path}.outputs`, add);
|
|
66
|
-
validatePlanningIntent(raw.planningIntent, `${path}.planningIntent`, add);
|
|
67
|
-
validateContentAccess(raw.permissions, `${path}.permissions`, add);
|
|
68
|
-
if (raw.authorityPresets !== void 0 && (!strings(raw.authorityPresets) || raw.authorityPresets.some((preset) => !["messaging", "direction", "influence", "estimation", "plan-contribution", "source-execution", "review-authority", "reporting"].includes(preset)))) add("agent_activity_authority_presets_invalid", `${path}.authorityPresets`, "authorityPresets must contain supported unique preset ids.");
|
|
69
|
-
for (const key of ["contextQueryRefs", "contextQuerySetRefs", "instructionTemplateRefs"]) if (raw[key] !== void 0 && !exactRefs(raw[key])) add("agent_activity_revision_refs_invalid", `${path}.${key}`, `${path}.${key} must contain unique exact id and revision references.`);
|
|
70
|
-
validateCapabilityRequirements(raw.capabilityRequirements, `${path}.capabilityRequirements`, add);
|
|
71
|
-
validateArtifactTriggers(raw.artifactTriggers, `${path}.artifactTriggers`, add);
|
|
72
|
-
validateCloseoutPolicy(raw.closeoutPolicy, `${path}.closeoutPolicy`, add);
|
|
73
|
-
validateQuestionPolicy(raw.questionPolicy, `${path}.questionPolicy`, add);
|
|
74
|
-
validateExecution(raw.execution, `${path}.execution`, add);
|
|
75
|
-
if (typeof raw.enabled === "boolean" && typeof raw.handler === "string" && record(raw.tools) && record(raw.outputs) && record(raw.branchPolicy)) {
|
|
76
|
-
for (const message of compileAgentAuthoritySnapshot(activity, raw).diagnostics) {
|
|
77
|
-
add("agent_activity_authority_widening_forbidden", path, message);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (enabled === 0) add("agent_activity_profile_enabled_required", "activityProfiles", "At least one activity profile must be enabled.");
|
|
82
|
-
return { ok: diagnostics.length === 0, diagnostics };
|
|
83
|
-
}
|
|
84
|
-
function validateSignals(value, path, add) {
|
|
85
|
-
if (value === void 0) return;
|
|
86
|
-
if (!record(value)) {
|
|
87
|
-
add("agent_activity_signals_invalid", path, "signals must be an object.");
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
unknownKeys(value, SIGNAL_KEYS, path, add);
|
|
91
|
-
if (value.publishes !== void 0 && !strings(value.publishes)) add("agent_activity_signal_publications_invalid", `${path}.publishes`, "publishes must contain unique signal contract IDs.");
|
|
92
|
-
if (value.subscribesTo === void 0) return;
|
|
93
|
-
if (!Array.isArray(value.subscribesTo)) {
|
|
94
|
-
add("agent_activity_signal_subscriptions_invalid", `${path}.subscribesTo`, "subscribesTo must be an array.");
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
value.subscribesTo.forEach((candidate, index) => {
|
|
98
|
-
const itemPath = `${path}.subscribesTo[${index}]`;
|
|
99
|
-
if (!record(candidate)) {
|
|
100
|
-
add("agent_activity_signal_subscription_invalid", itemPath, "Signal subscription must be an object.");
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
unknownKeys(candidate, SUBSCRIPTION_KEYS, itemPath, add);
|
|
104
|
-
if (typeof candidate.contract !== "string" || !candidate.contract.trim()) add("agent_activity_signal_contract_required", `${itemPath}.contract`, "Signal subscription contract is required.");
|
|
105
|
-
if (candidate.filters !== void 0 && !record(candidate.filters)) add("agent_activity_signal_filters_invalid", `${itemPath}.filters`, "Signal filters must be an object.");
|
|
106
|
-
if (candidate.groupScope !== void 0) validateGroupScope(candidate.groupScope, `${itemPath}.groupScope`, add);
|
|
107
|
-
if (candidate.cardinality !== void 0 && !["single", "each"].includes(String(candidate.cardinality))) add("agent_activity_signal_cardinality_invalid", `${itemPath}.cardinality`, "cardinality must be single or each.");
|
|
108
|
-
if (candidate.producerPolicy !== void 0 && !["any", "all", "quorum"].includes(String(candidate.producerPolicy))) add("agent_activity_producer_policy_invalid", `${itemPath}.producerPolicy`, "producerPolicy must be any, all, or quorum.");
|
|
109
|
-
if (candidate.producerPolicy === "quorum" && (!Number.isInteger(candidate.quorum) || Number(candidate.quorum) < 1)) add("agent_activity_signal_quorum_invalid", `${itemPath}.quorum`, "quorum must be a positive integer.");
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
function validateGroupScope(value, path, add) {
|
|
113
|
-
if (!record(value) || !["member-groups", "specific-groups", "project"].includes(String(value.mode))) {
|
|
114
|
-
add("agent_activity_group_scope_invalid", path, "groupScope.mode must be member-groups, specific-groups, or project.");
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
if (value.mode === "project" && (typeof value.projectId !== "string" || !value.projectId.trim())) add("agent_activity_group_scope_project_required", `${path}.projectId`, "Project-scoped subscriptions require projectId.");
|
|
118
|
-
if (value.mode === "specific-groups" && (!Array.isArray(value.groupRefs) || value.groupRefs.length === 0 || value.groupRefs.some((candidate) => !record(candidate) || typeof candidate.projectId !== "string" || typeof candidate.groupId !== "string"))) add("agent_activity_group_scope_refs_required", `${path}.groupRefs`, "Specific group scopes require projectId and groupId references.");
|
|
119
|
-
}
|
|
120
|
-
function validatePlanningIntent(value, path, add) {
|
|
121
|
-
if (value === void 0) return;
|
|
122
|
-
if (!record(value)) {
|
|
123
|
-
add("agent_activity_planning_intent_invalid", path, "planningIntent must be an object.");
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
unknownKeys(value, PLANNING_INTENT_KEYS, path, add);
|
|
127
|
-
for (const key of ["objective", "artifactKind", "subjectModel"]) {
|
|
128
|
-
if (value[key] !== void 0 && (typeof value[key] !== "string" || !value[key].trim())) add("agent_activity_planning_intent_text_invalid", `${path}.${key}`, `${path}.${key} must be a non-empty string.`);
|
|
129
|
-
}
|
|
130
|
-
if (value.subjectId !== void 0 && value.subjectId !== null && (typeof value.subjectId !== "string" || !value.subjectId.trim())) add("agent_activity_planning_intent_text_invalid", `${path}.subjectId`, `${path}.subjectId must be a non-empty string or null.`);
|
|
131
|
-
if (value.includeWorkdayArtifacts !== void 0 && typeof value.includeWorkdayArtifacts !== "boolean") add("agent_activity_planning_intent_boolean_invalid", `${path}.includeWorkdayArtifacts`, `${path}.includeWorkdayArtifacts must be boolean.`);
|
|
132
|
-
const stages = ["discovery", "synthesis", "deliberation", "evaluation", "revision", "closeout"];
|
|
133
|
-
if (value.stage !== void 0 && !stages.includes(String(value.stage))) add("agent_activity_planning_stage_invalid", `${path}.stage`, `${path}.stage is unsupported.`);
|
|
134
|
-
if (value.stages !== void 0) {
|
|
135
|
-
if (!Array.isArray(value.stages) || value.stages.length === 0) add("agent_activity_planning_stages_invalid", `${path}.stages`, "stages must be a non-empty array.");
|
|
136
|
-
else value.stages.forEach((candidate, index) => {
|
|
137
|
-
const stagePath = `${path}.stages[${index}]`;
|
|
138
|
-
if (!record(candidate)) {
|
|
139
|
-
add("agent_activity_planning_stage_invalid", stagePath, "Planning stage must be an object.");
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
unknownKeys(candidate, PLANNING_STAGE_KEYS, stagePath, add);
|
|
143
|
-
if (!stages.includes(String(candidate.stage))) add("agent_activity_planning_stage_invalid", `${stagePath}.stage`, "Planning stage is unsupported.");
|
|
144
|
-
if (candidate.promptTask !== void 0 && (typeof candidate.promptTask !== "string" || !candidate.promptTask.trim())) add("agent_activity_planning_stage_prompt_invalid", `${stagePath}.promptTask`, "promptTask must be non-empty.");
|
|
145
|
-
validateSignals(candidate.signals, `${stagePath}.signals`, add);
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
if (value.requiresArtifactKinds !== void 0 && !strings(value.requiresArtifactKinds)) add("agent_activity_string_list_invalid", `${path}.requiresArtifactKinds`, `${path}.requiresArtifactKinds must contain unique non-empty strings.`);
|
|
149
|
-
if (value.proposalTypes !== void 0 && !strings(value.proposalTypes)) add("agent_activity_string_list_invalid", `${path}.proposalTypes`, `${path}.proposalTypes must contain unique non-empty strings.`);
|
|
150
|
-
}
|
|
151
|
-
function validateStringLists(value, keys, required, path, add) {
|
|
152
|
-
if (!record(value)) {
|
|
153
|
-
add("agent_activity_policy_invalid", path, `${path} must be an object.`);
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
unknownKeys(value, keys, path, add);
|
|
157
|
-
for (const key of required) if (!strings(value[key])) add("agent_activity_string_list_invalid", `${path}.${key}`, `${path}.${key} must contain unique non-empty strings.`);
|
|
158
|
-
for (const key of keys) if (!["producerPolicy", "fanout"].includes(key) && value[key] !== void 0 && !strings(value[key])) add("agent_activity_string_list_invalid", `${path}.${key}`, `${path}.${key} must contain unique non-empty strings.`);
|
|
159
|
-
}
|
|
160
|
-
function validateBranch(value, path, add) {
|
|
161
|
-
if (!record(value) || typeof value.kind !== "string" || !BRANCH_KEYS[value.kind]) {
|
|
162
|
-
add("agent_activity_branch_policy_invalid", path, "branchPolicy.kind is invalid.");
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
unknownKeys(value, BRANCH_KEYS[value.kind], path, add);
|
|
166
|
-
const expected = value.kind === "read-only" ? ["main", "staging"] : value.kind === "main-planning-content" ? ["main"] : ["staging"];
|
|
167
|
-
if (!expected.includes(String(value.base))) add("agent_activity_branch_base_invalid", `${path}.base`, `branchPolicy.base must be ${expected.join(" or ")}.`);
|
|
168
|
-
if (value.kind === "assignment-feature" && value.target !== "staging") add("agent_activity_branch_target_invalid", `${path}.target`, "assignment-feature target must be staging.");
|
|
169
|
-
if (value.kind === "staging-release" && value.target !== "main") add("agent_activity_branch_target_invalid", `${path}.target`, "staging-release target must be main.");
|
|
170
|
-
}
|
|
171
|
-
function validateContentAccess(value, path, add) {
|
|
172
|
-
if (value === void 0) return;
|
|
173
|
-
if (!record(value)) {
|
|
174
|
-
add("agent_activity_permissions_invalid", path, "permissions must be an object.");
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
unknownKeys(value, CONTENT_ACCESS_KEYS, path, add);
|
|
178
|
-
if (value.content !== void 0) {
|
|
179
|
-
if (!record(value.content)) add("agent_activity_content_matrix_invalid", `${path}.content`, "content permissions must map model names to operation/filter policies.");
|
|
180
|
-
else for (const [model, permission] of Object.entries(value.content)) {
|
|
181
|
-
const modelPath = `${path}.content.${model}`;
|
|
182
|
-
if (!model.trim() || !record(permission)) {
|
|
183
|
-
add("agent_activity_model_permission_invalid", modelPath, "Each model permission must be an object.");
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
unknownKeys(permission, MODEL_PERMISSION_KEYS, modelPath, add);
|
|
187
|
-
if (!strings(permission.operations) || permission.operations.length === 0) add("agent_activity_model_operations_invalid", `${modelPath}.operations`, "Model operations must contain unique non-empty values.");
|
|
188
|
-
if (permission.filters !== void 0 && !record(permission.filters)) add("agent_activity_model_filters_invalid", `${modelPath}.filters`, "Model filters must be an object.");
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
if (value.commit !== void 0 && (!record(value.commit) || typeof value.commit.allowed !== "boolean" || Object.keys(value.commit).some((key) => key !== "allowed"))) add("agent_activity_commit_policy_invalid", `${path}.commit`, "commit must contain only a boolean allowed field.");
|
|
192
|
-
for (const key of ["repository", "network", "shell"]) if (value[key] !== void 0 && !record(value[key])) add("agent_activity_permissions_invalid", `${path}.${key}`, `${key} permissions must be an object.`);
|
|
193
|
-
}
|
|
194
|
-
function validateArtifactTriggers(value, path, add) {
|
|
195
|
-
if (value === void 0) return;
|
|
196
|
-
if (!Array.isArray(value)) {
|
|
197
|
-
add("agent_activity_artifact_triggers_invalid", path, "artifactTriggers must be an array.");
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
value.forEach((candidate, index) => {
|
|
201
|
-
const itemPath = `${path}[${index}]`;
|
|
202
|
-
if (!record(candidate)) {
|
|
203
|
-
add("agent_activity_artifact_trigger_invalid", itemPath, "Artifact trigger must be an object.");
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
unknownKeys(candidate, /* @__PURE__ */ new Set(["event", "artifactKind", "model", "required"]), itemPath, add);
|
|
207
|
-
for (const key of ["event", "artifactKind"]) if (typeof candidate[key] !== "string" || !candidate[key].trim()) add("agent_activity_artifact_trigger_invalid", `${itemPath}.${key}`, `${key} is required.`);
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
function validateCloseoutPolicy(value, path, add) {
|
|
211
|
-
if (value === void 0) return;
|
|
212
|
-
if (!record(value)) {
|
|
213
|
-
add("agent_activity_closeout_policy_invalid", path, "closeoutPolicy must be an object.");
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
unknownKeys(value, /* @__PURE__ */ new Set(["warningSeconds", "summaryRequired", "requiredArtifactKinds", "blockOnOpenQuestions"]), path, add);
|
|
217
|
-
if (value.warningSeconds !== void 0 && (!Number.isInteger(value.warningSeconds) || Number(value.warningSeconds) < 1)) add("agent_activity_closeout_warning_invalid", `${path}.warningSeconds`, "warningSeconds must be positive.");
|
|
218
|
-
if (value.requiredArtifactKinds !== void 0 && !strings(value.requiredArtifactKinds)) add("agent_activity_string_list_invalid", `${path}.requiredArtifactKinds`, "requiredArtifactKinds must contain unique non-empty strings.");
|
|
219
|
-
}
|
|
220
|
-
function validateCapabilityRequirements(value, path, add) {
|
|
221
|
-
if (value === void 0) {
|
|
222
|
-
add("agent_activity_capability_requirements_required", path, "capabilityRequirements is required.");
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
if (!Array.isArray(value) || value.length === 0) {
|
|
226
|
-
add("agent_activity_capability_requirements_required", path, "capabilityRequirements must be a non-empty array.");
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
value.forEach((candidate, index) => {
|
|
230
|
-
const itemPath = `${path}[${index}]`;
|
|
231
|
-
if (!record(candidate)) {
|
|
232
|
-
add("agent_activity_capability_requirement_invalid", itemPath, "Capability requirement must be an object.");
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
unknownKeys(candidate, /* @__PURE__ */ new Set(["capabilityId", "versionRange", "requirement", "alternativeGroup", "requiredFeatures", "configuration"]), itemPath, add);
|
|
236
|
-
if (typeof candidate.capabilityId !== "string" || !/^(?:treeseed\.|provider\.)/u.test(candidate.capabilityId)) add("agent_activity_capability_id_invalid", `${itemPath}.capabilityId`, "capabilityId must use a TreeSeed or provider namespace.");
|
|
237
|
-
if (typeof candidate.versionRange !== "string" || !candidate.versionRange.trim()) add("agent_activity_capability_version_invalid", `${itemPath}.versionRange`, "versionRange is required.");
|
|
238
|
-
if (!["required", "preferred"].includes(String(candidate.requirement))) add("agent_activity_capability_requirement_invalid", `${itemPath}.requirement`, "requirement must be required or preferred.");
|
|
239
|
-
if (candidate.requiredFeatures !== void 0 && !strings(candidate.requiredFeatures)) add("agent_activity_capability_features_invalid", `${itemPath}.requiredFeatures`, "requiredFeatures must contain unique values.");
|
|
240
|
-
if (candidate.configuration !== void 0 && !record(candidate.configuration)) add("agent_activity_capability_configuration_invalid", `${itemPath}.configuration`, "configuration must be an object.");
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
function validateQuestionPolicy(value, path, add) {
|
|
244
|
-
if (value === void 0) return;
|
|
245
|
-
if (!record(value)) {
|
|
246
|
-
add("agent_activity_question_policy_invalid", path, "questionPolicy must be an object.");
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
unknownKeys(value, QUESTION_KEYS, path, add);
|
|
250
|
-
if (value.blockExecutionWhenCreated !== void 0 && typeof value.blockExecutionWhenCreated !== "boolean") add("agent_activity_question_block_invalid", `${path}.blockExecutionWhenCreated`, "blockExecutionWhenCreated must be boolean.");
|
|
251
|
-
if (value.defaultAnswerPolicy !== void 0) {
|
|
252
|
-
if (!record(value.defaultAnswerPolicy)) add("agent_activity_answer_policy_invalid", `${path}.defaultAnswerPolicy`, "defaultAnswerPolicy must be an object.");
|
|
253
|
-
else {
|
|
254
|
-
unknownKeys(value.defaultAnswerPolicy, QUESTION_POLICY_KEYS, `${path}.defaultAnswerPolicy`, add);
|
|
255
|
-
if (!["team-human", "human-or-agent", "specific-human", "specific-agent"].includes(String(value.defaultAnswerPolicy.kind))) add("agent_activity_answer_policy_kind_invalid", `${path}.defaultAnswerPolicy.kind`, "Unknown answer policy kind.");
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
function validateExecution(value, path, add) {
|
|
260
|
-
if (value === void 0) return;
|
|
261
|
-
if (!record(value)) {
|
|
262
|
-
add("agent_activity_execution_invalid", path, "execution must be an object.");
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
unknownKeys(value, EXECUTION_KEYS, path, add);
|
|
266
|
-
for (const key of ["allowedPaths", "forbiddenPaths"]) if (value[key] !== void 0 && !strings(value[key])) add("agent_activity_string_list_invalid", `${path}.${key}`, `${path}.${key} must contain unique non-empty strings.`);
|
|
267
|
-
if (value.reasoningEffort !== void 0 && !["minimal", "low", "medium", "high", "xhigh"].includes(String(value.reasoningEffort))) add("agent_activity_reasoning_effort_invalid", `${path}.reasoningEffort`, "reasoningEffort must be minimal, low, medium, high, or xhigh.");
|
|
268
|
-
if (value.maxRuntimeSeconds !== void 0 && (!Number.isInteger(value.maxRuntimeSeconds) || Number(value.maxRuntimeSeconds) < 1)) add("agent_activity_runtime_invalid", `${path}.maxRuntimeSeconds`, "maxRuntimeSeconds must be a positive integer.");
|
|
269
|
-
if (value.closeoutWarningSeconds !== void 0 && (!Number.isInteger(value.closeoutWarningSeconds) || Number(value.closeoutWarningSeconds) < 1)) add("agent_activity_closeout_warning_invalid", `${path}.closeoutWarningSeconds`, "closeoutWarningSeconds must be a positive integer.");
|
|
270
|
-
if (value.preparationSeconds !== void 0 && (!Number.isInteger(value.preparationSeconds) || Number(value.preparationSeconds) < 1)) add("agent_activity_preparation_duration_invalid", `${path}.preparationSeconds`, "preparationSeconds must be a positive integer.");
|
|
271
|
-
if (value.closeoutSeconds !== void 0 && (!Number.isInteger(value.closeoutSeconds) || Number(value.closeoutSeconds) < 1)) add("agent_activity_closeout_duration_invalid", `${path}.closeoutSeconds`, "closeoutSeconds must be a positive integer.");
|
|
272
|
-
if (value.maxRetries !== void 0 && (!Number.isInteger(value.maxRetries) || Number(value.maxRetries) < 0)) add("agent_activity_retries_invalid", `${path}.maxRetries`, "maxRetries must be a non-negative integer.");
|
|
273
|
-
if (value.verificationRequired !== void 0 && typeof value.verificationRequired !== "boolean") add("agent_activity_verification_invalid", `${path}.verificationRequired`, "verificationRequired must be boolean.");
|
|
3
|
+
const parsed = activityProfilesSchema.safeParse(value);
|
|
4
|
+
return parsed.success ? { ok: true, diagnostics: [] } : { ok: false, diagnostics: diagnosticsFromZod(parsed.error, "activityProfiles") };
|
|
274
5
|
}
|
|
275
6
|
export {
|
|
276
7
|
validateAgentActivityProfilesConfiguration
|