page-agent-sdk 3.41.0 → 3.43.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": "3.41.0",
3
+ "version": "3.43.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",
@@ -328,6 +328,8 @@ export interface AgentInfo {
328
328
  actions?: Record<string, { description: string; hasParams: boolean }>;
329
329
  /** 跨压缩工作记忆(workingMemory 中间件;pin 最近 read/query/search 定位 path + read hash,≤10 LRU) */
330
330
  workingMemory?: WorkingMemory;
331
+ /** 写驱动过期读失效会话累计(stale-read-invalidation;写后旧 read/query/search 结果被替换为占位的次数) */
332
+ staleReadsInvalidated?: number;
331
333
  /** 当前上下文聚焦焦点(focus 中间件;兼容:首个;未聚焦/未开启 → undefined) */
332
334
  focus?: Focus;
333
335
  /** 全部聚焦焦点(multi-focus;空数组=未聚焦) */
@@ -490,11 +492,6 @@ export interface DataConfig {
490
492
  * 配置后 read 受保护路径返占位符(精确值不入 LLM 消息流),写侧强制(freeze 拒/verbatim 展开校验)。
491
493
  * opt-in:未配(默认)全部行为零变化 */
492
494
  resources?: ResourceProtectSpec[];
493
- /**
494
- * 装配期工具白名单(main-surface-slim Phase 1):`'high'` 预设(全量减旧四件 get/set/edit/delete_data)/
495
- * 具体名单(按名过滤,未装配名 warn 留痕)。不传 = 全量零回归;仅首次装配生效,运行时 setData 忽略。
496
- */
497
- tools?: string[] | 'high';
498
495
  }
499
496
  /** createDataOps 选项(审计回调 / 快照上限 / 乐观锁) */
500
497
  export interface DataOpsOptions {
@@ -504,11 +501,6 @@ export interface DataOpsOptions {
504
501
  onConflict?: (conflict: ConflictInfo) => Promise<ConflictResolution>;
505
502
  /** 冲突监听字段白名单(任意深度字段名):声明后仅这些字段的值变动触发自动冲突检测(位置不敏感);未声明 = 不开自动检测(仅显式 expectedHash 校验);['*'] = 全字段检测(旧 autoLock 行为) */
506
503
  conflictWatchFields?: string[];
507
- /**
508
- * 装配期工具白名单(main-surface-slim Phase 1):`'high'` 预设(全量减旧四件 get/set/edit/delete_data)/
509
- * 具体名单(按名过滤,未装配名 warn 留痕)。不传 = 全量零回归。
510
- */
511
- tools?: string[] | 'high';
512
504
  }
513
505
 
514
506
  /** 数据操作控制器(运行时替换配置;createDataOps 返回的工具数组上以不可枚举属性 `controller` 挂载) */
@@ -814,7 +806,7 @@ export interface ChatSdkOptions {
814
806
  permissions?: PermissionRule[];
815
807
  /** 自定义中间件(注入到内置中间件之后;可拦截/观察模型调用、工具、prompt) */
816
808
  middleware?: any[];
817
- vfs?: { initialFiles?: Record<string, string>; maxBytes?: number; poolBytes?: { largeResults?: number; drafts?: number; userFiles?: number }; mainTools?: boolean };
809
+ vfs?: { initialFiles?: Record<string, string>; maxBytes?: number; poolBytes?: { largeResults?: number; drafts?: number; userFiles?: number } };
818
810
  /** 每个数据对象最多保留快照数(默认 20) */
819
811
  maxSnapshots?: number;
820
812
  /** 乐观锁冲突裁决策略(默认 'ask'):ask=挂起 pendingConflict 等人工 resolveConflict;overwrite=agent 强制覆盖(宿主与 agent 争同一份数据且 agent 优先时用,冲突自动收口不挂起,无人值守场景防永挂);keep_external=自动保留外部修改(agent 收到提示重新 read)。自动裁决仍外发 conflict 事件(conflict.autoResolved 标记) */
@@ -838,6 +830,8 @@ export interface ChatSdkOptions {
838
830
  tokenBudget?: number;
839
831
  /** 单次 invoke 的 token 预算上限(opt-in,默认关):本次 agent 调用累计 total_tokens 超限 → 中断收口(observable emit + 友好文本,已完成部分保留);与 automation 全局 tokenBudget 正交 */
840
832
  roundTokenBudget?: number;
833
+ /** 写驱动过期读失效(stale-read-invalidation,默认 true):单次 invoke 窗口内,本批成功写之后被击中路径的旧 read/query/search 结果替换为失效占位(防模型凭旧快照答状态/用错位索引)。false = 主/子一致关闭零变化 */
834
+ staleReadInvalidation?: boolean;
841
835
  /** 时间预算 ms(从 agent 开始计时,超过 → 停止;需 capabilities.automation:true) */
842
836
  timeBudgetMs?: number;
843
837
  /** 无人值守错误恢复:致命错误(invoke 抛错)自动 restore_last_checkpoint + 重试次数(默认 1;防单点错误永久中断批量/长任务)。需 capabilities.automation:true */
package/types/index.d.ts CHANGED
@@ -666,6 +666,8 @@ export interface AgentInfo {
666
666
  actions?: Record<string, { description: string; hasParams: boolean }>;
667
667
  /** 跨压缩工作记忆(workingMemory 中间件;pin 最近 read/query/search 定位 path + read hash,≤10 LRU) */
668
668
  workingMemory?: WorkingMemory;
669
+ /** 写驱动过期读失效会话累计(stale-read-invalidation;写后旧 read/query/search 结果被替换为占位的次数) */
670
+ staleReadsInvalidated?: number;
669
671
  /** 当前上下文聚焦焦点(focus 中间件;兼容:首个;未聚焦/未开启 → undefined) */
670
672
  focus?: Focus;
671
673
  /** 全部聚焦焦点(multi-focus;空数组=未聚焦) */
@@ -854,11 +856,6 @@ export interface DataConfig {
854
856
  * 配置后 read 受保护路径返占位符(精确值不入 LLM 消息流),写侧强制(freeze 拒/verbatim 展开校验)。
855
857
  * opt-in:未配(默认)全部行为零变化 */
856
858
  resources?: ResourceProtectSpec[];
857
- /**
858
- * 装配期工具白名单(main-surface-slim Phase 1):`'high'` 预设(全量减旧四件 get/set/edit/delete_data)/
859
- * 具体名单(按名过滤,未装配名 warn 留痕)。不传 = 全量零回归;仅首次装配生效,运行时 setData 忽略。
860
- */
861
- tools?: string[] | 'high';
862
859
  }
863
860
  /** createDataOps 选项(审计回调 / 快照上限 / 乐观锁) */
864
861
  export interface DataOpsOptions {
@@ -868,11 +865,6 @@ export interface DataOpsOptions {
868
865
  onConflict?: (conflict: ConflictInfo) => Promise<ConflictResolution>;
869
866
  /** 冲突监听字段白名单(任意深度字段名):声明后仅这些字段的值变动触发自动冲突检测(位置不敏感);未声明 = 不开自动检测(仅显式 expectedHash 校验);['*'] = 全字段检测(旧 autoLock 行为) */
870
867
  conflictWatchFields?: string[];
871
- /**
872
- * 装配期工具白名单(main-surface-slim Phase 1):`'high'` 预设(全量减旧四件 get/set/edit/delete_data)/
873
- * 具体名单(按名过滤,未装配名 warn 留痕)。不传 = 全量零回归。
874
- */
875
- tools?: string[] | 'high';
876
868
  }
877
869
 
878
870
  /** 数据操作控制器(运行时替换配置;createDataOps 返回的工具数组上以不可枚举属性 `controller` 挂载) */
@@ -1203,7 +1195,7 @@ export interface ChatSdkOptions {
1203
1195
  permissions?: PermissionRule[];
1204
1196
  /** 自定义中间件(注入到内置中间件之后;可拦截/观察模型调用、工具、prompt) */
1205
1197
  middleware?: any[];
1206
- vfs?: { initialFiles?: Record<string, string>; maxBytes?: number; poolBytes?: { largeResults?: number; drafts?: number; userFiles?: number }; mainTools?: boolean };
1198
+ vfs?: { initialFiles?: Record<string, string>; maxBytes?: number; poolBytes?: { largeResults?: number; drafts?: number; userFiles?: number } };
1207
1199
  /** 每个数据对象最多保留快照数(默认 20) */
1208
1200
  maxSnapshots?: number;
1209
1201
  /** 乐观锁冲突裁决策略(默认 'ask'):ask=挂起 pendingConflict 等人工 resolveConflict;overwrite=agent 强制覆盖(宿主与 agent 争同一份数据且 agent 优先时用,冲突自动收口不挂起,无人值守场景防永挂);keep_external=自动保留外部修改(agent 收到提示重新 read)。自动裁决仍外发 conflict 事件(conflict.autoResolved 标记) */
@@ -1229,6 +1221,8 @@ export interface ChatSdkOptions {
1229
1221
  tokenBudget?: number;
1230
1222
  /** 单次 invoke 的 token 预算上限(opt-in,默认关):本次 agent 调用累计 total_tokens 超限 → 中断收口(observable emit + 友好文本,已完成部分保留);与 automation 全局 tokenBudget 正交 */
1231
1223
  roundTokenBudget?: number;
1224
+ /** 写驱动过期读失效(stale-read-invalidation,默认 true):单次 invoke 窗口内,本批成功写之后被击中路径的旧 read/query/search 结果替换为失效占位(防模型凭旧快照答状态/用错位索引)。false = 主/子一致关闭零变化 */
1225
+ staleReadInvalidation?: boolean;
1232
1226
  /** 时间预算 ms(从 agent 开始计时,超过 → 停止;需 capabilities.automation:true) */
1233
1227
  timeBudgetMs?: number;
1234
1228
  /** 无人值守错误恢复:致命错误(invoke 抛错)自动 restore_last_checkpoint + 重试次数(默认 1;防单点错误永久中断批量/长任务)。需 capabilities.automation:true */