@deepagents/text2sql 2.1.0 → 2.3.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
@@ -106,7 +106,8 @@ import {
106
106
  InMemoryContextStore,
107
107
  agent,
108
108
  chat,
109
- createContainerTool,
109
+ createBashTool,
110
+ createDockerSandbox,
110
111
  errorRecoveryGuardrail,
111
112
  npm,
112
113
  user,
@@ -120,7 +121,7 @@ const context = new ContextEngine({
120
121
  userId: 'user-456',
121
122
  });
122
123
 
123
- const sandbox = await createContainerTool({
124
+ const backend = await createDockerSandbox({
124
125
  installers: [npm('@deepagents/text2sql', { ensureRuntime: true })],
125
126
  volumes: [
126
127
  {
@@ -133,6 +134,9 @@ const sandbox = await createContainerTool({
133
134
  env: {
134
135
  TEXT2SQL_ADAPTERS: '/workspace/text2sql-adapters.ts',
135
136
  },
137
+ });
138
+ const sandbox = await createBashTool({
139
+ sandbox: backend,
136
140
  ...createSqlCommandHooks({ adapters: { main: adapter } }),
137
141
  });
138
142
 
@@ -193,8 +197,42 @@ sandbox was not prepared correctly.
193
197
  Set `TEXT2SQL_INDEX_VERSION` to manage cache invalidation across runs. Cache
194
198
  keys are `index-<version>-<adapter>`, so bump the version when schema changes.
195
199
 
196
- Spread `createSqlCommandHooks({ adapters })` into `createBashTool()` or
197
- `createContainerTool()` for model-driven bash calls. The before hook preserves
200
+ For in-process or virtual-sandbox usage (without installing the package CLI),
201
+ wrap an existing `Text2Sql` instance as a just-bash custom command:
202
+
203
+ ```typescript
204
+ import { InMemoryFs, createVirtualSandbox } from '@deepagents/context';
205
+ import {
206
+ type CreateSqlCommandOptions,
207
+ type CreateSqlCommandResult,
208
+ Text2Sql,
209
+ createSqlCommand,
210
+ } from '@deepagents/text2sql';
211
+
212
+ const text2sql = new Text2Sql({ model, adapters: { main: adapter } });
213
+
214
+ const commandOptions: CreateSqlCommandOptions = {
215
+ outputDir: '/sql-artifacts',
216
+ };
217
+ const sqlCommand: CreateSqlCommandResult = createSqlCommand(
218
+ text2sql,
219
+ commandOptions,
220
+ );
221
+
222
+ const sandbox = await createVirtualSandbox({
223
+ fs: new InMemoryFs(),
224
+ customCommands: [sqlCommand.command],
225
+ });
226
+
227
+ await sandbox.executeCommand('sql validate main "SELECT 1"');
228
+ ```
229
+
230
+ `CreateSqlCommandOptions` configures command defaults (currently `outputDir`).
231
+ `CreateSqlCommandResult` returns the command plus a `repair(raw)` helper for
232
+ normalizing model-generated argv before execution.
233
+
234
+ Spread `createSqlCommandHooks({ adapters })` into `createBashTool()` for
235
+ model-driven bash calls. The before hook preserves
198
236
  the old virtual-command tolerance for common LLM quote mistakes, rewrites SQL
199
237
  identifier backticks so bash does not run them as command substitutions, and
200
238
  blocks raw database access so read-only and scope checks stay behind
@@ -202,6 +240,10 @@ blocks raw database access so read-only and scope checks stay behind
202
240
  metadata from the host adapter map without putting that concern into the real
203
241
  CLI.
204
242
 
243
+ Read-only enforcement accepts a single `SELECT`/`WITH` statement even when it
244
+ starts with whitespace or SQL comments (`-- ...`, `/* ... */`). It still
245
+ rejects comment-only input, multi-statement batches, and write operations.
246
+
205
247
  ## Fragments
206
248
 
207
249
  Inject domain knowledge by setting fragments on the `ContextEngine` you build