@sentry/junior 0.138.0 → 0.139.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 (71) hide show
  1. package/dist/{agent-hooks-SCR74Q3E.js → agent-hooks-MJXMD7JP.js} +10 -10
  2. package/dist/api/schema/task.d.ts +100 -1
  3. package/dist/api/schema.d.ts +2 -2
  4. package/dist/api/schema.js +9 -1
  5. package/dist/api.js +198 -54
  6. package/dist/app.js +288 -602
  7. package/dist/{catalog-runtime-IU3QF4GG.js → catalog-runtime-GCCFYPIK.js} +6 -6
  8. package/dist/chat/agent/request.d.ts +12 -2
  9. package/dist/chat/credentials/context.d.ts +14 -0
  10. package/dist/chat/resource-events/actor.d.ts +23 -0
  11. package/dist/chat/state/turn-session.d.ts +1 -3
  12. package/dist/chat/tasks/execution-stats.d.ts +34 -3
  13. package/dist/chat/tasks/read.d.ts +3 -1
  14. package/dist/{chunk-JNNJZURV.js → chunk-2ECYPYKP.js} +1 -1
  15. package/dist/chunk-3T2JAGRH.js +115 -0
  16. package/dist/{chunk-PB3CXNVL.js → chunk-4V4QIYJH.js} +1 -1
  17. package/dist/{chunk-FEUNPTGV.js → chunk-5GSZWRE2.js} +434 -12
  18. package/dist/{chunk-QS527AV5.js → chunk-6OHTDR4F.js} +1 -1
  19. package/dist/{chunk-TCS76X5D.js → chunk-6SU2DT27.js} +2 -2
  20. package/dist/{chunk-BYW4B4PR.js → chunk-75I3UBIL.js} +2 -2
  21. package/dist/{chunk-ZBSMCXKV.js → chunk-AEQISMMU.js} +7 -6
  22. package/dist/{chunk-KDCHVT25.js → chunk-C2N6MNO4.js} +9 -2
  23. package/dist/{chunk-KFRHRSCJ.js → chunk-CXH25EL4.js} +2 -2
  24. package/dist/{chunk-TDJCLNDH.js → chunk-DW4PMHNW.js} +3 -3
  25. package/dist/{chunk-A7WCHXZV.js → chunk-G52UXKGO.js} +4 -4
  26. package/dist/chunk-GI52BW74.js +207 -0
  27. package/dist/{chunk-ZXNTJJIE.js → chunk-GWQSZT4C.js} +2 -2
  28. package/dist/{chunk-EPBBYMNE.js → chunk-HUO3UTAQ.js} +1 -1
  29. package/dist/{chunk-5MXWHTCK.js → chunk-IIESAYDL.js} +6 -6
  30. package/dist/{chunk-YU5QUF67.js → chunk-J3S57AXY.js} +1 -1
  31. package/dist/{chunk-E5UYAIKJ.js → chunk-J6EJQCHY.js} +17 -19
  32. package/dist/{chunk-5LTJ4ITU.js → chunk-MQ5RYATN.js} +4 -4
  33. package/dist/{chunk-BOLJOV5T.js → chunk-MXTVUV3I.js} +1 -1
  34. package/dist/{chunk-FNLBTB4K.js → chunk-MXVD2BDS.js} +1 -1
  35. package/dist/{chunk-TUUDXEXU.js → chunk-PJW6U46K.js} +12 -15
  36. package/dist/{chunk-SIPKWSXK.js → chunk-QTBKPZDA.js} +3 -3
  37. package/dist/{chunk-77VDLF3Z.js → chunk-RUIXF3YQ.js} +10 -0
  38. package/dist/{chunk-SD3OFRWY.js → chunk-U27DSXKB.js} +6 -6
  39. package/dist/{chunk-C7ZVPO4Z.js → chunk-U7CMWQ7Z.js} +1 -1
  40. package/dist/{chunk-DCLLQGS6.js → chunk-UDBUS533.js} +8 -3
  41. package/dist/{chunk-HIWJWWMT.js → chunk-WQRX57EA.js} +3 -3
  42. package/dist/{chunk-LPVUNO2W.js → chunk-WZH4JV7R.js} +7 -7
  43. package/dist/{chunk-HCIVH3JS.js → chunk-YCTDA7BD.js} +28 -0
  44. package/dist/{chunk-VPZFVJND.js → chunk-YGZ2OLXL.js} +1 -1
  45. package/dist/{chunk-N7WARMC6.js → chunk-ZQCGQMF2.js} +7 -7
  46. package/dist/{chunk-RZIBSCYC.js → chunk-ZYQSPQYR.js} +25 -22
  47. package/dist/cli/chat.js +33 -33
  48. package/dist/cli/check.js +7 -7
  49. package/dist/cli/plugins.js +14 -14
  50. package/dist/cli/snapshot-create.js +10 -10
  51. package/dist/cli/upgrade.js +8 -8
  52. package/dist/db/schema/task-executions.d.ts +23 -2
  53. package/dist/db/schema.d.ts +20 -1
  54. package/dist/{db-UO2IWXGA.js → db-UXPPGHDF.js} +7 -7
  55. package/dist/instrumentation.js +4 -4
  56. package/dist/nitro.js +2 -2
  57. package/dist/{oauth-callback-server-MAQI43LX.js → oauth-callback-server-4ZYMD5UA.js} +22 -21
  58. package/dist/{runner-PIUQEXKE.js → runner-MZSEONRZ.js} +18 -16
  59. package/dist/{sandbox-egress-signals-A5HWIQH4.js → sandbox-egress-signals-EKPAVWQL.js} +2 -2
  60. package/dist/{skills-4ARJADHQ.js → skills-IMVPXSQ7.js} +7 -7
  61. package/dist/spawn-S5LSVOCE.js +38 -0
  62. package/dist/{validation-S3EE3HWL.js → validation-ZKCY2BVR.js} +7 -7
  63. package/dist/version.js +1 -1
  64. package/dist/{work-UARRUAW3.js → work-GG3XDYRX.js} +18 -18
  65. package/dist/{worker-DOCIRVD3.js → worker-23AUELCJ.js} +10 -10
  66. package/migrations/0022_task_execution_status.sql +3 -0
  67. package/migrations/meta/0022_snapshot.json +2186 -0
  68. package/migrations/meta/_journal.json +7 -0
  69. package/package.json +5 -5
  70. package/dist/chunk-ELKW5FIB.js +0 -233
  71. package/dist/spawn-G2AWPMCT.js +0 -38
