@sentry/junior 0.178.0 → 0.180.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 (138) hide show
  1. package/dist/{agent-hooks-PBT4NNBV.js → agent-hooks-DKDDRKZA.js} +16 -18
  2. package/dist/api/schema.js +0 -1
  3. package/dist/api.js +401 -366
  4. package/dist/app.d.ts +4 -0
  5. package/dist/app.js +783 -1367
  6. package/dist/catalog-runtime-WXKGUF3W.js +14 -0
  7. package/dist/chat/agent/sandbox.d.ts +0 -2
  8. package/dist/chat/api-turns/routing.d.ts +4 -0
  9. package/dist/chat/api-turns/work.d.ts +5 -0
  10. package/dist/chat/config.d.ts +5 -2
  11. package/dist/chat/configuration/defaults.d.ts +1 -1
  12. package/dist/chat/conversations/projection.d.ts +6 -4
  13. package/dist/chat/ingress/message-router.d.ts +3 -0
  14. package/dist/chat/model-profile.d.ts +8 -10
  15. package/dist/chat/pi/conversation-events.d.ts +3 -2
  16. package/dist/chat/plugins/task-queue.d.ts +40 -3
  17. package/dist/chat/plugins/task-runner.d.ts +1 -1
  18. package/dist/chat/queue/callback.d.ts +26 -0
  19. package/dist/chat/queue/sign.d.ts +30 -0
  20. package/dist/chat/sandbox/sandbox.d.ts +0 -2
  21. package/dist/chat/sandbox/session.d.ts +0 -2
  22. package/dist/chat/sandbox/skill-sync.d.ts +1 -1
  23. package/dist/chat/sandbox/snapshot/events.d.ts +23 -0
  24. package/dist/chat/sandbox/snapshot/job-callback.d.ts +5 -0
  25. package/dist/chat/sandbox/snapshot/job-queue.d.ts +26 -0
  26. package/dist/chat/sandbox/snapshot/job-runner.d.ts +11 -0
  27. package/dist/chat/sandbox/snapshot/not-ready-error.d.ts +6 -0
  28. package/dist/chat/sandbox/snapshot/workspace.d.ts +9 -3
  29. package/dist/chat/scheduled-tasks/personal.d.ts +5 -8
  30. package/dist/chat/scheduled-tasks/runs.d.ts +49 -0
  31. package/dist/chat/scheduled-tasks/schedule-intent.d.ts +1 -1
  32. package/dist/chat/scheduled-tasks/tasks.d.ts +27 -0
  33. package/dist/chat/scheduled-tasks/tool-support.d.ts +0 -4
  34. package/dist/chat/scheduled-tasks/tools/create.d.ts +1 -1
  35. package/dist/chat/scheduled-tasks/tools/update.d.ts +1 -1
  36. package/dist/chat/scheduled-tasks/types.d.ts +127 -78
  37. package/dist/chat/services/turn-router.d.ts +4 -3
  38. package/dist/chat/task-execution/queue-signing.d.ts +10 -21
  39. package/dist/chat/task-execution/state.d.ts +48 -0
  40. package/dist/chat/task-execution/store.d.ts +28 -2
  41. package/dist/chat/task-execution/worker.d.ts +4 -1
  42. package/dist/chat/tools/handoff/tool.d.ts +1 -1
  43. package/dist/{chunk-534BO42N.js → chunk-2AYEVN7K.js} +8 -8
  44. package/dist/{chunk-D3UJTX4U.js → chunk-2YIRH4E3.js} +46 -46
  45. package/dist/{chunk-4K6VNP3S.js → chunk-3ILJBWP7.js} +35 -227
  46. package/dist/{chunk-FQ6BMP5P.js → chunk-5PUMIMNQ.js} +2724 -1257
  47. package/dist/{chunk-G3CQEUHI.js → chunk-5TUR4M3M.js} +8 -61
  48. package/dist/{chunk-6ZWRNC4D.js → chunk-6Y5B5PEX.js} +1 -1
  49. package/dist/{chunk-KEQAA42D.js → chunk-6YCEWOLO.js} +4 -4
  50. package/dist/chunk-7H2VZTWN.js +103 -0
  51. package/dist/{chunk-22T3HB44.js → chunk-CCDXTDSY.js} +8 -8
  52. package/dist/{chunk-CGA4ERJ5.js → chunk-CEMMLV5L.js} +1 -1
  53. package/dist/chunk-CK6EINVZ.js +1181 -0
  54. package/dist/{chunk-FIANEE7Z.js → chunk-CM5HNV2W.js} +6 -6
  55. package/dist/{chunk-PRDKO3QB.js → chunk-CP73FKME.js} +144 -218
  56. package/dist/{chunk-XWUJWHFD.js → chunk-DHLOGWYH.js} +36 -36
  57. package/dist/chunk-DKIJ2RP5.js +68 -0
  58. package/dist/{chunk-ABLODWPO.js → chunk-DRHEGXTZ.js} +1 -1
  59. package/dist/{chunk-OOUNJNMR.js → chunk-DWPN6SCH.js} +1 -1
  60. package/dist/chunk-EWHP2IRG.js +209 -0
  61. package/dist/{chunk-ZCHHVTMF.js → chunk-FGC3PHNH.js} +3 -3
  62. package/dist/{chunk-H6ZXBFGX.js → chunk-GA5NS74S.js} +1 -1
  63. package/dist/{chunk-BFLMRTPD.js → chunk-GPXAHUQH.js} +84 -274
  64. package/dist/chunk-GUKXEPMX.js +218 -0
  65. package/dist/{chunk-3ZZEPLLB.js → chunk-I6IFTAPF.js} +108 -76
  66. package/dist/{chunk-RGXOLPWO.js → chunk-IANUX7HX.js} +5 -5
  67. package/dist/{chunk-UMG7M32G.js → chunk-KCL6AWYW.js} +74 -68
  68. package/dist/{chunk-BUGO42R6.js → chunk-L7LTGN4Z.js} +129 -31
  69. package/dist/{chunk-QCCLDJHB.js → chunk-LGVQLNLS.js} +42 -41
  70. package/dist/chunk-M3QYTBQ6.js +55 -0
  71. package/dist/{chunk-AVRWMQ4U.js → chunk-MXEUIGHO.js} +2 -2
  72. package/dist/{chunk-M63DETLL.js → chunk-N7TMSOZH.js} +6 -6
  73. package/dist/{chunk-JVXZ3WDH.js → chunk-O4QYZTDK.js} +33 -32
  74. package/dist/chunk-PEQXYSSE.js +45 -0
  75. package/dist/{chunk-OGRD5PFM.js → chunk-QSO7B5JO.js} +1 -1
  76. package/dist/{chunk-UGWBJAGN.js → chunk-RAZG3YHC.js} +100 -79
  77. package/dist/{chunk-XCNS3CXE.js → chunk-S7YRTOSQ.js} +69 -73
  78. package/dist/{chunk-LAOP4EPL.js → chunk-SDBKZ5LV.js} +108 -5
  79. package/dist/{chunk-RE4XWXBV.js → chunk-TC5DE5KJ.js} +22 -18
  80. package/dist/{chunk-H4HBKISO.js → chunk-TXKUKMVO.js} +1 -1
  81. package/dist/chunk-U5EUCUBH.js +164 -0
  82. package/dist/{chunk-BHHWCNXI.js → chunk-VG722ONZ.js} +18 -16
  83. package/dist/{chunk-U3UDPGZG.js → chunk-VGPPWWHF.js} +16 -16
  84. package/dist/{chunk-AQHSXA3J.js → chunk-WVAMRKYG.js} +9 -54
  85. package/dist/chunk-X6GDDWQH.js +60 -0
  86. package/dist/{chunk-6OYVH66J.js → chunk-ZE2KOV3G.js} +1 -1
  87. package/dist/{chunk-IQRPDKPJ.js → chunk-ZM7ZURJS.js} +4 -3
  88. package/dist/cli/chat.js +47 -43
  89. package/dist/cli/check.js +13 -15
  90. package/dist/cli/env.js +0 -1
  91. package/dist/cli/init.js +0 -1
  92. package/dist/cli/main.js +2 -3
  93. package/dist/cli/plugins.js +18 -20
  94. package/dist/cli/run.js +0 -1
  95. package/dist/cli/snapshot-create.js +14 -16
  96. package/dist/cli/upgrade.js +16 -18
  97. package/dist/{conversation-work-KATFHLG3.js → conversation-work-VIOQ5ZF3.js} +0 -2
  98. package/dist/db/schema/scheduled-tasks.d.ts +29 -5
  99. package/dist/db/schema.d.ts +28 -4
  100. package/dist/{db-QVYOWATH.js → db-6SBHIAJK.js} +8 -10
  101. package/dist/deployment.d.ts +1 -0
  102. package/dist/{discovery-GUFTFBTL.js → discovery-DWVDM7UK.js} +1 -2
  103. package/dist/{experimental-XVDOSRBS.js → experimental-SIJSRDJD.js} +0 -1
  104. package/dist/instrumentation.js +7 -9
  105. package/dist/nitro.js +39 -13
  106. package/dist/{oauth-callback-server-PLPAFXO6.js → oauth-callback-server-WSDQPZZS.js} +34 -32
  107. package/dist/{oauth-relay-3ZU72UGL.js → oauth-relay-5XPVRPYB.js} +0 -1
  108. package/dist/{plugins-HW4VWW6G.js → plugins-YTYJMMJF.js} +1 -2
  109. package/dist/{runner-AGNEIOZS.js → runner-GWTSWESR.js} +39 -33
  110. package/dist/{sandbox-egress-signals-DXOOBSBI.js → sandbox-egress-signals-FIL7EGPR.js} +5 -6
  111. package/dist/{sentry-JMWTS32N.js → sentry-MB3NL3IR.js} +1 -2
  112. package/dist/skills-F32BPFYW.js +27 -0
  113. package/dist/spawn-X5BPP5OE.js +37 -0
  114. package/dist/task-runner-2FPBV5PP.js +32 -0
  115. package/dist/validation-62WO524A.js +17 -0
  116. package/dist/vercel.js +0 -1
  117. package/dist/version.js +1 -2
  118. package/dist/work-3C3CMZ24.js +45 -0
  119. package/dist/worker-MFAI6ZEK.js +22 -0
  120. package/package.json +7 -6
  121. package/dist/catalog-runtime-M7QGKPFZ.js +0 -16
  122. package/dist/chat/plugins/task-callback.d.ts +0 -5
  123. package/dist/chat/plugins/task-message.d.ts +0 -23
  124. package/dist/chat/plugins/task-signing.d.ts +0 -31
  125. package/dist/chat/sandbox/snapshot/waiting-error.d.ts +0 -15
  126. package/dist/chat/scheduled-tasks/store.d.ts +0 -78
  127. package/dist/chat/services/workspace-snapshot-wait.d.ts +0 -27
  128. package/dist/chunk-5I6ORJUY.js +0 -127
  129. package/dist/chunk-6GWA276C.js +0 -72
  130. package/dist/chunk-AGJ4OQ2V.js +0 -51
  131. package/dist/chunk-MLKGABMK.js +0 -9
  132. package/dist/chunk-RGV6KHDM.js +0 -1944
  133. package/dist/chunk-WR76IVA5.js +0 -130
  134. package/dist/skills-U5KQ66EM.js +0 -29
  135. package/dist/spawn-ZRYYZP2B.js +0 -37
  136. package/dist/validation-QE4U45KS.js +0 -19
  137. package/dist/work-ATAXAHJJ.js +0 -45
  138. package/dist/worker-LIL5AOER.js +0 -24
package/dist/api.js CHANGED
@@ -57,22 +57,18 @@ import {
57
57
  createVercelAttachmentStorage,
58
58
  formatSlackConversationRedactedLabel,
59
59
  listPersonalTokens,
60
- lookupSlackUser,
61
60
  readConversationAccessFromSql,
62
61
  readHealthReport,
63
62
  resolveSlackConversationContextFromThreadId,
64
63
  revokePersonalToken,
65
64
  viewerConversationMembership,
66
65
  webActorFromEmail
67
- } from "./chunk-PRDKO3QB.js";
66
+ } from "./chunk-CP73FKME.js";
68
67
  import {
69
68
  buildSentryConversationUrl,
70
69
  getWebAuthorization
71
- } from "./chunk-AVRWMQ4U.js";
72
- import {
73
- cancelHumanFacingPendingMessages,
74
- getConversation
75
- } from "./chunk-BUGO42R6.js";
70
+ } from "./chunk-MXEUIGHO.js";
71
+ import "./chunk-EWHP2IRG.js";
76
72
  import {
77
73
  readTaskExecutionByConversationId,
78
74
  readTaskExecutionDays,
@@ -80,8 +76,9 @@ import {
80
76
  readTaskExecutionSummaries,
81
77
  readTaskExecutions,
82
78
  readTaskRuns
83
- } from "./chunk-4K6VNP3S.js";
84
- import "./chunk-G3CQEUHI.js";
79
+ } from "./chunk-3ILJBWP7.js";
80
+ import "./chunk-M3QYTBQ6.js";
81
+ import "./chunk-5TUR4M3M.js";
85
82
  import {
86
83
  healthReportSchema,
87
84
  pluginOperationalReportFeedSchema,
@@ -89,37 +86,48 @@ import {
89
86
  runtimeInfoReportSchema,
90
87
  skillReportsSchema
91
88
  } from "./chunk-UTL3MHPC.js";
89
+ import "./chunk-U5EUCUBH.js";
92
90
  import {
93
- getVercelConversationWorkQueue
94
- } from "./chunk-WR76IVA5.js";
95
- import "./chunk-JAL3CH4G.js";
96
- import "./chunk-5I6ORJUY.js";
97
- import {
98
- createSchedulerSqlStore,
99
91
  deleteEventTask,
100
92
  eventTaskBelongsToUser,
101
93
  eventTaskTriggerAvailable,
102
94
  getEventTask,
103
95
  getResourceEventCatalog,
96
+ isListedScheduledTask,
104
97
  listEventTasksCreatedBy,
105
98
  listPublicEventTasksForTeams,
106
99
  listPublicScheduledTasksForTeams,
100
+ lookupSlackUser,
101
+ parseScheduledTaskRow,
107
102
  readLiveAttachment,
108
- readStats
109
- } from "./chunk-RGV6KHDM.js";
103
+ readScheduledTask,
104
+ readStats,
105
+ saveScheduledTask
106
+ } from "./chunk-CK6EINVZ.js";
110
107
  import {
111
108
  parseSlackThreadId
112
- } from "./chunk-22T3HB44.js";
109
+ } from "./chunk-CCDXTDSY.js";
110
+ import {
111
+ cancelHumanFacingPendingMessages,
112
+ getConversation
113
+ } from "./chunk-L7LTGN4Z.js";
114
+ import "./chunk-GUKXEPMX.js";
113
115
  import {
114
116
  agentTurnUsageSchema,
115
117
  fallbackShortTitle,
116
118
  hasAgentTurnUsage,
117
119
  renderJuniorNativeConversationEvent
118
- } from "./chunk-BFLMRTPD.js";
120
+ } from "./chunk-GPXAHUQH.js";
119
121
  import {
120
122
  getCachedSnapshot
121
- } from "./chunk-534BO42N.js";
123
+ } from "./chunk-2AYEVN7K.js";
122
124
  import "./chunk-PDO5BLNM.js";
