nttp 1.4.6 ā 1.4.10
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 +85 -1
- package/dist/cli/docs.d.ts +9 -0
- package/dist/cli/docs.d.ts.map +1 -0
- package/dist/cli/docs.js +437 -0
- package/dist/cli/docs.js.map +1 -0
- package/dist/cli/setup-ink.d.ts +15 -2
- package/dist/cli/setup-ink.d.ts.map +1 -1
- package/dist/cli/setup-ink.js +21 -3
- package/dist/cli/setup-ink.js.map +1 -1
- package/dist/cli/setup-non-interactive.d.ts +17 -0
- package/dist/cli/setup-non-interactive.d.ts.map +1 -0
- package/dist/cli/setup-non-interactive.js +166 -0
- package/dist/cli/setup-non-interactive.js.map +1 -0
- package/dist/cli.js +18 -2
- package/dist/cli.js.map +1 -1
- package/dist/errors.d.ts +99 -6
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +173 -11
- package/dist/errors.js.map +1 -1
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js +73 -12
- package/dist/executor.js.map +1 -1
- package/dist/intent.d.ts.map +1 -1
- package/dist/intent.js +125 -17
- package/dist/intent.js.map +1 -1
- package/dist/llm.d.ts +25 -0
- package/dist/llm.d.ts.map +1 -1
- package/dist/llm.js +25 -0
- package/dist/llm.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Non-interactive setup for LLM agents and automation
|
|
3
|
+
*/
|
|
4
|
+
import { writeFileSync, existsSync } from 'fs';
|
|
5
|
+
import { execSync } from 'child_process';
|
|
6
|
+
const LLM_MODELS = {
|
|
7
|
+
anthropic: 'claude-sonnet-4-5-20250929',
|
|
8
|
+
openai: 'gpt-4o',
|
|
9
|
+
cohere: 'command-r-plus',
|
|
10
|
+
mistral: 'mistral-large-latest',
|
|
11
|
+
google: 'gemini-pro',
|
|
12
|
+
};
|
|
13
|
+
export function runNonInteractiveSetup(options) {
|
|
14
|
+
console.log('š¤ Running non-interactive setup...\n');
|
|
15
|
+
// Validate required options
|
|
16
|
+
const errors = [];
|
|
17
|
+
if (!options.databaseType) {
|
|
18
|
+
errors.push('--database-type is required (pg, mysql2, better-sqlite3, mssql)');
|
|
19
|
+
}
|
|
20
|
+
if (options.databaseType === 'better-sqlite3') {
|
|
21
|
+
if (!options.databasePath) {
|
|
22
|
+
errors.push('--database-path is required for SQLite');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
if (!options.databaseUrl) {
|
|
27
|
+
errors.push('--database-url is required');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (!options.llmProvider) {
|
|
31
|
+
errors.push('--llm-provider is required (anthropic, openai, cohere, mistral, google)');
|
|
32
|
+
}
|
|
33
|
+
if (!options.llmApiKey) {
|
|
34
|
+
errors.push('--llm-api-key is required');
|
|
35
|
+
}
|
|
36
|
+
if (options.enableL2Cache && !options.embeddingApiKey) {
|
|
37
|
+
errors.push('--embedding-api-key is required when --enable-l2-cache is set');
|
|
38
|
+
}
|
|
39
|
+
if (errors.length > 0) {
|
|
40
|
+
console.error('ā Configuration errors:\n');
|
|
41
|
+
errors.forEach(err => console.error(` ⢠${err}`));
|
|
42
|
+
console.error('\nš” Example usage:');
|
|
43
|
+
console.error(' npx nttp setup --non-interactive \\');
|
|
44
|
+
console.error(' --database-type=pg \\');
|
|
45
|
+
console.error(' --database-url=postgresql://user:pass@localhost/db \\');
|
|
46
|
+
console.error(' --llm-provider=anthropic \\');
|
|
47
|
+
console.error(' --llm-api-key=sk-ant-... \\');
|
|
48
|
+
console.error(' --redis-url=redis://localhost:6379 \\');
|
|
49
|
+
console.error(' --enable-l2-cache \\');
|
|
50
|
+
console.error(' --embedding-api-key=sk-...');
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
// Auto-fill model if not provided
|
|
54
|
+
const llmModel = options.llmModel || LLM_MODELS[options.llmProvider];
|
|
55
|
+
console.log('ā Configuration validated');
|
|
56
|
+
console.log('ā Creating .env file...');
|
|
57
|
+
// Generate .env file
|
|
58
|
+
const envLines = [
|
|
59
|
+
'# nttp configuration',
|
|
60
|
+
'# Generated by nttp setup --non-interactive',
|
|
61
|
+
'',
|
|
62
|
+
'# Database',
|
|
63
|
+
];
|
|
64
|
+
if (options.databaseType === 'better-sqlite3') {
|
|
65
|
+
envLines.push(`DATABASE_PATH=${options.databasePath}`);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
envLines.push(`DATABASE_URL=${options.databaseUrl}`);
|
|
69
|
+
}
|
|
70
|
+
envLines.push(`DATABASE_TYPE=${options.databaseType}`);
|
|
71
|
+
envLines.push('');
|
|
72
|
+
envLines.push('# LLM Provider');
|
|
73
|
+
envLines.push(`LLM_PROVIDER=${options.llmProvider}`);
|
|
74
|
+
envLines.push(`LLM_MODEL=${llmModel}`);
|
|
75
|
+
const envKeys = {
|
|
76
|
+
anthropic: 'ANTHROPIC_API_KEY',
|
|
77
|
+
openai: 'OPENAI_API_KEY',
|
|
78
|
+
cohere: 'COHERE_API_KEY',
|
|
79
|
+
mistral: 'MISTRAL_API_KEY',
|
|
80
|
+
google: 'GOOGLE_API_KEY',
|
|
81
|
+
};
|
|
82
|
+
envLines.push(`${envKeys[options.llmProvider]}=${options.llmApiKey}`);
|
|
83
|
+
if (options.redisUrl) {
|
|
84
|
+
envLines.push('');
|
|
85
|
+
envLines.push('# Redis Cache');
|
|
86
|
+
envLines.push(`REDIS_URL=${options.redisUrl}`);
|
|
87
|
+
}
|
|
88
|
+
if (options.enableL2Cache) {
|
|
89
|
+
envLines.push('');
|
|
90
|
+
envLines.push('# Semantic Cache');
|
|
91
|
+
envLines.push('EMBEDDING_PROVIDER=openai');
|
|
92
|
+
envLines.push(`OPENAI_API_KEY=${options.embeddingApiKey}`);
|
|
93
|
+
}
|
|
94
|
+
writeFileSync('.env', envLines.join('\n') + '\n');
|
|
95
|
+
console.log('ā .env created');
|
|
96
|
+
// Generate example code
|
|
97
|
+
console.log('ā Creating nttp-example.js...');
|
|
98
|
+
const code = `/**
|
|
99
|
+
* NTTP Example - Ready to run!
|
|
100
|
+
* Run: node nttp-example.js or npm start
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
import 'dotenv/config';
|
|
104
|
+
import { NTTP } from 'nttp';
|
|
105
|
+
|
|
106
|
+
async function main() {
|
|
107
|
+
// Load configuration from .env
|
|
108
|
+
const nttp = await NTTP.fromEnv();
|
|
109
|
+
|
|
110
|
+
console.log('ā Connected to database');
|
|
111
|
+
|
|
112
|
+
// Run a natural language query
|
|
113
|
+
const result = await nttp.query('show me 5 records');
|
|
114
|
+
|
|
115
|
+
console.log(\`\\nā Query succeeded! Got \${result.data.length} rows\`);
|
|
116
|
+
console.log(\` Generated SQL: \${result.sql}\`);
|
|
117
|
+
console.log(\` Cache hit: \${result.cacheHit}\`);
|
|
118
|
+
console.log(\` Time: \${result.executionTimeMs}ms\\n\`);
|
|
119
|
+
|
|
120
|
+
// Display results
|
|
121
|
+
console.table(result.data);
|
|
122
|
+
|
|
123
|
+
// Cleanup
|
|
124
|
+
await nttp.close();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
main().catch(console.error);
|
|
128
|
+
`;
|
|
129
|
+
writeFileSync('nttp-example.js', code);
|
|
130
|
+
console.log('ā nttp-example.js created');
|
|
131
|
+
// Create package.json if it doesn't exist
|
|
132
|
+
if (!existsSync('package.json')) {
|
|
133
|
+
console.log('ā Creating package.json...');
|
|
134
|
+
const packageJson = {
|
|
135
|
+
name: 'nttp-project',
|
|
136
|
+
version: '1.0.0',
|
|
137
|
+
type: 'module',
|
|
138
|
+
scripts: {
|
|
139
|
+
start: 'node nttp-example.js'
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
writeFileSync('package.json', JSON.stringify(packageJson, null, 2));
|
|
143
|
+
console.log('ā package.json created');
|
|
144
|
+
}
|
|
145
|
+
// Install dependencies
|
|
146
|
+
console.log('ā Installing dependencies (nttp, dotenv)...');
|
|
147
|
+
try {
|
|
148
|
+
execSync('npm install nttp dotenv', { stdio: 'inherit' });
|
|
149
|
+
console.log('ā Dependencies installed');
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
console.error('ā Failed to install dependencies. Please run: npm install nttp dotenv');
|
|
153
|
+
}
|
|
154
|
+
// Success message
|
|
155
|
+
console.log('\nā
Setup complete!\n');
|
|
156
|
+
console.log('Created:');
|
|
157
|
+
console.log(' ⢠.env (your configuration)');
|
|
158
|
+
console.log(' ⢠nttp-example.js (example code)');
|
|
159
|
+
console.log(' ⢠package.json (if not exists)');
|
|
160
|
+
console.log(' ⢠node_modules/ (installed nttp, dotenv)\n');
|
|
161
|
+
console.log('Next steps:');
|
|
162
|
+
console.log(' 1. Try CLI: npx nttp query "show me 5 records"');
|
|
163
|
+
console.log(' 2. Or run code: node nttp-example.js');
|
|
164
|
+
console.log(' 3. Or use in your code: npm start\n');
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=setup-non-interactive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-non-interactive.js","sourceRoot":"","sources":["../../src/cli/setup-non-interactive.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAczC,MAAM,UAAU,GAA2B;IACzC,SAAS,EAAE,4BAA4B;IACvC,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,gBAAgB;IACxB,OAAO,EAAE,sBAAsB;IAC/B,MAAM,EAAE,YAAY;CACrB,CAAC;AAEF,MAAM,UAAU,sBAAsB,CAAC,OAA6B;IAClE,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;IAErD,4BAA4B;IAC5B,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,IAAI,CAAC,OAAO,CAA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-ink.js';
|
|
7
7
|
import { runQuery } from './cli/query.js';
|
|
8
8
|
import { runInit } from './cli/init.js';
|
|
9
|
+
import { runDocs } from './cli/docs.js';
|
|
9
10
|
const program = new Command();
|
|
10
11
|
program
|
|
11
12
|
.name('nttp')
|
|
12
13
|
.description('Query databases with natural language')
|
|
13
|
-
.version('1.4.
|
|
14
|
+
.version('1.4.10');
|
|
14
15
|
program
|
|
15
16
|
.command('setup')
|
|
16
|
-
.description('Interactive setup wizard')
|
|
17
|
+
.description('Interactive setup wizard (or use --non-interactive for agents)')
|
|
18
|
+
.option('--non-interactive', 'Run setup without interactive prompts (for agents/automation)')
|
|
19
|
+
.option('--database-type <type>', 'Database type: pg, mysql2, better-sqlite3, mssql')
|
|
20
|
+
.option('--database-url <url>', 'Database connection URL')
|
|
21
|
+
.option('--database-path <path>', 'SQLite database path (for better-sqlite3)')
|
|
22
|
+
.option('--llm-provider <provider>', 'LLM provider: anthropic, openai, cohere, mistral, google')
|
|
23
|
+
.option('--llm-model <model>', 'LLM model name')
|
|
24
|
+
.option('--llm-api-key <key>', 'LLM API key')
|
|
25
|
+
.option('--redis-url <url>', 'Redis URL for L1 cache persistence (optional)')
|
|
26
|
+
.option('--enable-l2-cache', 'Enable L2 semantic cache (optional)')
|
|
27
|
+
.option('--embedding-api-key <key>', 'OpenAI API key for embeddings (required if --enable-l2-cache)')
|
|
17
28
|
.action(runSetup);
|
|
18
29
|
program
|
|
19
30
|
.command('init')
|
|
@@ -24,5 +35,10 @@ program
|
|
|
24
35
|
.description('Execute a natural language query')
|
|
25
36
|
.option('-f, --format <type>', 'Output format (json|table)', 'table')
|
|
26
37
|
.action(runQuery);
|
|
38
|
+
program
|
|
39
|
+
.command('docs [query]')
|
|
40
|
+
.description('Show documentation (optionally search with query)')
|
|
41
|
+
.option('-q, --query <search>', 'Search query for documentation')
|
|
42
|
+
.action(runDocs);
|
|
27
43
|
program.parse();
|
|
28
44
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,MAAM,CAAC;KACZ,WAAW,CAAC,uCAAuC,CAAC;KACpD,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,MAAM,CAAC;KACZ,WAAW,CAAC,uCAAuC,CAAC;KACpD,OAAO,CAAC,QAAQ,CAAC,CAAC;AAErB,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,gEAAgE,CAAC;KAC7E,MAAM,CAAC,mBAAmB,EAAE,+DAA+D,CAAC;KAC5F,MAAM,CAAC,wBAAwB,EAAE,kDAAkD,CAAC;KACpF,MAAM,CAAC,sBAAsB,EAAE,yBAAyB,CAAC;KACzD,MAAM,CAAC,wBAAwB,EAAE,2CAA2C,CAAC;KAC7E,MAAM,CAAC,2BAA2B,EAAE,0DAA0D,CAAC;KAC/F,MAAM,CAAC,qBAAqB,EAAE,gBAAgB,CAAC;KAC/C,MAAM,CAAC,qBAAqB,EAAE,aAAa,CAAC;KAC5C,MAAM,CAAC,mBAAmB,EAAE,+CAA+C,CAAC;KAC5E,MAAM,CAAC,mBAAmB,EAAE,qCAAqC,CAAC;KAClE,MAAM,CAAC,2BAA2B,EAAE,+DAA+D,CAAC;KACpG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,oCAAoC,CAAC;KACjD,MAAM,CAAC,OAAO,CAAC,CAAC;AAEnB,OAAO;KACJ,OAAO,CAAC,cAAc,CAAC;KACvB,WAAW,CAAC,kCAAkC,CAAC;KAC/C,MAAM,CAAC,qBAAqB,EAAE,4BAA4B,EAAE,OAAO,CAAC;KACpE,MAAM,CAAC,QAAQ,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,cAAc,CAAC;KACvB,WAAW,CAAC,mDAAmD,CAAC;KAChE,MAAM,CAAC,sBAAsB,EAAE,gCAAgC,CAAC;KAChE,MAAM,CAAC,OAAO,CAAC,CAAC;AAEnB,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,35 +1,128 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Custom error classes for NTTP application.
|
|
3
|
-
*
|
|
3
|
+
* Enhanced with Claude 4.x best practices: clear explanations and actionable suggestions.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* Error thrown when intent parsing fails.
|
|
7
|
+
*
|
|
8
|
+
* This error occurs when the LLM cannot understand the natural language query
|
|
9
|
+
* or cannot map it to a valid database operation.
|
|
10
|
+
*
|
|
11
|
+
* Common causes:
|
|
12
|
+
* - Query references unknown tables or fields
|
|
13
|
+
* - Query is too ambiguous or vague
|
|
14
|
+
* - LLM API is unavailable or quota exceeded
|
|
15
|
+
*
|
|
16
|
+
* Suggested fixes:
|
|
17
|
+
* - Simplify your query (e.g., "show users" instead of complex phrasing)
|
|
18
|
+
* - Ensure table/field names match your database schema
|
|
19
|
+
* - Check LLM API key and quota
|
|
20
|
+
* - Try a more explicit query (e.g., "list all products" instead of "products")
|
|
7
21
|
*/
|
|
8
22
|
export declare class IntentParseError extends Error {
|
|
9
|
-
|
|
23
|
+
readonly suggestions: string[];
|
|
24
|
+
constructor(message: string, suggestions?: string[]);
|
|
25
|
+
private static formatMessage;
|
|
26
|
+
private static getDefaultSuggestions;
|
|
10
27
|
}
|
|
11
28
|
/**
|
|
12
29
|
* Error thrown when SQL generation fails.
|
|
30
|
+
*
|
|
31
|
+
* This error occurs when the LLM cannot generate valid SQL from the parsed intent,
|
|
32
|
+
* or when the generated SQL fails safety validation.
|
|
33
|
+
*
|
|
34
|
+
* Common causes:
|
|
35
|
+
* - Complex query requires table relationships not in schema
|
|
36
|
+
* - Generated SQL violates safety rules (e.g., attempted UPDATE/DELETE)
|
|
37
|
+
* - Schema description is incomplete or incorrect
|
|
38
|
+
* - LLM hallucinated invalid SQL syntax
|
|
39
|
+
*
|
|
40
|
+
* Suggested fixes:
|
|
41
|
+
* - Ensure your database schema is complete and accurate
|
|
42
|
+
* - Try a simpler query with fewer joins
|
|
43
|
+
* - Check that the LLM model supports structured outputs
|
|
44
|
+
* - Verify the intent was parsed correctly (use explain() method)
|
|
13
45
|
*/
|
|
14
46
|
export declare class SQLGenerationError extends Error {
|
|
15
|
-
|
|
47
|
+
readonly suggestions: string[];
|
|
48
|
+
constructor(message: string, suggestions?: string[]);
|
|
49
|
+
private static formatMessage;
|
|
50
|
+
private static getDefaultSuggestions;
|
|
16
51
|
}
|
|
17
52
|
/**
|
|
18
53
|
* Error thrown when SQL execution fails.
|
|
54
|
+
*
|
|
55
|
+
* This error occurs when the database rejects the generated SQL query.
|
|
56
|
+
*
|
|
57
|
+
* Common causes:
|
|
58
|
+
* - Database connection issues
|
|
59
|
+
* - Table or column doesn't exist (schema mismatch)
|
|
60
|
+
* - Type mismatch in WHERE clause (e.g., string vs integer)
|
|
61
|
+
* - Database permissions insufficient for SELECT
|
|
62
|
+
* - Syntax error in generated SQL
|
|
63
|
+
*
|
|
64
|
+
* Suggested fixes:
|
|
65
|
+
* - Verify database connection is active
|
|
66
|
+
* - Ensure schema matches actual database structure
|
|
67
|
+
* - Check database user has SELECT permissions
|
|
68
|
+
* - Examine the generated SQL for syntax errors
|
|
69
|
+
* - Try regenerating with forceNewSchema option
|
|
19
70
|
*/
|
|
20
71
|
export declare class SQLExecutionError extends Error {
|
|
21
|
-
|
|
72
|
+
readonly sql?: string;
|
|
73
|
+
readonly suggestions: string[];
|
|
74
|
+
constructor(message: string, sql?: string, suggestions?: string[]);
|
|
75
|
+
private static formatMessage;
|
|
76
|
+
private static getDefaultSuggestions;
|
|
22
77
|
}
|
|
23
78
|
/**
|
|
24
79
|
* Error thrown when LLM API calls fail.
|
|
80
|
+
*
|
|
81
|
+
* This error occurs when communication with the LLM provider fails.
|
|
82
|
+
*
|
|
83
|
+
* Common causes:
|
|
84
|
+
* - Invalid or expired API key
|
|
85
|
+
* - Rate limit or quota exceeded
|
|
86
|
+
* - Network connectivity issues
|
|
87
|
+
* - LLM provider service outage
|
|
88
|
+
* - Request timeout
|
|
89
|
+
*
|
|
90
|
+
* Suggested fixes:
|
|
91
|
+
* - Verify API key is correct and active
|
|
92
|
+
* - Check API quota and rate limits with provider
|
|
93
|
+
* - Ensure network connectivity to LLM provider
|
|
94
|
+
* - Wait and retry (automatic retry with backoff is already applied)
|
|
95
|
+
* - Check LLM provider status page for outages
|
|
25
96
|
*/
|
|
26
97
|
export declare class LLMError extends Error {
|
|
27
|
-
|
|
98
|
+
readonly suggestions: string[];
|
|
99
|
+
constructor(message: string, suggestions?: string[]);
|
|
100
|
+
private static formatMessage;
|
|
101
|
+
private static getDefaultSuggestions;
|
|
28
102
|
}
|
|
29
103
|
/**
|
|
30
104
|
* Error thrown when cache operations fail.
|
|
105
|
+
*
|
|
106
|
+
* This error occurs when the caching system encounters an issue.
|
|
107
|
+
*
|
|
108
|
+
* Common causes:
|
|
109
|
+
* - Redis connection failed (if using Redis L1 cache)
|
|
110
|
+
* - Redis authentication error
|
|
111
|
+
* - Network issues with Redis server
|
|
112
|
+
* - Embedding API failure (if using L2 semantic cache)
|
|
113
|
+
* - Out of memory for in-memory caches
|
|
114
|
+
*
|
|
115
|
+
* Suggested fixes:
|
|
116
|
+
* - Verify Redis server is running (if using Redis)
|
|
117
|
+
* - Check REDIS_URL format: redis://host:port
|
|
118
|
+
* - Ensure Redis authentication credentials are correct
|
|
119
|
+
* - Check OpenAI API key for embeddings (if L2 enabled)
|
|
120
|
+
* - Reduce cache size limits if memory is constrained
|
|
31
121
|
*/
|
|
32
122
|
export declare class CacheError extends Error {
|
|
33
|
-
|
|
123
|
+
readonly suggestions: string[];
|
|
124
|
+
constructor(message: string, suggestions?: string[]);
|
|
125
|
+
private static formatMessage;
|
|
126
|
+
private static getDefaultSuggestions;
|
|
34
127
|
}
|
|
35
128
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,SAAgB,WAAW,EAAE,MAAM,EAAE,CAAC;gBAE1B,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE;IAQnD,OAAO,CAAC,MAAM,CAAC,aAAa;IAK5B,OAAO,CAAC,MAAM,CAAC,qBAAqB;CAQrC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,SAAgB,WAAW,EAAE,MAAM,EAAE,CAAC;gBAE1B,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE;IAQnD,OAAO,CAAC,MAAM,CAAC,aAAa;IAK5B,OAAO,CAAC,MAAM,CAAC,qBAAqB;CAQrC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,SAAgB,GAAG,CAAC,EAAE,MAAM,CAAC;IAC7B,SAAgB,WAAW,EAAE,MAAM,EAAE,CAAC;gBAE1B,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE;IASjE,OAAO,CAAC,MAAM,CAAC,aAAa;IAU5B,OAAO,CAAC,MAAM,CAAC,qBAAqB;CASrC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,SAAgB,WAAW,EAAE,MAAM,EAAE,CAAC;gBAE1B,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE;IAQnD,OAAO,CAAC,MAAM,CAAC,aAAa;IAK5B,OAAO,CAAC,MAAM,CAAC,qBAAqB;CASrC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,SAAgB,WAAW,EAAE,MAAM,EAAE,CAAC;gBAE1B,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE;IAQnD,OAAO,CAAC,MAAM,CAAC,aAAa;IAK5B,OAAO,CAAC,MAAM,CAAC,qBAAqB;CASrC"}
|
package/dist/errors.js
CHANGED
|
@@ -1,55 +1,217 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Custom error classes for NTTP application.
|
|
3
|
-
*
|
|
3
|
+
* Enhanced with Claude 4.x best practices: clear explanations and actionable suggestions.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* Error thrown when intent parsing fails.
|
|
7
|
+
*
|
|
8
|
+
* This error occurs when the LLM cannot understand the natural language query
|
|
9
|
+
* or cannot map it to a valid database operation.
|
|
10
|
+
*
|
|
11
|
+
* Common causes:
|
|
12
|
+
* - Query references unknown tables or fields
|
|
13
|
+
* - Query is too ambiguous or vague
|
|
14
|
+
* - LLM API is unavailable or quota exceeded
|
|
15
|
+
*
|
|
16
|
+
* Suggested fixes:
|
|
17
|
+
* - Simplify your query (e.g., "show users" instead of complex phrasing)
|
|
18
|
+
* - Ensure table/field names match your database schema
|
|
19
|
+
* - Check LLM API key and quota
|
|
20
|
+
* - Try a more explicit query (e.g., "list all products" instead of "products")
|
|
7
21
|
*/
|
|
8
22
|
export class IntentParseError extends Error {
|
|
9
|
-
|
|
10
|
-
|
|
23
|
+
suggestions;
|
|
24
|
+
constructor(message, suggestions) {
|
|
25
|
+
const enhancedMessage = IntentParseError.formatMessage(message, suggestions);
|
|
26
|
+
super(enhancedMessage);
|
|
11
27
|
this.name = 'IntentParseError';
|
|
28
|
+
this.suggestions = suggestions || IntentParseError.getDefaultSuggestions();
|
|
12
29
|
Object.setPrototypeOf(this, IntentParseError.prototype);
|
|
13
30
|
}
|
|
31
|
+
static formatMessage(message, suggestions) {
|
|
32
|
+
const suggestionList = suggestions || IntentParseError.getDefaultSuggestions();
|
|
33
|
+
return `${message}\n\nSuggested fixes:\n${suggestionList.map(s => ` ⢠${s}`).join('\n')}`;
|
|
34
|
+
}
|
|
35
|
+
static getDefaultSuggestions() {
|
|
36
|
+
return [
|
|
37
|
+
'Simplify your query (e.g., "show users" instead of complex phrasing)',
|
|
38
|
+
'Ensure table/field names match your database schema',
|
|
39
|
+
'Try a more explicit query (e.g., "list all products")',
|
|
40
|
+
'Check if LLM API key is valid and has quota available',
|
|
41
|
+
];
|
|
42
|
+
}
|
|
14
43
|
}
|
|
15
44
|
/**
|
|
16
45
|
* Error thrown when SQL generation fails.
|
|
46
|
+
*
|
|
47
|
+
* This error occurs when the LLM cannot generate valid SQL from the parsed intent,
|
|
48
|
+
* or when the generated SQL fails safety validation.
|
|
49
|
+
*
|
|
50
|
+
* Common causes:
|
|
51
|
+
* - Complex query requires table relationships not in schema
|
|
52
|
+
* - Generated SQL violates safety rules (e.g., attempted UPDATE/DELETE)
|
|
53
|
+
* - Schema description is incomplete or incorrect
|
|
54
|
+
* - LLM hallucinated invalid SQL syntax
|
|
55
|
+
*
|
|
56
|
+
* Suggested fixes:
|
|
57
|
+
* - Ensure your database schema is complete and accurate
|
|
58
|
+
* - Try a simpler query with fewer joins
|
|
59
|
+
* - Check that the LLM model supports structured outputs
|
|
60
|
+
* - Verify the intent was parsed correctly (use explain() method)
|
|
17
61
|
*/
|
|
18
62
|
export class SQLGenerationError extends Error {
|
|
19
|
-
|
|
20
|
-
|
|
63
|
+
suggestions;
|
|
64
|
+
constructor(message, suggestions) {
|
|
65
|
+
const enhancedMessage = SQLGenerationError.formatMessage(message, suggestions);
|
|
66
|
+
super(enhancedMessage);
|
|
21
67
|
this.name = 'SQLGenerationError';
|
|
68
|
+
this.suggestions = suggestions || SQLGenerationError.getDefaultSuggestions();
|
|
22
69
|
Object.setPrototypeOf(this, SQLGenerationError.prototype);
|
|
23
70
|
}
|
|
71
|
+
static formatMessage(message, suggestions) {
|
|
72
|
+
const suggestionList = suggestions || SQLGenerationError.getDefaultSuggestions();
|
|
73
|
+
return `${message}\n\nSuggested fixes:\n${suggestionList.map(s => ` ⢠${s}`).join('\n')}`;
|
|
74
|
+
}
|
|
75
|
+
static getDefaultSuggestions() {
|
|
76
|
+
return [
|
|
77
|
+
'Ensure your database schema is complete and accurate',
|
|
78
|
+
'Try a simpler query with fewer joins or filters',
|
|
79
|
+
'Verify the intent was parsed correctly (use explain() method)',
|
|
80
|
+
'Check that the LLM model supports your database dialect',
|
|
81
|
+
];
|
|
82
|
+
}
|
|
24
83
|
}
|
|
25
84
|
/**
|
|
26
85
|
* Error thrown when SQL execution fails.
|
|
86
|
+
*
|
|
87
|
+
* This error occurs when the database rejects the generated SQL query.
|
|
88
|
+
*
|
|
89
|
+
* Common causes:
|
|
90
|
+
* - Database connection issues
|
|
91
|
+
* - Table or column doesn't exist (schema mismatch)
|
|
92
|
+
* - Type mismatch in WHERE clause (e.g., string vs integer)
|
|
93
|
+
* - Database permissions insufficient for SELECT
|
|
94
|
+
* - Syntax error in generated SQL
|
|
95
|
+
*
|
|
96
|
+
* Suggested fixes:
|
|
97
|
+
* - Verify database connection is active
|
|
98
|
+
* - Ensure schema matches actual database structure
|
|
99
|
+
* - Check database user has SELECT permissions
|
|
100
|
+
* - Examine the generated SQL for syntax errors
|
|
101
|
+
* - Try regenerating with forceNewSchema option
|
|
27
102
|
*/
|
|
28
103
|
export class SQLExecutionError extends Error {
|
|
29
|
-
|
|
30
|
-
|
|
104
|
+
sql;
|
|
105
|
+
suggestions;
|
|
106
|
+
constructor(message, sql, suggestions) {
|
|
107
|
+
const enhancedMessage = SQLExecutionError.formatMessage(message, sql, suggestions);
|
|
108
|
+
super(enhancedMessage);
|
|
31
109
|
this.name = 'SQLExecutionError';
|
|
110
|
+
this.sql = sql;
|
|
111
|
+
this.suggestions = suggestions || SQLExecutionError.getDefaultSuggestions();
|
|
32
112
|
Object.setPrototypeOf(this, SQLExecutionError.prototype);
|
|
33
113
|
}
|
|
114
|
+
static formatMessage(message, sql, suggestions) {
|
|
115
|
+
let formatted = message;
|
|
116
|
+
if (sql) {
|
|
117
|
+
formatted += `\n\nGenerated SQL:\n${sql}`;
|
|
118
|
+
}
|
|
119
|
+
const suggestionList = suggestions || SQLExecutionError.getDefaultSuggestions();
|
|
120
|
+
formatted += `\n\nSuggested fixes:\n${suggestionList.map(s => ` ⢠${s}`).join('\n')}`;
|
|
121
|
+
return formatted;
|
|
122
|
+
}
|
|
123
|
+
static getDefaultSuggestions() {
|
|
124
|
+
return [
|
|
125
|
+
'Verify database connection is active (check DATABASE_URL)',
|
|
126
|
+
'Ensure schema matches actual database structure',
|
|
127
|
+
'Check database user has SELECT permissions on the table',
|
|
128
|
+
'Examine the generated SQL for syntax errors',
|
|
129
|
+
'Try regenerating with forceNewSchema: true option',
|
|
130
|
+
];
|
|
131
|
+
}
|
|
34
132
|
}
|
|
35
133
|
/**
|
|
36
134
|
* Error thrown when LLM API calls fail.
|
|
135
|
+
*
|
|
136
|
+
* This error occurs when communication with the LLM provider fails.
|
|
137
|
+
*
|
|
138
|
+
* Common causes:
|
|
139
|
+
* - Invalid or expired API key
|
|
140
|
+
* - Rate limit or quota exceeded
|
|
141
|
+
* - Network connectivity issues
|
|
142
|
+
* - LLM provider service outage
|
|
143
|
+
* - Request timeout
|
|
144
|
+
*
|
|
145
|
+
* Suggested fixes:
|
|
146
|
+
* - Verify API key is correct and active
|
|
147
|
+
* - Check API quota and rate limits with provider
|
|
148
|
+
* - Ensure network connectivity to LLM provider
|
|
149
|
+
* - Wait and retry (automatic retry with backoff is already applied)
|
|
150
|
+
* - Check LLM provider status page for outages
|
|
37
151
|
*/
|
|
38
152
|
export class LLMError extends Error {
|
|
39
|
-
|
|
40
|
-
|
|
153
|
+
suggestions;
|
|
154
|
+
constructor(message, suggestions) {
|
|
155
|
+
const enhancedMessage = LLMError.formatMessage(message, suggestions);
|
|
156
|
+
super(enhancedMessage);
|
|
41
157
|
this.name = 'LLMError';
|
|
158
|
+
this.suggestions = suggestions || LLMError.getDefaultSuggestions();
|
|
42
159
|
Object.setPrototypeOf(this, LLMError.prototype);
|
|
43
160
|
}
|
|
161
|
+
static formatMessage(message, suggestions) {
|
|
162
|
+
const suggestionList = suggestions || LLMError.getDefaultSuggestions();
|
|
163
|
+
return `${message}\n\nSuggested fixes:\n${suggestionList.map(s => ` ⢠${s}`).join('\n')}`;
|
|
164
|
+
}
|
|
165
|
+
static getDefaultSuggestions() {
|
|
166
|
+
return [
|
|
167
|
+
'Verify API key is correct (check ANTHROPIC_API_KEY, OPENAI_API_KEY, etc.)',
|
|
168
|
+
'Check API quota and rate limits with your provider',
|
|
169
|
+
'Ensure network connectivity to the LLM provider',
|
|
170
|
+
'Wait a moment and retry (automatic backoff already applied)',
|
|
171
|
+
'Check provider status page for service outages',
|
|
172
|
+
];
|
|
173
|
+
}
|
|
44
174
|
}
|
|
45
175
|
/**
|
|
46
176
|
* Error thrown when cache operations fail.
|
|
177
|
+
*
|
|
178
|
+
* This error occurs when the caching system encounters an issue.
|
|
179
|
+
*
|
|
180
|
+
* Common causes:
|
|
181
|
+
* - Redis connection failed (if using Redis L1 cache)
|
|
182
|
+
* - Redis authentication error
|
|
183
|
+
* - Network issues with Redis server
|
|
184
|
+
* - Embedding API failure (if using L2 semantic cache)
|
|
185
|
+
* - Out of memory for in-memory caches
|
|
186
|
+
*
|
|
187
|
+
* Suggested fixes:
|
|
188
|
+
* - Verify Redis server is running (if using Redis)
|
|
189
|
+
* - Check REDIS_URL format: redis://host:port
|
|
190
|
+
* - Ensure Redis authentication credentials are correct
|
|
191
|
+
* - Check OpenAI API key for embeddings (if L2 enabled)
|
|
192
|
+
* - Reduce cache size limits if memory is constrained
|
|
47
193
|
*/
|
|
48
194
|
export class CacheError extends Error {
|
|
49
|
-
|
|
50
|
-
|
|
195
|
+
suggestions;
|
|
196
|
+
constructor(message, suggestions) {
|
|
197
|
+
const enhancedMessage = CacheError.formatMessage(message, suggestions);
|
|
198
|
+
super(enhancedMessage);
|
|
51
199
|
this.name = 'CacheError';
|
|
200
|
+
this.suggestions = suggestions || CacheError.getDefaultSuggestions();
|
|
52
201
|
Object.setPrototypeOf(this, CacheError.prototype);
|
|
53
202
|
}
|
|
203
|
+
static formatMessage(message, suggestions) {
|
|
204
|
+
const suggestionList = suggestions || CacheError.getDefaultSuggestions();
|
|
205
|
+
return `${message}\n\nSuggested fixes:\n${suggestionList.map(s => ` ⢠${s}`).join('\n')}`;
|
|
206
|
+
}
|
|
207
|
+
static getDefaultSuggestions() {
|
|
208
|
+
return [
|
|
209
|
+
'Verify Redis server is running (if using Redis)',
|
|
210
|
+
'Check REDIS_URL format: redis://host:port',
|
|
211
|
+
'Ensure Redis authentication credentials are correct',
|
|
212
|
+
'Verify OpenAI API key for embeddings (if L2 cache enabled)',
|
|
213
|
+
'Try disabling cache temporarily to isolate the issue',
|
|
214
|
+
];
|
|
215
|
+
}
|
|
54
216
|
}
|
|
55
217
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzB,WAAW,CAAW;IAEtC,YAAY,OAAe,EAAE,WAAsB;QACjD,MAAM,eAAe,GAAG,gBAAgB,CAAC,aAAa,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAC7E,KAAK,CAAC,eAAe,CAAC,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,WAAW,IAAI,gBAAgB,CAAC,qBAAqB,EAAE,CAAC;QAC3E,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAC1D,CAAC;IAEO,MAAM,CAAC,aAAa,CAAC,OAAe,EAAE,WAAsB;QAClE,MAAM,cAAc,GAAG,WAAW,IAAI,gBAAgB,CAAC,qBAAqB,EAAE,CAAC;QAC/E,OAAO,GAAG,OAAO,yBAAyB,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IAC7F,CAAC;IAEO,MAAM,CAAC,qBAAqB;QAClC,OAAO;YACL,sEAAsE;YACtE,qDAAqD;YACrD,uDAAuD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AC;IACJ,CAAC;CACF"}
|
package/dist/executor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,EACX,MAAM,EAEN,eAAe,EAIf,MAAM,YAAY,CAAC;AAMpB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEnF,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,EACX,MAAM,EAEN,eAAe,EAIf,MAAM,YAAY,CAAC;AAMpB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEnF,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAkHxD,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IA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