@sentry/junior 0.182.0 → 0.184.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 (98) hide show
  1. package/dist/{agent-hooks-3S25UIHO.js → agent-hooks-XTZVALGQ.js} +11 -11
  2. package/dist/api/acp/auth.d.ts +46 -0
  3. package/dist/api/acp/authorization-page.d.ts +11 -0
  4. package/dist/api/acp/conversations.d.ts +70 -0
  5. package/dist/api/acp/errors.d.ts +6 -0
  6. package/dist/api/acp/route.d.ts +16 -0
  7. package/dist/api/acp/schema.d.ts +97 -0
  8. package/dist/api/acp/sleep.d.ts +2 -0
  9. package/dist/api/acp/state.d.ts +22 -0
  10. package/dist/api/acp/transport.d.ts +113 -0
  11. package/dist/api/code/overview.d.ts +35 -0
  12. package/dist/api/code/routes.d.ts +4 -0
  13. package/dist/api/schema/code.d.ts +75 -0
  14. package/dist/api/schema.d.ts +2 -0
  15. package/dist/api/schema.js +9 -1
  16. package/dist/api.js +258 -134
  17. package/dist/app.d.ts +0 -4
  18. package/dist/app.js +2171 -220
  19. package/dist/{catalog-runtime-ESLMBQBV.js → catalog-runtime-5357XR4F.js} +4 -4
  20. package/dist/chat/agent-invocations/store.d.ts +4 -2
  21. package/dist/chat/agent-invocations/work.d.ts +1 -3
  22. package/dist/chat/app/factory.d.ts +3 -3
  23. package/dist/chat/app/services.d.ts +3 -3
  24. package/dist/chat/code/publisher.d.ts +3 -0
  25. package/dist/chat/code/store.d.ts +9 -0
  26. package/dist/chat/event-tasks/store.d.ts +10 -0
  27. package/dist/chat/ingress/slack-webhook.d.ts +1 -1
  28. package/dist/chat/plugins/agent-hooks.d.ts +5 -0
  29. package/dist/chat/{runtime/slack-runtime.d.ts → providers/slack/runtime.d.ts} +2 -2
  30. package/dist/chat/{runtime/reply-executor.d.ts → providers/slack/turn.d.ts} +10 -9
  31. package/dist/chat/resource-events/store.d.ts +12 -0
  32. package/dist/chat/runtime/turn-execution.d.ts +30 -0
  33. package/dist/chat/slack/dispatch-turn.d.ts +12 -14
  34. package/dist/chat/task-execution/slack-work.d.ts +1 -1
  35. package/dist/{chunk-SXOZIG5X.js → chunk-2ZQPVX7C.js} +6 -6
  36. package/dist/{chunk-UQP54CXZ.js → chunk-3S7ULUWW.js} +1 -1
  37. package/dist/{chunk-2CEOXDG2.js → chunk-4CNDGK25.js} +174 -6
  38. package/dist/{chunk-3THPTNN6.js → chunk-4RONS3WR.js} +4 -4
  39. package/dist/{chunk-LHQK5XCU.js → chunk-6UDPINOX.js} +2 -2
  40. package/dist/{chunk-BZD4ADQH.js → chunk-6VOYP4M6.js} +2 -3
  41. package/dist/{chunk-QHALFHZA.js → chunk-6WGC3SO4.js} +9 -9
  42. package/dist/{chunk-BDDWVY32.js → chunk-ACPDVEJO.js} +22 -20
  43. package/dist/{chunk-44BQ3TSK.js → chunk-BCHYQS4B.js} +233 -173
  44. package/dist/{chunk-SVFSYQMT.js → chunk-BHYRYYLY.js} +1 -1
  45. package/dist/{chunk-LT4QYGKM.js → chunk-BT53RIGJ.js} +160 -97
  46. package/dist/{chunk-Z7ALSQS3.js → chunk-DUKIDPF6.js} +1 -1
  47. package/dist/{chunk-PQES5LB5.js → chunk-E57WPXWY.js} +5 -5
  48. package/dist/{chunk-GGYA5NPN.js → chunk-FKEZZMXS.js} +8 -8
  49. package/dist/{chunk-LB4FWMCV.js → chunk-HIPUIPJM.js} +183 -155
  50. package/dist/{chunk-3NFHI2NA.js → chunk-HUXFMDBZ.js} +1 -1
  51. package/dist/{chunk-6TSWXBTQ.js → chunk-IZDYYYGP.js} +3 -3
  52. package/dist/{chunk-YHL2L2ZZ.js → chunk-JA43DV4Y.js} +1 -1
  53. package/dist/{chunk-V5UZCCNW.js → chunk-JM2COLGC.js} +6 -6
  54. package/dist/{chunk-A7THOQ6N.js → chunk-JNO2GUDS.js} +21 -21
  55. package/dist/{chunk-KGMHUDVF.js → chunk-K7VDC2QW.js} +6 -6
  56. package/dist/{chunk-CVBIM4Z3.js → chunk-LCP4EDKR.js} +1 -1
  57. package/dist/{chunk-4DZ62L36.js → chunk-LHXIZLFF.js} +1 -1
  58. package/dist/{chunk-D6OHGAIO.js → chunk-M5YWNMTE.js} +5 -5
  59. package/dist/{chunk-3ENUMZNG.js → chunk-MAPJFUMV.js} +3 -3
  60. package/dist/{chunk-UUMBHORH.js → chunk-MLSQX2EX.js} +1 -1
  61. package/dist/{chunk-WOIALVN2.js → chunk-PJPRXO2T.js} +1 -1
  62. package/dist/{chunk-VHMAFMHB.js → chunk-QABCY33S.js} +1 -1
  63. package/dist/{chunk-UKIHNBBD.js → chunk-SHJK75Z2.js} +3 -3
  64. package/dist/{chunk-S35OZMSL.js → chunk-UBOIHNTH.js} +13 -13
  65. package/dist/{chunk-DZR3L74W.js → chunk-UF6BUA5W.js} +3 -3
  66. package/dist/{chunk-JIOKUIAS.js → chunk-WQFEWULF.js} +2 -2
  67. package/dist/chunk-WVIA7V3M.js +975 -0
  68. package/dist/{chunk-MJISSOWB.js → chunk-YKX6MTLU.js} +1 -1
  69. package/dist/{chunk-TEFNHMO2.js → chunk-Z3QAXJR7.js} +4 -4
  70. package/dist/cli/chat.js +33 -35
  71. package/dist/cli/check.js +5 -5
  72. package/dist/cli/plugins.js +12 -12
  73. package/dist/cli/snapshot-create.js +9 -9
  74. package/dist/cli/upgrade.js +6 -6
  75. package/dist/db/schema/code.d.ts +367 -0
  76. package/dist/db/schema.d.ts +367 -1
  77. package/dist/{db-NYIWZ4L5.js → db-MA52H62H.js} +6 -6
  78. package/dist/instrumentation.js +3 -3
  79. package/dist/nitro.js +6 -6
  80. package/dist/{oauth-callback-server-A2YTPVVX.js → oauth-callback-server-DXGHKN6S.js} +25 -25
  81. package/dist/{runner-VKAEU52J.js → runner-4IXUAQNK.js} +18 -18
  82. package/dist/{skills-52GMXUTY.js → skills-X3DY7AXO.js} +5 -5
  83. package/dist/spawn-43WGS6CH.js +37 -0
  84. package/dist/task-runner-VDRKITPV.js +32 -0
  85. package/dist/{validation-VD2YQX2W.js → validation-Z6JXSTJS.js} +5 -5
  86. package/dist/version.js +1 -1
  87. package/dist/{work-ZWBTGEQP.js → work-OKWRFBDW.js} +18 -18
  88. package/dist/worker-B236AE72.js +22 -0
  89. package/migrations/0036_complex_rage.sql +32 -0
  90. package/migrations/meta/0036_snapshot.json +3186 -0
  91. package/migrations/meta/_journal.json +8 -1
  92. package/package.json +6 -7
  93. package/dist/app-adapter.d.ts +0 -85
  94. package/dist/chat/api-turns/adapter-conversations.d.ts +0 -15
  95. package/dist/chunk-CZYNWPWD.js +0 -930
  96. package/dist/spawn-GSS4EBLR.js +0 -37
  97. package/dist/task-runner-DUGDWF5O.js +0 -32
  98. package/dist/worker-XUWD5WS7.js +0 -22
