@helpai/elements 0.50.1 → 0.50.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.
package/index.mjs CHANGED
@@ -29,7 +29,7 @@ var BRAND = {
29
29
  };
30
30
 
31
31
  // src/core/version.ts
32
- var ELEMENTS_VERSION = true ? "0.50.1" : "0.0.0-dev";
32
+ var ELEMENTS_VERSION = true ? "0.50.2" : "0.0.0-dev";
33
33
  var ELEMENTS_VERSION_PARAM = "_ev";
34
34
 
35
35
  // src/i18n/strings.ts
@@ -5281,6 +5281,11 @@ function toolName(raw) {
5281
5281
  if (raw.startsWith("tool-")) return raw.slice(5);
5282
5282
  return raw;
5283
5283
  }
5284
+ function toolDecisionState(state, approval) {
5285
+ const terminal = state === "output-available" || state === "output-error" || state === "output-denied";
5286
+ const responded = state === "approval-responded" || approval?.approved !== void 0;
5287
+ return { terminal, responded, decided: terminal || responded };
5288
+ }
5284
5289
  function statusOf(state, approval) {
5285
5290
  if (state === "output-error") return "error";
5286
5291
  if (state === "output-denied" || approval?.approved === false) return "denied";
@@ -5371,9 +5376,7 @@ function ToolApproval({ part, strings, active, onDecision, onEdit }) {
5371
5376
  const error = useComputed2(() => part.errorSig.value);
5372
5377
  const name = toolName(part.toolName);
5373
5378
  const approved = approval.value?.approved;
5374
- const responded = approved !== void 0;
5375
- const terminal = state.value === "output-available" || state.value === "output-error" || state.value === "output-denied";
5376
- const decided = responded || terminal;
5379
+ const { terminal, responded, decided } = toolDecisionState(state.value, approval.value);
5377
5380
  const editable = responded && active && !terminal;
5378
5381
  const id = part.toolCallId;
5379
5382
  return /* @__PURE__ */ jsxs12("div", { class: `${p14}-toolui-group`, "data-testid": decided ? TID.toolDecision : TID.toolApproval, children: [
@@ -5496,9 +5499,7 @@ function ToolAskInput({ part, strings, active, onSubmit, onDecision, onEdit }) {
5496
5499
  const state = useComputed3(() => part.stateSig.value);
5497
5500
  const approval = useComputed3(() => part.approvalSig.value);
5498
5501
  const request = useComputed3(() => parseAskUserInput(part.inputSig.value));
5499
- const terminal = state.value === "output-available" || state.value === "output-error" || state.value === "output-denied";
5500
- const responded = state.value === "approval-responded" || approval.value?.approved !== void 0;
5501
- const decided = terminal || responded;
5502
+ const { terminal, responded, decided } = toolDecisionState(state.value, approval.value);
5502
5503
  const viaApproval = approval.value !== void 0;
5503
5504
  const resolve = (answer, accepted) => {
5504
5505
  if (viaApproval) onDecision(part.toolCallId, accepted, answer);
@@ -5603,7 +5604,7 @@ function DecidedCard({
5603
5604
  const output = useComputed3(() => part.outputSig.value);
5604
5605
  const approval = useComputed3(() => part.approvalSig.value);
5605
5606
  const skipped = approval.value?.approved === false;
5606
- const answer = approval.value?.approved !== void 0 ? approval.value.reason ?? "" : summarizeOutput(output.value);
5607
+ const answer = approval.value?.approved !== void 0 ? approval.value.reason ?? "" : summarizeOutput(output.value, strings);
5607
5608
  return /* @__PURE__ */ jsxs13("div", { class: `${p15}-toolui`, "data-testid": TID.toolDecision, children: [
5608
5609
  /* @__PURE__ */ jsxs13("div", { class: `${p15}-toolui-head`, children: [
5609
5610
  /* @__PURE__ */ jsx16("span", { class: `${p15}-toolui-badge ${p15}-toolui-badge-accent`, children: strings.inputBadge }),
@@ -5615,12 +5616,12 @@ function DecidedCard({
5615
5616
  editable ? /* @__PURE__ */ jsx16("div", { class: `${p15}-toolui-actions`, children: /* @__PURE__ */ jsx16("button", { type: "button", class: `${p15}-form-skip`, onClick: onEdit, "data-testid": TID.toolEdit, children: strings.edit }) }) : null
5616
5617
  ] });
5617
5618
  }
5618
- function summarizeOutput(output) {
5619
+ function summarizeOutput(output, strings) {
5619
5620
  if (output == null) return "";
5620
5621
  if (typeof output === "string") return output;
5621
5622
  if (typeof output === "object") {
5622
5623
  const rec = output;
5623
- if ("confirmed" in rec) return rec.confirmed ? "Yes" : "No";
5624
+ if ("confirmed" in rec) return rec.confirmed ? strings.confirmYes : strings.confirmNo;
5624
5625
  if (typeof rec.responseText === "string" && rec.responseText) return rec.responseText;
5625
5626
  return Object.values(rec).filter((v) => typeof v === "string" || typeof v === "number").join(", ");
5626
5627
  }
package/package.json CHANGED
@@ -80,5 +80,5 @@
80
80
  ],
81
81
  "type": "module",
82
82
  "types": "./index.d.ts",
83
- "version": "0.50.1"
83
+ "version": "0.50.2"
84
84
  }
package/web-component.mjs CHANGED
@@ -1794,7 +1794,7 @@ function createAuth(opts) {
1794
1794
  }
1795
1795
 
1796
1796
  // src/core/version.ts
1797
- var ELEMENTS_VERSION = true ? "0.50.1" : "0.0.0-dev";
1797
+ var ELEMENTS_VERSION = true ? "0.50.2" : "0.0.0-dev";
1798
1798
  var ELEMENTS_VERSION_PARAM = "_ev";
1799
1799
 
1800
1800
  // src/stream/types.ts
@@ -5240,6 +5240,11 @@ function toolName(raw) {
5240
5240
  if (raw.startsWith("tool-")) return raw.slice(5);
5241
5241
  return raw;
5242
5242
  }
5243
+ function toolDecisionState(state, approval) {
5244
+ const terminal = state === "output-available" || state === "output-error" || state === "output-denied";
5245
+ const responded = state === "approval-responded" || approval?.approved !== void 0;
5246
+ return { terminal, responded, decided: terminal || responded };
5247
+ }
5243
5248
  function statusOf(state, approval) {
5244
5249
  if (state === "output-error") return "error";
5245
5250
  if (state === "output-denied" || approval?.approved === false) return "denied";
@@ -5330,9 +5335,7 @@ function ToolApproval({ part, strings, active, onDecision, onEdit }) {
5330
5335
  const error = useComputed2(() => part.errorSig.value);
5331
5336
  const name = toolName(part.toolName);
5332
5337
  const approved = approval.value?.approved;
5333
- const responded = approved !== void 0;
5334
- const terminal = state.value === "output-available" || state.value === "output-error" || state.value === "output-denied";
5335
- const decided = responded || terminal;
5338
+ const { terminal, responded, decided } = toolDecisionState(state.value, approval.value);
5336
5339
  const editable = responded && active && !terminal;
5337
5340
  const id = part.toolCallId;
5338
5341
  return /* @__PURE__ */ jsxs12("div", { class: `${p14}-toolui-group`, "data-testid": decided ? TID.toolDecision : TID.toolApproval, children: [
@@ -5455,9 +5458,7 @@ function ToolAskInput({ part, strings, active, onSubmit, onDecision, onEdit }) {
5455
5458
  const state = useComputed3(() => part.stateSig.value);
5456
5459
  const approval = useComputed3(() => part.approvalSig.value);
5457
5460
  const request = useComputed3(() => parseAskUserInput(part.inputSig.value));
5458
- const terminal = state.value === "output-available" || state.value === "output-error" || state.value === "output-denied";
5459
- const responded = state.value === "approval-responded" || approval.value?.approved !== void 0;
5460
- const decided = terminal || responded;
5461
+ const { terminal, responded, decided } = toolDecisionState(state.value, approval.value);
5461
5462
  const viaApproval = approval.value !== void 0;
5462
5463
  const resolve = (answer, accepted) => {
5463
5464
  if (viaApproval) onDecision(part.toolCallId, accepted, answer);
@@ -5562,7 +5563,7 @@ function DecidedCard({
5562
5563
  const output = useComputed3(() => part.outputSig.value);
5563
5564
  const approval = useComputed3(() => part.approvalSig.value);
5564
5565
  const skipped = approval.value?.approved === false;
5565
- const answer = approval.value?.approved !== void 0 ? approval.value.reason ?? "" : summarizeOutput(output.value);
5566
+ const answer = approval.value?.approved !== void 0 ? approval.value.reason ?? "" : summarizeOutput(output.value, strings);
5566
5567
  return /* @__PURE__ */ jsxs13("div", { class: `${p15}-toolui`, "data-testid": TID.toolDecision, children: [
5567
5568
  /* @__PURE__ */ jsxs13("div", { class: `${p15}-toolui-head`, children: [
5568
5569
  /* @__PURE__ */ jsx16("span", { class: `${p15}-toolui-badge ${p15}-toolui-badge-accent`, children: strings.inputBadge }),
@@ -5574,12 +5575,12 @@ function DecidedCard({
5574
5575
  editable ? /* @__PURE__ */ jsx16("div", { class: `${p15}-toolui-actions`, children: /* @__PURE__ */ jsx16("button", { type: "button", class: `${p15}-form-skip`, onClick: onEdit, "data-testid": TID.toolEdit, children: strings.edit }) }) : null
5575
5576
  ] });
5576
5577
  }
5577
- function summarizeOutput(output) {
5578
+ function summarizeOutput(output, strings) {
5578
5579
  if (output == null) return "";
5579
5580
  if (typeof output === "string") return output;
5580
5581
  if (typeof output === "object") {
5581
5582
  const rec = output;
5582
- if ("confirmed" in rec) return rec.confirmed ? "Yes" : "No";
5583
+ if ("confirmed" in rec) return rec.confirmed ? strings.confirmYes : strings.confirmNo;
5583
5584
  if (typeof rec.responseText === "string" && rec.responseText) return rec.responseText;
5584
5585
  return Object.values(rec).filter((v) => typeof v === "string" || typeof v === "number").join(", ");
5585
5586
  }