@aeye/schema 0.9.0 → 0.10.1
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 +674 -674
- package/README.md +60 -60
- package/aeye-schema.md +529 -501
- package/dist/index.d.ts +68 -1
- package/dist/index.js +164 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -190,6 +190,12 @@ interface Profile {
|
|
|
190
190
|
readonly patternProperties: boolean;
|
|
191
191
|
/** Named types may go to `$defs` and be used by `$ref`. Off → inlined. */
|
|
192
192
|
readonly defs: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Whether a `$ref` may carry a description, title or examples beside it. `false` (OpenAI strict: "$ref cannot have
|
|
195
|
+
* keywords {'description'}", which fails the whole request) → the ref is wrapped, `{ anyOf: [{ $ref }], description }`,
|
|
196
|
+
* so the field keeps its words. Unset means allowed.
|
|
197
|
+
*/
|
|
198
|
+
readonly refSiblings?: boolean;
|
|
193
199
|
/**
|
|
194
200
|
* Whether a `$ref` may point back into itself:
|
|
195
201
|
* - `true`: anywhere;
|
|
@@ -2132,6 +2138,67 @@ declare function profileFor(model: ModelLike, opts?: {
|
|
|
2132
2138
|
speaks?: ReadonlySet<string>;
|
|
2133
2139
|
}): ModelProfile;
|
|
2134
2140
|
|
|
2141
|
+
/** What a deferred value is written with, once the request is planned. */
|
|
2142
|
+
interface DeferredSpec {
|
|
2143
|
+
/** The tool of the request whose arguments it is (or a part of, with `path`). */
|
|
2144
|
+
readonly tool?: string;
|
|
2145
|
+
/** The request's structured output instead of a tool. */
|
|
2146
|
+
readonly output?: boolean;
|
|
2147
|
+
/** The value, in the code shape (ignored for `type`). */
|
|
2148
|
+
readonly value?: unknown;
|
|
2149
|
+
/** A part: the value sits at this code path of the schema (`limits`, `rows.*.tags`). */
|
|
2150
|
+
readonly path?: string | readonly PathSeg[];
|
|
2151
|
+
/** Indent the JSON (`true` = 2 spaces). */
|
|
2152
|
+
readonly pretty?: boolean | number;
|
|
2153
|
+
/** Write the schema itself as TypeScript-like text (`{{schema}}`) instead of a value. */
|
|
2154
|
+
readonly type?: boolean;
|
|
2155
|
+
/**
|
|
2156
|
+
* For a tool the request may not have (one offered in a later step): its schema as lenient JSON Schema. When the
|
|
2157
|
+
* request has no tool of that name, the value is written as that schema would be, planned alone for the request's
|
|
2158
|
+
* model (with `strict`); without it the value is written in the code shape.
|
|
2159
|
+
*/
|
|
2160
|
+
readonly schema?: JsonSchema;
|
|
2161
|
+
/** The strictness the tool would be asked with (`schema` only). Default `1`. */
|
|
2162
|
+
readonly strict?: Strictness;
|
|
2163
|
+
/**
|
|
2164
|
+
* Show only this part of what was written (a dotted path in the WIRE value): the whole value is written, then the
|
|
2165
|
+
* part picked, e.g. a dispatcher-like tool's `args` as it writes them for the one it names (`{ fn, args }`, pick
|
|
2166
|
+
* `args`). Unlike `path`, the part is written as the whole value has it.
|
|
2167
|
+
*/
|
|
2168
|
+
readonly pick?: string;
|
|
2169
|
+
/** What to show when the plan can't write it (no such tool, no plan, a value that doesn't fit): else the code shape. */
|
|
2170
|
+
readonly fallback?: string;
|
|
2171
|
+
}
|
|
2172
|
+
/** One deferred value, captured whole: `text.split(DEFERRED_SPAN)` gives the text around them at even indexes and the values at odd ones. */
|
|
2173
|
+
declare const DEFERRED_SPAN: RegExp;
|
|
2174
|
+
/** The text of a deferred value: the spec, to be written through the request's plan. */
|
|
2175
|
+
declare function deferEncode(spec: DeferredSpec): string;
|
|
2176
|
+
/** The text of a deferred `{{schema}}`: the schema of a tool (or the output) as TypeScript-like text. */
|
|
2177
|
+
declare function deferSchema(spec: Pick<DeferredSpec, 'tool' | 'output' | 'schema' | 'strict'>): string;
|
|
2178
|
+
/** Whether a text holds any deferred value. */
|
|
2179
|
+
declare function hasDeferred(text: string): boolean;
|
|
2180
|
+
/** How `fillDeferred` treats what isn't in the plan. */
|
|
2181
|
+
interface FillOptions {
|
|
2182
|
+
/** A bound schema for a lenient JSON Schema a deferred value carries (default: `a.fromJSONSchema`, kept by JSON). */
|
|
2183
|
+
readonly schemaOf?: (schema: JsonSchema) => Bound<unknown>;
|
|
2184
|
+
}
|
|
2185
|
+
/**
|
|
2186
|
+
* Write every deferred value of a text through a request's plan: as the model writes that tool's arguments (or the
|
|
2187
|
+
* output), a part of them with `path`; a tool the plan doesn't have through the schema the value carries, planned
|
|
2188
|
+
* alone for the plan's model, else in the code shape. Without a plan, the code shape (`plainDeferred`). Text with no
|
|
2189
|
+
* deferred value comes back as it is.
|
|
2190
|
+
*/
|
|
2191
|
+
declare function fillDeferred(text: string, plan: RenderedRequest<any> | undefined, opts?: FillOptions): string;
|
|
2192
|
+
/** A text with each deferred value in the code shape: for estimates, logs and people, before a plan exists. */
|
|
2193
|
+
declare function plainDeferred(text: string): string;
|
|
2194
|
+
/**
|
|
2195
|
+
* A stand-in for a request's plan whose encoders write deferred values: render a request's templates for it (core's
|
|
2196
|
+
* `deferRequest`) and the text carries each value to be written once the request is planned where it is sent. `known`
|
|
2197
|
+
* supplies schemas a template may name that the request doesn't have (a tool offered in a later step): their deferred
|
|
2198
|
+
* values carry the schema. `wire` (a JSON value, not text) can't be deferred: it gives the code shape.
|
|
2199
|
+
*/
|
|
2200
|
+
declare function deferredRequest(plan: RenderedRequest<any>, known?: (name: string) => Bound<any> | undefined): RenderedRequest;
|
|
2201
|
+
|
|
2135
2202
|
/**
|
|
2136
2203
|
* Runtime errors of `@aeye/schema`. Model mistakes are never thrown: `parse`
|
|
2137
2204
|
* returns them as `Issue`s for a re-prompt. These are for the code's own
|
|
@@ -2388,4 +2455,4 @@ declare function ginNamedTypes<T extends Record<string, unknown> = {}>(registry:
|
|
|
2388
2455
|
readonly [K in keyof T]: SchemaOf<T[K]>;
|
|
2389
2456
|
} & Record<string, AnySchema>;
|
|
2390
2457
|
|
|
2391
|
-
export { ANTHROPIC_NON_STRICT, ANTHROPIC_STRICT, type Adjustment, type AllowRefs, type AnySchema, AnyType, ArrayType, type Audience, type Bindable, BooleanType, Bound, type Brand, Bundle, type Check, CodecType, Compiler, ConditionalType, type ConstraintSupport, type CopyStats, Cx, DEFAULT_ERROR_FORMAT, DEFAULT_JSON_INSTRUCTION, type DecodedCall, DefTarget, DefaultType, type Defs, DependentType, type DispatchCase, DispatchType, type DynamicDefs, DynamicModule, type DynamicOptions, type EncodeTextOptions, type Encoder, EnumType, type EnvOf, type ErrorDetail, type ErrorFormat, type ErrorFormatInput, FAILED, GIN_BUILTINS, GOOGLE_NON_STRICT, GOOGLE_OPENAPI, GOOGLE_STRICT, type GinRegistryLike, type GinSchema, type GinTypeDef, type Helper, type HelperOptions, type HelperSet, INLINE_BUDGET, type ImportReport, InlineBudgetExceeded, IntersectionType, type Issue, type IssueKind, type ItemName, type ItemOut, type JsonSchema, type JsonValue, LENIENT, type LimitName, LiteralType, type LiteralValue, type Loose, MINIMAL, type Merge, type Meta, type Missing, type ModelLike, ModelProfile, Module, NeverType, Node, type NodeImpl, NotType, NullType, NullableType, type NumberOptions, NumberType, OLLAMA, OPENAI_FINETUNED_STRICT, OPENAI_NON_STRICT, OPENAI_STRICT, type ObjectExtras, type ObjectOut, type ObjectRestOut, ObjectType, OptionalType, type OutOf, type OutputItem, PEOPLE, type ParseOptions, type ParseResult, type PathSeg, Printer, type Profile, type ProfileAdjustment, type ProfileFamily, RecordType, type RefFree, type RefMarker, RefType, type RefsOf, Rejection, Rendered, RenderedRequest, RequestEntry, type RequestItem, RequestLimitError, type RequestLimits, type RequestOptions, type RequestSchema, type Resolve, type ResolvedErrorFormat, type ResultOut, type RuleIssue, SCHEMA_DATA_KEY, Schema, SchemaDefinitionError, type SchemaError, type SchemaKind, type SchemaLimits, type SchemaMeasure, type SchemaOf, SchemaParseError, type SchemaTarget, type Shape, type ShapeRefs, type Simplify, type Strictness, type StringOptions, StringType, type Text, type ToolItem, TupleType, UnionType, type View, XAI_NON_STRICT, XAI_STRICT, ZERO_MEASURE, a, addMeasures, brokenLimits, didYouMean, editDistance, errorFormat, familyOf, familyProfile, formatErrors, formatIssues, formatPath, fromGin, fromJSONSchema, getProfile, ginNamedTypes, isBasicPattern, isNever, issueKind, measureJson, mergeErrorFormats, modelPath, nearest, newStats, overLimits, planRequest, profileFor, rankNear, readJsonText, registerProfile, registerSchemaHelpers, schemaData, schemaHelpers, shortType, staticBundle, strictPriority, suggestionBudget, suggestionFor, variant, viewOf };
|
|
2458
|
+
export { ANTHROPIC_NON_STRICT, ANTHROPIC_STRICT, type Adjustment, type AllowRefs, type AnySchema, AnyType, ArrayType, type Audience, type Bindable, BooleanType, Bound, type Brand, Bundle, type Check, CodecType, Compiler, ConditionalType, type ConstraintSupport, type CopyStats, Cx, DEFAULT_ERROR_FORMAT, DEFAULT_JSON_INSTRUCTION, DEFERRED_SPAN, type DecodedCall, DefTarget, DefaultType, type DeferredSpec, type Defs, DependentType, type DispatchCase, DispatchType, type DynamicDefs, DynamicModule, type DynamicOptions, type EncodeTextOptions, type Encoder, EnumType, type EnvOf, type ErrorDetail, type ErrorFormat, type ErrorFormatInput, FAILED, type FillOptions, GIN_BUILTINS, GOOGLE_NON_STRICT, GOOGLE_OPENAPI, GOOGLE_STRICT, type GinRegistryLike, type GinSchema, type GinTypeDef, type Helper, type HelperOptions, type HelperSet, INLINE_BUDGET, type ImportReport, InlineBudgetExceeded, IntersectionType, type Issue, type IssueKind, type ItemName, type ItemOut, type JsonSchema, type JsonValue, LENIENT, type LimitName, LiteralType, type LiteralValue, type Loose, MINIMAL, type Merge, type Meta, type Missing, type ModelLike, ModelProfile, Module, NeverType, Node, type NodeImpl, NotType, NullType, NullableType, type NumberOptions, NumberType, OLLAMA, OPENAI_FINETUNED_STRICT, OPENAI_NON_STRICT, OPENAI_STRICT, type ObjectExtras, type ObjectOut, type ObjectRestOut, ObjectType, OptionalType, type OutOf, type OutputItem, PEOPLE, type ParseOptions, type ParseResult, type PathSeg, Printer, type Profile, type ProfileAdjustment, type ProfileFamily, RecordType, type RefFree, type RefMarker, RefType, type RefsOf, Rejection, Rendered, RenderedRequest, RequestEntry, type RequestItem, RequestLimitError, type RequestLimits, type RequestOptions, type RequestSchema, type Resolve, type ResolvedErrorFormat, type ResultOut, type RuleIssue, SCHEMA_DATA_KEY, Schema, SchemaDefinitionError, type SchemaError, type SchemaKind, type SchemaLimits, type SchemaMeasure, type SchemaOf, SchemaParseError, type SchemaTarget, type Shape, type ShapeRefs, type Simplify, type Strictness, type StringOptions, StringType, type Text, type ToolItem, TupleType, UnionType, type View, XAI_NON_STRICT, XAI_STRICT, ZERO_MEASURE, a, addMeasures, brokenLimits, deferEncode, deferSchema, deferredRequest, didYouMean, editDistance, errorFormat, familyOf, familyProfile, fillDeferred, formatErrors, formatIssues, formatPath, fromGin, fromJSONSchema, getProfile, ginNamedTypes, hasDeferred, isBasicPattern, isNever, issueKind, measureJson, mergeErrorFormats, modelPath, nearest, newStats, overLimits, plainDeferred, planRequest, profileFor, rankNear, readJsonText, registerProfile, registerSchemaHelpers, schemaData, schemaHelpers, shortType, staticBundle, strictPriority, suggestionBudget, suggestionFor, variant, viewOf };
|
package/dist/index.js
CHANGED
|
@@ -90,6 +90,7 @@ var OPENAI_STRICT = Object.freeze({
|
|
|
90
90
|
conditionals: false,
|
|
91
91
|
patternProperties: false,
|
|
92
92
|
defs: true,
|
|
93
|
+
refSiblings: false,
|
|
93
94
|
recursion: true,
|
|
94
95
|
// OpenAI's own "any" would be a recursive $defs/Any with pairs, which can't
|
|
95
96
|
// be told apart from a real list of {key, value}; JSON text is exact.
|
|
@@ -1703,6 +1704,10 @@ var Compiler = class {
|
|
|
1703
1704
|
parts.push(`Example${examples.length > 1 ? "s" : ""}: ${examples.map((e) => JSON.stringify(e)).join(" ; ")}`);
|
|
1704
1705
|
}
|
|
1705
1706
|
if (parts.length) out.description = parts.join("\n");
|
|
1707
|
+
if (this.profile.refSiblings === false && typeof out.$ref === "string" && (out.description !== void 0 || out.title !== void 0 || out.examples !== void 0)) {
|
|
1708
|
+
const { $ref, ...annotations } = out;
|
|
1709
|
+
return { anyOf: [{ $ref }], ...annotations };
|
|
1710
|
+
}
|
|
1706
1711
|
return out;
|
|
1707
1712
|
}
|
|
1708
1713
|
/** An example is typed in the code shape; one that doesn't fit is a definition mistake, reported once. */
|
|
@@ -3910,13 +3915,14 @@ function fromJSONSchema(schema, report = { unsupported: [] }) {
|
|
|
3910
3915
|
const required = new Set(j.required ?? []);
|
|
3911
3916
|
const ap = j.additionalProperties;
|
|
3912
3917
|
const pp = j.patternProperties;
|
|
3913
|
-
if (!Object.keys(props).length && !pp && ap !== void 0 && ap !== false
|
|
3918
|
+
if (!Object.keys(props).length && !pp && ap !== void 0 && ap !== false) return new RecordType(ap === true ? new AnyType() : conv(ap));
|
|
3914
3919
|
const shape = {};
|
|
3915
3920
|
for (const [k, p] of Object.entries(props)) shape[k] = required.has(k) ? conv(p) : new OptionalType(conv(p));
|
|
3916
3921
|
for (const k of required) if (!(k in shape)) shape[k] = new AnyType();
|
|
3917
3922
|
let o = new ObjectType(shape);
|
|
3918
3923
|
if (pp) o = o.patterns(Object.fromEntries(Object.entries(pp).map(([p, v]) => [p, conv(v)])));
|
|
3919
|
-
if (ap
|
|
3924
|
+
if (ap === true) o = o.rest(new AnyType());
|
|
3925
|
+
else if (ap !== void 0 && typeof ap === "object") o = o.rest(conv(ap));
|
|
3920
3926
|
return ap === false ? o.strict() : o;
|
|
3921
3927
|
}
|
|
3922
3928
|
}
|
|
@@ -4560,6 +4566,155 @@ function profileFor(model, opts = {}) {
|
|
|
4560
4566
|
return new ModelProfile(tool, output, delivery);
|
|
4561
4567
|
}
|
|
4562
4568
|
|
|
4569
|
+
// src/deferred.ts
|
|
4570
|
+
var OPEN = "\u27E6";
|
|
4571
|
+
var CLOSE = "\u27E7";
|
|
4572
|
+
var PATTERN = /⟦(encode|schema) (\{[^⟧]*\})⟧/g;
|
|
4573
|
+
var DEFERRED_SPAN = /(⟦(?:encode|schema) \{[^⟧]*\}⟧)/;
|
|
4574
|
+
function deferEncode(spec) {
|
|
4575
|
+
const { type, ...rest } = spec;
|
|
4576
|
+
return `${OPEN}${type ? "schema" : "encode"} ${JSON.stringify(rest).replace(/⟧/g, "\\u27e7")}${CLOSE}`;
|
|
4577
|
+
}
|
|
4578
|
+
function deferSchema(spec) {
|
|
4579
|
+
return deferEncode({ ...spec, type: true });
|
|
4580
|
+
}
|
|
4581
|
+
function hasDeferred(text) {
|
|
4582
|
+
return text.includes(`${OPEN}encode `) || text.includes(`${OPEN}schema `);
|
|
4583
|
+
}
|
|
4584
|
+
var rebuilt = /* @__PURE__ */ new Map();
|
|
4585
|
+
var REBUILT_MAX = 32;
|
|
4586
|
+
function defaultSchemaOf(schema) {
|
|
4587
|
+
const key = JSON.stringify(schema);
|
|
4588
|
+
const known = rebuilt.get(key);
|
|
4589
|
+
if (known) {
|
|
4590
|
+
rebuilt.delete(key);
|
|
4591
|
+
rebuilt.set(key, known);
|
|
4592
|
+
return known;
|
|
4593
|
+
}
|
|
4594
|
+
const made = fromJSONSchema(schema).bind();
|
|
4595
|
+
rebuilt.set(key, made);
|
|
4596
|
+
while (rebuilt.size > REBUILT_MAX) rebuilt.delete(rebuilt.keys().next().value);
|
|
4597
|
+
return made;
|
|
4598
|
+
}
|
|
4599
|
+
function indentOf(pretty) {
|
|
4600
|
+
return pretty === true ? 2 : typeof pretty === "number" ? pretty : void 0;
|
|
4601
|
+
}
|
|
4602
|
+
function codeShape(spec) {
|
|
4603
|
+
if (spec.fallback !== void 0) return spec.fallback;
|
|
4604
|
+
if (spec.type) return "unknown";
|
|
4605
|
+
const shown = spec.pick === void 0 ? spec.value : pickAt(spec.value, spec.pick);
|
|
4606
|
+
return JSON.stringify(shown, null, indentOf(spec.pretty)) ?? "null";
|
|
4607
|
+
}
|
|
4608
|
+
function pickAt(value, path) {
|
|
4609
|
+
return path.split(".").reduce((at, key) => typeof at === "object" && at !== null ? at[key] : void 0, value);
|
|
4610
|
+
}
|
|
4611
|
+
function entryFor(spec, plan, opts) {
|
|
4612
|
+
if (!plan) return void 0;
|
|
4613
|
+
if (spec.output) return plan.output;
|
|
4614
|
+
if (spec.tool === void 0) return void 0;
|
|
4615
|
+
if (plan.has(spec.tool)) return plan.get(spec.tool);
|
|
4616
|
+
if (!spec.schema) return void 0;
|
|
4617
|
+
const bound = (opts.schemaOf ?? defaultSchemaOf)(spec.schema);
|
|
4618
|
+
return plan.target.request([{ kind: "tool", name: spec.tool, schema: bound, strict: spec.strict ?? 1 }]).get(spec.tool);
|
|
4619
|
+
}
|
|
4620
|
+
function sameJson(x, y) {
|
|
4621
|
+
if (x === y) return true;
|
|
4622
|
+
if (typeof x !== "object" || typeof y !== "object" || x === null || y === null) return false;
|
|
4623
|
+
if (Array.isArray(x) !== Array.isArray(y)) return false;
|
|
4624
|
+
if (Array.isArray(x)) return x.length === y.length && x.every((item, i) => sameJson(item, y[i]));
|
|
4625
|
+
const xs = Object.entries(x).filter(([, v]) => v !== void 0);
|
|
4626
|
+
const ys = Object.entries(y).filter(([, v]) => v !== void 0);
|
|
4627
|
+
return xs.length === ys.length && xs.every(([key, v]) => sameJson(v, y[key]));
|
|
4628
|
+
}
|
|
4629
|
+
function fillOne(spec, plan, opts) {
|
|
4630
|
+
const entry = entryFor(spec, plan, opts);
|
|
4631
|
+
if (!entry) return codeShape(spec);
|
|
4632
|
+
try {
|
|
4633
|
+
if (spec.type) return entry.rendered.typescript();
|
|
4634
|
+
const textOpts = {};
|
|
4635
|
+
if (spec.pretty !== void 0) textOpts.pretty = spec.pretty;
|
|
4636
|
+
if (spec.path !== void 0) textOpts.path = spec.path;
|
|
4637
|
+
const text = spec.pick === void 0 ? entry.encodeText(spec.value, textOpts) : entry.encodeText(spec.value);
|
|
4638
|
+
if (spec.path === void 0) {
|
|
4639
|
+
const back = entry.parseText(text, { repair: false });
|
|
4640
|
+
if (!back.ok || !sameJson(back.value, spec.value)) return codeShape(spec);
|
|
4641
|
+
}
|
|
4642
|
+
if (spec.pick === void 0) return text;
|
|
4643
|
+
return JSON.stringify(pickAt(JSON.parse(text), spec.pick), null, indentOf(spec.pretty)) ?? "null";
|
|
4644
|
+
} catch {
|
|
4645
|
+
return codeShape(spec);
|
|
4646
|
+
}
|
|
4647
|
+
}
|
|
4648
|
+
function fillDeferred(text, plan, opts = {}) {
|
|
4649
|
+
if (!hasDeferred(text)) return text;
|
|
4650
|
+
return text.replace(PATTERN, (whole, kind2, json2) => {
|
|
4651
|
+
let spec;
|
|
4652
|
+
try {
|
|
4653
|
+
spec = JSON.parse(json2);
|
|
4654
|
+
} catch {
|
|
4655
|
+
return whole;
|
|
4656
|
+
}
|
|
4657
|
+
return fillOne(kind2 === "schema" ? { ...spec, type: true } : spec, plan, opts);
|
|
4658
|
+
});
|
|
4659
|
+
}
|
|
4660
|
+
function plainDeferred(text) {
|
|
4661
|
+
return fillDeferred(text, void 0);
|
|
4662
|
+
}
|
|
4663
|
+
function deferredRequest(plan, known) {
|
|
4664
|
+
const entries = /* @__PURE__ */ new Map();
|
|
4665
|
+
const entryOf = (name, output) => {
|
|
4666
|
+
const key = output ? "\0output" : name;
|
|
4667
|
+
const kept = entries.get(key);
|
|
4668
|
+
if (kept) return kept;
|
|
4669
|
+
const extra = !output && !plan.has(name) ? known?.(name) : void 0;
|
|
4670
|
+
const base = output ? { output: true } : extra ? { tool: name, schema: extra.render(LENIENT).jsonSchema } : { tool: name };
|
|
4671
|
+
const lenient = output ? plan.output?.rendered : plan.has(name) ? plan.get(name).rendered : extra?.render(LENIENT);
|
|
4672
|
+
const encodeText = (value, opts = {}) => deferEncode({
|
|
4673
|
+
...base,
|
|
4674
|
+
value,
|
|
4675
|
+
...opts.path !== void 0 ? { path: opts.path } : {},
|
|
4676
|
+
...opts.pretty !== void 0 ? { pretty: opts.pretty } : {}
|
|
4677
|
+
});
|
|
4678
|
+
const encoder = ((value, opts) => encodeText(value, opts));
|
|
4679
|
+
encoder.wire = (value, path) => lenient ? path === void 0 ? lenient.encode(value) : lenient.encodeAt(value, path) : value;
|
|
4680
|
+
const made = {
|
|
4681
|
+
name,
|
|
4682
|
+
kind: output ? "output" : "tool",
|
|
4683
|
+
rendered: { encodeText, typescript: () => deferSchema(base) },
|
|
4684
|
+
encoder: Object.freeze(encoder),
|
|
4685
|
+
encodeText,
|
|
4686
|
+
encode: (value) => encoder.wire(value)
|
|
4687
|
+
};
|
|
4688
|
+
entries.set(key, made);
|
|
4689
|
+
return made;
|
|
4690
|
+
};
|
|
4691
|
+
const target = {
|
|
4692
|
+
target: plan.target,
|
|
4693
|
+
entries: plan.entries,
|
|
4694
|
+
degradations: plan.degradations,
|
|
4695
|
+
dispatcher: plan.dispatcher,
|
|
4696
|
+
get tools() {
|
|
4697
|
+
return plan.tools;
|
|
4698
|
+
},
|
|
4699
|
+
get sent() {
|
|
4700
|
+
return plan.sent;
|
|
4701
|
+
},
|
|
4702
|
+
get output() {
|
|
4703
|
+
return plan.output ? entryOf(plan.output.name, true) : void 0;
|
|
4704
|
+
},
|
|
4705
|
+
has: (name) => plan.has(name) || known?.(name) !== void 0,
|
|
4706
|
+
get: (name) => {
|
|
4707
|
+
if (plan.output && name === plan.output.name) return entryOf(name, true);
|
|
4708
|
+
if (!plan.has(name) && known?.(name) === void 0) throw new Error(`@aeye/schema: no schema named "${name}" in this request.`);
|
|
4709
|
+
return entryOf(name, false);
|
|
4710
|
+
},
|
|
4711
|
+
decodeCall: plan.decodeCall.bind(plan),
|
|
4712
|
+
encodeCall: plan.encodeCall.bind(plan),
|
|
4713
|
+
helpers: plan.helpers.bind(plan)
|
|
4714
|
+
};
|
|
4715
|
+
return target;
|
|
4716
|
+
}
|
|
4717
|
+
|
|
4563
4718
|
// src/gin/from-gin.ts
|
|
4564
4719
|
var GIN_BUILTINS = /* @__PURE__ */ new Set([
|
|
4565
4720
|
"text",
|
|
@@ -4742,6 +4897,7 @@ export {
|
|
|
4742
4897
|
Cx,
|
|
4743
4898
|
DEFAULT_ERROR_FORMAT,
|
|
4744
4899
|
DEFAULT_JSON_INSTRUCTION,
|
|
4900
|
+
DEFERRED_SPAN,
|
|
4745
4901
|
DefTarget,
|
|
4746
4902
|
DefaultType,
|
|
4747
4903
|
DependentType,
|
|
@@ -4795,11 +4951,15 @@ export {
|
|
|
4795
4951
|
a_exports as a,
|
|
4796
4952
|
addMeasures,
|
|
4797
4953
|
brokenLimits,
|
|
4954
|
+
deferEncode,
|
|
4955
|
+
deferSchema,
|
|
4956
|
+
deferredRequest,
|
|
4798
4957
|
didYouMean,
|
|
4799
4958
|
editDistance,
|
|
4800
4959
|
errorFormat,
|
|
4801
4960
|
familyOf,
|
|
4802
4961
|
familyProfile,
|
|
4962
|
+
fillDeferred,
|
|
4803
4963
|
formatErrors,
|
|
4804
4964
|
formatIssues,
|
|
4805
4965
|
formatPath,
|
|
@@ -4807,6 +4967,7 @@ export {
|
|
|
4807
4967
|
fromJSONSchema,
|
|
4808
4968
|
getProfile,
|
|
4809
4969
|
ginNamedTypes,
|
|
4970
|
+
hasDeferred,
|
|
4810
4971
|
isBasicPattern,
|
|
4811
4972
|
isNever,
|
|
4812
4973
|
issueKind,
|
|
@@ -4816,6 +4977,7 @@ export {
|
|
|
4816
4977
|
nearest,
|
|
4817
4978
|
newStats,
|
|
4818
4979
|
overLimits,
|
|
4980
|
+
plainDeferred,
|
|
4819
4981
|
planRequest,
|
|
4820
4982
|
profileFor,
|
|
4821
4983
|
rankNear,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeye/schema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "@aeye/schema - LLM-first schema builder: named and dynamic types, per-model rendering, request-wide budgets, copy-light decoding",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"author": "ClickerMonkey",
|
|
58
58
|
"dependencies": {},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@aeye/gin": "0.
|
|
61
|
-
"@aeye/query": "0.
|
|
60
|
+
"@aeye/gin": "0.10.1",
|
|
61
|
+
"@aeye/query": "0.10.1",
|
|
62
62
|
"expect-type": "^1.3.0",
|
|
63
63
|
"handlebars": "^4.7.0",
|
|
64
64
|
"tinybench": "^2.9.0",
|