@kya-os/contracts 1.7.1 → 1.7.3

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.
@@ -65,38 +65,38 @@ export declare const AuditContextSchema: z.ZodObject<{
65
65
  */
66
66
  scopeId: z.ZodOptional<z.ZodString>;
67
67
  }, "strip", z.ZodTypeAny, {
68
- requestHash: string;
69
- responseHash: string;
68
+ identity: {
69
+ did: string;
70
+ kid: string;
71
+ } & {
72
+ [k: string]: unknown;
73
+ };
70
74
  session: {
71
75
  audience: string;
72
76
  sessionId: string;
73
77
  } & {
74
78
  [k: string]: unknown;
75
79
  };
80
+ requestHash: string;
81
+ responseHash: string;
76
82
  verified: "yes" | "no";
83
+ scopeId?: string | undefined;
84
+ }, {
77
85
  identity: {
78
86
  did: string;
79
87
  kid: string;
80
88
  } & {
81
89
  [k: string]: unknown;
82
90
  };
83
- scopeId?: string | undefined;
84
- }, {
85
- requestHash: string;
86
- responseHash: string;
87
91
  session: {
88
92
  audience: string;
89
93
  sessionId: string;
90
94
  } & {
91
95
  [k: string]: unknown;
92
96
  };
97
+ requestHash: string;
98
+ responseHash: string;
93
99
  verified: "yes" | "no";
94
- identity: {
95
- did: string;
96
- kid: string;
97
- } & {
98
- [k: string]: unknown;
99
- };
100
100
  scopeId?: string | undefined;
101
101
  }>;
