@kya-os/mcp-i-cloudflare 1.14.7 → 1.15.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.
Files changed (152) hide show
  1. package/README.md +8 -8
  2. package/dist/adapter.d.ts.map +1 -1
  3. package/dist/adapter.js +8 -4
  4. package/dist/adapter.js.map +1 -1
  5. package/dist/agent.d.ts +22 -5
  6. package/dist/agent.d.ts.map +1 -1
  7. package/dist/agent.js +88 -46
  8. package/dist/agent.js.map +1 -1
  9. package/dist/app.d.ts.map +1 -1
  10. package/dist/app.js +15 -8
  11. package/dist/app.js.map +1 -1
  12. package/dist/config.d.ts +101 -5
  13. package/dist/config.d.ts.map +1 -1
  14. package/dist/config.js +18 -12
  15. package/dist/config.js.map +1 -1
  16. package/dist/constants.d.ts +5 -3
  17. package/dist/constants.d.ts.map +1 -1
  18. package/dist/constants.js +6 -4
  19. package/dist/constants.js.map +1 -1
  20. package/dist/delegation-http/anchor-registration.d.ts +2 -2
  21. package/dist/delegation-http/anchor-registration.js +4 -4
  22. package/dist/delegation-http/anchor-registration.js.map +1 -1
  23. package/dist/delegation-http/consent-anchor-bridge.js +3 -3
  24. package/dist/delegation-http/consent-anchor-bridge.js.map +1 -1
  25. package/dist/delegation-http/credential-consent.d.ts +2 -2
  26. package/dist/delegation-http/credential-consent.js +14 -14
  27. package/dist/delegation-http/credential-consent.js.map +1 -1
  28. package/dist/delegation-http/native-http.js +5 -5
  29. package/dist/delegation-http/native-http.js.map +1 -1
  30. package/dist/delegation-http/native-oauth-state-do.d.ts +43 -0
  31. package/dist/delegation-http/native-oauth-state-do.d.ts.map +1 -0
  32. package/dist/delegation-http/native-oauth-state-do.js +175 -0
  33. package/dist/delegation-http/native-oauth-state-do.js.map +1 -0
  34. package/dist/delegation-http/native-oauth-state.d.ts +12 -0
  35. package/dist/delegation-http/native-oauth-state.d.ts.map +1 -0
  36. package/dist/delegation-http/native-oauth-state.js +131 -0
  37. package/dist/delegation-http/native-oauth-state.js.map +1 -0
  38. package/dist/delegation-http/native-oauth.d.ts.map +1 -1
  39. package/dist/delegation-http/native-oauth.js +22 -17
  40. package/dist/delegation-http/native-oauth.js.map +1 -1
  41. package/dist/delegation-http/register.js +1 -1
  42. package/dist/delegation-http/register.js.map +1 -1
  43. package/dist/delegation-http/registrar-auth.d.ts +1 -1
  44. package/dist/delegation-http/registrar-auth.js +2 -2
  45. package/dist/delegation-http/registrar-auth.js.map +1 -1
  46. package/dist/delegation-http/remote-issuer.d.ts +1 -1
  47. package/dist/delegation-http/remote-issuer.d.ts.map +1 -1
  48. package/dist/delegation-http/remote-issuer.js +4 -4
  49. package/dist/delegation-http/remote-issuer.js.map +1 -1
  50. package/dist/helpers/env-mapper.d.ts +2 -2
  51. package/dist/helpers/env-mapper.d.ts.map +1 -1
  52. package/dist/helpers/env-mapper.js +21 -14
  53. package/dist/helpers/env-mapper.js.map +1 -1
  54. package/dist/index.d.ts +3 -1
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +4 -3
  57. package/dist/index.js.map +1 -1
  58. package/dist/needs-authorization-meta.d.ts +5 -0
  59. package/dist/needs-authorization-meta.d.ts.map +1 -1
  60. package/dist/needs-authorization-meta.js +9 -0
  61. package/dist/needs-authorization-meta.js.map +1 -1
  62. package/dist/proof-generator.d.ts +3 -3
  63. package/dist/proof-generator.js +4 -4
  64. package/dist/proof-generator.js.map +1 -1
  65. package/dist/runtime/invoke-tool-handler.d.ts +26 -1
  66. package/dist/runtime/invoke-tool-handler.d.ts.map +1 -1
  67. package/dist/runtime/invoke-tool-handler.js +32 -0
  68. package/dist/runtime/invoke-tool-handler.js.map +1 -1
  69. package/dist/runtime/oauth-handler.d.ts +9 -7
  70. package/dist/runtime/oauth-handler.d.ts.map +1 -1
  71. package/dist/runtime/oauth-handler.js +53 -49
  72. package/dist/runtime/oauth-handler.js.map +1 -1
  73. package/dist/runtime/oidc/authorize-url.js +2 -2
  74. package/dist/runtime/oidc/authorize-url.js.map +1 -1
  75. package/dist/runtime/oidc/token-exchange.d.ts +1 -1
  76. package/dist/runtime/oidc/token-exchange.d.ts.map +1 -1
  77. package/dist/runtime/tool-activity.d.ts +56 -0
  78. package/dist/runtime/tool-activity.d.ts.map +1 -0
  79. package/dist/runtime/tool-activity.js +55 -0
  80. package/dist/runtime/tool-activity.js.map +1 -0
  81. package/dist/runtime.d.ts +30 -13
  82. package/dist/runtime.d.ts.map +1 -1
  83. package/dist/runtime.js +71 -18
  84. package/dist/runtime.js.map +1 -1
  85. package/dist/server.d.ts.map +1 -1
  86. package/dist/server.js +17 -15
  87. package/dist/server.js.map +1 -1
  88. package/dist/services/admin.service.d.ts +1 -1
  89. package/dist/services/admin.service.js +13 -13
  90. package/dist/services/admin.service.js.map +1 -1
  91. package/dist/services/consent-config.service.d.ts +5 -5
  92. package/dist/services/consent-config.service.js +12 -12
  93. package/dist/services/consent-config.service.js.map +1 -1
  94. package/dist/services/consent-templates/base/components.d.ts +1 -1
  95. package/dist/services/consent-templates/base/components.js +1 -1
  96. package/dist/services/consent-templates/base/styles.d.ts +2 -2
  97. package/dist/services/consent-templates/base/styles.js +4 -4
  98. package/dist/services/consent-templates/base/styles.js.map +1 -1
  99. package/dist/services/consent-templates/helpers.d.ts +3 -3
  100. package/dist/services/consent-templates/helpers.js +4 -4
  101. package/dist/services/consent-templates/helpers.js.map +1 -1
  102. package/dist/services/consent-templates/index.d.ts +1 -1
  103. package/dist/services/consent-templates/index.js +1 -1
  104. package/dist/services/consent-templates/modes/credentials.template.d.ts +5 -5
  105. package/dist/services/consent-templates/modes/credentials.template.js +9 -9
  106. package/dist/services/consent-templates/modes/credentials.template.js.map +1 -1
  107. package/dist/services/consent-templates/registry.d.ts +3 -3
  108. package/dist/services/consent-templates/registry.js +3 -3
  109. package/dist/services/consent-templates/template-renderer.d.ts +5 -3
  110. package/dist/services/consent-templates/template-renderer.d.ts.map +1 -1
  111. package/dist/services/consent-templates/template-renderer.js +5 -3
  112. package/dist/services/consent-templates/template-renderer.js.map +1 -1
  113. package/dist/services/consent-templates/types.d.ts +4 -4
  114. package/dist/services/consent-templates/types.js +2 -2
  115. package/dist/services/consent.service.d.ts +44 -24
  116. package/dist/services/consent.service.d.ts.map +1 -1
  117. package/dist/services/consent.service.js +197 -119
  118. package/dist/services/consent.service.js.map +1 -1
  119. package/dist/services/delegation-mandate.d.ts +40 -0
  120. package/dist/services/delegation-mandate.d.ts.map +1 -0
  121. package/dist/services/delegation-mandate.js +46 -0
  122. package/dist/services/delegation-mandate.js.map +1 -0
  123. package/dist/services/delegation.service.d.ts +28 -12
  124. package/dist/services/delegation.service.d.ts.map +1 -1
  125. package/dist/services/delegation.service.js +88 -99
  126. package/dist/services/delegation.service.js.map +1 -1
  127. package/dist/services/kya-os-events.service.d.ts +15 -3
  128. package/dist/services/kya-os-events.service.d.ts.map +1 -1
  129. package/dist/services/kya-os-events.service.js +14 -4
  130. package/dist/services/kya-os-events.service.js.map +1 -1
  131. package/dist/services/proof-batch-queue.d.ts +4 -4
  132. package/dist/services/proof-batch-queue.d.ts.map +1 -1
  133. package/dist/services/proof-batch-queue.js +10 -10
  134. package/dist/services/proof-batch-queue.js.map +1 -1
  135. package/dist/services/proof.service.d.ts +64 -5
  136. package/dist/services/proof.service.d.ts.map +1 -1
  137. package/dist/services/proof.service.js +127 -40
  138. package/dist/services/proof.service.js.map +1 -1
  139. package/dist/services/provider-loader.service.d.ts +6 -6
  140. package/dist/services/provider-loader.service.d.ts.map +1 -1
  141. package/dist/services/provider-loader.service.js +4 -4
  142. package/dist/services/provider-loader.service.js.map +1 -1
  143. package/dist/services/vault-resolver.d.ts +4 -4
  144. package/dist/services/vault-resolver.d.ts.map +1 -1
  145. package/dist/services/vault-resolver.js +2 -2
  146. package/dist/types.d.ts +6 -4
  147. package/dist/types.d.ts.map +1 -1
  148. package/dist/utils/day0-config.d.ts +1 -1
  149. package/dist/utils/day0-config.js +1 -1
  150. package/dist/utils/env-secret-resolver.d.ts +1 -1
  151. package/dist/utils/env-secret-resolver.js +1 -1
  152. package/package.json +5 -5
