@artooi/ag-ui-web-component 0.27.0 → 0.29.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 +663 -1
- package/README.md +557 -11
- package/dist/ag-ui-web-component.bundle.js +294 -36
- package/dist/ag-ui-web-component.bundle.js.map +4 -4
- package/dist/constants.d.ts +69 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/core/ag_ui_chat.d.ts +262 -1
- package/dist/core/ag_ui_chat.d.ts.map +1 -1
- package/dist/core/agui_client.d.ts +46 -1
- package/dist/core/agui_client.d.ts.map +1 -1
- package/dist/core/conversation_store.d.ts +43 -1
- package/dist/core/conversation_store.d.ts.map +1 -1
- package/dist/core/create_http_agent.d.ts +13 -0
- package/dist/core/create_http_agent.d.ts.map +1 -1
- package/dist/core/remote_conversation_store.d.ts +23 -1
- package/dist/core/remote_conversation_store.d.ts.map +1 -1
- package/dist/core/utils.d.ts +28 -0
- package/dist/core/utils.d.ts.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2104 -194
- package/dist/index.js.map +4 -4
- package/dist/tools/is_destructive.d.ts +8 -2
- package/dist/tools/is_destructive.d.ts.map +1 -1
- package/dist/tools/parse_tool_catalog.d.ts +11 -4
- package/dist/tools/parse_tool_catalog.d.ts.map +1 -1
- package/dist/ui/approval_card.d.ts +18 -0
- package/dist/ui/approval_card.d.ts.map +1 -1
- package/dist/ui/checkpoint_menu.d.ts +10 -0
- package/dist/ui/checkpoint_menu.d.ts.map +1 -1
- package/dist/ui/confirmation_card.d.ts +16 -0
- package/dist/ui/confirmation_card.d.ts.map +1 -1
- package/dist/ui/message_actions.d.ts +46 -0
- package/dist/ui/message_actions.d.ts.map +1 -0
- package/dist/ui/page_quote_offer.d.ts +33 -0
- package/dist/ui/page_quote_offer.d.ts.map +1 -0
- package/dist/ui/quote_selection.d.ts +66 -0
- package/dist/ui/quote_selection.d.ts.map +1 -0
- package/dist/ui/relative_time.d.ts +10 -0
- package/dist/ui/relative_time.d.ts.map +1 -1
- package/dist/ui/render_markdown.d.ts +23 -5
- package/dist/ui/render_markdown.d.ts.map +1 -1
- package/dist/ui/resize_handle.d.ts +5 -1
- package/dist/ui/resize_handle.d.ts.map +1 -1
- package/dist/ui/stick_to_bottom.d.ts +55 -0
- package/dist/ui/stick_to_bottom.d.ts.map +1 -0
- package/dist/ui/styles.d.ts +1 -1
- package/dist/ui/styles.d.ts.map +1 -1
- package/dist/ui/suggestion_chips.d.ts +29 -0
- package/dist/ui/suggestion_chips.d.ts.map +1 -0
- package/dist/ui/thread_drawer.d.ts +10 -0
- package/dist/ui/thread_drawer.d.ts.map +1 -1
- package/dist/ui/tool_call_card.d.ts +8 -0
- package/dist/ui/tool_call_card.d.ts.map +1 -1
- package/dist/ui/ui_strings.d.ts +53 -7
- package/dist/ui/ui_strings.d.ts.map +1 -1
- package/dist/ui/voice_input.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +75 -0
- package/src/core/ag_ui_chat.ts +1357 -113
- package/src/core/agui_client.ts +81 -1
- package/src/core/conversation_store.ts +128 -42
- package/src/core/create_http_agent.ts +24 -2
- package/src/core/remote_conversation_store.ts +35 -2
- package/src/core/utils.ts +58 -0
- package/src/index.ts +39 -0
- package/src/tools/is_destructive.ts +8 -2
- package/src/tools/parse_tool_catalog.ts +18 -6
- package/src/ui/approval_card.ts +90 -2
- package/src/ui/checkpoint_menu.ts +22 -5
- package/src/ui/confirmation_card.ts +29 -1
- package/src/ui/message_actions.ts +158 -0
- package/src/ui/page_quote_offer.ts +215 -0
- package/src/ui/quote_selection.ts +345 -0
- package/src/ui/relative_time.ts +11 -0
- package/src/ui/render_markdown.ts +111 -21
- package/src/ui/resize_handle.ts +32 -2
- package/src/ui/stick_to_bottom.ts +126 -0
- package/src/ui/styles.ts +227 -0
- package/src/ui/suggestion_chips.ts +73 -0
- package/src/ui/thread_drawer.ts +22 -2
- package/src/ui/tool_call_card.ts +9 -0
- package/src/ui/ui_strings.ts +79 -8
- package/src/ui/voice_input.ts +43 -0
- package/src/version.ts +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -44,6 +44,66 @@ export declare const ATTACHMENT_EVENT = "ag-ui-attachments";
|
|
|
44
44
|
* error and cancellation alike, since a partial write is still a write.
|
|
45
45
|
*/
|
|
46
46
|
export declare const RUN_FINISHED_EVENT = "ag-ui-run-finished";
|
|
47
|
+
/**
|
|
48
|
+
* The agent sent an AG-UI `CUSTOM` event. `detail` is {@link CustomAgentDetail}.
|
|
49
|
+
*
|
|
50
|
+
* `CUSTOM` is one of exactly two carriers whose payload name the protocol leaves
|
|
51
|
+
* an open string, and it is the **imperative** one: something for the host page
|
|
52
|
+
* to *do*, with no place in the transcript. Its sibling `ACTIVITY_SNAPSHOT`
|
|
53
|
+
* carries transcript **content**, which is why that one is materialised into a
|
|
54
|
+
* message, persisted, and replayed on restore while this one is not.
|
|
55
|
+
*
|
|
56
|
+
* That asymmetry is the rule for choosing between them. Content has a place in
|
|
57
|
+
* the conversation and should replay; an imperative has no place and no meaning
|
|
58
|
+
* once acted on, so replaying it on a thread load would be a bug. Anything that
|
|
59
|
+
* must survive a reload belongs on the other carrier.
|
|
60
|
+
*
|
|
61
|
+
* The element takes no view of what a name means -- it forwards every one. A
|
|
62
|
+
* host that does not recognise a name ignores the event, which is the graceful
|
|
63
|
+
* outcome the open field exists for.
|
|
64
|
+
*/
|
|
65
|
+
export declare const CUSTOM_AGENT_EVENT = "ag-ui-custom";
|
|
66
|
+
/**
|
|
67
|
+
* The agent named resources its write has moved. `detail` is
|
|
68
|
+
* {@link InvalidateDetail}.
|
|
69
|
+
*
|
|
70
|
+
* A convention on top of {@link CUSTOM_AGENT_EVENT}, not a second channel: the
|
|
71
|
+
* wire carries an ordinary AG-UI `CUSTOM` event whose `name` is
|
|
72
|
+
* {@link INVALIDATE_CUSTOM_NAME}, and this is that one name routed to its own
|
|
73
|
+
* DOM event so a host does not have to string-match. Every other name still
|
|
74
|
+
* arrives as `ag-ui-custom`.
|
|
75
|
+
*
|
|
76
|
+
* Fires **as each announcement arrives**, during the run, which is what makes a
|
|
77
|
+
* long multi-step run feel live: the list refreshes as the third of eight writes
|
|
78
|
+
* lands rather than when everything finishes. {@link RUN_FINISHED_EVENT} carries
|
|
79
|
+
* the same keys again at the end, de-duplicated, for a host that would rather
|
|
80
|
+
* refetch once.
|
|
81
|
+
*/
|
|
82
|
+
export declare const INVALIDATE_EVENT = "ag-ui-invalidate";
|
|
83
|
+
/**
|
|
84
|
+
* Fired when the user rates an assistant message from its action row.
|
|
85
|
+
*
|
|
86
|
+
* `detail` is a {@link FeedbackDetail}: the rated message's text and the
|
|
87
|
+
* rating. **Nothing is stored** -- a rating belongs to whatever the host
|
|
88
|
+
* already uses to hold product signals, and a write-only table inside a chat
|
|
89
|
+
* widget is a schema nobody reads.
|
|
90
|
+
*/
|
|
91
|
+
export declare const FEEDBACK_EVENT = "ag-ui-feedback";
|
|
92
|
+
/**
|
|
93
|
+
* The `activity_type` carrying server-pushed follow-up prompts.
|
|
94
|
+
*
|
|
95
|
+
* Matches django-ag-ui's `SUGGESTIONS_ACTIVITY_TYPE`. A convention inside the
|
|
96
|
+
* protocol's open `activity_type` field, not an extension of it -- so a client
|
|
97
|
+
* that has never heard of it ignores the event, and this one is not privileged.
|
|
98
|
+
*/
|
|
99
|
+
export declare const SUGGESTIONS_ACTIVITY_TYPE = "suggestions";
|
|
100
|
+
/**
|
|
101
|
+
* The AG-UI `CUSTOM` event `name` that carries an invalidation.
|
|
102
|
+
*
|
|
103
|
+
* Matched exactly. Namespaced so it cannot collide with a host's own custom
|
|
104
|
+
* events, which share the field.
|
|
105
|
+
*/
|
|
106
|
+
export declare const INVALIDATE_CUSTOM_NAME = "ag_ui.invalidate";
|
|
47
107
|
/** Roles a chat message can take. */
|
|
48
108
|
export declare const MESSAGE_ROLE: {
|
|
49
109
|
readonly USER: "user";
|
|
@@ -189,4 +249,13 @@ export declare const ICON_FILE_TEXT = "<svg class=\"glyph\" viewBox=\"0 0 24 24\
|
|
|
189
249
|
* event, which is the graceful outcome.
|
|
190
250
|
*/
|
|
191
251
|
export declare const CHART_ACTIVITY_TYPE = "chart";
|
|
252
|
+
/**
|
|
253
|
+
* How long a screen-reader status stays in the announcer before it is emptied.
|
|
254
|
+
*
|
|
255
|
+
* Long enough for a reader to pick the change up, short enough that the region
|
|
256
|
+
* is empty again before the next status lands. Emptying is what makes an
|
|
257
|
+
* identical consecutive message announce at all -- a live region is read on
|
|
258
|
+
* *change*, and setting the same string twice is not one.
|
|
259
|
+
*/
|
|
260
|
+
export declare const ANNOUNCE_CLEAR_MS = 150;
|
|
192
261
|
//# sourceMappingURL=constants.d.ts.map
|
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,kEAAkE;AAClE,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,gBAAgB,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,sBAAsB,CAAC;AAEpD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAEvD,qCAAqC;AACrC,eAAO,MAAM,YAAY;aACvB,IAAI,EAAE,MAAM;aACZ,SAAS,EAAE,WAAW;CACd,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,aAAa,cAAc,CAAC;AAEzC;;;GAGG;AACH,eAAO,MAAM,aAAa,cA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;GAQG;AACH,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAE3C;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC"}
|
|
@@ -8,6 +8,7 @@ import { type PageState } from "../tools/page_state.js";
|
|
|
8
8
|
import { type RouteMap } from "../tools/route_map.js";
|
|
9
9
|
import { type ApprovalRenderer } from "../ui/approval_card.js";
|
|
10
10
|
import { type QuestionRenderer } from "../ui/question_card.js";
|
|
11
|
+
import type { RelativeTimeFormatter } from "../ui/relative_time.js";
|
|
11
12
|
import { type ToolDisplayMode } from "../ui/tool_call_card.js";
|
|
12
13
|
import { type UiStrings } from "../ui/ui_strings.js";
|
|
13
14
|
import { type AttachmentRef } from "./attachment.js";
|
|
@@ -31,6 +32,12 @@ export interface AttachmentsDetail {
|
|
|
31
32
|
readonly pending: number;
|
|
32
33
|
}
|
|
33
34
|
/** `detail` shape of the {@link STATE_EVENT} CustomEvent. */
|
|
35
|
+
/** {@link FEEDBACK_EVENT} detail: what was rated, and how. */
|
|
36
|
+
export interface FeedbackDetail {
|
|
37
|
+
/** The rated message's text, as rendered. */
|
|
38
|
+
readonly content: string;
|
|
39
|
+
readonly rating: "up" | "down";
|
|
40
|
+
}
|
|
34
41
|
export interface StateDetail {
|
|
35
42
|
readonly state: Readonly<Record<string, unknown>>;
|
|
36
43
|
}
|
|
@@ -48,6 +55,79 @@ export interface ToolRun {
|
|
|
48
55
|
export interface RunFinishedDetail {
|
|
49
56
|
/** In settle order. Empty when the interaction called no tools. */
|
|
50
57
|
readonly tools: readonly ToolRun[];
|
|
58
|
+
/**
|
|
59
|
+
* Every key announced during the interaction, de-duplicated, first-seen order.
|
|
60
|
+
*
|
|
61
|
+
* **This is the field that makes adoption one line** for a host already
|
|
62
|
+
* listening here, and the `else` is the whole compatibility story:
|
|
63
|
+
*
|
|
64
|
+
* ```js
|
|
65
|
+
* if (detail.invalidated.length > 0) refetchOnly(detail.invalidated);
|
|
66
|
+
* else if (detail.tools.some((t) => t.side === "server")) refetchEverything();
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* Empty against a server that announces nothing, so an old server and a new
|
|
70
|
+
* client fall through to the coarse refetch that shipped before either.
|
|
71
|
+
*/
|
|
72
|
+
readonly invalidated: readonly string[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Draw one activity, from its content alone.
|
|
76
|
+
*
|
|
77
|
+
* The contract is {@link ClientTool.render}'s, and for the same reason rather
|
|
78
|
+
* than by analogy. An activity is materialised into a `role: "activity"`
|
|
79
|
+
* message, persisted with the transcript, and re-fired on every restore -- so a
|
|
80
|
+
* renderer that writes to the page instead of returning DOM fires again on
|
|
81
|
+
* every thread load, which is exactly the bug the tool registry's purity rule
|
|
82
|
+
* was written to make unmakeable.
|
|
83
|
+
*
|
|
84
|
+
* - a pure function of `content` -- no host state, no network, no clock;
|
|
85
|
+
* - deterministic, so a reload reproduces what was there before;
|
|
86
|
+
* - free of effects outside the node it returns, which the component places.
|
|
87
|
+
*
|
|
88
|
+
* Return `null` for content that says nothing worth drawing. Anything already
|
|
89
|
+
* drawn under that message id is then removed: live and reload should agree,
|
|
90
|
+
* and the stored content is the version that could not be drawn.
|
|
91
|
+
*/
|
|
92
|
+
export type ActivityRenderer = (content: unknown) => Node | null;
|
|
93
|
+
/** One `activity_type` a host can draw. See {@link AgUiChat.registerActivityRenderer}. */
|
|
94
|
+
export interface ActivityRegistration {
|
|
95
|
+
/**
|
|
96
|
+
* The AG-UI `activity_type` this draws, matched exactly.
|
|
97
|
+
*
|
|
98
|
+
* An open string the protocol does not enumerate -- which is the whole reason
|
|
99
|
+
* this is a registry rather than a branch.
|
|
100
|
+
*/
|
|
101
|
+
readonly type: string;
|
|
102
|
+
readonly render: ActivityRenderer;
|
|
103
|
+
/**
|
|
104
|
+
* Shown in the transcript when something already drawn under this type stops
|
|
105
|
+
* being renderable. Omit for an activity whose disappearance needs no
|
|
106
|
+
* explanation.
|
|
107
|
+
*/
|
|
108
|
+
readonly removedNotice?: string;
|
|
109
|
+
}
|
|
110
|
+
/** `detail` shape of the {@link CUSTOM_AGENT_EVENT} CustomEvent. */
|
|
111
|
+
export interface CustomAgentDetail {
|
|
112
|
+
/** The `CUSTOM` event's `name`, verbatim. An open string; never interpreted here. */
|
|
113
|
+
readonly name: string;
|
|
114
|
+
/** Its `value`, verbatim and unparsed. `unknown` because the protocol says nothing about it. */
|
|
115
|
+
readonly value: unknown;
|
|
116
|
+
}
|
|
117
|
+
/** `detail` shape of the {@link INVALIDATE_EVENT} CustomEvent. */
|
|
118
|
+
export interface InvalidateDetail {
|
|
119
|
+
/**
|
|
120
|
+
* The resources that moved, as the server named them.
|
|
121
|
+
*
|
|
122
|
+
* **Opaque strings, and matching is exact.** `orders/42` does not imply
|
|
123
|
+
* `orders` -- a prefix rule would be this component guessing at a scheme it
|
|
124
|
+
* does not own, and `orders/1` would match `orders/11`. A server that wants
|
|
125
|
+
* the collection refreshed names it. Your own matching may be hierarchical,
|
|
126
|
+
* because in your vocabulary the scheme is known.
|
|
127
|
+
*/
|
|
128
|
+
readonly keys: readonly string[];
|
|
129
|
+
/** What caused the write -- usually the tool's name. `null` when unstated. */
|
|
130
|
+
readonly reason: string | null;
|
|
51
131
|
}
|
|
52
132
|
/** `detail` shape of the {@link TOGGLE_EVENT} CustomEvent. */
|
|
53
133
|
export interface ToggleDetail {
|
|
@@ -92,6 +172,22 @@ export declare class AgUiChat extends HTMLElement {
|
|
|
92
172
|
* `Authorization` are configured independently and neither drops the other.
|
|
93
173
|
*/
|
|
94
174
|
getHeaders: (() => Record<string, string>) | null;
|
|
175
|
+
/**
|
|
176
|
+
* Origins, besides the page's own, that this element may send {@link headers}
|
|
177
|
+
* and {@link getHeaders} credentials to without saying so on the console.
|
|
178
|
+
*
|
|
179
|
+
* Seven attributes name a URL, and every one of them carries these headers.
|
|
180
|
+
* They are plain HTML, so a page that builds one from a query parameter or
|
|
181
|
+
* from tenant-authored configuration has handed an attacker the destination,
|
|
182
|
+
* and the token leaves on the element's first request. Naming the origins you
|
|
183
|
+
* expect turns that from silent into either confirmed or reported.
|
|
184
|
+
*
|
|
185
|
+
* A notice rather than a refusal: a cross-origin agent is a documented
|
|
186
|
+
* deployment, so refusing would break working installations to defend against
|
|
187
|
+
* a page that is already interpolating untrusted data into its own markup.
|
|
188
|
+
* Leaving this empty costs nothing but one console line per foreign origin.
|
|
189
|
+
*/
|
|
190
|
+
trustedOrigins: readonly string[];
|
|
95
191
|
/**
|
|
96
192
|
* Permit `<img>` in rendered assistant markdown. **Off by default**: a
|
|
97
193
|
* model-controlled image URL is fetched with no user interaction, which
|
|
@@ -99,6 +195,22 @@ export declare class AgUiChat extends HTMLElement {
|
|
|
99
195
|
* data. Enable only when the content source is trusted.
|
|
100
196
|
*/
|
|
101
197
|
allowImages: boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Replace the relative timestamps in the thread drawer and the checkpoint
|
|
200
|
+
* panel -- `"5m ago"`, `"2d ago"` -- with the host's own formatting.
|
|
201
|
+
*
|
|
202
|
+
* The built-in is locale-neutral on purpose: there is no `Intl` anywhere in
|
|
203
|
+
* this component, so it never disagrees with the page it is embedded in by
|
|
204
|
+
* guessing a locale. That is a good default and a bad requirement, which is
|
|
205
|
+
* what this is for.
|
|
206
|
+
*
|
|
207
|
+
* ```js
|
|
208
|
+
* const rtf = new Intl.RelativeTimeFormat("de", { numeric: "auto" });
|
|
209
|
+
* chat.formatRelativeTime = (ts) =>
|
|
210
|
+
* rtf.format(Math.round((ts - Date.now()) / 60000), "minute");
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
formatRelativeTime: RelativeTimeFormatter | null;
|
|
102
214
|
/** When true, destructive tools execute without a confirmation modal. */
|
|
103
215
|
autoConfirm: boolean;
|
|
104
216
|
/**
|
|
@@ -122,6 +234,22 @@ export declare class AgUiChat extends HTMLElement {
|
|
|
122
234
|
* is enabled server-side; this only changes how the decision is collected.
|
|
123
235
|
*/
|
|
124
236
|
approvalRenderer: ApprovalRenderer | null;
|
|
237
|
+
/**
|
|
238
|
+
* Let the user edit a gated call's arguments before approving it.
|
|
239
|
+
*
|
|
240
|
+
* Off by default and **an assertion about your server**, not a negotiation:
|
|
241
|
+
* AG-UI carries `editedArgs` in the resume payload and gates it on the
|
|
242
|
+
* agent's own `approveWithEdits` capability, which this component never sees
|
|
243
|
+
* -- capabilities are not on the wire it reads. So the host says whether its
|
|
244
|
+
* agent honours them. Turned on against a server that does not, the user
|
|
245
|
+
* would edit arguments it silently discards, which is worse than not
|
|
246
|
+
* offering.
|
|
247
|
+
*
|
|
248
|
+
* Only affects calls whose arguments are known here: an interrupt names a
|
|
249
|
+
* `toolCallId`, and the tool card for that call is where the arguments still
|
|
250
|
+
* are. An interrupt naming no card gets the plain approve/deny.
|
|
251
|
+
*/
|
|
252
|
+
approveWithEdits: boolean;
|
|
125
253
|
/**
|
|
126
254
|
* Optional per-call confirmation predicate. When set it is authoritative,
|
|
127
255
|
* deciding from the tool name and args whether this particular call needs
|
|
@@ -218,7 +346,18 @@ export declare class AgUiChat extends HTMLElement {
|
|
|
218
346
|
/** Attributes the element reacts to after it has been connected. */
|
|
219
347
|
static get observedAttributes(): string[];
|
|
220
348
|
attributeChangedCallback(name: string, previous: string | null, value: string | null): void;
|
|
221
|
-
/**
|
|
349
|
+
/**
|
|
350
|
+
* Declare a frontend tool the agent may call.
|
|
351
|
+
*
|
|
352
|
+
* **A handler's thrown message leaves the browser.** When a handler rejects,
|
|
353
|
+
* its `Error.message` is posted back as that call's tool result — into the
|
|
354
|
+
* conversation, on to the AG-UI endpoint, persisted server-side, and
|
|
355
|
+
* forwarded to the model provider on every later round. That is deliberate,
|
|
356
|
+
* since it is what lets the agent recover from a failure it caused; but it
|
|
357
|
+
* means an internal hostname, a signed URL or a stack-derived path in a
|
|
358
|
+
* rethrown error is disclosed to parties the host never chose. Throw the
|
|
359
|
+
* message you would be content for the model to read, and log the detail.
|
|
360
|
+
*/
|
|
222
361
|
registerTool(tool: ClientTool): void;
|
|
223
362
|
/**
|
|
224
363
|
* AG-UI **shared state** for this conversation — the protocol's own state
|
|
@@ -242,6 +381,33 @@ export declare class AgUiChat extends HTMLElement {
|
|
|
242
381
|
/** The AG-UI endpoint URL, read from the `endpoint` attribute. */
|
|
243
382
|
get endpoint(): string;
|
|
244
383
|
set endpoint(value: string);
|
|
384
|
+
/**
|
|
385
|
+
* Who the stored conversation belongs to, from the `user-key` attribute.
|
|
386
|
+
*
|
|
387
|
+
* Set it to whatever identifies the signed-in principal — a user id, an
|
|
388
|
+
* account id, a hash of one. The value joins the storage namespace, so two
|
|
389
|
+
* principals in the same tab cannot read each other's transcript, and
|
|
390
|
+
* **changing it purges what the previous one left behind**.
|
|
391
|
+
*
|
|
392
|
+
* That purge is the reason this is a live attribute rather than a
|
|
393
|
+
* connect-time one. `sessionStorage` survives same-tab navigation, so it
|
|
394
|
+
* survives a logout; and a single-page app signs out through its own router
|
|
395
|
+
* without remounting anything, so there is no other moment at which the
|
|
396
|
+
* element could find out. The host naming the new principal — or dropping the
|
|
397
|
+
* attribute — is the signal.
|
|
398
|
+
*
|
|
399
|
+
* Absent means exactly today's behaviour, which is why nothing breaks by
|
|
400
|
+
* leaving it off: the conversation is scoped to the element and to nobody in
|
|
401
|
+
* particular, and on a shared workstation it carries into whoever signs in
|
|
402
|
+
* next in the same tab.
|
|
403
|
+
*
|
|
404
|
+
* The first value to arrive is treated as a host naming the user who was
|
|
405
|
+
* already there, not as a handover: the conversation in progress moves into
|
|
406
|
+
* the principal's namespace rather than being destroyed, so an element
|
|
407
|
+
* configured by an async auth handshake keeps what is on screen.
|
|
408
|
+
*/
|
|
409
|
+
get userKey(): string;
|
|
410
|
+
set userKey(value: string);
|
|
245
411
|
/**
|
|
246
412
|
* Cookie policy for **every** request this element makes, as `fetch`'s own
|
|
247
413
|
* `credentials` mode (`"omit"` / `"same-origin"` / `"include"`). Mirrored to
|
|
@@ -294,6 +460,42 @@ export declare class AgUiChat extends HTMLElement {
|
|
|
294
460
|
* indicator clears. Without this a removed element leaks all three.
|
|
295
461
|
*/
|
|
296
462
|
disconnectedCallback(): void;
|
|
463
|
+
/**
|
|
464
|
+
* Put `text` into the composer as a markdown quotation, and focus it.
|
|
465
|
+
*
|
|
466
|
+
* Deliberately **not** a send. Quoting is how a question narrows to one part
|
|
467
|
+
* of an answer, so the quotation is the preamble and the question is what
|
|
468
|
+
* comes next -- the caret is left after it, on its own line.
|
|
469
|
+
*
|
|
470
|
+
* This is also the seam for the half of this feature the component cannot
|
|
471
|
+
* build: selection in the **host page**. A widget mounted beside a table can
|
|
472
|
+
* be asked about a row, and nothing in a chat's own transcript can offer
|
|
473
|
+
* that. A host reads its own selection, however it likes, and calls this.
|
|
474
|
+
*
|
|
475
|
+
* No-ops on text that is empty or only whitespace.
|
|
476
|
+
*/
|
|
477
|
+
quote(text: string): void;
|
|
478
|
+
/**
|
|
479
|
+
* Offer to quote what the user selects in the **host page**, not just in the
|
|
480
|
+
* transcript. Returns a function that stops offering.
|
|
481
|
+
*
|
|
482
|
+
* The same select-then-offer gesture, over a table, a diff, a report -- the
|
|
483
|
+
* surface the user actually works in, which is the half of quoting no hosted
|
|
484
|
+
* chat can reach. Opt-in, because it listens on the host's document and that
|
|
485
|
+
* is theirs to grant.
|
|
486
|
+
*
|
|
487
|
+
* Deliberately **not** a four-line recipe, which is how this shipped first
|
|
488
|
+
* and was wrong: a page listener that quotes every settled selection appends
|
|
489
|
+
* to the composer on every drag made to read, to copy or to fix a typo -- and
|
|
490
|
+
* it cannot tell a selection in the page's prose from one inside the user's
|
|
491
|
+
* own half-typed `<input>`, because Chrome reports a field's internal
|
|
492
|
+
* selection as an ordinary range over the field's *wrapper*. See
|
|
493
|
+
* {@link attachQuoteOffer} for the guards.
|
|
494
|
+
*
|
|
495
|
+
* Detached automatically when the element leaves the document; a host that
|
|
496
|
+
* re-mounts it calls this again.
|
|
497
|
+
*/
|
|
498
|
+
offerQuoteInPage(within?: HTMLElement): () => void;
|
|
297
499
|
/**
|
|
298
500
|
* Replace the host-supplied (client) skill catalog. Merged after the embedded
|
|
299
501
|
* and fetched skills (so a client skill overrides a same-named server one).
|
|
@@ -360,6 +562,23 @@ export declare class AgUiChat extends HTMLElement {
|
|
|
360
562
|
* starts something new must not be the button that destroys what was there.
|
|
361
563
|
*/
|
|
362
564
|
newChat(): void;
|
|
565
|
+
/**
|
|
566
|
+
* Ask the same question again and replace the answer.
|
|
567
|
+
*
|
|
568
|
+
* History is truncated to the most recent user message inclusive and the run
|
|
569
|
+
* repeats, so the agent answers what it was asked rather than being told its
|
|
570
|
+
* last answer was wrong. Returns `false` when there is nothing to retry or a
|
|
571
|
+
* run is already in flight.
|
|
572
|
+
*
|
|
573
|
+
* Public because a host with its own message UI wants the same button, and
|
|
574
|
+
* because the failed-run notice reaches it from outside the action row.
|
|
575
|
+
*
|
|
576
|
+
* **A retried turn re-runs its tools**, which for a page-driving agent is not
|
|
577
|
+
* neutral: the previous attempt already clicked what it clicked, and this
|
|
578
|
+
* does not undo it. Confirmation still applies, so a destructive tool asks
|
|
579
|
+
* again -- unless the user waived it for this session.
|
|
580
|
+
*/
|
|
581
|
+
retryLastTurn(): Promise<boolean>;
|
|
363
582
|
/**
|
|
364
583
|
* Append a message bubble and return it.
|
|
365
584
|
*
|
|
@@ -419,5 +638,47 @@ export declare class AgUiChat extends HTMLElement {
|
|
|
419
638
|
* arrives is not something to switch on for everybody.
|
|
420
639
|
*/
|
|
421
640
|
enableCharts(routes?: readonly ("tool" | "activity")[]): void;
|
|
641
|
+
/**
|
|
642
|
+
* Teach this element to draw one kind of AG-UI activity.
|
|
643
|
+
*
|
|
644
|
+
* `activity_type` is one of exactly two fields the protocol leaves an open
|
|
645
|
+
* string, and it is the **content** one: an activity is materialised into a
|
|
646
|
+
* message, persisted with the thread, and replayed on every restore. Its
|
|
647
|
+
* sibling `CUSTOM` carries an imperative and is dispatched to the page
|
|
648
|
+
* instead ({@link CUSTOM_AGENT_EVENT}).
|
|
649
|
+
*
|
|
650
|
+
* That asymmetry decides which carrier a server should use. Content has a
|
|
651
|
+
* place in the conversation and should come back; an imperative has no place
|
|
652
|
+
* and no meaning once acted on.
|
|
653
|
+
*
|
|
654
|
+
* ```js
|
|
655
|
+
* chat.registerActivityRenderer({
|
|
656
|
+
* type: "build_status",
|
|
657
|
+
* render: (content) => {
|
|
658
|
+
* const el = document.createElement("div");
|
|
659
|
+
* el.textContent = `Build ${content.status}`;
|
|
660
|
+
* return el;
|
|
661
|
+
* },
|
|
662
|
+
* });
|
|
663
|
+
* ```
|
|
664
|
+
*
|
|
665
|
+
* Registering a type twice replaces the earlier renderer, so a host can
|
|
666
|
+
* override a built-in -- `chart` and `compaction` are registrations like any
|
|
667
|
+
* other, not privileged branches.
|
|
668
|
+
*
|
|
669
|
+
* ⚠ `render` runs again on every thread load. See {@link ActivityRenderer}
|
|
670
|
+
* for what that requires of it.
|
|
671
|
+
*/
|
|
672
|
+
registerActivityRenderer(registration: ActivityRegistration): void;
|
|
673
|
+
/**
|
|
674
|
+
* Activity types that arrived with nobody registered to draw them.
|
|
675
|
+
*
|
|
676
|
+
* Deliberately the only trace an unhandled activity leaves. Ignoring an
|
|
677
|
+
* unknown name is the protocol's own answer and the whole point of an open
|
|
678
|
+
* field, so warning would fire on every forward-compatible server -- but
|
|
679
|
+
* "nothing happened and nothing was said" is impossible to debug, so the set
|
|
680
|
+
* is readable. Accumulates for the element's lifetime, across threads.
|
|
681
|
+
*/
|
|
682
|
+
get unhandledActivityTypes(): readonly string[];
|
|
422
683
|
}
|
|
423
684
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"ag_ui_chat.d.ts","sourceRoot":"","sources":["../../src/core/ag_ui_chat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO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AS,CAAC,MAAM,GAAG,UAAU,CAAC,EAAyB,GAAG,IAAI,CA2BlF;IAmCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,wBAAwB,CAAC,YAAY,EAAE,oBAAoB,GAAG,IAAI,CAGjE;IAED;;;;;;;;OAQG;IACH,IAAI,sBAAsB,IAAI,SAAS,MAAM,EAAE,CAE9C;CA+GF"}
|
|
@@ -87,11 +87,36 @@ export interface AgUiClientHandlers {
|
|
|
87
87
|
onActivityChanged(messageId: string, activityType: string, content: unknown): void;
|
|
88
88
|
/** Fired when a reasoning model starts emitting its chain-of-thought. */
|
|
89
89
|
onReasoningStart(): void;
|
|
90
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* Fired on every reasoning token, and once more when the block ends.
|
|
92
|
+
*
|
|
93
|
+
* ``buffer`` is the text accumulated *before* the token that triggered the
|
|
94
|
+
* call, which is what the protocol client passes -- so the stream trails by
|
|
95
|
+
* one delta and the final call, at the end of the block, is what completes
|
|
96
|
+
* it. Render the buffer wholesale rather than appending it.
|
|
97
|
+
*/
|
|
91
98
|
onReasoningDelta(buffer: string): void;
|
|
92
99
|
/** Fired when the reasoning block ends (before the answer text streams). */
|
|
93
100
|
onReasoningEnd(): void;
|
|
94
101
|
onRunEnd(): void;
|
|
102
|
+
/**
|
|
103
|
+
* The server replaced the whole conversation with `MESSAGES_SNAPSHOT`.
|
|
104
|
+
*
|
|
105
|
+
* `@ag-ui/client` applies the event before any subscriber sees it, so by the
|
|
106
|
+
* time this fires `agent.messages` **is** the server's list -- and the run
|
|
107
|
+
* loop persists `agent.messages`. The replacement therefore reaches the
|
|
108
|
+
* conversation store whatever the host does; this hook exists so the host can
|
|
109
|
+
* stop that being invisible.
|
|
110
|
+
*/
|
|
111
|
+
onMessagesSnapshot(messages: readonly Message[]): void;
|
|
112
|
+
/**
|
|
113
|
+
* The agent sent a `CUSTOM` event.
|
|
114
|
+
*
|
|
115
|
+
* Forwarded whole and uninterpreted: `name` is an open string the protocol
|
|
116
|
+
* does not enumerate, so a client that decided which names were legal would
|
|
117
|
+
* be the thing the open field exists to avoid.
|
|
118
|
+
*/
|
|
119
|
+
onCustomEvent(name: string, value: unknown): void;
|
|
95
120
|
onError(message: string): void;
|
|
96
121
|
/**
|
|
97
122
|
* Fired when the user cancelled the run ({@link AgUiClient.cancel}) — the
|
|
@@ -185,6 +210,26 @@ export declare class AgUiClient {
|
|
|
185
210
|
* {@link messageAttachments}.
|
|
186
211
|
*/
|
|
187
212
|
send(content: string, attachments?: readonly AttachmentRef[]): Promise<void>;
|
|
213
|
+
/**
|
|
214
|
+
* Drop everything after the most recent user message, so the same question
|
|
215
|
+
* can be asked again.
|
|
216
|
+
*
|
|
217
|
+
* Returns the retained history, or `null` when there is nothing to retry (no
|
|
218
|
+
* user message has been sent yet). **Truncates only** -- the caller re-renders
|
|
219
|
+
* from the returned list and then calls {@link resume}, because the transcript
|
|
220
|
+
* belongs to the element and a client that reached into it would own two
|
|
221
|
+
* things. Running here instead would stream the new answer in underneath the
|
|
222
|
+
* old one.
|
|
223
|
+
*
|
|
224
|
+
* Re-running answers the question the agent was last asked, rather than
|
|
225
|
+
* telling it its answer was wrong, which is what makes the result a
|
|
226
|
+
* *different* answer instead of a conversation about the previous one.
|
|
227
|
+
*
|
|
228
|
+
* **A retried turn re-runs its tools.** For a page-driving agent that is not
|
|
229
|
+
* neutral: the previous attempt already clicked what it clicked, and this
|
|
230
|
+
* does not undo it.
|
|
231
|
+
*/
|
|
232
|
+
truncateToLastUser(): readonly Message[] | null;
|
|
188
233
|
/**
|
|
189
234
|
* Resume the run loop after a navigating tool's result was supplied
|
|
190
235
|
* 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,EACL,KAAK,aAAa,EAKnB,MAAM,eAAe,CAAC;AACvB,OAA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OAAO,CAAC,CAAC,GAAG,IAAI,CAEvD;IAED,4CAA4C;IAC5C,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,wEAAwE;IACxE,IAAI,QAAQ,IAAI,SAAS,OAAO,EAAE,CAEjC;IAED;;;;;;;;;;OAUG;IACG,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,GAAE,SAAS,aAAa,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAWrF;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,kBAAkB,IAAI,SAAS,OAAO,EAAE,GAAG,IAAI,CAkB9C;IAED;;;;OAIG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAE5B;IAED,0EAA0E;IAC1E,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAGvD;IAED;;;;;;OAMG;IACH,MAAM,IAAI,IAAI,CAGb;CAiQF"}
|
|
@@ -84,6 +84,23 @@ export interface ClientConversationStore {
|
|
|
84
84
|
*/
|
|
85
85
|
isUnsent?(threadId: string): boolean;
|
|
86
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* `sessionStorage.setItem` that survives a store which refuses to write.
|
|
89
|
+
*
|
|
90
|
+
* `setItem` throws on an exhausted quota (a long conversation, or one turn
|
|
91
|
+
* carrying a large tool result) and in privacy modes that deny storage
|
|
92
|
+
* altogether. Every write here is a *durability* concern — surviving a reload —
|
|
93
|
+
* and none of them is worth an exception, because of where they are called
|
|
94
|
+
* from: the element persists the transcript from inside the run loop, so an
|
|
95
|
+
* unguarded throw escapes as a run error and tells the user the agent failed
|
|
96
|
+
* when nothing but the browser's storage did. On the cancel path it escapes as
|
|
97
|
+
* an unhandled rejection instead.
|
|
98
|
+
*
|
|
99
|
+
* So a failed write loses the reload, never the conversation on screen, and
|
|
100
|
+
* says so once. Recovery is in the user's hands already: deleting the oversized
|
|
101
|
+
* thread from the history drawer is a `removeItem`, which frees the quota.
|
|
102
|
+
*/
|
|
103
|
+
export declare function writeStoredItem(key: string, value: string): void;
|
|
87
104
|
/**
|
|
88
105
|
* Default {@link ClientConversationStore}: per-tab `sessionStorage`.
|
|
89
106
|
*
|
|
@@ -95,11 +112,36 @@ export interface ClientConversationStore {
|
|
|
95
112
|
* An optional `namespace` scopes every key to one element, so two
|
|
96
113
|
* `<ag-ui-chat>` instances on the same origin keep separate active-thread
|
|
97
114
|
* pointers and drawer indexes instead of clobbering each other. The default
|
|
98
|
-
* empty namespace keeps the origin-global keys
|
|
115
|
+
* empty namespace keeps the origin-global keys, which a namespaced store adopts
|
|
116
|
+
* on construction; see {@link SessionStorageStore.adopt}.
|
|
99
117
|
*/
|
|
100
118
|
export declare class SessionStorageStore implements ClientConversationStore {
|
|
101
119
|
#private;
|
|
102
120
|
constructor(namespace?: string);
|
|
121
|
+
/**
|
|
122
|
+
* Move every key a store owns out of `from`'s namespace and into `to`'s.
|
|
123
|
+
*
|
|
124
|
+
* Two callers, one move. The constructor adopts the pre-namespacing global
|
|
125
|
+
* keys (`from` = `""`); `<ag-ui-chat>` adopts an element-scoped conversation
|
|
126
|
+
* into a principal-scoped one the first time a `user-key` arrives, which is a
|
|
127
|
+
* host naming the user who was already there rather than a handover.
|
|
128
|
+
*
|
|
129
|
+
* Only this store's own suffixes move — the element's `collapsed` / `size` /
|
|
130
|
+
* `theme` keys share the global root and are deliberately left where they
|
|
131
|
+
* are. A value already present at the destination wins: the destination is
|
|
132
|
+
* the durable record and the source is the stray this move exists to clear.
|
|
133
|
+
*/
|
|
134
|
+
static adopt(from: string, to: string): void;
|
|
135
|
+
/**
|
|
136
|
+
* Forget everything a store holds for `namespace`.
|
|
137
|
+
*
|
|
138
|
+
* The logout primitive: `<ag-ui-chat>` calls it when its `user-key` changes,
|
|
139
|
+
* and a host driving its own store can call it from its own sign-out path.
|
|
140
|
+
* Deliberately narrow — it removes only keys under this exact namespace whose
|
|
141
|
+
* suffix parses as one this store writes, so it can never reach another
|
|
142
|
+
* element's conversation or the host's own `sessionStorage` entries.
|
|
143
|
+
*/
|
|
144
|
+
static purge(namespace: string): void;
|
|
103
145
|
threadId(): string;
|
|
104
146
|
newThread(): string;
|
|
105
147
|
isUnsent(threadId: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation_store.d.ts","sourceRoot":"","sources":["../../src/core/conversation_store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,uEAAuE;IACvE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,uBAAuB;IACtC,yEAAyE;IACzE,QAAQ,IAAI,MAAM,CAAC;IACnB;;;;;;;;;;OAUG;IACH,SAAS,CAAC,IAAI,MAAM,CAAC;IACrB,sEAAsE;IACtE,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IACnE,8EAA8E;IAC9E,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI,CAAC;IACnE,0EAA0E;IAC1E,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI,CAAC;IAC9D,4EAA4E;IAC5E,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,GAAG,IAAI,GAAG,IAAI,CAAC;IAChF,+EAA+E;IAC/E,KAAK,CAA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AY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI,CAIjE;IAED,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI,CAE5D;IAED,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,GAAG,IAAI,GAAG,IAAI,CAO9E;IAED,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAW5B;IAED,WAAW,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,CAK5C;IAED,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAEtC;IAED,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CASlD;CAwDF"}
|
|
@@ -30,6 +30,19 @@ export interface HttpAgentOptions {
|
|
|
30
30
|
* server streams `STATE_SNAPSHOT` / `STATE_DELTA`.
|
|
31
31
|
*/
|
|
32
32
|
initialState?: Readonly<Record<string, unknown>>;
|
|
33
|
+
/**
|
|
34
|
+
* Origins, besides the document's own, this agent may carry the host's
|
|
35
|
+
* credentials to.
|
|
36
|
+
*
|
|
37
|
+
* Running the agent on another subdomain is a normal deployment and stays
|
|
38
|
+
* supported, so a cross-origin endpoint is not refused — it is *announced*,
|
|
39
|
+
* once per origin, on the console. Listing an origin here says the
|
|
40
|
+
* destination was chosen deliberately and silences the notice for it.
|
|
41
|
+
*
|
|
42
|
+
* Entries are compared as serialized origins (`https://agent.example.com`,
|
|
43
|
+
* scheme and port included), which is what `URL.origin` produces.
|
|
44
|
+
*/
|
|
45
|
+
trustedOrigins?: readonly string[];
|
|
33
46
|
}
|
|
34
47
|
/**
|
|
35
48
|
* Build an AG-UI {@link HttpAgent} pointed at `endpoint`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_http_agent.d.ts","sourceRoot":"","sources":["../../src/core/create_http_agent.ts"],"names":[],"mappings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