@kya-os/contracts 1.5.1 → 1.5.2-canary.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.
@@ -162,4 +162,3 @@ exports.revokeDelegationResponseSchema = zod_1.z.object({
162
162
  * Wrapped revocation response schema
163
163
  */
164
164
  exports.revokeDelegationAPIResponseSchema = (0, exports.agentShieldAPIResponseSchema)(exports.revokeDelegationResponseSchema);
165
- //# sourceMappingURL=schemas.js.map
@@ -109,7 +109,7 @@ export interface AgentShieldToolProtection {
109
109
  }
110
110
  /**
111
111
  * Response from tool protection config endpoint
112
- * GET /api/v1/bouncer/config/{projectId}
112
+ * GET /api/v1/bouncer/projects/{projectId}/config
113
113
  */
114
114
  export interface ToolProtectionConfigResponse {
115
115
  agent_did: string;
@@ -166,3 +166,4 @@ export declare class AgentShieldAPIError extends Error {
166
166
  readonly details?: Record<string, unknown> | undefined;
167
167
  constructor(code: string, message: string, details?: Record<string, unknown> | undefined);
168
168
  }
169
+ //# sourceMappingURL=types.d.ts.map
@@ -24,4 +24,3 @@ class AgentShieldAPIError extends Error {
24
24
  }
25
25
  }
26
26
  exports.AgentShieldAPIError = AgentShieldAPIError;
27
- //# sourceMappingURL=types.js.map
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Configuration Builder Utilities
3
+ *
4
+ * Shared utilities for building MCP-I configuration objects with sensible defaults.
5
+ * These functions are platform-agnostic and can be used by any adapter/platform.
6
+ *
7
+ * @module @kya-os/contracts/config
8
+ */
9
+ import type { MCPIBaseConfig } from './base.js';
10
+ import type { RuntimeIdentityConfig } from './identity.js';
11
+ import type { ProofingConfig } from './proofing.js';
12
+ import type { DelegationConfig } from './delegation.js';
13
+ import type { ToolProtectionSourceConfig } from './tool-protection.js';
14
+ /**
15
+ * Complete runtime configuration type
16
+ * This can be extended by platform-specific configs
17
+ */
18
+ export interface MCPIConfig extends MCPIBaseConfig {
19
+ identity?: RuntimeIdentityConfig;
20
+ proofing?: ProofingConfig;
21
+ delegation?: DelegationConfig;
22
+ toolProtection?: ToolProtectionSourceConfig;
23
+ }
24
+ /**
25
+ * Build base MCPIConfig that works across all platforms
26
+ *
27
+ * Creates a platform-agnostic configuration object with sensible defaults
28
+ * for identity, proofing, delegation, audit, and session management.
29
+ *
30
+ * @param env - Environment variables object (works with process.env or Cloudflare env)
31
+ * @returns Complete MCPIConfig object
32
+ */
33
+ export declare function buildBaseConfig(env: Record<string, any>): MCPIConfig;
34
+ //# sourceMappingURL=builder.d.ts.map
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ /**
3
+ * Configuration Builder Utilities
4
+ *
5
+ * Shared utilities for building MCP-I configuration objects with sensible defaults.
6
+ * These functions are platform-agnostic and can be used by any adapter/platform.
7
+ *
8
+ * @module @kya-os/contracts/config
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.buildBaseConfig = buildBaseConfig;
12
+ /**
13
+ * Build base MCPIConfig that works across all platforms
14
+ *
15
+ * Creates a platform-agnostic configuration object with sensible defaults
16
+ * for identity, proofing, delegation, audit, and session management.
17
+ *
18
+ * @param env - Environment variables object (works with process.env or Cloudflare env)
19
+ * @returns Complete MCPIConfig object
20
+ */
21
+ function buildBaseConfig(env) {
22
+ const environment = (env.MCPI_ENV || env.ENVIRONMENT || 'development');
23
+ const isDevelopment = environment === 'development';
24
+ const baseConfig = {
25
+ environment,
26
+ identity: {
27
+ enabled: true,
28
+ environment,
29
+ devIdentityPath: '.mcpi/identity.json'
30
+ },
31
+ proofing: {
32
+ enabled: true,
33
+ batchQueue: {
34
+ destinations: [
35
+ {
36
+ type: 'agentshield',
37
+ apiUrl: env.AGENTSHIELD_API_URL || 'https://kya.vouched.id',
38
+ apiKey: env.AGENTSHIELD_API_KEY || ''
39
+ }
40
+ ],
41
+ maxBatchSize: 10,
42
+ flushIntervalMs: 5000,
43
+ maxRetries: 3,
44
+ debug: isDevelopment
45
+ }
46
+ },
47
+ delegation: {
48
+ enabled: true,
49
+ enforceDelegations: true,
50
+ verifier: {
51
+ type: 'agentshield',
52
+ apiUrl: env.AGENTSHIELD_API_URL || 'https://kya.vouched.id',
53
+ apiKey: env.AGENTSHIELD_API_KEY || '',
54
+ cacheTtl: 60000, // 1 minute cache
55
+ debug: isDevelopment
56
+ },
57
+ authorization: {
58
+ authorizationUrl: env.AUTHORIZATION_URL || `${env.AGENTSHIELD_API_URL || 'https://kya.vouched.id'}/authorize`,
59
+ resumeTokenTtl: 600000, // 10 minutes
60
+ minReputationScore: 76
61
+ }
62
+ },
63
+ audit: {
64
+ enabled: true,
65
+ includeProofHashes: false,
66
+ includePayloads: false
67
+ },
68
+ session: {
69
+ timestampSkewSeconds: 120,
70
+ ttlMinutes: 30
71
+ }
72
+ };
73
+ return baseConfig;
74
+ }
75
+ //# sourceMappingURL=builder.js.map
@@ -6,21 +6,22 @@
6
6
  *
7
7
  * @module @kya-os/contracts/config
8
8
  */
9
- import type { MCPIBaseConfig } from './base.js';
10
- import type { RuntimeIdentityConfig } from './identity.js';
11
- import type { ProofingConfig } from './proofing.js';
12
- import type { DelegationConfig } from './delegation.js';
13
- import type { ToolProtectionSourceConfig } from './tool-protection.js';
14
- export { MCPIBaseConfig } from './base.js';
15
- export { RuntimeIdentityConfig, AgentIdentity } from './identity.js';
9
+ import type { MCPIBaseConfig } from "./base.js";
10
+ import type { RuntimeIdentityConfig } from "./identity.js";
11
+ import type { ProofingConfig } from "./proofing.js";
12
+ import type { DelegationConfig } from "./delegation.js";
13
+ import type { ToolProtectionSourceConfig } from "./tool-protection.js";
14
+ export { MCPIBaseConfig } from "./base.js";
15
+ export { RuntimeIdentityConfig, AgentIdentity } from "./identity.js";
16
16
  /**
17
17
  * @deprecated Use RuntimeIdentityConfig instead
18
18
  * This export is maintained for backward compatibility
19
19
  */
20
20
  export type IdentityConfig = RuntimeIdentityConfig;
21
- export { ProofingConfig, ProofBatchQueueConfig, ProofDestination, ProofDestinationType } from './proofing.js';
22
- export { DelegationConfig, DelegationVerifierConfig, DelegationVerifierType, AuthorizationConfig, DelegationRecord } from './delegation.js';
23
- export { ToolProtection, ToolProtectionMap, ToolProtectionSourceConfig, ToolProtectionSourceType, ToolProtectionServiceConfig, DelegationRequiredErrorData, ToolProtectionResponse } from './tool-protection.js';
21
+ export { ProofingConfig, ProofBatchQueueConfig, ProofDestination, ProofDestinationType, } from "./proofing.js";
22
+ export { DelegationConfig, DelegationVerifierConfig, DelegationVerifierType, AuthorizationConfig, DelegationRecord, } from "./delegation.js";
23
+ export { ToolProtection, ToolProtectionMap, ToolProtectionSourceConfig, ToolProtectionSourceType, ToolProtectionServiceConfig, DelegationRequiredErrorData, ToolProtectionResponse, } from "./tool-protection.js";
24
+ export { buildBaseConfig } from "./builder.js";
24
25
  /**
25
26
  * Complete runtime configuration type
26
27
  * This can be extended by platform-specific configs
@@ -31,3 +32,4 @@ export interface MCPIConfig extends MCPIBaseConfig {
31
32
  delegation?: DelegationConfig;
32
33
  toolProtection?: ToolProtectionSourceConfig;
33
34
  }
35
+ //# sourceMappingURL=index.d.ts.map
@@ -8,4 +8,8 @@
8
8
  * @module @kya-os/contracts/config
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.buildBaseConfig = void 0;
12
+ // Configuration builder utilities
13
+ var builder_js_1 = require("./builder.js");
14
+ Object.defineProperty(exports, "buildBaseConfig", { enumerable: true, get: function () { return builder_js_1.buildBaseConfig; } });
11
15
  //# sourceMappingURL=index.js.map
@@ -47,3 +47,4 @@ export declare function getDefaultConfigForPlatform(platform: "node" | "cloudfla
47
47
  * ```
48
48
  */
49
49
  export declare function mergeWithDefaults(partial: Partial<MCPIServerConfig>): MCPIServerConfig;
50
+ //# sourceMappingURL=default-config.d.ts.map
@@ -19,7 +19,8 @@ const zod_1 = require("zod");
19
19
  */
20
20
  const defaultConfigJson = {
21
21
  identity: {
22
- agentDid: "",
22
+ // agentDid removed - deprecated, use serverDid instead
23
+ serverDid: "", // New field - will be populated when identity is generated
23
24
  environment: "development",
24
25
  storageLocation: "env-vars",
25
26
  },
@@ -105,10 +106,17 @@ const defaultConfigJson = {
105
106
  /**
106
107
  * Relaxed schema for default config validation
107
108
  * Allows empty strings for fields that will be populated later
109
+ *
110
+ * Note: Empty `agentDid` is valid for new/incomplete configurations.
111
+ * This allows users to create configs before registering their agent DID.
112
+ * The base schema (mcpIServerConfigSchema) requires non-empty agentDid for
113
+ * complete configurations, but defaults allow empty to support progressive
114
+ * configuration.
108
115
  */
109
116
  const defaultConfigSchema = schemas_js_1.mcpIServerConfigSchema.extend({
110
117
  identity: schemas_js_1.mcpIServerConfigSchema.shape.identity.extend({
111
- agentDid: zod_1.z.string(), // Allow empty string for defaults
118
+ agentDid: zod_1.z.string().optional(), // Allow empty string or undefined for defaults (deprecated)
119
+ serverDid: zod_1.z.string(), // Allow empty string for defaults (will be populated later)
112
120
  }),
113
121
  metadata: schemas_js_1.mcpIServerConfigSchema.shape.metadata.extend({
114
122
  lastUpdated: zod_1.z.string(), // Allow empty string (will be set dynamically)
@@ -191,14 +199,21 @@ function getDefaultConfigForPlatform(platform) {
191
199
  function deepMerge(target, source) {
192
200
  const result = { ...target };
193
201
  for (const key in source) {
194
- if (source[key] &&
195
- typeof source[key] === "object" &&
196
- !Array.isArray(source[key]) &&
197
- source[key] !== null) {
198
- result[key] = deepMerge((target[key] || {}), source[key]);
202
+ const sourceValue = source[key];
203
+ if (sourceValue &&
204
+ typeof sourceValue === "object" &&
205
+ !Array.isArray(sourceValue) &&
206
+ sourceValue !== null) {
207
+ const targetValue = target[key];
208
+ if (targetValue &&
209
+ typeof targetValue === "object" &&
210
+ !Array.isArray(targetValue) &&
211
+ targetValue !== null) {
212
+ result[key] = deepMerge(targetValue, sourceValue);
213
+ }
199
214
  }
200
- else if (source[key] !== undefined) {
201
- result[key] = source[key];
215
+ else if (sourceValue !== undefined) {
216
+ result[key] = sourceValue;
202
217
  }
203
218
  }
204
219
  return result;
@@ -223,3 +238,4 @@ function deepMerge(target, source) {
223
238
  function mergeWithDefaults(partial) {
224
239
  return deepMerge(exports.defaultConfig, partial);
225
240
  }
241
+ //# sourceMappingURL=default-config.js.map
@@ -8,3 +8,4 @@
8
8
  export type { MCPIServerConfig, GetServerConfigRequest, GetServerConfigResponse, UpdateServerConfigRequest, UpdateServerConfigResponse, ValidateServerConfigRequest, ValidateServerConfigResponse, } from './types.js';
9
9
  export { identityConfigSchema, proofingConfigSchema, delegationConfigSchema, toolProtectionConfigSchema, auditConfigSchema, sessionConfigSchema, platformConfigSchema, cloudflarePlatformConfigSchema, nodePlatformConfigSchema, vercelPlatformConfigSchema, configMetadataSchema, mcpIServerConfigSchema, getServerConfigRequestSchema, getServerConfigResponseSchema, updateServerConfigRequestSchema, updateServerConfigResponseSchema, validateServerConfigRequestSchema, validateServerConfigResponseSchema, } from './schemas.js';
10
10
  export { defaultConfig, getDefaultConfigForPlatform, mergeWithDefaults, } from './default-config.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -33,3 +33,4 @@ var default_config_js_1 = require("./default-config.js");
33
33
  Object.defineProperty(exports, "defaultConfig", { enumerable: true, get: function () { return default_config_js_1.defaultConfig; } });
34
34
  Object.defineProperty(exports, "getDefaultConfigForPlatform", { enumerable: true, get: function () { return default_config_js_1.getDefaultConfigForPlatform; } });
35
35
  Object.defineProperty(exports, "mergeWithDefaults", { enumerable: true, get: function () { return default_config_js_1.mergeWithDefaults; } });
36
+ //# sourceMappingURL=index.js.map