agent-discover 1.3.8 → 1.4.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/CHANGELOG.md +44 -1
- package/README.md +34 -8
- package/agent-desk-plugin.json +10 -3
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +15 -0
- package/dist/context.js.map +1 -1
- package/dist/domain/log.d.ts +7 -3
- package/dist/domain/log.d.ts.map +1 -1
- package/dist/domain/log.js +15 -5
- package/dist/domain/log.js.map +1 -1
- package/dist/domain/presets.d.ts +30 -0
- package/dist/domain/presets.d.ts.map +1 -0
- package/dist/domain/presets.js +76 -0
- package/dist/domain/presets.js.map +1 -0
- package/dist/domain/proxy.d.ts +153 -0
- package/dist/domain/proxy.d.ts.map +1 -1
- package/dist/domain/proxy.js +396 -3
- package/dist/domain/proxy.js.map +1 -1
- package/dist/domain/sampling.d.ts +9 -0
- package/dist/domain/sampling.d.ts.map +1 -0
- package/dist/domain/sampling.js +68 -0
- package/dist/domain/sampling.js.map +1 -0
- package/dist/storage/database.js +21 -0
- package/dist/storage/database.js.map +1 -1
- package/dist/transport/rest.d.ts.map +1 -1
- package/dist/transport/rest.js +349 -0
- package/dist/transport/rest.js.map +1 -1
- package/dist/transport/ws.d.ts.map +1 -1
- package/dist/transport/ws.js +32 -0
- package/dist/transport/ws.js.map +1 -1
- package/dist/ui/app.js +16 -0
- package/dist/ui/index.html +3 -0
- package/dist/ui/markdown.js +102 -0
- package/dist/ui/schema-form.js +393 -0
- package/dist/ui/styles.css +724 -0
- package/dist/ui/tester-window.html +116 -0
- package/dist/ui/tester-window.js +153 -0
- package/dist/ui/tester.js +1412 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,49 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.4.0] - 2026-04-19
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **MCP Inspector-grade Test panel in the dashboard.** Every active server grows a new **Test** section on its card with seven subtabs — Tools, Info, Resources, Prompts, Events, Export, Diagnostics — covering the same debugging surface the upstream `@modelcontextprotocol/inspector` exposes, without launching a second process or second port.
|
|
13
|
+
- **Tools**: schema-driven form renderer (string/number/integer/boolean/enum/array/object + `oneOf`/`anyOf` raw-JSON fallback, format-aware inputs for `date`/`date-time`/`email`/`uri`), three result modes (Pretty / Raw JSON / cURL), latency pill, success/fail badge, "save as preset" + preset dropdown backed by `localStorage`.
|
|
14
|
+
- **Info**: server name, version, instructions (rendered as markdown), advertised capabilities dump.
|
|
15
|
+
- **Resources**: paginated list (Load more cursor), Read / Subscribe / Unsubscribe buttons, live refresh via WS `resources/updated` notifications.
|
|
16
|
+
- **Prompts**: paginated list, argument form, rendered message chain (user/assistant roles, markdown body).
|
|
17
|
+
- **Events**: live stream of server-sent `notifications/*` and `notifications/progress` scoped to the selected server.
|
|
18
|
+
- **Export**: segmented toggle between `mcp.json` (generic MCP client shape — Claude Desktop, Claude Code, Cursor, Windsurf all consume this) and `agent-discover` (declarative setup-file format). Auto-rendered JSON + one-click Copy.
|
|
19
|
+
- **Diagnostics**: `ping` round-trip, `logging/setLevel`.
|
|
20
|
+
- **Pop-out drawer → dedicated browser window.** Each Test drawer has a pop-out button that calls `window.open('/tester/:id', ...)`, spawning a real OS window (resizable, movable, second-monitor-capable) with its own WS connection. Matches Chrome DevTools undock / upstream Inspector UX — no in-page modals. New route `GET /tester/:id` (and `/tester/transient/:handle`) serves a minimal HTML shell that mounts only the tester UI.
|
|
21
|
+
- **Transient (ad-hoc) servers.** New `Test ad-hoc` button in the Servers header spins up a throwaway MCP server by pasted command/args/env (or URL). The child is never written to the registry, gets a 15-minute TTL, auto-disconnects on release, and its tools are invisible to the host MCP catalog — matching Inspector's "test without installing" flow.
|
|
22
|
+
- **14 new REST endpoints** under `/api/servers/:id/*` and `/api/transient/:handle/*`: `info`, `tools` (live), `resources`, `resource-templates`, `resource/read`, `resource/subscribe`, `resource/unsubscribe`, `prompts`, `prompt/get`, `ping`, `logging-level`, `export`, plus `POST /api/transient`, `DELETE /api/transient/:handle`, `GET /api/roots`, `GET /api/logs/notifications`, `GET /api/logs/progress`.
|
|
23
|
+
- **New WebSocket message types.** `notification` and `progress` are broadcast alongside the existing `log_entry` stream so the tester can render events in real time.
|
|
24
|
+
- **Roots capability.** agent-discover now advertises `roots/listChanged` toward every child server; the list is configurable via `AGENT_DISCOVER_ROOTS=file:///path1,file:///path2`.
|
|
25
|
+
- **Elicitation capability.** agent-discover advertises the `elicitation` client capability at activation time so servers that need user-confirmation round-trips are no longer blocked (UI plumbing is v1.5 scope).
|
|
26
|
+
- **`LogKind` taxonomy.** `LogService` entries are now tagged as `call | ping | resource-read | prompt-get | notification | progress | elicitation | sampling` and can be listed / counted per-kind.
|
|
27
|
+
- **Elicitation UI (`elicitation/create`)** — when a transient (ad-hoc) MCP server issues an elicitation request from inside a tool call, agent-discover surfaces it as a modal in the dashboard with a schema-driven form (`requestedSchema` rendered via the existing `schema-form.js`). User picks **Accept** / **Decline** / **Cancel**; the tool call resumes with the response. 2-minute server-side timeout auto-cancels stale requests. New REST endpoints: `GET /api/elicitations`, `POST /api/elicitations/:id/respond`. New WS message type: `elicitation_request`.
|
|
28
|
+
- **Sampling (`sampling/createMessage`) — OpenAI-backed.** Transient servers that call back into an LLM via MCP sampling are routed to OpenAI Chat Completions using `AGENT_DISCOVER_OPENAI_API_KEY` (falls back to `OPENAI_API_KEY`). Model controlled by `AGENT_DISCOVER_SAMPLING_MODEL` (default `gpt-5-mini`), base URL overridable via `AGENT_DISCOVER_OPENAI_BASE_URL`. Every sampling round-trip logged with `kind: "sampling"`. Without a key, the handler declines cleanly so the server can surface the error. `sampling: {}` capability is advertised only on interactive (transient) connections.
|
|
29
|
+
- **Interactive-vs-proxy boundary** — `activate()` threads an `interactive` flag through `ActiveServer`. Elicitation + sampling handlers are registered **only** on `interactive` connections (today: transient only). Registered-active servers stay non-interactive to avoid hijacking the host agent's conversation (documented tradeoff).
|
|
30
|
+
- **SQLite-backed presets (schema V6).** New table `test_presets` persists Test-panel tool/prompt presets cross-browser. REST: `GET /api/presets`, `POST /api/presets`, `DELETE /api/presets/:id`. `tester.js` reads/writes via REST. One-shot migration of legacy `localStorage` presets happens on first load after upgrade.
|
|
31
|
+
|
|
32
|
+
### Security
|
|
33
|
+
|
|
34
|
+
- **Tester API is localhost-only by default.** The 14 new tester endpoints reject non-loopback request origins with 403. Override with `AGENT_DISCOVER_ALLOW_REMOTE_TEST=1` plus a visible warning.
|
|
35
|
+
- **DNS-rebinding protection.** Origin header is validated on all POST/PUT/DELETE tester requests.
|
|
36
|
+
- **Transient command allowlist.** The `command` field passed to `/api/transient` is rejected if it contains unsafe characters. `env` values with CR/LF are stripped to prevent header injection.
|
|
37
|
+
|
|
38
|
+
### Internal
|
|
39
|
+
|
|
40
|
+
- `McpProxy` grows methods for `getServerInfo`, `listToolsLive`, `listResources`, `listResourceTemplates`, `readResource`, `subscribeResource`, `unsubscribeResource`, `listPrompts`, `getPrompt`, `ping`, `setLoggingLevel`, `exportConfig`, plus `activateTransient` / `releaseTransient` / `resolveTransient` and a pluggable `setRootsProvider`.
|
|
41
|
+
- 20 new tests across `tests/proxy-tester.test.ts`, `tests/rest-tester.test.ts`, `tests/log-kinds.test.ts`.
|
|
42
|
+
- New UI modules: `src/ui/schema-form.js`, `src/ui/markdown.js`, `src/ui/tester.js`. Zero new npm dependencies.
|
|
43
|
+
|
|
44
|
+
## [1.3.9] - 2026-04-15
|
|
45
|
+
|
|
46
|
+
### Changed
|
|
47
|
+
|
|
48
|
+
- **Bench README rewritten to reflect reproducible current-state numbers.** Headline replaced with the scaling-of-first-turn-tokens table at N ∈ {10, 100, 1000, 3000} on OpenCode + gpt-5-mini: discover flat at ~20.8k, eager linear (20.9k → 32.4k → 160.9k → context overflow at N=3000). Adversarial CRUD pack now shows both arms at 100% accuracy; discover slightly more expensive on end-to-end multi-turn cost ($0.086 vs $0.068) due to `find_tool` output accumulation in conversation history. Added an explicit multi-turn cost caveat section.
|
|
49
|
+
- **Top-level README elevates the no-session-restart differentiator.** Prominent callout directly under the intro noting that every MCP client today — including Claude Code — requires a full restart to pick up a newly registered MCP server, and agent-discover is the only path to register a new server and have it become discoverable in the same session.
|
|
50
|
+
|
|
8
51
|
## [1.3.2] - 2026-04-12
|
|
9
52
|
|
|
10
53
|
### Changed
|
|
@@ -107,7 +150,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
107
150
|
- **FTS5 + BM25 ranking on `server_tools`** (migration v4). Adds a `server_tools_fts` virtual table with name × 4 / description × 1 column weighting, plus a query preprocessor that expands verb synonyms (`fetch → get`, `cancel → delete`, etc.) and singularizes plurals (`subscriptions → subscription`).
|
|
108
151
|
- **Embedding columns on `server_tools`** (migration v5). `embedding` (TEXT, base64-encoded float32) and `embedding_model` columns for semantic search. Embeddings are optional; tools without one fall back to BM25 ranking only.
|
|
109
152
|
- **Hybrid retrieval (`searchToolsHybrid`).** Brute-force cosine similarity over the entire embedded catalog + BM25 candidate union, scored 70% semantic / 30% lexical. Closes the natural-language gap that pure BM25 misses (e.g. "billing arrangement" → "subscription").
|
|
110
|
-
- **Bench harness** under `bench/` comparing eager tool loading vs deferred discovery. Real Claude Code (`bench/drivers/cli.ts`) and OpenCode (`bench/drivers/opencode.ts`) drivers, isolated bench DB, scoring with `success` / `choice_accuracy` / `distractor_call_rate` / `refusal_rate` metrics, and a standalone `bench/rescore.ts` that re-applies the current scoring logic to captured event streams without spending fresh API tokens. Headline result
|
|
153
|
+
- **Bench harness** under `bench/` comparing eager tool loading vs deferred discovery. Real Claude Code (`bench/drivers/cli.ts`) and OpenCode (`bench/drivers/opencode.ts`) drivers, isolated bench DB, scoring with `success` / `choice_accuracy` / `distractor_call_rate` / `refusal_rate` metrics, and a standalone `bench/rescore.ts` that re-applies the current scoring logic to captured event streams without spending fresh API tokens. Headline reproducible result on OpenCode + gpt-5-mini: discover's first-turn input tokens are flat at ~20.8k across N ∈ {10, 100, 1000, 3000}; eager's grow linearly (20.9k → 32.4k → 160.9k → context overflow at N=3000, where eager can no longer complete the task). Full write-up in `bench/README.md`.
|
|
111
154
|
|
|
112
155
|
## [1.1.4] - 2026-04-09
|
|
113
156
|
|
package/README.md
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
[](LICENSE)
|
|
4
4
|
[](https://nodejs.org/)
|
|
5
|
-
[]()
|
|
6
6
|
[]()
|
|
7
7
|
[]()
|
|
8
|
-
[]()
|
|
9
9
|
|
|
10
10
|
**MCP server registry and marketplace.** Discover, install, activate, and manage MCP tools on demand. Acts as a dynamic proxy -- activated servers have their tools merged into the registry's own tool list, so agents can use them without restarting.
|
|
11
11
|
|
|
12
|
+
> **Every MCP client today — Claude Code, Cursor, Codex CLI, Aider, Continue, plain MCP clients — requires a full agent-session restart to pick up a newly registered MCP server.** The tool catalog is frozen at startup. agent-discover is the only path to register a new server and have it become discoverable in the same running session. This is the one differentiator that survives against every host, even those with their own built-in deferred-tool loaders.
|
|
13
|
+
|
|
12
14
|
Search spans the **official MCP registry**, **npm**, and **PyPI** in one query, so popular servers that aren't in the official index (Microsoft `@playwright/mcp`, `@modelcontextprotocol/server-*`, `mcp-server-fetch`, `mcp-server-git`, …) all show up.
|
|
13
15
|
|
|
14
16
|
Built for AI coding agents (Claude Code, Codex CLI, Gemini CLI, Aider) but works equally well with any MCP client, REST consumer, or WebSocket listener.
|
|
@@ -58,9 +60,10 @@ Static MCP configs mean every server is always running, even when unused. Adding
|
|
|
58
60
|
- **Full-text search** -- FTS5 search across server names, descriptions, and tags + cross-server tool index for `find_tool`
|
|
59
61
|
- **Pre-download** -- fire-and-forget `npm cache add` (npx servers) or `uv tool install` (uvx servers) on registration, plus a dedicated `/preinstall` endpoint
|
|
60
62
|
- **Real-time dashboard** -- web UI at http://localhost:3424 with Servers and Browse tabs, dark/light theme, WebSocket updates
|
|
63
|
+
- **MCP Inspector-grade Test panel** -- every active server card grows a Test drawer with seven subtabs (Tools / Info / Resources / Prompts / Events / Export / Diagnostics). Schema-driven form renderer, Pretty/Raw JSON/cURL result modes, live notification + progress streaming, localStorage presets, pop-out floating panel for side-by-side debugging, and a `Test ad-hoc` button that spins up a throwaway (never-registered) server with a 15-minute TTL. Covers the same surface as upstream `@modelcontextprotocol/inspector` without a second process or second port.
|
|
61
64
|
- **3 transport layers** -- MCP (stdio), REST API (HTTP), WebSocket (real-time events)
|
|
62
65
|
- **Declarative setup file** -- set `AGENT_DISCOVER_SETUP_FILE` to a JSON file listing servers to ensure-registered on startup. Idempotent (skips existing). Supports `auto_activate`, env var secret refs (`$VAR`), and tags. Automatically also reads a `.local.json` variant (e.g. `discover-setup.local.json`) for machine-specific servers with secrets. New `registry({ action: "sync" })` MCP action and `POST /api/sync` REST endpoint for on-demand re-read.
|
|
63
|
-
- **Bench harness** -- under `bench/`, comparing eager tool loading vs deferred discovery against real
|
|
66
|
+
- **Bench harness** -- under `bench/`, comparing eager tool loading vs deferred discovery against real OpenCode + gpt-5-mini. Reproducible structural result: discover's first-turn input tokens are flat in N (~20.8k across N ∈ {10, 100, 1000, 3000}); eager's grow linearly (20.9k → 32.4k → 160.9k → context overflow at N=3000). End-to-end accuracy and multi-turn cost numbers are noisier and model-dependent — see [`bench/README.md`](bench/README.md) for what reproduces and what doesn't.
|
|
64
67
|
|
|
65
68
|
---
|
|
66
69
|
|
|
@@ -136,7 +139,7 @@ When `find_tool` is called with `auto_activate: false` (recommended for catalogs
|
|
|
136
139
|
|
|
137
140
|
---
|
|
138
141
|
|
|
139
|
-
## REST API (
|
|
142
|
+
## REST API (33 endpoints)
|
|
140
143
|
|
|
141
144
|
All endpoints return JSON. CORS enabled.
|
|
142
145
|
|
|
@@ -160,6 +163,27 @@ GET /api/metrics Metrics overview across all servers
|
|
|
160
163
|
GET /api/browse Federated search: official registry + npm + PyPI (?query=, ?limit=, ?cursor=)
|
|
161
164
|
GET /api/npm-check Check if an npm package exists (?package=)
|
|
162
165
|
GET /api/status Active servers summary (names, tool counts, tool lists)
|
|
166
|
+
|
|
167
|
+
Tester surface (MCP Inspector parity — localhost-only unless AGENT_DISCOVER_ALLOW_REMOTE_TEST=1):
|
|
168
|
+
GET /api/servers/:id/info Server name, version, capabilities, instructions
|
|
169
|
+
GET /api/servers/:id/tools Live tools (bypasses activation cache)
|
|
170
|
+
POST /api/servers/:id/call Call a tool
|
|
171
|
+
GET /api/servers/:id/resources List resources (?cursor=...)
|
|
172
|
+
GET /api/servers/:id/resource-templates List resource templates
|
|
173
|
+
POST /api/servers/:id/resource/read Read a resource
|
|
174
|
+
POST /api/servers/:id/resource/subscribe Subscribe to resource updates
|
|
175
|
+
POST /api/servers/:id/resource/unsubscribe Unsubscribe
|
|
176
|
+
GET /api/servers/:id/prompts List prompts (?cursor=...)
|
|
177
|
+
POST /api/servers/:id/prompt/get Get a prompt with args
|
|
178
|
+
POST /api/servers/:id/ping Ping — returns { ok, rtt_ms }
|
|
179
|
+
POST /api/servers/:id/logging-level Set server logging level
|
|
180
|
+
GET /api/servers/:id/export Export config (?format=mcp-json|claude-code|cursor|agent-discover)
|
|
181
|
+
POST /api/transient Activate an ad-hoc server (returns { handle, ... })
|
|
182
|
+
DELETE /api/transient/:handle Release transient server
|
|
183
|
+
GET /api/transient/:handle/* Same tester surface, keyed by handle
|
|
184
|
+
GET /api/roots Configured client roots (AGENT_DISCOVER_ROOTS)
|
|
185
|
+
GET /api/logs/notifications Notification log entries
|
|
186
|
+
GET /api/logs/progress Progress log entries
|
|
163
187
|
```
|
|
164
188
|
|
|
165
189
|
---
|
|
@@ -192,10 +216,12 @@ npm run test:e2e:ui # Playwright dashboard smoke tests
|
|
|
192
216
|
|
|
193
217
|
### Core
|
|
194
218
|
|
|
195
|
-
| Variable
|
|
196
|
-
|
|
|
197
|
-
| `AGENT_DISCOVER_PORT`
|
|
198
|
-
| `AGENT_DISCOVER_DB`
|
|
219
|
+
| Variable | Default | Description |
|
|
220
|
+
| ---------------------------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
221
|
+
| `AGENT_DISCOVER_PORT` | `3424` | Dashboard HTTP port |
|
|
222
|
+
| `AGENT_DISCOVER_DB` | `~/.claude/agent-discover.db` | SQLite database path |
|
|
223
|
+
| `AGENT_DISCOVER_ROOTS` | — | Comma-separated root URIs advertised to child servers (e.g. `file:///Users/me/repo,file:///Users/me/data`) |
|
|
224
|
+
| `AGENT_DISCOVER_ALLOW_REMOTE_TEST` | `0` | Set to `1` to allow the Test panel endpoints from non-loopback origins. **Not recommended** — see Security. |
|
|
199
225
|
|
|
200
226
|
### Embeddings (semantic search for `find_tool`)
|
|
201
227
|
|
package/agent-desk-plugin.json
CHANGED
|
@@ -2,10 +2,17 @@
|
|
|
2
2
|
"id": "agent-discover",
|
|
3
3
|
"name": "Discover",
|
|
4
4
|
"icon": "explore",
|
|
5
|
-
"version": "1.
|
|
6
|
-
"description": "MCP server registry — browse, install, configure, monitor",
|
|
5
|
+
"version": "1.4.0",
|
|
6
|
+
"description": "MCP server registry — browse, install, configure, monitor, test",
|
|
7
7
|
"ui": "./dist/ui/app.js",
|
|
8
8
|
"css": "./dist/ui/styles.css",
|
|
9
|
-
"uiFiles": [
|
|
9
|
+
"uiFiles": [
|
|
10
|
+
"morphdom.min.js",
|
|
11
|
+
"template.js",
|
|
12
|
+
"markdown.js",
|
|
13
|
+
"schema-form.js",
|
|
14
|
+
"tester.js",
|
|
15
|
+
"app.js"
|
|
16
|
+
],
|
|
10
17
|
"position": 4
|
|
11
18
|
}
|
package/dist/context.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { SecretsService } from './domain/secrets.js';
|
|
|
8
8
|
import { HealthService } from './domain/health.js';
|
|
9
9
|
import { MetricsService } from './domain/metrics.js';
|
|
10
10
|
import { LogService } from './domain/log.js';
|
|
11
|
+
import { PresetsService } from './domain/presets.js';
|
|
11
12
|
import { type SyncResult } from './domain/setup.js';
|
|
12
13
|
export interface AppContext {
|
|
13
14
|
readonly db: Db;
|
|
@@ -20,6 +21,7 @@ export interface AppContext {
|
|
|
20
21
|
readonly health: HealthService;
|
|
21
22
|
readonly metrics: MetricsService;
|
|
22
23
|
readonly logs: LogService;
|
|
24
|
+
readonly presets: PresetsService;
|
|
23
25
|
syncSetup(filePath?: string): Promise<SyncResult>;
|
|
24
26
|
close(): void;
|
|
25
27
|
}
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAOA,OAAO,EAAY,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEnE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;IAChB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,QAAQ,CAAC,QAA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;AAEnE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;IAChB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAClD,KAAK,IAAI,IAAI,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,UAAU,CAwD/D;AAkBD,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBzE"}
|
package/dist/context.js
CHANGED
|
@@ -14,6 +14,8 @@ import { SecretsService } from './domain/secrets.js';
|
|
|
14
14
|
import { HealthService } from './domain/health.js';
|
|
15
15
|
import { MetricsService } from './domain/metrics.js';
|
|
16
16
|
import { LogService } from './domain/log.js';
|
|
17
|
+
import { PresetsService } from './domain/presets.js';
|
|
18
|
+
import { maybeCreateDefaultSamplingProvider } from './domain/sampling.js';
|
|
17
19
|
import { syncSetupFile } from './domain/setup.js';
|
|
18
20
|
export function createContext(dbOptions) {
|
|
19
21
|
const db = createDb(dbOptions);
|
|
@@ -27,6 +29,7 @@ export function createContext(dbOptions) {
|
|
|
27
29
|
const metrics = new MetricsService(db);
|
|
28
30
|
const health = new HealthService(db, proxy);
|
|
29
31
|
const logs = new LogService();
|
|
32
|
+
const presets = new PresetsService(db);
|
|
30
33
|
proxy.setSecretsService(secrets);
|
|
31
34
|
proxy.setMetricsService(metrics);
|
|
32
35
|
proxy.setLogService(logs);
|
|
@@ -34,6 +37,17 @@ export function createContext(dbOptions) {
|
|
|
34
37
|
const server = registry.getByName(name);
|
|
35
38
|
return server ? server.id : null;
|
|
36
39
|
});
|
|
40
|
+
proxy.setRootsProvider(() => {
|
|
41
|
+
const raw = process.env.AGENT_DISCOVER_ROOTS ?? '';
|
|
42
|
+
return raw
|
|
43
|
+
.split(',')
|
|
44
|
+
.map((s) => s.trim())
|
|
45
|
+
.filter(Boolean)
|
|
46
|
+
.map((uri) => ({ uri, name: uri }));
|
|
47
|
+
});
|
|
48
|
+
const samplingProvider = maybeCreateDefaultSamplingProvider();
|
|
49
|
+
if (samplingProvider)
|
|
50
|
+
proxy.setSamplingProvider(samplingProvider);
|
|
37
51
|
return {
|
|
38
52
|
db,
|
|
39
53
|
events,
|
|
@@ -45,6 +59,7 @@ export function createContext(dbOptions) {
|
|
|
45
59
|
health,
|
|
46
60
|
metrics,
|
|
47
61
|
logs,
|
|
62
|
+
presets,
|
|
48
63
|
syncSetup(filePath) {
|
|
49
64
|
return syncSetupFile(registry, secrets, proxy, filePath);
|
|
50
65
|
},
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,uCAAuC;AACvC,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,gFAAgF;AAEhF,OAAO,EAAE,QAAQ,EAA2B,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;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AC;IACF,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,CAAC,MAAM;YAAE,SAAS;QACtB,IAAI,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;YAAE,SAAS;QAC9C,IAAI,CAAC;YACH,MAAM,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC;gBACvB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,SAAS;gBACpC,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,GAAG,EAAE,MAAM,CAAC,QAAQ,IAAI,SAAS;aAClC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,qDAAqD,MAAM,CAAC,IAAI,MAAM,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAC3H,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/domain/log.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type LogKind = 'call' | 'ping' | 'resource-read' | 'prompt-get' | 'notification' | 'progress' | 'elicitation' | 'sampling';
|
|
1
2
|
export interface LogEntry {
|
|
2
3
|
id: number;
|
|
3
4
|
timestamp: string;
|
|
@@ -7,6 +8,7 @@ export interface LogEntry {
|
|
|
7
8
|
response: string;
|
|
8
9
|
latency_ms: number;
|
|
9
10
|
success: boolean;
|
|
11
|
+
kind: LogKind;
|
|
10
12
|
}
|
|
11
13
|
export declare class LogService {
|
|
12
14
|
private readonly buffer;
|
|
@@ -15,10 +17,12 @@ export declare class LogService {
|
|
|
15
17
|
private seq;
|
|
16
18
|
onEntry?: (entry: LogEntry) => void;
|
|
17
19
|
constructor(max?: number, retentionDays?: number);
|
|
18
|
-
push(server: string, tool: string, args: Record<string, unknown>, response: string, latencyMs: number, success: boolean): LogEntry;
|
|
20
|
+
push(server: string, tool: string, args: Record<string, unknown>, response: string, latencyMs: number, success: boolean, kind?: LogKind): LogEntry;
|
|
21
|
+
pushNotification(server: string, method: string, payload: Record<string, unknown>): LogEntry;
|
|
22
|
+
pushProgress(server: string, token: string | number, progress: number, total: number | undefined, message: string | undefined): LogEntry;
|
|
19
23
|
private pruneExpired;
|
|
20
|
-
list(limit?: number, offset?: number): LogEntry[];
|
|
21
|
-
count(): number;
|
|
24
|
+
list(limit?: number, offset?: number, kind?: LogKind): LogEntry[];
|
|
25
|
+
count(kind?: LogKind): number;
|
|
22
26
|
clear(): void;
|
|
23
27
|
}
|
|
24
28
|
//# sourceMappingURL=log.d.ts.map
|
package/dist/domain/log.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/domain/log.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/domain/log.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,OAAO,GACf,MAAM,GACN,MAAM,GACN,eAAe,GACf,YAAY,GACZ,cAAc,GACd,UAAU,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CAAC,KAAK,SAAM,EAAE,MAAM,SAAI,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,EAAE;IAMzD,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM;IAK7B,KAAK,IAAI,IAAI;CAGd"}
|
package/dist/domain/log.js
CHANGED
|
@@ -15,7 +15,7 @@ export class LogService {
|
|
|
15
15
|
parseInt(process.env.AGENT_DISCOVER_LOG_RETENTION_DAYS ?? String(DEFAULT_RETENTION_DAYS), 10);
|
|
16
16
|
this.retentionMs = (days > 0 ? days : DEFAULT_RETENTION_DAYS) * 86_400_000;
|
|
17
17
|
}
|
|
18
|
-
push(server, tool, args, response, latencyMs, success) {
|
|
18
|
+
push(server, tool, args, response, latencyMs, success, kind = 'call') {
|
|
19
19
|
this.pruneExpired();
|
|
20
20
|
const entry = {
|
|
21
21
|
id: ++this.seq,
|
|
@@ -26,6 +26,7 @@ export class LogService {
|
|
|
26
26
|
response,
|
|
27
27
|
latency_ms: latencyMs,
|
|
28
28
|
success,
|
|
29
|
+
kind,
|
|
29
30
|
};
|
|
30
31
|
this.buffer.push(entry);
|
|
31
32
|
if (this.buffer.length > this.max)
|
|
@@ -34,18 +35,27 @@ export class LogService {
|
|
|
34
35
|
this.onEntry(entry);
|
|
35
36
|
return entry;
|
|
36
37
|
}
|
|
38
|
+
pushNotification(server, method, payload) {
|
|
39
|
+
return this.push(server, method, payload, JSON.stringify(payload), 0, true, 'notification');
|
|
40
|
+
}
|
|
41
|
+
pushProgress(server, token, progress, total, message) {
|
|
42
|
+
return this.push(server, 'progress', { token, progress, total, message }, message ?? '', 0, true, 'progress');
|
|
43
|
+
}
|
|
37
44
|
pruneExpired() {
|
|
38
45
|
const cutoff = Date.now() - this.retentionMs;
|
|
39
46
|
while (this.buffer.length > 0 && new Date(this.buffer[0].timestamp).getTime() < cutoff) {
|
|
40
47
|
this.buffer.shift();
|
|
41
48
|
}
|
|
42
49
|
}
|
|
43
|
-
list(limit = 100, offset = 0) {
|
|
44
|
-
const
|
|
50
|
+
list(limit = 100, offset = 0, kind) {
|
|
51
|
+
const filtered = kind ? this.buffer.filter((e) => e.kind === kind) : this.buffer;
|
|
52
|
+
const reversed = [...filtered].reverse();
|
|
45
53
|
return reversed.slice(offset, offset + limit);
|
|
46
54
|
}
|
|
47
|
-
count() {
|
|
48
|
-
|
|
55
|
+
count(kind) {
|
|
56
|
+
if (!kind)
|
|
57
|
+
return this.buffer.length;
|
|
58
|
+
return this.buffer.reduce((n, e) => n + (e.kind === kind ? 1 : 0), 0);
|
|
49
59
|
}
|
|
50
60
|
clear() {
|
|
51
61
|
this.buffer.length = 0;
|
package/dist/domain/log.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/domain/log.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,oCAAoC;AACpC,gFAAgF;AAEhF,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,sBAAsB,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/domain/log.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,oCAAoC;AACpC,gFAAgF;AAEhF,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAwBlC,MAAM,OAAO,UAAU;IACJ,MAAM,GAAe,EAAE,CAAC;IACxB,GAAG,CAAS;IACZ,WAAW,CAAS;IAC7B,GAAG,GAAG,CAAC,CAAC;IAChB,OAAO,CAA6B;IAEpC,YAAY,GAAG,GAAG,WAAW,EAAE,aAAsB;QACnD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,MAAM,IAAI,GACR,aAAa;YACb,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,iCAAiC,IAAI,MAAM,CAAC,sBAAsB,CAAC,EAAE,EAAE,CAAC,CAAC;QAChG,IAAI,CAAC,WAAW,GAAG,CA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
import type { Db } from '../storage/database.js';
|
|
2
|
+
export type PresetKind = 'tool' | 'prompt';
|
|
3
|
+
export interface PresetEntry {
|
|
4
|
+
id: number;
|
|
5
|
+
server_name: string;
|
|
6
|
+
kind: PresetKind;
|
|
7
|
+
target_name: string;
|
|
8
|
+
preset_name: string;
|
|
9
|
+
payload: unknown;
|
|
10
|
+
created_at: string;
|
|
11
|
+
updated_at: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class PresetsService {
|
|
14
|
+
private readonly db;
|
|
15
|
+
constructor(db: Db);
|
|
16
|
+
list(filter?: {
|
|
17
|
+
server?: string;
|
|
18
|
+
kind?: PresetKind;
|
|
19
|
+
target?: string;
|
|
20
|
+
}): PresetEntry[];
|
|
21
|
+
upsert(input: {
|
|
22
|
+
server: string;
|
|
23
|
+
kind: PresetKind;
|
|
24
|
+
target: string;
|
|
25
|
+
preset: string;
|
|
26
|
+
payload: unknown;
|
|
27
|
+
}): PresetEntry;
|
|
28
|
+
delete(id: number): boolean;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=presets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/domain/presets.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAEjD,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE3C,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAgCD,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,EAAE;IAEnC,IAAI,CAAC,MAAM,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,UAAU,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,WAAW,EAAE;IAoBzF,MAAM,CAAC,KAAK,EAAE;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,UAAU,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,OAAO,CAAC;KAClB,GAAG,WAAW;IA2Bf,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;CAI5B"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// agent-discover — Preset storage for the Test panel
|
|
3
|
+
// =============================================================================
|
|
4
|
+
function hydrate(row) {
|
|
5
|
+
let payload;
|
|
6
|
+
try {
|
|
7
|
+
payload = JSON.parse(row.payload);
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
payload = {};
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
id: row.id,
|
|
14
|
+
server_name: row.server_name,
|
|
15
|
+
kind: row.kind,
|
|
16
|
+
target_name: row.target_name,
|
|
17
|
+
preset_name: row.preset_name,
|
|
18
|
+
payload,
|
|
19
|
+
created_at: row.created_at,
|
|
20
|
+
updated_at: row.updated_at,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export class PresetsService {
|
|
24
|
+
db;
|
|
25
|
+
constructor(db) {
|
|
26
|
+
this.db = db;
|
|
27
|
+
}
|
|
28
|
+
list(filter = {}) {
|
|
29
|
+
const clauses = [];
|
|
30
|
+
const params = [];
|
|
31
|
+
if (filter.server) {
|
|
32
|
+
clauses.push('server_name = ?');
|
|
33
|
+
params.push(filter.server);
|
|
34
|
+
}
|
|
35
|
+
if (filter.kind) {
|
|
36
|
+
clauses.push('kind = ?');
|
|
37
|
+
params.push(filter.kind);
|
|
38
|
+
}
|
|
39
|
+
if (filter.target) {
|
|
40
|
+
clauses.push('target_name = ?');
|
|
41
|
+
params.push(filter.target);
|
|
42
|
+
}
|
|
43
|
+
const sql = `SELECT * FROM test_presets${clauses.length ? ' WHERE ' + clauses.join(' AND ') : ''} ORDER BY server_name, target_name, preset_name`;
|
|
44
|
+
const rows = this.db.queryAll(sql, params);
|
|
45
|
+
return rows.map(hydrate);
|
|
46
|
+
}
|
|
47
|
+
upsert(input) {
|
|
48
|
+
if (!input.server)
|
|
49
|
+
throw new Error('server is required');
|
|
50
|
+
if (!input.target)
|
|
51
|
+
throw new Error('target is required');
|
|
52
|
+
if (!input.preset)
|
|
53
|
+
throw new Error('preset is required');
|
|
54
|
+
if (input.kind !== 'tool' && input.kind !== 'prompt') {
|
|
55
|
+
throw new Error(`kind must be "tool" or "prompt", got "${input.kind}"`);
|
|
56
|
+
}
|
|
57
|
+
const payloadJson = JSON.stringify(input.payload ?? {});
|
|
58
|
+
this.db.run(`
|
|
59
|
+
INSERT INTO test_presets (server_name, kind, target_name, preset_name, payload)
|
|
60
|
+
VALUES (?, ?, ?, ?, ?)
|
|
61
|
+
ON CONFLICT(server_name, kind, target_name, preset_name) DO UPDATE SET
|
|
62
|
+
payload = excluded.payload,
|
|
63
|
+
updated_at = datetime('now')
|
|
64
|
+
`, [input.server, input.kind, input.target, input.preset, payloadJson]);
|
|
65
|
+
const row = this.db.queryOne(`SELECT * FROM test_presets
|
|
66
|
+
WHERE server_name = ? AND kind = ? AND target_name = ? AND preset_name = ?`, [input.server, input.kind, input.target, input.preset]);
|
|
67
|
+
if (!row)
|
|
68
|
+
throw new Error('Failed to persist preset');
|
|
69
|
+
return hydrate(row);
|
|
70
|
+
}
|
|
71
|
+
delete(id) {
|
|
72
|
+
const result = this.db.run('DELETE FROM test_presets WHERE id = ?', [id]);
|
|
73
|
+
return result.changes > 0;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# s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