@sentry/junior 0.236.0 → 0.238.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 (73) hide show
  1. package/dist/{context-0Et9iVSB.js → actor-BTtLaeWy.js} +1 -96
  2. package/dist/admin-ZGlZ8lY6.js +33 -0
  3. package/dist/{agent-hooks-Da_H0jHv.js → agent-hooks-CxdSqU2u.js} +1426 -2965
  4. package/dist/{agent-runner-uP7QRc4c.js → agent-runner-ZS1LHtSR.js} +275 -143
  5. package/dist/api/schema.d.ts +4 -0
  6. package/dist/api/schema.js +4 -3
  7. package/dist/api.d.ts +1 -1
  8. package/dist/api.js +32 -25
  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 +27 -23
  12. package/dist/{automation-B9Kc1gcf.js → automation-CrQGQ2MT.js} +3 -2
  13. package/dist/{briefs-DrjBPQFy.js → briefs-B6IhUAgK.js} +4 -4
  14. package/dist/{catalog-runtime-C7339Cfm.js → catalog-runtime-BzNg07bb.js} +1 -1
  15. package/dist/{checkpoint-DaD7_Gsb.js → checkpoint-DWGyJg4c.js} +19 -10
  16. package/dist/cli/chat.js +13 -13
  17. package/dist/cli/check.js +3 -3
  18. package/dist/cli/main.js +6 -2
  19. package/dist/cli/plugins.js +5 -3
  20. package/dist/cli/run.d.ts +2 -1
  21. package/dist/cli/run.js +2 -1
  22. package/dist/cli/snapshot-create.js +3 -3
  23. package/dist/cli/upgrade.d.ts +1 -1
  24. package/dist/cli/upgrade.js +3 -3
  25. package/dist/{client-Ch9Hg9NU.js → client-CKs0rj3A.js} +2 -2
  26. package/dist/{config-JR9wke1W.js → config-DRw358bB.js} +2 -2
  27. package/dist/{conversation-9Fxa1Zbq.js → conversation-DwD-vquD.js} +3 -517
  28. package/dist/{conversation-privacy-au02dyZK.js → conversation-privacy-DAYxHp74.js} +1 -1
  29. package/dist/{credential-sync-BWTA3LnL.js → credential-sync-DmRbuyE4.js} +15 -14
  30. package/dist/{db-Ca9Nt5ci.d.ts → db-CWZP77Ex.d.ts} +1 -1
  31. package/dist/{executor-BW9XWgUQ.js → executor-DgPk8Lsx.js} +5 -2
  32. package/dist/experimental-Qn9rKLgx.js +50 -0
  33. package/dist/history-BLTUgFYO.js +518 -0
  34. package/dist/{images-BdG7zcNf.js → images-puyEuXoY.js} +3 -3
  35. package/dist/instrumentation.js +2 -2
  36. package/dist/{job-queue-BqXd0ZPV.js → job-queue-BL9stv_E.js} +1 -1
  37. package/dist/{logging-B4sKwmCG.js → logging-BNi_jyHb.js} +1 -1
  38. package/dist/nitro.d.ts +1 -1
  39. package/dist/nitro.js +3 -3
  40. package/dist/{oauth-authorization-BjRN99dc.js → oauth-authorization-Zv1oLB1J.js} +1 -1
  41. package/dist/{oauth-callback-server-B_1p98Mb.js → oauth-callback-server-BHtVbKvO.js} +2 -2
  42. package/dist/pending-auth-DulDjfwL.js +433 -0
  43. package/dist/{profile-BamYnmhO.js → profile-C2TScny6.js} +5 -7
  44. package/dist/{prompt-Ctwy6hSI.js → prompt-CMU-B4FA.js} +1 -1
  45. package/dist/{registry-CXNv9fDX.js → registry-D1RsbgDb.js} +111 -3
  46. package/dist/{resolve-C9ETkt4T.js → resolve-CuY3dhxy.js} +2 -2
  47. package/dist/{runner-DnBGVRnW.js → runner-BUkReLln.js} +10 -10
  48. package/dist/{sandbox-egress-signals-DwJ7Boi_.js → sandbox-egress-signals-etjG6qQX.js} +1 -1
  49. package/dist/{schema-CJiqDc5r.js → schema-CxWAN2zq.js} +2 -2
  50. package/dist/{skills-Dd8O9Aav.js → skills-BGhThSGR.js} +2 -2
  51. package/dist/{spawn-DFdRspSD.js → spawn-PtyOnoXt.js} +2 -2
  52. package/dist/{store-DoewL5mG.d.ts → store-BxxbxBlm.d.ts} +7 -0
  53. package/dist/{task-queue-DGQEOk1A.js → task-queue-Bi2uNATu.js} +3 -3
  54. package/dist/{task-runner-C5XCIDSF.js → task-runner-CDoZCo8g.js} +20 -10
  55. package/dist/{thread-state-D3E29wZk.js → thread-state-B-t88gH0.js} +6 -5
  56. package/dist/{turn-failure-response-TDoj0aZz.js → turn-failure-response-di4Jx90o.js} +10 -9
  57. package/dist/{turn-lifecycle-DOnU45p7.js → turn-lifecycle-ByhUHYjD.js} +1 -1
  58. package/dist/{turn-session-routing-DbpZZoin.js → turn-session-routing-QjNvsevm.js} +1 -1
  59. package/dist/{validation-B9lMbisx.js → validation-D3li76Ti.js} +2 -3
  60. package/dist/{version-CWkIGcLU.js → version-Chc6bVG5.js} +1 -1
  61. package/dist/version.js +1 -1
  62. package/dist/viewer-DsyM9kb9.js +1636 -0
  63. package/dist/{web-authorization-PPaoj2ns.js → web-authorization-Enb5lVYt.js} +6 -6
  64. package/dist/{web-input-CfNxXtHm.js → web-input-efQlcCis.js} +64 -502
  65. package/dist/{work-DNaoFrEe.js → work-CeiA_ZxD.js} +9 -10
  66. package/dist/{worker-xeJLxYwm.js → worker-BJb2hsUB.js} +5 -5
  67. package/migrations/0047_user_timezone.sql +1 -0
  68. package/migrations/0048_user_admin.sql +1 -0
  69. package/migrations/meta/0047_snapshot.json +3713 -0
  70. package/migrations/meta/0048_snapshot.json +3720 -0
  71. package/migrations/meta/_journal.json +14 -0
  72. package/package.json +4 -4
  73. package/dist/pending-auth-WqF4Gh8Z.js +0 -59
