@artooi/ag-ui-web-component 0.4.0 โ†’ 0.6.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +50 -1
  2. package/README.md +69 -2
  3. package/dist/ag-ui-web-component.bundle.js +355 -59
  4. package/dist/ag-ui-web-component.bundle.js.map +4 -4
  5. package/dist/constants.d.ts +16 -0
  6. package/dist/constants.d.ts.map +1 -1
  7. package/dist/core/ag_ui_chat.d.ts +17 -1
  8. package/dist/core/ag_ui_chat.d.ts.map +1 -1
  9. package/dist/core/agui_client.d.ts +7 -1
  10. package/dist/core/agui_client.d.ts.map +1 -1
  11. package/dist/core/attachment.d.ts +35 -0
  12. package/dist/core/attachment.d.ts.map +1 -0
  13. package/dist/core/conversation_store.d.ts +37 -8
  14. package/dist/core/conversation_store.d.ts.map +1 -1
  15. package/dist/core/remote_conversation_store.d.ts +35 -0
  16. package/dist/core/remote_conversation_store.d.ts.map +1 -0
  17. package/dist/core/upload_attachment.d.ts +32 -0
  18. package/dist/core/upload_attachment.d.ts.map +1 -0
  19. package/dist/index.d.ts +4 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +1198 -24
  22. package/dist/index.js.map +4 -4
  23. package/dist/ui/attachment_chips.d.ts +13 -0
  24. package/dist/ui/attachment_chips.d.ts.map +1 -0
  25. package/dist/ui/attachment_tray.d.ts +42 -0
  26. package/dist/ui/attachment_tray.d.ts.map +1 -0
  27. package/dist/ui/relative_time.d.ts +11 -0
  28. package/dist/ui/relative_time.d.ts.map +1 -0
  29. package/dist/ui/styles.d.ts +1 -1
  30. package/dist/ui/styles.d.ts.map +1 -1
  31. package/dist/ui/thread_drawer.d.ts +33 -0
  32. package/dist/ui/thread_drawer.d.ts.map +1 -0
  33. package/package.json +1 -1
  34. package/src/constants.ts +18 -0
  35. package/src/core/ag_ui_chat.ts +267 -14
  36. package/src/core/agui_client.ts +15 -2
  37. package/src/core/attachment.ts +39 -0
  38. package/src/core/conversation_store.ts +148 -9
  39. package/src/core/remote_conversation_store.ts +147 -0
  40. package/src/core/upload_attachment.ts +113 -0
  41. package/src/index.ts +8 -0
  42. package/src/ui/attachment_chips.ts +68 -0
  43. package/src/ui/attachment_tray.ts +237 -0
  44. package/src/ui/relative_time.ts +28 -0
  45. package/src/ui/styles.ts +294 -0
  46. package/src/ui/thread_drawer.ts +200 -0
  47. package/src/version.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,53 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.6.0] โ€” 2026-06-25
