@handstage/core 0.0.6 → 0.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@handstage/core",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -24,7 +24,7 @@
24
24
  "typescript": "^6.0.3"
25
25
  },
26
26
  "dependencies": {
27
- "@handstage/dom": "0.0.1",
27
+ "@handstage/dom": "0.0.2",
28
28
  "chrome-launcher": "^1.2.1",
29
29
  "devtools-protocol": "^0.0.1632630",
30
30
  "uuid": "^14.0.0",
@@ -1,4 +1,4 @@
1
- import type { Buffer } from "buffer"
1
+ import type { Buffer } from "node:buffer"
2
2
 
3
3
  export interface NormalizedFilePayload {
4
4
  name: string
@@ -1,4 +1,4 @@
1
- import type { Buffer } from "buffer"
1
+ import type { Buffer } from "node:buffer"
2
2
 
3
3
  export type MouseButton = "left" | "right" | "middle"
4
4
 
@@ -1,4 +1,3 @@
1
- import type { $ZodFormattedError } from "zod/v4/core"
2
1
  // Avoid .js extension so bundlers resolve TS source
3
2
  import { HANDSTAGE_VERSION } from "../../../version"
4
3
 
@@ -14,99 +13,6 @@ export class HandstageError extends Error {
14
13
  }
15
14
  }
16
15
 
17
- export class HandstageDefaultError extends HandstageError {
18
- constructor(error?: unknown) {
19
- if (error instanceof Error || error instanceof HandstageError) {
20
- super(
21
- `\nHey! We're sorry you ran into an error. \nHandstage version: ${HANDSTAGE_VERSION} \nIf you need help, please open a Github issue or reach out to us on Discord: https://handstage.dev/discord\n\nFull error:\n${error.message}`,
22
- )
23
- }
24
- }
25
- }
26
-
27
- export class HandstageEnvironmentError extends HandstageError {
28
- constructor(
29
- currentEnvironment: string,
30
- requiredEnvironment: string,
31
- feature: string,
32
- ) {
33
- super(
34
- `You seem to be setting the current environment to ${currentEnvironment}.` +
35
- `Ensure the environment is set to ${requiredEnvironment} if you want to use ${feature}.`,
36
- )
37
- }
38
- }
39
-
40
- export class MissingEnvironmentVariableError extends HandstageError {
41
- constructor(missingEnvironmentVariable: string, feature: string) {
42
- super(
43
- `${missingEnvironmentVariable} is required to use ${feature}.` +
44
- `Please set ${missingEnvironmentVariable} in your environment.`,
45
- )
46
- }
47
- }
48
-
49
- export class UnsupportedModelError extends HandstageError {
50
- constructor(supportedModels: string[], feature?: string) {
51
- const message = feature
52
- ? `${feature} requires a valid model.`
53
- : `Unsupported model.`
54
-
55
- const guidance =
56
- `\n\nPlease use the provider/model format (e.g., "openai/gpt-4o", "anthropic/claude-sonnet-4-5", "google/gemini-3-flash-preview").` +
57
- `\n\nFor a complete list of supported models and providers, see: https://docs.handstage.dev/v3/configuration/models#configuration-setup`
58
-
59
- super(`${message}${guidance}`)
60
- }
61
- }
62
-
63
- export class UnsupportedModelProviderError extends HandstageError {
64
- constructor(supportedProviders: string[], feature?: string) {
65
- super(
66
- feature
67
- ? `${feature} requires one of the following model providers: ${supportedProviders}`
68
- : `please use one of the supported model providers: ${supportedProviders}`,
69
- )
70
- }
71
- }
72
-
73
- export class UnsupportedAISDKModelProviderError extends HandstageError {
74
- constructor(provider: string, supportedProviders: string[]) {
75
- super(
76
- `${provider} is not currently supported for aiSDK. please use one of the supported model providers: ${supportedProviders}`,
77
- )
78
- }
79
- }
80
-
81
- export class InvalidAISDKModelFormatError extends HandstageError {
82
- constructor(modelName: string) {
83
- super(
84
- `${modelName} does not follow correct format for specifying aiSDK models. Please define your model as 'provider/model-name'. For example: \`model: 'openai/gpt-4o-mini'\``,
85
- )
86
- }
87
- }
88
-
89
- export class CaptchaTimeoutError extends HandstageError {
90
- constructor() {
91
- super("Captcha timeout")
92
- }
93
- }
94
-
95
- export class MissingLLMConfigurationError extends HandstageError {
96
- constructor() {
97
- super(
98
- "No LLM API key or LLM Client configured. An LLM API key or a custom LLM Client " +
99
- "is required to use act, extract, or observe.",
100
- )
101
- }
102
- }
103
-
104
- export class HandlerNotInitializedError extends HandstageError {
105
- constructor(handlerType: string) {
106
- super(`${handlerType} handler not initialized`)
107
- }
108
- }
109
-
110
16
  export class HandstageInvalidArgumentError extends HandstageError {
111
17
  constructor(message: string) {
112
18
  super(`InvalidArgumentError: ${message}`)
@@ -131,24 +37,6 @@ export class HandstageElementNotFoundError extends HandstageError {
131
37
  }
132
38
  }
133
39
 
134
- export class AgentScreenshotProviderError extends HandstageError {
135
- constructor(message: string) {
136
- super(`ScreenshotProviderError: ${message}`)
137
- }
138
- }
139
-
140
- export class HandstageMissingArgumentError extends HandstageError {
141
- constructor(message: string) {
142
- super(`MissingArgumentError: ${message}`)
143
- }
144
- }
145
-
146
- export class CreateChatCompletionResponseError extends HandstageError {
147
- constructor(message: string) {
148
- super(`CreateChatCompletionResponseError: ${message}`)
149
- }
150
- }
151
-
152
40
  export class HandstageEvalError extends HandstageError {
153
41
  constructor(message: string) {
154
42
  super(`HandstageEvalError: ${message}`)
@@ -169,20 +57,6 @@ export class HandstageLocatorError extends HandstageError {
169
57
  }
170
58
  }
171
59
 
172
- export class HandstageClickError extends HandstageError {
173
- constructor(message: string, selector: string) {
174
- super(
175
- `Error Clicking Element with selector: ${selector} Reason: ${message}`,
176
- )
177
- }
178
- }
179
-
180
- export class LLMResponseError extends HandstageError {
181
- constructor(primitive: string, message: string) {
182
- super(`${primitive} LLM response error: ${message}`)
183
- }
184
- }
185
-
186
60
  export class HandstageIframeError extends HandstageError {
187
61
  constructor(frameUrl: string, message: string) {
188
62
  super(
@@ -197,58 +71,6 @@ export class ContentFrameNotFoundError extends HandstageError {
197
71
  }
198
72
  }
199
73
 
200
- export class XPathResolutionError extends HandstageError {
201
- constructor(xpath: string) {
202
- super(`XPath "${xpath}" does not resolve in the current page or frames`)
203
- }
204
- }
205
-
206
- export class ZodSchemaValidationError extends Error {
207
- constructor(
208
- public readonly received: unknown,
209
- public readonly issues: $ZodFormattedError<unknown>,
210
- ) {
211
- super(`Zod schema validation failed
212
-
213
- — Received —
214
- ${JSON.stringify(received, null, 2)}
215
-
216
- — Issues —
217
- ${JSON.stringify(issues, null, 2)}`)
218
- this.name = "ZodSchemaValidationError"
219
- }
220
- }
221
-
222
- export class HandstageInitError extends HandstageError {
223
- constructor(message: string) {
224
- super(message)
225
- }
226
- }
227
-
228
- export class HandstageShadowRootMissingError extends HandstageError {
229
- constructor(detail?: string) {
230
- super(
231
- `No shadow root present on the resolved host` +
232
- (detail ? `: ${detail}` : ""),
233
- )
234
- }
235
- }
236
-
237
- export class HandstageShadowSegmentEmptyError extends HandstageError {
238
- constructor() {
239
- super(`Empty selector segment after shadow-DOM hop ("//")`)
240
- }
241
- }
242
-
243
- export class HandstageShadowSegmentNotFoundError extends HandstageError {
244
- constructor(segment: string, hint?: string) {
245
- super(
246
- `Shadow segment '${segment}' matched no element inside shadow root` +
247
- (hint ? ` ${hint}` : ""),
248
- )
249
- }
250
- }
251
-
252
74
  export class ElementNotVisibleError extends HandstageError {
253
75
  constructor(selector: string) {
254
76
  super(`Element not visible (no box model): ${selector}`)
@@ -285,12 +107,6 @@ export class ConnectionTimeoutError extends HandstageError {
285
107
  }
286
108
  }
287
109
 
288
- export class HandstageClosedError extends HandstageError {
289
- constructor() {
290
- super("Handstage session was closed")
291
- }
292
- }
293
-
294
110
  export class CDPConnectionClosedError extends HandstageError {
295
111
  constructor(reason: string) {
296
112
  super(`CDP connection closed: ${reason}`)
@@ -319,10 +135,3 @@ export class HandstageSnapshotError extends HandstageError {
319
135
  super(`error taking snapshot${suffix}`, cause)
320
136
  }
321
137
  }
322
-
323
- export class UnderstudyCommandException extends HandstageError {
324
- constructor(message: string, cause?: unknown) {
325
- super(message, cause)
326
- this.name = "UnderstudyCommandException"
327
- }
328
- }
@@ -1,6 +1,6 @@
1
- import { Buffer } from "buffer"
2
- import { promises as fs, type Stats } from "fs"
3
- import path from "path"
1
+ import { Buffer } from "node:buffer"
2
+ import { promises as fs, type Stats } from "node:fs"
3
+ import path from "node:path"
4
4
  import type { NormalizedFilePayload } from "../types/private/locator"
5
5
  import type {
6
6
  SetInputFilePayload,
@@ -1,4 +1,4 @@
1
- import { promises as fs } from "fs"
1
+ import { promises as fs } from "node:fs"
2
2
  import type { InitScriptSource } from "../types/private/index"
3
3
  import { HandstageInvalidArgumentError } from "../types/public/sdkErrors"
4
4
 
@@ -4,9 +4,9 @@ import {
4
4
  locatorScriptSources,
5
5
  } from "@handstage/dom/build/locatorScripts.generated"
6
6
  import type { Protocol } from "devtools-protocol"
7
- import * as fs from "fs"
8
- import * as os from "os"
9
- import * as path from "path"
7
+ import * as fs from "node:fs"
8
+ import * as os from "node:os"
9
+ import * as path from "node:path"
10
10
  import type { NormalizedFilePayload } from "../types/private/locator"
11
11
  import type {
12
12
  MouseButton,
@@ -1,5 +1,5 @@
1
1
  import type { Protocol } from "devtools-protocol"
2
- import { promises as fs } from "fs"
2
+ import { promises as fs } from "node:fs"
3
3
  import { v3Logger } from "../logger"
4
4
  import { withTimeout } from "../timeoutConfig"
5
5
  import type { InitScriptSource } from "../types/private/index"
package/src/v3/v3.ts CHANGED
@@ -1,7 +1,7 @@
1
- import fs from "fs"
2
- import os from "os"
3
- import path from "path"
4
- import process from "process"
1
+ import fs from "node:fs"
2
+ import os from "node:os"
3
+ import path from "node:path"
4
+ import process from "node:process"
5
5
  import { v7 as uuidv7 } from "uuid"
6
6
  import { launchLocalChrome } from "./launch/local"
7
7
  import {