@midscene/web 0.27.5 → 0.27.6
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/bin/midscene-playground +1 -1
- package/dist/es/bin.mjs +7 -0
- package/dist/es/bin.mjs.map +1 -0
- package/dist/es/bridge-mode/io-client.mjs +1 -1
- package/dist/es/bridge-mode/io-server.mjs +2 -2
- package/dist/es/bridge-mode/page-browser-side.mjs +1 -1
- package/dist/es/index.mjs +2 -3
- package/dist/es/web-element.mjs +3 -3
- package/dist/es/web-element.mjs.map +1 -1
- package/dist/lib/bin.js +13 -0
- package/dist/lib/bin.js.map +1 -0
- package/dist/lib/bridge-mode/io-client.js +1 -1
- package/dist/lib/bridge-mode/io-server.js +2 -2
- package/dist/lib/bridge-mode/page-browser-side.js +1 -1
- package/dist/lib/index.js +6 -16
- package/dist/lib/web-element.js +5 -5
- package/dist/lib/web-element.js.map +1 -1
- package/dist/types/index.d.ts +2 -3
- package/dist/types/web-element.d.ts +3 -11
- package/package.json +7 -25
- package/dist/es/playground/agent.mjs +0 -10
- package/dist/es/playground/agent.mjs.map +0 -1
- package/dist/es/playground/bin.mjs +0 -8
- package/dist/es/playground/bin.mjs.map +0 -1
- package/dist/es/playground/common.mjs +0 -130
- package/dist/es/playground/common.mjs.map +0 -1
- package/dist/es/playground/index.mjs +0 -5
- package/dist/es/playground/server.mjs +0 -256
- package/dist/es/playground/server.mjs.map +0 -1
- package/dist/es/playground/static-page.mjs +0 -104
- package/dist/es/playground/static-page.mjs.map +0 -1
- package/dist/lib/playground/agent.js +0 -44
- package/dist/lib/playground/agent.js.map +0 -1
- package/dist/lib/playground/bin.js +0 -36
- package/dist/lib/playground/bin.js.map +0 -1
- package/dist/lib/playground/common.js +0 -179
- package/dist/lib/playground/common.js.map +0 -1
- package/dist/lib/playground/index.js +0 -66
- package/dist/lib/playground/index.js.map +0 -1
- package/dist/lib/playground/server.js +0 -302
- package/dist/lib/playground/server.js.map +0 -1
- package/dist/lib/playground/static-page.js +0 -138
- package/dist/lib/playground/static-page.js.map +0 -1
- package/dist/types/playground/agent.d.ts +0 -5
- package/dist/types/playground/common.d.ts +0 -10
- package/dist/types/playground/index.d.ts +0 -5
- package/dist/types/playground/server.d.ts +0 -20
- package/dist/types/playground/static-page.d.ts +0 -39
- /package/dist/types/{playground/bin.d.ts → bin.d.ts} +0 -0
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { getTmpDir } from "@midscene/core/utils";
|
|
5
|
-
import { PLAYGROUND_SERVER_PORT } from "@midscene/shared/constants";
|
|
6
|
-
import { overrideAIConfig } from "@midscene/shared/env";
|
|
7
|
-
import { ifInBrowser, ifInWorker } from "@midscene/shared/utils";
|
|
8
|
-
import cors from "cors";
|
|
9
|
-
import dotenv from "dotenv";
|
|
10
|
-
import express from "express";
|
|
11
|
-
import { executeAction, formatErrorMessage } from "./common.mjs";
|
|
12
|
-
function _define_property(obj, key, value) {
|
|
13
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
14
|
-
value: value,
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true
|
|
18
|
-
});
|
|
19
|
-
else obj[key] = value;
|
|
20
|
-
return obj;
|
|
21
|
-
}
|
|
22
|
-
const defaultPort = PLAYGROUND_SERVER_PORT;
|
|
23
|
-
const errorHandler = (err, req, res, next)=>{
|
|
24
|
-
console.error(err);
|
|
25
|
-
res.status(500).json({
|
|
26
|
-
error: err.message
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
const setup = async ()=>{
|
|
30
|
-
if (!ifInBrowser && !ifInWorker) dotenv.config();
|
|
31
|
-
};
|
|
32
|
-
class PlaygroundServer {
|
|
33
|
-
filePathForUuid(uuid) {
|
|
34
|
-
return join(this.tmpDir, `${uuid}.json`);
|
|
35
|
-
}
|
|
36
|
-
saveContextFile(uuid, context) {
|
|
37
|
-
const tmpFile = this.filePathForUuid(uuid);
|
|
38
|
-
console.log(`save context file: ${tmpFile}`);
|
|
39
|
-
writeFileSync(tmpFile, context);
|
|
40
|
-
return tmpFile;
|
|
41
|
-
}
|
|
42
|
-
async launch(port) {
|
|
43
|
-
this.port = port || defaultPort;
|
|
44
|
-
this.app.use(errorHandler);
|
|
45
|
-
this.app.use(cors({
|
|
46
|
-
origin: '*',
|
|
47
|
-
credentials: true
|
|
48
|
-
}));
|
|
49
|
-
this.app.get('/status', async (req, res)=>{
|
|
50
|
-
res.send({
|
|
51
|
-
status: 'ok'
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
this.app.get('/context/:uuid', async (req, res)=>{
|
|
55
|
-
const { uuid } = req.params;
|
|
56
|
-
const contextFile = this.filePathForUuid(uuid);
|
|
57
|
-
if (!existsSync(contextFile)) return res.status(404).json({
|
|
58
|
-
error: 'Context not found'
|
|
59
|
-
});
|
|
60
|
-
const context = readFileSync(contextFile, 'utf8');
|
|
61
|
-
res.json({
|
|
62
|
-
context
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
this.app.get('/task-progress/:requestId', async (req, res)=>{
|
|
66
|
-
const { requestId } = req.params;
|
|
67
|
-
res.json({
|
|
68
|
-
tip: this.taskProgressTips[requestId] || ''
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
this.app.post('/action-space', express.json({
|
|
72
|
-
limit: '30mb'
|
|
73
|
-
}), async (req, res)=>{
|
|
74
|
-
const { context } = req.body;
|
|
75
|
-
if (!context) return res.status(400).json({
|
|
76
|
-
error: 'context is required'
|
|
77
|
-
});
|
|
78
|
-
try {
|
|
79
|
-
const page = new this.pageClass(context);
|
|
80
|
-
const actionSpace = await page.actionSpace();
|
|
81
|
-
const processedActionSpace = actionSpace.map((action)=>{
|
|
82
|
-
if (action.paramSchema && 'object' == typeof action.paramSchema) {
|
|
83
|
-
let processedSchema = null;
|
|
84
|
-
try {
|
|
85
|
-
if (action.paramSchema.shape && 'object' == typeof action.paramSchema.shape) processedSchema = {
|
|
86
|
-
type: 'ZodObject',
|
|
87
|
-
shape: action.paramSchema.shape
|
|
88
|
-
};
|
|
89
|
-
} catch (e) {
|
|
90
|
-
console.warn('Failed to process paramSchema for action:', action.name, e);
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
...action,
|
|
94
|
-
paramSchema: processedSchema
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
return action;
|
|
98
|
-
});
|
|
99
|
-
res.json(processedActionSpace);
|
|
100
|
-
} catch (error) {
|
|
101
|
-
console.error('Failed to get action space:', error);
|
|
102
|
-
res.status(500).json({
|
|
103
|
-
error: error.message
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
this.app.post('/playground-with-context', express.json({
|
|
108
|
-
limit: '50mb'
|
|
109
|
-
}), async (req, res)=>{
|
|
110
|
-
const context = req.body.context;
|
|
111
|
-
if (!context) return res.status(400).json({
|
|
112
|
-
error: 'context is required'
|
|
113
|
-
});
|
|
114
|
-
const uuid = randomUUID();
|
|
115
|
-
this.saveContextFile(uuid, context);
|
|
116
|
-
return res.json({
|
|
117
|
-
location: `/playground/${uuid}`,
|
|
118
|
-
uuid
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
this.app.post('/execute', express.json({
|
|
122
|
-
limit: '30mb'
|
|
123
|
-
}), async (req, res)=>{
|
|
124
|
-
const { context, type, prompt, params, requestId, deepThink, screenshotIncluded, domIncluded } = req.body;
|
|
125
|
-
if (!context) return res.status(400).json({
|
|
126
|
-
error: 'context is required'
|
|
127
|
-
});
|
|
128
|
-
if (!type) return res.status(400).json({
|
|
129
|
-
error: 'type is required'
|
|
130
|
-
});
|
|
131
|
-
const page = new this.pageClass(context);
|
|
132
|
-
const agent = new this.agentClass(page);
|
|
133
|
-
if (requestId) {
|
|
134
|
-
this.taskProgressTips[requestId] = '';
|
|
135
|
-
this.activeAgents[requestId] = agent;
|
|
136
|
-
agent.onTaskStartTip = (tip)=>{
|
|
137
|
-
this.taskProgressTips[requestId] = tip;
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
const response = {
|
|
141
|
-
result: null,
|
|
142
|
-
dump: null,
|
|
143
|
-
error: null,
|
|
144
|
-
reportHTML: null,
|
|
145
|
-
requestId
|
|
146
|
-
};
|
|
147
|
-
const startTime = Date.now();
|
|
148
|
-
try {
|
|
149
|
-
const actionSpace = await page.actionSpace();
|
|
150
|
-
const value = {
|
|
151
|
-
prompt,
|
|
152
|
-
params
|
|
153
|
-
};
|
|
154
|
-
response.result = await executeAction(agent, type, actionSpace, value, deepThink || false);
|
|
155
|
-
} catch (error) {
|
|
156
|
-
response.error = formatErrorMessage(error);
|
|
157
|
-
}
|
|
158
|
-
try {
|
|
159
|
-
response.dump = JSON.parse(agent.dumpDataString());
|
|
160
|
-
response.reportHTML = agent.reportHTMLString() || null;
|
|
161
|
-
agent.writeOutActionDumps();
|
|
162
|
-
agent.destroy();
|
|
163
|
-
} catch (error) {
|
|
164
|
-
console.error(`write out dump failed: requestId: ${requestId}, ${error.message}`);
|
|
165
|
-
}
|
|
166
|
-
res.send(response);
|
|
167
|
-
const timeCost = Date.now() - startTime;
|
|
168
|
-
if (response.error) console.error(`handle request failed after ${timeCost}ms: requestId: ${requestId}, ${response.error}`);
|
|
169
|
-
else console.log(`handle request done after ${timeCost}ms: requestId: ${requestId}`);
|
|
170
|
-
if (requestId && this.activeAgents[requestId]) delete this.activeAgents[requestId];
|
|
171
|
-
});
|
|
172
|
-
this.app.get('/cancel/:requestId', async (req, res)=>{
|
|
173
|
-
const { requestId } = req.params;
|
|
174
|
-
if (!requestId) return res.status(400).json({
|
|
175
|
-
error: 'requestId is required'
|
|
176
|
-
});
|
|
177
|
-
const agent = this.activeAgents[requestId];
|
|
178
|
-
if (!agent) return res.status(404).json({
|
|
179
|
-
error: 'No active agent found for this requestId'
|
|
180
|
-
});
|
|
181
|
-
try {
|
|
182
|
-
await agent.destroy();
|
|
183
|
-
delete this.activeAgents[requestId];
|
|
184
|
-
res.json({
|
|
185
|
-
status: 'cancelled'
|
|
186
|
-
});
|
|
187
|
-
} catch (error) {
|
|
188
|
-
console.error(`Failed to cancel agent: ${error.message}`);
|
|
189
|
-
res.status(500).json({
|
|
190
|
-
error: `Failed to cancel: ${error.message}`
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
this.app.post('/config', express.json({
|
|
195
|
-
limit: '1mb'
|
|
196
|
-
}), async (req, res)=>{
|
|
197
|
-
const { aiConfig } = req.body;
|
|
198
|
-
if (!aiConfig || 'object' != typeof aiConfig) return res.status(400).json({
|
|
199
|
-
error: 'aiConfig is required and must be an object'
|
|
200
|
-
});
|
|
201
|
-
try {
|
|
202
|
-
overrideAIConfig(aiConfig);
|
|
203
|
-
return res.json({
|
|
204
|
-
status: 'ok',
|
|
205
|
-
message: 'AI config updated successfully'
|
|
206
|
-
});
|
|
207
|
-
} catch (error) {
|
|
208
|
-
console.error(`Failed to update AI config: ${error.message}`);
|
|
209
|
-
return res.status(500).json({
|
|
210
|
-
error: `Failed to update AI config: ${error.message}`
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
if (this.staticPath) {
|
|
215
|
-
this.app.get('/', (_req, res)=>{
|
|
216
|
-
res.redirect('/index.html');
|
|
217
|
-
});
|
|
218
|
-
this.app.get('*', (req, res)=>{
|
|
219
|
-
const requestedPath = join(this.staticPath, req.path);
|
|
220
|
-
if (existsSync(requestedPath)) res.sendFile(requestedPath);
|
|
221
|
-
else res.sendFile(join(this.staticPath, 'index.html'));
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
return new Promise((resolve)=>{
|
|
225
|
-
const port = this.port;
|
|
226
|
-
this.server = this.app.listen(port, ()=>{
|
|
227
|
-
resolve(this);
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
close() {
|
|
232
|
-
if (this.server) return this.server.close();
|
|
233
|
-
}
|
|
234
|
-
constructor(pageClass, agentClass, staticPath){
|
|
235
|
-
_define_property(this, "app", void 0);
|
|
236
|
-
_define_property(this, "tmpDir", void 0);
|
|
237
|
-
_define_property(this, "server", void 0);
|
|
238
|
-
_define_property(this, "port", void 0);
|
|
239
|
-
_define_property(this, "pageClass", void 0);
|
|
240
|
-
_define_property(this, "agentClass", void 0);
|
|
241
|
-
_define_property(this, "staticPath", void 0);
|
|
242
|
-
_define_property(this, "taskProgressTips", void 0);
|
|
243
|
-
_define_property(this, "activeAgents", void 0);
|
|
244
|
-
this.app = express();
|
|
245
|
-
this.tmpDir = getTmpDir();
|
|
246
|
-
this.pageClass = pageClass;
|
|
247
|
-
this.agentClass = agentClass;
|
|
248
|
-
this.staticPath = staticPath;
|
|
249
|
-
this.taskProgressTips = {};
|
|
250
|
-
this.activeAgents = {};
|
|
251
|
-
setup();
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
export { PlaygroundServer as default };
|
|
255
|
-
|
|
256
|
-
//# sourceMappingURL=server.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"playground/server.mjs","sources":["webpack://@midscene/web/./src/playground/server.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport type { Server } from 'node:http';\nimport { join } from 'node:path';\nimport type { Agent as PageAgent } from '@midscene/core/agent';\nimport type { AbstractInterface } from '@midscene/core/device';\nimport { getTmpDir } from '@midscene/core/utils';\nimport { PLAYGROUND_SERVER_PORT } from '@midscene/shared/constants';\nimport { overrideAIConfig } from '@midscene/shared/env';\nimport { ifInBrowser, ifInWorker } from '@midscene/shared/utils';\nimport cors from 'cors';\nimport dotenv from 'dotenv';\nimport express from 'express';\nimport { executeAction, formatErrorMessage } from './common';\n\nconst defaultPort = PLAYGROUND_SERVER_PORT;\n// const staticPath = join(__dirname, '../../static');\n\nconst errorHandler = (err: any, req: any, res: any, next: any) => {\n console.error(err);\n res.status(500).json({\n error: err.message,\n });\n};\n\nconst setup = async () => {\n if (!ifInBrowser && !ifInWorker) {\n dotenv.config();\n }\n};\n\nexport default class PlaygroundServer {\n app: express.Application;\n tmpDir: string;\n server?: Server;\n port?: number | null;\n pageClass: new (\n ...args: any[]\n ) => AbstractInterface;\n agentClass: new (\n ...args: any[]\n ) => PageAgent;\n staticPath?: string;\n taskProgressTips: Record<string, string>;\n activeAgents: Record<string, PageAgent>;\n\n constructor(\n pageClass: new (...args: any[]) => AbstractInterface,\n agentClass: new (...args: any[]) => PageAgent,\n staticPath?: string,\n ) {\n this.app = express();\n this.tmpDir = getTmpDir()!;\n this.pageClass = pageClass;\n this.agentClass = agentClass;\n this.staticPath = staticPath;\n this.taskProgressTips = {};\n this.activeAgents = {};\n setup();\n }\n\n filePathForUuid(uuid: string) {\n return join(this.tmpDir, `${uuid}.json`);\n }\n\n saveContextFile(uuid: string, context: string) {\n const tmpFile = this.filePathForUuid(uuid);\n console.log(`save context file: ${tmpFile}`);\n writeFileSync(tmpFile, context);\n return tmpFile;\n }\n\n async launch(port?: number) {\n this.port = port || defaultPort;\n this.app.use(errorHandler);\n\n this.app.use(\n cors({\n origin: '*',\n credentials: true,\n }),\n );\n\n this.app.get('/status', async (req, res) => {\n // const modelName = g\n res.send({\n status: 'ok',\n });\n });\n\n this.app.get('/context/:uuid', async (req, res) => {\n const { uuid } = req.params;\n const contextFile = this.filePathForUuid(uuid);\n\n if (!existsSync(contextFile)) {\n return res.status(404).json({\n error: 'Context not found',\n });\n }\n\n const context = readFileSync(contextFile, 'utf8');\n res.json({\n context,\n });\n });\n\n this.app.get('/task-progress/:requestId', async (req, res) => {\n const { requestId } = req.params;\n res.json({\n tip: this.taskProgressTips[requestId] || '',\n });\n });\n\n this.app.post(\n '/action-space',\n express.json({ limit: '30mb' }),\n async (req, res) => {\n const { context } = req.body;\n\n if (!context) {\n return res.status(400).json({\n error: 'context is required',\n });\n }\n\n try {\n // Create agent with context like in /execute\n const page = new this.pageClass(context);\n const actionSpace = await page.actionSpace();\n\n // Process actionSpace to make paramSchema serializable\n const processedActionSpace = actionSpace.map((action: any) => {\n if (action.paramSchema && typeof action.paramSchema === 'object') {\n // Extract shape information from Zod schema\n let processedSchema = null;\n\n try {\n // Extract shape from runtime Zod object\n if (\n action.paramSchema.shape &&\n typeof action.paramSchema.shape === 'object'\n ) {\n processedSchema = {\n type: 'ZodObject',\n shape: action.paramSchema.shape,\n };\n }\n } catch (e) {\n console.warn(\n 'Failed to process paramSchema for action:',\n action.name,\n e,\n );\n }\n\n return {\n ...action,\n paramSchema: processedSchema,\n };\n }\n return action;\n });\n\n res.json(processedActionSpace);\n } catch (error: any) {\n console.error('Failed to get action space:', error);\n res.status(500).json({\n error: error.message,\n });\n }\n },\n );\n\n // -------------------------\n // actions from report file\n this.app.post(\n '/playground-with-context',\n express.json({ limit: '50mb' }),\n async (req, res) => {\n const context = req.body.context;\n\n if (!context) {\n return res.status(400).json({\n error: 'context is required',\n });\n }\n\n const uuid = randomUUID();\n this.saveContextFile(uuid, context);\n return res.json({\n location: `/playground/${uuid}`,\n uuid,\n });\n },\n );\n\n this.app.post(\n '/execute',\n express.json({ limit: '30mb' }),\n async (req, res) => {\n const {\n context,\n type,\n prompt,\n params,\n requestId,\n deepThink,\n screenshotIncluded,\n domIncluded,\n } = req.body;\n\n if (!context) {\n return res.status(400).json({\n error: 'context is required',\n });\n }\n\n if (!type) {\n return res.status(400).json({\n error: 'type is required',\n });\n }\n\n // build an agent with context\n const page = new this.pageClass(context);\n const agent = new this.agentClass(page);\n\n if (requestId) {\n this.taskProgressTips[requestId] = '';\n this.activeAgents[requestId] = agent;\n\n agent.onTaskStartTip = (tip: string) => {\n this.taskProgressTips[requestId] = tip;\n };\n }\n\n const response: {\n result: any;\n dump: string | null;\n error: string | null;\n reportHTML: string | null;\n requestId?: string;\n } = {\n result: null,\n dump: null,\n error: null,\n reportHTML: null,\n requestId,\n };\n\n const startTime = Date.now();\n try {\n // Get action space to check for dynamic actions\n const actionSpace = await page.actionSpace();\n\n // Prepare value object for executeAction\n const value = {\n prompt,\n params,\n };\n\n response.result = await executeAction(\n agent,\n type,\n actionSpace,\n value,\n deepThink || false,\n );\n } catch (error: any) {\n response.error = formatErrorMessage(error);\n }\n\n try {\n response.dump = JSON.parse(agent.dumpDataString());\n response.reportHTML = agent.reportHTMLString() || null;\n\n agent.writeOutActionDumps();\n agent.destroy();\n } catch (error: any) {\n console.error(\n `write out dump failed: requestId: ${requestId}, ${error.message}`,\n );\n }\n\n res.send(response);\n const timeCost = Date.now() - startTime;\n\n if (response.error) {\n console.error(\n `handle request failed after ${timeCost}ms: requestId: ${requestId}, ${response.error}`,\n );\n } else {\n console.log(\n `handle request done after ${timeCost}ms: requestId: ${requestId}`,\n );\n }\n\n // Clean up the agent from activeAgents after execution completes\n if (requestId && this.activeAgents[requestId]) {\n delete this.activeAgents[requestId];\n }\n },\n );\n\n this.app.get('/cancel/:requestId', async (req, res) => {\n const { requestId } = req.params;\n\n if (!requestId) {\n return res.status(400).json({\n error: 'requestId is required',\n });\n }\n\n const agent = this.activeAgents[requestId];\n if (!agent) {\n return res.status(404).json({\n error: 'No active agent found for this requestId',\n });\n }\n\n try {\n await agent.destroy();\n delete this.activeAgents[requestId];\n res.json({ status: 'cancelled' });\n } catch (error: any) {\n console.error(`Failed to cancel agent: ${error.message}`);\n res.status(500).json({\n error: `Failed to cancel: ${error.message}`,\n });\n }\n });\n\n this.app.post(\n '/config',\n express.json({ limit: '1mb' }),\n async (req, res) => {\n const { aiConfig } = req.body;\n\n if (!aiConfig || typeof aiConfig !== 'object') {\n return res.status(400).json({\n error: 'aiConfig is required and must be an object',\n });\n }\n\n try {\n overrideAIConfig(aiConfig);\n\n return res.json({\n status: 'ok',\n message: 'AI config updated successfully',\n });\n } catch (error: any) {\n console.error(`Failed to update AI config: ${error.message}`);\n return res.status(500).json({\n error: `Failed to update AI config: ${error.message}`,\n });\n }\n },\n );\n\n // Set up static file serving after all API routes are defined\n if (this.staticPath) {\n this.app.get('/', (_req, res) => {\n // compatible with windows\n res.redirect('/index.html');\n });\n\n this.app.get('*', (req, res) => {\n const requestedPath = join(this.staticPath!, req.path);\n if (existsSync(requestedPath)) {\n res.sendFile(requestedPath);\n } else {\n res.sendFile(join(this.staticPath!, 'index.html'));\n }\n });\n }\n\n return new Promise((resolve) => {\n const port = this.port;\n this.server = this.app.listen(port, () => {\n resolve(this);\n });\n });\n }\n\n close() {\n // close the server\n if (this.server) {\n return this.server.close();\n }\n }\n}\n"],"names":["defaultPort","PLAYGROUND_SERVER_PORT","errorHandler","err","req","res","next","console","setup","ifInBrowser","ifInWorker","dotenv","PlaygroundServer","uuid","join","context","tmpFile","writeFileSync","port","cors","contextFile","existsSync","readFileSync","requestId","express","page","actionSpace","processedActionSpace","action","processedSchema","e","error","randomUUID","type","prompt","params","deepThink","screenshotIncluded","domIncluded","agent","tip","response","startTime","Date","value","executeAction","formatErrorMessage","JSON","timeCost","aiConfig","overrideAIConfig","_req","requestedPath","Promise","resolve","pageClass","agentClass","staticPath","getTmpDir"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAeA,MAAMA,cAAcC;AAGpB,MAAMC,eAAe,CAACC,KAAUC,KAAUC,KAAUC;IAClDC,QAAQ,KAAK,CAACJ;IACdE,IAAI,MAAM,CAAC,KAAK,IAAI,CAAC;QACnB,OAAOF,IAAI,OAAO;IACpB;AACF;AAEA,MAAMK,QAAQ;IACZ,IAAI,CAACC,eAAe,CAACC,YACnBC,OAAO,MAAM;AAEjB;AAEe,MAAMC;IA8BnB,gBAAgBC,IAAY,EAAE;QAC5B,OAAOC,KAAK,IAAI,CAAC,MAAM,EAAE,GAAGD,KAAK,KAAK,CAAC;IACzC;IAEA,gBAAgBA,IAAY,EAAEE,OAAe,EAAE;QAC7C,MAAMC,UAAU,IAAI,CAAC,eAAe,CAACH;QACrCN,QAAQ,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jC;QACX,IAAI,CAAC,MAAM,GAAGkC;QACd,IAAI,CAAC,SAAS,GAAGH;QACjB,IAAI,CAAC,UAAU,GAAGC;QAClB,IAAI,CAAC,UAAU,GAAGC;QAClB,IAAI,CAAC,gBAAgB,GAAG,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,CAAC;QACrBjD;IACF;AA4UF"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { commonWebActionsForWebPage } from "../web-page.mjs";
|
|
2
|
-
import { ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED } from "@midscene/shared/common";
|
|
3
|
-
function _define_property(obj, key, value) {
|
|
4
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
5
|
-
value: value,
|
|
6
|
-
enumerable: true,
|
|
7
|
-
configurable: true,
|
|
8
|
-
writable: true
|
|
9
|
-
});
|
|
10
|
-
else obj[key] = value;
|
|
11
|
-
return obj;
|
|
12
|
-
}
|
|
13
|
-
const ThrowNotImplemented = (methodName)=>{
|
|
14
|
-
throw new Error(`The method "${methodName}" is not implemented as designed since this is a static UI context. (${ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED})`);
|
|
15
|
-
};
|
|
16
|
-
class StaticPage {
|
|
17
|
-
actionSpace() {
|
|
18
|
-
return commonWebActionsForWebPage(this);
|
|
19
|
-
}
|
|
20
|
-
async evaluateJavaScript(script) {
|
|
21
|
-
return ThrowNotImplemented('evaluateJavaScript');
|
|
22
|
-
}
|
|
23
|
-
async getElementsInfo() {
|
|
24
|
-
return ThrowNotImplemented('getElementsInfo');
|
|
25
|
-
}
|
|
26
|
-
async getElementsNodeTree() {
|
|
27
|
-
return ThrowNotImplemented('getElementsNodeTree');
|
|
28
|
-
}
|
|
29
|
-
async getXpathsById(id) {
|
|
30
|
-
return ThrowNotImplemented('getXpathsById');
|
|
31
|
-
}
|
|
32
|
-
async getXpathsByPoint(point) {
|
|
33
|
-
return ThrowNotImplemented('getXpathsByPoint');
|
|
34
|
-
}
|
|
35
|
-
async getElementInfoByXpath(xpath) {
|
|
36
|
-
return ThrowNotImplemented('getElementInfoByXpath');
|
|
37
|
-
}
|
|
38
|
-
async size() {
|
|
39
|
-
return this.uiContext.size;
|
|
40
|
-
}
|
|
41
|
-
async screenshotBase64() {
|
|
42
|
-
const base64 = this.uiContext.screenshotBase64;
|
|
43
|
-
if (!base64) throw new Error('screenshot base64 is empty');
|
|
44
|
-
return base64;
|
|
45
|
-
}
|
|
46
|
-
async url() {
|
|
47
|
-
return Promise.resolve('https://static_page_without_url');
|
|
48
|
-
}
|
|
49
|
-
async scrollUntilTop(startingPoint) {
|
|
50
|
-
return ThrowNotImplemented('scrollUntilTop');
|
|
51
|
-
}
|
|
52
|
-
async scrollUntilBottom(startingPoint) {
|
|
53
|
-
return ThrowNotImplemented('scrollUntilBottom');
|
|
54
|
-
}
|
|
55
|
-
async scrollUntilLeft(startingPoint) {
|
|
56
|
-
return ThrowNotImplemented('scrollUntilLeft');
|
|
57
|
-
}
|
|
58
|
-
async scrollUntilRight(startingPoint) {
|
|
59
|
-
return ThrowNotImplemented('scrollUntilRight');
|
|
60
|
-
}
|
|
61
|
-
async scrollUp(distance, startingPoint) {
|
|
62
|
-
return ThrowNotImplemented('scrollUp');
|
|
63
|
-
}
|
|
64
|
-
async scrollDown(distance, startingPoint) {
|
|
65
|
-
return ThrowNotImplemented('scrollDown');
|
|
66
|
-
}
|
|
67
|
-
async scrollLeft(distance, startingPoint) {
|
|
68
|
-
return ThrowNotImplemented('scrollLeft');
|
|
69
|
-
}
|
|
70
|
-
async scrollRight(distance, startingPoint) {
|
|
71
|
-
return ThrowNotImplemented('scrollRight');
|
|
72
|
-
}
|
|
73
|
-
async clearInput() {
|
|
74
|
-
return ThrowNotImplemented('clearInput');
|
|
75
|
-
}
|
|
76
|
-
async destroy() {}
|
|
77
|
-
async getContext() {
|
|
78
|
-
return this.uiContext;
|
|
79
|
-
}
|
|
80
|
-
constructor(uiContext){
|
|
81
|
-
_define_property(this, "interfaceType", 'static');
|
|
82
|
-
_define_property(this, "uiContext", void 0);
|
|
83
|
-
_define_property(this, "mouse", {
|
|
84
|
-
click: ThrowNotImplemented.bind(null, 'mouse.click'),
|
|
85
|
-
wheel: ThrowNotImplemented.bind(null, 'mouse.wheel'),
|
|
86
|
-
move: ThrowNotImplemented.bind(null, 'mouse.move'),
|
|
87
|
-
drag: ThrowNotImplemented.bind(null, 'mouse.drag')
|
|
88
|
-
});
|
|
89
|
-
_define_property(this, "keyboard", {
|
|
90
|
-
type: ThrowNotImplemented.bind(null, 'keyboard.type'),
|
|
91
|
-
press: ThrowNotImplemented.bind(null, 'keyboard.press')
|
|
92
|
-
});
|
|
93
|
-
if (uiContext.tree) this.uiContext = uiContext;
|
|
94
|
-
else this.uiContext = Object.assign(uiContext, {
|
|
95
|
-
tree: {
|
|
96
|
-
node: null,
|
|
97
|
-
children: []
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
export { StaticPage as default };
|
|
103
|
-
|
|
104
|
-
//# sourceMappingURL=static-page.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"playground/static-page.mjs","sources":["webpack://@midscene/web/./src/playground/static-page.ts"],"sourcesContent":["import { commonWebActionsForWebPage } from '@/web-page';\nimport type { DeviceAction, Point, UIContext } from '@midscene/core';\nimport type { AbstractInterface } from '@midscene/core/device';\nimport { ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED } from '@midscene/shared/common';\nimport type { WebUIContext } from '../web-element';\n\nconst ThrowNotImplemented: any = (methodName: string) => {\n throw new Error(\n `The method \"${methodName}\" is not implemented as designed since this is a static UI context. (${ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED})`,\n );\n};\n\nexport default class StaticPage implements AbstractInterface {\n interfaceType = 'static';\n\n private uiContext: WebUIContext;\n\n constructor(uiContext: WebUIContext) {\n if (uiContext.tree) {\n this.uiContext = uiContext;\n } else {\n this.uiContext = Object.assign(uiContext, {\n tree: {\n node: null,\n children: [],\n },\n });\n }\n }\n\n actionSpace(): DeviceAction[] {\n // Return common web actions for planning, but they won't actually execute\n return commonWebActionsForWebPage(this);\n }\n\n async evaluateJavaScript<T = any>(script: string): Promise<T> {\n return ThrowNotImplemented('evaluateJavaScript');\n }\n\n // @deprecated\n async getElementsInfo() {\n return ThrowNotImplemented('getElementsInfo');\n }\n\n async getElementsNodeTree() {\n return ThrowNotImplemented('getElementsNodeTree');\n }\n\n async getXpathsById(id: string) {\n return ThrowNotImplemented('getXpathsById');\n }\n\n async getXpathsByPoint(point: Point) {\n return ThrowNotImplemented('getXpathsByPoint');\n }\n\n async getElementInfoByXpath(xpath: string) {\n return ThrowNotImplemented('getElementInfoByXpath');\n }\n\n async size() {\n return this.uiContext.size;\n }\n\n async screenshotBase64() {\n const base64 = this.uiContext.screenshotBase64;\n if (!base64) {\n throw new Error('screenshot base64 is empty');\n }\n return base64;\n }\n\n async url() {\n return Promise.resolve('https://static_page_without_url');\n }\n\n async scrollUntilTop(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilTop');\n }\n\n async scrollUntilBottom(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilBottom');\n }\n\n async scrollUntilLeft(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilLeft');\n }\n\n async scrollUntilRight(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilRight');\n }\n\n async scrollUp(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollUp');\n }\n\n async scrollDown(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollDown');\n }\n\n async scrollLeft(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollLeft');\n }\n\n async scrollRight(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollRight');\n }\n\n async clearInput() {\n return ThrowNotImplemented('clearInput');\n }\n\n mouse = {\n click: ThrowNotImplemented.bind(null, 'mouse.click'),\n wheel: ThrowNotImplemented.bind(null, 'mouse.wheel'),\n move: ThrowNotImplemented.bind(null, 'mouse.move'),\n drag: ThrowNotImplemented.bind(null, 'mouse.drag'),\n };\n\n keyboard = {\n type: ThrowNotImplemented.bind(null, 'keyboard.type'),\n press: ThrowNotImplemented.bind(null, 'keyboard.press'),\n };\n\n async destroy(): Promise<void> {\n //\n }\n\n async getContext(): Promise<UIContext> {\n return this.uiContext;\n }\n}\n"],"names":["ThrowNotImplemented","methodName","Error","ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED","StaticPage","commonWebActionsForWebPage","script","id","point","xpath","base64","Promise","startingPoint","distance","uiContext","Object"],"mappings":";;;;;;;;;;;;AAMA,MAAMA,sBAA2B,CAACC;IAChC,MAAM,IAAIC,MACR,CAAC,YAAY,EAAED,WAAW,qEAAqE,EAAEE,uCAAuC,CAAC,CAAC;AAE9I;AAEe,MAAMC;IAkBnB,cAA8B;QAE5B,OAAOC,2BAA2B,IAAI;IACxC;IAEA,MAAM,mBAA4BC,MAAc,EAAc;QAC5D,OAAON,oBAAoB;IAC7B;IAGA,MAAM,kBAAkB;QACtB,OAAOA,oBAAoB;IAC7B;IAEA,MAAM,sBAAsB;QAC1B,OAAOA,oBAAoB;IAC7B;IAEA,MAAM,cAAcO,EAAU,EAAE;QAC9B,OAAOP,oBAAoB;IAC7B;IAEA,MAAM,iBAAiBQ,KAAY,EAAE;QACnC,OAAOR,oBAAoB;IAC7B;IAEA,MAAM,sBAAsBS,KAAa,EAAE;QACzC,OAAOT,oBAAoB;IAC7B;IAEA,MAAM,OAAO;QACX,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI;IAC5B;IAEA,MAAM,mBAAmB;QACvB,MAAMU,SAAS,IAAI,CAAC,SAAS,CAAC,gBAAgB;QAC9C,IAAI,CAACA,QACH,MAAM,IAAIR,MAAM;QAElB,OAAOQ;IACT;IAEA,MAAM,MAAM;QACV,OAAOC,QAAQ,OAAO,CAAC;IACzB;IAEA,MAAM,eAAeC,aAAqB,EAAE;Q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|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
StaticPageAgent: ()=>StaticPageAgent
|
|
28
|
-
});
|
|
29
|
-
const agent_namespaceObject = require("@midscene/core/agent");
|
|
30
|
-
class StaticPageAgent extends agent_namespaceObject.Agent {
|
|
31
|
-
constructor(page){
|
|
32
|
-
super(page, {});
|
|
33
|
-
this.dryMode = true;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.StaticPageAgent = __webpack_exports__.StaticPageAgent;
|
|
37
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
38
|
-
"StaticPageAgent"
|
|
39
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
40
|
-
Object.defineProperty(exports, '__esModule', {
|
|
41
|
-
value: true
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
//# sourceMappingURL=agent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"playground/agent.js","sources":["webpack://@midscene/web/webpack/runtime/define_property_getters","webpack://@midscene/web/webpack/runtime/has_own_property","webpack://@midscene/web/webpack/runtime/make_namespace_object","webpack://@midscene/web/./src/playground/agent.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { Agent as PageAgent } from '@midscene/core/agent';\nimport type StaticPage from './static-page';\n\nexport class StaticPageAgent extends PageAgent {\n constructor(page: StaticPage) {\n super(page, {});\n this.dryMode = true;\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","StaticPageAgent","PageAgent","page"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;ACHO,MAAMI,wBAAwBC,sBAAAA,KAASA;IAC5C,YAAYC,IAAgB,CAAE;QAC5B,KAAK,CAACA,MAAM,CAAC;QACb,IAAI,CAAC,OAAO,GAAG;IACjB;AACF"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = (module)=>{
|
|
5
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
-
__webpack_require__.d(getter, {
|
|
7
|
-
a: getter
|
|
8
|
-
});
|
|
9
|
-
return getter;
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
|
-
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: definition[key]
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
})();
|
|
20
|
-
(()=>{
|
|
21
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
-
})();
|
|
23
|
-
var __webpack_exports__ = {};
|
|
24
|
-
const external_index_js_namespaceObject = require("./index.js");
|
|
25
|
-
const external_server_js_namespaceObject = require("./server.js");
|
|
26
|
-
var external_server_js_default = /*#__PURE__*/ __webpack_require__.n(external_server_js_namespaceObject);
|
|
27
|
-
const server = new (external_server_js_default())(external_index_js_namespaceObject.StaticPage, external_index_js_namespaceObject.StaticPageAgent);
|
|
28
|
-
Promise.resolve().then(()=>server.launch()).then(()=>{
|
|
29
|
-
console.log(`Midscene playground server is running on http://localhost:${server.port}`);
|
|
30
|
-
});
|
|
31
|
-
for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
32
|
-
Object.defineProperty(exports, '__esModule', {
|
|
33
|
-
value: true
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
//# sourceMappingURL=bin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"playground/bin.js","sources":["webpack://@midscene/web/webpack/runtime/compat_get_default_export","webpack://@midscene/web/webpack/runtime/define_property_getters","webpack://@midscene/web/webpack/runtime/has_own_property","webpack://@midscene/web/./src/playground/bin.ts"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import { StaticPage, StaticPageAgent } from './';\nimport PlaygroundServer from './server';\n\nconst server = new PlaygroundServer(StaticPage, StaticPageAgent);\nPromise.resolve()\n .then(() => server.launch())\n .then(() => {\n console.log(\n `Midscene playground server is running on http://localhost:${server.port}`,\n );\n });\n"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","server","PlaygroundServer","StaticPage","StaticPageAgent","Promise","console"],"mappings":";;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAJ,oBAAoB,CAAC,GAAG,CAACM,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;;;;ACGlF,MAAMC,SAAS,IAAIC,CAAAA,4BAAAA,EAAiBC,kCAAAA,UAAUA,EAAEC,kCAAAA,eAAeA;AAC/DC,QAAQ,OAAO,GACZ,IAAI,CAAC,IAAMJ,OAAO,MAAM,IACxB,IAAI,CAAC;IACJK,QAAQ,GAAG,CACT,CAAC,0DAA0D,EAAEL,OAAO,IAAI,EAAE;AAE9E"}
|