page-agent-sdk 2.39.0 → 2.41.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 +3 -3
- package/README.zh-CN.md +3 -3
- package/dist/page-agent-sdk.headless.js +2032 -1937
- package/dist/page-agent-sdk.iife.js +140 -139
- package/dist/page-agent-sdk.js +4195 -4075
- package/dist/page-agent-sdk.umd.cjs +94 -93
- package/package.json +1 -1
- package/types/headless.d.ts +9 -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": "2.
|
|
3
|
+
"version": "2.41.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
|
@@ -36,6 +36,8 @@ export declare function extractTextDelta(chunk: import('@langchain/core/messages
|
|
|
36
36
|
export declare function extractReasoningDelta(chunk: import('@langchain/core/messages').AIMessageChunk): string;
|
|
37
37
|
/** 从响应消息提取 token usage(OpenAI additional_kwargs.usage + Anthropic response_metadata.usage) */
|
|
38
38
|
export declare function extractUsage(message: import('@langchain/core/messages').BaseMessage): any;
|
|
39
|
+
/** 原始 usage → 归一 TokenUsage(camelCase 兼容;fix-main-sub-isolation:sdk-events 与子栈 sub-usage 共用);全 0/无效返 null */
|
|
40
|
+
export declare function normalizeUsage(message: import('@langchain/core/messages').BaseMessage): TokenUsage | null;
|
|
39
41
|
|
|
40
42
|
export interface ToolStep {
|
|
41
43
|
name: string;
|
|
@@ -770,7 +772,7 @@ export interface ChatSdkOptions {
|
|
|
770
772
|
maxOutputTokens?: number;
|
|
771
773
|
/** 子 agent 委派(默认开启;{ enabled: false } 关闭) */
|
|
772
774
|
capabilities?: { dataOps?: boolean; fetch?: boolean; planning?: boolean; missionAnchor?: boolean; skills?: boolean; vfs?: boolean; summarization?: boolean; memory?: boolean; subagent?: boolean; verify?: boolean; domInspect?: boolean; inspectEnv?: boolean; draftWrite?: boolean; tracing?: boolean; todoDeps?: boolean; automation?: boolean; workingMemory?: boolean; focus?: boolean; skillHostScript?: boolean; contextInspector?: boolean; agentCompression?: boolean };
|
|
773
|
-
subagent?: { enabled?: boolean; allowedTools?: string[]; systemPrompt?: string; temperature?: number; maxTokens?: number; skills?: SkillSpec[]; llm?: LLMConfig | ChatModelLike; maxDepth?: number; maxParallel?: number };
|
|
775
|
+
subagent?: { enabled?: boolean; allowedTools?: string[]; systemPrompt?: string; temperature?: number; maxTokens?: number; skills?: SkillSpec[]; llm?: LLMConfig | ChatModelLike; maxDepth?: number; maxParallel?: number; timeoutMs?: number };
|
|
774
776
|
/** 预声明子 agent 列表:每个用同主配置方式声明,自动生成 use_<id> 委派工具(与 spawn_agent 共存) */
|
|
775
777
|
subagents?: SubagentConfig[];
|
|
776
778
|
/** 自检:agent 返回前跑 check,不通过则 feedback 回灌自纠(默认关闭;需 capabilities.verify:true)。check 省略时默认 createWriteBackCheck 写后读回验证 */
|
|
@@ -867,6 +869,12 @@ export interface ChatSdk {
|
|
|
867
869
|
show(): void;
|
|
868
870
|
send(message: string, options?: { mission?: Partial<Mission>; interceptors?: { input?: (input: unknown) => unknown; output?: (json: unknown) => unknown }; maxAutoRetries?: number; /** 中断信号(fix-hang-and-feedback P1-4) */ signal?: AbortSignal }): Promise<string>;
|
|
869
871
|
switchSession(sessionId?: string): Promise<string>;
|
|
872
|
+
/**
|
|
873
|
+
* 新建/清空会话(同步;「清空对话」编程式入口):中止在途流 + 收口挂起冲突(keep_external)
|
|
874
|
+
* + 重置全部内存态(messages/vfs/todos/memory/mission/workingMemory/focus/checkpoint/debugLogs)+ 换新 sessionId + emit session_restored。
|
|
875
|
+
* storage 开启时同步新建持久会话;未开启时仅重置内存态(P1-8 修复后不再早退泄漏)。
|
|
876
|
+
*/
|
|
877
|
+
resetSession(): void;
|
|
870
878
|
/** 列出当前 agent 的所有历史会话(供「历史列表」UI;storage 未开启 → []) */
|
|
871
879
|
listSessions(): Promise<SessionMeta[]>;
|
|
872
880
|
/** 历史会话列表(响应式;switchSession/deleteSession/onClear/init 后自动 refresh;直接消费无需手动 listSessions/refresh/hook) */
|
package/types/index.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export declare function extractTextDelta(chunk: import('@langchain/core/messages
|
|
|
29
29
|
export declare function extractReasoningDelta(chunk: import('@langchain/core/messages').AIMessageChunk): string;
|
|
30
30
|
/** 从响应消息提取 token usage(OpenAI additional_kwargs.usage + Anthropic response_metadata.usage) */
|
|
31
31
|
export declare function extractUsage(message: import('@langchain/core/messages').BaseMessage): any;
|
|
32
|
+
/** 原始 usage → 归一 TokenUsage(camelCase 兼容;fix-main-sub-isolation:sdk-events 与子栈 sub-usage 共用);全 0/无效返 null */
|
|
33
|
+
export declare function normalizeUsage(message: import('@langchain/core/messages').BaseMessage): TokenUsage | null;
|
|
32
34
|
|
|
33
35
|
export interface ToolStep {
|
|
34
36
|
name: string;
|
|
@@ -402,6 +404,12 @@ export declare const MessageContent: DefineComponent<any>;
|
|
|
402
404
|
export declare const CodePreview: DefineComponent<any>;
|
|
403
405
|
export declare const SkillPanel: DefineComponent<any>;
|
|
404
406
|
export declare function useChat(opts?: any): any;
|
|
407
|
+
/** 单代码块超过此字符数跳过 hljs 高亮(转义直出),防巨代码块单帧卡顿(P1-26 尺寸闸) */
|
|
408
|
+
export declare const HLJS_BLOCK_MAX_CHARS: number;
|
|
409
|
+
/** markdown → 未净化 HTML(marked + 代码块渲染,含 hljs 尺寸闸;**不含** DOMPurify;⚠️ 勿直接 v-html)。P1-26 抽离可单测 */
|
|
410
|
+
export declare function markedToHtml(text: string): string;
|
|
411
|
+
/** markdown → 净化 HTML(marked + 代码块渲染 + DOMPurify;含 hljs 尺寸闸;sanitize 恒走)。仅主包(headless 子路径不含) */
|
|
412
|
+
export declare function renderMarkdownHtml(text: string): string;
|
|
405
413
|
|
|
406
414
|
// ===== 框架无关 SDK(页面内 Agent)=====
|
|
407
415
|
export interface LLMConfig {
|
|
@@ -780,7 +788,7 @@ export interface ChatSdkOptions {
|
|
|
780
788
|
maxOutputTokens?: number;
|
|
781
789
|
/** 子 agent 委派(默认开启;{ enabled: false } 关闭) */
|
|
782
790
|
capabilities?: { dataOps?: boolean; fetch?: boolean; planning?: boolean; missionAnchor?: boolean; skills?: boolean; vfs?: boolean; summarization?: boolean; memory?: boolean; subagent?: boolean; verify?: boolean; domInspect?: boolean; inspectEnv?: boolean; draftWrite?: boolean; tracing?: boolean; todoDeps?: boolean; automation?: boolean; workingMemory?: boolean; focus?: boolean; skillHostScript?: boolean; contextInspector?: boolean; agentCompression?: boolean };
|
|
783
|
-
subagent?: { enabled?: boolean; allowedTools?: string[]; systemPrompt?: string; temperature?: number; maxTokens?: number; skills?: SkillSpec[]; llm?: LLMConfig | ChatModelLike; maxDepth?: number; maxParallel?: number };
|
|
791
|
+
subagent?: { enabled?: boolean; allowedTools?: string[]; systemPrompt?: string; temperature?: number; maxTokens?: number; skills?: SkillSpec[]; llm?: LLMConfig | ChatModelLike; maxDepth?: number; maxParallel?: number; timeoutMs?: number };
|
|
784
792
|
/** 预声明子 agent 列表:每个用同主配置方式声明,自动生成 use_<id> 委派工具(与 spawn_agent 共存) */
|
|
785
793
|
subagents?: SubagentConfig[];
|
|
786
794
|
/** 自检:agent 返回前跑 check,不通过则 feedback 回灌自纠(默认关闭;需 capabilities.verify:true)。check 省略时默认 createWriteBackCheck 写后读回验证 */
|
|
@@ -877,6 +885,12 @@ export interface ChatSdk {
|
|
|
877
885
|
show(): void;
|
|
878
886
|
send(message: string, options?: { mission?: Partial<Mission>; interceptors?: { input?: (input: unknown) => unknown; output?: (json: unknown) => unknown }; maxAutoRetries?: number; /** 中断信号(fix-hang-and-feedback P1-4) */ signal?: AbortSignal }): Promise<string>;
|
|
879
887
|
switchSession(sessionId?: string): Promise<string>;
|
|
888
|
+
/**
|
|
889
|
+
* 新建/清空会话(同步;「清空对话」编程式入口,与 UI ChatHeader 清空同语义):
|
|
890
|
+
* 中止在途流 + 收口挂起冲突(keep_external)+ 重置全部内存态(messages/vfs/todos/memory/mission/workingMemory/focus/checkpoint/debugLogs)
|
|
891
|
+
* + 换新 sessionId + emit session_restored。storage 开启时同步新建持久会话;未开启时仅重置内存态(P1-8 修复后不再早退泄漏)。
|
|
892
|
+
*/
|
|
893
|
+
resetSession(): void;
|
|
880
894
|
/** 列出当前 agent 的所有历史会话(供「历史列表」UI;storage 未开启 → []) */
|
|
881
895
|
listSessions(): Promise<SessionMeta[]>;
|
|
882
896
|
/** 历史会话列表(响应式;switchSession/deleteSession/onClear/init 后自动 refresh;直接消费无需手动 listSessions/refresh/hook) */
|