@sentry/junior 0.182.0 → 0.183.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.
- package/dist/{agent-hooks-3S25UIHO.js → agent-hooks-SNRBZYAU.js} +11 -11
- package/dist/api/code/overview.d.ts +35 -0
- package/dist/api/code/routes.d.ts +4 -0
- package/dist/api/schema/code.d.ts +75 -0
- package/dist/api/schema.d.ts +2 -0
- package/dist/api/schema.js +9 -1
- package/dist/api.js +258 -134
- package/dist/app.js +71 -48
- package/dist/{catalog-runtime-ESLMBQBV.js → catalog-runtime-3I3JOIIH.js} +4 -4
- package/dist/chat/agent-invocations/store.d.ts +4 -2
- package/dist/chat/agent-invocations/work.d.ts +1 -3
- package/dist/chat/app/factory.d.ts +3 -3
- package/dist/chat/app/services.d.ts +3 -3
- package/dist/chat/code/publisher.d.ts +3 -0
- package/dist/chat/code/store.d.ts +9 -0
- package/dist/chat/event-tasks/store.d.ts +10 -0
- package/dist/chat/ingress/slack-webhook.d.ts +1 -1
- package/dist/chat/plugins/agent-hooks.d.ts +5 -0
- package/dist/chat/{runtime/slack-runtime.d.ts → providers/slack/runtime.d.ts} +2 -2
- package/dist/chat/{runtime/reply-executor.d.ts → providers/slack/turn.d.ts} +10 -9
- package/dist/chat/resource-events/store.d.ts +12 -0
- package/dist/chat/runtime/turn-execution.d.ts +30 -0
- package/dist/chat/slack/dispatch-turn.d.ts +12 -14
- package/dist/chat/task-execution/slack-work.d.ts +1 -1
- package/dist/{chunk-SXOZIG5X.js → chunk-24OJZ5OU.js} +6 -6
- package/dist/{chunk-SVFSYQMT.js → chunk-2ADFGSUS.js} +1 -1
- package/dist/{chunk-GGYA5NPN.js → chunk-2EPYYVJC.js} +8 -8
- package/dist/{chunk-KGMHUDVF.js → chunk-35PM4YY5.js} +6 -6
- package/dist/{chunk-3ENUMZNG.js → chunk-37IQ6DGU.js} +3 -3
- package/dist/{chunk-3THPTNN6.js → chunk-3HJ4F4L7.js} +4 -4
- package/dist/{chunk-3NFHI2NA.js → chunk-3L7CWDQQ.js} +1 -1
- package/dist/{chunk-CVBIM4Z3.js → chunk-4WGFWHWP.js} +1 -1
- package/dist/{chunk-YHL2L2ZZ.js → chunk-56XONJPF.js} +1 -1
- package/dist/{chunk-44BQ3TSK.js → chunk-6UXDTPEN.js} +233 -173
- package/dist/{chunk-2CEOXDG2.js → chunk-AHMWPFIW.js} +174 -6
- package/dist/{chunk-6TSWXBTQ.js → chunk-AX3UDIMA.js} +3 -3
- package/dist/{chunk-S35OZMSL.js → chunk-AYW7J6K4.js} +13 -13
- package/dist/{chunk-WOIALVN2.js → chunk-E3OBGRHN.js} +1 -1
- package/dist/{chunk-4DZ62L36.js → chunk-EENQGEIP.js} +1 -1
- package/dist/{chunk-UUMBHORH.js → chunk-FJMTMGBC.js} +1 -1
- package/dist/{chunk-Z7ALSQS3.js → chunk-G2B2XZQW.js} +1 -1
- package/dist/{chunk-TEFNHMO2.js → chunk-HUK5XIZL.js} +4 -4
- package/dist/{chunk-LT4QYGKM.js → chunk-IO6KFXYE.js} +160 -97
- package/dist/{chunk-JIOKUIAS.js → chunk-KTXOGLNE.js} +2 -2
- package/dist/{chunk-LHQK5XCU.js → chunk-LMNMMESF.js} +2 -2
- package/dist/{chunk-UQP54CXZ.js → chunk-LZBPGX5A.js} +1 -1
- package/dist/{chunk-PQES5LB5.js → chunk-PLZT45VC.js} +5 -5
- package/dist/{chunk-V5UZCCNW.js → chunk-QI5JW5AG.js} +6 -6
- package/dist/{chunk-A7THOQ6N.js → chunk-QZV76CM4.js} +21 -21
- package/dist/{chunk-LB4FWMCV.js → chunk-R767Y7QV.js} +183 -155
- package/dist/{chunk-MJISSOWB.js → chunk-SQHFVIMZ.js} +1 -1
- package/dist/{chunk-BDDWVY32.js → chunk-T5MTGX2E.js} +19 -19
- package/dist/{chunk-DZR3L74W.js → chunk-V64JCZUV.js} +3 -3
- package/dist/{chunk-VHMAFMHB.js → chunk-VOV3SCM3.js} +1 -1
- package/dist/{chunk-BZD4ADQH.js → chunk-W46NIB5H.js} +1 -1
- package/dist/{chunk-QHALFHZA.js → chunk-W5JMPEBO.js} +9 -9
- package/dist/{chunk-D6OHGAIO.js → chunk-WOKJRLM2.js} +5 -5
- package/dist/chunk-WVIA7V3M.js +975 -0
- package/dist/{chunk-UKIHNBBD.js → chunk-X52ESOBP.js} +3 -3
- package/dist/cli/chat.js +33 -35
- package/dist/cli/check.js +5 -5
- package/dist/cli/plugins.js +12 -12
- package/dist/cli/snapshot-create.js +9 -9
- package/dist/cli/upgrade.js +6 -6
- package/dist/db/schema/code.d.ts +367 -0
- package/dist/db/schema.d.ts +367 -1
- package/dist/{db-NYIWZ4L5.js → db-K2VMNLHQ.js} +6 -6
- package/dist/instrumentation.js +3 -3
- package/dist/nitro.js +6 -6
- package/dist/{oauth-callback-server-A2YTPVVX.js → oauth-callback-server-DZZMTKSS.js} +25 -25
- package/dist/{runner-VKAEU52J.js → runner-IIAKWDXI.js} +18 -18
- package/dist/{skills-52GMXUTY.js → skills-EXIQ7BP5.js} +5 -5
- package/dist/spawn-ZR6OOEAN.js +37 -0
- package/dist/task-runner-C52HYCVD.js +32 -0
- package/dist/{validation-VD2YQX2W.js → validation-XUGIWBJF.js} +5 -5
- package/dist/version.js +1 -1
- package/dist/{work-ZWBTGEQP.js → work-G4RLJ634.js} +18 -18
- package/dist/worker-R2JEHK67.js +22 -0
- package/migrations/0036_complex_rage.sql +32 -0
- package/migrations/meta/0036_snapshot.json +3186 -0
- package/migrations/meta/_journal.json +8 -1
- package/package.json +6 -6
- package/dist/chunk-CZYNWPWD.js +0 -930
- package/dist/spawn-GSS4EBLR.js +0 -37
- package/dist/task-runner-DUGDWF5O.js +0 -32
- package/dist/worker-XUWD5WS7.js +0 -22
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
ToolInputError,
|
|
3
3
|
canRouteResourceEvents,
|
|
4
4
|
getPlugins
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-AHMWPFIW.js";
|
|
6
6
|
import {
|
|
7
7
|
getDb
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-AX3UDIMA.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-
|
|
16
|
+
} from "./chunk-6UXDTPEN.js";
|
|
17
17
|
import {
|
|
18
18
|
juniorDestinations
|
|
19
19
|
} from "./chunk-VFUK3X5B.js";
|
|
20
20
|
import {
|
|
21
21
|
getSlackBotToken
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-LMNMMESF.js";
|
|
23
23
|
import {
|
|
24
24
|
logWarn
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-LZBPGX5A.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
|
|
207
|
+
return z2.string().refine(() => false, unavailableMessage);
|
|
36
208
|
}
|
|
37
|
-
return
|
|
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
|
|
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,
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
buildSentryConversationUrl,
|
|
6
6
|
deleteWebAuthorization
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-4WGFWHWP.js";
|
|
8
8
|
import {
|
|
9
9
|
buildDeliveredTurnStatePatch,
|
|
10
10
|
finalizeFailedTurnReplyWithEvent,
|
|
@@ -15,11 +15,11 @@ import {
|
|
|
15
15
|
getTurnUserSlackMessageTs,
|
|
16
16
|
persistAuthPauseTurnState,
|
|
17
17
|
requireTurnFailureEventId
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-WOKJRLM2.js";
|
|
19
19
|
import {
|
|
20
20
|
resolveTurnSessionRouting,
|
|
21
21
|
scheduleSessionCompletedPluginTasks
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-W5JMPEBO.js";
|
|
23
23
|
import {
|
|
24
24
|
ConversationTurnLifecycleService
|
|
25
25
|
} from "./chunk-M3QYTBQ6.js";
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
getPersistedSandboxState,
|
|
31
31
|
getPersistedThreadState,
|
|
32
32
|
persistThreadStateById
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-PLZT45VC.js";
|
|
34
34
|
import {
|
|
35
35
|
createUserTokenStore,
|
|
36
36
|
deleteMcpAuthSession,
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
lookupSlackUserProfile,
|
|
42
42
|
resolvePluginOAuthAccount,
|
|
43
43
|
runAgentWithTimeout
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-2EPYYVJC.js";
|
|
45
45
|
import {
|
|
46
46
|
RetryableDeliveryError
|
|
47
47
|
} from "./chunk-RF6J3DIO.js";
|
|
@@ -57,17 +57,17 @@ import {
|
|
|
57
57
|
removeReactionFromMessage,
|
|
58
58
|
resolveBaseUrl,
|
|
59
59
|
truncateStatusText
|
|
60
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-QI5JW5AG.js";
|
|
61
61
|
import {
|
|
62
62
|
parseSlackThreadId,
|
|
63
63
|
readSlackRawMessageContext,
|
|
64
64
|
resolveSlackChannelIdFromMessage,
|
|
65
65
|
resolveSlackChannelIdFromThreadId
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-SQHFVIMZ.js";
|
|
67
67
|
import {
|
|
68
68
|
ensureConversationWake,
|
|
69
69
|
requestConversationWork
|
|
70
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-HUK5XIZL.js";
|
|
71
71
|
import {
|
|
72
72
|
CooperativeTurnYieldError,
|
|
73
73
|
clearPendingAuth,
|
|
@@ -76,7 +76,7 @@ import {
|
|
|
76
76
|
isCooperativeTurnYieldError,
|
|
77
77
|
isPendingAuthLatestRequest,
|
|
78
78
|
markTurnFailed
|
|
79
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-56XONJPF.js";
|
|
80
80
|
import {
|
|
81
81
|
TurnSliceLimitExceededError,
|
|
82
82
|
abandonTurnRecord,
|
|
@@ -96,13 +96,13 @@ import {
|
|
|
96
96
|
recordTurnSummary,
|
|
97
97
|
saveTurnCheckpoint,
|
|
98
98
|
turnHasReply
|
|
99
|
-
} from "./chunk-
|
|
99
|
+
} from "./chunk-24OJZ5OU.js";
|
|
100
100
|
import {
|
|
101
101
|
getVercelConversationWorkQueue
|
|
102
102
|
} from "./chunk-DKIJ2RP5.js";
|
|
103
103
|
import {
|
|
104
104
|
getTurnRequestDeadline
|
|
105
|
-
} from "./chunk-
|
|
105
|
+
} from "./chunk-FJMTMGBC.js";
|
|
106
106
|
import {
|
|
107
107
|
SlackActionError,
|
|
108
108
|
getDashboardConversationLink,
|
|
@@ -111,18 +111,18 @@ import {
|
|
|
111
111
|
getSlackClient,
|
|
112
112
|
isDmChannel,
|
|
113
113
|
normalizeSlackConversationId
|
|
114
|
-
} from "./chunk-
|
|
114
|
+
} from "./chunk-AHMWPFIW.js";
|
|
115
115
|
import {
|
|
116
116
|
getConversationEventStore,
|
|
117
117
|
getSqlExecutor,
|
|
118
118
|
requireSlackDestination,
|
|
119
119
|
upsertIdentity,
|
|
120
120
|
upsertLinkedIdentity
|
|
121
|
-
} from "./chunk-
|
|
121
|
+
} from "./chunk-AX3UDIMA.js";
|
|
122
122
|
import {
|
|
123
123
|
acquireActiveLock,
|
|
124
124
|
getStateAdapter
|
|
125
|
-
} from "./chunk-
|
|
125
|
+
} from "./chunk-G2B2XZQW.js";
|
|
126
126
|
import {
|
|
127
127
|
botConfig,
|
|
128
128
|
defaultModelId,
|
|
@@ -130,18 +130,18 @@ import {
|
|
|
130
130
|
getChatConfig,
|
|
131
131
|
getRuntimeMetadata,
|
|
132
132
|
normalizeSlackEmojiName
|
|
133
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-LMNMMESF.js";
|
|
134
134
|
import {
|
|
135
135
|
discoverSkills
|
|
136
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-KTXOGLNE.js";
|
|
137
137
|
import {
|
|
138
138
|
pluginCatalogRuntime
|
|
139
|
-
} from "./chunk-
|
|
139
|
+
} from "./chunk-E3OBGRHN.js";
|
|
140
140
|
import {
|
|
141
141
|
buildOAuthTokenRequest,
|
|
142
142
|
hasRequiredOAuthScope,
|
|
143
143
|
parseOAuthTokenResponse
|
|
144
|
-
} from "./chunk-
|
|
144
|
+
} from "./chunk-EENQGEIP.js";
|
|
145
145
|
import {
|
|
146
146
|
createSlackResumeActor,
|
|
147
147
|
isUserActor,
|
|
@@ -160,7 +160,7 @@ import {
|
|
|
160
160
|
setTags,
|
|
161
161
|
toOptionalString,
|
|
162
162
|
withLogContext
|
|
163
|
-
} from "./chunk-
|
|
163
|
+
} from "./chunk-LZBPGX5A.js";
|
|
164
164
|
|
|
165
165
|
// src/chat/slack/assistant-thread/status-render.ts
|
|
166
166
|
var DEFAULT_STATUS_CONTEXTS = {
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
} from "./chunk-7H2VZTWN.js";
|
|
7
7
|
import {
|
|
8
8
|
runWithTurnRequestDeadline
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-FJMTMGBC.js";
|
|
10
10
|
import {
|
|
11
11
|
logWarn
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-LZBPGX5A.js";
|
|
13
13
|
|
|
14
14
|
// src/chat/plugins/task-queue.ts
|
|
15
15
|
import { createHash } from "crypto";
|
|
@@ -129,7 +129,7 @@ function pluginTaskCallback() {
|
|
|
129
129
|
onRejected: logPluginTaskQueueMessageRejected,
|
|
130
130
|
// Load the runner on first use so this module can send without a cycle.
|
|
131
131
|
run: async (message) => {
|
|
132
|
-
const { processPluginTask } = await import("./task-runner-
|
|
132
|
+
const { processPluginTask } = await import("./task-runner-C52HYCVD.js");
|
|
133
133
|
await processPluginTask(message);
|
|
134
134
|
},
|
|
135
135
|
topic: PLUGIN_TASK_QUEUE_TOPIC,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
coerceThreadConversationState,
|
|
3
3
|
getPersistedThreadState
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-PLZT45VC.js";
|
|
5
5
|
import {
|
|
6
6
|
pluginTaskId,
|
|
7
7
|
pluginTaskParamsSchema,
|
|
8
8
|
sendVercelPluginTask
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-V64JCZUV.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-
|
|
19
|
+
} from "./chunk-24OJZ5OU.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-
|
|
28
|
+
} from "./chunk-AHMWPFIW.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-
|
|
36
|
+
} from "./chunk-AX3UDIMA.js";
|
|
37
37
|
import {
|
|
38
38
|
juniorConversations,
|
|
39
39
|
juniorTaskExecutions
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-6UXDTPEN.js";
|
|
41
41
|
import {
|
|
42
42
|
getStateAdapter
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-G2B2XZQW.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-
|
|
52
|
+
} from "./chunk-LZBPGX5A.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-
|
|
59
|
+
const conversationStore = args.conversationStore ?? (await import("./db-K2VMNLHQ.js")).getConversationStore();
|
|
60
60
|
const conversation = await conversationStore.get({
|
|
61
61
|
conversationId: args.conversationId
|
|
62
62
|
});
|
|
@@ -2,29 +2,29 @@ import {
|
|
|
2
2
|
coerceThreadConversationState,
|
|
3
3
|
getPersistedThreadState,
|
|
4
4
|
persistThreadStateById
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-PLZT45VC.js";
|
|
6
6
|
import {
|
|
7
7
|
buildDeterministicTurnId,
|
|
8
8
|
clearPendingAuth,
|
|
9
9
|
markTurnClosed,
|
|
10
10
|
markTurnCompleted
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-56XONJPF.js";
|
|
12
12
|
import {
|
|
13
13
|
hydrateConversationMessages,
|
|
14
14
|
markConversationMessage
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-24OJZ5OU.js";
|
|
16
16
|
import {
|
|
17
17
|
ProviderError,
|
|
18
18
|
findProviderError,
|
|
19
19
|
getProviderErrorAttributes,
|
|
20
20
|
getProviderErrorUserMessage
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-LMNMMESF.js";
|
|
22
22
|
import {
|
|
23
23
|
parseSlackMessageTs
|
|
24
24
|
} from "./chunk-N7TMSOZH.js";
|
|
25
25
|
import {
|
|
26
26
|
buildTurnFailureResponse
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-LZBPGX5A.js";
|
|
28
28
|
|
|
29
29
|
// src/chat/runtime/delivered-turn-state.ts
|
|
30
30
|
function buildDeliveredTurnStatePatch(args) {
|