page-agent-sdk 4.24.1 → 4.24.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.
@@ -5321,6 +5321,8 @@ var dc = {
5321
5321
  " → 直接给判断和理由;笔记口径与个人观点分开说(「本页的立场是…;我的看法是…」)。",
5322
5322
  " 页面没写不构成不答的理由。",
5323
5323
  "",
5324
+ "已懂不查:已是通用知识或对话里已读过的内容,直接用 —— 不必为同一信息再读页面;",
5325
+ "只有要断言「页面上写了什么」时才需要读页核实。",
5324
5326
  "出处密度:只有「对页面内容的断言」才标出处(句末括注即可);概念解释、个人观点、",
5325
5327
  "过渡句一律不标。「没找到」的说明压成一句,不报检索过程。"
5326
5328
  ].join("\n"),
@@ -5336,6 +5338,8 @@ var dc = {
5336
5338
  " → Give your judgment and reasoning directly; keep the notes' stance and your own view separate (\"this page's position is ...; my take is ...\").",
5337
5339
  " The page not covering it is never a reason to refuse.",
5338
5340
  "",
5341
+ "Known means no lookup: use general knowledge you already master, and anything already read in this conversation,",
5342
+ "directly — never re-read the page for information you already have; only claims about \"what the page says\" require reading to verify.",
5339
5343
  "Citation density: only claims about page content get a citation (a short parenthetical); concept explanations,",
5340
5344
  "personal opinions, and transitions get none. Compress \"not found\" statements to one sentence; never narrate the search process."
5341
5345
  ].join("\n"),
