@hazeljs/inspector 0.2.0-rc.5

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.
Files changed (75) hide show
  1. package/LICENSE +192 -0
  2. package/README.md +97 -0
  3. package/dist/config/inspector.config.d.ts +8 -0
  4. package/dist/config/inspector.config.d.ts.map +1 -0
  5. package/dist/config/inspector.config.js +38 -0
  6. package/dist/contracts/types.d.ts +253 -0
  7. package/dist/contracts/types.d.ts.map +1 -0
  8. package/dist/contracts/types.js +5 -0
  9. package/dist/index.d.ts +11 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +14 -0
  12. package/dist/inspector.module.d.ts +25 -0
  13. package/dist/inspector.module.d.ts.map +1 -0
  14. package/dist/inspector.module.js +489 -0
  15. package/dist/plugins/agent.inspector.d.ts +8 -0
  16. package/dist/plugins/agent.inspector.d.ts.map +1 -0
  17. package/dist/plugins/agent.inspector.js +51 -0
  18. package/dist/plugins/ai.inspector.d.ts +8 -0
  19. package/dist/plugins/ai.inspector.d.ts.map +1 -0
  20. package/dist/plugins/ai.inspector.js +87 -0
  21. package/dist/plugins/core.inspector.d.ts +8 -0
  22. package/dist/plugins/core.inspector.d.ts.map +1 -0
  23. package/dist/plugins/core.inspector.js +203 -0
  24. package/dist/plugins/cron.inspector.d.ts +8 -0
  25. package/dist/plugins/cron.inspector.d.ts.map +1 -0
  26. package/dist/plugins/cron.inspector.js +74 -0
  27. package/dist/plugins/data.inspector.d.ts +8 -0
  28. package/dist/plugins/data.inspector.d.ts.map +1 -0
  29. package/dist/plugins/data.inspector.js +50 -0
  30. package/dist/plugins/event-emitter.inspector.d.ts +8 -0
  31. package/dist/plugins/event-emitter.inspector.d.ts.map +1 -0
  32. package/dist/plugins/event-emitter.inspector.js +53 -0
  33. package/dist/plugins/flow.inspector.d.ts +8 -0
  34. package/dist/plugins/flow.inspector.d.ts.map +1 -0
  35. package/dist/plugins/flow.inspector.js +112 -0
  36. package/dist/plugins/graphql.inspector.d.ts +8 -0
  37. package/dist/plugins/graphql.inspector.d.ts.map +1 -0
  38. package/dist/plugins/graphql.inspector.js +75 -0
  39. package/dist/plugins/grpc.inspector.d.ts +8 -0
  40. package/dist/plugins/grpc.inspector.d.ts.map +1 -0
  41. package/dist/plugins/grpc.inspector.js +53 -0
  42. package/dist/plugins/kafka.inspector.d.ts +8 -0
  43. package/dist/plugins/kafka.inspector.d.ts.map +1 -0
  44. package/dist/plugins/kafka.inspector.js +59 -0
  45. package/dist/plugins/ml.inspector.d.ts +8 -0
  46. package/dist/plugins/ml.inspector.d.ts.map +1 -0
  47. package/dist/plugins/ml.inspector.js +78 -0
  48. package/dist/plugins/prompts.inspector.d.ts +7 -0
  49. package/dist/plugins/prompts.inspector.d.ts.map +1 -0
  50. package/dist/plugins/prompts.inspector.js +41 -0
  51. package/dist/plugins/queue.inspector.d.ts +8 -0
  52. package/dist/plugins/queue.inspector.d.ts.map +1 -0
  53. package/dist/plugins/queue.inspector.js +55 -0
  54. package/dist/plugins/rag.inspector.d.ts +8 -0
  55. package/dist/plugins/rag.inspector.d.ts.map +1 -0
  56. package/dist/plugins/rag.inspector.js +72 -0
  57. package/dist/plugins/serverless.inspector.d.ts +8 -0
  58. package/dist/plugins/serverless.inspector.d.ts.map +1 -0
  59. package/dist/plugins/serverless.inspector.js +53 -0
  60. package/dist/plugins/websocket.inspector.d.ts +8 -0
  61. package/dist/plugins/websocket.inspector.d.ts.map +1 -0
  62. package/dist/plugins/websocket.inspector.js +73 -0
  63. package/dist/registry/registry.d.ts +12 -0
  64. package/dist/registry/registry.d.ts.map +1 -0
  65. package/dist/registry/registry.js +43 -0
  66. package/dist/runtime/inspector-runtime.d.ts +66 -0
  67. package/dist/runtime/inspector-runtime.d.ts.map +1 -0
  68. package/dist/runtime/inspector-runtime.js +97 -0
  69. package/dist/service/inspector.service.d.ts +37 -0
  70. package/dist/service/inspector.service.d.ts.map +1 -0
  71. package/dist/service/inspector.service.js +146 -0
  72. package/package.json +124 -0
  73. package/ui-dist/assets/index-BN8Zr7QX.css +1 -0
  74. package/ui-dist/assets/index-DLS5TpZI.js +80 -0
  75. package/ui-dist/index.html +316 -0
