@xiaou66/vite-plugin-vue-mcp-next 1.1.1 → 1.2.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/dist/index.d.cts CHANGED
@@ -540,6 +540,79 @@ interface RuntimeScreenshotResult {
540
540
  /** 失败原因,保持浏览器 runtime 错误可读。 */
541
541
  readonly error?: string;
542
542
  }
543
+ /**
544
+ * 浏览器存储资源范围。
545
+ *
546
+ * Cookie 在 Runtime 侧只能访问当前页面可见的非 HttpOnly 值;CDP 可补足浏览器级查询能力。
547
+ */
548
+ type StorageScope = 'localStorage' | 'sessionStorage' | 'indexedDB' | 'cookie';
549
+ /**
550
+ * 浏览器存储操作类型。
551
+ *
552
+ * 使用统一动作枚举可以让 MCP 工具层和 Runtime 桥接层共享同一套权限与错误边界。
553
+ */
554
+ type StorageAction = 'list' | 'get' | 'set' | 'delete' | 'clear';
555
+ /**
556
+ * Runtime 存储桥接请求。
557
+ *
558
+ * Runtime 侧遵守浏览器同源策略,能处理 Web Storage、IndexedDB 以及 document.cookie 可见 Cookie;
559
+ * HttpOnly Cookie 必须依赖 CDP,不能通过页面脚本读取或删除。
560
+ */
561
+ interface RuntimeStorageRequest {
562
+ /** 并发请求隔离事件名,沿用现有 Runtime RPC 回传模型。 */
563
+ readonly event: string;
564
+ /** 页面目标 ID,用于多页面场景下确认请求来源。 */
565
+ readonly pageId: string;
566
+ /** 当前页面 origin,Runtime 侧用它拒绝跨源误用。 */
567
+ readonly origin: string;
568
+ /** 当前存储操作。 */
569
+ readonly action: StorageAction;
570
+ /** 当前存储资源范围。 */
571
+ readonly scope: StorageScope;
572
+ /** Web Storage key 或 IndexedDB key 的字符串表达。 */
573
+ readonly key?: string;
574
+ /** 写入值的 JSON 字符串表达,Runtime 侧按资源类型解释。 */
575
+ readonly value?: string;
576
+ /** IndexedDB 数据库名。 */
577
+ readonly databaseName?: string;
578
+ /** IndexedDB object store 名称。 */
579
+ readonly objectStoreName?: string;
580
+ /** IndexedDB index 名称,首版只作为查询边界保留。 */
581
+ readonly indexName?: string;
582
+ /** Cookie 操作参数,Runtime 只使用 document.cookie 可表达的同源字段。 */
583
+ readonly cookie?: {
584
+ readonly name: string;
585
+ readonly value?: string;
586
+ readonly domain?: string;
587
+ readonly path?: string;
588
+ readonly url?: string;
589
+ readonly httpOnly?: boolean;
590
+ readonly secure?: boolean;
591
+ readonly sameSite?: 'strict' | 'lax' | 'none';
592
+ readonly expires?: number;
593
+ };
594
+ }
595
+ /**
596
+ * Runtime 存储桥接结果。
597
+ *
598
+ * 结果显式携带 source,避免调用方把页面同源能力误认为浏览器级 CDP 能力。
599
+ */
600
+ interface RuntimeStorageResult {
601
+ /** 是否成功,失败时 error 必须说明边界或底层异常。 */
602
+ readonly ok: boolean;
603
+ /** 存储访问来源,调用方可据此区分页面同源能力和浏览器协议能力。 */
604
+ readonly source: 'hook' | 'cdp';
605
+ /** 实际执行的操作类型。 */
606
+ readonly action: StorageAction;
607
+ /** 实际访问的存储资源范围。 */
608
+ readonly scope: StorageScope;
609
+ /** 成功时返回的结构化数据。 */
610
+ readonly data?: unknown;
611
+ /** 能力限制说明,例如 Cookie 仅 CDP 可用。 */
612
+ readonly limitations?: string[];
613
+ /** 失败原因。 */
614
+ readonly error?: string;
615
+ }
543
616
  /**
544
617
  * 解析后的插件配置。
545
618
  *
@@ -777,6 +850,10 @@ interface VueRuntimeRpc {
777
850
  takeScreenshot(options: RuntimeScreenshotRequest): void | Promise<void>;
778
851
  /** 回传 snapdom 截图结果,使用事件名隔离并发 MCP 请求。 */
779
852
  onScreenshotTaken(event: string, data: RuntimeScreenshotResult): void;
853
+ /** 访问同源浏览器存储,用于无 CDP 配置时提供 Web Storage 和 IndexedDB 兜底。 */
854
+ manageStorage(options: RuntimeStorageRequest): void | Promise<void>;
855
+ /** 回传 Runtime 存储访问结果,使用事件名隔离并发 MCP 请求。 */
856
+ onStorageUpdated(event: string, data: RuntimeStorageResult): void;
780
857
  /** 读取 Vue component inspector tree,用于 `get_component_tree` 工具。 */