@@ -11,21 +11,21 @@ import {
11
11
  getPlugins,
12
12
  setPlugins,
13
13
  validatePlugins
14
- } from "./chunk-5MXWHTCK.js";
15
- import "./chunk-TCS76X5D.js";
16
- import "./chunk-SIPKWSXK.js";
17
- import "./chunk-DCLLQGS6.js";
14
+ } from "./chunk-IIESAYDL.js";
15
+ import "./chunk-6SU2DT27.js";
16
+ import "./chunk-QTBKPZDA.js";
17
+ import "./chunk-UDBUS533.js";
18
18
  import "./chunk-EM225ITJ.js";
19
- import "./chunk-BOLJOV5T.js";
20
- import "./chunk-BYW4B4PR.js";
19
+ import "./chunk-MXTVUV3I.js";
20
+ import "./chunk-75I3UBIL.js";
21
21
  import "./chunk-VFUK3X5B.js";
22
- import "./chunk-VPZFVJND.js";
22
+ import "./chunk-YGZ2OLXL.js";
23
23
  import "./chunk-HZF5P5UN.js";
24
24
  import "./chunk-F3B2YJ76.js";
25
- import "./chunk-JNNJZURV.js";
25
+ import "./chunk-2ECYPYKP.js";
26
26
  import "./chunk-6GWA276C.js";
27
- import "./chunk-KDCHVT25.js";
28
- import "./chunk-C7ZVPO4Z.js";
27
+ import "./chunk-C2N6MNO4.js";
28
+ import "./chunk-U7CMWQ7Z.js";
29
29
  import "./chunk-MLKGABMK.js";
30
30
  export {
31
31
  PluginHookDeniedError,
@@ -106,7 +106,7 @@ export declare const taskSummarySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
106
106
  source: z.ZodString;
107
107
  triggerAvailable: z.ZodBoolean;
108
108
  }, z.core.$strict>], "kind">;
109
- /** One UTC day of successful task executions stacked by task type. */
109
+ /** One UTC day of completed task executions stacked by task type. */
110
110
  export declare const taskExecutionDaySchema: z.ZodObject<{
111
111
  date: z.ZodString;
112
112
  event: z.ZodNumber;
@@ -180,6 +180,105 @@ export declare const taskParamsSchema: z.ZodObject<{
180
180
  scheduled: "scheduled";
181
181
  }>;
182
182
  }, z.core.$strict>;
