@tmcp/transport-http 0.4.0 → 0.4.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.
- package/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/index.js +17 -7
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -189,17 +189,27 @@ export class HttpTransport {
|
|
|
189
189
|
},
|
|
190
190
|
});
|
|
191
191
|
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
const handle = async () => {
|
|
193
|
+
const response = await this.#controller_storage.run(
|
|
194
|
+
controller,
|
|
195
|
+
() => this.#server.receive(body, session_id),
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
controller?.enqueue(
|
|
199
|
+
'data: ' + JSON.stringify(response) + '\n\n',
|
|
200
|
+
);
|
|
201
|
+
controller?.close();
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
handle();
|
|
196
205
|
|
|
197
|
-
|
|
198
|
-
controller?.close();
|
|
206
|
+
const messages = Array.isArray(body) ? body : [body];
|
|
199
207
|
|
|
200
208
|
// Determine status code based on response type
|
|
201
209
|
// 202 Accepted for notifications/responses, 200 OK for standard requests
|
|
202
|
-
const status =
|
|
210
|
+
const status = !messages.some((message) => message.id != null)
|
|
211
|
+
? 202
|
|
212
|
+
: 200;
|
|
203
213
|
|
|
204
214
|
return new Response(stream, {
|
|
205
215
|
headers: {
|