@contextableai/clawg-ui 0.4.3 → 0.4.4

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.
@@ -154,6 +154,16 @@ function buildBodyFromMessages(messages) {
154
154
  };
155
155
  }
156
156
  // ---------------------------------------------------------------------------
157
+ // Format AG-UI context entries for the LLM prompt
158
+ // ---------------------------------------------------------------------------
159
+ function formatContextEntries(context) {
160
+ const entries = context.filter((c) => c.description || c.value);
161
+ if (entries.length === 0)
162
+ return undefined;
163
+ const parts = entries.map((c) => `### ${c.description}\n${c.value}`);
164
+ return `\n\n## Context provided by the UI\n\n${parts.join("\n\n")}`;
165
+ }
166
+ // ---------------------------------------------------------------------------
157
167
  // HTTP handler factory
158
168
  // ---------------------------------------------------------------------------
159
169
  export function createAguiHttpHandler(api) {
@@ -283,6 +293,10 @@ export function createAguiHttpHandler(api) {
283
293
  }
284
294
  // Build body from messages
285
295
  const { body: messageBody } = buildBodyFromMessages(messages);
296
+ // Format AG-UI context entries (if any) for injection into the agent prompt
297
+ const contextSuffix = Array.isArray(input.context) && input.context.length > 0
298
+ ? formatContextEntries(input.context)
299
+ : undefined;
286
300
  if (!messageBody.trim()) {
287
301
  console.log(`[clawg-ui] 400: empty extracted body, roles=[${messages.map((m) => m.role).join(",")}], contents=[${messages.map((m) => JSON.stringify(m.content)).join(",")}]`);
288
302
  sendJson(res, 400, {
@@ -401,6 +415,7 @@ export function createAguiHttpHandler(api) {
401
415
  });
402
416
  const ctxPayload = runtime.channel.reply.finalizeInboundContext({
403
417
  Body: envelopedBody,
418
+ BodyForAgent: contextSuffix ? envelopedBody + contextSuffix : undefined,
404
419
  RawBody: messageBody,
405
420
  CommandBody: messageBody,
406
421
  From: `clawg-ui:${deviceId}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contextableai/clawg-ui",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
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",