proofscan 0.10.62 → 0.11.1
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/README.ja.md +1 -0
- package/README.md +2 -0
- package/dist/a2a/agent-card.d.ts +2 -0
- package/dist/a2a/agent-card.d.ts.map +1 -1
- package/dist/a2a/agent-card.js +2 -2
- package/dist/a2a/agent-card.js.map +1 -1
- package/dist/a2a/client.d.ts +74 -12
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +228 -29
- package/dist/a2a/client.js.map +1 -1
- package/dist/a2a/normalizer.d.ts +4 -0
- package/dist/a2a/normalizer.d.ts.map +1 -1
- package/dist/a2a/normalizer.js +7 -4
- package/dist/a2a/normalizer.js.map +1 -1
- package/dist/a2a/session-manager.d.ts +81 -0
- package/dist/a2a/session-manager.d.ts.map +1 -0
- package/dist/a2a/session-manager.js +176 -0
- package/dist/a2a/session-manager.js.map +1 -0
- package/dist/a2a/types.d.ts +60 -0
- package/dist/a2a/types.d.ts.map +1 -1
- package/dist/cli.d.ts +2 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +6 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/commands/agent.js +35 -10
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/analyze.d.ts.map +1 -1
- package/dist/commands/analyze.js +12 -10
- package/dist/commands/analyze.js.map +1 -1
- package/dist/commands/connectors.js +2 -2
- package/dist/commands/connectors.js.map +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +1 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/plans.js +1 -1
- package/dist/commands/plans.js.map +1 -1
- package/dist/commands/record.js +5 -4
- package/dist/commands/record.js.map +1 -1
- package/dist/commands/rpc.d.ts.map +1 -1
- package/dist/commands/rpc.js +90 -28
- package/dist/commands/rpc.js.map +1 -1
- package/dist/commands/scan.d.ts.map +1 -1
- package/dist/commands/scan.js +8 -10
- package/dist/commands/scan.js.map +1 -1
- package/dist/commands/secrets.d.ts.map +1 -1
- package/dist/commands/secrets.js +11 -10
- package/dist/commands/secrets.js.map +1 -1
- package/dist/commands/sessions.js +2 -2
- package/dist/commands/sessions.js.map +1 -1
- package/dist/commands/summary.d.ts.map +1 -1
- package/dist/commands/summary.js +4 -2
- package/dist/commands/summary.js.map +1 -1
- package/dist/commands/task.d.ts +14 -0
- package/dist/commands/task.d.ts.map +1 -0
- package/dist/commands/task.js +520 -0
- package/dist/commands/task.js.map +1 -0
- package/dist/db/connection.d.ts.map +1 -1
- package/dist/db/connection.js +68 -21
- package/dist/db/connection.js.map +1 -1
- package/dist/db/events-store.d.ts +307 -8
- package/dist/db/events-store.d.ts.map +1 -1
- package/dist/db/events-store.js +620 -26
- package/dist/db/events-store.js.map +1 -1
- package/dist/db/proofs-store.d.ts +8 -1
- package/dist/db/proofs-store.d.ts.map +1 -1
- package/dist/db/proofs-store.js +18 -8
- package/dist/db/proofs-store.js.map +1 -1
- package/dist/db/schema.d.ts +15 -3
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +150 -5
- package/dist/db/schema.js.map +1 -1
- package/dist/db/tool-analysis.d.ts +15 -3
- package/dist/db/tool-analysis.d.ts.map +1 -1
- package/dist/db/tool-analysis.js +35 -17
- package/dist/db/tool-analysis.js.map +1 -1
- package/dist/db/types.d.ts +64 -1
- package/dist/db/types.d.ts.map +1 -1
- package/dist/filter/fields.d.ts.map +1 -1
- package/dist/filter/fields.js +22 -0
- package/dist/filter/fields.js.map +1 -1
- package/dist/filter/parser.js +2 -2
- package/dist/filter/parser.js.map +1 -1
- package/dist/filter/types.d.ts +1 -1
- package/dist/filter/types.d.ts.map +1 -1
- package/dist/html/analytics.test.ts +682 -0
- package/dist/html/analytics.ts +499 -0
- package/dist/html/browser.ts +39 -0
- package/dist/html/index.ts +97 -0
- package/dist/html/rpc-inspector.test.ts +529 -0
- package/dist/html/rpc-inspector.ts +1700 -0
- package/dist/html/templates.js +4 -4
- package/dist/html/templates.js.map +1 -1
- package/dist/html/templates.test.ts +861 -0
- package/dist/html/templates.ts +3163 -0
- package/dist/html/trace-viewer.html +624 -0
- package/dist/html/types.d.ts +3 -3
- package/dist/html/types.d.ts.map +1 -1
- package/dist/html/types.ts +491 -0
- package/dist/html/utils.ts +107 -0
- package/dist/monitor/data/connectors.d.ts.map +1 -1
- package/dist/monitor/data/connectors.js +113 -8
- package/dist/monitor/data/connectors.js.map +1 -1
- package/dist/monitor/data/popl.js +2 -2
- package/dist/monitor/data/popl.js.map +1 -1
- package/dist/monitor/routes/api.js +2 -2
- package/dist/monitor/routes/api.js.map +1 -1
- package/dist/monitor/routes/connectors.js +15 -15
- package/dist/monitor/routes/connectors.js.map +1 -1
- package/dist/monitor/routes/popl.js +5 -5
- package/dist/monitor/routes/popl.js.map +1 -1
- package/dist/monitor/templates/components.js +2 -2
- package/dist/monitor/templates/components.js.map +1 -1
- package/dist/monitor/templates/popl.js +4 -4
- package/dist/monitor/templates/popl.js.map +1 -1
- package/dist/monitor/types.d.ts +2 -2
- package/dist/monitor/types.d.ts.map +1 -1
- package/dist/proxy/bridge-utils.d.ts +41 -0
- package/dist/proxy/bridge-utils.d.ts.map +1 -0
- package/dist/proxy/bridge-utils.js +60 -0
- package/dist/proxy/bridge-utils.js.map +1 -0
- package/dist/proxy/ipc-client.d.ts.map +1 -1
- package/dist/proxy/ipc-client.js +1 -2
- package/dist/proxy/ipc-client.js.map +1 -1
- package/dist/proxy/ipc-server.d.ts.map +1 -1
- package/dist/proxy/ipc-server.js +4 -2
- package/dist/proxy/ipc-server.js.map +1 -1
- package/dist/proxy/mcp-server.d.ts +31 -0
- package/dist/proxy/mcp-server.d.ts.map +1 -1
- package/dist/proxy/mcp-server.js +393 -4
- package/dist/proxy/mcp-server.js.map +1 -1
- package/dist/proxy/types.d.ts +95 -0
- package/dist/proxy/types.d.ts.map +1 -1
- package/dist/secrets/management.d.ts +2 -2
- package/dist/secrets/management.d.ts.map +1 -1
- package/dist/secrets/management.js +7 -7
- package/dist/secrets/management.js.map +1 -1
- package/dist/shell/completer.d.ts.map +1 -1
- package/dist/shell/completer.js +16 -0
- package/dist/shell/completer.js.map +1 -1
- package/dist/shell/context-applicator.d.ts.map +1 -1
- package/dist/shell/context-applicator.js +32 -0
- package/dist/shell/context-applicator.js.map +1 -1
- package/dist/shell/filter-mappers.d.ts +5 -1
- package/dist/shell/filter-mappers.d.ts.map +1 -1
- package/dist/shell/filter-mappers.js +12 -0
- package/dist/shell/filter-mappers.js.map +1 -1
- package/dist/shell/find-command.js +13 -13
- package/dist/shell/find-command.js.map +1 -1
- package/dist/shell/inscribe-commands.js +5 -5
- package/dist/shell/inscribe-commands.js.map +1 -1
- package/dist/shell/pager/less-pager.d.ts +1 -1
- package/dist/shell/pager/less-pager.d.ts.map +1 -1
- package/dist/shell/pager/less-pager.js +5 -2
- package/dist/shell/pager/less-pager.js.map +1 -1
- package/dist/shell/pager/more-pager.d.ts +1 -1
- package/dist/shell/pager/more-pager.d.ts.map +1 -1
- package/dist/shell/pager/more-pager.js +3 -2
- package/dist/shell/pager/more-pager.js.map +1 -1
- package/dist/shell/pager/renderer.d.ts.map +1 -1
- package/dist/shell/pager/renderer.js +66 -15
- package/dist/shell/pager/renderer.js.map +1 -1
- package/dist/shell/pager/types.d.ts +5 -2
- package/dist/shell/pager/types.d.ts.map +1 -1
- package/dist/shell/pager/utils.d.ts +5 -2
- package/dist/shell/pager/utils.d.ts.map +1 -1
- package/dist/shell/pager/utils.js +14 -17
- package/dist/shell/pager/utils.js.map +1 -1
- package/dist/shell/pipeline-types.d.ts +12 -4
- package/dist/shell/pipeline-types.d.ts.map +1 -1
- package/dist/shell/ref-commands.js +7 -7
- package/dist/shell/ref-commands.js.map +1 -1
- package/dist/shell/ref-resolver.d.ts +15 -15
- package/dist/shell/ref-resolver.d.ts.map +1 -1
- package/dist/shell/ref-resolver.js +34 -20
- package/dist/shell/ref-resolver.js.map +1 -1
- package/dist/shell/repl.d.ts +25 -0
- package/dist/shell/repl.d.ts.map +1 -1
- package/dist/shell/repl.js +285 -51
- package/dist/shell/repl.js.map +1 -1
- package/dist/shell/router-commands.d.ts +30 -0
- package/dist/shell/router-commands.d.ts.map +1 -1
- package/dist/shell/router-commands.js +1011 -62
- package/dist/shell/router-commands.js.map +1 -1
- package/dist/shell/selector.d.ts +1 -1
- package/dist/shell/selector.d.ts.map +1 -1
- package/dist/shell/selector.js +1 -1
- package/dist/shell/selector.js.map +1 -1
- package/dist/shell/types.d.ts.map +1 -1
- package/dist/shell/types.js +3 -1
- package/dist/shell/types.js.map +1 -1
- package/dist/shell/where-command.d.ts.map +1 -1
- package/dist/shell/where-command.js +19 -3
- package/dist/shell/where-command.js.map +1 -1
- package/dist/utils/output.d.ts.map +1 -1
- package/dist/utils/output.js +7 -1
- package/dist/utils/output.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML Report Types (Phase 5.0)
|
|
3
|
+
*
|
|
4
|
+
* Data models for HTML export functionality.
|
|
5
|
+
* Supports RPC detail and Session reports with embedded JSON.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Schema version for HTML reports
|
|
10
|
+
*/
|
|
11
|
+
export const HTML_REPORT_SCHEMA_VERSION = 1;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Default embed limit for payload JSON (256KB)
|
|
15
|
+
*/
|
|
16
|
+
export const DEFAULT_EMBED_MAX_BYTES = 262144;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Preview length for truncated payloads
|
|
20
|
+
*/
|
|
21
|
+
export const TRUNCATION_PREVIEW_LENGTH = 4096;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Short ID length for display (e.g., session IDs, RPC IDs)
|
|
25
|
+
*/
|
|
26
|
+
export const SHORT_ID_LENGTH = 8;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Report metadata
|
|
30
|
+
*/
|
|
31
|
+
export interface HtmlReportMeta {
|
|
32
|
+
schemaVersion: number;
|
|
33
|
+
generatedAt: string; // ISO8601
|
|
34
|
+
generatedBy: string; // "proofscan v0.x.x"
|
|
35
|
+
redacted: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* RPC status values (uppercase for consistency)
|
|
40
|
+
*/
|
|
41
|
+
export type RpcStatus = 'OK' | 'ERR' | 'PENDING';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* HTML export options
|
|
45
|
+
*/
|
|
46
|
+
export interface HtmlExportOptions {
|
|
47
|
+
/** Output directory */
|
|
48
|
+
outDir: string;
|
|
49
|
+
/** Open in browser after export */
|
|
50
|
+
open: boolean;
|
|
51
|
+
/** Redact sensitive values */
|
|
52
|
+
redact: boolean;
|
|
53
|
+
/** Max bytes per payload before truncation */
|
|
54
|
+
embedMaxBytes: number;
|
|
55
|
+
/** Write oversized payloads to separate files */
|
|
56
|
+
spill: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Default export options
|
|
61
|
+
*/
|
|
62
|
+
export const DEFAULT_EXPORT_OPTIONS: HtmlExportOptions = {
|
|
63
|
+
outDir: './pfscan_reports',
|
|
64
|
+
open: false,
|
|
65
|
+
redact: false,
|
|
66
|
+
embedMaxBytes: DEFAULT_EMBED_MAX_BYTES,
|
|
67
|
+
spill: false,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* RPC payload with truncation support
|
|
72
|
+
*/
|
|
73
|
+
export interface PayloadData {
|
|
74
|
+
/** Full JSON (null if truncated) */
|
|
75
|
+
json: unknown | null;
|
|
76
|
+
/** Size in bytes */
|
|
77
|
+
size: number;
|
|
78
|
+
/** Whether payload was truncated */
|
|
79
|
+
truncated: boolean;
|
|
80
|
+
/** Preview string if truncated (first N chars) */
|
|
81
|
+
preview: string | null;
|
|
82
|
+
/** Relative path to spill file if --spill enabled */
|
|
83
|
+
spillFile?: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* RPC detail for HTML report
|
|
88
|
+
*/
|
|
89
|
+
export interface HtmlRpcData {
|
|
90
|
+
rpc_id: string;
|
|
91
|
+
session_id: string;
|
|
92
|
+
target_id: string;
|
|
93
|
+
method: string;
|
|
94
|
+
status: RpcStatus;
|
|
95
|
+
latency_ms: number | null;
|
|
96
|
+
error_code: number | null;
|
|
97
|
+
request_ts: string;
|
|
98
|
+
response_ts: string | null;
|
|
99
|
+
request: PayloadData;
|
|
100
|
+
response: PayloadData;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* RPC Report V1
|
|
105
|
+
*/
|
|
106
|
+
export interface HtmlRpcReportV1 {
|
|
107
|
+
meta: HtmlReportMeta;
|
|
108
|
+
rpc: HtmlRpcData;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Session RPC detail for table rows
|
|
113
|
+
*/
|
|
114
|
+
export interface SessionRpcDetail {
|
|
115
|
+
rpc_id: string;
|
|
116
|
+
method: string;
|
|
117
|
+
status: RpcStatus;
|
|
118
|
+
latency_ms: number | null;
|
|
119
|
+
request_ts: string;
|
|
120
|
+
response_ts: string | null;
|
|
121
|
+
error_code: number | null;
|
|
122
|
+
request: PayloadData;
|
|
123
|
+
response: PayloadData;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Session data for HTML report
|
|
128
|
+
*/
|
|
129
|
+
export interface HtmlSessionData {
|
|
130
|
+
session_id: string;
|
|
131
|
+
target_id: string;
|
|
132
|
+
started_at: string;
|
|
133
|
+
ended_at: string | null;
|
|
134
|
+
exit_reason: string | null;
|
|
135
|
+
rpc_count: number;
|
|
136
|
+
event_count: number;
|
|
137
|
+
/** Total latency across all RPCs in milliseconds */
|
|
138
|
+
total_latency_ms: number | null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Session Report V1
|
|
143
|
+
*/
|
|
144
|
+
export interface HtmlSessionReportV1 {
|
|
145
|
+
meta: HtmlReportMeta;
|
|
146
|
+
session: HtmlSessionData;
|
|
147
|
+
rpcs: SessionRpcDetail[];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Convert DB status to RpcStatus
|
|
152
|
+
*/
|
|
153
|
+
export function toRpcStatus(success: number | null): RpcStatus {
|
|
154
|
+
if (success === 1) return 'OK';
|
|
155
|
+
if (success === 0) return 'ERR';
|
|
156
|
+
return 'PENDING';
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Get status symbol for display
|
|
161
|
+
*/
|
|
162
|
+
export function getStatusSymbol(status: RpcStatus): string {
|
|
163
|
+
switch (status) {
|
|
164
|
+
case 'OK': return '✓';
|
|
165
|
+
case 'ERR': return '✗';
|
|
166
|
+
case 'PENDING': return '?';
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Create payload data with truncation handling
|
|
172
|
+
*/
|
|
173
|
+
export function createPayloadData(
|
|
174
|
+
json: unknown | null,
|
|
175
|
+
rawJson: string | null,
|
|
176
|
+
embedMaxBytes: number,
|
|
177
|
+
spillFile?: string
|
|
178
|
+
): PayloadData {
|
|
179
|
+
if (rawJson === null || json === null) {
|
|
180
|
+
return {
|
|
181
|
+
json: null,
|
|
182
|
+
size: 0,
|
|
183
|
+
truncated: false,
|
|
184
|
+
preview: null,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const size = Buffer.byteLength(rawJson, 'utf8');
|
|
189
|
+
const truncated = size > embedMaxBytes;
|
|
190
|
+
|
|
191
|
+
if (truncated) {
|
|
192
|
+
return {
|
|
193
|
+
json: null,
|
|
194
|
+
size,
|
|
195
|
+
truncated: true,
|
|
196
|
+
preview: rawJson.slice(0, TRUNCATION_PREVIEW_LENGTH),
|
|
197
|
+
spillFile,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
json,
|
|
203
|
+
size,
|
|
204
|
+
truncated: false,
|
|
205
|
+
preview: null,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Generate output filename for RPC HTML
|
|
211
|
+
*/
|
|
212
|
+
export function getRpcHtmlFilename(rpcId: string): string {
|
|
213
|
+
return `rpc_${rpcId}.html`;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Generate output filename for Session HTML
|
|
218
|
+
*/
|
|
219
|
+
export function getSessionHtmlFilename(sessionId: string): string {
|
|
220
|
+
const short = sessionId.slice(0, 8);
|
|
221
|
+
return `session_${short}.html`;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Generate spill filename for payload
|
|
226
|
+
*/
|
|
227
|
+
export function getSpillFilename(
|
|
228
|
+
sessionId: string,
|
|
229
|
+
rpcId: string,
|
|
230
|
+
type: 'req' | 'res'
|
|
231
|
+
): string {
|
|
232
|
+
const sessionShort = sessionId.slice(0, 8);
|
|
233
|
+
return `payload_${sessionShort}_${rpcId}_${type}.json`;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// ============================================================================
|
|
237
|
+
// Connector HTML Report Types (Phase 5.1)
|
|
238
|
+
// ============================================================================
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* MCP Server capabilities from initialize response
|
|
242
|
+
*/
|
|
243
|
+
export interface HtmlMcpCapabilities {
|
|
244
|
+
tools: boolean; // capabilities.tools is present
|
|
245
|
+
resources: boolean; // capabilities.resources is present
|
|
246
|
+
prompts: boolean; // capabilities.prompts is present
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* MCP Server info extracted from initialize response
|
|
251
|
+
*/
|
|
252
|
+
export interface HtmlMcpServerInfo {
|
|
253
|
+
name: string | null; // serverInfo.name from initialize response
|
|
254
|
+
version: string | null; // serverInfo.version
|
|
255
|
+
protocolVersion: string | null; // protocolVersion from initialize response
|
|
256
|
+
capabilities: HtmlMcpCapabilities; // supported capabilities
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Connector configuration info for HTML display
|
|
261
|
+
*/
|
|
262
|
+
export interface HtmlConnectorInfo {
|
|
263
|
+
target_id: string;
|
|
264
|
+
enabled: boolean;
|
|
265
|
+
transport: {
|
|
266
|
+
type: 'stdio' | 'rpc-http' | 'rpc-sse';
|
|
267
|
+
/** For stdio: command + args joined */
|
|
268
|
+
command?: string;
|
|
269
|
+
/** For http/sse: URL */
|
|
270
|
+
url?: string;
|
|
271
|
+
};
|
|
272
|
+
/** MCP server info from latest initialize response (if available) */
|
|
273
|
+
server?: HtmlMcpServerInfo;
|
|
274
|
+
/** Total session count in DB */
|
|
275
|
+
session_count: number;
|
|
276
|
+
/** Sessions included in this export */
|
|
277
|
+
displayed_sessions: number;
|
|
278
|
+
/** Pagination offset */
|
|
279
|
+
offset: number;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Connector session row for left pane list
|
|
284
|
+
*/
|
|
285
|
+
export interface HtmlConnectorSessionRow {
|
|
286
|
+
session_id: string;
|
|
287
|
+
short_id: string; // 8文字プレフィックス
|
|
288
|
+
started_at: string;
|
|
289
|
+
ended_at: string | null;
|
|
290
|
+
rpc_count: number;
|
|
291
|
+
event_count: number;
|
|
292
|
+
error_count: number; // For ERR badge (success=0 count)
|
|
293
|
+
total_latency_ms: number | null;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Connector Report V1 - embeds multiple session reports
|
|
298
|
+
*/
|
|
299
|
+
export interface HtmlConnectorReportV1 {
|
|
300
|
+
meta: HtmlReportMeta;
|
|
301
|
+
connector: HtmlConnectorInfo;
|
|
302
|
+
/** セッション一覧(左ペイン用) */
|
|
303
|
+
sessions: HtmlConnectorSessionRow[];
|
|
304
|
+
/** セッション詳細(右ペイン用)- session_id をキーとするマップ */
|
|
305
|
+
session_reports: Record<string, HtmlSessionReportV1>;
|
|
306
|
+
/** Analytics data (Phase 5.2) */
|
|
307
|
+
analytics: HtmlConnectorAnalyticsV1;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Generate output filename for Connector HTML
|
|
312
|
+
* Sanitizes connector ID (replaces non-alphanumeric with hyphen)
|
|
313
|
+
*/
|
|
314
|
+
export function getConnectorHtmlFilename(connectorId: string): string {
|
|
315
|
+
const sanitized = connectorId.replace(/[^a-zA-Z0-9-_]/g, '-');
|
|
316
|
+
return `connector_${sanitized}.html`;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// ============================================================================
|
|
320
|
+
// Connector HTML Analytics Types (Phase 5.2)
|
|
321
|
+
// ============================================================================
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Connector-level KPIs
|
|
325
|
+
*/
|
|
326
|
+
export interface HtmlConnectorKpis {
|
|
327
|
+
rpc_total: number;
|
|
328
|
+
rpc_ok: number;
|
|
329
|
+
rpc_err: number;
|
|
330
|
+
rpc_pending: number;
|
|
331
|
+
avg_latency_ms: number | null; // null if no RPCs with latency
|
|
332
|
+
p95_latency_ms: number | null; // null if < 20 samples (nearest-rank method)
|
|
333
|
+
max_latency_ms: number | null;
|
|
334
|
+
total_request_bytes: number;
|
|
335
|
+
total_response_bytes: number;
|
|
336
|
+
sessions_total: number;
|
|
337
|
+
sessions_displayed: number;
|
|
338
|
+
top_tool_name: string | null;
|
|
339
|
+
top_tool_calls: number | null;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Heatmap cell (GitHub contributions style)
|
|
344
|
+
*/
|
|
345
|
+
export interface HtmlHeatmapCell {
|
|
346
|
+
date: string; // YYYY-MM-DD (UTC)
|
|
347
|
+
count: number; // RPC count
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Heatmap data with intensity calculation
|
|
352
|
+
*/
|
|
353
|
+
export interface HtmlHeatmapData {
|
|
354
|
+
start_date: string;
|
|
355
|
+
end_date: string;
|
|
356
|
+
cells: HtmlHeatmapCell[]; // Full range including 0-count days
|
|
357
|
+
max_count: number; // For intensity scaling
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Latency histogram bucket
|
|
362
|
+
*/
|
|
363
|
+
export interface HtmlLatencyBucket {
|
|
364
|
+
label: string; // e.g., "0-10", "1000+"
|
|
365
|
+
from_ms: number;
|
|
366
|
+
to_ms: number | null; // null = +∞ (for "1000+" bucket)
|
|
367
|
+
count: number;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Latency histogram data
|
|
372
|
+
*/
|
|
373
|
+
export interface HtmlLatencyHistogram {
|
|
374
|
+
buckets: HtmlLatencyBucket[];
|
|
375
|
+
sample_size: number; // RPCs with latency_ms
|
|
376
|
+
excluded_count: number; // RPCs without latency_ms
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Method latency entry for bar chart (one bar per method)
|
|
381
|
+
*/
|
|
382
|
+
export interface HtmlMethodLatencyEntry {
|
|
383
|
+
method: string; // e.g., "initialize", "tools/list", "tools/call"
|
|
384
|
+
latencies: number[]; // All latency values for this method
|
|
385
|
+
min_ms: number | null;
|
|
386
|
+
max_ms: number | null;
|
|
387
|
+
avg_ms: number | null;
|
|
388
|
+
p50_ms: number | null; // Median
|
|
389
|
+
count: number; // Number of calls
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Method-based latency chart data (logarithmic Y-axis)
|
|
394
|
+
*/
|
|
395
|
+
export interface HtmlMethodLatencyData {
|
|
396
|
+
methods: HtmlMethodLatencyEntry[];
|
|
397
|
+
sample_size: number;
|
|
398
|
+
max_latency_ms: number; // For Y-axis scaling
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Top tool entry
|
|
403
|
+
*/
|
|
404
|
+
export interface HtmlTopTool {
|
|
405
|
+
name: string;
|
|
406
|
+
count: number;
|
|
407
|
+
pct: number; // 0-100
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Top tools data
|
|
412
|
+
*/
|
|
413
|
+
export interface HtmlTopToolsData {
|
|
414
|
+
items: HtmlTopTool[]; // Top 5
|
|
415
|
+
total_calls: number; // Total tools/call count
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Method distribution slice (for donut chart)
|
|
420
|
+
*/
|
|
421
|
+
export interface HtmlMethodSlice {
|
|
422
|
+
method: string;
|
|
423
|
+
count: number;
|
|
424
|
+
pct: number; // 0-100
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Method distribution data
|
|
429
|
+
*/
|
|
430
|
+
export interface HtmlMethodDistribution {
|
|
431
|
+
slices: HtmlMethodSlice[]; // Top 5 methods + "Others"
|
|
432
|
+
total_rpcs: number;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Complete analytics data
|
|
437
|
+
*/
|
|
438
|
+
export interface HtmlConnectorAnalyticsV1 {
|
|
439
|
+
kpis: HtmlConnectorKpis;
|
|
440
|
+
heatmap: HtmlHeatmapData;
|
|
441
|
+
latency: HtmlLatencyHistogram;
|
|
442
|
+
/** Method-based latency chart (X: methods, Y: log scale latency) */
|
|
443
|
+
method_latency: HtmlMethodLatencyData;
|
|
444
|
+
top_tools: HtmlTopToolsData;
|
|
445
|
+
method_distribution: HtmlMethodDistribution;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// ============================================================================
|
|
449
|
+
// RPC Inspector Types (Phase 11.5)
|
|
450
|
+
// ============================================================================
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* JSON Pointer target (request or response payload)
|
|
454
|
+
*/
|
|
455
|
+
export type JsonPointerTarget = 'request' | 'response';
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Pointer link for summary-to-raw navigation
|
|
459
|
+
*/
|
|
460
|
+
export interface JsonPointer {
|
|
461
|
+
target: JsonPointerTarget;
|
|
462
|
+
path: string; // JSON Pointer format, e.g., "#/result/tools/0/name"
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Summary row with optional pointer link
|
|
467
|
+
*/
|
|
468
|
+
export interface SummaryRow {
|
|
469
|
+
type: 'header' | 'property' | 'item';
|
|
470
|
+
label: string;
|
|
471
|
+
value?: string;
|
|
472
|
+
pointer?: JsonPointer;
|
|
473
|
+
children?: SummaryRow[];
|
|
474
|
+
cssClass?: string;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Method-specific summary renderer result
|
|
479
|
+
*/
|
|
480
|
+
export interface MethodSummary {
|
|
481
|
+
method: string;
|
|
482
|
+
rows: SummaryRow[];
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Method summary handler interface
|
|
487
|
+
*/
|
|
488
|
+
export interface MethodSummaryHandler {
|
|
489
|
+
method: string | RegExp;
|
|
490
|
+
render: (request: unknown, response: unknown) => SummaryRow[];
|
|
491
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML Export Utilities
|
|
3
|
+
*
|
|
4
|
+
* Shared utility functions for HTML export functionality.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as fs from 'fs';
|
|
8
|
+
import * as path from 'path';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
import { t } from '../i18n/index.js';
|
|
11
|
+
|
|
12
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get package version for HTML reports
|
|
16
|
+
*/
|
|
17
|
+
let _packageVersion: string = '';
|
|
18
|
+
export function getPackageVersion(): string {
|
|
19
|
+
if (_packageVersion) {
|
|
20
|
+
return _packageVersion;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const pkgPath = path.resolve(__dirname, '../../package.json');
|
|
24
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
25
|
+
_packageVersion = pkg.version || '0.0.0';
|
|
26
|
+
} catch {
|
|
27
|
+
_packageVersion = '0.0.0';
|
|
28
|
+
}
|
|
29
|
+
return _packageVersion;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Validate and sanitize output directory path
|
|
34
|
+
* Prevents path traversal attacks by ensuring the path doesn't escape CWD
|
|
35
|
+
*
|
|
36
|
+
* @param outDir - User-provided output directory
|
|
37
|
+
* @returns Resolved absolute path
|
|
38
|
+
* @throws Error if path is invalid or escapes current directory
|
|
39
|
+
*/
|
|
40
|
+
export function validateOutputPath(outDir: string): string {
|
|
41
|
+
const cwd = process.cwd();
|
|
42
|
+
const resolved = path.resolve(cwd, outDir);
|
|
43
|
+
const normalized = path.normalize(resolved);
|
|
44
|
+
|
|
45
|
+
// Ensure the path is within or equal to CWD
|
|
46
|
+
// Allow paths that start with CWD or are absolute paths explicitly provided
|
|
47
|
+
if (!normalized.startsWith(cwd) && !path.isAbsolute(outDir)) {
|
|
48
|
+
throw new Error(t('errors.pathEscapes'));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Check for suspicious patterns even in absolute paths
|
|
52
|
+
if (outDir.includes('..')) {
|
|
53
|
+
// If it contains '..' but still resolves within cwd, that's OK
|
|
54
|
+
// If it resolves outside, reject
|
|
55
|
+
if (!normalized.startsWith(cwd)) {
|
|
56
|
+
throw new Error(t('errors.pathEscapes'));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return normalized;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Validate embedMaxBytes option
|
|
65
|
+
*
|
|
66
|
+
* @param value - String value from CLI
|
|
67
|
+
* @returns Validated positive integer
|
|
68
|
+
* @throws Error if value is invalid
|
|
69
|
+
*/
|
|
70
|
+
export function validateEmbedMaxBytes(value: string): number {
|
|
71
|
+
const parsed = parseInt(value, 10);
|
|
72
|
+
if (isNaN(parsed) || parsed <= 0) {
|
|
73
|
+
throw new Error(t('errors.invalidEmbedMaxBytes', { value }));
|
|
74
|
+
}
|
|
75
|
+
return parsed;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Safely create output directory
|
|
80
|
+
*
|
|
81
|
+
* @param outDir - Output directory path (should be validated first)
|
|
82
|
+
*/
|
|
83
|
+
export function ensureOutputDir(outDir: string): void {
|
|
84
|
+
try {
|
|
85
|
+
if (!fs.existsSync(outDir)) {
|
|
86
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
87
|
+
}
|
|
88
|
+
} catch (error) {
|
|
89
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
90
|
+
throw new Error(t('errors.createDirFailed', { path: outDir, error: message }));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Safely write file with error handling
|
|
96
|
+
*
|
|
97
|
+
* @param filePath - Full path to write
|
|
98
|
+
* @param content - Content to write
|
|
99
|
+
*/
|
|
100
|
+
export function safeWriteFile(filePath: string, content: string): void {
|
|
101
|
+
try {
|
|
102
|
+
fs.writeFileSync(filePath, content, 'utf8');
|
|
103
|
+
} catch (error) {
|
|
104
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
105
|
+
throw new Error(t('errors.writeFileFailed', { path: filePath, error: message }));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectors.d.ts","sourceRoot":"","sources":["../../../src/monitor/data/connectors.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"connectors.d.ts","sourceRoot":"","sources":["../../../src/monitor/data/connectors.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EAMrB,MAAM,aAAa,CAAC;AAOrB;;GAEG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,eAAe,CAAC,CAuD1B;AA2cD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CA4BtC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,CAAC,CA8DzB"}
|