@sentry/junior 0.178.0 → 0.179.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 (67) hide show
  1. package/dist/{agent-hooks-PBT4NNBV.js → agent-hooks-32IDCLMW.js} +12 -12
  2. package/dist/api.js +229 -196
  3. package/dist/app.js +570 -195
  4. package/dist/{catalog-runtime-M7QGKPFZ.js → catalog-runtime-FBVA6WAQ.js} +5 -5
  5. package/dist/chat/scheduled-tasks/personal.d.ts +5 -8
  6. package/dist/chat/scheduled-tasks/runs.d.ts +49 -0
  7. package/dist/chat/scheduled-tasks/schedule-intent.d.ts +1 -1
  8. package/dist/chat/scheduled-tasks/tasks.d.ts +27 -0
  9. package/dist/chat/scheduled-tasks/tool-support.d.ts +0 -4
  10. package/dist/chat/scheduled-tasks/tools/create.d.ts +1 -1
  11. package/dist/chat/scheduled-tasks/tools/update.d.ts +1 -1
  12. package/dist/chat/scheduled-tasks/types.d.ts +127 -78
  13. package/dist/{chunk-JVXZ3WDH.js → chunk-2HIPYNQI.js} +6 -6
  14. package/dist/{chunk-BHHWCNXI.js → chunk-3AFVR5UC.js} +5 -5
  15. package/dist/{chunk-XWUJWHFD.js → chunk-3I7XE3PA.js} +6 -6
  16. package/dist/{chunk-H6ZXBFGX.js → chunk-3TM3FYLQ.js} +1 -1
  17. package/dist/{chunk-6OYVH66J.js → chunk-4GWXAILB.js} +1 -1
  18. package/dist/{chunk-BUGO42R6.js → chunk-5IRROPA5.js} +4 -4
  19. package/dist/{chunk-534BO42N.js → chunk-B6ECUSVX.js} +3 -3
  20. package/dist/{chunk-G3CQEUHI.js → chunk-CJLBLELR.js} +5 -5
  21. package/dist/{chunk-22T3HB44.js → chunk-FAS6AIMF.js} +1 -1
  22. package/dist/{chunk-BFLMRTPD.js → chunk-FIDMHAO6.js} +6 -6
  23. package/dist/{chunk-AVRWMQ4U.js → chunk-FTGD2FBP.js} +1 -1
  24. package/dist/{chunk-UMG7M32G.js → chunk-G2CAC4CV.js} +17 -17
  25. package/dist/{chunk-3ZZEPLLB.js → chunk-GENV6KF2.js} +2 -2
  26. package/dist/{chunk-RE4XWXBV.js → chunk-GPLAT6H7.js} +6 -6
  27. package/dist/{chunk-UGWBJAGN.js → chunk-HQNE5APD.js} +1 -1
  28. package/dist/{chunk-AQHSXA3J.js → chunk-JMJNFEDC.js} +3 -3
  29. package/dist/{chunk-PRDKO3QB.js → chunk-JT4WMD3C.js} +12 -12
  30. package/dist/{chunk-4K6VNP3S.js → chunk-KJLHIHFF.js} +9 -9
  31. package/dist/{chunk-QCCLDJHB.js → chunk-Q5B3WTGG.js} +8 -8
  32. package/dist/{chunk-RGXOLPWO.js → chunk-R5NWWYIS.js} +1 -1
  33. package/dist/{chunk-ZCHHVTMF.js → chunk-R6U7N4FS.js} +1 -1
  34. package/dist/{chunk-OGRD5PFM.js → chunk-RTRBYSF3.js} +1 -1
  35. package/dist/{chunk-FQ6BMP5P.js → chunk-RZRYOLCE.js} +396 -74
  36. package/dist/{chunk-D3UJTX4U.js → chunk-SLGGOASN.js} +1 -1
  37. package/dist/{chunk-IQRPDKPJ.js → chunk-TIEKUH4Q.js} +1 -1
  38. package/dist/{chunk-LAOP4EPL.js → chunk-U4TKB6F6.js} +4 -4
  39. package/dist/{chunk-AGJ4OQ2V.js → chunk-UT6X7XN7.js} +1 -1
  40. package/dist/{chunk-XCNS3CXE.js → chunk-VP4OVRDD.js} +3 -3
  41. package/dist/{chunk-KEQAA42D.js → chunk-XSPSCWLH.js} +1 -1
  42. package/dist/chunk-XZY6G5YZ.js +1088 -0
  43. package/dist/{chunk-ABLODWPO.js → chunk-YFNAMRGE.js} +1 -1
  44. package/dist/{chunk-U3UDPGZG.js → chunk-ZQMG3CL5.js} +2 -2
  45. package/dist/cli/chat.js +31 -31
  46. package/dist/cli/check.js +6 -6
  47. package/dist/cli/plugins.js +13 -13
  48. package/dist/cli/snapshot-create.js +10 -10
  49. package/dist/cli/upgrade.js +7 -7
  50. package/dist/db/schema/scheduled-tasks.d.ts +29 -5
  51. package/dist/db/schema.d.ts +28 -4
  52. package/dist/{db-QVYOWATH.js → db-EJAV7JL6.js} +7 -7
  53. package/dist/instrumentation.js +4 -4
  54. package/dist/nitro.js +2 -2
  55. package/dist/{oauth-callback-server-PLPAFXO6.js → oauth-callback-server-GAVSUBTQ.js} +23 -23
  56. package/dist/{runner-AGNEIOZS.js → runner-34JL64JF.js} +15 -15
  57. package/dist/{skills-U5KQ66EM.js → skills-U545HALM.js} +6 -6
  58. package/dist/spawn-I2S4IDUQ.js +37 -0
  59. package/dist/{validation-QE4U45KS.js → validation-EVXVGA44.js} +6 -6
  60. package/dist/version.js +1 -1
  61. package/dist/{work-ATAXAHJJ.js → work-QOAUPDBU.js} +18 -18
  62. package/dist/worker-5GX2IKLZ.js +24 -0
  63. package/package.json +5 -5
  64. package/dist/chat/scheduled-tasks/store.d.ts +0 -78
  65. package/dist/chunk-RGV6KHDM.js +0 -1944
  66. package/dist/spawn-ZRYYZP2B.js +0 -37
  67. package/dist/worker-LIL5AOER.js +0 -24
