@midscene/core 0.2.2-beta-20240809090814.0 → 0.2.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/dist/es/index.js CHANGED
@@ -1112,8 +1112,6 @@ var Executor = class {
1112
1112
  __publicField(this, "tasks");
1113
1113
  // status of executor
1114
1114
  __publicField(this, "status");
1115
- __publicField(this, "errorMsg");
1116
- __publicField(this, "dumpFileName");
1117
1115
  this.status = tasks && tasks.length > 0 ? "pending" : "init";
1118
1116
  this.name = name;
1119
1117
  this.description = description;
@@ -1156,7 +1154,6 @@ var Executor = class {
1156
1154
  this.status = "running";
1157
1155
  let taskIndex = nextPendingIndex;
1158
1156
  let successfullyCompleted = true;
1159
- let errorMsg = "";
1160
1157
  let previousFindOutput;
1161
1158
  while (taskIndex < this.tasks.length) {
1162
1159
  const task = this.tasks[taskIndex];
@@ -1204,13 +1201,11 @@ var Executor = class {
1204
1201
  taskIndex++;
1205
1202
  } catch (e) {
1206
1203
  successfullyCompleted = false;
1204
+ task.error = (e == null ? void 0 : e.message) || "error-without-message";
1205
+ task.errorStack = e.stack;
1207
1206
  task.status = "fail";
1208
- errorMsg = `${e == null ? void 0 : e.message}
1209
- ${e == null ? void 0 : e.stack}`;
1210
- task.error = errorMsg;
1211
1207
  task.timing.end = Date.now();
1212
1208
  task.timing.cost = task.timing.end - task.timing.start;
1213
- this.errorMsg = errorMsg;
1214
1209
  break;
1215
1210
  }
1216
1211
  }
@@ -1224,9 +1219,23 @@ ${e == null ? void 0 : e.stack}`;
1224
1219
  }
1225
1220
  } else {
1226
1221
  this.status = "error";
1227
- throw new Error(`executor failed: ${errorMsg}`);
1228
1222
  }
1229
1223
  }
1224
+ isInErrorState() {
1225
+ return this.status === "error";
1226
+ }
1227
+ latestErrorTask() {
1228
+ if (this.status !== "error") {
1229
+ return null;
1230
+ }
1231
+ const errorTaskIndex = this.tasks.findIndex(
1232
+ (task) => task.status === "fail"
1233
+ );
1234
+ if (errorTaskIndex >= 0) {
1235
+ return this.tasks[errorTaskIndex];
1236
+ }
1237
+ return null;
1238
+ }
1230
1239
  dump() {
1231
1240
  const dumpData = {
1232
1241
  sdkVersion: getPkgInfo().version,
package/dist/lib/index.js CHANGED
@@ -1127,8 +1127,6 @@ var Executor = class {
1127
1127
  __publicField(this, "tasks");
1128
1128
  // status of executor
1129
1129
  __publicField(this, "status");
1130
- __publicField(this, "errorMsg");
1131
- __publicField(this, "dumpFileName");
1132
1130
  this.status = tasks && tasks.length > 0 ? "pending" : "init";
1133
1131
  this.name = name;
1134
1132
  this.description = description;
@@ -1171,7 +1169,6 @@ var Executor = class {
1171
1169
  this.status = "running";
1172
1170
  let taskIndex = nextPendingIndex;
1173
1171
  let successfullyCompleted = true;
1174
- let errorMsg = "";
1175
1172
  let previousFindOutput;
1176
1173
  while (taskIndex < this.tasks.length) {
1177
1174
  const task = this.tasks[taskIndex];
@@ -1219,13 +1216,11 @@ var Executor = class {
1219
1216
  taskIndex++;
1220
1217
  } catch (e) {
1221
1218
  successfullyCompleted = false;
1219
+ task.error = (e == null ? void 0 : e.message) || "error-without-message";
1220
+ task.errorStack = e.stack;
1222
1221
  task.status = "fail";
1223
- errorMsg = `${e == null ? void 0 : e.message}
1224
- ${e == null ? void 0 : e.stack}`;
1225
- task.error = errorMsg;
1226
1222
  task.timing.end = Date.now();
1227
1223
  task.timing.cost = task.timing.end - task.timing.start;
1228
- this.errorMsg = errorMsg;
1229
1224
  break;
1230
1225
  }
1231
1226
  }
@@ -1239,9 +1234,23 @@ ${e == null ? void 0 : e.stack}`;
1239
1234
  }
1240
1235
  } else {
1241
1236
  this.status = "error";
1242
- throw new Error(`executor failed: ${errorMsg}`);
1243
1237
  }
