@sentry/junior 0.181.1 → 0.182.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 (81) hide show
  1. package/dist/{agent-hooks-KO56HJ74.js → agent-hooks-3S25UIHO.js} +11 -11
  2. package/dist/api.js +125 -51
  3. package/dist/app-adapter.d.ts +85 -0
  4. package/dist/app.d.ts +6 -1
  5. package/dist/app.js +343 -487
  6. package/dist/{catalog-runtime-CJTFLCK3.js → catalog-runtime-ESLMBQBV.js} +4 -4
  7. package/dist/chat/api-turns/adapter-conversations.d.ts +15 -0
  8. package/dist/chat/api-turns/stop.d.ts +12 -0
  9. package/dist/chat/api-turns/work.d.ts +9 -1
  10. package/dist/chat/app/conversation-work.d.ts +1 -1
  11. package/dist/chat/event-tasks/tool-support.d.ts +7 -1
  12. package/dist/chat/event-tasks/types.d.ts +1 -0
  13. package/dist/chat/experimental.d.ts +1 -1
  14. package/dist/chat/resource-events/catalog.d.ts +11 -1
  15. package/dist/chat/resource-events/store.d.ts +5 -1
  16. package/dist/chat/services/subscribed-decision.d.ts +2 -1
  17. package/dist/chat/tools/create-event-task.d.ts +3 -0
  18. package/dist/chat/tools/delete-event-task.d.ts +2 -0
  19. package/dist/chat/tools/list-event-tasks.d.ts +2 -0
  20. package/dist/chat/tools/list-resource-event-subscriptions.d.ts +2 -0
  21. package/dist/chat/tools/search-resource-event-types.d.ts +10 -0
  22. package/dist/chat/tools/update-event-task.d.ts +3 -0
  23. package/dist/chat/tools/watch-resource-events.d.ts +3 -0
  24. package/dist/{chunk-WDNA4LML.js → chunk-2CEOXDG2.js} +20 -11
  25. package/dist/{chunk-VRS6WDK5.js → chunk-2LYHWMR4.js} +1 -1
  26. package/dist/{chunk-6TB7JN63.js → chunk-3ENUMZNG.js} +3 -3
  27. package/dist/{chunk-4WYHL4EH.js → chunk-3NFHI2NA.js} +1 -1
  28. package/dist/{chunk-MR36BRPE.js → chunk-3THPTNN6.js} +4 -4
  29. package/dist/{chunk-ULM7P4EQ.js → chunk-44BQ3TSK.js} +1 -1
  30. package/dist/{chunk-7UF37LNL.js → chunk-4DZ62L36.js} +1 -1
  31. package/dist/{chunk-YCW6RZGX.js → chunk-6TSWXBTQ.js} +3 -3
  32. package/dist/{chunk-IWRPJ3J5.js → chunk-A7THOQ6N.js} +58 -32
  33. package/dist/{chunk-J4ID4ZI6.js → chunk-BDDWVY32.js} +19 -19
  34. package/dist/{chunk-S5X2VQOD.js → chunk-BZD4ADQH.js} +3 -2
  35. package/dist/{chunk-CJRUBOJI.js → chunk-CVBIM4Z3.js} +1 -1
  36. package/dist/{chunk-HPFHC7YR.js → chunk-D6OHGAIO.js} +5 -5
  37. package/dist/{chunk-NRF23QZ4.js → chunk-DZR3L74W.js} +3 -3
  38. package/dist/{chunk-RULGB5NX.js → chunk-GGYA5NPN.js} +9 -9
  39. package/dist/{chunk-KH2SL2HT.js → chunk-JIOKUIAS.js} +2 -2
  40. package/dist/{chunk-XQ56HNH5.js → chunk-KGMHUDVF.js} +6 -6
  41. package/dist/{chunk-YFJDRORU.js → chunk-LB4FWMCV.js} +92 -8
  42. package/dist/{chunk-S63LNPIV.js → chunk-LHQK5XCU.js} +2 -2
  43. package/dist/{chunk-DINF4LMR.js → chunk-LT4QYGKM.js} +7 -7
  44. package/dist/{chunk-4OSVTPYQ.js → chunk-MJISSOWB.js} +1 -1
  45. package/dist/{chunk-PJ7EGFME.js → chunk-PQES5LB5.js} +5 -5
  46. package/dist/{chunk-XL3C4NAR.js → chunk-QHALFHZA.js} +9 -9
  47. package/dist/{chunk-HG6HNOTQ.js → chunk-S35OZMSL.js} +130 -200
  48. package/dist/{chunk-Z2UG4FBT.js → chunk-SVFSYQMT.js} +1 -1
  49. package/dist/{chunk-DTRCZOHE.js → chunk-SXOZIG5X.js} +6 -6
  50. package/dist/{chunk-4GOZBB22.js → chunk-TEFNHMO2.js} +63 -7
  51. package/dist/{chunk-QA6RE6IB.js → chunk-UKIHNBBD.js} +3 -3
  52. package/dist/{chunk-2CZ63QCL.js → chunk-UQP54CXZ.js} +1 -1
  53. package/dist/{chunk-HRTW7FFX.js → chunk-UUMBHORH.js} +1 -1
  54. package/dist/{chunk-ZQQWJMHE.js → chunk-V5UZCCNW.js} +6 -6
  55. package/dist/{chunk-GITIZ6TZ.js → chunk-VHMAFMHB.js} +1 -1
  56. package/dist/{chunk-DXK3VTVP.js → chunk-WOIALVN2.js} +1 -1
  57. package/dist/{chunk-VHSBLFNT.js → chunk-YHL2L2ZZ.js} +1 -1
  58. package/dist/{chunk-H6MPFFBE.js → chunk-Z7ALSQS3.js} +1 -1
  59. package/dist/cli/chat.js +34 -34
  60. package/dist/cli/check.js +5 -5
  61. package/dist/cli/plugins.js +12 -12
  62. package/dist/cli/snapshot-create.js +9 -9
  63. package/dist/cli/upgrade.js +6 -6
  64. package/dist/{db-4PXTD3OH.js → db-NYIWZ4L5.js} +6 -6
  65. package/dist/{experimental-SIJSRDJD.js → experimental-P5FZM4CU.js} +1 -1
  66. package/dist/instrumentation.js +3 -3
  67. package/dist/nitro.js +6 -6
  68. package/dist/{oauth-callback-server-TQWNEVR6.js → oauth-callback-server-A2YTPVVX.js} +26 -26
  69. package/dist/{runner-G5HLQA43.js → runner-VKAEU52J.js} +18 -18
  70. package/dist/{skills-BNNNRYNT.js → skills-52GMXUTY.js} +5 -5
  71. package/dist/spawn-GSS4EBLR.js +37 -0
  72. package/dist/task-runner-DUGDWF5O.js +32 -0
  73. package/dist/{validation-IJSBB6JR.js → validation-VD2YQX2W.js} +5 -5
  74. package/dist/version.js +1 -1
  75. package/dist/{work-5FQI4P2A.js → work-ZWBTGEQP.js} +18 -18
  76. package/dist/worker-XUWD5WS7.js +22 -0
  77. package/package.json +7 -6
  78. package/dist/api/acp/route.d.ts +0 -13
  79. package/dist/spawn-U2RKOFP2.js +0 -37
  80. package/dist/task-runner-CDZJBEXP.js +0 -32
  81. package/dist/worker-KJ362GVB.js +0 -22
