@sentry/junior 0.182.0 → 0.183.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 (86) hide show
  1. package/dist/{agent-hooks-3S25UIHO.js → agent-hooks-SNRBZYAU.js} +11 -11
  2. package/dist/api/code/overview.d.ts +35 -0
  3. package/dist/api/code/routes.d.ts +4 -0
  4. package/dist/api/schema/code.d.ts +75 -0
  5. package/dist/api/schema.d.ts +2 -0
  6. package/dist/api/schema.js +9 -1
  7. package/dist/api.js +258 -134
  8. package/dist/app.js +71 -48
  9. package/dist/{catalog-runtime-ESLMBQBV.js → catalog-runtime-3I3JOIIH.js} +4 -4
  10. package/dist/chat/agent-invocations/store.d.ts +4 -2
  11. package/dist/chat/agent-invocations/work.d.ts +1 -3
  12. package/dist/chat/app/factory.d.ts +3 -3
  13. package/dist/chat/app/services.d.ts +3 -3
  14. package/dist/chat/code/publisher.d.ts +3 -0
  15. package/dist/chat/code/store.d.ts +9 -0
  16. package/dist/chat/event-tasks/store.d.ts +10 -0
  17. package/dist/chat/ingress/slack-webhook.d.ts +1 -1
  18. package/dist/chat/plugins/agent-hooks.d.ts +5 -0
  19. package/dist/chat/{runtime/slack-runtime.d.ts → providers/slack/runtime.d.ts} +2 -2
  20. package/dist/chat/{runtime/reply-executor.d.ts → providers/slack/turn.d.ts} +10 -9
  21. package/dist/chat/resource-events/store.d.ts +12 -0
  22. package/dist/chat/runtime/turn-execution.d.ts +30 -0
  23. package/dist/chat/slack/dispatch-turn.d.ts +12 -14
  24. package/dist/chat/task-execution/slack-work.d.ts +1 -1
  25. package/dist/{chunk-SXOZIG5X.js → chunk-24OJZ5OU.js} +6 -6
  26. package/dist/{chunk-SVFSYQMT.js → chunk-2ADFGSUS.js} +1 -1
  27. package/dist/{chunk-GGYA5NPN.js → chunk-2EPYYVJC.js} +8 -8
  28. package/dist/{chunk-KGMHUDVF.js → chunk-35PM4YY5.js} +6 -6
  29. package/dist/{chunk-3ENUMZNG.js → chunk-37IQ6DGU.js} +3 -3
  30. package/dist/{chunk-3THPTNN6.js → chunk-3HJ4F4L7.js} +4 -4
  31. package/dist/{chunk-3NFHI2NA.js → chunk-3L7CWDQQ.js} +1 -1
  32. package/dist/{chunk-CVBIM4Z3.js → chunk-4WGFWHWP.js} +1 -1
  33. package/dist/{chunk-YHL2L2ZZ.js → chunk-56XONJPF.js} +1 -1
  34. package/dist/{chunk-44BQ3TSK.js → chunk-6UXDTPEN.js} +233 -173
  35. package/dist/{chunk-2CEOXDG2.js → chunk-AHMWPFIW.js} +174 -6
  36. package/dist/{chunk-6TSWXBTQ.js → chunk-AX3UDIMA.js} +3 -3
  37. package/dist/{chunk-S35OZMSL.js → chunk-AYW7J6K4.js} +13 -13
  38. package/dist/{chunk-WOIALVN2.js → chunk-E3OBGRHN.js} +1 -1
  39. package/dist/{chunk-4DZ62L36.js → chunk-EENQGEIP.js} +1 -1
  40. package/dist/{chunk-UUMBHORH.js → chunk-FJMTMGBC.js} +1 -1
  41. package/dist/{chunk-Z7ALSQS3.js → chunk-G2B2XZQW.js} +1 -1
  42. package/dist/{chunk-TEFNHMO2.js → chunk-HUK5XIZL.js} +4 -4
  43. package/dist/{chunk-LT4QYGKM.js → chunk-IO6KFXYE.js} +160 -97
  44. package/dist/{chunk-JIOKUIAS.js → chunk-KTXOGLNE.js} +2 -2
  45. package/dist/{chunk-LHQK5XCU.js → chunk-LMNMMESF.js} +2 -2
  46. package/dist/{chunk-UQP54CXZ.js → chunk-LZBPGX5A.js} +1 -1
  47. package/dist/{chunk-PQES5LB5.js → chunk-PLZT45VC.js} +5 -5
  48. package/dist/{chunk-V5UZCCNW.js → chunk-QI5JW5AG.js} +6 -6
  49. package/dist/{chunk-A7THOQ6N.js → chunk-QZV76CM4.js} +21 -21
  50. package/dist/{chunk-LB4FWMCV.js → chunk-R767Y7QV.js} +183 -155
  51. package/dist/{chunk-MJISSOWB.js → chunk-SQHFVIMZ.js} +1 -1
  52. package/dist/{chunk-BDDWVY32.js → chunk-T5MTGX2E.js} +19 -19
  53. package/dist/{chunk-DZR3L74W.js → chunk-V64JCZUV.js} +3 -3
  54. package/dist/{chunk-VHMAFMHB.js → chunk-VOV3SCM3.js} +1 -1
  55. package/dist/{chunk-BZD4ADQH.js → chunk-W46NIB5H.js} +1 -1
  56. package/dist/{chunk-QHALFHZA.js → chunk-W5JMPEBO.js} +9 -9
  57. package/dist/{chunk-D6OHGAIO.js → chunk-WOKJRLM2.js} +5 -5
  58. package/dist/chunk-WVIA7V3M.js +975 -0
  59. package/dist/{chunk-UKIHNBBD.js → chunk-X52ESOBP.js} +3 -3
  60. package/dist/cli/chat.js +33 -35
  61. package/dist/cli/check.js +5 -5
  62. package/dist/cli/plugins.js +12 -12
  63. package/dist/cli/snapshot-create.js +9 -9
  64. package/dist/cli/upgrade.js +6 -6
  65. package/dist/db/schema/code.d.ts +367 -0
  66. package/dist/db/schema.d.ts +367 -1
  67. package/dist/{db-NYIWZ4L5.js → db-K2VMNLHQ.js} +6 -6
  68. package/dist/instrumentation.js +3 -3
  69. package/dist/nitro.js +6 -6
  70. package/dist/{oauth-callback-server-A2YTPVVX.js → oauth-callback-server-DZZMTKSS.js} +25 -25
  71. package/dist/{runner-VKAEU52J.js → runner-IIAKWDXI.js} +18 -18
  72. package/dist/{skills-52GMXUTY.js → skills-EXIQ7BP5.js} +5 -5
  73. package/dist/spawn-ZR6OOEAN.js +37 -0
  74. package/dist/task-runner-C52HYCVD.js +32 -0
  75. package/dist/{validation-VD2YQX2W.js → validation-XUGIWBJF.js} +5 -5
  76. package/dist/version.js +1 -1
  77. package/dist/{work-ZWBTGEQP.js → work-G4RLJ634.js} +18 -18
  78. package/dist/worker-R2JEHK67.js +22 -0
  79. package/migrations/0036_complex_rage.sql +32 -0
  80. package/migrations/meta/0036_snapshot.json +3186 -0
  81. package/migrations/meta/_journal.json +8 -1
  82. package/package.json +6 -6
  83. package/dist/chunk-CZYNWPWD.js +0 -930
  84. package/dist/spawn-GSS4EBLR.js +0 -37
  85. package/dist/task-runner-DUGDWF5O.js +0 -32
  86. package/dist/worker-XUWD5WS7.js +0 -22
