@deepagents/text2sql 0.11.0 → 0.12.1

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.
Files changed (54) hide show
  1. package/dist/index.d.ts +3 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1334 -491
  4. package/dist/index.js.map +4 -4
  5. package/dist/lib/adapters/groundings/index.js +2034 -50
  6. package/dist/lib/adapters/groundings/index.js.map +4 -4
  7. package/dist/lib/adapters/groundings/report.grounding.d.ts.map +1 -1
  8. package/dist/lib/adapters/mysql/index.js +2034 -50
  9. package/dist/lib/adapters/mysql/index.js.map +4 -4
  10. package/dist/lib/adapters/postgres/index.js +2034 -50
  11. package/dist/lib/adapters/postgres/index.js.map +4 -4
  12. package/dist/lib/adapters/spreadsheet/index.js +35 -49
  13. package/dist/lib/adapters/spreadsheet/index.js.map +4 -4
  14. package/dist/lib/adapters/sqlite/index.js +2034 -50
  15. package/dist/lib/adapters/sqlite/index.js.map +4 -4
  16. package/dist/lib/adapters/sqlserver/column-stats.sqlserver.grounding.d.ts.map +1 -1
  17. package/dist/lib/adapters/sqlserver/index.js +2035 -53
  18. package/dist/lib/adapters/sqlserver/index.js.map +4 -4
  19. package/dist/lib/agents/developer.agent.d.ts.map +1 -1
  20. package/dist/lib/agents/explainer.agent.d.ts +4 -5
  21. package/dist/lib/agents/explainer.agent.d.ts.map +1 -1
  22. package/dist/lib/agents/question.agent.d.ts.map +1 -1
  23. package/dist/lib/agents/result-tools.d.ts +37 -0
  24. package/dist/lib/agents/result-tools.d.ts.map +1 -0
  25. package/dist/lib/agents/sql.agent.d.ts +1 -1
  26. package/dist/lib/agents/sql.agent.d.ts.map +1 -1
  27. package/dist/lib/agents/teachables.agent.d.ts.map +1 -1
  28. package/dist/lib/agents/text2sql.agent.d.ts +0 -21
  29. package/dist/lib/agents/text2sql.agent.d.ts.map +1 -1
  30. package/dist/lib/checkpoint.d.ts +1 -1
  31. package/dist/lib/checkpoint.d.ts.map +1 -1
  32. package/dist/lib/instructions.d.ts +9 -28
  33. package/dist/lib/instructions.d.ts.map +1 -1
  34. package/dist/lib/sql.d.ts +1 -1
  35. package/dist/lib/sql.d.ts.map +1 -1
  36. package/dist/lib/synthesis/extractors/base-contextual-extractor.d.ts +6 -7
  37. package/dist/lib/synthesis/extractors/base-contextual-extractor.d.ts.map +1 -1
  38. package/dist/lib/synthesis/extractors/last-query-extractor.d.ts.map +1 -1
  39. package/dist/lib/synthesis/extractors/segmented-context-extractor.d.ts +0 -6
  40. package/dist/lib/synthesis/extractors/segmented-context-extractor.d.ts.map +1 -1
  41. package/dist/lib/synthesis/extractors/sql-extractor.d.ts.map +1 -1
  42. package/dist/lib/synthesis/index.js +2394 -2132
  43. package/dist/lib/synthesis/index.js.map +4 -4
  44. package/dist/lib/synthesis/synthesizers/breadth-evolver.d.ts.map +1 -1
  45. package/dist/lib/synthesis/synthesizers/depth-evolver.d.ts +3 -3
  46. package/dist/lib/synthesis/synthesizers/depth-evolver.d.ts.map +1 -1
  47. package/dist/lib/synthesis/synthesizers/persona-generator.d.ts.map +1 -1
  48. package/dist/lib/synthesis/synthesizers/schema-synthesizer.d.ts +1 -1
  49. package/dist/lib/synthesis/synthesizers/schema-synthesizer.d.ts.map +1 -1
  50. package/package.json +9 -15
  51. package/dist/lib/instructions.js +0 -432
  52. package/dist/lib/instructions.js.map +0 -7
  53. package/dist/lib/teach/teachings.d.ts +0 -11
  54. package/dist/lib/teach/teachings.d.ts.map +0 -1
@@ -508,57 +508,43 @@ var ColumnValuesGrounding = class extends AbstractGrounding {
508
508
  };
