@artooi/ag-ui-web-component 0.40.0 → 0.41.1

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.
@@ -1,5 +1,5 @@
1
1
  import { randomUUID } from "@ag-ui/client";
2
- import type { Message } from "@ag-ui/core";
2
+ import { contentToText, type Message } from "@ag-ui/core";
3
3
  import { MESSAGE_ROLE, TOOL_OUTCOME } from "../../constants.js";
4
4
  import type { ActivityRegistry } from "../../core/activity_registry.js";
5
5
  import type { AgUiClient } from "../../core/agui_client.js";
@@ -12,7 +12,7 @@ import type {
12
12
  import type { MessageRole } from "../../core/message_role.js";
13
13
  import { RunIndex } from "../../core/run_index.js";
14
14
  import { toolStatusFromOutcome } from "../../core/tool_outcome.js";
15
- import { answerUnansweredCalls, mintThread } from "../../core/utils.js";
15
+ import { answerUnansweredCalls, metadataOrTopLevel, mintThread } from "../../core/utils.js";
16
16
  import type { ToolCatalog } from "../../tools/tool_catalog.js";
17
17
  import type { AnswerActions } from "../transcript/answer_actions.js";
18
18
  import { renderAttachmentChips } from "../transcript/attachment_chips.js";
@@ -365,7 +365,7 @@ export class ConversationHistory {
365
365
  //
366
366
  // All of it, even where this forks an earlier run and the server's
367
367
  // snapshot stops there: what is saved is what the screen shows.
368
- follows: this.#host.client()?.annotatedMessages ?? this.#restored,
368
+ follows: this.#host.client()?.messages ?? this.#restored,
369
369
  onSaved: (conversation) => {
370
370
  // A continuation stopped by New chat or a thread switch saves once its
371
371
  // request closes, into its own thread; the conversation now on screen
@@ -487,16 +487,14 @@ export class ConversationHistory {
487
487
  const restored = answerUnansweredCalls(
488
488
  messages,
489
489
  // The shape the store holds for a call the client answered the same way:
490
- // its tool message, with the outcome it annotates onto the stored copy.
491
- // Cast at the AG-UI boundary, as the client's own annotation is.
492
- (toolCallId) =>
493
- ({
494
- id: randomUUID(),
495
- role: "tool",
496
- content: unfinished,
497
- toolCallId,
498
- outcome: TOOL_OUTCOME.INTERRUPTED,
499
- }) as Message,
490
+ // its tool message, with the outcome in its metadata.
491
+ (toolCallId) => ({
492
+ id: randomUUID(),
493
+ role: "tool",
494
+ content: unfinished,
495
+ toolCallId,
496
+ metadata: { outcome: TOOL_OUTCOME.INTERRUPTED },
497
+ }),
500
498
  new Set(checkpoint === null ? [] : [checkpoint.toolCallId]),
501
499
  );
502
500
  this.#restored = restored;
@@ -611,16 +609,21 @@ export class ConversationHistory {
611
609
  if (message.role === "tool") {
612
610
  const card = this.#host.transcript.card(message.toolCallId);
613
611
  if (card !== undefined) {
614
- // The outcome `AgUiClient` annotated onto the persisted message, read
615
- // back through the same mapping the live path uses -- so a card that
616
- // said "declined" before the reload still says it after. Narrowed off
617
- // `unknown` rather than trusted, like every other field read out of the
618
- // store: `Message` does not declare it, a host store may not round-trip
619
- // it, and history written before this shipped has none. All three land
620
- // on DONE, which is what this line did unconditionally.
612
+ // The outcome in the message's metadata -- folded there from a server's
613
+ // result by `@ag-ui/client`, or written there by `AgUiClient` for a
614
+ // result it made itself -- read back through the same mapping the live
615
+ // path uses, so a card that said "declined" before the reload still
616
+ // says it after. History stored by an earlier release has it at the
617
+ // top level instead, which is read when the metadata has none. Narrowed
618
+ // off `unknown` rather than trusted, like every other field read out of
619
+ // the store: metadata is open by key, a host store may not round-trip
620
+ // it, and history written before outcomes existed has none. All three
621
+ // land on DONE, which is what this line did unconditionally.
621
622
  card.settle(
622
- toolStatusFromOutcome((message as { outcome?: unknown }).outcome),
623
- message.content,
623
+ toolStatusFromOutcome(metadataOrTopLevel(message, "outcome")),
624
+ // Flattened exactly as the live path flattens it, so a reload shows
625
+ // the card the user watched settle.
626
+ contentToText(message.content),
624
627
  );
625
628
  }
626
629
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION: string = "0.40.0";
1
+ export const VERSION: string = "0.41.1";