@@ -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 };
@@ -0,0 +1,518 @@
1
+ import { l as TURN_REASONING_LEVELS, s as modelProfileSchema } from "./model-profile-BwU8mqwD.js";
2
+ import { z } from "zod";
3
+ import { actorSchema } 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
518
+ export { conversationTurnFailureReasonSchema as a, newConversationEventSchema as c, instructionActors as d, instructionProvenanceFor as f, conversationTurnFailureCodeSchema as i, encodeHistoryPayload as l, usageSchema as m, agentHistoryItemSchema as n, decodeStoredConversationEvent as o, sameActorIdentity as p, conversationEventDataSchema as r, historyReplacementSchema as s, KNOWN_CONVERSATION_EVENT_TYPES as t, contextProvenance as u };
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { j as storeAttachment, k as readLiveAttachment } from "./agent-runner-uP7QRc4c.js";
3
- import { nn as getSqlExecutor } from "./agent-hooks-Da_H0jHv.js";
4
- import "./conversation-9Fxa1Zbq.js";
2
+ import { D as storeAttachment, T as readLiveAttachment } from "./agent-runner-ZS1LHtSR.js";
3
+ import { f as getSqlExecutor } from "./viewer-DsyM9kb9.js";
4
+ import "./conversation-DwD-vquD.js";
5
5
  //#region src/chat/attachments/images.ts
