omnibase-mcp 0.1.22 → 0.1.26
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/CHANGELOG.md +78 -0
- package/README.md +150 -9
- package/dist/src/audit-logger.d.ts +27 -0
- package/dist/src/audit-logger.js +104 -0
- package/dist/src/audit-logger.js.map +1 -0
- package/dist/src/cli/audit.d.ts +9 -0
- package/dist/src/cli/audit.js +149 -0
- package/dist/src/cli/audit.js.map +1 -0
- package/dist/src/cli/sidecar-utils.d.ts +8 -0
- package/dist/src/cli/sidecar-utils.js +18 -0
- package/dist/src/cli/sidecar-utils.js.map +1 -0
- package/dist/src/cli/status.d.ts +14 -0
- package/dist/src/cli/status.js +112 -0
- package/dist/src/cli/status.js.map +1 -0
- package/dist/src/cli/tools.d.ts +13 -0
- package/dist/src/cli/tools.js +527 -0
- package/dist/src/cli/tools.js.map +1 -0
- package/dist/src/cli/upgrade.d.ts +47 -0
- package/dist/src/cli/upgrade.js +288 -0
- package/dist/src/cli/upgrade.js.map +1 -0
- package/dist/src/compose-expander.d.ts +15 -0
- package/dist/src/compose-expander.js +55 -0
- package/dist/src/compose-expander.js.map +1 -0
- package/dist/src/config-watcher.d.ts +12 -0
- package/dist/src/config-watcher.js +49 -0
- package/dist/src/config-watcher.js.map +1 -0
- package/dist/src/config.d.ts +1 -1
- package/dist/src/config.js +77 -9
- package/dist/src/config.js.map +1 -1
- package/dist/src/connection-manager.d.ts +9 -0
- package/dist/src/connection-manager.js +26 -0
- package/dist/src/connection-manager.js.map +1 -1
- package/dist/src/custom-tools.d.ts +55 -0
- package/dist/src/custom-tools.js +691 -0
- package/dist/src/custom-tools.js.map +1 -0
- package/dist/src/index.js +245 -22
- package/dist/src/index.js.map +1 -1
- package/dist/src/schema-hint-manager.d.ts +16 -0
- package/dist/src/schema-hint-manager.js +90 -0
- package/dist/src/schema-hint-manager.js.map +1 -0
- package/dist/src/tools/execute-sql.d.ts +8 -2
- package/dist/src/tools/execute-sql.js +65 -35
- package/dist/src/tools/execute-sql.js.map +1 -1
- package/dist/src/types.d.ts +45 -0
- package/dist/src/types.js.map +1 -1
- package/dist/src/update-checker.d.ts +23 -0
- package/dist/src/update-checker.js +126 -0
- package/dist/src/update-checker.js.map +1 -0
- package/package.json +4 -1
- package/scripts/postinstall.js +89 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,83 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.26](https://github.com/itsJeremyMax/omnibase/compare/omnibase-mcp-v0.1.25...omnibase-mcp-v0.1.26) (2026-03-31)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add CLI upgrade command with update checking and changelog display ([28daa3e](https://github.com/itsJeremyMax/omnibase/commit/28daa3e1455fdc9a6733debb00d6df9ee3fb7095))
|
|
9
|
+
* add connection health dashboard via `status` command ([b7a1ae7](https://github.com/itsJeremyMax/omnibase/commit/b7a1ae7b9b328ac9ed77c871e3942bd8f2e159a8))
|
|
10
|
+
* add custom tools - user-defined MCP tools via config ([8b357fd](https://github.com/itsJeremyMax/omnibase/commit/8b357fd47557af3361cf196d6ba6aca6c1f29f67))
|
|
11
|
+
* add exact_counts parameter to list_tables for accurate row counts ([8dd47d8](https://github.com/itsJeremyMax/omnibase/commit/8dd47d880f9bd5ae75bef60c110654a8da041817))
|
|
12
|
+
* add multi-statement custom tools with transaction support ([3a8c6f0](https://github.com/itsJeremyMax/omnibase/commit/3a8c6f07cd28ca71b39c03b3b0b4107e89af4606))
|
|
13
|
+
* add query audit log with history tool and CLI ([7964058](https://github.com/itsJeremyMax/omnibase/commit/796405858e1344116907dba2d311c5229996c075))
|
|
14
|
+
* add schema-aware autocomplete hints in tool descriptions ([9688273](https://github.com/itsJeremyMax/omnibase/commit/96882731524683fd5cbe04b66d4508d20492f63d))
|
|
15
|
+
* add SHA-256 checksum verification and archives for sidecar releases ([676d074](https://github.com/itsJeremyMax/omnibase/commit/676d0741b2a633a82347dc829c2c811963a0ef6c))
|
|
16
|
+
* add tool composition with compose pipelines ([6a4807b](https://github.com/itsJeremyMax/omnibase/commit/6a4807ba852dbf432b2f31a180104f6dd5d8332c))
|
|
17
|
+
* add tools test command for dry-running custom tools ([492fcd0](https://github.com/itsJeremyMax/omnibase/commit/492fcd0b157dbdcf62fa7fe5aed5ef58341baf7c))
|
|
18
|
+
* auto-generate tool descriptions from SQL comments ([dacd8fe](https://github.com/itsJeremyMax/omnibase/commit/dacd8fec090580ecacc0501f472011d2ca3818d8))
|
|
19
|
+
* initial release of omnibase ([608d016](https://github.com/itsJeremyMax/omnibase/commit/608d01698b68e4088bc5b1c33144cd09a9dab591))
|
|
20
|
+
* sidecar version management and improved onboarding ([0e60853](https://github.com/itsJeremyMax/omnibase/commit/0e60853ff6776b1ecefc842d408d716c662341aa))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* ci workflow improvements ([d6f5286](https://github.com/itsJeremyMax/omnibase/commit/d6f52867c6aa90fbf345d7a37cad99385292c9ea))
|
|
26
|
+
* drop provenance/OIDC and use token-only npm publish ([736e16b](https://github.com/itsJeremyMax/omnibase/commit/736e16b5522a73613bf8619a640d5acd855b3be2))
|
|
27
|
+
* find correct .npmrc location for token removal ([7f09beb](https://github.com/itsJeremyMax/omnibase/commit/7f09beba40e4c4f84b1624f0a83b2ffc1c1ca727))
|
|
28
|
+
* include README in npm registry publish payload ([7f8d3ec](https://github.com/itsJeremyMax/omnibase/commit/7f8d3ec54acf3eca55fdabc55acac3db5a4f1e6a))
|
|
29
|
+
* increase postinstall test timeout and ensure sidecar is executable ([588116a](https://github.com/itsJeremyMax/omnibase/commit/588116ac54ebdd6e51e175dde833ae5369e84a46))
|
|
30
|
+
* make defaults section optional in config ([a05cf4a](https://github.com/itsJeremyMax/omnibase/commit/a05cf4ab935ad382fa2ccd5538234553e8a7ce2d))
|
|
31
|
+
* npm trusted publishing auth ([9622fd7](https://github.com/itsJeremyMax/omnibase/commit/9622fd7ac1cbb0cafad132d557eb270a255720ee))
|
|
32
|
+
* properly configure OIDC Trusted Publishing for npm ([78552d1](https://github.com/itsJeremyMax/omnibase/commit/78552d1e612a88a867c78f581159e2d439e40e9d))
|
|
33
|
+
* remove provenance config and force node24 for release-please ([f0f7574](https://github.com/itsJeremyMax/omnibase/commit/f0f75741771426988df1163b62d813ba35663d8f))
|
|
34
|
+
* remove registry-url from setup-node for trusted publishing ([7248c32](https://github.com/itsJeremyMax/omnibase/commit/7248c32411b22bf00ba30e6ca245beb951dda25c))
|
|
35
|
+
* restore registry-url and ensure npm >= 11.5.1 for OIDC ([6b5953d](https://github.com/itsJeremyMax/omnibase/commit/6b5953d1c79a3db006cb5cee9f506f4e652d17dc))
|
|
36
|
+
* revert readme from publish payload to avoid Cloudflare WAF block ([014f1f9](https://github.com/itsJeremyMax/omnibase/commit/014f1f9d401e2e62ec622a3417d5f3674fcbd9b5))
|
|
37
|
+
* run CI on release-please branches ([80ccc2d](https://github.com/itsJeremyMax/omnibase/commit/80ccc2de94f03a399e7f1abed8a951a793e7517d))
|
|
38
|
+
* sidecar build failures in CI ([06dd285](https://github.com/itsJeremyMax/omnibase/commit/06dd2857a29ae8d8a988c89b489293ab212fb6d0))
|
|
39
|
+
* strip auth token placeholder so npm uses OIDC ([3ee23ad](https://github.com/itsJeremyMax/omnibase/commit/3ee23adbaa51e8ba708b3b470c4f77f09c475cb1))
|
|
40
|
+
* unset NODE_AUTH_TOKEN instead of emptying it ([ea176c8](https://github.com/itsJeremyMax/omnibase/commit/ea176c80243b8106047dbe1c856cc5ae95869559))
|
|
41
|
+
* update integration tests for exact_counts and add CI concurrency ([2a07923](https://github.com/itsJeremyMax/omnibase/commit/2a079236c51521f52c0bd6582b1d6d0de232fe4a))
|
|
42
|
+
* upgrade npm to latest before publish ([5ec174a](https://github.com/itsJeremyMax/omnibase/commit/5ec174a9a62cc9febf156eddd04bcff461fe8080))
|
|
43
|
+
* use bash shell for windows sidecar build ([d84893a](https://github.com/itsJeremyMax/omnibase/commit/d84893a64c17f96500d8954f7f4e8971049f6503))
|
|
44
|
+
* use correct release tag format in sidecar download URL ([6822aa6](https://github.com/itsJeremyMax/omnibase/commit/6822aa697a24a1062f9655fca46dc03831150b79))
|
|
45
|
+
* use direct registry API for npm publish ([9a612e4](https://github.com/itsJeremyMax/omnibase/commit/9a612e44e9178d291f60a5918690eb06510ae938))
|
|
46
|
+
* use granular access token for npm publish ([7969e49](https://github.com/itsJeremyMax/omnibase/commit/7969e49afe6669587d8d2886650200042c3b7d3c))
|
|
47
|
+
* use OIDC Trusted Publishing for npm auth ([05fecbf](https://github.com/itsJeremyMax/omnibase/commit/05fecbfd116e7bb39a88aa7254558383f858ca8b))
|
|
48
|
+
* use PAT for release-please to trigger CI on PRs ([681c823](https://github.com/itsJeremyMax/omnibase/commit/681c8238fe4f6fe2d2993b03b560879c277e7307))
|
|
49
|
+
|
|
50
|
+
## [0.1.25](https://github.com/itsJeremyMax/omnibase/compare/omnibase-mcp-v0.1.24...omnibase-mcp-v0.1.25) (2026-03-31)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Features
|
|
54
|
+
|
|
55
|
+
* add CLI upgrade command with update checking and changelog display ([28daa3e](https://github.com/itsJeremyMax/omnibase/commit/28daa3e1455fdc9a6733debb00d6df9ee3fb7095))
|
|
56
|
+
* add connection health dashboard via `status` command ([b7a1ae7](https://github.com/itsJeremyMax/omnibase/commit/b7a1ae7b9b328ac9ed77c871e3942bd8f2e159a8))
|
|
57
|
+
* add custom tools - user-defined MCP tools via config ([8b357fd](https://github.com/itsJeremyMax/omnibase/commit/8b357fd47557af3361cf196d6ba6aca6c1f29f67))
|
|
58
|
+
* add multi-statement custom tools with transaction support ([3a8c6f0](https://github.com/itsJeremyMax/omnibase/commit/3a8c6f07cd28ca71b39c03b3b0b4107e89af4606))
|
|
59
|
+
* add query audit log with history tool and CLI ([7964058](https://github.com/itsJeremyMax/omnibase/commit/796405858e1344116907dba2d311c5229996c075))
|
|
60
|
+
* add schema-aware autocomplete hints in tool descriptions ([9688273](https://github.com/itsJeremyMax/omnibase/commit/96882731524683fd5cbe04b66d4508d20492f63d))
|
|
61
|
+
* add SHA-256 checksum verification and archives for sidecar releases ([676d074](https://github.com/itsJeremyMax/omnibase/commit/676d0741b2a633a82347dc829c2c811963a0ef6c))
|
|
62
|
+
* add tool composition with compose pipelines ([6a4807b](https://github.com/itsJeremyMax/omnibase/commit/6a4807ba852dbf432b2f31a180104f6dd5d8332c))
|
|
63
|
+
* add tools test command for dry-running custom tools ([492fcd0](https://github.com/itsJeremyMax/omnibase/commit/492fcd0b157dbdcf62fa7fe5aed5ef58341baf7c))
|
|
64
|
+
* auto-generate tool descriptions from SQL comments ([dacd8fe](https://github.com/itsJeremyMax/omnibase/commit/dacd8fec090580ecacc0501f472011d2ca3818d8))
|
|
65
|
+
|
|
66
|
+
## [0.1.24](https://github.com/itsJeremyMax/omnibase/compare/omnibase-mcp-v0.1.23...omnibase-mcp-v0.1.24) (2026-03-30)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
### Bug Fixes
|
|
70
|
+
|
|
71
|
+
* revert readme from publish payload to avoid Cloudflare WAF block ([014f1f9](https://github.com/itsJeremyMax/omnibase/commit/014f1f9d401e2e62ec622a3417d5f3674fcbd9b5))
|
|
72
|
+
|
|
73
|
+
## [0.1.23](https://github.com/itsJeremyMax/omnibase/compare/omnibase-mcp-v0.1.22...omnibase-mcp-v0.1.23) (2026-03-30)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
### Bug Fixes
|
|
77
|
+
|
|
78
|
+
* include README in npm registry publish payload ([7f8d3ec](https://github.com/itsJeremyMax/omnibase/commit/7f8d3ec54acf3eca55fdabc55acac3db5a4f1e6a))
|
|
79
|
+
* make defaults section optional in config ([a05cf4a](https://github.com/itsJeremyMax/omnibase/commit/a05cf4ab935ad382fa2ccd5538234553e8a7ce2d))
|
|
80
|
+
|
|
3
81
|
## [0.1.22](https://github.com/itsJeremyMax/omnibase/compare/omnibase-mcp-v0.1.21...omnibase-mcp-v0.1.22) (2026-03-30)
|
|
4
82
|
|
|
5
83
|
|
package/README.md
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
Give your AI agent secure access to any database. PostgreSQL, MySQL, SQLite, and [50+ more](https://github.com/xo/usql) through a single MCP server. Works with Claude Code, OpenCode, GitHub Copilot, Cursor, and any MCP-compatible client.
|
|
4
4
|
|
|
5
5
|
```yaml
|
|
6
|
-
# omnibase.config.yaml
|
|
6
|
+
# omnibase.config.yaml — all options: https://github.com/itsJeremyMax/omnibase#configuration-reference
|
|
7
7
|
connections:
|
|
8
8
|
prod:
|
|
9
9
|
dsn: $DATABASE_URL # credentials stay in your environment
|
|
10
|
-
permission: read-only #
|
|
10
|
+
permission: read-only # read-only | read-write | admin
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
```
|
|
@@ -47,23 +47,18 @@ Add to your MCP config (`.mcp.json`):
|
|
|
47
47
|
npx omnibase-mcp init
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
Edit `omnibase.config.yaml` with your database connection ([more examples](examples/)):
|
|
50
|
+
Edit `omnibase.config.yaml` with your database connection ([all options](#configuration-reference), [more examples](examples/)):
|
|
51
51
|
|
|
52
52
|
```yaml
|
|
53
53
|
connections:
|
|
54
54
|
my-db:
|
|
55
55
|
dsn: "pg://myuser:mypassword@localhost:5432/mydb"
|
|
56
56
|
permission: read-write
|
|
57
|
-
|
|
58
|
-
defaults:
|
|
59
|
-
permission: read-only
|
|
60
|
-
timeout: 30000
|
|
61
|
-
max_rows: 500
|
|
62
57
|
```
|
|
63
58
|
|
|
64
59
|
DSNs starting with `$` resolve from environment variables (e.g. `dsn: $DATABASE_URL`).
|
|
65
60
|
|
|
66
|
-
That's it. Your agent now has access to 13 database tools.
|
|
61
|
+
That's it. Your agent now has access to 13 database tools, plus any [custom tools](#custom-tools) you define.
|
|
67
62
|
|
|
68
63
|
<details>
|
|
69
64
|
<summary>Install from source (contributors)</summary>
|
|
@@ -114,6 +109,124 @@ Then point your MCP client at `node dist/src/index.js` with `cwd` set to your pr
|
|
|
114
109
|
|------|-------------|
|
|
115
110
|
| `validate_query` | Check syntax, schema references, permissions, and estimate affected rows before executing |
|
|
116
111
|
|
|
112
|
+
### History
|
|
113
|
+
|
|
114
|
+
| Tool | What it does |
|
|
115
|
+
|------|-------------|
|
|
116
|
+
| `query_history` | View recent query execution history with filtering by connection, status, and pagination |
|
|
117
|
+
|
|
118
|
+
### Custom Tools
|
|
119
|
+
|
|
120
|
+
Define your own MCP tools as SQL templates in your config. Custom tools are registered alongside built-in tools and go through the same security pipeline.
|
|
121
|
+
|
|
122
|
+
```yaml
|
|
123
|
+
tools:
|
|
124
|
+
get_active_users:
|
|
125
|
+
connection: my-db
|
|
126
|
+
description: "Get all active users"
|
|
127
|
+
sql: "SELECT * FROM users WHERE active = true"
|
|
128
|
+
max_rows: 100
|
|
129
|
+
|
|
130
|
+
find_orders_by_status:
|
|
131
|
+
connection: my-db
|
|
132
|
+
description: "Find orders filtered by status"
|
|
133
|
+
permission: read-write
|
|
134
|
+
parameters:
|
|
135
|
+
status:
|
|
136
|
+
type: enum
|
|
137
|
+
description: "Order status"
|
|
138
|
+
values: [pending, shipped, delivered, cancelled]
|
|
139
|
+
min_amount:
|
|
140
|
+
type: number
|
|
141
|
+
description: "Minimum order amount"
|
|
142
|
+
required: false
|
|
143
|
+
default: 0
|
|
144
|
+
sql: >
|
|
145
|
+
SELECT * FROM orders
|
|
146
|
+
WHERE status = {status}
|
|
147
|
+
AND total >= {min_amount}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Custom tools are registered as `custom_<name>` (e.g., `custom_get_active_users`). Parameters use `{param_name}` placeholders that are substituted as parameterized queries (not string interpolation) to prevent SQL injection.
|
|
151
|
+
|
|
152
|
+
**Auto-generated descriptions:** If you omit the `description` field, it will be derived from leading `-- ` comment lines in your SQL template.
|
|
153
|
+
|
|
154
|
+
**Parameter types:** `string`, `number`, `boolean`, `enum`
|
|
155
|
+
|
|
156
|
+
**Optional overrides per tool:** `permission`, `max_rows`, `timeout` (fall back to connection/default values)
|
|
157
|
+
|
|
158
|
+
**Multi-statement tools:** Use `steps` instead of `sql` to run multiple statements within a transaction. Mark one step with `return: true` to control which result goes back to the agent (defaults to the last step). If any step fails, the entire transaction is rolled back.
|
|
159
|
+
|
|
160
|
+
```yaml
|
|
161
|
+
tools:
|
|
162
|
+
user_activity_report:
|
|
163
|
+
connection: my-db
|
|
164
|
+
description: "Generate user activity report"
|
|
165
|
+
parameters:
|
|
166
|
+
days:
|
|
167
|
+
type: number
|
|
168
|
+
description: "Days to look back"
|
|
169
|
+
required: false
|
|
170
|
+
default: 30
|
|
171
|
+
steps:
|
|
172
|
+
- sql: |
|
|
173
|
+
CREATE TEMP TABLE recent_activity AS
|
|
174
|
+
SELECT user_id, COUNT(*) as action_count
|
|
175
|
+
FROM events
|
|
176
|
+
WHERE created_at > datetime('now', '-' || {days} || ' days')
|
|
177
|
+
GROUP BY user_id
|
|
178
|
+
- sql: |
|
|
179
|
+
SELECT u.name, u.email, COALESCE(ra.action_count, 0) as actions
|
|
180
|
+
FROM users u
|
|
181
|
+
LEFT JOIN recent_activity ra ON ra.user_id = u.id
|
|
182
|
+
ORDER BY actions DESC
|
|
183
|
+
return: true
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Tool composition:** Use `compose` to build pipelines where each step can call another custom tool or run inline SQL. Results from earlier steps are available to later steps via `{step_name.column}` references, which expand to comma-separated values.
|
|
187
|
+
|
|
188
|
+
```yaml
|
|
189
|
+
tools:
|
|
190
|
+
get_active_user_ids:
|
|
191
|
+
connection: my-db
|
|
192
|
+
description: "Get active user IDs"
|
|
193
|
+
sql: "SELECT id FROM users WHERE active = true"
|
|
194
|
+
|
|
195
|
+
active_user_orders:
|
|
196
|
+
connection: my-db
|
|
197
|
+
description: "Get orders for all active users"
|
|
198
|
+
compose:
|
|
199
|
+
- tool: get_active_user_ids
|
|
200
|
+
as: users
|
|
201
|
+
- sql: "SELECT * FROM orders WHERE user_id IN ({users.id})"
|
|
202
|
+
as: orders
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Steps run sequentially and the last step's result is returned. Tool-ref steps can pass arguments via `args`, and inline SQL steps can reference results from any prior step. Circular dependencies between composed tools are detected at validation time.
|
|
206
|
+
|
|
207
|
+
**Hot reload:** The server watches your config file and reloads custom tools automatically when it changes. No restart needed.
|
|
208
|
+
|
|
209
|
+
**CLI management:**
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
npx omnibase-mcp tools list # list all custom tools
|
|
213
|
+
npx omnibase-mcp tools add # interactive wizard to add a tool
|
|
214
|
+
npx omnibase-mcp tools remove # interactive wizard to remove a tool
|
|
215
|
+
npx omnibase-mcp tools validate # validate custom tool definitions
|
|
216
|
+
npx omnibase-mcp tools test # dry-run a tool with sample arguments
|
|
217
|
+
npx omnibase-mcp status # ping all connections, show health dashboard
|
|
218
|
+
npx omnibase-mcp audit tail # live tail the query audit log
|
|
219
|
+
npx omnibase-mcp audit search <q> # search audit log by keyword
|
|
220
|
+
npx omnibase-mcp audit clear # clear the audit log
|
|
221
|
+
npx omnibase-mcp upgrade # upgrade to latest version
|
|
222
|
+
npx omnibase-mcp upgrade --dry-run # check for updates and show changelog
|
|
223
|
+
npx omnibase-mcp upgrade --version 0.1.20 # switch to a specific version
|
|
224
|
+
npx omnibase-mcp upgrade --allow-major # allow major version changes
|
|
225
|
+
npx omnibase-mcp --version # print current version
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Updates to a new major version (or downgrades across a major version boundary) require the `--allow-major` flag. The CLI also checks for updates in the background and shows a notice after commands when a newer version is available. Set `NO_UPDATE_NOTIFIER=1` to suppress this.
|
|
229
|
+
|
|
117
230
|
## What Makes This Different
|
|
118
231
|
|
|
119
232
|
**Every query is inspected before it reaches your database.**
|
|
@@ -159,8 +272,36 @@ connections:
|
|
|
159
272
|
- audit_log
|
|
160
273
|
schema_filter: # optional — limit visible schemas/tables
|
|
161
274
|
schemas: [public]
|
|
275
|
+
|
|
276
|
+
# Optional — override built-in defaults
|
|
277
|
+
defaults:
|
|
278
|
+
permission: read-only # default permission for connections that don't specify one
|
|
279
|
+
timeout: 30000 # default query timeout in ms
|
|
280
|
+
max_rows: 500 # default max rows returned per query
|
|
162
281
|
```
|
|
163
282
|
|
|
283
|
+
### Schema hints
|
|
284
|
+
|
|
285
|
+
Omnibase embeds table and column names directly in tool descriptions so your AI agent sees the schema without needing to call `get_schema` first. This is enabled by default and updates automatically when a schema is fetched.
|
|
286
|
+
|
|
287
|
+
```yaml
|
|
288
|
+
schema_hints: true # embed table/column names in tool descriptions (default: true)
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Audit logging
|
|
292
|
+
|
|
293
|
+
Log every query to a local file for debugging and compliance. The `query_history` MCP tool lets agents view their own query history. By default, the last 10,000 entries are retained and older entries are automatically pruned.
|
|
294
|
+
|
|
295
|
+
```yaml
|
|
296
|
+
audit:
|
|
297
|
+
enabled: true
|
|
298
|
+
path: ./.omnibase/audit.log # default: .omnibase/audit.log next to config file
|
|
299
|
+
format: jsonl # jsonl (default) or text
|
|
300
|
+
max_entries: 10000 # 0 = unlimited (default: 10000)
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
The audit log defaults to `.omnibase/audit.log` in the same directory as your config file, so each project gets its own log. By default, the last 10,000 entries are retained and older entries are automatically pruned.
|
|
304
|
+
|
|
164
305
|
### Config discovery
|
|
165
306
|
|
|
166
307
|
1. `OMNIBASE_CONFIG` environment variable
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AuditConfig } from "./types.js";
|
|
2
|
+
export interface AuditEntry {
|
|
3
|
+
tool: string;
|
|
4
|
+
connection: string;
|
|
5
|
+
sql: string;
|
|
6
|
+
params: unknown[];
|
|
7
|
+
durationMs: number;
|
|
8
|
+
rows: number;
|
|
9
|
+
status: "ok" | "error";
|
|
10
|
+
error?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class AuditLogger {
|
|
13
|
+
private config;
|
|
14
|
+
constructor(config: AuditConfig);
|
|
15
|
+
log(entry: AuditEntry): Promise<void>;
|
|
16
|
+
private pruneIfNeeded;
|
|
17
|
+
/**
|
|
18
|
+
* Read recent audit entries (most recent first).
|
|
19
|
+
* Used by the query_history MCP tool.
|
|
20
|
+
*/
|
|
21
|
+
readEntries(options?: {
|
|
22
|
+
limit?: number;
|
|
23
|
+
offset?: number;
|
|
24
|
+
connection?: string;
|
|
25
|
+
status?: "ok" | "error";
|
|
26
|
+
}): Promise<Record<string, unknown>[]>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuditLogger = void 0;
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
class AuditLogger {
|
|
7
|
+
config;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.config = config;
|
|
10
|
+
}
|
|
11
|
+
async log(entry) {
|
|
12
|
+
if (!this.config.enabled)
|
|
13
|
+
return;
|
|
14
|
+
const ts = new Date().toISOString();
|
|
15
|
+
try {
|
|
16
|
+
await (0, promises_1.mkdir)((0, path_1.dirname)(this.config.path), { recursive: true });
|
|
17
|
+
let line;
|
|
18
|
+
if (this.config.format === "text") {
|
|
19
|
+
const errorPart = entry.error ? ` error="${entry.error}"` : "";
|
|
20
|
+
line =
|
|
21
|
+
`[${ts}] ${entry.status.toUpperCase()} tool=${entry.tool} ` +
|
|
22
|
+
`connection=${entry.connection} duration=${entry.durationMs}ms ` +
|
|
23
|
+
`rows=${entry.rows}${errorPart} sql=${entry.sql}\n`;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const record = {
|
|
27
|
+
ts,
|
|
28
|
+
tool: entry.tool,
|
|
29
|
+
connection: entry.connection,
|
|
30
|
+
sql: entry.sql,
|
|
31
|
+
params: entry.params,
|
|
32
|
+
duration_ms: entry.durationMs,
|
|
33
|
+
rows: entry.rows,
|
|
34
|
+
status: entry.status,
|
|
35
|
+
};
|
|
36
|
+
if (entry.error !== undefined)
|
|
37
|
+
record.error = entry.error;
|
|
38
|
+
line = JSON.stringify(record) + "\n";
|
|
39
|
+
}
|
|
40
|
+
await (0, promises_1.appendFile)(this.config.path, line, "utf-8");
|
|
41
|
+
// Prune if max_entries is set
|
|
42
|
+
if (this.config.maxEntries > 0) {
|
|
43
|
+
await this.pruneIfNeeded();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Never crash the server due to audit failures
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async pruneIfNeeded() {
|
|
51
|
+
try {
|
|
52
|
+
const content = await (0, promises_1.readFile)(this.config.path, "utf-8");
|
|
53
|
+
const lines = content.split("\n").filter((l) => l.trim());
|
|
54
|
+
if (lines.length > this.config.maxEntries) {
|
|
55
|
+
// Keep only the most recent maxEntries lines
|
|
56
|
+
const pruned = lines.slice(lines.length - this.config.maxEntries);
|
|
57
|
+
await (0, promises_1.writeFile)(this.config.path, pruned.join("\n") + "\n", "utf-8");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// Silently ignore prune failures
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Read recent audit entries (most recent first).
|
|
66
|
+
* Used by the query_history MCP tool.
|
|
67
|
+
*/
|
|
68
|
+
async readEntries(options) {
|
|
69
|
+
if (!this.config.enabled || this.config.format !== "jsonl")
|
|
70
|
+
return [];
|
|
71
|
+
try {
|
|
72
|
+
const content = await (0, promises_1.readFile)(this.config.path, "utf-8");
|
|
73
|
+
let entries = content
|
|
74
|
+
.split("\n")
|
|
75
|
+
.filter((l) => l.trim())
|
|
76
|
+
.map((l) => {
|
|
77
|
+
try {
|
|
78
|
+
return JSON.parse(l);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
.filter((e) => e !== null)
|
|
85
|
+
.reverse(); // Most recent first
|
|
86
|
+
// Apply filters
|
|
87
|
+
if (options?.connection) {
|
|
88
|
+
entries = entries.filter((e) => e.connection === options.connection);
|
|
89
|
+
}
|
|
90
|
+
if (options?.status) {
|
|
91
|
+
entries = entries.filter((e) => e.status === options.status);
|
|
92
|
+
}
|
|
93
|
+
// Apply pagination
|
|
94
|
+
const offset = options?.offset ?? 0;
|
|
95
|
+
const limit = options?.limit ?? 50;
|
|
96
|
+
return entries.slice(offset, offset + limit);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.AuditLogger = AuditLogger;
|
|
104
|
+
//# sourceMappingURL=audit-logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-logger.js","sourceRoot":"","sources":["../../src/audit-logger.ts"],"names":[],"mappings":";;;AAAA,0CAAqE;AACrE,+BAA+B;AAc/B,MAAa,WAAW;IACF;IAApB,YAAoB,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAE3C,KAAK,CAAC,GAAG,CAAC,KAAiB;QACzB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,OAAO;QAEjC,MAAM,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAEpC,IAAI,CAAC;YACH,MAAM,IAAA,gBAAK,EAAC,IAAA,cAAO,EAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAE5D,IAAI,IAAY,CAAC;YACjB,IAAI,IAAI,CAAC,MA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I,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACvB,CAAC;gBAAC,MAAM,CAAC;oBACP,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC,CAAC;iBACD,MAAM,CAAC,CAAC,CAAC,EAAgC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC;iBACvD,OAAO,EAAE,CAAC,CAAC,oBAAoB;YAElC,gBAAgB;YAChB,IAAI,OAAO,EAAE,UAAU,EAAE,CAAC;gBACxB,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;YACvE,CAAC;YACD,IAAI,OAAO,EAAE,MAAM,EAAE,CAAC;gBACpB,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;YAC/D,CAAC;YAED,mBAAmB;YACnB,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,CAAC,CAAC;YACpC,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC;YACnC,OAAO,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC;QAC/C,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AArGD,kCAqGC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.audit = void 0;
|
|
7
|
+
const picocolors_1 = __importDefault(require("picocolors"));
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const readline_1 = require("readline");
|
|
10
|
+
const path_1 = require("path");
|
|
11
|
+
const config_js_1 = require("../config.js");
|
|
12
|
+
function getLogPath() {
|
|
13
|
+
const configPath = (0, config_js_1.resolveConfigPath)(process.cwd());
|
|
14
|
+
if (configPath) {
|
|
15
|
+
const config = (0, config_js_1.loadConfig)(configPath);
|
|
16
|
+
if (config.audit?.path) {
|
|
17
|
+
return (0, path_1.resolve)(config.audit.path);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return (0, path_1.resolve)(process.cwd(), ".omnibase", "audit.log");
|
|
21
|
+
}
|
|
22
|
+
function formatLine(raw) {
|
|
23
|
+
try {
|
|
24
|
+
const entry = JSON.parse(raw);
|
|
25
|
+
const status = entry.status === "ok" ? picocolors_1.default.green("ok") : picocolors_1.default.red("error");
|
|
26
|
+
const duration = picocolors_1.default.dim(`${entry.duration_ms}ms`);
|
|
27
|
+
const rows = picocolors_1.default.dim(`${entry.rows} row${entry.rows === 1 ? "" : "s"}`);
|
|
28
|
+
const ts = picocolors_1.default.dim(entry.ts);
|
|
29
|
+
const tool = picocolors_1.default.cyan(entry.tool);
|
|
30
|
+
const conn = picocolors_1.default.yellow(entry.connection);
|
|
31
|
+
const sql = entry.sql.length > 80 ? entry.sql.slice(0, 77) + "..." : entry.sql;
|
|
32
|
+
const errorPart = entry.error ? ` ${picocolors_1.default.red(entry.error)}` : "";
|
|
33
|
+
return `${ts} [${status}] ${tool} @ ${conn} ${duration} ${rows}\n ${picocolors_1.default.dim(sql)}${errorPart}`;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return raw;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function printLines(filePath, filter) {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
const rl = (0, readline_1.createInterface)({
|
|
42
|
+
input: (0, fs_1.createReadStream)(filePath, { encoding: "utf-8" }),
|
|
43
|
+
crlfDelay: Infinity,
|
|
44
|
+
});
|
|
45
|
+
rl.on("line", (line) => {
|
|
46
|
+
if (!line.trim())
|
|
47
|
+
return;
|
|
48
|
+
if (filter && !filter(line))
|
|
49
|
+
return;
|
|
50
|
+
console.log(formatLine(line));
|
|
51
|
+
});
|
|
52
|
+
rl.on("close", resolve);
|
|
53
|
+
rl.on("error", reject);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async function printLinesFrom(filePath, startByte) {
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
const stream = (0, fs_1.createReadStream)(filePath, { start: startByte, encoding: "utf-8" });
|
|
59
|
+
const rl = (0, readline_1.createInterface)({ input: stream, crlfDelay: Infinity });
|
|
60
|
+
rl.on("line", (line) => {
|
|
61
|
+
if (!line.trim())
|
|
62
|
+
return;
|
|
63
|
+
console.log(formatLine(line));
|
|
64
|
+
});
|
|
65
|
+
rl.on("close", resolve);
|
|
66
|
+
rl.on("error", reject);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
async function tail() {
|
|
70
|
+
const logPath = getLogPath();
|
|
71
|
+
if (!(0, fs_1.existsSync)(logPath)) {
|
|
72
|
+
console.log(picocolors_1.default.dim(`No audit log found at ${logPath}`));
|
|
73
|
+
console.log(picocolors_1.default.dim("Enable audit logging with: audit: { enabled: true } in your config."));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
console.log(picocolors_1.default.dim(`Tailing ${logPath} — press Ctrl+C to stop\n`));
|
|
77
|
+
await printLines(logPath, null);
|
|
78
|
+
let lastSize = (0, fs_1.statSync)(logPath).size;
|
|
79
|
+
const interval = setInterval(async () => {
|
|
80
|
+
try {
|
|
81
|
+
const currentSize = (0, fs_1.statSync)(logPath).size;
|
|
82
|
+
if (currentSize > lastSize) {
|
|
83
|
+
await printLinesFrom(logPath, lastSize);
|
|
84
|
+
lastSize = currentSize;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch { }
|
|
88
|
+
}, 500);
|
|
89
|
+
process.on("SIGINT", () => {
|
|
90
|
+
clearInterval(interval);
|
|
91
|
+
process.exit(0);
|
|
92
|
+
});
|
|
93
|
+
await new Promise(() => { });
|
|
94
|
+
}
|
|
95
|
+
async function search(query) {
|
|
96
|
+
if (!query) {
|
|
97
|
+
console.error(picocolors_1.default.red("Usage: omnibase-mcp audit search <query>"));
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
const logPath = getLogPath();
|
|
101
|
+
if (!(0, fs_1.existsSync)(logPath)) {
|
|
102
|
+
console.log(picocolors_1.default.dim(`No audit log found at ${logPath}`));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const lowerQuery = query.toLowerCase();
|
|
106
|
+
let matchCount = 0;
|
|
107
|
+
await new Promise((resolve, reject) => {
|
|
108
|
+
const rl = (0, readline_1.createInterface)({
|
|
109
|
+
input: (0, fs_1.createReadStream)(logPath, { encoding: "utf-8" }),
|
|
110
|
+
crlfDelay: Infinity,
|
|
111
|
+
});
|
|
112
|
+
rl.on("line", (line) => {
|
|
113
|
+
if (!line.trim())
|
|
114
|
+
return;
|
|
115
|
+
if (line.toLowerCase().includes(lowerQuery)) {
|
|
116
|
+
matchCount++;
|
|
117
|
+
console.log(formatLine(line));
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
rl.on("close", resolve);
|
|
121
|
+
rl.on("error", reject);
|
|
122
|
+
});
|
|
123
|
+
if (matchCount === 0) {
|
|
124
|
+
console.log(picocolors_1.default.dim(`No entries matching "${query}"`));
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
console.log(picocolors_1.default.dim(`\n${matchCount} matching entries`));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async function clear() {
|
|
131
|
+
const logPath = getLogPath();
|
|
132
|
+
if (!(0, fs_1.existsSync)(logPath)) {
|
|
133
|
+
console.log(picocolors_1.default.dim("No audit log to clear."));
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const p = await import("@clack/prompts");
|
|
137
|
+
const confirmed = await p.confirm({
|
|
138
|
+
message: `Clear audit log at ${logPath}?`,
|
|
139
|
+
initialValue: false,
|
|
140
|
+
});
|
|
141
|
+
if (p.isCancel(confirmed) || !confirmed) {
|
|
142
|
+
p.cancel("Cancelled.");
|
|
143
|
+
process.exit(0);
|
|
144
|
+
}
|
|
145
|
+
(0, fs_1.truncateSync)(logPath, 0);
|
|
146
|
+
console.log(picocolors_1.default.green("Audit log cleared."));
|
|
147
|
+
}
|
|
148
|
+
exports.audit = { tail, search, clear };
|
|
149
|
+
//# sourceMappingURL=audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../../src/cli/audit.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA4B;AAC5B,2BAA0E;AAC1E,uCAA2C;AAC3C,+BAA+B;AAC/B,4CAA6D;AAE7D,SAAS,UAAU;IACjB,MAAM,UAAU,GAAG,IAAA,6BAAiB,EAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACpD,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,MAAM,GAAG,IAAA,sBAAU,EAAC,UAAU,CAAC,CAAC;QACtC,IAAI,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC;YACvB,OAAO,IAAA,cAAO,EAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IACD,OAAO,IAAA,cAAO,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,UAAU,CAAC,GAAW;IAC7B,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9B,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,oBAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,oBAAE,CAAC,GAAG,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manager.js";
|
|
3
|
+
export declare function resolveSidecarPath(): string;
|
|
4
|
+
export interface StartedSidecar {
|
|
5
|
+
sidecar: SidecarClient;
|
|
6
|
+
cm: ConnectionManager;
|
|
7
|
+
}
|
|
8
|
+
export declare function startSidecar(): Promise<StartedSidecar>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveSidecarPath = resolveSidecarPath;
|
|
4
|
+
exports.startSidecar = startSidecar;
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const sidecar_client_js_1 = require("../sidecar-client.js");
|
|
7
|
+
const connection_manager_js_1 = require("../connection-manager.js");
|
|
8
|
+
function resolveSidecarPath() {
|
|
9
|
+
return (process.env.OMNIBASE_SIDECAR_PATH ||
|
|
10
|
+
(0, path_1.resolve)(__dirname, "..", "..", "..", "sidecar", "omnibase-sidecar"));
|
|
11
|
+
}
|
|
12
|
+
async function startSidecar() {
|
|
13
|
+
const sidecar = new sidecar_client_js_1.SidecarClient(resolveSidecarPath());
|
|
14
|
+
await sidecar.start();
|
|
15
|
+
const cm = new connection_manager_js_1.ConnectionManager(sidecar);
|
|
16
|
+
return { sidecar, cm };
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=sidecar-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidecar-utils.js","sourceRoot":"","sources":["../../../src/cli/sidecar-utils.ts"],"names":[],"mappings":";;AAIA,gDAKC;AAOD,oCAKC;AArBD,+BAA+B;AAC/B,4DAAqD;AACrD,oEAA6D;AAE7D,SAAgB,kBAAkB;IAChC,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,qBAAqB;QACjC,IAAA,cAAO,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,kBAAkB,CAAC,CACpE,CAAC;AACJ,CAAC;AAOM,KAAK,UAAU,YAAY;IAChC,MAAM,OAAO,GAAG,IAAI,iCAAa,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACxD,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;IACtB,MAAM,EAAE,GAAG,IAAI,yCAAiB,CAAC,OAAO,CAAC,CAAC;IAC1C,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { OmnibaseConfig } from "../types.js";
|
|
2
|
+
import type { ConnectionManager } from "../connection-manager.js";
|
|
3
|
+
export declare function detectDbType(dsn: string): string;
|
|
4
|
+
export interface PingResult {
|
|
5
|
+
name: string;
|
|
6
|
+
dbType: string;
|
|
7
|
+
permission: string;
|
|
8
|
+
latencyMs: number | null;
|
|
9
|
+
status: "ok" | "error";
|
|
10
|
+
error?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function pingAllConnections(config: OmnibaseConfig, cm: ConnectionManager): Promise<PingResult[]>;
|
|
13
|
+
export declare function renderDashboard(results: PingResult[]): void;
|
|
14
|
+
export declare function runStatus(): Promise<void>;
|