@sentry/junior 0.237.0 → 0.238.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 (70) hide show
  1. package/dist/{context-0Et9iVSB.js → actor-BTtLaeWy.js} +1 -96
  2. package/dist/admin-leAJ2k0P.js +33 -0
  3. package/dist/{agent-hooks-otHGbhBx.js → agent-hooks-p3UA9FI1.js} +1423 -2973
  4. package/dist/{agent-runner-DMAsnPb9.js → agent-runner-DjQSEVuD.js} +171 -139
  5. package/dist/api/schema.d.ts +4 -0
  6. package/dist/api/schema.js +3 -2
  7. package/dist/api.d.ts +1 -1
  8. package/dist/api.js +31 -24
  9. package/dist/{app-MEd7wbF0.d.ts → app-FB2hmHpZ.d.ts} +1 -1
  10. package/dist/app.d.ts +1 -1
  11. package/dist/app.js +26 -22
  12. package/dist/{briefs-DDA1ugXk.js → briefs-mzUaJkBX.js} +4 -4
  13. package/dist/{catalog-runtime-DlXuhrmk.js → catalog-runtime-xq-njrMs.js} +1 -1
  14. package/dist/{checkpoint-BlIIiHG5.js → checkpoint-C37Xgtj-.js} +19 -10
  15. package/dist/cli/chat.js +13 -13
  16. package/dist/cli/check.js +3 -3
  17. package/dist/cli/main.js +6 -2
  18. package/dist/cli/plugins.js +5 -3
  19. package/dist/cli/run.d.ts +2 -1
  20. package/dist/cli/run.js +2 -1
  21. package/dist/cli/snapshot-create.js +3 -3
  22. package/dist/cli/upgrade.d.ts +1 -1
  23. package/dist/cli/upgrade.js +3 -3
  24. package/dist/{client-CPMbTmJU.js → client-BZdqKg6S.js} +2 -2
  25. package/dist/{config-CxpPG6nR.js → config-CGK_VplU.js} +2 -2
  26. package/dist/{conversation-9Fxa1Zbq.js → conversation-DwD-vquD.js} +3 -517
  27. package/dist/{conversation-privacy-Dbkdvozu.js → conversation-privacy-Ci3QLNOb.js} +1 -1
  28. package/dist/{credential-sync-D9yGg3q5.js → credential-sync-BBeYpK4k.js} +15 -14
  29. package/dist/{db-Ca9Nt5ci.d.ts → db-CWZP77Ex.d.ts} +1 -1
  30. package/dist/{executor-BNxfDS1V.js → executor-DmIad4GI.js} +4 -2
  31. package/dist/experimental-Qn9rKLgx.js +50 -0
  32. package/dist/history-BLTUgFYO.js +518 -0
  33. package/dist/{images-D6Y3FJDQ.js → images-1xUjTHGf.js} +3 -3
  34. package/dist/instrumentation.js +2 -2
  35. package/dist/{job-queue-Dq5_zt_l.js → job-queue-CXpx6KfD.js} +1 -1
  36. package/dist/{logging-rB_ngE_R.js → logging-Bne7JUXI.js} +1 -1
  37. package/dist/nitro.d.ts +1 -1
  38. package/dist/nitro.js +3 -3
  39. package/dist/{oauth-authorization-5T1S1v_1.js → oauth-authorization-O8N3knp9.js} +1 -1
  40. package/dist/{oauth-callback-server-Csw7RssK.js → oauth-callback-server-Cb-HPZPS.js} +2 -2
  41. package/dist/pending-auth-C6w4Gwve.js +433 -0
  42. package/dist/{profile-D6apIG2N.js → profile-DIcHBAxe.js} +5 -7
  43. package/dist/{prompt-Ctwy6hSI.js → prompt-CMU-B4FA.js} +1 -1
  44. package/dist/{registry-zfTzTHe6.js → registry-VSrEYeaD.js} +111 -3
  45. package/dist/{resolve-sJtTzuBO.js → resolve-BkpWmZgN.js} +2 -2
  46. package/dist/{runner-DkCk8cbc.js → runner-52ezCnZF.js} +10 -10
  47. package/dist/{sandbox-egress-signals-tSQ8OEcw.js → sandbox-egress-signals-Cmhf3P6Y.js} +1 -1
  48. package/dist/{schema-C5bgOpRg.js → schema-CxWAN2zq.js} +1 -1
  49. package/dist/{skills-BVpr_Gnv.js → skills-PHvy-ZgH.js} +2 -2
  50. package/dist/{spawn-CJhmyE4E.js → spawn-CY34_HCm.js} +2 -2
  51. package/dist/{store-DoewL5mG.d.ts → store-BxxbxBlm.d.ts} +7 -0
  52. package/dist/{task-queue-BAiZ7_CF.js → task-queue-B9uJqkal.js} +3 -3
  53. package/dist/{task-runner-Bh8XONXT.js → task-runner-BZUoctJ1.js} +20 -10
  54. package/dist/{thread-state-BnQln4jO.js → thread-state-SnFcB9Rk.js} +6 -5
  55. package/dist/{turn-failure-response-Ba7_kItn.js → turn-failure-response-CrSc1Vtn.js} +10 -9
  56. package/dist/{turn-lifecycle-D6CTbkb9.js → turn-lifecycle-D49hJbjm.js} +1 -1
  57. package/dist/{turn-session-routing-DNevs9H7.js → turn-session-routing-cMvumCLK.js} +1 -1
  58. package/dist/{validation-BNPhuAvt.js → validation-DsLyiOfn.js} +1 -1
  59. package/dist/{version-EQ4MWuUJ.js → version-Dayi_ng2.js} +1 -1
  60. package/dist/version.js +1 -1
  61. package/dist/viewer-DF3HTfW5.js +1636 -0
  62. package/dist/{web-authorization-DDt4FZld.js → web-authorization-Dg_R1tMc.js} +6 -6
  63. package/dist/{web-input-C56ivZuH.js → web-input-qVi8134S.js} +63 -433
  64. package/dist/{work-DJ7hb9Ul.js → work-BbcghZZp.js} +9 -10
  65. package/dist/{worker-DiiV8Lba.js → worker-B-uRQzKw.js} +5 -5
  66. package/migrations/0048_user_admin.sql +1 -0
  67. package/migrations/meta/0048_snapshot.json +3720 -0
  68. package/migrations/meta/_journal.json +7 -0
  69. package/package.json +5 -5
  70. package/dist/pending-auth-moCA2mTc.js +0 -59
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { S as toOptionalTrimmed, o as resolveGatewayModel } from "./client-CPMbTmJU.js";
3
- import { p as logWarn } from "./logging-rB_ngE_R.js";
2
+ import { S as toOptionalTrimmed, o as resolveGatewayModel } from "./client-BZdqKg6S.js";
3
+ import { p as logWarn } from "./logging-Bne7JUXI.js";
4
4
  import { l as TURN_REASONING_LEVELS, s as modelProfileSchema, t as DEFAULT_MODEL_PROFILES, u as parseTurnReasoningLevel } from "./model-profile-BwU8mqwD.js";
