@kya-os/contracts 1.5.3-canary.16 → 1.5.3-canary.17
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.
- package/.turbo/turbo-build.log +17 -0
- package/.turbo/turbo-test$colon$coverage.log +85 -0
- package/.turbo/turbo-test.log +32 -0
- package/coverage/coverage-final.json +38 -0
- package/dist/consent/schemas.d.ts +18 -0
- package/dist/consent/schemas.js +10 -0
- package/dist/dashboard-config/schemas.d.ts +1424 -220
- package/dist/tool-protection/index.d.ts +418 -8
- package/dist/tool-protection/index.js +61 -2
- package/package.json +35 -129
- package/schemas/cli/register-output/v1.0.0.json +69 -0
- package/schemas/identity/v1.0.0.json +46 -0
- package/schemas/proof/v1.0.0.json +80 -0
- package/schemas/registry/receipt-v1.0.0.json +60 -0
- package/schemas/verifier/verify-page/v1.0.0.json +94 -0
- package/schemas/well-known/agent/v1.0.0.json +67 -0
- package/schemas/well-known/did/v1.0.0.json +174 -0
- package/scripts/emit-schemas.js +11 -0
- package/src/agentshield-api/admin-schemas.ts +31 -0
- package/src/agentshield-api/admin-types.ts +47 -0
- package/src/agentshield-api/endpoints.ts +60 -0
- package/src/agentshield-api/index.ts +70 -0
- package/src/agentshield-api/schemas.ts +304 -0
- package/src/agentshield-api/types.ts +317 -0
- package/src/audit/index.ts +128 -0
- package/src/cli.ts +156 -0
- package/src/config/base.ts +107 -0
- package/src/config/builder.ts +97 -0
- package/src/config/delegation.ts +232 -0
- package/src/config/identity.ts +252 -0
- package/src/config/index.ts +78 -0
- package/src/config/proofing.ts +138 -0
- package/src/config/tool-context.ts +41 -0
- package/src/config/tool-protection.ts +174 -0
- package/src/consent/index.ts +32 -0
- package/src/consent/schemas.ts +334 -0
- package/src/consent/types.ts +199 -0
- package/src/dashboard-config/default-config.json +86 -0
- package/src/dashboard-config/default-config.ts +266 -0
- package/src/dashboard-config/index.ts +48 -0
- package/src/dashboard-config/schemas.ts +286 -0
- package/src/dashboard-config/types.ts +404 -0
- package/src/delegation/constraints.ts +267 -0
- package/src/delegation/index.ts +8 -0
- package/src/delegation/schemas.ts +595 -0
- package/src/did/index.ts +9 -0
- package/src/did/resolve-contract.ts +255 -0
- package/src/did/schemas.ts +190 -0
- package/src/did/types.ts +224 -0
- package/src/env/constants.ts +70 -0
- package/src/env/index.ts +5 -0
- package/src/handshake.ts +125 -0
- package/src/index.ts +45 -0
- package/src/proof/index.ts +31 -0
- package/src/proof/proof-record.ts +163 -0
- package/src/proof/signing-spec.ts +146 -0
- package/src/proof.ts +99 -0
- package/src/registry.ts +146 -0
- package/src/runtime/errors.ts +153 -0
- package/src/runtime/headers.ts +136 -0
- package/src/runtime/index.ts +6 -0
- package/src/test.ts +143 -0
- package/src/tlkrc/index.ts +5 -0
- package/src/tlkrc/rotation.ts +153 -0
- package/src/tool-protection/index.ts +343 -0
- package/src/utils/validation.ts +93 -0
- package/src/vc/index.ts +8 -0
- package/src/vc/schemas.ts +277 -0
- package/src/vc/statuslist.ts +279 -0
- package/src/verifier.ts +92 -0
- package/src/well-known/index.ts +237 -0
|
@@ -0,0 +1,199 @@
|
|
|
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
|
+
/**
|
|
11
|
+
* Consent Branding Configuration
|
|
12
|
+
*
|
|
13
|
+
* Customization options for consent page appearance
|
|
14
|
+
*/
|
|
15
|
+
export interface ConsentBranding {
|
|
16
|
+
/** Primary brand color (hex format, e.g., '#0066CC') */
|
|
17
|
+
primaryColor?: string;
|
|
18
|
+
|
|
19
|
+
/** Logo URL for display on consent page */
|
|
20
|
+
logoUrl?: string;
|
|
21
|
+
|
|
22
|
+
/** Company/application name */
|
|
23
|
+
companyName?: string;
|
|
24
|
+
|
|
25
|
+
/** Theme preference ('light', 'dark', or 'auto' for system preference) */
|
|
26
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Consent Terms Configuration
|
|
31
|
+
*
|
|
32
|
+
* Terms of service or privacy policy information
|
|
33
|
+
*/
|
|
34
|
+
export interface ConsentTerms {
|
|
35
|
+
/** Full terms text (displayed on page) */
|
|
36
|
+
text?: string;
|
|
37
|
+
|
|
38
|
+
/** URL to terms document */
|
|
39
|
+
url?: string;
|
|
40
|
+
|
|
41
|
+
/** Version identifier for terms */
|
|
42
|
+
version?: string;
|
|
43
|
+
|
|
44
|
+
/** Whether terms acceptance is required */
|
|
45
|
+
required?: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Consent Custom Field
|
|
50
|
+
*
|
|
51
|
+
* Additional fields to collect during consent (e.g., email, preferences)
|
|
52
|
+
*/
|
|
53
|
+
export interface ConsentCustomField {
|
|
54
|
+
/** Field name (used as form field name, must be valid identifier) */
|
|
55
|
+
name: string;
|
|
56
|
+
|
|
57
|
+
/** Display label for the field */
|
|
58
|
+
label: string;
|
|
59
|
+
|
|
60
|
+
/** Field type */
|
|
61
|
+
type: 'text' | 'textarea' | 'checkbox' | 'select';
|
|
62
|
+
|
|
63
|
+
/** Whether field is required */
|
|
64
|
+
required: boolean;
|
|
65
|
+
|
|
66
|
+
/** Placeholder text */
|
|
67
|
+
placeholder?: string;
|
|
68
|
+
|
|
69
|
+
/** Options for select fields */
|
|
70
|
+
options?: Array<{ value: string; label: string }>;
|
|
71
|
+
|
|
72
|
+
/** Validation pattern (regex) */
|
|
73
|
+
pattern?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Consent Page Configuration
|
|
78
|
+
*
|
|
79
|
+
* Complete configuration for rendering a consent page
|
|
80
|
+
*/
|
|
81
|
+
export interface ConsentPageConfig {
|
|
82
|
+
/** Tool name requiring authorization */
|
|
83
|
+
tool: string;
|
|
84
|
+
|
|
85
|
+
/** Description of what the tool does */
|
|
86
|
+
toolDescription: string;
|
|
87
|
+
|
|
88
|
+
/** Scopes being requested */
|
|
89
|
+
scopes: string[];
|
|
90
|
+
|
|
91
|
+
/** Agent DID requesting authorization */
|
|
92
|
+
agentDid: string;
|
|
93
|
+
|
|
94
|
+
/** Session ID for tracking */
|
|
95
|
+
sessionId: string;
|
|
96
|
+
|
|
97
|
+
/** Project ID from AgentShield */
|
|
98
|
+
projectId: string;
|
|
99
|
+
|
|
100
|
+
/** Branding configuration */
|
|
101
|
+
branding?: ConsentBranding;
|
|
102
|
+
|
|
103
|
+
/** Terms configuration */
|
|
104
|
+
terms?: ConsentTerms;
|
|
105
|
+
|
|
106
|
+
/** Custom fields to collect */
|
|
107
|
+
customFields?: ConsentCustomField[];
|
|
108
|
+
|
|
109
|
+
/** Server URL for form submission */
|
|
110
|
+
serverUrl: string;
|
|
111
|
+
|
|
112
|
+
/** Whether to auto-close window after success */
|
|
113
|
+
autoClose?: boolean;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Consent Approval Request
|
|
118
|
+
*
|
|
119
|
+
* Request payload when user approves consent
|
|
120
|
+
*/
|
|
121
|
+
export interface ConsentApprovalRequest {
|
|
122
|
+
/** Tool name */
|
|
123
|
+
tool: string;
|
|
124
|
+
|
|
125
|
+
/** Approved scopes */
|
|
126
|
+
scopes: string[];
|
|
127
|
+
|
|
128
|
+
/** Agent DID (snake_case for API compatibility) */
|
|
129
|
+
agent_did: string;
|
|
130
|
+
|
|
131
|
+
/** Session ID (snake_case for API compatibility) */
|
|
132
|
+
session_id: string;
|
|
133
|
+
|
|
134
|
+
/** Project ID (snake_case for API compatibility) */
|
|
135
|
+
project_id: string;
|
|
136
|
+
|
|
137
|
+
/** Whether terms were accepted */
|
|
138
|
+
termsAccepted: boolean;
|
|
139
|
+
|
|
140
|
+
/** Terms version (if applicable) */
|
|
141
|
+
termsVersion?: string;
|
|
142
|
+
|
|
143
|
+
/** Custom field values */
|
|
144
|
+
customFields?: Record<string, string | boolean>;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Consent Approval Response
|
|
149
|
+
*
|
|
150
|
+
* Response after processing consent approval
|
|
151
|
+
*/
|
|
152
|
+
export interface ConsentApprovalResponse {
|
|
153
|
+
/** Whether approval was successful */
|
|
154
|
+
success: boolean;
|
|
155
|
+
|
|
156
|
+
/** Delegation ID (if successful) */
|
|
157
|
+
delegation_id?: string;
|
|
158
|
+
|
|
159
|
+
/** Delegation token (if successful) */
|
|
160
|
+
delegation_token?: string;
|
|
161
|
+
|
|
162
|
+
/** Error message (if failed) */
|
|
163
|
+
error?: string;
|
|
164
|
+
|
|
165
|
+
/** Error code (if failed) */
|
|
166
|
+
error_code?: string;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Consent Configuration
|
|
171
|
+
*
|
|
172
|
+
* Complete consent configuration fetched from AgentShield or defaults
|
|
173
|
+
*/
|
|
174
|
+
export interface ConsentConfig {
|
|
175
|
+
/** Branding configuration */
|
|
176
|
+
branding?: ConsentBranding;
|
|
177
|
+
|
|
178
|
+
/** Terms configuration */
|
|
179
|
+
terms?: ConsentTerms;
|
|
180
|
+
|
|
181
|
+
/** Custom fields configuration */
|
|
182
|
+
customFields?: ConsentCustomField[];
|
|
183
|
+
|
|
184
|
+
/** UI preferences */
|
|
185
|
+
ui?: {
|
|
186
|
+
/** Theme preference */
|
|
187
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
188
|
+
|
|
189
|
+
/** Whether popup mode is enabled */
|
|
190
|
+
popupEnabled?: boolean;
|
|
191
|
+
|
|
192
|
+
/** Whether to auto-close after success */
|
|
193
|
+
autoClose?: boolean;
|
|
194
|
+
|
|
195
|
+
/** Delay before auto-close (milliseconds) */
|
|
196
|
+
autoCloseDelay?: number;
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"identity": {
|
|
3
|
+
"agentDid": "",
|
|
4
|
+
"environment": "development",
|
|
5
|
+
"storageLocation": "env-vars"
|
|
6
|
+
},
|
|
7
|
+
"proofing": {
|
|
8
|
+
"enabled": true,
|
|
9
|
+
"destinations": [
|
|
10
|
+
{
|
|
11
|
+
"type": "agentshield",
|
|
12
|
+
"apiUrl": "https://kya.vouched.id"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"batchQueue": {
|
|
16
|
+
"maxBatchSize": 10,
|
|
17
|
+
"flushIntervalMs": 5000,
|
|
18
|
+
"maxRetries": 3
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"delegation": {
|
|
22
|
+
"enabled": true,
|
|
23
|
+
"enforceStrictly": false,
|
|
24
|
+
"verifier": {
|
|
25
|
+
"type": "agentshield",
|
|
26
|
+
"apiUrl": "https://kya.vouched.id/api/v1/bouncer/delegations/verify",
|
|
27
|
+
"cacheTtl": 300000
|
|
28
|
+
},
|
|
29
|
+
"authorization": {
|
|
30
|
+
"authorizationUrl": "https://kya.vouched.id/api/v1/bouncer/delegations/authorize",
|
|
31
|
+
"minReputationScore": 80,
|
|
32
|
+
"resumeTokenTtl": 3600000,
|
|
33
|
+
"requireAuthForUnknown": false
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"toolProtection": {
|
|
37
|
+
"source": "agentshield",
|
|
38
|
+
"agentShield": {
|
|
39
|
+
"apiUrl": "https://kya.vouched.id",
|
|
40
|
+
"cacheTtl": 300000
|
|
41
|
+
},
|
|
42
|
+
"fallback": {}
|
|
43
|
+
},
|
|
44
|
+
"audit": {
|
|
45
|
+
"enabled": true,
|
|
46
|
+
"includeProofHashes": false,
|
|
47
|
+
"includePayloads": false
|
|
48
|
+
},
|
|
49
|
+
"session": {
|
|
50
|
+
"timestampSkewSeconds": 120,
|
|
51
|
+
"ttlMinutes": 30
|
|
52
|
+
},
|
|
53
|
+
"platform": {
|
|
54
|
+
"type": "node",
|
|
55
|
+
"node": {
|
|
56
|
+
"server": {
|
|
57
|
+
"port": 3000,
|
|
58
|
+
"host": "0.0.0.0",
|
|
59
|
+
"cors": true,
|
|
60
|
+
"timeout": 30000
|
|
61
|
+
},
|
|
62
|
+
"storage": {
|
|
63
|
+
"type": "memory"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"cloudflare": {
|
|
67
|
+
"workers": {
|
|
68
|
+
"cpuMs": 50,
|
|
69
|
+
"memoryMb": 128
|
|
70
|
+
},
|
|
71
|
+
"kvNamespaces": [],
|
|
72
|
+
"environmentVariables": []
|
|
73
|
+
},
|
|
74
|
+
"vercel": {
|
|
75
|
+
"environmentVariables": [],
|
|
76
|
+
"edgeRuntime": {}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"metadata": {
|
|
80
|
+
"version": "1.0.0",
|
|
81
|
+
"lastUpdated": "",
|
|
82
|
+
"source": "dashboard",
|
|
83
|
+
"deploymentStatus": "inactive"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
@@ -0,0 +1,266 @@
|
|
|
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
|
+
|
|
10
|
+
import type { MCPIServerConfig } from "./types.js";
|
|
11
|
+
import { mcpIServerConfigSchema } from "./schemas.js";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Default configuration JSON content
|
|
16
|
+
* Embedded here to avoid TypeScript JSON import issues in build
|
|
17
|
+
*/
|
|
18
|
+
const defaultConfigJson = {
|
|
19
|
+
identity: {
|
|
20
|
+
// agentDid removed - deprecated, use serverDid instead
|
|
21
|
+
serverDid: "", // New field - will be populated when identity is generated
|
|
22
|
+
environment: "development" as const,
|
|
23
|
+
storageLocation: "env-vars" as const,
|
|
24
|
+
},
|
|
25
|
+
proofing: {
|
|
26
|
+
enabled: true,
|
|
27
|
+
destinations: [
|
|
28
|
+
{
|
|
29
|
+
type: "agentshield" as const,
|
|
30
|
+
apiUrl: "https://kya.vouched.id",
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
batchQueue: {
|
|
34
|
+
maxBatchSize: 10,
|
|
35
|
+
flushIntervalMs: 5000,
|
|
36
|
+
maxRetries: 3,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
delegation: {
|
|
40
|
+
enabled: true,
|
|
41
|
+
enforceStrictly: false,
|
|
42
|
+
verifier: {
|
|
43
|
+
type: "agentshield" as const,
|
|
44
|
+
apiUrl: "https://kya.vouched.id/api/v1/bouncer/delegations/verify",
|
|
45
|
+
cacheTtl: 300000,
|
|
46
|
+
},
|
|
47
|
+
authorization: {
|
|
48
|
+
authorizationUrl:
|
|
49
|
+
"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" as const,
|
|
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" as const,
|
|
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" as const,
|
|
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" as const,
|
|
102
|
+
deploymentStatus: "inactive" as const,
|
|
103
|
+
},
|
|
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 = mcpIServerConfigSchema.extend({
|
|
117
|
+
identity: mcpIServerConfigSchema.shape.identity.extend({
|
|
118
|
+
agentDid: z.string().optional(), // Allow empty string or undefined for defaults (deprecated)
|
|
119
|
+
serverDid: z.string(), // Allow empty string for defaults (will be populated later)
|
|
120
|
+
}),
|
|
121
|
+
metadata: mcpIServerConfigSchema.shape.metadata.extend({
|
|
122
|
+
lastUpdated: z.string(), // Allow empty string (will be set dynamically)
|
|
123
|
+
}),
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Default configuration object
|
|
128
|
+
*
|
|
129
|
+
* This is the base default configuration used when creating new user configs.
|
|
130
|
+
* Platform-specific defaults are available via getDefaultConfigForPlatform().
|
|
131
|
+
*/
|
|
132
|
+
export const defaultConfig: MCPIServerConfig = defaultConfigSchema.parse(
|
|
133
|
+
defaultConfigJson
|
|
134
|
+
) as MCPIServerConfig;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Platform-specific default configurations
|
|
138
|
+
*/
|
|
139
|
+
const platformDefaults = {
|
|
140
|
+
node: {
|
|
141
|
+
platform: {
|
|
142
|
+
type: "node" as const,
|
|
143
|
+
node: {
|
|
144
|
+
server: {
|
|
145
|
+
port: 3000,
|
|
146
|
+
host: "0.0.0.0",
|
|
147
|
+
cors: true,
|
|
148
|
+
timeout: 30000,
|
|
149
|
+
},
|
|
150
|
+
storage: {
|
|
151
|
+
type: "memory" as const,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
cloudflare: {
|
|
157
|
+
platform: {
|
|
158
|
+
type: "cloudflare" as const,
|
|
159
|
+
cloudflare: {
|
|
160
|
+
workers: {
|
|
161
|
+
cpuMs: 50,
|
|
162
|
+
memoryMb: 128,
|
|
163
|
+
},
|
|
164
|
+
kvNamespaces: [],
|
|
165
|
+
environmentVariables: [],
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
vercel: {
|
|
170
|
+
platform: {
|
|
171
|
+
type: "vercel" as const,
|
|
172
|
+
vercel: {
|
|
173
|
+
environmentVariables: [],
|
|
174
|
+
edgeRuntime: {},
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Get default configuration for a specific platform
|
|
182
|
+
*
|
|
183
|
+
* Returns the base default config merged with platform-specific defaults.
|
|
184
|
+
*
|
|
185
|
+
* @param platform - Platform type ('node', 'cloudflare', or 'vercel')
|
|
186
|
+
* @returns Platform-specific default configuration
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```typescript
|
|
190
|
+
* const nodeConfig = getDefaultConfigForPlatform('node');
|
|
191
|
+
* const cloudflareConfig = getDefaultConfigForPlatform('cloudflare');
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
export function getDefaultConfigForPlatform(
|
|
195
|
+
platform: "node" | "cloudflare" | "vercel"
|
|
196
|
+
): MCPIServerConfig {
|
|
197
|
+
const platformDefault = platformDefaults[platform];
|
|
198
|
+
|
|
199
|
+
return {
|
|
200
|
+
...defaultConfig,
|
|
201
|
+
platform: platformDefault.platform,
|
|
202
|
+
} as MCPIServerConfig;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Deep merge utility for objects
|
|
207
|
+
*/
|
|
208
|
+
function deepMerge<T extends Record<string, unknown>>(
|
|
209
|
+
target: T,
|
|
210
|
+
source: Partial<T>
|
|
211
|
+
): T {
|
|
212
|
+
const result = { ...target } as T;
|
|
213
|
+
|
|
214
|
+
for (const key in source) {
|
|
215
|
+
const sourceValue = source[key];
|
|
216
|
+
if (
|
|
217
|
+
sourceValue &&
|
|
218
|
+
typeof sourceValue === "object" &&
|
|
219
|
+
!Array.isArray(sourceValue) &&
|
|
220
|
+
sourceValue !== null
|
|
221
|
+
) {
|
|
222
|
+
const targetValue = target[key];
|
|
223
|
+
if (
|
|
224
|
+
targetValue &&
|
|
225
|
+
typeof targetValue === "object" &&
|
|
226
|
+
!Array.isArray(targetValue) &&
|
|
227
|
+
targetValue !== null
|
|
228
|
+
) {
|
|
229
|
+
result[key] = deepMerge(
|
|
230
|
+
targetValue as Record<string, unknown>,
|
|
231
|
+
sourceValue as Record<string, unknown>
|
|
232
|
+
) as T[Extract<keyof T, string>];
|
|
233
|
+
}
|
|
234
|
+
} else if (sourceValue !== undefined) {
|
|
235
|
+
result[key] = sourceValue as T[Extract<keyof T, string>];
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return result;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Merge partial configuration with defaults
|
|
244
|
+
*
|
|
245
|
+
* Deep merges a partial configuration object with the base defaults,
|
|
246
|
+
* ensuring all required fields are present.
|
|
247
|
+
*
|
|
248
|
+
* @param partial - Partial configuration to merge with defaults
|
|
249
|
+
* @returns Complete configuration with defaults applied
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* const config = mergeWithDefaults({
|
|
254
|
+
* proofing: { enabled: false },
|
|
255
|
+
* identity: { environment: 'production' }
|
|
256
|
+
* });
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
export function mergeWithDefaults(
|
|
260
|
+
partial: Partial<MCPIServerConfig>
|
|
261
|
+
): MCPIServerConfig {
|
|
262
|
+
return deepMerge(
|
|
263
|
+
defaultConfig as unknown as Record<string, unknown>,
|
|
264
|
+
partial as unknown as Record<string, unknown>
|
|
265
|
+
) as unknown as MCPIServerConfig;
|
|
266
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dashboard Configuration Module
|
|
3
|
+
*
|
|
4
|
+
* Central export point for dashboard configuration types and schemas.
|
|
5
|
+
*
|
|
6
|
+
* @package @kya-os/contracts/dashboard-config
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Type exports
|
|
10
|
+
export type {
|
|
11
|
+
MCPIServerConfig,
|
|
12
|
+
GetServerConfigRequest,
|
|
13
|
+
GetServerConfigResponse,
|
|
14
|
+
UpdateServerConfigRequest,
|
|
15
|
+
UpdateServerConfigResponse,
|
|
16
|
+
ValidateServerConfigRequest,
|
|
17
|
+
ValidateServerConfigResponse,
|
|
18
|
+
} from './types.js';
|
|
19
|
+
|
|
20
|
+
// Schema exports
|
|
21
|
+
export {
|
|
22
|
+
identityConfigSchema,
|
|
23
|
+
proofingConfigSchema,
|
|
24
|
+
delegationConfigSchema,
|
|
25
|
+
toolProtectionConfigSchema,
|
|
26
|
+
auditConfigSchema,
|
|
27
|
+
sessionConfigSchema,
|
|
28
|
+
platformConfigSchema,
|
|
29
|
+
cloudflarePlatformConfigSchema,
|
|
30
|
+
nodePlatformConfigSchema,
|
|
31
|
+
vercelPlatformConfigSchema,
|
|
32
|
+
configMetadataSchema,
|
|
33
|
+
mcpIServerConfigSchema,
|
|
34
|
+
getServerConfigRequestSchema,
|
|
35
|
+
getServerConfigResponseSchema,
|
|
36
|
+
updateServerConfigRequestSchema,
|
|
37
|
+
updateServerConfigResponseSchema,
|
|
38
|
+
validateServerConfigRequestSchema,
|
|
39
|
+
validateServerConfigResponseSchema,
|
|
40
|
+
} from './schemas.js';
|
|
41
|
+
|
|
42
|
+
// Default configuration exports
|
|
43
|
+
export {
|
|
44
|
+
defaultConfig,
|
|
45
|
+
getDefaultConfigForPlatform,
|
|
46
|
+
mergeWithDefaults,
|
|
47
|
+
} from './default-config.js';
|
|
48
|
+
|