@godscene/core 1.7.11
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/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/es/agent/agent.mjs +767 -0
- package/dist/es/agent/common.mjs +0 -0
- package/dist/es/agent/execution-session.mjs +39 -0
- package/dist/es/agent/index.mjs +6 -0
- package/dist/es/agent/task-builder.mjs +343 -0
- package/dist/es/agent/task-cache.mjs +212 -0
- package/dist/es/agent/tasks.mjs +428 -0
- package/dist/es/agent/ui-utils.mjs +101 -0
- package/dist/es/agent/utils.mjs +167 -0
- package/dist/es/ai-model/auto-glm/actions.mjs +237 -0
- package/dist/es/ai-model/auto-glm/index.mjs +6 -0
- package/dist/es/ai-model/auto-glm/parser.mjs +237 -0
- package/dist/es/ai-model/auto-glm/planning.mjs +69 -0
- package/dist/es/ai-model/auto-glm/prompt.mjs +220 -0
- package/dist/es/ai-model/auto-glm/util.mjs +7 -0
- package/dist/es/ai-model/connectivity.mjs +136 -0
- package/dist/es/ai-model/conversation-history.mjs +193 -0
- package/dist/es/ai-model/index.mjs +12 -0
- package/dist/es/ai-model/inspect.mjs +395 -0
- package/dist/es/ai-model/llm-planning.mjs +231 -0
- package/dist/es/ai-model/prompt/common.mjs +5 -0
- package/dist/es/ai-model/prompt/describe.mjs +64 -0
- package/dist/es/ai-model/prompt/extraction.mjs +129 -0
- package/dist/es/ai-model/prompt/llm-locator.mjs +49 -0
- package/dist/es/ai-model/prompt/llm-planning.mjs +584 -0
- package/dist/es/ai-model/prompt/llm-section-locator.mjs +42 -0
- package/dist/es/ai-model/prompt/order-sensitive-judge.mjs +33 -0
- package/dist/es/ai-model/prompt/playwright-generator.mjs +115 -0
- package/dist/es/ai-model/prompt/ui-tars-planning.mjs +34 -0
- package/dist/es/ai-model/prompt/util.mjs +57 -0
- package/dist/es/ai-model/prompt/yaml-generator.mjs +201 -0
- package/dist/es/ai-model/service-caller/codex-app-server.mjs +573 -0
- package/dist/es/ai-model/service-caller/image-detail.mjs +4 -0
- package/dist/es/ai-model/service-caller/index.mjs +648 -0
- package/dist/es/ai-model/service-caller/request-timeout.mjs +47 -0
- package/dist/es/ai-model/ui-tars-planning.mjs +247 -0
- package/dist/es/common.mjs +382 -0
- package/dist/es/device/device-options.mjs +0 -0
- package/dist/es/device/index.mjs +340 -0
- package/dist/es/dump/html-utils.mjs +290 -0
- package/dist/es/dump/index.mjs +3 -0
- package/dist/es/dump/screenshot-restoration.mjs +30 -0
- package/dist/es/dump/screenshot-store.mjs +125 -0
- package/dist/es/index.mjs +17 -0
- package/dist/es/report-cli.mjs +149 -0
- package/dist/es/report-generator.mjs +203 -0
- package/dist/es/report-markdown.mjs +216 -0
- package/dist/es/report.mjs +287 -0
- package/dist/es/screenshot-item.mjs +120 -0
- package/dist/es/service/index.mjs +272 -0
- package/dist/es/service/utils.mjs +13 -0
- package/dist/es/skill/index.mjs +35 -0
- package/dist/es/task-runner.mjs +261 -0
- package/dist/es/task-timing.mjs +10 -0
- package/dist/es/tree.mjs +11 -0
- package/dist/es/types.mjs +202 -0
- package/dist/es/utils.mjs +232 -0
- package/dist/es/yaml/builder.mjs +11 -0
- package/dist/es/yaml/index.mjs +4 -0
- package/dist/es/yaml/player.mjs +425 -0
- package/dist/es/yaml/utils.mjs +100 -0
- package/dist/es/yaml.mjs +0 -0
- package/dist/lib/agent/agent.js +815 -0
- package/dist/lib/agent/common.js +5 -0
- package/dist/lib/agent/execution-session.js +73 -0
- package/dist/lib/agent/index.js +76 -0
- package/dist/lib/agent/task-builder.js +380 -0
- package/dist/lib/agent/task-cache.js +264 -0
- package/dist/lib/agent/tasks.js +471 -0
- package/dist/lib/agent/ui-utils.js +153 -0
- package/dist/lib/agent/utils.js +238 -0
- package/dist/lib/ai-model/auto-glm/actions.js +271 -0
- package/dist/lib/ai-model/auto-glm/index.js +64 -0
- package/dist/lib/ai-model/auto-glm/parser.js +280 -0
- package/dist/lib/ai-model/auto-glm/planning.js +103 -0
- package/dist/lib/ai-model/auto-glm/prompt.js +257 -0
- package/dist/lib/ai-model/auto-glm/util.js +44 -0
- package/dist/lib/ai-model/connectivity.js +180 -0
- package/dist/lib/ai-model/conversation-history.js +227 -0
- package/dist/lib/ai-model/index.js +127 -0
- package/dist/lib/ai-model/inspect.js +441 -0
- package/dist/lib/ai-model/llm-planning.js +268 -0
- package/dist/lib/ai-model/prompt/common.js +39 -0
- package/dist/lib/ai-model/prompt/describe.js +98 -0
- package/dist/lib/ai-model/prompt/extraction.js +169 -0
- package/dist/lib/ai-model/prompt/llm-locator.js +86 -0
- package/dist/lib/ai-model/prompt/llm-planning.js +621 -0
- package/dist/lib/ai-model/prompt/llm-section-locator.js +79 -0
- package/dist/lib/ai-model/prompt/order-sensitive-judge.js +70 -0
- package/dist/lib/ai-model/prompt/playwright-generator.js +176 -0
- package/dist/lib/ai-model/prompt/ui-tars-planning.js +71 -0
- package/dist/lib/ai-model/prompt/util.js +103 -0
- package/dist/lib/ai-model/prompt/yaml-generator.js +262 -0
- package/dist/lib/ai-model/service-caller/codex-app-server.js +622 -0
- package/dist/lib/ai-model/service-caller/image-detail.js +38 -0
- package/dist/lib/ai-model/service-caller/index.js +716 -0
- package/dist/lib/ai-model/service-caller/request-timeout.js +93 -0
- package/dist/lib/ai-model/ui-tars-planning.js +281 -0
- package/dist/lib/common.js +491 -0
- package/dist/lib/device/device-options.js +18 -0
- package/dist/lib/device/index.js +467 -0
- package/dist/lib/dump/html-utils.js +366 -0
- package/dist/lib/dump/index.js +58 -0
- package/dist/lib/dump/screenshot-restoration.js +64 -0
- package/dist/lib/dump/screenshot-store.js +165 -0
- package/dist/lib/index.js +184 -0
- package/dist/lib/report-cli.js +189 -0
- package/dist/lib/report-generator.js +244 -0
- package/dist/lib/report-markdown.js +253 -0
- package/dist/lib/report.js +333 -0
- package/dist/lib/screenshot-item.js +154 -0
- package/dist/lib/service/index.js +306 -0
- package/dist/lib/service/utils.js +47 -0
- package/dist/lib/skill/index.js +69 -0
- package/dist/lib/task-runner.js +298 -0
- package/dist/lib/task-timing.js +44 -0
- package/dist/lib/tree.js +51 -0
- package/dist/lib/types.js +298 -0
- package/dist/lib/utils.js +314 -0
- package/dist/lib/yaml/builder.js +55 -0
- package/dist/lib/yaml/index.js +79 -0
- package/dist/lib/yaml/player.js +459 -0
- package/dist/lib/yaml/utils.js +153 -0
- package/dist/lib/yaml.js +18 -0
- package/dist/types/agent/agent.d.ts +220 -0
- package/dist/types/agent/common.d.ts +0 -0
- package/dist/types/agent/execution-session.d.ts +36 -0
- package/dist/types/agent/index.d.ts +9 -0
- package/dist/types/agent/task-builder.d.ts +34 -0
- package/dist/types/agent/task-cache.d.ts +49 -0
- package/dist/types/agent/tasks.d.ts +70 -0
- package/dist/types/agent/ui-utils.d.ts +14 -0
- package/dist/types/agent/utils.d.ts +25 -0
- package/dist/types/ai-model/auto-glm/actions.d.ts +78 -0
- package/dist/types/ai-model/auto-glm/index.d.ts +6 -0
- package/dist/types/ai-model/auto-glm/parser.d.ts +18 -0
- package/dist/types/ai-model/auto-glm/planning.d.ts +12 -0
- package/dist/types/ai-model/auto-glm/prompt.d.ts +27 -0
- package/dist/types/ai-model/auto-glm/util.d.ts +13 -0
- package/dist/types/ai-model/connectivity.d.ts +20 -0
- package/dist/types/ai-model/conversation-history.d.ts +105 -0
- package/dist/types/ai-model/index.d.ts +16 -0
- package/dist/types/ai-model/inspect.d.ts +67 -0
- package/dist/types/ai-model/llm-planning.d.ts +19 -0
- package/dist/types/ai-model/prompt/common.d.ts +2 -0
- package/dist/types/ai-model/prompt/describe.d.ts +1 -0
- package/dist/types/ai-model/prompt/extraction.d.ts +7 -0
- package/dist/types/ai-model/prompt/llm-locator.d.ts +3 -0
- package/dist/types/ai-model/prompt/llm-planning.d.ts +10 -0
- package/dist/types/ai-model/prompt/llm-section-locator.d.ts +3 -0
- package/dist/types/ai-model/prompt/order-sensitive-judge.d.ts +2 -0
- package/dist/types/ai-model/prompt/playwright-generator.d.ts +26 -0
- package/dist/types/ai-model/prompt/ui-tars-planning.d.ts +2 -0
- package/dist/types/ai-model/prompt/util.d.ts +33 -0
- package/dist/types/ai-model/prompt/yaml-generator.d.ts +102 -0
- package/dist/types/ai-model/service-caller/codex-app-server.d.ts +42 -0
- package/dist/types/ai-model/service-caller/image-detail.d.ts +2 -0
- package/dist/types/ai-model/service-caller/index.d.ts +60 -0
- package/dist/types/ai-model/service-caller/request-timeout.d.ts +32 -0
- package/dist/types/ai-model/ui-tars-planning.d.ts +72 -0
- package/dist/types/common.d.ts +288 -0
- package/dist/types/device/device-options.d.ts +155 -0
- package/dist/types/device/index.d.ts +2565 -0
- package/dist/types/dump/html-utils.d.ts +75 -0
- package/dist/types/dump/index.d.ts +5 -0
- package/dist/types/dump/screenshot-restoration.d.ts +8 -0
- package/dist/types/dump/screenshot-store.d.ts +49 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/report-cli.d.ts +36 -0
- package/dist/types/report-generator.d.ts +88 -0
- package/dist/types/report-markdown.d.ts +24 -0
- package/dist/types/report.d.ts +52 -0
- package/dist/types/screenshot-item.d.ts +67 -0
- package/dist/types/service/index.d.ts +24 -0
- package/dist/types/service/utils.d.ts +2 -0
- package/dist/types/skill/index.d.ts +25 -0
- package/dist/types/task-runner.d.ts +50 -0
- package/dist/types/task-timing.d.ts +8 -0
- package/dist/types/tree.d.ts +4 -0
- package/dist/types/types.d.ts +684 -0
- package/dist/types/utils.d.ts +45 -0
- package/dist/types/yaml/builder.d.ts +2 -0
- package/dist/types/yaml/index.d.ts +4 -0
- package/dist/types/yaml/player.d.ts +34 -0
- package/dist/types/yaml/utils.d.ts +9 -0
- package/dist/types/yaml.d.ts +215 -0
- package/package.json +130 -0
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
"use strict";
|
|
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 ("u" > 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
|
+
locatePlanForLocate: ()=>external_task_builder_js_namespaceObject.locatePlanForLocate,
|
|
28
|
+
TaskExecutionError: ()=>external_task_runner_js_namespaceObject.TaskExecutionError,
|
|
29
|
+
TaskExecutor: ()=>TaskExecutor,
|
|
30
|
+
withFileChooser: ()=>withFileChooser
|
|
31
|
+
});
|
|
32
|
+
const index_js_namespaceObject = require("../ai-model/index.js");
|
|
33
|
+
const util_js_namespaceObject = require("../ai-model/auto-glm/util.js");
|
|
34
|
+
const external_common_js_namespaceObject = require("../common.js");
|
|
35
|
+
const external_task_runner_js_namespaceObject = require("../task-runner.js");
|
|
36
|
+
const external_types_js_namespaceObject = require("../types.js");
|
|
37
|
+
const logger_namespaceObject = require("@godscene/shared/logger");
|
|
38
|
+
const utils_namespaceObject = require("@godscene/shared/utils");
|
|
39
|
+
const external_execution_session_js_namespaceObject = require("./execution-session.js");
|
|
40
|
+
const external_task_builder_js_namespaceObject = require("./task-builder.js");
|
|
41
|
+
const external_task_timing_js_namespaceObject = require("../task-timing.js");
|
|
42
|
+
const extractor_namespaceObject = require("@godscene/shared/extractor");
|
|
43
|
+
const external_ui_utils_js_namespaceObject = require("./ui-utils.js");
|
|
44
|
+
const external_utils_js_namespaceObject = require("./utils.js");
|
|
45
|
+
function _define_property(obj, key, value) {
|
|
46
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
47
|
+
value: value,
|
|
48
|
+
enumerable: true,
|
|
49
|
+
configurable: true,
|
|
50
|
+
writable: true
|
|
51
|
+
});
|
|
52
|
+
else obj[key] = value;
|
|
53
|
+
return obj;
|
|
54
|
+
}
|
|
55
|
+
const debug = (0, logger_namespaceObject.getDebug)('device-task-executor');
|
|
56
|
+
const warnLog = (0, logger_namespaceObject.getDebug)('device-task-executor', {
|
|
57
|
+
console: true
|
|
58
|
+
});
|
|
59
|
+
const maxErrorCountAllowedInOnePlanningLoop = 5;
|
|
60
|
+
class TaskExecutor {
|
|
61
|
+
get page() {
|
|
62
|
+
return this.interface;
|
|
63
|
+
}
|
|
64
|
+
createExecutionSession(title, options) {
|
|
65
|
+
return new external_execution_session_js_namespaceObject.ExecutionSession(title, ()=>Promise.resolve(this.service.contextRetrieverFn()), {
|
|
66
|
+
onTaskStart: this.onTaskStartCallback,
|
|
67
|
+
tasks: options?.tasks,
|
|
68
|
+
onTaskUpdate: this.hooks?.onTaskUpdate
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
getActionSpace() {
|
|
72
|
+
return this.providedActionSpace;
|
|
73
|
+
}
|
|
74
|
+
async getTimeString(format) {
|
|
75
|
+
if (this.useDeviceTime) if (this.interface.getDeviceLocalTimeString) try {
|
|
76
|
+
return await this.interface.getDeviceLocalTimeString(format);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
warnLog(`Failed to get device time string, falling back to runtime time: ${error}`);
|
|
79
|
+
}
|
|
80
|
+
else warnLog('useDeviceTime is enabled but getDeviceLocalTimeString is not implemented, falling back to runtime time.');
|
|
81
|
+
return (0, external_common_js_namespaceObject.getReadableTimeString)(format);
|
|
82
|
+
}
|
|
83
|
+
async convertPlanToExecutable(plans, modelConfigForPlanning, modelConfigForDefaultIntent, options) {
|
|
84
|
+
return this.taskBuilder.build(plans, modelConfigForPlanning, modelConfigForDefaultIntent, options);
|
|
85
|
+
}
|
|
86
|
+
async loadYamlFlowAsPlanning(userInstruction, yamlString) {
|
|
87
|
+
const session = this.createExecutionSession((0, external_ui_utils_js_namespaceObject.taskTitleStr)('Act', userInstruction));
|
|
88
|
+
const task = {
|
|
89
|
+
type: 'Planning',
|
|
90
|
+
subType: 'LoadYaml',
|
|
91
|
+
param: {
|
|
92
|
+
userInstruction
|
|
93
|
+
},
|
|
94
|
+
executor: async (param, executorContext)=>{
|
|
95
|
+
const { uiContext } = executorContext;
|
|
96
|
+
(0, utils_namespaceObject.assert)(uiContext, 'uiContext is required for Planning task');
|
|
97
|
+
return {
|
|
98
|
+
output: {
|
|
99
|
+
actions: [],
|
|
100
|
+
shouldContinuePlanning: false,
|
|
101
|
+
log: '',
|
|
102
|
+
yamlString
|
|
103
|
+
},
|
|
104
|
+
cache: {
|
|
105
|
+
hit: true
|
|
106
|
+
},
|
|
107
|
+
hitBy: {
|
|
108
|
+
from: 'Cache',
|
|
109
|
+
context: {
|
|
110
|
+
yamlString
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const runner = session.getRunner();
|
|
117
|
+
await session.appendAndRun(task);
|
|
118
|
+
return {
|
|
119
|
+
runner
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
async runPlans(title, plans, modelConfigForPlanning, modelConfigForDefaultIntent) {
|
|
123
|
+
const session = this.createExecutionSession(title);
|
|
124
|
+
const { tasks } = await this.convertPlanToExecutable(plans, modelConfigForPlanning, modelConfigForDefaultIntent);
|
|
125
|
+
const runner = session.getRunner();
|
|
126
|
+
const result = await session.appendAndRun(tasks);
|
|
127
|
+
const { output } = result ?? {};
|
|
128
|
+
return {
|
|
129
|
+
output,
|
|
130
|
+
runner
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
async action(userPrompt, modelConfigForPlanning, modelConfigForDefaultIntent, includeBboxInPlanning, aiActContext, cacheable, replanningCycleLimitOverride, imagesIncludeCount, deepThink, fileChooserAccept, deepLocate, abortSignal) {
|
|
134
|
+
return withFileChooser(this.interface, fileChooserAccept, async ()=>this.runAction(userPrompt, modelConfigForPlanning, modelConfigForDefaultIntent, includeBboxInPlanning, aiActContext, cacheable, replanningCycleLimitOverride, imagesIncludeCount, deepThink, deepLocate, abortSignal));
|
|
135
|
+
}
|
|
136
|
+
async runAction(userPrompt, modelConfigForPlanning, modelConfigForDefaultIntent, includeBboxInPlanning, aiActContext, cacheable, replanningCycleLimitOverride, imagesIncludeCount, deepThink, deepLocate, abortSignal) {
|
|
137
|
+
const conversationHistory = new index_js_namespaceObject.ConversationHistory();
|
|
138
|
+
const session = this.createExecutionSession((0, external_ui_utils_js_namespaceObject.taskTitleStr)('Act', userPrompt));
|
|
139
|
+
const runner = session.getRunner();
|
|
140
|
+
let replanCount = 0;
|
|
141
|
+
const yamlFlow = [];
|
|
142
|
+
const replanningCycleLimit = replanningCycleLimitOverride ?? this.replanningCycleLimit;
|
|
143
|
+
(0, utils_namespaceObject.assert)(void 0 !== replanningCycleLimit, 'replanningCycleLimit is required for TaskExecutor.action');
|
|
144
|
+
let errorCountInOnePlanningLoop = 0;
|
|
145
|
+
let outputString;
|
|
146
|
+
while(true){
|
|
147
|
+
if (abortSignal?.aborted) return session.appendErrorPlan(`Task aborted: ${abortSignal.reason || 'abort signal received'}`);
|
|
148
|
+
const subGoalStatus = conversationHistory.subGoalsToText() || void 0;
|
|
149
|
+
const memoriesStatus = conversationHistory.memoriesToText() || void 0;
|
|
150
|
+
const result = await session.appendAndRun({
|
|
151
|
+
type: 'Planning',
|
|
152
|
+
subType: 'Plan',
|
|
153
|
+
param: {
|
|
154
|
+
userInstruction: userPrompt,
|
|
155
|
+
aiActContext,
|
|
156
|
+
imagesIncludeCount,
|
|
157
|
+
deepThink,
|
|
158
|
+
...subGoalStatus ? {
|
|
159
|
+
subGoalStatus
|
|
160
|
+
} : {},
|
|
161
|
+
...memoriesStatus ? {
|
|
162
|
+
memoriesStatus
|
|
163
|
+
} : {}
|
|
164
|
+
},
|
|
165
|
+
executor: async (param, executorContext)=>{
|
|
166
|
+
const { uiContext } = executorContext;
|
|
167
|
+
(0, utils_namespaceObject.assert)(uiContext, 'uiContext is required for Planning task');
|
|
168
|
+
const { modelFamily } = modelConfigForPlanning;
|
|
169
|
+
const timing = executorContext.task.timing;
|
|
170
|
+
const actionSpace = this.getActionSpace();
|
|
171
|
+
debug('actionSpace for this interface is:', actionSpace.map((action)=>action.name).join(', '));
|
|
172
|
+
(0, utils_namespaceObject.assert)(Array.isArray(actionSpace), 'actionSpace must be an array');
|
|
173
|
+
if (0 === actionSpace.length) console.warn(`ActionSpace for ${this.interface.interfaceType} is empty. This may lead to unexpected behavior.`);
|
|
174
|
+
const planImpl = (0, util_js_namespaceObject.isUITars)(modelFamily) ? index_js_namespaceObject.uiTarsPlanning : (0, util_js_namespaceObject.isAutoGLM)(modelFamily) ? index_js_namespaceObject.autoGLMPlanning : index_js_namespaceObject.plan;
|
|
175
|
+
let planResult;
|
|
176
|
+
try {
|
|
177
|
+
(0, external_task_timing_js_namespaceObject.setTimingFieldOnce)(timing, 'callAiStart');
|
|
178
|
+
planResult = await planImpl(param.userInstruction, {
|
|
179
|
+
context: uiContext,
|
|
180
|
+
actionContext: param.aiActContext,
|
|
181
|
+
interfaceType: this.interface.interfaceType,
|
|
182
|
+
actionSpace,
|
|
183
|
+
modelConfig: modelConfigForPlanning,
|
|
184
|
+
conversationHistory,
|
|
185
|
+
includeBbox: includeBboxInPlanning,
|
|
186
|
+
imagesIncludeCount,
|
|
187
|
+
deepThink,
|
|
188
|
+
abortSignal
|
|
189
|
+
});
|
|
190
|
+
} catch (planError) {
|
|
191
|
+
if (planError instanceof index_js_namespaceObject.AIResponseParseError) {
|
|
192
|
+
executorContext.task.usage = planError.usage;
|
|
193
|
+
executorContext.task.log = {
|
|
194
|
+
...executorContext.task.log || {},
|
|
195
|
+
rawResponse: planError.rawResponse
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
throw planError;
|
|
199
|
+
} finally{
|
|
200
|
+
(0, external_task_timing_js_namespaceObject.setTimingFieldOnce)(timing, 'callAiEnd');
|
|
201
|
+
}
|
|
202
|
+
debug('planResult', JSON.stringify(planResult, null, 2));
|
|
203
|
+
const { actions, thought, log, memory, error, usage, rawResponse, reasoning_content, finalizeSuccess, finalizeMessage, updateSubGoals, markFinishedIndexes } = planResult;
|
|
204
|
+
outputString = finalizeMessage;
|
|
205
|
+
executorContext.task.log = {
|
|
206
|
+
...executorContext.task.log || {},
|
|
207
|
+
rawResponse
|
|
208
|
+
};
|
|
209
|
+
executorContext.task.usage = usage;
|
|
210
|
+
executorContext.task.reasoning_content = reasoning_content;
|
|
211
|
+
executorContext.task.output = {
|
|
212
|
+
actions: actions || [],
|
|
213
|
+
log,
|
|
214
|
+
thought,
|
|
215
|
+
memory,
|
|
216
|
+
yamlFlow: planResult.yamlFlow,
|
|
217
|
+
output: finalizeMessage,
|
|
218
|
+
shouldContinuePlanning: planResult.shouldContinuePlanning,
|
|
219
|
+
updateSubGoals,
|
|
220
|
+
markFinishedIndexes
|
|
221
|
+
};
|
|
222
|
+
executorContext.uiContext = uiContext;
|
|
223
|
+
(0, utils_namespaceObject.assert)(!error, `Failed to continue: ${error}\n${log || ''}`);
|
|
224
|
+
if (false === finalizeSuccess) (0, utils_namespaceObject.assert)(false, `Task failed: ${finalizeMessage || 'No error message provided'}\n${log || ''}`);
|
|
225
|
+
return {
|
|
226
|
+
cache: {
|
|
227
|
+
hit: false
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}, {
|
|
232
|
+
allowWhenError: true
|
|
233
|
+
});
|
|
234
|
+
const planResult = result?.output;
|
|
235
|
+
const plans = planResult?.actions || [];
|
|
236
|
+
yamlFlow.push(...planResult?.yamlFlow || []);
|
|
237
|
+
let executables;
|
|
238
|
+
try {
|
|
239
|
+
executables = await this.convertPlanToExecutable(plans, modelConfigForPlanning, modelConfigForDefaultIntent, {
|
|
240
|
+
cacheable,
|
|
241
|
+
deepLocate,
|
|
242
|
+
abortSignal
|
|
243
|
+
});
|
|
244
|
+
} catch (error) {
|
|
245
|
+
return session.appendErrorPlan(`Error converting plans to executable tasks: ${error}, plans: ${JSON.stringify(plans)}`);
|
|
246
|
+
}
|
|
247
|
+
if (conversationHistory.pendingFeedbackMessage) console.warn('unconsumed pending feedback message detected, this may lead to unexpected planning result:', conversationHistory.pendingFeedbackMessage);
|
|
248
|
+
const initialTimeString = await this.getTimeString();
|
|
249
|
+
conversationHistory.pendingFeedbackMessage += `Current time: ${initialTimeString}`;
|
|
250
|
+
try {
|
|
251
|
+
await session.appendAndRun(executables.tasks);
|
|
252
|
+
} catch (error) {
|
|
253
|
+
errorCountInOnePlanningLoop++;
|
|
254
|
+
const timeString = await this.getTimeString();
|
|
255
|
+
conversationHistory.pendingFeedbackMessage = `Time: ${timeString}, Error executing running tasks: ${error?.message || String(error)}`;
|
|
256
|
+
debug('error when executing running tasks, but continue to run if it is not too many errors:', error instanceof Error ? error.message : String(error), 'current error count in one planning loop:', errorCountInOnePlanningLoop);
|
|
257
|
+
}
|
|
258
|
+
if (errorCountInOnePlanningLoop > maxErrorCountAllowedInOnePlanningLoop) return session.appendErrorPlan('Too many errors in one planning loop');
|
|
259
|
+
if (abortSignal?.aborted) return session.appendErrorPlan(`Task aborted: ${abortSignal.reason || 'abort signal received'}`);
|
|
260
|
+
if (!planResult?.shouldContinuePlanning) break;
|
|
261
|
+
++replanCount;
|
|
262
|
+
if (replanCount > replanningCycleLimit) {
|
|
263
|
+
const errorMsg = `Replanned ${replanningCycleLimit} times, exceeding the limit. Please configure a larger value for replanningCycleLimit (or use MIDSCENE_REPLANNING_CYCLE_LIMIT) to handle more complex tasks.`;
|
|
264
|
+
return session.appendErrorPlan(errorMsg);
|
|
265
|
+
}
|
|
266
|
+
if (!conversationHistory.pendingFeedbackMessage) {
|
|
267
|
+
const timeString = await this.getTimeString();
|
|
268
|
+
conversationHistory.pendingFeedbackMessage = `Time: ${timeString}, I have finished the action previously planned.`;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
output: {
|
|
273
|
+
yamlFlow,
|
|
274
|
+
output: outputString
|
|
275
|
+
},
|
|
276
|
+
runner
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
createTypeQueryTask(type, demand, modelConfig, opt, multimodalPrompt) {
|
|
280
|
+
const queryTask = {
|
|
281
|
+
type: 'Insight',
|
|
282
|
+
subType: type,
|
|
283
|
+
param: {
|
|
284
|
+
domIncluded: opt?.domIncluded,
|
|
285
|
+
dataDemand: multimodalPrompt ? {
|
|
286
|
+
demand,
|
|
287
|
+
multimodalPrompt
|
|
288
|
+
} : demand
|
|
289
|
+
},
|
|
290
|
+
executor: async (param, taskContext)=>{
|
|
291
|
+
const { task } = taskContext;
|
|
292
|
+
let queryDump;
|
|
293
|
+
const applyDump = (dump)=>{
|
|
294
|
+
queryDump = dump;
|
|
295
|
+
task.log = {
|
|
296
|
+
dump,
|
|
297
|
+
rawResponse: dump.taskInfo?.rawResponse
|
|
298
|
+
};
|
|
299
|
+
task.usage = dump.taskInfo?.usage;
|
|
300
|
+
if (dump.taskInfo?.reasoning_content) task.reasoning_content = dump.taskInfo.reasoning_content;
|
|
301
|
+
};
|
|
302
|
+
const uiContext = taskContext.uiContext;
|
|
303
|
+
(0, utils_namespaceObject.assert)(uiContext, 'uiContext is required for Query task');
|
|
304
|
+
const ifTypeRestricted = 'Query' !== type;
|
|
305
|
+
let demandInput = demand;
|
|
306
|
+
let keyOfResult = 'result';
|
|
307
|
+
if (ifTypeRestricted && ('Assert' === type || 'WaitFor' === type)) {
|
|
308
|
+
keyOfResult = 'StatementIsTruthy';
|
|
309
|
+
const booleanPrompt = 'Assert' === type ? `Boolean, whether the following statement is true: ${demand}` : `Boolean, the user wants to do some 'wait for' operation, please check whether the following statement is true: ${demand}`;
|
|
310
|
+
demandInput = {
|
|
311
|
+
[keyOfResult]: booleanPrompt
|
|
312
|
+
};
|
|
313
|
+
} else if (ifTypeRestricted) {
|
|
314
|
+
keyOfResult = type;
|
|
315
|
+
demandInput = {
|
|
316
|
+
[keyOfResult]: `${type}, ${demand}`
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
let extractResult;
|
|
320
|
+
let extraPageDescription = '';
|
|
321
|
+
if (opt?.domIncluded && this.interface.getElementsNodeTree) {
|
|
322
|
+
debug('appending tree info for page');
|
|
323
|
+
const tree = await this.interface.getElementsNodeTree();
|
|
324
|
+
extraPageDescription = await (0, extractor_namespaceObject.descriptionOfTree)(tree, 200, false, opt?.domIncluded === 'visible-only');
|
|
325
|
+
}
|
|
326
|
+
try {
|
|
327
|
+
extractResult = await this.service.extract(demandInput, modelConfig, opt, extraPageDescription, multimodalPrompt, uiContext);
|
|
328
|
+
} catch (error) {
|
|
329
|
+
if (error instanceof external_types_js_namespaceObject.ServiceError) applyDump(error.dump);
|
|
330
|
+
throw error;
|
|
331
|
+
}
|
|
332
|
+
const { data, thought, dump } = extractResult;
|
|
333
|
+
applyDump(dump);
|
|
334
|
+
let outputResult = data;
|
|
335
|
+
if (ifTypeRestricted) if ('string' == typeof data) outputResult = data;
|
|
336
|
+
else if ('WaitFor' === type) outputResult = null == data ? false : data[keyOfResult];
|
|
337
|
+
else if (null == data) outputResult = null;
|
|
338
|
+
else if (data?.[keyOfResult] !== void 0) outputResult = data[keyOfResult];
|
|
339
|
+
else if (data?.result !== void 0) outputResult = data.result;
|
|
340
|
+
else (0, utils_namespaceObject.assert)(false, 'No result in query data');
|
|
341
|
+
if ('Assert' === type && !outputResult) {
|
|
342
|
+
task.thought = thought;
|
|
343
|
+
throw new Error(`Assertion failed: ${thought}`);
|
|
344
|
+
}
|
|
345
|
+
return {
|
|
346
|
+
output: outputResult,
|
|
347
|
+
log: queryDump,
|
|
348
|
+
thought
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
return queryTask;
|
|
353
|
+
}
|
|
354
|
+
async createTypeQueryExecution(type, demand, modelConfig, opt, multimodalPrompt) {
|
|
355
|
+
const session = this.createExecutionSession((0, external_ui_utils_js_namespaceObject.taskTitleStr)(type, 'string' == typeof demand ? demand : JSON.stringify(demand)));
|
|
356
|
+
const queryTask = await this.createTypeQueryTask(type, demand, modelConfig, opt, multimodalPrompt);
|
|
357
|
+
const runner = session.getRunner();
|
|
358
|
+
const result = await session.appendAndRun(queryTask);
|
|
359
|
+
if (!result) throw new Error('result of taskExecutor.flush() is undefined in function createTypeQueryTask');
|
|
360
|
+
const { output, thought } = result;
|
|
361
|
+
return {
|
|
362
|
+
output,
|
|
363
|
+
thought,
|
|
364
|
+
runner
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
async waitFor(assertion, opt, modelConfig) {
|
|
368
|
+
const { textPrompt, multimodalPrompt } = (0, external_utils_js_namespaceObject.parsePrompt)(assertion);
|
|
369
|
+
const description = `waitFor: ${textPrompt}`;
|
|
370
|
+
const session = this.createExecutionSession((0, external_ui_utils_js_namespaceObject.taskTitleStr)('WaitFor', description));
|
|
371
|
+
const runner = session.getRunner();
|
|
372
|
+
const { timeoutMs, checkIntervalMs, domIncluded, screenshotIncluded, ...restOpt } = opt;
|
|
373
|
+
const serviceExtractOpt = {
|
|
374
|
+
domIncluded,
|
|
375
|
+
screenshotIncluded,
|
|
376
|
+
...restOpt
|
|
377
|
+
};
|
|
378
|
+
(0, utils_namespaceObject.assert)(assertion, 'No assertion for waitFor');
|
|
379
|
+
(0, utils_namespaceObject.assert)(timeoutMs, 'No timeoutMs for waitFor');
|
|
380
|
+
(0, utils_namespaceObject.assert)(checkIntervalMs, 'No checkIntervalMs for waitFor');
|
|
381
|
+
(0, utils_namespaceObject.assert)(checkIntervalMs <= timeoutMs, `wrong config for waitFor: checkIntervalMs must be less than timeoutMs, config: {checkIntervalMs: ${checkIntervalMs}, timeoutMs: ${timeoutMs}}`);
|
|
382
|
+
const overallStartTime = Date.now();
|
|
383
|
+
let lastCheckStart = overallStartTime;
|
|
384
|
+
let errorThought = '';
|
|
385
|
+
while(lastCheckStart - overallStartTime <= timeoutMs){
|
|
386
|
+
const currentCheckStart = Date.now();
|
|
387
|
+
lastCheckStart = currentCheckStart;
|
|
388
|
+
const queryTask = await this.createTypeQueryTask('WaitFor', textPrompt, modelConfig, serviceExtractOpt, multimodalPrompt);
|
|
389
|
+
const result = await session.appendAndRun(queryTask);
|
|
390
|
+
if (result?.output) return {
|
|
391
|
+
output: void 0,
|
|
392
|
+
runner
|
|
393
|
+
};
|
|
394
|
+
errorThought = result?.thought || !result && `No result from assertion: ${textPrompt}` || `unknown error when waiting for assertion: ${textPrompt}`;
|
|
395
|
+
const now = Date.now();
|
|
396
|
+
if (now - currentCheckStart < checkIntervalMs) {
|
|
397
|
+
const elapsed = now - currentCheckStart;
|
|
398
|
+
const timeRemaining = checkIntervalMs - elapsed;
|
|
399
|
+
const thought = `Check interval is ${checkIntervalMs}ms, ${elapsed}ms elapsed since last check, sleeping for ${timeRemaining}ms`;
|
|
400
|
+
const { tasks: sleepTasks } = await this.convertPlanToExecutable([
|
|
401
|
+
{
|
|
402
|
+
type: 'Sleep',
|
|
403
|
+
param: {
|
|
404
|
+
timeMs: timeRemaining
|
|
405
|
+
},
|
|
406
|
+
thought
|
|
407
|
+
}
|
|
408
|
+
], modelConfig, modelConfig);
|
|
409
|
+
if (sleepTasks[0]) await session.appendAndRun(sleepTasks[0]);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return session.appendErrorPlan(`waitFor timeout: ${errorThought}`);
|
|
413
|
+
}
|
|
414
|
+
constructor(interfaceInstance, service, opts){
|
|
415
|
+
_define_property(this, "interface", void 0);
|
|
416
|
+
_define_property(this, "service", void 0);
|
|
417
|
+
_define_property(this, "taskCache", void 0);
|
|
418
|
+
_define_property(this, "providedActionSpace", void 0);
|
|
419
|
+
_define_property(this, "taskBuilder", void 0);
|
|
420
|
+
_define_property(this, "onTaskStartCallback", void 0);
|
|
421
|
+
_define_property(this, "hooks", void 0);
|
|
422
|
+
_define_property(this, "replanningCycleLimit", void 0);
|
|
423
|
+
_define_property(this, "waitAfterAction", void 0);
|
|
424
|
+
_define_property(this, "useDeviceTime", void 0);
|
|
425
|
+
this.interface = interfaceInstance;
|
|
426
|
+
this.service = service;
|
|
427
|
+
this.taskCache = opts.taskCache;
|
|
428
|
+
this.onTaskStartCallback = opts?.onTaskStart;
|
|
429
|
+
this.replanningCycleLimit = opts.replanningCycleLimit;
|
|
430
|
+
this.waitAfterAction = opts.waitAfterAction;
|
|
431
|
+
this.useDeviceTime = opts.useDeviceTime;
|
|
432
|
+
this.hooks = opts.hooks;
|
|
433
|
+
this.providedActionSpace = opts.actionSpace;
|
|
434
|
+
this.taskBuilder = new external_task_builder_js_namespaceObject.TaskBuilder({
|
|
435
|
+
interfaceInstance,
|
|
436
|
+
service,
|
|
437
|
+
taskCache: opts.taskCache,
|
|
438
|
+
actionSpace: this.getActionSpace(),
|
|
439
|
+
waitAfterAction: opts.waitAfterAction
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
async function withFileChooser(interfaceInstance, fileChooserAccept, action) {
|
|
444
|
+
if (!fileChooserAccept?.length) return action();
|
|
445
|
+
if (!interfaceInstance.registerFileChooserListener) throw new Error(`File upload is not supported on ${interfaceInstance.interfaceType}`);
|
|
446
|
+
const handler = async (chooser)=>{
|
|
447
|
+
await chooser.accept(fileChooserAccept);
|
|
448
|
+
};
|
|
449
|
+
const { dispose, getError } = await interfaceInstance.registerFileChooserListener(handler);
|
|
450
|
+
try {
|
|
451
|
+
const result = await action();
|
|
452
|
+
const error = getError();
|
|
453
|
+
if (error) throw error;
|
|
454
|
+
return result;
|
|
455
|
+
} finally{
|
|
456
|
+
dispose();
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
exports.TaskExecutionError = __webpack_exports__.TaskExecutionError;
|
|
460
|
+
exports.TaskExecutor = __webpack_exports__.TaskExecutor;
|
|
461
|
+
exports.locatePlanForLocate = __webpack_exports__.locatePlanForLocate;
|
|
462
|
+
exports.withFileChooser = __webpack_exports__.withFileChooser;
|
|
463
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
464
|
+
"TaskExecutionError",
|
|
465
|
+
"TaskExecutor",
|
|
466
|
+
"locatePlanForLocate",
|
|
467
|
+
"withFileChooser"
|
|
468
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
469
|
+
Object.defineProperty(exports, '__esModule', {
|
|
470
|
+
value: true
|
|
471
|
+
});
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
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 ("u" > 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
|
+
extractInsightParam: ()=>extractInsightParam,
|
|
28
|
+
locateParamStr: ()=>locateParamStr,
|
|
29
|
+
paramStr: ()=>paramStr,
|
|
30
|
+
pullParamStr: ()=>pullParamStr,
|
|
31
|
+
scrollParamStr: ()=>scrollParamStr,
|
|
32
|
+
taskTitleStr: ()=>taskTitleStr,
|
|
33
|
+
typeStr: ()=>typeStr
|
|
34
|
+
});
|
|
35
|
+
function typeStr(task) {
|
|
36
|
+
return task.subType || task.type;
|
|
37
|
+
}
|
|
38
|
+
function locateParamStr(locate) {
|
|
39
|
+
if (!locate) return '';
|
|
40
|
+
if ('string' == typeof locate) return locate;
|
|
41
|
+
if ('object' == typeof locate) {
|
|
42
|
+
if ('object' == typeof locate.prompt && null !== locate.prompt && locate.prompt.prompt) {
|
|
43
|
+
const prompt = locate.prompt.prompt;
|
|
44
|
+
return prompt;
|
|
45
|
+
}
|
|
46
|
+
if ('string' == typeof locate.prompt) return locate.prompt;
|
|
47
|
+
if ('string' == typeof locate.description) return locate.description;
|
|
48
|
+
}
|
|
49
|
+
return '';
|
|
50
|
+
}
|
|
51
|
+
function scrollParamStr(scrollParam) {
|
|
52
|
+
if (!scrollParam) return '';
|
|
53
|
+
return `${scrollParam.direction || 'down'}, ${scrollParam.scrollType || 'singleAction'}, ${scrollParam.distance || 'distance-not-set'}`;
|
|
54
|
+
}
|
|
55
|
+
function pullParamStr(pullParam) {
|
|
56
|
+
if (!pullParam) return '';
|
|
57
|
+
const parts = [];
|
|
58
|
+
parts.push(`direction: ${pullParam.direction || 'down'}`);
|
|
59
|
+
if (pullParam.distance) parts.push(`distance: ${pullParam.distance}`);
|
|
60
|
+
if (pullParam.duration) parts.push(`duration: ${pullParam.duration}ms`);
|
|
61
|
+
return parts.join(', ');
|
|
62
|
+
}
|
|
63
|
+
function extractInsightParam(taskParam) {
|
|
64
|
+
if (!taskParam) return {
|
|
65
|
+
content: ''
|
|
66
|
+
};
|
|
67
|
+
const extractImages = (source)=>source?.multimodalPrompt?.images && Array.isArray(source.multimodalPrompt.images) ? source.multimodalPrompt.images : void 0;
|
|
68
|
+
const toContent = (value)=>'string' == typeof value ? value : JSON.stringify(value);
|
|
69
|
+
if (taskParam.demand) return {
|
|
70
|
+
content: toContent(taskParam.demand),
|
|
71
|
+
images: extractImages(taskParam)
|
|
72
|
+
};
|
|
73
|
+
if (taskParam.assertion) return {
|
|
74
|
+
content: toContent(taskParam.assertion),
|
|
75
|
+
images: extractImages(taskParam)
|
|
76
|
+
};
|
|
77
|
+
if (taskParam.dataDemand) {
|
|
78
|
+
const { dataDemand } = taskParam;
|
|
79
|
+
if ('string' == typeof dataDemand) return {
|
|
80
|
+
content: dataDemand
|
|
81
|
+
};
|
|
82
|
+
if ('object' == typeof dataDemand) return {
|
|
83
|
+
content: toContent(dataDemand.demand || dataDemand),
|
|
84
|
+
images: extractImages(dataDemand)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
content: ''
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function taskTitleStr(type, prompt) {
|
|
92
|
+
if (prompt) return `${type} - ${prompt}`;
|
|
93
|
+
return type;
|
|
94
|
+
}
|
|
95
|
+
function paramStr(task) {
|
|
96
|
+
let value;
|
|
97
|
+
if ('Planning' === task.type) if ('Locate' === task.subType) value = locateParamStr(task?.param);
|
|
98
|
+
else {
|
|
99
|
+
const planTask = task;
|
|
100
|
+
value = planTask.output?.log || planTask.param?.userInstruction;
|
|
101
|
+
}
|
|
102
|
+
if ('Insight' === task.type) value = extractInsightParam(task?.param).content;
|
|
103
|
+
if ('Action Space' === task.type) {
|
|
104
|
+
const locate = task?.param?.locate;
|
|
105
|
+
const locateStr = locate ? locateParamStr(locate) : '';
|
|
106
|
+
value = task.thought || '';
|
|
107
|
+
if ('number' == typeof task?.param?.timeMs) value = `${task?.param?.timeMs}ms`;
|
|
108
|
+
else if ('string' == typeof task?.param?.scrollType) value = scrollParamStr(task?.param);
|
|
109
|
+
else if ('string' == typeof task?.param?.direction && task?.subType === 'PullGesture') value = pullParamStr(task?.param);
|
|
110
|
+
else if (void 0 !== task?.param?.value) value = task?.param?.value;
|
|
111
|
+
else if (task?.param && 'object' == typeof task?.param && Object.keys(task?.param || {}).length > 0) value = task?.param;
|
|
112
|
+
if (locateStr) value = value && 'object' != typeof value ? `${locateStr} - ${value}` : locateStr;
|
|
113
|
+
}
|
|
114
|
+
if (void 0 === value) return '';
|
|
115
|
+
if ('string' == typeof value) return value;
|
|
116
|
+
if ('object' == typeof value) {
|
|
117
|
+
const locateStr = locateParamStr(value);
|
|
118
|
+
if (locateStr) return locateStr;
|
|
119
|
+
const entries = Object.entries(value);
|
|
120
|
+
if (0 === entries.length) return '';
|
|
121
|
+
const formatValue = (v)=>{
|
|
122
|
+
if ('string' == typeof v) return v;
|
|
123
|
+
if (null == v) return String(v);
|
|
124
|
+
if ('object' == typeof v) return JSON.stringify(v);
|
|
125
|
+
return String(v);
|
|
126
|
+
};
|
|
127
|
+
if (1 === entries.length) {
|
|
128
|
+
const [key, v] = entries[0];
|
|
129
|
+
return `${key}: ${formatValue(v)}`;
|
|
130
|
+
}
|
|
131
|
+
return entries.map(([key, v])=>`${key}: ${formatValue(v)}`).join(', ');
|
|
132
|
+
}
|
|
133
|
+
return String(value);
|
|
134
|
+
}
|
|
135
|
+
exports.extractInsightParam = __webpack_exports__.extractInsightParam;
|
|
136
|
+
exports.locateParamStr = __webpack_exports__.locateParamStr;
|
|
137
|
+
exports.paramStr = __webpack_exports__.paramStr;
|
|
138
|
+
exports.pullParamStr = __webpack_exports__.pullParamStr;
|
|
139
|
+
exports.scrollParamStr = __webpack_exports__.scrollParamStr;
|
|
140
|
+
exports.taskTitleStr = __webpack_exports__.taskTitleStr;
|
|
141
|
+
exports.typeStr = __webpack_exports__.typeStr;
|
|
142
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
143
|
+
"extractInsightParam",
|
|
144
|
+
"locateParamStr",
|
|
145
|
+
"paramStr",
|
|
146
|
+
"pullParamStr",
|
|
147
|
+
"scrollParamStr",
|
|
148
|
+
"taskTitleStr",
|
|
149
|
+
"typeStr"
|
|
150
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
151
|
+
Object.defineProperty(exports, '__esModule', {
|
|
152
|
+
value: true
|
|
153
|
+
});
|