6
6
  var images_exports = /* @__PURE__ */ __exportAll({
7
7
  decodeInputImages: () => decodeInputImages,
@@ -1,6 +1,6 @@
1
- import { N as getDeploymentServiceVersion, P as getDeploymentTelemetryAttributes } from "./logging-B4sKwmCG.js";
1
+ import { N as getDeploymentServiceVersion, P as getDeploymentTelemetryAttributes } from "./logging-BNi_jyHb.js";
2
2
  import { _ as vercelAIIntegration, a as getClient, b as withStreamedSpan, c as init, o as getGlobalScope } from "./sentry-CgWZM_kV.js";
3
- import { n as getCurrentConversationPrivacy } from "./conversation-privacy-au02dyZK.js";
3
+ import { n as getCurrentConversationPrivacy } from "./conversation-privacy-DAYxHp74.js";
4
4
  import { t as consumePrivateTraceResultMarker } from "./private-trace-result-BLvBjy_e.js";
5
5
  //#region src/chat/sentry-payload-filter.ts
6
6
  const PAYLOAD_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([
@@ -1,4 +1,4 @@
1
- import { i as getChatConfig } from "./config-JR9wke1W.js";
1
+ import { i as getChatConfig } from "./config-DRw358bB.js";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
3
  import { z } from "zod";
4
4
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
@@ -1,5 +1,5 @@
1
1
  import { d as setTag, f as setUser, h as startSpan, i as getActiveSpan, l as logger, n as captureMessage, p as spanToJSON, s as getTraceData, t as captureException, y as withScope } from "./sentry-CgWZM_kV.js";
2
- import { t as JUNIOR_VERSION } from "./version-CWkIGcLU.js";
2
+ import { t as JUNIOR_VERSION } from "./version-Chc6bVG5.js";
3
3
  import path from "node:path";
4
4
  import { styleText } from "node:util";
5
5
  import { ConfigError, configureSync, getConfig, getLogger } from "@logtape/logtape";
package/dist/nitro.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { r as JuniorDashboardOptions } from "./app-MEd7wbF0.js";
1
+ import { r as JuniorDashboardOptions } from "./app-FB2hmHpZ.js";
2
2
  import { n as JuniorPluginSet } from "./plugins-CjfUP5gJ.js";
3
3
  //#region src/nitro.d.ts
4
4
  export type JuniorNitroDashboardOptions = JuniorDashboardOptions;
package/dist/nitro.js CHANGED
@@ -1,8 +1,8 @@
1
- import { A as JUNIOR_RETENTION_ROUTE, D as JUNIOR_HEARTBEAT_ROUTE, E as JUNIOR_HEARTBEAT_CRON_SCHEDULE, O as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, T as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, j as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, k as JUNIOR_RETENTION_CRON_SCHEDULE } from "./logging-B4sKwmCG.js";
1
+ import { A as JUNIOR_RETENTION_ROUTE, D as JUNIOR_HEARTBEAT_ROUTE, E as JUNIOR_HEARTBEAT_CRON_SCHEDULE, O as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, T as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, j as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, k as JUNIOR_RETENTION_CRON_SCHEDULE } from "./logging-BNi_jyHb.js";
2
2
  import { d as resolvePackageDir, t as discoverInstalledPluginPackageContent, u as isValidPackageName } from "./package-discovery-BVvSnQBB.js";
3
- import { o as resolveConversationWorkQueueTopic, t as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC } from "./job-queue-BqXd0ZPV.js";
3
+ import { o as resolveConversationWorkQueueTopic, t as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC } from "./job-queue-BL9stv_E.js";
4
4
  import { a as pluginRuntimeRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "./plugins-egKWjgue.js";
5
- import { t as PLUGIN_TASK_QUEUE_TOPIC } from "./task-queue-DGQEOk1A.js";
5
+ import { t as PLUGIN_TASK_QUEUE_TOPIC } from "./task-queue-Bi2uNATu.js";
6
6
  import { n as loadPluginSetFromModule, r as resolvePluginModule } from "./plugin-module-CVvEUSMH.js";
7
7
  import path from "node:path";
8
8
  import { cpSync, existsSync, mkdirSync, readdirSync, statSync } from "node:fs";
@@ -1,4 +1,4 @@
1
- import { h as extractAssistantText } from "./checkpoint-DaD7_Gsb.js";
1
+ import { h as extractAssistantText } from "./checkpoint-DWGyJg4c.js";
2
2
  //#region src/chat/runtime/turn.ts
3
3
  /** Classified Slack turn failure carrying the owning Sentry capture outward. */
4
4
  var ConversationTurnBoundaryError = class extends Error {
@@ -1,5 +1,5 @@
1
- import { Pn as createUserTokenStore } from "./agent-runner-uP7QRc4c.js";
2
- import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-BWTA3LnL.js";
1
+ import { Mn as createUserTokenStore } from "./agent-runner-ZS1LHtSR.js";
2
+ import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-DmRbuyE4.js";
3
3
  import { createServer } from "node:http";
4
4
  //#region src/chat/local/oauth-callback-server.ts
5
5
  const LOCAL_OAUTH_TIMEOUT_MS = 6e5;