5
5
  //#region src/chat/slack/emoji.ts
6
6
  const SLACK_EMOJI_NAME_RE = /^(?:[a-z0-9_+-]+)(?:::(?:skin-tone-[2-6]))?$/;
@@ -1,520 +1,6 @@
1
- import { l as TURN_REASONING_LEVELS, s as modelProfileSchema } from "./model-profile-BwU8mqwD.js";
1
+ import { a as conversationTurnFailureReasonSchema, i as conversationTurnFailureCodeSchema, m as usageSchema } from "./history-BLTUgFYO.js";
2
2
  import { z } from "zod";
3
- import { actorSchema, codeChangeStateSchema, conversationAnnotationInputSchema, conversationEventPresentationSchema, conversationSidebarAnnotationSchema, objectFactFields, objectTypeSchema } from "@sentry/junior-plugin-api";
4
- //#region src/usage-schema.ts
5
- const usageCostSchema = z.object({
6
- input: z.number().finite().nonnegative().optional(),
7
- output: z.number().finite().nonnegative().optional(),
8
- cacheRead: z.number().finite().nonnegative().optional(),
9
- cacheWrite: z.number().finite().nonnegative().optional(),
10
- total: z.number().finite().nonnegative().optional()
11
- }).strict();
12
- const usageSchema = z.object({
13
- inputTokens: z.number().int().nonnegative().optional(),
14
- outputTokens: z.number().int().nonnegative().optional(),
15
- cachedInputTokens: z.number().int().nonnegative().optional(),
16
- cacheCreationTokens: z.number().int().nonnegative().optional(),
17
- reasoningTokens: z.number().int().nonnegative().optional(),
18
- totalTokens: z.number().int().nonnegative().optional(),
19
- cost: usageCostSchema.optional()
20
- }).strict();
21
- //#endregion
22
- //#region src/chat/conversations/provenance.ts
23
- /**
24
- * Durable message attribution shared by storage and projections.
25
- * Attribution never grants credential authority.
26
- */
27
- const conversationMessageAuthoritySchema = z.union([z.literal("instruction"), z.literal("context")]);
28
- /** Canonical authority and actor metadata for one durable message event. */
29
- const conversationMessageProvenanceSchema = z.object({
30
- authority: conversationMessageAuthoritySchema,
31
- actor: actorSchema.optional()
32
- }).strict();
33
- /** Build instruction provenance for an optional actor. */
34
- function instructionProvenanceFor(actor) {
35
- return actor ? {
36
- authority: "instruction",
37
- actor
38
- } : { authority: "instruction" };
39
- }
40
- /** Unattributed ambient-context provenance for non-instruction messages. */
41
- const contextProvenance = { authority: "context" };
42
- function actorIdentityKey(actor) {
43
- if (actor.platform === "system") return `system ${actor.name}`;
44
- return actor.platform === "slack" ? `slack\u0000${actor.teamId}\u0000${actor.userId}` : `${actor.platform}\u0000${actor.userId}`;
45
- }
46
- /** Compare two actors by runtime identity only, never by display metadata. */
47
- function sameActorIdentity(left, right) {
48
- return Boolean(left && right && actorIdentityKey(left) === actorIdentityKey(right));
49
- }
50
- /**
51
- * Return distinct instruction actors in first-seen order for attribution only.
52
- * Never use this list as credential authority.
53
- */
54
- function instructionActors(provenance) {
55
- const seen = /* @__PURE__ */ new Set();
56
- const actors = [];
57
- for (const entry of provenance) {
58
- if (entry.authority !== "instruction" || !entry.actor) continue;
59
- const identity = actorIdentityKey(entry.actor);
60
- if (seen.has(identity)) continue;
61
- seen.add(identity);
62
- actors.push(entry.actor);
63
- }
64
- return actors;
65
- }
66
- //#endregion
67
- //#region src/chat/conversations/history-payload.ts
68
- const messageFieldsSchema = z.record(z.string(), z.unknown());
69
- const replacementEntrySchema = z.object({ item: z.string() }).passthrough();
70
- /** Identify history events that store message fields as JSON strings. */
71
- function isEncodedHistoryType(type) {
72
- return type === "user_message" || type === "assistant_message" || type === "tool_result" || type === "handoff" || type === "compaction";
73
- }
74
- /** Encode agent history before SQL can change keys or string contents. */
75
- function encodeHistoryPayload(data) {
76
- const { type, ...payload } = data;
77
- if (!isEncodedHistoryType(type)) return {
78
- schemaVersion: 1,
79
- payload
80
- };
81
- if (data.type === "handoff" || data.type === "compaction") return {
82
- schemaVersion: 2,
83
- payload: {
84
- ...payload,
85
- replacementHistory: data.replacementHistory.map(({ item, ...entry }) => ({
86
- ...entry,
87
- item: JSON.stringify(item)
88
- }))
89
- }
90
- };
91
- const { provenance, ...message } = payload;
92
- return {
93
- schemaVersion: 2,
94
- payload: {
95
- message: JSON.stringify(message),
96
- provenance,
97
- model: message.model,
98
- provider: message.provider,
99
- usage: message.usage,
100
- toolCallId: message.toolCallId
101
- }
102
- };
103
- }
104
- /** Decode stored history for validation by the conversation event schema. */
105
- function decodeHistoryPayload(type, payload) {
106
- const fields = messageFieldsSchema.parse(payload);
107
- if (type === "handoff" || type === "compaction") return {
108
- ...fields,
109
- replacementHistory: z.array(replacementEntrySchema).parse(fields.replacementHistory).map(({ item, ...entry }) => ({
110
- ...entry,
111
- item: JSON.parse(item)
112
- }))
113
- };
114
- const message = messageFieldsSchema.parse(JSON.parse(z.string().parse(fields.message)));
115
- if (fields.provenance !== void 0) message.provenance = fields.provenance;
116
- return message;
117
- }
118
- //#endregion
119
- //#region src/chat/conversations/history.ts
120
- /**
121
- * Durable conversation event history port.
122
- *
123
- * Events append under the conversation lease in stable sequence order.
124
- * Compaction and handoff replace the active model history without rewriting
125
- * prior events. Unsupported stored events remain readable as opaque facts,
126
- * while malformed known events fail loudly. Provider-specific message fields
127
- * are validated by the Pi adapter when it restores model context.
128
- */
129
- const userMessageEventDataSchema = z.object({
130
- type: z.literal("user_message"),
131
- role: z.never().optional(),
132
- provenance: conversationMessageProvenanceSchema
133
- }).passthrough();
134
- const assistantMessageEventDataSchema = z.object({
135
- type: z.literal("assistant_message"),
136
- role: z.never().optional()
137
- }).passthrough();
138
- const toolResultEventDataSchema = z.object({
139
- type: z.literal("tool_result"),
140
- role: z.never().optional()
141
- }).passthrough();
142
- /**
143
- * One replayable agent-history item. Junior owns `type` and user provenance,
144
- * forbids the provider `role` discriminator, and leaves preserved message
145
- * fields for the Pi adapter to validate when restoring model context.
146
- */
147
- const agentHistoryItemSchema = z.discriminatedUnion("type", [
148
- userMessageEventDataSchema,
149
- assistantMessageEventDataSchema,
150
- toolResultEventDataSchema
151
- ]);
152
- const nativeReplacementHistoryItemSchema = z.object({
153
- item: agentHistoryItemSchema,
154
- sourceEventSeq: z.number().int().nonnegative().optional()
155
- }).strict();
156
- /**
157
- * The complete agent history used immediately after a replacement. Later
158
- * native history events append to it. Replacement entries are replayed model
159
- * history, not new conversation activity.
160
- */
161
- const replacementHistorySchema = z.array(nativeReplacementHistoryItemSchema);
162
- const compactionDetailsSchema = z.object({
163
- reason: z.literal("capacity"),
164
- estimatedInputTokens: z.number().int().nonnegative(),
165
- replacementInputTokens: z.number().int().nonnegative().optional(),
166
- triggerTokens: z.number().int().nonnegative(),
167
- inputLimitTokens: z.number().int().positive(),
168
- inputMessageCount: z.number().int().nonnegative(),
169
- retainedMessageCount: z.number().int().nonnegative(),
170
- summaryChars: z.number().int().nonnegative()
171
- }).strict();
172
- const historyReplacementEventDataSchema = z.discriminatedUnion("type", [z.object({
173
- type: z.literal("handoff"),
174
- modelProfile: modelProfileSchema,
175
- modelId: z.string().min(1),
176
- reasoningLevel: z.string().min(1).optional(),
177
- triggeringToolCallId: z.string().min(1).optional(),
178
- summary: z.string().min(1).optional(),
179
- replacementHistory: replacementHistorySchema
180
- }).strict(), z.object({
181
- type: z.literal("compaction"),
182
- modelProfile: modelProfileSchema,
183
- modelId: z.string().min(1),
184
- details: compactionDetailsSchema.optional(),
185
- summary: z.string().min(1).optional(),
186
- replacementHistory: replacementHistorySchema
187
- }).strict()]);
188
- /** Validate an event that intentionally replaces active model history. */
189
- const historyReplacementSchema = z.object({
190
- data: historyReplacementEventDataSchema,
191
- createdAtMs: z.number().finite()
192
- }).strict();
193
- const mcpProviderConnectedEventDataSchema = z.object({
194
- type: z.literal("mcp_provider_connected"),
195
- provider: z.string().min(1),
196
- credentialSubjectId: z.string().min(1)
197
- }).strict();
198
- const unownedMcpProviderConnectedEventDataSchema = z.object({
199
- type: z.literal("mcp_provider_connected_unowned"),
200
- provider: z.string().min(1)
201
- }).strict();
202
- const authorizationKindSchema = z.union([z.literal("plugin"), z.literal("mcp")]);
203
- const authorizationRequestedEventDataSchema = z.object({
204
- type: z.literal("authorization_requested"),
205
- kind: authorizationKindSchema,
206
- provider: z.string().min(1),
207
- actorId: z.string().min(1),
208
- authorizationId: z.string().min(1),
209
- delivery: z.union([z.literal("private_link_sent"), z.literal("private_link_reused")])
210
- }).strict();
211
- const authorizationCompletedEventDataSchema = z.object({
212
- type: z.literal("authorization_completed"),
213
- kind: authorizationKindSchema,
214
- provider: z.string().min(1),
215
- actorId: z.string().min(1),
216
- authorizationId: z.string().min(1)
217
- }).strict();
218
- const toolExecutionStartedEventDataSchema = z.object({
219
- type: z.literal("tool_execution_started"),
220
- toolCallId: z.string().min(1),
221
- toolName: z.string().min(1)
222
- }).strict();
223
- const guardianActionReviewedEventDataSchema = z.object({
224
- type: z.literal("guardian_action_reviewed"),
225
- turnId: z.string().min(1),
226
- toolCallId: z.string().min(1),
227
- toolName: z.string().min(1),
228
- costUsd: z.number().finite().nonnegative().optional(),
229
- decision: z.enum([
230
- "allow",
231
- "ask",
232
- "deny"
233
- ]),
234
- riskLevel: z.enum([
235
- "low",
236
- "medium",
237
- "high",
238
- "critical"
239
- ]),
240
- userAuthorization: z.enum([
241
- "high",
242
- "medium",
243
- "low",
244
- "unknown"
245
- ])
246
- }).strict();
247
- const conversationMessageRoleSchema = z.union([
248
- z.literal("user"),
249
- z.literal("assistant"),
250
- z.literal("system")
251
- ]);
252
- const messageEventDataSchema = z.object({
253
- type: z.literal("message"),
254
- messageId: z.string().min(1),
255
- role: conversationMessageRoleSchema,
256
- text: z.string(),
257
- authorIdentityId: z.string().min(1).optional(),
258
- meta: z.record(z.string(), z.unknown()).optional()
259
- }).strict();
260
- const messageUpdatedEventDataSchema = messageEventDataSchema.extend({ type: z.literal("message_updated") });
261
- const messageHandledEventDataSchema = z.object({
262
- type: z.literal("message_handled"),
263
- messageId: z.string().min(1)
264
- }).strict();
265
- const messagesSummarizedEventDataSchema = z.object({
266
- type: z.literal("messages_summarized"),
267
- historyFromSeq: z.number().int().nonnegative(),
268
- compactions: z.array(z.object({
269
- coveredMessageCount: z.number().int().nonnegative(),
270
- createdAtMs: z.number(),
271
- id: z.string().min(1),
272
- summary: z.string()
273
- }).strict())
274
- }).strict();
275
- /** Product surface that owns a durable conversation turn. */
276
- const conversationTurnSurfaceSchema = z.enum([
277
- "slack",
278
- "api",
279
- "scheduler",
280
- "internal"
281
- ]);
282
- /** Where a failed turn stopped. */
283
- const conversationTurnFailureCodeSchema = z.enum([
284
- "agent_run_failed",
285
- "delivery_failed",
286
- "model_execution_failed",
287
- "persistence_failed"
288
- ]);
289
- /**
290
- * Why a failed turn stopped.
291
- * Values are fixed labels only. Do not store raw exception text.
292
- */
293
- const conversationTurnFailureReasonSchema = z.enum([
294
- "auth",
295
- "permission",
296
- "rate_limit",
297
- "capacity",
298
- "timeout",
299
- "network",
300
- "server",
301
- "invalid_request",
302
- "invalid_response",
303
- "quota",
304
- "content_policy",
305
- "unknown",
306
- "empty_output",
307
- "tool_errors",
308
- "suppressed_output"
309
- ]);
310
- const turnStartedEventDataSchema = z.object({
311
- type: z.literal("turn_started"),
312
- turnId: z.string().min(1),
313
- inputMessageIds: z.array(z.string().min(1)).min(1),
314
- surface: conversationTurnSurfaceSchema
315
- }).strict().refine((data) => new Set(data.inputMessageIds).size === data.inputMessageIds.length, "turn input message ids must be unique");
316
- const turnRoutedEventDataSchema = z.object({
317
- type: z.literal("turn_routed"),
318
- turnId: z.string().min(1),
319
- modelProfile: modelProfileSchema,
320
- modelId: z.string().min(1),
321
- costUsd: z.number().finite().nonnegative().optional(),
322
- reasoningLevel: z.enum(TURN_REASONING_LEVELS),
323
- confidence: z.number().min(0).max(1).optional(),
324
- source: z.enum([
325
- "configured",
326
- "inherited",
327
- "router"
328
- ])
329
- }).strict();
330
- const turnContextEventDataSchema = z.object({
331
- type: z.literal("turn_context"),
332
- turnId: z.string().min(1),
333
- pluginName: z.string().min(1),
334
- kind: z.string().min(1).max(64),
335
- version: z.number().int().positive(),
336
- content: z.record(z.string(), z.unknown())
337
- }).strict();
338
- const structuredConversationEventDataSchema = z.object({
339
- type: z.literal("structured_event"),
340
- namespace: z.string().regex(/^[a-z][a-z0-9-]*$/),
341
- name: z.string().regex(/^[a-z][a-z0-9_]*$/),
342
- version: z.number().int().positive(),
343
- turnId: z.string().min(1).optional(),
344
- content: z.record(z.string(), z.unknown())
345
- }).strict();
346
- /** Durable attachment metadata on host-owned delivery events. */
347
- const deliveredAttachmentSchema = z.object({
348
- id: z.string().min(1),
349
- filename: z.string().min(1),
350
- contentType: z.string().min(1),
351
- bytes: z.number().int().nonnegative()
352
- }).strict();
353
- /** Host-owned transcript item for files delivered to humans this turn. */
354
- const attachmentsDeliveredEventDataSchema = z.object({
355
- type: z.literal("attachments_delivered"),
356
- attachments: z.array(deliveredAttachmentSchema).min(1),
357
- toolCallId: z.string().min(1).optional(),
358
- turnId: z.string().min(1).optional()
359
- }).strict();
360
- const turnCompletedEventDataSchema = z.object({
361
- type: z.literal("turn_completed"),
362
- turnId: z.string().min(1),
363
- outcome: z.enum([
364
- "success",
365
- "no_reply",
366
- "cancelled"
367
- ])
368
- }).strict();
369
- const turnFailedEventDataSchema = z.object({
370
- type: z.literal("turn_failed"),
371
- turnId: z.string().min(1),
372
- failureCode: conversationTurnFailureCodeSchema,
373
- failureReason: conversationTurnFailureReasonSchema.optional(),
374
- eventId: z.string().regex(/^[a-f0-9]{32}$/i).optional()
375
- }).strict();
376
- const subagentStartedEventDataSchema = z.object({
377
- type: z.literal("subagent_started"),
378
- subagentInvocationId: z.string().min(1),
379
- subagentKind: z.string().min(1),
380
- modelId: z.string().min(1).optional(),
381
- parentToolCallId: z.string().min(1).optional(),
382
- reasoningLevel: z.string().min(1).optional(),
383
- childConversationId: z.string().min(1)
384
- }).strict();
385
- const subagentEndedEventDataSchema = z.object({
386
- type: z.literal("subagent_ended"),
387
- subagentInvocationId: z.string().min(1),
388
- outcome: z.union([
389
- z.literal("success"),
390
- z.literal("error"),
391
- z.literal("aborted")
392
- ]),
393
- errorCode: z.string().min(1).optional()
394
- }).strict();
395
- /** Prevent ordinary appends from bypassing history-replacement validation. */
396
- const appendableConversationEventDataSchema = z.union([
397
- messageEventDataSchema,
398
- messageUpdatedEventDataSchema,
399
- agentHistoryItemSchema,
400
- mcpProviderConnectedEventDataSchema,
401
- authorizationRequestedEventDataSchema,
402
- authorizationCompletedEventDataSchema,
403
- toolExecutionStartedEventDataSchema,
404
- guardianActionReviewedEventDataSchema,
405
- messageHandledEventDataSchema,
406
- messagesSummarizedEventDataSchema,
407
- turnStartedEventDataSchema,
408
- turnContextEventDataSchema,
409
- structuredConversationEventDataSchema,
410
- attachmentsDeliveredEventDataSchema,
411
- turnRoutedEventDataSchema,
412
- turnCompletedEventDataSchema,
413
- turnFailedEventDataSchema,
414
- subagentStartedEventDataSchema,
415
- subagentEndedEventDataSchema
416
- ]);
417
- /** Strict event-data contract reused by the SQL row codec. */
418
- const conversationEventDataSchema = z.union([
419
- appendableConversationEventDataSchema,
420
- historyReplacementEventDataSchema,
421
- unownedMcpProviderConnectedEventDataSchema
422
- ]);
423
- /** Event type names recognized by current readers and observational queries. */
424
- const KNOWN_CONVERSATION_EVENT_TYPES = [
425
- "message",
426
- "message_updated",
427
- "user_message",
428
- "assistant_message",
429
- "tool_result",
430
- "mcp_provider_connected",
431
- "mcp_provider_connected_unowned",
432
- "authorization_requested",
433
- "authorization_completed",
434
- "tool_execution_started",
435
- "guardian_action_reviewed",
436
- "message_handled",
437
- "messages_summarized",
438
- "turn_started",
439
- "turn_context",
440
- "structured_event",
441
- "attachments_delivered",
442
- "turn_routed",
443
- "turn_completed",
444
- "turn_failed",
445
- "subagent_started",
446
- "subagent_ended",
447
- "handoff",
448
- "compaction"
449
- ];
450
- const knownConversationEventTypeSchema = z.enum(KNOWN_CONVERSATION_EVENT_TYPES);
451
- const unknownConversationEventDataSchema = z.object({
452
- type: z.literal("unknown"),
453
- originalType: z.string().min(1),
454
- payload: z.unknown()
455
- }).strict();
456
- const conversationEventEnvelopeSchema = z.object({
457
- schemaVersion: z.number().int().nonnegative(),
458
- seq: z.number().int().nonnegative(),
459
- historyVersion: z.number().int().nonnegative(),
460
- idempotencyKey: z.string().min(1).optional(),
461
- createdAtMs: z.number().finite()
462
- }).strict();
463
- /**
464
- * Canonical ordered envelope for the durable conversation log.
465
- * `schemaVersion` is persisted with every physical event row.
466
- */
467
- const conversationEventSchema = z.union([conversationEventEnvelopeSchema.extend({
468
- schemaVersion: z.union([z.literal(1), z.literal(2)]),
469
- data: conversationEventDataSchema
470
- }).refine((event) => event.schemaVersion === 1 || isEncodedHistoryType(event.data.type)), conversationEventEnvelopeSchema.extend({ data: unknownConversationEventDataSchema })]);
471
- const storedConversationEventSchema = conversationEventEnvelopeSchema.extend({
472
- type: z.string().min(1),
473
- payload: z.unknown()
474
- });
475
- /**
476
- * Decode a physical event row without making old or future event types
477
- * unreadable. Unsupported rows stay opaque until an upgrade migration defines
478
- * their semantics; supported events remain strict so corrupt canonical
479
- * data cannot be mistaken for compatibility data.
480
- */
481
- function decodeStoredConversationEvent(value) {
482
- const stored = storedConversationEventSchema.parse(value);
483
- const { type, payload, ...envelope } = stored;
484
- const knownType = knownConversationEventTypeSchema.safeParse(type).success;
485
- if (stored.schemaVersion === 2 && isEncodedHistoryType(type)) return conversationEventSchema.parse({
486
- ...envelope,
487
- data: {
488
- ...decodeHistoryPayload(type, payload),
489
- type
490
- }
491
- });
492
- if (stored.schemaVersion === 1 && knownType) {
493
- const data = typeof payload === "object" && payload !== null && !Array.isArray(payload) ? {
494
- ...payload,
495
- type
496
- } : { type };
497
- return conversationEventSchema.parse({
498
- ...envelope,
499
- data
500
- });
501
- }
502
- return conversationEventSchema.parse({
503
- ...envelope,
504
- data: {
505
- type: "unknown",
506
- originalType: type,
507
- payload
508
- }
509
- });
510
- }
511
- /** Validate an append without permitting model-history replacement events. */
512
- const newConversationEventSchema = z.object({
513
- data: appendableConversationEventDataSchema,
514
- idempotencyKey: z.string().min(1).optional(),
515
- createdAtMs: z.number().finite()
516
- }).strict();
517
- //#endregion
3
+ import { codeChangeStateSchema, conversationAnnotationInputSchema, conversationEventPresentationSchema, conversationSidebarAnnotationSchema, objectFactFields, objectTypeSchema } from "@sentry/junior-plugin-api";
518
4
  //#region src/chat/automations/card.ts
