@artooi/ag-ui-web-component 0.18.0 → 0.19.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.
@@ -223,7 +223,11 @@ export declare class AgUiChat extends HTMLElement {
223
223
  set endpoint(value: string);
224
224
  /**
225
225
  * How much detail tool-call cards show, from the `data-tool-display`
226
- * attribute (`minimal` / `compact` / `full`). Defaults to `full`.
226
+ * attribute (`minimal` / `inline` / `compact` / `full`). Defaults to `full`.
227
+ *
228
+ * Applied by the shadow CSS from the attribute itself, so changing it
229
+ * restyles every card already in the transcript rather than only the ones
230
+ * built afterwards.
227
231
  */
228
232
  get toolDisplay(): ToolDisplayMode;
229
233
  set toolDisplay(value: ToolDisplayMode);
@@ -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,EAKL,YAAY,EASb,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,KAAK,UAAU,EAAsB,MAAM,kCAAkC,CAAC;AAGvF,OAAO,EAAyB,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAC9F,OAAO,EAAwB,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAE9E,OAAO,EAAoB,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,wBAAwB,CAAC;AAOhC,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,wBAAwB,CAAC;AAQhC,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAA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IG;IACH,YAAY,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAerC;IAED,qEAAqE;IACrE,eAAe,IAAI,IAAI,CAEtB;IAED;;;;;OAKG;IACH,WAAW,IAAI,IAAI,CAKlB;IA0BD;;;OAGG;IACH,OAAO,IAAI,IAAI,CAQd;IA4ND;;;;;;;;;;OAUG;IACH,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAkBhE;IAwVD;;;;;;;;;;;;;;;;;OAiBG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,GAAE,SAAS,aAAa,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB5F;IAED;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAM9B;CA4dF"}
package/dist/index.js CHANGED
@@ -485,6 +485,9 @@ var DEFAULT_UI_STRINGS = {
485
485
  toolDone: "\u2713 done",
486
486
  toolError: "\u26A0 error",
487
487
  toolDeclined: "\u2298 declined",
488
+ decisionApproved: "approved by you",
489
+ decisionDeclined: "declined by you",
490
+ argumentsLabel: "Arguments",
488
491
  resultLabel: "Result",
489
492
  errorLabel: "Error",
490
493
  declinedLabel: "Declined",
@@ -1106,6 +1109,7 @@ function requestConfirmation(host, request, options = {}) {
1106
1109
  args.className = "confirm-args";
1107
1110
  args.setAttribute("part", "confirm-args");
1108
1111
  args.textContent = JSON.stringify(request.args, null, 2);
1112
+ args.hidden = Object.keys(request.args).length === 0;
1109
1113
  const actions = document.createElement("div");
1110
1114
  actions.className = "confirm-actions";
1111
1115
  actions.setAttribute("part", "confirm-actions");
@@ -1117,9 +1121,7 @@ function requestConfirmation(host, request, options = {}) {
1117
1121
  return;
1118
1122
  }
1119
1123
  settled = true;
1120
- cancel.disabled = true;
1121
- confirm2.disabled = true;
1122
- card.setAttribute("data-resolved", accepted ? "confirmed" : "declined");
1124
+ card.remove();
1123
1125
  resolve(accepted);
1124
1126
  };
1125
1127
  cancel.addEventListener("click", () => close(false));
@@ -5092,10 +5094,9 @@ var STYLES = `
5092
5094
  }
5093
5095
  }
5094
5096
 
5095
- /* Inline display mode: the lightest card \u2014 drop the box chrome so the
5096
- status row reads as one line of the answer; the result toggle still expands
5097
- below it. */
5098
- .tool-call[data-display="inline"] {
5097
+ /* Inline display mode: the lightest card. Drop the box chrome so the status row
5098
+ reads as one line of the answer; the result toggle still expands below it. */
5099
+ :host([data-tool-display="inline"]) .tool-call {
5099
5100
  max-width: 100%;
5100
5101
  background: transparent;
5101
5102
  border: none;
@@ -5125,6 +5126,37 @@ var STYLES = `
5125
5126
  color: var(--ag-ui-muted);
5126
5127
  }
5127
5128
 
5129
+ .tool-call-body {
5130
+ display: flex;
5131
+ flex-direction: column;
5132
+ gap: 6px;
5133
+ }
5134
+
5135
+ .tool-call-section {
5136
+ display: flex;
5137
+ flex-direction: column;
5138
+ gap: 3px;
5139
+ }
5140
+
5141
+ /* The heading that tells the two payloads apart. Without it the arguments and
5142
+ the result were one run of text and a reader had to guess the boundary. */
5143
+ .tool-call-section-label {
5144
+ font-size: 10px;
5145
+ font-weight: 700;
5146
+ letter-spacing: 0.06em;
5147
+ text-transform: uppercase;
5148
+ color: var(--ag-ui-muted);
5149
+ }
5150
+
5151
+ /* The record of a human decision on a gated call. An approved call used to
5152
+ look exactly like one that was never gated. */
5153
+ .tool-call-decision {
5154
+ flex: none;
5155
+ font-size: 11px;
5156
+ font-style: italic;
5157
+ color: var(--ag-ui-muted);
5158
+ }
5159
+
5128
5160
  .tool-call-args,
5129
5161
  .tool-call-result {
5130
5162
  margin: 0;
@@ -5139,6 +5171,43 @@ var STYLES = `
5139
5171
  color: var(--ag-ui-fg);
5140
5172
  }
5141
5173
 
5174
+ /* Display modes are pure visibility over one DOM shape, selected from the host
5175
+ attribute rather than a value stamped on the card when it was built. That is
5176
+ what lets a host flip data-tool-display and have every card already on screen
5177
+ re-read it, the way data-answer-well behaves. Baking the structure per mode
5178
+ meant the setting only reached cards created afterwards.
5179
+
5180
+ Default (no attribute) is the full mode: arguments always visible, result
5181
+ behind the toggle. */
5182
+ .tool-call[data-expanded="false"] .tool-call-section--result {
5183
+ display: none;
5184
+ }
5185
+
5186
+ /* Compact: one toggle over both regions, so a settled card is a single line
5187
+ until asked. */
5188
+ :host([data-tool-display="compact"]) .tool-call[data-expanded="false"] .tool-call-section {
5189
+ display: none;
5190
+ }
5191
+
5192
+ /* Inline: the result only; the call's arguments are noise at this density. */
5193
+ :host([data-tool-display="inline"]) .tool-call .tool-call-section--args {
5194
+ display: none;
5195
+ }
5196
+
5197
+ /* Minimal: the status row and nothing else, so there is no toggle to press. */
5198
+ :host([data-tool-display="minimal"]) .tool-call .tool-call-toggle,
5199
+ :host([data-tool-display="minimal"]) .tool-call .tool-call-body {
5200
+ display: none;
5201
+ }
5202
+
5203
+ /* A pending card has no result yet, and in the modes where the arguments are
5204
+ hidden too there is nothing behind the toggle. Hide the control rather than
5205
+ offer one that expands onto nothing. */
5206
+ .tool-call[data-status="pending"] .tool-call-toggle,
5207
+ :host([data-tool-display="inline"]) .tool-call[data-status="pending"] .tool-call-toggle {
5208
+ display: none;
5209
+ }
5210
+
5142
5211
  .tool-call-toggle {
5143
5212
  align-self: flex-start;
5144
5213
  border: none;
@@ -6231,24 +6300,32 @@ function resultLabels(strings) {
6231
6300
  [TOOL_CALL_STATUS.DECLINED]: strings.declinedLabel
6232
6301
  };
6233
6302
  }
6303
+ function formatPayload(text2) {
6304
+ try {
6305
+ return JSON.stringify(JSON.parse(text2), null, 2);
6306
+ } catch {
6307
+ return text2;
6308
+ }
6309
+ }
6234
6310
  var ToolCallCard = class {
6235
6311
  /** The card's root element; append this into the message list. */
6236
6312
  element;
6237
6313
  #status;
6238
- #mode;
6239
- #args;
6314
+ #decision;
6315
+ #toggle;
6316
+ #resultSection;
6317
+ #resultLabel;
6318
+ #resultBody;
6240
6319
  #strings;
6241
6320
  #settled = false;
6242
- constructor(name, args, mode = TOOL_DISPLAY.FULL, summary, strings = DEFAULT_UI_STRINGS) {
6243
- this.#mode = mode;
6244
- this.#args = args;
6321
+ constructor(name, args, summary, strings = DEFAULT_UI_STRINGS) {
6245
6322
  this.#strings = strings;
6246
6323
  this.element = document.createElement("div");
6247
6324
  this.element.className = "tool-call";
6248
6325
  this.element.setAttribute("part", "tool-card");
6249
6326
  this.element.setAttribute("data-tool-name", name);
6250
6327
  this.element.setAttribute("data-status", TOOL_CALL_STATUS.PENDING);
6251
- this.element.setAttribute("data-display", mode);
6328
+ this.element.setAttribute("data-expanded", "false");
6252
6329
  const head = document.createElement("div");
6253
6330
  head.className = "tool-call-head";
6254
6331
  head.setAttribute("part", "tool-card-head");
@@ -6264,24 +6341,52 @@ var ToolCallCard = class {
6264
6341
  this.#status.className = "tool-call-status";
6265
6342
  this.#status.setAttribute("part", "tool-card-status");
6266
6343
  this.#status.textContent = statusLabels(strings)[TOOL_CALL_STATUS.PENDING];
6267
- head.append(icon, label, this.#status);
6268
- this.element.append(head);
6269
- if (mode === TOOL_DISPLAY.FULL) {
6270
- const argsEl = document.createElement("pre");
6271
- argsEl.className = "tool-call-args";
6272
- argsEl.setAttribute("part", "tool-card-args");
6273
- argsEl.textContent = JSON.stringify(args, null, 2);
6274
- this.element.append(argsEl);
6275
- }
6344
+ this.#decision = document.createElement("span");
6345
+ this.#decision.className = "tool-call-decision";
6346
+ this.#decision.setAttribute("part", "tool-card-decision");
6347
+ this.#decision.hidden = true;
6348
+ head.append(icon, label, this.#status, this.#decision);
6349
+ const argsSection = this.#section("args", strings.argumentsLabel);
6350
+ argsSection.body.textContent = JSON.stringify(args, null, 2);
6351
+ argsSection.root.hidden = Object.keys(args).length === 0;
6352
+ const resultSection = this.#section("result", strings.resultLabel);
6353
+ this.#resultSection = resultSection.root;
6354
+ this.#resultLabel = resultSection.label;
6355
+ this.#resultBody = resultSection.body;
6356
+ resultSection.root.hidden = true;
6357
+ this.#toggle = document.createElement("button");
6358
+ this.#toggle.type = "button";
6359
+ this.#toggle.className = "tool-call-toggle";
6360
+ this.#toggle.setAttribute("part", "tool-card-toggle");
6361
+ this.#toggle.setAttribute("aria-expanded", "false");
6362
+ this.#toggle.textContent = strings.details;
6363
+ this.#toggle.addEventListener("click", () => this.#setExpanded(!this.#expanded()));
6364
+ const body = document.createElement("div");
6365
+ body.className = "tool-call-body";
6366
+ body.setAttribute("part", "tool-card-body");
6367
+ body.append(argsSection.root, resultSection.root);
6368
+ this.element.append(head, this.#toggle, body);
6369
+ }
6370
+ /**
6371
+ * Record that a human approved or declined this call, as a line in the card.
6372
+ *
6373
+ * Approval used to leave no trace at all: a declined call became a tool
6374
+ * result saying so, while an approved one simply ran, making the transcript
6375
+ * of a gated call byte-identical to one that was never gated. The prompt is
6376
+ * gone once answered, so this is where the decision lives.
6377
+ */
6378
+ recordDecision(kind) {
6379
+ this.element.setAttribute("data-decision", kind);
6380
+ this.#decision.textContent = kind === "approved" ? this.#strings.decisionApproved : this.#strings.decisionDeclined;
6381
+ this.#decision.hidden = false;
6276
6382
  }
6277
6383
  /** Whether {@link settle} has already run (so a terminal sweep can skip it). */
6278
6384
  get settled() {
6279
6385
  return this.#settled;
6280
6386
  }
6281
6387
  /**
6282
- * Flip the status pill to ``status`` and, unless in `minimal` mode, append a
6283
- * collapsed body behind a click-to-expand toggle: the result alone (`full` /
6284
- * `inline`), or the args + result together (`compact`).
6388
+ * Flip the status pill to `status` and fill in the result region, whose
6389
+ * heading names the outcome (result / error / declined).
6285
6390
  */
6286
6391
  settle(status, text2) {
6287
6392
  if (this.#settled) {
@@ -6290,33 +6395,31 @@ var ToolCallCard = class {
6290
6395
  this.#settled = true;
6291
6396
  this.element.setAttribute("data-status", status);
6292
6397
  this.#status.textContent = statusLabels(this.#strings)[status];
6293
- if (this.#mode === TOOL_DISPLAY.MINIMAL) {
6294
- return;
6295
- }
6296
- const toggle = document.createElement("button");
6297
- toggle.type = "button";
6298
- toggle.className = "tool-call-toggle";
6299
- toggle.setAttribute("part", "tool-card-toggle");
6300
- toggle.setAttribute("aria-expanded", "false");
6301
- const output = document.createElement("pre");
6302
- output.className = "tool-call-result";
6303
- output.setAttribute("part", "tool-card-result");
6304
- output.hidden = true;
6305
- if (this.#mode === TOOL_DISPLAY.COMPACT) {
6306
- toggle.textContent = this.#strings.details;
6307
- output.textContent = `args: ${JSON.stringify(this.#args)}
6308
-
6309
- ${text2}`;
6310
- } else {
6311
- toggle.textContent = resultLabels(this.#strings)[status];
6312
- output.textContent = text2;
6313
- }
6314
- toggle.addEventListener("click", () => {
6315
- const expand = output.hidden;
6316
- output.hidden = !expand;
6317
- toggle.setAttribute("aria-expanded", String(expand));
6318
- });
6319
- this.element.append(toggle, output);
6398
+ this.#resultLabel.textContent = resultLabels(this.#strings)[status];
6399
+ this.#resultBody.textContent = formatPayload(text2);
6400
+ this.#resultSection.hidden = false;
6401
+ }
6402
+ /** Build one labelled region of the body: a heading plus a payload block. */
6403
+ #section(kind, labelText) {
6404
+ const root = document.createElement("div");
6405
+ root.className = `tool-call-section tool-call-section--${kind}`;
6406
+ root.setAttribute("part", `tool-card-section tool-card-${kind}-section`);
6407
+ const label = document.createElement("span");
6408
+ label.className = "tool-call-section-label";
6409
+ label.setAttribute("part", `tool-card-section-label tool-card-${kind}-label`);
6410
+ label.textContent = labelText;
6411
+ const body = document.createElement("pre");
6412
+ body.className = `tool-call-${kind}`;
6413
+ body.setAttribute("part", `tool-card-${kind}`);
6414
+ root.append(label, body);
6415
+ return { root, label, body };
6416
+ }
6417
+ #expanded() {
6418
+ return this.element.getAttribute("data-expanded") === "true";
6419
+ }
6420
+ #setExpanded(expand) {
6421
+ this.element.setAttribute("data-expanded", String(expand));
6422
+ this.#toggle.setAttribute("aria-expanded", String(expand));
6320
6423
  }
6321
6424
  };
6322
6425
 
@@ -7731,7 +7834,11 @@ var AgUiChat = class extends HTMLElement {
7731
7834
  }
7732
7835
  /**
7733
7836
  * How much detail tool-call cards show, from the `data-tool-display`
7734
- * attribute (`minimal` / `compact` / `full`). Defaults to `full`.
7837
+ * attribute (`minimal` / `inline` / `compact` / `full`). Defaults to `full`.
7838
+ *
7839
+ * Applied by the shadow CSS from the attribute itself, so changing it
7840
+ * restyles every card already in the transcript rather than only the ones
7841
+ * built afterwards.
7735
7842
  */
7736
7843
  get toolDisplay() {
7737
7844
  const attr = this.getAttribute("data-tool-display");
@@ -8478,7 +8585,17 @@ Use the read_attachment tool with an id to read a file's contents.`
8478
8585
  this.#rail.addEventListener("click", () => this.setCollapsed(false));
8479
8586
  this.#root.append(style, this.#chat, this.#rail);
8480
8587
  }
8481
- /** Build a header control button (icon glyph + localized title/aria). */
8588
+ /**
8589
+ * Build a header control button: a named slot a host can project markup into,
8590
+ * with the built-in glyph as the slot's fallback.
8591
+ *
8592
+ * The glyph used to be the button's own `textContent`, which left a host able
8593
+ * to restyle the control through its `part` but unable to replace it — a CSS
8594
+ * `content` override could swap one character for another, and nothing could
8595
+ * supply a brand `<img>` or `<svg>`. This is the same slot-with-fallback
8596
+ * idiom the header icon already uses, so existing embeds render exactly as
8597
+ * before.
8598
+ */
8482
8599
  #headerButton(modifier, label, glyph) {
8483
8600
  const button2 = document.createElement("button");
8484
8601
  button2.type = "button";
@@ -8486,7 +8603,10 @@ Use the read_attachment tool with an id to read a file's contents.`
8486
8603
  button2.setAttribute("part", `header-button ${modifier}-button`);
8487
8604
  button2.title = label;
8488
8605
  button2.setAttribute("aria-label", label);
8489
- button2.textContent = glyph;
8606
+ const slot = document.createElement("slot");
8607
+ slot.name = `icon-${modifier}`;
8608
+ slot.append(document.createTextNode(glyph));
8609
+ button2.append(slot);
8490
8610
  return button2;
8491
8611
  }
8492
8612
  /**
@@ -8726,7 +8846,7 @@ Use the read_attachment tool with an id to read a file's contents.`
8726
8846
  request.message = confirmText;
8727
8847
  }
8728
8848
  this.#confirmAbort = new AbortController();
8729
- const decision = requestConfirmation(this.#messages, request, {
8849
+ const decision = requestConfirmation(this.#ensureGroup(), request, {
8730
8850
  signal: this.#confirmAbort.signal,
8731
8851
  strings: this.#strings
8732
8852
  });
@@ -8734,6 +8854,7 @@ Use the read_attachment tool with an id to read a file's contents.`
8734
8854
  this.#messages.scrollTop = this.#messages.scrollHeight;
8735
8855
  const accepted = await decision;
8736
8856
  this.#confirmAbort = null;
8857
+ card.recordDecision(accepted ? "approved" : "declined");
8737
8858
  if (!accepted) {
8738
8859
  const message = this.#strings.declinedAction;
8739
8860
  card.settle(TOOL_CALL_STATUS.DECLINED, message);
@@ -8999,7 +9120,7 @@ Use the read_attachment tool with an id to read a file's contents.`
8999
9120
  }
9000
9121
  const labelled = this.#resolveTool(call.name)?.parameters[X_SUMMARY_KEY];
9001
9122
  const summary = typeof labelled === "string" ? labelled : this.toolSummaries[call.name] ?? this.#toolCatalog[call.name] ?? prettifyToolName(call.name);
9002
- const card = new ToolCallCard(call.name, call.args, this.toolDisplay, summary, this.#strings);
9123
+ const card = new ToolCallCard(call.name, call.args, summary, this.#strings);
9003
9124
  this.#toolCards.set(call.id, card);
9004
9125
  this.#ensureGroup().appendChild(card.element);
9005
9126
  this.#updateEmptyState();
@@ -9059,7 +9180,7 @@ function setControlValue(el, value) {
9059
9180
  }
9060
9181
 
9061
9182
  // src/version.ts
9062
- var VERSION = "0.18.0";
9183
+ var VERSION = "0.19.0";
9063
9184
  export {
9064
9185
  ATTACHMENT_EVENT,
9065
9186
  AgUiChat,