@midscene/core 0.11.2 → 0.11.3

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.
@@ -2,13 +2,13 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkBYT7NPTCjs = require('./chunk-BYT7NPTC.js');
5
+ var _chunkIOU6IQ5Djs = require('./chunk-IOU6IQ5D.js');
6
6
 
7
7
 
8
8
 
9
9
 
10
10
 
11
- var _chunkHMB36AJ4js = require('./chunk-HMB36AJ4.js');
11
+ var _chunkJCZGPJM3js = require('./chunk-JCZGPJM3.js');
12
12
 
13
13
 
14
14
 
@@ -159,7 +159,7 @@ ${(_b = this.latestErrorTask()) == null ? void 0 : _b.errorStack}`
159
159
  }
160
160
  dump() {
161
161
  const dumpData = {
162
- sdkVersion: _chunkBYT7NPTCjs.getVersion.call(void 0, ),
162
+ sdkVersion: _chunkIOU6IQ5Djs.getVersion.call(void 0, ),
163
163
  model_name: _chunkG2Z4BC6Ljs.getAIConfig.call(void 0, _chunkG2Z4BC6Ljs.MIDSCENE_MODEL_NAME) || "",
164
164
  logTime: Date.now(),
165
165
  name: this.name,
@@ -179,11 +179,11 @@ var _utils = require('@midscene/shared/utils');
179
179
  var logContent = [];
180
180
  var logIdIndexMap = {};
181
181
  function emitInsightDump(data, logId, dumpSubscriber) {
182
- const logDir = _chunkBYT7NPTCjs.getLogDir.call(void 0, );
182
+ const logDir = _chunkIOU6IQ5Djs.getLogDir.call(void 0, );
183
183
  _assert2.default.call(void 0, logDir, "logDir should be set before writing dump file");
184
184
  const id = logId || _utils.uuid.call(void 0, );
185
185
  const baseData = {
186
- sdkVersion: _chunkBYT7NPTCjs.getVersion.call(void 0, ),
186
+ sdkVersion: _chunkIOU6IQ5Djs.getVersion.call(void 0, ),
187
187
  logTime: Date.now(),
188
188
  model_name: _chunkG2Z4BC6Ljs.getAIConfig.call(void 0, _chunkG2Z4BC6Ljs.MIDSCENE_MODEL_NAME) || "",
189
189
  model_description: _chunkG2Z4BC6Ljs.getAIConfig.call(void 0, _chunkG2Z4BC6Ljs.MIDSCENE_USE_VLM_UI_TARS) ? "vlm-ui-tars enabled" : ""
@@ -194,7 +194,7 @@ function emitInsightDump(data, logId, dumpSubscriber) {
194
194
  ...data
195
195
  };
196
196
  dumpSubscriber == null ? void 0 : dumpSubscriber(finalData);
197
- const dataString = _chunkBYT7NPTCjs.stringifyDumpData.call(void 0, finalData, 2);
197
+ const dataString = _chunkIOU6IQ5Djs.stringifyDumpData.call(void 0, finalData, 2);
198
198
  if (typeof logIdIndexMap[id] === "number") {
199
199
  logContent[logIdIndexMap[id]] = dataString;
200
200
  } else {
@@ -207,7 +207,7 @@ function emitInsightDump(data, logId, dumpSubscriber) {
207
207
  // src/insight/index.ts
208
208
  var Insight = class {
209
209
  constructor(context, opt) {
210
- this.aiVendorFn = _chunkHMB36AJ4js.callAiFn;
210
+ this.aiVendorFn = _chunkJCZGPJM3js.callAiFn;
211
211
  _assert2.default.call(void 0, context, "context is required for Insight");
212
212
  if (typeof context === "function") {
213
213
  this.contextRetrieverFn = context;
@@ -233,7 +233,7 @@ var Insight = class {
233
233
  this.onceDumpUpdatedFn = void 0;
234
234
  const context = await this.contextRetrieverFn("locate");
235
235
  const startTime = Date.now();
236
- const { parseResult, elementById, rawResponse, usage } = await _chunkHMB36AJ4js.AiInspectElement.call(void 0, {
236
+ const { parseResult, elementById, rawResponse, usage } = await _chunkJCZGPJM3js.AiInspectElement.call(void 0, {
237
237
  callAI: callAI || this.aiVendorFn,
238
238
  context,
239
239
  multi: Boolean(multi),
@@ -316,7 +316,7 @@ ${parseResult.errors.join("\n")}`;
316
316
  this.onceDumpUpdatedFn = void 0;
