@tylertech/forge-ai 0.13.12 → 0.13.13

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.
@@ -5826,6 +5826,56 @@
5826
5826
  "kind": "javascript-module",
5827
5827
  "path": "src/lib/ai-chatbot/utils.ts",
5828
5828
  "declarations": [
5829
+ {
5830
+ "kind": "function",
5831
+ "name": "shouldShowToolRenderer",
5832
+ "return": {
5833
+ "type": {
5834
+ "text": "boolean"
5835
+ }
5836
+ },
5837
+ "parameters": [
5838
+ {
5839
+ "name": "toolCall",
5840
+ "type": {
5841
+ "text": "ToolCall"
5842
+ }
5843
+ },
5844
+ {
5845
+ "name": "toolDefinition",
5846
+ "optional": true,
5847
+ "type": {
5848
+ "text": "ToolDefinition"
5849
+ }
5850
+ }
5851
+ ],
5852
+ "description": "Whether a tool call's renderer should currently be shown: once the call is complete,\nor immediately (while still parsing/executing) if the tool opted into `renderOnStart`."
5853
+ },
5854
+ {
5855
+ "kind": "function",
5856
+ "name": "isToolCallSettled",
5857
+ "return": {
5858
+ "type": {
5859
+ "text": "boolean"
5860
+ }
5861
+ },
5862
+ "parameters": [
5863
+ {
5864
+ "name": "toolCall",
5865
+ "type": {
5866
+ "text": "ToolCall"
5867
+ }
5868
+ },
5869
+ {
5870
+ "name": "toolDefinition",
5871
+ "optional": true,
5872
+ "type": {
5873
+ "text": "ToolDefinition"
5874
+ }
5875
+ }
5876
+ ],
5877
+ "description": "Whether a tool call should be treated as settled for activity indicators (thinking\nindicator, tool-call summary spinner): either genuinely finished, or already showing\nits own renderer to the user, which makes a redundant \"running\" spinner misleading."
5878
+ },
5829
5879
  {
5830
5880
  "kind": "function",
5831
5881
  "name": "generateId",
@@ -5973,6 +6023,22 @@
5973
6023
  "module": "../utils/markdown.js"
5974
6024
  }
5975
6025
  },
6026
+ {
6027
+ "kind": "js",
6028
+ "name": "shouldShowToolRenderer",
6029
+ "declaration": {
6030
+ "name": "shouldShowToolRenderer",
6031
+ "module": "src/lib/ai-chatbot/utils.ts"
6032
+ }
6033
+ },
6034
+ {
6035
+ "kind": "js",
6036
+ "name": "isToolCallSettled",
6037
+ "declaration": {
6038
+ "name": "isToolCallSettled",
6039
+ "module": "src/lib/ai-chatbot/utils.ts"
6040
+ }
6041
+ },
5976
6042
  {
5977
6043
  "kind": "js",
5978
6044
  "name": "generateId",
@@ -15085,7 +15151,7 @@
15085
15151
  },
15086
15152
  "AiChatbotToolCallComponent": {
15087
15153
  "path": "src/lib/ai-chatbot/ai-chatbot-tool-call.ts",
15088
- "lineNumber": 19
15154
+ "lineNumber": 20
15089
15155
  },
15090
15156
  "ForgeAiChatbotMessageEventData": {
15091
15157
  "path": "src/lib/ai-chatbot/ai-chatbot.ts",
@@ -15705,7 +15771,7 @@
15705
15771
  },
15706
15772
  "AiToolCallIndicatorComponent": {
15707
15773
  "path": "src/lib/ai-tool-call-indicator/ai-tool-call-indicator.ts",
15708
- "lineNumber": 31
15774
+ "lineNumber": 32
15709
15775
  },
