@deepagents/text2sql 4.2.1 → 5.0.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 CHANGED
@@ -184,9 +184,13 @@ model must pass to `sql validate <db>` and `sql run <db>`. Add or replace the
184
184
  instructions with your own domain fragments as needed.
185
185
 
186
186
  `sqlValidateReminder()` returns a context reminder fragment backed by
187
- `SQL_VALIDATE_REMINDER`. It adds a tool-output system reminder when the current
188
- assistant turn calls `sql run <db> "..."` without a prior `sql validate <db>
189
- "..."` for the same configured adapter name and exact SQL text.
187
+ `SQL_VALIDATE_REMINDER`. After a successful `sql run <db> "..."`, it adds a
188
+ model-only tool-output reminder before the next generation when no prior
189
+ `sql validate <db> "..."` used the same configured adapter name and exact SQL
190
+ text. The raw SQL command result remains unchanged. During streamed `chat()`
191
+ turns, the reminder is persisted as a synthetic user message for replay and
192
+ prompt caching; bare `createPrepareStep()` integrations and
193
+ `agent.generate()` own persistence of their generated assistant history.
190
194
 
191
195
  ## Advanced: SQL CLI in Sandboxes
192
196
 
package/dist/index.js CHANGED
@@ -4683,9 +4683,6 @@ Action: Ask user: "Top by what metric\u2014total revenue, number of orders, or m
4683
4683
  return baseTeachings;
4684
4684
  }
4685
4685
 
4686
- // packages/text2sql/src/lib/sql-meta-hook.ts
4687
- import { useBashMeta } from "@deepagents/context";
4688
-
4689
4686
  // packages/text2sql/src/lib/sql-invocation.ts
4690
4687
  import { parse } from "just-bash";
4691
4688
  import { asStaticWordText } from "@deepagents/context";
@@ -4758,12 +4755,12 @@ function createSqlMetaHook({ adapters }) {
4758
4755
  const adapter = adapters[invocation.dbName];
4759
4756
  if (!adapter) return void 0;
4760
4757
  try {
4761
- useBashMeta()?.setHidden({
4762
- formattedSql: adapter.format(invocation.sql)
4763
- });
4758
+ return {
4759
+ meta: { formattedSql: adapter.format(invocation.sql) }
4760
+ };
4764
4761
  } catch {
4762
+ return void 0;
4765
4763
  }
4766
- return void 0;
4767
4764
  }
4768
4765
  };
4769
4766
  }
@@ -4810,7 +4807,10 @@ import { BashTransformPipeline } from "just-bash";
4810
4807
  import { parse as parse2, serialize } from "just-bash";
4811
4808
  import { createHash as createHash4 } from "node:crypto";
4812
4809
  import * as path6 from "node:path";
4813
- import { BashException, asStaticWordText as asStaticWordText2 } from "@deepagents/context";
4810
+ import {
4811
+ BashException,
4812
+ asStaticWordText as asStaticWordText2
4813
+ } from "@deepagents/context";
4814
4814
  function isScriptNode(value) {
4815
4815
  if (typeof value !== "object" || value === null) {
4816
4816
  return false;
@@ -5925,8 +5925,10 @@ function alreadyValidated(messages, run) {
5925
5925
  }
5926
5926
  function sqlRunMissingValidate() {
5927
5927
  return (ctx) => {
5928
- const call = ctx.executingTool;
5929
- if (!call || call.name !== "bash") return false;
5928
+ const call = ctx.toolOutcome;
5929
+ if (!call || call.state !== "output-available" || call.name !== "bash") {
5930
+ return false;
5931
+ }
5930
5932
  const run = extractSqlInvocation(inputCommand(call.input));
5931
5933
  if (run?.subcommand !== "run") return false;
5932
5934
  return !alreadyValidated(ctx.lastAssistantMessages, run);