@@ -0,0 +1,25 @@
1
+ /**
2
+ * InspectorModule - Registers inspector with HazelApp
3
+ */
4
+ import type { DynamicModule } from '@hazeljs/core';
5
+ import type { InspectorModuleOptions } from './contracts/types';
6
+ /**
7
+ * Add InspectorModule.forRoot() to your app imports to enable the inspector.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * @HazelModule({
12
+ * imports: [
13
+ * InspectorModule.forRoot({
14
+ * inspectorBasePath: '/__hazel',
15
+ * developmentOnly: true,
16
+ * }),
17
+ * ],
18
+ * })
19
+ * export class AppModule {}
20
+ * ```
21
+ */
22
+ export declare const InspectorModule: {
23
+ forRoot(options?: InspectorModuleOptions): DynamicModule;
24
+ };
25
+ //# sourceMappingURL=inspector.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspector.module.d.ts","sourceRoot":"","sources":["../src/inspector.module.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAoB,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AA4BlF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe;sBACR,sBAAsB,GAAG,aAAa;CA4CzD,CAAC"}
@@ -0,0 +1,489 @@
1
+ "use strict";
2
+ /**
3
+ * InspectorModule - Registers inspector with HazelApp
4
+ */
5
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
6
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
8
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+ var __metadata = (this && this.__metadata) || function (k, v) {
12
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
13
+ };
14
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
15
+ return function (target, key) { decorator(target, key, paramIndex); }
16
+ };
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.InspectorModule = void 0;
22
+ const fs_1 = __importDefault(require("fs"));
23
+ const path_1 = __importDefault(require("path"));
24
+ const core_1 = require("@hazeljs/core");
25
+ const registry_1 = require("./registry/registry");
26
+ const inspector_service_1 = require("./service/inspector.service");
27
+ const core_inspector_1 = require("./plugins/core.inspector");
28
+ const cron_inspector_1 = require("./plugins/cron.inspector");
29
+ const queue_inspector_1 = require("./plugins/queue.inspector");
30
+ const websocket_inspector_1 = require("./plugins/websocket.inspector");
31
+ const agent_inspector_1 = require("./plugins/agent.inspector");
32
+ const ai_inspector_1 = require("./plugins/ai.inspector");
33
+ const rag_inspector_1 = require("./plugins/rag.inspector");
34
+ const prompts_inspector_1 = require("./plugins/prompts.inspector");
35
+ const event_emitter_inspector_1 = require("./plugins/event-emitter.inspector");
36
+ const graphql_inspector_1 = require("./plugins/graphql.inspector");
37
+ const grpc_inspector_1 = require("./plugins/grpc.inspector");
38
+ const kafka_inspector_1 = require("./plugins/kafka.inspector");
39
+ const flow_inspector_1 = require("./plugins/flow.inspector");
40
+ const data_inspector_1 = require("./plugins/data.inspector");
41
+ const serverless_inspector_1 = require("./plugins/serverless.inspector");
42
+ const ml_inspector_1 = require("./plugins/ml.inspector");
43
+ const inspector_config_1 = require("./config/inspector.config");
44
+ const inspector_runtime_1 = require("./runtime/inspector-runtime");
45
+ /** Eagerly resolves InspectorBootstrap so the early handler gets registered */
46
+ let InspectorBootstrapClass = class InspectorBootstrapClass {
47
+ constructor(_result) { }
48
+ };
49
+ InspectorBootstrapClass = __decorate([
50
+ (0, core_1.Injectable)(),
51
+ __param(0, (0, core_1.Inject)('InspectorBootstrap')),
52
+ __metadata("design:paramtypes", [Object])
53
+ ], InspectorBootstrapClass);
54
+ /**
55
+ * Add InspectorModule.forRoot() to your app imports to enable the inspector.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * @HazelModule({
60
+ * imports: [
61
+ * InspectorModule.forRoot({
62
+ * inspectorBasePath: '/__hazel',
63
+ * developmentOnly: true,
64
+ * }),
65
+ * ],
66
+ * })
67
+ * export class AppModule {}
68
+ * ```
69
+ */
70
+ exports.InspectorModule = {
71
+ forRoot(options) {
72
+ const config = (0, inspector_config_1.mergeInspectorConfig)(options);
73
+ const inspectorProvider = {
74
+ provide: 'InspectorBootstrap',
75
+ useFactory: () => {
76
+ if (!(0, inspector_config_1.shouldExposeInspector)(config))
77
+ return null;
78
+ const container = core_1.Container.getInstance();
79
+ const app = container.resolve(core_1.HazelApp);
80
+ const registry = new registry_1.HazelInspectorRegistry();
81
+ const service = new inspector_service_1.HazelInspectorService(registry, config);
82
+ registry.register(core_inspector_1.coreInspector);
83
+ registry.register(cron_inspector_1.cronInspector);
84
+ registry.register(queue_inspector_1.queueInspector);
85
+ registry.register(websocket_inspector_1.websocketInspector);
86
+ registry.register(agent_inspector_1.agentInspector);
87
+ registry.register(ai_inspector_1.aiInspector);
88
+ registry.register(rag_inspector_1.ragInspector);
89
+ registry.register(prompts_inspector_1.promptsInspector);
90
+ registry.register(event_emitter_inspector_1.eventEmitterInspector);
91
+ registry.register(graphql_inspector_1.graphqlInspector);
92
+ registry.register(grpc_inspector_1.grpcInspector);
93
+ registry.register(kafka_inspector_1.kafkaInspector);
94
+ registry.register(flow_inspector_1.flowInspector);
95
+ registry.register(data_inspector_1.dataInspector);
96
+ registry.register(serverless_inspector_1.serverlessInspector);
97
+ registry.register(ml_inspector_1.mlInspector);
98
+ const basePath = config.inspectorBasePath ?? '/__hazel';
99
+ const handler = createInspectorHandler(service, config, app);
100
+ app.addEarlyHandler(basePath, handler);
101
+ return true;
102
+ },
103
+ inject: [],
104
+ };
105
+ return {
106
+ module: class InspectorRootModule {
107
+ },
108
+ providers: [inspectorProvider, InspectorBootstrapClass],
109
+ };
110
+ },
111
+ };
112
+ function readJsonBody(req) {
113
+ return new Promise((resolve, reject) => {
114
+ const chunks = [];
115
+ req.on('data', (chunk) => chunk && chunks.push(chunk));
116
+ req.on('end', () => {
117
+ try {
118
+ const raw = Buffer.concat(chunks).toString('utf8');
119
+ resolve(raw ? JSON.parse(raw) : {});
120
+ }
121
+ catch {
122
+ reject(new Error('Invalid JSON body'));
123
+ }
124
+ });
125
+ req.on('error', reject);
126
+ });
127
+ }
128
+ function createInspectorHandler(service, config, app) {
129
+ return async (req, res) => {
130
+ const url = req.url?.split('?')[0] ?? '/';
131
+ const basePath = config.inspectorBasePath ?? '/__hazel';
132
+ const pathSeg = url.replace(basePath, '') || '/';
133
+ try {
134
+ if (pathSeg === '/' || pathSeg === '') {
135
+ if (config.exposeUi) {
136
+ const uiPath = path_1.default.join(__dirname, '..', 'ui-dist', 'index.html');
137
+ if (fs_1.default.existsSync(uiPath)) {
138
+ res.setHeader('Content-Type', 'text/html');
139
+ res.writeHead(200);
140
+ res.end(fs_1.default.readFileSync(uiPath, 'utf-8'));
141
+ return;
142
+ }
143
+ }
144
+ }
145
+ if (config.exposeUi && pathSeg.startsWith('/assets/')) {
146
+ const assetPath = path_1.default.join(__dirname, '..', 'ui-dist', pathSeg);
147
+ if (fs_1.default.existsSync(assetPath) &&
148
+ assetPath.startsWith(path_1.default.join(__dirname, '..', 'ui-dist'))) {
149
+ const ext = path_1.default.extname(assetPath);
150
+ const types = {
151
+ '.js': 'application/javascript',
152
+ '.css': 'text/css',
153
+ };
154
+ res.setHeader('Content-Type', types[ext] ?? 'application/octet-stream');
155
+ res.writeHead(200);
156
+ res.end(fs_1.default.readFileSync(assetPath, 'utf-8'));
157
+ return;
158
+ }
159
+ }
160
+ if (pathSeg === '/stats' || pathSeg === '/stats/') {
161
+ const mem = process.memoryUsage();
162
+ const uptime = process.uptime();
163
+ res.setHeader('Content-Type', 'application/json');
164
+ res.writeHead(200);
165
+ res.end(JSON.stringify({
166
+ memory: { rss: mem.rss, heapUsed: mem.heapUsed, heapTotal: mem.heapTotal },
167
+ uptimeSeconds: Math.floor(uptime),
168
+ nodeVersion: process.version,
169
+ nodeEnv: process.env.NODE_ENV ?? 'development',
170
+ inspectorVersion: '0.2.0-rc.2',
171
+ }));
172
+ return;
173
+ }
174
+ if (pathSeg === '/env' || pathSeg === '/env/') {
175
+ res.setHeader('Content-Type', 'application/json');
176
+ res.writeHead(200);
177
+ res.end(JSON.stringify({
178
+ nodeVersion: process.version,
179
+ nodeEnv: process.env.NODE_ENV ?? 'development',
180
+ inspectorVersion: '0.2.0-rc.2',
181
+ platform: process.platform,
182
+ arch: process.arch,
183
+ }));
184
+ return;
185
+ }
186
+ if ((pathSeg === '/prompts/render' || pathSeg === '/prompts/render/') &&
187
+ req.method === 'POST') {
188
+ const body = await readJsonBody(req);
189
+ const key = body?.key;
190
+ const variables = body?.variables ?? {};
191
+ if (!key || typeof key !== 'string') {
192
+ res.setHeader('Content-Type', 'application/json');
193
+ res.writeHead(400);
194
+ res.end(JSON.stringify({ error: 'Missing or invalid "key" in request body' }));
195
+ return;
196
+ }
197
+ try {
198
+ const promptsMod = require('@hazeljs/prompts');
199
+ const template = promptsMod.PromptRegistry.get(key);
200
+ const rendered = template.render(variables);
201
+ const tokenEstimate = Math.ceil(rendered.length / 4);
202
+ res.setHeader('Content-Type', 'application/json');
203
+ res.writeHead(200);
204
+ res.end(JSON.stringify({ rendered, tokenEstimate, template: template.template }));
205
+ }
206
+ catch (err) {
207
+ res.setHeader('Content-Type', 'application/json');
208
+ res.writeHead(400);
209
+ res.end(JSON.stringify({ error: String(err) }));
210
+ }
211
+ return;
212
+ }
213
+ res.setHeader('Content-Type', 'application/json');
214
+ const context = {
215
+ moduleType: app.getModuleType(),
216
+ container: app.getContainer(),
217
+ router: app.getRouter(),
218
+ };
219
+ const rawSnapshot = await service.collectSnapshot(context);
220
+ // Normalize response so UI never receives non-array entries or non-object summary
221
+ const snapshot = {
222
+ ...rawSnapshot,
223
+ entries: Array.isArray(rawSnapshot?.entries) ? rawSnapshot.entries : [],
224
+ summary: rawSnapshot?.summary && typeof rawSnapshot.summary === 'object'
225
+ ? rawSnapshot.summary
226
+ : {},
227
+ };
228
+ // Augment with gateway, discovery, resilience overview when available
229
+ const overview = {};
230
+ try {
231
+ const [gatewayData, discoveryData, resilienceData] = await Promise.all([
232
+ inspector_runtime_1.InspectorRuntime.getGatewayOverview(),
233
+ inspector_runtime_1.InspectorRuntime.getDiscoveryOverview(),
234
+ inspector_runtime_1.InspectorRuntime.getResilienceOverview(),
235
+ ]);
236
+ if (gatewayData)
237
+ overview.gateway = gatewayData;
238
+ if (discoveryData)
239
+ overview.discovery = discoveryData;
240
+ if (resilienceData)
241
+ overview.resilience = resilienceData;
242
+ }
243
+ catch {
244
+ // ignore
245
+ }
246
+ if (Object.keys(overview).length > 0) {
247
+ snapshot.overview = overview;
248
+ }
249
+ if (pathSeg === '/inspect' || pathSeg === '/inspect/') {
250
+ res.writeHead(200);
251
+ res.end(JSON.stringify(snapshot));
252
+ return;
253
+ }
254
+ if (pathSeg === '/routes' || pathSeg === '/routes/') {
255
+ const routes = snapshot.entries.filter((e) => e.kind === 'route');
256
+ res.writeHead(200);
257
+ res.end(JSON.stringify({ entries: routes }));
258
+ return;
259
+ }
260
+ if (pathSeg === '/modules' || pathSeg === '/modules/') {
261
+ const modules = snapshot.entries.filter((e) => e.kind === 'module');
262
+ res.writeHead(200);
263
+ res.end(JSON.stringify({ entries: modules }));
264
+ return;
265
+ }
266
+ if (pathSeg === '/providers' || pathSeg === '/providers/') {
267
+ const providers = snapshot.entries.filter((e) => e.kind === 'provider');
268
+ res.writeHead(200);
269
+ res.end(JSON.stringify({ entries: providers }));
270
+ return;
271
+ }
272
+ if (pathSeg === '/jobs' || pathSeg === '/jobs/') {
273
+ const jobs = snapshot.entries.filter((e) => e.kind === 'cron');
274
+ res.writeHead(200);
275
+ res.end(JSON.stringify({ entries: jobs }));
276
+ return;
277
+ }
278
+ if (pathSeg === '/queues' || pathSeg === '/queues/') {
279
+ const queues = snapshot.entries.filter((e) => e.kind === 'queue');
280
+ res.writeHead(200);
281
+ res.end(JSON.stringify({ entries: queues }));
282
+ return;
283
+ }
284
+ if (pathSeg === '/websocket' || pathSeg === '/websocket/') {
285
+ const ws = snapshot.entries.filter((e) => e.kind === 'websocket');
286
+ res.writeHead(200);
287
+ res.end(JSON.stringify({ entries: ws }));
288
+ return;
289
+ }
290
+ if (pathSeg === '/agents' || pathSeg === '/agents/') {
291
+ const agents = snapshot.entries.filter((e) => e.kind === 'agent');
292
+ res.writeHead(200);
293
+ res.end(JSON.stringify({ entries: agents }));
294
+ return;
295
+ }
296
+ const agentRunMatch = pathSeg.match(/^\/agents\/([^/]+)\/run\/?$/);
297
+ if (agentRunMatch && req.method === 'POST') {
298
+ const agentName = decodeURIComponent(agentRunMatch[1]);
299
+ const body = await readJsonBody(req);
300
+ const input = typeof body?.input === 'string' ? body.input : JSON.stringify(body ?? {});
301
+ try {
302
+ const { AgentService } = require('@hazeljs/agent');
303
+ const container = app.getContainer();
304
+ const svc = container.resolve(AgentService);
305
+ if (!svc?.execute) {
306
+ res.writeHead(503);
307
+ res.end(JSON.stringify({ error: 'AgentService not found. Ensure AgentModule is configured.' }));
308
+ return;
309
+ }
310
+ const result = await svc.execute(agentName, input);
311
+ res.writeHead(200);
312
+ res.end(JSON.stringify({ result }));
313
+ }
314
+ catch (err) {
315
+ res.writeHead(500);
316
+ res.end(JSON.stringify({ error: String(err) }));
317
+ }
318
+ return;
319
+ }
320
+ if (pathSeg === '/rag' || pathSeg === '/rag/') {
321
+ const rag = snapshot.entries.filter((e) => e.kind === 'rag');
322
+ res.writeHead(200);
323
+ res.end(JSON.stringify({ entries: rag }));
324
+ return;
325
+ }
326
+ const ragSearchMatch = pathSeg.match(/^\/rag\/([^/]+)\/search\/?$/);
327
+ if (ragSearchMatch && req.method === 'GET') {
328
+ const _pipeline = decodeURIComponent(ragSearchMatch[1]);
329
+ const q = (req.url?.includes('?')
330
+ ? new URL(req.url, 'http://localhost').searchParams.get('q')
331
+ : null) ?? '';
332
+ try {
333
+ const _ragMod = require('@hazeljs/rag');
334
+ const container = app.getContainer();
335
+ const tokensRaw = container.getTokens?.() ?? [];
336
+ const tokens = Array.isArray(tokensRaw) ? tokensRaw : [];
337
+ let ragService = null;
338
+ for (const token of tokens) {
339
+ try {
340
+ const svc = container.resolve(token);
341
+ if (svc && typeof svc.search === 'function') {
342
+ ragService = svc;
343
+ break;
344
+ }
345
+ }
346
+ catch {
347
+ continue;
348
+ }
349
+ }
350
+ if (!ragService?.search) {
351
+ res.writeHead(503);
352
+ res.end(JSON.stringify({
353
+ error: 'RAG service not found. Ensure a RAG pipeline is registered.',
354
+ }));
355
+ return;
356
+ }
357
+ const results = await ragService.search(q, { topK: 10 });
358
+ res.writeHead(200);
359
+ res.end(JSON.stringify({ results: results ?? [] }));
360
+ }
361
+ catch (err) {
362
+ res.writeHead(500);
363
+ res.end(JSON.stringify({ error: String(err) }));
364
+ }
365
+ return;
366
+ }
367
+ if (pathSeg === '/prompts' || pathSeg === '/prompts/') {
368
+ const prompts = snapshot.entries.filter((e) => e.kind === 'prompt');
369
+ res.writeHead(200);
370
+ res.end(JSON.stringify({ entries: prompts }));
371
+ return;
372
+ }
373
+ if ((pathSeg === '/prompts/render' || pathSeg === '/prompts/render/') &&
374
+ req.method === 'POST') {
375
+ const body = await readJsonBody(req);
376
+ const key = body?.key;
377
+ const variables = body?.variables ?? {};
378
+ if (!key || typeof key !== 'string') {
379
+ res.writeHead(400);
380
+ res.end(JSON.stringify({ error: 'Missing or invalid "key" in request body' }));
381
+ return;
382
+ }
383
+ try {
384
+ const promptsMod = require('@hazeljs/prompts');
385
+ const template = promptsMod.PromptRegistry.get(key);
386
+ const rendered = template.render(variables);
387
+ const tokenEstimate = Math.ceil(rendered.length / 4);
388
+ res.writeHead(200);
389
+ res.end(JSON.stringify({ rendered, tokenEstimate, template: template.template }));
390
+ }
391
+ catch (err) {
392
+ res.writeHead(400);
393
+ res.end(JSON.stringify({ error: String(err) }));
394
+ }
395
+ return;
396
+ }
397
+ if (pathSeg === '/aifunctions' || pathSeg === '/aifunctions/') {
398
+ const aifunctions = snapshot.entries.filter((e) => e.kind === 'aifunction');
399
+ res.writeHead(200);
400
+ res.end(JSON.stringify({ entries: aifunctions }));
401
+ return;
402
+ }
403
+ if (pathSeg === '/events' || pathSeg === '/events/') {
404
+ const events = snapshot.entries.filter((e) => e.kind === 'event');
405
+ res.writeHead(200);
406
+ res.end(JSON.stringify({ entries: events }));
407
+ return;
408
+ }
409
+ if (pathSeg === '/graphql' || pathSeg === '/graphql/') {
410
+ const graphql = snapshot.entries.filter((e) => e.kind === 'graphql');
411
+ res.writeHead(200);
412
+ res.end(JSON.stringify({ entries: graphql }));
413
+ return;
414
+ }
415
+ if (pathSeg === '/grpc' || pathSeg === '/grpc/') {
416
+ const grpc = snapshot.entries.filter((e) => e.kind === 'grpc');
417
+ res.writeHead(200);
418
+ res.end(JSON.stringify({ entries: grpc }));
419
+ return;
420
+ }
421
+ if (pathSeg === '/kafka' || pathSeg === '/kafka/') {
422
+ const kafka = snapshot.entries.filter((e) => e.kind === 'kafka');
423
+ res.writeHead(200);
424
+ res.end(JSON.stringify({ entries: kafka }));
425
+ return;
426
+ }
427
+ if (pathSeg === '/flows' || pathSeg === '/flows/') {
428
+ const flows = snapshot.entries.filter((e) => e.kind === 'flow');
429
+ res.writeHead(200);
430
+ res.end(JSON.stringify({ entries: flows }));
431
+ return;
432
+ }
433
+ if (pathSeg === '/data' || pathSeg === '/data/') {
434
+ const data = snapshot.entries.filter((e) => e.kind === 'data');
435
+ res.writeHead(200);
436
+ res.end(JSON.stringify({ entries: data }));
437
+ return;
438
+ }
439
+ if (pathSeg === '/serverless' || pathSeg === '/serverless/') {
440
+ const serverless = snapshot.entries.filter((e) => e.kind === 'serverless');
441
+ res.writeHead(200);
442
+ res.end(JSON.stringify({ entries: serverless }));
443
+ return;
444
+ }
445
+ if (pathSeg === '/ml' || pathSeg === '/ml/') {
446
+ const ml = snapshot.entries.filter((e) => e.kind === 'ml');
447
+ res.writeHead(200);
448
+ res.end(JSON.stringify({ entries: ml }));
449
+ return;
450
+ }
451
+ if (pathSeg === '/' || pathSeg === '') {
452
+ res.writeHead(200);
453
+ res.end(JSON.stringify({
454
+ inspector: true,
455
+ summary: snapshot.summary,
456
+ endpoints: [
457
+ '/inspect',
458
+ '/routes',
459
+ '/modules',
460
+ '/providers',
461
+ '/jobs',
462
+ '/queues',
463
+ '/websocket',
464
+ '/agents',
465
+ '/rag',
466
+ '/prompts',
467
+ '/aifunctions',
468
+ '/events',
469
+ '/graphql',
470
+ '/grpc',
471
+ '/kafka',
472
+ '/flows',
473
+ '/data',
474
+ '/serverless',
475
+ '/ml',
476
+ '/stats',
477
+ ],
478
+ }));
479
+ return;
480
+ }
481
+ res.writeHead(404);
482
+ res.end(JSON.stringify({ error: 'Not found', path: pathSeg }));
483
+ }
484
+ catch (err) {
485
+ res.writeHead(500);
486
+ res.end(JSON.stringify({ error: String(err) }));
487
+ }
488
+ };
489
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Agent inspector plugin - inspects @Agent decorated classes and their tools
3
+ * Optional: requires @hazeljs/agent to be installed
4
+ */
5
+ import 'reflect-metadata';
6
+ import type { HazelInspectorPlugin } from '../contracts/types';
7
+ export declare const agentInspector: HazelInspectorPlugin;
8
+ //# sourceMappingURL=agent.inspector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.inspector.d.ts","sourceRoot":"","sources":["../../src/plugins/agent.inspector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAuC,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAsBpG,eAAO,MAAM,cAAc,EAAE,oBAiC5B,CAAC"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /**
3
+ * Agent inspector plugin - inspects @Agent decorated classes and their tools
4
+ * Optional: requires @hazeljs/agent to be installed
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.agentInspector = void 0;
8
+ require("reflect-metadata");
9
+ function createId(...parts) {
10
+ return parts.filter(Boolean).join(':');
11
+ }
12
+ function tryGetAgentModule() {
13
+ try {
14
+ return require('@hazeljs/agent');
15
+ }
16
+ catch {
17
+ return null;
18
+ }
19
+ }
20
+ exports.agentInspector = {
21
+ name: 'agent',
22
+ version: '1.0.0',
23
+ supports: () => tryGetAgentModule() !== null,
24
+ inspect: async (context) => {
25
+ const agentMod = tryGetAgentModule();
26
+ if (!agentMod)
27
+ return [];
28
+ const entries = [];
29
+ const tokens = context.container.getTokens?.() ?? [];
30
+ for (const token of tokens) {
31
+ if (typeof token !== 'function')
32
+ continue;
33
+ if (!agentMod.isAgent(token))
34
+ continue;
35
+ const meta = agentMod.getAgentMetadata(token);
36
+ const tools = agentMod.getAgentTools(token);
37
+ const className = token.name ?? 'Unknown';
38
+ entries.push({
39
+ id: createId('agent', meta?.name ?? className),
40
+ kind: 'agent',
41
+ packageName: '@hazeljs/agent',
42
+ sourceType: 'class',
43
+ className,
44
+ agentName: meta?.name ?? className,
45
+ tools: tools.length > 0 ? tools : undefined,
46
+ model: meta?.model,
47
+ });
48
+ }
49
+ return entries;
50
+ },
51
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * AI inspector plugin - inspects @AIFunction decorated methods
3
+ * Optional: requires @hazeljs/ai to be installed
4
+ */
5
+ import 'reflect-metadata';
6
+ import type { HazelInspectorPlugin } from '../contracts/types';
7
+ export declare const aiInspector: HazelInspectorPlugin;
8
+ //# sourceMappingURL=ai.inspector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.inspector.d.ts","sourceRoot":"","sources":["../../src/plugins/ai.inspector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAGV,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAkB5B,eAAO,MAAM,WAAW,EAAE,oBAwEzB,CAAC"}