@coolkiller007/my-page-agent 0.2.0 → 0.2.2

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
@@ -254,11 +254,20 @@ declare class AgentRuntime extends EventTarget {
254
254
  * 当 Agent 需要向用户提问时调用。
255
255
  * 若未设置,`ask_user` 工具将被禁用。
256
256
  * 实现应在 `signal` 中止时 reject 该 Promise。
257
+ * 返回值可以是纯文本回答,也可以附带回答时用户上传的附件(图片等)。
257
258
  * @example onAskUser: (q) => window.prompt(q) || ''
258
259
  */
259
260
  onAskUser?: (question: string, options?: {
260
261
  signal: AbortSignal;
261
- }) => Promise<string>;
262
+ }) => Promise<string | {
263
+ text: string;
264
+ attachments?: Attachment[];
265
+ }>;
266
+ /**
267
+ * `ask_user` 工具收到带附件的回答后暂存于此,供下一步 `#assembleUserPrompt` 注入 LLM prompt 后清空。
268
+ * 非私有字段:需要被 `tools/index.ts` 中的 `ask_user` 工具从外部写入。
269
+ */
270
+ pendingAnswerAttachments: Attachment[];
262
271
  /** 构造函数:初始化配置、LLM、工具集,并注册重试事件监听与注入自定义工具 */
263
272
  constructor(config: AgentRuntimeConfig);
264
273
  /** 获取当前 Agent 状态 */
@@ -918,10 +927,14 @@ declare interface UIAdapter extends EventTarget {
918
927
  * 如果未设置,`ask_user` 工具将被禁用。
919
928
  * UI 会设置该回调以便通过自身的界面处理用户提问。
920
929
  * 可选参数 `signal` 在任务被停止或销毁时触发中止。
930
+ * 返回值为纯文本回答,或附带回答时上传的附件(图片等)。
921
931
  */
922
932
  onAskUser?: (question: string, options?: {
923
933
  signal: AbortSignal;
924
- }) => Promise<string>;
934
+ }) => Promise<string | {
935
+ text: string;
936
+ attachments?: Attachment_2[];
937
+ }>;
925
938
  /** 执行一个任务;attachments 为随任务一起上传的图片/文本附件(可选) */
926
939
  execute(task: string, attachments?: Attachment_2[]): Promise<unknown>;