package/dist/api.js CHANGED
@@ -64,15 +64,15 @@ import {
64
64
  revokePersonalToken,
65
65
  viewerConversationMembership,
66
66
  webActorFromEmail
67
- } from "./chunk-PRDKO3QB.js";
67
+ } from "./chunk-JT4WMD3C.js";
68
68
  import {
69
69
  buildSentryConversationUrl,
70
70
  getWebAuthorization
71
- } from "./chunk-AVRWMQ4U.js";
71
+ } from "./chunk-FTGD2FBP.js";
72
72
  import {
73
73
  cancelHumanFacingPendingMessages,
74
74
  getConversation
75
- } from "./chunk-BUGO42R6.js";
75
+ } from "./chunk-5IRROPA5.js";
76
76
  import {
77
77
  readTaskExecutionByConversationId,
78
78
  readTaskExecutionDays,
@@ -80,8 +80,8 @@ import {
80
80
  readTaskExecutionSummaries,
81
81
  readTaskExecutions,
82
82
  readTaskRuns
83
- } from "./chunk-4K6VNP3S.js";
84
- import "./chunk-G3CQEUHI.js";
83
+ } from "./chunk-KJLHIHFF.js";
84
+ import "./chunk-CJLBLELR.js";
85
85
  import {
86
86
  healthReportSchema,
87
87
  pluginOperationalReportFeedSchema,
@@ -95,30 +95,33 @@ import {
95
95
  import "./chunk-JAL3CH4G.js";
96
96
  import "./chunk-5I6ORJUY.js";
97
97
  import {
98
- createSchedulerSqlStore,
99
98
  deleteEventTask,
100
99
  eventTaskBelongsToUser,
101
100
  eventTaskTriggerAvailable,
102
101
  getEventTask,
103
102
  getResourceEventCatalog,
103
+ isListedScheduledTask,
104
104
  listEventTasksCreatedBy,
105
105
  listPublicEventTasksForTeams,
106
106
  listPublicScheduledTasksForTeams,
107
+ parseScheduledTaskRow,
107
108
  readLiveAttachment,
108
- readStats
109
- } from "./chunk-RGV6KHDM.js";
109
+ readScheduledTask,
110
+ readStats,
111
+ saveScheduledTask
112
+ } from "./chunk-XZY6G5YZ.js";
110
113
  import {
111
114
  parseSlackThreadId
112
- } from "./chunk-22T3HB44.js";
115
+ } from "./chunk-FAS6AIMF.js";
113
116
  import {
114
117
  agentTurnUsageSchema,
115
118
  fallbackShortTitle,
116
119
  hasAgentTurnUsage,
117
120
  renderJuniorNativeConversationEvent
118
- } from "./chunk-BFLMRTPD.js";
121
+ } from "./chunk-FIDMHAO6.js";
119
122
  import {
120
123
  getCachedSnapshot
121
- } from "./chunk-534BO42N.js";
124
+ } from "./chunk-B6ECUSVX.js";
122
125
  import "./chunk-PDO5BLNM.js";
123
126
  import {
124
127
  SANDBOX_RUNTIME,
@@ -139,7 +142,7 @@ import {
139
142
  updateWorkspace,
140
143
  withSlackRetries,
141
144
  workspaceRepoCheckoutPath
142
- } from "./chunk-XWUJWHFD.js";
145
+ } from "./chunk-3I7XE3PA.js";
143
146
  import "./chunk-3Y47VMHV.js";
144
147
  import {
145
148
  decodeStoredConversationEvent,
@@ -149,27 +152,28 @@ import {
149
152
  locationFromRow,
150
153
  parseSessionSource,
151
154
  resolveRootConversationId
152
- } from "./chunk-XCNS3CXE.js";
155
+ } from "./chunk-VP4OVRDD.js";
153
156
  import {
154
157
  conversationReadColumns,
155
158
  juniorConversationEvents,
156
159
  juniorConversationParticipants,
157
160
  juniorConversations,
158
161
  juniorIdentities,
162
+ juniorSchedulerTasks,
159
163
  juniorUsers
160
- } from "./chunk-ZCHHVTMF.js";
164
+ } from "./chunk-R6U7N4FS.js";
161
165
  import {
162
166
  create,
163
167
  hash
164
- } from "./chunk-AQHSXA3J.js";
165
- import "./chunk-H6ZXBFGX.js";
166
- import "./chunk-3ZZEPLLB.js";
168
+ } from "./chunk-JMJNFEDC.js";
169
+ import "./chunk-3TM3FYLQ.js";
170
+ import "./chunk-GENV6KF2.js";
167
171
  import {
168
172
  juniorDestinations
169
173
  } from "./chunk-VFUK3X5B.js";
170
- import "./chunk-KEQAA42D.js";
171
- import "./chunk-ABLODWPO.js";
172
- import "./chunk-D3UJTX4U.js";
174
+ import "./chunk-XSPSCWLH.js";
175
+ import "./chunk-YFNAMRGE.js";
176
+ import "./chunk-SLGGOASN.js";
173
177
  import "./chunk-CGA4ERJ5.js";
