@coolkiller007/my-page-agent 0.1.15 → 0.2.1

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.d.ts CHANGED
@@ -275,7 +275,7 @@ declare class AgentRuntime extends EventTarget {
275
275
  * 外部错误(前置检查/配置/钩子)会直接抛出;
276
276
  * Agent 内部错误会被捕获并加入历史,同时返回失败结果
277
277
  */
278
- execute(task: string): Promise<ExecutionResult>;
278
+ execute(task: string, attachments?: Attachment[]): Promise<ExecutionResult>;
279
279
  /** 销毁 Agent:中止任务、释放浏览器控制器,并触发 dispose 事件(一次性) */
280
280
  dispose(): void;
281
281
  }
@@ -323,6 +323,25 @@ declare interface AgentTool<TParams = any> {
323
323
  execute: (this: AgentRuntime, args: TParams, ctx: ToolContext) => Promise<string>;
324
324
  }
325
325
 
326
+ /**
327
+ * 用户随任务一起上传的附件(图片或文本类文件)
328
+ */
329
+ declare interface Attachment {
330
+ name: string;
331
+ mimeType: string;
332
+ dataUrl: string;
333
+ }
334
+
335
+ /**
336
+ * 用户随任务一起上传的附件(图片或文本类文件)
337
+ * @note 与 agent/types.ts 中的 Attachment 结构一致,但独立声明以保持 UI 与 Agent 解耦
338
+ */
339
+ declare interface Attachment_2 {
340
+ name: string;
341
+ mimeType: string;
342
+ dataUrl: string;
343
+ }
344
+
326
345
  /**
327
346
  * BrowserController 管理 DOM 状态和元素交互。
328
347
  * 它为所有 DOM 操作提供异步方法,并保持状态隔离。
@@ -634,6 +653,11 @@ declare const locales: {
634
653
  readonly expand: "Expand history";
635
654
  readonly collapse: "Collapse history";
636
655
  readonly step: "Step {{number}}";
656
+ readonly attachButtonTitle: "Attach files";
657
+ readonly attachTooMany: "You can attach up to {{max}} files";
658
+ readonly attachTooLarge: "\"{{name}}\" exceeds the {{maxMB}}MB size limit";
659
+ readonly attachUnsupportedType: "\"{{name}}\" is not a supported file type";
660
+ readonly attachmentsLabel: "📎 Attachments: {{names}}";
637
661
  readonly tools: {
638
662
  readonly clicking: "Clicking element [{{index}}]...";
639
663
  readonly inputting: "Inputting text to element [{{index}}]...";
@@ -678,6 +702,11 @@ declare const locales: {
678
702
  readonly expand: "展开历史";
679
703
  readonly collapse: "收起历史";
680
704
  readonly step: "步骤 {{number}}";
705
+ readonly attachButtonTitle: "添加附件";
706
+ readonly attachTooMany: "最多可添加 {{max}} 个文件";
707
+ readonly attachTooLarge: "\"{{name}}\" 超过 {{maxMB}}MB 大小限制";
708
+ readonly attachUnsupportedType: "\"{{name}}\" 不是支持的文件类型";
709
+ readonly attachmentsLabel: "📎 附件: {{names}}";
681
710
  readonly tools: {
682
711
  readonly clicking: "正在点击元素 [{{index}}]...";
683
712
  readonly inputting: "正在输入文本到元素 [{{index}}]...";
@@ -755,6 +784,7 @@ declare type SupportedLanguage_2 = keyof typeof locales;
755
784
  declare interface TaskStartEvent {
756
785
  type: 'task_start';
757
786
  task: string;
787
+ attachmentNames?: string[];
758
788
  }
759
789
 
760
790
  declare interface TextDomNode {
@@ -873,6 +903,8 @@ declare interface UIAdapter extends EventTarget {
873
903
  content?: string;
874
904
  /** 仅用于 'task_start' 类型 */
875
905
  task?: string;
906
+ /** 仅用于 'task_start' 类型 */
907
+ attachmentNames?: string[];
876
908
  /** 仅用于 'retry' 类型 */
877
909
  attempt?: number;
878
910
  maxAttempts?: number;
@@ -890,8 +922,8 @@ declare interface UIAdapter extends EventTarget {
890
922
  onAskUser?: (question: string, options?: {
891
923
  signal: AbortSignal;
892
924
  }) => Promise<string>;
893
- /** 执行一个任务 */
894
- execute(task: string): Promise<unknown>;
925
+ /** 执行一个任务;attachments 为随任务一起上传的图片/文本附件(可选) */
926
+ execute(task: string, attachments?: Attachment_2[]): Promise<unknown>;
895
927
  /** 停止当前任务(agent 仍可复用) */
896
928
  stop(): Promise<void>;
897
929
  /** 销毁 agent(终态,不可复用) */