btcp-browser-agent 0.1.0 → 0.1.2
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 +8 -9
- package/packages/core/dist/actions.d.ts +97 -0
- package/packages/core/dist/actions.js +940 -0
- package/packages/core/dist/errors.d.ts +138 -0
- package/packages/core/dist/errors.js +157 -0
- package/packages/core/dist/index.d.ts +120 -0
- package/packages/core/dist/index.js +134 -0
- package/packages/core/dist/ref-map.d.ts +16 -0
- package/packages/core/dist/ref-map.js +91 -0
- package/packages/core/dist/snapshot.d.ts +37 -0
- package/packages/core/dist/snapshot.js +751 -0
- package/packages/core/dist/types.d.ts +396 -0
- package/packages/core/dist/types.js +7 -0
- package/packages/extension/dist/background.d.ts +227 -0
- package/packages/extension/dist/background.js +737 -0
- package/packages/extension/dist/content.d.ts +18 -0
- package/packages/extension/dist/content.js +149 -0
- package/packages/extension/dist/index.d.ts +228 -0
- package/packages/extension/dist/index.js +350 -0
- package/packages/extension/dist/session-manager.d.ts +87 -0
- package/packages/extension/dist/session-manager.js +322 -0
- package/packages/extension/{src/session-types.ts → dist/session-types.d.ts} +113 -144
- package/packages/extension/dist/session-types.js +5 -0
- package/packages/extension/dist/types.d.ts +88 -0
- package/packages/extension/dist/types.js +7 -0
- package/CLAUDE.md +0 -230
- package/SKILL.md +0 -143
- package/SNAPSHOT_IMPROVEMENTS.md +0 -302
- package/USAGE.md +0 -146
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/docs/browser-cli-design.md +0 -500
- package/examples/chrome-extension/CHANGELOG.md +0 -210
- package/examples/chrome-extension/DEBUG.md +0 -231
- package/examples/chrome-extension/ERROR_FIXED.md +0 -147
- package/examples/chrome-extension/QUICK_TEST.md +0 -189
- package/examples/chrome-extension/README.md +0 -149
- package/examples/chrome-extension/SESSION_ONLY_MODE.md +0 -305
- package/examples/chrome-extension/TEST_WITH_YOUR_TABS.md +0 -97
- package/examples/chrome-extension/build.js +0 -43
- package/examples/chrome-extension/manifest.json +0 -37
- package/examples/chrome-extension/package-lock.json +0 -1063
- package/examples/chrome-extension/package.json +0 -21
- package/examples/chrome-extension/popup.html +0 -195
- package/examples/chrome-extension/src/background.ts +0 -12
- package/examples/chrome-extension/src/content.ts +0 -7
- package/examples/chrome-extension/src/popup.ts +0 -303
- package/examples/chrome-extension/src/scenario-google-github.ts +0 -389
- package/examples/chrome-extension/test-page.html +0 -127
- package/examples/chrome-extension/tests/README.md +0 -206
- package/examples/chrome-extension/tests/scenario-google-to-github-star.ts +0 -380
- package/examples/chrome-extension/tsconfig.json +0 -14
- package/examples/snapshots/README.md +0 -207
- package/examples/snapshots/amazon-com-detail.html +0 -9528
- package/examples/snapshots/amazon-com-detail.snapshot.txt +0 -997
- package/examples/snapshots/convert-snapshots.ts +0 -97
- package/examples/snapshots/edition-cnn-com.html +0 -13292
- package/examples/snapshots/edition-cnn-com.snapshot.txt +0 -562
- package/examples/snapshots/github-com-microsoft-vscode.html +0 -2916
- package/examples/snapshots/github-com-microsoft-vscode.snapshot.txt +0 -455
- package/examples/snapshots/google-search.html +0 -20012
- package/examples/snapshots/google-search.snapshot.txt +0 -195
- package/examples/snapshots/metadata.json +0 -86
- package/examples/snapshots/npr-org-templates.html +0 -2031
- package/examples/snapshots/npr-org-templates.snapshot.txt +0 -224
- package/examples/snapshots/stackoverflow-com.html +0 -5216
- package/examples/snapshots/stackoverflow-com.snapshot.txt +0 -2404
- package/examples/snapshots/test-all-mode.html +0 -46
- package/examples/snapshots/test-all-mode.snapshot.txt +0 -5
- package/examples/snapshots/validate.test.ts +0 -296
- package/packages/cli/package.json +0 -42
- package/packages/cli/src/__tests__/cli.test.ts +0 -434
- package/packages/cli/src/__tests__/errors.test.ts +0 -226
- package/packages/cli/src/__tests__/executor.test.ts +0 -275
- package/packages/cli/src/__tests__/formatter.test.ts +0 -260
- package/packages/cli/src/__tests__/parser.test.ts +0 -288
- package/packages/cli/src/__tests__/suggestions.test.ts +0 -255
- package/packages/cli/src/commands/back.ts +0 -22
- package/packages/cli/src/commands/check.ts +0 -33
- package/packages/cli/src/commands/clear.ts +0 -33
- package/packages/cli/src/commands/click.ts +0 -32
- package/packages/cli/src/commands/closetab.ts +0 -31
- package/packages/cli/src/commands/eval.ts +0 -41
- package/packages/cli/src/commands/fill.ts +0 -30
- package/packages/cli/src/commands/focus.ts +0 -33
- package/packages/cli/src/commands/forward.ts +0 -22
- package/packages/cli/src/commands/goto.ts +0 -34
- package/packages/cli/src/commands/help.ts +0 -162
- package/packages/cli/src/commands/hover.ts +0 -34
- package/packages/cli/src/commands/index.ts +0 -129
- package/packages/cli/src/commands/newtab.ts +0 -35
- package/packages/cli/src/commands/press.ts +0 -40
- package/packages/cli/src/commands/reload.ts +0 -25
- package/packages/cli/src/commands/screenshot.ts +0 -27
- package/packages/cli/src/commands/scroll.ts +0 -64
- package/packages/cli/src/commands/select.ts +0 -35
- package/packages/cli/src/commands/snapshot.ts +0 -21
- package/packages/cli/src/commands/tab.ts +0 -32
- package/packages/cli/src/commands/tabs.ts +0 -26
- package/packages/cli/src/commands/text.ts +0 -27
- package/packages/cli/src/commands/title.ts +0 -17
- package/packages/cli/src/commands/type.ts +0 -38
- package/packages/cli/src/commands/uncheck.ts +0 -33
- package/packages/cli/src/commands/url.ts +0 -17
- package/packages/cli/src/commands/wait.ts +0 -54
- package/packages/cli/src/errors.ts +0 -164
- package/packages/cli/src/executor.ts +0 -68
- package/packages/cli/src/formatter.ts +0 -215
- package/packages/cli/src/index.ts +0 -257
- package/packages/cli/src/parser.ts +0 -195
- package/packages/cli/src/suggestions.ts +0 -207
- package/packages/cli/src/terminal/Terminal.ts +0 -365
- package/packages/cli/src/terminal/index.ts +0 -5
- package/packages/cli/src/types.ts +0 -155
- package/packages/cli/tsconfig.json +0 -20
- package/packages/core/package.json +0 -35
- package/packages/core/src/actions.ts +0 -1210
- package/packages/core/src/errors.ts +0 -296
- package/packages/core/src/index.test.ts +0 -638
- package/packages/core/src/index.ts +0 -220
- package/packages/core/src/ref-map.ts +0 -107
- package/packages/core/src/snapshot.ts +0 -873
- package/packages/core/src/types.ts +0 -536
- package/packages/core/tsconfig.json +0 -23
- package/packages/extension/README.md +0 -129
- package/packages/extension/package.json +0 -43
- package/packages/extension/src/background.ts +0 -888
- package/packages/extension/src/content.ts +0 -172
- package/packages/extension/src/index.ts +0 -579
- package/packages/extension/src/session-manager.ts +0 -385
- package/packages/extension/src/types.ts +0 -162
- package/packages/extension/tsconfig.json +0 -28
- package/src/index.ts +0 -64
- package/tsconfig.build.json +0 -12
- package/tsconfig.json +0 -26
- package/vitest.config.ts +0 -13
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @btcp/cli - Type definitions
|
|
3
|
-
*
|
|
4
|
-
* Types for CLI commands, parsing, and execution.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { Response } from '@btcp/extension';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Parsed CLI command structure
|
|
11
|
-
*/
|
|
12
|
-
export interface ParsedCommand {
|
|
13
|
-
/** Command name (e.g., 'goto', 'click', 'snapshot') */
|
|
14
|
-
name: string;
|
|
15
|
-
/** Positional arguments */
|
|
16
|
-
args: string[];
|
|
17
|
-
/** Flag arguments (--flag or --flag=value) */
|
|
18
|
-
flags: Record<string, string | boolean>;
|
|
19
|
-
/** Original raw input */
|
|
20
|
-
raw: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Command execution result
|
|
25
|
-
*/
|
|
26
|
-
export interface CommandResult {
|
|
27
|
-
/** Whether the command succeeded */
|
|
28
|
-
success: boolean;
|
|
29
|
-
/** Human-readable message */
|
|
30
|
-
message?: string;
|
|
31
|
-
/** Result data (varies by command) */
|
|
32
|
-
data?: unknown;
|
|
33
|
-
/** Error message if failed */
|
|
34
|
-
error?: string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Result of executing multiple commands
|
|
39
|
-
*/
|
|
40
|
-
export interface BatchResult {
|
|
41
|
-
/** Results for each command in order */
|
|
42
|
-
results: CommandResult[];
|
|
43
|
-
/** Whether all commands succeeded */
|
|
44
|
-
allSucceeded: boolean;
|
|
45
|
-
/** Index of first failed command (-1 if all succeeded) */
|
|
46
|
-
firstFailedIndex: number;
|
|
47
|
-
/** Total number of commands executed */
|
|
48
|
-
executed: number;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Command handler definition
|
|
53
|
-
*/
|
|
54
|
-
export interface CommandHandler {
|
|
55
|
-
/** Command name */
|
|
56
|
-
name: string;
|
|
57
|
-
/** Brief description */
|
|
58
|
-
description: string;
|
|
59
|
-
/** Usage pattern (e.g., 'goto <url>') */
|
|
60
|
-
usage: string;
|
|
61
|
-
/** Example usages */
|
|
62
|
-
examples?: string[];
|
|
63
|
-
/** Execute the command */
|
|
64
|
-
execute: CommandExecuteFn;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Command execute function signature
|
|
69
|
-
*/
|
|
70
|
-
export type CommandExecuteFn = (
|
|
71
|
-
client: CommandClient,
|
|
72
|
-
args: string[],
|
|
73
|
-
flags: Record<string, string | boolean>
|
|
74
|
-
) => Promise<CommandResult>;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Client interface for command execution
|
|
78
|
-
* This is a subset of the @btcp/extension Client
|
|
79
|
-
*/
|
|
80
|
-
export interface CommandClient {
|
|
81
|
-
execute(command: import('@btcp/extension').Command): Promise<Response>;
|
|
82
|
-
navigate(url: string, options?: { waitUntil?: 'load' | 'domcontentloaded' }): Promise<Response>;
|
|
83
|
-
back(): Promise<Response>;
|
|
84
|
-
forward(): Promise<Response>;
|
|
85
|
-
reload(options?: { bypassCache?: boolean }): Promise<Response>;
|
|
86
|
-
getUrl(): Promise<string>;
|
|
87
|
-
getTitle(): Promise<string>;
|
|
88
|
-
snapshot(options?: { selector?: string; maxDepth?: number }): Promise<{
|
|
89
|
-
tree: string;
|
|
90
|
-
refs: Record<string, { selector: string; role: string; name?: string }>;
|
|
91
|
-
}>;
|
|
92
|
-
click(selector: string, options?: { button?: 'left' | 'right' | 'middle' }): Promise<Response>;
|
|
93
|
-
type(selector: string, text: string, options?: { delay?: number; clear?: boolean }): Promise<Response>;
|
|
94
|
-
fill(selector: string, value: string): Promise<Response>;
|
|
95
|
-
getText(selector: string): Promise<string | null>;
|
|
96
|
-
isVisible(selector: string): Promise<boolean>;
|
|
97
|
-
screenshot(options?: { format?: 'png' | 'jpeg'; quality?: number }): Promise<string>;
|
|
98
|
-
tabNew(options?: { url?: string; active?: boolean }): Promise<{ tabId: number; url?: string }>;
|
|
99
|
-
tabClose(tabId?: number): Promise<Response>;
|
|
100
|
-
tabSwitch(tabId: number): Promise<Response>;
|
|
101
|
-
tabList(): Promise<import('@btcp/extension').TabInfo[]>;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Formatted output for terminal display
|
|
106
|
-
*/
|
|
107
|
-
export interface FormattedOutput {
|
|
108
|
-
/** Output type for styling */
|
|
109
|
-
type: 'success' | 'error' | 'info' | 'data';
|
|
110
|
-
/** Text content */
|
|
111
|
-
content: string;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Terminal history entry
|
|
116
|
-
*/
|
|
117
|
-
export interface HistoryEntry {
|
|
118
|
-
/** Entry type */
|
|
119
|
-
type: 'input' | 'output' | 'error' | 'info';
|
|
120
|
-
/** Text content */
|
|
121
|
-
content: string;
|
|
122
|
-
/** Timestamp */
|
|
123
|
-
timestamp: number;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Terminal configuration
|
|
128
|
-
*/
|
|
129
|
-
export interface TerminalConfig {
|
|
130
|
-
/** Color theme */
|
|
131
|
-
theme: 'dark' | 'light';
|
|
132
|
-
/** Font size in pixels */
|
|
133
|
-
fontSize: number;
|
|
134
|
-
/** Max history entries */
|
|
135
|
-
historySize: number;
|
|
136
|
-
/** Command prompt string */
|
|
137
|
-
prompt: string;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* CLI instance interface
|
|
142
|
-
*/
|
|
143
|
-
export interface CLI {
|
|
144
|
-
/** Execute a single command or multiple commands (split by \n) */
|
|
145
|
-
execute(input: string): Promise<CommandResult>;
|
|
146
|
-
/**
|
|
147
|
-
* Execute multiple commands (split by \n)
|
|
148
|
-
* Stops on first error unless continueOnError is true
|
|
149
|
-
*/
|
|
150
|
-
executeAll(input: string, options?: { continueOnError?: boolean }): Promise<BatchResult>;
|
|
151
|
-
/** Get available commands */
|
|
152
|
-
getCommands(): CommandHandler[];
|
|
153
|
-
/** Get help for a specific command */
|
|
154
|
-
getHelp(commandName?: string): string;
|
|
155
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"declarationMap": true,
|
|
8
|
-
"sourceMap": true,
|
|
9
|
-
"outDir": "./dist",
|
|
10
|
-
"rootDir": "./src",
|
|
11
|
-
"strict": true,
|
|
12
|
-
"esModuleInterop": true,
|
|
13
|
-
"skipLibCheck": true,
|
|
14
|
-
"forceConsistentCasingInFileNames": true,
|
|
15
|
-
"resolveJsonModule": true,
|
|
16
|
-
"isolatedModules": true
|
|
17
|
-
},
|
|
18
|
-
"include": ["src/**/*"],
|
|
19
|
-
"exclude": ["node_modules", "dist"]
|
|
20
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@btcp/core",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"description": "Core DOM actions for browser automation - runs in any browser context",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.js"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "tsc",
|
|
16
|
-
"test": "vitest",
|
|
17
|
-
"clean": "rm -rf dist"
|
|
18
|
-
},
|
|
19
|
-
"files": [
|
|
20
|
-
"dist",
|
|
21
|
-
"src"
|
|
22
|
-
],
|
|
23
|
-
"keywords": [
|
|
24
|
-
"browser",
|
|
25
|
-
"automation",
|
|
26
|
-
"dom",
|
|
27
|
-
"accessibility"
|
|
28
|
-
],
|
|
29
|
-
"license": "Apache-2.0",
|
|
30
|
-
"devDependencies": {
|
|
31
|
-
"typescript": "^5.3.0",
|
|
32
|
-
"vitest": "^1.0.0",
|
|
33
|
-
"jsdom": "^24.0.0"
|
|
34
|
-
}
|
|
35
|
-
}
|