@webless/agent 0.6.5 → 0.6.6

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.
@@ -1,5 +1,16 @@
1
1
  // src/runtime/tool-ui.ts
2
2
  var AGENT_TOOL_UI_SCHEMA_VERSION = "webless.tool-ui.v1";
3
+ var AGENT_STRUCTURED_TOOL_INPUT_SCHEMA_VERSION = "webless.structured-tool-input.v1";
4
+ var AGENT_STRUCTURED_TOOL_INPUT_HEADER = "Webless-Structured-Tool-Input-JSON:";
5
+ function formatAgentStructuredToolInput(surface, values) {
6
+ const payload = {
7
+ schemaVersion: AGENT_STRUCTURED_TOOL_INPUT_SCHEMA_VERSION,
8
+ toolSlug: surface.toolSlug,
9
+ ...surface.operationId ? { operationId: surface.operationId } : {},
10
+ values
11
+ };
12
+ return `${AGENT_STRUCTURED_TOOL_INPUT_HEADER} ${JSON.stringify(payload)}`;
13
+ }
3
14
  function isRecord(value) {
4
15
  return value !== null && typeof value === "object" && !Array.isArray(value);
5
16
  }
@@ -394,21 +405,46 @@ function looksLikeBookingCopy(text) {
394
405
  text
395
406
  );
396
407
  }
397
- function inferComposerForm(text) {
398
- const cleaned = text.trim();
399
- if (!cleaned || looksLikeBookingCopy(cleaned) || !looksLikeFieldCollection(cleaned)) {
400
- return null;
401
- }
402
- const fields = FIELD_LIBRARY.flatMap((field) => {
403
- if (field.exclude?.test(cleaned)) {
404
- const leftover = cleaned.replace(field.exclude, " ");
408
+ function echoedLabeledFieldIds(text) {
409
+ const ids = /* @__PURE__ */ new Set();
410
+ if (/\bname\s*:\s+\S+/i.test(text)) ids.add("name");
411
+ if (/\be-?mail\s*:\s+\S+/i.test(text)) ids.add("email");
412
+ if (/\bphone\s*:\s+\S+/i.test(text)) ids.add("phone");
413
+ if (/\bcompany\s*:\s+\S+/i.test(text)) ids.add("company");
414
+ return ids;
415
+ }
416
+ function matchLibraryFields(text) {
417
+ return FIELD_LIBRARY.flatMap((field) => {
418
+ if (field.exclude?.test(text)) {
419
+ const leftover = text.replace(field.exclude, " ");
405
420
  if (!field.patterns.some((pattern) => pattern.test(leftover))) return [];
406
- } else if (!field.patterns.some((pattern) => pattern.test(cleaned))) {
421
+ } else if (!field.patterns.some((pattern) => pattern.test(text))) {
407
422
  return [];
408
423
  }
409
424
  const { patterns: _patterns, exclude: _exclude, ...next } = field;
410
425
  return [next];
411
426
  }).slice(0, MAX_FORM_FIELDS);
427
+ }
428
+ function looksLikeCompletedActionRecap(text) {
429
+ const confirmingCreate = /\bshould i create this\b/i.test(text);
430
+ const echoingFilledFields = /\b(?:name|email|phone|company)\s*:\s+\S+/i.test(text) && /[^\s@]+@[^\s@]+\.[^\s@]+/i.test(text);
431
+ if (echoingFilledFields) {
432
+ if (looksLikeFieldCollection(text)) {
433
+ const echoed = echoedLabeledFieldIds(text);
434
+ if (matchLibraryFields(text).some((field) => !echoed.has(field.id))) {
435
+ return false;
436
+ }
437
+ }
438
+ return true;
439
+ }
440
+ return confirmingCreate && !looksLikeFieldCollection(text);
441
+ }
442
+ function inferComposerForm(text) {
443
+ const cleaned = text.trim();
444
+ if (!cleaned || looksLikeBookingCopy(cleaned) || looksLikeCompletedActionRecap(cleaned) || !looksLikeFieldCollection(cleaned)) {
445
+ return null;
446
+ }
447
+ const fields = matchLibraryFields(cleaned);
412
448
  if (fields.length < MIN_FORM_FIELDS) return null;
413
449
  return {
414
450
  id: `inferred:${fields.map((field) => field.id).join("+")}`,
@@ -416,7 +452,9 @@ function inferComposerForm(text) {
416
452
  };
417
453
  }
418
454
  function resolveComposerForm(input) {
419
- if (input.enabled === false || input.hasBookingOffer) return null;
455
+ if (input.enabled === false || input.hasBookingOffer || input.hasPendingConfirmation) {
456
+ return null;
457
+ }
420
458
  const text = input.agentText.trim();
421
459
  if (!text) return null;
422
460
  const card = input.cards?.find((item) => item.type === "visitor_form");
@@ -441,7 +479,7 @@ function preferBookingOffer(current, next) {
441
479
  return next;
442
480
  }
443
481
  function looksLikeBookingReady(text) {
444
- return /demo option|options are ready|pick a (date|time)|available (times|slots)|book(ing)? (card|the demo)|schedule/i.test(
482
+ return /demo option|options are ready|pick a (date|time)|available (times|slots)|book(ing)? (card|the demo)|\bschedule\b/i.test(
445
483
  text
446
484
  );
447
485
  }
@@ -933,7 +971,8 @@ function presentVisitorToolResult(result, registry = []) {
933
971
  id: result.callId,
934
972
  toolName: result.toolName,
935
973
  status: result.status,
936
- kind: "hidden"
974
+ kind: "input",
975
+ surface: envelope.ui
937
976
  };
938
977
  }
939
978
  if (!proposed) {
@@ -1818,11 +1857,11 @@ function createAgentClient(options) {
1818
1857
 
1819
1858
  // src/runtime/errors.ts
1820
1859
  import { ClientError as ClientError3 } from "eve/client";
1821
- var TRANSIENT_AGENT_ERROR_MESSAGE = "I couldn\u2019t finish that answer. Please try again.";
1860
+ var TRANSIENT_AGENT_ERROR_MESSAGE = "The agent run stopped before the action finished. Please try again.";
1822
1861
  var PREVIEW_AUTHORIZATION_ERROR_MESSAGE = "This preview could not be authorized. Open the latest preview from Webless.";
1823
1862
  function isTransientRuntimeMessage(message) {
1824
1863
  const normalized = message.trim().toLowerCase();
1825
- return normalized.includes("empty response from runtime") || normalized.includes("failed to fetch") || normalized.includes("networkerror") || normalized.includes("load failed");
1864
+ return normalized.includes("empty response from runtime") || normalized.includes("failed to fetch") || normalized.includes("networkerror") || normalized.includes("network error") || normalized.includes("load failed") || normalized.includes("the stream");
1826
1865
  }
1827
1866
  function isPreviewAuthorizationMessage(message) {
1828
1867
  const normalized = message.trim().toLowerCase();
@@ -2124,6 +2163,7 @@ function clearPendingWidgetBooking(storageKeyPrefix, visitorSessionId) {
2124
2163
 
2125
2164
  // src/react/lib/visitor-input.ts
2126
2165
  function shouldRenderVisitorInputCard(request) {
2166
+ if (request.ui) return true;
2127
2167
  if (request.kind === "tool-approval" || request.kind === "session-limit") {
2128
2168
  return true;
2129
2169
  }
@@ -2457,7 +2497,6 @@ function useAgentChat({
2457
2497
  }
2458
2498
  if (!isActiveRun()) return;
2459
2499
  if (presentation.kind === "hidden") return;
2460
- if (presentation.kind === "input") return;
2461
2500
  setState((prev) => ({
2462
2501
  ...prev,
2463
2502
  toolResults: [
@@ -2735,14 +2774,13 @@ ${outgoing}` : outgoing;
2735
2774
  }, [runTurn, state.messages]);
2736
2775
  const respondToToolInput = useCallback(
2737
2776
  async (surface, values) => {
2738
- const details = JSON.stringify(values);
2739
- await submit(`${surface.title} details provided`, {
2777
+ await submit(`${surface.title} submitted`, {
2740
2778
  runtimeText: [
2741
- `Structured input provided for ${surface.toolSlug}.`,
2742
- surface.operationId ? `Operation: ${surface.operationId}.` : "",
2743
- `Use these exact values and retry the action: ${details}`,
2779
+ formatAgentStructuredToolInput(surface, values),
2780
+ "Use these exact structured values to retry the requested action.",
2781
+ "Reuse the operationId from the structured payload.",
2744
2782
  "Do not invent or alter any values."
2745
- ].filter(Boolean).join("\n")
2783
+ ].join("\n")
2746
2784
  });
2747
2785
  },
2748
2786
  [submit]
@@ -2891,6 +2929,7 @@ var defaultAgentRailTheme = {
2891
2929
  border: "rgb(42 51 70 / 0.1)",
2892
2930
  visitorBubble: "#f3edff",
2893
2931
  visitorText: "#171b2a",
2932
+ onBrand: "#ffffff",
2894
2933
  success: "#18794e",
2895
2934
  danger: "#c94b63",
2896
2935
  fontBody: '"Mulish", "Avenir Next", "Segoe UI", sans-serif',
@@ -2909,12 +2948,13 @@ var defaultDarkAgentRailTheme = {
2909
2948
  border: "rgb(226 232 240 / 0.16)",
2910
2949
  visitorBubble: "#2b2140",
2911
2950
  visitorText: "#f5f7fb",
2951
+ onBrand: "#171b2a",
2912
2952
  success: "#55cf91",
2913
2953
  danger: "#ff8da1"
2914
2954
  };
2915
2955
 
2916
2956
  // src/react/components/AgentRail/AgentRail.tsx
2917
- import { useEffect as useEffect3, useRef as useRef3, useState as useState7 } from "react";
2957
+ import { useEffect as useEffect3, useRef as useRef3, useState as useState8 } from "react";
2918
2958
 
2919
2959
  // src/react/hooks/useAgentColorScheme.ts
2920
2960
  import { useSyncExternalStore } from "react";
@@ -3358,6 +3398,9 @@ function calendarCells(year, month) {
3358
3398
  while (cells.length < 42) cells.push(null);
3359
3399
  return cells;
3360
3400
  }
3401
+ function BookingCardLoader() {
3402
+ return /* @__PURE__ */ jsx4("section", { className: "booking-card", "aria-label": "Book a meeting", children: /* @__PURE__ */ jsx4("p", { className: "booking-card__loading", role: "status", children: "Finding available times\u2026" }) });
3403
+ }
3361
3404
  function BookingCard({
3362
3405
  offer,
3363
3406
  onBook
@@ -3777,7 +3820,7 @@ function MessageBubble({
3777
3820
  }
3778
3821
 
3779
3822
  // src/react/components/HumanInputCard/HumanInputCard.tsx
3780
- import { useState as useState6 } from "react";
3823
+ import { useState as useState7 } from "react";
3781
3824
 
3782
3825
  // src/react/components/ConfirmationCard/ConfirmationCard.tsx
3783
3826
  import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
@@ -3818,18 +3861,450 @@ function ConfirmationCard({
3818
3861
  );
3819
3862
  }
3820
3863
 
3821
- // src/react/components/HumanInputCard/HumanInputCard.tsx
3864
+ // src/react/components/ToolInputCard/ToolInputCard.tsx
3865
+ import { useState as useState6 } from "react";
3822
3866
  import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
3867
+ function isRecord4(value) {
3868
+ return value !== null && typeof value === "object" && !Array.isArray(value);
3869
+ }
3870
+ function pathSegments(path) {
3871
+ return path.replace(/\[(\d+)\]/gu, ".$1").split(".").filter(Boolean);
3872
+ }
3873
+ function valueAtPath(root, path) {
3874
+ let current = root;
3875
+ for (const segment of pathSegments(path)) {
3876
+ if (Array.isArray(current)) {
3877
+ const index = Number(segment);
3878
+ current = Number.isInteger(index) ? current[index] : void 0;
3879
+ continue;
3880
+ }
3881
+ current = isRecord4(current) ? current[segment] : void 0;
3882
+ }
3883
+ return current;
3884
+ }
3885
+ function initialFieldValue(field, surface) {
3886
+ const supplied = valueAtPath(surface.values, field.path);
3887
+ if (supplied !== void 0) return supplied;
3888
+ if (field.defaultValue !== void 0) return field.defaultValue;
3889
+ if (field.kind === "checkbox" || field.kind === "confirmation") return false;
3890
+ if (field.kind === "multi-select") return [];
3891
+ if (field.kind === "range") return field.min ?? 0;
3892
+ return "";
3893
+ }
3894
+ function initialValues(surface) {
3895
+ return Object.fromEntries(
3896
+ surface.fields.map((field) => [
3897
+ field.path,
3898
+ initialFieldValue(field, surface)
3899
+ ])
3900
+ );
3901
+ }
3902
+ function cloneJsonValue(value) {
3903
+ if (Array.isArray(value)) return value.map(cloneJsonValue);
3904
+ if (isRecord4(value)) {
3905
+ return Object.fromEntries(
3906
+ Object.entries(value).map(([key, item]) => [key, cloneJsonValue(item)])
3907
+ );
3908
+ }
3909
+ return value;
3910
+ }
3911
+ function assignPath(target, path, value) {
3912
+ const segments = pathSegments(path);
3913
+ let current = target;
3914
+ segments.forEach((segment, index) => {
3915
+ if (index === segments.length - 1) {
3916
+ current[segment] = value;
3917
+ return;
3918
+ }
3919
+ const existing = current[segment];
3920
+ if (!isRecord4(existing)) current[segment] = {};
3921
+ current = current[segment];
3922
+ });
3923
+ }
3924
+ function isJsonValue3(value, seen = /* @__PURE__ */ new Set()) {
3925
+ if (value === null || typeof value === "string" || typeof value === "boolean") {
3926
+ return true;
3927
+ }
3928
+ if (typeof value === "number") return Number.isFinite(value);
3929
+ if (typeof value !== "object" || seen.has(value)) return false;
3930
+ seen.add(value);
3931
+ const valid = Array.isArray(value) ? value.every((item) => isJsonValue3(item, seen)) : Object.values(value).every((item) => isJsonValue3(item, seen));
3932
+ seen.delete(value);
3933
+ return valid;
3934
+ }
3935
+ function parsedFieldValue(field, value) {
3936
+ if (field.kind !== "json" || typeof value !== "string") return value;
3937
+ try {
3938
+ const parsed = JSON.parse(value);
3939
+ return isJsonValue3(parsed) ? parsed : void 0;
3940
+ } catch {
3941
+ return void 0;
3942
+ }
3943
+ }
3944
+ function isEmpty(value) {
3945
+ if (typeof value === "string") return value.trim().length === 0;
3946
+ if (Array.isArray(value)) return value.length === 0;
3947
+ return value === null || value === false;
3948
+ }
3949
+ function validateField(field, value) {
3950
+ if (field.required && isEmpty(value))
3951
+ return `Enter ${field.label.toLowerCase()}.`;
3952
+ if (typeof value === "string" && value.trim().length === 0) return "";
3953
+ if (field.kind === "email" && (typeof value !== "string" || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/u.test(value))) {
3954
+ return "Enter a valid email address.";
3955
+ }
3956
+ if (typeof value === "string") {
3957
+ if (field.minLength !== void 0 && value.length < field.minLength) {
3958
+ return `Use at least ${field.minLength} characters.`;
3959
+ }
3960
+ if (field.maxLength !== void 0 && value.length > field.maxLength) {
3961
+ return `Use no more than ${field.maxLength} characters.`;
3962
+ }
3963
+ }
3964
+ if (typeof value === "number") {
3965
+ if (field.min !== void 0 && value < field.min) {
3966
+ return `Choose ${field.min} or higher.`;
3967
+ }
3968
+ if (field.max !== void 0 && value > field.max) {
3969
+ return `Choose ${field.max} or lower.`;
3970
+ }
3971
+ }
3972
+ if (field.maxItems !== void 0 && Array.isArray(value) && value.length > field.maxItems) {
3973
+ return `Choose no more than ${field.maxItems}.`;
3974
+ }
3975
+ if (field.kind === "json" && parsedFieldValue(field, value) === void 0) {
3976
+ return "Enter valid JSON.";
3977
+ }
3978
+ return "";
3979
+ }
3980
+ function optionKey(option) {
3981
+ return JSON.stringify(option.value);
3982
+ }
3983
+ function valuesMatch(left, right) {
3984
+ return JSON.stringify(left) === JSON.stringify(right);
3985
+ }
3986
+ function FieldDescription({
3987
+ field,
3988
+ id
3989
+ }) {
3990
+ return field.description ? /* @__PURE__ */ jsx7("span", { id, className: "tool-input-card__description", children: field.description }) : null;
3991
+ }
3992
+ function ChoiceField({
3993
+ field,
3994
+ id,
3995
+ value,
3996
+ disabled,
3997
+ describedBy,
3998
+ error,
3999
+ onBlur,
4000
+ onChange
4001
+ }) {
4002
+ const options = field.options ?? [];
4003
+ const multiple = field.kind === "multi-select";
4004
+ const selected = Array.isArray(value) ? value : [];
4005
+ if (field.kind === "select") {
4006
+ const selectedIndex = options.findIndex(
4007
+ (option) => valuesMatch(option.value, value)
4008
+ );
4009
+ return /* @__PURE__ */ jsxs7(
4010
+ "select",
4011
+ {
4012
+ id,
4013
+ value: selectedIndex >= 0 ? String(selectedIndex) : "",
4014
+ disabled,
4015
+ required: field.required,
4016
+ "aria-describedby": describedBy,
4017
+ "aria-invalid": Boolean(error),
4018
+ onBlur,
4019
+ onChange: (event) => {
4020
+ const option = options[Number(event.target.value)];
4021
+ if (option) onChange(option.value);
4022
+ },
4023
+ children: [
4024
+ /* @__PURE__ */ jsx7("option", { value: "", disabled: field.required, children: "Choose an option" }),
4025
+ options.map((option, index) => /* @__PURE__ */ jsx7("option", { value: index, children: option.label }, optionKey(option)))
4026
+ ]
4027
+ }
4028
+ );
4029
+ }
4030
+ return /* @__PURE__ */ jsx7(
4031
+ "div",
4032
+ {
4033
+ className: "tool-input-card__choices",
4034
+ role: multiple ? "group" : "radiogroup",
4035
+ "aria-labelledby": `${id}-label`,
4036
+ "aria-describedby": describedBy,
4037
+ "aria-invalid": Boolean(error),
4038
+ "aria-required": field.required,
4039
+ children: options.map((option, index) => {
4040
+ const checked = multiple ? selected.some((item) => valuesMatch(item, option.value)) : valuesMatch(value, option.value);
4041
+ return /* @__PURE__ */ jsxs7("label", { className: "tool-input-card__choice", children: [
4042
+ /* @__PURE__ */ jsx7(
4043
+ "input",
4044
+ {
4045
+ type: multiple ? "checkbox" : "radio",
4046
+ name: id,
4047
+ value: String(index),
4048
+ checked,
4049
+ disabled,
4050
+ onBlur,
4051
+ onChange: () => {
4052
+ if (!multiple) {
4053
+ onChange(option.value);
4054
+ return;
4055
+ }
4056
+ onChange(
4057
+ checked ? selected.filter(
4058
+ (item) => !valuesMatch(item, option.value)
4059
+ ) : [...selected, option.value]
4060
+ );
4061
+ }
4062
+ }
4063
+ ),
4064
+ /* @__PURE__ */ jsx7("span", { children: option.label })
4065
+ ] }, optionKey(option));
4066
+ })
4067
+ }
4068
+ );
4069
+ }
4070
+ function ToolField({
4071
+ disabled,
4072
+ error,
4073
+ field,
4074
+ id,
4075
+ value,
4076
+ onBlur,
4077
+ onChange
4078
+ }) {
4079
+ const describedBy = [
4080
+ field.description ? `${id}-description` : "",
4081
+ error ? `${id}-error` : ""
4082
+ ].filter(Boolean).join(" ");
4083
+ if (field.kind === "checkbox" || field.kind === "confirmation") {
4084
+ return /* @__PURE__ */ jsxs7("div", { className: "tool-input-card__field", children: [
4085
+ /* @__PURE__ */ jsxs7("label", { className: "tool-input-card__check", htmlFor: id, children: [
4086
+ /* @__PURE__ */ jsx7(
4087
+ "input",
4088
+ {
4089
+ id,
4090
+ type: "checkbox",
4091
+ checked: value === true,
4092
+ disabled,
4093
+ "aria-describedby": describedBy || void 0,
4094
+ "aria-invalid": Boolean(error),
4095
+ onBlur,
4096
+ onChange: (event) => onChange(event.target.checked)
4097
+ }
4098
+ ),
4099
+ /* @__PURE__ */ jsxs7("span", { children: [
4100
+ /* @__PURE__ */ jsx7("strong", { children: field.label }),
4101
+ field.description ? /* @__PURE__ */ jsx7("span", { id: `${id}-description`, children: field.description }) : null
4102
+ ] })
4103
+ ] }),
4104
+ error ? /* @__PURE__ */ jsx7("span", { id: `${id}-error`, className: "tool-input-card__error", children: error }) : null
4105
+ ] });
4106
+ }
4107
+ const label = /* @__PURE__ */ jsxs7("label", { id: `${id}-label`, htmlFor: id, children: [
4108
+ field.label,
4109
+ field.required ? /* @__PURE__ */ jsx7("span", { "aria-hidden": "true", children: " *" }) : null
4110
+ ] });
4111
+ const common = {
4112
+ id,
4113
+ disabled,
4114
+ required: field.required,
4115
+ "aria-describedby": describedBy || void 0,
4116
+ "aria-invalid": Boolean(error),
4117
+ onBlur
4118
+ };
4119
+ let control;
4120
+ if (field.kind === "select" || field.kind === "radio" || field.kind === "multi-select") {
4121
+ control = /* @__PURE__ */ jsx7(
4122
+ ChoiceField,
4123
+ {
4124
+ field,
4125
+ id,
4126
+ value,
4127
+ disabled,
4128
+ describedBy: describedBy || void 0,
4129
+ error,
4130
+ onBlur,
4131
+ onChange
4132
+ }
4133
+ );
4134
+ } else if (field.kind === "textarea" || field.kind === "json") {
4135
+ control = /* @__PURE__ */ jsx7(
4136
+ "textarea",
4137
+ {
4138
+ ...common,
4139
+ rows: field.kind === "json" ? 4 : 3,
4140
+ maxLength: field.maxLength,
4141
+ minLength: field.minLength,
4142
+ placeholder: field.placeholder,
4143
+ value: typeof value === "string" ? value : JSON.stringify(value),
4144
+ onChange: (event) => onChange(event.target.value)
4145
+ }
4146
+ );
4147
+ } else if (field.kind === "range") {
4148
+ const numericValue = typeof value === "number" ? value : field.min ?? 0;
4149
+ control = /* @__PURE__ */ jsxs7("div", { className: "tool-input-card__range", children: [
4150
+ /* @__PURE__ */ jsx7(
4151
+ "input",
4152
+ {
4153
+ ...common,
4154
+ type: "range",
4155
+ min: field.min,
4156
+ max: field.max,
4157
+ step: field.step,
4158
+ value: numericValue,
4159
+ onChange: (event) => onChange(Number(event.target.value))
4160
+ }
4161
+ ),
4162
+ /* @__PURE__ */ jsx7("output", { htmlFor: id, children: numericValue })
4163
+ ] });
4164
+ } else {
4165
+ const type = field.kind === "date-time" ? "datetime-local" : field.kind === "calendar" ? "date" : field.kind;
4166
+ control = /* @__PURE__ */ jsx7(
4167
+ "input",
4168
+ {
4169
+ ...common,
4170
+ type,
4171
+ min: field.min,
4172
+ max: field.max,
4173
+ step: field.step,
4174
+ minLength: field.minLength,
4175
+ maxLength: field.maxLength,
4176
+ placeholder: field.placeholder,
4177
+ value: typeof value === "number" || typeof value === "string" ? value : "",
4178
+ onChange: (event) => onChange(
4179
+ field.kind === "number" && event.target.value !== "" ? Number(event.target.value) : event.target.value
4180
+ )
4181
+ }
4182
+ );
4183
+ }
4184
+ return /* @__PURE__ */ jsxs7("div", { className: "tool-input-card__field", children: [
4185
+ label,
4186
+ /* @__PURE__ */ jsx7(FieldDescription, { field, id: `${id}-description` }),
4187
+ control,
4188
+ error ? /* @__PURE__ */ jsx7("span", { id: `${id}-error`, className: "tool-input-card__error", children: error }) : null
4189
+ ] });
4190
+ }
4191
+ function ToolInputCard({
4192
+ disabled = false,
4193
+ surface,
4194
+ onSubmit
4195
+ }) {
4196
+ const [values, setValues] = useState6(
4197
+ () => initialValues(surface)
4198
+ );
4199
+ const [touched, setTouched] = useState6(() => /* @__PURE__ */ new Set());
4200
+ const [submitted, setSubmitted] = useState6(false);
4201
+ const errors = Object.fromEntries(
4202
+ surface.fields.map((field) => [
4203
+ field.path,
4204
+ touched.has(field.path) ? validateField(field, values[field.path] ?? "") : ""
4205
+ ])
4206
+ );
4207
+ function submit(event) {
4208
+ event.preventDefault();
4209
+ if (disabled || submitted) return;
4210
+ const allTouched = new Set(surface.fields.map((field) => field.path));
4211
+ setTouched(allTouched);
4212
+ const nextErrors = surface.fields.map(
4213
+ (field) => validateField(field, values[field.path] ?? "")
4214
+ );
4215
+ if (nextErrors.some(Boolean)) return;
4216
+ const result = isRecord4(surface.values) ? cloneJsonValue(surface.values) : {};
4217
+ for (const field of surface.fields) {
4218
+ const parsed = parsedFieldValue(field, values[field.path] ?? "");
4219
+ if (parsed !== void 0) assignPath(result, field.path, parsed);
4220
+ }
4221
+ setSubmitted(true);
4222
+ onSubmit?.(surface, result);
4223
+ }
4224
+ if (submitted) {
4225
+ return /* @__PURE__ */ jsxs7(
4226
+ "section",
4227
+ {
4228
+ className: "tool-input-card tool-input-card--submitted",
4229
+ role: "status",
4230
+ children: [
4231
+ /* @__PURE__ */ jsx7("span", { "aria-hidden": "true", children: "\u2713" }),
4232
+ /* @__PURE__ */ jsxs7("strong", { children: [
4233
+ surface.title,
4234
+ " submitted"
4235
+ ] })
4236
+ ]
4237
+ }
4238
+ );
4239
+ }
4240
+ return /* @__PURE__ */ jsxs7(
4241
+ "section",
4242
+ {
4243
+ className: "tool-input-card",
4244
+ "aria-labelledby": `tool-input-${surface.id}`,
4245
+ children: [
4246
+ /* @__PURE__ */ jsxs7("div", { className: "tool-input-card__heading", children: [
4247
+ /* @__PURE__ */ jsx7("strong", { id: `tool-input-${surface.id}`, children: surface.title }),
4248
+ surface.description ? /* @__PURE__ */ jsx7("p", { children: surface.description }) : null
4249
+ ] }),
4250
+ /* @__PURE__ */ jsxs7("form", { noValidate: true, onSubmit: submit, children: [
4251
+ /* @__PURE__ */ jsx7("div", { className: "tool-input-card__fields", children: surface.fields.map((field, index) => /* @__PURE__ */ jsx7(
4252
+ ToolField,
4253
+ {
4254
+ disabled,
4255
+ error: errors[field.path] ?? "",
4256
+ field,
4257
+ id: `tool-input-${surface.id}-${index}`,
4258
+ value: values[field.path] ?? "",
4259
+ onBlur: () => setTouched((current) => /* @__PURE__ */ new Set([...current, field.path])),
4260
+ onChange: (value) => setValues((current) => ({ ...current, [field.path]: value }))
4261
+ },
4262
+ field.path
4263
+ )) }),
4264
+ /* @__PURE__ */ jsxs7("div", { className: "tool-input-card__actions", children: [
4265
+ surface.actions?.some((action) => action.id === "reset") ? /* @__PURE__ */ jsx7(
4266
+ "button",
4267
+ {
4268
+ type: "button",
4269
+ className: "tool-input-card__secondary",
4270
+ disabled,
4271
+ onClick: () => {
4272
+ setValues(initialValues(surface));
4273
+ setTouched(/* @__PURE__ */ new Set());
4274
+ },
4275
+ children: surface.actions.find((action) => action.id === "reset")?.label ?? "Clear"
4276
+ }
4277
+ ) : null,
4278
+ /* @__PURE__ */ jsx7("button", { type: "submit", disabled, children: surface.submitLabel ?? surface.actions?.find((action) => action.id === "submit")?.label ?? "Continue" })
4279
+ ] })
4280
+ ] })
4281
+ ]
4282
+ }
4283
+ );
4284
+ }
4285
+
4286
+ // src/react/components/HumanInputCard/HumanInputCard.tsx
4287
+ import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
3823
4288
  function HumanInputCard({
3824
4289
  disabled = false,
3825
4290
  request,
3826
4291
  onRespond
3827
4292
  }) {
3828
- const [text, setText] = useState6("");
4293
+ const [text, setText] = useState7("");
3829
4294
  const options = request.options ?? [];
3830
4295
  const showText = request.display === "text" || request.allowFreeform && options.length === 0;
4296
+ if (request.ui) {
4297
+ return /* @__PURE__ */ jsx8(
4298
+ ToolInputCard,
4299
+ {
4300
+ disabled,
4301
+ surface: request.ui,
4302
+ onSubmit: (_, value) => onRespond?.({ requestId: request.requestId, value })
4303
+ }
4304
+ );
4305
+ }
3831
4306
  if (options.length > 0) {
3832
- return /* @__PURE__ */ jsx7(
4307
+ return /* @__PURE__ */ jsx8(
3833
4308
  ConfirmationCard,
3834
4309
  {
3835
4310
  disabled,
@@ -3844,17 +4319,17 @@ function HumanInputCard({
3844
4319
  if (!value || disabled) return;
3845
4320
  onRespond?.({ requestId: request.requestId, text: value });
3846
4321
  }
3847
- return /* @__PURE__ */ jsxs7(
4322
+ return /* @__PURE__ */ jsxs8(
3848
4323
  "section",
3849
4324
  {
3850
4325
  className: "human-input-card",
3851
4326
  "aria-labelledby": `human-input-${request.requestId}`,
3852
4327
  children: [
3853
- /* @__PURE__ */ jsx7("div", { className: "human-input-card__heading", children: /* @__PURE__ */ jsx7("strong", { id: `human-input-${request.requestId}`, children: request.prompt }) }),
3854
- showText ? /* @__PURE__ */ jsxs7("form", { onSubmit: submitText, children: [
3855
- /* @__PURE__ */ jsx7("label", { htmlFor: `human-input-text-${request.requestId}`, children: "Response" }),
3856
- /* @__PURE__ */ jsxs7("div", { children: [
3857
- /* @__PURE__ */ jsx7(
4328
+ /* @__PURE__ */ jsx8("div", { className: "human-input-card__heading", children: /* @__PURE__ */ jsx8("strong", { id: `human-input-${request.requestId}`, children: request.prompt }) }),
4329
+ showText ? /* @__PURE__ */ jsxs8("form", { onSubmit: submitText, children: [
4330
+ /* @__PURE__ */ jsx8("label", { htmlFor: `human-input-text-${request.requestId}`, children: "Response" }),
4331
+ /* @__PURE__ */ jsxs8("div", { children: [
4332
+ /* @__PURE__ */ jsx8(
3858
4333
  "input",
3859
4334
  {
3860
4335
  id: `human-input-text-${request.requestId}`,
@@ -3863,39 +4338,39 @@ function HumanInputCard({
3863
4338
  onChange: (event) => setText(event.target.value)
3864
4339
  }
3865
4340
  ),
3866
- /* @__PURE__ */ jsx7("button", { type: "submit", disabled: disabled || !text.trim(), children: "Send" })
4341
+ /* @__PURE__ */ jsx8("button", { type: "submit", disabled: disabled || !text.trim(), children: "Send" })
3867
4342
  ] })
3868
4343
  ] }) : null,
3869
- !showText && options.length === 0 ? /* @__PURE__ */ jsx7("p", { className: "human-input-card__unavailable", role: "status", children: "This request can\u2019t be answered here." }) : null
4344
+ !showText && options.length === 0 ? /* @__PURE__ */ jsx8("p", { className: "human-input-card__unavailable", role: "status", children: "This request can\u2019t be answered here." }) : null
3870
4345
  ]
3871
4346
  }
3872
4347
  );
3873
4348
  }
3874
4349
 
3875
4350
  // src/react/components/CollectionResultCard/CollectionResultCard.tsx
3876
- import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
4351
+ import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
3877
4352
  function CollectionResultCard({
3878
4353
  result
3879
4354
  }) {
3880
4355
  const empty = result.items.length === 0;
3881
- return /* @__PURE__ */ jsxs8(
4356
+ return /* @__PURE__ */ jsxs9(
3882
4357
  "section",
3883
4358
  {
3884
4359
  className: `collection-result-card tool-result-card tool-result-card--${result.status}`,
3885
4360
  "aria-label": result.title,
3886
4361
  children: [
3887
- /* @__PURE__ */ jsxs8("div", { className: "tool-result-card__heading", children: [
3888
- /* @__PURE__ */ jsx8("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
3889
- /* @__PURE__ */ jsx8("strong", { children: result.title })
4362
+ /* @__PURE__ */ jsxs9("div", { className: "tool-result-card__heading", children: [
4363
+ /* @__PURE__ */ jsx9("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
4364
+ /* @__PURE__ */ jsx9("strong", { children: result.title })
3890
4365
  ] }),
3891
- empty ? /* @__PURE__ */ jsx8("p", { className: "collection-result-card__empty", children: "No matching record for the email you shared." }) : /* @__PURE__ */ jsx8("ul", { className: "collection-result-card__list", children: result.items.map((item) => /* @__PURE__ */ jsxs8("li", { children: [
3892
- /* @__PURE__ */ jsx8("div", { className: "collection-result-card__item-title", children: item.title }),
3893
- item.description ? /* @__PURE__ */ jsx8("p", { children: item.description }) : null,
3894
- item.details?.length ? /* @__PURE__ */ jsx8("dl", { children: item.details.map((detail) => /* @__PURE__ */ jsxs8("div", { children: [
3895
- /* @__PURE__ */ jsx8("dt", { children: detail.label }),
3896
- /* @__PURE__ */ jsx8("dd", { children: detail.value })
4366
+ empty ? /* @__PURE__ */ jsx9("p", { className: "collection-result-card__empty", children: "No matching record for the email you shared." }) : /* @__PURE__ */ jsx9("ul", { className: "collection-result-card__list", children: result.items.map((item) => /* @__PURE__ */ jsxs9("li", { children: [
4367
+ /* @__PURE__ */ jsx9("div", { className: "collection-result-card__item-title", children: item.title }),
4368
+ item.description ? /* @__PURE__ */ jsx9("p", { children: item.description }) : null,
4369
+ item.details?.length ? /* @__PURE__ */ jsx9("dl", { children: item.details.map((detail) => /* @__PURE__ */ jsxs9("div", { children: [
4370
+ /* @__PURE__ */ jsx9("dt", { children: detail.label }),
4371
+ /* @__PURE__ */ jsx9("dd", { children: detail.value })
3897
4372
  ] }, `${detail.label}:${detail.value}`)) }) : null,
3898
- item.href ? /* @__PURE__ */ jsx8("a", { href: item.href, target: "_blank", rel: "noreferrer", children: "Open record" }) : null
4373
+ item.href ? /* @__PURE__ */ jsx9("a", { href: item.href, target: "_blank", rel: "noreferrer", children: "Open record" }) : null
3899
4374
  ] }, item.title)) })
3900
4375
  ]
3901
4376
  }
@@ -3903,26 +4378,26 @@ function CollectionResultCard({
3903
4378
  }
3904
4379
 
3905
4380
  // src/react/components/EntityResultCard/EntityResultCard.tsx
3906
- import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
4381
+ import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
3907
4382
  function EntityResultCard({
3908
4383
  result
3909
4384
  }) {
3910
- return /* @__PURE__ */ jsxs9(
4385
+ return /* @__PURE__ */ jsxs10(
3911
4386
  "section",
3912
4387
  {
3913
4388
  className: `entity-result-card tool-result-card tool-result-card--${result.status}`,
3914
4389
  "aria-label": result.title,
3915
4390
  children: [
3916
- /* @__PURE__ */ jsxs9("div", { className: "tool-result-card__heading", children: [
3917
- /* @__PURE__ */ jsx9("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
3918
- /* @__PURE__ */ jsx9("strong", { children: result.title })
4391
+ /* @__PURE__ */ jsxs10("div", { className: "tool-result-card__heading", children: [
4392
+ /* @__PURE__ */ jsx10("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
4393
+ /* @__PURE__ */ jsx10("strong", { children: result.title })
3919
4394
  ] }),
3920
- result.description ? /* @__PURE__ */ jsx9("p", { children: result.description }) : null,
3921
- result.details?.length ? /* @__PURE__ */ jsx9("dl", { children: result.details.map((detail) => /* @__PURE__ */ jsxs9("div", { children: [
3922
- /* @__PURE__ */ jsx9("dt", { children: detail.label }),
3923
- /* @__PURE__ */ jsx9("dd", { children: detail.value })
4395
+ result.description ? /* @__PURE__ */ jsx10("p", { children: result.description }) : null,
4396
+ result.details?.length ? /* @__PURE__ */ jsx10("dl", { children: result.details.map((detail) => /* @__PURE__ */ jsxs10("div", { children: [
4397
+ /* @__PURE__ */ jsx10("dt", { children: detail.label }),
4398
+ /* @__PURE__ */ jsx10("dd", { children: detail.value })
3924
4399
  ] }, `${detail.label}:${detail.value}`)) }) : null,
3925
- result.links?.length ? /* @__PURE__ */ jsx9("div", { className: "tool-result-card__links", children: result.links.map((link) => /* @__PURE__ */ jsx9(
4400
+ result.links?.length ? /* @__PURE__ */ jsx10("div", { className: "tool-result-card__links", children: result.links.map((link) => /* @__PURE__ */ jsx10(
3926
4401
  "a",
3927
4402
  {
3928
4403
  href: link.href,
@@ -3938,24 +4413,24 @@ function EntityResultCard({
3938
4413
  }
3939
4414
 
3940
4415
  // src/react/components/SignatureResultCard/SignatureResultCard.tsx
3941
- import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
4416
+ import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
3942
4417
  function SignatureResultCard({
3943
4418
  result
3944
4419
  }) {
3945
4420
  const primaryLink = result.links?.[0];
3946
- return /* @__PURE__ */ jsxs10(
4421
+ return /* @__PURE__ */ jsxs11(
3947
4422
  "section",
3948
4423
  {
3949
4424
  className: `signature-result-card tool-result-card tool-result-card--${result.status}`,
3950
4425
  "aria-label": result.title,
3951
4426
  children: [
3952
- /* @__PURE__ */ jsxs10("div", { className: "tool-result-card__heading", children: [
3953
- /* @__PURE__ */ jsx10("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
3954
- /* @__PURE__ */ jsx10("strong", { children: result.title })
4427
+ /* @__PURE__ */ jsxs11("div", { className: "tool-result-card__heading", children: [
4428
+ /* @__PURE__ */ jsx11("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
4429
+ /* @__PURE__ */ jsx11("strong", { children: result.title })
3955
4430
  ] }),
3956
- result.statusLabel ? /* @__PURE__ */ jsx10("span", { className: "signature-result-card__badge", children: result.statusLabel }) : null,
3957
- result.description ? /* @__PURE__ */ jsx10("p", { children: result.description }) : null,
3958
- primaryLink ? /* @__PURE__ */ jsx10(
4431
+ result.statusLabel ? /* @__PURE__ */ jsx11("span", { className: "signature-result-card__badge", children: result.statusLabel }) : null,
4432
+ result.description ? /* @__PURE__ */ jsx11("p", { children: result.description }) : null,
4433
+ primaryLink ? /* @__PURE__ */ jsx11(
3959
4434
  "a",
3960
4435
  {
3961
4436
  className: "signature-result-card__cta",
@@ -3971,26 +4446,26 @@ function SignatureResultCard({
3971
4446
  }
3972
4447
 
3973
4448
  // src/react/components/ToolResultCard/ToolResultCard.tsx
3974
- import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
4449
+ import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
3975
4450
  function ToolResultCard({
3976
4451
  result
3977
4452
  }) {
3978
- return /* @__PURE__ */ jsxs11(
4453
+ return /* @__PURE__ */ jsxs12(
3979
4454
  "section",
3980
4455
  {
3981
4456
  className: `tool-result-card tool-result-card--${result.status}`,
3982
4457
  "aria-label": result.title,
3983
4458
  children: [
3984
- /* @__PURE__ */ jsxs11("div", { className: "tool-result-card__heading", children: [
3985
- /* @__PURE__ */ jsx11("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
3986
- /* @__PURE__ */ jsx11("strong", { children: result.title })
4459
+ /* @__PURE__ */ jsxs12("div", { className: "tool-result-card__heading", children: [
4460
+ /* @__PURE__ */ jsx12("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
4461
+ /* @__PURE__ */ jsx12("strong", { children: result.title })
3987
4462
  ] }),
3988
- result.description ? /* @__PURE__ */ jsx11("p", { children: result.description }) : null,
3989
- result.details?.length ? /* @__PURE__ */ jsx11("dl", { children: result.details.map((detail) => /* @__PURE__ */ jsxs11("div", { children: [
3990
- /* @__PURE__ */ jsx11("dt", { children: detail.label }),
3991
- /* @__PURE__ */ jsx11("dd", { children: detail.value })
4463
+ result.description ? /* @__PURE__ */ jsx12("p", { children: result.description }) : null,
4464
+ result.details?.length ? /* @__PURE__ */ jsx12("dl", { children: result.details.map((detail) => /* @__PURE__ */ jsxs12("div", { children: [
4465
+ /* @__PURE__ */ jsx12("dt", { children: detail.label }),
4466
+ /* @__PURE__ */ jsx12("dd", { children: detail.value })
3992
4467
  ] }, `${detail.label}:${detail.value}`)) }) : null,
3993
- result.links?.length ? /* @__PURE__ */ jsx11("div", { className: "tool-result-card__links", children: result.links.map((link) => /* @__PURE__ */ jsx11(
4468
+ result.links?.length ? /* @__PURE__ */ jsx12("div", { className: "tool-result-card__links", children: result.links.map((link) => /* @__PURE__ */ jsx12(
3994
4469
  "a",
3995
4470
  {
3996
4471
  href: link.href,
@@ -4006,32 +4481,44 @@ function ToolResultCard({
4006
4481
  }
4007
4482
 
4008
4483
  // src/react/components/VisitorToolResultView/VisitorToolResultView.tsx
4009
- import { jsx as jsx12 } from "react/jsx-runtime";
4484
+ import { jsx as jsx13 } from "react/jsx-runtime";
4010
4485
  function VisitorToolResultView({
4486
+ disabled = false,
4487
+ onToolInput,
4011
4488
  result
4012
4489
  }) {
4490
+ if (result.kind === "input") {
4491
+ return /* @__PURE__ */ jsx13(
4492
+ ToolInputCard,
4493
+ {
4494
+ disabled,
4495
+ surface: result.surface,
4496
+ onSubmit: onToolInput
4497
+ }
4498
+ );
4499
+ }
4013
4500
  if (result.kind === "entity") {
4014
- return /* @__PURE__ */ jsx12(EntityResultCard, { result });
4501
+ return /* @__PURE__ */ jsx13(EntityResultCard, { result });
4015
4502
  }
4016
4503
  if (result.kind === "collection") {
4017
- return /* @__PURE__ */ jsx12(CollectionResultCard, { result });
4504
+ return /* @__PURE__ */ jsx13(CollectionResultCard, { result });
4018
4505
  }
4019
4506
  if (result.kind === "signature") {
4020
- return /* @__PURE__ */ jsx12(SignatureResultCard, { result });
4507
+ return /* @__PURE__ */ jsx13(SignatureResultCard, { result });
4021
4508
  }
4022
4509
  if (result.kind === "summary") {
4023
- return /* @__PURE__ */ jsx12(ToolResultCard, { result });
4510
+ return /* @__PURE__ */ jsx13(ToolResultCard, { result });
4024
4511
  }
4025
4512
  return null;
4026
4513
  }
4027
4514
  function isRenderableVisitorToolResult(result) {
4028
- return result.kind === "summary" || result.kind === "entity" || result.kind === "collection" || result.kind === "signature";
4515
+ return result.kind === "summary" || result.kind === "input" || result.kind === "entity" || result.kind === "collection" || result.kind === "signature";
4029
4516
  }
4030
4517
 
4031
4518
  // src/react/components/AgentRail/AgentRail.tsx
4032
- import { Fragment, jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
4519
+ import { Fragment, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
4033
4520
  function MinimizeIcon() {
4034
- return /* @__PURE__ */ jsx13("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx13(
4521
+ return /* @__PURE__ */ jsx14("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx14(
4035
4522
  "path",
4036
4523
  {
4037
4524
  d: "M3.5 8h9",
@@ -4042,7 +4529,7 @@ function MinimizeIcon() {
4042
4529
  ) });
4043
4530
  }
4044
4531
  function CloseIcon() {
4045
- return /* @__PURE__ */ jsx13("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx13(
4532
+ return /* @__PURE__ */ jsx14("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx14(
4046
4533
  "path",
4047
4534
  {
4048
4535
  d: "M4 4l8 8M12 4l-8 8",
@@ -4053,7 +4540,7 @@ function CloseIcon() {
4053
4540
  ) });
4054
4541
  }
4055
4542
  function NewChatIcon() {
4056
- return /* @__PURE__ */ jsx13("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx13(
4543
+ return /* @__PURE__ */ jsx14("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx14(
4057
4544
  "path",
4058
4545
  {
4059
4546
  d: "M9.5 3.5h3v3M12.25 3.75 8 8M7 4H4.5A1.5 1.5 0 0 0 3 5.5v6A1.5 1.5 0 0 0 4.5 13h6a1.5 1.5 0 0 0 1.5-1.5V9",
@@ -4065,7 +4552,7 @@ function NewChatIcon() {
4065
4552
  ) });
4066
4553
  }
4067
4554
  function ExpandIcon() {
4068
- return /* @__PURE__ */ jsx13("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx13(
4555
+ return /* @__PURE__ */ jsx14("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx14(
4069
4556
  "path",
4070
4557
  {
4071
4558
  d: "M6 3.5H3.5V6M10 3.5h2.5V6M10 12.5h2.5V10M6 12.5H3.5V10",
@@ -4077,7 +4564,7 @@ function ExpandIcon() {
4077
4564
  ) });
4078
4565
  }
4079
4566
  function RestoreIcon() {
4080
- return /* @__PURE__ */ jsx13("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx13(
4567
+ return /* @__PURE__ */ jsx14("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx14(
4081
4568
  "path",
4082
4569
  {
4083
4570
  d: "M5.5 5.5H3.5V7.5M10.5 5.5h2V7.5M10.5 10.5h2V8.5M5.5 10.5H3.5V8.5",
@@ -4106,12 +4593,13 @@ function AgentRail({
4106
4593
  onSubmit,
4107
4594
  onFollowUpSelect,
4108
4595
  onBook,
4109
- onInputResponse
4596
+ onInputResponse,
4597
+ onToolInput
4110
4598
  }) {
4111
4599
  const transcriptRef = useRef3(null);
4112
4600
  const resolvedBrandLabel = brandLabel.trim();
4113
4601
  const resolvedBrandLogoUrl = brandLogoUrl?.trim();
4114
- const [failedLogoUrl, setFailedLogoUrl] = useState7(null);
4602
+ const [failedLogoUrl, setFailedLogoUrl] = useState8(null);
4115
4603
  const showBrandLogo = Boolean(resolvedBrandLogoUrl) && failedLogoUrl !== resolvedBrandLogoUrl;
4116
4604
  const resolvedColorScheme = useAgentColorScheme(colorScheme);
4117
4605
  const brandedTheme = { ...defaultAgentRailTheme, ...theme };
@@ -4122,6 +4610,7 @@ function AgentRail({
4122
4610
  brandSoft: theme?.brandSoft ?? `color-mix(in srgb, ${theme?.brand ?? defaultDarkAgentRailTheme.brand} 18%, ${defaultDarkAgentRailTheme.surface})`,
4123
4611
  border: theme?.border ?? defaultDarkAgentRailTheme.border,
4124
4612
  danger: theme?.danger ?? defaultDarkAgentRailTheme.danger,
4613
+ onBrand: theme?.onBrand ?? defaultDarkAgentRailTheme.onBrand,
4125
4614
  success: theme?.success ?? defaultDarkAgentRailTheme.success,
4126
4615
  surface: theme?.surface ?? defaultDarkAgentRailTheme.surface,
4127
4616
  surfaceMuted: theme?.surfaceMuted ?? defaultDarkAgentRailTheme.surfaceMuted,
@@ -4144,6 +4633,7 @@ function AgentRail({
4144
4633
  "--as-border": resolvedTheme.border,
4145
4634
  "--as-visitor-bubble": resolvedTheme.visitorBubble,
4146
4635
  "--as-visitor-text": resolvedTheme.visitorText,
4636
+ "--as-on-brand": resolvedTheme.onBrand,
4147
4637
  "--as-success": resolvedTheme.success,
4148
4638
  "--as-danger": resolvedTheme.danger,
4149
4639
  "--as-font-body": resolvedTheme.fontBody,
@@ -4155,10 +4645,12 @@ function AgentRail({
4155
4645
  );
4156
4646
  const isBusy = state.phase === "thinking" || state.phase === "running-tools" || state.phase === "streaming" || state.phase === "waiting-input" && pendingInputRequests.length > 0;
4157
4647
  const semanticSurfaceDisabled = isBusy && state.phase !== "waiting-input";
4158
- const showActivity = state.toolSteps.length > 0;
4159
4648
  const visitorToolResults = (state.toolResults ?? []).filter(
4160
4649
  isRenderableVisitorToolResult
4161
4650
  );
4651
+ const activeVisitorToolInput = [...visitorToolResults].reverse().find((result) => result.kind === "input");
4652
+ const visibleVisitorToolResults = activeVisitorToolInput ? [activeVisitorToolInput] : visitorToolResults;
4653
+ const showActivity = state.toolSteps.length > 0 && visibleVisitorToolResults.length === 0 && pendingInputRequests.length === 0 && !state.pendingOffer;
4162
4654
  const hasVisitorMessages2 = state.messages.some(
4163
4655
  (message) => message.role === "visitor"
4164
4656
  );
@@ -4199,10 +4691,14 @@ function AgentRail({
4199
4691
  const bookingReadyText = state.streamingText || (lastIsAgent && lastMessage?.role === "agent" ? lastMessage.text : "");
4200
4692
  const waitingForBooking = !state.pendingOffer && looksLikeBookingReady(bookingReadyText) && (state.phase === "thinking" || state.phase === "running-tools" || state.phase === "streaming");
4201
4693
  const lastAgentText = lastIsAgent && lastMessage?.role === "agent" ? lastMessage.text : "";
4694
+ const hasPendingConfirmation = pendingInputRequests.some(
4695
+ (request) => request.kind === "tool-approval" || request.kind === "question" && (request.options?.length ?? 0) > 0
4696
+ );
4202
4697
  const composerForm = resolveComposerForm({
4203
4698
  agentText: lastAgentText,
4204
4699
  cards: extractToolCards(lastAgentText),
4205
4700
  hasBookingOffer: Boolean(state.pendingOffer) || waitingForBooking,
4701
+ hasPendingConfirmation,
4206
4702
  enabled: lastIsAgent && !isBusy
4207
4703
  });
4208
4704
  useEffect3(() => {
@@ -4216,7 +4712,7 @@ function AgentRail({
4216
4712
  state.followUps,
4217
4713
  state.journey
4218
4714
  ]);
4219
- return /* @__PURE__ */ jsxs12(
4715
+ return /* @__PURE__ */ jsxs13(
4220
4716
  "aside",
4221
4717
  {
4222
4718
  className: `agent-rail not-typeset${mobileFullscreen ? " agent-rail--mobile-fullscreen" : ""}${expanded ? " agent-rail--expanded" : ""}`,
@@ -4230,28 +4726,28 @@ function AgentRail({
4230
4726
  role: mobileFullscreen || expanded ? "dialog" : void 0,
4231
4727
  tabIndex: mobileFullscreen || expanded ? -1 : void 0,
4232
4728
  children: [
4233
- /* @__PURE__ */ jsx13("header", { className: "agent-rail__header", children: /* @__PURE__ */ jsxs12("div", { className: "agent-rail__brand-row", children: [
4234
- onCollapse ? /* @__PURE__ */ jsx13(
4729
+ /* @__PURE__ */ jsx14("header", { className: "agent-rail__header", children: /* @__PURE__ */ jsxs13("div", { className: "agent-rail__brand-row", children: [
4730
+ onCollapse ? /* @__PURE__ */ jsx14(
4235
4731
  "button",
4236
4732
  {
4237
4733
  type: "button",
4238
4734
  className: "agent-rail__collapse",
4239
4735
  "aria-label": "Collapse assist",
4240
4736
  onClick: onCollapse,
4241
- children: /* @__PURE__ */ jsx13(MinimizeIcon, {})
4737
+ children: /* @__PURE__ */ jsx14(MinimizeIcon, {})
4242
4738
  }
4243
- ) : onClose ? /* @__PURE__ */ jsx13(
4739
+ ) : onClose ? /* @__PURE__ */ jsx14(
4244
4740
  "button",
4245
4741
  {
4246
4742
  type: "button",
4247
4743
  className: "agent-rail__close",
4248
4744
  "aria-label": "Close agent",
4249
4745
  onClick: onClose,
4250
- children: /* @__PURE__ */ jsx13(CloseIcon, {})
4746
+ children: /* @__PURE__ */ jsx14(CloseIcon, {})
4251
4747
  }
4252
- ) : /* @__PURE__ */ jsx13("span", { className: "agent-rail__brand-spacer", "aria-hidden": "true" }),
4253
- resolvedBrandLabel || showBrandLogo ? /* @__PURE__ */ jsxs12("span", { className: "agent-rail__identity", children: [
4254
- showBrandLogo ? /* @__PURE__ */ jsx13("span", { className: "agent-rail__brand-mark", "aria-hidden": "true", children: /* @__PURE__ */ jsx13(
4748
+ ) : /* @__PURE__ */ jsx14("span", { className: "agent-rail__brand-spacer", "aria-hidden": "true" }),
4749
+ resolvedBrandLabel || showBrandLogo ? /* @__PURE__ */ jsxs13("span", { className: "agent-rail__identity", children: [
4750
+ showBrandLogo ? /* @__PURE__ */ jsx14("span", { className: "agent-rail__brand-mark", "aria-hidden": "true", children: /* @__PURE__ */ jsx14(
4255
4751
  "img",
4256
4752
  {
4257
4753
  className: "agent-rail__brand-logo",
@@ -4262,10 +4758,10 @@ function AgentRail({
4262
4758
  }
4263
4759
  }
4264
4760
  ) }) : null,
4265
- resolvedBrandLabel ? /* @__PURE__ */ jsx13("span", { className: "agent-rail__brand-label", children: resolvedBrandLabel }) : null
4761
+ resolvedBrandLabel ? /* @__PURE__ */ jsx14("span", { className: "agent-rail__brand-label", children: resolvedBrandLabel }) : null
4266
4762
  ] }) : null,
4267
- /* @__PURE__ */ jsxs12("span", { className: "agent-rail__actions", children: [
4268
- onReset ? /* @__PURE__ */ jsx13(
4763
+ /* @__PURE__ */ jsxs13("span", { className: "agent-rail__actions", children: [
4764
+ onReset ? /* @__PURE__ */ jsx14(
4269
4765
  "button",
4270
4766
  {
4271
4767
  type: "button",
@@ -4273,24 +4769,24 @@ function AgentRail({
4273
4769
  "aria-label": "Start a new conversation",
4274
4770
  disabled: !hasVisitorMessages2,
4275
4771
  onClick: onReset,
4276
- children: /* @__PURE__ */ jsx13(NewChatIcon, {})
4772
+ children: /* @__PURE__ */ jsx14(NewChatIcon, {})
4277
4773
  }
4278
4774
  ) : null,
4279
- onExpandToggle ? /* @__PURE__ */ jsx13(
4775
+ onExpandToggle ? /* @__PURE__ */ jsx14(
4280
4776
  "button",
4281
4777
  {
4282
4778
  type: "button",
4283
4779
  className: "agent-rail__expand",
4284
4780
  "aria-label": expanded ? "Exit full screen" : "Open full screen",
4285
4781
  onClick: onExpandToggle,
4286
- children: expanded ? /* @__PURE__ */ jsx13(RestoreIcon, {}) : /* @__PURE__ */ jsx13(ExpandIcon, {})
4782
+ children: expanded ? /* @__PURE__ */ jsx14(RestoreIcon, {}) : /* @__PURE__ */ jsx14(ExpandIcon, {})
4287
4783
  }
4288
4784
  ) : null
4289
4785
  ] })
4290
4786
  ] }) }),
4291
- /* @__PURE__ */ jsx13("div", { ref: transcriptRef, className: "agent-rail__transcript", children: /* @__PURE__ */ jsxs12("div", { className: "agent-rail__thread", children: [
4292
- !hasVisitorMessages2 ? /* @__PURE__ */ jsxs12("section", { className: "agent-rail__welcome", "aria-label": "Welcome", children: [
4293
- greeting?.role === "agent" ? /* @__PURE__ */ jsx13(
4787
+ /* @__PURE__ */ jsx14("div", { ref: transcriptRef, className: "agent-rail__transcript", children: /* @__PURE__ */ jsxs13("div", { className: "agent-rail__thread", children: [
4788
+ !hasVisitorMessages2 ? /* @__PURE__ */ jsxs13("section", { className: "agent-rail__welcome", "aria-label": "Welcome", children: [
4789
+ greeting?.role === "agent" ? /* @__PURE__ */ jsx14(
4294
4790
  MessageBubble,
4295
4791
  {
4296
4792
  message: greeting,
@@ -4298,7 +4794,7 @@ function AgentRail({
4298
4794
  onBook
4299
4795
  }
4300
4796
  ) : null,
4301
- showIdleFollowUps ? /* @__PURE__ */ jsx13("div", { className: "agent-rail__followups-slot", children: /* @__PURE__ */ jsx13(
4797
+ showIdleFollowUps ? /* @__PURE__ */ jsx14("div", { className: "agent-rail__followups-slot", children: /* @__PURE__ */ jsx14(
4302
4798
  FollowUpChips,
4303
4799
  {
4304
4800
  suggestions: state.followUps,
@@ -4307,7 +4803,7 @@ function AgentRail({
4307
4803
  onSelect: (suggestion) => onFollowUpSelect?.(suggestion.label)
4308
4804
  }
4309
4805
  ) }) : null,
4310
- showActivity ? /* @__PURE__ */ jsx13(
4806
+ showActivity ? /* @__PURE__ */ jsx14(
4311
4807
  AgentActivityBubble,
4312
4808
  {
4313
4809
  brandLabel: resolvedBrandLabel,
@@ -4316,8 +4812,16 @@ function AgentRail({
4316
4812
  steps: state.toolSteps
4317
4813
  }
4318
4814
  ) : null,
4319
- visitorToolResults.map((result) => /* @__PURE__ */ jsx13(VisitorToolResultView, { result }, result.id)),
4320
- pendingInputRequests.map((request) => /* @__PURE__ */ jsx13(
4815
+ visibleVisitorToolResults.map((result) => /* @__PURE__ */ jsx14(
4816
+ VisitorToolResultView,
4817
+ {
4818
+ result,
4819
+ disabled: semanticSurfaceDisabled,
4820
+ onToolInput
4821
+ },
4822
+ result.id
4823
+ )),
4824
+ pendingInputRequests.slice(0, 1).map((request) => /* @__PURE__ */ jsx14(
4321
4825
  HumanInputCard,
4322
4826
  {
4323
4827
  request,
@@ -4326,8 +4830,8 @@ function AgentRail({
4326
4830
  request.requestId
4327
4831
  ))
4328
4832
  ] }) : null,
4329
- visibleMessages.map((message, index) => /* @__PURE__ */ jsxs12("div", { className: "agent-rail__turn-block", children: [
4330
- /* @__PURE__ */ jsx13(
4833
+ visibleMessages.map((message, index) => /* @__PURE__ */ jsxs13("div", { className: "agent-rail__turn-block", children: [
4834
+ /* @__PURE__ */ jsx14(
4331
4835
  MessageBubble,
4332
4836
  {
4333
4837
  message,
@@ -4336,8 +4840,8 @@ function AgentRail({
4336
4840
  onBook
4337
4841
  }
4338
4842
  ),
4339
- index === lastVisitorIndex ? /* @__PURE__ */ jsxs12(Fragment, { children: [
4340
- showActivity ? /* @__PURE__ */ jsx13(
4843
+ index === lastVisitorIndex ? /* @__PURE__ */ jsxs13(Fragment, { children: [
4844
+ showActivity ? /* @__PURE__ */ jsx14(
4341
4845
  AgentActivityBubble,
4342
4846
  {
4343
4847
  brandLabel: resolvedBrandLabel,
@@ -4346,8 +4850,16 @@ function AgentRail({
4346
4850
  steps: state.toolSteps
4347
4851
  }
4348
4852
  ) : null,
4349
- visitorToolResults.map((result) => /* @__PURE__ */ jsx13(VisitorToolResultView, { result }, result.id)),
4350
- pendingInputRequests.map((request) => /* @__PURE__ */ jsx13(
4853
+ visibleVisitorToolResults.map((result) => /* @__PURE__ */ jsx14(
4854
+ VisitorToolResultView,
4855
+ {
4856
+ result,
4857
+ disabled: semanticSurfaceDisabled,
4858
+ onToolInput
4859
+ },
4860
+ result.id
4861
+ )),
4862
+ pendingInputRequests.slice(0, 1).map((request) => /* @__PURE__ */ jsx14(
4351
4863
  HumanInputCard,
4352
4864
  {
4353
4865
  request,
@@ -4357,7 +4869,7 @@ function AgentRail({
4357
4869
  ))
4358
4870
  ] }) : null
4359
4871
  ] }, message.id)),
4360
- streamingMessage ? /* @__PURE__ */ jsx13(
4872
+ streamingMessage ? /* @__PURE__ */ jsx14(
4361
4873
  MessageBubble,
4362
4874
  {
4363
4875
  message: streamingMessage,
@@ -4366,22 +4878,17 @@ function AgentRail({
4366
4878
  onBook
4367
4879
  }
4368
4880
  ) : null,
4369
- waitingForBooking ? /* @__PURE__ */ jsx13(
4370
- BookingCard,
4371
- {
4372
- offer: { type: "booking_offer", eventTypes: [], slots: [] }
4373
- }
4374
- ) : null,
4375
- state.error ? /* @__PURE__ */ jsxs12("section", { className: "agent-rail__error", role: "alert", children: [
4376
- /* @__PURE__ */ jsxs12("div", { children: [
4377
- /* @__PURE__ */ jsx13("strong", { children: "Something went wrong" }),
4378
- /* @__PURE__ */ jsx13("p", { children: state.error })
4881
+ waitingForBooking ? /* @__PURE__ */ jsx14(BookingCardLoader, {}) : null,
4882
+ state.error ? /* @__PURE__ */ jsxs13("section", { className: "agent-rail__error", role: "alert", children: [
4883
+ /* @__PURE__ */ jsxs13("div", { children: [
4884
+ /* @__PURE__ */ jsx14("strong", { children: "Something went wrong" }),
4885
+ /* @__PURE__ */ jsx14("p", { children: state.error })
4379
4886
  ] }),
4380
- onRetry ? /* @__PURE__ */ jsx13("button", { type: "button", onClick: onRetry, children: "Try again" }) : null
4887
+ onRetry ? /* @__PURE__ */ jsx14("button", { type: "button", onClick: onRetry, children: "Try again" }) : null
4381
4888
  ] }) : null
4382
4889
  ] }) }),
4383
- /* @__PURE__ */ jsxs12("div", { className: "agent-rail__composer-wrap", children: [
4384
- /* @__PURE__ */ jsx13(
4890
+ /* @__PURE__ */ jsxs13("div", { className: "agent-rail__composer-wrap", children: [
4891
+ /* @__PURE__ */ jsx14(
4385
4892
  Composer,
4386
4893
  {
4387
4894
  variant: expanded || mobileFullscreen ? "dock" : "default",
@@ -4391,9 +4898,9 @@ function AgentRail({
4391
4898
  onSubmit
4392
4899
  }
4393
4900
  ),
4394
- /* @__PURE__ */ jsx13("div", { className: "agent-rail__footer", children: /* @__PURE__ */ jsxs12("p", { children: [
4395
- /* @__PURE__ */ jsx13("span", { children: "AI can make mistakes. Check important info." }),
4396
- /* @__PURE__ */ jsx13("span", { children: poweredByLabel })
4901
+ /* @__PURE__ */ jsx14("div", { className: "agent-rail__footer", children: /* @__PURE__ */ jsxs13("p", { children: [
4902
+ /* @__PURE__ */ jsx14("span", { children: "AI can make mistakes. Check important info." }),
4903
+ /* @__PURE__ */ jsx14("span", { children: poweredByLabel })
4397
4904
  ] }) })
4398
4905
  ] })
4399
4906
  ]
@@ -4402,9 +4909,9 @@ function AgentRail({
4402
4909
  }
4403
4910
 
4404
4911
  // src/react/components/AssistEdgeTab/AssistEdgeTab.tsx
4405
- import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
4912
+ import { Fragment as Fragment2, jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
4406
4913
  function SparklesIcon() {
4407
- return /* @__PURE__ */ jsxs13(
4914
+ return /* @__PURE__ */ jsxs14(
4408
4915
  "svg",
4409
4916
  {
4410
4917
  className: "assist-edge-tab__sparkles",
@@ -4412,21 +4919,21 @@ function SparklesIcon() {
4412
4919
  fill: "none",
4413
4920
  "aria-hidden": "true",
4414
4921
  children: [
4415
- /* @__PURE__ */ jsx14(
4922
+ /* @__PURE__ */ jsx15(
4416
4923
  "path",
4417
4924
  {
4418
4925
  d: "M8 1.2l.95 2.7 2.85.05-2.25 1.75.8 2.75L8 6.7 5.65 8.45l.8-2.75L4.2 3.95l2.85-.05L8 1.2z",
4419
4926
  fill: "currentColor"
4420
4927
  }
4421
4928
  ),
4422
- /* @__PURE__ */ jsx14(
4929
+ /* @__PURE__ */ jsx15(
4423
4930
  "path",
4424
4931
  {
4425
4932
  d: "M14.2 6.4l.55 1.55 1.65.03-1.3 1 .46 1.58-1.36-1-1.36 1 .46-1.58-1.3-1 1.65-.03.55-1.55z",
4426
4933
  fill: "currentColor"
4427
4934
  }
4428
4935
  ),
4429
- /* @__PURE__ */ jsx14(
4936
+ /* @__PURE__ */ jsx15(
4430
4937
  "path",
4431
4938
  {
4432
4939
  d: "M3.1 9.1l.4 1.15 1.22.02-.96.74.34 1.17-1-.74-1 .74.34-1.17-.96-.74 1.22-.02.4-1.15z",
@@ -4440,7 +4947,7 @@ function SparklesIcon() {
4440
4947
  function TabMarkIcon({ customIconUrl }) {
4441
4948
  const url = customIconUrl?.trim();
4442
4949
  if (url) {
4443
- return /* @__PURE__ */ jsx14(
4950
+ return /* @__PURE__ */ jsx15(
4444
4951
  "img",
4445
4952
  {
4446
4953
  alt: "",
@@ -4450,10 +4957,10 @@ function TabMarkIcon({ customIconUrl }) {
4450
4957
  }
4451
4958
  );
4452
4959
  }
4453
- return /* @__PURE__ */ jsx14(SparklesIcon, {});
4960
+ return /* @__PURE__ */ jsx15(SparklesIcon, {});
4454
4961
  }
4455
4962
  function ChevronLeftIcon() {
4456
- return /* @__PURE__ */ jsx14("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx14(
4963
+ return /* @__PURE__ */ jsx15("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx15(
4457
4964
  "path",
4458
4965
  {
4459
4966
  d: "M10 4L6 8l4 4",
@@ -4465,7 +4972,7 @@ function ChevronLeftIcon() {
4465
4972
  ) });
4466
4973
  }
4467
4974
  function ChevronDownIcon() {
4468
- return /* @__PURE__ */ jsx14("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx14(
4975
+ return /* @__PURE__ */ jsx15("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx15(
4469
4976
  "path",
4470
4977
  {
4471
4978
  d: "M4 6l4 4 4-4",
@@ -4477,7 +4984,7 @@ function ChevronDownIcon() {
4477
4984
  ) });
4478
4985
  }
4479
4986
  function DragDots() {
4480
- return /* @__PURE__ */ jsx14("span", { className: "assist-edge-tab__dots", "aria-hidden": "true", children: Array.from({ length: 12 }, (_, index) => /* @__PURE__ */ jsx14("i", {}, index)) });
4987
+ return /* @__PURE__ */ jsx15("span", { className: "assist-edge-tab__dots", "aria-hidden": "true", children: Array.from({ length: 12 }, (_, index) => /* @__PURE__ */ jsx15("i", {}, index)) });
4481
4988
  }
4482
4989
  var VARIANT_COPY = {
4483
4990
  outline: { label: "Ask anything", aria: "Ask anything" },
@@ -4523,7 +5030,7 @@ function AssistEdgeTab({
4523
5030
  ...resolvedTextColor ? { "--as-text": resolvedTextColor } : {},
4524
5031
  colorScheme: resolvedColorScheme
4525
5032
  };
4526
- return /* @__PURE__ */ jsxs13(
5033
+ return /* @__PURE__ */ jsxs14(
4527
5034
  "button",
4528
5035
  {
4529
5036
  type: "button",
@@ -4535,15 +5042,15 @@ function AssistEdgeTab({
4535
5042
  tabIndex: visible ? 0 : -1,
4536
5043
  onClick: onOpen,
4537
5044
  children: [
4538
- mobile ? /* @__PURE__ */ jsxs13(Fragment2, { children: [
4539
- /* @__PURE__ */ jsxs13(
5045
+ mobile ? /* @__PURE__ */ jsxs14(Fragment2, { children: [
5046
+ /* @__PURE__ */ jsxs14(
4540
5047
  "span",
4541
5048
  {
4542
5049
  className: "assist-edge-tab__mark assist-edge-tab__mark--mobile",
4543
5050
  "aria-hidden": "true",
4544
5051
  children: [
4545
- /* @__PURE__ */ jsx14(TabMarkIcon, { customIconUrl }),
4546
- showLogo ? /* @__PURE__ */ jsx14(
5052
+ /* @__PURE__ */ jsx15(TabMarkIcon, { customIconUrl }),
5053
+ showLogo ? /* @__PURE__ */ jsx15(
4547
5054
  "img",
4548
5055
  {
4549
5056
  className: "assist-edge-tab__logo",
@@ -4557,11 +5064,11 @@ function AssistEdgeTab({
4557
5064
  ]
4558
5065
  }
4559
5066
  ),
4560
- /* @__PURE__ */ jsx14("span", { className: "assist-edge-tab__label", children: visibleLabel })
4561
- ] }) : variant === "outline" ? /* @__PURE__ */ jsxs13(Fragment2, { children: [
4562
- /* @__PURE__ */ jsxs13("span", { className: "assist-edge-tab__mark", "aria-hidden": "true", children: [
4563
- /* @__PURE__ */ jsx14(TabMarkIcon, { customIconUrl }),
4564
- showLogo ? /* @__PURE__ */ jsx14(
5067
+ /* @__PURE__ */ jsx15("span", { className: "assist-edge-tab__label", children: visibleLabel })
5068
+ ] }) : variant === "outline" ? /* @__PURE__ */ jsxs14(Fragment2, { children: [
5069
+ /* @__PURE__ */ jsxs14("span", { className: "assist-edge-tab__mark", "aria-hidden": "true", children: [
5070
+ /* @__PURE__ */ jsx15(TabMarkIcon, { customIconUrl }),
5071
+ showLogo ? /* @__PURE__ */ jsx15(
4565
5072
  "img",
4566
5073
  {
4567
5074
  className: "assist-edge-tab__logo",
@@ -4573,18 +5080,18 @@ function AssistEdgeTab({
4573
5080
  }
4574
5081
  ) : null
4575
5082
  ] }),
4576
- /* @__PURE__ */ jsx14("span", { className: "assist-edge-tab__label", children: visibleLabel }),
4577
- /* @__PURE__ */ jsx14(ChevronDownIcon, {})
5083
+ /* @__PURE__ */ jsx15("span", { className: "assist-edge-tab__label", children: visibleLabel }),
5084
+ /* @__PURE__ */ jsx15(ChevronDownIcon, {})
4578
5085
  ] }) : null,
4579
- variant === "ask" ? /* @__PURE__ */ jsxs13(Fragment2, { children: [
4580
- /* @__PURE__ */ jsx14(ChevronLeftIcon, {}),
4581
- /* @__PURE__ */ jsx14("span", { className: "assist-edge-tab__label", children: visibleLabel }),
4582
- /* @__PURE__ */ jsx14(DragDots, {})
5086
+ variant === "ask" ? /* @__PURE__ */ jsxs14(Fragment2, { children: [
5087
+ /* @__PURE__ */ jsx15(ChevronLeftIcon, {}),
5088
+ /* @__PURE__ */ jsx15("span", { className: "assist-edge-tab__label", children: visibleLabel }),
5089
+ /* @__PURE__ */ jsx15(DragDots, {})
4583
5090
  ] }) : null,
4584
- variant === "fill" ? /* @__PURE__ */ jsxs13(Fragment2, { children: [
4585
- /* @__PURE__ */ jsxs13("span", { className: "assist-edge-tab__mark", "aria-hidden": "true", children: [
4586
- /* @__PURE__ */ jsx14(TabMarkIcon, { customIconUrl }),
4587
- showLogo ? /* @__PURE__ */ jsx14(
5091
+ variant === "fill" ? /* @__PURE__ */ jsxs14(Fragment2, { children: [
5092
+ /* @__PURE__ */ jsxs14("span", { className: "assist-edge-tab__mark", "aria-hidden": "true", children: [
5093
+ /* @__PURE__ */ jsx15(TabMarkIcon, { customIconUrl }),
5094
+ showLogo ? /* @__PURE__ */ jsx15(
4588
5095
  "img",
4589
5096
  {
4590
5097
  className: "assist-edge-tab__logo",
@@ -4596,8 +5103,8 @@ function AssistEdgeTab({
4596
5103
  }
4597
5104
  ) : null
4598
5105
  ] }),
4599
- /* @__PURE__ */ jsx14("span", { className: "assist-edge-tab__label", children: visibleLabel }),
4600
- /* @__PURE__ */ jsx14(ChevronLeftIcon, {})
5106
+ /* @__PURE__ */ jsx15("span", { className: "assist-edge-tab__label", children: visibleLabel }),
5107
+ /* @__PURE__ */ jsx15(ChevronLeftIcon, {})
4601
5108
  ] }) : null
4602
5109
  ]
4603
5110
  }
@@ -4605,7 +5112,7 @@ function AssistEdgeTab({
4605
5112
  }
4606
5113
 
4607
5114
  // src/react/components/AgentWidget/AgentWidget.tsx
4608
- import { useEffect as useEffect6, useRef as useRef4, useState as useState9 } from "react";
5115
+ import { useEffect as useEffect6, useRef as useRef4, useState as useState10 } from "react";
4609
5116
 
4610
5117
  // src/react/page-shift.ts
4611
5118
  import { useEffect as useEffect4 } from "react";
@@ -4688,9 +5195,9 @@ function usePageShift(input) {
4688
5195
  }
4689
5196
 
4690
5197
  // src/react/hooks/useIsMobile.ts
4691
- import { useEffect as useEffect5, useState as useState8 } from "react";
5198
+ import { useEffect as useEffect5, useState as useState9 } from "react";
4692
5199
  function useIsMobile(breakpoint = 767) {
4693
- const [isMobile, setIsMobile] = useState8(
5200
+ const [isMobile, setIsMobile] = useState9(
4694
5201
  () => typeof window !== "undefined" && window.matchMedia(`(max-width: ${breakpoint}px)`).matches
4695
5202
  );
4696
5203
  useEffect5(() => {
@@ -4704,7 +5211,7 @@ function useIsMobile(breakpoint = 767) {
4704
5211
  }
4705
5212
 
4706
5213
  // src/react/components/AgentWidget/AgentWidget.tsx
4707
- import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
5214
+ import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
4708
5215
  function AgentWidget({
4709
5216
  indexId,
4710
5217
  customerId,
@@ -4723,8 +5230,8 @@ function AgentWidget({
4723
5230
  const isMobile = useIsMobile();
4724
5231
  const placement = normalizeAgentPlacement(placementInput);
4725
5232
  const railSlotRef = useRef4(null);
4726
- const [railCollapsed, setRailCollapsed] = useState9(defaultCollapsed);
4727
- const [railExpanded, setRailExpanded] = useState9(false);
5233
+ const [railCollapsed, setRailCollapsed] = useState10(defaultCollapsed);
5234
+ const [railExpanded, setRailExpanded] = useState10(false);
4728
5235
  const pageShiftActive = shouldApplyPageShift({
4729
5236
  pageShift,
4730
5237
  isMobile,
@@ -4754,7 +5261,10 @@ function AgentWidget({
4754
5261
  visitorBubble: branding.colors.primary
4755
5262
  } : {},
4756
5263
  ...branding?.colors?.primarySoft ? { brandSoft: branding.colors.primarySoft } : {},
4757
- ...branding?.colors?.primaryForeground ? { visitorText: branding.colors.primaryForeground } : {},
5264
+ ...branding?.colors?.primaryForeground ? {
5265
+ onBrand: branding.colors.primaryForeground,
5266
+ visitorText: branding.colors.primaryForeground
5267
+ } : {},
4758
5268
  ...branding?.colors?.surface ? { surface: branding.colors.surface } : {},
4759
5269
  ...branding?.colors?.surfaceMuted ? { surfaceMuted: branding.colors.surfaceMuted } : {},
4760
5270
  ...branding?.colors?.text ? { text: branding.colors.text } : {},
@@ -4815,19 +5325,19 @@ function AgentWidget({
4815
5325
  window.addEventListener("keydown", handleKeyDown);
4816
5326
  return () => window.removeEventListener("keydown", handleKeyDown);
4817
5327
  }, [isMobile, railCollapsed, railExpanded]);
4818
- return /* @__PURE__ */ jsxs14("div", { className: "webless-agent-root", children: [
4819
- /* @__PURE__ */ jsx15(
5328
+ return /* @__PURE__ */ jsxs15("div", { className: "webless-agent-root", children: [
5329
+ /* @__PURE__ */ jsx16(
4820
5330
  "div",
4821
5331
  {
4822
5332
  className: `webless-agent-root__shell${railCollapsed ? " webless-agent-root__shell--collapsed" : ""}${railExpanded ? " webless-agent-root__shell--expanded" : ""}`,
4823
- children: /* @__PURE__ */ jsx15(
5333
+ children: /* @__PURE__ */ jsx16(
4824
5334
  "div",
4825
5335
  {
4826
5336
  ref: railSlotRef,
4827
5337
  className: "webless-agent-root__rail-slot",
4828
5338
  inert: railCollapsed || void 0,
4829
5339
  "aria-hidden": railCollapsed,
4830
- children: /* @__PURE__ */ jsx15(
5340
+ children: /* @__PURE__ */ jsx16(
4831
5341
  AgentRail,
4832
5342
  {
4833
5343
  theme,
@@ -4855,7 +5365,7 @@ function AgentWidget({
4855
5365
  )
4856
5366
  }
4857
5367
  ),
4858
- railCollapsed ? /* @__PURE__ */ jsx15(
5368
+ railCollapsed ? /* @__PURE__ */ jsx16(
4859
5369
  AssistEdgeTab,
4860
5370
  {
4861
5371
  variant: placement.variant,
@@ -4883,6 +5393,9 @@ function AgentWidget({
4883
5393
  export {
4884
5394
  DEFAULT_RUNTIME_ORIGIN,
4885
5395
  resolveAgentRuntimeConfig,
5396
+ AGENT_STRUCTURED_TOOL_INPUT_SCHEMA_VERSION,
5397
+ AGENT_STRUCTURED_TOOL_INPUT_HEADER,
5398
+ formatAgentStructuredToolInput,
4886
5399
  builtInVisitorToolResultRegistry,
4887
5400
  presentVisitorToolResult,
4888
5401
  useAgentChat,
@@ -4901,4 +5414,4 @@ export {
4901
5414
  AssistEdgeTab,
4902
5415
  AgentWidget
4903
5416
  };
4904
- //# sourceMappingURL=chunk-U2TIUZJM.js.map
5417
+ //# sourceMappingURL=chunk-UR5QZZ2F.js.map