@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
@@ -1,51 +0,0 @@
1
- import {
2
- PluginHookDeniedError,
3
- applyPluginFormatMarkdown,
4
- createPluginHookRunner,
5
- getPluginApiRoutes,
6
- getPluginOperationalReports,
7
- getPluginProfileReports,
8
- getPluginRoutes,
9
- getPluginSlackConversationLink,
10
- getPluginSystemPromptContributions,
11
- getPluginTools,
12
- getPluginUserPromptContributions,
13
- getPlugins,
14
- setPlugins,
15
- validatePlugins
16
- } from "./chunk-IZ5B5IHQ.js";
17
- import "./chunk-3Y47VMHV.js";
18
- import "./chunk-GKEOHJL5.js";
19
- import "./chunk-IE2VPG7O.js";
20
- import "./chunk-5AHX53NQ.js";
21
- import "./chunk-P6KTRNVC.js";
22
- import "./chunk-7NL7T6VU.js";
23
- import "./chunk-VFUK3X5B.js";
24
- import "./chunk-ENY6SKIU.js";
25
- import "./chunk-NHJU2ZAL.js";
26
- import "./chunk-PKEX2AQX.js";
27
- import "./chunk-WCNQJKFT.js";
28
- import "./chunk-7GWQ5S5R.js";
29
- import "./chunk-CEMMLV5L.js";
30
- import "./chunk-N7TMSOZH.js";
31
- import "./chunk-DWPN6SCH.js";
32
- import "./chunk-TXKUKMVO.js";
33
- import "./chunk-WS7NAFTM.js";
34
- import "./chunk-PEQXYSSE.js";
35
- import "./chunk-WDZR3QQM.js";
36
- export {
37
- PluginHookDeniedError,
38
- applyPluginFormatMarkdown,
39
- createPluginHookRunner,
40
- getPluginApiRoutes,
41
- getPluginOperationalReports,
42
- getPluginProfileReports,
43
- getPluginRoutes,
44
- getPluginSlackConversationLink,
45
- getPluginSystemPromptContributions,
46
- getPluginTools,
47
- getPluginUserPromptContributions,
48
- getPlugins,
49
- setPlugins,
50
- validatePlugins
51
- };
@@ -1,14 +0,0 @@
1
- import {
2
- pluginCatalogRuntime
3
- } from "./chunk-WCNQJKFT.js";
4
- import "./chunk-7GWQ5S5R.js";
5
- import "./chunk-CEMMLV5L.js";
6
- import "./chunk-N7TMSOZH.js";
7
- import "./chunk-DWPN6SCH.js";
8
- import "./chunk-TXKUKMVO.js";
9
- import "./chunk-WS7NAFTM.js";
10
- import "./chunk-PEQXYSSE.js";
11
- import "./chunk-WDZR3QQM.js";
12
- export {
13
- pluginCatalogRuntime
14
- };
@@ -1,46 +0,0 @@
1
- // src/chat/experimental.ts
2
- var EXPERIMENTAL_FEATURES = ["passive-routing", "subagents"];
3
- var EXPERIMENTAL_FEATURE_SET = new Set(EXPERIMENTAL_FEATURES);
4
- var configuredExperimental = {};
5
- function isExperimentalFeature(value) {
6
- return EXPERIMENTAL_FEATURE_SET.has(value);
7
- }
8
- function setExperimentalFeatures(config) {
9
- const previous = { ...configuredExperimental };
10
- if (config === void 0) {
11
- configuredExperimental = {};
12
- return previous;
13
- }
14
- const next = {};
15
- for (const [rawName, enabled] of Object.entries(config)) {
16
- if (enabled === void 0) {
17
- continue;
18
- }
19
- if (typeof enabled !== "boolean") {
20
- throw new Error(
21
- `experimental.${rawName} must be a boolean when provided`
22
- );
23
- }
24
- if (!isExperimentalFeature(rawName)) {
25
- throw new Error(
26
- `experimental.${rawName} is not a known experimental feature. Known features: ${EXPERIMENTAL_FEATURES.join(", ")}`
27
- );
28
- }
29
- next[rawName] = enabled;
30
- }
31
- configuredExperimental = next;
32
- return previous;
33
- }
34
- function getExperimentalFeatures() {
35
- return { ...configuredExperimental };
36
- }
37
- function isExperimentalFeatureEnabled(feature) {
38
- return configuredExperimental[feature] === true;
39
- }
40
-
41
- export {
42
- EXPERIMENTAL_FEATURES,
43
- setExperimentalFeatures,
44
- getExperimentalFeatures,
45
- isExperimentalFeatureEnabled
46
- };
@@ -1,320 +0,0 @@
1
- import {
2
- parseSandboxEgressAuthRequiredSignal
3
- } from "./chunk-6Y5B5PEX.js";
4
- import {
5
- authorizationId
6
- } from "./chunk-DIB4GX3G.js";
7
- import {
8
- formatProviderLabel,
9
- startOAuthFlow
10
- } from "./chunk-UE4GPWSD.js";
11
- import {
12
- abandonReplacedPendingAuth,
13
- canReusePendingAuthLink
14
- } from "./chunk-5PDAG6O3.js";
15
- import {
16
- recordAuthorizationRequested
17
- } from "./chunk-F4MGCZOX.js";
18
- import {
19
- AGENT_INVOCATION_MAILBOX_STATUSES
20
- } from "./chunk-IE2VPG7O.js";
21
- import {
22
- TURN_REASONING_LEVELS
23
- } from "./chunk-NHJU2ZAL.js";
24
- import {
25
- pluginCatalogRuntime
26
- } from "./chunk-WCNQJKFT.js";
27
- import {
28
- credentialContextSchema
29
- } from "./chunk-CEMMLV5L.js";
30
-
31
- // src/chat/services/auth-pause.ts
32
- var AuthorizationPauseError = class extends Error {
33
- disposition;
34
- kind;
35
- provider;
36
- providerDisplayName;
37
- requestText;
38
- constructor(kind, provider, providerDisplayName, disposition, requestText) {
39
- super(
40
- kind === "mcp" ? `MCP authorization started for ${provider}` : `Plugin authorization started for ${provider}`
41
- );
42
- this.name = kind === "mcp" ? "McpAuthorizationPauseError" : "PluginAuthorizationPauseError";
43
- this.disposition = disposition;
44
- this.kind = kind;
45
- this.provider = provider;
46
- this.providerDisplayName = providerDisplayName;
47
- this.requestText = requestText;
48
- }
49
- };
50
- var AuthPausePersistenceError = class extends Error {
51
- constructor(conversationId, turnId, cause) {
52
- super(
53
- `Failed to persist auth pause for conversation=${conversationId} turn=${turnId}`,
54
- cause === void 0 ? void 0 : { cause }
55
- );
56
- this.name = "AuthPausePersistenceError";
57
- }
58
- };
59
- var AuthorizationFlowDisabledError = class extends Error {
60
- kind;
61
- provider;
62
- constructor(kind, provider) {
63
- super(
64
- `Authorization is required for ${provider}, but this turn cannot start an authorization flow.`
65
- );
66
- this.name = "AuthorizationFlowDisabledError";
67
- this.kind = kind;
68
- this.provider = provider;
69
- }
70
- };
71
-
72
- // src/chat/services/plugin-auth-orchestration.ts
73
- var PluginAuthorizationPauseError = class extends AuthorizationPauseError {
74
- constructor(provider, providerDisplayName, disposition, requestText) {
75
- super("plugin", provider, providerDisplayName, disposition, requestText);
76
- }
77
- };
78
- var PluginCredentialFailureError = class extends Error {
79
- provider;
80
- constructor(provider, message) {
81
- super(message);
82
- this.name = "PluginCredentialFailureError";
83
- this.provider = provider;
84
- }
85
- };
86
- function pluginAuthRequiredSignal(details) {
87
- if (!details || typeof details !== "object") {
88
- return void 0;
89
- }
90
- const signal = details.auth_required;
91
- const parsedSignal = parseSandboxEgressAuthRequiredSignal(signal);
92
- if (!parsedSignal) {
93
- return void 0;
94
- }
95
- return {
96
- provider: parsedSignal.provider,
97
- grant: parsedSignal.grant,
98
- kind: parsedSignal.kind,
99
- ...parsedSignal.message ? { message: parsedSignal.message } : void 0,
100
- ...parsedSignal.authorization ? { authorization: parsedSignal.authorization } : void 0
101
- };
102
- }
103
- function createPluginAuthOrchestration(input) {
104
- let pendingPause;
105
- const startAuthorizationPause = async (provider, options) => {
106
- if (pendingPause) {
107
- throw pendingPause;
108
- }
109
- if (!input.actorId || !pluginCatalogRuntime.getOAuthConfig(provider)) {
110
- throw new Error(`Cannot start plugin authorization for ${provider}`);
111
- }
112
- if (input.interactiveAuthEnabled === false) {
113
- throw new AuthorizationFlowDisabledError("plugin", provider);
114
- }
115
- const recordPendingAuth = input.sessionId ? input.recordPendingAuth : void 0;
116
- if (input.sessionId && !recordPendingAuth) {
117
- throw new Error(
118
- `Missing pending auth recorder for plugin authorization pause "${provider}"`
119
- );
120
- }
121
- const providerLabel = formatProviderLabel(provider);
122
- const reusingPendingLink = input.sessionId ? canReusePendingAuthLink({
123
- pendingAuth: input.pendingAuth,
124
- kind: "plugin",
125
- provider,
126
- actorId: input.actorId,
127
- sessionId: input.sessionId,
128
- ...options?.scope ? { scope: options.scope } : void 0
129
- }) : false;
130
- if (!reusingPendingLink) {
131
- const oauthResult = await startOAuthFlow(provider, {
132
- actorId: input.actorId,
133
- ...input.actor ? { actor: input.actor } : void 0,
134
- channelId: input.channelId,
135
- destination: input.destination,
136
- source: input.source,
137
- threadTs: input.threadTs,
138
- ...options?.scope ? { scope: options.scope } : void 0,
139
- resumeConversationId: input.conversationId,
140
- resumeSessionId: input.sessionId,
141
- authorization: input.authorization
142
- });
143
- if (!oauthResult.ok) {
144
- throw new Error(oauthResult.error);
145
- }
146
- if (!oauthResult.delivery) {
147
- throw new Error(
148
- `I need to connect your ${providerLabel} account first, but I wasn't able to send you a private authorization link. Please send me a direct message and try again.`
149
- );
150
- }
151
- }
152
- if (input.sessionId && recordPendingAuth) {
153
- const nextPendingAuth = {
154
- kind: "plugin",
155
- provider,
156
- actorId: input.actorId,
157
- ...options?.scope ? { scope: options.scope } : void 0,
158
- sessionId: input.sessionId,
159
- linkSentAtMs: reusingPendingLink ? input.pendingAuth.linkSentAtMs : Date.now()
160
- };
161
- await recordPendingAuth(nextPendingAuth);
162
- await abandonReplacedPendingAuth({
163
- conversationId: input.conversationId,
164
- previousPendingAuth: input.pendingAuth,
165
- nextPendingAuth
166
- });
167
- }
168
- if (input.conversationId && input.sessionId) {
169
- await recordAuthorizationRequested({
170
- conversationId: input.conversationId,
171
- kind: "plugin",
172
- provider,
173
- actorId: input.actorId,
174
- authorizationId: authorizationId({
175
- kind: "plugin",
176
- provider,
177
- sessionId: input.sessionId
178
- }),
179
- delivery: reusingPendingLink ? "private_link_reused" : "private_link_sent"
180
- });
181
- }
182
- pendingPause = new PluginAuthorizationPauseError(
183
- provider,
184
- providerLabel,
185
- reusingPendingLink ? "link_already_sent" : "link_sent",
186
- input.userMessage
187
- );
188
- input.abortAgent();
189
- throw pendingPause;
190
- };
191
- return {
192
- maybeHandleAuthSignal: async (details) => {
193
- const signal = pluginAuthRequiredSignal(details);
194
- if (!signal) {
195
- return;
196
- }
197
- const { provider, authorization } = signal;
198
- if (signal.kind === "unavailable") {
199
- throw new PluginCredentialFailureError(
200
- provider,
201
- signal.message ?? `${formatProviderLabel(provider)} credentials are unavailable.`
202
- );
203
- }
204
- if (!authorization) {
205
- throw new PluginCredentialFailureError(
206
- provider,
207
- signal.message ?? `${formatProviderLabel(provider)} credentials are required but no OAuth flow is available for this provider.`
208
- );
209
- }
210
- if (!input.actorId || !input.userTokenStore) {
211
- if (input.interactiveAuthEnabled === false) {
212
- throw new AuthorizationFlowDisabledError("plugin", provider);
213
- }
214
- throw new PluginCredentialFailureError(
215
- provider,
216
- signal.message ?? `${formatProviderLabel(provider)} credentials are required. Please connect your ${formatProviderLabel(provider)} account and try again.`
217
- );
218
- }
219
- if (!pluginCatalogRuntime.getOAuthConfig(authorization.provider)) {
220
- throw new PluginCredentialFailureError(
221
- provider,
222
- signal.message ?? `${formatProviderLabel(provider)} credentials are required but the provider is not configured for OAuth.`
223
- );
224
- }
225
- await startAuthorizationPause(
226
- authorization.provider,
227
- authorization.scope ? { scope: authorization.scope } : void 0
228
- );
229
- },
230
- getPendingPause: () => pendingPause
231
- };
232
- }
233
-
234
- // src/chat/agent-invocations/errors.ts
235
- var AgentInvocationBusyError = class extends Error {
236
- constructor(name) {
237
- super(`Named agent "${name}" already has active work`);
238
- this.name = "AgentInvocationBusyError";
239
- }
240
- };
241
- var AgentInvocationLimitError = class extends Error {
242
- constructor(limit) {
243
- super(
244
- `Parent already has ${limit} active child agent invocations (limit ${limit})`
245
- );
246
- this.name = "AgentInvocationLimitError";
247
- }
248
- };
249
-
250
- // src/chat/agent-invocations/types.ts
251
- import {
252
- actorSchema,
253
- destinationSchema,
254
- sourceSchema
255
- } from "@sentry/junior-plugin-api";
256
- import { z } from "zod";
257
- var exactStringSchema = z.string().min(1).refine((value) => value === value.trim());
258
- var agentNameSchema = exactStringSchema.max(64);
259
- var agentInvocationMailboxStatusSchema = z.enum(
260
- AGENT_INVOCATION_MAILBOX_STATUSES
261
- );
262
- var agentBindingSchema = z.object({
263
- childConversationId: exactStringSchema,
264
- name: agentNameSchema,
265
- parentConversationId: exactStringSchema
266
- }).strict();
267
- var agentInvocationBaseSchema = z.object({
268
- actor: actorSchema,
269
- agentName: agentNameSchema.optional(),
270
- childConversationId: exactStringSchema,
271
- createdAtMs: z.number().finite(),
272
- credentialContext: credentialContextSchema.optional(),
273
- destination: destinationSchema,
274
- input: exactStringSchema,
275
- invocationId: exactStringSchema,
276
- mailboxStatus: agentInvocationMailboxStatusSchema,
277
- parentConversationId: exactStringSchema,
278
- reasoningLevel: z.enum(TURN_REASONING_LEVELS).optional(),
279
- source: sourceSchema,
280
- updatedAtMs: z.number().finite()
281
- }).strict();
282
- var agentInvocationSchema = z.discriminatedUnion("status", [
283
- agentInvocationBaseSchema.extend({
284
- status: z.enum(["pending", "running", "awaiting_resume"])
285
- }),
286
- agentInvocationBaseSchema.extend({
287
- result: z.string(),
288
- status: z.literal("completed"),
289
- terminalAtMs: z.number().finite()
290
- }),
291
- agentInvocationBaseSchema.extend({
292
- errorMessage: z.string(),
293
- status: z.enum(["blocked", "failed"]),
294
- terminalAtMs: z.number().finite()
295
- })
296
- ]);
297
- var createAgentInvocationSchema = z.object({
298
- actor: actorSchema,
299
- agentName: agentNameSchema.optional(),
300
- credentialContext: credentialContextSchema.optional(),
301
- destination: destinationSchema,
302
- idempotencyKey: exactStringSchema,
303
- input: exactStringSchema,
304
- parentConversationId: exactStringSchema,
305
- reasoningLevel: z.enum(TURN_REASONING_LEVELS).optional()
306
- }).strict();
307
-
308
- export {
309
- AuthorizationPauseError,
310
- AuthPausePersistenceError,
311
- AuthorizationFlowDisabledError,
312
- AgentInvocationBusyError,
313
- AgentInvocationLimitError,
314
- agentNameSchema,
315
- agentBindingSchema,
316
- agentInvocationSchema,
317
- createAgentInvocationSchema,
318
- PluginCredentialFailureError,
319
- createPluginAuthOrchestration
320
- };
@@ -1,6 +0,0 @@
1
- // src/chat/state/ttl.ts
2
- var JUNIOR_THREAD_STATE_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
3
-
4
- export {
5
- JUNIOR_THREAD_STATE_TTL_MS
6
- };
@@ -1,164 +0,0 @@
1
- import {
2
- runWithTurnRequestDeadline
3
- } from "./chunk-NCEBK6PH.js";
4
- import {
5
- QUEUE_SIGNATURE_MAX_AGE_MS,
6
- createVercelQueueClient,
7
- signQueueMessage,
8
- verifyQueueMessage
9
- } from "./chunk-7H2VZTWN.js";
10
- import {
11
- logWarn
12
- } from "./chunk-WS7NAFTM.js";
13
-
14
- // src/chat/plugins/task-queue.ts
15
- import { createHash } from "crypto";
16
- import { z } from "zod";
17
-
18
- // src/chat/queue/callback.ts
19
- import {
20
- handleCallback,
21
- registerDevConsumer
22
- } from "@vercel/queue";
23
- function queueCallback(options) {
24
- const handler = async (value, metadata) => {
25
- if (options.skip?.(metadata)) {
26
- return;
27
- }
28
- const checked = options.verify(value);
29
- if (checked.status === "rejected") {
30
- options.onRejected(checked.reason, metadata);
31
- return;
32
- }
33
- if (checked.status === "unavailable") {
34
- throw new Error(
35
- `Queue message verification unavailable: ${checked.reason}`
36
- );
37
- }
38
- try {
39
- await runWithTurnRequestDeadline(
40
- () => options.run(checked.message, metadata)
41
- );
42
- } catch (error) {
43
- const reason = options.permanentError?.(error);
44
- if (!reason) {
45
- throw error;
46
- }
47
- options.onRejected(reason, metadata, error);
48
- }
49
- };
50
- const retry = (error, metadata) => {
51
- const reason = options.permanentError?.(error);
52
- if (reason) {
53
- options.onRejected(reason, metadata, error);
54
- return { acknowledge: true };
55
- }
56
- if (options.maxDeliveries !== null && metadata.deliveryCount >= options.maxDeliveries) {
57
- return { acknowledge: true };
58
- }
59
- return void 0;
60
- };
61
- const visibility = options.visibilityTimeoutSeconds === void 0 ? {} : { visibilityTimeoutSeconds: options.visibilityTimeoutSeconds };
62
- return {
63
- create: () => handleCallback(handler, { retry, ...visibility }),
64
- registerDev: () => {
65
- if (process.env.NODE_ENV !== "development") {
66
- return void 0;
67
- }
68
- return registerDevConsumer({
69
- client: createVercelQueueClient(),
70
- consumerGroup: options.consumerGroup,
71
- handler,
72
- retry,
73
- topic: options.topic,
74
- ...visibility
75
- });
76
- }
77
- };
78
- }
79
-
80
- // src/chat/plugins/task-queue.ts
81
- var PLUGIN_TASK_QUEUE_TOPIC = "junior_plugin_tasks";
82
- var PLUGIN_TASK_DEV_CONSUMER_GROUP = "junior_plugin_tasks_dev";
83
- var PLUGIN_TASK_MAX_DELIVERIES = 5;
84
- var PLUGIN_TASK_SIGN_CONTEXT = "junior.plugin_task_queue.v1";
85
- var PLUGIN_TASK_SIGN_VERSION = "v1";
86
- var pluginTaskParamsSchema = z.object({
87
- conversationId: z.string().min(1),
88
- sessionId: z.string().min(1)
89
- }).strict();
90
- var pluginTaskQueueMessageSchema = z.object({
91
- name: z.string().min(1),
92
- params: pluginTaskParamsSchema,
93
- plugin: z.string().min(1)
94
- }).strict();
95
- var pluginTaskSign = {
96
- context: PLUGIN_TASK_SIGN_CONTEXT,
97
- schema: pluginTaskQueueMessageSchema,
98
- signatureVersion: PLUGIN_TASK_SIGN_VERSION,
99
- parts: (message) => [
100
- message.plugin,
101
- message.name,
102
- message.params.conversationId,
103
- message.params.sessionId
104
- ]
105
- };
106
- function pluginTaskId(args) {
107
- const digest = createHash("sha256").update(args.plugin).update("\0").update(args.name).update("\0").update(args.params.conversationId).update("\0").update(args.params.sessionId).digest("hex").slice(0, 32);
108
- return `plugin-task_${digest}`;
109
- }
110
- function signPluginTaskQueueMessage(message, nowMs = Date.now()) {
111
- return signQueueMessage(pluginTaskSign, message, nowMs);
112
- }
113
- function verifyPluginTaskQueueMessage(value, nowMs = Date.now()) {
114
- return verifyQueueMessage(pluginTaskSign, value, nowMs);
115
- }
116
- function logPluginTaskQueueMessageRejected(reason, metadata) {
117
- logWarn("plugin.task.queue_message.rejected", {
118
- "app.queue.consumer_group": metadata.consumerGroup,
119
- "app.queue.delivery_count": metadata.deliveryCount,
120
- "app.queue.message_id": metadata.messageId,
121
- "app.queue.reject_reason": reason,
122
- "app.queue.topic_name": metadata.topicName
123
- });
124
- }
125
- function pluginTaskCallback() {
126
- return queueCallback({
127
- consumerGroup: PLUGIN_TASK_DEV_CONSUMER_GROUP,
128
- maxDeliveries: PLUGIN_TASK_MAX_DELIVERIES,
129
- onRejected: logPluginTaskQueueMessageRejected,
130
- // Load the runner on first use so this module can send without a cycle.
131
- run: async (message) => {
132
- const { processPluginTask } = await import("./task-runner-LBZWF32V.js");
133
- await processPluginTask(message);
134
- },
135
- topic: PLUGIN_TASK_QUEUE_TOPIC,
136
- verify: verifyPluginTaskQueueMessage
137
- });
138
- }
139
- async function sendVercelPluginTask(message) {
140
- await createVercelQueueClient().send(
141
- PLUGIN_TASK_QUEUE_TOPIC,
142
- signPluginTaskQueueMessage(message),
143
- {
144
- idempotencyKey: pluginTaskId(message),
145
- retentionSeconds: QUEUE_SIGNATURE_MAX_AGE_MS / 1e3
146
- }
147
- );
148
- }
149
- function createVercelPluginTaskCallback() {
150
- return pluginTaskCallback().create();
151
- }
152
- function registerVercelPluginTaskDevConsumer() {
153
- return pluginTaskCallback().registerDev();
154
- }
155
-
156
- export {
157
- queueCallback,
158
- PLUGIN_TASK_QUEUE_TOPIC,
159
- pluginTaskParamsSchema,
160
- pluginTaskId,
161
- sendVercelPluginTask,
162
- createVercelPluginTaskCallback,
163
- registerVercelPluginTaskDevConsumer
164
- };