@thinkbrowse/cli 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/README.md +246 -0
- package/dist/bin/thinkbrowse.d.ts +6 -0
- package/dist/bin/thinkbrowse.d.ts.map +1 -0
- package/dist/bin/thinkbrowse.js +58 -0
- package/dist/bin/thinkbrowse.js.map +1 -0
- package/dist/src/adapters/cloud.d.ts +46 -0
- package/dist/src/adapters/cloud.d.ts.map +1 -0
- package/dist/src/adapters/cloud.js +336 -0
- package/dist/src/adapters/cloud.js.map +1 -0
- package/dist/src/adapters/types.d.ts +39 -0
- package/dist/src/adapters/types.d.ts.map +1 -0
- package/dist/src/adapters/types.js +6 -0
- package/dist/src/adapters/types.js.map +1 -0
- package/dist/src/commands/actions.d.ts +26 -0
- package/dist/src/commands/actions.d.ts.map +1 -0
- package/dist/src/commands/actions.js +540 -0
- package/dist/src/commands/actions.js.map +1 -0
- package/dist/src/commands/cloud.d.ts +6 -0
- package/dist/src/commands/cloud.d.ts.map +1 -0
- package/dist/src/commands/cloud.js +212 -0
- package/dist/src/commands/cloud.js.map +1 -0
- package/dist/src/commands/config.d.ts +6 -0
- package/dist/src/commands/config.d.ts.map +1 -0
- package/dist/src/commands/config.js +123 -0
- package/dist/src/commands/config.js.map +1 -0
- package/dist/src/config/store.d.ts +22 -0
- package/dist/src/config/store.d.ts.map +1 -0
- package/dist/src/config/store.js +80 -0
- package/dist/src/config/store.js.map +1 -0
- package/dist/src/errors.d.ts +22 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +40 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/output/formatter.d.ts +18 -0
- package/dist/src/output/formatter.d.ts.map +1 -0
- package/dist/src/output/formatter.js +28 -0
- package/dist/src/output/formatter.js.map +1 -0
- package/dist/src/types.d.ts +108 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +5 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils.d.ts +5 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +18 -0
- package/dist/src/utils.js.map +1 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# @thinkbrowse/cli
|
|
2
|
+
|
|
3
|
+
CLI for controlling browsers via ThinkBrowse cloud infrastructure. 21 commands covering the full browser automation API.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Node.js 18+ (uses native `fetch`)
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g @thinkbrowse/cli
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# 1. Configure API key
|
|
19
|
+
thinkbrowse config set-key mech_browse_your_api_key_here
|
|
20
|
+
|
|
21
|
+
# 2. Start a cloud browser session (waits for provisioning)
|
|
22
|
+
thinkbrowse cloud start
|
|
23
|
+
|
|
24
|
+
# 3. Navigate and interact
|
|
25
|
+
thinkbrowse navigate "https://example.com"
|
|
26
|
+
thinkbrowse snapshot # Get accessibility tree
|
|
27
|
+
thinkbrowse click "button.submit"
|
|
28
|
+
thinkbrowse screenshot --output page.png
|
|
29
|
+
|
|
30
|
+
# 4. Stop the session
|
|
31
|
+
thinkbrowse cloud stop
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## AI Agent Workflow
|
|
35
|
+
|
|
36
|
+
The `snapshot` command returns an accessibility tree — ideal for AI agents that need to understand page structure without screenshots:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
thinkbrowse cloud start
|
|
40
|
+
thinkbrowse navigate "https://github.com/trending"
|
|
41
|
+
thinkbrowse snapshot # Returns accessibility tree
|
|
42
|
+
thinkbrowse click "a.repo-name" # AI decides what to click
|
|
43
|
+
thinkbrowse wait-for-text "README" # Wait for content
|
|
44
|
+
thinkbrowse extract "article" --format json
|
|
45
|
+
thinkbrowse cloud stop
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Commands
|
|
49
|
+
|
|
50
|
+
### Session Management
|
|
51
|
+
|
|
52
|
+
| Command | Description |
|
|
53
|
+
|---------|-------------|
|
|
54
|
+
| `cloud start` | Start a new cloud browser session |
|
|
55
|
+
| `cloud stop` | Stop the active session |
|
|
56
|
+
| `cloud list` | List all active sessions |
|
|
57
|
+
| `cloud status` | Show session details |
|
|
58
|
+
| `cloud use <id>` | Switch active session |
|
|
59
|
+
|
|
60
|
+
#### Cloud Start Options
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
thinkbrowse cloud start [options]
|
|
64
|
+
|
|
65
|
+
Options:
|
|
66
|
+
-b, --browser <type> Browser: chromium (default), firefox, webkit
|
|
67
|
+
--proxy Enable proxy rotation
|
|
68
|
+
--stealth Enable anti-detection mode
|
|
69
|
+
--no-wait Return immediately without waiting for ready
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Navigation
|
|
73
|
+
|
|
74
|
+
| Command | Description |
|
|
75
|
+
|---------|-------------|
|
|
76
|
+
| `navigate <url>` | Navigate to a URL |
|
|
77
|
+
| `back` | Go back in browser history |
|
|
78
|
+
| `forward` | Go forward in browser history |
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
thinkbrowse navigate "https://example.com" --wait-until networkidle
|
|
82
|
+
thinkbrowse back
|
|
83
|
+
thinkbrowse forward
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Interaction
|
|
87
|
+
|
|
88
|
+
| Command | Description |
|
|
89
|
+
|---------|-------------|
|
|
90
|
+
| `click <selector>` | Click an element |
|
|
91
|
+
| `type <selector> <text>` | Type text (appends) |
|
|
92
|
+
| `fill <selector> <value>` | Fill form field (clears first) |
|
|
93
|
+
| `press <key>` | Press keyboard key |
|
|
94
|
+
| `scroll` | Scroll the page |
|
|
95
|
+
| `hover <selector>` | Hover over element |
|
|
96
|
+
| `select <selector> <value>` | Select dropdown option |
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
thinkbrowse fill "#email" "user@example.com"
|
|
100
|
+
thinkbrowse fill "#password" "secret123"
|
|
101
|
+
thinkbrowse press Enter
|
|
102
|
+
thinkbrowse click ".submit-btn" --timeout 5000
|
|
103
|
+
thinkbrowse hover ".dropdown-trigger"
|
|
104
|
+
thinkbrowse select "#country" "US"
|
|
105
|
+
thinkbrowse scroll --down 500
|
|
106
|
+
thinkbrowse scroll --to "#footer"
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Waiting
|
|
110
|
+
|
|
111
|
+
| Command | Description |
|
|
112
|
+
|---------|-------------|
|
|
113
|
+
| `wait <condition>` | Wait for element or time (ms) |
|
|
114
|
+
| `wait-for-text <text>` | Wait for text on page |
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
thinkbrowse wait 2000 # Wait 2 seconds
|
|
118
|
+
thinkbrowse wait ".loading-complete" # Wait for element
|
|
119
|
+
thinkbrowse wait ".spinner" --hidden # Wait for element to hide
|
|
120
|
+
thinkbrowse wait-for-text "Success" --timeout 10000 # Wait for text
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Observation
|
|
124
|
+
|
|
125
|
+
| Command | Description |
|
|
126
|
+
|---------|-------------|
|
|
127
|
+
| `snapshot` | Get accessibility tree |
|
|
128
|
+
| `screenshot` | Capture screenshot |
|
|
129
|
+
| `extract <selector>` | Extract content from elements |
|
|
130
|
+
| `evaluate [script]` | Execute JavaScript in page |
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
thinkbrowse snapshot
|
|
134
|
+
thinkbrowse screenshot --output page.png --full-page
|
|
135
|
+
thinkbrowse extract "h1"
|
|
136
|
+
thinkbrowse extract ".item" --all --format json
|
|
137
|
+
thinkbrowse extract "a" --attr href --all
|
|
138
|
+
thinkbrowse evaluate "document.title"
|
|
139
|
+
thinkbrowse evaluate --file script.js
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Dialog Handling
|
|
143
|
+
|
|
144
|
+
| Command | Description |
|
|
145
|
+
|---------|-------------|
|
|
146
|
+
| `dialog get` | Check for pending dialog |
|
|
147
|
+
| `dialog accept [text]` | Accept dialog |
|
|
148
|
+
| `dialog dismiss` | Dismiss dialog |
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
thinkbrowse dialog get # Check for alerts/confirms/prompts
|
|
152
|
+
thinkbrowse dialog accept # Accept alert/confirm
|
|
153
|
+
thinkbrowse dialog accept "my answer" # Accept prompt with text
|
|
154
|
+
thinkbrowse dialog dismiss # Dismiss/cancel dialog
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Monitoring
|
|
158
|
+
|
|
159
|
+
| Command | Description |
|
|
160
|
+
|---------|-------------|
|
|
161
|
+
| `console` | Get browser console messages |
|
|
162
|
+
| `network` | Get network requests |
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
thinkbrowse console # View console.log, warnings, errors
|
|
166
|
+
thinkbrowse network # View XHR, fetch, and other requests
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Configuration
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
thinkbrowse config set-key <api-key> # Set API key
|
|
173
|
+
thinkbrowse config show # Show current config
|
|
174
|
+
thinkbrowse config set apiUrl <url> # Set custom API URL
|
|
175
|
+
thinkbrowse config set defaultBrowser firefox
|
|
176
|
+
thinkbrowse config reset # Reset all config
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Config file: `~/.thinkbrowse/config.json`
|
|
180
|
+
|
|
181
|
+
## Global Options
|
|
182
|
+
|
|
183
|
+
- `--json` — Force JSON output (auto-enabled for non-TTY)
|
|
184
|
+
- `--quiet` — Suppress non-error output
|
|
185
|
+
- `--verbose` — Show debugging info
|
|
186
|
+
|
|
187
|
+
## Examples
|
|
188
|
+
|
|
189
|
+
### Web Scraping
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
thinkbrowse cloud start
|
|
193
|
+
thinkbrowse navigate "https://news.ycombinator.com"
|
|
194
|
+
thinkbrowse extract ".titleline > a" --all --format json > titles.json
|
|
195
|
+
thinkbrowse screenshot --output hn.png
|
|
196
|
+
thinkbrowse cloud stop
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Form Automation
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
thinkbrowse cloud start
|
|
203
|
+
thinkbrowse navigate "https://example.com/login"
|
|
204
|
+
thinkbrowse fill "#email" "user@example.com"
|
|
205
|
+
thinkbrowse fill "#password" "secret123"
|
|
206
|
+
thinkbrowse click "button[type=submit]"
|
|
207
|
+
thinkbrowse wait-for-text "Dashboard"
|
|
208
|
+
thinkbrowse screenshot --output logged-in.png
|
|
209
|
+
thinkbrowse cloud stop
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Debugging a Page
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
thinkbrowse cloud start
|
|
216
|
+
thinkbrowse navigate "https://myapp.com"
|
|
217
|
+
thinkbrowse console # Check for JS errors
|
|
218
|
+
thinkbrowse network # Check failed requests
|
|
219
|
+
thinkbrowse snapshot # See page structure
|
|
220
|
+
thinkbrowse cloud stop
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Error Handling
|
|
224
|
+
|
|
225
|
+
The CLI returns structured errors with suggestions:
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
Error: API key not configured
|
|
229
|
+
Tip: Run: thinkbrowse config set-key <your-api-key>
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Retryable errors (502, 503) are automatically retried with exponential backoff.
|
|
233
|
+
|
|
234
|
+
## Troubleshooting
|
|
235
|
+
|
|
236
|
+
| Issue | Solution |
|
|
237
|
+
|-------|----------|
|
|
238
|
+
| `API key not configured` | Run `thinkbrowse config set-key <key>` |
|
|
239
|
+
| `No active session` | Run `thinkbrowse cloud start` first |
|
|
240
|
+
| `Session provisioning timed out` | Check `thinkbrowse cloud status`, try again |
|
|
241
|
+
| `fetch is not defined` | Upgrade to Node.js 18+ |
|
|
242
|
+
| All requests return 404 | Update to latest CLI version |
|
|
243
|
+
|
|
244
|
+
## License
|
|
245
|
+
|
|
246
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinkbrowse.d.ts","sourceRoot":"","sources":["../../bin/thinkbrowse.ts"],"names":[],"mappings":";AAEA;;GAEG"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* ThinkBrowse CLI Entry Point
|
|
4
|
+
*/
|
|
5
|
+
import { Command } from 'commander';
|
|
6
|
+
import { readFileSync } from 'fs';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
import { dirname, join } from 'path';
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = dirname(__filename);
|
|
11
|
+
// Read package.json for version
|
|
12
|
+
// When compiled, __dirname will be dist/bin, so we need to go up two levels
|
|
13
|
+
const packageJson = JSON.parse(readFileSync(join(__dirname, '..', '..', 'package.json'), 'utf-8'));
|
|
14
|
+
const program = new Command();
|
|
15
|
+
program
|
|
16
|
+
.name('thinkbrowse')
|
|
17
|
+
.description('CLI for controlling browsers via ThinkBrowse')
|
|
18
|
+
.version(packageJson.version)
|
|
19
|
+
.option('--json', 'Output in JSON format (default for non-TTY)')
|
|
20
|
+
.option('--quiet', 'Suppress non-error output')
|
|
21
|
+
.option('--verbose', 'Verbose output with debugging info');
|
|
22
|
+
// Import commands
|
|
23
|
+
import { createConfigCommand } from '../src/commands/config.js';
|
|
24
|
+
import { createCloudCommand } from '../src/commands/cloud.js';
|
|
25
|
+
import { createNavigateCommand, createClickCommand, createTypeCommand, createFillCommand, createScrollCommand, createWaitCommand, createWaitForTextCommand, createHoverCommand, createSelectCommand, createPressCommand, createBackCommand, createForwardCommand, createSnapshotCommand, createScreenshotCommand, createExtractCommand, createEvaluateCommand, createDialogCommand, createConsoleCommand, createNetworkCommand, } from '../src/commands/actions.js';
|
|
26
|
+
// Add commands
|
|
27
|
+
program.addCommand(createConfigCommand());
|
|
28
|
+
program.addCommand(createCloudCommand());
|
|
29
|
+
// Browser actions
|
|
30
|
+
program.addCommand(createNavigateCommand());
|
|
31
|
+
program.addCommand(createBackCommand());
|
|
32
|
+
program.addCommand(createForwardCommand());
|
|
33
|
+
program.addCommand(createClickCommand());
|
|
34
|
+
program.addCommand(createTypeCommand());
|
|
35
|
+
program.addCommand(createFillCommand());
|
|
36
|
+
program.addCommand(createPressCommand());
|
|
37
|
+
program.addCommand(createScrollCommand());
|
|
38
|
+
program.addCommand(createHoverCommand());
|
|
39
|
+
program.addCommand(createSelectCommand());
|
|
40
|
+
// Waiting
|
|
41
|
+
program.addCommand(createWaitCommand());
|
|
42
|
+
program.addCommand(createWaitForTextCommand());
|
|
43
|
+
// Observation
|
|
44
|
+
program.addCommand(createSnapshotCommand());
|
|
45
|
+
program.addCommand(createScreenshotCommand());
|
|
46
|
+
program.addCommand(createExtractCommand());
|
|
47
|
+
program.addCommand(createEvaluateCommand());
|
|
48
|
+
// Dialog, console, network
|
|
49
|
+
program.addCommand(createDialogCommand());
|
|
50
|
+
program.addCommand(createConsoleCommand());
|
|
51
|
+
program.addCommand(createNetworkCommand());
|
|
52
|
+
// Parse arguments
|
|
53
|
+
program.parse(process.argv);
|
|
54
|
+
// Show help if no command provided
|
|
55
|
+
if (!process.argv.slice(2).length) {
|
|
56
|
+
program.outputHelp();
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=thinkbrowse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinkbrowse.js","sourceRoot":"","sources":["../../bin/thinkbrowse.ts"],"names":[],"mappings":";AAEA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,E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C,kBAAkB;AAClB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B,mCAAmC;AACnC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,OAAO,CAAC,UAAU,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloud API adapter - connects to thinkbrowse.io API
|
|
3
|
+
*/
|
|
4
|
+
import type { BrowserAdapter } from './types.js';
|
|
5
|
+
import type { Session, SessionOptions, ActionResult, NavigateOptions, ClickOptions, TypeOptions, ScreenshotOptions, ExtractOptions, WaitOptions, DialogResult, ConsoleResult, NetworkResult } from '../types.js';
|
|
6
|
+
export declare class CloudAdapter implements BrowserAdapter {
|
|
7
|
+
private baseUrl;
|
|
8
|
+
private apiKey;
|
|
9
|
+
private defaultTimeout;
|
|
10
|
+
constructor(apiKey?: string, baseUrl?: string);
|
|
11
|
+
private request;
|
|
12
|
+
private sleep;
|
|
13
|
+
private getActiveSessionId;
|
|
14
|
+
startSession(options?: SessionOptions): Promise<Session>;
|
|
15
|
+
waitForSessionReady(sessionId: string, timeout?: number): Promise<Session>;
|
|
16
|
+
stopSession(sessionId?: string): Promise<void>;
|
|
17
|
+
getSession(sessionId: string): Promise<Session>;
|
|
18
|
+
listSessions(): Promise<Session[]>;
|
|
19
|
+
navigate(url: string, options?: NavigateOptions): Promise<ActionResult>;
|
|
20
|
+
goBack(): Promise<ActionResult>;
|
|
21
|
+
goForward(): Promise<ActionResult>;
|
|
22
|
+
click(selector: string, options?: ClickOptions): Promise<ActionResult>;
|
|
23
|
+
type(selector: string, text: string, options?: TypeOptions): Promise<ActionResult>;
|
|
24
|
+
fill(selector: string, value: string): Promise<ActionResult>;
|
|
25
|
+
press(key: string): Promise<ActionResult>;
|
|
26
|
+
scroll(options: {
|
|
27
|
+
selector?: string;
|
|
28
|
+
x?: number;
|
|
29
|
+
y?: number;
|
|
30
|
+
}): Promise<ActionResult>;
|
|
31
|
+
hover(selector: string): Promise<ActionResult>;
|
|
32
|
+
select(selector: string, value: string): Promise<ActionResult>;
|
|
33
|
+
wait(condition: string | number, options?: WaitOptions): Promise<ActionResult>;
|
|
34
|
+
waitForText(text: string, options?: {
|
|
35
|
+
timeout?: number;
|
|
36
|
+
}): Promise<ActionResult>;
|
|
37
|
+
snapshot(): Promise<ActionResult>;
|
|
38
|
+
screenshot(options?: ScreenshotOptions): Promise<ActionResult>;
|
|
39
|
+
extract(selector: string, options?: ExtractOptions): Promise<ActionResult>;
|
|
40
|
+
evaluate(script: string, args?: any[]): Promise<ActionResult>;
|
|
41
|
+
getDialog(): Promise<DialogResult>;
|
|
42
|
+
handleDialog(action: 'accept' | 'dismiss', promptText?: string): Promise<ActionResult>;
|
|
43
|
+
getConsoleMessages(): Promise<ConsoleResult>;
|
|
44
|
+
getNetworkRequests(): Promise<NetworkResult>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=cloud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud.d.ts","sourceRoot":"","sources":["../../../src/adapters/cloud.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EACd,MAAM,aAAa,CAAC;AAIrB,qBAAa,YAAa,YAAW,cAAc;IACjD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,cAAc,CAAS;gBAEnB,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;YAa/B,OAAO;IAsErB,OAAO,CA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