omowright 0.3.3 → 0.3.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.
@@ -1,14 +1,12 @@
1
- export interface ToolSession {
2
- tool(name: string, params?: Record<string, unknown>): Promise<unknown>;
3
- }
4
- export interface ScreenshotOptions {
1
+ import type { ScreenshotScope } from "./protocol/params.generated.js";
2
+ import type { SharedTabOptions, ToolSession as TypedToolSession } from "./shared-tab.js";
3
+ export type ToolSession = TypedToolSession<"screenshot" | "screenshot_full_page" | "screenshot_read" | "screenshot_release">;
4
+ export interface ScreenshotOptions extends SharedTabOptions {
5
5
  ref?: string;
6
6
  tabId?: number;
7
7
  fullPage?: boolean;
8
- scope?: string;
8
+ scope?: ScreenshotScope;
9
9
  timeoutMs?: number;
10
- context?: string;
11
- dependsOn?: readonly string[];
12
10
  }
13
11
  export interface Screenshot {
14
12
  buffer: Buffer;
@@ -21,4 +19,4 @@ export interface Screenshot {
21
19
  tabId: unknown;
22
20
  dialogs: unknown;
23
21
  }
24
- export declare function captureScreenshot(session: ToolSession, { ref, tabId, fullPage, scope, timeoutMs, context, dependsOn }?: ScreenshotOptions): Promise<Screenshot>;
22
+ export declare function captureScreenshot(session: ToolSession, { ref, tabId, fullPage, scope, timeoutMs, ...shared }?: ScreenshotOptions): Promise<Screenshot>;
@@ -1,9 +1,14 @@
1
- import type { Target } from "./targets.js";
1
+ import type { ElementTargetInput, Target } from "./targets.js";
2
2
  import type { Screenshot, ScreenshotOptions } from "./screenshot.js";
3
3
  import type { BskClient } from "./ipc-client.js";
4
- export interface SharedTabOptions {
5
- context?: string | undefined;
6
- dependsOn?: readonly string[] | undefined;
4
+ import type { SharedTabOptions } from "./shared-tab.js";
5
+ import type { ExtractOptions, ReadOptions, WaitForElementOptions } from "./dom-reads.js";
6
+ import type { ControlPolicy, CooperateAction, DragMode, DragPoint, DragTarget, EmulateOverrides, ExtractAction, HelpCompletionCriteria, KeyModifier, MouseButton, TabScope, WaitUntil } from "./protocol/params.generated.js";
7
+ export type { SharedTabOptions } from "./shared-tab.js";
8
+ export interface CooperateReply {
9
+ readonly context_id: string | undefined;
10
+ readonly observation_id: string | undefined;
11
+ readonly [field: string]: unknown;
7
12
  }
8
13
  export interface BskSessionInit {
9
14
  sessionId?: unknown;
@@ -13,7 +18,7 @@ export interface BskSessionInit {
13
18
  }
14
19
  export interface NavigationOptions extends SharedTabOptions {
15
20
  tabId?: number;
16
- waitUntil?: string;
21
+ waitUntil?: WaitUntil;
17
22
  timeoutMs?: number;
18
23
  }
19
24
  export interface TabTimeoutOptions extends SharedTabOptions {
@@ -23,6 +28,7 @@ export interface TabTimeoutOptions extends SharedTabOptions {
23
28
  export interface EvaluateOptions extends TabTimeoutOptions {
24
29
  awaitPromise?: boolean;
25
30
  returnByValue?: boolean;
31
+ unverified?: boolean;
26
32
  }
27
33
  export declare class BskSession {
28
34
  #private;
@@ -34,11 +40,12 @@ export declare class BskSession {
34
40
  get client(): BskClient;
35
41
  get stopped(): boolean;
36
42
  tool(name: string, params?: Record<string, unknown>): Promise<unknown>;
37
- cooperate(action: string, { tabId, timeoutMs, maxTokens }?: {
43
+ cooperate(action: CooperateAction, { tabId, timeoutMs, maxTokens, controlPolicy, }?: {
38
44
  tabId?: number;
39
45
  timeoutMs?: number;
40
46
  maxTokens?: number;
41
- }): Promise<unknown>;
47
+ controlPolicy?: ControlPolicy;
48
+ }): Promise<CooperateReply>;
42
49
  navigate(url: string, { tabId, waitUntil, timeoutMs, ...shared }?: NavigationOptions): Promise<unknown>;
43
50
  back({ tabId, waitUntil, timeoutMs, ...shared }?: NavigationOptions): Promise<unknown>;
44
51
  forward({ tabId, waitUntil, timeoutMs, ...shared }?: NavigationOptions): Promise<unknown>;
@@ -65,35 +72,47 @@ export declare class BskSession {
65
72
  }): Promise<unknown>;
66
73
  screenshot(options?: ScreenshotOptions): Promise<Screenshot>;
67
74
  click(target: Target, { button, clickCount, modifiers, tabId, timeoutMs, ...shared }?: TabTimeoutOptions & {
68
- button?: string | undefined;
75
+ button?: MouseButton | undefined;
69
76
  clickCount?: number;
70
- modifiers?: string[];
77
+ modifiers?: readonly KeyModifier[];
71
78
  }): Promise<unknown>;
72
- hover(target: Target, { modifiers, settleMs, tabId, timeoutMs, ...shared }?: TabTimeoutOptions & {
73
- modifiers?: string[];
79
+ hover(target: ElementTargetInput, { modifiers, settleMs, tabId, timeoutMs, ...shared }?: TabTimeoutOptions & {
80
+ modifiers?: readonly KeyModifier[];
74
81
  settleMs?: number;
75
82
  }): Promise<unknown>;
76
- focus(target: Target, { tabId, timeoutMs, ...shared }?: TabTimeoutOptions): Promise<unknown>;
77
- blur(target: Target, { tabId, timeoutMs, ...shared }?: TabTimeoutOptions): Promise<unknown>;
78
- fill(target: Target, value: string, { clearBefore, tabId, timeoutMs, ...shared }?: TabTimeoutOptions & {
83
+ focus(target: ElementTargetInput, { tabId, timeoutMs, ...shared }?: TabTimeoutOptions): Promise<unknown>;
84
+ blur(target: ElementTargetInput, { tabId, timeoutMs, ...shared }?: TabTimeoutOptions): Promise<unknown>;
85
+ fill(target: ElementTargetInput, value: string, { clearBefore, tabId, timeoutMs, ...shared }?: TabTimeoutOptions & {
79
86
  clearBefore?: boolean;
80
87
  }): Promise<unknown>;
81
88
  press(key: string, { target, modifiers, holdMs, tabId, timeoutMs, ...shared }?: TabTimeoutOptions & {
82
- target?: Target;
83
- modifiers?: string[];
89
+ target?: ElementTargetInput;
90
+ modifiers?: readonly KeyModifier[];
84
91
  holdMs?: number;
85
92
  }): Promise<unknown>;
86
- select(target: Target, values: string | string[], { tabId, timeoutMs, ...shared }?: TabTimeoutOptions): Promise<unknown>;
87
- scrollTo(target: Target, { tabId, timeoutMs, ...shared }?: TabTimeoutOptions): Promise<unknown>;
93
+ select(target: ElementTargetInput, values: string | string[], { tabId, timeoutMs, ...shared }?: TabTimeoutOptions): Promise<unknown>;
94
+ scrollTo(target: ElementTargetInput, { tabId, timeoutMs, ...shared }?: TabTimeoutOptions): Promise<unknown>;
88
95
  wheel({ deltaX, deltaY, target, modifiers, tabId, timeoutMs, ...shared }?: TabTimeoutOptions & {
89
96
  deltaX?: number;
90
97
  deltaY?: number;
91
- target?: Target;
92
- modifiers?: string[];
98
+ target?: ElementTargetInput;
99
+ modifiers?: readonly KeyModifier[];
100
+ }): Promise<unknown>;
101
+ evaluate(expression: string, { tabId, awaitPromise, returnByValue, timeoutMs, unverified, ...shared }?: EvaluateOptions): Promise<unknown>;
102
+ read(target?: ElementTargetInput, options?: ReadOptions): Promise<unknown>;
103
+ extract(action: ExtractAction, options?: ExtractOptions): Promise<unknown>;
104
+ waitForElement(target: ElementTargetInput, options: WaitForElementOptions): Promise<unknown>;
105
+ drag(source: DragTarget, { target, delta, mode, button, durationMs, holdMs, modifiers, tabId, timeoutMs, ...shared }?: TabTimeoutOptions & {
106
+ target?: DragTarget;
107
+ delta?: DragPoint;
108
+ mode?: DragMode;
109
+ button?: MouseButton;
110
+ durationMs?: number;
111
+ holdMs?: number;
112
+ modifiers?: readonly KeyModifier[];
93
113
  }): Promise<unknown>;
94
- evaluate(expression: string, { tabId, awaitPromise, returnByValue, timeoutMs, ...shared }?: EvaluateOptions): Promise<unknown>;
95
114
  tabList({ scope }?: {
96
- scope?: string;
115
+ scope?: TabScope;
97
116
  }): Promise<unknown>;
98
117
  tabCreate({ url, active, index }?: {
99
118
  url?: string;
@@ -108,14 +127,14 @@ export declare class BskSession {
108
127
  tabReturn(tabId: number): Promise<unknown>;
109
128
  waitForNavigation({ tabId, waitUntil, timeoutMs, }?: {
110
129
  tabId?: number;
111
- waitUntil?: string;
130
+ waitUntil?: WaitUntil;
112
131
  timeoutMs?: number;
113
132
  }): Promise<unknown>;
114
- requestHelp({ prompt, title, targets, completionCriteria, tabId, timeoutMs, }?: {
115
- prompt?: string;
133
+ requestHelp({ prompt, title, targets, completionCriteria, tabId, timeoutMs, }: {
134
+ prompt: string;
116
135
  title?: string;
117
- targets?: Target[];
118
- completionCriteria?: unknown;
136
+ targets?: ElementTargetInput[];
137
+ completionCriteria?: HelpCompletionCriteria;
119
138
  tabId?: number;
120
139
  timeoutMs?: number;
121
140
  }): Promise<unknown>;
@@ -136,7 +155,7 @@ export declare class BskSession {
136
155
  emulate({ tabId, off, overrides, ...shared }?: SharedTabOptions & {
137
156
  tabId?: number;
138
157
  off?: boolean;
139
- overrides?: Record<string, unknown>;
158
+ overrides?: EmulateOverrides;
140
159
  }): Promise<unknown>;
141
160
  stop(): Promise<unknown>;
142
161
  }
@@ -0,0 +1,22 @@
1
+ import type { ActionExpectation, BskToolParams } from "./protocol/params.generated.js";
2
+ export type ToolMethod = keyof BskToolParams;
3
+ export type WireParams<M extends ToolMethod> = Omit<BskToolParams[M], "session_id">;
4
+ export interface ToolSession<M extends ToolMethod> {
5
+ tool<N extends M>(name: N, params: WireParams<N>): Promise<unknown>;
6
+ }
7
+ export interface SharedTabOptions {
8
+ context?: string | undefined;
9
+ observation?: string | undefined;
10
+ expect?: readonly ActionExpectation[] | undefined;
11
+ dependsOn?: readonly string[] | undefined;
12
+ }
13
+ export type MetadataKey = "context_id" | "observation_id" | "expect" | "depends_on";
14
+ export type SharedTabMethod = {
15
+ [M in ToolMethod]: MetadataKey extends keyof BskToolParams[M] ? M : never;
16
+ }[ToolMethod];
17
+ export declare function sharedTab({ context, observation, expect, dependsOn, ...unknown }: SharedTabOptions): {
18
+ context_id: string | undefined;
19
+ observation_id: string | undefined;
20
+ expect: readonly ActionExpectation[] | undefined;
21
+ depends_on: readonly string[] | undefined;
22
+ };
@@ -1,10 +1,9 @@
1
1
  import type { BskSession } from "./session.js";
2
+ import type { SharedTabOptions } from "./shared-tab.js";
2
3
  export type EvaluateSession = Pick<BskSession, "evaluate">;
3
- export interface BskSnapshotOptions {
4
+ export interface BskSnapshotOptions extends SharedTabOptions {
4
5
  tabId?: number;
5
6
  timeoutMs?: number;
6
- context?: string;
7
- dependsOn?: readonly string[];
8
7
  [option: string]: unknown;
9
8
  }
10
9
  export interface BskSnapshot {
@@ -13,4 +12,4 @@ export interface BskSnapshot {
13
12
  css: unknown;
14
13
  }
15
14
  export declare function buildSnapshotExpression(options?: Record<string, unknown>): string;
16
- export declare function bskSnapshot(session: EvaluateSession, { tabId, timeoutMs, context, dependsOn, ...snapshotOptions }?: BskSnapshotOptions): Promise<BskSnapshot>;
15
+ export declare function bskSnapshot(session: EvaluateSession, { tabId, timeoutMs, context, observation, expect, dependsOn, ...snapshotOptions }?: BskSnapshotOptions): Promise<BskSnapshot>;
@@ -6,15 +6,18 @@ export interface TargetSpec {
6
6
  y?: number;
7
7
  }
8
8
  export type Target = string | TargetSpec;
9
- export type ResolvedTarget = {
9
+ export type ElementTargetInput = string | Pick<TargetSpec, "ref" | "selector">;
10
+ export type ElementTarget = {
10
11
  ref: string;
11
12
  } | {
12
13
  selector: string;
13
- } | {
14
+ };
15
+ export type ResolvedTarget = ElementTarget | {
14
16
  capture_id: string;
15
- image_x: unknown;
16
- image_y: unknown;
17
+ image_x: number;
18
+ image_y: number;
17
19
  };
18
20
  export declare function resolveTarget(target: unknown): ResolvedTarget;
19
- export declare function optionalTarget(target: unknown): ResolvedTarget | Record<string, never>;
21
+ export declare function resolveElementTarget(target: unknown): ElementTarget;
22
+ export declare function optionalElementTarget(target: unknown): ElementTarget | Record<string, never>;
20
23
  export declare function compact(params: Record<string, unknown>): Record<string, unknown>;
package/dist/index.d.ts CHANGED
@@ -31,6 +31,7 @@ export { createRoutes } from "./routes.js";
31
31
  export { collectWhileScrolling } from "./scroll-collect.js";
32
32
  export { createTrace } from "./trace.js";
33
33
  export { BskIpcClient, BskRpcError, readDaemonInfo, resolveBskHome } from "./bsk/ipc-client.js";
34
+ export type { BskCallOptions, BskClient } from "./bsk/ipc-client.js";
34
35
  export { BskSession } from "./bsk/session.js";
35
36
  export { connectBrowserSkill, listBrowsers } from "./bsk/connect.js";
36
37
  export { bskSnapshot, buildSnapshotExpression } from "./bsk/snapshot.js";