@mochabug/adapt-sdk 0.4.2 → 0.4.3
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/anthropic/index.d.ts +62 -20
- package/dist/anthropic/index.d.ts.map +1 -1
- package/dist/cjs/anthropic.cjs +1 -1
- package/dist/cjs/anthropic.cjs.map +3 -3
- package/dist/cjs/gemini.cjs +1 -1
- package/dist/cjs/gemini.cjs.map +3 -3
- package/dist/cjs/openai.cjs +1 -1
- package/dist/cjs/openai.cjs.map +3 -3
- package/dist/esm/anthropic.mjs +1 -1
- package/dist/esm/anthropic.mjs.map +3 -3
- package/dist/esm/gemini.mjs +1 -1
- package/dist/esm/gemini.mjs.map +3 -3
- package/dist/esm/openai.mjs +1 -1
- package/dist/esm/openai.mjs.map +3 -3
- package/dist/gemini/index.d.ts +62 -18
- package/dist/gemini/index.d.ts.map +1 -1
- package/dist/openai/index.d.ts +72 -20
- package/dist/openai/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -63,13 +63,34 @@ export interface ConvertFailure {
|
|
|
63
63
|
/** Array of human-readable error messages with JSON Pointer path prefixes. */
|
|
64
64
|
errors: string[];
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Successful conversion result for multiple signal descriptors.
|
|
68
|
+
*
|
|
69
|
+
* Returned when the conversion was created via {@link AnthropicConversion.fromSignals}.
|
|
70
|
+
* Contains per-signal results keyed by signal name.
|
|
71
|
+
*/
|
|
72
|
+
export interface ConvertSuccessSignals {
|
|
73
|
+
success: true;
|
|
74
|
+
kind: 'signals';
|
|
75
|
+
/**
|
|
76
|
+
* Per-signal values in dispatch-ready format.
|
|
77
|
+
*
|
|
78
|
+
* JSON signals are raw values (the JTD-validated data).
|
|
79
|
+
* Binary signals are `{ data: Uint8Array, mimeType: string, filename?: string }`.
|
|
80
|
+
*
|
|
81
|
+
* This record can be passed directly to `dispatchExchange()` or `send()`.
|
|
82
|
+
*/
|
|
83
|
+
signals: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
/** Union of all successful conversion outcomes. */
|
|
86
|
+
export type ConvertSuccess = ConvertSuccessJson | ConvertSuccessBinary | ConvertSuccessSignals;
|
|
66
87
|
/**
|
|
67
88
|
* Discriminated union of conversion outcomes.
|
|
68
89
|
*
|
|
69
|
-
* Check `success` first, then narrow on `kind` (`'json'
|
|
70
|
-
* for successful results.
|
|
90
|
+
* Check `success` first, then narrow on `kind` (`'json'`, `'binary'`, or
|
|
91
|
+
* `'signals'`) for successful results.
|
|
71
92
|
*/
|
|
72
|
-
export type ConvertResult =
|
|
93
|
+
export type ConvertResult = ConvertSuccess | ConvertFailure;
|
|
73
94
|
/**
|
|
74
95
|
* Converts JTD schemas or Adapt signal descriptors into Anthropic-compatible
|
|
75
96
|
* JSON Schema, and converts raw LLM output back into validated data.
|
|
@@ -124,7 +145,7 @@ export type ConvertResult = ConvertSuccessJson | ConvertSuccessBinary | ConvertF
|
|
|
124
145
|
* const restored = AnthropicConversion.fromJSON(cached);
|
|
125
146
|
* ```
|
|
126
147
|
*/
|
|
127
|
-
export declare class AnthropicConversion {
|
|
148
|
+
export declare class AnthropicConversion<T extends ConvertSuccess = ConvertSuccess> {
|
|
128
149
|
/** The Anthropic-specific JSON Schema to pass to the Anthropic API as the tool input schema. */
|
|
129
150
|
readonly schema: AnthropicSchema;
|
|
130
151
|
/**
|
|
@@ -146,6 +167,11 @@ export declare class AnthropicConversion {
|
|
|
146
167
|
* Set when created via {@link fromSignal}; `undefined` when created via {@link fromJTD}.
|
|
147
168
|
*/
|
|
148
169
|
readonly descriptor?: SignalDescriptorJson;
|
|
170
|
+
/**
|
|
171
|
+
* The original signal descriptors used to build this conversion.
|
|
172
|
+
* Set when created via {@link fromSignals}; `undefined` otherwise.
|
|
173
|
+
*/
|
|
174
|
+
readonly descriptors?: SignalDescriptorJson[];
|
|
149
175
|
/**
|
|
150
176
|
* Build a conversion from a JTD schema.
|
|
151
177
|
*
|
|
@@ -162,7 +188,7 @@ export declare class AnthropicConversion {
|
|
|
162
188
|
* nesting exceeding 32 levels, or **any circular reference** among
|
|
163
189
|
* definitions (Anthropic does not support recursive schemas).
|
|
164
190
|
*/
|
|
165
|
-
static fromJTD(jtdSchema: JTDSchemaJson): AnthropicConversion
|
|
191
|
+
static fromJTD(jtdSchema: JTDSchemaJson): AnthropicConversion<ConvertSuccessJson>;
|
|
166
192
|
/**
|
|
167
193
|
* Build a conversion from an Adapt signal descriptor.
|
|
168
194
|
*
|
|
@@ -177,7 +203,33 @@ export declare class AnthropicConversion {
|
|
|
177
203
|
* @throws If the descriptor has no formats, or a format has neither
|
|
178
204
|
* `jtdSchema` nor `mimeType`.
|
|
179
205
|
*/
|
|
180
|
-
static fromSignal(descriptor: SignalDescriptorJson): AnthropicConversion
|
|
206
|
+
static fromSignal(descriptor: SignalDescriptorJson): AnthropicConversion<ConvertSuccessJson | ConvertSuccessBinary>;
|
|
207
|
+
/**
|
|
208
|
+
* Build a conversion from multiple signal descriptors.
|
|
209
|
+
*
|
|
210
|
+
* Produces an object schema with one property per signal, suitable for
|
|
211
|
+
* use as structured output parameters. Each signal's schema is built via
|
|
212
|
+
* {@link fromSignal} internally.
|
|
213
|
+
*
|
|
214
|
+
* For Anthropic, optional signals are genuinely optional -- they are NOT
|
|
215
|
+
* added to `required` (no nullable wrapping needed).
|
|
216
|
+
*
|
|
217
|
+
* Receiver/transceiver compatible:
|
|
218
|
+
* ```ts
|
|
219
|
+
* const conv = AnthropicConversion.fromSignals(
|
|
220
|
+
* receiver.signals!,
|
|
221
|
+
* receiver.description,
|
|
222
|
+
* receiver.name
|
|
223
|
+
* );
|
|
224
|
+
* ```
|
|
225
|
+
*
|
|
226
|
+
* @param signals - Array of signal descriptors.
|
|
227
|
+
* @param description - Optional description for the compound schema.
|
|
228
|
+
* @param label - Optional label (reserved for other providers).
|
|
229
|
+
* @returns A new {@link AnthropicConversion} with `descriptors` set.
|
|
230
|
+
* @throws If any signal has no formats or an invalid format.
|
|
231
|
+
*/
|
|
232
|
+
static fromSignals(signals: SignalDescriptorJson[], description?: string, label?: string): AnthropicConversion<ConvertSuccessSignals>;
|
|
181
233
|
/**
|
|
182
234
|
* Restore an {@link AnthropicConversion} from its serialized form.
|
|
183
235
|
*
|
|
@@ -216,7 +268,7 @@ export declare class AnthropicConversion {
|
|
|
216
268
|
* @param json - The raw value returned by the Anthropic API (typically parsed JSON).
|
|
217
269
|
* @returns A {@link ConvertResult} indicating success or failure with errors.
|
|
218
270
|
*/
|
|
219
|
-
convert: (json: unknown) =>
|
|
271
|
+
convert: (json: unknown) => T | ConvertFailure;
|
|
220
272
|
/**
|
|
221
273
|
* Produce a JSON-serializable representation of this conversion.
|
|
222
274
|
*
|
|
@@ -227,17 +279,7 @@ export declare class AnthropicConversion {
|
|
|
227
279
|
*
|
|
228
280
|
* Called automatically by `JSON.stringify(conv)`.
|
|
229
281
|
*/
|
|
230
|
-
toJSON():
|
|
231
|
-
schema: AnthropicSchema;
|
|
232
|
-
strict: boolean;
|
|
233
|
-
descriptor: SignalDescriptorJson;
|
|
234
|
-
jtdSchema?: undefined;
|
|
235
|
-
} | {
|
|
236
|
-
schema: AnthropicSchema;
|
|
237
|
-
strict: boolean;
|
|
238
|
-
jtdSchema: JTDSchemaJson | undefined;
|
|
239
|
-
descriptor?: undefined;
|
|
240
|
-
};
|
|
282
|
+
toJSON(): Record<string, unknown>;
|
|
241
283
|
}
|
|
242
284
|
/**
|
|
243
285
|
* Convenience alias for {@link AnthropicConversion.fromJTD}.
|
|
@@ -245,12 +287,12 @@ export declare class AnthropicConversion {
|
|
|
245
287
|
* @param jtdSchema - A valid JTD schema (RFC 8927).
|
|
246
288
|
* @returns A new {@link AnthropicConversion}.
|
|
247
289
|
*/
|
|
248
|
-
export declare function convertToAnthropicSchema(jtdSchema: JTDSchemaJson): AnthropicConversion
|
|
290
|
+
export declare function convertToAnthropicSchema(jtdSchema: JTDSchemaJson): AnthropicConversion<ConvertSuccessJson>;
|
|
249
291
|
/**
|
|
250
292
|
* Convenience alias for {@link AnthropicConversion.fromSignal}.
|
|
251
293
|
*
|
|
252
294
|
* @param descriptor - An Adapt signal descriptor.
|
|
253
295
|
* @returns A new {@link AnthropicConversion}.
|
|
254
296
|
*/
|
|
255
|
-
export declare function convertSignalToAnthropicSchema(descriptor: SignalDescriptorJson): AnthropicConversion
|
|
297
|
+
export declare function convertSignalToAnthropicSchema(descriptor: SignalDescriptorJson): AnthropicConversion<ConvertSuccessJson | ConvertSuccessBinary>;
|
|
256
298
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/anthropic/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EAErB,MAAM,QAAQ,CAAC;AAOhB;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC7C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,oBAAoB,CAAC,EAAE,KAAK,CAAC;IAC7B,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC;IAC5C,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,KAAK,CAAC,EAAE,eAAe,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,MAAM,WAA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J=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var n in t)J(e,n,{get:t[n],enumerable:!0})},N=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of P(t))!x.call(e,r)&&r!==n&&J(e,r,{get:()=>t[r],enumerable:!(o=O(t,r))||o.enumerable});return e};var C=e=>N(J({},"__esModule",{value:!0}),e);var te={};E(te,{AnthropicConversion:()=>y,convertSignalToAnthropicSchema:()=>ee,convertToAnthropicSchema:()=>Q});module.exports=C(te);var S=require("jtd");var I=new Set(["int8","uint8","int16","uint16","int32","uint32"]);function M(e){return e.length===0?"/":e.map(t=>/^\d+$/.test(t)?`[${t}]`:`.${t}`).join("")}function k(e,t){let n=e;for(let o=0;o<t.length-1&&(n&&typeof n=="object"&&t[o]in n);o++)n=n[t[o]];return n}function F(e,t){let n=e;for(let o of t)if(n&&typeof n=="object")n=n[o];else return;return n}function _(e,t,n){let{instancePath:o,schemaPath:r}=e,i=M(o),s=r[r.length-1];if(s==="type"){let c=k(t,r)?.type;return c==="boolean"?`${i}: expected boolean`:c==="string"?`${i}: expected string`:c==="timestamp"?`${i}: expected timestamp string`:I.has(c)?`${i}: expected integer`:`${i}: expected number`}if(s==="enum"){let c=k(t,r)?.enum;return`${i}: expected one of [${c.join(", ")}]`}if(r.length>=2&&r[r.length-2]==="properties"&&s)return`${i==="/"?"":i}.${s}: missing required property`;if(s==="elements")return`${i}: expected array`;if(s==="properties"||s==="optionalProperties"||s==="values")return`${i}: expected object`;if(s==="discriminator")return`${i}: expected string discriminator`;if(s==="mapping"){let a=F(n,o);return`${i}: unknown variant "${a}"`}return r.length===0?`${i}: unexpected property`:`${i}: validation error at /${r.join("/")}`}function D(e,t,n){let o=n??e.definitions,r=o?{...e,definitions:o}:e;return(0,S.isValidSchema)(r)?(0,S.validate)(r,t,{maxDepth:U,maxErrors:q}).map(s=>_(s,r,t)):e.ref?[`/: unknown ref "${e.ref}"`]:["/: invalid schema"]}var U=32,q=100;var h=32,T=`Must be a valid JSON value encoded as a string. For objects: '{"key": "value"}', for arrays: '[1, 2]', for primitives: '"hello"' or '42' or 'true' or 'null'.`,V=`The variant data encoded as a valid JSON string (e.g. '{"key": "value"}').`,B="Array of key-value entries representing a map/dictionary. Each entry has a string 'key' (the property name) and a 'value' (the property value).",j={int8:{minimum:-128,maximum:127},uint8:{minimum:0,maximum:255},int16:{minimum:-32768,maximum:32767},uint16:{minimum:0,maximum:65535},int32:{minimum:-2147483648,maximum:2147483647},uint32:{minimum:0,maximum:4294967295}},A={minimum:-34028235e31,maximum:34028235e31};function b(e){return!e||typeof e!="object"?!0:e.type||e.enum||e.elements||e.values||e.discriminator||e.ref||e.properties&&Object.keys(e.properties).length>0||e.optionalProperties&&Object.keys(e.optionalProperties).length>0?!1:(e.properties!==void 0||e.optionalProperties!==void 0)&&e.additionalProperties===!0?!0:!(e.properties!==void 0||e.optionalProperties!==void 0)}function K(e,t){let n=e,o=0;for(;n.ref&&o<h;){let r=t?.[n.ref];if(!r)return!1;n=r,o++}return o>=h?!1:b(n)}function g(e){let t=[];if(!e||typeof e!="object")return t;if(e.ref&&t.push(e.ref),e.properties)for(let n of Object.values(e.properties))t.push(...g(n));if(e.optionalProperties)for(let n of Object.values(e.optionalProperties))t.push(...g(n));if(e.elements&&t.push(...g(e.elements)),e.values&&t.push(...g(e.values)),e.mapping)for(let n of Object.values(e.mapping))t.push(...g(n));return t}function G(e){let r=new Map;for(let s of Object.keys(e))r.set(s,0);function i(s){r.set(s,1);let a=e[s];if(a){for(let c of g(a))if(r.has(c)){if(r.get(c)===1)return c;if(r.get(c)===0){let p=i(c);if(p)return p}}}return r.set(s,2),null}for(let s of Object.keys(e))if(r.get(s)===0){let a=i(s);if(a)return a}return null}function f(e,t){return t?[e,"null"]:e}function H(e,t){e.description=e.description?`${e.description} ${t}`:t}var Y=new Set(["title","label","name","description"]);function l(e,t){let n=t.metadata;if(!n)return;let o=[],r=typeof n.title=="string"&&n.title.trim()||typeof n.label=="string"&&n.label.trim()||typeof n.name=="string"&&n.name.trim(),i=typeof n.description=="string"?n.description.trim():"";r&&i?o.push(`${r}. ${i}`):r?o.push(r):i&&o.push(i);let s=[];for(let[a,c]of Object.entries(n))Y.has(a)||(typeof c=="string"&&c.trim()?s.push(`[${a}: ${c.trim()}]`):(typeof c=="number"||typeof c=="boolean")&&s.push(`[${a}: ${c}]`));if(s.length>0&&o.push(s.join(" ")),o.length>0){let a=o.join(" ");e.description=e.description?`${e.description} ${a}`:a}}function m(e,t,n){if(n>h)throw new Error(`Schema nesting exceeded ${h} levels`);if(!e||typeof e!="object")return{type:"string",description:T};if(b(e)){let r={type:f("string",e.nullable===!0),description:T};return l(r,e),r}let o=e.nullable===!0;if(e.ref){let r=e.ref;if(!t?.[r])throw new Error(`Unresolved ref "${r}"`);if(o){let i={anyOf:[{$ref:`#/$defs/${r}`},{type:"null"}]};return l(i,e),i}return{$ref:`#/$defs/${r}`}}if(e.type){let r={},i,s=j[e.type];if(s)r.type=f("integer",o),i=`Value range: [${s.minimum}, ${s.maximum}].`;else switch(e.type){case"boolean":r.type=f("boolean",o);break;case"string":r.type=f("string",o);break;case"timestamp":r.type=f("string",o),r.format="date-time";break;case"float32":r.type=f("number",o),i=`Value range: [${A.minimum}, ${A.maximum}].`;break;case"float64":r.type=f("number",o);break;default:throw new Error(`Unknown JTD type "${e.type}"`)}return l(r,e),i&&H(r,i),r}if(e.enum){let r={type:f("string",o),enum:o?[...e.enum,null]:e.enum};return l(r,e),r}if(e.elements){let r={type:f("array",o),items:m(e.elements,t,n+1)};return l(r,e),r}if(e.properties||e.optionalProperties){let r={},i=[];if(e.properties)for(let[a,c]of Object.entries(e.properties))r[a]=m(c,t,n+1),i.push(a);if(e.optionalProperties)for(let[a,c]of Object.entries(e.optionalProperties))r[a]=m(c,t,n+1);let s={type:f("object",o),properties:r,additionalProperties:!1};return i.length>0&&(s.required=i),l(s,e),s}if(e.values){let r=m(e.values,t,n+1),i={type:f("array",o),description:B,items:{type:"object",properties:{key:{type:"string",description:"The property name."},value:r},required:["key","value"],additionalProperties:!1}};return l(i,e),i}if(e.discriminator&&e.mapping){let r=e.discriminator,i=e.mapping,s=[];for(let[c,p]of Object.entries(i)){let u;b(p)?u={type:"object",properties:{[r]:{const:c},_data:{type:"string",description:V}},required:[r,"_data"],additionalProperties:!1}:(u=m(p,t,n+1),u.properties[r]={const:c},(u.required??=[]).unshift(r),u.additionalProperties=!1),l(u,p),s.push(u)}o&&s.push({type:"null"});let a={anyOf:s};return l(a,e),a}return{type:"string",description:T}}var L=new Set(Object.keys(j));function d(e,t,n,o){if(o>h||e==null)return e;if(t.ref){let r=n?.[t.ref];return r?d(e,r,n,o+1):e}if(b(t)){if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}if(t.type&&L.has(t.type))return typeof e=="number"&&!Number.isInteger(e)?Math.round(e):e;if(t.elements&&Array.isArray(e)){let r=t.elements;return e.map(i=>d(i,r,n,o+1))}if((t.properties||t.optionalProperties)&&typeof e=="object"&&e!==null){let r={...e};if(t.properties)for(let[i,s]of Object.entries(t.properties))i in r&&(r[i]=d(r[i],s,n,o+1));if(t.optionalProperties)for(let[i,s]of Object.entries(t.optionalProperties))i in r&&(r[i]=d(r[i],s,n,o+1));return r}if(t.values&&Array.isArray(e)){let r={};for(let i of e)if(typeof i=="object"&&i!==null){let s=i,a=s.key;r[a]=d(s.value,t.values,n,o+1)}return r}if(t.discriminator&&t.mapping&&typeof e=="object"&&e!==null){let r=e,i=t.discriminator,s=r[i];if(typeof s!="string")return e;let a=t.mapping[s];if(!a)return e;if(b(a)){let p=r._data;if(typeof p=="string")try{let u=JSON.parse(p);if(typeof u=="object"&&u!==null)return{[i]:s,...u}}catch{}return{[i]:s}}let c={[i]:s};if(a.properties)for(let[p,u]of Object.entries(a.properties))p in r&&(c[p]=d(r[p],u,n,o+1));if(a.optionalProperties)for(let[p,u]of Object.entries(a.optionalProperties))p in r&&(c[p]=d(r[p],u,n,o+1));return c}return e}function W(e){return{type:"object",description:`Binary content (MIME type: ${e}).`,properties:{data:{type:"string",description:`The base64-encoded binary content (MIME type: ${e}).`},filename:{type:"string",description:'Optional filename for the binary content (e.g. "report.pdf", "image.png").'}},required:["data"],additionalProperties:!1}}var y=class e{schema;strict;jtdSchema;descriptor;static fromJTD(t){let n=t.definitions;if(n&&Object.keys(n).length>0){let i=G(n);if(i)throw new Error(`Anthropic structured output does not support recursive schemas. Definition "${i}" contains a circular reference.`)}let o=!K(t,n),r;return o?(r=m(t,n,0),n&&Object.keys(n).length>0&&(r.$defs=Object.fromEntries(Object.entries(n).map(([i,s])=>[i,m(s,n,0)])))):(r={},l(r,t)),new e(r,o,t,void 0)}static fromSignal(t){let{schema:n,strict:o}=Z(t);return new e(n,o,void 0,t)}static fromJSON(t){let n=typeof t=="string"?JSON.parse(t):t;if(n.descriptor)return e.fromSignal(n.descriptor);if(n.jtdSchema)return e.fromJTD(n.jtdSchema);throw new Error("Cannot deserialize: missing jtdSchema or descriptor")}constructor(t,n,o,r){this.schema=t,this.strict=n,this.jtdSchema=o,this.descriptor=r}convert=t=>this.jtdSchema?R(this.jtdSchema,t):this.descriptor?z(this.descriptor,t):{success:!1,errors:["No source schema available"]};toJSON(){return this.descriptor?{schema:this.schema,strict:this.strict,descriptor:this.descriptor}:{schema:this.schema,strict:this.strict,jtdSchema:this.jtdSchema}}};function R(e,t){let n=e.definitions,o=d(t,e,n,0),r=D(e,o,n);return r.length>0?{success:!1,errors:r}:{success:!0,kind:"json",data:o}}function X(e,t){if(typeof t!="object"||t===null)return{success:!1,errors:[`/: expected object with 'data' field for MIME type ${e}, got ${typeof t}`]};let n=t;if(typeof n.data!="string")return{success:!1,errors:[`/data: expected base64 string for MIME type ${e}, got ${typeof n.data}`]};let o={success:!0,kind:"binary",mimeType:e,data:new Uint8Array(Buffer.from(n.data,"base64"))};return typeof n.filename=="string"&&n.filename&&(o.filename=n.filename),o}function $(e,t){return e.mimeType?X(e.mimeType,t):e.jtdSchema?R(e.jtdSchema,t):{success:!1,errors:["Signal format has neither jtdSchema nor mimeType"]}}function z(e,t){let n=e.formats;if(!n||n.length===0)return{success:!1,errors:["Signal descriptor has no formats"]};if(n.length===1)return $(n[0],t);if(typeof t!="object"||t===null)return{success:!1,errors:[`/: expected object with format properties, got ${typeof t}`]};let o=t;for(let i=0;i<n.length;i++){let s=`format_${i}`;if(o[s]!==void 0&&o[s]!==null)return $(n[i],o[s])}if(e.optional)return{success:!0,kind:"json",data:null};let r=n.map((i,s)=>`format_${s}`);return{success:!1,errors:[`Signal '${e.name??"unnamed"}' is required but no format was provided. Set exactly one of: ${r.join(", ")}.`]}}function Z(e){let t=e.formats;if(!t||t.length===0)throw new Error("Signal descriptor has no formats");if(t.length===1){let[a]=t,{schema:c,strict:p}=w(a);if(e.label||e.description){let u=[];e.label&&u.push(e.label),e.description&&u.push(e.description);let v=u.join(". ");c.description=c.description?`${v} ${c.description}`:v}return{schema:c,strict:p}}let n={};for(let[a,c]of t.entries()){let{schema:p}=w(c);c.jtdSchema&&(p.description=p.description?`Structured JSON data. ${p.description}`:"Structured JSON data."),n[`format_${a}`]=p}let o=Object.keys(n),r=e.description??"",i=e.optional?"Provide at most ONE of the following format properties. All are optional.":`You MUST provide exactly ONE of the following format properties: ${o.join(", ")}.`;return{schema:{type:"object",description:r?`${r} ${i}`:i,properties:n,additionalProperties:!1},strict:!0}}function w(e){if(e.jtdSchema){let t=y.fromJTD(e.jtdSchema);return{schema:t.schema,strict:t.strict}}if(e.mimeType)return{schema:W(e.mimeType),strict:!0};throw new Error("Signal format has neither jtdSchema nor mimeType")}function Q(e){return y.fromJTD(e)}function ee(e){return y.fromSignal(e)}0&&(module.exports={AnthropicConversion,convertSignalToAnthropicSchema,convertToAnthropicSchema});
|
|
1
|
+
"use strict";var J=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var n in t)J(e,n,{get:t[n],enumerable:!0})},N=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of P(t))!E.call(e,r)&&r!==n&&J(e,r,{get:()=>t[r],enumerable:!(o=x(t,r))||o.enumerable});return e};var F=e=>N(J({},"__esModule",{value:!0}),e);var re={};C(re,{AnthropicConversion:()=>y,convertSignalToAnthropicSchema:()=>te,convertToAnthropicSchema:()=>ee});module.exports=F(re);var S=require("jtd");var I=new Set(["int8","uint8","int16","uint16","int32","uint32"]);function M(e){return e.length===0?"/":e.map(t=>/^\d+$/.test(t)?`[${t}]`:`.${t}`).join("")}function k(e,t){let n=e;for(let o=0;o<t.length-1&&(n&&typeof n=="object"&&t[o]in n);o++)n=n[t[o]];return n}function q(e,t){let n=e;for(let o of t)if(n&&typeof n=="object")n=n[o];else return;return n}function U(e,t,n){let{instancePath:o,schemaPath:r}=e,i=M(o),s=r[r.length-1];if(s==="type"){let c=k(t,r)?.type;return c==="boolean"?`${i}: expected boolean`:c==="string"?`${i}: expected string`:c==="timestamp"?`${i}: expected timestamp string`:I.has(c)?`${i}: expected integer`:`${i}: expected number`}if(s==="enum"){let c=k(t,r)?.enum;return`${i}: expected one of [${c.join(", ")}]`}if(r.length>=2&&r[r.length-2]==="properties"&&s)return`${i==="/"?"":i}.${s}: missing required property`;if(s==="elements")return`${i}: expected array`;if(s==="properties"||s==="optionalProperties"||s==="values")return`${i}: expected object`;if(s==="discriminator")return`${i}: expected string discriminator`;if(s==="mapping"){let a=q(n,o);return`${i}: unknown variant "${a}"`}return r.length===0?`${i}: unexpected property`:`${i}: validation error at /${r.join("/")}`}function D(e,t,n){let o=n??e.definitions,r=o?{...e,definitions:o}:e;return(0,S.isValidSchema)(r)?(0,S.validate)(r,t,{maxDepth:V,maxErrors:_}).map(s=>U(s,r,t)):e.ref?[`/: unknown ref "${e.ref}"`]:["/: invalid schema"]}var V=32,_=100;var h=32,v=`Must be a valid JSON value encoded as a string. For objects: '{"key": "value"}', for arrays: '[1, 2]', for primitives: '"hello"' or '42' or 'true' or 'null'.`,B=`The variant data encoded as a valid JSON string (e.g. '{"key": "value"}').`,K="Array of key-value entries representing a map/dictionary. Each entry has a string 'key' (the property name) and a 'value' (the property value).",j={int8:{minimum:-128,maximum:127},uint8:{minimum:0,maximum:255},int16:{minimum:-32768,maximum:32767},uint16:{minimum:0,maximum:65535},int32:{minimum:-2147483648,maximum:2147483647},uint32:{minimum:0,maximum:4294967295}},w={minimum:-34028235e31,maximum:34028235e31};function b(e){return!e||typeof e!="object"?!0:e.type||e.enum||e.elements||e.values||e.discriminator||e.ref||e.properties&&Object.keys(e.properties).length>0||e.optionalProperties&&Object.keys(e.optionalProperties).length>0?!1:(e.properties!==void 0||e.optionalProperties!==void 0)&&e.additionalProperties===!0?!0:!(e.properties!==void 0||e.optionalProperties!==void 0)}function G(e,t){let n=e,o=0;for(;n.ref&&o<h;){let r=t?.[n.ref];if(!r)return!1;n=r,o++}return o>=h?!1:b(n)}function g(e){let t=[];if(!e||typeof e!="object")return t;if(e.ref&&t.push(e.ref),e.properties)for(let n of Object.values(e.properties))t.push(...g(n));if(e.optionalProperties)for(let n of Object.values(e.optionalProperties))t.push(...g(n));if(e.elements&&t.push(...g(e.elements)),e.values&&t.push(...g(e.values)),e.mapping)for(let n of Object.values(e.mapping))t.push(...g(n));return t}function H(e){let r=new Map;for(let s of Object.keys(e))r.set(s,0);function i(s){r.set(s,1);let a=e[s];if(a){for(let c of g(a))if(r.has(c)){if(r.get(c)===1)return c;if(r.get(c)===0){let u=i(c);if(u)return u}}}return r.set(s,2),null}for(let s of Object.keys(e))if(r.get(s)===0){let a=i(s);if(a)return a}return null}function f(e,t){return t?[e,"null"]:e}function Y(e,t){e.description=e.description?`${e.description} ${t}`:t}var L=new Set(["title","label","name","description"]);function l(e,t){let n=t.metadata;if(!n)return;let o=[],r=typeof n.title=="string"&&n.title.trim()||typeof n.label=="string"&&n.label.trim()||typeof n.name=="string"&&n.name.trim(),i=typeof n.description=="string"?n.description.trim():"";r&&i?o.push(`${r}. ${i}`):r?o.push(r):i&&o.push(i);let s=[];for(let[a,c]of Object.entries(n))L.has(a)||(typeof c=="string"&&c.trim()?s.push(`[${a}: ${c.trim()}]`):(typeof c=="number"||typeof c=="boolean")&&s.push(`[${a}: ${c}]`));if(s.length>0&&o.push(s.join(" ")),o.length>0){let a=o.join(" ");e.description=e.description?`${e.description} ${a}`:a}}function m(e,t,n){if(n>h)throw new Error(`Schema nesting exceeded ${h} levels`);if(!e||typeof e!="object")return{type:"string",description:v};if(b(e)){let r={type:f("string",e.nullable===!0),description:v};return l(r,e),r}let o=e.nullable===!0;if(e.ref){let r=e.ref;if(!t?.[r])throw new Error(`Unresolved ref "${r}"`);if(o){let i={anyOf:[{$ref:`#/$defs/${r}`},{type:"null"}]};return l(i,e),i}return{$ref:`#/$defs/${r}`}}if(e.type){let r={},i,s=j[e.type];if(s)r.type=f("integer",o),i=`Value range: [${s.minimum}, ${s.maximum}].`;else switch(e.type){case"boolean":r.type=f("boolean",o);break;case"string":r.type=f("string",o);break;case"timestamp":r.type=f("string",o),r.format="date-time";break;case"float32":r.type=f("number",o),i=`Value range: [${w.minimum}, ${w.maximum}].`;break;case"float64":r.type=f("number",o);break;default:throw new Error(`Unknown JTD type "${e.type}"`)}return l(r,e),i&&Y(r,i),r}if(e.enum){let r={type:f("string",o),enum:o?[...e.enum,null]:e.enum};return l(r,e),r}if(e.elements){let r={type:f("array",o),items:m(e.elements,t,n+1)};return l(r,e),r}if(e.properties||e.optionalProperties){let r={},i=[];if(e.properties)for(let[a,c]of Object.entries(e.properties))r[a]=m(c,t,n+1),i.push(a);if(e.optionalProperties)for(let[a,c]of Object.entries(e.optionalProperties))r[a]=m(c,t,n+1);let s={type:f("object",o),properties:r,additionalProperties:!1};return i.length>0&&(s.required=i),l(s,e),s}if(e.values){let r=m(e.values,t,n+1),i={type:f("array",o),description:K,items:{type:"object",properties:{key:{type:"string",description:"The property name."},value:r},required:["key","value"],additionalProperties:!1}};return l(i,e),i}if(e.discriminator&&e.mapping){let r=e.discriminator,i=e.mapping,s=[];for(let[c,u]of Object.entries(i)){let p;b(u)?p={type:"object",properties:{[r]:{const:c},_data:{type:"string",description:B}},required:[r,"_data"],additionalProperties:!1}:(p=m(u,t,n+1),p.properties[r]={const:c},(p.required??=[]).unshift(r),p.additionalProperties=!1),l(p,u),s.push(p)}o&&s.push({type:"null"});let a={anyOf:s};return l(a,e),a}return{type:"string",description:v}}var W=new Set(Object.keys(j));function d(e,t,n,o){if(o>h||e==null)return e;if(t.ref){let r=n?.[t.ref];return r?d(e,r,n,o+1):e}if(b(t)){if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}if(t.type&&W.has(t.type))return typeof e=="number"&&!Number.isInteger(e)?Math.round(e):e;if(t.elements&&Array.isArray(e)){let r=t.elements;return e.map(i=>d(i,r,n,o+1))}if((t.properties||t.optionalProperties)&&typeof e=="object"&&e!==null){let r={...e};if(t.properties)for(let[i,s]of Object.entries(t.properties))i in r&&(r[i]=d(r[i],s,n,o+1));if(t.optionalProperties)for(let[i,s]of Object.entries(t.optionalProperties))i in r&&(r[i]=d(r[i],s,n,o+1));return r}if(t.values&&Array.isArray(e)){let r={};for(let i of e)if(typeof i=="object"&&i!==null){let s=i,a=s.key;r[a]=d(s.value,t.values,n,o+1)}return r}if(t.discriminator&&t.mapping&&typeof e=="object"&&e!==null){let r=e,i=t.discriminator,s=r[i];if(typeof s!="string")return e;let a=t.mapping[s];if(!a)return e;if(b(a)){let u=r._data;if(typeof u=="string")try{let p=JSON.parse(u);if(typeof p=="object"&&p!==null)return{[i]:s,...p}}catch{}return{[i]:s}}let c={[i]:s};if(a.properties)for(let[u,p]of Object.entries(a.properties))u in r&&(c[u]=d(r[u],p,n,o+1));if(a.optionalProperties)for(let[u,p]of Object.entries(a.optionalProperties))u in r&&(c[u]=d(r[u],p,n,o+1));return c}return e}function X(e){return{type:"object",description:`Binary content (MIME type: ${e}).`,properties:{data:{type:"string",description:`The base64-encoded binary content (MIME type: ${e}).`},filename:{type:"string",description:'Optional filename for the binary content (e.g. "report.pdf", "image.png").'}},required:["data"],additionalProperties:!1}}var y=class e{schema;strict;jtdSchema;descriptor;descriptors;static fromJTD(t){let n=t.definitions;if(n&&Object.keys(n).length>0){let i=H(n);if(i)throw new Error(`Anthropic structured output does not support recursive schemas. Definition "${i}" contains a circular reference.`)}let o=!G(t,n),r;return o?(r=m(t,n,0),n&&Object.keys(n).length>0&&(r.$defs=Object.fromEntries(Object.entries(n).map(([i,s])=>[i,m(s,n,0)])))):(r={},l(r,t)),new e(r,o,t,void 0)}static fromSignal(t){let{schema:n,strict:o}=Q(t);return new e(n,o,void 0,t)}static fromSignals(t,n,o){let r={},i=[],s=!0;for(let c of t){if(!c.name)continue;let u=e.fromSignal(c);u.strict||(s=!1),r[c.name]=u.schema,c.optional||i.push(c.name)}let a={type:"object",properties:r,required:i.length>0?i:void 0,additionalProperties:!1};return o&&n?a.description=`${o}. ${n}`:o?a.description=o:n&&(a.description=n),new e(a,s,void 0,void 0,t)}static fromJSON(t){let n=typeof t=="string"?JSON.parse(t):t;if(n.descriptors)return e.fromSignals(n.descriptors,n.description,n.label);if(n.descriptor)return e.fromSignal(n.descriptor);if(n.jtdSchema)return e.fromJTD(n.jtdSchema);throw new Error("Cannot deserialize: missing jtdSchema, descriptor, or descriptors")}constructor(t,n,o,r,i){this.schema=t,this.strict=n,this.jtdSchema=o,this.descriptor=r,this.descriptors=i}convert=t=>this.descriptors?Z(this.descriptors,t):this.jtdSchema?R(this.jtdSchema,t):this.descriptor?O(this.descriptor,t):{success:!1,errors:["No source schema available"]};toJSON(){if(this.descriptors){let t={schema:this.schema,strict:this.strict,descriptors:this.descriptors};return this.schema.description&&(t.description=this.schema.description),t}return this.descriptor?{schema:this.schema,strict:this.strict,descriptor:this.descriptor}:{schema:this.schema,strict:this.strict,jtdSchema:this.jtdSchema}}};function R(e,t){let n=e.definitions,o=d(t,e,n,0),r=D(e,o,n);return r.length>0?{success:!1,errors:r}:{success:!0,kind:"json",data:o}}function z(e,t){if(typeof t!="object"||t===null)return{success:!1,errors:[`/: expected object with 'data' field for MIME type ${e}, got ${typeof t}`]};let n=t;if(typeof n.data!="string")return{success:!1,errors:[`/data: expected base64 string for MIME type ${e}, got ${typeof n.data}`]};let o={success:!0,kind:"binary",mimeType:e,data:new Uint8Array(Buffer.from(n.data,"base64"))};return typeof n.filename=="string"&&n.filename&&(o.filename=n.filename),o}function $(e,t){return e.mimeType?z(e.mimeType,t):e.jtdSchema?R(e.jtdSchema,t):{success:!1,errors:["Signal format has neither jtdSchema nor mimeType"]}}function O(e,t){let n=e.formats;if(!n||n.length===0)return{success:!1,errors:["Signal descriptor has no formats"]};if(n.length===1)return $(n[0],t);if(typeof t!="object"||t===null)return{success:!1,errors:[`/: expected object with format properties, got ${typeof t}`]};let o=t;for(let i=0;i<n.length;i++){let s=`format_${i}`;if(o[s]!==void 0&&o[s]!==null)return $(n[i],o[s])}if(e.optional)return{success:!0,kind:"json",data:null};let r=n.map((i,s)=>`format_${s}`);return{success:!1,errors:[`Signal '${e.name??"unnamed"}' is required but no format was provided. Set exactly one of: ${r.join(", ")}.`]}}function Z(e,t){if(typeof t!="object"||t===null)return{success:!1,errors:["/: expected object with signal properties, got "+typeof t]};let n=t,o={},r=[];for(let i of e){if(!i.name)continue;let s=n[i.name];if(s==null)continue;let a=O(i,s);if(a.success)a.kind==="binary"?o[i.name]={data:a.data,mimeType:a.mimeType,filename:a.filename}:a.kind==="json"&&(o[i.name]=a.data);else for(let c of a.errors)r.push(`/${i.name}${c.startsWith("/")?"":": "}${c}`)}return r.length>0?{success:!1,errors:r}:{success:!0,kind:"signals",signals:o}}function Q(e){let t=e.formats;if(!t||t.length===0)throw new Error("Signal descriptor has no formats");if(t.length===1){let[a]=t,{schema:c,strict:u}=A(a);if(e.label||e.description){let p=[];e.label&&p.push(e.label),e.description&&p.push(e.description);let T=p.join(". ");c.description=c.description?`${T} ${c.description}`:T}return{schema:c,strict:u}}let n={};for(let[a,c]of t.entries()){let{schema:u}=A(c);c.jtdSchema&&(u.description=u.description?`Structured JSON data. ${u.description}`:"Structured JSON data."),n[`format_${a}`]=u}let o=Object.keys(n),r=e.description??"",i=e.optional?"Provide at most ONE of the following format properties. All are optional.":`You MUST provide exactly ONE of the following format properties: ${o.join(", ")}.`;return{schema:{type:"object",description:r?`${r} ${i}`:i,properties:n,additionalProperties:!1},strict:!0}}function A(e){if(e.jtdSchema){let t=y.fromJTD(e.jtdSchema);return{schema:t.schema,strict:t.strict}}if(e.mimeType)return{schema:X(e.mimeType),strict:!0};throw new Error("Signal format has neither jtdSchema nor mimeType")}function ee(e){return y.fromJTD(e)}function te(e){return y.fromSignal(e)}0&&(module.exports={AnthropicConversion,convertSignalToAnthropicSchema,convertToAnthropicSchema});
|
|
2
2
|
//# sourceMappingURL=anthropic.cjs.map
|