@kya-os/contracts 1.5.2-canary.4 → 1.5.2-canary.6

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 (101) hide show
  1. package/dist/agentshield-api/admin-schemas.d.ts +49 -0
  2. package/dist/agentshield-api/admin-schemas.js +30 -0
  3. package/dist/agentshield-api/admin-types.d.ts +37 -0
  4. package/dist/agentshield-api/admin-types.js +10 -0
  5. package/dist/agentshield-api/endpoints.d.ts +50 -0
  6. package/dist/agentshield-api/endpoints.js +46 -0
  7. package/dist/agentshield-api/index.d.ts +15 -0
  8. package/dist/agentshield-api/index.js +40 -0
  9. package/dist/agentshield-api/schemas.d.ts +6032 -0
  10. package/dist/agentshield-api/schemas.js +240 -0
  11. package/dist/agentshield-api/types.d.ts +231 -0
  12. package/dist/agentshield-api/types.js +26 -0
  13. package/dist/cli.d.ts +388 -0
  14. package/dist/cli.js +121 -0
  15. package/dist/config/base.d.ts +96 -0
  16. package/dist/config/base.js +11 -0
  17. package/dist/config/builder.d.ts +33 -0
  18. package/dist/config/builder.js +74 -0
  19. package/dist/config/delegation.d.ts +194 -0
  20. package/dist/config/delegation.js +10 -0
  21. package/dist/config/identity.d.ts +116 -0
  22. package/dist/config/identity.js +10 -0
  23. package/dist/config/index.d.ts +34 -0
  24. package/dist/config/index.js +14 -0
  25. package/dist/config/proofing.d.ts +120 -0
  26. package/dist/config/proofing.js +10 -0
  27. package/dist/config/tool-protection.d.ts +139 -0
  28. package/dist/config/tool-protection.js +10 -0
  29. package/dist/consent/index.d.ts +6 -0
  30. package/dist/consent/index.js +23 -0
  31. package/dist/consent/schemas.d.ts +845 -0
  32. package/dist/consent/schemas.js +241 -0
  33. package/dist/consent/types.d.ts +155 -0
  34. package/dist/consent/types.js +10 -0
  35. package/dist/dashboard-config/default-config.d.ts +49 -0
  36. package/dist/dashboard-config/default-config.js +240 -0
  37. package/dist/dashboard-config/index.d.ts +10 -0
  38. package/dist/dashboard-config/index.js +35 -0
  39. package/dist/dashboard-config/schemas.d.ts +5904 -0
  40. package/dist/dashboard-config/schemas.js +254 -0
  41. package/dist/dashboard-config/types.d.ts +337 -0
  42. package/dist/dashboard-config/types.js +10 -0
  43. package/dist/delegation/constraints.d.ts +1021 -0
  44. package/dist/delegation/constraints.js +218 -0
  45. package/dist/delegation/index.d.ts +7 -0
  46. package/dist/delegation/index.js +23 -0
  47. package/dist/delegation/schemas.d.ts +8457 -0
  48. package/dist/delegation/schemas.js +475 -0
  49. package/dist/did/index.d.ts +8 -0
  50. package/dist/did/index.js +24 -0
  51. package/dist/did/resolve-contract.d.ts +219 -0
  52. package/dist/did/resolve-contract.js +31 -0
  53. package/dist/did/schemas.d.ts +112 -0
  54. package/dist/did/schemas.js +172 -0
  55. package/dist/did/types.d.ts +163 -0
  56. package/dist/did/types.js +70 -0
  57. package/dist/env/constants.d.ts +57 -0
  58. package/dist/env/constants.js +59 -0
  59. package/dist/env/index.d.ts +4 -0
  60. package/dist/env/index.js +20 -0
  61. package/dist/handshake.d.ts +335 -0
  62. package/dist/handshake.js +81 -0
  63. package/dist/index.d.ts +25 -0
  64. package/dist/index.js +55 -0
  65. package/dist/proof/index.d.ts +9 -0
  66. package/dist/proof/index.js +38 -0
  67. package/dist/proof/proof-record.d.ts +837 -0
  68. package/dist/proof/proof-record.js +133 -0
  69. package/dist/proof/signing-spec.d.ts +146 -0
  70. package/dist/proof/signing-spec.js +122 -0
  71. package/dist/proof.d.ts +414 -0
  72. package/dist/proof.js +82 -0
  73. package/dist/registry.d.ts +342 -0
  74. package/dist/registry.js +118 -0
  75. package/dist/runtime/errors.d.ts +347 -0
  76. package/dist/runtime/errors.js +119 -0
  77. package/dist/runtime/headers.d.ts +83 -0
  78. package/dist/runtime/headers.js +81 -0
  79. package/dist/runtime/index.d.ts +5 -0
  80. package/dist/runtime/index.js +21 -0
  81. package/dist/test.d.ts +251 -0
  82. package/dist/test.js +119 -0
  83. package/dist/tlkrc/index.d.ts +4 -0
  84. package/dist/tlkrc/index.js +20 -0
  85. package/dist/tlkrc/rotation.d.ts +245 -0
  86. package/dist/tlkrc/rotation.js +126 -0
  87. package/dist/tool-protection/index.d.ts +227 -0
  88. package/dist/tool-protection/index.js +113 -0
  89. package/dist/utils/validation.d.ts +30 -0
  90. package/dist/utils/validation.js +69 -0
  91. package/dist/vc/index.d.ts +7 -0
  92. package/dist/vc/index.js +23 -0
  93. package/dist/vc/schemas.d.ts +2483 -0
  94. package/dist/vc/schemas.js +224 -0
  95. package/dist/vc/statuslist.d.ts +493 -0
  96. package/dist/vc/statuslist.js +132 -0
  97. package/dist/verifier.d.ts +205 -0
  98. package/dist/verifier.js +83 -0
  99. package/dist/well-known/index.d.ts +308 -0
  100. package/dist/well-known/index.js +134 -0
  101. package/package.json +1 -1
