@ericsanchezok/synergy-workbench 0.0.0-stage → 3.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.
Files changed (153) hide show
  1. package/AGENTS.md +30 -0
  2. package/README.md +16 -2
  3. package/dist/agents.js +11 -0
  4. package/dist/cli-adapter.js +8 -0
  5. package/dist/component.js +65 -0
  6. package/dist/config-schema.js +265 -0
  7. package/dist/execution/activity.js +78 -0
  8. package/dist/execution/content.js +184 -0
  9. package/dist/execution/json-sections.js +231 -0
  10. package/dist/execution/presentation.js +79 -0
  11. package/dist/execution/preview.js +13 -0
  12. package/dist/execution/process.js +125 -0
  13. package/dist/execution/projection.js +327 -0
  14. package/dist/execution/query.js +18 -0
  15. package/dist/execution/routes.js +189 -0
  16. package/dist/execution/schema.js +322 -0
  17. package/dist/execution/service.js +1993 -0
  18. package/dist/features.js +22 -0
  19. package/dist/http.js +65 -0
  20. package/dist/performance/analysis.js +330 -0
  21. package/dist/performance/catalog.js +391 -0
  22. package/dist/performance/dashboard.js +483 -0
  23. package/dist/performance/error.js +15 -0
  24. package/dist/performance/index.js +6 -0
  25. package/dist/performance/inflight.js +43 -0
  26. package/dist/performance/projection.js +138 -0
  27. package/dist/performance/prompt/base.txt +38 -0
  28. package/dist/performance/prompt/builder.js +21 -0
  29. package/dist/performance/routes/performance-route.js +439 -0
  30. package/dist/performance/schema.js +628 -0
  31. package/dist/performance/timeline.js +98 -0
  32. package/dist/performance/trace-detail.js +91 -0
  33. package/dist/presentation/service.js +270 -0
  34. package/dist/presentation/tools/workbench-view.js +65 -0
  35. package/dist/presentation/tools.js +10 -0
  36. package/dist/project/directories.js +363 -0
  37. package/dist/project/git-health.js +498 -0
  38. package/dist/project/ide.js +66 -0
  39. package/dist/project/migration.js +22 -0
  40. package/dist/project/routes/directories.js +89 -0
  41. package/dist/project/routes/git.js +30 -0
  42. package/dist/project/routes/task-defaults.js +42 -0
  43. package/dist/project/session-health.js +9 -0
  44. package/dist/project/startup.js +28 -0
  45. package/dist/project/task-defaults.js +68 -0
  46. package/dist/project/tools/session-control.js +664 -0
  47. package/dist/project/tools/session-control.txt +60 -0
  48. package/dist/project/tools/worktree-archive.js +76 -0
  49. package/dist/project/tools/worktree-enter.js +175 -0
  50. package/dist/project/tools/worktree-leave.js +119 -0
  51. package/dist/project/tools/worktree-list.js +52 -0
  52. package/dist/project/tools.js +26 -0
  53. package/dist/project/vcs-branch-watcher.js +76 -0
  54. package/dist/project/vcs.js +114 -0
  55. package/dist/project/worktree-janitor.js +140 -0
  56. package/dist/project/worktrees.js +98 -0
  57. package/dist/push/bridge.js +171 -0
  58. package/dist/push/index.js +4 -0
  59. package/dist/push/routes/push.js +224 -0
  60. package/dist/push/service.js +93 -0
  61. package/dist/push/store.js +121 -0
  62. package/dist/push/types.js +58 -0
  63. package/dist/review/git.js +226 -0
  64. package/dist/review/routes.js +45 -0
  65. package/dist/review/schema.js +32 -0
  66. package/dist/review/state.js +79 -0
  67. package/dist/stats/aggregator.js +252 -0
  68. package/dist/stats/canonical.js +89 -0
  69. package/dist/stats/cli/stats.js +302 -0
  70. package/dist/stats/engine.js +176 -0
  71. package/dist/stats/index.js +5 -0
  72. package/dist/stats/rollup.js +460 -0
  73. package/dist/stats/routes/stats.js +94 -0
  74. package/dist/stats/routes/usage.js +83 -0
  75. package/dist/stats/storage.js +86 -0
  76. package/dist/stats/types.js +267 -0
  77. package/dist/worker.js +6 -0
  78. package/package.json +232 -4
  79. package/src/agents.ts +15 -0
  80. package/src/cli-adapter.ts +11 -0
  81. package/src/component.ts +73 -0
  82. package/src/config-schema.ts +289 -0
  83. package/src/execution/activity.ts +83 -0
  84. package/src/execution/content.ts +189 -0
  85. package/src/execution/json-sections.ts +230 -0
  86. package/src/execution/presentation.ts +91 -0
  87. package/src/execution/preview.ts +12 -0
  88. package/src/execution/process.ts +118 -0
  89. package/src/execution/projection.ts +330 -0
  90. package/src/execution/query.ts +19 -0
  91. package/src/execution/routes.ts +324 -0
  92. package/src/execution/schema.ts +336 -0
  93. package/src/execution/service.ts +2149 -0
  94. package/src/features.ts +22 -0
  95. package/src/http.ts +75 -0
  96. package/src/performance/analysis.ts +356 -0
  97. package/src/performance/catalog.ts +902 -0
  98. package/src/performance/dashboard.ts +521 -0
  99. package/src/performance/error.ts +32 -0
  100. package/src/performance/index.ts +6 -0
  101. package/src/performance/inflight.ts +46 -0
  102. package/src/performance/projection.ts +143 -0
  103. package/src/performance/prompt/base.txt +38 -0
  104. package/src/performance/prompt/builder.ts +24 -0
  105. package/src/performance/routes/performance-route.ts +541 -0
  106. package/src/performance/schema.ts +695 -0
  107. package/src/performance/timeline.ts +100 -0
  108. package/src/performance/trace-detail.ts +97 -0
  109. package/src/presentation/service.ts +303 -0
  110. package/src/presentation/tools/workbench-view.ts +75 -0
  111. package/src/presentation/tools.ts +11 -0
  112. package/src/project/directories.ts +391 -0
  113. package/src/project/git-health.ts +577 -0
  114. package/src/project/ide.ts +80 -0
  115. package/src/project/migration.ts +24 -0
  116. package/src/project/routes/directories.ts +124 -0
  117. package/src/project/routes/git.ts +42 -0
  118. package/src/project/routes/task-defaults.ts +50 -0
  119. package/src/project/session-health.ts +10 -0
  120. package/src/project/startup.ts +28 -0
  121. package/src/project/task-defaults.ts +70 -0
  122. package/src/project/tools/session-control.ts +725 -0
  123. package/src/project/tools/session-control.txt +60 -0
  124. package/src/project/tools/worktree-archive.ts +92 -0
  125. package/src/project/tools/worktree-enter.ts +227 -0
  126. package/src/project/tools/worktree-leave.ts +140 -0
  127. package/src/project/tools/worktree-list.ts +68 -0
  128. package/src/project/tools.ts +29 -0
  129. package/src/project/vcs-branch-watcher.ts +81 -0
  130. package/src/project/vcs.ts +124 -0
  131. package/src/project/worktree-janitor.ts +153 -0
  132. package/src/project/worktrees.ts +110 -0
  133. package/src/push/bridge.ts +182 -0
  134. package/src/push/index.ts +4 -0
  135. package/src/push/routes/push.ts +267 -0
  136. package/src/push/service.ts +108 -0
  137. package/src/push/store.ts +120 -0
  138. package/src/push/types.ts +67 -0
  139. package/src/review/git.ts +221 -0
  140. package/src/review/routes.ts +65 -0
  141. package/src/review/schema.ts +34 -0
  142. package/src/review/state.ts +77 -0
  143. package/src/stats/aggregator.ts +277 -0
  144. package/src/stats/canonical.ts +93 -0
  145. package/src/stats/cli/stats.ts +348 -0
  146. package/src/stats/engine.ts +197 -0
  147. package/src/stats/index.ts +5 -0
  148. package/src/stats/rollup.ts +522 -0
  149. package/src/stats/routes/stats.ts +107 -0
  150. package/src/stats/routes/usage.ts +103 -0
  151. package/src/stats/storage.ts +78 -0
  152. package/src/stats/types.ts +351 -0
  153. package/src/worker.ts +7 -0
