@kya-os/mcp-i-core 1.3.7 → 1.3.8-canary.clientinfo.20251126050113

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.
@@ -112,6 +112,46 @@ export class SessionRegistrationService {
112
112
  url,
113
113
  });
114
114
 
115
+ // ✅ EMPIRICAL PROOF: Prepare request headers
116
+ // Try Authorization: Bearer first (same as proofs endpoint)
117
+ // If that fails, AgentShield may need X-AgentShield-Key instead
118
+ const requestHeaders = {
119
+ "Content-Type": "application/json",
120
+ Authorization: `Bearer ${this.config.apiKey}`, // Use same auth as proofs endpoint
121
+ };
122
+
123
+ // ✅ EMPIRICAL PROOF: Log exact request details (sanitized for security)
124
+ const sanitizedHeaders = {
125
+ ...requestHeaders,
126
+ Authorization: `Bearer ${this.config.apiKey.slice(0, 8)}...${this.config.apiKey.slice(-4)}`, // Show first 8 and last 4 chars
127
+ };
128
+
129
+ const sanitizedBody = {
130
+ session_id: request.session_id,
131
+ agent_did: request.agent_did,
132
+ project_id: request.project_id,
133
+ created_at: request.created_at,
134
+ client_info: request.client_info,
135
+ client_identity: request.client_identity,
136
+ server_did: request.server_did,
137
+ ttl_minutes: request.ttl_minutes,
138
+ };
139
+
140
+ this.config.logger(
141
+ "[SessionRegistration] 🔍 EMPIRICAL DEBUG - Request details",
142
+ {
143
+ url,
144
+ method: "POST",
145
+ headers: sanitizedHeaders,
146
+ headerKeys: Object.keys(requestHeaders),
147
+ authHeaderPresent: !!requestHeaders["Authorization"],
148
+ authHeaderName: "Authorization",
149
+ authHeaderFormat: requestHeaders["Authorization"]?.startsWith("Bearer ") ? "Bearer" : "Other",
150
+ body: sanitizedBody,
151
+ bodySize: JSON.stringify(request).length,
152
+ }
153
+ );
154
+
115
155
  // Make the request with timeout
116
156
  const controller = new AbortController();
117
157
  const timeoutId = setTimeout(
@@ -122,47 +162,75 @@ export class SessionRegistrationService {
122
162
  try {
123
163
  const response = await this.config.fetchProvider.fetch(url, {
124
164
  method: "POST",
125
- headers: {
126
- "Content-Type": "application/json",
127
- Authorization: `Bearer ${this.config.apiKey}`,
128
- },
165
+ headers: requestHeaders,
129
166
  body: JSON.stringify(request),
130
167
  signal: controller.signal,
131
168
  });
132
169
 
133
170
  clearTimeout(timeoutId);
134
171
 
172
+ // ✅ EMPIRICAL PROOF: Capture exact response details
173
+ const responseHeaders: Record<string, string> = {};
174
+ response.headers.forEach((value, key) => {
175
+ responseHeaders[key] = value;
176
+ });
177
+
178
+ const responseText = await response
179
+ .text()
180
+ .catch(() => "Failed to read response");
181
+ let responseBody: unknown;
182
+ try {
183
+ responseBody = JSON.parse(responseText);
184
+ } catch {
185
+ responseBody = responseText;
186
+ }
187
+
188
+ // ✅ EMPIRICAL PROOF: Log exact response details
189
+ this.config.logger(
190
+ "[SessionRegistration] 🔍 EMPIRICAL DEBUG - Response details",
191
+ {
192
+ status: response.status,
193
+ statusText: response.statusText,
194
+ ok: response.ok,
195
+ headers: responseHeaders,
196
+ body: responseBody,
197
+ bodyLength: responseText.length,
198
+ clientName: request.client_info.name,
199
+ }
200
+ );
201
+
135
202
  if (!response.ok) {
136
203
  // Log error but don't throw - this is fire-and-forget
137
- const errorText = await response.text().catch(() => "Unknown error");
138
204
  this.config.logger("[SessionRegistration] Registration failed", {
139
205
  sessionId,
140
206
  status: response.status,
141
- error: errorText,
207
+ error: responseText,
208
+ // ✅ EMPIRICAL PROOF: Include full response details
209
+ responseHeaders,
210
+ responseBody,
211
+ clientName: request.client_info.name,
142
212
  });
143
213
  return {
144
214
  success: false,
145
215
  sessionId,
146
- error: `HTTP ${response.status}: ${errorText}`,
216
+ error: `HTTP ${response.status}: ${responseText}`,
147
217
  };
148
218
  }
149
219
 
150
- // Parse response
151
- const responseData = (await response.json()) as {
152
- data?: RegisterSessionResponse;
153
- } & RegisterSessionResponse;
220
+ // Parse response (using already-captured responseBody)
221
+ const responseData = responseBody as
222
+ | { data?: RegisterSessionResponse }
223
+ | RegisterSessionResponse;
154
224
  const parseResult = registerSessionResponseSchema.safeParse(
155
- responseData.data || responseData
225
+ (responseData as { data?: RegisterSessionResponse }).data ||
226
+ responseData
156
227
  );
157
228
 
158
229
  if (!parseResult.success) {
159
- this.config.logger(
160
- "[SessionRegistration] Invalid response format",
161
- {
162
- sessionId,
163
- response: responseData,
164
- }
165
- );
230
+ this.config.logger("[SessionRegistration] Invalid response format", {
231
+ sessionId,
232
+ response: responseData,
233
+ });
166
234
  // Still consider it a success if we got a 200 OK
167
235
  return { success: true, sessionId };
168
236
  }
@@ -187,8 +255,7 @@ export class SessionRegistrationService {
187
255
  }
188
256
 
189
257
  // Log any other error
190
- const errorMsg =
191
- error instanceof Error ? error.message : "Unknown error";
258
+ const errorMsg = error instanceof Error ? error.message : "Unknown error";
192
259
  this.config.logger("[SessionRegistration] Unexpected error", {
193
260
  sessionId,
194
261
  error: errorMsg,
@@ -210,10 +277,13 @@ export class SessionRegistrationService {
210
277
  this.registerSession(request).catch((error) => {
211
278
  // This should never happen since registerSession catches all errors,
212
279
  // but just in case
213
- this.config.logger("[SessionRegistration] Background registration failed", {
214
- sessionId: request.session_id,
215
- error: error instanceof Error ? error.message : "Unknown error",
216
- });
280
+ this.config.logger(
281
+ "[SessionRegistration] Background registration failed",
282
+ {
283
+ sessionId: request.session_id,
284
+ error: error instanceof Error ? error.message : "Unknown error",
285
+ }
286
+ );
217
287
  });
218
288
  }
219
289
  }
@@ -248,4 +318,3 @@ export function createSessionRegistrationService(options: {
248
318
  logger: options.logger,
249
319
  });
250
320
  }
251
-
@@ -1,9 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Read(//Users/dylanhobbs/Documents/@kya-os/xmcp-i/packages/contracts/**)"
5
- ],
6
- "deny": [],
7
- "ask": []
8
- }
9
- }