@mochabug/adapt-sdk 0.4.10 → 0.4.12
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 +10 -4
- 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 +12 -8
- package/dist/gemini/index.d.ts.map +1 -1
- package/dist/openai/index.d.ts +12 -6
- package/dist/openai/index.d.ts.map +1 -1
- package/dist/schema-utils.d.ts +78 -4
- package/dist/schema-utils.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/gemini/index.d.ts
CHANGED
|
@@ -113,6 +113,8 @@ export declare class GeminiStructuredOutputConversion<T extends ConvertSuccess =
|
|
|
113
113
|
* Set when created via {@link fromSignals}; `undefined` otherwise.
|
|
114
114
|
*/
|
|
115
115
|
readonly descriptors?: SignalDescriptorJson[];
|
|
116
|
+
/** When true, MIME signals use file-reference schemas instead of base64. */
|
|
117
|
+
readonly referenceMode: boolean;
|
|
116
118
|
/**
|
|
117
119
|
* Build a conversion from a JTD schema.
|
|
118
120
|
*
|
|
@@ -139,7 +141,7 @@ export declare class GeminiStructuredOutputConversion<T extends ConvertSuccess =
|
|
|
139
141
|
* @throws If the descriptor has no formats, or a format has neither
|
|
140
142
|
* `jtdSchema` nor `mimeType`.
|
|
141
143
|
*/
|
|
142
|
-
static fromSignal(descriptor: SignalDescriptorJson): GeminiStructuredOutputConversion<ConvertSuccessJson | ConvertSuccessBinary>;
|
|
144
|
+
static fromSignal(descriptor: SignalDescriptorJson, referenceMode?: boolean): GeminiStructuredOutputConversion<ConvertSuccessJson | ConvertSuccessBinary>;
|
|
143
145
|
/**
|
|
144
146
|
* Build a conversion from multiple signal descriptors.
|
|
145
147
|
*
|
|
@@ -165,7 +167,7 @@ export declare class GeminiStructuredOutputConversion<T extends ConvertSuccess =
|
|
|
165
167
|
* @returns A new {@link GeminiStructuredOutputConversion} with `descriptors` set.
|
|
166
168
|
* @throws If any signal has no formats or an invalid format.
|
|
167
169
|
*/
|
|
168
|
-
static fromSignals(signals: SignalDescriptorJson[], description?: string, label?: string): GeminiStructuredOutputConversion<ConvertSuccessSignals>;
|
|
170
|
+
static fromSignals(signals: SignalDescriptorJson[], description?: string, label?: string, referenceMode?: boolean): GeminiStructuredOutputConversion<ConvertSuccessSignals>;
|
|
169
171
|
/**
|
|
170
172
|
* Restore a {@link GeminiStructuredOutputConversion} from its serialized form.
|
|
171
173
|
*
|
|
@@ -195,10 +197,10 @@ export declare class GeminiStructuredOutputConversion<T extends ConvertSuccess =
|
|
|
195
197
|
* For multi-format signals, the first non-null `format_N` property is
|
|
196
198
|
* selected and converted individually.
|
|
197
199
|
*
|
|
198
|
-
* @param
|
|
200
|
+
* @param value - The value to convert. JSON for JTD, or `{ data, mimeType, filename }` for MIME.
|
|
199
201
|
* @returns A {@link ConvertResult} indicating success or failure with errors.
|
|
200
202
|
*/
|
|
201
|
-
convert: (
|
|
203
|
+
convert: (value: unknown) => T | ConvertFailure;
|
|
202
204
|
/**
|
|
203
205
|
* Produce a JSON-serializable representation of this conversion.
|
|
204
206
|
*
|
|
@@ -272,6 +274,8 @@ export declare class GeminiFunctionCallingConversion<T extends ConvertSuccess =
|
|
|
272
274
|
* Set when created via {@link fromSignals}; `undefined` otherwise.
|
|
273
275
|
*/
|
|
274
276
|
readonly descriptors?: SignalDescriptorJson[];
|
|
277
|
+
/** When true, MIME signals use file-reference schemas instead of base64. */
|
|
278
|
+
readonly referenceMode: boolean;
|
|
275
279
|
/**
|
|
276
280
|
* Build a conversion from a JTD schema.
|
|
277
281
|
*
|
|
@@ -298,7 +302,7 @@ export declare class GeminiFunctionCallingConversion<T extends ConvertSuccess =
|
|
|
298
302
|
* @throws If the descriptor has no formats, or a format has neither
|
|
299
303
|
* `jtdSchema` nor `mimeType`.
|
|
300
304
|
*/
|
|
301
|
-
static fromSignal(descriptor: SignalDescriptorJson): GeminiFunctionCallingConversion<ConvertSuccessJson | ConvertSuccessBinary>;
|
|
305
|
+
static fromSignal(descriptor: SignalDescriptorJson, referenceMode?: boolean): GeminiFunctionCallingConversion<ConvertSuccessJson | ConvertSuccessBinary>;
|
|
302
306
|
/**
|
|
303
307
|
* Build a conversion from multiple signal descriptors.
|
|
304
308
|
*
|
|
@@ -323,7 +327,7 @@ export declare class GeminiFunctionCallingConversion<T extends ConvertSuccess =
|
|
|
323
327
|
* @returns A new {@link GeminiFunctionCallingConversion} with `descriptors` set.
|
|
324
328
|
* @throws If any signal has no formats or an invalid format.
|
|
325
329
|
*/
|
|
326
|
-
static fromSignals(signals: SignalDescriptorJson[], description?: string, label?: string): GeminiFunctionCallingConversion<ConvertSuccessSignals>;
|
|
330
|
+
static fromSignals(signals: SignalDescriptorJson[], description?: string, label?: string, referenceMode?: boolean): GeminiFunctionCallingConversion<ConvertSuccessSignals>;
|
|
327
331
|
/**
|
|
328
332
|
* Restore a {@link GeminiFunctionCallingConversion} from its serialized form.
|
|
329
333
|
*
|
|
@@ -359,10 +363,10 @@ export declare class GeminiFunctionCallingConversion<T extends ConvertSuccess =
|
|
|
359
363
|
* For multi-format signals, the first non-null `format_N` property is
|
|
360
364
|
* selected and converted individually.
|
|
361
365
|
*
|
|
362
|
-
* @param
|
|
366
|
+
* @param value - The value to convert. JSON for JTD, or `{ data, mimeType, filename }` for MIME.
|
|
363
367
|
* @returns A {@link ConvertResult} indicating success or failure with errors.
|
|
364
368
|
*/
|
|
365
|
-
convert: (
|
|
369
|
+
convert: (value: unknown) => T | ConvertFailure;
|
|
366
370
|
/**
|
|
367
371
|
* Produce a JSON-serializable representation of this conversion.
|
|
368
372
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gemini/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EAErB,MAAM,QAAQ,CAAC;AAChB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gemini/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EAErB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAcL,KAAK,cAAc,EAEnB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC3B,MAAM,iBAAiB,CAAC;AAMzB;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC1C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,GAAG,YAAY,CAAC;IAC9C,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAA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import { type
|
|
2
|
+
import { type ConvertFailure, type ConvertSuccess, type ConvertSuccessBinary, type ConvertSuccessJson, type ConvertSuccessSignals } from '../schema-utils';
|
|
3
3
|
/**
|
|
4
4
|
* JSON Schema subset accepted by the OpenAI structured-output API (strict mode).
|
|
5
5
|
*
|
|
@@ -24,7 +24,7 @@ export interface OpenAISchema {
|
|
|
24
24
|
$defs?: Record<string, OpenAISchema>;
|
|
25
25
|
$ref?: string;
|
|
26
26
|
}
|
|
27
|
-
export type {
|
|
27
|
+
export type { ConvertFailure, ConvertResult, ConvertSuccess, ConvertSuccessBinary, ConvertSuccessJson, ConvertSuccessSignals } from '../schema-utils';
|
|
28
28
|
/**
|
|
29
29
|
* Converts JTD schemas or Adapt signal descriptors into OpenAI-compatible
|
|
30
30
|
* JSON Schema (strict mode), and converts raw LLM output back into
|
|
@@ -104,6 +104,12 @@ export declare class OpenAIConversion<T extends ConvertSuccess = ConvertSuccess>
|
|
|
104
104
|
* Set when created via {@link fromSignals}; `undefined` otherwise.
|
|
105
105
|
*/
|
|
106
106
|
readonly descriptors?: SignalDescriptorJson[];
|
|
107
|
+
/**
|
|
108
|
+
* When true, MIME-format signals expect blob reference strings instead of
|
|
109
|
+
* base64-encoded data objects. Mixed signals (JTD + MIME) use a discriminated
|
|
110
|
+
* anyOf with `kind: "value" | "reference"`.
|
|
111
|
+
*/
|
|
112
|
+
readonly referenceMode: boolean;
|
|
107
113
|
/**
|
|
108
114
|
* Build a conversion from a JTD schema.
|
|
109
115
|
*
|
|
@@ -134,7 +140,7 @@ export declare class OpenAIConversion<T extends ConvertSuccess = ConvertSuccess>
|
|
|
134
140
|
* @throws If the descriptor has no formats, or a format has neither
|
|
135
141
|
* `jtdSchema` nor `mimeType`.
|
|
136
142
|
*/
|
|
137
|
-
static fromSignal(descriptor: SignalDescriptorJson, sharedDefs?: Record<string, JTDSchemaJson
|
|
143
|
+
static fromSignal(descriptor: SignalDescriptorJson, sharedDefs?: Record<string, JTDSchemaJson>, referenceMode?: boolean): OpenAIConversion<ConvertSuccessJson | ConvertSuccessBinary>;
|
|
138
144
|
/**
|
|
139
145
|
* Build a conversion from multiple signal descriptors.
|
|
140
146
|
*
|
|
@@ -164,7 +170,7 @@ export declare class OpenAIConversion<T extends ConvertSuccess = ConvertSuccess>
|
|
|
164
170
|
* @returns A new {@link OpenAIConversion} with `descriptors` set.
|
|
165
171
|
* @throws If any signal has no formats or an invalid format.
|
|
166
172
|
*/
|
|
167
|
-
static fromSignals(signals: SignalDescriptorJson[], description?: string, label?: string): OpenAIConversion<ConvertSuccessSignals>;
|
|
173
|
+
static fromSignals(signals: SignalDescriptorJson[], description?: string, label?: string, referenceMode?: boolean): OpenAIConversion<ConvertSuccessSignals>;
|
|
168
174
|
/**
|
|
169
175
|
* Restore an {@link OpenAIConversion} from its serialized form.
|
|
170
176
|
*
|
|
@@ -199,10 +205,10 @@ export declare class OpenAIConversion<T extends ConvertSuccess = ConvertSuccess>
|
|
|
199
205
|
* For multi-format signals, the first non-null `format_N` property is
|
|
200
206
|
* selected and converted individually.
|
|
201
207
|
*
|
|
202
|
-
* @param
|
|
208
|
+
* @param value - The value to convert. JSON for JTD, or `{ data, mimeType, filename }` for MIME.
|
|
203
209
|
* @returns A {@link ConvertResult} indicating success or failure with errors.
|
|
204
210
|
*/
|
|
205
|
-
convert: (
|
|
211
|
+
convert: (value: unknown) => T | ConvertFailure;
|
|
206
212
|
/**
|
|
207
213
|
* Produce a JSON-serializable representation of this conversion.
|
|
208
214
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/openai/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EAErB,MAAM,QAAQ,CAAC;AAChB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/openai/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EAErB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ist/schema-utils.d.ts
CHANGED
|
@@ -45,10 +45,84 @@ export interface ConvertFailure {
|
|
|
45
45
|
export type ConvertSuccess = ConvertSuccessJson | ConvertSuccessBinary | ConvertSuccessSignals;
|
|
46
46
|
export type ConvertResult = ConvertSuccess | ConvertFailure;
|
|
47
47
|
export declare function convertJTDOutput(jtdSchema: JTDSchemaJson, json: unknown, coerce: (value: unknown, schema: JTDSchemaJson, defs: Record<string, JTDSchemaJson> | undefined, depth: number) => unknown): ConvertResult;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Wrap a signal's value schema in a discriminated anyOf with two variants:
|
|
50
|
+
* - `{ kind: "value", data: <valueSchema> }` — inline data
|
|
51
|
+
* - `{ kind: "reference", ref: <string> }` — file reference
|
|
52
|
+
*
|
|
53
|
+
* The caller resolves references before calling convert.
|
|
54
|
+
*
|
|
55
|
+
* Returns a plain object — cast to the provider's schema type at the call site.
|
|
56
|
+
*
|
|
57
|
+
* @param valueSchema - The signal's original schema (JTD, MIME, or multi-format anyOf).
|
|
58
|
+
* @param description - Optional signal description to include.
|
|
59
|
+
* @param strict - When false, omits `additionalProperties` (required by GeminiFC).
|
|
60
|
+
*/
|
|
61
|
+
export declare function buildReferenceAnyOf(valueSchema: unknown, description?: string, strict?: boolean): {
|
|
62
|
+
anyOf: unknown[];
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Check if a concrete MIME type matches an accepted MIME pattern.
|
|
66
|
+
*
|
|
67
|
+
* - `*/*` matches everything
|
|
68
|
+
* - `image/*` matches any `image/...` subtype
|
|
69
|
+
* - Exact string match otherwise
|
|
70
|
+
*/
|
|
71
|
+
export declare function mimeTypeMatches(concrete: string, accepted: string): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Convert a MIME-format signal value to dispatch-ready binary SignalData.
|
|
74
|
+
*
|
|
75
|
+
* Accepts two data shapes:
|
|
76
|
+
* - **Inline (from LLM):** `{ data: "<base64>", mimeType: "image/png", filename?: "..." }`
|
|
77
|
+
* - **Resolved (from file reference):** `{ data: Uint8Array, mimeType: "image/png", filename?: "..." }`
|
|
78
|
+
*
|
|
79
|
+
* The input's `mimeType` field is the concrete type and ends up in the result.
|
|
80
|
+
* It is validated against the format's accepted pattern (which may be a wildcard).
|
|
81
|
+
*
|
|
82
|
+
* @param acceptedMimeType - MIME pattern from the signal format declaration.
|
|
83
|
+
* @param value - The signal value to convert.
|
|
84
|
+
*/
|
|
85
|
+
export declare function convertMimeOutput(acceptedMimeType: string, value: unknown): ConvertResult;
|
|
86
|
+
/**
|
|
87
|
+
* Convert a single format's value. Dispatches to JTD or MIME conversion.
|
|
88
|
+
*
|
|
89
|
+
* @param fmt - The signal format (has either `jtdSchema` or `mimeType`).
|
|
90
|
+
* @param value - The signal value. JSON for JTD formats, or `{ data, mimeType, filename }` for MIME.
|
|
91
|
+
* @param coerce - Provider-specific JTD coercion function.
|
|
92
|
+
*/
|
|
93
|
+
export declare function convertSingleFormatOutput(fmt: SignalFormatJson, value: unknown, coerce: (value: unknown, schema: JTDSchemaJson, defs: Record<string, JTDSchemaJson> | undefined, depth: number) => unknown): ConvertResult;
|
|
94
|
+
/**
|
|
95
|
+
* Convert a signal's value against its declared formats.
|
|
96
|
+
*
|
|
97
|
+
* The value is already resolved — this function knows nothing about file
|
|
98
|
+
* references. When `referenceMode` is used, the **caller** handles the
|
|
99
|
+
* `kind` discriminator:
|
|
100
|
+
*
|
|
101
|
+
* - `{ kind: "value", data: <inline> }` → caller extracts `data`, passes here
|
|
102
|
+
* - `{ kind: "reference", ref: "..." }` → caller resolves the ref, passes:
|
|
103
|
+
* - Parsed JSON object (for JTD formats)
|
|
104
|
+
* - `{ data: Uint8Array, mimeType, filename }` (for MIME formats)
|
|
105
|
+
*
|
|
106
|
+
* For **single-format** signals, the value is validated directly.
|
|
107
|
+
* For **multi-format** signals, each format is tried in order (anyOf — first match wins).
|
|
108
|
+
*
|
|
109
|
+
* @param descriptor - The signal descriptor with one or more formats.
|
|
110
|
+
* @param value - The resolved signal value (JSON for JTD, or `{ data, mimeType, filename }` for MIME).
|
|
111
|
+
* @param coerce - Provider-specific JTD coercion function.
|
|
112
|
+
*/
|
|
113
|
+
export declare function convertSignalOutput(descriptor: SignalDescriptorJson, value: unknown, coerce: (value: unknown, schema: JTDSchemaJson, defs: Record<string, JTDSchemaJson> | undefined, depth: number) => unknown): ConvertResult;
|
|
114
|
+
/**
|
|
115
|
+
* Convert multiple signals from a compound output.
|
|
116
|
+
*
|
|
117
|
+
* Expects `input` to be an object keyed by signal name. Each signal's
|
|
118
|
+
* value is passed to {@link convertSignalOutput} — it can be JSON (for
|
|
119
|
+
* JTD formats) or `{ data, mimeType, filename }` (for MIME formats).
|
|
120
|
+
*
|
|
121
|
+
* When using `referenceMode`, the **caller** must unwrap the `kind`
|
|
122
|
+
* discriminator for each signal before calling this function.
|
|
123
|
+
* See {@link convertSignalOutput} for the full reference-mode contract.
|
|
124
|
+
*/
|
|
125
|
+
export declare function convertSignalsOutput(descriptors: SignalDescriptorJson[], input: unknown, coerce: (value: unknown, schema: JTDSchemaJson, defs: Record<string, JTDSchemaJson> | undefined, depth: number) => unknown): ConvertResult;
|
|
52
126
|
/** Minimal shape for $ref-bearing schemas (satisfied by OpenAISchema and AnthropicSchema). */
|
|
53
127
|
interface RefNode {
|
|
54
128
|
properties?: Record<string, RefNode>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-utils.d.ts","sourceRoot":"","sources":["../src/schema-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,OAAO,CAAC;AAOf,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,MAAM,EACN;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAQ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U,CAAC,CAAC,SAAS,OAAO,EAC1C,MAAM,EAAE,CAAC,EACT,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,GACpB,IAAI,CAQN;AAmDD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG;IACtE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC1C,WAAW,EAAE,oBAAoB,EAAE,CAAC;CACrC,CA0FA;AAkBD;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,aAAa,GACjB,MAAM,CAqCR"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mochabug/adapt-sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.12",
|
|
4
4
|
"description": "The API toolkit to facilitate mochabug adapt plugin development",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"@connectrpc/connect": "^2.1.1",
|
|
106
106
|
"fuse.js": "^7.1.0",
|
|
107
107
|
"jtd": "^0.1.1",
|
|
108
|
-
"path-to-regexp": "^8.4.
|
|
108
|
+
"path-to-regexp": "^8.4.2"
|
|
109
109
|
},
|
|
110
110
|
"peerDependencies": {
|
|
111
111
|
"react": "^19.0.0"
|