125
+ import {
126
+ getVercelConversationWorkQueue
127
+ } from "./chunk-DKIJ2RP5.js";
128
+ import "./chunk-JAL3CH4G.js";
129
+ import "./chunk-7H2VZTWN.js";
130
+ import "./chunk-ZE2KOV3G.js";
123
131
  import {
124
132
  SANDBOX_RUNTIME,
125
133
  WorkspaceValidationError,
@@ -139,7 +147,7 @@ import {
139
147
  updateWorkspace,
140
148
  withSlackRetries,
141
149
  workspaceRepoCheckoutPath
142
- } from "./chunk-XWUJWHFD.js";
150
+ } from "./chunk-DHLOGWYH.js";
143
151
  import "./chunk-3Y47VMHV.js";
144
152
  import {
145
153
  decodeStoredConversationEvent,
@@ -149,43 +157,42 @@ import {
149
157
  locationFromRow,
150
158
  parseSessionSource,
151
159
  resolveRootConversationId
152
- } from "./chunk-XCNS3CXE.js";
160
+ } from "./chunk-S7YRTOSQ.js";
153
161
  import {
154
162
  conversationReadColumns,
155
163
  juniorConversationEvents,
156
164
  juniorConversationParticipants,
157
165
  juniorConversations,
158
166
  juniorIdentities,
167
+ juniorSchedulerTasks,
159
168
  juniorUsers
160
- } from "./chunk-ZCHHVTMF.js";
169
+ } from "./chunk-FGC3PHNH.js";
161
170
  import {
162
171
  create,
163
172
  hash
164
- } from "./chunk-AQHSXA3J.js";
165
- import "./chunk-H6ZXBFGX.js";
166
- import "./chunk-3ZZEPLLB.js";
173
+ } from "./chunk-WVAMRKYG.js";
174
+ import "./chunk-GA5NS74S.js";
167
175
  import {
168
176
  juniorDestinations
169
177
  } from "./chunk-VFUK3X5B.js";
170
- import "./chunk-KEQAA42D.js";
171
- import "./chunk-ABLODWPO.js";
172
- import "./chunk-D3UJTX4U.js";
173
- import "./chunk-CGA4ERJ5.js";
178
+ import "./chunk-I6IFTAPF.js";
179
+ import "./chunk-6YCEWOLO.js";
180
+ import "./chunk-DRHEGXTZ.js";
181
+ import "./chunk-2YIRH4E3.js";
182
+ import "./chunk-CEMMLV5L.js";
174
183
  import {
175
184
  parseSlackChannelId,
176
185
  parseSlackMessageTs,
177
186
  parseSlackTeamId
178
- } from "./chunk-M63DETLL.js";
187
+ } from "./chunk-N7TMSOZH.js";
188
+ import "./chunk-DWPN6SCH.js";
189
+ import "./chunk-TXKUKMVO.js";
179
190
  import {
180
191
  logException,
181
192
  logWarn
182
- } from "./chunk-UGWBJAGN.js";
183
- import "./chunk-6GWA276C.js";
184
- import "./chunk-OOUNJNMR.js";
185
- import "./chunk-H4HBKISO.js";
186
- import "./chunk-AGJ4OQ2V.js";
187
- import "./chunk-IQRPDKPJ.js";
188
- import "./chunk-MLKGABMK.js";
193
+ } from "./chunk-RAZG3YHC.js";
194
+ import "./chunk-PEQXYSSE.js";
195
+ import "./chunk-ZM7ZURJS.js";
189
196
 
190
197
  // src/api.ts
191
198
  import { Hono as Hono8 } from "hono";
@@ -213,7 +220,7 @@ function emptyResponse(status = 204) {
213
220
  }
214
221
  function throwApiError(status, message2, cause) {
215
222
  throw new HTTPException(status, {
216
- ...cause === void 0 ? {} : { cause },
223
+ ...cause === void 0 ? void 0 : { cause },
217
224
  message: message2,
218
225
  res: jsonResponse(apiErrorSchema, { error: message2 }, { status })
219
226
  });
@@ -371,7 +378,7 @@ async function requireConversationAttachment(args) {
371
378
  function actorFromViewer(viewer) {
372
379
  const normalized = viewer.email.trim().toLowerCase();
373
380
  return webActorFromEmail(normalized, {
374
- ...viewer.displayName ? { fullName: viewer.displayName } : {},
381
+ ...viewer.displayName ? { fullName: viewer.displayName } : void 0,
375
382
  userName: normalized.split("@")[0] || normalized
376
383
  });
377
384
  }
@@ -382,7 +389,7 @@ async function createConversationForViewer(viewer, body) {
382
389
  actor: actorFromViewer(viewer),
383
390
  idempotencyKey: body.idempotencyKey,
384
391
  message: body.message,
385
- ...body.visibility ? { visibility: body.visibility } : {}
392
+ ...body.visibility ? { visibility: body.visibility } : void 0
386
393
  },
387
394
  {
388
395
  conversationStore: getConversationStore(),
@@ -606,9 +613,9 @@ function usageFromRow(row) {
606
613
  ...Object.fromEntries(
607
614
  Object.entries(components).filter(([, value]) => value !== void 0)
608
615
  ),
609
- ...row.reasoningTokens === null ? {} : { reasoningTokens: row.reasoningTokens },
610
- ...row.totalTokens === null ? {} : { totalTokens: row.totalTokens },
611
- ...Object.keys(definedCost).length > 0 ? { cost: definedCost } : {}
616
+ ...row.reasoningTokens === null ? void 0 : { reasoningTokens: row.reasoningTokens },
617
+ ...row.totalTokens === null ? void 0 : { totalTokens: row.totalTokens },
618
+ ...Object.keys(definedCost).length > 0 ? { cost: definedCost } : void 0
612
619
  };
613
620
  return hasAgentTurnUsage(result) ? agentTurnUsageSchema.parse(result) : void 0;
614
621
  }
@@ -789,7 +796,7 @@ function sanitizeModelContentPart(value) {
789
796
  if (!media.success) return void 0;
790
797
  return {
791
798
  type: media.data.type,
792
- ...media.data.mimeType ? { mimeType: media.data.mimeType } : {}
799
+ ...media.data.mimeType ? { mimeType: media.data.mimeType } : void 0
793
800
  };
794
801
  }
795
802
  function modelVisibleToolOutput(content) {
@@ -804,9 +811,9 @@ function reportMessageActorIdentity(data) {
804
811
  const author = reportingMessageAuthorSchema.safeParse(data.meta?.author);
805
812
  if (!author.success) return void 0;
806
813
  const actorIdentity = {
807
- ...author.data.fullName ? { fullName: author.data.fullName } : {},
808
- ...author.data.userId ? { slackUserId: author.data.userId } : {},
809
- ...author.data.userName ? { slackUserName: author.data.userName } : {}
814
+ ...author.data.fullName ? { fullName: author.data.fullName } : void 0,
815
+ ...author.data.userId ? { slackUserId: author.data.userId } : void 0,
816
+ ...author.data.userName ? { slackUserName: author.data.userName } : void 0
810
817
  };
811
818
  return Object.keys(actorIdentity).length > 0 ? actorIdentity : void 0;
812
819
  }
@@ -823,7 +830,7 @@ function reportToolCalls(args) {
823
830
  status: "running",
824
831
  startedAt: new Date(args.createdAtMs).toISOString(),
825
832
  startedSeq: args.seq,
826
- ...args.canExposePayload && call.data.arguments !== void 0 ? { input: call.data.arguments } : {}
833
+ ...args.canExposePayload && call.data.arguments !== void 0 ? { input: call.data.arguments } : void 0
827
834
  }
828
835
  ];
829
836
  });
@@ -886,8 +893,8 @@ function reportToolResult(args) {
886
893
  ...args.start ? {
887
894
  startedAt: new Date(args.start.createdAtMs).toISOString(),
888
895
  startedSeq: args.start.seq
889
- } : {},
890
- ...args.canExposePayload && output !== void 0 ? { output } : {}
896
+ } : void 0,
897
+ ...args.canExposePayload && output !== void 0 ? { output } : void 0
891
898
  }
892
899
  ]
893
900
  };
@@ -913,7 +920,7 @@ function reportEventData(args) {
913
920
  namespace: data.namespace,
914
921
  name: data.name,
915
922
  version: data.version,
916
- ...data.turnId ? { turnId: data.turnId } : {},
923
+ ...data.turnId ? { turnId: data.turnId } : void 0,
917
924
  presentation
918
925
  };
919
926
  }
@@ -924,10 +931,10 @@ function reportEventData(args) {
924
931
  type: "message",
925
932
  messageId: data.messageId,
926
933
  role: data.role,
927
- ...data.meta?.source === "web" || data.meta?.source === "slack" ? { source: data.meta.source } : {},
928
- ...actorIdentity ? { actorIdentity } : {},
929
- ...typeof data.meta?.eventType === "string" ? { eventType: data.meta.eventType } : {},
930
- ...typeof data.meta?.explicitMention === "boolean" ? { explicitMention: data.meta.explicitMention } : {},
934
+ ...data.meta?.source === "web" || data.meta?.source === "slack" ? { source: data.meta.source } : void 0,
935
+ ...actorIdentity ? { actorIdentity } : void 0,
936
+ ...typeof data.meta?.eventType === "string" ? { eventType: data.meta.eventType } : void 0,
937
+ ...typeof data.meta?.explicitMention === "boolean" ? { explicitMention: data.meta.explicitMention } : void 0,
931
938
  ...args.canExposePayload ? { text: data.text } : { redacted: true }
932
939
  };
933
940
  }
@@ -941,7 +948,7 @@ function reportEventData(args) {
941
948
  type: "turn_lifecycle",
942
949
  turnId: data.turnId,
943
950
  state: "started",
944
- ...data.inputMessageIds.length > 0 ? { inputMessageIds: data.inputMessageIds } : {}
951
+ ...data.inputMessageIds.length > 0 ? { inputMessageIds: data.inputMessageIds } : void 0
945
952
  };
946
953
  case "turn_context":
