@sentry/junior 0.137.0 → 0.139.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 (103) hide show
  1. package/dist/{agent-hooks-MZOKEP3J.js → agent-hooks-MJXMD7JP.js} +11 -9
  2. package/dist/api/schema/task.d.ts +100 -1
  3. package/dist/api/schema.d.ts +2 -2
  4. package/dist/api/schema.js +9 -1
  5. package/dist/api.js +202 -55
  6. package/dist/app.d.ts +7 -0
  7. package/dist/app.js +601 -1356
  8. package/dist/{catalog-runtime-MD66YLFV.js → catalog-runtime-GCCFYPIK.js} +6 -6
  9. package/dist/chat/agent/request.d.ts +44 -4
  10. package/dist/chat/agent-dispatch/heartbeat.d.ts +5 -0
  11. package/dist/chat/agent-dispatch/types.d.ts +1 -1
  12. package/dist/chat/agent-invocations/errors.d.ts +8 -0
  13. package/dist/chat/agent-invocations/spawn.d.ts +12 -0
  14. package/dist/chat/agent-invocations/store.d.ts +44 -0
  15. package/dist/chat/agent-invocations/types.d.ts +449 -0
  16. package/dist/chat/agent-invocations/work.d.ts +31 -0
  17. package/dist/chat/config.d.ts +1 -0
  18. package/dist/chat/conversations/sql/store.d.ts +8 -0
  19. package/dist/chat/conversations/store.d.ts +7 -0
  20. package/dist/chat/credentials/context.d.ts +14 -0
  21. package/dist/chat/experimental.d.ts +16 -0
  22. package/dist/chat/resource-events/actor.d.ts +23 -0
  23. package/dist/chat/runtime/agent-runner.d.ts +2 -1
  24. package/dist/chat/services/auth-pause.d.ts +0 -1
  25. package/dist/chat/services/mcp-auth-orchestration.d.ts +3 -2
  26. package/dist/chat/services/plugin-auth-orchestration.d.ts +3 -2
  27. package/dist/chat/state/turn-session.d.ts +1 -5
  28. package/dist/chat/task-execution/state.d.ts +23 -11
  29. package/dist/chat/task-execution/store.d.ts +20 -11
  30. package/dist/chat/task-execution/worker.d.ts +2 -2
  31. package/dist/chat/tasks/execution-stats.d.ts +34 -3
  32. package/dist/chat/tasks/read.d.ts +3 -1
  33. package/dist/chat/tools/runtime/spawn-agent.d.ts +31 -0
  34. package/dist/chat/tools/types.d.ts +2 -0
  35. package/dist/{chunk-T6Z5S6PQ.js → chunk-2ECYPYKP.js} +1 -1
  36. package/dist/chunk-3T2JAGRH.js +115 -0
  37. package/dist/chunk-3Y47VMHV.js +6 -0
  38. package/dist/chunk-4V4QIYJH.js +41 -0
  39. package/dist/{chunk-SYCX4DOK.js → chunk-5GSZWRE2.js} +434 -65
  40. package/dist/chunk-5IDFPCON.js +46 -0
  41. package/dist/{chunk-36EG34YI.js → chunk-6OHTDR4F.js} +1 -1
  42. package/dist/chunk-6SU2DT27.js +441 -0
  43. package/dist/{chunk-UG6ZYPBI.js → chunk-75I3UBIL.js} +73 -60
  44. package/dist/chunk-AEQISMMU.js +711 -0
  45. package/dist/{chunk-5PNJMOY5.js → chunk-C2N6MNO4.js} +9 -2
  46. package/dist/{chunk-BZAMASJP.js → chunk-CXH25EL4.js} +2 -2
  47. package/dist/{chunk-K2NCQJKH.js → chunk-DW4PMHNW.js} +3 -3
  48. package/dist/chunk-EM225ITJ.js +56 -0
  49. package/dist/{chunk-UOXATPSI.js → chunk-G52UXKGO.js} +7 -5
  50. package/dist/chunk-GI52BW74.js +207 -0
  51. package/dist/{chunk-3Q342EJJ.js → chunk-GWQSZT4C.js} +2 -2
  52. package/dist/{chunk-EPBBYMNE.js → chunk-HUO3UTAQ.js} +1 -1
  53. package/dist/{chunk-WPPXIAFB.js → chunk-IIESAYDL.js} +17 -434
  54. package/dist/chunk-IUFM5JWV.js +24 -0
  55. package/dist/{chunk-UZQ4VY3M.js → chunk-J3S57AXY.js} +1 -1
  56. package/dist/{chunk-DQXAAVTR.js → chunk-J6EJQCHY.js} +46 -1471
  57. package/dist/{chunk-6ZK6FZIV.js → chunk-KCBZSJRU.js} +6 -27
  58. package/dist/chunk-MQ5RYATN.js +1523 -0
  59. package/dist/{chunk-5G34IEK2.js → chunk-MXTVUV3I.js} +2 -56
  60. package/dist/{chunk-YRPC6MJY.js → chunk-MXVD2BDS.js} +1 -1
  61. package/dist/{chunk-POBSY47Q.js → chunk-PJW6U46K.js} +337 -306
  62. package/dist/chunk-Q6QZTTLS.js +55 -0
  63. package/dist/{chunk-ZFS67WIR.js → chunk-QTBKPZDA.js} +57 -6
  64. package/dist/chunk-R776HKPK.js +81 -0
  65. package/dist/{chunk-77VDLF3Z.js → chunk-RUIXF3YQ.js} +10 -0
  66. package/dist/chunk-U27DSXKB.js +714 -0
  67. package/dist/{chunk-XZ7NPXAB.js → chunk-U7CMWQ7Z.js} +1 -1
  68. package/dist/{chunk-RB4NJKEX.js → chunk-UDBUS533.js} +125 -51
  69. package/dist/chunk-WQRX57EA.js +668 -0
  70. package/dist/chunk-WZH4JV7R.js +320 -0
  71. package/dist/{chunk-HCIVH3JS.js → chunk-YCTDA7BD.js} +28 -0
  72. package/dist/{chunk-YNFERGKP.js → chunk-YGZ2OLXL.js} +1 -1
  73. package/dist/{chunk-EWDSB24B.js → chunk-ZQCGQMF2.js} +16 -776
  74. package/dist/{chunk-KJ4HGRHN.js → chunk-ZYQSPQYR.js} +515 -601
  75. package/dist/cli/chat.js +68 -29
  76. package/dist/cli/check.js +7 -7
  77. package/dist/cli/plugins.js +15 -13
  78. package/dist/cli/snapshot-create.js +11 -10
  79. package/dist/cli/upgrade.js +8 -8
  80. package/dist/conversation-work-KATFHLG3.js +56 -0
  81. package/dist/db/schema/agent-invocations.d.ts +544 -0
  82. package/dist/db/schema/task-executions.d.ts +23 -2
  83. package/dist/db/schema.d.ts +563 -2
  84. package/dist/{db-66E7VDNC.js → db-UXPPGHDF.js} +7 -7
  85. package/dist/experimental-HH6OM6UH.js +13 -0
  86. package/dist/instrumentation.js +4 -4
  87. package/dist/nitro.js +4 -3
  88. package/dist/{oauth-callback-server-7QPD4Q7P.js → oauth-callback-server-4ZYMD5UA.js} +28 -19
  89. package/dist/{runner-L2BKJKOD.js → runner-MZSEONRZ.js} +32 -18
  90. package/dist/{sandbox-egress-signals-A5HWIQH4.js → sandbox-egress-signals-EKPAVWQL.js} +2 -2
  91. package/dist/{skills-HOQ2NSPW.js → skills-IMVPXSQ7.js} +7 -7
  92. package/dist/spawn-S5LSVOCE.js +38 -0
  93. package/dist/{validation-ENHI7S2C.js → validation-ZKCY2BVR.js} +7 -7
  94. package/dist/version.js +1 -1
  95. package/dist/work-GG3XDYRX.js +46 -0
  96. package/dist/worker-23AUELCJ.js +24 -0
  97. package/migrations/0021_first_warhawk.sql +35 -0
  98. package/migrations/0022_task_execution_status.sql +3 -0
  99. package/migrations/meta/0021_snapshot.json +2176 -0
  100. package/migrations/meta/0022_snapshot.json +2186 -0
  101. package/migrations/meta/_journal.json +15 -1
  102. package/package.json +4 -4
  103. package/dist/chunk-6QW2RRQT.js +0 -233
