@sentry/junior 0.182.0 → 0.183.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-3S25UIHO.js → agent-hooks-SNRBZYAU.js} +11 -11
- package/dist/api/code/overview.d.ts +35 -0
- package/dist/api/code/routes.d.ts +4 -0
- package/dist/api/schema/code.d.ts +75 -0
- package/dist/api/schema.d.ts +2 -0
- package/dist/api/schema.js +9 -1
- package/dist/api.js +258 -134
- package/dist/app.js +71 -48
- package/dist/{catalog-runtime-ESLMBQBV.js → catalog-runtime-3I3JOIIH.js} +4 -4
- package/dist/chat/agent-invocations/store.d.ts +4 -2
- package/dist/chat/agent-invocations/work.d.ts +1 -3
- package/dist/chat/app/factory.d.ts +3 -3
- package/dist/chat/app/services.d.ts +3 -3
- package/dist/chat/code/publisher.d.ts +3 -0
- package/dist/chat/code/store.d.ts +9 -0
- package/dist/chat/event-tasks/store.d.ts +10 -0
- package/dist/chat/ingress/slack-webhook.d.ts +1 -1
- package/dist/chat/plugins/agent-hooks.d.ts +5 -0
- package/dist/chat/{runtime/slack-runtime.d.ts → providers/slack/runtime.d.ts} +2 -2
- package/dist/chat/{runtime/reply-executor.d.ts → providers/slack/turn.d.ts} +10 -9
- package/dist/chat/resource-events/store.d.ts +12 -0
- package/dist/chat/runtime/turn-execution.d.ts +30 -0
- package/dist/chat/slack/dispatch-turn.d.ts +12 -14
- package/dist/chat/task-execution/slack-work.d.ts +1 -1
- package/dist/{chunk-SXOZIG5X.js → chunk-24OJZ5OU.js} +6 -6
- package/dist/{chunk-SVFSYQMT.js → chunk-2ADFGSUS.js} +1 -1
- package/dist/{chunk-GGYA5NPN.js → chunk-2EPYYVJC.js} +8 -8
- package/dist/{chunk-KGMHUDVF.js → chunk-35PM4YY5.js} +6 -6
- package/dist/{chunk-3ENUMZNG.js → chunk-37IQ6DGU.js} +3 -3
- package/dist/{chunk-3THPTNN6.js → chunk-3HJ4F4L7.js} +4 -4
- package/dist/{chunk-3NFHI2NA.js → chunk-3L7CWDQQ.js} +1 -1
- package/dist/{chunk-CVBIM4Z3.js → chunk-4WGFWHWP.js} +1 -1
- package/dist/{chunk-YHL2L2ZZ.js → chunk-56XONJPF.js} +1 -1
- package/dist/{chunk-44BQ3TSK.js → chunk-6UXDTPEN.js} +233 -173
- package/dist/{chunk-2CEOXDG2.js → chunk-AHMWPFIW.js} +174 -6
- package/dist/{chunk-6TSWXBTQ.js → chunk-AX3UDIMA.js} +3 -3
- package/dist/{chunk-S35OZMSL.js → chunk-AYW7J6K4.js} +13 -13
- package/dist/{chunk-WOIALVN2.js → chunk-E3OBGRHN.js} +1 -1
- package/dist/{chunk-4DZ62L36.js → chunk-EENQGEIP.js} +1 -1
- package/dist/{chunk-UUMBHORH.js → chunk-FJMTMGBC.js} +1 -1
- package/dist/{chunk-Z7ALSQS3.js → chunk-G2B2XZQW.js} +1 -1
- package/dist/{chunk-TEFNHMO2.js → chunk-HUK5XIZL.js} +4 -4
- package/dist/{chunk-LT4QYGKM.js → chunk-IO6KFXYE.js} +160 -97
- package/dist/{chunk-JIOKUIAS.js → chunk-KTXOGLNE.js} +2 -2
- package/dist/{chunk-LHQK5XCU.js → chunk-LMNMMESF.js} +2 -2
- package/dist/{chunk-UQP54CXZ.js → chunk-LZBPGX5A.js} +1 -1
- package/dist/{chunk-PQES5LB5.js → chunk-PLZT45VC.js} +5 -5
- package/dist/{chunk-V5UZCCNW.js → chunk-QI5JW5AG.js} +6 -6
- package/dist/{chunk-A7THOQ6N.js → chunk-QZV76CM4.js} +21 -21
- package/dist/{chunk-LB4FWMCV.js → chunk-R767Y7QV.js} +183 -155
- package/dist/{chunk-MJISSOWB.js → chunk-SQHFVIMZ.js} +1 -1
- package/dist/{chunk-BDDWVY32.js → chunk-T5MTGX2E.js} +19 -19
- package/dist/{chunk-DZR3L74W.js → chunk-V64JCZUV.js} +3 -3
- package/dist/{chunk-VHMAFMHB.js → chunk-VOV3SCM3.js} +1 -1
- package/dist/{chunk-BZD4ADQH.js → chunk-W46NIB5H.js} +1 -1
- package/dist/{chunk-QHALFHZA.js → chunk-W5JMPEBO.js} +9 -9
- package/dist/{chunk-D6OHGAIO.js → chunk-WOKJRLM2.js} +5 -5
- package/dist/chunk-WVIA7V3M.js +975 -0
- package/dist/{chunk-UKIHNBBD.js → chunk-X52ESOBP.js} +3 -3
- package/dist/cli/chat.js +33 -35
- 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/code.d.ts +367 -0
- package/dist/db/schema.d.ts +367 -1
- package/dist/{db-NYIWZ4L5.js → db-K2VMNLHQ.js} +6 -6
- package/dist/instrumentation.js +3 -3
- package/dist/nitro.js +6 -6
- package/dist/{oauth-callback-server-A2YTPVVX.js → oauth-callback-server-DZZMTKSS.js} +25 -25
- package/dist/{runner-VKAEU52J.js → runner-IIAKWDXI.js} +18 -18
- package/dist/{skills-52GMXUTY.js → skills-EXIQ7BP5.js} +5 -5
- package/dist/spawn-ZR6OOEAN.js +37 -0
- package/dist/task-runner-C52HYCVD.js +32 -0
- package/dist/{validation-VD2YQX2W.js → validation-XUGIWBJF.js} +5 -5
- package/dist/version.js +1 -1
- package/dist/{work-ZWBTGEQP.js → work-G4RLJ634.js} +18 -18
- package/dist/worker-R2JEHK67.js +22 -0
- package/migrations/0036_complex_rage.sql +32 -0
- package/migrations/meta/0036_snapshot.json +3186 -0
- package/migrations/meta/_journal.json +8 -1
- package/package.json +6 -6
- package/dist/chunk-CZYNWPWD.js +0 -930
- package/dist/spawn-GSS4EBLR.js +0 -37
- package/dist/task-runner-DUGDWF5O.js +0 -32
- package/dist/worker-XUWD5WS7.js +0 -22
package/dist/api.js
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
archiveConversationResponseSchema,
|
|
9
9
|
cancelConversationPendingMessagesBodySchema,
|
|
10
10
|
cancelConversationPendingMessagesResponseSchema,
|
|
11
|
+
codeOverviewReportSchema,
|
|
11
12
|
conversationAttachmentParamsSchema,
|
|
12
13
|
conversationDetailQuerySchema,
|
|
13
14
|
conversationDetailReportSchema,
|
|
@@ -41,7 +42,7 @@ import {
|
|
|
41
42
|
workspaceListSchema,
|
|
42
43
|
workspaceParamsSchema,
|
|
43
44
|
workspaceSchema
|
|
44
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-WVIA7V3M.js";
|
|
45
46
|
import {
|
|
46
47
|
appendAndEnqueueApiConversationMessage,
|
|
47
48
|
conversationArchiveTimes,
|
|
@@ -59,12 +60,12 @@ import {
|
|
|
59
60
|
resolveSlackConversationContextFromThreadId,
|
|
60
61
|
viewerConversationMembership,
|
|
61
62
|
webActorFromEmail
|
|
62
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-AYW7J6K4.js";
|
|
63
64
|
import {
|
|
64
65
|
buildSentryConversationUrl,
|
|
65
66
|
getWebAuthorization
|
|
66
|
-
} from "./chunk-
|
|
67
|
-
import "./chunk-
|
|
67
|
+
} from "./chunk-4WGFWHWP.js";
|
|
68
|
+
import "./chunk-WOKJRLM2.js";
|
|
68
69
|
import {
|
|
69
70
|
readTaskExecutionByConversationId,
|
|
70
71
|
readTaskExecutionDays,
|
|
@@ -72,9 +73,9 @@ import {
|
|
|
72
73
|
readTaskExecutionSummaries,
|
|
73
74
|
readTaskExecutions,
|
|
74
75
|
readTaskRuns
|
|
75
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-W5JMPEBO.js";
|
|
76
77
|
import "./chunk-M3QYTBQ6.js";
|
|
77
|
-
import "./chunk-
|
|
78
|
+
import "./chunk-PLZT45VC.js";
|
|
78
79
|
import {
|
|
79
80
|
healthReportSchema,
|
|
80
81
|
pluginOperationalReportFeedSchema,
|
|
@@ -82,7 +83,7 @@ import {
|
|
|
82
83
|
runtimeInfoReportSchema,
|
|
83
84
|
skillReportsSchema
|
|
84
85
|
} from "./chunk-UTL3MHPC.js";
|
|
85
|
-
import "./chunk-
|
|
86
|
+
import "./chunk-V64JCZUV.js";
|
|
86
87
|
import {
|
|
87
88
|
deleteEventTask,
|
|
88
89
|
eventTaskBelongsToUser,
|
|
@@ -99,31 +100,31 @@ import {
|
|
|
99
100
|
readScheduledTask,
|
|
100
101
|
readStats,
|
|
101
102
|
saveScheduledTask
|
|
102
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-R767Y7QV.js";
|
|
103
104
|
import {
|
|
104
105
|
parseSlackThreadId
|
|
105
|
-
} from "./chunk-
|
|
106
|
+
} from "./chunk-SQHFVIMZ.js";
|
|
106
107
|
import {
|
|
107
108
|
cancelHumanFacingPendingMessages,
|
|
108
109
|
getConversation
|
|
109
|
-
} from "./chunk-
|
|
110
|
-
import "./chunk-
|
|
110
|
+
} from "./chunk-HUK5XIZL.js";
|
|
111
|
+
import "./chunk-56XONJPF.js";
|
|
111
112
|
import {
|
|
112
113
|
agentTurnUsageSchema,
|
|
113
114
|
fallbackShortTitle,
|
|
114
115
|
hasAgentTurnUsage,
|
|
115
116
|
renderJuniorNativeConversationEvent
|
|
116
|
-
} from "./chunk-
|
|
117
|
+
} from "./chunk-24OJZ5OU.js";
|
|
117
118
|
import {
|
|
118
119
|
getCachedSnapshot
|
|
119
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-37IQ6DGU.js";
|
|
120
121
|
import "./chunk-PDO5BLNM.js";
|
|
121
122
|
import {
|
|
122
123
|
getVercelConversationWorkQueue
|
|
123
124
|
} from "./chunk-DKIJ2RP5.js";
|
|
124
125
|
import "./chunk-JAL3CH4G.js";
|
|
125
126
|
import "./chunk-7H2VZTWN.js";
|
|
126
|
-
import "./chunk-
|
|
127
|
+
import "./chunk-FJMTMGBC.js";
|
|
127
128
|
import {
|
|
128
129
|
SANDBOX_RUNTIME,
|
|
129
130
|
WorkspaceValidationError,
|
|
@@ -143,7 +144,7 @@ import {
|
|
|
143
144
|
updateWorkspace,
|
|
144
145
|
withSlackRetries,
|
|
145
146
|
workspaceRepoCheckoutPath
|
|
146
|
-
} from "./chunk-
|
|
147
|
+
} from "./chunk-AHMWPFIW.js";
|
|
147
148
|
import "./chunk-3Y47VMHV.js";
|
|
148
149
|
import {
|
|
149
150
|
decodeStoredConversationEvent,
|
|
@@ -153,29 +154,31 @@ import {
|
|
|
153
154
|
locationFromRow,
|
|
154
155
|
parseSessionSource,
|
|
155
156
|
resolveRootConversationId
|
|
156
|
-
} from "./chunk-
|
|
157
|
+
} from "./chunk-AX3UDIMA.js";
|
|
157
158
|
import {
|
|
158
159
|
conversationReadColumns,
|
|
159
160
|
juniorApiTokens,
|
|
161
|
+
juniorCodeChanges,
|
|
162
|
+
juniorCodeRepositories,
|
|
160
163
|
juniorConversationEvents,
|
|
161
164
|
juniorConversationParticipants,
|
|
162
165
|
juniorConversations,
|
|
163
166
|
juniorIdentities,
|
|
164
167
|
juniorSchedulerTasks,
|
|
165
168
|
juniorUsers
|
|
166
|
-
} from "./chunk-
|
|
169
|
+
} from "./chunk-6UXDTPEN.js";
|
|
167
170
|
import {
|
|
168
171
|
create,
|
|
169
172
|
hash
|
|
170
|
-
} from "./chunk-
|
|
171
|
-
import "./chunk-
|
|
173
|
+
} from "./chunk-X52ESOBP.js";
|
|
174
|
+
import "./chunk-G2B2XZQW.js";
|
|
172
175
|
import {
|
|
173
176
|
juniorDestinations
|
|
174
177
|
} from "./chunk-VFUK3X5B.js";
|
|
175
|
-
import "./chunk-
|
|
176
|
-
import "./chunk-
|
|
177
|
-
import "./chunk-
|
|
178
|
-
import "./chunk-
|
|
178
|
+
import "./chunk-LMNMMESF.js";
|
|
179
|
+
import "./chunk-2ADFGSUS.js";
|
|
180
|
+
import "./chunk-E3OBGRHN.js";
|
|
181
|
+
import "./chunk-EENQGEIP.js";
|
|
179
182
|
import "./chunk-CEMMLV5L.js";
|
|
180
183
|
import {
|
|
181
184
|
parseSlackChannelId,
|
|
@@ -187,12 +190,12 @@ import "./chunk-TXKUKMVO.js";
|
|
|
187
190
|
import {
|
|
188
191
|
logException,
|
|
189
192
|
logWarn
|
|
190
|
-
} from "./chunk-
|
|
193
|
+
} from "./chunk-LZBPGX5A.js";
|
|
191
194
|
import "./chunk-PEQXYSSE.js";
|
|
192
|
-
import "./chunk-
|
|
195
|
+
import "./chunk-W46NIB5H.js";
|
|
193
196
|
|
|
194
197
|
// src/api.ts
|
|
195
|
-
import { Hono as
|
|
198
|
+
import { Hono as Hono9 } from "hono";
|
|
196
199
|
import { HTTPException as HTTPException2 } from "hono/http-exception";
|
|
197
200
|
|
|
198
201
|
// src/api/conversations/routes.ts
|
|
@@ -3489,11 +3492,131 @@ function createConversationRoutes(options) {
|
|
|
3489
3492
|
return app;
|
|
3490
3493
|
}
|
|
3491
3494
|
|
|
3492
|
-
// src/api/
|
|
3495
|
+
// src/api/code/routes.ts
|
|
3493
3496
|
import { Hono as Hono2 } from "hono";
|
|
3494
3497
|
|
|
3498
|
+
// src/api/code/overview.ts
|
|
3499
|
+
import { desc as desc4, eq as eq11, gte as gte2, or as or5, sql as sql11 } from "drizzle-orm";
|
|
3500
|
+
import { z as z5 } from "zod";
|
|
3501
|
+
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
3502
|
+
var WINDOW_DAYS2 = 30;
|
|
3503
|
+
var summaryRowSchema = z5.object({
|
|
3504
|
+
closed: z5.number().int().nonnegative(),
|
|
3505
|
+
created: z5.number().int().nonnegative(),
|
|
3506
|
+
merged: z5.number().int().nonnegative(),
|
|
3507
|
+
open: z5.number().int().nonnegative()
|
|
3508
|
+
}).strict();
|
|
3509
|
+
var repositoryRowSchema = summaryRowSchema.extend({
|
|
3510
|
+
id: z5.string().min(1),
|
|
3511
|
+
name: z5.string().min(1),
|
|
3512
|
+
provider: z5.string().min(1),
|
|
3513
|
+
url: z5.string().nullable()
|
|
3514
|
+
}).strict();
|
|
3515
|
+
function queryRows(result) {
|
|
3516
|
+
if (typeof result !== "object" || result === null || !("rows" in result) || !Array.isArray(result.rows)) {
|
|
3517
|
+
throw new TypeError("Code overview query did not return rows");
|
|
3518
|
+
}
|
|
3519
|
+
return result.rows;
|
|
3520
|
+
}
|
|
3521
|
+
async function readCodeOverview(nowMs = Date.now()) {
|
|
3522
|
+
const db = getDb();
|
|
3523
|
+
const windowEnd = new Date(nowMs);
|
|
3524
|
+
const windowStart = new Date(nowMs - WINDOW_DAYS2 * DAY_MS);
|
|
3525
|
+
const changes = juniorCodeChanges;
|
|
3526
|
+
const repositories = juniorCodeRepositories;
|
|
3527
|
+
const [summaryResult, repositoryResult, recentChanges] = await Promise.all([
|
|
3528
|
+
db.execute(sql11`
|
|
3529
|
+
SELECT
|
|
3530
|
+
count(*) FILTER (WHERE ${changes.openedAt} >= ${windowStart})::integer AS "created",
|
|
3531
|
+
count(*) FILTER (WHERE ${changes.mergedAt} >= ${windowStart})::integer AS "merged",
|
|
3532
|
+
count(*) FILTER (
|
|
3533
|
+
WHERE ${changes.state} = 'closed' AND ${changes.closedAt} >= ${windowStart}
|
|
3534
|
+
)::integer AS "closed",
|
|
3535
|
+
count(*) FILTER (WHERE ${changes.state} = 'open')::integer AS "open"
|
|
3536
|
+
FROM ${changes}
|
|
3537
|
+
`),
|
|
3538
|
+
db.execute(sql11`
|
|
3539
|
+
SELECT
|
|
3540
|
+
${repositories.id} AS "id",
|
|
3541
|
+
${repositories.name} AS "name",
|
|
3542
|
+
${repositories.provider} AS "provider",
|
|
3543
|
+
${repositories.url} AS "url",
|
|
3544
|
+
count(${changes.id}) FILTER (WHERE ${changes.openedAt} >= ${windowStart})::integer AS "created",
|
|
3545
|
+
count(${changes.id}) FILTER (WHERE ${changes.mergedAt} >= ${windowStart})::integer AS "merged",
|
|
3546
|
+
count(${changes.id}) FILTER (
|
|
3547
|
+
WHERE ${changes.state} = 'closed' AND ${changes.closedAt} >= ${windowStart}
|
|
3548
|
+
)::integer AS "closed",
|
|
3549
|
+
count(${changes.id}) FILTER (WHERE ${changes.state} = 'open')::integer AS "open"
|
|
3550
|
+
FROM ${repositories}
|
|
3551
|
+
LEFT JOIN ${changes} ON ${changes.repositoryId} = ${repositories.id}
|
|
3552
|
+
WHERE ${changes.openedAt} >= ${windowStart}
|
|
3553
|
+
OR ${changes.mergedAt} >= ${windowStart}
|
|
3554
|
+
OR ${changes.closedAt} >= ${windowStart}
|
|
3555
|
+
OR ${changes.state} = 'open'
|
|
3556
|
+
GROUP BY ${repositories.id}
|
|
3557
|
+
ORDER BY "merged" DESC, "created" DESC, ${repositories.name} ASC
|
|
3558
|
+
LIMIT 25
|
|
3559
|
+
`),
|
|
3560
|
+
db.select({
|
|
3561
|
+
closedAt: changes.closedAt,
|
|
3562
|
+
id: changes.id,
|
|
3563
|
+
mergedAt: changes.mergedAt,
|
|
3564
|
+
number: changes.number,
|
|
3565
|
+
openedAt: changes.openedAt,
|
|
3566
|
+
provider: changes.provider,
|
|
3567
|
+
repository: repositories.name,
|
|
3568
|
+
state: changes.state,
|
|
3569
|
+
title: changes.title,
|
|
3570
|
+
url: changes.url
|
|
3571
|
+
}).from(changes).innerJoin(repositories, eq11(changes.repositoryId, repositories.id)).where(
|
|
3572
|
+
or5(
|
|
3573
|
+
gte2(changes.openedAt, windowStart),
|
|
3574
|
+
gte2(changes.mergedAt, windowStart),
|
|
3575
|
+
gte2(changes.closedAt, windowStart),
|
|
3576
|
+
eq11(changes.state, "open")
|
|
3577
|
+
)
|
|
3578
|
+
).orderBy(desc4(changes.updatedAt)).limit(25)
|
|
3579
|
+
]);
|
|
3580
|
+
const summary = summaryRowSchema.parse(queryRows(summaryResult)[0]);
|
|
3581
|
+
const completed = summary.merged + summary.closed;
|
|
3582
|
+
return codeOverviewReportSchema.parse({
|
|
3583
|
+
changes: recentChanges.map((change) => ({
|
|
3584
|
+
...change,
|
|
3585
|
+
closedAt: change.closedAt?.toISOString(),
|
|
3586
|
+
mergedAt: change.mergedAt?.toISOString(),
|
|
3587
|
+
openedAt: change.openedAt.toISOString(),
|
|
3588
|
+
title: change.title ?? void 0,
|
|
3589
|
+
url: change.url ?? void 0
|
|
3590
|
+
})),
|
|
3591
|
+
generatedAt: windowEnd.toISOString(),
|
|
3592
|
+
repositories: z5.array(repositoryRowSchema).parse(queryRows(repositoryResult)).map((repository) => ({
|
|
3593
|
+
...repository,
|
|
3594
|
+
url: repository.url ?? void 0
|
|
3595
|
+
})),
|
|
3596
|
+
summary: {
|
|
3597
|
+
...summary,
|
|
3598
|
+
mergeRate: completed > 0 ? summary.merged / completed : void 0
|
|
3599
|
+
},
|
|
3600
|
+
windowEnd: windowEnd.toISOString(),
|
|
3601
|
+
windowStart: windowStart.toISOString()
|
|
3602
|
+
});
|
|
3603
|
+
}
|
|
3604
|
+
|
|
3605
|
+
// src/api/code/routes.ts
|
|
3606
|
+
function createCodeRoutes() {
|
|
3607
|
+
const app = new Hono2();
|
|
3608
|
+
app.get(
|
|
3609
|
+
"/",
|
|
3610
|
+
async () => jsonResponse(codeOverviewReportSchema, await readCodeOverview())
|
|
3611
|
+
);
|
|
3612
|
+
return app;
|
|
3613
|
+
}
|
|
3614
|
+
|
|
3615
|
+
// src/api/locations/routes.ts
|
|
3616
|
+
import { Hono as Hono3 } from "hono";
|
|
3617
|
+
|
|
3495
3618
|
// src/api/locations/query.ts
|
|
3496
|
-
import { and as and11, asc as asc3, desc as
|
|
3619
|
+
import { and as and11, asc as asc3, desc as desc5, eq as eq12, gte as gte3, isNull as isNull5, sql as sql12 } from "drizzle-orm";
|
|
3497
3620
|
import { alias as alias4 } from "drizzle-orm/pg-core";
|
|
3498
3621
|
|
|
3499
3622
|
// src/api/conversations/reporting.ts
|
|
@@ -3603,8 +3726,8 @@ function topLevelWhere() {
|
|
|
3603
3726
|
function publicLocationWhere(destinationId) {
|
|
3604
3727
|
return and11(
|
|
3605
3728
|
topLevelWhere(),
|
|
3606
|
-
|
|
3607
|
-
|
|
3729
|
+
eq12(juniorDestinations.id, destinationId),
|
|
3730
|
+
eq12(juniorDestinations.visibility, "public")
|
|
3608
3731
|
);
|
|
3609
3732
|
}
|
|
3610
3733
|
function locationColumns() {
|
|
@@ -3655,28 +3778,28 @@ async function directoryRows(db) {
|
|
|
3655
3778
|
...conversationRangeColumns()
|
|
3656
3779
|
}).from(juniorConversations).innerJoin(
|
|
3657
3780
|
treeConversation2,
|
|
3658
|
-
|
|
3781
|
+
eq12(
|
|
3659
3782
|
treeConversation2.rootConversationId,
|
|
3660
3783
|
juniorConversations.conversationId
|
|
3661
3784
|
)
|
|
3662
3785
|
).leftJoin(
|
|
3663
3786
|
juniorDestinations,
|
|
3664
|
-
|
|
3787
|
+
eq12(juniorDestinations.id, juniorConversations.destinationId)
|
|
3665
3788
|
).where(topLevelWhere()).groupBy(...locationGroupBy());
|
|
3666
3789
|
}
|
|
3667
3790
|
async function directoryActivityRows(db, start) {
|
|
3668
|
-
const date =
|
|
3791
|
+
const date = sql12`TO_CHAR(
|
|
3669
3792
|
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
3670
3793
|
'YYYY-MM-DD'
|
|
3671
3794
|
)`;
|
|
3672
3795
|
return db.select({
|
|
3673
|
-
conversations:
|
|
3796
|
+
conversations: sql12`COUNT(*)::integer`,
|
|
3674
3797
|
date,
|
|
3675
3798
|
visibility: juniorDestinations.visibility
|
|
3676
3799
|
}).from(juniorConversations).leftJoin(
|
|
3677
3800
|
juniorDestinations,
|
|
3678
|
-
|
|
3679
|
-
).where(and11(topLevelWhere(),
|
|
3801
|
+
eq12(juniorDestinations.id, juniorConversations.destinationId)
|
|
3802
|
+
).where(and11(topLevelWhere(), gte3(juniorConversations.lastActivityAt, start))).groupBy(date, juniorDestinations.visibility);
|
|
3680
3803
|
}
|
|
3681
3804
|
function directoryActivityDays(rows, nowMs) {
|
|
3682
3805
|
const days = /* @__PURE__ */ new Map();
|
|
@@ -3749,7 +3872,7 @@ async function recentLocationRows(db, locationId) {
|
|
|
3749
3872
|
createdAt: juniorConversations.createdAt,
|
|
3750
3873
|
destinationId: juniorDestinations.id,
|
|
3751
3874
|
durationMs: juniorConversations.durationMs,
|
|
3752
|
-
email:
|
|
3875
|
+
email: sql12`COALESCE(
|
|
3753
3876
|
${juniorUsers.primaryEmailNormalized},
|
|
3754
3877
|
${juniorIdentities.email}
|
|
3755
3878
|
)`,
|
|
@@ -3758,7 +3881,7 @@ async function recentLocationRows(db, locationId) {
|
|
|
3758
3881
|
fullName: juniorUsers.displayName,
|
|
3759
3882
|
handle: juniorIdentities.handle,
|
|
3760
3883
|
lastActivityAt: juniorConversations.lastActivityAt,
|
|
3761
|
-
providerSubjectId:
|
|
3884
|
+
providerSubjectId: sql12`CASE
|
|
3762
3885
|
WHEN ${juniorIdentities.provider} = 'slack'
|
|
3763
3886
|
THEN ${juniorIdentities.providerSubjectId}
|
|
3764
3887
|
ELSE NULL
|
|
@@ -3769,12 +3892,12 @@ async function recentLocationRows(db, locationId) {
|
|
|
3769
3892
|
usage: juniorConversations.usage
|
|
3770
3893
|
}).from(juniorConversations).innerJoin(
|
|
3771
3894
|
juniorDestinations,
|
|
3772
|
-
|
|
3895
|
+
eq12(juniorDestinations.id, juniorConversations.destinationId)
|
|
3773
3896
|
).leftJoin(
|
|
3774
3897
|
juniorIdentities,
|
|
3775
|
-
|
|
3776
|
-
).leftJoin(juniorUsers,
|
|
3777
|
-
|
|
3898
|
+
eq12(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
3899
|
+
).leftJoin(juniorUsers, eq12(juniorUsers.id, juniorIdentities.userId)).where(publicLocationWhere(locationId)).orderBy(
|
|
3900
|
+
desc5(juniorConversations.lastActivityAt),
|
|
3778
3901
|
asc3(juniorConversations.conversationId)
|
|
3779
3902
|
).limit(RECENT_LIMIT);
|
|
3780
3903
|
}
|
|
@@ -3785,7 +3908,7 @@ async function readLocationDetailFromSql(locationId, options = {}) {
|
|
|
3785
3908
|
const start = new Date(end);
|
|
3786
3909
|
start.setUTCDate(start.getUTCDate() - (ACTIVITY_DAYS - 1));
|
|
3787
3910
|
const where = publicLocationWhere(locationId);
|
|
3788
|
-
const activityDate =
|
|
3911
|
+
const activityDate = sql12`TO_CHAR(
|
|
3789
3912
|
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
3790
3913
|
'YYYY-MM-DD'
|
|
3791
3914
|
)`;
|
|
@@ -3796,27 +3919,27 @@ async function readLocationDetailFromSql(locationId, options = {}) {
|
|
|
3796
3919
|
...conversationRangeColumns()
|
|
3797
3920
|
}).from(juniorConversations).innerJoin(
|
|
3798
3921
|
treeConversation2,
|
|
3799
|
-
|
|
3922
|
+
eq12(
|
|
3800
3923
|
treeConversation2.rootConversationId,
|
|
3801
3924
|
juniorConversations.conversationId
|
|
3802
3925
|
)
|
|
3803
3926
|
).innerJoin(
|
|
3804
3927
|
juniorDestinations,
|
|
3805
|
-
|
|
3928
|
+
eq12(juniorDestinations.id, juniorConversations.destinationId)
|
|
3806
3929
|
).where(where).groupBy(...locationGroupBy()),
|
|
3807
3930
|
getDb().select({
|
|
3808
3931
|
date: activityDate,
|
|
3809
3932
|
...treeAggregateColumns2
|
|
3810
3933
|
}).from(juniorConversations).innerJoin(
|
|
3811
3934
|
treeConversation2,
|
|
3812
|
-
|
|
3935
|
+
eq12(
|
|
3813
3936
|
treeConversation2.rootConversationId,
|
|
3814
3937
|
juniorConversations.conversationId
|
|
3815
3938
|
)
|
|
3816
3939
|
).innerJoin(
|
|
3817
3940
|
juniorDestinations,
|
|
3818
|
-
|
|
3819
|
-
).where(and11(where,
|
|
3941
|
+
eq12(juniorDestinations.id, juniorConversations.destinationId)
|
|
3942
|
+
).where(and11(where, gte3(juniorConversations.lastActivityAt, start))).groupBy(activityDate),
|
|
3820
3943
|
getDb().select({
|
|
3821
3944
|
actorIdentityId: juniorConversations.actorIdentityId,
|
|
3822
3945
|
email: juniorUsers.primaryEmailNormalized,
|
|
@@ -3828,17 +3951,17 @@ async function readLocationDetailFromSql(locationId, options = {}) {
|
|
|
3828
3951
|
...treeAggregateColumns2
|
|
3829
3952
|
}).from(juniorConversations).innerJoin(
|
|
3830
3953
|
treeConversation2,
|
|
3831
|
-
|
|
3954
|
+
eq12(
|
|
3832
3955
|
treeConversation2.rootConversationId,
|
|
3833
3956
|
juniorConversations.conversationId
|
|
3834
3957
|
)
|
|
3835
3958
|
).innerJoin(
|
|
3836
3959
|
juniorDestinations,
|
|
3837
|
-
|
|
3960
|
+
eq12(juniorDestinations.id, juniorConversations.destinationId)
|
|
3838
3961
|
).leftJoin(
|
|
3839
3962
|
juniorIdentities,
|
|
3840
|
-
|
|
3841
|
-
).leftJoin(juniorUsers,
|
|
3963
|
+
eq12(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
3964
|
+
).leftJoin(juniorUsers, eq12(juniorUsers.id, juniorIdentities.userId)).where(where).groupBy(
|
|
3842
3965
|
juniorConversations.actorIdentityId,
|
|
3843
3966
|
juniorUsers.primaryEmailNormalized,
|
|
3844
3967
|
juniorUsers.displayName,
|
|
@@ -3921,7 +4044,7 @@ async function readLocationDirectory() {
|
|
|
3921
4044
|
|
|
3922
4045
|
// src/api/locations/routes.ts
|
|
3923
4046
|
function createLocationRoutes() {
|
|
3924
|
-
const app = new
|
|
4047
|
+
const app = new Hono3();
|
|
3925
4048
|
app.get(
|
|
3926
4049
|
"/",
|
|
3927
4050
|
async () => jsonResponse(locationDirectoryReportSchema, await readLocationDirectory())
|
|
@@ -3948,13 +4071,13 @@ function createLocationRoutes() {
|
|
|
3948
4071
|
}
|
|
3949
4072
|
|
|
3950
4073
|
// src/api/people/routes.ts
|
|
3951
|
-
import { Hono as
|
|
4074
|
+
import { Hono as Hono4 } from "hono";
|
|
3952
4075
|
|
|
3953
4076
|
// src/api/people/list.query.ts
|
|
3954
|
-
import { and as and13, eq as
|
|
4077
|
+
import { and as and13, eq as eq14, gte as gte4, sql as sql14 } from "drizzle-orm";
|
|
3955
4078
|
|
|
3956
4079
|
// src/api/people/shared.ts
|
|
3957
|
-
import { and as and12, asc as asc4, desc as
|
|
4080
|
+
import { and as and12, asc as asc4, desc as desc6, eq as eq13, isNull as isNull6, notExists, or as or6, sql as sql13 } from "drizzle-orm";
|
|
3958
4081
|
import { alias as alias5 } from "drizzle-orm/pg-core";
|
|
3959
4082
|
var RECENT_LIMIT2 = 25;
|
|
3960
4083
|
var ACTIVITY_DAYS2 = 365;
|
|
@@ -3974,37 +4097,37 @@ var peopleTreeAggregateColumns = conversationAggregateColumns({
|
|
|
3974
4097
|
function peopleTreeMetricsJoin() {
|
|
3975
4098
|
const rootOwnedByActor = getDb().select({ conversationId: peopleRootConversation.conversationId }).from(peopleRootConversation).innerJoin(
|
|
3976
4099
|
peopleRootIdentity,
|
|
3977
|
-
|
|
4100
|
+
eq13(peopleRootIdentity.id, peopleRootConversation.actorIdentityId)
|
|
3978
4101
|
).where(
|
|
3979
4102
|
and12(
|
|
3980
|
-
|
|
4103
|
+
eq13(
|
|
3981
4104
|
peopleRootConversation.conversationId,
|
|
3982
4105
|
juniorConversations.rootConversationId
|
|
3983
4106
|
),
|
|
3984
4107
|
isNull6(peopleRootConversation.parentConversationId),
|
|
3985
|
-
|
|
4108
|
+
eq13(
|
|
3986
4109
|
peopleRootConversation.rootConversationId,
|
|
3987
4110
|
peopleRootConversation.conversationId
|
|
3988
4111
|
),
|
|
3989
|
-
|
|
4112
|
+
eq13(
|
|
3990
4113
|
peopleRootIdentity.emailNormalized,
|
|
3991
4114
|
juniorUsers.primaryEmailNormalized
|
|
3992
4115
|
),
|
|
3993
|
-
|
|
4116
|
+
eq13(peopleRootIdentity.emailVerified, true)
|
|
3994
4117
|
)
|
|
3995
4118
|
);
|
|
3996
4119
|
return and12(
|
|
3997
|
-
|
|
4120
|
+
eq13(
|
|
3998
4121
|
peopleTreeConversation.rootConversationId,
|
|
3999
4122
|
juniorConversations.rootConversationId
|
|
4000
4123
|
),
|
|
4001
|
-
|
|
4002
|
-
|
|
4124
|
+
or6(
|
|
4125
|
+
eq13(
|
|
4003
4126
|
juniorConversations.rootConversationId,
|
|
4004
4127
|
juniorConversations.conversationId
|
|
4005
4128
|
),
|
|
4006
4129
|
and12(
|
|
4007
|
-
|
|
4130
|
+
eq13(
|
|
4008
4131
|
peopleTreeConversation.conversationId,
|
|
4009
4132
|
juniorConversations.conversationId
|
|
4010
4133
|
),
|
|
@@ -4055,10 +4178,10 @@ function statsItems2(map) {
|
|
|
4055
4178
|
function verifiedActorWhere(email) {
|
|
4056
4179
|
const normalizedEmail = normalizeEmail(email);
|
|
4057
4180
|
return and12(
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
normalizedEmail ?
|
|
4181
|
+
eq13(juniorIdentities.provider, "slack"),
|
|
4182
|
+
eq13(juniorIdentities.emailVerified, true),
|
|
4183
|
+
sql13`${juniorUsers.primaryEmailNormalized} IS NOT NULL`,
|
|
4184
|
+
normalizedEmail ? eq13(juniorUsers.primaryEmailNormalized, normalizedEmail) : void 0
|
|
4062
4185
|
);
|
|
4063
4186
|
}
|
|
4064
4187
|
async function recentActorRows(email) {
|
|
@@ -4081,12 +4204,12 @@ async function recentActorRows(email) {
|
|
|
4081
4204
|
usage: juniorConversations.usage
|
|
4082
4205
|
}).from(juniorConversations).innerJoin(
|
|
4083
4206
|
juniorIdentities,
|
|
4084
|
-
|
|
4085
|
-
).innerJoin(juniorUsers,
|
|
4207
|
+
eq13(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
4208
|
+
).innerJoin(juniorUsers, eq13(juniorUsers.id, juniorIdentities.userId)).leftJoin(
|
|
4086
4209
|
juniorDestinations,
|
|
4087
|
-
|
|
4210
|
+
eq13(juniorDestinations.id, juniorConversations.destinationId)
|
|
4088
4211
|
).where(verifiedActorWhere(email)).orderBy(
|
|
4089
|
-
|
|
4212
|
+
desc6(juniorConversations.lastActivityAt),
|
|
4090
4213
|
asc4(juniorConversations.conversationId)
|
|
4091
4214
|
).limit(RECENT_LIMIT2);
|
|
4092
4215
|
}
|
|
@@ -4113,7 +4236,7 @@ function directoryActivityDays2(rows, nowMs) {
|
|
|
4113
4236
|
async function readPeopleListFromSql() {
|
|
4114
4237
|
const nowMs = Date.now();
|
|
4115
4238
|
const { end, start } = activityWindow(nowMs);
|
|
4116
|
-
const activityDate =
|
|
4239
|
+
const activityDate = sql14`TO_CHAR(
|
|
4117
4240
|
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
4118
4241
|
'YYYY-MM-DD'
|
|
4119
4242
|
)`;
|
|
@@ -4121,26 +4244,26 @@ async function readPeopleListFromSql() {
|
|
|
4121
4244
|
getDb().select({
|
|
4122
4245
|
email: juniorUsers.primaryEmailNormalized,
|
|
4123
4246
|
fullName: juniorUsers.displayName,
|
|
4124
|
-
slackUserId:
|
|
4125
|
-
slackUserName:
|
|
4247
|
+
slackUserId: sql14`MAX(${juniorIdentities.providerSubjectId})`,
|
|
4248
|
+
slackUserName: sql14`MAX(${juniorIdentities.handle})`,
|
|
4126
4249
|
activeDays: conversationActiveDaysColumn(),
|
|
4127
4250
|
...peopleTreeAggregateColumns,
|
|
4128
4251
|
...conversationRangeColumns()
|
|
4129
4252
|
}).from(juniorConversations).innerJoin(
|
|
4130
4253
|
juniorIdentities,
|
|
4131
|
-
|
|
4132
|
-
).innerJoin(juniorUsers,
|
|
4254
|
+
eq14(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
4255
|
+
).innerJoin(juniorUsers, eq14(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, peopleTreeMetricsJoin()).where(verifiedActorWhere()).groupBy(juniorUsers.primaryEmailNormalized, juniorUsers.displayName),
|
|
4133
4256
|
getDb().select({
|
|
4134
|
-
activePeople:
|
|
4135
|
-
conversations:
|
|
4257
|
+
activePeople: sql14`COUNT(DISTINCT ${juniorUsers.id})::int`,
|
|
4258
|
+
conversations: sql14`COUNT(*)::int`,
|
|
4136
4259
|
date: activityDate
|
|
4137
4260
|
}).from(juniorConversations).innerJoin(
|
|
4138
4261
|
juniorIdentities,
|
|
4139
|
-
|
|
4140
|
-
).innerJoin(juniorUsers,
|
|
4262
|
+
eq14(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
4263
|
+
).innerJoin(juniorUsers, eq14(juniorUsers.id, juniorIdentities.userId)).where(
|
|
4141
4264
|
and13(
|
|
4142
4265
|
verifiedActorWhere(),
|
|
4143
|
-
|
|
4266
|
+
gte4(juniorConversations.lastActivityAt, start)
|
|
4144
4267
|
)
|
|
4145
4268
|
).groupBy(activityDate)
|
|
4146
4269
|
]);
|
|
@@ -4191,7 +4314,7 @@ async function readPeoplePluginReports(args) {
|
|
|
4191
4314
|
source: "plugins"
|
|
4192
4315
|
});
|
|
4193
4316
|
}
|
|
4194
|
-
const { getPluginProfileReports } = await import("./agent-hooks-
|
|
4317
|
+
const { getPluginProfileReports } = await import("./agent-hooks-SNRBZYAU.js");
|
|
4195
4318
|
return pluginOperationalReportFeedSchema.parse({
|
|
4196
4319
|
generatedAt: new Date(nowMs).toISOString(),
|
|
4197
4320
|
reports: await getPluginProfileReports({
|
|
@@ -4204,7 +4327,7 @@ async function readPeoplePluginReports(args) {
|
|
|
4204
4327
|
}
|
|
4205
4328
|
|
|
4206
4329
|
// src/api/people/profile.query.ts
|
|
4207
|
-
import { and as and14, eq as
|
|
4330
|
+
import { and as and14, eq as eq15, gte as gte5, sql as sql15 } from "drizzle-orm";
|
|
4208
4331
|
function emptyProfile(email, nowMs) {
|
|
4209
4332
|
const end = new Date(nowMs);
|
|
4210
4333
|
end.setUTCHours(0, 0, 0, 0);
|
|
@@ -4239,7 +4362,7 @@ function addAggregate2(map, label, row) {
|
|
|
4239
4362
|
map.set(label, item);
|
|
4240
4363
|
}
|
|
4241
4364
|
function surfaceExpression() {
|
|
4242
|
-
return
|
|
4365
|
+
return sql15`CASE
|
|
4243
4366
|
WHEN ${juniorConversations.source} IN ('api', 'scheduler', 'slack')
|
|
4244
4367
|
THEN ${juniorConversations.source}
|
|
4245
4368
|
WHEN ${juniorConversations.conversationId} LIKE 'slack:%' THEN 'slack'
|
|
@@ -4268,30 +4391,30 @@ async function readPeopleProfileFromSql(email, options = {}) {
|
|
|
4268
4391
|
const where = verifiedActorWhere(normalizedEmail);
|
|
4269
4392
|
const metricsJoin = peopleTreeMetricsJoin();
|
|
4270
4393
|
const surface = surfaceExpression();
|
|
4271
|
-
const activityDate =
|
|
4394
|
+
const activityDate = sql15`TO_CHAR(
|
|
4272
4395
|
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
4273
4396
|
'YYYY-MM-DD'
|
|
4274
4397
|
)`;
|
|
4275
|
-
const channel =
|
|
4398
|
+
const channel = sql15`SPLIT_PART(${juniorConversations.conversationId}, ':', 2)`;
|
|
4276
4399
|
const [totalsRows, dayRows, locationRows, surfaceRows, recentRows] = await Promise.all([
|
|
4277
4400
|
getDb().select({
|
|
4278
4401
|
email: juniorUsers.primaryEmailNormalized,
|
|
4279
4402
|
fullName: juniorUsers.displayName,
|
|
4280
|
-
slackUserId:
|
|
4281
|
-
slackUserName:
|
|
4403
|
+
slackUserId: sql15`MAX(${juniorIdentities.providerSubjectId})`,
|
|
4404
|
+
slackUserName: sql15`MAX(${juniorIdentities.handle})`,
|
|
4282
4405
|
activeDays: conversationActiveDaysColumn(),
|
|
4283
4406
|
...peopleTreeAggregateColumns
|
|
4284
4407
|
}).from(juniorConversations).innerJoin(
|
|
4285
4408
|
juniorIdentities,
|
|
4286
|
-
|
|
4287
|
-
).innerJoin(juniorUsers,
|
|
4409
|
+
eq15(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
4410
|
+
).innerJoin(juniorUsers, eq15(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(where).groupBy(juniorUsers.primaryEmailNormalized, juniorUsers.displayName),
|
|
4288
4411
|
getDb().select({
|
|
4289
4412
|
date: activityDate,
|
|
4290
4413
|
...peopleTreeAggregateColumns
|
|
4291
4414
|
}).from(juniorConversations).innerJoin(
|
|
4292
4415
|
juniorIdentities,
|
|
4293
|
-
|
|
4294
|
-
).innerJoin(juniorUsers,
|
|
4416
|
+
eq15(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
4417
|
+
).innerJoin(juniorUsers, eq15(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(and14(where, gte5(juniorConversations.lastActivityAt, start))).groupBy(activityDate),
|
|
4295
4418
|
getDb().select({
|
|
4296
4419
|
channel,
|
|
4297
4420
|
channelName: juniorConversations.channelName,
|
|
@@ -4300,10 +4423,10 @@ async function readPeopleProfileFromSql(email, options = {}) {
|
|
|
4300
4423
|
...peopleTreeAggregateColumns
|
|
4301
4424
|
}).from(juniorConversations).innerJoin(
|
|
4302
4425
|
juniorIdentities,
|
|
4303
|
-
|
|
4304
|
-
).innerJoin(juniorUsers,
|
|
4426
|
+
eq15(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
4427
|
+
).innerJoin(juniorUsers, eq15(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).leftJoin(
|
|
4305
4428
|
juniorDestinations,
|
|
4306
|
-
|
|
4429
|
+
eq15(juniorDestinations.id, juniorConversations.destinationId)
|
|
4307
4430
|
).where(where).groupBy(
|
|
4308
4431
|
channel,
|
|
4309
4432
|
juniorConversations.channelName,
|
|
@@ -4312,8 +4435,8 @@ async function readPeopleProfileFromSql(email, options = {}) {
|
|
|
4312
4435
|
),
|
|
4313
4436
|
getDb().select({ surface, ...peopleTreeAggregateColumns }).from(juniorConversations).innerJoin(
|
|
4314
4437
|
juniorIdentities,
|
|
4315
|
-
|
|
4316
|
-
).innerJoin(juniorUsers,
|
|
4438
|
+
eq15(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
4439
|
+
).innerJoin(juniorUsers, eq15(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(where).groupBy(surface),
|
|
4317
4440
|
recentActorRows(normalizedEmail)
|
|
4318
4441
|
]);
|
|
4319
4442
|
const totalsRow = totalsRows[0];
|
|
@@ -4391,7 +4514,7 @@ async function readPeopleProfile(email, options = {}) {
|
|
|
4391
4514
|
}
|
|
4392
4515
|
|
|
4393
4516
|
// src/api/people/spend.query.ts
|
|
4394
|
-
import { and as and15, eq as
|
|
4517
|
+
import { and as and15, eq as eq16, gte as gte6, lte as lte2, sql as sql16 } from "drizzle-orm";
|
|
4395
4518
|
var SEVEN_DAY_OFFSET = 6;
|
|
4396
4519
|
var THIRTY_DAY_OFFSET = 29;
|
|
4397
4520
|
function addUsd2(current, next) {
|
|
@@ -4410,7 +4533,7 @@ function spendWindow(nowMs) {
|
|
|
4410
4533
|
async function readPersonalSpendFromSql(email, nowMs = Date.now()) {
|
|
4411
4534
|
const normalizedEmail = normalizeEmail(email);
|
|
4412
4535
|
const { end, sevenDayStart, thirtyDayStart } = spendWindow(nowMs);
|
|
4413
|
-
const activityDate =
|
|
4536
|
+
const activityDate = sql16`TO_CHAR(
|
|
4414
4537
|
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
4415
4538
|
'YYYY-MM-DD'
|
|
4416
4539
|
)`;
|
|
@@ -4420,11 +4543,11 @@ async function readPersonalSpendFromSql(email, nowMs = Date.now()) {
|
|
|
4420
4543
|
date: activityDate
|
|
4421
4544
|
}).from(juniorConversations).innerJoin(
|
|
4422
4545
|
juniorIdentities,
|
|
4423
|
-
|
|
4424
|
-
).innerJoin(juniorUsers,
|
|
4546
|
+
eq16(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
4547
|
+
).innerJoin(juniorUsers, eq16(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(
|
|
4425
4548
|
and15(
|
|
4426
4549
|
verifiedActorWhere(normalizedEmail),
|
|
4427
|
-
|
|
4550
|
+
gte6(juniorConversations.lastActivityAt, thirtyDayStart),
|
|
4428
4551
|
lte2(juniorConversations.lastActivityAt, end)
|
|
4429
4552
|
)
|
|
4430
4553
|
).groupBy(activityDate) : [];
|
|
@@ -4477,7 +4600,7 @@ function createPersonalSpendReader() {
|
|
|
4477
4600
|
|
|
4478
4601
|
// src/api/people/routes.ts
|
|
4479
4602
|
function createPeopleRoutes() {
|
|
4480
|
-
const app = new
|
|
4603
|
+
const app = new Hono4();
|
|
4481
4604
|
const readPersonalSpend = createPersonalSpendReader();
|
|
4482
4605
|
app.get("/me/spend", requireViewer, async (context) => {
|
|
4483
4606
|
const viewer = context.get("viewer");
|
|
@@ -4519,11 +4642,11 @@ function createPeopleRoutes() {
|
|
|
4519
4642
|
}
|
|
4520
4643
|
|
|
4521
4644
|
// src/api/personal-tokens/routes.ts
|
|
4522
|
-
import { Hono as
|
|
4645
|
+
import { Hono as Hono5 } from "hono";
|
|
4523
4646
|
|
|
4524
4647
|
// src/personal-tokens/store.ts
|
|
4525
4648
|
import { createHash, randomBytes, randomUUID } from "crypto";
|
|
4526
|
-
import { and as and16, desc as
|
|
4649
|
+
import { and as and16, desc as desc7, eq as eq17, gt, isNull as isNull7 } from "drizzle-orm";
|
|
4527
4650
|
var TOKEN_PREFIX = "jr_pat_";
|
|
4528
4651
|
var TOKEN_SUFFIX_LENGTH = 8;
|
|
4529
4652
|
var DEFAULT_TOKEN_LIFETIME_MS = 90 * 24 * 60 * 60 * 1e3;
|
|
@@ -4561,18 +4684,18 @@ async function createPersonalToken(args) {
|
|
|
4561
4684
|
async function listPersonalTokens(email, now = /* @__PURE__ */ new Date()) {
|
|
4562
4685
|
const rows = await getDb().select().from(juniorApiTokens).where(
|
|
4563
4686
|
and16(
|
|
4564
|
-
|
|
4687
|
+
eq17(juniorApiTokens.ownerEmailNormalized, normalizeEmail2(email)),
|
|
4565
4688
|
isNull7(juniorApiTokens.revokedAt),
|
|
4566
4689
|
gt(juniorApiTokens.expiresAt, now)
|
|
4567
4690
|
)
|
|
4568
|
-
).orderBy(
|
|
4691
|
+
).orderBy(desc7(juniorApiTokens.createdAt));
|
|
4569
4692
|
return rows.map(metadata);
|
|
4570
4693
|
}
|
|
4571
4694
|
async function revokePersonalToken(args) {
|
|
4572
4695
|
const rows = await getDb().update(juniorApiTokens).set({ revokedAt: args.now ?? /* @__PURE__ */ new Date() }).where(
|
|
4573
4696
|
and16(
|
|
4574
|
-
|
|
4575
|
-
|
|
4697
|
+
eq17(juniorApiTokens.id, args.id),
|
|
4698
|
+
eq17(juniorApiTokens.ownerEmailNormalized, normalizeEmail2(args.email)),
|
|
4576
4699
|
isNull7(juniorApiTokens.revokedAt)
|
|
4577
4700
|
)
|
|
4578
4701
|
).returning({ id: juniorApiTokens.id });
|
|
@@ -4585,20 +4708,20 @@ async function authenticatePersonalToken(token2, now = /* @__PURE__ */ new Date(
|
|
|
4585
4708
|
ownerEmailNormalized: juniorApiTokens.ownerEmailNormalized
|
|
4586
4709
|
}).from(juniorApiTokens).where(
|
|
4587
4710
|
and16(
|
|
4588
|
-
|
|
4711
|
+
eq17(juniorApiTokens.tokenHash, hashToken(token2)),
|
|
4589
4712
|
isNull7(juniorApiTokens.revokedAt),
|
|
4590
4713
|
gt(juniorApiTokens.expiresAt, now)
|
|
4591
4714
|
)
|
|
4592
4715
|
).limit(1);
|
|
4593
4716
|
const match = rows[0];
|
|
4594
4717
|
if (!match) return void 0;
|
|
4595
|
-
await getDb().update(juniorApiTokens).set({ lastUsedAt: now }).where(
|
|
4718
|
+
await getDb().update(juniorApiTokens).set({ lastUsedAt: now }).where(eq17(juniorApiTokens.id, match.id));
|
|
4596
4719
|
return match.ownerEmailNormalized;
|
|
4597
4720
|
}
|
|
4598
4721
|
|
|
4599
4722
|
// src/api/personal-tokens/routes.ts
|
|
4600
4723
|
function createPersonalTokenRoutes() {
|
|
4601
|
-
const app = new
|
|
4724
|
+
const app = new Hono5();
|
|
4602
4725
|
app.get("/", requireViewer, async (context) => {
|
|
4603
4726
|
const viewer = context.get("viewer");
|
|
4604
4727
|
return jsonResponse(personalTokenListSchema, {
|
|
@@ -4645,8 +4768,8 @@ function createPersonalTokenRoutes() {
|
|
|
4645
4768
|
}
|
|
4646
4769
|
|
|
4647
4770
|
// src/api/user-pages/routes.ts
|
|
4648
|
-
import { Hono as
|
|
4649
|
-
import { z as
|
|
4771
|
+
import { Hono as Hono6 } from "hono";
|
|
4772
|
+
import { z as z6 } from "zod";
|
|
4650
4773
|
import {
|
|
4651
4774
|
pluginUserPageContentSchema as pluginUserPageContentSchema2,
|
|
4652
4775
|
pluginUserPageCursorSchema,
|
|
@@ -4714,23 +4837,23 @@ async function readPluginUserPage(input) {
|
|
|
4714
4837
|
}
|
|
4715
4838
|
|
|
4716
4839
|
// src/api/user-pages/routes.ts
|
|
4717
|
-
var userPageQuerySchema =
|
|
4718
|
-
cursor:
|
|
4840
|
+
var userPageQuerySchema = z6.object({
|
|
4841
|
+
cursor: z6.preprocess(
|
|
4719
4842
|
(value) => value || void 0,
|
|
4720
4843
|
pluginUserPageCursorSchema
|
|
4721
4844
|
),
|
|
4722
|
-
filter:
|
|
4845
|
+
filter: z6.preprocess(
|
|
4723
4846
|
(value) => value || void 0,
|
|
4724
4847
|
pluginUserPageFilterSchema
|
|
4725
4848
|
),
|
|
4726
|
-
limit:
|
|
4849
|
+
limit: z6.preprocess(
|
|
4727
4850
|
(value) => value === "" ? void 0 : value,
|
|
4728
|
-
|
|
4851
|
+
z6.coerce.number().int().min(1).max(50).default(20)
|
|
4729
4852
|
),
|
|
4730
|
-
q:
|
|
4853
|
+
q: z6.preprocess((value) => value || void 0, pluginUserPageQuerySchema)
|
|
4731
4854
|
});
|
|
4732
4855
|
function createUserPageRoutes() {
|
|
4733
|
-
const app = new
|
|
4856
|
+
const app = new Hono6();
|
|
4734
4857
|
app.get(
|
|
4735
4858
|
"/",
|
|
4736
4859
|
() => jsonResponse(pluginUserPageLinksSchema2, readPluginUserPageLinks())
|
|
@@ -4759,9 +4882,9 @@ function createUserPageRoutes() {
|
|
|
4759
4882
|
}
|
|
4760
4883
|
|
|
4761
4884
|
// src/api/tasks/routes.ts
|
|
4762
|
-
import { Hono as
|
|
4885
|
+
import { Hono as Hono7 } from "hono";
|
|
4763
4886
|
function createTaskRoutes() {
|
|
4764
|
-
const app = new
|
|
4887
|
+
const app = new Hono7();
|
|
4765
4888
|
app.get("/", requireViewer, async (context) => {
|
|
4766
4889
|
const user = context.get("viewer");
|
|
4767
4890
|
return jsonResponse(taskListSchema, await readViewerTasks(user));
|
|
@@ -4820,7 +4943,7 @@ function createTaskRoutes() {
|
|
|
4820
4943
|
}
|
|
4821
4944
|
|
|
4822
4945
|
// src/api/workspaces/routes.ts
|
|
4823
|
-
import { Hono as
|
|
4946
|
+
import { Hono as Hono8 } from "hono";
|
|
4824
4947
|
function snapshotView(workspace) {
|
|
4825
4948
|
const recorded = workspace.snapshot;
|
|
4826
4949
|
if (!recorded) return null;
|
|
@@ -4876,7 +4999,7 @@ function handleValidationError(error) {
|
|
|
4876
4999
|
throw error;
|
|
4877
5000
|
}
|
|
4878
5001
|
function createWorkspaceRoutes() {
|
|
4879
|
-
const app = new
|
|
5002
|
+
const app = new Hono8();
|
|
4880
5003
|
app.get("/", requireViewer, async () => {
|
|
4881
5004
|
const [baselineSnapshot, workspaces] = await Promise.all([
|
|
4882
5005
|
baselineSnapshotView(),
|
|
@@ -4959,13 +5082,13 @@ function createWorkspaceRoutes() {
|
|
|
4959
5082
|
}
|
|
4960
5083
|
|
|
4961
5084
|
// src/api/stats.ts
|
|
4962
|
-
var
|
|
5085
|
+
var WINDOW_DAYS3 = 90;
|
|
4963
5086
|
async function readStatsReport() {
|
|
4964
5087
|
const now = /* @__PURE__ */ new Date();
|
|
4965
5088
|
const end = now.toISOString().slice(0, 10);
|
|
4966
5089
|
const startDate = new Date(now);
|
|
4967
5090
|
startDate.setUTCHours(0, 0, 0, 0);
|
|
4968
|
-
startDate.setUTCDate(startDate.getUTCDate() - (
|
|
5091
|
+
startDate.setUTCDate(startDate.getUTCDate() - (WINDOW_DAYS3 - 1));
|
|
4969
5092
|
const start = startDate.toISOString().slice(0, 10);
|
|
4970
5093
|
return statsReportSchema.parse({
|
|
4971
5094
|
generatedAt: now.toISOString(),
|
|
@@ -4987,7 +5110,7 @@ function readDescriptionText(home) {
|
|
|
4987
5110
|
}
|
|
4988
5111
|
}
|
|
4989
5112
|
async function readSkillReports() {
|
|
4990
|
-
const { discoverSkills } = await import("./skills-
|
|
5113
|
+
const { discoverSkills } = await import("./skills-EXIQ7BP5.js");
|
|
4991
5114
|
const skills = await discoverSkills();
|
|
4992
5115
|
return skillReportsSchema.parse(
|
|
4993
5116
|
skills.map((skill) => ({
|
|
@@ -4997,7 +5120,7 @@ async function readSkillReports() {
|
|
|
4997
5120
|
);
|
|
4998
5121
|
}
|
|
4999
5122
|
async function readPlugins() {
|
|
5000
|
-
const { pluginCatalogRuntime } = await import("./catalog-runtime-
|
|
5123
|
+
const { pluginCatalogRuntime } = await import("./catalog-runtime-3I3JOIIH.js");
|
|
5001
5124
|
return pluginsSchema.parse(
|
|
5002
5125
|
pluginCatalogRuntime.getProviders().map((plugin) => ({
|
|
5003
5126
|
configKeys: plugin.manifest.configKeys ?? [],
|
|
@@ -5010,7 +5133,7 @@ async function readPlugins() {
|
|
|
5010
5133
|
async function readRuntimeInfoReport() {
|
|
5011
5134
|
const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
|
|
5012
5135
|
import("./discovery-DWVDM7UK.js"),
|
|
5013
|
-
import("./catalog-runtime-
|
|
5136
|
+
import("./catalog-runtime-3I3JOIIH.js"),
|
|
5014
5137
|
readPlugins(),
|
|
5015
5138
|
readSkillReports()
|
|
5016
5139
|
]);
|
|
@@ -5026,7 +5149,7 @@ async function readRuntimeInfoReport() {
|
|
|
5026
5149
|
}
|
|
5027
5150
|
async function readPluginOperationalReportFeed() {
|
|
5028
5151
|
const nowMs = Date.now();
|
|
5029
|
-
const { getPluginOperationalReports } = await import("./agent-hooks-
|
|
5152
|
+
const { getPluginOperationalReports } = await import("./agent-hooks-SNRBZYAU.js");
|
|
5030
5153
|
return pluginOperationalReportFeedSchema.parse({
|
|
5031
5154
|
source: "plugins",
|
|
5032
5155
|
generatedAt: new Date(nowMs).toISOString(),
|
|
@@ -5036,7 +5159,7 @@ async function readPluginOperationalReportFeed() {
|
|
|
5036
5159
|
|
|
5037
5160
|
// src/api.ts
|
|
5038
5161
|
function createJuniorApi() {
|
|
5039
|
-
const app = new
|
|
5162
|
+
const app = new Hono9();
|
|
5040
5163
|
app.get(
|
|
5041
5164
|
"/api/health",
|
|
5042
5165
|
async () => jsonResponse(healthReportSchema, readHealthReport())
|
|
@@ -5070,6 +5193,7 @@ function createJuniorApi() {
|
|
|
5070
5193
|
attachmentStorage: createVercelAttachmentStorage()
|
|
5071
5194
|
})
|
|
5072
5195
|
);
|
|
5196
|
+
app.route("/api/code", createCodeRoutes());
|
|
5073
5197
|
app.route("/api/personal-tokens", createPersonalTokenRoutes());
|
|
5074
5198
|
app.route("/api/people", createPeopleRoutes());
|
|
5075
5199
|
app.route("/api/locations", createLocationRoutes());
|