@poncho-ai/browser 0.1.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/.turbo/turbo-build.log +14 -0
- package/LICENSE +21 -0
- package/dist/index.d.ts +110 -0
- package/dist/index.js +687 -0
- package/package.json +44 -0
- package/src/index.ts +12 -0
- package/src/session.ts +595 -0
- package/src/tools.ts +167 -0
- package/src/types.ts +60 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
> @poncho-ai/browser@0.1.0 build /home/runner/work/poncho-ai/poncho-ai/packages/browser
|
|
3
|
+
> tsup src/index.ts --format esm --dts
|
|
4
|
+
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
+
[34mCLI[39m tsup v8.5.1
|
|
8
|
+
[34mCLI[39m Target: es2022
|
|
9
|
+
[34mESM[39m Build start
|
|
10
|
+
[32mESM[39m [1mdist/index.js [22m[32m21.56 KB[39m
|
|
11
|
+
[32mESM[39m ⚡️ Build success in 52ms
|
|
12
|
+
[34mDTS[39m Build start
|
|
13
|
+
[32mDTS[39m ⚡️ Build success in 4536ms
|
|
14
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.75 KB[39m
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Latitude
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { ToolDefinition } from '@poncho-ai/sdk';
|
|
2
|
+
|
|
3
|
+
interface BrowserFrame {
|
|
4
|
+
data: string;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
timestamp: number;
|
|
8
|
+
}
|
|
9
|
+
interface BrowserStatus {
|
|
10
|
+
active: boolean;
|
|
11
|
+
url?: string;
|
|
12
|
+
interactionAllowed: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface ViewportOptions {
|
|
15
|
+
width?: number;
|
|
16
|
+
height?: number;
|
|
17
|
+
}
|
|
18
|
+
interface ScreencastOptions {
|
|
19
|
+
format?: "jpeg" | "png";
|
|
20
|
+
quality?: number;
|
|
21
|
+
maxWidth?: number;
|
|
22
|
+
maxHeight?: number;
|
|
23
|
+
everyNthFrame?: number;
|
|
24
|
+
}
|
|
25
|
+
interface MouseInputEvent {
|
|
26
|
+
type: "mousePressed" | "mouseReleased" | "mouseMoved" | "mouseWheel";
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
button?: "left" | "right" | "middle" | "none";
|
|
30
|
+
clickCount?: number;
|
|
31
|
+
deltaX?: number;
|
|
32
|
+
deltaY?: number;
|
|
33
|
+
}
|
|
34
|
+
interface KeyboardInputEvent {
|
|
35
|
+
type: "keyDown" | "keyUp" | "char";
|
|
36
|
+
key: string;
|
|
37
|
+
code?: string;
|
|
38
|
+
text?: string;
|
|
39
|
+
keyCode?: number;
|
|
40
|
+
}
|
|
41
|
+
interface ScrollInputEvent {
|
|
42
|
+
deltaX: number;
|
|
43
|
+
deltaY: number;
|
|
44
|
+
x?: number;
|
|
45
|
+
y?: number;
|
|
46
|
+
}
|
|
47
|
+
interface BrowserConfig {
|
|
48
|
+
viewport?: ViewportOptions;
|
|
49
|
+
quality?: number;
|
|
50
|
+
everyNthFrame?: number;
|
|
51
|
+
profileDir?: string;
|
|
52
|
+
sessionName?: string;
|
|
53
|
+
executablePath?: string;
|
|
54
|
+
headless?: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type FrameListener = (frame: BrowserFrame) => void;
|
|
58
|
+
type StatusListener = (status: BrowserStatus) => void;
|
|
59
|
+
declare class BrowserSession {
|
|
60
|
+
private readonly config;
|
|
61
|
+
private readonly sessionId;
|
|
62
|
+
private manager;
|
|
63
|
+
private readonly tabs;
|
|
64
|
+
private _lockQueue;
|
|
65
|
+
private _locked;
|
|
66
|
+
private _screencastConversation;
|
|
67
|
+
constructor(sessionId: string, config?: BrowserConfig);
|
|
68
|
+
get profileDir(): string;
|
|
69
|
+
private lock;
|
|
70
|
+
private unlock;
|
|
71
|
+
private launchFreshManager;
|
|
72
|
+
private ensureManager;
|
|
73
|
+
private evictOldestTab;
|
|
74
|
+
/** Reconcile tab indices with the manager's actual page list. */
|
|
75
|
+
private reconcileTabs;
|
|
76
|
+
private realTabCount;
|
|
77
|
+
private switchToConversation;
|
|
78
|
+
/** Check if a conversation has an active browser tab. */
|
|
79
|
+
isActiveFor(conversationId: string): boolean;
|
|
80
|
+
/** Get the current URL for a conversation's tab. */
|
|
81
|
+
getUrl(conversationId: string): string | undefined;
|
|
82
|
+
/** Whether the browser has been launched. */
|
|
83
|
+
get isLaunched(): boolean;
|
|
84
|
+
open(conversationId: string, url: string): Promise<{
|
|
85
|
+
title?: string;
|
|
86
|
+
}>;
|
|
87
|
+
private _doOpen;
|
|
88
|
+
snapshot(conversationId: string): Promise<string>;
|
|
89
|
+
click(conversationId: string, ref: string): Promise<void>;
|
|
90
|
+
type(conversationId: string, ref: string, text: string): Promise<void>;
|
|
91
|
+
screenshot(conversationId: string): Promise<string>;
|
|
92
|
+
scroll(conversationId: string, direction: "up" | "down", amount?: number): Promise<void>;
|
|
93
|
+
closeTab(conversationId: string): Promise<void>;
|
|
94
|
+
navigate(conversationId: string, action: string): Promise<void>;
|
|
95
|
+
startScreencast(conversationId: string, options?: ScreencastOptions): Promise<void>;
|
|
96
|
+
stopScreencast(): Promise<void>;
|
|
97
|
+
onFrame(conversationId: string, listener: FrameListener): () => void;
|
|
98
|
+
onStatus(conversationId: string, listener: StatusListener): () => void;
|
|
99
|
+
injectMouse(conversationId: string, event: MouseInputEvent): Promise<void>;
|
|
100
|
+
injectKeyboard(conversationId: string, event: KeyboardInputEvent): Promise<void>;
|
|
101
|
+
injectPaste(conversationId: string, text: string): Promise<void>;
|
|
102
|
+
injectScroll(conversationId: string, event: ScrollInputEvent): Promise<void>;
|
|
103
|
+
saveState(storagePath: string): Promise<void>;
|
|
104
|
+
close(): Promise<void>;
|
|
105
|
+
private emitStatus;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare function createBrowserTools(getSession: () => BrowserSession, getConversationId: () => string): ToolDefinition[];
|
|
109
|
+
|
|
110
|
+
export { type BrowserConfig, type BrowserFrame, BrowserSession, type BrowserStatus, type KeyboardInputEvent, type MouseInputEvent, type ScreencastOptions, type ScrollInputEvent, type ViewportOptions, createBrowserTools };
|