@framers/agentos 0.11.1 → 0.11.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structuredOutputFormat.d.ts","sourceRoot":"","sources":["../../../../src/core/llm/providers/structuredOutputFormat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAGnC;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,MAAM,EAAE,OAAO,CAAC;IAChB;;;;;OAKG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"structuredOutputFormat.d.ts","sourceRoot":"","sources":["../../../../src/core/llm/providers/structuredOutputFormat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAGnC;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,MAAM,EAAE,OAAO,CAAC;IAChB;;;;;OAKG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AA+JD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,wBAAwB,GAC9B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAoCzB"}
|
|
@@ -12,6 +12,60 @@ function sanitizeName(name) {
|
|
|
12
12
|
return 'response';
|
|
13
13
|
return name.replace(SCHEMA_NAME_INVALID_CHARS, '_').slice(0, SCHEMA_NAME_MAX_LEN);
|
|
14
14
|
}
|
|
15
|
+
/** JSON with object keys sorted, so two schemas that differ only in key order compare equal. */
|
|
16
|
+
function stableStringify(value) {
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
return `[${value.map(stableStringify).join(',')}]`;
|
|
19
|
+
}
|
|
20
|
+
if (value && typeof value === 'object') {
|
|
21
|
+
const entries = Object.keys(value)
|
|
22
|
+
.sort()
|
|
23
|
+
.map((k) => `${JSON.stringify(k)}:${stableStringify(value[k])}`);
|
|
24
|
+
return `{${entries.join(',')}}`;
|
|
25
|
+
}
|
|
26
|
+
return JSON.stringify(value) ?? 'undefined';
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Merges the schemas that the variants of a top-level union give one property.
|
|
30
|
+
* Enum schemas (a discriminant such as `kind`) become one enum of every value,
|
|
31
|
+
* keeping the fields they all share;
|
|
32
|
+
* otherwise identical schemas collapse to one, and different ones are kept side
|
|
33
|
+
* by side under a nested `anyOf`, which Anthropic accepts below the top level.
|
|
34
|
+
* Keeping only the first variant's schema would tell the model a later
|
|
35
|
+
* variant's value has the first variant's type, and the reply would then fail
|
|
36
|
+
* the caller's Zod schema.
|
|
37
|
+
*/
|
|
38
|
+
function mergePropertySchemas(schemas) {
|
|
39
|
+
if (schemas.length === 1) {
|
|
40
|
+
return schemas[0];
|
|
41
|
+
}
|
|
42
|
+
if (schemas.every((s) => s && typeof s === 'object' && Array.isArray(s.enum))) {
|
|
43
|
+
const records = schemas;
|
|
44
|
+
// Fields every variant gives the same value (`type`, a shared `description`) stay.
|
|
45
|
+
const shared = {};
|
|
46
|
+
for (const [field, value] of Object.entries(records[0])) {
|
|
47
|
+
if (field === 'enum')
|
|
48
|
+
continue;
|
|
49
|
+
if (records.every((r) => field in r && stableStringify(r[field]) === stableStringify(value))) {
|
|
50
|
+
shared[field] = value;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
...shared,
|
|
55
|
+
enum: Array.from(new Set(records.flatMap((r) => r.enum))),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const distinct = [];
|
|
59
|
+
const seen = new Set();
|
|
60
|
+
for (const schema of schemas) {
|
|
61
|
+
const key = stableStringify(schema);
|
|
62
|
+
if (!seen.has(key)) {
|
|
63
|
+
seen.add(key);
|
|
64
|
+
distinct.push(schema);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return distinct.length === 1 ? distinct[0] : { anyOf: distinct };
|
|
68
|
+
}
|
|
15
69
|
/**
|
|
16
70
|
* Adapt a lowered JSON Schema into a shape Anthropic's tool `input_schema`
|
|
17
71
|
* accepts. The Anthropic Messages API requires the tool input_schema to be a
|
|
@@ -23,7 +77,8 @@ function sanitizeName(name) {
|
|
|
23
77
|
*
|
|
24
78
|
* 1. **Union of objects → one merged object.** Union the members' `properties`
|
|
25
79
|
* (merging same-named `enum` members so a discriminant like `kind` becomes
|
|
26
|
-
* the full set of variant values
|
|
80
|
+
* the full set of variant values, and keeping a shared property's differing
|
|
81
|
+
* schemas under a nested `anyOf`), and keep in `required` only the fields
|
|
27
82
|
* required by EVERY member, so variant-specific fields stay optional. The
|
|
28
83
|
* model returns one flat object; the caller's Zod schema re-validates the
|
|
29
84
|
* exact variant, so strictness is preserved. Nested `anyOf` (inside a
|
|
@@ -47,28 +102,17 @@ function ensureAnthropicObjectSchema(jsonSchema) {
|
|
|
47
102
|
if (variants &&
|
|
48
103
|
variants.length > 0 &&
|
|
49
104
|
variants.every((v) => v && typeof v === 'object' && v.type === 'object')) {
|
|
50
|
-
|
|
105
|
+
// Every variant's schema for each property, in the order properties first appear.
|
|
106
|
+
const propertySchemas = new Map();
|
|
51
107
|
const requiredCounts = {};
|
|
52
108
|
for (const variant of variants) {
|
|
53
109
|
const props = variant.properties && typeof variant.properties === 'object'
|
|
54
110
|
? variant.properties
|
|
55
111
|
: {};
|
|
56
112
|
for (const [key, propSchema] of Object.entries(props)) {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
Array.isArray(existing.enum) &&
|
|
61
|
-
incoming &&
|
|
62
|
-
Array.isArray(incoming.enum)) {
|
|
63
|
-
// Same field is an enum across variants (e.g. the discriminant) —
|
|
64
|
-
// union the allowed values so the model can satisfy any variant.
|
|
65
|
-
mergedProperties[key] = {
|
|
66
|
-
enum: Array.from(new Set([...existing.enum, ...incoming.enum])),
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
else if (!(key in mergedProperties)) {
|
|
70
|
-
mergedProperties[key] = propSchema;
|
|
71
|
-
}
|
|
113
|
+
const schemas = propertySchemas.get(key) ?? [];
|
|
114
|
+
schemas.push(propSchema);
|
|
115
|
+
propertySchemas.set(key, schemas);
|
|
72
116
|
}
|
|
73
117
|
const variantRequired = Array.isArray(variant.required)
|
|
74
118
|
? variant.required
|
|
@@ -80,6 +124,10 @@ function ensureAnthropicObjectSchema(jsonSchema) {
|
|
|
80
124
|
// A field is required in the merged object only when EVERY variant requires
|
|
81
125
|
// it; variant-specific fields must stay optional.
|
|
82
126
|
const required = Object.keys(requiredCounts).filter((field) => requiredCounts[field] === variants.length);
|
|
127
|
+
const mergedProperties = {};
|
|
128
|
+
for (const [key, schemas] of propertySchemas) {
|
|
129
|
+
mergedProperties[key] = mergePropertySchemas(schemas);
|
|
130
|
+
}
|
|
83
131
|
return {
|
|
84
132
|
type: 'object',
|
|
85
133
|
properties: mergedProperties,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structuredOutputFormat.js","sourceRoot":"","sources":["../../../../src/core/llm/providers/structuredOutputFormat.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAC;AAmBzF,MAAM,yBAAyB,GAAG,gBAAgB,CAAC;AACnD,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,SAAS,YAAY,CAAC,IAAY;IAChC,wEAAwE;IACxE,wEAAwE;IACxE,qEAAqE;IACrE,sEAAsE;IACtE,mBAAmB;IACnB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAC;IAC7D,IAAI,CAAC,QAAQ;QAAE,OAAO,UAAU,CAAC;IACjC,OAAO,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC;AACpF,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"structuredOutputFormat.js","sourceRoot":"","sources":["../../../../src/core/llm/providers/structuredOutputFormat.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAC;AAmBzF,MAAM,yBAAyB,GAAG,gBAAgB,CAAC;AACnD,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,SAAS,YAAY,CAAC,IAAY;IAChC,wEAAwE;IACxE,wEAAwE;IACxE,qEAAqE;IACrE,sEAAsE;IACtE,mBAAmB;IACnB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAC;IAC7D,IAAI,CAAC,QAAQ;QAAE,OAAO,UAAU,CAAC;IACjC,OAAO,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC;AACpF,CAAC;AAED,gGAAgG;AAChG,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACrD,CAAC;IACD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAgC,CAAC;aAC1D,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,eAAe,CAAE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A+D;YAC/D,6DAA6D;YAC7D,iDAAiD;YACjD,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;IACnC,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@framers/agentos",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"description": "AgentOS: open-source TypeScript framework for autonomous AI agents. Unified graph orchestration, cognitive memory, runtime tool forging, multi-tier guardrails, voice pipeline, and 11 LLM providers.",
|
|
5
5
|
"homepage": "https://agentos.sh",
|
|
6
6
|
"repository": {
|