@artooi/ag-ui-web-component 0.2.1 → 0.2.2

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.
@@ -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;AAC1E,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,EA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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;CAmVlE"}
package/dist/index.js CHANGED
@@ -143,7 +143,7 @@ function createRouteTools(getRouteMap, getNavigate) {
143
143
  {
144
144
  name: "list_routes",
145
145
  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: [] },
146
+ parameters: { type: "object", properties: {}, required: [], [X_SUMMARY_KEY]: "List pages" },
147
147
  handler: () => getRouteMap().map((route) => ({ ...route, pathParams: pathParamNames(route.path) }))
148
148
  },
149
149
  {
@@ -156,7 +156,8 @@ function createRouteTools(getRouteMap, getNavigate) {
156
156
  params: { type: "object" }
157
157
  },
158
158
  required: ["route_id"],
159
- [X_NAVIGATES_KEY]: true
159
+ [X_NAVIGATES_KEY]: true,
160
+ [X_SUMMARY_KEY]: "Navigate"
160
161
  },
161
162
  handler: (args) => {
162
163
  const routeId = args["route_id"];
@@ -185,7 +186,12 @@ function createStateHookTools(hook) {
185
186
  {
186
187
  name: `read_${hook.name}`,
187
188
  description: `Read the "${hook.name}" state.`,
188
- parameters: { type: "object", properties: {}, required: [] },
189
+ parameters: {
190
+ type: "object",
191
+ properties: {},
192
+ required: [],
193
+ [X_SUMMARY_KEY]: `Read ${hook.name}`
194
+ },
189
195
  handler: () => hook.read()
190
196
  }
191
197
  ];
@@ -194,7 +200,11 @@ function createStateHookTools(hook) {
194
200
  tools.push({
195
201
  name: `set_${hook.name}`,
196
202
  description: `Update the "${hook.name}" state.`,
197
- parameters: { ...hook.schema ?? { type: "object" }, [X_DESTRUCTIVE_KEY]: true },
203
+ parameters: {
204
+ ...hook.schema ?? { type: "object" },
205
+ [X_DESTRUCTIVE_KEY]: true,
206
+ [X_SUMMARY_KEY]: `Update ${hook.name}`
207
+ },
198
208
  handler: (args) => write(args)
199
209
  });
200
210
  }
@@ -3145,7 +3155,10 @@ var STYLES = `
3145
3155
  }
3146
3156
 
3147
3157
  /* \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
- :host([data-text-animation="fade"]) .message--assistant {
3158
+ /* .message--restored (rehydrated history) is excluded: entrance animations are
3159
+ for freshly-arriving messages, not the whole transcript replaying on reload.
3160
+ Word mode is excluded implicitly \u2014 restored bubbles aren't wrapped. */
3161
+ :host([data-text-animation="fade"]) .message--assistant:not(.message--restored) {
3149
3162
  animation: ag-ui-msg-fade 0.25s ease both;
3150
3163
  }
3151
3164
 
@@ -3882,6 +3895,15 @@ var AgUiChat = class extends HTMLElement {
3882
3895
  * this from the current page; a missing placeholder blocks the send.
3883
3896
  */
3884
3897
  skillContext = () => ({});
3898
+ /**
3899
+ * Friendly display labels for tool-call cards, keyed by tool name (e.g.
3900
+ * `{ list_projects: "Search projects" }`). Used as a fallback when a tool has
3901
+ * no `x-summary` in its own schema — chiefly **server-side tools** (drf-mcp,
3902
+ * `@tool` registry), whose schema never reaches the browser (AG-UI streams
3903
+ * only the tool-call name). Client tools should prefer `x-summary` on their
3904
+ * schema; this map is the seam for everything else.
3905
+ */
3906
+ toolSummaries = {};
3885
3907
  #toolRegistry = new ClientToolRegistry();
3886
3908
  /** Tool-call cards awaiting execution, keyed by call id. */
3887
3909
  #toolCards = /* @__PURE__ */ new Map();
@@ -3901,6 +3923,10 @@ var AgUiChat = class extends HTMLElement {
3901
3923
  #skillHint;
3902
3924
  #client = null;
3903
3925
  #streamingBubble = null;
3926
+ // Text deltas applied to the current streaming bubble. >1 ⇒ the message
3927
+ // revealed progressively as it streamed, so the word reveal must not re-animate
3928
+ // it; ≤1 ⇒ it arrived at once and the word reveal is appropriate.
3929
+ #streamDeltas = 0;
3904
3930
  #pending = null;
3905
3931
  #threadId = "";
3906
3932
  #initialMessages = [];
@@ -3960,7 +3986,12 @@ var AgUiChat = class extends HTMLElement {
3960
3986
  {
3961
3987
  name: "read_page",
3962
3988
  description: "Read the current page's structure (fields, buttons, route). Call after acting to observe the result within the same turn.",
3963
- parameters: { type: "object", properties: {}, required: [] },
3989
+ parameters: {
3990
+ type: "object",
3991
+ properties: {},
3992
+ required: [],
3993
+ [X_SUMMARY_KEY]: "Read the page"
3994
+ },
3964
3995
  handler: () => getPageMap()
3965
3996
  }
3966
3997
  ];
@@ -4158,7 +4189,7 @@ var AgUiChat = class extends HTMLElement {
4158
4189
  }
4159
4190
  if (message.role === MESSAGE_ROLE.ASSISTANT) {
4160
4191
  if (text2 !== "") {
4161
- this.#revealWords(this.appendMessage(MESSAGE_ROLE.ASSISTANT, text2));
4192
+ this.appendMessage(MESSAGE_ROLE.ASSISTANT, text2).classList.add("message--restored");
4162
4193
  }
4163
4194
  const toolCalls = message.toolCalls;
4164
4195
  if (toolCalls !== void 0) {
@@ -4355,7 +4386,7 @@ var AgUiChat = class extends HTMLElement {
4355
4386
  const tool = this.#resolveTool(call.name);
4356
4387
  if (tool === null) {
4357
4388
  if (!this.#serverSettled.has(call.id)) {
4358
- card.settle(TOOL_CALL_STATUS.DONE, "Executed on the server.");
4389
+ card.settle(TOOL_CALL_STATUS.DONE, "No result returned.");
4359
4390
  }
4360
4391
  return null;
4361
4392
  }
@@ -4408,9 +4439,13 @@ var AgUiChat = class extends HTMLElement {
4408
4439
  onTextDelta: (buffer) => {
4409
4440
  this.#hidePending();
4410
4441
  this.#streamInto(buffer);
4442
+ this.#streamDeltas += 1;
4411
4443
  },
4412
4444
  onTextEnd: (buffer) => {
4413
- this.#revealWords(this.#streamInto(buffer));
4445
+ const bubble = this.#streamInto(buffer);
4446
+ if (this.#streamDeltas <= 1) {
4447
+ this.#revealWords(bubble);
4448
+ }
4414
4449
  this.#streamingBubble = null;
4415
4450
  },
4416
4451
  onToolCall: (call) => {
@@ -4473,6 +4508,7 @@ var AgUiChat = class extends HTMLElement {
4473
4508
  #streamInto(buffer) {
4474
4509
  if (this.#streamingBubble === null) {
4475
4510
  this.#streamingBubble = this.appendMessage(MESSAGE_ROLE.ASSISTANT, "");
4511
+ this.#streamDeltas = 0;
4476
4512
  }
4477
4513
  this.#streamingBubble.innerHTML = renderMarkdown(buffer);
4478
4514
  this.#messages.scrollTop = this.#messages.scrollHeight;
@@ -4489,13 +4525,9 @@ var AgUiChat = class extends HTMLElement {
4489
4525
  if (existing !== void 0) {
4490
4526
  return existing;
4491
4527
  }
4492
- const summary = this.#resolveTool(call.name)?.parameters[X_SUMMARY_KEY];
4493
- const card = new ToolCallCard(
4494
- call.name,
4495
- call.args,
4496
- this.toolDisplay,
4497
- typeof summary === "string" ? summary : void 0
4498
- );
4528
+ const labelled = this.#resolveTool(call.name)?.parameters[X_SUMMARY_KEY];
4529
+ const summary = typeof labelled === "string" ? labelled : this.toolSummaries[call.name];
4530
+ const card = new ToolCallCard(call.name, call.args, this.toolDisplay, summary);
4499
4531
  this.#toolCards.set(call.id, card);
4500
4532
  this.#messages.appendChild(card.element);
4501
4533
  this.#messages.scrollTop = this.#messages.scrollHeight;
@@ -4667,7 +4699,7 @@ function setControlValue(el, value) {
4667
4699
  }
4668
4700
 
4669
4701
  // src/version.ts
4670
- var VERSION = "0.2.1";
4702
+ var VERSION = "0.2.2";
4671
4703
  export {
4672
4704
  AgUiChat,
4673
4705
  AgUiClient,