@sentry/junior 0.190.0 → 0.192.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 (97) hide show
  1. package/dist/{agent-hooks-3IG2FQW2.js → agent-hooks-3JY76L5X.js} +11 -11
  2. package/dist/api/activity.d.ts +3 -1
  3. package/dist/api/code/overview.d.ts +12 -0
  4. package/dist/api/locations/detail.d.ts +8 -0
  5. package/dist/api/locations/list.d.ts +5 -0
  6. package/dist/api/people/code.d.ts +6 -0
  7. package/dist/api/people/shared.d.ts +2 -0
  8. package/dist/api/reporting-window.d.ts +40 -0
  9. package/dist/api/schema/code.d.ts +14 -0
  10. package/dist/api/schema/conversation.d.ts +27 -0
  11. package/dist/api/schema/location.d.ts +15 -0
  12. package/dist/api/schema/person.d.ts +104 -0
  13. package/dist/api/schema/task.d.ts +15 -2
  14. package/dist/api/schema.d.ts +1 -1
  15. package/dist/api/schema.js +2 -2
  16. package/dist/api.js +536 -141
  17. package/dist/app.js +93 -130
  18. package/dist/{catalog-runtime-2OT7S3ZC.js → catalog-runtime-5JVLWXRY.js} +4 -4
  19. package/dist/chat/agent/resume.d.ts +0 -1
  20. package/dist/chat/agent/types.d.ts +0 -1
  21. package/dist/chat/agent-invocations/types.d.ts +4 -4
  22. package/dist/chat/providers/slack/runtime.d.ts +1 -2
  23. package/dist/chat/providers/slack/system-turn.d.ts +9 -4
  24. package/dist/chat/providers/slack/turn.d.ts +0 -1
  25. package/dist/chat/services/turn-router.d.ts +1 -1
  26. package/dist/chat/slack/dispatch-turn.d.ts +0 -1
  27. package/dist/chat/slack/timestamp-param.d.ts +1 -1
  28. package/dist/chat/task-execution/assistant-message.d.ts +7 -7
  29. package/dist/chat/task-execution/checkpoint.d.ts +0 -1
  30. package/dist/chat/task-execution/conversation-turn.d.ts +2 -2
  31. package/dist/chat/task-execution/state.d.ts +0 -3
  32. package/dist/chat/task-execution/store.d.ts +0 -1
  33. package/dist/chat/task-execution/turn-cursor.d.ts +0 -2
  34. package/dist/chat/task-execution/worker.d.ts +0 -1
  35. package/dist/chat/tasks/execution-stats.d.ts +12 -0
  36. package/dist/{chunk-Y4WL4OYD.js → chunk-3ADPXQBL.js} +1 -1
  37. package/dist/{chunk-F3K2267N.js → chunk-3O2NXVGB.js} +77 -35
  38. package/dist/{chunk-2MKHYSYL.js → chunk-3UJSII43.js} +3 -3
  39. package/dist/{chunk-RLYJYEIY.js → chunk-47JFLZSF.js} +5 -7
  40. package/dist/{chunk-T66GV7A3.js → chunk-4AFSQJD6.js} +2 -2
  41. package/dist/{chunk-DJZGQ7OL.js → chunk-4B4DQGOM.js} +22 -29
  42. package/dist/{chunk-OJFX2FP7.js → chunk-4CCQZHD3.js} +9 -11
  43. package/dist/{chunk-BUJU6C2J.js → chunk-4WIA45WD.js} +1 -1
  44. package/dist/{chunk-VWNIDTFR.js → chunk-4Z7B5WVV.js} +2 -2
  45. package/dist/{chunk-3J3BCB4J.js → chunk-5V4BAUCH.js} +1 -1
  46. package/dist/{chunk-663DQH5W.js → chunk-6FCKJDKS.js} +1 -1
  47. package/dist/{chunk-HI5KXE3C.js → chunk-6LX6KV5C.js} +3 -3
  48. package/dist/{chunk-67MMSYSE.js → chunk-7XO7PTZE.js} +1 -1
  49. package/dist/{chunk-OKAHLUSU.js → chunk-AKR6W7VV.js} +3 -3
  50. package/dist/{chunk-JV7U4665.js → chunk-ARSUYYQG.js} +1 -1
  51. package/dist/{chunk-IRQ3RSX3.js → chunk-BGLMT6KP.js} +3 -3
  52. package/dist/{chunk-2MRF22J4.js → chunk-BUTAWPUV.js} +50 -8
  53. package/dist/{chunk-62DRKZQU.js → chunk-EIYOABL4.js} +4 -4
  54. package/dist/{chunk-PFAZSRGR.js → chunk-EYIMZY5O.js} +114 -19
  55. package/dist/{chunk-DVX6U6GI.js → chunk-EYNUOZCN.js} +1 -1
  56. package/dist/{chunk-4PKEJK5B.js → chunk-FGYWKKTJ.js} +1 -1
  57. package/dist/{chunk-YFU4DGZY.js → chunk-G4E5WIRL.js} +30 -9
  58. package/dist/{chunk-OON4IQHH.js → chunk-H5Q2T5VC.js} +1 -1
  59. package/dist/{chunk-ZFCO2TMB.js → chunk-IBO4YFFZ.js} +1 -1
  60. package/dist/{chunk-ECOR3OXY.js → chunk-ITTEDZGY.js} +8 -8
  61. package/dist/{chunk-4BLFIYVK.js → chunk-KR5F3QSP.js} +9 -12
  62. package/dist/{chunk-6BXUSF7J.js → chunk-LRTEMMCZ.js} +1 -1
  63. package/dist/{chunk-MNHJ4WLE.js → chunk-MB2CTEPD.js} +74 -4
  64. package/dist/{chunk-YKIAUKYH.js → chunk-OBN7UEQJ.js} +2 -2
  65. package/dist/{chunk-OYCOLHCR.js → chunk-PXP2M32M.js} +5 -5
  66. package/dist/{chunk-6H7YU6XH.js → chunk-PXUBRZBU.js} +1 -1
  67. package/dist/{chunk-REVH4BZU.js → chunk-PYVGXGKC.js} +2 -2
  68. package/dist/{chunk-UTL3MHPC.js → chunk-RC745GGZ.js} +8 -1
  69. package/dist/{chunk-CZXZKTAI.js → chunk-RWBZZMW6.js} +3 -3
  70. package/dist/{chunk-GWCFXTB6.js → chunk-SSR6YBWW.js} +6 -6
  71. package/dist/{chunk-7UJ6IJCK.js → chunk-SZ2O3CGS.js} +1 -1
  72. package/dist/{chunk-BGOLRC36.js → chunk-VF3EDS7P.js} +13 -11
  73. package/dist/{chunk-FVFJ57RK.js → chunk-YE6DVM43.js} +9 -8
  74. package/dist/{chunk-7Y7XMI6P.js → chunk-YRWGJ5OO.js} +5 -5
  75. package/dist/{chunk-W2C4TPLB.js → chunk-Z4DNJI5F.js} +5 -5
  76. package/dist/cli/chat.js +33 -33
  77. package/dist/cli/check.js +5 -5
  78. package/dist/cli/plugins.js +12 -12
  79. package/dist/cli/snapshot-create.js +9 -9
  80. package/dist/cli/upgrade.js +6 -6
  81. package/dist/db/schema/stats.d.ts +5 -1
  82. package/dist/{db-2IFDMDDY.js → db-LRM6AP66.js} +6 -6
  83. package/dist/instrumentation.js +3 -3
  84. package/dist/nitro.js +6 -6
  85. package/dist/{oauth-callback-server-SZSS2KH6.js → oauth-callback-server-BKCDVYVH.js} +29 -29
  86. package/dist/reporting-schema.d.ts +2 -2
  87. package/dist/{runner-2N4QU77X.js → runner-RUXGS3E6.js} +21 -21
  88. package/dist/{skills-VU2LZAKX.js → skills-DXP2RCJF.js} +5 -5
  89. package/dist/spawn-HH7GH7XT.js +42 -0
  90. package/dist/task-runner-H5I7R3LJ.js +36 -0
  91. package/dist/{validation-IJGHK7NI.js → validation-F4KYLIF2.js} +5 -5
  92. package/dist/version.js +1 -1
  93. package/dist/{work-DI45MLRL.js → work-UUNMNSML.js} +21 -21
  94. package/dist/{worker-FY7KWG2M.js → worker-PMIJ5NLD.js} +10 -10
  95. package/package.json +6 -6
  96. package/dist/spawn-3K7RV4T5.js +0 -42
  97. package/dist/task-runner-52DYFHW3.js +0 -36
