page-agent-sdk 2.13.0 → 2.14.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 +19 -2
- package/README.zh-CN.md +19 -2
- package/dist/page-agent-sdk.iife.js +124 -124
- package/dist/page-agent-sdk.js +2655 -2610
- package/dist/page-agent-sdk.umd.cjs +29 -29
- package/package.json +14 -1
- package/types/index.d.ts +61 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "page-agent-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Browser-native AI agent SDK: chat dialog + ReAct tool-calling + schema-validated JSON ops. Vue bundled, framework-agnostic. Works with DeepSeek/OpenAI/MCP.",
|
|
6
6
|
"main": "./dist/page-agent-sdk.umd.cjs",
|
|
@@ -17,6 +17,18 @@
|
|
|
17
17
|
"import": "./dist/page-agent-sdk.js",
|
|
18
18
|
"require": "./dist/page-agent-sdk.umd.cjs"
|
|
19
19
|
},
|
|
20
|
+
"./storage": {
|
|
21
|
+
"types": "./types/index.d.ts",
|
|
22
|
+
"import": "./dist/page-agent-sdk.js"
|
|
23
|
+
},
|
|
24
|
+
"./query": {
|
|
25
|
+
"types": "./types/index.d.ts",
|
|
26
|
+
"import": "./dist/page-agent-sdk.js"
|
|
27
|
+
},
|
|
28
|
+
"./llm": {
|
|
29
|
+
"types": "./types/index.d.ts",
|
|
30
|
+
"import": "./dist/page-agent-sdk.js"
|
|
31
|
+
},
|
|
20
32
|
"./style.css": "./dist/page-agent-sdk.css"
|
|
21
33
|
},
|
|
22
34
|
"files": [
|
|
@@ -76,6 +88,7 @@
|
|
|
76
88
|
},
|
|
77
89
|
"devDependencies": {
|
|
78
90
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
91
|
+
"@playwright/test": "^1.62.1",
|
|
79
92
|
"@vitejs/plugin-vue": "^6.0.7",
|
|
80
93
|
"tsx": "^4.23.1",
|
|
81
94
|
"typescript": "^7.0.2",
|
package/types/index.d.ts
CHANGED
|
@@ -601,6 +601,16 @@ export interface ConflictInfo {
|
|
|
601
601
|
}
|
|
602
602
|
|
|
603
603
|
export declare function createChatSdk(options: ChatSdkOptions): ChatSdk;
|
|
604
|
+
// ============ system prompt 构建(promptBuilder,refactor-module-extraction 从 createChatSdk 抽离)============
|
|
605
|
+
/** 默认 systemPrompt(用户未传 systemPrompt 时用);含身份 + 能力概述 + 可靠写入规则 */
|
|
606
|
+
export declare const DEFAULT_SYSTEM_PROMPT: string;
|
|
607
|
+
/** 拼接「可操作数据」段(从 data schema .describe() 自动提取注入) */
|
|
608
|
+
export declare function buildDataPrompt(data: DataConfig | undefined): string;
|
|
609
|
+
/**
|
|
610
|
+
* 统一 systemPrompt base 段入口:处理 appendReliableWriteRules 分支 + '---' 分割线。
|
|
611
|
+
* 传 systemPrompt 默认追加 reliableWriteRules(设 appendReliableWriteRules:false 关闭);不传用 DEFAULT_SYSTEM_PROMPT(已内置)。纯函数。
|
|
612
|
+
*/
|
|
613
|
+
export declare function buildSystemPrompt(opts: { systemPrompt?: string; appendReliableWriteRules?: boolean }): string;
|
|
604
614
|
export declare function defineTool(opts: {
|
|
605
615
|
name: string;
|
|
606
616
|
description: string;
|
|
@@ -609,6 +619,57 @@ export declare function defineTool(opts: {
|
|
|
609
619
|
}): any;
|
|
610
620
|
export declare function createDataOps(config: DataConfig, opts?: DataOpsOptions): any[];
|
|
611
621
|
export declare function filterByToolMode(tools: any[], mode?: 'simple' | 'advanced' | 'minimal'): any[];
|
|
622
|
+
// ============ 通用 JSON 操作纯函数(jsonUtils,refactor-module-extraction 从 dataOps 抽离;零依赖,经 ./query subpath 按需引入)============
|
|
623
|
+
export type EditOp = 'set' | 'remove' | 'merge' | 'append';
|
|
624
|
+
export declare const UNSAFE_KEYS: Set<string>;
|
|
625
|
+
export declare function isUnsafePath(path: string): boolean;
|
|
626
|
+
export declare function safeMerge(target: Record<string, any>, src: unknown): void;
|
|
627
|
+
export declare function getByPath(obj: unknown, path: string): unknown;
|
|
628
|
+
export declare function setByPath(obj: unknown, path: string, value: unknown): void;
|
|
629
|
+
export declare function deleteByPath(obj: unknown, path: string): boolean;
|
|
630
|
+
export declare function deepClone<T>(v: T): T;
|
|
631
|
+
export declare function maybeParseValue(v: unknown): { parsed?: unknown; parseError?: unknown };
|
|
632
|
+
export declare function projectFields(obj: unknown, fields: string[]): unknown;
|
|
633
|
+
export declare function limitDepth(obj: unknown, depth: number): unknown;
|
|
634
|
+
export declare function safeStringify(value: unknown, maxLen?: number): string;
|
|
635
|
+
export declare function hashValue(value: unknown): string;
|
|
636
|
+
export declare function applyPatchToClone(clone: any, op: EditOp, jsonPath: string, value: unknown): string | null;
|
|
637
|
+
export declare function applyPatchToLive(bind: any, op: EditOp, jsonPath: string, value: unknown): void;
|
|
638
|
+
export declare function restoreLive(bind: any, snapshotVal: unknown): void;
|
|
639
|
+
export declare function restoreInPlace(live: Record<string, unknown> | unknown[], snapshotVal: unknown): void;
|
|
640
|
+
// ============ schema 白名单投影纯函数(schemaUtils,refactor-module-extraction 从 dataOps 抽离)============
|
|
641
|
+
export declare function getSchemaTopKeys(schema: any): string[] | null;
|
|
642
|
+
export declare function isPathAllowed(jsonPath: string, schema: any | null, allowKeys: string[] | null): boolean;
|
|
643
|
+
export declare function unwrapSchema(schema: any): any;
|
|
644
|
+
export declare function getSchemaAtPath(schema: any, jsonPath: string): any | null;
|
|
645
|
+
export declare function projectBySchemaDeep(obj: unknown, schema: any | null): unknown;
|
|
646
|
+
export declare function projectBySchema(obj: unknown, allowKeys: string[] | null): unknown;
|
|
647
|
+
// ============ 上下文索引纯函数(contextIndex,refactor-module-extraction 期二 从 useContextManager 抽离)============
|
|
648
|
+
export declare const STOP_WORDS: Set<string>;
|
|
649
|
+
export declare function tokenize(text: string): string[];
|
|
650
|
+
export declare function estimateMessageTokens(m: any): number;
|
|
651
|
+
export declare function estimateRoundTokens(r: any): number;
|
|
652
|
+
export declare function indexSummarize(older: any[], preserve?: Set<string>): string;
|
|
653
|
+
export declare function recallRounds(older: any[], query: string, topK: number): any[];
|
|
654
|
+
// ============ LLM 解析(llmResolver,refactor-module-extraction 期二 从 createChatSdk 抽离)============
|
|
655
|
+
export declare function isChatModel(v: unknown): boolean;
|
|
656
|
+
export declare function resolveLlm(options: any): { modelCaps: any; summaryLlmInvoke: ((prompt: string) => Promise<string>) | undefined };
|
|
657
|
+
// ============ 乐观锁冲突管理器(conflictManager,refactor-module-extraction 期二 从 createChatSdk 抽离)============
|
|
658
|
+
export interface ConflictManager {
|
|
659
|
+
pendingConflict: import('vue').Ref<any | null>;
|
|
660
|
+
set(info: any): Promise<any>;
|
|
661
|
+
resolve(action: any): void;
|
|
662
|
+
}
|
|
663
|
+
export declare function createConflictManager(getEmit?: () => (((e: any) => void) | undefined)): ConflictManager;
|
|
664
|
+
// ============ 配置解析 + 事件系统(optionsResolver/events,refactor-module-extraction 期三)============
|
|
665
|
+
export declare function resolveStorage(storage: any): any | null;
|
|
666
|
+
export declare function resolveDialogConfig(opts: any): any;
|
|
667
|
+
export interface SdkEvents {
|
|
668
|
+
listeners: Set<(e: any) => void>;
|
|
669
|
+
emit: (e: any) => void;
|
|
670
|
+
hook(handler: (e: any) => void): () => void;
|
|
671
|
+
}
|
|
672
|
+
export declare function createSdkEvents(onEvent?: (e: any) => void): SdkEvents;
|
|
612
673
|
export declare function selectBuiltinTools(caps: { dataOps?: boolean; fetch?: boolean } | undefined, dataOps: any[], fetchDocs: any[]): any[];
|
|
613
674
|
export declare function createUsageHintsMiddleware(caps: { planning?: boolean; dataOps?: boolean; subagent?: boolean } | undefined, hasDataOps: boolean, toolMode?: 'simple' | 'advanced' | 'minimal'): any;
|
|
614
675
|
export declare const fetchDocTools: any[];
|