@page-agent/ui 0.0.7

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Alibaba
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,297 @@
1
+ import { Motion } from 'ai-motion';
2
+
3
+ export declare type AgentStatus = 'idle' | 'running' | 'paused' | 'completed' | 'error';
4
+
5
+ declare type DeepStringify<T> = {
6
+ [K in keyof T]: T[K] extends string ? string : T[K] extends object ? DeepStringify<T[K]> : T[K];
7
+ };
8
+
9
+ declare const enUS: {
10
+ readonly ui: {
11
+ readonly panel: {
12
+ readonly ready: "Ready";
13
+ readonly thinking: "Thinking...";
14
+ readonly paused: "Paused";
15
+ readonly taskInput: "Enter new task, describe steps in detail, press Enter to submit";
16
+ readonly userAnswerPrompt: "Please answer the question above, press Enter to submit";
17
+ readonly taskTerminated: "Task terminated";
18
+ readonly taskCompleted: "Task completed";
19
+ readonly continueExecution: "Continue execution";
20
+ readonly userAnswer: "User answer: {{input}}";
21
+ readonly question: "Question: {{question}}";
22
+ readonly waitingPlaceholder: "Waiting for task to start...";
23
+ readonly pause: "Pause";
24
+ readonly continue: "Continue";
25
+ readonly stop: "Stop";
26
+ readonly expand: "Expand history";
27
+ readonly collapse: "Collapse history";
28
+ readonly step: "Step {{number}} · {{time}}{{duration}}";
29
+ };
30
+ readonly tools: {
31
+ readonly clicking: "Clicking element [{{index}}]...";
32
+ readonly inputting: "Inputting text to element [{{index}}]...";
33
+ readonly selecting: "Selecting option \"{{text}}\"...";
34
+ readonly scrolling: "Scrolling page...";
35
+ readonly waiting: "Waiting {{seconds}} seconds...";
36
+ readonly done: "Task done";
37
+ readonly clicked: "🖱️ Clicked element [{{index}}]";
38
+ readonly inputted: "⌨️ Inputted text \"{{text}}\"";
39
+ readonly selected: "☑️ Selected option \"{{text}}\"";
40
+ readonly scrolled: "🛞 Page scrolled";
41
+ readonly waited: "⌛️ Wait completed";
42
+ readonly executing: "Executing {{toolName}}...";
43
+ readonly resultSuccess: "success";
44
+ readonly resultFailure: "failed";
45
+ readonly resultError: "error";
46
+ };
47
+ readonly errors: {
48
+ readonly elementNotFound: "No interactive element found at index {{index}}";
49
+ readonly taskRequired: "Task description is required";
50
+ readonly executionFailed: "Task execution failed";
51
+ readonly notInputElement: "Element is not an input or textarea";
52
+ readonly notSelectElement: "Element is not a select element";
53
+ readonly optionNotFound: "Option \"{{text}}\" not found";
54
+ };
55
+ };
56
+ };
57
+
58
+ export declare class I18n {
59
+ private language;
60
+ private translations;
61
+ constructor(language?: SupportedLanguage);
62
+ t(key: TranslationKey, params?: TranslationParams): string;
63
+ private getNestedValue;
64
+ private interpolate;
65
+ getLanguage(): SupportedLanguage;
66
+ }
67
+
68
+ declare const locales: {
69
+ readonly 'en-US': {
70
+ readonly ui: {
71
+ readonly panel: {
72
+ readonly ready: "Ready";
73
+ readonly thinking: "Thinking...";
74
+ readonly paused: "Paused";
75
+ readonly taskInput: "Enter new task, describe steps in detail, press Enter to submit";
76
+ readonly userAnswerPrompt: "Please answer the question above, press Enter to submit";
77
+ readonly taskTerminated: "Task terminated";
78
+ readonly taskCompleted: "Task completed";
79
+ readonly continueExecution: "Continue execution";
80
+ readonly userAnswer: "User answer: {{input}}";
81
+ readonly question: "Question: {{question}}";
82
+ readonly waitingPlaceholder: "Waiting for task to start...";
83
+ readonly pause: "Pause";
84
+ readonly continue: "Continue";
85
+ readonly stop: "Stop";
86
+ readonly expand: "Expand history";
87
+ readonly collapse: "Collapse history";
88
+ readonly step: "Step {{number}} · {{time}}{{duration}}";
89
+ };
90
+ readonly tools: {
91
+ readonly clicking: "Clicking element [{{index}}]...";
92
+ readonly inputting: "Inputting text to element [{{index}}]...";
93
+ readonly selecting: "Selecting option \"{{text}}\"...";
94
+ readonly scrolling: "Scrolling page...";
95
+ readonly waiting: "Waiting {{seconds}} seconds...";
96
+ readonly done: "Task done";
97
+ readonly clicked: "🖱️ Clicked element [{{index}}]";
98
+ readonly inputted: "⌨️ Inputted text \"{{text}}\"";
99
+ readonly selected: "☑️ Selected option \"{{text}}\"";
100
+ readonly scrolled: "🛞 Page scrolled";
101
+ readonly waited: "⌛️ Wait completed";
102
+ readonly executing: "Executing {{toolName}}...";
103
+ readonly resultSuccess: "success";
104
+ readonly resultFailure: "failed";
105
+ readonly resultError: "error";
106
+ };
107
+ readonly errors: {
108
+ readonly elementNotFound: "No interactive element found at index {{index}}";
109
+ readonly taskRequired: "Task description is required";
110
+ readonly executionFailed: "Task execution failed";
111
+ readonly notInputElement: "Element is not an input or textarea";
112
+ readonly notSelectElement: "Element is not a select element";
113
+ readonly optionNotFound: "Option \"{{text}}\" not found";
114
+ };
115
+ };
116
+ };
117
+ readonly 'zh-CN': {
118
+ readonly ui: {
119
+ readonly panel: {
120
+ readonly ready: "准备就绪";
121
+ readonly thinking: "正在思考...";
122
+ readonly paused: "暂停中,稍后";
123
+ readonly taskInput: "输入新任务,详细描述步骤,回车提交";
124
+ readonly userAnswerPrompt: "请回答上面问题,回车提交";
125
+ readonly taskTerminated: "任务已终止";
126
+ readonly taskCompleted: "任务结束";
127
+ readonly continueExecution: "继续执行";
128
+ readonly userAnswer: "用户回答: {{input}}";
129
+ readonly question: "询问: {{question}}";
130
+ readonly waitingPlaceholder: "等待任务开始...";
131
+ readonly pause: "暂停";
132
+ readonly continue: "继续";
133
+ readonly stop: "终止";
134
+ readonly expand: "展开历史";
135
+ readonly collapse: "收起历史";
136
+ readonly step: "步骤 {{number}} · {{time}}{{duration}}";
137
+ };
138
+ readonly tools: {
139
+ readonly clicking: "正在点击元素 [{{index}}]...";
140
+ readonly inputting: "正在输入文本到元素 [{{index}}]...";
141
+ readonly selecting: "正在选择选项 \"{{text}}\"...";
142
+ readonly scrolling: "正在滚动页面...";
143
+ readonly waiting: "等待 {{seconds}} 秒...";
144
+ readonly done: "结束任务";
145
+ readonly clicked: "🖱️ 已点击元素 [{{index}}]";
146
+ readonly inputted: "⌨️ 已输入文本 \"{{text}}\"";
147
+ readonly selected: "☑️ 已选择选项 \"{{text}}\"";
148
+ readonly scrolled: "🛞 页面滚动完成";
149
+ readonly waited: "⌛️ 等待完成";
150
+ readonly executing: "正在执行 {{toolName}}...";
151
+ readonly resultSuccess: "成功";
152
+ readonly resultFailure: "失败";
153
+ readonly resultError: "错误";
154
+ };
155
+ readonly errors: {
156
+ readonly elementNotFound: "未找到索引为 {{index}} 的交互元素";
157
+ readonly taskRequired: "任务描述不能为空";
158
+ readonly executionFailed: "任务执行失败";
159
+ readonly notInputElement: "元素不是输入框或文本域";
160
+ readonly notSelectElement: "元素不是选择框";
161
+ readonly optionNotFound: "未找到选项 \"{{text}}\"";
162
+ };
163
+ };
164
+ };
165
+ };
166
+
167
+ declare type NestedKeyOf<ObjectType extends object> = {
168
+ [Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}` | `${Key}.${NestedKeyOf<ObjectType[Key]>}` : `${Key}`;
169
+ }[keyof ObjectType & (string | number)];
170
+
171
+ /**
172
+ * Agent control panel
173
+ */
174
+ export declare class Panel {
175
+ #private;
176
+ get wrapper(): HTMLElement;
177
+ constructor(config: PanelConfig);
178
+ /**
179
+ * Ask for user input
180
+ */
181
+ askUser(question: string): Promise<string>;
182
+ show(): void;
183
+ hide(): void;
184
+ reset(): void;
185
+ expand(): void;
186
+ collapse(): void;
187
+ /**
188
+ * Update panel with semantic data - i18n handled internally
189
+ */
190
+ update(data: PanelUpdate): void;
191
+ /**
192
+ * Dispose panel
193
+ */
194
+ dispose(): void;
195
+ }
196
+
197
+ /**
198
+ * Panel configuration
199
+ */
200
+ export declare interface PanelConfig {
201
+ language?: SupportedLanguage;
202
+ onExecuteTask: (task: string) => void;
203
+ onStop: () => void;
204
+ onPauseToggle: () => boolean;
205
+ getPaused: () => boolean;
206
+ }
207
+
208
+ /**
209
+ * Semantic update types - Panel handles i18n internally
210
+ */
211
+ export declare type PanelUpdate = {
212
+ type: 'thinking';
213
+ text?: string;
214
+ } | {
215
+ type: 'input';
216
+ task: string;
217
+ } | {
218
+ type: 'question';
219
+ question: string;
220
+ } | {
221
+ type: 'userAnswer';
222
+ input: string;
223
+ } | {
224
+ type: 'retry';
225
+ current: number;
226
+ max: number;
227
+ } | {
228
+ type: 'error';
229
+ message: string;
230
+ } | {
231
+ type: 'output';
232
+ text: string;
233
+ } | {
234
+ type: 'completed';
235
+ } | {
236
+ type: 'toolExecuting';
237
+ toolName: string;
238
+ args: any;
239
+ } | {
240
+ type: 'toolCompleted';
241
+ toolName: string;
242
+ args: any;
243
+ result?: string;
244
+ duration?: number;
245
+ };
246
+
247
+ export declare class SimulatorMask {
248
+ #private;
249
+ wrapper: HTMLDivElement;
250
+ motion: Motion;
251
+ constructor();
252
+ setCursorPosition(x: number, y: number): void;
253
+ triggerClickAnimation(): void;
254
+ show(): void;
255
+ hide(): void;
256
+ dispose(): void;
257
+ }
258
+
259
+ /**
260
+ * Agent execution state management
261
+ */
262
+ export declare interface Step {
263
+ id: string;
264
+ stepNumber: number;
265
+ timestamp: Date;
266
+ type: 'thinking' | 'tool_executing' | 'completed' | 'error' | 'output' | 'input' | 'retry';
267
+ toolName?: string;
268
+ toolArgs?: any;
269
+ toolResult?: any;
270
+ displayText: string;
271
+ duration?: number;
272
+ }
273
+
274
+ export declare type SupportedLanguage = keyof typeof locales;
275
+
276
+ export declare type TranslationKey = NestedKeyOf<TranslationSchema>;
277
+
278
+ declare type TranslationParams = Record<string, string | number>;
279
+
280
+ declare type TranslationSchema = DeepStringify<typeof enUS>;
281
+
282
+ export declare class UIState {
283
+ private steps;
284
+ private currentStep;
285
+ private status;
286
+ private stepCounter;
287
+ addStep(stepData: Omit<Step, 'id' | 'stepNumber' | 'timestamp'>): Step;
288
+ updateCurrentStep(updates: Partial<Step>): Step | null;
289
+ getCurrentStep(): Step | null;
290
+ getAllSteps(): Step[];
291
+ getStatus(): AgentStatus;
292
+ reset(): void;
293
+ private updateStatus;
294
+ private generateId;
295
+ }
296
+
297
+ export { }