@@ -2,10 +2,10 @@ import {
2
2
  ToolInputError,
3
3
  canRouteResourceEvents,
4
4
  getPlugins
5
- } from "./chunk-WDNA4LML.js";
5
+ } from "./chunk-2CEOXDG2.js";
6
6
  import {
7
7
  getDb
8
- } from "./chunk-YCW6RZGX.js";
8
+ } from "./chunk-6TSWXBTQ.js";
9
9
  import {
10
10
  juniorAttachments,
11
11
  juniorConversations,
@@ -13,20 +13,21 @@ import {
13
13
  juniorSchedulerRuns,
14
14
  juniorSchedulerTasks,
15
15
  juniorStats
16
- } from "./chunk-ULM7P4EQ.js";
16
+ } from "./chunk-44BQ3TSK.js";
17
17
  import {
18
18
  juniorDestinations
19
19
  } from "./chunk-VFUK3X5B.js";
20
20
  import {
21
21
  getSlackBotToken
22
- } from "./chunk-S63LNPIV.js";
22
+ } from "./chunk-LHQK5XCU.js";
23
23
  import {
24
24
  logWarn
25
- } from "./chunk-2CZ63QCL.js";
25
+ } from "./chunk-UQP54CXZ.js";
26
26
 
27
27
  // src/chat/resource-events/catalog.ts
