visual-ai-assertions 0.4.0 → 0.5.0
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 +6 -10
- package/dist/index.cjs +12 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -10
- package/dist/index.d.ts +8 -10
- package/dist/index.js +12 -26
- package/dist/index.js.map +1 -1
- package/package.json +20 -12
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
/** Supported provider identifiers for
|
|
3
|
+
/** Supported provider identifiers used internally for pricing and provider selection. */
|
|
4
4
|
declare const Provider: {
|
|
5
5
|
readonly ANTHROPIC: "anthropic";
|
|
6
6
|
readonly OPENAI: "openai";
|
|
@@ -16,6 +16,8 @@ declare const Model: {
|
|
|
16
16
|
readonly OpenAI: {
|
|
17
17
|
readonly GPT_5_4: "gpt-5.4";
|
|
18
18
|
readonly GPT_5_4_PRO: "gpt-5.4-pro";
|
|
19
|
+
readonly GPT_5_4_MINI: "gpt-5.4-mini";
|
|
20
|
+
readonly GPT_5_4_NANO: "gpt-5.4-nano";
|
|
19
21
|
readonly GPT_5_2: "gpt-5.2";
|
|
20
22
|
readonly GPT_5_MINI: "gpt-5-mini";
|
|
21
23
|
};
|
|
@@ -29,11 +31,9 @@ type KnownModelName = (typeof Model.Anthropic)[keyof typeof Model.Anthropic] | (
|
|
|
29
31
|
/** Default model selection used when a caller omits `config.model`. */
|
|
30
32
|
declare const DEFAULT_MODELS: {
|
|
31
33
|
readonly anthropic: "claude-sonnet-4-6";
|
|
32
|
-
readonly openai: "gpt-5-mini";
|
|
34
|
+
readonly openai: "gpt-5.4-mini";
|
|
33
35
|
readonly google: "gemini-3-flash-preview";
|
|
34
36
|
};
|
|
35
|
-
/** List of accepted provider names for validation and public consumption. */
|
|
36
|
-
declare const VALID_PROVIDERS: readonly ProviderName[];
|
|
37
37
|
/** Built-in content checks available through `client.content()`. */
|
|
38
38
|
declare const Content: {
|
|
39
39
|
/** Detects Lorem ipsum, TODO, TBD, and similar placeholder text */
|
|
@@ -392,14 +392,12 @@ type ReasoningEffort = "low" | "medium" | "high" | "xhigh";
|
|
|
392
392
|
* @example
|
|
393
393
|
* ```ts
|
|
394
394
|
* const client = visualAI({
|
|
395
|
-
* provider: "openai",
|
|
396
395
|
* model: "gpt-5-mini",
|
|
397
396
|
* apiKey: process.env.OPENAI_API_KEY,
|
|
398
397
|
* });
|
|
399
398
|
* ```
|
|
400
399
|
*/
|
|
401
400
|
interface VisualAIConfig {
|
|
402
|
-
provider?: ProviderName;
|
|
403
401
|
apiKey?: string;
|
|
404
402
|
model?: string;
|
|
405
403
|
debug?: boolean;
|
|
@@ -458,7 +456,7 @@ interface ContentOptions {
|
|
|
458
456
|
*
|
|
459
457
|
* @example
|
|
460
458
|
* ```ts
|
|
461
|
-
* const client = visualAI({
|
|
459
|
+
* const client = visualAI({ model: "gpt-5-mini" });
|
|
462
460
|
* const result = await client.check("./tests/fixtures/small.png", "The button is visible");
|
|
463
461
|
* ```
|
|
464
462
|
*/
|
|
@@ -608,7 +606,7 @@ interface VisualAIClient {
|
|
|
608
606
|
/**
|
|
609
607
|
* Creates a configured visual AI client.
|
|
610
608
|
*
|
|
611
|
-
* @param config
|
|
609
|
+
* @param config Model selection and runtime options for subsequent requests.
|
|
612
610
|
* @returns A `VisualAIClient` instance with check, compare, ask, and template helpers.
|
|
613
611
|
* @throws {VisualAIConfigError} When the provider or model configuration is invalid.
|
|
614
612
|
* @throws {VisualAIAuthError} When required API credentials are missing.
|
|
@@ -619,7 +617,7 @@ interface VisualAIClient {
|
|
|
619
617
|
*
|
|
620
618
|
* test("hero loads correctly", async ({ page }) => {
|
|
621
619
|
* const client = visualAI({
|
|
622
|
-
*
|
|
620
|
+
* model: "gpt-5-mini",
|
|
623
621
|
* apiKey: process.env.OPENAI_API_KEY,
|
|
624
622
|
* });
|
|
625
623
|
*
|
|
@@ -836,4 +834,4 @@ declare function assertVisualResult(result: CheckResult, label?: string): void;
|
|
|
836
834
|
*/
|
|
837
835
|
declare function assertVisualCompareResult(result: CompareResult, label?: string): void;
|
|
838
836
|
|
|
839
|
-
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 ReasoningEffort, type StatementResult, StatementResultSchema, type SupportedMimeType, type UsageInfo, UsageInfoSchema,
|
|
837
|
+
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 ReasoningEffort, type StatementResult, StatementResultSchema, type SupportedMimeType, type UsageInfo, UsageInfoSchema, VisualAIAssertionError, VisualAIAuthError, type VisualAIClient, type VisualAIConfig, VisualAIConfigError, VisualAIError, type VisualAIErrorCode, VisualAIImageError, type VisualAIKnownError, VisualAIProviderError, VisualAIRateLimitError, VisualAIResponseParseError, assertVisualCompareResult, assertVisualResult, formatCheckResult, formatCompareResult, isVisualAIKnownError, visualAI };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
/** Supported provider identifiers for
|
|
3
|
+
/** Supported provider identifiers used internally for pricing and provider selection. */
|
|
4
4
|
declare const Provider: {
|
|
5
5
|
readonly ANTHROPIC: "anthropic";
|
|
6
6
|
readonly OPENAI: "openai";
|
|
@@ -16,6 +16,8 @@ declare const Model: {
|
|
|
16
16
|
readonly OpenAI: {
|
|
17
17
|
readonly GPT_5_4: "gpt-5.4";
|
|
18
18
|
readonly GPT_5_4_PRO: "gpt-5.4-pro";
|
|
19
|
+
readonly GPT_5_4_MINI: "gpt-5.4-mini";
|
|
20
|
+
readonly GPT_5_4_NANO: "gpt-5.4-nano";
|
|
19
21
|
readonly GPT_5_2: "gpt-5.2";
|
|
20
22
|
readonly GPT_5_MINI: "gpt-5-mini";
|
|
21
23
|
};
|
|
@@ -29,11 +31,9 @@ type KnownModelName = (typeof Model.Anthropic)[keyof typeof Model.Anthropic] | (
|
|
|
29
31
|
/** Default model selection used when a caller omits `config.model`. */
|
|
30
32
|
declare const DEFAULT_MODELS: {
|
|
31
33
|
readonly anthropic: "claude-sonnet-4-6";
|
|
32
|
-
readonly openai: "gpt-5-mini";
|
|
34
|
+
readonly openai: "gpt-5.4-mini";
|
|
33
35
|
readonly google: "gemini-3-flash-preview";
|
|
34
36
|
};
|
|
35
|
-
/** List of accepted provider names for validation and public consumption. */
|
|
36
|
-
declare const VALID_PROVIDERS: readonly ProviderName[];
|
|
37
37
|
/** Built-in content checks available through `client.content()`. */
|
|
38
38
|
declare const Content: {
|
|
39
39
|
/** Detects Lorem ipsum, TODO, TBD, and similar placeholder text */
|
|
@@ -392,14 +392,12 @@ type ReasoningEffort = "low" | "medium" | "high" | "xhigh";
|
|
|
392
392
|
* @example
|
|
393
393
|
* ```ts
|
|
394
394
|
* const client = visualAI({
|
|
395
|
-
* provider: "openai",
|
|
396
395
|
* model: "gpt-5-mini",
|
|
397
396
|
* apiKey: process.env.OPENAI_API_KEY,
|
|
398
397
|
* });
|
|
399
398
|
* ```
|
|
400
399
|
*/
|
|
401
400
|
interface VisualAIConfig {
|
|
402
|
-
provider?: ProviderName;
|
|
403
401
|
apiKey?: string;
|
|
404
402
|
model?: string;
|
|
405
403
|
debug?: boolean;
|
|
@@ -458,7 +456,7 @@ interface ContentOptions {
|
|
|
458
456
|
*
|
|
459
457
|
* @example
|
|
460
458
|
* ```ts
|
|
461
|
-
* const client = visualAI({
|
|
459
|
+
* const client = visualAI({ model: "gpt-5-mini" });
|
|
462
460
|
* const result = await client.check("./tests/fixtures/small.png", "The button is visible");
|
|
463
461
|
* ```
|
|
464
462
|
*/
|
|
@@ -608,7 +606,7 @@ interface VisualAIClient {
|
|
|
608
606
|
/**
|
|
609
607
|
* Creates a configured visual AI client.
|
|
610
608
|
*
|
|
611
|
-
* @param config
|
|
609
|
+
* @param config Model selection and runtime options for subsequent requests.
|
|
612
610
|
* @returns A `VisualAIClient` instance with check, compare, ask, and template helpers.
|
|
613
611
|
* @throws {VisualAIConfigError} When the provider or model configuration is invalid.
|
|
614
612
|
* @throws {VisualAIAuthError} When required API credentials are missing.
|
|
@@ -619,7 +617,7 @@ interface VisualAIClient {
|
|
|
619
617
|
*
|
|
620
618
|
* test("hero loads correctly", async ({ page }) => {
|
|
621
619
|
* const client = visualAI({
|
|
622
|
-
*
|
|
620
|
+
* model: "gpt-5-mini",
|
|
623
621
|
* apiKey: process.env.OPENAI_API_KEY,
|
|
624
622
|
* });
|
|
625
623
|
*
|
|
@@ -836,4 +834,4 @@ declare function assertVisualResult(result: CheckResult, label?: string): void;
|
|
|
836
834
|
*/
|
|
837
835
|
declare function assertVisualCompareResult(result: CompareResult, label?: string): void;
|
|
838
836
|
|
|
839
|
-
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 ReasoningEffort, type StatementResult, StatementResultSchema, type SupportedMimeType, type UsageInfo, UsageInfoSchema,
|
|
837
|
+
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 ReasoningEffort, type StatementResult, StatementResultSchema, type SupportedMimeType, type UsageInfo, UsageInfoSchema, VisualAIAssertionError, VisualAIAuthError, type VisualAIClient, type VisualAIConfig, VisualAIConfigError, VisualAIError, type VisualAIErrorCode, VisualAIImageError, type VisualAIKnownError, VisualAIProviderError, VisualAIRateLimitError, VisualAIResponseParseError, assertVisualCompareResult, assertVisualResult, formatCheckResult, formatCompareResult, isVisualAIKnownError, visualAI };
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,8 @@ var Model = {
|
|
|
13
13
|
OpenAI: {
|
|
14
14
|
GPT_5_4: "gpt-5.4",
|
|
15
15
|
GPT_5_4_PRO: "gpt-5.4-pro",
|
|
16
|
+
GPT_5_4_MINI: "gpt-5.4-mini",
|
|
17
|
+
GPT_5_4_NANO: "gpt-5.4-nano",
|
|
16
18
|
GPT_5_2: "gpt-5.2",
|
|
17
19
|
GPT_5_MINI: "gpt-5-mini"
|
|
18
20
|
},
|
|
@@ -23,7 +25,7 @@ var Model = {
|
|
|
23
25
|
};
|
|
24
26
|
var DEFAULT_MODELS = {
|
|
25
27
|
[Provider.ANTHROPIC]: Model.Anthropic.SONNET_4_6,
|
|
26
|
-
[Provider.OPENAI]: Model.OpenAI.
|
|
28
|
+
[Provider.OPENAI]: Model.OpenAI.GPT_5_4_MINI,
|
|
27
29
|
[Provider.GOOGLE]: Model.Google.GEMINI_3_FLASH_PREVIEW
|
|
28
30
|
};
|
|
29
31
|
var DEFAULT_MAX_TOKENS = 4096;
|
|
@@ -660,23 +662,6 @@ function inferProviderFromModel(model) {
|
|
|
660
662
|
return prefixMatch?.[1];
|
|
661
663
|
}
|
|
662
664
|
function resolveProvider(config) {
|
|
663
|
-
if (config.provider) {
|
|
664
|
-
if (!VALID_PROVIDERS.includes(config.provider)) {
|
|
665
|
-
throw new VisualAIConfigError(
|
|
666
|
-
`Unknown provider: "${config.provider}". Supported: ${VALID_PROVIDERS.join(", ")}`
|
|
667
|
-
);
|
|
668
|
-
}
|
|
669
|
-
return config.provider;
|
|
670
|
-
}
|
|
671
|
-
const envProvider = process.env.VISUAL_AI_PROVIDER;
|
|
672
|
-
if (envProvider) {
|
|
673
|
-
if (VALID_PROVIDERS.includes(envProvider)) {
|
|
674
|
-
return envProvider;
|
|
675
|
-
}
|
|
676
|
-
throw new VisualAIConfigError(
|
|
677
|
-
`Invalid VISUAL_AI_PROVIDER: "${envProvider}". Supported: ${VALID_PROVIDERS.join(", ")}`
|
|
678
|
-
);
|
|
679
|
-
}
|
|
680
665
|
const model = config.model ?? process.env.VISUAL_AI_MODEL;
|
|
681
666
|
if (model) {
|
|
682
667
|
const inferred = inferProviderFromModel(model);
|
|
@@ -690,7 +675,7 @@ function resolveProvider(config) {
|
|
|
690
675
|
const detected = apiKeyProviderMap.find(([key]) => process.env[key]);
|
|
691
676
|
if (detected) return detected[1];
|
|
692
677
|
throw new VisualAIConfigError(
|
|
693
|
-
"
|
|
678
|
+
"Cannot determine provider. Set a model name (config or VISUAL_AI_MODEL) or an API key env variable (ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_API_KEY)."
|
|
694
679
|
);
|
|
695
680
|
}
|
|
696
681
|
function parseBooleanEnv(envName, value) {
|
|
@@ -705,12 +690,6 @@ function parseBooleanEnv(envName, value) {
|
|
|
705
690
|
function resolveConfig(config) {
|
|
706
691
|
const provider = resolveProvider(config);
|
|
707
692
|
const model = config.model ?? process.env.VISUAL_AI_MODEL ?? DEFAULT_MODELS[provider];
|
|
708
|
-
const modelProvider = inferProviderFromModel(model);
|
|
709
|
-
if (modelProvider && modelProvider !== provider) {
|
|
710
|
-
throw new VisualAIConfigError(
|
|
711
|
-
`Model "${model}" appears to be a ${modelProvider} model, but provider is "${provider}". Either change the provider or use a ${provider}-compatible model.`
|
|
712
|
-
);
|
|
713
|
-
}
|
|
714
693
|
return {
|
|
715
694
|
provider,
|
|
716
695
|
apiKey: config.apiKey,
|
|
@@ -749,6 +728,14 @@ var PRICING_TABLE = {
|
|
|
749
728
|
inputPricePerToken: 1.75 / PER_MILLION,
|
|
750
729
|
outputPricePerToken: 14 / PER_MILLION
|
|
751
730
|
},
|
|
731
|
+
[`${Provider.OPENAI}:${Model.OpenAI.GPT_5_4_MINI}`]: {
|
|
732
|
+
inputPricePerToken: 0.75 / PER_MILLION,
|
|
733
|
+
outputPricePerToken: 4.5 / PER_MILLION
|
|
734
|
+
},
|
|
735
|
+
[`${Provider.OPENAI}:${Model.OpenAI.GPT_5_4_NANO}`]: {
|
|
736
|
+
inputPricePerToken: 0.2 / PER_MILLION,
|
|
737
|
+
outputPricePerToken: 1.25 / PER_MILLION
|
|
738
|
+
},
|
|
752
739
|
[`${Provider.OPENAI}:${Model.OpenAI.GPT_5_MINI}`]: {
|
|
753
740
|
inputPricePerToken: 0.25 / PER_MILLION,
|
|
754
741
|
outputPricePerToken: 2 / PER_MILLION
|
|
@@ -1330,7 +1317,6 @@ export {
|
|
|
1330
1317
|
Provider,
|
|
1331
1318
|
StatementResultSchema,
|
|
1332
1319
|
UsageInfoSchema,
|
|
1333
|
-
VALID_PROVIDERS,
|
|
1334
1320
|
VisualAIAssertionError,
|
|
1335
1321
|
VisualAIAuthError,
|
|
1336
1322
|
VisualAIConfigError,
|