@kya-os/contracts 1.4.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -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,225 @@
|
|
|
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: "",
|
|
23
|
+
environment: "development",
|
|
24
|
+
storageLocation: "env-vars",
|
|
25
|
+
},
|
|
26
|
+
proofing: {
|
|
27
|
+
enabled: true,
|
|
28
|
+
destinations: [
|
|
29
|
+
{
|
|
30
|
+
type: "agentshield",
|
|
31
|
+
apiUrl: "https://kya.vouched.id",
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
batchQueue: {
|
|
35
|
+
maxBatchSize: 10,
|
|
36
|
+
flushIntervalMs: 5000,
|
|
37
|
+
maxRetries: 3,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
delegation: {
|
|
41
|
+
enabled: true,
|
|
42
|
+
enforceStrictly: false,
|
|
43
|
+
verifier: {
|
|
44
|
+
type: "agentshield",
|
|
45
|
+
apiUrl: "https://kya.vouched.id/api/v1/bouncer/delegations/verify",
|
|
46
|
+
cacheTtl: 300000,
|
|
47
|
+
},
|
|
48
|
+
authorization: {
|
|
49
|
+
authorizationUrl: "https://kya.vouched.id/api/v1/bouncer/delegations/authorize",
|
|
50
|
+
minReputationScore: 80,
|
|
51
|
+
resumeTokenTtl: 3600000,
|
|
52
|
+
requireAuthForUnknown: false,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
toolProtection: {
|
|
56
|
+
source: "agentshield",
|
|
57
|
+
agentShield: {
|
|
58
|
+
apiUrl: "https://kya.vouched.id",
|
|
59
|
+
cacheTtl: 300000,
|
|
60
|
+
},
|
|
61
|
+
fallback: {},
|
|
62
|
+
},
|
|
63
|
+
audit: {
|
|
64
|
+
enabled: true,
|
|
65
|
+
includeProofHashes: false,
|
|
66
|
+
includePayloads: false,
|
|
67
|
+
},
|
|
68
|
+
session: {
|
|
69
|
+
timestampSkewSeconds: 120,
|
|
70
|
+
ttlMinutes: 30,
|
|
71
|
+
},
|
|
72
|
+
platform: {
|
|
73
|
+
type: "node",
|
|
74
|
+
node: {
|
|
75
|
+
server: {
|
|
76
|
+
port: 3000,
|
|
77
|
+
host: "0.0.0.0",
|
|
78
|
+
cors: true,
|
|
79
|
+
timeout: 30000,
|
|
80
|
+
},
|
|
81
|
+
storage: {
|
|
82
|
+
type: "memory",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
cloudflare: {
|
|
86
|
+
workers: {
|
|
87
|
+
cpuMs: 50,
|
|
88
|
+
memoryMb: 128,
|
|
89
|
+
},
|
|
90
|
+
kvNamespaces: [],
|
|
91
|
+
environmentVariables: [],
|
|
92
|
+
},
|
|
93
|
+
vercel: {
|
|
94
|
+
environmentVariables: [],
|
|
95
|
+
edgeRuntime: {},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
metadata: {
|
|
99
|
+
version: "1.0.0",
|
|
100
|
+
lastUpdated: "",
|
|
101
|
+
source: "dashboard",
|
|
102
|
+
deploymentStatus: "inactive",
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Relaxed schema for default config validation
|
|
107
|
+
* Allows empty strings for fields that will be populated later
|
|
108
|
+
*/
|
|
109
|
+
const defaultConfigSchema = schemas_js_1.mcpIServerConfigSchema.extend({
|
|
110
|
+
identity: schemas_js_1.mcpIServerConfigSchema.shape.identity.extend({
|
|
111
|
+
agentDid: zod_1.z.string(), // Allow empty string for defaults
|
|
112
|
+
}),
|
|
113
|
+
metadata: schemas_js_1.mcpIServerConfigSchema.shape.metadata.extend({
|
|
114
|
+
lastUpdated: zod_1.z.string(), // Allow empty string (will be set dynamically)
|
|
115
|
+
}),
|
|
116
|
+
});
|
|
117
|
+
/**
|
|
118
|
+
* Default configuration object
|
|
119
|
+
*
|
|
120
|
+
* This is the base default configuration used when creating new user configs.
|
|
121
|
+
* Platform-specific defaults are available via getDefaultConfigForPlatform().
|
|
122
|
+
*/
|
|
123
|
+
exports.defaultConfig = defaultConfigSchema.parse(defaultConfigJson);
|
|
124
|
+
/**
|
|
125
|
+
* Platform-specific default configurations
|
|
126
|
+
*/
|
|
127
|
+
const platformDefaults = {
|
|
128
|
+
node: {
|
|
129
|
+
platform: {
|
|
130
|
+
type: "node",
|
|
131
|
+
node: {
|
|
132
|
+
server: {
|
|
133
|
+
port: 3000,
|
|
134
|
+
host: "0.0.0.0",
|
|
135
|
+
cors: true,
|
|
136
|
+
timeout: 30000,
|
|
137
|
+
},
|
|
138
|
+
storage: {
|
|
139
|
+
type: "memory",
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
cloudflare: {
|
|
145
|
+
platform: {
|
|
146
|
+
type: "cloudflare",
|
|
147
|
+
cloudflare: {
|
|
148
|
+
workers: {
|
|
149
|
+
cpuMs: 50,
|
|
150
|
+
memoryMb: 128,
|
|
151
|
+
},
|
|
152
|
+
kvNamespaces: [],
|
|
153
|
+
environmentVariables: [],
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
vercel: {
|
|
158
|
+
platform: {
|
|
159
|
+
type: "vercel",
|
|
160
|
+
vercel: {
|
|
161
|
+
environmentVariables: [],
|
|
162
|
+
edgeRuntime: {},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Get default configuration for a specific platform
|
|
169
|
+
*
|
|
170
|
+
* Returns the base default config merged with platform-specific defaults.
|
|
171
|
+
*
|
|
172
|
+
* @param platform - Platform type ('node', 'cloudflare', or 'vercel')
|
|
173
|
+
* @returns Platform-specific default configuration
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* const nodeConfig = getDefaultConfigForPlatform('node');
|
|
178
|
+
* const cloudflareConfig = getDefaultConfigForPlatform('cloudflare');
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
function getDefaultConfigForPlatform(platform) {
|
|
182
|
+
const platformDefault = platformDefaults[platform];
|
|
183
|
+
return {
|
|
184
|
+
...exports.defaultConfig,
|
|
185
|
+
platform: platformDefault.platform,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Deep merge utility for objects
|
|
190
|
+
*/
|
|
191
|
+
function deepMerge(target, source) {
|
|
192
|
+
const result = { ...target };
|
|
193
|
+
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]);
|
|
199
|
+
}
|
|
200
|
+
else if (source[key] !== undefined) {
|
|
201
|
+
result[key] = source[key];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return result;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Merge partial configuration with defaults
|
|
208
|
+
*
|
|
209
|
+
* Deep merges a partial configuration object with the base defaults,
|
|
210
|
+
* ensuring all required fields are present.
|
|
211
|
+
*
|
|
212
|
+
* @param partial - Partial configuration to merge with defaults
|
|
213
|
+
* @returns Complete configuration with defaults applied
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```typescript
|
|
217
|
+
* const config = mergeWithDefaults({
|
|
218
|
+
* proofing: { enabled: false },
|
|
219
|
+
* identity: { environment: 'production' }
|
|
220
|
+
* });
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
function mergeWithDefaults(partial) {
|
|
224
|
+
return deepMerge(exports.defaultConfig, partial);
|
|
225
|
+
}
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
*/
|
|
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';
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @package @kya-os/contracts/dashboard-config
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.validateServerConfigResponseSchema = exports.validateServerConfigRequestSchema = exports.updateServerConfigResponseSchema = exports.updateServerConfigRequestSchema = exports.getServerConfigResponseSchema = exports.getServerConfigRequestSchema = exports.mcpIServerConfigSchema = exports.configMetadataSchema = exports.vercelPlatformConfigSchema = exports.nodePlatformConfigSchema = exports.cloudflarePlatformConfigSchema = exports.platformConfigSchema = exports.sessionConfigSchema = exports.auditConfigSchema = exports.toolProtectionConfigSchema = exports.delegationConfigSchema = exports.proofingConfigSchema = exports.identityConfigSchema = void 0;
|
|
10
|
+
exports.mergeWithDefaults = exports.getDefaultConfigForPlatform = exports.defaultConfig = exports.validateServerConfigResponseSchema = exports.validateServerConfigRequestSchema = exports.updateServerConfigResponseSchema = exports.updateServerConfigRequestSchema = exports.getServerConfigResponseSchema = exports.getServerConfigRequestSchema = exports.mcpIServerConfigSchema = exports.configMetadataSchema = exports.vercelPlatformConfigSchema = exports.nodePlatformConfigSchema = exports.cloudflarePlatformConfigSchema = exports.platformConfigSchema = exports.sessionConfigSchema = exports.auditConfigSchema = exports.toolProtectionConfigSchema = exports.delegationConfigSchema = exports.proofingConfigSchema = exports.identityConfigSchema = void 0;
|
|
11
11
|
// Schema exports
|
|
12
12
|
var schemas_js_1 = require("./schemas.js");
|
|
13
13
|
Object.defineProperty(exports, "identityConfigSchema", { enumerable: true, get: function () { return schemas_js_1.identityConfigSchema; } });
|
|
@@ -28,4 +28,8 @@ Object.defineProperty(exports, "updateServerConfigRequestSchema", { enumerable:
|
|
|
28
28
|
Object.defineProperty(exports, "updateServerConfigResponseSchema", { enumerable: true, get: function () { return schemas_js_1.updateServerConfigResponseSchema; } });
|
|
29
29
|
Object.defineProperty(exports, "validateServerConfigRequestSchema", { enumerable: true, get: function () { return schemas_js_1.validateServerConfigRequestSchema; } });
|
|
30
30
|
Object.defineProperty(exports, "validateServerConfigResponseSchema", { enumerable: true, get: function () { return schemas_js_1.validateServerConfigResponseSchema; } });
|
|
31
|
-
|
|
31
|
+
// Default configuration exports
|
|
32
|
+
var default_config_js_1 = require("./default-config.js");
|
|
33
|
+
Object.defineProperty(exports, "defaultConfig", { enumerable: true, get: function () { return default_config_js_1.defaultConfig; } });
|
|
34
|
+
Object.defineProperty(exports, "getDefaultConfigForPlatform", { enumerable: true, get: function () { return default_config_js_1.getDefaultConfigForPlatform; } });
|
|
35
|
+
Object.defineProperty(exports, "mergeWithDefaults", { enumerable: true, get: function () { return default_config_js_1.mergeWithDefaults; } });
|