agent-dir 0.3.1 → 0.4.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.md +3 -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 +120 -13
- 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 +77 -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 +29 -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 +266 -84
- package/dist/src/types.d.ts +27 -1
- package/dist/src/types.js +0 -1
- package/package.json +2 -2
- 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,19 @@ 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.healthState === undefined ? {} : { healthState: event.healthState }),
|
|
61
|
+
...(event.attempt === undefined ? {} : { attempt: boundedInteger(event.attempt) }),
|
|
62
|
+
...(event.attempts === undefined ? {} : { attempts: boundedInteger(event.attempts) }),
|
|
63
|
+
...(event.durationMs === undefined ? {} : { durationMs: boundedNumber(event.durationMs) }),
|
|
64
|
+
...(event.reasonCategory === undefined
|
|
65
|
+
? {}
|
|
66
|
+
: { reasonCategory: sanitizeErrorCategory(event.reasonCategory) }),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
45
69
|
if (event.event === "command_call") {
|
|
46
70
|
return {
|
|
47
71
|
event: "command_call",
|
|
@@ -76,15 +100,45 @@ export function createTelemetryEnvelope(level, event, runtime, project, configId
|
|
|
76
100
|
level,
|
|
77
101
|
event: sanitizeAnonymousEvent(event),
|
|
78
102
|
};
|
|
79
|
-
if (level === "basic" || level === "detailed") {
|
|
103
|
+
if (level === "basic" || level === "detailed" || level === "diagnostic") {
|
|
80
104
|
if (runtime)
|
|
81
105
|
envelope.runtime = sanitizeRuntimeContext(runtime);
|
|
82
106
|
}
|
|
83
|
-
if (level === "detailed" && project) {
|
|
107
|
+
if ((level === "detailed" || level === "diagnostic") && project) {
|
|
84
108
|
envelope.project = sanitizeProjectContext(project);
|
|
85
109
|
}
|
|
110
|
+
if (level === "diagnostic" && runtime) {
|
|
111
|
+
envelope.runtime = sanitizeDiagnosticRuntimeContext(runtime);
|
|
112
|
+
}
|
|
113
|
+
if (level === "diagnostic" && project) {
|
|
114
|
+
envelope.project = sanitizeDiagnosticProjectContext(project);
|
|
115
|
+
}
|
|
86
116
|
return envelope;
|
|
87
117
|
}
|
|
118
|
+
function sanitizeDiagnosticRuntimeContext(context) {
|
|
119
|
+
return {
|
|
120
|
+
...sanitizeRuntimeContext(context),
|
|
121
|
+
...(context.nodeVersion === undefined
|
|
122
|
+
? {}
|
|
123
|
+
: { nodeVersion: sanitizeVersion(context.nodeVersion) }),
|
|
124
|
+
...(context.hostname === undefined
|
|
125
|
+
? {}
|
|
126
|
+
: { hostname: sanitizeSensitiveIdentifier(context.hostname) }),
|
|
127
|
+
...(context.username === undefined
|
|
128
|
+
? {}
|
|
129
|
+
: { username: sanitizeSensitiveIdentifier(context.username) }),
|
|
130
|
+
...(context.processId === undefined ? {} : { processId: boundedInteger(context.processId) }),
|
|
131
|
+
...(context.parentProcessId === undefined
|
|
132
|
+
? {}
|
|
133
|
+
: { parentProcessId: boundedInteger(context.parentProcessId) }),
|
|
134
|
+
...(context.processUptimeMs === undefined
|
|
135
|
+
? {}
|
|
136
|
+
: { processUptimeMs: boundedNumber(context.processUptimeMs) }),
|
|
137
|
+
...(context.memoryRssBytes === undefined
|
|
138
|
+
? {}
|
|
139
|
+
: { memoryRssBytes: boundedNumber(context.memoryRssBytes) }),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
88
142
|
function sanitizeRuntimeContext(context) {
|
|
89
143
|
return {
|
|
90
144
|
agentDirVersion: sanitizeVersion(context.agentDirVersion),
|
|
@@ -99,6 +153,17 @@ function sanitizeRuntimeContext(context) {
|
|
|
99
153
|
: { mcpClientVersion: sanitizeVersion(context.mcpClientVersion) }),
|
|
100
154
|
};
|
|
101
155
|
}
|
|
156
|
+
function sanitizeDiagnosticProjectContext(context) {
|
|
157
|
+
return {
|
|
158
|
+
...sanitizeProjectContext(context),
|
|
159
|
+
...(context.projectRoot === undefined
|
|
160
|
+
? {}
|
|
161
|
+
: { projectRoot: sanitizeLocalPath(context.projectRoot) }),
|
|
162
|
+
...(context.workingDirectory === undefined
|
|
163
|
+
? {}
|
|
164
|
+
: { workingDirectory: sanitizeLocalPath(context.workingDirectory) }),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
102
167
|
function sanitizeProjectContext(context) {
|
|
103
168
|
return {
|
|
104
169
|
...(context.language ? { language: context.language } : {}),
|
|
@@ -117,6 +182,16 @@ function sanitizeIdentifier(value, pattern) {
|
|
|
117
182
|
const normalized = value.trim().toLowerCase();
|
|
118
183
|
return pattern.test(normalized) ? normalized : "unknown";
|
|
119
184
|
}
|
|
185
|
+
function sanitizeSensitiveIdentifier(value) {
|
|
186
|
+
const normalized = value.trim().slice(0, 128);
|
|
187
|
+
return /^[a-z0-9][a-z0-9 ._@-]*$/i.test(normalized) ? normalized : "unknown";
|
|
188
|
+
}
|
|
189
|
+
function sanitizeLocalPath(value) {
|
|
190
|
+
const normalized = value.trim().slice(0, 2048);
|
|
191
|
+
return normalized.startsWith("/") || /^[A-Za-z]:[\\\\/]/.test(normalized)
|
|
192
|
+
? normalized
|
|
193
|
+
: "unknown";
|
|
194
|
+
}
|
|
120
195
|
function sanitizeFreeIdentifier(value) {
|
|
121
196
|
const normalized = value.trim().slice(0, 64);
|
|
122
197
|
return /^[a-z0-9][a-z0-9 ._-]*$/i.test(normalized) ? normalized : "unknown";
|
|
@@ -142,4 +217,3 @@ function boundedInteger(value) {
|
|
|
142
217
|
function optionalNumber(key, value) {
|
|
143
218
|
return value === undefined ? {} : { [key]: boundedNumber(value) };
|
|
144
219
|
}
|
|
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,15 @@ 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" | "health";
|
|
50
|
+
healthState?: "healthy" | "degraded" | "recovered";
|
|
51
|
+
attempt?: number;
|
|
52
|
+
attempts?: number;
|
|
53
|
+
durationMs?: number;
|
|
54
|
+
reasonCategory?: string;
|
|
55
|
+
}
|
|
38
56
|
export interface TelemetrySessionEvent {
|
|
39
57
|
event: "session";
|
|
40
58
|
wallClockDurationMs: number;
|
|
@@ -44,7 +62,7 @@ export interface TelemetrySessionEvent {
|
|
|
44
62
|
toolCallCount: number;
|
|
45
63
|
commandCallCount: number;
|
|
46
64
|
}
|
|
47
|
-
export type AnonymousTelemetryEvent = TelemetryMcpRequestEvent | TelemetryToolEvent | TelemetryCommandEvent | TelemetrySessionEvent;
|
|
65
|
+
export type AnonymousTelemetryEvent = TelemetryHttpRequestEvent | TelemetryMcpRequestEvent | TelemetryToolEvent | TelemetryCommandEvent | TelemetryTunnelEvent | TelemetrySessionEvent;
|
|
48
66
|
export interface TelemetryRuntimeContext {
|
|
49
67
|
agentDirVersion: string;
|
|
50
68
|
nodeMajor: number;
|
|
@@ -52,8 +70,17 @@ export interface TelemetryRuntimeContext {
|
|
|
52
70
|
arch: string;
|
|
53
71
|
mcpClientName?: string;
|
|
54
72
|
mcpClientVersion?: string;
|
|
73
|
+
nodeVersion?: string;
|
|
74
|
+
hostname?: string;
|
|
75
|
+
username?: string;
|
|
76
|
+
processId?: number;
|
|
77
|
+
parentProcessId?: number;
|
|
78
|
+
processUptimeMs?: number;
|
|
79
|
+
memoryRssBytes?: number;
|
|
55
80
|
}
|
|
56
81
|
export interface TelemetryProjectContext {
|
|
82
|
+
projectRoot?: string;
|
|
83
|
+
workingDirectory?: string;
|
|
57
84
|
language?: "typescript" | "javascript" | "python" | "go" | "rust" | "java" | "other";
|
|
58
85
|
framework?: "nextjs" | "react" | "hono" | "node" | "other";
|
|
59
86
|
packageManager?: "npm" | "pnpm" | "yarn" | "bun" | "other";
|
|
@@ -71,4 +98,3 @@ export interface TelemetryEnvelope {
|
|
|
71
98
|
runtime?: TelemetryRuntimeContext;
|
|
72
99
|
project?: TelemetryProjectContext;
|
|
73
100
|
}
|
|
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>;
|