174
178
  import {
175
179
  parseSlackChannelId,
@@ -179,12 +183,12 @@ import {
179
183
  import {
180
184
  logException,
181
185
  logWarn
182
- } from "./chunk-UGWBJAGN.js";
186
+ } from "./chunk-HQNE5APD.js";
183
187
  import "./chunk-6GWA276C.js";
184
188
  import "./chunk-OOUNJNMR.js";
185
189
  import "./chunk-H4HBKISO.js";
186
- import "./chunk-AGJ4OQ2V.js";
187
- import "./chunk-IQRPDKPJ.js";
190
+ import "./chunk-UT6X7XN7.js";
191
+ import "./chunk-TIEKUH4Q.js";
188
192
  import "./chunk-MLKGABMK.js";
189
193
 
190
194
  // src/api.ts
@@ -2025,9 +2029,10 @@ async function readConversationFeed(options = {}) {
2025
2029
  }
2026
2030
 
2027
2031
  // src/chat/tasks/read.ts
2028
- import { and as and8, eq as eq8, or as or3 } from "drizzle-orm";
2032
+ import { and as and9, eq as eq9, or as or4 } from "drizzle-orm";
2029
2033
 
2030
2034
  // src/chat/scheduled-tasks/personal.ts
2035
+ 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
2036
  import { z as z3 } from "zod";
2032
2037
  var cursorSchema = z3.object({
2033
2038
  createdAtMs: z3.number().finite(),
@@ -2075,37 +2080,71 @@ function encodeCursor(task, query) {
2075
2080
  "utf8"
2076
2081
  ).toString("base64url");
2077
2082
  }
2078
- function createViewerScheduledTasks(store, user) {
2083
+ async function deleteViewerScheduledTask(db, user, id, nowMs = Date.now()) {
2079
2084
  const identityIds = new Set(user.identities.map((identity) => identity.id));
2085
+ const task = await readScheduledTask(db, id);
2086
+ if (!task || task.status === "deleted" || !identityIds.has(task.creatorIdentityId)) {
2087
+ throw new PersonalScheduledTaskNotFoundError();
2088
+ }
2089
+ await saveScheduledTask(db, {
2090
+ ...task,
2091
+ nextRunAtMs: void 0,
2092
+ runNowAtMs: void 0,
2093
+ status: "deleted",
2094
+ updatedAtMs: nowMs
2095
+ });
2096
+ }
2097
+ async function listViewerScheduledTasks(db, user, input) {
2098
+ const identityIds = user.identities.map((identity) => identity.id);
2099
+ if (identityIds.length === 0) return { tasks: [] };
2100
+ const query = normalizeQuery(input.query);
2101
+ const cursor = decodeCursor(input.cursor, query);
2102
+ const tasks = [];
2103
+ let before = cursor;
2104
+ const fetchLimit = input.limit + 1;
2105
+ while (tasks.length < fetchLimit) {
2106
+ const cursorFilter = before ? or3(
2107
+ lt2(juniorSchedulerTasks.createdAtMs, before.createdAtMs),
2108
+ and8(
2109
+ eq8(juniorSchedulerTasks.createdAtMs, before.createdAtMs),
2110
+ lt2(juniorSchedulerTasks.id, before.id)
2111
+ )
2112
+ ) : void 0;
2113
+ const search = query ? or3(
2114
+ sql8`strpos(lower(${juniorSchedulerTasks.title}), ${query}) > 0`,
2115
+ sql8`strpos(lower(${juniorSchedulerTasks.record}->'task'->>'text'), ${query}) > 0`,
2116
+ sql8`strpos(lower(${juniorSchedulerTasks.record}->'schedule'->>'description'), ${query}) > 0`,
2117
+ sql8`strpos(lower(${juniorSchedulerTasks.record}->'schedule'->>'timezone'), ${query}) > 0`,
2118
+ sql8`strpos(lower(${juniorSchedulerTasks.status}), ${query}) > 0`
2119
+ ) : void 0;
2120
+ const rows = await db.select({
2121
+ createdAtMs: juniorSchedulerTasks.createdAtMs,
2122
+ creatorIdentityId: juniorSchedulerTasks.creatorIdentityId,
2123
+ id: juniorSchedulerTasks.id,
2124
+ record: juniorSchedulerTasks.record,
2125
+ title: juniorSchedulerTasks.title
2126
+ }).from(juniorSchedulerTasks).where(
2127
+ and8(
2128
+ notInArray(juniorSchedulerTasks.status, ["deleted", "paused"]),
2129
+ inArray5(juniorSchedulerTasks.creatorIdentityId, identityIds),
2130
+ cursorFilter,
2131
+ search
2132
+ )
2133
+ ).orderBy(
2134
+ desc3(juniorSchedulerTasks.createdAtMs),
2135
+ desc3(juniorSchedulerTasks.id)
2136
+ ).limit(fetchLimit);
2137
+ tasks.push(
2138
+ ...rows.map(parseScheduledTaskRow).filter(isListedScheduledTask)
2139
+ );
2140
+ if (rows.length < fetchLimit) break;
2141
+ const last = rows.at(-1);
2142
+ before = { createdAtMs: last.createdAtMs, id: last.id };
2143
+ }
2144
+ const page = tasks.slice(0, input.limit);
2080
2145
  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
- }
2146
+ tasks: page,
2147
+ ...tasks.length > input.limit && page.length > 0 ? { nextCursor: encodeCursor(page.at(-1), query) } : {}
2109
2148
  };
2110
2149
  }
2111
2150
 
@@ -2135,16 +2174,16 @@ async function creatorProfileEmails(candidates) {
2135
2174
  email: juniorUsers.primaryEmailNormalized,
2136
2175
  slackUserId: juniorIdentities.providerSubjectId,
2137
2176
  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(
2177
+ }).from(juniorIdentities).innerJoin(juniorUsers, eq9(juniorUsers.id, juniorIdentities.userId)).where(
2178
+ and9(
2179
+ eq9(juniorIdentities.kind, "user"),
2180
+ eq9(juniorIdentities.provider, "slack"),
2181
+ eq9(juniorIdentities.emailVerified, true),
2182
+ or4(
2144
2183
  ...[...selectors.values()].map(
2145
- (selector) => and8(
2146
- eq8(juniorIdentities.providerTenantId, selector.teamId),
2147
- eq8(juniorIdentities.providerSubjectId, selector.slackUserId)
2184
+ (selector) => and9(
2185
+ eq9(juniorIdentities.providerTenantId, selector.teamId),
2186
+ eq9(juniorIdentities.providerSubjectId, selector.slackUserId)
2148
2187
  )
2149
2188
  )
2150
2189
  )
@@ -2180,12 +2219,12 @@ async function destinationDetails(destinations) {
2180
2219
  providerTenantId: juniorDestinations.providerTenantId,
2181
2220
  visibility: juniorDestinations.visibility
2182
2221
  }).from(juniorDestinations).where(
2183
- or3(
2222
+ or4(
2184
2223
  ...[...selectors.values()].map(
2185
- (destination) => and8(
2186
- eq8(juniorDestinations.provider, "slack"),
2187
- eq8(juniorDestinations.providerTenantId, destination.teamId),
2188
- eq8(juniorDestinations.providerDestinationId, destination.channelId)
2224
+ (destination) => and9(
2225
+ eq9(juniorDestinations.provider, "slack"),
2226
+ eq9(juniorDestinations.providerTenantId, destination.teamId),
2227
+ eq9(juniorDestinations.providerDestinationId, destination.channelId)
2189
2228
  )
2190
2229
  )
2191
2230
  )
@@ -2278,7 +2317,7 @@ async function resolveViewerTaskCandidate(user, kind, id) {
2278
2317
  const identityIds = new Set(user.identities.map((identity) => identity.id));
2279
2318
  const teamIds = viewerTeamIds(user);
2280
2319
  if (kind === "scheduled") {
2281
- const task2 = await createSchedulerSqlStore(db).getTask(id);
2320
+ const task2 = await readScheduledTask(db, id);
2282
2321
  if (!task2 || task2.status === "deleted") return void 0;
2283
2322
  const ownedByViewer2 = identityIds.has(task2.creatorIdentityId);
2284
2323
  const destinations2 = await destinationDetails([task2.destination]);
@@ -2343,13 +2382,10 @@ async function taskSummaryForCandidate(candidate) {
2343
2382
  }
2344
2383
  async function readViewerTasks(user) {
2345
2384
  const db = getDb();
2346
- const schedulerStore = createSchedulerSqlStore(db);
2347
2385
  const identityIds = new Set(user.identities.map((identity) => identity.id));
2348
2386
  const teamIds = viewerTeamIds(user);
2349
2387
  const [scheduledPage, publicScheduled, eventTasks, publicEventTasks] = await Promise.all([
2350
- createViewerScheduledTasks(schedulerStore, user).list({
2351
- limit: TASK_FETCH_LIMIT
2352
- }),
2388
+ listViewerScheduledTasks(db, user, { limit: TASK_FETCH_LIMIT }),
2353
2389
  listPublicScheduledTasksForTeams(db, teamIds, TASK_FETCH_LIMIT),
2354
2390
  listEventTasksCreatedBy(db, user, TASK_FETCH_LIMIT),
2355
2391
  listPublicEventTasksForTeams(db, teamIds, TASK_FETCH_LIMIT)
@@ -2531,10 +2567,7 @@ async function readConversationSourceTask(args) {
2531
2567
  async function deleteViewerTask(user, kind, id) {
2532
2568
  if (kind === "scheduled") {
2533
2569
  try {
2534
- await createViewerScheduledTasks(
2535
- createSchedulerSqlStore(getDb()),
2536
- user
2537
- ).delete(id);
2570
+ await deleteViewerScheduledTask(getDb(), user, id);
2538
2571
  return;
2539
2572
  } catch (error) {
2540
2573
  if (error instanceof PersonalScheduledTaskNotFoundError) {
@@ -2875,20 +2908,20 @@ async function requireConversationPendingMessages(conversationId, options = {})
2875
2908
  }
2876
2909
 
2877
2910
  // 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";
2911
+ import { and as and10, eq as eq10, gte, isNull as isNull4, lte, sql as sql10 } from "drizzle-orm";
2879
2912
  import { alias as alias3 } from "drizzle-orm/pg-core";
2880
2913
 
2881
2914
  // src/api/conversations/aggregate.ts
2882
- import { sql as sql8 } from "drizzle-orm";
2915
+ import { sql as sql9 } from "drizzle-orm";
2883
2916
  function usageTokenValue(source, field) {
2884
- return sql8`CASE
2917
+ return sql9`CASE
2885
2918
  WHEN ${source.usage}->>${field} IS NOT NULL
2886
2919
  THEN (${source.usage}->>${field})::double precision
2887
2920
  ELSE NULL
2888
2921
  END`;
2889
2922
  }
2890
2923
  function tokenValue(source) {
2891
- return sql8`
2924
+ return sql9`
2892
2925
  CASE
2893
2926
  WHEN COALESCE(
2894
2927
  ${source.usage}->>'inputTokens',
@@ -2907,7 +2940,7 @@ function tokenValue(source) {
2907
2940
  `;
2908
2941
  }
2909
2942
  function costValue(source) {
2910
- return sql8`
2943
+ return sql9`
2911
2944
  CASE
2912
2945
  WHEN ${source.usage}->'cost'->>'total' IS NOT NULL
2913
2946
  THEN (${source.usage}->'cost'->>'total')::double precision
@@ -2928,34 +2961,34 @@ function costValue(source) {
2928
2961
  function conversationAggregateColumns(sources) {
2929
2962
  const metrics = sources?.metrics ?? juniorConversations;
2930
2963
  const roots = sources?.roots ?? juniorConversations;
2931
- const conversationCount = sources ? sql8`COUNT(DISTINCT ${roots.conversationId})` : sql8`COUNT(*)`;
2964
+ const conversationCount = sources ? sql9`COUNT(DISTINCT ${roots.conversationId})` : sql9`COUNT(*)`;
2932
2965
  return {
2933
- active: sql8`${conversationCount} FILTER (
2966
+ active: sql9`${conversationCount} FILTER (
2934
2967
  WHERE ${roots.executionStatus} NOT IN ('idle', 'failed')
2935
2968
  )::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 (
2969
+ conversations: sql9`${conversationCount}::integer`,
2970
+ cachedInputTokens: sql9`SUM(${usageTokenValue(metrics, "cachedInputTokens")})::double precision`,
2971
+ costUsd: sql9`SUM(${costValue(metrics)})::double precision`,
2972
+ durationMs: sql9`COALESCE(SUM(${metrics.durationMs}), 0)::double precision`,
2973
+ failed: sql9`${conversationCount} FILTER (
2941
2974
  WHERE ${roots.executionStatus} = 'failed'
2942
2975
  )::integer`,
2943
- inputTokens: sql8`SUM(${usageTokenValue(metrics, "inputTokens")})::double precision`,
2944
- tokens: sql8`SUM(${tokenValue(metrics)})::double precision`
2976
+ inputTokens: sql9`SUM(${usageTokenValue(metrics, "inputTokens")})::double precision`,
2977
+ tokens: sql9`SUM(${tokenValue(metrics)})::double precision`
2945
2978
  };
2946
2979
  }
2947
2980
  function conversationRangeColumns() {
2948
2981
  return {
2949
- firstSeenAt: sql8`MIN(${juniorConversations.createdAt})`.mapWith(
2982
+ firstSeenAt: sql9`MIN(${juniorConversations.createdAt})`.mapWith(
2950
2983
  juniorConversations.createdAt
2951
2984
  ),
2952
- lastSeenAt: sql8`MAX(${juniorConversations.lastActivityAt})`.mapWith(
2985
+ lastSeenAt: sql9`MAX(${juniorConversations.lastActivityAt})`.mapWith(
2953
2986
  juniorConversations.lastActivityAt
2954
2987
  )
2955
2988
  };
2956
2989
  }
2957
2990
  function conversationActiveDaysColumn() {
2958
- return sql8`COUNT(DISTINCT (${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC')::date)::integer`;
2991
+ return sql9`COUNT(DISTINCT (${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC')::date)::integer`;
2959
2992
  }
2960
2993
 
2961
2994
  // src/api/conversations/stats.query.ts
@@ -3019,7 +3052,7 @@ function statsItems(map) {
3019
3052
  );
3020
3053
  }
3021
3054
  function statsWhere(start, end) {
3022
- return and9(
3055
+ return and10(
3023
3056
  isNull4(juniorConversations.parentConversationId),
3024
3057
  gte(juniorConversations.lastActivityAt, start),
3025
3058
  lte(juniorConversations.lastActivityAt, end)
@@ -3096,14 +3129,14 @@ function guardianStats(rows, endMs) {
3096
3129
  }
3097
3130
  async function aggregateStats(db, start, end) {
3098
3131
  const where = statsWhere(start, end);
3099
- const activityDate = sql9`TO_CHAR(
3132
+ const activityDate = sql10`TO_CHAR(
3100
3133
  ${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
3101
3134
  'YYYY-MM-DD'
3102
3135
  )`;
3103
3136
  const [totalsRows, actorRows, locationRows, metricRows] = await Promise.all([
3104
3137
  db.select(treeAggregateColumns).from(juniorConversations).innerJoin(
3105
3138
  treeConversation,
3106
- eq9(
3139
+ eq10(
3107
3140
  treeConversation.rootConversationId,
3108
3141
  juniorConversations.conversationId
3109
3142
  )
@@ -3118,14 +3151,14 @@ async function aggregateStats(db, start, end) {
3118
3151
  ...treeAggregateColumns
3119
3152
  }).from(juniorConversations).innerJoin(
3120
3153
  treeConversation,
3121
- eq9(
3154
+ eq10(
3122
3155
  treeConversation.rootConversationId,
3123
3156
  juniorConversations.conversationId
3124
3157
  )
3125
3158
  ).leftJoin(
3126
3159
  juniorIdentities,
3127
- eq9(juniorIdentities.id, juniorConversations.actorIdentityId)
3128
- ).leftJoin(juniorUsers, eq9(juniorUsers.id, juniorIdentities.userId)).where(where).groupBy(
3160
+ eq10(juniorIdentities.id, juniorConversations.actorIdentityId)
3161
+ ).leftJoin(juniorUsers, eq10(juniorUsers.id, juniorIdentities.userId)).where(where).groupBy(
3129
3162
  juniorIdentities.displayName,
3130
3163
  juniorIdentities.emailNormalized,
3131
3164
  juniorIdentities.handle,
@@ -3143,13 +3176,13 @@ async function aggregateStats(db, start, end) {
3143
3176
  ...treeAggregateColumns
3144
3177
  }).from(juniorConversations).innerJoin(
3145
3178
  treeConversation,
3146
- eq9(
3179
+ eq10(
3147
3180
  treeConversation.rootConversationId,
3148
3181
  juniorConversations.conversationId
3149
3182
  )
3150
3183
  ).leftJoin(
3151
3184
  juniorDestinations,
3152
- eq9(juniorDestinations.id, juniorConversations.destinationId)
3185
+ eq10(juniorDestinations.id, juniorConversations.destinationId)
3153
3186
  ).where(where).groupBy(
3154
3187
  juniorConversations.channelName,
3155
3188
  juniorConversations.source,
@@ -3168,7 +3201,7 @@ async function aggregateStats(db, start, end) {
3168
3201
  tokens: treeAggregateColumns.tokens
3169
3202
  }).from(juniorConversations).innerJoin(
3170
3203
  treeConversation,
3171
- eq9(
3204
+ eq10(
3172
3205
  treeConversation.rootConversationId,
3173
3206
  juniorConversations.conversationId
3174
3207
  )
@@ -3177,26 +3210,26 @@ async function aggregateStats(db, start, end) {
3177
3210
  return { actorRows, locationRows, metricRows, totals: totalsRows[0] };
3178
3211
  }
3179
3212
  async function aggregateGuardianStats(db, start, end) {
3180
- const date = sql9`TO_CHAR(
3213
+ const date = sql10`TO_CHAR(
3181
3214
  ${juniorConversationEvents.createdAt} AT TIME ZONE 'UTC',
3182
3215
  'YYYY-MM-DD'
3183
3216
  )`;
3184
- const decision = sql9`${juniorConversationEvents.payload}->>'decision'`;
3185
- const cost2 = sql9`CASE
3217
+ const decision = sql10`${juniorConversationEvents.payload}->>'decision'`;
3218
+ const cost2 = sql10`CASE
3186
3219
  WHEN jsonb_typeof(${juniorConversationEvents.payload}->'costUsd') = 'number'
3187
3220
  THEN (${juniorConversationEvents.payload}->>'costUsd')::double precision
3188
3221
  ELSE NULL
3189
3222
  END`;
3190
3223
  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`,
3224
+ allow: sql10`COUNT(*) FILTER (WHERE ${decision} = 'allow')::integer`,
3225
+ ask: sql10`COUNT(*) FILTER (WHERE ${decision} = 'ask')::integer`,
3226
+ costUsd: sql10`SUM(${cost2})::double precision`,
3194
3227
  date,
3195
- deny: sql9`COUNT(*) FILTER (WHERE ${decision} = 'deny')::integer`,
3196
- requests: sql9`COUNT(*)::integer`
3228
+ deny: sql10`COUNT(*) FILTER (WHERE ${decision} = 'deny')::integer`,
3229
+ requests: sql10`COUNT(*)::integer`
3197
3230
  }).from(juniorConversationEvents).where(
3198
- and9(
3199
- eq9(juniorConversationEvents.type, "guardian_action_reviewed"),
3231
+ and10(
3232
+ eq10(juniorConversationEvents.type, "guardian_action_reviewed"),
3200
3233
  gte(juniorConversationEvents.createdAt, start),
3201
3234
  lte(juniorConversationEvents.createdAt, end)
3202
3235
  )
@@ -3460,7 +3493,7 @@ function createConversationRoutes(options) {
3460
3493
  import { Hono as Hono2 } from "hono";
3461
3494
 
3462
3495
  // 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";
3496
+ 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
3497
  import { alias as alias4 } from "drizzle-orm/pg-core";
3465
3498
 
3466
3499
  // src/api/conversations/reporting.ts
@@ -3568,10 +3601,10 @@ function topLevelWhere() {
3568
3601
  return isNull5(juniorConversations.parentConversationId);
3569
3602
  }
3570
3603
  function publicLocationWhere(destinationId) {
3571
- return and10(
3604
+ return and11(
3572
3605
  topLevelWhere(),
3573
- eq10(juniorDestinations.id, destinationId),
3574
- eq10(juniorDestinations.visibility, "public")
3606
+ eq11(juniorDestinations.id, destinationId),
3607
+ eq11(juniorDestinations.visibility, "public")
3575
3608
  );
3576
3609
  }
3577
3610
  function locationColumns() {
@@ -3622,28 +3655,28 @@ async function directoryRows(db) {
3622
3655
  ...conversationRangeColumns()
3623
3656
  }).from(juniorConversations).innerJoin(
3624
3657
  treeConversation2,
3625
- eq10(
3658
+ eq11(
3626
3659
  treeConversation2.rootConversationId,
3627
3660
  juniorConversations.conversationId
3628
3661
  )
3629
3662
  ).leftJoin(
3630
3663
  juniorDestinations,
3631
- eq10(juniorDestinations.id, juniorConversations.destinationId)
3664
+ eq11(juniorDestinations.id, juniorConversations.destinationId)
3632
3665
  ).where(topLevelWhere()).groupBy(...locationGroupBy());
3633
3666
  }
3634
3667
  async function directoryActivityRows(db, start) {
3635
- const date = sql10`TO_CHAR(
3668
+ const date = sql11`TO_CHAR(
3636
3669
  ${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
3637
3670
  'YYYY-MM-DD'
3638
3671
  )`;
3639
3672
  return db.select({
3640
- conversations: sql10`COUNT(*)::integer`,
3673
+ conversations: sql11`COUNT(*)::integer`,
3641
3674
  date,
3642
3675
  visibility: juniorDestinations.visibility
3643
3676
  }).from(juniorConversations).leftJoin(
3644
3677
  juniorDestinations,
3645
- eq10(juniorDestinations.id, juniorConversations.destinationId)
3646
- ).where(and10(topLevelWhere(), gte2(juniorConversations.lastActivityAt, start))).groupBy(date, juniorDestinations.visibility);
3678
+ eq11(juniorDestinations.id, juniorConversations.destinationId)
3679
+ ).where(and11(topLevelWhere(), gte2(juniorConversations.lastActivityAt, start))).groupBy(date, juniorDestinations.visibility);
3647
3680
  }
3648
3681
  function directoryActivityDays(rows, nowMs) {
3649
3682
  const days = /* @__PURE__ */ new Map();
@@ -3716,7 +3749,7 @@ async function recentLocationRows(db, locationId) {
3716
3749
  createdAt: juniorConversations.createdAt,
3717
3750
  destinationId: juniorDestinations.id,
3718
3751
  durationMs: juniorConversations.durationMs,
3719
- email: sql10`COALESCE(
3752
+ email: sql11`COALESCE(
3720
3753
  ${juniorUsers.primaryEmailNormalized},
3721
3754
  ${juniorIdentities.email}
3722
3755
  )`,
@@ -3725,7 +3758,7 @@ async function recentLocationRows(db, locationId) {
3725
3758
  fullName: juniorUsers.displayName,
3726
3759
  handle: juniorIdentities.handle,
3727
3760
  lastActivityAt: juniorConversations.lastActivityAt,
3728
- providerSubjectId: sql10`CASE
3761
+ providerSubjectId: sql11`CASE
3729
3762
  WHEN ${juniorIdentities.provider} = 'slack'
3730
3763
  THEN ${juniorIdentities.providerSubjectId}
3731
3764
  ELSE NULL
@@ -3736,12 +3769,12 @@ async function recentLocationRows(db, locationId) {
3736
3769
  usage: juniorConversations.usage
3737
3770
  }).from(juniorConversations).innerJoin(
3738
3771
  juniorDestinations,
3739
- eq10(juniorDestinations.id, juniorConversations.destinationId)
3772
+ eq11(juniorDestinations.id, juniorConversations.destinationId)
3740
3773
  ).leftJoin(
3741
3774
  juniorIdentities,
3742
- eq10(juniorIdentities.id, juniorConversations.actorIdentityId)
3743
- ).leftJoin(juniorUsers, eq10(juniorUsers.id, juniorIdentities.userId)).where(publicLocationWhere(locationId)).orderBy(
3744
- desc3(juniorConversations.lastActivityAt),
3775
+ eq11(juniorIdentities.id, juniorConversations.actorIdentityId)
3776
+ ).leftJoin(juniorUsers, eq11(juniorUsers.id, juniorIdentities.userId)).where(publicLocationWhere(locationId)).orderBy(
3777
+ desc4(juniorConversations.lastActivityAt),
3745
3778
  asc3(juniorConversations.conversationId)
3746
3779
  ).limit(RECENT_LIMIT);
3747
3780
  }
@@ -3752,7 +3785,7 @@ async function readLocationDetailFromSql(locationId, options = {}) {
3752
3785
  const start = new Date(end);
3753
3786
  start.setUTCDate(start.getUTCDate() - (ACTIVITY_DAYS - 1));
3754
3787
  const where = publicLocationWhere(locationId);
3755
- const activityDate = sql10`TO_CHAR(
3788
+ const activityDate = sql11`TO_CHAR(
3756
3789
  ${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
3757
3790
  'YYYY-MM-DD'
3758
3791
  )`;
@@ -3763,27 +3796,27 @@ async function readLocationDetailFromSql(locationId, options = {}) {
3763
3796
  ...conversationRangeColumns()
3764
3797
  }).from(juniorConversations).innerJoin(
3765
3798
  treeConversation2,
3766
- eq10(
3799
+ eq11(
3767
3800
  treeConversation2.rootConversationId,
3768
3801
  juniorConversations.conversationId
3769
3802
  )
3770
3803
  ).innerJoin(
3771
3804
  juniorDestinations,
3772
- eq10(juniorDestinations.id, juniorConversations.destinationId)
3805
+ eq11(juniorDestinations.id, juniorConversations.destinationId)
3773
3806
  ).where(where).groupBy(...locationGroupBy()),
3774
3807
  getDb().select({
3775
3808
  date: activityDate,
3776
3809
  ...treeAggregateColumns2
3777
3810
  }).from(juniorConversations).innerJoin(
3778
3811
  treeConversation2,
3779
- eq10(
3812
+ eq11(
3780
3813
  treeConversation2.rootConversationId,
3781
3814
  juniorConversations.conversationId
3782
3815
  )
3783
3816
  ).innerJoin(
3784
3817
  juniorDestinations,
3785
- eq10(juniorDestinations.id, juniorConversations.destinationId)
3786
- ).where(and10(where, gte2(juniorConversations.lastActivityAt, start))).groupBy(activityDate),
3818
+ eq11(juniorDestinations.id, juniorConversations.destinationId)
3819
+ ).where(and11(where, gte2(juniorConversations.lastActivityAt, start))).groupBy(activityDate),
3787
3820
  getDb().select({
3788
3821
  actorIdentityId: juniorConversations.actorIdentityId,
3789
3822
  email: juniorUsers.primaryEmailNormalized,
@@ -3795,17 +3828,17 @@ async function readLocationDetailFromSql(locationId, options = {}) {
3795
3828
  ...treeAggregateColumns2
3796
3829
  }).from(juniorConversations).innerJoin(
3797
3830
  treeConversation2,
3798
- eq10(
3831
+ eq11(
3799
3832
  treeConversation2.rootConversationId,
3800
3833
  juniorConversations.conversationId
3801
3834
  )
3802
3835
  ).innerJoin(
3803
3836
  juniorDestinations,
3804
- eq10(juniorDestinations.id, juniorConversations.destinationId)
3837
+ eq11(juniorDestinations.id, juniorConversations.destinationId)
3805
3838
  ).leftJoin(
3806
3839
  juniorIdentities,
3807
- eq10(juniorIdentities.id, juniorConversations.actorIdentityId)
3808
- ).leftJoin(juniorUsers, eq10(juniorUsers.id, juniorIdentities.userId)).where(where).groupBy(
3840
+ eq11(juniorIdentities.id, juniorConversations.actorIdentityId)
3841
+ ).leftJoin(juniorUsers, eq11(juniorUsers.id, juniorIdentities.userId)).where(where).groupBy(
3809
3842
  juniorConversations.actorIdentityId,
3810
3843
  juniorUsers.primaryEmailNormalized,
3811
3844
  juniorUsers.displayName,
@@ -3918,10 +3951,10 @@ function createLocationRoutes() {
3918
3951
  import { Hono as Hono3 } from "hono";
3919
3952
 
3920
3953
  // src/api/people/list.query.ts
3921
- import { and as and12, eq as eq12, gte as gte3, sql as sql12 } from "drizzle-orm";
3954
+ import { and as and13, eq as eq13, gte as gte3, sql as sql13 } from "drizzle-orm";
3922
3955
 
3923
3956
  // 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";
3957
+ 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
3958
  import { alias as alias5 } from "drizzle-orm/pg-core";
3926
3959
  var RECENT_LIMIT2 = 25;
3927
3960
  var ACTIVITY_DAYS2 = 365;
@@ -3941,37 +3974,37 @@ var peopleTreeAggregateColumns = conversationAggregateColumns({
3941
3974
  function peopleTreeMetricsJoin() {
3942
3975
  const rootOwnedByActor = getDb().select({ conversationId: peopleRootConversation.conversationId }).from(peopleRootConversation).innerJoin(
3943
3976
  peopleRootIdentity,
3944
- eq11(peopleRootIdentity.id, peopleRootConversation.actorIdentityId)
3977
+ eq12(peopleRootIdentity.id, peopleRootConversation.actorIdentityId)
3945
3978
  ).where(
3946
- and11(
3947
- eq11(
3979
+ and12(
3980
+ eq12(
3948
3981
  peopleRootConversation.conversationId,
3949
3982
  juniorConversations.rootConversationId
3950
3983
  ),
3951
3984
  isNull6(peopleRootConversation.parentConversationId),
3952
- eq11(
3985
+ eq12(
3953
3986
  peopleRootConversation.rootConversationId,
3954
3987
  peopleRootConversation.conversationId
3955
3988
  ),
3956
- eq11(
3989
+ eq12(
3957
3990
  peopleRootIdentity.emailNormalized,
3958
3991
  juniorUsers.primaryEmailNormalized
3959
3992
  ),
3960
- eq11(peopleRootIdentity.emailVerified, true)
3993
+ eq12(peopleRootIdentity.emailVerified, true)
3961
3994
  )
3962
3995
  );
3963
- return and11(
3964
- eq11(
3996
+ return and12(
3997
+ eq12(
3965
3998
  peopleTreeConversation.rootConversationId,
3966
3999
  juniorConversations.rootConversationId
3967
4000
  ),
3968
- or4(
3969
- eq11(
4001
+ or5(
4002
+ eq12(
3970
4003
  juniorConversations.rootConversationId,
3971
4004
  juniorConversations.conversationId
3972
4005
  ),
3973
- and11(
3974
- eq11(
4006
+ and12(
4007
+ eq12(
3975
4008
  peopleTreeConversation.conversationId,
3976
4009
  juniorConversations.conversationId
3977
4010
  ),
@@ -4021,11 +4054,11 @@ function statsItems2(map) {
4021
4054
  }
4022
4055
  function verifiedActorWhere(email) {
4023
4056
  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
4057
+ return and12(
4058
+ eq12(juniorIdentities.provider, "slack"),
4059
+ eq12(juniorIdentities.emailVerified, true),
4060
+ sql12`${juniorUsers.primaryEmailNormalized} IS NOT NULL`,
4061
+ normalizedEmail ? eq12(juniorUsers.primaryEmailNormalized, normalizedEmail) : void 0
4029
4062
  );
4030
4063
  }
4031
4064
  async function recentActorRows(email) {
@@ -4048,12 +4081,12 @@ async function recentActorRows(email) {
4048
4081
  usage: juniorConversations.usage
4049
4082
  }).from(juniorConversations).innerJoin(
4050
4083
  juniorIdentities,
4051
- eq11(juniorIdentities.id, juniorConversations.actorIdentityId)
4052
- ).innerJoin(juniorUsers, eq11(juniorUsers.id, juniorIdentities.userId)).leftJoin(
4084
+ eq12(juniorIdentities.id, juniorConversations.actorIdentityId)
4085
+ ).innerJoin(juniorUsers, eq12(juniorUsers.id, juniorIdentities.userId)).leftJoin(
4053
4086
  juniorDestinations,
4054
- eq11(juniorDestinations.id, juniorConversations.destinationId)
4087
+ eq12(juniorDestinations.id, juniorConversations.destinationId)
4055
4088
  ).where(verifiedActorWhere(email)).orderBy(
4056
- desc4(juniorConversations.lastActivityAt),
4089
+ desc5(juniorConversations.lastActivityAt),
4057
4090
  asc4(juniorConversations.conversationId)
4058
4091
  ).limit(RECENT_LIMIT2);
4059
4092
  }
@@ -4080,7 +4113,7 @@ function directoryActivityDays2(rows, nowMs) {
4080
4113
  async function readPeopleListFromSql() {
4081
4114
  const nowMs = Date.now();
4082
4115
  const { end, start } = activityWindow(nowMs);
4083
- const activityDate = sql12`TO_CHAR(
4116
+ const activityDate = sql13`TO_CHAR(
4084
4117
  ${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
4085
4118
  'YYYY-MM-DD'
4086
4119
  )`;
@@ -4088,24 +4121,24 @@ async function readPeopleListFromSql() {
4088
4121
  getDb().select({
4089
4122
  email: juniorUsers.primaryEmailNormalized,
4090
4123
  fullName: juniorUsers.displayName,
4091
- slackUserId: sql12`MAX(${juniorIdentities.providerSubjectId})`,
4092
- slackUserName: sql12`MAX(${juniorIdentities.handle})`,
4124
+ slackUserId: sql13`MAX(${juniorIdentities.providerSubjectId})`,
4125
+ slackUserName: sql13`MAX(${juniorIdentities.handle})`,
4093
4126
  activeDays: conversationActiveDaysColumn(),
4094
4127
  ...peopleTreeAggregateColumns,
4095
4128
  ...conversationRangeColumns()
4096
4129
  }).from(juniorConversations).innerJoin(
4097
4130
  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),
4131
+ eq13(juniorIdentities.id, juniorConversations.actorIdentityId)
4132
+ ).innerJoin(juniorUsers, eq13(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, peopleTreeMetricsJoin()).where(verifiedActorWhere()).groupBy(juniorUsers.primaryEmailNormalized, juniorUsers.displayName),
4100
4133
  getDb().select({
4101
- activePeople: sql12`COUNT(DISTINCT ${juniorUsers.id})::int`,
4102
- conversations: sql12`COUNT(*)::int`,
4134
+ activePeople: sql13`COUNT(DISTINCT ${juniorUsers.id})::int`,
4135
+ conversations: sql13`COUNT(*)::int`,
4103
4136
  date: activityDate
4104
4137
  }).from(juniorConversations).innerJoin(
4105
4138
  juniorIdentities,
4106
- eq12(juniorIdentities.id, juniorConversations.actorIdentityId)
4107
- ).innerJoin(juniorUsers, eq12(juniorUsers.id, juniorIdentities.userId)).where(
4108
- and12(
4139
+ eq13(juniorIdentities.id, juniorConversations.actorIdentityId)
4140
+ ).innerJoin(juniorUsers, eq13(juniorUsers.id, juniorIdentities.userId)).where(
4141
+ and13(
4109
4142
  verifiedActorWhere(),
4110
4143
  gte3(juniorConversations.lastActivityAt, start)
4111
4144
  )
@@ -4158,7 +4191,7 @@ async function readPeoplePluginReports(args) {
4158
4191
  source: "plugins"
4159
4192
  });
4160
4193
  }
4161
- const { getPluginProfileReports } = await import("./agent-hooks-PBT4NNBV.js");
4194
+ const { getPluginProfileReports } = await import("./agent-hooks-32IDCLMW.js");
4162
4195
  return pluginOperationalReportFeedSchema.parse({
4163
4196
  generatedAt: new Date(nowMs).toISOString(),
4164
4197
  reports: await getPluginProfileReports({
@@ -4171,7 +4204,7 @@ async function readPeoplePluginReports(args) {
4171
4204
  }
4172
4205
 
4173
4206
  // src/api/people/profile.query.ts
4174
- import { and as and13, eq as eq13, gte as gte4, sql as sql13 } from "drizzle-orm";
4207
+ import { and as and14, eq as eq14, gte as gte4, sql as sql14 } from "drizzle-orm";
4175
4208
  function emptyProfile(email, nowMs) {
4176
4209
  const end = new Date(nowMs);
4177
4210
  end.setUTCHours(0, 0, 0, 0);
@@ -4206,7 +4239,7 @@ function addAggregate2(map, label, row) {
4206
4239
  map.set(label, item);
4207
4240
  }
4208
4241
  function surfaceExpression() {
4209
- return sql13`CASE
4242
+ return sql14`CASE
4210
4243
  WHEN ${juniorConversations.source} IN ('api', 'scheduler', 'slack')
4211
4244
  THEN ${juniorConversations.source}
4212
4245
  WHEN ${juniorConversations.conversationId} LIKE 'slack:%' THEN 'slack'
@@ -4235,30 +4268,30 @@ async function readPeopleProfileFromSql(email, options = {}) {
4235
4268
  const where = verifiedActorWhere(normalizedEmail);
4236
4269
  const metricsJoin = peopleTreeMetricsJoin();
4237
4270
  const surface = surfaceExpression();
4238
- const activityDate = sql13`TO_CHAR(
4271
+ const activityDate = sql14`TO_CHAR(
4239
4272
  ${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
4240
4273
  'YYYY-MM-DD'
4241
4274
  )`;
4242
- const channel = sql13`SPLIT_PART(${juniorConversations.conversationId}, ':', 2)`;
4275
+ const channel = sql14`SPLIT_PART(${juniorConversations.conversationId}, ':', 2)`;
4243
4276
  const [totalsRows, dayRows, locationRows, surfaceRows, recentRows] = await Promise.all([
4244
4277
  getDb().select({
4245
4278
  email: juniorUsers.primaryEmailNormalized,
4246
4279
  fullName: juniorUsers.displayName,
4247
- slackUserId: sql13`MAX(${juniorIdentities.providerSubjectId})`,
4248
- slackUserName: sql13`MAX(${juniorIdentities.handle})`,
4280
+ slackUserId: sql14`MAX(${juniorIdentities.providerSubjectId})`,
4281
+ slackUserName: sql14`MAX(${juniorIdentities.handle})`,
4249
4282
  activeDays: conversationActiveDaysColumn(),
4250
4283
  ...peopleTreeAggregateColumns
4251
4284
  }).from(juniorConversations).innerJoin(
4252
4285
  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),
4286
+ eq14(juniorIdentities.id, juniorConversations.actorIdentityId)
4287
+ ).innerJoin(juniorUsers, eq14(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(where).groupBy(juniorUsers.primaryEmailNormalized, juniorUsers.displayName),
4255
4288
  getDb().select({
4256
4289
  date: activityDate,
4257
4290
  ...peopleTreeAggregateColumns
4258
4291
  }).from(juniorConversations).innerJoin(
4259
4292
  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),
4293
+ eq14(juniorIdentities.id, juniorConversations.actorIdentityId)
4294
+ ).innerJoin(juniorUsers, eq14(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(and14(where, gte4(juniorConversations.lastActivityAt, start))).groupBy(activityDate),
4262
4295
  getDb().select({
4263
4296
  channel,
4264
4297
  channelName: juniorConversations.channelName,
@@ -4267,10 +4300,10 @@ async function readPeopleProfileFromSql(email, options = {}) {
4267
4300
  ...peopleTreeAggregateColumns
4268
4301
  }).from(juniorConversations).innerJoin(
4269
4302
  juniorIdentities,
4270
- eq13(juniorIdentities.id, juniorConversations.actorIdentityId)
4271
- ).innerJoin(juniorUsers, eq13(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).leftJoin(
4303
+ eq14(juniorIdentities.id, juniorConversations.actorIdentityId)
4304
+ ).innerJoin(juniorUsers, eq14(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).leftJoin(
4272
4305
  juniorDestinations,
4273
- eq13(juniorDestinations.id, juniorConversations.destinationId)
4306
+ eq14(juniorDestinations.id, juniorConversations.destinationId)
4274
4307
  ).where(where).groupBy(
4275
4308
  channel,
4276
4309
  juniorConversations.channelName,
@@ -4279,8 +4312,8 @@ async function readPeopleProfileFromSql(email, options = {}) {
4279
4312
  ),
4280
4313
  getDb().select({ surface, ...peopleTreeAggregateColumns }).from(juniorConversations).innerJoin(
4281
4314
  juniorIdentities,
4282
- eq13(juniorIdentities.id, juniorConversations.actorIdentityId)
4283
- ).innerJoin(juniorUsers, eq13(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(where).groupBy(surface),
4315
+ eq14(juniorIdentities.id, juniorConversations.actorIdentityId)
4316
+ ).innerJoin(juniorUsers, eq14(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(where).groupBy(surface),
4284
4317
  recentActorRows(normalizedEmail)
4285
4318
  ]);
4286
4319
  const totalsRow = totalsRows[0];
@@ -4358,7 +4391,7 @@ async function readPeopleProfile(email, options = {}) {
4358
4391
  }
4359
4392
 
4360
4393
  // 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";
4394
+ import { and as and15, eq as eq15, gte as gte5, lte as lte2, sql as sql15 } from "drizzle-orm";
4362
4395
  var SEVEN_DAY_OFFSET = 6;
4363
4396
  var THIRTY_DAY_OFFSET = 29;
4364
4397
  function addUsd2(current, next) {
@@ -4377,7 +4410,7 @@ function spendWindow(nowMs) {
4377
4410
  async function readPersonalSpendFromSql(email, nowMs = Date.now()) {
4378
4411
  const normalizedEmail = normalizeEmail(email);
4379
4412
  const { end, sevenDayStart, thirtyDayStart } = spendWindow(nowMs);
4380
- const activityDate = sql14`TO_CHAR(
4413
+ const activityDate = sql15`TO_CHAR(
4381
4414
  ${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
4382
4415
  'YYYY-MM-DD'
4383
4416
  )`;
@@ -4387,9 +4420,9 @@ async function readPersonalSpendFromSql(email, nowMs = Date.now()) {
4387
4420
  date: activityDate
4388
4421
  }).from(juniorConversations).innerJoin(
4389
4422
  juniorIdentities,
4390
- eq14(juniorIdentities.id, juniorConversations.actorIdentityId)
4391
- ).innerJoin(juniorUsers, eq14(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(
4392
- and14(
4423
+ eq15(juniorIdentities.id, juniorConversations.actorIdentityId)
4424
+ ).innerJoin(juniorUsers, eq15(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(
4425
+ and15(
4393
4426
  verifiedActorWhere(normalizedEmail),
4394
4427
  gte5(juniorConversations.lastActivityAt, thirtyDayStart),
4395
4428
  lte2(juniorConversations.lastActivityAt, end)
@@ -4877,7 +4910,7 @@ function readDescriptionText(home) {
4877
4910
  }
4878
4911
  }
4879
4912
  async function readSkillReports() {
4880
- const { discoverSkills } = await import("./skills-U5KQ66EM.js");
4913
+ const { discoverSkills } = await import("./skills-U545HALM.js");
4881
4914
  const skills = await discoverSkills();
4882
4915
  return skillReportsSchema.parse(
4883
4916
  skills.map((skill) => ({
@@ -4887,7 +4920,7 @@ async function readSkillReports() {
4887
4920
  );
4888
4921
  }
4889
4922
  async function readPlugins() {
4890
- const { pluginCatalogRuntime } = await import("./catalog-runtime-M7QGKPFZ.js");
4923
+ const { pluginCatalogRuntime } = await import("./catalog-runtime-FBVA6WAQ.js");
4891
4924
  return pluginsSchema.parse(
4892
4925
  pluginCatalogRuntime.getProviders().map((plugin) => ({
4893
4926
  configKeys: plugin.manifest.configKeys ?? [],
@@ -4900,7 +4933,7 @@ async function readPlugins() {
4900
4933
  async function readRuntimeInfoReport() {
4901
4934
  const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
4902
4935
  import("./discovery-GUFTFBTL.js"),
4903
- import("./catalog-runtime-M7QGKPFZ.js"),
4936
+ import("./catalog-runtime-FBVA6WAQ.js"),
4904
4937
  readPlugins(),
4905
4938
  readSkillReports()
4906
4939
  ]);
@@ -4916,7 +4949,7 @@ async function readRuntimeInfoReport() {
4916
4949
  }
4917
4950
  async function readPluginOperationalReportFeed() {
4918
4951
  const nowMs = Date.now();
4919
- const { getPluginOperationalReports } = await import("./agent-hooks-PBT4NNBV.js");
4952
+ const { getPluginOperationalReports } = await import("./agent-hooks-32IDCLMW.js");
4920
4953
  return pluginOperationalReportFeedSchema.parse({
4921
4954
  source: "plugins",
4922
4955
  generatedAt: new Date(nowMs).toISOString(),