@contextableai/clawg-ui 0.4.1 → 0.4.2
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 -22
- package/dist/index.js +1 -6
- package/dist/src/http-handler.d.ts +0 -1
- package/dist/src/http-handler.js +2 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -133,30 +133,9 @@ function App() {
|
|
|
133
133
|
}
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
## Agent discovery (`/info`)
|
|
137
|
-
|
|
138
|
-
The plugin registers a `/v1/clawg-ui/info` endpoint that CopilotKit and other AG-UI clients use to discover available agents. Accepts GET or POST.
|
|
139
|
-
|
|
140
|
-
```bash
|
|
141
|
-
curl http://localhost:18789/v1/clawg-ui/info \
|
|
142
|
-
-H "Authorization: Bearer <device-token>"
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
Response:
|
|
146
|
-
|
|
147
|
-
```json
|
|
148
|
-
{
|
|
149
|
-
"agents": {
|
|
150
|
-
"main": { "name": "main", "description": "Default agent" }
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
The response reflects the agents configured in OpenClaw's `agents.list` config. If no agents are configured, a default `"main"` agent is returned.
|
|
156
|
-
|
|
157
136
|
## Request format
|
|
158
137
|
|
|
159
|
-
The
|
|
138
|
+
The endpoint accepts a POST with a JSON body matching the AG-UI `RunAgentInput` schema:
|
|
160
139
|
|
|
161
140
|
| Field | Type | Required | Description |
|
|
162
141
|
|---|---|---|---|
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { emptyPluginConfigSchema } from "openclaw/plugin-sdk";
|
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { EventType } from "@ag-ui/core";
|
|
4
4
|
import { aguiChannelPlugin } from "./src/channel.js";
|
|
5
|
-
import { createAguiHttpHandler
|
|
5
|
+
import { createAguiHttpHandler } from "./src/http-handler.js";
|
|
6
6
|
import { clawgUiToolFactory } from "./src/client-tools.js";
|
|
7
7
|
import { getWriter, getMessageId, pushToolCallId, popToolCallId, isClientTool, setClientToolCalled, setToolFiredInRun, } from "./src/tool-store.js";
|
|
8
8
|
/**
|
|
@@ -97,11 +97,6 @@ const plugin = {
|
|
|
97
97
|
auth: "plugin",
|
|
98
98
|
handler: createAguiHttpHandler(api),
|
|
99
99
|
});
|
|
100
|
-
api.registerHttpRoute({
|
|
101
|
-
path: "/v1/clawg-ui/info",
|
|
102
|
-
auth: "plugin",
|
|
103
|
-
handler: createAguiInfoHandler(api),
|
|
104
|
-
});
|
|
105
100
|
api.on("before_tool_call", handleBeforeToolCall);
|
|
106
101
|
api.on("tool_result_persist", handleToolResultPersist);
|
|
107
102
|
// CLI commands for device management
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
2
|
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
3
3
|
export declare function createAguiHttpHandler(api: OpenClawPluginApi): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
4
|
-
export declare function createAguiInfoHandler(api: OpenClawPluginApi): (_req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
package/dist/src/http-handler.js
CHANGED
|
@@ -12,8 +12,8 @@ function sendJson(res, status, body) {
|
|
|
12
12
|
res.setHeader("Content-Type", "application/json; charset=utf-8");
|
|
13
13
|
res.end(JSON.stringify(body));
|
|
14
14
|
}
|
|
15
|
-
function sendMethodNotAllowed(res
|
|
16
|
-
res.setHeader("Allow",
|
|
15
|
+
function sendMethodNotAllowed(res) {
|
|
16
|
+
res.setHeader("Allow", "POST");
|
|
17
17
|
res.statusCode = 405;
|
|
18
18
|
res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
19
19
|
res.end("Method Not Allowed");
|
|
@@ -254,13 +254,6 @@ 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
|
-
}
|
|
264
257
|
const input = body;
|
|
265
258
|
const threadId = input.threadId || `clawg-ui-${randomUUID()}`;
|
|
266
259
|
const runId = input.runId || `clawg-ui-run-${randomUUID()}`;
|
|
@@ -558,31 +551,3 @@ export function createAguiHttpHandler(api) {
|
|
|
558
551
|
}
|
|
559
552
|
};
|
|
560
553
|
}
|
|
561
|
-
// ---------------------------------------------------------------------------
|
|
562
|
-
// /info handler — agent discovery for CopilotKit
|
|
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
|
-
}
|
|
579
|
-
export function createAguiInfoHandler(api) {
|
|
580
|
-
const runtime = api.runtime;
|
|
581
|
-
return async function handleAguiInfo(_req, res) {
|
|
582
|
-
if (_req.method !== "GET" && _req.method !== "POST") {
|
|
583
|
-
sendMethodNotAllowed(res, "GET, POST");
|
|
584
|
-
return;
|
|
585
|
-
}
|
|
586
|
-
sendJson(res, 200, buildAgentsResponse(runtime));
|
|
587
|
-
};
|
|
588
|
-
}
|
package/package.json
CHANGED