@@ -11,6 +11,61 @@ import {
11
11
 
12
12
  // src/api/activity.ts
13
13
  import { z } from "zod";
14
+
15
+ // src/api/reporting-window.ts
16
+ var HOUR_MS = 60 * 60 * 1e3;
17
+ var DAY_MS = 24 * HOUR_MS;
18
+ var WINDOW_HOURS = 24;
19
+ function startOfUtcDay(valueMs) {
20
+ const date = new Date(valueMs);
21
+ date.setUTCHours(0, 0, 0, 0);
22
+ return date;
23
+ }
24
+ function startOfUtcHour(valueMs) {
25
+ const date = new Date(valueMs);
26
+ date.setUTCMinutes(0, 0, 0);
27
+ return date;
28
+ }
29
+ function utcDayKey(value) {
30
+ const date = typeof value === "number" ? new Date(value) : value;
31
+ return date.toISOString().slice(0, 10);
32
+ }
33
+ function utcHourKey(value) {
34
+ const date = typeof value === "number" ? new Date(value) : value;
35
+ return date.toISOString().slice(0, 13);
36
+ }
37
+ function trailingUtcDayWindow(nowMs, dayCount) {
38
+ const end = startOfUtcDay(nowMs);
39
+ const start = new Date(end);
40
+ start.setUTCDate(start.getUTCDate() - (dayCount - 1));
41
+ return { end, start };
42
+ }
43
+ function trailingUtcHourWindow(nowMs, hourCount = WINDOW_HOURS) {
44
+ const end = startOfUtcHour(nowMs);
45
+ const start = new Date(end.getTime() - (hourCount - 1) * HOUR_MS);
46
+ return { end, start };
47
+ }
48
+ function fillUtcDays(args) {
49
+ const { end, start } = trailingUtcDayWindow(args.nowMs, args.count);
50
+ const items = [];
51
+ for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setUTCDate(cursor.getUTCDate() + 1)) {
52
+ const date = utcDayKey(cursor);
53
+ items.push(args.rows.get(date) ?? args.empty(date));
54
+ }
55
+ return items;
56
+ }
57
+ function fillUtcHours(args) {
58
+ const hourCount = args.count ?? WINDOW_HOURS;
59
+ const { end, start } = trailingUtcHourWindow(args.nowMs, hourCount);
60
+ const items = [];
61
+ for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setTime(cursor.getTime() + HOUR_MS)) {
62
+ const date = utcHourKey(cursor);
63
+ items.push(args.rows.get(date) ?? args.empty(date));
64
+ }
65
+ return items;
66
+ }
67
+
68
+ // src/api/activity.ts
14
69
  var dailyConversationActivitySchema = z.object({
15
70
  active: z.number(),
16
71
  conversations: z.number(),
@@ -29,16 +84,19 @@ function emptyActivityDay(date) {
29
84
  };
30
85
  }
31
86
  function activityDays(days, nowMs, count) {
32
- const items = [];
33
- const end = new Date(nowMs);
34
- end.setUTCHours(0, 0, 0, 0);
35
- const start = new Date(end);
36
- start.setUTCDate(start.getUTCDate() - (count - 1));
37
- for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setUTCDate(cursor.getUTCDate() + 1)) {
38
- const date = cursor.toISOString().slice(0, 10);
39
- items.push(days.get(date) ?? emptyActivityDay(date));
40
- }
41
- return items;
87
+ return fillUtcDays({
88
+ count,
89
+ empty: emptyActivityDay,
90
+ nowMs,
91
+ rows: days
92
+ });
93
+ }
94
+ function activityHours(hours, nowMs) {
95
+ return fillUtcHours({
96
+ empty: emptyActivityDay,
97
+ nowMs,
98
+ rows: hours
99
+ });
42
100
  }
