@dexto/server 1.2.6 → 1.4.0
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/dist/approval/manual-approval-handler.cjs +23 -15
- package/dist/approval/manual-approval-handler.d.ts.map +1 -1
- package/dist/approval/manual-approval-handler.js +23 -15
- package/dist/events/webhook-subscriber.cjs +1 -1
- package/dist/events/webhook-subscriber.d.ts.map +1 -1
- package/dist/events/webhook-subscriber.js +1 -1
- package/dist/hono/__tests__/test-fixtures.cjs +2 -2
- package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
- package/dist/hono/__tests__/test-fixtures.js +2 -2
- package/dist/hono/index.cjs +14 -2
- package/dist/hono/index.d.ts +486 -132
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +17 -2
- package/dist/hono/middleware/error.d.ts.map +1 -1
- package/dist/hono/routes/agents.cjs +8 -10
- package/dist/hono/routes/agents.d.ts +15 -8
- package/dist/hono/routes/agents.d.ts.map +1 -1
- package/dist/hono/routes/agents.js +10 -10
- package/dist/hono/routes/approvals.cjs +52 -1
- package/dist/hono/routes/approvals.d.ts +25 -0
- package/dist/hono/routes/approvals.d.ts.map +1 -1
- package/dist/hono/routes/approvals.js +52 -1
- package/dist/hono/routes/llm.cjs +110 -31
- package/dist/hono/routes/llm.d.ts +89 -37
- package/dist/hono/routes/llm.d.ts.map +1 -1
- package/dist/hono/routes/llm.js +108 -25
- package/dist/hono/routes/mcp.cjs +8 -4
- package/dist/hono/routes/mcp.d.ts +4 -1
- package/dist/hono/routes/mcp.d.ts.map +1 -1
- package/dist/hono/routes/mcp.js +9 -5
- package/dist/hono/routes/memory.d.ts +1 -1
- package/dist/hono/routes/messages.cjs +56 -64
- package/dist/hono/routes/messages.d.ts +101 -57
- package/dist/hono/routes/messages.d.ts.map +1 -1
- package/dist/hono/routes/messages.js +57 -65
- package/dist/hono/routes/prompts.cjs +2 -2
- package/dist/hono/routes/prompts.d.ts +7 -7
- package/dist/hono/routes/prompts.js +2 -2
- package/dist/hono/routes/queue.cjs +202 -0
- package/dist/hono/routes/queue.d.ts +171 -0
- package/dist/hono/routes/queue.d.ts.map +1 -0
- package/dist/hono/routes/queue.js +178 -0
- package/dist/hono/routes/resources.d.ts +1 -1
- package/dist/hono/routes/search.cjs +2 -24
- package/dist/hono/routes/search.d.ts +43 -15
- package/dist/hono/routes/search.d.ts.map +1 -1
- package/dist/hono/routes/search.js +3 -25
- package/dist/hono/routes/sessions.cjs +65 -11
- package/dist/hono/routes/sessions.d.ts +27 -5
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +65 -11
- package/dist/hono/routes/static.cjs +77 -0
- package/dist/hono/routes/static.d.ts +41 -0
- package/dist/hono/routes/static.d.ts.map +1 -0
- package/dist/hono/routes/static.js +52 -0
- package/dist/hono/schemas/responses.cjs +67 -25
- package/dist/hono/schemas/responses.d.ts +2076 -354
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +69 -35
- package/package.json +3 -3
|
@@ -6,17 +6,20 @@ export declare function createMessagesRouter(getAgent: () => DextoAgent, approva
|
|
|
6
6
|
$post: {
|
|
7
7
|
input: {
|
|
8
8
|
json: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
content: string | ({
|
|
10
|
+
type: "text";
|
|
11
|
+
text: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: "image";
|
|
14
|
+
image: string;
|
|
15
|
+
mimeType?: string | undefined;
|
|
16
|
+
} | {
|
|
17
|
+
type: "file";
|
|
16
18
|
mimeType: string;
|
|
17
|
-
|
|
19
|
+
data: string;
|
|
18
20
|
filename?: string | undefined;
|
|
19
|
-
}
|
|
21
|
+
})[];
|
|
22
|
+
sessionId: string;
|
|
20
23
|
};
|
|
21
24
|
};
|
|
22
25
|
output: {
|
|
@@ -28,17 +31,20 @@ export declare function createMessagesRouter(getAgent: () => DextoAgent, approva
|
|
|
28
31
|
} | {
|
|
29
32
|
input: {
|
|
30
33
|
json: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
content: string | ({
|
|
35
|
+
type: "text";
|
|
36
|
+
text: string;
|
|
37
|
+
} | {
|
|
38
|
+
type: "image";
|
|
39
|
+
image: string;
|
|
40
|
+
mimeType?: string | undefined;
|
|
41
|
+
} | {
|
|
42
|
+
type: "file";
|
|
38
43
|
mimeType: string;
|
|
39
|
-
|
|
44
|
+
data: string;
|
|
40
45
|
filename?: string | undefined;
|
|
41
|
-
}
|
|
46
|
+
})[];
|
|
47
|
+
sessionId: string;
|
|
42
48
|
};
|
|
43
49
|
};
|
|
44
50
|
output: {};
|
|
@@ -51,17 +57,20 @@ export declare function createMessagesRouter(getAgent: () => DextoAgent, approva
|
|
|
51
57
|
$post: {
|
|
52
58
|
input: {
|
|
53
59
|
json: {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
content: string | ({
|
|
61
|
+
type: "text";
|
|
62
|
+
text: string;
|
|
63
|
+
} | {
|
|
64
|
+
type: "image";
|
|
65
|
+
image: string;
|
|
66
|
+
mimeType?: string | undefined;
|
|
67
|
+
} | {
|
|
68
|
+
type: "file";
|
|
57
69
|
mimeType: string;
|
|
58
|
-
|
|
59
|
-
} | undefined;
|
|
60
|
-
fileData?: {
|
|
61
|
-
mimeType: string;
|
|
62
|
-
base64: string;
|
|
70
|
+
data: string;
|
|
63
71
|
filename?: string | undefined;
|
|
64
|
-
}
|
|
72
|
+
})[];
|
|
73
|
+
sessionId: string;
|
|
65
74
|
};
|
|
66
75
|
};
|
|
67
76
|
output: {};
|
|
@@ -70,25 +79,25 @@ export declare function createMessagesRouter(getAgent: () => DextoAgent, approva
|
|
|
70
79
|
} | {
|
|
71
80
|
input: {
|
|
72
81
|
json: {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
content: string | ({
|
|
83
|
+
type: "text";
|
|
84
|
+
text: string;
|
|
85
|
+
} | {
|
|
86
|
+
type: "image";
|
|
87
|
+
image: string;
|
|
88
|
+
mimeType?: string | undefined;
|
|
89
|
+
} | {
|
|
90
|
+
type: "file";
|
|
80
91
|
mimeType: string;
|
|
81
|
-
|
|
92
|
+
data: string;
|
|
82
93
|
filename?: string | undefined;
|
|
83
|
-
}
|
|
94
|
+
})[];
|
|
95
|
+
sessionId: string;
|
|
84
96
|
};
|
|
85
97
|
};
|
|
86
98
|
output: {
|
|
87
99
|
sessionId: string;
|
|
88
100
|
response: string;
|
|
89
|
-
provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | undefined;
|
|
90
|
-
model?: string | undefined;
|
|
91
|
-
router?: "vercel" | "in-built" | undefined;
|
|
92
101
|
reasoning?: string | undefined;
|
|
93
102
|
tokenUsage?: {
|
|
94
103
|
inputTokens?: number | undefined;
|
|
@@ -96,6 +105,8 @@ export declare function createMessagesRouter(getAgent: () => DextoAgent, approva
|
|
|
96
105
|
reasoningTokens?: number | undefined;
|
|
97
106
|
totalTokens?: number | undefined;
|
|
98
107
|
} | undefined;
|
|
108
|
+
model?: string | undefined;
|
|
109
|
+
provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | undefined;
|
|
99
110
|
};
|
|
100
111
|
outputFormat: "json";
|
|
101
112
|
status: 200;
|
|
@@ -122,17 +133,20 @@ export declare function createMessagesRouter(getAgent: () => DextoAgent, approva
|
|
|
122
133
|
$post: {
|
|
123
134
|
input: {
|
|
124
135
|
json: {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
136
|
+
content: string | ({
|
|
137
|
+
type: "text";
|
|
138
|
+
text: string;
|
|
139
|
+
} | {
|
|
140
|
+
type: "image";
|
|
141
|
+
image: string;
|
|
142
|
+
mimeType?: string | undefined;
|
|
143
|
+
} | {
|
|
144
|
+
type: "file";
|
|
132
145
|
mimeType: string;
|
|
133
|
-
|
|
146
|
+
data: string;
|
|
134
147
|
filename?: string | undefined;
|
|
135
|
-
}
|
|
148
|
+
})[];
|
|
149
|
+
sessionId: string;
|
|
136
150
|
};
|
|
137
151
|
};
|
|
138
152
|
output: Response;
|
|
@@ -141,22 +155,52 @@ export declare function createMessagesRouter(getAgent: () => DextoAgent, approva
|
|
|
141
155
|
} | {
|
|
142
156
|
input: {
|
|
143
157
|
json: {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
158
|
+
content: string | ({
|
|
159
|
+
type: "text";
|
|
160
|
+
text: string;
|
|
161
|
+
} | {
|
|
162
|
+
type: "image";
|
|
163
|
+
image: string;
|
|
164
|
+
mimeType?: string | undefined;
|
|
165
|
+
} | {
|
|
166
|
+
type: "file";
|
|
151
167
|
mimeType: string;
|
|
152
|
-
|
|
168
|
+
data: string;
|
|
153
169
|
filename?: string | undefined;
|
|
154
|
-
}
|
|
170
|
+
})[];
|
|
171
|
+
sessionId: string;
|
|
155
172
|
};
|
|
156
173
|
};
|
|
157
174
|
output: {};
|
|
158
175
|
outputFormat: string;
|
|
159
176
|
status: 400;
|
|
177
|
+
} | {
|
|
178
|
+
input: {
|
|
179
|
+
json: {
|
|
180
|
+
content: string | ({
|
|
181
|
+
type: "text";
|
|
182
|
+
text: string;
|
|
183
|
+
} | {
|
|
184
|
+
type: "image";
|
|
185
|
+
image: string;
|
|
186
|
+
mimeType?: string | undefined;
|
|
187
|
+
} | {
|
|
188
|
+
type: "file";
|
|
189
|
+
mimeType: string;
|
|
190
|
+
data: string;
|
|
191
|
+
filename?: string | undefined;
|
|
192
|
+
})[];
|
|
193
|
+
sessionId: string;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
output: {
|
|
197
|
+
sessionId: string;
|
|
198
|
+
busy: true;
|
|
199
|
+
queueLength: number;
|
|
200
|
+
hint: string;
|
|
201
|
+
};
|
|
202
|
+
outputFormat: "json";
|
|
203
|
+
status: 202;
|
|
160
204
|
};
|
|
161
205
|
};
|
|
162
206
|
}, "/">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAgB,MAAM,aAAa,CAAC;AAE5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AA2DlF,wBAAgB,oBAAoB,CAChC,QAAQ,EAAE,MAAM,UAAU,EAC1B,mBAAmB,CAAC,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA0U5C"}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
2
2
|
import { streamSSE } from "hono/streaming";
|
|
3
|
-
import { LLM_PROVIDERS
|
|
3
|
+
import { LLM_PROVIDERS } from "@dexto/core";
|
|
4
4
|
import { TokenUsageSchema } from "../schemas/responses.js";
|
|
5
|
+
const TextPartSchema = z.object({
|
|
6
|
+
type: z.literal("text").describe("Content type identifier"),
|
|
7
|
+
text: z.string().describe("Text content")
|
|
8
|
+
}).describe("Text content part");
|
|
9
|
+
const ImagePartSchema = z.object({
|
|
10
|
+
type: z.literal("image").describe("Content type identifier"),
|
|
11
|
+
image: z.string().describe("Base64-encoded image data or URL"),
|
|
12
|
+
mimeType: z.string().optional().describe("MIME type (e.g., image/png)")
|
|
13
|
+
}).describe("Image content part");
|
|
14
|
+
const FilePartSchema = z.object({
|
|
15
|
+
type: z.literal("file").describe("Content type identifier"),
|
|
16
|
+
data: z.string().describe("Base64-encoded file data or URL"),
|
|
17
|
+
mimeType: z.string().describe("MIME type (e.g., application/pdf)"),
|
|
18
|
+
filename: z.string().optional().describe("Optional filename")
|
|
19
|
+
}).describe("File content part");
|
|
20
|
+
const ContentPartSchema = z.discriminatedUnion("type", [TextPartSchema, ImagePartSchema, FilePartSchema]).describe("Content part - text, image, or file");
|
|
5
21
|
const MessageBodySchema = z.object({
|
|
6
|
-
|
|
7
|
-
sessionId: z.string().min(1, "Session ID is required").describe("The session to use for this message")
|
|
8
|
-
|
|
9
|
-
base64: z.string().describe("Base64-encoded image data"),
|
|
10
|
-
mimeType: z.string().describe("The MIME type of the image (e.g., image/png)")
|
|
11
|
-
}).optional().describe("Optional image data to include with the message"),
|
|
12
|
-
fileData: z.object({
|
|
13
|
-
base64: z.string().describe("Base64-encoded file data"),
|
|
14
|
-
mimeType: z.string().describe("The MIME type of the file (e.g., application/pdf)"),
|
|
15
|
-
filename: z.string().optional().describe("The filename")
|
|
16
|
-
}).optional().describe("Optional file data to include with the message")
|
|
17
|
-
}).refine(
|
|
18
|
-
(data) => {
|
|
19
|
-
const msg = (data.message ?? "").trim();
|
|
20
|
-
return msg.length > 0 || !!data.imageData || !!data.fileData;
|
|
21
|
-
},
|
|
22
|
-
{ message: "Must provide either message text, image data, or file data" }
|
|
23
|
-
).describe("Request body for sending a message to the agent");
|
|
22
|
+
content: z.union([z.string(), z.array(ContentPartSchema)]).describe("Message content - string for text, or ContentPart[] for multimodal"),
|
|
23
|
+
sessionId: z.string().min(1, "Session ID is required").describe("The session to use for this message")
|
|
24
|
+
}).describe("Request body for sending a message to the agent");
|
|
24
25
|
const ResetBodySchema = z.object({
|
|
25
26
|
sessionId: z.string().min(1, "Session ID is required").describe("The ID of the session to reset")
|
|
26
27
|
}).describe("Request body for resetting a conversation");
|
|
@@ -72,8 +73,7 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
|
|
|
72
73
|
tokenUsage: TokenUsageSchema.optional().describe("Token usage statistics"),
|
|
73
74
|
reasoning: z.string().optional().describe("Extended thinking content from reasoning models"),
|
|
74
75
|
model: z.string().optional().describe("Model used for this response"),
|
|
75
|
-
provider: z.enum(LLM_PROVIDERS).optional().describe("LLM provider")
|
|
76
|
-
router: z.enum(LLM_ROUTERS).optional().describe("Router used (e.g., vercel)")
|
|
76
|
+
provider: z.enum(LLM_PROVIDERS).optional().describe("LLM provider")
|
|
77
77
|
}).strict()
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -108,7 +108,7 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
|
|
|
108
108
|
method: "post",
|
|
109
109
|
path: "/message-stream",
|
|
110
110
|
summary: "Stream message response",
|
|
111
|
-
description: "Sends a message and streams the response via Server-Sent Events (SSE). Returns SSE stream directly in response. Events include llm:thinking, llm:chunk, llm:tool-call, llm:tool-result, llm:response, and llm:error.",
|
|
111
|
+
description: "Sends a message and streams the response via Server-Sent Events (SSE). Returns SSE stream directly in response. Events include llm:thinking, llm:chunk, llm:tool-call, llm:tool-result, llm:response, and llm:error. If the session is busy processing another message, returns 202 with queue information.",
|
|
112
112
|
tags: ["messages"],
|
|
113
113
|
request: {
|
|
114
114
|
body: {
|
|
@@ -144,23 +144,28 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
},
|
|
147
|
+
202: {
|
|
148
|
+
description: "Session is busy processing another message. Use the queue endpoints to manage pending messages.",
|
|
149
|
+
content: {
|
|
150
|
+
"application/json": {
|
|
151
|
+
schema: z.object({
|
|
152
|
+
busy: z.literal(true).describe("Indicates session is busy"),
|
|
153
|
+
sessionId: z.string().describe("The session ID"),
|
|
154
|
+
queueLength: z.number().describe("Current number of messages in queue"),
|
|
155
|
+
hint: z.string().describe("Instructions for the client")
|
|
156
|
+
}).strict()
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
147
160
|
400: { description: "Validation error" }
|
|
148
161
|
}
|
|
149
162
|
});
|
|
150
163
|
return app.openapi(messageRoute, async (ctx) => {
|
|
151
164
|
const agent = getAgent();
|
|
152
165
|
agent.logger.info("Received message via POST /api/message");
|
|
153
|
-
const {
|
|
154
|
-
const imageDataInput = imageData ? { image: imageData.base64, mimeType: imageData.mimeType } : void 0;
|
|
155
|
-
const fileDataInput = fileData ? {
|
|
156
|
-
data: fileData.base64,
|
|
157
|
-
mimeType: fileData.mimeType,
|
|
158
|
-
...fileData.filename && { filename: fileData.filename }
|
|
159
|
-
} : void 0;
|
|
160
|
-
if (imageDataInput) agent.logger.info("Image data included in message.");
|
|
161
|
-
if (fileDataInput) agent.logger.info("File data included in message.");
|
|
166
|
+
const { content, sessionId } = ctx.req.valid("json");
|
|
162
167
|
agent.logger.info(`Message for session: ${sessionId}`);
|
|
163
|
-
agent.
|
|
168
|
+
agent.generate(content, sessionId).catch((error) => {
|
|
164
169
|
agent.logger.error(
|
|
165
170
|
`Error in async message processing: ${error instanceof Error ? error.message : String(error)}`
|
|
166
171
|
);
|
|
@@ -169,21 +174,9 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
|
|
|
169
174
|
}).openapi(messageSyncRoute, async (ctx) => {
|
|
170
175
|
const agent = getAgent();
|
|
171
176
|
agent.logger.info("Received message via POST /api/message-sync");
|
|
172
|
-
const {
|
|
173
|
-
const imageDataInput = imageData ? { image: imageData.base64, mimeType: imageData.mimeType } : void 0;
|
|
174
|
-
const fileDataInput = fileData ? {
|
|
175
|
-
data: fileData.base64,
|
|
176
|
-
mimeType: fileData.mimeType,
|
|
177
|
-
...fileData.filename && { filename: fileData.filename }
|
|
178
|
-
} : void 0;
|
|
179
|
-
if (imageDataInput) agent.logger.info("Image data included in message.");
|
|
180
|
-
if (fileDataInput) agent.logger.info("File data included in message.");
|
|
177
|
+
const { content, sessionId } = ctx.req.valid("json");
|
|
181
178
|
agent.logger.info(`Message for session: ${sessionId}`);
|
|
182
|
-
const result = await agent.generate(
|
|
183
|
-
sessionId,
|
|
184
|
-
imageData: imageDataInput,
|
|
185
|
-
fileData: fileDataInput
|
|
186
|
-
});
|
|
179
|
+
const result = await agent.generate(content, sessionId);
|
|
187
180
|
const llmConfig = agent.stateManager.getLLMConfig(sessionId);
|
|
188
181
|
return ctx.json({
|
|
189
182
|
response: result.content,
|
|
@@ -191,9 +184,7 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
|
|
|
191
184
|
tokenUsage: result.usage,
|
|
192
185
|
reasoning: result.reasoning,
|
|
193
186
|
model: llmConfig.model,
|
|
194
|
-
provider: llmConfig.provider
|
|
195
|
-
router: "vercel"
|
|
196
|
-
// Hardcoded for now since we only use Vercel AI SDK
|
|
187
|
+
provider: llmConfig.provider
|
|
197
188
|
});
|
|
198
189
|
}).openapi(resetRoute, async (ctx) => {
|
|
199
190
|
const agent = getAgent();
|
|
@@ -203,22 +194,23 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
|
|
|
203
194
|
return ctx.json({ status: "reset initiated", sessionId });
|
|
204
195
|
}).openapi(messageStreamRoute, async (ctx) => {
|
|
205
196
|
const agent = getAgent();
|
|
206
|
-
const
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
197
|
+
const { content, sessionId } = ctx.req.valid("json");
|
|
198
|
+
const isBusy = await agent.isSessionBusy(sessionId);
|
|
199
|
+
if (isBusy) {
|
|
200
|
+
const queuedMessages = await agent.getQueuedMessages(sessionId);
|
|
201
|
+
return ctx.json(
|
|
202
|
+
{
|
|
203
|
+
busy: true,
|
|
204
|
+
sessionId,
|
|
205
|
+
queueLength: queuedMessages.length,
|
|
206
|
+
hint: "Use POST /api/queue/{sessionId} to queue this message, or wait for the current request to complete."
|
|
207
|
+
},
|
|
208
|
+
202
|
|
209
|
+
);
|
|
210
|
+
}
|
|
214
211
|
const abortController = new AbortController();
|
|
215
212
|
const { signal } = abortController;
|
|
216
|
-
const iterator = await agent.stream(
|
|
217
|
-
sessionId,
|
|
218
|
-
imageData: imageDataInput,
|
|
219
|
-
fileData: fileDataInput,
|
|
220
|
-
signal
|
|
221
|
-
});
|
|
213
|
+
const iterator = await agent.stream(content, sessionId, { signal });
|
|
222
214
|
return streamSSE(ctx, async (stream) => {
|
|
223
215
|
const pendingApprovalEvents = [];
|
|
224
216
|
if (approvalCoordinator) {
|
|
@@ -254,7 +246,7 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
|
|
|
254
246
|
data: JSON.stringify(approvalEvent.data)
|
|
255
247
|
});
|
|
256
248
|
}
|
|
257
|
-
const eventData = event.
|
|
249
|
+
const eventData = event.name === "llm:error" && event.error instanceof Error ? {
|
|
258
250
|
...event,
|
|
259
251
|
error: {
|
|
260
252
|
message: event.error.message,
|
|
@@ -263,7 +255,7 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
|
|
|
263
255
|
}
|
|
264
256
|
} : event;
|
|
265
257
|
await stream.writeSSE({
|
|
266
|
-
event: event.
|
|
258
|
+
event: event.name,
|
|
267
259
|
data: JSON.stringify(eventData)
|
|
268
260
|
});
|
|
269
261
|
}
|
|
@@ -37,7 +37,7 @@ const CustomPromptRequestSchema = import_zod_openapi.z.object({
|
|
|
37
37
|
}).strict()
|
|
38
38
|
).optional().describe("Array of argument definitions"),
|
|
39
39
|
resource: import_zod_openapi.z.object({
|
|
40
|
-
|
|
40
|
+
data: import_zod_openapi.z.string().min(1, "Resource data is required").describe("Base64-encoded resource data"),
|
|
41
41
|
mimeType: import_zod_openapi.z.string().min(1, "Resource MIME type is required").describe("MIME type of the resource (e.g., text/plain, application/pdf)"),
|
|
42
42
|
filename: import_zod_openapi.z.string().optional().describe("Resource filename")
|
|
43
43
|
}).strict().optional().describe("Attach a resource to this prompt")
|
|
@@ -182,7 +182,7 @@ function createPromptsRouter(getAgent) {
|
|
|
182
182
|
...promptArguments && promptArguments.length > 0 ? { arguments: promptArguments } : {},
|
|
183
183
|
...payload.resource ? {
|
|
184
184
|
resource: {
|
|
185
|
-
|
|
185
|
+
data: payload.resource.data,
|
|
186
186
|
mimeType: payload.resource.mimeType,
|
|
187
187
|
...payload.resource.filename ? { filename: payload.resource.filename } : {}
|
|
188
188
|
}
|
|
@@ -10,14 +10,14 @@ export declare function createPromptsRouter(getAgent: () => DextoAgent): OpenAPI
|
|
|
10
10
|
source: "config" | "custom" | "mcp";
|
|
11
11
|
description?: string | undefined;
|
|
12
12
|
title?: string | undefined;
|
|
13
|
+
metadata?: {
|
|
14
|
+
[x: string]: import("hono/utils/types").JSONValue;
|
|
15
|
+
} | undefined;
|
|
13
16
|
arguments?: {
|
|
14
17
|
name: string;
|
|
15
18
|
description?: string | undefined;
|
|
16
19
|
required?: boolean | undefined;
|
|
17
20
|
}[] | undefined;
|
|
18
|
-
metadata?: {
|
|
19
|
-
[x: string]: import("hono/utils/types").JSONValue;
|
|
20
|
-
} | undefined;
|
|
21
21
|
}[];
|
|
22
22
|
};
|
|
23
23
|
outputFormat: "json";
|
|
@@ -40,7 +40,7 @@ export declare function createPromptsRouter(getAgent: () => DextoAgent): OpenAPI
|
|
|
40
40
|
}[] | undefined;
|
|
41
41
|
resource?: {
|
|
42
42
|
mimeType: string;
|
|
43
|
-
|
|
43
|
+
data: string;
|
|
44
44
|
filename?: string | undefined;
|
|
45
45
|
} | undefined;
|
|
46
46
|
};
|
|
@@ -51,14 +51,14 @@ export declare function createPromptsRouter(getAgent: () => DextoAgent): OpenAPI
|
|
|
51
51
|
source: "config" | "custom" | "mcp";
|
|
52
52
|
description?: string | undefined;
|
|
53
53
|
title?: string | undefined;
|
|
54
|
+
metadata?: {
|
|
55
|
+
[x: string]: import("hono/utils/types").JSONValue;
|
|
56
|
+
} | undefined;
|
|
54
57
|
arguments?: {
|
|
55
58
|
name: string;
|
|
56
59
|
description?: string | undefined;
|
|
57
60
|
required?: boolean | undefined;
|
|
58
61
|
}[] | undefined;
|
|
59
|
-
metadata?: {
|
|
60
|
-
[x: string]: import("hono/utils/types").JSONValue;
|
|
61
|
-
} | undefined;
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
64
|
outputFormat: "json";
|
|
@@ -14,7 +14,7 @@ const CustomPromptRequestSchema = z.object({
|
|
|
14
14
|
}).strict()
|
|
15
15
|
).optional().describe("Array of argument definitions"),
|
|
16
16
|
resource: z.object({
|
|
17
|
-
|
|
17
|
+
data: z.string().min(1, "Resource data is required").describe("Base64-encoded resource data"),
|
|
18
18
|
mimeType: z.string().min(1, "Resource MIME type is required").describe("MIME type of the resource (e.g., text/plain, application/pdf)"),
|
|
19
19
|
filename: z.string().optional().describe("Resource filename")
|
|
20
20
|
}).strict().optional().describe("Attach a resource to this prompt")
|
|
@@ -159,7 +159,7 @@ function createPromptsRouter(getAgent) {
|
|
|
159
159
|
...promptArguments && promptArguments.length > 0 ? { arguments: promptArguments } : {},
|
|
160
160
|
...payload.resource ? {
|
|
161
161
|
resource: {
|
|
162
|
-
|
|
162
|
+
data: payload.resource.data,
|
|
163
163
|
mimeType: payload.resource.mimeType,
|
|
164
164
|
...payload.resource.filename ? { filename: payload.resource.filename } : {}
|
|
165
165
|
}
|