@@ -2,10 +2,10 @@ import {
2
2
  ToolInputError,
3
3
  canRouteResourceEvents,
4
4
  getPlugins
5
- } from "./chunk-2CEOXDG2.js";
5
+ } from "./chunk-4CNDGK25.js";
6
6
  import {
7
7
  getDb
8
- } from "./chunk-6TSWXBTQ.js";
8
+ } from "./chunk-IZDYYYGP.js";
9
9
  import {
10
10
  juniorAttachments,
11
11
  juniorConversations,
@@ -13,28 +13,200 @@ import {
13
13
  juniorSchedulerRuns,
14
14
  juniorSchedulerTasks,
15
15
  juniorStats
16
- } from "./chunk-44BQ3TSK.js";
16
+ } from "./chunk-BCHYQS4B.js";
17
17
  import {
18
18
  juniorDestinations
19
19
  } from "./chunk-VFUK3X5B.js";
20
20
  import {
21
21
  getSlackBotToken
22
- } from "./chunk-LHQK5XCU.js";
22
+ } from "./chunk-6UDPINOX.js";
23
23
  import {
24
24
  logWarn
25
- } from "./chunk-UQP54CXZ.js";
25
+ } from "./chunk-3S7ULUWW.js";
26
+
27
+ // src/chat/event-tasks/store.ts
28
+ import {
29
+ resourceEventMatches
30
+ } from "@sentry/junior-plugin-api";
31
+ import { and, asc, desc, eq, inArray, or, sql } from "drizzle-orm";
32
+
33
+ // src/chat/event-tasks/types.ts
34
+ import {
35
+ actorUserIdSchema,
36
+ destinationVisibilitySchema,
37
+ resourceEventMatchSchema,
38
+ resourceEventTypeSchema,
39
+ slackDestinationSchema
40
+ } from "@sentry/junior-plugin-api";
41
+ import { z } from "zod";
42
+ var EVENT_TASK_IDENTIFIER_MAX_LENGTH = 300;
43
+ var eventTaskPrincipalSchema = z.object({
44
+ slackUserId: actorUserIdSchema,
45
+ fullName: z.string().optional(),
46
+ userName: z.string().optional()
47
+ }).strict();
48
+ var eventTaskTriggerSchema = z.object({
49
+ events: z.array(resourceEventTypeSchema).min(1),
50
+ label: z.string().min(1),
51
+ match: resourceEventMatchSchema.optional(),
52
+ namespace: z.string().min(1),
53
+ identifier: z.string().min(1).max(EVENT_TASK_IDENTIFIER_MAX_LENGTH),
54
+ resourceType: z.string().min(1)
55
+ }).strict();
56
+ var eventTaskSchema = z.object({
57
+ id: z.string().min(1),
58
+ createdAtMs: z.number().finite(),
59
+ createdBy: eventTaskPrincipalSchema,
60
+ credentialMode: z.enum(["system", "creator"]),
61
+ destination: slackDestinationSchema,
62
+ destinationVisibility: destinationVisibilitySchema,
63
+ task: z.object({ text: z.string().min(1) }).strict(),
64
+ trigger: eventTaskTriggerSchema
65
+ }).strict();
66
+
67
+ // src/chat/event-tasks/store.ts
68
+ function eventTaskJsonPayload(task) {
69
+ const { title: _title, ...payload } = task;
70
+ return payload;
71
+ }
72
+ function parseTask(row) {
73
+ const raw = row.task && typeof row.task === "object" ? { ...row.task } : row.task;
74
+ if (raw && typeof raw === "object" && "title" in raw) {
75
+ delete raw.title;
76
+ }
77
+ const payload = eventTaskSchema.parse(raw);
78
+ const title = row.title?.trim();
79
+ return title ? { ...payload, title } : payload;
80
+ }
81
+ async function getEventTask(db, id) {
82
+ const rows = await db.select({ task: juniorEventTasks.task, title: juniorEventTasks.title }).from(juniorEventTasks).where(eq(juniorEventTasks.id, id)).limit(1);
83
+ return rows[0] ? parseTask(rows[0]) : void 0;
84
+ }
85
+ async function createEventTask(db, task) {
86
+ const parsed = eventTaskSchema.parse(eventTaskJsonPayload(task));
87
+ const title = task.title?.trim() || null;
88
+ await db.insert(juniorEventTasks).values({
89
+ id: parsed.id,
90
+ teamId: parsed.destination.teamId,
91
+ namespace: parsed.trigger.namespace,
92
+ identifier: parsed.trigger.identifier,
93
+ createdAtMs: parsed.createdAtMs,
94
+ title,
95
+ task: parsed
96
+ }).onConflictDoNothing();
97
+ return await getEventTask(db, parsed.id) ?? { ...parsed, ...title ? { title } : void 0 };
98
+ }
99
+ async function saveEventTask(db, task) {
100
+ const parsed = eventTaskSchema.parse(eventTaskJsonPayload(task));
101
+ const title = task.title?.trim() || null;
102
+ const rows = await db.update(juniorEventTasks).set({
103
+ namespace: parsed.trigger.namespace,
104
+ identifier: parsed.trigger.identifier,
105
+ title,
106
+ task: parsed
107
+ }).where(eq(juniorEventTasks.id, parsed.id)).returning({ task: juniorEventTasks.task, title: juniorEventTasks.title });
108
+ return rows[0] ? parseTask(rows[0]) : void 0;
109
+ }
110
+ async function deleteEventTask(db, id) {
111
+ const rows = await db.delete(juniorEventTasks).where(eq(juniorEventTasks.id, id)).returning({ task: juniorEventTasks.task, title: juniorEventTasks.title });
112
+ return rows[0] ? parseTask(rows[0]) : void 0;
113
+ }
114
+ async function listEventTasksForTeam(db, teamId) {
115
+ const rows = await db.select({ task: juniorEventTasks.task, title: juniorEventTasks.title }).from(juniorEventTasks).where(eq(juniorEventTasks.teamId, teamId)).orderBy(asc(juniorEventTasks.createdAtMs), asc(juniorEventTasks.id));
116
+ return rows.map(parseTask);
117
+ }
118
+ function viewerSlackIdentities(user) {
119
+ return user.identities.filter(
120
+ (identity) => identity.provider === "slack" && Boolean(identity.providerTenantId) && Boolean(identity.providerSubjectId)
121
+ );
122
+ }
123
+ function eventTaskBelongsToUser(task, user) {
124
+ return viewerSlackIdentities(user).some(
125
+ (identity) => identity.providerTenantId === task.destination.teamId && identity.providerSubjectId === task.createdBy.slackUserId
126
+ );
127
+ }
128
+ async function listEventTasksCreatedBy(db, user, limit) {
129
+ const identities = viewerSlackIdentities(user);
130
+ const ownership = or(
131
+ ...identities.map(
132
+ (identity) => and(
133
+ eq(juniorEventTasks.teamId, identity.providerTenantId),
134
+ sql`${juniorEventTasks.task}->'createdBy'->>'slackUserId' = ${identity.providerSubjectId}`
135
+ )
136
+ )
137
+ );
138
+ if (!ownership) return [];
139
+ const rows = await db.select({ task: juniorEventTasks.task, title: juniorEventTasks.title }).from(juniorEventTasks).where(ownership).orderBy(desc(juniorEventTasks.createdAtMs), desc(juniorEventTasks.id)).limit(limit);
140
+ return rows.map(parseTask);
141
+ }
142
+ async function listPublicEventTasksForTeams(db, teamIds, limit) {
143
+ if (teamIds.length === 0) return [];
144
+ const rows = await db.select({ task: juniorEventTasks.task, title: juniorEventTasks.title }).from(juniorEventTasks).innerJoin(
145
+ juniorDestinations,
146
+ and(
147
+ eq(juniorDestinations.provider, "slack"),
148
+ eq(juniorDestinations.providerTenantId, juniorEventTasks.teamId),
149
+ sql`${juniorDestinations.providerDestinationId} = ${juniorEventTasks.task}->'destination'->>'channelId'`
150
+ )
151
+ ).where(
152
+ and(
153
+ inArray(juniorEventTasks.teamId, teamIds),
154
+ eq(juniorDestinations.visibility, "public")
155
+ )
156
+ ).orderBy(desc(juniorEventTasks.createdAtMs), desc(juniorEventTasks.id)).limit(limit);
157
+ return rows.map(parseTask);
158
+ }
159
+ async function collectEventTaskMatchKeys(db, input) {
160
+ const eventTypes = new Set(
161
+ input.eventTypes.map((eventType) => eventType.trim()).filter(Boolean)
162
+ );
163
+ const identifiers = [
164
+ ...new Set(input.identifiers.map((value) => value.trim()).filter(Boolean))
165
+ ];
166
+ if (eventTypes.size === 0 || identifiers.length === 0) return [];
167
+ const rows = await db.select({ task: juniorEventTasks.task, title: juniorEventTasks.title }).from(juniorEventTasks).where(
168
+ and(
169
+ eq(juniorEventTasks.teamId, input.teamId),
170
+ eq(juniorEventTasks.namespace, input.namespace),
171
+ inArray(juniorEventTasks.identifier, identifiers)
172
+ )
173
+ ).orderBy(asc(juniorEventTasks.createdAtMs), asc(juniorEventTasks.id));
174
+ const keys = /* @__PURE__ */ new Set();
175
+ for (const row of rows) {
176
+ const task = parseTask(row);
177
+ if (!task.trigger.events.some((eventType) => eventTypes.has(eventType))) {
178
+ continue;
179
+ }
180
+ for (const key of Object.keys(task.trigger.match ?? {})) {
181
+ keys.add(key);
182
+ }
183
+ }
184
+ return [...keys].sort();
185
+ }
186
+ async function findMatchingEventTasks(db, event, teamId) {
187
+ const rows = await db.select({ task: juniorEventTasks.task, title: juniorEventTasks.title }).from(juniorEventTasks).where(
188
+ and(
189
+ eq(juniorEventTasks.teamId, teamId),
190
+ eq(juniorEventTasks.namespace, event.namespace),
191
+ eq(juniorEventTasks.identifier, event.identifier)
192
+ )
193
+ ).orderBy(asc(juniorEventTasks.createdAtMs), asc(juniorEventTasks.id));
194
+ return rows.map(parseTask).filter(
195
+ (task) => task.trigger.events.includes(event.eventType) && resourceEventMatches(task.trigger.match, event.data)
196
+ );
197
+ }
26
198
 
