@godscene/visualizer 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.
Files changed (221) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -0
  3. package/dist/es/component/blackboard/highlights.mjs +47 -0
  4. package/dist/es/component/blackboard/index.css +118 -0
  5. package/dist/es/component/blackboard/index.mjs +122 -0
  6. package/dist/es/component/config-selector/index.mjs +251 -0
  7. package/dist/es/component/context-preview/index.mjs +37 -0
  8. package/dist/es/component/env-config/index.mjs +237 -0
  9. package/dist/es/component/env-config-reminder/index.css +30 -0
  10. package/dist/es/component/env-config-reminder/index.mjs +27 -0
  11. package/dist/es/component/form-field/index.mjs +158 -0
  12. package/dist/es/component/history-selector/index.css +237 -0
  13. package/dist/es/component/history-selector/index.mjs +197 -0
  14. package/dist/es/component/index.mjs +1 -0
  15. package/dist/es/component/logo/index.css +19 -0
  16. package/dist/es/component/logo/index.mjs +20 -0
  17. package/dist/es/component/logo/logo.mjs +2 -0
  18. package/dist/es/component/misc/index.mjs +96 -0
  19. package/dist/es/component/nav-actions/index.mjs +14 -0
  20. package/dist/es/component/nav-actions/style.css +35 -0
  21. package/dist/es/component/player/index.css +296 -0
  22. package/dist/es/component/player/index.mjs +702 -0
  23. package/dist/es/component/player/playback-controls.mjs +4 -0
  24. package/dist/es/component/player/report-download.mjs +61 -0
  25. package/dist/es/component/player/scenes/StepScene.mjs +194 -0
  26. package/dist/es/component/player/scenes/derive-frame-state.mjs +229 -0
  27. package/dist/es/component/player/scenes/export-branded-video.mjs +360 -0
  28. package/dist/es/component/player/scenes/frame-calculator.mjs +149 -0
  29. package/dist/es/component/player/scenes/playback-frame.mjs +6 -0
  30. package/dist/es/component/player/scenes/playback-layout.mjs +12 -0
  31. package/dist/es/component/player/scenes/pointer-layout.mjs +36 -0
  32. package/dist/es/component/player/use-frame-player.mjs +87 -0
  33. package/dist/es/component/playground/index.css +930 -0
  34. package/dist/es/component/playground/playground-demo-ui-context.json +290 -0
  35. package/dist/es/component/playground-result/index.css +92 -0
  36. package/dist/es/component/playground-result/index.mjs +232 -0
  37. package/dist/es/component/prompt-input/index.css +832 -0
  38. package/dist/es/component/prompt-input/index.mjs +959 -0
  39. package/dist/es/component/screenshot-viewer/index.css +237 -0
  40. package/dist/es/component/screenshot-viewer/index.mjs +319 -0
  41. package/dist/es/component/service-mode-control/index.mjs +107 -0
  42. package/dist/es/component/shiny-text/index.css +107 -0
  43. package/dist/es/component/shiny-text/index.mjs +15 -0
  44. package/dist/es/component/universal-playground/empty-state.mjs +5 -0
  45. package/dist/es/component/universal-playground/index.css +619 -0
  46. package/dist/es/component/universal-playground/index.mjs +558 -0
  47. package/dist/es/component/universal-playground/providers/context-provider.mjs +90 -0
  48. package/dist/es/component/universal-playground/providers/indexeddb-storage-provider.mjs +280 -0
  49. package/dist/es/component/universal-playground/providers/storage-provider.mjs +279 -0
  50. package/dist/es/component/universal-playground/universal-playground-electron.mjs +668 -0
  51. package/dist/es/hooks/useMinimalTypeGate.mjs +47 -0
  52. package/dist/es/hooks/usePlaygroundExecution.mjs +435 -0
  53. package/dist/es/hooks/usePlaygroundState.mjs +278 -0
  54. package/dist/es/hooks/useSafeOverrideAIConfig.mjs +20 -0
  55. package/dist/es/hooks/useServerValid.mjs +55 -0
  56. package/dist/es/hooks/useTheme.mjs +25 -0
  57. package/dist/es/icons/action-chevron.mjs +61 -0
  58. package/dist/es/icons/avatar.mjs +70 -0
  59. package/dist/es/icons/close.mjs +61 -0
  60. package/dist/es/icons/global-perspective.mjs +58 -0
  61. package/dist/es/icons/history.mjs +72 -0
  62. package/dist/es/icons/magnifying-glass.mjs +81 -0
  63. package/dist/es/icons/player-setting.mjs +68 -0
  64. package/dist/es/icons/prompt-history.mjs +70 -0
  65. package/dist/es/icons/setting.mjs +62 -0
  66. package/dist/es/icons/show-marker.mjs +58 -0
  67. package/dist/es/index.mjs +26 -0
  68. package/dist/es/static/image/logo.png +0 -0
  69. package/dist/es/store/history.mjs +128 -0
  70. package/dist/es/store/store.mjs +277 -0
  71. package/dist/es/types.mjs +73 -0
  72. package/dist/es/utils/action-label.mjs +15 -0
  73. package/dist/es/utils/color.mjs +35 -0
  74. package/dist/es/utils/constants.mjs +99 -0
  75. package/dist/es/utils/device-capabilities.mjs +13 -0
  76. package/dist/es/utils/empty-state-scroll.mjs +8 -0
  77. package/dist/es/utils/highlight-element.mjs +62 -0
  78. package/dist/es/utils/index.mjs +13 -0
  79. package/dist/es/utils/playground-utils.mjs +43 -0
  80. package/dist/es/utils/progress-action-icon.mjs +30 -0
  81. package/dist/es/utils/prompt-input-utils.mjs +49 -0
  82. package/dist/es/utils/prompt-placeholder.mjs +19 -0
  83. package/dist/es/utils/replay-scripts.mjs +428 -0
  84. package/dist/lib/component/blackboard/highlights.js +84 -0
  85. package/dist/lib/component/blackboard/index.css +118 -0
  86. package/dist/lib/component/blackboard/index.js +169 -0
  87. package/dist/lib/component/config-selector/index.js +295 -0
  88. package/dist/lib/component/context-preview/index.js +82 -0
  89. package/dist/lib/component/env-config/index.js +271 -0
  90. package/dist/lib/component/env-config-reminder/index.css +30 -0
  91. package/dist/lib/component/env-config-reminder/index.js +61 -0
  92. package/dist/lib/component/form-field/index.js +204 -0
  93. package/dist/lib/component/history-selector/index.css +237 -0
  94. package/dist/lib/component/history-selector/index.js +243 -0
  95. package/dist/lib/component/index.js +58 -0
  96. package/dist/lib/component/logo/index.css +19 -0
  97. package/dist/lib/component/logo/index.js +67 -0
  98. package/dist/lib/component/logo/logo.js +24 -0
  99. package/dist/lib/component/misc/index.js +152 -0
  100. package/dist/lib/component/nav-actions/index.js +48 -0
  101. package/dist/lib/component/nav-actions/style.css +35 -0
  102. package/dist/lib/component/player/index.css +296 -0
  103. package/dist/lib/component/player/index.js +747 -0
  104. package/dist/lib/component/player/playback-controls.js +38 -0
  105. package/dist/lib/component/player/report-download.js +98 -0
  106. package/dist/lib/component/player/scenes/StepScene.js +228 -0
  107. package/dist/lib/component/player/scenes/derive-frame-state.js +266 -0
  108. package/dist/lib/component/player/scenes/export-branded-video.js +403 -0
  109. package/dist/lib/component/player/scenes/frame-calculator.js +186 -0
  110. package/dist/lib/component/player/scenes/playback-frame.js +40 -0
  111. package/dist/lib/component/player/scenes/playback-layout.js +46 -0
  112. package/dist/lib/component/player/scenes/pointer-layout.js +88 -0
  113. package/dist/lib/component/player/use-frame-player.js +121 -0
  114. package/dist/lib/component/playground/index.css +930 -0
  115. package/dist/lib/component/playground/playground-demo-ui-context.json +290 -0
  116. package/dist/lib/component/playground-result/index.css +92 -0
  117. package/dist/lib/component/playground-result/index.js +276 -0
  118. package/dist/lib/component/prompt-input/index.css +832 -0
  119. package/dist/lib/component/prompt-input/index.js +1005 -0
  120. package/dist/lib/component/screenshot-viewer/index.css +237 -0
  121. package/dist/lib/component/screenshot-viewer/index.js +353 -0
  122. package/dist/lib/component/service-mode-control/index.js +141 -0
  123. package/dist/lib/component/shiny-text/index.css +107 -0
  124. package/dist/lib/component/shiny-text/index.js +49 -0
  125. package/dist/lib/component/universal-playground/empty-state.js +39 -0
  126. package/dist/lib/component/universal-playground/index.css +619 -0
  127. package/dist/lib/component/universal-playground/index.js +607 -0
  128. package/dist/lib/component/universal-playground/providers/context-provider.js +133 -0
  129. package/dist/lib/component/universal-playground/providers/indexeddb-storage-provider.js +320 -0
  130. package/dist/lib/component/universal-playground/providers/storage-provider.js +337 -0
  131. package/dist/lib/component/universal-playground/universal-playground-electron.js +717 -0
  132. package/dist/lib/hooks/useMinimalTypeGate.js +81 -0
  133. package/dist/lib/hooks/usePlaygroundExecution.js +478 -0
  134. package/dist/lib/hooks/usePlaygroundState.js +312 -0
  135. package/dist/lib/hooks/useSafeOverrideAIConfig.js +57 -0
  136. package/dist/lib/hooks/useServerValid.js +89 -0
  137. package/dist/lib/hooks/useTheme.js +59 -0
  138. package/dist/lib/icons/action-chevron.js +95 -0
  139. package/dist/lib/icons/avatar.js +104 -0
  140. package/dist/lib/icons/close.js +95 -0
  141. package/dist/lib/icons/global-perspective.js +92 -0
  142. package/dist/lib/icons/history.js +106 -0
  143. package/dist/lib/icons/magnifying-glass.js +115 -0
  144. package/dist/lib/icons/player-setting.js +102 -0
  145. package/dist/lib/icons/prompt-history.js +104 -0
  146. package/dist/lib/icons/setting.js +96 -0
  147. package/dist/lib/icons/show-marker.js +92 -0
  148. package/dist/lib/index.js +204 -0
  149. package/dist/lib/static/image/logo.png +0 -0
  150. package/dist/lib/store/history.js +135 -0
  151. package/dist/lib/store/store.js +287 -0
  152. package/dist/lib/types.js +119 -0
  153. package/dist/lib/utils/action-label.js +52 -0
  154. package/dist/lib/utils/color.js +75 -0
  155. package/dist/lib/utils/constants.js +172 -0
  156. package/dist/lib/utils/device-capabilities.js +50 -0
  157. package/dist/lib/utils/empty-state-scroll.js +42 -0
  158. package/dist/lib/utils/highlight-element.js +99 -0
  159. package/dist/lib/utils/index.js +69 -0
  160. package/dist/lib/utils/playground-utils.js +86 -0
  161. package/dist/lib/utils/progress-action-icon.js +67 -0
  162. package/dist/lib/utils/prompt-input-utils.js +89 -0
  163. package/dist/lib/utils/prompt-placeholder.js +53 -0
  164. package/dist/lib/utils/replay-scripts.js +474 -0
  165. package/dist/types/component/blackboard/highlights.d.ts +11 -0
  166. package/dist/types/component/blackboard/index.d.ts +10 -0
  167. package/dist/types/component/config-selector/index.d.ts +15 -0
  168. package/dist/types/component/context-preview/index.d.ts +9 -0
  169. package/dist/types/component/env-config/index.d.ts +8 -0
  170. package/dist/types/component/env-config-reminder/index.d.ts +6 -0
  171. package/dist/types/component/form-field/index.d.ts +17 -0
  172. package/dist/types/component/history-selector/index.d.ts +13 -0
  173. package/dist/types/component/index.d.ts +1 -0
  174. package/dist/types/component/logo/index.d.ts +5 -0
  175. package/dist/types/component/misc/index.d.ts +6 -0
  176. package/dist/types/component/nav-actions/index.d.ts +12 -0
  177. package/dist/types/component/player/index.d.ts +15 -0
  178. package/dist/types/component/player/playback-controls.d.ts +1 -0
  179. package/dist/types/component/player/report-download.d.ts +32 -0
  180. package/dist/types/component/player/scenes/StepScene.d.ts +9 -0
  181. package/dist/types/component/player/scenes/derive-frame-state.d.ts +40 -0
  182. package/dist/types/component/player/scenes/export-branded-video.d.ts +33 -0
  183. package/dist/types/component/player/scenes/frame-calculator.d.ts +40 -0
  184. package/dist/types/component/player/scenes/playback-frame.d.ts +3 -0
  185. package/dist/types/component/player/scenes/playback-layout.d.ts +7 -0
  186. package/dist/types/component/player/scenes/pointer-layout.d.ts +20 -0
  187. package/dist/types/component/player/use-frame-player.d.ts +17 -0
  188. package/dist/types/component/playground-result/index.d.ts +22 -0
  189. package/dist/types/component/prompt-input/index.d.ts +23 -0
  190. package/dist/types/component/screenshot-viewer/index.d.ts +23 -0
  191. package/dist/types/component/service-mode-control/index.d.ts +6 -0
  192. package/dist/types/component/shiny-text/index.d.ts +12 -0
  193. package/dist/types/component/universal-playground/empty-state.d.ts +3 -0
  194. package/dist/types/component/universal-playground/index.d.ts +4 -0
  195. package/dist/types/component/universal-playground/providers/context-provider.d.ts +37 -0
  196. package/dist/types/component/universal-playground/providers/indexeddb-storage-provider.d.ts +71 -0
  197. package/dist/types/component/universal-playground/providers/storage-provider.d.ts +58 -0
  198. package/dist/types/component/universal-playground/universal-playground-electron.d.ts +4 -0
  199. package/dist/types/hooks/useMinimalTypeGate.d.ts +72 -0
  200. package/dist/types/hooks/usePlaygroundExecution.d.ts +40 -0
  201. package/dist/types/hooks/usePlaygroundState.d.ts +26 -0
  202. package/dist/types/hooks/useSafeOverrideAIConfig.d.ts +16 -0
  203. package/dist/types/hooks/useServerValid.d.ts +1 -0
  204. package/dist/types/hooks/useTheme.d.ts +7 -0
  205. package/dist/types/index.d.ts +29 -0
  206. package/dist/types/store/history.d.ts +16 -0
  207. package/dist/types/store/store.d.ts +57 -0
  208. package/dist/types/types.d.ts +278 -0
  209. package/dist/types/utils/action-label.d.ts +11 -0
  210. package/dist/types/utils/color.d.ts +4 -0
  211. package/dist/types/utils/constants.d.ts +80 -0
  212. package/dist/types/utils/device-capabilities.d.ts +9 -0
  213. package/dist/types/utils/empty-state-scroll.d.ts +11 -0
  214. package/dist/types/utils/highlight-element.d.ts +3 -0
  215. package/dist/types/utils/index.d.ts +5 -0
  216. package/dist/types/utils/playground-utils.d.ts +11 -0
  217. package/dist/types/utils/progress-action-icon.d.ts +12 -0
  218. package/dist/types/utils/prompt-input-utils.d.ts +24 -0
  219. package/dist/types/utils/prompt-placeholder.d.ts +1 -0
  220. package/dist/types/utils/replay-scripts.d.ts +50 -0
  221. package/package.json +82 -0