28
28
  import {
29
- normalizeResourceEventIdentifier
29
+ normalizeResourceEventIdentifier,
30
+ resourceEventMatchSchema
30
31
  } from "@sentry/junior-plugin-api";
31
32
  import { z } from "zod";
32
33
  function enumSchema(values, unavailableMessage) {
@@ -75,6 +76,72 @@ function resourceEventGuidance(catalog, namespace, resourceType, eventType) {
75
76
  (candidate) => candidate.type === resourceType
76
77
  )?.guidance?.[eventType];
77
78
  }
79
+ function resourceEventMatchFields(catalog, namespace, resourceType) {
80
+ return catalog[namespace]?.resourceTypes.find(
81
+ (candidate) => candidate.type === resourceType
82
+ )?.matchFields;
83
+ }
84
+ function registeredResourceEventMatchSchema() {
85
+ return resourceEventMatchSchema.optional().describe(
86
+ "Optional exact values from the resource type matchFields. A single value must equal the event data. A list means the event value may be any one entry. Omit a key to ignore it. Unmatched events are dropped with no agent turn."
87
+ );
88
+ }
89
+ function requireSupportedResourceEventMatch(catalog, input) {
90
+ const match = input.match;
91
+ if (!match || Object.keys(match).length === 0) return void 0;
92
+ const fields = resourceEventMatchFields(
93
+ catalog,
94
+ input.namespace,
95
+ input.resourceType
96
+ );
97
+ if (!fields || Object.keys(fields).length === 0) {
98
+ throw new ToolInputError(
99
+ `Resource type "${input.namespace}:${input.resourceType}" does not support match.`
100
+ );
101
+ }
102
+ const normalized = {};
103
+ for (const [key, value] of Object.entries(match)) {
104
+ const field = fields[key];
105
+ if (!field) {
106
+ throw new ToolInputError(
107
+ `Resource type "${input.namespace}:${input.resourceType}" does not support match key "${key}".`
108
+ );
109
+ }
110
+ if (Array.isArray(value)) {
111
+ if (field.kind === "boolean") {
112
+ throw new ToolInputError(
113
+ `Match key "${key}" is boolean and cannot use a list.`
114
+ );
115
+ }
116
+ for (const entry of value) {
117
+ if (typeof entry !== field.kind) {
118
+ throw new ToolInputError(
119
+ `Match key "${key}" expects ${field.kind} values.`
120
+ );
121
+ }
122
+ if (field.enum && typeof entry === "string" && !field.enum.includes(entry)) {
123
+ throw new ToolInputError(
124
+ `Match key "${key}" does not allow value "${entry}".`
125
+ );
126
+ }
127
+ }
128
+ normalized[key] = [...new Set(value)];
129
+ continue;
130
+ }
131
+ if (typeof value !== field.kind) {
132
+ throw new ToolInputError(
133
+ `Match key "${key}" expects a ${field.kind} value.`
134
+ );
135
+ }
136
+ if (field.enum && typeof value === "string" && !field.enum.includes(value)) {
137
+ throw new ToolInputError(
138
+ `Match key "${key}" does not allow value "${value}".`
139
+ );
140
+ }
141
+ normalized[key] = value;
142
+ }
143
+ return Object.keys(normalized).length > 0 ? normalized : void 0;
144
+ }
78
145
  function normalizeEventIdentifier(catalog, namespace, identifier) {
79
146
  return normalizeResourceEventIdentifier(catalog[namespace], identifier);
80
147
  }