27
199
  // src/chat/resource-events/catalog.ts
28
200
  import {
29
201
  normalizeResourceEventIdentifier,
30
- resourceEventMatchSchema
202
+ resourceEventMatchSchema as resourceEventMatchSchema2
31
203
  } from "@sentry/junior-plugin-api";
32
- import { z } from "zod";
204
+ import { z as z2 } from "zod";
33
205
  function enumSchema(values, unavailableMessage) {
34
206
  if (values.length === 0) {
35
- return z.string().refine(() => false, unavailableMessage);
207
+ return z2.string().refine(() => false, unavailableMessage);
36
208
  }
37
- return z.enum(values);
209
+ return z2.enum(values);
38
210
  }
39
211
  function eventNamespaceSchema(catalog) {
40
212
  return enumSchema(
@@ -82,7 +254,7 @@ function resourceEventMatchFields(catalog, namespace, resourceType) {
82
254
  )?.matchFields;
83
255
  }
84
256
  function registeredResourceEventMatchSchema() {
85
- return resourceEventMatchSchema.optional().describe(
257
+ return resourceEventMatchSchema2.optional().describe(
86
258
  "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
259
  );
88
260
  }
@@ -160,151 +332,6 @@ function getResourceEventCatalog() {
160
332
  );
161
333
  }
162
334
 
163
- // src/chat/event-tasks/store.ts
164
- import {
165
- resourceEventMatches
166
- } from "@sentry/junior-plugin-api";
167
- import { and, asc, desc, eq, inArray, or, sql } from "drizzle-orm";
168
-
169
- // src/chat/event-tasks/types.ts
170
- import {
171
- actorUserIdSchema,
172
- destinationVisibilitySchema,
173
- resourceEventMatchSchema as resourceEventMatchSchema2,
174
- resourceEventTypeSchema,
175
- slackDestinationSchema
176
- } from "@sentry/junior-plugin-api";
177
- import { z as z2 } from "zod";
178
- var EVENT_TASK_IDENTIFIER_MAX_LENGTH = 300;
179
- var eventTaskPrincipalSchema = z2.object({
180
- slackUserId: actorUserIdSchema,
181
- fullName: z2.string().optional(),
182
- userName: z2.string().optional()
183
- }).strict();
184
- var eventTaskTriggerSchema = z2.object({
185
- events: z2.array(resourceEventTypeSchema).min(1),
186
- label: z2.string().min(1),
187
- match: resourceEventMatchSchema2.optional(),
188
- namespace: z2.string().min(1),
189
- identifier: z2.string().min(1).max(EVENT_TASK_IDENTIFIER_MAX_LENGTH),
190
- resourceType: z2.string().min(1)
191
- }).strict();
192
- var eventTaskSchema = z2.object({
193
- id: z2.string().min(1),
194
- createdAtMs: z2.number().finite(),
195
- createdBy: eventTaskPrincipalSchema,
196
- credentialMode: z2.enum(["system", "creator"]),
197
- destination: slackDestinationSchema,
198
- destinationVisibility: destinationVisibilitySchema,
199
- task: z2.object({ text: z2.string().min(1) }).strict(),
200
- trigger: eventTaskTriggerSchema
201
- }).strict();
202
-
203
- // src/chat/event-tasks/store.ts
204
- function eventTaskJsonPayload(task) {
205
- const { title: _title, ...payload } = task;
206
- return payload;
207
- }
208
- function parseTask(row) {
209
- const raw = row.task && typeof row.task === "object" ? { ...row.task } : row.task;
210
- if (raw && typeof raw === "object" && "title" in raw) {
211
- delete raw.title;
212
- }
213
- const payload = eventTaskSchema.parse(raw);
214
- const title = row.title?.trim();
215
- return title ? { ...payload, title } : payload;
216
- }
217
- async function getEventTask(db, id) {
218
- const rows = await db.select({ task: juniorEventTasks.task, title: juniorEventTasks.title }).from(juniorEventTasks).where(eq(juniorEventTasks.id, id)).limit(1);
219
- return rows[0] ? parseTask(rows[0]) : void 0;
220
- }
221
- async function createEventTask(db, task) {
222
- const parsed = eventTaskSchema.parse(eventTaskJsonPayload(task));
223
- const title = task.title?.trim() || null;
224
- await db.insert(juniorEventTasks).values({
225
- id: parsed.id,
226
- teamId: parsed.destination.teamId,
227
- namespace: parsed.trigger.namespace,
228
- identifier: parsed.trigger.identifier,
229
- createdAtMs: parsed.createdAtMs,
230
- title,
231
- task: parsed
232
- }).onConflictDoNothing();
233
- return await getEventTask(db, parsed.id) ?? { ...parsed, ...title ? { title } : void 0 };
234
- }
235
- async function saveEventTask(db, task) {
236
- const parsed = eventTaskSchema.parse(eventTaskJsonPayload(task));
237
- const title = task.title?.trim() || null;
238
- const rows = await db.update(juniorEventTasks).set({
239
- namespace: parsed.trigger.namespace,
240
- identifier: parsed.trigger.identifier,
241
- title,
242
- task: parsed
243
- }).where(eq(juniorEventTasks.id, parsed.id)).returning({ task: juniorEventTasks.task, title: juniorEventTasks.title });
244
- return rows[0] ? parseTask(rows[0]) : void 0;
245
- }
246
- async function deleteEventTask(db, id) {
247
- const rows = await db.delete(juniorEventTasks).where(eq(juniorEventTasks.id, id)).returning({ task: juniorEventTasks.task, title: juniorEventTasks.title });
248
- return rows[0] ? parseTask(rows[0]) : void 0;
249
- }
250
- async function listEventTasksForTeam(db, teamId) {
251
- const rows = await db.select({ task: juniorEventTasks.task, title: juniorEventTasks.title }).from(juniorEventTasks).where(eq(juniorEventTasks.teamId, teamId)).orderBy(asc(juniorEventTasks.createdAtMs), asc(juniorEventTasks.id));
252
- return rows.map(parseTask);
253
- }
254
- function viewerSlackIdentities(user) {
255
- return user.identities.filter(
256
- (identity) => identity.provider === "slack" && Boolean(identity.providerTenantId) && Boolean(identity.providerSubjectId)
257
- );
258
- }
259
- function eventTaskBelongsToUser(task, user) {
260
- return viewerSlackIdentities(user).some(
261
- (identity) => identity.providerTenantId === task.destination.teamId && identity.providerSubjectId === task.createdBy.slackUserId
262
- );
263
- }
264
- async function listEventTasksCreatedBy(db, user, limit) {
265
- const identities = viewerSlackIdentities(user);
266
- const ownership = or(
267
- ...identities.map(
268
- (identity) => and(
269
- eq(juniorEventTasks.teamId, identity.providerTenantId),
270
- sql`${juniorEventTasks.task}->'createdBy'->>'slackUserId' = ${identity.providerSubjectId}`
271
- )
272
- )
273
- );
274
- if (!ownership) return [];
275
- const rows = await db.select({ task: juniorEventTasks.task, title: juniorEventTasks.title }).from(juniorEventTasks).where(ownership).orderBy(desc(juniorEventTasks.createdAtMs), desc(juniorEventTasks.id)).limit(limit);
276
- return rows.map(parseTask);
277
- }
278
- async function listPublicEventTasksForTeams(db, teamIds, limit) {
279
- if (teamIds.length === 0) return [];
280
- const rows = await db.select({ task: juniorEventTasks.task, title: juniorEventTasks.title }).from(juniorEventTasks).innerJoin(
281
- juniorDestinations,
282
- and(
283
- eq(juniorDestinations.provider, "slack"),
284
- eq(juniorDestinations.providerTenantId, juniorEventTasks.teamId),
285
- sql`${juniorDestinations.providerDestinationId} = ${juniorEventTasks.task}->'destination'->>'channelId'`
286
- )
287
- ).where(
288
- and(
289
- inArray(juniorEventTasks.teamId, teamIds),
290
- eq(juniorDestinations.visibility, "public")
291
- )
292
- ).orderBy(desc(juniorEventTasks.createdAtMs), desc(juniorEventTasks.id)).limit(limit);
293
- return rows.map(parseTask);
294
- }
295
- async function findMatchingEventTasks(db, event, teamId) {
296
- const rows = await db.select({ task: juniorEventTasks.task, title: juniorEventTasks.title }).from(juniorEventTasks).where(
297
- and(
298
- eq(juniorEventTasks.teamId, teamId),
299
- eq(juniorEventTasks.namespace, event.namespace),
300
- eq(juniorEventTasks.identifier, event.identifier)
301
- )
302
- ).orderBy(asc(juniorEventTasks.createdAtMs), asc(juniorEventTasks.id));
303
- return rows.map(parseTask).filter(
304
- (task) => task.trigger.events.includes(event.eventType) && resourceEventMatches(task.trigger.match, event.data)
305
- );
306
- }
307
-
308
335
  // src/stats.ts
309
336
  import { and as and2, asc as asc2, gte, lte, sql as sql2 } from "drizzle-orm";
310
337
  function utcDate(nowMs) {
@@ -1232,6 +1259,7 @@ export {
1232
1259
  eventTaskBelongsToUser,
1233
1260
  listEventTasksCreatedBy,
1234
1261
  listPublicEventTasksForTeams,
1262
+ collectEventTaskMatchKeys,
1235
1263
  findMatchingEventTasks,
1236
1264
  eventTaskToolResultSchema,
1237
1265
  eventTaskListToolResultSchema,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-WOIALVN2.js";
3
+ } from "./chunk-PJPRXO2T.js";
4
4
 
5
5
  // src/chat/plugins/validation.ts
6
6
  import { isDeepStrictEqual } from "util";
@@ -8,7 +8,7 @@ import {
8
8
  juniorConversations,
9
9
  juniorIdentities,
10
10
  juniorUsers
11
- } from "./chunk-44BQ3TSK.js";
11
+ } from "./chunk-BCHYQS4B.js";
12
12
  import {
13
13
  juniorDestinations
14
14
  } from "./chunk-VFUK3X5B.js";
@@ -16,7 +16,7 @@ import {
16
16
  TURN_REASONING_LEVELS,
17
17
  getChatConfig,
18
18
  modelProfileSchema
19
- } from "./chunk-LHQK5XCU.js";
19
+ } from "./chunk-6UDPINOX.js";
20
20
  import {
21
21
  parseActorUserId,
22
22
  parseSlackChannelReferenceId,
@@ -24,7 +24,7 @@ import {
24
24
  } from "./chunk-N7TMSOZH.js";
25
25
  import {
26
26
  normalizeIdentityEmail
27
- } from "./chunk-UQP54CXZ.js";
27
+ } from "./chunk-3S7ULUWW.js";
28
28
 
