page-agent-sdk 2.38.0 → 2.38.2

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": "2.38.0",
3
+ "version": "2.38.2",
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",
@@ -55,6 +55,7 @@
55
55
  "test:e2e": "node tests/e2e-integration.mjs",
56
56
  "test:exports": "node tests/exports-consistency.mjs",
57
57
  "test:types": "tsc --noEmit -p tsconfig.test.json",
58
+ "test:types-alignment": "tsc --noEmit -p tsconfig.types-alignment.json",
58
59
  "test:size": "node tests/size-check.mjs",
59
60
  "test:browser": "playwright test",
60
61
  "test:browser:ui": "playwright test --ui",
@@ -767,7 +767,7 @@ export interface ChatSdkOptions {
767
767
  /** 模型最大输出(token);顶层声明对 llm 实例场景也生效,缺省按 model 名查表 */
768
768
  maxOutputTokens?: number;
769
769
  /** 子 agent 委派(默认开启;{ enabled: false } 关闭) */
770
- 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 };
770
+ 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 };
771
771
  subagent?: { enabled?: boolean; allowedTools?: string[]; systemPrompt?: string; temperature?: number; maxTokens?: number; skills?: SkillSpec[]; llm?: LLMConfig | ChatModelLike; maxDepth?: number; maxParallel?: number };
772
772
  /** 预声明子 agent 列表:每个用同主配置方式声明,自动生成 use_<id> 委派工具(与 spawn_agent 共存) */
773
773
  subagents?: SubagentConfig[];
