page-agent-sdk 1.3.13 → 1.4.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 +1 -0
- package/README.zh-CN.md +1 -0
- package/dist/page-agent-sdk.css +1 -1
- package/dist/page-agent-sdk.iife.js +120 -118
- package/dist/page-agent-sdk.js +1030 -927
- package/dist/page-agent-sdk.umd.cjs +45 -43
- package/package.json +1 -1
- package/types/index.d.ts +35 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "page-agent-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "框架无关的页面内 Agent JS SDK —— 以对话框形态挂载到任意网页,通过自定义 tool 读写宿主 window 属性(GET 抓文档),具备 planning/skills/虚拟工作区/快照回退/context 管理能力。Vue 打包进库,使用者无需安装 Vue。",
|
|
6
6
|
"main": "./dist/page-agent-sdk.umd.cjs",
|
package/types/index.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export type SdkEvent =
|
|
|
57
57
|
| { type: 'done'; content: string }
|
|
58
58
|
| { type: 'window_prop_change'; path: string; operation: 'set' | 'edit' | 'delete' | 'restore'; value?: unknown }
|
|
59
59
|
| { type: 'message_update'; count: number }
|
|
60
|
+
| { type: 'conflict'; conflict: PendingConflict }
|
|
60
61
|
| { type: 'error'; message: string };
|
|
61
62
|
|
|
62
63
|
export type SdkEventHandler = (event: SdkEvent) => void;
|
|
@@ -402,6 +403,40 @@ export interface ChatSdk {
|
|
|
402
403
|
removeWindowProp(path: string): boolean;
|
|
403
404
|
/** 列出当前所有已注册 window 属性(反映动态增删后的最新状态) */
|
|
404
405
|
listWindowProps(): WindowPropSpec[];
|
|
406
|
+
/** 乐观锁冲突挂起状态(响应式;无冲突为 null,有冲突时 UI 据此渲染冲突对话框)。headless 集成方可 watch 自建 UI */
|
|
407
|
+
pendingConflict: PendingConflict | null;
|
|
408
|
+
/** 冲突解决:用户点「保留外部」(keep_external)/「强制覆盖」(overwrite)/「回退」(restore) → 收口挂起的 conflict,被挂起的工具调用继续 */
|
|
409
|
+
resolveConflict(action: ConflictResolution['action']): void;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/** 乐观锁冲突挂起(windowOps 写入时 expectedHash 不匹配,挂起等用户决定) */
|
|
413
|
+
export interface PendingConflict {
|
|
414
|
+
id: number;
|
|
415
|
+
path: string;
|
|
416
|
+
op: 'set' | 'edit' | 'delete';
|
|
417
|
+
agentValue?: unknown;
|
|
418
|
+
currentValue: unknown;
|
|
419
|
+
currentHash: string;
|
|
420
|
+
expectedHash: string;
|
|
421
|
+
snapshotId: number;
|
|
422
|
+
resolve: (r: ConflictResolution) => void;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/** 冲突解决决定:保留外部修改 / 强制覆盖 / 回退到写前快照 */
|
|
426
|
+
export type ConflictResolution =
|
|
427
|
+
| { action: 'keep_external' }
|
|
428
|
+
| { action: 'overwrite' }
|
|
429
|
+
| { action: 'restore' };
|
|
430
|
+
|
|
431
|
+
/** 乐观锁冲突信息(windowOps onConflict 回调参数) */
|
|
432
|
+
export interface ConflictInfo {
|
|
433
|
+
path: string;
|
|
434
|
+
op: 'set' | 'edit' | 'delete';
|
|
435
|
+
agentValue?: unknown;
|
|
436
|
+
currentValue: unknown;
|
|
437
|
+
currentHash: string;
|
|
438
|
+
expectedHash: string;
|
|
439
|
+
snapshotId: number;
|
|
405
440
|
}
|
|
406
441
|
|
|
407
442
|
export declare function createChatSdk(options: ChatSdkOptions): ChatSdk;
|