|
| 1 | +# @agentic-kit/db-tools |
| 2 | + |
| 3 | +<p align="center" width="100%"> |
| 4 | + <img height="250" src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" /> |
| 5 | +</p> |
| 6 | + |
| 7 | +<p align="center" width="100%"> |
| 8 | + <a href="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml"> |
| 9 | + <img height="20" src="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml/badge.svg" /> |
| 10 | + </a> |
| 11 | + <a href="https://github.com/constructive-io/constructive/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a> |
| 12 | + <a href="https://www.npmjs.com/package/@agentic-kit/db-tools"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=agentic%2Fdb-tools%2Fpackage.json"/></a> |
| 13 | +</p> |
| 14 | + |
| 15 | +The Constructive typed database tools, as **harness-neutral** [`HarnessTool`](https://www.npmjs.com/package/@agentic-kit/harness)s: zod parameters, `execute(params, { cwd, signal })`, and no coding-agent SDK anywhere in the package. Binding them to a harness is the *adapter's* job — [`@agentic-kit/pi`](https://www.npmjs.com/package/@agentic-kit/pi) does it with `toPiTool()` — so a second, compatible harness registers the same 18 tools without a fork. |
| 16 | + |
| 17 | +``` |
| 18 | +@agentic-kit/db-tools ──► @agentic-kit/harness (HarnessTool) |
| 19 | + ▲ |
| 20 | + ├── @agentic-kit/pi toPiTool() ──► pi's ToolDefinition |
| 21 | + └── your adapter toXTool() ──► your harness's tool shape |
| 22 | +``` |
| 23 | + |
| 24 | +```bash |
| 25 | +npm install @agentic-kit/db-tools |
| 26 | +``` |
| 27 | + |
| 28 | +## What's inside |
| 29 | + |
| 30 | +- **18 typed db tools** — `provision_database`, `provision_blueprint`, `describe_schema`, `add_relation`, `delete_table`, `create_field` / `update_field` / `delete_field`, `add_policies`, `add_records`, `manage_entity_types`, `create_api_key`, `run_codegen`, and the template suite (`list` / `create` / `apply` / `update` / `delete`). `constructiveDbTools` is the list, in registration order. |
| 31 | +- **Host injection** — credentials, backend endpoints and data-plane tokens come from the host application, not from the package. Call `configureHost()` once at startup; the tools read it lazily per call. |
| 32 | +- **Project context** — `resolveProjectContext` / `resolveDataToken` resolve the database a tool acts on from the cwd's `.env` plus the host's session, and `deriveSubdomainEndpoint` derives its per-database endpoints. |
| 33 | +- **Provisioning model** — the pinned `node-type-registry` presets, the provision manifest, and overlay resolution (`resolveProvisionModules`). |
| 34 | +- **`toolSchema`** — a tool's zod parameters as plain JSON Schema, for adapters whose harness wants JSON Schema rather than zod. |
| 35 | + |
| 36 | +## Usage |
| 37 | + |
| 38 | +```ts |
| 39 | +import { configureHost, constructiveDbTools } from '@agentic-kit/db-tools'; |
| 40 | + |
| 41 | +configureHost({ |
| 42 | + account: () => ({ userId, accessToken }), |
| 43 | + backendConfig: () => ({ apiEndpoint, modulesEndpoint }), |
| 44 | + signInHint: 'Run `agent login` to sign in.' |
| 45 | +}); |
| 46 | + |
| 47 | +for (const tool of constructiveDbTools) { |
| 48 | + myHarness.registerTool(myToolBinding(tool)); |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +A tool executes against nothing but its params and a context, so it is callable directly — which is also how the tests drive it: |
| 53 | + |
| 54 | +```ts |
| 55 | +const result = await describeSchemaTool.execute({ database_name: 'my-app' }, { cwd: process.cwd() }); |
| 56 | +``` |
| 57 | + |
| 58 | +## Related |
| 59 | + |
| 60 | +| Package | Role | |
| 61 | +| --- | --- | |
| 62 | +| [`@agentic-kit/harness`](https://www.npmjs.com/package/@agentic-kit/harness) | the neutral contracts: `HarnessTool`, `HarnessAdapter`, the run gate | |
| 63 | +| [`@agentic-kit/pi`](https://www.npmjs.com/package/@agentic-kit/pi) | the pi adapter: binds these tools and attaches a run's lanes to a pi session | |
| 64 | +| [`@agentic-kit/cli`](https://www.npmjs.com/package/@agentic-kit/cli) | the `agent` CLI, which materializes the tools into a pi agent dir | |
| 65 | + |
| 66 | +## License |
| 67 | + |
| 68 | +SEE LICENSE IN LICENSE |
0 commit comments