@@ -775,6 +775,8 @@ export interface ChatSdkOptions {
775
775
  verify?: { enabled?: boolean; check?: VerifyCheck; maxAttempts?: number; adversarial?: boolean };
776
776
  /** 人工确认:工具调用前弹确认框,用户「允许/拒绝」后才执行(默认关闭,不传 = 不装) */
777
777
  approval?: ApprovalOptions;
778
+ /** 主动征询(默认开启):装载 request_human_confirmation 工具,LLM 在不确定/多方案/高风险时主动征询;false 关闭(types-alignment 补漏) */
779
+ humanConfirm?: boolean;
778
780
  /** 会话级 checkpoint 回滚(回到上次正常时)。默认关闭;传 true 或 { maxCheckpoints?, auto? } 开启 */
779
781
  checkpoint?: boolean | { maxCheckpoints?: number; auto?: boolean };
780
782
  /** MCP server 列表(连远程 server 动态注入其 tools;浏览器仅 http/sse/websocket) */
@@ -795,6 +797,10 @@ export interface ChatSdkOptions {
795
797
  summaryMaxTokens?: number;
796
798
  /** 摘要 LLM 超时毫秒(默认 15000;超时回退索引摘要) */
797
799
  summaryTimeoutMs?: number;
800
+ /** 压缩决策(agentCompression)LLM 超时毫秒(默认 6000;不复用 summaryTimeoutMs 15s,两段叠加阻塞首响应) */
801
+ decisionTimeoutMs?: number;
802
+ /** 压缩决策 LLM 输出上限(默认 2048;避免继承 summaryLlm 1024 截断 JSON → safeParse 失败无谓降级) */
803
+ decisionMaxTokens?: number;
798
804
  /**
799
805
  * SDK 事件回调:订阅常用时机(数据槽变化 / 消息更新 / 工具调用 / 流式文本 / 轮次 / 错误)。
800
806
  * UI 与 headless 模式均生效;用于外部联动(宿主页面响应式刷新、埋点、日志),替代轮询。
@@ -857,7 +863,7 @@ export interface ChatSdk {
857
863
  hide(): void;
858
864
  /** 抽屉模式显示:移除 cs-hidden class 恢复可见(配合 hide 使用;首次挂载用 mount) */
859
865
  show(): void;
860
- send(message: string, options?: { mission?: Partial<Mission> }): Promise<string>;
866
+ send(message: string, options?: { mission?: Partial<Mission>; interceptors?: { input?: (input: unknown) => unknown; output?: (json: unknown) => unknown }; maxAutoRetries?: number }): Promise<string>;
861
867
  switchSession(sessionId?: string): Promise<string>;
862
868
  /** 列出当前 agent 的所有历史会话(供「历史列表」UI;storage 未开启 → []) */
863
869
  listSessions(): Promise<SessionMeta[]>;
package/types/index.d.ts CHANGED
@@ -777,7 +777,7 @@ export interface ChatSdkOptions {
777
777
  /** 模型最大输出(token);顶层声明对 llm 实例场景也生效,缺省按 model 名查表 */
778
778
  maxOutputTokens?: number;
779
779
  /** 子 agent 委派(默认开启;{ enabled: false } 关闭) */
780
- 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 };
780
+ 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 };
781
781
  subagent?: { enabled?: boolean; allowedTools?: string[]; systemPrompt?: string; temperature?: number; maxTokens?: number; skills?: SkillSpec[]; llm?: LLMConfig | ChatModelLike; maxDepth?: number; maxParallel?: number };
782
782
  /** 预声明子 agent 列表:每个用同主配置方式声明,自动生成 use_<id> 委派工具(与 spawn_agent 共存) */
783
783
  subagents?: SubagentConfig[];
@@ -785,6 +785,8 @@ export interface ChatSdkOptions {
785
785
  verify?: { enabled?: boolean; check?: VerifyCheck; maxAttempts?: number; adversarial?: boolean };
786
786
  /** 人工确认:工具调用前弹确认框,用户「允许/拒绝」后才执行(默认关闭,不传 = 不装) */
787
787
  approval?: ApprovalOptions;
788
+ /** 主动征询(默认开启):装载 request_human_confirmation 工具,LLM 在不确定/多方案/高风险时主动征询;false 关闭(types-alignment 补漏) */
789
+ humanConfirm?: boolean;
788
790
  /** 会话级 checkpoint 回滚(回到上次正常时)。默认关闭;传 true 或 { maxCheckpoints?, auto? } 开启 */
789
791
  checkpoint?: boolean | { maxCheckpoints?: number; auto?: boolean };
790
792
  /** MCP server 列表(连远程 server 动态注入其 tools;浏览器仅 http/sse/websocket) */
@@ -805,6 +807,10 @@ export interface ChatSdkOptions {
805
807
  summaryMaxTokens?: number;
806
808
  /** 摘要 LLM 超时毫秒(默认 15000;超时回退索引摘要) */
807
809
  summaryTimeoutMs?: number;
810
+ /** 压缩决策(agentCompression)LLM 超时毫秒(默认 6000;不复用 summaryTimeoutMs 15s,两段叠加阻塞首响应) */
811
+ decisionTimeoutMs?: number;
812
+ /** 压缩决策 LLM 输出上限(默认 2048;避免继承 summaryLlm 1024 截断 JSON → safeParse 失败无谓降级) */
813
+ decisionMaxTokens?: number;
808
814
  /**
809
815
  * SDK 事件回调:订阅常用时机(数据槽变化 / 消息更新 / 工具调用 / 流式文本 / 轮次 / 错误)。
810
816
  * UI 与 headless 模式均生效;用于外部联动(宿主页面响应式刷新、埋点、日志),替代轮询。
@@ -867,7 +873,7 @@ export interface ChatSdk {
867
873
  hide(): void;
868
874
  /** 抽屉模式显示:移除 cs-hidden class 恢复可见(配合 hide 使用;首次挂载用 mount) */
869
875
  show(): void;
870
- send(message: string, options?: { mission?: Partial<Mission> }): Promise<string>;
876
+ send(message: string, options?: { mission?: Partial<Mission>; interceptors?: { input?: (input: unknown) => unknown; output?: (json: unknown) => unknown }; maxAutoRetries?: number }): Promise<string>;
871
877
  switchSession(sessionId?: string): Promise<string>;
872
878
  /** 列出当前 agent 的所有历史会话(供「历史列表」UI;storage 未开启 → []) */
873
879
  listSessions(): Promise<SessionMeta[]>;