15710
15776
  "ForgeAiUserMessageCopyEventData": {
15711
15777
  "path": "src/lib/ai-user-message/ai-user-message.ts",
@@ -83,7 +83,7 @@ renderTextChunk_fn = function(child) {
83
83
  };
84
84
  renderToolCall_fn = function(toolCall) {
85
85
  const toolDefinition = this.tools?.get(toolCall.name);
86
- if (!toolDefinition?.renderer || toolCall.status !== "complete") {
86
+ if (!toolDefinition?.renderer) {
87
87
  return nothing;
88
88
  }
89
89
  return html`<forge-ai-chatbot-tool-call
@@ -166,14 +166,12 @@ thinkingIndicator_get = function() {
166
166
  if (!this.showThinking) {
167
167
  return nothing;
168
168
  }
169
+ const lastChild = this.response.children[this.response.children.length - 1];
169
170
  const isThinking = this.response.status === "streaming" && this.response.isThinking === true;
170
- if (!isThinking) {
171
- const lastChild = this.response.children[this.response.children.length - 1];
172
- if (lastChild?.type === "text" && lastChild.status === "streaming") {
173
- const content = typeof lastChild.content === "string" ? lastChild.content : "";
174
- if (content.trim().length > 0) {
175
- return nothing;
176
- }
171
+ if (!isThinking && lastChild?.type === "text" && lastChild.status === "streaming") {
172
+ const content = typeof lastChild.content === "string" ? lastChild.content : "";
173
+ if (content.trim().length > 0) {
174
+ return nothing;
177
175
  }
178
176
  }
179
177
  const hasActiveToolCall = this.response.children.some((child) => {
@@ -1,6 +1,7 @@
1
1
  import { unsafeCSS, LitElement, nothing, html } from "lit";
2
2
  import { property, customElement } from "lit/decorators.js";
3
3
  import { createRef, ref } from "lit/directives/ref.js";
4
+ import { shouldShowToolRenderer } from "./utils.mjs";
4
5
  import styles from "./ai-chatbot-tool-call.scss.mjs";
5
6
  var __defProp = Object.defineProperty;
6
7
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -20,7 +21,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
20
21
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
21
22
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
22
23
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
23
- var _customRendererRef, _renderedElement, _AiChatbotToolCallComponent_instances, shouldRenderCustom_get, dispatchScrollRequest_fn, customRenderer_get;
24
+ var _customRendererRef, _renderedElement, _AiChatbotToolCallComponent_instances, shouldRenderCustom_get, dispatchScrollRequest_fn, customRenderer_get, replaceRenderedElement_fn;
24
25
  const AiChatbotToolCallComponentTagName = "forge-ai-chatbot-tool-call";
25
26
  let AiChatbotToolCallComponent = class extends LitElement {
26
27
  constructor() {
@@ -31,25 +32,24 @@ let AiChatbotToolCallComponent = class extends LitElement {
31
32
  }
32
33
  updated(changedProperties) {
33
34
  super.updated(changedProperties);
34
- if (changedProperties.has("toolCall") || changedProperties.has("toolDefinition")) {
35
- const renderer = this.toolDefinition?.renderer;
36
- const container = __privateGet(this, _customRendererRef).value;
37
- if (container && __privateGet(this, _AiChatbotToolCallComponent_instances, shouldRenderCustom_get)) {
38
- if (__privateGet(this, _renderedElement) && container.contains(__privateGet(this, _renderedElement))) {
39
- container.removeChild(__privateGet(this, _renderedElement));
40
- }
41
- if (renderer?.elementTag) {
42
- const element = document.createElement(renderer.elementTag);
43
- element.toolCall = this.toolCall;
44
- __privateSet(this, _renderedElement, element);
45
- container.appendChild(element);
46
- __privateMethod(this, _AiChatbotToolCallComponent_instances, dispatchScrollRequest_fn).call(this);
47
- } else if (renderer?.render) {
48
- __privateSet(this, _renderedElement, renderer.render(this.toolCall));
49
- container.appendChild(__privateGet(this, _renderedElement));
50
- __privateMethod(this, _AiChatbotToolCallComponent_instances, dispatchScrollRequest_fn).call(this);
51
- }
35
+ if (!changedProperties.has("toolCall") && !changedProperties.has("toolDefinition")) {
36
+ return;
37
+ }
38
+ const container = __privateGet(this, _customRendererRef).value;
39
+ if (!container || !__privateGet(this, _AiChatbotToolCallComponent_instances, shouldRenderCustom_get)) {
40
+ return;
41
+ }
42
+ const renderer = this.toolDefinition?.renderer;
43
+ if (renderer?.elementTag) {
44
+ if (__privateGet(this, _renderedElement) instanceof HTMLElement && __privateGet(this, _renderedElement).tagName.toLowerCase() === renderer.elementTag) {
45
+ __privateGet(this, _renderedElement).toolCall = this.toolCall;
46
+ return;
52
47
  }
48
+ const element = document.createElement(renderer.elementTag);
49
+ element.toolCall = this.toolCall;
50
+ __privateMethod(this, _AiChatbotToolCallComponent_instances, replaceRenderedElement_fn).call(this, container, element);
51
+ } else if (renderer?.render) {
52
+ __privateMethod(this, _AiChatbotToolCallComponent_instances, replaceRenderedElement_fn).call(this, container, renderer.render(this.toolCall));
53
53
  }
54
54
  }
55
55
  render() {
@@ -60,14 +60,7 @@ _customRendererRef = /* @__PURE__ */ new WeakMap();
60
60
  _renderedElement = /* @__PURE__ */ new WeakMap();
61
61
  _AiChatbotToolCallComponent_instances = /* @__PURE__ */ new WeakSet();
62
62
  shouldRenderCustom_get = function() {
63
- const status = this.toolCall?.status;
64
- if (status === "complete") {
65
- return true;
66
- }
67
- if (this.toolDefinition?.renderOnStart && (status === "parsing" || status === "executing")) {
68
- return true;
69
- }
70
- return false;
63
+ return shouldShowToolRenderer(this.toolCall, this.toolDefinition);
71
64
  };
72
65
  dispatchScrollRequest_fn = function() {
73
66
  this.dispatchEvent(
@@ -87,6 +80,14 @@ customRenderer_get = function() {
87
80
  }
88
81
  return nothing;
89
82
  };
83
+ replaceRenderedElement_fn = function(container, element) {
84
+ if (__privateGet(this, _renderedElement) && container.contains(__privateGet(this, _renderedElement))) {
85
+ container.removeChild(__privateGet(this, _renderedElement));
86
+ }
87
+ __privateSet(this, _renderedElement, element);
88
+ container.appendChild(element);
89
+ __privateMethod(this, _AiChatbotToolCallComponent_instances, dispatchScrollRequest_fn).call(this);
90
+ };
90
91
  AiChatbotToolCallComponent.styles = unsafeCSS(styles);
91
92
  __decorateClass([
92
93
  property({ attribute: false })
@@ -1,5 +1,16 @@
1
- import { ChatMessage, ContextItem, FileAttachment, ToolCall } from './types.js';
1
+ import { ChatMessage, ContextItem, FileAttachment, ToolCall, ToolDefinition } from './types.js';
2
2
  export { renderMarkdown, renderInlineMarkdown, type RenderMarkdownOptions } from '../utils/markdown.js';
3
+ /**
4
+ * Whether a tool call's renderer should currently be shown: once the call is complete,
5
+ * or immediately (while still parsing/executing) if the tool opted into `renderOnStart`.
6
+ */
7
+ export declare function shouldShowToolRenderer(toolCall: ToolCall, toolDefinition?: ToolDefinition): boolean;
8
+ /**
9
+ * Whether a tool call should be treated as settled for activity indicators (thinking
10
+ * indicator, tool-call summary spinner): either genuinely finished, or already showing
11
+ * its own renderer to the user, which makes a redundant "running" spinner misleading.
12
+ */
13
+ export declare function isToolCallSettled(toolCall: ToolCall, toolDefinition?: ToolDefinition): boolean;
3
14
  /**
4
15
  * Generates a unique ID using UUID v4
5
16
  */
@@ -1,5 +1,17 @@
1
1
  import { v4 } from "uuid";
2
2
  import { renderInlineMarkdown, renderMarkdown } from "../utils/markdown.mjs";
3
+ function shouldShowToolRenderer(toolCall, toolDefinition) {
4
+ if (!toolDefinition?.renderer) {
5
+ return false;
6
+ }
7
+ if (toolCall.status === "complete") {
8
+ return true;
9
+ }
10
+ return !!toolDefinition.renderOnStart && (toolCall.status === "parsing" || toolCall.status === "executing");
11
+ }
12
+ function isToolCallSettled(toolCall, toolDefinition) {
13
+ return toolCall.status === "complete" || toolCall.status === "error" || shouldShowToolRenderer(toolCall, toolDefinition);
14
+ }
3
15
  function generateId() {
4
16
  return v4();
5
17
  }
@@ -89,6 +101,8 @@ export {
89
101
  formatChatTranscript,
90
102
  formatToolCallForExport,
91
103
  generateId,
104
+ isToolCallSettled,
92
105
  renderInlineMarkdown,
93
- renderMarkdown
106
+ renderMarkdown,
107
+ shouldShowToolRenderer
94
108
  };
@@ -2,6 +2,7 @@ import { unsafeCSS, LitElement, html, nothing } from "lit";
2
2
  import { property, state, customElement } from "lit/decorators.js";
3
3
  import { when } from "lit/directives/when.js";
4
4
  import { unsafeHTML } from "lit/directives/unsafe-html.js";
5
+ import { isToolCallSettled } from "../ai-chatbot/utils.mjs";
5
6
  import "../ai-spinner/ai-spinner.mjs";
6
7
  import styles from "./ai-tool-call-indicator.scss.mjs";
7
8
  var __defProp = Object.defineProperty;
@@ -123,7 +124,7 @@ count_get = function() {
123
124
  return this.toolCalls.length;
124
125
  };
125
126
  isRunning_get = function() {
126
- return this.toolCalls.some((tc) => tc.status !== "complete" && tc.status !== "error");
127
+ return this.toolCalls.some((tc) => !isToolCallSettled(tc, this.tools?.get(tc.name)));
127
128
  };
128
129
  elapsedMs_get = function() {
129
130
  if (__privateGet(this, _AiToolCallIndicatorComponent_instances, isRunning_get)) {
@@ -217,12 +218,12 @@ highlightJson_fn = function(value) {
217
218
  return html`${unsafeHTML(highlighted)}`;
218
219
  };
219
220
  statusMarker_fn = function(toolCall) {
220
- if (toolCall.status === "complete") {
221
- return html`<span class="row-marker row-marker--complete">${__privateGet(this, _completeIcon)}</span>`;
222
- }
223
221
  if (toolCall.status === "error") {
224
222
  return html`<span class="row-marker row-marker--error">${__privateGet(this, _errorIcon)}</span>`;
225
223
  }
224
+ if (isToolCallSettled(toolCall, this.tools?.get(toolCall.name))) {
225
+ return html`<span class="row-marker row-marker--complete">${__privateGet(this, _completeIcon)}</span>`;
226
+ }
226
227
  return html`<span class="row-marker"><forge-ai-spinner size="small"></forge-ai-spinner></span>`;
227
228
  };
228
229
  detailPayload_fn = function(toolCall) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tylertech/forge-ai",
3
- "version": "0.13.12",
3
+ "version": "0.13.13",
4
4
  "description": "A library of Tyler Forge™ AI chat interface web components.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Tyler Technologies, Inc.",