@contextableai/clawg-ui 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/dist/src/http-handler.js +23 -13
- package/package.json +1 -1
package/dist/src/http-handler.js
CHANGED
|
@@ -254,6 +254,13 @@ export function createAguiHttpHandler(api) {
|
|
|
254
254
|
});
|
|
255
255
|
return;
|
|
256
256
|
}
|
|
257
|
+
// CopilotKit single-transport sends { method: "info" } to the main URL
|
|
258
|
+
if (body &&
|
|
259
|
+
typeof body === "object" &&
|
|
260
|
+
body.method === "info") {
|
|
261
|
+
sendJson(res, 200, buildAgentsResponse(runtime));
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
257
264
|
const input = body;
|
|
258
265
|
const threadId = input.threadId || `clawg-ui-${randomUUID()}`;
|
|
259
266
|
const runId = input.runId || `clawg-ui-run-${randomUUID()}`;
|
|
@@ -554,6 +561,21 @@ export function createAguiHttpHandler(api) {
|
|
|
554
561
|
// ---------------------------------------------------------------------------
|
|
555
562
|
// /info handler — agent discovery for CopilotKit
|
|
556
563
|
// ---------------------------------------------------------------------------
|
|
564
|
+
function buildAgentsResponse(runtime) {
|
|
565
|
+
const cfg = runtime.config.loadConfig();
|
|
566
|
+
const agentList = cfg
|
|
567
|
+
.agents?.list ?? [];
|
|
568
|
+
const agents = {};
|
|
569
|
+
for (const agent of agentList) {
|
|
570
|
+
const name = agent.name ?? agent.id;
|
|
571
|
+
agents[agent.id] = { name, description: name };
|
|
572
|
+
}
|
|
573
|
+
// If no agents configured, expose a default "main" agent
|
|
574
|
+
if (Object.keys(agents).length === 0) {
|
|
575
|
+
agents["main"] = { name: "main", description: "Default agent" };
|
|
576
|
+
}
|
|
577
|
+
return { agents };
|
|
578
|
+
}
|
|
557
579
|
export function createAguiInfoHandler(api) {
|
|
558
580
|
const runtime = api.runtime;
|
|
559
581
|
return async function handleAguiInfo(_req, res) {
|
|
@@ -561,18 +583,6 @@ export function createAguiInfoHandler(api) {
|
|
|
561
583
|
sendMethodNotAllowed(res, "GET, POST");
|
|
562
584
|
return;
|
|
563
585
|
}
|
|
564
|
-
|
|
565
|
-
const agentList = cfg
|
|
566
|
-
.agents?.list ?? [];
|
|
567
|
-
const agents = {};
|
|
568
|
-
for (const agent of agentList) {
|
|
569
|
-
const name = agent.name ?? agent.id;
|
|
570
|
-
agents[agent.id] = { name, description: name };
|
|
571
|
-
}
|
|
572
|
-
// If no agents configured, expose a default "main" agent
|
|
573
|
-
if (Object.keys(agents).length === 0) {
|
|
574
|
-
agents["main"] = { name: "main", description: "Default agent" };
|
|
575
|
-
}
|
|
576
|
-
sendJson(res, 200, { agents });
|
|
586
|
+
sendJson(res, 200, buildAgentsResponse(runtime));
|
|
577
587
|
};
|
|
578
588
|
}
|
package/package.json
CHANGED