@tangle-network/agent-app 0.43.64 → 0.43.66
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.d.ts +4 -4
- package/dist/assistant/index.js +5 -5
- package/dist/{attachment-validation-tPRp-PP1.d.ts → attachment-validation-B2FFna9E.d.ts} +1 -1
- package/dist/chat-routes/index.d.ts +5 -5
- package/dist/chat-routes/index.js +6 -6
- package/dist/chat-store/index.d.ts +4 -4
- package/dist/chat-store/index.js +3 -3
- package/dist/{chunk-3OFQFW5K.js → chunk-3ALFBTIW.js} +10 -8
- package/dist/chunk-3ALFBTIW.js.map +1 -0
- package/dist/{chunk-7YW6EBDX.js → chunk-3JUTOVUH.js} +2 -2
- package/dist/{chunk-YKOM4ZLQ.js → chunk-3ZK5IJSW.js} +1 -1
- package/dist/chunk-3ZK5IJSW.js.map +1 -0
- package/dist/{chunk-BG52UKNN.js → chunk-5EPIPT4V.js} +2 -2
- package/dist/{chunk-K3LIPKFV.js → chunk-6GQ5DKFK.js} +2 -2
- package/dist/{chunk-BPSV5AA2.js → chunk-FMDMI25K.js} +2 -2
- package/dist/{chunk-DTSPS2HV.js → chunk-X3N2H6JE.js} +2 -2
- package/dist/{chunk-C3NSB66C.js → chunk-YTSEDJWA.js} +59 -10
- package/dist/chunk-YTSEDJWA.js.map +1 -0
- package/dist/{contract-TjB68uqA.d.ts → contract-B3h7peV3.d.ts} +30 -5
- package/dist/durable-chat/index.d.ts +1 -1
- package/dist/durable-chat/index.js +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -6
- package/dist/interactions/index.d.ts +2 -2
- package/dist/interactions/index.js +2 -2
- package/dist/{parts-n9XUon0a.d.ts → parts-Bg8qcDvB.d.ts} +1 -1
- package/dist/sandbox/index.d.ts +14 -0
- package/dist/sandbox/index.js +1 -1
- package/dist/stream/index.d.ts +3 -3
- package/dist/stream/index.js +2 -2
- package/dist/{stream-normalizer-BlCP_Cdd.d.ts → stream-normalizer-QYUl4vnl.d.ts} +1 -1
- package/dist/web-react/index.d.ts +53 -8
- package/dist/web-react/index.js +7 -5
- package/package.json +1 -1
- package/dist/chunk-3OFQFW5K.js.map +0 -1
- package/dist/chunk-C3NSB66C.js.map +0 -1
- package/dist/chunk-YKOM4ZLQ.js.map +0 -1
- /package/dist/{chunk-7YW6EBDX.js.map → chunk-3JUTOVUH.js.map} +0 -0
- /package/dist/{chunk-BG52UKNN.js.map → chunk-5EPIPT4V.js.map} +0 -0
- /package/dist/{chunk-K3LIPKFV.js.map → chunk-6GQ5DKFK.js.map} +0 -0
- /package/dist/{chunk-BPSV5AA2.js.map → chunk-FMDMI25K.js.map} +0 -0
- /package/dist/{chunk-DTSPS2HV.js.map → chunk-X3N2H6JE.js.map} +0 -0
|
@@ -9,14 +9,14 @@ import {
|
|
|
9
9
|
checkAttachmentType,
|
|
10
10
|
sanitizeAttachmentFileName,
|
|
11
11
|
sniffBinary
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-FMDMI25K.js";
|
|
13
13
|
import {
|
|
14
14
|
stepActivityFlowTrace
|
|
15
15
|
} from "./chunk-FBVLEGEG.js";
|
|
16
16
|
import {
|
|
17
17
|
attachmentPartsFromMessageParts,
|
|
18
18
|
formatBytes
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-X3N2H6JE.js";
|
|
20
20
|
import {
|
|
21
21
|
cancelStatusFor,
|
|
22
22
|
fieldAcceptsFreeText,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
parseInteractionRequest,
|
|
27
27
|
persistedPartToInteraction,
|
|
28
28
|
questionInteractionContentSignature
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-3ZK5IJSW.js";
|
|
30
30
|
import {
|
|
31
31
|
parsePlanSubmittedEvent,
|
|
32
32
|
persistedPartToPlan
|
|
@@ -502,6 +502,26 @@ async function responseErrorMessage(res) {
|
|
|
502
502
|
}
|
|
503
503
|
return { message: `Answer failed (${res.status})` };
|
|
504
504
|
}
|
|
505
|
+
function settleInteractionSubmit(run, timeoutMs = INTERACTION_SUBMIT_TIMEOUT_MS) {
|
|
506
|
+
return new Promise((resolve) => {
|
|
507
|
+
const timer = setTimeout(
|
|
508
|
+
() => resolve({ ok: false, expired: false, message: INTERACTION_SUBMIT_TIMEOUT_MESSAGE }),
|
|
509
|
+
timeoutMs
|
|
510
|
+
);
|
|
511
|
+
const settle = (result) => {
|
|
512
|
+
clearTimeout(timer);
|
|
513
|
+
resolve(result);
|
|
514
|
+
};
|
|
515
|
+
Promise.resolve().then(run).then(
|
|
516
|
+
settle,
|
|
517
|
+
(err) => settle({
|
|
518
|
+
ok: false,
|
|
519
|
+
expired: false,
|
|
520
|
+
message: err instanceof Error ? err.message : "Failed to submit the answer"
|
|
521
|
+
})
|
|
522
|
+
);
|
|
523
|
+
});
|
|
524
|
+
}
|
|
505
525
|
function createInteractionAnswerSubmitter(options) {
|
|
506
526
|
const timeoutMs = options.timeoutMs ?? INTERACTION_SUBMIT_TIMEOUT_MS;
|
|
507
527
|
return async (submission) => {
|
|
@@ -606,6 +626,13 @@ function QuestionOptionList({
|
|
|
606
626
|
function selectField(field) {
|
|
607
627
|
return field.type === "select" ? field : null;
|
|
608
628
|
}
|
|
629
|
+
function freeTextField(field) {
|
|
630
|
+
return field.type === "text" || field.type === "secret" ? field : null;
|
|
631
|
+
}
|
|
632
|
+
function textFieldMaxLength(field) {
|
|
633
|
+
const max = field.maxLength;
|
|
634
|
+
return typeof max === "number" && Number.isInteger(max) && max > 0 ? max : void 0;
|
|
635
|
+
}
|
|
609
636
|
function valuesWithSelected(values, field, optionValue) {
|
|
610
637
|
const current = values[field.name]?.selected ?? [];
|
|
611
638
|
let selected = [optionValue];
|
|
@@ -629,6 +656,10 @@ function InteractionQuestionCard({
|
|
|
629
656
|
submitAnswer,
|
|
630
657
|
onResolved,
|
|
631
658
|
onLateAnswer,
|
|
659
|
+
kindLabel,
|
|
660
|
+
sourceNote,
|
|
661
|
+
timeoutNote,
|
|
662
|
+
renderMarkdown,
|
|
632
663
|
className
|
|
633
664
|
}) {
|
|
634
665
|
const [values, setValues] = useState3(() => fieldValuesFromAnswers(interaction.fields, interaction.answers));
|
|
@@ -637,6 +668,14 @@ function InteractionQuestionCard({
|
|
|
637
668
|
const [lateAnswerSent, setLateAnswerSent] = useState3(false);
|
|
638
669
|
const [error, setError] = useState3(null);
|
|
639
670
|
const submitInFlightRef = useRef3(false);
|
|
671
|
+
const [askId, setAskId] = useState3(interaction.id);
|
|
672
|
+
if (askId !== interaction.id) {
|
|
673
|
+
setAskId(interaction.id);
|
|
674
|
+
setValues(fieldValuesFromAnswers(interaction.fields, interaction.answers));
|
|
675
|
+
setLocalStatus(null);
|
|
676
|
+
setLateAnswerSent(false);
|
|
677
|
+
setError(null);
|
|
678
|
+
}
|
|
640
679
|
useEffect3(() => {
|
|
641
680
|
if (!interaction.answers) return;
|
|
642
681
|
setValues(fieldValuesFromAnswers(interaction.fields, interaction.answers));
|
|
@@ -686,7 +725,9 @@ function InteractionQuestionCard({
|
|
|
686
725
|
setSubmitting(true);
|
|
687
726
|
setError(null);
|
|
688
727
|
try {
|
|
689
|
-
const result = await
|
|
728
|
+
const result = await settleInteractionSubmit(
|
|
729
|
+
() => submitAnswer({ id: interaction.id, outcome: "accepted", data: answerData })
|
|
730
|
+
);
|
|
690
731
|
if (result.ok) {
|
|
691
732
|
setLocalStatus("answered");
|
|
692
733
|
onResolved?.(interaction.id, "answered", answerData);
|
|
@@ -705,6 +746,7 @@ function InteractionQuestionCard({
|
|
|
705
746
|
}
|
|
706
747
|
const terminalNote = secretLateAnswerBlocked ? "This question asked for a secret, so it cannot be sent as a new chat message. Ask the agent to request it again." : TERMINAL_NOTES[status];
|
|
707
748
|
const showSubmitButton = status === "pending" || canWrite && lateAnswerable && !lateAnswerSent;
|
|
749
|
+
const showTimeoutNote = timeoutNote != null && status === "pending";
|
|
708
750
|
let submitLabel = "Submit answer";
|
|
709
751
|
if (lateAnswerable) {
|
|
710
752
|
submitLabel = submitting ? "Sending\u2026" : "Send as new message";
|
|
@@ -714,16 +756,17 @@ function InteractionQuestionCard({
|
|
|
714
756
|
return /* @__PURE__ */ jsxs3("div", { className: `rounded-xl border border-border bg-card p-4 shadow-sm ${className ?? ""}`, children: [
|
|
715
757
|
/* @__PURE__ */ jsxs3("div", { className: "mb-3 flex flex-wrap items-center justify-between gap-2", children: [
|
|
716
758
|
/* @__PURE__ */ jsxs3("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
717
|
-
/* @__PURE__ */ jsx4(InteractionBadge, { variant: "outline", children: "Question" }),
|
|
759
|
+
/* @__PURE__ */ jsx4(InteractionBadge, { variant: "outline", children: kindLabel ?? "Question" }),
|
|
718
760
|
/* @__PURE__ */ jsx4(InteractionBadge, { variant: answered ? "default" : status === "expired" || status === "declined" ? "destructive" : "outline", children: STATUS_LABELS[status] })
|
|
719
761
|
] }),
|
|
720
|
-
/* @__PURE__ */ jsx4("span", { className: "text-xs text-muted-foreground", children: "The agent asked for input" })
|
|
762
|
+
/* @__PURE__ */ jsx4("span", { className: "text-xs text-muted-foreground", children: sourceNote ?? "The agent asked for input" })
|
|
721
763
|
] }),
|
|
722
764
|
interaction.title.trim() && interaction.fields.every((field) => field.label !== interaction.title) && /* @__PURE__ */ jsx4("p", { className: "mb-3 text-sm font-medium leading-5 text-foreground", children: interaction.title }),
|
|
723
|
-
interaction.body && /* @__PURE__ */ jsx4("p", { className: "mb-3 text-sm leading-5 text-muted-foreground", children: interaction.body }),
|
|
765
|
+
interaction.body && (renderMarkdown ? /* @__PURE__ */ jsx4("div", { className: "mb-3 text-sm leading-5 text-muted-foreground", children: renderMarkdown(interaction.body) }) : /* @__PURE__ */ jsx4("p", { className: "mb-3 text-sm leading-5 text-muted-foreground", children: interaction.body })),
|
|
724
766
|
/* @__PURE__ */ jsx4("div", { className: "space-y-4", children: interaction.fields.map((field) => {
|
|
725
767
|
const value = values[field.name] ?? {};
|
|
726
768
|
const select = selectField(field);
|
|
769
|
+
const freeText = freeTextField(field);
|
|
727
770
|
return /* @__PURE__ */ jsxs3("fieldset", { className: "space-y-2", children: [
|
|
728
771
|
/* @__PURE__ */ jsx4("p", { className: "text-sm font-medium leading-5 text-foreground", children: field.label }),
|
|
729
772
|
select ? /* @__PURE__ */ jsxs3("div", { className: "space-y-2", children: [
|
|
@@ -784,6 +827,7 @@ function InteractionQuestionCard({
|
|
|
784
827
|
"aria-label": field.label,
|
|
785
828
|
onChange: (event) => setFieldValue(field.name, { text: event.target.value }),
|
|
786
829
|
placeholder: field.placeholder,
|
|
830
|
+
maxLength: freeText ? textFieldMaxLength(freeText) : void 0,
|
|
787
831
|
className: FIELD_INPUT_CLASSES
|
|
788
832
|
}
|
|
789
833
|
) : /* @__PURE__ */ jsx4(
|
|
@@ -794,15 +838,19 @@ function InteractionQuestionCard({
|
|
|
794
838
|
"aria-label": field.label,
|
|
795
839
|
onChange: (event) => setFieldValue(field.name, { text: event.target.value }),
|
|
796
840
|
rows: 3,
|
|
841
|
+
maxLength: freeText ? textFieldMaxLength(freeText) : void 0,
|
|
797
842
|
placeholder: field.type === "text" ? field.placeholder : void 0,
|
|
798
843
|
className: FIELD_INPUT_CLASSES
|
|
799
844
|
}
|
|
800
845
|
)
|
|
801
846
|
] }, field.name);
|
|
802
847
|
}) }),
|
|
803
|
-
error && /* @__PURE__ */ jsx4("p", { className: "mt-3 text-xs text-destructive", children: error }),
|
|
848
|
+
error && /* @__PURE__ */ jsx4("p", { role: "alert", className: "mt-3 text-xs text-destructive", children: error }),
|
|
804
849
|
terminalNote && /* @__PURE__ */ jsx4("p", { className: "mt-3 text-xs text-muted-foreground", children: terminalNote }),
|
|
805
|
-
showSubmitButton && /* @__PURE__ */
|
|
850
|
+
(showSubmitButton || showTimeoutNote) && /* @__PURE__ */ jsxs3("div", { className: "mt-4 flex flex-wrap items-center justify-end gap-2", children: [
|
|
851
|
+
showTimeoutNote && /* @__PURE__ */ jsx4("div", { className: "mr-auto text-xs text-muted-foreground", children: timeoutNote }),
|
|
852
|
+
showSubmitButton && /* @__PURE__ */ jsx4(InteractionActionButton, { onClick: () => void submit(), disabled: disabled || !answerData, children: submitLabel })
|
|
853
|
+
] }),
|
|
806
854
|
answered && /* @__PURE__ */ jsx4("div", { className: "mt-4 flex items-center justify-end", children: /* @__PURE__ */ jsxs3("span", { className: "inline-flex items-center gap-1 text-xs text-muted-foreground", children: [
|
|
807
855
|
/* @__PURE__ */ jsx4(CheckGlyph, { className: "h-3 w-3" }),
|
|
808
856
|
"Answered"
|
|
@@ -3835,6 +3883,7 @@ export {
|
|
|
3835
3883
|
INTERACTION_SUBMIT_TIMEOUT_MS,
|
|
3836
3884
|
INTERACTION_SUBMIT_TIMEOUT_MESSAGE,
|
|
3837
3885
|
responseErrorMessage,
|
|
3886
|
+
settleInteractionSubmit,
|
|
3838
3887
|
createInteractionAnswerSubmitter,
|
|
3839
3888
|
InteractionBadge,
|
|
3840
3889
|
InteractionActionButton,
|
|
@@ -3891,4 +3940,4 @@ export {
|
|
|
3891
3940
|
useThinkingSeconds,
|
|
3892
3941
|
ChatMessages
|
|
3893
3942
|
};
|
|
3894
|
-
//# sourceMappingURL=chunk-
|
|
3943
|
+
//# sourceMappingURL=chunk-YTSEDJWA.js.map
|