@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/dist/tools.js CHANGED
@@ -1,336 +1,32 @@
1
- import { z } from "zod";
2
- const num = (v) => (typeof v === "number" ? v : undefined);
3
- const str = (v) => (typeof v === "string" ? v : undefined);
4
- // Shared, reusable input fields (all optional unless a tool needs otherwise).
5
- const since = z.number().int().optional().describe("Start of the time range, epoch milliseconds.");
6
- const until = z.number().int().optional().describe("End of the time range, epoch milliseconds.");
7
- const bins = z.number().int().positive().max(500).optional().describe("Grid resolution per axis.");
8
- const limit = z.number().int().positive().max(1000).optional().describe("Maximum rows to return.");
9
- const scene = z.string().optional().describe("Restrict to one developer-assigned scene id.");
10
- const session = z.string().optional().describe("Scope the aggregate to a single session id.");
11
- const cellSize = z.number().positive().max(1000).optional().describe("Voxel size in world units.");
12
- const interval = z
13
- .number()
14
- .int()
15
- .positive()
16
- .optional()
17
- .describe("Time-series bucket width, seconds.");
18
- const eventType = z
19
- .string()
20
- .optional()
21
- .describe("Restrict to a single event type, e.g. pointer_click.");
22
- const source = z
23
- .enum(["mouse", "touch", "stylus", "pen", "xr-controller", "hand", "gaze", "transient", "other"])
24
- .optional()
25
- .describe("Restrict a pointer/world heatmap to one input source.");
26
- const cameraMode = z
27
- .enum(["viewer", "first-person"])
28
- .optional()
29
- .describe("Camera navigation mode to scope to: 'viewer' (orbit) or 'first-person' (walkable).");
30
- const rapidTurn = z
31
- .number()
32
- .nonnegative()
33
- .max(Math.PI)
34
- .optional()
35
- .describe("Rapid-turn threshold in radians (0..π); view turns above this flag motion-sickness risk.");
36
- const steps = z
37
- .string()
38
- .min(1)
39
- .describe("Funnel steps as a JSON-encoded array of ordered step predicates (ADR 0038). Required. " +
40
- 'Each step is `{ "type": <event_type>, ... }`; e.g. ' +
41
- '`[{"type":"scene_change","to":"lobby"},{"type":"mesh_interaction","mesh":"buy"}]`.');
42
- /** Build the common `{ since, until }` range params from validated args. */
43
- function range(args) {
44
- return { since: num(args.since), until: num(args.until) };
45
- }
1
+ import { registryToTools } from "./registryTools.js";
46
2
  /**
47
- * The catalog of read-only tools. Each wraps one documented collector query
48
- * endpoint (docs/integration.md §Query). There are intentionally **no**
49
- * ingestion, mutation, or raw per-session event tools the surface is
50
- * aggregate, read-only, and privacy-preserving (ADR 0003 / ADR 0017).
3
+ * The catalog of read-only tools one per metric in the `@uptimizr/db`
4
+ * **semantic metric registry** that the collector serves on an endpoint
5
+ * (ADR 0051 §1, design sketch §A.2). It is **generated**, not hand-written: a
6
+ * new aggregation reaches agents by getting a registry entry, and there is no
7
+ * second list to keep in step. See `registryTools.ts` for how each field is
8
+ * derived.
9
+ *
10
+ * Every tool wraps one documented collector query endpoint (docs/integration.md
11
+ * §Query). There are intentionally **no** ingestion, mutation, or raw
12
+ * per-session event tools — the surface is aggregate, read-only, and
13
+ * privacy-preserving (ADR 0003 / ADR 0017); the registry's two builder-less
14
+ * resource entries (`session_meta`, `scene_representation`) are coarse
15
+ * descriptors, never an event stream.
16
+ *
17
+ * The 20 tool names the hand-written catalog shipped are registry ids verbatim
18
+ * and their argument schemas are unchanged — `__tests__/shippedToolCompat.test.ts`
19
+ * pins that against a frozen fixture, so an MCP client written against the old
20
+ * catalog keeps working.
51
21
  */
