@sentry/junior 0.193.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-DWY3MZZ7.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/conversations/aggregate.d.ts +2 -0
- package/dist/api/conversations/list.d.ts +1 -1
- package/dist/api/conversations/projection.d.ts +1 -1
- package/dist/api/locations/detail.d.ts +9 -1
- 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 +28 -3
- package/dist/api/schema/location.d.ts +14 -1
- package/dist/api/schema/person.d.ts +15 -1
- package/dist/api/schema/task.d.ts +83 -8
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +3 -1
- package/dist/api.js +320 -222
- package/dist/app.js +108 -39
- package/dist/{catalog-runtime-NAD44W5K.js → catalog-runtime-6E6SGRZK.js} +4 -4
- package/dist/chat/agent/resume.d.ts +2 -0
- package/dist/chat/config.d.ts +2 -0
- package/dist/chat/conversations/history.d.ts +4 -2
- 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/services/turn-limit.d.ts +11 -1
- package/dist/chat/slack/automated-turn-limit-notice.d.ts +38 -0
- package/dist/chat/slack/{source-link.d.ts → location-url.d.ts} +1 -1
- package/dist/chat/task-execution/checkpoint.d.ts +2 -0
- package/dist/chat/task-execution/turn-cursor.d.ts +3 -0
- package/dist/chat/tasks/execution-stats.d.ts +15 -2
- package/dist/chat/tasks/read.d.ts +5 -2
- package/dist/chat/usage.d.ts +4 -0
- package/dist/{chunk-GUKGU6R7.js → chunk-3VWIZVK7.js} +1 -1
- package/dist/{chunk-THYNA2QN.js → chunk-5HNXLP4W.js} +1 -1
- package/dist/{chunk-GUMBIDDL.js → chunk-5NR7N567.js} +194 -43
- package/dist/{chunk-N6Q2PNSI.js → chunk-6GGDBXXP.js} +3 -3
- package/dist/{chunk-HMBTX5RK.js → chunk-6TRQLG3D.js} +1 -1
- package/dist/{chunk-IOUUS6H4.js → chunk-7MYXH5LA.js} +1 -1
- package/dist/{chunk-WH5VV2RW.js → chunk-7PQMTME5.js} +1 -1
- package/dist/{chunk-5E5SLAVD.js → chunk-7UED4D5T.js} +23 -25
- package/dist/{chunk-4UA5C7AM.js → chunk-BJZML4RT.js} +8 -8
- package/dist/{chunk-QDU5MW2R.js → chunk-C4NY6L7S.js} +1 -1
- package/dist/{chunk-DVU734PI.js → chunk-CE2P6TOV.js} +3 -3
- package/dist/{chunk-BFP3ZKG6.js → chunk-DTYOEHUP.js} +148 -19
- package/dist/{chunk-S5HS6WRH.js → chunk-FE3Y4KES.js} +5 -5
- package/dist/{chunk-PYBFVK6K.js → chunk-FEZIEEOP.js} +985 -569
- package/dist/{chunk-5S6AQFNG.js → chunk-FPQPYJEG.js} +23 -29
- package/dist/{chunk-42N6CDWF.js → chunk-HE5PZAPS.js} +4 -4
- package/dist/{chunk-QY2IU47O.js → chunk-HUQOXMDG.js} +1 -1
- package/dist/{chunk-IQCL5JGL.js → chunk-I4RH3KLJ.js} +1 -1
- package/dist/{chunk-LXRTHE43.js → chunk-JBSCMOLR.js} +5 -5
- package/dist/{chunk-OICYQPKP.js → chunk-KBPWC7NU.js} +1 -1
- package/dist/{chunk-2CYWEVOP.js → chunk-KQ3GZGBK.js} +88 -68
- package/dist/{chunk-GTXQHZ2O.js → chunk-KUQRWV53.js} +5 -5
- package/dist/{chunk-IBXXTO3J.js → chunk-L62JVQPL.js} +3 -3
- package/dist/{chunk-KWXZMHJS.js → chunk-LM7UE523.js} +3 -3
- package/dist/{chunk-WJJDQLVL.js → chunk-LMYRF6HX.js} +6 -2
- package/dist/{chunk-AZVDODSP.js → chunk-N67T4VY3.js} +9 -9
- package/dist/{chunk-D4XQZOHB.js → chunk-OQHO62VA.js} +8 -8
- package/dist/{chunk-FQ5HFSFR.js → chunk-PFQRZ4IB.js} +9 -6
- package/dist/{chunk-LG7Q4OW4.js → chunk-PYTRZZ4V.js} +8 -8
- package/dist/{chunk-THFNL3TL.js → chunk-QHJZSYKY.js} +2 -2
- package/dist/{chunk-5LEVZYXF.js → chunk-QKHZF2LH.js} +4 -4
- package/dist/{chunk-EYIMZY5O.js → chunk-QPZL2IYT.js} +100 -9
- package/dist/{chunk-D5YQPCEG.js → chunk-R5BGW4WR.js} +24 -2
- package/dist/{chunk-COCVPDWX.js → chunk-R5OHONYU.js} +6 -6
- package/dist/{chunk-DXFUYLHX.js → chunk-RKA22BQP.js} +1 -1
- package/dist/{chunk-3YZ2Q6AW.js → chunk-RQO67SAO.js} +2 -2
- package/dist/{chunk-ZFPEPWOO.js → chunk-RZ3PBNDV.js} +60 -29
- package/dist/{chunk-K47OVEO4.js → chunk-VYDIA2UL.js} +1 -1
- package/dist/{chunk-QWY4KI2V.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-H5MDRQEY.js → db-FVCSDROR.js} +6 -6
- package/dist/instrumentation.js +3 -3
- package/dist/nitro.js +6 -6
- package/dist/{oauth-callback-server-IOU3NUHT.js → oauth-callback-server-Z5PXTDOE.js} +29 -29
- package/dist/{runner-FZ5ZHLFG.js → runner-RHYU7OGV.js} +21 -21
- package/dist/{skills-AR3WD6BX.js → skills-QTN73DN5.js} +5 -5
- package/dist/spawn-R56OWLUH.js +42 -0
- package/dist/task-runner-LLJZTLRP.js +36 -0
- package/dist/{validation-VYE7TQY7.js → validation-2ZK7GA6N.js} +5 -5
- package/dist/version.js +1 -1
- package/dist/{work-CTQFWYKE.js → work-7IBKSZRU.js} +21 -21
- package/dist/{worker-6WQU3IT5.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 +4 -4
- package/dist/spawn-ZU6JABR7.js +0 -42
- package/dist/task-runner-EEGGG2PM.js +0 -36
|
@@ -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,12 +68,11 @@ import {
|
|
|
68
68
|
isCooperativeTurnYieldError,
|
|
69
69
|
isPendingAuthLatestRequest,
|
|
70
70
|
markTurnFailed
|
|
71
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-VYDIA2UL.js";
|
|
72
72
|
import {
|
|
73
|
-
TurnSliceLimitExceededError,
|
|
74
73
|
abandonTurnRecord,
|
|
75
74
|
buildConversationContext,
|
|
76
|
-
|
|
75
|
+
buildTurnErrorResponse,
|
|
77
76
|
commitAcceptedReply,
|
|
78
77
|
failTurnRecord,
|
|
79
78
|
getTurnRecord,
|
|
@@ -88,20 +87,20 @@ import {
|
|
|
88
87
|
recordTurnSummary,
|
|
89
88
|
saveTurnCheckpoint,
|
|
90
89
|
turnHasReply
|
|
91
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-RZ3PBNDV.js";
|
|
92
91
|
import {
|
|
93
92
|
parseSlackThreadId,
|
|
94
93
|
readSlackRawMessageContext,
|
|
95
94
|
resolveSlackChannelIdFromMessage,
|
|
96
95
|
resolveSlackChannelIdFromThreadId
|
|
97
|
-
} from "./chunk-
|
|
96
|
+
} from "./chunk-6TRQLG3D.js";
|
|
98
97
|
import {
|
|
99
98
|
ensureConversationWake,
|
|
100
99
|
requestConversationWork
|
|
101
|
-
} from "./chunk-
|
|
100
|
+
} from "./chunk-QKHZF2LH.js";
|
|
102
101
|
import {
|
|
103
102
|
getTurnRequestDeadline
|
|
104
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-I4RH3KLJ.js";
|
|
105
104
|
import {
|
|
106
105
|
getVercelConversationWorkQueue
|
|
107
106
|
} from "./chunk-DKIJ2RP5.js";
|
|
@@ -113,39 +112,39 @@ import {
|
|
|
113
112
|
getSlackClient,
|
|
114
113
|
isDmChannel,
|
|
115
114
|
normalizeSlackConversationId
|
|
116
|
-
} from "./chunk-
|
|
115
|
+
} from "./chunk-PFQRZ4IB.js";
|
|
117
116
|
import {
|
|
118
117
|
getConversationStore,
|
|
119
118
|
getSqlExecutor,
|
|
120
119
|
requireSlackDestination,
|
|
121
120
|
upsertIdentity,
|
|
122
121
|
upsertLinkedIdentity
|
|
123
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-KQ3GZGBK.js";
|
|
124
123
|
import {
|
|
125
124
|
acquireActiveLock,
|
|
126
125
|
getStateAdapter
|
|
127
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-7MYXH5LA.js";
|
|
128
127
|
import {
|
|
129
128
|
botConfig,
|
|
130
129
|
escapeXml,
|
|
131
130
|
getChatConfig,
|
|
132
131
|
getRuntimeMetadata,
|
|
133
132
|
normalizeSlackEmojiName
|
|
134
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-LMYRF6HX.js";
|
|
135
134
|
import {
|
|
136
135
|
defaultModelId
|
|
137
136
|
} from "./chunk-D4YV5TDV.js";
|
|
138
137
|
import {
|
|
139
138
|
discoverSkills
|
|
140
|
-
} from "./chunk-
|
|
139
|
+
} from "./chunk-RQO67SAO.js";
|
|
141
140
|
import {
|
|
142
141
|
pluginCatalogRuntime
|
|
143
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-RKA22BQP.js";
|
|
144
143
|
import {
|
|
145
144
|
buildOAuthTokenRequest,
|
|
146
145
|
hasRequiredOAuthScope,
|
|
147
146
|
parseOAuthTokenResponse
|
|
148
|
-
} from "./chunk-
|
|
147
|
+
} from "./chunk-X3PBQ4BK.js";
|
|
149
148
|
import {
|
|
150
149
|
createSlackResumeActor,
|
|
151
150
|
isUserActor,
|
|
@@ -156,7 +155,6 @@ import {
|
|
|
156
155
|
homeDir
|
|
157
156
|
} from "./chunk-TXKUKMVO.js";
|
|
158
157
|
import {
|
|
159
|
-
buildTurnFailureResponse,
|
|
160
158
|
logException,
|
|
161
159
|
logInfo,
|
|
162
160
|
logWarn,
|
|
@@ -164,7 +162,7 @@ import {
|
|
|
164
162
|
setTags,
|
|
165
163
|
toOptionalString,
|
|
166
164
|
withLogContext
|
|
167
|
-
} from "./chunk-
|
|
165
|
+
} from "./chunk-HUQOXMDG.js";
|
|
168
166
|
|
|
169
167
|
// src/chat/slack/assistant-thread/status-render.ts
|
|
170
168
|
var DEFAULT_STATUS_CONTEXTS = {
|
|
@@ -1171,7 +1169,7 @@ async function postResumeFailureReply(args) {
|
|
|
1171
1169
|
await postSlackMessage({
|
|
1172
1170
|
channelId: args.channelId,
|
|
1173
1171
|
threadTs: args.threadTs,
|
|
1174
|
-
text: args.error
|
|
1172
|
+
text: buildTurnErrorResponse(args.error, args.eventId)
|
|
1175
1173
|
});
|
|
1176
1174
|
}
|
|
1177
1175
|
async function handleResumeFailure(args) {
|
|
@@ -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() {
|