@contextableai/clawg-ui 0.4.0 → 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 -27
- 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");
|
|
@@ -551,28 +551,3 @@ export function createAguiHttpHandler(api) {
|
|
|
551
551
|
}
|
|
552
552
|
};
|
|
553
553
|
}
|
|
554
|
-
// ---------------------------------------------------------------------------
|
|
555
|
-
// /info handler — agent discovery for CopilotKit
|
|
556
|
-
// ---------------------------------------------------------------------------
|
|
557
|
-
export function createAguiInfoHandler(api) {
|
|
558
|
-
const runtime = api.runtime;
|
|
559
|
-
return async function handleAguiInfo(_req, res) {
|
|
560
|
-
if (_req.method !== "GET" && _req.method !== "POST") {
|
|
561
|
-
sendMethodNotAllowed(res, "GET, POST");
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
const cfg = runtime.config.loadConfig();
|
|
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 });
|
|
577
|
-
};
|
|
578
|
-
}
|
package/package.json
CHANGED