Repository navigation
Releases: irzix/nestjs-agentic
Release list
nestjs-agentic@1.6.0
@nestjs-agentic/rag@1.6.0
@nestjs-agentic/orchestration@1.6.0
@nestjs-agentic/openai@1.6.0
Minor Changes
-
cf18702: Add structured output: constrain an agent's final answer to a JSON Schema, with validation and bounded repair.
outputSchema(JSON Schema) onAgentConfigandRunInput, with optionalstructuredOutputoptions:name,description,strict(defaultfalse),maxRepairAttempts(default2), and a pluggablevalidatefor Ajv, zod, or any validator.- The built-in runtime sends the schema as the new optional
ModelRequest.outputFormat. Adapters that setsupportsStructuredOutputforward it natively; for others the schema is described in that request's system prompt only. Existing adapters keep working unchanged. - The final answer is parsed (tolerating code fences and surrounding prose), validated, and repaired by re-prompting with the specific issues. The parsed value is returned as
AgentResult.structured, andrunner.run<T>()types it. A turn that never conforms fails withStructuredOutputError. Repair rounds count toward usage and budgets and stay out of session history. - Streaming emits
output_rejectedbefore each repair round andstructuredonfinal_answer. - A dependency-free
validateJsonSchemacovering the subset providers' structured-output modes use, plusparseJsonAnswer. - A turn that would run through a
RuntimeAdapterwith anoutputSchemathrowsStructuredOutputNotSupportedErrorinstead of returning unvalidated text. - A run that sets its own
outputSchemadoes not inherit the agent's options (itsvalidatein particular). Schemas with an invalid pattern or an unresolvable$refthrowInvalidOutputSchemaErrorbefore any model call. A refusal (ModelResponse.refusal) fails the turn without repair. A failed turn's conversation is still saved, and an approval whose resumed answer misses its schema is recorded as settled. The schema and repair state survive approval resume and checkpoint recovery, and an agent schema that broke after a run started does not block resuming it. - The validator also covers
patternProperties, OpenAPInullable, draft-07 tuples, code-point string lengths, patterns that need the non-Unicode regex mode, and deep recursive$refs. OpenAiModelAdaptersendsoutputFormatasresponse_format: { type: 'json_schema' }(non-object roots wrapped as{ value }, with root-relative$refs kept pointing at the original root), sends schemas outside strict mode's subset non-strict instead of letting the request fail, reports refusals, and takesstructuredOutput: 'prompt'for servers withoutjson_schemasupport.
@nestjs-agentic/memory@1.6.0
@nestjs-agentic/memory@1.6.0
@nestjs-agentic/mcp@1.6.0
@nestjs-agentic/jev@1.6.0
Minor Changes
-
68218ea: New package:
@nestjs-agentic/jev, Jev (TypeSafe System One) decisions for nestjs-agentic governance.JevActionGate(options)creates an injectable tool policy that maps Jev's calibrated probability that a call is safe ontoallow(at or aboveallowAt),require_approval(between the thresholds, withrequiredApprovalsas a number or a function of the probability for dual control), anddeny(belowdenyBelow). Every decision reason, allow included, records the probability and thresholds for the audit trail. Unnamed gates get distinct names.JevOutputGate(options)creates an output rail that withholds tool output, by default prompt injections, before the model sees it.describecontrols exactly what is sent to the TypeSafe API; an error it throws propagates instead of being treated as an outage.onErrordecides what happens when Jev is unreachable, slow (timeoutMs, enforced even for clients that ignore the abort signal), or answers malformed: human review by default for action gates, withonErrorRequiredApprovalsapprovers (required whenrequiredApprovalsis a function), and deny for output gates. A circuit breaker, shared throughJevModule, makes calls fail fast after repeated failures. A cancelled run throwsExecutionCancelledErrorrather than followingonError.JevModule.forRoot()/forRootAsync()share one client and defaults; each gate can also take its ownclient.jevFaithfulnessJudgeandjevTaskJudgeplug into@nestjs-agentic/evaluation'sFaithfulnessMetricandLLMAsAJudgeMetric.- Works with
TypeSafeClientfrom@typesafe-ai/sdk(optional peer dependency) or any client with a compatiblesystemOne().
Core: an
allowpolicy result, before or after execution, may carry an optionalreason, recorded on the audit trail (withaudit.includeAllowDecisionsfor tool calls) and never shown to the model. When several policies require approval, a policy without its ownttlSecondsnow counts with the module'sapprovalTtlSecondswhen the shortest lifetime is chosen, so it is no longer outlived by another policy's longer explicit lifetime.
@nestjs-agentic/evaluation@1.6.0
Minor Changes
-
2482962: Add retrieval-quality metrics for RAG pipelines.
- New
RetrievalEvalMetriccontract, parallel toEvalMetric, scored against retrieval output (RetrievalContext, whichRAGContextsatisfies structurally) rather than anAgentResult. Dataset items carry ground truth asrelevantIds, with optionalrelevanceGrades. - Metrics:
RecallAtKMetric,PrecisionAtKMetric,HitRateAtKMetric,ReciprocalRankMetric(MRR),NdcgAtKMetric(graded relevance), andFaithfulnessMetricwith a pluggable judge that sees the passages plus any hydrated, compressed, or graph context the pipeline produced. - Relevance is matched per chunk (
matchOn: 'id'), per document ('parentId'), or by any function of the chunk. Results are ranked bycontext.scoreswhen present, or bychunksorder withrankBy: 'order'for rerankers such as MMR. RetrievalBenchmarkRunnerruns a labeled query set through aRAGPipeline, aKnowledgeBase, or any retriever function, optionally generates answers for answer-level metrics, and reports per-metric averages for CI gates. Its defaults areRecall@k,Precision@k,MRR@k, andnDCG@k, withkseparate fromtopK. A failing retrieval scores its item 0, a failing answer step is reported asanswerErrorwithout discarding the retrieval scores, and a failing metric fails only itself.
- New
Patch Changes
@nestjs-agentic/core@1.6.0
Minor Changes
-
22276c8: Add dual control (N-of-M approvals) for high-risk actions.
- A
require_approvalpolicy decision can setrequiredApprovals. The withheld tool then runs only after that many distinct approvers have calledApprovalService.approve(). Earlier calls return apending_approvalresult withsignaturesandrequiredApprovals. Every signature runs through theApprovalAuthorizer, tenant isolation, and separation-of-duties checks and must carryactor.userId. A repeated signature from the sameuserIdis refused rather than counted twice, and a single authorizedreject()vetoes. - New optional
ApprovalStore.addSignature(id, signature)appends a signature atomically and claims the approval on the one that meets the threshold, so exactly one caller settles it. Implemented byInMemoryApprovalStore,PostgresApprovalStore, andRedisApprovalStore(when the client exposeseval; the approval and its signatures share one key). Stores without it keep working for single-approver approvals, and a multi-approver decision on such a store is denied instead of downgraded. - Behavior change: when a policy returns
require_approval, the remaining policies on the tool still run. A laterdenynow wins, and the approval takes the strictest terms across policies (most approvers, shortestttlSeconds). Previously the first approval requirement stopped evaluation, so later policies, including deny rules, never ran for that call, because an approved call skips policies. - Each signature records the version of the approval it was given for (
approvalVersion), and completion is refused if any signature was given for a different version. Every settlement path checks the signature count before the tool runs. Cancellation is honored before store writes, and an approval consumed by a cancelled call is put back. RedisApprovalStoreaccepts anevalFnadapter (for node-redis v4 and similar).claim()uses an atomic script when the client hasevalbut nogetdel. The signature script reads the record without decoding JSON.- New
approval_signedaudit event per counted signature,requiredApprovalsonapproval_requested, andsignaturesonapproval_settled. runApprovalStoreContractgains capability-gated groups foraddSignature: threshold accumulation, duplicate rejection, and atomicity under concurrent signers. Its argument round-trip check no longer depends on JSON key order, which PostgreSQLjsonbdoes not preserve.- New exports:
ApprovalSignature,ApprovalSignatureResult,ApprovalSignedAuditEvent,ApprovalSignaturesUnsupportedError,requiredApprovalsOf.
- A
-
68218ea: New package:
@nestjs-agentic/jev, Jev (TypeSafe System One) decisions for nestjs-agentic governance.JevActionGate(options)creates an injectable tool policy that maps Jev's calibrated probability that a call is safe ontoallow(at or aboveallowAt),require_approval(between the thresholds, withrequiredApprovalsas a number or a function of the probability for dual control), anddeny(belowdenyBelow). Every decision reason, allow included, records the probability and thresholds for the audit trail. Unnamed gates get distinct names.JevOutputGate(options)creates an output rail that withholds tool output, by default prompt injections, before the model sees it.describecontrols exactly what is sent to the TypeSafe API; an error it throws propagates instead of being treated as an outage.onErrordecides what happens when Jev is unreachable, slow (timeoutMs, enforced even for clients that ignore the abort signal), or answers malformed: human review by default for action gates, withonErrorRequiredApprovalsapprovers (required whenrequiredApprovalsis a function), and deny for output gates. A circuit breaker, shared throughJevModule, makes calls fail fast after repeated failures. A cancelled run throwsExecutionCancelledErrorrather than followingonError.JevModule.forRoot()/forRootAsync()share one client and defaults; each gate can also take its ownclient.jevFaithfulnessJudgeandjevTaskJudgeplug into@nestjs-agentic/evaluation'sFaithfulnessMetricandLLMAsAJudgeMetric.- Works with
TypeSafeClientfrom@typesafe-ai/sdk(optional peer dependency) or any client with a compatiblesystemOne().
Core: an
allowpolicy result, before or after execution, may carry an optionalreason, recorded on the audit trail (withaudit.includeAllowDecisionsfor tool calls) and never shown to the model. When several policies require approval, a policy without its ownttlSecondsnow counts with the module'sapprovalTtlSecondswhen the shortest lifetime is chosen, so it is no longer outlived by another policy's longer explicit lifetime. -
f81f32e: Redact errors before they reach observers.
Observers usually forward events to external telemetry, and provider SDK errors routinely carry request headers, API keys, and prompt content.
ObserverNotifiernow scrubs every error-carrying field before dispatch:AgentErrorEvent.error,ModelRetryEvent.error,CircuitBreakerEvent.reason, and theerrortext of failed tool results inToolResultEventandAgentEndEvent.- Behavior change: by default observers now receive a
RedactedErrorinstead of the original error. It keepsname, a credential-masked message capped at 500 characters, numericstatus/statusCode, a shortcode, stack frames, and a redactedcausechain (3 links deep). Request config, headers, response bodies, and every other property are dropped. The error thrown to the caller ofrun()is unchanged. - Configure it with
observability.errorRedactiononAgenticModuleOptions: passcreateErrorRedactor({ maxMessageLength, maxCauseDepth, patterns, mask }), any(error: unknown) => Error(optionally withredactTextfor free text), or'none'to restore raw errors. Any other value is rejected.ObserverNotifieraccepts the same setting aserrorRedaction. - New exports:
ErrorRedactor,ObservabilityOptions,ErrorRedactorOptions,RedactedError,createErrorRedactor,defaultErrorRedactor.
- Behavior change: by default observers now receive a
-
cf18702: Add structured output: constrain an agent's final answer to a JSON Schema, with validation and bounded repair.
outputSchema(JSON Schema) onAgentConfigandRunInput, with optionalstructuredOutputoptions:name,description,strict(defaultfalse),maxRepairAttempts(default2), and a pluggablevalidatefor Ajv, zod, or any validator.- The built-in runtime sends the schema as the new optional
ModelRequest.outputFormat. Adapters that setsupportsStructuredOutputforward it natively; for others the schema is described in that request's system prompt only. Existing adapters keep working unchanged. - The final answer is parsed (tolerating code fences and surrounding prose), validated, and repaired by re-prompting with the specific issues. The parsed value is returned as
AgentResult.structured, andrunner.run<T>()types it. A turn that never conforms fails withStructuredOutputError. Repair rounds count toward usage and budgets and stay out of session history. - Streaming emits
output_rejectedbefore each repair round andstructuredonfinal_answer. - A dependency-free
validateJsonSchemacovering the subset providers' structured-output modes use, plusparseJsonAnswer. - A turn that would run through a
RuntimeAdapterwith anoutputSchemathrowsStructuredOutputNotSupportedErrorinstead of returning unvalidated text. - A run that sets its own
outputSchemadoes not inherit the agent's options (itsvalidatein particular). Schemas with an invalid pattern or an unresolvable$refthrowInvalidOutputSchemaErrorbefore any model call. A refusal (ModelResponse.refusal) fails the turn without repair. A failed turn's conversation is still saved, and an approval whose resumed answer misses its schema is recorded as settled. The schema and repair state survive approval resume and checkpoint recovery, and an agent schema that broke after a run started does not block resuming it. - The validator also covers
patternProperties, OpenAPInullable, draft-07 tuples, code-point string lengths, patterns that need the non-Unicode regex mode, and deep recursive$refs. OpenAiModelAdaptersendsoutputFormatasresponse_format: { type: 'json_schema' }(non-object roots wrapped as{ value }, with root-relative$refs kept pointing at the original root), sends schemas outside strict mode's subset non-strict instead of letting the request fail, reports refusals, and takesstructuredOutput: 'prompt'for servers withoutjson_schemasupport.
nestjs-agentic@1.5.0
Patch Changes
-
c679715: Support NestJS 12 and tighten what gets published.
- Peer dependencies on
@nestjs/commonand@nestjs/corenow accept^12.0.0, so installing into a NestJS 12 app no longer fails withERESOLVE. Every package's test suite passes against NestJS 11.2 and 12.1, and CI now checks both. NestJS 12 is ESM only; with these CommonJS packages it needs Node 20.19+ or 22.12+. - Internal
*ranges (@nestjs-agentic/memoryinrag's dependencies, and the@nestjs-agentic/core/nestjs-agenticpeers ofmemory,ragandopenai) are now^1.4.0, so a future major of a sibling package is never pulled in silently. - Compiled tests are written to
test-dist/instead ofdist/test/, so they are no longer published.evaluation,mcpandorchestrationnow declarefileslike the other packages, so they stop shippingsrc/,test/andtsconfig.jsonand excludetest-dist/even when packed outside the repo.@nestjs-agentic/coredrops from 712 files (3.4 MB) to about 315 files (1.4 MB) unpacked.
- Peer dependencies on
-
Updated dependencies [9ee3e4a]
-
Updated dependencies [c679715]
- @nestjs-agentic/core@1.5.0