@aipanel/core 1.2.8 → 1.2.9

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.
Files changed (59) hide show
  1. package/es/{logger.d.ts → client/logger.d.ts} +1 -1
  2. package/es/{logger.mjs → client/logger.mjs} +2 -2
  3. package/es/client.d.ts +1 -0
  4. package/es/client.mjs +1 -0
  5. package/es/{constants.d.ts → common/constants.d.ts} +8 -0
  6. package/es/{constants.mjs → common/constants.mjs} +9 -1
  7. package/{lib → es/common}/options.d.ts +16 -0
  8. package/{lib → es/common}/types.d.ts +34 -0
  9. package/es/index.d.ts +6 -7
  10. package/es/index.mjs +6 -7
  11. package/es/node/diagnostics.mjs +2 -2
  12. package/es/{file-log-watcher.mjs → node/file-log-watcher.mjs} +1 -1
  13. package/{lib → es/node}/node-logger.d.ts +1 -1
  14. package/es/{node-logger.mjs → node/node-logger.mjs} +2 -2
  15. package/es/{node-utils.mjs → node/node-utils.mjs} +1 -1
  16. package/es/node.d.ts +6 -6
  17. package/es/node.mjs +6 -6
  18. package/lib/{logger.cjs → client/logger.cjs} +2 -2
  19. package/lib/{logger.d.ts → client/logger.d.ts} +1 -1
  20. package/lib/client.cjs +21 -0
  21. package/lib/client.d.ts +1 -0
  22. package/lib/{constants.cjs → common/constants.cjs} +12 -1
  23. package/lib/{constants.d.ts → common/constants.d.ts} +8 -0
  24. package/{es → lib/common}/options.d.ts +16 -0
  25. package/{es → lib/common}/types.d.ts +34 -0
  26. package/lib/index.cjs +12 -14
  27. package/lib/index.d.ts +6 -7
  28. package/lib/node/diagnostics.cjs +2 -2
  29. package/lib/{file-log-watcher.cjs → node/file-log-watcher.cjs} +1 -1
  30. package/lib/{node-logger.cjs → node/node-logger.cjs} +2 -2
  31. package/{es → lib/node}/node-logger.d.ts +1 -1
  32. package/lib/{node-utils.cjs → node/node-utils.cjs} +1 -1
  33. package/lib/node.cjs +12 -12
  34. package/lib/node.d.ts +6 -6
  35. package/package.json +6 -1
  36. /package/es/{logger-core.d.ts → common/logger-core.d.ts} +0 -0
  37. /package/es/{logger-core.mjs → common/logger-core.mjs} +0 -0
  38. /package/es/{options.mjs → common/options.mjs} +0 -0
  39. /package/es/{provider.d.ts → common/provider.d.ts} +0 -0
  40. /package/es/{provider.mjs → common/provider.mjs} +0 -0
  41. /package/es/{types.mjs → common/types.mjs} +0 -0
  42. /package/es/{utils.d.ts → common/utils.d.ts} +0 -0
  43. /package/es/{utils.mjs → common/utils.mjs} +0 -0
  44. /package/es/{file-log-watcher.d.ts → node/file-log-watcher.d.ts} +0 -0
  45. /package/es/{node-utils.d.ts → node/node-utils.d.ts} +0 -0
  46. /package/es/{process-logger.d.ts → node/process-logger.d.ts} +0 -0
  47. /package/es/{process-logger.mjs → node/process-logger.mjs} +0 -0
  48. /package/lib/{logger-core.cjs → common/logger-core.cjs} +0 -0
  49. /package/lib/{logger-core.d.ts → common/logger-core.d.ts} +0 -0
  50. /package/lib/{options.cjs → common/options.cjs} +0 -0
  51. /package/lib/{provider.cjs → common/provider.cjs} +0 -0
  52. /package/lib/{provider.d.ts → common/provider.d.ts} +0 -0
  53. /package/lib/{types.cjs → common/types.cjs} +0 -0
  54. /package/lib/{utils.cjs → common/utils.cjs} +0 -0
  55. /package/lib/{utils.d.ts → common/utils.d.ts} +0 -0
  56. /package/lib/{file-log-watcher.d.ts → node/file-log-watcher.d.ts} +0 -0
  57. /package/lib/{node-utils.d.ts → node/node-utils.d.ts} +0 -0
  58. /package/lib/{process-logger.cjs → node/process-logger.cjs} +0 -0
  59. /package/lib/{process-logger.d.ts → node/process-logger.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import { type LogContext } from "./logger-core";
1
+ import { type LogContext } from "../common/logger-core";
2
2
  export declare const logger: {
3
3
  debug(message: string, context?: LogContext, ...args: unknown[]): void;
4
4
  info(message: string, context?: LogContext, ...args: unknown[]): void;
@@ -1,11 +1,11 @@
1
- import { LOG_PREFIX } from "./constants.mjs";
1
+ import { LOG_PREFIX } from "../common/constants.mjs";
2
2
  import {
3
3
  LogLevel,
4
4
  getConfig,
5
5
  getTimestamp,
6
6
  formatContext,
7
7
  formatValue
8
- } from "./logger-core.mjs";
8
+ } from "../common/logger-core.mjs";
9
9
  const LEVEL_NAMES = {
10
10
  [LogLevel.DEBUG]: "DEBUG",
11
11
  [LogLevel.INFO]: "INFO ",
package/es/client.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./client/logger";
package/es/client.mjs ADDED
@@ -0,0 +1 @@
1
+ export * from "./client/logger.mjs";
@@ -56,6 +56,8 @@ export declare const NOTIFICATION_DURATION = 3000;
56
56
  export declare const INIT_MARKER = "__AIPANEL_INITIALIZED__";
57
57
  /** 选中元素存储键 */
58
58
  export declare const SELECTED_ELEMENTS_KEY = "__aipanel_selected_elements__";
59
+ /** 页面会话标识键(sessionStorage,跨导航标识同一 Tab 的页面上下文) */
60
+ export declare const SESSION_ID_KEY = "_aipanel_pk";
59
61
  /** ==================== 缓存目录 ==================== */
60
62
  /**
61
63
  * AIPanel 项目级资源/缓存目录(相对于项目根目录,各 Provider 统一使用)。
@@ -83,6 +85,8 @@ export declare const EXT_MSG: {
83
85
  readonly SELECTION_START: "SELECTION_START";
84
86
  readonly SELECTION_STOP: "SELECTION_STOP";
85
87
  readonly CS_QUERY_WINDOW: "__CS_QUERY_WINDOW__";
88
+ /** Side Panel → Background:立即轮询一次并回传当前服务信息 */
89
+ readonly FORCE_POLL: "FORCE_POLL";
86
90
  readonly PAGE_CONTEXT: "PAGE_CONTEXT";
87
91
  readonly THEME_CHANGE: "THEME_CHANGE";
88
92
  readonly SERVICE_APPEARED: "SERVICE_APPEARED";
@@ -137,6 +141,10 @@ export declare const SEVERITY_WARN = 2;
137
141
  /** ==================== VS Code 扩展桥接 ==================== */
138
142
  /** VS Code 扩展 HTTP 服务端口(vscode-extension ↔ provider 通信协议) */
139
143
  export declare const VSCODE_EXTENSION_PORT = 51939;
144
+ /** VS Code 扩展 HTTP 路由:健康检查 */
145
+ export declare const VSCODE_ROUTE_HEALTH = "/health";
146
+ /** VS Code 扩展 HTTP 路由:文件格式化 */
147
+ export declare const VSCODE_ROUTE_FORMAT = "/format";
140
148
  /** VS Code 扩展相关环境变量名 */
141
149
  export declare const ENV_VSCODE_MODE = "AIPANEL_VSCODE_MODE";
142
150
  export declare const ENV_VSCODE_PORT = "AIPANEL_VSCODE_PORT";
@@ -22,6 +22,7 @@ const AUTO_OPEN_DELAY = 1e3;
22
22
  const NOTIFICATION_DURATION = 3e3;
23
23
  const INIT_MARKER = "__AIPANEL_INITIALIZED__";
24
24
  const SELECTED_ELEMENTS_KEY = "__aipanel_selected_elements__";
25
+ const SESSION_ID_KEY = "_aipanel_pk";
25
26
  const AIPANEL_CACHE_DIR = "node_modules/.cache/aipanel";
26
27
  const CHROME_DEVTOOLS_PORT = 9222;
27
28
  const CHROME_DEVTOOLS_CHECK_TIMEOUT = 2e3;
@@ -38,7 +39,9 @@ const EXT_MSG = {
38
39
  REQUEST_PAGE_CONTEXT: "REQUEST_PAGE_CONTEXT",
39
40
  SELECTION_START: "SELECTION_START",
40
41
  SELECTION_STOP: "SELECTION_STOP",
41
- CS_QUERY_WINDOW: "__CS_QUERY_WINDOW__"
42
+ CS_QUERY_WINDOW: "__CS_QUERY_WINDOW__",
43
+ /** Side Panel → Background:立即轮询一次并回传当前服务信息 */
44
+ FORCE_POLL: "FORCE_POLL"
42
45
  };
43
46
  const WIDGET_MSG = {
44
47
  READY: "AIPANEL_READY",
@@ -70,6 +73,8 @@ const PAGE_CONTEXT_MAX_TEXT_LENGTH = 1e4;
70
73
  const SEVERITY_ERROR = 1;
71
74
  const SEVERITY_WARN = 2;
72
75
  const VSCODE_EXTENSION_PORT = 51939;
76
+ const VSCODE_ROUTE_HEALTH = "/health";
77
+ const VSCODE_ROUTE_FORMAT = "/format";
73
78
  const ENV_VSCODE_MODE = "AIPANEL_VSCODE_MODE";
74
79
  const ENV_VSCODE_PORT = "AIPANEL_VSCODE_PORT";
75
80
  const VUE_DEVTOOLS_ACTIONS = {
@@ -115,11 +120,14 @@ export {
115
120
  SERVER_START_TIMEOUT,
116
121
  SERVER_SYNC_INTERVAL,
117
122
  SESSIONS_API_PATH,
123
+ SESSION_ID_KEY,
118
124
  SEVERITY_ERROR,
119
125
  SEVERITY_WARN,
120
126
  SSE_EVENTS_PATH,
121
127
  START_API_PATH,
122
128
  VSCODE_EXTENSION_PORT,
129
+ VSCODE_ROUTE_FORMAT,
130
+ VSCODE_ROUTE_HEALTH,
123
131
  VUE_DEVTOOLS_ACTIONS,
124
132
  WARMUP_API_PATH,
125
133
  WIDGET_MSG,
@@ -3,6 +3,20 @@
3
3
  * Provider 专属配置通过泛型 P 注入,核心层不感知具体 schema。
4
4
  */
5
5
  import type { DisplayMode, LogFileConfig, SplitModeOptions } from "./types";
6
+ /**
7
+ * chrome-devtools-mcp 进程的用户透传配置。
8
+ * 只允许“追加”,不允许覆盖核心受保护参数(由 McpProxy 统一过滤)。
9
+ */
10
+ export interface ChromeMcpOptions {
11
+ /**
12
+ * 追加的 CLI 参数(先于核心参数注入)。
13
+ * 与核心受保护项(auto-connect / usage-statistics / performance-crux /
14
+ * page-id-routing 及其反义)冲突的参数会被剔除并告警。
15
+ */
16
+ args?: string[];
17
+ /** 透传给 chrome-devtools-mcp 进程的额外环境变量(合并到 process.env 之上) */
18
+ env?: Record<string, string>;
19
+ }
6
20
  /**
7
21
  * 插件配置选项
8
22
  * @typeParam P - 当前 Provider 的专属配置段(schema 由具体 Provider 声明)
@@ -34,6 +48,8 @@ export interface PluginOptions<P extends Record<string, unknown> = Record<string
34
48
  warmupChromeMcp?: boolean;
35
49
  /** Chrome DevTools Protocol 端口,默认 9222 */
36
50
  chromeDevtoolsPort?: number;
51
+ /** chrome-devtools-mcp 进程透传配置(只可追加,不可覆盖核心受保护参数) */
52
+ chromeMcp?: ChromeMcpOptions;
37
53
  /** 展示模式,默认 'bubble' */
38
54
  displayMode?: DisplayMode;
39
55
  /** 分屏模式配置 */
@@ -84,6 +84,8 @@ export interface SelectedElement {
84
84
  innerText: string;
85
85
  /** 元素描述(标签名+选择器) */
86
86
  description?: string;
87
+ /** 用户选中节点时的页面 URL(AIPanel 附加;host 端上下文注入用) */
88
+ previewPageUrl?: string;
87
89
  }
88
90
  /**
89
91
  * 页面上下文数据
@@ -154,6 +156,22 @@ export interface AIPanelSelectedElement {
154
156
  column: number | null;
155
157
  innerText: string;
156
158
  description?: string;
159
+ /** 用户选中节点时的页面 URL(AIPanel 附加;host 端上下文注入用) */
160
+ previewPageUrl?: string;
161
+ }
162
+ /**
163
+ * 单条代码诊断(1-based 行列坐标)——AIPanel 诊断工具(run_diagnostics 等)的
164
+ * canonical 持久化/展示共用协议:宿主插件写 tool/result.meta,client 插件据此渲染卡片。
165
+ */
166
+ export interface AIPanelDiagnosticEntry {
167
+ /** 所属文件(绝对路径) */
168
+ file: string;
169
+ /** 1-based 行号 */
170
+ line: number;
171
+ /** 1-based 列号 */
172
+ column: number;
173
+ severity: "error" | "warning";
174
+ message: string;
157
175
  }
158
176
  /**
159
177
  * 删除选中节点的载荷
@@ -185,6 +203,22 @@ export interface AIPanelSelectedElementItem {
185
203
  panelFileText: string;
186
204
  element: AIPanelSelectedElement;
187
205
  }
206
+ /**
207
+ * 服务实例信息(Chrome 扩展 Background ↔ Side Panel 共享的服务载荷;
208
+ * 由 widget 的 SERVICE_INFO 上报与 vite start 端点探测归一化而来)。
209
+ */
210
+ export interface AIPanelServiceInfo {
211
+ /** 代理端口 */
212
+ proxyPort: number;
213
+ /** Vite 开发服务端口(字符串;可能来自 widget 上报或探测 origin) */
214
+ vitePort: string;
215
+ /** 项目根目录 */
216
+ projectRoot: string;
217
+ /** 服务实例唯一 id(多实例隔离) */
218
+ serviceInstanceId: string;
219
+ /** 是否开启 verbose(可选) */
220
+ verbose?: boolean;
221
+ }
188
222
  /**
189
223
  * 挂件组件 Props
190
224
  */
package/es/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- export * from "./constants";
2
- export * from "./logger-core";
3
- export * from "./logger";
4
- export * from "./options";
5
- export * from "./provider";
6
- export * from "./types";
7
- export * from "./utils";
1
+ export * from "./common/constants";
2
+ export * from "./common/logger-core";
3
+ export * from "./common/options";
4
+ export * from "./common/provider";
5
+ export * from "./common/types";
6
+ export * from "./common/utils";
package/es/index.mjs CHANGED
@@ -1,7 +1,6 @@
1
- export * from "./constants.mjs";
2
- export * from "./logger-core.mjs";
3
- export * from "./logger.mjs";
4
- export * from "./options.mjs";
5
- export * from "./provider.mjs";
6
- export * from "./types.mjs";
7
- export * from "./utils.mjs";
1
+ export * from "./common/constants.mjs";
2
+ export * from "./common/logger-core.mjs";
3
+ export * from "./common/options.mjs";
4
+ export * from "./common/provider.mjs";
5
+ export * from "./common/types.mjs";
6
+ export * from "./common/utils.mjs";
@@ -2,8 +2,8 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { exec } from "node:child_process";
4
4
  import { createRequire } from "node:module";
5
- import { SEVERITY_ERROR, SEVERITY_WARN } from "../constants.mjs";
6
- import { createLogger } from "../node-logger.mjs";
5
+ import { SEVERITY_ERROR, SEVERITY_WARN } from "../common/constants.mjs";
6
+ import { createLogger } from "./node-logger.mjs";
7
7
  const log = createLogger("Diagnostics");
8
8
  const JS_EXTENSIONS = /* @__PURE__ */ new Set([
9
9
  ".js",
@@ -1,6 +1,6 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import { createLogger } from "./logger.mjs";
3
+ import { createLogger } from "../client/logger.mjs";
4
4
  const log = createLogger("FileLogReader");
5
5
  function detectLogLevel(line) {
6
6
  const lowerLine = line.toLowerCase();
@@ -1,4 +1,4 @@
1
- import { type LogContext } from "./logger-core";
1
+ import { type LogContext } from "../common/logger-core";
2
2
  export declare const nodeLogger: {
3
3
  debug(message: string, context?: LogContext, ...args: unknown[]): void;
4
4
  info(message: string, context?: LogContext, ...args: unknown[]): void;
@@ -1,14 +1,14 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { LOG_PREFIX } from "./constants.mjs";
4
+ import { LOG_PREFIX } from "../common/constants.mjs";
5
5
  import {
6
6
  LogLevel,
7
7
  getConfig,
8
8
  formatContext,
9
9
  formatValue,
10
10
  generateTraceId as _generateTraceId
11
- } from "./logger-core.mjs";
11
+ } from "../common/logger-core.mjs";
12
12
  const COLORS = {
13
13
  reset: "\x1B[0m",
14
14
  dim: "\x1B[2m",
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
2
  import path from "node:path";
3
- import { CHROME_DEVTOOLS_PORT, CHROME_DEVTOOLS_CHECK_TIMEOUT } from "./constants.mjs";
3
+ import { CHROME_DEVTOOLS_PORT, CHROME_DEVTOOLS_CHECK_TIMEOUT } from "../common/constants.mjs";
4
4
  function createPackageRequire(baseDir = process.cwd()) {
5
5
  return createRequire(path.join(baseDir, "package.json"));
6
6
  }
package/es/node.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export * from "./constants";
2
- export * from "./logger-core";
3
- export * from "./node-logger";
4
- export * from "./process-logger";
5
- export * from "./file-log-watcher";
6
- export * from "./node-utils";
1
+ export * from "./common/constants";
2
+ export * from "./common/logger-core";
3
+ export * from "./node/node-logger";
4
+ export * from "./node/process-logger";
5
+ export * from "./node/file-log-watcher";
6
+ export * from "./node/node-utils";
7
7
  export * from "./node/diagnostics";
package/es/node.mjs CHANGED
@@ -1,7 +1,7 @@
1
- export * from "./constants.mjs";
2
- export * from "./logger-core.mjs";
3
- export * from "./node-logger.mjs";
4
- export * from "./process-logger.mjs";
5
- export * from "./file-log-watcher.mjs";
6
- export * from "./node-utils.mjs";
1
+ export * from "./common/constants.mjs";
2
+ export * from "./common/logger-core.mjs";
3
+ export * from "./node/node-logger.mjs";
4
+ export * from "./node/process-logger.mjs";
5
+ export * from "./node/file-log-watcher.mjs";
6
+ export * from "./node/node-utils.mjs";
7
7
  export * from "./node/diagnostics.mjs";
@@ -21,8 +21,8 @@ __export(logger_exports, {
21
21
  logger: () => logger
22
22
  });
23
23
  module.exports = __toCommonJS(logger_exports);
24
- var import_constants = require("./constants.cjs");
25
- var import_logger_core = require("./logger-core.cjs");
24
+ var import_constants = require("../common/constants.cjs");
25
+ var import_logger_core = require("../common/logger-core.cjs");
26
26
  const LEVEL_NAMES = {
27
27
  [import_logger_core.LogLevel.DEBUG]: "DEBUG",
28
28
  [import_logger_core.LogLevel.INFO]: "INFO ",
@@ -1,4 +1,4 @@
1
- import { type LogContext } from "./logger-core";
1
+ import { type LogContext } from "../common/logger-core";
2
2
  export declare const logger: {
3
3
  debug(message: string, context?: LogContext, ...args: unknown[]): void;
4
4
  info(message: string, context?: LogContext, ...args: unknown[]): void;
package/lib/client.cjs ADDED
@@ -0,0 +1,21 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var client_exports = {};
16
+ module.exports = __toCommonJS(client_exports);
17
+ __reExport(client_exports, require("./client/logger.cjs"), module.exports);
18
+ // Annotate the CommonJS export names for ESM import in node:
19
+ 0 && (module.exports = {
20
+ ...require("./client/logger.cjs")
21
+ });
@@ -0,0 +1 @@
1
+ export * from "./client/logger";
@@ -51,11 +51,14 @@ __export(constants_exports, {
51
51
  SERVER_START_TIMEOUT: () => SERVER_START_TIMEOUT,
52
52
  SERVER_SYNC_INTERVAL: () => SERVER_SYNC_INTERVAL,
53
53
  SESSIONS_API_PATH: () => SESSIONS_API_PATH,
54
+ SESSION_ID_KEY: () => SESSION_ID_KEY,
54
55
  SEVERITY_ERROR: () => SEVERITY_ERROR,
55
56
  SEVERITY_WARN: () => SEVERITY_WARN,
56
57
  SSE_EVENTS_PATH: () => SSE_EVENTS_PATH,
57
58
  START_API_PATH: () => START_API_PATH,
58
59
  VSCODE_EXTENSION_PORT: () => VSCODE_EXTENSION_PORT,
60
+ VSCODE_ROUTE_FORMAT: () => VSCODE_ROUTE_FORMAT,
61
+ VSCODE_ROUTE_HEALTH: () => VSCODE_ROUTE_HEALTH,
59
62
  VUE_DEVTOOLS_ACTIONS: () => VUE_DEVTOOLS_ACTIONS,
60
63
  WARMUP_API_PATH: () => WARMUP_API_PATH,
61
64
  WIDGET_MSG: () => WIDGET_MSG,
@@ -87,6 +90,7 @@ const AUTO_OPEN_DELAY = 1e3;
87
90
  const NOTIFICATION_DURATION = 3e3;
88
91
  const INIT_MARKER = "__AIPANEL_INITIALIZED__";
89
92
  const SELECTED_ELEMENTS_KEY = "__aipanel_selected_elements__";
93
+ const SESSION_ID_KEY = "_aipanel_pk";
90
94
  const AIPANEL_CACHE_DIR = "node_modules/.cache/aipanel";
91
95
  const CHROME_DEVTOOLS_PORT = 9222;
92
96
  const CHROME_DEVTOOLS_CHECK_TIMEOUT = 2e3;
@@ -103,7 +107,9 @@ const EXT_MSG = {
103
107
  REQUEST_PAGE_CONTEXT: "REQUEST_PAGE_CONTEXT",
104
108
  SELECTION_START: "SELECTION_START",
105
109
  SELECTION_STOP: "SELECTION_STOP",
106
- CS_QUERY_WINDOW: "__CS_QUERY_WINDOW__"
110
+ CS_QUERY_WINDOW: "__CS_QUERY_WINDOW__",
111
+ /** Side Panel → Background:立即轮询一次并回传当前服务信息 */
112
+ FORCE_POLL: "FORCE_POLL"
107
113
  };
108
114
  const WIDGET_MSG = {
109
115
  READY: "AIPANEL_READY",
@@ -135,6 +141,8 @@ const PAGE_CONTEXT_MAX_TEXT_LENGTH = 1e4;
135
141
  const SEVERITY_ERROR = 1;
136
142
  const SEVERITY_WARN = 2;
137
143
  const VSCODE_EXTENSION_PORT = 51939;
144
+ const VSCODE_ROUTE_HEALTH = "/health";
145
+ const VSCODE_ROUTE_FORMAT = "/format";
138
146
  const ENV_VSCODE_MODE = "AIPANEL_VSCODE_MODE";
139
147
  const ENV_VSCODE_PORT = "AIPANEL_VSCODE_PORT";
140
148
  const VUE_DEVTOOLS_ACTIONS = {
@@ -181,11 +189,14 @@ const VUE_DEVTOOLS_ACTIONS = {
181
189
  SERVER_START_TIMEOUT,
182
190
  SERVER_SYNC_INTERVAL,
183
191
  SESSIONS_API_PATH,
192
+ SESSION_ID_KEY,
184
193
  SEVERITY_ERROR,
185
194
  SEVERITY_WARN,
186
195
  SSE_EVENTS_PATH,
187
196
  START_API_PATH,
188
197
  VSCODE_EXTENSION_PORT,
198
+ VSCODE_ROUTE_FORMAT,
199
+ VSCODE_ROUTE_HEALTH,
189
200
  VUE_DEVTOOLS_ACTIONS,
190
201
  WARMUP_API_PATH,
191
202
  WIDGET_MSG,
@@ -56,6 +56,8 @@ export declare const NOTIFICATION_DURATION = 3000;
56
56
  export declare const INIT_MARKER = "__AIPANEL_INITIALIZED__";
57
57
  /** 选中元素存储键 */
58
58
  export declare const SELECTED_ELEMENTS_KEY = "__aipanel_selected_elements__";
59
+ /** 页面会话标识键(sessionStorage,跨导航标识同一 Tab 的页面上下文) */
60
+ export declare const SESSION_ID_KEY = "_aipanel_pk";
59
61
  /** ==================== 缓存目录 ==================== */
60
62
  /**
61
63
  * AIPanel 项目级资源/缓存目录(相对于项目根目录,各 Provider 统一使用)。
@@ -83,6 +85,8 @@ export declare const EXT_MSG: {
83
85
  readonly SELECTION_START: "SELECTION_START";
84
86
  readonly SELECTION_STOP: "SELECTION_STOP";
85
87
  readonly CS_QUERY_WINDOW: "__CS_QUERY_WINDOW__";
88
+ /** Side Panel → Background:立即轮询一次并回传当前服务信息 */
89
+ readonly FORCE_POLL: "FORCE_POLL";
86
90
  readonly PAGE_CONTEXT: "PAGE_CONTEXT";
87
91
  readonly THEME_CHANGE: "THEME_CHANGE";
88
92
  readonly SERVICE_APPEARED: "SERVICE_APPEARED";
@@ -137,6 +141,10 @@ export declare const SEVERITY_WARN = 2;
137
141
  /** ==================== VS Code 扩展桥接 ==================== */
138
142
  /** VS Code 扩展 HTTP 服务端口(vscode-extension ↔ provider 通信协议) */
139
143
  export declare const VSCODE_EXTENSION_PORT = 51939;
144
+ /** VS Code 扩展 HTTP 路由:健康检查 */
145
+ export declare const VSCODE_ROUTE_HEALTH = "/health";
146
+ /** VS Code 扩展 HTTP 路由:文件格式化 */
147
+ export declare const VSCODE_ROUTE_FORMAT = "/format";
140
148
  /** VS Code 扩展相关环境变量名 */
141
149
  export declare const ENV_VSCODE_MODE = "AIPANEL_VSCODE_MODE";
142
150
  export declare const ENV_VSCODE_PORT = "AIPANEL_VSCODE_PORT";
@@ -3,6 +3,20 @@
3
3
  * Provider 专属配置通过泛型 P 注入,核心层不感知具体 schema。
4
4
  */
5
5
  import type { DisplayMode, LogFileConfig, SplitModeOptions } from "./types";
6
+ /**
7
+ * chrome-devtools-mcp 进程的用户透传配置。
8
+ * 只允许“追加”,不允许覆盖核心受保护参数(由 McpProxy 统一过滤)。
9
+ */
10
+ export interface ChromeMcpOptions {
11
+ /**
12
+ * 追加的 CLI 参数(先于核心参数注入)。
13
+ * 与核心受保护项(auto-connect / usage-statistics / performance-crux /
14
+ * page-id-routing 及其反义)冲突的参数会被剔除并告警。
15
+ */
16
+ args?: string[];
17
+ /** 透传给 chrome-devtools-mcp 进程的额外环境变量(合并到 process.env 之上) */
18
+ env?: Record<string, string>;
19
+ }
6
20
  /**
7
21
  * 插件配置选项
8
22
  * @typeParam P - 当前 Provider 的专属配置段(schema 由具体 Provider 声明)
@@ -34,6 +48,8 @@ export interface PluginOptions<P extends Record<string, unknown> = Record<string
34
48
  warmupChromeMcp?: boolean;
35
49
  /** Chrome DevTools Protocol 端口,默认 9222 */
36
50
  chromeDevtoolsPort?: number;
51
+ /** chrome-devtools-mcp 进程透传配置(只可追加,不可覆盖核心受保护参数) */
52
+ chromeMcp?: ChromeMcpOptions;
37
53
  /** 展示模式,默认 'bubble' */
38
54
  displayMode?: DisplayMode;
39
55
  /** 分屏模式配置 */
@@ -84,6 +84,8 @@ export interface SelectedElement {
84
84
  innerText: string;
85
85
  /** 元素描述(标签名+选择器) */
86
86
  description?: string;
87
+ /** 用户选中节点时的页面 URL(AIPanel 附加;host 端上下文注入用) */
88
+ previewPageUrl?: string;
87
89
  }
88
90
  /**
89
91
  * 页面上下文数据
@@ -154,6 +156,22 @@ export interface AIPanelSelectedElement {
154
156
  column: number | null;
155
157
  innerText: string;
156
158
  description?: string;
159
+ /** 用户选中节点时的页面 URL(AIPanel 附加;host 端上下文注入用) */
160
+ previewPageUrl?: string;
161
+ }
162
+ /**
163
+ * 单条代码诊断(1-based 行列坐标)——AIPanel 诊断工具(run_diagnostics 等)的
164
+ * canonical 持久化/展示共用协议:宿主插件写 tool/result.meta,client 插件据此渲染卡片。
165
+ */
166
+ export interface AIPanelDiagnosticEntry {
167
+ /** 所属文件(绝对路径) */
168
+ file: string;
169
+ /** 1-based 行号 */
170
+ line: number;
171
+ /** 1-based 列号 */
172
+ column: number;
173
+ severity: "error" | "warning";
174
+ message: string;
157
175
  }
158
176
  /**
159
177
  * 删除选中节点的载荷
@@ -185,6 +203,22 @@ export interface AIPanelSelectedElementItem {
185
203
  panelFileText: string;
186
204
  element: AIPanelSelectedElement;
187
205
  }
206
+ /**
207
+ * 服务实例信息(Chrome 扩展 Background ↔ Side Panel 共享的服务载荷;
208
+ * 由 widget 的 SERVICE_INFO 上报与 vite start 端点探测归一化而来)。
209
+ */
210
+ export interface AIPanelServiceInfo {
211
+ /** 代理端口 */
212
+ proxyPort: number;
213
+ /** Vite 开发服务端口(字符串;可能来自 widget 上报或探测 origin) */
214
+ vitePort: string;
215
+ /** 项目根目录 */
216
+ projectRoot: string;
217
+ /** 服务实例唯一 id(多实例隔离) */
218
+ serviceInstanceId: string;
219
+ /** 是否开启 verbose(可选) */
220
+ verbose?: boolean;
221
+ }
188
222
  /**
189
223
  * 挂件组件 Props
190
224
  */
package/lib/index.cjs CHANGED
@@ -14,20 +14,18 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
14
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
15
  var lib_exports = {};
16
16
  module.exports = __toCommonJS(lib_exports);
17
- __reExport(lib_exports, require("./constants.cjs"), module.exports);
18
- __reExport(lib_exports, require("./logger-core.cjs"), module.exports);
19
- __reExport(lib_exports, require("./logger.cjs"), module.exports);
20
- __reExport(lib_exports, require("./options.cjs"), module.exports);
21
- __reExport(lib_exports, require("./provider.cjs"), module.exports);
22
- __reExport(lib_exports, require("./types.cjs"), module.exports);
23
- __reExport(lib_exports, require("./utils.cjs"), module.exports);
17
+ __reExport(lib_exports, require("./common/constants.cjs"), module.exports);
18
+ __reExport(lib_exports, require("./common/logger-core.cjs"), module.exports);
19
+ __reExport(lib_exports, require("./common/options.cjs"), module.exports);
20
+ __reExport(lib_exports, require("./common/provider.cjs"), module.exports);
21
+ __reExport(lib_exports, require("./common/types.cjs"), module.exports);
22
+ __reExport(lib_exports, require("./common/utils.cjs"), module.exports);
24
23
  // Annotate the CommonJS export names for ESM import in node:
25
24
  0 && (module.exports = {
26
- ...require("./constants.cjs"),
27
- ...require("./logger-core.cjs"),
28
- ...require("./logger.cjs"),
29
- ...require("./options.cjs"),
30
- ...require("./provider.cjs"),
31
- ...require("./types.cjs"),
32
- ...require("./utils.cjs")
25
+ ...require("./common/constants.cjs"),
26
+ ...require("./common/logger-core.cjs"),
27
+ ...require("./common/options.cjs"),
28
+ ...require("./common/provider.cjs"),
29
+ ...require("./common/types.cjs"),
30
+ ...require("./common/utils.cjs")
33
31
  });
package/lib/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- export * from "./constants";
2
- export * from "./logger-core";
3
- export * from "./logger";
4
- export * from "./options";
5
- export * from "./provider";
6
- export * from "./types";
7
- export * from "./utils";
1
+ export * from "./common/constants";
2
+ export * from "./common/logger-core";
3
+ export * from "./common/options";
4
+ export * from "./common/provider";
5
+ export * from "./common/types";
6
+ export * from "./common/utils";
@@ -41,8 +41,8 @@ var import_node_fs = __toESM(require("node:fs"));
41
41
  var import_node_path = __toESM(require("node:path"));
42
42
  var import_node_child_process = require("node:child_process");
43
43
  var import_node_module = require("node:module");
44
- var import_constants = require("../constants.cjs");
45
- var import_node_logger = require("../node-logger.cjs");
44
+ var import_constants = require("../common/constants.cjs");
45
+ var import_node_logger = require("./node-logger.cjs");
46
46
  const import_meta = {};
47
47
  const log = (0, import_node_logger.createLogger)("Diagnostics");
48
48
  const JS_EXTENSIONS = /* @__PURE__ */ new Set([
@@ -33,7 +33,7 @@ __export(file_log_watcher_exports, {
33
33
  module.exports = __toCommonJS(file_log_watcher_exports);
34
34
  var import_fs = __toESM(require("fs"));
35
35
  var import_path = __toESM(require("path"));
36
- var import_logger = require("./logger.cjs");
36
+ var import_logger = require("../client/logger.cjs");
37
37
  const log = (0, import_logger.createLogger)("FileLogReader");
38
38
  function detectLogLevel(line) {
39
39
  const lowerLine = line.toLowerCase();
@@ -28,8 +28,8 @@ __export(node_logger_exports, {
28
28
  nodeLogger: () => nodeLogger
29
29
  });
30
30
  module.exports = __toCommonJS(node_logger_exports);
31
- var import_constants = require("./constants.cjs");
32
- var import_logger_core = require("./logger-core.cjs");
31
+ var import_constants = require("../common/constants.cjs");
32
+ var import_logger_core = require("../common/logger-core.cjs");
33
33
  const COLORS = {
34
34
  reset: "\x1B[0m",
35
35
  dim: "\x1B[2m",
@@ -1,4 +1,4 @@
1
- import { type LogContext } from "./logger-core";
1
+ import { type LogContext } from "../common/logger-core";
2
2
  export declare const nodeLogger: {
3
3
  debug(message: string, context?: LogContext, ...args: unknown[]): void;
4
4
  info(message: string, context?: LogContext, ...args: unknown[]): void;
@@ -36,7 +36,7 @@ __export(node_utils_exports, {
36
36
  module.exports = __toCommonJS(node_utils_exports);
37
37
  var import_node_module = require("node:module");
38
38
  var import_node_path = __toESM(require("node:path"));
39
- var import_constants = require("./constants.cjs");
39
+ var import_constants = require("../common/constants.cjs");
40
40
  function createPackageRequire(baseDir = process.cwd()) {
41
41
  return (0, import_node_module.createRequire)(import_node_path.default.join(baseDir, "package.json"));
42
42
  }
package/lib/node.cjs CHANGED
@@ -14,20 +14,20 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
14
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
15
  var node_exports = {};
16
16
  module.exports = __toCommonJS(node_exports);
17
- __reExport(node_exports, require("./constants.cjs"), module.exports);
18
- __reExport(node_exports, require("./logger-core.cjs"), module.exports);
19
- __reExport(node_exports, require("./node-logger.cjs"), module.exports);
20
- __reExport(node_exports, require("./process-logger.cjs"), module.exports);
21
- __reExport(node_exports, require("./file-log-watcher.cjs"), module.exports);
22
- __reExport(node_exports, require("./node-utils.cjs"), module.exports);
17
+ __reExport(node_exports, require("./common/constants.cjs"), module.exports);
18
+ __reExport(node_exports, require("./common/logger-core.cjs"), module.exports);
19
+ __reExport(node_exports, require("./node/node-logger.cjs"), module.exports);
20
+ __reExport(node_exports, require("./node/process-logger.cjs"), module.exports);
21
+ __reExport(node_exports, require("./node/file-log-watcher.cjs"), module.exports);
22
+ __reExport(node_exports, require("./node/node-utils.cjs"), module.exports);
23
23
  __reExport(node_exports, require("./node/diagnostics.cjs"), module.exports);
24
24
  // Annotate the CommonJS export names for ESM import in node:
25
25
  0 && (module.exports = {
26
- ...require("./constants.cjs"),
27
- ...require("./logger-core.cjs"),
28
- ...require("./node-logger.cjs"),
29
- ...require("./process-logger.cjs"),
30
- ...require("./file-log-watcher.cjs"),
31
- ...require("./node-utils.cjs"),
26
+ ...require("./common/constants.cjs"),
27
+ ...require("./common/logger-core.cjs"),
28
+ ...require("./node/node-logger.cjs"),
29
+ ...require("./node/process-logger.cjs"),
30
+ ...require("./node/file-log-watcher.cjs"),
31
+ ...require("./node/node-utils.cjs"),
32
32
  ...require("./node/diagnostics.cjs")
33
33
  });
package/lib/node.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export * from "./constants";
2
- export * from "./logger-core";
3
- export * from "./node-logger";
4
- export * from "./process-logger";
5
- export * from "./file-log-watcher";
6
- export * from "./node-utils";
1
+ export * from "./common/constants";
2
+ export * from "./common/logger-core";
3
+ export * from "./node/node-logger";
4
+ export * from "./node/process-logger";
5
+ export * from "./node/file-log-watcher";
6
+ export * from "./node/node-utils";
7
7
  export * from "./node/diagnostics";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aipanel/core",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "lib/index.cjs",
@@ -16,6 +16,11 @@
16
16
  "import": "./es/index.mjs",
17
17
  "require": "./lib/index.cjs"
18
18
  },
19
+ "./client": {
20
+ "types": "./es/client.d.ts",
21
+ "import": "./es/client.mjs",
22
+ "require": "./lib/client.cjs"
23
+ },
19
24
  "./node": {
20
25
  "types": "./es/node.d.ts",
21
26
  "import": "./es/node.mjs",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes