@tangle-network/agent-app 0.60.109 → 0.60.110
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/dist/assistant/index.js +1 -1
- package/dist/{chunk-NBZQYRRM.js → chunk-FERGTHQF.js} +28 -7
- package/dist/chunk-FERGTHQF.js.map +1 -0
- package/dist/web-react/durable-chat-cards.d.ts +2 -1
- package/dist/web-react/index.js +5 -1
- package/dist/web-react/interaction-card-support.d.ts +7 -0
- package/dist/web-react/interaction-question-card.d.ts +9 -3
- package/package.json +1 -1
- package/dist/chunk-NBZQYRRM.js.map +0 -1
package/dist/assistant/index.js
CHANGED
|
@@ -188,6 +188,21 @@ function buildAnswerData(fields, values) {
|
|
|
188
188
|
}
|
|
189
189
|
return data;
|
|
190
190
|
}
|
|
191
|
+
function firstUnansweredRequiredField(fields, values) {
|
|
192
|
+
return fields.find((field) => field.required === true && fieldAnswer(field, values) === null) ?? null;
|
|
193
|
+
}
|
|
194
|
+
function shortLabel(label, max = 48) {
|
|
195
|
+
const text = label.trim().replace(/\s+/g, " ");
|
|
196
|
+
if (text.length <= max) return text;
|
|
197
|
+
const cut = text.slice(0, max);
|
|
198
|
+
const space = cut.lastIndexOf(" ");
|
|
199
|
+
return `${(space > max / 2 ? cut.slice(0, space) : cut).replace(/[\s,.:;?!]+$/, "")}\u2026`;
|
|
200
|
+
}
|
|
201
|
+
function missingAnswerHint(field, fieldCount, verb) {
|
|
202
|
+
const select = field.type === "select" ? field : null;
|
|
203
|
+
const action = select ? `${select.multi === true ? "Choose at least one option" : "Choose an option"}${select.allowCustom === true ? " or write your own" : ""}` : field.type === "boolean" ? "Choose Yes or No" : field.type === "number" ? "Enter a number" : "Type an answer";
|
|
204
|
+
return fieldCount > 1 ? `${action} for \u201C${shortLabel(field.label)}\u201D to ${verb}.` : `${action} to ${verb}.`;
|
|
205
|
+
}
|
|
191
206
|
function isLateAnswerableStatus(status) {
|
|
192
207
|
return status === "expired" || status === "cancelled";
|
|
193
208
|
}
|
|
@@ -392,8 +407,8 @@ var STATUS_LABELS = interactionStatusLabels({
|
|
|
392
407
|
declined: "Declined"
|
|
393
408
|
});
|
|
394
409
|
var TERMINAL_NOTES = interactionTerminalNotes("question", {
|
|
395
|
-
expired: "
|
|
396
|
-
cancelled: "The agent withdrew this question. Answer
|
|
410
|
+
expired: "This question timed out, so the agent went on without your answer. Answer here to send it as a new message.",
|
|
411
|
+
cancelled: "The agent withdrew this question. Answer here to send it as a new message.",
|
|
397
412
|
declined: "You declined this question."
|
|
398
413
|
});
|
|
399
414
|
function InteractionQuestionCard({
|
|
@@ -411,7 +426,8 @@ function InteractionQuestionCard({
|
|
|
411
426
|
const [values, setValues] = useState3(() => fieldValuesFromAnswers(interaction.fields, interaction.answers));
|
|
412
427
|
const [submitting, setSubmitting] = useState3(false);
|
|
413
428
|
const [localStatus, setLocalStatus] = useState3(null);
|
|
414
|
-
const [
|
|
429
|
+
const [lateAnswerOutcome, setLateAnswerOutcome] = useState3(null);
|
|
430
|
+
const lateAnswerSent = lateAnswerOutcome !== null;
|
|
415
431
|
const [error, setError] = useState3(null);
|
|
416
432
|
const submitInFlightRef = useRef2(false);
|
|
417
433
|
const [declining, setDeclining] = useState3(false);
|
|
@@ -420,7 +436,7 @@ function InteractionQuestionCard({
|
|
|
420
436
|
setAskId(interaction.id);
|
|
421
437
|
setValues(fieldValuesFromAnswers(interaction.fields, interaction.answers));
|
|
422
438
|
setLocalStatus(null);
|
|
423
|
-
|
|
439
|
+
setLateAnswerOutcome(null);
|
|
424
440
|
setError(null);
|
|
425
441
|
}
|
|
426
442
|
useEffect2(() => {
|
|
@@ -460,7 +476,7 @@ function InteractionQuestionCard({
|
|
|
460
476
|
setError("The new message was not sent. Try again from this card.");
|
|
461
477
|
return;
|
|
462
478
|
}
|
|
463
|
-
|
|
479
|
+
setLateAnswerOutcome(accepted === "queued" ? "queued" : "sent");
|
|
464
480
|
}
|
|
465
481
|
async function submit() {
|
|
466
482
|
if (lateAnswerable) {
|
|
@@ -528,6 +544,8 @@ function InteractionQuestionCard({
|
|
|
528
544
|
submitLabel = "Submitting\u2026";
|
|
529
545
|
}
|
|
530
546
|
const showDeclineButton = declinable && canWrite && status === "pending";
|
|
547
|
+
const unanswered = showSubmitButton && !disabled && !answerData ? firstUnansweredRequiredField(interaction.fields, values) : null;
|
|
548
|
+
const missingHint = unanswered ? missingAnswerHint(unanswered, interaction.fields.length, lateAnswerable ? "send" : "submit") : null;
|
|
531
549
|
return (
|
|
532
550
|
// The card LANDS. This is the moment the run stopped and handed the turn
|
|
533
551
|
// back — a surface that blinks into place reads as chrome that was always
|
|
@@ -633,6 +651,7 @@ function InteractionQuestionCard({
|
|
|
633
651
|
terminalNote && /* @__PURE__ */ jsx2("p", { className: "mt-3 text-sm text-muted-foreground", children: terminalNote }),
|
|
634
652
|
(showSubmitButton || showTimeoutNote) && /* @__PURE__ */ jsxs("div", { className: "mt-4 flex flex-wrap items-center justify-end gap-2", children: [
|
|
635
653
|
showTimeoutNote && /* @__PURE__ */ jsx2("div", { className: "mr-auto text-sm text-muted-foreground", children: timeoutNote }),
|
|
654
|
+
missingHint && /* @__PURE__ */ jsx2("span", { "aria-live": "polite", className: "text-sm text-muted-foreground", children: missingHint }),
|
|
636
655
|
showDeclineButton && /* @__PURE__ */ jsx2(InteractionActionButton, { variant: "outline", onClick: () => void decline(), disabled, children: declining ? "Declining\u2026" : "Decline" }),
|
|
637
656
|
showSubmitButton && /* @__PURE__ */ jsx2(InteractionActionButton, { onClick: () => void submit(), disabled: disabled || !answerData, children: submitLabel })
|
|
638
657
|
] }),
|
|
@@ -642,7 +661,7 @@ function InteractionQuestionCard({
|
|
|
642
661
|
] }) }),
|
|
643
662
|
lateAnswerSent && /* @__PURE__ */ jsx2("div", { className: "mt-4 flex items-center justify-end", children: /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 text-sm text-muted-foreground", children: [
|
|
644
663
|
/* @__PURE__ */ jsx2(CheckGlyph, { className: "h-3 w-3" }),
|
|
645
|
-
"Sent as new message"
|
|
664
|
+
lateAnswerOutcome === "queued" ? "Queued. It sends when the agent finishes." : "Sent as new message"
|
|
646
665
|
] }) })
|
|
647
666
|
] })
|
|
648
667
|
);
|
|
@@ -6647,6 +6666,8 @@ export {
|
|
|
6647
6666
|
fieldValuesFromAnswers,
|
|
6648
6667
|
fieldAnswer,
|
|
6649
6668
|
buildAnswerData,
|
|
6669
|
+
firstUnansweredRequiredField,
|
|
6670
|
+
missingAnswerHint,
|
|
6650
6671
|
isLateAnswerableStatus,
|
|
6651
6672
|
hasSecretField,
|
|
6652
6673
|
lateAnswerMessage,
|
|
@@ -6778,4 +6799,4 @@ export {
|
|
|
6778
6799
|
useThinkingSeconds,
|
|
6779
6800
|
ChatMessages
|
|
6780
6801
|
};
|
|
6781
|
-
//# sourceMappingURL=chunk-
|
|
6802
|
+
//# sourceMappingURL=chunk-FERGTHQF.js.map
|