29
29
  // src/chat/conversations/sql/store.ts
30
30
  import { randomUUID as randomUUID2 } from "crypto";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  abandonTurnRecord,
3
3
  extractAssistantText
4
- } from "./chunk-SXOZIG5X.js";
4
+ } from "./chunk-2ZQPVX7C.js";
5
5
 
6
6
  // src/chat/state/turn-id.ts
7
7
  function buildDeterministicTurnId(messageId) {
@@ -5,19 +5,19 @@ import {
5
5
  isDmChannel,
6
6
  normalizeSlackConversationId,
7
7
  withSlackRetries
8
- } from "./chunk-2CEOXDG2.js";
8
+ } from "./chunk-4CNDGK25.js";
9
9
  import {
10
10
  parseDestination
11
- } from "./chunk-6TSWXBTQ.js";
11
+ } from "./chunk-IZDYYYGP.js";
12
12
  import {
13
13
  getStateAdapter
14
- } from "./chunk-Z7ALSQS3.js";
14
+ } from "./chunk-DUKIDPF6.js";
15
15
  import {
16
16
  normalizeSlackEmojiName
17
- } from "./chunk-LHQK5XCU.js";
17
+ } from "./chunk-6UDPINOX.js";
18
18
  import {
19
19
  pluginCatalogRuntime
20
- } from "./chunk-WOIALVN2.js";
20
+ } from "./chunk-PJPRXO2T.js";
21
21
  import {
22
22
  parseSlackMessageTs,
23
23
  parseSlackUserId
@@ -26,7 +26,7 @@ import {
26
26
  isRecord,
27
27
  logInfo,
28
28
  logWarn
29
- } from "./chunk-UQP54CXZ.js";
29
+ } from "./chunk-3S7ULUWW.js";
30
30
 
