@aipanel/core 1.2.7 → 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} +11 -1
  6. package/es/{constants.mjs → common/constants.mjs} +11 -1
  7. package/es/{options.d.ts → common/options.d.ts} +16 -0
  8. package/{lib → es/common}/provider.d.ts +18 -2
  9. package/{lib → es/common}/types.d.ts +34 -0
  10. package/es/index.d.ts +6 -7
  11. package/es/index.mjs +6 -7
  12. package/es/node/diagnostics.mjs +2 -2
  13. package/es/{file-log-watcher.mjs → node/file-log-watcher.mjs} +1 -1
  14. package/{lib → es/node}/node-logger.d.ts +5 -2
  15. package/es/{node-logger.mjs → node/node-logger.mjs} +12 -5
  16. package/es/{node-utils.mjs → node/node-utils.mjs} +1 -1
  17. package/es/node.d.ts +6 -6
  18. package/es/node.mjs +6 -6
  19. package/lib/{logger.cjs → client/logger.cjs} +2 -2
  20. package/lib/{logger.d.ts → client/logger.d.ts} +1 -1
  21. package/lib/client.cjs +21 -0
  22. package/lib/client.d.ts +1 -0
  23. package/lib/{constants.cjs → common/constants.cjs} +15 -1
  24. package/lib/{constants.d.ts → common/constants.d.ts} +11 -1
  25. package/lib/{options.d.ts → common/options.d.ts} +16 -0
  26. package/{es → lib/common}/provider.d.ts +18 -2
  27. package/{es → lib/common}/types.d.ts +34 -0
  28. package/lib/index.cjs +12 -14
  29. package/lib/index.d.ts +6 -7
  30. package/lib/node/diagnostics.cjs +2 -2
  31. package/lib/{file-log-watcher.cjs → node/file-log-watcher.cjs} +1 -1
  32. package/lib/{node-logger.cjs → node/node-logger.cjs} +12 -5
  33. package/{es → lib/node}/node-logger.d.ts +5 -2
  34. package/lib/{node-utils.cjs → node/node-utils.cjs} +1 -1
  35. package/lib/node.cjs +12 -12
  36. package/lib/node.d.ts +6 -6
  37. package/package.json +6 -1
  38. /package/es/{logger-core.d.ts → common/logger-core.d.ts} +0 -0
  39. /package/es/{logger-core.mjs → common/logger-core.mjs} +0 -0
  40. /package/es/{options.mjs → common/options.mjs} +0 -0
  41. /package/es/{provider.mjs → common/provider.mjs} +0 -0
  42. /package/es/{types.mjs → common/types.mjs} +0 -0
  43. /package/es/{utils.d.ts → common/utils.d.ts} +0 -0
  44. /package/es/{utils.mjs → common/utils.mjs} +0 -0
  45. /package/es/{file-log-watcher.d.ts → node/file-log-watcher.d.ts} +0 -0
  46. /package/es/{node-utils.d.ts → node/node-utils.d.ts} +0 -0
  47. /package/es/{process-logger.d.ts → node/process-logger.d.ts} +0 -0
  48. /package/es/{process-logger.mjs → node/process-logger.mjs} +0 -0
  49. /package/lib/{logger-core.cjs → common/logger-core.cjs} +0 -0
  50. /package/lib/{logger-core.d.ts → common/logger-core.d.ts} +0 -0
  51. /package/lib/{options.cjs → common/options.cjs} +0 -0
  52. /package/lib/{provider.cjs → common/provider.cjs} +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";
@@ -37,8 +37,10 @@ export declare const START_API_PATH = "/__aipanel_start__";
37
37
  export declare const SESSIONS_API_PATH = "/__aipanel_sessions__";
38
38
  /** MCP 代理 API 路径 */
39
39
  export declare const MCP_API_PATH = "/__aipanel_mcp__";
40
- /** SSE 事件流路径 */
40
+ /** SSE 事件流路径(客户端订阅 SESSION_EVENT 等) */
41
41
  export declare const SSE_EVENTS_PATH = "/__aipanel_events__";
42
+ /** 宿主侧事件推送 API 路径(dsh-plugin 等 Host 插件把归一化 ProviderEvent POST 到这里,core 再广播给 SSE 客户端) */
43
+ export declare const HOST_EVENTS_API_PATH = "/__aipanel_host_events__";
42
44
  /** 上下文更新间隔(毫秒) */