@@ -94,12 +161,16 @@ function getResourceEventCatalog() {
94
161
  }
95
162
 
96
163
  // src/chat/event-tasks/store.ts
164
+ import {
165
+ resourceEventMatches
166
+ } from "@sentry/junior-plugin-api";
97
167
  import { and, asc, desc, eq, inArray, or, sql } from "drizzle-orm";
98
168
 
99
169
  // src/chat/event-tasks/types.ts
100
170
  import {
101
171
  actorUserIdSchema,
102
172
  destinationVisibilitySchema,
173
+ resourceEventMatchSchema as resourceEventMatchSchema2,
103
174
  resourceEventTypeSchema,
104
175
  slackDestinationSchema
105
176
  } from "@sentry/junior-plugin-api";
@@ -113,6 +184,7 @@ var eventTaskPrincipalSchema = z2.object({
113
184
  var eventTaskTriggerSchema = z2.object({
114
185
  events: z2.array(resourceEventTypeSchema).min(1),
115
186
  label: z2.string().min(1),
187
+ match: resourceEventMatchSchema2.optional(),
116
188
  namespace: z2.string().min(1),
117
189
  identifier: z2.string().min(1).max(EVENT_TASK_IDENTIFIER_MAX_LENGTH),
118
190
  resourceType: z2.string().min(1)
@@ -228,7 +300,9 @@ async function findMatchingEventTasks(db, event, teamId) {
228
300
  eq(juniorEventTasks.identifier, event.identifier)
229
301
  )
230
302
  ).orderBy(asc(juniorEventTasks.createdAtMs), asc(juniorEventTasks.id));
231
- return rows.map(parseTask).filter((task) => task.trigger.events.includes(event.eventType));
303
+ return rows.map(parseTask).filter(
304
+ (task) => task.trigger.events.includes(event.eventType) && resourceEventMatches(task.trigger.match, event.data)
305
+ );
232
306
  }
233
307
 
234
308
  // src/stats.ts
@@ -407,6 +481,7 @@ var compactEventTaskResultSchema = z5.object({
407
481
  resourceType: z5.string().min(1),
408
482
  label: z5.string().min(1),
409
483
  events: z5.array(z5.string().min(1)).min(1),
484
+ match: z5.record(z5.string(), z5.unknown()).optional(),
410
485
  credentialMode: z5.enum(["system", "creator"]),
411
486
  createdBy: eventTaskPrincipalSchema,
412
487
  triggerAvailable: z5.boolean()
@@ -424,7 +499,8 @@ function registeredEventTaskTriggerSchema(catalog) {
424
499
  identifier: z5.string().trim().min(1).max(EVENT_TASK_IDENTIFIER_MAX_LENGTH),
425
500
  resourceType: registeredResourceTypeSchema(catalog),
426
501
  label: z5.string().trim().min(1).max(500),
427
- events: z5.array(registeredEventTypeSchema(catalog)).min(1)
502
+ events: z5.array(registeredEventTypeSchema(catalog)).min(1),
503
+ match: registeredResourceEventMatchSchema()
428
504
  }).strict();
429
505
  }
430
506
  function requireSupportedEventTaskTrigger(catalog, trigger) {
@@ -440,6 +516,11 @@ function requireSupportedEventTaskTrigger(catalog, trigger) {
440
516
  );
441
517
  }
442
518
  }
519
+ return requireSupportedResourceEventMatch(catalog, {
520
+ match: trigger.match,
521
+ namespace: trigger.namespace,
522
+ resourceType: trigger.resourceType
523
+ });
443
524
  }