31
31
  // src/chat/slack/outbound.ts
32
32
  var MAX_SLACK_MESSAGE_TEXT_CHARS = 4e4;
@@ -7,7 +7,7 @@ import {
7
7
  PluginCredentialFailureError,
8
8
  agentNameSchema,
9
9
  createPluginAuthOrchestration
10
- } from "./chunk-KGMHUDVF.js";
10
+ } from "./chunk-K7VDC2QW.js";
11
11
  import {
12
12
  parseSandboxEgressAuthRequiredSignal,
13
13
  parseSandboxEgressPermissionDeniedSignal,
@@ -38,7 +38,7 @@ import {
38
38
  searchSlackUsers,
39
39
  selectPluginGrant,
40
40
  toMcpProviderError
41
- } from "./chunk-GGYA5NPN.js";
41
+ } from "./chunk-FKEZZMXS.js";
42
42
  import {
43
43
  RetryableDeliveryError,
44
44
  actorFromRun,
@@ -54,7 +54,7 @@ import {
54
54
  getSlackMessagePermalink,
55
55
  resolveBaseUrl,
56
56
  uploadFilesToConversation
57
- } from "./chunk-V5UZCCNW.js";
57
+ } from "./chunk-JM2COLGC.js";
58
58
  import {
59
59
  SCHEDULED_TASK_SYSTEM_ACTOR,
60
60
  compactEventTask,
@@ -90,13 +90,13 @@ import {
90
90
  saveScheduledTask,
91
91
  storeAttachments,
92
92
  writableEventTask
93
- } from "./chunk-LB4FWMCV.js";
93
+ } from "./chunk-HIPUIPJM.js";
94
94
  import {
95
95
  parseSlackThreadId
96
- } from "./chunk-MJISSOWB.js";
96
+ } from "./chunk-YKX6MTLU.js";
97
97
  import {
98
98
  appendAndEnqueueInboundMessage
99
- } from "./chunk-TEFNHMO2.js";
99
+ } from "./chunk-Z3QAXJR7.js";
100
100
  import {
101
101
  CooperativeTurnYieldError,
102
102
  NO_REPLY_MARKER,
@@ -111,7 +111,7 @@ import {
111
111
  isTurnInputCommitLostError,
112
112
  isTurnInputDeferredError,
113
113
  sanitizeAssistantText
114
- } from "./chunk-YHL2L2ZZ.js";
114
+ } from "./chunk-JA43DV4Y.js";
115
115
  import {
116
116
  AGENTS_REMOVAL_NOTICE,
117
117
  AGENTS_REPLACEMENT_NOTICE,
@@ -170,7 +170,7 @@ import {
170
170
  stripRuntimeTurnContext,
171
171
  trimTrailingAssistantMessages,
172
172
  truncateText
173
- } from "./chunk-SXOZIG5X.js";
173
+ } from "./chunk-2ZQPVX7C.js";
174
174
  import {
175
175
  bindSandboxFileSystem,
176
176
  createSandboxSession,
@@ -181,7 +181,7 @@ import {
181
181
  resolve,
182
182
  setSnapshotSpanAttributes,
183
183
  stopSession
184
- } from "./chunk-3ENUMZNG.js";
184
+ } from "./chunk-MAPJFUMV.js";
185
185
  import {
186
186
  privateTraceResultAttributes
187
187
  } from "./chunk-UIE3R5XU.js";
