@artooi/ag-ui-web-component 0.2.1 → 0.3.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 +46 -1
- package/README.md +12 -2
- package/dist/ag-ui-web-component.bundle.js +31 -28
- package/dist/ag-ui-web-component.bundle.js.map +4 -4
- package/dist/core/ag_ui_chat.d.ts +9 -0
- package/dist/core/ag_ui_chat.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +89 -17
- package/dist/index.js.map +3 -3
- package/dist/tools/parse_tool_catalog.d.ts +19 -0
- package/dist/tools/parse_tool_catalog.d.ts.map +1 -0
- package/dist/tools/route_map.d.ts.map +1 -1
- package/dist/tools/state_hook.d.ts.map +1 -1
- package/dist/ui/styles.d.ts +1 -1
- package/dist/ui/styles.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/ag_ui_chat.ts +76 -16
- package/src/index.ts +1 -0
- package/src/tools/parse_tool_catalog.ts +36 -0
- package/src/tools/route_map.ts +3 -2
- package/src/tools/state_hook.ts +12 -3
- package/src/ui/styles.ts +4 -1
- package/src/version.ts +1 -1
|
@@ -91,6 +91,15 @@ export declare class AgUiChat extends HTMLElement {
|
|
|
91
91
|
* this from the current page; a missing placeholder blocks the send.
|
|
92
92
|
*/
|
|
93
93
|
skillContext: () => Record<string, unknown>;
|
|
94
|
+
/**
|
|
95
|
+
* Friendly display labels for tool-call cards, keyed by tool name (e.g.
|
|
96
|
+
* `{ list_projects: "Search projects" }`). Used as a fallback when a tool has
|
|
97
|
+
* no `x-summary` in its own schema — chiefly **server-side tools** (drf-mcp,
|
|
98
|
+
* `@tool` registry), whose schema never reaches the browser (AG-UI streams
|
|
99
|
+
* only the tool-call name). Client tools should prefer `x-summary` on their
|
|
100
|
+
* schema; this map is the seam for everything else.
|
|
101
|
+
*/
|
|
102
|
+
toolSummaries: Record<string, string>;
|
|
94
103
|
constructor();
|
|
95
104
|
/** Attributes whose late changes must reflect in already-rendered chrome. */
|
|
96
105
|
static get observedAttributes(): string[];
|
|
@@ -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,EACL,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;
|
|
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,EACL,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;AAM9E,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAO7E,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAE1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,wBAAwB,CAAC;AAE5E,8CAA8C;AAC9C,MAAM,MAAM,WAAW,GAAG,CAAC,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;IAEzD;;;;;;;OAOG;IACH,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;;IAqD3C,6EAA6E;IAC7E,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAM7F,kDAAkD;IAClD,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAIpC,wEAAwE;IACxE,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IA0DxC,kEAAkE;IAClE,IAAI,QAAQ,IAAI,MAAM,CAErB;IAKD,IAAI,QAAQ,CAAC,KAAK,EAAE,MAAM,EAEzB;IAED;;;OAGG;IACH,IAAI,WAAW,IAAI,eAAe,CAMjC;IAED,IAAI,WAAW,CAAC,KAAK,EAAE,eAAe,EAErC;IAED,iBAAiB,IAAI,IAAI;IAyBzB;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,GAAG,IAAI;IAoEzC,gFAAgF;IAChF,IAAI,SAAS,IAAI,OAAO,CAEvB;IAID,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,EAE3B;IAED;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI;IAgBtC,qEAAqE;IACrE,eAAe,IAAI,IAAI;IAIvB;;;OAGG;IACH,OAAO,IAAI,IAAI;IA0Gf;;;;;;OAMG;IACH,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc;CAuVlE"}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export { type ClientTool, ClientToolRegistry } from "./tools/client_tool_registr
|
|
|
12
12
|
export { isDestructive } from "./tools/is_destructive.js";
|
|
13
13
|
export { isNavigates } from "./tools/is_navigates.js";
|
|
14
14
|
export { createPageMapContext, type PageMap } from "./tools/page_map.js";
|
|
15
|
+
export { parseToolCatalog, type ToolCatalogEntry } from "./tools/parse_tool_catalog.js";
|
|
15
16
|
export { createRouteTools, type Route, type RouteMap, type RouteWithParams, } from "./tools/route_map.js";
|
|
16
17
|
export { createStateHookTools, type StateHook } from "./tools/state_hook.js";
|
|
17
18
|
export { type ConfirmationRequest, requestConfirmation } from "./ui/confirmation_card.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,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,YAAY,EACjB,eAAe,EACf,KAAK,gBAAgB,GACtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EACL,KAAK,YAAY,EACjB,cAAc,EACd,KAAK,qBAAqB,EAC1B,kBAAkB,EAClB,KAAK,YAAY,EACjB,oBAAoB,EACpB,cAAc,EACd,KAAK,aAAa,EAClB,oBAAoB,EACpB,YAAY,EACZ,KAAK,eAAe,EAC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,EAAE,oBAAoB,EAAE,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,EACL,gBAAgB,EAChB,KAAK,KAAK,EACV,KAAK,QAAQ,EACb,KAAK,eAAe,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,KAAK,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EACL,KAAK,aAAa,EAClB,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -106,6 +106,26 @@ function createPageMapContext(getPageMap, autoInject) {
|
|
|
106
106
|
return [{ description: "page_map", value: JSON.stringify(getPageMap()) }];
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
// src/tools/parse_tool_catalog.ts
|
|
110
|
+
function parseToolCatalog(data) {
|
|
111
|
+
const out = {};
|
|
112
|
+
if (!Array.isArray(data)) {
|
|
113
|
+
return out;
|
|
114
|
+
}
|
|
115
|
+
for (const entry of data) {
|
|
116
|
+
if (entry === null || typeof entry !== "object") {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const record = entry;
|
|
120
|
+
const name = record["name"];
|
|
121
|
+
const summary = record["summary"];
|
|
122
|
+
if (typeof name === "string" && typeof summary === "string") {
|
|
123
|
+
out[name] = summary;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return out;
|
|
127
|
+
}
|
|
128
|
+
|
|
109
129
|
// src/tools/route_map.ts
|
|
110
130
|
var PATH_PARAM_RE = /:([A-Za-z_][A-Za-z0-9_]*)/g;
|
|
111
131
|
function pathParamNames(path) {
|
|
@@ -143,7 +163,7 @@ function createRouteTools(getRouteMap, getNavigate) {
|
|
|
143
163
|
{
|
|
144
164
|
name: "list_routes",
|
|
145
165
|
description: "List the routes the app can navigate to. Each route's `pathParams` names the dynamic segments to pass as `params` to `navigate_to_route`.",
|
|
146
|
-
parameters: { type: "object", properties: {}, required: [] },
|
|
166
|
+
parameters: { type: "object", properties: {}, required: [], [X_SUMMARY_KEY]: "List pages" },
|
|
147
167
|
handler: () => getRouteMap().map((route) => ({ ...route, pathParams: pathParamNames(route.path) }))
|
|
148
168
|
},
|
|
149
169
|
{
|
|
@@ -156,7 +176,8 @@ function createRouteTools(getRouteMap, getNavigate) {
|
|
|
156
176
|
params: { type: "object" }
|
|
157
177
|
},
|
|
158
178
|
required: ["route_id"],
|
|
159
|
-
[X_NAVIGATES_KEY]: true
|
|
179
|
+
[X_NAVIGATES_KEY]: true,
|
|
180
|
+
[X_SUMMARY_KEY]: "Navigate"
|
|
160
181
|
},
|
|
161
182
|
handler: (args) => {
|
|
162
183
|
const routeId = args["route_id"];
|
|
@@ -185,7 +206,12 @@ function createStateHookTools(hook) {
|
|
|
185
206
|
{
|
|
186
207
|
name: `read_${hook.name}`,
|
|
187
208
|
description: `Read the "${hook.name}" state.`,
|
|
188
|
-
parameters: {
|
|
209
|
+
parameters: {
|
|
210
|
+
type: "object",
|
|
211
|
+
properties: {},
|
|
212
|
+
required: [],
|
|
213
|
+
[X_SUMMARY_KEY]: `Read ${hook.name}`
|
|
214
|
+
},
|
|
189
215
|
handler: () => hook.read()
|
|
190
216
|
}
|
|
191
217
|
];
|
|
@@ -194,7 +220,11 @@ function createStateHookTools(hook) {
|
|
|
194
220
|
tools.push({
|
|
195
221
|
name: `set_${hook.name}`,
|
|
196
222
|
description: `Update the "${hook.name}" state.`,
|
|
197
|
-
parameters: {
|
|
223
|
+
parameters: {
|
|
224
|
+
...hook.schema ?? { type: "object" },
|
|
225
|
+
[X_DESTRUCTIVE_KEY]: true,
|
|
226
|
+
[X_SUMMARY_KEY]: `Update ${hook.name}`
|
|
227
|
+
},
|
|
198
228
|
handler: (args) => write(args)
|
|
199
229
|
});
|
|
200
230
|
}
|
|
@@ -3145,7 +3175,10 @@ var STYLES = `
|
|
|
3145
3175
|
}
|
|
3146
3176
|
|
|
3147
3177
|
/* \u2500\u2500 Incoming-text animations (data-text-animation) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
3148
|
-
|
|
3178
|
+
/* .message--restored (rehydrated history) is excluded: entrance animations are
|
|
3179
|
+
for freshly-arriving messages, not the whole transcript replaying on reload.
|
|
3180
|
+
Word mode is excluded implicitly \u2014 restored bubbles aren't wrapped. */
|
|
3181
|
+
:host([data-text-animation="fade"]) .message--assistant:not(.message--restored) {
|
|
3149
3182
|
animation: ag-ui-msg-fade 0.25s ease both;
|
|
3150
3183
|
}
|
|
3151
3184
|
|
|
@@ -3882,6 +3915,21 @@ var AgUiChat = class extends HTMLElement {
|
|
|
3882
3915
|
* this from the current page; a missing placeholder blocks the send.
|
|
3883
3916
|
*/
|
|
3884
3917
|
skillContext = () => ({});
|
|
3918
|
+
/**
|
|
3919
|
+
* Friendly display labels for tool-call cards, keyed by tool name (e.g.
|
|
3920
|
+
* `{ list_projects: "Search projects" }`). Used as a fallback when a tool has
|
|
3921
|
+
* no `x-summary` in its own schema — chiefly **server-side tools** (drf-mcp,
|
|
3922
|
+
* `@tool` registry), whose schema never reaches the browser (AG-UI streams
|
|
3923
|
+
* only the tool-call name). Client tools should prefer `x-summary` on their
|
|
3924
|
+
* schema; this map is the seam for everything else.
|
|
3925
|
+
*/
|
|
3926
|
+
toolSummaries = {};
|
|
3927
|
+
/**
|
|
3928
|
+
* Card labels fetched from a server tool catalog (`data-tools-url`), keyed by
|
|
3929
|
+
* tool name. The base layer behind {@link toolSummaries}: an explicit entry in
|
|
3930
|
+
* `toolSummaries` wins, this fills the rest. Populated once on connect.
|
|
3931
|
+
*/
|
|
3932
|
+
#toolCatalog = {};
|
|
3885
3933
|
#toolRegistry = new ClientToolRegistry();
|
|
3886
3934
|
/** Tool-call cards awaiting execution, keyed by call id. */
|
|
3887
3935
|
#toolCards = /* @__PURE__ */ new Map();
|
|
@@ -3901,6 +3949,10 @@ var AgUiChat = class extends HTMLElement {
|
|
|
3901
3949
|
#skillHint;
|
|
3902
3950
|
#client = null;
|
|
3903
3951
|
#streamingBubble = null;
|
|
3952
|
+
// Text deltas applied to the current streaming bubble. >1 ⇒ the message
|
|
3953
|
+
// revealed progressively as it streamed, so the word reveal must not re-animate
|
|
3954
|
+
// it; ≤1 ⇒ it arrived at once and the word reveal is appropriate.
|
|
3955
|
+
#streamDeltas = 0;
|
|
3904
3956
|
#pending = null;
|
|
3905
3957
|
#threadId = "";
|
|
3906
3958
|
#initialMessages = [];
|
|
@@ -3960,7 +4012,12 @@ var AgUiChat = class extends HTMLElement {
|
|
|
3960
4012
|
{
|
|
3961
4013
|
name: "read_page",
|
|
3962
4014
|
description: "Read the current page's structure (fields, buttons, route). Call after acting to observe the result within the same turn.",
|
|
3963
|
-
parameters: {
|
|
4015
|
+
parameters: {
|
|
4016
|
+
type: "object",
|
|
4017
|
+
properties: {},
|
|
4018
|
+
required: [],
|
|
4019
|
+
[X_SUMMARY_KEY]: "Read the page"
|
|
4020
|
+
},
|
|
3964
4021
|
handler: () => getPageMap()
|
|
3965
4022
|
}
|
|
3966
4023
|
];
|
|
@@ -4007,9 +4064,22 @@ var AgUiChat = class extends HTMLElement {
|
|
|
4007
4064
|
this.setAttribute("collapsed", "");
|
|
4008
4065
|
}
|
|
4009
4066
|
this.#initSkills();
|
|
4067
|
+
void this.#fetchToolCatalog();
|
|
4010
4068
|
this.#threadId = this.conversationStore.threadId();
|
|
4011
4069
|
void this.#rehydrate();
|
|
4012
4070
|
}
|
|
4071
|
+
/** Fetch the server tool-label catalog from `data-tools-url`, if set. */
|
|
4072
|
+
async #fetchToolCatalog() {
|
|
4073
|
+
const url = this.getAttribute("data-tools-url");
|
|
4074
|
+
if (url === null) {
|
|
4075
|
+
return;
|
|
4076
|
+
}
|
|
4077
|
+
try {
|
|
4078
|
+
const response = await fetch(url, { headers: this.headers });
|
|
4079
|
+
this.#toolCatalog = parseToolCatalog(await response.json());
|
|
4080
|
+
} catch {
|
|
4081
|
+
}
|
|
4082
|
+
}
|
|
4013
4083
|
/**
|
|
4014
4084
|
* Replace the host-supplied (client) skill catalog. Merged after the embedded
|
|
4015
4085
|
* and fetched skills (so a client skill overrides a same-named server one).
|
|
@@ -4158,7 +4228,7 @@ var AgUiChat = class extends HTMLElement {
|
|
|
4158
4228
|
}
|
|
4159
4229
|
if (message.role === MESSAGE_ROLE.ASSISTANT) {
|
|
4160
4230
|
if (text2 !== "") {
|
|
4161
|
-
this
|
|
4231
|
+
this.appendMessage(MESSAGE_ROLE.ASSISTANT, text2).classList.add("message--restored");
|
|
4162
4232
|
}
|
|
4163
4233
|
const toolCalls = message.toolCalls;
|
|
4164
4234
|
if (toolCalls !== void 0) {
|
|
@@ -4355,7 +4425,7 @@ var AgUiChat = class extends HTMLElement {
|
|
|
4355
4425
|
const tool = this.#resolveTool(call.name);
|
|
4356
4426
|
if (tool === null) {
|
|
4357
4427
|
if (!this.#serverSettled.has(call.id)) {
|
|
4358
|
-
card.settle(TOOL_CALL_STATUS.DONE, "
|
|
4428
|
+
card.settle(TOOL_CALL_STATUS.DONE, "No result returned.");
|
|
4359
4429
|
}
|
|
4360
4430
|
return null;
|
|
4361
4431
|
}
|
|
@@ -4408,9 +4478,13 @@ var AgUiChat = class extends HTMLElement {
|
|
|
4408
4478
|
onTextDelta: (buffer) => {
|
|
4409
4479
|
this.#hidePending();
|
|
4410
4480
|
this.#streamInto(buffer);
|
|
4481
|
+
this.#streamDeltas += 1;
|
|
4411
4482
|
},
|
|
4412
4483
|
onTextEnd: (buffer) => {
|
|
4413
|
-
this.#
|
|
4484
|
+
const bubble = this.#streamInto(buffer);
|
|
4485
|
+
if (this.#streamDeltas <= 1) {
|
|
4486
|
+
this.#revealWords(bubble);
|
|
4487
|
+
}
|
|
4414
4488
|
this.#streamingBubble = null;
|
|
4415
4489
|
},
|
|
4416
4490
|
onToolCall: (call) => {
|
|
@@ -4473,6 +4547,7 @@ var AgUiChat = class extends HTMLElement {
|
|
|
4473
4547
|
#streamInto(buffer) {
|
|
4474
4548
|
if (this.#streamingBubble === null) {
|
|
4475
4549
|
this.#streamingBubble = this.appendMessage(MESSAGE_ROLE.ASSISTANT, "");
|
|
4550
|
+
this.#streamDeltas = 0;
|
|
4476
4551
|
}
|
|
4477
4552
|
this.#streamingBubble.innerHTML = renderMarkdown(buffer);
|
|
4478
4553
|
this.#messages.scrollTop = this.#messages.scrollHeight;
|
|
@@ -4489,13 +4564,9 @@ var AgUiChat = class extends HTMLElement {
|
|
|
4489
4564
|
if (existing !== void 0) {
|
|
4490
4565
|
return existing;
|
|
4491
4566
|
}
|
|
4492
|
-
const
|
|
4493
|
-
const
|
|
4494
|
-
|
|
4495
|
-
call.args,
|
|
4496
|
-
this.toolDisplay,
|
|
4497
|
-
typeof summary === "string" ? summary : void 0
|
|
4498
|
-
);
|
|
4567
|
+
const labelled = this.#resolveTool(call.name)?.parameters[X_SUMMARY_KEY];
|
|
4568
|
+
const summary = typeof labelled === "string" ? labelled : this.toolSummaries[call.name] ?? this.#toolCatalog[call.name];
|
|
4569
|
+
const card = new ToolCallCard(call.name, call.args, this.toolDisplay, summary);
|
|
4499
4570
|
this.#toolCards.set(call.id, card);
|
|
4500
4571
|
this.#messages.appendChild(card.element);
|
|
4501
4572
|
this.#messages.scrollTop = this.#messages.scrollHeight;
|
|
@@ -4667,7 +4738,7 @@ function setControlValue(el, value) {
|
|
|
4667
4738
|
}
|
|
4668
4739
|
|
|
4669
4740
|
// src/version.ts
|
|
4670
|
-
var VERSION = "0.
|
|
4741
|
+
var VERSION = "0.3.0";
|
|
4671
4742
|
export {
|
|
4672
4743
|
AgUiChat,
|
|
4673
4744
|
AgUiClient,
|
|
@@ -4697,6 +4768,7 @@ export {
|
|
|
4697
4768
|
highlightThenClick,
|
|
4698
4769
|
isDestructive,
|
|
4699
4770
|
isNavigates,
|
|
4771
|
+
parseToolCatalog,
|
|
4700
4772
|
prefersReducedMotion,
|
|
4701
4773
|
pressButton,
|
|
4702
4774
|
pressThenClick,
|