519
5
  /** Saved automation facts shown with a Message, not a live status view. */
520
6
  const automationCardSchema = z.object({
@@ -1368,4 +854,4 @@ const conversationStatsReportSchema = z.object({
1368
854
  windowStart: z.string()
1369
855
  }).strict();
1370
856
  //#endregion
1371
- export { historyReplacementSchema as $, forkConversationResponseSchema as A, parseBriefInput as B, conversationReportEventSchema as C, createConversationBodySchema as D, conversationSummaryReportSchema as E, isVisionImageMediaType as F, removedCardSchema as G, messageCardRef as H, briefCodeChangeSchema as I, agentHistoryItemSchema as J, resolveMessageCards as K, briefLinkSchema as L, MAX_INPUT_IMAGE_BYTES as M, readMessageAttachments as N, createConversationMessageBodySchema as O, INPUT_IMAGE_TYPES as P, decodeStoredConversationEvent as Q, briefOutcomeStatusSchema as R, conversationReportEventDataSchema as S, conversationStatsReportSchema as T, messageCardText as U, annotationCard as V, readMessageCardRefs as W, conversationTurnFailureCodeSchema as X, conversationEventDataSchema as Y, conversationTurnFailureReasonSchema as Z, conversationParamsSchema as _, cancelConversationPendingMessagesBodySchema as a, sameActorIdentity as at, conversationPendingMessageSchema as b, conversationAttachmentParamsSchema as c, conversationDetailReportSchema as d, newConversationEventSchema as et, conversationEventHistorySchema as f, conversationFeedSchema as g, conversationFeedQuerySchema as h, archiveConversationResponseSchema as i, instructionProvenanceFor as it, MAX_INPUT_IMAGES as j, forkConversationBodySchema as k, conversationAuxiliaryCostsSchema as l, conversationEventsQuerySchema as m, actorIdentitySchema as n, contextProvenance as nt, cancelConversationPendingMessagesResponseSchema as o, usageSchema as ot, conversationEventPageSchema as p, KNOWN_CONVERSATION_EVENT_TYPES as q, archiveConversationBodySchema as r, instructionActors as rt, conversationActivityPreviewSchema as s, acceptedConversationMessageSchema as t, encodeHistoryPayload as tt, conversationDetailQuerySchema as u, conversationPendingAuthorizationSchema as v, conversationStatsItemSchema as w, conversationPendingMessagesReportSchema as x, conversationPendingMessageDeliverySchema as y, conversationBriefSchema as z };
857
+ export { forkConversationResponseSchema as A, parseBriefInput as B, conversationReportEventSchema as C, createConversationBodySchema as D, conversationSummaryReportSchema as E, isVisionImageMediaType as F, removedCardSchema as G, messageCardRef as H, briefCodeChangeSchema as I, resolveMessageCards as K, briefLinkSchema as L, MAX_INPUT_IMAGE_BYTES as M, readMessageAttachments as N, createConversationMessageBodySchema as O, INPUT_IMAGE_TYPES as P, briefOutcomeStatusSchema as R, conversationReportEventDataSchema as S, conversationStatsReportSchema as T, messageCardText as U, annotationCard as V, readMessageCardRefs as W, conversationParamsSchema as _, cancelConversationPendingMessagesBodySchema as a, conversationPendingMessageSchema as b, conversationAttachmentParamsSchema as c, conversationDetailReportSchema as d, conversationEventHistorySchema as f, conversationFeedSchema as g, conversationFeedQuerySchema as h, archiveConversationResponseSchema as i, MAX_INPUT_IMAGES as j, forkConversationBodySchema as k, conversationAuxiliaryCostsSchema as l, conversationEventsQuerySchema as m, actorIdentitySchema as n, cancelConversationPendingMessagesResponseSchema as o, conversationEventPageSchema as p, archiveConversationBodySchema as r, conversationActivityPreviewSchema as s, acceptedConversationMessageSchema as t, conversationDetailQuerySchema as u, conversationPendingAuthorizationSchema as v, conversationStatsItemSchema as w, conversationPendingMessagesReportSchema as x, conversationPendingMessageDeliverySchema as y, conversationBriefSchema as z };
@@ -1,4 +1,4 @@
1
- import { p as logWarn } from "./logging-rB_ngE_R.js";
1
+ import { p as logWarn } from "./logging-Bne7JUXI.js";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
3
  //#region src/chat/conversation-privacy.ts
4
4
  const SAFE_METADATA_KEY_LIMIT = 20;
@@ -1,18 +1,19 @@
1
- import { Fn as createUserTokenStore, Sn as resolveBaseUrl, St as getMcpProviderErrorAttributes, T as lookupSlackUserProfile, _ as resolvePluginOAuthAccount, bn as formatProviderLabel, d as getMcpAuthSession, f as getMcpStoredOAuthCredentials, jn as postSlackMessage, o as finalizeMcpAuthorization, p as putMcpStoredOAuthCredentials, s as deleteMcpAuthSession, xn as parseOAuthStatePayload } from "./agent-runner-DMAsnPb9.js";
2
- import { f as escapeXml } from "./client-CPMbTmJU.js";
3
- import { d as logException, h as runBestEffort, p as logWarn } from "./logging-rB_ngE_R.js";
4
- import { a as getRuntimeMetadata, n as botConfig } from "./config-CxpPG6nR.js";
5
- import { g as parseSlackUserId } from "./context-0Et9iVSB.js";
6
- import { W as getSlackClient, nn as getSqlExecutor, vn as upsertIdentity, yn as upsertLinkedIdentity } from "./agent-hooks-otHGbhBx.js";
1
+ import { Mn as createUserTokenStore, On as postSlackMessage, _ as resolvePluginOAuthAccount, _n as formatProviderLabel, d as getMcpAuthSession, f as getMcpStoredOAuthCredentials, o as finalizeMcpAuthorization, p as putMcpStoredOAuthCredentials, s as deleteMcpAuthSession, vn as parseOAuthStatePayload, vt as getMcpProviderErrorAttributes, x as lookupSlackUserProfile, yn as resolveBaseUrl } from "./agent-runner-DjQSEVuD.js";
2
+ import { f as escapeXml } from "./client-BZdqKg6S.js";
3
+ import { d as logException, h as runBestEffort, p as logWarn } from "./logging-Bne7JUXI.js";
4
+ import { a as getRuntimeMetadata, n as botConfig } from "./config-CGK_VplU.js";
5
+ import { f as parseSlackUserId } from "./actor-BTtLaeWy.js";
6
+ import { A as upsertLinkedIdentity, f as getSqlExecutor, k as upsertIdentity } from "./viewer-DF3HTfW5.js";
7
7
  import { i as homeDir } from "./package-discovery-BVvSnQBB.js";
8
- import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-zfTzTHe6.js";
9
- import { n as pluginCatalogRuntime } from "./catalog-runtime-DlXuhrmk.js";
10
- import { t as discoverSkills } from "./skills-BVpr_Gnv.js";
11
- import { B as recordAuthenticationLinked, V as recordAuthorizationCompleted, s as getTurnRecord } from "./checkpoint-BlIIiHG5.js";
12
- import { E as acquireActiveLock, w as getStateAdapter } from "./profile-D6apIG2N.js";
13
- import { i as getConversationPendingAuth } from "./pending-auth-moCA2mTc.js";
14
- import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-BnQln4jO.js";
15
- import { n as deleteWebAuthorization, o as wakeAuthorizedTurn, s as wakePausedTurn } from "./web-authorization-DDt4FZld.js";
8
+ import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-VSrEYeaD.js";
9
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-xq-njrMs.js";
10
+ import { t as discoverSkills } from "./skills-PHvy-ZgH.js";
11
+ import { B as recordAuthenticationLinked, V as recordAuthorizationCompleted, s as getTurnRecord } from "./checkpoint-C37Xgtj-.js";
12
+ import { at as getSlackClient } from "./agent-hooks-p3UA9FI1.js";
13
+ import { E as acquireActiveLock, w as getStateAdapter } from "./profile-DIcHBAxe.js";
14
+ import { i as getConversationPendingAuth } from "./pending-auth-C6w4Gwve.js";
15
+ import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-SnFcB9Rk.js";
16
+ import { n as deleteWebAuthorization, o as wakeAuthorizedTurn, s as wakePausedTurn } from "./web-authorization-Dg_R1tMc.js";
16
17
  import { n as relayLocalOAuthCallback } from "./oauth-relay-CdCnu80W.js";
17
18
  import path from "node:path";
18
19
  import { z } from "zod";
@@ -1,4 +1,4 @@
1
- import "./store-DoewL5mG.js";
1
+ import "./store-BxxbxBlm.js";
2
2
  import { z } from "zod";
3
3
  import "drizzle-orm/pg-core";
4
4
  import "drizzle-orm/migrator";
@@ -1,6 +1,6 @@
1
- import { d as logException } from "./logging-rB_ngE_R.js";
1
+ import { d as logException } from "./logging-Bne7JUXI.js";
2
2
  import { g as startSpanManual } from "./sentry-CgWZM_kV.js";
3
- import "./config-CxpPG6nR.js";
3
+ import "./config-CGK_VplU.js";
4
4
  import { n as juniorDestinations, r as timestamptz } from "./destinations-BeBiJeEM.js";
5
5
  import { AsyncLocalStorage } from "node:async_hooks";
6
6
  import { getTableColumns, sql } from "drizzle-orm";
@@ -40,6 +40,8 @@ const juniorUsers = pgTable("junior_users", {
40
40
  primaryEmailNormalized: text("primary_email_normalized").notNull(),
41
41
  displayName: text("display_name"),
42
42
  timezone: text("timezone"),
43
+ /** Junior-wide admin role. Only the `junior admin` CLI changes it. */
44
+ isAdmin: boolean("is_admin").notNull().default(false),
43
45
  createdAt: timestamptz("created_at").notNull(),
44
46
  updatedAt: timestamptz("updated_at").notNull()
45
47
  }, (table) => [uniqueIndex("junior_users_primary_email_normalized_uidx").on(table.primaryEmailNormalized)]);
@@ -0,0 +1,50 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
+ //#region src/chat/experimental.ts
3
+ var experimental_exports = /* @__PURE__ */ __exportAll({
4
+ EXPERIMENTAL_FEATURES: () => EXPERIMENTAL_FEATURES,
5
+ getExperimentalFeatures: () => getExperimentalFeatures,
6
+ isExperimentalFeatureEnabled: () => isExperimentalFeatureEnabled,
7
+ setExperimentalFeatures: () => setExperimentalFeatures
8
+ });
9
+ /**
10
+ * Known unstable product features that must be opted into explicitly.
11
+ * Add new keys here as features graduate from private experiments; remove them
12
+ * once they become stable defaults.
13
+ */
14
+ const EXPERIMENTAL_FEATURES = [
15
+ "operator-tools",
16
+ "passive-routing",
17
+ "subagents"
18
+ ];
19
+ const EXPERIMENTAL_FEATURE_SET = new Set(EXPERIMENTAL_FEATURES);
20
+ let configuredExperimental = {};
21
+ function isExperimentalFeature(value) {
22
+ return EXPERIMENTAL_FEATURE_SET.has(value);
23
+ }
24
+ /** Replace app-level experimental opt-ins and return the previous setting. */
25
+ function setExperimentalFeatures(config) {
26
+ const previous = { ...configuredExperimental };
27
+ if (config === void 0) {
28
+ configuredExperimental = {};
29
+ return previous;
30
+ }
31
+ const next = {};
32
+ for (const [rawName, enabled] of Object.entries(config)) {
33
+ if (enabled === void 0) continue;
34
+ if (typeof enabled !== "boolean") throw new Error(`experimental.${rawName} must be a boolean when provided`);
35
+ if (!isExperimentalFeature(rawName)) throw new Error(`experimental.${rawName} is not a known experimental feature. Known features: ${EXPERIMENTAL_FEATURES.join(", ")}`);
36
+ next[rawName] = enabled;
37
+ }
38
+ configuredExperimental = next;
39
+ return previous;
40
+ }
41
+ /** Return a copy of the app-level experimental opt-ins configured by createApp(). */
42
+ function getExperimentalFeatures() {
43
+ return { ...configuredExperimental };
44
+ }
45
+ /** Return whether one experimental feature is enabled via createApp({ experimental }). */
46
+ function isExperimentalFeatureEnabled(feature) {
47
+ return configuredExperimental[feature] === true;
48
+ }
49
+ //#endregion
50
+ export { setExperimentalFeatures as i, getExperimentalFeatures as n, isExperimentalFeatureEnabled as r, experimental_exports as t };