@sentry/junior 0.306.0 → 0.307.1
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-CnY-i32r.js → adapter-context-HrBTD8rJ.js} +2 -2
- package/dist/{admin-BLLdLnXh.js → admin-B78_KmfR.js} +2 -2
- package/dist/{agent-runner-BaLjEjPR.js → agent-runner-DxivxUYd.js} +226 -137
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +4 -4
- package/dist/api.d.ts +1 -1
- package/dist/api.js +328 -298
- package/dist/{app-DvYbM9UD.d.ts → app-EZur8cVC.d.ts} +12 -3
- package/dist/app.d.ts +2 -2
- package/dist/app.js +84 -44
- package/dist/background-compaction-queue-HlljT9ql.js +231 -0
- package/dist/{briefs-DvyzXfrF.js → briefs-DR8mp-TK.js} +2 -2
- package/dist/{catalog-runtime-B1R-nHd3.js → catalog-runtime-Se9idiDR.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-DUD-zMvp.js → config-DY5c1E0l.js} +74 -38
- package/dist/{connections-CDhsqPcC.js → connections-C-SqzubG.js} +10 -8
- package/dist/{continue-in-slack-BXQizz9o.js → continue-in-slack-DNkrrWuQ.js} +5 -5
- package/dist/{conversation-privacy-YE54gMN8.js → conversation-privacy-CVj9vSrP.js} +1 -1
- package/dist/{conversation-turn-BzdmrHb0.js → conversation-turn-CkzrIfJ2.js} +19 -47
- package/dist/{credential-sync-Cdm-e1vJ.js → credential-sync-B9CIkgOT.js} +28 -28
- package/dist/{db-DV2ZUb1Y.js → db-C21CyyTE.js} +140 -11
- package/dist/{db-pH357Dkt.d.ts → db-C41UgdBj.d.ts} +1 -1
- package/dist/{executor-CjNhwwnj.js → executor-DfNoVVGd.js} +93 -32
- package/dist/{install-DbD7C5td.js → install-lYZs8UCL.js} +2 -2
- package/dist/instrumentation.js +2 -2
- package/dist/{lineage-BFdIPb3o.js → lineage-BJTSY53A.js} +2 -2
- package/dist/{logging-oYpJYr-S.js → logging-DjW7LjgJ.js} +1 -1
- package/dist/{message-BBPcMKJY.js → message-BPPZpdoZ.js} +8 -8
- package/dist/{model-input-DYYF3a8B.js → model-input-DKqiLFGa.js} +3 -3
- package/dist/nitro.d.ts +2 -2
- package/dist/nitro.js +12 -5
- package/dist/{oauth-callback-server-C7Q987su.js → oauth-callback-server-OJP8Y4Ca.js} +2 -2
- package/dist/{oauth-relay-DAmfVmJu.js → oauth-relay-KwDz41Z3.js} +1 -1
- package/dist/{plugins-B_0Cr0MO.d.ts → plugins-fBrz8PCV.d.ts} +2 -0
- package/dist/{projection-CWXDE0f6.js → projection-D47mlszd.js} +1112 -693
- package/dist/{prompt-P3eRqO8C.js → prompt-DuWH_YIb.js} +3 -3
- package/dist/{registry-1pzXmplY.js → registry-yht0oxq6.js} +19 -9
- package/dist/{resolve-n87oXY-d.js → resolve-gZ-hVMYl.js} +3 -3
- package/dist/{result-BmF9v9bv.js → result-CP99Ok0_.js} +13 -11
- package/dist/{runner-4j7ZsxP5.js → runner-eVlnUkY7.js} +9 -9
- package/dist/{sandbox-egress-signals-BRQI8HvT.js → sandbox-egress-signals-DZL_0lnG.js} +1 -1
- package/dist/{schedule-CHPWQn-x.js → schedule-BG1tEbRF.js} +34 -4
- package/dist/{schema-CVbIjrF3.d.ts → schema-CRXcj4fj.d.ts} +350 -143
- package/dist/{schema-D7iIEh6t.js → schema-D4jdesIu.js} +12 -4
- package/dist/{service-account-DzQiOmqa.js → service-account-CZneZHh7.js} +8 -6
- package/dist/{service-account-BDQ9xzta.js → service-account-tI3LBg2_.js} +3 -3
- package/dist/{session-stop-BQxgHR4X.js → session-stop-D3S7mSkX.js} +36 -23
- package/dist/{skills-CPf4vNuC.js → skills-Bm6uSO9V.js} +32 -28
- package/dist/{slack-conversation-unfurl-B1KEptUg.js → slack-conversation-unfurl-BeBvg3xU.js} +10 -10
- package/dist/{spawn-CjGddiAU.js → spawn-vhMAmLuh.js} +6 -6
- package/dist/{state-9wfj6aSD.js → state-3Yiy2FvP.js} +4 -4
- package/dist/{stop-CsQGuN5n.js → stop-Bh53GUoX.js} +146 -158
- package/dist/{store-Dz3YZ7gQ.js → store-BZJdHYR7.js} +5 -5
- package/dist/{background-compaction-queue-D2wzxtGU.js → task-queue-BEl5G38v.js} +164 -180
- package/dist/{task-runner-frzlUvFD.js → task-runner-C6Bujc6h.js} +11 -8
- package/dist/{thread-context-C4QuZlM8.js → thread-context-DxMQGGd_.js} +6 -6
- package/dist/{turn-session-routing-BXaubz2w.js → turn-session-routing-CmQY0T60.js} +24 -5
- package/dist/{turn-user-message-DNC0eRZ7.js → turn-user-message-Dfbr3Ud9.js} +3 -3
- package/dist/{users-XCCKn3xW.js → users-6rSdqXXk.js} +1 -1
- package/dist/{validation-L5fdjmFX.js → validation--hsjOLRL.js} +1 -1
- package/dist/{version-BFmuwgxP.js → version-9iMT25Hq.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-DKOeHpv3.js → viewer-De1vmuEA.js} +3 -3
- package/dist/{warmup-mTMIatCV.js → warmup-C0IblNtf.js} +596 -281
- package/dist/{web-message-id-CUaSiGme.js → web-message-id-BT8Mg8LL.js} +1 -1
- package/dist/{worker-Bz4KNxjI.js → worker-CiyRr2q7.js} +8 -7
- 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/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 +42 -0
- package/package.json +10 -9
- package/dist/queue-7FSijgqG.js +0 -115
- package/dist/secrets-DHaJ5TTn.js +0 -18
- package/dist/task-queue-CFlrJguF.js +0 -89
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as JuniorPluginSet } from "./plugins-
|
|
1
|
+
import { n as JuniorPluginSet } from "./plugins-fBrz8PCV.js";
|
|
2
2
|
import { n as ConversationWorkQueue, t as ConversationQueueMessage } from "./queue-CbEHUO0l.js";
|
|
3
|
-
import "./schema-
|
|
4
|
-
import { t as ConversationStore } from "./db-
|
|
3
|
+
import "./schema-CRXcj4fj.js";
|
|
4
|
+
import { t as ConversationStore } from "./db-C41UgdBj.js";
|
|
5
5
|
import "./sentry-DrKC2NeM.js";
|
|
6
6
|
import { Hono } from "hono";
|
|
7
7
|
import * as z from "zod";
|
|
@@ -255,6 +255,15 @@ interface JuniorAppOptions extends BotModelConfig {
|
|
|
255
255
|
briefs?: {
|
|
256
256
|
enabled?: boolean;
|
|
257
257
|
};
|
|
258
|
+
/**
|
|
259
|
+
* Embed the searchable events of a Conversation after each completed Turn,
|
|
260
|
+
* so `searchConversationEvents` also matches its history by meaning. This
|
|
261
|
+
* costs one embedding call per 32 new events. Disabled by default. Word
|
|
262
|
+
* search works without it.
|
|
263
|
+
*/
|
|
264
|
+
eventEmbeddings?: {
|
|
265
|
+
enabled?: boolean;
|
|
266
|
+
};
|
|
258
267
|
/**
|
|
259
268
|
* Domains that may use Junior. Slack checks the email domain of the
|
|
260
269
|
* author's Slack profile. Dashboard Google sign-in checks the `hd` claim of
|
package/dist/app.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as JuniorDashboardOptions, n as JuniorAppOptions, r as createApp, t as JuniorApp } from "./app-
|
|
2
|
-
import { i as defineJuniorPlugins, n as JuniorPluginSet, r as JuniorPluginSetOptions, t as JuniorPluginInput } from "./plugins-
|
|
1
|
+
import { i as JuniorDashboardOptions, n as JuniorAppOptions, r as createApp, t as JuniorApp } from "./app-EZur8cVC.js";
|
|
2
|
+
import { i as defineJuniorPlugins, n as JuniorPluginSet, r as JuniorPluginSetOptions, t as JuniorPluginInput } from "./plugins-fBrz8PCV.js";
|
|
3
3
|
import { t as JUNIOR_VERSION } from "./version-Cc2OFd9G.js";
|
|
4
4
|
export { JUNIOR_VERSION, JuniorApp, JuniorAppOptions, type JuniorDashboardOptions, type JuniorPluginInput, type JuniorPluginSet, type JuniorPluginSetOptions, createApp, defineJuniorPlugins };
|
package/dist/app.js
CHANGED
|
@@ -1,51 +1,48 @@
|
|
|
1
|
-
import { $
|
|
2
|
-
import { d as restoreRuntimeConfig, f as setBotModelConfig, g as snapshotRuntimeConfig, h as setSlackReactionConfig, i as getChatConfig, m as setRuntimeLimits, n as botConfig, p as setBotName, u as resetRuntimeConfig, ut as getAttachmentStorage } from "./config-
|
|
3
|
-
import { $ as getStateAdapter, C as withConversationMutationLock, G as recordGoogleSignIn, I as resolveActorIdentityId, Z as disconnectStateAdapter, a as getConversationStore, at as withLock, it as fenceLock, m as withConversationEventLock, nt as MUTATION_LOCK_TTL_MS, o as getDb, p as deleteMessageLinks, r as getConversationEventStore, s as getSqlExecutor, t as closeDb
|
|
4
|
-
import { A as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE, E as withSpan, G as normalizeIdentityEmail, L as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, O as JUNIOR_AUTO_ARCHIVE_ROUTE, P as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, T as withLogContext, U as GOOGLE_IDENTITY_PROVIDER, b as setSpanAttributes, h as logWarn, k as JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE, m as logInfo, p as logException, r as createRequestContext, w as withContext } from "./logging-
|
|
5
|
-
import { C as parseSlackReviewItemClick, E as parseSlackUserInputSubmission, S as buildSlackReviewItemModal, _ as createSlackReviewItemShow, b as findSlackThreadOwnerId, d as publicArtifactHeaders, f as readPublicArtifact, g as scheduledAutomationRunAttributes, h as logScheduledAutomationRunSkipped, n as executeAgentRun, p as unpublishedArtifactHeaders, r as processBackgroundCompaction, t as createAgentRunner, v as resolveSlackReviewItemCardConversationId, w as parseSlackReviewItemFormTarget, y as syncReviewItemSlackCards } from "./agent-runner-
|
|
6
|
-
import { E as getAuthPausedConversationTurnId, G as isAllowedDomain, J as resolveEventAuthor, K as isTrustedSlackAuthor, U as eventAuthorText, W as findTrustedUser, X as resolveBotSlackTeamId, Y as setTrustConfig, Z as renderTaskInput, _t as slackChannelMessageEvent, at as decodeAnnotationRef, b as deletePlanItems, dt as getExperimentalFeatures, ft as isExperimentalFeatureEnabled, ht as SLACK_EVENT_NAMESPACE, it as annotationKeyDigest, mt as getEventCatalog, pt as setExperimentalFeatures, q as parseEmail, rt as renderSlackObjectCard, vt as slackChannelMessageReplyThreadTs, yt as slackChannelMessageRunsAutomation } from "./session-stop-
|
|
7
|
-
import { a as getSandboxResourceConfig, s as setSandboxResourceConfig } from "./install-
|
|
8
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
9
|
-
import { $ as publicAddressLookup, A as actOnReviewItem, C as encodeConversationCursor, F as runAutoArchiveSweep, I as setConversationAutoArchive, J as readObjectLinkTypes, M as readReviewItemForUser, N as reviewItemChange, O as stopConversation, P as archiveViewerDoneConversations, Q as isPublicAddress, S as decodeConversationCursor, T as readConversationPendingMessages, U as backfillCacheWarmingGaps, V as runSavingsRefillSlice, W as GET$4, _t as SubscribedReplyReason, at as slackInboundMessageId, b as createConversationForViewer, dt as recordSkippedConversationMessage, et as createProductionConversationWorkOptions, ft as createSlackWebApiStatusSender, gt as parseContent, ht as stripLeadingBotMention, i as readConversationFeed, it as clearSlackPendingReactions, j as closeReviewItemsAnsweredByReply, k as ReviewItemActionError, l as readConversationDetail, lt as enqueueAgentDispatch, mt as startProcessingReaction, n as steerConversationPendingMessagesForViewer, nt as getProductionSlackAdapter, ot as normalizeIncomingSlackThreadId, pt as bindMessageAuthorIdentityId, rt as buildSlackInboundMessage, s as pinConversation, st as withNormalizedThreadId, t as stopConversationTurnForViewer, tt as createProductionSlackWebhookServices, ut as failStoppedDispatch, v as readConversationRecordFromSql, vt as getThreadStopDecision, w as cancelConversationPendingMessagesForViewer, y as appendConversationMessageForViewer } from "./stop-
|
|
10
|
-
import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "./validation
|
|
1
|
+
import { $i as proxyVercelSandboxEgressRequest, $o as listPendingDispatchMailboxAppends, $r as reviewItemReaderForUser, $s as withScheduledAutomationLock, Ai as verifySlackDirectCredentialSubject, Ao as createConversationEmbedder, At as hasRunnableConversationWork, Bs as slackMention, C as settleConversationTitleWork, Ca as normalizeSandboxEgressTracePropagationDomains, Ci as takeDueTimerWatches, Dc as eventGuidance, Di as bindSlackDirectCredentialSubject, Dn as getPluginApiRoutes, Do as resolveRootVisibility, Dr as createPluginReviewItems, Ei as bindScheduledAutomationCredentialSubject, Er as projectConversationMessages, Es as isDmChannel, Fn as setPlugins, Go as createOrGetDispatch, Hn as setEventEmbeddingsConfig, Ho as buildDispatchId, In as validatePlugins, It as pruneActiveConversation, Jc as existingConversationId, Ko as getDispatchConversationId, Mi as createPluginState, Mr as dismissOpenReviewItems, Mt as isInvalidConversationRecordError, Nn as getPlugins, No as createPluginAnnotations, Ns as getWorkspaceTeamId, Oa as createPluginEmbedder, Oi as verifyEventAutomationCredentialSubject, On as getPluginRoutes, Po as listConversationAnnotations, Ps as runWithWorkspaceTeamId, Qi as isVercelSandboxEgressRequest, Qo as isTerminalDispatchStatus, Qs as scheduledRunId, Rc as automationVersionOf, Rn as isBriefsEnabled, Sc as eventAutomationRunLimitReason, So as requestAttachmentDeletion, Ti as bindEventAutomationCredentialSubject, Tn as createPluginEventPublisher, Ua as createPluginLogger, Ur as canActOnReviewItem, Vn as setBriefsConfig, Wo as confirmDispatchMailboxAppend, Yo as getDispatchRecord, Ys as readScheduledAutomation, Zo as getPluginDispatchProjection, Zs as saveScheduledAutomationInLock, _ as appendConversationMessages, _a as consumeSandboxEgressPermissionDeniedSignal, _l as setConfigDefaults, as as notifyAutomationBlocked, bn as createUserTokenStore, dc as blockEventAutomation, ds as postSlackEphemeralMessage, ec as getDashboardConversationLink, ei as reviewItemReaderForUserInConversation, fc as collectEventAutomationMatchKeys, ga as consumeSandboxEgressAuthRequiredSignal, gl as getConfigDefaults, ha as clearSandboxEgressSignals, hc as findMatchingEventAutomations, hi as collectEventMatchKeys, ic as getDashboardReviewItemLink, il as refreshAutomationLastRun, io as readConversationEventPageAfter, ki as verifyScheduledAutomationCredentialSubject, ko as backfillConversationEmbeddings, lt as CONVERSATION_WORK_STALE_ENQUEUE_MS, oc as getDashboardTaskLink, oi as createCodeChangePublisher, oo as readConversationLastEventSeq, qa as readConversationAccessFromSql, qs as listScheduledAutomationsForTeam, ra as resolveBaseUrl, rl as recordAutomationExecution, ro as readConversationEventPage, rs as markDispatchFailed, so as readConversationMessageEventSeq, uc as setDashboardConversationLinkOptions, ul as createPluginCache, us as openSlackModal, vo as collectAttachmentGarbage, vs as slackEntitySchema, ws as getSlackClient, xc as admitEventAutomationRun, ya as parseSandboxEgressCredentialToken, yi as findMatchingWatches, ys as slackExternalRefIdSchema, zr as searchReviewItems } from "./projection-D47mlszd.js";
|
|
2
|
+
import { d as restoreRuntimeConfig, f as setBotModelConfig, g as snapshotRuntimeConfig, h as setSlackReactionConfig, i as getChatConfig, m as setRuntimeLimits, n as botConfig, p as setBotName, u as resetRuntimeConfig, ut as getAttachmentStorage } from "./config-DY5c1E0l.js";
|
|
3
|
+
import { $ as getStateAdapter, C as withConversationMutationLock, Et as createSlackDestination, G as recordGoogleSignIn, I as resolveActorIdentityId, Tt as touchConversationDetail, Z as disconnectStateAdapter, a as getConversationStore, at as withLock, it as fenceLock, lt as conversationCostOf, m as withConversationEventLock, nt as MUTATION_LOCK_TTL_MS, o as getDb, p as deleteMessageLinks, r as getConversationEventStore, s as getSqlExecutor, t as closeDb } from "./db-C21CyyTE.js";
|
|
4
|
+
import { A as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE, E as withSpan, G as normalizeIdentityEmail, L as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, O as JUNIOR_AUTO_ARCHIVE_ROUTE, P as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, T as withLogContext, U as GOOGLE_IDENTITY_PROVIDER, b as setSpanAttributes, h as logWarn, k as JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE, m as logInfo, p as logException, r as createRequestContext, w as withContext } from "./logging-DjW7LjgJ.js";
|
|
5
|
+
import { A as resumeConversationDelivery, C as parseSlackReviewItemClick, E as parseSlackUserInputSubmission, S as buildSlackReviewItemModal, _ as createSlackReviewItemShow, b as findSlackThreadOwnerId, d as publicArtifactHeaders, f as readPublicArtifact, g as scheduledAutomationRunAttributes, h as logScheduledAutomationRunSkipped, n as executeAgentRun, p as unpublishedArtifactHeaders, r as processBackgroundCompaction, t as createAgentRunner, v as resolveSlackReviewItemCardConversationId, w as parseSlackReviewItemFormTarget, y as syncReviewItemSlackCards } from "./agent-runner-DxivxUYd.js";
|
|
6
|
+
import { E as getAuthPausedConversationTurnId, G as isAllowedDomain, J as resolveEventAuthor, K as isTrustedSlackAuthor, U as eventAuthorText, W as findTrustedUser, X as resolveBotSlackTeamId, Y as setTrustConfig, Z as renderTaskInput, _t as slackChannelMessageEvent, at as decodeAnnotationRef, b as deletePlanItems, dt as getExperimentalFeatures, ft as isExperimentalFeatureEnabled, ht as SLACK_EVENT_NAMESPACE, it as annotationKeyDigest, mt as getEventCatalog, pt as setExperimentalFeatures, q as parseEmail, rt as renderSlackObjectCard, vt as slackChannelMessageReplyThreadTs, yt as slackChannelMessageRunsAutomation } from "./session-stop-D3S7mSkX.js";
|
|
7
|
+
import { a as getSandboxResourceConfig, s as setSandboxResourceConfig } from "./install-lYZs8UCL.js";
|
|
8
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-Se9idiDR.js";
|
|
9
|
+
import { $ as publicAddressLookup, A as actOnReviewItem, C as encodeConversationCursor, F as runAutoArchiveSweep, I as setConversationAutoArchive, J as readObjectLinkTypes, M as readReviewItemForUser, N as reviewItemChange, O as stopConversation, P as archiveViewerDoneConversations, Q as isPublicAddress, S as decodeConversationCursor, T as readConversationPendingMessages, U as backfillCacheWarmingGaps, V as runSavingsRefillSlice, W as GET$4, _t as SubscribedReplyReason, at as slackInboundMessageId, b as createConversationForViewer, dt as recordSkippedConversationMessage, et as createProductionConversationWorkOptions, ft as createSlackWebApiStatusSender, gt as parseContent, ht as stripLeadingBotMention, i as readConversationFeed, it as clearSlackPendingReactions, j as closeReviewItemsAnsweredByReply, k as ReviewItemActionError, l as readConversationDetail, lt as enqueueAgentDispatch, mt as startProcessingReaction, n as steerConversationPendingMessagesForViewer, nt as getProductionSlackAdapter, ot as normalizeIncomingSlackThreadId, pt as bindMessageAuthorIdentityId, rt as buildSlackInboundMessage, s as pinConversation, st as withNormalizedThreadId, t as stopConversationTurnForViewer, tt as createProductionSlackWebhookServices, ut as failStoppedDispatch, v as readConversationRecordFromSql, vt as getThreadStopDecision, w as cancelConversationPendingMessagesForViewer, y as appendConversationMessageForViewer } from "./stop-Bh53GUoX.js";
|
|
10
|
+
import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "./validation--hsjOLRL.js";
|
|
11
11
|
import { a as pluginRuntimeRegistrationsFromPluginSet, n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "./plugins-Bkk0XRo2.js";
|
|
12
|
-
import { Ci as
|
|
13
|
-
import { _ as getConversationWorkState, g as getConversation, h as ensureConversationWake, l as clearExpiredConversationLease, r as appendAndEnqueueInboundMessage, y as listActiveConversationIds } from "./store-
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { i as enqueueAgentInvocationResult, r as createEndStoppedChildWork } from "./result-
|
|
18
|
-
import {
|
|
19
|
-
import { a as GET$5, i as publishAppHomeView, r as GET$6, t as receiveLocalOAuthCredential } from "./credential-sync-
|
|
12
|
+
import { Ci as findAutomationSkill, E as processWorkspaceSnapshotJob, Kt as listPendingAgentInvocationMailboxAppends, Ot as collectAttachmentUploadGarbage, St as createAndEnqueueConversation, Ti as effectiveTaskOutcomes, Tt as webActorFromUser, Wn as setConversationSubscription, _n as recordSubagentEnded, _t as renderReviewItemMessage, bt as appendAndEnqueueWebMessage, ci as ViewerTaskNotFoundError, dt as markConversationRead, fi as readViewerAutomationSummary, gt as deliverReviewItemChange, k as ingestEvent, lt as archiveConversation, mi as readViewerAutomations, or as parseSlackThreadId, qt as listPendingAgentInvocationResults, ui as readViewerAutomationExecutions, un as enqueueAgentInvocation, vr as joinPublicChannel, vt as reviewItemChangeRecord, wi as missingAutomationSkillReason, wt as recordWebConversationActivity, xt as conversationTurnIdForMessage, yi as automationCardStatus } from "./warmup-C0IblNtf.js";
|
|
13
|
+
import { _ as getConversationWorkState, g as getConversation, h as ensureConversationWake, l as clearExpiredConversationLease, r as appendAndEnqueueInboundMessage, y as listActiveConversationIds } from "./store-BZJdHYR7.js";
|
|
14
|
+
import { G as getNextRunAtMs, Q as automationTaskText, R as scheduledRunSchema, Z as automationTaskSchema, m as automationListQuerySchema, u as automationExecutionStatusSchema } from "./schedule-BG1tEbRF.js";
|
|
15
|
+
import { A as juniorConversationEvents, E as juniorConversationBriefs, R as juniorConversations, V as juniorDestinations, f as juniorReviewItems, h as juniorAutomations, p as juniorAutomationRuns, v as juniorAgentBindings, y as juniorAgentInvocations } from "./executor-DfNoVVGd.js";
|
|
16
|
+
import { c as registerVercelCacheWarmupDevConsumer, g as verifyConversationQueueMessage, h as resolveConversationWorkQueueTopic, i as verifyBackgroundCompactionMessage, m as getVercelConversationWorkQueue, o as cacheWarmupQueueConsumer, p as verifyWorkspaceSnapshotJobMessage, r as vercelBackgroundCompactionQueue, s as createVercelCacheWarmupCallback, t as BACKGROUND_COMPACTION_QUEUE_TOPIC, u as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC, v as conversationQueueMessageSchema, y as isConversationQueueMessageRejectedError } from "./background-compaction-queue-HlljT9ql.js";
|
|
17
|
+
import { i as enqueueAgentInvocationResult, r as createEndStoppedChildWork } from "./result-CP99Ok0_.js";
|
|
18
|
+
import { _ as getQueueProvider, a as pluginTaskQueueConsumer, f as readSchedulerSecret, h as queueCallback, n as createVercelPluginTaskCallback, o as registerVercelPluginTaskDevConsumer, p as readSignInSecret, s as sendVercelPluginTask } from "./task-queue-BEl5G38v.js";
|
|
19
|
+
import { a as GET$5, i as publishAppHomeView, r as GET$6, t as receiveLocalOAuthCredential } from "./credential-sync-B9CIkgOT.js";
|
|
20
20
|
import { t as nameRequestRoute } from "./sentry-route-name-C6EIzAGP.js";
|
|
21
21
|
import { t as SANDBOX_EGRESS_PROXY_PATH } from "./proxy-path-BHYoKZdq.js";
|
|
22
22
|
import { B as conversationTitleSchema, G as annotationCard, I as conversationBriefSchema, b as conversationSurfaceSchema, v as conversationReportStatusSchema } from "./conversation--f85g4zL.js";
|
|
23
|
-
import { i as readActorIdentity, l as resolveViewerUser, p as parseAvatarUrl } from "./viewer-
|
|
23
|
+
import { i as readActorIdentity, l as resolveViewerUser, p as parseAvatarUrl } from "./viewer-De1vmuEA.js";
|
|
24
24
|
import { b as slackMessageTsSchema, g as slackTeamIdSchema, h as slackChannelIdSchema, n as createSlackActor, s as parseActorUserId, u as parseSlackChannelId, v as parseSlackMessageTs, y as slackMessageTsFromMs } from "./actor-D2iXzvlN.js";
|
|
25
|
-
import { a as resolveSlackActingUser, i as unfurlDashboardConversationLinks, n as handleSlackContinueHereClick, o as isSlackWorkspaceMember, s as slackWorkspaceBotId, t as SLACK_CONTINUE_HERE_ACTION_ID } from "./slack-conversation-unfurl-
|
|
26
|
-
import { o as unlinkProvider } from "./connections-
|
|
27
|
-
import { s as buttonUserInputField } from "./web-message-id-
|
|
28
|
-
import { n as verifySlackSignature, t as runWithSlackInstallation } from "./adapter-context-
|
|
29
|
-
import { c as coerceThreadConversationState } from "./turn-session-routing-
|
|
30
|
-
import { a as resumeConversationDelivery } from "./conversation-turn-BzdmrHb0.js";
|
|
25
|
+
import { a as resolveSlackActingUser, i as unfurlDashboardConversationLinks, n as handleSlackContinueHereClick, o as isSlackWorkspaceMember, s as slackWorkspaceBotId, t as SLACK_CONTINUE_HERE_ACTION_ID } from "./slack-conversation-unfurl-BeBvg3xU.js";
|
|
26
|
+
import { o as unlinkProvider } from "./connections-C-SqzubG.js";
|
|
27
|
+
import { s as buttonUserInputField } from "./web-message-id-BT8Mg8LL.js";
|
|
28
|
+
import { n as verifySlackSignature, t as runWithSlackInstallation } from "./adapter-context-HrBTD8rJ.js";
|
|
29
|
+
import { c as coerceThreadConversationState } from "./turn-session-routing-CmQY0T60.js";
|
|
31
30
|
import { i as getActiveSpan, n as captureMessage, u as sentry_exports } from "./sentry-CPbZjomA.js";
|
|
32
|
-
import { t as processConversationWork } from "./worker-
|
|
33
|
-
import { t as bindMessageAgent } from "./message-
|
|
34
|
-
import { t as bindSpawnAgent } from "./spawn-
|
|
35
|
-
import {
|
|
36
|
-
import { t as
|
|
37
|
-
import { i as registerVercelCacheWarmupDevConsumer, l as verifyWorkspaceSnapshotJobMessage, n as cacheWarmupQueueConsumer, o as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC, r as createVercelCacheWarmupCallback } from "./queue-7FSijgqG.js";
|
|
38
|
-
import { t as JUNIOR_VERSION } from "./version-BFmuwgxP.js";
|
|
31
|
+
import { t as processConversationWork } from "./worker-CiyRr2q7.js";
|
|
32
|
+
import { t as bindMessageAgent } from "./message-BPPZpdoZ.js";
|
|
33
|
+
import { t as bindSpawnAgent } from "./spawn-vhMAmLuh.js";
|
|
34
|
+
import { t as processPluginTask } from "./task-runner-C6Bujc6h.js";
|
|
35
|
+
import { t as JUNIOR_VERSION } from "./version-9iMT25Hq.js";
|
|
39
36
|
import { c as conversationPendingMessageDeliverySchema, n as conversationFeedQuerySchema } from "./conversation-feed-BNs9KiqC.js";
|
|
40
37
|
import { createRequire } from "node:module";
|
|
41
38
|
import { Hono } from "hono";
|
|
39
|
+
import pLimit from "p-limit";
|
|
42
40
|
import * as z from "zod";
|
|
43
41
|
import { createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
44
42
|
import { and, asc, eq, inArray, isNotNull, isNull, lte, ne, or, sql } from "drizzle-orm";
|
|
45
43
|
import { EVENT_SUMMARY_MAX_LENGTH, EVENT_TEXT_MAX_LENGTH, dispatchOptionsSchema, eventSchema as eventSchema$1, eventTriggerFiltersText, identityDispatchOptionsSchema, isSlackDestination, userSchema } from "@sentry/junior-plugin-api";
|
|
46
44
|
import { pathToFileURL } from "node:url";
|
|
47
45
|
import { Message, ThreadImpl } from "chat";
|
|
48
|
-
import pLimit from "p-limit";
|
|
49
46
|
import net from "node:net";
|
|
50
47
|
import { decodeJwt } from "jose";
|
|
51
48
|
import { HTTPException } from "hono/http-exception";
|
|
@@ -57,6 +54,28 @@ import { bodyLimit } from "hono/body-limit";
|
|
|
57
54
|
import { createAuthMiddleware } from "better-auth/api";
|
|
58
55
|
import { getSessionCookie } from "better-auth/cookies";
|
|
59
56
|
import { betterAuth } from "better-auth/minimal";
|
|
57
|
+
// src/chat/conversations/embedding-backfill.ts
|
|
58
|
+
const BACKFILL_BUDGET_MS = 1e4;
|
|
59
|
+
const BACKFILL_CLAIM_TTL_MS = 6e4;
|
|
60
|
+
const BACKFILL_DONE_TTL_MS = 36e5;
|
|
61
|
+
/** Embed the latest Briefs that have no vector of the embedder's model. */
|
|
62
|
+
async function runConversationEmbeddingBackfill(embedder) {
|
|
63
|
+
const key = `junior:conversation_embeddings:backfill:${embedder.provider}:${embedder.model}`;
|
|
64
|
+
const state = getStateAdapter();
|
|
65
|
+
if (!await state.setIfNotExists(key, "running", BACKFILL_CLAIM_TTL_MS)) return;
|
|
66
|
+
await withSpan("conversation_embeddings.backfill", "conversation_embeddings.backfill", {}, async (setSpanAttributes) => {
|
|
67
|
+
const result = await backfillConversationEmbeddings({
|
|
68
|
+
db: getDb(),
|
|
69
|
+
deadlineMs: Date.now() + BACKFILL_BUDGET_MS,
|
|
70
|
+
embedder
|
|
71
|
+
});
|
|
72
|
+
if (result.done) await state.set(key, "done", BACKFILL_DONE_TTL_MS);
|
|
73
|
+
setSpanAttributes({
|
|
74
|
+
"app.conversation_embeddings.backfill.embedded.count": result.embedded,
|
|
75
|
+
"app.conversation_embeddings.backfill.outcome": result.done ? "completed" : "budget_exceeded"
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
60
79
|
// src/chat/events/timers.ts
|
|
61
80
|
/** Publish a bounded batch of due timers; the mailbox owns agent execution. */
|
|
62
81
|
async function runTimerWatchHeartbeat(args) {
|
|
@@ -386,11 +405,13 @@ async function getScheduledAutomationDispatch(id) {
|
|
|
386
405
|
* has.
|
|
387
406
|
*/
|
|
388
407
|
async function recordEventAutomationRunStarted(db, args) {
|
|
408
|
+
const conversationId = getDispatchConversationId({ id: args.dispatchId });
|
|
389
409
|
await db.insert(juniorAutomationRuns).values({
|
|
390
410
|
id: args.dispatchId,
|
|
391
411
|
automationId: args.automation.id,
|
|
392
412
|
automationVersion: automationVersionOf(args.automation),
|
|
393
|
-
conversationId: existingConversationId(
|
|
413
|
+
conversationId: existingConversationId(conversationId),
|
|
414
|
+
costMicroUsd: conversationCostOf(conversationId),
|
|
394
415
|
startedAtMs: args.nowMs,
|
|
395
416
|
status: "running"
|
|
396
417
|
}).onConflictDoNothing({ target: juniorAutomationRuns.id });
|
|
@@ -460,13 +481,15 @@ async function readRun(db, runId) {
|
|
|
460
481
|
*/
|
|
461
482
|
async function writeRun(db, run, automationVersion) {
|
|
462
483
|
const stored = scheduledRunSchema.parse(run);
|
|
484
|
+
const dispatchConversationId = stored.dispatchId ? getDispatchConversationId({ id: stored.dispatchId }) : void 0;
|
|
463
485
|
const columns = {
|
|
464
486
|
...automationVersion ? { automationVersion } : void 0,
|
|
465
487
|
attempt: stored.attempt,
|
|
466
488
|
automationId: stored.taskId,
|
|
467
489
|
claimedAtMs: stored.claimedAtMs,
|
|
468
490
|
completedAtMs: stored.completedAtMs ?? null,
|
|
469
|
-
conversationId:
|
|
491
|
+
conversationId: dispatchConversationId ? existingConversationId(dispatchConversationId) : null,
|
|
492
|
+
costMicroUsd: dispatchConversationId ? conversationCostOf(dispatchConversationId) : null,
|
|
470
493
|
dispatchId: stored.dispatchId ?? null,
|
|
471
494
|
errorMessage: stored.errorMessage ?? null,
|
|
472
495
|
resultMessageTs: stored.resultMessageTs ?? null,
|
|
@@ -481,6 +504,7 @@ async function writeRun(db, run, automationVersion) {
|
|
|
481
504
|
target: juniorAutomationRuns.id,
|
|
482
505
|
set: columns
|
|
483
506
|
});
|
|
507
|
+
if (stored.completedAtMs !== void 0) await refreshAutomationLastRun(db, stored.taskId);
|
|
484
508
|
}
|
|
485
509
|
/**
|
|
486
510
|
* List incomplete Scheduled automation runs, optionally for one automation.
|
|
@@ -1190,6 +1214,14 @@ async function runHeartbeat(args) {
|
|
|
1190
1214
|
} catch (error) {
|
|
1191
1215
|
logException(error, "cache_warming.savings_refill.failed");
|
|
1192
1216
|
}
|
|
1217
|
+
if (isBriefsEnabled()) try {
|
|
1218
|
+
await runConversationEmbeddingBackfill(createConversationEmbedder({
|
|
1219
|
+
cost: { owner: "none" },
|
|
1220
|
+
operation: "conversation_embedding"
|
|
1221
|
+
}));
|
|
1222
|
+
} catch (error) {
|
|
1223
|
+
logException(error, "conversation_embeddings.backfill.failed");
|
|
1224
|
+
}
|
|
1193
1225
|
}
|
|
1194
1226
|
// src/handlers/scheduler-auth.ts
|
|
1195
1227
|
/** Check the bearer secret that internal cron requests must send. */
|
|
@@ -2536,7 +2568,12 @@ function dateField(key, label, value, empty) {
|
|
|
2536
2568
|
function renderAutomationDetails(automation) {
|
|
2537
2569
|
const url = getDashboardTaskLink(automation.id);
|
|
2538
2570
|
if (!url) return void 0;
|
|
2539
|
-
const
|
|
2571
|
+
const { status, warning } = automationCardStatus({
|
|
2572
|
+
status: automation.status,
|
|
2573
|
+
statusReason: automation.statusReason,
|
|
2574
|
+
triggerProblems: automation.kind === "event" ? automation.trigger.problems : void 0
|
|
2575
|
+
});
|
|
2576
|
+
const fields = [textField("status", "Status", status)];
|
|
2540
2577
|
const { task } = automation;
|
|
2541
2578
|
if (task.kind === "skill") fields.push(textField("skill", "Skill", task.skill));
|
|
2542
2579
|
const text = automationTaskText(task);
|
|
@@ -2561,11 +2598,11 @@ function renderAutomationDetails(automation) {
|
|
|
2561
2598
|
...textField("filters", "Filters", trigger.filters.length > 0 ? eventTriggerFiltersText(trigger.filters) : "No filters. Runs on every selected event."),
|
|
2562
2599
|
long: true
|
|
2563
2600
|
});
|
|
2564
|
-
if (trigger.problems.length > 0) fields.push({
|
|
2565
|
-
...textField("warning", "Needs attention", ["Trigger unavailable.", ...trigger.problems].join(" ")),
|
|
2566
|
-
long: true
|
|
2567
|
-
});
|
|
2568
2601
|
}
|
|
2602
|
+
if (warning) fields.push({
|
|
2603
|
+
...textField("warning", "Needs attention", warning),
|
|
2604
|
+
long: true
|
|
2605
|
+
});
|
|
2569
2606
|
const lastRun = dateField("last_run", "Last execution", automation.lastRunAt, "Never run");
|
|
2570
2607
|
if (automation.lastRunAt && automation.lastConversationId) lastRun.link = getDashboardConversationLink(automation.lastConversationId);
|
|
2571
2608
|
fields.push(textField("outcomes", "Outcomes", automation.outcomes.length === 0 ? "None (silent)" : `${automation.outcomes.length} message${automation.outcomes.length === 1 ? "" : "s"}`), textField("destination", "Destination", `${automation.destination.label} · ${automation.destination.visibility}`), textField("created_by", "Created by", automation.createdBy), dateField("date_created", "Created", automation.createdAt, "Unknown"), textField("executions", "Executions", `${automation.totalRuns} total · ${automation.runs[30]} in the last 30 days`), lastRun);
|
|
@@ -2589,7 +2626,7 @@ const detailsEventSchema = z.object({
|
|
|
2589
2626
|
trigger_id: z.string().min(1),
|
|
2590
2627
|
user: z.string().min(1),
|
|
2591
2628
|
external_ref: z.object({
|
|
2592
|
-
id:
|
|
2629
|
+
id: slackExternalRefIdSchema,
|
|
2593
2630
|
type: z.literal("automation")
|
|
2594
2631
|
})
|
|
2595
2632
|
});
|
|
@@ -6312,7 +6349,7 @@ function triggerText(automation) {
|
|
|
6312
6349
|
const { events, filters } = automation.trigger;
|
|
6313
6350
|
return [`${events.join(", ")} on ${automation.resource}`, ...filters].join("; ");
|
|
6314
6351
|
}
|
|
6315
|
-
/** Map an Automation summary to its MCP view. */
|
|
6352
|
+
/** Map an Automation list row or summary to its MCP view. */
|
|
6316
6353
|
function mcpAutomation(automation) {
|
|
6317
6354
|
const url = getDashboardTaskLink(automation.id);
|
|
6318
6355
|
return {
|
|
@@ -6358,9 +6395,10 @@ function registerGetAutomationTool(server, { user }) {
|
|
|
6358
6395
|
}
|
|
6359
6396
|
}, async ({ id }) => {
|
|
6360
6397
|
try {
|
|
6361
|
-
const list = await readViewerAutomationExecutions(user, id);
|
|
6398
|
+
const [automation, list] = await Promise.all([readViewerAutomationSummary(user, id), readViewerAutomationExecutions(user, id)]);
|
|
6399
|
+
if (!automation) return mcpToolError("Automation not found.");
|
|
6362
6400
|
return mcpToolResult({
|
|
6363
|
-
automation: mcpAutomation(
|
|
6401
|
+
automation: mcpAutomation(automation),
|
|
6364
6402
|
runs: list.executions.slice(0, RECENT_RUN_LIMIT).map(({ conversationId, error, executedAt, status }) => ({
|
|
6365
6403
|
executedAt,
|
|
6366
6404
|
status,
|
|
@@ -7709,6 +7747,7 @@ async function createApp(options) {
|
|
|
7709
7747
|
const previousSandboxResources = getSandboxResourceConfig();
|
|
7710
7748
|
const previousExperimentalFeatures = getExperimentalFeatures();
|
|
7711
7749
|
const previousBriefsConfig = setBriefsConfig(options?.briefs);
|
|
7750
|
+
const previousEventEmbeddingsConfig = setEventEmbeddingsConfig(options?.eventEmbeddings);
|
|
7712
7751
|
const previousDashboardLinkOptions = setDashboardConversationLinkOptions(dashboard);
|
|
7713
7752
|
let previousTrustConfig;
|
|
7714
7753
|
const restoreRuntimeConfig$1 = () => {
|
|
@@ -7720,6 +7759,7 @@ async function createApp(options) {
|
|
|
7720
7759
|
setSandboxResourceConfig(previousSandboxResources);
|
|
7721
7760
|
setExperimentalFeatures(previousExperimentalFeatures);
|
|
7722
7761
|
setBriefsConfig(previousBriefsConfig);
|
|
7762
|
+
setEventEmbeddingsConfig(previousEventEmbeddingsConfig);
|
|
7723
7763
|
setDashboardConversationLinkOptions(previousDashboardLinkOptions);
|
|
7724
7764
|
};
|
|
7725
7765
|
let pluginRoutes = [];
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { i as getChatConfig } from "./config-DY5c1E0l.js";
|
|
2
|
+
import { E as withSpan, h as logWarn } from "./logging-DjW7LjgJ.js";
|
|
3
|
+
import { _ as getQueueProvider, c as QUEUE_SIGNATURE_MAX_AGE_MS, h as queueCallback, l as signQueueMessage, u as verifyQueueMessage } from "./task-queue-BEl5G38v.js";
|
|
4
|
+
import * as z from "zod";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
/** Validate the v2 conversation work hint sent through Vercel Queue. */
|
|
7
|
+
const conversationQueueMessageSchema = z.object({
|
|
8
|
+
schemaVersion: z.literal(2),
|
|
9
|
+
conversationId: z.string().trim().min(1)
|
|
10
|
+
}).strict();
|
|
11
|
+
var ConversationQueueMessageRejectedError = class extends Error {
|
|
12
|
+
conversationId;
|
|
13
|
+
reason;
|
|
14
|
+
constructor(reason, message, options = {}) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = "ConversationQueueMessageRejectedError";
|
|
17
|
+
this.reason = reason;
|
|
18
|
+
this.conversationId = options.conversationId;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
/** Return whether an error means the queue message was permanently rejected. */
|
|
22
|
+
function isConversationQueueMessageRejectedError(error) {
|
|
23
|
+
return error instanceof ConversationQueueMessageRejectedError;
|
|
24
|
+
}
|
|
25
|
+
/** Build the idempotency key of a wake that one worker event sends. */
|
|
26
|
+
function nudgeIdempotencyKey(reason, conversationId, nowMs) {
|
|
27
|
+
return `${reason}:${conversationId}:${nowMs}`;
|
|
28
|
+
}
|
|
29
|
+
// src/chat/task-execution/queue-signing.ts
|
|
30
|
+
const conversationQueueSign = {
|
|
31
|
+
context: "junior.conversation_work_queue.v2",
|
|
32
|
+
schema: conversationQueueMessageSchema,
|
|
33
|
+
separator: ":",
|
|
34
|
+
signatureVersion: "v2",
|
|
35
|
+
parts: (message) => [message.conversationId]
|
|
36
|
+
};
|
|
37
|
+
const CONVERSATION_WORK_QUEUE_SIGNATURE_MAX_SKEW_MS = QUEUE_SIGNATURE_MAX_AGE_MS;
|
|
38
|
+
/** Sign a conversation queue payload before it crosses the public callback route. */
|
|
39
|
+
function signConversationQueueMessage(message, nowMs = Date.now()) {
|
|
40
|
+
return signQueueMessage(conversationQueueSign, message, nowMs);
|
|
41
|
+
}
|
|
42
|
+
/** Explain whether a queue payload is verified, rejected, or unavailable. */
|
|
43
|
+
function verifyConversationQueueMessage(value, nowMs = Date.now()) {
|
|
44
|
+
return verifyQueueMessage(conversationQueueSign, value, nowMs);
|
|
45
|
+
}
|
|
46
|
+
const CONVERSATION_WORK_QUEUE_RETENTION_SECONDS = CONVERSATION_WORK_QUEUE_SIGNATURE_MAX_SKEW_MS / 1e3;
|
|
47
|
+
let defaultQueue;
|
|
48
|
+
/** Resolve the Vercel Queue topic used for conversation wake-up nudges. */
|
|
49
|
+
function resolveConversationWorkQueueTopic(options = {}) {
|
|
50
|
+
return options.topic?.trim() || process.env["JUNIOR_CONVERSATION_WORK_QUEUE_TOPIC"]?.trim() || "junior_conversation_work";
|
|
51
|
+
}
|
|
52
|
+
function toDelaySeconds(options) {
|
|
53
|
+
if (!options?.delayMs || options.delayMs <= 0) return;
|
|
54
|
+
return Math.ceil(options.delayMs / 1e3);
|
|
55
|
+
}
|
|
56
|
+
/** Create the Vercel Queue implementation for conversation wake-up nudges. */
|
|
57
|
+
function createVercelConversationWorkQueue(options = {}) {
|
|
58
|
+
const topic = resolveConversationWorkQueueTopic(options);
|
|
59
|
+
const client = options.client ?? getQueueProvider();
|
|
60
|
+
return { async send(message, sendOptions) {
|
|
61
|
+
const payload = signConversationQueueMessage(message);
|
|
62
|
+
return await withSpan("conversation.work.publish", "queue.publish", { conversationId: message.conversationId }, async (setSpanAttributes) => {
|
|
63
|
+
const result = await client.send(topic, payload, {
|
|
64
|
+
idempotencyKey: sendOptions?.idempotencyKey,
|
|
65
|
+
delaySeconds: toDelaySeconds(sendOptions),
|
|
66
|
+
retentionSeconds: options.retentionSeconds ?? CONVERSATION_WORK_QUEUE_RETENTION_SECONDS
|
|
67
|
+
});
|
|
68
|
+
if (!result.messageId) return {};
|
|
69
|
+
setSpanAttributes({ "messaging.message.id": result.messageId });
|
|
70
|
+
return { messageId: result.messageId };
|
|
71
|
+
}, {
|
|
72
|
+
"messaging.destination.name": topic,
|
|
73
|
+
"messaging.message.body.size": Buffer.byteLength(JSON.stringify(payload)),
|
|
74
|
+
"messaging.system": getQueueProvider().messagingSystem
|
|
75
|
+
});
|
|
76
|
+
} };
|
|
77
|
+
}
|
|
78
|
+
/** Return the default production conversation work queue. */
|
|
79
|
+
function getVercelConversationWorkQueue() {
|
|
80
|
+
defaultQueue ??= createVercelConversationWorkQueue();
|
|
81
|
+
return defaultQueue;
|
|
82
|
+
}
|
|
83
|
+
// src/chat/sandbox/snapshot/job-queue.ts
|
|
84
|
+
/** Send Workspace snapshot build messages. */
|
|
85
|
+
const SIGNATURE_CONTEXT = "junior.workspace_snapshot_queue.v1";
|
|
86
|
+
const SIGNATURE_VERSION = "v1";
|
|
87
|
+
const WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC = "junior_workspace_snapshots";
|
|
88
|
+
const workspaceSnapshotJobSign = {
|
|
89
|
+
context: SIGNATURE_CONTEXT,
|
|
90
|
+
schema: z.object({
|
|
91
|
+
workspaceId: z.string().uuid(),
|
|
92
|
+
profileHash: z.string().min(1)
|
|
93
|
+
}).strict(),
|
|
94
|
+
signatureVersion: SIGNATURE_VERSION,
|
|
95
|
+
parts: (message) => [message.workspaceId, message.profileHash]
|
|
96
|
+
};
|
|
97
|
+
function jobId(message) {
|
|
98
|
+
return `workspace-snapshot_${createHash("sha256").update(message.workspaceId).update("\0").update(message.profileHash).digest("hex").slice(0, 32)}`;
|
|
99
|
+
}
|
|
100
|
+
/** Sign a Workspace snapshot job for tests and local checks. */
|
|
101
|
+
function signWorkspaceSnapshotJobMessage(message, nowMs = Date.now()) {
|
|
102
|
+
return signQueueMessage(workspaceSnapshotJobSign, message, nowMs);
|
|
103
|
+
}
|
|
104
|
+
/** Check that a recent queue message came from Junior. */
|
|
105
|
+
function verifyWorkspaceSnapshotJobMessage(value, nowMs = Date.now()) {
|
|
106
|
+
return verifyQueueMessage(workspaceSnapshotJobSign, value, nowMs);
|
|
107
|
+
}
|
|
108
|
+
async function send(message, idempotencyKey) {
|
|
109
|
+
const options = { retentionSeconds: QUEUE_SIGNATURE_MAX_AGE_MS / 1e3 };
|
|
110
|
+
if (idempotencyKey) options.idempotencyKey = idempotencyKey;
|
|
111
|
+
await getQueueProvider().send(WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC, signWorkspaceSnapshotJobMessage(message), options);
|
|
112
|
+
}
|
|
113
|
+
/** Send a job unless the same Workspace build already has one. */
|
|
114
|
+
async function sendWorkspaceSnapshotJob(message) {
|
|
115
|
+
await send(message, jobId(message));
|
|
116
|
+
}
|
|
117
|
+
/** Send the next job for a Workspace build that is still running. */
|
|
118
|
+
async function sendNextWorkspaceSnapshotJob(message) {
|
|
119
|
+
await send(message);
|
|
120
|
+
}
|
|
121
|
+
// src/chat/cache-warming/queue.ts
|
|
122
|
+
/** Send and receive delayed cache warmup messages. */
|
|
123
|
+
/** Deploy topic name. Keep stable for Vercel queue wiring. */
|
|
124
|
+
const CACHE_WARMUP_QUEUE_TOPIC = "junior_cache_warmups";
|
|
125
|
+
const CACHE_WARMUP_DEV_CONSUMER_GROUP = "junior_cache_warmups_dev";
|
|
126
|
+
const cacheWarmupSign = {
|
|
127
|
+
context: "junior.cache_warmup_queue.v1",
|
|
128
|
+
schema: z.discriminatedUnion("kind", [z.object({
|
|
129
|
+
kind: z.literal("warmup"),
|
|
130
|
+
conversationId: z.string().min(1),
|
|
131
|
+
cycle: z.number().int().positive(),
|
|
132
|
+
generation: z.string().min(1),
|
|
133
|
+
cacheExpiresAtMs: z.number().int().positive()
|
|
134
|
+
}).strict(), z.object({
|
|
135
|
+
kind: z.literal("horizon"),
|
|
136
|
+
conversationId: z.string().min(1),
|
|
137
|
+
generation: z.string().min(1)
|
|
138
|
+
}).strict()]),
|
|
139
|
+
signatureVersion: "v1",
|
|
140
|
+
parts: (message) => [
|
|
141
|
+
message.kind,
|
|
142
|
+
message.conversationId,
|
|
143
|
+
message.generation,
|
|
144
|
+
message.kind === "warmup" ? String(message.cycle) : "",
|
|
145
|
+
message.kind === "warmup" ? String(message.cacheExpiresAtMs) : ""
|
|
146
|
+
]
|
|
147
|
+
};
|
|
148
|
+
/** Send a cache warming message that is delivered after `delayMs`. */
|
|
149
|
+
async function sendCacheWarmup(message, delayMs) {
|
|
150
|
+
await getQueueProvider().send(CACHE_WARMUP_QUEUE_TOPIC, signQueueMessage(cacheWarmupSign, message), {
|
|
151
|
+
delaySeconds: Math.max(0, Math.floor(delayMs / 1e3)),
|
|
152
|
+
retentionSeconds: message.kind === "warmup" ? Math.min(QUEUE_SIGNATURE_MAX_AGE_MS / 1e3, Math.ceil(Math.max(0, delayMs) / 1e3) + 120) : QUEUE_SIGNATURE_MAX_AGE_MS / 1e3,
|
|
153
|
+
idempotencyKey: `cache-warmup_${message.generation}_${message.kind === "warmup" ? message.cycle : message.kind}`
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function logCacheWarmupRejected(reason, metadata, error) {
|
|
157
|
+
logWarn("cache_warming.queue_message.rejected", {
|
|
158
|
+
"app.queue.consumer_group": metadata.consumerGroup,
|
|
159
|
+
"app.queue.delivery_count": metadata.deliveryCount,
|
|
160
|
+
"app.queue.message_id": metadata.messageId,
|
|
161
|
+
"app.queue.reject_reason": reason,
|
|
162
|
+
"app.queue.topic_name": metadata.topicName,
|
|
163
|
+
...error instanceof Error ? { "exception.message": error.message } : void 0
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function cacheWarmupCallback() {
|
|
167
|
+
return queueCallback({
|
|
168
|
+
consumerGroup: CACHE_WARMUP_DEV_CONSUMER_GROUP,
|
|
169
|
+
maxDeliveries: 1,
|
|
170
|
+
onRejected: logCacheWarmupRejected,
|
|
171
|
+
run: async (message) => {
|
|
172
|
+
const { runCacheWarmup } = await import("./warmup-C0IblNtf.js").then((n) => n.s);
|
|
173
|
+
await runCacheWarmup(message);
|
|
174
|
+
},
|
|
175
|
+
skip: () => !getChatConfig().cacheWarmingEnabled,
|
|
176
|
+
topic: CACHE_WARMUP_QUEUE_TOPIC,
|
|
177
|
+
verify: (value) => verifyQueueMessage(cacheWarmupSign, value)
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/** Create the HTTP route for cache warmup messages. */
|
|
181
|
+
function createVercelCacheWarmupCallback() {
|
|
182
|
+
return cacheWarmupCallback().create();
|
|
183
|
+
}
|
|
184
|
+
/** Return the queue consumer for cache warmups, for a pulling queue worker. */
|
|
185
|
+
function cacheWarmupQueueConsumer() {
|
|
186
|
+
return cacheWarmupCallback().consumer;
|
|
187
|
+
}
|
|
188
|
+
/** Receive cache warmup messages during local development. */
|
|
189
|
+
function registerVercelCacheWarmupDevConsumer() {
|
|
190
|
+
return cacheWarmupCallback().registerDev();
|
|
191
|
+
}
|
|
192
|
+
// src/chat/services/background-compaction-queue.ts
|
|
193
|
+
/**
|
|
194
|
+
* Messages of background compaction jobs.
|
|
195
|
+
*
|
|
196
|
+
* A message names one `compaction_requested` event. The event log holds the
|
|
197
|
+
* request, and the State adapter holds the request snapshot, so the message
|
|
198
|
+
* stays small.
|
|
199
|
+
*/
|
|
200
|
+
/** Deploy topic name. Keep stable for Vercel queue wiring. */
|
|
201
|
+
const BACKGROUND_COMPACTION_QUEUE_TOPIC = "junior_context_compaction";
|
|
202
|
+
const backgroundCompactionSign = {
|
|
203
|
+
context: "junior.context_compaction_queue.v1",
|
|
204
|
+
schema: z.object({
|
|
205
|
+
conversationId: z.string().min(1),
|
|
206
|
+
historyVersion: z.number().int().nonnegative(),
|
|
207
|
+
markSeq: z.number().int().nonnegative()
|
|
208
|
+
}).strict(),
|
|
209
|
+
signatureVersion: "v1",
|
|
210
|
+
parts: (message) => [
|
|
211
|
+
message.conversationId,
|
|
212
|
+
String(message.historyVersion),
|
|
213
|
+
String(message.markSeq)
|
|
214
|
+
]
|
|
215
|
+
};
|
|
216
|
+
/** Stable id of one request, for event, snapshot, and delivery dedupe. */
|
|
217
|
+
function backgroundCompactionId(message) {
|
|
218
|
+
return `context-compaction_${createHash("sha256").update(message.conversationId).update("\0").update(String(message.historyVersion)).update("\0").update(String(message.markSeq)).digest("hex").slice(0, 32)}`;
|
|
219
|
+
}
|
|
220
|
+
/** Check that a recent queue message came from Junior. */
|
|
221
|
+
function verifyBackgroundCompactionMessage(value) {
|
|
222
|
+
return verifyQueueMessage(backgroundCompactionSign, value);
|
|
223
|
+
}
|
|
224
|
+
/** The production queue for background compaction jobs. */
|
|
225
|
+
const vercelBackgroundCompactionQueue = { send: async (message) => {
|
|
226
|
+
await getQueueProvider().send(BACKGROUND_COMPACTION_QUEUE_TOPIC, signQueueMessage(backgroundCompactionSign, message), {
|
|
227
|
+
idempotencyKey: backgroundCompactionId(message),
|
|
228
|
+
retentionSeconds: QUEUE_SIGNATURE_MAX_AGE_MS / 1e3
|
|
229
|
+
});
|
|
230
|
+
} };
|
|
231
|
+
export { ConversationQueueMessageRejectedError as _, CACHE_WARMUP_QUEUE_TOPIC as a, nudgeIdempotencyKey as b, registerVercelCacheWarmupDevConsumer as c, sendNextWorkspaceSnapshotJob as d, sendWorkspaceSnapshotJob as f, verifyConversationQueueMessage as g, resolveConversationWorkQueueTopic as h, verifyBackgroundCompactionMessage as i, sendCacheWarmup as l, getVercelConversationWorkQueue as m, backgroundCompactionId as n, cacheWarmupQueueConsumer as o, verifyWorkspaceSnapshotJobMessage as p, vercelBackgroundCompactionQueue as r, createVercelCacheWarmupCallback as s, BACKGROUND_COMPACTION_QUEUE_TOPIC as t, WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC as u, conversationQueueMessageSchema as v, isConversationQueueMessageRejectedError as y };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { F as briefResourceLabel, L as parseBriefInput, M as briefCodeChangeSchema, f as conversationEventPageSchema, u as conversationDetailReportSchema } from "./conversation--f85g4zL.js";
|
|
2
|
-
import { c as generateBrief, n as briefEntriesFromReportEvents, t as BRIEF_PROMPT, u as completeObject } from "./prompt-
|
|
2
|
+
import { c as generateBrief, n as briefEntriesFromReportEvents, t as BRIEF_PROMPT, u as completeObject } from "./prompt-DuWH_YIb.js";
|
|
3
3
|
import { CLI_USAGE } from "./cli/run.js";
|
|
4
4
|
import * as z from "zod";
|
|
5
5
|
import path from "node:path";
|
|
@@ -264,7 +264,7 @@ async function parseRunOptions(argv) {
|
|
|
264
264
|
* token.
|
|
265
265
|
*/
|
|
266
266
|
async function configuredBot() {
|
|
267
|
-
const { botConfig } = await import("./config-
|
|
267
|
+
const { botConfig } = await import("./config-DY5c1E0l.js").then((n) => n.r);
|
|
268
268
|
return botConfig;
|
|
269
269
|
}
|
|
270
270
|
function apiUrl(baseUrl, pathname) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
|
|
2
|
-
import { t as createPluginCatalogRuntime } from "./registry-
|
|
2
|
+
import { t as createPluginCatalogRuntime } from "./registry-yht0oxq6.js";
|
|
3
3
|
// src/chat/plugins/catalog-runtime.ts
|
|
4
4
|
var catalog_runtime_exports = /* @__PURE__ */ __exportAll({ pluginCatalogRuntime: () => pluginCatalogRuntime });
|
|
5
5
|
const pluginCatalogRuntime = createPluginCatalogRuntime();
|
package/dist/cli/chat.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as JuniorPluginSet } from "../plugins-
|
|
1
|
+
import { n as JuniorPluginSet } from "../plugins-fBrz8PCV.js";
|
|
2
2
|
export declare const CHAT_USAGE = "usage: junior chat\n junior chat -p <message>";
|
|
3
3
|
export type ChatCommandOptions = {
|
|
4
4
|
mode: "interactive";
|