@artooi/ag-ui-web-component 0.26.0 → 0.26.1
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 +51 -1
- package/README.md +24 -4
- package/dist/ag-ui-web-component.bundle.js +21 -21
- package/dist/ag-ui-web-component.bundle.js.map +3 -3
- package/dist/core/ag_ui_chat.d.ts.map +1 -1
- package/dist/index.js +36 -22
- package/dist/index.js.map +2 -2
- package/dist/tools/client_tool_registry.d.ts +10 -1
- package/dist/tools/client_tool_registry.d.ts.map +1 -1
- package/dist/ui/chart_block.d.ts.map +1 -1
- package/dist/ui/chart_spec_from.d.ts.map +1 -1
- package/dist/ui/chart_tool.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/ag_ui_chat.ts +34 -14
- package/src/tools/client_tool_registry.ts +11 -1
- package/src/ui/chart_block.ts +6 -1
- package/src/ui/chart_spec_from.ts +21 -2
- package/src/ui/chart_tool.ts +13 -5
- package/src/version.ts +1 -1
|
@@ -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,EAUL,YAAY,EAWb,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,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,EAAsB,IAAI,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAUL,YAAY,EAWb,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,KAAK,UAAU,EAAsB,MAAM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E;IACrE,eAAe,IAAI,IAAI,CAEtB;IAED;;;;;OAKG;IACH,WAAW,IAAI,IAAI,CAKlB;IAwJD;;;;;;;;OAQG;IACH,WAAW,IAAI,IAAI,CAQlB;IAED;;;;;;OAMG;IACH,eAAe,IAAI,IAAI,CAKtB;IAED,kDAAkD;IAClD,gBAAgB,IAAI,IAAI,CAEvB;IAED;;;;;OAKG;IACH,iBAAiB,IAAI,IAAI,CAMxB;IAED;;;OAGG;IACH,OAAO,IAAI,IAAI,CASd;IAoPD;;;;;;;;;OASG;IACH,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAkBhE;IA4fD;;;;;;;;;;;;;;OAcG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,GAAE,SAAS,aAAa,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB5F;IAED;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAM9B;IAmiBD;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,CAAC,MAAM,GAAE,SAAS,CAAC,MAAM,GAAG,UAAU,CAAC,EAAyB,GAAG,IAAI,CAgBlF;CA0FF"}
|
package/dist/index.js
CHANGED
|
@@ -1097,7 +1097,7 @@ function drawStacked(svg2, spec, min, max) {
|
|
|
1097
1097
|
const running = spec.labels.map(() => 0);
|
|
1098
1098
|
spec.series.forEach((series, s) => {
|
|
1099
1099
|
series.points.forEach((value, i) => {
|
|
1100
|
-
const from = running[i];
|
|
1100
|
+
const from = running[i] ?? 0;
|
|
1101
1101
|
const to = from + value;
|
|
1102
1102
|
running[i] = to;
|
|
1103
1103
|
const y2 = scaleY(to, min, max);
|
|
@@ -1241,6 +1241,7 @@ function renderChart(spec) {
|
|
|
1241
1241
|
// src/ui/chart_spec_from.ts
|
|
1242
1242
|
var KINDS = ["bar", "line", "pie", "scatter", "stacked"];
|
|
1243
1243
|
var MAX_POINTS = 2e4;
|
|
1244
|
+
var MAX_LABELS = 2e3;
|
|
1244
1245
|
var MAX_MAGNITUDE = 1e15;
|
|
1245
1246
|
function asKind(value) {
|
|
1246
1247
|
return KINDS.includes(value) ? value : "bar";
|
|
@@ -1262,9 +1263,14 @@ function asNumbers(value) {
|
|
|
1262
1263
|
return out;
|
|
1263
1264
|
}
|
|
1264
1265
|
function asStrings(value) {
|
|
1265
|
-
if (!Array.isArray(value)
|
|
1266
|
+
if (!Array.isArray(value)) {
|
|
1266
1267
|
return null;
|
|
1267
1268
|
}
|
|
1269
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
1270
|
+
if (typeof value[i] !== "string") {
|
|
1271
|
+
return null;
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1268
1274
|
return value;
|
|
1269
1275
|
}
|
|
1270
1276
|
function chartSpecFrom(value) {
|
|
@@ -1291,7 +1297,7 @@ function chartSpecFrom(value) {
|
|
|
1291
1297
|
if (series.length === 0) {
|
|
1292
1298
|
return null;
|
|
1293
1299
|
}
|
|
1294
|
-
if (series.length * labels.length > MAX_POINTS) {
|
|
1300
|
+
if (series.length * labels.length > MAX_POINTS || labels.length > MAX_LABELS) {
|
|
1295
1301
|
return null;
|
|
1296
1302
|
}
|
|
1297
1303
|
const kind = asKind(raw["kind"]);
|
|
@@ -1305,6 +1311,10 @@ function draw(args) {
|
|
|
1305
1311
|
const spec = chartSpecFrom(args);
|
|
1306
1312
|
return spec === null ? null : renderChart(spec);
|
|
1307
1313
|
}
|
|
1314
|
+
function drawable(args) {
|
|
1315
|
+
const spec = chartSpecFrom(args);
|
|
1316
|
+
return spec !== null && spec.labels.length > 0 && spec.series.length > 0;
|
|
1317
|
+
}
|
|
1308
1318
|
var REJECTED = "chart not rendered: expected labels (strings) and series, each with one finite number per label";
|
|
1309
1319
|
function createChartTool() {
|
|
1310
1320
|
return {
|
|
@@ -1334,11 +1344,13 @@ function createChartTool() {
|
|
|
1334
1344
|
// Says what happened and nothing else; the drawing is `render`'s job. Told
|
|
1335
1345
|
// plainly when the arguments are unusable, because the model can fix that
|
|
1336
1346
|
// and retry — a silent no-op would leave it believing the chart is on screen.
|
|
1337
|
-
// Answers on what
|
|
1338
|
-
// pass validation and still have nothing to show
|
|
1339
|
-
//
|
|
1340
|
-
// chart is
|
|
1341
|
-
|
|
1347
|
+
// Answers on what will actually be drawn, not on what validated: a spec can
|
|
1348
|
+
// pass validation and still have nothing to show, and reporting success
|
|
1349
|
+
// then would leave the model believing a chart is on screen. Asks the
|
|
1350
|
+
// question without building the chart, because `render` is about to build
|
|
1351
|
+
// the same one a moment later and drawing it twice is pure waste on a spec
|
|
1352
|
+
// large enough to matter.
|
|
1353
|
+
handler: (args) => drawable(args) ? "chart rendered" : REJECTED,
|
|
1342
1354
|
render: draw
|
|
1343
1355
|
};
|
|
1344
1356
|
}
|
|
@@ -10067,9 +10079,9 @@ var AgUiChat = class extends HTMLElement {
|
|
|
10067
10079
|
continue;
|
|
10068
10080
|
}
|
|
10069
10081
|
this.#cardElements.set(restored.id, this.#cardFor(restored).element);
|
|
10070
|
-
const
|
|
10071
|
-
if (
|
|
10072
|
-
this.#renderToolOutput(
|
|
10082
|
+
const render = this.#resolveTool(restored.name)?.render;
|
|
10083
|
+
if (render !== void 0) {
|
|
10084
|
+
this.#renderToolOutput(render, restored);
|
|
10073
10085
|
}
|
|
10074
10086
|
}
|
|
10075
10087
|
return;
|
|
@@ -10693,7 +10705,9 @@ var AgUiChat = class extends HTMLElement {
|
|
|
10693
10705
|
}
|
|
10694
10706
|
try {
|
|
10695
10707
|
const result = await tool.handler(call.args, call.id);
|
|
10696
|
-
|
|
10708
|
+
if (tool.render !== void 0) {
|
|
10709
|
+
this.#renderToolOutput(tool.render, call);
|
|
10710
|
+
}
|
|
10697
10711
|
if (navigates) {
|
|
10698
10712
|
card.settle(TOOL_CALL_STATUS.DONE, this.#strings.navigating);
|
|
10699
10713
|
return { content: "", halt: true };
|
|
@@ -11017,12 +11031,16 @@ var AgUiChat = class extends HTMLElement {
|
|
|
11017
11031
|
* arrives is not something to switch on for everybody.
|
|
11018
11032
|
*/
|
|
11019
11033
|
enableCharts(routes = ["tool", "activity"]) {
|
|
11034
|
+
const first = !this.#chartActivity && !this.#toolRegistry.has(CHART_TOOL_NAME);
|
|
11020
11035
|
if (routes.includes("activity")) {
|
|
11021
11036
|
this.#chartActivity = true;
|
|
11022
11037
|
}
|
|
11023
11038
|
if (routes.includes("tool")) {
|
|
11024
11039
|
this.registerTool(createChartTool());
|
|
11025
11040
|
}
|
|
11041
|
+
if (first && this.isConnected) {
|
|
11042
|
+
this.reload();
|
|
11043
|
+
}
|
|
11026
11044
|
}
|
|
11027
11045
|
/**
|
|
11028
11046
|
* Place a tool's rendered node against its own card.
|
|
@@ -11034,13 +11052,10 @@ var AgUiChat = class extends HTMLElement {
|
|
|
11034
11052
|
* created inline, in the right place, so anchoring makes *when* the handler
|
|
11035
11053
|
* runs stop mattering.
|
|
11036
11054
|
*/
|
|
11037
|
-
#renderToolOutput(
|
|
11038
|
-
if (tool.render === void 0) {
|
|
11039
|
-
return;
|
|
11040
|
-
}
|
|
11055
|
+
#renderToolOutput(render, call) {
|
|
11041
11056
|
let node;
|
|
11042
11057
|
try {
|
|
11043
|
-
node =
|
|
11058
|
+
node = render(call.args);
|
|
11044
11059
|
} catch (error) {
|
|
11045
11060
|
console.warn(`ag-ui-chat: render failed for tool ${call.name}`, error);
|
|
11046
11061
|
return;
|
|
@@ -11054,11 +11069,10 @@ var AgUiChat = class extends HTMLElement {
|
|
|
11054
11069
|
/** Draw, or redraw in place, the chart for one activity message. */
|
|
11055
11070
|
#drawActivityChart(messageId, content) {
|
|
11056
11071
|
const spec = chartSpecFrom(content);
|
|
11057
|
-
|
|
11058
|
-
return;
|
|
11059
|
-
}
|
|
11060
|
-
const block = renderChart(spec);
|
|
11072
|
+
const block = spec === null ? null : renderChart(spec);
|
|
11061
11073
|
if (block === null) {
|
|
11074
|
+
this.#activityBlocks.get(messageId)?.remove();
|
|
11075
|
+
this.#activityBlocks.delete(messageId);
|
|
11062
11076
|
return;
|
|
11063
11077
|
}
|
|
11064
11078
|
const existing = this.#activityBlocks.get(messageId);
|
|
@@ -11155,7 +11169,7 @@ function setControlValue(el2, value) {
|
|
|
11155
11169
|
}
|
|
11156
11170
|
|
|
11157
11171
|
// src/version.ts
|
|
11158
|
-
var VERSION = "0.26.
|
|
11172
|
+
var VERSION = "0.26.1";
|
|
11159
11173
|
export {
|
|
11160
11174
|
ATTACHMENT_EVENT,
|
|
11161
11175
|
AgUiChat,
|