@sentry/junior 0.194.0 → 0.195.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-IDX764FD.js → agent-hooks-VIBTIP5F.js} +11 -11
- package/dist/api/activity.d.ts +9 -1
- package/dist/api/code/overview.d.ts +12 -0
- package/dist/api/locations/detail.d.ts +8 -0
- package/dist/api/locations/list.d.ts +5 -0
- package/dist/api/people/code.d.ts +6 -0
- package/dist/api/people/shared.d.ts +9 -1
- package/dist/api/reporting-window.d.ts +39 -1
- package/dist/api/schema/code.d.ts +12 -0
- package/dist/api/schema/conversation.d.ts +25 -0
- package/dist/api/schema/location.d.ts +13 -0
- package/dist/api/schema/person.d.ts +14 -0
- package/dist/api/schema/task.d.ts +12 -0
- package/dist/api/schema.js +1 -1
- package/dist/api.js +242 -63
- package/dist/app.js +102 -38
- package/dist/{catalog-runtime-MICXEBLK.js → catalog-runtime-6E6SGRZK.js} +4 -4
- package/dist/chat/config.d.ts +1 -0
- package/dist/chat/event-tasks/store.d.ts +27 -17
- package/dist/chat/resource-events/notification.d.ts +2 -1
- package/dist/chat/services/automated-turn-limit.d.ts +110 -0
- package/dist/chat/slack/automated-turn-limit-notice.d.ts +38 -0
- package/dist/chat/tasks/execution-stats.d.ts +2 -1
- package/dist/chat/tasks/read.d.ts +5 -2
- package/dist/{chunk-KNIAWMBU.js → chunk-3VWIZVK7.js} +1 -1
- package/dist/{chunk-XND3J6AT.js → chunk-5HNXLP4W.js} +1 -1
- package/dist/{chunk-VOB2DKO6.js → chunk-5NR7N567.js} +24 -13
- package/dist/{chunk-CFGBKPWQ.js → chunk-6GGDBXXP.js} +3 -3
- package/dist/{chunk-IOGDKPVU.js → chunk-6TRQLG3D.js} +1 -1
- package/dist/{chunk-V4HXV5MY.js → chunk-7MYXH5LA.js} +1 -1
- package/dist/{chunk-6H2MKVV5.js → chunk-7PQMTME5.js} +1 -1
- package/dist/{chunk-INTBMGNX.js → chunk-7UED4D5T.js} +21 -21
- package/dist/{chunk-NPO24LAN.js → chunk-BJZML4RT.js} +8 -8
- package/dist/{chunk-IME5OW4Y.js → chunk-C4NY6L7S.js} +1 -1
- package/dist/{chunk-53IEEFFP.js → chunk-CE2P6TOV.js} +3 -3
- package/dist/{chunk-WMJS5DDV.js → chunk-DTYOEHUP.js} +148 -19
- package/dist/{chunk-GY5SEFVL.js → chunk-FE3Y4KES.js} +5 -5
- package/dist/{chunk-G4RARFNT.js → chunk-FEZIEEOP.js} +957 -567
- package/dist/{chunk-XLWZRHX5.js → chunk-FPQPYJEG.js} +23 -29
- package/dist/{chunk-73JEAQRT.js → chunk-HE5PZAPS.js} +4 -4
- package/dist/{chunk-X76JVHQ4.js → chunk-HUQOXMDG.js} +1 -1
- package/dist/{chunk-NWWDFHXP.js → chunk-I4RH3KLJ.js} +1 -1
- package/dist/{chunk-QMEF4Z7R.js → chunk-JBSCMOLR.js} +5 -5
- package/dist/{chunk-JOI3DHML.js → chunk-KBPWC7NU.js} +1 -1
- package/dist/{chunk-ADEACKAH.js → chunk-KQ3GZGBK.js} +10 -3
- package/dist/{chunk-2NL3Y47F.js → chunk-KUQRWV53.js} +5 -5
- package/dist/{chunk-ELCYG6UU.js → chunk-L62JVQPL.js} +3 -3
- package/dist/{chunk-7ANA7PBB.js → chunk-LM7UE523.js} +3 -3
- package/dist/{chunk-U76RWMFR.js → chunk-LMYRF6HX.js} +4 -2
- package/dist/{chunk-F2KSURTJ.js → chunk-N67T4VY3.js} +9 -9
- package/dist/{chunk-AWZS5SVX.js → chunk-OQHO62VA.js} +8 -8
- package/dist/{chunk-CCTYK5RH.js → chunk-PFQRZ4IB.js} +9 -6
- package/dist/{chunk-H4DCWLTR.js → chunk-PYTRZZ4V.js} +8 -8
- package/dist/{chunk-XRDSML3K.js → chunk-QHJZSYKY.js} +2 -2
- package/dist/{chunk-E53C73ML.js → chunk-QKHZF2LH.js} +4 -4
- package/dist/{chunk-YSLIB7ER.js → chunk-QPZL2IYT.js} +82 -6
- package/dist/{chunk-RFE7DCZK.js → chunk-R5BGW4WR.js} +2 -2
- package/dist/{chunk-ENWIHU54.js → chunk-R5OHONYU.js} +6 -6
- package/dist/{chunk-WWXJUURQ.js → chunk-RKA22BQP.js} +1 -1
- package/dist/{chunk-P2P6MUQ4.js → chunk-RQO67SAO.js} +2 -2
- package/dist/{chunk-OEQOAONV.js → chunk-RZ3PBNDV.js} +6 -6
- package/dist/{chunk-G35QGPO2.js → chunk-VYDIA2UL.js} +1 -1
- package/dist/{chunk-S7GX44BU.js → chunk-X3PBQ4BK.js} +1 -1
- package/dist/cli/chat.js +33 -33
- 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/event-tasks.d.ts +21 -0
- package/dist/db/schema.d.ts +19 -0
- package/dist/{db-3IEVINAY.js → db-FVCSDROR.js} +6 -6
- package/dist/instrumentation.js +3 -3
- package/dist/nitro.js +6 -6
- package/dist/{oauth-callback-server-N7L2BB4L.js → oauth-callback-server-Z5PXTDOE.js} +29 -29
- package/dist/{runner-PTTZV3WU.js → runner-RHYU7OGV.js} +21 -21
- package/dist/{skills-POMWS2RR.js → skills-QTN73DN5.js} +5 -5
- package/dist/spawn-R56OWLUH.js +42 -0
- package/dist/task-runner-LLJZTLRP.js +36 -0
- package/dist/{validation-U6LOMXR7.js → validation-2ZK7GA6N.js} +5 -5
- package/dist/version.js +1 -1
- package/dist/{work-FHA3BS4L.js → work-7IBKSZRU.js} +21 -21
- package/dist/{worker-GR4UNVVP.js → worker-RNVQVCO7.js} +10 -10
- package/migrations/0038_event_task_status.sql +5 -0
- package/migrations/meta/0038_snapshot.json +3323 -0
- package/migrations/meta/_journal.json +8 -1
- package/package.json +5 -5
- package/dist/spawn-R75MXXKE.js +0 -42
- package/dist/task-runner-OQLRHADB.js +0 -36
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
agentTurnCostUsd,
|
|
3
3
|
agentTurnTotalTokens
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-R5BGW4WR.js";
|
|
5
5
|
import {
|
|
6
6
|
getDb
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-KQ3GZGBK.js";
|
|
8
8
|
import {
|
|
9
9
|
juniorConversations,
|
|
10
10
|
juniorTaskExecutions
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-FPQPYJEG.js";
|
|
12
12
|
import {
|
|
13
13
|
logWarn
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-HUQOXMDG.js";
|
|
15
15
|
|
|
16
16
|
// src/chat/tasks/execution-stats.ts
|
|
17
17
|
import {
|
|
@@ -258,7 +258,7 @@ async function readTaskExecutionDays(dayCount = 90, options = {}) {
|
|
|
258
258
|
}
|
|
259
259
|
return [...byDate.values()];
|
|
260
260
|
}
|
|
261
|
-
async function readTaskExecutionHours(hourCount = 24, options = {}) {
|
|
261
|
+
async function readTaskExecutionHours(hourCount = 7 * 24, options = {}) {
|
|
262
262
|
const nowMs = options.nowMs ?? Date.now();
|
|
263
263
|
const end = new Date(nowMs);
|
|
264
264
|
end.setUTCMinutes(0, 0, 0);
|
|
@@ -349,14 +349,25 @@ async function readTaskExecutions(args) {
|
|
|
349
349
|
return rows.map((row) => mapTaskExecutionRecord(row));
|
|
350
350
|
}
|
|
351
351
|
async function readTaskRuns(args) {
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
352
|
+
const tasks = args.tasks ?? [];
|
|
353
|
+
const conversationIds = [
|
|
354
|
+
...new Set(
|
|
355
|
+
(args.conversationIds ?? []).filter(
|
|
356
|
+
(conversationId) => conversationId.trim().length > 0
|
|
357
|
+
)
|
|
358
358
|
)
|
|
359
|
-
|
|
359
|
+
];
|
|
360
|
+
if (tasks.length === 0 && conversationIds.length === 0) return [];
|
|
361
|
+
const namespace = args.namespace ?? "junior";
|
|
362
|
+
const selectors = [
|
|
363
|
+
...tasks.map(
|
|
364
|
+
(task) => and(
|
|
365
|
+
eq(juniorTaskExecutions.kind, task.kind),
|
|
366
|
+
eq(juniorTaskExecutions.taskId, task.taskId)
|
|
367
|
+
)
|
|
368
|
+
),
|
|
369
|
+
...conversationIds.length > 0 ? [inArray(juniorTaskExecutions.conversationId, conversationIds)] : []
|
|
370
|
+
];
|
|
360
371
|
const rows = await getDb().select({
|
|
361
372
|
conversationId: juniorTaskExecutions.conversationId,
|
|
362
373
|
durationMs: juniorConversations.durationMs,
|
|
@@ -441,7 +452,7 @@ async function readTaskExecutionStatusDays(args) {
|
|
|
441
452
|
return [...byDate.values()];
|
|
442
453
|
}
|
|
443
454
|
async function readTaskExecutionStatusHours(args) {
|
|
444
|
-
const hourCount = args.hourCount ?? 24;
|
|
455
|
+
const hourCount = args.hourCount ?? 7 * 24;
|
|
445
456
|
const namespace = args.namespace ?? "junior";
|
|
446
457
|
const nowMs = args.nowMs ?? Date.now();
|
|
447
458
|
const end = new Date(nowMs);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runWithTurnRequestDeadline
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-I4RH3KLJ.js";
|
|
4
4
|
import {
|
|
5
5
|
QUEUE_SIGNATURE_MAX_AGE_MS,
|
|
6
6
|
createVercelQueueClient,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-7H2VZTWN.js";
|
|
10
10
|
import {
|
|
11
11
|
logWarn
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-HUQOXMDG.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-LLJZTLRP.js");
|
|
133
133
|
await processPluginTask(message);
|
|
134
134
|
},
|
|
135
135
|
topic: PLUGIN_TASK_QUEUE_TOPIC,
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
AgentRunError,
|
|
6
6
|
executeTurn
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-CE2P6TOV.js";
|
|
8
8
|
import {
|
|
9
9
|
buildDeliveredTurnStatePatch,
|
|
10
10
|
finalizeFailedTurnReplyWithEvent,
|
|
@@ -15,14 +15,14 @@ import {
|
|
|
15
15
|
getTurnUserSlackMessageTs,
|
|
16
16
|
persistAuthPauseTurnState,
|
|
17
17
|
requireTurnFailureEventId
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-KUQRWV53.js";
|
|
19
19
|
import {
|
|
20
20
|
resolveTurnSessionRouting,
|
|
21
21
|
scheduleSessionCompletedPluginTasks
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-BJZML4RT.js";
|
|
23
23
|
import {
|
|
24
24
|
getTurnLifecycle
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-7PQMTME5.js";
|
|
26
26
|
import {
|
|
27
27
|
coerceThreadConversationState,
|
|
28
28
|
configValueSchema,
|
|
@@ -30,11 +30,11 @@ import {
|
|
|
30
30
|
getPersistedSandboxState,
|
|
31
31
|
getPersistedThreadState,
|
|
32
32
|
persistThreadStateById
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-FE3Y4KES.js";
|
|
34
34
|
import {
|
|
35
35
|
buildSentryConversationUrl,
|
|
36
36
|
deleteWebAuthorization
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-5HNXLP4W.js";
|
|
38
38
|
import {
|
|
39
39
|
createUserTokenStore,
|
|
40
40
|
deleteMcpAuthSession,
|
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
lookupSlackUserProfile,
|
|
46
46
|
putMcpStoredOAuthCredentials,
|
|
47
47
|
resolvePluginOAuthAccount
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-OQHO62VA.js";
|
|
49
49
|
import {
|
|
50
50
|
RetryableDeliveryError,
|
|
51
51
|
addReactionToMessage,
|
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
removeReactionFromMessage,
|
|
60
60
|
resolveBaseUrl,
|
|
61
61
|
truncateStatusText
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-R5OHONYU.js";
|
|
63
63
|
import {
|
|
64
64
|
CooperativeTurnYieldError,
|
|
65
65
|
clearPendingAuth,
|
|
@@ -68,7 +68,7 @@ import {
|
|
|
68
68
|
isCooperativeTurnYieldError,
|
|
69
69
|
isPendingAuthLatestRequest,
|
|
70
70
|
markTurnFailed
|
|
71
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-VYDIA2UL.js";
|
|
72
72
|
import {
|
|
73
73
|
abandonTurnRecord,
|
|
74
74
|
buildConversationContext,
|
|
@@ -87,20 +87,20 @@ import {
|
|
|
87
87
|
recordTurnSummary,
|
|
88
88
|
saveTurnCheckpoint,
|
|
89
89
|
turnHasReply
|
|
90
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-RZ3PBNDV.js";
|
|
91
91
|
import {
|
|
92
92
|
parseSlackThreadId,
|
|
93
93
|
readSlackRawMessageContext,
|
|
94
94
|
resolveSlackChannelIdFromMessage,
|
|
95
95
|
resolveSlackChannelIdFromThreadId
|
|
96
|
-
} from "./chunk-
|
|
96
|
+
} from "./chunk-6TRQLG3D.js";
|
|
97
97
|
import {
|
|
98
98
|
ensureConversationWake,
|
|
99
99
|
requestConversationWork
|
|
100
|
-
} from "./chunk-
|
|
100
|
+
} from "./chunk-QKHZF2LH.js";
|
|
101
101
|
import {
|
|
102
102
|
getTurnRequestDeadline
|
|
103
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-I4RH3KLJ.js";
|
|
104
104
|
import {
|
|
105
105
|
getVercelConversationWorkQueue
|
|
106
106
|
} from "./chunk-DKIJ2RP5.js";
|
|
@@ -112,39 +112,39 @@ import {
|
|
|
112
112
|
getSlackClient,
|
|
113
113
|
isDmChannel,
|
|
114
114
|
normalizeSlackConversationId
|
|
115
|
-
} from "./chunk-
|
|
115
|
+
} from "./chunk-PFQRZ4IB.js";
|
|
116
116
|
import {
|
|
117
117
|
getConversationStore,
|
|
118
118
|
getSqlExecutor,
|
|
119
119
|
requireSlackDestination,
|
|
120
120
|
upsertIdentity,
|
|
121
121
|
upsertLinkedIdentity
|
|
122
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-KQ3GZGBK.js";
|
|
123
123
|
import {
|
|
124
124
|
acquireActiveLock,
|
|
125
125
|
getStateAdapter
|
|
126
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-7MYXH5LA.js";
|
|
127
127
|
import {
|
|
128
128
|
botConfig,
|
|
129
129
|
escapeXml,
|
|
130
130
|
getChatConfig,
|
|
131
131
|
getRuntimeMetadata,
|
|
132
132
|
normalizeSlackEmojiName
|
|
133
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-LMYRF6HX.js";
|
|
134
134
|
import {
|
|
135
135
|
defaultModelId
|
|
136
136
|
} from "./chunk-D4YV5TDV.js";
|
|
137
137
|
import {
|
|
138
138
|
discoverSkills
|
|
139
|
-
} from "./chunk-
|
|
139
|
+
} from "./chunk-RQO67SAO.js";
|
|
140
140
|
import {
|
|
141
141
|
pluginCatalogRuntime
|
|
142
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-RKA22BQP.js";
|
|
143
143
|
import {
|
|
144
144
|
buildOAuthTokenRequest,
|
|
145
145
|
hasRequiredOAuthScope,
|
|
146
146
|
parseOAuthTokenResponse
|
|
147
|
-
} from "./chunk-
|
|
147
|
+
} from "./chunk-X3PBQ4BK.js";
|
|
148
148
|
import {
|
|
149
149
|
createSlackResumeActor,
|
|
150
150
|
isUserActor,
|
|
@@ -162,7 +162,7 @@ import {
|
|
|
162
162
|
setTags,
|
|
163
163
|
toOptionalString,
|
|
164
164
|
withLogContext
|
|
165
|
-
} from "./chunk-
|
|
165
|
+
} from "./chunk-HUQOXMDG.js";
|
|
166
166
|
|
|
167
167
|
// src/chat/slack/assistant-thread/status-render.ts
|
|
168
168
|
var DEFAULT_STATUS_CONTEXTS = {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
coerceThreadConversationState,
|
|
3
3
|
getPersistedThreadState
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-FE3Y4KES.js";
|
|
5
5
|
import {
|
|
6
6
|
recordTaskExecution
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-5NR7N567.js";
|
|
8
8
|
import {
|
|
9
9
|
pluginTaskId,
|
|
10
10
|
pluginTaskParamsSchema,
|
|
11
11
|
sendVercelPluginTask
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-6GGDBXXP.js";
|
|
13
13
|
import {
|
|
14
14
|
getPiMessageRole,
|
|
15
15
|
getTurnRecord,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
isToolResultMessage,
|
|
20
20
|
normalizeToolNameFromResult,
|
|
21
21
|
stripRuntimeTurnContext
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-RZ3PBNDV.js";
|
|
23
23
|
import {
|
|
24
24
|
createPluginConversationEvents,
|
|
25
25
|
createPluginEmbedder,
|
|
@@ -28,17 +28,17 @@ import {
|
|
|
28
28
|
createPluginState,
|
|
29
29
|
getPlugins,
|
|
30
30
|
readActorIdentity
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-PFQRZ4IB.js";
|
|
32
32
|
import {
|
|
33
33
|
JUNIOR_THREAD_STATE_TTL_MS
|
|
34
34
|
} from "./chunk-3Y47VMHV.js";
|
|
35
35
|
import {
|
|
36
36
|
getConversationStore,
|
|
37
37
|
getDb
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-KQ3GZGBK.js";
|
|
39
39
|
import {
|
|
40
40
|
getStateAdapter
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-7MYXH5LA.js";
|
|
42
42
|
import {
|
|
43
43
|
sameActorIdentity
|
|
44
44
|
} from "./chunk-GFBR4S3Q.js";
|
|
@@ -84,7 +84,7 @@ function slackSourceForDestination(args) {
|
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
async function resolveConversationRouting(args) {
|
|
87
|
-
const conversationStore = args.conversationStore ?? (await import("./db-
|
|
87
|
+
const conversationStore = args.conversationStore ?? (await import("./db-FVCSDROR.js")).getConversationStore();
|
|
88
88
|
const chain = await loadConversationChain(
|
|
89
89
|
args.conversationId,
|
|
90
90
|
conversationStore
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ConversationTurnLifecycleService
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7PQMTME5.js";
|
|
4
4
|
import {
|
|
5
5
|
runAgentWithTimeout
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-R5OHONYU.js";
|
|
7
7
|
import {
|
|
8
8
|
getConversationEventStore
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-KQ3GZGBK.js";
|
|
10
10
|
|
|
11
11
|
// src/chat/runtime/turn-execution.ts
|
|
12
12
|
var AgentRunError = class extends Error {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ToolInputError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-R5BGW4WR.js";
|
|
4
4
|
import {
|
|
5
5
|
getPlugins
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PFQRZ4IB.js";
|
|
7
7
|
import {
|
|
8
8
|
getDb
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-KQ3GZGBK.js";
|
|
10
10
|
import {
|
|
11
11
|
juniorAttachments,
|
|
12
12
|
juniorConversations,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
juniorSchedulerRuns,
|
|
15
15
|
juniorSchedulerTasks,
|
|
16
16
|
juniorStats
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-FPQPYJEG.js";
|
|
18
18
|
import {
|
|
19
19
|
juniorDestinations
|
|
20
20
|
} from "./chunk-VFUK3X5B.js";
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import {
|
|
24
24
|
resourceEventMatches
|
|
25
25
|
} from "@sentry/junior-plugin-api";
|
|
26
|
-
import { and, asc, desc, eq, inArray, or, sql } from "drizzle-orm";
|
|
26
|
+
import { and, asc, desc, eq, inArray, ne, or, sql } from "drizzle-orm";
|
|
27
27
|
|
|
28
28
|
// src/chat/event-tasks/types.ts
|
|
29
29
|
import {
|
|
@@ -61,7 +61,11 @@ var eventTaskSchema = z.object({
|
|
|
61
61
|
|
|
62
62
|
// src/chat/event-tasks/store.ts
|
|
63
63
|
function eventTaskJsonPayload(task) {
|
|
64
|
-
const {
|
|
64
|
+
const {
|
|
65
|
+
status: _status,
|
|
66
|
+
title: _title,
|
|
67
|
+
...payload
|
|
68
|
+
} = task;
|
|
65
69
|
return payload;
|
|
66
70
|
}
|
|
67
71
|
function parseTask(row) {
|
|
@@ -71,10 +75,21 @@ function parseTask(row) {
|
|
|
71
75
|
}
|
|
72
76
|
const payload = eventTaskSchema.parse(raw);
|
|
73
77
|
const title = row.title?.trim();
|
|
74
|
-
return
|
|
78
|
+
return {
|
|
79
|
+
...payload,
|
|
80
|
+
status: row.status === "deleted" ? "deleted" : "active",
|
|
81
|
+
...title ? { title } : void 0
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function activeEventTaskWhere() {
|
|
85
|
+
return ne(juniorEventTasks.status, "deleted");
|
|
75
86
|
}
|
|
76
87
|
async function getEventTask(db, id) {
|
|
77
|
-
const rows = await db.select({
|
|
88
|
+
const rows = await db.select({
|
|
89
|
+
status: juniorEventTasks.status,
|
|
90
|
+
task: juniorEventTasks.task,
|
|
91
|
+
title: juniorEventTasks.title
|
|
92
|
+
}).from(juniorEventTasks).where(eq(juniorEventTasks.id, id)).limit(1);
|
|
78
93
|
return rows[0] ? parseTask(rows[0]) : void 0;
|
|
79
94
|
}
|
|
80
95
|
async function createEventTask(db, task) {
|
|
@@ -86,10 +101,43 @@ async function createEventTask(db, task) {
|
|
|
86
101
|
namespace: parsed.trigger.namespace,
|
|
87
102
|
identifier: parsed.trigger.identifier,
|
|
88
103
|
createdAtMs: parsed.createdAtMs,
|
|
104
|
+
status: "active",
|
|
89
105
|
title,
|
|
90
106
|
task: parsed
|
|
91
107
|
}).onConflictDoNothing();
|
|
92
|
-
|
|
108
|
+
const existing = await getEventTask(db, parsed.id);
|
|
109
|
+
if (!existing) {
|
|
110
|
+
return {
|
|
111
|
+
...parsed,
|
|
112
|
+
status: "active",
|
|
113
|
+
...title ? { title } : void 0
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (existing.status !== "deleted") {
|
|
117
|
+
return existing;
|
|
118
|
+
}
|
|
119
|
+
const rows = await db.update(juniorEventTasks).set({
|
|
120
|
+
teamId: parsed.destination.teamId,
|
|
121
|
+
namespace: parsed.trigger.namespace,
|
|
122
|
+
identifier: parsed.trigger.identifier,
|
|
123
|
+
status: "active",
|
|
124
|
+
title,
|
|
125
|
+
task: parsed
|
|
126
|
+
}).where(
|
|
127
|
+
and(
|
|
128
|
+
eq(juniorEventTasks.id, parsed.id),
|
|
129
|
+
eq(juniorEventTasks.status, "deleted")
|
|
130
|
+
)
|
|
131
|
+
).returning({
|
|
132
|
+
status: juniorEventTasks.status,
|
|
133
|
+
task: juniorEventTasks.task,
|
|
134
|
+
title: juniorEventTasks.title
|
|
135
|
+
});
|
|
136
|
+
return rows[0] ? parseTask(rows[0]) : await getEventTask(db, parsed.id) ?? {
|
|
137
|
+
...parsed,
|
|
138
|
+
status: "active",
|
|
139
|
+
...title ? { title } : void 0
|
|
140
|
+
};
|
|
93
141
|
}
|
|
94
142
|
async function saveEventTask(db, task) {
|
|
95
143
|
const parsed = eventTaskSchema.parse(eventTaskJsonPayload(task));
|
|
@@ -99,15 +147,27 @@ async function saveEventTask(db, task) {
|
|
|
99
147
|
identifier: parsed.trigger.identifier,
|
|
100
148
|
title,
|
|
101
149
|
task: parsed
|
|
102
|
-
}).where(eq(juniorEventTasks.id, parsed.id)).returning({
|
|
150
|
+
}).where(and(eq(juniorEventTasks.id, parsed.id), activeEventTaskWhere())).returning({
|
|
151
|
+
status: juniorEventTasks.status,
|
|
152
|
+
task: juniorEventTasks.task,
|
|
153
|
+
title: juniorEventTasks.title
|
|
154
|
+
});
|
|
103
155
|
return rows[0] ? parseTask(rows[0]) : void 0;
|
|
104
156
|
}
|
|
105
157
|
async function deleteEventTask(db, id) {
|
|
106
|
-
const rows = await db.
|
|
158
|
+
const rows = await db.update(juniorEventTasks).set({ status: "deleted" }).where(and(eq(juniorEventTasks.id, id), activeEventTaskWhere())).returning({
|
|
159
|
+
status: juniorEventTasks.status,
|
|
160
|
+
task: juniorEventTasks.task,
|
|
161
|
+
title: juniorEventTasks.title
|
|
162
|
+
});
|
|
107
163
|
return rows[0] ? parseTask(rows[0]) : void 0;
|
|
108
164
|
}
|
|
109
165
|
async function listEventTasksForTeam(db, teamId) {
|
|
110
|
-
const rows = await db.select({
|
|
166
|
+
const rows = await db.select({
|
|
167
|
+
status: juniorEventTasks.status,
|
|
168
|
+
task: juniorEventTasks.task,
|
|
169
|
+
title: juniorEventTasks.title
|
|
170
|
+
}).from(juniorEventTasks).where(and(eq(juniorEventTasks.teamId, teamId), activeEventTaskWhere())).orderBy(asc(juniorEventTasks.createdAtMs), asc(juniorEventTasks.id));
|
|
111
171
|
return rows.map(parseTask);
|
|
112
172
|
}
|
|
113
173
|
function viewerSlackIdentities(user) {
|
|
@@ -131,12 +191,38 @@ async function listEventTasksCreatedBy(db, user, limit) {
|
|
|
131
191
|
)
|
|
132
192
|
);
|
|
133
193
|
if (!ownership) return [];
|
|
134
|
-
const rows = await db.select({
|
|
194
|
+
const rows = await db.select({
|
|
195
|
+
status: juniorEventTasks.status,
|
|
196
|
+
task: juniorEventTasks.task,
|
|
197
|
+
title: juniorEventTasks.title
|
|
198
|
+
}).from(juniorEventTasks).where(and(ownership, activeEventTaskWhere())).orderBy(desc(juniorEventTasks.createdAtMs), desc(juniorEventTasks.id)).limit(limit);
|
|
199
|
+
return rows.map(parseTask);
|
|
200
|
+
}
|
|
201
|
+
async function listDeletedEventTasksCreatedBy(db, user, limit) {
|
|
202
|
+
const identities = viewerSlackIdentities(user);
|
|
203
|
+
const ownership = or(
|
|
204
|
+
...identities.map(
|
|
205
|
+
(identity) => and(
|
|
206
|
+
eq(juniorEventTasks.teamId, identity.providerTenantId),
|
|
207
|
+
sql`${juniorEventTasks.task}->'createdBy'->>'slackUserId' = ${identity.providerSubjectId}`
|
|
208
|
+
)
|
|
209
|
+
)
|
|
210
|
+
);
|
|
211
|
+
if (!ownership) return [];
|
|
212
|
+
const rows = await db.select({
|
|
213
|
+
status: juniorEventTasks.status,
|
|
214
|
+
task: juniorEventTasks.task,
|
|
215
|
+
title: juniorEventTasks.title
|
|
216
|
+
}).from(juniorEventTasks).where(and(ownership, eq(juniorEventTasks.status, "deleted"))).orderBy(desc(juniorEventTasks.createdAtMs), desc(juniorEventTasks.id)).limit(limit);
|
|
135
217
|
return rows.map(parseTask);
|
|
136
218
|
}
|
|
137
219
|
async function listPublicEventTasksForTeams(db, teamIds, limit) {
|
|
138
220
|
if (teamIds.length === 0) return [];
|
|
139
|
-
const rows = await db.select({
|
|
221
|
+
const rows = await db.select({
|
|
222
|
+
status: juniorEventTasks.status,
|
|
223
|
+
task: juniorEventTasks.task,
|
|
224
|
+
title: juniorEventTasks.title
|
|
225
|
+
}).from(juniorEventTasks).innerJoin(
|
|
140
226
|
juniorDestinations,
|
|
141
227
|
and(
|
|
142
228
|
eq(juniorDestinations.provider, "slack"),
|
|
@@ -146,6 +232,7 @@ async function listPublicEventTasksForTeams(db, teamIds, limit) {
|
|
|
146
232
|
).where(
|
|
147
233
|
and(
|
|
148
234
|
inArray(juniorEventTasks.teamId, teamIds),
|
|
235
|
+
activeEventTaskWhere(),
|
|
149
236
|
eq(juniorDestinations.visibility, "public")
|
|
150
237
|
)
|
|
151
238
|
).orderBy(desc(juniorEventTasks.createdAtMs), desc(juniorEventTasks.id)).limit(limit);
|
|
@@ -159,11 +246,16 @@ async function collectEventTaskMatchKeys(db, input) {
|
|
|
159
246
|
...new Set(input.identifiers.map((value) => value.trim()).filter(Boolean))
|
|
160
247
|
];
|
|
161
248
|
if (eventTypes.size === 0 || identifiers.length === 0) return [];
|
|
162
|
-
const rows = await db.select({
|
|
249
|
+
const rows = await db.select({
|
|
250
|
+
status: juniorEventTasks.status,
|
|
251
|
+
task: juniorEventTasks.task,
|
|
252
|
+
title: juniorEventTasks.title
|
|
253
|
+
}).from(juniorEventTasks).where(
|
|
163
254
|
and(
|
|
164
255
|
eq(juniorEventTasks.teamId, input.teamId),
|
|
165
256
|
eq(juniorEventTasks.namespace, input.namespace),
|
|
166
|
-
inArray(juniorEventTasks.identifier, identifiers)
|
|
257
|
+
inArray(juniorEventTasks.identifier, identifiers),
|
|
258
|
+
activeEventTaskWhere()
|
|
167
259
|
)
|
|
168
260
|
).orderBy(asc(juniorEventTasks.createdAtMs), asc(juniorEventTasks.id));
|
|
169
261
|
const keys = /* @__PURE__ */ new Set();
|
|
@@ -179,11 +271,16 @@ async function collectEventTaskMatchKeys(db, input) {
|
|
|
179
271
|
return [...keys].sort();
|
|
180
272
|
}
|
|
181
273
|
async function findMatchingEventTasks(db, event, teamId) {
|
|
182
|
-
const rows = await db.select({
|
|
274
|
+
const rows = await db.select({
|
|
275
|
+
status: juniorEventTasks.status,
|
|
276
|
+
task: juniorEventTasks.task,
|
|
277
|
+
title: juniorEventTasks.title
|
|
278
|
+
}).from(juniorEventTasks).where(
|
|
183
279
|
and(
|
|
184
280
|
eq(juniorEventTasks.teamId, teamId),
|
|
185
281
|
eq(juniorEventTasks.namespace, event.namespace),
|
|
186
|
-
eq(juniorEventTasks.identifier, event.identifier)
|
|
282
|
+
eq(juniorEventTasks.identifier, event.identifier),
|
|
283
|
+
activeEventTaskWhere()
|
|
187
284
|
)
|
|
188
285
|
).orderBy(asc(juniorEventTasks.createdAtMs), asc(juniorEventTasks.id));
|
|
189
286
|
return rows.map(parseTask).filter(
|
|
@@ -569,7 +666,7 @@ function eventTaskIsWritableFrom(task, destination) {
|
|
|
569
666
|
async function writableEventTask(context, id) {
|
|
570
667
|
const { destination } = requireEventTaskSlackContext(context);
|
|
571
668
|
const task = await getEventTask(getDb(), id);
|
|
572
|
-
if (!task || !eventTaskIsWritableFrom(task, destination)) {
|
|
669
|
+
if (!task || task.status === "deleted" || !eventTaskIsWritableFrom(task, destination)) {
|
|
573
670
|
throw new ToolInputError("Event task was not found.");
|
|
574
671
|
}
|
|
575
672
|
return task;
|
|
@@ -845,8 +942,39 @@ async function writeScheduledTask(db, task, current) {
|
|
|
845
942
|
)
|
|
846
943
|
);
|
|
847
944
|
}
|
|
945
|
+
if (task.status === "deleted" && current?.status !== "deleted") {
|
|
946
|
+
await skipPendingRunsForDeletedTask(db, task);
|
|
947
|
+
}
|
|
848
948
|
await upsertScheduledTask(db, task);
|
|
849
949
|
}
|
|
950
|
+
async function skipPendingRunsForDeletedTask(db, task) {
|
|
951
|
+
const errorMessage = `Scheduled task ${task.id} was deleted before the run started.`;
|
|
952
|
+
const rows = await db.select({ record: juniorSchedulerRuns.record }).from(juniorSchedulerRuns).where(
|
|
953
|
+
and3(
|
|
954
|
+
eq2(juniorSchedulerRuns.taskId, task.id),
|
|
955
|
+
eq2(juniorSchedulerRuns.status, "pending")
|
|
956
|
+
)
|
|
957
|
+
);
|
|
958
|
+
for (const row of rows) {
|
|
959
|
+
const parsed = scheduledRunSchema.safeParse(row.record);
|
|
960
|
+
if (!parsed.success || parsed.data.status !== "pending") continue;
|
|
961
|
+
const next = scheduledRunSchema.parse({
|
|
962
|
+
...parsed.data,
|
|
963
|
+
completedAtMs: task.updatedAtMs,
|
|
964
|
+
errorMessage,
|
|
965
|
+
status: "skipped"
|
|
966
|
+
});
|
|
967
|
+
await db.update(juniorSchedulerRuns).set({
|
|
968
|
+
record: next,
|
|
969
|
+
status: next.status
|
|
970
|
+
}).where(
|
|
971
|
+
and3(
|
|
972
|
+
eq2(juniorSchedulerRuns.id, next.id),
|
|
973
|
+
eq2(juniorSchedulerRuns.status, "pending")
|
|
974
|
+
)
|
|
975
|
+
);
|
|
976
|
+
}
|
|
977
|
+
}
|
|
850
978
|
async function createScheduledTask(db, task) {
|
|
851
979
|
const next = requireStoredTask(task);
|
|
852
980
|
return await withScheduledTaskLock(db, task.id, async (tx) => {
|
|
@@ -1263,6 +1391,7 @@ export {
|
|
|
1263
1391
|
listEventTasksForTeam,
|
|
1264
1392
|
eventTaskBelongsToUser,
|
|
1265
1393
|
listEventTasksCreatedBy,
|
|
1394
|
+
listDeletedEventTasksCreatedBy,
|
|
1266
1395
|
listPublicEventTasksForTeams,
|
|
1267
1396
|
collectEventTaskMatchKeys,
|
|
1268
1397
|
findMatchingEventTasks,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
persistConversationMessages
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RZ3PBNDV.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-
|
|
9
|
+
} from "./chunk-KQ3GZGBK.js";
|
|
10
10
|
import {
|
|
11
11
|
juniorLocationConfigurations
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-FPQPYJEG.js";
|
|
13
13
|
import {
|
|
14
14
|
getStateAdapter
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-7MYXH5LA.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-
|
|
23
|
+
} from "./chunk-HUQOXMDG.js";
|
|
24
24
|
|
|
25
25
|
// src/chat/state/conversation.ts
|
|
26
26
|
function defaultConversationState() {
|