183
+ export declare const taskExecutionStatusSchema: z.ZodEnum<{
184
+ completed: "completed";
185
+ failed: "failed";
186
+ blocked: "blocked";
187
+ }>;
188
+ export declare const taskExecutionSchema: z.ZodObject<{
189
+ conversationId: z.ZodOptional<z.ZodString>;
190
+ executedAt: z.ZodString;
191
+ executionId: z.ZodString;
192
+ status: z.ZodEnum<{
193
+ completed: "completed";
194
+ failed: "failed";
195
+ blocked: "blocked";
196
+ }>;
197
+ title: z.ZodOptional<z.ZodString>;
198
+ }, z.core.$strict>;
199
+ /** One UTC day of terminal executions for a single task, stacked by status. */
200
+ export declare const taskExecutionStatusDaySchema: z.ZodObject<{
201
+ blocked: z.ZodNumber;
202
+ completed: z.ZodNumber;
203
+ date: z.ZodString;
204
+ failed: z.ZodNumber;
205
+ }, z.core.$strict>;
206
+ export declare const taskExecutionListSchema: z.ZodObject<{
207
+ executionDays: z.ZodArray<z.ZodObject<{
208
+ blocked: z.ZodNumber;
209
+ completed: z.ZodNumber;
210
+ date: z.ZodString;
211
+ failed: z.ZodNumber;
212
+ }, z.core.$strict>>;
213
+ executions: z.ZodArray<z.ZodObject<{
214
+ conversationId: z.ZodOptional<z.ZodString>;
215
+ executedAt: z.ZodString;
216
+ executionId: z.ZodString;
217
+ status: z.ZodEnum<{
218
+ completed: "completed";
219
+ failed: "failed";
220
+ blocked: "blocked";
221
+ }>;
222
+ title: z.ZodOptional<z.ZodString>;
223
+ }, z.core.$strict>>;
224
+ task: z.ZodDiscriminatedUnion<[z.ZodObject<{
225
+ createdAt: z.ZodString;
226
+ createdBy: z.ZodString;
227
+ createdByEmail: z.ZodOptional<z.ZodString>;
228
+ destination: z.ZodObject<{
229
+ channelId: z.ZodString;
230
+ label: z.ZodString;
231
+ teamId: z.ZodString;
232
+ visibility: z.ZodEnum<{
233
+ public: "public";
234
+ private: "private";
235
+ }>;
236
+ }, z.core.$strict>;
237
+ id: z.ZodString;
238
+ instruction: z.ZodString;
239
+ lastConversationId: z.ZodOptional<z.ZodString>;
240
+ lastRunAt: z.ZodOptional<z.ZodString>;
241
+ ownedByViewer: z.ZodBoolean;
242
+ runsLast7Days: z.ZodNumber;
243
+ totalRuns: z.ZodNumber;
244
+ kind: z.ZodLiteral<"scheduled">;
245
+ nextRunAt: z.ZodOptional<z.ZodString>;
246
+ schedule: z.ZodString;
247
+ status: z.ZodEnum<{
248
+ blocked: "blocked";
249
+ active: "active";
250
+ }>;
251
+ }, z.core.$strict>, z.ZodObject<{
252
+ createdAt: z.ZodString;
253
+ createdBy: z.ZodString;
254
+ createdByEmail: z.ZodOptional<z.ZodString>;
255
+ destination: z.ZodObject<{
256
+ channelId: z.ZodString;
257
+ label: z.ZodString;
258
+ teamId: z.ZodString;
259
+ visibility: z.ZodEnum<{
260
+ public: "public";
261
+ private: "private";
262
+ }>;
263
+ }, z.core.$strict>;
264
+ id: z.ZodString;
265
+ instruction: z.ZodString;
266
+ lastConversationId: z.ZodOptional<z.ZodString>;
267
+ lastRunAt: z.ZodOptional<z.ZodString>;
268
+ ownedByViewer: z.ZodBoolean;
269
+ runsLast7Days: z.ZodNumber;
270
+ totalRuns: z.ZodNumber;
271
+ events: z.ZodArray<z.ZodString>;
272
+ kind: z.ZodLiteral<"event">;
273
+ resource: z.ZodString;
274
+ source: z.ZodString;
275
+ triggerAvailable: z.ZodBoolean;
276
+ }, z.core.$strict>], "kind">;
277
+ truncated: z.ZodBoolean;
278
+ }, z.core.$strict>;
183
279
  export type TaskExecutionDay = z.output<typeof taskExecutionDaySchema>;
