@treeseed/sdk 0.13.0-rc.121 → 0.13.0-rc.123
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/agent-capacity/contracts/capacity/assignments/agent-execution.d.ts +2365 -1275
- package/dist/agent-capacity/contracts/capacity/assignments/agent-execution.js +94 -28
- package/dist/agent-capacity/contracts/capacity/assignments/assignment-context-pack.d.ts +38 -38
- package/dist/agent-capacity/contracts/capacity/assignments/assignment-path.d.ts +2 -0
- package/dist/agent-capacity/contracts/capacity/assignments/assignment-path.js +13 -0
- package/dist/agent-capacity/contracts/capacity/assignments/assignment-records.d.ts +2 -59
- package/dist/agent-capacity/contracts/capacity/providers/supply-policy.d.ts +126 -1
- package/dist/agent-capacity/contracts/capacity/providers/supply-policy.js +35 -1
- package/dist/agent-capacity/contracts/capacity/workdays/assignment-allocation.d.ts +2 -4
- package/dist/agent-capacity/contracts/capacity/workdays/assignment-allocation.js +22 -16
- package/dist/agent-capacity/contracts/capacity/workdays/capability-accounting.d.ts +3 -42
- package/dist/agent-capacity/contracts/capacity/workdays/capability-accounting.js +8 -8
- package/dist/agent-capacity/contracts/capacity/workdays/workday-allocation.d.ts +244 -85
- package/dist/agent-capacity/contracts/capacity/workdays/workday-allocation.js +54 -19
- package/dist/agent-capacity/contracts/capacity/workdays/workday-records.d.ts +216 -70
- package/dist/agent-capacity/contracts/capacity/workdays/workday-records.js +19 -0
- package/dist/agent-capacity/contracts/configuration/configuration.d.ts +1 -1
- package/dist/agent-capacity/contracts/configuration/configuration.js +0 -2
- package/dist/agent-capacity/contracts/operations/agent-team-clone.d.ts +55 -55
- package/dist/agent-capacity/contracts/projects/agents/project-agent-class.d.ts +119 -23
- package/dist/agent-capacity/contracts/projects/agents/project-agent-class.js +16 -0
- package/dist/agent-capacity/contracts/runtime/runtime-observability.d.ts +2 -154
- package/dist/agent-capacity/contracts/support/agent-atlas.d.ts +0 -13
- package/dist/agent-capacity/contracts/support/execution-graph.d.ts +496 -292
- package/dist/agent-capacity/contracts/support/execution-graph.js +21 -19
- package/dist/agent-capacity/contracts/support/financial-records.d.ts +3 -6
- package/dist/agent-capacity/contracts/support/planning-records.d.ts +1 -87
- package/dist/agent-capacity/grant.d.ts +34 -0
- package/dist/agent-capacity/grant.js +4 -0
- package/dist/agent-capacity/validation/agent-definition-schema.d.ts +1178 -1152
- package/dist/agent-capacity/validation/agent-definition-schema.js +21 -28
- package/dist/agent-capacity/validation/agent-lab-forensics-schema.d.ts +10 -10
- package/dist/agent-capacity/validation/agent-lab-forensics-schema.js +0 -1
- package/dist/agent-capacity/validation/assignment-records.d.ts +1 -6
- package/dist/agent-capacity/validation/assignment-records.js +49 -35
- package/dist/agent-capacity/validation/configuration.d.ts +1 -1
- package/dist/agent-capacity/validation/configuration.js +2 -6
- package/dist/agent-capacity/validation/grant.d.ts +11 -0
- package/dist/agent-capacity/validation/grant.js +31 -0
- package/dist/capacity/agents/agent-capacity.d.ts +3 -4
- package/dist/capacity/agents/agent-capacity.js +2 -3
- package/dist/capacity-provider/capability-ontology.d.ts +150 -150
- package/dist/capacity-provider/client.d.ts +15 -9
- package/dist/capacity-provider/client.js +1 -10
- package/dist/capacity-provider/contracts/capacity-facts.d.ts +0 -1
- package/dist/capacity-provider/contracts/environment-profiles.d.ts +44 -44
- package/dist/capacity-provider/contracts/governance.d.ts +2 -17
- package/dist/capacity-provider/contracts/index.d.ts +2 -0
- package/dist/capacity-provider/contracts/index.js +2 -0
- package/dist/capacity-provider/core-capability-catalog.d.ts +7 -7
- package/dist/capacity-provider/environment-catalog.d.ts +188 -188
- package/dist/capacity-provider/environment-catalog.js +1 -1
- package/dist/capacity-provider/install-configuration.d.ts +2 -2
- package/dist/capacity-provider/sandbox-contracts.d.ts +92 -92
- package/dist/capacity-provider/source-workspace.d.ts +166 -68
- package/dist/capacity-provider/source-workspace.js +5 -1
- package/dist/capacity-provider/validation.d.ts +10 -2
- package/dist/capacity-provider/validation.js +52 -22
- package/dist/content/validation/agent-operational-content-schemas.d.ts +144 -142
- package/dist/content/validation/agent-operational-content-schemas.js +2 -0
- package/dist/content/validation/auxiliary-content-schemas.d.ts +158 -158
- package/dist/content/validation/content-model-schemas.d.ts +9105 -5295
- package/dist/content/validation/content-model-schemas.js +192 -115
- package/dist/content/validation/portable-content-data.d.ts +411 -238
- package/dist/content/validation/portable-content-data.js +6 -1
- package/dist/content/validation/schema-constraints.d.ts +78 -0
- package/dist/content/validation/schema-constraints.js +149 -0
- package/dist/deployment/ai/storage.d.ts +24 -24
- package/dist/deployment/ai-hosting.d.ts +18 -18
- package/dist/deployment/ai-instance.d.ts +16 -16
- package/dist/deployment/ai-mode.d.ts +92 -92
- package/dist/deployment/hosted-topology-template.d.ts +44 -44
- package/dist/deployment/hosted-topology.d.ts +335 -335
- package/dist/deployment/postgres/contracts.d.ts +52 -52
- package/dist/deployment/postgres/transfer.d.ts +6 -6
- package/dist/deployment/schemas.d.ts +1114 -1114
- package/dist/development/schemas.d.ts +633 -633
- package/dist/graph/context-query-contracts.js +1 -1
- package/dist/guarantees/index.d.ts +26 -2
- package/dist/identity/contracts.js +6 -1
- package/dist/knowledge/contracts.d.ts +9 -2
- package/dist/knowledge/contracts.js +2 -2
- package/dist/model-registry/discussion-models.js +0 -1
- package/dist/operator-contracts/canonical-command-tree.js +25 -9
- package/dist/operator-contracts/catalog/agents/agent-team-clone-operations.d.ts +29 -29
- package/dist/operator-contracts/catalog/capability-ontology-operations.d.ts +30 -30
- package/dist/operator-contracts/catalog/commands/command-tree-builders.d.ts +15 -13
- package/dist/operator-contracts/catalog/communication-operations.d.ts +176 -158
- package/dist/operator-contracts/catalog/hosted-topology-operations.d.ts +67 -67
- package/dist/operator-contracts/catalog/inbox-operations.d.ts +65 -65
- package/dist/operator-contracts/catalog/infrastructure/ai-instance-operations.d.ts +6 -6
- package/dist/operator-contracts/catalog/infrastructure/ai-instance-operations.js +2 -1
- package/dist/operator-contracts/catalog/knowledge-share-operations.d.ts +10 -10
- package/dist/operator-contracts/catalog/provider-environment-operations.d.ts +3 -3
- package/dist/operator-contracts/catalog/services/secret-operations.d.ts +16 -8
- package/dist/operator-contracts/catalog/services/secret-operations.js +2 -1
- package/dist/operator-contracts/catalog/workdays/profile-operations.d.ts +11 -11
- package/dist/operator-contracts/catalog/workdays/selection-commands.js +3 -0
- package/dist/operator-contracts/communication/contracts.d.ts +537 -395
- package/dist/operator-contracts/communication/contracts.js +6 -1
- package/dist/operator-contracts/control-plane-operation.d.ts +7 -0
- package/dist/operator-contracts/control-plane-operation.js +6 -0
- package/dist/operator-contracts/control-plane-operations.d.ts +631 -610
- package/dist/operator-contracts/control-plane-operations.js +26 -12
- package/dist/operator-contracts/inbox/contracts.d.ts +229 -229
- package/dist/operator-contracts/knowledge/contracts.d.ts +16 -16
- package/dist/operator-contracts/mcp.js +4 -3
- package/dist/operator-contracts/workday-lifecycle.d.ts +192 -0
- package/dist/operator-contracts/workday-lifecycle.js +109 -45
- package/dist/platform/agent-schema-verification.d.ts +3 -0
- package/dist/platform/agent-schema-verification.js +377 -0
- package/dist/platform/contracts.d.ts +72 -72
- package/dist/platform/schemas.d.ts +144 -36
- package/dist/platform/schemas.js +26 -0
- package/dist/platform/verification.js +10 -0
- package/dist/sdk-types/support/planning-policy.d.ts +1 -1
- package/dist/sdk-types/support/sdk-search-request.d.ts +2 -2
- package/dist/secrets-capability/secret-contracts.d.ts +2 -2
- package/dist/secrets-capability/shared-access.d.ts +3 -3
- package/dist/secrets-capability/shared-resources.d.ts +50 -50
- package/dist/secrets-capability/vault-contracts.d.ts +2 -2
- package/dist/security/encrypted-envelope.d.ts +14 -14
- package/dist/treedx/client.d.ts +4 -4
- package/dist/treedx/index.d.ts +1 -1
- package/dist/treedx/index.js +1 -0
- package/dist/treedx/types.d.ts +286 -0
- package/dist/treedx/types.js +44 -0
- package/guarantees/agent/golden/component-boundaries.guarantee.yaml +12 -0
- package/guarantees/agent/golden/product-custody.guarantee.yaml +12 -0
- package/guarantees/agent/golden/product.guarantee.yaml +12 -0
- package/guarantees/agent/golden/scenes/component-boundaries.scene.yaml +837 -0
- package/guarantees/agent/golden/scenes/product-custody.scene.yaml +53 -0
- package/guarantees/agent/golden/scenes/product.scene.yaml +8 -0
- package/guarantees/verifiers/golden.verifiers.yaml +1429 -0
- package/package.json +9 -3
- package/tests/acceptance/golden-product.test.ts +205 -0
- package/tests/acceptance/golden-product.ts +404 -0
- package/tests/acceptance/product/base-red.ts +73 -0
- package/tests/acceptance/product/documentation-examples.ts +68 -0
- package/tests/acceptance/product/intent-runtime.ts +145 -0
- package/tests/acceptance/product/release-output.ts +160 -0
- package/tests/acceptance/product/research-artifact.ts +87 -0
- package/tests/acceptance/product/research-revision.ts +82 -0
- package/tests/acceptance/product/research-source.ts +91 -0
- package/tests/acceptance/product/test-chain.ts +192 -0
- package/treeseed.package.yaml +147 -0
- package/dist/.treeseed-build-complete.json +0 -1
- package/dist/agent-capacity/allocation.d.ts +0 -183
- package/dist/agent-capacity/allocation.js +0 -5
- package/dist/agent-capacity/artifact-mutation-receipt.d.ts +0 -49
- package/dist/agent-capacity/artifact-mutation-receipt.js +0 -36
- package/dist/agent-capacity/artifacts.d.ts +0 -123
- package/dist/agent-capacity/artifacts.js +0 -39
- package/dist/agent-capacity/contracts/support/decision-work.d.ts +0 -227
- package/dist/agent-capacity/contracts/support/decision-work.js +0 -0
- package/dist/agent-capacity/validation/allocation.d.ts +0 -12
- package/dist/agent-capacity/validation/allocation.js +0 -115
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { describeContentFrontmatterSchema } from "../content/validation/content-model-schemas.js";
|
|
2
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { exportSchemaConstraints } from "../content/validation/schema-constraints.js";
|
|
5
|
+
import {
|
|
6
|
+
assignmentAttemptSchema,
|
|
7
|
+
assignmentContextSchema,
|
|
8
|
+
assignmentResultSchema,
|
|
9
|
+
usageSettlementSchema,
|
|
10
|
+
leaseSchema,
|
|
11
|
+
reservationSchema,
|
|
12
|
+
exactEntityReferenceSchema,
|
|
13
|
+
exactGrantSchema,
|
|
14
|
+
assignmentWorkspaceSchema,
|
|
15
|
+
estimateSchema
|
|
16
|
+
} from "../agent-capacity/contracts/capacity/assignments/agent-execution.js";
|
|
17
|
+
import {
|
|
18
|
+
assignmentReferenceSchema,
|
|
19
|
+
effectiveActivityProfileSchema,
|
|
20
|
+
authorizedContextItemSchema,
|
|
21
|
+
verificationRecordSchema,
|
|
22
|
+
usageSchema,
|
|
23
|
+
diagnosticSchema,
|
|
24
|
+
assignmentTimingAwarenessReceiptSchema
|
|
25
|
+
} from "../agent-capacity/contracts/capacity/assignments/agent-execution.js";
|
|
26
|
+
import {
|
|
27
|
+
executionNodeSchema,
|
|
28
|
+
executionEdgeSchema,
|
|
29
|
+
graphRevisionSchema,
|
|
30
|
+
graphChangeSetSchema,
|
|
31
|
+
conditionDefinitionSchema
|
|
32
|
+
} from "../agent-capacity/validation/execution/execution-graph.js";
|
|
33
|
+
import { appliedWorkdaySchema, workdayPolicySchema, workdayProfileSchema, weightMapSchema, projectWeightSchema, agentClassWeightSchema } from "../agent-capacity/contracts/capacity/workdays/workday-allocation.js";
|
|
34
|
+
import { activityProfileSchema, activityProfilesSchema } from "../agent-capacity/validation/agent-definition-schema.js";
|
|
35
|
+
import { providerOfferSchema, providerStateSchema, availabilityWindowSchema, nativeLimitSchema } from "../agent-capacity/contracts/capacity/providers/supply-policy.js";
|
|
36
|
+
import { treeDxWorkspaceSchema, treeDxWorkspaceReviewSchema, treeDxPublicationReceiptSchema } from "../treedx/types.js";
|
|
37
|
+
import { teamRecordSchema, projectRecordSchema, repositoryBindingSchema, treeDxBindingSchema } from "./schemas.js";
|
|
38
|
+
import { agentRegistrationSchema } from "../agent-capacity/contracts/projects/agents/project-agent-class.js";
|
|
39
|
+
import { workdayIntentSchema } from "../operator-contracts/workday-lifecycle.js";
|
|
40
|
+
import { workdayScheduleSchema } from "../agent-capacity/contracts/capacity/workdays/workday-records.js";
|
|
41
|
+
const models = {
|
|
42
|
+
Book: "book",
|
|
43
|
+
Knowledge: "knowledge",
|
|
44
|
+
Objective: "objective",
|
|
45
|
+
Discussion: "discussion",
|
|
46
|
+
DiscussionMessage: "discussion_message",
|
|
47
|
+
AgentProfile: "agent",
|
|
48
|
+
Proposal: "proposal",
|
|
49
|
+
Question: "question",
|
|
50
|
+
Note: "note",
|
|
51
|
+
Decision: "decision"
|
|
52
|
+
};
|
|
53
|
+
const runtimeSchemas = {
|
|
54
|
+
WeightMap: weightMapSchema,
|
|
55
|
+
ProjectWeight: projectWeightSchema,
|
|
56
|
+
AgentClassWeight: agentClassWeightSchema,
|
|
57
|
+
WorkdayIntent: workdayIntentSchema,
|
|
58
|
+
RepositoryBinding: repositoryBindingSchema,
|
|
59
|
+
TreeDxBinding: treeDxBindingSchema,
|
|
60
|
+
AvailabilityWindow: availabilityWindowSchema,
|
|
61
|
+
NativeLimit: nativeLimitSchema,
|
|
62
|
+
AssignmentContext: assignmentContextSchema,
|
|
63
|
+
ExactEntityReference: exactEntityReferenceSchema,
|
|
64
|
+
ExactGrant: exactGrantSchema,
|
|
65
|
+
AssignmentWorkspace: assignmentWorkspaceSchema,
|
|
66
|
+
Estimate: estimateSchema,
|
|
67
|
+
AssignmentReference: assignmentReferenceSchema,
|
|
68
|
+
GitReference: assignmentReferenceSchema.options[0],
|
|
69
|
+
TreeDxReference: assignmentReferenceSchema.options[1],
|
|
70
|
+
UrlReference: assignmentReferenceSchema.options[2],
|
|
71
|
+
ReadOnlyWorkspace: assignmentWorkspaceSchema.options[0],
|
|
72
|
+
TreeDxAssignmentWorkspace: assignmentWorkspaceSchema.options[1],
|
|
73
|
+
GitAssignmentWorkspace: assignmentWorkspaceSchema.options[2],
|
|
74
|
+
EffectiveActivityProfile: effectiveActivityProfileSchema,
|
|
75
|
+
AuthorizedContextItem: authorizedContextItemSchema,
|
|
76
|
+
VerificationRecord: verificationRecordSchema,
|
|
77
|
+
Usage: usageSchema,
|
|
78
|
+
Diagnostic: diagnosticSchema,
|
|
79
|
+
AssignmentTimingAwarenessReceipt: assignmentTimingAwarenessReceiptSchema,
|
|
80
|
+
GraphChangeSet: graphChangeSetSchema,
|
|
81
|
+
ConditionDefinition: conditionDefinitionSchema,
|
|
82
|
+
WorkdayPolicyFields: workdayPolicySchema,
|
|
83
|
+
ActivityProfile: activityProfileSchema,
|
|
84
|
+
ActivityProfiles: activityProfilesSchema,
|
|
85
|
+
PlanningRound: appliedWorkdaySchema.innerType().shape.planningRounds.element,
|
|
86
|
+
AssignmentLimits: assignmentAttemptSchema.innerType().shape.limits,
|
|
87
|
+
ProviderOfferSelection: assignmentAttemptSchema.innerType().shape.provider
|
|
88
|
+
};
|
|
89
|
+
const schemas = {
|
|
90
|
+
Team: teamRecordSchema,
|
|
91
|
+
Project: projectRecordSchema,
|
|
92
|
+
AgentRegistration: agentRegistrationSchema,
|
|
93
|
+
WorkdaySchedule: workdayScheduleSchema,
|
|
94
|
+
...Object.fromEntries(Object.entries(models).map(([name, model]) => [name, describeContentFrontmatterSchema(model)])),
|
|
95
|
+
ProviderOffer: providerOfferSchema,
|
|
96
|
+
ProviderState: providerStateSchema,
|
|
97
|
+
TreeDxWorkspace: treeDxWorkspaceSchema,
|
|
98
|
+
TreeDxWorkspaceReview: treeDxWorkspaceReviewSchema,
|
|
99
|
+
TreeDxPublicationReceipt: treeDxPublicationReceiptSchema,
|
|
100
|
+
AssignmentAttempt: assignmentAttemptSchema,
|
|
101
|
+
AssignmentResult: assignmentResultSchema,
|
|
102
|
+
UsageSettlement: usageSettlementSchema,
|
|
103
|
+
Lease: leaseSchema,
|
|
104
|
+
Reservation: reservationSchema,
|
|
105
|
+
ExecutionNode: executionNodeSchema,
|
|
106
|
+
ExecutionEdge: executionEdgeSchema,
|
|
107
|
+
Workday: appliedWorkdaySchema,
|
|
108
|
+
GraphRevision: graphRevisionSchema,
|
|
109
|
+
WorkdayPolicy: workdayProfileSchema,
|
|
110
|
+
...runtimeSchemas
|
|
111
|
+
};
|
|
112
|
+
const runtimeOnly = new Set(Object.keys(runtimeSchemas));
|
|
113
|
+
function record(value) {
|
|
114
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
115
|
+
}
|
|
116
|
+
function dereference(schema, root, references) {
|
|
117
|
+
while (typeof schema.$ref === "string" && schema.$ref.startsWith("#/")) {
|
|
118
|
+
const reference = schema.$ref;
|
|
119
|
+
if (references.has(reference)) return schema;
|
|
120
|
+
references.add(reference);
|
|
121
|
+
const parts = reference.slice(2).split("/");
|
|
122
|
+
if (parts.some((part) => /~(?![01])/u.test(part))) return schema;
|
|
123
|
+
let selected = root;
|
|
124
|
+
for (const part of parts) {
|
|
125
|
+
const key = part.replace(/~1/gu, "/").replace(/~0/gu, "~");
|
|
126
|
+
if (!selected || typeof selected !== "object" || !Object.hasOwn(selected, key)) return schema;
|
|
127
|
+
selected = Object.getOwnPropertyDescriptor(selected, key)?.value;
|
|
128
|
+
}
|
|
129
|
+
if (selected === false) return false;
|
|
130
|
+
if (selected !== true && (!selected || typeof selected !== "object" || Array.isArray(selected))) return schema;
|
|
131
|
+
schema = { ...record(selected), ...Object.fromEntries(Object.entries(schema).filter(([key]) => key !== "$ref")) };
|
|
132
|
+
}
|
|
133
|
+
return schema;
|
|
134
|
+
}
|
|
135
|
+
function disjointTaggedBranches(value) {
|
|
136
|
+
if (!Array.isArray(value) || !value.length) return false;
|
|
137
|
+
const branches = value.map(record), first = branches[0];
|
|
138
|
+
if (branches.some((branch) => branch.type !== "object" || !Array.isArray(branch.required))) return false;
|
|
139
|
+
return first.required.some((field) => {
|
|
140
|
+
if (typeof field !== "string") return false;
|
|
141
|
+
const tags = [];
|
|
142
|
+
for (const branch of branches) {
|
|
143
|
+
if (!branch.required.includes(field)) return false;
|
|
144
|
+
const tag = record(record(branch.properties)[field]);
|
|
145
|
+
if (!Object.hasOwn(tag, "const")) return false;
|
|
146
|
+
const literal = tag.const;
|
|
147
|
+
if (literal !== null && typeof literal !== "string" && typeof literal !== "boolean" && !(typeof literal === "number" && Number.isFinite(literal))) return false;
|
|
148
|
+
tags.push(JSON.stringify(literal));
|
|
149
|
+
}
|
|
150
|
+
return new Set(tags).size === branches.length;
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function finiteValuesImplyType(schema) {
|
|
154
|
+
const values = Object.hasOwn(schema, "const") ? [schema.const] : Array.isArray(schema.enum) ? schema.enum : [];
|
|
155
|
+
const types = Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
156
|
+
return values.length > 0 && values.every((value) => types.some((type) => type === "null" ? value === null : type === "array" ? Array.isArray(value) : type === "object" ? value !== null && typeof value === "object" && !Array.isArray(value) : type === "integer" ? typeof value === "number" && Number.isInteger(value) : type === "number" ? typeof value === "number" && Number.isFinite(value) : typeof value === type));
|
|
157
|
+
}
|
|
158
|
+
function finiteValues(value) {
|
|
159
|
+
const schema = record(value), keys = Object.keys(schema);
|
|
160
|
+
if (keys.length !== 1) return void 0;
|
|
161
|
+
const values = keys[0] === "const" ? [schema.const] : keys[0] === "enum" && Array.isArray(schema.enum) ? schema.enum : schema.type === "null" ? [null] : void 0;
|
|
162
|
+
if (!values?.length || values.some((item) => item !== null && typeof item !== "string" && typeof item !== "boolean" && !(typeof item === "number" && Number.isFinite(item)))) return void 0;
|
|
163
|
+
return values;
|
|
164
|
+
}
|
|
165
|
+
function finiteSchema(values) {
|
|
166
|
+
const unique = [...new Map(values.map((value) => [JSON.stringify(value), value])).entries()].sort(([left], [right]) => left.localeCompare(right)).map(([, value]) => value);
|
|
167
|
+
return unique.length === 1 ? { const: unique[0] } : { enum: unique };
|
|
168
|
+
}
|
|
169
|
+
function structuralSchema(value, root, ancestors = /* @__PURE__ */ new Set(), inheritedObject = false, cache = /* @__PURE__ */ new WeakMap()) {
|
|
170
|
+
if (!value || typeof value !== "object") return structuralSchemaValue(value, root, ancestors, inheritedObject, cache);
|
|
171
|
+
const key = JSON.stringify([[...ancestors].sort(), inheritedObject]), entries = cache.get(value) ?? /* @__PURE__ */ new Map();
|
|
172
|
+
if (entries.has(key)) return entries.get(key);
|
|
173
|
+
const result = structuralSchemaValue(value, root, ancestors, inheritedObject, cache);
|
|
174
|
+
entries.set(key, result);
|
|
175
|
+
cache.set(value, entries);
|
|
176
|
+
return result;
|
|
177
|
+
}
|
|
178
|
+
function structuralSchemaValue(value, root, ancestors, inheritedObject, cache) {
|
|
179
|
+
if (typeof value === "boolean") return value ? {} : false;
|
|
180
|
+
const references = new Set(ancestors), schema = dereference(record(value), root, references);
|
|
181
|
+
if (schema === false) return false;
|
|
182
|
+
const normalized = {};
|
|
183
|
+
for (const key of [
|
|
184
|
+
"$ref",
|
|
185
|
+
"type",
|
|
186
|
+
"const",
|
|
187
|
+
"enum",
|
|
188
|
+
"minLength",
|
|
189
|
+
"maxLength",
|
|
190
|
+
"pattern",
|
|
191
|
+
"format",
|
|
192
|
+
"minimum",
|
|
193
|
+
"maximum",
|
|
194
|
+
"exclusiveMinimum",
|
|
195
|
+
"exclusiveMaximum",
|
|
196
|
+
"multipleOf",
|
|
197
|
+
"minItems",
|
|
198
|
+
"maxItems",
|
|
199
|
+
"minProperties",
|
|
200
|
+
"maxProperties",
|
|
201
|
+
"uniqueItems",
|
|
202
|
+
"minContains",
|
|
203
|
+
"maxContains"
|
|
204
|
+
]) {
|
|
205
|
+
if (schema[key] !== void 0) normalized[key] = schema[key];
|
|
206
|
+
}
|
|
207
|
+
const objectAuthority = inheritedObject || schema.type === "object";
|
|
208
|
+
if (inheritedObject && normalized.type === "object") delete normalized.type;
|
|
209
|
+
if (normalized.type === "integer" && schema.exclusiveMinimum === 0 && normalized.minimum === void 0) {
|
|
210
|
+
normalized.minimum = 1;
|
|
211
|
+
delete normalized.exclusiveMinimum;
|
|
212
|
+
}
|
|
213
|
+
if (!Object.hasOwn(normalized, "const") && Array.isArray(normalized.enum) && normalized.enum.length === 1) {
|
|
214
|
+
normalized.const = normalized.enum[0];
|
|
215
|
+
delete normalized.enum;
|
|
216
|
+
}
|
|
217
|
+
if (finiteValuesImplyType(normalized)) delete normalized.type;
|
|
218
|
+
for (const key of ["items", "contains", "not", "if", "then", "else", "propertyNames", "unevaluatedItems", "unevaluatedProperties"]) {
|
|
219
|
+
if (schema[key] !== void 0) normalized[key] = structuralSchema(
|
|
220
|
+
schema[key],
|
|
221
|
+
root,
|
|
222
|
+
references,
|
|
223
|
+
objectAuthority && ["not", "if", "then", "else"].includes(key),
|
|
224
|
+
cache
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
for (const key of ["allOf", "anyOf", "oneOf", "prefixItems"]) {
|
|
228
|
+
if (schema[key] !== void 0) normalized[key] = Array.isArray(schema[key]) ? schema[key].map((child) => structuralSchema(child, root, references, objectAuthority && key !== "prefixItems", cache)) : schema[key];
|
|
229
|
+
}
|
|
230
|
+
if (normalized.anyOf === void 0 && disjointTaggedBranches(normalized.oneOf)) {
|
|
231
|
+
normalized.anyOf = normalized.oneOf;
|
|
232
|
+
delete normalized.oneOf;
|
|
233
|
+
}
|
|
234
|
+
if (disjointTaggedBranches(normalized.anyOf)) normalized.anyOf = [...normalized.anyOf].sort((left, right) => JSON.stringify(left).localeCompare(JSON.stringify(right)));
|
|
235
|
+
for (const key of ["properties", "patternProperties", "dependentSchemas"]) {
|
|
236
|
+
if (schema[key] !== void 0) normalized[key] = Object.fromEntries(
|
|
237
|
+
Object.entries(record(schema[key])).sort(([left], [right]) => left.localeCompare(right)).map(([name, child]) => [name, structuralSchema(child, root, references, false, cache)])
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
if (schema.dependentRequired !== void 0) normalized.dependentRequired = Object.fromEntries(
|
|
241
|
+
Object.entries(record(schema.dependentRequired)).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => [key, Array.isArray(child) ? [...child].sort() : child])
|
|
242
|
+
);
|
|
243
|
+
if (Array.isArray(schema.required)) normalized.required = [...schema.required].sort();
|
|
244
|
+
if (schema.additionalProperties === false) normalized.additionalProperties = false;
|
|
245
|
+
else if (schema.additionalProperties && Object.keys(record(schema.additionalProperties)).length) {
|
|
246
|
+
normalized.additionalProperties = structuralSchema(schema.additionalProperties, root, references, false, cache);
|
|
247
|
+
}
|
|
248
|
+
const finite = finiteValues(normalized);
|
|
249
|
+
if (finite) return finiteSchema(finite);
|
|
250
|
+
if (Object.keys(normalized).length === 1) {
|
|
251
|
+
const key = normalized.anyOf !== void 0 ? "anyOf" : "oneOf", union = normalized[key];
|
|
252
|
+
if (Array.isArray(union) && union.length) {
|
|
253
|
+
const branches = union.map(finiteValues);
|
|
254
|
+
if (branches.every((branch) => branch !== void 0)) {
|
|
255
|
+
const values = branches.flat();
|
|
256
|
+
if (key === "anyOf" || new Set(values.map((value2) => JSON.stringify(value2))).size === values.length) {
|
|
257
|
+
return finiteSchema(values);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return normalized;
|
|
263
|
+
}
|
|
264
|
+
function structuralDifferences(expected, actual, path = "") {
|
|
265
|
+
if (JSON.stringify(expected) === JSON.stringify(actual)) return [];
|
|
266
|
+
if (!expected || !actual || typeof expected !== "object" || typeof actual !== "object" || Array.isArray(expected) !== Array.isArray(actual)) return [
|
|
267
|
+
`${path || "<root>"}: declaration ${JSON.stringify(expected)}, executable ${JSON.stringify(actual)}`
|
|
268
|
+
];
|
|
269
|
+
const left = expected, right = actual;
|
|
270
|
+
return [.../* @__PURE__ */ new Set([...Object.keys(left), ...Object.keys(right)])].sort().flatMap((key) => structuralDifferences(left[key], right[key], path ? `${path}.${key}` : key));
|
|
271
|
+
}
|
|
272
|
+
const executableStructures = new Map(Object.entries(schemas).map(([name, schema]) => {
|
|
273
|
+
const generated = record(zodToJsonSchema(schema, { name, $refStrategy: "none", postProcess: exportSchemaConstraints }));
|
|
274
|
+
let base = schema;
|
|
275
|
+
while (base instanceof z.ZodEffects) base = base.innerType();
|
|
276
|
+
const shape = base instanceof z.ZodObject ? base.shape : {};
|
|
277
|
+
const keys = Object.keys(shape).sort(), required = keys.filter((key) => !shape[key].isOptional());
|
|
278
|
+
return [name, {
|
|
279
|
+
object: base instanceof z.ZodObject,
|
|
280
|
+
shape,
|
|
281
|
+
keys,
|
|
282
|
+
required,
|
|
283
|
+
structure: JSON.stringify(structuralSchema(record(record(generated.definitions)[name]), generated))
|
|
284
|
+
}];
|
|
285
|
+
}));
|
|
286
|
+
function verifyAgentContentSchema(document, path = "docs/agent.schema.yml") {
|
|
287
|
+
const definitions = document?.$defs ?? {};
|
|
288
|
+
const diagnostics = [];
|
|
289
|
+
const structures = /* @__PURE__ */ new WeakMap();
|
|
290
|
+
for (const [name, value] of Object.entries(definitions)) if (!Object.keys(record(value)).length)
|
|
291
|
+
diagnostics.push({ code: "agent_schema_missing", path, message: `${name} definition is missing or unconstrained.` });
|
|
292
|
+
const union = record(document).oneOf;
|
|
293
|
+
if (!Array.isArray(union) || !union.length) diagnostics.push({
|
|
294
|
+
code: "agent_schema_root_missing",
|
|
295
|
+
path,
|
|
296
|
+
message: "The stored-record root must declare a nonempty oneOf union; a content-model subset is not complete authority."
|
|
297
|
+
});
|
|
298
|
+
else {
|
|
299
|
+
const seen = /* @__PURE__ */ new Set();
|
|
300
|
+
for (const entry of union) {
|
|
301
|
+
const reference = record(entry).$ref;
|
|
302
|
+
const match = typeof reference === "string" ? /^#\/\$defs\/([^/]+)$/u.exec(reference) : null;
|
|
303
|
+
const name = match?.[1];
|
|
304
|
+
if (!name || Object.keys(record(entry)).length !== 1) diagnostics.push({
|
|
305
|
+
code: "agent_schema_root_invalid",
|
|
306
|
+
path,
|
|
307
|
+
message: `Stored-record root reference ${String(reference)} must identify one exact local definition.`
|
|
308
|
+
});
|
|
309
|
+
else {
|
|
310
|
+
if (seen.has(name)) diagnostics.push({ code: "agent_schema_root_duplicate", path, message: `Stored-record root repeats ${name}.` });
|
|
311
|
+
seen.add(name);
|
|
312
|
+
if (!Object.hasOwn(definitions, name) || !Object.keys(record(definitions[name])).length) diagnostics.push({
|
|
313
|
+
code: "agent_schema_missing",
|
|
314
|
+
path,
|
|
315
|
+
message: `${name} root authority is missing or unconstrained.`
|
|
316
|
+
});
|
|
317
|
+
else if (runtimeOnly.has(name)) diagnostics.push({
|
|
318
|
+
code: "agent_schema_root_invalid",
|
|
319
|
+
path,
|
|
320
|
+
message: `${name} is a runtime/shared contract, not a stored-record root member.`
|
|
321
|
+
});
|
|
322
|
+
else if (!Object.hasOwn(schemas, name)) diagnostics.push({
|
|
323
|
+
code: "agent_schema_unverified",
|
|
324
|
+
path,
|
|
325
|
+
message: `${name} stored-record authority has no executable schema equivalence implementation.`
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
for (const name of Object.keys(schemas)) if (!runtimeOnly.has(name) && !seen.has(name)) {
|
|
330
|
+
diagnostics.push({
|
|
331
|
+
code: "agent_schema_root_missing",
|
|
332
|
+
path,
|
|
333
|
+
message: `${name} executable stored-record authority is absent from the root union.`
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
for (const [definition, executable] of executableStructures) {
|
|
338
|
+
const declared = definitions[definition];
|
|
339
|
+
const { shape, keys: actualKeys, required } = executable;
|
|
340
|
+
if (!declared || typeof declared !== "object" || executable.object && !declared.properties) {
|
|
341
|
+
diagnostics.push({ code: "agent_schema_missing", path, message: `${definition} must declare properties and required fields.` });
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
const declaredKeys = Object.keys(declared.properties ?? {}).sort();
|
|
345
|
+
const missing = actualKeys.filter((key) => !declaredKeys.includes(key));
|
|
346
|
+
const extra = declaredKeys.filter((key) => !actualKeys.includes(key));
|
|
347
|
+
if (missing.length || extra.length) diagnostics.push({
|
|
348
|
+
code: "agent_schema_fields_mismatch",
|
|
349
|
+
path,
|
|
350
|
+
message: `${definition} differs from SDK executable fields; missing: ${missing.join(", ") || "none"}; extra: ${extra.join(", ") || "none"}.`
|
|
351
|
+
});
|
|
352
|
+
const declaredRequired = [...declared.required ?? []].sort();
|
|
353
|
+
if (JSON.stringify(required) !== JSON.stringify(declaredRequired)) diagnostics.push({
|
|
354
|
+
code: "agent_schema_required_mismatch",
|
|
355
|
+
path,
|
|
356
|
+
message: `${definition} required fields differ; SDK: ${required.join(", ") || "none"}; declaration: ${declaredRequired.join(", ") || "none"}.`
|
|
357
|
+
});
|
|
358
|
+
for (const [field, specification] of Object.entries(declared.properties ?? {})) {
|
|
359
|
+
if (specification && Object.hasOwn(specification, "const") && shape[field] && !shape[field].safeParse(specification.const).success) diagnostics.push({
|
|
360
|
+
code: "agent_schema_constant_mismatch",
|
|
361
|
+
path,
|
|
362
|
+
message: `${definition}.${field} constant is rejected by the SDK validator.`
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
const expectedStructure = JSON.stringify(structuralSchema(declared, document, /* @__PURE__ */ new Set(), false, structures));
|
|
366
|
+
const actualStructure = executable.structure;
|
|
367
|
+
if (expectedStructure !== actualStructure) diagnostics.push({
|
|
368
|
+
code: "agent_schema_structure_mismatch",
|
|
369
|
+
path,
|
|
370
|
+
message: `${definition} nested declarative constraints differ from the SDK validator at ${structuralDifferences(JSON.parse(expectedStructure), JSON.parse(actualStructure)).join("; ")}.`
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
return diagnostics;
|
|
374
|
+
}
|
|
375
|
+
export {
|
|
376
|
+
verifyAgentContentSchema
|
|
377
|
+
};
|