agentcheck-sdk 0.4.0 → 0.5.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/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/telemetry.d.ts +30 -0
- package/dist/telemetry.js +78 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { AgentToolChecker } from "./langchain";
|
|
|
6
6
|
export { DelegationDashboard } from "./dashboard";
|
|
7
7
|
export { quickStart } from "./quickstart";
|
|
8
8
|
export { templates } from "./templates";
|
|
9
|
+
export { TelemetryPlugin } from "./telemetry";
|
|
9
10
|
export type { WebhookEvent } from "./webhook";
|
|
10
11
|
export type { ScopeVerifier, DelegationProviderConfig } from "./provider";
|
|
11
12
|
export type { GuardConfig } from "./guard";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RateLimitError = exports.ValidationError = exports.NotFoundError = exports.AuthenticationError = exports.AgentCheckError = exports.templates = exports.quickStart = exports.DelegationDashboard = exports.AgentToolChecker = exports.delegationGuard = exports.DelegationProvider = exports.WebhookHandler = exports.AgentCheckClient = void 0;
|
|
3
|
+
exports.RateLimitError = exports.ValidationError = exports.NotFoundError = exports.AuthenticationError = exports.AgentCheckError = exports.TelemetryPlugin = exports.templates = exports.quickStart = exports.DelegationDashboard = exports.AgentToolChecker = exports.delegationGuard = exports.DelegationProvider = exports.WebhookHandler = exports.AgentCheckClient = void 0;
|
|
4
4
|
// Individual commands (basic menu)
|
|
5
5
|
var client_1 = require("./client");
|
|
6
6
|
Object.defineProperty(exports, "AgentCheckClient", { enumerable: true, get: function () { return client_1.AgentCheckClient; } });
|
|
@@ -19,6 +19,8 @@ var quickstart_1 = require("./quickstart");
|
|
|
19
19
|
Object.defineProperty(exports, "quickStart", { enumerable: true, get: function () { return quickstart_1.quickStart; } });
|
|
20
20
|
var templates_1 = require("./templates");
|
|
21
21
|
Object.defineProperty(exports, "templates", { enumerable: true, get: function () { return templates_1.templates; } });
|
|
22
|
+
var telemetry_1 = require("./telemetry");
|
|
23
|
+
Object.defineProperty(exports, "TelemetryPlugin", { enumerable: true, get: function () { return telemetry_1.TelemetryPlugin; } });
|
|
22
24
|
var errors_1 = require("./errors");
|
|
23
25
|
Object.defineProperty(exports, "AgentCheckError", { enumerable: true, get: function () { return errors_1.AgentCheckError; } });
|
|
24
26
|
Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return errors_1.AuthenticationError; } });
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telemetry Plugin - Opt-in usage tracking.
|
|
3
|
+
*
|
|
4
|
+
* NOT enabled by default. You must explicitly enable it.
|
|
5
|
+
*
|
|
6
|
+
* What it tracks:
|
|
7
|
+
* - Which SDK features are used (record, list, revoke, etc.)
|
|
8
|
+
* - SDK language and version
|
|
9
|
+
* - Agent names (for your own analytics)
|
|
10
|
+
*
|
|
11
|
+
* What it does NOT track:
|
|
12
|
+
* - Scope content, email addresses, API keys, payloads
|
|
13
|
+
*/
|
|
14
|
+
export declare class TelemetryPlugin {
|
|
15
|
+
private static instance;
|
|
16
|
+
private apiKey;
|
|
17
|
+
private baseUrl;
|
|
18
|
+
private buffer;
|
|
19
|
+
private enabled;
|
|
20
|
+
private timer;
|
|
21
|
+
private flushInterval;
|
|
22
|
+
constructor(apiKey: string, baseUrl?: string, flushInterval?: number);
|
|
23
|
+
/** Start collecting telemetry (opt-in). */
|
|
24
|
+
enable(): void;
|
|
25
|
+
/** Stop collecting telemetry. */
|
|
26
|
+
disable(): void;
|
|
27
|
+
/** Record a telemetry event (no-op if not enabled). */
|
|
28
|
+
static track(event: string, feature?: string, agentName?: string, metadata?: Record<string, unknown>): void;
|
|
29
|
+
private flush;
|
|
30
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Telemetry Plugin - Opt-in usage tracking.
|
|
4
|
+
*
|
|
5
|
+
* NOT enabled by default. You must explicitly enable it.
|
|
6
|
+
*
|
|
7
|
+
* What it tracks:
|
|
8
|
+
* - Which SDK features are used (record, list, revoke, etc.)
|
|
9
|
+
* - SDK language and version
|
|
10
|
+
* - Agent names (for your own analytics)
|
|
11
|
+
*
|
|
12
|
+
* What it does NOT track:
|
|
13
|
+
* - Scope content, email addresses, API keys, payloads
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.TelemetryPlugin = void 0;
|
|
17
|
+
class TelemetryPlugin {
|
|
18
|
+
constructor(apiKey, baseUrl = "https://agentcheck.spaceplanning.work", flushInterval = 60000) {
|
|
19
|
+
this.buffer = [];
|
|
20
|
+
this.enabled = false;
|
|
21
|
+
this.timer = null;
|
|
22
|
+
this.apiKey = apiKey;
|
|
23
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
24
|
+
this.flushInterval = flushInterval;
|
|
25
|
+
}
|
|
26
|
+
/** Start collecting telemetry (opt-in). */
|
|
27
|
+
enable() {
|
|
28
|
+
this.enabled = true;
|
|
29
|
+
TelemetryPlugin.instance = this;
|
|
30
|
+
this.timer = setInterval(() => this.flush(), this.flushInterval);
|
|
31
|
+
}
|
|
32
|
+
/** Stop collecting telemetry. */
|
|
33
|
+
disable() {
|
|
34
|
+
this.enabled = false;
|
|
35
|
+
TelemetryPlugin.instance = null;
|
|
36
|
+
if (this.timer)
|
|
37
|
+
clearInterval(this.timer);
|
|
38
|
+
this.flush();
|
|
39
|
+
}
|
|
40
|
+
/** Record a telemetry event (no-op if not enabled). */
|
|
41
|
+
static track(event, feature, agentName, metadata) {
|
|
42
|
+
const instance = TelemetryPlugin.instance;
|
|
43
|
+
if (!instance || !instance.enabled)
|
|
44
|
+
return;
|
|
45
|
+
instance.buffer.push({
|
|
46
|
+
event,
|
|
47
|
+
sdk_language: "typescript",
|
|
48
|
+
sdk_version: "0.4.0",
|
|
49
|
+
feature,
|
|
50
|
+
agent_name: agentName,
|
|
51
|
+
metadata,
|
|
52
|
+
});
|
|
53
|
+
if (instance.buffer.length >= 50) {
|
|
54
|
+
instance.flush();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async flush() {
|
|
58
|
+
if (!this.buffer.length)
|
|
59
|
+
return;
|
|
60
|
+
const events = [...this.buffer];
|
|
61
|
+
this.buffer = [];
|
|
62
|
+
try {
|
|
63
|
+
await fetch(`${this.baseUrl}/api/v1/telemetry`, {
|
|
64
|
+
method: "POST",
|
|
65
|
+
headers: {
|
|
66
|
+
"Content-Type": "application/json",
|
|
67
|
+
"X-API-Key": this.apiKey,
|
|
68
|
+
},
|
|
69
|
+
body: JSON.stringify({ events }),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
// Telemetry should never break the app
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.TelemetryPlugin = TelemetryPlugin;
|
|
78
|
+
TelemetryPlugin.instance = null;
|