@senad-d/observme 0.1.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.
Files changed (111) hide show
  1. package/.env.example +57 -0
  2. package/CHANGELOG.md +52 -0
  3. package/LICENSE +21 -0
  4. package/ObservMe-Production-Docs/00-README.md +79 -0
  5. package/ObservMe-Production-Docs/01-requirements-and-scope.md +207 -0
  6. package/ObservMe-Production-Docs/02-reference-architecture.md +306 -0
  7. package/ObservMe-Production-Docs/03-pi-event-and-session-model.md +266 -0
  8. package/ObservMe-Production-Docs/04-telemetry-semantic-conventions.md +722 -0
  9. package/ObservMe-Production-Docs/05-otel-pipeline-and-collector.md +355 -0
  10. package/ObservMe-Production-Docs/06-security-privacy-redaction.md +294 -0
  11. package/ObservMe-Production-Docs/07-extension-implementation-blueprint.md +447 -0
  12. package/ObservMe-Production-Docs/08-query-grafana-integration.md +276 -0
  13. package/ObservMe-Production-Docs/09-dashboards-alerts-slos.md +640 -0
  14. package/ObservMe-Production-Docs/10-testing-release-operations.md +319 -0
  15. package/ObservMe-Production-Docs/11-deployment-runbooks.md +203 -0
  16. package/ObservMe-Production-Docs/12-configuration-reference.md +337 -0
  17. package/ObservMe-Production-Docs/13-source-notes.md +33 -0
  18. package/ObservMe-Production-Docs/pi-session-format.md +427 -0
  19. package/README.md +356 -0
  20. package/SECURITY.md +45 -0
  21. package/dashboards/observme-agent-node-graphs.json +250 -0
  22. package/dashboards/observme-agents.json +1880 -0
  23. package/dashboards/observme-alerts.yaml +113 -0
  24. package/dashboards/observme-branches-compactions.json +1042 -0
  25. package/dashboards/observme-cost.json +1254 -0
  26. package/dashboards/observme-errors.json +1659 -0
  27. package/dashboards/observme-export-health.json +1802 -0
  28. package/dashboards/observme-latency.json +1494 -0
  29. package/dashboards/observme-llm-conversations.json +730 -0
  30. package/dashboards/observme-logs-llm.json +644 -0
  31. package/dashboards/observme-models.json +933 -0
  32. package/dashboards/observme-overview.json +2129 -0
  33. package/dashboards/observme-slo-health.json +737 -0
  34. package/dashboards/observme-slos.yaml +56 -0
  35. package/dashboards/observme-tools.json +902 -0
  36. package/dashboards/observme-trace-journey.json +1793 -0
  37. package/docs/STRUCTURE.md +49 -0
  38. package/docs/agent-subagent-observability-requirements.md +997 -0
  39. package/docs/compatibility-matrix.md +39 -0
  40. package/docs/configuration-tui-design-standard.md +767 -0
  41. package/docs/configuration.md +38 -0
  42. package/docs/review-validation.md +115 -0
  43. package/docs/validation-flow.md +117 -0
  44. package/examples/collector.yaml +123 -0
  45. package/examples/observme.yaml +131 -0
  46. package/img/demo.gif +0 -0
  47. package/img/icon.svg +47 -0
  48. package/package.json +103 -0
  49. package/src/commands/obs-agents-runtime.ts +150 -0
  50. package/src/commands/obs-agents.ts +491 -0
  51. package/src/commands/obs-args.ts +63 -0
  52. package/src/commands/obs-backfill.ts +1334 -0
  53. package/src/commands/obs-command-support.ts +43 -0
  54. package/src/commands/obs-cost.ts +228 -0
  55. package/src/commands/obs-diagnostics.ts +22 -0
  56. package/src/commands/obs-errors.ts +156 -0
  57. package/src/commands/obs-health.ts +301 -0
  58. package/src/commands/obs-link.ts +90 -0
  59. package/src/commands/obs-logs.ts +194 -0
  60. package/src/commands/obs-loki-summary.ts +184 -0
  61. package/src/commands/obs-session.ts +259 -0
  62. package/src/commands/obs-status.ts +359 -0
  63. package/src/commands/obs-tools.ts +274 -0
  64. package/src/commands/obs-trace.ts +411 -0
  65. package/src/commands/obs.ts +211 -0
  66. package/src/config/bootstrap-project-config.ts +300 -0
  67. package/src/config/defaults.ts +143 -0
  68. package/src/config/load-config.ts +631 -0
  69. package/src/config/project-paths.ts +61 -0
  70. package/src/config/schema.ts +405 -0
  71. package/src/config/validate.ts +456 -0
  72. package/src/constants.ts +4 -0
  73. package/src/diagnostics/sanitize.ts +6 -0
  74. package/src/extension.ts +38 -0
  75. package/src/otel/logs.ts +160 -0
  76. package/src/otel/metrics.ts +165 -0
  77. package/src/otel/otlp-endpoint.ts +10 -0
  78. package/src/otel/sdk.ts +114 -0
  79. package/src/otel/shutdown.ts +102 -0
  80. package/src/otel/traces.ts +166 -0
  81. package/src/pi/agent-lineage.ts +378 -0
  82. package/src/pi/agent-tree-tracker.ts +258 -0
  83. package/src/pi/event-handlers/agent-turn.ts +155 -0
  84. package/src/pi/event-handlers/lifecycle.ts +642 -0
  85. package/src/pi/event-handlers/llm.ts +115 -0
  86. package/src/pi/event-handlers/session-events.ts +159 -0
  87. package/src/pi/event-handlers/tool-bash.ts +275 -0
  88. package/src/pi/handler-internals.ts +2154 -0
  89. package/src/pi/handler-runtime.ts +633 -0
  90. package/src/pi/handler-types.ts +261 -0
  91. package/src/pi/handlers.ts +75 -0
  92. package/src/pi/subagent-spawn.ts +975 -0
  93. package/src/pi/subagent-types.ts +29 -0
  94. package/src/privacy/content-capture.ts +104 -0
  95. package/src/privacy/hash.ts +93 -0
  96. package/src/privacy/redact.ts +619 -0
  97. package/src/privacy/secret-patterns.ts +185 -0
  98. package/src/privacy/truncate.ts +69 -0
  99. package/src/query/grafana-readiness.ts +164 -0
  100. package/src/query/grafana-transport.ts +481 -0
  101. package/src/query/grafana.ts +371 -0
  102. package/src/query/loki.ts +332 -0
  103. package/src/query/prometheus.ts +388 -0
  104. package/src/query/tempo.ts +332 -0
  105. package/src/safety/sensitive-input.ts +208 -0
  106. package/src/semconv/attributes.ts +279 -0
  107. package/src/semconv/metrics.ts +146 -0
  108. package/src/semconv/spans.ts +19 -0
  109. package/src/semconv/values.ts +13 -0
  110. package/src/util/bounded-map.ts +97 -0
  111. package/tsconfig.json +15 -0
