@adonis-agora/agent 0.34.1 → 0.36.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/CHANGELOG.md +24 -0
- package/README.md +34 -0
- package/dist/assets/spa/assets/index-7XqfoeQH.js +9 -0
- package/dist/assets/spa/index.html +1 -1
- package/dist/providers/agent_provider.d.ts.map +1 -1
- package/dist/providers/agent_provider.js +4 -0
- package/dist/providers/agent_provider.js.map +1 -1
- package/dist/src/agent-deps-factory.d.ts +5 -0
- package/dist/src/agent-deps-factory.d.ts.map +1 -1
- package/dist/src/agent-deps-factory.js +6 -0
- package/dist/src/agent-deps-factory.js.map +1 -1
- package/dist/src/agent-deps.d.ts +5 -0
- package/dist/src/agent-deps.d.ts.map +1 -1
- package/dist/src/agent-deps.js.map +1 -1
- package/dist/src/define_config.d.ts +12 -0
- package/dist/src/define_config.d.ts.map +1 -1
- package/dist/src/define_config.js.map +1 -1
- package/dist/src/guardrails/agent.d.ts +211 -0
- package/dist/src/guardrails/agent.d.ts.map +1 -0
- package/dist/src/guardrails/agent.js +433 -0
- package/dist/src/guardrails/agent.js.map +1 -0
- package/dist/src/guardrails/detectors/custom.d.ts +9 -0
- package/dist/src/guardrails/detectors/custom.d.ts.map +1 -0
- package/dist/src/guardrails/detectors/custom.js +81 -0
- package/dist/src/guardrails/detectors/custom.js.map +1 -0
- package/dist/src/guardrails/detectors/injection.d.ts +23 -0
- package/dist/src/guardrails/detectors/injection.d.ts.map +1 -0
- package/dist/src/guardrails/detectors/injection.js +208 -0
- package/dist/src/guardrails/detectors/injection.js.map +1 -0
- package/dist/src/guardrails/detectors/pii.d.ts +23 -0
- package/dist/src/guardrails/detectors/pii.d.ts.map +1 -0
- package/dist/src/guardrails/detectors/pii.js +295 -0
- package/dist/src/guardrails/detectors/pii.js.map +1 -0
- package/dist/src/guardrails/detectors/secrets.d.ts +5 -0
- package/dist/src/guardrails/detectors/secrets.d.ts.map +1 -0
- package/dist/src/guardrails/detectors/secrets.js +110 -0
- package/dist/src/guardrails/detectors/secrets.js.map +1 -0
- package/dist/src/guardrails/detectors/tool-poisoning.d.ts +16 -0
- package/dist/src/guardrails/detectors/tool-poisoning.d.ts.map +1 -0
- package/dist/src/guardrails/detectors/tool-poisoning.js +116 -0
- package/dist/src/guardrails/detectors/tool-poisoning.js.map +1 -0
- package/dist/src/guardrails/engine.d.ts +90 -0
- package/dist/src/guardrails/engine.d.ts.map +1 -0
- package/dist/src/guardrails/engine.js +324 -0
- package/dist/src/guardrails/engine.js.map +1 -0
- package/dist/src/guardrails/glob.d.ts +4 -0
- package/dist/src/guardrails/glob.d.ts.map +1 -0
- package/dist/src/guardrails/glob.js +20 -0
- package/dist/src/guardrails/glob.js.map +1 -0
- package/dist/src/guardrails/index.d.ts +20 -0
- package/dist/src/guardrails/index.d.ts.map +1 -0
- package/dist/src/guardrails/index.js +20 -0
- package/dist/src/guardrails/index.js.map +1 -0
- package/dist/src/guardrails/segments.d.ts +14 -0
- package/dist/src/guardrails/segments.d.ts.map +1 -0
- package/dist/src/guardrails/segments.js +32 -0
- package/dist/src/guardrails/segments.js.map +1 -0
- package/dist/src/guardrails/types.d.ts +161 -0
- package/dist/src/guardrails/types.d.ts.map +1 -0
- package/dist/src/guardrails/types.js +49 -0
- package/dist/src/guardrails/types.js.map +1 -0
- package/dist/src/guardrails/vault.d.ts +44 -0
- package/dist/src/guardrails/vault.d.ts.map +1 -0
- package/dist/src/guardrails/vault.js +103 -0
- package/dist/src/guardrails/vault.js.map +1 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/mcp-client/index.d.ts +1 -1
- package/dist/src/mcp-client/index.d.ts.map +1 -1
- package/dist/src/mcp-client/index.js.map +1 -1
- package/dist/src/mcp-client/options.d.ts +32 -0
- package/dist/src/mcp-client/options.d.ts.map +1 -1
- package/dist/src/mcp-client/tool-source.d.ts +2 -0
- package/dist/src/mcp-client/tool-source.d.ts.map +1 -1
- package/dist/src/mcp-client/tool-source.js +27 -1
- package/dist/src/mcp-client/tool-source.js.map +1 -1
- package/dist/src/rag/http-reranker.d.ts +46 -0
- package/dist/src/rag/http-reranker.d.ts.map +1 -0
- package/dist/src/rag/http-reranker.js +83 -0
- package/dist/src/rag/http-reranker.js.map +1 -0
- package/dist/src/rag/hybrid-retriever.d.ts +6 -1
- package/dist/src/rag/hybrid-retriever.d.ts.map +1 -1
- package/dist/src/rag/hybrid-retriever.js +27 -3
- package/dist/src/rag/hybrid-retriever.js.map +1 -1
- package/dist/src/rag/index.d.ts +6 -2
- package/dist/src/rag/index.d.ts.map +1 -1
- package/dist/src/rag/index.js +6 -2
- package/dist/src/rag/index.js.map +1 -1
- package/dist/src/rag/lexical-query.d.ts +28 -0
- package/dist/src/rag/lexical-query.d.ts.map +1 -0
- package/dist/src/rag/lexical-query.js +90 -0
- package/dist/src/rag/lexical-query.js.map +1 -0
- package/dist/src/rag/lexical-retriever.d.ts +23 -0
- package/dist/src/rag/lexical-retriever.d.ts.map +1 -0
- package/dist/src/rag/lexical-retriever.js +28 -0
- package/dist/src/rag/lexical-retriever.js.map +1 -0
- package/dist/src/rag/openai-embeddings.d.ts +62 -0
- package/dist/src/rag/openai-embeddings.d.ts.map +1 -0
- package/dist/src/rag/openai-embeddings.js +106 -0
- package/dist/src/rag/openai-embeddings.js.map +1 -0
- package/dist/src/rag/pg-vector-store.d.ts +133 -6
- package/dist/src/rag/pg-vector-store.d.ts.map +1 -1
- package/dist/src/rag/pg-vector-store.js +272 -31
- package/dist/src/rag/pg-vector-store.js.map +1 -1
- package/dist/src/rag/vector-store.d.ts +15 -0
- package/dist/src/rag/vector-store.d.ts.map +1 -1
- package/dist/src/rag/vector-store.js +4 -0
- package/dist/src/rag/vector-store.js.map +1 -1
- package/dist/src/stores/factory.d.ts +25 -3
- package/dist/src/stores/factory.d.ts.map +1 -1
- package/dist/src/stores/factory.js +21 -3
- package/dist/src/stores/factory.js.map +1 -1
- package/dist/src/testing/fake-embedding-provider.d.ts +12 -0
- package/dist/src/testing/fake-embedding-provider.d.ts.map +1 -1
- package/dist/src/testing/fake-embedding-provider.js +35 -0
- package/dist/src/testing/fake-embedding-provider.js.map +1 -1
- package/dist/src/testing/index.d.ts +1 -1
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/testing/index.js +1 -1
- package/dist/src/testing/index.js.map +1 -1
- package/package.json +9 -3
- package/dist/assets/spa/assets/index-DjIMQOxi.js +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @adonis-agora/agent
|
|
2
2
|
|
|
3
|
+
## 0.36.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#191](https://github.com/DavideCarvalho/adonis-agora-agent/pull/191) [`c70587d`](https://github.com/DavideCarvalho/adonis-agora-agent/commit/c70587d52cb00235203539d5b4868d5055789788) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `PgLexicalVectorStore.searchText` (and `retrievers.pgvector({ fullText })`): natural-language questions are searched by their meaningful terms. The question's stop words are dropped (new `fullText.stopWords`, default `DEFAULT_STOP_WORDS`: English, Portuguese and Spanish, only the language(s) the question is written in; `false` keeps every word) and rows holding any remaining term are ranked by the sum of the matched terms' IDF among the matching rows (BM25 without term frequencies), `ts_rank_cd` breaking ties. Before, a question had to match every word and then fell back to any word including stop words, ranked by `ts_rank_cd`, so rows dense in "the/of/which" won: in a 149-question benchmark over 12k chunks this took the keyword-only evidence hit rate from 18% to 75% (hybrid 69% to 80%), and it is faster. Quoted phrases and `-word` still go through `websearch_to_tsquery` as written first; `anyTermFallback: false` keeps the old every-word-only behavior. New exports: `keywordTerms`, `hasSearchSyntax`, `anyTermTsquery`, `DEFAULT_STOP_WORDS`.
|
|
8
|
+
|
|
9
|
+
## 0.35.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#186](https://github.com/DavideCarvalho/adonis-agora-agent/pull/186) [`e7d75e1`](https://github.com/DavideCarvalho/adonis-agora-agent/commit/e7d75e1f1e931d5071de94d5f9d207eb83c76c42) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Guardrails, and processors you can actually configure
|
|
14
|
+
|
|
15
|
+
- **`@adonis-agora/agent/guardrails`** — PII (Luhn-validated cards, CPF/CNPJ, SSN, IBAN, phones, emails, IPv4), secret (provider key formats, JWT, PEM, entropy-gated assignments), prompt-injection (EN / PT-BR / ES, hidden Unicode, encoded payloads) and tool-poisoning detectors; a rule engine with `allow`/`log`/`redact`/`approve`/`block`, fail modes and reversible redaction (`Vault`); and `createGuardrails(options)`, which runs it on the loop's processor seams — `guardrails.input` / `guardrails.output`, `wrapTool` for tool arguments, `screenTool` for tool definitions — with per-call rule resolution (per tenant) and an audit hook. A port of `@dudousxd/nestjs-agent-core/guardrails`.
|
|
16
|
+
- **`inputProcessors` / `outputProcessors` in `config/agent.ts`.** The loop has taken processors since they were ported, but nothing between the config and the loop carried them, so an app using the provider could not register one. They now reach every agent's turn, inline and durable.
|
|
17
|
+
- **`mcpServers[].screen`** — inspect each listed tool definition before it is imported, and skip the ones it refuses (a screen that throws skips the tool too).
|
|
18
|
+
|
|
19
|
+
- [#185](https://github.com/DavideCarvalho/adonis-agora-agent/pull/185) [`2f4fc8c`](https://github.com/DavideCarvalho/adonis-agora-agent/commit/2f4fc8cf865e1b310280a40e2df91ed7f72caf93) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - First-party HTTP embedding and rerank adapters
|
|
20
|
+
|
|
21
|
+
New `openAiEmbeddings` — an `EmbeddingProvider` over any OpenAI-compatible `/v1/embeddings` (OpenAI, gateways, TEI, Ollama, vLLM), with `embedWithUsage` so embedding spend reaches the ledger and quota — and `HttpReranker`, a `Reranker` over Cohere/Jina/Voyage/TEI-style `/rerank`. Both are dependency-free and throw `HttpModelError`. `@adonis-agora/agent/testing` adds `hashedEmbeddings(dimensions)`, a deterministic Unicode-aware hashed embedder.
|
|
22
|
+
|
|
23
|
+
- [#184](https://github.com/DavideCarvalho/adonis-agora-agent/pull/184) [`1b8cc02`](https://github.com/DavideCarvalho/adonis-agora-agent/commit/1b8cc02fc447841e01bd58219e5c674413b46cc1) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - pgvector: batched upserts, full-text hybrid search, mixed dimensions
|
|
24
|
+
|
|
25
|
+
`PgVectorStore` now upserts in multi-row `INSERT … ON CONFLICT` statements (`upsertBatchSize`, default 100; duplicate ids in one call keep the last), and gains opt-in `nullableEmbeddings` (`embedding: []` → `NULL`), mixed-dimension tables (`dimension: [768, 1536]`, one partial HNSW index per width, searches compare like with like), and pgvector ≥ 0.8 `iterativeScan` / `efSearch` (`SET LOCAL` inside a Lucid transaction, skipped on older pgvector). New `PgLexicalVectorStore` (Postgres full-text `searchText`), `LexicalVectorStore` / `isLexicalVectorStore` and `LexicalRetriever`; `retrievers.pgvector({ fullText: {} })` returns a `HybridRetriever` of both legs. `HybridRetriever` gains `retrieveWithUsage`, so embedding spend from its legs still reaches the ledger. Everything is off by default.
|
|
26
|
+
|
|
3
27
|
## 0.34.1
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -152,6 +152,40 @@ export const executeSql = dataTool({
|
|
|
152
152
|
})
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
+
### Guardrails — PII, secrets, prompt injection, tool poisoning
|
|
156
|
+
|
|
157
|
+
`@adonis-agora/agent/guardrails` puts detectors and a rule engine on the loop's processor seams,
|
|
158
|
+
which `config/agent.ts` now takes as `inputProcessors` / `outputProcessors`:
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
// config/agent.ts
|
|
162
|
+
import { createGuardrails } from '@adonis-agora/agent/guardrails'
|
|
163
|
+
|
|
164
|
+
const guardrails = createGuardrails({
|
|
165
|
+
pii: 'redact', // reversible: the model sees [EMAIL_1], the reader the address
|
|
166
|
+
secrets: 'block',
|
|
167
|
+
injection: { threshold: 0.6 }, // the prompt and every tool result; default action: block
|
|
168
|
+
toolPoisoning: true, // guardrails.screenTool, for `mcpServers[].screen`
|
|
169
|
+
rules: (ctx) => rulesForTenant(ctx.actor?.tenantRef), // more rules, resolved per scan
|
|
170
|
+
onEvent: (event) => audit(event), // hits carry fingerprints, never values
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
export default defineConfig({
|
|
174
|
+
model: () => aiSdkModel(openai('gpt-4o-mini')),
|
|
175
|
+
inputProcessors: [guardrails.input],
|
|
176
|
+
outputProcessors: [guardrails.output],
|
|
177
|
+
mcpServers: [{ name: 'docs', transport: { type: 'http', url }, screen: (t) => guardrails.screenTool(t) }],
|
|
178
|
+
})
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
A blocked prompt fails the run (`ProcessorFailedError` caused by a `GuardrailBlockedError`); a
|
|
182
|
+
blocked tool result is withheld and the turn goes on; a blocked answer or tool call is an
|
|
183
|
+
`OutputRejectedError`. `guardrails.wrapTool(name, handler)` restores placeholders into a tool's
|
|
184
|
+
arguments and runs the `tool_args` rules on them. The output processor declares `incremental`, so the
|
|
185
|
+
answer keeps streaming. The detectors (`detectPii` with Luhn/CPF/CNPJ/IBAN checks, `detectSecrets`,
|
|
186
|
+
`scoreInjection`, `scoreToolText`) and `scan` work on their own. Same code as
|
|
187
|
+
`@dudousxd/nestjs-agent-core/guardrails`, which also carries the raw OpenAI/Anthropic stream guard.
|
|
188
|
+
|
|
155
189
|
### Framework-agnostic core (no AdonisJS)
|
|
156
190
|
|
|
157
191
|
`runAgentLoop(deps, input, hooks)` is the shared turn body both the in-process (`InlineAgentRunner`)
|