@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.js
CHANGED
|
@@ -1048,7 +1048,7 @@ AgentDepsFactory2 = _ts_decorate5([
|
|
|
1048
1048
|
], AgentDepsFactory2);
|
|
1049
1049
|
|
|
1050
1050
|
// src/agent.service.ts
|
|
1051
|
-
import { AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE4, REQUESTER_APPROVER, mayDecideApproval } from "@dudousxd/nestjs-agent-core";
|
|
1051
|
+
import { AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE4, REQUESTER_APPROVER, mayDecideApproval, readElicitationQuestions, validateElicitationAnswer } from "@dudousxd/nestjs-agent-core";
|
|
1052
1052
|
import { BadRequestException, ForbiddenException, GoneException, Inject as Inject5, Injectable as Injectable5, NotFoundException, NotImplementedException, Optional as Optional3 } from "@nestjs/common";
|
|
1053
1053
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
1054
1054
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1224,6 +1224,7 @@ var AgentService = class {
|
|
|
1224
1224
|
*/
|
|
1225
1225
|
async answer(actor, toolCallId2, answers2 = {}) {
|
|
1226
1226
|
await this.assertOwnsToolCall(actor, toolCallId2);
|
|
1227
|
+
await this.assertAnswersFit(toolCallId2, answers2);
|
|
1227
1228
|
const reply = {
|
|
1228
1229
|
answers: answers2,
|
|
1229
1230
|
answeredByRef: actor.id
|
|
@@ -1492,6 +1493,27 @@ var AgentService = class {
|
|
|
1492
1493
|
}
|
|
1493
1494
|
}
|
|
1494
1495
|
/**
|
|
1496
|
+
* Check a reply against the questions it answers before it is signalled: every submitted value a
|
|
1497
|
+
* question's own rules accept (a typed input's type, bounds and pattern; a pick from the offered
|
|
1498
|
+
* options), and every `required` question answered — by the reply, or by the defaults an omitted
|
|
1499
|
+
* question falls back to. A reply the loop would have to drop parts of is refused here instead, so
|
|
1500
|
+
* the person who typed it hears why. Needs the store to hand back the call's recorded questions;
|
|
1501
|
+
* without that seam the loop's own filtering is the only check.
|
|
1502
|
+
*/
|
|
1503
|
+
async assertAnswersFit(toolCallId2, answers2) {
|
|
1504
|
+
if (this.store.toolCallInput === void 0) {
|
|
1505
|
+
return;
|
|
1506
|
+
}
|
|
1507
|
+
const questions = readElicitationQuestions(await this.store.toolCallInput(toolCallId2));
|
|
1508
|
+
for (const question of questions) {
|
|
1509
|
+
const submitted = Object.hasOwn(answers2, question.id) ? answers2[question.id] : void 0;
|
|
1510
|
+
const problem = validateElicitationAnswer(question, submitted ?? question.defaults ?? []);
|
|
1511
|
+
if (problem !== null) {
|
|
1512
|
+
throw new BadRequestException(`answers["${question.id}"] ${problem}`);
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
/**
|
|
1495
1517
|
* Authorization seam for approve/reject. The call's recorded approver decides who may settle it:
|
|
1496
1518
|
* the requester (the default, and every call recorded before approvers existed) is the thread's
|
|
1497
1519
|
* own actor — the ownership check this always was; any other approver goes through the policy's
|