@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,322 @@
1
+ import { z } from "zod";
2
+ import { RolloutAccounting, RolloutEvidence, RolloutSchema } from "@ericsanchezok/synergy-harness/rollout";
3
+ import { Usage } from "@ericsanchezok/synergy-harness/usage";
4
+ import { BusEvent } from "@ericsanchezok/synergy-harness/bus/bus-event";
5
+ import { MessageV2 } from "@ericsanchezok/synergy-harness/session/message-v2";
6
+ import { SessionInteraction } from "@ericsanchezok/synergy-harness/session/interaction";
7
+ import { CortexTypes } from "@ericsanchezok/synergy-harness/cortex/types";
8
+ import { ExecutionPresentation } from "./presentation.js";
9
+ import { ContextUsageEstimateSchema } from "@ericsanchezok/synergy-harness/context";
10
+ export var ExecutionSchema;
11
+ (function (ExecutionSchema) {
12
+ const Json = z.unknown().meta({ ref: "ExecutionJson" });
13
+ ExecutionSchema.Query = z.object({
14
+ mode: z.enum(["process", "records"]).default("records"),
15
+ order: z.enum(["time", "round", "call"]).default("time"),
16
+ runID: z.string().optional(),
17
+ session: z.string().optional(),
18
+ actor: z.enum(["main", "all"]).default("main"),
19
+ query: z.string().max(500).optional(),
20
+ kind: z
21
+ .enum([
22
+ "turn",
23
+ "input",
24
+ "context",
25
+ "reasoning",
26
+ "output",
27
+ "model",
28
+ "retry",
29
+ "tool",
30
+ "process",
31
+ "compaction",
32
+ "subtask",
33
+ ])
34
+ .optional(),
35
+ status: z.enum(["running", "completed", "failed", "cancelled", "interrupted", "unknown"]).optional(),
36
+ kinds: z.string().max(200).optional(),
37
+ statuses: z.string().max(100).optional(),
38
+ anomalies: z.preprocess((value) => (value === "false" ? false : value), z.coerce.boolean()).default(false),
39
+ from: z.coerce.number().nonnegative().optional(),
40
+ to: z.coerce.number().nonnegative().optional(),
41
+ activityFrom: z.coerce.number().int().nonnegative().optional(),
42
+ activityTo: z.coerce.number().int().nonnegative().optional(),
43
+ cursor: z.string().max(4096).optional(),
44
+ anchor: z.string().optional(),
45
+ position: z.enum(["before", "after", "around"]).optional(),
46
+ limit: z.coerce.number().int().min(1).max(500).default(100),
47
+ });
48
+ ExecutionSchema.Node = z
49
+ .object({
50
+ id: z.string(),
51
+ sessionID: z.string(),
52
+ runID: z.string(),
53
+ rootRunID: z.string().nullable().optional(),
54
+ parentID: z.string().nullable(),
55
+ kind: ExecutionSchema.Query.shape.kind.unwrap(),
56
+ title: z.string(),
57
+ preview: z.string(),
58
+ started: z.number(),
59
+ ended: z.number().optional(),
60
+ status: ExecutionSchema.Query.shape.status.unwrap(),
61
+ revision: z.number(),
62
+ messageID: z.string().optional(),
63
+ tool: z.string().optional(),
64
+ modelID: z.string().optional(),
65
+ modelKind: RolloutSchema.CallRecord.shape.kind,
66
+ agent: z.string().optional(),
67
+ callID: z.string().optional(),
68
+ source: z.enum(["recorded", "messages"]),
69
+ evidenceKind: RolloutEvidence.Kind.optional(),
70
+ attemptIndex: z.number().int().nonnegative().optional(),
71
+ purpose: z.string().optional(),
72
+ usageRole: z.string().optional(),
73
+ attribution: z.enum(["known", "unassigned"]).optional(),
74
+ tokens: RolloutAccounting.Metric.optional(),
75
+ group: z
76
+ .object({
77
+ id: z.string(),
78
+ started: z.number().optional(),
79
+ callCount: z.number().int().positive().optional(),
80
+ memberCount: z.number(),
81
+ attemptCount: z.number(),
82
+ retryCount: z.number(),
83
+ anomalies: z.number(),
84
+ purpose: z.string().nullable(),
85
+ })
86
+ .optional(),
87
+ ancestors: z.array(z.object({ id: z.string(), title: z.string(), kind: ExecutionSchema.Query.shape.kind.unwrap() })).optional(),
88
+ activity: z
89
+ .object({ index: z.number(), count: z.number(), endIndex: z.number(), instruction: z.boolean() })
90
+ .optional(),
91
+ })
92
+ .meta({ ref: "ExecutionTrajectoryNode" });
93
+ ExecutionSchema.Task = z
94
+ .object({
95
+ sessionID: z.string(),
96
+ nodeID: z.string().nullable(),
97
+ parentID: z.string().nullable(),
98
+ title: z.string(),
99
+ status: z.enum([
100
+ "running",
101
+ "completed",
102
+ "failed",
103
+ "cancelled",
104
+ "interrupted",
105
+ "unknown",
106
+ "queued",
107
+ "paused",
108
+ "waiting",
109
+ ]),
110
+ elapsedMs: z.number().nullable(),
111
+ elapsedActive: z.boolean(),
112
+ elapsedLowerBound: z.boolean(),
113
+ tokens: RolloutAccounting.Metric,
114
+ runs: z.array(z.string()),
115
+ interaction: SessionInteraction.Info.optional(),
116
+ cortex: z
117
+ .object({
118
+ taskID: CortexTypes.Task.shape.id,
119
+ agent: CortexTypes.Task.shape.agent,
120
+ status: CortexTypes.TaskStatus,
121
+ visibility: CortexTypes.Task.shape.visibility,
122
+ })
123
+ .optional(),
124
+ })
125
+ .meta({ ref: "ExecutionTask" });
126
+ ExecutionSchema.ContextQuery = z.object({
127
+ runID: z.string().optional(),
128
+ cursor: z.string().max(4096).optional(),
129
+ limit: z.coerce.number().int().min(1).max(100).default(30),
130
+ });
131
+ ExecutionSchema.ContextSnapshot = z
132
+ .object({
133
+ sessionID: z.string(),
134
+ callID: z.string(),
135
+ nodeID: z.string(),
136
+ runID: z.string(),
137
+ started: z.number(),
138
+ requestNumber: z.number().int().positive(),
139
+ roundNumber: z.number().int().positive(),
140
+ status: RolloutSchema.Status,
141
+ modelID: z.string(),
142
+ providerID: z.string(),
143
+ inputTokens: z.number().nonnegative().nullable(),
144
+ contextLimit: z.number().nonnegative().nullable(),
145
+ outputTokens: z.number().nonnegative().nullable(),
146
+ cacheHit: z.number().min(0).max(1).nullable(),
147
+ elapsedMs: z.number().nonnegative().nullable(),
148
+ retries: z.number().int().nonnegative(),
149
+ usage: MessageV2.Assistant.shape.contextUsage.unwrap().nullable(),
150
+ estimate: ContextUsageEstimateSchema.optional(),
151
+ compactedBefore: z.boolean(),
152
+ requestAvailable: z.boolean(),
153
+ })
154
+ .meta({ ref: "ExecutionContextSnapshot" });
155
+ ExecutionSchema.ContextHistory = z
156
+ .object({
157
+ sessionID: z.string(),
158
+ revision: z.number(),
159
+ total: z.number(),
160
+ items: z.array(ExecutionSchema.ContextSnapshot),
161
+ nextCursor: z.string().nullable(),
162
+ })
163
+ .meta({ ref: "ExecutionContextHistory" });
164
+ ExecutionSchema.ContextItemsQuery = ExecutionSchema.ContextQuery.extend({
165
+ category: MessageV2.ContextSource.shape.category.optional(),
166
+ query: z.string().max(500).optional(),
167
+ version: z.string().max(4096).optional(),
168
+ });
169
+ ExecutionSchema.ContextItem = MessageV2.ContextSource.extend({
170
+ id: z.string(),
171
+ offset: z.number().nonnegative(),
172
+ bytes: z.number().nonnegative(),
173
+ }).meta({ ref: "ExecutionContextItem" });
174
+ ExecutionSchema.ContextItems = z
175
+ .object({
176
+ callID: z.string(),
177
+ nodeID: z.string(),
178
+ contentVersion: z.string().nullable(),
179
+ status: z.enum(["available", "legacy", "unavailable"]),
180
+ items: z.array(ExecutionSchema.ContextItem),
181
+ total: z.number(),
182
+ nextCursor: z.string().nullable(),
183
+ truncated: z.boolean(),
184
+ })
185
+ .meta({ ref: "ExecutionContextItems" });
186
+ ExecutionSchema.Summary = z
187
+ .object({
188
+ sessionID: z.string(),
189
+ revision: z.number(),
190
+ runID: z.string().optional(),
191
+ computedAt: z.number(),
192
+ clockID: z.string(),
193
+ sampledAt: z.number(),
194
+ status: ExecutionSchema.Task.shape.status,
195
+ elapsedMs: z.number().nullable(),
196
+ elapsedActive: z.boolean(),
197
+ elapsedLowerBound: z.boolean(),
198
+ accounting: RolloutAccounting.Summary,
199
+ cost: ExecutionPresentation.Cost,
200
+ own: RolloutAccounting.Summary,
201
+ descendants: RolloutAccounting.Summary,
202
+ rates: Usage.Summary.shape.rates,
203
+ cache: Usage.Summary.shape.cache,
204
+ latency: Usage.Summary.shape.latency,
205
+ outcomes: Usage.Summary.shape.outcomes,
206
+ tools: Usage.Summary.shape.tools,
207
+ context: Usage.Summary.shape.context,
208
+ contextDistribution: MessageV2.Assistant.shape.contextUsage.unwrap().nullable(),
209
+ tasks: z.array(ExecutionSchema.Task),
210
+ rounds: z.array(z.object({
211
+ id: z.string(),
212
+ title: z.string(),
213
+ started: z.number(),
214
+ status: ExecutionSchema.Task.shape.status,
215
+ elapsedMs: z.number().nullable(),
216
+ elapsedActive: z.boolean(),
217
+ elapsedLowerBound: z.boolean(),
218
+ })),
219
+ coverage: z.object({
220
+ recorded: z.number(),
221
+ messages: z.number(),
222
+ gaps: z.number().nullable(),
223
+ partial: z.boolean(),
224
+ }),
225
+ lanes: z.array(z.object({
226
+ kind: z.enum(["input", "model", "tool"]),
227
+ start: z.number(),
228
+ end: z.number(),
229
+ nodes: z.array(ExecutionSchema.Node),
230
+ total: z.number(),
231
+ })),
232
+ activityTotal: z.number(),
233
+ activitySegments: z
234
+ .array(z.object({
235
+ runID: z.string().nullable(),
236
+ from: z.number(),
237
+ to: z.number(),
238
+ count: z.number(),
239
+ rounds: z.number(),
240
+ }))
241
+ .optional(),
242
+ humanInputs: z.number(),
243
+ taskInstructions: z.number(),
244
+ })
245
+ .meta({ ref: "ExecutionSummary" });
246
+ ExecutionSchema.Page = z
247
+ .object({
248
+ sessionID: z.string(),
249
+ revision: z.number(),
250
+ total: z.number(),
251
+ items: z.array(ExecutionSchema.Node),
252
+ nextCursor: z.string().nullable(),
253
+ previousCursor: z.string().nullable(),
254
+ })
255
+ .meta({ ref: "ExecutionTrajectoryPage" });
256
+ ExecutionSchema.Detail = z
257
+ .object({
258
+ node: ExecutionSchema.Node,
259
+ execution: ExecutionSchema.Summary.pick({
260
+ status: true,
261
+ elapsedMs: true,
262
+ elapsedActive: true,
263
+ elapsedLowerBound: true,
264
+ clockID: true,
265
+ sampledAt: true,
266
+ revision: true,
267
+ }).optional(),
268
+ record: Json.nullable(),
269
+ sources: z.array(z.object({ field: z.string(), artifact: RolloutSchema.ArtifactRef })),
270
+ definitions: Json.nullable(),
271
+ related: z.array(ExecutionSchema.Node),
272
+ })
273
+ .meta({ ref: "ExecutionNodeDetail" });
274
+ ExecutionSchema.Content = RolloutEvidence.Content;
275
+ ExecutionSchema.Updated = BusEvent.define("execution.updated", z.object({
276
+ sessionID: z.string(),
277
+ revision: z.number(),
278
+ summary: ExecutionSchema.Summary,
279
+ roundSummaries: z.array(ExecutionSchema.Summary),
280
+ contextUpserts: z.array(ExecutionSchema.ContextSnapshot).optional(),
281
+ previousRevision: z.number().int().nonnegative().optional(),
282
+ upserts: z.array(ExecutionSchema.Node),
283
+ processUpserts: z.array(ExecutionSchema.Node).optional(),
284
+ processRemoved: z.array(z.string()).optional(),
285
+ removed: z.array(z.string()),
286
+ }));
287
+ const ProjectionBase = z.object({
288
+ sessionID: z.string(),
289
+ revision: z.number().int().nonnegative(),
290
+ previousRevision: z.number().int().nonnegative(),
291
+ contexts: z.array(ExecutionSchema.ContextSnapshot),
292
+ contextTotal: z.number().int().nonnegative(),
293
+ });
294
+ ExecutionSchema.Projection = z
295
+ .discriminatedUnion("state", [
296
+ ProjectionBase.extend({ state: z.literal("root") }),
297
+ ProjectionBase.extend({
298
+ state: z.literal("preparing"),
299
+ progress: z.object({
300
+ stage: z.enum(["metadata", "messages", "parts"]),
301
+ prepared: z.number().int().nonnegative(),
302
+ total: z.number().int().nonnegative().optional(),
303
+ }),
304
+ }),
305
+ ProjectionBase.extend({
306
+ state: z.literal("failed"),
307
+ error: z.object({ kind: z.string(), message: z.string(), retryable: z.boolean() }),
308
+ }),
309
+ ProjectionBase.extend({
310
+ state: z.literal("ready"),
311
+ summary: ExecutionSchema.Summary,
312
+ detailPreviousRevision: z.number().int().nonnegative(),
313
+ roundSummaries: z.array(ExecutionSchema.Summary),
314
+ upserts: z.array(ExecutionSchema.Node),
315
+ processUpserts: z.array(ExecutionSchema.Node),
316
+ processRemoved: z.array(z.string()),
317
+ removed: z.array(z.string()),
318
+ }),
319
+ ])
320
+ .meta({ ref: "ExecutionProjection" });
321
+ ExecutionSchema.ProjectionUpdated = BusEvent.define("execution.projection", ExecutionSchema.Projection);
322
+ })(ExecutionSchema || (ExecutionSchema = {}));