@pgsage/core 0.1.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/README.md +126 -0
- package/dist/corrector/index.d.ts +72 -0
- package/dist/corrector/index.d.ts.map +1 -0
- package/dist/corrector/index.js +113 -0
- package/dist/corrector/index.js.map +1 -0
- package/dist/db/index.d.ts +3 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +2 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/pool.d.ts +46 -0
- package/dist/db/pool.d.ts.map +1 -0
- package/dist/db/pool.js +46 -0
- package/dist/db/pool.js.map +1 -0
- package/dist/embeddings/index.d.ts +4 -0
- package/dist/embeddings/index.d.ts.map +1 -0
- package/dist/embeddings/index.js +2 -0
- package/dist/embeddings/index.js.map +1 -0
- package/dist/embeddings/types.d.ts +39 -0
- package/dist/embeddings/types.d.ts.map +1 -0
- package/dist/embeddings/types.js +16 -0
- package/dist/embeddings/types.js.map +1 -0
- package/dist/embeddings/voyage.d.ts +70 -0
- package/dist/embeddings/voyage.d.ts.map +1 -0
- package/dist/embeddings/voyage.js +163 -0
- package/dist/embeddings/voyage.js.map +1 -0
- package/dist/estimator/index.d.ts +53 -0
- package/dist/estimator/index.d.ts.map +1 -0
- package/dist/estimator/index.js +57 -0
- package/dist/estimator/index.js.map +1 -0
- package/dist/executor/index.d.ts +56 -0
- package/dist/executor/index.d.ts.map +1 -0
- package/dist/executor/index.js +86 -0
- package/dist/executor/index.js.map +1 -0
- package/dist/explainer/index.d.ts +39 -0
- package/dist/explainer/index.d.ts.map +1 -0
- package/dist/explainer/index.js +79 -0
- package/dist/explainer/index.js.map +1 -0
- package/dist/explainer/prompt.d.ts +37 -0
- package/dist/explainer/prompt.d.ts.map +1 -0
- package/dist/explainer/prompt.js +102 -0
- package/dist/explainer/prompt.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/introspector/index.d.ts +127 -0
- package/dist/introspector/index.d.ts.map +1 -0
- package/dist/introspector/index.js +460 -0
- package/dist/introspector/index.js.map +1 -0
- package/dist/orchestrator/index.d.ts +113 -0
- package/dist/orchestrator/index.d.ts.map +1 -0
- package/dist/orchestrator/index.js +126 -0
- package/dist/orchestrator/index.js.map +1 -0
- package/dist/planner/index.d.ts +83 -0
- package/dist/planner/index.d.ts.map +1 -0
- package/dist/planner/index.js +67 -0
- package/dist/planner/index.js.map +1 -0
- package/dist/planner/prompt.d.ts +37 -0
- package/dist/planner/prompt.d.ts.map +1 -0
- package/dist/planner/prompt.js +436 -0
- package/dist/planner/prompt.js.map +1 -0
- package/dist/retriever/index.d.ts +90 -0
- package/dist/retriever/index.d.ts.map +1 -0
- package/dist/retriever/index.js +164 -0
- package/dist/retriever/index.js.map +1 -0
- package/dist/validator/index.d.ts +26 -0
- package/dist/validator/index.d.ts.map +1 -0
- package/dist/validator/index.js +205 -0
- package/dist/validator/index.js.map +1 -0
- package/package.json +63 -0
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# @pgsage/core
|
|
2
|
+
|
|
3
|
+
The pgsage SDK. All pipeline stages from schema retrieval to natural-language explanation, plus the `createAgent()` entrypoint that wires them together.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm add @pgsage/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Requires `ANTHROPIC_API_KEY` and `VOYAGE_API_KEY` in the environment.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Quick Example
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import {
|
|
21
|
+
createAgent,
|
|
22
|
+
createPool,
|
|
23
|
+
createReadonlyPool,
|
|
24
|
+
VoyageEmbeddingProvider,
|
|
25
|
+
} from "@pgsage/core";
|
|
26
|
+
|
|
27
|
+
const agent = createAgent({
|
|
28
|
+
pool: createPool(process.env.DATABASE_URL!),
|
|
29
|
+
readonlyPool: createReadonlyPool(process.env.DATABASE_READONLY_URL!),
|
|
30
|
+
embedder: new VoyageEmbeddingProvider({ apiKey: process.env.VOYAGE_API_KEY! }),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const response = await agent.query("Top 5 counties by median household income", {
|
|
34
|
+
onProgress: (step, label) => console.log(`[${step}] ${label}`),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
console.log(response.answer); // "The highest median household income is..."
|
|
38
|
+
console.log(response.sql); // the generated SELECT query
|
|
39
|
+
console.log(response.rows); // result rows
|
|
40
|
+
console.log(response.displayHint); // suggested visualization layout
|
|
41
|
+
console.log(response.assumptions); // interpretive assumptions
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Pipeline Stages
|
|
47
|
+
|
|
48
|
+
| Module | Exported via | Description |
|
|
49
|
+
|--------|-------------|-------------|
|
|
50
|
+
| `retriever` | `@pgsage/core` | pgvector similarity search over schema embeddings |
|
|
51
|
+
| `planner` | `@pgsage/core` | Claude LLM → SQL + assumptions + `displayHint` |
|
|
52
|
+
| `validator` | `@pgsage/core` | AST safety check — rejects writes, DDL, multi-statement |
|
|
53
|
+
| `estimator` | `@pgsage/core` | `EXPLAIN FORMAT JSON` cost check before execution |
|
|
54
|
+
| `executor` | `@pgsage/core` | Read-only pool execution with row limit and statement timeout |
|
|
55
|
+
| `corrector` | `@pgsage/core` | Retry loop — re-plans with error context on failure |
|
|
56
|
+
| `explainer` | `@pgsage/core` | Claude LLM → concise natural-language answer from result rows |
|
|
57
|
+
| `orchestrator` | `@pgsage/core` | `createAgent()` — wires all stages into a single `query()` call |
|
|
58
|
+
|
|
59
|
+
Each module is also accessible as a namespace export:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { validator, estimator, executor } from "@pgsage/core";
|
|
63
|
+
|
|
64
|
+
const { valid, reason } = validator.validate(sql);
|
|
65
|
+
const { exceedsThreshold, planCost } = await estimator.createEstimator({ pool }).estimate(sql);
|
|
66
|
+
const { rows, fields, truncated } = await executor.createExecutor({ pool }).execute(sql);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Configuration
|
|
72
|
+
|
|
73
|
+
`createAgent(config: OrchestratorConfig)` accepts:
|
|
74
|
+
|
|
75
|
+
| Field | Type | Default | Description |
|
|
76
|
+
|-------|------|---------|-------------|
|
|
77
|
+
| `pool` | `pg.Pool` | required | Read-write pool (retrieval, EXPLAIN) |
|
|
78
|
+
| `readonlyPool` | `pg.Pool` | required | Read-only pool (query execution) |
|
|
79
|
+
| `embedder` | `EmbeddingProvider` | required | Embedding provider for pgvector search |
|
|
80
|
+
| `model` | `string` | `"anthropic/claude-sonnet-4-6"` | Mastra model string for the planner |
|
|
81
|
+
| `explainerModel` | `string` | same as `model` | Model for the explainer stage |
|
|
82
|
+
| `topK` | `number` | `10` | Schema chunks to retrieve |
|
|
83
|
+
| `costThreshold` | `number` | `1_000_000` | Max EXPLAIN cost before rejection |
|
|
84
|
+
| `rowThreshold` | `number` | `500_000` | Max EXPLAIN rows before rejection |
|
|
85
|
+
| `rowLimit` | `number` | `500` | Max rows returned by the executor |
|
|
86
|
+
| `statementTimeout` | `number` | `30_000` | Statement timeout in ms |
|
|
87
|
+
| `maxRetries` | `number` | `3` | Max self-correction retries |
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Key Types
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
// The response from agent.query()
|
|
95
|
+
interface QueryResponse {
|
|
96
|
+
answer: string; // LLM-generated natural-language answer
|
|
97
|
+
sql: string; // The executed SELECT query
|
|
98
|
+
assumptions: string[]; // Planner's interpretive assumptions
|
|
99
|
+
displayHint: DisplayHint; // "big" | "statrow" | "bar" | "grouped" | "table"
|
|
100
|
+
rows: Record<string, unknown>[]; // Result rows
|
|
101
|
+
rowCount: number;
|
|
102
|
+
fields: string[]; // Column names
|
|
103
|
+
truncated: boolean; // True if rowLimit was hit
|
|
104
|
+
attempts: { sql: string; error: string }[]; // Self-correction history
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Per-request options for query()
|
|
108
|
+
interface QueryOptions {
|
|
109
|
+
onProgress?: (step: number, label: string) => void;
|
|
110
|
+
// Steps: 0=Searching schema, 1=Generating SQL, 2=Validating & executing,
|
|
111
|
+
// 3=Correcting query (retry only), 4=Summarizing results
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Suggested visualization layout
|
|
115
|
+
type DisplayHint = "big" | "statrow" | "bar" | "grouped" | "table";
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Testing
|
|
121
|
+
|
|
122
|
+
```sh
|
|
123
|
+
pnpm --filter @pgsage/core test
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
204 unit tests, 11 integration tests (require Docker + API keys, skipped by default).
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Corrector
|
|
3
|
+
*
|
|
4
|
+
* Error-driven re-planning loop: on execution error or a suspicious zero-row
|
|
5
|
+
* result, re-invokes the planner with the failure context appended to the
|
|
6
|
+
* prompt (via PlanOptions.errorContext), capped at maxRetries attempts.
|
|
7
|
+
*
|
|
8
|
+
* Zero-row heuristic: zero rows from a broad aggregation (no WHERE clause
|
|
9
|
+
* with specific values) is flagged as a likely query bug and triggers a retry.
|
|
10
|
+
* Zero rows from a query with specific WHERE filters is treated as a
|
|
11
|
+
* legitimately empty result and returned as-is.
|
|
12
|
+
*/
|
|
13
|
+
import type { Planner, PlanResult, PriorAttempt } from "../planner/index.js";
|
|
14
|
+
import type { RetrievedSchemaChunk } from "../retriever/index.js";
|
|
15
|
+
import type { ExecutionResult } from "../executor/index.js";
|
|
16
|
+
export interface CorrectorConfig {
|
|
17
|
+
/** The planner instance used to generate correction attempts. */
|
|
18
|
+
planner: Planner;
|
|
19
|
+
/**
|
|
20
|
+
* Maximum number of re-plan attempts before giving up.
|
|
21
|
+
* Default: 3.
|
|
22
|
+
*/
|
|
23
|
+
maxRetries?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface CorrectionResult {
|
|
26
|
+
/** The final PlanResult (may be the original if no correction was needed). */
|
|
27
|
+
plan: PlanResult;
|
|
28
|
+
/**
|
|
29
|
+
* All prior attempts including failures, in order. Empty when the first
|
|
30
|
+
* plan succeeded.
|
|
31
|
+
*/
|
|
32
|
+
attempts: PriorAttempt[];
|
|
33
|
+
/** True when the corrector gave up after maxRetries without a clean result. */
|
|
34
|
+
exhausted: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface Corrector {
|
|
37
|
+
/**
|
|
38
|
+
* Given a question, schema context, and an initial plan result, run the
|
|
39
|
+
* plan through validation/execution and re-plan on failure up to maxRetries.
|
|
40
|
+
*
|
|
41
|
+
* The `execute` callback encapsulates the validate → estimate → execute
|
|
42
|
+
* pipeline. It should throw on SQL errors (rejected promise) or resolve
|
|
43
|
+
* to an ExecutionResult. The corrector decides whether a zero-row result
|
|
44
|
+
* warrants a retry based on the zero-row heuristic.
|
|
45
|
+
*/
|
|
46
|
+
correct(question: string, context: RetrievedSchemaChunk[], initialPlan: PlanResult, execute: (sql: string) => Promise<ExecutionResult>): Promise<CorrectionResult>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns true when a zero-row result is likely a query bug rather than a
|
|
50
|
+
* legitimately empty result.
|
|
51
|
+
*
|
|
52
|
+
* Heuristic: if the top-level query has no WHERE clause (or the WHERE clause
|
|
53
|
+
* contains no literal value comparisons), a zero-row result from what should
|
|
54
|
+
* be an aggregation or full-table query is suspicious. If there are specific
|
|
55
|
+
* literal filters (WHERE county_name = 'Providence County'), the empty result
|
|
56
|
+
* is more likely legitimate.
|
|
57
|
+
*
|
|
58
|
+
* Conservatively returns false (don't retry) when parsing fails.
|
|
59
|
+
*/
|
|
60
|
+
export declare function isLikelyZeroRowBug(sql: string): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Create a Corrector that wraps a Planner in a retry loop.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const corrector = createCorrector({ planner, maxRetries: 3 });
|
|
67
|
+
* const result = await corrector.correct(question, context, initialPlan, executeFn);
|
|
68
|
+
* if (result.exhausted) throw new Error("Could not produce a valid query.");
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare function createCorrector(config: CorrectorConfig): Corrector;
|
|
72
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/corrector/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAO5D,MAAM,WAAW,eAAe;IAC9B,iEAAiE;IACjE,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,8EAA8E;IAC9E,IAAI,EAAE,UAAU,CAAC;IACjB;;;OAGG;IACH,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,+EAA+E;IAC/E,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB;;;;;;;;OAQG;IACH,OAAO,CACL,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,oBAAoB,EAAE,EAC/B,WAAW,EAAE,UAAU,EACvB,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,CAAC,GACjD,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC9B;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAyBvD;AAQD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CA0DlE"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Corrector
|
|
3
|
+
*
|
|
4
|
+
* Error-driven re-planning loop: on execution error or a suspicious zero-row
|
|
5
|
+
* result, re-invokes the planner with the failure context appended to the
|
|
6
|
+
* prompt (via PlanOptions.errorContext), capped at maxRetries attempts.
|
|
7
|
+
*
|
|
8
|
+
* Zero-row heuristic: zero rows from a broad aggregation (no WHERE clause
|
|
9
|
+
* with specific values) is flagged as a likely query bug and triggers a retry.
|
|
10
|
+
* Zero rows from a query with specific WHERE filters is treated as a
|
|
11
|
+
* legitimately empty result and returned as-is.
|
|
12
|
+
*/
|
|
13
|
+
import { parse } from "pgsql-ast-parser";
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// Zero-row heuristic
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
/**
|
|
18
|
+
* Returns true when a zero-row result is likely a query bug rather than a
|
|
19
|
+
* legitimately empty result.
|
|
20
|
+
*
|
|
21
|
+
* Heuristic: if the top-level query has no WHERE clause (or the WHERE clause
|
|
22
|
+
* contains no literal value comparisons), a zero-row result from what should
|
|
23
|
+
* be an aggregation or full-table query is suspicious. If there are specific
|
|
24
|
+
* literal filters (WHERE county_name = 'Providence County'), the empty result
|
|
25
|
+
* is more likely legitimate.
|
|
26
|
+
*
|
|
27
|
+
* Conservatively returns false (don't retry) when parsing fails.
|
|
28
|
+
*/
|
|
29
|
+
export function isLikelyZeroRowBug(sql) {
|
|
30
|
+
try {
|
|
31
|
+
const stmts = parse(sql);
|
|
32
|
+
const stmt = stmts[0];
|
|
33
|
+
if (!stmt)
|
|
34
|
+
return false;
|
|
35
|
+
// Unwrap WITH statements to their inner SELECT
|
|
36
|
+
const selectStmt = stmt.type === "with"
|
|
37
|
+
? stmt.in
|
|
38
|
+
: stmt.type === "select"
|
|
39
|
+
? stmt
|
|
40
|
+
: null;
|
|
41
|
+
if (!selectStmt || selectStmt.type !== "select")
|
|
42
|
+
return false;
|
|
43
|
+
// If there's no WHERE clause at all, a zero-row result is suspicious
|
|
44
|
+
if (!("where" in selectStmt) || selectStmt.where == null)
|
|
45
|
+
return true;
|
|
46
|
+
// If there IS a WHERE clause, conservatively trust it — the result may
|
|
47
|
+
// legitimately be empty for those specific filter values.
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
// Factory
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
const DEFAULT_MAX_RETRIES = 3;
|
|
58
|
+
/**
|
|
59
|
+
* Create a Corrector that wraps a Planner in a retry loop.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const corrector = createCorrector({ planner, maxRetries: 3 });
|
|
64
|
+
* const result = await corrector.correct(question, context, initialPlan, executeFn);
|
|
65
|
+
* if (result.exhausted) throw new Error("Could not produce a valid query.");
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export function createCorrector(config) {
|
|
69
|
+
const maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
70
|
+
return {
|
|
71
|
+
async correct(question, context, initialPlan, execute) {
|
|
72
|
+
const attempts = [];
|
|
73
|
+
let currentPlan = initialPlan;
|
|
74
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
75
|
+
// Attempt execution of the current plan
|
|
76
|
+
let execResult;
|
|
77
|
+
try {
|
|
78
|
+
execResult = await execute(currentPlan.sql);
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
// Execution error — record the attempt and re-plan if retries remain
|
|
82
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
83
|
+
attempts.push({ sql: currentPlan.sql, error });
|
|
84
|
+
if (attempt >= maxRetries) {
|
|
85
|
+
return { plan: currentPlan, attempts, exhausted: true };
|
|
86
|
+
}
|
|
87
|
+
currentPlan = await config.planner.plan(question, context, {
|
|
88
|
+
errorContext: attempts,
|
|
89
|
+
});
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
// Execution succeeded — check the zero-row heuristic
|
|
93
|
+
if (execResult.rowCount === 0 && isLikelyZeroRowBug(currentPlan.sql)) {
|
|
94
|
+
const error = "Query returned 0 rows from a query with no WHERE filters — " +
|
|
95
|
+
"this is likely a schema mismatch or incorrect table reference.";
|
|
96
|
+
attempts.push({ sql: currentPlan.sql, error });
|
|
97
|
+
if (attempt >= maxRetries) {
|
|
98
|
+
return { plan: currentPlan, attempts, exhausted: true };
|
|
99
|
+
}
|
|
100
|
+
currentPlan = await config.planner.plan(question, context, {
|
|
101
|
+
errorContext: attempts,
|
|
102
|
+
});
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
// Clean result — return it (with any accumulated prior attempts)
|
|
106
|
+
return { plan: currentPlan, attempts, exhausted: false };
|
|
107
|
+
}
|
|
108
|
+
// Should be unreachable but TypeScript needs it
|
|
109
|
+
return { plan: currentPlan, attempts, exhausted: true };
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/corrector/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AA8CzC,8EAA8E;AAC9E,qBAAqB;AACrB,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;wBACzD,YAAY,EAAE,QAAQ;qBACvB,CAAC,CAAC;oBACH,SAAS;gBACX,CAAC;gBAED,iEAAiE;gBACjE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;YAC3D,CAAC;YAED,gDAAgD;YAChD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC1D,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC3D,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/db/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared pg Pool factory.
|
|
3
|
+
*
|
|
4
|
+
* All stages that need a database connection should create their pool through
|
|
5
|
+
* one of these factories so that connection defaults are applied consistently
|
|
6
|
+
* across the SDK.
|
|
7
|
+
*
|
|
8
|
+
* pg is a peerDependency of @pgsage/core — the caller is responsible for
|
|
9
|
+
* installing it. We import via a type-only import so that the factory
|
|
10
|
+
* signature is typed at build time without bundling pg.
|
|
11
|
+
*/
|
|
12
|
+
declare const Pool: typeof import("pg").Pool;
|
|
13
|
+
export interface PoolOptions {
|
|
14
|
+
/** Maximum number of connections in the pool. Default: 5. */
|
|
15
|
+
max?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Milliseconds a client may sit idle before being closed.
|
|
18
|
+
* Default: 30 000 ms.
|
|
19
|
+
*/
|
|
20
|
+
idleTimeoutMillis?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Milliseconds to wait for a connection before throwing.
|
|
23
|
+
* Default: 5 000 ms.
|
|
24
|
+
*/
|
|
25
|
+
connectionTimeoutMillis?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Per-query statement timeout in milliseconds.
|
|
28
|
+
* Passed as a SET option on every acquired client.
|
|
29
|
+
* Default: 30 000 ms.
|
|
30
|
+
*/
|
|
31
|
+
statementTimeout?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a read-write pool for admin operations (migrations, loaders,
|
|
35
|
+
* introspection, embedding indexing).
|
|
36
|
+
*/
|
|
37
|
+
export declare function createPool(connectionString: string, options?: PoolOptions): InstanceType<typeof Pool>;
|
|
38
|
+
/**
|
|
39
|
+
* Create a read-only pool for the executor stage.
|
|
40
|
+
* Identical to createPool but semantically scoped to a read-only role
|
|
41
|
+
* connection string — no additional restrictions are enforced here beyond
|
|
42
|
+
* what the DB role itself restricts.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createReadonlyPool(connectionString: string, options?: PoolOptions): InstanceType<typeof Pool>;
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=pool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/db/pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,QAAA,MAAQ,IAAI,0BAAO,CAAC;AAEpB,MAAM,WAAW,WAAW;IAC1B,6DAA6D;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAaD;;;GAGG;AACH,wBAAgB,UAAU,CACxB,gBAAgB,EAAE,MAAM,EACxB,OAAO,GAAE,WAAgB,GACxB,YAAY,CAAC,OAAO,IAAI,CAAC,CAS3B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,gBAAgB,EAAE,MAAM,EACxB,OAAO,GAAE,WAAgB,GACxB,YAAY,CAAC,OAAO,IAAI,CAAC,CAE3B"}
|
package/dist/db/pool.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared pg Pool factory.
|
|
3
|
+
*
|
|
4
|
+
* All stages that need a database connection should create their pool through
|
|
5
|
+
* one of these factories so that connection defaults are applied consistently
|
|
6
|
+
* across the SDK.
|
|
7
|
+
*
|
|
8
|
+
* pg is a peerDependency of @pgsage/core — the caller is responsible for
|
|
9
|
+
* installing it. We import via a type-only import so that the factory
|
|
10
|
+
* signature is typed at build time without bundling pg.
|
|
11
|
+
*/
|
|
12
|
+
import pg from "pg";
|
|
13
|
+
const { Pool } = pg;
|
|
14
|
+
const DEFAULTS = {
|
|
15
|
+
max: 5,
|
|
16
|
+
idleTimeoutMillis: 30_000,
|
|
17
|
+
connectionTimeoutMillis: 5_000,
|
|
18
|
+
statementTimeout: 30_000,
|
|
19
|
+
};
|
|
20
|
+
function applyDefaults(options = {}) {
|
|
21
|
+
return { ...DEFAULTS, ...options };
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Create a read-write pool for admin operations (migrations, loaders,
|
|
25
|
+
* introspection, embedding indexing).
|
|
26
|
+
*/
|
|
27
|
+
export function createPool(connectionString, options = {}) {
|
|
28
|
+
const opts = applyDefaults(options);
|
|
29
|
+
return new Pool({
|
|
30
|
+
connectionString,
|
|
31
|
+
max: opts.max,
|
|
32
|
+
idleTimeoutMillis: opts.idleTimeoutMillis,
|
|
33
|
+
connectionTimeoutMillis: opts.connectionTimeoutMillis,
|
|
34
|
+
options: `--statement_timeout=${opts.statementTimeout}`,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a read-only pool for the executor stage.
|
|
39
|
+
* Identical to createPool but semantically scoped to a read-only role
|
|
40
|
+
* connection string — no additional restrictions are enforced here beyond
|
|
41
|
+
* what the DB role itself restricts.
|
|
42
|
+
*/
|
|
43
|
+
export function createReadonlyPool(connectionString, options = {}) {
|
|
44
|
+
return createPool(connectionString, options);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../src/db/pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;AAuBpB,MAAM,QAAQ,GAA0B;IACtC,GAAG,EAAE,CAAC;IACN,iBAAiB,EAAE,MAAM;IACzB,uBAAuB,EAAE,KAAK;IAC9B,gBAAgB,EAAE,MAAM;CACzB,CAAC;AAEF,SAAS,aAAa,CAAC,UAAuB,EAAE;IAC9C,OAAO,EAAE,GAAG,QAAQ,EAAE,GAAG,OAAO,EAAE,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,gBAAwB,EACxB,UAAuB,EAAE;IAEzB,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACpC,OAAO,IAAI,IAAI,CAAC;QACd,gBAAgB;QAChB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;QACzC,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;QACrD,OAAO,EAAE,uBAAuB,IAAI,CAAC,gBAAgB,EAAE;KACxD,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,gBAAwB,EACxB,UAAuB,EAAE;IAEzB,OAAO,UAAU,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/embeddings/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACtE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/embeddings/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EmbeddingProvider — provider-agnostic interface for text embedding.
|
|
3
|
+
*
|
|
4
|
+
* The retriever depends on this interface rather than any concrete
|
|
5
|
+
* implementation so that alternative providers (OpenAI, Cohere, local
|
|
6
|
+
* models, etc.) can be substituted without modifying retriever logic.
|
|
7
|
+
*
|
|
8
|
+
* Contract:
|
|
9
|
+
* - embed() returns one embedding vector per input text, in the same order.
|
|
10
|
+
* - All vectors returned by a single provider instance have the same length
|
|
11
|
+
* (equal to `dimensions`).
|
|
12
|
+
* - inputType is a hint to the provider; providers that do not distinguish
|
|
13
|
+
* query vs document may safely ignore it.
|
|
14
|
+
*/
|
|
15
|
+
export type EmbeddingInputType = "query" | "document";
|
|
16
|
+
export interface EmbeddingResult {
|
|
17
|
+
/** One float32 vector per input text, in input order. */
|
|
18
|
+
embeddings: number[][];
|
|
19
|
+
/** Total tokens consumed (for cost tracking / logging). */
|
|
20
|
+
totalTokens: number;
|
|
21
|
+
/** The model identifier that produced these embeddings. */
|
|
22
|
+
model: string;
|
|
23
|
+
}
|
|
24
|
+
export interface EmbeddingProvider {
|
|
25
|
+
/**
|
|
26
|
+
* Embed one or more texts.
|
|
27
|
+
*
|
|
28
|
+
* @param texts Non-empty array of strings to embed.
|
|
29
|
+
* @param inputType Optional hint: 'document' for corpus content,
|
|
30
|
+
* 'query' for user questions. Allows providers like
|
|
31
|
+
* Voyage to prepend retrieval-optimised prompts.
|
|
32
|
+
*/
|
|
33
|
+
embed(this: void, texts: string[], inputType?: EmbeddingInputType): Promise<EmbeddingResult>;
|
|
34
|
+
/** Number of dimensions in each returned vector. */
|
|
35
|
+
readonly dimensions: number;
|
|
36
|
+
/** Human-readable model identifier (e.g. 'voyage-4-lite'). */
|
|
37
|
+
readonly modelId: string;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/embeddings/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,UAAU,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC9B,yDAAyD;IACzD,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC;IACvB,2DAA2D;IAC3D,WAAW,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE7F,oDAAoD;IACpD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EmbeddingProvider — provider-agnostic interface for text embedding.
|
|
3
|
+
*
|
|
4
|
+
* The retriever depends on this interface rather than any concrete
|
|
5
|
+
* implementation so that alternative providers (OpenAI, Cohere, local
|
|
6
|
+
* models, etc.) can be substituted without modifying retriever logic.
|
|
7
|
+
*
|
|
8
|
+
* Contract:
|
|
9
|
+
* - embed() returns one embedding vector per input text, in the same order.
|
|
10
|
+
* - All vectors returned by a single provider instance have the same length
|
|
11
|
+
* (equal to `dimensions`).
|
|
12
|
+
* - inputType is a hint to the provider; providers that do not distinguish
|
|
13
|
+
* query vs document may safely ignore it.
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/embeddings/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VoyageEmbeddingProvider
|
|
3
|
+
*
|
|
4
|
+
* Wraps the Voyage AI REST API (https://api.voyageai.com/v1/embeddings)
|
|
5
|
+
* using the global fetch available in Node 22+. No external dependencies.
|
|
6
|
+
*
|
|
7
|
+
* Key behaviours:
|
|
8
|
+
* - Batches large text arrays into configurable chunks to stay within
|
|
9
|
+
* Voyage's per-request token limits.
|
|
10
|
+
* - Retries 429 (rate-limit) and 5xx responses with exponential backoff.
|
|
11
|
+
* - Maps our EmbeddingInputType to Voyage's input_type param, which causes
|
|
12
|
+
* Voyage to prepend retrieval-optimised prompts server-side.
|
|
13
|
+
* - Passes output_dimension to enable Matryoshka truncation server-side.
|
|
14
|
+
*/
|
|
15
|
+
import type { EmbeddingInputType, EmbeddingProvider, EmbeddingResult } from "./types.js";
|
|
16
|
+
export type VoyageModel = "voyage-4-large" | "voyage-4" | "voyage-4-lite" | "voyage-4-nano" | (string & {});
|
|
17
|
+
export interface VoyageConfig {
|
|
18
|
+
/** Voyage AI API key. Required. */
|
|
19
|
+
apiKey: string;
|
|
20
|
+
/** Model to use. Default: 'voyage-4-lite'. */
|
|
21
|
+
model?: VoyageModel;
|
|
22
|
+
/** API base URL. Default: 'https://api.voyageai.com/v1'. */
|
|
23
|
+
baseUrl?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Output embedding dimensions.
|
|
26
|
+
* Voyage 4-series supports 256 | 512 | 1024 | 2048.
|
|
27
|
+
* Default: 1024 (matches schema_embeddings column).
|
|
28
|
+
*/
|
|
29
|
+
dimensions?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Maximum number of texts per API request.
|
|
32
|
+
* Voyage allows up to 1 000; we default to 128 to stay well under
|
|
33
|
+
* the per-request token limits for all model tiers.
|
|
34
|
+
*/
|
|
35
|
+
maxTextsPerBatch?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Whether to truncate texts that exceed the model's context length.
|
|
38
|
+
* Default: true.
|
|
39
|
+
*/
|
|
40
|
+
truncation?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Per-request timeout in milliseconds (via AbortSignal.timeout).
|
|
43
|
+
* Default: 30 000 ms.
|
|
44
|
+
*/
|
|
45
|
+
requestTimeoutMs?: number;
|
|
46
|
+
/** Maximum retry attempts on 429 / 5xx responses. Default: 3. */
|
|
47
|
+
maxRetries?: number;
|
|
48
|
+
}
|
|
49
|
+
export declare class VoyageApiError extends Error {
|
|
50
|
+
readonly status: number;
|
|
51
|
+
readonly detail: string;
|
|
52
|
+
readonly attempt: number;
|
|
53
|
+
constructor(status: number, detail: string, attempt: number);
|
|
54
|
+
}
|
|
55
|
+
export declare class VoyageEmbeddingProvider implements EmbeddingProvider {
|
|
56
|
+
private readonly apiKey;
|
|
57
|
+
private readonly model;
|
|
58
|
+
private readonly baseUrl;
|
|
59
|
+
private readonly _dimensions;
|
|
60
|
+
private readonly maxTextsPerBatch;
|
|
61
|
+
private readonly truncation;
|
|
62
|
+
private readonly requestTimeoutMs;
|
|
63
|
+
private readonly maxRetries;
|
|
64
|
+
constructor(config: VoyageConfig);
|
|
65
|
+
get dimensions(): number;
|
|
66
|
+
get modelId(): string;
|
|
67
|
+
embed(texts: string[], inputType?: EmbeddingInputType): Promise<EmbeddingResult>;
|
|
68
|
+
private embedBatch;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=voyage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voyage.d.ts","sourceRoot":"","sources":["../../src/embeddings/voyage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAMzF,MAAM,MAAM,WAAW,GACnB,gBAAgB,GAChB,UAAU,GACV,eAAe,GACf,eAAe,GACf,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAmCD,qBAAa,cAAe,SAAQ,KAAK;aAErB,MAAM,EAAE,MAAM;aACd,MAAM,EAAE,MAAM;aACd,OAAO,EAAE,MAAM;gBAFf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM;CAKlC;AAgBD,qBAAa,uBAAwB,YAAW,iBAAiB;IAC/D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC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