@kya-os/mcp-i-cloudflare 1.14.7 → 1.14.8

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 (149) hide show
  1. package/README.md +7 -7
  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 +21 -4
  6. package/dist/agent.d.ts.map +1 -1
  7. package/dist/agent.js +78 -39
  8. package/dist/agent.js.map +1 -1
  9. package/dist/app.d.ts.map +1 -1
  10. package/dist/app.js +10 -4
  11. package/dist/app.js.map +1 -1
  12. package/dist/config.d.ts +99 -4
  13. package/dist/config.d.ts.map +1 -1
  14. package/dist/config.js +15 -11
  15. package/dist/config.js.map +1 -1
  16. package/dist/constants.d.ts +3 -3
  17. package/dist/constants.js +3 -3
  18. package/dist/delegation-http/anchor-registration.d.ts +2 -2
  19. package/dist/delegation-http/anchor-registration.js +4 -4
  20. package/dist/delegation-http/anchor-registration.js.map +1 -1
  21. package/dist/delegation-http/consent-anchor-bridge.js +3 -3
  22. package/dist/delegation-http/consent-anchor-bridge.js.map +1 -1
  23. package/dist/delegation-http/credential-consent.d.ts +2 -2
  24. package/dist/delegation-http/credential-consent.js +10 -10
  25. package/dist/delegation-http/credential-consent.js.map +1 -1
  26. package/dist/delegation-http/native-http.js +5 -5
  27. package/dist/delegation-http/native-http.js.map +1 -1
  28. package/dist/delegation-http/native-oauth-state-do.d.ts +43 -0
  29. package/dist/delegation-http/native-oauth-state-do.d.ts.map +1 -0
  30. package/dist/delegation-http/native-oauth-state-do.js +175 -0
  31. package/dist/delegation-http/native-oauth-state-do.js.map +1 -0
  32. package/dist/delegation-http/native-oauth-state.d.ts +12 -0
  33. package/dist/delegation-http/native-oauth-state.d.ts.map +1 -0
  34. package/dist/delegation-http/native-oauth-state.js +131 -0
  35. package/dist/delegation-http/native-oauth-state.js.map +1 -0
  36. package/dist/delegation-http/native-oauth.d.ts.map +1 -1
  37. package/dist/delegation-http/native-oauth.js +22 -17
  38. package/dist/delegation-http/native-oauth.js.map +1 -1
  39. package/dist/delegation-http/register.js +1 -1
  40. package/dist/delegation-http/register.js.map +1 -1
  41. package/dist/delegation-http/registrar-auth.d.ts +1 -1
  42. package/dist/delegation-http/registrar-auth.js +2 -2
  43. package/dist/delegation-http/registrar-auth.js.map +1 -1
  44. package/dist/delegation-http/remote-issuer.d.ts +1 -1
  45. package/dist/delegation-http/remote-issuer.d.ts.map +1 -1
  46. package/dist/delegation-http/remote-issuer.js +4 -4
  47. package/dist/delegation-http/remote-issuer.js.map +1 -1
  48. package/dist/helpers/env-mapper.d.ts +2 -2
  49. package/dist/helpers/env-mapper.d.ts.map +1 -1
  50. package/dist/helpers/env-mapper.js +21 -14
  51. package/dist/helpers/env-mapper.js.map +1 -1
  52. package/dist/index.d.ts +3 -1
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +4 -3
  55. package/dist/index.js.map +1 -1
  56. package/dist/needs-authorization-meta.d.ts +5 -0
  57. package/dist/needs-authorization-meta.d.ts.map +1 -1
  58. package/dist/needs-authorization-meta.js +9 -0
  59. package/dist/needs-authorization-meta.js.map +1 -1
  60. package/dist/proof-generator.d.ts +3 -3
  61. package/dist/proof-generator.js +4 -4
  62. package/dist/proof-generator.js.map +1 -1
  63. package/dist/runtime/invoke-tool-handler.d.ts +26 -1
  64. package/dist/runtime/invoke-tool-handler.d.ts.map +1 -1
  65. package/dist/runtime/invoke-tool-handler.js +32 -0
  66. package/dist/runtime/invoke-tool-handler.js.map +1 -1
  67. package/dist/runtime/oauth-handler.d.ts +6 -4
  68. package/dist/runtime/oauth-handler.d.ts.map +1 -1
  69. package/dist/runtime/oauth-handler.js +39 -35
  70. package/dist/runtime/oauth-handler.js.map +1 -1
  71. package/dist/runtime/oidc/authorize-url.js +2 -2
  72. package/dist/runtime/oidc/authorize-url.js.map +1 -1
  73. package/dist/runtime/oidc/token-exchange.d.ts +1 -1
  74. package/dist/runtime/oidc/token-exchange.d.ts.map +1 -1
  75. package/dist/runtime/tool-activity.d.ts +56 -0
  76. package/dist/runtime/tool-activity.d.ts.map +1 -0
  77. package/dist/runtime/tool-activity.js +55 -0
  78. package/dist/runtime/tool-activity.js.map +1 -0
  79. package/dist/runtime.d.ts +30 -13
  80. package/dist/runtime.d.ts.map +1 -1
  81. package/dist/runtime.js +71 -18
  82. package/dist/runtime.js.map +1 -1
  83. package/dist/server.d.ts.map +1 -1
  84. package/dist/server.js +17 -15
  85. package/dist/server.js.map +1 -1
  86. package/dist/services/admin.service.d.ts +1 -1
  87. package/dist/services/admin.service.js +9 -9
  88. package/dist/services/admin.service.js.map +1 -1
  89. package/dist/services/consent-config.service.d.ts +5 -5
  90. package/dist/services/consent-config.service.js +10 -10
  91. package/dist/services/consent-config.service.js.map +1 -1
  92. package/dist/services/consent-templates/base/components.d.ts +1 -1
  93. package/dist/services/consent-templates/base/components.js +1 -1
  94. package/dist/services/consent-templates/base/styles.d.ts +2 -2
  95. package/dist/services/consent-templates/base/styles.js +4 -4
  96. package/dist/services/consent-templates/base/styles.js.map +1 -1
  97. package/dist/services/consent-templates/helpers.d.ts +3 -3
  98. package/dist/services/consent-templates/helpers.js +4 -4
  99. package/dist/services/consent-templates/helpers.js.map +1 -1
  100. package/dist/services/consent-templates/index.d.ts +1 -1
  101. package/dist/services/consent-templates/index.js +1 -1
  102. package/dist/services/consent-templates/modes/credentials.template.d.ts +5 -5
  103. package/dist/services/consent-templates/modes/credentials.template.js +9 -9
  104. package/dist/services/consent-templates/modes/credentials.template.js.map +1 -1
  105. package/dist/services/consent-templates/registry.d.ts +3 -3
  106. package/dist/services/consent-templates/registry.js +3 -3
  107. package/dist/services/consent-templates/template-renderer.d.ts +5 -3
  108. package/dist/services/consent-templates/template-renderer.d.ts.map +1 -1
  109. package/dist/services/consent-templates/template-renderer.js +5 -3
  110. package/dist/services/consent-templates/template-renderer.js.map +1 -1
  111. package/dist/services/consent-templates/types.d.ts +4 -4
  112. package/dist/services/consent-templates/types.js +2 -2
  113. package/dist/services/consent.service.d.ts +43 -23
  114. package/dist/services/consent.service.d.ts.map +1 -1
  115. package/dist/services/consent.service.js +178 -100
  116. package/dist/services/consent.service.js.map +1 -1
  117. package/dist/services/delegation-mandate.d.ts +40 -0
  118. package/dist/services/delegation-mandate.d.ts.map +1 -0
  119. package/dist/services/delegation-mandate.js +46 -0
  120. package/dist/services/delegation-mandate.js.map +1 -0
  121. package/dist/services/delegation.service.d.ts +3 -3
  122. package/dist/services/delegation.service.js +10 -10
  123. package/dist/services/delegation.service.js.map +1 -1
  124. package/dist/services/kya-os-events.service.d.ts +15 -3
  125. package/dist/services/kya-os-events.service.d.ts.map +1 -1
  126. package/dist/services/kya-os-events.service.js +14 -4
  127. package/dist/services/kya-os-events.service.js.map +1 -1
  128. package/dist/services/proof-batch-queue.d.ts +3 -3
  129. package/dist/services/proof-batch-queue.d.ts.map +1 -1
  130. package/dist/services/proof-batch-queue.js +9 -9
  131. package/dist/services/proof-batch-queue.js.map +1 -1
  132. package/dist/services/proof.service.d.ts +63 -4
  133. package/dist/services/proof.service.d.ts.map +1 -1
  134. package/dist/services/proof.service.js +114 -27
  135. package/dist/services/proof.service.js.map +1 -1
  136. package/dist/services/provider-loader.service.d.ts +6 -6
  137. package/dist/services/provider-loader.service.d.ts.map +1 -1
  138. package/dist/services/provider-loader.service.js +4 -4
  139. package/dist/services/provider-loader.service.js.map +1 -1
  140. package/dist/services/vault-resolver.d.ts +4 -4
  141. package/dist/services/vault-resolver.d.ts.map +1 -1
  142. package/dist/services/vault-resolver.js +2 -2
  143. package/dist/types.d.ts +6 -4
  144. package/dist/types.d.ts.map +1 -1
  145. package/dist/utils/day0-config.d.ts +1 -1
  146. package/dist/utils/day0-config.js +1 -1
  147. package/dist/utils/env-secret-resolver.d.ts +1 -1
  148. package/dist/utils/env-secret-resolver.js +1 -1
  149. 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,17 +134,20 @@ 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
