@midscene/visualizer 0.28.4-beta-20250910153230.0 → 0.28.4
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/component/{blackboard.mjs → blackboard/index.mjs} +3 -3
- package/dist/es/component/{playground/ConfigSelector.mjs → config-selector/index.mjs} +2 -3
- package/dist/es/component/{playground/ContextPreview.mjs → context-preview/index.mjs} +3 -4
- package/dist/es/component/{env-config.mjs → env-config/index.mjs} +1 -1
- package/dist/es/component/{github-star.mjs → github-star/index.mjs} +1 -1
- package/dist/es/component/history-selector/index.css +132 -0
- package/dist/es/component/{playground/HistorySelector.mjs → history-selector/index.mjs} +1 -1
- package/dist/es/component/index.mjs +1 -0
- package/dist/es/component/{logo.mjs → logo/index.mjs} +1 -1
- package/dist/es/component/{misc.mjs → misc/index.mjs} +42 -2
- package/dist/es/component/{player.mjs → player/index.mjs} +8 -8
- package/dist/es/component/playground/index.css +35 -161
- package/dist/es/component/playground/index.mjs +8 -0
- package/dist/es/component/playground-result/index.css +35 -0
- package/dist/es/component/{playground/PlaygroundResult.mjs → playground-result/index.mjs} +7 -5
- package/dist/es/component/prompt-input/index.css +330 -0
- package/dist/es/component/{playground/PromptInput.mjs → prompt-input/index.mjs} +9 -9
- package/dist/es/component/{playground/ServiceModeControl.mjs → service-mode-control/index.mjs} +4 -5
- package/dist/es/component/{shiny-text.mjs → shiny-text/index.mjs} +1 -1
- package/dist/es/component/universal-playground/index.css +341 -0
- package/dist/es/component/universal-playground/index.mjs +273 -0
- package/dist/es/component/universal-playground/providers/context-provider.mjs +52 -0
- package/dist/es/component/universal-playground/providers/storage-provider.mjs +107 -0
- package/dist/es/hooks/usePlaygroundExecution.mjs +168 -0
- package/dist/es/hooks/usePlaygroundState.mjs +176 -0
- package/dist/es/icons/avatar.mjs +28 -0
- package/dist/es/index.mjs +22 -18
- package/dist/es/{component/playground/playground-constants.mjs → utils/constants.mjs} +23 -43
- package/dist/es/{component/playground → utils}/playground-utils.mjs +1 -1
- package/dist/es/{component → utils}/replay-scripts.mjs +1 -2
- package/dist/lib/component/{blackboard.js → blackboard/index.js} +5 -5
- package/dist/lib/component/{playground/ConfigSelector.js → config-selector/index.js} +6 -7
- package/dist/lib/component/{playground/ContextPreview.js → context-preview/index.js} +8 -9
- package/dist/lib/component/{env-config.js → env-config/index.js} +1 -1
- package/dist/lib/component/{github-star.js → github-star/index.js} +1 -1
- package/dist/lib/component/history-selector/index.css +132 -0
- package/dist/lib/component/{playground/HistorySelector.js → history-selector/index.js} +1 -1
- package/dist/lib/component/index.js +60 -0
- package/dist/lib/component/{logo.js → logo/index.js} +1 -1
- package/dist/lib/component/{misc.js → misc/index.js} +60 -1
- package/dist/lib/component/{player.js → player/index.js} +23 -23
- package/dist/lib/component/playground/index.css +35 -161
- package/dist/lib/component/playground/index.js +113 -0
- package/dist/lib/component/playground-result/index.css +35 -0
- package/dist/lib/component/{playground/PlaygroundResult.js → playground-result/index.js} +12 -10
- package/dist/lib/component/prompt-input/index.css +330 -0
- package/dist/lib/component/{playground/PromptInput.js → prompt-input/index.js} +37 -37
- package/dist/lib/component/{playground/ServiceModeControl.js → service-mode-control/index.js} +8 -9
- package/dist/lib/component/{shiny-text.js → shiny-text/index.js} +1 -1
- package/dist/lib/component/universal-playground/index.css +341 -0
- package/dist/lib/component/universal-playground/index.js +321 -0
- package/dist/lib/component/universal-playground/providers/context-provider.js +95 -0
- package/dist/lib/component/universal-playground/providers/storage-provider.js +147 -0
- package/dist/lib/hooks/usePlaygroundExecution.js +202 -0
- package/dist/lib/hooks/usePlaygroundState.js +210 -0
- package/dist/lib/icons/avatar.js +62 -0
- package/dist/lib/index.js +66 -34
- package/dist/lib/{component/playground/playground-constants.js → utils/constants.js} +31 -64
- package/dist/lib/{component/playground → utils}/playground-utils.js +1 -1
- package/dist/lib/{component → utils}/replay-scripts.js +3 -4
- package/dist/types/component/{blackboard.d.ts → blackboard/index.d.ts} +2 -2
- package/dist/types/component/{playground/ConfigSelector.d.ts → config-selector/index.d.ts} +0 -1
- package/dist/types/component/{playground/ContextPreview.d.ts → context-preview/index.d.ts} +0 -1
- package/dist/types/component/{github-star.d.ts → github-star/index.d.ts} +1 -1
- package/dist/types/component/{playground/HistorySelector.d.ts → history-selector/index.d.ts} +1 -1
- package/dist/types/component/index.d.ts +1 -0
- package/dist/types/component/{logo.d.ts → logo/index.d.ts} +1 -1
- package/dist/types/component/misc/index.d.ts +6 -0
- package/dist/types/component/{player.d.ts → player/index.d.ts} +2 -2
- package/dist/types/component/playground/index.d.ts +7 -0
- package/dist/types/component/{playground/PlaygroundResult.d.ts → playground-result/index.d.ts} +3 -4
- package/dist/types/component/{playground/PromptInput.d.ts → prompt-input/index.d.ts} +3 -2
- package/dist/types/component/{playground/ServiceModeControl.d.ts → service-mode-control/index.d.ts} +0 -1
- package/dist/types/component/{shiny-text.d.ts → shiny-text/index.d.ts} +1 -1
- package/dist/types/component/universal-playground/index.d.ts +4 -0
- package/dist/types/component/universal-playground/providers/context-provider.d.ts +37 -0
- package/dist/types/component/universal-playground/providers/storage-provider.d.ts +33 -0
- package/dist/types/hooks/usePlaygroundExecution.d.ts +10 -0
- package/dist/types/hooks/usePlaygroundState.d.ts +26 -0
- package/dist/types/index.d.ts +15 -10
- package/dist/types/types.d.ts +164 -0
- package/dist/types/{component/playground/playground-constants.d.ts → utils/constants.d.ts} +3 -5
- package/dist/types/{component → utils}/replay-scripts.d.ts +0 -1
- package/package.json +5 -5
- package/dist/es/blank_polyfill.mjs +0 -2
- package/dist/es/component/describer.css +0 -25
- package/dist/es/component/playground/playground-types.mjs +0 -0
- package/dist/es/init.mjs +0 -10
- package/dist/lib/blank_polyfill.js +0 -36
- package/dist/lib/component/describer.css +0 -25
- package/dist/lib/component/playground/playground-types.js +0 -18
- package/dist/lib/init.js +0 -44
- package/dist/types/blank_polyfill.d.ts +0 -2
- package/dist/types/component/misc.d.ts +0 -2
- package/dist/types/component/playground/playground-types.d.ts +0 -19
- package/dist/types/component/playground/types.d.ts +0 -72
- package/dist/types/init.d.ts +0 -1
- /package/dist/es/component/{blackboard.css → blackboard/index.css} +0 -0
- /package/dist/es/component/{playground/FormField.mjs → form-field/index.mjs} +0 -0
- /package/dist/es/component/{github-star.css → github-star/index.css} +0 -0
- /package/dist/es/component/{logo.css → logo/index.css} +0 -0
- /package/dist/es/component/{player.css → player/index.css} +0 -0
- /package/dist/es/component/{playground-demo-ui-context.json → playground/playground-demo-ui-context.json} +0 -0
- /package/dist/es/component/{shiny-text.css → shiny-text/index.css} +0 -0
- /package/dist/es/{component/playground → hooks}/useServerValid.mjs +0 -0
- /package/dist/es/{component/store → store}/history.mjs +0 -0
- /package/dist/es/{component/store → store}/store.mjs +0 -0
- /package/dist/es/{component/playground/types.mjs → types.mjs} +0 -0
- /package/dist/es/{component → utils}/color.mjs +0 -0
- /package/dist/es/{utils.mjs → utils/index.mjs} +0 -0
- /package/dist/es/{component → utils}/pixi-loader.mjs +0 -0
- /package/dist/lib/component/{blackboard.css → blackboard/index.css} +0 -0
- /package/dist/lib/component/{playground/FormField.js → form-field/index.js} +0 -0
- /package/dist/lib/component/{github-star.css → github-star/index.css} +0 -0
- /package/dist/lib/component/{logo.css → logo/index.css} +0 -0
- /package/dist/lib/component/{player.css → player/index.css} +0 -0
- /package/dist/lib/component/{playground-demo-ui-context.json → playground/playground-demo-ui-context.json} +0 -0
- /package/dist/lib/component/{shiny-text.css → shiny-text/index.css} +0 -0
- /package/dist/lib/{component/playground → hooks}/useServerValid.js +0 -0
- /package/dist/lib/{component/store → store}/history.js +0 -0
- /package/dist/lib/{component/store → store}/store.js +0 -0
- /package/dist/lib/{component/playground/types.js → types.js} +0 -0
- /package/dist/lib/{component → utils}/color.js +0 -0
- /package/dist/lib/{utils.js → utils/index.js} +0 -0
- /package/dist/lib/{component → utils}/pixi-loader.js +0 -0
- /package/dist/types/component/{env-config.d.ts → env-config/index.d.ts} +0 -0
- /package/dist/types/component/{playground/FormField.d.ts → form-field/index.d.ts} +0 -0
- /package/dist/types/{component/playground → hooks}/useServerValid.d.ts +0 -0
- /package/dist/types/{component/store → store}/history.d.ts +0 -0
- /package/dist/types/{component/store → store}/store.d.ts +0 -0
- /package/dist/types/{component → utils}/color.d.ts +0 -0
- /package/dist/types/{utils.d.ts → utils/index.d.ts} +0 -0
- /package/dist/types/{component → utils}/pixi-loader.d.ts +0 -0
- /package/dist/types/{component/playground → utils}/playground-utils.d.ts +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
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 ('undefined' != 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
|
+
AgentContextProvider: ()=>AgentContextProvider,
|
|
28
|
+
BaseContextProvider: ()=>BaseContextProvider,
|
|
29
|
+
NoOpContextProvider: ()=>NoOpContextProvider,
|
|
30
|
+
StaticContextProvider: ()=>StaticContextProvider
|
|
31
|
+
});
|
|
32
|
+
function _define_property(obj, key, value) {
|
|
33
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
34
|
+
value: value,
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true
|
|
38
|
+
});
|
|
39
|
+
else obj[key] = value;
|
|
40
|
+
return obj;
|
|
41
|
+
}
|
|
42
|
+
class BaseContextProvider {
|
|
43
|
+
async refreshContext() {
|
|
44
|
+
this.cachedContext = void 0;
|
|
45
|
+
return await this.getUIContext();
|
|
46
|
+
}
|
|
47
|
+
constructor(){
|
|
48
|
+
_define_property(this, "cachedContext", void 0);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
class AgentContextProvider extends BaseContextProvider {
|
|
52
|
+
async getUIContext() {
|
|
53
|
+
if (this.cachedContext) return this.cachedContext;
|
|
54
|
+
const agent = this.getAgent();
|
|
55
|
+
if (!(null == agent ? void 0 : agent.getUIContext)) throw new Error('Agent does not support getUIContext');
|
|
56
|
+
const context = await agent.getUIContext();
|
|
57
|
+
this.cachedContext = context;
|
|
58
|
+
return context;
|
|
59
|
+
}
|
|
60
|
+
constructor(getAgent, options){
|
|
61
|
+
super(), _define_property(this, "getAgent", void 0), _define_property(this, "options", void 0), this.getAgent = getAgent, this.options = options;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
class StaticContextProvider extends BaseContextProvider {
|
|
65
|
+
async getUIContext() {
|
|
66
|
+
return this.context;
|
|
67
|
+
}
|
|
68
|
+
async refreshContext() {
|
|
69
|
+
return this.context;
|
|
70
|
+
}
|
|
71
|
+
constructor(context){
|
|
72
|
+
super(), _define_property(this, "context", void 0), this.context = context;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
class NoOpContextProvider {
|
|
76
|
+
async getUIContext() {
|
|
77
|
+
throw new Error('Context preview is disabled');
|
|
78
|
+
}
|
|
79
|
+
async refreshContext() {
|
|
80
|
+
throw new Error('Context preview is disabled');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.AgentContextProvider = __webpack_exports__.AgentContextProvider;
|
|
84
|
+
exports.BaseContextProvider = __webpack_exports__.BaseContextProvider;
|
|
85
|
+
exports.NoOpContextProvider = __webpack_exports__.NoOpContextProvider;
|
|
86
|
+
exports.StaticContextProvider = __webpack_exports__.StaticContextProvider;
|
|
87
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
88
|
+
"AgentContextProvider",
|
|
89
|
+
"BaseContextProvider",
|
|
90
|
+
"NoOpContextProvider",
|
|
91
|
+
"StaticContextProvider"
|
|
92
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
93
|
+
Object.defineProperty(exports, '__esModule', {
|
|
94
|
+
value: true
|
|
95
|
+
});
|
|
@@ -0,0 +1,147 @@
|
|
|
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 ('undefined' != 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
|
+
LocalStorageProvider: ()=>LocalStorageProvider,
|
|
28
|
+
MemoryStorageProvider: ()=>MemoryStorageProvider,
|
|
29
|
+
NoOpStorageProvider: ()=>NoOpStorageProvider
|
|
30
|
+
});
|
|
31
|
+
function _define_property(obj, key, value) {
|
|
32
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
33
|
+
value: value,
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true
|
|
37
|
+
});
|
|
38
|
+
else obj[key] = value;
|
|
39
|
+
return obj;
|
|
40
|
+
}
|
|
41
|
+
class LocalStorageProvider {
|
|
42
|
+
async saveMessages(messages) {
|
|
43
|
+
try {
|
|
44
|
+
const lightMessages = messages.map((msg)=>({
|
|
45
|
+
...msg,
|
|
46
|
+
result: void 0
|
|
47
|
+
}));
|
|
48
|
+
localStorage.setItem(this.messagesKey, JSON.stringify(lightMessages));
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error('Failed to save messages to localStorage:', error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async loadMessages() {
|
|
54
|
+
try {
|
|
55
|
+
const stored = localStorage.getItem(this.messagesKey);
|
|
56
|
+
if (!stored) return [];
|
|
57
|
+
const messages = JSON.parse(stored);
|
|
58
|
+
const restoredMessages = await Promise.all(messages.map(async (msg)=>{
|
|
59
|
+
if ('result' === msg.type && msg.id) {
|
|
60
|
+
const resultKey = `${this.resultsKey}-${msg.id}`;
|
|
61
|
+
const storedResult = localStorage.getItem(resultKey);
|
|
62
|
+
if (storedResult) try {
|
|
63
|
+
const resultItem = JSON.parse(storedResult);
|
|
64
|
+
return {
|
|
65
|
+
...msg,
|
|
66
|
+
...resultItem
|
|
67
|
+
};
|
|
68
|
+
} catch (e) {
|
|
69
|
+
console.warn('Failed to parse stored result:', e);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return msg;
|
|
73
|
+
}));
|
|
74
|
+
return restoredMessages;
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error('Failed to load messages from localStorage:', error);
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async clearMessages() {
|
|
81
|
+
try {
|
|
82
|
+
localStorage.removeItem(this.messagesKey);
|
|
83
|
+
const keys = Object.keys(localStorage);
|
|
84
|
+
keys.forEach((key)=>{
|
|
85
|
+
if (key.startsWith(this.resultsKey)) localStorage.removeItem(key);
|
|
86
|
+
});
|
|
87
|
+
} catch (error) {
|
|
88
|
+
console.error('Failed to clear messages from localStorage:', error);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async saveResult(id, result) {
|
|
92
|
+
try {
|
|
93
|
+
const resultKey = `${this.resultsKey}-${id}`;
|
|
94
|
+
localStorage.setItem(resultKey, JSON.stringify(result));
|
|
95
|
+
} catch (error) {
|
|
96
|
+
console.error('Failed to save result to localStorage:', error);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
constructor(namespace = 'playground'){
|
|
100
|
+
_define_property(this, "messagesKey", void 0);
|
|
101
|
+
_define_property(this, "resultsKey", void 0);
|
|
102
|
+
this.messagesKey = `${namespace}-messages`;
|
|
103
|
+
this.resultsKey = `${namespace}-results`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
class MemoryStorageProvider {
|
|
107
|
+
async saveMessages(messages) {
|
|
108
|
+
this.messages = [
|
|
109
|
+
...messages
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
async loadMessages() {
|
|
113
|
+
return [
|
|
114
|
+
...this.messages
|
|
115
|
+
];
|
|
116
|
+
}
|
|
117
|
+
async clearMessages() {
|
|
118
|
+
this.messages = [];
|
|
119
|
+
this.results.clear();
|
|
120
|
+
}
|
|
121
|
+
async saveResult(id, result) {
|
|
122
|
+
this.results.set(id, result);
|
|
123
|
+
}
|
|
124
|
+
constructor(){
|
|
125
|
+
_define_property(this, "messages", []);
|
|
126
|
+
_define_property(this, "results", new Map());
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
class NoOpStorageProvider {
|
|
130
|
+
async saveMessages(_messages) {}
|
|
131
|
+
async loadMessages() {
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
async clearMessages() {}
|
|
135
|
+
async saveResult(_id, _result) {}
|
|
136
|
+
}
|
|
137
|
+
exports.LocalStorageProvider = __webpack_exports__.LocalStorageProvider;
|
|
138
|
+
exports.MemoryStorageProvider = __webpack_exports__.MemoryStorageProvider;
|
|
139
|
+
exports.NoOpStorageProvider = __webpack_exports__.NoOpStorageProvider;
|
|
140
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
141
|
+
"LocalStorageProvider",
|
|
142
|
+
"MemoryStorageProvider",
|
|
143
|
+
"NoOpStorageProvider"
|
|
144
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
145
|
+
Object.defineProperty(exports, '__esModule', {
|
|
146
|
+
value: true
|
|
147
|
+
});
|
|
@@ -0,0 +1,202 @@
|
|
|
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 ('undefined' != 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
|
+
usePlaygroundExecution: ()=>usePlaygroundExecution
|
|
28
|
+
});
|
|
29
|
+
const external_react_namespaceObject = require("react");
|
|
30
|
+
const constants_js_namespaceObject = require("../utils/constants.js");
|
|
31
|
+
const replay_scripts_js_namespaceObject = require("../utils/replay-scripts.js");
|
|
32
|
+
const noReplayAPIs = [
|
|
33
|
+
'aiQuery',
|
|
34
|
+
'aiAssert'
|
|
35
|
+
];
|
|
36
|
+
function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, setLoading, infoList, setInfoList, replayCounter, setReplayCounter, verticalMode, currentRunningIdRef, interruptedFlagRef) {
|
|
37
|
+
const handleRun = (0, external_react_namespaceObject.useCallback)(async (value)=>{
|
|
38
|
+
const thisRunningId = Date.now();
|
|
39
|
+
const actionType = value.type;
|
|
40
|
+
const displayContent = `${value.type}: ${value.prompt || JSON.stringify(value.params)}`;
|
|
41
|
+
const userItem = {
|
|
42
|
+
id: `user-${Date.now()}`,
|
|
43
|
+
type: 'user',
|
|
44
|
+
content: displayContent,
|
|
45
|
+
timestamp: new Date()
|
|
46
|
+
};
|
|
47
|
+
setInfoList((prev)=>[
|
|
48
|
+
...prev,
|
|
49
|
+
userItem
|
|
50
|
+
]);
|
|
51
|
+
setLoading(true);
|
|
52
|
+
const result = {
|
|
53
|
+
...constants_js_namespaceObject.BLANK_RESULT
|
|
54
|
+
};
|
|
55
|
+
const systemItem = {
|
|
56
|
+
id: `system-${thisRunningId}`,
|
|
57
|
+
type: 'system',
|
|
58
|
+
content: '',
|
|
59
|
+
timestamp: new Date(),
|
|
60
|
+
loading: true,
|
|
61
|
+
loadingProgressText: ''
|
|
62
|
+
};
|
|
63
|
+
setInfoList((prev)=>[
|
|
64
|
+
...prev,
|
|
65
|
+
systemItem
|
|
66
|
+
]);
|
|
67
|
+
try {
|
|
68
|
+
currentRunningIdRef.current = thisRunningId;
|
|
69
|
+
interruptedFlagRef.current[thisRunningId] = false;
|
|
70
|
+
if (playgroundSDK.onProgressUpdate) playgroundSDK.onProgressUpdate((tip)=>{
|
|
71
|
+
if (interruptedFlagRef.current[thisRunningId]) return;
|
|
72
|
+
const progressItem = {
|
|
73
|
+
id: `progress-${thisRunningId}-${Date.now()}`,
|
|
74
|
+
type: 'progress',
|
|
75
|
+
content: tip,
|
|
76
|
+
timestamp: new Date()
|
|
77
|
+
};
|
|
78
|
+
setInfoList((prev)=>[
|
|
79
|
+
...prev,
|
|
80
|
+
progressItem
|
|
81
|
+
]);
|
|
82
|
+
});
|
|
83
|
+
result.result = await playgroundSDK.executeAction(actionType, value, {
|
|
84
|
+
requestId: thisRunningId.toString()
|
|
85
|
+
});
|
|
86
|
+
if ('object' == typeof result.result && null !== result.result) {
|
|
87
|
+
const resultObj = result.result;
|
|
88
|
+
if (resultObj.dump) result.dump = resultObj.dump;
|
|
89
|
+
if (resultObj.reportHTML) result.reportHTML = resultObj.reportHTML;
|
|
90
|
+
if (resultObj.error) result.error = resultObj.error;
|
|
91
|
+
if (void 0 !== resultObj.result) result.result = resultObj.result;
|
|
92
|
+
}
|
|
93
|
+
} catch (e) {
|
|
94
|
+
result.error = (null == e ? void 0 : e.message) || String(e);
|
|
95
|
+
console.error('Playground execution error:', e);
|
|
96
|
+
}
|
|
97
|
+
if (interruptedFlagRef.current[thisRunningId]) return;
|
|
98
|
+
setLoading(false);
|
|
99
|
+
currentRunningIdRef.current = null;
|
|
100
|
+
let replayInfo = null;
|
|
101
|
+
let counter = replayCounter;
|
|
102
|
+
if ((null == result ? void 0 : result.dump) && !noReplayAPIs.includes(actionType)) {
|
|
103
|
+
const info = (0, replay_scripts_js_namespaceObject.allScriptsFromDump)(result.dump);
|
|
104
|
+
setReplayCounter((c)=>c + 1);
|
|
105
|
+
replayInfo = info;
|
|
106
|
+
counter = replayCounter + 1;
|
|
107
|
+
}
|
|
108
|
+
setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` ? {
|
|
109
|
+
...item,
|
|
110
|
+
content: '',
|
|
111
|
+
loading: false,
|
|
112
|
+
loadingProgressText: ''
|
|
113
|
+
} : item));
|
|
114
|
+
const resultItem = {
|
|
115
|
+
id: `result-${thisRunningId}`,
|
|
116
|
+
type: 'result',
|
|
117
|
+
content: 'Execution result',
|
|
118
|
+
timestamp: new Date(),
|
|
119
|
+
result: result,
|
|
120
|
+
loading: false,
|
|
121
|
+
replayScriptsInfo: replayInfo,
|
|
122
|
+
replayCounter: counter,
|
|
123
|
+
loadingProgressText: '',
|
|
124
|
+
verticalMode: verticalMode
|
|
125
|
+
};
|
|
126
|
+
setInfoList((prev)=>[
|
|
127
|
+
...prev,
|
|
128
|
+
resultItem
|
|
129
|
+
]);
|
|
130
|
+
if (null == storage ? void 0 : storage.saveResult) try {
|
|
131
|
+
await storage.saveResult(resultItem.id, resultItem);
|
|
132
|
+
} catch (error) {
|
|
133
|
+
console.error('Failed to save result:', error);
|
|
134
|
+
}
|
|
135
|
+
const separatorItem = {
|
|
136
|
+
id: `separator-${thisRunningId}`,
|
|
137
|
+
type: 'separator',
|
|
138
|
+
content: 'New Session',
|
|
139
|
+
timestamp: new Date()
|
|
140
|
+
};
|
|
141
|
+
setInfoList((prev)=>[
|
|
142
|
+
...prev,
|
|
143
|
+
separatorItem
|
|
144
|
+
]);
|
|
145
|
+
}, [
|
|
146
|
+
playgroundSDK,
|
|
147
|
+
storage,
|
|
148
|
+
actionSpace,
|
|
149
|
+
setLoading,
|
|
150
|
+
setInfoList,
|
|
151
|
+
replayCounter,
|
|
152
|
+
setReplayCounter,
|
|
153
|
+
verticalMode,
|
|
154
|
+
currentRunningIdRef,
|
|
155
|
+
interruptedFlagRef
|
|
156
|
+
]);
|
|
157
|
+
const handleStop = (0, external_react_namespaceObject.useCallback)(async ()=>{
|
|
158
|
+
const thisRunningId = currentRunningIdRef.current;
|
|
159
|
+
if (thisRunningId && playgroundSDK.cancelExecution) try {
|
|
160
|
+
await playgroundSDK.cancelExecution(thisRunningId.toString());
|
|
161
|
+
interruptedFlagRef.current[thisRunningId] = true;
|
|
162
|
+
setLoading(false);
|
|
163
|
+
setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` && item.loading ? {
|
|
164
|
+
...item,
|
|
165
|
+
content: 'Operation stopped',
|
|
166
|
+
loading: false,
|
|
167
|
+
loadingProgressText: ''
|
|
168
|
+
} : item));
|
|
169
|
+
const separatorItem = {
|
|
170
|
+
id: `separator-${thisRunningId}`,
|
|
171
|
+
type: 'separator',
|
|
172
|
+
content: 'New Session',
|
|
173
|
+
timestamp: new Date()
|
|
174
|
+
};
|
|
175
|
+
setInfoList((prev)=>[
|
|
176
|
+
...prev,
|
|
177
|
+
separatorItem
|
|
178
|
+
]);
|
|
179
|
+
} catch (error) {
|
|
180
|
+
console.error('Failed to stop execution:', error);
|
|
181
|
+
}
|
|
182
|
+
}, [
|
|
183
|
+
playgroundSDK,
|
|
184
|
+
currentRunningIdRef,
|
|
185
|
+
interruptedFlagRef,
|
|
186
|
+
setLoading,
|
|
187
|
+
setInfoList
|
|
188
|
+
]);
|
|
189
|
+
const canStop = loading && !!currentRunningIdRef.current && !!playgroundSDK.cancelExecution;
|
|
190
|
+
return {
|
|
191
|
+
handleRun,
|
|
192
|
+
handleStop,
|
|
193
|
+
canStop
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
exports.usePlaygroundExecution = __webpack_exports__.usePlaygroundExecution;
|
|
197
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
198
|
+
"usePlaygroundExecution"
|
|
199
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
200
|
+
Object.defineProperty(exports, '__esModule', {
|
|
201
|
+
value: true
|
|
202
|
+
});
|
|
@@ -0,0 +1,210 @@
|
|
|
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 ('undefined' != 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
|
+
usePlaygroundState: ()=>usePlaygroundState
|
|
28
|
+
});
|
|
29
|
+
const external_react_namespaceObject = require("react");
|
|
30
|
+
const constants_js_namespaceObject = require("../utils/constants.js");
|
|
31
|
+
function usePlaygroundState(playgroundSDK, storage, contextProvider) {
|
|
32
|
+
const [loading, setLoading] = (0, external_react_namespaceObject.useState)(false);
|
|
33
|
+
const [infoList, setInfoList] = (0, external_react_namespaceObject.useState)([]);
|
|
34
|
+
const [actionSpace, setActionSpace] = (0, external_react_namespaceObject.useState)([]);
|
|
35
|
+
const [actionSpaceLoading, setActionSpaceLoading] = (0, external_react_namespaceObject.useState)(true);
|
|
36
|
+
const [uiContextPreview, setUiContextPreview] = (0, external_react_namespaceObject.useState)();
|
|
37
|
+
const [showScrollToBottomButton, setShowScrollToBottomButton] = (0, external_react_namespaceObject.useState)(false);
|
|
38
|
+
const [verticalMode, setVerticalMode] = (0, external_react_namespaceObject.useState)(false);
|
|
39
|
+
const [replayCounter, setReplayCounter] = (0, external_react_namespaceObject.useState)(0);
|
|
40
|
+
const infoListRef = (0, external_react_namespaceObject.useRef)(null);
|
|
41
|
+
const currentRunningIdRef = (0, external_react_namespaceObject.useRef)(null);
|
|
42
|
+
const interruptedFlagRef = (0, external_react_namespaceObject.useRef)({});
|
|
43
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
44
|
+
const initializeMessages = async ()=>{
|
|
45
|
+
const welcomeMessage = {
|
|
46
|
+
...constants_js_namespaceObject.WELCOME_MESSAGE_TEMPLATE,
|
|
47
|
+
id: 'welcome',
|
|
48
|
+
timestamp: new Date()
|
|
49
|
+
};
|
|
50
|
+
if (null == storage ? void 0 : storage.loadMessages) try {
|
|
51
|
+
const storedMessages = await storage.loadMessages();
|
|
52
|
+
const hasWelcomeMessage = storedMessages.some((msg)=>'welcome' === msg.id);
|
|
53
|
+
hasWelcomeMessage ? setInfoList(storedMessages) : setInfoList([
|
|
54
|
+
welcomeMessage,
|
|
55
|
+
...storedMessages
|
|
56
|
+
]);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error('Failed to load messages:', error);
|
|
59
|
+
setInfoList([
|
|
60
|
+
welcomeMessage
|
|
61
|
+
]);
|
|
62
|
+
}
|
|
63
|
+
else setInfoList([
|
|
64
|
+
welcomeMessage
|
|
65
|
+
]);
|
|
66
|
+
};
|
|
67
|
+
if (0 === infoList.length) initializeMessages();
|
|
68
|
+
}, []);
|
|
69
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
70
|
+
if ((null == storage ? void 0 : storage.saveMessages) && infoList.length > 1) storage.saveMessages(infoList).catch((error)=>{
|
|
71
|
+
console.error('Failed to save messages:', error);
|
|
72
|
+
});
|
|
73
|
+
}, [
|
|
74
|
+
infoList,
|
|
75
|
+
storage
|
|
76
|
+
]);
|
|
77
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
78
|
+
if (!(null == contextProvider ? void 0 : contextProvider.getUIContext) || uiContextPreview) return;
|
|
79
|
+
contextProvider.getUIContext().then((context)=>setUiContextPreview(context)).catch((error)=>{
|
|
80
|
+
console.error('Failed to get UI context:', error);
|
|
81
|
+
});
|
|
82
|
+
}, [
|
|
83
|
+
contextProvider,
|
|
84
|
+
uiContextPreview
|
|
85
|
+
]);
|
|
86
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
87
|
+
const loadActionSpace = async ()=>{
|
|
88
|
+
setActionSpaceLoading(true);
|
|
89
|
+
try {
|
|
90
|
+
var _contextProvider_getUIContext;
|
|
91
|
+
const context = uiContextPreview || await (null == contextProvider ? void 0 : null == (_contextProvider_getUIContext = contextProvider.getUIContext) ? void 0 : _contextProvider_getUIContext.call(contextProvider));
|
|
92
|
+
const space = await playgroundSDK.getActionSpace(context);
|
|
93
|
+
setActionSpace(space || []);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.error('Failed to load action space:', error);
|
|
96
|
+
setActionSpace([]);
|
|
97
|
+
} finally{
|
|
98
|
+
setActionSpaceLoading(false);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
loadActionSpace();
|
|
102
|
+
}, [
|
|
103
|
+
playgroundSDK,
|
|
104
|
+
uiContextPreview,
|
|
105
|
+
contextProvider
|
|
106
|
+
]);
|
|
107
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
108
|
+
const sizeThreshold = 750;
|
|
109
|
+
setVerticalMode(window.innerWidth < sizeThreshold);
|
|
110
|
+
const handleResize = ()=>{
|
|
111
|
+
setVerticalMode(window.innerWidth < sizeThreshold);
|
|
112
|
+
};
|
|
113
|
+
window.addEventListener('resize', handleResize);
|
|
114
|
+
return ()=>window.removeEventListener('resize', handleResize);
|
|
115
|
+
}, []);
|
|
116
|
+
const scrollToBottom = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
117
|
+
setTimeout(()=>{
|
|
118
|
+
if (infoListRef.current) infoListRef.current.scrollTop = infoListRef.current.scrollHeight;
|
|
119
|
+
}, 100);
|
|
120
|
+
}, []);
|
|
121
|
+
const checkIfScrolledToBottom = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
122
|
+
if (infoListRef.current) {
|
|
123
|
+
const { scrollTop, scrollHeight, clientHeight } = infoListRef.current;
|
|
124
|
+
const isAtBottom = scrollTop + clientHeight >= scrollHeight - 10;
|
|
125
|
+
setShowScrollToBottomButton(!isAtBottom);
|
|
126
|
+
}
|
|
127
|
+
}, []);
|
|
128
|
+
const handleScrollToBottom = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
129
|
+
if (infoListRef.current) {
|
|
130
|
+
infoListRef.current.scrollTo({
|
|
131
|
+
top: infoListRef.current.scrollHeight,
|
|
132
|
+
behavior: 'smooth'
|
|
133
|
+
});
|
|
134
|
+
setShowScrollToBottomButton(false);
|
|
135
|
+
}
|
|
136
|
+
}, []);
|
|
137
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
138
|
+
if (infoList.length > 0) scrollToBottom();
|
|
139
|
+
}, [
|
|
140
|
+
infoList,
|
|
141
|
+
scrollToBottom
|
|
142
|
+
]);
|
|
143
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
144
|
+
const container = infoListRef.current;
|
|
145
|
+
if (container) {
|
|
146
|
+
container.addEventListener('scroll', checkIfScrolledToBottom);
|
|
147
|
+
checkIfScrolledToBottom();
|
|
148
|
+
return ()=>{
|
|
149
|
+
container.removeEventListener('scroll', checkIfScrolledToBottom);
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}, [
|
|
153
|
+
checkIfScrolledToBottom
|
|
154
|
+
]);
|
|
155
|
+
const clearInfoList = (0, external_react_namespaceObject.useCallback)(async ()=>{
|
|
156
|
+
const welcomeMessage = {
|
|
157
|
+
...constants_js_namespaceObject.WELCOME_MESSAGE_TEMPLATE,
|
|
158
|
+
id: 'welcome',
|
|
159
|
+
timestamp: new Date()
|
|
160
|
+
};
|
|
161
|
+
setInfoList([
|
|
162
|
+
welcomeMessage
|
|
163
|
+
]);
|
|
164
|
+
if (null == storage ? void 0 : storage.clearMessages) try {
|
|
165
|
+
await storage.clearMessages();
|
|
166
|
+
} catch (error) {
|
|
167
|
+
console.error('Failed to clear stored messages:', error);
|
|
168
|
+
}
|
|
169
|
+
}, [
|
|
170
|
+
storage
|
|
171
|
+
]);
|
|
172
|
+
const refreshContext = (0, external_react_namespaceObject.useCallback)(async ()=>{
|
|
173
|
+
if (null == contextProvider ? void 0 : contextProvider.refreshContext) try {
|
|
174
|
+
const newContext = await contextProvider.refreshContext();
|
|
175
|
+
setUiContextPreview(newContext);
|
|
176
|
+
} catch (error) {
|
|
177
|
+
console.error('Failed to refresh context:', error);
|
|
178
|
+
}
|
|
179
|
+
}, [
|
|
180
|
+
contextProvider
|
|
181
|
+
]);
|
|
182
|
+
return {
|
|
183
|
+
loading,
|
|
184
|
+
setLoading,
|
|
185
|
+
infoList,
|
|
186
|
+
setInfoList,
|
|
187
|
+
actionSpace,
|
|
188
|
+
actionSpaceLoading,
|
|
189
|
+
uiContextPreview,
|
|
190
|
+
setUiContextPreview,
|
|
191
|
+
showScrollToBottomButton,
|
|
192
|
+
verticalMode,
|
|
193
|
+
replayCounter,
|
|
194
|
+
setReplayCounter,
|
|
195
|
+
infoListRef,
|
|
196
|
+
currentRunningIdRef,
|
|
197
|
+
interruptedFlagRef,
|
|
198
|
+
clearInfoList,
|
|
199
|
+
refreshContext,
|
|
200
|
+
handleScrollToBottom,
|
|
201
|
+
scrollToBottom
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
exports.usePlaygroundState = __webpack_exports__.usePlaygroundState;
|
|
205
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
206
|
+
"usePlaygroundState"
|
|
207
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
208
|
+
Object.defineProperty(exports, '__esModule', {
|
|
209
|
+
value: true
|
|
210
|
+
});
|