@dsh-cc/tools 0.5.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/LICENSE +201 -0
- package/README.i18n.yaml +6 -0
- package/README.md +209 -0
- package/README.zh.md +200 -0
- package/lib/abort-utils.d.ts +80 -0
- package/lib/abort-utils.d.ts.map +1 -0
- package/lib/abort-utils.js +186 -0
- package/lib/abort-utils.js.map +1 -0
- package/lib/cc-names.d.ts +100 -0
- package/lib/cc-names.d.ts.map +1 -0
- package/lib/cc-names.js +197 -0
- package/lib/cc-names.js.map +1 -0
- package/lib/code-mode.d.ts +46 -0
- package/lib/code-mode.d.ts.map +1 -0
- package/lib/code-mode.js +380 -0
- package/lib/code-mode.js.map +1 -0
- package/lib/define-tool.d.ts +103 -0
- package/lib/define-tool.d.ts.map +1 -0
- package/lib/define-tool.js +354 -0
- package/lib/define-tool.js.map +1 -0
- package/lib/index.d.ts +348 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +289 -0
- package/lib/index.js.map +1 -0
- package/lib/invariant.d.ts +13 -0
- package/lib/invariant.d.ts.map +1 -0
- package/lib/invariant.js +123 -0
- package/lib/invariant.js.map +1 -0
- package/lib/json-render.d.ts +18 -0
- package/lib/json-render.d.ts.map +1 -0
- package/lib/json-render.js +111 -0
- package/lib/json-render.js.map +1 -0
- package/lib/json-schema-value.d.ts +18 -0
- package/lib/json-schema-value.d.ts.map +1 -0
- package/lib/json-schema-value.js +238 -0
- package/lib/json-schema-value.js.map +1 -0
- package/lib/json-schema.d.ts +101 -0
- package/lib/json-schema.d.ts.map +1 -0
- package/lib/json-schema.js +351 -0
- package/lib/json-schema.js.map +1 -0
- package/lib/presentation.d.ts +367 -0
- package/lib/presentation.d.ts.map +1 -0
- package/lib/presentation.js +8 -0
- package/lib/presentation.js.map +1 -0
- package/lib/py-names.d.ts +163 -0
- package/lib/py-names.d.ts.map +1 -0
- package/lib/py-names.js +236 -0
- package/lib/py-names.js.map +1 -0
- package/lib/py-render.d.ts +23 -0
- package/lib/py-render.d.ts.map +1 -0
- package/lib/py-render.js +434 -0
- package/lib/py-render.js.map +1 -0
- package/lib/py-sdk-doc.d.ts +29 -0
- package/lib/py-sdk-doc.d.ts.map +1 -0
- package/lib/py-sdk-doc.js +114 -0
- package/lib/py-sdk-doc.js.map +1 -0
- package/lib/py-types.d.ts +34 -0
- package/lib/py-types.d.ts.map +1 -0
- package/lib/py-types.js +40 -0
- package/lib/py-types.js.map +1 -0
- package/lib/run-code-defs.d.ts +77 -0
- package/lib/run-code-defs.d.ts.map +1 -0
- package/lib/run-code-defs.js +98 -0
- package/lib/run-code-defs.js.map +1 -0
- package/lib/runtime-code.d.ts +65 -0
- package/lib/runtime-code.d.ts.map +1 -0
- package/lib/runtime-code.js +129 -0
- package/lib/runtime-code.js.map +1 -0
- package/lib/runtime-core.d.ts +130 -0
- package/lib/runtime-core.d.ts.map +1 -0
- package/lib/runtime-core.js +33 -0
- package/lib/runtime-core.js.map +1 -0
- package/lib/runtime-execute.d.ts +82 -0
- package/lib/runtime-execute.d.ts.map +1 -0
- package/lib/runtime-execute.js +333 -0
- package/lib/runtime-execute.js.map +1 -0
- package/lib/runtime-registry.d.ts +131 -0
- package/lib/runtime-registry.d.ts.map +1 -0
- package/lib/runtime-registry.js +269 -0
- package/lib/runtime-registry.js.map +1 -0
- package/lib/runtime-results.d.ts +32 -0
- package/lib/runtime-results.d.ts.map +1 -0
- package/lib/runtime-results.js +163 -0
- package/lib/runtime-results.js.map +1 -0
- package/lib/runtime-schemas.d.ts +112 -0
- package/lib/runtime-schemas.d.ts.map +1 -0
- package/lib/runtime-schemas.js +222 -0
- package/lib/runtime-schemas.js.map +1 -0
- package/lib/scheduler.d.ts +22 -0
- package/lib/scheduler.d.ts.map +1 -0
- package/lib/scheduler.js +21 -0
- package/lib/scheduler.js.map +1 -0
- package/lib/schema-spec.d.ts +154 -0
- package/lib/schema-spec.d.ts.map +1 -0
- package/lib/schema-spec.js +9 -0
- package/lib/schema-spec.js.map +1 -0
- package/lib/schema.d.ts +5 -0
- package/lib/schema.d.ts.map +1 -0
- package/lib/schema.js +3 -0
- package/lib/schema.js.map +1 -0
- package/lib/testing.d.ts +25 -0
- package/lib/testing.d.ts.map +1 -0
- package/lib/testing.js +25 -0
- package/lib/testing.js.map +1 -0
- package/lib/tool-layer.d.ts +49 -0
- package/lib/tool-layer.d.ts.map +1 -0
- package/lib/tool-layer.js +57 -0
- package/lib/tool-layer.js.map +1 -0
- package/lib/tool-types.d.ts +385 -0
- package/lib/tool-types.d.ts.map +1 -0
- package/lib/tool-types.js +11 -0
- package/lib/tool-types.js.map +1 -0
- package/lib/ts-types.d.ts +37 -0
- package/lib/ts-types.d.ts.map +1 -0
- package/lib/ts-types.js +265 -0
- package/lib/ts-types.js.map +1 -0
- package/lib/types.d.ts +55 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +7 -0
- package/lib/types.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enforced JSON Schema subset shared by tool outputs, generated Code Mode
|
|
3
|
+
* types, subagents, and workflows. The subset accepts any JSON root, an
|
|
4
|
+
* annotation-only schema for unconstrained JSON, one scalar `type`, object
|
|
5
|
+
* `properties`/`required`/boolean `additionalProperties`, array `items`,
|
|
6
|
+
* type-correct scalar `enum`/`const`, and exact-one `oneOf`.
|
|
7
|
+
*
|
|
8
|
+
* Unsupported or misplaced keywords reject rather than being accepted without
|
|
9
|
+
* enforcement. Consumers that require an object root apply
|
|
10
|
+
* {@link assertObjectJsonSchema} before accepting input.
|
|
11
|
+
* @module dsh-tools/json-schema
|
|
12
|
+
*/
|
|
13
|
+
import { HarnessError } from '@deepseek-ai/dsh-llm';
|
|
14
|
+
import { type JsonValue } from '@deepseek-ai/dsh-session';
|
|
15
|
+
/** Scalar JSON values supported by `enum` and `const`. */
|
|
16
|
+
export type JsonSchemaScalar = string | number | boolean | null;
|
|
17
|
+
/** Single-type keywords accepted by the enforced subset. */
|
|
18
|
+
export type JsonSchemaType = 'object' | 'array' | 'string' | 'number' | 'integer' | 'boolean' | 'null';
|
|
19
|
+
/**
|
|
20
|
+
* One raw JSON Schema node in the enforced subset. The optional fields express
|
|
21
|
+
* the external wire schema; {@link assertSupportedJsonSchema} rejects invalid
|
|
22
|
+
* combinations before a caller treats the node as trusted.
|
|
23
|
+
*/
|
|
24
|
+
export interface JsonSchemaNode {
|
|
25
|
+
/** Omit with no constraints for any JSON value, or use `oneOf`. */
|
|
26
|
+
type?: JsonSchemaType;
|
|
27
|
+
/** Exactly one branch must validate; at least two branches are required. */
|
|
28
|
+
oneOf?: JsonSchemaNode[];
|
|
29
|
+
/** Nested property schemas (`type: 'object'` only). */
|
|
30
|
+
properties?: Record<string, JsonSchemaNode>;
|
|
31
|
+
/** Required property names; each must appear in `properties`. */
|
|
32
|
+
required?: string[];
|
|
33
|
+
/** `false` rejects undeclared keys; absent/`true` follows JSON Schema's open default. */
|
|
34
|
+
additionalProperties?: boolean;
|
|
35
|
+
/** Item schema (`type: 'array'` only); absent accepts any JSON item. */
|
|
36
|
+
items?: JsonSchemaNode;
|
|
37
|
+
/** Allowed values for a scalar node. */
|
|
38
|
+
enum?: JsonSchemaScalar[];
|
|
39
|
+
/** The single allowed value for a scalar node. */
|
|
40
|
+
const?: JsonSchemaScalar;
|
|
41
|
+
/** Annotation, ignored for validation. */
|
|
42
|
+
description?: string;
|
|
43
|
+
/** Annotation, ignored for validation. */
|
|
44
|
+
title?: string;
|
|
45
|
+
/** Annotation, ignored for validation but required to be lossless JSON. */
|
|
46
|
+
default?: JsonValue;
|
|
47
|
+
/** Annotation, ignored for validation but required to be lossless JSON. */
|
|
48
|
+
examples?: JsonValue;
|
|
49
|
+
}
|
|
50
|
+
/** A consumer-constrained object-rooted schema. */
|
|
51
|
+
export type ObjectJsonSchema = JsonSchemaNode & {
|
|
52
|
+
type: 'object';
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Thrown when a raw schema falls outside the enforced subset. `violations`
|
|
56
|
+
* lists every offending path instead of stopping at the first author error.
|
|
57
|
+
*/
|
|
58
|
+
export declare class JsonSchemaError extends HarnessError {
|
|
59
|
+
/** Individual schema violations in walk order. */
|
|
60
|
+
readonly violations: string[];
|
|
61
|
+
constructor(violations: string[]);
|
|
62
|
+
}
|
|
63
|
+
export declare const SCHEMA_TYPES: readonly JsonSchemaType[];
|
|
64
|
+
/**
|
|
65
|
+
* Test for a realm-agnostic plain JSON record without accepting arrays or
|
|
66
|
+
* exotic objects.
|
|
67
|
+
* @param value - candidate record from any JavaScript realm.
|
|
68
|
+
* @returns Whether the value has a plain-object prototype chain.
|
|
69
|
+
*/
|
|
70
|
+
export declare function isPlainJsonRecord(value: unknown): value is Record<string, unknown>;
|
|
71
|
+
/**
|
|
72
|
+
* Test for an ordinary schema record whose keys survive JSON projection.
|
|
73
|
+
* @param value - candidate record from any JavaScript realm.
|
|
74
|
+
* @returns Whether the record has an intrinsic prototype and only own enumerable string keys.
|
|
75
|
+
*/
|
|
76
|
+
export declare function isJsonSchemaRecord(value: unknown): value is Record<string, unknown>;
|
|
77
|
+
/**
|
|
78
|
+
* Test for a dense ordinary array with no JSON-invisible decorations.
|
|
79
|
+
* @param value - candidate array from any JavaScript realm.
|
|
80
|
+
* @returns Whether the array is intrinsic, dense, and undecorated.
|
|
81
|
+
*/
|
|
82
|
+
export declare function isPlainJsonArray(value: unknown): value is unknown[];
|
|
83
|
+
/** Lossless finite JSON number, excluding negative zero. */
|
|
84
|
+
export declare function isJsonNumber(value: unknown): value is number;
|
|
85
|
+
/**
|
|
86
|
+
* Assert that an arbitrary raw schema uses only the enforced subset.
|
|
87
|
+
* Annotation-only schemas are accepted as the standard unconstrained-JSON
|
|
88
|
+
* form; callers that require an object root use {@link assertObjectJsonSchema}.
|
|
89
|
+
* @param schema - untrusted raw JSON Schema.
|
|
90
|
+
* @returns Assertion that the schema belongs to the supported subset.
|
|
91
|
+
*/
|
|
92
|
+
export declare function assertSupportedJsonSchema(schema: unknown): asserts schema is JsonSchemaNode;
|
|
93
|
+
/**
|
|
94
|
+
* Assert the enforced subset plus the object-root constraint retained by
|
|
95
|
+
* subagent and workflow structured outputs.
|
|
96
|
+
* @param schema - untrusted caller-supplied schema.
|
|
97
|
+
* @returns Assertion that the schema belongs to the supported subset and has an object root.
|
|
98
|
+
*/
|
|
99
|
+
export declare function assertObjectJsonSchema(schema: unknown): asserts schema is ObjectJsonSchema;
|
|
100
|
+
export { validateJsonSchemaValue } from './json-schema-value.ts';
|
|
101
|
+
//# sourceMappingURL=json-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../src/json-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAe,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAEtE,0DAA0D;AAC1D,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;AAE/D,4DAA4D;AAC5D,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAA;AAKtG;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,mEAAmE;IACnE,IAAI,CAAC,EAAE,cAAc,CAAA;IACrB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,cAAc,EAAE,CAAA;IACxB,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAC3C,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,yFAAyF;IACzF,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,wEAAwE;IACxE,KAAK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sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,IAAI,gBAAgB,CAQ1F;AAED,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enforced JSON Schema subset shared by tool outputs, generated Code Mode
|
|
3
|
+
* types, subagents, and workflows. The subset accepts any JSON root, an
|
|
4
|
+
* annotation-only schema for unconstrained JSON, one scalar `type`, object
|
|
5
|
+
* `properties`/`required`/boolean `additionalProperties`, array `items`,
|
|
6
|
+
* type-correct scalar `enum`/`const`, and exact-one `oneOf`.
|
|
7
|
+
*
|
|
8
|
+
* Unsupported or misplaced keywords reject rather than being accepted without
|
|
9
|
+
* enforcement. Consumers that require an object root apply
|
|
10
|
+
* {@link assertObjectJsonSchema} before accepting input.
|
|
11
|
+
* @module dsh-tools/json-schema
|
|
12
|
+
*/
|
|
13
|
+
import { assertNever, HarnessError } from '@deepseek-ai/dsh-llm';
|
|
14
|
+
import { isJsonValue } from '@deepseek-ai/dsh-session';
|
|
15
|
+
/**
|
|
16
|
+
* Thrown when a raw schema falls outside the enforced subset. `violations`
|
|
17
|
+
* lists every offending path instead of stopping at the first author error.
|
|
18
|
+
*/
|
|
19
|
+
export class JsonSchemaError extends HarnessError {
|
|
20
|
+
/** Individual schema violations in walk order. */
|
|
21
|
+
violations;
|
|
22
|
+
constructor(violations) {
|
|
23
|
+
super(`unsupported JSON schema: ${violations.join('; ')}`, 'UNSUPPORTED_SCHEMA');
|
|
24
|
+
this.name = 'JsonSchemaError';
|
|
25
|
+
this.violations = violations;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const CONSTRAINT_KEYWORDS = new Set([
|
|
29
|
+
'type',
|
|
30
|
+
'oneOf',
|
|
31
|
+
'properties',
|
|
32
|
+
'required',
|
|
33
|
+
'additionalProperties',
|
|
34
|
+
'items',
|
|
35
|
+
'enum',
|
|
36
|
+
'const',
|
|
37
|
+
]);
|
|
38
|
+
const ANNOTATION_KEYWORDS = new Set(['description', 'title', 'default', 'examples']);
|
|
39
|
+
export const SCHEMA_TYPES = ['object', 'array', 'string', 'number', 'integer', 'boolean', 'null'];
|
|
40
|
+
/* jscpd:ignore-start -- this realm boundary mirrors the session-owned lossless-JSON intrinsic test */
|
|
41
|
+
/** Whether a realm-owned intrinsic prototype is backed by its native constructor. */
|
|
42
|
+
function hasIntrinsicConstructor(prototype, name) {
|
|
43
|
+
const descriptor = Object.getOwnPropertyDescriptor(prototype, 'constructor');
|
|
44
|
+
const constructor = descriptor?.value;
|
|
45
|
+
if (typeof constructor !== 'function')
|
|
46
|
+
return false;
|
|
47
|
+
try {
|
|
48
|
+
return constructor.name === name
|
|
49
|
+
&& constructor.prototype === prototype
|
|
50
|
+
&& Function.prototype.toString.call(constructor) === `function ${name}() { [native code] }`;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** Whether a candidate is one realm's intrinsic `Object.prototype`. */
|
|
57
|
+
function isIntrinsicObjectPrototype(value) {
|
|
58
|
+
return Object.getPrototypeOf(value) === null && hasIntrinsicConstructor(value, 'Object');
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Test for a realm-agnostic plain JSON record without accepting arrays or
|
|
62
|
+
* exotic objects.
|
|
63
|
+
* @param value - candidate record from any JavaScript realm.
|
|
64
|
+
* @returns Whether the value has a plain-object prototype chain.
|
|
65
|
+
*/
|
|
66
|
+
export function isPlainJsonRecord(value) {
|
|
67
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
68
|
+
return false;
|
|
69
|
+
try {
|
|
70
|
+
const prototype = Object.getPrototypeOf(value);
|
|
71
|
+
return prototype === null
|
|
72
|
+
|| typeof prototype === 'object' && isIntrinsicObjectPrototype(prototype);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** Whether an array uses one realm's intrinsic `Array.prototype`. */
|
|
79
|
+
function hasPlainArrayPrototype(value) {
|
|
80
|
+
const prototype = Object.getPrototypeOf(value);
|
|
81
|
+
if (!Array.isArray(prototype) || !hasIntrinsicConstructor(prototype, 'Array'))
|
|
82
|
+
return false;
|
|
83
|
+
const objectPrototype = Object.getPrototypeOf(prototype);
|
|
84
|
+
return typeof objectPrototype === 'object'
|
|
85
|
+
&& objectPrototype !== null
|
|
86
|
+
&& isIntrinsicObjectPrototype(objectPrototype);
|
|
87
|
+
}
|
|
88
|
+
/* jscpd:ignore-end */
|
|
89
|
+
/** Return whether a record contains only own enumerable string keys. */
|
|
90
|
+
function hasOnlyEnumerableStringKeys(value) {
|
|
91
|
+
try {
|
|
92
|
+
return Reflect.ownKeys(value)
|
|
93
|
+
.every(key => typeof key === 'string' && Object.prototype.propertyIsEnumerable.call(value, key));
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Test for an ordinary schema record whose keys survive JSON projection.
|
|
101
|
+
* @param value - candidate record from any JavaScript realm.
|
|
102
|
+
* @returns Whether the record has an intrinsic prototype and only own enumerable string keys.
|
|
103
|
+
*/
|
|
104
|
+
export function isJsonSchemaRecord(value) {
|
|
105
|
+
return isPlainJsonRecord(value) && hasOnlyEnumerableStringKeys(value);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Test for a dense ordinary array with no JSON-invisible decorations.
|
|
109
|
+
* @param value - candidate array from any JavaScript realm.
|
|
110
|
+
* @returns Whether the array is intrinsic, dense, and undecorated.
|
|
111
|
+
*/
|
|
112
|
+
export function isPlainJsonArray(value) {
|
|
113
|
+
if (!Array.isArray(value))
|
|
114
|
+
return false;
|
|
115
|
+
try {
|
|
116
|
+
if (!hasPlainArrayPrototype(value) || Reflect.ownKeys(value).length !== value.length + 1)
|
|
117
|
+
return false;
|
|
118
|
+
for (let index = 0; index < value.length; index++) {
|
|
119
|
+
if (!Object.hasOwn(value, index))
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/** Lossless finite JSON number, excluding negative zero. */
|
|
129
|
+
export function isJsonNumber(value) {
|
|
130
|
+
return typeof value === 'number' && Number.isFinite(value) && !Object.is(value, -0);
|
|
131
|
+
}
|
|
132
|
+
/** Whether a scalar is valid for one declared schema type. */
|
|
133
|
+
function scalarMatches(type, value) {
|
|
134
|
+
switch (type) {
|
|
135
|
+
case 'string': return typeof value === 'string';
|
|
136
|
+
case 'number': return isJsonNumber(value);
|
|
137
|
+
case 'integer': return isJsonNumber(value) && Number.isInteger(value);
|
|
138
|
+
case 'boolean': return typeof value === 'boolean';
|
|
139
|
+
case 'null': return value === null;
|
|
140
|
+
/* v8 ignore next -- JsonSchemaScalarType is closed; this retains compile-time exhaustiveness. */
|
|
141
|
+
default: return assertNever(type, 'JsonSchemaType');
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/** Keywords that are invalid beside `oneOf`. */
|
|
145
|
+
const ONE_OF_SIBLING_KEYWORDS = ['properties', 'required', 'additionalProperties', 'items', 'enum', 'const'];
|
|
146
|
+
/** Validate object-only fields after its property schemas have been visited. */
|
|
147
|
+
function checkObjectSchemaTail(node, path, properties, violations) {
|
|
148
|
+
const hasRequired = Object.hasOwn(node, 'required');
|
|
149
|
+
const required = hasRequired ? node.required : undefined;
|
|
150
|
+
if (hasRequired) {
|
|
151
|
+
if (!isPlainJsonArray(required) || required.some(entry => typeof entry !== 'string')) {
|
|
152
|
+
violations.push(`${path}.required must be an array of strings`);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
const declared = isJsonSchemaRecord(properties) ? properties : {};
|
|
156
|
+
for (const key of required) {
|
|
157
|
+
if (!Object.hasOwn(declared, key))
|
|
158
|
+
violations.push(`${path}.required names "${key}" which is not in properties`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (Object.hasOwn(node, 'additionalProperties') && typeof node.additionalProperties !== 'boolean') {
|
|
163
|
+
violations.push(`${path}.additionalProperties must be a boolean`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/** Collect every violation for one raw schema tree without using the JavaScript call stack. */
|
|
167
|
+
function checkSchemaNode(root, rootPath, violations, seen) {
|
|
168
|
+
const tasks = [{ kind: 'enter', node: root, path: rootPath }];
|
|
169
|
+
for (let task = tasks.pop(); task !== undefined; task = tasks.pop()) {
|
|
170
|
+
if (task.kind === 'leave') {
|
|
171
|
+
seen.delete(task.node);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (task.kind === 'one-of-tail') {
|
|
175
|
+
for (const key of ONE_OF_SIBLING_KEYWORDS) {
|
|
176
|
+
if (Object.hasOwn(task.node, key))
|
|
177
|
+
violations.push(`${task.path}.${key} is not supported beside oneOf`);
|
|
178
|
+
}
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (task.kind === 'object-tail') {
|
|
182
|
+
checkObjectSchemaTail(task.node, task.path, task.properties, violations);
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
const { node, path } = task;
|
|
186
|
+
if (!isJsonSchemaRecord(node)) {
|
|
187
|
+
violations.push(`${path} must be a schema object`);
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (seen.has(node)) {
|
|
191
|
+
violations.push(`${path} is circular`);
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
seen.add(node);
|
|
195
|
+
tasks.push({ kind: 'leave', node });
|
|
196
|
+
for (const key of Object.keys(node)) {
|
|
197
|
+
if (CONSTRAINT_KEYWORDS.has(key))
|
|
198
|
+
continue;
|
|
199
|
+
if (ANNOTATION_KEYWORDS.has(key)) {
|
|
200
|
+
try {
|
|
201
|
+
if (!isJsonValue(node[key]))
|
|
202
|
+
violations.push(`${path}.${key} annotation must be lossless JSON data`);
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
violations.push(`${path}.${key} annotation must be lossless JSON data`);
|
|
206
|
+
}
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
violations.push(`${path}.${key} is not a supported keyword (subset: type/oneOf/properties/required/additionalProperties/items/enum/const + annotations)`);
|
|
210
|
+
}
|
|
211
|
+
if (Object.hasOwn(node, 'description') && typeof node.description !== 'string') {
|
|
212
|
+
violations.push(`${path}.description must be a string`);
|
|
213
|
+
}
|
|
214
|
+
if (Object.hasOwn(node, 'title') && typeof node.title !== 'string') {
|
|
215
|
+
violations.push(`${path}.title must be a string`);
|
|
216
|
+
}
|
|
217
|
+
const hasType = Object.hasOwn(node, 'type');
|
|
218
|
+
const hasOneOf = Object.hasOwn(node, 'oneOf');
|
|
219
|
+
if (hasType && hasOneOf) {
|
|
220
|
+
violations.push(`${path} cannot declare both type and oneOf`);
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (!hasType && !hasOneOf) {
|
|
224
|
+
for (const key of ONE_OF_SIBLING_KEYWORDS) {
|
|
225
|
+
if (Object.hasOwn(node, key))
|
|
226
|
+
violations.push(`${path}.${key} requires type or oneOf`);
|
|
227
|
+
}
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
if (hasOneOf) {
|
|
231
|
+
const oneOf = node.oneOf;
|
|
232
|
+
tasks.push({ kind: 'one-of-tail', node, path });
|
|
233
|
+
if (!isPlainJsonArray(oneOf) || oneOf.length < 2) {
|
|
234
|
+
violations.push(`${path}.oneOf must be an array of at least two schemas`);
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
for (let index = oneOf.length - 1; index >= 0; index--) {
|
|
238
|
+
tasks.push({ kind: 'enter', node: oneOf[index], path: `${path}.oneOf[${index}]` });
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
const type = node.type;
|
|
244
|
+
if (typeof type !== 'string' || !SCHEMA_TYPES.includes(type)) {
|
|
245
|
+
violations.push(Array.isArray(type)
|
|
246
|
+
? `${path}.type must be a single type string (type arrays are not supported)`
|
|
247
|
+
: `${path}.type must be one of ${SCHEMA_TYPES.join('/')}`);
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
const schemaType = type;
|
|
251
|
+
const allowedFor = {
|
|
252
|
+
properties: ['object'],
|
|
253
|
+
required: ['object'],
|
|
254
|
+
additionalProperties: ['object'],
|
|
255
|
+
items: ['array'],
|
|
256
|
+
enum: ['string', 'number', 'integer', 'boolean', 'null'],
|
|
257
|
+
const: ['string', 'number', 'integer', 'boolean', 'null'],
|
|
258
|
+
};
|
|
259
|
+
for (const [key, types] of Object.entries(allowedFor)) {
|
|
260
|
+
if (Object.hasOwn(node, key) && !types.includes(schemaType)) {
|
|
261
|
+
violations.push(`${path}.${key} is not supported on type "${schemaType}"`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
switch (schemaType) {
|
|
265
|
+
case 'object': {
|
|
266
|
+
const properties = Object.hasOwn(node, 'properties') ? node.properties : undefined;
|
|
267
|
+
tasks.push({ kind: 'object-tail', node, path, properties });
|
|
268
|
+
if (Object.hasOwn(node, 'properties')) {
|
|
269
|
+
if (!isJsonSchemaRecord(properties)) {
|
|
270
|
+
violations.push(`${path}.properties must be an object of schemas`);
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
const entries = Object.entries(properties);
|
|
274
|
+
for (let index = entries.length - 1; index >= 0; index--) {
|
|
275
|
+
const entry = entries[index];
|
|
276
|
+
/* v8 ignore next -- the loop is bounded by the captured entry count. */
|
|
277
|
+
if (entry === undefined)
|
|
278
|
+
continue;
|
|
279
|
+
tasks.push({ kind: 'enter', node: entry[1], path: `${path}.properties.${entry[0]}` });
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
case 'array': {
|
|
286
|
+
if (Object.hasOwn(node, 'items'))
|
|
287
|
+
tasks.push({ kind: 'enter', node: node.items, path: `${path}.items` });
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
case 'string':
|
|
291
|
+
case 'number':
|
|
292
|
+
case 'integer':
|
|
293
|
+
case 'boolean':
|
|
294
|
+
case 'null': {
|
|
295
|
+
const hasEnum = Object.hasOwn(node, 'enum');
|
|
296
|
+
const allowed = hasEnum ? node.enum : undefined;
|
|
297
|
+
const enumValid = isPlainJsonArray(allowed)
|
|
298
|
+
&& allowed.length > 0
|
|
299
|
+
&& allowed.every(entry => scalarMatches(schemaType, entry));
|
|
300
|
+
if (hasEnum && !enumValid) {
|
|
301
|
+
violations.push(`${path}.enum must be a non-empty array of ${schemaType} values`);
|
|
302
|
+
}
|
|
303
|
+
const hasConst = Object.hasOwn(node, 'const');
|
|
304
|
+
const declaredConst = hasConst ? node.const : undefined;
|
|
305
|
+
const constValid = scalarMatches(schemaType, declaredConst);
|
|
306
|
+
if (hasConst) {
|
|
307
|
+
if (!constValid) {
|
|
308
|
+
violations.push(`${path}.const must be a ${schemaType} value`);
|
|
309
|
+
}
|
|
310
|
+
else if (enumValid && !allowed.includes(declaredConst)) {
|
|
311
|
+
violations.push(`${path}.const must be one of ${path}.enum when both are declared`);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
/* v8 ignore next -- schemaType was narrowed from the closed SCHEMA_TYPES table above. */
|
|
317
|
+
default: assertNever(schemaType, 'JsonSchemaType');
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Assert that an arbitrary raw schema uses only the enforced subset.
|
|
323
|
+
* Annotation-only schemas are accepted as the standard unconstrained-JSON
|
|
324
|
+
* form; callers that require an object root use {@link assertObjectJsonSchema}.
|
|
325
|
+
* @param schema - untrusted raw JSON Schema.
|
|
326
|
+
* @returns Assertion that the schema belongs to the supported subset.
|
|
327
|
+
*/
|
|
328
|
+
export function assertSupportedJsonSchema(schema) {
|
|
329
|
+
const violations = [];
|
|
330
|
+
checkSchemaNode(schema, 'schema', violations, new Set());
|
|
331
|
+
if (violations.length > 0)
|
|
332
|
+
throw new JsonSchemaError(violations);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Assert the enforced subset plus the object-root constraint retained by
|
|
336
|
+
* subagent and workflow structured outputs.
|
|
337
|
+
* @param schema - untrusted caller-supplied schema.
|
|
338
|
+
* @returns Assertion that the schema belongs to the supported subset and has an object root.
|
|
339
|
+
*/
|
|
340
|
+
export function assertObjectJsonSchema(schema) {
|
|
341
|
+
const violations = [];
|
|
342
|
+
checkSchemaNode(schema, 'schema', violations, new Set());
|
|
343
|
+
if (violations.length === 0
|
|
344
|
+
&& (!isJsonSchemaRecord(schema) || !Object.hasOwn(schema, 'type') || schema.type !== 'object')) {
|
|
345
|
+
violations.push('schema.type must be "object" (structured output is object-rooted)');
|
|
346
|
+
}
|
|
347
|
+
if (violations.length > 0)
|
|
348
|
+
throw new JsonSchemaError(violations);
|
|
349
|
+
}
|
|
350
|
+
export { validateJsonSchemaValue } from "./json-schema-value.js";
|
|
351
|
+
//# sourceMappingURL=json-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema.js","sourceRoot":"","sources":["../src/json-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,WAAW,EAAkB,MAAM,0BAA0B,CAAA;AA8CtE;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,YAAY;IAC/C,kDAAkD;IACzC,UAAU,CAAU;IAE7B,YAAY,UAAoB;QAC9B,KAAK,CAAC,4BAA4B,UAAU,CA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