page-agent-sdk 3.37.0 → 3.38.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 -1
- package/README.zh-CN.md +1 -1
- package/dist/page-agent-sdk.headless.js +1546 -1075
- package/dist/page-agent-sdk.iife.js +138 -138
- package/dist/page-agent-sdk.js +3017 -2546
- package/dist/page-agent-sdk.legacy.js +14728 -14227
- package/dist/page-agent-sdk.umd.cjs +90 -90
- package/package.json +1 -1
- package/types/headless.d.ts +34 -1
- package/types/index.d.ts +45 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "page-agent-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.38.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
|
@@ -1083,7 +1083,24 @@ export declare function defineTool(opts: {
|
|
|
1083
1083
|
}): any;
|
|
1084
1084
|
export declare function createDataOps(config: DataConfig, opts?: DataOpsOptions): any[];
|
|
1085
1085
|
/** 整体 set 写入纯函数:schema 校验 + 快照 + merge/替换 + audit。set_data / write(set) / draft_commit 共用。返回 {ok,hash,data} 或 {ok:false,error} */
|
|
1086
|
-
export declare function commitSetToBind(args: { bindRef: unknown; value: unknown; schema: any; allowKeys: string[] | null; snapshots: any[]; maxSnapshots: number; audit: (e: any) => void; dryRun?: boolean; op?: 'set' | 'draft_commit' }): { ok: true; hash: string; data: unknown } | { ok: false; error: string };
|
|
1086
|
+
export declare function commitSetToBind(args: { bindRef: unknown; value: unknown; schema: any; allowKeys: string[] | null; snapshots: any[]; maxSnapshots: number; audit: (e: any) => void; dryRun?: boolean; op?: 'set' | 'draft_commit'; snapshotLabel?: string }): { ok: true; hash: string; data: unknown; notices: string[] } | { ok: false; error: string };
|
|
1087
|
+
export interface LocalWriteBack {
|
|
1088
|
+
op: 'set' | 'remove' | 'move' | 'mergeKeys' | 'appendElems';
|
|
1089
|
+
jp: string;
|
|
1090
|
+
value?: unknown;
|
|
1091
|
+
toPath?: string;
|
|
1092
|
+
entries?: [string, unknown][];
|
|
1093
|
+
elems?: unknown[];
|
|
1094
|
+
}
|
|
1095
|
+
export interface LocalValidationPlan {
|
|
1096
|
+
ok: boolean;
|
|
1097
|
+
error?: string;
|
|
1098
|
+
writeBacks: LocalWriteBack[];
|
|
1099
|
+
notices: string[];
|
|
1100
|
+
}
|
|
1101
|
+
export declare function validateRootValueLocally(args: { schema: any; allowKeys: string[] | null; value: unknown; bindRef: unknown }): { ok: true; assembly: unknown; wholeParsed: Record<string, unknown> | null; notices: string[] } | { ok: false; error: string; notices: string[] };
|
|
1102
|
+
export declare function validateWriteLocally(args: { schema: any; bindRef: unknown; clone: unknown; patches: { op?: string; jsonPath?: string; value?: unknown }[]; schemaErrorMode?: 'zod' | 'schema_invalid'; appendCaptures: { jp: string; elems: unknown[] }[]; moveCaptures: { jp: string; toPath: string; elem: unknown }[]; valueAt?: (jp: string) => unknown }): LocalValidationPlan;
|
|
1103
|
+
export declare function applyPatchesToBind(args: { bindRef: unknown; patches: { op?: string; jsonPath?: string; value?: unknown }[]; schema: any; allowKeys: string[] | null; snapshots: any[]; maxSnapshots: number; markDataDirty?: () => void; schemaErrorMode?: 'zod' | 'schema_invalid'; snapshotLabel?: string; dryRun?: boolean; internalAfterWrite?: (bind: any, before: any) => void; protectedCtx?: unknown }): { ok: true; applied: { op: string; jp: string; value: unknown }[]; clone: unknown; notices: string[] } | { ok: false; error: string };
|
|
1087
1104
|
/** 结构化追踪 span(revive-observability-tracing Phase 3) */
|
|
1088
1105
|
export type SpanType = 'round' | 'model' | 'tool' | 'compression';
|
|
1089
1106
|
export type SpanStatus = 'ok' | 'error' | 'timeout';
|
|
@@ -1142,6 +1159,22 @@ export declare function unwrapSchema(schema: any): any;
|
|
|
1142
1159
|
export declare function getSchemaAtPath(schema: any, jsonPath: string): any | null;
|
|
1143
1160
|
export declare function projectBySchemaDeep(obj: unknown, schema: any | null): unknown;
|
|
1144
1161
|
export declare function projectBySchema(obj: unknown, allowKeys: string[] | null): unknown;
|
|
1162
|
+
// ============ path-scoped-validation(write 校验局部化:union-tolerant 路径解析 + 目标路径局部校验)============
|
|
1163
|
+
export type PathSchemaResolution =
|
|
1164
|
+
| { kind: 'schemas'; schemas: any[] }
|
|
1165
|
+
| { kind: 'open' }
|
|
1166
|
+
| { kind: 'missing' };
|
|
1167
|
+
export interface ValidateAtPathResult {
|
|
1168
|
+
ok: boolean;
|
|
1169
|
+
data?: unknown;
|
|
1170
|
+
issues?: unknown[];
|
|
1171
|
+
resolution: 'schemas' | 'open' | 'missing';
|
|
1172
|
+
}
|
|
1173
|
+
export declare function resolveSchemaPath(schema: any, jsonPath: string): PathSchemaResolution;
|
|
1174
|
+
export declare function validateAtPath(schema: any, jsonPath: string, value: unknown): ValidateAtPathResult;
|
|
1175
|
+
export declare function schemaHasRefinement(schemaRaw: any): boolean;
|
|
1176
|
+
export declare function arrayMinLength(schemaRaw: any): number | null;
|
|
1177
|
+
export declare function elementSchemaCandidates(schemas: any[]): any[];
|
|
1145
1178
|
// ============ schema 约束结构化提取(expose-schema-constraints;供 systemPrompt「可操作数据」段 / read 概览 / schema_data 工具)============
|
|
1146
1179
|
export interface SchemaNodeDesc {
|
|
1147
1180
|
type: string;
|
package/types/index.d.ts
CHANGED
|
@@ -1508,7 +1508,28 @@ export declare function defineTool(opts: {
|
|
|
1508
1508
|
}): any;
|
|
1509
1509
|
export declare function createDataOps(config: DataConfig, opts?: DataOpsOptions): any[];
|
|
1510
1510
|
/** 整体 set 写入纯函数:schema 校验 + 快照 + merge/替换 + audit。set_data / write(set) / draft_commit 共用。返回 {ok,hash,data} 或 {ok:false,error} */
|
|
1511
|
-
export declare function commitSetToBind(args: { bindRef: unknown; value: unknown; schema: any; allowKeys: string[] | null; snapshots: any[]; maxSnapshots: number; audit: (e: any) => void; dryRun?: boolean; op?: 'set' | 'draft_commit' }): { ok: true; hash: string; data: unknown } | { ok: false; error: string };
|
|
1511
|
+
export declare function commitSetToBind(args: { bindRef: unknown; value: unknown; schema: any; allowKeys: string[] | null; snapshots: any[]; maxSnapshots: number; audit: (e: any) => void; dryRun?: boolean; op?: 'set' | 'draft_commit'; snapshotLabel?: string }): { ok: true; hash: string; data: unknown; notices: string[] } | { ok: false; error: string };
|
|
1512
|
+
/** path-scoped-validation:增量 patch 逐目标局部校验(全部 apply 后按最终态;兄弟脏数据不株连)。返回写回计划 */
|
|
1513
|
+
export interface LocalWriteBack {
|
|
1514
|
+
op: 'set' | 'remove' | 'move' | 'mergeKeys' | 'appendElems';
|
|
1515
|
+
jp: string;
|
|
1516
|
+
value?: unknown;
|
|
1517
|
+
toPath?: string;
|
|
1518
|
+
entries?: [string, unknown][];
|
|
1519
|
+
elems?: unknown[];
|
|
1520
|
+
}
|
|
1521
|
+
export interface LocalValidationPlan {
|
|
1522
|
+
ok: boolean;
|
|
1523
|
+
error?: string;
|
|
1524
|
+
writeBacks: LocalWriteBack[];
|
|
1525
|
+
notices: string[];
|
|
1526
|
+
}
|
|
1527
|
+
/** 整体 set 局部校验:只校验 value 出现的顶层 key(缺必填不再拒 —— 契约收窄);per-key strip 检测 + 解析值写回 */
|
|
1528
|
+
export declare function validateRootValueLocally(args: { schema: any; allowKeys: string[] | null; value: unknown; bindRef: unknown }): { ok: true; assembly: unknown; wholeParsed: Record<string, unknown> | null; notices: string[] } | { ok: false; error: string; notices: string[] };
|
|
1529
|
+
/** 增量 patch 逐目标局部校验纯函数(appendCaptures/moveCaptures 由 apply 循环捕获;valueAt 为位移兜底) */
|
|
1530
|
+
export declare function validateWriteLocally(args: { schema: any; bindRef: unknown; clone: unknown; patches: { op?: string; jsonPath?: string; value?: unknown }[]; schemaErrorMode?: 'zod' | 'schema_invalid'; appendCaptures: { jp: string; elems: unknown[] }[]; moveCaptures: { jp: string; toPath: string; elem: unknown }[]; valueAt?: (jp: string) => unknown }): LocalValidationPlan;
|
|
1531
|
+
/** 增量 patch 写入纯函数(clone + 局部校验 + 快照 + 外科手术式写回);edit_data / write(edit) / eval 共用 */
|
|
1532
|
+
export declare function applyPatchesToBind(args: { bindRef: unknown; patches: { op?: string; jsonPath?: string; value?: unknown }[]; schema: any; allowKeys: string[] | null; snapshots: any[]; maxSnapshots: number; markDataDirty?: () => void; schemaErrorMode?: 'zod' | 'schema_invalid'; snapshotLabel?: string; dryRun?: boolean; internalAfterWrite?: (bind: any, before: any) => void; protectedCtx?: unknown }): { ok: true; applied: { op: string; jp: string; value: unknown }[]; clone: unknown; notices: string[] } | { ok: false; error: string };
|
|
1512
1533
|
/** 结构化追踪 span(revive-observability-tracing Phase 3) */
|
|
1513
1534
|
export type SpanType = 'round' | 'model' | 'tool' | 'compression';
|
|
1514
1535
|
export type SpanStatus = 'ok' | 'error' | 'timeout';
|
|
@@ -1569,6 +1590,29 @@ export declare function unwrapSchema(schema: any): any;
|
|
|
1569
1590
|
export declare function getSchemaAtPath(schema: any, jsonPath: string): any | null;
|
|
1570
1591
|
export declare function projectBySchemaDeep(obj: unknown, schema: any | null): unknown;
|
|
1571
1592
|
export declare function projectBySchema(obj: unknown, allowKeys: string[] | null): unknown;
|
|
1593
|
+
// ============ path-scoped-validation(write 校验局部化:union-tolerant 路径解析 + 目标路径局部校验)============
|
|
1594
|
+
/** 路径解析结果:schemas=候选集(any-option-accepts)/ open=开放节点(record·any·unknown·passthrough)/ missing=全分支未声明 */
|
|
1595
|
+
export type PathSchemaResolution =
|
|
1596
|
+
| { kind: 'schemas'; schemas: any[] }
|
|
1597
|
+
| { kind: 'open' }
|
|
1598
|
+
| { kind: 'missing' };
|
|
1599
|
+
/** validateAtPath 结果:ok=true 时 data 为 strip 后可写回的解析值(open 节点 = 原值) */
|
|
1600
|
+
export interface ValidateAtPathResult {
|
|
1601
|
+
ok: boolean;
|
|
1602
|
+
data?: unknown;
|
|
1603
|
+
issues?: unknown[];
|
|
1604
|
+
resolution: 'schemas' | 'open' | 'missing';
|
|
1605
|
+
}
|
|
1606
|
+
/** union-tolerant 路径解析:union 就地展开为各 option(同段在每个 option 内重试);写校验单一解析入口 */
|
|
1607
|
+
export declare function resolveSchemaPath(schema: any, jsonPath: string): PathSchemaResolution;
|
|
1608
|
+
/** 目标路径局部校验:候选分支任一接受即过(open 放行 / missing 由调用方按 SCHEMA_STRIP 语义拒) */
|
|
1609
|
+
export declare function validateAtPath(schema: any, jsonPath: string, value: unknown): ValidateAtPathResult;
|
|
1610
|
+
/** schema 是否挂 refine/superRefine(局部校验不执行这类跨节点约束,留痕判据) */
|
|
1611
|
+
export declare function schemaHasRefinement(schemaRaw: any): boolean;
|
|
1612
|
+
/** 数组 schema 最小长度约束(无则 null;remove 的父容器结构性校验用) */
|
|
1613
|
+
export declare function arrayMinLength(schemaRaw: any): number | null;
|
|
1614
|
+
/** 候选集中数组元素 schema 候选(append/move 元素校验用) */
|
|
1615
|
+
export declare function elementSchemaCandidates(schemas: any[]): any[];
|
|
1572
1616
|
// ============ schema 约束结构化提取(expose-schema-constraints;供 systemPrompt「可操作数据」段 / read 概览 / schema_data 工具)============
|
|
1573
1617
|
export interface SchemaNodeDesc {
|
|
1574
1618
|
type: string;
|