43
101
 
44
102
  // src/api/schema/code.ts
@@ -54,10 +112,11 @@ var codeChangeSummarySchema = z2.object({
54
112
  mergeRate: z2.number().min(0).max(1).optional(),
55
113
  open: z2.number().int().nonnegative()
56
114
  }).strict();
115
+ var codeMetricBucketSchema = z2.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/);
57
116
  var codeActivityDaySchema = z2.object({
58
117
  closed: z2.number().int().nonnegative(),
59
118
  created: z2.number().int().nonnegative(),
60
- date: z2.string().date(),
119
+ date: codeMetricBucketSchema,
61
120
  merged: z2.number().int().nonnegative()
62
121
  }).strict();
63
122
  var codeRepositorySummarySchema = z2.object({
@@ -86,6 +145,7 @@ var codeChangeSummaryReportSchema = z2.object({
86
145
  }).strict();
87
146
  var codeOverviewReportSchema = z2.object({
88
147
  activityDays: z2.array(codeActivityDaySchema),
148
+ activityHours: z2.array(codeActivityDaySchema).optional(),
89
149
  changes: z2.array(codeChangeSummaryReportSchema),
90
150
  generatedAt: z2.string(),
91
151
  repositories: z2.array(codeRepositorySummarySchema),
@@ -95,6 +155,7 @@ var codeOverviewReportSchema = z2.object({
95
155
  }).strict();
96
156
  var codePersonReportSchema = z2.object({
97
157
  activityDays: z2.array(codeActivityDaySchema),
158
+ activityHours: z2.array(codeActivityDaySchema).optional(),
98
159
  generatedAt: z2.string(),
99
160
  summary: codeChangeSummarySchema,
100
161
  windowEnd: z2.string(),
@@ -623,11 +684,12 @@ var conversationStatsItemSchema = z3.object({
623
684
  costUsd: z3.number().optional(),
624
685
  tokens: z3.number().optional()
625
686
  }).strict();
687
+ var conversationMetricBucketSchema = z3.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/);
626
688
  var conversationMetricDaySchema = z3.object({
627
689
  cachedInputTokens: z3.number().optional(),
628
690
  conversations: z3.number(),
629
691
  costUsd: z3.number().optional(),
630
- date: z3.string(),
692
+ date: conversationMetricBucketSchema,
631
693
  durationMs: z3.number(),
632
694
  inputTokens: z3.number().optional(),
633
695
  tokens: z3.number().optional()
@@ -636,7 +698,7 @@ var guardianMetricDaySchema = z3.object({
636
698
  allow: z3.number(),
637
699
  ask: z3.number(),
638
700
  costUsd: z3.number().optional(),
639
- date: z3.string(),
701
+ date: conversationMetricBucketSchema,
640
702
  deny: z3.number(),
641
703
  requests: z3.number()
642
704
  }).strict();
@@ -646,6 +708,7 @@ var guardianStatsSchema = z3.object({
646
708
  costUsd: z3.number().optional(),
647
709
  deny: z3.number(),
648
710
  metricDays: z3.array(guardianMetricDaySchema),
711
+ metricHours: z3.array(guardianMetricDaySchema).optional(),
649
712
  requests: z3.number()
650
713
  }).strict();
651
714
  var conversationStatsReportSchema = z3.object({
@@ -657,6 +720,7 @@ var conversationStatsReportSchema = z3.object({
657
720
  generatedAt: z3.string(),
658
721
  guardian: guardianStatsSchema,
659
722
  metricDays: z3.array(conversationMetricDaySchema),
723
+ metricHours: z3.array(conversationMetricDaySchema).optional(),
660
724
  locations: z3.array(conversationStatsItemSchema),
661
725
  actors: z3.array(conversationStatsItemSchema),
662
726
  source: z3.literal("conversation_index"),
@@ -671,11 +735,12 @@ var conversationStatsReportSchema = z3.object({
671
735
  import { z as z4 } from "zod";
672
736
  var personParamsSchema = z4.object({ email: z4.string().trim().min(1) }).strict();
673
737
  var peopleConversationStatsItemSchema = conversationStatsItemSchema.omit({ costUsd: true });
738
+ var peopleMetricBucketSchema = z4.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/);
674
739
  var actorActivityDayReportSchema = z4.object({
675
740
  active: z4.number(),
676
741
  conversations: z4.number(),
677
742
  costUsd: z4.number().optional(),
678
- date: z4.string(),
743
+ date: peopleMetricBucketSchema,
679
744
  durationMs: z4.number(),
680
745
  failed: z4.number(),
681
746
  tokens: z4.number().optional()
@@ -683,7 +748,7 @@ var actorActivityDayReportSchema = z4.object({
683
748
  var peopleActivityDayReportSchema = z4.object({
684
749
  activePeople: z4.number(),
685
750
  conversations: z4.number(),
686
- date: z4.string()
751
+ date: peopleMetricBucketSchema
687
752
  }).strict();
688
753
  var actorTotalsReportSchema = z4.object({
689
754
  active: z4.number(),
@@ -693,14 +758,28 @@ var actorTotalsReportSchema = z4.object({
693
758
  failed: z4.number(),
694
759
  tokens: z4.number().optional()
695
760
  }).strict();
761
+ var actorWindowMetricsSchema = z4.object({
762
+ conversations: z4.number().int().nonnegative(),
763
+ costUsd: z4.number().finite().nonnegative(),
764
+ durationMs: z4.number().finite().nonnegative(),
765
+ priorCostUsd: z4.number().finite().nonnegative()
766
+ }).strict();
767
+ var actorDirectoryWindowsSchema = z4.object({
768
+ 1: actorWindowMetricsSchema,
769
+ 7: actorWindowMetricsSchema,
770
+ 30: actorWindowMetricsSchema,
771
+ 90: actorWindowMetricsSchema
772
+ }).strict();
696
773
  var identifiedActorSchema = actorIdentitySchema.extend({ email: z4.string().min(1) }).strict();
697
774
  var actorSummaryReportSchema = actorTotalsReportSchema.extend({
698
775
  firstSeenAt: z4.string(),
699
776
  lastSeenAt: z4.string(),
700
- actor: identifiedActorSchema
777
+ actor: identifiedActorSchema,
778
+ windows: actorDirectoryWindowsSchema
701
779
  }).strict();
702
780
  var actorDirectoryReportSchema = z4.object({
703
781
  activityDays: z4.array(peopleActivityDayReportSchema),
782
+ activityHours: z4.array(peopleActivityDayReportSchema).optional(),
704
783
  generatedAt: z4.string(),
705
784
  people: z4.array(actorSummaryReportSchema),
706
785
  source: z4.literal("conversation_index"),
@@ -709,6 +788,7 @@ var actorDirectoryReportSchema = z4.object({
709
788
  }).strict();
710
789
  var actorProfileReportSchema = z4.object({
711
790
  activityDays: z4.array(actorActivityDayReportSchema),
791
+ activityHours: z4.array(actorActivityDayReportSchema).optional(),
712
792
  generatedAt: z4.string(),
713
793
  locations: z4.array(peopleConversationStatsItemSchema),
714
794
  recentConversations: z4.array(conversationSummaryReportSchema),
@@ -741,13 +821,15 @@ var locationSummaryReportSchema = conversationStatsItemSchema.extend({
741
821
  visibility: z5.literal("public")
742
822
  }).strict();
743
823
  var locationActorSummaryReportSchema = conversationStatsItemSchema.extend({ actor: actorIdentitySchema }).strict();
824
+ var locationMetricBucketSchema = z5.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/);
744
825
  var locationActivityDayReportSchema = z5.object({
745
- date: z5.string(),
826
+ date: locationMetricBucketSchema,
746
827
  privateConversations: z5.number(),
747
828
  publicConversations: z5.number()
748
829
  }).strict();
749
830
  var locationDirectoryReportSchema = z5.object({
750
831
  activityDays: z5.array(locationActivityDayReportSchema),
832
+ activityHours: z5.array(locationActivityDayReportSchema).optional(),
751
833
  generatedAt: z5.string(),
752
834
  locations: z5.array(locationSummaryReportSchema),
753
835
  privateActivity: conversationStatsItemSchema,
@@ -757,6 +839,7 @@ var locationDirectoryReportSchema = z5.object({
757
839
  }).strict();
758
840
  var locationDetailReportSchema = locationSummaryReportSchema.extend({
759
841
  activityDays: z5.array(dailyConversationActivitySchema),
842
+ activityHours: z5.array(dailyConversationActivitySchema).optional(),
760
843
  actors: z5.array(locationActorSummaryReportSchema),
761
844
  generatedAt: z5.string(),
762
845
  recentConversations: z5.array(conversationSummaryReportSchema),
@@ -867,13 +950,15 @@ var taskSummarySchema = z9.discriminatedUnion("kind", [
867
950
  scheduledTaskSummarySchema,
868
951
  eventTaskSummarySchema
869
952
  ]);
953
+ var taskMetricBucketSchema = z9.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/);
870
954
  var taskExecutionDaySchema = z9.object({
871
- date: z9.string().min(1),
955
+ date: taskMetricBucketSchema,
872
956
  event: z9.number().int().nonnegative(),
873
957
  scheduled: z9.number().int().nonnegative()
874
958
  }).strict();
875
959
  var taskListSchema = z9.object({
876
960
  executionDays: z9.array(taskExecutionDaySchema),
961
+ executionHours: z9.array(taskExecutionDaySchema).optional(),
877
962
  tasks: z9.array(taskSummarySchema),
878
963
  truncated: z9.boolean()
879
964
  }).strict();
@@ -896,11 +981,12 @@ var taskExecutionSchema = z9.object({
896
981
  var taskExecutionStatusDaySchema = z9.object({
897
982
  blocked: z9.number().int().nonnegative(),
898
983
  completed: z9.number().int().nonnegative(),
899
- date: z9.string().min(1),
984
+ date: taskMetricBucketSchema,
900
985
  failed: z9.number().int().nonnegative()
901
986
  }).strict();
902
987
  var taskExecutionListSchema = z9.object({
903
988
  executionDays: z9.array(taskExecutionStatusDaySchema),
989
+ executionHours: z9.array(taskExecutionStatusDaySchema).optional(),
904
990
  executions: z9.array(taskExecutionSchema),
905
991
  task: taskSummarySchema,
906
992
  truncated: z9.boolean()
@@ -964,8 +1050,17 @@ export {
964
1050
  codeChangeSummaryReportSchema,
965
1051
  codeOverviewReportSchema,
966
1052
  codePersonReportSchema,
1053
+ HOUR_MS,
1054
+ DAY_MS,
1055
+ utcDayKey,
1056
+ utcHourKey,
1057
+ trailingUtcDayWindow,
1058
+ trailingUtcHourWindow,
1059
+ fillUtcDays,
1060
+ fillUtcHours,
967
1061
  dailyConversationActivitySchema,
968
1062
  activityDays,
1063
+ activityHours,
969
1064
  locationParamsSchema,
970
1065
  locationActivityDayReportSchema,
971
1066
  locationDirectoryReportSchema,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logWarn
3
- } from "./chunk-Y4WL4OYD.js";
3
+ } from "./chunk-3ADPXQBL.js";
4
4
 
5
5
  // src/chat/conversation-privacy.ts
6
6
  import { AsyncLocalStorage } from "async_hooks";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createPluginCatalogRuntime
3
- } from "./chunk-663DQH5W.js";
3
+ } from "./chunk-6FCKJDKS.js";
4
4
 
5
5
  // src/chat/plugins/catalog-runtime.ts
6
6
  var pluginCatalogRuntime = createPluginCatalogRuntime();
@@ -8,14 +8,14 @@ import {
8
8
  getConversationStore,
9
9
  parseDestination,
10
10
  sameDestination
11
- } from "./chunk-OKAHLUSU.js";
11
+ } from "./chunk-AKR6W7VV.js";
12
12
  import {
13
13
  getDefaultRedisStateAdapterFor,
14
14
  getStateAdapter
15
- } from "./chunk-6BXUSF7J.js";
15
+ } from "./chunk-LRTEMMCZ.js";
16
16
  import {
17
17
  getChatConfig
18
- } from "./chunk-VWNIDTFR.js";
18
+ } from "./chunk-4Z7B5WVV.js";
19
19
  import {
20
20
  parseStoredSlackActor
21
21
  } from "./chunk-N7TMSOZH.js";
@@ -23,7 +23,7 @@ import {
23
23
  isRecord,
24
24
  toOptionalNumber,
25
25
  toOptionalString
26
- } from "./chunk-Y4WL4OYD.js";
26
+ } from "./chunk-3ADPXQBL.js";
27
27
 
28
28
  // src/chat/task-execution/state.ts
29
29
  import { randomUUID } from "crypto";
@@ -81,7 +81,6 @@ var agentInputSchema = z.object({
81
81
  message: "agent input requires text or attachments"
82
82
  });
83
83
  var inboundMessageDeliverySchema = z.enum(["defer", "interrupt"]);
84
- var publishExternallySchema = z.boolean();
85
84
  var inboundMessageSchema = z.object({
86
85
  attemptCount: z.number().finite().optional(),
87
86
  conversationId: z.string().refine((value) => value.trim().length > 0),
@@ -92,9 +91,11 @@ var inboundMessageSchema = z.object({
92
91
  injectedAtMs: z.number().finite().optional(),
93
92
  input: agentInputSchema,
94
93
  receivedAtMs: z.number().finite(),
95
- publishExternally: publishExternallySchema,
96
94
  source: inboundMessageSourceSchema
97
95
  }).strict();
96
+ var storedInboundMessageSchema = inboundMessageSchema.extend({
97
+ publishExternally: z.boolean()
98
+ });
98
99
  function conversationKey(conversationId) {
99
100
  return `${CONVERSATION_PREFIX}:${conversationId}`;
100
101
  }
@@ -148,8 +149,15 @@ function normalizeExecutionStatus(value) {
148
149
  return void 0;
149
150
  }
150
151
  function normalizeMessage(value) {
151
- const parsed = inboundMessageSchema.safeParse(value);
152
- return parsed.success ? parsed.data : void 0;
152
+ const parsed = storedInboundMessageSchema.safeParse(value);
153
+ if (!parsed.success) {
154
+ return void 0;
155
+ }
156
+ const { publishExternally: _publishExternally, ...message } = parsed.data;
157
+ return message;
158
+ }
159
+ function storeMessage(message, publishExternally) {
160
+ return { ...message, publishExternally };
153
161
  }
154
162
  function isFinalAttempt(message) {
155
163
  return (message.attemptCount ?? 0) >= CONVERSATION_WORK_MAX_DELIVERY_ATTEMPTS - 1;
@@ -612,9 +620,22 @@ async function writeConversation(state, lock, conversation) {
612
620
  if (!fenced) {
613
621
  throw new ConversationMutationFencedError(next.conversationId);
614
622
  }
623
+ const hasSlackDestination = next.destination?.platform === "slack";
624
+ const stored = {
625
+ ...next,
626
+ execution: {
627
+ ...next.execution,
628
+ pendingMessages: next.execution.pendingMessages.map(
629
+ (message) => storeMessage(
630
+ message,
631
+ hasSlackDestination && (message.source === "slack" || message.source === "resource_event" || message.source === "plugin" || message.source === "scheduler")
632
+ )
633
+ )
634
+ }
635
+ };
615
636
  await state.set(
616
637
  conversationKey(next.conversationId),
617
- next,
638
+ stored,
618
639
  JUNIOR_THREAD_STATE_TTL_MS
619
640
  );
620
641
  await upsertIndexEntry({
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getStateAdapter
3
- } from "./chunk-6BXUSF7J.js";
3
+ } from "./chunk-LRTEMMCZ.js";
4
4
  import {
5
5
  getClient
6
6
  } from "./chunk-PEQXYSSE.js";
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-VFUK3X5B.js";
5
5
  import {
6
6
  DEFAULT_SQL_STATEMENT_TIMEOUT_MS
7
- } from "./chunk-VWNIDTFR.js";
7
+ } from "./chunk-4Z7B5WVV.js";
8
8
 
9
9
  // src/db/neon.ts
10
10
  import { AsyncLocalStorage } from "async_hooks";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  coerceThreadConversationState,
3
3
  getPersistedThreadState
4
- } from "./chunk-W2C4TPLB.js";
4
+ } from "./chunk-Z4DNJI5F.js";
5
5
  import {
6
6
  recordTaskExecution
7
- } from "./chunk-MNHJ4WLE.js";
7
+ } from "./chunk-MB2CTEPD.js";
8
8
  import {
9
9
  pluginTaskId,
10
10
  pluginTaskParamsSchema,
11
11
  sendVercelPluginTask
12
- } from "./chunk-CZXZKTAI.js";
12
+ } from "./chunk-RWBZZMW6.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-BGOLRC36.js";
22
+ } from "./chunk-VF3EDS7P.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-2MRF22J4.js";
31
+ } from "./chunk-BUTAWPUV.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-OKAHLUSU.js";
38
+ } from "./chunk-AKR6W7VV.js";
39
39
  import {
40
40
  getStateAdapter
41
- } from "./chunk-6BXUSF7J.js";
41
+ } from "./chunk-LRTEMMCZ.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-2IFDMDDY.js")).getConversationStore();
87
+ const conversationStore = args.conversationStore ?? (await import("./db-LRM6AP66.js")).getConversationStore();
88
88
  const chain = await loadConversationChain(
89
89
  args.conversationId,
90
90
  conversationStore
@@ -1,41 +1,41 @@
1
1
  import {
2
2
  healthReportSchema
3
- } from "./chunk-UTL3MHPC.js";
3
+ } from "./chunk-RC745GGZ.js";
4
4
  import {
5
5
  parseSlackThreadId
6
- } from "./chunk-BUJU6C2J.js";
6
+ } from "./chunk-4WIA45WD.js";
7
7
  import {
8
8
  appendAndEnqueueExclusiveInboundMessage,
9
9
  appendAndEnqueueInboundMessage
10
- } from "./chunk-YFU4DGZY.js";
10
+ } from "./chunk-G4E5WIRL.js";
11
11
  import {
12
12
  buildDeterministicTurnId
13
13
  } from "./chunk-DA2KGZZI.js";
14
14
  import {
15
15
  normalizeSlackConversationId
16
- } from "./chunk-2MRF22J4.js";
16
+ } from "./chunk-BUTAWPUV.js";
17
17
  import {
18
18
  getConversationStore,
19
19
  getDb
20
- } from "./chunk-OKAHLUSU.js";
20
+ } from "./chunk-AKR6W7VV.js";
21
21
  import {
22
22
  juniorConversationParticipants,
23
23
  juniorConversations,
24
24
  juniorIdentities,
25
25
  juniorUsers
26
- } from "./chunk-ZFCO2TMB.js";
26
+ } from "./chunk-IBO4YFFZ.js";
27
27
  import {
28
28
  juniorDestinations
29
29
  } from "./chunk-VFUK3X5B.js";
30
30
  import {
31
31
  getSlackBotToken
32
- } from "./chunk-VWNIDTFR.js";
32
+ } from "./chunk-4Z7B5WVV.js";
33
33
  import {
34
34
  canExposeConversationPayload
35
- } from "./chunk-DVX6U6GI.js";
35
+ } from "./chunk-EYNUOZCN.js";
36
36
  import {
37
37
  logWarn
38
- } from "./chunk-Y4WL4OYD.js";
38
+ } from "./chunk-3ADPXQBL.js";
39
39
 
40
40
  // src/handlers/health.ts
41
41
  function readHealthReport() {
@@ -398,9 +398,6 @@ function buildWebInboundMessage(args) {
398
398
  }
399
399
  },
400
400
  receivedAtMs: nowMs,
401
- // TODO(dcramer): Rename this stored field to publish after deployed
402
- // mailbox readers and writers use the new name.
403
- publishExternally: false,
404
401
  // TODO(dcramer): Replace this string after deployed mailbox readers and
405
402
  // writers use a complete web Source.
406
403
  source: "web"
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getChatConfig
3
- } from "./chunk-VWNIDTFR.js";
3
+ } from "./chunk-4Z7B5WVV.js";
4
4
 
5
5
  // src/chat/state/adapter.ts
6
6
  import { createMemoryState } from "@chat-adapter/state-memory";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  getDb
3
- } from "./chunk-OKAHLUSU.js";
3
+ } from "./chunk-AKR6W7VV.js";
4
4
  import {
5
5
  juniorConversations,
6
6
  juniorTaskExecutions
7
- } from "./chunk-ZFCO2TMB.js";
7
+ } from "./chunk-IBO4YFFZ.js";
8
8
  import {
9
9
  logWarn
10
- } from "./chunk-Y4WL4OYD.js";
10
+ } from "./chunk-3ADPXQBL.js";
11
11
 