102
102
  export type AuditContext = {
@@ -153,33 +153,33 @@ export declare const AuditEventContextSchema: z.ZodObject<{
153
153
  */
154
154
  eventData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
155
155
  }, "strip", z.ZodTypeAny, {
156
- session: {
157
- audience: string;
158
- sessionId: string;
159
- } & {
160
- [k: string]: unknown;
161
- };
162
156
  identity: {
163
157
  did: string;
164
158
  kid: string;
165
159
  } & {
166
160
  [k: string]: unknown;
167
161
  };
168
- eventType: string;
169
- eventData?: Record<string, unknown> | undefined;
170
- }, {
171
162
  session: {
172
163
  audience: string;
173
164
  sessionId: string;
174
165
  } & {
175
166
  [k: string]: unknown;
176
167
  };
168
+ eventType: string;
169
+ eventData?: Record<string, unknown> | undefined;
170
+ }, {
177
171
  identity: {
178
172
  did: string;
179
173
  kid: string;
180
174
  } & {
181
175
  [k: string]: unknown;
182
176
  };
177
+ session: {
178
+ audience: string;
179
+ sessionId: string;
180
+ } & {
181
+ [k: string]: unknown;
182
+ };
183
183
  eventType: string;
184
184
  eventData?: Record<string, unknown> | undefined;
185
185
  }>;
@@ -0,0 +1,192 @@
1
+ /**
2
+ * Client Messages Configuration Types
3
+ *
4
+ * Types for configuring client-specific delegation error messages.
5
+ * Different MCP clients (Claude, ChatGPT, Cursor, etc.) may benefit from
6
+ * different message formats based on their capabilities.
7
+ *
8
+ * @module @kya-os/contracts/config/client-messages
9
+ */
10
+ import { z } from "zod";
11
+ /**
12
+ * Template configuration for a specific client's messages
13
+ */
14
+ export interface ClientMessageTemplate {
15
+ /**
16
+ * Message template with placeholders: {toolName}, {consentUrl}, {scopes}
17
+ *
18
+ * @example "I need your permission to use {toolName}.\n\n[Click to authorize]({consentUrl})"
19
+ */
20
+ message?: string;
21
+ /**
22
+ * Message template when no consent URL is available
23
+ *
24
+ * @example "Authorization required for {toolName} but no consent URL is available."
25
+ */
26
+ noUrlMessage?: string;
27
+ /**
28
+ * OAuth-specific message template with placeholders: {toolName}, {oauthUrl}, {provider}, {scopes}
29
+ *
30
+ * @example "Sign in with {provider} to use {toolName}.\n\n[Authorize]({oauthUrl})"
31
+ */
32
+ oauthMessage?: string;
33
+ /**
34
+ * Message template when OAuth URL is unavailable
35
+ *
36
+ * @example "Sign-in required for {toolName} but {provider} is not configured."
37
+ */
38
+ noOAuthUrlMessage?: string;
39
+ /**
40
+ * Custom consent URL format (optional override)
41
+ * Can include placeholders: {baseUrl}, {toolName}, {sessionId}, etc.
42
+ */
43
+ consentUrlFormat?: string;
44
+ /**
45
+ * Extra URL parameters to append to consent URL
46
+ *
47
+ * @example { utm_source: "chatgpt", utm_campaign: "delegation" }
48
+ */
49
+ extraParams?: Record<string, string>;
50
+ /**
51
+ * Whether client supports markdown formatting
52
+ * When false, markdown links [text](url) are converted to "text: url"
53
+ *
54
+ * @default true
55
+ */
56
+ supportsMarkdown?: boolean;
57
+ }
58
+ /**
59
+ * Configuration for client-specific messages
60
+ */
61
+ export interface ClientMessagesConfig {
62
+ /**
63
+ * Default template for unknown/unrecognized clients
64
+ */
65
+ default?: ClientMessageTemplate;
66
+ /**
67
+ * Per-client overrides keyed by canonical client ID
68
+ *
69
+ * Known client IDs: "claude", "chatgpt", "cursor", "perplexity",
70
+ * "mcp-inspector", "windsurf", "cline", "zed"
71
+ */
72
+ clients?: Record<string, ClientMessageTemplate>;
73
+ }
74
+ export declare const ClientMessageTemplateSchema: z.ZodObject<{
75
+ message: z.ZodOptional<z.ZodString>;
76
+ noUrlMessage: z.ZodOptional<z.ZodString>;
77
+ oauthMessage: z.ZodOptional<z.ZodString>;
78
+ noOAuthUrlMessage: z.ZodOptional<z.ZodString>;
79
+ consentUrlFormat: z.ZodOptional<z.ZodString>;
80
+ extraParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
81
+ supportsMarkdown: z.ZodOptional<z.ZodBoolean>;
82
+ }, "strip", z.ZodTypeAny, {
83
+ message?: string | undefined;
84
+ noUrlMessage?: string | undefined;
85
+ oauthMessage?: string | undefined;
86
+ noOAuthUrlMessage?: string | undefined;
87
+ consentUrlFormat?: string | undefined;
88
+ extraParams?: Record<string, string> | undefined;
89
+ supportsMarkdown?: boolean | undefined;
90
+ }, {
91
+ message?: string | undefined;
92
+ noUrlMessage?: string | undefined;
93
+ oauthMessage?: string | undefined;
94
+ noOAuthUrlMessage?: string | undefined;
95
+ consentUrlFormat?: string | undefined;
96
+ extraParams?: Record<string, string> | undefined;
97
+ supportsMarkdown?: boolean | undefined;
98
+ }>;
99
+ export declare const ClientMessagesConfigSchema: z.ZodObject<{
100
+ default: z.ZodOptional<z.ZodObject<{
101
+ message: z.ZodOptional<z.ZodString>;
102
+ noUrlMessage: z.ZodOptional<z.ZodString>;
103
+ oauthMessage: z.ZodOptional<z.ZodString>;
104
+ noOAuthUrlMessage: z.ZodOptional<z.ZodString>;
105
+ consentUrlFormat: z.ZodOptional<z.ZodString>;
106
+ extraParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
107
+ supportsMarkdown: z.ZodOptional<z.ZodBoolean>;
108
+ }, "strip", z.ZodTypeAny, {
109
+ message?: string | undefined;
110
+ noUrlMessage?: string | undefined;
111
+ oauthMessage?: string | undefined;
112
+ noOAuthUrlMessage?: string | undefined;
113
+ consentUrlFormat?: string | undefined;
114
+ extraParams?: Record<string, string> | undefined;
115
+ supportsMarkdown?: boolean | undefined;
116
+ }, {
117
+ message?: string | undefined;
118
+ noUrlMessage?: string | undefined;
119
+ oauthMessage?: string | undefined;
120
+ noOAuthUrlMessage?: string | undefined;
121
+ consentUrlFormat?: string | undefined;
122
+ extraParams?: Record<string, string> | undefined;
123
+ supportsMarkdown?: boolean | undefined;
124
+ }>>;
125
+ clients: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
126
+ message: z.ZodOptional<z.ZodString>;
127
+ noUrlMessage: z.ZodOptional<z.ZodString>;
128
+ oauthMessage: z.ZodOptional<z.ZodString>;
129
+ noOAuthUrlMessage: z.ZodOptional<z.ZodString>;
130
+ consentUrlFormat: z.ZodOptional<z.ZodString>;
131
+ extraParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
132
+ supportsMarkdown: z.ZodOptional<z.ZodBoolean>;
133
+ }, "strip", z.ZodTypeAny, {
134
+ message?: string | undefined;
135
+ noUrlMessage?: string | undefined;
136
+ oauthMessage?: string | undefined;
137
+ noOAuthUrlMessage?: string | undefined;
138
+ consentUrlFormat?: string | undefined;
139
+ extraParams?: Record<string, string> | undefined;
140
+ supportsMarkdown?: boolean | undefined;
141
+ }, {
142
+ message?: string | undefined;
143
+ noUrlMessage?: string | undefined;
144
+ oauthMessage?: string | undefined;
145
+ noOAuthUrlMessage?: string | undefined;
146
+ consentUrlFormat?: string | undefined;
147
+ extraParams?: Record<string, string> | undefined;
148
+ supportsMarkdown?: boolean | undefined;
149
+ }>>>;
150
+ }, "strip", z.ZodTypeAny, {
151
+ default?: {
152
+ message?: string | undefined;
153
+ noUrlMessage?: string | undefined;
154
+ oauthMessage?: string | undefined;
155
+ noOAuthUrlMessage?: string | undefined;
156
+ consentUrlFormat?: string | undefined;
157
+ extraParams?: Record<string, string> | undefined;
158
+ supportsMarkdown?: boolean | undefined;
159
+ } | undefined;
160
+ clients?: Record<string, {
161
+ message?: string | undefined;
162
+ noUrlMessage?: string | undefined;
163
+ oauthMessage?: string | undefined;
164
+ noOAuthUrlMessage?: string | undefined;
165
+ consentUrlFormat?: string | undefined;
166
+ extraParams?: Record<string, string> | undefined;
167
+ supportsMarkdown?: boolean | undefined;
168
+ }> | undefined;
169
+ }, {
170
+ default?: {
171
+ message?: string | undefined;
172
+ noUrlMessage?: string | undefined;
173
+ oauthMessage?: string | undefined;
174
+ noOAuthUrlMessage?: string | undefined;
175
+ consentUrlFormat?: string | undefined;
176
+ extraParams?: Record<string, string> | undefined;
177
+ supportsMarkdown?: boolean | undefined;
178
+ } | undefined;
179
+ clients?: Record<string, {
180
+ message?: string | undefined;
181
+ noUrlMessage?: string | undefined;
182
+ oauthMessage?: string | undefined;
183
+ noOAuthUrlMessage?: string | undefined;
184
+ consentUrlFormat?: string | undefined;
185
+ extraParams?: Record<string, string> | undefined;
186
+ supportsMarkdown?: boolean | undefined;
187
+ }> | undefined;
188
+ }>;
189
+ export declare function isClientMessageTemplate(obj: unknown): obj is ClientMessageTemplate;
190
+ export declare function isClientMessagesConfig(obj: unknown): obj is ClientMessagesConfig;
191
+ export declare function validateClientMessageTemplate(obj: unknown): ClientMessageTemplate;
192
+ export declare function validateClientMessagesConfig(obj: unknown): ClientMessagesConfig;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ /**
3
+ * Client Messages Configuration Types
4
+ *
5
+ * Types for configuring client-specific delegation error messages.
6
+ * Different MCP clients (Claude, ChatGPT, Cursor, etc.) may benefit from
7
+ * different message formats based on their capabilities.
8
+ *
9
+ * @module @kya-os/contracts/config/client-messages
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ClientMessagesConfigSchema = exports.ClientMessageTemplateSchema = void 0;
13
+ exports.isClientMessageTemplate = isClientMessageTemplate;
14
+ exports.isClientMessagesConfig = isClientMessagesConfig;
15
+ exports.validateClientMessageTemplate = validateClientMessageTemplate;
16
+ exports.validateClientMessagesConfig = validateClientMessagesConfig;
17
+ const zod_1 = require("zod");
18
+ // Zod Schemas for validation
19
+ exports.ClientMessageTemplateSchema = zod_1.z.object({
20
+ message: zod_1.z.string().optional(),
21
+ noUrlMessage: zod_1.z.string().optional(),
22
+ oauthMessage: zod_1.z.string().optional(),
23
+ noOAuthUrlMessage: zod_1.z.string().optional(),
24
+ consentUrlFormat: zod_1.z.string().optional(),
25
+ extraParams: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
26
+ supportsMarkdown: zod_1.z.boolean().optional(),
27
+ });
28
+ exports.ClientMessagesConfigSchema = zod_1.z.object({
29
+ default: exports.ClientMessageTemplateSchema.optional(),
30
+ clients: zod_1.z.record(zod_1.z.string(), exports.ClientMessageTemplateSchema).optional(),
31
+ });
32
+ // Type guards
33
+ function isClientMessageTemplate(obj) {
34
+ return exports.ClientMessageTemplateSchema.safeParse(obj).success;
35
+ }
36
+ function isClientMessagesConfig(obj) {
37
+ return exports.ClientMessagesConfigSchema.safeParse(obj).success;
38
+ }
39
+ // Validation functions
40
+ function validateClientMessageTemplate(obj) {
41
+ return exports.ClientMessageTemplateSchema.parse(obj);
42
+ }
43
+ function validateClientMessagesConfig(obj) {
44
+ return exports.ClientMessagesConfigSchema.parse(obj);
45
+ }
@@ -11,6 +11,7 @@ import type { RuntimeIdentityConfig } from "./identity.js";
11
11
  import type { ProofingConfig } from "./proofing.js";
12
12
  import type { DelegationConfig } from "./delegation.js";
13
13
  import type { ToolProtectionSourceConfig } from "./tool-protection.js";
14
+ import type { ClientMessagesConfig } from "./client-messages.js";
14
15
  export { MCPIBaseConfig } from "./base.js";
15
16
  export { RuntimeIdentityConfig, AgentIdentity, OAuthProvider, OAuthConfig, IdpTokens, AuthProviderType, BaseProviderConfig, CredentialProviderConfig, CredentialProviderConfigSchema, OAuth2ProviderConfig, OAuth2ProviderConfigSchema, AuthProvider, AuthProviderSchema, } from "./identity.js";
16
17
  export type { ToolExecutionContext } from "./tool-context.js";
@@ -23,6 +24,7 @@ export { ProofingConfig, ProofBatchQueueConfig, ProofDestination, ProofDestinati
23
24
  export { DelegationConfig, DelegationVerifierConfig, DelegationVerifierType, AuthorizationConfig, DelegationRecord, } from "./delegation.js";
24
25
  export { ToolProtection, ToolProtectionMap, ToolProtectionSourceConfig, ToolProtectionSourceType, ToolProtectionServiceConfig, DelegationRequiredErrorData, ToolProtectionResponse, } from "./tool-protection.js";
25
26
  export { buildBaseConfig } from "./builder.js";
27
+ export { ClientMessageTemplate, ClientMessagesConfig, ClientMessageTemplateSchema, ClientMessagesConfigSchema, isClientMessageTemplate, isClientMessagesConfig, validateClientMessageTemplate, validateClientMessagesConfig, } from "./client-messages.js";
26
28
  /**
27
29
  * Complete runtime configuration type
28
30
  * This can be extended by platform-specific configs
@@ -32,4 +34,6 @@ export interface MCPIConfig extends MCPIBaseConfig {
32
34
  proofing?: ProofingConfig;
33
35
  delegation?: DelegationConfig;
34
36
  toolProtection?: ToolProtectionSourceConfig;
37
+ /** Client-specific message configuration for delegation errors */
38
+ clientMessages?: ClientMessagesConfig;
35
39
  }
