@sentry/junior 0.305.0 → 0.307.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-BpvbUki8.js → adapter-context-B69WPn6b.js} +2 -2
- package/dist/{admin-CoDt35ny.js → admin-nCJXMgkp.js} +2 -2
- package/dist/{agent-runner-C5d6rY5g.js → agent-runner-DdFcxAxG.js} +463 -303
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +7 -8
- package/dist/api.d.ts +19 -4
- package/dist/api.js +437 -310
- package/dist/{app-Cs157Zc5.d.ts → app-EZur8cVC.d.ts} +12 -3
- package/dist/app.d.ts +2 -2
- package/dist/app.js +532 -439
- package/dist/background-compaction-queue-BhEe4UfU.js +231 -0
- package/dist/{briefs-BRdznF7c.js → briefs-Dl9lxi7J.js} +3 -3
- package/dist/{catalog-runtime-J52Tej47.js → catalog-runtime-OXrv2Ewn.js} +1 -1
- package/dist/cli/chat.d.ts +1 -1
- package/dist/cli/chat.js +17 -16
- package/dist/cli/check.js +58 -48
- 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 +5 -5
- package/dist/cli/upgrade.d.ts +2 -2
- package/dist/cli/upgrade.js +3 -8
- package/dist/{config-CBZp0udd.js → config-362yMSIz.js} +183 -49
- package/dist/{connections-BYmuJ6Vm.js → connections-BJv3EjmB.js} +10 -8
- package/dist/{continue-in-slack-Cvot6S38.js → continue-in-slack-CFEevC7z.js} +5 -5
- package/dist/{conversation-BOqdRtUx.js → conversation--f85g4zL.js} +132 -132
- package/dist/{conversation-feed-CgpgP7yi.js → conversation-feed-BNs9KiqC.js} +1 -1
- package/dist/{conversation-privacy-D2pOzBNl.js → conversation-privacy-Tjj5P2W6.js} +1 -1
- package/dist/{conversation-turn-CI8WDpnK.js → conversation-turn-DU0_WDAr.js} +26 -72
- package/dist/{credential-sync-COqnZ1Dx.js → credential-sync-D6aFARKE.js} +28 -27
- package/dist/{db-DU84dCVu.js → db-Bcbd9zQc.js} +226 -18
- package/dist/{db-zbN5ZV_o.d.ts → db-C41UgdBj.d.ts} +1 -1
- package/dist/{executor-CFyrgOu1.js → executor-DBMBrpNV.js} +137 -33
- package/dist/{history-m2-ceTTX.js → history-N7IVbUom.js} +5 -1
- package/dist/{install-CQ76CfRw.js → install-CgoAbzfF.js} +2 -2
- package/dist/instrumentation.js +2 -2
- package/dist/{lineage-DLd2UxVP.js → lineage-CsZDmz3e.js} +2 -2
- package/dist/{logging-BPNTQVFu.js → logging-CHCuQ5iz.js} +1 -1
- package/dist/{message-BWJLeQ5e.js → message-B8vCbZZB.js} +8 -8
- package/dist/{model-input-DoM9Ht-d.js → model-input-Xluiy-1W.js} +3 -3
- package/dist/nitro.d.ts +2 -2
- package/dist/nitro.js +3 -4
- package/dist/{oauth-callback-server-DeHbnAQl.js → oauth-callback-server-BUuNvfvu.js} +2 -2
- package/dist/{oauth-relay-DAmfVmJu.js → oauth-relay-DGAZzg9m.js} +1 -1
- package/dist/{plugins-B_0Cr0MO.d.ts → plugins-fBrz8PCV.d.ts} +2 -0
- package/dist/{projection-CcFBVFUo.js → projection-xPpvqexa.js} +13423 -11432
- package/dist/{prompt-C5LREK2p.js → prompt-D8u4jFs_.js} +15 -7
- package/dist/{registry-BjZZqKqi.js → registry-D20hG3r6.js} +19 -9
- package/dist/{resolve-CeJgXuH1.js → resolve-BhCySRCW.js} +3 -3
- package/dist/{result-icDrueyB.js → result-DddO63S9.js} +13 -11
- package/dist/{runner-nVfMkMMB.js → runner-DQR9vYce.js} +13 -15
- package/dist/{sandbox-egress-signals-H9vQ5qRf.js → sandbox-egress-signals-DFlNUOnK.js} +1 -1
- package/dist/{automation-CuA3yEcD.js → schedule-BG1tEbRF.js} +380 -8
- package/dist/{schema-CKcu-IK6.d.ts → schema-CRXcj4fj.d.ts} +420 -143
- package/dist/{schema-Bx0Mlo32.js → schema-D4jdesIu.js} +62 -8
- package/dist/{service-account-DU5865XA.js → service-account-Bv5QwrEq.js} +8 -6
- package/dist/{service-account-Dw06p3zm.js → service-account-CNfycv0z.js} +3 -3
- package/dist/{session-stop-uotLtp4g.js → session-stop-BDdwyZaa.js} +878 -171
- package/dist/{skills-Bex1EaO5.js → skills-63i1Bcv1.js} +32 -28
- package/dist/{slack-conversation-unfurl-EPG3riWF.js → slack-conversation-unfurl-DtpBUlUu.js} +10 -9
- package/dist/{spawn-CoD3vDuS.js → spawn-mwimEY9_.js} +6 -6
- package/dist/{state-nCR4Muhn.js → state-BBn9L6gC.js} +4 -4
- package/dist/{stop-BFVd0P0m.js → stop-Da-Ug7tg.js} +172 -239
- package/dist/{store-Ca6G962n.js → store-CdWg2r2L.js} +5 -5
- package/dist/{background-compaction-queue-BTqMIfTA.js → task-queue-BcjAYWyB.js} +164 -180
- package/dist/{task-runner-xsOPIxCZ.js → task-runner-CoXmMlsW.js} +13 -11
- package/dist/{thread-context-BOvZhsKK.js → thread-context-ZPGqOjW7.js} +8 -91
- package/dist/turn-session-routing-DFYak28Q.js +263 -0
- package/dist/{turn-user-message-BrhuyYrH.js → turn-user-message-B1S8nOnG.js} +3 -3
- package/dist/users-DDbENg-I.js +181 -0
- package/dist/{validation-BnY9K5WB.js → validation-fl21ps-k.js} +1 -1
- package/dist/{version-qROlRQGF.js → version-DCdMMx_0.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-CxUiOraX.js → viewer-DN_xzVKj.js} +3 -3
- package/dist/{warmup--Gkz7iB-.js → warmup-CxhEhm71.js} +842 -532
- package/dist/{web-message-id-lNodcCOI.js → web-message-id-BT8Mg8LL.js} +16 -1
- package/dist/{worker-DJ8d9fmD.js → worker-Btb1SB5h.js} +8 -7
- package/migrations/0114_plan_items.sql +22 -0
- package/migrations/0115_automation_creator_slack_index.sql +1 -0
- package/migrations/0116_conversation_event_search.sql +25 -0
- package/migrations/0117_automation_last_run.sql +46 -0
- package/migrations/0118_automation_last_run_index.sql +1 -0
- package/migrations/0119_money_micro_usd.sql +29 -0
- package/migrations/0120_conversation_cost_micro_usd.sql +8 -0
- package/migrations/meta/0114_snapshot.json +5203 -0
- package/migrations/meta/0115_snapshot.json +5225 -0
- package/migrations/meta/0116_snapshot.json +5388 -0
- package/migrations/meta/0117_snapshot.json +5413 -0
- package/migrations/meta/0118_snapshot.json +5428 -0
- package/migrations/meta/0119_snapshot.json +5441 -0
- package/migrations/meta/0120_snapshot.json +5441 -0
- package/migrations/meta/_journal.json +49 -0
- package/package.json +10 -9
- package/dist/queue-B2AAL3ym.js +0 -115
- package/dist/schedule-cP0AACm1.js +0 -344
- package/dist/secrets-DHaJ5TTn.js +0 -18
- package/dist/task-queue-BLPZU6kC.js +0 -89
- package/dist/turn-session-routing-2bW2qfeb.js +0 -1792
package/dist/api.js
CHANGED
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
import { V as escapeXml,
|
|
2
|
-
import { A as conversationKindFromRow, C as withConversationMutationLock, X as
|
|
3
|
-
import {
|
|
4
|
-
import { C as createConversationMessageBodySchema,
|
|
5
|
-
import { $ as testNotificationResponseSchema, A as startServiceAccountSignInResponseSchema, At as
|
|
6
|
-
import { S as skillDetailReportSchema, a as cancelConversationPendingMessagesResponseSchema, b as pluginsSchema, d as conversationUnchangedDetailWithMailboxSchema, f as steerConversationPendingMessagesBodySchema, h as pluginOperationalReportFeedSchema, i as cancelConversationPendingMessagesBodySchema, m as healthReportSchema, n as conversationFeedQuerySchema, o as conversationDetailWithMailboxReportSchema, p as steerConversationPendingMessagesResponseSchema, r as conversationFeedSchema, u as conversationPendingMessagesReportSchema, w as skillReportsSchema, x as runtimeInfoReportSchema } from "./conversation-feed-
|
|
7
|
-
import {
|
|
8
|
-
import { $
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { i as continueConversationInSlack, r as canContinueInSlack, t as BUSY } from "./continue-in-slack-
|
|
1
|
+
import { V as escapeXml, n as botConfig, ut as getAttachmentStorage } from "./config-362yMSIz.js";
|
|
2
|
+
import { $ as getStateAdapter, A as conversationKindFromRow, C as withConversationMutationLock, X as createCache, a as getConversationStore, dt as microUsdToUsd, ht as conversationUsageCostExpr, mt as conversationRangeColumns, o as getDb, pt as conversationAggregateColumns, s as getSqlExecutor, ut as microUsdSql, wt as nextDetailVersion, y as loadConversationSlackTenantIds } from "./db-Bcbd9zQc.js";
|
|
3
|
+
import { Dt as AttachmentUploadError, Ft as listOwnedWatches, Gn as emptyResponse, It as listChildAgents, Kn as jsonResponse, Oi as countOwnedAutomationsNeedingAttention, Tt as webActorFromUser, Wn as setConversationSubscription, _ as closeBreaker, ai as deleteViewerTask, ci as ViewerTaskNotFoundError, di as readViewerAutomationRuns, fi as readViewerAutomationSummary, ft as reportConversationRead, g as breakerStates, h as savingsTotals, ii as changeViewerAutomationLifecycle, jt as writeAttachmentUpload, kt as createAttachmentUpload, lt as archiveConversation, mi as readViewerAutomations, oi as readViewerAutomationEdit, pi as readViewerAutomationVersions, qn as throwApiError, si as updateViewerAutomation, ti as activateViewerAutomationVersion, u as SAVINGS_NAMESPACE, ui as readViewerAutomationExecutions, v as connectedState, w as readStats, xi as AutomationEditError, yt as acceptsWebMessages } from "./warmup-CxhEhm71.js";
|
|
4
|
+
import { C as createConversationMessageBodySchema, H as renameConversationResponseSchema, S as createConversationBodySchema, T as forkConversationResponseSchema, U as conversationReadPositionSchema, V as renameConversationBodySchema, Z as MAX_ATTACHMENT_BYTES, f as conversationEventPageSchema, l as conversationDetailQuerySchema, m as conversationParamsSchema, 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 forkConversationBodySchema } from "./conversation--f85g4zL.js";
|
|
5
|
+
import { $ as testNotificationResponseSchema, A as startServiceAccountSignInResponseSchema, At as objectLinksReportSchema, B as personParamsSchema, Bt as conversationSubscriptionResponseSchema, C as cacheWarmingSavingsRefillResponseSchema, Ct as conversationChildAgentsReportSchema, D as serviceAccountListSchema, Dt as attachObjectLinkBodySchema, E as disconnectServiceAccountResponseSchema, F as personalTokenParamsSchema, Ft as archiveConversationBodySchema, G as locationParamsSchema, Gt as reorderPinnedConversationsBodySchema, Ht as conversationDeliveryResponseSchema, I as revokePersonalTokenResponseSchema, It as archiveConversationResponseSchema, J as activitySixHours$1, Jt as conversationCatchUpSchema, K as activityDays$1, Kt as reorderPinnedConversationsResponseSchema, L as actorDirectoryReportSchema, Lt as archiveDoneConversationsResponseSchema, M as createdPersonalTokenSchema, Mt as conversationStatsReportSchema, N as personalTokenListSchema, O as serviceAccountParamsSchema, Ot as attachObjectLinkResponseSchema, Pt as conversationOutlineSchema, Q as pushSubscriptionDeleteBodySchema, R as actorProfileReportSchema, Rt as conversationAutoArchiveSchema, S as cacheWarmingSavingsQuerySchema, T as closeCacheWarmingBreakerResponseSchema, Tt as continueConversationInSlackResponseSchema, U as locationDetailReportSchema, Ut as pinConversationBodySchema, V as personalSpendReportSchema, Vt as conversationDeliveryBodySchema, W as locationDirectoryReportSchema, Wt as pinConversationResponseSchema, X as notificationSettingsSchema, Xt as attachmentUploadSchema, Yt as attachmentUploadParamsSchema, Z as pushSubscriptionBodySchema, Zt as createAttachmentUploadBodySchema, _ as reviewItemParamsSchema, _t as conversationPlanReportSchema, b as cacheWarmingBreakerListSchema, c as workspaceListSchema, d as workspaceSchema, dt as codeRepositoryParamsSchema, et as connectionListSchema, f as reviewItemActionSchema, ft as codeRepositoryQuerySchema, g as reviewItemListSchema, gt as conversationPlanItemSchema, h as reviewItemListQuerySchema, ht as personCodeQuerySchema, i as statsReportSchema, it as startConnectionResponseSchema, j as createPersonalTokenBodySchema, jt as stopConversationTurnResponseSchema, kt as objectLinksQuerySchema, 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 conversationCatchUpBodySchema, rt as disconnectConnectionResponseSchema, s as workspaceBodySchema, t as versionsQuerySchema, tt as connectionParamsSchema, ut as codePersonReportSchema, v as reviewItemSchema, vt as planItemParamsSchema, w as cacheWarmingSavingsReportSchema, wt as continueConversationInSlackBodySchema, x as cacheWarmingBreakerParamsSchema, xt as conversationWatchesReportSchema, y as reviewItemWaitingConversationsSchema, yt as planItemStatusBodySchema, z as avatarParamsSchema, zt as conversationSubscriptionBodySchema } from "./schema-D4jdesIu.js";
|
|
6
|
+
import { S as skillDetailReportSchema, a as cancelConversationPendingMessagesResponseSchema, b as pluginsSchema, d as conversationUnchangedDetailWithMailboxSchema, f as steerConversationPendingMessagesBodySchema, h as pluginOperationalReportFeedSchema, i as cancelConversationPendingMessagesBodySchema, m as healthReportSchema, n as conversationFeedQuerySchema, o as conversationDetailWithMailboxReportSchema, p as steerConversationPendingMessagesResponseSchema, r as conversationFeedSchema, u as conversationPendingMessagesReportSchema, w as skillReportsSchema, x as runtimeInfoReportSchema } from "./conversation-feed-BNs9KiqC.js";
|
|
7
|
+
import { G as isAllowedDomain, H as addConversationNote, S as setPlanItemStatusByUser, _ as readUserCustomization, ft as isExperimentalFeatureEnabled, mt as getEventCatalog, q as parseEmail, v as saveUserCustomization, x as listPlanItems } from "./session-stop-BDdwyZaa.js";
|
|
8
|
+
import { $r as reviewItemReaderForUser, Ar as countOpenReviewItemsForUser, Bi as updateWorkspace, Cr as saveNotificationSchedule, Ea as workspaceRepoCheckoutPath, Fi as deleteWorkspace, Hc as AutomationConflictError, Ii as getWorkspace, Is as escapeSlackMrkdwnText, Jr as itemNeedsUser, Ka as createConversationAccessReader, Ki as create, Lr as listWaitingConversations, Ls as formatSlackLink, Nn as getPlugins, No as createPluginAnnotations, Pi as createWorkspace, Po as listConversationAnnotations, Ri as listWorkspaces, Rr as reviewItemsNeedingUserVersionQuery, Sr as readNotificationSchedule, Tr as isPausedBySlack, Ua as createPluginLogger, Ur as canActOnReviewItem, Vi as WorkspaceValidationError, _r as readWebPushConfig, ac as getDashboardSettingsLink, bn as createUserTokenStore, bo as readLiveAttachment, br as deletePushSubscription, ec as getDashboardConversationLink, ei as reviewItemReaderForUserInConversation, fs as postSlackMessage, ho as readSlackAttachmentSource, jr as countReviewItemsNeedingUserBySubject, nl as readAutomationTitlesByConversationId, qa as readConversationAccessFromSql, qi as hash, qr as isOnlyAssignee, ro as readConversationEventPage, to as readConversationBriefThrough, ul as createPluginCache, vr as sendPushNotificationToUser, wa as SANDBOX_RUNTIME, wc as automationEventCatalog, wr as savePushSubscription, xr as listPushSubscriptions, yr as resolveNotificationTimezone, z as createPluginEgress, zi as listWorkspacesByRepository, zr as searchReviewItems } from "./projection-xPpvqexa.js";
|
|
9
|
+
import { A as actOnReviewItem, B as readSavingsRefill, Ct as decodeImageId, D as resolveMentions, E as requireConversationPendingMessages, G as readHealthReport, H as startSavingsRefill, I as setConversationAutoArchive, J as readObjectLinkTypes, K as OBJECT_LINK_TTL_MS, L as DEFAULT_USER_SETTINGS, M as readReviewItemForUser, P as archiveViewerDoneConversations, R as readUserSettings, St as IMAGE_WIDTHS, X as resolveObjectLinks, Y as resolveObjectLinkNow, Z as guardedFetch, _ as readConversationEvents, a as decodePageCursor, b as createConversationForViewer, bt as readFirstHumanMessageTexts, c as reorderPinnedConversations, d as childAgentTotalsReport, f as readConversationTreeMetricsFromSql, g as keepQuickQuestionForViewer, h as forkConversationForViewer, i as readConversationFeed, k as ReviewItemActionError, l as readConversationDetail, m as readConversationDetailEtag, n as steerConversationPendingMessagesForViewer, nt as getProductionSlackAdapter, o as encodePageCursor, p as conversationVersionQuery, q as readLinkObjectType, r as conversationFeedVersionQuery, s as pinConversation, t as stopConversationTurnForViewer, u as readConversationAuxiliaryCostsFromSql, w as cancelConversationPendingMessagesForViewer, x as requireWebMessageConversation, xt as createViewerMcp, y as appendConversationMessageForViewer, yt as conversationSummaryFromStoredConversation, z as updateUserSettings } from "./stop-Da-Ug7tg.js";
|
|
10
|
+
import { d as completeText, n as briefEntriesFromReportEvents } from "./prompt-D8u4jFs_.js";
|
|
11
|
+
import { A as resumeConversationDelivery, D as canPauseConversationDelivery, M as readAttachmentContent, N as previewOriginBelongsTo, _ as createSlackReviewItemShow, j as AttachmentDownloadError, k as pauseConversationDelivery } from "./agent-runner-DdFcxAxG.js";
|
|
12
|
+
import { _ as runBestEffort, h as logWarn, m as logInfo, p as logException } from "./logging-CHCuQ5iz.js";
|
|
13
|
+
import { t as runWithSlackInstallation } from "./adapter-context-B69WPn6b.js";
|
|
14
|
+
import { A as juniorConversationEvents, B as juniorUsers, E as juniorConversationBriefs, N as juniorCodeChanges, O as juniorConversationMetrics, P as juniorCodeRepositories, R as juniorConversations, V as juniorDestinations, j as juniorApiTokens, z as juniorIdentities } from "./executor-DBMBrpNV.js";
|
|
15
|
+
import { i as continueConversationInSlack, r as canContinueInSlack, t as BUSY } from "./continue-in-slack-CFEevC7z.js";
|
|
16
16
|
import { f as parseSlackTeamId, u as parseSlackChannelId } from "./actor-D2iXzvlN.js";
|
|
17
|
-
import { A as
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import { o as getSandboxResources } from "./install-CQ76CfRw.js";
|
|
28
|
-
import { t as getCachedSnapshot } from "./resolve-CeJgXuH1.js";
|
|
29
|
-
import { o as getVercelConversationWorkQueue } from "./background-compaction-queue-BTqMIfTA.js";
|
|
17
|
+
import { A as HOUR_MS$1, F as sumUtcHoursIntoSixHours, I as trailingUtcDayWindow, L as trailingUtcHourWindow, M as fillUtcHours, N as fillUtcSixHours, O as apiErrorSchema, P as startOfUtcHour, R as trailingUtcSixHourWindow, _ as userCustomizationSchema, f as INLINE_VIDEO_TYPES, j as fillUtcDays, k as DAY_MS$2, m as detectImageMediaType, p as INPUT_IMAGE_TYPES, x as isOpenPlanItemStatus, z as utcHourKey } from "./web-message-id-BT8Mg8LL.js";
|
|
18
|
+
import { a as startConnection, n as isConnectableProvider, r as listConnections, s as htmlCallbackResponse, t as disconnectConnection } from "./connections-BJv3EjmB.js";
|
|
19
|
+
import { p as credentialContextForActor } from "./registry-D20hG3r6.js";
|
|
20
|
+
import { c as readViewerAvatarUrl, d as updateViewerDisplayName, l as resolveViewerUser, m as readAvatarFetch, t as findUserByEmail } from "./viewer-DN_xzVKj.js";
|
|
21
|
+
import { n as finishServiceAccountSignIn, o as serviceAccountPlugins, r as getServiceAccountStatus, s as startServiceAccountSignIn, t as disconnectServiceAccount } from "./service-account-Bv5QwrEq.js";
|
|
22
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-OXrv2Ewn.js";
|
|
23
|
+
import { B as compileScheduleIntent, C as automationUpdateSchema, E as automationVersionParamsSchema, Q as automationTaskText, S as automationSummarySchema, T as automationVersionListSchema, _ as automationRunListSchema, a as automationEditSchema, b as automationScheduleIntentSchema, d as automationLifecycleSchema, g as automationParamsSchema, i as automationEditErrorSchema, m as automationListQuerySchema, o as automationEventCatalogSchema, p as automationListPageSchema, r as notificationScheduleSchema, s as automationExecutionListSchema, w as automationVersionActivateSchema, x as automationSchedulePreviewSchema, z as ScheduleIntentError } from "./schedule-BG1tEbRF.js";
|
|
24
|
+
import { o as getSandboxResources } from "./install-CgoAbzfF.js";
|
|
25
|
+
import { t as getCachedSnapshot } from "./resolve-BhCySRCW.js";
|
|
26
|
+
import { m as getVercelConversationWorkQueue } from "./background-compaction-queue-BhEe4UfU.js";
|
|
30
27
|
import { Hono } from "hono";
|
|
31
28
|
import * as z from "zod";
|
|
32
29
|
import path from "node:path";
|
|
@@ -246,18 +243,49 @@ async function catchUpOnConversation(viewer, conversationId, range) {
|
|
|
246
243
|
...conversation.title ? { title: conversation.title } : void 0
|
|
247
244
|
});
|
|
248
245
|
}
|
|
246
|
+
// src/chat/slack/detach-notice.ts
|
|
247
|
+
function detachNoticeText(conversationId, actorName) {
|
|
248
|
+
const url = getDashboardConversationLink(conversationId);
|
|
249
|
+
const dashboard = url ? formatSlackLink(url, "the dashboard") : "the dashboard";
|
|
250
|
+
return `${escapeSlackMrkdwnText(actorName)} detached this conversation from Slack. Updates continue in ${dashboard}. Mention me here to attach it again.`;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Tell a Slack thread once that its Conversation was detached, so people
|
|
254
|
+
* there know replies stopped. Call it only when the detach changed state.
|
|
255
|
+
* Run it inside the Slack installation of `location.teamId`.
|
|
256
|
+
*/
|
|
257
|
+
async function postSlackDetachNotice(args) {
|
|
258
|
+
const { location } = args;
|
|
259
|
+
if (!location.threadTs) return;
|
|
260
|
+
await postSlackMessage({
|
|
261
|
+
channelId: location.channelId,
|
|
262
|
+
text: detachNoticeText(args.conversationId, args.actorName),
|
|
263
|
+
threadTs: location.threadTs
|
|
264
|
+
});
|
|
265
|
+
}
|
|
249
266
|
// src/api/conversations/delivery.ts
|
|
250
267
|
/**
|
|
251
268
|
* Detach a root from its Location, or attach it again. Only a participant
|
|
252
269
|
* can change it, the same as rename. A mention in the Location attaches it
|
|
253
|
-
* again too.
|
|
270
|
+
* again too. Each detach tells the Slack thread once.
|
|
254
271
|
*/
|
|
255
272
|
async function setConversationDeliveryForViewer(viewer, conversationId, body) {
|
|
256
273
|
const conversation = (await readConversationAccessFromSql(getDb(), [conversationId], viewer)).get(conversationId)?.isParticipant ? await getConversationStore().get({ conversationId }) : void 0;
|
|
257
274
|
if (!conversation) throwApiError(404, "Conversation not found.");
|
|
258
275
|
if (!canPauseConversationDelivery(conversation)) throwApiError(409, "Only a conversation with a Slack thread can detach.");
|
|
259
|
-
if (body.paused)
|
|
260
|
-
|
|
276
|
+
if (body.paused) {
|
|
277
|
+
const detached = await pauseConversationDelivery(conversationId);
|
|
278
|
+
const location = conversation.location;
|
|
279
|
+
if (detached && location?.provider === "slack") await runBestEffort(() => runWithSlackInstallation({
|
|
280
|
+
adapter: getProductionSlackAdapter(),
|
|
281
|
+
installation: { teamId: location.teamId },
|
|
282
|
+
task: () => postSlackDetachNotice({
|
|
283
|
+
actorName: viewer.displayName ?? viewer.email,
|
|
284
|
+
conversationId,
|
|
285
|
+
location
|
|
286
|
+
})
|
|
287
|
+
}), "conversation.detach_notice.failed", { "app.conversation.id": conversationId });
|
|
288
|
+
} else await resumeConversationDelivery(conversationId);
|
|
261
289
|
return { paused: body.paused };
|
|
262
290
|
}
|
|
263
291
|
// src/chat/conversations/sql/title.ts
|
|
@@ -565,33 +593,41 @@ async function writeAttachmentUploadForViewer(args) {
|
|
|
565
593
|
// src/api/conversations/outline.ts
|
|
566
594
|
const payload = juniorConversationEvents.payload;
|
|
567
595
|
/**
|
|
568
|
-
* List the person messages of a whole Conversation
|
|
569
|
-
*
|
|
570
|
-
* outline cannot build its items from the
|
|
596
|
+
* List the person messages of a whole Conversation, each with its author and
|
|
597
|
+
* the start of Junior's reply, for the dashboard outline. The dashboard transcript loads
|
|
598
|
+
* only the latest pages, so the outline cannot build its items from the
|
|
599
|
+
* loaded rows alone.
|
|
571
600
|
*
|
|
572
601
|
* It uses the same rules as the transcript: Event messages are not person
|
|
573
602
|
* messages, and a message that does not mention Junior is thread context.
|
|
574
|
-
* The
|
|
575
|
-
* messages, so the cost grows with the person messages, not all events.
|
|
603
|
+
* The cost grows with the messages, not all events.
|
|
576
604
|
*/
|
|
577
605
|
async function readConversationOutline(conversationId, options = {}) {
|
|
578
606
|
const access = (await readConversationAccessFromSql(getDb(), [conversationId], options.viewer)).get(conversationId);
|
|
579
607
|
if (!access) return void 0;
|
|
580
608
|
if (!access.canViewPrivateContent) return { items: [] };
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
text: sql`left(${payload}->>'text', ${200})`
|
|
584
|
-
}).from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, conversationId), sql`${juniorConversationEvents.type} = 'message'`, sql`${payload}->>'role' = 'user'`, sql`${payload}->'meta'->>'eventType' is null`, sql`coalesce(${payload}->'meta'->>'explicitMention', 'true') <> 'false'`)).orderBy(asc(juniorConversationEvents.seq))).flatMap((row) => {
|
|
609
|
+
const [rows, replies] = await Promise.all([readMessages(conversationId, "user", sql`${payload}->'meta'->>'eventType' is null`, sql`coalesce(${payload}->'meta'->>'explicitMention', 'true') <> 'false'`), readMessages(conversationId, "assistant")]);
|
|
610
|
+
const items = rows.flatMap((row) => {
|
|
585
611
|
const text = withoutCutToken(row.text).trim();
|
|
586
|
-
|
|
612
|
+
if (!text) return [];
|
|
613
|
+
return [{
|
|
614
|
+
createdAt: row.createdAt.toISOString(),
|
|
587
615
|
seq: row.seq,
|
|
588
|
-
text
|
|
589
|
-
|
|
616
|
+
text,
|
|
617
|
+
...row.authorIdentityId && row.authorIdentityId !== "system" ? { actorIdentityId: row.authorIdentityId } : void 0,
|
|
618
|
+
...row.agentInvocationId ? { agentInvocationId: row.agentInvocationId } : void 0
|
|
619
|
+
}];
|
|
590
620
|
});
|
|
621
|
+
let itemIndex = -1;
|
|
622
|
+
for (const reply of replies) {
|
|
623
|
+
while (items[itemIndex + 1] && items[itemIndex + 1].seq < reply.seq) itemIndex += 1;
|
|
624
|
+
const text = withoutCutToken(reply.text).trim();
|
|
625
|
+
if (itemIndex >= 0 && text) items[itemIndex].reply = text;
|
|
626
|
+
}
|
|
591
627
|
const tenantId = (await loadConversationSlackTenantIds(getSqlExecutor(), [conversationId])).get(conversationId);
|
|
592
628
|
const mentions = await resolveMentions(getSqlExecutor(), items.map((item) => ({
|
|
593
629
|
tenantId,
|
|
594
|
-
texts: [item.text]
|
|
630
|
+
texts: [item.text, item.reply]
|
|
595
631
|
})));
|
|
596
632
|
return { items: items.map((item, index) => mentions[index].length > 0 ? {
|
|
597
633
|
...item,
|
|
@@ -599,6 +635,19 @@ async function readConversationOutline(conversationId, options = {}) {
|
|
|
599
635
|
} : item) };
|
|
600
636
|
}
|
|
601
637
|
/**
|
|
638
|
+
* Read the cut text of one role's messages in seq order. The
|
|
639
|
+
* `message_role_idx` index reads only these messages, not all events.
|
|
640
|
+
*/
|
|
641
|
+
function readMessages(conversationId, role, ...filters) {
|
|
642
|
+
return getDb().select({
|
|
643
|
+
agentInvocationId: sql`${payload}->'meta'->>'agentInvocationId'`,
|
|
644
|
+
authorIdentityId: sql`coalesce(${payload}->>'authorIdentityId', ${juniorConversationEvents.actorIdentityId})`,
|
|
645
|
+
createdAt: juniorConversationEvents.createdAt,
|
|
646
|
+
seq: juniorConversationEvents.seq,
|
|
647
|
+
text: sql`coalesce(left(${payload}->>'text', ${200}), '')`
|
|
648
|
+
}).from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, conversationId), sql`${juniorConversationEvents.type} = 'message'`, sql`${payload}->>'role' = ${role}`, ...filters)).orderBy(asc(juniorConversationEvents.seq));
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
602
651
|
* Repair a Slack token that the length cut split. A cut mention, such as
|
|
603
652
|
* `<@U12`, cannot resolve, so it is dropped. A cut link keeps its URL text,
|
|
604
653
|
* so a message that is only a long link still has a title.
|
|
@@ -736,7 +785,7 @@ function emptyStatsItem(label) {
|
|
|
736
785
|
label
|
|
737
786
|
};
|
|
738
787
|
}
|
|
739
|
-
function addUsd
|
|
788
|
+
function addUsd(current, next) {
|
|
740
789
|
return Math.round(((current ?? 0) + next) * 0xe8d4a51000) / 0xe8d4a51000;
|
|
741
790
|
}
|
|
742
791
|
function actorLabel$1(row) {
|
|
@@ -763,7 +812,7 @@ function addAggregate$1(map, label, row) {
|
|
|
763
812
|
item.durationMs += row.durationMs;
|
|
764
813
|
item.failed += row.failed;
|
|
765
814
|
if (row.tokens !== null) item.tokens = (item.tokens ?? 0) + row.tokens;
|
|
766
|
-
if (row.costUsd !== null) item.costUsd = addUsd
|
|
815
|
+
if (row.costUsd !== null) item.costUsd = addUsd(item.costUsd, row.costUsd);
|
|
767
816
|
map.set(label, item);
|
|
768
817
|
}
|
|
769
818
|
function statsItems$1(map) {
|
|
@@ -818,7 +867,7 @@ function applyMetricBuckets(rows, metrics, outcomes) {
|
|
|
818
867
|
const row = byDate.get(metric.date) ?? emptyMetricRow(metric.date);
|
|
819
868
|
if (metric.metric === "cached_input_tokens") row.cachedInputTokens = metric.value;
|
|
820
869
|
else if (metric.metric === "cache_creation_tokens") row.cacheCreationTokens = metric.value;
|
|
821
|
-
else if (metric.metric === "
|
|
870
|
+
else if (metric.metric === "cost_micro_usd") row.costUsd = microUsdToUsd(metric.value);
|
|
822
871
|
else if (metric.metric === "duration_ms") row.durationMs = metric.value;
|
|
823
872
|
else if (metric.metric === "input_tokens") row.inputTokens = metric.value;
|
|
824
873
|
else if (metric.metric === "total_tokens") row.tokens = metric.value;
|
|
@@ -833,12 +882,12 @@ function metricPoint(date, row) {
|
|
|
833
882
|
durationMs: row?.durationMs ?? 0,
|
|
834
883
|
...row?.cachedInputTokens !== null && row?.cachedInputTokens !== void 0 ? { cachedInputTokens: row.cachedInputTokens } : void 0,
|
|
835
884
|
...row?.cacheCreationTokens !== null && row?.cacheCreationTokens !== void 0 ? { cacheCreationTokens: row.cacheCreationTokens } : void 0,
|
|
836
|
-
...row?.costUsd !== null && row?.costUsd !== void 0 ? { costUsd:
|
|
885
|
+
...row?.costUsd !== null && row?.costUsd !== void 0 ? { costUsd: row.costUsd } : void 0,
|
|
837
886
|
...row?.inputTokens !== null && row?.inputTokens !== void 0 ? { inputTokens: row.inputTokens } : void 0,
|
|
838
887
|
...row?.outcomes !== null && row?.outcomes !== void 0 ? {
|
|
839
|
-
mergedCodeChangeCostUsd: addUsd
|
|
888
|
+
mergedCodeChangeCostUsd: addUsd(void 0, row.mergedCodeChangeCostUsd ?? 0),
|
|
840
889
|
mergedCodeChanges: row.mergedCodeChanges ?? 0,
|
|
841
|
-
outcomeCostUsd: addUsd
|
|
890
|
+
outcomeCostUsd: addUsd(void 0, row.outcomeCostUsd ?? 0),
|
|
842
891
|
outcomes: row.outcomes
|
|
843
892
|
} : void 0,
|
|
844
893
|
...row?.tokens !== null && row?.tokens !== void 0 ? { tokens: row.tokens } : void 0
|
|
@@ -927,7 +976,7 @@ function guardianStats(dayRows, hourRows, endMs) {
|
|
|
927
976
|
ask += row?.ask ?? 0;
|
|
928
977
|
deny += row?.deny ?? 0;
|
|
929
978
|
requests += row?.requests ?? 0;
|
|
930
|
-
if (row?.costUsd !== null && row?.costUsd !== void 0) costUsd = addUsd
|
|
979
|
+
if (row?.costUsd !== null && row?.costUsd !== void 0) costUsd = addUsd(costUsd, row.costUsd);
|
|
931
980
|
metricDays.push(guardianPoint(date, row));
|
|
932
981
|
}
|
|
933
982
|
const byHour = new Map(hourRows.map((row) => [row.date, row]));
|
|
@@ -1083,7 +1132,7 @@ async function readConversationStatsFromSql() {
|
|
|
1083
1132
|
locations: statsItems$1(locations),
|
|
1084
1133
|
actors: statsItems$1(actors),
|
|
1085
1134
|
source: "conversation_index",
|
|
1086
|
-
...totals?.costUsd !== null && totals?.costUsd !== void 0 ? { costUsd: addUsd
|
|
1135
|
+
...totals?.costUsd !== null && totals?.costUsd !== void 0 ? { costUsd: addUsd(void 0, totals.costUsd) } : void 0,
|
|
1087
1136
|
...totals?.inputTokens !== null && totals?.inputTokens !== void 0 ? { inputTokens: totals.inputTokens } : void 0,
|
|
1088
1137
|
...totals?.tokens !== null && totals?.tokens !== void 0 ? { tokens: totals.tokens } : void 0,
|
|
1089
1138
|
windowEnd: end.toISOString(),
|
|
@@ -1136,6 +1185,65 @@ async function requireConversationWatches(conversationId, options = {}) {
|
|
|
1136
1185
|
watches
|
|
1137
1186
|
});
|
|
1138
1187
|
}
|
|
1188
|
+
// src/api/conversations/plan.ts
|
|
1189
|
+
/** Closed items that the report shows after the open ones. */
|
|
1190
|
+
const RECENT_CLOSED_ITEMS = 5;
|
|
1191
|
+
function reportItem(item, canViewPrivateContent) {
|
|
1192
|
+
const { assignee } = item;
|
|
1193
|
+
return {
|
|
1194
|
+
id: item.id,
|
|
1195
|
+
status: item.status,
|
|
1196
|
+
updatedAt: new Date(item.updatedAtMs).toISOString(),
|
|
1197
|
+
...canViewPrivateContent ? {
|
|
1198
|
+
title: item.title,
|
|
1199
|
+
...item.notes ? { notes: item.notes } : void 0,
|
|
1200
|
+
assignee: assignee.kind === "user" ? {
|
|
1201
|
+
kind: "user",
|
|
1202
|
+
name: assignee.name ?? assignee.email
|
|
1203
|
+
} : assignee,
|
|
1204
|
+
...item.changedBy ? { changedBy: item.changedBy.name ?? item.changedBy.email } : void 0
|
|
1205
|
+
} : {
|
|
1206
|
+
assignee: assignee.kind === "agent" ? {
|
|
1207
|
+
kind: "agent",
|
|
1208
|
+
conversationId: assignee.conversationId
|
|
1209
|
+
} : { kind: assignee.kind },
|
|
1210
|
+
redacted: true
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
/**
|
|
1215
|
+
* Load the plan of one Conversation: every open item, then the latest closed
|
|
1216
|
+
* ones. Throws a standard API not-found error. Viewers who cannot see
|
|
1217
|
+
* private content get no titles, notes, or names.
|
|
1218
|
+
*/
|
|
1219
|
+
async function requireConversationPlan(conversationId, options = {}) {
|
|
1220
|
+
if (!await getConversationStore().get({ conversationId })) throwApiError(404, "Conversation not found.");
|
|
1221
|
+
const [accessByConversation, items] = await Promise.all([readConversationAccessFromSql(getDb(), [conversationId], options.viewer), listPlanItems(getSqlExecutor(), conversationId)]);
|
|
1222
|
+
const canViewPrivateContent = accessByConversation.get(conversationId)?.canViewPrivateContent ?? false;
|
|
1223
|
+
const closed = items.filter((item) => !isOpenPlanItemStatus(item.status)).sort((left, right) => right.updatedAtMs - left.updatedAtMs).slice(0, RECENT_CLOSED_ITEMS);
|
|
1224
|
+
return conversationPlanReportSchema.parse({
|
|
1225
|
+
conversationId,
|
|
1226
|
+
items: [...items.filter((item) => isOpenPlanItemStatus(item.status)), ...closed].map((item) => reportItem(item, canViewPrivateContent))
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Set the status of one Plan item for a person. The plan is shared, so only
|
|
1231
|
+
* a Participant can change it, the same as the title. The agent sees the
|
|
1232
|
+
* change in a `<plan-delta>` on its next Turn.
|
|
1233
|
+
*/
|
|
1234
|
+
async function setConversationPlanItemStatus(viewer, conversationId, itemId, body) {
|
|
1235
|
+
const conversationAccess = (await readConversationAccessFromSql(getDb(), [conversationId], viewer)).get(conversationId);
|
|
1236
|
+
if (!conversationAccess?.isParticipant) throwApiError(404, "Conversation not found.");
|
|
1237
|
+
const item = await setPlanItemStatusByUser(getSqlExecutor(), {
|
|
1238
|
+
conversationId,
|
|
1239
|
+
id: itemId,
|
|
1240
|
+
nowMs: Date.now(),
|
|
1241
|
+
status: body.status,
|
|
1242
|
+
userId: viewer.id
|
|
1243
|
+
});
|
|
1244
|
+
if (!item) throwApiError(404, "Plan item not found.");
|
|
1245
|
+
return reportItem(item, conversationAccess.canViewPrivateContent);
|
|
1246
|
+
}
|
|
1139
1247
|
// src/api/conversations/routes.ts
|
|
1140
1248
|
/** Create the HTTP routes owned by the conversations API. */
|
|
1141
1249
|
function createConversationRoutes(options) {
|
|
@@ -1243,6 +1351,15 @@ function createConversationRoutes(options) {
|
|
|
1243
1351
|
const viewer = context.get("viewer");
|
|
1244
1352
|
return jsonResponse(conversationWatchesReportSchema, await requireConversationWatches(conversationId, { viewer }));
|
|
1245
1353
|
});
|
|
1354
|
+
app.get("/:conversationId/plan", validateRequest("param", conversationParamsSchema, "Invalid route parameters."), async (context) => {
|
|
1355
|
+
const { conversationId } = context.req.valid("param");
|
|
1356
|
+
const viewer = context.get("viewer");
|
|
1357
|
+
return jsonResponse(conversationPlanReportSchema, await requireConversationPlan(conversationId, { viewer }));
|
|
1358
|
+
});
|
|
1359
|
+
app.patch("/:conversationId/plan/:itemId", requireViewer, validateRequest("param", planItemParamsSchema, "Invalid route parameters."), validateRequest("json", planItemStatusBodySchema, "Invalid request body."), async (context) => {
|
|
1360
|
+
const { conversationId, itemId } = context.req.valid("param");
|
|
1361
|
+
return jsonResponse(conversationPlanItemSchema, await setConversationPlanItemStatus(context.get("viewer"), conversationId, itemId, context.req.valid("json")));
|
|
1362
|
+
});
|
|
1246
1363
|
app.get("/:conversationId/pending-messages", validateRequest("param", conversationParamsSchema, "Invalid route parameters."), async (context) => {
|
|
1247
1364
|
const { conversationId } = context.req.valid("param");
|
|
1248
1365
|
const viewer = context.get("viewer");
|
|
@@ -1692,7 +1809,7 @@ function createCodeRoutes() {
|
|
|
1692
1809
|
/**
|
|
1693
1810
|
* Create authenticated routes that list, connect, and disconnect the viewer's
|
|
1694
1811
|
* plugin accounts. Connections belong to the viewer's User id, which is the
|
|
1695
|
-
* web Actor id and the credential subject for the viewer's
|
|
1812
|
+
* web Actor id and the credential subject for the viewer's Conversations.
|
|
1696
1813
|
*/
|
|
1697
1814
|
function createConnectionRoutes() {
|
|
1698
1815
|
const app = new Hono();
|
|
@@ -2390,93 +2507,96 @@ async function readPeopleCode(email, cursor) {
|
|
|
2390
2507
|
userId: subject.id
|
|
2391
2508
|
});
|
|
2392
2509
|
}
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2510
|
+
const metrics$1 = juniorConversationMetrics;
|
|
2511
|
+
/** Sum the values of one metric among grouped metric rows. */
|
|
2512
|
+
function metricSum(metric) {
|
|
2513
|
+
return sql`sum(${metrics$1.value}) FILTER (WHERE ${metrics$1.metric} = ${metric})`;
|
|
2397
2514
|
}
|
|
2398
2515
|
/** Sum the spend of Turn metric rows read straight from their table. */
|
|
2399
|
-
const turnMetricColumns = {
|
|
2516
|
+
const turnMetricColumns = { costMicroUsd: microUsdSql(metricSum("cost_micro_usd")) };
|
|
2400
2517
|
/** Root Conversation of a person's Turn, for status, location, and surface. */
|
|
2401
2518
|
const turnRoot = alias(juniorConversations, "person_turn_root");
|
|
2519
|
+
/** Root of a Conversation row: itself when it has no root. */
|
|
2520
|
+
const conversationRootId = sql`coalesce(
|
|
2521
|
+
${juniorConversations.rootConversationId},
|
|
2522
|
+
${juniorConversations.conversationId}
|
|
2523
|
+
)`;
|
|
2402
2524
|
/**
|
|
2403
|
-
* Read one row per
|
|
2404
|
-
*
|
|
2525
|
+
* Read one row per verified person and root Conversation where they ran a
|
|
2526
|
+
* Turn, over all time: the Turn range and the duration and token totals.
|
|
2405
2527
|
*
|
|
2406
|
-
*
|
|
2407
|
-
*
|
|
2528
|
+
* The person and metric filters apply to the metric rows, and the rows are
|
|
2529
|
+
* grouped before any join. Every Run writes a `duration_ms` row, so these
|
|
2530
|
+
* two metrics mark every Turn.
|
|
2408
2531
|
*/
|
|
2409
|
-
function
|
|
2532
|
+
function personRoots(email) {
|
|
2533
|
+
const verifiedIdentities = getDb().select({ id: juniorIdentities.id }).from(juniorIdentities).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(verifiedActorWhere(email));
|
|
2534
|
+
const conversations = getDb().select({
|
|
2535
|
+
identityId: sql`${metrics$1.actorIdentityId}`.as("turn_identity_id"),
|
|
2536
|
+
conversationId: sql`${metrics$1.conversationId}`.as("turn_conversation_id"),
|
|
2537
|
+
firstAt: sql`min(${metrics$1.occurredAt})`.as("turn_first_at"),
|
|
2538
|
+
lastAt: sql`max(${metrics$1.occurredAt})`.as("turn_last_at"),
|
|
2539
|
+
durationMs: metricSum("duration_ms").as("turn_duration_ms"),
|
|
2540
|
+
tokens: metricSum("total_tokens").as("turn_tokens")
|
|
2541
|
+
}).from(metrics$1).where(and(inArray(metrics$1.actorIdentityId, verifiedIdentities), inArray(metrics$1.metric, ["duration_ms", "total_tokens"]))).groupBy(metrics$1.actorIdentityId, metrics$1.conversationId).as("person_conversation_turns");
|
|
2410
2542
|
return getDb().select({
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
)
|
|
2425
|
-
)`.as("last_root_turn_at"),
|
|
2426
|
-
slackUserId: sql`CASE WHEN ${juniorIdentities.provider} = 'slack' THEN ${juniorIdentities.providerSubjectId} END`.as("slack_user_id"),
|
|
2427
|
-
slackUserName: sql`CASE WHEN ${juniorIdentities.provider} = 'slack' THEN ${juniorIdentities.handle} END`.as("slack_user_name"),
|
|
2428
|
-
userId: sql`${juniorUsers.id}`.as("user_id"),
|
|
2429
|
-
value: juniorConversationMetrics.value
|
|
2430
|
-
}).from(juniorConversationMetrics).innerJoin(juniorConversations, eq(juniorConversations.conversationId, juniorConversationMetrics.conversationId)).innerJoin(juniorIdentities, eq(juniorIdentities.id, juniorConversationMetrics.actorIdentityId)).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(verifiedActorWhere(email)).as("person_turns");
|
|
2431
|
-
}
|
|
2432
|
-
/** Join a person's Turn rows to the root Conversation of each Turn. */
|
|
2433
|
-
function turnRootJoin(turns) {
|
|
2434
|
-
return eq(turnRoot.conversationId, turns.rootConversationId);
|
|
2435
|
-
}
|
|
2436
|
-
function turnSum(turns, metric) {
|
|
2437
|
-
return sql`SUM(${turns.value}) FILTER (WHERE ${turns.metric} = ${metric})`;
|
|
2543
|
+
userId: sql`${juniorIdentities.userId}`.as("root_user_id"),
|
|
2544
|
+
rootConversationId: conversationRootId.as("person_root_id"),
|
|
2545
|
+
firstAt: sql`min(${conversations.firstAt})`.as("root_first_at"),
|
|
2546
|
+
lastAt: sql`max(${conversations.lastAt})`.as("root_last_at"),
|
|
2547
|
+
durationMs: sql`sum(${conversations.durationMs})`.as("root_duration_ms"),
|
|
2548
|
+
tokens: sql`sum(${conversations.tokens})`.as("root_tokens"),
|
|
2549
|
+
slackUserId: sql`max(CASE WHEN ${juniorIdentities.provider} = 'slack' THEN ${juniorIdentities.providerSubjectId} END)`.as("root_slack_user_id"),
|
|
2550
|
+
slackUserName: sql`max(CASE WHEN ${juniorIdentities.provider} = 'slack' THEN ${juniorIdentities.handle} END)`.as("root_slack_user_name")
|
|
2551
|
+
}).from(conversations).innerJoin(juniorIdentities, eq(juniorIdentities.id, conversations.identityId)).innerJoin(juniorConversations, eq(juniorConversations.conversationId, conversations.conversationId)).groupBy(juniorIdentities.userId, conversationRootId).as("person_roots");
|
|
2552
|
+
}
|
|
2553
|
+
/** Join a person's roots to the root Conversation rows. */
|
|
2554
|
+
function personRootJoin(roots) {
|
|
2555
|
+
return eq(turnRoot.conversationId, roots.rootConversationId);
|
|
2438
2556
|
}
|
|
2439
2557
|
/**
|
|
2440
|
-
* Aggregate
|
|
2441
|
-
* who ran a Turn in it
|
|
2442
|
-
*
|
|
2443
|
-
* Active and failed read the root's current
|
|
2444
|
-
*
|
|
2445
|
-
* mark every past day.
|
|
2558
|
+
* Aggregate rows from {@link personRoots} joined to {@link turnRoot}. A
|
|
2559
|
+
* Conversation counts once for each person who ran a Turn in it, and child
|
|
2560
|
+
* Conversation Turns count for the root. Each row is one root of one person,
|
|
2561
|
+
* so plain counts need no DISTINCT. Active and failed read the root's current
|
|
2562
|
+
* status.
|
|
2446
2563
|
*/
|
|
2447
|
-
function
|
|
2448
|
-
const roots = sql`COUNT(DISTINCT ${turns.rootConversationId})`;
|
|
2449
|
-
const lastTurn = sql`${turns.occurredAt} = ${turns.lastRootTurnAt}`;
|
|
2564
|
+
function rootAggregateColumns(roots) {
|
|
2450
2565
|
return {
|
|
2451
|
-
active: sql
|
|
2452
|
-
WHERE ${
|
|
2453
|
-
)::integer`,
|
|
2454
|
-
conversations: sql
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2566
|
+
active: sql`(count(*) FILTER (
|
|
2567
|
+
WHERE ${turnRoot.executionStatus} NOT IN ('idle', 'failed')
|
|
2568
|
+
))::integer`,
|
|
2569
|
+
conversations: sql`count(*)::integer`,
|
|
2570
|
+
durationMs: sql`COALESCE(sum(${roots.durationMs}), 0)::double precision`,
|
|
2571
|
+
failed: sql`(count(*) FILTER (
|
|
2572
|
+
WHERE ${turnRoot.executionStatus} = 'failed' AND ${turnRoot.stoppedAt} IS NULL
|
|
2573
|
+
))::integer`,
|
|
2574
|
+
tokens: sql`sum(${roots.tokens})::double precision`
|
|
2575
|
+
};
|
|
2576
|
+
}
|
|
2577
|
+
/**
|
|
2578
|
+
* Count the UTC days on which the grouped person ran a Turn. A correlated
|
|
2579
|
+
* subquery runs once per person through the actor index, so a bad row
|
|
2580
|
+
* estimate cannot make Postgres repeat it once per root.
|
|
2581
|
+
*/
|
|
2582
|
+
function personActiveDays() {
|
|
2583
|
+
const days = getDb().selectDistinct({ day: sql`(${metrics$1.occurredAt} AT TIME ZONE 'UTC')::date`.as("turn_day") }).from(metrics$1).innerJoin(juniorIdentities, eq(juniorIdentities.id, metrics$1.actorIdentityId)).where(and(eq(juniorIdentities.userId, juniorUsers.id), eq(juniorIdentities.kind, "user"), eq(juniorIdentities.emailVerified, true))).as("person_turn_days");
|
|
2584
|
+
return sql`(${getDb().select({ days: sql`count(*)` }).from(days)})::integer`;
|
|
2469
2585
|
}
|
|
2470
|
-
/**
|
|
2471
|
-
|
|
2586
|
+
/**
|
|
2587
|
+
* Select the identity, Turn range, and totals of one person from roots
|
|
2588
|
+
* grouped by person and joined to {@link juniorUsers}.
|
|
2589
|
+
*/
|
|
2590
|
+
function personTotalColumns(roots) {
|
|
2472
2591
|
return {
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2592
|
+
...rootAggregateColumns(roots),
|
|
2593
|
+
activeDays: personActiveDays(),
|
|
2594
|
+
email: sql`${juniorUsers.primaryEmailNormalized}`,
|
|
2595
|
+
firstSeenAt: sql`min(${roots.firstAt})`.mapWith(metrics$1.occurredAt),
|
|
2596
|
+
fullName: juniorUsers.displayName,
|
|
2597
|
+
lastSeenAt: sql`max(${roots.lastAt})`.mapWith(metrics$1.occurredAt),
|
|
2598
|
+
slackUserId: sql`max(${roots.slackUserId})`,
|
|
2599
|
+
slackUserName: sql`max(${roots.slackUserName})`
|
|
2480
2600
|
};
|
|
2481
2601
|
}
|
|
2482
2602
|
/** Normalize emails before matching people API rows. */
|
|
@@ -2553,11 +2673,10 @@ function verifiedActorWhere(email) {
|
|
|
2553
2673
|
}
|
|
2554
2674
|
/** Read the Conversations where a person ran a Turn, by their last Turn. */
|
|
2555
2675
|
async function recentActorRows(email) {
|
|
2556
|
-
const turns = personTurns(email);
|
|
2557
2676
|
const lastTurns = getDb().select({
|
|
2558
|
-
conversationId:
|
|
2559
|
-
lastTurnAt: sql`max(${
|
|
2560
|
-
}).from(
|
|
2677
|
+
conversationId: sql`${metrics$1.conversationId}`.as("turn_conversation_id"),
|
|
2678
|
+
lastTurnAt: sql`max(${metrics$1.occurredAt})`.as("last_turn_at")
|
|
2679
|
+
}).from(metrics$1).innerJoin(juniorIdentities, eq(juniorIdentities.id, metrics$1.actorIdentityId)).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(and(verifiedActorWhere(email), eq(metrics$1.metric, "duration_ms"))).groupBy(metrics$1.conversationId).as("person_last_turns");
|
|
2561
2680
|
return getDb().select({
|
|
2562
2681
|
channelName: juniorConversations.channelName,
|
|
2563
2682
|
conversationId: juniorConversations.conversationId,
|
|
@@ -2585,8 +2704,7 @@ async function recentActorRows(email) {
|
|
|
2585
2704
|
const DIRECTORY_ACTIVITY_DAYS = 90;
|
|
2586
2705
|
/** Day ranges need the prior equal period too (90d + prior 90d). */
|
|
2587
2706
|
const DAY_METRIC_LOOKBACK = 180;
|
|
2588
|
-
|
|
2589
|
-
const HOUR_METRIC_LOOKBACK = 48;
|
|
2707
|
+
const metrics = juniorConversationMetrics;
|
|
2590
2708
|
function emptyDirectoryDay(date) {
|
|
2591
2709
|
return {
|
|
2592
2710
|
activePeople: 0,
|
|
@@ -2594,15 +2712,6 @@ function emptyDirectoryDay(date) {
|
|
|
2594
2712
|
date
|
|
2595
2713
|
};
|
|
2596
2714
|
}
|
|
2597
|
-
function emptyBucket() {
|
|
2598
|
-
return {
|
|
2599
|
-
costUsd: 0,
|
|
2600
|
-
durationMs: 0
|
|
2601
|
-
};
|
|
2602
|
-
}
|
|
2603
|
-
function addUsd$1(current, next) {
|
|
2604
|
-
return Math.round((current + next) * 0xe8d4a51000) / 0xe8d4a51000;
|
|
2605
|
-
}
|
|
2606
2715
|
function directoryActivityDays(rows, nowMs) {
|
|
2607
2716
|
return fillUtcDays({
|
|
2608
2717
|
count: DIRECTORY_ACTIVITY_DAYS,
|
|
@@ -2626,66 +2735,53 @@ function directoryActivitySixHours(rows, nowMs) {
|
|
|
2626
2735
|
rows: new Map(rows.map((row) => [row.date, row]))
|
|
2627
2736
|
});
|
|
2628
2737
|
}
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
const currentTotals = sumBuckets(buckets, current.start.getTime(), current.end.getTime(), utcHourKey, HOUR_MS$1);
|
|
2645
|
-
const priorTotals = sumBuckets(buckets, priorStartMs, priorEndMs, utcHourKey, HOUR_MS$1);
|
|
2646
|
-
return {
|
|
2647
|
-
conversations,
|
|
2648
|
-
costUsd: currentTotals.costUsd,
|
|
2649
|
-
durationMs: currentTotals.durationMs,
|
|
2650
|
-
priorCostUsd: priorTotals.costUsd
|
|
2651
|
-
};
|
|
2652
|
-
}
|
|
2653
|
-
const current = trailingUtcDayWindow(nowMs, range);
|
|
2654
|
-
const priorEndMs = current.start.getTime() - DAY_MS$2;
|
|
2655
|
-
const priorStartMs = priorEndMs - (range - 1) * DAY_MS$2;
|
|
2656
|
-
const currentTotals = sumBuckets(buckets, current.start.getTime(), current.end.getTime(), utcDayKey, DAY_MS$2);
|
|
2657
|
-
const priorTotals = sumBuckets(buckets, priorStartMs, priorEndMs, utcDayKey, DAY_MS$2);
|
|
2738
|
+
/** Start of the current period of each directory range. */
|
|
2739
|
+
function rangeStart(nowMs, range) {
|
|
2740
|
+
return range === 1 ? trailingUtcHourWindow(nowMs, 24).start : trailingUtcDayWindow(nowMs, range).start;
|
|
2741
|
+
}
|
|
2742
|
+
/**
|
|
2743
|
+
* Sum one range of a person's spend: the current period, and the prior
|
|
2744
|
+
* period of equal length that ends where the current one starts.
|
|
2745
|
+
*/
|
|
2746
|
+
function rangeSpendColumns(nowMs, range) {
|
|
2747
|
+
const start = rangeStart(nowMs, range);
|
|
2748
|
+
const priorStart = new Date(start.getTime() - (range === 1 ? 24 * HOUR_MS$1 : range * DAY_MS$2));
|
|
2749
|
+
const current = sql`${metrics.occurredAt} >= ${start.toISOString()}::timestamptz`;
|
|
2750
|
+
const prior = sql`${metrics.occurredAt} >= ${priorStart.toISOString()}::timestamptz
|
|
2751
|
+
AND ${metrics.occurredAt} < ${start.toISOString()}::timestamptz`;
|
|
2752
|
+
const sum = (metric, when) => sql`sum(${metrics.value}) FILTER (WHERE ${metrics.metric} = ${metric} AND ${when})`;
|
|
2658
2753
|
return {
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
priorCostUsd: priorTotals.costUsd
|
|
2754
|
+
costMicroUsd: microUsdSql(sum("cost_micro_usd", current)),
|
|
2755
|
+
durationMs: sql`COALESCE(${sum("duration_ms", current)}, 0)::double precision`,
|
|
2756
|
+
priorCostMicroUsd: microUsdSql(sum("cost_micro_usd", prior))
|
|
2663
2757
|
};
|
|
2664
2758
|
}
|
|
2665
|
-
function
|
|
2666
|
-
const { conversations, dayBuckets, hourBuckets, nowMs } = args;
|
|
2759
|
+
function rangeWindow(spend, conversations) {
|
|
2667
2760
|
return {
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2761
|
+
conversations,
|
|
2762
|
+
costUsd: microUsdToUsd(spend?.costMicroUsd ?? 0),
|
|
2763
|
+
durationMs: spend?.durationMs ?? 0,
|
|
2764
|
+
priorCostUsd: microUsdToUsd(spend?.priorCostMicroUsd ?? 0)
|
|
2672
2765
|
};
|
|
2673
2766
|
}
|
|
2674
|
-
/**
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
function
|
|
2679
|
-
const
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2767
|
+
/**
|
|
2768
|
+
* Count active people and root Conversations in each bucket from one row per
|
|
2769
|
+
* Turn. The time bound applies to the metric rows before any join.
|
|
2770
|
+
*/
|
|
2771
|
+
function activityRows(since, unit) {
|
|
2772
|
+
const utc = sql`(${metrics.occurredAt} AT TIME ZONE 'UTC')`;
|
|
2773
|
+
const bucket = unit === "six_hour" ? sql`date_trunc('day', ${utc}) + FLOOR(EXTRACT(HOUR FROM ${utc}) / 6) * INTERVAL '6 hours'` : sql`date_trunc(${sql.raw(`'${unit}'`)}, ${utc})`;
|
|
2774
|
+
const format = unit === "day" ? "YYYY-MM-DD" : "YYYY-MM-DD\"T\"HH24";
|
|
2775
|
+
const turns = getDb().select({
|
|
2776
|
+
bucket: bucket.as("activity_bucket"),
|
|
2777
|
+
userId: sql`${juniorUsers.id}`.as("activity_user_id"),
|
|
2778
|
+
rootConversationId: conversationRootId.as("activity_root_id")
|
|
2779
|
+
}).from(metrics).innerJoin(juniorIdentities, eq(juniorIdentities.id, metrics.actorIdentityId)).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).innerJoin(juniorConversations, eq(juniorConversations.conversationId, metrics.conversationId)).where(and(verifiedActorWhere(), eq(metrics.metric, "duration_ms"), gte(metrics.occurredAt, since))).groupBy(bucket, juniorUsers.id, conversationRootId).as("activity_turns");
|
|
2780
|
+
return getDb().select({
|
|
2781
|
+
activePeople: sql`COUNT(DISTINCT ${turns.userId})::int`,
|
|
2782
|
+
conversations: sql`COUNT(DISTINCT ${turns.rootConversationId})::int`,
|
|
2783
|
+
date: sql`TO_CHAR(${turns.bucket}, ${sql.raw(`'${format}'`)})`
|
|
2784
|
+
}).from(turns).groupBy(turns.bucket);
|
|
2689
2785
|
}
|
|
2690
2786
|
/**
|
|
2691
2787
|
* Load the complete People directory with grouping and metrics owned by SQL.
|
|
@@ -2698,52 +2794,30 @@ async function readPeopleListFromSql() {
|
|
|
2698
2794
|
const { end, start } = trailingUtcDayWindow(nowMs, DIRECTORY_ACTIVITY_DAYS);
|
|
2699
2795
|
const hourWindow = trailingUtcHourWindow(nowMs, 168);
|
|
2700
2796
|
const sixHourWindow = trailingUtcSixHourWindow(nowMs);
|
|
2701
|
-
const
|
|
2702
|
-
const
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
const
|
|
2706
|
-
const hour = turnBucket(turns, "hour");
|
|
2707
|
-
const sixHour = sql`TO_CHAR(
|
|
2708
|
-
date_trunc('day', ${turns.occurredAt} AT TIME ZONE 'UTC')
|
|
2709
|
-
+ (FLOOR(EXTRACT(HOUR FROM ${turns.occurredAt} AT TIME ZONE 'UTC') / 6) * INTERVAL '6 hours'),
|
|
2710
|
-
'YYYY-MM-DD"T"HH24'
|
|
2711
|
-
)`;
|
|
2712
|
-
const rangeConversations = (range) => sql`COUNT(DISTINCT ${turns.rootConversationId}) FILTER (
|
|
2713
|
-
WHERE ${turns.occurredAt} >= ${rangeStart(nowMs, range).toISOString()}::timestamptz
|
|
2714
|
-
)::integer`;
|
|
2715
|
-
const spendRows = (since, bucket) => getDb().select({
|
|
2716
|
-
email: turns.email,
|
|
2717
|
-
date: bucket,
|
|
2718
|
-
costUsd,
|
|
2719
|
-
durationMs
|
|
2720
|
-
}).from(turns).where(gte(turns.occurredAt, since)).groupBy(turns.email, bucket);
|
|
2721
|
-
const activityRows = (since, bucket) => getDb().select({
|
|
2722
|
-
activePeople: sql`COUNT(DISTINCT ${turns.userId})::int`,
|
|
2723
|
-
conversations,
|
|
2724
|
-
date: bucket
|
|
2725
|
-
}).from(turns).where(gte(turns.occurredAt, since)).groupBy(bucket);
|
|
2726
|
-
const [rows, activityDayRows, activityHourRows, activitySixHourRows, daySpendRows, hourSpendRows] = await Promise.all([
|
|
2797
|
+
const roots = personRoots();
|
|
2798
|
+
const rangeConversations = (range) => sql`(count(*) FILTER (
|
|
2799
|
+
WHERE ${roots.lastAt} >= ${rangeStart(nowMs, range).toISOString()}::timestamptz
|
|
2800
|
+
))::integer`;
|
|
2801
|
+
const [rows, activityDayRows, activityHourRows, activitySixHourRows, spend] = await Promise.all([
|
|
2727
2802
|
getDb().select({
|
|
2728
|
-
...
|
|
2729
|
-
active,
|
|
2730
|
-
conversations,
|
|
2731
|
-
durationMs,
|
|
2732
|
-
failed,
|
|
2733
|
-
tokens,
|
|
2803
|
+
...personTotalColumns(roots),
|
|
2734
2804
|
conversations1: rangeConversations(1),
|
|
2735
2805
|
conversations7: rangeConversations(7),
|
|
2736
2806
|
conversations30: rangeConversations(30),
|
|
2737
2807
|
conversations90: rangeConversations(90)
|
|
2738
|
-
}).from(
|
|
2739
|
-
activityRows(start, day),
|
|
2740
|
-
activityRows(hourWindow.start, hour),
|
|
2741
|
-
activityRows(sixHourWindow.start,
|
|
2742
|
-
|
|
2743
|
-
|
|
2808
|
+
}).from(roots).innerJoin(juniorUsers, eq(juniorUsers.id, roots.userId)).innerJoin(turnRoot, personRootJoin(roots)).groupBy(juniorUsers.id),
|
|
2809
|
+
activityRows(start, "day"),
|
|
2810
|
+
activityRows(hourWindow.start, "hour"),
|
|
2811
|
+
activityRows(sixHourWindow.start, "six_hour"),
|
|
2812
|
+
getDb().select({
|
|
2813
|
+
email: sql`${juniorUsers.primaryEmailNormalized}`,
|
|
2814
|
+
1: rangeSpendColumns(nowMs, 1),
|
|
2815
|
+
7: rangeSpendColumns(nowMs, 7),
|
|
2816
|
+
30: rangeSpendColumns(nowMs, 30),
|
|
2817
|
+
90: rangeSpendColumns(nowMs, 90)
|
|
2818
|
+
}).from(metrics).innerJoin(juniorIdentities, eq(juniorIdentities.id, metrics.actorIdentityId)).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(and(verifiedActorWhere(), inArray(metrics.metric, ["cost_micro_usd", "duration_ms"]), gte(metrics.occurredAt, trailingUtcDayWindow(nowMs, DAY_METRIC_LOOKBACK).start))).groupBy(juniorUsers.id)
|
|
2744
2819
|
]);
|
|
2745
|
-
const
|
|
2746
|
-
const hourBucketsByEmail = metricBuckets(hourSpendRows);
|
|
2820
|
+
const spendByEmail = new Map(spend.map((row) => [row.email, row]));
|
|
2747
2821
|
const people = rows.map((row) => {
|
|
2748
2822
|
const actor = {
|
|
2749
2823
|
email: row.email,
|
|
@@ -2751,6 +2825,7 @@ async function readPeopleListFromSql() {
|
|
|
2751
2825
|
...row.slackUserId ? { slackUserId: row.slackUserId } : void 0,
|
|
2752
2826
|
...row.slackUserName ? { slackUserName: row.slackUserName } : void 0
|
|
2753
2827
|
};
|
|
2828
|
+
const personSpend = spendByEmail.get(row.email);
|
|
2754
2829
|
return {
|
|
2755
2830
|
active: row.active,
|
|
2756
2831
|
activeDays: row.activeDays,
|
|
@@ -2760,17 +2835,12 @@ async function readPeopleListFromSql() {
|
|
|
2760
2835
|
firstSeenAt: row.firstSeenAt.toISOString(),
|
|
2761
2836
|
lastSeenAt: row.lastSeenAt.toISOString(),
|
|
2762
2837
|
actor,
|
|
2763
|
-
windows:
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
},
|
|
2770
|
-
dayBuckets: dayBucketsByEmail.get(row.email) ?? /* @__PURE__ */ new Map(),
|
|
2771
|
-
hourBuckets: hourBucketsByEmail.get(row.email) ?? /* @__PURE__ */ new Map(),
|
|
2772
|
-
nowMs
|
|
2773
|
-
}),
|
|
2838
|
+
windows: {
|
|
2839
|
+
1: rangeWindow(personSpend?.[1], row.conversations1),
|
|
2840
|
+
7: rangeWindow(personSpend?.[7], row.conversations7),
|
|
2841
|
+
30: rangeWindow(personSpend?.[30], row.conversations30),
|
|
2842
|
+
90: rangeWindow(personSpend?.[90], row.conversations90)
|
|
2843
|
+
},
|
|
2774
2844
|
...row.tokens !== null ? { tokens: row.tokens } : void 0
|
|
2775
2845
|
};
|
|
2776
2846
|
});
|
|
@@ -2800,7 +2870,7 @@ async function readPeoplePluginReports(args) {
|
|
|
2800
2870
|
reports: [],
|
|
2801
2871
|
source: "plugins"
|
|
2802
2872
|
});
|
|
2803
|
-
const { getPluginProfileReports } = await import("./projection-
|
|
2873
|
+
const { getPluginProfileReports } = await import("./projection-xPpvqexa.js").then((n) => n.Cn);
|
|
2804
2874
|
return pluginOperationalReportFeedSchema.parse({
|
|
2805
2875
|
generatedAt: new Date(nowMs).toISOString(),
|
|
2806
2876
|
reports: await getPluginProfileReports({
|
|
@@ -2851,7 +2921,7 @@ function surfaceExpression(table) {
|
|
|
2851
2921
|
return sql`CASE
|
|
2852
2922
|
WHEN ${table.source} IN ('api', 'scheduler', 'slack')
|
|
2853
2923
|
THEN ${table.source}
|
|
2854
|
-
-- Dashboard
|
|
2924
|
+
-- Dashboard Conversations share the product api surface label.
|
|
2855
2925
|
WHEN ${table.source} = 'web' THEN 'api'
|
|
2856
2926
|
WHEN ${table.conversationId} LIKE 'slack:%' THEN 'slack'
|
|
2857
2927
|
WHEN ${table.conversationId} LIKE 'scheduler:%' THEN 'scheduler'
|
|
@@ -2871,13 +2941,62 @@ function locationLabel(row) {
|
|
|
2871
2941
|
}) ?? "Conversation";
|
|
2872
2942
|
}
|
|
2873
2943
|
function activityBuckets(rows) {
|
|
2874
|
-
return new Map(rows.map(({
|
|
2944
|
+
return new Map(rows.map(({ costMicroUsd, tokens, ...row }) => [row.date, {
|
|
2875
2945
|
...emptyActivityDay(row.date),
|
|
2876
2946
|
...row,
|
|
2877
|
-
...
|
|
2947
|
+
...costMicroUsd !== null ? { costUsd: microUsdToUsd(costMicroUsd) } : void 0,
|
|
2878
2948
|
...tokens !== null ? { tokens } : void 0
|
|
2879
2949
|
}]));
|
|
2880
2950
|
}
|
|
2951
|
+
/**
|
|
2952
|
+
* Sum one person's Turns into UTC day or hour buckets since `since`. A root
|
|
2953
|
+
* counts once in each bucket where the person ran a Turn in it. Its current
|
|
2954
|
+
* status counts only in the bucket of their last Turn in that root, so a
|
|
2955
|
+
* status change does not mark every past bucket.
|
|
2956
|
+
*/
|
|
2957
|
+
function rootBucketRows(args) {
|
|
2958
|
+
const metrics = juniorConversationMetrics;
|
|
2959
|
+
const unit = sql.raw(`'${args.unit}'`);
|
|
2960
|
+
const bucket = sql`date_trunc(${unit}, ${metrics.occurredAt} AT TIME ZONE 'UTC')`;
|
|
2961
|
+
const format = args.unit === "day" ? "YYYY-MM-DD" : "YYYY-MM-DD\"T\"HH24";
|
|
2962
|
+
const rootBuckets = getDb().select({
|
|
2963
|
+
bucket: bucket.as("bucket_start"),
|
|
2964
|
+
rootConversationId: conversationRootId.as("bucket_root_id"),
|
|
2965
|
+
lastAt: sql`max(${metrics.occurredAt})`.as("bucket_last_at"),
|
|
2966
|
+
costMicroUsd: metricSum("cost_micro_usd").as("bucket_cost_micro_usd"),
|
|
2967
|
+
durationMs: metricSum("duration_ms").as("bucket_duration_ms"),
|
|
2968
|
+
tokens: metricSum("total_tokens").as("bucket_tokens")
|
|
2969
|
+
}).from(metrics).innerJoin(juniorIdentities, eq(juniorIdentities.id, metrics.actorIdentityId)).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).innerJoin(juniorConversations, eq(juniorConversations.conversationId, metrics.conversationId)).where(and(verifiedActorWhere(args.email), inArray(metrics.metric, [
|
|
2970
|
+
"cost_micro_usd",
|
|
2971
|
+
"duration_ms",
|
|
2972
|
+
"total_tokens"
|
|
2973
|
+
]))).groupBy(bucket, conversationRootId).as("person_root_buckets");
|
|
2974
|
+
const buckets = getDb().select({
|
|
2975
|
+
bucket: rootBuckets.bucket,
|
|
2976
|
+
rootConversationId: rootBuckets.rootConversationId,
|
|
2977
|
+
isLastTurn: sql`${rootBuckets.lastAt} = max(${rootBuckets.lastAt}) OVER (
|
|
2978
|
+
PARTITION BY ${rootBuckets.rootConversationId}
|
|
2979
|
+
)`.as("bucket_has_last_turn"),
|
|
2980
|
+
costMicroUsd: rootBuckets.costMicroUsd,
|
|
2981
|
+
durationMs: rootBuckets.durationMs,
|
|
2982
|
+
tokens: rootBuckets.tokens
|
|
2983
|
+
}).from(rootBuckets).as("person_buckets");
|
|
2984
|
+
return getDb().select({
|
|
2985
|
+
active: sql`(count(*) FILTER (
|
|
2986
|
+
WHERE ${buckets.isLastTurn} AND ${turnRoot.executionStatus} NOT IN ('idle', 'failed')
|
|
2987
|
+
))::integer`,
|
|
2988
|
+
conversations: sql`count(*)::integer`,
|
|
2989
|
+
costMicroUsd: microUsdSql(sql`sum(${buckets.costMicroUsd})`),
|
|
2990
|
+
date: sql`TO_CHAR(${buckets.bucket}, ${sql.raw(`'${format}'`)})`,
|
|
2991
|
+
durationMs: sql`COALESCE(sum(${buckets.durationMs}), 0)::double precision`,
|
|
2992
|
+
failed: sql`(count(*) FILTER (
|
|
2993
|
+
WHERE ${buckets.isLastTurn}
|
|
2994
|
+
AND ${turnRoot.executionStatus} = 'failed'
|
|
2995
|
+
AND ${turnRoot.stoppedAt} IS NULL
|
|
2996
|
+
))::integer`,
|
|
2997
|
+
tokens: sql`sum(${buckets.tokens})::double precision`
|
|
2998
|
+
}).from(buckets).innerJoin(turnRoot, eq(turnRoot.conversationId, buckets.rootConversationId)).where(sql`${buckets.bucket} >= (${args.since.toISOString()}::timestamptz AT TIME ZONE 'UTC')`).groupBy(buckets.bucket);
|
|
2999
|
+
}
|
|
2881
3000
|
/** Load one complete person profile while bounding only its recent-conversation list. */
|
|
2882
3001
|
async function readPeopleProfileFromSql(email, options = {}) {
|
|
2883
3002
|
const nowMs = Date.now();
|
|
@@ -2887,37 +3006,34 @@ async function readPeopleProfileFromSql(email, options = {}) {
|
|
|
2887
3006
|
end.setUTCHours(0, 0, 0, 0);
|
|
2888
3007
|
const start = new Date(end);
|
|
2889
3008
|
start.setUTCDate(start.getUTCDate() - 364);
|
|
2890
|
-
const
|
|
2891
|
-
const aggregate =
|
|
3009
|
+
const roots = personRoots(normalizedEmail);
|
|
3010
|
+
const aggregate = rootAggregateColumns(roots);
|
|
2892
3011
|
const surface = surfaceExpression(turnRoot);
|
|
2893
3012
|
const channel = channelExpression(turnRoot);
|
|
2894
|
-
const day = turnBucket(turns, "day");
|
|
2895
|
-
const hour = turnBucket(turns, "hour");
|
|
2896
3013
|
const hourWindow = trailingUtcHourWindow(nowMs, 168);
|
|
2897
3014
|
const [totalsRows, dayRows, hourRows, locationRows, surfaceRows, recentRows] = await Promise.all([
|
|
2898
|
-
getDb().select(
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
}).from(turns).innerJoin(turnRoot, turnRootJoin(turns)).where(gte(turns.occurredAt, hourWindow.start)).groupBy(hour),
|
|
3015
|
+
getDb().select(personTotalColumns(roots)).from(roots).innerJoin(juniorUsers, eq(juniorUsers.id, roots.userId)).innerJoin(turnRoot, personRootJoin(roots)).groupBy(juniorUsers.id),
|
|
3016
|
+
rootBucketRows({
|
|
3017
|
+
email: normalizedEmail,
|
|
3018
|
+
since: start,
|
|
3019
|
+
unit: "day"
|
|
3020
|
+
}),
|
|
3021
|
+
rootBucketRows({
|
|
3022
|
+
email: normalizedEmail,
|
|
3023
|
+
since: hourWindow.start,
|
|
3024
|
+
unit: "hour"
|
|
3025
|
+
}),
|
|
2910
3026
|
getDb().select({
|
|
2911
3027
|
channel,
|
|
2912
3028
|
channelName: turnRoot.channelName,
|
|
2913
3029
|
destinationVisibility: juniorDestinations.visibility,
|
|
2914
3030
|
surface,
|
|
2915
3031
|
...aggregate
|
|
2916
|
-
}).from(
|
|
3032
|
+
}).from(roots).innerJoin(turnRoot, personRootJoin(roots)).leftJoin(juniorDestinations, eq(juniorDestinations.id, turnRoot.destinationId)).groupBy(channel, turnRoot.channelName, juniorDestinations.visibility, surface),
|
|
2917
3033
|
getDb().select({
|
|
2918
3034
|
surface,
|
|
2919
3035
|
...aggregate
|
|
2920
|
-
}).from(
|
|
3036
|
+
}).from(roots).innerJoin(turnRoot, personRootJoin(roots)).groupBy(surface),
|
|
2921
3037
|
recentActorRows(normalizedEmail)
|
|
2922
3038
|
]);
|
|
2923
3039
|
const person = totalsRows[0];
|
|
@@ -2976,9 +3092,6 @@ async function readPeopleProfile(email, options = {}) {
|
|
|
2976
3092
|
// src/api/people/spend.query.ts
|
|
2977
3093
|
const SEVEN_DAY_OFFSET = 6;
|
|
2978
3094
|
const THIRTY_DAY_OFFSET = 29;
|
|
2979
|
-
function addUsd(current, next) {
|
|
2980
|
-
return Math.round((current + next) * 0xe8d4a51000) / 0xe8d4a51000;
|
|
2981
|
-
}
|
|
2982
3095
|
function spendWindow(nowMs) {
|
|
2983
3096
|
const end = new Date(nowMs);
|
|
2984
3097
|
const currentDay = new Date(end);
|
|
@@ -2997,7 +3110,7 @@ function spendWindow(nowMs) {
|
|
|
2997
3110
|
function viewerWindowWhere(email, nowMs) {
|
|
2998
3111
|
const normalizedEmail = normalizeEmail$1(email);
|
|
2999
3112
|
const { end, thirtyDayStart } = spendWindow(nowMs);
|
|
3000
|
-
return normalizedEmail ? and(verifiedActorWhere(normalizedEmail), eq(juniorConversationMetrics.metric, "
|
|
3113
|
+
return normalizedEmail ? and(verifiedActorWhere(normalizedEmail), eq(juniorConversationMetrics.metric, "cost_micro_usd"), gte(juniorConversationMetrics.occurredAt, thirtyDayStart), lte(juniorConversationMetrics.occurredAt, end)) : sql`false`;
|
|
3001
3114
|
}
|
|
3002
3115
|
/** Return a query for one viewer's model spend for each UTC day in the window. */
|
|
3003
3116
|
function personalSpendDaysQuery(email, nowMs) {
|
|
@@ -3006,7 +3119,7 @@ function personalSpendDaysQuery(email, nowMs) {
|
|
|
3006
3119
|
'YYYY-MM-DD'
|
|
3007
3120
|
)`;
|
|
3008
3121
|
return getDb().select({
|
|
3009
|
-
|
|
3122
|
+
costMicroUsd: turnMetricColumns.costMicroUsd,
|
|
3010
3123
|
date
|
|
3011
3124
|
}).from(juniorConversationMetrics).innerJoin(juniorIdentities, eq(juniorIdentities.id, juniorConversationMetrics.actorIdentityId)).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(viewerWindowWhere(email, nowMs)).groupBy(date);
|
|
3012
3125
|
}
|
|
@@ -3022,10 +3135,10 @@ function personalSpendVersionQuery(db, email, nowMs) {
|
|
|
3022
3135
|
const { sevenDayStart, thirtyDayStart } = spendWindow(nowMs);
|
|
3023
3136
|
return db.select({ version: sql`concat_ws(':',
|
|
3024
3137
|
${thirtyDayStart.toISOString().slice(0, 10)}::text,
|
|
3025
|
-
|
|
3026
|
-
|
|
3138
|
+
sum(${juniorConversationMetrics.value})::bigint,
|
|
3139
|
+
(sum(${juniorConversationMetrics.value}) filter (
|
|
3027
3140
|
where ${juniorConversationMetrics.occurredAt} >= ${sevenDayStart}
|
|
3028
|
-
))::
|
|
3141
|
+
))::bigint
|
|
3029
3142
|
)` }).from(juniorConversationMetrics).innerJoin(juniorIdentities, eq(juniorIdentities.id, juniorConversationMetrics.actorIdentityId)).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(viewerWindowWhere(email, nowMs));
|
|
3030
3143
|
}
|
|
3031
3144
|
/** Read one viewer's rolling model spend with one bounded aggregate query. */
|
|
@@ -3033,18 +3146,18 @@ async function readPersonalSpendFromSql(email, nowMs = Date.now()) {
|
|
|
3033
3146
|
const { end, sevenDayStart, thirtyDayStart } = spendWindow(nowMs);
|
|
3034
3147
|
const rows = await personalSpendDaysQuery(email, nowMs);
|
|
3035
3148
|
const sevenDayStartDate = sevenDayStart.toISOString().slice(0, 10);
|
|
3036
|
-
let
|
|
3037
|
-
let
|
|
3149
|
+
let sevenDaysMicroUsd = 0;
|
|
3150
|
+
let thirtyDaysMicroUsd = 0;
|
|
3038
3151
|
for (const row of rows) {
|
|
3039
|
-
if (row.
|
|
3040
|
-
|
|
3041
|
-
if (row.date >= sevenDayStartDate)
|
|
3152
|
+
if (row.costMicroUsd === null) continue;
|
|
3153
|
+
thirtyDaysMicroUsd += row.costMicroUsd;
|
|
3154
|
+
if (row.date >= sevenDayStartDate) sevenDaysMicroUsd += row.costMicroUsd;
|
|
3042
3155
|
}
|
|
3043
3156
|
return {
|
|
3044
3157
|
generatedAt: new Date(nowMs).toISOString(),
|
|
3045
|
-
sevenDaysUsd,
|
|
3158
|
+
sevenDaysUsd: microUsdToUsd(sevenDaysMicroUsd),
|
|
3046
3159
|
source: "conversation_index",
|
|
3047
|
-
thirtyDaysUsd,
|
|
3160
|
+
thirtyDaysUsd: microUsdToUsd(thirtyDaysMicroUsd),
|
|
3048
3161
|
windowEnd: end.toISOString(),
|
|
3049
3162
|
windowStart: thirtyDayStart.toISOString()
|
|
3050
3163
|
};
|
|
@@ -3241,9 +3354,19 @@ function createServiceAccountRoutes() {
|
|
|
3241
3354
|
}
|
|
3242
3355
|
// src/api/cache-warming/savings.ts
|
|
3243
3356
|
const DAY_MS = 864e5;
|
|
3244
|
-
function
|
|
3245
|
-
|
|
3246
|
-
|
|
3357
|
+
function savingsUsd(totals) {
|
|
3358
|
+
return {
|
|
3359
|
+
hits: totals.hits,
|
|
3360
|
+
idlePeriods: totals.idlePeriods,
|
|
3361
|
+
oracleSavingsUsd: microUsdToUsd(totals.oracleSavingsMicroUsd),
|
|
3362
|
+
savedUsd: microUsdToUsd(totals.savedMicroUsd),
|
|
3363
|
+
unwarmedIdlePeriods: totals.unwarmedIdlePeriods,
|
|
3364
|
+
unwarmedOracleSavingsUsd: microUsdToUsd(totals.unwarmedOracleSavingsMicroUsd),
|
|
3365
|
+
warmupCostUsd: microUsdToUsd(totals.warmupCostMicroUsd)
|
|
3366
|
+
};
|
|
3367
|
+
}
|
|
3368
|
+
function netSavingsUsd(totals) {
|
|
3369
|
+
return microUsdToUsd(totals.savedMicroUsd - totals.warmupCostMicroUsd);
|
|
3247
3370
|
}
|
|
3248
3371
|
/**
|
|
3249
3372
|
* Read what cache warming saved on each of the last `days` UTC days, today
|
|
@@ -3254,22 +3377,23 @@ async function readCacheWarmingSavings(days, nowMs = Date.now()) {
|
|
|
3254
3377
|
const dates = Array.from({ length: days }, (_, index) => (/* @__PURE__ */ new Date(nowMs - (days - 1 - index) * DAY_MS)).toISOString().slice(0, 10));
|
|
3255
3378
|
const stats = (await readStats(dates[0], dates.at(-1))).filter((stat) => stat.namespace === SAVINGS_NAMESPACE);
|
|
3256
3379
|
const unknownCostDates = new Set(dates.filter((date) => savingsTotals(stats.filter((stat) => stat.date === date)).historyDays > 0));
|
|
3257
|
-
const known =
|
|
3258
|
-
const
|
|
3380
|
+
const known = savingsTotals(stats.filter((stat) => !unknownCostDates.has(stat.date)));
|
|
3381
|
+
const knownNetSavingsUsd = netSavingsUsd(known);
|
|
3382
|
+
const knownOracleSavingsUsd = microUsdToUsd(known.oracleSavingsMicroUsd);
|
|
3259
3383
|
return cacheWarmingSavingsReportSchema.parse({
|
|
3260
3384
|
days: dates.map((date) => {
|
|
3261
|
-
const day =
|
|
3385
|
+
const day = savingsTotals(stats.filter((stat) => stat.date === date));
|
|
3262
3386
|
return {
|
|
3263
3387
|
date,
|
|
3264
|
-
...day,
|
|
3265
|
-
netSavingsUsd: unknownCostDates.has(date) ? null : day
|
|
3388
|
+
...savingsUsd(day),
|
|
3389
|
+
netSavingsUsd: unknownCostDates.has(date) ? null : netSavingsUsd(day)
|
|
3266
3390
|
};
|
|
3267
3391
|
}),
|
|
3268
3392
|
totals: {
|
|
3269
|
-
...
|
|
3270
|
-
netSavingsUsd,
|
|
3271
|
-
knownCostOracleSavingsUsd:
|
|
3272
|
-
effectiveness:
|
|
3393
|
+
...savingsUsd(savingsTotals(stats)),
|
|
3394
|
+
netSavingsUsd: knownNetSavingsUsd,
|
|
3395
|
+
knownCostOracleSavingsUsd: knownOracleSavingsUsd,
|
|
3396
|
+
effectiveness: knownOracleSavingsUsd > 0 ? knownNetSavingsUsd / knownOracleSavingsUsd : null,
|
|
3273
3397
|
unknownCostDays: unknownCostDates.size
|
|
3274
3398
|
}
|
|
3275
3399
|
});
|
|
@@ -3433,16 +3557,24 @@ function editErrorResponse(error) {
|
|
|
3433
3557
|
}, { status: 400 });
|
|
3434
3558
|
throw error;
|
|
3435
3559
|
}
|
|
3560
|
+
/** Position after the last row of a `sort=activity` page. */
|
|
3561
|
+
const automationListCursorSchema = z.object({
|
|
3562
|
+
activityAtMs: z.number().int().nonnegative(),
|
|
3563
|
+
id: z.string().min(1)
|
|
3564
|
+
}).strict();
|
|
3436
3565
|
/** Create authenticated native task list and action routes. */
|
|
3437
3566
|
function createAutomationRoutes() {
|
|
3438
3567
|
const app = new Hono();
|
|
3439
3568
|
app.get("/", requireViewer, validateRequest("query", automationListQuerySchema, "Invalid task list query."), async (context) => {
|
|
3440
3569
|
const user = context.get("viewer");
|
|
3441
3570
|
const query = context.req.valid("query");
|
|
3442
|
-
|
|
3443
|
-
|
|
3571
|
+
if (query.cursor && query.sort !== "activity") throwApiError(400, "A cursor pages only sort=activity.");
|
|
3572
|
+
const after = query.cursor ? decodePageCursor(automationListCursorSchema, query.cursor, "Invalid Automation list cursor.") : void 0;
|
|
3573
|
+
const { next, ...list } = await readViewerAutomations(user, query, after);
|
|
3574
|
+
return jsonResponse(automationListPageSchema, {
|
|
3444
3575
|
...list,
|
|
3445
|
-
automations: await attachAutomationMentions(getSqlExecutor(), list.automations)
|
|
3576
|
+
automations: await attachAutomationMentions(getSqlExecutor(), list.automations),
|
|
3577
|
+
...next ? { nextCursor: encodePageCursor(automationListCursorSchema, next) } : void 0
|
|
3446
3578
|
});
|
|
3447
3579
|
});
|
|
3448
3580
|
app.get("/event-catalog", requireViewer, () => {
|
|
@@ -3463,12 +3595,7 @@ function createAutomationRoutes() {
|
|
|
3463
3595
|
const user = context.get("viewer");
|
|
3464
3596
|
const params = context.req.valid("param");
|
|
3465
3597
|
try {
|
|
3466
|
-
|
|
3467
|
-
const [automation] = await attachAutomationMentions(getSqlExecutor(), [list.automation]);
|
|
3468
|
-
return jsonResponse(automationExecutionListSchema, {
|
|
3469
|
-
...list,
|
|
3470
|
-
automation
|
|
3471
|
-
});
|
|
3598
|
+
return jsonResponse(automationExecutionListSchema, await readViewerAutomationExecutions(user, params.id));
|
|
3472
3599
|
} catch (error) {
|
|
3473
3600
|
if (error instanceof ViewerTaskNotFoundError) return jsonResponse(apiErrorSchema, { error: error.message }, { status: 404 });
|
|
3474
3601
|
throw error;
|
|
@@ -3928,7 +4055,7 @@ function readDescriptionText(home) {
|
|
|
3928
4055
|
}
|
|
3929
4056
|
/** Read discovered skills for runtime diagnostics and the Automation editor. */
|
|
3930
4057
|
async function readSkillReports() {
|
|
3931
|
-
const { discoverSkills } = await import("./skills-
|
|
4058
|
+
const { discoverSkills } = await import("./skills-63i1Bcv1.js").then((n) => n.o);
|
|
3932
4059
|
const skills = await discoverSkills();
|
|
3933
4060
|
return skillReportsSchema.parse(skills.map((skill) => ({
|
|
3934
4061
|
name: skill.name,
|
|
@@ -3942,7 +4069,7 @@ async function readSkillReports() {
|
|
|
3942
4069
|
* what the skill tells Junior. Returns null when no skill has that name.
|
|
3943
4070
|
*/
|
|
3944
4071
|
async function readSkillDetailReport(name) {
|
|
3945
|
-
const { discoverSkills, findSkillByName, parseSkillFile } = await import("./skills-
|
|
4072
|
+
const { discoverSkills, findSkillByName, parseSkillFile } = await import("./skills-63i1Bcv1.js").then((n) => n.o);
|
|
3946
4073
|
const skill = findSkillByName(name, await discoverSkills());
|
|
3947
4074
|
if (!skill) return null;
|
|
3948
4075
|
const parsed = parseSkillFile(await fs.readFile(path.join(skill.skillPath, "SKILL.md"), "utf8"), skill.name);
|
|
@@ -3957,7 +4084,7 @@ async function readSkillDetailReport(name) {
|
|
|
3957
4084
|
}
|
|
3958
4085
|
/** Read safe configured plugin metadata for authenticated runtime diagnostics. */
|
|
3959
4086
|
async function readPlugins() {
|
|
3960
|
-
const { pluginCatalogRuntime } = await import("./catalog-runtime-
|
|
4087
|
+
const { pluginCatalogRuntime } = await import("./catalog-runtime-OXrv2Ewn.js").then((n) => n.t);
|
|
3961
4088
|
return pluginsSchema.parse(pluginCatalogRuntime.getProviders().map((plugin) => ({
|
|
3962
4089
|
configKeys: plugin.manifest.configKeys ?? [],
|
|
3963
4090
|
description: plugin.manifest.description,
|
|
@@ -3969,7 +4096,7 @@ async function readPlugins() {
|
|
|
3969
4096
|
async function readRuntimeInfoReport() {
|
|
3970
4097
|
const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
|
|
3971
4098
|
import("./package-discovery-x4AvVhMj.js").then((n) => n.r),
|
|
3972
|
-
import("./catalog-runtime-
|
|
4099
|
+
import("./catalog-runtime-OXrv2Ewn.js").then((n) => n.t),
|
|
3973
4100
|
readPlugins(),
|
|
3974
4101
|
readSkillReports()
|
|
3975
4102
|
]);
|
|
@@ -3986,7 +4113,7 @@ async function readRuntimeInfoReport() {
|
|
|
3986
4113
|
/** Read sanitized operational summaries contributed by plugins. */
|
|
3987
4114
|
async function readPluginOperationalReportFeed() {
|
|
3988
4115
|
const nowMs = Date.now();
|
|
3989
|
-
const { getPluginOperationalReports } = await import("./projection-
|
|
4116
|
+
const { getPluginOperationalReports } = await import("./projection-xPpvqexa.js").then((n) => n.Cn);
|
|
3990
4117
|
return pluginOperationalReportFeedSchema.parse({
|
|
3991
4118
|
source: "plugins",
|
|
3992
4119
|
generatedAt: new Date(nowMs).toISOString(),
|
|
@@ -4043,4 +4170,4 @@ function createJuniorApi(options = {}) {
|
|
|
4043
4170
|
});
|
|
4044
4171
|
return app;
|
|
4045
4172
|
}
|
|
4046
|
-
export { DEFAULT_USER_SETTINGS, authenticatePersonalToken, createJuniorApi,
|
|
4173
|
+
export { DEFAULT_USER_SETTINGS, authenticatePersonalToken, createJuniorApi, isAllowedDomain, jsonResponse, parseEmail, readUserSettings, readViewerAvatarUrl, resolveViewerUser, updateUserSettings, updateViewerDisplayName };
|