page-agent-sdk 4.26.1 → 4.27.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": "4.26.1",
3
+ "version": "4.27.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",
@@ -249,7 +249,8 @@ export type SdkEvent =
249
249
  | { type: 'focus_chip_click'; path: string; label?: string }
250
250
  | { type: 'focus_change'; focuses: Focus[] }
251
251
  | { type: 'proposal_pending'; id: string; summary: string; added: number; removed: number }
252
- | { type: 'proposal_resolved'; id: string; outcome: 'applied' | 'discarded'; summary: string };
252
+ | { type: 'proposal_resolved'; id: string; outcome: 'applied' | 'discarded'; summary: string }
253
+ | { type: 'action_resolved'; name: string; outcome: 'applied' | 'discarded'; detail?: string };
253
254
 
254
255
  /** token 用量(OpenAI 协议字段名) */
255
256
  export interface TokenUsage {
@@ -983,6 +984,8 @@ export interface ActionDef {
983
984
  run: (args: Record<string, unknown>) => unknown | Promise<unknown>;
984
985
  /** 可选参数 schema(ZodObject);不传 = 无参 tool */
985
986
  params?: any;
987
+ /** params 的别名:与 defineTool 的 schema 同名同义(消除两入口命名分叉);两者同给时 params 优先 */
988
+ schema?: any;
986
989
  /** 标记本 action 读取宿主态(4.20+):旧工具结果随 `sdk.notifyHostChange()` 替换为过期占位(修前仅 read_page 等五个内置页面读工具享受,action 仅靠 reason 文案口头告知);页面断言门禁的「页面依据」计数也计入。不标记 = 现行为零变化 */
987
990
  readsHostState?: boolean;
988
991
  /** 标记本 action 的效果延迟到用户确认才生效(提案类,4.20+):调用成功 ≠ 已写入 → 零工具门禁事实清单对此类调用注记「待用户确认后才生效」,防模型收口「已修改完成」;等效写计数不含此类。不标记 = 现行为零变化 */
@@ -1280,6 +1283,10 @@ export interface ChatSdk {
1280
1283
  revokeApprovalGrants(): void;
1281
1284
  /** content-proposals(4.22+):宿主裁决回传 → 出队 + proposal_resolved 事件 + 下轮结局注入;false = id 未知/已裁决 */
1282
1285
  resolveProposal(id: string, outcome: 'applied' | 'discarded', detail?: string): boolean;
1286
+ /** deferredWrite 动作裁决回传(action-resolve-outcome):结局入队 → 下一轮一次性系统段 + action_resolved 事件 + debugLogs(action_resolved)。
1287
+ * 名字键:同名字不同结局 = 新裁决覆盖旧笔;相同结局重报 / 未标记 deferredWrite / 未知名 → false(幂等)。
1288
+ * detail 自由文本随行(如「3 条候选:采纳 2」);裁决到达不打断在途轮;未送达的裁决随 switchSession/resetSession 清空 */
1289
+ resolveAction(name: string, outcome: 'applied' | 'discarded', detail?: string): boolean;
1283
1290
  /** content-proposals:只读状态投射(未配置恒 null) */
1284
1291
  readonly proposals: { pending: Array<{ id: string; summary: string; createdAt: number; added: number; removed: number }>; applied: number; discarded: number; lastResolved: { id: string; outcome: 'applied' | 'discarded'; summary: string; detail?: string; at: number } | null } | null;
1285
1292
  /** 回退到最近一次正常 checkpoint(整体还原对话历史 + 主数据 + vfs + todos);需开启 checkpoint,无可用返回 false */
package/types/index.d.ts CHANGED
@@ -253,7 +253,8 @@ export type SdkEvent =
253
253
  | { type: 'focus_chip_click'; path: string; label?: string }
254
254
  | { type: 'focus_change'; focuses: Focus[] }
255
255
  | { type: 'proposal_pending'; id: string; summary: string; added: number; removed: number }
256
- | { type: 'proposal_resolved'; id: string; outcome: 'applied' | 'discarded'; summary: string };
256
+ | { type: 'proposal_resolved'; id: string; outcome: 'applied' | 'discarded'; summary: string }
257
+ | { type: 'action_resolved'; name: string; outcome: 'applied' | 'discarded'; detail?: string };
257
258
 
258
259
  /** token 用量(OpenAI 协议字段名) */
259
260
  export interface TokenUsage {
@@ -1353,6 +1354,8 @@ export interface ActionDef {
1353
1354
  run: (args: Record<string, unknown>) => unknown | Promise<unknown>;
1354
1355
  /** 可选参数 schema(ZodObject);不传 = 无参 tool */
1355
1356
  params?: any;
1357
+ /** params 的别名:与 defineTool 的 schema 同名同义(消除两入口命名分叉);两者同给时 params 优先 */
1358
+ schema?: any;
1356
1359
  /** 标记本 action 读取宿主态(4.20+):旧工具结果随 `sdk.notifyHostChange()` 替换为过期占位(修前仅 read_page 等五个内置页面读工具享受,action 仅靠 reason 文案口头告知);页面断言门禁的「页面依据」计数也计入。不标记 = 现行为零变化 */
1357
1360
  readsHostState?: boolean;
1358
1361
  /** 标记本 action 的效果延迟到用户确认才生效(提案类,4.20+):调用成功 ≠ 已写入 → 零工具门禁事实清单对此类调用注记「待用户确认后才生效」,防模型收口「已修改完成」;等效写计数不含此类。不标记 = 现行为零变化 */
@@ -1706,6 +1709,10 @@ export interface ChatSdk {
1706
1709
  revokeApprovalGrants(): void;
1707
1710
  /** content-proposals(4.22+):宿主裁决回传 → 出队 + proposal_resolved 事件 + 下轮结局注入;false = id 未知/已裁决 */
1708
1711
  resolveProposal(id: string, outcome: 'applied' | 'discarded', detail?: string): boolean;
1712
+ /** deferredWrite 动作裁决回传(action-resolve-outcome):结局入队 → 下一轮一次性系统段 + action_resolved 事件 + debugLogs(action_resolved)。
1713
+ * 名字键:同名字不同结局 = 新裁决覆盖旧笔;相同结局重报 / 未标记 deferredWrite / 未知名 → false(幂等)。
1714
+ * detail 自由文本随行(如「3 条候选:采纳 2」);裁决到达不打断在途轮;未送达的裁决随 switchSession/resetSession 清空 */
1715
+ resolveAction(name: string, outcome: 'applied' | 'discarded', detail?: string): boolean;
1709
1716
  /** content-proposals:只读状态投射(未配置恒 null) */
1710
1717
  readonly proposals: { pending: Array<{ id: string; summary: string; createdAt: number; added: number; removed: number }>; applied: number; discarded: number; lastResolved: { id: string; outcome: 'applied' | 'discarded'; summary: string; detail?: string; at: number } | null } | null;
1711
1718
  /** 回退到最近一次正常 checkpoint(整体还原对话历史 + 主数据 + vfs + todos);需开启 checkpoint,无可用返回 false */