page-agent-sdk 3.7.0 → 3.8.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.7.0",
3
+ "version": "3.8.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/index.d.ts CHANGED
@@ -1097,7 +1097,7 @@ export interface TraceMetrics {
1097
1097
  /** 从 TraceSpan[] 聚合 metrics(纯函数:轮次/延迟/工具成功率/重试/压缩/token) */
1098
1098
  export declare function getTraceMetrics(spans: TraceSpan[]): TraceMetrics;
1099
1099
  // ============ 通用 JSON 操作纯函数(jsonUtils,refactor-module-extraction 从 dataOps 抽离;零依赖,经 ./query subpath 按需引入)============
1100
- export type EditOp = 'set' | 'remove' | 'merge' | 'append';
1100
+ export type EditOp = 'set' | 'remove' | 'merge' | 'append' | 'move';
1101
1101
  export declare const UNSAFE_KEYS: Set<string>;
1102
1102
  export declare function isUnsafePath(path: string): boolean;
1103
1103
  export declare function safeMerge(target: Record<string, any>, src: unknown): void;
@@ -1112,6 +1112,8 @@ export declare function safeStringify(value: unknown, maxLen?: number): string;
1112
1112
  export declare function hashValue(value: unknown): string;
1113
1113
  export declare function applyPatchToClone(clone: any, op: EditOp, jsonPath: string, value: unknown): string | null;
1114
1114
  export declare function applyPatchToLive(bind: any, op: EditOp, jsonPath: string, value: unknown): void;
1115
+ /** move op:把 jsonPath 指向的数组元素移动到 toPath 位置(数组本身=追加/数组内下标=插入;同数组即重排,目标下标按移除源后解释)。返回错误信息或 null */
1116
+ export declare function moveByPath(root: any, jsonPath: string, toPath: unknown): string | null;
1115
1117
  export declare function restoreLive(bind: any, snapshotVal: unknown): void;
1116
1118
  export declare function restoreInPlace(live: Record<string, unknown> | unknown[], snapshotVal: unknown): void;
1117
1119
  /** 深度差异对比(对象/数组递归,叶子差异),返回 {path, from, to}[];供 diff_data / verify 自纠 / 审计复用 */