page-agent-sdk 3.20.0 → 3.22.0
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/README.md +4 -4
- package/README.zh-CN.md +4 -4
- package/dist/page-agent-sdk.headless.js +779 -485
- package/dist/page-agent-sdk.iife.js +140 -137
- package/dist/page-agent-sdk.js +3411 -3066
- package/dist/page-agent-sdk.umd.cjs +74 -71
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/skills/page-agent-sdk-integrate/SKILL.md +22 -0
- package/types/index.d.ts +258 -83
package/types/index.d.ts
CHANGED
|
@@ -199,88 +199,239 @@ export interface DialogIcons {
|
|
|
199
199
|
|
|
200
200
|
/** 对话框文案键空间(dialog.locale 选包 / dialog.messages 键级覆盖优先;含插值的键组件侧拼数字) */
|
|
201
201
|
export interface DialogMessages {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
202
|
+
// ===== 容器缺省(ChatDialog 默认 title/placeholder 跟随 locale)=====
|
|
203
|
+
defaultTitle: string
|
|
204
|
+
inputPlaceholder: string
|
|
205
|
+
// ===== ChatHeader =====
|
|
206
|
+
newSession: string
|
|
207
|
+
history: string
|
|
208
|
+
more: string
|
|
209
|
+
close: string
|
|
210
|
+
debugMenu: string
|
|
211
|
+
debugMenuTitle: string
|
|
212
|
+
skillMenu: string
|
|
213
|
+
skillMenuTitle: string
|
|
214
|
+
clearChat: string
|
|
215
|
+
sessionFallbackPrefix: string // 会话 / Session(截尾 id 前缀)
|
|
216
|
+
justNow: string
|
|
217
|
+
minutesAgoSuffix: string // 分钟前 / min ago(数字在前拼接)
|
|
218
|
+
// ===== MessageList =====
|
|
219
|
+
emptyGreeting: string
|
|
220
|
+
retry: string
|
|
221
|
+
undo: string
|
|
222
|
+
undoTitle: string
|
|
223
|
+
// ===== MessageBubble =====
|
|
224
|
+
thinking: string // 思考中... / Thinking...
|
|
225
|
+
// ===== MessageSteps / SubReasonDetails =====
|
|
226
|
+
statusRunning: string
|
|
227
|
+
statusDone: string
|
|
228
|
+
statusError: string
|
|
229
|
+
subagentBadge: string // 「子」字标 / "sub"
|
|
230
|
+
subagentBadgeTitle: string
|
|
231
|
+
subagentProgress: string // 子 agent 进度(图标后的词)
|
|
232
|
+
nthCallPrefix: string // 第 / #(第 {n} 次 → prefix + n + suffix)
|
|
233
|
+
nthCallSuffix: string // 次 / of calls
|
|
234
|
+
argsLabel: string
|
|
235
|
+
resultLabel: string
|
|
236
|
+
copy: string
|
|
237
|
+
copied: string
|
|
238
|
+
regenerate: string
|
|
239
|
+
expand: string
|
|
240
|
+
collapse: string
|
|
241
|
+
noResult: string
|
|
242
|
+
displayTruncatedSuffix: string // …(展示截断,复制可得全量)
|
|
243
|
+
thinkingCountPrefix: string // 思考中… / Thinking…(+ N字)
|
|
244
|
+
charCountSuffix: string // 字 / chars
|
|
245
|
+
reasoningTitle: string // 思考过程
|
|
246
|
+
truncatedNotePrefix: string // 仅显最近 / Last(+ N 字)
|
|
247
|
+
truncatedNoteSuffix: string // 字 / chars
|
|
248
|
+
copyThinking: string
|
|
249
|
+
copyThinkingTruncTitle: string
|
|
250
|
+
// ===== MessageRow / ChatInput 焦点 chip =====
|
|
251
|
+
focusChipTitlePrefix: string // 精修中: / Focus:(+ path)
|
|
252
|
+
focusChipTitleHint: string // (点击回看 · ✕ 移除)
|
|
253
|
+
historyFocusChipTitlePrefix: string // 回看 / View(+ path)
|
|
254
|
+
removeFocus: string
|
|
255
|
+
// ===== ChatInput =====
|
|
256
|
+
sendHint: string
|
|
257
|
+
sendTitle: string
|
|
258
|
+
stopTitle: string
|
|
259
|
+
// ===== QueuedBar =====
|
|
260
|
+
queuedTitle: string
|
|
261
|
+
queuedEditTitle: string
|
|
262
|
+
removeQueuedTitle: string
|
|
263
|
+
// ===== ApprovalBar =====
|
|
264
|
+
humanConfirmTitle: string
|
|
265
|
+
recommendPrefix: string // 推荐 / Recommend:(值在后)
|
|
266
|
+
approve: string
|
|
267
|
+
deny: string
|
|
268
|
+
toolConfirmPrefix: string // 需确认工具调用: / Confirm tool call:
|
|
269
|
+
viewArgs: string
|
|
270
|
+
collapseArgs: string
|
|
271
|
+
argsTruncatedSuffix: string // …(已截断)
|
|
272
|
+
// ===== ConflictBar =====
|
|
273
|
+
conflictTitlePrefix: string // 写入冲突: / Write conflict:
|
|
274
|
+
conflictTitleSuffix: string // 已被外部修改 / was modified externally
|
|
275
|
+
conflictDetailTemplate: string // 含 {op} 占位(写入/删除)
|
|
276
|
+
conflictOpWrite: string
|
|
277
|
+
conflictOpDelete: string
|
|
278
|
+
viewDiff: string
|
|
279
|
+
collapseDiff: string
|
|
280
|
+
agentValueLabel: string // AI 想写的值
|
|
281
|
+
currentValueLabel: string // 外部改后的当前值
|
|
282
|
+
deleteNoValue: string // (delete 操作无值)
|
|
283
|
+
keepExternal: string
|
|
284
|
+
keepExternalTitle: string
|
|
285
|
+
overwrite: string
|
|
286
|
+
overwriteTitle: string
|
|
287
|
+
restore: string
|
|
288
|
+
restoreTitle: string
|
|
289
|
+
// ===== FocusBar =====
|
|
290
|
+
switchFocusTitle: string
|
|
291
|
+
exitFocusTitle: string
|
|
292
|
+
focusPathPlaceholder: string
|
|
293
|
+
focusLabelPlaceholder: string
|
|
294
|
+
focusSubmit: string
|
|
295
|
+
// ===== DebugDrawer(phase2;tab/过滤器/状态/各面板)=====
|
|
296
|
+
debugTabLogs: string
|
|
297
|
+
debugTabFlow: string
|
|
298
|
+
debugTabContext: string
|
|
299
|
+
debugTabSubagent: string
|
|
300
|
+
debugTabInfo: string
|
|
301
|
+
debugClearLogs: string
|
|
302
|
+
debugTypeContext: string
|
|
303
|
+
debugTypeLlmRequest: string
|
|
304
|
+
debugTypeLlmResponse: string
|
|
305
|
+
debugTypeToolCall: string
|
|
306
|
+
debugTypeToolResult: string
|
|
307
|
+
debugTypeError: string
|
|
308
|
+
debugTypeMiddleware: string
|
|
309
|
+
debugFilterAll: string
|
|
310
|
+
debugFlowPrep: string // 准备 / 其他(流程视图无 round 分组标题)
|
|
311
|
+
debugLogsEmpty: string
|
|
312
|
+
debugFlowEmpty: string
|
|
313
|
+
debugNoInfo: string
|
|
314
|
+
debugCardView: string
|
|
315
|
+
debugRequestBody: string
|
|
316
|
+
debugViewRawJson: string
|
|
317
|
+
debugCollapseRawJson: string
|
|
318
|
+
debugModel: string
|
|
319
|
+
debugTemperature: string
|
|
320
|
+
debugMessageCount: string
|
|
321
|
+
debugToolsLabel: string
|
|
322
|
+
debugContextMessages: string
|
|
323
|
+
debugRoundPrefix: string // 第 / Round(n 在中间)
|
|
324
|
+
debugRoundSuffix: string // 轮 / ''(空)
|
|
325
|
+
debugMsgCountSuffix: string // 条消息 / messages(n 在前)
|
|
326
|
+
debugToolCountSuffix: string // 工具 / tools(n 在前)
|
|
327
|
+
debugToolCallsSuffix: string // 个工具调用 / tool calls(n 在前)
|
|
328
|
+
debugResultSuffix: string // 结果 / result(name 在前)
|
|
329
|
+
debugTodoPending: string
|
|
330
|
+
debugTodoInProgress: string
|
|
331
|
+
debugTodoCompleted: string
|
|
332
|
+
debugSubRunning: string
|
|
333
|
+
debugSubDone: string
|
|
334
|
+
debugSubError: string
|
|
335
|
+
debugLocksTitle: string // 组件锁 / Component locks
|
|
336
|
+
debugSubagentEmpty: string
|
|
337
|
+
debugSubRunningTitle: string // 运行中 / Running
|
|
338
|
+
debugSubHistoryTitle: string // 历史 / History
|
|
339
|
+
debugStepsBtn: string
|
|
340
|
+
debugStepsCountSuffix: string // 步 / steps(n 在前)
|
|
341
|
+
debugTraceEmpty: string
|
|
342
|
+
debugMetricRounds: string
|
|
343
|
+
debugMetricTotal: string
|
|
344
|
+
debugMetricAvg: string
|
|
345
|
+
debugMetricTools: string
|
|
346
|
+
debugMetricCompressions: string
|
|
347
|
+
debugCtxEmpty: string
|
|
348
|
+
debugCtxOccupancy: string // 占用 / Occupancy(title)
|
|
349
|
+
debugCtxThreshold: string // 压缩阈值 / compress threshold
|
|
350
|
+
debugCtxTokens: string // 估算 / est.(token 前缀)
|
|
351
|
+
debugCtxWindow: string // 窗口 / window(数值前缀)
|
|
352
|
+
debugCtxThresholdPct: string // 阈值 / threshold(数值前缀)
|
|
353
|
+
debugCtxCategories: string
|
|
354
|
+
debugCtxLastCompression: string
|
|
355
|
+
debugCtxSummarized: string // 摘要 / summarized(N/M 轮前缀)
|
|
356
|
+
debugCtxRoundsSuffix: string // 轮 / rounds(N/M 后缀)
|
|
357
|
+
debugCtxRecalled: string // 召回 / recalled(数值前缀)
|
|
358
|
+
debugCtxAgentDecision: string // agent 决策: / agent decision:
|
|
359
|
+
debugInfoBasic: string
|
|
360
|
+
debugToolCount: string // 工具数 / Tools
|
|
361
|
+
debugMiddleware: string
|
|
362
|
+
debugMiddlewareStack: string
|
|
363
|
+
debugSkillsTitle: string
|
|
364
|
+
debugSkillsHint: string
|
|
365
|
+
debugLoading: string
|
|
366
|
+
debugDataTitle: string
|
|
367
|
+
debugDataFallback: string // 主数据对象 / main data object(无 description 兜底)
|
|
368
|
+
debugSchemaPrefix: string // schema: (zh/en 同,占位保持结构)
|
|
369
|
+
debugSchemaDeclared: string
|
|
370
|
+
debugSchemaMissing: string
|
|
371
|
+
debugSubagentTitle: string
|
|
372
|
+
debugEnabled: string
|
|
373
|
+
debugYes: string
|
|
374
|
+
debugNo: string
|
|
375
|
+
debugMaxDepth: string
|
|
376
|
+
debugMaxParallel: string
|
|
377
|
+
debugExtraTools: string
|
|
378
|
+
debugDefaultReadonly: string
|
|
379
|
+
debugVerifyTitle: string
|
|
380
|
+
debugMaxAttempts: string
|
|
381
|
+
debugAdversarial: string
|
|
382
|
+
debugOn: string
|
|
383
|
+
debugOff: string
|
|
384
|
+
debugAdversarialModel: string
|
|
385
|
+
debugSameAsMain: string // (同主) / (same as main)
|
|
386
|
+
debugTodosTitle: string
|
|
387
|
+
debugMemoryTitle: string
|
|
388
|
+
debugLastCompTitle: string
|
|
389
|
+
debugTriggered: string
|
|
390
|
+
debugNotTriggered: string // ✗(未达阈值) / ✗ (below threshold)
|
|
391
|
+
debugRoundsSummarized: string
|
|
392
|
+
debugCountSuffix: string // 条 / ''(召回 N 条)
|
|
393
|
+
debugStrategy: string
|
|
394
|
+
debugDecision: string
|
|
395
|
+
debugSummaryMode: string // 摘要 / summary(决策摘要 mode 后缀)
|
|
396
|
+
debugSkillNoReader: string
|
|
397
|
+
debugSkillEmpty: string
|
|
398
|
+
// ===== SkillPanel(phase2)=====
|
|
399
|
+
skillPanelTitle: string
|
|
400
|
+
skillEditingPrefix: string // 编辑 Skill: / Edit skill:
|
|
401
|
+
skillCreateNew: string
|
|
402
|
+
skillCancelEdit: string
|
|
403
|
+
skillNameLabel: string
|
|
404
|
+
skillNamePlaceholder: string
|
|
405
|
+
skillDescLabel: string
|
|
406
|
+
skillDescPlaceholder: string
|
|
407
|
+
skillContentLabel: string
|
|
408
|
+
skillContentPlaceholder: string
|
|
409
|
+
skillSave: string
|
|
410
|
+
skillAdd: string
|
|
411
|
+
skillCreatedTitle: string // 已创建 Skill / Created skills(n 在后)
|
|
412
|
+
skillEmpty: string
|
|
413
|
+
skillEditBtn: string
|
|
414
|
+
skillEditTitle: string
|
|
415
|
+
skillDeleteBtn: string
|
|
416
|
+
skillDeleteTitle: string
|
|
417
|
+
skillErrName: string
|
|
418
|
+
skillErrDesc: string
|
|
419
|
+
skillErrContent: string
|
|
420
|
+
skillDupWarnPrefix: string // 已存在同名用户 skill " / User skill " exists: "
|
|
421
|
+
skillDupWarnSuffix: string // ",将覆盖 / " will be overwritten
|
|
422
|
+
skillHintA: string // 底部提示三段(code 标签留在模板混排)
|
|
423
|
+
skillHintB: string
|
|
424
|
+
skillHintC: string
|
|
425
|
+
// ===== CodePreview(phase2)=====
|
|
426
|
+
codeCopyTitle: string
|
|
427
|
+
codeOpenTitle: string
|
|
428
|
+
codePreviewTitlePrefix: string // 代码预览 · / Code preview · (lang 在后)
|
|
429
|
+
codePreviewTab: string
|
|
430
|
+
codeSourceTab: string
|
|
431
|
+
codeDemoTitle: string
|
|
432
|
+
codeDemoText: string
|
|
433
|
+
codeDemoButton: string
|
|
434
|
+
codeDemoInput: string
|
|
284
435
|
}
|
|
285
436
|
export type DialogLocale = 'zh-CN' | 'en-US';
|
|
286
437
|
export declare const MESSAGES_ZH_CN: DialogMessages;
|
|
@@ -295,6 +446,8 @@ export declare function resolveDialogIcons(partial?: Partial<DialogIcons>): Dial
|
|
|
295
446
|
export declare function isIconHtml(value: string): boolean;
|
|
296
447
|
/** HTML 图标净化(DOMPurify 图标白名单:svg 形状族/img/i 等 + 几何/描边属性;事件属性与危险协议剥除) */
|
|
297
448
|
export declare function sanitizeIconHtml(html: string): string;
|
|
449
|
+
/** HTML 文案净化(DOMPurify 文案白名单:b/em/u/s/span/mark/code 等行内标签 + class/style;script/事件属性/危险协议剥;i18n.messages 富文本渲染位用) */
|
|
450
|
+
export declare function sanitizeMessageHtml(html: string): string;
|
|
298
451
|
/** 图标渲染出口:纯文本文本插值;HTML 片段(以 '<' 开头)净化后 v-html 渲染。props:{ icon: string } */
|
|
299
452
|
export declare const IconGlyph: DefineComponent<{ icon: string }>;
|
|
300
453
|
|
|
@@ -994,6 +1147,8 @@ export interface ChatSdkOptions {
|
|
|
994
1147
|
streaming?: boolean;
|
|
995
1148
|
/** Dialog UI config (title/placeholder/drawer/drawerWidth/drawerHidden/inputRows/onClose grouped) */
|
|
996
1149
|
dialog?: DialogConfig;
|
|
1150
|
+
/** 国际化:locale 切语言 + messages 键级覆盖文案(3.22+;UI 文案包 + 默认 systemPrompt/autoTitle 语言;原 dialog.locale/dialog.messages 两键合并至此) */
|
|
1151
|
+
i18n?: I18nOptions;
|
|
997
1152
|
}
|
|
998
1153
|
|
|
999
1154
|
/** Dialog UI config (grouped form, recommended) */
|
|
@@ -1011,6 +1166,21 @@ export interface DialogConfig {
|
|
|
1011
1166
|
/** Icon overrides (partial; unset keys keep default emojis 🤖/🧬/🎯/📋/✏️/💡/⚠️/💬; empty string hides the icon; avatar keys undefined = built-in SVG). Values: plain text, or an HTML fragment starting with '<' (inline svg/img, sanitized via a DOMPurify icon allowlist) */
|
|
1012
1167
|
icons?: Partial<DialogIcons>;
|
|
1013
1168
|
}
|
|
1169
|
+
/**
|
|
1170
|
+
* 国际化配置(顶层 i18n;3.22 起,原 dialog.locale/dialog.messages 两键移入此处合并)。
|
|
1171
|
+
* 不放 dialog 组:locale 除 UI 文案包外还驱动默认 systemPrompt 语言与 autoTitle 标题语言(agent 层)。
|
|
1172
|
+
*/
|
|
1173
|
+
export interface I18nOptions {
|
|
1174
|
+
/** 语言:'zh-CN'(默认)/'en-US';切换内置文案包(聊天面 + Debug 抽屉 + Skill 面板 + 代码预览);
|
|
1175
|
+
* formatTime(12h/24h)/autoTitle/默认 systemPrompt 跟随(en → 英文版身份 + "Respond in English" 锚,
|
|
1176
|
+
* agent 回复与 UI 同语言;自定义 systemPrompt 不受影响,但自动追加的 reliableWriteRules 段切英文) */
|
|
1177
|
+
locale?: DialogLocale;
|
|
1178
|
+
/** 文案键级覆盖(Partial<DialogMessages>;优先于 locale 包 —— 换语言与改个别文案一套机制,如 statusDone:'完成')。
|
|
1179
|
+
* 漏配键回退包值;完整键清单(~219 键)见 DialogMessages。
|
|
1180
|
+
* 部分渲染位支持行内 HTML 片段(值以 '<' 开头,文案白名单净化渲染,如 '<b style="color:#10b981">完成</b>'):
|
|
1181
|
+
* 标题/状态标签/思考中/空态问候/确认与冲突按钮;title/placeholder 属性位与拼接键(prefix/suffix)按纯文本 */
|
|
1182
|
+
messages?: Partial<DialogMessages>;
|
|
1183
|
+
}
|
|
1014
1184
|
|
|
1015
1185
|
/** 会话级任务目标锚点(mission 中间件;capture 或 setMission;revive-mission-anchor Phase 1) */
|
|
1016
1186
|
/** 跨压缩工作记忆(workingMemory 中间件;经 augmentPrompt 每轮注入 system,天然跨压缩保留) */
|
|
@@ -1209,13 +1379,16 @@ export declare function createChatSdk(options: ChatSdkOptions): ChatSdk;
|
|
|
1209
1379
|
// ============ system prompt 构建(promptBuilder,refactor-module-extraction 从 createChatSdk 抽离)============
|
|
1210
1380
|
/** 默认 systemPrompt(用户未传 systemPrompt 时用);含身份 + 能力概述 + 可靠写入规则 */
|
|
1211
1381
|
export declare const DEFAULT_SYSTEM_PROMPT: string;
|
|
1382
|
+
/** 默认 systemPrompt 英文版(dialog.locale:'en-US' 且未传 systemPrompt 时用;末行语言锚确保英文输出) */
|
|
1383
|
+
export declare const DEFAULT_SYSTEM_PROMPT_EN: string;
|
|
1212
1384
|
/** 拼接「可操作数据」段(从 data schema .describe() 自动提取注入) */
|
|
1213
1385
|
export declare function buildDataPrompt(data: DataConfig | undefined): string;
|
|
1214
1386
|
/**
|
|
1215
1387
|
* 统一 systemPrompt base 段入口:处理 appendReliableWriteRules 分支 + '---' 分割线。
|
|
1216
1388
|
* 传 systemPrompt 默认追加 reliableWriteRules(设 appendReliableWriteRules:false 关闭);不传用 DEFAULT_SYSTEM_PROMPT(已内置)。纯函数。
|
|
1389
|
+
* locale:'en-US' 时默认 prompt 用 DEFAULT_SYSTEM_PROMPT_EN、追加规则段用 reliableWriteRulesEn(默认 prompt 与 UI 同语言)。
|
|
1217
1390
|
*/
|
|
1218
|
-
export declare function buildSystemPrompt(opts: { systemPrompt?: string; appendReliableWriteRules?: boolean }): string;
|
|
1391
|
+
export declare function buildSystemPrompt(opts: { systemPrompt?: string; appendReliableWriteRules?: boolean; locale?: DialogLocale }): string;
|
|
1219
1392
|
export declare function defineTool(opts: {
|
|
1220
1393
|
name: string;
|
|
1221
1394
|
description: string;
|
|
@@ -1395,6 +1568,8 @@ export declare const presets: Record<string, any>;
|
|
|
1395
1568
|
export declare const systemPromptHelpers: {
|
|
1396
1569
|
/** 可靠写入规则:改前先读、动态先 list、字段以 describe 为准、写错看校验错误重试、优先增量 patch */
|
|
1397
1570
|
readonly reliableWriteRules: string;
|
|
1571
|
+
/** 可靠写入规则(英文版;dialog.locale:'en-US' 时 buildSystemPrompt 自动使用) */
|
|
1572
|
+
readonly reliableWriteRulesEn: string;
|
|
1398
1573
|
/** HTML 页面搭建主 agent 编排规则(与 createHtmlSubagent 配套;职责边界 / 逐个委派 / 修改排查 / 预算暂停) */
|
|
1399
1574
|
readonly htmlPageOrchestrator: string;
|
|
1400
1575
|
/** HTML 页面搭建「先出方案再生成」(新建/创意类先给 2~3 套方案问用户;产品决策,opt-in 拼进 systemPrompt) */
|