280
+ export type TaskExecutionStatusDay = z.output<typeof taskExecutionStatusDaySchema>;
281
+ export type TaskExecution = z.output<typeof taskExecutionSchema>;
282
+ export type TaskExecutionList = z.output<typeof taskExecutionListSchema>;
184
283
  export type TaskSummary = z.output<typeof taskSummarySchema>;
185
284
  export type TaskList = z.output<typeof taskListSchema>;
@@ -10,8 +10,8 @@ export { apiErrorSchema } from "./schema/common";
10
10
  export type { ApiError } from "./schema/common";
11
11
  export { createPersonalTokenBodySchema, createdPersonalTokenSchema, personalTokenListSchema, personalTokenMetadataSchema, personalTokenParamsSchema, revokePersonalTokenResponseSchema, } from "./schema/personal-token";
12
12
  export type { PersonalTokenMetadata } from "./schema/personal-token";
13
- export { eventTaskSummarySchema, scheduledTaskSummarySchema, taskListSchema, taskParamsSchema, taskSummarySchema, } from "./schema/task";
14
- export type { TaskExecutionDay, TaskList, TaskSummary } from "./schema/task";
13
+ export { eventTaskSummarySchema, scheduledTaskSummarySchema, taskExecutionListSchema, taskExecutionSchema, taskExecutionStatusDaySchema, taskExecutionStatusSchema, taskListSchema, taskParamsSchema, taskSummarySchema, } from "./schema/task";
14
+ export type { TaskExecution, TaskExecutionDay, TaskExecutionList, TaskExecutionStatusDay, TaskList, TaskSummary, } from "./schema/task";
15
15
  export { statSchema, statsReportSchema } from "./schema/stats";
16
16
  export type { StatReport, StatsReport } from "./schema/stats";
17
17
  export { healthReportSchema, pluginOperationalReportFeedSchema, pluginOperationalReportSchema, pluginPackageContentItemReportSchema, pluginPackageContentReportSchema, pluginSchema, pluginsSchema, runtimeInfoReportSchema, skillReportSchema, skillReportsSchema, } from "../reporting-schema";
@@ -34,10 +34,14 @@ import {
34
34
  scheduledTaskSummarySchema,
35
35
  statSchema,
36
36
  statsReportSchema,
37
+ taskExecutionListSchema,
38
+ taskExecutionSchema,
39
+ taskExecutionStatusDaySchema,
40
+ taskExecutionStatusSchema,
37
41
  taskListSchema,
38
42
  taskParamsSchema,
39
43
  taskSummarySchema
40
- } from "../chunk-HCIVH3JS.js";
44
+ } from "../chunk-YCTDA7BD.js";
41
45
  import {
42
46
  healthReportSchema,
43
47
  pluginOperationalReportFeedSchema,
@@ -99,6 +103,10 @@ export {
99
103
  skillReportsSchema,
100
104
  statSchema,
101
105
  statsReportSchema,
106
+ taskExecutionListSchema,
107
+ taskExecutionSchema,
108
+ taskExecutionStatusDaySchema,
109
+ taskExecutionStatusSchema,
102
110
  taskListSchema,
103
111
  taskParamsSchema,
104
112
  taskSummarySchema
package/dist/api.js CHANGED
@@ -25,19 +25,24 @@ import {
25
25
  personalTokenParamsSchema,
26
26
  revokePersonalTokenResponseSchema,
27
27
  statsReportSchema,
28
+ taskExecutionListSchema,
28
29
  taskListSchema,
29
30
  taskParamsSchema
30
- } from "./chunk-HCIVH3JS.js";
31
+ } from "./chunk-YCTDA7BD.js";
31
32
  import {
32
33
  formatSlackConversationRedactedLabel,
33
34
  readHealthReport,
34
- readTaskExecutionDays,
35
- readTaskExecutionSummaries,
36
35
  resolveSlackConversationContextFromThreadId
37
- } from "./chunk-ELKW5FIB.js";
36
+ } from "./chunk-3T2JAGRH.js";
38
37
  import {
39
38
  buildSentryConversationUrl
40
39
  } from "./chunk-4CODA7P5.js";