317
317
  const context = await this.contextRetrieverFn("extract");
318
318
  const startTime = Date.now();
319
- const { parseResult, elementById } = await _chunkHMB36AJ4js.AiExtractElementInfo.call(void 0, {
319
+ const { parseResult, elementById } = await _chunkJCZGPJM3js.AiExtractElementInfo.call(void 0, {
320
320
  context,
321
321
  dataQuery: dataDemand
322
322
  });
@@ -370,7 +370,7 @@ ${parseResult.errors.join("\n")}`;
370
370
  this.onceDumpUpdatedFn = void 0;
371
371
  const context = await this.contextRetrieverFn("assert");
372
372
  const startTime = Date.now();
373
- const assertResult = await _chunkHMB36AJ4js.AiAssert.call(void 0, {
373
+ const assertResult = await _chunkJCZGPJM3js.AiAssert.call(void 0, {
374
374
  assertion,
375
375
  context
376
376
  });
@@ -413,4 +413,4 @@ var src_default = Insight;
413
413
 
414
414
  exports.Executor = Executor; exports.Insight = Insight; exports.src_default = src_default;
415
415
 
416
- //# sourceMappingURL=chunk-DNL7467B.js.map
416
+ //# sourceMappingURL=chunk-PQ34NDB5.js.map
@@ -1,8 +1,8 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }require('./chunk-DNL7467B.js');
2
- require('./chunk-BYT7NPTC.js');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }require('./chunk-PQ34NDB5.js');
2
+ require('./chunk-IOU6IQ5D.js');
3
3
 
4
4
 
5
- var _chunkHMB36AJ4js = require('./chunk-HMB36AJ4.js');
5
+ var _chunkJCZGPJM3js = require('./chunk-JCZGPJM3.js');
6
6
  require('./chunk-G2Z4BC6L.js');
7
7
  require('./chunk-LQ2VYIYD.js');
8
8
 
@@ -34,7 +34,7 @@ async function buildContext(targetDir) {
34
34
  context: {
35
35
  ...baseContext,
36
36
  describer: async () => {
37
- return _chunkHMB36AJ4js.describeUserPage.call(void 0, baseContext);
37
+ return _chunkJCZGPJM3js.describeUserPage.call(void 0, baseContext);
38
38
  }
39
39
  },
40
40
  snapshotJson,
package/dist/lib/index.js CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkDNL7467Bjs = require('./chunk-DNL7467B.js');
5
+ var _chunkPQ34NDB5js = require('./chunk-PQ34NDB5.js');
6
6
 
7
7
 
8
8
 
9
9
 
10
- var _chunkBYT7NPTCjs = require('./chunk-BYT7NPTC.js');
10
+ var _chunkIOU6IQ5Djs = require('./chunk-IOU6IQ5D.js');
11
11
 
12
12
 
13
13
 
@@ -17,7 +17,7 @@ var _chunkBYT7NPTCjs = require('./chunk-BYT7NPTC.js');
17
17
 
18
18
 
19
19
 
20
- var _chunkHMB36AJ4js = require('./chunk-HMB36AJ4.js');
20
+ var _chunkJCZGPJM3js = require('./chunk-JCZGPJM3.js');
21
21
 
22
22
 
23
23
 
@@ -40,4 +40,4 @@ require('./chunk-LQ2VYIYD.js');
40
40
 
41
41
 
42
42
 
43
- exports.AIResponseFormat = _chunkHMB36AJ4js.AIResponseFormat; exports.AiAssert = _chunkHMB36AJ4js.AiAssert; exports.AiInspectElement = _chunkHMB36AJ4js.AiInspectElement; exports.BaseElement = _chunkHMB36AJ4js.BaseElement; exports.Executor = _chunkDNL7467Bjs.Executor; exports.Insight = _chunkDNL7467Bjs.Insight; exports.MIDSCENE_MODEL_NAME = _chunkG2Z4BC6Ljs.MIDSCENE_MODEL_NAME; exports.UIContext = _chunkHMB36AJ4js.UIContext; exports.default = _chunkDNL7467Bjs.src_default; exports.describeUserPage = _chunkHMB36AJ4js.describeUserPage; exports.getAIConfig = _chunkG2Z4BC6Ljs.getAIConfig; exports.getLogDirByType = _chunkBYT7NPTCjs.getLogDirByType; exports.getVersion = _chunkBYT7NPTCjs.getVersion; exports.plan = _chunkHMB36AJ4js.plan; exports.setLogDir = _chunkBYT7NPTCjs.setLogDir; exports.transformElementPositionToId = _chunkHMB36AJ4js.transformElementPositionToId;
43
+ exports.AIResponseFormat = _chunkJCZGPJM3js.AIResponseFormat; exports.AiAssert = _chunkJCZGPJM3js.AiAssert; exports.AiInspectElement = _chunkJCZGPJM3js.AiInspectElement; exports.BaseElement = _chunkJCZGPJM3js.BaseElement; exports.Executor = _chunkPQ34NDB5js.Executor; exports.Insight = _chunkPQ34NDB5js.Insight; exports.MIDSCENE_MODEL_NAME = _chunkG2Z4BC6Ljs.MIDSCENE_MODEL_NAME; exports.UIContext = _chunkJCZGPJM3js.UIContext; exports.default = _chunkPQ34NDB5js.src_default; exports.describeUserPage = _chunkJCZGPJM3js.describeUserPage; exports.getAIConfig = _chunkG2Z4BC6Ljs.getAIConfig; exports.getLogDirByType = _chunkIOU6IQ5Djs.getLogDirByType; exports.getVersion = _chunkIOU6IQ5Djs.getVersion; exports.plan = _chunkJCZGPJM3js.plan; exports.setLogDir = _chunkIOU6IQ5Djs.setLogDir; exports.transformElementPositionToId = _chunkJCZGPJM3js.transformElementPositionToId;
@@ -1,8 +1,8 @@
1
- import { h as AIUsageInfo, z as PlanningAction } from './types-4eebf154.js';
1
+ import { h as AIUsageInfo, z as PlanningAction } from './types-95b0888e.js';
2
2
  import { ChatCompletionMessageParam } from 'openai/resources';
3
3
  export { ChatCompletionMessageParam } from 'openai/resources';
4
- import { b as AIActionType } from './llm-planning-65378494.js';
5
- export { a as AiAssert, e as AiExtractElementInfo, A as AiInspectElement, c as callAiFn, d as describeUserPage, p as plan, t as transformElementPositionToId } from './llm-planning-65378494.js';
4
+ import { b as AIActionType } from './llm-planning-75af16ef.js';
5
+ export { a as AiAssert, e as AiExtractElementInfo, A as AiInspectElement, c as callAiFn, d as describeUserPage, p as plan, t as transformElementPositionToId } from './llm-planning-75af16ef.js';
6
6
  import { actionParser } from '@ui-tars/action-parser';
7
7
  import '@midscene/shared/constants';
8
8
 
@@ -1,7 +1,7 @@
1
- import { E as ExecutionTask, a as ExecutionTaskProgressOptions, b as ExecutionTaskApply, c as ExecutionDump, B as BaseElement, U as UIContext, I as InsightAction, D as DumpSubscriber, d as InsightOptions, e as InsightTaskInfo, f as InsightAssertionResponse, A as AISingleElementResponse } from './types-4eebf154.js';
2
- export { o as AIAssertionResponse, l as AIElementIdResponse, m as AIElementResponse, i as AIResponseFormat, n as AISectionParseResponse, j as AISingleElementResponseById, k as AISingleElementResponseByPosition, h as AIUsageInfo, x as AgentAssertOpt, w as AgentWaitForOpt, Y as BaseAgentParserOpt, C as CallAIFn, X as Color, r as DumpMeta, v as ElementById, g as ElementTreeNode, p as EnsureObject, $ as ExecutionRecorderItem, ah as ExecutionTaskAction, ag as ExecutionTaskActionApply, af as ExecutionTaskInsightAssertion, ae as ExecutionTaskInsightAssertionApply, ad as ExecutionTaskInsightAssertionParam, a6 as ExecutionTaskInsightDumpLog, a8 as ExecutionTaskInsightLocate, a7 as ExecutionTaskInsightLocateApply, a5 as ExecutionTaskInsightLocateOutput, a4 as ExecutionTaskInsightLocateParam, ac as ExecutionTaskInsightQuery, ab as ExecutionTaskInsightQueryApply, aa as ExecutionTaskInsightQueryOutput, a9 as ExecutionTaskInsightQueryParam, aj as ExecutionTaskPlanning, ai as ExecutionTaskPlanningApply, a3 as ExecutionTaskReturn, a0 as ExecutionTaskType, a1 as ExecutorContext, ak as GroupedActionDump, t as InsightDump, q as InsightExtractParam, L as LiteUISection, O as OnTaskStartTip, u as PartialInsightDumpFromSDK, F as PlanningAIResponse, z as PlanningAction, Q as PlanningActionParamAssert, V as PlanningActionParamError, K as PlanningActionParamHover, M as PlanningActionParamInputOrKeyPress, H as PlanningActionParamPlan, N as PlanningActionParamScroll, T as PlanningActionParamSleep, J as PlanningActionParamTap, W as PlanningActionParamWaitFor, G as PlanningFurtherPlan, y as PlanningLocateParam, _ as PlaywrightParserOpt, P as Point, Z as PuppeteerParserOpt, R as Rect, s as ReportDumpWithAttributes, S as Size, a2 as TaskCacheInfo } from './types-4eebf154.js';
3
- import { c as callAiFn } from './llm-planning-65378494.js';
4
- export { a as AiAssert, A as AiInspectElement, d as describeUserPage, p as plan, t as transformElementPositionToId } from './llm-planning-65378494.js';
1
+ import { E as ExecutionTask, a as ExecutionTaskProgressOptions, b as ExecutionTaskApply, c as ExecutionDump, B as BaseElement, U as UIContext, I as InsightAction, D as DumpSubscriber, d as InsightOptions, e as InsightTaskInfo, f as InsightAssertionResponse, A as AISingleElementResponse } from './types-95b0888e.js';
2
+ export { o as AIAssertionResponse, l as AIElementIdResponse, m as AIElementResponse, i as AIResponseFormat, n as AISectionParseResponse, j as AISingleElementResponseById, k as AISingleElementResponseByPosition, h as AIUsageInfo, x as AgentAssertOpt, w as AgentWaitForOpt, Y as BaseAgentParserOpt, C as CallAIFn, X as Color, r as DumpMeta, v as ElementById, g as ElementTreeNode, p as EnsureObject, $ as ExecutionRecorderItem, ah as ExecutionTaskAction, ag as ExecutionTaskActionApply, af as ExecutionTaskInsightAssertion, ae as ExecutionTaskInsightAssertionApply, ad as ExecutionTaskInsightAssertionParam, a6 as ExecutionTaskInsightDumpLog, a8 as ExecutionTaskInsightLocate, a7 as ExecutionTaskInsightLocateApply, a5 as ExecutionTaskInsightLocateOutput, a4 as ExecutionTaskInsightLocateParam, ac as ExecutionTaskInsightQuery, ab as ExecutionTaskInsightQueryApply, aa as ExecutionTaskInsightQueryOutput, a9 as ExecutionTaskInsightQueryParam, aj as ExecutionTaskPlanning, ai as ExecutionTaskPlanningApply, a3 as ExecutionTaskReturn, a0 as ExecutionTaskType, a1 as ExecutorContext, ak as GroupedActionDump, t as InsightDump, q as InsightExtractParam, L as LiteUISection, O as OnTaskStartTip, u as PartialInsightDumpFromSDK, F as PlanningAIResponse, z as PlanningAction, Q as PlanningActionParamAssert, V as PlanningActionParamError, K as PlanningActionParamHover, M as PlanningActionParamInputOrKeyPress, H as PlanningActionParamPlan, N as PlanningActionParamScroll, T as PlanningActionParamSleep, J as PlanningActionParamTap, W as PlanningActionParamWaitFor, G as PlanningFurtherPlan, y as PlanningLocateParam, _ as PlaywrightParserOpt, P as Point, Z as PuppeteerParserOpt, R as Rect, s as ReportDumpWithAttributes, S as Size, a2 as TaskCacheInfo } from './types-95b0888e.js';
3
+ import { c as callAiFn } from './llm-planning-75af16ef.js';
4
+ export { a as AiAssert, A as AiInspectElement, d as describeUserPage, p as plan, t as transformElementPositionToId } from './llm-planning-75af16ef.js';
5
5
  export { getLogDirByType, getVersion, setLogDir } from './utils.js';
6
6
  export { MIDSCENE_MODEL_NAME, getAIConfig } from './env.js';
7
7
  import '@midscene/shared/constants';
@@ -1,4 +1,4 @@
1
- import { h as AIUsageInfo, B as BaseElement, U as UIContext, m as AIElementResponse, g as ElementTreeNode, A as AISingleElementResponse, k as AISingleElementResponseByPosition, v as ElementById, n as AISectionParseResponse, o as AIAssertionResponse, F as PlanningAIResponse } from './types-4eebf154.js';
1
+ import { h as AIUsageInfo, B as BaseElement, U as UIContext, m as AIElementResponse, g as ElementTreeNode, A as AISingleElementResponse, k as AISingleElementResponseByPosition, v as ElementById, n as AISectionParseResponse, o as AIAssertionResponse, F as PlanningAIResponse } from './types-95b0888e.js';
2
2
  import { ChatCompletionSystemMessageParam, ChatCompletionUserMessageParam } from 'openai/resources';
3
3
 
4
4
  type AIArgs = [
@@ -1,5 +1,5 @@
1
1
  import * as _midscene_shared_constants from '@midscene/shared/constants';
2
- import { B as BaseElement, g as ElementTreeNode } from './types-4eebf154.js';
2
+ import { B as BaseElement, g as ElementTreeNode } from './types-95b0888e.js';
3
3
  import 'openai/resources';
4
4
 
5
5
  declare function truncateText(text: string | number | object | undefined, maxLength?: number): string;
@@ -243,6 +243,7 @@ interface ExecutionTaskApply<Type extends ExecutionTaskType = any, TaskParam = a
243
243
  thought?: string;
244
244
  locate: PlanningLocateParam | null;
245
245
  quickAnswer?: AISingleElementResponse | null;
246
+ pageContext?: UIContext;
246
247
  executor: (param: TaskParam, context: ExecutorContext) => Promise<ExecutionTaskReturn<TaskOutput, TaskLog> | undefined | void> | undefined | void;
247
248
  }
248
249
  interface ExecutionTaskReturn<TaskOutput = unknown, TaskLog = unknown> {
@@ -1,4 +1,4 @@
1
- import { s as ReportDumpWithAttributes, R as Rect } from './types-4eebf154.js';
1
+ import { s as ReportDumpWithAttributes, R as Rect } from './types-95b0888e.js';
2
2
  import '@midscene/shared/constants';
3
3
  import 'openai/resources';
4
4
 
package/dist/lib/utils.js CHANGED
@@ -15,7 +15,7 @@
15
15
 
16
16
 
17
17
 
18
- var _chunkBYT7NPTCjs = require('./chunk-BYT7NPTC.js');
18
+ var _chunkIOU6IQ5Djs = require('./chunk-IOU6IQ5D.js');
19
19
  require('./chunk-G2Z4BC6L.js');
20
20
  require('./chunk-LQ2VYIYD.js');
21
21
 
@@ -35,4 +35,4 @@ require('./chunk-LQ2VYIYD.js');
35
35
 
36
36
 
37
37
 
38
- exports.getLogDir = _chunkBYT7NPTCjs.getLogDir; exports.getLogDirByType = _chunkBYT7NPTCjs.getLogDirByType; exports.getTmpDir = _chunkBYT7NPTCjs.getTmpDir; exports.getTmpFile = _chunkBYT7NPTCjs.getTmpFile; exports.getVersion = _chunkBYT7NPTCjs.getVersion; exports.groupedActionDumpFileExt = _chunkBYT7NPTCjs.groupedActionDumpFileExt; exports.overlapped = _chunkBYT7NPTCjs.overlapped; exports.replaceStringWithFirstAppearance = _chunkBYT7NPTCjs.replaceStringWithFirstAppearance; exports.replacerForPageObject = _chunkBYT7NPTCjs.replacerForPageObject; exports.reportHTMLContent = _chunkBYT7NPTCjs.reportHTMLContent; exports.setLogDir = _chunkBYT7NPTCjs.setLogDir; exports.sleep = _chunkBYT7NPTCjs.sleep; exports.stringifyDumpData = _chunkBYT7NPTCjs.stringifyDumpData; exports.uploadTestInfoToServer = _chunkBYT7NPTCjs.uploadTestInfoToServer; exports.writeDumpReport = _chunkBYT7NPTCjs.writeDumpReport; exports.writeLogFile = _chunkBYT7NPTCjs.writeLogFile;
38
+ exports.getLogDir = _chunkIOU6IQ5Djs.getLogDir; exports.getLogDirByType = _chunkIOU6IQ5Djs.getLogDirByType; exports.getTmpDir = _chunkIOU6IQ5Djs.getTmpDir; exports.getTmpFile = _chunkIOU6IQ5Djs.getTmpFile; exports.getVersion = _chunkIOU6IQ5Djs.getVersion; exports.groupedActionDumpFileExt = _chunkIOU6IQ5Djs.groupedActionDumpFileExt; exports.overlapped = _chunkIOU6IQ5Djs.overlapped; exports.replaceStringWithFirstAppearance = _chunkIOU6IQ5Djs.replaceStringWithFirstAppearance; exports.replacerForPageObject = _chunkIOU6IQ5Djs.replacerForPageObject; exports.reportHTMLContent = _chunkIOU6IQ5Djs.reportHTMLContent; exports.setLogDir = _chunkIOU6IQ5Djs.setLogDir; exports.sleep = _chunkIOU6IQ5Djs.sleep; exports.stringifyDumpData = _chunkIOU6IQ5Djs.stringifyDumpData; exports.uploadTestInfoToServer = _chunkIOU6IQ5Djs.uploadTestInfoToServer; exports.writeDumpReport = _chunkIOU6IQ5Djs.writeDumpReport; exports.writeLogFile = _chunkIOU6IQ5Djs.writeLogFile;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@midscene/core",
3
3
  "description": "Automate browser actions, extract data, and perform assertions using AI. It offers JavaScript SDK, Chrome extension, and support for scripting in YAML. See https://midscenejs.com/ for details.",
4
- "version": "0.11.2",
4
+ "version": "0.11.3",
5
5
  "repository": "https://github.com/web-infra-dev/midscene",
6
6
  "homepage": "https://midscenejs.com/",
7
7
  "jsnext:source": "./src/index.ts",
@@ -50,7 +50,7 @@
50
50
  "@ui-tars/action-parser": "1.0.1",
51
51
  "openai": "4.81.0",
52
52
  "socks-proxy-agent": "8.0.4",
53
- "@midscene/shared": "0.11.2"
53
+ "@midscene/shared": "0.11.3"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@modern-js/module-tools": "2.60.6",