927
940
  /** 停止当前任务(agent 仍可复用) */
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function() { try { if (typeof document != "undefined") { var elementStyle = document.createElement("style"); elementStyle.appendChild(document.createTextNode("._wrapper_ur79v_1 {\n position: fixed;\n inset: 0;\n z-index: 2147483641; /* 确保在所有元素之上,除了 Agent UI */\n cursor: wait;\n overflow: hidden;\n\n display: none;\n}\n\n._wrapper_ur79v_1._visible_ur79v_11 {\n display: block;\n}\n/* AI 光标样式 */\n._cursor_eh09s_2 {\n position: absolute;\n width: var(--cursor-size, 48px);\n height: var(--cursor-size, 48px);\n pointer-events: none;\n z-index: 10000;\n}\n\n._cursorBorder_eh09s_10 {\n position: absolute;\n width: 100%;\n height: 100%;\n background: linear-gradient(45deg, rgb(57, 182, 255), rgb(189, 69, 251));\n mask-image: url(\"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201024%201024'%20fill='none'%3e%3cpath%20d='M287.232%20128l514.752%20387.008L574.912%20576l149.376%20299.52-103.04%2051.392L472.32%20628.544l-185.856%20143.424z'%20stroke='%23000000'%20stroke-width='56'%20stroke-linejoin='miter'/%3e%3c/svg%3e\");\n mask-size: 100% 100%;\n mask-repeat: no-repeat;\n margin-left: -16px;\n margin-top: -7px;\n}\n\n._cursorFilling_eh09s_22 {\n position: absolute;\n width: 100%;\n height: 100%;\n background: url(\"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201024%201024'%3e%3cpath%20d='M287.232%20128l514.752%20387.008L574.912%20576l149.376%20299.52-103.04%2051.392L472.32%20628.544l-185.856%20143.424z'%20fill='%23ffffff'/%3e%3c/svg%3e\");\n background-size: 100% 100%;\n background-repeat: no-repeat;\n margin-left: -16px;\n margin-top: -7px;\n}\n\n._cursorRipple_eh09s_33 {\n position: absolute;\n width: 100%;\n height: 100%;\n pointer-events: none;\n margin-left: -50%;\n margin-top: -50%;\n\n &::after {\n content: '';\n opacity: 0;\n position: absolute;\n inset: 0;\n border: 4px solid rgba(57, 182, 255, 1);\n border-radius: 50%;\n }\n}\n\n._cursor_eh09s_2._clicking_eh09s_51 ._cursorRipple_eh09s_33::after {\n animation: _cursor-ripple_eh09s_1 300ms ease-out forwards;\n}\n\n@keyframes _cursor-ripple_eh09s_1 {\n 0% {\n transform: scale(0);\n opacity: 1;\n }\n 100% {\n transform: scale(2);\n opacity: 0;\n }\n}\n._wrapper_194hg_1 {\n position: fixed;\n bottom: 100px;\n left: 50%;\n transform: translateX(-50%) translateY(20px);\n opacity: 0;\n z-index: 2147483642; /* 比 SimulatorMask 高一层 */\n box-sizing: border-box;\n\n /* 普通流布局:历史弹窗、面板依次纵向排列,靠子元素自身尺寸撑开,\n * 不再用 position:absolute + 手算偏移量拼位置(这套算法之前连续出过两次 bug:\n * 弹窗被状态条盖住、状态条运行态时下方角没跟着圆)。 */\n display: flex;\n flex-direction: column;\n align-items: center;\n\n * {\n box-sizing: border-box;\n }\n\n /* 宽度取窗口 40%,用 clamp 防止超窄/超宽窗口下过小或过大 */\n --width: clamp(280px, 40vw, 640px);\n --height: 40px; /* 状态条高度 */\n --input-height: 80px; /* 输入区高度 */\n --border-radius: 16px;\n\n --side-space: 12px; /* 控制栏两侧的间距 */\n --history-width: calc(var(--width) - var(--side-space) * 2);\n\n --color-1: rgb(57, 182, 255);\n --color-2: rgb(189, 69, 251);\n --color-3: rgb(255, 87, 51);\n --color-4: rgb(255, 214, 0);\n\n width: var(--width);\n\n transition:\n opacity 0.3s ease-in-out,\n transform 0.3s ease-in-out;\n\n /* 响应式设计 */\n @media (max-width: 480px) {\n width: calc(100vw - 40px);\n --width: calc(100vw - 40px);\n }\n}\n\n@keyframes _mask-running_194hg_1 {\n from {\n transform: translateX(-100%);\n }\n to {\n transform: translateX(100%);\n }\n}\n\n/* 状态条 + 输入区的外层容器;.background 光效挂在这一层,.shellInner 负责裁出圆角 */\n._shell_194hg_57 {\n position: relative;\n width: 100%;\n}\n\n._background_194hg_57 {\n position: absolute;\n inset: -2px;\n border-radius: calc(var(--border-radius) + 4px);\n filter: blur(4px);\n overflow: hidden;\n pointer-events: none;\n\n &::before {\n content: '';\n pointer-events: none;\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n\n background-image: linear-gradient(\n to bottom left,\n var(--color-1),\n var(--color-2),\n var(--color-1)\n );\n animation: _mask-running_194hg_1 2s linear infinite;\n }\n &::after {\n content: '';\n pointer-events: none;\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n\n background-image: linear-gradient(\n to bottom left,\n var(--color-2),\n var(--color-1),\n var(--color-2)\n );\n animation: _mask-running_194hg_1 2s linear infinite;\n animation-delay: 1s;\n }\n}\n\n/* 可视区域:靠 overflow:hidden + border-radius 统一裁角,\n * header 单独存在(运行中输入区隐藏)或 header+输入区一起存在时,四角都自动是圆的,\n * 不用再像以前那样给 header 写一条\"输入区隐藏时补圆角\"的特判规则。 */\n._shellInner_194hg_57 {\n position: relative;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n border-radius: var(--border-radius);\n border: 2px solid rgba(255, 255, 255, 0.4);\n box-shadow:\n 0 0 5px 1px rgba(255, 255, 255, 0.3),\n 0 4px 20px rgba(0, 0, 0, 0.5);\n}\n\n/* 控制栏 */\n._header_194hg_124 {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 8px 12px;\n user-select: none;\n\n height: var(--height);\n flex-shrink: 0; /* 防止 header 被压缩 */\n\n cursor: pointer;\n\n background: rgba(0, 0, 0, 0.5);\n backdrop-filter: blur(10px);\n background-clip: padding-box;\n\n ._statusSection_194hg_140 {\n display: flex;\n align-items: center;\n gap: 8px;\n flex: 1;\n min-height: 24px; /* 确保垂直居中 */\n\n ._indicator_194hg_147 {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: rgba(255, 255, 255, 0.5);\n flex-shrink: 0;\n animation: none; /* 默认无动画 */\n\n /* 运行状态 - 有动画 */\n &._thinking_194hg_156 {\n background: rgb(57, 182, 255);\n animation: _pulse_194hg_1 0.8s ease-in-out infinite;\n }\n\n &._tool_executing_194hg_161 {\n background: rgb(189, 69, 251);\n animation: _pulse_194hg_1 0.6s ease-in-out infinite;\n }\n\n &._retry_194hg_166 {\n background: rgb(255, 214, 0);\n animation: _retryPulse_194hg_1 1s ease-in-out infinite;\n }\n\n /* 静止状态 - 无动画 */\n &._completed_194hg_172,\n &._input_194hg_173,\n &._output_194hg_174 {\n background: rgb(34, 197, 94);\n animation: none;\n }\n\n &._error_194hg_179 {\n background: rgb(239, 68, 68);\n animation: none;\n }\n }\n\n ._statusText_194hg_185 {\n color: white;\n font-size: 12px;\n line-height: 1;\n font-weight: 500;\n transition: all 0.3s ease-in-out;\n position: relative;\n overflow: hidden;\n display: flex;\n align-items: center;\n min-height: 24px; /* 确保垂直居中 */\n\n &._fadeOut_194hg_197 {\n animation: _statusTextFadeOut_194hg_1 0.3s ease forwards;\n }\n\n &._fadeIn_194hg_201 {\n animation: _statusTextFadeIn_194hg_1 0.3s ease forwards;\n }\n }\n }\n\n ._controls_194hg_207 {\n display: flex;\n align-items: center;\n gap: 4px;\n\n ._controlButton_194hg_212 {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: rgba(255, 255, 255, 0.1);\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 12px;\n line-height: 1;\n\n &:hover {\n background: rgba(255, 255, 255, 0.2);\n }\n }\n\n ._stopButton_194hg_231 {\n background: rgba(239, 68, 68, 0.2);\n color: rgb(255, 41, 41);\n font-weight: 600;\n\n &:hover {\n background: rgba(239, 68, 68, 0.3);\n }\n }\n }\n}\n\n@keyframes _statusTextFadeIn_194hg_1 {\n 0% {\n opacity: 0;\n transform: translateY(5px);\n }\n 100% {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes _statusTextFadeOut_194hg_1 {\n 0% {\n opacity: 1;\n transform: translateY(0);\n }\n 100% {\n opacity: 0;\n transform: translateY(-5px);\n }\n}\n\n/* 历史记录弹窗:普通流里排在面板前面(视觉上在上方),默认收起为 0 高度,\n * 展开时靠 JS 量出的真实内容高度做 max-height 动画(不用固定封顶值),\n * 撑开多高、要不要出现,跟面板本身完全无关,不用再算\"面板一共多高、弹窗该挂在哪个 bottom 偏移\"。 */\n._historySectionWrapper_194hg_268 {\n width: 100%;\n overflow: hidden;\n max-height: 0;\n margin-bottom: 0;\n\n background: rgba(2, 0, 20, 0.5);\n backdrop-filter: blur(10px);\n\n text-shadow: 0 0 1px rgba(0, 0, 0, 0.2);\n\n border-radius: calc(var(--border-radius) + 4px);\n border: 0 solid rgba(255, 255, 255, 0);\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0);\n\n transition:\n max-height 0.2s,\n margin-bottom 0.2s,\n border-width 0.2s,\n border-color 0.2s,\n box-shadow 0.2s;\n\n ._wrapper_194hg_1._expanded_194hg_290 & {\n margin-bottom: 8px;\n border-width: 2px;\n border-color: rgba(255, 255, 255, 0.4);\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);\n }\n\n ._historySection_194hg_268 {\n max-height: min(\n 500px,\n calc(100vh - 200px - var(--height))\n ); /* 列表本身的滚动上限,跟展开/收起动画解耦 */\n overflow-y: auto;\n overscroll-behavior: contain;\n scrollbar-width: none;\n /* 底部留白用 padding 撑,不依赖最后一项 margin-bottom:\n * overflow:auto 容器会裁掉末尾子元素的 margin,导致最后一条记录贴底 */\n padding: 8px;\n\n ._historyItem_194hg_309 {\n /* backdrop-filter: blur(10px); */\n padding: 8px 10px;\n margin-bottom: 8px;\n background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));\n border-radius: 8px;\n border-left: 2px solid rgba(57, 182, 255, 0.5);\n font-size: 12px;\n color: white;\n /* color: black; */\n line-height: 1.3;\n position: relative;\n overflow: hidden;\n\n /* 微妙的内阴影 */\n box-shadow:\n 0 1px 0 rgba(255, 255, 255, 0.1),\n 0 1px 3px rgba(0, 0, 0, 0.1);\n\n &::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n height: 1px;\n background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);\n }\n\n &:hover {\n background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06));\n /* transform: translateY(-1px); */\n box-shadow:\n inset 0 1px 0 rgba(255, 255, 255, 0.15),\n 0 2px 4px rgba(0, 0, 0, 0.15);\n }\n\n &._completed_194hg_172,\n &._input_194hg_173,\n &._output_194hg_174 {\n border-left-color: rgb(34, 197, 94);\n background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(34, 197, 94, 0.05));\n }\n\n &._error_194hg_179 {\n border-left-color: rgb(239, 68, 68);\n background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));\n }\n\n &._retry_194hg_166 {\n border-left-color: rgb(255, 214, 0);\n background: linear-gradient(135deg, rgba(255, 214, 0, 0.1), rgba(255, 214, 0, 0.05));\n }\n\n &._observation_194hg_363 {\n border-left-color: rgb(147, 51, 234);\n background: linear-gradient(135deg, rgba(147, 51, 234, 0.1), rgba(147, 51, 234, 0.05));\n }\n\n &._question_194hg_368 {\n border-left-color: rgb(255, 159, 67);\n background: linear-gradient(135deg, rgba(255, 159, 67, 0.15), rgba(255, 159, 67, 0.08));\n }\n\n /* 突出显示 done 成功结果 */\n &._doneSuccess_194hg_374 {\n background: linear-gradient(\n 135deg,\n rgba(34, 197, 94, 0.25),\n rgba(34, 197, 94, 0.15),\n rgba(34, 197, 94, 0.08)\n );\n border: none;\n border-left: 2px solid rgb(34, 197, 94);\n box-shadow:\n 0 4px 12px rgba(34, 197, 94, 0.3),\n inset 0 1px 0 rgba(255, 255, 255, 0.2),\n 0 0 20px rgba(34, 197, 94, 0.1);\n font-weight: 600;\n color: rgb(220, 252, 231);\n padding: 10px 12px;\n margin-bottom: 8px;\n border-radius: 8px;\n position: relative;\n overflow: hidden;\n\n &::before {\n background: linear-gradient(90deg, transparent, rgba(34, 197, 94, 0.4), transparent);\n }\n\n &::after {\n content: '';\n position: absolute;\n top: 0;\n left: -100%;\n width: 100%;\n height: 100%;\n background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);\n animation: _shimmer_194hg_1 2s ease-in-out infinite;\n }\n\n ._historyContent_194hg_410 {\n ._statusIcon_194hg_411 {\n font-size: 16px;\n animation: _celebrate_194hg_1 0.8s ease-in-out;\n filter: drop-shadow(0 2px 4px rgba(34, 197, 94, 0.5));\n }\n }\n }\n\n /* 突出显示 done 失败结果 */\n &._doneError_194hg_420 {\n background: linear-gradient(\n 135deg,\n rgba(239, 68, 68, 0.25),\n rgba(239, 68, 68, 0.15),\n rgba(239, 68, 68, 0.08)\n );\n border: none;\n border-left: 2px solid rgb(239, 68, 68);\n box-shadow:\n 0 4px 12px rgba(239, 68, 68, 0.3),\n inset 0 1px 0 rgba(255, 255, 255, 0.2),\n 0 0 20px rgba(239, 68, 68, 0.1);\n font-weight: 600;\n color: rgb(254, 226, 226);\n padding: 10px 12px;\n margin-bottom: 8px;\n border-radius: 8px;\n position: relative;\n overflow: hidden;\n\n &::before {\n background: linear-gradient(90deg, transparent, rgba(239, 68, 68, 0.4), transparent);\n }\n\n ._historyContent_194hg_410 {\n ._statusIcon_194hg_411 {\n font-size: 16px;\n filter: drop-shadow(0 2px 4px rgba(239, 68, 68, 0.5));\n }\n }\n }\n\n ._historyContent_194hg_410 {\n display: flex;\n align-items: center;\n gap: 8px;\n\n word-break: break-all;\n white-space: pre-wrap;\n\n /* overflow-x: auto; */\n\n ._statusIcon_194hg_411 {\n font-size: 12px;\n flex-shrink: 0;\n line-height: 1;\n transition: all 0.3s ease;\n }\n\n ._reflectionLines_194hg_470 {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n }\n\n ._historyMeta_194hg_477 {\n font-size: 10px;\n color: rgba(255, 255, 255, 0.6);\n /* color: rgb(61, 61, 61); */\n margin-top: 8px;\n line-height: 1;\n }\n }\n }\n}\n\n/* 动画关键帧 - 更快的闪烁 */\n@keyframes _pulse_194hg_1 {\n 0%,\n 100% {\n opacity: 1;\n transform: scale(1);\n }\n 50% {\n opacity: 0.4;\n transform: scale(1.3);\n }\n}\n\n/* 重试动画 - 旋转脉冲 */\n@keyframes _retryPulse_194hg_1 {\n 0%,\n 100% {\n opacity: 1;\n transform: scale(1) rotate(0deg);\n }\n 25% {\n opacity: 0.6;\n transform: scale(1.2) rotate(90deg);\n }\n 50% {\n opacity: 0.8;\n transform: scale(1.1) rotate(180deg);\n }\n 75% {\n opacity: 0.6;\n transform: scale(1.2) rotate(270deg);\n }\n}\n\n/* 庆祝动画 */\n@keyframes _celebrate_194hg_1 {\n 0%,\n 100% {\n transform: scale(1);\n }\n 25% {\n transform: scale(1.2) rotate(-5deg);\n }\n 75% {\n transform: scale(1.2) rotate(5deg);\n }\n}\n\n/* done 卡片的光泽效果 */\n@keyframes _shimmer_194hg_1 {\n 0% {\n left: -100%;\n }\n 100% {\n left: 100%;\n }\n}\n\n/* 输入区域样式 */\n._inputSectionWrapper_194hg_547 {\n width: 100%;\n margin: 0 auto;\n\n overflow: hidden;\n max-height: 0; /* 由 JS 同步为真实内容高度(含附件条、错误提示),见 #syncInputHeight */\n\n transition: max-height 0.2s;\n\n /* 与 header 保持同色调,让面板看起来是一体的深色玻璃卡片 */\n background: rgba(0, 0, 0, 0.4);\n backdrop-filter: blur(10px);\n\n border-bottom-left-radius: calc(var(--border-radius) + 4px);\n border-bottom-right-radius: calc(var(--border-radius) + 4px);\n\n &._hidden_194hg_563 {\n max-height: 0;\n }\n\n ._inputSection_194hg_547 {\n position: relative;\n display: flex;\n align-items: center;\n height: var(--input-height);\n padding: 8px; /* 与上方状态条 padding 保持一致 */\n\n ._attachButton_194hg_574 {\n position: absolute;\n right: 14px;\n bottom: 12px;\n z-index: 1;\n width: 26px;\n height: 26px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: rgba(255, 255, 255, 0.85);\n font-size: 13px;\n line-height: 1;\n cursor: pointer;\n }\n\n ._taskInput_194hg_590 {\n flex: 1;\n height: 100%;\n background: rgba(255, 255, 255, 0.08);\n border: 1px solid rgba(255, 255, 255, 0.15);\n border-radius: 12px;\n padding: 8px 40px 8px 14px; /* 右侧留白避免文字与悬浮的附件按钮重叠 */\n color: rgb(240, 240, 245);\n font-family: inherit;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n resize: none;\n overflow-y: auto;\n transition: all 0.2s ease;\n\n &::placeholder {\n color: rgba(255, 255, 255, 0.45);\n }\n\n &:focus {\n background: rgba(255, 255, 255, 0.14);\n border-color: rgba(57, 182, 255, 0.6);\n box-shadow: 0 0 0 2px rgba(57, 182, 255, 0.2);\n }\n }\n }\n\n ._attachmentsBar_194hg_618 {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n padding: 8px 8px 0;\n\n &:empty {\n display: none;\n }\n }\n\n ._attachmentChip_194hg_629 {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n max-width: 160px;\n padding: 3px 4px 3px 8px;\n border-radius: 10px;\n background: rgba(255, 255, 255, 0.1);\n color: rgba(255, 255, 255, 0.85);\n font-size: 12px;\n white-space: nowrap;\n\n span {\n overflow: hidden;\n text-overflow: ellipsis;\n }\n }\n\n ._attachmentChipRemove_194hg_647 {\n flex-shrink: 0;\n border: none;\n background: transparent;\n color: rgba(255, 255, 255, 0.6);\n cursor: pointer;\n font-size: 13px;\n line-height: 1;\n padding: 0 4px;\n\n &:hover {\n color: rgba(255, 255, 255, 0.95);\n }\n }\n\n ._attachError_194hg_662 {\n padding: 4px 8px 0;\n color: rgb(255, 138, 138);\n font-size: 12px;\n\n &:empty {\n display: none;\n padding: 0;\n }\n }\n\n ._fileInput_194hg_673 {\n display: none;\n }\n}\n/*$vite$:1*/")); document.head.appendChild(elementStyle); } } catch (e) { console.error("vite-plugin-css-injected-by-js", e); }})();
1
+ (function() { try { if (typeof document != "undefined") { var elementStyle = document.createElement("style"); elementStyle.appendChild(document.createTextNode("._wrapper_1utdd_1 {\n position: fixed;\n inset: 0;\n z-index: 10000; /* 层级:本层(10000) < Agent UI(20000) < 图片预览(99999),上限 99999 */\n cursor: wait;\n overflow: hidden;\n\n display: none;\n}\n\n._wrapper_1utdd_1._visible_1utdd_11 {\n display: block;\n}\n/* AI 光标样式 */\n._cursor_eh09s_2 {\n position: absolute;\n width: var(--cursor-size, 48px);\n height: var(--cursor-size, 48px);\n pointer-events: none;\n z-index: 10000;\n}\n\n._cursorBorder_eh09s_10 {\n position: absolute;\n width: 100%;\n height: 100%;\n background: linear-gradient(45deg, rgb(57, 182, 255), rgb(189, 69, 251));\n mask-image: url(\"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201024%201024'%20fill='none'%3e%3cpath%20d='M287.232%20128l514.752%20387.008L574.912%20576l149.376%20299.52-103.04%2051.392L472.32%20628.544l-185.856%20143.424z'%20stroke='%23000000'%20stroke-width='56'%20stroke-linejoin='miter'/%3e%3c/svg%3e\");\n mask-size: 100% 100%;\n mask-repeat: no-repeat;\n margin-left: -16px;\n margin-top: -7px;\n}\n\n._cursorFilling_eh09s_22 {\n position: absolute;\n width: 100%;\n height: 100%;\n background: url(\"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201024%201024'%3e%3cpath%20d='M287.232%20128l514.752%20387.008L574.912%20576l149.376%20299.52-103.04%2051.392L472.32%20628.544l-185.856%20143.424z'%20fill='%23ffffff'/%3e%3c/svg%3e\");\n background-size: 100% 100%;\n background-repeat: no-repeat;\n margin-left: -16px;\n margin-top: -7px;\n}\n\n._cursorRipple_eh09s_33 {\n position: absolute;\n width: 100%;\n height: 100%;\n pointer-events: none;\n margin-left: -50%;\n margin-top: -50%;\n\n &::after {\n content: '';\n opacity: 0;\n position: absolute;\n inset: 0;\n border: 4px solid rgba(57, 182, 255, 1);\n border-radius: 50%;\n }\n}\n\n._cursor_eh09s_2._clicking_eh09s_51 ._cursorRipple_eh09s_33::after {\n animation: _cursor-ripple_eh09s_1 300ms ease-out forwards;\n}\n\n@keyframes _cursor-ripple_eh09s_1 {\n 0% {\n transform: scale(0);\n opacity: 1;\n }\n 100% {\n transform: scale(2);\n opacity: 0;\n }\n}\n._wrapper_1svu5_1 {\n position: fixed;\n bottom: 100px;\n left: 50%;\n transform: translateX(-50%) translateY(20px);\n opacity: 0;\n z-index: 20000; /* 层级:SimulatorMask(10000) < 本层(20000),上限 99999 */\n box-sizing: border-box;\n\n /* 普通流布局:历史弹窗、面板依次纵向排列,靠子元素自身尺寸撑开,\n * 不再用 position:absolute + 手算偏移量拼位置(这套算法之前连续出过两次 bug:\n * 弹窗被状态条盖住、状态条运行态时下方角没跟着圆)。 */\n display: flex;\n flex-direction: column;\n align-items: center;\n\n * {\n box-sizing: border-box;\n }\n\n /* 宽度取窗口 40%,用 clamp 防止超窄/超宽窗口下过小或过大 */\n --width: clamp(280px, 40vw, 640px);\n --height: 40px; /* 状态条高度 */\n --input-height: 80px; /* 输入区高度 */\n --border-radius: 16px;\n\n --side-space: 12px; /* 控制栏两侧的间距 */\n --history-width: calc(var(--width) - var(--side-space) * 2);\n\n --color-1: rgb(57, 182, 255);\n --color-2: rgb(189, 69, 251);\n --color-3: rgb(255, 87, 51);\n --color-4: rgb(255, 214, 0);\n\n width: var(--width);\n\n transition:\n opacity 0.3s ease-in-out,\n transform 0.3s ease-in-out;\n\n /* 响应式设计 */\n @media (max-width: 480px) {\n width: calc(100vw - 40px);\n --width: calc(100vw - 40px);\n }\n}\n\n@keyframes _mask-running_1svu5_1 {\n from {\n transform: translateX(-100%);\n }\n to {\n transform: translateX(100%);\n }\n}\n\n/* 状态条 + 输入区的外层容器;.background 光效挂在这一层,.shellInner 负责裁出圆角 */\n._shell_1svu5_57 {\n position: relative;\n width: 100%;\n}\n\n._background_1svu5_57 {\n position: absolute;\n inset: -2px;\n border-radius: calc(var(--border-radius) + 4px);\n filter: blur(4px);\n overflow: hidden;\n pointer-events: none;\n\n &::before {\n content: '';\n pointer-events: none;\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n\n background-image: linear-gradient(\n to bottom left,\n var(--color-1),\n var(--color-2),\n var(--color-1)\n );\n animation: _mask-running_1svu5_1 2s linear infinite;\n }\n &::after {\n content: '';\n pointer-events: none;\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n\n background-image: linear-gradient(\n to bottom left,\n var(--color-2),\n var(--color-1),\n var(--color-2)\n );\n animation: _mask-running_1svu5_1 2s linear infinite;\n animation-delay: 1s;\n }\n}\n\n/* 可视区域:靠 overflow:hidden + border-radius 统一裁角,\n * header 单独存在(运行中输入区隐藏)或 header+输入区一起存在时,四角都自动是圆的,\n * 不用再像以前那样给 header 写一条\"输入区隐藏时补圆角\"的特判规则。 */\n._shellInner_1svu5_57 {\n position: relative;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n border-radius: var(--border-radius);\n border: 2px solid rgba(255, 255, 255, 0.4);\n box-shadow:\n 0 0 5px 1px rgba(255, 255, 255, 0.3),\n 0 4px 20px rgba(0, 0, 0, 0.5);\n}\n\n/* 控制栏 */\n._header_1svu5_124 {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 8px 12px;\n user-select: none;\n\n height: var(--height);\n flex-shrink: 0; /* 防止 header 被压缩 */\n\n cursor: pointer;\n\n background: rgba(0, 0, 0, 0.5);\n backdrop-filter: blur(10px);\n background-clip: padding-box;\n\n ._statusSection_1svu5_140 {\n display: flex;\n align-items: center;\n gap: 8px;\n flex: 1;\n min-height: 24px; /* 确保垂直居中 */\n\n ._indicator_1svu5_147 {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: rgba(255, 255, 255, 0.5);\n flex-shrink: 0;\n animation: none; /* 默认无动画 */\n\n /* 运行状态 - 有动画 */\n &._thinking_1svu5_156 {\n background: rgb(57, 182, 255);\n animation: _pulse_1svu5_1 0.8s ease-in-out infinite;\n }\n\n &._tool_executing_1svu5_161 {\n background: rgb(189, 69, 251);\n animation: _pulse_1svu5_1 0.6s ease-in-out infinite;\n }\n\n &._retry_1svu5_166 {\n background: rgb(255, 214, 0);\n animation: _retryPulse_1svu5_1 1s ease-in-out infinite;\n }\n\n /* 静止状态 - 无动画 */\n &._completed_1svu5_172,\n &._input_1svu5_173,\n &._output_1svu5_174 {\n background: rgb(34, 197, 94);\n animation: none;\n }\n\n &._error_1svu5_179 {\n background: rgb(239, 68, 68);\n animation: none;\n }\n }\n\n ._statusText_1svu5_185 {\n color: white;\n font-size: 12px;\n line-height: 1;\n font-weight: 500;\n transition: all 0.3s ease-in-out;\n position: relative;\n overflow: hidden;\n display: flex;\n align-items: center;\n min-height: 24px; /* 确保垂直居中 */\n\n &._fadeOut_1svu5_197 {\n animation: _statusTextFadeOut_1svu5_1 0.3s ease forwards;\n }\n\n &._fadeIn_1svu5_201 {\n animation: _statusTextFadeIn_1svu5_1 0.3s ease forwards;\n }\n }\n }\n\n ._controls_1svu5_207 {\n display: flex;\n align-items: center;\n gap: 4px;\n\n ._controlButton_1svu5_212 {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: rgba(255, 255, 255, 0.1);\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 12px;\n line-height: 1;\n\n &:hover {\n background: rgba(255, 255, 255, 0.2);\n }\n }\n\n ._stopButton_1svu5_231 {\n background: rgba(239, 68, 68, 0.2);\n color: rgb(255, 41, 41);\n font-weight: 600;\n\n &:hover {\n background: rgba(239, 68, 68, 0.3);\n }\n }\n }\n}\n\n@keyframes _statusTextFadeIn_1svu5_1 {\n 0% {\n opacity: 0;\n transform: translateY(5px);\n }\n 100% {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes _statusTextFadeOut_1svu5_1 {\n 0% {\n opacity: 1;\n transform: translateY(0);\n }\n 100% {\n opacity: 0;\n transform: translateY(-5px);\n }\n}\n\n/* 历史记录弹窗:普通流里排在面板前面(视觉上在上方),默认收起为 0 高度,\n * 展开时靠 JS 量出的真实内容高度做 max-height 动画(不用固定封顶值),\n * 撑开多高、要不要出现,跟面板本身完全无关,不用再算\"面板一共多高、弹窗该挂在哪个 bottom 偏移\"。 */\n._historySectionWrapper_1svu5_268 {\n width: 100%;\n overflow: hidden;\n max-height: 0;\n margin-bottom: 0;\n\n background: rgba(2, 0, 20, 0.5);\n backdrop-filter: blur(10px);\n\n text-shadow: 0 0 1px rgba(0, 0, 0, 0.2);\n\n border-radius: calc(var(--border-radius) + 4px);\n border: 0 solid rgba(255, 255, 255, 0);\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0);\n\n transition:\n max-height 0.2s,\n margin-bottom 0.2s,\n border-width 0.2s,\n border-color 0.2s,\n box-shadow 0.2s;\n\n ._wrapper_1svu5_1._expanded_1svu5_290 & {\n margin-bottom: 8px;\n border-width: 2px;\n border-color: rgba(255, 255, 255, 0.4);\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);\n }\n\n ._historySection_1svu5_268 {\n max-height: min(\n 500px,\n calc(100vh - 200px - var(--height))\n ); /* 列表本身的滚动上限,跟展开/收起动画解耦 */\n overflow-y: auto;\n overscroll-behavior: contain;\n scrollbar-width: none;\n /* 底部留白用 padding 撑,不依赖最后一项 margin-bottom:\n * overflow:auto 容器会裁掉末尾子元素的 margin,导致最后一条记录贴底 */\n padding: 8px;\n\n ._historyItem_1svu5_309 {\n /* backdrop-filter: blur(10px); */\n padding: 8px 10px;\n margin-bottom: 8px;\n background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));\n border-radius: 8px;\n border-left: 2px solid rgba(57, 182, 255, 0.5);\n font-size: 12px;\n color: white;\n /* color: black; */\n line-height: 1.3;\n position: relative;\n overflow: hidden;\n\n /* 微妙的内阴影 */\n box-shadow:\n 0 1px 0 rgba(255, 255, 255, 0.1),\n 0 1px 3px rgba(0, 0, 0, 0.1);\n\n &::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n height: 1px;\n background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);\n }\n\n &:hover {\n background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06));\n /* transform: translateY(-1px); */\n box-shadow:\n inset 0 1px 0 rgba(255, 255, 255, 0.15),\n 0 2px 4px rgba(0, 0, 0, 0.15);\n }\n\n &._completed_1svu5_172,\n &._input_1svu5_173,\n &._output_1svu5_174 {\n border-left-color: rgb(34, 197, 94);\n background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(34, 197, 94, 0.05));\n }\n\n &._error_1svu5_179 {\n border-left-color: rgb(239, 68, 68);\n background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));\n }\n\n &._retry_1svu5_166 {\n border-left-color: rgb(255, 214, 0);\n background: linear-gradient(135deg, rgba(255, 214, 0, 0.1), rgba(255, 214, 0, 0.05));\n }\n\n &._observation_1svu5_363 {\n border-left-color: rgb(147, 51, 234);\n background: linear-gradient(135deg, rgba(147, 51, 234, 0.1), rgba(147, 51, 234, 0.05));\n }\n\n &._question_1svu5_368 {\n border-left-color: rgb(255, 159, 67);\n background: linear-gradient(135deg, rgba(255, 159, 67, 0.15), rgba(255, 159, 67, 0.08));\n }\n\n /* 突出显示 done 成功结果 */\n &._doneSuccess_1svu5_374 {\n background: linear-gradient(\n 135deg,\n rgba(34, 197, 94, 0.25),\n rgba(34, 197, 94, 0.15),\n rgba(34, 197, 94, 0.08)\n );\n border: none;\n border-left: 2px solid rgb(34, 197, 94);\n box-shadow:\n 0 4px 12px rgba(34, 197, 94, 0.3),\n inset 0 1px 0 rgba(255, 255, 255, 0.2),\n 0 0 20px rgba(34, 197, 94, 0.1);\n font-weight: 600;\n color: rgb(220, 252, 231);\n padding: 10px 12px;\n margin-bottom: 8px;\n border-radius: 8px;\n position: relative;\n overflow: hidden;\n\n &::before {\n background: linear-gradient(90deg, transparent, rgba(34, 197, 94, 0.4), transparent);\n }\n\n &::after {\n content: '';\n position: absolute;\n top: 0;\n left: -100%;\n width: 100%;\n height: 100%;\n background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);\n animation: _shimmer_1svu5_1 2s ease-in-out infinite;\n }\n\n ._historyContent_1svu5_410 {\n ._statusIcon_1svu5_411 {\n font-size: 16px;\n animation: _celebrate_1svu5_1 0.8s ease-in-out;\n filter: drop-shadow(0 2px 4px rgba(34, 197, 94, 0.5));\n }\n }\n }\n\n /* 突出显示 done 失败结果 */\n &._doneError_1svu5_420 {\n background: linear-gradient(\n 135deg,\n rgba(239, 68, 68, 0.25),\n rgba(239, 68, 68, 0.15),\n rgba(239, 68, 68, 0.08)\n );\n border: none;\n border-left: 2px solid rgb(239, 68, 68);\n box-shadow:\n 0 4px 12px rgba(239, 68, 68, 0.3),\n inset 0 1px 0 rgba(255, 255, 255, 0.2),\n 0 0 20px rgba(239, 68, 68, 0.1);\n font-weight: 600;\n color: rgb(254, 226, 226);\n padding: 10px 12px;\n margin-bottom: 8px;\n border-radius: 8px;\n position: relative;\n overflow: hidden;\n\n &::before {\n background: linear-gradient(90deg, transparent, rgba(239, 68, 68, 0.4), transparent);\n }\n\n ._historyContent_1svu5_410 {\n ._statusIcon_1svu5_411 {\n font-size: 16px;\n filter: drop-shadow(0 2px 4px rgba(239, 68, 68, 0.5));\n }\n }\n }\n\n ._historyContent_1svu5_410 {\n display: flex;\n align-items: center;\n gap: 8px;\n\n word-break: break-all;\n white-space: pre-wrap;\n\n /* overflow-x: auto; */\n\n ._statusIcon_1svu5_411 {\n font-size: 12px;\n flex-shrink: 0;\n line-height: 1;\n transition: all 0.3s ease;\n }\n\n ._reflectionLines_1svu5_470 {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n }\n\n ._historyMeta_1svu5_477 {\n font-size: 10px;\n color: rgba(255, 255, 255, 0.6);\n /* color: rgb(61, 61, 61); */\n margin-top: 8px;\n line-height: 1;\n }\n }\n }\n}\n\n/* 动画关键帧 - 更快的闪烁 */\n@keyframes _pulse_1svu5_1 {\n 0%,\n 100% {\n opacity: 1;\n transform: scale(1);\n }\n 50% {\n opacity: 0.4;\n transform: scale(1.3);\n }\n}\n\n/* 重试动画 - 旋转脉冲 */\n@keyframes _retryPulse_1svu5_1 {\n 0%,\n 100% {\n opacity: 1;\n transform: scale(1) rotate(0deg);\n }\n 25% {\n opacity: 0.6;\n transform: scale(1.2) rotate(90deg);\n }\n 50% {\n opacity: 0.8;\n transform: scale(1.1) rotate(180deg);\n }\n 75% {\n opacity: 0.6;\n transform: scale(1.2) rotate(270deg);\n }\n}\n\n/* 庆祝动画 */\n@keyframes _celebrate_1svu5_1 {\n 0%,\n 100% {\n transform: scale(1);\n }\n 25% {\n transform: scale(1.2) rotate(-5deg);\n }\n 75% {\n transform: scale(1.2) rotate(5deg);\n }\n}\n\n/* done 卡片的光泽效果 */\n@keyframes _shimmer_1svu5_1 {\n 0% {\n left: -100%;\n }\n 100% {\n left: 100%;\n }\n}\n\n/* 输入区域样式 */\n._inputSectionWrapper_1svu5_547 {\n width: 100%;\n margin: 0 auto;\n\n overflow: hidden;\n max-height: 0; /* 由 JS 同步为真实内容高度(含附件条、错误提示),见 #syncInputHeight */\n\n transition: max-height 0.2s;\n\n /* 与 header 保持同色调,让面板看起来是一体的深色玻璃卡片 */\n background: rgba(0, 0, 0, 0.4);\n backdrop-filter: blur(10px);\n\n border-bottom-left-radius: calc(var(--border-radius) + 4px);\n border-bottom-right-radius: calc(var(--border-radius) + 4px);\n\n &._hidden_1svu5_563 {\n max-height: 0;\n }\n\n ._inputSection_1svu5_547 {\n position: relative;\n display: flex;\n align-items: center;\n height: var(--input-height);\n padding: 8px; /* 与上方状态条 padding 保持一致 */\n\n ._attachButton_1svu5_574 {\n position: absolute;\n right: 14px;\n bottom: 12px;\n z-index: 1;\n width: 26px;\n height: 26px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: rgba(255, 255, 255, 0.85);\n font-size: 13px;\n line-height: 1;\n cursor: pointer;\n }\n\n ._taskInput_1svu5_590 {\n flex: 1;\n height: 100%;\n background: rgba(255, 255, 255, 0.08);\n border: 1px solid rgba(255, 255, 255, 0.15);\n border-radius: 12px;\n padding: 8px 40px 8px 14px; /* 右侧留白避免文字与悬浮的附件按钮重叠 */\n color: rgb(240, 240, 245);\n font-family: inherit;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n resize: none;\n overflow-y: auto;\n transition: all 0.2s ease;\n\n &::placeholder {\n color: rgba(255, 255, 255, 0.45);\n }\n\n &:focus {\n background: rgba(255, 255, 255, 0.14);\n border-color: rgba(57, 182, 255, 0.6);\n box-shadow: 0 0 0 2px rgba(57, 182, 255, 0.2);\n }\n }\n }\n\n ._attachmentsBar_1svu5_618 {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n padding: 8px 8px 0;\n\n &:empty {\n display: none;\n }\n }\n\n ._attachmentChip_1svu5_629 {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n max-width: 160px;\n padding: 3px 4px 3px 8px;\n border-radius: 10px;\n background: rgba(255, 255, 255, 0.1);\n color: rgba(255, 255, 255, 0.85);\n font-size: 12px;\n white-space: nowrap;\n\n span {\n overflow: hidden;\n text-overflow: ellipsis;\n }\n }\n\n ._attachmentChipRemove_1svu5_647 {\n flex-shrink: 0;\n border: none;\n background: transparent;\n color: rgba(255, 255, 255, 0.6);\n cursor: pointer;\n font-size: 13px;\n line-height: 1;\n padding: 0 4px;\n\n &:hover {\n color: rgba(255, 255, 255, 0.95);\n }\n }\n\n ._attachError_1svu5_662 {\n padding: 4px 8px 0;\n color: rgb(255, 138, 138);\n font-size: 12px;\n\n &:empty {\n display: none;\n padding: 0;\n }\n }\n\n ._fileInput_1svu5_673 {\n display: none;\n }\n}\n/*$vite$:1*/")); document.head.appendChild(elementStyle); } } catch (e) { console.error("vite-plugin-css-injected-by-js", e); }})();
2
2
  import { Motion } from "ai-motion";
