@artooi/ag-ui-web-component 0.5.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.
- package/CHANGELOG.md +30 -1
- package/README.md +69 -2
- package/dist/ag-ui-web-component.bundle.js +155 -43
- package/dist/ag-ui-web-component.bundle.js.map +4 -4
- package/dist/constants.d.ts +16 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/core/ag_ui_chat.d.ts +17 -1
- package/dist/core/ag_ui_chat.d.ts.map +1 -1
- package/dist/core/agui_client.d.ts +7 -1
- package/dist/core/agui_client.d.ts.map +1 -1
- package/dist/core/attachment.d.ts +35 -0
- package/dist/core/attachment.d.ts.map +1 -0
- package/dist/core/upload_attachment.d.ts +32 -0
- package/dist/core/upload_attachment.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +578 -20
- package/dist/index.js.map +4 -4
- package/dist/ui/attachment_chips.d.ts +13 -0
- package/dist/ui/attachment_chips.d.ts.map +1 -0
- package/dist/ui/attachment_tray.d.ts +42 -0
- package/dist/ui/attachment_tray.d.ts.map +1 -0
- package/dist/ui/styles.d.ts +1 -1
- package/dist/ui/styles.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +18 -0
- package/src/core/ag_ui_chat.ts +178 -12
- package/src/core/agui_client.ts +15 -2
- package/src/core/attachment.ts +39 -0
- package/src/core/upload_attachment.ts +113 -0
- package/src/index.ts +6 -0
- package/src/ui/attachment_chips.ts +68 -0
- package/src/ui/attachment_tray.ts +237 -0
- package/src/ui/styles.ts +110 -0
- package/src/version.ts +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -57,6 +57,22 @@ export declare const TOOL_CALL_STATUS: {
|
|
|
57
57
|
readonly ERROR: "error";
|
|
58
58
|
readonly DECLINED: "declined";
|
|
59
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Lifecycle status of a pending-attachment chip in the composer tray. A chip
|
|
62
|
+
* opens as `UPLOADING` (with a progress bar), then settles to `READY` (a durable
|
|
63
|
+
* ref) or `ERROR` (with a retry control).
|
|
64
|
+
*/
|
|
65
|
+
export declare const ATTACHMENT_STATUS: {
|
|
66
|
+
readonly UPLOADING: "uploading";
|
|
67
|
+
readonly READY: "ready";
|
|
68
|
+
readonly ERROR: "error";
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Default client-side upload size cap (10 MiB), matching django-ag-ui's
|
|
72
|
+
* `ATTACHMENT_MAX_BYTES` default. Overridable per element via
|
|
73
|
+
* `data-attachment-max-bytes`; the server stays authoritative.
|
|
74
|
+
*/
|
|
75
|
+
export declare const DEFAULT_ATTACHMENT_MAX_BYTES: number;
|
|
60
76
|
/**
|
|
61
77
|
* How much detail a tool-call card shows. Set via the `data-tool-display`
|
|
62
78
|
* attribute on `<ag-ui-chat>`; defaults to `full` (back-compatible).
|
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,qCAAqC;AACrC,eAAO,MAAM,YAAY;;;CAGf,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,yEAAyE;AACzE,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;CAKnB,CAAC;AAEX;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY;;;;CAIf,CAAC"}
|
|
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,qCAAqC;AACrC,eAAO,MAAM,YAAY;;;CAGf,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,yEAAyE;AACzE,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;CAKnB,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;;;CAIpB,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,QAAmB,CAAC;AAE7D;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY;;;;CAIf,CAAC"}
|
|
@@ -6,13 +6,17 @@ import { type PageMap } from "../tools/page_map.js";
|
|
|
6
6
|
import { type RouteMap } from "../tools/route_map.js";
|
|
7
7
|
import { type StateHook } from "../tools/state_hook.js";
|
|
8
8
|
import { type ToolDisplayMode } from "../ui/tool_call_card.js";
|
|
9
|
+
import { type AttachmentRef } from "./attachment.js";
|
|
9
10
|
import { type ClientConversationStore, type NavigationCheckpoint } from "./conversation_store.js";
|
|
10
11
|
import { type AgentFactory } from "./create_http_agent.js";
|
|
12
|
+
import { type UploadHandler } from "./upload_attachment.js";
|
|
11
13
|
/** The role a rendered chat message takes. */
|
|
12
14
|
export type MessageRole = (typeof MESSAGE_ROLE)[keyof typeof MESSAGE_ROLE];
|
|
13
15
|
/** `detail` shape of the {@link SUBMIT_EVENT} CustomEvent. */
|
|
14
16
|
export interface SubmitDetail {
|
|
15
17
|
readonly content: string;
|
|
18
|
+
/** Durable refs for the files attached to this message (empty when none). */
|
|
19
|
+
readonly attachments: readonly AttachmentRef[];
|
|
16
20
|
}
|
|
17
21
|
/** `detail` shape of the {@link TOGGLE_EVENT} CustomEvent. */
|
|
18
22
|
export interface ToggleDetail {
|
|
@@ -62,7 +66,9 @@ export declare class AgUiChat extends HTMLElement {
|
|
|
62
66
|
getTools: () => Tool[];
|
|
63
67
|
/**
|
|
64
68
|
* Per-run context provider. Defaults to the compact page map (when a
|
|
65
|
-
* {@link getPageMap} provider is set and {@link autoInjectPageMap} is on)
|
|
69
|
+
* {@link getPageMap} provider is set and {@link autoInjectPageMap} is on)
|
|
70
|
+
* plus a one-line manifest of the files attached to the message being sent,
|
|
71
|
+
* so the agent knows which `read_attachment` ids are available.
|
|
66
72
|
*/
|
|
67
73
|
getContext: () => Context[];
|
|
68
74
|
/**
|
|
@@ -86,6 +92,16 @@ export declare class AgUiChat extends HTMLElement {
|
|
|
86
92
|
* server-backed store for cross-tab/device durability.
|
|
87
93
|
*/
|
|
88
94
|
conversationStore: ClientConversationStore;
|
|
95
|
+
/**
|
|
96
|
+
* How attached files are uploaded. `null` (default) uses the built-in
|
|
97
|
+
* multipart `POST` to `data-attachments-url`. Set a custom
|
|
98
|
+
* {@link UploadHandler} — `(file, onProgress) => Promise<AttachmentRef>` — to
|
|
99
|
+
* swap the transport (e.g. a `tus-js-client` resumable adapter or
|
|
100
|
+
* direct-to-S3 multipart) without changing the tray, the chips, or the AG-UI
|
|
101
|
+
* wire (refs are transport-agnostic). When set, the 📎 affordance appears even
|
|
102
|
+
* with no `data-attachments-url`; the handler owns its own endpoint + headers.
|
|
103
|
+
*/
|
|
104
|
+
uploadHandler: UploadHandler | null;
|
|
89
105
|
/**
|
|
90
106
|
* Builds the tool result a navigating tool resumes with after the page
|
|
91
107
|
* reloads. Defaults to the landed URL; a host (e.g. the admin package) can
|
|
@@ -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,EAAW,IAAI,EAAE,MAAM,aAAa,CAAC;AAC1D,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,EAAW,IAAI,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAEL,YAAY,EAOb,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,KAAK,UAAU,EAAsB,MAAM,kCAAkC,CAAC;AAGvF,OAAO,EAAwB,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE1E,OAAO,EAAoB,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAU9E,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAO7E,OAAO,EAAE,KAAK,aAAa,EAAsB,MAAM,iBAAiB,CAAC;AACzE,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAE1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,wBAAwB,CAAC;AAE5E,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,wBAAwB,CAAC;AAE9E,8CAA8C;AAC9C,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE3E,8DAA8D;A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Message, Tool } from "@ag-ui/core";
|
|
3
|
+
import type { AttachmentRef } from "./attachment.js";
|
|
3
4
|
/** A tool call surfaced to the host by {@link AgUiClient}. */
|
|
4
5
|
export interface AgUiToolCall {
|
|
5
6
|
readonly id: string;
|
|
@@ -106,8 +107,13 @@ export declare class AgUiClient {
|
|
|
106
107
|
* When the agent calls frontend tools, this executes them and re-runs the
|
|
107
108
|
* agent with the results, looping until the agent stops calling frontend
|
|
108
109
|
* tools (bounded by {@link MAX_TOOL_ROUNDS}).
|
|
110
|
+
*
|
|
111
|
+
* `attachments` ride on the user message as a non-standard field so the
|
|
112
|
+
* default client store round-trips them for history replay; the agent learns
|
|
113
|
+
* the ids from the run context (the server's strict validation ignores the
|
|
114
|
+
* unknown message field), then reads bytes via the `read_attachment` tool.
|
|
109
115
|
*/
|
|
110
|
-
send(content: string): Promise<void>;
|
|
116
|
+
send(content: string, attachments?: readonly AttachmentRef[]): Promise<void>;
|
|
111
117
|
/**
|
|
112
118
|
* Resume the run loop after a navigating tool's result was supplied
|
|
113
119
|
* post-reload (via {@link addToolResult}). Unlike {@link send}, adds no user
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agui_client.d.ts","sourceRoot":"","sources":["../../src/core/agui_client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAoC,MAAM,eAAe,CAAC;AACrF,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"agui_client.d.ts","sourceRoot":"","sources":["../../src/core/agui_client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAoC,MAAM,eAAe,CAAC;AACrF,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,8DAA8D;AAC9D,MAAM,W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EAAsE;IACtE,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,oEAAoE;IACpE,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,KAAK,IAAI,CAAC;CACpD;AAED;;;;;;GAMG;AACH,qBAAa,UAAU;;gBAWT,MAAM,EAAE,gBAAgB;IASpC,4CAA4C;IAC5C,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,wEAAwE;IACxE,IAAI,QAAQ,IAAI,SAAS,OAAO,EAAE,CAEjC;IAED;;;;;;;;;;;OAWG;IACG,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,GAAE,SAAS,aAAa,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAatF;;;;OAIG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,0EAA0E;IAC1E,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAKxD;;;;;;OAMG;IACH,MAAM,IAAI,IAAI;CAgHf"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Message } from "@ag-ui/core";
|
|
2
|
+
/**
|
|
3
|
+
* A durable, lightweight reference to one uploaded file — what an upload
|
|
4
|
+
* returns and what rides on a sent message, never the bytes.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors django-ag-ui's `AttachmentRef`: a file uploads out-of-band to the
|
|
7
|
+
* attachments endpoint, the server hands back this ref, and the agent reads the
|
|
8
|
+
* actual content server-side via the `read_attachment` tool. Keeping the AG-UI
|
|
9
|
+
* message stream free of base64 mirrors how the tool catalog keeps schemas off
|
|
10
|
+
* the wire.
|
|
11
|
+
*/
|
|
12
|
+
export interface AttachmentRef {
|
|
13
|
+
/** Opaque, owner-scoped handle the server resolves back to bytes. */
|
|
14
|
+
readonly id: string;
|
|
15
|
+
/** Original filename, for display on the chip. */
|
|
16
|
+
readonly name: string;
|
|
17
|
+
/** Declared content type (a hint — the server is authoritative). */
|
|
18
|
+
readonly mime: string;
|
|
19
|
+
/** Size in bytes. */
|
|
20
|
+
readonly size: number;
|
|
21
|
+
/** Optional direct fetch URL (the owner-checked download endpoint). */
|
|
22
|
+
readonly url?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The attachment refs a user message carries.
|
|
26
|
+
*
|
|
27
|
+
* Refs are stored on the user message as a non-standard `attachments` field: a
|
|
28
|
+
* web-component augmentation that the default client store round-trips and
|
|
29
|
+
* `@ag-ui/client` preserves through `addMessage` / `structuredClone`, so a
|
|
30
|
+
* restored conversation re-renders its attachment chips. The server's strict
|
|
31
|
+
* `RunAgentInput` validation ignores the unknown field — the model learns the
|
|
32
|
+
* ids from the run context manifest instead.
|
|
33
|
+
*/
|
|
34
|
+
export declare function messageAttachments(message: Message): readonly AttachmentRef[];
|
|
35
|
+
//# sourceMappingURL=attachment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../../src/core/attachment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;;;;;GASG;AACH,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qBAAqB;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,aAAa,EAAE,CAG7E"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AttachmentRef } from "./attachment.js";
|
|
2
|
+
/**
|
|
3
|
+
* The composer's upload contract: take a `File`, report `0..1` progress, and
|
|
4
|
+
* resolve to a durable {@link AttachmentRef}. The built-in handler is
|
|
5
|
+
* {@link uploadAttachment} (multipart POST); a host swaps in its own — e.g. a
|
|
6
|
+
* `tus-js-client` or direct-to-S3 adapter — via `AgUiChat.uploadHandler`,
|
|
7
|
+
* **without** touching the tray, the chips, or the AG-UI wire (refs are
|
|
8
|
+
* transport-agnostic).
|
|
9
|
+
*/
|
|
10
|
+
export type UploadHandler = (file: File, onProgress: (fraction: number) => void) => Promise<AttachmentRef>;
|
|
11
|
+
/** Options for {@link uploadAttachment}. */
|
|
12
|
+
export interface UploadOptions {
|
|
13
|
+
/** The attachments endpoint (`data-attachments-url`). */
|
|
14
|
+
readonly url: string;
|
|
15
|
+
/** Extra HTTP headers (CSRF / auth), read fresh per upload. */
|
|
16
|
+
readonly headers?: Record<string, string>;
|
|
17
|
+
/** Progress callback, `0..1`, fired as the body uploads. */
|
|
18
|
+
readonly onProgress?: (fraction: number) => void;
|
|
19
|
+
/** Abort signal to cancel the in-flight upload. */
|
|
20
|
+
readonly signal?: AbortSignal;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Upload one file to the attachments endpoint and resolve to its durable
|
|
24
|
+
* {@link AttachmentRef}.
|
|
25
|
+
*
|
|
26
|
+
* Uses `XMLHttpRequest` (not `fetch`) for real upload-progress events: the file
|
|
27
|
+
* is sent as multipart under the `file` field, with the element's `headers` so
|
|
28
|
+
* CSRF / auth ride along exactly like the skills/tools fetches. A non-2xx
|
|
29
|
+
* response or a network/abort error rejects, so the tray can show an error chip.
|
|
30
|
+
*/
|
|
31
|
+
export declare function uploadAttachment(file: File, options: UploadOptions): Promise<AttachmentRef>;
|
|
32
|
+
//# sourceMappingURL=upload_attachment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload_attachment.d.ts","sourceRoot":"","sources":["../../src/core/upload_attachment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,KACnC,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5B,4CAA4C;AAC5C,MAAM,WAAW,aAAa;IAC5B,yDAAyD;IACzD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,4DAA4D;IAC5D,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,mDAAmD;IACnD,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAyC3F"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export { ELEMENT_TAG, MAX_TOOL_ROUNDS, MESSAGE_ROLE, 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
2
|
export { AgUiChat, type MessageRole, type SubmitDetail, type ToggleDetail, } from "./core/ag_ui_chat.js";
|
|
3
3
|
export { AgUiClient, type AgUiClientConfig, type AgUiClientHandlers, type AgUiRunInputs, type AgUiToolCall, type ExecuteTool, type ToolExecution, } from "./core/agui_client.js";
|
|
4
|
+
export { type AttachmentRef, messageAttachments } from "./core/attachment.js";
|
|
4
5
|
export { type ClientConversationStore, type NavigationCheckpoint, SessionStorageStore, type ThreadMeta, } from "./core/conversation_store.js";
|
|
5
6
|
export { type AgentFactory, createHttpAgent, type HttpAgentOptions, } from "./core/create_http_agent.js";
|
|
6
7
|
export { defineAgUiChat } from "./core/define_ag_ui_chat.js";
|
|
7
8
|
export { RemoteConversationStore } from "./core/remote_conversation_store.js";
|
|
9
|
+
export { type UploadHandler, type UploadOptions, uploadAttachment, } from "./core/upload_attachment.js";
|
|
8
10
|
export { type FlashOptions, focusWithFlash, type HighlightClickOptions, highlightThenClick, type PressOptions, prefersReducedMotion, pressThenClick, type SelectOptions, scrollIntoCenterView, selectOption, type TextLikeElement, type ToggleOptions, type TypeOptions, toggleControl, typeInto, } from "./dom/animations.js";
|
|
9
11
|
export { clickElement, type FillFieldOptions, fillField, pressButton, selectControl, setControlValue, toggleCheckbox, } from "./dom/dom_driver.js";
|
|
10
12
|
export { setNativeChecked, setNativeValue } from "./dom/native_setter.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,WAAW,EACX,eAAe,EACf,YAAY,EACZ,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,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,KAAK,WAAW,EAChB,KAAK,aAAa,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,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