43
45
  export declare const CONTEXT_UPDATE_INTERVAL = 500;
44
46
  /** 服务器同步间隔(毫秒) */
@@ -54,6 +56,8 @@ export declare const NOTIFICATION_DURATION = 3000;
54
56
  export declare const INIT_MARKER = "__AIPANEL_INITIALIZED__";
55
57
  /** 选中元素存储键 */
56
58
  export declare const SELECTED_ELEMENTS_KEY = "__aipanel_selected_elements__";
59
+ /** 页面会话标识键(sessionStorage,跨导航标识同一 Tab 的页面上下文) */
60
+ export declare const SESSION_ID_KEY = "_aipanel_pk";
57
61
  /** ==================== 缓存目录 ==================== */
58
62
  /**
59
63
  * AIPanel 项目级资源/缓存目录(相对于项目根目录,各 Provider 统一使用)。
@@ -81,6 +85,8 @@ export declare const EXT_MSG: {
81
85
  readonly SELECTION_START: "SELECTION_START";
82
86
  readonly SELECTION_STOP: "SELECTION_STOP";
83
87
  readonly CS_QUERY_WINDOW: "__CS_QUERY_WINDOW__";
88
+ /** Side Panel → Background:立即轮询一次并回传当前服务信息 */
89
+ readonly FORCE_POLL: "FORCE_POLL";
84
90
  readonly PAGE_CONTEXT: "PAGE_CONTEXT";
85
91
  readonly THEME_CHANGE: "THEME_CHANGE";
86
92
  readonly SERVICE_APPEARED: "SERVICE_APPEARED";
@@ -135,6 +141,10 @@ export declare const SEVERITY_WARN = 2;
135
141
  /** ==================== VS Code 扩展桥接 ==================== */
136
142
  /** VS Code 扩展 HTTP 服务端口(vscode-extension ↔ provider 通信协议) */
137
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";
138
148
  /** VS Code 扩展相关环境变量名 */
139
149
  export declare const ENV_VSCODE_MODE = "AIPANEL_VSCODE_MODE";
140
150
  export declare const ENV_VSCODE_PORT = "AIPANEL_VSCODE_PORT";
@@ -14,6 +14,7 @@ const START_API_PATH = "/__aipanel_start__";
14
14
  const SESSIONS_API_PATH = "/__aipanel_sessions__";
15
15
  const MCP_API_PATH = "/__aipanel_mcp__";
16
16
  const SSE_EVENTS_PATH = "/__aipanel_events__";
17
+ const HOST_EVENTS_API_PATH = "/__aipanel_host_events__";
17
18
  const CONTEXT_UPDATE_INTERVAL = 500;
18
19
  const SERVER_SYNC_INTERVAL = 2e3;
19
20
  const INSPECTOR_CHECK_INTERVAL = 500;
@@ -21,6 +22,7 @@ const AUTO_OPEN_DELAY = 1e3;
21
22
  const NOTIFICATION_DURATION = 3e3;
22
23
  const INIT_MARKER = "__AIPANEL_INITIALIZED__";
23
24
  const SELECTED_ELEMENTS_KEY = "__aipanel_selected_elements__";
25
+ const SESSION_ID_KEY = "_aipanel_pk";
24
26
  const AIPANEL_CACHE_DIR = "node_modules/.cache/aipanel";
25
27
  const CHROME_DEVTOOLS_PORT = 9222;
26
28
  const CHROME_DEVTOOLS_CHECK_TIMEOUT = 2e3;
@@ -37,7 +39,9 @@ const EXT_MSG = {
37
39
  REQUEST_PAGE_CONTEXT: "REQUEST_PAGE_CONTEXT",
38
40
  SELECTION_START: "SELECTION_START",
39
41
  SELECTION_STOP: "SELECTION_STOP",
40
- CS_QUERY_WINDOW: "__CS_QUERY_WINDOW__"
42
+ CS_QUERY_WINDOW: "__CS_QUERY_WINDOW__",
43
+ /** Side Panel → Background:立即轮询一次并回传当前服务信息 */
44
+ FORCE_POLL: "FORCE_POLL"
41
45
  };