11
+
12
+ ### Added
13
+
14
+ - **File uploads.** Set `data-attachments-url` (django-ag-ui's `AttachmentsView`)
15
+ to reveal a ๐Ÿ“Ž picker + drag-and-drop on the composer. Each file uploads
16
+ out-of-band (multipart, with the element's `headers`) into a pending tray โ€”
17
+ one chip per file with a progress bar, settling to `ready` or `error` (with
18
+ retry / remove). On send, the ready files' refs render as read-only chips on
19
+ the user bubble and travel to the agent: the wire stays vanilla AG-UI (only
20
+ lightweight `{ id, name, mime, size }` refs, never bytes), the model learns the
21
+ ids from a one-line run-context manifest, and reads contents server-side via
22
+ the `read_attachment` tool. Refs persist on the message, so a restored
23
+ conversation re-renders its chips.
24
+ - **Client-side guards** (instant feedback; the server stays authoritative):
25
+ `data-attachment-accept` (an `<input accept>` list) and
26
+ `data-attachment-max-bytes` (default 10 MiB, `0` disables).
27
+ - **Pluggable upload transport.** A new `uploadHandler` property โ€”
28
+ `(file, onProgress) => Promise<AttachmentRef>` โ€” swaps the built-in multipart
29
+ upload for a custom one (a resumable `tus-js-client` adapter, direct-to-S3
30
+ multipart, โ€ฆ) without touching the tray, chips, or AG-UI wire. When set, the
31
+ ๐Ÿ“Ž affordance appears even with no `data-attachments-url`. Defaults to the
32
+ built-in `uploadAttachment`.
33
+ - **New exports:** `uploadAttachment` + `UploadOptions` + `UploadHandler`, the
34
+ `AttachmentRef` type, and `messageAttachments`. `AgUiClient.send` gains an
35
+ optional second `attachments` argument; the `ag-ui-submit` event `detail` now
36
+ also carries `attachments`.
37
+
38
+ ## [0.5.0] โ€” 2026-06-24
39
+
40
+ ### Added
41
+
42
+ - **Chat-history drawer.** A history toggle (โ˜ฐ) in the header opens a slide-over
43
+ listing the user's past conversations (title ยท relative time ยท preview), with
44
+ select, new chat, inline rename, and delete-with-confirm. The
45
+ `ClientConversationStore` interface gains `listThreads` / `setActiveThread` /
46
+ `renameThread` and a `ThreadMeta` row shape; the default `SessionStorageStore`
47
+ now keeps a per-tab thread index so the drawer works with no server. Selecting
48
+ a row switches the active conversation and replays its history. The drawer is a
49
+ slide-over by default, with an inline side-panel variant for
50
+ `placement="embedded"`.
51
+ - **Server-backed history via `data-threads-url`.** Set the attribute (to
52
+ django-ag-ui's `ThreadsView` URL) and the drawer routes list / load / rename /
53
+ delete through that endpoint via a new `RemoteConversationStore`, showing
54
+ durable, cross-device threads. The client store remains the offline fallback;
55
+ rename / delete apply optimistically.
56
+
10
57
  ## [0.4.0] โ€” 2026-06-12
11
58
 
12
59
  ### Added
@@ -250,7 +297,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
250
297
  ### Notes
251
298
  - First release โ€” exercising the automated npm OIDC publish pipeline end-to-end.
252
299
 
253
- [Unreleased]: https://github.com/Artui/ag-ui-web-component/compare/v0.4.0...HEAD
300
+ [Unreleased]: https://github.com/Artui/ag-ui-web-component/compare/v0.6.0...HEAD
301
+ [0.6.0]: https://github.com/Artui/ag-ui-web-component/compare/v0.5.0...v0.6.0
302
+ [0.5.0]: https://github.com/Artui/ag-ui-web-component/compare/v0.4.0...v0.5.0
254
303
  [0.4.0]: https://github.com/Artui/ag-ui-web-component/compare/v0.3.1...v0.4.0
255
304
  [0.3.1]: https://github.com/Artui/ag-ui-web-component/compare/v0.3.0...v0.3.1
256
305
  [0.3.0]: https://github.com/Artui/ag-ui-web-component/compare/v0.2.2...v0.3.0
package/README.md CHANGED
@@ -152,6 +152,10 @@ That's the whole integration: an `endpoint` attribute pointing at your AG-UI ser
152
152
  | `data-skills` | โ€” | Inline JSON skill catalog. |
153
153
  | `data-skills-url` | โ€” | URL of a JSON skill catalog (fetched with `headers`). |
154
154
  | `data-tools-url` | โ€” | URL of a server tool-label catalog (`[{ name, summary, description? }]`), fetched with `headers`; labels tool-call cards for server-side tools. |
155
+ | `data-threads-url` | โ€” | URL of a server thread index (django-ag-ui's `ThreadsView`); enables durable, cross-device chat history. |
156
+ | `data-attachments-url` | โ€” | URL of the file-upload endpoint (django-ag-ui's `AttachmentsView`); reveals the composer's ๐Ÿ“Ž picker + drag-and-drop. |
157
+ | `data-attachment-accept` | โ€” | `<input accept>` list for client-side type filtering (e.g. `image/*,.pdf`). The server stays authoritative. |
158
+ | `data-attachment-max-bytes` | โ€” | Client-side upload size cap in bytes (default 10 MiB; `0` disables). The server stays authoritative. |
155
159
  | `collapsed` | `collapsed` | Reflected boolean; collapses the widget. Persisted per-tab in `sessionStorage`. |
156
160
  | `theme` | โ€” | CSS-only: `light` (default) / `dark` / `auto` / `code`. |
157
161
  | `density` | โ€” | CSS-only: `comfortable` (default) / `compact`. |
@@ -159,8 +163,8 @@ That's the whole integration: an `endpoint` attribute pointing at your AG-UI ser
159
163
 
160
164
  **Properties** (JS only, not attributes): `headers`, `allowImages`, `autoConfirm`,
161
165
  `confirmPredicate`, `agentFactory`, `getTools`, `getContext`, `routeMap`, `navigate`,
162
- `getPageMap`, `autoInjectPageMap`, `conversationStore`, `navigationResult`, `skillContext`,
163
- `toolSummaries`, plus the mirrors `endpoint` / `toolDisplay` / `collapsed`.
166
+ `getPageMap`, `autoInjectPageMap`, `conversationStore`, `uploadHandler`, `navigationResult`,
167
+ `skillContext`, `toolSummaries`, plus the mirrors `endpoint` / `toolDisplay` / `collapsed`.
164
168
 
165
169
  `allowImages` (default `false`) re-enables `<img>` in rendered assistant markdown.
166
170
  It is off by default because a model-controlled image URL is fetched by the browser
@@ -525,6 +529,57 @@ chat.navigate = (path) => router.push(path); // SPA: in-page, no reload
525
529
 
526
530
  Route map + `navigate()` and the reload model are the same feature seen from two ends.
527
531
 
532
+ ## File uploads
533
+
534
+ Set **`data-attachments-url`** (django-ag-ui's `AttachmentsView`) to let the user attach files
535
+ to a message. A ๐Ÿ“Ž button and drag-and-drop appear on the composer; each picked file uploads
536
+ out-of-band (multipart, with the element's `headers`) and shows a chip in a pending tray โ€”
537
+ `uploading` (with a progress bar) โ†’ `ready`, or `error` with a retry. On send, the ready files'
538
+ **refs** ride on the user bubble as read-only chips and the agent reads their contents
539
+ server-side via the `read_attachment` tool. The wire stays vanilla AG-UI: only lightweight refs
540
+ (`{ id, name, mime, size }`) travel, never the bytes.
541
+
542
+ ```html
543
+ <ag-ui-chat
544
+ endpoint="/agent/"
545
+ data-attachments-url="/agent/attachments/"
546
+ data-attachment-accept="image/*,application/pdf,text/plain"
547
+ data-attachment-max-bytes="10485760"
548
+ ></ag-ui-chat>
549
+ ```
550
+
551
+ Client-side `accept` / size checks are an instant-feedback nicety โ€” **the server is
552
+ authoritative**. Refs persist on the message, so a restored conversation re-renders its chips.
553
+ Without the attribute the affordance stays hidden and the chat is text-only.
554
+
555
+ **Swapping the upload transport.** The built-in multipart `POST` is just the default
556
+ `uploadHandler`. Set your own to use a different transport โ€” a resumable
557
+ [`tus-js-client`](https://github.com/tus/tus-js-client) adapter, direct-to-S3 multipart, etc.
558
+ โ€” without touching the tray, the chips, or the AG-UI wire (refs are transport-agnostic). The
559
+ handler is `(file, onProgress) => Promise<AttachmentRef>`; when set, the ๐Ÿ“Ž affordance appears
560
+ even with no `data-attachments-url`, and your handler owns its own endpoint and headers:
561
+
562
+ ```js
563
+ import { Upload } from "tus-js-client";
564
+
565
+ chat.uploadHandler = (file, onProgress) =>
566
+ new Promise((resolve, reject) => {
567
+ const up = new Upload(file, {
568
+ endpoint: "/tus/",
569
+ headers: chat.headers,
570
+ onProgress: (sent, total) => onProgress(sent / total),
571
+ onError: reject,
572
+ onSuccess: () =>
573
+ resolve({ id: up.url.split("/").pop(), name: file.name, mime: file.type, size: file.size }),
574
+ });
575
+ up.start();
576
+ });
577
+ ```
578
+
579
+ The server side is the matching half: the agent reads bytes by ref id, so point the
580
+ `read_attachment` store at wherever your transport persisted them (django-ag-ui's
581
+ `AttachmentStore` is the seam). The refs themselves never change shape.
582
+
528
583
  ---
529
584
 
530
585
  ## Public API surface
@@ -580,9 +635,21 @@ re-export point. Internal modules import from leaf paths.
580
635
  | Export | Kind | Summary |
581
636
  | --- | --- | --- |
582
637
  | `SessionStorageStore` | class | Default per-tab conversation store. |
638
+ | `RemoteConversationStore` | class | Server-backed store over a `data-threads-url` endpoint. |
583
639
  | `ClientConversationStore` | type | The persistence seam. |
640
+ | `ThreadMeta` | type | A thread-drawer row (`{ threadId, title, updatedAt, preview }`). |
584
641
  | `NavigationCheckpoint` | type | The pre-reload checkpoint marker. |
585
642
 
643
+ ### Attachments
644
+
645
+ | Export | Kind | Summary |
646
+ | --- | --- | --- |
647
+ | `uploadAttachment(file, options)` | function | The built-in upload (multipart, progress) โ†’ `AttachmentRef`. |
648
+ | `UploadOptions` | type | `{ url, headers?, onProgress?, signal? }`. |
649
+ | `UploadHandler` | type | `(file, onProgress) => Promise<AttachmentRef>` โ€” the `uploadHandler` swap seam (TUS / S3). |
650
+ | `AttachmentRef` | type | The durable upload ref (`{ id, name, mime, size, url? }`). |
651
+ | `messageAttachments(message)` | function | Read the refs a restored user message carries. |
652
+
586
653
  ### UI & DOM primitives
587
654
 
588
655
  | Export | Kind | Summary |