@dudousxd/nestjs-agent-react 0.6.4 → 0.7.1
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/index.cjs +16 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -4
- package/dist/index.d.ts +13 -4
- package/dist/index.js +16 -16
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1057,7 +1057,7 @@ __name(isAwaitingApproval, "isAwaitingApproval");
|
|
|
1057
1057
|
function buildToolCall(part, options) {
|
|
1058
1058
|
const toolCallId = part.toolCallId;
|
|
1059
1059
|
const awaiting = isAwaitingApproval(part);
|
|
1060
|
-
const
|
|
1060
|
+
const sending = awaiting ? options?.submitting(toolCallId) ?? null : null;
|
|
1061
1061
|
return {
|
|
1062
1062
|
part,
|
|
1063
1063
|
toolCallId,
|
|
@@ -1065,12 +1065,12 @@ function buildToolCall(part, options) {
|
|
|
1065
1065
|
isAwaitingApproval: awaiting,
|
|
1066
1066
|
approve: {
|
|
1067
1067
|
available: awaiting && options?.canApprove === true,
|
|
1068
|
-
isSubmitting,
|
|
1068
|
+
isSubmitting: sending === "approve",
|
|
1069
1069
|
run: /* @__PURE__ */ __name(() => options?.approve(toolCallId), "run")
|
|
1070
1070
|
},
|
|
1071
1071
|
reject: {
|
|
1072
1072
|
available: awaiting && options?.canReject === true,
|
|
1073
|
-
isSubmitting,
|
|
1073
|
+
isSubmitting: sending === "reject",
|
|
1074
1074
|
run: /* @__PURE__ */ __name(() => options?.reject(toolCallId), "run")
|
|
1075
1075
|
},
|
|
1076
1076
|
error: options?.errorOf(toolCallId) ?? null
|
|
@@ -1168,7 +1168,7 @@ function buildElicitationBlock(key, part, request, options) {
|
|
|
1168
1168
|
}))
|
|
1169
1169
|
};
|
|
1170
1170
|
});
|
|
1171
|
-
const
|
|
1171
|
+
const sending = isPending ? options.submitting(toolCallId) : null;
|
|
1172
1172
|
return {
|
|
1173
1173
|
kind: "elicitation",
|
|
1174
1174
|
key,
|
|
@@ -1181,12 +1181,12 @@ function buildElicitationBlock(key, part, request, options) {
|
|
|
1181
1181
|
error: options.errorOf(toolCallId),
|
|
1182
1182
|
answer: {
|
|
1183
1183
|
available: isPending && options.canAnswer,
|
|
1184
|
-
isSubmitting,
|
|
1184
|
+
isSubmitting: sending === "answer",
|
|
1185
1185
|
run: /* @__PURE__ */ __name(() => options.answer(toolCallId), "run")
|
|
1186
1186
|
},
|
|
1187
1187
|
skip: {
|
|
1188
1188
|
available: isPending && options.canSkip,
|
|
1189
|
-
isSubmitting,
|
|
1189
|
+
isSubmitting: sending === "skip",
|
|
1190
1190
|
run: /* @__PURE__ */ __name(() => options.skip(toolCallId), "run")
|
|
1191
1191
|
}
|
|
1192
1192
|
};
|
|
@@ -1475,7 +1475,7 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
|
|
|
1475
1475
|
const [copied, setCopied] = (0, import_react4.useState)(() => /* @__PURE__ */ new Set());
|
|
1476
1476
|
const [openReasoning, setOpenReasoning] = (0, import_react4.useState)(() => /* @__PURE__ */ new Map());
|
|
1477
1477
|
const [picks, setPicks] = (0, import_react4.useState)(() => /* @__PURE__ */ new Map());
|
|
1478
|
-
const [settling, setSettling] = (0, import_react4.useState)(() => /* @__PURE__ */ new
|
|
1478
|
+
const [settling, setSettling] = (0, import_react4.useState)(() => /* @__PURE__ */ new Map());
|
|
1479
1479
|
const [settleErrors, setSettleErrors] = (0, import_react4.useState)(() => /* @__PURE__ */ new Map());
|
|
1480
1480
|
const latest = (0, import_react4.useRef)({
|
|
1481
1481
|
options,
|
|
@@ -1518,7 +1518,7 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
|
|
|
1518
1518
|
const pick = (0, import_react4.useCallback)((toolCallId, questionId, values) => {
|
|
1519
1519
|
setPicks((current) => new Map(current).set(pickKey(toolCallId, questionId), values));
|
|
1520
1520
|
}, []);
|
|
1521
|
-
const settle = (0, import_react4.useCallback)((toolCallId, send) => {
|
|
1521
|
+
const settle = (0, import_react4.useCallback)((toolCallId, action, send) => {
|
|
1522
1522
|
setSettleErrors((current) => {
|
|
1523
1523
|
if (!current.has(toolCallId)) {
|
|
1524
1524
|
return current;
|
|
@@ -1527,10 +1527,10 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
|
|
|
1527
1527
|
next.delete(toolCallId);
|
|
1528
1528
|
return next;
|
|
1529
1529
|
});
|
|
1530
|
-
setSettling((current) => new
|
|
1530
|
+
setSettling((current) => new Map(current).set(toolCallId, action));
|
|
1531
1531
|
const failed = /* @__PURE__ */ __name((error) => {
|
|
1532
1532
|
setSettling((current) => {
|
|
1533
|
-
const next = new
|
|
1533
|
+
const next = new Map(current);
|
|
1534
1534
|
next.delete(toolCallId);
|
|
1535
1535
|
return next;
|
|
1536
1536
|
});
|
|
@@ -1548,14 +1548,14 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
|
|
|
1548
1548
|
if (!onAnswer) {
|
|
1549
1549
|
return;
|
|
1550
1550
|
}
|
|
1551
|
-
settle(toolCallId, () => onAnswer(toolCallId, answersFor(current.picks, toolCallId)));
|
|
1551
|
+
settle(toolCallId, "answer", () => onAnswer(toolCallId, answersFor(current.picks, toolCallId)));
|
|
1552
1552
|
}, [
|
|
1553
1553
|
settle
|
|
1554
1554
|
]);
|
|
1555
1555
|
const skip = (0, import_react4.useCallback)((toolCallId) => {
|
|
1556
1556
|
const onSkip = latest.current.options.onSkip;
|
|
1557
1557
|
if (onSkip) {
|
|
1558
|
-
settle(toolCallId, () => onSkip(toolCallId));
|
|
1558
|
+
settle(toolCallId, "skip", () => onSkip(toolCallId));
|
|
1559
1559
|
}
|
|
1560
1560
|
}, [
|
|
1561
1561
|
settle
|
|
@@ -1563,7 +1563,7 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
|
|
|
1563
1563
|
const approve = (0, import_react4.useCallback)((toolCallId) => {
|
|
1564
1564
|
const onApprove = latest.current.options.onApprove;
|
|
1565
1565
|
if (onApprove) {
|
|
1566
|
-
settle(toolCallId, () => onApprove(toolCallId));
|
|
1566
|
+
settle(toolCallId, "approve", () => onApprove(toolCallId));
|
|
1567
1567
|
}
|
|
1568
1568
|
}, [
|
|
1569
1569
|
settle
|
|
@@ -1571,7 +1571,7 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
|
|
|
1571
1571
|
const reject = (0, import_react4.useCallback)((toolCallId) => {
|
|
1572
1572
|
const onReject = latest.current.options.onReject;
|
|
1573
1573
|
if (onReject) {
|
|
1574
|
-
settle(toolCallId, () => onReject(toolCallId));
|
|
1574
|
+
settle(toolCallId, "reject", () => onReject(toolCallId));
|
|
1575
1575
|
}
|
|
1576
1576
|
}, [
|
|
1577
1577
|
settle
|
|
@@ -1696,7 +1696,7 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
|
|
|
1696
1696
|
canSkip: options.onSkip !== void 0,
|
|
1697
1697
|
answer,
|
|
1698
1698
|
skip,
|
|
1699
|
-
|
|
1699
|
+
submitting: /* @__PURE__ */ __name((toolCallId) => settling.get(toolCallId) ?? null, "submitting"),
|
|
1700
1700
|
errorOf: /* @__PURE__ */ __name((toolCallId) => settleErrors.get(toolCallId) ?? null, "errorOf")
|
|
1701
1701
|
}
|
|
1702
1702
|
} : {},
|
|
@@ -1706,7 +1706,7 @@ function useTranscriptItems({ messages, visibleStart, streamingMessageId, option
|
|
|
1706
1706
|
canReject: options.onReject !== void 0,
|
|
1707
1707
|
approve,
|
|
1708
1708
|
reject,
|
|
1709
|
-
|
|
1709
|
+
submitting: /* @__PURE__ */ __name((toolCallId) => settling.get(toolCallId) ?? null, "submitting"),
|
|
1710
1710
|
errorOf: /* @__PURE__ */ __name((toolCallId) => settleErrors.get(toolCallId) ?? null, "errorOf")
|
|
1711
1711
|
}
|
|
1712
1712
|
} : {}
|