@@ -0,0 +1,241 @@
1
+ "use strict";
2
+ /**
3
+ * Consent Schemas
4
+ *
5
+ * Zod schemas for runtime validation of consent-related data structures.
6
+ * All types are derived from these schemas using z.infer.
7
+ *
8
+ * Related Spec: MCP-I Phase 0 Implementation Plan
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.consentConfigSchema = exports.consentApprovalResponseSchema = exports.consentApprovalRequestSchema = exports.consentPageConfigSchema = exports.oauthIdentitySchema = exports.consentCustomFieldSchema = exports.consentCustomFieldOptionSchema = exports.consentTermsSchema = exports.consentBrandingSchema = void 0;
12
+ exports.validateConsentPageConfig = validateConsentPageConfig;
13
+ exports.validateConsentApprovalRequest = validateConsentApprovalRequest;
14
+ exports.validateConsentApprovalResponse = validateConsentApprovalResponse;
15
+ exports.validateConsentConfig = validateConsentConfig;
16
+ const zod_1 = require("zod");
17
+ /**
18
+ * Consent Branding Schema
19
+ */
20
+ exports.consentBrandingSchema = zod_1.z.object({
21
+ primaryColor: zod_1.z
22
+ .string()
23
+ .regex(/^#[0-9A-Fa-f]{6}$/, 'Must be a valid hex color (e.g., #0066CC)')
24
+ .optional(),
25
+ logoUrl: zod_1.z.string().url('Must be a valid URL').optional(),
26
+ companyName: zod_1.z.string().max(100, 'Company name must be 100 characters or less').optional(),
27
+ theme: zod_1.z.enum(['light', 'dark', 'auto']).optional(),
28
+ });
29
+ /**
30
+ * Consent Terms Schema
31
+ */
32
+ exports.consentTermsSchema = zod_1.z.object({
33
+ text: zod_1.z.string().max(10000, 'Terms text must be 10000 characters or less').optional(),
34
+ url: zod_1.z.string().url('Must be a valid URL').optional(),
35
+ version: zod_1.z.string().max(50, 'Version must be 50 characters or less').optional(),
36
+ required: zod_1.z.boolean().default(true),
37
+ });
38
+ /**
39
+ * Consent Custom Field Option Schema
40
+ */
41
+ exports.consentCustomFieldOptionSchema = zod_1.z.object({
42
+ value: zod_1.z.string().max(100, 'Option value must be 100 characters or less'),
43
+ label: zod_1.z.string().max(100, 'Option label must be 100 characters or less'),
44
+ });
45
+ /**
46
+ * Consent Custom Field Schema
47
+ */
48
+ exports.consentCustomFieldSchema = zod_1.z.object({
49
+ name: zod_1.z
50
+ .string()
51
+ .min(1, 'Field name is required')
52
+ .max(50, 'Field name must be 50 characters or less')
53
+ .regex(/^[a-zA-Z0-9_]+$/, 'Field name must contain only letters, numbers, and underscores'),
54
+ label: zod_1.z.string().min(1, 'Field label is required').max(100, 'Field label must be 100 characters or less'),
55
+ type: zod_1.z.enum(['text', 'textarea', 'checkbox', 'select']),
56
+ required: zod_1.z.boolean(),
57
+ placeholder: zod_1.z.string().max(200, 'Placeholder must be 200 characters or less').optional(),
58
+ options: zod_1.z
59
+ .array(exports.consentCustomFieldOptionSchema)
60
+ .min(1, 'Select fields must have at least one option')
61
+ .optional(),
62
+ pattern: zod_1.z.string().max(500, 'Pattern must be 500 characters or less').optional(),
63
+ }).refine((data) => {
64
+ // Select fields must have options
65
+ if (data.type === 'select' && (!data.options || data.options.length === 0)) {
66
+ return false;
67
+ }
68
+ // Non-select fields should not have options
69
+ if (data.type !== 'select' && data.options) {
70
+ return false;
71
+ }
72
+ return true;
73
+ }, {
74
+ message: 'Select fields must have options, and non-select fields must not have options',
75
+ });
76
+ /**
77
+ * OAuth Identity Schema
78
+ *
79
+ * Represents a user's OAuth provider account information.
80
+ * Used in Phase 4 to link OAuth accounts to persistent User DIDs.
81
+ */
82
+ exports.oauthIdentitySchema = zod_1.z.object({
83
+ /**
84
+ * OAuth provider name (e.g., "google", "github", "microsoft")
85
+ */
86
+ provider: zod_1.z.string()
87
+ .min(1, 'Provider is required')
88
+ .max(50, 'Provider name must be 50 characters or less'),
89
+ /**
90
+ * OAuth subject identifier (unique user ID from provider)
91
+ * @example "123456789" (Google), "github-user-id" (GitHub)
92
+ */
93
+ subject: zod_1.z.string()
94
+ .min(1, 'Subject is required')
95
+ .max(255, 'Subject must be 255 characters or less'),
96
+ /**
97
+ * User's email address from OAuth provider (optional)
98
+ */
99
+ email: zod_1.z.string()
100
+ .email('Must be a valid email address')
101
+ .max(255, 'Email must be 255 characters or less')
102
+ .optional(),
103
+ /**
104
+ * User's display name from OAuth provider (optional)
105
+ */
106
+ name: zod_1.z.string()
107
+ .max(255, 'Name must be 255 characters or less')
108
+ .optional(),
109
+ });
110
+ /**
111
+ * Consent Page Config Schema
112
+ */
113
+ exports.consentPageConfigSchema = zod_1.z.object({
114
+ tool: zod_1.z.string().min(1, 'Tool name is required'),
115
+ toolDescription: zod_1.z.string().max(500, 'Tool description must be 500 characters or less'),
116
+ scopes: zod_1.z.array(zod_1.z.string()).min(0, 'Scopes array cannot be negative'),
117
+ agentDid: zod_1.z.string().min(1, 'Agent DID is required'),
118
+ sessionId: zod_1.z.string().min(1, 'Session ID is required'),
119
+ projectId: zod_1.z.string().min(1, 'Project ID is required'),
120
+ branding: exports.consentBrandingSchema.optional(),
121
+ terms: exports.consentTermsSchema.optional(),
122
+ customFields: zod_1.z
123
+ .array(exports.consentCustomFieldSchema)
124
+ .max(10, 'Maximum 10 custom fields allowed')
125
+ .optional(),
126
+ serverUrl: zod_1.z.string().url('Server URL must be a valid URL'),
127
+ autoClose: zod_1.z.boolean().optional(),
128
+ });
129
+ /**
130
+ * Consent Approval Request Schema
131
+ *
132
+ * Note: Uses snake_case for API compatibility (agent_did, session_id, project_id)
133
+ *
134
+ * Phase 4 additions:
135
+ * - oauth_identity: Optional OAuth provider information for identity linking
136
+ * - user_did: Optional User DID for persistent identity (if already known)
137
+ */
138
+ exports.consentApprovalRequestSchema = zod_1.z.object({
139
+ tool: zod_1.z.string().min(1, 'Tool name is required'),
140
+ scopes: zod_1.z.array(zod_1.z.string()).min(0, 'Scopes array cannot be negative'),
141
+ agent_did: zod_1.z.string().min(1, 'Agent DID is required'),
142
+ session_id: zod_1.z.string().min(1, 'Session ID is required'),
143
+ project_id: zod_1.z.string().min(1, 'Project ID is required'),
144
+ termsAccepted: zod_1.z.boolean(),
145
+ termsVersion: zod_1.z.string()
146
+ .max(50, 'Terms version must be 50 characters or less')
147
+ .optional(),
148
+ customFields: zod_1.z
149
+ .record(zod_1.z.union([zod_1.z.string(), zod_1.z.boolean()]))
150
+ .optional(),
151
+ // Phase 4: OAuth identity linking
152
+ /**
153
+ * OAuth provider identity information (optional)
154
+ * Used to link OAuth accounts to persistent User DIDs
155
+ */
156
+ oauth_identity: exports.oauthIdentitySchema.optional(),
157
+ /**
158
+ * User DID (optional)
159
+ * If provided, represents the persistent User DID for this user
160
+ * Format: did:key:... or did:web:...
161
+ */
162
+ user_did: zod_1.z.string()
163
+ .regex(/^did:/, 'Must be a valid DID format (starting with did:)')
164
+ .max(500, 'DID must be 500 characters or less')
165
+ .optional(),
166
+ });
167
+ /**
168
+ * Consent Approval Response Schema
169
+ */
170
+ exports.consentApprovalResponseSchema = zod_1.z.object({
171
+ success: zod_1.z.boolean(),
172
+ delegation_id: zod_1.z.string().min(1).optional(),
173
+ delegation_token: zod_1.z.string().min(1).optional(),
174
+ error: zod_1.z.string().optional(),
175
+ error_code: zod_1.z.string().optional(),
176
+ }).refine((data) => {
177
+ // If success is true, must have delegation_id and delegation_token
178
+ if (data.success) {
179
+ return !!data.delegation_id && !!data.delegation_token;
180
+ }
181
+ // If success is false, must have error or error_code
182
+ return !!data.error || !!data.error_code;
183
+ }, {
184
+ message: 'Successful responses must include delegation_id and delegation_token. Failed responses must include error or error_code',
185
+ });
186
+ /**
187
+ * Consent Config Schema
188
+ */
189
+ exports.consentConfigSchema = zod_1.z.object({
190
+ branding: exports.consentBrandingSchema.optional(),
191
+ terms: exports.consentTermsSchema.optional(),
192
+ customFields: zod_1.z
193
+ .array(exports.consentCustomFieldSchema)
194
+ .max(10, 'Maximum 10 custom fields allowed')
195
+ .optional(),
196
+ ui: zod_1.z.object({
197
+ theme: zod_1.z.enum(['light', 'dark', 'auto']).optional(),
198
+ popupEnabled: zod_1.z.boolean().optional(),
199
+ autoClose: zod_1.z.boolean().optional(),
200
+ autoCloseDelay: zod_1.z.number().int().positive().max(60000, 'Auto-close delay must be 60000ms or less').optional(),
201
+ }).optional(),
202
+ });
203
+ /**
204
+ * Validation Helpers
205
+ */
206
+ /**
207
+ * Validate a consent page config
208
+ *
209
+ * @param config - The config to validate
210
+ * @returns Validation result
211
+ */
212
+ function validateConsentPageConfig(config) {
213
+ return exports.consentPageConfigSchema.safeParse(config);
214
+ }
215
+ /**
216
+ * Validate a consent approval request
217
+ *
218
+ * @param request - The request to validate
219
+ * @returns Validation result
220
+ */
221
+ function validateConsentApprovalRequest(request) {
222
+ return exports.consentApprovalRequestSchema.safeParse(request);
223
+ }
224
+ /**
225
+ * Validate a consent approval response
226
+ *
227
+ * @param response - The response to validate
228
+ * @returns Validation result
229
+ */
230
+ function validateConsentApprovalResponse(response) {
231
+ return exports.consentApprovalResponseSchema.safeParse(response);
232
+ }
233
+ /**
234
+ * Validate a consent config
235
+ *
236
+ * @param config - The config to validate
237
+ * @returns Validation result
238
+ */
239
+ function validateConsentConfig(config) {
240
+ return exports.consentConfigSchema.safeParse(config);
241
+ }
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Consent Types
3
+ *
4
+ * TypeScript type definitions for consent page configuration and approval handling.
5
+ * These types are used for server-hosted consent pages in HTTP/SSE transports.
6
+ *
7
+ * Related Spec: MCP-I Phase 0 Implementation Plan
8
+ */
9
+ /**
10
+ * Consent Branding Configuration
11
+ *
12
+ * Customization options for consent page appearance
13
+ */
14
+ export interface ConsentBranding {
15
+ /** Primary brand color (hex format, e.g., '#0066CC') */
16
+ primaryColor?: string;
17
+ /** Logo URL for display on consent page */
18
+ logoUrl?: string;
19
+ /** Company/application name */
20
+ companyName?: string;
21
+ /** Theme preference ('light', 'dark', or 'auto' for system preference) */
22
+ theme?: 'light' | 'dark' | 'auto';
23
+ }
24
+ /**
25
+ * Consent Terms Configuration
26
+ *
27
+ * Terms of service or privacy policy information
28
+ */
29
+ export interface ConsentTerms {
30
+ /** Full terms text (displayed on page) */
31
+ text?: string;
32
+ /** URL to terms document */
33
+ url?: string;
34
+ /** Version identifier for terms */
35
+ version?: string;
36
+ /** Whether terms acceptance is required */
37
+ required?: boolean;
38
+ }
39
+ /**
40
+ * Consent Custom Field
41
+ *
42
+ * Additional fields to collect during consent (e.g., email, preferences)
43
+ */
44
+ export interface ConsentCustomField {
45
+ /** Field name (used as form field name, must be valid identifier) */
46
+ name: string;
47
+ /** Display label for the field */
48
+ label: string;
49
+ /** Field type */
50
+ type: 'text' | 'textarea' | 'checkbox' | 'select';
51
+ /** Whether field is required */
52
+ required: boolean;
53
+ /** Placeholder text */
54
+ placeholder?: string;
55
+ /** Options for select fields */
56
+ options?: Array<{
57
+ value: string;
58
+ label: string;
59
+ }>;
60
+ /** Validation pattern (regex) */
61
+ pattern?: string;
62
+ }
63
+ /**
64
+ * Consent Page Configuration
65
+ *
66
+ * Complete configuration for rendering a consent page
67
+ */
68
+ export interface ConsentPageConfig {
69
+ /** Tool name requiring authorization */
70
+ tool: string;
71
+ /** Description of what the tool does */
72
+ toolDescription: string;
73
+ /** Scopes being requested */
74
+ scopes: string[];
75
+ /** Agent DID requesting authorization */
76
+ agentDid: string;
77
+ /** Session ID for tracking */
78
+ sessionId: string;
79
+ /** Project ID from AgentShield */
80
+ projectId: string;
81
+ /** Branding configuration */
82
+ branding?: ConsentBranding;
83
+ /** Terms configuration */
84
+ terms?: ConsentTerms;
85
+ /** Custom fields to collect */
86
+ customFields?: ConsentCustomField[];
87
+ /** Server URL for form submission */
88
+ serverUrl: string;
89
+ /** Whether to auto-close window after success */
90
+ autoClose?: boolean;
91
+ }
92
+ /**
93
+ * Consent Approval Request
94
+ *
95
+ * Request payload when user approves consent
96
+ */
97
+ export interface ConsentApprovalRequest {
98
+ /** Tool name */
99
+ tool: string;
100
+ /** Approved scopes */
101
+ scopes: string[];
102
+ /** Agent DID (snake_case for API compatibility) */
103
+ agent_did: string;
104
+ /** Session ID (snake_case for API compatibility) */
105
+ session_id: string;
106
+ /** Project ID (snake_case for API compatibility) */
107
+ project_id: string;
108
+ /** Whether terms were accepted */
109
+ termsAccepted: boolean;
110
+ /** Terms version (if applicable) */
111
+ termsVersion?: string;
112
+ /** Custom field values */
113
+ customFields?: Record<string, string | boolean>;
114
+ }
115
+ /**
116
+ * Consent Approval Response
117
+ *
118
+ * Response after processing consent approval
119
+ */
120
+ export interface ConsentApprovalResponse {
121
+ /** Whether approval was successful */
122
+ success: boolean;
123
+ /** Delegation ID (if successful) */
124
+ delegation_id?: string;
125
+ /** Delegation token (if successful) */
126
+ delegation_token?: string;
127
+ /** Error message (if failed) */
128
+ error?: string;
129
+ /** Error code (if failed) */
130
+ error_code?: string;
131
+ }
132
+ /**
133
+ * Consent Configuration
134
+ *
135
+ * Complete consent configuration fetched from AgentShield or defaults
136
+ */
137
+ export interface ConsentConfig {
138
+ /** Branding configuration */
139
+ branding?: ConsentBranding;
140
+ /** Terms configuration */
141
+ terms?: ConsentTerms;
142
+ /** Custom fields configuration */
143
+ customFields?: ConsentCustomField[];
144
+ /** UI preferences */
145
+ ui?: {
146
+ /** Theme preference */
147
+ theme?: 'light' | 'dark' | 'auto';
148
+ /** Whether popup mode is enabled */
149
+ popupEnabled?: boolean;
150
+ /** Whether to auto-close after success */
151
+ autoClose?: boolean;
152
+ /** Delay before auto-close (milliseconds) */
153
+ autoCloseDelay?: number;
154
+ };
155
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /**
3
+ * Consent Types
4
+ *
5
+ * TypeScript type definitions for consent page configuration and approval handling.
6
+ * These types are used for server-hosted consent pages in HTTP/SSE transports.
7
+ *
8
+ * Related Spec: MCP-I Phase 0 Implementation Plan
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Default Configuration for MCP-I Servers
3
+ *
4
+ * Provides safe, production-ready defaults for new user configurations.
5
+ * Used by AgentShield Dashboard, Scaffolder, and Runtime fallbacks.
6
+ *
7
+ * @package @kya-os/contracts/dashboard-config
8
+ */
9
+ import type { MCPIServerConfig } from "./types.js";
10
+ /**
11
+ * Default configuration object
12
+ *
13
+ * This is the base default configuration used when creating new user configs.
14
+ * Platform-specific defaults are available via getDefaultConfigForPlatform().
15
+ */
16
+ export declare const defaultConfig: MCPIServerConfig;
17
+ /**
18
+ * Get default configuration for a specific platform
19
+ *
20
+ * Returns the base default config merged with platform-specific defaults.
21
+ *
22
+ * @param platform - Platform type ('node', 'cloudflare', or 'vercel')
23
+ * @returns Platform-specific default configuration
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const nodeConfig = getDefaultConfigForPlatform('node');
28
+ * const cloudflareConfig = getDefaultConfigForPlatform('cloudflare');
29
+ * ```
30
+ */
31
+ export declare function getDefaultConfigForPlatform(platform: "node" | "cloudflare" | "vercel"): MCPIServerConfig;
32
+ /**
33
+ * Merge partial configuration with defaults
34
+ *
35
+ * Deep merges a partial configuration object with the base defaults,
36
+ * ensuring all required fields are present.
37
+ *
38
+ * @param partial - Partial configuration to merge with defaults
39
+ * @returns Complete configuration with defaults applied
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const config = mergeWithDefaults({
44
+ * proofing: { enabled: false },
45
+ * identity: { environment: 'production' }
46
+ * });
47
+ * ```
48
+ */
49
+ export declare function mergeWithDefaults(partial: Partial<MCPIServerConfig>): MCPIServerConfig;
@@ -0,0 +1,240 @@
1
+ "use strict";
2
+ /**
3
+ * Default Configuration for MCP-I Servers
4
+ *
5
+ * Provides safe, production-ready defaults for new user configurations.
6
+ * Used by AgentShield Dashboard, Scaffolder, and Runtime fallbacks.
7
+ *
8
+ * @package @kya-os/contracts/dashboard-config
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.defaultConfig = void 0;
12
+ exports.getDefaultConfigForPlatform = getDefaultConfigForPlatform;
13
+ exports.mergeWithDefaults = mergeWithDefaults;
14
+ const schemas_js_1 = require("./schemas.js");
15
+ const zod_1 = require("zod");
16
+ /**
17
+ * Default configuration JSON content
18
+ * Embedded here to avoid TypeScript JSON import issues in build
19
+ */
20
+ const defaultConfigJson = {
21
+ identity: {
22
+ // agentDid removed - deprecated, use serverDid instead
23
+ serverDid: "", // New field - will be populated when identity is generated
24
+ environment: "development",
25
+ storageLocation: "env-vars",
26
+ },
27
+ proofing: {
28
+ enabled: true,
29
+ destinations: [
30
+ {
31
+ type: "agentshield",
32
+ apiUrl: "https://kya.vouched.id",
33
+ },
34
+ ],
35
+ batchQueue: {
36
+ maxBatchSize: 10,
37
+ flushIntervalMs: 5000,
38
+ maxRetries: 3,
39
+ },
40
+ },
41
+ delegation: {
42
+ enabled: true,
43
+ enforceStrictly: false,
44
+ verifier: {
45
+ type: "agentshield",
46
+ apiUrl: "https://kya.vouched.id/api/v1/bouncer/delegations/verify",
47
+ cacheTtl: 300000,
48
+ },
49
+ authorization: {
50
+ authorizationUrl: "https://kya.vouched.id/api/v1/bouncer/delegations/authorize",
51
+ minReputationScore: 80,
52
+ resumeTokenTtl: 3600000,
53
+ requireAuthForUnknown: false,
54
+ },
55
+ },
56
+ toolProtection: {
57
+ source: "agentshield",
58
+ agentShield: {
59
+ apiUrl: "https://kya.vouched.id",
60
+ cacheTtl: 300000,
61
+ },
62
+ fallback: {},
63
+ },
64
+ audit: {
65
+ enabled: true,
66
+ includeProofHashes: false,
67
+ includePayloads: false,
68
+ },
69
+ session: {
70
+ timestampSkewSeconds: 120,
71
+ ttlMinutes: 30,
72
+ },
73
+ platform: {
74
+ type: "node",
75
+ node: {
76
+ server: {
77
+ port: 3000,
78
+ host: "0.0.0.0",
79
+ cors: true,
80
+ timeout: 30000,
81
+ },
82
+ storage: {
83
+ type: "memory",
84
+ },
85
+ },
86
+ cloudflare: {
87
+ workers: {
88
+ cpuMs: 50,
89
+ memoryMb: 128,
90
+ },
91
+ kvNamespaces: [],
92
+ environmentVariables: [],
93
+ },
94
+ vercel: {
95
+ environmentVariables: [],
96
+ edgeRuntime: {},
97
+ },
98
+ },
99
+ metadata: {
100
+ version: "1.0.0",
101
+ lastUpdated: "",
102
+ source: "dashboard",
103
+ deploymentStatus: "inactive",
104
+ },
105
+ };
106
+ /**
107
+ * Relaxed schema for default config validation
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.
115
+ */
116
+ const defaultConfigSchema = schemas_js_1.mcpIServerConfigSchema.extend({
117
+ identity: schemas_js_1.mcpIServerConfigSchema.shape.identity.extend({
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)
120
+ }),
121
+ metadata: schemas_js_1.mcpIServerConfigSchema.shape.metadata.extend({
122
+ lastUpdated: zod_1.z.string(), // Allow empty string (will be set dynamically)
123
+ }),
124
+ });
125
+ /**
126
+ * Default configuration object
127
+ *
128
+ * This is the base default configuration used when creating new user configs.
129
+ * Platform-specific defaults are available via getDefaultConfigForPlatform().
130
+ */
131
+ exports.defaultConfig = defaultConfigSchema.parse(defaultConfigJson);
132
+ /**
133
+ * Platform-specific default configurations
134
+ */
135
+ const platformDefaults = {
136
+ node: {
137
+ platform: {
138
+ type: "node",
139
+ node: {
140
+ server: {
141
+ port: 3000,
142
+ host: "0.0.0.0",
143
+ cors: true,
144
+ timeout: 30000,
145
+ },
146
+ storage: {
147
+ type: "memory",
148
+ },
149
+ },
150
+ },
151
+ },
152
+ cloudflare: {
153
+ platform: {
154
+ type: "cloudflare",
155
+ cloudflare: {
156
+ workers: {
157
+ cpuMs: 50,
158
+ memoryMb: 128,
159
+ },
160
+ kvNamespaces: [],
161
+ environmentVariables: [],
162
+ },
163
+ },
164
+ },
165
+ vercel: {
166
+ platform: {
167
+ type: "vercel",
168
+ vercel: {
169
+ environmentVariables: [],
170
+ edgeRuntime: {},
171
+ },
172
+ },
173
+ },
174
+ };
175
+ /**
176
+ * Get default configuration for a specific platform
177
+ *
178
+ * Returns the base default config merged with platform-specific defaults.
179
+ *
180
+ * @param platform - Platform type ('node', 'cloudflare', or 'vercel')
181
+ * @returns Platform-specific default configuration
182
+ *
183
+ * @example
184
+ * ```typescript
185
+ * const nodeConfig = getDefaultConfigForPlatform('node');
186
+ * const cloudflareConfig = getDefaultConfigForPlatform('cloudflare');
187
+ * ```
188
+ */
189
+ function getDefaultConfigForPlatform(platform) {
190
+ const platformDefault = platformDefaults[platform];
191
+ return {
192
+ ...exports.defaultConfig,
193
+ platform: platformDefault.platform,
194
+ };
195
+ }
196
+ /**
197
+ * Deep merge utility for objects
198
+ */
199
+ function deepMerge(target, source) {
200
+ const result = { ...target };
201
+ for (const key in source) {
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
+ }
214
+ }
215
+ else if (sourceValue !== undefined) {
216
+ result[key] = sourceValue;
217
+ }
218
+ }
219
+ return result;
220
+ }
221
+ /**
222
+ * Merge partial configuration with defaults
223
+ *
224
+ * Deep merges a partial configuration object with the base defaults,
225
+ * ensuring all required fields are present.
226
+ *
227
+ * @param partial - Partial configuration to merge with defaults
228
+ * @returns Complete configuration with defaults applied
229
+ *
230
+ * @example
231
+ * ```typescript
232
+ * const config = mergeWithDefaults({
233
+ * proofing: { enabled: false },
234
+ * identity: { environment: 'production' }
235
+ * });
236
+ * ```
237
+ */
238
+ function mergeWithDefaults(partial) {
239
+ return deepMerge(exports.defaultConfig, partial);
240
+ }