package/dist/agent.js CHANGED
@@ -14,6 +14,7 @@ import { createCloudflareRuntime } from "./index";
14
14
  import { mapPrefixedEnv } from "./helpers/env-mapper";
15
15
  import { makeEnvSecretResolver } from "./utils/env-secret-resolver.js";
16
16
  import { handlePickupInternal } from "./delegation-http/anchor-do";
17
+ import { NATIVE_OAUTH_INTERNAL_PREFIX } from "./delegation-http/native-oauth-state-do";
17
18
  import { augmentKyaOsIdentityWellKnown } from "./delegation-http/well-known-capability";
18
19
  import { resolveCloudflareAuditAssurance } from "./audit/assurance";
19
20
  import { createCloudflareAuditRuntimeFromEnv } from "./audit/deployment-binding";
@@ -41,7 +42,8 @@ import { calculateDOInstanceId, parseDORoutingStrategy, parseDOShardCount, } fro
41
42
  import { defaultProviderRegistry, } from "@kya-os/provider-registry";
42
43
  import { hasApiKeyAuthorization, AuthRequiredError, } from "@kya-os/contracts/tool-protection";
43
44
  import { VaultResolver } from "./services/vault-resolver";
44
- import { invokeToolHandlerOnce } from "./runtime/invoke-tool-handler";
45
+ import { invokeToolHandlerOnce, withVerifiedDelegation, } from "./runtime/invoke-tool-handler";
46
+ import { withCheckpointNames } from "@kya-os/contracts/config";
45
47
  // CRITICAL: Force OAuth registry evaluation at module load time
