@modelnex/sdk 0.5.46 → 0.5.47
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/index.js +76 -3
- package/dist/index.mjs +76 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4732,6 +4732,13 @@ function useTourPlayback({
|
|
|
4732
4732
|
},
|
|
4733
4733
|
resolve: async () => {
|
|
4734
4734
|
let targetEl = null;
|
|
4735
|
+
if (typeof params.selector === "string" && params.selector.trim()) {
|
|
4736
|
+
try {
|
|
4737
|
+
targetEl = document.querySelector(params.selector.trim());
|
|
4738
|
+
} catch {
|
|
4739
|
+
targetEl = null;
|
|
4740
|
+
}
|
|
4741
|
+
}
|
|
4735
4742
|
if (params.uid) {
|
|
4736
4743
|
const { getElementByUid: getElementByUid2 } = await Promise.resolve().then(() => (init_aom(), aom_exports));
|
|
4737
4744
|
targetEl = getElementByUid2(params.uid);
|
|
@@ -4876,6 +4883,49 @@ function useTourPlayback({
|
|
|
4876
4883
|
const resolution = typeof action.params?.resolution === "string" ? action.params.resolution : void 0;
|
|
4877
4884
|
return { result: await captureScreenshot(selector, resolution) };
|
|
4878
4885
|
}
|
|
4886
|
+
if (action.type === "get_ui_messages") {
|
|
4887
|
+
const includeHidden = action.params?.includeHidden === true;
|
|
4888
|
+
const maxItems = Number.isFinite(action.params?.maxItems) ? Number(action.params.maxItems) : void 0;
|
|
4889
|
+
const messages = collectUiMessages({ includeHidden, maxItems });
|
|
4890
|
+
return {
|
|
4891
|
+
result: {
|
|
4892
|
+
messages,
|
|
4893
|
+
total: messages.length,
|
|
4894
|
+
capturedAt: Date.now()
|
|
4895
|
+
}
|
|
4896
|
+
};
|
|
4897
|
+
}
|
|
4898
|
+
if (action.type === "get_last_action_effect") {
|
|
4899
|
+
return {
|
|
4900
|
+
result: {
|
|
4901
|
+
effect: getLastActionEffectRecord()
|
|
4902
|
+
}
|
|
4903
|
+
};
|
|
4904
|
+
}
|
|
4905
|
+
if (action.type === "inspect_element_state") {
|
|
4906
|
+
const targetEl = await resolveTargetElement2(action.params, currentStep);
|
|
4907
|
+
if (!targetEl) {
|
|
4908
|
+
return {
|
|
4909
|
+
success: false,
|
|
4910
|
+
result: {
|
|
4911
|
+
found: false,
|
|
4912
|
+
reason: "Element not found from the provided fingerprint, selector, uid, or text hint."
|
|
4913
|
+
},
|
|
4914
|
+
error: "inspect_element_not_found"
|
|
4915
|
+
};
|
|
4916
|
+
}
|
|
4917
|
+
const resolvedVia = typeof action.params?.selector === "string" && action.params.selector.trim() ? "selector" : action.params?.uid ? "uid" : action.params?.fingerprint ? "fingerprint" : action.params?.textContaining ? "textContaining" : "fallback";
|
|
4918
|
+
return {
|
|
4919
|
+
result: {
|
|
4920
|
+
found: true,
|
|
4921
|
+
target: {
|
|
4922
|
+
fingerprint: targetEl.getAttribute("data-modelnex-fp") || null,
|
|
4923
|
+
resolvedVia
|
|
4924
|
+
},
|
|
4925
|
+
element: inspectDomElementState(targetEl)
|
|
4926
|
+
}
|
|
4927
|
+
};
|
|
4928
|
+
}
|
|
4879
4929
|
if (action.type === "navigate_to_url") {
|
|
4880
4930
|
const nextUrl = typeof action.params?.url === "string" ? action.params.url : "";
|
|
4881
4931
|
if (!nextUrl) {
|
|
@@ -4928,8 +4978,13 @@ function useTourPlayback({
|
|
|
4928
4978
|
handleTourEnd();
|
|
4929
4979
|
return { result: "ended" };
|
|
4930
4980
|
}
|
|
4931
|
-
|
|
4932
|
-
|
|
4981
|
+
const unknownAction = String(action?.type ?? "unknown");
|
|
4982
|
+
console.warn(`[TourClient] Unknown action type: ${unknownAction}. Skipping.`);
|
|
4983
|
+
return {
|
|
4984
|
+
success: false,
|
|
4985
|
+
result: "unknown_action_skipped",
|
|
4986
|
+
error: `Unknown action type: ${unknownAction}`
|
|
4987
|
+
};
|
|
4933
4988
|
};
|
|
4934
4989
|
try {
|
|
4935
4990
|
const resultsBuffer = new Array(payload.commands.length);
|
|
@@ -4943,9 +4998,27 @@ function useTourPlayback({
|
|
|
4943
4998
|
pendingUIActions.length = 0;
|
|
4944
4999
|
}
|
|
4945
5000
|
const executionPromise = (async () => {
|
|
5001
|
+
const beforeSnapshot = captureDebugSnapshot();
|
|
5002
|
+
const startedAt = Date.now();
|
|
4946
5003
|
const execution = await executeOne(command);
|
|
4947
5004
|
await execution.settlePromise;
|
|
4948
|
-
|
|
5005
|
+
const success = execution.success !== false;
|
|
5006
|
+
const error = typeof execution.error === "string" ? execution.error : null;
|
|
5007
|
+
recordLastActionEffect({
|
|
5008
|
+
actionId: command.type,
|
|
5009
|
+
success,
|
|
5010
|
+
error,
|
|
5011
|
+
startedAt,
|
|
5012
|
+
finishedAt: Date.now(),
|
|
5013
|
+
before: beforeSnapshot,
|
|
5014
|
+
after: captureDebugSnapshot()
|
|
5015
|
+
});
|
|
5016
|
+
resultsBuffer[commandIndex] = {
|
|
5017
|
+
type: command.type,
|
|
5018
|
+
success,
|
|
5019
|
+
result: execution.result,
|
|
5020
|
+
...error ? { error } : {}
|
|
5021
|
+
};
|
|
4949
5022
|
})();
|
|
4950
5023
|
if (isTerminal) {
|
|
4951
5024
|
await executionPromise;
|
package/dist/index.mjs
CHANGED
|
@@ -3903,6 +3903,13 @@ function useTourPlayback({
|
|
|
3903
3903
|
},
|
|
3904
3904
|
resolve: async () => {
|
|
3905
3905
|
let targetEl = null;
|
|
3906
|
+
if (typeof params.selector === "string" && params.selector.trim()) {
|
|
3907
|
+
try {
|
|
3908
|
+
targetEl = document.querySelector(params.selector.trim());
|
|
3909
|
+
} catch {
|
|
3910
|
+
targetEl = null;
|
|
3911
|
+
}
|
|
3912
|
+
}
|
|
3906
3913
|
if (params.uid) {
|
|
3907
3914
|
const { getElementByUid } = await import("./aom-SP2LMWQI.mjs");
|
|
3908
3915
|
targetEl = getElementByUid(params.uid);
|
|
@@ -4047,6 +4054,49 @@ function useTourPlayback({
|
|
|
4047
4054
|
const resolution = typeof action.params?.resolution === "string" ? action.params.resolution : void 0;
|
|
4048
4055
|
return { result: await captureScreenshot(selector, resolution) };
|
|
4049
4056
|
}
|
|
4057
|
+
if (action.type === "get_ui_messages") {
|
|
4058
|
+
const includeHidden = action.params?.includeHidden === true;
|
|
4059
|
+
const maxItems = Number.isFinite(action.params?.maxItems) ? Number(action.params.maxItems) : void 0;
|
|
4060
|
+
const messages = collectUiMessages({ includeHidden, maxItems });
|
|
4061
|
+
return {
|
|
4062
|
+
result: {
|
|
4063
|
+
messages,
|
|
4064
|
+
total: messages.length,
|
|
4065
|
+
capturedAt: Date.now()
|
|
4066
|
+
}
|
|
4067
|
+
};
|
|
4068
|
+
}
|
|
4069
|
+
if (action.type === "get_last_action_effect") {
|
|
4070
|
+
return {
|
|
4071
|
+
result: {
|
|
4072
|
+
effect: getLastActionEffectRecord()
|
|
4073
|
+
}
|
|
4074
|
+
};
|
|
4075
|
+
}
|
|
4076
|
+
if (action.type === "inspect_element_state") {
|
|
4077
|
+
const targetEl = await resolveTargetElement2(action.params, currentStep);
|
|
4078
|
+
if (!targetEl) {
|
|
4079
|
+
return {
|
|
4080
|
+
success: false,
|
|
4081
|
+
result: {
|
|
4082
|
+
found: false,
|
|
4083
|
+
reason: "Element not found from the provided fingerprint, selector, uid, or text hint."
|
|
4084
|
+
},
|
|
4085
|
+
error: "inspect_element_not_found"
|
|
4086
|
+
};
|
|
4087
|
+
}
|
|
4088
|
+
const resolvedVia = typeof action.params?.selector === "string" && action.params.selector.trim() ? "selector" : action.params?.uid ? "uid" : action.params?.fingerprint ? "fingerprint" : action.params?.textContaining ? "textContaining" : "fallback";
|
|
4089
|
+
return {
|
|
4090
|
+
result: {
|
|
4091
|
+
found: true,
|
|
4092
|
+
target: {
|
|
4093
|
+
fingerprint: targetEl.getAttribute("data-modelnex-fp") || null,
|
|
4094
|
+
resolvedVia
|
|
4095
|
+
},
|
|
4096
|
+
element: inspectDomElementState(targetEl)
|
|
4097
|
+
}
|
|
4098
|
+
};
|
|
4099
|
+
}
|
|
4050
4100
|
if (action.type === "navigate_to_url") {
|
|
4051
4101
|
const nextUrl = typeof action.params?.url === "string" ? action.params.url : "";
|
|
4052
4102
|
if (!nextUrl) {
|
|
@@ -4099,8 +4149,13 @@ function useTourPlayback({
|
|
|
4099
4149
|
handleTourEnd();
|
|
4100
4150
|
return { result: "ended" };
|
|
4101
4151
|
}
|
|
4102
|
-
|
|
4103
|
-
|
|
4152
|
+
const unknownAction = String(action?.type ?? "unknown");
|
|
4153
|
+
console.warn(`[TourClient] Unknown action type: ${unknownAction}. Skipping.`);
|
|
4154
|
+
return {
|
|
4155
|
+
success: false,
|
|
4156
|
+
result: "unknown_action_skipped",
|
|
4157
|
+
error: `Unknown action type: ${unknownAction}`
|
|
4158
|
+
};
|
|
4104
4159
|
};
|
|
4105
4160
|
try {
|
|
4106
4161
|
const resultsBuffer = new Array(payload.commands.length);
|
|
@@ -4114,9 +4169,27 @@ function useTourPlayback({
|
|
|
4114
4169
|
pendingUIActions.length = 0;
|
|
4115
4170
|
}
|
|
4116
4171
|
const executionPromise = (async () => {
|
|
4172
|
+
const beforeSnapshot = captureDebugSnapshot();
|
|
4173
|
+
const startedAt = Date.now();
|
|
4117
4174
|
const execution = await executeOne(command);
|
|
4118
4175
|
await execution.settlePromise;
|
|
4119
|
-
|
|
4176
|
+
const success = execution.success !== false;
|
|
4177
|
+
const error = typeof execution.error === "string" ? execution.error : null;
|
|
4178
|
+
recordLastActionEffect({
|
|
4179
|
+
actionId: command.type,
|
|
4180
|
+
success,
|
|
4181
|
+
error,
|
|
4182
|
+
startedAt,
|
|
4183
|
+
finishedAt: Date.now(),
|
|
4184
|
+
before: beforeSnapshot,
|
|
4185
|
+
after: captureDebugSnapshot()
|
|
4186
|
+
});
|
|
4187
|
+
resultsBuffer[commandIndex] = {
|
|
4188
|
+
type: command.type,
|
|
4189
|
+
success,
|
|
4190
|
+
result: execution.result,
|
|
4191
|
+
...error ? { error } : {}
|
|
4192
|
+
};
|
|
4120
4193
|
})();
|
|
4121
4194
|
if (isTerminal) {
|
|
4122
4195
|
await executionPromise;
|