@contextableai/clawg-ui 0.3.1 → 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 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. At least one `user` message required. |
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/index.js CHANGED
@@ -108,7 +108,8 @@ const plugin = {
108
108
  .command("devices")
109
109
  .description("List approved devices")
110
110
  .action(async () => {
111
- const devices = await api.runtime.channel.pairing.readAllowFromStore("clawg-ui");
111
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- SDK types lag behind runtime
112
+ const devices = await api.runtime.channel.pairing.readAllowFromStore({ channel: "clawg-ui" });
112
113
  if (devices.length === 0) {
113
114
  console.log("No approved devices.");
114
115
  return;
@@ -226,8 +226,8 @@ export function createAguiHttpHandler(api) {
226
226
  // ---------------------------------------------------------------------------
227
227
  // Pairing check: verify device is approved
228
228
  // ---------------------------------------------------------------------------
229
- const storeAllowFrom = await runtime.channel.pairing
230
- .readAllowFromStore("clawg-ui")
229
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- SDK types lag behind runtime; object form required in 2026.3.7+
230
+ const storeAllowFrom = await runtime.channel.pairing.readAllowFromStore({ channel: "clawg-ui" })
231
231
  .catch(() => []);
232
232
  const normalizedAllowFrom = storeAllowFrom.map((e) => e.replace(/^clawg-ui:/i, "").toLowerCase());
233
233
  const allowed = normalizedAllowFrom.includes(deviceId.toLowerCase());
@@ -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
- console.log(`[clawg-ui] 400: no user/tool message, roles=[${messages.map((m) => m.role).join(",")}], messageCount=${messages.length}`);
268
- sendJson(res, 400, {
269
- error: {
270
- message: "At least one user or tool message is required in `messages`.",
271
- type: "invalid_request_error",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contextableai/clawg-ui",
3
- "version": "0.3.1",
3
+ "version": "0.3.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",