12
12
  // src/chat/tasks/execution-stats.ts
13
13
  import {
@@ -139,6 +139,37 @@ async function readTaskExecutionDays(dayCount = 90, options = {}) {
139
139
  }
140
140
  return [...byDate.values()];
141
141
  }
142
+ async function readTaskExecutionHours(hourCount = 24, options = {}) {
143
+ const nowMs = options.nowMs ?? Date.now();
144
+ const end = new Date(nowMs);
145
+ end.setUTCMinutes(0, 0, 0);
146
+ const endMs = end.getTime() + 3599999;
147
+ const startMs = end.getTime() - (hourCount - 1) * 36e5;
148
+ const executionHour = sql`to_char(to_timestamp(${juniorTaskExecutions.executedAtMs} / 1000.0) at time zone 'UTC', 'YYYY-MM-DD"T"HH24')`;
149
+ const rows = await getDb().select({
150
+ count: count(),
151
+ date: executionHour,
152
+ kind: juniorTaskExecutions.kind
153
+ }).from(juniorTaskExecutions).where(
154
+ and(
155
+ gte(juniorTaskExecutions.executedAtMs, startMs),
156
+ lte(juniorTaskExecutions.executedAtMs, endMs),
157
+ eq(juniorTaskExecutions.status, "completed")
158
+ )
159
+ ).groupBy(executionHour, juniorTaskExecutions.kind).orderBy(asc(executionHour), asc(juniorTaskExecutions.kind));
160
+ const byHour = /* @__PURE__ */ new Map();
161
+ for (let offset = 0; offset < hourCount; offset += 1) {
162
+ const date = new Date(startMs + offset * 36e5).toISOString().slice(0, 13);
163
+ byHour.set(date, emptyDay(date));
164
+ }
165
+ for (const row of rows) {
166
+ const hour = byHour.get(row.date);
167
+ if (!hour) continue;
168
+ if (row.kind === "scheduled") hour.scheduled = row.count;
169
+ else if (row.kind === "event") hour.event = row.count;
170
+ }
171
+ return [...byHour.values()];
172
+ }
142
173
  async function readTaskExecutionByConversationId(args) {
143
174
  const namespace = args.namespace ?? "junior";
144
175
  const rows = await getDb().select({
@@ -273,13 +304,52 @@ async function readTaskExecutionStatusDays(args) {
273
304
  }
274
305
  return [...byDate.values()];
275
306
  }
307
+ async function readTaskExecutionStatusHours(args) {
308
+ const hourCount = args.hourCount ?? 24;
309
+ const namespace = args.namespace ?? "junior";
310
+ const nowMs = args.nowMs ?? Date.now();
311
+ const end = new Date(nowMs);
312
+ end.setUTCMinutes(0, 0, 0);
313
+ const endMs = end.getTime() + 3599999;
314
+ const startMs = end.getTime() - (hourCount - 1) * 36e5;
315
+ const executionHour = sql`to_char(to_timestamp(${juniorTaskExecutions.executedAtMs} / 1000.0) at time zone 'UTC', 'YYYY-MM-DD"T"HH24')`;
316
+ const rows = await getDb().select({
317
+ count: count(),
318
+ date: executionHour,
319
+ status: juniorTaskExecutions.status
320
+ }).from(juniorTaskExecutions).where(
321
+ and(
322
+ eq(juniorTaskExecutions.kind, args.kind),
323
+ eq(juniorTaskExecutions.namespace, namespace),
324
+ eq(juniorTaskExecutions.taskId, args.taskId),
325
+ gte(juniorTaskExecutions.executedAtMs, startMs),
326
+ lte(juniorTaskExecutions.executedAtMs, endMs),
327
+ inArray(juniorTaskExecutions.status, [...TASK_EXECUTION_STATUSES])
328
+ )
329
+ ).groupBy(executionHour, juniorTaskExecutions.status).orderBy(asc(executionHour), asc(juniorTaskExecutions.status));
330
+ const byHour = /* @__PURE__ */ new Map();
331
+ for (let offset = 0; offset < hourCount; offset += 1) {
332
+ const date = new Date(startMs + offset * 36e5).toISOString().slice(0, 13);
333
+ byHour.set(date, emptyStatusDay(date));
334
+ }
335
+ for (const row of rows) {
336
+ const hour = byHour.get(row.date);
337
+ if (!hour) continue;
338
+ if (row.status === "completed") hour.completed = row.count;
339
+ else if (row.status === "failed") hour.failed = row.count;
340
+ else if (row.status === "blocked") hour.blocked = row.count;
341
+ }
342
+ return [...byHour.values()];
343
+ }
276
344
 
277
345
  export {
278
346
  recordTaskExecution,
279
347
  readTaskExecutionSummaries,
280
348
  readTaskExecutionDays,
349
+ readTaskExecutionHours,
281
350
  readTaskExecutionByConversationId,
282
351
  readTaskExecutions,
283
352
  readTaskRuns,
284
- readTaskExecutionStatusDays
353
+ readTaskExecutionStatusDays,
354
+ readTaskExecutionStatusHours
285
355
  };
@@ -3,10 +3,10 @@ import {
3
3
  } from "./chunk-PDO5BLNM.js";
4
4
  import {
5
5
  botConfig
6
- } from "./chunk-VWNIDTFR.js";
6
+ } from "./chunk-4Z7B5WVV.js";
7
7
  import {
8
8
  logWarn
9
- } from "./chunk-Y4WL4OYD.js";
9
+ } from "./chunk-3ADPXQBL.js";
10
10
 
11
11
  // src/chat/conversations/structured-events.ts
12
12
  import {