@@ -1,930 +0,0 @@
1
- import {
2
- usageSchema
3
- } from "./chunk-PDO5BLNM.js";
4
- import {
5
- juniorDestinationKindSchema
6
- } from "./chunk-VFUK3X5B.js";
7
-
8
- // src/api/activity.ts
9
- import { z } from "zod";
10
- var dailyConversationActivitySchema = z.object({
11
- active: z.number(),
12
- conversations: z.number(),
13
- date: z.string(),
14
- durationMs: z.number(),
15
- failed: z.number(),
16
- tokens: z.number().optional()
17
- }).strict();
18
- function emptyActivityDay(date) {
19
- return {
20
- active: 0,
21
- conversations: 0,
22
- date,
23
- durationMs: 0,
24
- failed: 0
25
- };
26
- }
27
- function activityDays(days, nowMs, count) {
28
- const items = [];
29
- const end = new Date(nowMs);
30
- end.setUTCHours(0, 0, 0, 0);
31
- const start = new Date(end);
32
- start.setUTCDate(start.getUTCDate() - (count - 1));
33
- for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setUTCDate(cursor.getUTCDate() + 1)) {
34
- const date = cursor.toISOString().slice(0, 10);
35
- items.push(days.get(date) ?? emptyActivityDay(date));
36
- }
37
- return items;
38
- }
39
-
40
- // src/api/schema/conversation.ts
41
- import { z as z2 } from "zod";
42
- import {
43
- conversationAnnotationInputSchema,
44
- conversationSidebarAnnotationSchema,
45
- conversationEventPresentationSchema
46
- } from "@sentry/junior-plugin-api";
47
- var conversationReportStatusSchema = z2.enum([
48
- "active",
49
- "completed",
50
- "failed"
51
- ]);
52
- var conversationSurfaceSchema = z2.enum([
53
- "api",
54
- "internal",
55
- "scheduler",
56
- "slack"
57
- ]);
58
- var conversationUsageSchema = usageSchema;
59
- var conversationParamsSchema = z2.object({ conversationId: z2.string().min(1) }).strict();
60
- var conversationAttachmentParamsSchema = z2.object({
61
- attachmentId: z2.string().min(1),
62
- conversationId: z2.string().min(1)
63
- }).strict();
64
- var conversationDetailQuerySchema = z2.object({
65
- limit: z2.coerce.number().int().min(1).max(1e3).default(500)
66
- }).strict();
67
- var conversationEventsQuerySchema = z2.object({
68
- before: z2.string().min(1),
69
- limit: z2.coerce.number().int().min(1).max(1e3).default(500)
70
- }).strict();
71
- var conversationFeedQuerySchema = z2.object({
72
- actorEmail: z2.string().trim().email().transform((value) => value.toLowerCase()).optional(),
73
- status: z2.enum(["active", "archived"]).default("active")
74
- }).strict();
75
- var archiveConversationBodySchema = z2.object({ archived: z2.boolean(), lastSeenAt: z2.string().datetime() }).strict();
76
- var archiveConversationResponseSchema = z2.object({ archivedAt: z2.string().datetime().nullable() }).strict();
77
- var createConversationBodySchema = z2.object({
78
- idempotencyKey: z2.string().trim().min(1).max(200),
79
- message: z2.string().trim().min(1).max(32e3),
80
- /** New roots default public. Private roots stay participant-only. */
81
- visibility: z2.enum(["private", "public"]).optional()
82
- }).strict();
83
- var createConversationMessageBodySchema = z2.object({
84
- idempotencyKey: z2.string().trim().min(1).max(200),
85
- message: z2.string().trim().min(1).max(32e3)
86
- }).strict();
87
- var acceptedConversationMessageSchema = z2.object({
88
- conversationId: z2.string().min(1),
89
- messageId: z2.string().min(1),
90
- status: z2.enum(["accepted", "duplicate"])
91
- }).strict();
92
- var actorIdentitySchema = z2.object({
93
- email: z2.string().optional(),
94
- fullName: z2.string().optional(),
95
- slackUserId: z2.string().optional(),
96
- slackUserName: z2.string().optional()
97
- }).strict();
98
- var conversationPendingMessageDeliverySchema = z2.enum([
99
- "defer",
100
- "interrupt"
101
- ]);
102
- var conversationPendingMessageSchema = z2.object({
103
- actorIdentity: actorIdentitySchema.optional(),
104
- createdAt: z2.string().datetime(),
105
- delivery: conversationPendingMessageDeliverySchema,
106
- inboundMessageId: z2.string().min(1),
107
- messageId: z2.string().min(1),
108
- receivedAt: z2.string().datetime(),
109
- role: z2.literal("user"),
110
- source: z2.enum(["slack", "web"]),
111
- text: z2.string().optional(),
112
- redacted: z2.literal(true).optional()
113
- }).strict().superRefine((data, context) => {
114
- if (data.text === void 0 === (data.redacted !== true)) {
115
- context.addIssue({
116
- code: "custom",
117
- message: "pending message content must be text or explicitly redacted"
118
- });
119
- }
120
- if (data.redacted && data.actorIdentity) {
121
- context.addIssue({
122
- code: "custom",
123
- message: "redacted pending messages must not expose actor identity"
124
- });
125
- }
126
- });
127
- var conversationPendingAuthorizationSchema = z2.object({
128
- authorizationUrl: z2.string().url(),
129
- completionText: z2.string().min(1),
130
- label: z2.string().min(1)
131
- }).strict();
132
- var conversationPendingMessagesReportSchema = z2.object({
133
- authorization: conversationPendingAuthorizationSchema.optional(),
134
- conversationId: z2.string().min(1),
135
- generatedAt: z2.string().datetime(),
136
- messages: z2.array(conversationPendingMessageSchema)
137
- }).strict();
138
- var cancelConversationPendingMessagesBodySchema = z2.object({
139
- inboundMessageIds: z2.array(z2.string().min(1)).min(1).optional(),
140
- receivedBefore: z2.string().datetime().optional()
141
- }).strict();
142
- var cancelConversationPendingMessagesResponseSchema = z2.object({
143
- cancelledCount: z2.number().int().nonnegative(),
144
- cancelledInboundMessageIds: z2.array(z2.string().min(1)),
145
- conversationId: z2.string().min(1)
146
- }).strict();
147
- var conversationAuxiliaryCostsSchema = z2.object({
148
- costUsd: z2.number().finite().nonnegative(),
149
- operations: z2.array(
150
- z2.object({
151
- costUsd: z2.number().finite().nonnegative(),
152
- events: z2.number().int().positive(),
153
- name: z2.string().min(1),
154
- namespace: z2.string().min(1)
155
- }).strict()
156
- ).min(1)
157
- }).strict();
158
- var conversationSourceTaskSchema = z2.object({
159
- id: z2.string().min(1).optional(),
160
- kind: z2.enum(["scheduled", "event"]),
161
- label: z2.string().min(1).optional(),
162
- title: z2.string().min(1).optional()
163
- }).strict().superRefine((value, context) => {
164
- if (Boolean(value.id) !== Boolean(value.label)) {
165
- context.addIssue({
166
- code: "custom",
167
- message: "sourceTask id and label must both be set or both omitted"
168
- });
169
- }
170
- });
171
- var conversationAnnotationReportSchema = conversationAnnotationInputSchema.and(
172
- z2.object({
173
- plugin: z2.string().min(1),
174
- createdAt: z2.string().datetime(),
175
- updatedAt: z2.string().datetime()
176
- })
177
- );
178
- var conversationSummaryReportSchema = z2.object({
179
- displayTitle: z2.string(),
180
- cumulativeDurationMs: z2.number(),
181
- cumulativeUsage: conversationUsageSchema.optional(),
182
- auxiliaryCosts: conversationAuxiliaryCostsSchema.optional(),
183
- conversationId: z2.string(),
184
- isParticipant: z2.boolean(),
185
- visibility: z2.enum(["private", "public"]).optional(),
186
- status: conversationReportStatusSchema,
187
- startedAt: z2.string(),
188
- lastSeenAt: z2.string(),
189
- lastProgressAt: z2.string(),
190
- surface: conversationSurfaceSchema,
191
- actorIdentity: actorIdentitySchema.optional(),
192
- archivedAt: z2.string().datetime().nullable().optional(),
193
- channel: z2.string().optional(),
194
- channelName: z2.string().optional(),
195
- channelNameRedacted: z2.boolean().optional(),
196
- locationId: z2.string().optional(),
197
- sentryTraceUrl: z2.string().optional(),
198
- sourceUrl: z2.string().url().optional(),
199
- traceId: z2.string().optional(),
200
- /**
201
- * Plugin-owned resource links for this conversation.
202
- * Present on the conversation feed when the viewer can see private content.
203
- * Clients must not fetch provider state while rendering these links.
204
- */
205
- annotations: z2.array(conversationAnnotationReportSchema).optional(),
206
- /** Plugin-selected annotations for the compact conversation row. */
207
- sidebarAnnotations: z2.array(conversationSidebarAnnotationSchema).optional(),
208
- assignedWork: z2.boolean().optional(),
209
- finishedWorkAt: z2.string().datetime().optional(),
210
- /**
211
- * Dashboard Priority membership for this conversation summary.
212
- * Present on the conversation feed. Clients must not recompute it.
213
- *
214
- * True only when:
215
- * - unfinished work was last seen within 48 hours
216
- * - finished assigned work has conversation activity after the finish time
217
- * - there is no known work and the conversation was last seen within 3 hours
218
- */
219
- isPriority: z2.boolean().optional(),
220
- unfinishedWork: z2.boolean().optional()
221
- }).strict();
222
- var conversationReportMessageEventDataSchema = z2.object({
223
- type: z2.literal("message"),
224
- messageId: z2.string().min(1),
225
- role: z2.enum(["assistant", "system", "user"]),
226
- source: z2.enum(["slack", "web"]).optional(),
227
- actorIdentity: actorIdentitySchema.optional(),
228
- eventType: z2.string().min(1).optional(),
229
- explicitMention: z2.boolean().optional(),
230
- text: z2.string().optional(),
231
- redacted: z2.literal(true).optional()
232
- }).strict().superRefine((data, context) => {
233
- if (data.text === void 0 === (data.redacted !== true)) {
234
- context.addIssue({
235
- code: "custom",
236
- message: "message content must be text or explicitly redacted"
237
- });
238
- }
239
- if (data.redacted && data.actorIdentity) {
240
- context.addIssue({
241
- code: "custom",
242
- message: "redacted messages must not expose actor identity"
243
- });
244
- }
245
- });
246
- var conversationReportMessageHandledEventDataSchema = z2.object({
247
- type: z2.literal("message_handled"),
248
- messageId: z2.string().min(1)
249
- }).strict();
250
- var conversationReportToolCallSchema = z2.object({
251
- toolCallId: z2.string().min(1),
252
- name: z2.string().min(1),
253
- status: z2.enum(["running", "completed", "error"]),
254
- startedAt: z2.string().datetime().optional(),
255
- startedSeq: z2.number().int().nonnegative().optional(),
256
- input: z2.unknown().optional(),
257
- output: z2.unknown().optional()
258
- }).strict().superRefine((call, context) => {
259
- if (call.startedAt === void 0 !== (call.startedSeq === void 0)) {
260
- context.addIssue({
261
- code: "custom",
262
- message: "tool start sequence and timestamp must be provided together"
263
- });
264
- }
265
- });
266
- var conversationReportReasoningPartSchema = z2.object({
267
- type: z2.literal("reasoning"),
268
- text: z2.string().min(1).optional(),
269
- redacted: z2.literal(true).optional()
270
- }).strict().superRefine((data, context) => {
271
- if (data.text === void 0 === (data.redacted !== true)) {
272
- context.addIssue({
273
- code: "custom",
274
- message: "reasoning content must be text or explicitly redacted"
275
- });
276
- }
277
- });
278
- var conversationReportAssistantToolCallPartSchema = z2.object({
279
- type: z2.literal("tool_call"),
280
- toolCallId: z2.string().min(1)
281
- }).strict();
282
- var conversationReportAssistantMetadataSchema = z2.object({
283
- parts: z2.array(
284
- z2.discriminatedUnion("type", [
285
- conversationReportReasoningPartSchema,
286
- conversationReportAssistantToolCallPartSchema
287
- ])
288
- ).min(1)
289
- }).strict();
290
- var conversationReportToolCallsEventDataSchema = z2.object({
291
- type: z2.literal("tool_calls"),
292
- calls: z2.array(conversationReportToolCallSchema).min(1),
293
- assistant: conversationReportAssistantMetadataSchema.optional()
294
- }).strict().superRefine((data, context) => {
295
- if (!data.assistant) return;
296
- const callCounts = /* @__PURE__ */ new Map();
297
- for (const call of data.calls) {
298
- callCounts.set(
299
- call.toolCallId,
300
- (callCounts.get(call.toolCallId) ?? 0) + 1
301
- );
302
- }
303
- const partCounts = /* @__PURE__ */ new Map();
304
- for (const part of data.assistant.parts) {
305
- if (part.type !== "tool_call") continue;
306
- partCounts.set(
307
- part.toolCallId,
308
- (partCounts.get(part.toolCallId) ?? 0) + 1
309
- );
310
- }
311
- if (callCounts.size !== partCounts.size || [...callCounts].some(
312
- ([toolCallId, count]) => partCounts.get(toolCallId) !== count
313
- )) {
314
- context.addIssue({
315
- code: "custom",
316
- path: ["assistant", "parts"],
317
- message: "assistant tool parts must reference every call exactly once"
318
- });
319
- }
320
- });
321
- var conversationReportAssistantMessageEventDataSchema = z2.object({
322
- type: z2.literal("assistant_message"),
323
- parts: z2.array(conversationReportReasoningPartSchema).min(1)
324
- }).strict();
325
- var conversationReportTurnLifecycleEventDataSchema = z2.discriminatedUnion(
326
- "state",
327
- [
328
- z2.object({
329
- type: z2.literal("turn_lifecycle"),
330
- turnId: z2.string().min(1),
331
- state: z2.enum(["succeeded", "no_reply"])
332
- }).strict(),
333
- z2.object({
334
- type: z2.literal("turn_lifecycle"),
335
- turnId: z2.string().min(1),
336
- state: z2.literal("started"),
337
- inputMessageIds: z2.array(z2.string().min(1)).min(1).optional()
338
- }).strict(),
339
- z2.object({
340
- type: z2.literal("turn_lifecycle"),
341
- turnId: z2.string().min(1),
342
- state: z2.literal("failed"),
343
- failureKind: z2.enum(["agent", "delivery"])
344
- }).strict()
345
- ]
346
- );
347
- var conversationReportTurnRoutedEventDataSchema = z2.object({
348
- type: z2.literal("turn_routed"),
349
- turnId: z2.string().min(1),
350
- modelProfile: z2.string().min(1),
351
- modelId: z2.string().min(1),
352
- costUsd: z2.number().finite().nonnegative().optional(),
353
- reasoningLevel: z2.string().min(1),
354
- confidence: z2.number().min(0).max(1).optional(),
355
- source: z2.enum(["configured", "inherited", "router"])
356
- }).strict();
357
- var conversationReportGuardianActionReviewedEventDataSchema = z2.object({
358
- type: z2.literal("guardian_action_reviewed"),
359
- turnId: z2.string().min(1),
360
- toolCallId: z2.string().min(1),
361
- toolName: z2.string().min(1),
362
- decision: z2.enum(["allow", "ask", "deny"]),
363
- riskLevel: z2.enum(["low", "medium", "high", "critical"]),
364
- userAuthorization: z2.enum(["high", "medium", "low", "unknown"])
365
- }).strict();
366
- var conversationReportTurnContextEventDataSchema = z2.object({
367
- type: z2.literal("turn_context"),
368
- turnId: z2.string().min(1),
369
- pluginName: z2.string().min(1),
370
- kind: z2.string().min(1),
371
- version: z2.number().int().positive(),
372
- content: z2.record(z2.string(), z2.unknown())
373
- }).strict();
374
- var conversationReportStructuredEventDataSchema = z2.object({
375
- type: z2.literal("structured_event"),
376
- namespace: z2.string().min(1),
377
- name: z2.string().min(1),
378
- version: z2.number().int().positive(),
379
- turnId: z2.string().min(1).optional(),
380
- presentation: conversationEventPresentationSchema
381
- }).strict();
382
- var conversationReportDeliveredAttachmentSchema = z2.object({
383
- id: z2.string().min(1),
384
- filename: z2.string().min(1),
385
- contentType: z2.string().min(1),
386
- bytes: z2.number().int().nonnegative()
387
- }).strict();
388
- var conversationReportAttachmentsDeliveredEventDataSchema = z2.object({
389
- type: z2.literal("attachments_delivered"),
390
- attachments: z2.array(conversationReportDeliveredAttachmentSchema).min(1)
391
- }).strict();
392
- var conversationReportCompactionEventDataSchema = z2.object({
393
- type: z2.literal("compaction"),
394
- modelProfile: z2.string().min(1).optional(),
395
- modelId: z2.string().min(1).optional(),
396
- summary: z2.string().min(1).optional(),
397
- details: z2.object({
398
- reason: z2.literal("capacity"),
399
- estimatedInputTokens: z2.number().int().nonnegative(),
400
- replacementInputTokens: z2.number().int().nonnegative().optional(),
401
- triggerTokens: z2.number().int().nonnegative(),
402
- inputLimitTokens: z2.number().int().positive(),
403
- inputMessageCount: z2.number().int().nonnegative(),
404
- retainedMessageCount: z2.number().int().nonnegative(),
405
- summaryChars: z2.number().int().nonnegative()
406
- }).strict().optional()
407
- }).strict();
408
- var conversationReportHandoffEventDataSchema = z2.object({
409
- type: z2.literal("handoff"),
410
- modelProfile: z2.string().min(1),
411
- modelId: z2.string().min(1),
412
- reasoningLevel: z2.string().min(1).optional(),
413
- triggeringToolCallId: z2.string().min(1).optional(),
414
- summary: z2.string().min(1).optional()
415
- }).strict();
416
- var conversationReportSubagentEventDataSchema = z2.object({
417
- type: z2.literal("subagent"),
418
- startedSeq: z2.number().int().nonnegative(),
419
- startedAt: z2.string().datetime(),
420
- childConversationId: z2.string().min(1),
421
- subagentKind: z2.string().min(1),
422
- parentToolCallId: z2.string().min(1).optional(),
423
- status: z2.enum(["running", "completed", "error", "aborted"])
424
- }).strict();
425
- var conversationReportEventDataSchema = z2.discriminatedUnion("type", [
426
- conversationReportMessageEventDataSchema,
427
- conversationReportMessageHandledEventDataSchema,
428
- conversationReportAssistantMessageEventDataSchema,
429
- conversationReportToolCallsEventDataSchema,
430
- conversationReportTurnLifecycleEventDataSchema,
431
- conversationReportTurnContextEventDataSchema,
432
- conversationReportStructuredEventDataSchema,
433
- conversationReportAttachmentsDeliveredEventDataSchema,
434
- conversationReportTurnRoutedEventDataSchema,
435
- conversationReportGuardianActionReviewedEventDataSchema,
436
- conversationReportCompactionEventDataSchema,
437
- conversationReportHandoffEventDataSchema,
438
- conversationReportSubagentEventDataSchema
439
- ]);
440
- var conversationReportEventSchema = z2.object({
441
- seq: z2.number().int().nonnegative(),
442
- createdAt: z2.string().datetime(),
443
- data: conversationReportEventDataSchema
444
- }).strict();
445
- var conversationEventHistorySchema = z2.discriminatedUnion("status", [
446
- z2.object({ status: z2.literal("available") }).strict(),
447
- z2.object({
448
- status: z2.literal("redacted"),
449
- reason: z2.literal("non_public_conversation")
450
- }).strict(),
451
- z2.object({
452
- status: z2.literal("expired"),
453
- expiredAt: z2.string().datetime()
454
- }).strict()
455
- ]);
456
- var conversationModelUsageSchema = z2.object({
457
- modelId: z2.string(),
458
- usage: conversationUsageSchema
459
- }).strict();
460
- function validateConversationEvents(report, context) {
461
- if (report.eventHistory.status === "expired" && report.events.length > 0) {
462
- context.addIssue({
463
- code: "custom",
464
- path: ["events"],
465
- message: "expired event history must not contain events"
466
- });
467
- }
468
- for (let index = 1; index < report.events.length; index += 1) {
469
- if (report.events[index].seq <= report.events[index - 1].seq) {
470
- context.addIssue({
471
- code: "custom",
472
- path: ["events", index, "seq"],
473
- message: "report event sequences must be strictly increasing"
474
- });
475
- }
476
- }
477
- for (const [index, event] of report.events.entries()) {
478
- if (event.data.type === "message") {
479
- if (report.eventHistory.status === "redacted" && event.data.redacted !== true) {
480
- context.addIssue({
481
- code: "custom",
482
- path: ["events", index, "data"],
483
- message: "redacted event history must redact messages"
484
- });
485
- }
486
- if (report.eventHistory.status === "available" && event.data.redacted === true) {
487
- context.addIssue({
488
- code: "custom",
489
- path: ["events", index, "data"],
490
- message: "available event history must expose messages"
491
- });
492
- }
493
- }
494
- if (report.eventHistory.status === "redacted" && event.data.type === "tool_calls" && event.data.calls.some(
495
- (call) => call.input !== void 0 || call.output !== void 0
496
- )) {
497
- context.addIssue({
498
- code: "custom",
499
- path: ["events", index, "data"],
500
- message: "redacted event history must redact tool payloads"
501
- });
502
- }
503
- if (report.eventHistory.status === "redacted" && event.data.type === "assistant_message" && event.data.parts.some((part) => part.text !== void 0)) {
504
- context.addIssue({
505
- code: "custom",
506
- path: ["events", index, "data"],
507
- message: "redacted event history must redact assistant messages"
508
- });
509
- }
510
- if (report.eventHistory.status === "available" && event.data.type === "assistant_message" && event.data.parts.some((part) => part.redacted === true)) {
511
- context.addIssue({
512
- code: "custom",
513
- path: ["events", index, "data"],
514
- message: "available event history must expose reasoning"
515
- });
516
- }
517
- if (event.data.type === "tool_calls" && (report.eventHistory.status === "redacted" && event.data.assistant?.parts.some(
518
- (part) => part.type === "reasoning" && part.text !== void 0
519
- ) || report.eventHistory.status === "available" && event.data.assistant?.parts.some(
520
- (part) => part.type === "reasoning" && part.redacted === true
521
- ))) {
522
- context.addIssue({
523
- code: "custom",
524
- path: ["events", index, "data", "assistant"],
525
- message: "assistant reasoning must match event history visibility"
526
- });
527
- }
528
- }
529
- }
530
- var conversationDetailReportSchema = conversationSummaryReportSchema.extend({
531
- modelUsage: z2.array(conversationModelUsageSchema).optional(),
532
- events: z2.array(conversationReportEventSchema),
533
- eventHistory: conversationEventHistorySchema,
534
- previousCursor: z2.string().min(1).optional(),
535
- generatedAt: z2.string(),
536
- sentryConversationUrl: z2.string().optional(),
537
- sourceTask: conversationSourceTaskSchema.optional()
538
- }).strict().superRefine(validateConversationEvents);
539
- var conversationEventPageSchema = z2.object({
540
- events: z2.array(conversationReportEventSchema),
541
- eventHistory: conversationEventHistorySchema,
542
- previousCursor: z2.string().min(1).optional(),
543
- generatedAt: z2.string()
544
- }).strict().superRefine(validateConversationEvents);
545
- var conversationFeedSchema = z2.object({
546
- conversations: z2.array(conversationSummaryReportSchema),
547
- source: z2.literal("conversation_index"),
548
- generatedAt: z2.string()
549
- }).strict();
550
- var conversationStatsItemSchema = z2.object({
551
- active: z2.number(),
552
- conversations: z2.number(),
553
- durationMs: z2.number(),
554
- failed: z2.number(),
555
- label: z2.string(),
556
- costUsd: z2.number().optional(),
557
- tokens: z2.number().optional()
558
- }).strict();
559
- var conversationMetricDaySchema = z2.object({
560
- cachedInputTokens: z2.number().optional(),
561
- conversations: z2.number(),
562
- costUsd: z2.number().optional(),
563
- date: z2.string(),
564
- durationMs: z2.number(),
565
- inputTokens: z2.number().optional(),
566
- tokens: z2.number().optional()
567
- }).strict();
568
- var guardianMetricDaySchema = z2.object({
569
- allow: z2.number(),
570
- ask: z2.number(),
571
- costUsd: z2.number().optional(),
572
- date: z2.string(),
573
- deny: z2.number(),
574
- requests: z2.number()
575
- }).strict();
576
- var guardianStatsSchema = z2.object({
577
- allow: z2.number(),
578
- ask: z2.number(),
579
- costUsd: z2.number().optional(),
580
- deny: z2.number(),
581
- metricDays: z2.array(guardianMetricDaySchema),
582
- requests: z2.number()
583
- }).strict();
584
- var conversationStatsReportSchema = z2.object({
585
- active: z2.number(),
586
- cachedInputTokens: z2.number().optional(),
587
- conversations: z2.number(),
588
- durationMs: z2.number(),
589
- failed: z2.number(),
590
- generatedAt: z2.string(),
591
- guardian: guardianStatsSchema,
592
- metricDays: z2.array(conversationMetricDaySchema),
593
- locations: z2.array(conversationStatsItemSchema),
594
- actors: z2.array(conversationStatsItemSchema),
595
- source: z2.literal("conversation_index"),
596
- costUsd: z2.number().optional(),
597
- inputTokens: z2.number().optional(),
598
- tokens: z2.number().optional(),
599
- windowEnd: z2.string(),
600
- windowStart: z2.string()
601
- }).strict();
602
-
603
- // src/api/schema/person.ts
604
- import { z as z3 } from "zod";
605
- var personParamsSchema = z3.object({ email: z3.string().trim().min(1) }).strict();
606
- var peopleConversationStatsItemSchema = conversationStatsItemSchema.omit({ costUsd: true });
607
- var actorActivityDayReportSchema = z3.object({
608
- active: z3.number(),
609
- conversations: z3.number(),
610
- costUsd: z3.number().optional(),
611
- date: z3.string(),
612
- durationMs: z3.number(),
613
- failed: z3.number(),
614
- tokens: z3.number().optional()
615
- }).strict();
616
- var peopleActivityDayReportSchema = z3.object({
617
- activePeople: z3.number(),
618
- conversations: z3.number(),
619
- date: z3.string()
620
- }).strict();
621
- var actorTotalsReportSchema = z3.object({
622
- active: z3.number(),
623
- activeDays: z3.number(),
624
- conversations: z3.number(),
625
- durationMs: z3.number(),
626
- failed: z3.number(),
627
- tokens: z3.number().optional()
628
- }).strict();
629
- var identifiedActorSchema = actorIdentitySchema.extend({ email: z3.string().min(1) }).strict();
630
- var actorSummaryReportSchema = actorTotalsReportSchema.extend({
631
- firstSeenAt: z3.string(),
632
- lastSeenAt: z3.string(),
633
- actor: identifiedActorSchema
634
- }).strict();
635
- var actorDirectoryReportSchema = z3.object({
636
- activityDays: z3.array(peopleActivityDayReportSchema),
637
- generatedAt: z3.string(),
638
- people: z3.array(actorSummaryReportSchema),
639
- source: z3.literal("conversation_index"),
640
- windowEnd: z3.string(),
641
- windowStart: z3.string()
642
- }).strict();
643
- var actorProfileReportSchema = z3.object({
644
- activityDays: z3.array(actorActivityDayReportSchema),
645
- generatedAt: z3.string(),
646
- locations: z3.array(peopleConversationStatsItemSchema),
647
- recentConversations: z3.array(conversationSummaryReportSchema),
648
- actor: identifiedActorSchema,
649
- source: z3.literal("conversation_index"),
650
- surfaces: z3.array(peopleConversationStatsItemSchema),
651
- totals: actorTotalsReportSchema,
652
- windowEnd: z3.string(),
653
- windowStart: z3.string()
654
- }).strict();
655
- var personalSpendReportSchema = z3.object({
656
- generatedAt: z3.string(),
657
- sevenDaysUsd: z3.number().finite().nonnegative(),
658
- source: z3.literal("conversation_index"),
659
- thirtyDaysUsd: z3.number().finite().nonnegative(),
660
- windowEnd: z3.string(),
661
- windowStart: z3.string()
662
- }).strict();
663
-
664
- // src/api/schema/location.ts
665
- import { z as z4 } from "zod";
666
- var locationParamsSchema = z4.object({ locationId: z4.string().min(1) }).strict();
667
- var locationSummaryReportSchema = conversationStatsItemSchema.extend({
668
- id: z4.string(),
669
- firstSeenAt: z4.string(),
670
- kind: juniorDestinationKindSchema,
671
- lastSeenAt: z4.string(),
672
- provider: z4.string(),
673
- providerDestinationId: z4.string(),
674
- visibility: z4.literal("public")
675
- }).strict();
676
- var locationActorSummaryReportSchema = conversationStatsItemSchema.extend({ actor: actorIdentitySchema }).strict();
677
- var locationActivityDayReportSchema = z4.object({
678
- date: z4.string(),
679
- privateConversations: z4.number(),
680
- publicConversations: z4.number()
681
- }).strict();
682
- var locationDirectoryReportSchema = z4.object({
683
- activityDays: z4.array(locationActivityDayReportSchema),
684
- generatedAt: z4.string(),
685
- locations: z4.array(locationSummaryReportSchema),
686
- privateActivity: conversationStatsItemSchema,
687
- source: z4.literal("conversation_index"),
688
- windowEnd: z4.string(),
689
- windowStart: z4.string()
690
- }).strict();
691
- var locationDetailReportSchema = locationSummaryReportSchema.extend({
692
- activityDays: z4.array(dailyConversationActivitySchema),
693
- actors: z4.array(locationActorSummaryReportSchema),
694
- generatedAt: z4.string(),
695
- recentConversations: z4.array(conversationSummaryReportSchema),
696
- source: z4.literal("conversation_index"),
697
- windowEnd: z4.string(),
698
- windowStart: z4.string()
699
- }).strict();
700
-
701
- // src/api/schema/common.ts
702
- import { z as z5 } from "zod";
703
- var apiErrorSchema = z5.object({ error: z5.string().min(1) }).strict();
704
-
705
- // src/api/schema/personal-token.ts
706
- import { z as z6 } from "zod";
707
- var personalTokenMetadataSchema = z6.object({
708
- id: z6.string().uuid(),
709
- name: z6.string(),
710
- tokenSuffix: z6.string(),
711
- createdAt: z6.string().datetime(),
712
- expiresAt: z6.string().datetime(),
713
- lastUsedAt: z6.string().datetime().nullable()
714
- }).strict();
715
- var personalTokenListSchema = z6.object({ tokens: z6.array(personalTokenMetadataSchema) }).strict();
716
- var createPersonalTokenBodySchema = z6.object({ name: z6.string().trim().min(1).max(80) }).strict();
717
- var createdPersonalTokenSchema = personalTokenMetadataSchema.extend({ token: z6.string().startsWith("jr_pat_") }).strict();
718
- var personalTokenParamsSchema = z6.object({ id: z6.string().uuid() }).strict();
719
- var revokePersonalTokenResponseSchema = z6.object({ revoked: z6.literal(true) }).strict();
720
-
721
- // src/api/schema/workspace.ts
722
- import { z as z7 } from "zod";
723
- var workspaceRepoInputSchema = z7.object({
724
- provider: z7.string(),
725
- repo: z7.string()
726
- }).strict();
727
- var workspaceRepoSchema = z7.object({
728
- provider: z7.string(),
729
- repo: z7.string(),
730
- checkoutPath: z7.string()
731
- }).strict();
732
- var workspaceSnapshotSchema = z7.object({
733
- id: z7.string(),
734
- generatedAt: z7.iso.datetime(),
735
- buildDurationMs: z7.number().int().nonnegative(),
736
- sizeBytes: z7.number().int().nonnegative().nullable()
737
- }).strict();
738
- var baselineSnapshotSchema = z7.object({
739
- id: z7.string(),
740
- generatedAt: z7.iso.datetime(),
741
- buildDurationMs: z7.number().int().nonnegative(),
742
- dependencyCount: z7.number().int().nonnegative()
743
- }).strict();
744
- var workspaceSchema = z7.object({
745
- id: z7.string().uuid(),
746
- name: z7.string(),
747
- setupScript: z7.string(),
748
- repos: z7.array(workspaceRepoSchema),
749
- snapshot: workspaceSnapshotSchema.nullable()
750
- }).strict();
751
- var workspaceListSchema = z7.object({
752
- baselineSnapshot: baselineSnapshotSchema.nullable(),
753
- workspaces: z7.array(workspaceSchema)
754
- }).strict();
755
- var workspaceBodySchema = z7.object({
756
- name: z7.string(),
757
- setupScript: z7.string().optional(),
758
- repos: z7.array(workspaceRepoInputSchema)
759
- }).strict();
760
- var workspaceParamsSchema = z7.object({ id: z7.string().uuid() }).strict();
761
- var deleteWorkspaceResponseSchema = z7.object({ deleted: z7.literal(true) }).strict();
762
-
763
- // src/api/schema/task.ts
764
- import { z as z8 } from "zod";
765
- var taskDestinationSchema = z8.object({
766
- channelId: z8.string().min(1),
767
- label: z8.string().min(1),
768
- teamId: z8.string().min(1),
769
- visibility: z8.enum(["private", "public"])
770
- }).strict();
771
- var taskSummaryBaseSchema = z8.object({
772
- createdAt: z8.string().datetime(),
773
- createdBy: z8.string().min(1),
774
- createdByEmail: z8.string().trim().email().optional(),
775
- destination: taskDestinationSchema,
776
- id: z8.string().min(1),
777
- instruction: z8.string().min(1),
778
- lastConversationId: z8.string().min(1).optional(),
779
- lastRunAt: z8.string().datetime().optional(),
780
- ownedByViewer: z8.boolean(),
781
- runsLast7Days: z8.number().int().nonnegative(),
782
- /** Short display title; falls back from instruction when unset. */
783
- title: z8.string().min(1),
784
- totalRuns: z8.number().int().nonnegative()
785
- });
786
- var scheduledTaskSummarySchema = taskSummaryBaseSchema.extend({
787
- kind: z8.literal("scheduled"),
788
- nextRunAt: z8.string().datetime().optional(),
789
- schedule: z8.string().min(1),
790
- status: z8.enum(["active", "blocked", "completed"])
791
- }).strict();
792
- var eventTaskSummarySchema = taskSummaryBaseSchema.extend({
793
- events: z8.array(z8.string().min(1)).min(1),
794
- kind: z8.literal("event"),
795
- resource: z8.string().min(1),
796
- source: z8.string().min(1),
797
- triggerAvailable: z8.boolean()
798
- }).strict();
799
- var taskSummarySchema = z8.discriminatedUnion("kind", [
800
- scheduledTaskSummarySchema,
801
- eventTaskSummarySchema
802
- ]);
803
- var taskExecutionDaySchema = z8.object({
804
- date: z8.string().min(1),
805
- event: z8.number().int().nonnegative(),
806
- scheduled: z8.number().int().nonnegative()
807
- }).strict();
808
- var taskListSchema = z8.object({
809
- executionDays: z8.array(taskExecutionDaySchema),
810
- tasks: z8.array(taskSummarySchema),
811
- truncated: z8.boolean()
812
- }).strict();
813
- var taskParamsSchema = z8.object({
814
- id: z8.string().min(1),
815
- kind: z8.enum(["scheduled", "event"])
816
- }).strict();
817
- var taskExecutionStatusSchema = z8.enum([
818
- "blocked",
819
- "completed",
820
- "failed"
821
- ]);
822
- var taskExecutionSchema = z8.object({
823
- conversationId: z8.string().min(1).optional(),
824
- executedAt: z8.string().datetime(),
825
- executionId: z8.string().min(1),
826
- status: taskExecutionStatusSchema,
827
- title: z8.string().min(1).optional()
828
- }).strict();
829
- var taskExecutionStatusDaySchema = z8.object({
830
- blocked: z8.number().int().nonnegative(),
831
- completed: z8.number().int().nonnegative(),
832
- date: z8.string().min(1),
833
- failed: z8.number().int().nonnegative()
834
- }).strict();
835
- var taskExecutionListSchema = z8.object({
836
- executionDays: z8.array(taskExecutionStatusDaySchema),
837
- executions: z8.array(taskExecutionSchema),
838
- task: taskSummarySchema,
839
- truncated: z8.boolean()
840
- }).strict();
841
- var taskRunSchema = taskExecutionSchema.extend({
842
- kind: z8.enum(["scheduled", "event"]),
843
- taskId: z8.string().min(1),
844
- taskTitle: z8.string().min(1)
845
- }).strict();
846
- var taskRunListSchema = z8.object({
847
- runs: z8.array(taskRunSchema),
848
- truncated: z8.boolean()
849
- }).strict();
850
-
851
- // src/api/schema/stats.ts
852
- import { z as z9 } from "zod";
853
- var statSchema = z9.object({
854
- count: z9.number().int().nonnegative(),
855
- date: z9.string(),
856
- metric: z9.string().min(1),
857
- name: z9.string().min(1),
858
- namespace: z9.string().min(1)
859
- }).strict();
860
- var statsReportSchema = z9.object({
861
- generatedAt: z9.string().datetime(),
862
- stats: z9.array(statSchema),
863
- windowEnd: z9.string(),
864
- windowStart: z9.string()
865
- }).strict();
866
-
867
- export {
868
- apiErrorSchema,
869
- conversationParamsSchema,
870
- conversationAttachmentParamsSchema,
871
- conversationDetailQuerySchema,
872
- conversationEventsQuerySchema,
873
- conversationFeedQuerySchema,
874
- archiveConversationBodySchema,
875
- archiveConversationResponseSchema,
876
- createConversationBodySchema,
877
- createConversationMessageBodySchema,
878
- acceptedConversationMessageSchema,
879
- conversationPendingMessageDeliverySchema,
880
- conversationPendingMessageSchema,
881
- conversationPendingAuthorizationSchema,
882
- conversationPendingMessagesReportSchema,
883
- cancelConversationPendingMessagesBodySchema,
884
- cancelConversationPendingMessagesResponseSchema,
885
- conversationAuxiliaryCostsSchema,
886
- conversationSummaryReportSchema,
887
- conversationReportEventDataSchema,
888
- conversationReportEventSchema,
889
- conversationEventHistorySchema,
890
- conversationDetailReportSchema,
891
- conversationEventPageSchema,
892
- conversationFeedSchema,
893
- conversationStatsReportSchema,
894
- dailyConversationActivitySchema,
895
- activityDays,
896
- locationParamsSchema,
897
- locationActivityDayReportSchema,
898
- locationDirectoryReportSchema,
899
- locationDetailReportSchema,
900
- personParamsSchema,
901
- actorDirectoryReportSchema,
902
- actorProfileReportSchema,
903
- personalSpendReportSchema,
904
- personalTokenMetadataSchema,
905
- personalTokenListSchema,
906
- createPersonalTokenBodySchema,
907
- createdPersonalTokenSchema,
908
- personalTokenParamsSchema,
909
- revokePersonalTokenResponseSchema,
910
- scheduledTaskSummarySchema,
911
- eventTaskSummarySchema,
912
- taskSummarySchema,
913
- taskListSchema,
914
- taskParamsSchema,
915
- taskExecutionStatusSchema,
916
- taskExecutionSchema,
917
- taskExecutionStatusDaySchema,
918
- taskExecutionListSchema,
919
- taskRunSchema,
920
- taskRunListSchema,
921
- workspaceRepoSchema,
922
- baselineSnapshotSchema,
923
- workspaceSchema,
924
- workspaceListSchema,
925
- workspaceBodySchema,
926
- workspaceParamsSchema,
927
- deleteWorkspaceResponseSchema,
928
- statSchema,
929
- statsReportSchema
930
- };