@uptimizr/agent-core 1.0.1 → 1.1.1
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/AGENTS.md +74 -8
- package/README.md +62 -14
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/registryTools.d.ts +54 -0
- package/dist/registryTools.d.ts.map +1 -0
- package/dist/registryTools.js +409 -0
- package/dist/registryTools.js.map +1 -0
- package/dist/tools.d.ts +44 -9
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +38 -328
- package/dist/tools.js.map +1 -1
- package/llms.txt +49 -1
- package/package.json +4 -2
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **Generated tool catalog** (ADR 0051 §1, design sketch §A.2).
|
|
3
|
+
*
|
|
4
|
+
* `registryToTools()` turns the semantic metric registry in `@uptimizr/metrics`
|
|
5
|
+
* into the read-only {@link ReadTool} catalog this package exports. One registry
|
|
6
|
+
* entry with an `endpoint` becomes exactly one tool, so agent coverage of the
|
|
7
|
+
* collector's read surface is mechanical rather than hand-maintained: adding an
|
|
8
|
+
* aggregation + a registry entry adds the tool, and there is no second list to
|
|
9
|
+
* forget.
|
|
10
|
+
*
|
|
11
|
+
* What each part of a tool is derived from:
|
|
12
|
+
*
|
|
13
|
+
* | Tool field | Registry source |
|
|
14
|
+
* | -------------- | ---------------------------------------------------------- |
|
|
15
|
+
* | `name` | `id` (the 20 shipped tool names are registry ids verbatim) |
|
|
16
|
+
* | `title` | `title` |
|
|
17
|
+
* | `description` | `description` + `interpretation` + `caveats` |
|
|
18
|
+
* | `inputSchema` | `filters` + `endpoint.pathParams`, via {@link FILTER_FIELDS} |
|
|
19
|
+
* | `buildRequest` | `endpoint.path` (with `:param` substitution) + `filters` |
|
|
20
|
+
* | `outputSchema` | `row`, wrapped as `{ rows: Row[] }` |
|
|
21
|
+
*
|
|
22
|
+
* **Browser safety (ADR 0050).** This module imports `@uptimizr/metrics` — the
|
|
23
|
+
* registry's own dependency-free package, whose only runtime dependencies are
|
|
24
|
+
* `zod` and `@uptimizr/schema`. This package does not depend on `@uptimizr/db`
|
|
25
|
+
* at all: that package owns the DuckDB store and pulls in a ~37 MB native
|
|
26
|
+
* binding a browser can never use. `src/__tests__/browserSafety.test.ts` bundles
|
|
27
|
+
* this package for the browser and fails if any `node:` built-in or the DuckDB
|
|
28
|
+
* driver reaches the bundle, and `src/__tests__/dependencies.test.ts` fails if
|
|
29
|
+
* `@uptimizr/db` ever reappears in the manifest.
|
|
30
|
+
*/
|
|
31
|
+
import { z } from "zod";
|
|
32
|
+
import { allMetrics } from "@uptimizr/metrics";
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
// Shared parameter definitions
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
//
|
|
37
|
+
// One Zod field per registry `FilterId`, defined **once** and reused by every
|
|
38
|
+
// tool that accepts that filter — the "a param means the same thing everywhere"
|
|
39
|
+
// rule the capabilities resource already assumes.
|
|
40
|
+
//
|
|
41
|
+
// The fields for the parameters the hand-written catalog shipped (`since`,
|
|
42
|
+
// `until`, `bins`, `limit`, `scene`, `session`, `cellSize`, `interval`, `type`,
|
|
43
|
+
// `source`, `cameraMode`, `rapidTurn`, `steps`) are carried over **verbatim**,
|
|
44
|
+
// so the 20 shipped tools' JSON Schemas are byte-identical after the migration
|
|
45
|
+
// (`src/__tests__/shippedToolCompat.test.ts` pins that against a frozen
|
|
46
|
+
// fixture). Bounds on the new fields mirror the collector's own Zod querystring
|
|
47
|
+
// in `oss/apps/collector-server/src/routes/query.ts`.
|
|
48
|
+
const since = z.number().int().optional().describe("Start of the time range, epoch milliseconds.");
|
|
49
|
+
const until = z.number().int().optional().describe("End of the time range, epoch milliseconds.");
|
|
50
|
+
const bins = z.number().int().positive().max(500).optional().describe("Grid resolution per axis.");
|
|
51
|
+
const limit = z.number().int().positive().max(1000).optional().describe("Maximum rows to return.");
|
|
52
|
+
const scene = z.string().optional().describe("Restrict to one developer-assigned scene id.");
|
|
53
|
+
const session = z.string().optional().describe("Scope the aggregate to a single session id.");
|
|
54
|
+
const cellSize = z.number().positive().max(1000).optional().describe("Voxel size in world units.");
|
|
55
|
+
const interval = z
|
|
56
|
+
.number()
|
|
57
|
+
.int()
|
|
58
|
+
.positive()
|
|
59
|
+
.optional()
|
|
60
|
+
.describe("Time-series bucket width, seconds.");
|
|
61
|
+
const eventType = z
|
|
62
|
+
.string()
|
|
63
|
+
.optional()
|
|
64
|
+
.describe("Restrict to a single event type, e.g. pointer_click.");
|
|
65
|
+
const source = z
|
|
66
|
+
.enum(["mouse", "touch", "stylus", "pen", "xr-controller", "hand", "gaze", "transient", "other"])
|
|
67
|
+
.optional()
|
|
68
|
+
.describe("Restrict a pointer/world heatmap to one input source.");
|
|
69
|
+
const cameraMode = z
|
|
70
|
+
.enum(["viewer", "first-person"])
|
|
71
|
+
.optional()
|
|
72
|
+
.describe("Camera navigation mode to scope to: 'viewer' (orbit) or 'first-person' (walkable).");
|
|
73
|
+
const rapidTurn = z
|
|
74
|
+
.number()
|
|
75
|
+
.nonnegative()
|
|
76
|
+
.max(Math.PI)
|
|
77
|
+
.optional()
|
|
78
|
+
.describe("Rapid-turn threshold in radians (0..π); view turns above this flag motion-sickness risk.");
|
|
79
|
+
const steps = z
|
|
80
|
+
.string()
|
|
81
|
+
.min(1)
|
|
82
|
+
.describe("Funnel steps as a JSON-encoded array of ordered step predicates (ADR 0038). Required. " +
|
|
83
|
+
'Each step is `{ "type": <event_type>, ... }`; e.g. ' +
|
|
84
|
+
'`[{"type":"scene_change","to":"lobby"},{"type":"mesh_interaction","mesh":"buy"}]`.');
|
|
85
|
+
/**
|
|
86
|
+
* The Zod field each {@link FilterId} contributes to a tool's input schema.
|
|
87
|
+
*
|
|
88
|
+
* Every entry is **optional** except the two the collector declares required
|
|
89
|
+
* (see {@link REQUIRED_FILTERS}); `filterField()` re-derives requiredness per
|
|
90
|
+
* metric so one shared definition serves both cases.
|
|
91
|
+
*/
|
|
92
|
+
const FILTER_FIELDS = {
|
|
93
|
+
since,
|
|
94
|
+
until,
|
|
95
|
+
scene,
|
|
96
|
+
session,
|
|
97
|
+
source,
|
|
98
|
+
mesh: z.string().min(1).max(256).optional().describe("Restrict to one mesh/object name."),
|
|
99
|
+
region: z
|
|
100
|
+
.string()
|
|
101
|
+
.optional()
|
|
102
|
+
.describe("World-space drill-down box as `minX,minY,minZ,maxX,maxY,maxZ` (ADR 0040 §4). " +
|
|
103
|
+
"Omit for the whole scene."),
|
|
104
|
+
cameraMode,
|
|
105
|
+
bins,
|
|
106
|
+
limit,
|
|
107
|
+
cellSize,
|
|
108
|
+
interval,
|
|
109
|
+
type: eventType,
|
|
110
|
+
bucket: z.number().int().positive().max(240).optional().describe("Histogram bin width in FPS."),
|
|
111
|
+
bucketMs: z
|
|
112
|
+
.number()
|
|
113
|
+
.int()
|
|
114
|
+
.positive()
|
|
115
|
+
.max(60_000)
|
|
116
|
+
.optional()
|
|
117
|
+
.describe("Histogram bin width in milliseconds."),
|
|
118
|
+
bucketSize: z
|
|
119
|
+
.number()
|
|
120
|
+
.positive()
|
|
121
|
+
.max(1000)
|
|
122
|
+
.optional()
|
|
123
|
+
.describe("Histogram bin width in world units."),
|
|
124
|
+
minRepeats: z
|
|
125
|
+
.number()
|
|
126
|
+
.int()
|
|
127
|
+
.min(2)
|
|
128
|
+
.max(100)
|
|
129
|
+
.optional()
|
|
130
|
+
.describe("Minimum clicks in a window before it counts as a rage cluster."),
|
|
131
|
+
windowMs: z
|
|
132
|
+
.number()
|
|
133
|
+
.int()
|
|
134
|
+
.positive()
|
|
135
|
+
.max(86_400_000)
|
|
136
|
+
.optional()
|
|
137
|
+
.describe("How long before a session's end a perf dip still counts as correlated."),
|
|
138
|
+
fpsThreshold: z
|
|
139
|
+
.number()
|
|
140
|
+
.positive()
|
|
141
|
+
.max(240)
|
|
142
|
+
.optional()
|
|
143
|
+
.describe("A frame-perf sample below this FPS counts as a dip."),
|
|
144
|
+
stallMs: z
|
|
145
|
+
.number()
|
|
146
|
+
.nonnegative()
|
|
147
|
+
.max(60_000)
|
|
148
|
+
.optional()
|
|
149
|
+
.describe("A shader-compile stall at least this long (ms) counts as a dip."),
|
|
150
|
+
moveThreshold: z
|
|
151
|
+
.number()
|
|
152
|
+
.nonnegative()
|
|
153
|
+
.max(1000)
|
|
154
|
+
.optional()
|
|
155
|
+
.describe("Inter-sample distance (world units) above which a segment counts as active travel."),
|
|
156
|
+
rapidTurn,
|
|
157
|
+
centerX: z.number().optional().describe("X of the reference point distances are measured from."),
|
|
158
|
+
centerY: z.number().optional().describe("Y of the reference point distances are measured from."),
|
|
159
|
+
centerZ: z.number().optional().describe("Z of the reference point distances are measured from."),
|
|
160
|
+
severity: z
|
|
161
|
+
.string()
|
|
162
|
+
.min(1)
|
|
163
|
+
.max(64)
|
|
164
|
+
.optional()
|
|
165
|
+
.describe("Graphics-diagnostic severity (info / warning / error / fatal). " +
|
|
166
|
+
"Setting it excludes JS runtime errors."),
|
|
167
|
+
category: z
|
|
168
|
+
.string()
|
|
169
|
+
.min(1)
|
|
170
|
+
.max(64)
|
|
171
|
+
.optional()
|
|
172
|
+
.describe("Graphics-diagnostic category (context-loss / validation / shader-compile / …). " +
|
|
173
|
+
"Setting it excludes JS runtime errors."),
|
|
174
|
+
errorKind: z
|
|
175
|
+
.string()
|
|
176
|
+
.min(1)
|
|
177
|
+
.max(64)
|
|
178
|
+
.optional()
|
|
179
|
+
.describe("Runtime-error kind (error / unhandledrejection). Setting it excludes engine diagnostics."),
|
|
180
|
+
groupByOrigin: z
|
|
181
|
+
.boolean()
|
|
182
|
+
.optional()
|
|
183
|
+
.describe("Add the click-time standpoint voxel as a grouping dimension."),
|
|
184
|
+
originVoxel: z
|
|
185
|
+
.string()
|
|
186
|
+
.regex(/^-?\d+(\.\d+)?,-?\d+(\.\d+)?,-?\d+(\.\d+)?$/)
|
|
187
|
+
.optional()
|
|
188
|
+
.describe("Restrict to clicks whose standpoint falls in this `vx,vy,vz` voxel."),
|
|
189
|
+
steps: steps.optional(),
|
|
190
|
+
bands: z
|
|
191
|
+
.string()
|
|
192
|
+
.max(256)
|
|
193
|
+
.optional()
|
|
194
|
+
.describe("Ascending, comma-separated load-time band boundaries in ms. " +
|
|
195
|
+
"Omit for the default `1000,3000,5000`."),
|
|
196
|
+
variant: z
|
|
197
|
+
.string()
|
|
198
|
+
.min(1)
|
|
199
|
+
.max(2048)
|
|
200
|
+
.optional()
|
|
201
|
+
.describe("JSON funnel-step predicate selecting the variant events. " +
|
|
202
|
+
"Omit to treat every custom event as a variant."),
|
|
203
|
+
conversion: z
|
|
204
|
+
.string()
|
|
205
|
+
.min(1)
|
|
206
|
+
.max(2048)
|
|
207
|
+
.optional()
|
|
208
|
+
.describe("JSON funnel-step predicate for the success event. Omit to report views only."),
|
|
209
|
+
// The shared result envelope (ADR 0051 §2). Declared literally rather than
|
|
210
|
+
// imported from `@uptimizr/db/summary`, which would put a database driver back
|
|
211
|
+
// on this package's dependency graph. `full` stays the default here: switching
|
|
212
|
+
// the generated tools to `table` is a separate, documented change (#299).
|
|
213
|
+
format: z
|
|
214
|
+
.enum(["full", "table", "summary"])
|
|
215
|
+
.optional()
|
|
216
|
+
.describe("Result envelope. `full` (default) returns the bare rows; `table` wraps them with a " +
|
|
217
|
+
"`meta` block; `summary` returns a bounded digest — top rows, a trend or merged " +
|
|
218
|
+
"spatial clusters — with shares, caveats and a plain-language reading. Prefer " +
|
|
219
|
+
"`summary` for a large result such as a heatmap or a long leaderboard."),
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Filters the collector declares **required** in its querystring schema, by
|
|
223
|
+
* metric id. The registry records requiredness in prose (a `caveats` line) but
|
|
224
|
+
* not as data, so the two exceptions are listed here; everything else is
|
|
225
|
+
* optional. Path parameters are always required and are handled separately.
|
|
226
|
+
*
|
|
227
|
+
* Keep this in step with `oss/apps/collector-server/src/routes/query.ts`
|
|
228
|
+
* (`funnelQueryParams.steps`, `meshUvHeatmapQueryParams.mesh`). Promoting it
|
|
229
|
+
* into the registry itself is tracked as a follow-up.
|
|
230
|
+
*/
|
|
231
|
+
const REQUIRED_FILTERS = {
|
|
232
|
+
funnel: ["steps"],
|
|
233
|
+
mesh_uv_heatmap: ["mesh"],
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* The **required** variant of each filter named in {@link REQUIRED_FILTERS} —
|
|
237
|
+
* the same field without the trailing `.optional()`. Declared rather than
|
|
238
|
+
* unwrapped so the shipped `steps` schema stays byte-identical.
|
|
239
|
+
*/
|
|
240
|
+
const REQUIRED_FILTER_FIELDS = {
|
|
241
|
+
steps,
|
|
242
|
+
mesh: z.string().min(1).max(256).describe("The mesh/object name to bin. Required."),
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Argument name for a filter that travels in the **path** rather than the
|
|
246
|
+
* querystring. The registry names such a parameter by the filter it binds
|
|
247
|
+
* (`session`, `scene`); the shipped tools call them `sessionId` / `sceneId` and
|
|
248
|
+
* those names are part of the public MCP contract, so they are preserved.
|
|
249
|
+
*/
|
|
250
|
+
const PATH_PARAM_ARG_NAMES = {
|
|
251
|
+
session: "sessionId",
|
|
252
|
+
scene: "sceneId",
|
|
253
|
+
};
|
|
254
|
+
/** The Zod field a path parameter contributes — always a required, non-empty id. */
|
|
255
|
+
const PATH_PARAM_FIELDS = {
|
|
256
|
+
session: z.string().min(1).describe("The session id to describe."),
|
|
257
|
+
scene: z.string().min(1).describe("The scene id to fetch."),
|
|
258
|
+
};
|
|
259
|
+
// ---------------------------------------------------------------------------
|
|
260
|
+
// Generation
|
|
261
|
+
// ---------------------------------------------------------------------------
|
|
262
|
+
/** The field a metric contributes for one filter: required where the route says so. */
|
|
263
|
+
function filterField(metric, filter) {
|
|
264
|
+
if (REQUIRED_FILTERS[metric.id]?.includes(filter)) {
|
|
265
|
+
const required = REQUIRED_FILTER_FIELDS[filter];
|
|
266
|
+
if (!required)
|
|
267
|
+
throw new Error(`no required field defined for filter '${filter}'`);
|
|
268
|
+
return required;
|
|
269
|
+
}
|
|
270
|
+
return FILTER_FIELDS[filter];
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* The row schema a tool advertises, built from the registry's `row`.
|
|
274
|
+
*
|
|
275
|
+
* Two deliberate relaxations, both driven by what the collector really returns:
|
|
276
|
+
*
|
|
277
|
+
* - **Every column is nullable.** An aggregate over a range with no matching
|
|
278
|
+
* samples projects SQL `NULL` for its measures (`resource_summary`,
|
|
279
|
+
* `perf_churn`, … over an empty window). The registry's row schema describes
|
|
280
|
+
* the populated shape; a consumer that validates the advertised JSON Schema
|
|
281
|
+
* strictly — the MCP SDK's client does, with Ajv — would otherwise reject a
|
|
282
|
+
* perfectly ordinary "no data yet" answer. The column set and its types stay
|
|
283
|
+
* exactly as the registry declares them.
|
|
284
|
+
* - **Unknown columns are kept.** A few routes add a field of their own on top
|
|
285
|
+
* of the aggregation (the `*_stats` endpoints echo the resolved `cellSize`),
|
|
286
|
+
* and dropping it silently would be worse than passing it through.
|
|
287
|
+
*
|
|
288
|
+
* The schema still *coerces*: `@uptimizr/db` declares numeric columns with
|
|
289
|
+
* `z.coerce.number()` because ClickHouse renders 64-bit integers as strings over
|
|
290
|
+
* HTTP, so parsing a result with this schema normalises those strings to JSON
|
|
291
|
+
* numbers (ADR 0051 §2). `@uptimizr/mcp` parses with it before sending
|
|
292
|
+
* `structuredContent`, which is what makes the advertised schema true on every
|
|
293
|
+
* store engine.
|
|
294
|
+
*/
|
|
295
|
+
function outputRowSchema(metric) {
|
|
296
|
+
const shape = {};
|
|
297
|
+
for (const [column, field] of Object.entries(metric.row.shape)) {
|
|
298
|
+
shape[column] = field.nullable();
|
|
299
|
+
}
|
|
300
|
+
return z.looseObject(shape);
|
|
301
|
+
}
|
|
302
|
+
/** `[":id"]` → the ordered `:param` placeholders of a Fastify path. */
|
|
303
|
+
function pathPlaceholders(path) {
|
|
304
|
+
return path
|
|
305
|
+
.split("/")
|
|
306
|
+
.filter((segment) => segment.startsWith(":"))
|
|
307
|
+
.map((segment) => segment.slice(1));
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Compose the agent-facing tool description: what the metric measures, how to
|
|
311
|
+
* read the result, and the caveats that decide how far to trust it. All three
|
|
312
|
+
* come from the registry, so the prose an agent sees and the prose the docs and
|
|
313
|
+
* the capabilities resource show are the same text.
|
|
314
|
+
*/
|
|
315
|
+
export function describeMetric(metric) {
|
|
316
|
+
const caveats = metric.caveats.map((caveat) => `- ${caveat}`).join("\n");
|
|
317
|
+
return (`${metric.description}\n\n` +
|
|
318
|
+
`How to read it: ${metric.interpretation}\n\n` +
|
|
319
|
+
`Caveats:\n${caveats}`);
|
|
320
|
+
}
|
|
321
|
+
/** The value a validated argument contributes to the collector querystring. */
|
|
322
|
+
function toQueryValue(value) {
|
|
323
|
+
if (value == null)
|
|
324
|
+
return undefined;
|
|
325
|
+
if (typeof value === "number" || typeof value === "string")
|
|
326
|
+
return value;
|
|
327
|
+
// `groupByOrigin` is a boolean in the tool schema and `"true"`/`"false"` on
|
|
328
|
+
// the wire (the collector's querystring enum).
|
|
329
|
+
if (typeof value === "boolean")
|
|
330
|
+
return String(value);
|
|
331
|
+
return undefined;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Build the {@link ReadTool} for one registry metric. Returns `undefined` for a
|
|
335
|
+
* metric with no collector endpoint (the two daily rollups), which therefore
|
|
336
|
+
* cannot be called by an agent.
|
|
337
|
+
*/
|
|
338
|
+
export function metricToTool(metric) {
|
|
339
|
+
const endpoint = metric.endpoint;
|
|
340
|
+
if (!endpoint)
|
|
341
|
+
return undefined;
|
|
342
|
+
const pathParams = endpoint.pathParams ?? [];
|
|
343
|
+
const placeholders = pathPlaceholders(endpoint.path);
|
|
344
|
+
if (placeholders.length !== pathParams.length) {
|
|
345
|
+
throw new Error(`metric ${metric.id}: endpoint path has ${placeholders.length} path parameter(s) but ` +
|
|
346
|
+
`${pathParams.length} are declared`);
|
|
347
|
+
}
|
|
348
|
+
// `:param` placeholder (positional) → the tool argument that fills it.
|
|
349
|
+
const pathArgs = placeholders.map((placeholder, index) => {
|
|
350
|
+
const filter = pathParams[index];
|
|
351
|
+
const argName = PATH_PARAM_ARG_NAMES[filter];
|
|
352
|
+
const field = PATH_PARAM_FIELDS[filter];
|
|
353
|
+
if (!argName || !field) {
|
|
354
|
+
throw new Error(`metric ${metric.id}: no tool argument defined for path filter '${filter}'`);
|
|
355
|
+
}
|
|
356
|
+
return { placeholder, argName, field };
|
|
357
|
+
});
|
|
358
|
+
const inputSchema = {};
|
|
359
|
+
for (const { argName, field } of pathArgs)
|
|
360
|
+
inputSchema[argName] = field;
|
|
361
|
+
for (const filter of metric.filters)
|
|
362
|
+
inputSchema[filter] = filterField(metric, filter);
|
|
363
|
+
// Every row of the collector's response, in one bounded envelope. A single
|
|
364
|
+
// object result (a session descriptor, a one-row summary) is reported as a
|
|
365
|
+
// one-element `rows` array so the envelope is the same for every tool.
|
|
366
|
+
const outputSchema = {
|
|
367
|
+
rows: z
|
|
368
|
+
.array(outputRowSchema(metric))
|
|
369
|
+
.describe(`Result rows (one row per ${metric.grain}). A column is null when it has no data.`),
|
|
370
|
+
};
|
|
371
|
+
// The collector client strips a leading slash; keep paths root-relative so a
|
|
372
|
+
// tool's `path` reads the same as it always has (`api/v1/...`).
|
|
373
|
+
const template = endpoint.path.replace(/^\//, "");
|
|
374
|
+
return {
|
|
375
|
+
name: metric.id,
|
|
376
|
+
title: metric.title,
|
|
377
|
+
description: describeMetric(metric),
|
|
378
|
+
inputSchema,
|
|
379
|
+
outputSchema,
|
|
380
|
+
buildRequest: (args) => {
|
|
381
|
+
let path = template;
|
|
382
|
+
for (const { placeholder, argName } of pathArgs) {
|
|
383
|
+
const raw = args[argName];
|
|
384
|
+
path = path.replace(`:${placeholder}`, encodeURIComponent(typeof raw === "string" ? raw : ""));
|
|
385
|
+
}
|
|
386
|
+
const params = {};
|
|
387
|
+
for (const filter of metric.filters)
|
|
388
|
+
params[filter] = toQueryValue(args[filter]);
|
|
389
|
+
return { path, params };
|
|
390
|
+
},
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Generate the read-only tool catalog from the metric registry: one tool per
|
|
395
|
+
* registry entry that has a collector endpoint, in registry declaration order.
|
|
396
|
+
*
|
|
397
|
+
* Pure — it reads definitions only and never touches a collector — so the whole
|
|
398
|
+
* catalog is unit-testable without a live server.
|
|
399
|
+
*/
|
|
400
|
+
export function registryToTools(metrics = allMetrics()) {
|
|
401
|
+
const tools = [];
|
|
402
|
+
for (const metric of metrics) {
|
|
403
|
+
const tool = metricToTool(metric);
|
|
404
|
+
if (tool)
|
|
405
|
+
tools.push(tool);
|
|
406
|
+
}
|
|
407
|
+
return tools;
|
|
408
|
+
}
|
|
409
|
+
//# sourceMappingURL=registryTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registryTools.js","sourceRoot":"","sources":["../src/registryTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAwC,MAAM,mBAAmB,CAAC;AAIrF,8EAA8E;AAC9E,+BAA+B;AAC/B,8EAA8E;AAC9E,EAAE;AACF,8EAA8E;AAC9E,gFAAgF;AAChF,kDAAkD;AAClD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;AAChF,+EAA+E;AAC/E,+EAA+E;AAC/E,wEAAwE;AACxE,gFAAgF;AAChF,sDAAsD;AAEtD,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,8CAA8C,CAAC,CAAC;AACnG,MAAM,KAAK,GAAG,CAAC,CAA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AAM,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YACjF,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC1B,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,UAAuC,UAAU,EAAE;IAEnD,MAAM,KAAK,GAAe,EAAE,CAAC;IAC7B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,IAAI;YAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
1
|
+
import type { z } from "zod";
|
|
2
2
|
import type { QueryParams } from "./client.js";
|
|
3
3
|
/** A resolved read request: the collector path and its query parameters. */
|
|
4
4
|
export interface ReadToolRequest {
|
|
@@ -16,22 +16,46 @@ export interface ReadTool {
|
|
|
16
16
|
title: string;
|
|
17
17
|
description: string;
|
|
18
18
|
inputSchema: z.ZodRawShape;
|
|
19
|
+
/**
|
|
20
|
+
* Zod raw shape describing what the tool **returns**, derived from the metric
|
|
21
|
+
* registry's `row` schema (ADR 0051 §1). It is always the single-key envelope
|
|
22
|
+
* `{ rows: Row[] }`: a single-object result (a session descriptor, a one-row
|
|
23
|
+
* summary) is reported as a one-element array so every tool has the same
|
|
24
|
+
* shape. Consumers that speak MCP register it as the tool's `outputSchema`
|
|
25
|
+
* and return matching `structuredContent`; consumers that do not can ignore
|
|
26
|
+
* it. Optional so a hand-built tool stays valid.
|
|
27
|
+
*/
|
|
28
|
+
outputSchema?: z.ZodRawShape;
|
|
19
29
|
buildRequest: (args: Record<string, unknown>) => ReadToolRequest;
|
|
20
30
|
}
|
|
21
31
|
/**
|
|
22
|
-
* The catalog of read-only tools
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
32
|
+
* The catalog of read-only tools — one per metric in the `@uptimizr/db`
|
|
33
|
+
* **semantic metric registry** that the collector serves on an endpoint
|
|
34
|
+
* (ADR 0051 §1, design sketch §A.2). It is **generated**, not hand-written: a
|
|
35
|
+
* new aggregation reaches agents by getting a registry entry, and there is no
|
|
36
|
+
* second list to keep in step. See `registryTools.ts` for how each field is
|
|
37
|
+
* derived.
|
|
38
|
+
*
|
|
39
|
+
* Every tool wraps one documented collector query endpoint (docs/integration.md
|
|
40
|
+
* §Query). There are intentionally **no** ingestion, mutation, or raw
|
|
41
|
+
* per-session event tools — the surface is aggregate, read-only, and
|
|
42
|
+
* privacy-preserving (ADR 0003 / ADR 0017); the registry's two builder-less
|
|
43
|
+
* resource entries (`session_meta`, `scene_representation`) are coarse
|
|
44
|
+
* descriptors, never an event stream.
|
|
45
|
+
*
|
|
46
|
+
* The 20 tool names the hand-written catalog shipped are registry ids verbatim
|
|
47
|
+
* and their argument schemas are unchanged — `__tests__/shippedToolCompat.test.ts`
|
|
48
|
+
* pins that against a frozen fixture, so an MCP client written against the old
|
|
49
|
+
* catalog keeps working.
|
|
26
50
|
*/
|
|
27
51
|
export declare const readTools: readonly ReadTool[];
|
|
28
52
|
/**
|
|
29
53
|
* Names of the **core** read tools — a small, single-step-friendly subset of
|
|
30
54
|
* {@link readTools} for small local models (ADR 0050). A 4-bit 7–8B model folds
|
|
31
|
-
* every tool schema into its function-calling system prompt, so sending
|
|
32
|
-
* overwhelms it and degrades selection even for simple questions.
|
|
33
|
-
* covers the most common single-metric questions (recent sessions,
|
|
34
|
-
* scenes, top meshes, FPS, event counts, event volume over time, and one
|
|
55
|
+
* every tool schema into its function-calling system prompt, so sending the
|
|
56
|
+
* whole catalog overwhelms it and degrades selection even for simple questions.
|
|
57
|
+
* This subset covers the most common single-metric questions (recent sessions,
|
|
58
|
+
* active scenes, top meshes, FPS, event counts, event volume over time, and one
|
|
35
59
|
* view-direction heatmap).
|
|
36
60
|
*
|
|
37
61
|
* Plain string membership only — used to FILTER {@link readTools} below, never to
|
|
@@ -51,4 +75,15 @@ export type ReadToolSetKind = "core" | "full";
|
|
|
51
75
|
* catalog. Both are views of the same single tool definitions.
|
|
52
76
|
*/
|
|
53
77
|
export declare function selectReadTools(kind: ReadToolSetKind): readonly ReadTool[];
|
|
78
|
+
/**
|
|
79
|
+
* Narrow the catalog to a caller-supplied set of tool names, preserving catalog
|
|
80
|
+
* order and identity. Unknown names are ignored, so a host app that pins a tool
|
|
81
|
+
* list cannot break when the registry renames or retires a metric — check the
|
|
82
|
+
* result's length if that matters to you.
|
|
83
|
+
*
|
|
84
|
+
* Use it when a model's context budget or a product decision calls for a
|
|
85
|
+
* deliberate subset (see {@link coreReadTools} for the built-in small-model one)
|
|
86
|
+
* rather than the full ~69-tool surface.
|
|
87
|
+
*/
|
|
88
|
+
export declare function filterReadTools(names: readonly string[]): readonly ReadTool[];
|
|
54
89
|
//# sourceMappingURL=tools.d.ts.map
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd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