@kya-os/mcp-i 1.12.4 → 1.13.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.
@@ -2,12 +2,13 @@
2
2
  * Checkpoint API Delegation Verifier
3
3
  *
4
4
  * Queries delegations from Checkpoint managed service API.
5
- * Includes local caching to minimize network calls and maximize performance.
5
+ * No verdict is cached: every verification asks Checkpoint, so a revocation
6
+ * refuses the very next call and a delegation granted (or replaced) after a
7
+ * refusal is accepted on the next call. `cacheTtl`, `skipCache` and
8
+ * `maxCacheAge` therefore have no effect on this verifier.
6
9
  *
7
10
  * Performance:
8
- * - Fast path (cached): < 5ms
9
- * - Slow path (API call): < 100ms
10
- * - Cache TTL: 1 minute (configurable)
11
+ * - API call: < 100ms
11
12
  *
12
13
  * API Endpoints:
13
14
  * - POST /api/v1/delegations/verify - Verify delegation by agent DID + scopes
@@ -18,7 +19,7 @@
18
19
  * Authentication: Bearer token via X-API-Key header
19
20
  *
20
21
  * Related: PHASE_1_XMCP_I_SERVER.md Ticket 1.3
21
- * Related: AGENTSHIELD_DASHBOARD_PLAN.md Epic 2 (Public API)
22
+ * Related: CHECKPOINT_DASHBOARD_PLAN.md Epic 2 (Public API)
22
23
  */
23
24
  import { DelegationRecord } from "@kya-os/contracts/delegation";
24
25
  import { DelegationVerifier, DelegationVerifierConfig, VerifyDelegationResult, VerifyDelegationOptions } from "./delegation-verifier";