46
48
  // This creates an observable side effect that esbuild cannot tree-shake
47
49
  // Without this, esbuild may eliminate oauth-service-registry.ts entirely
@@ -77,6 +79,7 @@ export class MCPICloudflareAgent extends McpAgent {
77
79
  mcpiRuntime;
78
80
  env;
79
81
  providerRegistry;
82
+ _runtimeConfig;
80
83
  _environment = "production";
81
84
  _autoDetectedOrigin; // Auto-detected server origin from request URL
82
85
  _clientMessagesConfig; // Client-specific delegation messages
@@ -86,8 +89,9 @@ export class MCPICloudflareAgent extends McpAgent {
86
89
  constructor(state, env, providerRegistry = defaultProviderRegistry) {
87
90
  // Call super() with just state and env (agents@0.2.21+ only accepts 2 parameters)
88
91
  // The config is no longer passed to the constructor - it's set via the server property
89
- super(state, env);
90
- this.env = env;
92
+ const current = withCheckpointNames(env);
93
+ super(state, current);
94
+ this.env = current;
91
95
  this.providerRegistry = providerRegistry;
92
96
  // Get agent configuration from subclass methods
93
97
  const agentName = this.getAgentName();
@@ -99,10 +103,15 @@ export class MCPICloudflareAgent extends McpAgent {
99
103
  name: agentName,
100
104
  version: agentVersion || "1.0.0",
101
105
  });
102
- // Map prefixed environment to standard CloudflareEnv
106
+ // Map prefixed environment to standard CloudflareEnv. Unprefixed, this is
107
+ // a shallow copy: workerd hands the SAME env object to this Durable
108
+ // Object and to the worker's stateless fetch handler, so tagging it
109
+ // directly would leak this DO's state into the app-level runtime, whose
110
+ // identity provider would then write to it from another request
111
+ // ("Cannot perform I/O on behalf of a different request").
103
112
  const mappedEnv = envPrefix
104
- ? mapPrefixedEnv(env, envPrefix)
105
- : env;
113
+ ? mapPrefixedEnv(current, envPrefix)
114
+ : { ...current };
106
115
  // Add DurableObjectState to mapped env for identity persistence
107
116
  mappedEnv._durableObjectState = state;
108
117
  // Load runtime configuration from subclass
@@ -125,18 +134,24 @@ export class MCPICloudflareAgent extends McpAgent {
125
134
  }
126
135
  // Store environment for logging checks
127
136
  this._environment = runtimeConfig.environment || "production";
137
+ // Discovery must use the same effective audit trail as the initialized
138
+ // runtime, including managed bindings absent from the template defaults.
139
+ this._runtimeConfig = runtimeConfig;
128
140
  // Create tool protection service if configured
129
141
  const toolProtectionService = runtimeConfig.toolProtection &&
130
142
  mappedEnv.TOOL_PROTECTION_KV &&
131
- mappedEnv.AGENTSHIELD_API_KEY
143
+ mappedEnv.CHECKPOINT_API_KEY
132
144
  ? CloudflareRuntime.createToolProtectionService(mappedEnv.TOOL_PROTECTION_KV, {
133
- apiUrl: runtimeConfig.toolProtection.agentShield?.apiUrl ||
134
- mappedEnv.AGENTSHIELD_API_URL ||
145
+ apiUrl: (runtimeConfig.toolProtection.checkpoint ??
146
+ runtimeConfig.toolProtection.agentShield)?.apiUrl ||
147
+ mappedEnv.CHECKPOINT_API_URL ||
135
148
  "https://kya.vouched.id",
136
- apiKey: mappedEnv.AGENTSHIELD_API_KEY,
137
- projectId: runtimeConfig.toolProtection.agentShield?.projectId ||
138
- mappedEnv.AGENTSHIELD_PROJECT_ID,
139
- cacheTtl: runtimeConfig.toolProtection.agentShield?.cacheTtl || 300000,
149
+ apiKey: mappedEnv.CHECKPOINT_API_KEY,
150
+ projectId: (runtimeConfig.toolProtection.checkpoint ??
151
+ runtimeConfig.toolProtection.agentShield)?.projectId ||
152
+ mappedEnv.CHECKPOINT_PROJECT_ID,
153
+ cacheTtl: (runtimeConfig.toolProtection.checkpoint ??
154
+ runtimeConfig.toolProtection.agentShield)?.cacheTtl || 300000,
140
155
  debug: runtimeConfig.environment === "development",
141
156
  // Wrap localConfig ToolProtectionMap into ToolProtectionConfig format
142
157
  // The ToolProtectionSourceConfig.localConfig is a BaseToolProtectionMap (Record<string, ToolProtection>)
@@ -226,8 +241,8 @@ export class MCPICloudflareAgent extends McpAgent {
226
241
  const clientIdentity = await resolveClientIdentity(clientInfo, ktaApiUrl);
227
242
  // Store client identity for use in sessions/proofs
228
243
  await this.ctx.storage.put("clientIdentity", clientIdentity);
229
- // Register session with AgentShield (fire-and-forget) - always in production too
230
- await this.registerSessionWithAgentShield(clientInfo, clientIdentity, protocolVersion);
244
+ // Register session with Checkpoint (fire-and-forget) - always in production too
245
+ await this.registerSessionWithCheckpoint(clientInfo, clientIdentity, protocolVersion);
231
246
  // Skip balloon logging in production (only skip the visual output)
232
247
  if (this._environment !== "development")
233
248
  return;
@@ -395,10 +410,10 @@ export class MCPICloudflareAgent extends McpAgent {
395
410
  }
396
411
  }
397
412
  /**
398
- * Register session with AgentShield for dashboard visibility
413
+ * Register session with Checkpoint for dashboard visibility
399
414
  * This is a fire-and-forget operation - failures are logged but don't block
400
415
  */
401
- async registerSessionWithAgentShield(clientInfo, clientIdentity, protocolVersion) {
416
+ async registerSessionWithCheckpoint(clientInfo, clientIdentity, protocolVersion) {
402
417
  try {
403
418
  const envPrefix = this.getEnvPrefix();
404
419
  const mappedEnv = envPrefix
@@ -422,9 +437,9 @@ export class MCPICloudflareAgent extends McpAgent {
422
437
  // ✅ CRITICAL: Initialize session storage with ephemeral identity FIRST
423
438
  // This ensures every session has a userDid before any delegation operations
424
439
  await this.initializeSessionStorage(sessionId);
425
- // Check if we have the required config for AgentShield registration
426
- if (!mappedEnv.AGENTSHIELD_API_KEY || !mappedEnv.AGENTSHIELD_PROJECT_ID) {
427
- // Skip AgentShield registration - but session storage was still initialized above
440
+ // Check if we have the required config for Checkpoint registration
441
+ if (!mappedEnv.CHECKPOINT_API_KEY || !mappedEnv.CHECKPOINT_PROJECT_ID) {
442
+ // Skip Checkpoint registration - but session storage was still initialized above
428
443
  return;
429
444
  }
430
445
  // Get agent DID
@@ -441,21 +456,21 @@ export class MCPICloudflareAgent extends McpAgent {
441
456
  fetch: (url, options) => fetch(url, options),
442
457
  };
443
458
  const service = new SessionRegistrationService({
444
- baseUrl: mappedEnv.AGENTSHIELD_API_URL || "https://kya.vouched.id",
445
- apiKey: mappedEnv.AGENTSHIELD_API_KEY,
459
+ baseUrl: mappedEnv.CHECKPOINT_API_URL || "https://kya.vouched.id",
460
+ apiKey: mappedEnv.CHECKPOINT_API_KEY,
446
461
  fetchProvider,
447
462
  logger: this._environment === "development"
448
463
  ? (msg, data) => logger.debug(msg, data)
449
464
  : undefined,
450
465
  });
451
466
  // Register session (fire-and-forget)
452
- // Include agent_name for AgentShield dashboard display
467
+ // Include agent_name for Checkpoint dashboard display
453
468
  const agentName = this.getAgentName() || mappedEnv.MCP_SERVER_NAME || undefined;
454
469
  service.registerSessionAsync({
455
470
  session_id: sessionId,
456
471
  agent_did: identity.did,
457
472
  agent_name: agentName, // Human-readable name for dashboard
458
- project_id: mappedEnv.AGENTSHIELD_PROJECT_ID,
473
+ project_id: mappedEnv.CHECKPOINT_PROJECT_ID,
459
474
  created_at: Date.now(),
460
475
  client_info: {
461
476
  name: clientInfo?.name || "Unidentified",
@@ -532,6 +547,23 @@ export class MCPICloudflareAgent extends McpAgent {
532
547
  setClientMessagesConfig(config) {
533
548
  this._clientMessagesConfig = config;
534
549
  }
550
+ /**
551
+ * The delegation verifier the runtime uses for protected tool calls.
552
+ *
553
+ * Subclasses can ask the same verifier a question the runtime would ask,
554
+ * with the same credentials and base URL, instead of building their own
555
+ * client. Undefined when no CHECKPOINT_API_KEY is configured (the runtime
556
+ * then has no remote verifier either).
557
+ *
558
+ * @example
559
+ * ```typescript
560
+ * const verifier = this.getDelegationVerifier();
561
+ * const result = await verifier?.verifyDelegation({ agent_did, scopes, delegation_token });
562
+ * ```
563
+ */
564
+ getDelegationVerifier() {
565
+ return this.mcpiRuntime?.getAccessControlService();
566
+ }
535
567
  /**
536
568
  * Whether to attach a popup-launch hint when this client supports it.
537
569
  * Subclasses may override; defaults to `true` so popup-aware clients
@@ -1403,7 +1435,7 @@ export class MCPICloudflareAgent extends McpAgent {
1403
1435
  ? "MCP_SERVER_URL env var"
1404
1436
  : this._autoDetectedOrigin
1405
1437
  ? "auto-detected from request"
1406
- : "none (will use AgentShield fallback)",
1438
+ : "none (will use Checkpoint fallback)",
1407
1439
  serverUrl: serverUrl?.slice(0, 50) || "undefined",
1408
1440
  });
1409
1441
  }
@@ -1537,11 +1569,11 @@ export class MCPICloudflareAgent extends McpAgent {
1537
1569
  agentDid: getMcpRequestHolder()?.did ?? (await this.mcpiRuntime.getIdentity()).did,
1538
1570
  // Trusted per-request proof result; never a client-supplied DID label.
1539
1571
  verifiedInvokerDid: getMcpRequestHolder()?.did,
1540
- agentName: this.getAgentName() || mappedEnv.MCP_SERVER_NAME || "Unknown Agent", // Human-readable agent name for AgentShield dashboard
1572
+ agentName: this.getAgentName() || mappedEnv.MCP_SERVER_NAME || "Unknown Agent", // Human-readable agent name for Checkpoint dashboard
1541
1573
  createdAt: timestamp,
1542
1574
  expiresAt: timestamp + 30 * 60 * 1000, // 30 minutes
1543
1575
  serverOrigin: serverUrl, // Use MCP_SERVER_URL for consent URL building
1544
- projectId: mappedEnv.AGENTSHIELD_PROJECT_ID || "", // For inline consent UI approve POST
1576
+ projectId: mappedEnv.CHECKPOINT_PROJECT_ID || "", // For inline consent UI approve POST
1545
1577
  delegationToken, // ✅ Include token in session if found
1546
1578
  delegationId, // ✅ Include delegationId for proof submission attribution
1547
1579
  userDid, // ✅ FIX: Include userDid in session for ToolExecutionContext propagation
@@ -1765,8 +1797,10 @@ export class MCPICloudflareAgent extends McpAgent {
1765
1797
  // For backward compatibility, handlers can accept (args) or (args, context)
1766
1798
  // JavaScript handlers safely ignore extra arguments. Never retry a handler
1767
1799
  // after it throws: doing so can duplicate irreversible tool side effects.
1768
- const handlerWithContext = async (handlerArgs) => {
1769
- return invokeToolHandlerOnce(handler, handlerArgs, toolContext);
1800
+ // The runtime passes `verified` only from THIS call's successful verify, so
1801
+ // the grant a handler enforces is never read from storage or the token.
1802
+ const handlerWithContext = async (handlerArgs, verified) => {
1803
+ return invokeToolHandlerOnce(handler, handlerArgs, withVerifiedDelegation(toolContext, verified, { sessionId, userDid }));
1770
1804
  };
1771
1805
  // Execute tool with automatic proof generation
1772
1806
  // If inline credential UI was prepared, return it directly (no error throw needed)
@@ -1819,6 +1853,9 @@ export class MCPICloudflareAgent extends McpAgent {
1819
1853
  consentUrl: delegationError.consentUrl,
1820
1854
  scopes,
1821
1855
  clientId,
1856
+ // A verifier refusal (revoked, expired, wrong agent) gets its
1857
+ // configured per-code line; without one the text stays as today.
1858
+ denial: delegationError.denial,
1822
1859
  });
1823
1860
  // Popup launch — only attached as a hint in `_meta` so popup-aware
1824
1861
  // clients (today: `.mcpb`-installed Claude Desktop) can open the
@@ -1942,9 +1979,9 @@ export class MCPICloudflareAgent extends McpAgent {
1942
1979
  * @private
1943
1980
  */
1944
1981
  async buildToolContext(toolName, userDid, sessionId, delegationToken, delegationAuthorizationType, env) {
1945
- // Only build context if userDid is available and AgentShield API is configured.
1982
+ // Only build context if userDid is available and Checkpoint API is configured.
1946
1983
  // Note: DELEGATION_STORAGE is only required for password/OAuth paths, not apikey vault.
1947
- if (!userDid || !env.AGENTSHIELD_API_KEY) {
1984
+ if (!userDid || !env.CHECKPOINT_API_KEY) {
1948
1985
  return undefined;
1949
1986
  }
1950
1987
  // Check if tool protection service is available
@@ -2128,7 +2165,7 @@ export class MCPICloudflareAgent extends McpAgent {
2128
2165
  return undefined;
2129
2166
  }
2130
2167
  }
2131
- // For API key vault tools, resolve per-user secrets from AgentShield vault.
2168
+ // For API key vault tools, resolve per-user secrets from Checkpoint vault.
2132
2169
  // This follows the same early-return pattern as isPasswordAuth above.
2133
2170
  if (hasApiKeyAuthorization(protection)) {
2134
2171
  const projectId = toolProtectionService.getProjectId();
@@ -2169,8 +2206,8 @@ export class MCPICloudflareAgent extends McpAgent {
2169
2206
  pkcs8.set(rawKey, pkcs8Header.length);
2170
2207
  const identityKey = await crypto.subtle.importKey("pkcs8", pkcs8.buffer, { name: "Ed25519", namedCurve: "Ed25519" }, false, ["sign"]);
2171
2208
  this._vaultResolver = new VaultResolver({
2172
- apiUrl: env.AGENTSHIELD_API_URL || "https://kya.vouched.id",
2173
- apiKey: env.AGENTSHIELD_API_KEY,
2209
+ apiUrl: env.CHECKPOINT_API_URL || "https://kya.vouched.id",
2210
+ apiKey: env.CHECKPOINT_API_KEY,
2174
2211
  identityKey,
2175
2212
  agentDid: identity.did,
2176
2213
  });
@@ -2195,7 +2232,7 @@ export class MCPICloudflareAgent extends McpAgent {
2195
2232
  return undefined;
2196
2233
  }
2197
2234
  // No vault secrets AND no static env — throw structured error
2198
- const apiUrl = env.AGENTSHIELD_API_URL || "https://kya.vouched.id";
2235
+ const apiUrl = env.CHECKPOINT_API_URL || "https://kya.vouched.id";
2199
2236
  // Use /dashboard/projects/{id} path — works without orgId and
2200
2237
  // the dashboard redirects to the correct org-scoped route.
2201
2238
  const configUrl = `${apiUrl}/dashboard/projects/${projectId}/settings`;
@@ -2256,8 +2293,8 @@ export class MCPICloudflareAgent extends McpAgent {
2256
2293
  ? new KVOAuthConfigCache({ kv: env.TOOL_PROTECTION_KV })
2257
2294
  : undefined;
2258
2295
  const oauthConfigService = new ConfigService({
2259
- baseUrl: env.AGENTSHIELD_API_URL || "https://kya.vouched.id",
2260
- apiKey: env.AGENTSHIELD_API_KEY,
2296
+ baseUrl: env.CHECKPOINT_API_URL || "https://kya.vouched.id",
2297
+ apiKey: env.CHECKPOINT_API_KEY,
2261
2298
  fetchProvider,
2262
2299
  cache: oauthConfigCache,
2263
2300
  });
@@ -2266,8 +2303,8 @@ export class MCPICloudflareAgent extends McpAgent {
2266
2303
  const oauthService = new OAuthService({
2267
2304
  configService: oauthConfigService,
2268
2305
  fetchProvider,
2269
- agentShieldApiUrl: env.AGENTSHIELD_API_URL || "https://kya.vouched.id",
2270
- agentShieldApiKey: env.AGENTSHIELD_API_KEY,
2306
+ checkpointApiUrl: env.CHECKPOINT_API_URL || "https://kya.vouched.id",
2307
+ checkpointApiKey: env.CHECKPOINT_API_KEY,
2271
2308
  projectId,
2272
2309
  // WFP fix (see makeEnvSecretResolver): resolve the client secret from the
2273
2310
  // RAW worker env. We pass `this.env`, NOT the `env` param — `env` here is
@@ -2381,9 +2418,9 @@ export class MCPICloudflareAgent extends McpAgent {
2381
2418
  const agentDid = getMcpRequestHolder()?.did ?? (await this.mcpiRuntime.getIdentity()).did;
2382
2419
  // Determine the OAuth provider from the error or discover from config
2383
2420
  let provider = error.provider;
2384
- // If no provider specified, try to discover from AgentShield config
2421
+ // If no provider specified, try to discover from Checkpoint config
2385
2422
  if (!provider) {
2386
- const agentShieldUrl = env.AGENTSHIELD_API_URL || "https://kya.vouched.id";
2423
+ const checkpointUrl = env.CHECKPOINT_API_URL || "https://kya.vouched.id";
2387
2424
  const oauthServices = isOAuthServicesAvailable()
2388
2425
  ? getOAuthServices()
2389
2426
  : null;
@@ -2394,13 +2431,13 @@ export class MCPICloudflareAgent extends McpAgent {
2394
2431
  kv: env.TOOL_PROTECTION_KV,
2395
2432
  });
2396
2433
  const configService = new OAuthConfigService({
2397
- baseUrl: agentShieldUrl,
2398
- apiKey: env.AGENTSHIELD_API_KEY || "",
2434
+ baseUrl: checkpointUrl,
2435
+ apiKey: env.CHECKPOINT_API_KEY || "",
2399
2436
  fetchProvider: new WorkersFetchProvider(),
2400
2437
  cache: oauthConfigCache,
2401
2438
  });
2402
2439
  const registry = new OAuthProviderRegistry(configService);
2403
- await registry.loadFromAgentShield(projectId);
2440
+ await registry.loadFromCheckpoint(projectId);
2404
2441
  const discoveredProvider = registry.getConfiguredProvider();
2405
2442
  if (discoveredProvider) {
2406
2443
  provider = discoveredProvider;
@@ -2515,6 +2552,11 @@ export class MCPICloudflareAgent extends McpAgent {
2515
2552
  */
2516
2553
  async fetch(request) {
2517
2554
  const url = new URL(request.url);
2555
+ // Native state moved to its own binding/class. Refuse obsolete internal
2556
+ // dispatch without initializing MCP or touching the shared Agent scheduler.
2557
+ if (url.pathname.startsWith(NATIVE_OAUTH_INTERNAL_PREFIX)) {
2558
+ return new Response(null, { status: 404 });
2559
+ }
2518
2560
  // draft-kya-http-02 §13 pickup-anchor dispatch.
2519
2561
  // These requests target dedicated `pickup:<sid>` durable-object instances and
2520
2562
  // must run BEFORE any origin detection, handshake-session side effects, or
@@ -2712,7 +2754,7 @@ export class MCPICloudflareAgent extends McpAgent {
2712
2754
  : this.env;
2713
2755
  const runtimeConfig = this.getRuntimeConfigInternal(mappedEnv);
2714
2756
  const httpChallengeCfg = resolveHttpChallengeConfig(runtimeConfig, mappedEnv);
2715
- const augmented = augmentKyaOsIdentityWellKnown(wellKnownPath, result, httpChallengeCfg, isAnchorRegistrationEnabled(httpChallengeCfg, mappedEnv), resolveCloudflareAuditAssurance(runtimeConfig));
2757
+ const augmented = augmentKyaOsIdentityWellKnown(wellKnownPath, result, httpChallengeCfg, isAnchorRegistrationEnabled(httpChallengeCfg, mappedEnv), resolveCloudflareAuditAssurance(this._runtimeConfig));
2716
2758
  return new Response(JSON.stringify(augmented), {
2717
2759
  status: 200,
2718
2760
  headers: { "Content-Type": "application/json" },
@@ -2997,7 +3039,7 @@ export class MCPICloudflareAgent extends McpAgent {
2997
3039
  ?.toolProtectionService;
2998
3040
  // Also clear consent config cache
2999
3041
  try {
3000
- const projectId = this.env.AGENTSHIELD_PROJECT_ID;
3042
+ const projectId = this.env.CHECKPOINT_PROJECT_ID;
3001
3043
  if (projectId && this.env.TOOL_PROTECTION_KV) {
3002
3044
  // Clear the consent config cache key directly
3003
3045
  const consentCacheKey = `consent:config:${projectId}`;