visual-ai-assertions 0.6.0 → 0.7.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/README.md +20 -18
- package/dist/index.cjs +152 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -6
- package/dist/index.d.ts +53 -6
- package/dist/index.js +150 -42
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
/** Supported reasoning effort levels. */
|
|
4
|
+
declare const ReasoningEffort: {
|
|
5
|
+
readonly LOW: "low";
|
|
6
|
+
readonly MEDIUM: "medium";
|
|
7
|
+
readonly HIGH: "high";
|
|
8
|
+
readonly XHIGH: "xhigh";
|
|
9
|
+
};
|
|
10
|
+
/** Union of valid reasoning effort values, derived from the ReasoningEffort constant. */
|
|
11
|
+
type ReasoningEffortLevel = (typeof ReasoningEffort)[keyof typeof ReasoningEffort];
|
|
3
12
|
/** Supported provider identifiers used internally for pricing and provider selection. */
|
|
4
13
|
declare const Provider: {
|
|
5
14
|
readonly ANTHROPIC: "anthropic";
|
|
@@ -23,6 +32,7 @@ declare const Model: {
|
|
|
23
32
|
};
|
|
24
33
|
readonly Google: {
|
|
25
34
|
readonly GEMINI_3_1_PRO_PREVIEW: "gemini-3.1-pro-preview";
|
|
35
|
+
readonly GEMINI_3_1_FLASH_LITE_PREVIEW: "gemini-3.1-flash-lite-preview";
|
|
26
36
|
readonly GEMINI_3_FLASH_PREVIEW: "gemini-3-flash-preview";
|
|
27
37
|
};
|
|
28
38
|
};
|
|
@@ -124,16 +134,20 @@ type StatementResult = z.infer<typeof StatementResultSchema>;
|
|
|
124
134
|
declare const UsageInfoSchema: z.ZodObject<{
|
|
125
135
|
inputTokens: z.ZodNumber;
|
|
126
136
|
outputTokens: z.ZodNumber;
|
|
137
|
+
/** Reasoning/thinking tokens consumed by the model (informational, typically included within outputTokens). */
|
|
138
|
+
reasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
127
139
|
estimatedCost: z.ZodOptional<z.ZodNumber>;
|
|
128
140
|
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
129
141
|
}, "strip", z.ZodTypeAny, {
|
|
130
142
|
inputTokens: number;
|
|
131
143
|
outputTokens: number;
|
|
144
|
+
reasoningTokens?: number | undefined;
|
|
132
145
|
estimatedCost?: number | undefined;
|
|
133
146
|
durationSeconds?: number | undefined;
|
|
134
147
|
}, {
|
|
135
148
|
inputTokens: number;
|
|
136
149
|
outputTokens: number;
|
|
150
|
+
reasoningTokens?: number | undefined;
|
|
137
151
|
estimatedCost?: number | undefined;
|
|
138
152
|
durationSeconds?: number | undefined;
|
|
139
153
|
}>;
|
|
@@ -146,16 +160,20 @@ declare const CheckResultSchema: z.ZodObject<{
|
|
|
146
160
|
usage: z.ZodOptional<z.ZodObject<{
|
|
147
161
|
inputTokens: z.ZodNumber;
|
|
148
162
|
outputTokens: z.ZodNumber;
|
|
163
|
+
/** Reasoning/thinking tokens consumed by the model (informational, typically included within outputTokens). */
|
|
164
|
+
reasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
149
165
|
estimatedCost: z.ZodOptional<z.ZodNumber>;
|
|
150
166
|
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
151
167
|
}, "strip", z.ZodTypeAny, {
|
|
152
168
|
inputTokens: number;
|
|
153
169
|
outputTokens: number;
|
|
170
|
+
reasoningTokens?: number | undefined;
|
|
154
171
|
estimatedCost?: number | undefined;
|
|
155
172
|
durationSeconds?: number | undefined;
|
|
156
173
|
}, {
|
|
157
174
|
inputTokens: number;
|
|
158
175
|
outputTokens: number;
|
|
176
|
+
reasoningTokens?: number | undefined;
|
|
159
177
|
estimatedCost?: number | undefined;
|
|
160
178
|
durationSeconds?: number | undefined;
|
|
161
179
|
}>>;
|
|
@@ -210,6 +228,7 @@ declare const CheckResultSchema: z.ZodObject<{
|
|
|
210
228
|
usage?: {
|
|
211
229
|
inputTokens: number;
|
|
212
230
|
outputTokens: number;
|
|
231
|
+
reasoningTokens?: number | undefined;
|
|
213
232
|
estimatedCost?: number | undefined;
|
|
214
233
|
durationSeconds?: number | undefined;
|
|
215
234
|
} | undefined;
|
|
@@ -231,6 +250,7 @@ declare const CheckResultSchema: z.ZodObject<{
|
|
|
231
250
|
usage?: {
|
|
232
251
|
inputTokens: number;
|
|
233
252
|
outputTokens: number;
|
|
253
|
+
reasoningTokens?: number | undefined;
|
|
234
254
|
estimatedCost?: number | undefined;
|
|
235
255
|
durationSeconds?: number | undefined;
|
|
236
256
|
} | undefined;
|
|
@@ -257,16 +277,20 @@ declare const CompareResultSchema: z.ZodObject<{
|
|
|
257
277
|
usage: z.ZodOptional<z.ZodObject<{
|
|
258
278
|
inputTokens: z.ZodNumber;
|
|
259
279
|
outputTokens: z.ZodNumber;
|
|
280
|
+
/** Reasoning/thinking tokens consumed by the model (informational, typically included within outputTokens). */
|
|
281
|
+
reasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
260
282
|
estimatedCost: z.ZodOptional<z.ZodNumber>;
|
|
261
283
|
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
262
284
|
}, "strip", z.ZodTypeAny, {
|
|
263
285
|
inputTokens: number;
|
|
264
286
|
outputTokens: number;
|
|
287
|
+
reasoningTokens?: number | undefined;
|
|
265
288
|
estimatedCost?: number | undefined;
|
|
266
289
|
durationSeconds?: number | undefined;
|
|
267
290
|
}, {
|
|
268
291
|
inputTokens: number;
|
|
269
292
|
outputTokens: number;
|
|
293
|
+
reasoningTokens?: number | undefined;
|
|
270
294
|
estimatedCost?: number | undefined;
|
|
271
295
|
durationSeconds?: number | undefined;
|
|
272
296
|
}>>;
|
|
@@ -291,6 +315,7 @@ declare const CompareResultSchema: z.ZodObject<{
|
|
|
291
315
|
usage?: {
|
|
292
316
|
inputTokens: number;
|
|
293
317
|
outputTokens: number;
|
|
318
|
+
reasoningTokens?: number | undefined;
|
|
294
319
|
estimatedCost?: number | undefined;
|
|
295
320
|
durationSeconds?: number | undefined;
|
|
296
321
|
} | undefined;
|
|
@@ -304,6 +329,7 @@ declare const CompareResultSchema: z.ZodObject<{
|
|
|
304
329
|
usage?: {
|
|
305
330
|
inputTokens: number;
|
|
306
331
|
outputTokens: number;
|
|
332
|
+
reasoningTokens?: number | undefined;
|
|
307
333
|
estimatedCost?: number | undefined;
|
|
308
334
|
durationSeconds?: number | undefined;
|
|
309
335
|
} | undefined;
|
|
@@ -334,16 +360,20 @@ declare const AskResultSchema: z.ZodObject<{
|
|
|
334
360
|
usage: z.ZodOptional<z.ZodObject<{
|
|
335
361
|
inputTokens: z.ZodNumber;
|
|
336
362
|
outputTokens: z.ZodNumber;
|
|
363
|
+
/** Reasoning/thinking tokens consumed by the model (informational, typically included within outputTokens). */
|
|
364
|
+
reasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
337
365
|
estimatedCost: z.ZodOptional<z.ZodNumber>;
|
|
338
366
|
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
339
367
|
}, "strip", z.ZodTypeAny, {
|
|
340
368
|
inputTokens: number;
|
|
341
369
|
outputTokens: number;
|
|
370
|
+
reasoningTokens?: number | undefined;
|
|
342
371
|
estimatedCost?: number | undefined;
|
|
343
372
|
durationSeconds?: number | undefined;
|
|
344
373
|
}, {
|
|
345
374
|
inputTokens: number;
|
|
346
375
|
outputTokens: number;
|
|
376
|
+
reasoningTokens?: number | undefined;
|
|
347
377
|
estimatedCost?: number | undefined;
|
|
348
378
|
durationSeconds?: number | undefined;
|
|
349
379
|
}>>;
|
|
@@ -358,6 +388,7 @@ declare const AskResultSchema: z.ZodObject<{
|
|
|
358
388
|
usage?: {
|
|
359
389
|
inputTokens: number;
|
|
360
390
|
outputTokens: number;
|
|
391
|
+
reasoningTokens?: number | undefined;
|
|
361
392
|
estimatedCost?: number | undefined;
|
|
362
393
|
durationSeconds?: number | undefined;
|
|
363
394
|
} | undefined;
|
|
@@ -372,6 +403,7 @@ declare const AskResultSchema: z.ZodObject<{
|
|
|
372
403
|
usage?: {
|
|
373
404
|
inputTokens: number;
|
|
374
405
|
outputTokens: number;
|
|
406
|
+
reasoningTokens?: number | undefined;
|
|
375
407
|
estimatedCost?: number | undefined;
|
|
376
408
|
durationSeconds?: number | undefined;
|
|
377
409
|
} | undefined;
|
|
@@ -384,8 +416,6 @@ type ImageInput = Buffer | Uint8Array | string;
|
|
|
384
416
|
type SupportedMimeType = "image/jpeg" | "image/png" | "image/webp" | "image/gif";
|
|
385
417
|
/** Supported provider identifiers. */
|
|
386
418
|
type ProviderName = "anthropic" | "openai" | "google";
|
|
387
|
-
/** Optional reasoning depth requested from providers that support it. */
|
|
388
|
-
type ReasoningEffort = "low" | "medium" | "high" | "xhigh";
|
|
389
419
|
/**
|
|
390
420
|
* Configuration for creating a visual AI client.
|
|
391
421
|
*
|
|
@@ -407,7 +437,7 @@ interface VisualAIConfig {
|
|
|
407
437
|
/** Log responses to stderr. */
|
|
408
438
|
debugResponse?: boolean;
|
|
409
439
|
maxTokens?: number;
|
|
410
|
-
reasoningEffort?:
|
|
440
|
+
reasoningEffort?: ReasoningEffortLevel;
|
|
411
441
|
trackUsage?: boolean;
|
|
412
442
|
}
|
|
413
443
|
/** Optional instructions for `check()`. */
|
|
@@ -642,7 +672,7 @@ declare function visualAI(config?: VisualAIConfig): VisualAIClient;
|
|
|
642
672
|
/**
|
|
643
673
|
* Discrete error codes exposed by visual-ai-assertions for programmatic handling.
|
|
644
674
|
*/
|
|
645
|
-
type VisualAIErrorCode = "VISUAL_AI_ERROR" | "AUTH_FAILED" | "RATE_LIMITED" | "PROVIDER_ERROR" | "IMAGE_INVALID" | "RESPONSE_PARSE_FAILED" | "CONFIG_INVALID" | "ASSERTION_FAILED";
|
|
675
|
+
type VisualAIErrorCode = "VISUAL_AI_ERROR" | "AUTH_FAILED" | "RATE_LIMITED" | "PROVIDER_ERROR" | "IMAGE_INVALID" | "RESPONSE_PARSE_FAILED" | "RESPONSE_TRUNCATED" | "CONFIG_INVALID" | "ASSERTION_FAILED";
|
|
646
676
|
/**
|
|
647
677
|
* Base class for all library errors.
|
|
648
678
|
*
|
|
@@ -730,6 +760,23 @@ declare class VisualAIResponseParseError extends VisualAIError<"RESPONSE_PARSE_F
|
|
|
730
760
|
rawResponse: string;
|
|
731
761
|
constructor(message: string, rawResponse: string);
|
|
732
762
|
}
|
|
763
|
+
/**
|
|
764
|
+
* Thrown when a provider response is truncated due to token budget exhaustion.
|
|
765
|
+
*
|
|
766
|
+
* Carries `partialResponse` and `maxTokens` so callers can inspect the output
|
|
767
|
+
* and adjust configuration.
|
|
768
|
+
*
|
|
769
|
+
* @example
|
|
770
|
+
* ```ts
|
|
771
|
+
* throw new VisualAITruncationError("Response truncated", partialText, 4096);
|
|
772
|
+
* ```
|
|
773
|
+
*/
|
|
774
|
+
declare class VisualAITruncationError extends VisualAIError<"RESPONSE_TRUNCATED"> {
|
|
775
|
+
readonly code: "RESPONSE_TRUNCATED";
|
|
776
|
+
readonly partialResponse: string;
|
|
777
|
+
readonly maxTokens: number;
|
|
778
|
+
constructor(message: string, partialResponse: string, maxTokens: number);
|
|
779
|
+
}
|
|
733
780
|
/**
|
|
734
781
|
* Thrown when library configuration is missing or invalid.
|
|
735
782
|
*
|
|
@@ -760,7 +807,7 @@ declare class VisualAIAssertionError extends VisualAIError<"ASSERTION_FAILED"> {
|
|
|
760
807
|
/**
|
|
761
808
|
* Union of all concrete error subclasses exposed by the library.
|
|
762
809
|
*/
|
|
763
|
-
type VisualAIKnownError = VisualAIAuthError | VisualAIRateLimitError | VisualAIProviderError | VisualAIImageError | VisualAIResponseParseError | VisualAIConfigError | VisualAIAssertionError;
|
|
810
|
+
type VisualAIKnownError = VisualAIAuthError | VisualAIRateLimitError | VisualAIProviderError | VisualAIImageError | VisualAIResponseParseError | VisualAITruncationError | VisualAIConfigError | VisualAIAssertionError;
|
|
764
811
|
/**
|
|
765
812
|
* Narrows an unknown thrown value to the concrete visual-ai-assertions error union.
|
|
766
813
|
*
|
|
@@ -839,4 +886,4 @@ declare function assertVisualResult(result: CheckResult, label?: string): void;
|
|
|
839
886
|
*/
|
|
840
887
|
declare function assertVisualCompareResult(result: CompareResult, label?: string): void;
|
|
841
888
|
|
|
842
|
-
export { Accessibility, type AccessibilityCheckName, type AccessibilityOptions, type AskOptions, type AskResult, AskResultSchema, type ChangeEntry, ChangeEntrySchema, type CheckOptions, type CheckResult, CheckResultSchema, type CompareOptions, type CompareResult, CompareResultSchema, type Confidence, ConfidenceSchema, Content, type ContentCheckName, type ContentOptions, DEFAULT_MODELS, type DiffImageResult, type ElementsVisibilityOptions, type ImageInput, type Issue, type IssueCategory, IssueCategorySchema, type IssuePriority, IssuePrioritySchema, IssueSchema, type KnownModelName, Layout, type LayoutCheckName, type LayoutOptions, Model, type PageLoadOptions, Provider, type ProviderName, type
|
|
889
|
+
export { Accessibility, type AccessibilityCheckName, type AccessibilityOptions, type AskOptions, type AskResult, AskResultSchema, type ChangeEntry, ChangeEntrySchema, type CheckOptions, type CheckResult, CheckResultSchema, type CompareOptions, type CompareResult, CompareResultSchema, type Confidence, ConfidenceSchema, Content, type ContentCheckName, type ContentOptions, DEFAULT_MODELS, type DiffImageResult, type ElementsVisibilityOptions, type ImageInput, type Issue, type IssueCategory, IssueCategorySchema, type IssuePriority, IssuePrioritySchema, IssueSchema, type KnownModelName, Layout, type LayoutCheckName, type LayoutOptions, Model, type PageLoadOptions, Provider, type ProviderName, ReasoningEffort, type ReasoningEffortLevel, type StatementResult, StatementResultSchema, type SupportedMimeType, type UsageInfo, UsageInfoSchema, VisualAIAssertionError, VisualAIAuthError, type VisualAIClient, type VisualAIConfig, VisualAIConfigError, VisualAIError, type VisualAIErrorCode, VisualAIImageError, type VisualAIKnownError, VisualAIProviderError, VisualAIRateLimitError, VisualAIResponseParseError, VisualAITruncationError, assertVisualCompareResult, assertVisualResult, formatCheckResult, formatCompareResult, isVisualAIKnownError, visualAI };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
/** Supported reasoning effort levels. */
|
|
4
|
+
declare const ReasoningEffort: {
|
|
5
|
+
readonly LOW: "low";
|
|
6
|
+
readonly MEDIUM: "medium";
|
|
7
|
+
readonly HIGH: "high";
|
|
8
|
+
readonly XHIGH: "xhigh";
|
|
9
|
+
};
|
|
10
|
+
/** Union of valid reasoning effort values, derived from the ReasoningEffort constant. */
|
|
11
|
+
type ReasoningEffortLevel = (typeof ReasoningEffort)[keyof typeof ReasoningEffort];
|
|
3
12
|
/** Supported provider identifiers used internally for pricing and provider selection. */
|
|
4
13
|
declare const Provider: {
|
|
5
14
|
readonly ANTHROPIC: "anthropic";
|
|
@@ -23,6 +32,7 @@ declare const Model: {
|
|
|
23
32
|
};
|
|
24
33
|
readonly Google: {
|
|
25
34
|
readonly GEMINI_3_1_PRO_PREVIEW: "gemini-3.1-pro-preview";
|
|
35
|
+
readonly GEMINI_3_1_FLASH_LITE_PREVIEW: "gemini-3.1-flash-lite-preview";
|
|
26
36
|
readonly GEMINI_3_FLASH_PREVIEW: "gemini-3-flash-preview";
|
|
27
37
|
};
|
|
28
38
|
};
|
|
@@ -124,16 +134,20 @@ type StatementResult = z.infer<typeof StatementResultSchema>;
|
|
|
124
134
|
declare const UsageInfoSchema: z.ZodObject<{
|
|
125
135
|
inputTokens: z.ZodNumber;
|
|
126
136
|
outputTokens: z.ZodNumber;
|
|
137
|
+
/** Reasoning/thinking tokens consumed by the model (informational, typically included within outputTokens). */
|
|
138
|
+
reasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
127
139
|
estimatedCost: z.ZodOptional<z.ZodNumber>;
|
|
128
140
|
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
129
141
|
}, "strip", z.ZodTypeAny, {
|
|
130
142
|
inputTokens: number;
|
|
131
143
|
outputTokens: number;
|
|
144
|
+
reasoningTokens?: number | undefined;
|
|
132
145
|
estimatedCost?: number | undefined;
|
|
133
146
|
durationSeconds?: number | undefined;
|
|
134
147
|
}, {
|
|
135
148
|
inputTokens: number;
|
|
136
149
|
outputTokens: number;
|
|
150
|
+
reasoningTokens?: number | undefined;
|
|
137
151
|
estimatedCost?: number | undefined;
|
|
138
152
|
durationSeconds?: number | undefined;
|
|
139
153
|
}>;
|
|
@@ -146,16 +160,20 @@ declare const CheckResultSchema: z.ZodObject<{
|
|
|
146
160
|
usage: z.ZodOptional<z.ZodObject<{
|
|
147
161
|
inputTokens: z.ZodNumber;
|
|
148
162
|
outputTokens: z.ZodNumber;
|
|
163
|
+
/** Reasoning/thinking tokens consumed by the model (informational, typically included within outputTokens). */
|
|
164
|
+
reasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
149
165
|
estimatedCost: z.ZodOptional<z.ZodNumber>;
|
|
150
166
|
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
151
167
|
}, "strip", z.ZodTypeAny, {
|
|
152
168
|
inputTokens: number;
|
|
153
169
|
outputTokens: number;
|
|
170
|
+
reasoningTokens?: number | undefined;
|
|
154
171
|
estimatedCost?: number | undefined;
|
|
155
172
|
durationSeconds?: number | undefined;
|
|
156
173
|
}, {
|
|
157
174
|
inputTokens: number;
|
|
158
175
|
outputTokens: number;
|
|
176
|
+
reasoningTokens?: number | undefined;
|
|
159
177
|
estimatedCost?: number | undefined;
|
|
160
178
|
durationSeconds?: number | undefined;
|
|
161
179
|
}>>;
|
|
@@ -210,6 +228,7 @@ declare const CheckResultSchema: z.ZodObject<{
|
|
|
210
228
|
usage?: {
|
|
211
229
|
inputTokens: number;
|
|
212
230
|
outputTokens: number;
|
|
231
|
+
reasoningTokens?: number | undefined;
|
|
213
232
|
estimatedCost?: number | undefined;
|
|
214
233
|
durationSeconds?: number | undefined;
|
|
215
234
|
} | undefined;
|
|
@@ -231,6 +250,7 @@ declare const CheckResultSchema: z.ZodObject<{
|
|
|
231
250
|
usage?: {
|
|
232
251
|
inputTokens: number;
|
|
233
252
|
outputTokens: number;
|
|
253
|
+
reasoningTokens?: number | undefined;
|
|
234
254
|
estimatedCost?: number | undefined;
|
|
235
255
|
durationSeconds?: number | undefined;
|
|
236
256
|
} | undefined;
|
|
@@ -257,16 +277,20 @@ declare const CompareResultSchema: z.ZodObject<{
|
|
|
257
277
|
usage: z.ZodOptional<z.ZodObject<{
|
|
258
278
|
inputTokens: z.ZodNumber;
|
|
259
279
|
outputTokens: z.ZodNumber;
|
|
280
|
+
/** Reasoning/thinking tokens consumed by the model (informational, typically included within outputTokens). */
|
|
281
|
+
reasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
260
282
|
estimatedCost: z.ZodOptional<z.ZodNumber>;
|
|
261
283
|
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
262
284
|
}, "strip", z.ZodTypeAny, {
|
|
263
285
|
inputTokens: number;
|
|
264
286
|
outputTokens: number;
|
|
287
|
+
reasoningTokens?: number | undefined;
|
|
265
288
|
estimatedCost?: number | undefined;
|
|
266
289
|
durationSeconds?: number | undefined;
|
|
267
290
|
}, {
|
|
268
291
|
inputTokens: number;
|
|
269
292
|
outputTokens: number;
|
|
293
|
+
reasoningTokens?: number | undefined;
|
|
270
294
|
estimatedCost?: number | undefined;
|
|
271
295
|
durationSeconds?: number | undefined;
|
|
272
296
|
}>>;
|
|
@@ -291,6 +315,7 @@ declare const CompareResultSchema: z.ZodObject<{
|
|
|
291
315
|
usage?: {
|
|
292
316
|
inputTokens: number;
|
|
293
317
|
outputTokens: number;
|
|
318
|
+
reasoningTokens?: number | undefined;
|
|
294
319
|
estimatedCost?: number | undefined;
|
|
295
320
|
durationSeconds?: number | undefined;
|
|
296
321
|
} | undefined;
|
|
@@ -304,6 +329,7 @@ declare const CompareResultSchema: z.ZodObject<{
|
|
|
304
329
|
usage?: {
|
|
305
330
|
inputTokens: number;
|
|
306
331
|
outputTokens: number;
|
|
332
|
+
reasoningTokens?: number | undefined;
|
|
307
333
|
estimatedCost?: number | undefined;
|
|
308
334
|
durationSeconds?: number | undefined;
|
|
309
335
|
} | undefined;
|
|
@@ -334,16 +360,20 @@ declare const AskResultSchema: z.ZodObject<{
|
|
|
334
360
|
usage: z.ZodOptional<z.ZodObject<{
|
|
335
361
|
inputTokens: z.ZodNumber;
|
|
336
362
|
outputTokens: z.ZodNumber;
|
|
363
|
+
/** Reasoning/thinking tokens consumed by the model (informational, typically included within outputTokens). */
|
|
364
|
+
reasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
337
365
|
estimatedCost: z.ZodOptional<z.ZodNumber>;
|
|
338
366
|
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
339
367
|
}, "strip", z.ZodTypeAny, {
|
|
340
368
|
inputTokens: number;
|
|
341
369
|
outputTokens: number;
|
|
370
|
+
reasoningTokens?: number | undefined;
|
|
342
371
|
estimatedCost?: number | undefined;
|
|
343
372
|
durationSeconds?: number | undefined;
|
|
344
373
|
}, {
|
|
345
374
|
inputTokens: number;
|
|
346
375
|
outputTokens: number;
|
|
376
|
+
reasoningTokens?: number | undefined;
|
|
347
377
|
estimatedCost?: number | undefined;
|
|
348
378
|
durationSeconds?: number | undefined;
|
|
349
379
|
}>>;
|
|
@@ -358,6 +388,7 @@ declare const AskResultSchema: z.ZodObject<{
|
|
|
358
388
|
usage?: {
|
|
359
389
|
inputTokens: number;
|
|
360
390
|
outputTokens: number;
|
|
391
|
+
reasoningTokens?: number | undefined;
|
|
361
392
|
estimatedCost?: number | undefined;
|
|
362
393
|
durationSeconds?: number | undefined;
|
|
363
394
|
} | undefined;
|
|
@@ -372,6 +403,7 @@ declare const AskResultSchema: z.ZodObject<{
|
|
|
372
403
|
usage?: {
|
|
373
404
|
inputTokens: number;
|
|
374
405
|
outputTokens: number;
|
|
406
|
+
reasoningTokens?: number | undefined;
|
|
375
407
|
estimatedCost?: number | undefined;
|
|
376
408
|
durationSeconds?: number | undefined;
|
|
377
409
|
} | undefined;
|
|
@@ -384,8 +416,6 @@ type ImageInput = Buffer | Uint8Array | string;
|
|
|
384
416
|
type SupportedMimeType = "image/jpeg" | "image/png" | "image/webp" | "image/gif";
|
|
385
417
|
/** Supported provider identifiers. */
|
|
386
418
|
type ProviderName = "anthropic" | "openai" | "google";
|
|
387
|
-
/** Optional reasoning depth requested from providers that support it. */
|
|
388
|
-
type ReasoningEffort = "low" | "medium" | "high" | "xhigh";
|
|
389
419
|
/**
|
|
390
420
|
* Configuration for creating a visual AI client.
|
|
391
421
|
*
|
|
@@ -407,7 +437,7 @@ interface VisualAIConfig {
|
|
|
407
437
|
/** Log responses to stderr. */
|
|
408
438
|
debugResponse?: boolean;
|
|
409
439
|
maxTokens?: number;
|
|
410
|
-
reasoningEffort?:
|
|
440
|
+
reasoningEffort?: ReasoningEffortLevel;
|
|
411
441
|
trackUsage?: boolean;
|
|
412
442
|
}
|
|
413
443
|
/** Optional instructions for `check()`. */
|
|
@@ -642,7 +672,7 @@ declare function visualAI(config?: VisualAIConfig): VisualAIClient;
|
|
|
642
672
|
/**
|
|
643
673
|
* Discrete error codes exposed by visual-ai-assertions for programmatic handling.
|
|
644
674
|
*/
|
|
645
|
-
type VisualAIErrorCode = "VISUAL_AI_ERROR" | "AUTH_FAILED" | "RATE_LIMITED" | "PROVIDER_ERROR" | "IMAGE_INVALID" | "RESPONSE_PARSE_FAILED" | "CONFIG_INVALID" | "ASSERTION_FAILED";
|
|
675
|
+
type VisualAIErrorCode = "VISUAL_AI_ERROR" | "AUTH_FAILED" | "RATE_LIMITED" | "PROVIDER_ERROR" | "IMAGE_INVALID" | "RESPONSE_PARSE_FAILED" | "RESPONSE_TRUNCATED" | "CONFIG_INVALID" | "ASSERTION_FAILED";
|
|
646
676
|
/**
|
|
647
677
|
* Base class for all library errors.
|
|
648
678
|
*
|
|
@@ -730,6 +760,23 @@ declare class VisualAIResponseParseError extends VisualAIError<"RESPONSE_PARSE_F
|
|
|
730
760
|
rawResponse: string;
|
|
731
761
|
constructor(message: string, rawResponse: string);
|
|
732
762
|
}
|
|
763
|
+
/**
|
|
764
|
+
* Thrown when a provider response is truncated due to token budget exhaustion.
|
|
765
|
+
*
|
|
766
|
+
* Carries `partialResponse` and `maxTokens` so callers can inspect the output
|
|
767
|
+
* and adjust configuration.
|
|
768
|
+
*
|
|
769
|
+
* @example
|
|
770
|
+
* ```ts
|
|
771
|
+
* throw new VisualAITruncationError("Response truncated", partialText, 4096);
|
|
772
|
+
* ```
|
|
773
|
+
*/
|
|
774
|
+
declare class VisualAITruncationError extends VisualAIError<"RESPONSE_TRUNCATED"> {
|
|
775
|
+
readonly code: "RESPONSE_TRUNCATED";
|
|
776
|
+
readonly partialResponse: string;
|
|
777
|
+
readonly maxTokens: number;
|
|
778
|
+
constructor(message: string, partialResponse: string, maxTokens: number);
|
|
779
|
+
}
|
|
733
780
|
/**
|
|
734
781
|
* Thrown when library configuration is missing or invalid.
|
|
735
782
|
*
|
|
@@ -760,7 +807,7 @@ declare class VisualAIAssertionError extends VisualAIError<"ASSERTION_FAILED"> {
|
|
|
760
807
|
/**
|
|
761
808
|
* Union of all concrete error subclasses exposed by the library.
|
|
762
809
|
*/
|
|
763
|
-
type VisualAIKnownError = VisualAIAuthError | VisualAIRateLimitError | VisualAIProviderError | VisualAIImageError | VisualAIResponseParseError | VisualAIConfigError | VisualAIAssertionError;
|
|
810
|
+
type VisualAIKnownError = VisualAIAuthError | VisualAIRateLimitError | VisualAIProviderError | VisualAIImageError | VisualAIResponseParseError | VisualAITruncationError | VisualAIConfigError | VisualAIAssertionError;
|
|
764
811
|
/**
|
|
765
812
|
* Narrows an unknown thrown value to the concrete visual-ai-assertions error union.
|
|
766
813
|
*
|
|
@@ -839,4 +886,4 @@ declare function assertVisualResult(result: CheckResult, label?: string): void;
|
|
|
839
886
|
*/
|
|
840
887
|
declare function assertVisualCompareResult(result: CompareResult, label?: string): void;
|
|
841
888
|
|
|
842
|
-
export { Accessibility, type AccessibilityCheckName, type AccessibilityOptions, type AskOptions, type AskResult, AskResultSchema, type ChangeEntry, ChangeEntrySchema, type CheckOptions, type CheckResult, CheckResultSchema, type CompareOptions, type CompareResult, CompareResultSchema, type Confidence, ConfidenceSchema, Content, type ContentCheckName, type ContentOptions, DEFAULT_MODELS, type DiffImageResult, type ElementsVisibilityOptions, type ImageInput, type Issue, type IssueCategory, IssueCategorySchema, type IssuePriority, IssuePrioritySchema, IssueSchema, type KnownModelName, Layout, type LayoutCheckName, type LayoutOptions, Model, type PageLoadOptions, Provider, type ProviderName, type
|
|
889
|
+
export { Accessibility, type AccessibilityCheckName, type AccessibilityOptions, type AskOptions, type AskResult, AskResultSchema, type ChangeEntry, ChangeEntrySchema, type CheckOptions, type CheckResult, CheckResultSchema, type CompareOptions, type CompareResult, CompareResultSchema, type Confidence, ConfidenceSchema, Content, type ContentCheckName, type ContentOptions, DEFAULT_MODELS, type DiffImageResult, type ElementsVisibilityOptions, type ImageInput, type Issue, type IssueCategory, IssueCategorySchema, type IssuePriority, IssuePrioritySchema, IssueSchema, type KnownModelName, Layout, type LayoutCheckName, type LayoutOptions, Model, type PageLoadOptions, Provider, type ProviderName, ReasoningEffort, type ReasoningEffortLevel, type StatementResult, StatementResultSchema, type SupportedMimeType, type UsageInfo, UsageInfoSchema, VisualAIAssertionError, VisualAIAuthError, type VisualAIClient, type VisualAIConfig, VisualAIConfigError, VisualAIError, type VisualAIErrorCode, VisualAIImageError, type VisualAIKnownError, VisualAIProviderError, VisualAIRateLimitError, VisualAIResponseParseError, VisualAITruncationError, assertVisualCompareResult, assertVisualResult, formatCheckResult, formatCompareResult, isVisualAIKnownError, visualAI };
|