@kya-os/mcp-i-core 1.3.7 → 1.3.9-canary.clientinfo.20251126121212
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 +1 -1
- package/.turbo/turbo-test$colon$coverage.log +3089 -3275
- package/.turbo/turbo-test.log +1257 -1257
- package/coverage/coverage-final.json +56 -56
- package/dist/__tests__/utils/mock-providers.d.ts +103 -0
- package/dist/__tests__/utils/mock-providers.d.ts.map +1 -0
- package/dist/__tests__/utils/mock-providers.js +293 -0
- package/dist/__tests__/utils/mock-providers.js.map +1 -0
- package/dist/services/session-registration.service.d.ts.map +1 -1
- package/dist/services/session-registration.service.js +90 -10
- package/dist/services/session-registration.service.js.map +1 -1
- package/package.json +1 -1
- package/src/services/session-registration.service.ts +121 -26
- package/.claude/settings.local.json +0 -9
|
@@ -109,9 +109,55 @@ export class SessionRegistrationService {
|
|
|
109
109
|
sessionId,
|
|
110
110
|
agentDid: request.agent_did,
|
|
111
111
|
clientName: request.client_info.name,
|
|
112
|
+
clientVersion: request.client_info.version,
|
|
113
|
+
hasClientIdentity: !!request.client_identity,
|
|
112
114
|
url,
|
|
113
115
|
});
|
|
114
116
|
|
|
117
|
+
// ✅ EMPIRICAL PROOF: Prepare request headers
|
|
118
|
+
// Try Authorization: Bearer first (same as proofs endpoint)
|
|
119
|
+
// If that fails, AgentShield may need X-AgentShield-Key instead
|
|
120
|
+
const requestHeaders = {
|
|
121
|
+
"Content-Type": "application/json",
|
|
122
|
+
Authorization: `Bearer ${this.config.apiKey}`, // Use same auth as proofs endpoint
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// ✅ EMPIRICAL PROOF: Log exact request details (sanitized for security)
|
|
126
|
+
const sanitizedHeaders = {
|
|
127
|
+
...requestHeaders,
|
|
128
|
+
Authorization: `Bearer ${this.config.apiKey.slice(0, 8)}...${this.config.apiKey.slice(-4)}`, // Show first 8 and last 4 chars
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const sanitizedBody = {
|
|
132
|
+
session_id: request.session_id,
|
|
133
|
+
agent_did: request.agent_did,
|
|
134
|
+
project_id: request.project_id,
|
|
135
|
+
created_at: request.created_at,
|
|
136
|
+
client_info: request.client_info,
|
|
137
|
+
client_identity: request.client_identity,
|
|
138
|
+
server_did: request.server_did,
|
|
139
|
+
ttl_minutes: request.ttl_minutes,
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
this.config.logger(
|
|
143
|
+
"[SessionRegistration] 🔍 EMPIRICAL DEBUG - Request details",
|
|
144
|
+
{
|
|
145
|
+
url,
|
|
146
|
+
method: "POST",
|
|
147
|
+
headers: sanitizedHeaders,
|
|
148
|
+
headerKeys: Object.keys(requestHeaders),
|
|
149
|
+
authHeaderPresent: !!requestHeaders["Authorization"],
|
|
150
|
+
authHeaderName: "Authorization",
|
|
151
|
+
authHeaderFormat: requestHeaders["Authorization"]?.startsWith(
|
|
152
|
+
"Bearer "
|
|
153
|
+
)
|
|
154
|
+
? "Bearer"
|
|
155
|
+
: "Other",
|
|
156
|
+
body: sanitizedBody,
|
|
157
|
+
bodySize: JSON.stringify(request).length,
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
|
|
115
161
|
// Make the request with timeout
|
|
116
162
|
const controller = new AbortController();
|
|
117
163
|
const timeoutId = setTimeout(
|
|
@@ -122,47 +168,89 @@ export class SessionRegistrationService {
|
|
|
122
168
|
try {
|
|
123
169
|
const response = await this.config.fetchProvider.fetch(url, {
|
|
124
170
|
method: "POST",
|
|
125
|
-
headers:
|
|
126
|
-
"Content-Type": "application/json",
|
|
127
|
-
Authorization: `Bearer ${this.config.apiKey}`,
|
|
128
|
-
},
|
|
171
|
+
headers: requestHeaders,
|
|
129
172
|
body: JSON.stringify(request),
|
|
130
173
|
signal: controller.signal,
|
|
131
174
|
});
|
|
132
175
|
|
|
133
176
|
clearTimeout(timeoutId);
|
|
134
177
|
|
|
178
|
+
// ✅ EMPIRICAL PROOF: Capture exact response details
|
|
179
|
+
const responseHeaders: Record<string, string> = {};
|
|
180
|
+
response.headers.forEach((value, key) => {
|
|
181
|
+
responseHeaders[key] = value;
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const responseText = await response
|
|
185
|
+
.text()
|
|
186
|
+
.catch(() => "Failed to read response");
|
|
187
|
+
let responseBody: unknown;
|
|
188
|
+
try {
|
|
189
|
+
responseBody = JSON.parse(responseText);
|
|
190
|
+
} catch {
|
|
191
|
+
responseBody = responseText;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// ✅ EMPIRICAL PROOF: Log exact response details
|
|
195
|
+
this.config.logger(
|
|
196
|
+
"[SessionRegistration] 🔍 EMPIRICAL DEBUG - Response details",
|
|
197
|
+
{
|
|
198
|
+
status: response.status,
|
|
199
|
+
statusText: response.statusText,
|
|
200
|
+
ok: response.ok,
|
|
201
|
+
headers: responseHeaders,
|
|
202
|
+
body: responseBody,
|
|
203
|
+
bodyLength: responseText.length,
|
|
204
|
+
clientName: request.client_info.name,
|
|
205
|
+
// ✅ DEBUG: Include request ID from response headers for AgentShield support
|
|
206
|
+
requestId:
|
|
207
|
+
responseHeaders["x-request-id"] ||
|
|
208
|
+
responseHeaders["X-Request-ID"] ||
|
|
209
|
+
"not-provided",
|
|
210
|
+
// ✅ DEBUG: Full response text for AgentShield team
|
|
211
|
+
fullResponseText: responseText,
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
|
|
135
215
|
if (!response.ok) {
|
|
136
216
|
// Log error but don't throw - this is fire-and-forget
|
|
137
|
-
const errorText = await response.text().catch(() => "Unknown error");
|
|
138
217
|
this.config.logger("[SessionRegistration] Registration failed", {
|
|
139
218
|
sessionId,
|
|
140
219
|
status: response.status,
|
|
141
|
-
error:
|
|
220
|
+
error: responseText,
|
|
221
|
+
// ✅ DEBUG: EMPIRICAL: Include full response details
|
|
222
|
+
responseHeaders,
|
|
223
|
+
responseBody,
|
|
224
|
+
clientName: request.client_info.name,
|
|
225
|
+
// ✅ DEBUG: Request ID for AgentShield support ticket
|
|
226
|
+
requestId:
|
|
227
|
+
responseHeaders["x-request-id"] ||
|
|
228
|
+
responseHeaders["X-Request-ID"] ||
|
|
229
|
+
"not-provided",
|
|
230
|
+
// ✅ DEBUG: Full request body for AgentShield team
|
|
231
|
+
fullRequestBody: JSON.stringify(request, null, 2),
|
|
142
232
|
});
|
|
143
233
|
return {
|
|
144
234
|
success: false,
|
|
145
235
|
sessionId,
|
|
146
|
-
error: `HTTP ${response.status}: ${
|
|
236
|
+
error: `HTTP ${response.status}: ${responseText}`,
|
|
147
237
|
};
|
|
148
238
|
}
|
|
149
239
|
|
|
150
|
-
// Parse response
|
|
151
|
-
const responseData =
|
|
152
|
-
data?: RegisterSessionResponse
|
|
153
|
-
|
|
240
|
+
// Parse response (using already-captured responseBody)
|
|
241
|
+
const responseData = responseBody as
|
|
242
|
+
| { data?: RegisterSessionResponse }
|
|
243
|
+
| RegisterSessionResponse;
|
|
154
244
|
const parseResult = registerSessionResponseSchema.safeParse(
|
|
155
|
-
responseData.data ||
|
|
245
|
+
(responseData as { data?: RegisterSessionResponse }).data ||
|
|
246
|
+
responseData
|
|
156
247
|
);
|
|
157
248
|
|
|
158
249
|
if (!parseResult.success) {
|
|
159
|
-
this.config.logger(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
response: responseData,
|
|
164
|
-
}
|
|
165
|
-
);
|
|
250
|
+
this.config.logger("[SessionRegistration] Invalid response format", {
|
|
251
|
+
sessionId,
|
|
252
|
+
response: responseData,
|
|
253
|
+
});
|
|
166
254
|
// Still consider it a success if we got a 200 OK
|
|
167
255
|
return { success: true, sessionId };
|
|
168
256
|
}
|
|
@@ -170,6 +258,12 @@ export class SessionRegistrationService {
|
|
|
170
258
|
this.config.logger("[SessionRegistration] Session registered", {
|
|
171
259
|
sessionId,
|
|
172
260
|
registered: parseResult.data.registered,
|
|
261
|
+
// ✅ DEBUG: Include full response for AgentShield debugging
|
|
262
|
+
responseData: parseResult.data,
|
|
263
|
+
requestId:
|
|
264
|
+
responseHeaders["x-request-id"] ||
|
|
265
|
+
responseHeaders["X-Request-ID"] ||
|
|
266
|
+
"not-provided",
|
|
173
267
|
});
|
|
174
268
|
|
|
175
269
|
return { success: true, sessionId };
|
|
@@ -187,8 +281,7 @@ export class SessionRegistrationService {
|
|
|
187
281
|
}
|
|
188
282
|
|
|
189
283
|
// Log any other error
|
|
190
|
-
const errorMsg =
|
|
191
|
-
error instanceof Error ? error.message : "Unknown error";
|
|
284
|
+
const errorMsg = error instanceof Error ? error.message : "Unknown error";
|
|
192
285
|
this.config.logger("[SessionRegistration] Unexpected error", {
|
|
193
286
|
sessionId,
|
|
194
287
|
error: errorMsg,
|
|
@@ -210,10 +303,13 @@ export class SessionRegistrationService {
|
|
|
210
303
|
this.registerSession(request).catch((error) => {
|
|
211
304
|
// This should never happen since registerSession catches all errors,
|
|
212
305
|
// but just in case
|
|
213
|
-
this.config.logger(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
306
|
+
this.config.logger(
|
|
307
|
+
"[SessionRegistration] Background registration failed",
|
|
308
|
+
{
|
|
309
|
+
sessionId: request.session_id,
|
|
310
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
311
|
+
}
|
|
312
|
+
);
|
|
217
313
|
});
|
|
218
314
|
}
|
|
219
315
|
}
|
|
@@ -248,4 +344,3 @@ export function createSessionRegistrationService(options: {
|
|
|
248
344
|
logger: options.logger,
|
|
249
345
|
});
|
|
250
346
|
}
|
|
251
|
-
|