145
  apiUrl: runtimeConfig.toolProtection.agentShield?.apiUrl ||
134
- mappedEnv.AGENTSHIELD_API_URL ||
146
+ mappedEnv.CHECKPOINT_API_URL ||
135
147
  "https://kya.vouched.id",
136
- apiKey: mappedEnv.AGENTSHIELD_API_KEY,
148
+ apiKey: mappedEnv.CHECKPOINT_API_KEY,
137
149
  projectId: runtimeConfig.toolProtection.agentShield?.projectId ||
138
- mappedEnv.AGENTSHIELD_PROJECT_ID,
150
+ mappedEnv.CHECKPOINT_PROJECT_ID,
139
151
  cacheTtl: runtimeConfig.toolProtection.agentShield?.cacheTtl || 300000,
140
152
  debug: runtimeConfig.environment === "development",
141
153
  // Wrap localConfig ToolProtectionMap into ToolProtectionConfig format
@@ -226,7 +238,7 @@ export class MCPICloudflareAgent extends McpAgent {
226
238
  const clientIdentity = await resolveClientIdentity(clientInfo, ktaApiUrl);
227
239
  // Store client identity for use in sessions/proofs
228
240
  await this.ctx.storage.put("clientIdentity", clientIdentity);
229
- // Register session with AgentShield (fire-and-forget) - always in production too
241
+ // Register session with Checkpoint (fire-and-forget) - always in production too
230
242
  await this.registerSessionWithAgentShield(clientInfo, clientIdentity, protocolVersion);
231
243
  // Skip balloon logging in production (only skip the visual output)
232
244
  if (this._environment !== "development")
@@ -395,7 +407,7 @@ export class MCPICloudflareAgent extends McpAgent {
395
407
  }
396
408
  }