947
954
  if (!args.canExposePayload) {
@@ -969,9 +976,9 @@ function reportEventData(args) {
969
976
  turnId: data.turnId,
970
977
  modelProfile: data.modelProfile,
971
978
  modelId: data.modelId,
972
- ...data.costUsd !== void 0 ? { costUsd: data.costUsd } : {},
979
+ ...data.costUsd !== void 0 ? { costUsd: data.costUsd } : void 0,
973
980
  reasoningLevel: data.reasoningLevel,
974
- ...data.confidence !== void 0 ? { confidence: data.confidence } : {},
981
+ ...data.confidence !== void 0 ? { confidence: data.confidence } : void 0,
975
982
  source: data.source
976
983
  };
977
984
  case "guardian_action_reviewed":
@@ -1002,8 +1009,8 @@ function reportEventData(args) {
1002
1009
  type: "compaction",
1003
1010
  modelProfile: data.modelProfile,
1004
1011
  modelId: data.modelId,
1005
- ...args.canExposePayload && data.summary ? { summary: data.summary } : {},
1006
- ...data.details ? { details: data.details } : {}
1012
+ ...args.canExposePayload && data.summary ? { summary: data.summary } : void 0,
1013
+ ...data.details ? { details: data.details } : void 0
1007
1014
  };
1008
1015
  default:
1009
1016
  return void 0;
@@ -1048,7 +1055,7 @@ function projectConversationReportEventPage(args) {
1048
1055
  data = reportAssistantMessage(reportArgs) ?? reportToolResult({
1049
1056
  canExposePayload: args.canExposePayload,
1050
1057
  message: event.data,
1051
- ...start && start.seq < event.seq ? { start } : {}
1058
+ ...start && start.seq < event.seq ? { start } : void 0
1052
1059
  });
1053
1060
  } else if (event.data.type === "tool_execution_started") {
1054
1061
  toolStarts.set(event.data.toolCallId, {
@@ -1081,7 +1088,7 @@ function projectConversationReportEventPage(args) {
1081
1088
  childConversationId: event.data.childConversationId,
1082
1089
  subagentKind: event.data.subagentKind,
1083
1090
  status: "running",
1084
- ...event.data.parentToolCallId ? { parentToolCallId: event.data.parentToolCallId } : {}
1091
+ ...event.data.parentToolCallId ? { parentToolCallId: event.data.parentToolCallId } : void 0
1085
1092
  };
1086
1093
  } else if (event.data.type === "subagent_ended") {
1087
1094
  const started = subagentStarts.get(event.data.subagentInvocationId);
@@ -1092,7 +1099,7 @@ function projectConversationReportEventPage(args) {
1092
1099
  startedAt: new Date(started.createdAtMs).toISOString(),
1093
1100
  childConversationId: started.data.childConversationId,
1094
1101
  subagentKind: started.data.subagentKind,
1095
- ...started.data.parentToolCallId ? { parentToolCallId: started.data.parentToolCallId } : {},
1102
+ ...started.data.parentToolCallId ? { parentToolCallId: started.data.parentToolCallId } : void 0,
1096
1103
  status: event.data.outcome === "success" ? "completed" : event.data.outcome
1097
1104
  };
1098
1105
  subagentStarts.delete(event.data.subagentInvocationId);
@@ -1102,9 +1109,9 @@ function projectConversationReportEventPage(args) {
1102
1109
  type: "handoff",
1103
1110
  modelProfile: event.data.modelProfile,
1104
1111
  modelId: event.data.modelId,
1105
- ...event.data.reasoningLevel ? { reasoningLevel: event.data.reasoningLevel } : {},
1106
- ...event.data.triggeringToolCallId ? { triggeringToolCallId: event.data.triggeringToolCallId } : {},
1107
- ...args.canExposePayload && event.data.summary ? { summary: event.data.summary } : {}
1112
+ ...event.data.reasoningLevel ? { reasoningLevel: event.data.reasoningLevel } : void 0,
1113
+ ...event.data.triggeringToolCallId ? { triggeringToolCallId: event.data.triggeringToolCallId } : void 0,
1114
+ ...args.canExposePayload && event.data.summary ? { summary: event.data.summary } : void 0
1108
1115
  };
1109
1116
  } else {
1110
1117
  data = reportEventData({
@@ -1166,7 +1173,7 @@ function decodeConversationEventRow(row) {
1166
1173
  schemaVersion: row.schemaVersion,
1167
1174
  seq: row.seq,
1168
1175
  historyVersion: row.historyVersion,
1169
- ...row.idempotencyKey ? { idempotencyKey: row.idempotencyKey } : {},
1176
+ ...row.idempotencyKey ? { idempotencyKey: row.idempotencyKey } : void 0,
1170
1177
  createdAtMs: row.createdAt.getTime(),
1171
1178
  type: row.type,
1172
1179
  payload: row.payload
@@ -1228,7 +1235,7 @@ async function readConversationEventPage(executor, args) {
1228
1235
  const events = projected.slice(-args.limit);
1229
1236
  return {
1230
1237
  events,
1231
- ...projected.length > events.length && events[0] ? { previousSeq: events[0].seq } : {}
1238
+ ...projected.length > events.length && events[0] ? { previousSeq: events[0].seq } : void 0
1232
1239
  };
1233
1240
  }
1234
1241
 
@@ -1297,10 +1304,10 @@ function sourceUrlFromConversation(args) {
1297
1304
  function actorIdentityReport(actor) {
1298
1305
  if (!actor) return void 0;
1299
1306
  const identity = {
1300
- ...actor.email !== void 0 ? { email: actor.email } : {},
1301
- ...actor.fullName !== void 0 ? { fullName: actor.fullName } : {},
1302
- ...actor.slackUserId !== void 0 ? { slackUserId: actor.slackUserId } : {},
1303
- ...actor.slackUserName !== void 0 ? { slackUserName: actor.slackUserName } : {}
1307
+ ...actor.email !== void 0 ? { email: actor.email } : void 0,
1308
+ ...actor.fullName !== void 0 ? { fullName: actor.fullName } : void 0,
1309
+ ...actor.slackUserId !== void 0 ? { slackUserId: actor.slackUserId } : void 0,
1310
+ ...actor.slackUserName !== void 0 ? { slackUserName: actor.slackUserName } : void 0
1304
1311
  };
1305
1312
  return Object.keys(identity).length > 0 ? identity : void 0;
1306
1313
  }
@@ -1319,7 +1326,7 @@ function titleFromConversation(args) {
1319
1326
  const slackConversation = resolveSlackConversationContextFromThreadId({
1320
1327
  threadId: args.conversation.conversationId,
1321
1328
  channelName: effectiveChannelName,
1322
- ...args.visibility ? { visibility: args.visibility } : {}
1329
+ ...args.visibility ? { visibility: args.visibility } : void 0
1323
1330
  });
1324
1331
  const privateLabel = args.canViewPrivateContent ? void 0 : privateConversationLabel(slackConversation);
1325
1332
  return privateLabel ?? args.conversation.title ?? slackStatsLocationLabel({
@@ -1336,7 +1343,7 @@ function channelNameFromConversation(conversation, canViewPrivateContent, visibi
1336
1343
  const slackConversation = resolveSlackConversationContextFromThreadId({
1337
1344
  threadId: conversation.conversationId,
1338
1345
  channelName: effectiveChannelName,
1339
- ...visibility ? { visibility } : {}
1346
+ ...visibility ? { visibility } : void 0
1340
1347
  });
1341
1348
  if (!canViewPrivateContent) {
1342
1349
  return privateConversationLabel(slackConversation);
@@ -1373,7 +1380,7 @@ function conversationSummaryFromStoredConversation(args) {
1373
1380
  const sourceUrl = sourceUrlFromConversation({
1374
1381
  canViewPrivateContent,
1375
1382
  conversation,
1376
- ...args.teamDomainByTeamId ? { teamDomainByTeamId: args.teamDomainByTeamId } : {}
1383
+ ...args.teamDomainByTeamId ? { teamDomainByTeamId: args.teamDomainByTeamId } : void 0
1377
1384
  });
1378
1385
  const slackThread = parseSlackThreadId(conversation.conversationId);
1379
1386
  const channelName = channelNameFromConversation(
@@ -1395,7 +1402,7 @@ function conversationSummaryFromStoredConversation(args) {
1395
1402
  visibility
1396
1403
  }),
1397
1404
  isParticipant: args.access?.isParticipant ?? false,
1398
- ...visibility ? { visibility } : {},
1405
+ ...visibility ? { visibility } : void 0,
1399
1406
  lastProgressAt: new Date(
1400
1407
  conversation.execution.updatedAtMs ?? conversation.updatedAtMs
1401
1408
  ).toISOString(),
@@ -1403,15 +1410,15 @@ function conversationSummaryFromStoredConversation(args) {
1403
1410
  startedAt: new Date(conversation.createdAtMs).toISOString(),
1404
1411
  status: statusFromConversation(conversation),
1405
1412
  surface,
1406
- ...args.auxiliaryCosts ? { auxiliaryCosts: args.auxiliaryCosts } : {},
1407
- ...usage3 ? { cumulativeUsage: usage3 } : {},
1408
- ...actorIdentity ? { actorIdentity } : {},
1409
- ...sourceUrl ? { sourceUrl } : {},
1413
+ ...args.auxiliaryCosts ? { auxiliaryCosts: args.auxiliaryCosts } : void 0,
1414
+ ...usage3 ? { cumulativeUsage: usage3 } : void 0,
1415
+ ...actorIdentity ? { actorIdentity } : void 0,
1416
+ ...sourceUrl ? { sourceUrl } : void 0,
1410
1417
  archivedAt: args.archivedAtMs === void 0 ? null : new Date(args.archivedAtMs).toISOString(),
1411
- ...slackThread ? { channel: slackThread.channelId } : {},
1412
- ...channelName ? { channelName } : {},
1413
- ...channelNameRedacted ? { channelNameRedacted: true } : {},
1414
- ...args.locationId && !channelNameRedacted ? { locationId: args.locationId } : {}
1418
+ ...slackThread ? { channel: slackThread.channelId } : void 0,
1419
+ ...channelName ? { channelName } : void 0,
1420
+ ...channelNameRedacted ? { channelNameRedacted: true } : void 0,
1421
+ ...args.locationId && !channelNameRedacted ? { locationId: args.locationId } : void 0
1415
1422
  };
1416
1423
  }
1417
1424
 
@@ -1448,16 +1455,16 @@ function usageFromAggregate(row) {
1448
1455
  componentTotal += value;
1449
1456
  }
1450
1457
  const cost2 = {
1451
- ...row.costInput === null ? {} : { input: row.costInput },
1452
- ...row.costOutput === null ? {} : { output: row.costOutput },
1453
- ...row.costCacheRead === null ? {} : { cacheRead: row.costCacheRead },
1454
- ...row.costCacheWrite === null ? {} : { cacheWrite: row.costCacheWrite },
1455
- ...row.costTotal === null ? {} : { total: row.costTotal }
1458
+ ...row.costInput === null ? void 0 : { input: row.costInput },
1459
+ ...row.costOutput === null ? void 0 : { output: row.costOutput },
1460
+ ...row.costCacheRead === null ? void 0 : { cacheRead: row.costCacheRead },
1461
+ ...row.costCacheWrite === null ? void 0 : { cacheWrite: row.costCacheWrite },
1462
+ ...row.costTotal === null ? void 0 : { total: row.costTotal }
1456
1463
  };
1457
1464
  const result = {
1458
1465
  ...row.totalOnlyTokens === null ? components : { totalTokens: row.totalOnlyTokens + componentTotal },
1459
- ...row.reasoningTokens === null ? {} : { reasoningTokens: row.reasoningTokens },
1460
- ...Object.keys(cost2).length === 0 ? {} : { cost: cost2 }
1466
+ ...row.reasoningTokens === null ? void 0 : { reasoningTokens: row.reasoningTokens },
1467
+ ...Object.keys(cost2).length === 0 ? void 0 : { cost: cost2 }
1461
1468
  };
1462
1469
  return hasAgentTurnUsage(result) ? result : void 0;
1463
1470
  }
@@ -1511,7 +1518,7 @@ async function readRootConversationMetricsFromSql(db, rootConversationIds) {
1511
1518
  return [
1512
1519
  [
1513
1520
  row.rootConversationId,
1514
- { durationMs: row.durationMs, ...usage3 ? { usage: usage3 } : {} }
1521
+ { durationMs: row.durationMs, ...usage3 ? { usage: usage3 } : void 0 }
1515
1522
  ]
1516
1523
  ];
1517
1524
  })
@@ -1844,11 +1851,11 @@ function conversationFromRow(row) {
1844
1851
  const actorFullName = row.userDisplayName?.trim() ? row.userDisplayName : row.identityDisplayName;
1845
1852
  const actor = row.identityProvider === "slack" ? {
1846
1853
  platform: "slack",
1847
- ...row.identityEmail ? { email: row.identityEmail } : {},
1848
- ...actorFullName ? { fullName: actorFullName } : {},
1849
- ...row.identitySubjectId ? { slackUserId: row.identitySubjectId } : {},
1850
- ...row.identityHandle ? { slackUserName: row.identityHandle } : {},
1851
- ...row.identityTenantId ? { teamId: row.identityTenantId } : {}
1854
+ ...row.identityEmail ? { email: row.identityEmail } : void 0,
1855
+ ...actorFullName ? { fullName: actorFullName } : void 0,
1856
+ ...row.identitySubjectId ? { slackUserId: row.identitySubjectId } : void 0,
1857
+ ...row.identityHandle ? { slackUserName: row.identityHandle } : void 0,
1858
+ ...row.identityTenantId ? { teamId: row.identityTenantId } : void 0
1852
1859
  } : void 0;
1853
1860
  const location = locationFromRow(row.destination);
1854
1861
  return {
@@ -1859,16 +1866,16 @@ function conversationFromRow(row) {
1859
1866
  updatedAtMs: value.updatedAt.getTime(),
1860
1867
  execution: {
1861
1868
  status: value.executionStatus,
1862
- ...value.runId ? { runId: value.runId } : {},
1863
- ...value.executionUpdatedAt ? { updatedAtMs: value.executionUpdatedAt.getTime() } : {}
1869
+ ...value.runId ? { runId: value.runId } : void 0,
1870
+ ...value.executionUpdatedAt ? { updatedAtMs: value.executionUpdatedAt.getTime() } : void 0
1864
1871
  },
1865
- ...actor ? { actor } : {},
1866
- ...location ? { location } : {},
1867
- ...value.channelName ? { channelName: value.channelName } : {},
1868
- ...value.source ? { source: value.source } : {},
1869
- ...sessionSource ? { sessionSource } : {},
1870
- ...value.title ? { title: value.title } : {},
1871
- ...value.transcriptPurgedAt ? { transcriptPurgedAtMs: value.transcriptPurgedAt.getTime() } : {}
1872
+ ...actor ? { actor } : void 0,
1873
+ ...location ? { location } : void 0,
1874
+ ...value.channelName ? { channelName: value.channelName } : void 0,
1875
+ ...value.source ? { source: value.source } : void 0,
1876
+ ...sessionSource ? { sessionSource } : void 0,
1877
+ ...value.title ? { title: value.title } : void 0,
1878
+ ...value.transcriptPurgedAt ? { transcriptPurgedAtMs: value.transcriptPurgedAt.getTime() } : void 0
1872
1879
  };
1873
1880
  }
1874
1881
  async function readConversationRecordFromSql(conversationId) {
@@ -1894,7 +1901,7 @@ async function readConversationRecordFromSql(conversationId) {
1894
1901
  return row ? {
1895
1902
  conversation: conversationFromRow(row),
1896
1903
  durationMs: row.conversation.durationMs,
1897
- ...row.destination?.visibility === "public" ? { locationId: row.destination.id } : {},
1904
+ ...row.destination?.visibility === "public" ? { locationId: row.destination.id } : void 0,
1898
1905
  usage: row.conversation.usage,
1899
1906
  rootConversationId: row.conversation.rootConversationId
1900
1907
  } : void 0;
@@ -1978,30 +1985,30 @@ async function readConversationFeedFromSql(options = {}) {
1978
1985
  conversation.conversationId
1979
1986
  );
1980
1987
  const summary = conversationSummaryFromStoredConversation({
1981
- ...archivedAtMs === void 0 ? {} : { archivedAtMs },
1988
+ ...archivedAtMs === void 0 ? void 0 : { archivedAtMs },
1982
1989
  conversation,
1983
1990
  access,
1984
1991
  auxiliaryCosts: auxiliaryCostsByRoot.get(conversation.conversationId),
1985
1992
  durationMs: metrics?.durationMs ?? row.conversation.durationMs,
1986
1993
  teamDomainByTeamId,
1987
- ...row.destination?.visibility === "public" ? { locationId: row.destination.id } : {},
1994
+ ...row.destination?.visibility === "public" ? { locationId: row.destination.id } : void 0,
1988
1995
  usage: metrics?.usage ?? row.conversation.usage ?? void 0
1989
1996
  });
1990
1997
  const work = {
1991
- ...assignedWork.has(conversation.conversationId) ? { assignedWork: true } : {},
1998
+ ...assignedWork.has(conversation.conversationId) ? { assignedWork: true } : void 0,
1992
1999
  ...conversationWork.finishedAtById[conversation.conversationId] ? {
1993
2000
  finishedWorkAt: conversationWork.finishedAtById[conversation.conversationId]
1994
- } : {},
1995
- ...unfinishedWork.has(conversation.conversationId) ? { unfinishedWork: true } : {}
2001
+ } : void 0,
2002
+ ...unfinishedWork.has(conversation.conversationId) ? { unfinishedWork: true } : void 0
1996
2003
  };
1997
2004
  const annotations = access?.canViewPrivateContent ? annotationsByConversation.get(conversation.conversationId) ?? [] : [];
1998
2005
  return {
1999
2006
  ...summary,
2000
2007
  ...work,
2001
- ...annotations.length > 0 ? { annotations } : {},
2008
+ ...annotations.length > 0 ? { annotations } : void 0,
2002
2009
  ...sidebarAnnotationsByConversation[conversation.conversationId] ? {
2003
2010
  sidebarAnnotations: sidebarAnnotationsByConversation[conversation.conversationId]
2004
- } : {},
2011
+ } : void 0,
2005
2012
  isPriority: isConversationPriority(
2006
2013
  {
2007
2014
  lastSeenAt: summary.lastSeenAt,
@@ -2025,9 +2032,10 @@ async function readConversationFeed(options = {}) {
2025
2032
  }
2026
2033
 
2027
2034
  // src/chat/tasks/read.ts
2028
- import { and as and8, eq as eq8, or as or3 } from "drizzle-orm";
2035
+ import { and as and9, eq as eq9, or as or4 } from "drizzle-orm";
2029
2036
 
2030
2037
  // src/chat/scheduled-tasks/personal.ts
2038
+ import { and as and8, desc as desc3, eq as eq8, inArray as inArray5, lt as lt2, notInArray, or as or3, sql as sql8 } from "drizzle-orm";
2031
2039
  import { z as z3 } from "zod";
2032
2040
  var cursorSchema = z3.object({
2033
2041
  createdAtMs: z3.number().finite(),
@@ -2069,43 +2077,77 @@ function encodeCursor(task, query) {
2069
2077
  JSON.stringify({
2070
2078
  createdAtMs: task.createdAtMs,
2071
2079
  id: task.id,
2072
- ...query ? { query } : {},
2080
+ ...query ? { query } : void 0,
2073
2081
  version: 1
2074
2082
  }),
2075
2083
  "utf8"
2076
2084
  ).toString("base64url");
2077
2085
  }
2078
- function createViewerScheduledTasks(store, user) {
2086
+ async function deleteViewerScheduledTask(db, user, id, nowMs = Date.now()) {
2079
2087
  const identityIds = new Set(user.identities.map((identity) => identity.id));
2088
+ const task = await readScheduledTask(db, id);
2089
+ if (!task || task.status === "deleted" || !identityIds.has(task.creatorIdentityId)) {
2090
+ throw new PersonalScheduledTaskNotFoundError();
2091
+ }
2092
+ await saveScheduledTask(db, {
2093
+ ...task,
2094
+ nextRunAtMs: void 0,
2095
+ runNowAtMs: void 0,
2096
+ status: "deleted",
2097
+ updatedAtMs: nowMs
2098
+ });
2099
+ }
2100
+ async function listViewerScheduledTasks(db, user, input) {
2101
+ const identityIds = user.identities.map((identity) => identity.id);
2102
+ if (identityIds.length === 0) return { tasks: [] };
2103
+ const query = normalizeQuery(input.query);
2104
+ const cursor = decodeCursor(input.cursor, query);
2105
+ const tasks = [];
2106
+ let before = cursor;
2107
+ const fetchLimit = input.limit + 1;
2108
+ while (tasks.length < fetchLimit) {
2109
+ const cursorFilter = before ? or3(
2110
+ lt2(juniorSchedulerTasks.createdAtMs, before.createdAtMs),
2111
+ and8(
2112
+ eq8(juniorSchedulerTasks.createdAtMs, before.createdAtMs),
2113
+ lt2(juniorSchedulerTasks.id, before.id)
2114
+ )
2115
+ ) : void 0;
2116
+ const search = query ? or3(
2117
+ sql8`strpos(lower(${juniorSchedulerTasks.title}), ${query}) > 0`,
2118
+ sql8`strpos(lower(${juniorSchedulerTasks.record}->'task'->>'text'), ${query}) > 0`,
2119
+ sql8`strpos(lower(${juniorSchedulerTasks.record}->'schedule'->>'description'), ${query}) > 0`,
2120
+ sql8`strpos(lower(${juniorSchedulerTasks.record}->'schedule'->>'timezone'), ${query}) > 0`,
2121
+ sql8`strpos(lower(${juniorSchedulerTasks.status}), ${query}) > 0`
2122
+ ) : void 0;
2123
+ const rows = await db.select({
2124
+ createdAtMs: juniorSchedulerTasks.createdAtMs,
2125
+ creatorIdentityId: juniorSchedulerTasks.creatorIdentityId,
2126
+ id: juniorSchedulerTasks.id,
2127
+ record: juniorSchedulerTasks.record,
2128
+ title: juniorSchedulerTasks.title
2129
+ }).from(juniorSchedulerTasks).where(
2130
+ and8(
2131
+ notInArray(juniorSchedulerTasks.status, ["deleted", "paused"]),
2132
+ inArray5(juniorSchedulerTasks.creatorIdentityId, identityIds),
2133
+ cursorFilter,
2134
+ search
2135
+ )
2136
+ ).orderBy(
2137
+ desc3(juniorSchedulerTasks.createdAtMs),
2138
+ desc3(juniorSchedulerTasks.id)
2139
+ ).limit(fetchLimit);
2140
+ tasks.push(
2141
+ ...rows.map(parseScheduledTaskRow).filter(isListedScheduledTask)
2142
+ );
2143
+ if (rows.length < fetchLimit) break;
2144
+ const last = rows.at(-1);
2145
+ before = { createdAtMs: last.createdAtMs, id: last.id };
2146
+ }
2147
+ const page = tasks.slice(0, input.limit);
2080
2148
  return {
2081
- async delete(id, nowMs = Date.now()) {
2082
- const task = await store.getTask(id);
2083
- if (!task || task.status === "deleted" || !identityIds.has(task.creatorIdentityId)) {
2084
- throw new PersonalScheduledTaskNotFoundError();
2085
- }
2086
- await store.saveTask({
2087
- ...task,
2088
- nextRunAtMs: void 0,
2089
- runNowAtMs: void 0,
2090
- status: "deleted",
2091
- updatedAtMs: nowMs
2092
- });
2093
- },
2094
- async list(input) {
2095
- const query = normalizeQuery(input.query);
2096
- const cursor = decodeCursor(input.cursor, query);
2097
- const matching = await store.listTasksCreatedBy({
2098
- ...cursor ? { before: cursor } : {},
2099
- identityIds: [...identityIds],
2100
- limit: input.limit + 1,
2101
- ...query ? { query } : {}
2102
- });
2103
- const tasks = matching.slice(0, input.limit);
2104
- return {
2105
- tasks,
2106
- ...matching.length > input.limit && tasks.length > 0 ? { nextCursor: encodeCursor(tasks.at(-1), query) } : {}
2107
- };
2108
- }
2149
+ tasks: page,
2150
+ ...tasks.length > input.limit && page.length > 0 ? { nextCursor: encodeCursor(page.at(-1), query) } : void 0
2109
2151
  };
2110
2152
  }
2111
2153
 
@@ -2135,16 +2177,16 @@ async function creatorProfileEmails(candidates) {
2135
2177
  email: juniorUsers.primaryEmailNormalized,
2136
2178
  slackUserId: juniorIdentities.providerSubjectId,
2137
2179
  teamId: juniorIdentities.providerTenantId
2138
- }).from(juniorIdentities).innerJoin(juniorUsers, eq8(juniorUsers.id, juniorIdentities.userId)).where(
2139
- and8(
2140
- eq8(juniorIdentities.kind, "user"),
2141
- eq8(juniorIdentities.provider, "slack"),
2142
- eq8(juniorIdentities.emailVerified, true),
2143
- or3(
2180
+ }).from(juniorIdentities).innerJoin(juniorUsers, eq9(juniorUsers.id, juniorIdentities.userId)).where(
2181
+ and9(
2182
+ eq9(juniorIdentities.kind, "user"),
2183
+ eq9(juniorIdentities.provider, "slack"),
2184
+ eq9(juniorIdentities.emailVerified, true),
2185
+ or4(
2144
2186
  ...[...selectors.values()].map(
2145
- (selector) => and8(
2146
- eq8(juniorIdentities.providerTenantId, selector.teamId),
2147
- eq8(juniorIdentities.providerSubjectId, selector.slackUserId)
2187
+ (selector) => and9(
2188
+ eq9(juniorIdentities.providerTenantId, selector.teamId),
2189
+ eq9(juniorIdentities.providerSubjectId, selector.slackUserId)
2148
2190
  )
2149
2191
  )
2150
2192
  )
@@ -2180,12 +2222,12 @@ async function destinationDetails(destinations) {
2180
2222
  providerTenantId: juniorDestinations.providerTenantId,
2181
2223
  visibility: juniorDestinations.visibility
2182
2224
  }).from(juniorDestinations).where(
2183
- or3(
2225
+ or4(
2184
2226
  ...[...selectors.values()].map(
2185
- (destination) => and8(
2186
- eq8(juniorDestinations.provider, "slack"),
2187
- eq8(juniorDestinations.providerTenantId, destination.teamId),
2188
- eq8(juniorDestinations.providerDestinationId, destination.channelId)
2227
+ (destination) => and9(
2228
+ eq9(juniorDestinations.provider, "slack"),
2229
+ eq9(juniorDestinations.providerTenantId, destination.teamId),
2230
+ eq9(juniorDestinations.providerDestinationId, destination.channelId)
2189
2231
  )
2190
2232
  )
2191
2233
  )
@@ -2206,8 +2248,8 @@ async function destinationDetails(destinations) {
2206
2248
  }
2207
2249
  function executionSummaryFields(stats) {
2208
2250
  return {
2209
- ...stats?.lastConversationId ? { lastConversationId: stats.lastConversationId } : {},
2210
- ...stats?.lastExecutedAtMs ? { lastRunAt: new Date(stats.lastExecutedAtMs).toISOString() } : {},
2251
+ ...stats?.lastConversationId ? { lastConversationId: stats.lastConversationId } : void 0,
2252
+ ...stats?.lastExecutedAtMs ? { lastRunAt: new Date(stats.lastExecutedAtMs).toISOString() } : void 0,
2211
2253
  runsLast7Days: stats?.runsLast7Days ?? 0,
2212
2254
  totalRuns: stats?.totalRuns ?? 0
2213
2255
  };
@@ -2221,7 +2263,7 @@ function scheduledTaskSummary(task, ownedByViewer, destination, stats, createdBy
2221
2263
  return {
2222
2264
  createdAt: new Date(task.createdAtMs).toISOString(),
2223
2265
  createdBy: creatorLabel(task.createdBy),
2224
- ...createdByEmail ? { createdByEmail } : {},
2266
+ ...createdByEmail ? { createdByEmail } : void 0,
2225
2267
  destination: {
2226
2268
  channelId: task.destination.channelId,
2227
2269
  label: destination.label,
@@ -2232,7 +2274,7 @@ function scheduledTaskSummary(task, ownedByViewer, destination, stats, createdBy
2232
2274
  instruction,
2233
2275
  kind: "scheduled",
2234
2276
  ...executionSummaryFields(stats),
2235
- ...nextRunAtMs !== void 0 ? { nextRunAt: new Date(nextRunAtMs).toISOString() } : {},
2277
+ ...nextRunAtMs !== void 0 ? { nextRunAt: new Date(nextRunAtMs).toISOString() } : void 0,
2236
2278
  ownedByViewer,
2237
2279
  schedule: displayText(task.schedule.description, "Schedule unavailable"),
2238
2280
  status: task.status,
@@ -2244,7 +2286,7 @@ function eventTaskSummary(task, ownedByViewer, destination, stats, createdByEmai
2244
2286
  return {
2245
2287
  createdAt: new Date(task.createdAtMs).toISOString(),
2246
2288
  createdBy: creatorLabel(task.createdBy),
2247
- ...createdByEmail ? { createdByEmail } : {},
2289
+ ...createdByEmail ? { createdByEmail } : void 0,
2248
2290
  destination: {
2249
2291
  channelId: task.destination.channelId,
2250
2292
  label: destination.label,
@@ -2278,7 +2320,7 @@ async function resolveViewerTaskCandidate(user, kind, id) {
2278
2320
  const identityIds = new Set(user.identities.map((identity) => identity.id));
2279
2321
  const teamIds = viewerTeamIds(user);
2280
2322
  if (kind === "scheduled") {
2281
- const task2 = await createSchedulerSqlStore(db).getTask(id);
2323
+ const task2 = await readScheduledTask(db, id);
2282
2324
  if (!task2 || task2.status === "deleted") return void 0;
2283
2325
  const ownedByViewer2 = identityIds.has(task2.creatorIdentityId);
2284
2326
  const destinations2 = await destinationDetails([task2.destination]);
@@ -2343,13 +2385,10 @@ async function taskSummaryForCandidate(candidate) {
2343
2385
  }
2344
2386
  async function readViewerTasks(user) {
2345
2387
  const db = getDb();
2346
- const schedulerStore = createSchedulerSqlStore(db);
2347
2388
  const identityIds = new Set(user.identities.map((identity) => identity.id));
2348
2389
  const teamIds = viewerTeamIds(user);
2349
2390
  const [scheduledPage, publicScheduled, eventTasks, publicEventTasks] = await Promise.all([
2350
- createViewerScheduledTasks(schedulerStore, user).list({
2351
- limit: TASK_FETCH_LIMIT
2352
- }),
2391
+ listViewerScheduledTasks(db, user, { limit: TASK_FETCH_LIMIT }),
2353
2392
  listPublicScheduledTasksForTeams(db, teamIds, TASK_FETCH_LIMIT),
2354
2393
  listEventTasksCreatedBy(db, user, TASK_FETCH_LIMIT),
2355
2394
  listPublicEventTasksForTeams(db, teamIds, TASK_FETCH_LIMIT)
@@ -2531,10 +2570,7 @@ async function readConversationSourceTask(args) {
2531
2570
  async function deleteViewerTask(user, kind, id) {
2532
2571
  if (kind === "scheduled") {
2533
2572
  try {
2534
- await createViewerScheduledTasks(
2535
- createSchedulerSqlStore(getDb()),
2536
- user
2537
- ).delete(id);
2573
+ await deleteViewerScheduledTask(getDb(), user, id);
2538
2574
  return;
2539
2575
  } catch (error) {
2540
2576
  if (error instanceof PersonalScheduledTaskNotFoundError) {
@@ -2561,12 +2597,12 @@ function projectConversationDetail(args) {
2561
2597
  return {
2562
2598
  ...conversationSummaryFromStoredConversation({
2563
2599
  access: args.access,
2564
- ...args.archivedAtMs === void 0 ? {} : { archivedAtMs: args.archivedAtMs },
2600
+ ...args.archivedAtMs === void 0 ? void 0 : { archivedAtMs: args.archivedAtMs },
2565
2601
  auxiliaryCosts: args.auxiliaryCosts,
2566
2602
  conversation,
2567
2603
  durationMs: args.durationMs,
2568
- ...args.locationId ? { locationId: args.locationId } : {},
2569
- ...args.teamDomainByTeamId ? { teamDomainByTeamId: args.teamDomainByTeamId } : {},
2604
+ ...args.locationId ? { locationId: args.locationId } : void 0,
2605
+ ...args.teamDomainByTeamId ? { teamDomainByTeamId: args.teamDomainByTeamId } : void 0,
2570
2606
  usage: args.usage
2571
2607
  }),
2572
2608
  annotations: canExposePayload ? args.annotations : [],
@@ -2576,15 +2612,15 @@ function projectConversationDetail(args) {
2576
2612
  conversationId,
2577
2613
  seq: args.previousSeq
2578
2614
  })
2579
- } : {},
2580
- ...modelUsage.length > 0 ? { modelUsage } : {},
2615
+ } : void 0,
2616
+ ...modelUsage.length > 0 ? { modelUsage } : void 0,
2581
2617
  eventHistory: conversationEventHistory({
2582
2618
  canExposePayload,
2583
- ...transcriptPurgedAtMs === void 0 ? {} : { transcriptPurgedAtMs }
2619
+ ...transcriptPurgedAtMs === void 0 ? void 0 : { transcriptPurgedAtMs }
2584
2620
  }),
2585
2621
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
2586
- ...sentryConversationUrl ? { sentryConversationUrl } : {},
2587
- ...args.sourceTask ? { sourceTask: args.sourceTask } : {}
2622
+ ...sentryConversationUrl ? { sentryConversationUrl } : void 0,
2623
+ ...args.sourceTask ? { sourceTask: args.sourceTask } : void 0
2588
2624
  };
2589
2625
  }
2590
2626
  async function readConversationDetailFromSql(conversationId, options) {
@@ -2617,7 +2653,7 @@ async function readConversationDetailFromSql(conversationId, options) {
2617
2653
  ),
2618
2654
  readConversationSourceTask({
2619
2655
  conversationId,
2620
- ...options.viewer ? { viewer: options.viewer } : {}
2656
+ ...options.viewer ? { viewer: options.viewer } : void 0
2621
2657
  }),
2622
2658
  resolveSlackTeamDomains(
2623
2659
  record.conversation.sessionSource?.platform === "slack" ? [record.conversation.sessionSource.teamId] : []
@@ -2633,15 +2669,15 @@ async function readConversationDetailFromSql(conversationId, options) {
2633
2669
  return projectConversationDetail({
2634
2670
  ...record,
2635
2671
  access,
2636
- ...archivedAtMs === void 0 ? {} : { archivedAtMs },
2672
+ ...archivedAtMs === void 0 ? void 0 : { archivedAtMs },
2637
2673
  annotations,
2638
2674
  auxiliaryCosts: auxiliaryCostsByConversation.get(conversationId),
2639
2675
  durationMs: metrics?.durationMs ?? record.durationMs,
2640
2676
  events: page.events,
2641
2677
  modelUsage,
2642
- ...sourceTask ? { sourceTask } : {},
2678
+ ...sourceTask ? { sourceTask } : void 0,
2643
2679
  teamDomainByTeamId,
2644
- ...page.previousSeq === void 0 ? {} : { previousSeq: page.previousSeq },
2680
+ ...page.previousSeq === void 0 ? void 0 : { previousSeq: page.previousSeq },
2645
2681
  usage: metrics?.usage ?? record.usage ?? void 0
2646
2682
  });
2647
2683
  }
@@ -2680,9 +2716,9 @@ async function readConversationEvents(conversationId, beforeValue, options = {})
2680
2716
  events: page.events,
2681
2717
  eventHistory: conversationEventHistory({
2682
2718
  canExposePayload,
2683
- ...transcriptPurgedAtMs === void 0 ? {} : { transcriptPurgedAtMs }
2719
+ ...transcriptPurgedAtMs === void 0 ? void 0 : { transcriptPurgedAtMs }
2684
2720
  }),
2685
- ...page.previousSeq === void 0 ? {} : {
2721
+ ...page.previousSeq === void 0 ? void 0 : {
2686
2722
  previousCursor: encodeConversationCursor({
2687
2723
  conversationId,
2688
2724
  seq: page.previousSeq
@@ -2712,8 +2748,8 @@ async function cancelConversationPendingMessagesForViewer(viewer, conversationId
2712
2748
  try {
2713
2749
  const result = await cancelHumanFacingPendingMessages({
2714
2750
  conversationId,
2715
- ...body.inboundMessageIds ? { inboundMessageIds: body.inboundMessageIds } : {},
2716
- ...body.receivedBefore ? { receivedBeforeMs: Date.parse(body.receivedBefore) } : {},
2751
+ ...body.inboundMessageIds ? { inboundMessageIds: body.inboundMessageIds } : void 0,
2752
+ ...body.receivedBefore ? { receivedBeforeMs: Date.parse(body.receivedBefore) } : void 0,
2717
2753
  conversationStore: getConversationStore()
2718
2754
  });
2719
2755
  return {
@@ -2756,7 +2792,7 @@ function isoFromMs(value) {
2756
2792
  function actorIdentityFromApiMetadata(metadata) {
2757
2793
  return {
2758
2794
  email: metadata.authorEmail.trim().toLowerCase(),
2759
- ...metadata.authorFullName ? { fullName: metadata.authorFullName } : {}
2795
+ ...metadata.authorFullName ? { fullName: metadata.authorFullName } : void 0
2760
2796
  };
2761
2797
  }
2762
2798
  async function actorIdentityFromSlackMetadata(metadata, teamId) {
@@ -2769,9 +2805,9 @@ async function actorIdentityFromSlackMetadata(metadata, teamId) {
2769
2805
  const email = profile?.email?.trim().toLowerCase();
2770
2806
  return {
2771
2807
  slackUserId,
2772
- ...slackUserName ? { slackUserName } : {},
2773
- ...fullName ? { fullName } : {},
2774
- ...email ? { email } : {}
2808
+ ...slackUserName ? { slackUserName } : void 0,
2809
+ ...fullName ? { fullName } : void 0,
2810
+ ...email ? { email } : void 0
2775
2811
  };
2776
2812
  }
2777
2813
  async function projectPendingMessage(message2, canExposePayload) {
@@ -2828,7 +2864,7 @@ async function projectPendingMessage(message2, canExposePayload) {
2828
2864
  receivedAt: isoFromMs(message2.receivedAtMs),
2829
2865
  role: "user",
2830
2866
  source: "slack",
2831
- ...actorIdentity ? { actorIdentity } : {},
2867
+ ...actorIdentity ? { actorIdentity } : void 0,
2832
2868
  text
2833
2869
  };
2834
2870
  }
@@ -2862,7 +2898,7 @@ async function readConversationPendingMessages(conversationId, options = {}) {
2862
2898
  completionText: authorization.completionText,
2863
2899
  label: authorization.label
2864
2900
  }
2865
- } : {},
2901
+ } : void 0,
2866
2902
  conversationId,
2867
2903
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
2868
2904
  messages
@@ -2875,20 +2911,20 @@ async function requireConversationPendingMessages(conversationId, options = {})
2875
2911
  }
2876
2912
 
2877
2913
  // src/api/conversations/stats.query.ts
2878
- import { and as and9, eq as eq9, gte, isNull as isNull4, lte, sql as sql9 } from "drizzle-orm";
2914
+ import { and as and10, eq as eq10, gte, isNull as isNull4, lte, sql as sql10 } from "drizzle-orm";
2879
2915
  import { alias as alias3 } from "drizzle-orm/pg-core";
2880
2916
 
2881
2917
  // src/api/conversations/aggregate.ts
2882
- import { sql as sql8 } from "drizzle-orm";
2918
+ import { sql as sql9 } from "drizzle-orm";
2883
2919
  function usageTokenValue(source, field) {
2884
- return sql8`CASE
2920
+ return sql9`CASE
2885
2921
  WHEN ${source.usage}->>${field} IS NOT NULL
2886
2922
  THEN (${source.usage}->>${field})::double precision
2887
2923
  ELSE NULL
2888
2924
  END`;
2889
2925
  }
2890
2926
  function tokenValue(source) {
2891
- return sql8`
2927
+ return sql9`
2892
2928
  CASE
2893
2929
  WHEN COALESCE(
2894
2930
  ${source.usage}->>'inputTokens',
@@ -2907,7 +2943,7 @@ function tokenValue(source) {
2907
2943
  `;
2908
2944
  }
2909
2945
  function costValue(source) {
2910
- return sql8`
2946
+ return sql9`
2911
2947
  CASE
2912
2948
  WHEN ${source.usage}->'cost'->>'total' IS NOT NULL
2913
2949
  THEN (${source.usage}->'cost'->>'total')::double precision
@@ -2928,34 +2964,34 @@ function costValue(source) {
2928
2964
  function conversationAggregateColumns(sources) {
2929
2965
  const metrics = sources?.metrics ?? juniorConversations;
2930
2966
  const roots = sources?.roots ?? juniorConversations;
2931
- const conversationCount = sources ? sql8`COUNT(DISTINCT ${roots.conversationId})` : sql8`COUNT(*)`;
2967
+ const conversationCount = sources ? sql9`COUNT(DISTINCT ${roots.conversationId})` : sql9`COUNT(*)`;
2932
2968
  return {
2933
- active: sql8`${conversationCount} FILTER (
2969
+ active: sql9`${conversationCount} FILTER (
2934
2970
  WHERE ${roots.executionStatus} NOT IN ('idle', 'failed')
2935
2971
  )::integer`,
2936
- conversations: sql8`${conversationCount}::integer`,
2937
- cachedInputTokens: sql8`SUM(${usageTokenValue(metrics, "cachedInputTokens")})::double precision`,
2938
- costUsd: sql8`SUM(${costValue(metrics)})::double precision`,
2939
- durationMs: sql8`COALESCE(SUM(${metrics.durationMs}), 0)::double precision`,
2940
- failed: sql8`${conversationCount} FILTER (
2972
+ conversations: sql9`${conversationCount}::integer`,
2973
+ cachedInputTokens: sql9`SUM(${usageTokenValue(metrics, "cachedInputTokens")})::double precision`,
2974
+ costUsd: sql9`SUM(${costValue(metrics)})::double precision`,
2975
+ durationMs: sql9`COALESCE(SUM(${metrics.durationMs}), 0)::double precision`,
2976
+ failed: sql9`${conversationCount} FILTER (
2941
2977
  WHERE ${roots.executionStatus} = 'failed'
2942
2978
  )::integer`,
2943
- inputTokens: sql8`SUM(${usageTokenValue(metrics, "inputTokens")})::double precision`,
2944
- tokens: sql8`SUM(${tokenValue(metrics)})::double precision`
2979
+ inputTokens: sql9`SUM(${usageTokenValue(metrics, "inputTokens")})::double precision`,
2980
+ tokens: sql9`SUM(${tokenValue(metrics)})::double precision`
2945
2981
  };
2946
2982
  }
2947
2983
  function conversationRangeColumns() {
2948
2984
  return {
2949
- firstSeenAt: sql8`MIN(${juniorConversations.createdAt})`.mapWith(
2985
+ firstSeenAt: sql9`MIN(${juniorConversations.createdAt})`.mapWith(
2950
2986
  juniorConversations.createdAt
2951
2987
  ),
2952
- lastSeenAt: sql8`MAX(${juniorConversations.lastActivityAt})`.mapWith(
2988
+ lastSeenAt: sql9`MAX(${juniorConversations.lastActivityAt})`.mapWith(
2953
2989
  juniorConversations.lastActivityAt
2954
2990
  )
2955
2991
  };
2956
2992
  }
2957
2993
  function conversationActiveDaysColumn() {
2958
- return sql8`COUNT(DISTINCT (${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC')::date)::integer`;
2994
+ return sql9`COUNT(DISTINCT (${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC')::date)::integer`;
2959
2995
  }
2960
2996
 
2961
2997
  // src/api/conversations/stats.query.ts
@@ -3019,7 +3055,7 @@ function statsItems(map) {
3019
3055
  );
3020
3056
  }
3021
3057
  function statsWhere(start, end) {
3022
- return and9(
3058
+ return and10(
3023
3059
  isNull4(juniorConversations.parentConversationId),
3024
3060
  gte(juniorConversations.lastActivityAt, start),
3025
3061
  lte(juniorConversations.lastActivityAt, end)
@@ -3046,10 +3082,10 @@ function metricDays(rows, endMs) {
3046
3082
  conversations: row?.conversations ?? 0,
3047
3083
  date,
3048
3084
  durationMs: row?.durationMs ?? 0,
3049
- ...row?.cachedInputTokens !== null && row?.cachedInputTokens !== void 0 ? { cachedInputTokens: row.cachedInputTokens } : {},
3050
- ...row?.costUsd !== null && row?.costUsd !== void 0 ? { costUsd: addUsd(void 0, row.costUsd) } : {},
3051
- ...row?.inputTokens !== null && row?.inputTokens !== void 0 ? { inputTokens: row.inputTokens } : {},
3052
- ...row?.tokens !== null && row?.tokens !== void 0 ? { tokens: row.tokens } : {}
3085
+ ...row?.cachedInputTokens !== null && row?.cachedInputTokens !== void 0 ? { cachedInputTokens: row.cachedInputTokens } : void 0,
3086
+ ...row?.costUsd !== null && row?.costUsd !== void 0 ? { costUsd: addUsd(void 0, row.costUsd) } : void 0,
3087
+ ...row?.inputTokens !== null && row?.inputTokens !== void 0 ? { inputTokens: row.inputTokens } : void 0,
3088
+ ...row?.tokens !== null && row?.tokens !== void 0 ? { tokens: row.tokens } : void 0
3053
3089
  });
3054
3090
  }
3055
3091
  return days;
@@ -3082,7 +3118,7 @@ function guardianStats(rows, endMs) {
3082
3118
  date,
3083
3119
  deny: row?.deny ?? 0,
3084
3120
  requests: row?.requests ?? 0,
3085
- ...row?.costUsd !== null && row?.costUsd !== void 0 ? { costUsd: row.costUsd } : {}
3121
+ ...row?.costUsd !== null && row?.costUsd !== void 0 ? { costUsd: row.costUsd } : void 0
3086
3122
  });
3087
3123
  }
3088
3124
  return {
@@ -3091,19 +3127,19 @@ function guardianStats(rows, endMs) {
3091
3127
  deny,
3092
3128
  metricDays: metricDays2,
3093
3129
  requests,
3094
- ...costUsd !== void 0 ? { costUsd } : {}
3130
+ ...costUsd !== void 0 ? { costUsd } : void 0
3095
3131
  };
3096
3132
  }
3097
3133
  async function aggregateStats(db, start, end) {
3098
3134
  const where = statsWhere(start, end);
3099
- const activityDate = sql9`TO_CHAR(
3135
+ const activityDate = sql10`TO_CHAR(
3100
3136
  ${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
3101
3137
  'YYYY-MM-DD'
3102
3138
  )`;
3103
3139
  const [totalsRows, actorRows, locationRows, metricRows] = await Promise.all([
3104
3140
  db.select(treeAggregateColumns).from(juniorConversations).innerJoin(
3105
3141
  treeConversation,
3106
- eq9(
3142
+ eq10(
3107
3143
  treeConversation.rootConversationId,
3108
3144
  juniorConversations.conversationId
3109
3145
  )
@@ -3118,14 +3154,14 @@ async function aggregateStats(db, start, end) {
3118
3154
  ...treeAggregateColumns
3119
3155
  }).from(juniorConversations).innerJoin(
3120
3156
  treeConversation,
3121
- eq9(
3157
+ eq10(
3122
3158
  treeConversation.rootConversationId,
3123
3159
  juniorConversations.conversationId
3124
3160
  )
3125
3161
  ).leftJoin(
3126
3162
  juniorIdentities,
3127
- eq9(juniorIdentities.id, juniorConversations.actorIdentityId)
3128
- ).leftJoin(juniorUsers, eq9(juniorUsers.id, juniorIdentities.userId)).where(where).groupBy(
3163
+ eq10(juniorIdentities.id, juniorConversations.actorIdentityId)
3164
+ ).leftJoin(juniorUsers, eq10(juniorUsers.id, juniorIdentities.userId)).where(where).groupBy(
3129
3165
  juniorIdentities.displayName,
3130
3166
  juniorIdentities.emailNormalized,
3131
3167
  juniorIdentities.handle,
@@ -3143,13 +3179,13 @@ async function aggregateStats(db, start, end) {
3143
3179
  ...treeAggregateColumns
3144
3180
  }).from(juniorConversations).innerJoin(
3145
3181
  treeConversation,
3146
- eq9(
3182
+ eq10(
3147
3183
  treeConversation.rootConversationId,
3148
3184
  juniorConversations.conversationId
3149
3185
  )
3150
3186
  ).leftJoin(
3151
3187
  juniorDestinations,
3152
- eq9(juniorDestinations.id, juniorConversations.destinationId)
3188
+ eq10(juniorDestinations.id, juniorConversations.destinationId)
3153
3189
  ).where(where).groupBy(
3154
3190
  juniorConversations.channelName,
3155
3191
  juniorConversations.source,
@@ -3168,7 +3204,7 @@ async function aggregateStats(db, start, end) {
3168
3204
  tokens: treeAggregateColumns.tokens
3169
3205
  }).from(juniorConversations).innerJoin(
3170
3206
  treeConversation,
3171
- eq9(
3207
+ eq10(
3172
3208
  treeConversation.rootConversationId,
3173
3209
  juniorConversations.conversationId
3174
3210
  )
@@ -3177,26 +3213,26 @@ async function aggregateStats(db, start, end) {
3177
3213
  return { actorRows, locationRows, metricRows, totals: totalsRows[0] };
3178
3214
  }
3179
3215
  async function aggregateGuardianStats(db, start, end) {
3180
- const date = sql9`TO_CHAR(
3216
+ const date = sql10`TO_CHAR(
3181
3217
  ${juniorConversationEvents.createdAt} AT TIME ZONE 'UTC',
3182
3218
  'YYYY-MM-DD'
3183
3219
  )`;
3184
- const decision = sql9`${juniorConversationEvents.payload}->>'decision'`;
3185
- const cost2 = sql9`CASE
3220
+ const decision = sql10`${juniorConversationEvents.payload}->>'decision'`;
3221
+ const cost2 = sql10`CASE
3186
3222
  WHEN jsonb_typeof(${juniorConversationEvents.payload}->'costUsd') = 'number'
3187
3223
  THEN (${juniorConversationEvents.payload}->>'costUsd')::double precision
3188
3224
  ELSE NULL
3189
3225
  END`;
3190
3226
  return await db.select({
3191
- allow: sql9`COUNT(*) FILTER (WHERE ${decision} = 'allow')::integer`,
3192
- ask: sql9`COUNT(*) FILTER (WHERE ${decision} = 'ask')::integer`,
3193
- costUsd: sql9`SUM(${cost2})::double precision`,
3227
+ allow: sql10`COUNT(*) FILTER (WHERE ${decision} = 'allow')::integer`,
3228
+ ask: sql10`COUNT(*) FILTER (WHERE ${decision} = 'ask')::integer`,
3229
+ costUsd: sql10`SUM(${cost2})::double precision`,
3194
3230
  date,
3195
- deny: sql9`COUNT(*) FILTER (WHERE ${decision} = 'deny')::integer`,
3196
- requests: sql9`COUNT(*)::integer`
3231
+ deny: sql10`COUNT(*) FILTER (WHERE ${decision} = 'deny')::integer`,
3232
+ requests: sql10`COUNT(*)::integer`
3197
3233
  }).from(juniorConversationEvents).where(
3198
- and9(
3199
- eq9(juniorConversationEvents.type, "guardian_action_reviewed"),
3234
+ and10(
3235
+ eq10(juniorConversationEvents.type, "guardian_action_reviewed"),
3200
3236
  gte(juniorConversationEvents.createdAt, start),
3201
3237
  lte(juniorConversationEvents.createdAt, end)
3202
3238
  )
@@ -3220,7 +3256,7 @@ async function readConversationStatsFromSql() {
3220
3256
  }
3221
3257
  return {
3222
3258
  active: totals?.active ?? 0,
3223
- ...totals?.cachedInputTokens !== null && totals?.cachedInputTokens !== void 0 ? { cachedInputTokens: totals.cachedInputTokens } : {},
3259
+ ...totals?.cachedInputTokens !== null && totals?.cachedInputTokens !== void 0 ? { cachedInputTokens: totals.cachedInputTokens } : void 0,
3224
3260
  conversations: totals?.conversations ?? 0,
3225
3261
  durationMs: totals?.durationMs ?? 0,
3226
3262
  failed: totals?.failed ?? 0,
@@ -3230,9 +3266,9 @@ async function readConversationStatsFromSql() {
3230
3266
  locations: statsItems(locations),
3231
3267
  actors: statsItems(actors),
3232
3268
  source: "conversation_index",
3233
- ...totals?.costUsd !== null && totals?.costUsd !== void 0 ? { costUsd: addUsd(void 0, totals.costUsd) } : {},
3234
- ...totals?.inputTokens !== null && totals?.inputTokens !== void 0 ? { inputTokens: totals.inputTokens } : {},
3235
- ...totals?.tokens !== null && totals?.tokens !== void 0 ? { tokens: totals.tokens } : {},
3269
+ ...totals?.costUsd !== null && totals?.costUsd !== void 0 ? { costUsd: addUsd(void 0, totals.costUsd) } : void 0,
3270
+ ...totals?.inputTokens !== null && totals?.inputTokens !== void 0 ? { inputTokens: totals.inputTokens } : void 0,
3271
+ ...totals?.tokens !== null && totals?.tokens !== void 0 ? { tokens: totals.tokens } : void 0,
3236
3272
  windowEnd: end.toISOString(),
3237
3273
  windowStart: start.toISOString()
3238
3274
  };
@@ -3261,9 +3297,9 @@ function createConversationRoutes(options) {
3261
3297
  return jsonResponse(
3262
3298
  conversationFeedSchema,
3263
3299
  await readConversationFeed({
3264
- ...actorEmail ? { actorEmail } : {},
3300
+ ...actorEmail ? { actorEmail } : void 0,
3265
3301
  status,
3266
- ...viewer ? { viewer } : {}
3302
+ ...viewer ? { viewer } : void 0
3267
3303
  })
3268
3304
  );
3269
3305
  }
@@ -3353,7 +3389,7 @@ function createConversationRoutes(options) {
3353
3389
  const viewer = context.get("viewer");
3354
3390
  const report = await readConversationEvents(conversationId, before, {
3355
3391
  limit,
3356
- ...viewer ? { viewer } : {}
3392
+ ...viewer ? { viewer } : void 0
3357
3393
  });
3358
3394
  if (!report) throwApiError(404, "Conversation not found.");
3359
3395
  return jsonResponse(conversationEventPageSchema, report);
@@ -3418,7 +3454,7 @@ function createConversationRoutes(options) {
3418
3454
  attachmentId,
3419
3455
  conversationId,
3420
3456
  storage: options.attachmentStorage,
3421
- ...viewer ? { viewer } : {}
3457
+ ...viewer ? { viewer } : void 0
3422
3458
  });
3423
3459
  return new Response(opened.body, {
3424
3460
  headers: conversationAttachmentHeaders({
@@ -3447,7 +3483,7 @@ function createConversationRoutes(options) {
3447
3483
  const viewer = context.get("viewer");
3448
3484
  const report = await readConversationDetail(conversationId, {
3449
3485
  ...query,
3450
- ...viewer ? { viewer } : {}
3486
+ ...viewer ? { viewer } : void 0
3451
3487
  });
3452
3488
  if (!report) throwApiError(404, "Conversation not found.");
3453
3489
  return jsonResponse(conversationDetailReportSchema, report);
@@ -3460,7 +3496,7 @@ function createConversationRoutes(options) {
3460
3496
  import { Hono as Hono2 } from "hono";
3461
3497
 
3462
3498
  // src/api/locations/query.ts
3463
- import { and as and10, asc as asc3, desc as desc3, eq as eq10, gte as gte2, isNull as isNull5, sql as sql10 } from "drizzle-orm";
3499
+ import { and as and11, asc as asc3, desc as desc4, eq as eq11, gte as gte2, isNull as isNull5, sql as sql11 } from "drizzle-orm";
3464
3500
  import { alias as alias4 } from "drizzle-orm/pg-core";
3465
3501
 
3466
3502
  // src/api/conversations/reporting.ts
@@ -3487,10 +3523,10 @@ function slackLocationLabel(args) {
3487
3523
  }
3488
3524
  function actorFromRow(row) {
3489
3525
  const actor = {
3490
- ...row.email ? { email: row.email } : {},
3491
- ...row.fullName ? { fullName: row.fullName } : {},
3492
- ...row.providerSubjectId ? { slackUserId: row.providerSubjectId } : {},
3493
- ...row.handle ? { slackUserName: row.handle } : {}
3526
+ ...row.email ? { email: row.email } : void 0,
3527
+ ...row.fullName ? { fullName: row.fullName } : void 0,
3528
+ ...row.providerSubjectId ? { slackUserId: row.providerSubjectId } : void 0,
3529
+ ...row.handle ? { slackUserName: row.handle } : void 0
3494
3530
  };
3495
3531
  return Object.keys(actor).length ? actor : void 0;
3496
3532
  }
@@ -3503,18 +3539,18 @@ function summaryFromRow(row, options = {}) {
3503
3539
  updatedAtMs: row.updatedAt.getTime(),
3504
3540
  execution: {
3505
3541
  status: row.executionStatus,
3506
- ...row.executionUpdatedAt ? { updatedAtMs: row.executionUpdatedAt.getTime() } : {}
3542
+ ...row.executionUpdatedAt ? { updatedAtMs: row.executionUpdatedAt.getTime() } : void 0
3507
3543
  },
3508
- ...actor ? { actor } : {},
3509
- ...row.channelName ? { channelName: row.channelName } : {},
3510
- ...row.source ? { source: row.source } : {},
3511
- ...row.title ? { title: row.title } : {}
3544
+ ...actor ? { actor } : void 0,
3545
+ ...row.channelName ? { channelName: row.channelName } : void 0,
3546
+ ...row.source ? { source: row.source } : void 0,
3547
+ ...row.title ? { title: row.title } : void 0
3512
3548
  };
3513
3549
  return conversationSummaryFromStoredConversation({
3514
3550
  access: options.access,
3515
3551
  conversation,
3516
3552
  durationMs: options.metrics?.durationMs ?? row.durationMs,
3517
- ...options.access?.visibility === "public" && row.destinationId ? { locationId: row.destinationId } : {},
3553
+ ...options.access?.visibility === "public" && row.destinationId ? { locationId: row.destinationId } : void 0,
3518
3554
  usage: options.metrics?.usage ?? row.usage ?? void 0
3519
3555
  });
3520
3556
  }
@@ -3568,10 +3604,10 @@ function topLevelWhere() {
3568
3604
  return isNull5(juniorConversations.parentConversationId);
3569
3605
  }
3570
3606
  function publicLocationWhere(destinationId) {
3571
- return and10(
3607
+ return and11(
3572
3608
  topLevelWhere(),
3573
- eq10(juniorDestinations.id, destinationId),
3574
- eq10(juniorDestinations.visibility, "public")
3609
+ eq11(juniorDestinations.id, destinationId),
3610
+ eq11(juniorDestinations.visibility, "public")
3575
3611
  );
3576
3612
  }
3577
3613
  function locationColumns() {
@@ -3622,28 +3658,28 @@ async function directoryRows(db) {
3622
3658
  ...conversationRangeColumns()
3623
3659
  }).from(juniorConversations).innerJoin(
3624
3660
  treeConversation2,
3625
- eq10(
3661
+ eq11(
3626
3662
  treeConversation2.rootConversationId,
3627
3663
  juniorConversations.conversationId
3628
3664
  )
3629
3665
  ).leftJoin(
3630
3666
  juniorDestinations,
3631
- eq10(juniorDestinations.id, juniorConversations.destinationId)
3667
+ eq11(juniorDestinations.id, juniorConversations.destinationId)
3632
3668
  ).where(topLevelWhere()).groupBy(...locationGroupBy());
3633
3669
  }
3634
3670
  async function directoryActivityRows(db, start) {
3635
- const date = sql10`TO_CHAR(
3671
+ const date = sql11`TO_CHAR(
3636
3672
  ${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
3637
3673
  'YYYY-MM-DD'
3638
3674
  )`;
3639
3675
  return db.select({
3640
- conversations: sql10`COUNT(*)::integer`,
3676
+ conversations: sql11`COUNT(*)::integer`,
3641
3677
  date,
3642
3678
  visibility: juniorDestinations.visibility
3643
3679
  }).from(juniorConversations).leftJoin(
3644
3680
  juniorDestinations,
3645
- eq10(juniorDestinations.id, juniorConversations.destinationId)
3646
- ).where(and10(topLevelWhere(), gte2(juniorConversations.lastActivityAt, start))).groupBy(date, juniorDestinations.visibility);
3681
+ eq11(juniorDestinations.id, juniorConversations.destinationId)
3682
+ ).where(and11(topLevelWhere(), gte2(juniorConversations.lastActivityAt, start))).groupBy(date, juniorDestinations.visibility);
3647
3683
  }
3648
3684
  function directoryActivityDays(rows, nowMs) {
3649
3685
  const days = /* @__PURE__ */ new Map();
@@ -3716,7 +3752,7 @@ async function recentLocationRows(db, locationId) {
3716
3752
  createdAt: juniorConversations.createdAt,
3717
3753
  destinationId: juniorDestinations.id,
3718
3754
  durationMs: juniorConversations.durationMs,
3719
- email: sql10`COALESCE(
3755
+ email: sql11`COALESCE(
3720
3756
  ${juniorUsers.primaryEmailNormalized},
3721
3757
  ${juniorIdentities.email}
3722
3758
  )`,
@@ -3725,7 +3761,7 @@ async function recentLocationRows(db, locationId) {
3725
3761
  fullName: juniorUsers.displayName,
3726
3762
  handle: juniorIdentities.handle,
3727
3763
  lastActivityAt: juniorConversations.lastActivityAt,
3728
- providerSubjectId: sql10`CASE
3764
+ providerSubjectId: sql11`CASE
3729
3765
  WHEN ${juniorIdentities.provider} = 'slack'
3730
3766
  THEN ${juniorIdentities.providerSubjectId}
3731
3767
  ELSE NULL
@@ -3736,12 +3772,12 @@ async function recentLocationRows(db, locationId) {
3736
3772
  usage: juniorConversations.usage
3737
3773
  }).from(juniorConversations).innerJoin(
3738
3774
  juniorDestinations,
3739
- eq10(juniorDestinations.id, juniorConversations.destinationId)
3775
+ eq11(juniorDestinations.id, juniorConversations.destinationId)
3740
3776
  ).leftJoin(
3741
3777
  juniorIdentities,
3742
- eq10(juniorIdentities.id, juniorConversations.actorIdentityId)
3743
- ).leftJoin(juniorUsers, eq10(juniorUsers.id, juniorIdentities.userId)).where(publicLocationWhere(locationId)).orderBy(
3744
- desc3(juniorConversations.lastActivityAt),
3778
+ eq11(juniorIdentities.id, juniorConversations.actorIdentityId)
3779
+ ).leftJoin(juniorUsers, eq11(juniorUsers.id, juniorIdentities.userId)).where(publicLocationWhere(locationId)).orderBy(
3780
+ desc4(juniorConversations.lastActivityAt),
3745
3781
  asc3(juniorConversations.conversationId)
3746
3782
  ).limit(RECENT_LIMIT);
3747
3783
  }
@@ -3752,7 +3788,7 @@ async function readLocationDetailFromSql(locationId, options = {}) {
3752
3788
  const start = new Date(end);
3753
3789
  start.setUTCDate(start.getUTCDate() - (ACTIVITY_DAYS - 1));
3754
3790
  const where = publicLocationWhere(locationId);
3755
- const activityDate = sql10`TO_CHAR(
3791
+ const activityDate = sql11`TO_CHAR(
3756
3792
  ${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
3757
3793
  'YYYY-MM-DD'
3758
3794
  )`;
@@ -3763,27 +3799,27 @@ async function readLocationDetailFromSql(locationId, options = {}) {
3763
3799
  ...conversationRangeColumns()
3764
3800
  }).from(juniorConversations).innerJoin(
3765
3801
  treeConversation2,
3766
- eq10(
3802
+ eq11(
3767
3803
  treeConversation2.rootConversationId,
3768
3804
  juniorConversations.conversationId
3769
3805
  )
3770
3806
  ).innerJoin(
3771
3807
  juniorDestinations,
3772
- eq10(juniorDestinations.id, juniorConversations.destinationId)
3808
+ eq11(juniorDestinations.id, juniorConversations.destinationId)
3773
3809
  ).where(where).groupBy(...locationGroupBy()),
3774
3810
  getDb().select({
3775
3811
  date: activityDate,
3776
3812
  ...treeAggregateColumns2
3777
3813
  }).from(juniorConversations).innerJoin(
3778
3814
  treeConversation2,
3779
- eq10(
3815
+ eq11(
3780
3816
  treeConversation2.rootConversationId,
3781
3817
  juniorConversations.conversationId
3782
3818
  )
3783
3819
  ).innerJoin(
3784
3820
  juniorDestinations,
3785
- eq10(juniorDestinations.id, juniorConversations.destinationId)
3786
- ).where(and10(where, gte2(juniorConversations.lastActivityAt, start))).groupBy(activityDate),
3821
+ eq11(juniorDestinations.id, juniorConversations.destinationId)
3822
+ ).where(and11(where, gte2(juniorConversations.lastActivityAt, start))).groupBy(activityDate),
3787
3823
  getDb().select({
3788
3824
  actorIdentityId: juniorConversations.actorIdentityId,
3789
3825
  email: juniorUsers.primaryEmailNormalized,
@@ -3795,17 +3831,17 @@ async function readLocationDetailFromSql(locationId, options = {}) {
3795
3831
  ...treeAggregateColumns2
3796
3832
  }).from(juniorConversations).innerJoin(
3797
3833
  treeConversation2,
3798
- eq10(
3834
+ eq11(
3799
3835
  treeConversation2.rootConversationId,
3800
3836
  juniorConversations.conversationId
3801
3837
  )
3802
3838
  ).innerJoin(
3803
3839
  juniorDestinations,
3804
- eq10(juniorDestinations.id, juniorConversations.destinationId)
3840
+ eq11(juniorDestinations.id, juniorConversations.destinationId)
3805
3841
  ).leftJoin(
3806
3842
  juniorIdentities,
3807
- eq10(juniorIdentities.id, juniorConversations.actorIdentityId)
3808
- ).leftJoin(juniorUsers, eq10(juniorUsers.id, juniorIdentities.userId)).where(where).groupBy(
3843
+ eq11(juniorIdentities.id, juniorConversations.actorIdentityId)
3844
+ ).leftJoin(juniorUsers, eq11(juniorUsers.id, juniorIdentities.userId)).where(where).groupBy(
3809
3845
  juniorConversations.actorIdentityId,
3810
3846
  juniorUsers.primaryEmailNormalized,
3811
3847
  juniorUsers.displayName,
@@ -3827,17 +3863,17 @@ async function readLocationDetailFromSql(locationId, options = {}) {
3827
3863
  date: row.date,
3828
3864
  durationMs: row.durationMs,
3829
3865
  failed: row.failed,
3830
- ...row.tokens !== null ? { tokens: row.tokens } : {}
3866
+ ...row.tokens !== null ? { tokens: row.tokens } : void 0
3831
3867
  });
3832
3868
  }
3833
3869
  const actors = [];
3834
3870
  for (const row of actorRows) {
3835
3871
  if (!row.actorIdentityId) continue;
3836
3872
  const actor = {
3837
- ...row.email ?? row.identityEmail ? { email: row.email ?? row.identityEmail ?? void 0 } : {},
3838
- ...row.fullName ? { fullName: row.fullName } : {},
3839
- ...row.identityProvider === "slack" && row.providerSubjectId ? { slackUserId: row.providerSubjectId } : {},
3840
- ...row.handle ? { slackUserName: row.handle } : {}
3873
+ ...row.email ?? row.identityEmail ? { email: row.email ?? row.identityEmail ?? void 0 } : void 0,
3874
+ ...row.fullName ? { fullName: row.fullName } : void 0,
3875
+ ...row.identityProvider === "slack" && row.providerSubjectId ? { slackUserId: row.providerSubjectId } : void 0,
3876
+ ...row.handle ? { slackUserName: row.handle } : void 0
3841
3877
  };
3842
3878
  if (!actor.email && !actor.slackUserId) continue;
3843
3879
  const item = emptyActor(actor);
@@ -3918,10 +3954,10 @@ function createLocationRoutes() {
3918
3954
  import { Hono as Hono3 } from "hono";
3919
3955
 
3920
3956
  // src/api/people/list.query.ts
3921
- import { and as and12, eq as eq12, gte as gte3, sql as sql12 } from "drizzle-orm";
3957
+ import { and as and13, eq as eq13, gte as gte3, sql as sql13 } from "drizzle-orm";
3922
3958
 
3923
3959
  // src/api/people/shared.ts
3924
- import { and as and11, asc as asc4, desc as desc4, eq as eq11, isNull as isNull6, notExists, or as or4, sql as sql11 } from "drizzle-orm";
3960
+ import { and as and12, asc as asc4, desc as desc5, eq as eq12, isNull as isNull6, notExists, or as or5, sql as sql12 } from "drizzle-orm";
3925
3961
  import { alias as alias5 } from "drizzle-orm/pg-core";
3926
3962
  var RECENT_LIMIT2 = 25;
3927
3963
  var ACTIVITY_DAYS2 = 365;
@@ -3941,37 +3977,37 @@ var peopleTreeAggregateColumns = conversationAggregateColumns({
3941
3977
  function peopleTreeMetricsJoin() {
3942
3978
  const rootOwnedByActor = getDb().select({ conversationId: peopleRootConversation.conversationId }).from(peopleRootConversation).innerJoin(
3943
3979
  peopleRootIdentity,
3944
- eq11(peopleRootIdentity.id, peopleRootConversation.actorIdentityId)
3980
+ eq12(peopleRootIdentity.id, peopleRootConversation.actorIdentityId)
3945
3981
  ).where(
3946
- and11(
3947
- eq11(
3982
+ and12(
3983
+ eq12(
3948
3984
  peopleRootConversation.conversationId,
3949
3985
  juniorConversations.rootConversationId
3950
3986
  ),
3951
3987
  isNull6(peopleRootConversation.parentConversationId),
3952
- eq11(
3988
+ eq12(
3953
3989
  peopleRootConversation.rootConversationId,
3954
3990
  peopleRootConversation.conversationId
3955
3991
  ),
3956
- eq11(
3992
+ eq12(
3957
3993
  peopleRootIdentity.emailNormalized,
3958
3994
  juniorUsers.primaryEmailNormalized
3959
3995
  ),
3960
- eq11(peopleRootIdentity.emailVerified, true)
3996
+ eq12(peopleRootIdentity.emailVerified, true)
3961
3997
  )
3962
3998
  );
3963
- return and11(
3964
- eq11(
3999
+ return and12(
4000
+ eq12(
3965
4001
  peopleTreeConversation.rootConversationId,
3966
4002
  juniorConversations.rootConversationId
3967
4003
  ),
3968
- or4(
3969
- eq11(
4004
+ or5(
4005
+ eq12(
3970
4006
  juniorConversations.rootConversationId,
3971
4007
  juniorConversations.conversationId
3972
4008
  ),
3973
- and11(
3974
- eq11(
4009
+ and12(
4010
+ eq12(
3975
4011
  peopleTreeConversation.conversationId,
3976
4012
  juniorConversations.conversationId
3977
4013
  ),
@@ -4021,11 +4057,11 @@ function statsItems2(map) {
4021
4057
  }
4022
4058
  function verifiedActorWhere(email) {
4023
4059
  const normalizedEmail = normalizeEmail(email);
4024
- return and11(
4025
- eq11(juniorIdentities.provider, "slack"),
4026
- eq11(juniorIdentities.emailVerified, true),
4027
- sql11`${juniorUsers.primaryEmailNormalized} IS NOT NULL`,
4028
- normalizedEmail ? eq11(juniorUsers.primaryEmailNormalized, normalizedEmail) : void 0
4060
+ return and12(
4061
+ eq12(juniorIdentities.provider, "slack"),
4062
+ eq12(juniorIdentities.emailVerified, true),
4063
+ sql12`${juniorUsers.primaryEmailNormalized} IS NOT NULL`,
4064
+ normalizedEmail ? eq12(juniorUsers.primaryEmailNormalized, normalizedEmail) : void 0
4029
4065
  );
4030
4066
  }
4031
4067
  async function recentActorRows(email) {
@@ -4048,12 +4084,12 @@ async function recentActorRows(email) {
4048
4084
  usage: juniorConversations.usage
4049
4085
  }).from(juniorConversations).innerJoin(
4050
4086
  juniorIdentities,
4051
- eq11(juniorIdentities.id, juniorConversations.actorIdentityId)
4052
- ).innerJoin(juniorUsers, eq11(juniorUsers.id, juniorIdentities.userId)).leftJoin(
4087
+ eq12(juniorIdentities.id, juniorConversations.actorIdentityId)
4088
+ ).innerJoin(juniorUsers, eq12(juniorUsers.id, juniorIdentities.userId)).leftJoin(
4053
4089
  juniorDestinations,
4054
- eq11(juniorDestinations.id, juniorConversations.destinationId)
4090
+ eq12(juniorDestinations.id, juniorConversations.destinationId)
4055
4091
  ).where(verifiedActorWhere(email)).orderBy(
4056
- desc4(juniorConversations.lastActivityAt),
4092
+ desc5(juniorConversations.lastActivityAt),
4057
4093
  asc4(juniorConversations.conversationId)
4058
4094
  ).limit(RECENT_LIMIT2);
4059
4095
  }
@@ -4080,7 +4116,7 @@ function directoryActivityDays2(rows, nowMs) {
4080
4116
  async function readPeopleListFromSql() {
4081
4117
  const nowMs = Date.now();
4082
4118
  const { end, start } = activityWindow(nowMs);
4083
- const activityDate = sql12`TO_CHAR(
4119
+ const activityDate = sql13`TO_CHAR(
4084
4120
  ${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
4085
4121
  'YYYY-MM-DD'
4086
4122
  )`;
@@ -4088,24 +4124,24 @@ async function readPeopleListFromSql() {
4088
4124
  getDb().select({
4089
4125
  email: juniorUsers.primaryEmailNormalized,
4090
4126
  fullName: juniorUsers.displayName,
4091
- slackUserId: sql12`MAX(${juniorIdentities.providerSubjectId})`,
4092
- slackUserName: sql12`MAX(${juniorIdentities.handle})`,
4127
+ slackUserId: sql13`MAX(${juniorIdentities.providerSubjectId})`,
4128
+ slackUserName: sql13`MAX(${juniorIdentities.handle})`,
4093
4129
  activeDays: conversationActiveDaysColumn(),
4094
4130
  ...peopleTreeAggregateColumns,
4095
4131
  ...conversationRangeColumns()
4096
4132
  }).from(juniorConversations).innerJoin(
4097
4133
  juniorIdentities,
4098
- eq12(juniorIdentities.id, juniorConversations.actorIdentityId)
4099
- ).innerJoin(juniorUsers, eq12(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, peopleTreeMetricsJoin()).where(verifiedActorWhere()).groupBy(juniorUsers.primaryEmailNormalized, juniorUsers.displayName),
4134
+ eq13(juniorIdentities.id, juniorConversations.actorIdentityId)
4135
+ ).innerJoin(juniorUsers, eq13(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, peopleTreeMetricsJoin()).where(verifiedActorWhere()).groupBy(juniorUsers.primaryEmailNormalized, juniorUsers.displayName),
4100
4136
  getDb().select({
4101
- activePeople: sql12`COUNT(DISTINCT ${juniorUsers.id})::int`,
4102
- conversations: sql12`COUNT(*)::int`,
4137
+ activePeople: sql13`COUNT(DISTINCT ${juniorUsers.id})::int`,
4138
+ conversations: sql13`COUNT(*)::int`,
4103
4139
  date: activityDate
4104
4140
  }).from(juniorConversations).innerJoin(
4105
4141
  juniorIdentities,
4106
- eq12(juniorIdentities.id, juniorConversations.actorIdentityId)
4107
- ).innerJoin(juniorUsers, eq12(juniorUsers.id, juniorIdentities.userId)).where(
4108
- and12(
4142
+ eq13(juniorIdentities.id, juniorConversations.actorIdentityId)
4143
+ ).innerJoin(juniorUsers, eq13(juniorUsers.id, juniorIdentities.userId)).where(
4144
+ and13(
4109
4145
  verifiedActorWhere(),
4110
4146
  gte3(juniorConversations.lastActivityAt, start)
4111
4147
  )
@@ -4114,9 +4150,9 @@ async function readPeopleListFromSql() {
4114
4150
  const people = rows.map((row) => {
4115
4151
  const actor = {
4116
4152
  email: row.email,
4117
- ...row.fullName ? { fullName: row.fullName } : {},
4118
- ...row.slackUserId ? { slackUserId: row.slackUserId } : {},
4119
- ...row.slackUserName ? { slackUserName: row.slackUserName } : {}
4153
+ ...row.fullName ? { fullName: row.fullName } : void 0,
4154
+ ...row.slackUserId ? { slackUserId: row.slackUserId } : void 0,
4155
+ ...row.slackUserName ? { slackUserName: row.slackUserName } : void 0
4120
4156
  };
4121
4157
  return {
4122
4158
  active: row.active,
@@ -4127,7 +4163,7 @@ async function readPeopleListFromSql() {
4127
4163
  firstSeenAt: row.firstSeenAt.toISOString(),
4128
4164
  lastSeenAt: row.lastSeenAt.toISOString(),
4129
4165
  actor,
4130
- ...row.tokens !== null ? { tokens: row.tokens } : {}
4166
+ ...row.tokens !== null ? { tokens: row.tokens } : void 0
4131
4167
  };
4132
4168
  });
4133
4169
  return {
@@ -4158,7 +4194,7 @@ async function readPeoplePluginReports(args) {
4158
4194
  source: "plugins"
4159
4195
  });
4160
4196
  }
4161
- const { getPluginProfileReports } = await import("./agent-hooks-PBT4NNBV.js");
4197
+ const { getPluginProfileReports } = await import("./agent-hooks-DKDDRKZA.js");
4162
4198
  return pluginOperationalReportFeedSchema.parse({
4163
4199
  generatedAt: new Date(nowMs).toISOString(),
4164
4200
  reports: await getPluginProfileReports({
@@ -4171,7 +4207,7 @@ async function readPeoplePluginReports(args) {
4171
4207
  }
4172
4208
 
4173
4209
  // src/api/people/profile.query.ts
4174
- import { and as and13, eq as eq13, gte as gte4, sql as sql13 } from "drizzle-orm";
4210
+ import { and as and14, eq as eq14, gte as gte4, sql as sql14 } from "drizzle-orm";
4175
4211
  function emptyProfile(email, nowMs) {
4176
4212
  const end = new Date(nowMs);
4177
4213
  end.setUTCHours(0, 0, 0, 0);
@@ -4206,7 +4242,7 @@ function addAggregate2(map, label, row) {
4206
4242
  map.set(label, item);
4207
4243
  }
4208
4244
  function surfaceExpression() {
4209
- return sql13`CASE
4245
+ return sql14`CASE
4210
4246
  WHEN ${juniorConversations.source} IN ('api', 'scheduler', 'slack')
4211
4247
  THEN ${juniorConversations.source}
4212
4248
  WHEN ${juniorConversations.conversationId} LIKE 'slack:%' THEN 'slack'
@@ -4235,30 +4271,30 @@ async function readPeopleProfileFromSql(email, options = {}) {
4235
4271
  const where = verifiedActorWhere(normalizedEmail);
4236
4272
  const metricsJoin = peopleTreeMetricsJoin();
4237
4273
  const surface = surfaceExpression();
4238
- const activityDate = sql13`TO_CHAR(
4274
+ const activityDate = sql14`TO_CHAR(
4239
4275
  ${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
4240
4276
  'YYYY-MM-DD'
4241
4277
  )`;
4242
- const channel = sql13`SPLIT_PART(${juniorConversations.conversationId}, ':', 2)`;
4278
+ const channel = sql14`SPLIT_PART(${juniorConversations.conversationId}, ':', 2)`;
4243
4279
  const [totalsRows, dayRows, locationRows, surfaceRows, recentRows] = await Promise.all([
4244
4280
  getDb().select({
4245
4281
  email: juniorUsers.primaryEmailNormalized,
4246
4282
  fullName: juniorUsers.displayName,
4247
- slackUserId: sql13`MAX(${juniorIdentities.providerSubjectId})`,
4248
- slackUserName: sql13`MAX(${juniorIdentities.handle})`,
4283
+ slackUserId: sql14`MAX(${juniorIdentities.providerSubjectId})`,
4284
+ slackUserName: sql14`MAX(${juniorIdentities.handle})`,
4249
4285
  activeDays: conversationActiveDaysColumn(),
4250
4286
  ...peopleTreeAggregateColumns
4251
4287
  }).from(juniorConversations).innerJoin(
4252
4288
  juniorIdentities,
4253
- eq13(juniorIdentities.id, juniorConversations.actorIdentityId)
4254
- ).innerJoin(juniorUsers, eq13(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(where).groupBy(juniorUsers.primaryEmailNormalized, juniorUsers.displayName),
4289
+ eq14(juniorIdentities.id, juniorConversations.actorIdentityId)
4290
+ ).innerJoin(juniorUsers, eq14(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(where).groupBy(juniorUsers.primaryEmailNormalized, juniorUsers.displayName),
4255
4291
  getDb().select({
4256
4292
  date: activityDate,
4257
4293
  ...peopleTreeAggregateColumns
4258
4294
  }).from(juniorConversations).innerJoin(
4259
4295
  juniorIdentities,
4260
- eq13(juniorIdentities.id, juniorConversations.actorIdentityId)
4261
- ).innerJoin(juniorUsers, eq13(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(and13(where, gte4(juniorConversations.lastActivityAt, start))).groupBy(activityDate),
4296
+ eq14(juniorIdentities.id, juniorConversations.actorIdentityId)
4297
+ ).innerJoin(juniorUsers, eq14(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(and14(where, gte4(juniorConversations.lastActivityAt, start))).groupBy(activityDate),
4262
4298
  getDb().select({
4263
4299
  channel,
4264
4300
  channelName: juniorConversations.channelName,
@@ -4267,10 +4303,10 @@ async function readPeopleProfileFromSql(email, options = {}) {
4267
4303
  ...peopleTreeAggregateColumns
4268
4304
  }).from(juniorConversations).innerJoin(
4269
4305
  juniorIdentities,
4270
- eq13(juniorIdentities.id, juniorConversations.actorIdentityId)
4271
- ).innerJoin(juniorUsers, eq13(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).leftJoin(
4306
+ eq14(juniorIdentities.id, juniorConversations.actorIdentityId)
4307
+ ).innerJoin(juniorUsers, eq14(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).leftJoin(
4272
4308
  juniorDestinations,
4273
- eq13(juniorDestinations.id, juniorConversations.destinationId)
4309
+ eq14(juniorDestinations.id, juniorConversations.destinationId)
4274
4310
  ).where(where).groupBy(
4275
4311
  channel,
4276
4312
  juniorConversations.channelName,
@@ -4279,28 +4315,28 @@ async function readPeopleProfileFromSql(email, options = {}) {
4279
4315
  ),
4280
4316
  getDb().select({ surface, ...peopleTreeAggregateColumns }).from(juniorConversations).innerJoin(
4281
4317
  juniorIdentities,
4282
- eq13(juniorIdentities.id, juniorConversations.actorIdentityId)
4283
- ).innerJoin(juniorUsers, eq13(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(where).groupBy(surface),
4318
+ eq14(juniorIdentities.id, juniorConversations.actorIdentityId)
4319
+ ).innerJoin(juniorUsers, eq14(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(where).groupBy(surface),
4284
4320
  recentActorRows(normalizedEmail)
4285
4321
  ]);
4286
4322
  const totalsRow = totalsRows[0];
4287
4323
  if (!totalsRow) return emptyProfile(normalizedEmail, nowMs);
4288
4324
  const actor = {
4289
4325
  email: totalsRow.email,
4290
- ...totalsRow.fullName ? { fullName: totalsRow.fullName } : {},
4291
- ...totalsRow.slackUserId ? { slackUserId: totalsRow.slackUserId } : {},
4292
- ...totalsRow.slackUserName ? { slackUserName: totalsRow.slackUserName } : {}
4326
+ ...totalsRow.fullName ? { fullName: totalsRow.fullName } : void 0,
4327
+ ...totalsRow.slackUserId ? { slackUserId: totalsRow.slackUserId } : void 0,
4328
+ ...totalsRow.slackUserName ? { slackUserName: totalsRow.slackUserName } : void 0
4293
4329
  };
4294
4330
  const days = /* @__PURE__ */ new Map();
4295
4331
  for (const row of dayRows) {
4296
4332
  days.set(row.date, {
4297
4333
  active: row.active,
4298
4334
  conversations: row.conversations,
4299
- ...row.costUsd !== null ? { costUsd: row.costUsd } : {},
4335
+ ...row.costUsd !== null ? { costUsd: row.costUsd } : void 0,
4300
4336
  date: row.date,
4301
4337
  durationMs: row.durationMs,
4302
4338
  failed: row.failed,
4303
- ...row.tokens !== null ? { tokens: row.tokens } : {}
4339
+ ...row.tokens !== null ? { tokens: row.tokens } : void 0
4304
4340
  });
4305
4341
  }
4306
4342
  const locations = /* @__PURE__ */ new Map();
@@ -4343,7 +4379,7 @@ async function readPeopleProfileFromSql(email, options = {}) {
4343
4379
  conversations: totalsRow.conversations,
4344
4380
  durationMs: totalsRow.durationMs,
4345
4381
  failed: totalsRow.failed,
4346
- ...totalsRow.tokens !== null ? { tokens: totalsRow.tokens } : {}
4382
+ ...totalsRow.tokens !== null ? { tokens: totalsRow.tokens } : void 0
4347
4383
  },
4348
4384
  windowEnd: end.toISOString(),
4349
4385
  windowStart: start.toISOString()
@@ -4358,7 +4394,7 @@ async function readPeopleProfile(email, options = {}) {
4358
4394
  }
4359
4395
 
4360
4396
  // src/api/people/spend.query.ts
4361
- import { and as and14, eq as eq14, gte as gte5, lte as lte2, sql as sql14 } from "drizzle-orm";
4397
+ import { and as and15, eq as eq15, gte as gte5, lte as lte2, sql as sql15 } from "drizzle-orm";
4362
4398
  var SEVEN_DAY_OFFSET = 6;
4363
4399
  var THIRTY_DAY_OFFSET = 29;
4364
4400
  function addUsd2(current, next) {
@@ -4377,7 +4413,7 @@ function spendWindow(nowMs) {
4377
4413
  async function readPersonalSpendFromSql(email, nowMs = Date.now()) {
4378
4414
  const normalizedEmail = normalizeEmail(email);
4379
4415
  const { end, sevenDayStart, thirtyDayStart } = spendWindow(nowMs);
4380
- const activityDate = sql14`TO_CHAR(
4416
+ const activityDate = sql15`TO_CHAR(
4381
4417
  ${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
4382
4418
  'YYYY-MM-DD'
4383
4419
  )`;
@@ -4387,9 +4423,9 @@ async function readPersonalSpendFromSql(email, nowMs = Date.now()) {
4387
4423
  date: activityDate
4388
4424
  }).from(juniorConversations).innerJoin(
4389
4425
  juniorIdentities,
4390
- eq14(juniorIdentities.id, juniorConversations.actorIdentityId)
4391
- ).innerJoin(juniorUsers, eq14(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(
4392
- and14(
4426
+ eq15(juniorIdentities.id, juniorConversations.actorIdentityId)
4427
+ ).innerJoin(juniorUsers, eq15(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(
4428
+ and15(
4393
4429
  verifiedActorWhere(normalizedEmail),
4394
4430
  gte5(juniorConversations.lastActivityAt, thirtyDayStart),
4395
4431
  lte2(juniorConversations.lastActivityAt, end)
@@ -4539,8 +4575,10 @@ import { Hono as Hono5 } from "hono";
4539
4575
  import { z as z5 } from "zod";
4540
4576
  import {
4541
4577
  pluginUserPageContentSchema as pluginUserPageContentSchema2,
4542
- pluginUserPageInputSchema,
4543
- pluginUserPageLinksSchema as pluginUserPageLinksSchema2
4578
+ pluginUserPageCursorSchema,
4579
+ pluginUserPageFilterSchema,
4580
+ pluginUserPageLinksSchema as pluginUserPageLinksSchema2,
4581
+ pluginUserPageQuerySchema
4544
4582
  } from "@sentry/junior-plugin-api";
4545
4583
 
4546
4584
  // src/chat/plugins/user-pages.ts
@@ -4605,20 +4643,17 @@ async function readPluginUserPage(input) {
4605
4643
  var userPageQuerySchema = z5.object({
4606
4644
  cursor: z5.preprocess(
4607
4645
  (value) => value || void 0,
4608
- pluginUserPageInputSchema.shape.cursor
4646
+ pluginUserPageCursorSchema
4609
4647
  ),
4610
4648
  filter: z5.preprocess(
4611
4649
  (value) => value || void 0,
4612
- pluginUserPageInputSchema.shape.filter
4650
+ pluginUserPageFilterSchema
4613
4651
  ),
4614
4652
  limit: z5.preprocess(
4615
4653
  (value) => value === "" ? void 0 : value,
4616
4654
  z5.coerce.number().int().min(1).max(50).default(20)
4617
4655
  ),
4618
- q: z5.preprocess(
4619
- (value) => value || void 0,
4620
- pluginUserPageInputSchema.shape.query
4621
- )
4656
+ q: z5.preprocess((value) => value || void 0, pluginUserPageQuerySchema)
4622
4657
  });
4623
4658
  function createUserPageRoutes() {
4624
4659
  const app = new Hono5();
@@ -4637,7 +4672,7 @@ function createUserPageRoutes() {
4637
4672
  email: viewer.email,
4638
4673
  pageId: context.req.param("pageId"),
4639
4674
  pluginName: context.req.param("pluginName"),
4640
- query: { ...query, ...q === void 0 ? {} : { query: q } }
4675
+ query: { ...query, ...q === void 0 ? void 0 : { query: q } }
4641
4676
  });
4642
4677
  return page ? jsonResponse(pluginUserPageContentSchema2, page) : jsonResponse(
4643
4678
  apiErrorSchema,
@@ -4877,7 +4912,7 @@ function readDescriptionText(home) {
4877
4912
  }
4878
4913
  }
4879
4914
  async function readSkillReports() {
4880
- const { discoverSkills } = await import("./skills-U5KQ66EM.js");
4915
+ const { discoverSkills } = await import("./skills-F32BPFYW.js");
4881
4916
  const skills = await discoverSkills();
4882
4917
  return skillReportsSchema.parse(
4883
4918
  skills.map((skill) => ({
@@ -4887,7 +4922,7 @@ async function readSkillReports() {
4887
4922
  );
4888
4923
  }
4889
4924
  async function readPlugins() {
4890
- const { pluginCatalogRuntime } = await import("./catalog-runtime-M7QGKPFZ.js");
4925
+ const { pluginCatalogRuntime } = await import("./catalog-runtime-WXKGUF3W.js");
4891
4926
  return pluginsSchema.parse(
4892
4927
  pluginCatalogRuntime.getProviders().map((plugin) => ({
4893
4928
  configKeys: plugin.manifest.configKeys ?? [],
@@ -4899,8 +4934,8 @@ async function readPlugins() {
4899
4934
  }
4900
4935
  async function readRuntimeInfoReport() {
4901
4936
  const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
4902
- import("./discovery-GUFTFBTL.js"),
4903
- import("./catalog-runtime-M7QGKPFZ.js"),
4937
+ import("./discovery-DWVDM7UK.js"),
4938
+ import("./catalog-runtime-WXKGUF3W.js"),
4904
4939
  readPlugins(),
4905
4940
  readSkillReports()
4906
4941
  ]);
@@ -4916,7 +4951,7 @@ async function readRuntimeInfoReport() {
4916
4951
  }
4917
4952
  async function readPluginOperationalReportFeed() {
4918
4953
  const nowMs = Date.now();
4919
- const { getPluginOperationalReports } = await import("./agent-hooks-PBT4NNBV.js");
4954
+ const { getPluginOperationalReports } = await import("./agent-hooks-DKDDRKZA.js");
4920
4955
  return pluginOperationalReportFeedSchema.parse({
4921
4956
  source: "plugins",
4922
4957
  generatedAt: new Date(nowMs).toISOString(),