@contextableai/clawg-ui 0.2.2 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.3 (2026-02-06)
4
+
5
+ ### Fixed
6
+ - Append `\n\n` paragraph joiner to streamed text deltas so chunks render with proper spacing
7
+ - Include `runId` in all `TEXT_MESSAGE_START`, `TEXT_MESSAGE_CONTENT`, and `TEXT_MESSAGE_END` events for AG-UI protocol compliance
8
+
9
+ ### Changed
10
+ - Set channel defaults to `blockStreaming: true` and `chunkMode: "newline"` for correct paragraph-based streaming out of the box
11
+ - Clean up multi-run logic for tool-call-then-text flows (single run per request)
12
+
3
13
  ## 0.2.2 (2026-02-05)
4
14
 
5
15
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contextableai/clawg-ui",
3
- "version": "0.2.2",
3
+ "version": "0.2.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",
@@ -39,7 +39,11 @@
39
39
  "docsPath": "/channels/clawg-ui",
40
40
  "docsLabel": "clawg-ui",
41
41
  "blurb": "AG-UI protocol endpoint for CopilotKit and HttpAgent clients.",
42
- "order": 90
42
+ "order": 90,
43
+ "defaults": {
44
+ "blockStreaming": true,
45
+ "chunkMode": "newline"
46
+ }
43
47
  },
44
48
  "install": {
45
49
  "npmSpec": "@contextableai/clawg-ui",
@@ -368,8 +368,9 @@ export function createAguiHttpHandler(api: OpenClawPluginApi) {
368
368
  res.flushHeaders?.();
369
369
 
370
370
  let closed = false;
371
- const messageId = `msg-${randomUUID()}`;
371
+ let currentMessageId = `msg-${randomUUID()}`;
372
372
  let messageStarted = false;
373
+ let currentRunId = runId;
373
374
 
374
375
  const writeEvent = (event: { type: EventType } & Record<string, unknown>) => {
375
376
  if (closed) {
@@ -408,7 +409,7 @@ export function createAguiHttpHandler(api: OpenClawPluginApi) {
408
409
  }
409
410
 
410
411
  // Register SSE writer so before/after_tool_call hooks can emit AG-UI events
411
- setWriter(sessionKey, writeEvent, messageId);
412
+ setWriter(sessionKey, writeEvent, currentMessageId);
412
413
  const storePath = runtime.channel.session.resolveStorePath(cfg.session?.store, {
413
414
  agentId: route.agentId,
414
415
  });
@@ -473,18 +474,23 @@ export function createAguiHttpHandler(api: OpenClawPluginApi) {
473
474
  if (!text) {
474
475
  return false;
475
476
  }
477
+
476
478
  if (!messageStarted) {
477
479
  messageStarted = true;
478
480
  writeEvent({
479
481
  type: EventType.TEXT_MESSAGE_START,
480
- messageId,
482
+ messageId: currentMessageId,
483
+ runId: currentRunId,
481
484
  role: "assistant",
482
485
  });
483
486
  }
487
+
488
+ // Join chunks with \n\n (breakPreference: paragraph uses double-newline joiner)
484
489
  writeEvent({
485
490
  type: EventType.TEXT_MESSAGE_CONTENT,
486
- messageId,
487
- delta: text,
491
+ messageId: currentMessageId,
492
+ runId: currentRunId,
493
+ delta: text + "\n\n",
488
494
  });
489
495
  return true;
490
496
  },
@@ -493,32 +499,37 @@ export function createAguiHttpHandler(api: OpenClawPluginApi) {
493
499
  return false;
494
500
  }
495
501
  const text = wasClientToolCalled(sessionKey) ? "" : payload.text?.trim();
502
+
496
503
  if (text) {
497
504
  if (!messageStarted) {
498
505
  messageStarted = true;
499
506
  writeEvent({
500
507
  type: EventType.TEXT_MESSAGE_START,
501
- messageId,
508
+ messageId: currentMessageId,
509
+ runId: currentRunId,
502
510
  role: "assistant",
503
511
  });
504
512
  }
513
+ // Join chunks with \n\n (breakPreference: paragraph uses double-newline joiner)
505
514
  writeEvent({
506
515
  type: EventType.TEXT_MESSAGE_CONTENT,
507
- messageId,
508
- delta: text,
516
+ messageId: currentMessageId,
517
+ runId: currentRunId,
518
+ delta: text + "\n\n",
509
519
  });
510
520
  }
511
521
  // End the message and run
512
522
  if (messageStarted) {
513
523
  writeEvent({
514
524
  type: EventType.TEXT_MESSAGE_END,
515
- messageId,
525
+ messageId: currentMessageId,
526
+ runId: currentRunId,
516
527
  });
517
528
  }
518
529
  writeEvent({
519
530
  type: EventType.RUN_FINISHED,
520
531
  threadId,
521
- runId,
532
+ runId: currentRunId,
522
533
  });
523
534
  closed = true;
524
535
  res.end();
@@ -550,13 +561,14 @@ export function createAguiHttpHandler(api: OpenClawPluginApi) {
550
561
  if (messageStarted) {
551
562
  writeEvent({
552
563
  type: EventType.TEXT_MESSAGE_END,
553
- messageId,
564
+ messageId: currentMessageId,
565
+ runId: currentRunId,
554
566
  });
555
567
  }
556
568
  writeEvent({
557
569
  type: EventType.RUN_FINISHED,
558
570
  threadId,
559
- runId,
571
+ runId: currentRunId,
560
572
  });
561
573
  closed = true;
562
574
  res.end();
package/src/tool-store.ts CHANGED
@@ -129,3 +129,4 @@ export function clearClientToolCalled(sessionKey: string): void {
129
129
  console.log(`[clawg-ui] clearClientToolCalled: sessionKey=${sessionKey}`);
130
130
  clientToolCalledFlags.delete(sessionKey);
131
131
  }
132
+