@sentry/junior 0.162.0 → 0.163.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/README.md +2 -0
- package/dist/{agent-hooks-TL2SGC5W.js → agent-hooks-6IX5CV7G.js} +10 -10
- package/dist/api/acp/route.d.ts +13 -0
- package/dist/api.js +204 -403
- package/dist/app.d.ts +2 -2
- package/dist/app.js +480 -38
- package/dist/{catalog-runtime-IGSMIADJ.js → catalog-runtime-NEPZNTOM.js} +5 -5
- package/dist/chat/agent/sandbox.d.ts +4 -0
- package/dist/chat/api-turns/cancellation.d.ts +27 -0
- package/dist/chat/api-turns/routing.d.ts +31 -0
- package/dist/chat/api-turns/work.d.ts +12 -29
- package/dist/chat/app/conversation-work.d.ts +6 -1
- package/dist/chat/app/production.d.ts +2 -2
- package/dist/chat/conversations/history.d.ts +3 -0
- package/dist/chat/conversations/turn-lifecycle.d.ts +1 -1
- package/dist/chat/experimental.d.ts +1 -1
- package/dist/chat/plugins/agent-hooks.d.ts +4 -0
- package/dist/chat/repository-instructions.d.ts +1 -1
- package/dist/chat/sandbox/paths.d.ts +1 -0
- package/dist/chat/sandbox/prepare-workspace.d.ts +11 -0
- package/dist/chat/sandbox/ref.d.ts +1 -0
- package/dist/chat/sandbox/sandbox.d.ts +4 -0
- package/dist/chat/sandbox/session.d.ts +4 -0
- package/dist/chat/sandbox/snapshot/profile.d.ts +4 -3
- package/dist/chat/sandbox/snapshot/resolve.d.ts +4 -0
- package/dist/chat/sandbox/workspace.d.ts +4 -0
- package/dist/chat/tools/types.d.ts +5 -0
- package/dist/chat/workspaces/checkout-path.d.ts +4 -0
- package/dist/chat/workspaces/store.d.ts +8 -0
- package/dist/chat/workspaces/tools.d.ts +4 -0
- package/dist/chat/workspaces/types.d.ts +13 -0
- package/dist/{chunk-BPZQWAZJ.js → chunk-2FBPN2Y4.js} +4 -1
- package/dist/{chunk-H2KW7AZC.js → chunk-2HBJQEBE.js} +1 -1
- package/dist/{chunk-O6P7DZ6O.js → chunk-3OZNFCPR.js} +6 -6
- package/dist/{chunk-7DTPFFQX.js → chunk-3T7RJVDJ.js} +1 -1
- package/dist/{chunk-FEWT5KPP.js → chunk-4P2XNVTO.js} +2 -2
- package/dist/{chunk-CZ6EHOU5.js → chunk-ATWHPSMF.js} +40 -2
- package/dist/{chunk-MMBMDSRK.js → chunk-BLZUFHM7.js} +1 -1
- package/dist/chunk-BVREIWBD.js +131 -0
- package/dist/{chunk-OPNJRQDP.js → chunk-EKGJVUVS.js} +9 -6
- package/dist/{chunk-4WYGQ47U.js → chunk-FEIHINKR.js} +5 -5
- package/dist/{chunk-JJ3VXFDI.js → chunk-GCLHNRMU.js} +1 -1
- package/dist/{chunk-WHAJ3QVY.js → chunk-ICJ3KCA2.js} +1 -1
- package/dist/{chunk-5NEBOHRG.js → chunk-IIT23D3M.js} +4 -4
- package/dist/{chunk-EHQLTK3X.js → chunk-IX4XI42N.js} +376 -128
- package/dist/{chunk-DDQ43S5Q.js → chunk-JI5EPI3O.js} +4 -4
- package/dist/{chunk-C3KUKA27.js → chunk-KD3ROG6P.js} +17 -17
- package/dist/{chunk-JRVURR3H.js → chunk-MWVQ35U6.js} +543 -164
- package/dist/{chunk-V7QL4QMW.js → chunk-MXFL7LNZ.js} +12 -7
- package/dist/{chunk-RDV4BQRZ.js → chunk-NL53P7PS.js} +1 -1
- package/dist/{chunk-EBEHJPFF.js → chunk-O4IK4O7C.js} +1 -1
- package/dist/{chunk-KQSO4DJ4.js → chunk-O5ZZL7IR.js} +9 -9
- package/dist/{chunk-FESUWAYU.js → chunk-RK7KPI6G.js} +1 -1
- package/dist/{chunk-OBFRMQBY.js → chunk-RTPJRLOP.js} +9 -9
- package/dist/{chunk-HW4BW3PC.js → chunk-SR6WRBJW.js} +4 -4
- package/dist/{chunk-6BJFIWEV.js → chunk-THS4CKN4.js} +46 -87
- package/dist/{chunk-DZC3F2UI.js → chunk-TPDNZCZU.js} +1 -1
- package/dist/{chunk-Y75ZDQB5.js → chunk-TPT6EF7K.js} +1 -1
- package/dist/{chunk-5IDFPCON.js → chunk-VRS6WDK5.js} +1 -1
- package/dist/{chunk-AJ7J2HWY.js → chunk-WPGYWDJR.js} +6 -6
- package/dist/{chunk-K7IV6UV3.js → chunk-XY2IVIAY.js} +5 -5
- package/dist/{chunk-MNCEGXEH.js → chunk-YAUQXZVT.js} +2 -2
- package/dist/{chunk-THXMSSFZ.js → chunk-ZDKTZG3G.js} +1 -1
- package/dist/{chunk-QHCIZLIX.js → chunk-ZF6IC27P.js} +87 -10
- package/dist/cli/chat.js +32 -32
- package/dist/cli/check.js +6 -6
- package/dist/cli/plugins.js +13 -13
- package/dist/cli/snapshot-create.js +10 -10
- package/dist/cli/upgrade.js +7 -7
- package/dist/db/schema/workspaces.d.ts +169 -0
- package/dist/db/schema.d.ts +169 -1
- package/dist/{db-66XZ4HHQ.js → db-6VBMHVW2.js} +7 -7
- package/dist/{experimental-HH6OM6UH.js → experimental-XVDOSRBS.js} +1 -1
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-FMLKDUUF.js → oauth-callback-server-5NCCUIM2.js} +24 -24
- package/dist/{runner-YZONUMNY.js → runner-6ONEB6TQ.js} +13 -13
- package/dist/{skills-3UDJJXSO.js → skills-Y5R36UH4.js} +6 -6
- package/dist/spawn-RFMBQ6B3.js +37 -0
- package/dist/{validation-3HTDBONC.js → validation-HLHEQDEK.js} +6 -6
- package/dist/version.js +1 -1
- package/dist/{work-O4YTIS54.js → work-VIEFYTFG.js} +18 -18
- package/dist/worker-MRSKPKQZ.js +24 -0
- package/migrations/0029_dizzy_barracuda.sql +19 -0
- package/migrations/meta/0029_snapshot.json +2709 -0
- package/migrations/meta/_journal.json +8 -1
- package/package.json +8 -5
- package/dist/chunk-EM225ITJ.js +0 -56
- package/dist/spawn-TBPVA5S2.js +0 -37
- package/dist/worker-WHURUEYX.js +0 -24
package/dist/api.js
CHANGED
|
@@ -39,22 +39,30 @@ import {
|
|
|
39
39
|
} from "./chunk-SA6BEEAB.js";
|
|
40
40
|
import {
|
|
41
41
|
appendAndEnqueueApiConversationMessage,
|
|
42
|
+
authenticatePersonalToken,
|
|
43
|
+
conversationHasParticipantEmail,
|
|
44
|
+
conversationHasParticipantUser,
|
|
42
45
|
createAndEnqueueApiConversation,
|
|
46
|
+
createPersonalToken,
|
|
43
47
|
createVercelAttachmentStorage,
|
|
44
48
|
formatSlackConversationRedactedLabel,
|
|
49
|
+
listPersonalTokens,
|
|
45
50
|
lookupSlackUser,
|
|
51
|
+
readConversationAccessFromSql,
|
|
46
52
|
readHealthReport,
|
|
47
53
|
resolveSlackConversationContextFromThreadId,
|
|
54
|
+
revokePersonalToken,
|
|
55
|
+
viewerConversationMembership,
|
|
48
56
|
webActorFromEmail
|
|
49
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-MWVQ35U6.js";
|
|
50
58
|
import {
|
|
51
59
|
buildSentryConversationUrl,
|
|
52
60
|
getWebAuthorization
|
|
53
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-NL53P7PS.js";
|
|
54
62
|
import {
|
|
55
63
|
cancelHumanFacingPendingMessages,
|
|
56
64
|
getConversation
|
|
57
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-IIT23D3M.js";
|
|
58
66
|
import {
|
|
59
67
|
readTaskExecutionByConversationId,
|
|
60
68
|
readTaskExecutionDays,
|
|
@@ -62,8 +70,8 @@ import {
|
|
|
62
70
|
readTaskExecutionSummaries,
|
|
63
71
|
readTaskExecutions,
|
|
64
72
|
readTaskRuns
|
|
65
|
-
} from "./chunk-
|
|
66
|
-
import "./chunk-
|
|
73
|
+
} from "./chunk-O5ZZL7IR.js";
|
|
74
|
+
import "./chunk-EKGJVUVS.js";
|
|
67
75
|
import {
|
|
68
76
|
healthReportSchema,
|
|
69
77
|
pluginOperationalReportFeedSchema,
|
|
@@ -88,16 +96,16 @@ import {
|
|
|
88
96
|
listPublicScheduledTasksForTeams,
|
|
89
97
|
readLiveAttachment,
|
|
90
98
|
readStats
|
|
91
|
-
} from "./chunk-
|
|
99
|
+
} from "./chunk-FEIHINKR.js";
|
|
92
100
|
import {
|
|
93
101
|
parseSlackThreadId
|
|
94
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-ICJ3KCA2.js";
|
|
95
103
|
import {
|
|
96
104
|
agentTurnUsageSchema,
|
|
97
105
|
fallbackShortTitle,
|
|
98
106
|
hasAgentTurnUsage,
|
|
99
107
|
renderJuniorNativeConversationEvent
|
|
100
|
-
} from "./chunk-
|
|
108
|
+
} from "./chunk-MXFL7LNZ.js";
|
|
101
109
|
import "./chunk-3Y47VMHV.js";
|
|
102
110
|
import "./chunk-PDO5BLNM.js";
|
|
103
111
|
import {
|
|
@@ -111,7 +119,7 @@ import {
|
|
|
111
119
|
resolveViewerUser,
|
|
112
120
|
updateViewerDisplayName,
|
|
113
121
|
withSlackRetries
|
|
114
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-ZF6IC27P.js";
|
|
115
123
|
import {
|
|
116
124
|
decodeStoredConversationEvent,
|
|
117
125
|
getConversationStore,
|
|
@@ -119,24 +127,20 @@ import {
|
|
|
119
127
|
getSqlExecutor,
|
|
120
128
|
locationFromRow,
|
|
121
129
|
parseSessionSource
|
|
122
|
-
} from "./chunk-
|
|
130
|
+
} from "./chunk-JI5EPI3O.js";
|
|
123
131
|
import {
|
|
124
|
-
juniorApiTokens,
|
|
125
132
|
juniorConversationEvents,
|
|
126
|
-
juniorConversationParticipants,
|
|
127
133
|
juniorConversations,
|
|
128
134
|
juniorIdentities,
|
|
129
135
|
juniorUsers
|
|
130
|
-
} from "./chunk-
|
|
131
|
-
import "./chunk-
|
|
132
|
-
import "./chunk-
|
|
133
|
-
import "./chunk-
|
|
136
|
+
} from "./chunk-ATWHPSMF.js";
|
|
137
|
+
import "./chunk-BVREIWBD.js";
|
|
138
|
+
import "./chunk-TPDNZCZU.js";
|
|
139
|
+
import "./chunk-YAUQXZVT.js";
|
|
134
140
|
import {
|
|
135
141
|
juniorDestinations
|
|
136
142
|
} from "./chunk-VFUK3X5B.js";
|
|
137
|
-
import
|
|
138
|
-
canExposeConversationPayload
|
|
139
|
-
} from "./chunk-7DTPFFQX.js";
|
|
143
|
+
import "./chunk-3T7RJVDJ.js";
|
|
140
144
|
import "./chunk-BDUENQD3.js";
|
|
141
145
|
import {
|
|
142
146
|
parseSlackChannelId,
|
|
@@ -146,10 +150,10 @@ import {
|
|
|
146
150
|
import {
|
|
147
151
|
logException,
|
|
148
152
|
logWarn
|
|
149
|
-
} from "./chunk-
|
|
153
|
+
} from "./chunk-TPT6EF7K.js";
|
|
150
154
|
import "./chunk-6GWA276C.js";
|
|
151
|
-
import "./chunk-
|
|
152
|
-
import "./chunk-
|
|
155
|
+
import "./chunk-ZDKTZG3G.js";
|
|
156
|
+
import "./chunk-2FBPN2Y4.js";
|
|
153
157
|
import "./chunk-MLKGABMK.js";
|
|
154
158
|
|
|
155
159
|
// src/api.ts
|
|
@@ -233,132 +237,6 @@ async function archiveConversation(conversationId, body) {
|
|
|
233
237
|
return { archived: body.archived };
|
|
234
238
|
}
|
|
235
239
|
|
|
236
|
-
// src/api/conversations/access.ts
|
|
237
|
-
import { eq as eq3, inArray as inArray2 } from "drizzle-orm";
|
|
238
|
-
import { alias } from "drizzle-orm/pg-core";
|
|
239
|
-
|
|
240
|
-
// src/api/conversations/membership.ts
|
|
241
|
-
import { and as and2, eq as eq2, exists, inArray, or } from "drizzle-orm";
|
|
242
|
-
function conversationHasParticipantUser(userId) {
|
|
243
|
-
const participant = getDb().select({
|
|
244
|
-
rootConversationId: juniorConversationParticipants.rootConversationId
|
|
245
|
-
}).from(juniorConversationParticipants).where(
|
|
246
|
-
and2(
|
|
247
|
-
eq2(
|
|
248
|
-
juniorConversationParticipants.rootConversationId,
|
|
249
|
-
juniorConversations.conversationId
|
|
250
|
-
),
|
|
251
|
-
eq2(juniorConversationParticipants.userId, userId)
|
|
252
|
-
)
|
|
253
|
-
);
|
|
254
|
-
return exists(participant);
|
|
255
|
-
}
|
|
256
|
-
function conversationHasParticipantEmail(email) {
|
|
257
|
-
const participant = getDb().select({
|
|
258
|
-
rootConversationId: juniorConversationParticipants.rootConversationId
|
|
259
|
-
}).from(juniorConversationParticipants).innerJoin(
|
|
260
|
-
juniorUsers,
|
|
261
|
-
eq2(juniorUsers.id, juniorConversationParticipants.userId)
|
|
262
|
-
).where(
|
|
263
|
-
and2(
|
|
264
|
-
eq2(
|
|
265
|
-
juniorConversationParticipants.rootConversationId,
|
|
266
|
-
juniorConversations.conversationId
|
|
267
|
-
),
|
|
268
|
-
eq2(juniorUsers.primaryEmailNormalized, email)
|
|
269
|
-
)
|
|
270
|
-
);
|
|
271
|
-
return exists(participant);
|
|
272
|
-
}
|
|
273
|
-
function viewerConversationMembership(args) {
|
|
274
|
-
if (args.actorMatch && args.participantMatch) {
|
|
275
|
-
return or(args.actorMatch, args.participantMatch);
|
|
276
|
-
}
|
|
277
|
-
return args.actorMatch ?? args.participantMatch;
|
|
278
|
-
}
|
|
279
|
-
async function conversationIdsWithParticipantUser(db, conversationIds, userId) {
|
|
280
|
-
if (conversationIds.length === 0) {
|
|
281
|
-
return /* @__PURE__ */ new Set();
|
|
282
|
-
}
|
|
283
|
-
const rows = await db.select({
|
|
284
|
-
rootConversationId: juniorConversationParticipants.rootConversationId
|
|
285
|
-
}).from(juniorConversationParticipants).where(
|
|
286
|
-
and2(
|
|
287
|
-
eq2(juniorConversationParticipants.userId, userId),
|
|
288
|
-
inArray(juniorConversationParticipants.rootConversationId, [
|
|
289
|
-
...conversationIds
|
|
290
|
-
])
|
|
291
|
-
)
|
|
292
|
-
);
|
|
293
|
-
return new Set(rows.map((row) => row.rootConversationId));
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// src/api/conversations/access.ts
|
|
297
|
-
var rootConversation = alias(juniorConversations, "access_root_conversation");
|
|
298
|
-
var rootDestination = alias(juniorDestinations, "access_root_destination");
|
|
299
|
-
var rootIdentity = alias(juniorIdentities, "access_root_identity");
|
|
300
|
-
async function readConversationAccessFromSql(db, conversationIds, viewer) {
|
|
301
|
-
if (conversationIds.length === 0) return /* @__PURE__ */ new Map();
|
|
302
|
-
const normalizedViewerEmail = viewer?.email.trim().toLowerCase() || void 0;
|
|
303
|
-
const rows = await db.select({
|
|
304
|
-
conversationId: juniorConversations.conversationId,
|
|
305
|
-
parentConversationId: juniorConversations.parentConversationId,
|
|
306
|
-
storedRootConversationId: juniorConversations.rootConversationId,
|
|
307
|
-
rootConversationId: rootConversation.conversationId,
|
|
308
|
-
rootParentConversationId: rootConversation.parentConversationId,
|
|
309
|
-
rootRootConversationId: rootConversation.rootConversationId,
|
|
310
|
-
visibility: rootDestination.visibility,
|
|
311
|
-
rootEmailNormalized: rootIdentity.emailNormalized,
|
|
312
|
-
rootEmailVerified: rootIdentity.emailVerified,
|
|
313
|
-
rootUserId: rootIdentity.userId
|
|
314
|
-
}).from(juniorConversations).leftJoin(
|
|
315
|
-
rootConversation,
|
|
316
|
-
eq3(
|
|
317
|
-
rootConversation.conversationId,
|
|
318
|
-
juniorConversations.rootConversationId
|
|
319
|
-
)
|
|
320
|
-
).leftJoin(
|
|
321
|
-
rootDestination,
|
|
322
|
-
eq3(rootDestination.id, rootConversation.destinationId)
|
|
323
|
-
).leftJoin(
|
|
324
|
-
rootIdentity,
|
|
325
|
-
eq3(rootIdentity.id, rootConversation.actorIdentityId)
|
|
326
|
-
).where(inArray2(juniorConversations.conversationId, [...conversationIds]));
|
|
327
|
-
const membershipConversationIds = /* @__PURE__ */ new Set();
|
|
328
|
-
for (const row of rows) {
|
|
329
|
-
membershipConversationIds.add(row.conversationId);
|
|
330
|
-
if (row.storedRootConversationId) {
|
|
331
|
-
membershipConversationIds.add(row.storedRootConversationId);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
const participantRootIds = viewer !== void 0 ? await conversationIdsWithParticipantUser(
|
|
335
|
-
db,
|
|
336
|
-
[...membershipConversationIds],
|
|
337
|
-
viewer.id
|
|
338
|
-
) : /* @__PURE__ */ new Set();
|
|
339
|
-
return new Map(
|
|
340
|
-
rows.map((row) => {
|
|
341
|
-
const hasValidRoot = row.rootConversationId !== null && row.rootConversationId === row.storedRootConversationId && row.rootRootConversationId === row.rootConversationId && row.rootParentConversationId === null && (row.parentConversationId !== null || row.storedRootConversationId === row.conversationId);
|
|
342
|
-
const validRootConversationId = hasValidRoot ? row.rootConversationId ?? void 0 : void 0;
|
|
343
|
-
const visibility = validRootConversationId === void 0 ? null : row.visibility;
|
|
344
|
-
const isRootActor = validRootConversationId !== void 0 && viewer !== void 0 && (row.rootUserId === viewer.id || normalizedViewerEmail !== void 0 && row.rootEmailVerified === true && row.rootEmailNormalized === normalizedViewerEmail);
|
|
345
|
-
const isMaterializedParticipant = participantRootIds.has(row.conversationId) || validRootConversationId !== void 0 && participantRootIds.has(validRootConversationId);
|
|
346
|
-
const isParticipant = isRootActor || isMaterializedParticipant;
|
|
347
|
-
const canViewPrivateContent = isParticipant || validRootConversationId !== void 0 && canExposeConversationPayload({
|
|
348
|
-
visibility: visibility ?? void 0
|
|
349
|
-
});
|
|
350
|
-
return [
|
|
351
|
-
row.conversationId,
|
|
352
|
-
{
|
|
353
|
-
canViewPrivateContent,
|
|
354
|
-
isParticipant,
|
|
355
|
-
visibility
|
|
356
|
-
}
|
|
357
|
-
];
|
|
358
|
-
})
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
240
|
// src/api/conversations/attachments.ts
|
|
363
241
|
function mayDisplayInline(contentType) {
|
|
364
242
|
return contentType === "image/gif" || contentType === "image/jpeg" || contentType === "image/png" || contentType === "image/webp";
|
|
@@ -579,7 +457,7 @@ async function resolveSlackTeamDomains(teamIds) {
|
|
|
579
457
|
}
|
|
580
458
|
|
|
581
459
|
// src/chat/pi/sql-model-usage.ts
|
|
582
|
-
import { and as
|
|
460
|
+
import { and as and2, eq as eq2, sql } from "drizzle-orm";
|
|
583
461
|
var message = sql`${juniorConversationEvents.payload}`;
|
|
584
462
|
var usage = sql`${message}->'usage'`;
|
|
585
463
|
var cost = sql`${usage}->'cost'`;
|
|
@@ -677,14 +555,14 @@ async function readConversationModelUsageFromSql(executor, options) {
|
|
|
677
555
|
costTotal: summedCost(nonnegativeNumber(cost, "total"))
|
|
678
556
|
}).from(juniorConversationEvents).innerJoin(
|
|
679
557
|
juniorConversations,
|
|
680
|
-
|
|
558
|
+
eq2(
|
|
681
559
|
juniorConversations.conversationId,
|
|
682
560
|
juniorConversationEvents.conversationId
|
|
683
561
|
)
|
|
684
562
|
).where(
|
|
685
|
-
|
|
686
|
-
options.includeDescendants ?
|
|
687
|
-
|
|
563
|
+
and2(
|
|
564
|
+
options.includeDescendants ? eq2(juniorConversations.rootConversationId, options.conversationId) : eq2(juniorConversationEvents.conversationId, options.conversationId),
|
|
565
|
+
eq2(juniorConversationEvents.type, "assistant_message"),
|
|
688
566
|
sql`jsonb_typeof(${message}->'provider') = 'string'`,
|
|
689
567
|
sql`jsonb_typeof(${message}->'model') = 'string'`,
|
|
690
568
|
sql`coalesce(${message}->>'provider', '') <> ''`,
|
|
@@ -746,12 +624,12 @@ function decodeConversationCursor(args) {
|
|
|
746
624
|
|
|
747
625
|
// src/api/conversations/event-page.ts
|
|
748
626
|
import {
|
|
749
|
-
and as
|
|
627
|
+
and as and3,
|
|
750
628
|
asc,
|
|
751
629
|
desc,
|
|
752
|
-
eq as
|
|
630
|
+
eq as eq3,
|
|
753
631
|
getTableColumns,
|
|
754
|
-
inArray
|
|
632
|
+
inArray,
|
|
755
633
|
lt,
|
|
756
634
|
sql as sql2
|
|
757
635
|
} from "drizzle-orm";
|
|
@@ -1174,18 +1052,18 @@ async function readConversationEventRows(executor, args) {
|
|
|
1174
1052
|
else ${juniorConversationEvents.payload}
|
|
1175
1053
|
end`
|
|
1176
1054
|
}).from(juniorConversationEvents).where(
|
|
1177
|
-
|
|
1178
|
-
|
|
1055
|
+
and3(
|
|
1056
|
+
eq3(juniorConversationEvents.conversationId, args.conversationId),
|
|
1179
1057
|
args.beforeSeq === void 0 ? void 0 : lt(juniorConversationEvents.seq, args.beforeSeq),
|
|
1180
|
-
|
|
1058
|
+
inArray(
|
|
1181
1059
|
juniorConversationEvents.type,
|
|
1182
1060
|
args.types ?? [...conversationReportSourceEventTypes]
|
|
1183
1061
|
),
|
|
1184
|
-
args.subagentInvocationIds === void 0 ? void 0 :
|
|
1062
|
+
args.subagentInvocationIds === void 0 ? void 0 : inArray(
|
|
1185
1063
|
sql2`${juniorConversationEvents.payload}->>'subagentInvocationId'`,
|
|
1186
1064
|
args.subagentInvocationIds
|
|
1187
1065
|
),
|
|
1188
|
-
args.toolCallIds === void 0 ? void 0 :
|
|
1066
|
+
args.toolCallIds === void 0 ? void 0 : inArray(
|
|
1189
1067
|
sql2`${juniorConversationEvents.payload}->>'toolCallId'`,
|
|
1190
1068
|
args.toolCallIds
|
|
1191
1069
|
)
|
|
@@ -1266,7 +1144,7 @@ async function readConversationEventPage(executor, args) {
|
|
|
1266
1144
|
}
|
|
1267
1145
|
|
|
1268
1146
|
// src/api/conversations/list.ts
|
|
1269
|
-
import { and as
|
|
1147
|
+
import { and as and7, asc as asc2, desc as desc2, eq as eq7, isNull as isNull3 } from "drizzle-orm";
|
|
1270
1148
|
|
|
1271
1149
|
// src/api/conversations/shared.ts
|
|
1272
1150
|
function slackStatsLocationLabel(input) {
|
|
@@ -1449,10 +1327,10 @@ function conversationSummaryFromStoredConversation(args) {
|
|
|
1449
1327
|
}
|
|
1450
1328
|
|
|
1451
1329
|
// src/api/conversations/usage.ts
|
|
1452
|
-
import { and as
|
|
1453
|
-
import { alias
|
|
1330
|
+
import { and as and4, eq as eq4, inArray as inArray2, isNull, sql as sql3 } from "drizzle-orm";
|
|
1331
|
+
import { alias } from "drizzle-orm/pg-core";
|
|
1454
1332
|
var usage2 = juniorConversations.usage;
|
|
1455
|
-
var metricRootConversation =
|
|
1333
|
+
var metricRootConversation = alias(
|
|
1456
1334
|
juniorConversations,
|
|
1457
1335
|
"metric_root_conversation"
|
|
1458
1336
|
);
|
|
@@ -1523,19 +1401,19 @@ async function readRootConversationMetricsFromSql(db, rootConversationIds) {
|
|
|
1523
1401
|
costTotal: summedCostNumber("total")
|
|
1524
1402
|
}).from(juniorConversations).innerJoin(
|
|
1525
1403
|
metricRootConversation,
|
|
1526
|
-
|
|
1527
|
-
|
|
1404
|
+
and4(
|
|
1405
|
+
eq4(
|
|
1528
1406
|
metricRootConversation.conversationId,
|
|
1529
1407
|
juniorConversations.rootConversationId
|
|
1530
1408
|
),
|
|
1531
1409
|
isNull(metricRootConversation.parentConversationId),
|
|
1532
|
-
|
|
1410
|
+
eq4(
|
|
1533
1411
|
metricRootConversation.rootConversationId,
|
|
1534
1412
|
metricRootConversation.conversationId
|
|
1535
1413
|
)
|
|
1536
1414
|
)
|
|
1537
1415
|
).where(
|
|
1538
|
-
|
|
1416
|
+
inArray2(juniorConversations.rootConversationId, [...rootConversationIds])
|
|
1539
1417
|
).groupBy(juniorConversations.rootConversationId);
|
|
1540
1418
|
return new Map(
|
|
1541
1419
|
rows.flatMap((row) => {
|
|
@@ -1553,16 +1431,16 @@ async function readRootConversationMetricsFromSql(db, rootConversationIds) {
|
|
|
1553
1431
|
|
|
1554
1432
|
// src/api/conversations/auxiliary-costs.ts
|
|
1555
1433
|
import {
|
|
1556
|
-
and as
|
|
1557
|
-
eq as
|
|
1558
|
-
inArray as
|
|
1434
|
+
and as and5,
|
|
1435
|
+
eq as eq5,
|
|
1436
|
+
inArray as inArray3,
|
|
1559
1437
|
isNotNull as isNotNull2,
|
|
1560
1438
|
isNull as isNull2,
|
|
1561
|
-
or
|
|
1439
|
+
or,
|
|
1562
1440
|
sql as sql4
|
|
1563
1441
|
} from "drizzle-orm";
|
|
1564
|
-
import { alias as
|
|
1565
|
-
var auxiliaryRootConversation =
|
|
1442
|
+
import { alias as alias2 } from "drizzle-orm/pg-core";
|
|
1443
|
+
var auxiliaryRootConversation = alias2(
|
|
1566
1444
|
juniorConversations,
|
|
1567
1445
|
"auxiliary_root_conversation"
|
|
1568
1446
|
);
|
|
@@ -1595,13 +1473,13 @@ async function readConversationAuxiliaryCostsFromSql(db, conversationIds, option
|
|
|
1595
1473
|
ELSE ${juniorConversationEvents.type}
|
|
1596
1474
|
END`;
|
|
1597
1475
|
const cost2 = eventCost();
|
|
1598
|
-
const selectedConversation = options.includeDescendants ?
|
|
1599
|
-
|
|
1600
|
-
|
|
1476
|
+
const selectedConversation = options.includeDescendants ? or(
|
|
1477
|
+
and5(
|
|
1478
|
+
inArray3(juniorConversations.rootConversationId, selectedIds),
|
|
1601
1479
|
isNotNull2(auxiliaryRootConversation.conversationId)
|
|
1602
1480
|
),
|
|
1603
|
-
|
|
1604
|
-
) :
|
|
1481
|
+
inArray3(juniorConversations.conversationId, selectedIds)
|
|
1482
|
+
) : inArray3(juniorConversations.conversationId, selectedIds);
|
|
1605
1483
|
const rows = await db.select({
|
|
1606
1484
|
conversationId,
|
|
1607
1485
|
costUsd: sql4`round(sum(${cost2}), 12)::double precision`.mapWith(
|
|
@@ -1612,29 +1490,29 @@ async function readConversationAuxiliaryCostsFromSql(db, conversationIds, option
|
|
|
1612
1490
|
namespace
|
|
1613
1491
|
}).from(juniorConversationEvents).innerJoin(
|
|
1614
1492
|
juniorConversations,
|
|
1615
|
-
|
|
1493
|
+
eq5(
|
|
1616
1494
|
juniorConversations.conversationId,
|
|
1617
1495
|
juniorConversationEvents.conversationId
|
|
1618
1496
|
)
|
|
1619
1497
|
).leftJoin(
|
|
1620
1498
|
auxiliaryRootConversation,
|
|
1621
|
-
|
|
1622
|
-
|
|
1499
|
+
and5(
|
|
1500
|
+
eq5(
|
|
1623
1501
|
auxiliaryRootConversation.conversationId,
|
|
1624
1502
|
juniorConversations.rootConversationId
|
|
1625
1503
|
),
|
|
1626
1504
|
isNull2(auxiliaryRootConversation.parentConversationId),
|
|
1627
|
-
|
|
1505
|
+
eq5(
|
|
1628
1506
|
auxiliaryRootConversation.rootConversationId,
|
|
1629
1507
|
auxiliaryRootConversation.conversationId
|
|
1630
1508
|
)
|
|
1631
1509
|
)
|
|
1632
1510
|
).where(
|
|
1633
|
-
|
|
1511
|
+
and5(
|
|
1634
1512
|
selectedConversation,
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1513
|
+
or(
|
|
1514
|
+
eq5(juniorConversationEvents.type, "structured_event"),
|
|
1515
|
+
inArray3(juniorConversationEvents.type, [
|
|
1638
1516
|
"guardian_action_reviewed",
|
|
1639
1517
|
"turn_routed"
|
|
1640
1518
|
])
|
|
@@ -1786,7 +1664,7 @@ function isConversationPriority(conversation, nowMs) {
|
|
|
1786
1664
|
}
|
|
1787
1665
|
|
|
1788
1666
|
// src/api/conversations/user-message-activity.ts
|
|
1789
|
-
import { and as
|
|
1667
|
+
import { and as and6, eq as eq6, inArray as inArray4, isNotNull as isNotNull3, or as or2, sql as sql5 } from "drizzle-orm";
|
|
1790
1668
|
async function readLastUserMessageAtByConversation(db, conversationIds) {
|
|
1791
1669
|
if (conversationIds.length === 0) return /* @__PURE__ */ new Map();
|
|
1792
1670
|
const authority = sql5`${juniorConversationEvents.payload}->'provenance'->>'authority'`;
|
|
@@ -1796,17 +1674,17 @@ async function readLastUserMessageAtByConversation(db, conversationIds) {
|
|
|
1796
1674
|
conversationId: juniorConversationEvents.conversationId,
|
|
1797
1675
|
lastUserMessageAt: sql5`max(${juniorConversationEvents.createdAt})`
|
|
1798
1676
|
}).from(juniorConversationEvents).where(
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1677
|
+
and6(
|
|
1678
|
+
inArray4(juniorConversationEvents.conversationId, conversationIds),
|
|
1679
|
+
or2(
|
|
1680
|
+
and6(
|
|
1681
|
+
eq6(juniorConversationEvents.type, "user_message"),
|
|
1682
|
+
eq6(authority, "instruction"),
|
|
1805
1683
|
sql5`${actorPlatform} in ('slack', 'local', 'web')`
|
|
1806
1684
|
),
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1685
|
+
and6(
|
|
1686
|
+
eq6(juniorConversationEvents.type, "message"),
|
|
1687
|
+
eq6(role, "user"),
|
|
1810
1688
|
isNotNull3(juniorConversationEvents.actorIdentityId)
|
|
1811
1689
|
)
|
|
1812
1690
|
)
|
|
@@ -1826,12 +1704,12 @@ function conversationFeedMembershipFilter(filter) {
|
|
|
1826
1704
|
if (!filter) return void 0;
|
|
1827
1705
|
if (filter.kind === "viewer") {
|
|
1828
1706
|
return viewerConversationMembership({
|
|
1829
|
-
actorMatch:
|
|
1707
|
+
actorMatch: eq7(juniorIdentities.userId, filter.userId),
|
|
1830
1708
|
participantMatch: conversationHasParticipantUser(filter.userId)
|
|
1831
1709
|
});
|
|
1832
1710
|
}
|
|
1833
1711
|
return viewerConversationMembership({
|
|
1834
|
-
actorMatch:
|
|
1712
|
+
actorMatch: eq7(juniorUsers.primaryEmailNormalized, filter.email),
|
|
1835
1713
|
participantMatch: conversationHasParticipantEmail(filter.email)
|
|
1836
1714
|
});
|
|
1837
1715
|
}
|
|
@@ -1848,12 +1726,12 @@ async function conversationRows(db, limit, filter) {
|
|
|
1848
1726
|
userDisplayName: juniorUsers.displayName
|
|
1849
1727
|
}).from(juniorConversations).leftJoin(
|
|
1850
1728
|
juniorDestinations,
|
|
1851
|
-
|
|
1729
|
+
eq7(juniorDestinations.id, juniorConversations.destinationId)
|
|
1852
1730
|
).leftJoin(
|
|
1853
1731
|
juniorIdentities,
|
|
1854
|
-
|
|
1855
|
-
).leftJoin(juniorUsers,
|
|
1856
|
-
|
|
1732
|
+
eq7(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
1733
|
+
).leftJoin(juniorUsers, eq7(juniorUsers.id, juniorIdentities.userId)).where(
|
|
1734
|
+
and7(
|
|
1857
1735
|
isNull3(juniorConversations.parentConversationId),
|
|
1858
1736
|
isNull3(juniorConversations.archivedAt),
|
|
1859
1737
|
conversationFeedMembershipFilter(filter)
|
|
@@ -1914,11 +1792,11 @@ async function readConversationRecordFromSql(conversationId) {
|
|
|
1914
1792
|
userDisplayName: juniorUsers.displayName
|
|
1915
1793
|
}).from(juniorConversations).leftJoin(
|
|
1916
1794
|
juniorDestinations,
|
|
1917
|
-
|
|
1795
|
+
eq7(juniorDestinations.id, juniorConversations.destinationId)
|
|
1918
1796
|
).leftJoin(
|
|
1919
1797
|
juniorIdentities,
|
|
1920
|
-
|
|
1921
|
-
).leftJoin(juniorUsers,
|
|
1798
|
+
eq7(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
1799
|
+
).leftJoin(juniorUsers, eq7(juniorUsers.id, juniorIdentities.userId)).where(eq7(juniorConversations.conversationId, conversationId)).limit(1);
|
|
1922
1800
|
const row = rows[0];
|
|
1923
1801
|
return row ? {
|
|
1924
1802
|
conversation: conversationFromRow(row),
|
|
@@ -2042,7 +1920,7 @@ async function readConversationFeed(options = {}) {
|
|
|
2042
1920
|
}
|
|
2043
1921
|
|
|
2044
1922
|
// src/chat/tasks/read.ts
|
|
2045
|
-
import { and as
|
|
1923
|
+
import { and as and8, eq as eq8, or as or3 } from "drizzle-orm";
|
|
2046
1924
|
|
|
2047
1925
|
// src/chat/scheduled-tasks/personal.ts
|
|
2048
1926
|
import { z as z3 } from "zod";
|
|
@@ -2152,16 +2030,16 @@ async function creatorProfileEmails(candidates) {
|
|
|
2152
2030
|
email: juniorUsers.primaryEmailNormalized,
|
|
2153
2031
|
slackUserId: juniorIdentities.providerSubjectId,
|
|
2154
2032
|
teamId: juniorIdentities.providerTenantId
|
|
2155
|
-
}).from(juniorIdentities).innerJoin(juniorUsers,
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2033
|
+
}).from(juniorIdentities).innerJoin(juniorUsers, eq8(juniorUsers.id, juniorIdentities.userId)).where(
|
|
2034
|
+
and8(
|
|
2035
|
+
eq8(juniorIdentities.kind, "user"),
|
|
2036
|
+
eq8(juniorIdentities.provider, "slack"),
|
|
2037
|
+
eq8(juniorIdentities.emailVerified, true),
|
|
2038
|
+
or3(
|
|
2161
2039
|
...[...selectors.values()].map(
|
|
2162
|
-
(selector) =>
|
|
2163
|
-
|
|
2164
|
-
|
|
2040
|
+
(selector) => and8(
|
|
2041
|
+
eq8(juniorIdentities.providerTenantId, selector.teamId),
|
|
2042
|
+
eq8(juniorIdentities.providerSubjectId, selector.slackUserId)
|
|
2165
2043
|
)
|
|
2166
2044
|
)
|
|
2167
2045
|
)
|
|
@@ -2197,12 +2075,12 @@ async function destinationDetails(destinations) {
|
|
|
2197
2075
|
providerTenantId: juniorDestinations.providerTenantId,
|
|
2198
2076
|
visibility: juniorDestinations.visibility
|
|
2199
2077
|
}).from(juniorDestinations).where(
|
|
2200
|
-
|
|
2078
|
+
or3(
|
|
2201
2079
|
...[...selectors.values()].map(
|
|
2202
|
-
(destination) =>
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2080
|
+
(destination) => and8(
|
|
2081
|
+
eq8(juniorDestinations.provider, "slack"),
|
|
2082
|
+
eq8(juniorDestinations.providerTenantId, destination.teamId),
|
|
2083
|
+
eq8(juniorDestinations.providerDestinationId, destination.channelId)
|
|
2206
2084
|
)
|
|
2207
2085
|
)
|
|
2208
2086
|
)
|
|
@@ -2767,19 +2645,19 @@ var slackMailboxMetadataSchema = z4.object({
|
|
|
2767
2645
|
function isoFromMs(value) {
|
|
2768
2646
|
return new Date(value).toISOString();
|
|
2769
2647
|
}
|
|
2770
|
-
function actorIdentityFromApiMetadata(
|
|
2648
|
+
function actorIdentityFromApiMetadata(metadata) {
|
|
2771
2649
|
return {
|
|
2772
|
-
email:
|
|
2773
|
-
...
|
|
2650
|
+
email: metadata.authorEmail.trim().toLowerCase(),
|
|
2651
|
+
...metadata.authorFullName ? { fullName: metadata.authorFullName } : {}
|
|
2774
2652
|
};
|
|
2775
2653
|
}
|
|
2776
|
-
async function actorIdentityFromSlackMetadata(
|
|
2777
|
-
if (
|
|
2778
|
-
const slackUserId =
|
|
2654
|
+
async function actorIdentityFromSlackMetadata(metadata, teamId) {
|
|
2655
|
+
if (metadata.message.author.isMe === true) return void 0;
|
|
2656
|
+
const slackUserId = metadata.message.author.userId.trim();
|
|
2779
2657
|
if (!slackUserId) return void 0;
|
|
2780
2658
|
const profile = teamId ? await lookupSlackUser(teamId, slackUserId) : null;
|
|
2781
|
-
const slackUserName = profile?.userName?.trim() ||
|
|
2782
|
-
const fullName = profile?.fullName?.trim() ||
|
|
2659
|
+
const slackUserName = profile?.userName?.trim() || metadata.message.author.userName?.trim();
|
|
2660
|
+
const fullName = profile?.fullName?.trim() || metadata.message.author.fullName?.trim();
|
|
2783
2661
|
const email = profile?.email?.trim().toLowerCase();
|
|
2784
2662
|
return {
|
|
2785
2663
|
slackUserId,
|
|
@@ -2790,32 +2668,32 @@ async function actorIdentityFromSlackMetadata(metadata2, teamId) {
|
|
|
2790
2668
|
}
|
|
2791
2669
|
async function projectPendingMessage(message2, canExposePayload) {
|
|
2792
2670
|
if (message2.source === "web") {
|
|
2793
|
-
const
|
|
2671
|
+
const metadata = apiTurnMailboxMetadataSchema.safeParse(
|
|
2794
2672
|
message2.input.metadata
|
|
2795
2673
|
);
|
|
2796
|
-
if (!
|
|
2674
|
+
if (!metadata.success) return void 0;
|
|
2797
2675
|
const text = message2.input.text.trim();
|
|
2798
2676
|
if (!text) return void 0;
|
|
2799
2677
|
return {
|
|
2800
2678
|
createdAt: isoFromMs(message2.createdAtMs),
|
|
2801
2679
|
delivery: message2.delivery,
|
|
2802
2680
|
inboundMessageId: message2.inboundMessageId,
|
|
2803
|
-
messageId:
|
|
2681
|
+
messageId: metadata.data.messageId,
|
|
2804
2682
|
receivedAt: isoFromMs(message2.receivedAtMs),
|
|
2805
2683
|
role: "user",
|
|
2806
2684
|
source: "web",
|
|
2807
2685
|
...canExposePayload ? {
|
|
2808
|
-
actorIdentity: actorIdentityFromApiMetadata(
|
|
2686
|
+
actorIdentity: actorIdentityFromApiMetadata(metadata.data),
|
|
2809
2687
|
text
|
|
2810
2688
|
} : { redacted: true }
|
|
2811
2689
|
};
|
|
2812
2690
|
}
|
|
2813
2691
|
if (message2.source === "slack") {
|
|
2814
|
-
const
|
|
2692
|
+
const metadata = slackMailboxMetadataSchema.safeParse(
|
|
2815
2693
|
message2.input.metadata
|
|
2816
2694
|
);
|
|
2817
|
-
if (!
|
|
2818
|
-
if (
|
|
2695
|
+
if (!metadata.success) return void 0;
|
|
2696
|
+
if (metadata.data.message.author.isMe === true) return void 0;
|
|
2819
2697
|
const text = message2.input.text.trim();
|
|
2820
2698
|
if (!text) return void 0;
|
|
2821
2699
|
if (!canExposePayload) {
|
|
@@ -2823,7 +2701,7 @@ async function projectPendingMessage(message2, canExposePayload) {
|
|
|
2823
2701
|
createdAt: isoFromMs(message2.createdAtMs),
|
|
2824
2702
|
delivery: message2.delivery,
|
|
2825
2703
|
inboundMessageId: message2.inboundMessageId,
|
|
2826
|
-
messageId:
|
|
2704
|
+
messageId: metadata.data.message.id,
|
|
2827
2705
|
receivedAt: isoFromMs(message2.receivedAtMs),
|
|
2828
2706
|
redacted: true,
|
|
2829
2707
|
role: "user",
|
|
@@ -2831,14 +2709,14 @@ async function projectPendingMessage(message2, canExposePayload) {
|
|
|
2831
2709
|
};
|
|
2832
2710
|
}
|
|
2833
2711
|
const actorIdentity = await actorIdentityFromSlackMetadata(
|
|
2834
|
-
|
|
2712
|
+
metadata.data,
|
|
2835
2713
|
message2.destination?.platform === "slack" ? message2.destination.teamId : void 0
|
|
2836
2714
|
);
|
|
2837
2715
|
return {
|
|
2838
2716
|
createdAt: isoFromMs(message2.createdAtMs),
|
|
2839
2717
|
delivery: message2.delivery,
|
|
2840
2718
|
inboundMessageId: message2.inboundMessageId,
|
|
2841
|
-
messageId:
|
|
2719
|
+
messageId: metadata.data.message.id,
|
|
2842
2720
|
receivedAt: isoFromMs(message2.receivedAtMs),
|
|
2843
2721
|
role: "user",
|
|
2844
2722
|
source: "slack",
|
|
@@ -2889,8 +2767,8 @@ async function requireConversationPendingMessages(conversationId, options = {})
|
|
|
2889
2767
|
}
|
|
2890
2768
|
|
|
2891
2769
|
// src/api/conversations/stats.query.ts
|
|
2892
|
-
import { and as
|
|
2893
|
-
import { alias as
|
|
2770
|
+
import { and as and9, eq as eq9, gte, isNull as isNull4, lte, sql as sql7 } from "drizzle-orm";
|
|
2771
|
+
import { alias as alias3 } from "drizzle-orm/pg-core";
|
|
2894
2772
|
|
|
2895
2773
|
// src/api/conversations/aggregate.ts
|
|
2896
2774
|
import { sql as sql6 } from "drizzle-orm";
|
|
@@ -2974,7 +2852,7 @@ function conversationActiveDaysColumn() {
|
|
|
2974
2852
|
|
|
2975
2853
|
// src/api/conversations/stats.query.ts
|
|
2976
2854
|
var WINDOW_DAYS = 90;
|
|
2977
|
-
var treeConversation =
|
|
2855
|
+
var treeConversation = alias3(juniorConversations, "stats_tree_conversation");
|
|
2978
2856
|
var treeAggregateColumns = conversationAggregateColumns({
|
|
2979
2857
|
metrics: treeConversation,
|
|
2980
2858
|
roots: juniorConversations
|
|
@@ -3033,7 +2911,7 @@ function statsItems(map) {
|
|
|
3033
2911
|
);
|
|
3034
2912
|
}
|
|
3035
2913
|
function statsWhere(start, end) {
|
|
3036
|
-
return
|
|
2914
|
+
return and9(
|
|
3037
2915
|
isNull4(juniorConversations.parentConversationId),
|
|
3038
2916
|
gte(juniorConversations.lastActivityAt, start),
|
|
3039
2917
|
lte(juniorConversations.lastActivityAt, end)
|
|
@@ -3117,7 +2995,7 @@ async function aggregateStats(db, start, end) {
|
|
|
3117
2995
|
const [totalsRows, actorRows, locationRows, metricRows] = await Promise.all([
|
|
3118
2996
|
db.select(treeAggregateColumns).from(juniorConversations).innerJoin(
|
|
3119
2997
|
treeConversation,
|
|
3120
|
-
|
|
2998
|
+
eq9(
|
|
3121
2999
|
treeConversation.rootConversationId,
|
|
3122
3000
|
juniorConversations.conversationId
|
|
3123
3001
|
)
|
|
@@ -3132,14 +3010,14 @@ async function aggregateStats(db, start, end) {
|
|
|
3132
3010
|
...treeAggregateColumns
|
|
3133
3011
|
}).from(juniorConversations).innerJoin(
|
|
3134
3012
|
treeConversation,
|
|
3135
|
-
|
|
3013
|
+
eq9(
|
|
3136
3014
|
treeConversation.rootConversationId,
|
|
3137
3015
|
juniorConversations.conversationId
|
|
3138
3016
|
)
|
|
3139
3017
|
).leftJoin(
|
|
3140
3018
|
juniorIdentities,
|
|
3141
|
-
|
|
3142
|
-
).leftJoin(juniorUsers,
|
|
3019
|
+
eq9(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
3020
|
+
).leftJoin(juniorUsers, eq9(juniorUsers.id, juniorIdentities.userId)).where(where).groupBy(
|
|
3143
3021
|
juniorIdentities.displayName,
|
|
3144
3022
|
juniorIdentities.emailNormalized,
|
|
3145
3023
|
juniorIdentities.handle,
|
|
@@ -3157,13 +3035,13 @@ async function aggregateStats(db, start, end) {
|
|
|
3157
3035
|
...treeAggregateColumns
|
|
3158
3036
|
}).from(juniorConversations).innerJoin(
|
|
3159
3037
|
treeConversation,
|
|
3160
|
-
|
|
3038
|
+
eq9(
|
|
3161
3039
|
treeConversation.rootConversationId,
|
|
3162
3040
|
juniorConversations.conversationId
|
|
3163
3041
|
)
|
|
3164
3042
|
).leftJoin(
|
|
3165
3043
|
juniorDestinations,
|
|
3166
|
-
|
|
3044
|
+
eq9(juniorDestinations.id, juniorConversations.destinationId)
|
|
3167
3045
|
).where(where).groupBy(
|
|
3168
3046
|
juniorConversations.channelName,
|
|
3169
3047
|
juniorConversations.source,
|
|
@@ -3182,7 +3060,7 @@ async function aggregateStats(db, start, end) {
|
|
|
3182
3060
|
tokens: treeAggregateColumns.tokens
|
|
3183
3061
|
}).from(juniorConversations).innerJoin(
|
|
3184
3062
|
treeConversation,
|
|
3185
|
-
|
|
3063
|
+
eq9(
|
|
3186
3064
|
treeConversation.rootConversationId,
|
|
3187
3065
|
juniorConversations.conversationId
|
|
3188
3066
|
)
|
|
@@ -3209,8 +3087,8 @@ async function aggregateGuardianStats(db, start, end) {
|
|
|
3209
3087
|
deny: sql7`COUNT(*) FILTER (WHERE ${decision} = 'deny')::integer`,
|
|
3210
3088
|
requests: sql7`COUNT(*)::integer`
|
|
3211
3089
|
}).from(juniorConversationEvents).where(
|
|
3212
|
-
|
|
3213
|
-
|
|
3090
|
+
and9(
|
|
3091
|
+
eq9(juniorConversationEvents.type, "guardian_action_reviewed"),
|
|
3214
3092
|
gte(juniorConversationEvents.createdAt, start),
|
|
3215
3093
|
lte(juniorConversationEvents.createdAt, end)
|
|
3216
3094
|
)
|
|
@@ -3471,8 +3349,8 @@ function createConversationRoutes(options) {
|
|
|
3471
3349
|
import { Hono as Hono2 } from "hono";
|
|
3472
3350
|
|
|
3473
3351
|
// src/api/locations/query.ts
|
|
3474
|
-
import { and as
|
|
3475
|
-
import { alias as
|
|
3352
|
+
import { and as and10, asc as asc3, desc as desc3, eq as eq10, gte as gte2, isNull as isNull5, sql as sql8 } from "drizzle-orm";
|
|
3353
|
+
import { alias as alias4 } from "drizzle-orm/pg-core";
|
|
3476
3354
|
|
|
3477
3355
|
// src/api/conversations/reporting.ts
|
|
3478
3356
|
function surfaceLabel2(surface) {
|
|
@@ -3533,7 +3411,7 @@ function summaryFromRow(row, options = {}) {
|
|
|
3533
3411
|
// src/api/locations/query.ts
|
|
3534
3412
|
var RECENT_LIMIT = 25;
|
|
3535
3413
|
var ACTIVITY_DAYS = 90;
|
|
3536
|
-
var treeConversation2 =
|
|
3414
|
+
var treeConversation2 = alias4(
|
|
3537
3415
|
juniorConversations,
|
|
3538
3416
|
"location_tree_conversation"
|
|
3539
3417
|
);
|
|
@@ -3579,10 +3457,10 @@ function topLevelWhere() {
|
|
|
3579
3457
|
return isNull5(juniorConversations.parentConversationId);
|
|
3580
3458
|
}
|
|
3581
3459
|
function publicLocationWhere(destinationId) {
|
|
3582
|
-
return
|
|
3460
|
+
return and10(
|
|
3583
3461
|
topLevelWhere(),
|
|
3584
|
-
|
|
3585
|
-
|
|
3462
|
+
eq10(juniorDestinations.id, destinationId),
|
|
3463
|
+
eq10(juniorDestinations.visibility, "public")
|
|
3586
3464
|
);
|
|
3587
3465
|
}
|
|
3588
3466
|
function locationColumns() {
|
|
@@ -3633,13 +3511,13 @@ async function directoryRows(db) {
|
|
|
3633
3511
|
...conversationRangeColumns()
|
|
3634
3512
|
}).from(juniorConversations).innerJoin(
|
|
3635
3513
|
treeConversation2,
|
|
3636
|
-
|
|
3514
|
+
eq10(
|
|
3637
3515
|
treeConversation2.rootConversationId,
|
|
3638
3516
|
juniorConversations.conversationId
|
|
3639
3517
|
)
|
|
3640
3518
|
).leftJoin(
|
|
3641
3519
|
juniorDestinations,
|
|
3642
|
-
|
|
3520
|
+
eq10(juniorDestinations.id, juniorConversations.destinationId)
|
|
3643
3521
|
).where(topLevelWhere()).groupBy(...locationGroupBy());
|
|
3644
3522
|
}
|
|
3645
3523
|
async function directoryActivityRows(db, start) {
|
|
@@ -3653,8 +3531,8 @@ async function directoryActivityRows(db, start) {
|
|
|
3653
3531
|
visibility: juniorDestinations.visibility
|
|
3654
3532
|
}).from(juniorConversations).leftJoin(
|
|
3655
3533
|
juniorDestinations,
|
|
3656
|
-
|
|
3657
|
-
).where(
|
|
3534
|
+
eq10(juniorDestinations.id, juniorConversations.destinationId)
|
|
3535
|
+
).where(and10(topLevelWhere(), gte2(juniorConversations.lastActivityAt, start))).groupBy(date, juniorDestinations.visibility);
|
|
3658
3536
|
}
|
|
3659
3537
|
function directoryActivityDays(rows, nowMs) {
|
|
3660
3538
|
const days = /* @__PURE__ */ new Map();
|
|
@@ -3747,12 +3625,12 @@ async function recentLocationRows(db, locationId) {
|
|
|
3747
3625
|
usage: juniorConversations.usage
|
|
3748
3626
|
}).from(juniorConversations).innerJoin(
|
|
3749
3627
|
juniorDestinations,
|
|
3750
|
-
|
|
3628
|
+
eq10(juniorDestinations.id, juniorConversations.destinationId)
|
|
3751
3629
|
).leftJoin(
|
|
3752
3630
|
juniorIdentities,
|
|
3753
|
-
|
|
3754
|
-
).leftJoin(juniorUsers,
|
|
3755
|
-
|
|
3631
|
+
eq10(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
3632
|
+
).leftJoin(juniorUsers, eq10(juniorUsers.id, juniorIdentities.userId)).where(
|
|
3633
|
+
and10(
|
|
3756
3634
|
publicLocationWhere(locationId),
|
|
3757
3635
|
isNull5(juniorConversations.archivedAt)
|
|
3758
3636
|
)
|
|
@@ -3779,27 +3657,27 @@ async function readLocationDetailFromSql(locationId, options = {}) {
|
|
|
3779
3657
|
...conversationRangeColumns()
|
|
3780
3658
|
}).from(juniorConversations).innerJoin(
|
|
3781
3659
|
treeConversation2,
|
|
3782
|
-
|
|
3660
|
+
eq10(
|
|
3783
3661
|
treeConversation2.rootConversationId,
|
|
3784
3662
|
juniorConversations.conversationId
|
|
3785
3663
|
)
|
|
3786
3664
|
).innerJoin(
|
|
3787
3665
|
juniorDestinations,
|
|
3788
|
-
|
|
3666
|
+
eq10(juniorDestinations.id, juniorConversations.destinationId)
|
|
3789
3667
|
).where(where).groupBy(...locationGroupBy()),
|
|
3790
3668
|
getDb().select({
|
|
3791
3669
|
date: activityDate,
|
|
3792
3670
|
...treeAggregateColumns2
|
|
3793
3671
|
}).from(juniorConversations).innerJoin(
|
|
3794
3672
|
treeConversation2,
|
|
3795
|
-
|
|
3673
|
+
eq10(
|
|
3796
3674
|
treeConversation2.rootConversationId,
|
|
3797
3675
|
juniorConversations.conversationId
|
|
3798
3676
|
)
|
|
3799
3677
|
).innerJoin(
|
|
3800
3678
|
juniorDestinations,
|
|
3801
|
-
|
|
3802
|
-
).where(
|
|
3679
|
+
eq10(juniorDestinations.id, juniorConversations.destinationId)
|
|
3680
|
+
).where(and10(where, gte2(juniorConversations.lastActivityAt, start))).groupBy(activityDate),
|
|
3803
3681
|
getDb().select({
|
|
3804
3682
|
actorIdentityId: juniorConversations.actorIdentityId,
|
|
3805
3683
|
email: juniorUsers.primaryEmailNormalized,
|
|
@@ -3811,17 +3689,17 @@ async function readLocationDetailFromSql(locationId, options = {}) {
|
|
|
3811
3689
|
...treeAggregateColumns2
|
|
3812
3690
|
}).from(juniorConversations).innerJoin(
|
|
3813
3691
|
treeConversation2,
|
|
3814
|
-
|
|
3692
|
+
eq10(
|
|
3815
3693
|
treeConversation2.rootConversationId,
|
|
3816
3694
|
juniorConversations.conversationId
|
|
3817
3695
|
)
|
|
3818
3696
|
).innerJoin(
|
|
3819
3697
|
juniorDestinations,
|
|
3820
|
-
|
|
3698
|
+
eq10(juniorDestinations.id, juniorConversations.destinationId)
|
|
3821
3699
|
).leftJoin(
|
|
3822
3700
|
juniorIdentities,
|
|
3823
|
-
|
|
3824
|
-
).leftJoin(juniorUsers,
|
|
3701
|
+
eq10(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
3702
|
+
).leftJoin(juniorUsers, eq10(juniorUsers.id, juniorIdentities.userId)).where(where).groupBy(
|
|
3825
3703
|
juniorConversations.actorIdentityId,
|
|
3826
3704
|
juniorUsers.primaryEmailNormalized,
|
|
3827
3705
|
juniorUsers.displayName,
|
|
@@ -3934,22 +3812,22 @@ function createLocationRoutes() {
|
|
|
3934
3812
|
import { Hono as Hono3 } from "hono";
|
|
3935
3813
|
|
|
3936
3814
|
// src/api/people/list.query.ts
|
|
3937
|
-
import { and as
|
|
3815
|
+
import { and as and12, eq as eq12, gte as gte3, sql as sql10 } from "drizzle-orm";
|
|
3938
3816
|
|
|
3939
3817
|
// src/api/people/shared.ts
|
|
3940
|
-
import { and as
|
|
3941
|
-
import { alias as
|
|
3818
|
+
import { and as and11, asc as asc4, desc as desc4, eq as eq11, isNull as isNull6, notExists, or as or4, sql as sql9 } from "drizzle-orm";
|
|
3819
|
+
import { alias as alias5 } from "drizzle-orm/pg-core";
|
|
3942
3820
|
var RECENT_LIMIT2 = 25;
|
|
3943
3821
|
var ACTIVITY_DAYS2 = 365;
|
|
3944
|
-
var peopleTreeConversation =
|
|
3822
|
+
var peopleTreeConversation = alias5(
|
|
3945
3823
|
juniorConversations,
|
|
3946
3824
|
"people_tree_conversation"
|
|
3947
3825
|
);
|
|
3948
|
-
var peopleRootConversation =
|
|
3826
|
+
var peopleRootConversation = alias5(
|
|
3949
3827
|
juniorConversations,
|
|
3950
3828
|
"people_root_conversation"
|
|
3951
3829
|
);
|
|
3952
|
-
var peopleRootIdentity =
|
|
3830
|
+
var peopleRootIdentity = alias5(juniorIdentities, "people_root_identity");
|
|
3953
3831
|
var peopleTreeAggregateColumns = conversationAggregateColumns({
|
|
3954
3832
|
metrics: peopleTreeConversation,
|
|
3955
3833
|
roots: juniorConversations
|
|
@@ -3957,37 +3835,37 @@ var peopleTreeAggregateColumns = conversationAggregateColumns({
|
|
|
3957
3835
|
function peopleTreeMetricsJoin() {
|
|
3958
3836
|
const rootOwnedByActor = getDb().select({ conversationId: peopleRootConversation.conversationId }).from(peopleRootConversation).innerJoin(
|
|
3959
3837
|
peopleRootIdentity,
|
|
3960
|
-
|
|
3838
|
+
eq11(peopleRootIdentity.id, peopleRootConversation.actorIdentityId)
|
|
3961
3839
|
).where(
|
|
3962
|
-
|
|
3963
|
-
|
|
3840
|
+
and11(
|
|
3841
|
+
eq11(
|
|
3964
3842
|
peopleRootConversation.conversationId,
|
|
3965
3843
|
juniorConversations.rootConversationId
|
|
3966
3844
|
),
|
|
3967
3845
|
isNull6(peopleRootConversation.parentConversationId),
|
|
3968
|
-
|
|
3846
|
+
eq11(
|
|
3969
3847
|
peopleRootConversation.rootConversationId,
|
|
3970
3848
|
peopleRootConversation.conversationId
|
|
3971
3849
|
),
|
|
3972
|
-
|
|
3850
|
+
eq11(
|
|
3973
3851
|
peopleRootIdentity.emailNormalized,
|
|
3974
3852
|
juniorUsers.primaryEmailNormalized
|
|
3975
3853
|
),
|
|
3976
|
-
|
|
3854
|
+
eq11(peopleRootIdentity.emailVerified, true)
|
|
3977
3855
|
)
|
|
3978
3856
|
);
|
|
3979
|
-
return
|
|
3980
|
-
|
|
3857
|
+
return and11(
|
|
3858
|
+
eq11(
|
|
3981
3859
|
peopleTreeConversation.rootConversationId,
|
|
3982
3860
|
juniorConversations.rootConversationId
|
|
3983
3861
|
),
|
|
3984
|
-
|
|
3985
|
-
|
|
3862
|
+
or4(
|
|
3863
|
+
eq11(
|
|
3986
3864
|
juniorConversations.rootConversationId,
|
|
3987
3865
|
juniorConversations.conversationId
|
|
3988
3866
|
),
|
|
3989
|
-
|
|
3990
|
-
|
|
3867
|
+
and11(
|
|
3868
|
+
eq11(
|
|
3991
3869
|
peopleTreeConversation.conversationId,
|
|
3992
3870
|
juniorConversations.conversationId
|
|
3993
3871
|
),
|
|
@@ -4037,11 +3915,11 @@ function statsItems2(map) {
|
|
|
4037
3915
|
}
|
|
4038
3916
|
function verifiedActorWhere(email) {
|
|
4039
3917
|
const normalizedEmail = normalizeEmail(email);
|
|
4040
|
-
return
|
|
4041
|
-
|
|
4042
|
-
|
|
3918
|
+
return and11(
|
|
3919
|
+
eq11(juniorIdentities.provider, "slack"),
|
|
3920
|
+
eq11(juniorIdentities.emailVerified, true),
|
|
4043
3921
|
sql9`${juniorUsers.primaryEmailNormalized} IS NOT NULL`,
|
|
4044
|
-
normalizedEmail ?
|
|
3922
|
+
normalizedEmail ? eq11(juniorUsers.primaryEmailNormalized, normalizedEmail) : void 0
|
|
4045
3923
|
);
|
|
4046
3924
|
}
|
|
4047
3925
|
async function recentActorRows(email) {
|
|
@@ -4064,12 +3942,12 @@ async function recentActorRows(email) {
|
|
|
4064
3942
|
usage: juniorConversations.usage
|
|
4065
3943
|
}).from(juniorConversations).innerJoin(
|
|
4066
3944
|
juniorIdentities,
|
|
4067
|
-
|
|
4068
|
-
).innerJoin(juniorUsers,
|
|
3945
|
+
eq11(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
3946
|
+
).innerJoin(juniorUsers, eq11(juniorUsers.id, juniorIdentities.userId)).leftJoin(
|
|
4069
3947
|
juniorDestinations,
|
|
4070
|
-
|
|
3948
|
+
eq11(juniorDestinations.id, juniorConversations.destinationId)
|
|
4071
3949
|
).where(
|
|
4072
|
-
|
|
3950
|
+
and11(verifiedActorWhere(email), isNull6(juniorConversations.archivedAt))
|
|
4073
3951
|
).orderBy(
|
|
4074
3952
|
desc4(juniorConversations.lastActivityAt),
|
|
4075
3953
|
asc4(juniorConversations.conversationId)
|
|
@@ -4113,17 +3991,17 @@ async function readPeopleListFromSql() {
|
|
|
4113
3991
|
...conversationRangeColumns()
|
|
4114
3992
|
}).from(juniorConversations).innerJoin(
|
|
4115
3993
|
juniorIdentities,
|
|
4116
|
-
|
|
4117
|
-
).innerJoin(juniorUsers,
|
|
3994
|
+
eq12(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
3995
|
+
).innerJoin(juniorUsers, eq12(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, peopleTreeMetricsJoin()).where(verifiedActorWhere()).groupBy(juniorUsers.primaryEmailNormalized, juniorUsers.displayName),
|
|
4118
3996
|
getDb().select({
|
|
4119
3997
|
activePeople: sql10`COUNT(DISTINCT ${juniorUsers.id})::int`,
|
|
4120
3998
|
conversations: sql10`COUNT(*)::int`,
|
|
4121
3999
|
date: activityDate
|
|
4122
4000
|
}).from(juniorConversations).innerJoin(
|
|
4123
4001
|
juniorIdentities,
|
|
4124
|
-
|
|
4125
|
-
).innerJoin(juniorUsers,
|
|
4126
|
-
|
|
4002
|
+
eq12(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
4003
|
+
).innerJoin(juniorUsers, eq12(juniorUsers.id, juniorIdentities.userId)).where(
|
|
4004
|
+
and12(
|
|
4127
4005
|
verifiedActorWhere(),
|
|
4128
4006
|
gte3(juniorConversations.lastActivityAt, start)
|
|
4129
4007
|
)
|
|
@@ -4176,7 +4054,7 @@ async function readPeoplePluginReports(args) {
|
|
|
4176
4054
|
source: "plugins"
|
|
4177
4055
|
});
|
|
4178
4056
|
}
|
|
4179
|
-
const { getPluginProfileReports } = await import("./agent-hooks-
|
|
4057
|
+
const { getPluginProfileReports } = await import("./agent-hooks-6IX5CV7G.js");
|
|
4180
4058
|
return pluginOperationalReportFeedSchema.parse({
|
|
4181
4059
|
generatedAt: new Date(nowMs).toISOString(),
|
|
4182
4060
|
reports: await getPluginProfileReports({
|
|
@@ -4189,7 +4067,7 @@ async function readPeoplePluginReports(args) {
|
|
|
4189
4067
|
}
|
|
4190
4068
|
|
|
4191
4069
|
// src/api/people/profile.query.ts
|
|
4192
|
-
import { and as
|
|
4070
|
+
import { and as and13, eq as eq13, gte as gte4, sql as sql11 } from "drizzle-orm";
|
|
4193
4071
|
function emptyProfile(email, nowMs) {
|
|
4194
4072
|
const end = new Date(nowMs);
|
|
4195
4073
|
end.setUTCHours(0, 0, 0, 0);
|
|
@@ -4268,15 +4146,15 @@ async function readPeopleProfileFromSql(email, options = {}) {
|
|
|
4268
4146
|
...peopleTreeAggregateColumns
|
|
4269
4147
|
}).from(juniorConversations).innerJoin(
|
|
4270
4148
|
juniorIdentities,
|
|
4271
|
-
|
|
4272
|
-
).innerJoin(juniorUsers,
|
|
4149
|
+
eq13(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
4150
|
+
).innerJoin(juniorUsers, eq13(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(where).groupBy(juniorUsers.primaryEmailNormalized, juniorUsers.displayName),
|
|
4273
4151
|
getDb().select({
|
|
4274
4152
|
date: activityDate,
|
|
4275
4153
|
...peopleTreeAggregateColumns
|
|
4276
4154
|
}).from(juniorConversations).innerJoin(
|
|
4277
4155
|
juniorIdentities,
|
|
4278
|
-
|
|
4279
|
-
).innerJoin(juniorUsers,
|
|
4156
|
+
eq13(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
4157
|
+
).innerJoin(juniorUsers, eq13(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(and13(where, gte4(juniorConversations.lastActivityAt, start))).groupBy(activityDate),
|
|
4280
4158
|
getDb().select({
|
|
4281
4159
|
channel,
|
|
4282
4160
|
channelName: juniorConversations.channelName,
|
|
@@ -4285,10 +4163,10 @@ async function readPeopleProfileFromSql(email, options = {}) {
|
|
|
4285
4163
|
...peopleTreeAggregateColumns
|
|
4286
4164
|
}).from(juniorConversations).innerJoin(
|
|
4287
4165
|
juniorIdentities,
|
|
4288
|
-
|
|
4289
|
-
).innerJoin(juniorUsers,
|
|
4166
|
+
eq13(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
4167
|
+
).innerJoin(juniorUsers, eq13(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).leftJoin(
|
|
4290
4168
|
juniorDestinations,
|
|
4291
|
-
|
|
4169
|
+
eq13(juniorDestinations.id, juniorConversations.destinationId)
|
|
4292
4170
|
).where(where).groupBy(
|
|
4293
4171
|
channel,
|
|
4294
4172
|
juniorConversations.channelName,
|
|
@@ -4297,8 +4175,8 @@ async function readPeopleProfileFromSql(email, options = {}) {
|
|
|
4297
4175
|
),
|
|
4298
4176
|
getDb().select({ surface, ...peopleTreeAggregateColumns }).from(juniorConversations).innerJoin(
|
|
4299
4177
|
juniorIdentities,
|
|
4300
|
-
|
|
4301
|
-
).innerJoin(juniorUsers,
|
|
4178
|
+
eq13(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
4179
|
+
).innerJoin(juniorUsers, eq13(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(where).groupBy(surface),
|
|
4302
4180
|
recentActorRows(normalizedEmail)
|
|
4303
4181
|
]);
|
|
4304
4182
|
const totalsRow = totalsRows[0];
|
|
@@ -4376,7 +4254,7 @@ async function readPeopleProfile(email, options = {}) {
|
|
|
4376
4254
|
}
|
|
4377
4255
|
|
|
4378
4256
|
// src/api/people/spend.query.ts
|
|
4379
|
-
import { and as
|
|
4257
|
+
import { and as and14, eq as eq14, gte as gte5, lte as lte2, sql as sql12 } from "drizzle-orm";
|
|
4380
4258
|
var SEVEN_DAY_OFFSET = 6;
|
|
4381
4259
|
var THIRTY_DAY_OFFSET = 29;
|
|
4382
4260
|
function addUsd2(current, next) {
|
|
@@ -4405,9 +4283,9 @@ async function readPersonalSpendFromSql(email, nowMs = Date.now()) {
|
|
|
4405
4283
|
date: activityDate
|
|
4406
4284
|
}).from(juniorConversations).innerJoin(
|
|
4407
4285
|
juniorIdentities,
|
|
4408
|
-
|
|
4409
|
-
).innerJoin(juniorUsers,
|
|
4410
|
-
|
|
4286
|
+
eq14(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
4287
|
+
).innerJoin(juniorUsers, eq14(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(
|
|
4288
|
+
and14(
|
|
4411
4289
|
verifiedActorWhere(normalizedEmail),
|
|
4412
4290
|
gte5(juniorConversations.lastActivityAt, thirtyDayStart),
|
|
4413
4291
|
lte2(juniorConversations.lastActivityAt, end)
|
|
@@ -4505,83 +4383,6 @@ function createPeopleRoutes() {
|
|
|
4505
4383
|
|
|
4506
4384
|
// src/api/personal-tokens/routes.ts
|
|
4507
4385
|
import { Hono as Hono4 } from "hono";
|
|
4508
|
-
|
|
4509
|
-
// src/personal-tokens/store.ts
|
|
4510
|
-
import { createHash, randomBytes, randomUUID } from "crypto";
|
|
4511
|
-
import { and as and16, desc as desc5, eq as eq17, gt, isNull as isNull7 } from "drizzle-orm";
|
|
4512
|
-
var TOKEN_PREFIX = "jr_pat_";
|
|
4513
|
-
var TOKEN_SUFFIX_LENGTH = 8;
|
|
4514
|
-
var DEFAULT_TOKEN_LIFETIME_MS = 90 * 24 * 60 * 60 * 1e3;
|
|
4515
|
-
function normalizeEmail2(email) {
|
|
4516
|
-
return email.trim().toLowerCase();
|
|
4517
|
-
}
|
|
4518
|
-
function hashToken(token2) {
|
|
4519
|
-
return createHash("sha256").update(token2, "utf8").digest("hex");
|
|
4520
|
-
}
|
|
4521
|
-
function metadata(row) {
|
|
4522
|
-
return {
|
|
4523
|
-
id: row.id,
|
|
4524
|
-
name: row.name,
|
|
4525
|
-
tokenSuffix: row.tokenSuffix,
|
|
4526
|
-
createdAt: row.createdAt.toISOString(),
|
|
4527
|
-
expiresAt: row.expiresAt.toISOString(),
|
|
4528
|
-
lastUsedAt: row.lastUsedAt?.toISOString() ?? null
|
|
4529
|
-
};
|
|
4530
|
-
}
|
|
4531
|
-
async function createPersonalToken(args) {
|
|
4532
|
-
const now = args.now ?? /* @__PURE__ */ new Date();
|
|
4533
|
-
const token2 = `${TOKEN_PREFIX}${randomBytes(32).toString("base64url")}`;
|
|
4534
|
-
const row = {
|
|
4535
|
-
id: randomUUID(),
|
|
4536
|
-
ownerEmailNormalized: normalizeEmail2(args.email),
|
|
4537
|
-
name: args.name.trim(),
|
|
4538
|
-
tokenHash: hashToken(token2),
|
|
4539
|
-
tokenSuffix: token2.slice(-TOKEN_SUFFIX_LENGTH),
|
|
4540
|
-
createdAt: now,
|
|
4541
|
-
expiresAt: new Date(now.getTime() + DEFAULT_TOKEN_LIFETIME_MS)
|
|
4542
|
-
};
|
|
4543
|
-
await getDb().insert(juniorApiTokens).values(row);
|
|
4544
|
-
return { ...metadata({ ...row, lastUsedAt: null, revokedAt: null }), token: token2 };
|
|
4545
|
-
}
|
|
4546
|
-
async function listPersonalTokens(email, now = /* @__PURE__ */ new Date()) {
|
|
4547
|
-
const rows = await getDb().select().from(juniorApiTokens).where(
|
|
4548
|
-
and16(
|
|
4549
|
-
eq17(juniorApiTokens.ownerEmailNormalized, normalizeEmail2(email)),
|
|
4550
|
-
isNull7(juniorApiTokens.revokedAt),
|
|
4551
|
-
gt(juniorApiTokens.expiresAt, now)
|
|
4552
|
-
)
|
|
4553
|
-
).orderBy(desc5(juniorApiTokens.createdAt));
|
|
4554
|
-
return rows.map(metadata);
|
|
4555
|
-
}
|
|
4556
|
-
async function revokePersonalToken(args) {
|
|
4557
|
-
const rows = await getDb().update(juniorApiTokens).set({ revokedAt: args.now ?? /* @__PURE__ */ new Date() }).where(
|
|
4558
|
-
and16(
|
|
4559
|
-
eq17(juniorApiTokens.id, args.id),
|
|
4560
|
-
eq17(juniorApiTokens.ownerEmailNormalized, normalizeEmail2(args.email)),
|
|
4561
|
-
isNull7(juniorApiTokens.revokedAt)
|
|
4562
|
-
)
|
|
4563
|
-
).returning({ id: juniorApiTokens.id });
|
|
4564
|
-
return rows.length > 0;
|
|
4565
|
-
}
|
|
4566
|
-
async function authenticatePersonalToken(token2, now = /* @__PURE__ */ new Date()) {
|
|
4567
|
-
if (!token2.startsWith(TOKEN_PREFIX)) return void 0;
|
|
4568
|
-
const rows = await getDb().select({
|
|
4569
|
-
id: juniorApiTokens.id,
|
|
4570
|
-
ownerEmailNormalized: juniorApiTokens.ownerEmailNormalized
|
|
4571
|
-
}).from(juniorApiTokens).where(
|
|
4572
|
-
and16(
|
|
4573
|
-
eq17(juniorApiTokens.tokenHash, hashToken(token2)),
|
|
4574
|
-
isNull7(juniorApiTokens.revokedAt),
|
|
4575
|
-
gt(juniorApiTokens.expiresAt, now)
|
|
4576
|
-
)
|
|
4577
|
-
).limit(1);
|
|
4578
|
-
const match = rows[0];
|
|
4579
|
-
if (!match) return void 0;
|
|
4580
|
-
await getDb().update(juniorApiTokens).set({ lastUsedAt: now }).where(eq17(juniorApiTokens.id, match.id));
|
|
4581
|
-
return match.ownerEmailNormalized;
|
|
4582
|
-
}
|
|
4583
|
-
|
|
4584
|
-
// src/api/personal-tokens/routes.ts
|
|
4585
4386
|
function createPersonalTokenRoutes() {
|
|
4586
4387
|
const app = new Hono4();
|
|
4587
4388
|
app.get("/", requireViewer, async (context) => {
|
|
@@ -4834,7 +4635,7 @@ function readDescriptionText(home) {
|
|
|
4834
4635
|
}
|
|
4835
4636
|
}
|
|
4836
4637
|
async function readSkillReports() {
|
|
4837
|
-
const { discoverSkills } = await import("./skills-
|
|
4638
|
+
const { discoverSkills } = await import("./skills-Y5R36UH4.js");
|
|
4838
4639
|
const skills = await discoverSkills();
|
|
4839
4640
|
return skillReportsSchema.parse(
|
|
4840
4641
|
skills.map((skill) => ({
|
|
@@ -4844,7 +4645,7 @@ async function readSkillReports() {
|
|
|
4844
4645
|
);
|
|
4845
4646
|
}
|
|
4846
4647
|
async function readPlugins() {
|
|
4847
|
-
const { pluginCatalogRuntime } = await import("./catalog-runtime-
|
|
4648
|
+
const { pluginCatalogRuntime } = await import("./catalog-runtime-NEPZNTOM.js");
|
|
4848
4649
|
return pluginsSchema.parse(
|
|
4849
4650
|
pluginCatalogRuntime.getProviders().map((plugin) => ({
|
|
4850
4651
|
configKeys: plugin.manifest.configKeys ?? [],
|
|
@@ -4857,7 +4658,7 @@ async function readPlugins() {
|
|
|
4857
4658
|
async function readRuntimeInfoReport() {
|
|
4858
4659
|
const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
|
|
4859
4660
|
import("./discovery-GUFTFBTL.js"),
|
|
4860
|
-
import("./catalog-runtime-
|
|
4661
|
+
import("./catalog-runtime-NEPZNTOM.js"),
|
|
4861
4662
|
readPlugins(),
|
|
4862
4663
|
readSkillReports()
|
|
4863
4664
|
]);
|
|
@@ -4873,7 +4674,7 @@ async function readRuntimeInfoReport() {
|
|
|
4873
4674
|
}
|
|
4874
4675
|
async function readPluginOperationalReportFeed() {
|
|
4875
4676
|
const nowMs = Date.now();
|
|
4876
|
-
const { getPluginOperationalReports } = await import("./agent-hooks-
|
|
4677
|
+
const { getPluginOperationalReports } = await import("./agent-hooks-6IX5CV7G.js");
|
|
4877
4678
|
return pluginOperationalReportFeedSchema.parse({
|
|
4878
4679
|
source: "plugins",
|
|
4879
4680
|
generatedAt: new Date(nowMs).toISOString(),
|