@@ -0,0 +1,81 @@
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
+ useMinimalTypeGate: ()=>useMinimalTypeGate
28
+ });
29
+ const external_react_namespaceObject = require("react");
30
+ function useMinimalTypeGate(options) {
31
+ const { enabled, form, selectedType, onAfterReset, defaultType = 'aiAct' } = options;
32
+ const [hasExplicitSelection, setHasExplicitSelection] = (0, external_react_namespaceObject.useState)(false);
33
+ const skipNextRestoreRef = (0, external_react_namespaceObject.useRef)(false);
34
+ (0, external_react_namespaceObject.useEffect)(()=>{
35
+ if (!enabled || hasExplicitSelection || !selectedType || selectedType === defaultType) return;
36
+ skipNextRestoreRef.current = false;
37
+ form.setFieldsValue({
38
+ type: defaultType,
39
+ prompt: '',
40
+ params: {}
41
+ });
42
+ null == onAfterReset || onAfterReset();
43
+ }, [
44
+ enabled,
45
+ hasExplicitSelection,
46
+ selectedType,
47
+ defaultType,
48
+ form,
49
+ onAfterReset
50
+ ]);
51
+ const markExplicitSelection = (0, external_react_namespaceObject.useCallback)(()=>{
52
+ if (!enabled) return;
53
+ setHasExplicitSelection(true);
54
+ }, [
55
+ enabled
56
+ ]);
57
+ const skipNextRestore = (0, external_react_namespaceObject.useCallback)(()=>{
58
+ skipNextRestoreRef.current = true;
59
+ }, []);
60
+ const shouldSkipRestoreOnce = (0, external_react_namespaceObject.useCallback)(()=>{
61
+ if (!skipNextRestoreRef.current) return false;
62
+ skipNextRestoreRef.current = false;
63
+ return true;
64
+ }, []);
65
+ return (0, external_react_namespaceObject.useMemo)(()=>({
66
+ markExplicitSelection,
67
+ skipNextRestore,
68
+ shouldSkipRestoreOnce
69
+ }), [
70
+ markExplicitSelection,
71
+ skipNextRestore,
72
+ shouldSkipRestoreOnce
73
+ ]);
74
+ }
75
+ exports.useMinimalTypeGate = __webpack_exports__.useMinimalTypeGate;
76
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
77
+ "useMinimalTypeGate"
78
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
79
+ Object.defineProperty(exports, '__esModule', {
80
+ value: true
81
+ });
@@ -0,0 +1,478 @@
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
+ buildProgressContent: ()=>buildProgressContent,
28
+ formatError: ()=>formatError,
29
+ usePlaygroundExecution: ()=>usePlaygroundExecution,
30
+ wrapExecutionDumpForReplay: ()=>wrapExecutionDumpForReplay
31
+ });
32
+ const agent_namespaceObject = require("@godscene/core/agent");
33
+ const external_react_namespaceObject = require("react");
34
+ const store_js_namespaceObject = require("../store/store.js");
35
+ const constants_js_namespaceObject = require("../utils/constants.js");
36
+ const replay_scripts_js_namespaceObject = require("../utils/replay-scripts.js");
37
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
38
+ try {
39
+ var info = gen[key](arg);
40
+ var value = info.value;
41
+ } catch (error) {
42
+ reject(error);
43
+ return;
44
+ }
45
+ if (info.done) resolve(value);
46
+ else Promise.resolve(value).then(_next, _throw);
47
+ }
48
+ function _async_to_generator(fn) {
49
+ return function() {
50
+ var self = this, args = arguments;
51
+ return new Promise(function(resolve, reject) {
52
+ var gen = fn.apply(self, args);
53
+ function _next(value) {
54
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
55
+ }
56
+ function _throw(err) {
57
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
58
+ }
59
+ _next(void 0);
60
+ });
61
+ };
62
+ }
63
+ function _define_property(obj, key, value) {
64
+ if (key in obj) Object.defineProperty(obj, key, {
65
+ value: value,
66
+ enumerable: true,
67
+ configurable: true,
68
+ writable: true
69
+ });
70
+ else obj[key] = value;
71
+ return obj;
72
+ }
73
+ function _object_spread(target) {
74
+ for(var i = 1; i < arguments.length; i++){
75
+ var source = null != arguments[i] ? arguments[i] : {};
76
+ var ownKeys = Object.keys(source);
77
+ if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
78
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
79
+ }));
80
+ ownKeys.forEach(function(key) {
81
+ _define_property(target, key, source[key]);
82
+ });
83
+ }
84
+ return target;
85
+ }
86
+ function usePlaygroundExecution_ownKeys(object, enumerableOnly) {
87
+ var keys = Object.keys(object);
88
+ if (Object.getOwnPropertySymbols) {
89
+ var symbols = Object.getOwnPropertySymbols(object);
90
+ if (enumerableOnly) symbols = symbols.filter(function(sym) {
91
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
92
+ });
93
+ keys.push.apply(keys, symbols);
94
+ }
95
+ return keys;
96
+ }
97
+ function _object_spread_props(target, source) {
98
+ source = null != source ? source : {};
99
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
100
+ else usePlaygroundExecution_ownKeys(Object(source)).forEach(function(key) {
101
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
102
+ });
103
+ return target;
104
+ }
105
+ function formatError(error) {
106
+ var _error_dump;
107
+ if (!error) return '';
108
+ if ('string' == typeof error) return error;
109
+ if (null == error ? void 0 : null == (_error_dump = error.dump) ? void 0 : _error_dump.error) return error.dump.error;
110
+ if (error.message) return String(error.message);
111
+ try {
112
+ return JSON.stringify(error);
113
+ } catch (unused) {
114
+ return String(error);
115
+ }
116
+ }
117
+ function buildProgressContent(task) {
118
+ const action = (0, agent_namespaceObject.typeStr)(task);
119
+ const description = (0, agent_namespaceObject.paramStr)(task);
120
+ return description ? `${action} - ${description}` : action;
121
+ }
122
+ function wrapExecutionDumpForReplay(dump, deviceType) {
123
+ return {
124
+ sdkVersion: '',
125
+ groupName: 'Playground Execution',
126
+ modelBriefs: [],
127
+ executions: [
128
+ dump
129
+ ],
130
+ deviceType
131
+ };
132
+ }
133
+ function usePlaygroundExecution(options) {
134
+ const { playgroundSDK, storage, actionSpace, loading, setLoading, setInfoList, replayCounter, setReplayCounter, verticalMode, currentRunningIdRef, interruptedFlagRef, deviceType } = options;
135
+ const { deepLocate, deepThink, screenshotIncluded, domIncluded, imeStrategy, autoDismissKeyboard, keyboardDismissStrategy, alwaysRefreshScreenInfo } = (0, store_js_namespaceObject.useEnvConfig)();
136
+ const handleRun = (0, external_react_namespaceObject.useCallback)((value)=>_async_to_generator(function*() {
137
+ if (!playgroundSDK) return void console.warn('PlaygroundSDK is not available');
138
+ const thisRunningId = Date.now();
139
+ const actionType = value.type;
140
+ const displayContent = `${value.type}: ${value.prompt || JSON.stringify(value.params)}`;
141
+ const userItem = {
142
+ id: `user-${Date.now()}`,
143
+ type: 'user',
144
+ content: displayContent,
145
+ timestamp: new Date()
146
+ };
147
+ setInfoList((prev)=>[
148
+ ...prev,
149
+ userItem
150
+ ]);
151
+ setLoading(true);
152
+ const result = _object_spread({}, constants_js_namespaceObject.BLANK_RESULT);
153
+ const systemItem = {
154
+ id: `system-${thisRunningId}`,
155
+ type: 'system',
156
+ content: '',
157
+ timestamp: new Date(),
158
+ loading: true,
159
+ loadingProgressText: ''
160
+ };
161
+ setInfoList((prev)=>[
162
+ ...prev,
163
+ systemItem
164
+ ]);
165
+ try {
166
+ currentRunningIdRef.current = thisRunningId;
167
+ interruptedFlagRef.current[thisRunningId] = false;
168
+ if (playgroundSDK.onDumpUpdate) playgroundSDK.onDumpUpdate((_, executionDump)=>{
169
+ var _executionDump_tasks;
170
+ if (interruptedFlagRef.current[thisRunningId] || !(null == executionDump ? void 0 : null == (_executionDump_tasks = executionDump.tasks) ? void 0 : _executionDump_tasks.length)) return;
171
+ const progressItems = executionDump.tasks.map((task, index)=>{
172
+ var _task_timing;
173
+ return {
174
+ id: `progress-${thisRunningId}-task-${index}`,
175
+ type: 'progress',
176
+ content: buildProgressContent(task),
177
+ actionKind: (0, agent_namespaceObject.typeStr)(task),
178
+ timestamp: new Date((null == (_task_timing = task.timing) ? void 0 : _task_timing.start) || Date.now()),
179
+ result: task.error ? {
180
+ error: formatError(task.error),
181
+ result: null
182
+ } : void 0
183
+ };
184
+ });
185
+ setInfoList((prev)=>{
186
+ const systemItemIndex = prev.findIndex((item)=>item.id === `system-${thisRunningId}`);
187
+ if (-1 === systemItemIndex) return prev;
188
+ const listWithoutCurrentProgress = prev.filter((item)=>!('progress' === item.type && item.id.startsWith(`progress-${thisRunningId}-`)));
189
+ return [
190
+ ...listWithoutCurrentProgress.slice(0, systemItemIndex + 1),
191
+ ...progressItems,
192
+ ...listWithoutCurrentProgress.slice(systemItemIndex + 1)
193
+ ];
194
+ });
195
+ });
196
+ if ('aiAct' !== actionType && true === deepThink) console.warn('[Playground] Non-aiAct action will be executed without deepThink. deepThink is only forwarded for aiAct.', {
197
+ actionType,
198
+ requestId: thisRunningId.toString()
199
+ });
200
+ const resolvedDeepThink = 'unset' === deepThink ? void 0 : deepThink;
201
+ const executionOptions = _object_spread_props(_object_spread({
202
+ requestId: thisRunningId.toString(),
203
+ deepLocate
204
+ }, 'aiAct' === actionType && void 0 !== resolvedDeepThink ? {
205
+ deepThink: resolvedDeepThink
206
+ } : {}), {
207
+ screenshotIncluded,
208
+ domIncluded,
209
+ deviceOptions: {
210
+ imeStrategy,
211
+ autoDismissKeyboard,
212
+ keyboardDismissStrategy,
213
+ alwaysRefreshScreenInfo
214
+ }
215
+ });
216
+ result.result = yield playgroundSDK.executeAction(actionType, value, executionOptions);
217
+ if ('object' == typeof result.result && null !== result.result) {
218
+ const resultObj = result.result;
219
+ if (resultObj.dump) result.dump = resultObj.dump;
220
+ if (resultObj.reportHTML) result.reportHTML = resultObj.reportHTML;
221
+ if (resultObj.error) result.error = formatError(resultObj.error);
222
+ if ('result' in resultObj) result.result = resultObj.result;
223
+ }
224
+ } catch (e) {
225
+ result.error = formatError(e);
226
+ console.error('Playground execution error:', e);
227
+ if ('object' == typeof e && null !== e) {
228
+ if (e.dump) result.dump = e.dump;
229
+ if (e.reportHTML) result.reportHTML = e.reportHTML;
230
+ }
231
+ }
232
+ if (interruptedFlagRef.current[thisRunningId]) return;
233
+ setLoading(false);
234
+ currentRunningIdRef.current = null;
235
+ let replayInfo = null;
236
+ let counter = replayCounter;
237
+ if (null == result ? void 0 : result.dump) {
238
+ if (result.dump.tasks && Array.isArray(result.dump.tasks)) {
239
+ const groupedDump = wrapExecutionDumpForReplay(result.dump, deviceType);
240
+ const info = (0, replay_scripts_js_namespaceObject.allScriptsFromDump)(groupedDump);
241
+ setReplayCounter((c)=>c + 1);
242
+ replayInfo = info;
243
+ counter = replayCounter + 1;
244
+ }
245
+ }
246
+ setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` ? _object_spread_props(_object_spread({}, item), {
247
+ content: '',
248
+ loading: false,
249
+ loadingProgressText: ''
250
+ }) : item));
251
+ const resultItem = {
252
+ id: `result-${thisRunningId}`,
253
+ type: 'result',
254
+ content: 'Execution result',
255
+ timestamp: new Date(),
256
+ result: result,
257
+ loading: false,
258
+ replayScriptsInfo: replayInfo,
259
+ replayCounter: counter,
260
+ loadingProgressText: '',
261
+ verticalMode: verticalMode,
262
+ actionType: actionType
263
+ };
264
+ setInfoList((prev)=>[
265
+ ...prev,
266
+ resultItem
267
+ ]);
268
+ if (null == storage ? void 0 : storage.saveResult) try {
269
+ yield storage.saveResult(resultItem.id, resultItem);
270
+ } catch (error) {
271
+ console.error('Failed to save result:', error);
272
+ }
273
+ try {
274
+ console.log('result----', result);
275
+ const { tasks, logTime } = result.dump;
276
+ const end = tasks.at(-1).timing.end;
277
+ const totalTime = end - logTime;
278
+ const list = tasks.map((item)=>({
279
+ type: item.type,
280
+ subType: item.subType,
281
+ cost: item.timing.cost
282
+ }));
283
+ console.log('总耗时:', totalTime);
284
+ console.table(list);
285
+ } catch (error) {
286
+ console.error(error);
287
+ }
288
+ if (result && result.dump && result.dump.tasks) {
289
+ const thisRunningId = Date.now();
290
+ const tasks = result.dump.tasks || [];
291
+ const actionTasks = tasks.map((item, index)=>{
292
+ if ('Action Space' === item.type) {
293
+ var _tasks__param, _tasks_;
294
+ if ('DragAndDrop' === item.subType) {
295
+ var _tasks__param1, _tasks_1, _tasks__param2, _tasks_2;
296
+ const from = (null == (_tasks_1 = tasks[index - 2]) ? void 0 : null == (_tasks__param1 = _tasks_1.param) ? void 0 : _tasks__param1.prompt) || '';
297
+ const to = (null == (_tasks_2 = tasks[index - 1]) ? void 0 : null == (_tasks__param2 = _tasks_2.param) ? void 0 : _tasks__param2.prompt) || '';
298
+ return _object_spread_props(_object_spread({}, item), {
299
+ param: _object_spread_props(_object_spread({}, item.param), {
300
+ from: _object_spread_props(_object_spread({}, item.param.from), {
301
+ locateDescription: from
302
+ }),
303
+ to: _object_spread_props(_object_spread({}, item.param.to), {
304
+ locateDescription: to
305
+ })
306
+ }),
307
+ output: _object_spread_props(_object_spread({}, item.output), {
308
+ param: _object_spread_props(_object_spread({}, item.output.param), {
309
+ from: _object_spread_props(_object_spread({}, item.output.param.from), {
310
+ locateDescription: from
311
+ }),
312
+ to: _object_spread_props(_object_spread({}, item.output.param.to), {
313
+ locateDescription: to
314
+ })
315
+ })
316
+ })
317
+ });
318
+ }
319
+ return _object_spread_props(_object_spread({}, item), {
320
+ locateDescription: (null == (_tasks_ = tasks[index - 1]) ? void 0 : null == (_tasks__param = _tasks_.param) ? void 0 : _tasks__param.prompt) || ''
321
+ });
322
+ }
323
+ return null;
324
+ }).filter(Boolean);
325
+ const systemItem = {
326
+ id: `system-${thisRunningId}`,
327
+ type: 'system',
328
+ content: '',
329
+ timestamp: new Date(),
330
+ loading: false,
331
+ loadingProgressText: '',
332
+ actionTasks
333
+ };
334
+ setInfoList((prev)=>[
335
+ ...prev,
336
+ systemItem
337
+ ]);
338
+ }
339
+ const separatorItem = {
340
+ id: `separator-${thisRunningId}`,
341
+ type: 'separator',
342
+ content: 'New Session',
343
+ timestamp: new Date()
344
+ };
345
+ setInfoList((prev)=>[
346
+ ...prev,
347
+ separatorItem
348
+ ]);
349
+ return _object_spread_props(_object_spread({}, result), {
350
+ reportHTML: null
351
+ });
352
+ })(), [
353
+ playgroundSDK,
354
+ storage,
355
+ actionSpace,
356
+ setLoading,
357
+ setInfoList,
358
+ replayCounter,
359
+ setReplayCounter,
360
+ verticalMode,
361
+ currentRunningIdRef,
362
+ interruptedFlagRef,
363
+ deepLocate,
364
+ deepThink,
365
+ screenshotIncluded,
366
+ domIncluded,
367
+ deviceType,
368
+ imeStrategy,
369
+ autoDismissKeyboard,
370
+ keyboardDismissStrategy,
371
+ alwaysRefreshScreenInfo
372
+ ]);
373
+ const handleStop = (0, external_react_namespaceObject.useCallback)(()=>_async_to_generator(function*() {
374
+ const thisRunningId = currentRunningIdRef.current;
375
+ if (thisRunningId && playgroundSDK && playgroundSDK.cancelExecution) try {
376
+ const cancelResult = yield playgroundSDK.cancelExecution(thisRunningId.toString());
377
+ let executionData = null;
378
+ if (cancelResult) executionData = cancelResult;
379
+ else if (playgroundSDK.getCurrentExecutionData) try {
380
+ executionData = yield playgroundSDK.getCurrentExecutionData();
381
+ } catch (error) {
382
+ console.error('Failed to get execution data before stop:', error);
383
+ }
384
+ interruptedFlagRef.current[thisRunningId] = true;
385
+ setLoading(false);
386
+ if (playgroundSDK.onProgressUpdate) playgroundSDK.onProgressUpdate(()=>{});
387
+ if (playgroundSDK.onDumpUpdate) playgroundSDK.onDumpUpdate(()=>{});
388
+ setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` ? _object_spread_props(_object_spread({}, item), {
389
+ content: '',
390
+ loading: false,
391
+ loadingProgressText: ''
392
+ }) : item));
393
+ if (executionData && (executionData.dump || executionData.reportHTML)) {
394
+ var _executionData_dump;
395
+ let replayInfo = null;
396
+ let counter = replayCounter;
397
+ if ((null == (_executionData_dump = executionData.dump) ? void 0 : _executionData_dump.tasks) && Array.isArray(executionData.dump.tasks)) {
398
+ const groupedDump = wrapExecutionDumpForReplay(executionData.dump, deviceType);
399
+ replayInfo = (0, replay_scripts_js_namespaceObject.allScriptsFromDump)(groupedDump);
400
+ setReplayCounter((c)=>c + 1);
401
+ counter = replayCounter + 1;
402
+ }
403
+ const resultItem = {
404
+ id: `stop-result-${thisRunningId}`,
405
+ type: 'result',
406
+ content: 'Execution stopped by user',
407
+ timestamp: new Date(),
408
+ result: {
409
+ result: null,
410
+ dump: executionData.dump,
411
+ reportHTML: executionData.reportHTML,
412
+ error: null
413
+ },
414
+ loading: false,
415
+ verticalMode,
416
+ replayScriptsInfo: replayInfo,
417
+ replayCounter: counter
418
+ };
419
+ setInfoList((prev)=>[
420
+ ...prev,
421
+ resultItem
422
+ ]);
423
+ } else {
424
+ const stopItem = {
425
+ id: `stop-${thisRunningId}`,
426
+ type: 'system',
427
+ content: 'Operation stopped',
428
+ timestamp: new Date(),
429
+ loading: false
430
+ };
431
+ setInfoList((prev)=>[
432
+ ...prev,
433
+ stopItem
434
+ ]);
435
+ }
436
+ const separatorItem = {
437
+ id: `separator-${thisRunningId}`,
438
+ type: 'separator',
439
+ content: 'New Session',
440
+ timestamp: new Date()
441
+ };
442
+ setInfoList((prev)=>[
443
+ ...prev,
444
+ separatorItem
445
+ ]);
446
+ } catch (error) {
447
+ console.error('Failed to stop execution:', error);
448
+ }
449
+ })(), [
450
+ playgroundSDK,
451
+ currentRunningIdRef,
452
+ interruptedFlagRef,
453
+ setLoading,
454
+ setInfoList,
455
+ verticalMode,
456
+ replayCounter,
457
+ deviceType
458
+ ]);
459
+ const canStop = loading && !!currentRunningIdRef.current && !!playgroundSDK && !!playgroundSDK.cancelExecution;
460
+ return {
461
+ handleRun,
462
+ handleStop,
463
+ canStop
464
+ };
465
+ }
466
+ exports.buildProgressContent = __webpack_exports__.buildProgressContent;
467
+ exports.formatError = __webpack_exports__.formatError;
468
+ exports.usePlaygroundExecution = __webpack_exports__.usePlaygroundExecution;
469
+ exports.wrapExecutionDumpForReplay = __webpack_exports__.wrapExecutionDumpForReplay;
470
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
471
+ "buildProgressContent",
472
+ "formatError",
473
+ "usePlaygroundExecution",
474
+ "wrapExecutionDumpForReplay"
475
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
476
+ Object.defineProperty(exports, '__esModule', {
477
+ value: true
478
+ });