444
525
  function requireEventTaskSlackContext(context) {
445
526
  if (context.source.platform !== "slack" || context.destination.platform !== "slack" || context.actor?.platform !== "slack" || context.actor.teamId !== context.source.teamId) {
@@ -489,6 +570,7 @@ function compactEventTask(task, catalog) {
489
570
  resourceType: task.trigger.resourceType,
490
571
  label: task.trigger.label,
491
572
  events: task.trigger.events,
573
+ ...task.trigger.match ? { match: task.trigger.match } : void 0,
492
574
  credentialMode: task.credentialMode,
493
575
  createdBy: task.createdBy,
494
576
  triggerAvailable: eventTaskTriggerAvailable(task, catalog)
@@ -1138,6 +1220,8 @@ export {
1138
1220
  registeredResourceTypeSchema,
1139
1221
  pluginSupportsEvent,
1140
1222
  resourceEventGuidance,
1223
+ registeredResourceEventMatchSchema,
1224
+ requireSupportedResourceEventMatch,
1141
1225
  normalizeEventIdentifier,
1142
1226
  getResourceEventCatalog,
1143
1227
  getEventTask,
@@ -3,7 +3,7 @@ import {
3
3
  toCanonicalInputMessage,
4
4
  toCanonicalOutputMessage,
5
5
  toGenAiMessagesTraceAttributes
6
- } from "./chunk-Z2UG4FBT.js";
6
+ } from "./chunk-SVFSYQMT.js";
7
7
  import {
8
8
  extractGenAiUsageAttributes,
9
9
  logException,
@@ -11,7 +11,7 @@ import {
11
11
  normalizeGenAiFinishReason,
12
12
  serializeGenAiAttribute,
13
13
  withSpan
14
- } from "./chunk-2CZ63QCL.js";
14
+ } from "./chunk-UQP54CXZ.js";
15
15
 
16
16
  // src/chat/services/provider-error.ts
17
17
  var ProviderError = class extends Error {
@@ -5,7 +5,7 @@ import {
5
5
  getPersistedSandboxState,
6
6
  getPersistedThreadState,
7
7
  persistThreadStateById
8
- } from "./chunk-PJ7EGFME.js";
8
+ } from "./chunk-PQES5LB5.js";
9
9
  import {
10
10
  AgentInvocationBusyError,
11
11
  AgentInvocationLimitError,
@@ -14,32 +14,32 @@ import {
14
14
  agentBindingSchema,
15
15
  agentInvocationSchema,
16
16
  createAgentInvocationSchema
17
- } from "./chunk-XQ56HNH5.js";
17
+ } from "./chunk-KGMHUDVF.js";
18
18
  import {
19
19
  appendAndEnqueueInboundMessage
20
- } from "./chunk-4GOZBB22.js";
20
+ } from "./chunk-TEFNHMO2.js";
21
21
  import {
22
22
  TurnInputCommitLostError,
23
23
  getAssistantReplyText,
24
24
  getConversationTurnBoundaryError,
25
25
  isTurnInputCommitLostError
26
- } from "./chunk-VHSBLFNT.js";
26
+ } from "./chunk-YHL2L2ZZ.js";
27
27
  import {
28
28
  failTurnRecord,
29
29
  getTerminalAssistantMessages,
30
30
  getTurnRecord,
31
31
  openConversationProjection,
32
32
  saveTurnCheckpoint
33
- } from "./chunk-DTRCZOHE.js";
33
+ } from "./chunk-SXOZIG5X.js";
34
34
  import {
35
35
  getConversationEventStore,
36
36
  getConversationStore,
37
37
  getSqlExecutor
38
- } from "./chunk-YCW6RZGX.js";
38
+ } from "./chunk-6TSWXBTQ.js";
39
39
  import {
40
40
  juniorAgentBindings,
41
41
  juniorAgentInvocations
42
- } from "./chunk-ULM7P4EQ.js";
42
+ } from "./chunk-44BQ3TSK.js";
43
43
 
44
44
  // src/chat/agent-invocations/work.ts
45
45
  import { z } from "zod";
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-N7TMSOZH.js";
6
6
  import {
7
7
  toOptionalString
8
- } from "./chunk-2CZ63QCL.js";
8
+ } from "./chunk-UQP54CXZ.js";
9
9
 
10
10
  // src/chat/slack/context.ts
11
11
  import { z } from "zod";
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  persistConversationMessages
3
- } from "./chunk-DTRCZOHE.js";
3
+ } from "./chunk-SXOZIG5X.js";
4
4
  import {
5
5
  JUNIOR_THREAD_STATE_TTL_MS
6
6
  } from "./chunk-3Y47VMHV.js";
