@artooi/ag-ui-web-component 0.16.0 → 0.17.0
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 +87 -1
- package/README.md +29 -2
- package/dist/ag-ui-web-component.bundle.js +87 -55
- package/dist/ag-ui-web-component.bundle.js.map +3 -3
- package/dist/constants.d.ts +12 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/core/ag_ui_chat.d.ts +41 -2
- package/dist/core/ag_ui_chat.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +153 -15
- package/dist/index.js.map +2 -2
- package/dist/ui/attachment_tray.d.ts +2 -0
- package/dist/ui/attachment_tray.d.ts.map +1 -1
- package/dist/ui/checkpoint_menu.d.ts.map +1 -1
- package/dist/ui/styles.d.ts +1 -1
- package/dist/ui/styles.d.ts.map +1 -1
- package/dist/ui/ui_strings.d.ts +2 -0
- package/dist/ui/ui_strings.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +13 -0
- package/src/core/ag_ui_chat.ts +157 -12
- package/src/index.ts +2 -0
- package/src/ui/attachment_tray.ts +5 -0
- package/src/ui/checkpoint_menu.ts +2 -0
- package/src/ui/styles.ts +38 -6
- package/src/ui/ui_strings.ts +4 -0
- package/src/version.ts +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -22,6 +22,18 @@ export declare const TOGGLE_EVENT = "ag-ui-toggle";
|
|
|
22
22
|
* which exposes host state to the agent as ordinary *tools*.
|
|
23
23
|
*/
|
|
24
24
|
export declare const STATE_EVENT = "ag-ui-state";
|
|
25
|
+
/**
|
|
26
|
+
* Event dispatched by `<ag-ui-chat>` whenever the attachment tray changes — a
|
|
27
|
+
* file queued, an upload finishing or failing, a chip removed, the tray
|
|
28
|
+
* cleared after a send. `detail` carries `{ attachments, pending }`:
|
|
29
|
+
* the durable refs of everything that has finished uploading, and how many are
|
|
30
|
+
* still in flight.
|
|
31
|
+
*
|
|
32
|
+
* This is the seam for a host that drives its own composer: without it the tray
|
|
33
|
+
* only ever spoke to the built-in Send button, so a custom send had no way to
|
|
34
|
+
* know whether a file was ready or still uploading.
|
|
35
|
+
*/
|
|
36
|
+
export declare const ATTACHMENT_EVENT = "ag-ui-attachments";
|
|
25
37
|
/** Roles a chat message can take. */
|
|
26
38
|
export declare const MESSAGE_ROLE: {
|
|
27
39
|
readonly USER: "user";
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAGA,wEAAwE;AACxE,eAAO,MAAM,WAAW,eAAe,CAAC;AAExC;;;;GAIG;AACH,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C;;;;;GAKG;AACH,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,gBAAgB,CAAC;AAEzC,qCAAqC;AACrC,eAAO,MAAM,YAAY;aACvB,IAAI,EAAE,MAAM;aACZ,SAAS,EAAE,WAAW;CACd,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,cAAc,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,aAAa,cAAc,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAE7C;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,cAAc,CAAC;AAE1C,yEAAyE;AACzE,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC;;;GAGG;AACH,eAAO,MAAM,gBAAgB;aAC3B,OAAO,EAAE,SAAS;aAClB,IAAI,EAAE,MAAM;aACZ,KAAK,EAAE,OAAO;aACd,QAAQ,EAAE,UAAU;CACZ,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;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3B,OAAO,EAAE,SAAS;aAClB,IAAI,EAAE,MAAM;aACZ,KAAK,EAAE,OAAO;aACd,QAAQ,EAAE,UAAU;CACZ,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;aAC5B,SAAS,EAAE,WAAW;aACtB,KAAK,EAAE,OAAO;aACd,KAAK,EAAE,OAAO;CACN,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,QAAmB,CAAC;AAE7D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY;aACvB,MAAM,EAAE,QAAQ;aAChB,OAAO,EAAE,SAAS;aAClB,OAAO,EAAE,SAAS;aAClB,IAAI,EAAE,MAAM;CACJ,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,eAAe,CAAC;AAErD;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,oBAAoB,CAAC"}
|
|
@@ -23,6 +23,13 @@ export interface SubmitDetail {
|
|
|
23
23
|
/** Durable refs for the files attached to this message (empty when none). */
|
|
24
24
|
readonly attachments: readonly AttachmentRef[];
|
|
25
25
|
}
|
|
26
|
+
/** `detail` shape of the {@link ATTACHMENT_EVENT} CustomEvent. */
|
|
27
|
+
export interface AttachmentsDetail {
|
|
28
|
+
/** Durable refs for every file that has finished uploading. */
|
|
29
|
+
readonly attachments: readonly AttachmentRef[];
|
|
30
|
+
/** How many files are still uploading; a send now would leave these behind. */
|
|
31
|
+
readonly pending: number;
|
|
32
|
+
}
|
|
26
33
|
/** `detail` shape of the {@link STATE_EVENT} CustomEvent. */
|
|
27
34
|
export interface StateDetail {
|
|
28
35
|
readonly state: Readonly<Record<string, unknown>>;
|
|
@@ -183,9 +190,9 @@ export declare class AgUiChat extends HTMLElement {
|
|
|
183
190
|
*/
|
|
184
191
|
resolvePageTarget: ResolvePageTarget;
|
|
185
192
|
constructor();
|
|
186
|
-
/** Attributes
|
|
193
|
+
/** Attributes the element reacts to after it has been connected. */
|
|
187
194
|
static get observedAttributes(): string[];
|
|
188
|
-
attributeChangedCallback(
|
|
195
|
+
attributeChangedCallback(name: string, previous: string | null, value: string | null): void;
|
|
189
196
|
/** Declare a frontend tool the agent may call. */
|
|
190
197
|
registerTool(tool: ClientTool): void;
|
|
191
198
|
/**
|
|
@@ -270,5 +277,37 @@ export declare class AgUiChat extends HTMLElement {
|
|
|
270
277
|
* (the well wraps the *assistant* turn, the user message precedes it).
|
|
271
278
|
*/
|
|
272
279
|
appendMessage(role: MessageRole, content: string): HTMLDivElement;
|
|
280
|
+
/**
|
|
281
|
+
* Send a message as if the user had typed it — renders the user bubble,
|
|
282
|
+
* dispatches {@link SUBMIT_EVENT}, and starts the run.
|
|
283
|
+
*
|
|
284
|
+
* The programmatic half of the composer, for a host driving its own input
|
|
285
|
+
* (a "Ask about this order" button, a command palette, a custom composer
|
|
286
|
+
* replacing the built-in one). Everything the built-in Send does happens
|
|
287
|
+
* here; Send itself now reads the composer, clears it, and calls this.
|
|
288
|
+
*
|
|
289
|
+
* `attachments` are durable {@link AttachmentRef}s — the shape
|
|
290
|
+
* {@link attachFile}'s upload resolves to, and the shape
|
|
291
|
+
* {@link ATTACHMENT_EVENT} reports. Pass them to attach files to the message.
|
|
292
|
+
*
|
|
293
|
+
* No-ops while a run is in flight (a second concurrent run would orphan the
|
|
294
|
+
* first) and for an entirely empty message. Unlike the built-in Send, this
|
|
295
|
+
* does **not** consult the tray: what you pass is what is sent, so a host
|
|
296
|
+
* composer stays in charge of its own state.
|
|
297
|
+
*/
|
|
298
|
+
sendMessage(content: string, attachments?: readonly AttachmentRef[]): Promise<void>;
|
|
299
|
+
/**
|
|
300
|
+
* Queue a file for upload into the attachment tray, exactly as the file
|
|
301
|
+
* picker and drag-and-drop do — validation, progress chip, and all.
|
|
302
|
+
*
|
|
303
|
+
* Returns `false` when uploads are not configured (no `data-attachments-url`
|
|
304
|
+
* and no {@link uploadHandler}), which is the only way for a host to tell;
|
|
305
|
+
* the tray does not exist to report anything in that case.
|
|
306
|
+
*
|
|
307
|
+
* Uploading is asynchronous: watch {@link ATTACHMENT_EVENT} for the resulting
|
|
308
|
+
* {@link AttachmentRef}, and pass it to {@link sendMessage} once `pending`
|
|
309
|
+
* reaches zero.
|
|
310
|
+
*/
|
|
311
|
+
attachFile(file: File): boolean;
|
|
273
312
|
}
|
|
274
313
|
//# sourceMappingURL=ag_ui_chat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ag_ui_chat.d.ts","sourceRoot":"","sources":["../../src/core/ag_ui_chat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAsB,IAAI,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,
|
|
1
|
+
{"version":3,"file":"ag_ui_chat.d.ts","sourceRoot":"","sources":["../../src/core/ag_ui_chat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAsB,IAAI,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAKL,YAAY,EASb,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,KAAK,UAAU,EAAsB,MAAM,kCAAkC,CAAC;AAGvF,OAAO,EAAyB,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAC9F,OAAO,EAAwB,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAE9E,OAAO,EAAoB,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,wBAAwB,CAAC;AAMhC,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,wBAAwB,CAAC;AAQhC,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAA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EAAqE;IACrE,eAAe,IAAI,IAAI,CAEtB;IAED;;;;;OAKG;IACH,WAAW,IAAI,IAAI,CAKlB;IA0BD;;;OAGG;IACH,OAAO,IAAI,IAAI,CAQd;IA4ND;;;;;;;;;;OAUG;IACH,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAehE;IA2UD;;;;;;;;;;;;;;;;;OAiBG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,GAAE,SAAS,aAAa,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB5F;IAED;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAM9B;CAsdF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { COMPACTION_ACTIVITY_TYPE, ELEMENT_TAG, LOAD_CAPABILITY_TOOL, MAX_TOOL_ROUNDS, MESSAGE_ROLE, STATE_EVENT, SUBMIT_EVENT, TOGGLE_EVENT, TOOL_CALL_STATUS, TOOL_DISPLAY, X_CONFIRM_KEY, X_DESTRUCTIVE_KEY, X_NAVIGATES_KEY, X_SUMMARY_KEY, } from "./constants.js";
|
|
2
|
-
export { AgUiChat, type MessageRole, type StateDetail, type SubmitDetail, type ToggleDetail, } from "./core/ag_ui_chat.js";
|
|
1
|
+
export { ATTACHMENT_EVENT, COMPACTION_ACTIVITY_TYPE, ELEMENT_TAG, LOAD_CAPABILITY_TOOL, MAX_TOOL_ROUNDS, MESSAGE_ROLE, STATE_EVENT, SUBMIT_EVENT, TOGGLE_EVENT, TOOL_CALL_STATUS, TOOL_DISPLAY, X_CONFIRM_KEY, X_DESTRUCTIVE_KEY, X_NAVIGATES_KEY, X_SUMMARY_KEY, } from "./constants.js";
|
|
2
|
+
export { AgUiChat, type AttachmentsDetail, type MessageRole, type StateDetail, type SubmitDetail, type ToggleDetail, } from "./core/ag_ui_chat.js";
|
|
3
3
|
export { AgUiClient, type AgUiClientConfig, type AgUiClientHandlers, type AgUiRunInputs, type AgUiToolCall, ConnectionLostError, type ExecuteTool, type InterruptResponse, type ResolveInterrupts, type ToolExecution, } from "./core/agui_client.js";
|
|
4
4
|
export { type AttachmentRef, messageAttachments } from "./core/attachment.js";
|
|
5
5
|
export { type ClientConversationStore, type NavigationCheckpoint, SessionStorageStore, type ThreadMeta, } from "./core/conversation_store.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,wBAAwB,EACxB,WAAW,EACX,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,QAAQ,EACR,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,UAAU,EACV,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,mBAAmB,EACnB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,aAAa,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,aAAa,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,mBAAmB,EACnB,KAAK,UAAU,GAChB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,YAAY,EACjB,eAAe,EACf,KAAK,gBAAgB,GACtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE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,CAAC;AAC9D,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,qBAAqB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,EACL,KAAK,aAAa,EAClB,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ var ELEMENT_TAG = "ag-ui-chat";
|
|
|
3
3
|
var SUBMIT_EVENT = "ag-ui-submit";
|
|
4
4
|
var TOGGLE_EVENT = "ag-ui-toggle";
|
|
5
5
|
var STATE_EVENT = "ag-ui-state";
|
|
6
|
+
var ATTACHMENT_EVENT = "ag-ui-attachments";
|
|
6
7
|
var MESSAGE_ROLE = {
|
|
7
8
|
USER: "user",
|
|
8
9
|
ASSISTANT: "assistant"
|
|
@@ -466,6 +467,7 @@ var DEFAULT_UI_STRINGS = {
|
|
|
466
467
|
usingSkill: "Using skill {name}",
|
|
467
468
|
runInterrupted: "The previous response didn\u2019t finish \u2014 the page changed before it arrived.",
|
|
468
469
|
pageMoved: "The page changed since you last looked at it. Call read_page to see the current page, then retry.",
|
|
470
|
+
attachmentsStillUploading: "{n} file still uploading \u2014 it was not sent with this message and is still attached.",
|
|
469
471
|
skillNeeds: "\u201C{title}\u201D needs: {fields}",
|
|
470
472
|
message: "Message",
|
|
471
473
|
inputPlaceholder: "Ask anything\u2026",
|
|
@@ -693,6 +695,10 @@ var AttachmentTray = class {
|
|
|
693
695
|
hasPending() {
|
|
694
696
|
return this.#items.some((item) => item.status === ATTACHMENT_STATUS.UPLOADING);
|
|
695
697
|
}
|
|
698
|
+
/** How many chips are still uploading — the count a send-time notice names. */
|
|
699
|
+
pendingCount() {
|
|
700
|
+
return this.#items.filter((item) => item.status === ATTACHMENT_STATUS.UPLOADING).length;
|
|
701
|
+
}
|
|
696
702
|
/** Whether the tray holds no chips. */
|
|
697
703
|
isEmpty() {
|
|
698
704
|
return this.#items.length === 0;
|
|
@@ -895,6 +901,7 @@ var CheckpointMenu = class {
|
|
|
895
901
|
header.setAttribute("part", "checkpoints-header");
|
|
896
902
|
this.#heading = document.createElement("span");
|
|
897
903
|
this.#heading.className = "checkpoints-title";
|
|
904
|
+
this.#heading.setAttribute("part", "checkpoints-title");
|
|
898
905
|
this.#heading.textContent = strings.checkpoints;
|
|
899
906
|
header.append(this.#heading);
|
|
900
907
|
this.#list = document.createElement("div");
|
|
@@ -949,6 +956,7 @@ var CheckpointMenu = class {
|
|
|
949
956
|
row.setAttribute("part", "checkpoint-row");
|
|
950
957
|
const label = document.createElement("span");
|
|
951
958
|
label.className = "checkpoint-label";
|
|
959
|
+
label.setAttribute("part", "checkpoint-label");
|
|
952
960
|
label.textContent = run.started_at === null ? run.run_id : relativeTime(Date.parse(run.started_at), Date.now(), this.#strings);
|
|
953
961
|
label.title = run.run_id;
|
|
954
962
|
row.append(label);
|
|
@@ -4231,6 +4239,7 @@ var STYLES = `
|
|
|
4231
4239
|
--ag-ui-user-bg: #4f46e5;
|
|
4232
4240
|
--ag-ui-user-fg: #ffffff;
|
|
4233
4241
|
--ag-ui-assistant-bg: #f1f1f6;
|
|
4242
|
+
--ag-ui-hover: #e7e7ee;
|
|
4234
4243
|
--ag-ui-input-bg: var(--ag-ui-bg);
|
|
4235
4244
|
--ag-ui-tool-bg: var(--ag-ui-assistant-bg);
|
|
4236
4245
|
--ag-ui-tool-fg: var(--ag-ui-accent);
|
|
@@ -4300,6 +4309,7 @@ var STYLES = `
|
|
|
4300
4309
|
--ag-ui-bg: #15151f;
|
|
4301
4310
|
--ag-ui-fg: #e8e8f2;
|
|
4302
4311
|
--ag-ui-assistant-bg: #25253a;
|
|
4312
|
+
--ag-ui-hover: #303049;
|
|
4303
4313
|
--ag-ui-header-bg: #1f1f30;
|
|
4304
4314
|
--ag-ui-header-fg: #e8e8f2;
|
|
4305
4315
|
--ag-ui-border: #33334a;
|
|
@@ -4312,6 +4322,7 @@ var STYLES = `
|
|
|
4312
4322
|
--ag-ui-bg: #15151f;
|
|
4313
4323
|
--ag-ui-fg: #e8e8f2;
|
|
4314
4324
|
--ag-ui-assistant-bg: #25253a;
|
|
4325
|
+
--ag-ui-hover: #303049;
|
|
4315
4326
|
--ag-ui-header-bg: #1f1f30;
|
|
4316
4327
|
--ag-ui-header-fg: #e8e8f2;
|
|
4317
4328
|
--ag-ui-border: #33334a;
|
|
@@ -4327,6 +4338,7 @@ var STYLES = `
|
|
|
4327
4338
|
--ag-ui-accent: #3fb950;
|
|
4328
4339
|
--ag-ui-user-bg: #238636;
|
|
4329
4340
|
--ag-ui-assistant-bg: #161b22;
|
|
4341
|
+
--ag-ui-hover: #21262d;
|
|
4330
4342
|
--ag-ui-header-bg: #010409;
|
|
4331
4343
|
--ag-ui-header-fg: #c9d1d9;
|
|
4332
4344
|
--ag-ui-border: #30363d;
|
|
@@ -4734,6 +4746,34 @@ var STYLES = `
|
|
|
4734
4746
|
color: var(--ag-ui-muted);
|
|
4735
4747
|
}
|
|
4736
4748
|
|
|
4749
|
+
/* Markdown tables. table/thead/tbody/tr/th/td are all in
|
|
4750
|
+
the sanitizer's ALLOWED_TAGS, so an agent emitting one renders it \u2014 and until
|
|
4751
|
+
now rendered it entirely unstyled, overflowing the bubble. A wide table
|
|
4752
|
+
scrolls inside its own box rather than stretching the message: the bubble is
|
|
4753
|
+
width-constrained, so without this the columns either crush or push the
|
|
4754
|
+
layout sideways. */
|
|
4755
|
+
.message--assistant table {
|
|
4756
|
+
display: block;
|
|
4757
|
+
width: fit-content;
|
|
4758
|
+
max-width: 100%;
|
|
4759
|
+
overflow-x: auto;
|
|
4760
|
+
border-collapse: collapse;
|
|
4761
|
+
font-size: 0.95em;
|
|
4762
|
+
}
|
|
4763
|
+
|
|
4764
|
+
.message--assistant th,
|
|
4765
|
+
.message--assistant td {
|
|
4766
|
+
padding: 6px 10px;
|
|
4767
|
+
border: 1px solid var(--ag-ui-border);
|
|
4768
|
+
text-align: left;
|
|
4769
|
+
vertical-align: top;
|
|
4770
|
+
}
|
|
4771
|
+
|
|
4772
|
+
.message--assistant th {
|
|
4773
|
+
background: var(--ag-ui-hover);
|
|
4774
|
+
font-weight: 600;
|
|
4775
|
+
}
|
|
4776
|
+
|
|
4737
4777
|
.pending {
|
|
4738
4778
|
align-self: flex-start;
|
|
4739
4779
|
display: inline-flex;
|
|
@@ -5484,9 +5524,9 @@ var STYLES = `
|
|
|
5484
5524
|
flex-direction: column;
|
|
5485
5525
|
gap: 0.25rem;
|
|
5486
5526
|
padding: 0.5rem;
|
|
5487
|
-
border: 1px solid var(--
|
|
5527
|
+
border: 1px solid var(--ag-ui-border);
|
|
5488
5528
|
border-radius: 0.5rem;
|
|
5489
|
-
background: var(--
|
|
5529
|
+
background: var(--ag-ui-assistant-bg);
|
|
5490
5530
|
box-shadow: 0 6px 24px rgb(0 0 0 / 12%);
|
|
5491
5531
|
max-height: 60%;
|
|
5492
5532
|
overflow-y: auto;
|
|
@@ -5517,7 +5557,7 @@ var STYLES = `
|
|
|
5517
5557
|
}
|
|
5518
5558
|
|
|
5519
5559
|
.checkpoint-row:hover {
|
|
5520
|
-
background: var(--
|
|
5560
|
+
background: var(--ag-ui-hover);
|
|
5521
5561
|
}
|
|
5522
5562
|
|
|
5523
5563
|
.checkpoint-label {
|
|
@@ -5532,7 +5572,7 @@ var STYLES = `
|
|
|
5532
5572
|
font-size: 0.6875rem;
|
|
5533
5573
|
padding: 0 0.375rem;
|
|
5534
5574
|
border-radius: 999px;
|
|
5535
|
-
background: var(--
|
|
5575
|
+
background: var(--ag-ui-hover);
|
|
5536
5576
|
opacity: 0.8;
|
|
5537
5577
|
}
|
|
5538
5578
|
|
|
@@ -5541,14 +5581,14 @@ var STYLES = `
|
|
|
5541
5581
|
font-size: 0.75rem;
|
|
5542
5582
|
cursor: pointer;
|
|
5543
5583
|
padding: 0.125rem 0.5rem;
|
|
5544
|
-
border: 1px solid var(--
|
|
5584
|
+
border: 1px solid var(--ag-ui-border);
|
|
5545
5585
|
border-radius: 0.375rem;
|
|
5546
5586
|
background: transparent;
|
|
5547
5587
|
color: inherit;
|
|
5548
5588
|
}
|
|
5549
5589
|
|
|
5550
5590
|
.checkpoint-action:hover {
|
|
5551
|
-
background: var(--
|
|
5591
|
+
background: var(--ag-ui-hover);
|
|
5552
5592
|
}
|
|
5553
5593
|
|
|
5554
5594
|
.drawer-backdrop {
|
|
@@ -6999,6 +7039,21 @@ function errorMessage2(xhr) {
|
|
|
6999
7039
|
}
|
|
7000
7040
|
|
|
7001
7041
|
// src/core/ag_ui_chat.ts
|
|
7042
|
+
var CONNECT_TIME_ATTRIBUTES = [
|
|
7043
|
+
"data-attachments-url",
|
|
7044
|
+
"data-attachment-accept",
|
|
7045
|
+
"data-attachment-max-bytes",
|
|
7046
|
+
"data-transcribe-url",
|
|
7047
|
+
"data-threads-url",
|
|
7048
|
+
"data-tools-url",
|
|
7049
|
+
"data-skills-url",
|
|
7050
|
+
"data-skills",
|
|
7051
|
+
"data-prompt-chips",
|
|
7052
|
+
"data-slash-commands",
|
|
7053
|
+
"data-theme-toggle",
|
|
7054
|
+
"data-strings",
|
|
7055
|
+
"data-icon-url"
|
|
7056
|
+
];
|
|
7002
7057
|
var COLLAPSED_KEY = "ag-ui-chat:collapsed";
|
|
7003
7058
|
var THEME_KEY = "ag-ui-chat:theme";
|
|
7004
7059
|
var AgUiChat = class extends HTMLElement {
|
|
@@ -7198,6 +7253,8 @@ var AgUiChat = class extends HTMLElement {
|
|
|
7198
7253
|
#voiceSlot;
|
|
7199
7254
|
/** Voice-input control; created on connect when transcription is available. */
|
|
7200
7255
|
#voice = null;
|
|
7256
|
+
/** Whether the element is currently in the DOM; gates the connect-time warning. */
|
|
7257
|
+
#connected = false;
|
|
7201
7258
|
/** Refs attached to the message currently being sent (the context manifest). */
|
|
7202
7259
|
#runAttachments = [];
|
|
7203
7260
|
#client = null;
|
|
@@ -7344,12 +7401,21 @@ var AgUiChat = class extends HTMLElement {
|
|
|
7344
7401
|
const index = this.#runs();
|
|
7345
7402
|
this.#checkpoints.setRuns(index === null ? [] : await index.continuable());
|
|
7346
7403
|
}
|
|
7347
|
-
/** Attributes
|
|
7404
|
+
/** Attributes the element reacts to after it has been connected. */
|
|
7348
7405
|
static get observedAttributes() {
|
|
7349
|
-
return ["title-text"];
|
|
7406
|
+
return ["title-text", ...CONNECT_TIME_ATTRIBUTES];
|
|
7350
7407
|
}
|
|
7351
|
-
attributeChangedCallback(
|
|
7352
|
-
|
|
7408
|
+
attributeChangedCallback(name, previous, value) {
|
|
7409
|
+
if (name === "title-text") {
|
|
7410
|
+
this.#title.textContent = value ?? this.#strings.title;
|
|
7411
|
+
return;
|
|
7412
|
+
}
|
|
7413
|
+
if (previous === value || !this.#connected) {
|
|
7414
|
+
return;
|
|
7415
|
+
}
|
|
7416
|
+
console.warn(
|
|
7417
|
+
`<ag-ui-chat>: "${name}" was changed after the element connected, and is read only while connecting \u2014 this assignment has no effect. Set it before the element enters the DOM (in the markup, or on the element before appending it); frameworks that patch attributes after mount should bind it at creation. To apply a new value now, remove and re-insert the element.`
|
|
7418
|
+
);
|
|
7353
7419
|
}
|
|
7354
7420
|
/** Declare a frontend tool the agent may call. */
|
|
7355
7421
|
registerTool(tool) {
|
|
@@ -7565,6 +7631,7 @@ var AgUiChat = class extends HTMLElement {
|
|
|
7565
7631
|
this.#wireVoice();
|
|
7566
7632
|
this.#threadId = this.conversationStore.threadId();
|
|
7567
7633
|
void this.#rehydrate();
|
|
7634
|
+
this.#connected = true;
|
|
7568
7635
|
}
|
|
7569
7636
|
/**
|
|
7570
7637
|
* Tear down live resources when the element leaves the DOM (a removed node, a
|
|
@@ -7575,6 +7642,7 @@ var AgUiChat = class extends HTMLElement {
|
|
|
7575
7642
|
* `MediaRecorder`.
|
|
7576
7643
|
*/
|
|
7577
7644
|
disconnectedCallback() {
|
|
7645
|
+
this.#connected = false;
|
|
7578
7646
|
this.#cancelRun();
|
|
7579
7647
|
this.#attachTray?.dispose();
|
|
7580
7648
|
this.#voice?.dispose();
|
|
@@ -7608,12 +7676,18 @@ var AgUiChat = class extends HTMLElement {
|
|
|
7608
7676
|
return;
|
|
7609
7677
|
}
|
|
7610
7678
|
const accept = this.getAttribute("data-attachment-accept") ?? "";
|
|
7611
|
-
|
|
7679
|
+
const tray = new AttachmentTray({
|
|
7612
7680
|
upload,
|
|
7613
7681
|
maxBytes: this.#attachmentMaxBytes(),
|
|
7614
7682
|
accept,
|
|
7615
|
-
strings: this.#strings
|
|
7683
|
+
strings: this.#strings,
|
|
7684
|
+
// The tray's change hook, surfaced to the host as an event. A host
|
|
7685
|
+
// driving its own composer could otherwise not tell a settled upload from
|
|
7686
|
+
// one still in flight, which is the state sendMessage() has to be called
|
|
7687
|
+
// with knowledge of.
|
|
7688
|
+
onChange: () => this.#dispatchAttachments(tray)
|
|
7616
7689
|
});
|
|
7690
|
+
this.#attachTray = tray;
|
|
7617
7691
|
this.#attachSlot.appendChild(this.#attachTray.element);
|
|
7618
7692
|
this.#fileInput.accept = accept;
|
|
7619
7693
|
this.#attachButton.hidden = false;
|
|
@@ -8338,12 +8412,46 @@ Use the read_attachment tool with an id to read a file's contents.`
|
|
|
8338
8412
|
if (content === "" && attachments.length === 0) {
|
|
8339
8413
|
return;
|
|
8340
8414
|
}
|
|
8415
|
+
this.#input.value = "";
|
|
8416
|
+
if (this.#attachTray?.hasPending() === true) {
|
|
8417
|
+
this.#appendNotice(
|
|
8418
|
+
"\u{1F4CE}",
|
|
8419
|
+
this.#strings.attachmentsStillUploading.replace(
|
|
8420
|
+
"{n}",
|
|
8421
|
+
String(this.#attachTray.pendingCount())
|
|
8422
|
+
),
|
|
8423
|
+
"attachment-pending"
|
|
8424
|
+
);
|
|
8425
|
+
}
|
|
8426
|
+
this.#attachTray?.clearReady();
|
|
8427
|
+
await this.sendMessage(content, attachments);
|
|
8428
|
+
}
|
|
8429
|
+
/**
|
|
8430
|
+
* Send a message as if the user had typed it — renders the user bubble,
|
|
8431
|
+
* dispatches {@link SUBMIT_EVENT}, and starts the run.
|
|
8432
|
+
*
|
|
8433
|
+
* The programmatic half of the composer, for a host driving its own input
|
|
8434
|
+
* (a "Ask about this order" button, a command palette, a custom composer
|
|
8435
|
+
* replacing the built-in one). Everything the built-in Send does happens
|
|
8436
|
+
* here; Send itself now reads the composer, clears it, and calls this.
|
|
8437
|
+
*
|
|
8438
|
+
* `attachments` are durable {@link AttachmentRef}s — the shape
|
|
8439
|
+
* {@link attachFile}'s upload resolves to, and the shape
|
|
8440
|
+
* {@link ATTACHMENT_EVENT} reports. Pass them to attach files to the message.
|
|
8441
|
+
*
|
|
8442
|
+
* No-ops while a run is in flight (a second concurrent run would orphan the
|
|
8443
|
+
* first) and for an entirely empty message. Unlike the built-in Send, this
|
|
8444
|
+
* does **not** consult the tray: what you pass is what is sent, so a host
|
|
8445
|
+
* composer stays in charge of its own state.
|
|
8446
|
+
*/
|
|
8447
|
+
async sendMessage(content, attachments = []) {
|
|
8448
|
+
if (this.#running || content === "" && attachments.length === 0) {
|
|
8449
|
+
return;
|
|
8450
|
+
}
|
|
8341
8451
|
const bubble = this.appendMessage(MESSAGE_ROLE.USER, content);
|
|
8342
8452
|
if (attachments.length > 0) {
|
|
8343
8453
|
bubble.appendChild(renderAttachmentChips(attachments));
|
|
8344
8454
|
}
|
|
8345
|
-
this.#input.value = "";
|
|
8346
|
-
this.#attachTray?.clearReady();
|
|
8347
8455
|
this.#runAttachments = attachments;
|
|
8348
8456
|
this.dispatchEvent(
|
|
8349
8457
|
new CustomEvent(SUBMIT_EVENT, {
|
|
@@ -8354,6 +8462,35 @@ Use the read_attachment tool with an id to read a file's contents.`
|
|
|
8354
8462
|
);
|
|
8355
8463
|
await this.#client_send(content, attachments);
|
|
8356
8464
|
}
|
|
8465
|
+
/**
|
|
8466
|
+
* Queue a file for upload into the attachment tray, exactly as the file
|
|
8467
|
+
* picker and drag-and-drop do — validation, progress chip, and all.
|
|
8468
|
+
*
|
|
8469
|
+
* Returns `false` when uploads are not configured (no `data-attachments-url`
|
|
8470
|
+
* and no {@link uploadHandler}), which is the only way for a host to tell;
|
|
8471
|
+
* the tray does not exist to report anything in that case.
|
|
8472
|
+
*
|
|
8473
|
+
* Uploading is asynchronous: watch {@link ATTACHMENT_EVENT} for the resulting
|
|
8474
|
+
* {@link AttachmentRef}, and pass it to {@link sendMessage} once `pending`
|
|
8475
|
+
* reaches zero.
|
|
8476
|
+
*/
|
|
8477
|
+
attachFile(file) {
|
|
8478
|
+
if (this.#attachTray === null) {
|
|
8479
|
+
return false;
|
|
8480
|
+
}
|
|
8481
|
+
this.#attachTray.add(file);
|
|
8482
|
+
return true;
|
|
8483
|
+
}
|
|
8484
|
+
/** Tell the host what the tray now holds — see {@link ATTACHMENT_EVENT}. */
|
|
8485
|
+
#dispatchAttachments(tray) {
|
|
8486
|
+
this.dispatchEvent(
|
|
8487
|
+
new CustomEvent(ATTACHMENT_EVENT, {
|
|
8488
|
+
detail: { attachments: tray.readyRefs(), pending: tray.pendingCount() },
|
|
8489
|
+
bubbles: true,
|
|
8490
|
+
composed: true
|
|
8491
|
+
})
|
|
8492
|
+
);
|
|
8493
|
+
}
|
|
8357
8494
|
async #client_send(content, attachments) {
|
|
8358
8495
|
if (this.endpoint === "") {
|
|
8359
8496
|
return;
|
|
@@ -8766,8 +8903,9 @@ function setControlValue(el, value) {
|
|
|
8766
8903
|
}
|
|
8767
8904
|
|
|
8768
8905
|
// src/version.ts
|
|
8769
|
-
var VERSION = "0.
|
|
8906
|
+
var VERSION = "0.17.0";
|
|
8770
8907
|
export {
|
|
8908
|
+
ATTACHMENT_EVENT,
|
|
8771
8909
|
AgUiChat,
|
|
8772
8910
|
AgUiClient,
|
|
8773
8911
|
COMPACTION_ACTIVITY_TYPE,
|