52
- export const readTools = [
53
- {
54
- name: "list_sessions",
55
- title: "List recent sessions",
56
- description: "Recent sessions with id, visitor, event count, and start/end times.",
57
- inputSchema: { since, until, limit },
58
- buildRequest: (args) => ({
59
- path: "api/v1/sessions",
60
- params: { ...range(args), limit: num(args.limit) },
61
- }),
62
- },
63
- {
64
- name: "pointer_heatmap",
65
- title: "2D pointer heatmap",
66
- description: "Binned 2D pointer-position heatmap (screen-normalized).",
67
- inputSchema: { since, until, bins, scene, source, session },
68
- buildRequest: (args) => ({
69
- path: "api/v1/heatmaps/pointer",
70
- params: {
71
- ...range(args),
72
- bins: num(args.bins),
73
- scene: str(args.scene),
74
- source: str(args.source),
75
- session: str(args.session),
76
- },
77
- }),
78
- },
79
- {
80
- name: "world_heatmap",
81
- title: "3D world-space pointer heatmap",
82
- description: "Voxelized world-space pointer heatmap.",
83
- inputSchema: { since, until, cellSize, limit, scene, source },
84
- buildRequest: (args) => ({
85
- path: "api/v1/heatmaps/world",
86
- params: {
87
- ...range(args),
88
- cellSize: num(args.cellSize),
89
- limit: num(args.limit),
90
- scene: str(args.scene),
91
- source: str(args.source),
92
- },
93
- }),
94
- },
95
- {
96
- name: "camera_heatmap",
97
- title: "View-direction heatmap",
98
- description: "Camera view-direction distribution as spherical bins.",
99
- inputSchema: { since, until, bins, scene, session },
100
- buildRequest: (args) => ({
101
- path: "api/v1/heatmaps/camera",
102
- params: {
103
- ...range(args),
104
- bins: num(args.bins),
105
- scene: str(args.scene),
106
- session: str(args.session),
107
- },
108
- }),
109
- },
110
- {
111
- name: "click_rays",
112
- title: "View-gated click rays",
113
- description: "Clicks ASOF-joined to their nearest camera sample, per voxel and clicked mesh.",
114
- inputSchema: { since, until, cellSize, limit, scene, source, session },
115
- buildRequest: (args) => ({
116
- path: "api/v1/heatmaps/click-rays",
117
- params: {
118
- ...range(args),
119
- cellSize: num(args.cellSize),
120
- limit: num(args.limit),
121
- scene: str(args.scene),
122
- source: str(args.source),
123
- session: str(args.session),
124
- },
125
- }),
126
- },
127
- {
128
- name: "flow_links",
129
- title: "Gaze→mesh flow links",
130
- description: "Aggregate links from camera-direction bins to clicked meshes.",
131
- inputSchema: { since, until, bins, limit, scene, session },
132
- buildRequest: (args) => ({
133
- path: "api/v1/heatmaps/flow",
134
- params: {
135
- ...range(args),
136
- bins: num(args.bins),
137
- limit: num(args.limit),
138
- scene: str(args.scene),
139
- session: str(args.session),
140
- },
141
- }),
142
- },
143
- {
144
- name: "top_meshes",
145
- title: "Most-interacted meshes",
146
- description: "Meshes ranked by interaction count.",
147
- inputSchema: { since, until, limit, session },
148
- buildRequest: (args) => ({
149
- path: "api/v1/meshes/top",
150
- params: { ...range(args), limit: num(args.limit), session: str(args.session) },
151
- }),
152
- },
153
- {
154
- name: "perf_summary",
155
- title: "Rendering performance summary",
156
- description: "Sample count and avg/min/p50 FPS over the range.",
157
- inputSchema: { since, until, session },
158
- buildRequest: (args) => ({
159
- path: "api/v1/perf",
160
- params: { ...range(args), session: str(args.session) },
161
- }),
162
- },
163
- {
164
- name: "list_scenes",
165
- title: "List active scenes",
166
- description: "Distinct developer-assigned scenes with activity.",
167
- inputSchema: { since, until, limit },
168
- buildRequest: (args) => ({
169
- path: "api/v1/scenes",
170
- params: { ...range(args), limit: num(args.limit) },
171
- }),
172
- },
173
- {
174
- name: "timeseries",
175
- title: "Event-volume time series",
176
- description: "Event-volume buckets over time, with average FPS per bucket.",
177
- inputSchema: { since, until, interval, scene, type: eventType },
178
- buildRequest: (args) => ({
179
- path: "api/v1/timeseries",
180
- params: {
181
- ...range(args),
182
- interval: num(args.interval),
183
- scene: str(args.scene),
184
- type: str(args.type),
185
- },
186
- }),
187
- },
188
- {
189
- name: "event_counts",
190
- title: "Per-event-type counts",
191
- description: "Counts per event type over the range (scene-health panel).",
192
- inputSchema: { since, until, scene },
193
- buildRequest: (args) => ({
194
- path: "api/v1/event-counts",
195
- params: { ...range(args), scene: str(args.scene) },
196
- }),
197
- },
198
- {
199
- name: "session_meta",
200
- title: "Session descriptor",
201
- description: "Coarse descriptor for one session (device/scene/user). No raw event stream.",
202
- inputSchema: { sessionId: z.string().min(1).describe("The session id to describe.") },
203
- buildRequest: (args) => ({
204
- path: `api/v1/sessions/${encodeURIComponent(str(args.sessionId) ?? "")}/meta`,
205
- params: {},
206
- }),
207
- },
208
- {
209
- name: "scene_representation",
210
- title: "Scene representation",
211
- description: "Registered proxy geometry (bounds/meshes) for one scene, if any.",
212
- inputSchema: { sceneId: z.string().min(1).describe("The scene id to fetch.") },
213
- buildRequest: (args) => ({
214
- path: `api/v1/scenes/${encodeURIComponent(str(args.sceneId) ?? "")}/representation`,
215
- params: {},
216
- }),
217
- },
218
- {
219
- name: "funnel",
220
- title: "Conversion funnel",
221
- description: "Ordered, per-session conversion funnel (ADR 0038): how many sessions reach each " +
222
- "caller-supplied step. Steps are a JSON array (see the `steps` argument).",
223
- inputSchema: { since, until, scene, cameraMode, steps },
224
- buildRequest: (args) => ({
225
- path: "api/v1/funnel",
226
- params: {
227
- ...range(args),
228
- scene: str(args.scene),
229
- cameraMode: str(args.cameraMode),
230
- steps: str(args.steps),
231
- },
232
- }),
233
- },
234
- {
235
- name: "aggregate_paths",
236
- title: "Aggregate desire-line paths",
237
- description: "Crowd-level movement routes (ADR 0037): every session's camera path binned onto the " +
238
- "ground grid and returned as ordered, session-keyed points for an overlaid route map.",
239
- inputSchema: { since, until, cellSize, limit, scene, cameraMode },
240
- buildRequest: (args) => ({
241
- path: "api/v1/paths",
242
- params: {
243
- ...range(args),
244
- cellSize: num(args.cellSize),
245
- limit: num(args.limit),
246
- scene: str(args.scene),
247
- cameraMode: str(args.cameraMode),
248
- },
249
- }),
250
- },
251
- {
252
- name: "rendering_technology",
253
- title: "Rendering-technology breakdown",
254
- description: "Rendering-technology mix from session_start.graphics (ADR 0046): session count per " +
255
- "(api, backend, api_version, shading_language) — WebGPU vs WebGL2 and shading language.",
256
- inputSchema: { since, until, scene, session },
257
- buildRequest: (args) => ({
258
- path: "api/v1/rendering-technology",
259
- params: { ...range(args), scene: str(args.scene), session: str(args.session) },
260
- }),
261
- },
262
- {
263
- name: "xr_rotation",
264
- title: "XR head-rotation rate",
265
- description: "XR head/view rotation rate (ADR 0048), a motion-sickness proxy: per-session rapid-turn " +
266
- "counts over the camera pose stream.",
267
- inputSchema: { since, until, rapidTurn, limit, scene, session },
268
- buildRequest: (args) => ({
269
- path: "api/v1/xr/rotation",
270
- params: {
271
- ...range(args),
272
- rapidTurn: num(args.rapidTurn),
273
- limit: num(args.limit),
274
- scene: str(args.scene),
275
- session: str(args.session),
276
- },
277
- }),
278
- },
279
- {
280
- name: "xr_sources",
281
- title: "XR input-source usage",
282
- description: "XR input-source split (ADR 0048): hand vs. controller vs. gaze usage.",
283
- inputSchema: { since, until, limit, scene, session },
284
- buildRequest: (args) => ({
285
- path: "api/v1/xr/sources",
286
- params: {
287
- ...range(args),
288
- limit: num(args.limit),
289
- scene: str(args.scene),
290
- session: str(args.session),
291
- },
292
- }),
293
- },
294
- {
295
- name: "xr_abandonment",
296
- title: "XR session abandonment",
297
- description: "XR session abandonment (ADR 0048): per XR session, its time bounds and event/interaction " +
298
- "counts; a short span signals headset drop-off.",
299
- inputSchema: { since, until, limit, scene, session },
300
- buildRequest: (args) => ({
301
- path: "api/v1/xr/abandonment",
302
- params: {
303
- ...range(args),
304
- limit: num(args.limit),
305
- scene: str(args.scene),
306
- session: str(args.session),
307
- },
308
- }),
309
- },
310
- {
311
- name: "xr_locomotion",
312
- title: "XR locomotion & comfort",
313
- description: "XR locomotion & comfort (ADR 0048): per XR session, its locomotion-style mix " +
314
- "(fly / navigate / teleport + duration) and wall-clock span — a discomfort proxy.",
315
- inputSchema: { since, until, limit, scene, session },
316
- buildRequest: (args) => ({
317
- path: "api/v1/xr/locomotion",
318
- params: {
319
- ...range(args),
320
- limit: num(args.limit),
321
- scene: str(args.scene),
322
- session: str(args.session),
323
- },
324
- }),
325
- },
326
- ];
22
+ export const readTools = registryToTools();
327
23
  /**
328
24
  * Names of the **core** read tools — a small, single-step-friendly subset of
329
25
  * {@link readTools} for small local models (ADR 0050). A 4-bit 7–8B model folds
330
- * every tool schema into its function-calling system prompt, so sending all 20
331
- * overwhelms it and degrades selection even for simple questions. This subset
332
- * covers the most common single-metric questions (recent sessions, active
333
- * scenes, top meshes, FPS, event counts, event volume over time, and one
26
+ * every tool schema into its function-calling system prompt, so sending the
27
+ * whole catalog overwhelms it and degrades selection even for simple questions.
28
+ * This subset covers the most common single-metric questions (recent sessions,
29
+ * active scenes, top meshes, FPS, event counts, event volume over time, and one
334
30
  * view-direction heatmap).
335
31
  *
336
32
  * Plain string membership only — used to FILTER {@link readTools} below, never to
@@ -358,4 +54,18 @@ export const coreReadTools = readTools.filter((tool) => CORE_READ_TOOL_NAMES.inc
358
54
  export function selectReadTools(kind) {
359
55
  return kind === "core" ? coreReadTools : readTools;
360
56
  }
57
+ /**
58
+ * Narrow the catalog to a caller-supplied set of tool names, preserving catalog
59
+ * order and identity. Unknown names are ignored, so a host app that pins a tool
60
+ * list cannot break when the registry renames or retires a metric — check the
61
+ * result's length if that matters to you.
62
+ *
63
+ * Use it when a model's context budget or a product decision calls for a
64
+ * deliberate subset (see {@link coreReadTools} for the built-in small-model one)
65
+ * rather than the full ~69-tool surface.
66
+ */
67
+ export function filterReadTools(names) {
68
+ const wanted = new Set(names);
69
+ return readTools.filter((tool) => wanted.has(tool.name));
70
+ }
361
71
  //# sourceMappingURL=tools.js.map
