@sentry/junior 0.302.0 → 0.303.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/{adapter-context-Cx9fn9B3.js → adapter-context-BdVnSuY5.js} +2 -2
- package/dist/{admin-_poE5NKL.js → admin-AfeAdS3J.js} +2 -2
- package/dist/{agent-runner-CY9RvsTX.js → agent-runner-BP8_DLUv.js} +2987 -2948
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +6 -6
- package/dist/api.d.ts +13 -12
- package/dist/api.js +207 -80
- package/dist/{app-BpY3wtRP.d.ts → app-Dd9v1mNx.d.ts} +15 -15
- package/dist/app.d.ts +1 -1
- package/dist/app.js +63 -64
- package/dist/{automation-Cva5ZOwW.js → automation-D9MvhOWY.js} +3 -1
- package/dist/{background-compaction-queue-CXFq1_Cz.js → background-compaction-queue-xaE05jxH.js} +6 -6
- package/dist/{briefs-B3NG-pid.js → briefs-D8i-dKTp.js} +4 -4
- package/dist/{catalog-runtime-Dss0lSV6.js → catalog-runtime-d1EM6Z0V.js} +2 -2
- package/dist/cli/chat.d.ts +1 -1
- package/dist/cli/chat.js +21 -21
- package/dist/cli/check.js +8 -8
- package/dist/cli/env.d.ts +1 -0
- package/dist/cli/env.js +8 -7
- package/dist/cli/init.js +13 -4
- package/dist/cli/main.js +4 -4
- package/dist/cli/plugins.js +6 -6
- package/dist/cli/snapshot-create.js +7 -5
- package/dist/cli/upgrade.d.ts +2 -2
- package/dist/cli/upgrade.js +5 -5
- package/dist/{config-CzeZiMKs.js → config-oGM7KA9M.js} +44 -63
- package/dist/{connections-CDYhMfrs.js → connections-BlikzEJv.js} +6 -6
- package/dist/{continue-in-slack-7Uf05ndC.js → continue-in-slack-BZnYifiG.js} +5 -5
- package/dist/{conversation-BNXfq6Lb.js → conversation-CY1jnBiC.js} +1 -1
- package/dist/{conversation-feed-Clf_cv0n.js → conversation-feed-BZJRk6UV.js} +1 -1
- package/dist/{conversation-privacy-D9xnM5mK.js → conversation-privacy-Cx515ddM.js} +7 -7
- package/dist/{conversation-turn-D7SEZgTG.js → conversation-turn-DAhRdX4m.js} +20 -23
- package/dist/{credential-sync-DoD0gW-j.js → credential-sync-DfhmWFeo.js} +18 -18
- package/dist/{db-B-gtnNjr.js → db-C-2tFxk3.js} +15 -15
- package/dist/{db-BdsCzytP.d.ts → db-DPqcEM9_.d.ts} +25 -25
- package/dist/{executor-DZg20EqU.js → executor-NVfS8aQ2.js} +14 -8
- package/dist/{history-IjdmO_r6.js → history-UZ3M2M9r.js} +13 -10
- package/dist/{install-t1KQyTUs.js → install-CHLrpRZc.js} +3 -3
- package/dist/instrumentation.d.ts +4 -4
- package/dist/instrumentation.js +10 -10
- package/dist/{lineage-C79GjoQr.js → lineage-HGLhd_-N.js} +2 -2
- package/dist/{logging-C9oDAg4M.js → logging-DiyqRLBx.js} +19 -19
- package/dist/{message-BLUCzJXN.js → message-CkCOcbFH.js} +9 -9
- package/dist/{model-input-5jwNC45G.js → model-input-DmoPPtPE.js} +4 -9
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +7 -7
- package/dist/{oauth-callback-server-BBl66vCb.js → oauth-callback-server-CIf_6YmA.js} +5 -4
- package/dist/{oauth-relay-DRzq73b6.js → oauth-relay-DAmfVmJu.js} +3 -6
- package/dist/{package-discovery-DJhGdS4c.js → package-discovery-x4AvVhMj.js} +1 -1
- package/dist/{plugin-module-Cf5gVPWP.js → plugin-module-Cv2ETe8Y.js} +1 -1
- package/dist/{plugins-BBX07Jzt.js → plugins-Bkk0XRo2.js} +3 -3
- package/dist/{projection-CIBwgD3s.js → projection-DBq8tsA5.js} +221 -173
- package/dist/{prompt-CRQbzp5e.js → prompt-D2KlJopL.js} +4 -4
- package/dist/{queue-CZyYgPF0.d.ts → queue-CbEHUO0l.d.ts} +1 -1
- package/dist/{queue-DtCDaIct.js → queue-DFaOscp5.js} +4 -4
- package/dist/{registry-DdFQHZ_d.js → registry-Bu0Z9BEO.js} +37 -37
- package/dist/{resolve-CdW4BdrK.js → resolve-DXuA3G0g.js} +3 -3
- package/dist/{result-oOMv1t4O.js → result-DpiNseDA.js} +10 -15
- package/dist/rolldown-runtime-BKpuH2hG.js +26 -0
- package/dist/{runner-DqitLtm-.js → runner-iu1heRFv.js} +10 -10
- package/dist/{sandbox-egress-signals-Bw9I0yfJ.js → sandbox-egress-signals-2HFYDcQf.js} +1 -1
- package/dist/{schema-BIFM-U1a.d.ts → schema-DHMOaRzC.d.ts} +520 -13
- package/dist/{schema-DnVQepWP.js → schema-DvfX3Gq_.js} +77 -13
- package/dist/{secrets-DebYU866.js → secrets-DHaJ5TTn.js} +4 -4
- package/dist/{sentry-BRTJqumy.js → sentry-CPbZjomA.js} +3 -28
- package/dist/{sentry-route-name-BhwWnfqj.js → sentry-route-name-C6EIzAGP.js} +1 -1
- package/dist/{service-account-CrZftRTb.js → service-account-BcT5LR7V.js} +47 -47
- package/dist/{service-account-B6mKAPVo.js → service-account-xYkaQTrw.js} +3 -3
- package/dist/{session-stop-DW63Z3kj.js → session-stop-BLLp1IP_.js} +28 -35
- package/dist/{skills-C16fz60Z.js → skills-CNAGH4ju.js} +6 -9
- package/dist/{slack-conversation-unfurl-BHhefEb7.js → slack-conversation-unfurl-DYnqe5ci.js} +10 -15
- package/dist/{spawn-D_RnFYfy.js → spawn-cGasWW33.js} +7 -7
- package/dist/{legacy-web-actor-id-C-cEeWqL.js → state-CDS6h_Wv.js} +32 -32
- package/dist/{stop-7p1i08CY.js → stop-DMMA67yT.js} +221 -139
- package/dist/{store-C28I0CVW.js → store-Dgs7Oe44.js} +5 -5
- package/dist/{task-queue-BVUJbQ28.js → task-queue-DcF0nhhz.js} +3 -3
- package/dist/{task-runner-CWi8j7Z6.js → task-runner-BGXF7Fo7.js} +15 -18
- package/dist/{thread-context-D3-yYUd0.js → thread-context-BPky1KBe.js} +12 -12
- package/dist/{turn-session-routing-BFMS9ATF.js → turn-session-routing-DGvn9MSl.js} +32 -32
- package/dist/{turn-user-message-C3-O8Omt.js → turn-user-message-19CkuUvM.js} +3 -3
- package/dist/{validation-BSFKUIb4.js → validation-lu1DgjNQ.js} +2 -2
- package/dist/vercel.js +1 -1
- package/dist/{version-BHHXNi-0.js → version-Uo3c94Dx.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-B1SO21Qa.js → viewer-BPQHMx3-.js} +3 -3
- package/dist/{warmup-Bz9bzkzN.js → warmup-H8uLvW9e.js} +149 -130
- package/dist/{worker-BspReIIK.js → worker-B-pM_-3K.js} +9 -12
- package/migrations/0109_user_preferences.sql +1 -0
- package/migrations/0110_code_change_repository_state_index.sql +1 -0
- package/migrations/meta/0109_snapshot.json +4925 -0
- package/migrations/meta/0110_snapshot.json +4952 -0
- package/migrations/meta/_journal.json +15 -1
- package/package.json +16 -19
package/dist/api.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { h as
|
|
4
|
-
import { f as
|
|
5
|
-
import { G as
|
|
6
|
-
import { C as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { n as briefEntriesFromReportEvents, u as completeText } from "./prompt-
|
|
1
|
+
import { R as escapeXml, Z as getAttachmentStorage, n as botConfig } from "./config-oGM7KA9M.js";
|
|
2
|
+
import { G as createCache, J as getStateAdapter, O as conversationKindFromRow, _ as loadConversationSlackTenantIds, a as getConversationStore, ft as nextDetailVersion, o as getDb, s as getSqlExecutor, x as withConversationMutationLock } from "./db-C-2tFxk3.js";
|
|
3
|
+
import { Bt as listOwnedWatches, Dt as AttachmentUploadError, Jn as setConversationSubscription, Nt as readLiveAttachment, Tt as webActorFromUser, Vt as listChildAgents, Xn as jsonResponse, Yn as emptyResponse, Zn as throwApiError, _ as closeBreaker, _i as readViewerAutomationVersions, ai as activateViewerAutomationVersion, ci as changeViewerAutomationLifecycle, di as updateViewerAutomation, fi as ViewerTaskNotFoundError, ft as reportConversationRead, g as breakerStates, gi as readViewerAutomationSummary, h as savingsTotals, hi as readViewerAutomationRuns, ji as countOwnedAutomationsNeedingAttention, jt as writeAttachmentUpload, kt as createAttachmentUpload, li as deleteViewerTask, lt as archiveConversation, mi as readViewerAutomationExecutions, u as SAVINGS_NAMESPACE, ui as readViewerAutomationEdit, v as connectedState, vi as readViewerAutomations, w as readStats, wi as AutomationEditError, yt as acceptsWebMessages } from "./warmup-H8uLvW9e.js";
|
|
4
|
+
import { C as createConversationBodySchema, E as forkConversationResponseSchema, F as renameConversationBodySchema, G as MAX_ATTACHMENT_BYTES, I as renameConversationResponseSchema, L as conversationReadPositionSchema, T as forkConversationBodySchema, f as conversationEventPageSchema, h as conversationParamsSchema, l as conversationDetailQuerySchema, m as conversationFeedQuerySchema, n as CONVERSATION_VERSION_HEADER, o as conversationAttachmentParamsSchema, p as conversationEventsQuerySchema, r as acceptedConversationMessageSchema, s as conversationAttachmentQuerySchema, t as CONVERSATION_DETAIL_VERSION_HEADER, u as conversationDetailReportSchema, w as createConversationMessageBodySchema } from "./conversation-CY1jnBiC.js";
|
|
5
|
+
import { $ as testNotificationResponseSchema, A as startServiceAccountSignInResponseSchema, At as conversationOutlineSchema, B as personParamsSchema, Bt as pinConversationResponseSchema, C as cacheWarmingSavingsRefillResponseSchema, Ct as attachObjectLinkBodySchema, D as serviceAccountListSchema, Dt as stopConversationTurnResponseSchema, E as disconnectServiceAccountResponseSchema, Et as objectLinksReportSchema, F as personalTokenParamsSchema, Ft as conversationSubscriptionBodySchema, G as locationParamsSchema, Gt as attachmentUploadParamsSchema, Ht as reorderPinnedConversationsResponseSchema, I as revokePersonalTokenResponseSchema, It as conversationSubscriptionResponseSchema, J as activitySixHours$1, K as activityDays$1, Kt as attachmentUploadSchema, L as actorDirectoryReportSchema, Lt as conversationDeliveryBodySchema, M as createdPersonalTokenSchema, Mt as archiveConversationResponseSchema, N as personalTokenListSchema, Nt as archiveDoneConversationsResponseSchema, O as serviceAccountParamsSchema, Ot as conversationStatsReportSchema, Pt as conversationAutoArchiveSchema, Q as pushSubscriptionDeleteBodySchema, R as actorProfileReportSchema, Rt as conversationDeliveryResponseSchema, S as cacheWarmingSavingsQuerySchema, T as closeCacheWarmingBreakerResponseSchema, Tt as objectLinksQuerySchema, U as locationDetailReportSchema, Ut as conversationCatchUpBodySchema, V as personalSpendReportSchema, Vt as reorderPinnedConversationsBodySchema, W as locationDirectoryReportSchema, Wt as conversationCatchUpSchema, X as notificationSettingsSchema, Z as pushSubscriptionBodySchema, _ as reviewItemParamsSchema, _t as conversationWatchesReportSchema, b as cacheWarmingBreakerListSchema, bt as continueConversationInSlackBodySchema, c as workspaceListSchema, d as workspaceSchema, dt as codeRepositoryParamsSchema, et as connectionListSchema, f as reviewItemActionSchema, ft as codeRepositoryQuerySchema, g as reviewItemListSchema, h as reviewItemListQuerySchema, ht as personCodeQuerySchema, i as statsReportSchema, it as startConnectionResponseSchema, j as createPersonalTokenBodySchema, jt as archiveConversationBodySchema, l as workspaceParamsSchema, lt as codeOverviewReportSchema, m as reviewItemCountSchema, n as versionsSchema, o as deleteWorkspaceResponseSchema, p as reviewItemCountQuerySchema, pt as codeRepositoryReportSchema, q as activityHours$1, qt as createAttachmentUploadBodySchema, rt as disconnectConnectionResponseSchema, s as workspaceBodySchema, t as versionsQuerySchema, tt as connectionParamsSchema, ut as codePersonReportSchema, v as reviewItemSchema, w as cacheWarmingSavingsReportSchema, wt as attachObjectLinkResponseSchema, x as cacheWarmingBreakerParamsSchema, xt as continueConversationInSlackResponseSchema, y as reviewItemWaitingConversationsSchema, yt as conversationChildAgentsReportSchema, z as avatarParamsSchema, zt as pinConversationBodySchema } from "./schema-DvfX3Gq_.js";
|
|
6
|
+
import { C as skillReportsSchema, a as conversationDetailWithMailboxReportSchema, b as runtimeInfoReportSchema, d as steerConversationPendingMessagesBodySchema, f as steerConversationPendingMessagesResponseSchema, i as cancelConversationPendingMessagesResponseSchema, l as conversationPendingMessagesReportSchema, m as pluginOperationalReportFeedSchema, n as conversationFeedSchema, p as healthReportSchema, r as cancelConversationPendingMessagesBodySchema, u as conversationUnchangedDetailWithMailboxSchema, x as skillDetailReportSchema, y as pluginsSchema } from "./conversation-feed-BZJRk6UV.js";
|
|
7
|
+
import { J as isExperimentalFeatureEnabled, X as getEventCatalog, _ as readUserCustomization, v as saveUserCustomization, y as addConversationNote } from "./session-stop-BLLp1IP_.js";
|
|
8
|
+
import { $a as SANDBOX_RUNTIME, $r as reviewItemReaderForUser, Ar as countOpenReviewItemsForUser, Co as readConversationAccessFromSql, Cr as saveNotificationSchedule, Cs as createPluginCache, Gi as deleteWorkspace, Go as readSlackAttachmentSource, Ii as getDashboardSettingsLink, Ji as listWorkspaces, Jr as itemNeedsUser, Ki as getWorkspace, Lr as listWaitingConversations, No as readConversationEventPage, Rr as reviewItemsNeedingUserVersionQuery, So as createConversationAccessReader, Sr as readNotificationSchedule, Tr as isPausedBySlack, Ur as canActOnReviewItem, V as createPluginEgress, Wi as createWorkspace, Xi as updateWorkspace, Yi as listWorkspacesByRepository, Zi as WorkspaceValidationError, Zn as createUserTokenStore, _r as readWebPushConfig, br as deletePushSubscription, ei as reviewItemReaderForUserInConversation, hs as listConversationAnnotations, jo as readConversationBriefThrough, jr as countReviewItemsNeedingUserBySubject, ms as createPluginAnnotations, na as create, qr as isOnlyAssignee, ra as hash, to as workspaceRepoCheckoutPath, ur as getPlugins, vr as sendPushNotificationToUser, wr as savePushSubscription, xr as listPushSubscriptions, yo as createPluginLogger, yr as resolveNotificationTimezone, zr as searchReviewItems } from "./projection-DBq8tsA5.js";
|
|
9
|
+
import { $ as readObjectLinkTypes, A as isAllowedSignInEmail, D as resolveMentions, Dt as IMAGE_WIDTHS, E as requireConversationPendingMessages, Et as createViewerMcp, F as actOnReviewItem, G as readSavingsRefill, H as DEFAULT_USER_SETTINGS, L as readReviewItemForUser, Ot as decodeImageId, P as ReviewItemActionError, Q as readLinkObjectType, Tt as readFirstHumanMessageTexts, U as readUserSettings, V as setConversationAutoArchive, W as updateUserSettings, X as readHealthReport, Z as OBJECT_LINK_TTL_MS, _ as readConversationEvents, a as decodePageCursor, b as createConversationForViewer, c as reorderPinnedConversations, d as childAgentTotalsReport, et as resolveObjectLinkNow, f as readConversationTreeMetricsFromSql, g as keepQuickQuestionForViewer, h as forkConversationForViewer, i as readConversationFeed, l as readConversationDetail, m as readConversationDetailEtag, n as steerConversationPendingMessagesForViewer, nt as guardedFetch, o as encodePageCursor, p as conversationVersionQuery, q as startSavingsRefill, r as conversationFeedVersionQuery, s as pinConversation, st as getProductionSlackAdapter, t as stopConversationTurnForViewer, tt as resolveObjectLinks, u as readConversationAuxiliaryCostsFromSql, w as cancelConversationPendingMessagesForViewer, wt as conversationSummaryFromStoredConversation, x as requireWebMessageConversation, y as appendConversationMessageForViewer, z as archiveViewerDoneConversations } from "./stop-DMMA67yT.js";
|
|
10
|
+
import { n as briefEntriesFromReportEvents, u as completeText } from "./prompt-D2KlJopL.js";
|
|
11
|
+
import { a as resumeConversationDelivery, i as pauseConversationDelivery, r as canPauseConversationDelivery } from "./conversation-turn-DAhRdX4m.js";
|
|
11
12
|
import { r as notificationScheduleSchema } from "./schedule-cP0AACm1.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { F as compileScheduleIntent, P as ScheduleIntentError, U as automationTaskText, _ as automationSummarySchema, b as automationVersionListSchema, c as automationLifecycleSchema, d as automationParamsSchema, f as automationRunListSchema, g as automationSchedulePreviewSchema, h as automationScheduleIntentSchema, i as automationExecutionListSchema, l as automationListQuerySchema, n as automationEditSchema, r as automationEventCatalogSchema, t as automationEditErrorSchema, u as automationListSchema, v as automationUpdateSchema, x as automationVersionParamsSchema, y as automationVersionActivateSchema } from "./automation-Cva5ZOwW.js";
|
|
17
|
-
import { F as readAutomationTitlesByConversationId, L as conversationAggregateColumns, R as conversationRangeColumns, _t as automationEventCatalog, pt as AutomationConflictError, z as conversationUsageCostExpr } from "./turn-session-routing-BFMS9ATF.js";
|
|
13
|
+
import { C as juniorConversationMetrics, E as juniorApiTokens, F as juniorDestinations, M as juniorConversations, N as juniorIdentities, O as juniorCodeChanges, P as juniorUsers, T as juniorConversationEvents, k as juniorCodeRepositories, x as juniorConversationBriefs } from "./executor-NVfS8aQ2.js";
|
|
14
|
+
import { t as runWithSlackInstallation } from "./adapter-context-BdVnSuY5.js";
|
|
15
|
+
import { i as continueConversationInSlack, r as canContinueInSlack, t as BUSY } from "./continue-in-slack-BZnYifiG.js";
|
|
16
|
+
import { f as parseSlackTeamId, u as parseSlackChannelId } from "./actor-D2iXzvlN.js";
|
|
18
17
|
import { A as fillUtcSixHours, D as HOUR_MS$1, E as DAY_MS$2, F as trailingUtcSixHourWindow, I as utcDayKey, L as utcHourKey, M as sumUtcHoursIntoSixHours, N as trailingUtcDayWindow, O as fillUtcDays, P as trailingUtcHourWindow, T as apiErrorSchema, _ as userCustomizationSchema, f as INLINE_VIDEO_TYPES, j as startOfUtcHour, k as fillUtcHours, m as detectImageMediaType, p as INPUT_IMAGE_TYPES } from "./web-message-id-lNodcCOI.js";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { t as
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
18
|
+
import { O as previewOriginBelongsTo, d as AttachmentDownloadError, f as readAttachmentContent, y as createSlackReviewItemShow } from "./agent-runner-BP8_DLUv.js";
|
|
19
|
+
import { F as readAutomationTitlesByConversationId, L as conversationAggregateColumns, R as conversationRangeColumns, _t as automationEventCatalog, pt as AutomationConflictError, z as conversationUsageCostExpr } from "./turn-session-routing-DGvn9MSl.js";
|
|
20
|
+
import { a as startConnection, n as isConnectableProvider, r as listConnections, s as htmlCallbackResponse, t as disconnectConnection } from "./connections-BlikzEJv.js";
|
|
21
|
+
import { h as logWarn, m as logInfo, p as logException } from "./logging-DiyqRLBx.js";
|
|
22
|
+
import { f as credentialContextForActor } from "./registry-Bu0Z9BEO.js";
|
|
23
|
+
import { c as readViewerAvatarUrl, d as updateViewerDisplayName, l as resolveViewerUser, m as readAvatarFetch, t as findUserByEmail } from "./viewer-BPQHMx3-.js";
|
|
24
|
+
import { n as finishServiceAccountSignIn, o as serviceAccountPlugins, r as getServiceAccountStatus, s as startServiceAccountSignIn, t as disconnectServiceAccount } from "./service-account-BcT5LR7V.js";
|
|
25
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-d1EM6Z0V.js";
|
|
26
|
+
import { F as compileScheduleIntent, P as ScheduleIntentError, U as automationTaskText, _ as automationSummarySchema, b as automationVersionListSchema, c as automationLifecycleSchema, d as automationParamsSchema, f as automationRunListSchema, g as automationSchedulePreviewSchema, h as automationScheduleIntentSchema, i as automationExecutionListSchema, l as automationListQuerySchema, n as automationEditSchema, r as automationEventCatalogSchema, t as automationEditErrorSchema, u as automationListSchema, v as automationUpdateSchema, x as automationVersionParamsSchema, y as automationVersionActivateSchema } from "./automation-D9MvhOWY.js";
|
|
27
|
+
import { o as getSandboxResources } from "./install-CHLrpRZc.js";
|
|
28
|
+
import { t as getCachedSnapshot } from "./resolve-DXuA3G0g.js";
|
|
29
|
+
import { o as getVercelConversationWorkQueue } from "./background-compaction-queue-xaE05jxH.js";
|
|
30
30
|
import { Hono } from "hono";
|
|
31
31
|
import * as z from "zod";
|
|
32
32
|
import path from "node:path";
|
|
33
33
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
34
|
-
import { and, asc, countDistinct, desc, eq, gt, gte, inArray, isNull, lte, notExists, or, sql } from "drizzle-orm";
|
|
34
|
+
import { and, asc, countDistinct, desc, eq, gt, gte, inArray, isNull, lt, lte, ne, notExists, or, sql } from "drizzle-orm";
|
|
35
35
|
import { objectPresentation, pluginUserPageContentSchema, pluginUserPageCursorSchema, pluginUserPageFilterSchema, pluginUserPageLinksSchema, pluginUserPageQuerySchema } from "@sentry/junior-plugin-api";
|
|
36
36
|
import { alias } from "drizzle-orm/pg-core";
|
|
37
37
|
import fs from "node:fs/promises";
|
|
@@ -398,7 +398,7 @@ function parseRangeHeader(header, size) {
|
|
|
398
398
|
};
|
|
399
399
|
}
|
|
400
400
|
const start = Number(first);
|
|
401
|
-
const end = last ? Number(last) :
|
|
401
|
+
const end = last ? Number(last) : 1e400;
|
|
402
402
|
if (end < start) return void 0;
|
|
403
403
|
if (start >= size) return "unsatisfiable";
|
|
404
404
|
return {
|
|
@@ -1322,8 +1322,9 @@ function createConversationRoutes(options) {
|
|
|
1322
1322
|
const DAY_MS$1 = 864e5;
|
|
1323
1323
|
const WINDOW_DAYS = 30;
|
|
1324
1324
|
/**
|
|
1325
|
-
* Code changes
|
|
1326
|
-
*
|
|
1325
|
+
* Code changes on one page of a person's code overview. Open changes sort
|
|
1326
|
+
* first, so the first page has the open changes before completed ones, and
|
|
1327
|
+
* `nextCursor` reads the rest.
|
|
1327
1328
|
*/
|
|
1328
1329
|
const PERSON_CHANGE_LIMIT = 100;
|
|
1329
1330
|
function startOfUtcDay(timestampMs) {
|
|
@@ -1395,21 +1396,28 @@ async function readTreeCosts(conversationIds) {
|
|
|
1395
1396
|
return total;
|
|
1396
1397
|
};
|
|
1397
1398
|
}
|
|
1398
|
-
/**
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1399
|
+
/**
|
|
1400
|
+
* True when any linked conversation actor belongs to the subject user. The
|
|
1401
|
+
* subquery starts from the user's Conversations, so Postgres hash-joins them
|
|
1402
|
+
* with the linked ids instead of one lookup per code change.
|
|
1403
|
+
*/
|
|
1404
|
+
function ownedByUserSql(userId) {
|
|
1405
|
+
return sql`${juniorCodeChanges.id} IN (
|
|
1406
|
+
SELECT linked.id
|
|
1407
|
+
FROM junior_identities AS identities
|
|
1403
1408
|
INNER JOIN junior_conversations AS conversations
|
|
1404
|
-
ON conversations.
|
|
1405
|
-
INNER JOIN
|
|
1406
|
-
|
|
1409
|
+
ON conversations.actor_identity_id = identities.id
|
|
1410
|
+
INNER JOIN (
|
|
1411
|
+
SELECT id, unnest(conversation_ids) AS conversation_id
|
|
1412
|
+
FROM junior_code_changes
|
|
1413
|
+
) AS linked
|
|
1414
|
+
ON linked.conversation_id = conversations.conversation_id
|
|
1407
1415
|
WHERE identities.user_id = ${userId}
|
|
1408
1416
|
)`;
|
|
1409
1417
|
}
|
|
1410
1418
|
/** Limit code changes to one person's conversations or one repository. */
|
|
1411
1419
|
function changeScopeFilter(args) {
|
|
1412
|
-
return and(args.userId ? ownedByUserSql(
|
|
1420
|
+
return and(args.userId ? ownedByUserSql(args.userId) : void 0, args.repositoryId ? eq(juniorCodeChanges.repositoryId, args.repositoryId) : void 0);
|
|
1413
1421
|
}
|
|
1414
1422
|
/** Read windowed code summary and activity buckets for an optional scope. */
|
|
1415
1423
|
async function readCodeWindows(args) {
|
|
@@ -1424,6 +1432,7 @@ async function readCodeWindows(args) {
|
|
|
1424
1432
|
const rows = await db.select({
|
|
1425
1433
|
closedAt: changes.closedAt,
|
|
1426
1434
|
conversationIds: changes.conversationIds,
|
|
1435
|
+
lastActivityAt: changes.lastActivityAt,
|
|
1427
1436
|
mergedAt: changes.mergedAt,
|
|
1428
1437
|
openedAt: changes.openedAt,
|
|
1429
1438
|
state: changes.state
|
|
@@ -1445,6 +1454,7 @@ async function readCodeWindows(args) {
|
|
|
1445
1454
|
closed: closed.length,
|
|
1446
1455
|
costUsd: treeCost(createdConversationIds),
|
|
1447
1456
|
created: created.length,
|
|
1457
|
+
idle: rows.filter((row) => row.state === "open" && Math.floor((args.nowMs - (row.lastActivityAt ?? row.openedAt).getTime()) / DAY_MS$1) > 7).length,
|
|
1448
1458
|
medianCostUsd: median(changeCosts.filter((cost) => cost > 0)),
|
|
1449
1459
|
medianMergeTimeMs: median(merged.flatMap((row) => row.state === "merged" && row.mergedAt ? [row.mergedAt.getTime() - row.openedAt.getTime()] : [])),
|
|
1450
1460
|
merged: merged.length,
|
|
@@ -1554,22 +1564,51 @@ async function readCodeOverview(nowMs = Date.now()) {
|
|
|
1554
1564
|
});
|
|
1555
1565
|
}
|
|
1556
1566
|
/**
|
|
1567
|
+
* Position after the last change of a page of a person's code overview.
|
|
1568
|
+
* `idleSince` is set only when that change was open. Code change times are
|
|
1569
|
+
* written from JavaScript dates, so milliseconds keep the order exact.
|
|
1570
|
+
*/
|
|
1571
|
+
const personCodeCursorSchema = z.object({
|
|
1572
|
+
id: z.guid(),
|
|
1573
|
+
idleSince: z.iso.datetime().optional(),
|
|
1574
|
+
updatedAt: z.iso.datetime()
|
|
1575
|
+
}).strict();
|
|
1576
|
+
const idleSince = sql`coalesce(${juniorCodeChanges.lastActivityAt}, ${juniorCodeChanges.openedAt})`;
|
|
1577
|
+
function afterPersonCodeCursor(cursor) {
|
|
1578
|
+
const updatedAt = new Date(cursor.updatedAt);
|
|
1579
|
+
const laterInGroup = or(lt(juniorCodeChanges.updatedAt, updatedAt), and(eq(juniorCodeChanges.updatedAt, updatedAt), gt(juniorCodeChanges.id, cursor.id)));
|
|
1580
|
+
const completed = ne(juniorCodeChanges.state, "open");
|
|
1581
|
+
if (cursor.idleSince === void 0) return and(completed, laterInGroup);
|
|
1582
|
+
const since = sql`${cursor.idleSince}::timestamptz`;
|
|
1583
|
+
return or(completed, sql`${idleSince} > ${since}`, and(sql`${idleSince} = ${since}`, laterInGroup));
|
|
1584
|
+
}
|
|
1585
|
+
/**
|
|
1557
1586
|
* Read person-scoped code activity and recent code changes linked through
|
|
1558
1587
|
* conversation actors on Junior-owned code changes.
|
|
1559
1588
|
*/
|
|
1560
1589
|
async function readPersonCodeOverview(args) {
|
|
1561
1590
|
const nowMs = args.nowMs ?? Date.now();
|
|
1591
|
+
const after = args.cursor ? decodePageCursor(personCodeCursorSchema, args.cursor, "Invalid code change cursor.") : void 0;
|
|
1562
1592
|
const db = getDb();
|
|
1563
1593
|
const [windows, changes] = await Promise.all([readCodeWindows({
|
|
1564
1594
|
nowMs,
|
|
1565
1595
|
userId: args.userId
|
|
1566
|
-
}), db.select(
|
|
1596
|
+
}), db.select({
|
|
1597
|
+
change: codeChangeReportColumns,
|
|
1598
|
+
updatedAt: juniorCodeChanges.updatedAt
|
|
1599
|
+
}).from(juniorCodeChanges).innerJoin(juniorCodeRepositories, eq(juniorCodeChanges.repositoryId, juniorCodeRepositories.id)).where(and(changeScopeFilter({ userId: args.userId }), after ? afterPersonCodeCursor(after) : void 0)).orderBy(desc(sql`${juniorCodeChanges.state} = 'open'`), asc(sql`CASE WHEN ${juniorCodeChanges.state} = 'open' THEN ${idleSince} END`), desc(juniorCodeChanges.updatedAt), asc(juniorCodeChanges.id)).limit(PERSON_CHANGE_LIMIT)]);
|
|
1600
|
+
const last = changes.at(-1);
|
|
1567
1601
|
return codePersonReportSchema.parse({
|
|
1568
1602
|
activityDays: windows.activityDays,
|
|
1569
1603
|
activityHours: windows.activityHours,
|
|
1570
1604
|
activitySixHours: windows.activitySixHours,
|
|
1571
|
-
changes: changes.map(codeChangeReport),
|
|
1605
|
+
changes: changes.map((row) => codeChangeReport(row.change)),
|
|
1572
1606
|
generatedAt: windows.windowEnd.toISOString(),
|
|
1607
|
+
nextCursor: last && changes.length === PERSON_CHANGE_LIMIT ? encodePageCursor(personCodeCursorSchema, {
|
|
1608
|
+
id: last.change.id,
|
|
1609
|
+
...last.change.state === "open" ? { idleSince: (last.change.lastActivityAt ?? last.change.openedAt).toISOString() } : void 0,
|
|
1610
|
+
updatedAt: last.updatedAt.toISOString()
|
|
1611
|
+
}) : void 0,
|
|
1573
1612
|
summary: windows.summary,
|
|
1574
1613
|
windowEnd: windows.windowEnd.toISOString(),
|
|
1575
1614
|
windowStart: windows.windowStart.toISOString()
|
|
@@ -1578,25 +1617,35 @@ async function readPersonCodeOverview(args) {
|
|
|
1578
1617
|
// src/api/code/repository.ts
|
|
1579
1618
|
/** Most recent code changes listed on one repository page. */
|
|
1580
1619
|
const REPOSITORY_CHANGE_LIMIT = 100;
|
|
1620
|
+
function countState(state) {
|
|
1621
|
+
return sql`count(*) filter (where ${juniorCodeChanges.state} = ${state})`.mapWith(Number);
|
|
1622
|
+
}
|
|
1581
1623
|
/**
|
|
1582
1624
|
* Read code activity for one repository: windowed summary, activity buckets,
|
|
1583
|
-
* recent code changes, and the Workspaces that
|
|
1625
|
+
* recent code changes, change counts by state, and the Workspaces that
|
|
1626
|
+
* include it. `state` limits the listed changes; the counts cover every
|
|
1627
|
+
* change.
|
|
1584
1628
|
*/
|
|
1585
|
-
async function readCodeRepository(repositoryId,
|
|
1629
|
+
async function readCodeRepository(repositoryId, options = {}) {
|
|
1630
|
+
const nowMs = options.nowMs ?? Date.now();
|
|
1586
1631
|
const db = getDb();
|
|
1587
|
-
const [
|
|
1632
|
+
const [row] = await db.select({
|
|
1633
|
+
closed: countState("closed"),
|
|
1588
1634
|
id: juniorCodeRepositories.id,
|
|
1635
|
+
merged: countState("merged"),
|
|
1589
1636
|
name: juniorCodeRepositories.name,
|
|
1637
|
+
open: countState("open"),
|
|
1590
1638
|
provider: juniorCodeRepositories.provider,
|
|
1591
1639
|
url: juniorCodeRepositories.url
|
|
1592
|
-
}).from(juniorCodeRepositories).where(eq(juniorCodeRepositories.id, repositoryId)).
|
|
1593
|
-
if (!
|
|
1640
|
+
}).from(juniorCodeRepositories).leftJoin(juniorCodeChanges, eq(juniorCodeChanges.repositoryId, juniorCodeRepositories.id)).where(eq(juniorCodeRepositories.id, repositoryId)).groupBy(juniorCodeRepositories.id);
|
|
1641
|
+
if (!row) return void 0;
|
|
1642
|
+
const { closed, merged, open, ...repository } = row;
|
|
1594
1643
|
const [windows, changes, workspaces] = await Promise.all([
|
|
1595
1644
|
readCodeWindows({
|
|
1596
1645
|
nowMs,
|
|
1597
1646
|
repositoryId
|
|
1598
1647
|
}),
|
|
1599
|
-
db.select(codeChangeReportColumns).from(juniorCodeChanges).innerJoin(juniorCodeRepositories, eq(juniorCodeChanges.repositoryId, juniorCodeRepositories.id)).where(eq(juniorCodeChanges.repositoryId, repositoryId)).orderBy(desc(juniorCodeChanges.updatedAt)).limit(REPOSITORY_CHANGE_LIMIT),
|
|
1648
|
+
db.select(codeChangeReportColumns).from(juniorCodeChanges).innerJoin(juniorCodeRepositories, eq(juniorCodeChanges.repositoryId, juniorCodeRepositories.id)).where(and(eq(juniorCodeChanges.repositoryId, repositoryId), options.state ? eq(juniorCodeChanges.state, options.state) : void 0)).orderBy(desc(juniorCodeChanges.updatedAt)).limit(REPOSITORY_CHANGE_LIMIT),
|
|
1600
1649
|
listWorkspacesByRepository(db, {
|
|
1601
1650
|
provider: repository.provider,
|
|
1602
1651
|
repo: repository.name
|
|
@@ -1606,6 +1655,11 @@ async function readCodeRepository(repositoryId, nowMs = Date.now()) {
|
|
|
1606
1655
|
activityDays: windows.activityDays,
|
|
1607
1656
|
activityHours: windows.activityHours,
|
|
1608
1657
|
activitySixHours: windows.activitySixHours,
|
|
1658
|
+
changeCounts: {
|
|
1659
|
+
closed,
|
|
1660
|
+
merged,
|
|
1661
|
+
open
|
|
1662
|
+
},
|
|
1609
1663
|
changes: changes.map(codeChangeReport),
|
|
1610
1664
|
generatedAt: windows.windowEnd.toISOString(),
|
|
1611
1665
|
repository: {
|
|
@@ -1623,9 +1677,10 @@ async function readCodeRepository(repositoryId, nowMs = Date.now()) {
|
|
|
1623
1677
|
function createCodeRoutes() {
|
|
1624
1678
|
const app = new Hono();
|
|
1625
1679
|
app.get("/", async () => jsonResponse(codeOverviewReportSchema, await readCodeOverview()));
|
|
1626
|
-
app.get("/repositories/:repositoryId", validateRequest("param", codeRepositoryParamsSchema, "Invalid route parameters."), async (context) => {
|
|
1680
|
+
app.get("/repositories/:repositoryId", validateRequest("param", codeRepositoryParamsSchema, "Invalid route parameters."), validateRequest("query", codeRepositoryQuerySchema, "Invalid query parameters."), async (context) => {
|
|
1627
1681
|
const { repositoryId } = context.req.valid("param");
|
|
1628
|
-
const
|
|
1682
|
+
const { state } = context.req.valid("query");
|
|
1683
|
+
const report = await readCodeRepository(repositoryId, { state });
|
|
1629
1684
|
if (!report) throwApiError(404, "Repository not found.");
|
|
1630
1685
|
return jsonResponse(codeRepositoryReportSchema, report);
|
|
1631
1686
|
});
|
|
@@ -2309,7 +2364,7 @@ function createImageRoutes() {
|
|
|
2309
2364
|
}
|
|
2310
2365
|
// src/api/people/code.ts
|
|
2311
2366
|
/** Read person-scoped native code activity for one People profile. */
|
|
2312
|
-
async function readPeopleCode(email) {
|
|
2367
|
+
async function readPeopleCode(email, cursor) {
|
|
2313
2368
|
const subject = await findUserByEmail(email);
|
|
2314
2369
|
if (!subject) {
|
|
2315
2370
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -2320,6 +2375,7 @@ async function readPeopleCode(email) {
|
|
|
2320
2375
|
summary: {
|
|
2321
2376
|
closed: 0,
|
|
2322
2377
|
created: 0,
|
|
2378
|
+
idle: 0,
|
|
2323
2379
|
merged: 0,
|
|
2324
2380
|
open: 0
|
|
2325
2381
|
},
|
|
@@ -2327,7 +2383,10 @@ async function readPeopleCode(email) {
|
|
|
2327
2383
|
windowStart: (/* @__PURE__ */ new Date(now.getTime() - 2592e6)).toISOString()
|
|
2328
2384
|
});
|
|
2329
2385
|
}
|
|
2330
|
-
return await readPersonCodeOverview({
|
|
2386
|
+
return await readPersonCodeOverview({
|
|
2387
|
+
cursor,
|
|
2388
|
+
userId: subject.id
|
|
2389
|
+
});
|
|
2331
2390
|
}
|
|
2332
2391
|
function turnMetricSum(metric) {
|
|
2333
2392
|
return sql`SUM(${juniorConversationMetrics.value}) FILTER (
|
|
@@ -2739,7 +2798,7 @@ async function readPeoplePluginReports(args) {
|
|
|
2739
2798
|
reports: [],
|
|
2740
2799
|
source: "plugins"
|
|
2741
2800
|
});
|
|
2742
|
-
const { getPluginProfileReports } = await import("./projection-
|
|
2801
|
+
const { getPluginProfileReports } = await import("./projection-DBq8tsA5.js").then((n) => n.er);
|
|
2743
2802
|
return pluginOperationalReportFeedSchema.parse({
|
|
2744
2803
|
generatedAt: new Date(nowMs).toISOString(),
|
|
2745
2804
|
reports: await getPluginProfileReports({
|
|
@@ -3014,9 +3073,10 @@ function createPeopleRoutes() {
|
|
|
3014
3073
|
viewer
|
|
3015
3074
|
}));
|
|
3016
3075
|
});
|
|
3017
|
-
app.get("/:email/code", validateRequest("param", personParamsSchema, "Invalid route parameters."), async (context) => {
|
|
3076
|
+
app.get("/:email/code", validateRequest("param", personParamsSchema, "Invalid route parameters."), validateRequest("query", personCodeQuerySchema, "Invalid code query."), async (context) => {
|
|
3018
3077
|
const { email } = context.req.valid("param");
|
|
3019
|
-
|
|
3078
|
+
const { cursor } = context.req.valid("query");
|
|
3079
|
+
return jsonResponse(codePersonReportSchema, await readPeopleCode(email, cursor));
|
|
3020
3080
|
});
|
|
3021
3081
|
app.get("/:email", validateRequest("param", personParamsSchema, "Invalid route parameters."), async (context) => {
|
|
3022
3082
|
const { email } = context.req.valid("param");
|
|
@@ -3125,7 +3185,7 @@ function createPersonalTokenRoutes() {
|
|
|
3125
3185
|
* provider sends the Admin back to the dashboard session that started it.
|
|
3126
3186
|
*/
|
|
3127
3187
|
function callbackUrl(request, provider) {
|
|
3128
|
-
const base = process.env
|
|
3188
|
+
const base = process.env["JUNIOR_BASE_URL"]?.trim() || new URL(request.url).origin;
|
|
3129
3189
|
return new URL(`api/service-accounts/${encodeURIComponent(provider)}/callback`, base.endsWith("/") ? base : `${base}/`).toString();
|
|
3130
3190
|
}
|
|
3131
3191
|
function requirePlugin(provider) {
|
|
@@ -3513,20 +3573,26 @@ function createUserCustomizationRoutes() {
|
|
|
3513
3573
|
// src/api/review-items/routes.ts
|
|
3514
3574
|
const ARCHIVED_LIMIT = 50;
|
|
3515
3575
|
const cursorSchema = z.object({
|
|
3576
|
+
closedAtMs: z.number().int().optional(),
|
|
3516
3577
|
conversationId: z.string().min(1).optional(),
|
|
3517
3578
|
createdAtMs: z.number().int(),
|
|
3518
3579
|
forUserId: z.string().min(1).optional(),
|
|
3519
3580
|
id: z.string().min(1),
|
|
3581
|
+
needsUser: z.boolean().optional(),
|
|
3520
3582
|
query: z.string().min(1).optional(),
|
|
3583
|
+
sort: z.literal("waiting").optional(),
|
|
3584
|
+
status: z.string().min(1).optional(),
|
|
3521
3585
|
version: z.literal(2)
|
|
3522
3586
|
}).strict();
|
|
3523
3587
|
/**
|
|
3524
|
-
* Encode the last
|
|
3588
|
+
* Encode the last item of a page as the cursor of the next page. The
|
|
3525
3589
|
* cursor names its list, so it cannot page through a different list.
|
|
3526
3590
|
*/
|
|
3527
|
-
function encodeCursor(item, filters) {
|
|
3591
|
+
function encodeCursor(item, filters, viewer) {
|
|
3528
3592
|
return Buffer.from(JSON.stringify({
|
|
3529
3593
|
...filters,
|
|
3594
|
+
...filters.status && item.closedAt ? { closedAtMs: item.closedAt.getTime() } : void 0,
|
|
3595
|
+
...filters.sort ? { needsUser: itemNeedsUser(item, viewer.id) } : void 0,
|
|
3530
3596
|
createdAtMs: item.createdAt.getTime(),
|
|
3531
3597
|
id: item.id,
|
|
3532
3598
|
version: 2
|
|
@@ -3536,10 +3602,12 @@ function encodeCursor(item, filters) {
|
|
|
3536
3602
|
function decodeCursor(cursor, filters) {
|
|
3537
3603
|
try {
|
|
3538
3604
|
const parsed = cursorSchema.parse(JSON.parse(Buffer.from(cursor, "base64url").toString("utf8")));
|
|
3539
|
-
if (parsed.conversationId !== filters.conversationId || parsed.forUserId !== filters.forUserId || parsed.query !== filters.query) return;
|
|
3605
|
+
if (parsed.conversationId !== filters.conversationId || parsed.forUserId !== filters.forUserId || parsed.query !== filters.query || parsed.sort !== filters.sort || parsed.status !== filters.status || filters.status !== void 0 && parsed.closedAtMs === void 0 || filters.sort !== void 0 && parsed.needsUser === void 0) return;
|
|
3540
3606
|
return {
|
|
3607
|
+
...parsed.closedAtMs !== void 0 ? { closedAt: new Date(parsed.closedAtMs) } : void 0,
|
|
3541
3608
|
createdAt: new Date(parsed.createdAtMs),
|
|
3542
|
-
id: parsed.id
|
|
3609
|
+
id: parsed.id,
|
|
3610
|
+
...parsed.needsUser !== void 0 ? { needsUser: parsed.needsUser } : void 0
|
|
3543
3611
|
};
|
|
3544
3612
|
} catch {
|
|
3545
3613
|
return;
|
|
@@ -3551,6 +3619,13 @@ const ERROR_STATUS = {
|
|
|
3551
3619
|
invalid: 400,
|
|
3552
3620
|
not_found: 404
|
|
3553
3621
|
};
|
|
3622
|
+
function subjectPayload(subject) {
|
|
3623
|
+
const objectType = subject.url && readLinkObjectType(subject.url);
|
|
3624
|
+
return {
|
|
3625
|
+
...subject,
|
|
3626
|
+
...objectType ? { objectType } : void 0
|
|
3627
|
+
};
|
|
3628
|
+
}
|
|
3554
3629
|
/** Build the API payload of one Review item for its viewer. */
|
|
3555
3630
|
function reviewItemPayload(item, viewer) {
|
|
3556
3631
|
return {
|
|
@@ -3575,7 +3650,7 @@ function reviewItemPayload(item, viewer) {
|
|
|
3575
3650
|
...item.closedAt ? { closedAt: item.closedAt.toISOString() } : void 0,
|
|
3576
3651
|
...item.closedBy ? { closedBy: item.closedBy } : void 0,
|
|
3577
3652
|
...item.request ? { request: item.request } : void 0,
|
|
3578
|
-
...item.subject ? { subject: item.subject } : void 0
|
|
3653
|
+
...item.subject ? { subject: subjectPayload(item.subject) } : void 0
|
|
3579
3654
|
};
|
|
3580
3655
|
}
|
|
3581
3656
|
function actionErrorResponse(error) {
|
|
@@ -3591,35 +3666,87 @@ function createReviewItemRoutes(services) {
|
|
|
3591
3666
|
const filters = {
|
|
3592
3667
|
...query.conversationId ? { conversationId: query.conversationId } : void 0,
|
|
3593
3668
|
...query.for === "viewer" ? { forUserId: viewer.id } : void 0,
|
|
3594
|
-
...query.q ? { query: query.q } : void 0
|
|
3669
|
+
...query.q ? { query: query.q } : void 0,
|
|
3670
|
+
...query.status[0] === "open" ? query.sort ? { sort: query.sort } : void 0 : { status: [...query.status].sort().join(",") }
|
|
3595
3671
|
};
|
|
3596
3672
|
const after = query.cursor ? decodeCursor(query.cursor, filters) : void 0;
|
|
3597
3673
|
if (query.cursor && !after) return jsonResponse(apiErrorSchema, { error: "Invalid review item cursor." }, { status: 400 });
|
|
3598
3674
|
const db = getDb();
|
|
3599
3675
|
const reader = filters.conversationId ? await reviewItemReaderForUserInConversation(viewer, filters.conversationId) : reviewItemReaderForUser(viewer);
|
|
3600
|
-
|
|
3676
|
+
if (filters.status) {
|
|
3677
|
+
const closed = await searchReviewItems(db, reader, {
|
|
3678
|
+
...filters,
|
|
3679
|
+
limit: query.limit + 1,
|
|
3680
|
+
order: "closed",
|
|
3681
|
+
statuses: query.status,
|
|
3682
|
+
...after?.closedAt ? { closedBefore: {
|
|
3683
|
+
closedAt: after.closedAt,
|
|
3684
|
+
id: after.id
|
|
3685
|
+
} } : void 0
|
|
3686
|
+
});
|
|
3687
|
+
const page = closed.slice(0, query.limit);
|
|
3688
|
+
const last = page.at(-1);
|
|
3689
|
+
return jsonResponse(reviewItemListSchema, {
|
|
3690
|
+
items: page.map((item) => reviewItemPayload(item, viewer)),
|
|
3691
|
+
...closed.length > query.limit && last ? { nextCursor: encodeCursor(last, filters, viewer) } : void 0
|
|
3692
|
+
});
|
|
3693
|
+
}
|
|
3694
|
+
const [open, archived] = await Promise.all([searchReviewItems(db, reader, {
|
|
3601
3695
|
...filters,
|
|
3602
3696
|
limit: query.limit + 1,
|
|
3603
|
-
order: "oldest",
|
|
3604
3697
|
statuses: ["open"],
|
|
3605
|
-
...
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3698
|
+
...filters.sort ? {
|
|
3699
|
+
order: { needsUserId: viewer.id },
|
|
3700
|
+
...after ? { afterWaiting: {
|
|
3701
|
+
createdAt: after.createdAt,
|
|
3702
|
+
id: after.id,
|
|
3703
|
+
needsUser: after.needsUser === true
|
|
3704
|
+
} } : void 0
|
|
3705
|
+
} : {
|
|
3706
|
+
order: "oldest",
|
|
3707
|
+
...after ? { after } : void 0
|
|
3708
|
+
}
|
|
3709
|
+
}), (filters.query || query.include === "archived") && !after ? searchReviewItems(db, reader, {
|
|
3610
3710
|
...filters,
|
|
3611
3711
|
limit: 51,
|
|
3612
3712
|
statuses: ["done", "dismissed"]
|
|
3613
|
-
}) : [];
|
|
3713
|
+
}) : []]);
|
|
3714
|
+
const page = open.slice(0, query.limit);
|
|
3715
|
+
const last = page.at(-1);
|
|
3614
3716
|
return jsonResponse(reviewItemListSchema, {
|
|
3615
3717
|
items: [...page, ...archived.slice(0, ARCHIVED_LIMIT)].map((item) => reviewItemPayload(item, viewer)),
|
|
3616
3718
|
...archived.length > ARCHIVED_LIMIT ? { moreArchived: true } : void 0,
|
|
3617
|
-
...open.length > query.limit && last ? { nextCursor: encodeCursor(last, filters) } : void 0
|
|
3719
|
+
...open.length > query.limit && last ? { nextCursor: encodeCursor(last, filters, viewer) } : void 0
|
|
3618
3720
|
});
|
|
3619
3721
|
});
|
|
3620
|
-
app.get("/count", requireViewer, async (context) => {
|
|
3722
|
+
app.get("/count", requireViewer, validateRequest("query", reviewItemCountQuerySchema, "Invalid review item count query."), async (context) => {
|
|
3621
3723
|
const viewer = context.get("viewer");
|
|
3622
|
-
|
|
3724
|
+
const query = context.req.valid("query");
|
|
3725
|
+
const db = getDb();
|
|
3726
|
+
const [subjects, snoozed, automations] = await Promise.all([
|
|
3727
|
+
countReviewItemsNeedingUserBySubject(db, viewer.id),
|
|
3728
|
+
countOpenReviewItemsForUser(db, {
|
|
3729
|
+
...reviewItemReaderForUser(viewer),
|
|
3730
|
+
userId: viewer.id
|
|
3731
|
+
}, query.snoozed),
|
|
3732
|
+
query.include === "automations" ? countOwnedAutomationsNeedingAttention(viewer) : void 0
|
|
3733
|
+
]);
|
|
3734
|
+
const linkTypes = readObjectLinkTypes();
|
|
3735
|
+
let codeChanges = 0;
|
|
3736
|
+
let decisions = 0;
|
|
3737
|
+
let needsViewer = 0;
|
|
3738
|
+
for (const subject of subjects) {
|
|
3739
|
+
needsViewer += subject.total;
|
|
3740
|
+
decisions += subject.decisions;
|
|
3741
|
+
if (subject.subjectUrl && readLinkObjectType(subject.subjectUrl, linkTypes) === "code_change") codeChanges += subject.total;
|
|
3742
|
+
}
|
|
3743
|
+
return jsonResponse(reviewItemCountSchema, {
|
|
3744
|
+
...automations === void 0 ? void 0 : { automations },
|
|
3745
|
+
codeChanges,
|
|
3746
|
+
decisions,
|
|
3747
|
+
needsViewer,
|
|
3748
|
+
snoozed
|
|
3749
|
+
});
|
|
3623
3750
|
});
|
|
3624
3751
|
app.get("/waiting-conversations", requireViewer, async (context) => {
|
|
3625
3752
|
const viewer = context.get("viewer");
|
|
@@ -3803,7 +3930,7 @@ function readDescriptionText(home) {
|
|
|
3803
3930
|
}
|
|
3804
3931
|
/** Read discovered skills for runtime diagnostics and the Automation editor. */
|
|
3805
3932
|
async function readSkillReports() {
|
|
3806
|
-
const { discoverSkills } = await import("./skills-
|
|
3933
|
+
const { discoverSkills } = await import("./skills-CNAGH4ju.js").then((n) => n.o);
|
|
3807
3934
|
const skills = await discoverSkills();
|
|
3808
3935
|
return skillReportsSchema.parse(skills.map((skill) => ({
|
|
3809
3936
|
name: skill.name,
|
|
@@ -3817,7 +3944,7 @@ async function readSkillReports() {
|
|
|
3817
3944
|
* what the skill tells Junior. Returns null when no skill has that name.
|
|
3818
3945
|
*/
|
|
3819
3946
|
async function readSkillDetailReport(name) {
|
|
3820
|
-
const { discoverSkills, findSkillByName, parseSkillFile } = await import("./skills-
|
|
3947
|
+
const { discoverSkills, findSkillByName, parseSkillFile } = await import("./skills-CNAGH4ju.js").then((n) => n.o);
|
|
3821
3948
|
const skill = findSkillByName(name, await discoverSkills());
|
|
3822
3949
|
if (!skill) return null;
|
|
3823
3950
|
const parsed = parseSkillFile(await fs.readFile(path.join(skill.skillPath, "SKILL.md"), "utf8"), skill.name);
|
|
@@ -3832,7 +3959,7 @@ async function readSkillDetailReport(name) {
|
|
|
3832
3959
|
}
|
|
3833
3960
|
/** Read safe configured plugin metadata for authenticated runtime diagnostics. */
|
|
3834
3961
|
async function readPlugins() {
|
|
3835
|
-
const { pluginCatalogRuntime } = await import("./catalog-runtime-
|
|
3962
|
+
const { pluginCatalogRuntime } = await import("./catalog-runtime-d1EM6Z0V.js").then((n) => n.t);
|
|
3836
3963
|
return pluginsSchema.parse(pluginCatalogRuntime.getProviders().map((plugin) => ({
|
|
3837
3964
|
configKeys: plugin.manifest.configKeys ?? [],
|
|
3838
3965
|
description: plugin.manifest.description,
|
|
@@ -3843,8 +3970,8 @@ async function readPlugins() {
|
|
|
3843
3970
|
/** Read authenticated runtime discovery data. */
|
|
3844
3971
|
async function readRuntimeInfoReport() {
|
|
3845
3972
|
const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
|
|
3846
|
-
import("./package-discovery-
|
|
3847
|
-
import("./catalog-runtime-
|
|
3973
|
+
import("./package-discovery-x4AvVhMj.js").then((n) => n.r),
|
|
3974
|
+
import("./catalog-runtime-d1EM6Z0V.js").then((n) => n.t),
|
|
3848
3975
|
readPlugins(),
|
|
3849
3976
|
readSkillReports()
|
|
3850
3977
|
]);
|
|
@@ -3861,7 +3988,7 @@ async function readRuntimeInfoReport() {
|
|
|
3861
3988
|
/** Read sanitized operational summaries contributed by plugins. */
|
|
3862
3989
|
async function readPluginOperationalReportFeed() {
|
|
3863
3990
|
const nowMs = Date.now();
|
|
3864
|
-
const { getPluginOperationalReports } = await import("./projection-
|
|
3991
|
+
const { getPluginOperationalReports } = await import("./projection-DBq8tsA5.js").then((n) => n.er);
|
|
3865
3992
|
return pluginOperationalReportFeedSchema.parse({
|
|
3866
3993
|
source: "plugins",
|
|
3867
3994
|
generatedAt: new Date(nowMs).toISOString(),
|
|
@@ -3918,4 +4045,4 @@ function createJuniorApi(options = {}) {
|
|
|
3918
4045
|
});
|
|
3919
4046
|
return app;
|
|
3920
4047
|
}
|
|
3921
|
-
export {
|
|
4048
|
+
export { DEFAULT_USER_SETTINGS, authenticatePersonalToken, createJuniorApi, isAllowedSignInEmail, jsonResponse, readUserSettings, readViewerAvatarUrl, resolveViewerUser, updateUserSettings, updateViewerDisplayName };
|