781
858
  getInspectorTree(options: {
782
859
  event: string;
package/dist/index.d.ts CHANGED
@@ -540,6 +540,79 @@ interface RuntimeScreenshotResult {
540
540
  /** 失败原因,保持浏览器 runtime 错误可读。 */
541
541
  readonly error?: string;
542
542
  }
543
+ /**
544
+ * 浏览器存储资源范围。
545
+ *
546
+ * Cookie 在 Runtime 侧只能访问当前页面可见的非 HttpOnly 值;CDP 可补足浏览器级查询能力。
547
+ */
548
+ type StorageScope = 'localStorage' | 'sessionStorage' | 'indexedDB' | 'cookie';
549
+ /**
550
+ * 浏览器存储操作类型。
551
+ *
552
+ * 使用统一动作枚举可以让 MCP 工具层和 Runtime 桥接层共享同一套权限与错误边界。
553
+ */
554
+ type StorageAction = 'list' | 'get' | 'set' | 'delete' | 'clear';
555
+ /**
556
+ * Runtime 存储桥接请求。
557
+ *
558
+ * Runtime 侧遵守浏览器同源策略,能处理 Web Storage、IndexedDB 以及 document.cookie 可见 Cookie;
559
+ * HttpOnly Cookie 必须依赖 CDP,不能通过页面脚本读取或删除。
560
+ */
561
+ interface RuntimeStorageRequest {
562
+ /** 并发请求隔离事件名,沿用现有 Runtime RPC 回传模型。 */
563
+ readonly event: string;
564
+ /** 页面目标 ID,用于多页面场景下确认请求来源。 */
565
+ readonly pageId: string;
566
+ /** 当前页面 origin,Runtime 侧用它拒绝跨源误用。 */
567
+ readonly origin: string;
568
+ /** 当前存储操作。 */
569
+ readonly action: StorageAction;
570
+ /** 当前存储资源范围。 */
571
+ readonly scope: StorageScope;
572
+ /** Web Storage key 或 IndexedDB key 的字符串表达。 */
573
+ readonly key?: string;
574
+ /** 写入值的 JSON 字符串表达,Runtime 侧按资源类型解释。 */
575
+ readonly value?: string;
576
+ /** IndexedDB 数据库名。 */
577
+ readonly databaseName?: string;
578
+ /** IndexedDB object store 名称。 */
579
+ readonly objectStoreName?: string;
580
+ /** IndexedDB index 名称,首版只作为查询边界保留。 */
581
+ readonly indexName?: string;
582
+ /** Cookie 操作参数,Runtime 只使用 document.cookie 可表达的同源字段。 */
583
+ readonly cookie?: {
584
+ readonly name: string;
585
+ readonly value?: string;
586
+ readonly domain?: string;
587
+ readonly path?: string;
588
+ readonly url?: string;
589
+ readonly httpOnly?: boolean;
590
+ readonly secure?: boolean;
591
+ readonly sameSite?: 'strict' | 'lax' | 'none';
592
+ readonly expires?: number;
593
+ };
594
+ }
595
+ /**
596
+ * Runtime 存储桥接结果。
597
+ *
598
+ * 结果显式携带 source,避免调用方把页面同源能力误认为浏览器级 CDP 能力。
599
+ */
600
+ interface RuntimeStorageResult {
601
+ /** 是否成功,失败时 error 必须说明边界或底层异常。 */
602
+ readonly ok: boolean;
603
+ /** 存储访问来源,调用方可据此区分页面同源能力和浏览器协议能力。 */
604
+ readonly source: 'hook' | 'cdp';
605
+ /** 实际执行的操作类型。 */
606
+ readonly action: StorageAction;
607
+ /** 实际访问的存储资源范围。 */
608
+ readonly scope: StorageScope;
609
+ /** 成功时返回的结构化数据。 */
610
+ readonly data?: unknown;
611
+ /** 能力限制说明,例如 Cookie 仅 CDP 可用。 */
612
+ readonly limitations?: string[];
613
+ /** 失败原因。 */
614
+ readonly error?: string;
615
+ }
543
616
  /**
544
617
  * 解析后的插件配置。
545
618
  *
@@ -777,6 +850,10 @@ interface VueRuntimeRpc {
777
850
  takeScreenshot(options: RuntimeScreenshotRequest): void | Promise<void>;
778
851
  /** 回传 snapdom 截图结果,使用事件名隔离并发 MCP 请求。 */
779
852
  onScreenshotTaken(event: string, data: RuntimeScreenshotResult): void;
853
+ /** 访问同源浏览器存储,用于无 CDP 配置时提供 Web Storage 和 IndexedDB 兜底。 */
854
+ manageStorage(options: RuntimeStorageRequest): void | Promise<void>;
855
+ /** 回传 Runtime 存储访问结果,使用事件名隔离并发 MCP 请求。 */
856
+ onStorageUpdated(event: string, data: RuntimeStorageResult): void;
780
857
  /** 读取 Vue component inspector tree,用于 `get_component_tree` 工具。 */
781
858
  getInspectorTree(options: {
782
859
  event: string;