@arcote.tech/arc-chat 0.5.1 → 0.5.5

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.
@@ -1,49 +0,0 @@
1
- import { route } from "@arcote.tech/arc";
2
- import type { Token } from "@arcote.tech/arc-auth";
3
- import { getStreamSession } from "../streaming/stream-registry";
4
-
5
- export function createToolResultsRoute(config: {
6
- name: string;
7
- userToken: Token;
8
- }) {
9
- return route(`${config.name}ChatToolResults`)
10
- .path(`/chat/${config.name}/tools/:sessionId`)
11
- .protectBy(config.userToken, () => true)
12
- .handle({
13
- POST: async (
14
- _ctx,
15
- req: Request,
16
- params: Record<string, string>,
17
- ) => {
18
- const session = getStreamSession(params.sessionId);
19
- if (!session) {
20
- return new Response(
21
- JSON.stringify({ error: "Session not found" }),
22
- { status: 404, headers: { "Content-Type": "application/json" } },
23
- );
24
- }
25
-
26
- if (session.isClosed()) {
27
- return new Response(
28
- JSON.stringify({ error: "Session already closed" }),
29
- { status: 410, headers: { "Content-Type": "application/json" } },
30
- );
31
- }
32
-
33
- const body = (await req.json()) as {
34
- toolResults: Array<{
35
- toolCallId: string;
36
- name: string;
37
- content: string;
38
- isError: boolean;
39
- }>;
40
- };
41
-
42
- session.resolveClientToolResults(body.toolResults);
43
-
44
- return new Response(JSON.stringify({ ok: true }), {
45
- headers: { "Content-Type": "application/json" },
46
- });
47
- },
48
- });
49
- }