@@ -0,0 +1,628 @@
1
+ import { ObservabilityConfig } from "@ericsanchezok/synergy-harness/observability/config";
2
+ import { ObservabilitySchema } from "@ericsanchezok/synergy-harness/observability/schema";
3
+ import { SessionManager } from "@ericsanchezok/synergy-harness/session/manager";
4
+ import z from "zod";
5
+ export var PerformanceSchema;
6
+ (function (PerformanceSchema) {
7
+ PerformanceSchema.Source = ObservabilitySchema.Source.meta({ ref: "PerfSource" });
8
+ PerformanceSchema.Module = ObservabilitySchema.Module.meta({ ref: "PerfModule" });
9
+ PerformanceSchema.Unit = ObservabilitySchema.Unit.meta({ ref: "PerfUnit" });
10
+ PerformanceSchema.LabelValue = ObservabilitySchema.LabelValue.meta({ ref: "PerfLabelValue" });
11
+ PerformanceSchema.Labels = ObservabilitySchema.Labels.meta({ ref: "PerfLabels" });
12
+ PerformanceSchema.Metric = z
13
+ .object({
14
+ metricId: z.string(),
15
+ time: z.number(),
16
+ iso: z.string(),
17
+ name: z.string(),
18
+ value: z.number(),
19
+ unit: PerformanceSchema.Unit,
20
+ source: PerformanceSchema.Source,
21
+ module: PerformanceSchema.Module,
22
+ correlationId: z.string().optional(),
23
+ scopeID: z.string().optional(),
24
+ sessionID: z.string().optional(),
25
+ messageID: z.string().optional(),
26
+ callID: z.string().optional(),
27
+ traceId: z.string().optional(),
28
+ spanId: z.string().optional(),
29
+ parentSpanId: z.string().optional(),
30
+ rid: z.string().optional(),
31
+ processId: z.string().optional(),
32
+ pid: z.number().int().optional(),
33
+ tool: z.string().optional(),
34
+ labels: PerformanceSchema.Labels,
35
+ sampleRate: z.number().min(0).max(1).default(1),
36
+ })
37
+ .meta({ ref: "PerfMetric" });
38
+ PerformanceSchema.SpanStatus = z
39
+ .enum(["running", "ok", "error", "cancelled", "timeout", "interrupted"])
40
+ .meta({ ref: "PerfSpanStatus" });
41
+ PerformanceSchema.Span = z
42
+ .object({
43
+ traceId: z.string(),
44
+ correlationId: z.string().optional(),
45
+ spanId: z.string(),
46
+ parentSpanId: z.string().optional(),
47
+ kind: z.string().optional(),
48
+ name: z.string(),
49
+ module: PerformanceSchema.Module,
50
+ source: PerformanceSchema.Source,
51
+ startTime: z.number(),
52
+ endTime: z.number().optional(),
53
+ durationMs: z.number().optional(),
54
+ status: PerformanceSchema.SpanStatus.default("ok"),
55
+ lastActivityTime: z.number().optional(),
56
+ heartbeatTime: z.number().optional(),
57
+ heartbeatCount: z.number().int().optional(),
58
+ stalled: z.boolean().optional(),
59
+ errorCode: z.string().optional(),
60
+ errorMessage: z.string().optional(),
61
+ scopeID: z.string().optional(),
62
+ sessionID: z.string().optional(),
63
+ messageID: z.string().optional(),
64
+ callID: z.string().optional(),
65
+ rid: z.string().optional(),
66
+ processId: z.string().optional(),
67
+ pid: z.number().int().optional(),
68
+ tool: z.string().optional(),
69
+ attributes: PerformanceSchema.Labels,
70
+ })
71
+ .meta({ ref: "PerfSpan" });
72
+ PerformanceSchema.ResourceSample = z
73
+ .object({
74
+ sampleId: z.string(),
75
+ time: z.number(),
76
+ iso: z.string(),
77
+ source: PerformanceSchema.Source,
78
+ process: z.object({ pid: z.number().int().optional(), processId: z.string().optional(), role: z.string() }),
79
+ cpu: z
80
+ .object({
81
+ userMicros: z.number().optional(),
82
+ systemMicros: z.number().optional(),
83
+ utilizationRatio: z
84
+ .number()
85
+ .describe("Process CPU time per wall-clock time; 1 is one fully used CPU core and values may exceed 1")
86
+ .optional(),
87
+ })
88
+ .default({}),
89
+ memory: z
90
+ .object({
91
+ rssBytes: z.number().optional(),
92
+ heapTotalBytes: z.number().optional(),
93
+ heapUsedBytes: z.number().optional(),
94
+ externalBytes: z.number().optional(),
95
+ arrayBuffersBytes: z.number().optional(),
96
+ })
97
+ .default({}),
98
+ cgroup: z
99
+ .object({
100
+ currentBytes: z.number().optional(),
101
+ highBytes: z.number().optional(),
102
+ maxBytes: z.number().optional(),
103
+ peakBytes: z.number().optional(),
104
+ oomCount: z.number().optional(),
105
+ oomKillCount: z.number().optional(),
106
+ })
107
+ .optional(),
108
+ serviceMemory: z
109
+ .object({
110
+ rssBytes: z.number().optional(),
111
+ source: z.enum(["cgroup_v2", "process_api"]),
112
+ completeness: z.enum(["full", "partial"]),
113
+ })
114
+ .optional(),
115
+ eventLoop: z.object({ lagMs: z.number().optional(), sampleWindowMs: z.number() }),
116
+ io: z
117
+ .object({
118
+ appReadBytes: z.number().optional(),
119
+ appWrittenBytes: z.number().optional(),
120
+ appReadOps: z.number().optional(),
121
+ appWriteOps: z.number().optional(),
122
+ osReadBytes: z.number().optional(),
123
+ osWrittenBytes: z.number().optional(),
124
+ osAvailable: z.boolean().default(false),
125
+ })
126
+ .default({ osAvailable: false }),
127
+ correlationId: z.string().optional(),
128
+ scopeID: z.string().optional(),
129
+ sessionID: z.string().optional(),
130
+ traceId: z.string().optional(),
131
+ labels: PerformanceSchema.Labels,
132
+ })
133
+ .meta({ ref: "PerfResourceSample" });
134
+ PerformanceSchema.IssueSeverity = z.enum(["info", "warning", "error", "critical"]).meta({ ref: "PerfIssueSeverity" });
135
+ PerformanceSchema.IssueStatus = z.enum(["open", "resolved", "suppressed"]).meta({ ref: "PerfIssueStatus" });
136
+ PerformanceSchema.Issue = z
137
+ .object({
138
+ issueId: z.string(),
139
+ time: z.number(),
140
+ iso: z.string(),
141
+ severity: PerformanceSchema.IssueSeverity,
142
+ status: PerformanceSchema.IssueStatus.default("open"),
143
+ code: z.string(),
144
+ title: z.string(),
145
+ message: z.string(),
146
+ recommendation: z.string().optional(),
147
+ module: PerformanceSchema.Module,
148
+ correlationId: z.string().optional(),
149
+ scopeID: z.string().optional(),
150
+ traceId: z.string().optional(),
151
+ spanId: z.string().optional(),
152
+ sessionID: z.string().optional(),
153
+ messageID: z.string().optional(),
154
+ callID: z.string().optional(),
155
+ rid: z.string().optional(),
156
+ evidence: PerformanceSchema.Labels,
157
+ firstSeenTime: z.number(),
158
+ lastSeenTime: z.number(),
159
+ occurrenceCount: z.number().int(),
160
+ fingerprint: z.string(),
161
+ })
162
+ .meta({ ref: "PerfIssue" });
163
+ PerformanceSchema.RankedItem = z
164
+ .object({
165
+ id: z.string(),
166
+ label: z.string(),
167
+ module: PerformanceSchema.Module.optional(),
168
+ value: z.number(),
169
+ unit: PerformanceSchema.Unit,
170
+ traceId: z.string().optional(),
171
+ sessionID: z.string().optional(),
172
+ tool: z.string().optional(),
173
+ status: z.string().optional(),
174
+ processId: z.string().optional(),
175
+ pid: z.number().int().optional(),
176
+ })
177
+ .meta({ ref: "PerfRankedItem" });
178
+ PerformanceSchema.ToolFailureCategory = z
179
+ .object({
180
+ errorClass: z.string(),
181
+ count: z.number().int().nonnegative(),
182
+ })
183
+ .meta({ ref: "PerfToolFailureCategory" });
184
+ PerformanceSchema.ToolFailureItem = z
185
+ .object({
186
+ tool: z.string(),
187
+ callCount: z.number().int().nonnegative(),
188
+ errorCount: z.number().int().nonnegative(),
189
+ errorRate: z.number().min(0).max(1),
190
+ categories: z.array(PerformanceSchema.ToolFailureCategory),
191
+ })
192
+ .meta({ ref: "PerfToolFailureItem" });
193
+ PerformanceSchema.TimelineQuality = z
194
+ .object({
195
+ truncated: z.boolean().optional(),
196
+ sampled: z.boolean().optional(),
197
+ partial: z.boolean().optional(),
198
+ retentionLimited: z.boolean().optional(),
199
+ unavailableReason: z.string().optional(),
200
+ })
201
+ .meta({ ref: "PerfTimelineQuality" });
202
+ PerformanceSchema.ResourceOwnerKind = z
203
+ .enum(["control_plane", "agent", "policy", "plugin", "browser", "mcp", "local_process"])
204
+ .meta({ ref: "PerfResourceOwnerKind" });
205
+ PerformanceSchema.ResourceRecovery = z
206
+ .object({
207
+ action: z.enum(["gc", "recycle", "idle_retire", "close"]),
208
+ reason: z.string(),
209
+ at: z.number(),
210
+ beforeBytes: z.number().nonnegative().optional(),
211
+ afterBytes: z.number().nonnegative().optional(),
212
+ reclaimedBytes: z.number().nonnegative().optional(),
213
+ timedOut: z.boolean().optional(),
214
+ })
215
+ .meta({ ref: "PerfResourceRecovery" });
216
+ PerformanceSchema.ResourceOwner = z
217
+ .object({
218
+ owner: PerformanceSchema.ResourceOwnerKind,
219
+ processCount: z.number().int().nonnegative(),
220
+ measuredProcessCount: z.number().int().nonnegative(),
221
+ currentBytes: z.number().nonnegative().optional(),
222
+ peakBytes: z.number().nonnegative().optional(),
223
+ baselineBytes: z.number().nonnegative().optional(),
224
+ retainedBytes: z.number().nonnegative().optional(),
225
+ heapUsedBytes: z.number().nonnegative().optional(),
226
+ externalBytes: z.number().nonnegative().optional(),
227
+ arrayBuffersBytes: z.number().nonnegative().optional(),
228
+ source: z.enum([
229
+ "process_api",
230
+ "worker_ipc",
231
+ "plugin_monitor",
232
+ "browser_runtime",
233
+ "mcp_stdio",
234
+ "process_registry",
235
+ ]),
236
+ completeness: z.enum(["full", "partial", "unavailable"]),
237
+ attributes: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).default({}),
238
+ lastRecovery: PerformanceSchema.ResourceRecovery.optional(),
239
+ })
240
+ .meta({ ref: "PerfResourceOwner" });
241
+ PerformanceSchema.DashboardSummary = z
242
+ .object({
243
+ generatedAt: z.string(),
244
+ windowMs: z.number(),
245
+ quality: PerformanceSchema.TimelineQuality.optional(),
246
+ health: z.object({
247
+ status: z.enum(["healthy", "degraded", "critical", "unknown"]),
248
+ score: z.number(),
249
+ openIssueCount: z.number().int(),
250
+ criticalIssueCount: z.number().int(),
251
+ }),
252
+ backend: z.object({
253
+ requestCount: z.number().int(),
254
+ errorRate: z.number(),
255
+ p50RequestMs: z.number().optional(),
256
+ p95RequestMs: z.number().optional(),
257
+ p99RequestMs: z.number().optional(),
258
+ activeSessions: z.number().int(),
259
+ pendingSessions: z.number().int(),
260
+ }),
261
+ resources: z.object({
262
+ rssBytes: z.number().optional(),
263
+ heapUsedBytes: z.number().optional(),
264
+ heapTotalBytes: z.number().optional(),
265
+ externalBytes: z.number().optional(),
266
+ arrayBuffersBytes: z.number().optional(),
267
+ cpuUtilizationRatio: z
268
+ .number()
269
+ .describe("Process CPU time per wall-clock time; 1 is one fully used CPU core and values may exceed 1")
270
+ .optional(),
271
+ eventLoopLagP95Ms: z.number().optional(),
272
+ appReadBytes: z.number().optional(),
273
+ appWrittenBytes: z.number().optional(),
274
+ appReadOps: z.number().int().optional(),
275
+ appWriteOps: z.number().int().optional(),
276
+ childProcessCount: z.number().int().optional(),
277
+ measuredChildProcessCount: z.number().int().optional(),
278
+ serviceMemory: z
279
+ .object({
280
+ rssBytes: z.number().optional(),
281
+ currentBytes: z.number().optional(),
282
+ workingSetBytes: z.number().optional(),
283
+ reclaimableBytes: z.number().optional(),
284
+ peakBytes: z.number().optional(),
285
+ source: z.enum(["cgroup_v2", "process_api"]),
286
+ completeness: z.enum(["full", "partial"]),
287
+ })
288
+ .optional(),
289
+ childProcessRssBytes: z.number().optional(),
290
+ owners: z.array(PerformanceSchema.ResourceOwner),
291
+ }),
292
+ sessions: z.object({
293
+ turnCount: z.number().int(),
294
+ p95TurnMs: z.number().optional(),
295
+ llmCallCount: z.number().int(),
296
+ toolCallCount: z.number().int(),
297
+ }),
298
+ frontend: z.object({
299
+ inpMs: z.number().optional(),
300
+ lcpMs: z.number().optional(),
301
+ cls: z.number().optional(),
302
+ fcpMs: z.number().optional(),
303
+ ttfbMs: z.number().optional(),
304
+ longTaskCount: z.number().int(),
305
+ resourceP95Ms: z.number().optional(),
306
+ }),
307
+ runtime: z.object({
308
+ alive: z.boolean().optional(),
309
+ healthy: z.boolean().optional(),
310
+ pid: z.number().int().optional(),
311
+ mode: z.string().optional(),
312
+ mirrorFiles: z.number().int(),
313
+ traceFiles: z.number().int().optional(),
314
+ recentErrors: z.number().int(),
315
+ pendingSessions: z.number().int(),
316
+ sessionRuntimes: z.object({
317
+ totalCount: z.number().int(),
318
+ runningCount: z.number().int(),
319
+ idleCount: z.number().int(),
320
+ childCount: z.number().int(),
321
+ userCount: z.number().int(),
322
+ waiterCount: z.number().int(),
323
+ executionPhases: z.partialRecord(SessionManager.ExecutionPhase, z.number().int().nonnegative()).optional(),
324
+ }),
325
+ execution: z
326
+ .object({
327
+ agentWorkers: z.object({
328
+ configured: z.number().int().positive(),
329
+ minIdle: z.number().int().nonnegative(),
330
+ idleTimeoutMs: z.number().int().positive(),
331
+ maxQueued: z.number().int().nonnegative(),
332
+ maxQueuedBytes: z.number().int().positive(),
333
+ workers: z.number().int().nonnegative(),
334
+ ready: z.number().int().nonnegative(),
335
+ active: z.number().int().nonnegative(),
336
+ queued: z.number().int().nonnegative(),
337
+ queuedBytes: z.number().int().nonnegative(),
338
+ rssBytes: z.number().int().nonnegative(),
339
+ heapUsedBytes: z.number().int().nonnegative(),
340
+ heapTotalBytes: z.number().int().nonnegative(),
341
+ externalBytes: z.number().int().nonnegative(),
342
+ arrayBuffersBytes: z.number().int().nonnegative(),
343
+ }),
344
+ policyWorkers: z.object({
345
+ configured: z.number().int().positive(),
346
+ maxQueued: z.number().int().nonnegative(),
347
+ maxQueuedBytes: z.number().int().positive(),
348
+ workers: z.number().int().nonnegative(),
349
+ ready: z.number().int().nonnegative(),
350
+ active: z.number().int().nonnegative(),
351
+ queued: z.number().int().nonnegative(),
352
+ queuedBytes: z.number().int().nonnegative(),
353
+ rssBytes: z.number().int().nonnegative(),
354
+ heapUsedBytes: z.number().int().nonnegative(),
355
+ heapTotalBytes: z.number().int().nonnegative(),
356
+ externalBytes: z.number().int().nonnegative(),
357
+ arrayBuffersBytes: z.number().int().nonnegative(),
358
+ }),
359
+ toolTasks: z.object({
360
+ active: z.number().int().nonnegative(),
361
+ queued: z.number().int().nonnegative(),
362
+ tracked: z.number().int().nonnegative(),
363
+ queuedBytes: z.number().int().nonnegative(),
364
+ maxConcurrent: z.number().int().positive(),
365
+ maxQueued: z.number().int().nonnegative(),
366
+ maxQueuedBytes: z.number().int().positive().optional(),
367
+ byExecutor: z
368
+ .partialRecord(z.enum(["local_process", "file", "plugin", "mcp", "browser", "control_plane"]), z.object({
369
+ active: z.number().int().nonnegative(),
370
+ queued: z.number().int().nonnegative(),
371
+ limit: z.number().int().positive(),
372
+ }))
373
+ .optional(),
374
+ }),
375
+ })
376
+ .optional(),
377
+ messageCache: z
378
+ .object({
379
+ totalBytes: z.number().int().nonnegative(),
380
+ activeCount: z.number().int().nonnegative(),
381
+ entryCount: z.number().int().nonnegative(),
382
+ hits: z.number().int().nonnegative(),
383
+ misses: z.number().int().nonnegative(),
384
+ evictions: z.number().int().nonnegative(),
385
+ protectedOverbudget: z.number().int().nonnegative(),
386
+ entries: z.array(z.object({ estimatedBytes: z.number().int().nonnegative() })),
387
+ truncatedEntryCount: z.number().int().nonnegative(),
388
+ })
389
+ .optional(),
390
+ llmTurns: z
391
+ .object({
392
+ activeTurnCount: z.number().int().nonnegative(),
393
+ activeStreamCount: z.number().int().nonnegative(),
394
+ turns: z.array(z.object({
395
+ ageMs: z.number().nonnegative(),
396
+ streamActive: z.boolean(),
397
+ providerID: z.string(),
398
+ modelID: z.string(),
399
+ historyBeforeBytes: z.number().int().nonnegative(),
400
+ historyAfterBytes: z.number().int().nonnegative(),
401
+ requestBytes: z.number().int().nonnegative(),
402
+ toolSchemaBytes: z.number().int().nonnegative(),
403
+ outputChars: z.number().int().nonnegative(),
404
+ toolRawChars: z.number().int().nonnegative(),
405
+ })),
406
+ })
407
+ .optional(),
408
+ cortexTasks: z.object({
409
+ totalCount: z.number().int(),
410
+ queuedCount: z.number().int(),
411
+ runningCount: z.number().int(),
412
+ completedCount: z.number().int(),
413
+ errorCount: z.number().int(),
414
+ cancelledCount: z.number().int(),
415
+ interruptedCount: z.number().int(),
416
+ retainedPromptChars: z.number().int(),
417
+ retainedOutputChars: z.number().int(),
418
+ retainedErrorChars: z.number().int(),
419
+ retainedProgressToolCount: z.number().int(),
420
+ }),
421
+ }),
422
+ top: z.object({
423
+ slowRoutes: z.array(PerformanceSchema.RankedItem),
424
+ slowSessions: z.array(PerformanceSchema.RankedItem),
425
+ slowTools: z.array(PerformanceSchema.RankedItem),
426
+ toolFailures: z.array(PerformanceSchema.ToolFailureItem),
427
+ slowProviders: z.array(PerformanceSchema.RankedItem),
428
+ slowStorage: z.array(PerformanceSchema.RankedItem),
429
+ slowLibrary: z.array(PerformanceSchema.RankedItem),
430
+ childProcesses: z.array(PerformanceSchema.RankedItem),
431
+ slowFrontend: z.array(PerformanceSchema.RankedItem),
432
+ }),
433
+ issues: z.array(PerformanceSchema.Issue),
434
+ })
435
+ .meta({ ref: "PerfDashboardSummary" });
436
+ PerformanceSchema.TimelineQuery = z
437
+ .object({
438
+ from: z.string().optional(),
439
+ to: z.string().optional(),
440
+ bucketMs: z.coerce.number().int().positive().optional(),
441
+ metric: z.union([z.string(), z.array(z.string())]).optional(),
442
+ stat: z.enum(["avg", "latest", "sum", "rate", "p50", "p95", "p99", "max"]).optional(),
443
+ scopeID: z.string().optional(),
444
+ sessionID: z.string().optional(),
445
+ tool: z.string().optional(),
446
+ providerID: z.string().optional(),
447
+ module: PerformanceSchema.Module.optional(),
448
+ windowMs: z.coerce.number().int().positive().optional(),
449
+ })
450
+ .meta({ ref: "PerfTimelineQuery" });
451
+ PerformanceSchema.TimelineStat = z
452
+ .enum(["avg", "latest", "sum", "rate", "p50", "p95", "p99", "max"])
453
+ .meta({ ref: "PerfTimelineStat" });
454
+ PerformanceSchema.MetricKind = z
455
+ .enum(["duration", "gauge", "counter", "rate", "size", "ratio"])
456
+ .meta({ ref: "PerfMetricKind" });
457
+ PerformanceSchema.TimelinePoint = z
458
+ .object({ time: z.number(), value: z.number().nullable(), sampleCount: z.number().int().optional() })
459
+ .meta({ ref: "PerfTimelinePoint" });
460
+ PerformanceSchema.TimelineSeries = z
461
+ .object({
462
+ name: z.string(),
463
+ label: z.string().optional(),
464
+ unit: PerformanceSchema.Unit,
465
+ kind: PerformanceSchema.MetricKind.optional(),
466
+ stat: PerformanceSchema.TimelineStat.optional(),
467
+ sampleCount: z.number().int().optional(),
468
+ module: PerformanceSchema.Module.optional(),
469
+ source: PerformanceSchema.Source.optional(),
470
+ quality: PerformanceSchema.TimelineQuality.optional(),
471
+ points: z.array(PerformanceSchema.TimelinePoint),
472
+ })
473
+ .meta({ ref: "PerfTimelineSeries" });
474
+ PerformanceSchema.Timeline = z
475
+ .object({
476
+ generatedAt: z.string(),
477
+ from: z.number(),
478
+ to: z.number(),
479
+ bucketMs: z.number(),
480
+ quality: PerformanceSchema.TimelineQuality.optional(),
481
+ series: z.array(PerformanceSchema.TimelineSeries),
482
+ })
483
+ .meta({ ref: "PerfTimeline" });
484
+ PerformanceSchema.TraceListQuery = z
485
+ .object({
486
+ from: z.string().optional(),
487
+ to: z.string().optional(),
488
+ limit: z.coerce.number().int().positive().max(200).optional(),
489
+ cursor: z.string().optional(),
490
+ kind: z
491
+ .enum(["request", "session", "tool", "provider", "runtime", "storage", "frontend", "mcp", "plugin", "channel"])
492
+ .optional(),
493
+ status: PerformanceSchema.SpanStatus.optional(),
494
+ minDurationMs: z.coerce.number().nonnegative().optional(),
495
+ scopeID: z.string().optional(),
496
+ sessionID: z.string().optional(),
497
+ })
498
+ .meta({ ref: "PerfTraceListQuery" });
499
+ PerformanceSchema.TraceListItem = z
500
+ .object({
501
+ traceId: z.string(),
502
+ correlationId: z.string().optional(),
503
+ kind: z.string(),
504
+ name: z.string(),
505
+ status: PerformanceSchema.SpanStatus,
506
+ startedAt: z.string(),
507
+ endedAt: z.string().optional(),
508
+ durationMs: z.number().optional(),
509
+ module: PerformanceSchema.Module,
510
+ source: PerformanceSchema.Source,
511
+ sessionID: z.string().optional(),
512
+ scopeID: z.string().optional(),
513
+ rid: z.string().optional(),
514
+ tool: z.string().optional(),
515
+ errorCode: z.string().optional(),
516
+ redactionApplied: z.boolean(),
517
+ })
518
+ .meta({ ref: "PerfTraceListItem" });
519
+ PerformanceSchema.TraceList = z
520
+ .object({ generatedAt: z.string(), items: z.array(PerformanceSchema.TraceListItem), nextCursor: z.string().optional() })
521
+ .meta({ ref: "PerfTraceList" });
522
+ PerformanceSchema.InflightSpan = PerformanceSchema.Span.extend({
523
+ ageMs: z.number(),
524
+ idleMs: z.number(),
525
+ stale: z.boolean(),
526
+ activeSince: z.number().optional(),
527
+ }).meta({ ref: "PerfInflightSpan" });
528
+ PerformanceSchema.Inflight = z
529
+ .object({ generatedAt: z.string(), spans: z.array(PerformanceSchema.InflightSpan) })
530
+ .meta({ ref: "PerfInflight" });
531
+ PerformanceSchema.AnalysisRequest = z
532
+ .object({
533
+ windowMs: z.coerce.number().int().min(1000).max(86_400_000).default(900_000),
534
+ })
535
+ .meta({ ref: "PerformanceAnalysisRequest" });
536
+ PerformanceSchema.AnalysisStatus = z
537
+ .enum(["queued", "running", "completed", "error", "cancelled", "interrupted"])
538
+ .meta({ ref: "PerformanceAnalysisStatus" });
539
+ PerformanceSchema.AnalysisView = z
540
+ .object({
541
+ sessionID: z.string(),
542
+ status: PerformanceSchema.AnalysisStatus,
543
+ startedAt: z.number(),
544
+ completedAt: z.number().optional(),
545
+ result: z.string().optional(),
546
+ error: z.string().optional(),
547
+ })
548
+ .meta({ ref: "PerformanceAnalysisView" });
549
+ PerformanceSchema.TraceEvent = z
550
+ .object({
551
+ time: z.number(),
552
+ iso: z.string(),
553
+ type: z.string(),
554
+ level: z.string().optional(),
555
+ traceId: z.string().optional(),
556
+ correlationId: z.string().optional(),
557
+ sessionID: z.string().optional(),
558
+ messageID: z.string().optional(),
559
+ callID: z.string().optional(),
560
+ rid: z.string().optional(),
561
+ tool: z.string().optional(),
562
+ processId: z.string().optional(),
563
+ pid: z.number().int().optional(),
564
+ dataKeys: z.array(z.string()).default([]),
565
+ redactionApplied: z.boolean(),
566
+ })
567
+ .meta({ ref: "PerfTraceEvent" });
568
+ PerformanceSchema.TraceDetail = z
569
+ .object({
570
+ generatedAt: z.string(),
571
+ traceId: z.string(),
572
+ root: PerformanceSchema.Span.optional(),
573
+ spans: z.array(PerformanceSchema.Span),
574
+ events: z.array(PerformanceSchema.TraceEvent),
575
+ redaction: z.object({ applied: z.boolean(), omittedAttributes: z.number().int() }),
576
+ })
577
+ .meta({ ref: "PerfTraceDetail" });
578
+ PerformanceSchema.BrowserMetric = z
579
+ .object({
580
+ name: z.string().max(96),
581
+ value: z.number(),
582
+ unit: PerformanceSchema.Unit,
583
+ time: z.number().optional(),
584
+ labels: PerformanceSchema.Labels.optional(),
585
+ })
586
+ .meta({ ref: "PerfBrowserMetric" });
587
+ PerformanceSchema.BrowserMetricBatch = z
588
+ .object({
589
+ batchId: z.string().max(128).optional(),
590
+ sentAt: z.number(),
591
+ page: z
592
+ .object({
593
+ routeName: z.string().max(256).optional(),
594
+ pathTemplate: z.string().max(512).optional(),
595
+ sessionID: z.string().max(128).optional(),
596
+ scopeID: z.string().max(128).optional(),
597
+ correlationId: z.string().max(128).optional(),
598
+ navigationId: z.string().max(128).optional(),
599
+ sessionSwitchId: z.string().max(128).optional(),
600
+ })
601
+ .default({}),
602
+ metrics: z.array(PerformanceSchema.BrowserMetric).max(100),
603
+ resourceEntries: z
604
+ .array(z.object({
605
+ name: z.string().max(2048),
606
+ initiatorType: z.string().max(64).optional(),
607
+ startTime: z.number(),
608
+ duration: z.number(),
609
+ transferSize: z.number().optional(),
610
+ encodedBodySize: z.number().optional(),
611
+ decodedBodySize: z.number().optional(),
612
+ requestStart: z.number().finite().nonnegative().optional(),
613
+ responseStart: z.number().finite().nonnegative().optional(),
614
+ responseEnd: z.number().finite().nonnegative().optional(),
615
+ }))
616
+ .max(100)
617
+ .optional(),
618
+ longTasks: z
619
+ .array(z.object({ startTime: z.number(), duration: z.number(), attribution: z.string().max(128).optional() }))
620
+ .max(100)
621
+ .optional(),
622
+ })
623
+ .meta({ ref: "PerfBrowserMetricBatch" });
624
+ PerformanceSchema.BrowserMetricIngestResult = z
625
+ .object({ batchId: z.string(), accepted: z.number().int(), rejected: z.number().int(), receivedAt: z.string() })
626
+ .meta({ ref: "PerfBrowserMetricIngestResult" });
627
+ PerformanceSchema.Config = ObservabilityConfig.Schema.meta({ ref: "PerfConfig" });
628
+ })(PerformanceSchema || (PerformanceSchema = {}));