509
509
 
510
510
  // packages/text2sql/src/lib/adapters/groundings/report.grounding.ts
511
- import { groq } from "@ai-sdk/groq";
511
+ import { groq as groq2 } from "@ai-sdk/groq";
512
512
  import { tool } from "ai";
513
513
  import dedent from "dedent";
514
514
  import z from "zod";
515
- import {
516
- agent,
517
- generate,
518
- toState,
519
- user
520
- } from "@deepagents/agent";
521
- var reportAgent = agent({
522
- name: "db-report-agent",
523
- model: groq("openai/gpt-oss-20b"),
524
- prompt: () => dedent`
525
- <identity>
526
- You are a database analyst expert. Your job is to understand what
527
- a database represents and provide business context about it.
528
- You have READ-ONLY access to the database.
529
- </identity>
530
-
531
- <instructions>
532
- Write a business context that helps another agent answer questions accurately.
533
-
534
- For EACH table, do queries ONE AT A TIME:
535
- 1. SELECT COUNT(*) to get row count
536
- 2. SELECT * LIMIT 3 to see sample data
515
+ import "@deepagents/agent";
537
516
 
538
- Then write a report with:
539
- - What business this database is for
540
- - For each table: purpose, row count, and example of what the data looks like
541
-
542
- Include concrete examples like "Track prices are $0.99",
543
- "Customer names like 'Luís Gonçalves'", etc.
544
-
545
- Keep it 400-600 words, conversational style.
546
- </instructions>
547
- `,
548
- tools: {
549
- query_database: tool({
550
- description: "Execute a SELECT query to explore the database and gather insights.",
551
- inputSchema: z.object({
552
- sql: z.string().describe("The SELECT query to execute"),
553
- purpose: z.string().describe("What insight you are trying to gather with this query")
554
- }),
555
- execute: ({ sql }, options) => {
556
- const state = toState(options);
557
- return state.adapter.execute(sql);
558
- }
559
- })
560
- }
561
- });
517
+ // packages/context/dist/index.js
518
+ import { encode } from "gpt-tokenizer";
519
+ import { generateId } from "ai";
520
+ import pluralize from "pluralize";
521
+ import { titlecase } from "stringcase";
522
+ import chalk from "chalk";
523
+ import { defineCommand } from "just-bash";
524
+ import spawn from "nano-spawn";
525
+ import "bash-tool";
526
+ import spawn2 from "nano-spawn";
527
+ import {
528
+ createBashTool
529
+ } from "bash-tool";
530
+ import YAML from "yaml";
531
+ import { DatabaseSync } from "node:sqlite";
532
+ import { groq } from "@ai-sdk/groq";
533
+ import {
534
+ NoSuchToolError,
535
+ Output,
536
+ convertToModelMessages,
537
+ createUIMessageStream,
538
+ generateId as generateId2,
539
+ generateText,
540
+ smoothStream,
541
+ stepCountIs,
542
+ streamText
543
+ } from "ai";
544
+ import chalk2 from "chalk";
545
+ import "zod";
546
+ import "@deepagents/agent";
547
+ var LAZY_ID = Symbol("lazy-id");
562
548
 
563
549
  // packages/text2sql/src/lib/adapters/groundings/row-count.grounding.ts
564
550
  var RowCountGrounding = class extends AbstractGrounding {
@@ -1060,7 +1046,7 @@ function rowCount(config = {}) {
1060
1046
  }
1061
1047
 
1062
1048
  // packages/text2sql/src/lib/adapters/spreadsheet/spreadsheet.ts
1063
- import { DatabaseSync } from "node:sqlite";
1049
+ import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
1064
1050
 
1065
1051
  // packages/text2sql/src/lib/adapters/spreadsheet/parser.ts
1066
1052
  import * as path from "node:path";
@@ -1197,7 +1183,7 @@ var Spreadsheet = class extends Sqlite {
1197
1183
  constructor(options) {
1198
1184
  const sheets = parseFile(options.file);
1199
1185
  const dbPath = options.database ?? ":memory:";
1200
- const db = new DatabaseSync(dbPath);
1186
+ const db = new DatabaseSync2(dbPath);
1201
1187
  for (const sheet of sheets) {
1202
1188
  const createSQL = createTableSQL(sheet);
1203
1189
  db.exec(createSQL);