40
+ import {
41
+ readTaskExecutionDays,
42
+ readTaskExecutionStatusDays,
43
+ readTaskExecutionSummaries,
44
+ readTaskExecutions
45
+ } from "./chunk-GI52BW74.js";
41
46
  import {
42
47
  healthReportSchema,
43
48
  pluginOperationalReportFeedSchema,
@@ -56,10 +61,10 @@ import {
56
61
  listPublicEventTasksForTeams,
57
62
  listPublicScheduledTasksForTeams,
58
63
  readStats
59
- } from "./chunk-TDJCLNDH.js";
64
+ } from "./chunk-DW4PMHNW.js";
60
65
  import {
61
66
  parseSlackThreadId
62
- } from "./chunk-FNLBTB4K.js";
67
+ } from "./chunk-MXVD2BDS.js";
63
68
  import {
64
69
  agentTurnUsageSchema,
65
70
  hasAgentTurnUsage,
@@ -72,44 +77,44 @@ import {
72
77
  listConversationAnnotations,
73
78
  renderPluginConversationEvent,
74
79
  resolveViewerUser
75
- } from "./chunk-5MXWHTCK.js";
80
+ } from "./chunk-IIESAYDL.js";
76
81
  import {
77
82
  getSlackClient,
78
83
  withSlackRetries
79
- } from "./chunk-TCS76X5D.js";
84
+ } from "./chunk-6SU2DT27.js";
80
85
  import {
81
86
  decodeStoredConversationEvent,
82
87
  getDb,
83
88
  getSqlExecutor,
84
89
  locationFromRow,
85
90
  parseSessionSource
86
- } from "./chunk-SIPKWSXK.js";
91
+ } from "./chunk-QTBKPZDA.js";
87
92
  import {
88
93
  juniorApiTokens,
89
94
  juniorConversationEvents,
90
95
  juniorConversations,
91
96
  juniorIdentities,
92
97
  juniorUsers
93
- } from "./chunk-DCLLQGS6.js";
98
+ } from "./chunk-UDBUS533.js";
94
99
  import "./chunk-EM225ITJ.js";
95
- import "./chunk-BOLJOV5T.js";
96
- import "./chunk-BYW4B4PR.js";
100
+ import "./chunk-MXTVUV3I.js";
101
+ import "./chunk-75I3UBIL.js";
97
102
  import {
98
103
  juniorDestinations
99
104
  } from "./chunk-VFUK3X5B.js";
100
105
  import {
101
106
  canExposeConversationPayload
102
- } from "./chunk-VPZFVJND.js";
107
+ } from "./chunk-YGZ2OLXL.js";
103
108
  import "./chunk-HZF5P5UN.js";
104
109
  import {
105
110
  parseSlackChannelId,
106
111
  parseSlackMessageTs,
107
112
  parseSlackTeamId
108
113
  } from "./chunk-F3B2YJ76.js";
109
- import "./chunk-JNNJZURV.js";
114
+ import "./chunk-2ECYPYKP.js";
110
115
  import "./chunk-6GWA276C.js";
111
- import "./chunk-KDCHVT25.js";
112
- import "./chunk-C7ZVPO4Z.js";
116
+ import "./chunk-C2N6MNO4.js";
117
+ import "./chunk-U7CMWQ7Z.js";
113
118
  import "./chunk-MLKGABMK.js";
114
119
 
115
120
  // src/api.ts
@@ -2170,7 +2175,7 @@ function readDescriptionText(home) {
2170
2175
  }
2171
2176
  }