42
46
  const WIDGET_MSG = {
43
47
  READY: "AIPANEL_READY",
@@ -69,6 +73,8 @@ const PAGE_CONTEXT_MAX_TEXT_LENGTH = 1e4;
69
73
  const SEVERITY_ERROR = 1;
70
74
  const SEVERITY_WARN = 2;
71
75
  const VSCODE_EXTENSION_PORT = 51939;
76
+ const VSCODE_ROUTE_HEALTH = "/health";
77
+ const VSCODE_ROUTE_FORMAT = "/format";
72
78
  const ENV_VSCODE_MODE = "AIPANEL_VSCODE_MODE";
73
79
  const ENV_VSCODE_PORT = "AIPANEL_VSCODE_PORT";
74
80
  const VUE_DEVTOOLS_ACTIONS = {
@@ -97,6 +103,7 @@ export {
97
103
  ENV_VSCODE_PORT,
98
104
  EXT_BROADCAST,
99
105
  EXT_MSG,
106
+ HOST_EVENTS_API_PATH,
100
107
  INIT_MARKER,
101
108
  INSPECTOR_CHECK_INTERVAL,
102
109
  LOGS_API_PATH,
@@ -113,11 +120,14 @@ export {
113
120
  SERVER_START_TIMEOUT,
114
121
  SERVER_SYNC_INTERVAL,
115
122
  SESSIONS_API_PATH,
123
+ SESSION_ID_KEY,
116
124
  SEVERITY_ERROR,
117
125
  SEVERITY_WARN,
118
126
  SSE_EVENTS_PATH,
119
127
  START_API_PATH,
120
128
  VSCODE_EXTENSION_PORT,
129
+ VSCODE_ROUTE_FORMAT,
130
+ VSCODE_ROUTE_HEALTH,
121
131
  VUE_DEVTOOLS_ACTIONS,
122
132
  WARMUP_API_PATH,
123
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
  /** 分屏模式配置 */
@@ -74,6 +74,12 @@ export interface ProviderStartOptions {
74
74
  logsApiUrl?: string;
75
75
  /** Vue DevTools API 地址(核心层提供的回连地址) */
76
76
  vueDevtoolsApiUrl?: string;
77
+ /**
78
+ * 宿主事件推送令牌(核心层每轮启动随机生成,透传给 Host 侧插件)。
79
+ * dsh-plugin 监听宿主事件(session/event 总线)时须携带该令牌 POST 到 HOST_EVENTS_API_PATH,
80
+ * core 校验通过后按 SESSION_EVENT 广播给 SSE 客户端。无该能力/无需求的 Provider 忽略即可。
81
+ */
82
+ eventsToken?: string;
77
83
  /** 启用 verbose 模式 */
78
84
  verbose?: boolean;
79
85
  }
@@ -99,6 +105,12 @@ export interface ProviderStartResult {
99
105
  url: string;
100
106
  /** 进程句柄(供编排层做就绪等待与退出检测,不透明) */
101
107
  processHandle?: unknown;
108
+ /**
109
+ * 对 Provider Web 服务做浏览器会话认证所需的 Cookie(可选)。
110
+ * dsh web 升级后在索引页与 /api 上强制 browser-session 认证(launch token → 签名 cookie),
111
+ * 代理需在转发请求时注入该 Cookie 才能通过 401 门禁。opencode 等无需认证的 Provider 不设置。
112
+ */
113
+ webAuthCookie?: string;
102
114
  }
103
115
  /** Provider 初始化配置(主题/语言/设置等,schema 由 Provider 定义) */
104
116
  export interface ProviderConfig {
@@ -142,8 +154,12 @@ export interface WebProvider {
142
154
  stop(): Promise<void>;
143
155
  /** 清理孤儿进程(上次退出残留的 provider 进程),返回清理数量(可选) */
144
156
  killOrphans?(): Promise<number>;
145
- /** 会话管理(归一化到 ChatSession,过滤逻辑在此内部完成) */
146
- listSessions(projectDir: string): Promise<ChatSession[]>;
157
+ /**
158
+ * 会话管理(归一化到 ChatSession,过滤逻辑在此内部完成)。
159
+ * @param activeSessionId 当前选中会话 id(可选):用于对齐 dsh 等 UI 的可见性规则
160
+ * (blank 会话仅当其为当前选中会话时展示)。无选中态概念的 Provider 忽略即可。
161
+ */
162
+ listSessions(projectDir: string, activeSessionId?: string): Promise<ChatSession[]>;
147
163
  createSession(projectDir: string, title?: string): Promise<ChatSession>;
148
164
  /** 可选:部分 Provider 无删除语义;core 不支持时隐藏删除入口 */
149
165
  deleteSession?(sessionId: string): Promise<void>;
@@ -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;
@@ -28,7 +28,10 @@ export declare class RequestContext {
28
28
  path: string;
29
29
  startTime: number;
30
30
  private checkpoints;
31
- constructor(method: string, path: string);
31
+ private quiet;
32
+ constructor(method: string, path: string, options?: {
33
+ quiet?: boolean;
34
+ });
32
35
  checkpoint(label: string): void;
33
36
  end(statusCode: number): void;
34
37
  error(error: Error | 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",
@@ -168,25 +168,32 @@ class PerformanceTimer {
168
168
  }
169
169
  }
170
170
  class RequestContext {
171
- constructor(method, path) {
171
+ constructor(method, path, options) {
172
172
  __publicField(this, "traceId");
173
173
  __publicField(this, "method");
174
174
  __publicField(this, "path");
175
175
  __publicField(this, "startTime");
176
176
  __publicField(this, "checkpoints", []);
177
+ __publicField(this, "quiet");
177
178
  this.traceId = _generateTraceId();
178
179
  this.method = method;
179
180
  this.path = path;
181
+ this.quiet = options?.quiet ?? false;
180
182
  this.startTime = performance.now();
181
- nodeLogger.debug(`\u2192 ${method} ${path}`, { traceId: this.traceId, module: "HTTP" });
183
+ if (!this.quiet) {
184
+ nodeLogger.debug(`\u2192 ${method} ${path}`, { traceId: this.traceId, module: "HTTP" });
185
+ }
182
186
  }
183
187
  checkpoint(label) {
184
188
  const elapsed = Math.round(performance.now() - this.startTime);
185
189
  this.checkpoints.push({ time: elapsed, label });
186
- nodeLogger.debug(` \u2192 ${label}`, { traceId: this.traceId, duration: elapsed });
190
+ if (!this.quiet) {
191
+ nodeLogger.debug(` \u2192 ${label}`, { traceId: this.traceId, duration: elapsed });
192
+ }
187
193
  }
188
194
  end(statusCode) {
189
195
  const duration = Math.round(performance.now() - this.startTime);
196
+ if (this.quiet) return;
190
197
  const statusColor = statusCode < 400 ? COLORS.green : COLORS.red;
191
198
  nodeLogger.debug(`\u2190 ${this.method} ${this.path} ${statusColor}${statusCode}${COLORS.reset}`, {
192
199
  traceId: this.traceId,
@@ -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";
@@ -34,6 +34,7 @@ __export(constants_exports, {
34
34
  ENV_VSCODE_PORT: () => ENV_VSCODE_PORT,
35
35
  EXT_BROADCAST: () => EXT_BROADCAST,
36
36
  EXT_MSG: () => EXT_MSG,
37
+ HOST_EVENTS_API_PATH: () => HOST_EVENTS_API_PATH,
37
38
  INIT_MARKER: () => INIT_MARKER,
38
39
  INSPECTOR_CHECK_INTERVAL: () => INSPECTOR_CHECK_INTERVAL,
39
40
  LOGS_API_PATH: () => LOGS_API_PATH,
@@ -50,11 +51,14 @@ __export(constants_exports, {
50
51
  SERVER_START_TIMEOUT: () => SERVER_START_TIMEOUT,
51
52
  SERVER_SYNC_INTERVAL: () => SERVER_SYNC_INTERVAL,
52
53
  SESSIONS_API_PATH: () => SESSIONS_API_PATH,
54
+ SESSION_ID_KEY: () => SESSION_ID_KEY,
53
55
  SEVERITY_ERROR: () => SEVERITY_ERROR,
54
56
  SEVERITY_WARN: () => SEVERITY_WARN,
55
57
  SSE_EVENTS_PATH: () => SSE_EVENTS_PATH,
56
58
  START_API_PATH: () => START_API_PATH,
57
59
  VSCODE_EXTENSION_PORT: () => VSCODE_EXTENSION_PORT,
60
+ VSCODE_ROUTE_FORMAT: () => VSCODE_ROUTE_FORMAT,
61
+ VSCODE_ROUTE_HEALTH: () => VSCODE_ROUTE_HEALTH,
58
62
  VUE_DEVTOOLS_ACTIONS: () => VUE_DEVTOOLS_ACTIONS,
59
63
  WARMUP_API_PATH: () => WARMUP_API_PATH,
60
64
  WIDGET_MSG: () => WIDGET_MSG,
@@ -78,6 +82,7 @@ const START_API_PATH = "/__aipanel_start__";
78
82
  const SESSIONS_API_PATH = "/__aipanel_sessions__";
79
83
  const MCP_API_PATH = "/__aipanel_mcp__";
80
84
  const SSE_EVENTS_PATH = "/__aipanel_events__";
85
+ const HOST_EVENTS_API_PATH = "/__aipanel_host_events__";
81
86
  const CONTEXT_UPDATE_INTERVAL = 500;
82
87
  const SERVER_SYNC_INTERVAL = 2e3;
83
88
  const INSPECTOR_CHECK_INTERVAL = 500;
@@ -85,6 +90,7 @@ const AUTO_OPEN_DELAY = 1e3;
85
90
  const NOTIFICATION_DURATION = 3e3;
86
91
  const INIT_MARKER = "__AIPANEL_INITIALIZED__";
87
92
  const SELECTED_ELEMENTS_KEY = "__aipanel_selected_elements__";
93
+ const SESSION_ID_KEY = "_aipanel_pk";
88
94
  const AIPANEL_CACHE_DIR = "node_modules/.cache/aipanel";
89
95
  const CHROME_DEVTOOLS_PORT = 9222;
90
96
  const CHROME_DEVTOOLS_CHECK_TIMEOUT = 2e3;
@@ -101,7 +107,9 @@ const EXT_MSG = {
101
107
  REQUEST_PAGE_CONTEXT: "REQUEST_PAGE_CONTEXT",
102
108
  SELECTION_START: "SELECTION_START",
103
109
  SELECTION_STOP: "SELECTION_STOP",
104
- CS_QUERY_WINDOW: "__CS_QUERY_WINDOW__"
110
+ CS_QUERY_WINDOW: "__CS_QUERY_WINDOW__",
111
+ /** Side Panel → Background:立即轮询一次并回传当前服务信息 */
112
+ FORCE_POLL: "FORCE_POLL"
105
113
  };
106
114
  const WIDGET_MSG = {
107
115
  READY: "AIPANEL_READY",
@@ -133,6 +141,8 @@ const PAGE_CONTEXT_MAX_TEXT_LENGTH = 1e4;
133
141
  const SEVERITY_ERROR = 1;
134
142
  const SEVERITY_WARN = 2;
135
143
  const VSCODE_EXTENSION_PORT = 51939;
144
+ const VSCODE_ROUTE_HEALTH = "/health";
145
+ const VSCODE_ROUTE_FORMAT = "/format";
136
146
  const ENV_VSCODE_MODE = "AIPANEL_VSCODE_MODE";
137
147
  const ENV_VSCODE_PORT = "AIPANEL_VSCODE_PORT";
138
148
  const VUE_DEVTOOLS_ACTIONS = {
@@ -162,6 +172,7 @@ const VUE_DEVTOOLS_ACTIONS = {
162
172
  ENV_VSCODE_PORT,
163
173
  EXT_BROADCAST,
164
174
  EXT_MSG,
175
+ HOST_EVENTS_API_PATH,
165
176
  INIT_MARKER,
166
177
  INSPECTOR_CHECK_INTERVAL,
167
178
  LOGS_API_PATH,
@@ -178,11 +189,14 @@ const VUE_DEVTOOLS_ACTIONS = {
178
189
  SERVER_START_TIMEOUT,
179
190
  SERVER_SYNC_INTERVAL,
180
191
  SESSIONS_API_PATH,
192
+ SESSION_ID_KEY,
181
193
  SEVERITY_ERROR,
182
194
  SEVERITY_WARN,
183
195
  SSE_EVENTS_PATH,
184
196
  START_API_PATH,
185
197
  VSCODE_EXTENSION_PORT,
198
+ VSCODE_ROUTE_FORMAT,
199
+ VSCODE_ROUTE_HEALTH,
186
200
  VUE_DEVTOOLS_ACTIONS,
187
201
  WARMUP_API_PATH,
188
202
  WIDGET_MSG,
@@ -37,8 +37,10 @@ export declare const START_API_PATH = "/__aipanel_start__";
37
37
  export declare const SESSIONS_API_PATH = "/__aipanel_sessions__";
38
38
  /** MCP 代理 API 路径 */
39
39
  export declare const MCP_API_PATH = "/__aipanel_mcp__";
40
- /** SSE 事件流路径 */
40
+ /** SSE 事件流路径(客户端订阅 SESSION_EVENT 等) */
41
41
  export declare const SSE_EVENTS_PATH = "/__aipanel_events__";
42
+ /** 宿主侧事件推送 API 路径(dsh-plugin 等 Host 插件把归一化 ProviderEvent POST 到这里,core 再广播给 SSE 客户端) */
43
+ export declare const HOST_EVENTS_API_PATH = "/__aipanel_host_events__";
42
44
  /** 上下文更新间隔(毫秒) */
43
45
  export declare const CONTEXT_UPDATE_INTERVAL = 500;
44
46
  /** 服务器同步间隔(毫秒) */
@@ -54,6 +56,8 @@ export declare const NOTIFICATION_DURATION = 3000;
54
56
  export declare const INIT_MARKER = "__AIPANEL_INITIALIZED__";
55
57
  /** 选中元素存储键 */
56
58
  export declare const SELECTED_ELEMENTS_KEY = "__aipanel_selected_elements__";
59
+ /** 页面会话标识键(sessionStorage,跨导航标识同一 Tab 的页面上下文) */
60
+ export declare const SESSION_ID_KEY = "_aipanel_pk";
57
61
  /** ==================== 缓存目录 ==================== */
58
62
  /**
59
63
  * AIPanel 项目级资源/缓存目录(相对于项目根目录,各 Provider 统一使用)。
@@ -81,6 +85,8 @@ export declare const EXT_MSG: {
81
85
  readonly SELECTION_START: "SELECTION_START";
82
86
  readonly SELECTION_STOP: "SELECTION_STOP";
83
87
  readonly CS_QUERY_WINDOW: "__CS_QUERY_WINDOW__";
88
+ /** Side Panel → Background:立即轮询一次并回传当前服务信息 */
89
+ readonly FORCE_POLL: "FORCE_POLL";
84
90
  readonly PAGE_CONTEXT: "PAGE_CONTEXT";
85
91
  readonly THEME_CHANGE: "THEME_CHANGE";
86
92
  readonly SERVICE_APPEARED: "SERVICE_APPEARED";
@@ -135,6 +141,10 @@ export declare const SEVERITY_WARN = 2;
135
141
  /** ==================== VS Code 扩展桥接 ==================== */
136
142
  /** VS Code 扩展 HTTP 服务端口(vscode-extension ↔ provider 通信协议) */
137
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";
138
148
  /** VS Code 扩展相关环境变量名 */
139
149
  export declare const ENV_VSCODE_MODE = "AIPANEL_VSCODE_MODE";
140
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
  /** 分屏模式配置 */
@@ -74,6 +74,12 @@ export interface ProviderStartOptions {
74
74
  logsApiUrl?: string;
75
75
  /** Vue DevTools API 地址(核心层提供的回连地址) */
76
76
  vueDevtoolsApiUrl?: string;
77
+ /**
78
+ * 宿主事件推送令牌(核心层每轮启动随机生成,透传给 Host 侧插件)。
79
+ * dsh-plugin 监听宿主事件(session/event 总线)时须携带该令牌 POST 到 HOST_EVENTS_API_PATH,
80
+ * core 校验通过后按 SESSION_EVENT 广播给 SSE 客户端。无该能力/无需求的 Provider 忽略即可。
81
+ */
82
+ eventsToken?: string;
77
83
  /** 启用 verbose 模式 */
78
84
  verbose?: boolean;
79
85
  }
@@ -99,6 +105,12 @@ export interface ProviderStartResult {
99
105
  url: string;
100
106
  /** 进程句柄(供编排层做就绪等待与退出检测,不透明) */
101
107
  processHandle?: unknown;
108
+ /**
109
+ * 对 Provider Web 服务做浏览器会话认证所需的 Cookie(可选)。
110
+ * dsh web 升级后在索引页与 /api 上强制 browser-session 认证(launch token → 签名 cookie),
111
+ * 代理需在转发请求时注入该 Cookie 才能通过 401 门禁。opencode 等无需认证的 Provider 不设置。
112
+ */
113
+ webAuthCookie?: string;
102
114
  }
103
115
  /** Provider 初始化配置(主题/语言/设置等,schema 由 Provider 定义) */
104
116
  export interface ProviderConfig {
@@ -142,8 +154,12 @@ export interface WebProvider {
142
154
  stop(): Promise<void>;
143
155
  /** 清理孤儿进程(上次退出残留的 provider 进程),返回清理数量(可选) */
144
156
  killOrphans?(): Promise<number>;
145
- /** 会话管理(归一化到 ChatSession,过滤逻辑在此内部完成) */
146
- listSessions(projectDir: string): Promise<ChatSession[]>;
157
+ /**
158
+ * 会话管理(归一化到 ChatSession,过滤逻辑在此内部完成)。
159
+ * @param activeSessionId 当前选中会话 id(可选):用于对齐 dsh 等 UI 的可见性规则
160
+ * (blank 会话仅当其为当前选中会话时展示)。无选中态概念的 Provider 忽略即可。
161
+ */
162
+ listSessions(projectDir: string, activeSessionId?: string): Promise<ChatSession[]>;
147
163
  createSession(projectDir: string, title?: string): Promise<ChatSession>;
148
164
  /** 可选:部分 Provider 无删除语义;core 不支持时隐藏删除入口 */
149
165
  deleteSession?(sessionId: string): Promise<void>;
@@ -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",
@@ -189,25 +189,32 @@ class PerformanceTimer {
189
189
  }
190
190
  }
191
191
  class RequestContext {
192
- constructor(method, path) {
192
+ constructor(method, path, options) {
193
193
  __publicField(this, "traceId");
194
194
  __publicField(this, "method");
195
195
  __publicField(this, "path");
196
196
  __publicField(this, "startTime");
197
197
  __publicField(this, "checkpoints", []);
198
+ __publicField(this, "quiet");
198
199
  this.traceId = (0, import_logger_core.generateTraceId)();
199
200
  this.method = method;
200
201
  this.path = path;
202
+ this.quiet = options?.quiet ?? false;
201
203
  this.startTime = performance.now();
202
- nodeLogger.debug(`\u2192 ${method} ${path}`, { traceId: this.traceId, module: "HTTP" });
204
+ if (!this.quiet) {
205
+ nodeLogger.debug(`\u2192 ${method} ${path}`, { traceId: this.traceId, module: "HTTP" });
206
+ }
203
207
  }
204
208
  checkpoint(label) {
205
209
  const elapsed = Math.round(performance.now() - this.startTime);
206
210
  this.checkpoints.push({ time: elapsed, label });
207
- nodeLogger.debug(` \u2192 ${label}`, { traceId: this.traceId, duration: elapsed });
211
+ if (!this.quiet) {
212
+ nodeLogger.debug(` \u2192 ${label}`, { traceId: this.traceId, duration: elapsed });
213
+ }
208
214
  }
209
215
  end(statusCode) {
210
216
  const duration = Math.round(performance.now() - this.startTime);
217
+ if (this.quiet) return;
211
218
  const statusColor = statusCode < 400 ? COLORS.green : COLORS.red;
212
219
  nodeLogger.debug(`\u2190 ${this.method} ${this.path} ${statusColor}${statusCode}${COLORS.reset}`, {
213
220
  traceId: this.traceId,
@@ -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;
@@ -28,7 +28,10 @@ export declare class RequestContext {
28
28
  path: string;
29
29
  startTime: number;
30
30
  private checkpoints;
31
- constructor(method: string, path: string);
31
+ private quiet;
32
+ constructor(method: string, path: string, options?: {
33
+ quiet?: boolean;
34
+ });
32
35
  checkpoint(label: string): void;
33
36
  end(statusCode: number): void;
34
37
  error(error: Error | 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.7",
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