@contextableai/clawg-ui 0.3.2 → 0.3.3
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/README.md +1 -1
- package/dist/src/http-handler.js +15 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -141,7 +141,7 @@ The endpoint accepts a POST with a JSON body matching the AG-UI `RunAgentInput`
|
|
|
141
141
|
|---|---|---|---|
|
|
142
142
|
| `threadId` | string | no | Conversation thread ID. Auto-generated if omitted. |
|
|
143
143
|
| `runId` | string | no | Unique run ID. Auto-generated if omitted. |
|
|
144
|
-
| `messages` | Message[] | yes | Array of messages.
|
|
144
|
+
| `messages` | Message[] | yes | Array of messages. May be empty (returns an empty run). For agent execution, at least one `user` or `tool` message should be present. |
|
|
145
145
|
| `tools` | Tool[] | no | Client-side tool definitions. The agent can invoke these; see [Tool call events](#tool-call-events). |
|
|
146
146
|
| `state` | object | no | Client state (reserved for future use). |
|
|
147
147
|
|
package/dist/src/http-handler.js
CHANGED
|
@@ -264,13 +264,21 @@ export function createAguiHttpHandler(api) {
|
|
|
264
264
|
const hasUserMessage = messages.some((m) => m.role === "user");
|
|
265
265
|
const hasToolMessage = messages.some((m) => m.role === "tool");
|
|
266
266
|
if (!hasUserMessage && !hasToolMessage) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
267
|
+
// AG-UI protocol allows empty messages (used for session init/sync).
|
|
268
|
+
// Return a valid empty run instead of 400.
|
|
269
|
+
const accept = typeof req.headers.accept === "string"
|
|
270
|
+
? req.headers.accept
|
|
271
|
+
: "text/event-stream";
|
|
272
|
+
const encoder = new EventEncoder({ accept });
|
|
273
|
+
res.statusCode = 200;
|
|
274
|
+
res.setHeader("Content-Type", encoder.getContentType());
|
|
275
|
+
res.setHeader("Cache-Control", "no-cache");
|
|
276
|
+
res.setHeader("Connection", "keep-alive");
|
|
277
|
+
res.setHeader("X-Accel-Buffering", "no");
|
|
278
|
+
res.flushHeaders?.();
|
|
279
|
+
res.write(encoder.encode({ type: EventType.RUN_STARTED, threadId, runId }));
|
|
280
|
+
res.write(encoder.encode({ type: EventType.RUN_FINISHED, threadId, runId }));
|
|
281
|
+
res.end();
|
|
274
282
|
return;
|
|
275
283
|
}
|
|
276
284
|
// Build body from messages
|
package/package.json
CHANGED