page-agent-sdk 3.40.3 → 3.42.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 +6 -4
- package/README.zh-CN.md +6 -4
- package/dist/page-agent-sdk.headless.js +4412 -4166
- package/dist/page-agent-sdk.iife.js +158 -157
- package/dist/page-agent-sdk.js +6501 -6255
- package/dist/page-agent-sdk.legacy.js +18830 -18580
- package/dist/page-agent-sdk.umd.cjs +109 -108
- package/package.json +1 -1
- package/types/headless.d.ts +15 -1
- package/types/index.d.ts +15 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "page-agent-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.42.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",
|
package/types/headless.d.ts
CHANGED
|
@@ -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,6 +492,11 @@ export interface DataConfig {
|
|
|
490
492
|
* 配置后 read 受保护路径返占位符(精确值不入 LLM 消息流),写侧强制(freeze 拒/verbatim 展开校验)。
|
|
491
493
|
* opt-in:未配(默认)全部行为零变化 */
|
|
492
494
|
resources?: ResourceProtectSpec[];
|
|
495
|
+
/**
|
|
496
|
+
* 装配期工具白名单(main-surface-slim Phase 1):`'high'` 预设(全量减旧四件 get/set/edit/delete_data)/
|
|
497
|
+
* 具体名单(按名过滤,未装配名 warn 留痕)。不传 = 全量零回归;仅首次装配生效,运行时 setData 忽略。
|
|
498
|
+
*/
|
|
499
|
+
tools?: string[] | 'high';
|
|
493
500
|
}
|
|
494
501
|
/** createDataOps 选项(审计回调 / 快照上限 / 乐观锁) */
|
|
495
502
|
export interface DataOpsOptions {
|
|
@@ -499,6 +506,11 @@ export interface DataOpsOptions {
|
|
|
499
506
|
onConflict?: (conflict: ConflictInfo) => Promise<ConflictResolution>;
|
|
500
507
|
/** 冲突监听字段白名单(任意深度字段名):声明后仅这些字段的值变动触发自动冲突检测(位置不敏感);未声明 = 不开自动检测(仅显式 expectedHash 校验);['*'] = 全字段检测(旧 autoLock 行为) */
|
|
501
508
|
conflictWatchFields?: string[];
|
|
509
|
+
/**
|
|
510
|
+
* 装配期工具白名单(main-surface-slim Phase 1):`'high'` 预设(全量减旧四件 get/set/edit/delete_data)/
|
|
511
|
+
* 具体名单(按名过滤,未装配名 warn 留痕)。不传 = 全量零回归。
|
|
512
|
+
*/
|
|
513
|
+
tools?: string[] | 'high';
|
|
502
514
|
}
|
|
503
515
|
|
|
504
516
|
/** 数据操作控制器(运行时替换配置;createDataOps 返回的工具数组上以不可枚举属性 `controller` 挂载) */
|
|
@@ -804,7 +816,7 @@ export interface ChatSdkOptions {
|
|
|
804
816
|
permissions?: PermissionRule[];
|
|
805
817
|
/** 自定义中间件(注入到内置中间件之后;可拦截/观察模型调用、工具、prompt) */
|
|
806
818
|
middleware?: any[];
|
|
807
|
-
|
|
819
|
+
vfs?: { initialFiles?: Record<string, string>; maxBytes?: number; poolBytes?: { largeResults?: number; drafts?: number; userFiles?: number }; mainTools?: boolean };
|
|
808
820
|
/** 每个数据对象最多保留快照数(默认 20) */
|
|
809
821
|
maxSnapshots?: number;
|
|
810
822
|
/** 乐观锁冲突裁决策略(默认 'ask'):ask=挂起 pendingConflict 等人工 resolveConflict;overwrite=agent 强制覆盖(宿主与 agent 争同一份数据且 agent 优先时用,冲突自动收口不挂起,无人值守场景防永挂);keep_external=自动保留外部修改(agent 收到提示重新 read)。自动裁决仍外发 conflict 事件(conflict.autoResolved 标记) */
|
|
@@ -828,6 +840,8 @@ export interface ChatSdkOptions {
|
|
|
828
840
|
tokenBudget?: number;
|
|
829
841
|
/** 单次 invoke 的 token 预算上限(opt-in,默认关):本次 agent 调用累计 total_tokens 超限 → 中断收口(observable emit + 友好文本,已完成部分保留);与 automation 全局 tokenBudget 正交 */
|
|
830
842
|
roundTokenBudget?: number;
|
|
843
|
+
/** 写驱动过期读失效(stale-read-invalidation,默认 true):单次 invoke 窗口内,本批成功写之后被击中路径的旧 read/query/search 结果替换为失效占位(防模型凭旧快照答状态/用错位索引)。false = 主/子一致关闭零变化 */
|
|
844
|
+
staleReadInvalidation?: boolean;
|
|
831
845
|
/** 时间预算 ms(从 agent 开始计时,超过 → 停止;需 capabilities.automation:true) */
|
|
832
846
|
timeBudgetMs?: number;
|
|
833
847
|
/** 无人值守错误恢复:致命错误(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,6 +856,11 @@ export interface DataConfig {
|
|
|
854
856
|
* 配置后 read 受保护路径返占位符(精确值不入 LLM 消息流),写侧强制(freeze 拒/verbatim 展开校验)。
|
|
855
857
|
* opt-in:未配(默认)全部行为零变化 */
|
|
856
858
|
resources?: ResourceProtectSpec[];
|
|
859
|
+
/**
|
|
860
|
+
* 装配期工具白名单(main-surface-slim Phase 1):`'high'` 预设(全量减旧四件 get/set/edit/delete_data)/
|
|
861
|
+
* 具体名单(按名过滤,未装配名 warn 留痕)。不传 = 全量零回归;仅首次装配生效,运行时 setData 忽略。
|
|
862
|
+
*/
|
|
863
|
+
tools?: string[] | 'high';
|
|
857
864
|
}
|
|
858
865
|
/** createDataOps 选项(审计回调 / 快照上限 / 乐观锁) */
|
|
859
866
|
export interface DataOpsOptions {
|
|
@@ -863,6 +870,11 @@ export interface DataOpsOptions {
|
|
|
863
870
|
onConflict?: (conflict: ConflictInfo) => Promise<ConflictResolution>;
|
|
864
871
|
/** 冲突监听字段白名单(任意深度字段名):声明后仅这些字段的值变动触发自动冲突检测(位置不敏感);未声明 = 不开自动检测(仅显式 expectedHash 校验);['*'] = 全字段检测(旧 autoLock 行为) */
|
|
865
872
|
conflictWatchFields?: string[];
|
|
873
|
+
/**
|
|
874
|
+
* 装配期工具白名单(main-surface-slim Phase 1):`'high'` 预设(全量减旧四件 get/set/edit/delete_data)/
|
|
875
|
+
* 具体名单(按名过滤,未装配名 warn 留痕)。不传 = 全量零回归。
|
|
876
|
+
*/
|
|
877
|
+
tools?: string[] | 'high';
|
|
866
878
|
}
|
|
867
879
|
|
|
868
880
|
/** 数据操作控制器(运行时替换配置;createDataOps 返回的工具数组上以不可枚举属性 `controller` 挂载) */
|
|
@@ -1193,7 +1205,7 @@ export interface ChatSdkOptions {
|
|
|
1193
1205
|
permissions?: PermissionRule[];
|
|
1194
1206
|
/** 自定义中间件(注入到内置中间件之后;可拦截/观察模型调用、工具、prompt) */
|
|
1195
1207
|
middleware?: any[];
|
|
1196
|
-
|
|
1208
|
+
vfs?: { initialFiles?: Record<string, string>; maxBytes?: number; poolBytes?: { largeResults?: number; drafts?: number; userFiles?: number }; mainTools?: boolean };
|
|
1197
1209
|
/** 每个数据对象最多保留快照数(默认 20) */
|
|
1198
1210
|
maxSnapshots?: number;
|
|
1199
1211
|
/** 乐观锁冲突裁决策略(默认 'ask'):ask=挂起 pendingConflict 等人工 resolveConflict;overwrite=agent 强制覆盖(宿主与 agent 争同一份数据且 agent 优先时用,冲突自动收口不挂起,无人值守场景防永挂);keep_external=自动保留外部修改(agent 收到提示重新 read)。自动裁决仍外发 conflict 事件(conflict.autoResolved 标记) */
|
|
@@ -1219,6 +1231,8 @@ export interface ChatSdkOptions {
|
|
|
1219
1231
|
tokenBudget?: number;
|
|
1220
1232
|
/** 单次 invoke 的 token 预算上限(opt-in,默认关):本次 agent 调用累计 total_tokens 超限 → 中断收口(observable emit + 友好文本,已完成部分保留);与 automation 全局 tokenBudget 正交 */
|
|
1221
1233
|
roundTokenBudget?: number;
|
|
1234
|
+
/** 写驱动过期读失效(stale-read-invalidation,默认 true):单次 invoke 窗口内,本批成功写之后被击中路径的旧 read/query/search 结果替换为失效占位(防模型凭旧快照答状态/用错位索引)。false = 主/子一致关闭零变化 */
|
|
1235
|
+
staleReadInvalidation?: boolean;
|
|
1222
1236
|
/** 时间预算 ms(从 agent 开始计时,超过 → 停止;需 capabilities.automation:true) */
|
|
1223
1237
|
timeBudgetMs?: number;
|
|
1224
1238
|
/** 无人值守错误恢复:致命错误(invoke 抛错)自动 restore_last_checkpoint + 重试次数(默认 1;防单点错误永久中断批量/长任务)。需 capabilities.automation:true */
|