397
409
  /**
398
- * Register session with AgentShield for dashboard visibility
410
+ * Register session with Checkpoint for dashboard visibility
399
411
  * This is a fire-and-forget operation - failures are logged but don't block
400
412
  */
401
413
  async registerSessionWithAgentShield(clientInfo, clientIdentity, protocolVersion) {
@@ -422,9 +434,9 @@ export class MCPICloudflareAgent extends McpAgent {
422
434
  // ✅ CRITICAL: Initialize session storage with ephemeral identity FIRST
423
435
  // This ensures every session has a userDid before any delegation operations
424
436
  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
437
+ // Check if we have the required config for Checkpoint registration
438
+ if (!mappedEnv.CHECKPOINT_API_KEY || !mappedEnv.CHECKPOINT_PROJECT_ID) {
439
+ // Skip Checkpoint registration - but session storage was still initialized above
428
440
  return;
429
441
  }
430
442
  // Get agent DID
@@ -441,21 +453,21 @@ export class MCPICloudflareAgent extends McpAgent {
441
453
  fetch: (url, options) => fetch(url, options),
442
454
  };
443
455
  const service = new SessionRegistrationService({
444
- baseUrl: mappedEnv.AGENTSHIELD_API_URL || "https://kya.vouched.id",
445
- apiKey: mappedEnv.AGENTSHIELD_API_KEY,
456
+ baseUrl: mappedEnv.CHECKPOINT_API_URL || "https://kya.vouched.id",
457
+ apiKey: mappedEnv.CHECKPOINT_API_KEY,
446
458
  fetchProvider,
447
459
  logger: this._environment === "development"
448
460
  ? (msg, data) => logger.debug(msg, data)
449
461
  : undefined,
450
462
  });
451
463
  // Register session (fire-and-forget)
452
- // Include agent_name for AgentShield dashboard display
464
+ // Include agent_name for Checkpoint dashboard display
453
465
  const agentName = this.getAgentName() || mappedEnv.MCP_SERVER_NAME || undefined;
454
466
  service.registerSessionAsync({
455
467
  session_id: sessionId,
456
468
  agent_did: identity.did,
457
469
  agent_name: agentName, // Human-readable name for dashboard
458
- project_id: mappedEnv.AGENTSHIELD_PROJECT_ID,
470
+ project_id: mappedEnv.CHECKPOINT_PROJECT_ID,
459
471
  created_at: Date.now(),
460
472
  client_info: {
461
473
  name: clientInfo?.name || "Unidentified",
@@ -532,6 +544,23 @@ export class MCPICloudflareAgent extends McpAgent {
532
544
  setClientMessagesConfig(config) {
533
545
  this._clientMessagesConfig = config;
534
546
  }
547
+ /**
548
+ * The delegation verifier the runtime uses for protected tool calls.
549
+ *
550
+ * Subclasses can ask the same verifier a question the runtime would ask,
551
+ * with the same credentials and base URL, instead of building their own
552
+ * client. Undefined when no CHECKPOINT_API_KEY is configured (the runtime
553
+ * then has no remote verifier either).
554
+ *
555
+ * @example
556
+ * ```typescript
557
+ * const verifier = this.getDelegationVerifier();
558
+ * const result = await verifier?.verifyDelegation({ agent_did, scopes, delegation_token });
559
+ * ```
560
+ */
561
+ getDelegationVerifier() {
562
+ return this.mcpiRuntime?.getAccessControlService();
563
+ }
535
564
  /**
536
565
  * Whether to attach a popup-launch hint when this client supports it.
537
566
  * Subclasses may override; defaults to `true` so popup-aware clients
@@ -1403,7 +1432,7 @@ export class MCPICloudflareAgent extends McpAgent {
1403
1432
  ? "MCP_SERVER_URL env var"
1404
1433
  : this._autoDetectedOrigin
1405
1434
  ? "auto-detected from request"
1406
- : "none (will use AgentShield fallback)",
1435
+ : "none (will use Checkpoint fallback)",
1407
1436
  serverUrl: serverUrl?.slice(0, 50) || "undefined",
1408
1437
  });
1409
1438
  }
@@ -1537,11 +1566,11 @@ export class MCPICloudflareAgent extends McpAgent {
1537
1566
  agentDid: getMcpRequestHolder()?.did ?? (await this.mcpiRuntime.getIdentity()).did,
1538
1567
  // Trusted per-request proof result; never a client-supplied DID label.
1539
1568
  verifiedInvokerDid: getMcpRequestHolder()?.did,
1540
- agentName: this.getAgentName() || mappedEnv.MCP_SERVER_NAME || "Unknown Agent", // Human-readable agent name for AgentShield dashboard
1569
+ agentName: this.getAgentName() || mappedEnv.MCP_SERVER_NAME || "Unknown Agent", // Human-readable agent name for Checkpoint dashboard
1541
1570
  createdAt: timestamp,
1542
1571
  expiresAt: timestamp + 30 * 60 * 1000, // 30 minutes
1543
1572
  serverOrigin: serverUrl, // Use MCP_SERVER_URL for consent URL building
1544
- projectId: mappedEnv.AGENTSHIELD_PROJECT_ID || "", // For inline consent UI approve POST
1573
+ projectId: mappedEnv.CHECKPOINT_PROJECT_ID || "", // For inline consent UI approve POST
1545
1574
  delegationToken, // ✅ Include token in session if found
1546
1575
  delegationId, // ✅ Include delegationId for proof submission attribution
1547
1576
  userDid, // ✅ FIX: Include userDid in session for ToolExecutionContext propagation
@@ -1765,8 +1794,10 @@ export class MCPICloudflareAgent extends McpAgent {
1765
1794
  // For backward compatibility, handlers can accept (args) or (args, context)
1766
1795
  // JavaScript handlers safely ignore extra arguments. Never retry a handler
1767
1796
  // after it throws: doing so can duplicate irreversible tool side effects.
1768
- const handlerWithContext = async (handlerArgs) => {
1769
- return invokeToolHandlerOnce(handler, handlerArgs, toolContext);
1797
+ // The runtime passes `verified` only from THIS call's successful verify, so
1798
+ // the grant a handler enforces is never read from storage or the token.
1799
+ const handlerWithContext = async (handlerArgs, verified) => {
1800
+ return invokeToolHandlerOnce(handler, handlerArgs, withVerifiedDelegation(toolContext, verified, { sessionId, userDid }));
1770
1801
  };
1771
1802
  // Execute tool with automatic proof generation
1772
1803
  // If inline credential UI was prepared, return it directly (no error throw needed)
@@ -1819,6 +1850,9 @@ export class MCPICloudflareAgent extends McpAgent {
1819
1850
  consentUrl: delegationError.consentUrl,
1820
1851
  scopes,
1821
1852
  clientId,
1853
+ // A verifier refusal (revoked, expired, wrong agent) gets its
1854
+ // configured per-code line; without one the text stays as today.
1855
+ denial: delegationError.denial,
1822
1856
  });
1823
1857
  // Popup launch — only attached as a hint in `_meta` so popup-aware
1824
1858
  // clients (today: `.mcpb`-installed Claude Desktop) can open the
@@ -1942,9 +1976,9 @@ export class MCPICloudflareAgent extends McpAgent {
1942
1976
  * @private
1943
1977
  */
1944
1978
  async buildToolContext(toolName, userDid, sessionId, delegationToken, delegationAuthorizationType, env) {
1945
- // Only build context if userDid is available and AgentShield API is configured.
1979
+ // Only build context if userDid is available and Checkpoint API is configured.
1946
1980
  // Note: DELEGATION_STORAGE is only required for password/OAuth paths, not apikey vault.
1947
- if (!userDid || !env.AGENTSHIELD_API_KEY) {
1981
+ if (!userDid || !env.CHECKPOINT_API_KEY) {
1948
1982
  return undefined;
1949
1983
  }
1950
1984
  // Check if tool protection service is available
@@ -2128,7 +2162,7 @@ export class MCPICloudflareAgent extends McpAgent {
2128
2162
  return undefined;
2129
2163
  }
2130
2164
  }
2131
- // For API key vault tools, resolve per-user secrets from AgentShield vault.
2165
+ // For API key vault tools, resolve per-user secrets from Checkpoint vault.
2132
2166
  // This follows the same early-return pattern as isPasswordAuth above.
2133
2167
  if (hasApiKeyAuthorization(protection)) {
2134
2168
  const projectId = toolProtectionService.getProjectId();
@@ -2169,8 +2203,8 @@ export class MCPICloudflareAgent extends McpAgent {
2169
2203
  pkcs8.set(rawKey, pkcs8Header.length);
2170
2204
  const identityKey = await crypto.subtle.importKey("pkcs8", pkcs8.buffer, { name: "Ed25519", namedCurve: "Ed25519" }, false, ["sign"]);
2171
2205
  this._vaultResolver = new VaultResolver({
2172
- apiUrl: env.AGENTSHIELD_API_URL || "https://kya.vouched.id",
2173
- apiKey: env.AGENTSHIELD_API_KEY,
2206
+ apiUrl: env.CHECKPOINT_API_URL || "https://kya.vouched.id",
2207
+ apiKey: env.CHECKPOINT_API_KEY,
2174
2208
  identityKey,
2175
2209
  agentDid: identity.did,
2176
2210
  });
@@ -2195,7 +2229,7 @@ export class MCPICloudflareAgent extends McpAgent {
2195
2229
  return undefined;
2196
2230
  }
2197
2231
  // No vault secrets AND no static env — throw structured error
2198
- const apiUrl = env.AGENTSHIELD_API_URL || "https://kya.vouched.id";
2232
+ const apiUrl = env.CHECKPOINT_API_URL || "https://kya.vouched.id";
2199
2233
  // Use /dashboard/projects/{id} path — works without orgId and
2200
2234
  // the dashboard redirects to the correct org-scoped route.
2201
2235
  const configUrl = `${apiUrl}/dashboard/projects/${projectId}/settings`;
@@ -2256,8 +2290,8 @@ export class MCPICloudflareAgent extends McpAgent {
2256
2290
  ? new KVOAuthConfigCache({ kv: env.TOOL_PROTECTION_KV })
2257
2291
  : undefined;
2258
2292
  const oauthConfigService = new ConfigService({
2259
- baseUrl: env.AGENTSHIELD_API_URL || "https://kya.vouched.id",
2260
- apiKey: env.AGENTSHIELD_API_KEY,
2293
+ baseUrl: env.CHECKPOINT_API_URL || "https://kya.vouched.id",
2294
+ apiKey: env.CHECKPOINT_API_KEY,
2261
2295
  fetchProvider,
2262
2296
  cache: oauthConfigCache,
2263
2297
  });
@@ -2266,8 +2300,8 @@ export class MCPICloudflareAgent extends McpAgent {
2266
2300
  const oauthService = new OAuthService({
2267
2301
  configService: oauthConfigService,
2268
2302
  fetchProvider,
2269
- agentShieldApiUrl: env.AGENTSHIELD_API_URL || "https://kya.vouched.id",
2270
- agentShieldApiKey: env.AGENTSHIELD_API_KEY,
2303
+ agentShieldApiUrl: env.CHECKPOINT_API_URL || "https://kya.vouched.id",
2304
+ agentShieldApiKey: env.CHECKPOINT_API_KEY,
2271
2305
  projectId,
2272
2306
  // WFP fix (see makeEnvSecretResolver): resolve the client secret from the
2273
2307
  // RAW worker env. We pass `this.env`, NOT the `env` param — `env` here is
@@ -2381,9 +2415,9 @@ export class MCPICloudflareAgent extends McpAgent {
2381
2415
  const agentDid = getMcpRequestHolder()?.did ?? (await this.mcpiRuntime.getIdentity()).did;
2382
2416
  // Determine the OAuth provider from the error or discover from config
2383
2417
  let provider = error.provider;
2384
- // If no provider specified, try to discover from AgentShield config
2418
+ // If no provider specified, try to discover from Checkpoint config
2385
2419
  if (!provider) {
2386
- const agentShieldUrl = env.AGENTSHIELD_API_URL || "https://kya.vouched.id";
2420
+ const agentShieldUrl = env.CHECKPOINT_API_URL || "https://kya.vouched.id";
2387
2421
  const oauthServices = isOAuthServicesAvailable()
2388
2422
  ? getOAuthServices()
2389
2423
  : null;
@@ -2395,7 +2429,7 @@ export class MCPICloudflareAgent extends McpAgent {
2395
2429
  });
2396
2430
  const configService = new OAuthConfigService({
2397
2431
  baseUrl: agentShieldUrl,
2398
- apiKey: env.AGENTSHIELD_API_KEY || "",
2432
+ apiKey: env.CHECKPOINT_API_KEY || "",
2399
2433
  fetchProvider: new WorkersFetchProvider(),
2400
2434
  cache: oauthConfigCache,
2401
2435
  });
@@ -2515,6 +2549,11 @@ export class MCPICloudflareAgent extends McpAgent {
2515
2549
  */
2516
2550
  async fetch(request) {
2517
2551
  const url = new URL(request.url);
2552
+ // Native state moved to its own binding/class. Refuse obsolete internal
2553
+ // dispatch without initializing MCP or touching the shared Agent scheduler.
2554
+ if (url.pathname.startsWith(NATIVE_OAUTH_INTERNAL_PREFIX)) {
2555
+ return new Response(null, { status: 404 });
2556
+ }
2518
2557
  // draft-kya-http-02 §13 pickup-anchor dispatch.
2519
2558
  // These requests target dedicated `pickup:<sid>` durable-object instances and
2520
2559
  // must run BEFORE any origin detection, handshake-session side effects, or
@@ -2712,7 +2751,7 @@ export class MCPICloudflareAgent extends McpAgent {
2712
2751
  : this.env;
2713
2752
  const runtimeConfig = this.getRuntimeConfigInternal(mappedEnv);
2714
2753
  const httpChallengeCfg = resolveHttpChallengeConfig(runtimeConfig, mappedEnv);
2715
- const augmented = augmentKyaOsIdentityWellKnown(wellKnownPath, result, httpChallengeCfg, isAnchorRegistrationEnabled(httpChallengeCfg, mappedEnv), resolveCloudflareAuditAssurance(runtimeConfig));
2754
+ const augmented = augmentKyaOsIdentityWellKnown(wellKnownPath, result, httpChallengeCfg, isAnchorRegistrationEnabled(httpChallengeCfg, mappedEnv), resolveCloudflareAuditAssurance(this._runtimeConfig));
2716
2755
  return new Response(JSON.stringify(augmented), {
2717
2756
  status: 200,
2718
2757
  headers: { "Content-Type": "application/json" },
@@ -2997,7 +3036,7 @@ export class MCPICloudflareAgent extends McpAgent {
2997
3036
  ?.toolProtectionService;
2998
3037
  // Also clear consent config cache
2999
3038
  try {
3000
- const projectId = this.env.AGENTSHIELD_PROJECT_ID;
3039
+ const projectId = this.env.CHECKPOINT_PROJECT_ID;
3001
3040
  if (projectId && this.env.TOOL_PROTECTION_KV) {
3002
3041
  // Clear the consent config cache key directly
3003
3042
  const consentCacheKey = `consent:config:${projectId}`;