7
7
  import {
8
8
  getDb
9
- } from "./chunk-YCW6RZGX.js";
9
+ } from "./chunk-6TSWXBTQ.js";
10
10
  import {
11
11
  juniorLocationConfigurations
12
- } from "./chunk-ULM7P4EQ.js";
12
+ } from "./chunk-44BQ3TSK.js";
13
13
  import {
14
14
  getStateAdapter
15
- } from "./chunk-H6MPFFBE.js";
15
+ } from "./chunk-Z7ALSQS3.js";
16
16
  import {
17
17
  juniorDestinations
18
18
  } from "./chunk-VFUK3X5B.js";
@@ -20,7 +20,7 @@ import {
20
20
  isRecord,
21
21
  toOptionalNumber,
22
22
  toOptionalString
23
- } from "./chunk-2CZ63QCL.js";
23
+ } from "./chunk-UQP54CXZ.js";
24
24
 
25
25
  // src/chat/state/conversation.ts
26
26
  function defaultConversationState() {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  coerceThreadConversationState,
3
3
  getPersistedThreadState
4
- } from "./chunk-PJ7EGFME.js";
4
+ } from "./chunk-PQES5LB5.js";
5
5
  import {
6
6
  pluginTaskId,
7
7
  pluginTaskParamsSchema,
8
8
  sendVercelPluginTask
9
- } from "./chunk-NRF23QZ4.js";
9
+ } from "./chunk-DZR3L74W.js";
10
10
  import {
11
11
  getPiMessageRole,
12
12
  getTurnRecord,
@@ -16,7 +16,7 @@ import {
16
16
  isToolResultMessage,
17
17
  normalizeToolNameFromResult,
18
18
  stripRuntimeTurnContext
19
- } from "./chunk-DTRCZOHE.js";
19
+ } from "./chunk-SXOZIG5X.js";
20
20
  import {
21
21
  createPluginConversationEvents,
22
22
  createPluginEmbedder,
@@ -25,7 +25,7 @@ import {
25
25
  createPluginState,
26
26
  getPlugins,
27
27
  readActorIdentity
28
- } from "./chunk-WDNA4LML.js";
28
+ } from "./chunk-2CEOXDG2.js";
29
29
  import {
30
30
  JUNIOR_THREAD_STATE_TTL_MS
31
31
  } from "./chunk-3Y47VMHV.js";
@@ -33,14 +33,14 @@ import {
33
33
  getConversationStore,
34
34
  getDb,
35
35
  sameActorIdentity
36
- } from "./chunk-YCW6RZGX.js";
36
+ } from "./chunk-6TSWXBTQ.js";
37
37
  import {
38
38
  juniorConversations,
39
39
  juniorTaskExecutions
40
- } from "./chunk-ULM7P4EQ.js";
40
+ } from "./chunk-44BQ3TSK.js";
41
41
  import {
42
42
  getStateAdapter
43
- } from "./chunk-H6MPFFBE.js";
43
+ } from "./chunk-Z7ALSQS3.js";
44
44
  import {
45
45
  credentialSubjectSchema
46
46
  } from "./chunk-CEMMLV5L.js";
@@ -49,14 +49,14 @@ import {
49
49
  } from "./chunk-N7TMSOZH.js";
50
50
  import {
51
51
  logWarn
52
- } from "./chunk-2CZ63QCL.js";
52
+ } from "./chunk-UQP54CXZ.js";
53
53
 
54
54
  // src/chat/plugins/task-runner.ts
55
55
  import { pluginRunContextSchema } from "@sentry/junior-plugin-api";
56
56
 
57
57
  // src/chat/services/turn-session-routing.ts
58
58
  async function resolveTurnSessionRouting(args) {
59
- const conversationStore = args.conversationStore ?? (await import("./db-4PXTD3OH.js")).getConversationStore();
59
+ const conversationStore = args.conversationStore ?? (await import("./db-NYIWZ4L5.js")).getConversationStore();
60
60
  const conversation = await conversationStore.get({
61
61
  conversationId: args.conversationId
62
62
  });