3
3
  import * as z from "zod/v4";
4
4
  //#region \0rolldown/runtime.js
@@ -555,7 +555,7 @@ var dom_tree_default = (args = {
555
555
  /**
556
556
  * @edit smaller zIndex for highlight
557
557
  */
558
- container.style.zIndex = "2147483640";
558
+ container.style.zIndex = "5000";
559
559
  container.style.backgroundColor = "transparent";
560
560
  document.body.appendChild(container);
561
561
  }
@@ -1954,8 +1954,8 @@ var init_checkDarkMode = __esmMin((() => {}));
1954
1954
  //#region src/browser/visual/SimulatorMask.module.css
1955
1955
  var wrapper$1, visible, SimulatorMask_module_default;
1956
1956
  var init_SimulatorMask_module = __esmMin((() => {
1957
- wrapper$1 = "_wrapper_ur79v_1";
1958
- visible = "_visible_ur79v_11";
1957
+ wrapper$1 = "_wrapper_1utdd_1";
1958
+ visible = "_visible_1utdd_11";
1959
1959
  SimulatorMask_module_default = {
1960
1960
  wrapper: wrapper$1,
1961
1961
  visible
@@ -2565,8 +2565,8 @@ var locales = {
2565
2565
  var I18n = class {
2566
2566
  language;
2567
2567
  translations;
2568
- constructor(language = "en-US") {
2569
- this.language = language in locales ? language : "en-US";
2568
+ constructor(language = "zh-CN") {
2569
+ this.language = language in locales ? language : "zh-CN";
2570
2570
  this.translations = locales[this.language];
2571
2571
  }
2572
2572
  t(key, params) {
@@ -2607,55 +2607,55 @@ function escapeHtml(text) {
2607
2607
  return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
2608
2608
  }
2609
2609
  var UI_module_default = {
2610
- wrapper: "_wrapper_194hg_1",
2611
- shell: "_shell_194hg_57",
2612
- background: "_background_194hg_57",
2613
- "mask-running": "_mask-running_194hg_1",
2614
- shellInner: "_shellInner_194hg_57",
2615
- header: "_header_194hg_124",
2616
- pulse: "_pulse_194hg_1",
2617
- retryPulse: "_retryPulse_194hg_1",
2618
- statusTextFadeOut: "_statusTextFadeOut_194hg_1",
2619
- statusTextFadeIn: "_statusTextFadeIn_194hg_1",
2620
- statusSection: "_statusSection_194hg_140",
2621
- indicator: "_indicator_194hg_147",
2622
- thinking: "_thinking_194hg_156",
2623
- tool_executing: "_tool_executing_194hg_161",
2624
- retry: "_retry_194hg_166",
2625
- completed: "_completed_194hg_172",
2626
- input: "_input_194hg_173",
2627
- output: "_output_194hg_174",
2628
- error: "_error_194hg_179",
2629
- statusText: "_statusText_194hg_185",
2630
- fadeOut: "_fadeOut_194hg_197",
2631
- fadeIn: "_fadeIn_194hg_201",
2632
- controls: "_controls_194hg_207",
2633
- controlButton: "_controlButton_194hg_212",
2634
- stopButton: "_stopButton_194hg_231",
2635
- historySectionWrapper: "_historySectionWrapper_194hg_268",
2636
- shimmer: "_shimmer_194hg_1",
2637
- celebrate: "_celebrate_194hg_1",
2638
- expanded: "_expanded_194hg_290",
2639
- historySection: "_historySection_194hg_268",
2640
- historyItem: "_historyItem_194hg_309",
2641
- observation: "_observation_194hg_363",
2642
- question: "_question_194hg_368",
2643
- doneSuccess: "_doneSuccess_194hg_374",
2644
- historyContent: "_historyContent_194hg_410",
2645
- statusIcon: "_statusIcon_194hg_411",
2646
- doneError: "_doneError_194hg_420",
2647
- reflectionLines: "_reflectionLines_194hg_470",
2648
- historyMeta: "_historyMeta_194hg_477",
2649
- inputSectionWrapper: "_inputSectionWrapper_194hg_547",
2650
- hidden: "_hidden_194hg_563",
2651
- inputSection: "_inputSection_194hg_547",
2652
- attachButton: "_attachButton_194hg_574",
2653
- taskInput: "_taskInput_194hg_590",
2654
- attachmentsBar: "_attachmentsBar_194hg_618",
2655
- attachmentChip: "_attachmentChip_194hg_629",
2656
- attachmentChipRemove: "_attachmentChipRemove_194hg_647",
2657
- attachError: "_attachError_194hg_662",
2658
- fileInput: "_fileInput_194hg_673"
2610
+ wrapper: "_wrapper_1svu5_1",
2611
+ shell: "_shell_1svu5_57",
2612
+ background: "_background_1svu5_57",
2613
+ "mask-running": "_mask-running_1svu5_1",
2614
+ shellInner: "_shellInner_1svu5_57",
2615
+ header: "_header_1svu5_124",
2616
+ pulse: "_pulse_1svu5_1",
2617
+ retryPulse: "_retryPulse_1svu5_1",
2618
+ statusTextFadeOut: "_statusTextFadeOut_1svu5_1",
2619
+ statusTextFadeIn: "_statusTextFadeIn_1svu5_1",
2620
+ statusSection: "_statusSection_1svu5_140",
2621
+ indicator: "_indicator_1svu5_147",
2622
+ thinking: "_thinking_1svu5_156",
2623
+ tool_executing: "_tool_executing_1svu5_161",
2624
+ retry: "_retry_1svu5_166",
2625
+ completed: "_completed_1svu5_172",
2626
+ input: "_input_1svu5_173",
2627
+ output: "_output_1svu5_174",
2628
+ error: "_error_1svu5_179",
2629
+ statusText: "_statusText_1svu5_185",
2630
+ fadeOut: "_fadeOut_1svu5_197",
2631
+ fadeIn: "_fadeIn_1svu5_201",
2632
+ controls: "_controls_1svu5_207",
2633
+ controlButton: "_controlButton_1svu5_212",
2634
+ stopButton: "_stopButton_1svu5_231",
2635
+ historySectionWrapper: "_historySectionWrapper_1svu5_268",
2636
+ shimmer: "_shimmer_1svu5_1",
2637
+ celebrate: "_celebrate_1svu5_1",
2638
+ expanded: "_expanded_1svu5_290",
2639
+ historySection: "_historySection_1svu5_268",
2640
+ historyItem: "_historyItem_1svu5_309",
2641
+ observation: "_observation_1svu5_363",
2642
+ question: "_question_1svu5_368",
2643
+ doneSuccess: "_doneSuccess_1svu5_374",
2644
+ historyContent: "_historyContent_1svu5_410",
2645
+ statusIcon: "_statusIcon_1svu5_411",
2646
+ doneError: "_doneError_1svu5_420",
2647
+ reflectionLines: "_reflectionLines_1svu5_470",
2648
+ historyMeta: "_historyMeta_1svu5_477",
2649
+ inputSectionWrapper: "_inputSectionWrapper_1svu5_547",
2650
+ hidden: "_hidden_1svu5_563",
2651
+ inputSection: "_inputSection_1svu5_547",
2652
+ attachButton: "_attachButton_1svu5_574",
2653
+ taskInput: "_taskInput_1svu5_590",
2654
+ attachmentsBar: "_attachmentsBar_1svu5_618",
2655
+ attachmentChip: "_attachmentChip_1svu5_629",
2656
+ attachmentChipRemove: "_attachmentChipRemove_1svu5_647",
2657
+ attachError: "_attachError_1svu5_662",
2658
+ fileInput: "_fileInput_1svu5_673"
2659
2659
  };
2660
2660
  //#endregion
2661
2661
  //#region src/ui/cards.ts
@@ -2731,6 +2731,7 @@ var UI = class {
2731
2731
  #userAnswerAbortHandler = null;
2732
2732
  #isWaitingForUserAnswer = false;
2733
2733
  #pendingAttachments = [];
2734
+ #lastSubmission = null;
2734
2735
  #headerUpdateTimer = null;
2735
2736
  #timers = /* @__PURE__ */ new Set();
2736
2737
  #pendingHeaderText = null;
@@ -2753,7 +2754,7 @@ var UI = class {
2753
2754
  constructor(agent, config = {}) {
2754
2755
  this.#agent = agent;
2755
2756
  this.#config = config;
2756
- this.#i18n = new I18n(config.language ?? "en-US");
2757
+ this.#i18n = new I18n(config.language ?? "zh-CN");
2757
2758
  this.#agent.onAskUser = this.#askUserCallback;
2758
2759
  this.#wrapper = this.#createWrapper();
2759
2760
  this.#indicator = this.#wrapper.querySelector(`.${UI_module_default.indicator}`);
@@ -2910,6 +2911,9 @@ var UI = class {
2910
2911
  this.#updateStatusIndicator("thinking");
2911
2912
  this.#renderHistory();
2912
2913
  this.#collapse();
2914
+ this.#pendingAttachments = [];
2915
+ this.#renderAttachments();
2916
+ this.#setAttachError("");
2913
2917
  this.#showInputArea();
2914
2918
  }
2915
2919
  /** 展开历史弹窗(公开方法) */
@@ -2971,6 +2975,10 @@ var UI = class {
2971
2975
  return;
2972
2976
  }
2973
2977
  const attachments = this.#pendingAttachments;
2978
+ this.#lastSubmission = {
2979
+ task: input,
2980
+ attachments
2981
+ };
2974
2982
  this.#pendingAttachments = [];
2975
2983
  this.#renderAttachments();
2976
2984
  this.#setAttachError("");
@@ -2981,14 +2989,28 @@ var UI = class {
2981
2989
  };
2982
2990
  (attachments.length > 0 ? this.#agent.execute(input, attachments) : this.#agent.execute(input)).catch(onExecuteError);
2983
2991
  }
2992
+ /** 将上一次提交的文本和附件回填到输入框,供 ↑ 键触发 */
2993
+ #restoreLastSubmission() {
2994
+ const last = this.#lastSubmission;
2995
+ if (!last) return;
2996
+ this.#taskInput.value = last.task;
2997
+ this.#pendingAttachments = [...last.attachments];
2998
+ this.#renderAttachments();
2999
+ }
2984
3000
  /**
2985
- * 处理用户回答
3001
+ * 处理用户回答;若回答时附带了附件,一并传给 resolve 回调
2986
3002
  */
2987
3003
  #handleUserAnswer(input) {
2988
3004
  this.#removeTempCards();
3005
+ const attachments = this.#pendingAttachments;
3006
+ this.#pendingAttachments = [];
3007
+ this.#renderAttachments();
2989
3008
  const resolve = this.#userAnswerResolver;
2990
3009
  this.#clearQuestionState();
2991
- resolve?.(input);
3010
+ resolve?.(attachments.length > 0 ? {
3011
+ text: input,
3012
+ attachments
3013
+ } : input);
2992
3014
  }
2993
3015
  /**
2994
3016
  * 显示输入区域
@@ -2997,7 +3019,6 @@ var UI = class {
2997
3019
  this.#taskInput.value = "";
2998
3020
  this.#taskInput.placeholder = placeholder || this.#i18n.t("ui.taskInput");
2999
3021
  this.#inputSection.classList.remove(UI_module_default.hidden);
3000
- this.#attachButton.style.display = this.#isWaitingForUserAnswer ? "none" : "";
3001
3022
  this.#syncInputHeight();
3002
3023
  this.#setTimer(() => {
3003
3024
  this.#taskInput.focus();
@@ -3181,6 +3202,9 @@ var UI = class {
3181
3202
  if (e.key === "Enter" && !e.shiftKey) {
3182
3203
  e.preventDefault();
3183
3204
  this.#submitTask();
3205
+ } else if (e.key === "ArrowUp" && !this.#isWaitingForUserAnswer && this.#lastSubmission) {
3206
+ e.preventDefault();
3207
+ this.#restoreLastSubmission();
3184
3208
  }
3185
3209
  });
3186
3210
  this.#inputSection.addEventListener("click", (e) => {
@@ -3194,6 +3218,12 @@ var UI = class {
3194
3218
  if (files?.length) this.#handleFileSelection(files);
3195
3219
  this.#fileInput.value = "";
3196
3220
  });
3221
+ this.#taskInput.addEventListener("paste", (e) => {
3222
+ const files = e.clipboardData?.files;
3223
+ if (!files?.length) return;
3224
+ e.preventDefault();
3225
+ this.#handleFileSelection(files);
3226
+ });
3197
3227
  this.#attachmentsBar.addEventListener("click", (e) => {
3198
3228
  const removeButton = e.target.closest(`.${UI_module_default.attachmentChipRemove}`);
3199
3229
  if (!(removeButton instanceof HTMLElement)) return;
@@ -3891,7 +3921,7 @@ function parseLLMConfig(config) {
3891
3921
  }
3892
3922
  //#endregion
3893
3923
  //#region src/agent/prompts/system_prompt.md?raw
3894
- var system_prompt_default = "You are an AI agent designed to operate in an iterative loop to automate browser tasks. Your ultimate goal is accomplishing the task provided in <user_request>.\n\n<intro>\nYou excel at following tasks:\n1. Navigating complex websites and extracting precise information\n2. Automating form submissions and interactive web actions\n3. Gathering and saving information \n4. Operate effectively in an agent loop\n5. Efficiently performing diverse web tasks\n</intro>\n\n<language_settings>\n- Default working language: **English**\n- Use the language that user is using. Return in user's language.\n</language_settings>\n\n<input>\nAt every step, your input will consist of: \n1. <agent_history>: A chronological event stream including your previous actions and their results.\n2. <agent_state>: Current <user_request> and <step_info>.\n3. <browser_state>: Current URL, interactive elements indexed for actions, and visible page content.\n</input>\n\n<agent_history>\nAgent history will be given as a list of step information as follows:\n\n<step_{step_number}>:\nEvaluation of Previous Step: Assessment of last action\nMemory: Your memory of this step\nNext Goal: Your goal for this step\nAction Results: Your actions and their results\n</step_{step_number}>\n\nand system messages wrapped in <sys> tag.\n</agent_history>\n\n<user_request>\nUSER REQUEST: This is your ultimate objective and always remains visible.\n- This has the highest priority. Make the user happy.\n- If the user request is very specific - then carefully follow each step and don't skip or hallucinate steps.\n- If the task is open ended you can plan yourself how to get it done.\n</user_request>\n\n<browser_state>\n1. Browser State will be given as:\n\nCurrent URL: URL of the page you are currently viewing.\nInteractive Elements: All interactive elements will be provided in format as [index]<type>text</type> where\n- index: Numeric identifier for interaction\n- type: HTML element type (button, input, etc.)\n- text: Element description\n\nExamples:\n[33]<div>User form</div>\n\\t*[35]<button aria-label='Submit form'>Submit</button>\n\nNote that:\n- Only elements with numeric indexes in [] are interactive\n- (stacked) indentation (with \\t) is important and means that the element is a (html) child of the element above (with a lower index)\n- Elements tagged with `*[` are the new clickable elements that appeared on the website since the last step - if url has not changed.\n- Pure text elements without [] are not interactive.\n</browser_state>\n\n<browser_rules>\nStrictly follow these rules while using the browser and navigating the web:\n- Only interact with elements that have a numeric [index] assigned.\n- Only use indexes that are explicitly provided.\n- If the page changes after, for example, an input text action, analyze if you need to interact with new elements, e.g. selecting the right option from the list.\n- By default, only elements in the visible viewport are listed. Use scrolling actions if you suspect relevant content is offscreen which you need to interact with. Scroll ONLY if there are more pixels below or above the page.\n- You can scroll by a specific number of pages using the num_pages parameter (e.g., 0.5 for half page, 2.0 for two pages).\n- All the elements that are scrollable are marked with `data-scrollable` attribute. Including the scrollable distance in every directions. You can scroll *the element* in case some area are overflowed.\n- If a captcha appears, tell user you can not solve captcha. Finish the task and ask user to solve it.\n- If the page is not fully loaded, use the `wait` action.\n- Do not repeat one action for more than 3 times unless some conditions changed.\n- If you fill an input field and your action sequence is interrupted, most often something changed e.g. suggestions popped up under the field.\n- If the <user_request> includes specific page information such as product type, rating, price, location, etc., try to apply filters to be more efficient.\n- The <user_request> is the ultimate goal. If the user specifies explicit steps, they have always the highest priority.\n- If you input_text into a field, you might need to press enter, click the search button, or select from dropdown for completion.\n- Don't login into a page if you don't have to. Don't login if you don't have the credentials. \n- There are 2 types of tasks always first think which type of request you are dealing with:\n1. Very specific step by step instructions:\n- Follow them as very precise and don't skip steps. Try to complete everything as requested.\n2. Open ended tasks. Plan yourself, be creative in achieving them.\n- If you get stuck e.g. with logins or captcha in open-ended tasks you can re-evaluate the task and try alternative ways, e.g. sometimes accidentally login pops up, even though there some part of the page is accessible or you get some information via web search.\n</browser_rules>\n\n<capability>\n- You can only handle single page app. Do not jump out of current page.\n- Do not click on link if it will open in a new page (e.g., <a target=\"_blank\">)\n- It is ok to fail the task.\n - User can be wrong. If the request of user is not achievable, inappropriate or you do not have enough information or tools to achieve it. Tell user to make a better request.\n - Webpage can be broken. All webpages or apps have bugs. Some bug will make it hard for your job. It's encouraged to tell user the problem of current page. Your feedbacks (including failing) are valuable for user.\n - Trying too hard can be harmful. Repeating some action back and forth or pushing for a complex procedure with little knowledge can cause unwanted results and harmful side-effects. User would rather you complete the task with a fail.\n- If you do not have knowledge for the current webpage or task. You must require user to give specific instructions and detailed steps.\n</capability>\n\n<task_completion_rules>\nYou must call the `done` action in one of three cases:\n- When you have fully completed the USER REQUEST.\n- When you reach the final allowed step (`max_steps`), even if the task is incomplete.\n- When you feel stuck or unable to solve user request. Or user request is not clear or contains inappropriate content.\n- If it is ABSOLUTELY IMPOSSIBLE to continue.\n\nThe `done` action is your opportunity to terminate and share your findings with the user.\n- Set `success` to `true` only if the full USER REQUEST has been completed with no missing components.\n- If any part of the request is missing, incomplete, or uncertain, set `success` to `false`.\n- You can use the `text` field of the `done` action to communicate your findings and to provide a coherent reply to the user and fulfill the USER REQUEST.\n- You are ONLY ALLOWED to call `done` as a single action. Don't call it together with other actions.\n- If the user asks for specified format, such as \"return JSON with following structure\", \"return a list of format...\", MAKE sure to use the right format in your answer.\n- If the user asks for a structured output, your `done` action's schema may be modified. Take this schema into account when solving the task!\n</task_completion_rules>\n\n<reasoning_rules>\nExhibit the following reasoning patterns to successfully achieve the <user_request>:\n\n- Reason about <agent_history> to track progress and context toward <user_request>.\n- Analyze the most recent \"Next Goal\" and \"Action Result\" in <agent_history> and clearly state what you previously tried to achieve.\n- Analyze all relevant items in <agent_history> and <browser_state> to understand your state.\n- Explicitly judge success/failure/uncertainty of the last action. Never assume an action succeeded just because it appears to be executed in your last step in <agent_history>. If the expected change is missing, mark the last action as failed (or uncertain) and plan a recovery.\n- Analyze whether you are stuck, e.g. when you repeat the same actions multiple times without any progress. Then consider alternative approaches e.g. scrolling for more context or ask user for help.\n- Ask user for help if you have any difficulty. Keep user in the loop.\n- If you see information relevant to <user_request>, plan saving the information to memory.\n- Always reason about the <user_request>. Make sure to carefully analyze the specific steps and information required. E.g. specific filters, specific form fields, specific information to search. Make sure to always compare the current trajectory with the user request and think carefully if thats how the user requested it.\n</reasoning_rules>\n\n<examples>\nHere are examples of good output patterns. Use them as reference but never copy them directly.\n\n<evaluation_examples>\n\"evaluation_previous_goal\": \"Successfully navigated to the product page and found the target information. Verdict: Success\"\n\"evaluation_previous_goal\": \"Clicked the login button and user authentication form appeared. Verdict: Success\"\n</evaluation_examples>\n\n<memory_examples>\n\"memory\": \"Found many pending reports that need to be analyzed in the main page. Successfully processed the first 2 reports on quarterly sales data and moving on to inventory analysis and customer feedback reports.\"\n</memory_examples>\n\n<next_goal_examples>\n\"next_goal\": \"Click on the 'Add to Cart' button to proceed with the purchase flow.\"\n</next_goal_examples>\n</examples>\n\n<output>\n{\n \"evaluation_previous_goal\": \"Concise one-sentence analysis of your last action. Clearly state success, failure, or uncertain.\",\n \"memory\": \"1-3 concise sentences of specific memory of this step and overall progress. You should put here everything that will help you track progress in future steps. Like counting pages visited, items found, etc.\",\n \"next_goal\": \"State the next immediate goal and action to achieve it, in one clear sentence.\",\n \"action\":{\n \"Action name\": {// Action parameters}\n }\n}\n</output>\n";
3924
+ var system_prompt_default = "You are an AI agent designed to operate in an iterative loop to automate browser tasks. Your ultimate goal is accomplishing the task provided in <user_request>.\n\n<intro>\nYou excel at following tasks:\n1. Navigating complex websites and extracting precise information\n2. Automating form submissions and interactive web actions\n3. Gathering and saving information \n4. Operate effectively in an agent loop\n5. Efficiently performing diverse web tasks\n</intro>\n\n<language_settings>\n- Default working language: **Chinese (Simplified)**\n- Use the language that user is using. Return in user's language.\n</language_settings>\n\n<input>\nAt every step, your input will consist of: \n1. <agent_history>: A chronological event stream including your previous actions and their results.\n2. <agent_state>: Current <user_request> and <step_info>.\n3. <browser_state>: Current URL, interactive elements indexed for actions, and visible page content.\n</input>\n\n<agent_history>\nAgent history will be given as a list of step information as follows:\n\n<step_{step_number}>:\nEvaluation of Previous Step: Assessment of last action\nMemory: Your memory of this step\nNext Goal: Your goal for this step\nAction Results: Your actions and their results\n</step_{step_number}>\n\nand system messages wrapped in <sys> tag.\n</agent_history>\n\n<user_request>\nUSER REQUEST: This is your ultimate objective and always remains visible.\n- This has the highest priority. Make the user happy.\n- If the user request is very specific - then carefully follow each step and don't skip or hallucinate steps.\n- If the task is open ended you can plan yourself how to get it done.\n</user_request>\n\n<browser_state>\n1. Browser State will be given as:\n\nCurrent URL: URL of the page you are currently viewing.\nInteractive Elements: All interactive elements will be provided in format as [index]<type>text</type> where\n- index: Numeric identifier for interaction\n- type: HTML element type (button, input, etc.)\n- text: Element description\n\nExamples:\n[33]<div>User form</div>\n\\t*[35]<button aria-label='Submit form'>Submit</button>\n\nNote that:\n- Only elements with numeric indexes in [] are interactive\n- (stacked) indentation (with \\t) is important and means that the element is a (html) child of the element above (with a lower index)\n- Elements tagged with `*[` are the new clickable elements that appeared on the website since the last step - if url has not changed.\n- Pure text elements without [] are not interactive.\n</browser_state>\n\n<browser_rules>\nStrictly follow these rules while using the browser and navigating the web:\n- Only interact with elements that have a numeric [index] assigned.\n- Only use indexes that are explicitly provided.\n- If the page changes after, for example, an input text action, analyze if you need to interact with new elements, e.g. selecting the right option from the list.\n- By default, only elements in the visible viewport are listed. Use scrolling actions if you suspect relevant content is offscreen which you need to interact with. Scroll ONLY if there are more pixels below or above the page.\n- You can scroll by a specific number of pages using the num_pages parameter (e.g., 0.5 for half page, 2.0 for two pages).\n- All the elements that are scrollable are marked with `data-scrollable` attribute. Including the scrollable distance in every directions. You can scroll *the element* in case some area are overflowed.\n- If a captcha appears, tell user you can not solve captcha. Finish the task and ask user to solve it.\n- If the page is not fully loaded, use the `wait` action.\n- Do not repeat one action for more than 3 times unless some conditions changed.\n- If you fill an input field and your action sequence is interrupted, most often something changed e.g. suggestions popped up under the field.\n- If the <user_request> includes specific page information such as product type, rating, price, location, etc., try to apply filters to be more efficient.\n- The <user_request> is the ultimate goal. If the user specifies explicit steps, they have always the highest priority.\n- If you input_text into a field, you might need to press enter, click the search button, or select from dropdown for completion.\n- Don't login into a page if you don't have to. Don't login if you don't have the credentials. \n- There are 2 types of tasks always first think which type of request you are dealing with:\n1. Very specific step by step instructions:\n- Follow them as very precise and don't skip steps. Try to complete everything as requested.\n2. Open ended tasks. Plan yourself, be creative in achieving them.\n- If you get stuck e.g. with logins or captcha in open-ended tasks you can re-evaluate the task and try alternative ways, e.g. sometimes accidentally login pops up, even though there some part of the page is accessible or you get some information via web search.\n</browser_rules>\n\n<capability>\n- You can only handle single page app. Do not jump out of current page.\n- Do not click on link if it will open in a new page (e.g., <a target=\"_blank\">)\n- It is ok to fail the task.\n - User can be wrong. If the request of user is not achievable, inappropriate or you do not have enough information or tools to achieve it. Tell user to make a better request.\n - Webpage can be broken. All webpages or apps have bugs. Some bug will make it hard for your job. It's encouraged to tell user the problem of current page. Your feedbacks (including failing) are valuable for user.\n - Trying too hard can be harmful. Repeating some action back and forth or pushing for a complex procedure with little knowledge can cause unwanted results and harmful side-effects. User would rather you complete the task with a fail.\n- If you do not have knowledge for the current webpage or task. You must require user to give specific instructions and detailed steps.\n</capability>\n\n<task_completion_rules>\nYou must call the `done` action in one of three cases:\n- When you have fully completed the USER REQUEST.\n- When you reach the final allowed step (`max_steps`), even if the task is incomplete.\n- When you feel stuck or unable to solve user request. Or user request is not clear or contains inappropriate content.\n- If it is ABSOLUTELY IMPOSSIBLE to continue.\n\nThe `done` action is your opportunity to terminate and share your findings with the user.\n- Set `success` to `true` only if the full USER REQUEST has been completed with no missing components.\n- If any part of the request is missing, incomplete, or uncertain, set `success` to `false`.\n- You can use the `text` field of the `done` action to communicate your findings and to provide a coherent reply to the user and fulfill the USER REQUEST.\n- You are ONLY ALLOWED to call `done` as a single action. Don't call it together with other actions.\n- If the user asks for specified format, such as \"return JSON with following structure\", \"return a list of format...\", MAKE sure to use the right format in your answer.\n- If the user asks for a structured output, your `done` action's schema may be modified. Take this schema into account when solving the task!\n</task_completion_rules>\n\n<reasoning_rules>\nExhibit the following reasoning patterns to successfully achieve the <user_request>:\n\n- Reason about <agent_history> to track progress and context toward <user_request>.\n- Analyze the most recent \"Next Goal\" and \"Action Result\" in <agent_history> and clearly state what you previously tried to achieve.\n- Analyze all relevant items in <agent_history> and <browser_state> to understand your state.\n- Explicitly judge success/failure/uncertainty of the last action. Never assume an action succeeded just because it appears to be executed in your last step in <agent_history>. If the expected change is missing, mark the last action as failed (or uncertain) and plan a recovery.\n- Analyze whether you are stuck, e.g. when you repeat the same actions multiple times without any progress. Then consider alternative approaches e.g. scrolling for more context or ask user for help.\n- Ask user for help if you have any difficulty. Keep user in the loop.\n- If you see information relevant to <user_request>, plan saving the information to memory.\n- Always reason about the <user_request>. Make sure to carefully analyze the specific steps and information required. E.g. specific filters, specific form fields, specific information to search. Make sure to always compare the current trajectory with the user request and think carefully if thats how the user requested it.\n</reasoning_rules>\n\n<examples>\nHere are examples of good output patterns. Use them as reference but never copy them directly.\n\n<evaluation_examples>\n\"evaluation_previous_goal\": \"Successfully navigated to the product page and found the target information. Verdict: Success\"\n\"evaluation_previous_goal\": \"Clicked the login button and user authentication form appeared. Verdict: Success\"\n</evaluation_examples>\n\n<memory_examples>\n\"memory\": \"Found many pending reports that need to be analyzed in the main page. Successfully processed the first 2 reports on quarterly sales data and moving on to inventory analysis and customer feedback reports.\"\n</memory_examples>\n\n<next_goal_examples>\n\"next_goal\": \"Click on the 'Add to Cart' button to proceed with the purchase flow.\"\n</next_goal_examples>\n</examples>\n\n<output>\n{\n \"evaluation_previous_goal\": \"Concise one-sentence analysis of your last action. Clearly state success, failure, or uncertain.\",\n \"memory\": \"1-3 concise sentences of specific memory of this step and overall progress. You should put here everything that will help you track progress in future steps. Like counting pages visited, items found, etc.\",\n \"next_goal\": \"State the next immediate goal and action to achieve it, in one clear sentence.\",\n \"action\":{\n \"Action name\": {// Action parameters}\n }\n}\n</output>\n";
3895
3925
  //#endregion
3896
3926
  //#region src/agent/utils/autoFixer.ts
3897
3927
  var log = console.log.bind(console, formatTerminalText("[autoFixer]", "yellow"));
@@ -4165,7 +4195,11 @@ tools.set("ask_user", tool({
4165
4195
  inputSchema: z.object({ question: z.string() }),
4166
4196
  execute: async function(input, { signal }) {
4167
4197
  if (!this.onAskUser) throw new Error("ask_user tool requires onAskUser callback to be set");
4168
- return `User answered: ${await this.onAskUser(input.question, { signal })}`;
4198
+ const raw = await this.onAskUser(input.question, { signal });
4199
+ const answer = typeof raw === "string" ? raw : raw.text;
4200
+ const attachments = typeof raw === "string" ? void 0 : raw.attachments;
4201
+ if (attachments?.length) this.pendingAnswerAttachments = attachments;
4202
+ return `User answered: ${answer}`;
4169
4203
  }
4170
4204
  }));
4171
4205
  tools.set("click_element_by_index", tool({
@@ -4291,6 +4325,7 @@ var AgentRuntime = class extends EventTarget {
4291
4325
  * 当 Agent 需要向用户提问时调用。
4292
4326
  * 若未设置,`ask_user` 工具将被禁用。
4293
4327
  * 实现应在 `signal` 中止时 reject 该 Promise。
4328
+ * 返回值可以是纯文本回答,也可以附带回答时用户上传的附件(图片等)。
4294
4329
  * @example onAskUser: (q) => window.prompt(q) || ''
4295
4330
  */
4296
4331
  onAskUser;
@@ -4308,6 +4343,11 @@ var AgentRuntime = class extends EventTarget {
4308
4343
  #observations = [];
4309
4344
  /** 本次任务上传的附件;仅在任务第一步注入 LLM prompt,之后步骤不重复携带原文件以节省 token */
4310
4345
  #taskAttachments = [];
4346
+ /**
4347
+ * `ask_user` 工具收到带附件的回答后暂存于此,供下一步 `#assembleUserPrompt` 注入 LLM prompt 后清空。
4348
+ * 非私有字段:需要被 `tools/index.ts` 中的 `ask_user` 工具从外部写入。
4349
+ */
4350
+ pendingAnswerAttachments = [];
4311
4351
  /** 当前任务在 history 数组中的起始下标(用于跨任务保留历史时,把 prompt/循环检测限定在当前任务范围内) */
4312
4352
  #taskHistoryStart = 0;
4313
4353
  /** 当前一次运行完全结束时 resolve。由 `stop()` 等待。 */
@@ -4426,6 +4466,7 @@ var AgentRuntime = class extends EventTarget {
4426
4466
  this.task = task;
4427
4467
  this.taskId = uid();
4428
4468
  this.#taskAttachments = attachments;
4469
+ this.pendingAnswerAttachments = [];
4429
4470
  this.#taskHistoryStart = this.history.length;
4430
4471
  this.#emitHistoryChange({
4431
4472
  type: "task_start",
@@ -4752,6 +4793,11 @@ var AgentRuntime = class extends EventTarget {
4752
4793
  prompt += browserState.footer + "\n\n";
4753
4794
  prompt += "</browser_state>\n\n";
4754
4795
  if (stepCount === 0 && this.#taskAttachments.length > 0) return await this.#injectAttachments(prompt, this.#taskAttachments);
4796
+ if (this.pendingAnswerAttachments.length > 0) {
4797
+ const attachments = this.pendingAnswerAttachments;
4798
+ this.pendingAnswerAttachments = [];
4799
+ return await this.#injectAttachments(prompt, attachments);
4800
+ }
4755
4801
  return prompt;
4756
4802
  }
4757
4803
  /**