package/dist/tools.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAuBxB,MAAM,GAAG,GAAG,CAAC,CAAU,EAAsB,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AACxF,MAAM,GAAG,GAAG,CAAC,CAAU,EAAsB,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAExF,8EAA8E;AAC9E,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,8CAA8C,CAAC,CAAC;AACnG,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,4CAA4C,CAAC,CAAC;AACjG,MAAM,IAAI,GAAG,CAAC,CAAC,M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CAAC,CAAC,IAAI,EAAE,EAAE,CAC1E,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CACzC,CAAC;AAKF;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAAqB;IACnD,OAAO,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC;AACrD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,KAAwB;IACtD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAC9B,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3D,CAAC"}
package/llms.txt CHANGED
@@ -11,9 +11,57 @@
11
11
  - [Integration & API reference](https://github.com/RaananW/Uptimizr/blob/main/docs/integration.md): the underlying query endpoints.
12
12
  - [Architecture Decision Records](https://github.com/RaananW/Uptimizr/tree/main/docs/adr): in-browser assistant (0050), privacy model (0003), thin backends (0005), consumer-facing agents (0017).
13
13
 
14
+ ## Tools (read-only)
15
+
16
+ <!-- generated:registry-tool-names:start — generated by `pnpm gen:docs`; edit the metric registry, not this list -->
17
+
18
+ `list_sessions`, `session_meta`, `scene_representation`, `list_scenes`, `timeseries`,
19
+ `event_counts`, `pointer_heatmap`, `mesh_uv_heatmap`, `world_heatmap`, `world_heatmap_stats`,
20
+ `gaze_heatmap`, `gaze_heatmap_stats`, `camera_heatmap`, `view_coverage_histogram`,
21
+ `position_heatmap`, `session_trajectory`, `aggregate_paths`, `scene_coverage`, `camera_distance`,
22
+ `click_rays`, `flow_links`, `top_meshes`, `mesh_sources`, `mesh_trend`, `mesh_dwell`,
23
+ `mesh_blind_spots`, `mesh_interaction_kinds`, `mesh_reachability`, `dead_clicks`, `rage_clicks`,
24
+ `hover_dwell`, `interaction_sources`, `top_input_actions`, `camera_gestures`, `navigation_stats`,
25
+ `backtrack_ratio`, `perf_summary`, `render_scale_truth`, `perf_distribution`, `fps_histogram`,
26
+ `frame_time_percentiles`, `jank_rate`, `perf_churn`, `perf_by_device`, `perf_by_scene`,
27
+ `perf_heatmap`, `compile_stalls`, `resource_summary`, `resource_percentiles`, `stability_counts`,
28
+ `graphics_diagnostics`, `error_heatmap`, `rendering_technology`, `capability_changes`,
29
+ `xr_rotation`, `xr_sources`, `xr_abandonment`, `xr_locomotion`, `xr_tracking_quality`,
30
+ `boundary_heatmap`, `boundary_heatmap_stats`, `xr_boundary_contacts`,
31
+ `ar_placement_time_to_place`, `ar_placement_attempts`, `ar_placement_surfaces`, `funnel`,
32
+ `scene_retention`, `load_bounce_funnel`, `variant_leaderboard`
33
+
34
+ <!-- generated:registry-tool-names:end -->
35
+
36
+ ## Result formats (`format`)
37
+
38
+ Every aggregate tool declares a `format` argument — the envelope its rows arrive in, not a filter
39
+ (ADR 0051 §2).
40
+
41
+ - `summary` — **prefer this whenever a model reads the result.** A bounded digest: `ranked` top
42
+ rows, a `series` trend, merged spatial `clusters`, or a single `record`, with shares, a sample
43
+ size, the metric's `caveats` and a templated `reading` sentence. Capped at the metric's
44
+ `limits.maxSummaryRows`, so a 500-bin heatmap costs the same as a 5-bin one — which is what keeps
45
+ one heatmap from filling a small local model's whole context.
46
+ - `table` — `{ meta, rows }`: every row plus the metric, range, applied filters, sample size, row
47
+ count, a truncation flag and the registry limits.
48
+ - `full` — the bare rows. Today's default, so existing consumers such as the dashboard are
49
+ unaffected; pass `format` explicitly from an agent path.
50
+
51
+ `reading` and `caveats` are templated by pure code, never a model, so identical rows always produce
52
+ identical words. Shares appear only where the measure can honestly be summed (an FPS or ratio metric
53
+ reports `total: null` and no shares). Cluster coordinates are grid indices — multiply by the
54
+ effective `cellSize` for world space. `session_meta` and `scene_representation` are stored records,
55
+ not aggregations, and declare no `format`.
56
+
14
57
  ## Key exports
15
58
 
16
- - `readTools` — the read-only tool catalog (one entry per query endpoint).
59
+ - `readTools` — the read-only tool catalog (one entry per query endpoint), generated from the
60
+ `@uptimizr/metrics` metric registry: 69 tools, each with an input schema, an output schema and the
61
+ metric's interpretation notes and caveats in its description (ADR 0051).
62
+ - `coreReadTools` / `selectReadTools(kind)` / `filterReadTools(names)` — narrowed views of the
63
+ catalog for models that cannot carry every tool schema.
64
+ - `registryToTools(metrics?)` — generate the catalog from metric-registry definitions.
17
65
  - `createCollectorClient(config)` — the thin GET-only collector client.
18
66
  - `runAgent(options)` — the headless tool-calling loop (LLM ↔ tools ↔ collector).
19
67
  - `toToolSchemas(tools?)` — convert catalog tools to JSON-Schema tool descriptors for an LLM.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uptimizr/agent-core",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "description": "Framework-agnostic, browser-safe core for Uptimizr analytics agents — the single read-only tool catalog over the collector query API, a headless LLM provider-adapter interface, and the tool-calling loop.",
5
5
  "keywords": [
6
6
  "uptimizr",
@@ -58,7 +58,8 @@
58
58
  ],
59
59
  "sideEffects": false,
60
60
  "dependencies": {
61
- "zod": "^4.5.4"
61
+ "zod": "^4.5.4",
62
+ "@uptimizr/metrics": "0.1.0"
62
63
  },
63
64
  "peerDependencies": {
64
65
  "@mlc-ai/web-llm": "^0.2.0"
@@ -70,6 +71,7 @@
70
71
  },
71
72
  "devDependencies": {
72
73
  "@mlc-ai/web-llm": "^0.2.84",
74
+ "esbuild": "^0.28.2",
73
75
  "vitest": "^4.1.11"
74
76
  },
75
77
  "engines": {