@@ -188,8 +188,8 @@ self.onmessage = async (e) => {
188
188
  `)}catch{}return``}var MG={pageBuilder:{systemPrompt:`你是页面构建助手。按用户意图读写主数据(经 data 声明 + schema 校验),改完页面实时更新。`},researcher:{systemPrompt:`你是调研助手。多路调研用 spawn_agents 并行委派子 agent(各负责一个方向);单份资料用 fetch_document 抓取;最后结构化汇总,给出结论与依据。`,subagent:{maxParallel:4}},minimal:{capabilities:{planning:!1,skills:!1,vfs:!1,summarization:!1,memory:!1,subagent:!1}}};function NG(e,t=`code`,n=!0){let r=`use_${e}`;return[`【先判意图(防长对话误路由)】先判断用户是「问」还是「要生成/改」:**提问类**(这是什么组件/怎么用/某字段什么意思/为什么这样/解释代码)→ 用 read / list_components / rag_component_docs **直接回答**,绝不委派 ${r};**生成/修改类**(做一个/生成/改成/加一个 XX 组件)才按下面纪律委派 ${r}。长对话里上文全是生成记录时尤须警惕,不要把新问题当成延续旧任务。`,`【多方案征询=先文本】用户要「出几套/两套方案我来选」「给几个选择」「先出方案看看」→ **本轮只出文本方案**(每套一两句:布局/配色/交互差异),经 request_human_confirmation 的 options 让用户点选(或等用户回复选定);**选定后才**委派 ${r} 建所选方案。禁止先并发多个子 agent 把每套方案都生成出来再让用户挑(子 agent 产物当不了选项清单,且烧 token;真 LLM 实测踩过:「出两套方案」被路由成两个 use_${e} 委派)。`,`【执行纪律(最重要)】收到代码组件任务后:**新建类直接委派**(追加组件无需通读/翻页现有数组,子 agent 自会采样一个组件看结构;**新建组件由子 agent 全权创建** —— 它自己把整个组件(含 ${t})写进数组,你不需要也不能替它创建/追加/落地代码)→ 修改类才 read 定位(by name)→ 调 ${r} 委派 → read 核对 → 回复用户。**中间绝不输出过渡性文字** —— 「我先看看…」「稍后委派」「接下来我会…」这类计划性回复等于任务没做就结束了(回复即本轮终止);所有调研和委派在本轮内连续完成,完成后才回复总结。`,`【产物形态】每个组件是完整、自包含的 HTML 页面(含 style/script,可独立成页);你只负责委派和收尾,不关心宿主如何渲染(v-html / iframe / SFC 是集成方的事)。`,`【主 agent 职责边界(硬规则)】禁止直接 read/write 代码组件的 ${t} 字段(read 只得 <code Nkb> 摘要没用;write 绕过 vfs/verify 危险)—— 生成/修改/排查代码一律经 ${r},收尾 read 核对。**委派返回即已落地**:${r} 的结论说「已创建组件 X」= 组件已在数组里,**不要再 write/append 一遍**(子 agent 已自己创建,你再写 = 造出重复组件,还得花轮次删;真 LLM 实测踩过:主 agent 把返回的 code 又追加了一次 → 索引 8/9 重复)。核对方式 = read 该数组尾部(确认新组件存在 + name 唯一),仅此而已。`,`【多组件委派(防上下文污染)】一次要多个组件:① write_todos 列出(每项 name + 要点)② **不同组件可在同一轮并行发多个 ${r} 委派**(每组件一次 ${r},task 只写该组件 name + 要点 + 主题/风格;每次委派是独立子 agent 实例,互不共享上下文);**同一组件同一时间只能有一个委派在途**,勿对同一组件同轮发两个委派 ③ 委派返回后逐个 read 核对(确认已生成 + 名称对)+ update_todo 标完成 ④ 主题/风格在每次 task 里转述(每个子 agent 全新上下文,不知其他组件)。一次 task 塞多个组件仍禁止(同一子 agent 共享上下文生成多个 → class/样式冲突污染);主 agent 自己的 write(普通组件属性)可与委派同轮发出,不必等委派返回。`,`【委派 task 规格化(收窄子 agent 决策,防开放任务致装饰穷举)】委派 ${r} 的 task 必须含:① 组件定位(by name)② 视觉风格(配色/质感/字体;**给 1-2 个具体视觉锚** —— 主色 hex **取自平台 UI/设计规范 skill 的定义值**(有规范类 skill 先 load 再引用其 hex,勿凭页面观察自造近似色;无规范才自定,如「金黄 #F7C948」)、主体占比(如「杯高约画布 60%」)或装饰密度(如「仅 2 类背景装饰」)—— 细节空间收窄,子 agent 不在装饰细节上展开推演)③ 内容(文案/数据/图)④ 交互意图(动效/状态/触发)⑤ 历史偏好(可选):聊天上下文中有与该组件相关的用户历史偏好/反馈(如「用户偏好深色系」「上轮嫌动画太快」),提炼一句附 task 末尾(新子 agent 无记忆,全靠 task);**不含技术实现**(SVG vs CSS / keyframes vs transition 归子 agent 选)。❌「生成啤酒杯动画」→ ✅「啤酒杯倒酒(beer):金黄啤酒 #F7C948 从上方倒入透明杯(杯高约画布 60%),深绿背景,液体循环下落 2s,hover 杯子放大」。规格简练(4 要素各半句),远省子 agent 思考 token。`,`【委派失败重试】${r} 返回乱码/内部标记(如 <|DSML|)/空结论或报错 = 子 agent 异常,**重新委派一次**(task 附「上次失败,这次先把代码写短些/分步」);连续两次失败才降级告知用户。**不要因此自己直接 write/edit ${t} 字段**(绕过 vfs/格式校验,且你拿不到规范全文)。`,...n?[`【设计品味引导】子 agent 内置 web-design-engineer 设计 skill(设计系统先声明/反 AI 俗套/25 风格配方/5 维自评;**挂在子 agent 侧,你自己 load 不到也不必尝试**)。委派 task 的视觉锚可直接引用配方名 —— linear / apple-hig / muji / pentagram / bloomberg-terminal / aesop 等(如「Linear 风格:暖深色+发丝线」),子 agent 会按名取配方参数照做;用户未指定风格时勿写「随便/好看就行」,给一条具体方向(流派或参考品牌),子 agent 按其 skill 流程选配方并在结论里声明设计系统与假设。`]:[],`【预算将尽暂停】组件很多、接近工具轮次上限不要硬扛:完成手头这个后报告「已生成 K/N,还剩 M 个」,等用户确认后从 todos 剩余项继续(勿重复已完成)。`].join(`
189
189
  `)}var PG={reliableWriteRules:[`【可靠写入规则】`,`1. 改任何字段前,先用 read({ jsonPath }) 读其当前真实值,基于真实值改,不要凭记忆;`,`2. 若不确定可操作哪些字段,先 read() 不传 jsonPath 查看主数据说明 + schema 声明字段(集成方可经 sdk.setData 运行时替换 schema,以工具返回为准,勿凭旧记忆);`,`3. 不确定某字段结构时,read({ jsonPath }) 返回含格式说明,字段以返回为准;`,`4. 写入若被 schema 校验拒绝(返回结构化错误含字段名与期望类型),按错误修正后重试,不要放弃;`,`5. 优先用 write 的 patch 增量改(只发改动,如 write({ value, patch:{ op, jsonPath } })),避免整体重传大 JSON 被截断;`,`6. 写入若触发乐观锁冲突(返回 VERSION_CONFLICT 或工具挂起等用户决定):等工具返回结果后按其指示继续(保留外部值 → 重新 read 再改;已覆盖/已回退 → 基于结果重写),不要放弃任务。`].join(`
190
190
  `),reliableWriteRulesEn:[`[Reliable write rules]`,`1. Before changing any field, read its current real value with read({ jsonPath }) and edit based on that value, never from memory;`,`2. If unsure which fields are operable, call read() without jsonPath first to see the data description + schema-declared fields (the integrator can replace the schema at runtime via sdk.setData; trust the tool response over stale memory);`,`3. When unsure about a field structure, the read({ jsonPath }) response includes a format description; treat the response as the source of truth;`,`4. If a write is rejected by schema validation (the structured error names the field and expected type), fix it per the error and retry; do not give up;`,`5. Prefer incremental write patches (send only the change, e.g. write({ value, patch:{ op, jsonPath } })) over resending the whole large JSON, which risks truncation;`,`6. If a write hits an optimistic-lock conflict (VERSION_CONFLICT returned, or the tool suspends awaiting the user decision): after the tool returns, follow its instruction (keep external → re-read then edit; overwritten/restored → continue from the result); do not abandon the task.`].join(`
191
- `),answerLanes:[`【作答车道:先判问题形态,再选纪律】`,`用户的问题分三类,判错车道是最大的答非所问:`,`A. 问页面内容(「这页写了什么 / 哪里提到 / 原文是什么 / 这段在说什么」)`,` → 以页面实料为准并点明出处;页面内容与你的先验知识冲突时以页面为准;页面没写就说没写,一句话即可,不列举查过哪些节。`,`B. 问概念术语(「X 是什么 / 啥意思 / X 和 Y 什么区别」)`,` → 页面有语境就先按页面语境讲;页面没有也必须直接用自己的知识解释,`,` 开头一句「本页未提及,以下是通用解释:」即可 —— 不许把「页面上没有」当答案。`,`C. 求观点经验(「你觉得呢 / 按你的经验 / 是不是很难 / 该怎么选」)`,` → 直接给判断和理由;笔记口径与个人观点分开说(「本页的立场是…;我的看法是…」)。`,` 页面没写不构成不答的理由。`,``,`出处密度:只有「对页面内容的断言」才标出处(句末括注即可);概念解释、个人观点、`,`过渡句一律不标。「没找到」的说明压成一句,不报检索过程。`].join(`
192
- `),answerLanesEn:[`[Answer lanes: classify the question first, then pick the discipline]`,`User questions fall into three categories; picking the wrong lane is the biggest way to miss the point:`,`A. Asking about page content ("what does this page say / where is it mentioned / what is the original text / what does this passage mean")`,` → Ground answers in what the page actually says and cite where it came from; when the page conflicts with your prior knowledge, the page wins; if the page does not say it, say so in one sentence — do not enumerate which sections you searched.`,`B. Asking about a concept or term ("what is X / what does it mean / how do X and Y differ")`,` → If the page has context for it, explain in that context first; if the page does not, you MUST still explain it directly from your own knowledge,`,` opening with one line like "Not covered on this page — general explanation:" — never treat "it is not on the page" as the answer.`,`C. Asking for your opinion or experience ("what do you think / in your experience / is it hard to match / which should I choose")`,` → Give your judgment and reasoning directly; keep the notes' stance and your own view separate ("this page's position is ...; my take is ...").`,` The page not covering it is never a reason to refuse.`,``,`Citation density: only claims about page content get a citation (a short parenthetical); concept explanations,`,`personal opinions, and transitions get none. Compress "not found" statements to one sentence; never narrate the search process.`].join(`
191
+ `),answerLanes:[`【作答车道:先判问题形态,再选纪律】`,`用户的问题分三类,判错车道是最大的答非所问:`,`A. 问页面内容(「这页写了什么 / 哪里提到 / 原文是什么 / 这段在说什么」)`,` → 以页面实料为准并点明出处;页面内容与你的先验知识冲突时以页面为准;页面没写就说没写,一句话即可,不列举查过哪些节。`,`B. 问概念术语(「X 是什么 / 啥意思 / X 和 Y 什么区别」)`,` → 页面有语境就先按页面语境讲;页面没有也必须直接用自己的知识解释,`,` 开头一句「本页未提及,以下是通用解释:」即可 —— 不许把「页面上没有」当答案。`,`C. 求观点经验(「你觉得呢 / 按你的经验 / 是不是很难 / 该怎么选」)`,` → 直接给判断和理由;笔记口径与个人观点分开说(「本页的立场是…;我的看法是…」)。`,` 页面没写不构成不答的理由。`,``,`已懂不查:已是通用知识或对话里已读过的内容,直接用 —— 不必为同一信息再读页面;`,`只有要断言「页面上写了什么」时才需要读页核实。`,`出处密度:只有「对页面内容的断言」才标出处(句末括注即可);概念解释、个人观点、`,`过渡句一律不标。「没找到」的说明压成一句,不报检索过程。`].join(`
192
+ `),answerLanesEn:[`[Answer lanes: classify the question first, then pick the discipline]`,`User questions fall into three categories; picking the wrong lane is the biggest way to miss the point:`,`A. Asking about page content ("what does this page say / where is it mentioned / what is the original text / what does this passage mean")`,` → Ground answers in what the page actually says and cite where it came from; when the page conflicts with your prior knowledge, the page wins; if the page does not say it, say so in one sentence — do not enumerate which sections you searched.`,`B. Asking about a concept or term ("what is X / what does it mean / how do X and Y differ")`,` → If the page has context for it, explain in that context first; if the page does not, you MUST still explain it directly from your own knowledge,`,` opening with one line like "Not covered on this page — general explanation:" — never treat "it is not on the page" as the answer.`,`C. Asking for your opinion or experience ("what do you think / in your experience / is it hard to match / which should I choose")`,` → Give your judgment and reasoning directly; keep the notes' stance and your own view separate ("this page's position is ...; my take is ...").`,` The page not covering it is never a reason to refuse.`,``,`Known means no lookup: use general knowledge you already master, and anything already read in this conversation,`,`directly — never re-read the page for information you already have; only claims about "what the page says" require reading to verify.`,`Citation density: only claims about page content get a citation (a short parenthetical); concept explanations,`,`personal opinions, and transitions get none. Compress "not found" statements to one sentence; never narrate the search process.`].join(`
193
193
  `),htmlPageOrchestrator:NG(`html`),htmlPageProposeFirst:[`【新建/创意类请求】先用简短文字给出 2~3 套方案(每套一两句风格/配色/结构要点),询问用户选哪套;选定前不要委派生成代码、不要写 components。`,`【方案切换】已生成某套方案后改选另一套:不重新罗列,直接依据之前描述重新委派生成并覆盖相应组件(委派工具见编排段 use_<id>)。`].join(`
194
194
  `),htmlDirectWriteFallback:[`【纯代码组件 · 你直接写】当前未配备 html 子 agent,纯代码组件的代码字段(code,以 schema 声明为准)由你直接 write(普通字段,经 schema 校验 + 乐观锁 + 快照栈,与改其他字段无异;无 vfs 工作副本 / 无格式校验门禁)。`,`【HTML 生成规范】代码字段必须是完整、自包含的 HTML 页面(含 <style>/<script>,可独立成页):标签正确闭合、style/script 集中放置(如 <head> 内)、class 加前缀防冲突;可引外部 JS/CSS(CDN/字体)。安全底线:禁 eval/new Function、不引可疑外部脚本、不访问 document.cookie 等敏感属性。`,`【修改而非重写】改已有代码:先 read({jsonPath}) 取当前代码字段 → 基于当前值增量改(只动要改的部分,如换配色/文案/某段结构),不要整体重写整个代码字段(易丢已有内容、token 浪费)。`,`【质量自检】无格式校验门禁,写完自查标签闭合 / 结构完整;代码进 data 由集成方渲染层(v-html/iframe)呈现。如需代码资产机制(vfs 工作副本 + 格式校验 + 增量 commit),注册 createHtmlSubagent。`].join(`
195
195
  `)},FG=15,IG=4e3,LG=new WeakMap;function RG(e,t){if(!e)return``;let n=t?`${t.maxKeys??``}|${t.maxChars??``}`:``;if(typeof e==`object`){let t=LG.get(e);if(t&&t.optsKey===n)return t.hint}let r=zG(e,t);return typeof e==`object`&&LG.set(e,{optsKey:n,hint:r}),r}function zG(e,t){let n=OG(e);if(n){let r=t?.maxKeys??FG,i=t?.maxChars??IG;if(n.split(`
@@ -7754,6 +7754,8 @@ var Qp = {
7754
7754
  " → 直接给判断和理由;笔记口径与个人观点分开说(「本页的立场是…;我的看法是…」)。",
7755
7755
  " 页面没写不构成不答的理由。",
7756
7756
  "",
7757
+ "已懂不查:已是通用知识或对话里已读过的内容,直接用 —— 不必为同一信息再读页面;",
7758
+ "只有要断言「页面上写了什么」时才需要读页核实。",
7757
7759
  "出处密度:只有「对页面内容的断言」才标出处(句末括注即可);概念解释、个人观点、",
7758
7760
  "过渡句一律不标。「没找到」的说明压成一句,不报检索过程。"
7759
7761
  ].join("\n"),
@@ -7769,6 +7771,8 @@ var Qp = {
7769
7771
  " → Give your judgment and reasoning directly; keep the notes' stance and your own view separate (\"this page's position is ...; my take is ...\").",
7770
7772
  " The page not covering it is never a reason to refuse.",
7771
7773
  "",
7774
+ "Known means no lookup: use general knowledge you already master, and anything already read in this conversation,",
7775
+ "directly — never re-read the page for information you already have; only claims about \"what the page says\" require reading to verify.",
7772
7776
  "Citation density: only claims about page content get a citation (a short parenthetical); concept explanations,",
7773
7777
  "personal opinions, and transitions get none. Compress \"not found\" statements to one sentence; never narrate the search process."
7774
7778
  ].join("\n"),
@@ -57631,6 +57631,8 @@ var d$ = {
57631
57631
  " → 直接给判断和理由;笔记口径与个人观点分开说(「本页的立场是…;我的看法是…」)。",
57632
57632
  " 页面没写不构成不答的理由。",
57633
57633
  "",
57634
+ "已懂不查:已是通用知识或对话里已读过的内容,直接用 —— 不必为同一信息再读页面;",
57635
+ "只有要断言「页面上写了什么」时才需要读页核实。",
57634
57636
  "出处密度:只有「对页面内容的断言」才标出处(句末括注即可);概念解释、个人观点、",
57635
57637
  "过渡句一律不标。「没找到」的说明压成一句,不报检索过程。"
57636
57638
  ].join("\n"),
@@ -57646,6 +57648,8 @@ var d$ = {
57646
57648
  " → Give your judgment and reasoning directly; keep the notes' stance and your own view separate (\"this page's position is ...; my take is ...\").",
57647
57649
  " The page not covering it is never a reason to refuse.",
57648
57650
  "",
57651
+ "Known means no lookup: use general knowledge you already master, and anything already read in this conversation,",
57652
+ "directly — never re-read the page for information you already have; only claims about \"what the page says\" require reading to verify.",
57649
57653
  "Citation density: only claims about page content get a citation (a short parenthetical); concept explanations,",
57650
57654
  "personal opinions, and transitions get none. Compress \"not found\" statements to one sentence; never narrate the search process."
57651
57655
  ].join("\n"),
@@ -48,8 +48,8 @@ self.onmessage = async (e) => {
48
48
  `)}catch{}return``}var qp={pageBuilder:{systemPrompt:`你是页面构建助手。按用户意图读写主数据(经 data 声明 + schema 校验),改完页面实时更新。`},researcher:{systemPrompt:`你是调研助手。多路调研用 spawn_agents 并行委派子 agent(各负责一个方向);单份资料用 fetch_document 抓取;最后结构化汇总,给出结论与依据。`,subagent:{maxParallel:4}},minimal:{capabilities:{planning:!1,skills:!1,vfs:!1,summarization:!1,memory:!1,subagent:!1}}};function Jp(e,t=`code`,n=!0){let r=`use_${e}`;return[`【先判意图(防长对话误路由)】先判断用户是「问」还是「要生成/改」:**提问类**(这是什么组件/怎么用/某字段什么意思/为什么这样/解释代码)→ 用 read / list_components / rag_component_docs **直接回答**,绝不委派 ${r};**生成/修改类**(做一个/生成/改成/加一个 XX 组件)才按下面纪律委派 ${r}。长对话里上文全是生成记录时尤须警惕,不要把新问题当成延续旧任务。`,`【多方案征询=先文本】用户要「出几套/两套方案我来选」「给几个选择」「先出方案看看」→ **本轮只出文本方案**(每套一两句:布局/配色/交互差异),经 request_human_confirmation 的 options 让用户点选(或等用户回复选定);**选定后才**委派 ${r} 建所选方案。禁止先并发多个子 agent 把每套方案都生成出来再让用户挑(子 agent 产物当不了选项清单,且烧 token;真 LLM 实测踩过:「出两套方案」被路由成两个 use_${e} 委派)。`,`【执行纪律(最重要)】收到代码组件任务后:**新建类直接委派**(追加组件无需通读/翻页现有数组,子 agent 自会采样一个组件看结构;**新建组件由子 agent 全权创建** —— 它自己把整个组件(含 ${t})写进数组,你不需要也不能替它创建/追加/落地代码)→ 修改类才 read 定位(by name)→ 调 ${r} 委派 → read 核对 → 回复用户。**中间绝不输出过渡性文字** —— 「我先看看…」「稍后委派」「接下来我会…」这类计划性回复等于任务没做就结束了(回复即本轮终止);所有调研和委派在本轮内连续完成,完成后才回复总结。`,`【产物形态】每个组件是完整、自包含的 HTML 页面(含 style/script,可独立成页);你只负责委派和收尾,不关心宿主如何渲染(v-html / iframe / SFC 是集成方的事)。`,`【主 agent 职责边界(硬规则)】禁止直接 read/write 代码组件的 ${t} 字段(read 只得 <code Nkb> 摘要没用;write 绕过 vfs/verify 危险)—— 生成/修改/排查代码一律经 ${r},收尾 read 核对。**委派返回即已落地**:${r} 的结论说「已创建组件 X」= 组件已在数组里,**不要再 write/append 一遍**(子 agent 已自己创建,你再写 = 造出重复组件,还得花轮次删;真 LLM 实测踩过:主 agent 把返回的 code 又追加了一次 → 索引 8/9 重复)。核对方式 = read 该数组尾部(确认新组件存在 + name 唯一),仅此而已。`,`【多组件委派(防上下文污染)】一次要多个组件:① write_todos 列出(每项 name + 要点)② **不同组件可在同一轮并行发多个 ${r} 委派**(每组件一次 ${r},task 只写该组件 name + 要点 + 主题/风格;每次委派是独立子 agent 实例,互不共享上下文);**同一组件同一时间只能有一个委派在途**,勿对同一组件同轮发两个委派 ③ 委派返回后逐个 read 核对(确认已生成 + 名称对)+ update_todo 标完成 ④ 主题/风格在每次 task 里转述(每个子 agent 全新上下文,不知其他组件)。一次 task 塞多个组件仍禁止(同一子 agent 共享上下文生成多个 → class/样式冲突污染);主 agent 自己的 write(普通组件属性)可与委派同轮发出,不必等委派返回。`,`【委派 task 规格化(收窄子 agent 决策,防开放任务致装饰穷举)】委派 ${r} 的 task 必须含:① 组件定位(by name)② 视觉风格(配色/质感/字体;**给 1-2 个具体视觉锚** —— 主色 hex **取自平台 UI/设计规范 skill 的定义值**(有规范类 skill 先 load 再引用其 hex,勿凭页面观察自造近似色;无规范才自定,如「金黄 #F7C948」)、主体占比(如「杯高约画布 60%」)或装饰密度(如「仅 2 类背景装饰」)—— 细节空间收窄,子 agent 不在装饰细节上展开推演)③ 内容(文案/数据/图)④ 交互意图(动效/状态/触发)⑤ 历史偏好(可选):聊天上下文中有与该组件相关的用户历史偏好/反馈(如「用户偏好深色系」「上轮嫌动画太快」),提炼一句附 task 末尾(新子 agent 无记忆,全靠 task);**不含技术实现**(SVG vs CSS / keyframes vs transition 归子 agent 选)。❌「生成啤酒杯动画」→ ✅「啤酒杯倒酒(beer):金黄啤酒 #F7C948 从上方倒入透明杯(杯高约画布 60%),深绿背景,液体循环下落 2s,hover 杯子放大」。规格简练(4 要素各半句),远省子 agent 思考 token。`,`【委派失败重试】${r} 返回乱码/内部标记(如 <|DSML|)/空结论或报错 = 子 agent 异常,**重新委派一次**(task 附「上次失败,这次先把代码写短些/分步」);连续两次失败才降级告知用户。**不要因此自己直接 write/edit ${t} 字段**(绕过 vfs/格式校验,且你拿不到规范全文)。`,...n?[`【设计品味引导】子 agent 内置 web-design-engineer 设计 skill(设计系统先声明/反 AI 俗套/25 风格配方/5 维自评;**挂在子 agent 侧,你自己 load 不到也不必尝试**)。委派 task 的视觉锚可直接引用配方名 —— linear / apple-hig / muji / pentagram / bloomberg-terminal / aesop 等(如「Linear 风格:暖深色+发丝线」),子 agent 会按名取配方参数照做;用户未指定风格时勿写「随便/好看就行」,给一条具体方向(流派或参考品牌),子 agent 按其 skill 流程选配方并在结论里声明设计系统与假设。`]:[],`【预算将尽暂停】组件很多、接近工具轮次上限不要硬扛:完成手头这个后报告「已生成 K/N,还剩 M 个」,等用户确认后从 todos 剩余项继续(勿重复已完成)。`].join(`
49
49
  `)}var Yp={reliableWriteRules:[`【可靠写入规则】`,`1. 改任何字段前,先用 read({ jsonPath }) 读其当前真实值,基于真实值改,不要凭记忆;`,`2. 若不确定可操作哪些字段,先 read() 不传 jsonPath 查看主数据说明 + schema 声明字段(集成方可经 sdk.setData 运行时替换 schema,以工具返回为准,勿凭旧记忆);`,`3. 不确定某字段结构时,read({ jsonPath }) 返回含格式说明,字段以返回为准;`,`4. 写入若被 schema 校验拒绝(返回结构化错误含字段名与期望类型),按错误修正后重试,不要放弃;`,`5. 优先用 write 的 patch 增量改(只发改动,如 write({ value, patch:{ op, jsonPath } })),避免整体重传大 JSON 被截断;`,`6. 写入若触发乐观锁冲突(返回 VERSION_CONFLICT 或工具挂起等用户决定):等工具返回结果后按其指示继续(保留外部值 → 重新 read 再改;已覆盖/已回退 → 基于结果重写),不要放弃任务。`].join(`
50
50
  `),reliableWriteRulesEn:[`[Reliable write rules]`,`1. Before changing any field, read its current real value with read({ jsonPath }) and edit based on that value, never from memory;`,`2. If unsure which fields are operable, call read() without jsonPath first to see the data description + schema-declared fields (the integrator can replace the schema at runtime via sdk.setData; trust the tool response over stale memory);`,`3. When unsure about a field structure, the read({ jsonPath }) response includes a format description; treat the response as the source of truth;`,`4. If a write is rejected by schema validation (the structured error names the field and expected type), fix it per the error and retry; do not give up;`,`5. Prefer incremental write patches (send only the change, e.g. write({ value, patch:{ op, jsonPath } })) over resending the whole large JSON, which risks truncation;`,`6. If a write hits an optimistic-lock conflict (VERSION_CONFLICT returned, or the tool suspends awaiting the user decision): after the tool returns, follow its instruction (keep external → re-read then edit; overwritten/restored → continue from the result); do not abandon the task.`].join(`
51
- `),answerLanes:[`【作答车道:先判问题形态,再选纪律】`,`用户的问题分三类,判错车道是最大的答非所问:`,`A. 问页面内容(「这页写了什么 / 哪里提到 / 原文是什么 / 这段在说什么」)`,` → 以页面实料为准并点明出处;页面内容与你的先验知识冲突时以页面为准;页面没写就说没写,一句话即可,不列举查过哪些节。`,`B. 问概念术语(「X 是什么 / 啥意思 / X 和 Y 什么区别」)`,` → 页面有语境就先按页面语境讲;页面没有也必须直接用自己的知识解释,`,` 开头一句「本页未提及,以下是通用解释:」即可 —— 不许把「页面上没有」当答案。`,`C. 求观点经验(「你觉得呢 / 按你的经验 / 是不是很难 / 该怎么选」)`,` → 直接给判断和理由;笔记口径与个人观点分开说(「本页的立场是…;我的看法是…」)。`,` 页面没写不构成不答的理由。`,``,`出处密度:只有「对页面内容的断言」才标出处(句末括注即可);概念解释、个人观点、`,`过渡句一律不标。「没找到」的说明压成一句,不报检索过程。`].join(`
52
- `),answerLanesEn:[`[Answer lanes: classify the question first, then pick the discipline]`,`User questions fall into three categories; picking the wrong lane is the biggest way to miss the point:`,`A. Asking about page content ("what does this page say / where is it mentioned / what is the original text / what does this passage mean")`,` → Ground answers in what the page actually says and cite where it came from; when the page conflicts with your prior knowledge, the page wins; if the page does not say it, say so in one sentence — do not enumerate which sections you searched.`,`B. Asking about a concept or term ("what is X / what does it mean / how do X and Y differ")`,` → If the page has context for it, explain in that context first; if the page does not, you MUST still explain it directly from your own knowledge,`,` opening with one line like "Not covered on this page — general explanation:" — never treat "it is not on the page" as the answer.`,`C. Asking for your opinion or experience ("what do you think / in your experience / is it hard to match / which should I choose")`,` → Give your judgment and reasoning directly; keep the notes' stance and your own view separate ("this page's position is ...; my take is ...").`,` The page not covering it is never a reason to refuse.`,``,`Citation density: only claims about page content get a citation (a short parenthetical); concept explanations,`,`personal opinions, and transitions get none. Compress "not found" statements to one sentence; never narrate the search process.`].join(`
51
+ `),answerLanes:[`【作答车道:先判问题形态,再选纪律】`,`用户的问题分三类,判错车道是最大的答非所问:`,`A. 问页面内容(「这页写了什么 / 哪里提到 / 原文是什么 / 这段在说什么」)`,` → 以页面实料为准并点明出处;页面内容与你的先验知识冲突时以页面为准;页面没写就说没写,一句话即可,不列举查过哪些节。`,`B. 问概念术语(「X 是什么 / 啥意思 / X 和 Y 什么区别」)`,` → 页面有语境就先按页面语境讲;页面没有也必须直接用自己的知识解释,`,` 开头一句「本页未提及,以下是通用解释:」即可 —— 不许把「页面上没有」当答案。`,`C. 求观点经验(「你觉得呢 / 按你的经验 / 是不是很难 / 该怎么选」)`,` → 直接给判断和理由;笔记口径与个人观点分开说(「本页的立场是…;我的看法是…」)。`,` 页面没写不构成不答的理由。`,``,`已懂不查:已是通用知识或对话里已读过的内容,直接用 —— 不必为同一信息再读页面;`,`只有要断言「页面上写了什么」时才需要读页核实。`,`出处密度:只有「对页面内容的断言」才标出处(句末括注即可);概念解释、个人观点、`,`过渡句一律不标。「没找到」的说明压成一句,不报检索过程。`].join(`
52
+ `),answerLanesEn:[`[Answer lanes: classify the question first, then pick the discipline]`,`User questions fall into three categories; picking the wrong lane is the biggest way to miss the point:`,`A. Asking about page content ("what does this page say / where is it mentioned / what is the original text / what does this passage mean")`,` → Ground answers in what the page actually says and cite where it came from; when the page conflicts with your prior knowledge, the page wins; if the page does not say it, say so in one sentence — do not enumerate which sections you searched.`,`B. Asking about a concept or term ("what is X / what does it mean / how do X and Y differ")`,` → If the page has context for it, explain in that context first; if the page does not, you MUST still explain it directly from your own knowledge,`,` opening with one line like "Not covered on this page — general explanation:" — never treat "it is not on the page" as the answer.`,`C. Asking for your opinion or experience ("what do you think / in your experience / is it hard to match / which should I choose")`,` → Give your judgment and reasoning directly; keep the notes' stance and your own view separate ("this page's position is ...; my take is ...").`,` The page not covering it is never a reason to refuse.`,``,`Known means no lookup: use general knowledge you already master, and anything already read in this conversation,`,`directly — never re-read the page for information you already have; only claims about "what the page says" require reading to verify.`,`Citation density: only claims about page content get a citation (a short parenthetical); concept explanations,`,`personal opinions, and transitions get none. Compress "not found" statements to one sentence; never narrate the search process.`].join(`
53
53
  `),htmlPageOrchestrator:Jp(`html`),htmlPageProposeFirst:[`【新建/创意类请求】先用简短文字给出 2~3 套方案(每套一两句风格/配色/结构要点),询问用户选哪套;选定前不要委派生成代码、不要写 components。`,`【方案切换】已生成某套方案后改选另一套:不重新罗列,直接依据之前描述重新委派生成并覆盖相应组件(委派工具见编排段 use_<id>)。`].join(`
54
54
  `),htmlDirectWriteFallback:[`【纯代码组件 · 你直接写】当前未配备 html 子 agent,纯代码组件的代码字段(code,以 schema 声明为准)由你直接 write(普通字段,经 schema 校验 + 乐观锁 + 快照栈,与改其他字段无异;无 vfs 工作副本 / 无格式校验门禁)。`,`【HTML 生成规范】代码字段必须是完整、自包含的 HTML 页面(含 <style>/<script>,可独立成页):标签正确闭合、style/script 集中放置(如 <head> 内)、class 加前缀防冲突;可引外部 JS/CSS(CDN/字体)。安全底线:禁 eval/new Function、不引可疑外部脚本、不访问 document.cookie 等敏感属性。`,`【修改而非重写】改已有代码:先 read({jsonPath}) 取当前代码字段 → 基于当前值增量改(只动要改的部分,如换配色/文案/某段结构),不要整体重写整个代码字段(易丢已有内容、token 浪费)。`,`【质量自检】无格式校验门禁,写完自查标签闭合 / 结构完整;代码进 data 由集成方渲染层(v-html/iframe)呈现。如需代码资产机制(vfs 工作副本 + 格式校验 + 增量 commit),注册 createHtmlSubagent。`].join(`
55
55
  `)},Xp=15,Zp=4e3,Qp=new WeakMap;function $p(e,t){if(!e)return``;let n=t?`${t.maxKeys??``}|${t.maxChars??``}`:``;if(typeof e==`object`){let t=Qp.get(e);if(t&&t.optsKey===n)return t.hint}let r=em(e,t);return typeof e==`object`&&Qp.set(e,{optsKey:n,hint:r}),r}function em(e,t){let n=Up(e);if(n){let r=t?.maxKeys??Xp,i=t?.maxChars??Zp;if(n.split(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "page-agent-sdk",
3
- "version": "4.24.1",
3
+ "version": "4.24.2",
4
4
  "type": "module",
5
5
  "description": "AI agent SDK for web pages — embed a chat assistant that edits page data via schema-validated tools. A lighter, framework-agnostic alternative to CopilotKit/LangChain for in-page JSON-editing agents. Vue-bundled; works with DeepSeek, OpenAI, MCP.",
6
6
  "main": "./dist/page-agent-sdk.umd.cjs",