@sentry/junior 0.203.0 → 0.204.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 (174) hide show
  1. package/dist/agent-CMyTD4DD.js +17509 -0
  2. package/dist/agent-hooks-Bbcp9e33.js +4040 -0
  3. package/dist/agent-runner-DNb1A49M.js +678 -0
  4. package/dist/api/schema.d.ts +2728 -2639
  5. package/dist/api/schema.js +4 -169
  6. package/dist/api.d.ts +23 -17
  7. package/dist/api.js +3881 -5326
  8. package/dist/app-B1TOqBI8.d.ts +246 -0
  9. package/dist/app.d.ts +4 -520
  10. package/dist/app.js +9522 -11875
  11. package/dist/auth-pause-state-DosEalIG.js +168 -0
  12. package/dist/catalog-runtime-BReos-D4.js +7 -0
  13. package/dist/checkpoint-CNrPyRJN.js +2450 -0
  14. package/dist/cli/chat.d.ts +20 -0
  15. package/dist/cli/chat.js +229 -336
  16. package/dist/cli/check.d.ts +8 -0
  17. package/dist/cli/check.js +513 -806
  18. package/dist/cli/env.d.ts +13 -0
  19. package/dist/cli/env.js +63 -12
  20. package/dist/cli/init.d.ts +3 -0
  21. package/dist/cli/init.js +90 -159
  22. package/dist/cli/main.d.ts +6 -0
  23. package/dist/cli/main.js +43 -64
  24. package/dist/cli/plugins.d.ts +13 -0
  25. package/dist/cli/plugins.js +148 -227
  26. package/dist/cli/run.d.ts +16 -0
  27. package/dist/cli/run.js +52 -8
  28. package/dist/cli/snapshot-create.d.ts +4 -0
  29. package/dist/cli/snapshot-create.js +71 -125
  30. package/dist/cli/upgrade.d.ts +15 -0
  31. package/dist/cli/upgrade.js +232 -335
  32. package/dist/config-nGCW1OTG.js +941 -0
  33. package/dist/context-B45_WqVX.js +298 -0
  34. package/dist/conversation-privacy-B4voFRSm.js +182 -0
  35. package/dist/conversation-work-C6y3T5Hx.js +51 -0
  36. package/dist/credential-sync-kXr1hvO1.js +2660 -0
  37. package/dist/db-BeyXKJOI.d.ts +5 -0
  38. package/dist/destinations-BeBiJeEM.js +29 -0
  39. package/dist/execution-stats-DWfSihcH.js +373 -0
  40. package/dist/executor-DcMSlI5c.js +721 -0
  41. package/dist/experimental-CIXf7Uye.js +46 -0
  42. package/dist/history-ClE4toxe.d.ts +32 -0
  43. package/dist/history-CqTuSAdI.js +441 -0
  44. package/dist/instrumentation.d.ts +3 -3
  45. package/dist/instrumentation.js +130 -176
  46. package/dist/job-queue-Drn_LXlM.js +63 -0
  47. package/dist/logging-BzAk1S_s.js +1210 -0
  48. package/dist/model-profile-CZmVoGdX.js +49 -0
  49. package/dist/nitro.d.ts +31 -36
  50. package/dist/nitro.js +275 -456
  51. package/dist/oauth-callback-server-JiftokvA.js +130 -0
  52. package/dist/oauth-relay-CdCnu80W.js +62 -0
  53. package/dist/package-discovery-7a9YqLhE.js +455 -0
  54. package/dist/pending-auth-CWmSdZVg.js +185 -0
  55. package/dist/plugin-module-BKGOXca2.js +81 -0
  56. package/dist/plugins-BI9A1vKA.d.ts +95 -0
  57. package/dist/plugins-egKWjgue.js +99 -0
  58. package/dist/private-trace-result-BLvBjy_e.js +16 -0
  59. package/dist/profile-CrT5nXbw.js +861 -0
  60. package/dist/registry-DH1xUo2N.js +1419 -0
  61. package/dist/reporting-schema-DosTN__Q.js +105 -0
  62. package/dist/resolve-CZHnfxaS.js +546 -0
  63. package/dist/rolldown-runtime-B4FMCO8f.js +28 -0
  64. package/dist/runner-CZV2sC46.js +392 -0
  65. package/dist/sandbox-egress-signals-bHZfmhbd.js +46 -0
  66. package/dist/schema-Rn8-XEaN.js +1140 -0
  67. package/dist/sentry-CD3SdJl-.js +26 -0
  68. package/dist/skills-CIcDQSgM.js +316 -0
  69. package/dist/spawn-DdkUFRmq.js +29 -0
  70. package/dist/stats-DTUbAb88.js +2634 -0
  71. package/dist/store-C5qxF2ac.d.ts +208 -0
  72. package/dist/task-queue-CJIR4RF7.js +136 -0
  73. package/dist/task-runner-D-O3A-Cp.js +639 -0
  74. package/dist/thread-state-CRc9jTJS.js +431 -0
  75. package/dist/turn-execution-BkinIdJF.js +47 -0
  76. package/dist/turn-lifecycle-DQV19VTW.js +54 -0
  77. package/dist/usage-D3EbSO7w.js +296 -0
  78. package/dist/usage-schema-CKaDkH_j.js +20 -0
  79. package/dist/validation-C2CR-OX3.js +40 -0
  80. package/dist/vercel-queue-DIkVcfK4.js +167 -0
  81. package/dist/vercel.d.ts +6 -6
  82. package/dist/vercel.js +14 -6
  83. package/dist/version-CnXZ614E.d.ts +5 -0
  84. package/dist/version-DxcWdoKa.js +8 -0
  85. package/dist/version.d.ts +2 -4
  86. package/dist/version.js +2 -6
  87. package/dist/web-authorization-RMBxAR_t.js +76 -0
  88. package/dist/web-input-3EPfpf55.js +494 -0
  89. package/dist/work-fGofI7Op.js +509 -0
  90. package/dist/worker-CsOLq-mR.js +625 -0
  91. package/package.json +8 -8
  92. package/dist/agent-hooks-GB2VPTNA.js +0 -51
  93. package/dist/catalog-runtime-UBLIWD3O.js +0 -14
  94. package/dist/chunk-2LYHWMR4.js +0 -46
  95. package/dist/chunk-352OWAZH.js +0 -320
  96. package/dist/chunk-3Y47VMHV.js +0 -6
  97. package/dist/chunk-3YJSKOWF.js +0 -164
  98. package/dist/chunk-4KSSKTQ5.js +0 -229
  99. package/dist/chunk-4UO6FK4G.js +0 -64
  100. package/dist/chunk-5AHX53NQ.js +0 -717
  101. package/dist/chunk-5J3E5FWA.js +0 -700
  102. package/dist/chunk-5PDAG6O3.js +0 -206
  103. package/dist/chunk-6Y5B5PEX.js +0 -80
  104. package/dist/chunk-7GWQ5S5R.js +0 -2086
  105. package/dist/chunk-7H2VZTWN.js +0 -103
  106. package/dist/chunk-7NL7T6VU.js +0 -406
  107. package/dist/chunk-A5L27LE4.js +0 -387
  108. package/dist/chunk-ADIAWL34.js +0 -81
  109. package/dist/chunk-ASTEMBKJ.js +0 -519
  110. package/dist/chunk-CEMMLV5L.js +0 -98
  111. package/dist/chunk-CM5HNV2W.js +0 -131
  112. package/dist/chunk-CRTRBBRI.js +0 -105
  113. package/dist/chunk-DA2KGZZI.js +0 -13
  114. package/dist/chunk-DIB4GX3G.js +0 -8
  115. package/dist/chunk-DKIJ2RP5.js +0 -68
  116. package/dist/chunk-DWPN6SCH.js +0 -172
  117. package/dist/chunk-EDKUFGPL.js +0 -64
  118. package/dist/chunk-ENY6SKIU.js +0 -1228
  119. package/dist/chunk-F4MGCZOX.js +0 -2943
  120. package/dist/chunk-FA6POGLH.js +0 -70
  121. package/dist/chunk-FSUR7GTG.js +0 -20475
  122. package/dist/chunk-GKEOHJL5.js +0 -1856
  123. package/dist/chunk-GMCB6W5Y.js +0 -333
  124. package/dist/chunk-IE2VPG7O.js +0 -1135
  125. package/dist/chunk-IZ5B5IHQ.js +0 -3656
  126. package/dist/chunk-JAL3CH4G.js +0 -27
  127. package/dist/chunk-KIIEUXD3.js +0 -1764
  128. package/dist/chunk-KXU4NIL7.js +0 -692
  129. package/dist/chunk-MTM5IFCY.js +0 -1190
  130. package/dist/chunk-N7TMSOZH.js +0 -235
  131. package/dist/chunk-NCEBK6PH.js +0 -36
  132. package/dist/chunk-NHJU2ZAL.js +0 -56
  133. package/dist/chunk-P6KTRNVC.js +0 -321
  134. package/dist/chunk-PDO5BLNM.js +0 -22
  135. package/dist/chunk-PDRNLLFT.js +0 -3295
  136. package/dist/chunk-PEQXYSSE.js +0 -45
  137. package/dist/chunk-PKEX2AQX.js +0 -198
  138. package/dist/chunk-PSJCGIGO.js +0 -1163
  139. package/dist/chunk-PZUSUL55.js +0 -506
  140. package/dist/chunk-R45M4TUS.js +0 -37
  141. package/dist/chunk-RC745GGZ.js +0 -122
  142. package/dist/chunk-SP3QKZXJ.js +0 -820
  143. package/dist/chunk-TXKUKMVO.js +0 -417
  144. package/dist/chunk-UE4GPWSD.js +0 -931
  145. package/dist/chunk-UIE3R5XU.js +0 -17
  146. package/dist/chunk-UXPG6ZIN.js +0 -84
  147. package/dist/chunk-VFUK3X5B.js +0 -50
  148. package/dist/chunk-VNMJWREK.js +0 -787
  149. package/dist/chunk-VZ7CSOX2.js +0 -706
  150. package/dist/chunk-WCNQJKFT.js +0 -10
  151. package/dist/chunk-WDZR3QQM.js +0 -135
  152. package/dist/chunk-WLYVJCHV.js +0 -1433
  153. package/dist/chunk-WS7NAFTM.js +0 -1520
  154. package/dist/chunk-X6GDDWQH.js +0 -60
  155. package/dist/chunk-XPDEYNQI.js +0 -102
  156. package/dist/chunk-XRW44VGM.js +0 -58
  157. package/dist/chunk-Y2CM7HXH.js +0 -111
  158. package/dist/chunk-Y7X25LFY.js +0 -15
  159. package/dist/conversation-work-VIOQ5ZF3.js +0 -54
  160. package/dist/db-NGDJV7YH.js +0 -26
  161. package/dist/discovery-DWVDM7UK.js +0 -44
  162. package/dist/experimental-P5FZM4CU.js +0 -12
  163. package/dist/oauth-callback-server-YFY7YEGK.js +0 -243
  164. package/dist/oauth-relay-5XPVRPYB.js +0 -8
  165. package/dist/plugins-YTYJMMJF.js +0 -14
  166. package/dist/runner-ORTNSB2Q.js +0 -522
  167. package/dist/sandbox-egress-signals-FIL7EGPR.js +0 -73
  168. package/dist/sentry-MB3NL3IR.js +0 -42
  169. package/dist/skills-H376WQOH.js +0 -27
  170. package/dist/spawn-T43WHLOS.js +0 -42
  171. package/dist/task-runner-LBZWF32V.js +0 -36
  172. package/dist/validation-REJLRKI6.js +0 -17
  173. package/dist/work-3KJ3RE76.js +0 -51
  174. package/dist/worker-QFEBU72E.js +0 -24
