@sentry/junior 0.294.0 → 0.296.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/{admin-vt8aSiCD.js → admin-z_lgDi-z.js} +2 -2
- package/dist/{agent-runner-DJu7w6mI.js → agent-runner-HoQiUKLL.js} +318 -199
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +5 -5
- package/dist/api.d.ts +1 -1
- package/dist/api.js +321 -331
- package/dist/{app--a5RLOrr.d.ts → app-C75Ft-A_.d.ts} +3 -3
- package/dist/app.d.ts +2 -2
- package/dist/app.js +33 -34
- package/dist/{automation-BM-OBsKW.js → automation-yJX3C7i3.js} +3 -3
- package/dist/{background-compaction-queue-D2j-0XkH.js → background-compaction-queue-Cre1wFt9.js} +7 -9
- package/dist/{briefs-JOAoCb6d.js → briefs-BXECHduJ.js} +3 -3
- package/dist/{catalog-runtime-CLMA9AXd.js → catalog-runtime-CpCmlD9L.js} +1 -1
- package/dist/cli/chat.d.ts +1 -1
- package/dist/cli/chat.js +15 -15
- package/dist/cli/check.js +3 -3
- package/dist/cli/init.js +2 -0
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.d.ts +1 -1
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +2 -2
- package/dist/cli/upgrade.js +3 -3
- package/dist/{config-mIZeGEWv.js → config-CCPHvTqx.js} +59 -2
- package/dist/{connections-XhdVg7OR.js → connections-B5pWh8e2.js} +6 -6
- package/dist/{conversation-CDWejM4R.js → conversation-CMkSmi02.js} +2 -11
- package/dist/{conversation-pending-messages-Dh2tfbaw.js → conversation-feed-BVAOga0H.js} +27 -2
- package/dist/{conversation-privacy-C6h-X2cZ.js → conversation-privacy-CZD5soDW.js} +1 -1
- package/dist/{credential-sync-zigBlXS3.js → credential-sync-DwLkIvXI.js} +16 -15
- package/dist/{db-DV5AbcGM.d.ts → db-B3iyr_Or.d.ts} +6 -1
- package/dist/{db--xuNV7g6.js → db-C1M1y-bh.js} +64 -26
- package/dist/{executor-BItuRqAR.js → executor-DUSEwXaO.js} +16 -5
- package/dist/instrumentation.js +19 -2
- package/dist/{logging-Cb6MGvdt.js → logging-D0svFM8r.js} +2 -1
- package/dist/{message-BTGgSmaH.js → message-BFnIwKpx.js} +9 -9
- package/dist/nitro.d.ts +2 -2
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-Dvh1aOIi.js → oauth-callback-server-BXRtD6Fk.js} +2 -2
- package/dist/{oauth-relay-D6xxVywK.js → oauth-relay-CsfIazeF.js} +2 -1
- package/dist/{plugins-DtmjkTza.d.ts → plugins-B_0Cr0MO.d.ts} +0 -1
- package/dist/{projection-DLQgfO5N.js → projection-B6VS7kbo.js} +386 -108
- package/dist/{prompt-qp_LdxLX.js → prompt-CD11tfG8.js} +4 -4
- package/dist/{registry-MtwokaqW.js → registry-CHewwYEo.js} +3 -13
- package/dist/{resolve-BnJA0UNE.js → resolve-1owMH4qo.js} +3 -3
- package/dist/{result-ChL-1KyW.js → result-CEqQFrEf.js} +8 -8
- package/dist/{runner-BONN7Dp2.js → runner-BtWvJslp.js} +8 -8
- package/dist/{sandbox-egress-signals-nmlmI5Ab.js → sandbox-egress-signals-ByftwJVt.js} +1 -1
- package/dist/{schema-DgvcyJ1y.d.ts → schema-Ct1Zf2xy.d.ts} +66 -14
- package/dist/{schema-yr0ccDni.js → schema-D2iGyYIp.js} +24 -6
- package/dist/secrets-DebYU866.js +18 -0
- package/dist/{service-account-Bd0lBaGr.js → service-account-BZEuMKdo.js} +3 -3
- package/dist/{service-account-kio5nXSD.js → service-account-DLoeoHww.js} +42 -26
- package/dist/{session-stop-CeCXL3j9.js → session-stop-hYNTNpVf.js} +23 -778
- package/dist/{skills-e3DDNlKO.js → skills-DXgd5Inh.js} +3 -3
- package/dist/{spawn--cRxITWQ.js → spawn-YeqlNDv8.js} +5 -5
- package/dist/{adapter-DxLhJEnO.js → state-C3CbtD_m.js} +132 -2
- package/dist/{stop-Iai5N2PU.js → stop-Cze_pEL8.js} +351 -255
- package/dist/{store-C8LsaJwS.js → store-CZ9vqR4P.js} +3 -3
- package/dist/{task-runner-Dw7exu0-.js → task-runner-CMiNGsER.js} +275 -251
- package/dist/{turn-failure-response-BqTTx3XG.js → turn-failure-response-pXhZ2wMK.js} +12 -9
- package/dist/{validation-BrGahtnv.js → validation-Du7NdkOR.js} +1 -1
- package/dist/{version-Bdqhx8Qh.js → version-EN3Wnq-R.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-CjRFHR5U.js → viewer-Agxi_o5c.js} +3 -3
- package/dist/warmup-CY2ArYag.js +2017 -0
- package/dist/{work-BWBG1EGV.js → work-EA98F0ia.js} +11 -11
- package/dist/{worker-DAnBIVMs.js → worker-BALVdWbv.js} +6 -6
- package/migrations/0098_review_item_plugin_actions.sql +5 -0
- package/migrations/0099_conversation_last_message_at.sql +1 -0
- package/migrations/0100_automation_task_kind_repair.sql +48 -0
- package/migrations/0101_drop_legacy_columns.sql +12 -0
- package/migrations/meta/0098_snapshot.json +4490 -0
- package/migrations/meta/0099_snapshot.json +4720 -0
- package/migrations/meta/0100_snapshot.json +4496 -0
- package/migrations/meta/0101_snapshot.json +4496 -0
- package/migrations/meta/_journal.json +28 -0
- package/package.json +6 -5
- package/dist/assistant-reply-iTtEdDyc.js +0 -58
- package/dist/warmup-DuxCtzKC.js +0 -1039
package/dist/api.js
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
|
-
import { $a as createConversationAccessReader, $n as savePushSubscription, Bn as getPlugins, Dr as reviewItemReaderForUserInConversation, Ei as hash, En as createUserTokenStore, Er as reviewItemReaderForUser, Jn as resolveNotificationTimezone, Kn as readWebPushConfig,
|
|
2
|
-
import { L as escapeXml, Y as getAttachmentStorage, n as botConfig } from "./config-
|
|
3
|
-
import { m as logInfo, p as logException } from "./logging-
|
|
1
|
+
import { $a as createConversationAccessReader, $n as savePushSubscription, Bn as getPlugins, Dr as reviewItemReaderForUserInConversation, Ei as hash, En as createUserTokenStore, Er as reviewItemReaderForUser, Jn as resolveNotificationTimezone, Kn as readWebPushConfig, Pa as workspaceRepoCheckoutPath, Po as createPluginCache, Qn as saveNotificationSchedule, Ti as create, Tr as reviewItemNeedsUser, Xa as createPluginLogger, Xn as listPushSubscriptions, Yn as deletePushSubscription, Zn as readNotificationSchedule, _i as listWorkspaces, bi as WorkspaceValidationError, br as isOnlyAssignee, co as readConversationBriefThrough, dr as reviewItemsNeedingUserVersionQuery, eo as readConversationAccessFromSql, er as isPausedBySlack, fr as searchReviewItems, gr as canActOnReviewItem, hi as getWorkspace, hr as PLUGIN_REVIEW_ITEM_KEY_PREFIX, ir as countReviewItemsNeedingUser, ja as SANDBOX_RUNTIME, mi as deleteWorkspace, no as conversationIsMemberRoot, oi as getDashboardSettingsLink, pi as createWorkspace, qn as sendPushNotificationToUser, uo as readConversationEventPage, ur as listWaitingConversations, vi as listWorkspacesByRepository, yi as updateWorkspace } from "./projection-B6VS7kbo.js";
|
|
2
|
+
import { L as escapeXml, Y as getAttachmentStorage, n as botConfig } from "./config-CCPHvTqx.js";
|
|
3
|
+
import { m as logInfo, p as logException } from "./logging-D0svFM8r.js";
|
|
4
4
|
import { f as parseSlackTeamId, u as parseSlackChannelId } from "./actor-6jsm_v96.js";
|
|
5
|
-
import {
|
|
6
|
-
import { A as juniorConversations, D as juniorCodeChanges, E as juniorConversationAnnotations, M as juniorUsers, N as juniorDestinations, O as juniorCodeRepositories, S as juniorConversationMetrics, T as juniorApiTokens, j as juniorIdentities, l as juniorReviewItems, s as juniorReviewItemConversations, w as juniorConversationEvents } from "./executor-
|
|
5
|
+
import { O as conversationKindFromRow, S as withConversationMutationLock, a as getConversationStore, o as getDb, s as getSqlExecutor, tt as nextDetailVersion, v as loadConversationSlackTenantIds } from "./db-C1M1y-bh.js";
|
|
6
|
+
import { A as juniorConversations, D as juniorCodeChanges, E as juniorConversationAnnotations, M as juniorUsers, N as juniorDestinations, O as juniorCodeRepositories, S as juniorConversationMetrics, T as juniorApiTokens, b as juniorConversationBriefs, j as juniorIdentities, l as juniorReviewItems, s as juniorReviewItemConversations, w as juniorConversationEvents } from "./executor-DUSEwXaO.js";
|
|
7
7
|
import { n as INPUT_IMAGE_TYPES, t as INLINE_VIDEO_TYPES } from "./media-BepyEUNm.js";
|
|
8
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
9
|
-
import { $ as readViewerAutomationSummary, $t as resumeConversationDelivery, A as runWithSlackInstallation, Ct as emptyResponse, G as changeViewerAutomationLifecycle, J as updateViewerAutomation, K as deleteViewerTask, Q as readViewerAutomationRuns, Qt as pauseConversationDelivery, S as createSlackReviewItemShow, Tt as throwApiError, W as activateViewerAutomationVersion, Y as ViewerTaskNotFoundError, Z as readViewerAutomationExecutions, Zt as canPauseConversationDelivery, _t as readLiveAttachment, bt as archiveConversation, et as readViewerAutomationVersions, it as listOwnedWatches, m as readStats, mt as webActorFromUser, nt as AutomationEditError, on as listedConversation, q as readViewerAutomationEdit, sn as listChildAgents, tt as readViewerAutomations, v as setConversationSubscription, wt as jsonResponse } from "./agent-runner-
|
|
10
|
-
import { n as briefEntriesFromReportEvents, u as completeText } from "./prompt-
|
|
11
|
-
import { c as readViewerAvatarUrl, d as updateViewerDisplayName, l as resolveViewerUser, m as readAvatarImage, t as findUserByEmail } from "./viewer-
|
|
12
|
-
import {
|
|
8
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-CpCmlD9L.js";
|
|
9
|
+
import { $ as readViewerAutomationSummary, $t as resumeConversationDelivery, A as runWithSlackInstallation, Ct as emptyResponse, G as changeViewerAutomationLifecycle, J as updateViewerAutomation, K as deleteViewerTask, Q as readViewerAutomationRuns, Qt as pauseConversationDelivery, S as createSlackReviewItemShow, Tt as throwApiError, W as activateViewerAutomationVersion, Y as ViewerTaskNotFoundError, Z as readViewerAutomationExecutions, Zt as canPauseConversationDelivery, _t as readLiveAttachment, bt as archiveConversation, et as readViewerAutomationVersions, it as listOwnedWatches, m as readStats, mt as webActorFromUser, nt as AutomationEditError, on as listedConversation, q as readViewerAutomationEdit, sn as listChildAgents, tt as readViewerAutomations, v as setConversationSubscription, wt as jsonResponse } from "./agent-runner-HoQiUKLL.js";
|
|
10
|
+
import { n as briefEntriesFromReportEvents, u as completeText } from "./prompt-CD11tfG8.js";
|
|
11
|
+
import { c as readViewerAvatarUrl, d as updateViewerDisplayName, l as resolveViewerUser, m as readAvatarImage, t as findUserByEmail } from "./viewer-Agxi_o5c.js";
|
|
12
|
+
import { a as getStateAdapter } from "./state-C3CbtD_m.js";
|
|
13
13
|
import { r as notificationScheduleSchema } from "./schedule-cP0AACm1.js";
|
|
14
|
-
import { A as
|
|
15
|
-
import { a as segmentGapsKey, h as gapHistogramReport, u as GAP_SEGMENTS } from "./warmup-
|
|
16
|
-
import { g as getVercelConversationWorkQueue } from "./background-compaction-queue-
|
|
17
|
-
import { O as getEventCatalog, et as readUserCustomization, rt as isExperimentalFeatureEnabled, tt as saveUserCustomization } from "./session-stop-
|
|
14
|
+
import { A as renameConversationResponseSchema, C as createConversationMessageBodySchema, M as conversationReadReportSchema, S as createConversationBodySchema, T as forkConversationResponseSchema, c as conversationDetailQuerySchema, d as conversationEventPageSchema, f as conversationEventsQuerySchema, j as conversationReadPositionSchema, k as renameConversationBodySchema, l as conversationDetailReportSchema, m as conversationParamsSchema, n as CONVERSATION_VERSION_HEADER, o as conversationAttachmentParamsSchema, p as conversationFeedQuerySchema, r as acceptedConversationMessageSchema, t as CONVERSATION_DETAIL_VERSION_HEADER, w as forkConversationBodySchema } from "./conversation-CMkSmi02.js";
|
|
15
|
+
import { a as segmentGapsKey, h as gapHistogramReport, u as GAP_SEGMENTS } from "./warmup-CY2ArYag.js";
|
|
16
|
+
import { g as getVercelConversationWorkQueue } from "./background-compaction-queue-Cre1wFt9.js";
|
|
17
|
+
import { O as getEventCatalog, et as readUserCustomization, rt as isExperimentalFeatureEnabled, tt as saveUserCustomization } from "./session-stop-hYNTNpVf.js";
|
|
18
18
|
import { E as userCustomizationSchema, a as fillUtcSixHours, c as trailingUtcDayWindow, d as utcDayKey, f as utcHourKey, i as fillUtcHours, l as trailingUtcHourWindow, m as apiErrorSchema, n as HOUR_MS$1, o as startOfUtcHour, r as fillUtcDays, s as sumUtcHoursIntoSixHours, t as DAY_MS$1, u as trailingUtcSixHourWindow } from "./reporting-window-B3Ze-Qnt.js";
|
|
19
|
-
import { s as getSandboxResources, t as getCachedSnapshot } from "./resolve-
|
|
20
|
-
import {
|
|
21
|
-
import { n as finishServiceAccountSignIn, o as serviceAccountPlugins, r as getServiceAccountStatus, s as startServiceAccountSignIn, t as disconnectServiceAccount } from "./service-account-
|
|
22
|
-
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-
|
|
23
|
-
import {
|
|
24
|
-
import { $ as actOnReviewItem, C as createConversationForViewer, E as cancelConversationPendingMessagesForViewer, F as isAllowedSignInEmail, M as getProductionSlackAdapter, O as requireConversationPendingMessages, Q as ReviewItemActionError, S as appendConversationMessageForViewer, _ as keepQuickQuestionForViewer, a as pinConversation, at as continueConversationInSlack, c as readConversationParticipants, ct as archiveViewerDoneConversations, d as readConversationTreeMetricsFromSql, dt as setConversationAutoArchive, f as conversationVersionQuery, ft as updateUserAutoArchiveSettings, g as forkConversationForViewer, gt as readHealthReport, h as reportConversationRead, i as readConversationFeed, it as canContinueInSlack, k as resolveMentions, l as readConversationAuxiliaryCostsFromSql, lt as readUserAutoArchiveSettings, m as markConversationUnread, n as steerConversationPendingMessagesForViewer, o as reorderPinnedConversations, p as readConversationDetailEtag, r as conversationFeedVersionQuery, s as readConversationDetail, st as DEFAULT_AUTO_ARCHIVE_SETTINGS, t as stopConversationTurnForViewer, tt as readReviewItemForUser, u as childAgentTotalsReport, v as readConversationEvents, x as readFirstHumanMessageTexts
|
|
25
|
-
import { a as startConnection, n as isConnectableProvider, r as listConnections, s as htmlCallbackResponse, t as disconnectConnection } from "./connections-
|
|
26
|
-
import { A as revokePersonalTokenResponseSchema, At as reorderPinnedConversationsBodySchema, B as activityDays$1, Ct as markConversationUnreadBodySchema, D as personalTokenListSchema, Dt as conversationDeliveryResponseSchema, E as createdPersonalTokenSchema, Et as conversationDeliveryBodySchema, F as personalSpendReportSchema, G as pushSubscriptionBodySchema, H as activitySixHours$1, J as connectionListSchema, K as pushSubscriptionDeleteBodySchema, L as locationDetailReportSchema, M as actorProfileReportSchema, Mt as conversationCatchUpBodySchema, N as avatarParamsSchema, Nt as conversationCatchUpSchema, Ot as pinConversationBodySchema, P as personParamsSchema, Q as startConnectionResponseSchema, R as locationDirectoryReportSchema, S as serviceAccountParamsSchema, St as conversationUnreadSchema, T as createPersonalTokenBodySchema, Tt as conversationSubscriptionResponseSchema, V as activityHours$1, W as notificationSettingsSchema, Y as connectionParamsSchema, Z as disconnectConnectionResponseSchema, _ as reviewItemParamsSchema, _t as conversationOutlineSchema, a as replyTimeSegmentsReportSchema, at as codeRepositoryReportSchema, b as disconnectServiceAccountResponseSchema, bt as archiveDoneConversationsResponseSchema, c as workspaceBodySchema, dt as conversationChildAgentsReportSchema, f as workspaceSchema, ft as continueConversationInSlackBodySchema, g as reviewItemListSchema, h as reviewItemListQuerySchema, ht as conversationStatsReportSchema, i as statsReportSchema, it as codeRepositoryParamsSchema, j as actorDirectoryReportSchema, jt as reorderPinnedConversationsResponseSchema, k as personalTokenParamsSchema, kt as pinConversationResponseSchema, l as workspaceListSchema, lt as conversationWatchesReportSchema, m as reviewItemCountSchema, mt as stopConversationTurnResponseSchema, n as versionsSchema, nt as codeOverviewReportSchema, p as reviewItemActionSchema, pt as continueConversationInSlackResponseSchema, q as testNotificationResponseSchema, rt as codePersonReportSchema, s as deleteWorkspaceResponseSchema, st as boardReportSchema, t as versionsQuerySchema, u as workspaceParamsSchema, v as reviewItemSchema, vt as archiveConversationBodySchema, w as startServiceAccountSignInResponseSchema, wt as conversationSubscriptionBodySchema, x as serviceAccountListSchema, xt as conversationAutoArchiveSchema, y as reviewItemWaitingConversationsSchema, yt as archiveConversationResponseSchema, z as locationParamsSchema } from "./schema-
|
|
19
|
+
import { s as getSandboxResources, t as getCachedSnapshot } from "./resolve-1owMH4qo.js";
|
|
20
|
+
import { _t as conversationRangeColumns, bt as automationEventCatalog, gt as conversationAggregateColumns, mt as readAutomationTitlesByConversationId, rt as AutomationConflictError, vt as conversationUsageCostExpr } from "./task-runner-CMiNGsER.js";
|
|
21
|
+
import { n as finishServiceAccountSignIn, o as serviceAccountPlugins, r as getServiceAccountStatus, s as startServiceAccountSignIn, t as disconnectServiceAccount } from "./service-account-DLoeoHww.js";
|
|
22
|
+
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-yJX3C7i3.js";
|
|
23
|
+
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-BVAOga0H.js";
|
|
24
|
+
import { $ as actOnReviewItem, C as createConversationForViewer, E as cancelConversationPendingMessagesForViewer, F as isAllowedSignInEmail, M as getProductionSlackAdapter, O as requireConversationPendingMessages, Q as ReviewItemActionError, S as appendConversationMessageForViewer, _ as keepQuickQuestionForViewer, a as pinConversation, at as continueConversationInSlack, b as conversationSummaryFromStoredConversation, c as readConversationParticipants, ct as archiveViewerDoneConversations, d as readConversationTreeMetricsFromSql, dt as setConversationAutoArchive, f as conversationVersionQuery, ft as updateUserAutoArchiveSettings, g as forkConversationForViewer, gt as readHealthReport, h as reportConversationRead, i as readConversationFeed, it as canContinueInSlack, k as resolveMentions, l as readConversationAuxiliaryCostsFromSql, lt as readUserAutoArchiveSettings, m as markConversationUnread, n as steerConversationPendingMessagesForViewer, o as reorderPinnedConversations, p as readConversationDetailEtag, r as conversationFeedVersionQuery, s as readConversationDetail, st as DEFAULT_AUTO_ARCHIVE_SETTINGS, t as stopConversationTurnForViewer, tt as readReviewItemForUser, u as childAgentTotalsReport, v as readConversationEvents, x as readFirstHumanMessageTexts } from "./stop-Cze_pEL8.js";
|
|
25
|
+
import { a as startConnection, n as isConnectableProvider, r as listConnections, s as htmlCallbackResponse, t as disconnectConnection } from "./connections-B5pWh8e2.js";
|
|
26
|
+
import { A as revokePersonalTokenResponseSchema, At as reorderPinnedConversationsBodySchema, B as activityDays$1, Ct as markConversationUnreadBodySchema, D as personalTokenListSchema, Dt as conversationDeliveryResponseSchema, E as createdPersonalTokenSchema, Et as conversationDeliveryBodySchema, F as personalSpendReportSchema, G as pushSubscriptionBodySchema, H as activitySixHours$1, J as connectionListSchema, K as pushSubscriptionDeleteBodySchema, L as locationDetailReportSchema, M as actorProfileReportSchema, Mt as conversationCatchUpBodySchema, N as avatarParamsSchema, Nt as conversationCatchUpSchema, Ot as pinConversationBodySchema, P as personParamsSchema, Q as startConnectionResponseSchema, R as locationDirectoryReportSchema, S as serviceAccountParamsSchema, St as conversationUnreadSchema, T as createPersonalTokenBodySchema, Tt as conversationSubscriptionResponseSchema, V as activityHours$1, W as notificationSettingsSchema, Y as connectionParamsSchema, Z as disconnectConnectionResponseSchema, _ as reviewItemParamsSchema, _t as conversationOutlineSchema, a as replyTimeSegmentsReportSchema, at as codeRepositoryReportSchema, b as disconnectServiceAccountResponseSchema, bt as archiveDoneConversationsResponseSchema, c as workspaceBodySchema, dt as conversationChildAgentsReportSchema, f as workspaceSchema, ft as continueConversationInSlackBodySchema, g as reviewItemListSchema, h as reviewItemListQuerySchema, ht as conversationStatsReportSchema, i as statsReportSchema, it as codeRepositoryParamsSchema, j as actorDirectoryReportSchema, jt as reorderPinnedConversationsResponseSchema, k as personalTokenParamsSchema, kt as pinConversationResponseSchema, l as workspaceListSchema, lt as conversationWatchesReportSchema, m as reviewItemCountSchema, mt as stopConversationTurnResponseSchema, n as versionsSchema, nt as codeOverviewReportSchema, p as reviewItemActionSchema, pt as continueConversationInSlackResponseSchema, q as testNotificationResponseSchema, rt as codePersonReportSchema, s as deleteWorkspaceResponseSchema, st as boardReportSchema, t as versionsQuerySchema, u as workspaceParamsSchema, v as reviewItemSchema, vt as archiveConversationBodySchema, w as startServiceAccountSignInResponseSchema, wt as conversationSubscriptionBodySchema, x as serviceAccountListSchema, xt as conversationAutoArchiveSchema, y as reviewItemWaitingConversationsSchema, yt as archiveConversationResponseSchema, z as locationParamsSchema } from "./schema-D2iGyYIp.js";
|
|
27
27
|
import { Hono } from "hono";
|
|
28
28
|
import path from "node:path";
|
|
29
29
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
30
30
|
import * as z from "zod";
|
|
31
|
-
import { and, arrayOverlaps, asc, desc, eq, gt, gte, inArray, isNull, like, lte, or, sql } from "drizzle-orm";
|
|
31
|
+
import { and, arrayOverlaps, asc, countDistinct, desc, eq, gt, gte, inArray, isNull, like, lte, notExists, or, sql } from "drizzle-orm";
|
|
32
32
|
import { conversationAnnotationInputSchema, pluginUserPageContentSchema, pluginUserPageCursorSchema, pluginUserPageFilterSchema, pluginUserPageLinksSchema, pluginUserPageQuerySchema } from "@sentry/junior-plugin-api";
|
|
33
33
|
import { alias } from "drizzle-orm/pg-core";
|
|
34
|
+
import fs from "node:fs/promises";
|
|
34
35
|
import { readFileSync } from "node:fs";
|
|
35
36
|
import { HTTPException } from "hono/http-exception";
|
|
36
37
|
import { bodyLimit } from "hono/body-limit";
|
|
@@ -455,6 +456,111 @@ async function readConversationMetricBuckets(db, options) {
|
|
|
455
456
|
value: sql`sum(${juniorConversationMetrics.value})::double precision`
|
|
456
457
|
}).from(juniorConversationMetrics).where(and(gte(juniorConversationMetrics.occurredAt, options.start), lte(juniorConversationMetrics.occurredAt, options.end))).groupBy(date, juniorConversationMetrics.metric).orderBy(asc(date), asc(juniorConversationMetrics.metric));
|
|
457
458
|
}
|
|
459
|
+
// src/api/conversations/outcome-buckets.ts
|
|
460
|
+
const changes = juniorCodeChanges;
|
|
461
|
+
const linked = alias(juniorConversations, "linked");
|
|
462
|
+
const linksChange = sql`${linked.conversationId} = any(${changes.conversationIds})`;
|
|
463
|
+
const linkedRoot = sql`coalesce(${linked.rootConversationId}, ${linked.conversationId})`;
|
|
464
|
+
/**
|
|
465
|
+
* Count outcomes per UTC day or hour, with the conversation cost that
|
|
466
|
+
* produced them. An outcome is one of:
|
|
467
|
+
*
|
|
468
|
+
* - a merged code change, at its merge time. Each root Conversation splits its
|
|
469
|
+
* tree cost evenly across all of its merged code changes, so a long
|
|
470
|
+
* Conversation that merges three changes makes each one cheaper.
|
|
471
|
+
* - a root Conversation with no linked code change whose latest Brief is
|
|
472
|
+
* `done` or `answered`, at its last activity. Its whole tree cost counts.
|
|
473
|
+
*
|
|
474
|
+
* Roots with only open or closed code changes count nothing until a change
|
|
475
|
+
* merges, so one Conversation is never both kinds of outcome. A merged change
|
|
476
|
+
* with no linked Conversation has an unknown cost, not a zero cost, so it is
|
|
477
|
+
* left out instead of making the mean look cheaper.
|
|
478
|
+
*/
|
|
479
|
+
async function readOutcomeBuckets(db, options) {
|
|
480
|
+
const [merges, briefRoots] = await Promise.all([readWindowMerges(db, options), readBriefOutcomeRoots(db, options)]);
|
|
481
|
+
const mergeRoots = [...new Set(merges.map((merge) => merge.rootId))];
|
|
482
|
+
const [rootMerges, treeCosts] = await Promise.all([readRootMergeCounts(db, mergeRoots), readTreeCosts$1(db, [...mergeRoots, ...briefRoots.map((root) => root.rootId)])]);
|
|
483
|
+
const dateLength = options.bucket === "day" ? 10 : 13;
|
|
484
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
485
|
+
const bucketAt = (instant) => {
|
|
486
|
+
const date = instant.toISOString().slice(0, dateLength);
|
|
487
|
+
let bucket = buckets.get(date);
|
|
488
|
+
if (!bucket) {
|
|
489
|
+
bucket = {
|
|
490
|
+
date,
|
|
491
|
+
mergedCodeChangeCostUsd: 0,
|
|
492
|
+
mergedCodeChanges: 0,
|
|
493
|
+
outcomeCostUsd: 0,
|
|
494
|
+
outcomes: 0
|
|
495
|
+
};
|
|
496
|
+
buckets.set(date, bucket);
|
|
497
|
+
}
|
|
498
|
+
return bucket;
|
|
499
|
+
};
|
|
500
|
+
const changeCosts = /* @__PURE__ */ new Map();
|
|
501
|
+
for (const merge of merges) {
|
|
502
|
+
const share = (treeCosts.get(merge.rootId) ?? 0) / (rootMerges.get(merge.rootId) ?? 1);
|
|
503
|
+
const change = changeCosts.get(merge.changeId);
|
|
504
|
+
if (change) change.costUsd += share;
|
|
505
|
+
else changeCosts.set(merge.changeId, {
|
|
506
|
+
costUsd: share,
|
|
507
|
+
mergedAt: merge.mergedAt
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
for (const change of changeCosts.values()) {
|
|
511
|
+
const bucket = bucketAt(change.mergedAt);
|
|
512
|
+
bucket.mergedCodeChanges += 1;
|
|
513
|
+
bucket.mergedCodeChangeCostUsd += change.costUsd;
|
|
514
|
+
bucket.outcomes += 1;
|
|
515
|
+
bucket.outcomeCostUsd += change.costUsd;
|
|
516
|
+
}
|
|
517
|
+
for (const root of briefRoots) {
|
|
518
|
+
const bucket = bucketAt(root.lastActivityAt);
|
|
519
|
+
bucket.outcomes += 1;
|
|
520
|
+
bucket.outcomeCostUsd += treeCosts.get(root.rootId) ?? 0;
|
|
521
|
+
}
|
|
522
|
+
return [...buckets.values()];
|
|
523
|
+
}
|
|
524
|
+
async function readWindowMerges(db, options) {
|
|
525
|
+
return (await db.selectDistinct({
|
|
526
|
+
changeId: changes.id,
|
|
527
|
+
mergedAt: changes.mergedAt,
|
|
528
|
+
rootId: linkedRoot
|
|
529
|
+
}).from(changes).innerJoin(linked, linksChange).where(and(eq(changes.state, "merged"), gte(changes.mergedAt, options.start), lte(changes.mergedAt, options.end)))).flatMap(({ changeId, mergedAt, rootId }) => mergedAt && rootId ? [{
|
|
530
|
+
changeId,
|
|
531
|
+
mergedAt,
|
|
532
|
+
rootId
|
|
533
|
+
}] : []);
|
|
534
|
+
}
|
|
535
|
+
async function readBriefOutcomeRoots(db, options) {
|
|
536
|
+
const roots = juniorConversations;
|
|
537
|
+
const briefs = juniorConversationBriefs;
|
|
538
|
+
const latestBrief = db.select({ status: sql`${briefs.content}->'outcome'->>'status'`.as("status") }).from(briefs).where(eq(briefs.conversationId, roots.conversationId)).orderBy(desc(briefs.version)).limit(1).as("latest_brief");
|
|
539
|
+
return await db.select({
|
|
540
|
+
lastActivityAt: roots.lastActivityAt,
|
|
541
|
+
rootId: roots.conversationId
|
|
542
|
+
}).from(roots).innerJoinLateral(latestBrief, sql`true`).where(and(isNull(roots.parentConversationId), gte(roots.lastActivityAt, options.start), lte(roots.lastActivityAt, options.end), inArray(latestBrief.status, ["done", "answered"]), notExists(db.select({ id: changes.id }).from(changes).innerJoin(linked, linksChange).where(eq(linkedRoot, roots.conversationId)))));
|
|
543
|
+
}
|
|
544
|
+
/** Merged code changes of all time per root, so each merge gets its share. */
|
|
545
|
+
async function readRootMergeCounts(db, rootIds) {
|
|
546
|
+
if (!rootIds.length) return /* @__PURE__ */ new Map();
|
|
547
|
+
const rows = await db.select({
|
|
548
|
+
merged: countDistinct(changes.id),
|
|
549
|
+
rootId: linkedRoot
|
|
550
|
+
}).from(changes).innerJoin(linked, linksChange).where(and(eq(changes.state, "merged"), inArray(linkedRoot, [...rootIds]))).groupBy(linkedRoot);
|
|
551
|
+
return new Map(rows.flatMap((row) => row.rootId ? [[row.rootId, row.merged]] : []));
|
|
552
|
+
}
|
|
553
|
+
async function readTreeCosts$1(db, rootIds) {
|
|
554
|
+
if (!rootIds.length) return /* @__PURE__ */ new Map();
|
|
555
|
+
const conversations = juniorConversations;
|
|
556
|
+
const ids = [...new Set(rootIds)];
|
|
557
|
+
const treeRoot = sql`coalesce(${conversations.rootConversationId}, ${conversations.conversationId})`;
|
|
558
|
+
const rows = await db.select({
|
|
559
|
+
costUsd: sql`coalesce(sum(${conversationUsageCostExpr(conversations.usage)}), 0)::double precision`,
|
|
560
|
+
rootId: treeRoot
|
|
561
|
+
}).from(conversations).where(or(inArray(conversations.rootConversationId, ids), inArray(conversations.conversationId, ids))).groupBy(treeRoot);
|
|
562
|
+
return new Map(rows.flatMap((row) => row.rootId ? [[row.rootId, row.costUsd]] : []));
|
|
563
|
+
}
|
|
458
564
|
// src/api/conversations/stats.query.ts
|
|
459
565
|
const treeConversation$1 = alias(juniorConversations, "stats_tree_conversation");
|
|
460
566
|
const treeAggregateColumns$1 = conversationAggregateColumns({
|
|
@@ -519,27 +625,37 @@ function statsWindow(nowMs) {
|
|
|
519
625
|
const HOUR_MS = 36e5;
|
|
520
626
|
/** Keep 7d of hours so clients can roll 7d charts into 6h buckets. */
|
|
521
627
|
const WINDOW_HOURS = 168;
|
|
522
|
-
function
|
|
523
|
-
|
|
524
|
-
...row,
|
|
628
|
+
function emptyMetricRow(date) {
|
|
629
|
+
return {
|
|
525
630
|
cachedInputTokens: null,
|
|
526
631
|
cacheCreationTokens: null,
|
|
632
|
+
conversations: 0,
|
|
527
633
|
costUsd: null,
|
|
634
|
+
date,
|
|
528
635
|
durationMs: 0,
|
|
529
636
|
inputTokens: null,
|
|
637
|
+
mergedCodeChangeCostUsd: null,
|
|
638
|
+
mergedCodeChanges: null,
|
|
639
|
+
outcomeCostUsd: null,
|
|
640
|
+
outcomes: null,
|
|
530
641
|
tokens: null
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
function applyMetricBuckets(rows, metrics, outcomes) {
|
|
645
|
+
const byDate = new Map(rows.map((row) => [row.date, {
|
|
646
|
+
...emptyMetricRow(row.date),
|
|
647
|
+
conversations: row.conversations
|
|
531
648
|
}]));
|
|
649
|
+
for (const bucket of outcomes) {
|
|
650
|
+
const row = byDate.get(bucket.date) ?? emptyMetricRow(bucket.date);
|
|
651
|
+
row.mergedCodeChanges = bucket.mergedCodeChanges;
|
|
652
|
+
row.mergedCodeChangeCostUsd = bucket.mergedCodeChangeCostUsd;
|
|
653
|
+
row.outcomes = bucket.outcomes;
|
|
654
|
+
row.outcomeCostUsd = bucket.outcomeCostUsd;
|
|
655
|
+
byDate.set(bucket.date, row);
|
|
656
|
+
}
|
|
532
657
|
for (const metric of metrics) {
|
|
533
|
-
const row = byDate.get(metric.date) ??
|
|
534
|
-
cachedInputTokens: null,
|
|
535
|
-
cacheCreationTokens: null,
|
|
536
|
-
conversations: 0,
|
|
537
|
-
costUsd: null,
|
|
538
|
-
date: metric.date,
|
|
539
|
-
durationMs: 0,
|
|
540
|
-
inputTokens: null,
|
|
541
|
-
tokens: null
|
|
542
|
-
};
|
|
658
|
+
const row = byDate.get(metric.date) ?? emptyMetricRow(metric.date);
|
|
543
659
|
if (metric.metric === "cached_input_tokens") row.cachedInputTokens = metric.value;
|
|
544
660
|
else if (metric.metric === "cache_creation_tokens") row.cacheCreationTokens = metric.value;
|
|
545
661
|
else if (metric.metric === "cost_usd") row.costUsd = metric.value;
|
|
@@ -559,6 +675,12 @@ function metricPoint(date, row) {
|
|
|
559
675
|
...row?.cacheCreationTokens !== null && row?.cacheCreationTokens !== void 0 ? { cacheCreationTokens: row.cacheCreationTokens } : void 0,
|
|
560
676
|
...row?.costUsd !== null && row?.costUsd !== void 0 ? { costUsd: addUsd$2(void 0, row.costUsd) } : void 0,
|
|
561
677
|
...row?.inputTokens !== null && row?.inputTokens !== void 0 ? { inputTokens: row.inputTokens } : void 0,
|
|
678
|
+
...row?.outcomes !== null && row?.outcomes !== void 0 ? {
|
|
679
|
+
mergedCodeChangeCostUsd: addUsd$2(void 0, row.mergedCodeChangeCostUsd ?? 0),
|
|
680
|
+
mergedCodeChanges: row.mergedCodeChanges ?? 0,
|
|
681
|
+
outcomeCostUsd: addUsd$2(void 0, row.outcomeCostUsd ?? 0),
|
|
682
|
+
outcomes: row.outcomes
|
|
683
|
+
} : void 0,
|
|
562
684
|
...row?.tokens !== null && row?.tokens !== void 0 ? { tokens: row.tokens } : void 0
|
|
563
685
|
};
|
|
564
686
|
}
|
|
@@ -678,7 +800,7 @@ async function aggregateStats(db, start, end) {
|
|
|
678
800
|
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
679
801
|
'YYYY-MM-DD"T"HH24'
|
|
680
802
|
)`;
|
|
681
|
-
const [totalsRows, actorRows, locationRows, metricRows, metricHourRows, dayMetrics, hourMetrics] = await Promise.all([
|
|
803
|
+
const [totalsRows, actorRows, locationRows, metricRows, metricHourRows, dayMetrics, hourMetrics, dayOutcomes, hourOutcomes] = await Promise.all([
|
|
682
804
|
db.select(treeAggregateColumns$1).from(juniorConversations).innerJoin(treeConversation$1, eq(treeConversation$1.rootConversationId, juniorConversations.conversationId)).where(where),
|
|
683
805
|
db.select({
|
|
684
806
|
identityDisplayName: juniorIdentities.displayName,
|
|
@@ -715,13 +837,23 @@ async function aggregateStats(db, start, end) {
|
|
|
715
837
|
bucket: "hour",
|
|
716
838
|
start: hourStart,
|
|
717
839
|
end
|
|
840
|
+
}),
|
|
841
|
+
readOutcomeBuckets(db, {
|
|
842
|
+
bucket: "day",
|
|
843
|
+
start,
|
|
844
|
+
end
|
|
845
|
+
}),
|
|
846
|
+
readOutcomeBuckets(db, {
|
|
847
|
+
bucket: "hour",
|
|
848
|
+
start: hourStart,
|
|
849
|
+
end
|
|
718
850
|
})
|
|
719
851
|
]);
|
|
720
852
|
return {
|
|
721
853
|
actorRows,
|
|
722
854
|
locationRows,
|
|
723
|
-
metricHourRows: applyMetricBuckets(metricHourRows, hourMetrics),
|
|
724
|
-
metricRows: applyMetricBuckets(metricRows, dayMetrics),
|
|
855
|
+
metricHourRows: applyMetricBuckets(metricHourRows, hourMetrics, hourOutcomes),
|
|
856
|
+
metricRows: applyMetricBuckets(metricRows, dayMetrics, dayOutcomes),
|
|
725
857
|
totals: totalsRows[0]
|
|
726
858
|
};
|
|
727
859
|
}
|
|
@@ -1118,7 +1250,7 @@ async function readBoard(args) {
|
|
|
1118
1250
|
readConversationParticipants(db, rootIds)
|
|
1119
1251
|
]);
|
|
1120
1252
|
const codeChangeUrls = codeChanges.flatMap((change) => change.state === "open" && change.url ? [change.url] : []);
|
|
1121
|
-
const readyUrls = new Set(codeChangeUrls.length === 0 ? [] : (await db.select({ subjectId: juniorReviewItems.subjectId }).from(juniorReviewItems).where(and(eq(juniorReviewItems.status, "open"),
|
|
1253
|
+
const readyUrls = new Set(codeChangeUrls.length === 0 ? [] : (await db.select({ subjectId: juniorReviewItems.subjectId }).from(juniorReviewItems).where(and(eq(juniorReviewItems.status, "open"), like(juniorReviewItems.dedupeKey, `${PLUGIN_REVIEW_ITEM_KEY_PREFIX}%`), inArray(juniorReviewItems.subjectId, codeChangeUrls)))).flatMap((row) => row.subjectId ? [row.subjectId] : []));
|
|
1122
1254
|
const homes = /* @__PURE__ */ new Map();
|
|
1123
1255
|
const workingHomes = /* @__PURE__ */ new Set();
|
|
1124
1256
|
const needsViewerHomes = /* @__PURE__ */ new Set();
|
|
@@ -1254,44 +1386,6 @@ const WINDOW_DAYS = 30;
|
|
|
1254
1386
|
* stale open change is not cut off by newer completed changes.
|
|
1255
1387
|
*/
|
|
1256
1388
|
const PERSON_CHANGE_LIMIT = 100;
|
|
1257
|
-
const summaryRowSchema = z.object({
|
|
1258
|
-
closed: z.number().int().nonnegative(),
|
|
1259
|
-
costUsd: z.number().nonnegative().nullable(),
|
|
1260
|
-
created: z.number().int().nonnegative(),
|
|
1261
|
-
medianCostUsd: z.number().nonnegative().nullable(),
|
|
1262
|
-
medianMergeTimeMs: z.number().nonnegative().nullable(),
|
|
1263
|
-
merged: z.number().int().nonnegative(),
|
|
1264
|
-
open: z.number().int().nonnegative()
|
|
1265
|
-
}).strict().transform((row) => ({
|
|
1266
|
-
...row,
|
|
1267
|
-
costUsd: row.costUsd ?? void 0,
|
|
1268
|
-
medianCostUsd: row.medianCostUsd ?? void 0,
|
|
1269
|
-
medianMergeTimeMs: row.medianMergeTimeMs ?? void 0
|
|
1270
|
-
}));
|
|
1271
|
-
const repositoryRowSchema = z.object({
|
|
1272
|
-
closed: z.number().int().nonnegative(),
|
|
1273
|
-
created: z.number().int().nonnegative(),
|
|
1274
|
-
id: z.string().min(1),
|
|
1275
|
-
medianCostUsd: z.number().nonnegative().nullable(),
|
|
1276
|
-
merged: z.number().int().nonnegative(),
|
|
1277
|
-
name: z.string().min(1),
|
|
1278
|
-
open: z.number().int().nonnegative(),
|
|
1279
|
-
provider: z.string().min(1),
|
|
1280
|
-
url: z.string().nullable()
|
|
1281
|
-
}).strict().transform((row) => ({
|
|
1282
|
-
...row,
|
|
1283
|
-
medianCostUsd: row.medianCostUsd ?? void 0
|
|
1284
|
-
}));
|
|
1285
|
-
const activityDaySchema = z.object({
|
|
1286
|
-
closed: z.number().int().nonnegative(),
|
|
1287
|
-
created: z.number().int().nonnegative(),
|
|
1288
|
-
date: z.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),
|
|
1289
|
-
merged: z.number().int().nonnegative()
|
|
1290
|
-
}).strict();
|
|
1291
|
-
function queryRows(result) {
|
|
1292
|
-
if (typeof result !== "object" || result === null || !("rows" in result) || !Array.isArray(result.rows)) throw new TypeError("Code overview query did not return rows");
|
|
1293
|
-
return result.rows;
|
|
1294
|
-
}
|
|
1295
1389
|
function startOfUtcDay(timestampMs) {
|
|
1296
1390
|
const date = new Date(timestampMs);
|
|
1297
1391
|
date.setUTCHours(0, 0, 0, 0);
|
|
@@ -1301,39 +1395,65 @@ function mergeRate(merged, closed) {
|
|
|
1301
1395
|
const completed = merged + closed;
|
|
1302
1396
|
return completed > 0 ? merged / completed : void 0;
|
|
1303
1397
|
}
|
|
1398
|
+
function median(values) {
|
|
1399
|
+
if (!values.length) return void 0;
|
|
1400
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
1401
|
+
const middle = (sorted.length - 1) / 2;
|
|
1402
|
+
return (sorted[Math.floor(middle)] + sorted[Math.ceil(middle)]) / 2;
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* Count created, merged, and closed changes per UTC bucket, from `start`
|
|
1406
|
+
* through `end`. Every bucket is present, so charts get zero gaps.
|
|
1407
|
+
*/
|
|
1408
|
+
function bucketActivity(changes, range) {
|
|
1409
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
1410
|
+
for (let ms = range.start.getTime(); ms <= range.end.getTime(); ms += range.stepMs) {
|
|
1411
|
+
const date = new Date(ms).toISOString().slice(0, range.keyLength);
|
|
1412
|
+
buckets.set(date, {
|
|
1413
|
+
closed: 0,
|
|
1414
|
+
created: 0,
|
|
1415
|
+
date,
|
|
1416
|
+
merged: 0
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1419
|
+
const add = (at, kind) => {
|
|
1420
|
+
if (!at || at < range.start) return;
|
|
1421
|
+
const bucket = buckets.get(at.toISOString().slice(0, range.keyLength));
|
|
1422
|
+
if (bucket) bucket[kind] += 1;
|
|
1423
|
+
};
|
|
1424
|
+
for (const change of changes) {
|
|
1425
|
+
add(change.openedAt, "created");
|
|
1426
|
+
add(change.mergedAt, "merged");
|
|
1427
|
+
if (change.state === "closed") add(change.closedAt, "closed");
|
|
1428
|
+
}
|
|
1429
|
+
return [...buckets.values()];
|
|
1430
|
+
}
|
|
1304
1431
|
/**
|
|
1305
|
-
*
|
|
1306
|
-
*
|
|
1307
|
-
*
|
|
1432
|
+
* Read conversation-tree costs for the given linked conversation ids. The
|
|
1433
|
+
* returned function sums each tree once, child Conversations included, so a
|
|
1434
|
+
* change linked to two Conversations of one tree pays for that tree once.
|
|
1308
1435
|
*/
|
|
1309
|
-
function
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
WHERE conversations.root_conversation_id IN (
|
|
1331
|
-
SELECT coalesce(roots.root_conversation_id, roots.conversation_id)
|
|
1332
|
-
FROM junior_conversations AS roots
|
|
1333
|
-
WHERE roots.conversation_id = ANY (conversation_ids.ids)
|
|
1334
|
-
)
|
|
1335
|
-
), 0::double precision)
|
|
1336
|
-
`;
|
|
1436
|
+
async function readTreeCosts(conversationIds) {
|
|
1437
|
+
const db = getDb();
|
|
1438
|
+
const conversations = juniorConversations;
|
|
1439
|
+
const ids = [...new Set(conversationIds)];
|
|
1440
|
+
const links = ids.length ? await db.select({
|
|
1441
|
+
conversationId: conversations.conversationId,
|
|
1442
|
+
rootId: sql`coalesce(${conversations.rootConversationId}, ${conversations.conversationId})`
|
|
1443
|
+
}).from(conversations).where(inArray(conversations.conversationId, ids)) : [];
|
|
1444
|
+
const rootOf = new Map(links.map((link) => [link.conversationId, link.rootId]));
|
|
1445
|
+
const rootIds = [...new Set(rootOf.values())];
|
|
1446
|
+
const trees = rootIds.length ? await db.select({
|
|
1447
|
+
costUsd: sql`coalesce(sum(${conversationUsageCostExpr(conversations.usage)}), 0)`.mapWith(Number),
|
|
1448
|
+
rootId: conversations.rootConversationId
|
|
1449
|
+
}).from(conversations).where(inArray(conversations.rootConversationId, rootIds)).groupBy(conversations.rootConversationId) : [];
|
|
1450
|
+
const costOf = new Map(trees.map((tree) => [tree.rootId, tree.costUsd]));
|
|
1451
|
+
return (linked) => {
|
|
1452
|
+
let total = 0;
|
|
1453
|
+
const roots = new Set(linked.flatMap((id) => rootOf.get(id) ?? []));
|
|
1454
|
+
for (const root of roots) total += costOf.get(root) ?? 0;
|
|
1455
|
+
return total;
|
|
1456
|
+
};
|
|
1337
1457
|
}
|
|
1338
1458
|
/** True when any linked conversation actor belongs to the subject user. */
|
|
1339
1459
|
function ownedByUserSql(conversationIds, userId) {
|
|
@@ -1358,166 +1478,45 @@ async function readCodeWindows(args) {
|
|
|
1358
1478
|
const windowStart = /* @__PURE__ */ new Date(args.nowMs - WINDOW_DAYS * DAY_MS);
|
|
1359
1479
|
const activityStart = startOfUtcDay(args.nowMs - 89 * DAY_MS);
|
|
1360
1480
|
const changes = juniorCodeChanges;
|
|
1361
|
-
const scope = changeScopeFilter(args);
|
|
1362
|
-
const conversationTreeCost = conversationTreeCostExpr();
|
|
1363
1481
|
const activityHourEnd = new Date(args.nowMs);
|
|
1364
1482
|
activityHourEnd.setUTCMinutes(0, 0, 0);
|
|
1365
1483
|
const activityHourStart = /* @__PURE__ */ new Date(activityHourEnd.getTime() - 167 * (DAY_MS / 24));
|
|
1366
|
-
const
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
AND recent_changes.closed_at >= ${windowStart}
|
|
1396
|
-
)::integer AS "closed",
|
|
1397
|
-
count(*) FILTER (WHERE recent_changes.state = 'open')::integer AS "open",
|
|
1398
|
-
(
|
|
1399
|
-
percentile_cont(0.5) WITHIN GROUP (
|
|
1400
|
-
ORDER BY extract(
|
|
1401
|
-
epoch FROM (recent_changes.merged_at - recent_changes.opened_at)
|
|
1402
|
-
) * 1000
|
|
1403
|
-
) FILTER (
|
|
1404
|
-
WHERE recent_changes.state = 'merged'
|
|
1405
|
-
AND recent_changes.merged_at >= ${windowStart}
|
|
1406
|
-
)
|
|
1407
|
-
)::double precision AS "medianMergeTimeMs",
|
|
1408
|
-
coalesce((
|
|
1409
|
-
SELECT ${conversationTreeCost}
|
|
1410
|
-
FROM (
|
|
1411
|
-
SELECT ARRAY(
|
|
1412
|
-
SELECT DISTINCT unnest(change_costs.ids)
|
|
1413
|
-
FROM change_costs
|
|
1414
|
-
) AS ids
|
|
1415
|
-
) AS conversation_ids
|
|
1416
|
-
), 0)::double precision AS "costUsd",
|
|
1417
|
-
(
|
|
1418
|
-
SELECT percentile_cont(0.5) WITHIN GROUP (
|
|
1419
|
-
ORDER BY change_costs.cost_usd
|
|
1420
|
-
)
|
|
1421
|
-
FROM change_costs
|
|
1422
|
-
WHERE change_costs.cost_usd > 0
|
|
1423
|
-
)::double precision AS "medianCostUsd"
|
|
1424
|
-
FROM recent_changes
|
|
1425
|
-
`),
|
|
1426
|
-
db.execute(sql`
|
|
1427
|
-
WITH days AS (
|
|
1428
|
-
SELECT generate_series(
|
|
1429
|
-
date_trunc('day', ${activityStart}::timestamptz AT TIME ZONE 'UTC'),
|
|
1430
|
-
date_trunc('day', ${windowEnd}::timestamptz AT TIME ZONE 'UTC'),
|
|
1431
|
-
interval '1 day'
|
|
1432
|
-
) AS day
|
|
1433
|
-
), daily AS (
|
|
1434
|
-
SELECT
|
|
1435
|
-
date_trunc('day', event_at AT TIME ZONE 'UTC') AS day,
|
|
1436
|
-
count(*) FILTER (WHERE kind = 'created')::integer AS created,
|
|
1437
|
-
count(*) FILTER (WHERE kind = 'merged')::integer AS merged,
|
|
1438
|
-
count(*) FILTER (WHERE kind = 'closed')::integer AS closed
|
|
1439
|
-
FROM (
|
|
1440
|
-
SELECT ${changes.openedAt} AS event_at, 'created'::text AS kind
|
|
1441
|
-
FROM ${changes}
|
|
1442
|
-
WHERE ${changes.openedAt} >= ${activityStart}
|
|
1443
|
-
${scope ? sql`AND ${scope}` : sql``}
|
|
1444
|
-
UNION ALL
|
|
1445
|
-
SELECT ${changes.mergedAt} AS event_at, 'merged'::text AS kind
|
|
1446
|
-
FROM ${changes}
|
|
1447
|
-
WHERE ${changes.mergedAt} >= ${activityStart}
|
|
1448
|
-
${scope ? sql`AND ${scope}` : sql``}
|
|
1449
|
-
UNION ALL
|
|
1450
|
-
SELECT ${changes.closedAt} AS event_at, 'closed'::text AS kind
|
|
1451
|
-
FROM ${changes}
|
|
1452
|
-
WHERE ${changes.state} = 'closed'
|
|
1453
|
-
AND ${changes.closedAt} >= ${activityStart}
|
|
1454
|
-
${scope ? sql`AND ${scope}` : sql``}
|
|
1455
|
-
) AS events
|
|
1456
|
-
GROUP BY date_trunc('day', event_at AT TIME ZONE 'UTC')
|
|
1457
|
-
)
|
|
1458
|
-
SELECT
|
|
1459
|
-
to_char(days.day, 'YYYY-MM-DD') AS "date",
|
|
1460
|
-
coalesce(daily.created, 0)::integer AS "created",
|
|
1461
|
-
coalesce(daily.merged, 0)::integer AS "merged",
|
|
1462
|
-
coalesce(daily.closed, 0)::integer AS "closed"
|
|
1463
|
-
FROM days
|
|
1464
|
-
LEFT JOIN daily ON daily.day = days.day
|
|
1465
|
-
ORDER BY days.day
|
|
1466
|
-
`),
|
|
1467
|
-
db.execute(sql`
|
|
1468
|
-
WITH hours AS (
|
|
1469
|
-
SELECT generate_series(
|
|
1470
|
-
date_trunc('hour', ${activityHourStart}::timestamptz AT TIME ZONE 'UTC'),
|
|
1471
|
-
date_trunc('hour', ${activityHourEnd}::timestamptz AT TIME ZONE 'UTC'),
|
|
1472
|
-
interval '1 hour'
|
|
1473
|
-
) AS hour
|
|
1474
|
-
), hourly AS (
|
|
1475
|
-
SELECT
|
|
1476
|
-
date_trunc('hour', event_at AT TIME ZONE 'UTC') AS hour,
|
|
1477
|
-
count(*) FILTER (WHERE kind = 'created')::integer AS created,
|
|
1478
|
-
count(*) FILTER (WHERE kind = 'merged')::integer AS merged,
|
|
1479
|
-
count(*) FILTER (WHERE kind = 'closed')::integer AS closed
|
|
1480
|
-
FROM (
|
|
1481
|
-
SELECT ${changes.openedAt} AS event_at, 'created'::text AS kind
|
|
1482
|
-
FROM ${changes}
|
|
1483
|
-
WHERE ${changes.openedAt} >= ${activityHourStart}
|
|
1484
|
-
${scope ? sql`AND ${scope}` : sql``}
|
|
1485
|
-
UNION ALL
|
|
1486
|
-
SELECT ${changes.mergedAt} AS event_at, 'merged'::text AS kind
|
|
1487
|
-
FROM ${changes}
|
|
1488
|
-
WHERE ${changes.mergedAt} >= ${activityHourStart}
|
|
1489
|
-
${scope ? sql`AND ${scope}` : sql``}
|
|
1490
|
-
UNION ALL
|
|
1491
|
-
SELECT ${changes.closedAt} AS event_at, 'closed'::text AS kind
|
|
1492
|
-
FROM ${changes}
|
|
1493
|
-
WHERE ${changes.state} = 'closed'
|
|
1494
|
-
AND ${changes.closedAt} >= ${activityHourStart}
|
|
1495
|
-
${scope ? sql`AND ${scope}` : sql``}
|
|
1496
|
-
) AS events
|
|
1497
|
-
GROUP BY date_trunc('hour', event_at AT TIME ZONE 'UTC')
|
|
1498
|
-
)
|
|
1499
|
-
SELECT
|
|
1500
|
-
to_char(hours.hour, 'YYYY-MM-DD"T"HH24') AS "date",
|
|
1501
|
-
coalesce(hourly.created, 0)::integer AS "created",
|
|
1502
|
-
coalesce(hourly.merged, 0)::integer AS "merged",
|
|
1503
|
-
coalesce(hourly.closed, 0)::integer AS "closed"
|
|
1504
|
-
FROM hours
|
|
1505
|
-
LEFT JOIN hourly ON hourly.hour = hours.hour
|
|
1506
|
-
ORDER BY hours.hour
|
|
1507
|
-
`)
|
|
1508
|
-
]);
|
|
1509
|
-
const summary = summaryRowSchema.parse(queryRows(summaryResult)[0] ?? {
|
|
1510
|
-
closed: 0,
|
|
1511
|
-
costUsd: 0,
|
|
1512
|
-
created: 0,
|
|
1513
|
-
medianCostUsd: null,
|
|
1514
|
-
medianMergeTimeMs: null,
|
|
1515
|
-
merged: 0,
|
|
1516
|
-
open: 0
|
|
1517
|
-
});
|
|
1518
|
-
const activityHours = z.array(activityDaySchema).parse(queryRows(activityHourResult));
|
|
1484
|
+
const rows = await db.select({
|
|
1485
|
+
closedAt: changes.closedAt,
|
|
1486
|
+
conversationIds: changes.conversationIds,
|
|
1487
|
+
mergedAt: changes.mergedAt,
|
|
1488
|
+
openedAt: changes.openedAt,
|
|
1489
|
+
state: changes.state
|
|
1490
|
+
}).from(changes).where(and(changeScopeFilter(args), or(gte(changes.openedAt, activityStart), gte(changes.mergedAt, activityStart), gte(changes.closedAt, activityStart), eq(changes.state, "open"))));
|
|
1491
|
+
const inWindow = (at) => at !== null && at >= windowStart;
|
|
1492
|
+
const created = rows.filter((row) => inWindow(row.openedAt));
|
|
1493
|
+
const merged = rows.filter((row) => inWindow(row.mergedAt));
|
|
1494
|
+
const closed = rows.filter((row) => row.state === "closed" && inWindow(row.closedAt));
|
|
1495
|
+
const createdConversationIds = created.flatMap((row) => row.conversationIds);
|
|
1496
|
+
const treeCost = await readTreeCosts(createdConversationIds);
|
|
1497
|
+
const changeCosts = created.map((row) => treeCost(row.conversationIds));
|
|
1498
|
+
const activityHours = bucketActivity(rows, {
|
|
1499
|
+
end: activityHourEnd,
|
|
1500
|
+
keyLength: 13,
|
|
1501
|
+
start: activityHourStart,
|
|
1502
|
+
stepMs: DAY_MS / 24
|
|
1503
|
+
});
|
|
1504
|
+
const summary = {
|
|
1505
|
+
closed: closed.length,
|
|
1506
|
+
costUsd: treeCost(createdConversationIds),
|
|
1507
|
+
created: created.length,
|
|
1508
|
+
medianCostUsd: median(changeCosts.filter((cost) => cost > 0)),
|
|
1509
|
+
medianMergeTimeMs: median(merged.flatMap((row) => row.state === "merged" && row.mergedAt ? [row.mergedAt.getTime() - row.openedAt.getTime()] : [])),
|
|
1510
|
+
merged: merged.length,
|
|
1511
|
+
open: rows.filter((row) => row.state === "open").length
|
|
1512
|
+
};
|
|
1519
1513
|
return {
|
|
1520
|
-
activityDays:
|
|
1514
|
+
activityDays: bucketActivity(rows, {
|
|
1515
|
+
end: startOfUtcDay(args.nowMs),
|
|
1516
|
+
keyLength: 10,
|
|
1517
|
+
start: activityStart,
|
|
1518
|
+
stepMs: DAY_MS
|
|
1519
|
+
}),
|
|
1521
1520
|
activityHours,
|
|
1522
1521
|
activitySixHours: sumUtcHoursIntoSixHours({
|
|
1523
1522
|
empty: (date) => ({
|
|
@@ -1567,74 +1566,42 @@ async function readCodeOverview(nowMs = Date.now()) {
|
|
|
1567
1566
|
const changes = juniorCodeChanges;
|
|
1568
1567
|
const repositories = juniorCodeRepositories;
|
|
1569
1568
|
const windows = await readCodeWindows({ nowMs });
|
|
1570
|
-
const
|
|
1571
|
-
const
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
SELECT
|
|
1598
|
-
${repositories.id} AS "id",
|
|
1599
|
-
${repositories.name} AS "name",
|
|
1600
|
-
${repositories.provider} AS "provider",
|
|
1601
|
-
${repositories.url} AS "url",
|
|
1602
|
-
count(recent_changes.id) FILTER (
|
|
1603
|
-
WHERE recent_changes.opened_at >= ${windows.windowStart}
|
|
1604
|
-
)::integer AS "created",
|
|
1605
|
-
count(recent_changes.id) FILTER (
|
|
1606
|
-
WHERE recent_changes.merged_at >= ${windows.windowStart}
|
|
1607
|
-
)::integer AS "merged",
|
|
1608
|
-
count(recent_changes.id) FILTER (
|
|
1609
|
-
WHERE recent_changes.state = 'closed'
|
|
1610
|
-
AND recent_changes.closed_at >= ${windows.windowStart}
|
|
1611
|
-
)::integer AS "closed",
|
|
1612
|
-
count(recent_changes.id) FILTER (
|
|
1613
|
-
WHERE recent_changes.state = 'open'
|
|
1614
|
-
)::integer AS "open",
|
|
1615
|
-
(
|
|
1616
|
-
SELECT percentile_cont(0.5) WITHIN GROUP (
|
|
1617
|
-
ORDER BY change_costs.cost_usd
|
|
1618
|
-
)
|
|
1619
|
-
FROM change_costs
|
|
1620
|
-
WHERE change_costs.repository_id = ${repositories.id}
|
|
1621
|
-
AND change_costs.cost_usd > 0
|
|
1622
|
-
)::double precision AS "medianCostUsd"
|
|
1623
|
-
FROM ${repositories}
|
|
1624
|
-
INNER JOIN recent_changes
|
|
1625
|
-
ON recent_changes.repository_id = ${repositories.id}
|
|
1626
|
-
GROUP BY ${repositories.id}
|
|
1627
|
-
ORDER BY "merged" DESC, "created" DESC, ${repositories.name} ASC
|
|
1628
|
-
LIMIT 25
|
|
1629
|
-
`), db.select(codeChangeReportColumns).from(changes).innerJoin(repositories, eq(changes.repositoryId, repositories.id)).where(or(gte(changes.openedAt, windows.windowStart), gte(changes.mergedAt, windows.windowStart), gte(changes.closedAt, windows.windowStart), eq(changes.state, "open"))).orderBy(desc(changes.updatedAt)).limit(25)]);
|
|
1569
|
+
const windowStart = windows.windowStart;
|
|
1570
|
+
const created = sql`count(*) filter (where ${changes.openedAt} >= ${windowStart})`.mapWith(Number);
|
|
1571
|
+
const merged = sql`count(*) filter (where ${changes.mergedAt} >= ${windowStart})`.mapWith(Number);
|
|
1572
|
+
const recent = or(gte(changes.openedAt, windowStart), gte(changes.mergedAt, windowStart), gte(changes.closedAt, windowStart), eq(changes.state, "open"));
|
|
1573
|
+
const [repositoryRows, recentChanges] = await Promise.all([db.select({
|
|
1574
|
+
closed: sql`count(*) filter (where ${changes.state} = 'closed' and ${changes.closedAt} >= ${windowStart})`.mapWith(Number),
|
|
1575
|
+
created,
|
|
1576
|
+
id: repositories.id,
|
|
1577
|
+
merged,
|
|
1578
|
+
name: repositories.name,
|
|
1579
|
+
open: sql`count(*) filter (where ${changes.state} = 'open')`.mapWith(Number),
|
|
1580
|
+
provider: repositories.provider,
|
|
1581
|
+
url: repositories.url
|
|
1582
|
+
}).from(repositories).innerJoin(changes, eq(changes.repositoryId, repositories.id)).where(recent).groupBy(repositories.id).orderBy(desc(merged), desc(created), asc(repositories.name)).limit(25), db.select(codeChangeReportColumns).from(changes).innerJoin(repositories, eq(changes.repositoryId, repositories.id)).where(recent).orderBy(desc(changes.updatedAt)).limit(25)]);
|
|
1583
|
+
const repositoryChanges = repositoryRows.length ? await db.select({
|
|
1584
|
+
conversationIds: changes.conversationIds,
|
|
1585
|
+
repositoryId: changes.repositoryId
|
|
1586
|
+
}).from(changes).where(and(gte(changes.openedAt, windowStart), inArray(changes.repositoryId, repositoryRows.map((row) => row.id)))) : [];
|
|
1587
|
+
const treeCost = await readTreeCosts(repositoryChanges.flatMap((change) => change.conversationIds));
|
|
1588
|
+
const repositoryCosts = /* @__PURE__ */ new Map();
|
|
1589
|
+
for (const change of repositoryChanges) {
|
|
1590
|
+
const cost = treeCost(change.conversationIds);
|
|
1591
|
+
if (cost <= 0) continue;
|
|
1592
|
+
const costs = repositoryCosts.get(change.repositoryId) ?? [];
|
|
1593
|
+
costs.push(cost);
|
|
1594
|
+
repositoryCosts.set(change.repositoryId, costs);
|
|
1595
|
+
}
|
|
1630
1596
|
return codeOverviewReportSchema.parse({
|
|
1631
1597
|
activityDays: windows.activityDays,
|
|
1632
1598
|
activityHours: windows.activityHours,
|
|
1633
1599
|
activitySixHours: windows.activitySixHours,
|
|
1634
1600
|
changes: recentChanges.map(codeChangeReport),
|
|
1635
1601
|
generatedAt: windows.windowEnd.toISOString(),
|
|
1636
|
-
repositories:
|
|
1602
|
+
repositories: repositoryRows.map((repository) => ({
|
|
1637
1603
|
...repository,
|
|
1604
|
+
medianCostUsd: median(repositoryCosts.get(repository.id) ?? []),
|
|
1638
1605
|
mergeRate: mergeRate(repository.merged, repository.closed),
|
|
1639
1606
|
url: repository.url ?? void 0
|
|
1640
1607
|
})),
|
|
@@ -2666,7 +2633,7 @@ async function readPeoplePluginReports(args) {
|
|
|
2666
2633
|
reports: [],
|
|
2667
2634
|
source: "plugins"
|
|
2668
2635
|
});
|
|
2669
|
-
const { getPluginProfileReports } = await import("./projection-
|
|
2636
|
+
const { getPluginProfileReports } = await import("./projection-B6VS7kbo.js").then((n) => n.jn);
|
|
2670
2637
|
return pluginOperationalReportFeedSchema.parse({
|
|
2671
2638
|
generatedAt: new Date(nowMs).toISOString(),
|
|
2672
2639
|
reports: await getPluginProfileReports({
|
|
@@ -3695,7 +3662,7 @@ function readDescriptionText(home) {
|
|
|
3695
3662
|
}
|
|
3696
3663
|
/** Read discovered skills for runtime diagnostics and the Automation editor. */
|
|
3697
3664
|
async function readSkillReports() {
|
|
3698
|
-
const { discoverSkills } = await import("./skills-
|
|
3665
|
+
const { discoverSkills } = await import("./skills-DXgd5Inh.js").then((n) => n.o);
|
|
3699
3666
|
const skills = await discoverSkills();
|
|
3700
3667
|
return skillReportsSchema.parse(skills.map((skill) => ({
|
|
3701
3668
|
name: skill.name,
|
|
@@ -3704,9 +3671,27 @@ async function readSkillReports() {
|
|
|
3704
3671
|
disableModelInvocation: skill.disableModelInvocation
|
|
3705
3672
|
})));
|
|
3706
3673
|
}
|
|
3674
|
+
/**
|
|
3675
|
+
* Read one discovered skill with the body its author wrote, so people can see
|
|
3676
|
+
* what the skill tells Junior. Returns null when no skill has that name.
|
|
3677
|
+
*/
|
|
3678
|
+
async function readSkillDetailReport(name) {
|
|
3679
|
+
const { discoverSkills, findSkillByName, parseSkillFile } = await import("./skills-DXgd5Inh.js").then((n) => n.o);
|
|
3680
|
+
const skill = findSkillByName(name, await discoverSkills());
|
|
3681
|
+
if (!skill) return null;
|
|
3682
|
+
const parsed = parseSkillFile(await fs.readFile(path.join(skill.skillPath, "SKILL.md"), "utf8"), skill.name);
|
|
3683
|
+
if (!parsed.ok) throw new Error(`Invalid skill file for ${skill.name}: ${parsed.error}`);
|
|
3684
|
+
return skillDetailReportSchema.parse({
|
|
3685
|
+
name: skill.name,
|
|
3686
|
+
description: skill.description,
|
|
3687
|
+
pluginProvider: skill.pluginProvider,
|
|
3688
|
+
disableModelInvocation: skill.disableModelInvocation,
|
|
3689
|
+
body: parsed.skill.body
|
|
3690
|
+
});
|
|
3691
|
+
}
|
|
3707
3692
|
/** Read safe configured plugin metadata for authenticated runtime diagnostics. */
|
|
3708
3693
|
async function readPlugins() {
|
|
3709
|
-
const { pluginCatalogRuntime } = await import("./catalog-runtime-
|
|
3694
|
+
const { pluginCatalogRuntime } = await import("./catalog-runtime-CpCmlD9L.js").then((n) => n.t);
|
|
3710
3695
|
return pluginsSchema.parse(pluginCatalogRuntime.getProviders().map((plugin) => ({
|
|
3711
3696
|
configKeys: plugin.manifest.configKeys ?? [],
|
|
3712
3697
|
description: plugin.manifest.description,
|
|
@@ -3718,7 +3703,7 @@ async function readPlugins() {
|
|
|
3718
3703
|
async function readRuntimeInfoReport() {
|
|
3719
3704
|
const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
|
|
3720
3705
|
import("./package-discovery-DJhGdS4c.js").then((n) => n.r),
|
|
3721
|
-
import("./catalog-runtime-
|
|
3706
|
+
import("./catalog-runtime-CpCmlD9L.js").then((n) => n.t),
|
|
3722
3707
|
readPlugins(),
|
|
3723
3708
|
readSkillReports()
|
|
3724
3709
|
]);
|
|
@@ -3735,7 +3720,7 @@ async function readRuntimeInfoReport() {
|
|
|
3735
3720
|
/** Read sanitized operational summaries contributed by plugins. */
|
|
3736
3721
|
async function readPluginOperationalReportFeed() {
|
|
3737
3722
|
const nowMs = Date.now();
|
|
3738
|
-
const { getPluginOperationalReports } = await import("./projection-
|
|
3723
|
+
const { getPluginOperationalReports } = await import("./projection-B6VS7kbo.js").then((n) => n.jn);
|
|
3739
3724
|
return pluginOperationalReportFeedSchema.parse({
|
|
3740
3725
|
source: "plugins",
|
|
3741
3726
|
generatedAt: new Date(nowMs).toISOString(),
|
|
@@ -3750,6 +3735,11 @@ function createJuniorApi(options = {}) {
|
|
|
3750
3735
|
app.get("/api/runtime", async () => jsonResponse(runtimeInfoReportSchema, await readRuntimeInfoReport()));
|
|
3751
3736
|
app.get("/api/plugins", async () => jsonResponse(pluginsSchema, await readPlugins()));
|
|
3752
3737
|
app.get("/api/skills", async () => jsonResponse(skillReportsSchema, await readSkillReports()));
|
|
3738
|
+
app.get("/api/skills/:name", async (context) => {
|
|
3739
|
+
const skill = await readSkillDetailReport(context.req.param("name"));
|
|
3740
|
+
if (!skill) throwApiError(404, "Skill not found.");
|
|
3741
|
+
return jsonResponse(skillDetailReportSchema, skill);
|
|
3742
|
+
});
|
|
3753
3743
|
app.get("/api/plugin-reports", async () => jsonResponse(pluginOperationalReportFeedSchema, await readPluginOperationalReportFeed()));
|
|
3754
3744
|
app.get("/api/stats", async () => jsonResponse(statsReportSchema, await readStatsReport()));
|
|
3755
3745
|
app.get("/api/reply-times", async () => jsonResponse(replyTimeSegmentsReportSchema, await readReplyTimeSegments()));
|