@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/README.md
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
# @aeye/schema
|
|
2
|
-
|
|
3
|
-
The LLM-first schema builder for the @aeye framework: `a` is to aeye what `z` is to zod, built for
|
|
4
|
-
tool arguments and structured outputs.
|
|
5
|
-
|
|
6
|
-
## Features
|
|
7
|
-
|
|
8
|
-
- **Typed like zod**: `a.infer<typeof X>` is the exact code type, recursion included
|
|
9
|
-
- **Named, lazy and dynamic types**: `a.define(...).dynamic((ctx) => ...).result(...)`, checked at compile time in every case
|
|
10
|
-
- **Rendered per model**: records as pairs only where the dialect needs it, `null` for absent on OpenAI strict, JSON text where recursion or "any" can't be said — chosen from the model's capabilities
|
|
11
|
-
- **Request-wide budgets**: every schema of one request fitted together (Anthropic's 20 strict tools / 24 optional / 16 unions, OpenAI's size limits, 128 tools), each choice recorded
|
|
12
|
-
- **One rendering for everything**: the JSON sent, decoding, error paths, examples and `{{encode value}}` in instructions all agree
|
|
13
|
-
- **Copy-light decoding**: validated and decoded in one pass, in place; untouched subtrees are the same references
|
|
14
|
-
- **Errors for the model**: its own JSON echoed back with a marker under each mistake, "did you mean", the expected type, a hard size cap; the detail level is set per tool / prompt
|
|
15
|
-
- **Imports** JSON Schema (MCP, OpenAPI) and gin types
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
Not yet published (`private`); used from the monorepo workspace.
|
|
20
|
-
|
|
21
|
-
## Quick Start
|
|
22
|
-
|
|
23
|
-
```ts
|
|
24
|
-
import { a, profileFor } from '@aeye/schema';
|
|
25
|
-
|
|
26
|
-
const SetBudget = a.object({
|
|
27
|
-
owner: a.string(),
|
|
28
|
-
limits: a.record(a.number().min(0)).describe((v) => `Limit per category, as ${v.recordWord}.`),
|
|
29
|
-
note: a.string().optional(),
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const req = profileFor(model).request([{ kind: 'tool', name: 'set_budget', schema: SetBudget }]);
|
|
33
|
-
const tool = req.get('set_budget');
|
|
34
|
-
|
|
35
|
-
send({ parameters: tool.jsonSchema, strict: tool.strict });
|
|
36
|
-
const res = tool.parseText(rawArgs);
|
|
37
|
-
if (res.ok) console.log(res.value.limits.food);
|
|
38
|
-
else reprompt(res.message); // the model's JSON with "^^^ limits[0].value: Must be at least 0." under the bad value
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
In instructions:
|
|
42
|
-
|
|
43
|
-
```hbs
|
|
44
|
-
Example: {{encode example}}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
```ts
|
|
48
|
-
instructions(vars, { helpers: tool.helpers() });
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
See [aeye-schema.md](./aeye-schema.md) for the full reference and [DESIGN.md](./DESIGN.md) for
|
|
52
|
-
the design and its history.
|
|
53
|
-
|
|
54
|
-
## Scripts
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
npm test # vitest + type tests (tsc -p tsconfig.typetest.json)
|
|
58
|
-
npm run typecheck
|
|
59
|
-
npm run build # tsup → dist
|
|
60
|
-
```
|
|
1
|
+
# @aeye/schema
|
|
2
|
+
|
|
3
|
+
The LLM-first schema builder for the @aeye framework: `a` is to aeye what `z` is to zod, built for
|
|
4
|
+
tool arguments and structured outputs.
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- **Typed like zod**: `a.infer<typeof X>` is the exact code type, recursion included
|
|
9
|
+
- **Named, lazy and dynamic types**: `a.define(...).dynamic((ctx) => ...).result(...)`, checked at compile time in every case
|
|
10
|
+
- **Rendered per model**: records as pairs only where the dialect needs it, `null` for absent on OpenAI strict, JSON text where recursion or "any" can't be said — chosen from the model's capabilities
|
|
11
|
+
- **Request-wide budgets**: every schema of one request fitted together (Anthropic's 20 strict tools / 24 optional / 16 unions, OpenAI's size limits, 128 tools), each choice recorded
|
|
12
|
+
- **One rendering for everything**: the JSON sent, decoding, error paths, examples and `{{encode value}}` in instructions all agree
|
|
13
|
+
- **Copy-light decoding**: validated and decoded in one pass, in place; untouched subtrees are the same references
|
|
14
|
+
- **Errors for the model**: its own JSON echoed back with a marker under each mistake, "did you mean", the expected type, a hard size cap; the detail level is set per tool / prompt
|
|
15
|
+
- **Imports** JSON Schema (MCP, OpenAPI) and gin types
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Not yet published (`private`); used from the monorepo workspace.
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { a, profileFor } from '@aeye/schema';
|
|
25
|
+
|
|
26
|
+
const SetBudget = a.object({
|
|
27
|
+
owner: a.string(),
|
|
28
|
+
limits: a.record(a.number().min(0)).describe((v) => `Limit per category, as ${v.recordWord}.`),
|
|
29
|
+
note: a.string().optional(),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const req = profileFor(model).request([{ kind: 'tool', name: 'set_budget', schema: SetBudget }]);
|
|
33
|
+
const tool = req.get('set_budget');
|
|
34
|
+
|
|
35
|
+
send({ parameters: tool.jsonSchema, strict: tool.strict });
|
|
36
|
+
const res = tool.parseText(rawArgs);
|
|
37
|
+
if (res.ok) console.log(res.value.limits.food);
|
|
38
|
+
else reprompt(res.message); // the model's JSON with "^^^ limits[0].value: Must be at least 0." under the bad value
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
In instructions:
|
|
42
|
+
|
|
43
|
+
```hbs
|
|
44
|
+
Example: {{encode example}}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
instructions(vars, { helpers: tool.helpers() });
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
See [aeye-schema.md](./aeye-schema.md) for the full reference and [DESIGN.md](./DESIGN.md) for
|
|
52
|
+
the design and its history.
|
|
53
|
+
|
|
54
|
+
## Scripts
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm test # vitest + type tests (tsc -p tsconfig.typetest.json)
|
|
58
|
+
npm run typecheck
|
|
59
|
+
npm run build # tsup → dist
|
|
60
|
+
```
|