1244
1238
  }
1239
+ isInErrorState() {
1240
+ return this.status === "error";
1241
+ }
1242
+ latestErrorTask() {
1243
+ if (this.status !== "error") {
1244
+ return null;
1245
+ }
1246
+ const errorTaskIndex = this.tasks.findIndex(
1247
+ (task) => task.status === "fail"
1248
+ );
1249
+ if (errorTaskIndex >= 0) {
1250
+ return this.tasks[errorTaskIndex];
1251
+ }
1252
+ return null;
1253
+ }
1245
1254
  dump() {
1246
1255
  const dumpData = {
1247
1256
  sdkVersion: getPkgInfo().version,
@@ -1,8 +1,8 @@
1
1
  import { ChatCompletionMessageParam } from 'openai/resources';
2
2
  export { ChatCompletionMessageParam } from 'openai/resources';
3
- import { c as callAiFn } from './index-56d82df6.js';
4
- export { d as describeUserPage, p as plan } from './index-56d82df6.js';
5
- import { B as BaseElement, U as UIContext, e as AIElementParseResponse, f as AISectionParseResponse, g as AIAssertionResponse } from './types-47142f81.js';
3
+ import { c as callAiFn } from './index-b994b411.js';
4
+ export { d as describeUserPage, p as plan } from './index-b994b411.js';
5
+ import { B as BaseElement, U as UIContext, e as AIElementParseResponse, f as AISectionParseResponse, g as AIAssertionResponse } from './types-60690f66.js';
6
6
 
7
7
  declare function AiInspectElement<ElementType extends BaseElement = BaseElement>(options: {
8
8
  context: UIContext<ElementType>;
@@ -1,5 +1,5 @@
1
1
  import { Buffer } from 'node:buffer';
2
- import { S as Size, R as Rect, h as UISection, U as UIContext, x as Color } from './types-47142f81.js';
2
+ import { S as Size, R as Rect, h as UISection, U as UIContext, x as Color } from './types-60690f66.js';
3
3
  import 'openai/resources';
4
4
 
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { B as BaseElement, U as UIContext, p as PlanningAction } from './types-47142f81.js';
1
+ import { B as BaseElement, U as UIContext, p as PlanningAction } from './types-60690f66.js';
2
2
  import { ChatCompletionSystemMessageParam, ChatCompletionUserMessageParam } from 'openai/resources';
3
3
 
4
4
  type AIArgs = [
@@ -1,7 +1,7 @@
1
- import { E as ExecutionTask, a as ExecutionTaskApply, b as ExecutionDump, B as BaseElement, U as UIContext, D as DumpSubscriber, I as InsightTaskInfo, c as InsightOptions, d as InsightAssertionResponse } from './types-47142f81.js';
2
- export { g as AIAssertionResponse, e as AIElementParseResponse, A as AIResponseFormat, f as AISectionParseResponse, y as BaseAgentParserOpt, j as BasicSectionQuery, C as CallAIFn, x as Color, l as DumpMeta, o as ElementById, i as EnsureObject, G as ExecutionRecorderItem, a2 as ExecutionTaskAction, a1 as ExecutionTaskActionApply, a0 as ExecutionTaskInsightAssertion, $ as ExecutionTaskInsightAssertionApply, _ as ExecutionTaskInsightAssertionParam, O as ExecutionTaskInsightDumpLog, V as ExecutionTaskInsightLocate, Q as ExecutionTaskInsightLocateApply, N as ExecutionTaskInsightLocateOutput, M as ExecutionTaskInsightLocateParam, Z as ExecutionTaskInsightQuery, Y as ExecutionTaskInsightQueryApply, X as ExecutionTaskInsightQueryOutput, W as ExecutionTaskInsightQueryParam, a4 as ExecutionTaskPlanning, a3 as ExecutionTaskPlanningApply, K as ExecutionTaskReturn, H as ExecutionTaskType, J as ExecutorContext, a5 as GroupedActionDump, m as InsightDump, k as InsightExtractParam, L as LiteUISection, n as PartialInsightDumpFromSDK, q as PlanningAIResponse, p as PlanningAction, v as PlanningActionParamAssert, s as PlanningActionParamHover, t as PlanningActionParamInputOrKeyPress, u as PlanningActionParamScroll, w as PlanningActionParamSleep, r as PlanningActionParamTap, F as PlaywrightParserOpt, P as Point, z as PuppeteerParserOpt, R as Rect, S as Size, T as TaskCacheInfo, h as UISection } from './types-47142f81.js';
3
- import { c as callAiFn, r as retrieveElement, a as retrieveSection } from './index-56d82df6.js';
4
- export { p as plan } from './index-56d82df6.js';
1
+ import { E as ExecutionTask, a as ExecutionTaskApply, b as ExecutionDump, B as BaseElement, U as UIContext, D as DumpSubscriber, I as InsightTaskInfo, c as InsightOptions, d as InsightAssertionResponse } from './types-60690f66.js';
2
+ export { g as AIAssertionResponse, e as AIElementParseResponse, A as AIResponseFormat, f as AISectionParseResponse, y as BaseAgentParserOpt, j as BasicSectionQuery, C as CallAIFn, x as Color, l as DumpMeta, o as ElementById, i as EnsureObject, G as ExecutionRecorderItem, a2 as ExecutionTaskAction, a1 as ExecutionTaskActionApply, a0 as ExecutionTaskInsightAssertion, $ as ExecutionTaskInsightAssertionApply, _ as ExecutionTaskInsightAssertionParam, O as ExecutionTaskInsightDumpLog, V as ExecutionTaskInsightLocate, Q as ExecutionTaskInsightLocateApply, N as ExecutionTaskInsightLocateOutput, M as ExecutionTaskInsightLocateParam, Z as ExecutionTaskInsightQuery, Y as ExecutionTaskInsightQueryApply, X as ExecutionTaskInsightQueryOutput, W as ExecutionTaskInsightQueryParam, a4 as ExecutionTaskPlanning, a3 as ExecutionTaskPlanningApply, K as ExecutionTaskReturn, H as ExecutionTaskType, J as ExecutorContext, a5 as GroupedActionDump, m as InsightDump, k as InsightExtractParam, L as LiteUISection, n as PartialInsightDumpFromSDK, q as PlanningAIResponse, p as PlanningAction, v as PlanningActionParamAssert, s as PlanningActionParamHover, t as PlanningActionParamInputOrKeyPress, u as PlanningActionParamScroll, w as PlanningActionParamSleep, r as PlanningActionParamTap, F as PlaywrightParserOpt, P as Point, z as PuppeteerParserOpt, R as Rect, S as Size, T as TaskCacheInfo, h as UISection } from './types-60690f66.js';
3
+ import { c as callAiFn, r as retrieveElement, a as retrieveSection } from './index-b994b411.js';
4
+ export { p as plan } from './index-b994b411.js';
5
5
  export { setDumpDir } from './utils.js';
6
6
  import 'openai/resources';
7
7
 
@@ -10,12 +10,12 @@ declare class Executor {
10
10
  description?: string;
11
11
  tasks: ExecutionTask[];
12
12
  status: 'init' | 'pending' | 'running' | 'completed' | 'error';
13
- errorMsg?: string;
14
- dumpFileName?: string;
15
13
  constructor(name: string, description?: string, tasks?: ExecutionTaskApply[]);
16
14
  private markTaskAsPending;
17
15
  append(task: ExecutionTaskApply[] | ExecutionTaskApply): Promise<void>;
18
16
  flush(): Promise<any>;
17
+ isInErrorState(): boolean;
18
+ latestErrorTask(): ExecutionTask | null;
19
19
  dump(): ExecutionDump;
20
20
  }
21
21
 
@@ -189,6 +189,7 @@ interface ExecutionTaskReturn<TaskOutput = unknown, TaskLog = unknown> {
189
189
  type ExecutionTask<E extends ExecutionTaskApply<any, any, any> = ExecutionTaskApply<any, any, any>> = E & ExecutionTaskReturn<E extends ExecutionTaskApply<any, any, infer TaskOutput, any> ? TaskOutput : unknown, E extends ExecutionTaskApply<any, any, any, infer TaskLog> ? TaskLog : unknown> & {
190
190
  status: 'pending' | 'running' | 'success' | 'fail' | 'cancelled';
191
191
  error?: string;
192
+ errorStack?: string;
192
193
  timing?: {
193
194
  start: number;
194
195
  end?: number;
@@ -1,4 +1,4 @@
1
- import { R as Rect } from './types-47142f81.js';
1
+ import { R as Rect } from './types-60690f66.js';
2
2
  import 'openai/resources';
3
3
 
4
4
  interface PkgInfo {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@midscene/core",
3
3
  "description": "Hello, It's Midscene",
4
- "version": "0.2.2-beta-20240809090814.0",
4
+ "version": "0.2.2",
5
5
  "jsnext:source": "./src/index.ts",
6
6
  "main": "./dist/lib/index.js",
7
7
  "module": "./dist/es/index.js",