page-agent-sdk 2.42.0 → 2.43.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": "2.42.0",
3
+ "version": "2.43.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",
@@ -255,6 +255,8 @@ export interface SubagentConfig {
255
255
  allowedTools?: string[];
256
256
  middleware?: any[];
257
257
  summarization?: boolean | any;
258
+ /** beforeReturn 自纠上限(默认 0 = 关闭);>0 时返回前跑中间件 beforeReturn 钩子(如 verify 格式门禁),feedback 回灌自纠。配 verify 类中间件时必开 */
259
+ maxVerifyAttempts?: number;
258
260
  }
259
261
  export interface AgentInfo {
260
262
  id: string;
@@ -1385,10 +1387,35 @@ export interface CreateHtmlSubagentOptions {
1385
1387
  temperature?: number;
1386
1388
  skills?: SkillSpec[];
1387
1389
  extraTools?: any[];
1390
+ /** 代码形态:'sfc'(默认,Vue SFC)/ 'html'(纯 HTML 片段,v-html 注入场景) */
1391
+ codeKind?: 'sfc' | 'html';
1392
+ /** 输出格式校验(validate_code 工具 + verify beforeReturn 门禁);默认 true */
1393
+ formatCheck?: boolean;
1388
1394
  [k: string]: any;
1389
1395
  }
1390
1396
  export declare function createRagSubagent(options: CreateRagSubagentOptions): SubagentConfig;
1391
1397
  export declare function createHtmlSubagent(options: CreateHtmlSubagentOptions): SubagentConfig;
1398
+ export interface HtmlFormatIssue {
1399
+ /** 行号(1 基) */
1400
+ line: number;
1401
+ /** 问题码:UNCLOSED_TAG / STRAY_CLOSE_TAG / UNCLOSED_COMMENT / DOCTYPE_IN_FRAGMENT / DOC_TAG_IN_FRAGMENT / SCRIPT_IN_FRAGMENT */
1402
+ code: string;
1403
+ message: string;
1404
+ }
1405
+ export interface ValidateHtmlFormatOptions {
1406
+ /** Vue SFC 模式:允许 <script>(SFC 自有块);默认 false = 纯 HTML 片段(禁 <script>) */
1407
+ sfc?: boolean;
1408
+ }
1409
+ /** HTML 格式校验(标签闭合 + v-html 片段契约);纯函数,node/浏览器通用(集成方渲染层纵深防御可复用) */
1410
+ export declare function validateHtmlFormat(source: string, opts?: ValidateHtmlFormatOptions): HtmlFormatIssue[];
1411
+ /** HTML void 元素集合(无需闭合标签;validateHtmlFormat 用,集成方可复用) */
1412
+ export declare const HTML_VOID_TAGS: Set<string>;
1413
+ export interface HtmlFormatCheckOptions {
1414
+ /** vfs 代码路径前缀(与 createHtmlSubagent 的 codeVfsPrefix 一致);默认 'html/' */
1415
+ vfsPrefix?: string;
1416
+ }
1417
+ /** HTML 格式 verify check(beforeReturn 门禁):扫 state.files 代码文件,不通过回灌 feedback 自纠 */
1418
+ export declare function createHtmlFormatCheck(opts?: HtmlFormatCheckOptions): VerifyCheck;
1392
1419
 
1393
1420
  // checkpoint / dataOps / permissions
1394
1421
  export interface CheckpointDeps { [k: string]: any }
package/types/index.d.ts CHANGED
@@ -251,6 +251,8 @@ export interface SubagentConfig {
251
251
  middleware?: any[];
252
252
  /** 跨轮上下文压缩;true=默认索引摘要(零 LLM),或 SummarizationOptions 自配(含 llmInvoke 升级)。不传=不装 */
253
253
  summarization?: boolean | any;
254
+ /** beforeReturn 自纠上限(默认 0 = 关闭);>0 时返回前跑中间件 beforeReturn 钩子(如 verify 格式门禁),feedback 回灌自纠。配 verify 类中间件时必开 */
255
+ maxVerifyAttempts?: number;
254
256
  }
255
257
  export interface AgentInfo {
256
258
  id: string;
@@ -1401,10 +1403,35 @@ export interface CreateHtmlSubagentOptions {
1401
1403
  temperature?: number;
1402
1404
  skills?: SkillSpec[];
1403
1405
  extraTools?: any[];
1406
+ /** 代码形态:'sfc'(默认,Vue SFC)/ 'html'(纯 HTML 片段,v-html 注入场景) */
1407
+ codeKind?: 'sfc' | 'html';
1408
+ /** 输出格式校验(validate_code 工具 + verify beforeReturn 门禁);默认 true */
1409
+ formatCheck?: boolean;
1404
1410
  [k: string]: any;
1405
1411
  }
1406
1412
  export declare function createRagSubagent(options: CreateRagSubagentOptions): SubagentConfig;
1407
1413
  export declare function createHtmlSubagent(options: CreateHtmlSubagentOptions): SubagentConfig;
1414
+ export interface HtmlFormatIssue {
1415
+ /** 行号(1 基) */
1416
+ line: number;
1417
+ /** 问题码:UNCLOSED_TAG / STRAY_CLOSE_TAG / UNCLOSED_COMMENT / DOCTYPE_IN_FRAGMENT / DOC_TAG_IN_FRAGMENT / SCRIPT_IN_FRAGMENT */
1418
+ code: string;
1419
+ message: string;
1420
+ }
1421
+ export interface ValidateHtmlFormatOptions {
1422
+ /** Vue SFC 模式:允许 <script>(SFC 自有块);默认 false = 纯 HTML 片段(禁 <script>) */
1423
+ sfc?: boolean;
1424
+ }
1425
+ /** HTML 格式校验(标签闭合 + v-html 片段契约);纯函数,node/浏览器通用(集成方渲染层纵深防御可复用) */
1426
+ export declare function validateHtmlFormat(source: string, opts?: ValidateHtmlFormatOptions): HtmlFormatIssue[];
1427
+ /** HTML void 元素集合(无需闭合标签;validateHtmlFormat 用,集成方可复用) */
1428
+ export declare const HTML_VOID_TAGS: Set<string>;
1429
+ export interface HtmlFormatCheckOptions {
1430
+ /** vfs 代码路径前缀(与 createHtmlSubagent 的 codeVfsPrefix 一致);默认 'html/' */
1431
+ vfsPrefix?: string;
1432
+ }
1433
+ /** HTML 格式 verify check(beforeReturn 门禁):扫 state.files 代码文件,不通过回灌 feedback 自纠 */
1434
+ export declare function createHtmlFormatCheck(opts?: HtmlFormatCheckOptions): VerifyCheck;
1408
1435
 
1409
1436
  // checkpoint / dataOps / permissions
1410
1437
  export interface CheckpointDeps { [k: string]: any }