@@ -194,7 +194,7 @@ import {
194
194
  } from "./chunk-DKIJ2RP5.js";
195
195
  import {
196
196
  getTurnRequestDeadline
197
- } from "./chunk-UUMBHORH.js";
197
+ } from "./chunk-MLSQX2EX.js";
198
198
  import {
199
199
  RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS,
200
200
  RESOURCE_SUBSCRIPTION_MAX_TTL_MS,
@@ -244,7 +244,7 @@ import {
244
244
  updateWorkspace,
245
245
  withSlackRetries,
246
246
  workspaceRepoCheckoutPath
247
- } from "./chunk-2CEOXDG2.js";
247
+ } from "./chunk-4CNDGK25.js";
248
248
  import {
249
249
  KNOWN_CONVERSATION_EVENT_TYPES,
250
250
  contextProvenance,
@@ -258,12 +258,12 @@ import {
258
258
  instructionProvenanceFor,
259
259
  requireSlackDestination,
260
260
  sameActorIdentity
261
- } from "./chunk-6TSWXBTQ.js";
261
+ } from "./chunk-IZDYYYGP.js";
262
262
  import {
263
263
  juniorArtifacts,
264
264
  juniorIdentities,
265
265
  juniorSchedulerRuns
266
- } from "./chunk-44BQ3TSK.js";
266
+ } from "./chunk-BCHYQS4B.js";
267
267
  import {
268
268
  SANDBOX_DATA_ROOT,
269
269
  SANDBOX_REPOS_ROOT,
@@ -290,12 +290,12 @@ import {
290
290
  sleep,
291
291
  throwSandboxOperationError,
292
292
  wrapSandboxSetupError
293
- } from "./chunk-UKIHNBBD.js";
293
+ } from "./chunk-SHJK75Z2.js";
294
294
  import {
295
295
  fenceLock,
296
296
  getStateAdapter,
297
297
  withLock
298
- } from "./chunk-Z7ALSQS3.js";
298
+ } from "./chunk-DUKIDPF6.js";
299
299
  import {
300
300
  ACTIVE_TURN_COMPACTION_SUMMARY_PREFIX,
301
301
  COMPACTION_SUMMARY_PREFIX,
@@ -326,7 +326,7 @@ import {
326
326
  resolveGatewayCredential,
327
327
  resolveGatewayModel,
328
328
  unwrapCurrentInstruction
329
- } from "./chunk-LHQK5XCU.js";
329
+ } from "./chunk-6UDPINOX.js";
330
330
  import {
331
331
  canExposeConversationPayload,
332
332
  resolveConversationPrivacy,
@@ -336,16 +336,16 @@ import {
336
336
  toGenAiMessagesTraceAttributes,
337
337
  toGenAiPayloadMetadata,
338
338
  toGenAiPayloadTraceAttributes
339
- } from "./chunk-SVFSYQMT.js";
339
+ } from "./chunk-BHYRYYLY.js";
340
340
  import {
341
341
  discoverSkills,
342
342
  findSkillByName,
343
343
  loadSkillsByName,
344
344
  parseSkillInvocation
345
- } from "./chunk-JIOKUIAS.js";
345
+ } from "./chunk-WQFEWULF.js";
346
346
  import {
347
347
  pluginCatalogRuntime
348
- } from "./chunk-WOIALVN2.js";
348
+ } from "./chunk-PJPRXO2T.js";
349
349
  import {
350
350
  CredentialUnavailableError,
351
351
  OAuthProviderError,
@@ -353,7 +353,7 @@ import {
353
353
  getOAuthProviderErrorAttributes,
354
354
  resolveAuthTokenPlaceholder,
355
355
  resolvePluginCommandEnv
356
- } from "./chunk-4DZ62L36.js";
356
+ } from "./chunk-LHXIZLFF.js";
357
357
  import {
358
358
  credentialContextForActor,
359
359
  credentialUserSubjectId
@@ -393,7 +393,7 @@ import {
393
393
  summarizeMessageText,
394
394
  withLogContext,
395
395
  withSpan
396
- } from "./chunk-UQP54CXZ.js";
396
+ } from "./chunk-3S7ULUWW.js";
397
397
  import {
398
398
  startInactiveSpan,
399
399
  withActiveSpan
@@ -7,23 +7,23 @@ import {
7
7
  import {
8
8
  formatProviderLabel,
9
9
  startOAuthFlow
10
- } from "./chunk-V5UZCCNW.js";
10
+ } from "./chunk-JM2COLGC.js";
11
11
  import {
12
12
  abandonReplacedPendingAuth,
13
13
  canReusePendingAuthLink
14
- } from "./chunk-YHL2L2ZZ.js";
14
+ } from "./chunk-JA43DV4Y.js";
15
15
  import {
16
16
  recordAuthorizationRequested
17
- } from "./chunk-SXOZIG5X.js";
17
+ } from "./chunk-2ZQPVX7C.js";
18
18
  import {
19
19
  AGENT_INVOCATION_MAILBOX_STATUSES
20
- } from "./chunk-44BQ3TSK.js";
20
+ } from "./chunk-BCHYQS4B.js";
21
21
  import {
22
22
  TURN_REASONING_LEVELS
23
- } from "./chunk-LHQK5XCU.js";
23
+ } from "./chunk-6UDPINOX.js";
24
24
  import {
25
25
  pluginCatalogRuntime
26
- } from "./chunk-WOIALVN2.js";
26
+ } from "./chunk-PJPRXO2T.js";
27
27
  import {
28
28
  credentialContextSchema
29
29
  } from "./chunk-CEMMLV5L.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getStateAdapter
3
- } from "./chunk-Z7ALSQS3.js";
3
+ } from "./chunk-DUKIDPF6.js";
4
4
  import {
5
5
  getClient
6
6
  } from "./chunk-PEQXYSSE.js";
@@ -12,7 +12,7 @@ import {
12
12
  logInfo,
13
13
  logWarn,
14
14
  setSpanAttributes
15
- } from "./chunk-UQP54CXZ.js";
15
+ } from "./chunk-3S7ULUWW.js";
16
16
 
17
17
  // src/chat/plugins/manifest.ts
18
18
  import { z } from "zod";