@@ -0,0 +1,405 @@
1
+ import { StringEnum } from "@earendil-works/pi-ai";
2
+ import { Type } from "typebox";
3
+
4
+ const observMeEnvironments = ["production", "development", "test"] as const;
5
+ const privacyPathModes = ["hash", "basename", "full", "drop"] as const;
6
+
7
+ export type ObservMeEnvironment = (typeof observMeEnvironments)[number];
8
+ export type OtlpProtocol = "http/protobuf";
9
+ export type PrivacyPathMode = (typeof privacyPathModes)[number];
10
+
11
+ export interface OtlpTlsConfig {
12
+ enabled: boolean;
13
+ insecureSkipVerify: boolean;
14
+ }
15
+
16
+ export interface OtlpSignalEndpointsConfig {
17
+ traces?: string;
18
+ metrics?: string;
19
+ logs?: string;
20
+ }
21
+
22
+ export interface OtlpConfig {
23
+ endpoint: string;
24
+ protocol: OtlpProtocol;
25
+ timeoutMs: number;
26
+ headers: Record<string, string>;
27
+ tls: OtlpTlsConfig;
28
+ signalEndpoints?: OtlpSignalEndpointsConfig;
29
+ }
30
+
31
+ export interface ResourceConfig {
32
+ attributes: Record<string, string>;
33
+ }
34
+
35
+ export interface WorkflowConfig {
36
+ idEnv: string;
37
+ enabled: boolean;
38
+ maxDepthWarning: number;
39
+ maxFanoutWarning: number;
40
+ }
41
+
42
+ export interface AgentConfig {
43
+ idEnv: string;
44
+ parentIdEnv: string;
45
+ rootIdEnv: string;
46
+ parentSessionIdEnv: string;
47
+ parentTraceIdEnv: string;
48
+ parentSpanIdEnv: string;
49
+ depthEnv: string;
50
+ spawnIdEnv: string;
51
+ propagateTraceContext: boolean;
52
+ propagateToSubagents: boolean;
53
+ capabilityEnv: string;
54
+ writeCorrelationEntry: boolean;
55
+ }
56
+
57
+ export interface TraceBatchConfig {
58
+ maxQueueSize: number;
59
+ maxExportBatchSize: number;
60
+ scheduledDelayMillis: number;
61
+ exportTimeoutMillis: number;
62
+ }
63
+
64
+ export interface TracesConfig {
65
+ enabled: boolean;
66
+ sampleRatio: number;
67
+ batch: TraceBatchConfig;
68
+ }
69
+
70
+ export interface MetricsConfig {
71
+ enabled: boolean;
72
+ exportIntervalMillis: number;
73
+ exportTimeoutMillis: number;
74
+ labels?: string[];
75
+ }
76
+
77
+ export interface LogsBatchConfig {
78
+ maxQueueSize: number;
79
+ maxExportBatchSize: number;
80
+ scheduledDelayMillis: number;
81
+ }
82
+
83
+ export interface LogsConfig {
84
+ enabled: boolean;
85
+ batch: LogsBatchConfig;
86
+ }
87
+
88
+ export interface CaptureConfig {
89
+ prompts: boolean;
90
+ responses: boolean;
91
+ thinking: boolean;
92
+ toolArguments: boolean;
93
+ toolResults: boolean;
94
+ bashCommands: boolean;
95
+ bashOutput: boolean;
96
+ filePaths: boolean;
97
+ }
98
+
99
+ export interface CustomRedactionPatternConfig {
100
+ name: string;
101
+ pattern: string;
102
+ }
103
+
104
+ export interface PrivacyConfig {
105
+ redactionEnabled: boolean;
106
+ allowUnsafeCapture: boolean;
107
+ allowInsecureTransport: boolean;
108
+ tenantSaltEnv: string;
109
+ pathMode: PrivacyPathMode;
110
+ customRedactionPatterns: CustomRedactionPatternConfig[];
111
+ }
112
+
113
+ export interface LimitsConfig {
114
+ maxPromptChars: number;
115
+ maxResponseChars: number;
116
+ maxToolArgumentChars: number;
117
+ maxToolResultChars: number;
118
+ maxBashOutputChars: number;
119
+ maxLogBodyChars: number;
120
+ maxActiveAgentRuns: number;
121
+ maxActiveTurns: number;
122
+ maxActiveToolCalls: number;
123
+ maxActiveLlmRequests: number;
124
+ maxActiveSubagentSpawns: number;
125
+ maxActiveAgentWaits: number;
126
+ maxActiveAgentJoins: number;
127
+ }
128
+
129
+ export interface QueryLinksConfig {
130
+ traceUrlTemplate: string;
131
+ }
132
+
133
+ export interface GrafanaDatasourceUidsConfig {
134
+ tempo: string;
135
+ loki: string;
136
+ prometheus: string;
137
+ }
138
+
139
+ export interface GrafanaTlsConfig {
140
+ insecureSkipVerify: boolean;
141
+ }
142
+
143
+ export interface GrafanaTransportConfig {
144
+ preferIPv4: boolean;
145
+ }
146
+
147
+ export interface GrafanaConfig {
148
+ url: string;
149
+ token: string;
150
+ username: string;
151
+ password: string;
152
+ datasourceUids: GrafanaDatasourceUidsConfig;
153
+ tls: GrafanaTlsConfig;
154
+ transport: GrafanaTransportConfig;
155
+ }
156
+
157
+ export interface QueryConfig {
158
+ enabled: boolean;
159
+ timeoutMs: number;
160
+ maxLogs: number;
161
+ maxTraces: number;
162
+ maxMetricSeries: number;
163
+ maxAgents: number;
164
+ links: QueryLinksConfig;
165
+ grafana: GrafanaConfig;
166
+ }
167
+
168
+ export interface ShutdownConfig {
169
+ flushTimeoutMs: number;
170
+ }
171
+
172
+ export interface ObservMeConfig {
173
+ enabled: boolean;
174
+ environment: ObservMeEnvironment;
175
+ tenant: string;
176
+ replayOnStart: boolean;
177
+ otlp: OtlpConfig;
178
+ resource: ResourceConfig;
179
+ workflow: WorkflowConfig;
180
+ agent: AgentConfig;
181
+ traces: TracesConfig;
182
+ metrics: MetricsConfig;
183
+ logs: LogsConfig;
184
+ capture: CaptureConfig;
185
+ privacy: PrivacyConfig;
186
+ limits: LimitsConfig;
187
+ query: QueryConfig;
188
+ shutdown: ShutdownConfig;
189
+ }
190
+
191
+ const environmentSchema = StringEnum(observMeEnvironments);
192
+ const otlpProtocolSchema = Type.Literal("http/protobuf");
193
+ const stringRecordSchema = Type.Record(Type.String(), Type.String());
194
+ const positiveIntegerSchema = Type.Integer({ minimum: 1 });
195
+ const ratioSchema = Type.Number({ minimum: 0, maximum: 1 });
196
+ const pathModeSchema = StringEnum(privacyPathModes);
197
+
198
+ export const customRedactionPatternSchema = Type.Object(
199
+ {
200
+ name: Type.String({ minLength: 1 }),
201
+ pattern: Type.String({ minLength: 1 }),
202
+ },
203
+ { additionalProperties: false },
204
+ );
205
+
206
+ export const observMeConfigSchema = Type.Object(
207
+ {
208
+ enabled: Type.Boolean(),
209
+ environment: environmentSchema,
210
+ tenant: Type.String({ minLength: 1 }),
211
+ replayOnStart: Type.Boolean(),
212
+ otlp: Type.Object(
213
+ {
214
+ endpoint: Type.String({ minLength: 1 }),
215
+ protocol: otlpProtocolSchema,
216
+ timeoutMs: positiveIntegerSchema,
217
+ headers: stringRecordSchema,
218
+ tls: Type.Object(
219
+ {
220
+ enabled: Type.Boolean(),
221
+ insecureSkipVerify: Type.Boolean(),
222
+ },
223
+ { additionalProperties: false },
224
+ ),
225
+ signalEndpoints: Type.Optional(
226
+ Type.Object(
227
+ {
228
+ traces: Type.Optional(Type.String({ minLength: 1 })),
229
+ metrics: Type.Optional(Type.String({ minLength: 1 })),
230
+ logs: Type.Optional(Type.String({ minLength: 1 })),
231
+ },
232
+ { additionalProperties: false },
233
+ ),
234
+ ),
235
+ },
236
+ { additionalProperties: false },
237
+ ),
238
+ resource: Type.Object(
239
+ {
240
+ attributes: stringRecordSchema,
241
+ },
242
+ { additionalProperties: false },
243
+ ),
244
+ workflow: Type.Object(
245
+ {
246
+ idEnv: Type.String({ minLength: 1 }),
247
+ enabled: Type.Boolean(),
248
+ maxDepthWarning: positiveIntegerSchema,
249
+ maxFanoutWarning: positiveIntegerSchema,
250
+ },
251
+ { additionalProperties: false },
252
+ ),
253
+ agent: Type.Object(
254
+ {
255
+ idEnv: Type.String({ minLength: 1 }),
256
+ parentIdEnv: Type.String({ minLength: 1 }),
257
+ rootIdEnv: Type.String({ minLength: 1 }),
258
+ parentSessionIdEnv: Type.String({ minLength: 1 }),
259
+ parentTraceIdEnv: Type.String({ minLength: 1 }),
260
+ parentSpanIdEnv: Type.String({ minLength: 1 }),
261
+ depthEnv: Type.String({ minLength: 1 }),
262
+ spawnIdEnv: Type.String({ minLength: 1 }),
263
+ propagateTraceContext: Type.Boolean(),
264
+ propagateToSubagents: Type.Boolean(),
265
+ capabilityEnv: Type.String({ minLength: 1 }),
266
+ writeCorrelationEntry: Type.Boolean(),
267
+ },
268
+ { additionalProperties: false },
269
+ ),
270
+ traces: Type.Object(
271
+ {
272
+ enabled: Type.Boolean(),
273
+ sampleRatio: ratioSchema,
274
+ batch: Type.Object(
275
+ {
276
+ maxQueueSize: positiveIntegerSchema,
277
+ maxExportBatchSize: positiveIntegerSchema,
278
+ scheduledDelayMillis: positiveIntegerSchema,
279
+ exportTimeoutMillis: positiveIntegerSchema,
280
+ },
281
+ { additionalProperties: false },
282
+ ),
283
+ },
284
+ { additionalProperties: false },
285
+ ),
286
+ metrics: Type.Object(
287
+ {
288
+ enabled: Type.Boolean(),
289
+ exportIntervalMillis: positiveIntegerSchema,
290
+ exportTimeoutMillis: positiveIntegerSchema,
291
+ labels: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
292
+ },
293
+ { additionalProperties: false },
294
+ ),
295
+ logs: Type.Object(
296
+ {
297
+ enabled: Type.Boolean(),
298
+ batch: Type.Object(
299
+ {
300
+ maxQueueSize: positiveIntegerSchema,
301
+ maxExportBatchSize: positiveIntegerSchema,
302
+ scheduledDelayMillis: positiveIntegerSchema,
303
+ },
304
+ { additionalProperties: false },
305
+ ),
306
+ },
307
+ { additionalProperties: false },
308
+ ),
309
+ capture: Type.Object(
310
+ {
311
+ prompts: Type.Boolean(),
312
+ responses: Type.Boolean(),
313
+ thinking: Type.Boolean(),
314
+ toolArguments: Type.Boolean(),
315
+ toolResults: Type.Boolean(),
316
+ bashCommands: Type.Boolean(),
317
+ bashOutput: Type.Boolean(),
318
+ filePaths: Type.Boolean(),
319
+ },
320
+ { additionalProperties: false },
321
+ ),
322
+ privacy: Type.Object(
323
+ {
324
+ redactionEnabled: Type.Boolean(),
325
+ allowUnsafeCapture: Type.Boolean(),
326
+ allowInsecureTransport: Type.Boolean(),
327
+ tenantSaltEnv: Type.String({ minLength: 1 }),
328
+ pathMode: pathModeSchema,
329
+ customRedactionPatterns: Type.Array(customRedactionPatternSchema),
330
+ },
331
+ { additionalProperties: false },
332
+ ),
333
+ limits: Type.Object(
334
+ {
335
+ maxPromptChars: positiveIntegerSchema,
336
+ maxResponseChars: positiveIntegerSchema,
337
+ maxToolArgumentChars: positiveIntegerSchema,
338
+ maxToolResultChars: positiveIntegerSchema,
339
+ maxBashOutputChars: positiveIntegerSchema,
340
+ maxLogBodyChars: positiveIntegerSchema,
341
+ maxActiveAgentRuns: positiveIntegerSchema,
342
+ maxActiveTurns: positiveIntegerSchema,
343
+ maxActiveToolCalls: positiveIntegerSchema,
344
+ maxActiveLlmRequests: positiveIntegerSchema,
345
+ maxActiveSubagentSpawns: positiveIntegerSchema,
346
+ maxActiveAgentWaits: positiveIntegerSchema,
347
+ maxActiveAgentJoins: positiveIntegerSchema,
348
+ },
349
+ { additionalProperties: false },
350
+ ),
351
+ query: Type.Object(
352
+ {
353
+ enabled: Type.Boolean(),
354
+ timeoutMs: positiveIntegerSchema,
355
+ maxLogs: positiveIntegerSchema,
356
+ maxTraces: positiveIntegerSchema,
357
+ maxMetricSeries: positiveIntegerSchema,
358
+ maxAgents: positiveIntegerSchema,
359
+ links: Type.Object(
360
+ {
361
+ traceUrlTemplate: Type.String(),
362
+ },
363
+ { additionalProperties: false },
364
+ ),
365
+ grafana: Type.Object(
366
+ {
367
+ url: Type.String(),
368
+ token: Type.String(),
369
+ username: Type.String(),
370
+ password: Type.String(),
371
+ datasourceUids: Type.Object(
372
+ {
373
+ tempo: Type.String({ minLength: 1 }),
374
+ loki: Type.String({ minLength: 1 }),
375
+ prometheus: Type.String({ minLength: 1 }),
376
+ },
377
+ { additionalProperties: false },
378
+ ),
379
+ tls: Type.Object(
380
+ {
381
+ insecureSkipVerify: Type.Boolean(),
382
+ },
383
+ { additionalProperties: false },
384
+ ),
385
+ transport: Type.Object(
386
+ {
387
+ preferIPv4: Type.Boolean(),
388
+ },
389
+ { additionalProperties: false },
390
+ ),
391
+ },
392
+ { additionalProperties: false },
393
+ ),
394
+ },
395
+ { additionalProperties: false },
396
+ ),
397
+ shutdown: Type.Object(
398
+ {
399
+ flushTimeoutMs: positiveIntegerSchema,
400
+ },
401
+ { additionalProperties: false },
402
+ ),
403
+ },
404
+ { $id: "ObservMeConfig", additionalProperties: false },
405
+ );