@@ -0,0 +1,46 @@
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 = ["passive-routing", "subagents"];
15
+ const EXPERIMENTAL_FEATURE_SET = new Set(EXPERIMENTAL_FEATURES);
16
+ let configuredExperimental = {};
17
+ function isExperimentalFeature(value) {
18
+ return EXPERIMENTAL_FEATURE_SET.has(value);
19
+ }
20
+ /** Replace app-level experimental opt-ins and return the previous setting. */
21
+ function setExperimentalFeatures(config) {
22
+ const previous = { ...configuredExperimental };
23
+ if (config === void 0) {
24
+ configuredExperimental = {};
25
+ return previous;
26
+ }
27
+ const next = {};
28
+ for (const [rawName, enabled] of Object.entries(config)) {
29
+ if (enabled === void 0) continue;
30
+ if (typeof enabled !== "boolean") throw new Error(`experimental.${rawName} must be a boolean when provided`);
31
+ if (!isExperimentalFeature(rawName)) throw new Error(`experimental.${rawName} is not a known experimental feature. Known features: ${EXPERIMENTAL_FEATURES.join(", ")}`);
32
+ next[rawName] = enabled;
33
+ }
34
+ configuredExperimental = next;
35
+ return previous;
36
+ }
37
+ /** Return a copy of the app-level experimental opt-ins configured by createApp(). */
38
+ function getExperimentalFeatures() {
39
+ return { ...configuredExperimental };
40
+ }
41
+ /** Return whether one experimental feature is enabled via createApp({ experimental }). */
42
+ function isExperimentalFeatureEnabled(feature) {
43
+ return configuredExperimental[feature] === true;
44
+ }
45
+ //#endregion
46
+ export { setExperimentalFeatures as i, getExperimentalFeatures as n, isExperimentalFeatureEnabled as r, experimental_exports as t };
@@ -0,0 +1,32 @@
1
+ import { z } from "zod";
2
+ //#region src/chat/conversations/history.d.ts
3
+ /** Where a failed turn stopped. */
4
+ declare const conversationTurnFailureCodeSchema: z.ZodEnum<{
5
+ agent_run_failed: "agent_run_failed";
6
+ delivery_failed: "delivery_failed";
7
+ model_execution_failed: "model_execution_failed";
8
+ persistence_failed: "persistence_failed";
9
+ }>;
10
+ /**
11
+ * Why a failed turn stopped.
12
+ * Values are fixed labels only. Do not store raw exception text.
13
+ */
14
+ declare const conversationTurnFailureReasonSchema: z.ZodEnum<{
15
+ unknown: "unknown";
16
+ capacity: "capacity";
17
+ auth: "auth";
18
+ permission: "permission";
19
+ rate_limit: "rate_limit";
20
+ timeout: "timeout";
21
+ network: "network";
22
+ server: "server";
23
+ invalid_request: "invalid_request";
24
+ invalid_response: "invalid_response";
25
+ quota: "quota";
26
+ content_policy: "content_policy";
27
+ empty_output: "empty_output";
28
+ tool_errors: "tool_errors";
29
+ suppressed_output: "suppressed_output";
30
+ }>;
31
+ //#endregion
32
+ export { conversationTurnFailureReasonSchema as n, conversationTurnFailureCodeSchema as t };
@@ -0,0 +1,441 @@
1
+ import { c as TURN_REASONING_LEVELS, o as modelProfileSchema } from "./model-profile-CZmVoGdX.js";
2
+ import { z } from "zod";
3
+ import { actorSchema } from "@sentry/junior-plugin-api";
4
+ //#region src/chat/conversations/provenance.ts
5
+ /**
6
+ * Durable message attribution shared by storage and projections.
7
+ * Attribution never grants credential authority.
8
+ */
9
+ const conversationMessageAuthoritySchema = z.union([z.literal("instruction"), z.literal("context")]);
10
+ /** Canonical authority and actor metadata for one durable message event. */
11
+ const conversationMessageProvenanceSchema = z.object({
12
+ authority: conversationMessageAuthoritySchema,
13
+ actor: actorSchema.optional()
14
+ }).strict();
15
+ /** Build instruction provenance for an optional actor. */
16
+ function instructionProvenanceFor(actor) {
17
+ return actor ? {
18
+ authority: "instruction",
19
+ actor
20
+ } : { authority: "instruction" };
21
+ }
22
+ /** Unattributed ambient-context provenance for non-instruction messages. */
23
+ const contextProvenance = { authority: "context" };
24
+ function actorIdentityKey(actor) {
25
+ if (actor.platform === "system") return `system ${actor.name}`;
26
+ return actor.platform === "slack" ? `slack\u0000${actor.teamId}\u0000${actor.userId}` : `${actor.platform}\u0000${actor.userId}`;
27
+ }
28
+ /** Compare two actors by runtime identity only, never by display metadata. */
29
+ function sameActorIdentity(left, right) {
30
+ return Boolean(left && right && actorIdentityKey(left) === actorIdentityKey(right));
31
+ }
32
+ /**
33
+ * Return distinct instruction actors in first-seen order for attribution only.
34
+ * Never use this list as credential authority.
35
+ */
36
+ function instructionActors(provenance) {
37
+ const seen = /* @__PURE__ */ new Set();
38
+ const actors = [];
39
+ for (const entry of provenance) {
40
+ if (entry.authority !== "instruction" || !entry.actor) continue;
41
+ const identity = actorIdentityKey(entry.actor);
42
+ if (seen.has(identity)) continue;
43
+ seen.add(identity);
44
+ actors.push(entry.actor);
45
+ }
46
+ return actors;
47
+ }
48
+ //#endregion
49
+ //#region src/chat/conversations/history.ts
50
+ /**
51
+ * Durable conversation event history port.
52
+ *
53
+ * Events append under the conversation lease in stable sequence order.
54
+ * Compaction and handoff replace the active model history without rewriting
55
+ * prior events. Unsupported stored events remain readable as opaque facts,
56
+ * while malformed known events fail loudly. Provider-specific message fields
57
+ * are validated by the Pi adapter when it restores model context.
58
+ */
59
+ const userMessageEventDataSchema = z.object({
60
+ type: z.literal("user_message"),
61
+ role: z.never().optional(),
62
+ provenance: conversationMessageProvenanceSchema
63
+ }).passthrough();
64
+ const assistantMessageEventDataSchema = z.object({
65
+ type: z.literal("assistant_message"),
66
+ role: z.never().optional()
67
+ }).passthrough();
68
+ const toolResultEventDataSchema = z.object({
69
+ type: z.literal("tool_result"),
70
+ role: z.never().optional()
71
+ }).passthrough();
72
+ /**
73
+ * One replayable agent-history item. Junior owns `type` and user provenance,
74
+ * forbids the provider `role` discriminator, and leaves preserved message
75
+ * fields for the Pi adapter to validate when restoring model context.
76
+ */
77
+ const agentHistoryItemSchema = z.discriminatedUnion("type", [
78
+ userMessageEventDataSchema,
79
+ assistantMessageEventDataSchema,
80
+ toolResultEventDataSchema
81
+ ]);
82
+ const nativeReplacementHistoryItemSchema = z.object({
83
+ item: agentHistoryItemSchema,
84
+ sourceEventSeq: z.number().int().nonnegative().optional()
85
+ }).strict();
86
+ /**
87
+ * The complete agent history used immediately after a replacement. Later
88
+ * native history events append to it. Replacement entries are replayed model
89
+ * history, not new conversation activity.
90
+ */
91
+ const replacementHistorySchema = z.array(nativeReplacementHistoryItemSchema);
92
+ const compactionDetailsSchema = z.object({
93
+ reason: z.literal("capacity"),
94
+ estimatedInputTokens: z.number().int().nonnegative(),
95
+ replacementInputTokens: z.number().int().nonnegative().optional(),
96
+ triggerTokens: z.number().int().nonnegative(),
97
+ inputLimitTokens: z.number().int().positive(),
98
+ inputMessageCount: z.number().int().nonnegative(),
99
+ retainedMessageCount: z.number().int().nonnegative(),
100
+ summaryChars: z.number().int().nonnegative()
101
+ }).strict();
102
+ const historyReplacementEventDataSchema = z.discriminatedUnion("type", [z.object({
103
+ type: z.literal("handoff"),
104
+ modelProfile: modelProfileSchema,
105
+ modelId: z.string().min(1),
106
+ reasoningLevel: z.string().min(1).optional(),
107
+ triggeringToolCallId: z.string().min(1).optional(),
108
+ summary: z.string().min(1).optional(),
109
+ replacementHistory: replacementHistorySchema
110
+ }).strict(), z.object({
111
+ type: z.literal("compaction"),
112
+ modelProfile: modelProfileSchema,
113
+ modelId: z.string().min(1),
114
+ details: compactionDetailsSchema.optional(),
115
+ summary: z.string().min(1).optional(),
116
+ replacementHistory: replacementHistorySchema
117
+ }).strict()]);
118
+ /** Validate an event that intentionally replaces active model history. */
119
+ const historyReplacementSchema = z.object({
120
+ data: historyReplacementEventDataSchema,
121
+ createdAtMs: z.number().finite()
122
+ }).strict();
123
+ const mcpProviderConnectedEventDataSchema = z.object({
124
+ type: z.literal("mcp_provider_connected"),
125
+ provider: z.string().min(1),
126
+ credentialSubjectId: z.string().min(1)
127
+ }).strict();
128
+ const unownedMcpProviderConnectedEventDataSchema = z.object({
129
+ type: z.literal("mcp_provider_connected_unowned"),
130
+ provider: z.string().min(1)
131
+ }).strict();
132
+ const authorizationKindSchema = z.union([z.literal("plugin"), z.literal("mcp")]);
133
+ const authorizationRequestedEventDataSchema = z.object({
134
+ type: z.literal("authorization_requested"),
135
+ kind: authorizationKindSchema,
136
+ provider: z.string().min(1),
137
+ actorId: z.string().min(1),
138
+ authorizationId: z.string().min(1),
139
+ delivery: z.union([z.literal("private_link_sent"), z.literal("private_link_reused")])
140
+ }).strict();
141
+ const authorizationCompletedEventDataSchema = z.object({
142
+ type: z.literal("authorization_completed"),
143
+ kind: authorizationKindSchema,
144
+ provider: z.string().min(1),
145
+ actorId: z.string().min(1),
146
+ authorizationId: z.string().min(1)
147
+ }).strict();
148
+ const toolExecutionStartedEventDataSchema = z.object({
149
+ type: z.literal("tool_execution_started"),
150
+ toolCallId: z.string().min(1),
151
+ toolName: z.string().min(1)
152
+ }).strict();
153
+ const guardianActionReviewedEventDataSchema = z.object({
154
+ type: z.literal("guardian_action_reviewed"),
155
+ turnId: z.string().min(1),
156
+ toolCallId: z.string().min(1),
157
+ toolName: z.string().min(1),
158
+ costUsd: z.number().finite().nonnegative().optional(),
159
+ decision: z.enum([
160
+ "allow",
161
+ "ask",
162
+ "deny"
163
+ ]),
164
+ riskLevel: z.enum([
165
+ "low",
166
+ "medium",
167
+ "high",
168
+ "critical"
169
+ ]),
170
+ userAuthorization: z.enum([
171
+ "high",
172
+ "medium",
173
+ "low",
174
+ "unknown"
175
+ ])
176
+ }).strict();
177
+ const conversationMessageRoleSchema = z.union([
178
+ z.literal("user"),
179
+ z.literal("assistant"),
180
+ z.literal("system")
181
+ ]);
182
+ const messageEventDataSchema = z.object({
183
+ type: z.literal("message"),
184
+ messageId: z.string().min(1),
185
+ role: conversationMessageRoleSchema,
186
+ text: z.string(),
187
+ authorIdentityId: z.string().min(1).optional(),
188
+ meta: z.record(z.string(), z.unknown()).optional()
189
+ }).strict();
190
+ const messageUpdatedEventDataSchema = messageEventDataSchema.extend({ type: z.literal("message_updated") });
191
+ const messageHandledEventDataSchema = z.object({
192
+ type: z.literal("message_handled"),
193
+ messageId: z.string().min(1)
194
+ }).strict();
195
+ const messagesSummarizedEventDataSchema = z.object({
196
+ type: z.literal("messages_summarized"),
197
+ historyFromSeq: z.number().int().nonnegative(),
198
+ compactions: z.array(z.object({
199
+ coveredMessageCount: z.number().int().nonnegative(),
200
+ createdAtMs: z.number(),
201
+ id: z.string().min(1),
202
+ summary: z.string()
203
+ }).strict())
204
+ }).strict();
205
+ /** Product surface that owns a durable conversation turn. */
206
+ const conversationTurnSurfaceSchema = z.enum([
207
+ "slack",
208
+ "api",
209
+ "scheduler",
210
+ "internal"
211
+ ]);
212
+ /** Where a failed turn stopped. */
213
+ const conversationTurnFailureCodeSchema = z.enum([
214
+ "agent_run_failed",
215
+ "delivery_failed",
216
+ "model_execution_failed",
217
+ "persistence_failed"
218
+ ]);
219
+ /**
220
+ * Why a failed turn stopped.
221
+ * Values are fixed labels only. Do not store raw exception text.
222
+ */
223
+ const conversationTurnFailureReasonSchema = z.enum([
224
+ "auth",
225
+ "permission",
226
+ "rate_limit",
227
+ "capacity",
228
+ "timeout",
229
+ "network",
230
+ "server",
231
+ "invalid_request",
232
+ "invalid_response",
233
+ "quota",
234
+ "content_policy",
235
+ "unknown",
236
+ "empty_output",
237
+ "tool_errors",
238
+ "suppressed_output"
239
+ ]);
240
+ const turnStartedEventDataSchema = z.object({
241
+ type: z.literal("turn_started"),
242
+ turnId: z.string().min(1),
243
+ inputMessageIds: z.array(z.string().min(1)).min(1),
244
+ surface: conversationTurnSurfaceSchema
245
+ }).strict().refine((data) => new Set(data.inputMessageIds).size === data.inputMessageIds.length, "turn input message ids must be unique");
246
+ const turnRoutedEventDataSchema = z.object({
247
+ type: z.literal("turn_routed"),
248
+ turnId: z.string().min(1),
249
+ modelProfile: modelProfileSchema,
250
+ modelId: z.string().min(1),
251
+ costUsd: z.number().finite().nonnegative().optional(),
252
+ reasoningLevel: z.enum(TURN_REASONING_LEVELS),
253
+ confidence: z.number().min(0).max(1).optional(),
254
+ source: z.enum([
255
+ "configured",
256
+ "inherited",
257
+ "router"
258
+ ])
259
+ }).strict();
260
+ const turnContextEventDataSchema = z.object({
261
+ type: z.literal("turn_context"),
262
+ turnId: z.string().min(1),
263
+ pluginName: z.string().min(1),
264
+ kind: z.string().min(1).max(64),
265
+ version: z.number().int().positive(),
266
+ content: z.record(z.string(), z.unknown())
267
+ }).strict();
268
+ const structuredConversationEventDataSchema = z.object({
269
+ type: z.literal("structured_event"),
270
+ namespace: z.string().regex(/^[a-z][a-z0-9-]*$/),
271
+ name: z.string().regex(/^[a-z][a-z0-9_]*$/),
272
+ version: z.number().int().positive(),
273
+ turnId: z.string().min(1).optional(),
274
+ content: z.record(z.string(), z.unknown())
275
+ }).strict();
276
+ /** Durable attachment metadata on host-owned delivery events. */
277
+ const deliveredAttachmentSchema = z.object({
278
+ id: z.string().min(1),
279
+ filename: z.string().min(1),
280
+ contentType: z.string().min(1),
281
+ bytes: z.number().int().nonnegative()
282
+ }).strict();
283
+ /** Host-owned transcript item for files delivered to humans this turn. */
284
+ const attachmentsDeliveredEventDataSchema = z.object({
285
+ type: z.literal("attachments_delivered"),
286
+ attachments: z.array(deliveredAttachmentSchema).min(1),
287
+ toolCallId: z.string().min(1).optional(),
288
+ turnId: z.string().min(1).optional()
289
+ }).strict();
290
+ const turnCompletedEventDataSchema = z.object({
291
+ type: z.literal("turn_completed"),
292
+ turnId: z.string().min(1),
293
+ outcome: z.enum([
294
+ "success",
295
+ "no_reply",
296
+ "cancelled"
297
+ ])
298
+ }).strict();
299
+ const turnFailedEventDataSchema = z.object({
300
+ type: z.literal("turn_failed"),
301
+ turnId: z.string().min(1),
302
+ failureCode: conversationTurnFailureCodeSchema,
303
+ failureReason: conversationTurnFailureReasonSchema.optional(),
304
+ eventId: z.string().regex(/^[a-f0-9]{32}$/i).optional()
305
+ }).strict();
306
+ const subagentStartedEventDataSchema = z.object({
307
+ type: z.literal("subagent_started"),
308
+ subagentInvocationId: z.string().min(1),
309
+ subagentKind: z.string().min(1),
310
+ modelId: z.string().min(1).optional(),
311
+ parentToolCallId: z.string().min(1).optional(),
312
+ reasoningLevel: z.string().min(1).optional(),
313
+ childConversationId: z.string().min(1)
314
+ }).strict();
315
+ const subagentEndedEventDataSchema = z.object({
316
+ type: z.literal("subagent_ended"),
317
+ subagentInvocationId: z.string().min(1),
318
+ outcome: z.union([
319
+ z.literal("success"),
320
+ z.literal("error"),
321
+ z.literal("aborted")
322
+ ]),
323
+ errorCode: z.string().min(1).optional()
324
+ }).strict();
325
+ /** Prevent ordinary appends from bypassing history-replacement validation. */
326
+ const appendableConversationEventDataSchema = z.union([
327
+ messageEventDataSchema,
328
+ messageUpdatedEventDataSchema,
329
+ agentHistoryItemSchema,
330
+ mcpProviderConnectedEventDataSchema,
331
+ authorizationRequestedEventDataSchema,
332
+ authorizationCompletedEventDataSchema,
333
+ toolExecutionStartedEventDataSchema,
334
+ guardianActionReviewedEventDataSchema,
335
+ messageHandledEventDataSchema,
336
+ messagesSummarizedEventDataSchema,
337
+ turnStartedEventDataSchema,
338
+ turnContextEventDataSchema,
339
+ structuredConversationEventDataSchema,
340
+ attachmentsDeliveredEventDataSchema,
341
+ turnRoutedEventDataSchema,
342
+ turnCompletedEventDataSchema,
343
+ turnFailedEventDataSchema,
344
+ subagentStartedEventDataSchema,
345
+ subagentEndedEventDataSchema
346
+ ]);
347
+ /** Strict event-data contract reused by the SQL row codec. */
348
+ const conversationEventDataSchema = z.union([
349
+ appendableConversationEventDataSchema,
350
+ historyReplacementEventDataSchema,
351
+ unownedMcpProviderConnectedEventDataSchema
352
+ ]);
353
+ /** Event type names recognized by current readers and observational queries. */
354
+ const KNOWN_CONVERSATION_EVENT_TYPES = [
355
+ "message",
356
+ "message_updated",
357
+ "user_message",
358
+ "assistant_message",
359
+ "tool_result",
360
+ "mcp_provider_connected",
361
+ "mcp_provider_connected_unowned",
362
+ "authorization_requested",
363
+ "authorization_completed",
364
+ "tool_execution_started",
365
+ "guardian_action_reviewed",
366
+ "message_handled",
367
+ "messages_summarized",
368
+ "turn_started",
369
+ "turn_context",
370
+ "structured_event",
371
+ "attachments_delivered",
372
+ "turn_routed",
373
+ "turn_completed",
374
+ "turn_failed",
375
+ "subagent_started",
376
+ "subagent_ended",
377
+ "handoff",
378
+ "compaction"
379
+ ];
380
+ const knownConversationEventTypeSchema = z.enum(KNOWN_CONVERSATION_EVENT_TYPES);
381
+ const unknownConversationEventDataSchema = z.object({
382
+ type: z.literal("unknown"),
383
+ originalType: z.string().min(1),
384
+ payload: z.unknown()
385
+ }).strict();
386
+ const conversationEventEnvelopeSchema = z.object({
387
+ schemaVersion: z.number().int().nonnegative(),
388
+ seq: z.number().int().nonnegative(),
389
+ historyVersion: z.number().int().nonnegative(),
390
+ idempotencyKey: z.string().min(1).optional(),
391
+ createdAtMs: z.number().finite()
392
+ }).strict();
393
+ /**
394
+ * Canonical ordered envelope for the durable conversation log.
395
+ * `schemaVersion` is persisted with every physical event row.
396
+ */
397
+ const conversationEventSchema = z.union([conversationEventEnvelopeSchema.extend({
398
+ schemaVersion: z.literal(1),
399
+ data: conversationEventDataSchema
400
+ }), conversationEventEnvelopeSchema.extend({ data: unknownConversationEventDataSchema })]);
401
+ const storedConversationEventSchema = conversationEventEnvelopeSchema.extend({
402
+ type: z.string().min(1),
403
+ payload: z.unknown()
404
+ });
405
+ /**
406
+ * Decode a physical event row without making old or future event types
407
+ * unreadable. Unsupported rows stay opaque until an upgrade migration defines
408
+ * their semantics; known version-one events remain strict so corrupt canonical
409
+ * data cannot be mistaken for compatibility data.
410
+ */
411
+ function decodeStoredConversationEvent(value) {
412
+ const stored = storedConversationEventSchema.parse(value);
413
+ const { type, payload, ...envelope } = stored;
414
+ const knownType = knownConversationEventTypeSchema.safeParse(type).success;
415
+ if (stored.schemaVersion === 1 && knownType) {
416
+ const data = typeof payload === "object" && payload !== null && !Array.isArray(payload) ? {
417
+ ...payload,
418
+ type
419
+ } : { type };
420
+ return conversationEventSchema.parse({
421
+ ...envelope,
422
+ data
423
+ });
424
+ }
425
+ return conversationEventSchema.parse({
426
+ ...envelope,
427
+ data: {
428
+ type: "unknown",
429
+ originalType: type,
430
+ payload
431
+ }
432
+ });
433
+ }
434
+ /** Validate an append without permitting model-history replacement events. */
435
+ const newConversationEventSchema = z.object({
436
+ data: appendableConversationEventDataSchema,
437
+ idempotencyKey: z.string().min(1).optional(),
438
+ createdAtMs: z.number().finite()
439
+ }).strict();
440
+ //#endregion
441
+ export { conversationTurnFailureReasonSchema as a, newConversationEventSchema as c, instructionProvenanceFor as d, sameActorIdentity as f, conversationTurnFailureCodeSchema as i, contextProvenance as l, agentHistoryItemSchema as n, decodeStoredConversationEvent as o, conversationEventDataSchema as r, historyReplacementSchema as s, KNOWN_CONVERSATION_EVENT_TYPES as t, instructionActors as u };
@@ -1,4 +1,4 @@
1
+ //#region src/instrumentation.d.ts
1
2
  /** Initialize Sentry for the Junior runtime. Call at the top of your entry point. */
2
- declare function initSentry(): void;
3
-
4
- export { initSentry };
3
+ export declare function initSentry(): void;
4
+ //#endregion