@@ -0,0 +1,320 @@
1
+ import {
2
+ authorizationId
3
+ } from "./chunk-DIB4GX3G.js";
4
+ import {
5
+ formatProviderLabel,
6
+ startOAuthFlow
7
+ } from "./chunk-U27DSXKB.js";
8
+ import {
9
+ abandonReplacedPendingAuth,
10
+ canReusePendingAuthLink,
11
+ recordAuthorizationRequested
12
+ } from "./chunk-PJW6U46K.js";
13
+ import {
14
+ parseSandboxEgressAuthRequiredSignal
15
+ } from "./chunk-HUO3UTAQ.js";
16
+ import {
17
+ AGENT_INVOCATION_MAILBOX_STATUSES
18
+ } from "./chunk-UDBUS533.js";
19
+ import {
20
+ TURN_REASONING_LEVELS
21
+ } from "./chunk-75I3UBIL.js";
22
+ import {
23
+ pluginCatalogRuntime
24
+ } from "./chunk-6OHTDR4F.js";
25
+ import {
26
+ credentialContextSchema
27
+ } from "./chunk-RUIXF3YQ.js";
28
+
29
+ // src/chat/services/auth-pause.ts
30
+ var AuthorizationPauseError = class extends Error {
31
+ disposition;
32
+ kind;
33
+ provider;
34
+ providerDisplayName;
35
+ requestText;
36
+ constructor(kind, provider, providerDisplayName, disposition, requestText) {
37
+ super(
38
+ kind === "mcp" ? `MCP authorization started for ${provider}` : `Plugin authorization started for ${provider}`
39
+ );
40
+ this.name = kind === "mcp" ? "McpAuthorizationPauseError" : "PluginAuthorizationPauseError";
41
+ this.disposition = disposition;
42
+ this.kind = kind;
43
+ this.provider = provider;
44
+ this.providerDisplayName = providerDisplayName;
45
+ this.requestText = requestText;
46
+ }
47
+ };
48
+ var AuthPausePersistenceError = class extends Error {
49
+ constructor(conversationId, turnId, cause) {
50
+ super(
51
+ `Failed to persist auth pause for conversation=${conversationId} turn=${turnId}`,
52
+ cause === void 0 ? void 0 : { cause }
53
+ );
54
+ this.name = "AuthPausePersistenceError";
55
+ }
56
+ };
57
+ var AuthorizationFlowDisabledError = class extends Error {
58
+ kind;
59
+ provider;
60
+ constructor(kind, provider) {
61
+ super(
62
+ `Authorization is required for ${provider}, but this turn cannot start an authorization flow.`
63
+ );
64
+ this.name = "AuthorizationFlowDisabledError";
65
+ this.kind = kind;
66
+ this.provider = provider;
67
+ }
68
+ };
69
+
70
+ // src/chat/services/plugin-auth-orchestration.ts
71
+ var PluginAuthorizationPauseError = class extends AuthorizationPauseError {
72
+ constructor(provider, providerDisplayName, disposition, requestText) {
73
+ super("plugin", provider, providerDisplayName, disposition, requestText);
74
+ }
75
+ };
76
+ var PluginCredentialFailureError = class extends Error {
77
+ provider;
78
+ constructor(provider, message) {
79
+ super(message);
80
+ this.name = "PluginCredentialFailureError";
81
+ this.provider = provider;
82
+ }
83
+ };
84
+ function pluginAuthRequiredSignal(details) {
85
+ if (!details || typeof details !== "object") {
86
+ return void 0;
87
+ }
88
+ const signal = details.auth_required;
89
+ const parsedSignal = parseSandboxEgressAuthRequiredSignal(signal);
90
+ if (!parsedSignal) {
91
+ return void 0;
92
+ }
93
+ return {
94
+ provider: parsedSignal.provider,
95
+ grant: parsedSignal.grant,
96
+ kind: parsedSignal.kind,
97
+ ...parsedSignal.message ? { message: parsedSignal.message } : {},
98
+ ...parsedSignal.authorization ? { authorization: parsedSignal.authorization } : {}
99
+ };
100
+ }
101
+ function createPluginAuthOrchestration(input) {
102
+ let pendingPause;
103
+ const startAuthorizationPause = async (provider, options) => {
104
+ if (pendingPause) {
105
+ throw pendingPause;
106
+ }
107
+ if (!input.actorId || !pluginCatalogRuntime.getOAuthConfig(provider)) {
108
+ throw new Error(`Cannot start plugin authorization for ${provider}`);
109
+ }
110
+ if (input.interactiveAuthEnabled === false) {
111
+ throw new AuthorizationFlowDisabledError("plugin", provider);
112
+ }
113
+ const recordPendingAuth = input.sessionId ? input.recordPendingAuth : void 0;
114
+ if (input.sessionId && !recordPendingAuth) {
115
+ throw new Error(
116
+ `Missing pending auth recorder for plugin authorization pause "${provider}"`
117
+ );
118
+ }
119
+ const providerLabel = formatProviderLabel(provider);
120
+ const reusingPendingLink = input.sessionId ? canReusePendingAuthLink({
121
+ pendingAuth: input.pendingAuth,
122
+ kind: "plugin",
123
+ provider,
124
+ actorId: input.actorId,
125
+ sessionId: input.sessionId,
126
+ ...options?.scope ? { scope: options.scope } : {}
127
+ }) : false;
128
+ if (!reusingPendingLink) {
129
+ const oauthResult = await startOAuthFlow(provider, {
130
+ actorId: input.actorId,
131
+ channelId: input.channelId,
132
+ destination: input.destination,
133
+ source: input.source,
134
+ threadTs: input.threadTs,
135
+ ...options?.scope ? { scope: options.scope } : {},
136
+ resumeConversationId: input.conversationId,
137
+ resumeSessionId: input.sessionId,
138
+ authorization: input.authorization
139
+ });
140
+ if (!oauthResult.ok) {
141
+ throw new Error(oauthResult.error);
142
+ }
143
+ if (!oauthResult.delivery) {
144
+ throw new Error(
145
+ `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.`
146
+ );
147
+ }
148
+ }
149
+ if (input.sessionId && recordPendingAuth) {
150
+ const nextPendingAuth = {
151
+ kind: "plugin",
152
+ provider,
153
+ actorId: input.actorId,
154
+ ...options?.scope ? { scope: options.scope } : {},
155
+ sessionId: input.sessionId,
156
+ linkSentAtMs: reusingPendingLink ? input.pendingAuth.linkSentAtMs : Date.now()
157
+ };
158
+ await recordPendingAuth(nextPendingAuth);
159
+ await abandonReplacedPendingAuth({
160
+ conversationId: input.conversationId,
161
+ previousPendingAuth: input.pendingAuth,
162
+ nextPendingAuth
163
+ });
164
+ }
165
+ if (input.conversationId && input.sessionId) {
166
+ await recordAuthorizationRequested({
167
+ conversationId: input.conversationId,
168
+ kind: "plugin",
169
+ provider,
170
+ actorId: input.actorId,
171
+ authorizationId: authorizationId({
172
+ kind: "plugin",
173
+ provider,
174
+ sessionId: input.sessionId
175
+ }),
176
+ delivery: reusingPendingLink ? "private_link_reused" : "private_link_sent"
177
+ });
178
+ }
179
+ pendingPause = new PluginAuthorizationPauseError(
180
+ provider,
181
+ providerLabel,
182
+ reusingPendingLink ? "link_already_sent" : "link_sent",
183
+ input.userMessage
184
+ );
185
+ input.abortAgent();
186
+ throw pendingPause;
187
+ };
188
+ return {
189
+ maybeHandleAuthSignal: async (details) => {
190
+ const signal = pluginAuthRequiredSignal(details);
191
+ if (!signal) {
192
+ return;
193
+ }
194
+ const { provider, authorization } = signal;
195
+ if (signal.kind === "unavailable") {
196
+ throw new PluginCredentialFailureError(
197
+ provider,
198
+ signal.message ?? `${formatProviderLabel(provider)} credentials are unavailable.`
199
+ );
200
+ }
201
+ if (!authorization) {
202
+ throw new PluginCredentialFailureError(
203
+ provider,
204
+ signal.message ?? `${formatProviderLabel(provider)} credentials are required but no OAuth flow is available for this provider.`
205
+ );
206
+ }
207
+ if (!input.actorId || !input.userTokenStore) {
208
+ if (input.interactiveAuthEnabled === false) {
209
+ throw new AuthorizationFlowDisabledError("plugin", provider);
210
+ }
211
+ throw new PluginCredentialFailureError(
212
+ provider,
213
+ signal.message ?? `${formatProviderLabel(provider)} credentials are required. Please connect your ${formatProviderLabel(provider)} account and try again.`
214
+ );
215
+ }
216
+ if (!pluginCatalogRuntime.getOAuthConfig(authorization.provider)) {
217
+ throw new PluginCredentialFailureError(
218
+ provider,
219
+ signal.message ?? `${formatProviderLabel(provider)} credentials are required but the provider is not configured for OAuth.`
220
+ );
221
+ }
222
+ await startAuthorizationPause(
223
+ authorization.provider,
224
+ authorization.scope ? { scope: authorization.scope } : void 0
225
+ );
226
+ },
227
+ getPendingPause: () => pendingPause
228
+ };
229
+ }
230
+
231
+ // src/chat/agent-invocations/errors.ts
232
+ var AgentInvocationBusyError = class extends Error {
233
+ constructor(name) {
234
+ super(`Named agent "${name}" already has active work`);
235
+ this.name = "AgentInvocationBusyError";
236
+ }
237
+ };
238
+ var AgentInvocationLimitError = class extends Error {
239
+ constructor(limit) {
240
+ super(
241
+ `Parent already has ${limit} active child agent invocations (limit ${limit})`
242
+ );
243
+ this.name = "AgentInvocationLimitError";
244
+ }
245
+ };
246
+
247
+ // src/chat/agent-invocations/types.ts
248
+ import {
249
+ actorSchema,
250
+ destinationSchema,
251
+ sourceSchema
252
+ } from "@sentry/junior-plugin-api";
253
+ import { z } from "zod";
254
+ var exactStringSchema = z.string().min(1).refine((value) => value === value.trim());
255
+ var agentNameSchema = exactStringSchema.max(64);
256
+ var agentInvocationMailboxStatusSchema = z.enum(
257
+ AGENT_INVOCATION_MAILBOX_STATUSES
258
+ );
259
+ var agentBindingSchema = z.object({
260
+ childConversationId: exactStringSchema,
261
+ name: agentNameSchema,
262
+ parentConversationId: exactStringSchema
263
+ }).strict();
264
+ var agentInvocationBaseSchema = z.object({
265
+ actor: actorSchema,
266
+ agentName: agentNameSchema.optional(),
267
+ childConversationId: exactStringSchema,
268
+ createdAtMs: z.number().finite(),
269
+ credentialContext: credentialContextSchema.optional(),
270
+ destination: destinationSchema,
271
+ destinationVisibility: z.enum(["public", "private"]).optional(),
272
+ input: exactStringSchema,
273
+ invocationId: exactStringSchema,
274
+ mailboxStatus: agentInvocationMailboxStatusSchema,
275
+ parentConversationId: exactStringSchema,
276
+ reasoningLevel: z.enum(TURN_REASONING_LEVELS).optional(),
277
+ source: sourceSchema,
278
+ updatedAtMs: z.number().finite()
279
+ }).strict();
280
+ var agentInvocationSchema = z.discriminatedUnion("status", [
281
+ agentInvocationBaseSchema.extend({
282
+ status: z.enum(["pending", "running", "awaiting_resume"])
283
+ }),
284
+ agentInvocationBaseSchema.extend({
285
+ result: z.string(),
286
+ status: z.literal("completed"),
287
+ terminalAtMs: z.number().finite()
288
+ }),
289
+ agentInvocationBaseSchema.extend({
290
+ errorMessage: z.string(),
291
+ status: z.enum(["blocked", "failed"]),
292
+ terminalAtMs: z.number().finite()
293
+ })
294
+ ]);
295
+ var createAgentInvocationSchema = z.object({
296
+ actor: actorSchema,
297
+ agentName: agentNameSchema.optional(),
298
+ credentialContext: credentialContextSchema.optional(),
299
+ destination: destinationSchema,
300
+ destinationVisibility: z.enum(["public", "private"]).optional(),
301
+ idempotencyKey: exactStringSchema,
302
+ input: exactStringSchema,
303
+ parentConversationId: exactStringSchema,
304
+ reasoningLevel: z.enum(TURN_REASONING_LEVELS).optional(),
305
+ source: sourceSchema
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
+ };
@@ -642,6 +642,30 @@ var taskParamsSchema = z7.object({
642
642
  id: z7.string().min(1),
643
643
  kind: z7.enum(["scheduled", "event"])
644
644
  }).strict();
645
+ var taskExecutionStatusSchema = z7.enum([
646
+ "blocked",
647
+ "completed",
648
+ "failed"
649
+ ]);
650
+ var taskExecutionSchema = z7.object({
651
+ conversationId: z7.string().min(1).optional(),
652
+ executedAt: z7.string().datetime(),
653
+ executionId: z7.string().min(1),
654
+ status: taskExecutionStatusSchema,
655
+ title: z7.string().min(1).optional()
656
+ }).strict();
657
+ var taskExecutionStatusDaySchema = z7.object({
658
+ blocked: z7.number().int().nonnegative(),
659
+ completed: z7.number().int().nonnegative(),
660
+ date: z7.string().min(1),
661
+ failed: z7.number().int().nonnegative()
662
+ }).strict();
663
+ var taskExecutionListSchema = z7.object({
664
+ executionDays: z7.array(taskExecutionStatusDaySchema),
665
+ executions: z7.array(taskExecutionSchema),
666
+ task: taskSummarySchema,
667
+ truncated: z7.boolean()
668
+ }).strict();
645
669
 
646
670
  // src/api/schema/stats.ts
647
671
  import { z as z8 } from "zod";
@@ -697,6 +721,10 @@ export {
697
721
  taskSummarySchema,
698
722
  taskListSchema,
699
723
  taskParamsSchema,
724
+ taskExecutionStatusSchema,
725
+ taskExecutionSchema,
726
+ taskExecutionStatusDaySchema,
727
+ taskExecutionListSchema,
700
728
  statSchema,
701
729
  statsReportSchema
702
730
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logWarn
3
- } from "./chunk-T6Z5S6PQ.js";
3
+ } from "./chunk-2ECYPYKP.js";
4
4
 
5
5
  // src/chat/conversation-privacy.ts
6
6
  import { AsyncLocalStorage } from "async_hooks";