@adonis-agora/agent 0.25.1 → 0.25.2
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 +28 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/stubs/config/agent.stub +8 -8
- package/dist/stubs/config/mcp.stub +5 -5
- package/dist/stubs/database/migrations/create_agent_rag_chunks.stub +10 -10
- package/dist/stubs/database/migrations/create_agent_tables.stub +14 -14
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @adonis-agora/agent
|
|
2
2
|
|
|
3
|
+
## 0.25.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#79](https://github.com/DavideCarvalho/adonis-agora-agent/pull/79) [`88018eb`](https://github.com/DavideCarvalho/adonis-agora-agent/commit/88018ebfeef32be65c464b075d692b62a369d3fd) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Fix `node ace configure @adonis-agora/agent`, which was broken in every published version.
|
|
8
|
+
|
|
9
|
+
The configure codemod runs each stub through Tempura, which compiles the stub **body** into a JavaScript
|
|
10
|
+
template literal. A bare backtick in the body closes that literal; a bare `${` opens an interpolation.
|
|
11
|
+
All four published stubs were full of both, in ordinary JSDoc prose — `` `lucid` ``, `` `model` ``,
|
|
12
|
+
`` `${documentId}#<n>` `` — so every one of them threw at render time.
|
|
13
|
+
|
|
14
|
+
`configure` therefore aborted on the very first stub, _after_ `updateRcFile` had already succeeded. The
|
|
15
|
+
result was worse than nothing happening: `adonisrc.ts` came out referencing the agent and dashboard
|
|
16
|
+
providers while `config/agent.ts` was never written, leaving an app that could not boot.
|
|
17
|
+
|
|
18
|
+
Both constructs are now backslash-escaped in the stub bodies (`` \` ``, `\${`). This is a render-time
|
|
19
|
+
concern only — the generated files are **byte-identical** to what the stubs always intended, backticked
|
|
20
|
+
prose and all, which was verified against the pre-fix sources.
|
|
21
|
+
|
|
22
|
+
The reason no gate caught this: every stub harness here rendered by stripping the `{{{ }}}` header with a
|
|
23
|
+
regex and using the remainder, which is not what the generator does. A gate that renders differently from
|
|
24
|
+
the generator is not testing the generator. All of them now render through the real engine
|
|
25
|
+
(`app.stubs.create().build().prepare()`), and a new `stub-render.spec.ts` asserts that every stub
|
|
26
|
+
`configure.ts` publishes actually renders — including the two config stubs, which no test had touched.
|
|
27
|
+
|
|
28
|
+
Users on an earlier version who ran `configure` and saw it fail should re-run it after upgrading; if
|
|
29
|
+
`adonisrc.ts` already lists the providers, the codemod is idempotent and only the missing files are written.
|
|
30
|
+
|
|
3
31
|
## 0.25.1
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -7,17 +7,17 @@ import { defineConfig, stores, AuthActorResolver } from '@adonis-agora/agent'
|
|
|
7
7
|
// import { openai } from '@ai-sdk/openai'
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Configuration for @adonis-agora/agent. Only
|
|
11
|
-
*
|
|
12
|
-
* in-memory store. The runner is in-process by default (
|
|
10
|
+
* Configuration for @adonis-agora/agent. Only \`model\` is required. Pick a \`store\` by name from the
|
|
11
|
+
* \`stores\` map (each driver's peer is imported lazily, only when selected); omit \`store\` for the
|
|
12
|
+
* in-memory store. The runner is in-process by default (\`durable\` is deferred). The actor resolver
|
|
13
13
|
* defaults to one that THROWS — the agent never fabricates a caller — so wire a real one.
|
|
14
14
|
*
|
|
15
|
-
* Publish the tables with
|
|
15
|
+
* Publish the tables with \`node ace migration:run\` after configuring.
|
|
16
16
|
*/
|
|
17
17
|
export default defineConfig({
|
|
18
18
|
/**
|
|
19
|
-
* The LLM provider. Wrap the Vercel AI SDK via
|
|
20
|
-
* or supply any
|
|
19
|
+
* The LLM provider. Wrap the Vercel AI SDK via \`aiSdkModel(...)\` (from \`@adonis-agora/agent/ai-sdk\`)
|
|
20
|
+
* or supply any \`ModelProvider\`. A lazy thunk keeps the provider SDK peer imported only at boot:
|
|
21
21
|
*
|
|
22
22
|
* model: () => aiSdkModel({ model: openai('gpt-4o-mini') }),
|
|
23
23
|
*/
|
|
@@ -40,7 +40,7 @@ export default defineConfig({
|
|
|
40
40
|
// maxSteps: 8, // cap on model↔tool iterations per turn
|
|
41
41
|
|
|
42
42
|
// Governance console — served automatically at <path>/dashboard (default /agent/dashboard), no
|
|
43
|
-
// separate install. It only mounts once
|
|
43
|
+
// separate install. It only mounts once \`governanceAuthorize\` is set (every panel but Quota reads
|
|
44
44
|
// the cross-actor governance routes, which need that gate too — see the docs). Toggle it off,
|
|
45
45
|
// relocate it, or add an extra gate on top of governanceAuthorize:
|
|
46
46
|
// dashboard: { enabled: true, path: '/agent/dashboard', authorize: (actor) => actor.roles?.includes('ADMIN') ?? false },
|
|
@@ -48,7 +48,7 @@ export default defineConfig({
|
|
|
48
48
|
|
|
49
49
|
// Multimodal uploads — mounts POST /agent/attachments, which stages a file into a model-fetchable
|
|
50
50
|
// MessageAttachment the client sends back with its next chat message. Bind your own store (presign
|
|
51
|
-
// S3/GCS or wrap your media pipeline);
|
|
51
|
+
// S3/GCS or wrap your media pipeline); \`attachmentStores.memory()\` inlines bytes as a data: URL.
|
|
52
52
|
// attachmentStaging: attachmentStores.memory(),
|
|
53
53
|
// attachmentMaxBytes: 20 * 1024 * 1024,
|
|
54
54
|
// attachmentAllowedContentTypes: ['image/png', 'image/jpeg', 'application/pdf'],
|
|
@@ -6,10 +6,10 @@ import { defineMcpConfig, authKitAuth } from '@adonis-agora/agent/mcp'
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Configuration for the MCP (Model Context Protocol) endpoint. The provider exposes the agent's tool
|
|
9
|
-
* registry over Streamable HTTP:
|
|
10
|
-
*
|
|
9
|
+
* registry over Streamable HTTP: \`tools/list\` mirrors the tools the acting actor may call and
|
|
10
|
+
* \`tools/call\` runs them through the same role-checked registry the agent loop uses.
|
|
11
11
|
*
|
|
12
|
-
* Requires
|
|
12
|
+
* Requires \`@adonis-agora/agent\`'s agent provider (which owns the ToolRegistry singleton) to be
|
|
13
13
|
* registered. Register the MCP provider in adonisrc.ts:
|
|
14
14
|
*
|
|
15
15
|
* providers: [
|
|
@@ -17,8 +17,8 @@ import { defineMcpConfig, authKitAuth } from '@adonis-agora/agent/mcp'
|
|
|
17
17
|
* () => import('@adonis-agora/agent/mcp_provider'),
|
|
18
18
|
* ]
|
|
19
19
|
*
|
|
20
|
-
* The endpoint mounts at
|
|
21
|
-
* the login flow at
|
|
20
|
+
* The endpoint mounts at \`/mcp\`. When \`auth\` exposes OAuth metadata (authKitAuth), MCP clients discover
|
|
21
|
+
* the login flow at \`/.well-known/oauth-protected-resource/mcp\`.
|
|
22
22
|
*/
|
|
23
23
|
export default defineMcpConfig({
|
|
24
24
|
name: 'Agent MCP Server',
|
|
@@ -6,22 +6,22 @@ import db from '@adonisjs/lucid/services/db'
|
|
|
6
6
|
import { PgVectorStore } from '@adonis-agora/agent'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* The pgvector chunk table for the @adonis-agora/agent
|
|
10
|
-
* embedded chunk (id
|
|
11
|
-
* metadata column filtered with
|
|
9
|
+
* The pgvector chunk table for the @adonis-agora/agent \`retrievers.pgvector({...})\` store: one row per
|
|
10
|
+
* embedded chunk (id \`\${documentId}#<n>\`), the chunk text, an optional citation source, a \`jsonb\`
|
|
11
|
+
* metadata column filtered with \`@>\`, and the \`vector(N)\` embedding ranked with the \`<=>\`/\`<->\`/\`<#>\`
|
|
12
12
|
* operators. Requires the pgvector extension — Postgres only. Delete this file if you do not use
|
|
13
13
|
* pgvector RAG.
|
|
14
14
|
*
|
|
15
|
-
* Like the agent tables migration, this DELEGATES rather than copying DDL:
|
|
15
|
+
* Like the agent tables migration, this DELEGATES rather than copying DDL: \`PgVectorStore\` owns the
|
|
16
16
|
* column names and the index operator class its own queries depend on, and it exposes the same
|
|
17
|
-
* provisioning the store runs for itself under
|
|
18
|
-
*
|
|
17
|
+
* provisioning the store runs for itself under \`ensureSchema: true\`. Every statement is
|
|
18
|
+
* \`IF NOT EXISTS\`, so this is safe against a database that already has the table.
|
|
19
19
|
*
|
|
20
|
-
* SET THESE to match your retriever config in
|
|
20
|
+
* SET THESE to match your retriever config in \`config/agent.ts\` — they must agree, or the store will
|
|
21
21
|
* query a table shaped differently from the one this created:
|
|
22
|
-
* -
|
|
23
|
-
* -
|
|
24
|
-
* -
|
|
22
|
+
* - \`DIMENSION\` — your embedding model's width (1536 for text-embedding-3-small).
|
|
23
|
+
* - \`METRIC\` — 'cosine' (default), 'l2', or 'inner'. Picks the index operator class.
|
|
24
|
+
* - \`TABLE\` — only if you overrode \`table\` on the retriever.
|
|
25
25
|
*/
|
|
26
26
|
const TABLE = 'agent_rag_chunks'
|
|
27
27
|
const DIMENSION = 1536
|
|
@@ -6,36 +6,36 @@ import db from '@adonisjs/lucid/services/db'
|
|
|
6
6
|
import { createAgentTables, dropAgentTables } from '@adonis-agora/agent'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* The six tables for the @adonis-agora/agent
|
|
9
|
+
* The six tables for the @adonis-agora/agent \`lucid\` store: threads, messages, tool calls, token
|
|
10
10
|
* usage, model pricing, and the run lifecycle — plus their indexes.
|
|
11
11
|
*
|
|
12
12
|
* This migration DELEGATES to the library instead of reproducing its DDL. The schema belongs to the
|
|
13
|
-
* library:
|
|
13
|
+
* library: \`LucidAgentStore\`, the pricing store and the governance read-model all decide together what
|
|
14
14
|
* columns they read and write, so a hand-copied snapshot here can only ever be right until the next
|
|
15
|
-
* release. It was already wrong in two ways. It reproduced
|
|
15
|
+
* release. It was already wrong in two ways. It reproduced \`createTable(...)\` with no existence guard,
|
|
16
16
|
* which THROWS on a database where the tables are already there — and they usually are, because
|
|
17
|
-
*
|
|
17
|
+
* \`autoCreateTables\` defaults to \`true\` and any of those three stores provisions the shared schema on
|
|
18
18
|
* its first use. And it took two files to say what the library says in one: a second additive migration
|
|
19
|
-
* existed purely to ALTER in the
|
|
19
|
+
* existed purely to ALTER in the \`run_id\` columns this one had been written before.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
* is missing and ALTERs the
|
|
21
|
+
* \`createAgentTables\` is idempotent (\`CREATE TABLE IF NOT EXISTS\`) and additive-only: it creates what
|
|
22
|
+
* is missing and ALTERs the \`run_id\` columns into a database that predates run tracking. So it is safe
|
|
23
23
|
* against an empty database, against one the library already auto-created, and against one left over
|
|
24
24
|
* from an older version — which is exactly the set of states a real app is in.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
26
|
+
* \`db\` (the \`Database\` manager from \`@adonisjs/lucid/services/db\`) rather than \`this.db\`: the manager
|
|
27
27
|
* checks out its own connection from the pool, which is what keeps the DDL out of the migrator's
|
|
28
|
-
* transaction (see
|
|
29
|
-
*
|
|
28
|
+
* transaction (see \`disableTransactions\` below). \`this.db\` still supplies the connection NAME, so
|
|
29
|
+
* \`node ace migration:run --connection=x\` provisions the tables on connection \`x\` and not on the default.
|
|
30
30
|
*/
|
|
31
31
|
export default class extends BaseSchema {
|
|
32
32
|
/**
|
|
33
|
-
* REQUIRED, not a preference. The DDL below runs on a connection the
|
|
33
|
+
* REQUIRED, not a preference. The DDL below runs on a connection the \`Database\` manager checks out
|
|
34
34
|
* itself — it is not part of the transaction the migrator would otherwise open for this migration.
|
|
35
|
-
* With
|
|
36
|
-
* connection while
|
|
35
|
+
* With \`pool: { max: 1 }\` (Adonis's own SQLite guidance) that transaction would hold the only
|
|
36
|
+
* connection while \`createAgentTables\` waited for a free one, and the migration would hang until the
|
|
37
37
|
* acquire timeout. Nothing is lost by opting out: the statements were never inside that transaction
|
|
38
|
-
* anyway, and re-running an interrupted
|
|
38
|
+
* anyway, and re-running an interrupted \`createAgentTables\` is a no-op.
|
|
39
39
|
*/
|
|
40
40
|
static disableTransactions = true
|
|
41
41
|
|
package/package.json
CHANGED