@dev-blinq/bvt-playwright-js 1.0.0-dev.2 → 1.0.0-dev.4

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.
Files changed (4) hide show
  1. package/index.d.mts +530 -178
  2. package/index.mjs +6377 -1761
  3. package/index.mjs.map +1 -1
  4. package/package.json +1 -1
package/index.d.mts CHANGED
@@ -13,6 +13,85 @@ declare const apiResponseSnapshotSchema: z.ZodObject<{
13
13
  bodyJson: z.ZodOptional<z.ZodUnknown>;
14
14
  }, z.core.$strict>;
15
15
  type ApiResponseSnapshot = z.infer<typeof apiResponseSnapshotSchema>;
16
+ declare const apiRequestSchema: z.ZodObject<{
17
+ method: z.ZodEnum<{
18
+ GET: "GET";
19
+ POST: "POST";
20
+ PUT: "PUT";
21
+ PATCH: "PATCH";
22
+ DELETE: "DELETE";
23
+ }>;
24
+ url: z.ZodString;
25
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
26
+ body: z.ZodOptional<z.ZodString>;
27
+ saveAs: z.ZodOptional<z.ZodString>;
28
+ capturedResponse: z.ZodOptional<z.ZodObject<{
29
+ status: z.ZodNumber;
30
+ statusText: z.ZodString;
31
+ timeMs: z.ZodNumber;
32
+ sizeBytes: z.ZodNumber;
33
+ headers: z.ZodRecord<z.ZodString, z.ZodString>;
34
+ bodyText: z.ZodString;
35
+ bodyJson: z.ZodOptional<z.ZodUnknown>;
36
+ }, z.core.$strict>>;
37
+ options: z.ZodOptional<z.ZodObject<{
38
+ timeout: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
39
+ }, z.core.$strict>>;
40
+ }, z.core.$strict>;
41
+ type ApiRequest = z.infer<typeof apiRequestSchema>;
42
+ declare const apiResponseAssertionCommandData: z.ZodDiscriminatedUnion<[
43
+ z.ZodObject<{
44
+ operator: z.ZodEnum<{
45
+ equals: "equals";
46
+ notEquals: "notEquals";
47
+ contains: "contains";
48
+ lessThan: "lessThan";
49
+ greaterThan: "greaterThan";
50
+ exists: "exists";
51
+ }>;
52
+ target: z.ZodLiteral<"status">;
53
+ expected: z.ZodString;
54
+ }, z.core.$strict>,
55
+ z.ZodObject<{
56
+ operator: z.ZodEnum<{
57
+ equals: "equals";
58
+ notEquals: "notEquals";
59
+ contains: "contains";
60
+ lessThan: "lessThan";
61
+ greaterThan: "greaterThan";
62
+ exists: "exists";
63
+ }>;
64
+ target: z.ZodLiteral<"responseTime">;
65
+ expected: z.ZodString;
66
+ }, z.core.$strict>,
67
+ z.ZodObject<{
68
+ operator: z.ZodEnum<{
69
+ equals: "equals";
70
+ notEquals: "notEquals";
71
+ contains: "contains";
72
+ lessThan: "lessThan";
73
+ greaterThan: "greaterThan";
74
+ exists: "exists";
75
+ }>;
76
+ expected: z.ZodDefault<z.ZodOptional<z.ZodString>>;
77
+ target: z.ZodLiteral<"header">;
78
+ path: z.ZodString;
79
+ }, z.core.$strict>,
80
+ z.ZodObject<{
81
+ operator: z.ZodEnum<{
82
+ equals: "equals";
83
+ notEquals: "notEquals";
84
+ contains: "contains";
85
+ lessThan: "lessThan";
86
+ greaterThan: "greaterThan";
87
+ exists: "exists";
88
+ }>;
89
+ expected: z.ZodDefault<z.ZodOptional<z.ZodString>>;
90
+ target: z.ZodLiteral<"bodyField">;
91
+ path: z.ZodString;
92
+ }, z.core.$strict>
93
+ ], "target">;
94
+ type ApiResponseAssertionCommandData = z.infer<typeof apiResponseAssertionCommandData>;
16
95
  declare const elementActionSchema: z.ZodDiscriminatedUnion<[
17
96
  z.ZodObject<{
18
97
  type: z.ZodLiteral<"click">;
@@ -1797,9 +1876,9 @@ declare const CommandSchema: z.ZodDiscriminatedUnion<[
1797
1876
  ], "type">;
1798
1877
  score: z.ZodNumber;
1799
1878
  source: z.ZodEnum<{
1879
+ role: "role";
1800
1880
  xpath: "xpath";
1801
1881
  testId: "testId";
1802
- role: "role";
1803
1882
  accessibleName: "accessibleName";
1804
1883
  visibleText: "visibleText";
1805
1884
  stableAttribute: "stableAttribute";
@@ -2557,9 +2636,9 @@ declare const CommandSchema: z.ZodDiscriminatedUnion<[
2557
2636
  ], "type">;
2558
2637
  score: z.ZodNumber;
2559
2638
  source: z.ZodEnum<{
2639
+ role: "role";
2560
2640
  xpath: "xpath";
2561
2641
  testId: "testId";
2562
- role: "role";
2563
2642
  accessibleName: "accessibleName";
2564
2643
  visibleText: "visibleText";
2565
2644
  stableAttribute: "stableAttribute";
@@ -3201,9 +3280,9 @@ declare const CommandSchema: z.ZodDiscriminatedUnion<[
3201
3280
  ], "type">;
3202
3281
  score: z.ZodNumber;
3203
3282
  source: z.ZodEnum<{
3283
+ role: "role";
3204
3284
  xpath: "xpath";
3205
3285
  testId: "testId";
3206
- role: "role";
3207
3286
  accessibleName: "accessibleName";
3208
3287
  visibleText: "visibleText";
3209
3288
  stableAttribute: "stableAttribute";
@@ -3290,6 +3369,23 @@ declare const CommandSchema: z.ZodDiscriminatedUnion<[
3290
3369
  }, z.core.$strict>>;
3291
3370
  }, z.core.$strict>>>;
3292
3371
  }, z.core.$strict>,
3372
+ z.ZodObject<{
3373
+ _id: z.ZodString;
3374
+ type: z.ZodLiteral<"custom.code">;
3375
+ runtime: z.ZodDefault<z.ZodLiteral<"secure-exec-v1">>;
3376
+ language: z.ZodDefault<z.ZodLiteral<"javascript">>;
3377
+ code: z.ZodString;
3378
+ config: z.ZodOptional<z.ZodDefault<z.ZodObject<{
3379
+ continueOnFailure: z.ZodDefault<z.ZodBoolean>;
3380
+ preCommandDelay: z.ZodDefault<z.ZodNumber>;
3381
+ postCommandDelay: z.ZodDefault<z.ZodNumber>;
3382
+ sideEffectPolicy: z.ZodOptional<z.ZodObject<{
3383
+ isDestructive: z.ZodDefault<z.ZodBoolean>;
3384
+ isIdempotent: z.ZodDefault<z.ZodBoolean>;
3385
+ requiresOptIn: z.ZodDefault<z.ZodBoolean>;
3386
+ }, z.core.$strict>>;
3387
+ }, z.core.$strict>>>;
3388
+ }, z.core.$strict>,
3293
3389
  z.ZodObject<{
3294
3390
  _id: z.ZodString;
3295
3391
  type: z.ZodLiteral<"api.action">;
@@ -4779,9 +4875,9 @@ declare const StepDefinitionSchema: z.ZodObject<{
4779
4875
  ], "type">;
4780
4876
  score: z.ZodNumber;
4781
4877
  source: z.ZodEnum<{
4878
+ role: "role";
4782
4879
  xpath: "xpath";
4783
4880
  testId: "testId";
4784
- role: "role";
4785
4881
  accessibleName: "accessibleName";
4786
4882
  visibleText: "visibleText";
4787
4883
  stableAttribute: "stableAttribute";
@@ -5539,9 +5635,9 @@ declare const StepDefinitionSchema: z.ZodObject<{
5539
5635
  ], "type">;
5540
5636
  score: z.ZodNumber;
5541
5637
  source: z.ZodEnum<{
5638
+ role: "role";
5542
5639
  xpath: "xpath";
5543
5640
  testId: "testId";
5544
- role: "role";
5545
5641
  accessibleName: "accessibleName";
5546
5642
  visibleText: "visibleText";
5547
5643
  stableAttribute: "stableAttribute";
@@ -6183,9 +6279,9 @@ declare const StepDefinitionSchema: z.ZodObject<{
6183
6279
  ], "type">;
6184
6280
  score: z.ZodNumber;
6185
6281
  source: z.ZodEnum<{
6282
+ role: "role";
6186
6283
  xpath: "xpath";
6187
6284
  testId: "testId";
6188
- role: "role";
6189
6285
  accessibleName: "accessibleName";
6190
6286
  visibleText: "visibleText";
6191
6287
  stableAttribute: "stableAttribute";
@@ -6272,6 +6368,23 @@ declare const StepDefinitionSchema: z.ZodObject<{
6272
6368
  }, z.core.$strict>>;
6273
6369
  }, z.core.$strict>>>;
6274
6370
  }, z.core.$strict>,
6371
+ z.ZodObject<{
6372
+ _id: z.ZodString;
6373
+ type: z.ZodLiteral<"custom.code">;
6374
+ runtime: z.ZodDefault<z.ZodLiteral<"secure-exec-v1">>;
6375
+ language: z.ZodDefault<z.ZodLiteral<"javascript">>;
6376
+ code: z.ZodString;
6377
+ config: z.ZodOptional<z.ZodDefault<z.ZodObject<{
6378
+ continueOnFailure: z.ZodDefault<z.ZodBoolean>;
6379
+ preCommandDelay: z.ZodDefault<z.ZodNumber>;
6380
+ postCommandDelay: z.ZodDefault<z.ZodNumber>;
6381
+ sideEffectPolicy: z.ZodOptional<z.ZodObject<{
6382
+ isDestructive: z.ZodDefault<z.ZodBoolean>;
6383
+ isIdempotent: z.ZodDefault<z.ZodBoolean>;
6384
+ requiresOptIn: z.ZodDefault<z.ZodBoolean>;
6385
+ }, z.core.$strict>>;
6386
+ }, z.core.$strict>>>;
6387
+ }, z.core.$strict>,
6275
6388
  z.ZodObject<{
6276
6389
  _id: z.ZodString;
6277
6390
  type: z.ZodLiteral<"api.action">;
@@ -6765,9 +6878,9 @@ declare const ReplayLocatorCandidateSchema: z.ZodObject<{
6765
6878
  ], "type">;
6766
6879
  score: z.ZodNumber;
6767
6880
  source: z.ZodEnum<{
6881
+ role: "role";
6768
6882
  xpath: "xpath";
6769
6883
  testId: "testId";
6770
- role: "role";
6771
6884
  accessibleName: "accessibleName";
6772
6885
  visibleText: "visibleText";
6773
6886
  stableAttribute: "stableAttribute";
@@ -7047,9 +7160,9 @@ declare const StepReplayTelemetrySchema: z.ZodObject<{
7047
7160
  ], "type">;
7048
7161
  score: z.ZodNumber;
7049
7162
  source: z.ZodEnum<{
7163
+ role: "role";
7050
7164
  xpath: "xpath";
7051
7165
  testId: "testId";
7052
- role: "role";
7053
7166
  accessibleName: "accessibleName";
7054
7167
  visibleText: "visibleText";
7055
7168
  stableAttribute: "stableAttribute";
@@ -7251,8 +7364,8 @@ declare const RecoveryDecisionSchema: z.ZodDiscriminatedUnion<[
7251
7364
  }, z.core.$strip>
7252
7365
  ], "type">;
7253
7366
  repairContext: z.ZodEnum<{
7254
- "local-run": "local-run";
7255
7367
  "recorder-replay": "recorder-replay";
7368
+ "local-run": "local-run";
7256
7369
  "execution-planner": "execution-planner";
7257
7370
  }>;
7258
7371
  rcaLabel: z.ZodOptional<z.ZodString>;
@@ -7308,10 +7421,10 @@ type ExecutionStartedEventData = {
7308
7421
  };
7309
7422
  declare const ScopeTypeSchema: z.ZodEnum<{
7310
7423
  environment: "environment";
7424
+ runtime: "runtime";
7311
7425
  global: "global";
7312
7426
  feature: "feature";
7313
7427
  scenario: "scenario";
7314
- runtime: "runtime";
7315
7428
  }>;
7316
7429
  type ScopeType = z.infer<typeof ScopeTypeSchema>;
7317
7430
  declare const TestDataTypeSchema: z.ZodEnum<{
@@ -7343,10 +7456,10 @@ declare const TestDataEntrySchema: z.ZodObject<{
7343
7456
  scope: z.ZodObject<{
7344
7457
  type: z.ZodEnum<{
7345
7458
  environment: "environment";
7459
+ runtime: "runtime";
7346
7460
  global: "global";
7347
7461
  feature: "feature";
7348
7462
  scenario: "scenario";
7349
- runtime: "runtime";
7350
7463
  }>;
7351
7464
  environmentId: z.ZodOptional<z.ZodString>;
7352
7465
  featureId: z.ZodOptional<z.ZodString>;
@@ -7376,8 +7489,8 @@ declare const BrowserObserverStateKSchema: z.ZodUnion<readonly [
7376
7489
  input: "input";
7377
7490
  text: "text";
7378
7491
  context: "context";
7379
- hover: "hover";
7380
7492
  ai: "ai";
7493
+ hover: "hover";
7381
7494
  none: "none";
7382
7495
  snapshot: "snapshot";
7383
7496
  element: "element";
@@ -7732,9 +7845,9 @@ declare const PickedElementSchema: z.ZodObject<{
7732
7845
  ], "type">;
7733
7846
  score: z.ZodNumber;
7734
7847
  source: z.ZodEnum<{
7848
+ role: "role";
7735
7849
  xpath: "xpath";
7736
7850
  testId: "testId";
7737
- role: "role";
7738
7851
  accessibleName: "accessibleName";
7739
7852
  visibleText: "visibleText";
7740
7853
  stableAttribute: "stableAttribute";
@@ -7773,6 +7886,69 @@ declare const PickedElementSchema: z.ZodObject<{
7773
7886
  stale: z.ZodOptional<z.ZodBoolean>;
7774
7887
  }, z.core.$strict>;
7775
7888
  type PickedElement = z.infer<typeof PickedElementSchema>;
7889
+ declare const ExecutionResultSchema: z.ZodObject<{
7890
+ success: z.ZodBoolean;
7891
+ result: z.ZodOptional<z.ZodUnknown>;
7892
+ error: z.ZodOptional<z.ZodString>;
7893
+ userMessage: z.ZodOptional<z.ZodString>;
7894
+ logs: z.ZodArray<z.ZodString>;
7895
+ checkpoints: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
7896
+ label: z.ZodString;
7897
+ timestampMs: z.ZodNumber;
7898
+ data: z.ZodOptional<z.ZodUnknown>;
7899
+ }, z.core.$strict>>>>;
7900
+ duration: z.ZodNumber;
7901
+ screenshotAfter: z.ZodOptional<z.ZodString>;
7902
+ mutationSignals: z.ZodOptional<z.ZodObject<{
7903
+ httpMutations: z.ZodArray<z.ZodObject<{
7904
+ method: z.ZodEnum<{
7905
+ POST: "POST";
7906
+ PUT: "PUT";
7907
+ PATCH: "PATCH";
7908
+ DELETE: "DELETE";
7909
+ }>;
7910
+ url: z.ZodString;
7911
+ status: z.ZodNumber;
7912
+ timestampMs: z.ZodNumber;
7913
+ }, z.core.$strict>>;
7914
+ cookieChanges: z.ZodArray<z.ZodObject<{
7915
+ name: z.ZodString;
7916
+ action: z.ZodEnum<{
7917
+ added: "added";
7918
+ modified: "modified";
7919
+ deleted: "deleted";
7920
+ }>;
7921
+ suspectedAuth: z.ZodBoolean;
7922
+ }, z.core.$strict>>;
7923
+ storageMutations: z.ZodObject<{
7924
+ localStorage: z.ZodObject<{
7925
+ added: z.ZodArray<z.ZodString>;
7926
+ modified: z.ZodArray<z.ZodString>;
7927
+ deleted: z.ZodArray<z.ZodString>;
7928
+ }, z.core.$strict>;
7929
+ sessionStorage: z.ZodObject<{
7930
+ added: z.ZodArray<z.ZodString>;
7931
+ modified: z.ZodArray<z.ZodString>;
7932
+ deleted: z.ZodArray<z.ZodString>;
7933
+ }, z.core.$strict>;
7934
+ }, z.core.$strict>;
7935
+ navigationEvents: z.ZodArray<z.ZodObject<{
7936
+ url: z.ZodString;
7937
+ timestampMs: z.ZodNumber;
7938
+ }, z.core.$strict>>;
7939
+ dialogEvents: z.ZodArray<z.ZodObject<{
7940
+ type: z.ZodEnum<{
7941
+ alert: "alert";
7942
+ confirm: "confirm";
7943
+ prompt: "prompt";
7944
+ }>;
7945
+ message: z.ZodString;
7946
+ }, z.core.$strict>>;
7947
+ downloadCount: z.ZodNumber;
7948
+ pageErrorCount: z.ZodNumber;
7949
+ }, z.core.$strict>>;
7950
+ }, z.core.$strict>;
7951
+ type ExecutionResult = z.infer<typeof ExecutionResultSchema>;
7776
7952
  declare const RecoveryArtifactSchema: z.ZodObject<{
7777
7953
  rootCauseAnalysis: z.ZodString;
7778
7954
  aiLog: z.ZodString;
@@ -7844,6 +8020,207 @@ declare class DownloadStore {
7844
8020
  */
7845
8021
  cancelAll(): void;
7846
8022
  }
8023
+ type CustomCodeAllowedHost = {
8024
+ readonly protocol: "http:" | "https:" | "pg:";
8025
+ readonly hostname: string;
8026
+ };
8027
+ type CustomCodePolicy = {
8028
+ readonly maxDurationMs: number;
8029
+ readonly memoryMb: number;
8030
+ readonly outputBytes: number;
8031
+ readonly payloadBytes: number;
8032
+ readonly packages: readonly string[];
8033
+ readonly env: {
8034
+ readonly allowedKeys: readonly string[];
8035
+ };
8036
+ readonly network: {
8037
+ readonly allowedHosts: readonly CustomCodeAllowedHost[];
8038
+ readonly blockPrivateIpRanges: boolean;
8039
+ readonly requirePgTls: boolean;
8040
+ };
8041
+ readonly filesystem: {
8042
+ readonly root: string;
8043
+ readonly maxBytesPerFile: number;
8044
+ readonly maxFiles: number;
8045
+ };
8046
+ readonly process: {
8047
+ readonly allowedCommands: readonly string[];
8048
+ readonly maxOutputBytes: number;
8049
+ };
8050
+ readonly browser: {
8051
+ readonly pageMethods: readonly string[];
8052
+ readonly locatorMethods: readonly string[];
8053
+ readonly expectMethods: readonly string[];
8054
+ };
8055
+ };
8056
+ type CustomCodeDriverRunInput = {
8057
+ readonly code: string;
8058
+ readonly filePath: string;
8059
+ readonly policy: CustomCodePolicy;
8060
+ readonly bindings: Readonly<Record<string, unknown>>;
8061
+ readonly onStdout: (message: string) => void;
8062
+ readonly onStderr: (message: string) => void;
8063
+ };
8064
+ type CustomCodeDriverRunResult = {
8065
+ readonly exitCode: number;
8066
+ readonly errorMessage?: string;
8067
+ };
8068
+ interface CustomCodeDriver {
8069
+ run(input: CustomCodeDriverRunInput): Promise<CustomCodeDriverRunResult>;
8070
+ }
8071
+ type LogMethod = (...args: any[]) => void;
8072
+ type LogContext = any;
8073
+ type MetricTags = Record<string, string>;
8074
+ type EventProperties = Record<string, unknown>;
8075
+ type ObservabilityLoggerLike = {
8076
+ info: LogMethod;
8077
+ warn: LogMethod;
8078
+ error: LogMethod;
8079
+ withContext?: (context: LogContext) => ObservabilityLoggerLike;
8080
+ log?: LogMethod;
8081
+ };
8082
+ type ObservabilityMetricsLike = {
8083
+ count: (name: string, value?: number, tags?: MetricTags, context?: LogContext) => void;
8084
+ gauge: (name: string, value: number, unit?: any, tags?: MetricTags, context?: LogContext) => void;
8085
+ histogram: (name: string, value: number, unit?: any, tags?: MetricTags, context?: LogContext) => void;
8086
+ latency: (name: string, startMs: number, tags?: MetricTags, context?: LogContext) => void;
8087
+ withContext?: (context: LogContext) => ObservabilityMetricsLike;
8088
+ };
8089
+ type ObservabilityEventsLike = {
8090
+ track: (name: string, properties?: EventProperties, context?: any) => void;
8091
+ withContext?: (context: any) => ObservabilityEventsLike;
8092
+ };
8093
+ type ConsoleLikeLogger = Partial<Record<"log" | "info" | "warn" | "error", LogMethod>>;
8094
+ interface AgentLogger {
8095
+ log: LogMethod;
8096
+ info: LogMethod;
8097
+ warn: LogMethod;
8098
+ error: LogMethod;
8099
+ withContext: (context: LogContext) => AgentLogger;
8100
+ }
8101
+ interface AgentMetrics {
8102
+ count: (name: string, value?: number, tags?: MetricTags, context?: LogContext) => void;
8103
+ gauge: (name: string, value: number, unit?: any, tags?: MetricTags, context?: LogContext) => void;
8104
+ histogram: (name: string, value: number, unit?: any, tags?: MetricTags, context?: LogContext) => void;
8105
+ latency: (name: string, startMs: number, tags?: MetricTags, context?: LogContext) => void;
8106
+ withContext: (context: LogContext) => AgentMetrics;
8107
+ }
8108
+ interface AgentEvents {
8109
+ track: (name: string, properties?: EventProperties, context?: any) => void;
8110
+ withContext: (context: any) => AgentEvents;
8111
+ }
8112
+ interface AgentObservability {
8113
+ logger: AgentLogger;
8114
+ metrics: AgentMetrics;
8115
+ events: AgentEvents;
8116
+ withContext: (context: LogContext) => AgentObservability;
8117
+ }
8118
+ type AgentLoggerInput = AgentLogger | ObservabilityLoggerLike | ConsoleLikeLogger | undefined;
8119
+ type AgentObservabilityInput = AgentObservability | {
8120
+ logger?: AgentLoggerInput;
8121
+ metrics?: AgentMetrics | ObservabilityMetricsLike;
8122
+ events?: AgentEvents | ObservabilityEventsLike;
8123
+ } | AgentLoggerInput;
8124
+ interface TestDataApiOptions {
8125
+ /**
8126
+ * Called after every successful write. Used by WorkerRuntime to fan out
8127
+ * snapshots over the sessionTestData subscription.
8128
+ */
8129
+ onChange?: () => void;
8130
+ /**
8131
+ * Optional logger. When supplied, every setRuntime/getRuntime call emits a
8132
+ * structured info log so the operator can trace test-data writes without
8133
+ * grepping for `provider.upsert`.
8134
+ */
8135
+ logger?: AgentLoggerInput;
8136
+ }
8137
+ declare class TestDataApi {
8138
+ private readonly provider;
8139
+ private readonly context;
8140
+ private readonly options;
8141
+ private readonly logger?;
8142
+ constructor(provider: ITestDataProvider, context: ResolutionContext, options?: TestDataApiOptions);
8143
+ /**
8144
+ * Save a value to runtime test data.
8145
+ *
8146
+ * Runtime values:
8147
+ * - resolvable as `{{key}}` in subsequent steps within the same execution
8148
+ * - scoped to the current scenario; cleared when the scenario or environment changes
8149
+ * - last write wins for the same key inside one run (idempotent)
8150
+ *
8151
+ * @example in AI-chat-generated custom code
8152
+ * const orderId = await page.locator('[data-order-id]').getAttribute('data-order-id');
8153
+ * await context.testData.setRuntime('orderId', orderId ?? '');
8154
+ *
8155
+ * @example with explicit dataType
8156
+ * await context.testData.setRuntime('authToken', token, { dataType: 'secret' });
8157
+ */
8158
+ setRuntime(key: string, value: string, opts?: {
8159
+ dataType?: TestDataType;
8160
+ }): Promise<void>;
8161
+ /**
8162
+ * Shorthand for {@link setRuntime}. Saves a value to the current session's
8163
+ * runtime scope, resolvable as `{{key}}` in subsequent steps.
8164
+ */
8165
+ set(key: string, value: string, opts?: {
8166
+ dataType?: TestDataType;
8167
+ }): Promise<void>;
8168
+ /**
8169
+ * Shorthand for {@link getRuntime}. Reads a value from the current session's
8170
+ * runtime scope. Returns `null` if no entry exists for `key`.
8171
+ */
8172
+ get(key: string): Promise<string | null>;
8173
+ /**
8174
+ * Read a runtime value previously saved via setRuntime or an extract step.
8175
+ *
8176
+ * Returns `null` if no entry exists for `key` in the current runtime scope.
8177
+ * Does NOT walk the scope chain. For full resolution including environment +
8178
+ * global, use the `{{key}}` token syntax with the resolver.
8179
+ */
8180
+ getRuntime(key: string): Promise<string | null>;
8181
+ /**
8182
+ * Read a value through the full runtime → scenario → feature → environment → global
8183
+ * scope chain. This is used by built-in utility commands that need the raw value
8184
+ * rather than `{{key}}` token interpolation.
8185
+ */
8186
+ getScoped(key: string): Promise<string | null>;
8187
+ }
8188
+ type CustomCodeLogEntry = {
8189
+ readonly level: "info" | "warn" | "error";
8190
+ readonly message: string;
8191
+ };
8192
+ type CustomCodeCheckpoint = {
8193
+ readonly label: string;
8194
+ readonly timestampMs: number;
8195
+ readonly data?: unknown;
8196
+ };
8197
+ type CustomCodeExecutionResult = Omit<ExecutionResult, "logs" | "checkpoints" | "duration"> & {
8198
+ readonly logs?: readonly CustomCodeLogEntry[];
8199
+ readonly checkpoints?: readonly CustomCodeCheckpoint[];
8200
+ readonly errorKind?: string;
8201
+ };
8202
+ type ExecuteCustomCodeInput = {
8203
+ readonly commandId: string;
8204
+ readonly code: string;
8205
+ readonly variables: Readonly<Record<string, string>>;
8206
+ readonly page: Page;
8207
+ readonly testData?: Pick<TestDataApi, "set" | "get" | "setRuntime" | "getRuntime" | "getScoped">;
8208
+ readonly fetchImpl: typeof fetch;
8209
+ readonly checkpoint: (label: string, data?: unknown) => Promise<void>;
8210
+ readonly signal?: AbortSignal;
8211
+ };
8212
+ type CustomCodeRuntimeOptions = {
8213
+ readonly driver?: CustomCodeDriver;
8214
+ readonly policy?: CustomCodePolicy;
8215
+ readonly logger?: AgentLoggerInput;
8216
+ };
8217
+ declare class CustomCodeRuntime {
8218
+ private readonly driver;
8219
+ private readonly policy;
8220
+ private readonly logger?;
8221
+ constructor(options?: CustomCodeRuntimeOptions);
8222
+ execute(input: ExecuteCustomCodeInput): Promise<CustomCodeExecutionResult>;
8223
+ }
7847
8224
  type AriaRole = "alert" | "alertdialog" | "application" | "article" | "banner" | "blockquote" | "button" | "caption" | "cell" | "checkbox" | "code" | "columnheader" | "combobox" | "complementary" | "contentinfo" | "definition" | "deletion" | "dialog" | "directory" | "document" | "emphasis" | "feed" | "figure" | "form" | "generic" | "grid" | "gridcell" | "group" | "heading" | "img" | "insertion" | "link" | "list" | "listbox" | "listitem" | "log" | "main" | "mark" | "marquee" | "math" | "meter" | "menu" | "menubar" | "menuitem" | "menuitemcheckbox" | "menuitemradio" | "navigation" | "none" | "note" | "option" | "paragraph" | "presentation" | "progressbar" | "radio" | "radiogroup" | "region" | "row" | "rowgroup" | "rowheader" | "scrollbar" | "search" | "searchbox" | "separator" | "slider" | "spinbutton" | "status" | "strong" | "subscript" | "superscript" | "switch" | "tab" | "table" | "tablist" | "tabpanel" | "term" | "textbox" | "time" | "timer" | "toolbar" | "tooltip" | "tree" | "treegrid" | "treeitem";
7848
8225
  type AriaProps = {
7849
8226
  checked?: boolean | "mixed";
@@ -8659,111 +9036,6 @@ type TesterApiClient = {
8659
9036
  };
8660
9037
  };
8661
9038
  };
8662
- type LogMethod = (...args: any[]) => void;
8663
- type LogContext = any;
8664
- type MetricTags = Record<string, string>;
8665
- type EventProperties = Record<string, unknown>;
8666
- type ObservabilityLoggerLike = {
8667
- info: LogMethod;
8668
- warn: LogMethod;
8669
- error: LogMethod;
8670
- withContext?: (context: LogContext) => ObservabilityLoggerLike;
8671
- log?: LogMethod;
8672
- };
8673
- type ObservabilityMetricsLike = {
8674
- count: (name: string, value?: number, tags?: MetricTags, context?: LogContext) => void;
8675
- gauge: (name: string, value: number, unit?: any, tags?: MetricTags, context?: LogContext) => void;
8676
- histogram: (name: string, value: number, unit?: any, tags?: MetricTags, context?: LogContext) => void;
8677
- latency: (name: string, startMs: number, tags?: MetricTags, context?: LogContext) => void;
8678
- withContext?: (context: LogContext) => ObservabilityMetricsLike;
8679
- };
8680
- type ObservabilityEventsLike = {
8681
- track: (name: string, properties?: EventProperties, context?: any) => void;
8682
- withContext?: (context: any) => ObservabilityEventsLike;
8683
- };
8684
- type ConsoleLikeLogger = Partial<Record<"log" | "info" | "warn" | "error", LogMethod>>;
8685
- interface AgentLogger {
8686
- log: LogMethod;
8687
- info: LogMethod;
8688
- warn: LogMethod;
8689
- error: LogMethod;
8690
- withContext: (context: LogContext) => AgentLogger;
8691
- }
8692
- interface AgentMetrics {
8693
- count: (name: string, value?: number, tags?: MetricTags, context?: LogContext) => void;
8694
- gauge: (name: string, value: number, unit?: any, tags?: MetricTags, context?: LogContext) => void;
8695
- histogram: (name: string, value: number, unit?: any, tags?: MetricTags, context?: LogContext) => void;
8696
- latency: (name: string, startMs: number, tags?: MetricTags, context?: LogContext) => void;
8697
- withContext: (context: LogContext) => AgentMetrics;
8698
- }
8699
- interface AgentEvents {
8700
- track: (name: string, properties?: EventProperties, context?: any) => void;
8701
- withContext: (context: any) => AgentEvents;
8702
- }
8703
- interface AgentObservability {
8704
- logger: AgentLogger;
8705
- metrics: AgentMetrics;
8706
- events: AgentEvents;
8707
- withContext: (context: LogContext) => AgentObservability;
8708
- }
8709
- type AgentLoggerInput = AgentLogger | ObservabilityLoggerLike | ConsoleLikeLogger | undefined;
8710
- type AgentObservabilityInput = AgentObservability | {
8711
- logger?: AgentLoggerInput;
8712
- metrics?: AgentMetrics | ObservabilityMetricsLike;
8713
- events?: AgentEvents | ObservabilityEventsLike;
8714
- } | AgentLoggerInput;
8715
- interface TestDataApiOptions {
8716
- /**
8717
- * Called after every successful write. Used by WorkerRuntime to fan out
8718
- * snapshots over the sessionTestData subscription.
8719
- */
8720
- onChange?: () => void;
8721
- /**
8722
- * Optional logger. When supplied, every setRuntime/getRuntime call emits a
8723
- * structured info log so the operator can trace test-data writes without
8724
- * grepping for `provider.upsert`.
8725
- */
8726
- logger?: AgentLoggerInput;
8727
- }
8728
- declare class TestDataApi {
8729
- private readonly provider;
8730
- private readonly context;
8731
- private readonly options;
8732
- private readonly logger?;
8733
- constructor(provider: ITestDataProvider, context: ResolutionContext, options?: TestDataApiOptions);
8734
- /**
8735
- * Save a value to runtime test data.
8736
- *
8737
- * Runtime values:
8738
- * - resolvable as `{{key}}` in subsequent steps within the same execution
8739
- * - scoped to the current scenario; cleared when the scenario or environment changes
8740
- * - last write wins for the same key inside one run (idempotent)
8741
- *
8742
- * @example in AI-chat-generated custom code
8743
- * const orderId = await page.locator('[data-order-id]').getAttribute('data-order-id');
8744
- * await context.testData.setRuntime('orderId', orderId ?? '');
8745
- *
8746
- * @example with explicit dataType
8747
- * await context.testData.setRuntime('authToken', token, { dataType: 'secret' });
8748
- */
8749
- setRuntime(key: string, value: string, opts?: {
8750
- dataType?: TestDataType;
8751
- }): Promise<void>;
8752
- /**
8753
- * Read a runtime value previously saved via setRuntime or an extract step.
8754
- *
8755
- * Returns `null` if no entry exists for `key` in the current runtime scope.
8756
- * Does NOT walk the scope chain. For full resolution including environment +
8757
- * global, use the `{{key}}` token syntax with the resolver.
8758
- */
8759
- getRuntime(key: string): Promise<string | null>;
8760
- /**
8761
- * Read a value through the full runtime → scenario → feature → environment → global
8762
- * scope chain. This is used by built-in utility commands that need the raw value
8763
- * rather than `{{key}}` token interpolation.
8764
- */
8765
- getScoped(key: string): Promise<string | null>;
8766
- }
8767
9039
  type ApiExecutionResponse = ApiResponseSnapshot;
8768
9040
  type CommandExecutionContext = {
8769
9041
  stepParameters?: Record<string, string>;
@@ -8874,6 +9146,7 @@ type TesterOptions = {
8874
9146
  * an absolute path. Lets the caller (worker / planner) own FS layout.
8875
9147
  */
8876
9148
  getDownloadTargetPath?: (fileName: string) => string;
9149
+ customCodeRuntime?: CustomCodeRuntime;
8877
9150
  };
8878
9151
  type TesterTraceConfig = {
8879
9152
  mode?: "upload";
@@ -8923,6 +9196,7 @@ declare class Tester {
8923
9196
  private readonly fileResolver?;
8924
9197
  private readonly downloadStore?;
8925
9198
  private readonly getDownloadTargetPath?;
9199
+ private readonly customCodeRuntime?;
8926
9200
  private pageList;
8927
9201
  private sessionToken;
8928
9202
  private activeBrowserContext;
@@ -9077,7 +9351,7 @@ declare class Tester {
9077
9351
  downloadCount: number;
9078
9352
  pageErrorCount: number;
9079
9353
  } | undefined;
9080
- } | {
9354
+ } | CustomCodeExecutionResult | {
9081
9355
  status: number;
9082
9356
  statusText: string;
9083
9357
  timeMs: number;
@@ -9086,6 +9360,14 @@ declare class Tester {
9086
9360
  bodyText: string;
9087
9361
  bodyJson?: unknown;
9088
9362
  } | undefined>;
9363
+ /**
9364
+ * Runtime test-data accessor bound to the tester's current data provider and
9365
+ * resolution context. Returns `undefined` when no provider/context is
9366
+ * configured (e.g. a tester constructed without a test-data layer). A fresh
9367
+ * instance is returned each access so it always reflects the latest context
9368
+ * set via `setContext`.
9369
+ */
9370
+ get testDataApi(): TestDataApi | undefined;
9089
9371
  extractToTestData(input: {
9090
9372
  key: string;
9091
9373
  value: string;
@@ -9120,13 +9402,106 @@ export type PlaywrightRunnerParameters = {
9120
9402
  export type PlaywrightRunnerOptions = {
9121
9403
  readonly parameters?: PlaywrightRunnerParameters;
9122
9404
  };
9123
- export type PlaywrightRunnerTester = Pick<Tester, "executeCommand"> & Partial<Pick<Tester, "setContext">>;
9405
+ export type PlaywrightRunnerTester = Pick<Tester, "executeCommand"> & Partial<Pick<Tester, "setContext" | "testDataApi">>;
9124
9406
  export type PlaywrightRunnerDependencies = {
9125
9407
  readonly tester?: PlaywrightRunnerTester;
9126
9408
  readonly testDataProvider?: ITestDataProvider;
9127
9409
  readonly logger?: Pick<Console, "error" | "info" | "log" | "warn">;
9128
9410
  };
9129
- type GeneratedCommand = Parameters<PlaywrightRunnerTester["executeCommand"]>[0]["command"];
9411
+ /**
9412
+ * Tagged union the recorder stores in `command.data.value` for assertions
9413
+ * that accept a string-or-regex (`toHaveText`, `toHaveURL`, ...) or a
9414
+ * primitive-or-regex (`toHaveJSProperty`). Mirrors the `StringOrRegex` /
9415
+ * `PrimitiveOrRegex` schemas in `@blinq/schemas/base.schema`.
9416
+ */
9417
+ export type MatcherValueInput = {
9418
+ type: "string";
9419
+ value: string;
9420
+ } | {
9421
+ type: "number";
9422
+ value: number;
9423
+ } | {
9424
+ type: "boolean";
9425
+ value: boolean;
9426
+ } | {
9427
+ type: "regex";
9428
+ source: string;
9429
+ flags?: string;
9430
+ };
9431
+ /**
9432
+ * Resolve the recorder's tagged value into the form Playwright's matchers
9433
+ * expect: a plain string/number/boolean, or a `RegExp` for `{ type: "regex" }`.
9434
+ *
9435
+ * Generated spec code calls this on `resolvedCommand.data.value` before
9436
+ * passing it to `expect(locator).toHaveText(...)`, `.toHaveJSProperty(...)`,
9437
+ * etc. Returns `undefined` when given `undefined` so it composes cleanly with
9438
+ * optional fields (e.g. `toHaveAttribute`'s `value`).
9439
+ */
9440
+ export declare function toMatcherValue(value: MatcherValueInput): string | number | boolean | RegExp;
9441
+ export declare function toMatcherValue(value: undefined): undefined;
9442
+ export declare function toMatcherValue(value: MatcherValueInput | undefined): string | number | boolean | RegExp | undefined;
9443
+ type GeneratedCommand = Command;
9444
+ /**
9445
+ * Stateful API helper for generated `api.action` / `api.assertion` steps.
9446
+ * Mirrors the Tester's runtime: a request stores its response as `lastResponse`
9447
+ * (and writes `saveAs` to runtime test data), and an assertion runs against
9448
+ * that stored response. The shared state lives here because the request and
9449
+ * assertion are emitted as separate `test.step` blocks with no shared scope.
9450
+ */
9451
+ export type BlinqApi = {
9452
+ /** Run the request, store it as `lastResponse`, and persist `saveAs` if set. */
9453
+ request(request: ApiRequest): Promise<ApiResponseSnapshot>;
9454
+ /** Assert against `lastResponse`; throws if no request has run yet. */
9455
+ assert(assertion: ApiResponseAssertionCommandData): Promise<void>;
9456
+ readonly lastResponse: ApiResponseSnapshot | undefined;
9457
+ };
9458
+ /**
9459
+ * The `context` object AI-chat (`custom`) command code receives. Mirrors the
9460
+ * recorder sandbox's `context`: the resolution-scope fields plus a `testData`
9461
+ * accessor (which is the runner's `TestDataApi`, exposing
9462
+ * `set`/`get`/`setRuntime`/`getRuntime`).
9463
+ */
9464
+ export type AiChatContext = {
9465
+ readonly testData: TestDataApi;
9466
+ readonly projectId?: string;
9467
+ readonly environmentId?: string;
9468
+ readonly featureId?: string;
9469
+ readonly scenarioId?: string;
9470
+ readonly executionId?: string;
9471
+ };
9472
+ /**
9473
+ * The globals AI-chat custom code expects beyond `page` / `expect` / `console`.
9474
+ * Generated specs declare `context`, `checkpoint`, `onCommandStart`, and
9475
+ * `onCommandPass` above the inlined code, sourced from the bvt fixture.
9476
+ *
9477
+ * Recovery helpers (`helpers.getPreferredInteractiveTarget`, etc.) are
9478
+ * intentionally NOT provided — they depend on bvt-agent's runtime recovery and
9479
+ * have no standalone equivalent.
9480
+ */
9481
+ export type AiChatGlobals = {
9482
+ readonly context: AiChatContext;
9483
+ checkpoint(label: string, data?: unknown): void;
9484
+ onCommandStart(label: string): Promise<void>;
9485
+ onCommandPass(opts?: {
9486
+ delayMs?: number;
9487
+ }): Promise<void>;
9488
+ };
9489
+ /**
9490
+ * Build the AI-chat command globals. Mirrors the recorder sandbox:
9491
+ * `onCommandStart` waits the watch-delay then records the command boundary,
9492
+ * `onCommandPass` waits the (overridable) watch-delay, and `checkpoint`
9493
+ * records a labelled marker. In a standalone Playwright run the sandbox's
9494
+ * live-timeline bridge is replaced by Playwright test annotations (via the
9495
+ * injected `annotate` callback).
9496
+ */
9497
+ export declare function createAiChatGlobals(input: {
9498
+ testDataApi: TestDataApi;
9499
+ parameters: PlaywrightRunnerParameters;
9500
+ annotate: (annotation: {
9501
+ type: string;
9502
+ description: string;
9503
+ }) => void;
9504
+ }): AiChatGlobals;
9130
9505
  export declare class TempFileTestDataProvider implements ITestDataProvider {
9131
9506
  readonly filePath: string;
9132
9507
  readonly seedFilePath?: string | undefined;
@@ -9158,6 +9533,7 @@ export declare class PlaywrightRunner {
9158
9533
  private readonly scopeManager?;
9159
9534
  private readonly preprocessors;
9160
9535
  private resolutionContext;
9536
+ private apiRuntime?;
9161
9537
  constructor(options?: PlaywrightRunnerOptions, dependencies?: PlaywrightRunnerDependencies);
9162
9538
  private applyResolutionContext;
9163
9539
  /**
@@ -9166,63 +9542,14 @@ export declare class PlaywrightRunner {
9166
9542
  */
9167
9543
  attach(page: Page): void;
9168
9544
  detach(): void;
9169
- executeCommand(command: GeneratedCommand, parameters?: Record<string, string>): Promise<{
9170
- success: boolean;
9171
- logs: string[];
9172
- checkpoints: {
9173
- label: string;
9174
- timestampMs: number;
9175
- data?: unknown;
9176
- }[];
9177
- duration: number;
9178
- result?: unknown;
9179
- error?: string | undefined;
9180
- userMessage?: string | undefined;
9181
- screenshotAfter?: string | undefined;
9182
- mutationSignals?: {
9183
- httpMutations: {
9184
- method: "POST" | "PUT" | "PATCH" | "DELETE";
9185
- url: string;
9186
- status: number;
9187
- timestampMs: number;
9188
- }[];
9189
- cookieChanges: {
9190
- name: string;
9191
- action: "added" | "modified" | "deleted";
9192
- suspectedAuth: boolean;
9193
- }[];
9194
- storageMutations: {
9195
- localStorage: {
9196
- added: string[];
9197
- modified: string[];
9198
- deleted: string[];
9199
- };
9200
- sessionStorage: {
9201
- added: string[];
9202
- modified: string[];
9203
- deleted: string[];
9204
- };
9205
- };
9206
- navigationEvents: {
9207
- url: string;
9208
- timestampMs: number;
9209
- }[];
9210
- dialogEvents: {
9211
- type: "alert" | "confirm" | "prompt";
9212
- message: string;
9213
- }[];
9214
- downloadCount: number;
9215
- pageErrorCount: number;
9216
- } | undefined;
9217
- } | {
9218
- status: number;
9219
- statusText: string;
9220
- timeMs: number;
9221
- sizeBytes: number;
9222
- headers: Record<string, string>;
9223
- bodyText: string;
9224
- bodyJson?: unknown;
9225
- } | undefined>;
9545
+ /**
9546
+ * Stateful API helper for `api.action` / `api.assertion` steps. Lazily built
9547
+ * and held for the runner's lifetime so a request and its following assertion
9548
+ * share `lastResponse`. Throws if no test-data provider/context is available
9549
+ * (the `saveAs` path needs it).
9550
+ */
9551
+ get api(): BlinqApi;
9552
+ executeCommand(command: GeneratedCommand, parameters?: Record<string, string>): Promise<unknown>;
9226
9553
  /**
9227
9554
  * Run the preprocessor pipeline (step parameters, data-resolver tokens,
9228
9555
  * ai-chat code tokens, test-data API) over `command` and validate the
@@ -9288,6 +9615,31 @@ export type CreateBlinqTestOptions = {
9288
9615
  export type BlinqTestRuntime = {
9289
9616
  readonly page: Page;
9290
9617
  readonly parameters: PlaywrightRunnerParameters;
9618
+ /**
9619
+ * Runtime test-data accessor. Extract steps write the extracted value via
9620
+ * `bvt.testDataApi.setRuntime(key, value, { dataType })` so it resolves as
9621
+ * `{{key}}` in later steps.
9622
+ */
9623
+ readonly testDataApi: TestDataApi;
9624
+ /**
9625
+ * Stateful API helper. `api.action` steps call `bvt.api.request(...)` and
9626
+ * `api.assertion` steps call `bvt.api.assert(...)`; the request's response is
9627
+ * shared with the following assertion via `bvt.api.lastResponse`.
9628
+ */
9629
+ readonly api: BlinqApi;
9630
+ /**
9631
+ * The `context` object AI-chat (`custom`) command code receives; generated
9632
+ * specs declare `const context = bvt.aiChatContext` above the inlined code.
9633
+ */
9634
+ readonly aiChatContext: AiChatContext;
9635
+ /** AI-chat `checkpoint(label, data?)` global — records a Playwright annotation. */
9636
+ checkpoint(label: string, data?: unknown): void;
9637
+ /** AI-chat `onCommandStart(label)` global — watch-delay then a boundary annotation. */
9638
+ onCommandStart(label: string): Promise<void>;
9639
+ /** AI-chat `onCommandPass(opts?)` global — watch-delay (overridable via `delayMs`). */
9640
+ onCommandPass(opts?: {
9641
+ delayMs?: number;
9642
+ }): Promise<void>;
9291
9643
  executeCommand(command: GeneratedCommand, parameters?: Record<string, string>): Promise<unknown>;
9292
9644
  resolveCommand(command: unknown, parameters?: Record<string, string>): Promise<Command>;
9293
9645
  find(command: Command): Promise<Locator | Page | FrameLocator | null>;