page-agent-sdk 4.19.2 → 4.20.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "page-agent-sdk",
3
- "version": "4.19.2",
3
+ "version": "4.20.0",
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",
@@ -413,7 +413,7 @@ export interface AgentInfo {
413
413
  /** 方案确认留痕(save-and-plan-gates 3c:RHC 带 options 的方案被点选;undefined=本会话无已确认方案) */
414
414
  planConfirmation?: PlanConfirmationRecord;
415
415
  /** 宿主动作元信息(actions 注册;集成方 save_draft/publish 等) */
416
- actions?: Record<string, { description: string; hasParams: boolean }>;
416
+ actions?: Record<string, { description: string; hasParams: boolean; readsHostState?: boolean; deferredWrite?: boolean }>;
417
417
  /** 跨压缩工作记忆(workingMemory 中间件;pin 最近 read/query/search 定位 path + read hash,≤10 LRU) */
418
418
  workingMemory?: WorkingMemory;
419
419
  /** 写驱动过期读失效会话累计(stale-read-invalidation;写后旧 read/query/search 结果被替换为占位的次数) */
@@ -926,6 +926,10 @@ export interface ActionDef {
926
926
  run: (args: Record<string, unknown>) => unknown | Promise<unknown>;
927
927
  /** 可选参数 schema(ZodObject);不传 = 无参 tool */
928
928
  params?: any;
929
+ /** 标记本 action 读取宿主态(4.20+):旧工具结果随 `sdk.notifyHostChange()` 替换为过期占位(修前仅 read_page 等五个内置页面读工具享受,action 仅靠 reason 文案口头告知);页面断言门禁的「页面依据」计数也计入。不标记 = 现行为零变化 */
930
+ readsHostState?: boolean;
931
+ /** 标记本 action 的效果延迟到用户确认才生效(提案类,4.20+):调用成功 ≠ 已写入 → 零工具门禁事实清单对此类调用注记「待用户确认后才生效」,防模型收口「已修改完成」;等效写计数不含此类。不标记 = 现行为零变化 */
932
+ deferredWrite?: boolean;
929
933
  }
930
934
  /** actions 配置:动作名 → 定义(动作名即 tool 名,须合法标识符) */
931
935
  export type ActionMap = Record<string, ActionDef>;
@@ -1496,7 +1500,7 @@ export declare const getDomTool: any;
1496
1500
  export declare function domToStructure(node: Element | null, opts: { depth: number; attrs?: string[]; includeText?: boolean }): DomNode | null;
1497
1501
  /** 把集成方注册的 actions 转成命名 tool 数组(每个 action 一个 tool) */
1498
1502
  export declare function actionsToTools(actions: ActionMap): any[];
1499
- export declare function actionsToInspectInfo(actions: ActionMap): Record<string, { description: string; hasParams: boolean }>;
1503
+ export declare function actionsToInspectInfo(actions: ActionMap): Record<string, { description: string; hasParams: boolean; readsHostState: boolean; deferredWrite: boolean }>;
1500
1504
  export interface DomNode { tag: string; attrs: Record<string, string>; text?: string; children?: DomNode[]; childCount?: number }
1501
1505
  export interface DomReadOptions { depth: number; attrs?: string[]; includeText?: boolean }
1502
1506
 
@@ -1599,6 +1603,10 @@ export interface CreateAgentOptions {
1599
1603
  * 传入(仅页面问答形态装配 —— 数据槽场景「页面上已改成…」误伤路径从结构上切断);false/缺省 = 门禁层不进判定。
1600
1604
  */
1601
1605
  pageAssertionGate?: boolean;
1606
+ /** 有效页面读集扩展(action-host-semantics,4.20):宿主标记 readsHostState 的 action 名 —— 进页面断言门禁「页面依据」计数;缺省 = 仅默认五工具 */
1607
+ pageReadTools?: Set<string>;
1608
+ /** 延迟生效写 action 名集(action-host-semantics,4.20):零工具门禁事实清单对其调用注记「待用户确认后才生效」;缺省 = 清单与现行为逐字节一致 */
1609
+ deferredWriteTools?: Set<string>;
1602
1610
  /** LLM 运行时切换回调(setLlm 后触发,供重解析模型能力 contextWindow/maxOutputTokens) */
1603
1611
  onLlmChange?: (newLlm: import('@langchain/core/language_models/chat_models').BaseChatModel) => void;
1604
1612
  /** 显式声明主模型是否多模态识图(声明 > 查表 > 缺省 false) */
package/types/index.d.ts CHANGED
@@ -722,7 +722,7 @@ export interface AgentInfo {
722
722
  /** 方案确认留痕(save-and-plan-gates 3c:RHC 带 options 的方案被点选;undefined=本会话无已确认方案) */
723
723
  planConfirmation?: PlanConfirmationRecord;
724
724
  /** 宿主动作元信息(actions 注册;集成方 save_draft/publish 等) */
725
- actions?: Record<string, { description: string; hasParams: boolean }>;
725
+ actions?: Record<string, { description: string; hasParams: boolean; readsHostState?: boolean; deferredWrite?: boolean }>;
726
726
  /** 跨压缩工作记忆(workingMemory 中间件;pin 最近 read/query/search 定位 path + read hash,≤10 LRU) */
727
727
  workingMemory?: WorkingMemory;
728
728
  /** 写驱动过期读失效会话累计(stale-read-invalidation;写后旧 read/query/search 结果被替换为占位的次数) */
@@ -1286,6 +1286,10 @@ export interface ActionDef {
1286
1286
  run: (args: Record<string, unknown>) => unknown | Promise<unknown>;
1287
1287
  /** 可选参数 schema(ZodObject);不传 = 无参 tool */
1288
1288
  params?: any;
1289
+ /** 标记本 action 读取宿主态(4.20+):旧工具结果随 `sdk.notifyHostChange()` 替换为过期占位(修前仅 read_page 等五个内置页面读工具享受,action 仅靠 reason 文案口头告知);页面断言门禁的「页面依据」计数也计入。不标记 = 现行为零变化 */
1290
+ readsHostState?: boolean;
1291
+ /** 标记本 action 的效果延迟到用户确认才生效(提案类,4.20+):调用成功 ≠ 已写入 → 零工具门禁事实清单对此类调用注记「待用户确认后才生效」,防模型收口「已修改完成」;等效写计数不含此类。不标记 = 现行为零变化 */
1292
+ deferredWrite?: boolean;
1289
1293
  }
1290
1294
  /** actions 配置:动作名 → 定义(动作名即 tool 名,须合法标识符) */
1291
1295
  export type ActionMap = Record<string, ActionDef>;
@@ -1925,7 +1929,7 @@ export declare const getDomTool: any;
1925
1929
  export declare function domToStructure(node: Element | null, opts: { depth: number; attrs?: string[]; includeText?: boolean }): DomNode | null;
1926
1930
  /** 把集成方注册的 actions 转成命名 tool 数组(每个 action 一个 tool) */
1927
1931
  export declare function actionsToTools(actions: ActionMap): any[];
1928
- export declare function actionsToInspectInfo(actions: ActionMap): Record<string, { description: string; hasParams: boolean }>;
1932
+ export declare function actionsToInspectInfo(actions: ActionMap): Record<string, { description: string; hasParams: boolean; readsHostState: boolean; deferredWrite: boolean }>;
1929
1933
  export interface DomNode { tag: string; attrs: Record<string, string>; text?: string; children?: DomNode[]; childCount?: number }
1930
1934
  export interface DomReadOptions { depth: number; attrs?: string[]; includeText?: boolean }
1931
1935
 
@@ -2028,6 +2032,10 @@ export interface CreateAgentOptions {
2028
2032
  * 传入(仅页面问答形态装配 —— 数据槽场景「页面上已改成…」误伤路径从结构上切断);false/缺省 = 门禁层不进判定。
2029
2033
  */
2030
2034
  pageAssertionGate?: boolean;
2035
+ /** 有效页面读集扩展(action-host-semantics,4.20):宿主标记 readsHostState 的 action 名 —— 进页面断言门禁「页面依据」计数;缺省 = 仅默认五工具 */
2036
+ pageReadTools?: Set<string>;
2037
+ /** 延迟生效写 action 名集(action-host-semantics,4.20):零工具门禁事实清单对其调用注记「待用户确认后才生效」;缺省 = 清单与现行为逐字节一致 */
2038
+ deferredWriteTools?: Set<string>;
2031
2039
  /** LLM 运行时切换回调(setLlm 后触发,供重解析模型能力 contextWindow/maxOutputTokens) */
2032
2040
  onLlmChange?: (newLlm: import('@langchain/core/language_models/chat_models').BaseChatModel) => void;
2033
2041
  /** 显式声明主模型是否多模态识图(声明 > 查表 > 缺省 false) */