@sentry/junior 0.192.0 → 0.194.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-hooks-3JY76L5X.js → agent-hooks-IDX764FD.js} +11 -11
- package/dist/api/conversations/aggregate.d.ts +2 -0
- package/dist/api/conversations/list.d.ts +1 -1
- package/dist/api/conversations/projection.d.ts +1 -1
- package/dist/api/locations/detail.d.ts +1 -1
- package/dist/api/schema/conversation.d.ts +3 -3
- package/dist/api/schema/location.d.ts +1 -1
- package/dist/api/schema/person.d.ts +1 -1
- package/dist/api/schema/task.d.ts +71 -8
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +3 -1
- package/dist/api.js +106 -187
- package/dist/app.js +55 -83
- package/dist/{catalog-runtime-5JVLWXRY.js → catalog-runtime-MICXEBLK.js} +4 -4
- package/dist/chat/agent/prompt.d.ts +1 -1
- package/dist/chat/agent/resume.d.ts +2 -0
- package/dist/chat/agent-dispatch/types.d.ts +2 -1
- package/dist/chat/agent-dispatch/validation.d.ts +1 -1
- package/dist/chat/agent-invocations/types.d.ts +24 -28
- package/dist/chat/config.d.ts +1 -0
- package/dist/chat/conversations/history.d.ts +4 -2
- package/dist/chat/event-tasks/tool-support.d.ts +10 -1
- package/dist/chat/plugins/agent-hooks.d.ts +2 -2
- package/dist/chat/prompt.d.ts +4 -5
- package/dist/chat/services/turn-limit.d.ts +11 -1
- package/dist/chat/services/turn-session-routing.d.ts +4 -3
- package/dist/chat/slack/{source-link.d.ts → location-url.d.ts} +1 -1
- package/dist/chat/slack/tool-support/context.d.ts +3 -6
- package/dist/chat/source.d.ts +4 -6
- package/dist/chat/task-execution/checkpoint.d.ts +2 -0
- package/dist/chat/task-execution/turn-cursor.d.ts +3 -0
- package/dist/chat/tasks/execution-stats.d.ts +13 -1
- package/dist/chat/tools/delete-event-task.d.ts +1 -1
- package/dist/chat/tools/types.d.ts +10 -9
- package/dist/chat/tools/update-event-task.d.ts +1 -1
- package/dist/chat/usage.d.ts +4 -0
- package/dist/{chunk-YRWGJ5OO.js → chunk-2NL3Y47F.js} +5 -5
- package/dist/{chunk-BGLMT6KP.js → chunk-53IEEFFP.js} +3 -3
- package/dist/{chunk-PXUBRZBU.js → chunk-6H2MKVV5.js} +1 -1
- package/dist/{chunk-47JFLZSF.js → chunk-73JEAQRT.js} +4 -4
- package/dist/{chunk-6LX6KV5C.js → chunk-7ANA7PBB.js} +3 -3
- package/dist/{chunk-AKR6W7VV.js → chunk-ADEACKAH.js} +82 -69
- package/dist/{chunk-YE6DVM43.js → chunk-AWZS5SVX.js} +8 -8
- package/dist/{chunk-BUTAWPUV.js → chunk-CCTYK5RH.js} +37 -31
- package/dist/{chunk-RWBZZMW6.js → chunk-CFGBKPWQ.js} +3 -3
- package/dist/{chunk-G4E5WIRL.js → chunk-E53C73ML.js} +4 -4
- package/dist/{chunk-3UJSII43.js → chunk-ELCYG6UU.js} +3 -3
- package/dist/{chunk-SSR6YBWW.js → chunk-ENWIHU54.js} +11 -7
- package/dist/{chunk-4CCQZHD3.js → chunk-F2KSURTJ.js} +11 -11
- package/dist/{chunk-7XO7PTZE.js → chunk-G35QGPO2.js} +1 -1
- package/dist/{chunk-4B4DQGOM.js → chunk-G4RARFNT.js} +101 -66
- package/dist/{chunk-Z4DNJI5F.js → chunk-GY5SEFVL.js} +5 -5
- package/dist/{chunk-KR5F3QSP.js → chunk-H4DCWLTR.js} +8 -8
- package/dist/{chunk-ARSUYYQG.js → chunk-IME5OW4Y.js} +1 -1
- package/dist/{chunk-3O2NXVGB.js → chunk-INTBMGNX.js} +23 -25
- package/dist/{chunk-4WIA45WD.js → chunk-IOGDKPVU.js} +1 -1
- package/dist/{chunk-EYNUOZCN.js → chunk-JOI3DHML.js} +1 -1
- package/dist/{chunk-5V4BAUCH.js → chunk-KNIAWMBU.js} +1 -1
- package/dist/{chunk-ITTEDZGY.js → chunk-NPO24LAN.js} +32 -25
- package/dist/{chunk-SZ2O3CGS.js → chunk-NWWDFHXP.js} +1 -1
- package/dist/{chunk-VF3EDS7P.js → chunk-OEQOAONV.js} +60 -29
- package/dist/{chunk-PYVGXGKC.js → chunk-P2P6MUQ4.js} +2 -2
- package/dist/{chunk-PXP2M32M.js → chunk-QMEF4Z7R.js} +6 -7
- package/dist/{chunk-OBN7UEQJ.js → chunk-RFE7DCZK.js} +24 -2
- package/dist/{chunk-6FCKJDKS.js → chunk-S7GX44BU.js} +1 -1
- package/dist/{chunk-4Z7B5WVV.js → chunk-U76RWMFR.js} +4 -2
- package/dist/{chunk-LRTEMMCZ.js → chunk-V4HXV5MY.js} +1 -1
- package/dist/{chunk-MB2CTEPD.js → chunk-VOB2DKO6.js} +174 -34
- package/dist/{chunk-EIYOABL4.js → chunk-WMJS5DDV.js} +12 -8
- package/dist/{chunk-FGYWKKTJ.js → chunk-WWXJUURQ.js} +1 -1
- package/dist/{chunk-3ADPXQBL.js → chunk-X76JVHQ4.js} +1 -1
- package/dist/{chunk-IBO4YFFZ.js → chunk-XLWZRHX5.js} +1 -1
- package/dist/{chunk-H5Q2T5VC.js → chunk-XND3J6AT.js} +1 -1
- package/dist/{chunk-4AFSQJD6.js → chunk-XRDSML3K.js} +3 -4
- package/dist/{chunk-EYIMZY5O.js → chunk-YSLIB7ER.js} +18 -3
- package/dist/cli/chat.js +33 -33
- package/dist/cli/check.js +5 -5
- package/dist/cli/plugins.js +12 -12
- package/dist/cli/snapshot-create.js +9 -9
- package/dist/cli/upgrade.js +6 -6
- package/dist/db/schema/agent-invocations.d.ts +16 -0
- package/dist/db/schema.d.ts +16 -0
- package/dist/{db-LRM6AP66.js → db-3IEVINAY.js} +6 -6
- package/dist/instrumentation.js +3 -3
- package/dist/nitro.js +6 -6
- package/dist/{oauth-callback-server-BKCDVYVH.js → oauth-callback-server-N7L2BB4L.js} +29 -29
- package/dist/{runner-RUXGS3E6.js → runner-PTTZV3WU.js} +21 -21
- package/dist/{skills-DXP2RCJF.js → skills-POMWS2RR.js} +5 -5
- package/dist/spawn-R75MXXKE.js +42 -0
- package/dist/task-runner-OQLRHADB.js +36 -0
- package/dist/{validation-F4KYLIF2.js → validation-U6LOMXR7.js} +5 -5
- package/dist/version.js +1 -1
- package/dist/{work-UUNMNSML.js → work-FHA3BS4L.js} +21 -21
- package/dist/{worker-PMIJ5NLD.js → worker-GR4UNVVP.js} +10 -10
- package/package.json +5 -5
- package/dist/spawn-HH7GH7XT.js +0 -42
- package/dist/task-runner-H5I7R3LJ.js +0 -36
package/dist/api.js
CHANGED
|
@@ -52,7 +52,7 @@ import {
|
|
|
52
52
|
workspaceListSchema,
|
|
53
53
|
workspaceParamsSchema,
|
|
54
54
|
workspaceSchema
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-YSLIB7ER.js";
|
|
56
56
|
import {
|
|
57
57
|
appendAndEnqueueWebMessage,
|
|
58
58
|
conversationArchiveTimes,
|
|
@@ -72,13 +72,17 @@ import {
|
|
|
72
72
|
resolveSlackConversationContextFromThreadId,
|
|
73
73
|
viewerConversationMembership,
|
|
74
74
|
webActorFromEmail
|
|
75
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-H4DCWLTR.js";
|
|
76
76
|
import {
|
|
77
77
|
buildSentryConversationUrl,
|
|
78
78
|
buildSentryEventUrl,
|
|
79
79
|
getWebAuthorization
|
|
80
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-XND3J6AT.js";
|
|
81
81
|
import {
|
|
82
|
+
conversationActiveDaysColumn,
|
|
83
|
+
conversationAggregateColumns,
|
|
84
|
+
conversationRangeColumns,
|
|
85
|
+
emptyTaskRunWindows,
|
|
82
86
|
readTaskExecutionByConversationId,
|
|
83
87
|
readTaskExecutionDays,
|
|
84
88
|
readTaskExecutionHours,
|
|
@@ -87,7 +91,7 @@ import {
|
|
|
87
91
|
readTaskExecutionSummaries,
|
|
88
92
|
readTaskExecutions,
|
|
89
93
|
readTaskRuns
|
|
90
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-VOB2DKO6.js";
|
|
91
95
|
import {
|
|
92
96
|
healthReportSchema,
|
|
93
97
|
pluginOperationalReportFeedSchema,
|
|
@@ -110,24 +114,24 @@ import {
|
|
|
110
114
|
readScheduledTask,
|
|
111
115
|
readStats,
|
|
112
116
|
saveScheduledTask
|
|
113
|
-
} from "./chunk-
|
|
117
|
+
} from "./chunk-WMJS5DDV.js";
|
|
114
118
|
import {
|
|
115
119
|
parseSlackThreadId
|
|
116
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-IOGDKPVU.js";
|
|
117
121
|
import {
|
|
118
122
|
cancelHumanFacingPendingMessages,
|
|
119
123
|
getConversation
|
|
120
|
-
} from "./chunk-
|
|
124
|
+
} from "./chunk-E53C73ML.js";
|
|
121
125
|
import "./chunk-DA2KGZZI.js";
|
|
122
126
|
import {
|
|
123
127
|
agentTurnUsageSchema,
|
|
124
128
|
fallbackShortTitle,
|
|
125
129
|
hasAgentTurnUsage,
|
|
126
130
|
renderJuniorNativeConversationEvent
|
|
127
|
-
} from "./chunk-
|
|
131
|
+
} from "./chunk-RFE7DCZK.js";
|
|
128
132
|
import {
|
|
129
133
|
getCachedSnapshot
|
|
130
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-ELCYG6UU.js";
|
|
131
135
|
import "./chunk-PDO5BLNM.js";
|
|
132
136
|
import {
|
|
133
137
|
getVercelConversationWorkQueue
|
|
@@ -153,7 +157,7 @@ import {
|
|
|
153
157
|
updateWorkspace,
|
|
154
158
|
withSlackRetries,
|
|
155
159
|
workspaceRepoCheckoutPath
|
|
156
|
-
} from "./chunk-
|
|
160
|
+
} from "./chunk-CCTYK5RH.js";
|
|
157
161
|
import "./chunk-3Y47VMHV.js";
|
|
158
162
|
import {
|
|
159
163
|
getConversationStore,
|
|
@@ -162,7 +166,7 @@ import {
|
|
|
162
166
|
locationFromRow,
|
|
163
167
|
parseSessionSource,
|
|
164
168
|
resolveRootConversationId
|
|
165
|
-
} from "./chunk-
|
|
169
|
+
} from "./chunk-ADEACKAH.js";
|
|
166
170
|
import {
|
|
167
171
|
conversationReadColumns,
|
|
168
172
|
juniorApiTokens,
|
|
@@ -174,23 +178,23 @@ import {
|
|
|
174
178
|
juniorIdentities,
|
|
175
179
|
juniorSchedulerTasks,
|
|
176
180
|
juniorUsers
|
|
177
|
-
} from "./chunk-
|
|
181
|
+
} from "./chunk-XLWZRHX5.js";
|
|
178
182
|
import {
|
|
179
183
|
create,
|
|
180
184
|
hash
|
|
181
|
-
} from "./chunk-
|
|
182
|
-
import "./chunk-
|
|
185
|
+
} from "./chunk-7ANA7PBB.js";
|
|
186
|
+
import "./chunk-V4HXV5MY.js";
|
|
183
187
|
import {
|
|
184
188
|
decodeStoredConversationEvent
|
|
185
189
|
} from "./chunk-GFBR4S3Q.js";
|
|
186
190
|
import {
|
|
187
191
|
juniorDestinations
|
|
188
192
|
} from "./chunk-VFUK3X5B.js";
|
|
189
|
-
import "./chunk-
|
|
193
|
+
import "./chunk-U76RWMFR.js";
|
|
190
194
|
import "./chunk-D4YV5TDV.js";
|
|
191
|
-
import "./chunk-
|
|
192
|
-
import "./chunk-
|
|
193
|
-
import "./chunk-
|
|
195
|
+
import "./chunk-JOI3DHML.js";
|
|
196
|
+
import "./chunk-WWXJUURQ.js";
|
|
197
|
+
import "./chunk-S7GX44BU.js";
|
|
194
198
|
import "./chunk-CEMMLV5L.js";
|
|
195
199
|
import {
|
|
196
200
|
parseSlackChannelId,
|
|
@@ -202,9 +206,9 @@ import "./chunk-TXKUKMVO.js";
|
|
|
202
206
|
import {
|
|
203
207
|
logException,
|
|
204
208
|
logWarn
|
|
205
|
-
} from "./chunk-
|
|
209
|
+
} from "./chunk-X76JVHQ4.js";
|
|
206
210
|
import "./chunk-PEQXYSSE.js";
|
|
207
|
-
import "./chunk-
|
|
211
|
+
import "./chunk-IME5OW4Y.js";
|
|
208
212
|
|
|
209
213
|
// src/api.ts
|
|
210
214
|
import { Hono as Hono9 } from "hono";
|
|
@@ -450,7 +454,7 @@ async function appendConversationMessageForViewer(viewer, conversationId, body)
|
|
|
450
454
|
}
|
|
451
455
|
}
|
|
452
456
|
|
|
453
|
-
// src/chat/slack/
|
|
457
|
+
// src/chat/slack/location-url.ts
|
|
454
458
|
function parseSlackTeamDomain(value) {
|
|
455
459
|
if (typeof value !== "string") return void 0;
|
|
456
460
|
const domain = value.trim().toLowerCase();
|
|
@@ -463,7 +467,7 @@ function archivePathFromThreadTs(threadTs) {
|
|
|
463
467
|
const [seconds, fraction = ""] = threadTs.split(".");
|
|
464
468
|
return `p${seconds}${(fraction ?? "").padEnd(6, "0").slice(0, 6)}`;
|
|
465
469
|
}
|
|
466
|
-
function
|
|
470
|
+
function buildSlackLocationUrl(args) {
|
|
467
471
|
const channelId = parseSlackChannelId(args.channelId);
|
|
468
472
|
const teamDomain = parseSlackTeamDomain(args.teamDomain);
|
|
469
473
|
const threadTs = parseSlackMessageTs(args.threadTs);
|
|
@@ -1305,18 +1309,16 @@ function surfaceFromSource(source, conversationId) {
|
|
|
1305
1309
|
}
|
|
1306
1310
|
return surfaceFromConversationId(conversationId);
|
|
1307
1311
|
}
|
|
1308
|
-
function
|
|
1312
|
+
function locationUrlFromConversation(args) {
|
|
1309
1313
|
const { conversation } = args;
|
|
1310
|
-
if (!args.canViewPrivateContent || conversation.
|
|
1314
|
+
if (!args.canViewPrivateContent || conversation.location?.provider !== "slack") {
|
|
1311
1315
|
return void 0;
|
|
1312
1316
|
}
|
|
1313
|
-
const teamDomain = args.teamDomainByTeamId?.get(
|
|
1314
|
-
|
|
1315
|
-
);
|
|
1316
|
-
const threadTs = conversation.sessionSource.threadTs;
|
|
1317
|
+
const teamDomain = args.teamDomainByTeamId?.get(conversation.location.teamId);
|
|
1318
|
+
const threadTs = conversation.location.threadTs;
|
|
1317
1319
|
if (!teamDomain || !threadTs) return void 0;
|
|
1318
|
-
return
|
|
1319
|
-
channelId: conversation.
|
|
1320
|
+
return buildSlackLocationUrl({
|
|
1321
|
+
channelId: conversation.location.channelId,
|
|
1320
1322
|
teamDomain,
|
|
1321
1323
|
threadTs
|
|
1322
1324
|
});
|
|
@@ -1397,7 +1399,7 @@ function conversationSummaryFromStoredConversation(args) {
|
|
|
1397
1399
|
conversation.conversationId
|
|
1398
1400
|
);
|
|
1399
1401
|
const actorIdentity = actorIdentityReport(conversation.actor);
|
|
1400
|
-
const
|
|
1402
|
+
const locationUrl = locationUrlFromConversation({
|
|
1401
1403
|
canViewPrivateContent,
|
|
1402
1404
|
conversation,
|
|
1403
1405
|
...args.teamDomainByTeamId ? { teamDomainByTeamId: args.teamDomainByTeamId } : void 0
|
|
@@ -1433,7 +1435,7 @@ function conversationSummaryFromStoredConversation(args) {
|
|
|
1433
1435
|
...args.auxiliaryCosts ? { auxiliaryCosts: args.auxiliaryCosts } : void 0,
|
|
1434
1436
|
...usage3 ? { cumulativeUsage: usage3 } : void 0,
|
|
1435
1437
|
...actorIdentity ? { actorIdentity } : void 0,
|
|
1436
|
-
...
|
|
1438
|
+
...locationUrl ? { locationUrl } : void 0,
|
|
1437
1439
|
archivedAt: args.archivedAtMs === void 0 ? null : new Date(args.archivedAtMs).toISOString(),
|
|
1438
1440
|
...slackThread ? { channel: slackThread.channelId } : void 0,
|
|
1439
1441
|
...channelName ? { channelName } : void 0,
|
|
@@ -1838,7 +1840,7 @@ function conversationFeedMembershipFilter(status, filter) {
|
|
|
1838
1840
|
async function conversationRows(db, limit, status, filter) {
|
|
1839
1841
|
return db.select({
|
|
1840
1842
|
conversation: conversationReadColumns(),
|
|
1841
|
-
|
|
1843
|
+
location: juniorDestinations,
|
|
1842
1844
|
identityDisplayName: juniorIdentities.displayName,
|
|
1843
1845
|
identityEmail: juniorIdentities.email,
|
|
1844
1846
|
identityHandle: juniorIdentities.handle,
|
|
@@ -1864,9 +1866,9 @@ async function conversationRows(db, limit, status, filter) {
|
|
|
1864
1866
|
}
|
|
1865
1867
|
function conversationFromRow(row) {
|
|
1866
1868
|
const value = row.conversation;
|
|
1867
|
-
const
|
|
1868
|
-
if (value.sessionSource !== null && !
|
|
1869
|
-
throw new Error("Conversation
|
|
1869
|
+
const legacySessionSource = value.sessionSource === null ? void 0 : parseSessionSource(value.sessionSource);
|
|
1870
|
+
if (value.sessionSource !== null && !legacySessionSource) {
|
|
1871
|
+
throw new Error("Conversation legacy source_json is invalid");
|
|
1870
1872
|
}
|
|
1871
1873
|
const actorFullName = row.userDisplayName?.trim() ? row.userDisplayName : row.identityDisplayName;
|
|
1872
1874
|
const actor = row.identityProvider === "slack" ? {
|
|
@@ -1879,8 +1881,8 @@ function conversationFromRow(row) {
|
|
|
1879
1881
|
} : void 0;
|
|
1880
1882
|
const location = locationFromRow(
|
|
1881
1883
|
value.location,
|
|
1882
|
-
row.
|
|
1883
|
-
|
|
1884
|
+
row.location,
|
|
1885
|
+
legacySessionSource
|
|
1884
1886
|
);
|
|
1885
1887
|
return {
|
|
1886
1888
|
schemaVersion: 1,
|
|
@@ -1897,7 +1899,6 @@ function conversationFromRow(row) {
|
|
|
1897
1899
|
...location ? { location } : void 0,
|
|
1898
1900
|
...value.channelName ? { channelName: value.channelName } : void 0,
|
|
1899
1901
|
...value.source ? { source: value.source } : void 0,
|
|
1900
|
-
...sessionSource ? { sessionSource } : void 0,
|
|
1901
1902
|
...value.title ? { title: value.title } : void 0,
|
|
1902
1903
|
...value.transcriptPurgedAt ? { transcriptPurgedAtMs: value.transcriptPurgedAt.getTime() } : void 0
|
|
1903
1904
|
};
|
|
@@ -1906,7 +1907,7 @@ async function readConversationRecordFromSql(conversationId) {
|
|
|
1906
1907
|
const db = getDb();
|
|
1907
1908
|
const rows = await db.select({
|
|
1908
1909
|
conversation: conversationReadColumns(),
|
|
1909
|
-
|
|
1910
|
+
location: juniorDestinations,
|
|
1910
1911
|
identityDisplayName: juniorIdentities.displayName,
|
|
1911
1912
|
identityEmail: juniorIdentities.email,
|
|
1912
1913
|
identityHandle: juniorIdentities.handle,
|
|
@@ -1925,7 +1926,7 @@ async function readConversationRecordFromSql(conversationId) {
|
|
|
1925
1926
|
return row ? {
|
|
1926
1927
|
conversation: conversationFromRow(row),
|
|
1927
1928
|
durationMs: row.conversation.durationMs,
|
|
1928
|
-
...row.
|
|
1929
|
+
...row.location?.visibility === "public" ? { locationId: row.location.id } : void 0,
|
|
1929
1930
|
usage: row.conversation.usage,
|
|
1930
1931
|
rootConversationId: row.conversation.rootConversationId
|
|
1931
1932
|
} : void 0;
|
|
@@ -1982,7 +1983,7 @@ async function readConversationFeedFromSql(options = {}) {
|
|
|
1982
1983
|
readRootConversationMetricsFromSql(db, conversationIds),
|
|
1983
1984
|
resolveSlackTeamDomains(
|
|
1984
1985
|
conversations.flatMap(
|
|
1985
|
-
(conversation) => conversation.
|
|
1986
|
+
(conversation) => conversation.location?.provider === "slack" ? [conversation.location.teamId] : []
|
|
1986
1987
|
)
|
|
1987
1988
|
),
|
|
1988
1989
|
listConversationWork(conversationIds),
|
|
@@ -2015,7 +2016,7 @@ async function readConversationFeedFromSql(options = {}) {
|
|
|
2015
2016
|
auxiliaryCosts: auxiliaryCostsByRoot.get(conversation.conversationId),
|
|
2016
2017
|
durationMs: metrics?.durationMs ?? row.conversation.durationMs,
|
|
2017
2018
|
teamDomainByTeamId,
|
|
2018
|
-
...row.
|
|
2019
|
+
...row.location?.visibility === "public" ? { locationId: row.location.id } : void 0,
|
|
2019
2020
|
usage: metrics?.usage ?? row.conversation.usage ?? void 0
|
|
2020
2021
|
});
|
|
2021
2022
|
const work = {
|
|
@@ -2274,7 +2275,7 @@ function executionSummaryFields(stats) {
|
|
|
2274
2275
|
return {
|
|
2275
2276
|
...stats?.lastConversationId ? { lastConversationId: stats.lastConversationId } : void 0,
|
|
2276
2277
|
...stats?.lastExecutedAtMs ? { lastRunAt: new Date(stats.lastExecutedAtMs).toISOString() } : void 0,
|
|
2277
|
-
|
|
2278
|
+
runs: stats?.runs ?? emptyTaskRunWindows(),
|
|
2278
2279
|
totalRuns: stats?.totalRuns ?? 0
|
|
2279
2280
|
};
|
|
2280
2281
|
}
|
|
@@ -2687,7 +2688,7 @@ async function readConversationDetailFromSql(conversationId, options) {
|
|
|
2687
2688
|
...options.viewer ? { viewer: options.viewer } : void 0
|
|
2688
2689
|
}),
|
|
2689
2690
|
resolveSlackTeamDomains(
|
|
2690
|
-
record.conversation.
|
|
2691
|
+
record.conversation.location?.provider === "slack" ? [record.conversation.location.teamId] : []
|
|
2691
2692
|
)
|
|
2692
2693
|
]);
|
|
2693
2694
|
const access = accessByConversation.get(conversationId);
|
|
@@ -2934,90 +2935,8 @@ async function requireConversationPendingMessages(conversationId, options = {})
|
|
|
2934
2935
|
}
|
|
2935
2936
|
|
|
2936
2937
|
// src/api/conversations/stats.query.ts
|
|
2937
|
-
import { and as and10, eq as eq10, gte, isNull as isNull4, lte, sql as
|
|
2938
|
+
import { and as and10, eq as eq10, gte, isNull as isNull4, lte, sql as sql9 } from "drizzle-orm";
|
|
2938
2939
|
import { alias as alias3 } from "drizzle-orm/pg-core";
|
|
2939
|
-
|
|
2940
|
-
// src/api/conversations/aggregate.ts
|
|
2941
|
-
import { sql as sql9 } from "drizzle-orm";
|
|
2942
|
-
function usageTokenValue(source, field) {
|
|
2943
|
-
return sql9`CASE
|
|
2944
|
-
WHEN ${source.usage}->>${field} IS NOT NULL
|
|
2945
|
-
THEN (${source.usage}->>${field})::double precision
|
|
2946
|
-
ELSE NULL
|
|
2947
|
-
END`;
|
|
2948
|
-
}
|
|
2949
|
-
function tokenValue(source) {
|
|
2950
|
-
return sql9`
|
|
2951
|
-
CASE
|
|
2952
|
-
WHEN COALESCE(
|
|
2953
|
-
${source.usage}->>'inputTokens',
|
|
2954
|
-
${source.usage}->>'outputTokens',
|
|
2955
|
-
${source.usage}->>'cachedInputTokens',
|
|
2956
|
-
${source.usage}->>'cacheCreationTokens'
|
|
2957
|
-
) IS NOT NULL
|
|
2958
|
-
THEN COALESCE((${source.usage}->>'inputTokens')::double precision, 0)
|
|
2959
|
-
+ COALESCE((${source.usage}->>'outputTokens')::double precision, 0)
|
|
2960
|
-
+ COALESCE((${source.usage}->>'cachedInputTokens')::double precision, 0)
|
|
2961
|
-
+ COALESCE((${source.usage}->>'cacheCreationTokens')::double precision, 0)
|
|
2962
|
-
WHEN ${source.usage}->>'totalTokens' IS NOT NULL
|
|
2963
|
-
THEN (${source.usage}->>'totalTokens')::double precision
|
|
2964
|
-
ELSE NULL
|
|
2965
|
-
END
|
|
2966
|
-
`;
|
|
2967
|
-
}
|
|
2968
|
-
function costValue(source) {
|
|
2969
|
-
return sql9`
|
|
2970
|
-
CASE
|
|
2971
|
-
WHEN ${source.usage}->'cost'->>'total' IS NOT NULL
|
|
2972
|
-
THEN (${source.usage}->'cost'->>'total')::double precision
|
|
2973
|
-
WHEN COALESCE(
|
|
2974
|
-
${source.usage}->'cost'->>'input',
|
|
2975
|
-
${source.usage}->'cost'->>'output',
|
|
2976
|
-
${source.usage}->'cost'->>'cacheRead',
|
|
2977
|
-
${source.usage}->'cost'->>'cacheWrite'
|
|
2978
|
-
) IS NOT NULL
|
|
2979
|
-
THEN COALESCE((${source.usage}->'cost'->>'input')::double precision, 0)
|
|
2980
|
-
+ COALESCE((${source.usage}->'cost'->>'output')::double precision, 0)
|
|
2981
|
-
+ COALESCE((${source.usage}->'cost'->>'cacheRead')::double precision, 0)
|
|
2982
|
-
+ COALESCE((${source.usage}->'cost'->>'cacheWrite')::double precision, 0)
|
|
2983
|
-
ELSE NULL
|
|
2984
|
-
END
|
|
2985
|
-
`;
|
|
2986
|
-
}
|
|
2987
|
-
function conversationAggregateColumns(sources) {
|
|
2988
|
-
const metrics = sources?.metrics ?? juniorConversations;
|
|
2989
|
-
const roots = sources?.roots ?? juniorConversations;
|
|
2990
|
-
const conversationCount = sources ? sql9`COUNT(DISTINCT ${roots.conversationId})` : sql9`COUNT(*)`;
|
|
2991
|
-
return {
|
|
2992
|
-
active: sql9`${conversationCount} FILTER (
|
|
2993
|
-
WHERE ${roots.executionStatus} NOT IN ('idle', 'failed')
|
|
2994
|
-
)::integer`,
|
|
2995
|
-
conversations: sql9`${conversationCount}::integer`,
|
|
2996
|
-
cachedInputTokens: sql9`SUM(${usageTokenValue(metrics, "cachedInputTokens")})::double precision`,
|
|
2997
|
-
costUsd: sql9`SUM(${costValue(metrics)})::double precision`,
|
|
2998
|
-
durationMs: sql9`COALESCE(SUM(${metrics.durationMs}), 0)::double precision`,
|
|
2999
|
-
failed: sql9`${conversationCount} FILTER (
|
|
3000
|
-
WHERE ${roots.executionStatus} = 'failed'
|
|
3001
|
-
)::integer`,
|
|
3002
|
-
inputTokens: sql9`SUM(${usageTokenValue(metrics, "inputTokens")})::double precision`,
|
|
3003
|
-
tokens: sql9`SUM(${tokenValue(metrics)})::double precision`
|
|
3004
|
-
};
|
|
3005
|
-
}
|
|
3006
|
-
function conversationRangeColumns() {
|
|
3007
|
-
return {
|
|
3008
|
-
firstSeenAt: sql9`MIN(${juniorConversations.createdAt})`.mapWith(
|
|
3009
|
-
juniorConversations.createdAt
|
|
3010
|
-
),
|
|
3011
|
-
lastSeenAt: sql9`MAX(${juniorConversations.lastActivityAt})`.mapWith(
|
|
3012
|
-
juniorConversations.lastActivityAt
|
|
3013
|
-
)
|
|
3014
|
-
};
|
|
3015
|
-
}
|
|
3016
|
-
function conversationActiveDaysColumn() {
|
|
3017
|
-
return sql9`COUNT(DISTINCT (${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC')::date)::integer`;
|
|
3018
|
-
}
|
|
3019
|
-
|
|
3020
|
-
// src/api/conversations/stats.query.ts
|
|
3021
2940
|
var WINDOW_DAYS = 90;
|
|
3022
2941
|
var treeConversation = alias3(juniorConversations, "stats_tree_conversation");
|
|
3023
2942
|
var treeAggregateColumns = conversationAggregateColumns({
|
|
@@ -3190,11 +3109,11 @@ function guardianStats(dayRows, hourRows, endMs) {
|
|
|
3190
3109
|
}
|
|
3191
3110
|
async function aggregateStats(db, start, end) {
|
|
3192
3111
|
const where = statsWhere(start, end);
|
|
3193
|
-
const activityDate =
|
|
3112
|
+
const activityDate = sql9`TO_CHAR(
|
|
3194
3113
|
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
3195
3114
|
'YYYY-MM-DD'
|
|
3196
3115
|
)`;
|
|
3197
|
-
const activityHour =
|
|
3116
|
+
const activityHour = sql9`TO_CHAR(
|
|
3198
3117
|
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
3199
3118
|
'YYYY-MM-DD"T"HH24'
|
|
3200
3119
|
)`;
|
|
@@ -3302,26 +3221,26 @@ async function aggregateStats(db, start, end) {
|
|
|
3302
3221
|
};
|
|
3303
3222
|
}
|
|
3304
3223
|
async function aggregateGuardianStats(db, start, end) {
|
|
3305
|
-
const day =
|
|
3224
|
+
const day = sql9`TO_CHAR(
|
|
3306
3225
|
${juniorConversationEvents.createdAt} AT TIME ZONE 'UTC',
|
|
3307
3226
|
'YYYY-MM-DD'
|
|
3308
3227
|
)`;
|
|
3309
|
-
const hour =
|
|
3228
|
+
const hour = sql9`TO_CHAR(
|
|
3310
3229
|
${juniorConversationEvents.createdAt} AT TIME ZONE 'UTC',
|
|
3311
3230
|
'YYYY-MM-DD"T"HH24'
|
|
3312
3231
|
)`;
|
|
3313
|
-
const decision =
|
|
3314
|
-
const cost2 =
|
|
3232
|
+
const decision = sql9`${juniorConversationEvents.payload}->>'decision'`;
|
|
3233
|
+
const cost2 = sql9`CASE
|
|
3315
3234
|
WHEN jsonb_typeof(${juniorConversationEvents.payload}->'costUsd') = 'number'
|
|
3316
3235
|
THEN (${juniorConversationEvents.payload}->>'costUsd')::double precision
|
|
3317
3236
|
ELSE NULL
|
|
3318
3237
|
END`;
|
|
3319
3238
|
const selectColumns = {
|
|
3320
|
-
allow:
|
|
3321
|
-
ask:
|
|
3322
|
-
costUsd:
|
|
3323
|
-
deny:
|
|
3324
|
-
requests:
|
|
3239
|
+
allow: sql9`COUNT(*) FILTER (WHERE ${decision} = 'allow')::integer`,
|
|
3240
|
+
ask: sql9`COUNT(*) FILTER (WHERE ${decision} = 'ask')::integer`,
|
|
3241
|
+
costUsd: sql9`SUM(${cost2})::double precision`,
|
|
3242
|
+
deny: sql9`COUNT(*) FILTER (WHERE ${decision} = 'deny')::integer`,
|
|
3243
|
+
requests: sql9`COUNT(*)::integer`
|
|
3325
3244
|
};
|
|
3326
3245
|
const where = and10(
|
|
3327
3246
|
eq10(juniorConversationEvents.type, "guardian_action_reviewed"),
|
|
@@ -3596,7 +3515,7 @@ function createConversationRoutes(options) {
|
|
|
3596
3515
|
import { Hono as Hono2 } from "hono";
|
|
3597
3516
|
|
|
3598
3517
|
// src/api/code/overview.ts
|
|
3599
|
-
import { desc as desc4, eq as eq11, gte as gte2, or as or5, sql as
|
|
3518
|
+
import { desc as desc4, eq as eq11, gte as gte2, or as or5, sql as sql10 } from "drizzle-orm";
|
|
3600
3519
|
import { z as z5 } from "zod";
|
|
3601
3520
|
var DAY_MS2 = 24 * 60 * 60 * 1e3;
|
|
3602
3521
|
var WINDOW_DAYS2 = 30;
|
|
@@ -3651,7 +3570,7 @@ function mergeRate(merged, closed) {
|
|
|
3651
3570
|
return completed > 0 ? merged / completed : void 0;
|
|
3652
3571
|
}
|
|
3653
3572
|
function conversationTreeCostExpr() {
|
|
3654
|
-
return
|
|
3573
|
+
return sql10`
|
|
3655
3574
|
coalesce((
|
|
3656
3575
|
SELECT sum(
|
|
3657
3576
|
CASE
|
|
@@ -3680,7 +3599,7 @@ function conversationTreeCostExpr() {
|
|
|
3680
3599
|
`;
|
|
3681
3600
|
}
|
|
3682
3601
|
function ownedByUserSql(conversationIds, userId) {
|
|
3683
|
-
return
|
|
3602
|
+
return sql10`EXISTS (
|
|
3684
3603
|
SELECT 1
|
|
3685
3604
|
FROM unnest(${conversationIds}) AS linked(conversation_id)
|
|
3686
3605
|
INNER JOIN junior_conversations AS conversations
|
|
@@ -3692,7 +3611,7 @@ function ownedByUserSql(conversationIds, userId) {
|
|
|
3692
3611
|
}
|
|
3693
3612
|
function ownershipFilter(userId) {
|
|
3694
3613
|
if (!userId) return void 0;
|
|
3695
|
-
return ownedByUserSql(
|
|
3614
|
+
return ownedByUserSql(sql10`${juniorCodeChanges.conversationIds}`, userId);
|
|
3696
3615
|
}
|
|
3697
3616
|
async function readCodeWindows(args) {
|
|
3698
3617
|
const db = getDb();
|
|
@@ -3708,7 +3627,7 @@ async function readCodeWindows(args) {
|
|
|
3708
3627
|
activityHourEnd.getTime() - 23 * (DAY_MS2 / 24)
|
|
3709
3628
|
);
|
|
3710
3629
|
const [summaryResult, activityResult, activityHourResult] = await Promise.all([
|
|
3711
|
-
db.execute(
|
|
3630
|
+
db.execute(sql10`
|
|
3712
3631
|
WITH recent_changes AS (
|
|
3713
3632
|
SELECT
|
|
3714
3633
|
${changes.id},
|
|
@@ -3718,7 +3637,7 @@ async function readCodeWindows(args) {
|
|
|
3718
3637
|
${changes.state},
|
|
3719
3638
|
${changes.conversationIds} AS conversation_ids
|
|
3720
3639
|
FROM ${changes}
|
|
3721
|
-
${ownership ?
|
|
3640
|
+
${ownership ? sql10`WHERE ${ownership}` : sql10``}
|
|
3722
3641
|
), change_costs AS (
|
|
3723
3642
|
SELECT
|
|
3724
3643
|
recent_changes.id,
|
|
@@ -3767,7 +3686,7 @@ async function readCodeWindows(args) {
|
|
|
3767
3686
|
)::double precision AS "medianCostUsd"
|
|
3768
3687
|
FROM recent_changes
|
|
3769
3688
|
`),
|
|
3770
|
-
db.execute(
|
|
3689
|
+
db.execute(sql10`
|
|
3771
3690
|
WITH days AS (
|
|
3772
3691
|
SELECT generate_series(
|
|
3773
3692
|
date_trunc('day', ${activityStart}::timestamptz AT TIME ZONE 'UTC'),
|
|
@@ -3784,18 +3703,18 @@ async function readCodeWindows(args) {
|
|
|
3784
3703
|
SELECT ${changes.openedAt} AS event_at, 'created'::text AS kind
|
|
3785
3704
|
FROM ${changes}
|
|
3786
3705
|
WHERE ${changes.openedAt} >= ${activityStart}
|
|
3787
|
-
${ownership ?
|
|
3706
|
+
${ownership ? sql10`AND ${ownership}` : sql10``}
|
|
3788
3707
|
UNION ALL
|
|
3789
3708
|
SELECT ${changes.mergedAt} AS event_at, 'merged'::text AS kind
|
|
3790
3709
|
FROM ${changes}
|
|
3791
3710
|
WHERE ${changes.mergedAt} >= ${activityStart}
|
|
3792
|
-
${ownership ?
|
|
3711
|
+
${ownership ? sql10`AND ${ownership}` : sql10``}
|
|
3793
3712
|
UNION ALL
|
|
3794
3713
|
SELECT ${changes.closedAt} AS event_at, 'closed'::text AS kind
|
|
3795
3714
|
FROM ${changes}
|
|
3796
3715
|
WHERE ${changes.state} = 'closed'
|
|
3797
3716
|
AND ${changes.closedAt} >= ${activityStart}
|
|
3798
|
-
${ownership ?
|
|
3717
|
+
${ownership ? sql10`AND ${ownership}` : sql10``}
|
|
3799
3718
|
) AS events
|
|
3800
3719
|
GROUP BY date_trunc('day', event_at AT TIME ZONE 'UTC')
|
|
3801
3720
|
)
|
|
@@ -3808,7 +3727,7 @@ async function readCodeWindows(args) {
|
|
|
3808
3727
|
LEFT JOIN daily ON daily.day = days.day
|
|
3809
3728
|
ORDER BY days.day
|
|
3810
3729
|
`),
|
|
3811
|
-
db.execute(
|
|
3730
|
+
db.execute(sql10`
|
|
3812
3731
|
WITH hours AS (
|
|
3813
3732
|
SELECT generate_series(
|
|
3814
3733
|
date_trunc('hour', ${activityHourStart}::timestamptz AT TIME ZONE 'UTC'),
|
|
@@ -3825,18 +3744,18 @@ async function readCodeWindows(args) {
|
|
|
3825
3744
|
SELECT ${changes.openedAt} AS event_at, 'created'::text AS kind
|
|
3826
3745
|
FROM ${changes}
|
|
3827
3746
|
WHERE ${changes.openedAt} >= ${activityHourStart}
|
|
3828
|
-
${ownership ?
|
|
3747
|
+
${ownership ? sql10`AND ${ownership}` : sql10``}
|
|
3829
3748
|
UNION ALL
|
|
3830
3749
|
SELECT ${changes.mergedAt} AS event_at, 'merged'::text AS kind
|
|
3831
3750
|
FROM ${changes}
|
|
3832
3751
|
WHERE ${changes.mergedAt} >= ${activityHourStart}
|
|
3833
|
-
${ownership ?
|
|
3752
|
+
${ownership ? sql10`AND ${ownership}` : sql10``}
|
|
3834
3753
|
UNION ALL
|
|
3835
3754
|
SELECT ${changes.closedAt} AS event_at, 'closed'::text AS kind
|
|
3836
3755
|
FROM ${changes}
|
|
3837
3756
|
WHERE ${changes.state} = 'closed'
|
|
3838
3757
|
AND ${changes.closedAt} >= ${activityHourStart}
|
|
3839
|
-
${ownership ?
|
|
3758
|
+
${ownership ? sql10`AND ${ownership}` : sql10``}
|
|
3840
3759
|
) AS events
|
|
3841
3760
|
GROUP BY date_trunc('hour', event_at AT TIME ZONE 'UTC')
|
|
3842
3761
|
)
|
|
@@ -3879,7 +3798,7 @@ async function readCodeOverview(nowMs = Date.now()) {
|
|
|
3879
3798
|
const windows = await readCodeWindows({ nowMs });
|
|
3880
3799
|
const conversationTreeCost = conversationTreeCostExpr();
|
|
3881
3800
|
const [repositoryResult, recentChanges] = await Promise.all([
|
|
3882
|
-
db.execute(
|
|
3801
|
+
db.execute(sql10`
|
|
3883
3802
|
WITH recent_changes AS (
|
|
3884
3803
|
SELECT
|
|
3885
3804
|
${changes.id},
|
|
@@ -4010,7 +3929,7 @@ function createCodeRoutes() {
|
|
|
4010
3929
|
import { Hono as Hono3 } from "hono";
|
|
4011
3930
|
|
|
4012
3931
|
// src/api/locations/query.ts
|
|
4013
|
-
import { and as and11, asc as asc3, desc as desc5, eq as eq12, gte as gte3, isNull as isNull5, sql as
|
|
3932
|
+
import { and as and11, asc as asc3, desc as desc5, eq as eq12, gte as gte3, isNull as isNull5, sql as sql11 } from "drizzle-orm";
|
|
4014
3933
|
import { alias as alias4 } from "drizzle-orm/pg-core";
|
|
4015
3934
|
|
|
4016
3935
|
// src/api/conversations/reporting.ts
|
|
@@ -4182,16 +4101,16 @@ async function directoryRows(db) {
|
|
|
4182
4101
|
).where(topLevelWhere()).groupBy(...locationGroupBy());
|
|
4183
4102
|
}
|
|
4184
4103
|
async function directoryActivityRows(db, start, hourStart) {
|
|
4185
|
-
const day =
|
|
4104
|
+
const day = sql11`TO_CHAR(
|
|
4186
4105
|
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
4187
4106
|
'YYYY-MM-DD'
|
|
4188
4107
|
)`;
|
|
4189
|
-
const hour =
|
|
4108
|
+
const hour = sql11`TO_CHAR(
|
|
4190
4109
|
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
4191
4110
|
'YYYY-MM-DD"T"HH24'
|
|
4192
4111
|
)`;
|
|
4193
4112
|
const select = {
|
|
4194
|
-
conversations:
|
|
4113
|
+
conversations: sql11`COUNT(*)::integer`,
|
|
4195
4114
|
visibility: juniorDestinations.visibility
|
|
4196
4115
|
};
|
|
4197
4116
|
const [dayRows, hourRows] = await Promise.all([
|
|
@@ -4286,7 +4205,7 @@ async function recentLocationRows(db, locationId) {
|
|
|
4286
4205
|
createdAt: juniorConversations.createdAt,
|
|
4287
4206
|
destinationId: juniorDestinations.id,
|
|
4288
4207
|
durationMs: juniorConversations.durationMs,
|
|
4289
|
-
email:
|
|
4208
|
+
email: sql11`COALESCE(
|
|
4290
4209
|
${juniorUsers.primaryEmailNormalized},
|
|
4291
4210
|
${juniorIdentities.email}
|
|
4292
4211
|
)`,
|
|
@@ -4295,7 +4214,7 @@ async function recentLocationRows(db, locationId) {
|
|
|
4295
4214
|
fullName: juniorUsers.displayName,
|
|
4296
4215
|
handle: juniorIdentities.handle,
|
|
4297
4216
|
lastActivityAt: juniorConversations.lastActivityAt,
|
|
4298
|
-
providerSubjectId:
|
|
4217
|
+
providerSubjectId: sql11`CASE
|
|
4299
4218
|
WHEN ${juniorIdentities.provider} = 'slack'
|
|
4300
4219
|
THEN ${juniorIdentities.providerSubjectId}
|
|
4301
4220
|
ELSE NULL
|
|
@@ -4320,11 +4239,11 @@ async function readLocationDetailFromSql(locationId, options = {}) {
|
|
|
4320
4239
|
const { end, start } = trailingUtcDayWindow(nowMs, ACTIVITY_DAYS2);
|
|
4321
4240
|
const hourWindow = trailingUtcHourWindow(nowMs);
|
|
4322
4241
|
const where = publicLocationWhere(locationId);
|
|
4323
|
-
const activityDate =
|
|
4242
|
+
const activityDate = sql11`TO_CHAR(
|
|
4324
4243
|
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
4325
4244
|
'YYYY-MM-DD'
|
|
4326
4245
|
)`;
|
|
4327
|
-
const activityHour =
|
|
4246
|
+
const activityHour = sql11`TO_CHAR(
|
|
4328
4247
|
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
4329
4248
|
'YYYY-MM-DD"T"HH24'
|
|
4330
4249
|
)`;
|
|
@@ -4539,10 +4458,10 @@ async function readPeopleCode(email) {
|
|
|
4539
4458
|
}
|
|
4540
4459
|
|
|
4541
4460
|
// src/api/people/list.query.ts
|
|
4542
|
-
import { and as and13, eq as eq14, gte as gte4, sql as
|
|
4461
|
+
import { and as and13, eq as eq14, gte as gte4, sql as sql13 } from "drizzle-orm";
|
|
4543
4462
|
|
|
4544
4463
|
// src/api/people/shared.ts
|
|
4545
|
-
import { and as and12, asc as asc4, desc as desc6, eq as eq13, isNull as isNull6, notExists, or as or6, sql as
|
|
4464
|
+
import { and as and12, asc as asc4, desc as desc6, eq as eq13, isNull as isNull6, notExists, or as or6, sql as sql12 } from "drizzle-orm";
|
|
4546
4465
|
import { alias as alias5 } from "drizzle-orm/pg-core";
|
|
4547
4466
|
var RECENT_LIMIT2 = 25;
|
|
4548
4467
|
var ACTIVITY_DAYS3 = 365;
|
|
@@ -4648,7 +4567,7 @@ function verifiedActorWhere(email) {
|
|
|
4648
4567
|
return and12(
|
|
4649
4568
|
eq13(juniorIdentities.provider, "slack"),
|
|
4650
4569
|
eq13(juniorIdentities.emailVerified, true),
|
|
4651
|
-
|
|
4570
|
+
sql12`${juniorUsers.primaryEmailNormalized} IS NOT NULL`,
|
|
4652
4571
|
normalizedEmail ? eq13(juniorUsers.primaryEmailNormalized, normalizedEmail) : void 0
|
|
4653
4572
|
);
|
|
4654
4573
|
}
|
|
@@ -4782,11 +4701,11 @@ function buildActorWindows(args) {
|
|
|
4782
4701
|
async function readPeopleListFromSql() {
|
|
4783
4702
|
const nowMs = Date.now();
|
|
4784
4703
|
const { end, start } = trailingUtcDayWindow(nowMs, DIRECTORY_ACTIVITY_DAYS);
|
|
4785
|
-
const activityDate =
|
|
4704
|
+
const activityDate = sql13`TO_CHAR(
|
|
4786
4705
|
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
4787
4706
|
'YYYY-MM-DD'
|
|
4788
4707
|
)`;
|
|
4789
|
-
const activityHour =
|
|
4708
|
+
const activityHour = sql13`TO_CHAR(
|
|
4790
4709
|
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
4791
4710
|
'YYYY-MM-DD"T"HH24'
|
|
4792
4711
|
)`;
|
|
@@ -4807,8 +4726,8 @@ async function readPeopleListFromSql() {
|
|
|
4807
4726
|
getDb().select({
|
|
4808
4727
|
email: juniorUsers.primaryEmailNormalized,
|
|
4809
4728
|
fullName: juniorUsers.displayName,
|
|
4810
|
-
slackUserId:
|
|
4811
|
-
slackUserName:
|
|
4729
|
+
slackUserId: sql13`MAX(${juniorIdentities.providerSubjectId})`,
|
|
4730
|
+
slackUserName: sql13`MAX(${juniorIdentities.handle})`,
|
|
4812
4731
|
activeDays: conversationActiveDaysColumn(),
|
|
4813
4732
|
...peopleTreeAggregateColumns,
|
|
4814
4733
|
...conversationRangeColumns()
|
|
@@ -4817,8 +4736,8 @@ async function readPeopleListFromSql() {
|
|
|
4817
4736
|
eq14(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
4818
4737
|
).innerJoin(juniorUsers, eq14(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(verifiedActorWhere()).groupBy(juniorUsers.primaryEmailNormalized, juniorUsers.displayName),
|
|
4819
4738
|
getDb().select({
|
|
4820
|
-
activePeople:
|
|
4821
|
-
conversations:
|
|
4739
|
+
activePeople: sql13`COUNT(DISTINCT ${juniorUsers.id})::int`,
|
|
4740
|
+
conversations: sql13`COUNT(*)::int`,
|
|
4822
4741
|
date: activityDate
|
|
4823
4742
|
}).from(juniorConversations).innerJoin(
|
|
4824
4743
|
juniorIdentities,
|
|
@@ -4830,8 +4749,8 @@ async function readPeopleListFromSql() {
|
|
|
4830
4749
|
)
|
|
4831
4750
|
).groupBy(activityDate),
|
|
4832
4751
|
getDb().select({
|
|
4833
|
-
activePeople:
|
|
4834
|
-
conversations:
|
|
4752
|
+
activePeople: sql13`COUNT(DISTINCT ${juniorUsers.id})::int`,
|
|
4753
|
+
conversations: sql13`COUNT(*)::int`,
|
|
4835
4754
|
date: activityHour
|
|
4836
4755
|
}).from(juniorConversations).innerJoin(
|
|
4837
4756
|
juniorIdentities,
|
|
@@ -4952,7 +4871,7 @@ async function readPeoplePluginReports(args) {
|
|
|
4952
4871
|
source: "plugins"
|
|
4953
4872
|
});
|
|
4954
4873
|
}
|
|
4955
|
-
const { getPluginProfileReports } = await import("./agent-hooks-
|
|
4874
|
+
const { getPluginProfileReports } = await import("./agent-hooks-IDX764FD.js");
|
|
4956
4875
|
return pluginOperationalReportFeedSchema.parse({
|
|
4957
4876
|
generatedAt: new Date(nowMs).toISOString(),
|
|
4958
4877
|
reports: await getPluginProfileReports({
|
|
@@ -4965,7 +4884,7 @@ async function readPeoplePluginReports(args) {
|
|
|
4965
4884
|
}
|
|
4966
4885
|
|
|
4967
4886
|
// src/api/people/profile.query.ts
|
|
4968
|
-
import { and as and14, eq as eq15, gte as gte5, sql as
|
|
4887
|
+
import { and as and14, eq as eq15, gte as gte5, sql as sql14 } from "drizzle-orm";
|
|
4969
4888
|
function emptyProfile(email, nowMs) {
|
|
4970
4889
|
const end = new Date(nowMs);
|
|
4971
4890
|
end.setUTCHours(0, 0, 0, 0);
|
|
@@ -5001,7 +4920,7 @@ function addAggregate2(map, label, row) {
|
|
|
5001
4920
|
map.set(label, item);
|
|
5002
4921
|
}
|
|
5003
4922
|
function surfaceExpression() {
|
|
5004
|
-
return
|
|
4923
|
+
return sql14`CASE
|
|
5005
4924
|
WHEN ${juniorConversations.source} IN ('api', 'scheduler', 'slack')
|
|
5006
4925
|
THEN ${juniorConversations.source}
|
|
5007
4926
|
WHEN ${juniorConversations.conversationId} LIKE 'slack:%' THEN 'slack'
|
|
@@ -5030,22 +4949,22 @@ async function readPeopleProfileFromSql(email, options = {}) {
|
|
|
5030
4949
|
const where = verifiedActorWhere(normalizedEmail);
|
|
5031
4950
|
const metricsJoin = peopleTreeMetricsJoin();
|
|
5032
4951
|
const surface = surfaceExpression();
|
|
5033
|
-
const activityDate =
|
|
4952
|
+
const activityDate = sql14`TO_CHAR(
|
|
5034
4953
|
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
5035
4954
|
'YYYY-MM-DD'
|
|
5036
4955
|
)`;
|
|
5037
|
-
const activityHour =
|
|
4956
|
+
const activityHour = sql14`TO_CHAR(
|
|
5038
4957
|
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
5039
4958
|
'YYYY-MM-DD"T"HH24'
|
|
5040
4959
|
)`;
|
|
5041
|
-
const channel =
|
|
4960
|
+
const channel = sql14`SPLIT_PART(${juniorConversations.conversationId}, ':', 2)`;
|
|
5042
4961
|
const hourWindow = trailingUtcHourWindow(nowMs);
|
|
5043
4962
|
const [totalsRows, dayRows, hourRows, locationRows, surfaceRows, recentRows] = await Promise.all([
|
|
5044
4963
|
getDb().select({
|
|
5045
4964
|
email: juniorUsers.primaryEmailNormalized,
|
|
5046
4965
|
fullName: juniorUsers.displayName,
|
|
5047
|
-
slackUserId:
|
|
5048
|
-
slackUserName:
|
|
4966
|
+
slackUserId: sql14`MAX(${juniorIdentities.providerSubjectId})`,
|
|
4967
|
+
slackUserName: sql14`MAX(${juniorIdentities.handle})`,
|
|
5049
4968
|
activeDays: conversationActiveDaysColumn(),
|
|
5050
4969
|
...peopleTreeAggregateColumns
|
|
5051
4970
|
}).from(juniorConversations).innerJoin(
|
|
@@ -5180,7 +5099,7 @@ async function readPeopleProfile(email, options = {}) {
|
|
|
5180
5099
|
}
|
|
5181
5100
|
|
|
5182
5101
|
// src/api/people/spend.query.ts
|
|
5183
|
-
import { and as and15, eq as eq16, gte as gte6, lte as lte2, sql as
|
|
5102
|
+
import { and as and15, eq as eq16, gte as gte6, lte as lte2, sql as sql15 } from "drizzle-orm";
|
|
5184
5103
|
var SEVEN_DAY_OFFSET = 6;
|
|
5185
5104
|
var THIRTY_DAY_OFFSET = 29;
|
|
5186
5105
|
function addUsd3(current, next) {
|
|
@@ -5199,7 +5118,7 @@ function spendWindow(nowMs) {
|
|
|
5199
5118
|
async function readPersonalSpendFromSql(email, nowMs = Date.now()) {
|
|
5200
5119
|
const normalizedEmail = normalizeEmail(email);
|
|
5201
5120
|
const { end, sevenDayStart, thirtyDayStart } = spendWindow(nowMs);
|
|
5202
|
-
const activityDate =
|
|
5121
|
+
const activityDate = sql15`TO_CHAR(
|
|
5203
5122
|
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
5204
5123
|
'YYYY-MM-DD'
|
|
5205
5124
|
)`;
|
|
@@ -5784,7 +5703,7 @@ function readDescriptionText(home) {
|
|
|
5784
5703
|
}
|
|
5785
5704
|
}
|
|
5786
5705
|
async function readSkillReports() {
|
|
5787
|
-
const { discoverSkills } = await import("./skills-
|
|
5706
|
+
const { discoverSkills } = await import("./skills-POMWS2RR.js");
|
|
5788
5707
|
const skills = await discoverSkills();
|
|
5789
5708
|
return skillReportsSchema.parse(
|
|
5790
5709
|
skills.map((skill) => ({
|
|
@@ -5794,7 +5713,7 @@ async function readSkillReports() {
|
|
|
5794
5713
|
);
|
|
5795
5714
|
}
|
|
5796
5715
|
async function readPlugins() {
|
|
5797
|
-
const { pluginCatalogRuntime } = await import("./catalog-runtime-
|
|
5716
|
+
const { pluginCatalogRuntime } = await import("./catalog-runtime-MICXEBLK.js");
|
|
5798
5717
|
return pluginsSchema.parse(
|
|
5799
5718
|
pluginCatalogRuntime.getProviders().map((plugin) => ({
|
|
5800
5719
|
configKeys: plugin.manifest.configKeys ?? [],
|
|
@@ -5807,7 +5726,7 @@ async function readPlugins() {
|
|
|
5807
5726
|
async function readRuntimeInfoReport() {
|
|
5808
5727
|
const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
|
|
5809
5728
|
import("./discovery-DWVDM7UK.js"),
|
|
5810
|
-
import("./catalog-runtime-
|
|
5729
|
+
import("./catalog-runtime-MICXEBLK.js"),
|
|
5811
5730
|
readPlugins(),
|
|
5812
5731
|
readSkillReports()
|
|
5813
5732
|
]);
|
|
@@ -5823,7 +5742,7 @@ async function readRuntimeInfoReport() {
|
|
|
5823
5742
|
}
|
|
5824
5743
|
async function readPluginOperationalReportFeed() {
|
|
5825
5744
|
const nowMs = Date.now();
|
|
5826
|
-
const { getPluginOperationalReports } = await import("./agent-hooks-
|
|
5745
|
+
const { getPluginOperationalReports } = await import("./agent-hooks-IDX764FD.js");
|
|
5827
5746
|
return pluginOperationalReportFeedSchema.parse({
|
|
5828
5747
|
source: "plugins",
|
|
5829
5748
|
generatedAt: new Date(nowMs).toISOString(),
|