@adonis-agora/agent 0.36.0 → 0.37.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 +17 -0
- package/NOTICE +31 -0
- package/README.md +5 -5
- package/dist/configure.d.ts.map +1 -1
- package/dist/configure.js +1 -0
- package/dist/configure.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/rag/index.d.ts +2 -1
- package/dist/src/rag/index.d.ts.map +1 -1
- package/dist/src/rag/index.js +2 -1
- package/dist/src/rag/index.js.map +1 -1
- package/dist/src/rag/openai-embeddings.d.ts +20 -2
- package/dist/src/rag/openai-embeddings.d.ts.map +1 -1
- package/dist/src/rag/openai-embeddings.js +107 -42
- package/dist/src/rag/openai-embeddings.js.map +1 -1
- package/dist/src/rag/pg-vector-store.d.ts +27 -0
- package/dist/src/rag/pg-vector-store.d.ts.map +1 -1
- package/dist/src/rag/pg-vector-store.js +2 -2
- package/dist/src/rag/pg-vector-store.js.map +1 -1
- package/dist/src/rag/tree/build.d.ts +96 -0
- package/dist/src/rag/tree/build.d.ts.map +1 -0
- package/dist/src/rag/tree/build.js +659 -0
- package/dist/src/rag/tree/build.js.map +1 -0
- package/dist/src/rag/tree/headings.d.ts +29 -0
- package/dist/src/rag/tree/headings.d.ts.map +1 -0
- package/dist/src/rag/tree/headings.js +227 -0
- package/dist/src/rag/tree/headings.js.map +1 -0
- package/dist/src/rag/tree/index-document.d.ts +33 -0
- package/dist/src/rag/tree/index-document.d.ts.map +1 -0
- package/dist/src/rag/tree/index-document.js +36 -0
- package/dist/src/rag/tree/index-document.js.map +1 -0
- package/dist/src/rag/tree/index.d.ts +13 -0
- package/dist/src/rag/tree/index.d.ts.map +1 -0
- package/dist/src/rag/tree/index.js +12 -0
- package/dist/src/rag/tree/index.js.map +1 -0
- package/dist/src/rag/tree/keyword-tree-llm.d.ts +15 -0
- package/dist/src/rag/tree/keyword-tree-llm.d.ts.map +1 -0
- package/dist/src/rag/tree/keyword-tree-llm.js +105 -0
- package/dist/src/rag/tree/keyword-tree-llm.js.map +1 -0
- package/dist/src/rag/tree/llm.d.ts +179 -0
- package/dist/src/rag/tree/llm.d.ts.map +1 -0
- package/dist/src/rag/tree/llm.js +264 -0
- package/dist/src/rag/tree/llm.js.map +1 -0
- package/dist/src/rag/tree/navigate-tool.d.ts +58 -0
- package/dist/src/rag/tree/navigate-tool.d.ts.map +1 -0
- package/dist/src/rag/tree/navigate-tool.js +95 -0
- package/dist/src/rag/tree/navigate-tool.js.map +1 -0
- package/dist/src/rag/tree/navigate.d.ts +137 -0
- package/dist/src/rag/tree/navigate.d.ts.map +1 -0
- package/dist/src/rag/tree/navigate.js +404 -0
- package/dist/src/rag/tree/navigate.js.map +1 -0
- package/dist/src/rag/tree/pg-tree-store.d.ts +45 -0
- package/dist/src/rag/tree/pg-tree-store.d.ts.map +1 -0
- package/dist/src/rag/tree/pg-tree-store.js +205 -0
- package/dist/src/rag/tree/pg-tree-store.js.map +1 -0
- package/dist/src/rag/tree/store.d.ts +57 -0
- package/dist/src/rag/tree/store.d.ts.map +1 -0
- package/dist/src/rag/tree/store.js +66 -0
- package/dist/src/rag/tree/store.js.map +1 -0
- package/dist/src/rag/tree/two-stage.d.ts +54 -0
- package/dist/src/rag/tree/two-stage.d.ts.map +1 -0
- package/dist/src/rag/tree/two-stage.js +92 -0
- package/dist/src/rag/tree/two-stage.js.map +1 -0
- package/dist/src/rag/tree/types.d.ts +135 -0
- package/dist/src/rag/tree/types.d.ts.map +1 -0
- package/dist/src/rag/tree/types.js +21 -0
- package/dist/src/rag/tree/types.js.map +1 -0
- package/dist/stubs/database/migrations/create_agent_rag_trees.stub +40 -0
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/rag/tree/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH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,EAAO,GACrC,SAAS,CAAC;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,IAAI,EAAE,SAAS,gBAAgB,EAAE,CAAA;CAAE,CAAC,CAK1E;AAED,2DAA2D;AAC3D,wBAAgB,SAAS,CACvB,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,GAChC,GAAG,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,IAAI,EAAE,SAAS,gBAAgB,EAAE,CAAA;CAAE,CAAC,CAM5E"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The data model of tree navigation retrieval: a hierarchical table of contents per long document
|
|
3
|
+
* (PageIndex-style: sections with page ranges and summaries), built once at ingestion and read by an
|
|
4
|
+
* LLM at query time to walk to the relevant sections instead of ranking hundreds of look-alike chunks.
|
|
5
|
+
*/
|
|
6
|
+
/** Walk a tree depth-first (pre-order). */
|
|
7
|
+
export function* walkTree(nodes, path = []) {
|
|
8
|
+
for (const node of nodes) {
|
|
9
|
+
yield { node, path };
|
|
10
|
+
yield* walkTree(node.children, [...path, node]);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Index a tree's nodes by id, each with its ancestors. */
|
|
14
|
+
export function indexTree(tree) {
|
|
15
|
+
const index = new Map();
|
|
16
|
+
for (const entry of walkTree(tree.nodes)) {
|
|
17
|
+
index.set(entry.node.id, entry);
|
|
18
|
+
}
|
|
19
|
+
return index;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/rag/tree/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkIH,2CAA2C;AAC3C,MAAM,SAAS,CAAC,CAAC,QAAQ,CACvB,KAAkC,EAClC,IAAI,GAAgC,EAAE;IAEtC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACrB,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAClD,CAAC;AACH,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,SAAS,CACvB,IAAiC;IAEjC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAyE,CAAC;IAC/F,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACzC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.migrationsPath(`${new Date().getTime()}_create_agent_rag_trees.ts`) })
|
|
3
|
+
}}}
|
|
4
|
+
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
5
|
+
import db from '@adonisjs/lucid/services/db'
|
|
6
|
+
import { PgDocumentTreeStore } from '@adonis-agora/agent'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The tables of \`PgDocumentTreeStore\`, the tree navigation store (PageIndex-style retrieval for long
|
|
10
|
+
* documents): one row per document tree (header columns, a \`jsonb\` metadata column filtered like the
|
|
11
|
+
* chunk table's, the nodes as \`jsonb\`) and one row per page/section of text the nodes point at.
|
|
12
|
+
* Postgres only; needs no extension. Delete this file if you do not use tree navigation.
|
|
13
|
+
*
|
|
14
|
+
* Like the other migrations, this DELEGATES rather than copying DDL: the store owns the column names
|
|
15
|
+
* its own queries depend on. Every statement is \`IF NOT EXISTS\`, so this is safe against a database
|
|
16
|
+
* where \`ensureSchema()\` already ran.
|
|
17
|
+
*
|
|
18
|
+
* SET \`TABLE\` / \`UNITS_TABLE\` only if you pass \`table\` / \`unitsTable\` to
|
|
19
|
+
* \`new PgDocumentTreeStore(db, { ... })\` (the units table defaults to the trees table + \`_units\`).
|
|
20
|
+
*/
|
|
21
|
+
const TABLE = 'agent_rag_trees'
|
|
22
|
+
const UNITS_TABLE = 'agent_rag_trees_units'
|
|
23
|
+
|
|
24
|
+
export default class extends BaseSchema {
|
|
25
|
+
/** Same reason as the agent tables migration: the DDL runs on the manager's own pooled connection. */
|
|
26
|
+
static disableTransactions = true
|
|
27
|
+
|
|
28
|
+
async up() {
|
|
29
|
+
const store = new PgDocumentTreeStore(db.connection(this.db.connectionName), {
|
|
30
|
+
table: TABLE,
|
|
31
|
+
unitsTable: UNITS_TABLE,
|
|
32
|
+
})
|
|
33
|
+
await store.ensureSchema()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async down() {
|
|
37
|
+
this.schema.dropTableIfExists(UNITS_TABLE)
|
|
38
|
+
this.schema.dropTableIfExists(TABLE)
|
|
39
|
+
}
|
|
40
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonis-agora/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -146,6 +146,7 @@
|
|
|
146
146
|
"dist/",
|
|
147
147
|
"README.md",
|
|
148
148
|
"CHANGELOG.md",
|
|
149
|
+
"NOTICE",
|
|
149
150
|
"skills"
|
|
150
151
|
],
|
|
151
152
|
"sideEffects": false,
|