@assemble-dev/shared-types 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.
@@ -0,0 +1,399 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/trace-events.ts
21
+ var trace_events_exports = {};
22
+ __export(trace_events_exports, {
23
+ AgentCompletedEventSchema: () => AgentCompletedEventSchema,
24
+ AgentFailedEventSchema: () => AgentFailedEventSchema,
25
+ AgentStartedEventSchema: () => AgentStartedEventSchema,
26
+ ApprovalApprovedEventSchema: () => ApprovalApprovedEventSchema,
27
+ ApprovalRejectedEventSchema: () => ApprovalRejectedEventSchema,
28
+ ApprovalRequiredEventSchema: () => ApprovalRequiredEventSchema,
29
+ EvalCompletedEventSchema: () => EvalCompletedEventSchema,
30
+ EvalStartedEventSchema: () => EvalStartedEventSchema,
31
+ PolicyEvaluatedEventSchema: () => PolicyEvaluatedEventSchema,
32
+ ReplayCompletedEventSchema: () => ReplayCompletedEventSchema,
33
+ ReplayStartedEventSchema: () => ReplayStartedEventSchema,
34
+ RouteSelectedEventSchema: () => RouteSelectedEventSchema,
35
+ RunCompletedEventSchema: () => RunCompletedEventSchema,
36
+ RunFailedEventSchema: () => RunFailedEventSchema,
37
+ RunStartedEventSchema: () => RunStartedEventSchema,
38
+ ToolApprovedEventSchema: () => ToolApprovedEventSchema,
39
+ ToolBlockedEventSchema: () => ToolBlockedEventSchema,
40
+ ToolCompletedEventSchema: () => ToolCompletedEventSchema,
41
+ ToolFailedEventSchema: () => ToolFailedEventSchema,
42
+ ToolRequestedEventSchema: () => ToolRequestedEventSchema,
43
+ TraceEventErrorSchema: () => TraceEventErrorSchema,
44
+ TraceEventSchema: () => TraceEventSchema,
45
+ traceEventTypes: () => traceEventTypes
46
+ });
47
+ module.exports = __toCommonJS(trace_events_exports);
48
+ var import_zod4 = require("zod");
49
+
50
+ // src/json.ts
51
+ var import_zod = require("zod");
52
+ var JsonPrimitiveSchema = import_zod.z.union([
53
+ import_zod.z.string(),
54
+ import_zod.z.number(),
55
+ import_zod.z.boolean(),
56
+ import_zod.z.null()
57
+ ]);
58
+ var JsonValueSchema = import_zod.z.lazy(
59
+ () => import_zod.z.union([
60
+ JsonPrimitiveSchema,
61
+ import_zod.z.array(JsonValueSchema),
62
+ import_zod.z.record(import_zod.z.string(), JsonValueSchema)
63
+ ])
64
+ );
65
+ var JsonObjectSchema = import_zod.z.record(import_zod.z.string(), JsonValueSchema);
66
+
67
+ // src/run-metadata.ts
68
+ var import_zod2 = require("zod");
69
+ var RunMetadataSchema = import_zod2.z.object({
70
+ sessionId: import_zod2.z.string().optional(),
71
+ userId: import_zod2.z.string().optional(),
72
+ tags: import_zod2.z.array(import_zod2.z.string()).optional(),
73
+ parentTraceId: import_zod2.z.string().optional(),
74
+ parentSpanId: import_zod2.z.string().optional()
75
+ });
76
+
77
+ // src/runs.ts
78
+ var import_zod3 = require("zod");
79
+ var RunStatusSchema = import_zod3.z.enum([
80
+ "pending",
81
+ "running",
82
+ "awaiting_approval",
83
+ "completed",
84
+ "failed",
85
+ "canceled",
86
+ "rejected"
87
+ ]);
88
+ var PolicyActionSchema = import_zod3.z.enum([
89
+ "allow",
90
+ "block",
91
+ "requireApproval",
92
+ "logOnly",
93
+ "redact"
94
+ ]);
95
+ var ApprovalStatusSchema = import_zod3.z.enum(["pending", "approved", "rejected"]);
96
+ var RunErrorSchema = import_zod3.z.object({
97
+ message: import_zod3.z.string(),
98
+ code: import_zod3.z.string().optional(),
99
+ agentName: import_zod3.z.string().optional(),
100
+ toolName: import_zod3.z.string().optional(),
101
+ timestamp: import_zod3.z.iso.datetime()
102
+ });
103
+ var RunMessageRoleSchema = import_zod3.z.enum([
104
+ "system",
105
+ "user",
106
+ "assistant",
107
+ "tool"
108
+ ]);
109
+ var RunMessageSchema = import_zod3.z.object({
110
+ role: RunMessageRoleSchema,
111
+ content: import_zod3.z.string(),
112
+ agentName: import_zod3.z.string().optional(),
113
+ toolName: import_zod3.z.string().optional(),
114
+ timestamp: import_zod3.z.iso.datetime()
115
+ });
116
+ var AgentCallStatusSchema = import_zod3.z.enum(["running", "completed", "failed"]);
117
+ var AgentCallSchema = import_zod3.z.object({
118
+ id: import_zod3.z.string(),
119
+ agentName: import_zod3.z.string(),
120
+ status: AgentCallStatusSchema,
121
+ input: JsonValueSchema,
122
+ output: JsonValueSchema.nullable(),
123
+ error: RunErrorSchema.nullable(),
124
+ startedAt: import_zod3.z.iso.datetime(),
125
+ completedAt: import_zod3.z.iso.datetime().nullable(),
126
+ latencyMs: import_zod3.z.number().nonnegative().nullable()
127
+ });
128
+ var ToolCallStatusSchema = import_zod3.z.enum([
129
+ "requested",
130
+ "approved",
131
+ "blocked",
132
+ "completed",
133
+ "failed"
134
+ ]);
135
+ var ToolCallSchema = import_zod3.z.object({
136
+ id: import_zod3.z.string(),
137
+ toolName: import_zod3.z.string(),
138
+ agentName: import_zod3.z.string(),
139
+ status: ToolCallStatusSchema,
140
+ input: JsonValueSchema,
141
+ output: JsonValueSchema.nullable(),
142
+ error: RunErrorSchema.nullable(),
143
+ requestedAt: import_zod3.z.iso.datetime(),
144
+ completedAt: import_zod3.z.iso.datetime().nullable(),
145
+ latencyMs: import_zod3.z.number().nonnegative().nullable()
146
+ });
147
+ var PolicyDecisionSchema = import_zod3.z.object({
148
+ policyName: import_zod3.z.string(),
149
+ action: PolicyActionSchema,
150
+ agentName: import_zod3.z.string().optional(),
151
+ toolName: import_zod3.z.string().optional(),
152
+ reason: import_zod3.z.string(),
153
+ timestamp: import_zod3.z.iso.datetime()
154
+ });
155
+ var RoutingDecisionSchema = import_zod3.z.object({
156
+ supervisorName: import_zod3.z.string(),
157
+ selectedAgentName: import_zod3.z.string(),
158
+ candidateAgentNames: import_zod3.z.array(import_zod3.z.string()),
159
+ reason: import_zod3.z.string(),
160
+ timestamp: import_zod3.z.iso.datetime()
161
+ });
162
+ var RunApprovalSchema = import_zod3.z.object({
163
+ id: import_zod3.z.string(),
164
+ status: ApprovalStatusSchema,
165
+ toolCallId: import_zod3.z.string().nullable(),
166
+ toolName: import_zod3.z.string().optional(),
167
+ agentName: import_zod3.z.string().optional(),
168
+ reason: import_zod3.z.string(),
169
+ requestedAt: import_zod3.z.iso.datetime(),
170
+ decidedAt: import_zod3.z.iso.datetime().nullable(),
171
+ decidedBy: import_zod3.z.string().nullable()
172
+ });
173
+ var RunArtifactSchema = import_zod3.z.object({
174
+ key: import_zod3.z.string(),
175
+ value: JsonValueSchema,
176
+ producedByAgentName: import_zod3.z.string().optional(),
177
+ createdAt: import_zod3.z.iso.datetime()
178
+ });
179
+ var TokenUsageSchema = import_zod3.z.object({
180
+ inputTokens: import_zod3.z.number().int().nonnegative(),
181
+ outputTokens: import_zod3.z.number().int().nonnegative(),
182
+ totalTokens: import_zod3.z.number().int().nonnegative(),
183
+ cacheCreationInputTokens: import_zod3.z.number().int().nonnegative().optional(),
184
+ cacheReadInputTokens: import_zod3.z.number().int().nonnegative().optional()
185
+ });
186
+ var RunMetricsSchema = import_zod3.z.object({
187
+ totalLatencyMs: import_zod3.z.number().nonnegative().nullable(),
188
+ tokenUsage: TokenUsageSchema.nullable(),
189
+ agentCallCount: import_zod3.z.number().int().nonnegative(),
190
+ toolCallCount: import_zod3.z.number().int().nonnegative(),
191
+ policyDecisionCount: import_zod3.z.number().int().nonnegative(),
192
+ approvalCount: import_zod3.z.number().int().nonnegative()
193
+ });
194
+ var RunStateSchema = import_zod3.z.object({
195
+ runId: import_zod3.z.string(),
196
+ workflowName: import_zod3.z.string(),
197
+ status: RunStatusSchema,
198
+ input: JsonValueSchema,
199
+ messages: import_zod3.z.array(RunMessageSchema),
200
+ agentCalls: import_zod3.z.array(AgentCallSchema),
201
+ toolCalls: import_zod3.z.array(ToolCallSchema),
202
+ policyDecisions: import_zod3.z.array(PolicyDecisionSchema),
203
+ routingDecisions: import_zod3.z.array(RoutingDecisionSchema),
204
+ approvals: import_zod3.z.array(RunApprovalSchema),
205
+ artifacts: import_zod3.z.array(RunArtifactSchema),
206
+ errors: import_zod3.z.array(RunErrorSchema),
207
+ metrics: RunMetricsSchema,
208
+ finalOutput: JsonValueSchema.nullable(),
209
+ createdAt: import_zod3.z.iso.datetime(),
210
+ startedAt: import_zod3.z.iso.datetime().nullable(),
211
+ completedAt: import_zod3.z.iso.datetime().nullable()
212
+ });
213
+
214
+ // src/trace-events.ts
215
+ var TraceEventErrorSchema = import_zod4.z.object({
216
+ message: import_zod4.z.string(),
217
+ code: import_zod4.z.string().optional(),
218
+ stack: import_zod4.z.string().optional()
219
+ });
220
+ var TraceEventBaseSchema = import_zod4.z.object({
221
+ id: import_zod4.z.string(),
222
+ runId: import_zod4.z.string(),
223
+ workflowName: import_zod4.z.string(),
224
+ timestamp: import_zod4.z.iso.datetime(),
225
+ parentEventId: import_zod4.z.string().nullable(),
226
+ redacted: import_zod4.z.boolean(),
227
+ metadata: RunMetadataSchema.optional()
228
+ });
229
+ var RunStartedEventSchema = TraceEventBaseSchema.extend({
230
+ type: import_zod4.z.literal("run.started"),
231
+ input: JsonValueSchema
232
+ });
233
+ var RunCompletedEventSchema = TraceEventBaseSchema.extend({
234
+ type: import_zod4.z.literal("run.completed"),
235
+ output: JsonValueSchema,
236
+ latencyMs: import_zod4.z.number().nonnegative()
237
+ });
238
+ var RunFailedEventSchema = TraceEventBaseSchema.extend({
239
+ type: import_zod4.z.literal("run.failed"),
240
+ error: TraceEventErrorSchema,
241
+ latencyMs: import_zod4.z.number().nonnegative()
242
+ });
243
+ var AgentStartedEventSchema = TraceEventBaseSchema.extend({
244
+ type: import_zod4.z.literal("agent.started"),
245
+ agentName: import_zod4.z.string(),
246
+ input: JsonValueSchema
247
+ });
248
+ var AgentCompletedEventSchema = TraceEventBaseSchema.extend({
249
+ type: import_zod4.z.literal("agent.completed"),
250
+ agentName: import_zod4.z.string(),
251
+ output: JsonValueSchema,
252
+ latencyMs: import_zod4.z.number().nonnegative()
253
+ });
254
+ var AgentFailedEventSchema = TraceEventBaseSchema.extend({
255
+ type: import_zod4.z.literal("agent.failed"),
256
+ agentName: import_zod4.z.string(),
257
+ error: TraceEventErrorSchema,
258
+ latencyMs: import_zod4.z.number().nonnegative()
259
+ });
260
+ var ToolRequestedEventSchema = TraceEventBaseSchema.extend({
261
+ type: import_zod4.z.literal("tool.requested"),
262
+ toolName: import_zod4.z.string(),
263
+ agentName: import_zod4.z.string(),
264
+ input: JsonValueSchema
265
+ });
266
+ var ToolApprovedEventSchema = TraceEventBaseSchema.extend({
267
+ type: import_zod4.z.literal("tool.approved"),
268
+ toolName: import_zod4.z.string(),
269
+ agentName: import_zod4.z.string(),
270
+ approvalId: import_zod4.z.string().nullable()
271
+ });
272
+ var ToolBlockedEventSchema = TraceEventBaseSchema.extend({
273
+ type: import_zod4.z.literal("tool.blocked"),
274
+ toolName: import_zod4.z.string(),
275
+ agentName: import_zod4.z.string(),
276
+ policyName: import_zod4.z.string(),
277
+ reason: import_zod4.z.string()
278
+ });
279
+ var ToolCompletedEventSchema = TraceEventBaseSchema.extend({
280
+ type: import_zod4.z.literal("tool.completed"),
281
+ toolName: import_zod4.z.string(),
282
+ agentName: import_zod4.z.string(),
283
+ output: JsonValueSchema,
284
+ latencyMs: import_zod4.z.number().nonnegative()
285
+ });
286
+ var ToolFailedEventSchema = TraceEventBaseSchema.extend({
287
+ type: import_zod4.z.literal("tool.failed"),
288
+ toolName: import_zod4.z.string(),
289
+ agentName: import_zod4.z.string(),
290
+ error: TraceEventErrorSchema,
291
+ latencyMs: import_zod4.z.number().nonnegative()
292
+ });
293
+ var PolicyEvaluatedEventSchema = TraceEventBaseSchema.extend({
294
+ type: import_zod4.z.literal("policy.evaluated"),
295
+ policyName: import_zod4.z.string(),
296
+ action: PolicyActionSchema,
297
+ agentName: import_zod4.z.string().optional(),
298
+ toolName: import_zod4.z.string().optional(),
299
+ reason: import_zod4.z.string()
300
+ });
301
+ var RouteSelectedEventSchema = TraceEventBaseSchema.extend({
302
+ type: import_zod4.z.literal("route.selected"),
303
+ supervisorName: import_zod4.z.string(),
304
+ selectedAgentName: import_zod4.z.string(),
305
+ candidateAgentNames: import_zod4.z.array(import_zod4.z.string()),
306
+ reason: import_zod4.z.string()
307
+ });
308
+ var ApprovalRequiredEventSchema = TraceEventBaseSchema.extend({
309
+ type: import_zod4.z.literal("approval.required"),
310
+ approvalId: import_zod4.z.string(),
311
+ toolName: import_zod4.z.string().optional(),
312
+ agentName: import_zod4.z.string().optional(),
313
+ reason: import_zod4.z.string()
314
+ });
315
+ var ApprovalApprovedEventSchema = TraceEventBaseSchema.extend({
316
+ type: import_zod4.z.literal("approval.approved"),
317
+ approvalId: import_zod4.z.string(),
318
+ decidedBy: import_zod4.z.string().nullable()
319
+ });
320
+ var ApprovalRejectedEventSchema = TraceEventBaseSchema.extend({
321
+ type: import_zod4.z.literal("approval.rejected"),
322
+ approvalId: import_zod4.z.string(),
323
+ decidedBy: import_zod4.z.string().nullable(),
324
+ reason: import_zod4.z.string()
325
+ });
326
+ var EvalStartedEventSchema = TraceEventBaseSchema.extend({
327
+ type: import_zod4.z.literal("eval.started"),
328
+ evalRunId: import_zod4.z.string(),
329
+ suiteName: import_zod4.z.string(),
330
+ caseCount: import_zod4.z.number().int().nonnegative()
331
+ });
332
+ var EvalCompletedEventSchema = TraceEventBaseSchema.extend({
333
+ type: import_zod4.z.literal("eval.completed"),
334
+ evalRunId: import_zod4.z.string(),
335
+ passedCaseCount: import_zod4.z.number().int().nonnegative(),
336
+ failedCaseCount: import_zod4.z.number().int().nonnegative(),
337
+ latencyMs: import_zod4.z.number().nonnegative()
338
+ });
339
+ var ReplayStartedEventSchema = TraceEventBaseSchema.extend({
340
+ type: import_zod4.z.literal("replay.started"),
341
+ sourceRunId: import_zod4.z.string(),
342
+ fromEventId: import_zod4.z.string().nullable()
343
+ });
344
+ var ReplayCompletedEventSchema = TraceEventBaseSchema.extend({
345
+ type: import_zod4.z.literal("replay.completed"),
346
+ sourceRunId: import_zod4.z.string(),
347
+ latencyMs: import_zod4.z.number().nonnegative()
348
+ });
349
+ var TraceEventSchema = import_zod4.z.discriminatedUnion("type", [
350
+ RunStartedEventSchema,
351
+ RunCompletedEventSchema,
352
+ RunFailedEventSchema,
353
+ AgentStartedEventSchema,
354
+ AgentCompletedEventSchema,
355
+ AgentFailedEventSchema,
356
+ ToolRequestedEventSchema,
357
+ ToolApprovedEventSchema,
358
+ ToolBlockedEventSchema,
359
+ ToolCompletedEventSchema,
360
+ ToolFailedEventSchema,
361
+ PolicyEvaluatedEventSchema,
362
+ RouteSelectedEventSchema,
363
+ ApprovalRequiredEventSchema,
364
+ ApprovalApprovedEventSchema,
365
+ ApprovalRejectedEventSchema,
366
+ EvalStartedEventSchema,
367
+ EvalCompletedEventSchema,
368
+ ReplayStartedEventSchema,
369
+ ReplayCompletedEventSchema
370
+ ]);
371
+ var traceEventTypes = TraceEventSchema.options.map(
372
+ (option) => option.shape.type.value
373
+ );
374
+ // Annotate the CommonJS export names for ESM import in node:
375
+ 0 && (module.exports = {
376
+ AgentCompletedEventSchema,
377
+ AgentFailedEventSchema,
378
+ AgentStartedEventSchema,
379
+ ApprovalApprovedEventSchema,
380
+ ApprovalRejectedEventSchema,
381
+ ApprovalRequiredEventSchema,
382
+ EvalCompletedEventSchema,
383
+ EvalStartedEventSchema,
384
+ PolicyEvaluatedEventSchema,
385
+ ReplayCompletedEventSchema,
386
+ ReplayStartedEventSchema,
387
+ RouteSelectedEventSchema,
388
+ RunCompletedEventSchema,
389
+ RunFailedEventSchema,
390
+ RunStartedEventSchema,
391
+ ToolApprovedEventSchema,
392
+ ToolBlockedEventSchema,
393
+ ToolCompletedEventSchema,
394
+ ToolFailedEventSchema,
395
+ ToolRequestedEventSchema,
396
+ TraceEventErrorSchema,
397
+ TraceEventSchema,
398
+ traceEventTypes
399
+ });