agent-dir 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -2
- package/dist/bin/agent-dir.d.ts +0 -1
- package/dist/bin/agent-dir.js +11 -4
- package/dist/src/auth.d.ts +0 -1
- package/dist/src/auth.js +0 -1
- package/dist/src/codegraph.d.ts +0 -1
- package/dist/src/codegraph.js +0 -1
- package/dist/src/config.d.ts +0 -1
- package/dist/src/config.js +0 -1
- package/dist/src/logging.d.ts +0 -1
- package/dist/src/logging.js +1 -2
- package/dist/src/mcp.d.ts +0 -1
- package/dist/src/mcp.js +11 -2
- package/dist/src/server.d.ts +0 -1
- package/dist/src/server.js +42 -2
- package/dist/src/setup.d.ts +0 -1
- package/dist/src/setup.js +4 -3
- package/dist/src/telemetry/aggregate.d.ts +7 -1
- package/dist/src/telemetry/aggregate.js +39 -3
- package/dist/src/telemetry/config.d.ts +0 -1
- package/dist/src/telemetry/config.js +0 -1
- package/dist/src/telemetry/format.d.ts +0 -1
- package/dist/src/telemetry/format.js +1 -2
- package/dist/src/telemetry/privacy.d.ts +0 -1
- package/dist/src/telemetry/privacy.js +76 -3
- package/dist/src/telemetry/recorder.d.ts +0 -1
- package/dist/src/telemetry/recorder.js +0 -1
- package/dist/src/telemetry/types.d.ts +28 -3
- package/dist/src/telemetry/types.js +1 -2
- package/dist/src/tools/code.d.ts +0 -1
- package/dist/src/tools/code.js +0 -1
- package/dist/src/tools/commands.d.ts +0 -1
- package/dist/src/tools/commands.js +0 -1
- package/dist/src/tools/diagnostics.d.ts +0 -1
- package/dist/src/tools/diagnostics.js +0 -1
- package/dist/src/tools/files.d.ts +0 -1
- package/dist/src/tools/files.js +0 -1
- package/dist/src/tools/git.d.ts +0 -1
- package/dist/src/tools/git.js +0 -1
- package/dist/src/tools/metadata.d.ts +0 -1
- package/dist/src/tools/metadata.js +0 -1
- package/dist/src/tools/npm.d.ts +0 -1
- package/dist/src/tools/npm.js +0 -1
- package/dist/src/tools/skills.d.ts +0 -1
- package/dist/src/tools/skills.js +0 -1
- package/dist/src/tunnel.d.ts +1 -2
- package/dist/src/tunnel.js +243 -83
- package/dist/src/types.d.ts +24 -1
- package/dist/src/types.js +0 -1
- package/package.json +6 -3
- package/dist/bin/agent-dir.d.ts.map +0 -1
- package/dist/bin/agent-dir.js.map +0 -1
- package/dist/src/auth.d.ts.map +0 -1
- package/dist/src/auth.js.map +0 -1
- package/dist/src/codegraph.d.ts.map +0 -1
- package/dist/src/codegraph.js.map +0 -1
- package/dist/src/config.d.ts.map +0 -1
- package/dist/src/config.js.map +0 -1
- package/dist/src/logging.d.ts.map +0 -1
- package/dist/src/logging.js.map +0 -1
- package/dist/src/mcp.d.ts.map +0 -1
- package/dist/src/mcp.js.map +0 -1
- package/dist/src/server.d.ts.map +0 -1
- package/dist/src/server.js.map +0 -1
- package/dist/src/setup.d.ts.map +0 -1
- package/dist/src/setup.js.map +0 -1
- package/dist/src/telemetry/aggregate.d.ts.map +0 -1
- package/dist/src/telemetry/aggregate.js.map +0 -1
- package/dist/src/telemetry/config.d.ts.map +0 -1
- package/dist/src/telemetry/config.js.map +0 -1
- package/dist/src/telemetry/format.d.ts.map +0 -1
- package/dist/src/telemetry/format.js.map +0 -1
- package/dist/src/telemetry/privacy.d.ts.map +0 -1
- package/dist/src/telemetry/privacy.js.map +0 -1
- package/dist/src/telemetry/recorder.d.ts.map +0 -1
- package/dist/src/telemetry/recorder.js.map +0 -1
- package/dist/src/telemetry/types.d.ts.map +0 -1
- package/dist/src/telemetry/types.js.map +0 -1
- package/dist/src/tools/code.d.ts.map +0 -1
- package/dist/src/tools/code.js.map +0 -1
- package/dist/src/tools/commands.d.ts.map +0 -1
- package/dist/src/tools/commands.js.map +0 -1
- package/dist/src/tools/diagnostics.d.ts.map +0 -1
- package/dist/src/tools/diagnostics.js.map +0 -1
- package/dist/src/tools/files.d.ts.map +0 -1
- package/dist/src/tools/files.js.map +0 -1
- package/dist/src/tools/git.d.ts.map +0 -1
- package/dist/src/tools/git.js.map +0 -1
- package/dist/src/tools/metadata.d.ts.map +0 -1
- package/dist/src/tools/metadata.js.map +0 -1
- package/dist/src/tools/npm.d.ts.map +0 -1
- package/dist/src/tools/npm.js.map +0 -1
- package/dist/src/tools/skills.d.ts.map +0 -1
- package/dist/src/tools/skills.js.map +0 -1
- package/dist/src/tunnel.d.ts.map +0 -1
- package/dist/src/tunnel.js.map +0 -1
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js.map +0 -1
|
@@ -14,6 +14,17 @@ const SAFE_TOOL_NAME = /^[a-z][a-z0-9_]*$/;
|
|
|
14
14
|
const SAFE_COMMAND_FAMILY = /^[a-z][a-z0-9_-]*$/;
|
|
15
15
|
const SAFE_OPERATION = /^[a-z][a-z0-9_.-]*$/;
|
|
16
16
|
export function sanitizeAnonymousEvent(event) {
|
|
17
|
+
if (event.event === "http_request") {
|
|
18
|
+
return {
|
|
19
|
+
event: "http_request",
|
|
20
|
+
method: sanitizeMcpMethod(event.method),
|
|
21
|
+
route: event.route,
|
|
22
|
+
status: boundedInteger(event.status),
|
|
23
|
+
success: event.success === true,
|
|
24
|
+
durationMs: boundedNumber(event.durationMs),
|
|
25
|
+
authenticated: event.authenticated === true,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
17
28
|
if (event.event === "mcp_request") {
|
|
18
29
|
return {
|
|
19
30
|
event: "mcp_request",
|
|
@@ -42,6 +53,18 @@ export function sanitizeAnonymousEvent(event) {
|
|
|
42
53
|
: { errorCategory: sanitizeErrorCategory(event.errorCategory) }),
|
|
43
54
|
};
|
|
44
55
|
}
|
|
56
|
+
if (event.event === "tunnel") {
|
|
57
|
+
return {
|
|
58
|
+
event: "tunnel",
|
|
59
|
+
state: event.state,
|
|
60
|
+
...(event.attempt === undefined ? {} : { attempt: boundedInteger(event.attempt) }),
|
|
61
|
+
...(event.attempts === undefined ? {} : { attempts: boundedInteger(event.attempts) }),
|
|
62
|
+
...(event.durationMs === undefined ? {} : { durationMs: boundedNumber(event.durationMs) }),
|
|
63
|
+
...(event.reasonCategory === undefined
|
|
64
|
+
? {}
|
|
65
|
+
: { reasonCategory: sanitizeErrorCategory(event.reasonCategory) }),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
45
68
|
if (event.event === "command_call") {
|
|
46
69
|
return {
|
|
47
70
|
event: "command_call",
|
|
@@ -76,15 +99,45 @@ export function createTelemetryEnvelope(level, event, runtime, project, configId
|
|
|
76
99
|
level,
|
|
77
100
|
event: sanitizeAnonymousEvent(event),
|
|
78
101
|
};
|
|
79
|
-
if (level === "basic" || level === "detailed") {
|
|
102
|
+
if (level === "basic" || level === "detailed" || level === "diagnostic") {
|
|
80
103
|
if (runtime)
|
|
81
104
|
envelope.runtime = sanitizeRuntimeContext(runtime);
|
|
82
105
|
}
|
|
83
|
-
if (level === "detailed" && project) {
|
|
106
|
+
if ((level === "detailed" || level === "diagnostic") && project) {
|
|
84
107
|
envelope.project = sanitizeProjectContext(project);
|
|
85
108
|
}
|
|
109
|
+
if (level === "diagnostic" && runtime) {
|
|
110
|
+
envelope.runtime = sanitizeDiagnosticRuntimeContext(runtime);
|
|
111
|
+
}
|
|
112
|
+
if (level === "diagnostic" && project) {
|
|
113
|
+
envelope.project = sanitizeDiagnosticProjectContext(project);
|
|
114
|
+
}
|
|
86
115
|
return envelope;
|
|
87
116
|
}
|
|
117
|
+
function sanitizeDiagnosticRuntimeContext(context) {
|
|
118
|
+
return {
|
|
119
|
+
...sanitizeRuntimeContext(context),
|
|
120
|
+
...(context.nodeVersion === undefined
|
|
121
|
+
? {}
|
|
122
|
+
: { nodeVersion: sanitizeVersion(context.nodeVersion) }),
|
|
123
|
+
...(context.hostname === undefined
|
|
124
|
+
? {}
|
|
125
|
+
: { hostname: sanitizeSensitiveIdentifier(context.hostname) }),
|
|
126
|
+
...(context.username === undefined
|
|
127
|
+
? {}
|
|
128
|
+
: { username: sanitizeSensitiveIdentifier(context.username) }),
|
|
129
|
+
...(context.processId === undefined ? {} : { processId: boundedInteger(context.processId) }),
|
|
130
|
+
...(context.parentProcessId === undefined
|
|
131
|
+
? {}
|
|
132
|
+
: { parentProcessId: boundedInteger(context.parentProcessId) }),
|
|
133
|
+
...(context.processUptimeMs === undefined
|
|
134
|
+
? {}
|
|
135
|
+
: { processUptimeMs: boundedNumber(context.processUptimeMs) }),
|
|
136
|
+
...(context.memoryRssBytes === undefined
|
|
137
|
+
? {}
|
|
138
|
+
: { memoryRssBytes: boundedNumber(context.memoryRssBytes) }),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
88
141
|
function sanitizeRuntimeContext(context) {
|
|
89
142
|
return {
|
|
90
143
|
agentDirVersion: sanitizeVersion(context.agentDirVersion),
|
|
@@ -99,6 +152,17 @@ function sanitizeRuntimeContext(context) {
|
|
|
99
152
|
: { mcpClientVersion: sanitizeVersion(context.mcpClientVersion) }),
|
|
100
153
|
};
|
|
101
154
|
}
|
|
155
|
+
function sanitizeDiagnosticProjectContext(context) {
|
|
156
|
+
return {
|
|
157
|
+
...sanitizeProjectContext(context),
|
|
158
|
+
...(context.projectRoot === undefined
|
|
159
|
+
? {}
|
|
160
|
+
: { projectRoot: sanitizeLocalPath(context.projectRoot) }),
|
|
161
|
+
...(context.workingDirectory === undefined
|
|
162
|
+
? {}
|
|
163
|
+
: { workingDirectory: sanitizeLocalPath(context.workingDirectory) }),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
102
166
|
function sanitizeProjectContext(context) {
|
|
103
167
|
return {
|
|
104
168
|
...(context.language ? { language: context.language } : {}),
|
|
@@ -117,6 +181,16 @@ function sanitizeIdentifier(value, pattern) {
|
|
|
117
181
|
const normalized = value.trim().toLowerCase();
|
|
118
182
|
return pattern.test(normalized) ? normalized : "unknown";
|
|
119
183
|
}
|
|
184
|
+
function sanitizeSensitiveIdentifier(value) {
|
|
185
|
+
const normalized = value.trim().slice(0, 128);
|
|
186
|
+
return /^[a-z0-9][a-z0-9 ._@-]*$/i.test(normalized) ? normalized : "unknown";
|
|
187
|
+
}
|
|
188
|
+
function sanitizeLocalPath(value) {
|
|
189
|
+
const normalized = value.trim().slice(0, 2048);
|
|
190
|
+
return normalized.startsWith("/") || /^[A-Za-z]:[\\\\/]/.test(normalized)
|
|
191
|
+
? normalized
|
|
192
|
+
: "unknown";
|
|
193
|
+
}
|
|
120
194
|
function sanitizeFreeIdentifier(value) {
|
|
121
195
|
const normalized = value.trim().slice(0, 64);
|
|
122
196
|
return /^[a-z0-9][a-z0-9 ._-]*$/i.test(normalized) ? normalized : "unknown";
|
|
@@ -142,4 +216,3 @@ function boundedInteger(value) {
|
|
|
142
216
|
function optionalNumber(key, value) {
|
|
143
217
|
return value === undefined ? {} : { [key]: boundedNumber(value) };
|
|
144
218
|
}
|
|
145
|
-
//# sourceMappingURL=privacy.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const TELEMETRY_LEVELS: readonly ["none", "anonymous", "basic", "detailed"];
|
|
1
|
+
export declare const TELEMETRY_LEVELS: readonly ["none", "anonymous", "basic", "detailed", "diagnostic"];
|
|
2
2
|
export type TelemetryLevel = (typeof TELEMETRY_LEVELS)[number];
|
|
3
3
|
export interface TelemetryConfig {
|
|
4
4
|
level: TelemetryLevel;
|
|
@@ -6,6 +6,15 @@ export interface TelemetryConfig {
|
|
|
6
6
|
persist?: boolean;
|
|
7
7
|
sessionId?: string;
|
|
8
8
|
}
|
|
9
|
+
export interface TelemetryHttpRequestEvent {
|
|
10
|
+
event: "http_request";
|
|
11
|
+
method: string;
|
|
12
|
+
route: "mcp" | "tree" | "root" | "file" | "other";
|
|
13
|
+
status: number;
|
|
14
|
+
success: boolean;
|
|
15
|
+
durationMs: number;
|
|
16
|
+
authenticated: boolean;
|
|
17
|
+
}
|
|
9
18
|
export interface TelemetryMcpRequestEvent {
|
|
10
19
|
event: "mcp_request";
|
|
11
20
|
method: string;
|
|
@@ -35,6 +44,14 @@ export interface TelemetryCommandEvent {
|
|
|
35
44
|
outputBytes?: number;
|
|
36
45
|
errorCategory?: string;
|
|
37
46
|
}
|
|
47
|
+
export interface TelemetryTunnelEvent {
|
|
48
|
+
event: "tunnel";
|
|
49
|
+
state: "online" | "disconnected" | "reconnecting" | "reconnected" | "failed";
|
|
50
|
+
attempt?: number;
|
|
51
|
+
attempts?: number;
|
|
52
|
+
durationMs?: number;
|
|
53
|
+
reasonCategory?: string;
|
|
54
|
+
}
|
|
38
55
|
export interface TelemetrySessionEvent {
|
|
39
56
|
event: "session";
|
|
40
57
|
wallClockDurationMs: number;
|
|
@@ -44,7 +61,7 @@ export interface TelemetrySessionEvent {
|
|
|
44
61
|
toolCallCount: number;
|
|
45
62
|
commandCallCount: number;
|
|
46
63
|
}
|
|
47
|
-
export type AnonymousTelemetryEvent = TelemetryMcpRequestEvent | TelemetryToolEvent | TelemetryCommandEvent | TelemetrySessionEvent;
|
|
64
|
+
export type AnonymousTelemetryEvent = TelemetryHttpRequestEvent | TelemetryMcpRequestEvent | TelemetryToolEvent | TelemetryCommandEvent | TelemetryTunnelEvent | TelemetrySessionEvent;
|
|
48
65
|
export interface TelemetryRuntimeContext {
|
|
49
66
|
agentDirVersion: string;
|
|
50
67
|
nodeMajor: number;
|
|
@@ -52,8 +69,17 @@ export interface TelemetryRuntimeContext {
|
|
|
52
69
|
arch: string;
|
|
53
70
|
mcpClientName?: string;
|
|
54
71
|
mcpClientVersion?: string;
|
|
72
|
+
nodeVersion?: string;
|
|
73
|
+
hostname?: string;
|
|
74
|
+
username?: string;
|
|
75
|
+
processId?: number;
|
|
76
|
+
parentProcessId?: number;
|
|
77
|
+
processUptimeMs?: number;
|
|
78
|
+
memoryRssBytes?: number;
|
|
55
79
|
}
|
|
56
80
|
export interface TelemetryProjectContext {
|
|
81
|
+
projectRoot?: string;
|
|
82
|
+
workingDirectory?: string;
|
|
57
83
|
language?: "typescript" | "javascript" | "python" | "go" | "rust" | "java" | "other";
|
|
58
84
|
framework?: "nextjs" | "react" | "hono" | "node" | "other";
|
|
59
85
|
packageManager?: "npm" | "pnpm" | "yarn" | "bun" | "other";
|
|
@@ -71,4 +97,3 @@ export interface TelemetryEnvelope {
|
|
|
71
97
|
runtime?: TelemetryRuntimeContext;
|
|
72
98
|
project?: TelemetryProjectContext;
|
|
73
99
|
}
|
|
74
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export const TELEMETRY_LEVELS = ["none", "anonymous", "basic", "detailed"];
|
|
2
|
-
//# sourceMappingURL=types.js.map
|
|
1
|
+
export const TELEMETRY_LEVELS = ["none", "anonymous", "basic", "detailed", "diagnostic"];
|
package/dist/src/tools/code.d.ts
CHANGED
|
@@ -24,4 +24,3 @@ export declare function findDefinition(root: string, symbol: string, maxResults?
|
|
|
24
24
|
export declare function findReferences(root: string, symbol: string, maxResults?: number, maxBytes?: number): Promise<SearchMatch[]>;
|
|
25
25
|
export declare function findImports(root: string, maxResults?: number, maxBytes?: number): Promise<ImportMatch[]>;
|
|
26
26
|
export declare function findExports(root: string, maxResults?: number, maxBytes?: number): Promise<ExportMatch[]>;
|
|
27
|
-
//# sourceMappingURL=code.d.ts.map
|
package/dist/src/tools/code.js
CHANGED
|
@@ -6,4 +6,3 @@ export interface CommandResult {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function isCommandBlacklisted(command: string, args?: string[], blacklistedCommands?: string[]): boolean;
|
|
8
8
|
export declare function runCommand(root: string, command: string, args?: string[], allowedCommands?: string[], blacklistedCommands?: string[], timeoutMs?: number, signal?: AbortSignal): Promise<CommandResult>;
|
|
9
|
-
//# sourceMappingURL=commands.d.ts.map
|
package/dist/src/tools/files.js
CHANGED
package/dist/src/tools/git.d.ts
CHANGED
|
@@ -12,4 +12,3 @@ export declare function gitStatus(root: string): Promise<GitResult>;
|
|
|
12
12
|
export declare function gitDiff(root: string, staged?: boolean, pathspec?: string): Promise<GitResult>;
|
|
13
13
|
export declare function gitRestore(root: string, paths: string[], staged?: boolean): Promise<GitResult>;
|
|
14
14
|
export declare function gitLog(root: string, limit?: number, pathspec?: string): Promise<GitResult>;
|
|
15
|
-
//# sourceMappingURL=git.d.ts.map
|
package/dist/src/tools/git.js
CHANGED
|
@@ -17,4 +17,3 @@ export interface ProjectOverview {
|
|
|
17
17
|
export declare function fileInfo(root: string, relativePath: string): Promise<Record<string, unknown>>;
|
|
18
18
|
export declare function packageInfo(root: string): Promise<Record<string, unknown>>;
|
|
19
19
|
export declare function projectOverview(root: string): Promise<ProjectOverview>;
|
|
20
|
-
//# sourceMappingURL=metadata.d.ts.map
|
package/dist/src/tools/npm.d.ts
CHANGED
package/dist/src/tools/npm.js
CHANGED
package/dist/src/tools/skills.js
CHANGED
package/dist/src/tunnel.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import type { TunnelOptions, TunnelResult } from "./types.js";
|
|
2
|
-
export declare function startTunnel(
|
|
3
|
-
//# sourceMappingURL=tunnel.d.ts.map
|
|
2
|
+
export declare function startTunnel(options: TunnelOptions): Promise<TunnelResult>;
|