agentcheck-sdk 0.4.0 → 0.6.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/client.d.ts CHANGED
@@ -16,6 +16,15 @@ export declare class AgentCheckClient {
16
16
  revoke(agreementId: string, reason: string): Promise<Agreement>;
17
17
  /** Register a webhook endpoint. */
18
18
  registerWebhook(url: string, events: string[]): Promise<WebhookResult>;
19
+ /** Get audit trail (hash chain) for an agreement. */
20
+ getAuditTrail(agreementId: string): Promise<any>;
21
+ /** Verify hash chain integrity for an agreement. */
22
+ verifyAuditChain(agreementId: string): Promise<{
23
+ valid: boolean;
24
+ total_entries: number;
25
+ broken_at: number | null;
26
+ error: string | null;
27
+ }>;
19
28
  /** Self-service signup. Returns API key (shown once). */
20
29
  static signup(email: string, companyName?: string, baseUrl?: string): Promise<SignupResult>;
21
30
  }
package/dist/client.js CHANGED
@@ -72,6 +72,14 @@ class AgentCheckClient {
72
72
  events,
73
73
  });
74
74
  }
75
+ /** Get audit trail (hash chain) for an agreement. */
76
+ async getAuditTrail(agreementId) {
77
+ return this.request("GET", `/api/v1/audit/${agreementId}`);
78
+ }
79
+ /** Verify hash chain integrity for an agreement. */
80
+ async verifyAuditChain(agreementId) {
81
+ return this.request("GET", `/api/v1/audit/${agreementId}/verify`);
82
+ }
75
83
  /** Self-service signup. Returns API key (shown once). */
76
84
  static async signup(email, companyName, baseUrl = DEFAULT_BASE_URL) {
77
85
  const body = { email };
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentcheck-sdk",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Record what your AI agent is allowed to do",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",