2172
2177
  async function readSkillReports() {
2173
- const { discoverSkills } = await import("./skills-4ARJADHQ.js");
2178
+ const { discoverSkills } = await import("./skills-IMVPXSQ7.js");
2174
2179
  const skills = await discoverSkills();
2175
2180
  return skillReportsSchema.parse(
2176
2181
  skills.map((skill) => ({
@@ -2180,7 +2185,7 @@ async function readSkillReports() {
2180
2185
  );
2181
2186
  }
2182
2187
  async function readPlugins() {
2183
- const { pluginCatalogRuntime } = await import("./catalog-runtime-IU3QF4GG.js");
2188
+ const { pluginCatalogRuntime } = await import("./catalog-runtime-GCCFYPIK.js");
2184
2189
  return pluginsSchema.parse(
2185
2190
  pluginCatalogRuntime.getProviders().map((plugin) => ({
2186
2191
  configKeys: plugin.manifest.configKeys ?? [],
@@ -2193,7 +2198,7 @@ async function readPlugins() {
2193
2198
  async function readRuntimeInfoReport() {
2194
2199
  const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
2195
2200
  import("./discovery-GUFTFBTL.js"),
2196
- import("./catalog-runtime-IU3QF4GG.js"),
2201
+ import("./catalog-runtime-GCCFYPIK.js"),
2197
2202
  readPlugins(),
2198
2203
  readSkillReports()
2199
2204
  ]);
@@ -2209,7 +2214,7 @@ async function readRuntimeInfoReport() {
2209
2214
  }
2210
2215
  async function readPluginOperationalReportFeed() {
2211
2216
  const nowMs = Date.now();
2212
- const { getPluginOperationalReports } = await import("./agent-hooks-SCR74Q3E.js");
2217
+ const { getPluginOperationalReports } = await import("./agent-hooks-MJXMD7JP.js");
2213
2218
  return pluginOperationalReportFeedSchema.parse({
2214
2219
  source: "plugins",
2215
2220
  generatedAt: new Date(nowMs).toISOString(),
@@ -3579,6 +3584,7 @@ function createViewerScheduledTasks(store, user) {
3579
3584
  // src/chat/tasks/read.ts
3580
3585
  var TASK_LIST_LIMIT = 100;
3581
3586
  var TASK_FETCH_LIMIT = TASK_LIST_LIMIT + 1;
3587
+ var TASK_EXECUTION_LIST_LIMIT = 100;
3582
3588
  function creatorLabel(creator) {
3583
3589
  return creator.fullName?.trim() || (creator.userName?.trim() ? `@${creator.userName.trim()}` : "") || creator.slackUserId;
3584
3590
  }
@@ -3673,7 +3679,7 @@ function executionSummaryFields(stats) {
3673
3679
  totalRuns: stats?.totalRuns ?? 0
3674
3680
  };
3675
3681
  }
3676
- function scheduledTaskSummary(task, ownedByViewer, destination, stats) {
3682
+ function scheduledTaskSummary(task, ownedByViewer, destination, stats, createdByEmail) {
3677
3683
  if (task.status === "deleted") {
3678
3684
  throw new Error("Deleted scheduled tasks cannot enter the Tasks view");
3679
3685
  }
@@ -3681,6 +3687,7 @@ function scheduledTaskSummary(task, ownedByViewer, destination, stats) {
3681
3687
  return {
3682
3688
  createdAt: new Date(task.createdAtMs).toISOString(),
3683
3689
  createdBy: creatorLabel(task.createdBy),
3690
+ ...createdByEmail ? { createdByEmail } : {},
3684
3691
  destination: {
3685
3692
  channelId: task.destination.channelId,
3686
3693
  label: destination.label,
@@ -3697,15 +3704,111 @@ function scheduledTaskSummary(task, ownedByViewer, destination, stats) {
3697
3704
  status: task.status
3698
3705
  };
3699
3706
  }
3700
- async function readViewerTasks(user) {
3701
- const db = getDb();
3702
- const schedulerStore = createSchedulerSqlStore(db);
3703
- const identityIds = new Set(user.identities.map((identity) => identity.id));
3704
- const teamIds = [
3707
+ function eventTaskSummary(task, ownedByViewer, destination, stats, createdByEmail) {
3708
+ return {
3709
+ createdAt: new Date(task.createdAtMs).toISOString(),
3710
+ createdBy: creatorLabel(task.createdBy),
3711
+ ...createdByEmail ? { createdByEmail } : {},
3712
+ destination: {
3713
+ channelId: task.destination.channelId,
3714
+ label: destination.label,
3715
+ teamId: task.destination.teamId,
3716
+ visibility: destination.visibility
3717
+ },
3718
+ events: task.trigger.events,
3719
+ id: task.id,
3720
+ instruction: task.task.text,
3721
+ kind: "event",
3722
+ ...executionSummaryFields(stats),
3723
+ ownedByViewer,
3724
+ resource: `${task.trigger.label} \xB7 ${task.trigger.identifier}`,
3725
+ source: task.trigger.namespace,
3726
+ triggerAvailable: eventTaskTriggerAvailable(
3727
+ task,
3728
+ getResourceEventCatalog()
3729
+ )
3730
+ };
3731
+ }
3732
+ function viewerTeamIds(user) {
3733
+ return [
3705
3734
  ...new Set(
3706
3735
  user.identities.filter((identity) => identity.provider === "slack").map((identity) => identity.providerTenantId).filter((teamId) => Boolean(teamId))
3707
3736
  )
3708
3737
  ];
3738
+ }
3739
+ async function resolveViewerTaskCandidate(user, kind, id) {
3740
+ const db = getDb();
3741
+ const identityIds = new Set(user.identities.map((identity) => identity.id));
3742
+ const teamIds = viewerTeamIds(user);
3743
+ if (kind === "scheduled") {
3744
+ const task2 = await createSchedulerSqlStore(db).getTask(id);
3745
+ if (!task2 || task2.status === "deleted") return void 0;
3746
+ const ownedByViewer2 = identityIds.has(task2.creatorIdentityId);
3747
+ const destinations2 = await destinationDetails([task2.destination]);
3748
+ const destination2 = destinations2.get(destinationKey(task2.destination));
3749
+ const publicToViewer2 = teamIds.includes(task2.destination.teamId) && destination2?.visibility === "public";
3750
+ if (!ownedByViewer2 && !publicToViewer2) return void 0;
3751
+ return {
3752
+ kind: "scheduled",
3753
+ ownedByViewer: ownedByViewer2,
3754
+ publicToViewer: publicToViewer2,
3755
+ task: task2
3756
+ };
3757
+ }
3758
+ const task = await getEventTask(db, id);
3759
+ if (!task) return void 0;
3760
+ const ownedByViewer = eventTaskBelongsToUser(task, user);
3761
+ const destinations = await destinationDetails([task.destination]);
3762
+ const destination = destinations.get(destinationKey(task.destination));
3763
+ const publicToViewer = teamIds.includes(task.destination.teamId) && destination?.visibility === "public";
3764
+ if (!ownedByViewer && !publicToViewer) return void 0;
3765
+ return {
3766
+ kind: "event",
3767
+ ownedByViewer,
3768
+ publicToViewer,
3769
+ task
3770
+ };
3771
+ }
3772
+ async function taskSummaryForCandidate(candidate) {
3773
+ const [destinations, creatorEmails, stats] = await Promise.all([
3774
+ destinationDetails([candidate.task.destination]),
3775
+ creatorProfileEmails([candidate]),
3776
+ readTaskExecutionSummaries(candidate.kind, "junior")
3777
+ ]);
3778
+ const destination = destinations.get(
3779
+ destinationKey(candidate.task.destination)
3780
+ ) ?? {
3781
+ label: `Channel ${candidate.task.destination.channelId}`,
3782
+ visibility: "private"
3783
+ };
3784
+ const createdByEmail = creatorEmails.get(
3785
+ creatorKey(
3786
+ candidate.task.destination.teamId,
3787
+ candidate.task.createdBy.slackUserId
3788
+ )
3789
+ );
3790
+ if (candidate.kind === "scheduled") {
3791
+ return scheduledTaskSummary(
3792
+ candidate.task,
3793
+ candidate.ownedByViewer,
3794
+ destination,
3795
+ stats.get(candidate.task.id),
3796
+ createdByEmail
3797
+ );
3798
+ }
3799
+ return eventTaskSummary(
3800
+ candidate.task,
3801
+ candidate.ownedByViewer,
3802
+ destination,
3803
+ stats.get(candidate.task.id),
3804
+ createdByEmail
3805
+ );
3806
+ }
3807
+ async function readViewerTasks(user) {
3808
+ const db = getDb();
3809
+ const schedulerStore = createSchedulerSqlStore(db);
3810
+ const identityIds = new Set(user.identities.map((identity) => identity.id));
3811
+ const teamIds = viewerTeamIds(user);
3709
3812
  const [scheduledPage, publicScheduled, eventTasks, publicEventTasks] = await Promise.all([
3710
3813
  createViewerScheduledTasks(schedulerStore, user).list({
3711
3814
  limit: TASK_FETCH_LIMIT
@@ -3753,7 +3856,6 @@ async function readViewerTasks(user) {
3753
3856
  destinationDetails(selected.map(({ task }) => task.destination)),
3754
3857
  creatorProfileEmails(selected)
3755
3858
  ]);
3756
- const eventCatalog = getResourceEventCatalog();
3757
3859
  const visible = selected.filter(
3758
3860
  (candidate) => candidate.ownedByViewer || destinations.get(destinationKey(candidate.task.destination))?.visibility === "public"
3759
3861
  );
@@ -3776,38 +3878,21 @@ async function readViewerTasks(user) {
3776
3878
  )
3777
3879
  );
3778
3880
  if (candidate.kind === "scheduled") {
3779
- const summary = scheduledTaskSummary(
3881
+ return scheduledTaskSummary(
3780
3882
  candidate.task,
3781
3883
  candidate.ownedByViewer,
3782
3884
  destination,
3783
- scheduledStats.get(candidate.task.id)
3885
+ scheduledStats.get(candidate.task.id),
3886
+ createdByEmail
3784
3887
  );
3785
- return {
3786
- ...summary,
3787
- ...createdByEmail ? { createdByEmail } : {}
3788
- };
3789
3888
  }
3790
- const task = candidate.task;
3791
- return {
3792
- createdAt: new Date(task.createdAtMs).toISOString(),
3793
- createdBy: creatorLabel(task.createdBy),
3794
- ...createdByEmail ? { createdByEmail } : {},
3795
- destination: {
3796
- channelId: task.destination.channelId,
3797
- label: destination.label,
3798
- teamId: task.destination.teamId,
3799
- visibility: destination.visibility
3800
- },
3801
- events: task.trigger.events,
3802
- id: task.id,
3803
- instruction: task.task.text,
3804
- kind: "event",
3805
- ...executionSummaryFields(eventStats.get(task.id)),
3806
- ownedByViewer: candidate.ownedByViewer,
3807
- resource: `${task.trigger.label} \xB7 ${task.trigger.identifier}`,
3808
- source: task.trigger.namespace,
3809
- triggerAvailable: eventTaskTriggerAvailable(task, eventCatalog)
3810
- };
3889
+ return eventTaskSummary(
3890
+ candidate.task,
3891
+ candidate.ownedByViewer,
3892
+ destination,
3893
+ eventStats.get(candidate.task.id),
3894
+ createdByEmail
3895
+ );
3811
3896
  });
3812
3897
  return {
3813
3898
  executionDays,
@@ -3821,6 +3906,28 @@ var ViewerTaskNotFoundError = class extends Error {
3821
3906
  this.name = "ViewerTaskNotFoundError";
3822
3907
  }
3823
3908
  };
3909
+ async function readViewerTaskExecutions(user, kind, id) {
3910
+ const candidate = await resolveViewerTaskCandidate(user, kind, id);
3911
+ if (!candidate) throw new ViewerTaskNotFoundError();
3912
+ const [task, executions, executionDays] = await Promise.all([
3913
+ taskSummaryForCandidate(candidate),
3914
+ readTaskExecutions({
3915
+ kind,
3916
+ limit: TASK_EXECUTION_LIST_LIMIT + 1,
3917
+ taskId: id
3918
+ }),
3919
+ readTaskExecutionStatusDays({
3920
+ kind,
3921
+ taskId: id
3922
+ })
3923
+ ]);
3924
+ return {
3925
+ executionDays,
3926
+ executions: executions.slice(0, TASK_EXECUTION_LIST_LIMIT),
3927
+ task,
3928
+ truncated: executions.length > TASK_EXECUTION_LIST_LIMIT
3929
+ };
3930
+ }
3824
3931
  async function deleteViewerTask(user, kind, id) {
3825
3932
  if (kind === "scheduled") {
3826
3933
  try {
@@ -3858,6 +3965,43 @@ function createTaskRoutes() {
3858
3965
  { status: 401 }
3859
3966
  );
3860
3967
  });
3968
+ app.get("/:kind/:id/executions", async (context) => {
3969
+ const user = await viewer(context);
3970
+ if (!user) {
3971
+ return jsonResponse(
3972
+ apiErrorSchema,
3973
+ { error: "Authentication required." },
3974
+ { status: 401 }
3975
+ );
3976
+ }
3977
+ const params = taskParamsSchema.safeParse(context.req.param());
3978
+ if (!params.success) {
3979
+ return jsonResponse(
3980
+ apiErrorSchema,
3981
+ { error: "Invalid task." },
3982
+ { status: 400 }
3983
+ );
3984
+ }
3985
+ try {
3986
+ return jsonResponse(
3987
+ taskExecutionListSchema,
3988
+ await readViewerTaskExecutions(
3989
+ user,
3990
+ params.data.kind,
3991
+ params.data.id
3992
+ )
3993
+ );
3994
+ } catch (error) {
3995
+ if (error instanceof ViewerTaskNotFoundError) {
3996
+ return jsonResponse(
3997
+ apiErrorSchema,
3998
+ { error: error.message },
3999
+ { status: 404 }
4000
+ );
4001
+ }
4002
+ throw error;
4003
+ }
4004
+ });
3861
4005
  app.delete("/:kind/:id", async (context) => {
3862
4006
  const user = await viewer(context);
3863
4007
  if (!user) {