@artooi/ag-ui-web-component 0.41.1 → 0.41.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 +57 -1
- package/README.md +4 -1
- package/dist/ag-ui-web-component.bundle.js +78 -75
- package/dist/ag-ui-web-component.bundle.js.map +4 -4
- package/dist/constants.d.ts +6 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/core/ag_ui_chat.d.ts.map +1 -1
- package/dist/index.js +1482 -1021
- package/dist/index.js.map +4 -4
- package/dist/ui/history/conversation_history.d.ts +7 -2
- package/dist/ui/history/conversation_history.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +6 -1
- package/src/core/ag_ui_chat.ts +21 -1
- package/src/ui/history/conversation_history.ts +56 -8
- package/src/version.ts +1 -1
|
@@ -49,6 +49,11 @@ export interface ConversationHistoryHost {
|
|
|
49
49
|
readonly requestCredentials: () => RequestCredentials | undefined;
|
|
50
50
|
/** The element's `appendMessage`, which a restored bubble opens through. */
|
|
51
51
|
readonly appendMessage: (role: MessageRole, content: string) => HTMLDivElement;
|
|
52
|
+
/**
|
|
53
|
+
* Draw a turn the user sent and dispatch the submit event, as the element's
|
|
54
|
+
* own send does before it starts a run.
|
|
55
|
+
*/
|
|
56
|
+
readonly announceTurn: (content: string) => void;
|
|
52
57
|
/** Resize the composer to its content. */
|
|
53
58
|
readonly autoGrow: () => void;
|
|
54
59
|
/**
|
|
@@ -188,8 +193,8 @@ export declare class ConversationHistory {
|
|
|
188
193
|
* Giving them to the replay, rather than leaving the client to add them, is
|
|
189
194
|
* what settles each card from its result. The checkpointed call is excluded,
|
|
190
195
|
* because the resume path answers it from the page the reload landed on; that
|
|
191
|
-
* exclusion is held by "
|
|
192
|
-
*
|
|
196
|
+
* exclusion is held by "resumes with the landed page's result, and its card says
|
|
197
|
+
* so" in `ag_ui_chat_reload_mid_run.test.ts`.
|
|
193
198
|
*/
|
|
194
199
|
rehydrate(): Promise<void>;
|
|
195
200
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation_history.d.ts","sourceRoot":"","sources":["../../../src/ui/history/conversation_history.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,qEAAqE;AACrE,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,mEAAmE;IACnE,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,kEAAkE;IAClE,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAC;IACrC,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,EAAE,UA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AOjB;IAED,yEAAyE;IACzE,IAAI,IAAI,QAAQ,GAAG,IAAI,CAatB;IAED,mEAAmE;IACnE,WAAW,IAAI,IAAI,CAQlB;IAED,mEAAmE;IACnE,eAAe,IAAI,IAAI,CAKtB;IAED,0EAA0E;IACpE,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUlD;IAED,kEAAkE;IAClE,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAGlD;IAED,4EAA4E;IAC5E,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAYnC;IAED,kEAAkE;IAC5D,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAMnC;IAWD;;;;;;;;;;;;;;;;;;OAkBG;IACG,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAkIpE;IAYD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAuD/B;IAyBD;;;;;OAKG;IACH,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAyF7B;CAmDF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artooi/ag-ui-web-component",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.3",
|
|
4
4
|
"description": "Framework-free <ag-ui-chat> Web Component over the AG-UI protocol. Drop-in chat sidebar with a pluggable client-side tool registry, DOM driver primitives, animations, and destructive-action confirmation modal.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
package/src/constants.ts
CHANGED
|
@@ -4,7 +4,12 @@
|
|
|
4
4
|
/** The Custom Element tag name registered by {@link defineAgUiChat}. */
|
|
5
5
|
export const ELEMENT_TAG = "ag-ui-chat";
|
|
6
6
|
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* User submitted a message. `detail` is {@link SubmitDetail}.
|
|
9
|
+
*
|
|
10
|
+
* Fires for every turn the user sends: with Send, through `sendMessage`, and
|
|
11
|
+
* as the next turn of a run resumed or forked from the checkpoint panel.
|
|
12
|
+
*/
|
|
8
13
|
export const SUBMIT_EVENT = "ag-ui-submit";
|
|
9
14
|
|
|
10
15
|
/**
|
package/src/core/ag_ui_chat.ts
CHANGED
|
@@ -860,6 +860,9 @@ export class AgUiChat extends HTMLElement {
|
|
|
860
860
|
headersFor: (url) => this.#headersFor(url),
|
|
861
861
|
requestCredentials: () => this.#requestCredentials(),
|
|
862
862
|
appendMessage: (role, content) => this.appendMessage(role, content),
|
|
863
|
+
// A continuation sends only what the composer holds. The tray is not
|
|
864
|
+
// read, so nothing rides along to be drawn or announced.
|
|
865
|
+
announceTurn: (content) => this.#announceTurn(content, []),
|
|
863
866
|
autoGrow: () => autoGrow(this.#input),
|
|
864
867
|
continuationEnded: () => this.#flushQueued(),
|
|
865
868
|
client: () => this.#client,
|
|
@@ -2598,6 +2601,24 @@ export class AgUiChat extends HTMLElement {
|
|
|
2598
2601
|
if (this.#transcript.isEmpty()) {
|
|
2599
2602
|
this.setAttribute("data-composer-settling", "");
|
|
2600
2603
|
}
|
|
2604
|
+
this.#announceTurn(content, attachments);
|
|
2605
|
+
await this.#client_send(content, attachments);
|
|
2606
|
+
}
|
|
2607
|
+
|
|
2608
|
+
/**
|
|
2609
|
+
* Put a turn the user sent on screen, and tell the host it was sent.
|
|
2610
|
+
*
|
|
2611
|
+
* The half of a send that does not depend on where it goes, so both senders
|
|
2612
|
+
* take it from here: {@link sendMessage}, and a checkpoint continuation, which
|
|
2613
|
+
* posts to the resume or fork endpoint on a client of its own. The
|
|
2614
|
+
* continuation used to call that client directly, so the turn went out and
|
|
2615
|
+
* its answer streamed in under no question -- while the save it made held the
|
|
2616
|
+
* turn, and a reload showed what the live transcript never had.
|
|
2617
|
+
*
|
|
2618
|
+
* Arming the composer's travel stays with {@link sendMessage}: continuing a
|
|
2619
|
+
* run is a change of context, and docks at once.
|
|
2620
|
+
*/
|
|
2621
|
+
#announceTurn(content: string, attachments: readonly AttachmentRef[]): void {
|
|
2601
2622
|
const bubble = this.appendMessage(MESSAGE_ROLE.USER, content);
|
|
2602
2623
|
if (attachments.length > 0) {
|
|
2603
2624
|
bubble.appendChild(renderAttachmentChips(attachments));
|
|
@@ -2609,7 +2630,6 @@ export class AgUiChat extends HTMLElement {
|
|
|
2609
2630
|
composed: true,
|
|
2610
2631
|
}),
|
|
2611
2632
|
);
|
|
2612
|
-
await this.#client_send(content, attachments);
|
|
2613
2633
|
}
|
|
2614
2634
|
|
|
2615
2635
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from "@ag-ui/client";
|
|
2
2
|
import { contentToText, type Message } from "@ag-ui/core";
|
|
3
|
-
import { MESSAGE_ROLE, TOOL_OUTCOME } from "../../constants.js";
|
|
3
|
+
import { MESSAGE_ROLE, TOOL_CALL_STATUS, 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";
|
|
6
6
|
import { messageAttachments } from "../../core/attachment.js";
|
|
@@ -59,6 +59,11 @@ export interface ConversationHistoryHost {
|
|
|
59
59
|
readonly requestCredentials: () => RequestCredentials | undefined;
|
|
60
60
|
/** The element's `appendMessage`, which a restored bubble opens through. */
|
|
61
61
|
readonly appendMessage: (role: MessageRole, content: string) => HTMLDivElement;
|
|
62
|
+
/**
|
|
63
|
+
* Draw a turn the user sent and dispatch the submit event, as the element's
|
|
64
|
+
* own send does before it starts a run.
|
|
65
|
+
*/
|
|
66
|
+
readonly announceTurn: (content: string) => void;
|
|
62
67
|
/** Resize the composer to its content. */
|
|
63
68
|
readonly autoGrow: () => void;
|
|
64
69
|
/**
|
|
@@ -392,6 +397,30 @@ export class ConversationHistory {
|
|
|
392
397
|
});
|
|
393
398
|
this.#continuation = client;
|
|
394
399
|
try {
|
|
400
|
+
// Drawn and announced as the element's own send does, because this is
|
|
401
|
+
// the same act sent somewhere else. Without the bubble the answer arrived
|
|
402
|
+
// under no question, while the save below wrote the turn, so a reload
|
|
403
|
+
// showed what the live transcript never had.
|
|
404
|
+
//
|
|
405
|
+
// The submit event fires too. A host listens to it as "the user sent
|
|
406
|
+
// something", which a continued turn is: typed in the composer and sent
|
|
407
|
+
// by a press. Only the endpoint differs, and the host chose that when it
|
|
408
|
+
// configured the panel; leaving it out would make a host's own record of
|
|
409
|
+
// the conversation miss exactly the turns this panel exists to add.
|
|
410
|
+
//
|
|
411
|
+
// Only once the continuation is recorded, because a listener runs here:
|
|
412
|
+
// a host's own send from it is refused as overlapping the run in flight,
|
|
413
|
+
// as it would be from any later moment of this one.
|
|
414
|
+
this.#host.announceTurn(content);
|
|
415
|
+
// A listener can also have stopped it: New chat, a thread switch, or
|
|
416
|
+
// moving the element all reach the stop. That cancelled a client whose
|
|
417
|
+
// run had not begun, and a run resets its own cancellation when it
|
|
418
|
+
// starts, so sending now would start one that nothing holds and nothing
|
|
419
|
+
// can stop -- in a conversation the user has already left, with its
|
|
420
|
+
// tools still driving the page.
|
|
421
|
+
if (this.#continuation !== client) {
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
395
424
|
await client.send(content);
|
|
396
425
|
} finally {
|
|
397
426
|
// Only if it is still the one in flight: stopping forgets it at once, and
|
|
@@ -449,8 +478,8 @@ export class ConversationHistory {
|
|
|
449
478
|
* Giving them to the replay, rather than leaving the client to add them, is
|
|
450
479
|
* what settles each card from its result. The checkpointed call is excluded,
|
|
451
480
|
* because the resume path answers it from the page the reload landed on; that
|
|
452
|
-
* exclusion is held by "
|
|
453
|
-
*
|
|
481
|
+
* exclusion is held by "resumes with the landed page's result, and its card says
|
|
482
|
+
* so" in `ag_ui_chat_reload_mid_run.test.ts`.
|
|
454
483
|
*/
|
|
455
484
|
async rehydrate(): Promise<void> {
|
|
456
485
|
// Guard against a thread-switch race: with a slow remote store, picking
|
|
@@ -648,15 +677,34 @@ export class ConversationHistory {
|
|
|
648
677
|
return {};
|
|
649
678
|
}
|
|
650
679
|
|
|
651
|
-
/**
|
|
680
|
+
/**
|
|
681
|
+
* Complete the checkpointed navigating tool call and continue the run.
|
|
682
|
+
*
|
|
683
|
+
* The call's card is settled here, from the result the continuation carries.
|
|
684
|
+
* The restore left it open on purpose -- it is the one call a reload was
|
|
685
|
+
* expected by -- and nothing after this answers it: the run that follows
|
|
686
|
+
* streams no result for a call the client answered itself. Left open, it
|
|
687
|
+
* spun through the whole continuation, and the sweep that closes a run then
|
|
688
|
+
* found it pending and called it not finished -- on the one call known to
|
|
689
|
+
* have finished, since the page it moved to is the page doing the asking.
|
|
690
|
+
*
|
|
691
|
+
* Settled from the string the stored message holds, and with no outcome,
|
|
692
|
+
* since `addToolResult` writes none, so the card is the one a later reload
|
|
693
|
+
* draws from that message. The card can be missing, when the stored
|
|
694
|
+
* transcript does not hold the call -- a store that kept the checkpoint and
|
|
695
|
+
* lost the turn that made it -- and then there is nothing to settle. That
|
|
696
|
+
* guard is held by "resumes a checkpointed navigating tool call on mount" in
|
|
697
|
+
* `ag_ui_chat.test.ts`, whose transcript never made the call.
|
|
698
|
+
*/
|
|
652
699
|
async #resumeFrom(checkpoint: NavigationCheckpoint): Promise<void> {
|
|
653
700
|
this.#host.conversationStore().saveCheckpoint(this.#threadId, null);
|
|
654
701
|
const client = this.#host.ensureClient();
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
JSON.stringify(this.#host.navigationResult().call(this.#host.element, checkpoint)),
|
|
702
|
+
// Called on the element, as `this.navigationResult(...)` always was.
|
|
703
|
+
const landed = JSON.stringify(
|
|
704
|
+
this.#host.navigationResult().call(this.#host.element, checkpoint),
|
|
659
705
|
);
|
|
706
|
+
client.addToolResult(checkpoint.toolCallId, landed);
|
|
707
|
+
this.#host.transcript.card(checkpoint.toolCallId)?.settle(TOOL_CALL_STATUS.DONE, landed);
|
|
660
708
|
await client.resume();
|
|
661
709
|
}
|
|
662
710
|
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION: string = "0.41.
|
|
1
|
+
export const VERSION: string = "0.41.3";
|