@@ -8,7 +8,7 @@
8
8
  * @module @kya-os/contracts/config
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.buildBaseConfig = exports.AuthProviderSchema = exports.OAuth2ProviderConfigSchema = exports.CredentialProviderConfigSchema = void 0;
11
+ exports.validateClientMessagesConfig = exports.validateClientMessageTemplate = exports.isClientMessagesConfig = exports.isClientMessageTemplate = exports.ClientMessagesConfigSchema = exports.ClientMessageTemplateSchema = exports.buildBaseConfig = exports.AuthProviderSchema = exports.OAuth2ProviderConfigSchema = exports.CredentialProviderConfigSchema = void 0;
12
12
  // Identity configuration
13
13
  var identity_js_1 = require("./identity.js");
14
14
  Object.defineProperty(exports, "CredentialProviderConfigSchema", { enumerable: true, get: function () { return identity_js_1.CredentialProviderConfigSchema; } });
@@ -17,3 +17,11 @@ Object.defineProperty(exports, "AuthProviderSchema", { enumerable: true, get: fu
17
17
  // Configuration builder utilities
18
18
  var builder_js_1 = require("./builder.js");
19
19
  Object.defineProperty(exports, "buildBaseConfig", { enumerable: true, get: function () { return builder_js_1.buildBaseConfig; } });
20
+ // Client-specific message configuration
21
+ var client_messages_js_1 = require("./client-messages.js");
22
+ Object.defineProperty(exports, "ClientMessageTemplateSchema", { enumerable: true, get: function () { return client_messages_js_1.ClientMessageTemplateSchema; } });
23
+ Object.defineProperty(exports, "ClientMessagesConfigSchema", { enumerable: true, get: function () { return client_messages_js_1.ClientMessagesConfigSchema; } });
24
+ Object.defineProperty(exports, "isClientMessageTemplate", { enumerable: true, get: function () { return client_messages_js_1.isClientMessageTemplate; } });
25
+ Object.defineProperty(exports, "isClientMessagesConfig", { enumerable: true, get: function () { return client_messages_js_1.isClientMessagesConfig; } });
26
+ Object.defineProperty(exports, "validateClientMessageTemplate", { enumerable: true, get: function () { return client_messages_js_1.validateClientMessageTemplate; } });
27
+ Object.defineProperty(exports, "validateClientMessagesConfig", { enumerable: true, get: function () { return client_messages_js_1.validateClientMessagesConfig; } });