@sentry/junior 0.286.0 → 0.288.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-JQZaJ-B_.js → adapter-Cikcqdty.js} +1 -1
- package/dist/{admin-Dm2bimJ-.js → admin-BcSxHuTB.js} +2 -1
- package/dist/{agent-runner-DGCwOEyL.js → agent-runner-9MXyWUL8.js} +784 -368
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +9 -8
- package/dist/api.d.ts +1 -1
- package/dist/api.js +411 -65
- package/dist/{app-BKq0JzWx.d.ts → app-BUklJVBe.d.ts} +4 -2
- package/dist/app.d.ts +1 -1
- package/dist/app.js +555 -71
- package/dist/{assistant-reply-CAPafcUY.js → assistant-reply-mj47jMRV.js} +1 -1
- package/dist/{automation-B-jJN_gM.js → automation-DDXwHQs5.js} +4 -7
- package/dist/{background-compaction-queue-Btu2oab_.js → background-compaction-queue-CjllSPir.js} +161 -90
- package/dist/{briefs-UMeYehUe.js → briefs-DW9iuolG.js} +7 -5
- package/dist/{catalog-runtime-Bym8GVdh.js → catalog-runtime-B3gfH58M.js} +1 -1
- package/dist/cli/chat.js +14 -14
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -3
- package/dist/config-CLJcyYEF.js +1762 -0
- package/dist/{connections-CQ7p0aNJ.js → connections-BtdJftow.js} +9 -9
- package/dist/{conversation-BusI2uzj.js → conversation-DhoqHtQ7.js} +30 -6
- package/dist/{conversation-pending-messages-DwehU0Fd.js → conversation-pending-messages-DHV0S4uF.js} +2 -5
- package/dist/{conversation-privacy-Cd_nZZBM.js → conversation-privacy-BPirIVlX.js} +1 -1
- package/dist/core-model-BTt5E5b0.js +182 -0
- package/dist/{credential-sync-DmiJi_At.js → credential-sync-Co8Q2xRW.js} +28 -20
- package/dist/{viewer-CH-ASQzh.js → db-Co7DTYYh.js} +62 -358
- package/dist/{db-C5zi4ecs.d.ts → db-zIs8-Ba3.d.ts} +6 -2
- package/dist/{executor-Dipi2Ixl.js → executor-m0kIN71Q.js} +102 -14
- package/dist/{media-B-BpXo41.js → history-IjdmO_r6.js} +8 -88
- package/dist/instrumentation.js +2 -2
- package/dist/{logging-CMFhLLj4.js → logging-DbD-dErY.js} +3 -2
- package/dist/media-BAHvgkok.js +85 -0
- package/dist/{message-D1xLljUF.js → message-DKTdTYm-.js} +10 -10
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +19 -41
- package/dist/{oauth-callback-server-DCAFIUQr.js → oauth-callback-server-CpbepSbp.js} +2 -2
- package/dist/{projection-CoeMNxJ4.js → projection-BViECfYu.js} +361 -746
- package/dist/{prompt-C9OQEfan.js → prompt-KT6MaDHN.js} +1 -1
- package/dist/{registry-u-sFYtx_.js → registry-D-Acyjhh.js} +1 -1
- package/dist/{reporting-window-B4TwyuJo.js → reporting-window-B3Ze-Qnt.js} +4 -1
- package/dist/{resolve-DYqgL3Eo.js → resolve-gkT2R66z.js} +3 -3
- package/dist/{result-CescSwAw.js → result-DHmCFEt8.js} +8 -8
- package/dist/{runner-Cr67a8TB.js → runner-DBKjGjH-.js} +8 -8
- package/dist/{sandbox-egress-signals-DLOazy5W.js → sandbox-egress-signals-9n8hqx29.js} +1 -1
- package/dist/{schedule-BTp__wrw.js → schedule-cP0AACm1.js} +11 -2
- package/dist/{schema-Ih60j59-.d.ts → schema-B_6aOcx5.d.ts} +159 -3
- package/dist/{schema-BUSi3sgv.js → schema-DxicIQbc.js} +79 -14
- package/dist/{service-account-CsKxktLk.js → service-account-Bi0HsY6w.js} +3 -3
- package/dist/{service-account-CGEqz9wG.js → service-account-CDlC9ssy.js} +3 -3
- package/dist/{session-stop-CGz5DByb.js → session-stop-BWOsuo8p.js} +62 -20
- package/dist/{skills-COCqf61f.js → skills-DO5K68Rq.js} +2 -2
- package/dist/spawn-BBqZDcPa.js +79 -0
- package/dist/{stop-GyFZkHuQ.js → stop-WC97cmHz.js} +832 -552
- package/dist/{store-D0-8plWp.js → store-ByR1Lr7e.js} +4 -16
- package/dist/{task-runner-xPuQmEot.js → task-runner-B-Ewf8TX.js} +30 -21
- package/dist/{turn-failure-response-BOviBdT-.js → turn-failure-response-CpdPoZSl.js} +25 -11
- package/dist/{validation-DZDKorGz.js → validation-B4sbIoES.js} +1 -1
- package/dist/{version-BTIz7fGi.js → version-D6lpuAgL.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/viewer-CeP27tC3.js +337 -0
- package/dist/warmup-P_GJCL1c.js +767 -0
- package/dist/{work-C75_IM5e.js → work-DI7x1Slm.js} +32 -20
- package/dist/{worker-Dl47I729.js → worker-CYPTOT4j.js} +6 -7
- package/migrations/0088_conversation_unsubscribe.sql +1 -0
- package/migrations/0089_conversation_paused_status.sql +3 -0
- package/migrations/0090_guardian_review_time_index.sql +20 -0
- package/migrations/meta/0088_snapshot.json +4372 -0
- package/migrations/meta/0089_snapshot.json +4372 -0
- package/migrations/meta/0090_snapshot.json +4388 -0
- package/migrations/meta/_journal.json +21 -0
- package/package.json +5 -4
- package/dist/client-B0aAs7wC.js +0 -793
- package/dist/config-B9f9Lqo5.js +0 -579
- package/dist/spawn-C8F_iXWO.js +0 -42
package/dist/api.js
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
1
|
-
import { $
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { A as juniorConversations, D as juniorCodeChanges, M as juniorUsers, N as juniorDestinations, O as juniorCodeRepositories, S as juniorConversationMetrics, T as juniorApiTokens, j as juniorIdentities, w as juniorConversationEvents } from "./executor-
|
|
7
|
-
import { n as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { r as
|
|
12
|
-
import {
|
|
13
|
-
import { n as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
1
|
+
import { $n as savePushSubscription, Aa as workspaceRepoCheckoutPath, Bn as getPlugins, Cr as reviewItemNeedsUser, Da as SANDBOX_RUNTIME, Dn as createUserTokenStore, Ja as createConversationAccessReader, Jn as resolveNotificationTimezone, Ka as createPluginLogger, Kn as readWebPushConfig, Oo as createPluginCache, Qn as saveNotificationSchedule, Si as hash, Xn as listPushSubscriptions, Ya as readConversationAccessFromSql, Yn as deletePushSubscription, Za as conversationIsMemberRoot, Zn as readNotificationSchedule, di as getWorkspace, dr as searchReviewItems, er as isPausedBySlack, gi as WorkspaceValidationError, hi as updateWorkspace, hr as canActOnReviewItem, io as readConversationBriefThrough, li as createWorkspace, lr as listWaitingConversations, mi as listWorkspacesByRepository, mr as PLUGIN_REVIEW_ITEM_KEY_PREFIX, ni as getDashboardSettingsLink, oo as readConversationEventPage, pi as listWorkspaces, qn as sendPushNotificationToUser, rr as countReviewItemsNeedingUser, ui as deleteWorkspace, ur as reviewItemsNeedingUserVersionQuery, vr as isOnlyAssignee, wr as reviewItemReaderForUser, xi as create } from "./projection-BViECfYu.js";
|
|
2
|
+
import { D as transcribeAudio, H as findProviderError, J as getAttachmentStorage, R as escapeXml, W as getProviderErrorUserMessage, n as botConfig } from "./config-CLJcyYEF.js";
|
|
3
|
+
import { m as logInfo, p as logException } from "./logging-DbD-dErY.js";
|
|
4
|
+
import { f as parseSlackTeamId, u as parseSlackChannelId } from "./actor-6jsm_v96.js";
|
|
5
|
+
import { V as nextDetailVersion, a as getConversationStore, b as withConversationMutationLock, o as getDb, s as getSqlExecutor, v as loadConversationSlackTenantIds, x as conversationKindFromRow } from "./db-Co7DTYYh.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, j as juniorIdentities, l as juniorReviewItems, s as juniorReviewItemConversations, w as juniorConversationEvents } from "./executor-m0kIN71Q.js";
|
|
7
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-B3gfH58M.js";
|
|
8
|
+
import { $ as readViewerAutomationSummary, A as runWithSlackInstallation, Et as throwApiError, G as changeViewerAutomationLifecycle, J as updateViewerAutomation, Jt as listChildAgents, K as deleteViewerTask, Q as readViewerAutomationRuns, S as createSlackReviewItemShow, Tt as jsonResponse, W as activateViewerAutomationVersion, Y as ViewerTaskNotFoundError, Z as readViewerAutomationExecutions, _t as readLiveAttachment, et as readViewerAutomationVersions, it as listOwnedWatches, m as readStats, mt as webActorFromUser, nt as AutomationEditError, q as readViewerAutomationEdit, tt as readViewerAutomations, v as setConversationSubscription, wt as emptyResponse, xt as archiveConversation } from "./agent-runner-9MXyWUL8.js";
|
|
9
|
+
import { r as completeText } from "./core-model-BTt5E5b0.js";
|
|
10
|
+
import { c as readViewerAvatarUrl, d as updateViewerDisplayName, l as resolveViewerUser, m as readAvatarImage, t as findUserByEmail } from "./viewer-CeP27tC3.js";
|
|
11
|
+
import { r as getStateAdapter } from "./adapter-Cikcqdty.js";
|
|
12
|
+
import { r as notificationScheduleSchema } from "./schedule-cP0AACm1.js";
|
|
13
|
+
import { n as INPUT_IMAGE_TYPES, t as INLINE_VIDEO_TYPES } from "./media-BAHvgkok.js";
|
|
14
|
+
import { A as renameConversationBodySchema, C as createConversationBodySchema, E as forkConversationResponseSchema, M as conversationReadPositionSchema, N as conversationReadReportSchema, T as forkConversationBodySchema, c as conversationDetailQuerySchema, d as conversationEventPageSchema, f as conversationEventsQuerySchema, h as conversationParamsSchema, j as renameConversationResponseSchema, l as conversationDetailReportSchema, m as conversationFeedSchema, n as CONVERSATION_VERSION_HEADER, o as conversationAttachmentParamsSchema, p as conversationFeedQuerySchema, r as acceptedConversationMessageSchema, t as CONVERSATION_DETAIL_VERSION_HEADER, w as createConversationMessageBodySchema } from "./conversation-DhoqHtQ7.js";
|
|
15
|
+
import { n as briefEntriesFromReportEvents } from "./prompt-KT6MaDHN.js";
|
|
16
|
+
import { g as getVercelConversationWorkQueue } from "./background-compaction-queue-CjllSPir.js";
|
|
17
|
+
import { O as getEventCatalog, et as readUserCustomization, rt as isExperimentalFeatureEnabled, tt as saveUserCustomization } from "./session-stop-BWOsuo8p.js";
|
|
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-gkT2R66z.js";
|
|
20
|
+
import { J as AutomationConflictError, St as automationEventCatalog, dt as conversationRangeColumns, ft as conversationUsageCostExpr, lt as conversationActiveDaysColumn, st as readAutomationTitlesByConversationId, ut as conversationAggregateColumns } from "./task-runner-B-Ewf8TX.js";
|
|
21
|
+
import { n as finishServiceAccountSignIn, o as serviceAccountPlugins, r as getServiceAccountStatus, s as startServiceAccountSignIn, t as disconnectServiceAccount } from "./service-account-CDlC9ssy.js";
|
|
22
|
+
import { N as ScheduleIntentError, P as compileScheduleIntent, _ 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-DDXwHQs5.js";
|
|
23
|
+
import { _ as pluginsSchema, b as skillReportsSchema, c as conversationUnchangedDetailWithMailboxSchema, d as healthReportSchema, f as pluginOperationalReportFeedSchema, l as steerConversationPendingMessagesBodySchema, n as cancelConversationPendingMessagesResponseSchema, r as conversationDetailWithMailboxReportSchema, s as conversationPendingMessagesReportSchema, t as cancelConversationPendingMessagesBodySchema, u as steerConversationPendingMessagesResponseSchema, v as runtimeInfoReportSchema } from "./conversation-pending-messages-DHV0S4uF.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, 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, y as conversationSummaryFromStoredConversation } from "./stop-WC97cmHz.js";
|
|
25
|
+
import { a as startConnection, n as isConnectableProvider, r as listConnections, s as htmlCallbackResponse, t as disconnectConnection } from "./connections-BtdJftow.js";
|
|
26
|
+
import { $ as startConnectionResponseSchema, A as personalTokenParamsSchema, At as reorderPinnedConversationsResponseSchema, B as locationParamsSchema, C as serviceAccountParamsSchema, Ct as conversationUnreadSchema, D as createdPersonalTokenSchema, Dt as pinConversationBodySchema, E as createPersonalTokenBodySchema, Et as conversationSubscriptionResponseSchema, F as personParamsSchema, G as notificationSettingsSchema, H as activityHours$1, I as personalSpendReportSchema, J as testNotificationResponseSchema, K as pushSubscriptionBodySchema, M as actorDirectoryReportSchema, Mt as conversationCatchUpSchema, N as actorProfileReportSchema, O as personalTokenListSchema, Ot as pinConversationResponseSchema, P as avatarParamsSchema, Q as disconnectConnectionResponseSchema, R as locationDetailReportSchema, S as serviceAccountListSchema, St as conversationAutoArchiveSchema, T as startServiceAccountSignInResponseSchema, Tt as conversationSubscriptionBodySchema, U as activitySixHours$1, V as activityDays$1, X as connectionParamsSchema, Y as connectionListSchema, _ as reviewItemSchema, at as codeRepositoryParamsSchema, b as transcriptionSchema, bt as archiveConversationResponseSchema, c as workspaceListSchema, ct as boardReportSchema, d as workspaceSchema, f as reviewItemActionSchema, ft as conversationChildAgentsReportSchema, g as reviewItemParamsSchema, gt as conversationStatsReportSchema, h as reviewItemListSchema, ht as stopConversationTurnResponseSchema, i as statsReportSchema, it as codePersonReportSchema, j as revokePersonalTokenResponseSchema, jt as conversationCatchUpBodySchema, kt as reorderPinnedConversationsBodySchema, l as workspaceParamsSchema, m as reviewItemListQuerySchema, mt as continueConversationInSlackResponseSchema, n as versionsSchema, o as deleteWorkspaceResponseSchema, ot as codeRepositoryReportSchema, p as reviewItemCountSchema, pt as continueConversationInSlackBodySchema, q as pushSubscriptionDeleteBodySchema, rt as codeOverviewReportSchema, s as workspaceBodySchema, t as versionsQuerySchema, ut as conversationWatchesReportSchema, v as reviewItemWaitingConversationsSchema, vt as conversationOutlineSchema, wt as markConversationUnreadBodySchema, x as disconnectServiceAccountResponseSchema, xt as archiveDoneConversationsResponseSchema, y as transcriptionRequestSchema, yt as archiveConversationBodySchema, z as locationDirectoryReportSchema } from "./schema-DxicIQbc.js";
|
|
25
27
|
import { Hono } from "hono";
|
|
26
28
|
import path from "node:path";
|
|
27
29
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
28
30
|
import * as z from "zod";
|
|
29
|
-
import { and, asc, desc, eq, gt, gte, inArray, isNull, lte, notExists, or, sql } from "drizzle-orm";
|
|
30
|
-
import { pluginUserPageContentSchema, pluginUserPageCursorSchema, pluginUserPageFilterSchema, pluginUserPageLinksSchema, pluginUserPageQuerySchema } from "@sentry/junior-plugin-api";
|
|
31
|
+
import { and, arrayOverlaps, asc, desc, eq, gt, gte, inArray, isNull, like, lte, notExists, or, sql } from "drizzle-orm";
|
|
32
|
+
import { conversationAnnotationInputSchema, pluginUserPageContentSchema, pluginUserPageCursorSchema, pluginUserPageFilterSchema, pluginUserPageLinksSchema, pluginUserPageQuerySchema } from "@sentry/junior-plugin-api";
|
|
31
33
|
import { alias } from "drizzle-orm/pg-core";
|
|
32
34
|
import { readFileSync } from "node:fs";
|
|
33
35
|
import { HTTPException } from "hono/http-exception";
|
|
@@ -131,7 +133,8 @@ async function generateCatchUp(args) {
|
|
|
131
133
|
modelId: args.modelId
|
|
132
134
|
},
|
|
133
135
|
modelId: args.modelId,
|
|
134
|
-
|
|
136
|
+
operation: "conversation_catch_up",
|
|
137
|
+
cost: args.cost,
|
|
135
138
|
system: CATCH_UP_PROMPT,
|
|
136
139
|
temperature: 0
|
|
137
140
|
})).text);
|
|
@@ -183,6 +186,7 @@ async function catchUpOnConversation(viewer, conversationId, range) {
|
|
|
183
186
|
...brief ? { brief: brief.content } : void 0,
|
|
184
187
|
completeText,
|
|
185
188
|
conversationId,
|
|
189
|
+
cost: { conversationId },
|
|
186
190
|
entries,
|
|
187
191
|
modelId: botConfig.fastModelId,
|
|
188
192
|
omittedEarlierRows,
|
|
@@ -224,20 +228,6 @@ async function renameConversation(viewer, conversationId, body) {
|
|
|
224
228
|
return { title };
|
|
225
229
|
}
|
|
226
230
|
// src/api/conversations/child-agents.ts
|
|
227
|
-
/** Read the kind and archive of each child Conversation. */
|
|
228
|
-
async function readChildKinds(db, childIds) {
|
|
229
|
-
if (childIds.length === 0) return /* @__PURE__ */ new Map();
|
|
230
|
-
const rows = await db.select({
|
|
231
|
-
conversationId: juniorConversations.conversationId,
|
|
232
|
-
kind: juniorConversations.kind,
|
|
233
|
-
archivedAt: juniorConversations.archivedAt,
|
|
234
|
-
parentConversationId: juniorConversations.parentConversationId
|
|
235
|
-
}).from(juniorConversations).where(inArray(juniorConversations.conversationId, [...childIds]));
|
|
236
|
-
return new Map(rows.map((row) => [row.conversationId, {
|
|
237
|
-
archivedAt: row.archivedAt?.toISOString() ?? null,
|
|
238
|
-
kind: conversationKindFromRow(row) === "thread" ? "thread" : "task"
|
|
239
|
-
}]));
|
|
240
|
-
}
|
|
241
231
|
/**
|
|
242
232
|
* Load the direct child agents of one Conversation, or throw a standard API
|
|
243
233
|
* not-found error. Viewers who cannot see private content get only the status,
|
|
@@ -250,11 +240,7 @@ async function requireConversationChildAgents(conversationId, options = {}) {
|
|
|
250
240
|
const [accessByConversation, children] = await Promise.all([readConversationAccessFromSql(db, [conversationId], options.viewer), listChildAgents(conversationId)]);
|
|
251
241
|
const canExposePayload = accessByConversation.get(conversationId)?.canViewPrivateContent ?? false;
|
|
252
242
|
const childIds = children.map((agent) => agent.childConversationId);
|
|
253
|
-
const [metricsByChild, auxiliaryCostsByChild
|
|
254
|
-
readConversationTreeMetricsFromSql(db, childIds),
|
|
255
|
-
readConversationAuxiliaryCostsFromSql(db, childIds),
|
|
256
|
-
readChildKinds(db, childIds)
|
|
257
|
-
]);
|
|
243
|
+
const [metricsByChild, auxiliaryCostsByChild] = await Promise.all([readConversationTreeMetricsFromSql(db, childIds), readConversationAuxiliaryCostsFromSql(db, childIds)]);
|
|
258
244
|
const agents = children.map((agent) => {
|
|
259
245
|
const metrics = metricsByChild.get(agent.childConversationId);
|
|
260
246
|
const auxiliaryCosts = auxiliaryCostsByChild.get(agent.childConversationId);
|
|
@@ -265,10 +251,8 @@ async function requireConversationChildAgents(conversationId, options = {}) {
|
|
|
265
251
|
...metrics?.usage ? { cumulativeUsage: metrics.usage } : void 0,
|
|
266
252
|
...auxiliaryCosts ? { auxiliaryCosts: auxiliaryCosts.total } : void 0,
|
|
267
253
|
...childAgentTotals ? { childAgentTotals } : void 0,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
kind: "task"
|
|
271
|
-
},
|
|
254
|
+
archivedAt: agent.archivedAtMs !== void 0 ? new Date(agent.archivedAtMs).toISOString() : null,
|
|
255
|
+
kind: agent.kind,
|
|
272
256
|
status: agent.status,
|
|
273
257
|
updatedAt: new Date(agent.updatedAtMs).toISOString(),
|
|
274
258
|
...canExposePayload ? {
|
|
@@ -284,6 +268,47 @@ async function requireConversationChildAgents(conversationId, options = {}) {
|
|
|
284
268
|
conversationId
|
|
285
269
|
});
|
|
286
270
|
}
|
|
271
|
+
// src/api/conversations/continue-in-slack.ts
|
|
272
|
+
async function readSlackChannelLocation(locationId) {
|
|
273
|
+
const [row] = await getDb().select({
|
|
274
|
+
channelId: juniorDestinations.providerDestinationId,
|
|
275
|
+
displayName: juniorDestinations.displayName,
|
|
276
|
+
teamId: juniorDestinations.providerTenantId
|
|
277
|
+
}).from(juniorDestinations).where(and(eq(juniorDestinations.id, locationId), eq(juniorDestinations.provider, "slack"), eq(juniorDestinations.kind, "channel")));
|
|
278
|
+
const channelId = parseSlackChannelId(row?.channelId);
|
|
279
|
+
const teamId = parseSlackTeamId(row?.teamId);
|
|
280
|
+
if (!row || !channelId || !teamId) return void 0;
|
|
281
|
+
return {
|
|
282
|
+
channelId,
|
|
283
|
+
...row.displayName ? { channelName: row.displayName } : void 0,
|
|
284
|
+
teamId
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/** Move a participant's public dashboard Conversation to a new Slack thread. */
|
|
288
|
+
async function continueConversationInSlackForViewer(viewer, conversationId, body) {
|
|
289
|
+
const conversation = await getConversationStore().get({ conversationId });
|
|
290
|
+
const access = conversation ? (await readConversationAccessFromSql(getDb(), [conversationId], viewer)).get(conversationId) : void 0;
|
|
291
|
+
if (!conversation || !access?.canViewPrivateContent) throwApiError(404, "Conversation not found.");
|
|
292
|
+
if (!access.isParticipant) throwApiError(403, "Only conversation participants can move it to Slack.");
|
|
293
|
+
if (!canContinueInSlack(conversation, access)) throwApiError(409, "Only a public dashboard conversation can move to Slack, once.");
|
|
294
|
+
const channel = await readSlackChannelLocation(body.locationId);
|
|
295
|
+
if (!channel) throwApiError(404, "Channel not found.");
|
|
296
|
+
const result = await runWithSlackInstallation({
|
|
297
|
+
adapter: getProductionSlackAdapter(),
|
|
298
|
+
installation: { teamId: channel.teamId },
|
|
299
|
+
task: () => continueConversationInSlack({
|
|
300
|
+
actorName: viewer.displayName ?? viewer.email,
|
|
301
|
+
channel,
|
|
302
|
+
conversation
|
|
303
|
+
})
|
|
304
|
+
});
|
|
305
|
+
if (result.status === "refused") throwApiError(409, result.message);
|
|
306
|
+
return {
|
|
307
|
+
conversationId,
|
|
308
|
+
...result.channelName ? { channelName: result.channelName } : void 0,
|
|
309
|
+
...result.locationUrl ? { locationUrl: result.locationUrl } : void 0
|
|
310
|
+
};
|
|
311
|
+
}
|
|
287
312
|
// src/api/conversations/attachments.ts
|
|
288
313
|
const INLINE_TYPES = [...INPUT_IMAGE_TYPES, ...INLINE_VIDEO_TYPES];
|
|
289
314
|
function contentDisposition(filename, contentType) {
|
|
@@ -363,6 +388,50 @@ async function conversationAttachmentResponse(args) {
|
|
|
363
388
|
function notFound() {
|
|
364
389
|
throwApiError(404, "Attachment not found.");
|
|
365
390
|
}
|
|
391
|
+
// src/api/conversations/outline.ts
|
|
392
|
+
const payload = juniorConversationEvents.payload;
|
|
393
|
+
/**
|
|
394
|
+
* List the person messages of a whole Conversation for the dashboard
|
|
395
|
+
* outline. The dashboard transcript loads only the latest pages, so the
|
|
396
|
+
* outline cannot build its items from the loaded rows alone.
|
|
397
|
+
*
|
|
398
|
+
* It uses the same rules as the transcript: Event messages are not person
|
|
399
|
+
* messages, and a message that does not mention Junior is thread context.
|
|
400
|
+
* The `message_role_idx` index reads only this Conversation's user
|
|
401
|
+
* messages, so the cost grows with the person messages, not all events.
|
|
402
|
+
*/
|
|
403
|
+
async function readConversationOutline(conversationId, options = {}) {
|
|
404
|
+
const access = (await readConversationAccessFromSql(getDb(), [conversationId], options.viewer)).get(conversationId);
|
|
405
|
+
if (!access) return void 0;
|
|
406
|
+
if (!access.canViewPrivateContent) return { items: [] };
|
|
407
|
+
const items = (await getDb().select({
|
|
408
|
+
seq: juniorConversationEvents.seq,
|
|
409
|
+
text: sql`left(${payload}->>'text', ${200})`
|
|
410
|
+
}).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) => {
|
|
411
|
+
const text = withoutCutToken(row.text).trim();
|
|
412
|
+
return text ? [{
|
|
413
|
+
seq: row.seq,
|
|
414
|
+
text
|
|
415
|
+
}] : [];
|
|
416
|
+
});
|
|
417
|
+
const tenantId = (await loadConversationSlackTenantIds(getSqlExecutor(), [conversationId])).get(conversationId);
|
|
418
|
+
const mentions = await resolveMentions(getSqlExecutor(), items.map((item) => ({
|
|
419
|
+
tenantId,
|
|
420
|
+
texts: [item.text]
|
|
421
|
+
})));
|
|
422
|
+
return { items: items.map((item, index) => mentions[index].length > 0 ? {
|
|
423
|
+
...item,
|
|
424
|
+
mentions: mentions[index]
|
|
425
|
+
} : item) };
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Repair a Slack token that the length cut split. A cut mention, such as
|
|
429
|
+
* `<@U12`, cannot resolve, so it is dropped. A cut link keeps its URL text,
|
|
430
|
+
* so a message that is only a long link still has a title.
|
|
431
|
+
*/
|
|
432
|
+
function withoutCutToken(text) {
|
|
433
|
+
return text.length < 200 ? text : text.replace(/<([^<>]*)$/, (_, token) => /^[@#!]/.test(token) ? "" : token.split("|")[0]);
|
|
434
|
+
}
|
|
366
435
|
// src/api/conversations/metric-buckets.ts
|
|
367
436
|
/** Sum all Conversation metrics into UTC day or hour buckets. */
|
|
368
437
|
async function readConversationMetricBuckets(db, options) {
|
|
@@ -810,6 +879,7 @@ function createConversationRoutes(options) {
|
|
|
810
879
|
return jsonResponse(archiveConversationResponseSchema, await archiveConversation(viewer, conversationId, body));
|
|
811
880
|
});
|
|
812
881
|
app.patch("/:conversationId/pin", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", pinConversationBodySchema, "Invalid request body."), async (context) => jsonResponse(pinConversationResponseSchema, await pinConversation(context.get("viewer"), context.req.valid("param").conversationId, context.req.valid("json"))));
|
|
882
|
+
app.patch("/:conversationId/subscription", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", conversationSubscriptionBodySchema, "Invalid request body."), async (context) => jsonResponse(conversationSubscriptionResponseSchema, await setConversationSubscription(context.get("viewer"), context.req.valid("param").conversationId, context.req.valid("json"))));
|
|
813
883
|
app.patch("/:conversationId/unread", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", markConversationUnreadBodySchema, "Invalid request body."), async (context) => jsonResponse(conversationUnreadSchema, await markConversationUnread(context.get("viewer"), context.req.valid("param").conversationId, context.req.valid("json"))));
|
|
814
884
|
app.patch("/:conversationId/title", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", renameConversationBodySchema, "Invalid request body."), async (context) => jsonResponse(renameConversationResponseSchema, await renameConversation(context.get("viewer"), context.req.valid("param").conversationId, context.req.valid("json"))));
|
|
815
885
|
app.put("/:conversationId/read-position", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", conversationReadPositionSchema, "Invalid request body."), async (context) => {
|
|
@@ -838,6 +908,13 @@ function createConversationRoutes(options) {
|
|
|
838
908
|
if (!report) throwApiError(404, "Conversation not found.");
|
|
839
909
|
return jsonResponse(conversationEventPageSchema, report);
|
|
840
910
|
});
|
|
911
|
+
app.get("/:conversationId/outline", validateRequest("param", conversationParamsSchema, "Invalid route parameters."), async (context) => {
|
|
912
|
+
const { conversationId } = context.req.valid("param");
|
|
913
|
+
const viewer = context.get("viewer");
|
|
914
|
+
const outline = await readConversationOutline(conversationId, viewer ? { viewer } : void 0);
|
|
915
|
+
if (!outline) throwApiError(404, "Conversation not found.");
|
|
916
|
+
return jsonResponse(conversationOutlineSchema, outline);
|
|
917
|
+
});
|
|
841
918
|
app.get("/:conversationId/agents", validateRequest("param", conversationParamsSchema, "Invalid route parameters."), async (context) => {
|
|
842
919
|
const { conversationId } = context.req.valid("param");
|
|
843
920
|
const viewer = context.get("viewer");
|
|
@@ -907,7 +984,10 @@ function createConversationRoutes(options) {
|
|
|
907
984
|
});
|
|
908
985
|
const report = await readConversationDetail(conversationId, {
|
|
909
986
|
...query,
|
|
910
|
-
...version ? {
|
|
987
|
+
...version ? { stored: {
|
|
988
|
+
record: version.record,
|
|
989
|
+
state: version.state
|
|
990
|
+
} } : void 0,
|
|
911
991
|
...viewerOptions
|
|
912
992
|
});
|
|
913
993
|
if (!report) throwApiError(404, "Conversation not found.");
|
|
@@ -919,6 +999,239 @@ function createConversationRoutes(options) {
|
|
|
919
999
|
});
|
|
920
1000
|
return app;
|
|
921
1001
|
}
|
|
1002
|
+
// src/api/board/columns.ts
|
|
1003
|
+
const DONE_WINDOW_MS = 216e5;
|
|
1004
|
+
/** Choose the column of a code change that Junior created. */
|
|
1005
|
+
function codeChangeColumn(args) {
|
|
1006
|
+
if (args.state === "merged") return args.mergedAtMs !== void 0 && args.nowMs - args.mergedAtMs <= DONE_WINDOW_MS ? "done" : void 0;
|
|
1007
|
+
if (args.state === "closed") return void 0;
|
|
1008
|
+
return args.hasReadyNotice ? "ready" : "in_progress";
|
|
1009
|
+
}
|
|
1010
|
+
/** Choose the column of a ticket linked to a Conversation. */
|
|
1011
|
+
function ticketColumn(args) {
|
|
1012
|
+
if (args.status === "closed") return args.nowMs - args.updatedAtMs <= DONE_WINDOW_MS ? "done" : void 0;
|
|
1013
|
+
if (args.status !== "open") return void 0;
|
|
1014
|
+
return args.working ? "in_progress" : "planned";
|
|
1015
|
+
}
|
|
1016
|
+
// src/api/board/read.ts
|
|
1017
|
+
/** Root Conversations with activity in this window feed the Board. */
|
|
1018
|
+
const ACTIVE_WINDOW_MS = 12096e5;
|
|
1019
|
+
/** Bound the Board to the viewer's most recent root Conversations. */
|
|
1020
|
+
const ROOT_LIMIT = 200;
|
|
1021
|
+
function parentOf(nodes, node) {
|
|
1022
|
+
return node.parentConversationId ? nodes.get(node.parentConversationId) : void 0;
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* A card belongs to the nearest root or Thread. People do not message a
|
|
1026
|
+
* Task, so its work shows on its parent. A row from an older deploy has no
|
|
1027
|
+
* kind; a child without a kind is treated as a Task. A Conversation shows
|
|
1028
|
+
* only while it and every ancestor are unarchived.
|
|
1029
|
+
*/
|
|
1030
|
+
function homeId(nodes, conversationId) {
|
|
1031
|
+
const start = nodes.get(conversationId);
|
|
1032
|
+
for (let node = start; node; node = parentOf(nodes, node)) if (node.archived) return void 0;
|
|
1033
|
+
let node = start;
|
|
1034
|
+
while (node && (node.kind === "task" || !node.kind && node.parentConversationId)) node = parentOf(nodes, node);
|
|
1035
|
+
return node?.conversationId;
|
|
1036
|
+
}
|
|
1037
|
+
function rootOf(nodes, node) {
|
|
1038
|
+
let current = node;
|
|
1039
|
+
for (let parent = parentOf(nodes, current); parent; parent = parentOf(nodes, parent)) current = parent;
|
|
1040
|
+
return current;
|
|
1041
|
+
}
|
|
1042
|
+
async function readViewerTrees(userId, nowMs) {
|
|
1043
|
+
const db = getDb();
|
|
1044
|
+
const rootIds = (await db.select({ conversationId: juniorConversations.conversationId }).from(juniorConversations).where(and(conversationIsMemberRoot({ userId }), isNull(juniorConversations.parentConversationId), isNull(juniorConversations.archivedAt), isNull(juniorConversations.quickQuestionAt), gte(juniorConversations.lastActivityAt, /* @__PURE__ */ new Date(nowMs - ACTIVE_WINDOW_MS)))).orderBy(desc(juniorConversations.lastActivityAt)).limit(ROOT_LIMIT)).map((row) => row.conversationId);
|
|
1045
|
+
if (rootIds.length === 0) return {
|
|
1046
|
+
nodes: /* @__PURE__ */ new Map(),
|
|
1047
|
+
rootIds
|
|
1048
|
+
};
|
|
1049
|
+
const rows = await db.select({
|
|
1050
|
+
archivedAt: juniorConversations.archivedAt,
|
|
1051
|
+
conversationId: juniorConversations.conversationId,
|
|
1052
|
+
createdAt: juniorConversations.createdAt,
|
|
1053
|
+
kind: juniorConversations.kind,
|
|
1054
|
+
parentConversationId: juniorConversations.parentConversationId,
|
|
1055
|
+
status: juniorConversations.executionStatus,
|
|
1056
|
+
title: juniorConversations.title
|
|
1057
|
+
}).from(juniorConversations).where(or(inArray(juniorConversations.conversationId, rootIds), inArray(juniorConversations.rootConversationId, rootIds)));
|
|
1058
|
+
return {
|
|
1059
|
+
nodes: new Map(rows.map((row) => [row.conversationId, {
|
|
1060
|
+
archived: row.archivedAt !== null,
|
|
1061
|
+
conversationId: row.conversationId,
|
|
1062
|
+
createdAtMs: row.createdAt.getTime(),
|
|
1063
|
+
kind: row.kind,
|
|
1064
|
+
parentConversationId: row.parentConversationId,
|
|
1065
|
+
status: row.status,
|
|
1066
|
+
title: row.title
|
|
1067
|
+
}])),
|
|
1068
|
+
rootIds
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Read the viewer's Board: the code changes and tickets of their recent
|
|
1073
|
+
* Conversations, each in one column. See `./columns` for the column rules.
|
|
1074
|
+
*/
|
|
1075
|
+
async function readBoard(args) {
|
|
1076
|
+
const db = getDb();
|
|
1077
|
+
const { nodes, rootIds } = await readViewerTrees(args.userId, args.nowMs);
|
|
1078
|
+
const treeIds = [...nodes.keys()];
|
|
1079
|
+
if (treeIds.length === 0) return {
|
|
1080
|
+
cards: [],
|
|
1081
|
+
doneWindowHours: 6
|
|
1082
|
+
};
|
|
1083
|
+
const doneSince = /* @__PURE__ */ new Date(args.nowMs - 216e5);
|
|
1084
|
+
const [codeChanges, ticketRows, needsViewerRows, participants] = await Promise.all([
|
|
1085
|
+
db.select({
|
|
1086
|
+
conversationIds: juniorCodeChanges.conversationIds,
|
|
1087
|
+
id: juniorCodeChanges.id,
|
|
1088
|
+
mergedAt: juniorCodeChanges.mergedAt,
|
|
1089
|
+
number: juniorCodeChanges.number,
|
|
1090
|
+
repository: juniorCodeRepositories.name,
|
|
1091
|
+
state: juniorCodeChanges.state,
|
|
1092
|
+
title: juniorCodeChanges.title,
|
|
1093
|
+
updatedAt: juniorCodeChanges.updatedAt,
|
|
1094
|
+
url: juniorCodeChanges.url
|
|
1095
|
+
}).from(juniorCodeChanges).innerJoin(juniorCodeRepositories, eq(juniorCodeRepositories.id, juniorCodeChanges.repositoryId)).where(and(or(eq(juniorCodeChanges.state, "open"), and(eq(juniorCodeChanges.state, "merged"), gte(juniorCodeChanges.mergedAt, doneSince))), arrayOverlaps(juniorCodeChanges.conversationIds, treeIds))),
|
|
1096
|
+
db.select({
|
|
1097
|
+
annotation: juniorConversationAnnotations.annotation,
|
|
1098
|
+
conversationId: juniorConversationAnnotations.conversationId,
|
|
1099
|
+
key: juniorConversationAnnotations.key,
|
|
1100
|
+
plugin: juniorConversationAnnotations.plugin,
|
|
1101
|
+
updatedAt: juniorConversationAnnotations.updatedAt
|
|
1102
|
+
}).from(juniorConversationAnnotations).where(and(inArray(juniorConversationAnnotations.conversationId, treeIds), sql`${juniorConversationAnnotations.annotation}->>'objectType' = 'task'`)),
|
|
1103
|
+
db.selectDistinct({ conversationId: juniorReviewItemConversations.conversationId }).from(juniorReviewItemConversations).innerJoin(juniorReviewItems, eq(juniorReviewItems.id, juniorReviewItemConversations.itemId)).where(and(inArray(juniorReviewItemConversations.conversationId, treeIds), reviewItemNeedsUser(args.userId))),
|
|
1104
|
+
readConversationParticipants(db, rootIds)
|
|
1105
|
+
]);
|
|
1106
|
+
const codeChangeUrls = codeChanges.flatMap((change) => change.state === "open" && change.url ? [change.url] : []);
|
|
1107
|
+
const readyUrls = new Set(codeChangeUrls.length === 0 ? [] : (await db.select({ subjectId: juniorReviewItems.subjectId }).from(juniorReviewItems).where(and(eq(juniorReviewItems.status, "open"), eq(juniorReviewItems.kind, "notice"), like(juniorReviewItems.dedupeKey, `${PLUGIN_REVIEW_ITEM_KEY_PREFIX}%`), inArray(juniorReviewItems.subjectId, codeChangeUrls)))).flatMap((row) => row.subjectId ? [row.subjectId] : []));
|
|
1108
|
+
const homes = /* @__PURE__ */ new Map();
|
|
1109
|
+
const workingHomes = /* @__PURE__ */ new Set();
|
|
1110
|
+
const needsViewerHomes = /* @__PURE__ */ new Set();
|
|
1111
|
+
for (const node of nodes.values()) {
|
|
1112
|
+
if (node.status !== "running" && node.status !== "pending") continue;
|
|
1113
|
+
const home = homeId(nodes, node.conversationId);
|
|
1114
|
+
if (home) workingHomes.add(home);
|
|
1115
|
+
}
|
|
1116
|
+
for (const row of needsViewerRows) {
|
|
1117
|
+
const home = homeId(nodes, row.conversationId);
|
|
1118
|
+
if (home) needsViewerHomes.add(home);
|
|
1119
|
+
}
|
|
1120
|
+
const homeFor = (conversationIds) => {
|
|
1121
|
+
let node;
|
|
1122
|
+
for (const conversationId of conversationIds) {
|
|
1123
|
+
const candidateId = homeId(nodes, conversationId);
|
|
1124
|
+
const candidate = candidateId ? nodes.get(candidateId) : void 0;
|
|
1125
|
+
if (!candidate) continue;
|
|
1126
|
+
if (!node || candidate.createdAtMs < node.createdAtMs || candidate.createdAtMs === node.createdAtMs && candidate.conversationId < node.conversationId) node = candidate;
|
|
1127
|
+
}
|
|
1128
|
+
if (!node) return void 0;
|
|
1129
|
+
const id = node.conversationId;
|
|
1130
|
+
const cached = homes.get(id);
|
|
1131
|
+
if (cached) return cached;
|
|
1132
|
+
const root = rootOf(nodes, node);
|
|
1133
|
+
const home = {
|
|
1134
|
+
conversation: {
|
|
1135
|
+
conversationId: id,
|
|
1136
|
+
...node.title ? { title: node.title } : void 0,
|
|
1137
|
+
...root !== node && root.title ? { rootTitle: root.title } : void 0
|
|
1138
|
+
},
|
|
1139
|
+
needsViewer: needsViewerHomes.has(id),
|
|
1140
|
+
participants: participants.get(root.conversationId) ?? [],
|
|
1141
|
+
working: workingHomes.has(id)
|
|
1142
|
+
};
|
|
1143
|
+
homes.set(id, home);
|
|
1144
|
+
return home;
|
|
1145
|
+
};
|
|
1146
|
+
const cards = [];
|
|
1147
|
+
for (const change of codeChanges) {
|
|
1148
|
+
const home = homeFor(change.conversationIds);
|
|
1149
|
+
if (!home) continue;
|
|
1150
|
+
const mergedAtMs = change.mergedAt?.getTime();
|
|
1151
|
+
const column = codeChangeColumn({
|
|
1152
|
+
hasReadyNotice: Boolean(change.url && readyUrls.has(change.url)),
|
|
1153
|
+
...mergedAtMs !== void 0 ? { mergedAtMs } : void 0,
|
|
1154
|
+
nowMs: args.nowMs,
|
|
1155
|
+
state: change.state
|
|
1156
|
+
});
|
|
1157
|
+
if (!column) continue;
|
|
1158
|
+
const label = `${change.repository}#${change.number}`;
|
|
1159
|
+
cards.push({
|
|
1160
|
+
column,
|
|
1161
|
+
conversation: home.conversation,
|
|
1162
|
+
key: `code_change:${change.id}`,
|
|
1163
|
+
label,
|
|
1164
|
+
needsViewer: home.needsViewer,
|
|
1165
|
+
objectType: "code_change",
|
|
1166
|
+
participants: home.participants,
|
|
1167
|
+
status: change.state,
|
|
1168
|
+
title: change.title ?? label,
|
|
1169
|
+
updatedAt: (change.mergedAt ?? change.updatedAt).toISOString(),
|
|
1170
|
+
...change.url ? { url: change.url } : void 0,
|
|
1171
|
+
working: home.working
|
|
1172
|
+
});
|
|
1173
|
+
}
|
|
1174
|
+
const tickets = /* @__PURE__ */ new Map();
|
|
1175
|
+
for (const row of ticketRows) {
|
|
1176
|
+
const key = `${row.plugin}:${row.key}`;
|
|
1177
|
+
const current = tickets.get(key);
|
|
1178
|
+
if (!current) {
|
|
1179
|
+
tickets.set(key, {
|
|
1180
|
+
conversationIds: /* @__PURE__ */ new Set([row.conversationId]),
|
|
1181
|
+
latest: row
|
|
1182
|
+
});
|
|
1183
|
+
continue;
|
|
1184
|
+
}
|
|
1185
|
+
current.conversationIds.add(row.conversationId);
|
|
1186
|
+
if (row.updatedAt > current.latest.updatedAt) current.latest = row;
|
|
1187
|
+
}
|
|
1188
|
+
for (const [key, ticket] of tickets) {
|
|
1189
|
+
const parsed = conversationAnnotationInputSchema.safeParse(ticket.latest.annotation);
|
|
1190
|
+
if (!parsed.success) continue;
|
|
1191
|
+
const annotation = parsed.data;
|
|
1192
|
+
const status = annotation.status;
|
|
1193
|
+
if (!status) continue;
|
|
1194
|
+
const home = homeFor(ticket.conversationIds);
|
|
1195
|
+
if (!home) continue;
|
|
1196
|
+
const column = ticketColumn({
|
|
1197
|
+
nowMs: args.nowMs,
|
|
1198
|
+
status,
|
|
1199
|
+
updatedAtMs: ticket.latest.updatedAt.getTime(),
|
|
1200
|
+
working: home.working
|
|
1201
|
+
});
|
|
1202
|
+
if (!column) continue;
|
|
1203
|
+
const title = annotation.kind === "object" ? annotation.title : annotation.description ?? annotation.label;
|
|
1204
|
+
cards.push({
|
|
1205
|
+
column,
|
|
1206
|
+
conversation: home.conversation,
|
|
1207
|
+
key: `ticket:${key}`,
|
|
1208
|
+
label: annotation.label,
|
|
1209
|
+
needsViewer: home.needsViewer,
|
|
1210
|
+
objectType: "task",
|
|
1211
|
+
participants: home.participants,
|
|
1212
|
+
status,
|
|
1213
|
+
title,
|
|
1214
|
+
updatedAt: ticket.latest.updatedAt.toISOString(),
|
|
1215
|
+
...annotation.url ? { url: annotation.url } : void 0,
|
|
1216
|
+
working: home.working
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
cards.sort((left, right) => right.updatedAt.localeCompare(left.updatedAt));
|
|
1220
|
+
return {
|
|
1221
|
+
cards,
|
|
1222
|
+
doneWindowHours: 6
|
|
1223
|
+
};
|
|
1224
|
+
}
|
|
1225
|
+
// src/api/board/routes.ts
|
|
1226
|
+
/** Create the viewer's Board API. */
|
|
1227
|
+
function createBoardRoutes() {
|
|
1228
|
+
const app = new Hono();
|
|
1229
|
+
app.get("/", requireViewer, async (context) => jsonResponse(boardReportSchema, await readBoard({
|
|
1230
|
+
nowMs: Date.now(),
|
|
1231
|
+
userId: context.get("viewer").id
|
|
1232
|
+
}), { headers: { "cache-control": "private, no-store" } }));
|
|
1233
|
+
return app;
|
|
1234
|
+
}
|
|
922
1235
|
// src/api/code/overview.ts
|
|
923
1236
|
const DAY_MS = 864e5;
|
|
924
1237
|
const WINDOW_DAYS = 30;
|
|
@@ -1426,17 +1739,22 @@ async function readSettings(userId) {
|
|
|
1426
1739
|
const db = getDb();
|
|
1427
1740
|
const nowMs = Date.now();
|
|
1428
1741
|
const schedule = await readNotificationSchedule(db, userId);
|
|
1429
|
-
const [{ source, timezone }, subscriptions] = await Promise.all([
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1742
|
+
const [{ source, timezone }, subscriptions, slackPausedNow] = await Promise.all([
|
|
1743
|
+
resolveNotificationTimezone({
|
|
1744
|
+
db,
|
|
1745
|
+
nowMs,
|
|
1746
|
+
schedule,
|
|
1747
|
+
userId
|
|
1748
|
+
}),
|
|
1749
|
+
listPushSubscriptions(db, userId),
|
|
1750
|
+
isPausedBySlack(db, userId, nowMs)
|
|
1751
|
+
]);
|
|
1435
1752
|
const config = readWebPushConfig();
|
|
1436
1753
|
return notificationSettingsSchema.parse({
|
|
1437
1754
|
...config ? { publicKey: config.publicKey } : void 0,
|
|
1438
1755
|
deviceCount: subscriptions.length,
|
|
1439
1756
|
schedule,
|
|
1757
|
+
slackPausedNow,
|
|
1440
1758
|
timezone,
|
|
1441
1759
|
timezoneSource: source
|
|
1442
1760
|
});
|
|
@@ -1445,7 +1763,7 @@ async function settingsResponse(userId) {
|
|
|
1445
1763
|
return jsonResponse(notificationSettingsSchema, await readSettings(userId));
|
|
1446
1764
|
}
|
|
1447
1765
|
/**
|
|
1448
|
-
* Create authenticated routes for the viewer's
|
|
1766
|
+
* Create authenticated routes for the viewer's push notifications: browser
|
|
1449
1767
|
* subscriptions, notification hours, and a test notification.
|
|
1450
1768
|
*/
|
|
1451
1769
|
function createNotificationRoutes() {
|
|
@@ -1457,7 +1775,7 @@ function createNotificationRoutes() {
|
|
|
1457
1775
|
return await settingsResponse(viewer.id);
|
|
1458
1776
|
});
|
|
1459
1777
|
app.post("/subscriptions", requireViewer, validateRequest("json", pushSubscriptionBodySchema, "Invalid subscription."), async (context) => {
|
|
1460
|
-
if (!readWebPushConfig()) throwApiError(503, "
|
|
1778
|
+
if (!readWebPushConfig()) throwApiError(503, "Push notifications are not configured.");
|
|
1461
1779
|
const viewer = context.get("viewer");
|
|
1462
1780
|
const { endpoint, keys } = context.req.valid("json");
|
|
1463
1781
|
await savePushSubscription(getDb(), viewer.id, {
|
|
@@ -1475,7 +1793,7 @@ function createNotificationRoutes() {
|
|
|
1475
1793
|
});
|
|
1476
1794
|
app.post("/test", requireViewer, async (context) => {
|
|
1477
1795
|
const config = readWebPushConfig();
|
|
1478
|
-
if (!config) throwApiError(503, "
|
|
1796
|
+
if (!config) throwApiError(503, "Push notifications are not configured.");
|
|
1479
1797
|
const result = await sendPushNotificationToUser({
|
|
1480
1798
|
config,
|
|
1481
1799
|
db: getDb(),
|
|
@@ -2272,7 +2590,7 @@ async function readPeoplePluginReports(args) {
|
|
|
2272
2590
|
reports: [],
|
|
2273
2591
|
source: "plugins"
|
|
2274
2592
|
});
|
|
2275
|
-
const { getPluginProfileReports } = await import("./projection-
|
|
2593
|
+
const { getPluginProfileReports } = await import("./projection-BViECfYu.js").then((n) => n.Mn);
|
|
2276
2594
|
return pluginOperationalReportFeedSchema.parse({
|
|
2277
2595
|
generatedAt: new Date(nowMs).toISOString(),
|
|
2278
2596
|
reports: await getPluginProfileReports({
|
|
@@ -2985,6 +3303,32 @@ function createAutomationRoutes() {
|
|
|
2985
3303
|
});
|
|
2986
3304
|
return app;
|
|
2987
3305
|
}
|
|
3306
|
+
// src/api/transcriptions/routes.ts
|
|
3307
|
+
/** Create the route that turns one dashboard dictation recording into text. */
|
|
3308
|
+
function createTranscriptionRoutes() {
|
|
3309
|
+
const app = new Hono();
|
|
3310
|
+
app.post("/", requireViewer, bodyLimit({
|
|
3311
|
+
maxSize: 445e4,
|
|
3312
|
+
onError: () => {
|
|
3313
|
+
throwApiError(413, "Recording is too long.");
|
|
3314
|
+
}
|
|
3315
|
+
}), validateRequest("json", transcriptionRequestSchema, "Send the recording as base64 audio."), async (context) => {
|
|
3316
|
+
const audio = Buffer.from(context.req.valid("json").audio, "base64");
|
|
3317
|
+
try {
|
|
3318
|
+
const { text } = await transcribeAudio({
|
|
3319
|
+
audio,
|
|
3320
|
+
modelId: botConfig.transcriptionModelId,
|
|
3321
|
+
signal: context.req.raw.signal
|
|
3322
|
+
});
|
|
3323
|
+
return jsonResponse(transcriptionSchema, { text: text.trim() });
|
|
3324
|
+
} catch (error) {
|
|
3325
|
+
const providerError = findProviderError(error);
|
|
3326
|
+
if (!providerError) throw error;
|
|
3327
|
+
throwApiError(502, getProviderErrorUserMessage(providerError), providerError);
|
|
3328
|
+
}
|
|
3329
|
+
});
|
|
3330
|
+
return app;
|
|
3331
|
+
}
|
|
2988
3332
|
// src/api/user-customization/routes.ts
|
|
2989
3333
|
/**
|
|
2990
3334
|
* Create routes that read and replace the viewer's customization. They return
|
|
@@ -3301,7 +3645,7 @@ function readDescriptionText(home) {
|
|
|
3301
3645
|
}
|
|
3302
3646
|
/** Read discovered skill names for authenticated runtime diagnostics. */
|
|
3303
3647
|
async function readSkillReports() {
|
|
3304
|
-
const { discoverSkills } = await import("./skills-
|
|
3648
|
+
const { discoverSkills } = await import("./skills-DO5K68Rq.js").then((n) => n.o);
|
|
3305
3649
|
const skills = await discoverSkills();
|
|
3306
3650
|
return skillReportsSchema.parse(skills.map((skill) => ({
|
|
3307
3651
|
name: skill.name,
|
|
@@ -3310,7 +3654,7 @@ async function readSkillReports() {
|
|
|
3310
3654
|
}
|
|
3311
3655
|
/** Read safe configured plugin metadata for authenticated runtime diagnostics. */
|
|
3312
3656
|
async function readPlugins() {
|
|
3313
|
-
const { pluginCatalogRuntime } = await import("./catalog-runtime-
|
|
3657
|
+
const { pluginCatalogRuntime } = await import("./catalog-runtime-B3gfH58M.js").then((n) => n.t);
|
|
3314
3658
|
return pluginsSchema.parse(pluginCatalogRuntime.getProviders().map((plugin) => ({
|
|
3315
3659
|
configKeys: plugin.manifest.configKeys ?? [],
|
|
3316
3660
|
description: plugin.manifest.description,
|
|
@@ -3322,7 +3666,7 @@ async function readPlugins() {
|
|
|
3322
3666
|
async function readRuntimeInfoReport() {
|
|
3323
3667
|
const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
|
|
3324
3668
|
import("./package-discovery-DJhGdS4c.js").then((n) => n.r),
|
|
3325
|
-
import("./catalog-runtime-
|
|
3669
|
+
import("./catalog-runtime-B3gfH58M.js").then((n) => n.t),
|
|
3326
3670
|
readPlugins(),
|
|
3327
3671
|
readSkillReports()
|
|
3328
3672
|
]);
|
|
@@ -3339,7 +3683,7 @@ async function readRuntimeInfoReport() {
|
|
|
3339
3683
|
/** Read sanitized operational summaries contributed by plugins. */
|
|
3340
3684
|
async function readPluginOperationalReportFeed() {
|
|
3341
3685
|
const nowMs = Date.now();
|
|
3342
|
-
const { getPluginOperationalReports } = await import("./projection-
|
|
3686
|
+
const { getPluginOperationalReports } = await import("./projection-BViECfYu.js").then((n) => n.Mn);
|
|
3343
3687
|
return pluginOperationalReportFeedSchema.parse({
|
|
3344
3688
|
source: "plugins",
|
|
3345
3689
|
generatedAt: new Date(nowMs).toISOString(),
|
|
@@ -3366,6 +3710,7 @@ function createJuniorApi(options = {}) {
|
|
|
3366
3710
|
queue,
|
|
3367
3711
|
show: createSlackReviewItemShow(getProductionSlackAdapter)
|
|
3368
3712
|
} }));
|
|
3713
|
+
app.route("/api/board", createBoardRoutes());
|
|
3369
3714
|
app.route("/api/code", createCodeRoutes());
|
|
3370
3715
|
app.route("/api/connections", createConnectionRoutes());
|
|
3371
3716
|
app.route("/api/notifications", createNotificationRoutes());
|
|
@@ -3374,6 +3719,7 @@ function createJuniorApi(options = {}) {
|
|
|
3374
3719
|
app.route("/api/people", createPeopleRoutes());
|
|
3375
3720
|
app.route("/api/locations", createLocationRoutes());
|
|
3376
3721
|
app.route("/api/user-pages", createUserPageRoutes());
|
|
3722
|
+
app.route("/api/transcriptions", createTranscriptionRoutes());
|
|
3377
3723
|
app.route("/api/user-customization", createUserCustomizationRoutes());
|
|
3378
3724
|
app.route("/api/automations", createAutomationRoutes());
|
|
3379
3725
|
app.route("/api/workspaces", createWorkspaceRoutes());
|