@dudousxd/nestjs-agent 1.3.0 → 1.4.0
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/durable/index.cjs +22 -0
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.js +23 -1
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +22 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/durable/index.cjs
CHANGED
|
@@ -1252,6 +1252,7 @@ var AgentService = class {
|
|
|
1252
1252
|
*/
|
|
1253
1253
|
async answer(actor, toolCallId2, answers2 = {}) {
|
|
1254
1254
|
await this.assertOwnsToolCall(actor, toolCallId2);
|
|
1255
|
+
await this.assertAnswersFit(toolCallId2, answers2);
|
|
1255
1256
|
const reply = {
|
|
1256
1257
|
answers: answers2,
|
|
1257
1258
|
answeredByRef: actor.id
|
|
@@ -1520,6 +1521,27 @@ var AgentService = class {
|
|
|
1520
1521
|
}
|
|
1521
1522
|
}
|
|
1522
1523
|
/**
|
|
1524
|
+
* Check a reply against the questions it answers before it is signalled: every submitted value a
|
|
1525
|
+
* question's own rules accept (a typed input's type, bounds and pattern; a pick from the offered
|
|
1526
|
+
* options), and every `required` question answered — by the reply, or by the defaults an omitted
|
|
1527
|
+
* question falls back to. A reply the loop would have to drop parts of is refused here instead, so
|
|
1528
|
+
* the person who typed it hears why. Needs the store to hand back the call's recorded questions;
|
|
1529
|
+
* without that seam the loop's own filtering is the only check.
|
|
1530
|
+
*/
|
|
1531
|
+
async assertAnswersFit(toolCallId2, answers2) {
|
|
1532
|
+
if (this.store.toolCallInput === void 0) {
|
|
1533
|
+
return;
|
|
1534
|
+
}
|
|
1535
|
+
const questions = (0, import_nestjs_agent_core8.readElicitationQuestions)(await this.store.toolCallInput(toolCallId2));
|
|
1536
|
+
for (const question of questions) {
|
|
1537
|
+
const submitted = Object.hasOwn(answers2, question.id) ? answers2[question.id] : void 0;
|
|
1538
|
+
const problem = (0, import_nestjs_agent_core8.validateElicitationAnswer)(question, submitted ?? question.defaults ?? []);
|
|
1539
|
+
if (problem !== null) {
|
|
1540
|
+
throw new import_common6.BadRequestException(`answers["${question.id}"] ${problem}`);
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
/**
|
|
1523
1545
|
* Authorization seam for approve/reject. The call's recorded approver decides who may settle it:
|
|
1524
1546
|
* the requester (the default, and every call recorded before approvers existed) is the thread's
|
|
1525
1547
|
* own actor — the ownership check this always was; any other approver goes through the policy's
|