@contextableai/clawg-ui 0.4.1 → 0.4.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 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 run endpoint accepts a POST with a JSON body matching the AG-UI `RunAgentInput` schema:
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, createAguiInfoHandler } from "./src/http-handler.js";
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>;
@@ -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, allow = "POST") {
16
- res.setHeader("Allow", 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()}`;
@@ -302,10 +295,14 @@ export function createAguiHttpHandler(api) {
302
295
  }
303
296
  // Resolve agent route
304
297
  const cfg = runtime.config.loadConfig();
298
+ const agentIdHeader = typeof req.headers["x-openclaw-agent-id"] === "string"
299
+ ? req.headers["x-openclaw-agent-id"]
300
+ : undefined;
305
301
  const route = runtime.channel.routing.resolveAgentRoute({
306
302
  cfg,
307
303
  channel: "clawg-ui",
308
304
  peer: { kind: "dm", id: `clawg-ui-${threadId}` },
305
+ accountId: agentIdHeader,
309
306
  });
310
307
  // Set up SSE via EventEncoder
311
308
  const accept = typeof req.headers.accept === "string"
@@ -558,31 +555,3 @@ export function createAguiHttpHandler(api) {
558
555
  }
559
556
  };
560
557
  }
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contextableai/clawg-ui",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "AG-UI protocol channel plugin for OpenClaw — connect CopilotKit and AG-UI clients to your OpenClaw gateway",
5
5
  "type": "module",
6
6
  "license": "MIT",