@@ -27,11 +28,9 @@ import { DelegationVerifier, DelegationVerifierConfig, VerifyDelegationResult, V
27
28
  *
28
29
  * Managed mode: Queries delegations from Checkpoint dashboard API
29
30
  */
30
- export declare class AgentShieldAPIDelegationVerifier implements DelegationVerifier {
31
+ export declare class CheckpointAPIDelegationVerifier implements DelegationVerifier {
31
32
  private apiUrl;
32
33
  private apiKey;
33
- private cache;
34
- private cacheTtl;
35
34
  private debug;
36
35
  private accessControlService;
37
36
  constructor(config: DelegationVerifierConfig);
@@ -55,11 +54,7 @@ export declare class AgentShieldAPIDelegationVerifier implements DelegationVerif
55
54
  */
56
55
  revoke(delegationId: string, reason?: string): Promise<void>;
57
56
  /**
58
- * Close connections (cleanup)
57
+ * Close connections (cleanup). The verifier holds no cache or connection.
59
58
  */
60
59
  close(): Promise<void>;
61
- /**
62
- * Build deterministic scopes key for caching
63
- */
64
- private buildScopesKey;
65
60
  }
@@ -3,12 +3,13 @@
3
3
  * Checkpoint API Delegation Verifier
4
4
  *
5
5
  * Queries delegations from Checkpoint managed service API.
6
- * Includes local caching to minimize network calls and maximize performance.
6
+ * No verdict is cached: every verification asks Checkpoint, so a revocation
7
+ * refuses the very next call and a delegation granted (or replaced) after a
8
+ * refusal is accepted on the next call. `cacheTtl`, `skipCache` and
9
+ * `maxCacheAge` therefore have no effect on this verifier.
7
10
  *
8
11
  * Performance:
9
- * - Fast path (cached): < 5ms
10
- * - Slow path (API call): < 100ms
11
- * - Cache TTL: 1 minute (configurable)
12
+ * - API call: < 100ms
12
13
  *
13
14
  * API Endpoints:
14
15
  * - POST /api/v1/delegations/verify - Verify delegation by agent DID + scopes
@@ -19,74 +20,34 @@
19
20
  * Authentication: Bearer token via X-API-Key header
20
21
  *
21
22
  * Related: PHASE_1_XMCP_I_SERVER.md Ticket 1.3
22
- * Related: AGENTSHIELD_DASHBOARD_PLAN.md Epic 2 (Public API)
23
+ * Related: CHECKPOINT_DASHBOARD_PLAN.md Epic 2 (Public API)
23
24
  */
24
25
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.AgentShieldAPIDelegationVerifier = void 0;
26
+ exports.CheckpointAPIDelegationVerifier = void 0;
26
27
  const delegation_1 = require("@kya-os/contracts/delegation");
27
- const agentshield_api_1 = require("@kya-os/contracts/agentshield-api");
28
+ const checkpoint_api_1 = require("@kya-os/contracts/checkpoint-api");
28
29
  const delegation_verifier_1 = require("./delegation-verifier");
29
30
  // C4 drain: stays on @kya-os/mcp-i-core - the test vi.mocks that specifier; source import + mock must drain together in L-Node-tests.
30
31
  const mcp_i_core_1 = require("@kya-os/mcp-i-core");
31
32
  const node_providers_1 = require("../providers/node-providers");
32
- /**
33
- * Simple in-memory cache (same as KV verifier)
34
- */
35
- class DelegationCache {
36
- cache = new Map();
37
- maxSize;
38
- constructor(maxSize = 1000) {
39
- this.maxSize = maxSize;
40
- }
41
- get(key) {
42
- const entry = this.cache.get(key);
43
- if (!entry)
44
- return null;
45
- if (Date.now() > entry.expiresAt) {
46
- this.cache.delete(key);
47
- return null;
48
- }
49
- return entry.data;
50
- }
51
- set(key, data, ttlMs) {
52
- if (this.cache.size >= this.maxSize) {
53
- const firstKey = this.cache.keys().next().value;
54
- if (firstKey)
55
- this.cache.delete(firstKey);
56
- }
57
- this.cache.set(key, {
58
- data,
59
- expiresAt: Date.now() + ttlMs,
60
- });
61
- }
62
- delete(key) {
63
- this.cache.delete(key);
64
- }
65
- clear() {
66
- this.cache.clear();
67
- }
68
- }
69
33
  // Use standard Checkpoint API response types from contracts
70
34
  /**
71
35
  * Checkpoint API Delegation Verifier
72
36
  *
73
37
  * Managed mode: Queries delegations from Checkpoint dashboard API
74
38
  */
75
- class AgentShieldAPIDelegationVerifier {
39
+ class CheckpointAPIDelegationVerifier {
76
40
  apiUrl;
77
41
  apiKey;
78
- cache;
79
- cacheTtl;
80
42
  debug;
81
43
  accessControlService;
82
44
  constructor(config) {
83
- if (!config.agentshield?.apiUrl || !config.agentshield?.apiKey) {
84
- throw new Error("AgentShieldAPIDelegationVerifier requires agentshield.apiUrl and agentshield.apiKey in config");
45
+ const checkpoint = config.checkpoint ?? config.agentshield;
46
+ if (!checkpoint?.apiUrl || !checkpoint?.apiKey) {
47
+ throw new Error("CheckpointAPIDelegationVerifier requires checkpoint.apiUrl and checkpoint.apiKey in config");
85
48
  }
86
- this.apiUrl = config.agentshield.apiUrl.replace(/\/$/, ""); // Remove trailing slash
87
- this.apiKey = config.agentshield.apiKey;
88
- this.cache = new DelegationCache();
89
- this.cacheTtl = config.cacheTtl || 60_000; // Default 1 minute
49
+ this.apiUrl = checkpoint.apiUrl.replace(/\/$/, ""); // Remove trailing slash
50
+ this.apiKey = checkpoint.apiKey;
90
51
  this.debug = config.debug || false;
91
52
  // Create AccessControlApiService instance
92
53
  const fetchProvider = new node_providers_1.NodeFetchProvider();
@@ -116,30 +77,14 @@ class AgentShieldAPIDelegationVerifier {
116
77
  };
117
78
  }
118
79
  const startTime = Date.now();
119
- // Build cache key
120
- const scopesKey = this.buildScopesKey(scopes);
121
- const cacheKey = `verify:${agentDid}:${scopesKey}`;
122
- // Fast path: Check cache
123
- if (!options?.skipCache) {
124
- const cached = this.cache.get(cacheKey);
125
- if (cached) {
126
- if (this.debug) {
127
- console.error(`[Checkpoint] Cache HIT for ${agentDid} (${Date.now() - startTime}ms)`);
128
- }
129
- // Return cached result with cached flag set to true
130
- return {
131
- ...cached,
132
- cached: true,
133
- };
134
- }
135
- }
136
- // Slow path: API call
80
+ // Every verification asks Checkpoint: a cached acceptance would outlive a
81
+ // revocation, and a cached refusal would hide a delegation granted since.
137
82
  if (this.debug) {
138
- console.error(`[Checkpoint] Cache MISS for ${agentDid}, calling API...`);
83
+ console.error(`[Checkpoint] Verifying ${agentDid}, calling API...`);
139
84
  }
140
85
  try {
141
86
  // Validate request input using contracts schema
142
- const requestBody = agentshield_api_1.verifyDelegationRequestSchema.parse({
87
+ const requestBody = checkpoint_api_1.verifyDelegationRequestSchema.parse({
143
88
  agent_did: agentDid,
144
89
  scopes,
145
90
  });
@@ -148,8 +93,6 @@ class AgentShieldAPIDelegationVerifier {
148
93
  // Extract data from wrapped response
149
94
  const data = response.data;
150
95
  // Build result from validated response
151
- // Note: Don't include 'cached' property in the result that gets cached
152
- // We'll add it when returning (false for API calls, true for cache hits)
153
96
  const result = {
154
97
  valid: data.valid,
155
98
  delegation: data.delegation,
@@ -157,20 +100,16 @@ class AgentShieldAPIDelegationVerifier {
157
100
  credential: data.credential,
158
101
  reason: data.error ? data.error.message : data.reason,
159
102
  };
160
- // Cache result (without cached property)
161
- const ttl = data.valid ? this.cacheTtl : this.cacheTtl / 2;
162
- this.cache.set(cacheKey, result, ttl);
163
103
  if (this.debug) {
164
104
  console.error(`[Checkpoint] Delegation ${data.valid ? "verified" : "rejected"} (${Date.now() - startTime}ms)`);
165
105
  }
166
- // Return result with cached: false for API calls
167
106
  return { ...result, cached: false };
168
107
  }
169
108
  catch (error) {
170
109
  console.error("[Checkpoint] API call failed:", error);
171
110
  // Return negative result on error (don't cache failures)
172
111
  // Use standard error format
173
- if (error instanceof agentshield_api_1.AgentShieldAPIError) {
112
+ if (error instanceof checkpoint_api_1.CheckpointAPIError) {
174
113
  return {
175
114
  valid: false,
176
115
  reason: error.message,
@@ -243,11 +182,6 @@ class AgentShieldAPIDelegationVerifier {
243
182
  if (!response.ok) {
244
183
  throw new Error(`Checkpoint API error: ${response.status} ${response.statusText}`);
245
184
  }
246
- // Invalidate cache
247
- const delegationScopes = (0, delegation_verifier_1.extractScopes)(delegation);
248
- const scopesKey = this.buildScopesKey(delegationScopes);
249
- this.cache.delete(`delegation:${delegation.id}`);
250
- this.cache.delete(`verify:${delegation.subjectDid}:${scopesKey}`);
251
185
  if (this.debug) {
252
186
  console.error(`[Checkpoint] Stored delegation ${delegation.id}`);
253
187
  }
@@ -273,8 +207,6 @@ class AgentShieldAPIDelegationVerifier {
273
207
  if (!response.ok) {
274
208
  throw new Error(`Checkpoint API error: ${response.status} ${response.statusText}`);
275
209
  }
276
- // Invalidate cache
277
- this.cache.delete(`delegation:${delegationId}`);
278
210
  if (this.debug) {
279
211
  console.error(`[Checkpoint] Revoked delegation ${delegationId}`);
280
212
  }
@@ -285,24 +217,8 @@ class AgentShieldAPIDelegationVerifier {
285
217
  }
286
218
  }
287
219
  /**
288
- * Close connections (cleanup)
220
+ * Close connections (cleanup). The verifier holds no cache or connection.
289
221
  */
290
- async close() {
291
- this.cache.clear();
292
- }
293
- /**
294
- * Build deterministic scopes key for caching
295
- */
296
- buildScopesKey(scopes) {
297
- const sorted = [...scopes].sort();
298
- const str = sorted.join(",");
299
- let hash = 0;
300
- for (let i = 0; i < str.length; i++) {
301
- const char = str.charCodeAt(i);
302
- hash = (hash << 5) - hash + char;
303
- hash = hash & hash;
304
- }
305
- return Math.abs(hash).toString(36);
306
- }
222
+ async close() { }
307
223
  }
308
- exports.AgentShieldAPIDelegationVerifier = AgentShieldAPIDelegationVerifier;
224
+ exports.CheckpointAPIDelegationVerifier = CheckpointAPIDelegationVerifier;
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * Architecture:
8
8
  * - DelegationVerifier: Abstract interface (Dependency Inversion Principle)
9
- * - Concrete adapters: CloudflareKVVerifier, AgentShieldAPIVerifier
9
+ * - Concrete adapters: CloudflareKVVerifier, CheckpointAPIVerifier
10
10
  * - Factory: createDelegationVerifier() selects adapter based on config
11
11
  *
12
12
  * Related: PHASE_1_XMCP_I_SERVER.md Epic 1 (Delegation Storage Layer)
@@ -56,7 +56,7 @@ export interface VerifyDelegationOptions {
56
56
  *
57
57
  * Implementations:
58
58
  * - CloudflareKVDelegationVerifier (local storage)
59
- * - AgentShieldAPIDelegationVerifier (remote managed service)
59
+ * - CheckpointAPIDelegationVerifier (remote managed service)
60
60
  *
61
61
  * Follows Interface Segregation Principle (SOLID) - minimal required methods
62
62
  */
@@ -155,8 +155,11 @@ export declare const VerifyDelegationInputSchema: z.ZodObject<{
155
155
  * Configuration for delegation verifiers
156
156
  */
157
157
  export interface DelegationVerifierConfig {
158
- /** Verifier type */
159
- type: 'cloudflare-kv' | 'agentshield-api' | 'memory';
158
+ /**
159
+ * Verifier type. `'agentshield-api'` is the former name of `'checkpoint-api'`
160
+ * and selects the same verifier.
161
+ */
162
+ type: 'cloudflare-kv' | 'checkpoint-api' | 'agentshield-api' | 'memory';
160
163
  /** Cloudflare KV namespace (for cloudflare-kv type) */
161
164
  kvNamespace?: {
162
165
  get(key: string): Promise<string | null>;
@@ -170,7 +173,12 @@ export interface DelegationVerifierConfig {
170
173
  }>;
171
174
  }>;
172
175
  };
173
- /** Checkpoint API configuration (for agentshield-api type) */
176
+ /** Checkpoint API configuration (for checkpoint-api type) */
177
+ checkpoint?: {
178
+ apiUrl: string;
179
+ apiKey: string;
180
+ };
181
+ /** @deprecated Use `checkpoint`; read only when `checkpoint` is absent. */
174
182
  agentshield?: {
175
183
  apiUrl: string;
176
184
  apiKey: string;
@@ -188,8 +196,8 @@ export interface DelegationVerifierConfig {
188
196
  *
189
197
  * Note: Checkpoint API responses use standard wrapper format
190
198
  * { success: boolean, data: {...}, metadata?: {...} } as defined in
191
- * @kya-os/contracts/agentshield-api. This is handled in the
192
- * AgentShieldAPIDelegationVerifier implementation.
199
+ * @kya-os/contracts/checkpoint-api. This is handled in the
200
+ * CheckpointAPIDelegationVerifier implementation.
193
201
  *
194
202
  * @param config - Verifier configuration
195
203
  * @returns DelegationVerifier instance
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * Architecture:
9
9
  * - DelegationVerifier: Abstract interface (Dependency Inversion Principle)
10
- * - Concrete adapters: CloudflareKVVerifier, AgentShieldAPIVerifier
10
+ * - Concrete adapters: CloudflareKVVerifier, CheckpointAPIVerifier
11
11
  * - Factory: createDelegationVerifier() selects adapter based on config
12
12
  *
13
13
  * Related: PHASE_1_XMCP_I_SERVER.md Epic 1 (Delegation Storage Layer)
@@ -97,8 +97,8 @@ exports.VerifyDelegationInputSchema = zod_1.z.object({
97
97
  *
98
98
  * Note: Checkpoint API responses use standard wrapper format
99
99
  * { success: boolean, data: {...}, metadata?: {...} } as defined in
100
- * @kya-os/contracts/agentshield-api. This is handled in the
101
- * AgentShieldAPIDelegationVerifier implementation.
100
+ * @kya-os/contracts/checkpoint-api. This is handled in the
101
+ * CheckpointAPIDelegationVerifier implementation.
102
102
  *
103
103
  * @param config - Verifier configuration
104
104
  * @returns DelegationVerifier instance
@@ -109,9 +109,10 @@ function createDelegationVerifier(config) {
109
109
  const CloudflareKVDelegationVerifier = require('./delegation-verifier-kv').CloudflareKVDelegationVerifier;
110
110
  return new CloudflareKVDelegationVerifier(config);
111
111
  }
112
+ case 'checkpoint-api':
112
113
  case 'agentshield-api': {
113
- const AgentShieldAPIDelegationVerifier = require('./delegation-verifier-agentshield').AgentShieldAPIDelegationVerifier;
114
- return new AgentShieldAPIDelegationVerifier(config);
114
+ const CheckpointAPIDelegationVerifier = require('./delegation-verifier-checkpoint').CheckpointAPIDelegationVerifier;
115
+ return new CheckpointAPIDelegationVerifier(config);
115
116
  }
116
117
  case 'memory': {
117
118
  const MemoryDelegationVerifier = require('./delegation-verifier-memory').MemoryDelegationVerifier;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The AgentShield-named exports from before these classes took the Checkpoint
3
+ * name. Each is the Checkpoint class itself, so existing imports, `instanceof`
4
+ * checks and type annotations keep working unchanged.
5
+ */
6
+ import { CheckpointAPIDelegationVerifier } from "./delegation-verifier-checkpoint";
7
+ import { CheckpointProofDestination } from "./proof-batch-queue";
8
+ import { CheckpointToolProtectionSource } from "./tool-protection";
9
+ /** @deprecated Use `CheckpointAPIDelegationVerifier`. */
10
+ export declare const AgentShieldAPIDelegationVerifier: typeof CheckpointAPIDelegationVerifier;
11
+ /** @deprecated Use `CheckpointAPIDelegationVerifier`. */
12
+ export type AgentShieldAPIDelegationVerifier = CheckpointAPIDelegationVerifier;
13
+ /** @deprecated Use `CheckpointProofDestination`. */
14
+ export declare const AgentShieldProofDestination: typeof CheckpointProofDestination;
15
+ /** @deprecated Use `CheckpointProofDestination`. */
16
+ export type AgentShieldProofDestination = CheckpointProofDestination;
17
+ /** @deprecated Use `CheckpointToolProtectionSource`. */
18
+ export declare const AgentShieldToolProtectionSource: typeof CheckpointToolProtectionSource;
19
+ /** @deprecated Use `CheckpointToolProtectionSource`. */
20
+ export type AgentShieldToolProtectionSource = CheckpointToolProtectionSource;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /**
3
+ * The AgentShield-named exports from before these classes took the Checkpoint
4
+ * name. Each is the Checkpoint class itself, so existing imports, `instanceof`
5
+ * checks and type annotations keep working unchanged.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.AgentShieldToolProtectionSource = exports.AgentShieldProofDestination = exports.AgentShieldAPIDelegationVerifier = void 0;
9
+ const delegation_verifier_checkpoint_1 = require("./delegation-verifier-checkpoint");
10
+ const proof_batch_queue_1 = require("./proof-batch-queue");
11
+ const tool_protection_1 = require("./tool-protection");
12
+ /** @deprecated Use `CheckpointAPIDelegationVerifier`. */
13
+ exports.AgentShieldAPIDelegationVerifier = delegation_verifier_checkpoint_1.CheckpointAPIDelegationVerifier;
14
+ /** @deprecated Use `CheckpointProofDestination`. */
15
+ exports.AgentShieldProofDestination = proof_batch_queue_1.CheckpointProofDestination;
16
+ /** @deprecated Use `CheckpointToolProtectionSource`. */
17
+ exports.AgentShieldToolProtectionSource = tool_protection_1.CheckpointToolProtectionSource;