@sentry/junior 0.256.0 → 0.257.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{admin-BhucwVfy.js → admin-DgIkm6Vy.js} +1 -1
- package/dist/{agent-hooks-DlSK8PQQ.js → agent-hooks-BjtTzvru.js} +13 -13
- package/dist/{agent-invocations-BY60iNw-.js → agent-invocations-Bdu3ROfo.js} +2 -1
- package/dist/{agent-runner-C6_cd61V.js → agent-runner-D7OboVb3.js} +41 -33
- package/dist/api/schema.d.ts +41 -1
- package/dist/api/schema.js +2 -2
- package/dist/api.js +121 -33
- package/dist/{app-B0gT1Slp.d.ts → app-BsU5QNBd.d.ts} +7 -1
- package/dist/app.d.ts +1 -1
- package/dist/app.js +587 -210
- package/dist/{assistant-reply-yn5G-YEG.js → assistant-reply-CbTPebzL.js} +1 -1
- package/dist/{briefs-U6Bi3IYw.js → briefs-oLOldnDM.js} +4 -4
- package/dist/{catalog-runtime-DF5OWqCc.js → catalog-runtime-CZzhGQ7F.js} +1 -1
- package/dist/cli/chat.js +16 -16
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +2 -2
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +3 -3
- package/dist/cli/upgrade.js +3 -3
- package/dist/{client-BVrAp-pq.js → client-D8HnkOQX.js} +2 -2
- package/dist/{config-DdBiDanf.js → config-CJRnWK9H.js} +2 -2
- package/dist/{connections-CG04HdpC.js → connections-ClYrKzpX.js} +16 -11
- package/dist/{conversation-T18Xlkx9.js → conversation-CKNLYBJt.js} +3 -2
- package/dist/{conversation-privacy-CpSYOWnP.js → conversation-privacy-C8b1nphZ.js} +1 -1
- package/dist/{credential-sync-DKWNdcgm.js → credential-sync-BXfohNmJ.js} +82 -40
- package/dist/{executor-BroK9oKy.js → executor-Do0THDRR.js} +33 -23
- package/dist/{experimental-Qn9rKLgx.js → experimental-CQIvMUO7.js} +1 -0
- package/dist/{images-D0VZ5nv0.js → images-BN_BiBXF.js} +3 -3
- package/dist/instrumentation.js +2 -2
- package/dist/{job-queue-BbGg3gvu.js → job-queue-B6SV9uVa.js} +1 -1
- package/dist/{logging-tPQeUe2i.js → logging-CWxiIuCF.js} +50 -15
- package/dist/{message-DdPGRYQP.js → message-TUOdbSBW.js} +3 -3
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-callback-server-B-2errCX.js → oauth-callback-server-Dj5UJODo.js} +2 -2
- package/dist/{pending-auth-DT3MRVW8.js → pending-auth-s_QFribU.js} +3 -3
- package/dist/{profile-Bb1zCVGP.js → profile-h-72wM78.js} +4 -4
- package/dist/{prompt-C04mP1hu.js → prompt-DyoEj9c2.js} +1 -1
- package/dist/{registry-CsNavQ_Z.js → registry-sLTr-sV9.js} +43 -3
- package/dist/{resolve-B6ZZ9duG.js → resolve-ncQPZROQ.js} +2 -2
- package/dist/{result-j9nS0se-.js → result-C883vngT.js} +7 -7
- package/dist/{runner-Y331DoZ5.js → runner-CzYImdOF.js} +10 -10
- package/dist/{sandbox-egress-signals-BUfjEdHY.js → sandbox-egress-signals-CZbMINHI.js} +1 -1
- package/dist/{schema-BBgv0MNf.js → schema-Dy69D4Ge.js} +4 -3
- package/dist/{session-stop-q-6GNHx6.js → session-stop-CQjKd4a2.js} +46 -20
- package/dist/{skills-CyvTsR9M.js → skills-C22SLruK.js} +2 -2
- package/dist/{spawn-Do5mX3d_.js → spawn-DY9CLXDL.js} +2 -2
- package/dist/{store-D2It0ozF.js → store-DXFIQy-G.js} +6 -6
- package/dist/{task-queue-ZMk9bLRT.js → task-queue-B17vV0La.js} +3 -3
- package/dist/{task-runner-cIGU5VwJ.js → task-runner-DUjvzYXj.js} +11 -11
- package/dist/{tasks-CODtRzvX.js → tasks-D_WIJtvO.js} +25 -10
- package/dist/{thread-state-BPkwVmvK.js → thread-state-Ch4yuCqG.js} +7 -7
- package/dist/{turn-failure-response-ChmMeKar.js → turn-failure-response-C5nBKC4S.js} +8 -8
- package/dist/{turn-lifecycle-BUP7ZOVa.js → turn-lifecycle-CO-ylUmV.js} +1 -1
- package/dist/{turn-session-routing-BcWM3PLm.js → turn-session-routing-B3LWooK5.js} +1 -1
- package/dist/{validation-DCd69-cP.js → validation-CXYxaNYx.js} +1 -1
- package/dist/{version-DBc4Qt_P.js → version-BcdZy2zg.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-C-9nFKYr.js → viewer-DSZXygMU.js} +53 -5
- package/dist/{web-input-Cv42P3ni.js → web-input-B9Bv0_lR.js} +73 -75
- package/dist/{work-6UmVQq1V.js → work-nAfDSUFP.js} +9 -9
- package/dist/{worker-DAoBZuZn.js → worker-vGXZ6XFT.js} +5 -5
- package/migrations/0059_automation_run_version.sql +2 -0
- package/migrations/0060_identity_signed_in_at.sql +1 -0
- package/migrations/meta/0059_snapshot.json +3619 -0
- package/migrations/meta/0060_snapshot.json +3465 -0
- package/migrations/meta/_journal.json +15 -1
- package/package.json +5 -4
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { d as unwrapCurrentInstruction, f as escapeXml, i as completeText, o as resolveGatewayModel } from "./client-
|
|
2
|
-
import {
|
|
1
|
+
import { d as unwrapCurrentInstruction, f as escapeXml, i as completeText, o as resolveGatewayModel } from "./client-D8HnkOQX.js";
|
|
2
|
+
import { f as logException, m as logWarn, o as getActiveTraceId, s as getLogContextAttributes, t as buildTurnFailureResponse, y as setSpanAttributes } from "./logging-CWxiIuCF.js";
|
|
3
3
|
import { n as captureMessage } from "./sentry-CgWZM_kV.js";
|
|
4
|
-
import { n as botConfig, v as normalizeSlackEmojiName } from "./config-
|
|
4
|
+
import { n as botConfig, v as normalizeSlackEmojiName } from "./config-CJRnWK9H.js";
|
|
5
5
|
import { c as toStoredSlackActor, f as parseSlackUserId, g as parseSlackMessageTs } from "./actor-BTtLaeWy.js";
|
|
6
|
-
import {
|
|
7
|
-
import { a as
|
|
6
|
+
import { S as bindProviderConversation, b as startLocationThread, d as getConversationStore, h as withConversationEventLock, l as getConversationEventStore, m as createSqlConversationEventStore, p as getSqlExecutor, w as addAgentTurnUsage } from "./viewer-DSZXygMU.js";
|
|
7
|
+
import { a as juniorAutomationRuns, o as juniorAutomationVersions, s as juniorAutomations } from "./executor-Do0THDRR.js";
|
|
8
8
|
import { d as contextProvenance, f as instructionActors, n as agentHistoryItemSchema, p as instructionProvenanceFor } from "./history-9pO1Zd4Y.js";
|
|
9
|
-
import {
|
|
10
|
-
import { $t as authenticationUnlinkedEvent, Gt as normalizeSlackConversationId, Ht as getSlackClient, Qt as authenticationLinkedEvent, Rt as SlackActionError, Xt as JUNIOR_NATIVE_EVENT_NAMESPACE, Zt as agentsInstructionsUpdatedEvent, n as applyPluginFormatMarkdown, qt as withSlackRetries } from "./agent-hooks-
|
|
11
|
-
import { G as messageCardRef } from "./conversation-
|
|
12
|
-
import { D as fenceLock, O as withLock, T as MUTATION_LOCK_TTL_MS, k as sleep, w as getStateAdapter } from "./profile-
|
|
9
|
+
import { h as credentialSubjectSchema } from "./registry-sLTr-sV9.js";
|
|
10
|
+
import { $t as authenticationUnlinkedEvent, Gt as normalizeSlackConversationId, Ht as getSlackClient, Qt as authenticationLinkedEvent, Rt as SlackActionError, Xt as JUNIOR_NATIVE_EVENT_NAMESPACE, Zt as agentsInstructionsUpdatedEvent, n as applyPluginFormatMarkdown, qt as withSlackRetries } from "./agent-hooks-BjtTzvru.js";
|
|
11
|
+
import { G as messageCardRef } from "./conversation-CKNLYBJt.js";
|
|
12
|
+
import { D as fenceLock, O as withLock, T as MUTATION_LOCK_TTL_MS, k as sleep, w as getStateAdapter } from "./profile-h-72wM78.js";
|
|
13
13
|
import { A as eventAutomationSchema, E as scheduledAutomationSchema, S as automationVersionSchema } from "./automation-CHdlHVZP.js";
|
|
14
14
|
import { isDeepStrictEqual } from "node:util";
|
|
15
15
|
import { z } from "zod";
|
|
@@ -2869,6 +2869,21 @@ async function recordAutomationVersion(db, task, current, editedBy) {
|
|
|
2869
2869
|
definition
|
|
2870
2870
|
});
|
|
2871
2871
|
}
|
|
2872
|
+
/**
|
|
2873
|
+
* Select the newest saved version with the same definition as `task`.
|
|
2874
|
+
*
|
|
2875
|
+
* An Automation run stores this version so that a reader can see the
|
|
2876
|
+
* instruction that ran after the definition changes. The value is null when
|
|
2877
|
+
* no saved version has this definition.
|
|
2878
|
+
*/
|
|
2879
|
+
function automationVersionOf(task) {
|
|
2880
|
+
return sql`(
|
|
2881
|
+
SELECT max(${juniorAutomationVersions.version})
|
|
2882
|
+
FROM ${juniorAutomationVersions}
|
|
2883
|
+
WHERE ${juniorAutomationVersions.automationId} = ${task.id}
|
|
2884
|
+
AND ${juniorAutomationVersions.definition} = ${JSON.stringify(automationDefinition(task))}::jsonb
|
|
2885
|
+
)`;
|
|
2886
|
+
}
|
|
2872
2887
|
const versionColumns = {
|
|
2873
2888
|
createdAtMs: juniorAutomationVersions.createdAtMs,
|
|
2874
2889
|
definition: juniorAutomationVersions.definition,
|
|
@@ -3270,4 +3285,4 @@ async function saveScheduledAutomationInLock(db, task, current) {
|
|
|
3270
3285
|
await writeScheduledAutomation(db, requireStoredTask(task), current);
|
|
3271
3286
|
}
|
|
3272
3287
|
//#endregion
|
|
3273
|
-
export {
|
|
3288
|
+
export { recordTurnSummary as $, buildConversationContext as $t, escapeSlackMrkdwnText as A, loadTurnProjection as At, postSlackMessage as B, recordSubscribedReplyRoute as Bt, automationVersionOf as C, ToolInputError as Ct, AutomationConflictError as D, loadConversationProjection as Dt, sameDefinitionValue as E, loadConnectedMcpProviders as Et, truncateStatusText as F, recordAuthenticationLinked as Ft, continuableMessages as G, persistConversationMessages as Gt, uploadFilesToConversation as H, recordTurnRoute as Ht, addReactionToMessage as I, recordAuthorizationCompleted as It, abandonTurnRecord as J, resolveConversationTitle as Jt, loadTurnCheckpoint as K, projectConversationMessages as Kt, getSlackMessagePermalink as L, recordAuthorizationRequested as Lt, normalizeSlackReplyMarkdown as M, openConversationProjection as Mt, normalizeSlackStatusText as N, recordAgentsInstructionsUpdated as Nt, automationRevision as O, loadLastModelProfile as Ot, slackMention as P, recordAttachmentsDelivered as Pt, listTurnSummaries as Q, appendThreadContextMessages as Qt, openSlackDirectMessage as R, recordGuardianActionReviewed as Rt, automationDefinition as S, TURN_CONTEXT_TAG as St, readAutomationVersion as T, commitMessages as Tt, slackEntitySchema as U, appendConversationMessages as Ut, removeReactionFromMessage as V, recordToolExecutionStarted as Vt, slackExternalRefIdSchema as W, hydrateConversationMessages as Wt, failTurnRecord as X, fallbackShortTitle as Xt, completeTurnRecord as Y, settleConversationTitleWork as Yt, getTurnRecord as Z, resolveTaskTitle as Zt, parseEventAutomationRow as _, isToolResultMessage as _t, saveScheduledAutomation as a, normalizeConversationText as an, buildTurnErrorResponse as at, admitEventAutomationRun as b, stripRuntimeTurnContext as bt, withScheduledAutomationLock as c, upsertConversationMessage as cn, extractAssistantText as ct, createEventAutomation as d, getAgentContextInputLimitTokens as dn, getUserMessageInstructionText as dt, createConversationMemoryService as en, persistWithRetry as et, deleteEventAutomation as f, historyItemFromPiMessage as fn, hasRuntimeTurnContext as ft, listEventAutomationsForTeam as g, isToolResultError as gt, listDeletedEventAutomationsCreatedBy as h, isContinuablePiBoundary as ht, readScheduledAutomation as i, markConversationMessage as in, TurnToolCallLimitExceededError as it, formatSlackLink as j, loadTurnRoute as jt, requireAutomationRevision as k, loadProjection as kt, blockEventAutomation as l, estimateTextTokens as ln, getPiMessageRole as lt, getEventAutomation as m, isAssistantMessage as mt, listScheduledAutomationsForTeam as n, getConversationMessageSlackTs as nn, TurnBudgetExceededError as nt, saveScheduledAutomationInLock as o, recordDeliveredAssistantMessage as on, createTurnLimitGate as ot, findMatchingEventAutomations as p, piMessageFromHistoryItem as pn, instructionTextForProjection as pt, saveTurnCheckpoint as q, persistConversationMessageSummaries as qt, parseScheduledAutomationRow as r, isHumanConversationMessage as rn, TurnSliceLimitExceededError as rt, scheduledRunId as s, turnHasReply as sn, isTurnExecutionLimitExceededError as st, createScheduledAutomation as t, estimateConversationContextTokens as tn, TURN_LIMIT_DISABLED_REASON as tt, collectEventAutomationMatchKeys as u, getAgentContextCompactionTriggerTokens as un, getTerminalAssistantMessages as ut, saveEventAutomation as v, normalizeToolNameFromResult as vt, listAutomationVersions as w, commitAcceptedReply as wt, eventAutomationRunLimitReason as x, trimTrailingAssistantMessages as xt, setEventAutomationStatus as y, retainRuntimeTurnContext as yt, postSlackEphemeralMessage as z, recordMcpProviderConnected as zt };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { d as juniorDestinations } from "./agent-invocations-
|
|
4
|
-
import { l as juniorLocationConfigurations } from "./executor-
|
|
5
|
-
import {
|
|
6
|
-
import { it as JUNIOR_THREAD_STATE_TTL_MS } from "./agent-hooks-
|
|
7
|
-
import { w as getStateAdapter } from "./profile-
|
|
1
|
+
import { B as toOptionalNumber, V as toOptionalString, z as isRecord } from "./logging-CWxiIuCF.js";
|
|
2
|
+
import { f as getDb } from "./viewer-DSZXygMU.js";
|
|
3
|
+
import { d as juniorDestinations } from "./agent-invocations-Bdu3ROfo.js";
|
|
4
|
+
import { l as juniorLocationConfigurations } from "./executor-Do0THDRR.js";
|
|
5
|
+
import { Gt as persistConversationMessages } from "./tasks-D_WIJtvO.js";
|
|
6
|
+
import { it as JUNIOR_THREAD_STATE_TTL_MS } from "./agent-hooks-BjtTzvru.js";
|
|
7
|
+
import { w as getStateAdapter } from "./profile-h-72wM78.js";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
10
10
|
import { and, eq, sql } from "drizzle-orm";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { _ as getProviderErrorUserMessage, g as getProviderErrorAttributes, h as findProviderError, p as ProviderError } from "./client-
|
|
2
|
-
import {
|
|
1
|
+
import { _ as getProviderErrorUserMessage, g as getProviderErrorAttributes, h as findProviderError, p as ProviderError } from "./client-D8HnkOQX.js";
|
|
2
|
+
import { t as buildTurnFailureResponse, z as isRecord } from "./logging-CWxiIuCF.js";
|
|
3
3
|
import { g as parseSlackMessageTs } from "./actor-BTtLaeWy.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { Nt as listConversationAnnotations } from "./agent-hooks-
|
|
7
|
-
import { J as removedCardSchema, Y as resolveMessageCards, q as readMessageCardRefs } from "./conversation-
|
|
8
|
-
import { r as clearPendingAuth, u as buildDeterministicTurnId } from "./pending-auth-
|
|
4
|
+
import { f as getDb, l as getConversationEventStore } from "./viewer-DSZXygMU.js";
|
|
5
|
+
import { Wt as hydrateConversationMessages, in as markConversationMessage } from "./tasks-D_WIJtvO.js";
|
|
6
|
+
import { Nt as listConversationAnnotations } from "./agent-hooks-BjtTzvru.js";
|
|
7
|
+
import { J as removedCardSchema, Y as resolveMessageCards, q as readMessageCardRefs } from "./conversation-CKNLYBJt.js";
|
|
8
|
+
import { r as clearPendingAuth, u as buildDeterministicTurnId } from "./pending-auth-s_QFribU.js";
|
|
9
9
|
import { d as markTurnCompleted, u as markTurnClosed } from "./oauth-authorization-BA4Dt6a7.js";
|
|
10
|
-
import { o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-
|
|
10
|
+
import { o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-Ch4yuCqG.js";
|
|
11
11
|
//#region src/chat/conversations/pending-cards.ts
|
|
12
12
|
/** Select undelivered cards and load their latest saved facts. */
|
|
13
13
|
async function loadPendingMessageCards(conversationId) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as getConversationEventStore } from "./viewer-DSZXygMU.js";
|
|
2
2
|
//#region src/chat/conversations/turn-lifecycle.ts
|
|
3
3
|
/** Persist correlated turn lifecycle facts with retry-safe terminal exclusion. */
|
|
4
4
|
var ConversationTurnLifecycleService = class {
|
|
@@ -34,7 +34,7 @@ function slackSourceForDestination(args) {
|
|
|
34
34
|
* Reads parent Conversations when this Conversation has no Destination.
|
|
35
35
|
*/
|
|
36
36
|
async function resolveConversationRouting(args) {
|
|
37
|
-
const conversationStore = args.conversationStore ?? (await import("./viewer-
|
|
37
|
+
const conversationStore = args.conversationStore ?? (await import("./viewer-DSZXygMU.js").then((n) => n.c)).getConversationStore();
|
|
38
38
|
const chain = await loadConversationChain(args.conversationId, conversationStore);
|
|
39
39
|
let destination;
|
|
40
40
|
let source;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
2
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-CZzhGQ7F.js";
|
|
3
3
|
import { isDeepStrictEqual } from "node:util";
|
|
4
4
|
//#region src/chat/plugins/validation.ts
|
|
5
5
|
var validation_exports = /* @__PURE__ */ __exportAll({
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as JUNIOR_VERSION } from "./version-
|
|
1
|
+
import { t as JUNIOR_VERSION } from "./version-BcdZy2zg.js";
|
|
2
2
|
export { JUNIOR_VERSION };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import {
|
|
3
|
-
import { i as getChatConfig } from "./config-
|
|
2
|
+
import { I as GOOGLE_IDENTITY_PROVIDER, R as normalizeIdentityEmail } from "./logging-CWxiIuCF.js";
|
|
3
|
+
import { i as getChatConfig } from "./config-CJRnWK9H.js";
|
|
4
4
|
import { d as parseSlackTeamId, o as parseActorUserId, u as parseSlackChannelReferenceId } from "./actor-BTtLaeWy.js";
|
|
5
|
-
import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers, o as conversationReadColumns, s as juniorConversations } from "./agent-invocations-
|
|
6
|
-
import { _ as juniorConversationAnnotations, d as juniorConversationBindings, h as juniorConversationEvents, m as juniorConversationMetrics, p as CONVERSATION_METRICS, t as createJuniorSqlExecutor, u as juniorConversationParticipants } from "./executor-
|
|
5
|
+
import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers, o as conversationReadColumns, s as juniorConversations } from "./agent-invocations-Bdu3ROfo.js";
|
|
6
|
+
import { _ as juniorConversationAnnotations, d as juniorConversationBindings, h as juniorConversationEvents, m as juniorConversationMetrics, p as CONVERSATION_METRICS, t as createJuniorSqlExecutor, u as juniorConversationParticipants } from "./executor-Do0THDRR.js";
|
|
7
7
|
import { c as newConversationEventSchema, h as usageSchema, l as encodeHistoryPayload, o as decodeStoredConversationEvent, r as conversationEventDataSchema, s as historyReplacementSchema } from "./history-9pO1Zd4Y.js";
|
|
8
8
|
import { randomUUID } from "node:crypto";
|
|
9
9
|
import { and, asc, desc, eq, gt, gte, inArray, isNull, lt, lte, ne, or, sql } from "drizzle-orm";
|
|
10
10
|
import { destinationSchema, identitySchema, locationSchema, sourceSchema, userSchema } from "@sentry/junior-plugin-api";
|
|
11
|
+
import { alias } from "drizzle-orm/pg-core";
|
|
11
12
|
//#region src/chat/destination.ts
|
|
12
13
|
/** Build Junior's canonical destination from Slack workspace and channel ids. */
|
|
13
14
|
function createSlackDestination(input) {
|
|
@@ -39,6 +40,7 @@ function sameDestination(left, right) {
|
|
|
39
40
|
}
|
|
40
41
|
//#endregion
|
|
41
42
|
//#region src/chat/identities/sql.ts
|
|
43
|
+
const googleIdentity = alias(juniorIdentities, "google_identity");
|
|
42
44
|
function dateFromMs$1(ms) {
|
|
43
45
|
return new Date(ms);
|
|
44
46
|
}
|
|
@@ -153,12 +155,57 @@ async function upsertIdentity(executor, identity, nowMs = Date.now()) {
|
|
|
153
155
|
async function upsertLinkedIdentity(executor, userId, identity, nowMs = Date.now()) {
|
|
154
156
|
return await upsertIdentityRecord(executor, identity, userId, nowMs);
|
|
155
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Find the one user whose primary email is in a provider-verified email list.
|
|
160
|
+
* Return undefined when no user or more than one user matches.
|
|
161
|
+
*/
|
|
162
|
+
async function findUserByVerifiedEmails(executor, emails) {
|
|
163
|
+
const normalized = new Set(emails.map((email) => normalizeIdentityEmail(email) ?? ""));
|
|
164
|
+
normalized.delete("");
|
|
165
|
+
if (normalized.size === 0) return void 0;
|
|
166
|
+
const rows = await executor.db().select({
|
|
167
|
+
email: juniorUsers.primaryEmail,
|
|
168
|
+
userId: juniorUsers.id
|
|
169
|
+
}).from(juniorUsers).where(inArray(juniorUsers.primaryEmailNormalized, Array.from(normalized))).limit(2);
|
|
170
|
+
return rows.length === 1 ? rows[0] : void 0;
|
|
171
|
+
}
|
|
156
172
|
/** Remove one exact provider identity owned by a workspace Slack user. */
|
|
157
173
|
async function deleteProviderIdentityForSlackUser(executor, slackTeamId, slackUserId, provider, providerSubjectId) {
|
|
158
174
|
const userId = (await executor.db().select({ userId: juniorIdentities.userId }).from(juniorIdentities).where(and(eq(juniorIdentities.kind, "user"), eq(juniorIdentities.provider, "slack"), eq(juniorIdentities.providerTenantId, slackTeamId), eq(juniorIdentities.providerSubjectId, slackUserId))).limit(1))[0]?.userId;
|
|
159
175
|
if (!userId) return;
|
|
176
|
+
await deleteProviderIdentityForUser(executor, userId, provider, providerSubjectId);
|
|
177
|
+
}
|
|
178
|
+
/** Remove one exact provider identity owned by a user. */
|
|
179
|
+
async function deleteProviderIdentityForUser(executor, userId, provider, providerSubjectId) {
|
|
160
180
|
await executor.db().delete(juniorIdentities).where(and(eq(juniorIdentities.userId, userId), eq(juniorIdentities.provider, provider), eq(juniorIdentities.providerTenantId, ""), eq(juniorIdentities.providerSubjectId, providerSubjectId)));
|
|
161
181
|
}
|
|
182
|
+
/** Read the user linked to one Slack identity. */
|
|
183
|
+
async function findSlackIdentityUserId(executor, slackTeamId, slackUserId) {
|
|
184
|
+
return (await executor.db().select({ userId: juniorIdentities.userId }).from(juniorIdentities).where(and(eq(juniorIdentities.kind, "user"), eq(juniorIdentities.provider, "slack"), eq(juniorIdentities.providerTenantId, slackTeamId), eq(juniorIdentities.providerSubjectId, slackUserId))).limit(1))[0]?.userId ?? void 0;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Save one Google sign-in. Link the Google identity to the user of its
|
|
188
|
+
* verified email, and set its sign-in time.
|
|
189
|
+
*/
|
|
190
|
+
async function recordGoogleSignIn(executor, account, nowMs = Date.now()) {
|
|
191
|
+
const stored = await upsertIdentity(executor, {
|
|
192
|
+
kind: "user",
|
|
193
|
+
provider: GOOGLE_IDENTITY_PROVIDER,
|
|
194
|
+
providerSubjectId: account.subject,
|
|
195
|
+
email: account.email,
|
|
196
|
+
emailVerified: true,
|
|
197
|
+
displayName: account.displayName
|
|
198
|
+
}, nowMs);
|
|
199
|
+
await executor.db().update(juniorIdentities).set({ signedInAt: dateFromMs$1(nowMs) }).where(eq(juniorIdentities.id, stored.id));
|
|
200
|
+
return stored;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Return whether the user of one Slack identity signed in with Google at or
|
|
204
|
+
* after `signedInSince`.
|
|
205
|
+
*/
|
|
206
|
+
async function slackUserHasGoogleSignIn(executor, args) {
|
|
207
|
+
return (await executor.db().select({ id: googleIdentity.id }).from(juniorIdentities).innerJoin(googleIdentity, eq(googleIdentity.userId, juniorIdentities.userId)).where(and(eq(juniorIdentities.kind, "user"), eq(juniorIdentities.provider, "slack"), eq(juniorIdentities.providerTenantId, args.slackTeamId), eq(juniorIdentities.providerSubjectId, args.slackUserId), eq(googleIdentity.kind, "user"), eq(googleIdentity.provider, GOOGLE_IDENTITY_PROVIDER), eq(googleIdentity.emailVerified, true), gte(googleIdentity.signedInAt, args.signedInSince))).limit(1)).length > 0;
|
|
208
|
+
}
|
|
162
209
|
//#endregion
|
|
163
210
|
//#region src/chat/conversations/sql/participants.ts
|
|
164
211
|
/** Resolve the root conversation id that owns personal-feed membership. */
|
|
@@ -1042,6 +1089,7 @@ function readAuthor(meta) {
|
|
|
1042
1089
|
...typeof author.userName === "string" ? { userName: author.userName } : void 0
|
|
1043
1090
|
};
|
|
1044
1091
|
}
|
|
1092
|
+
/** Read the Slack workspace that owns a conversation, when it has one. */
|
|
1045
1093
|
async function loadConversationSlackTenantId(executor, conversationId) {
|
|
1046
1094
|
const [row] = await executor.db().select({
|
|
1047
1095
|
providerTenantId: juniorDestinations.providerTenantId,
|
|
@@ -1620,4 +1668,4 @@ async function readActorIdentity(actor) {
|
|
|
1620
1668
|
return await readActorIdentityFromSql(getDb(), actor);
|
|
1621
1669
|
}
|
|
1622
1670
|
//#endregion
|
|
1623
|
-
export {
|
|
1671
|
+
export { deleteProviderIdentityForSlackUser as A, createSlackDestination as B, parseSessionSource as C, agentTurnUsageSchema as D, agentTurnTotalTokens as E, recordGoogleSignIn as F, requireSlackDestination as H, saveUserTimezone as I, slackUserHasGoogleSignIn as L, findSlackIdentityUserId as M, findUserByVerifiedEmails as N, hasAgentTurnUsage as O, readUserTimezone as P, upsertIdentity as R, bindProviderConversation as S, agentTurnCostUsd as T, sameDestination as U, parseDestination as V, createSqlStore as _, resolveViewerUser as a, startLocationThread as b, db_exports as c, getConversationStore as d, getDb as f, loadConversationSlackTenantId as g, withConversationEventLock as h, readActorIdentity as i, deleteProviderIdentityForUser as j, resolveRootConversationId as k, getConversationEventStore as l, createSqlConversationEventStore as m, findUserByEmailFromSql as n, setUserAdminFromSql as o, getSqlExecutor as p, listAdminUsersFromSql as r, updateViewerDisplayName as s, findUserByEmail as t, getConversationMessageSearchStore as u, withConversationMutationLock as v, addAgentTurnUsage as w, identityFromActor as x, locationFromRow as y, upsertLinkedIdentity as z };
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { A as resolveSlackChannelIdFromMessage, B as effectiveTaskOutcomes, Bt as
|
|
2
|
-
import { f as escapeXml, i as completeText, r as completeObject, v as isProviderRetryError } from "./client-
|
|
3
|
-
import {
|
|
4
|
-
import { c as getSlackClientSecret, i as getChatConfig, l as getSlackSigningSecret, n as botConfig, o as getSlackBotToken, s as getSlackClientId, v as normalizeSlackEmojiName } from "./config-
|
|
1
|
+
import { A as resolveSlackChannelIdFromMessage, B as effectiveTaskOutcomes, Bt as withoutSavedSteeringMessages, C as renderBlockText, D as storeAttachment, Kt as shouldEmitDevAgentTrace, M as getConversationInfo, N as listThreadReplies, O as parseSlackThreadId, Rt as createUserTokenStore, S as renderAttachmentText, Vt as RetryableDeliveryError, Wt as AuthorizationFlowDisabledError, a as buildAuthPauseResponse, h as latestProgressStatus, j as resolveSlackChannelIdFromThreadId, k as readSlackRawMessageContext, m as PluginCredentialFailureError, n as executeAgentRun, r as createContextCompactor, t as createAgentRunner, z as eventAutomationTriggerAvailable, zt as buildSteeringPiMessage } from "./agent-runner-D7OboVb3.js";
|
|
2
|
+
import { f as escapeXml, i as completeText, r as completeObject, v as isProviderRetryError } from "./client-D8HnkOQX.js";
|
|
3
|
+
import { B as toOptionalNumber, T as withSpan, V as toOptionalString, d as logError, f as logException, m as logWarn, n as createChatSdkLogger, o as getActiveTraceId, p as logInfo, t as buildTurnFailureResponse, v as setSentryUser, w as withLogContext, x as setTags, y as setSpanAttributes, z as isRecord } from "./logging-CWxiIuCF.js";
|
|
4
|
+
import { c as getSlackClientSecret, i as getChatConfig, l as getSlackSigningSecret, n as botConfig, o as getSlackBotToken, s as getSlackClientId, v as normalizeSlackEmojiName } from "./config-CJRnWK9H.js";
|
|
5
5
|
import { o as modelIdForProfile, r as defaultModelId } from "./model-profile-BwU8mqwD.js";
|
|
6
6
|
import { a as isUserActor, g as parseSlackMessageTs, i as isActorUserId, l as parseSlackChannelId, n as createSlackActor, o as parseActorUserId, r as createSlackResumeActor, t as createActor } from "./actor-BTtLaeWy.js";
|
|
7
|
-
import {
|
|
8
|
-
import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers } from "./agent-invocations-
|
|
9
|
-
import {
|
|
7
|
+
import { B as createSlackDestination, H as requireSlackDestination, d as getConversationStore, f as getDb, l as getConversationEventStore, p as getSqlExecutor } from "./viewer-DSZXygMU.js";
|
|
8
|
+
import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers } from "./agent-invocations-Bdu3ROfo.js";
|
|
9
|
+
import { a as juniorAutomationRuns, s as juniorAutomations } from "./executor-Do0THDRR.js";
|
|
10
10
|
import { p as instructionProvenanceFor } from "./history-9pO1Zd4Y.js";
|
|
11
|
-
import { d as credentialContextForActor } from "./registry-
|
|
12
|
-
import { $ as
|
|
13
|
-
import { Et as getSlackFileId, Gt as normalizeSlackConversationId, Ht as getSlackClient, Kt as runWithSlackInstallationToken, Lt as lookupSlackUser, Ot as readAttachmentVisionSummary, Rt as SlackActionError, Tt as buildSentryConversationUrl, V as cancelSubscriptions, Vt as getHeaderString, Wt as isDmChannel, at as getDashboardConversationLink, it as JUNIOR_THREAD_STATE_TTL_MS, kt as recordSlackAttachment, o as getPluginSlackConversationLink, ot as getDashboardObjectIconLink, rt as verifyTimerWatchCredentialSubject, zt as downloadPrivateSlackFile } from "./agent-hooks-
|
|
14
|
-
import { F as readMessageAttachments, R as isVisionImageMediaType } from "./conversation-
|
|
15
|
-
import { E as acquireActiveLock, O as withLock, T as MUTATION_LOCK_TTL_MS, w as getStateAdapter } from "./profile-
|
|
16
|
-
import { a as wasPendingAuthStopped, c as getThreadStopDecision, l as buildDeterministicAssistantMessageId, o as decideSubscribedThreadReply, r as clearPendingAuth, s as getSubscribedReplyPreflightDecision, u as buildDeterministicTurnId } from "./pending-auth-
|
|
11
|
+
import { d as actorLogContext, f as credentialContextForActor } from "./registry-sLTr-sV9.js";
|
|
12
|
+
import { $ as recordTurnSummary, $t as buildConversationContext, A as escapeSlackMrkdwnText, B as postSlackMessage, Bt as recordSubscribedReplyRoute, Dt as loadConversationProjection, E as sameDefinitionValue, F as truncateStatusText, Gt as persistConversationMessages, I as addReactionToMessage, It as recordAuthorizationCompleted, J as abandonTurnRecord, Jt as resolveConversationTitle, K as loadTurnCheckpoint, M as normalizeSlackReplyMarkdown, N as normalizeSlackStatusText, Q as listTurnSummaries, Qt as appendThreadContextMessages, S as automationDefinition, Tt as commitMessages, V as removeReactionFromMessage, Wt as hydrateConversationMessages, X as failTurnRecord, Xt as fallbackShortTitle, Y as completeTurnRecord, Z as getTurnRecord, _ as parseEventAutomationRow, an as normalizeConversationText, at as buildTurnErrorResponse, c as withScheduledAutomationLock, cn as upsertConversationMessage, en as createConversationMemoryService, et as persistWithRetry, f as deleteEventAutomation, h as listDeletedEventAutomationsCreatedBy, i as readScheduledAutomation, in as markConversationMessage, j as formatSlackLink, kt as loadProjection, nn as getConversationMessageSlackTs, o as saveScheduledAutomationInLock, on as recordDeliveredAssistantMessage, q as saveTurnCheckpoint, qt as persistConversationMessageSummaries, r as parseScheduledAutomationRow, rn as isHumanConversationMessage, sn as turnHasReply, tn as estimateConversationContextTokens, w as listAutomationVersions, wt as commitAcceptedReply, xt as trimTrailingAssistantMessages } from "./tasks-D_WIJtvO.js";
|
|
13
|
+
import { Et as getSlackFileId, Gt as normalizeSlackConversationId, Ht as getSlackClient, Kt as runWithSlackInstallationToken, Lt as lookupSlackUser, Ot as readAttachmentVisionSummary, Rt as SlackActionError, Tt as buildSentryConversationUrl, V as cancelSubscriptions, Vt as getHeaderString, Wt as isDmChannel, at as getDashboardConversationLink, it as JUNIOR_THREAD_STATE_TTL_MS, kt as recordSlackAttachment, o as getPluginSlackConversationLink, ot as getDashboardObjectIconLink, rt as verifyTimerWatchCredentialSubject, zt as downloadPrivateSlackFile } from "./agent-hooks-BjtTzvru.js";
|
|
14
|
+
import { F as readMessageAttachments, R as isVisionImageMediaType } from "./conversation-CKNLYBJt.js";
|
|
15
|
+
import { E as acquireActiveLock, O as withLock, T as MUTATION_LOCK_TTL_MS, w as getStateAdapter } from "./profile-h-72wM78.js";
|
|
16
|
+
import { a as wasPendingAuthStopped, c as getThreadStopDecision, l as buildDeterministicAssistantMessageId, o as decideSubscribedThreadReply, r as clearPendingAuth, s as getSubscribedReplyPreflightDecision, u as buildDeterministicTurnId } from "./pending-auth-s_QFribU.js";
|
|
17
17
|
import { a as TurnInputDeferredError, c as isTurnInputCommitLostError, d as markTurnCompleted, f as markTurnFailed, i as TurnInputCommitLostError, l as isTurnInputDeferredError, n as ConversationTurnBoundaryError, o as getConversationTurnBoundaryError, p as startActiveTurn, r as CooperativeTurnYieldError, s as isCooperativeTurnYieldError, u as markTurnClosed } from "./oauth-authorization-BA4Dt6a7.js";
|
|
18
|
-
import { n as getAssistantReplyText } from "./assistant-reply-
|
|
19
|
-
import { A as
|
|
20
|
-
import { a as EVENT_SYSTEM_ACTOR, o as isEventConversationMessage } from "./prompt-
|
|
21
|
-
import { a as getVercelConversationWorkQueue, f as getTurnRequestDeadline } from "./job-queue-
|
|
22
|
-
import { E as stopConversationWork, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage, w as requestConversationWork } from "./store-
|
|
18
|
+
import { n as getAssistantReplyText } from "./assistant-reply-CbTPebzL.js";
|
|
19
|
+
import { A as maybePostAutomatedTurnLimitNotice, F as deliversFinalText, I as finishedRunReply, c as timerWatchCredentialSubject, i as skipInputBeforeConversationStop, j as recordFinishedTurnForAutomatedLimit, l as getEventCatalog, s as isEventMailboxMetadata, y as automationEventCatalog, z as runDispatchOutcome } from "./session-stop-CQjKd4a2.js";
|
|
20
|
+
import { a as EVENT_SYSTEM_ACTOR, o as isEventConversationMessage } from "./prompt-DyoEj9c2.js";
|
|
21
|
+
import { a as getVercelConversationWorkQueue, f as getTurnRequestDeadline } from "./job-queue-B6SV9uVa.js";
|
|
22
|
+
import { E as stopConversationWork, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage, w as requestConversationWork } from "./store-DXFIQy-G.js";
|
|
23
23
|
import { l as automationListQuerySchema } from "./automation-CHdlHVZP.js";
|
|
24
|
-
import { r as isExperimentalFeatureEnabled } from "./experimental-
|
|
24
|
+
import { r as isExperimentalFeatureEnabled } from "./experimental-CQIvMUO7.js";
|
|
25
25
|
import { c as sumUtcHoursIntoSixHours, m as healthReportSchema, t as webMessageId } from "./web-message-id-xPI_EFSC.js";
|
|
26
|
-
import { A as readAutomationRuns, C as readAutomationExecutionByConversationId, D as readAutomationExecutionStatusHours, E as readAutomationExecutionStatusDays, O as readAutomationExecutionSummaries, T as readAutomationExecutionHours, _ as markDispatchCompleted, a as confirmDispatchMailboxAppend, c as getDispatchIdForConversation, d as getDispatchTurnId, g as markDispatchBlocked, h as markDispatchAwaitingResume, i as claimDispatchMailboxAppend, k as readAutomationExecutions, l as getDispatchInputMessageId, n as scheduleSessionCompletedPluginTasks, p as isTerminalDispatchStatus, s as getDispatchConversationId, t as processPluginTask, u as getDispatchRecord, v as markDispatchFailed, w as readAutomationExecutionDays, x as emptyAutomationRunWindows, y as markDispatchRunning } from "./task-runner-
|
|
27
|
-
import { a as withAgentInvocationResultActors, c as resolveMailboxTurnWork, f as joinMailboxText, i as startAgentInvocationsForChildInput, l as sourceFromTurnInput, o as getAuthPausedConversationTurnId, s as getEventBatchDelayMs, t as enqueueAgentInvocationResult, u as turnInputFactsFromConversationMessage } from "./result-
|
|
28
|
-
import { n as getTurnLifecycle, t as ConversationTurnLifecycleService } from "./turn-lifecycle-
|
|
29
|
-
import { i as resolveAgentInvocationId, o as AgentRunError, s as executeTurn, t as createAgentInvocationWorker } from "./work-
|
|
30
|
-
import { a as persistThreadState, c as configValueSchema, i as persistThreadRuntimeState, n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState, t as getLocationConfigurationService } from "./thread-state-
|
|
31
|
-
import { c as deleteWebAuthorization, d as getPausedTurnRequest, m as getTurnAuthorization, p as wakePausedTurn, s as createWebAuthorization, u as createPausedTurns } from "./connections-
|
|
32
|
-
import { n as resolveTurnSessionRouting } from "./turn-session-routing-
|
|
33
|
-
import { t as bindMessageAgent } from "./message-
|
|
34
|
-
import { t as bindSpawnAgent } from "./spawn-
|
|
35
|
-
import { a as persistAuthPauseTurnState, c as getTurnUserSlackMessageTs, d as loadPendingMessageCards, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, n as getAgentTurnDiagnosticsAttributes, o as getTurnUserMessage, r as requireTurnFailureEventId, s as getTurnUserReplyAttachmentContext, t as finalizeFailedTurnReplyWithEvent, u as getInterruptionMarker } from "./turn-failure-response-
|
|
36
|
-
import { r as storeInputImages } from "./images-
|
|
26
|
+
import { A as readAutomationRuns, C as readAutomationExecutionByConversationId, D as readAutomationExecutionStatusHours, E as readAutomationExecutionStatusDays, O as readAutomationExecutionSummaries, T as readAutomationExecutionHours, _ as markDispatchCompleted, a as confirmDispatchMailboxAppend, c as getDispatchIdForConversation, d as getDispatchTurnId, g as markDispatchBlocked, h as markDispatchAwaitingResume, i as claimDispatchMailboxAppend, k as readAutomationExecutions, l as getDispatchInputMessageId, n as scheduleSessionCompletedPluginTasks, p as isTerminalDispatchStatus, s as getDispatchConversationId, t as processPluginTask, u as getDispatchRecord, v as markDispatchFailed, w as readAutomationExecutionDays, x as emptyAutomationRunWindows, y as markDispatchRunning } from "./task-runner-DUjvzYXj.js";
|
|
27
|
+
import { a as withAgentInvocationResultActors, c as resolveMailboxTurnWork, f as joinMailboxText, i as startAgentInvocationsForChildInput, l as sourceFromTurnInput, o as getAuthPausedConversationTurnId, s as getEventBatchDelayMs, t as enqueueAgentInvocationResult, u as turnInputFactsFromConversationMessage } from "./result-C883vngT.js";
|
|
28
|
+
import { n as getTurnLifecycle, t as ConversationTurnLifecycleService } from "./turn-lifecycle-CO-ylUmV.js";
|
|
29
|
+
import { i as resolveAgentInvocationId, o as AgentRunError, s as executeTurn, t as createAgentInvocationWorker } from "./work-nAfDSUFP.js";
|
|
30
|
+
import { a as persistThreadState, c as configValueSchema, i as persistThreadRuntimeState, n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState, t as getLocationConfigurationService } from "./thread-state-Ch4yuCqG.js";
|
|
31
|
+
import { c as deleteWebAuthorization, d as getPausedTurnRequest, m as getTurnAuthorization, p as wakePausedTurn, s as createWebAuthorization, u as createPausedTurns } from "./connections-ClYrKzpX.js";
|
|
32
|
+
import { n as resolveTurnSessionRouting } from "./turn-session-routing-B3LWooK5.js";
|
|
33
|
+
import { t as bindMessageAgent } from "./message-TUOdbSBW.js";
|
|
34
|
+
import { t as bindSpawnAgent } from "./spawn-DY9CLXDL.js";
|
|
35
|
+
import { a as persistAuthPauseTurnState, c as getTurnUserSlackMessageTs, d as loadPendingMessageCards, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, n as getAgentTurnDiagnosticsAttributes, o as getTurnUserMessage, r as requireTurnFailureEventId, s as getTurnUserReplyAttachmentContext, t as finalizeFailedTurnReplyWithEvent, u as getInterruptionMarker } from "./turn-failure-response-C5nBKC4S.js";
|
|
36
|
+
import { r as storeInputImages } from "./images-BN_BiBXF.js";
|
|
37
37
|
import { z } from "zod";
|
|
38
38
|
import { createHash } from "node:crypto";
|
|
39
39
|
import { and, asc, count, desc, eq, exists, inArray, ne, or, sql } from "drizzle-orm";
|
|
@@ -498,6 +498,47 @@ function renderSlackObjectCard(card, conversationId, surface = "preview") {
|
|
|
498
498
|
};
|
|
499
499
|
}
|
|
500
500
|
//#endregion
|
|
501
|
+
//#region src/chat/slack/adapter-context.ts
|
|
502
|
+
const initializedAdapters = /* @__PURE__ */ new WeakSet();
|
|
503
|
+
async function getConnectedState$1(stateAdapter) {
|
|
504
|
+
const state = stateAdapter ?? getStateAdapter();
|
|
505
|
+
await state.connect();
|
|
506
|
+
return state;
|
|
507
|
+
}
|
|
508
|
+
/** Initialize the Slack adapter against the repository state adapter. */
|
|
509
|
+
async function ensureSlackAdapterInitialized(args) {
|
|
510
|
+
if (initializedAdapters.has(args.adapter)) return;
|
|
511
|
+
const state = await getConnectedState$1(args.state);
|
|
512
|
+
await args.adapter.initialize({ getState: () => state });
|
|
513
|
+
if (args.adapter.defaultBotTokenProvider && !args.adapter.botUserId) throw new Error("Slack adapter initialized without a resolved bot user id");
|
|
514
|
+
initializedAdapters.add(args.adapter);
|
|
515
|
+
}
|
|
516
|
+
/** Verify a Slack request using the adapter's configured signing secret. */
|
|
517
|
+
function verifySlackSignature(args) {
|
|
518
|
+
const verifySignature = args.adapter.verifySignature;
|
|
519
|
+
if (!verifySignature) throw new Error("Slack adapter does not expose signature verification");
|
|
520
|
+
return verifySignature.call(args.adapter, args.body, args.request.headers.get("x-slack-request-timestamp"), args.request.headers.get("x-slack-signature"));
|
|
521
|
+
}
|
|
522
|
+
/** Run Slack work with the installation token that matches the inbound event. */
|
|
523
|
+
async function runWithSlackInstallation(args) {
|
|
524
|
+
await ensureSlackAdapterInitialized({
|
|
525
|
+
adapter: args.adapter,
|
|
526
|
+
state: args.state
|
|
527
|
+
});
|
|
528
|
+
const internals = args.adapter;
|
|
529
|
+
if (internals.defaultBotTokenProvider) return await args.task();
|
|
530
|
+
const installationId = args.installation.isEnterpriseInstall ? args.installation.enterpriseId : args.installation.teamId;
|
|
531
|
+
if (!installationId) throw new Error("Slack installation context is missing team id");
|
|
532
|
+
if (!internals.resolveTokenForTeam || !internals.requestContext) throw new Error("Slack adapter cannot resolve workspace installations");
|
|
533
|
+
const tokenContext = await internals.resolveTokenForTeam.call(args.adapter, installationId, args.installation.isEnterpriseInstall);
|
|
534
|
+
if (!tokenContext) throw new Error(`Slack installation token was not found for ${installationId}`);
|
|
535
|
+
return await internals.requestContext.run({
|
|
536
|
+
...tokenContext,
|
|
537
|
+
enterpriseId: args.installation.enterpriseId,
|
|
538
|
+
isEnterpriseInstall: args.installation.isEnterpriseInstall
|
|
539
|
+
}, () => runWithSlackInstallationToken(tokenContext.token, args.task));
|
|
540
|
+
}
|
|
541
|
+
//#endregion
|
|
501
542
|
//#region src/chat/slack/errors.ts
|
|
502
543
|
/** Extract Slack's stable API error code from Web API errors. */
|
|
503
544
|
function getSlackApiErrorCode(error) {
|
|
@@ -1728,47 +1769,6 @@ async function subscribeSlackThreadForMessage(args) {
|
|
|
1728
1769
|
return result.value;
|
|
1729
1770
|
}
|
|
1730
1771
|
//#endregion
|
|
1731
|
-
//#region src/chat/slack/adapter-context.ts
|
|
1732
|
-
const initializedAdapters = /* @__PURE__ */ new WeakSet();
|
|
1733
|
-
async function getConnectedState$1(stateAdapter) {
|
|
1734
|
-
const state = stateAdapter ?? getStateAdapter();
|
|
1735
|
-
await state.connect();
|
|
1736
|
-
return state;
|
|
1737
|
-
}
|
|
1738
|
-
/** Initialize the Slack adapter against the repository state adapter. */
|
|
1739
|
-
async function ensureSlackAdapterInitialized(args) {
|
|
1740
|
-
if (initializedAdapters.has(args.adapter)) return;
|
|
1741
|
-
const state = await getConnectedState$1(args.state);
|
|
1742
|
-
await args.adapter.initialize({ getState: () => state });
|
|
1743
|
-
if (args.adapter.defaultBotTokenProvider && !args.adapter.botUserId) throw new Error("Slack adapter initialized without a resolved bot user id");
|
|
1744
|
-
initializedAdapters.add(args.adapter);
|
|
1745
|
-
}
|
|
1746
|
-
/** Verify a Slack request using the adapter's configured signing secret. */
|
|
1747
|
-
function verifySlackSignature(args) {
|
|
1748
|
-
const verifySignature = args.adapter.verifySignature;
|
|
1749
|
-
if (!verifySignature) throw new Error("Slack adapter does not expose signature verification");
|
|
1750
|
-
return verifySignature.call(args.adapter, args.body, args.request.headers.get("x-slack-request-timestamp"), args.request.headers.get("x-slack-signature"));
|
|
1751
|
-
}
|
|
1752
|
-
/** Run Slack work with the installation token that matches the inbound event. */
|
|
1753
|
-
async function runWithSlackInstallation(args) {
|
|
1754
|
-
await ensureSlackAdapterInitialized({
|
|
1755
|
-
adapter: args.adapter,
|
|
1756
|
-
state: args.state
|
|
1757
|
-
});
|
|
1758
|
-
const internals = args.adapter;
|
|
1759
|
-
if (internals.defaultBotTokenProvider) return await args.task();
|
|
1760
|
-
const installationId = args.installation.isEnterpriseInstall ? args.installation.enterpriseId : args.installation.teamId;
|
|
1761
|
-
if (!installationId) throw new Error("Slack installation context is missing team id");
|
|
1762
|
-
if (!internals.resolveTokenForTeam || !internals.requestContext) throw new Error("Slack adapter cannot resolve workspace installations");
|
|
1763
|
-
const tokenContext = await internals.resolveTokenForTeam.call(args.adapter, installationId, args.installation.isEnterpriseInstall);
|
|
1764
|
-
if (!tokenContext) throw new Error(`Slack installation token was not found for ${installationId}`);
|
|
1765
|
-
return await internals.requestContext.run({
|
|
1766
|
-
...tokenContext,
|
|
1767
|
-
enterpriseId: args.installation.enterpriseId,
|
|
1768
|
-
isEnterpriseInstall: args.installation.isEnterpriseInstall
|
|
1769
|
-
}, () => runWithSlackInstallationToken(tokenContext.token, args.task));
|
|
1770
|
-
}
|
|
1771
|
-
//#endregion
|
|
1772
1772
|
//#region src/chat/task-execution/slack-work.ts
|
|
1773
1773
|
const slackConversationRouteSchema = z.enum(["mention", "subscribed"]);
|
|
1774
1774
|
function hasSteeringOverride(text) {
|
|
@@ -5598,12 +5598,10 @@ function createReadOnlyConfigService(rawValues) {
|
|
|
5598
5598
|
};
|
|
5599
5599
|
}
|
|
5600
5600
|
function getResumeLogContext(args) {
|
|
5601
|
-
const actor = args.run?.actor;
|
|
5602
5601
|
return {
|
|
5603
5602
|
conversationId: args.conversationId,
|
|
5604
5603
|
messageConversationId: args.conversationId,
|
|
5605
|
-
|
|
5606
|
-
userName: isUserActor(actor) ? actor.userName : void 0,
|
|
5604
|
+
...actorLogContext(args.run?.actor, args.run?.credentialContext),
|
|
5607
5605
|
destinationName: args.channelId,
|
|
5608
5606
|
assistantUserName: botConfig.userName,
|
|
5609
5607
|
modelId: defaultModelId(botConfig)
|
|
@@ -7376,4 +7374,4 @@ async function appendAndEnqueueWebMessage(input, options) {
|
|
|
7376
7374
|
};
|
|
7377
7375
|
}
|
|
7378
7376
|
//#endregion
|
|
7379
|
-
export {
|
|
7377
|
+
export { THREAD_OPTOUT_ACK as A, readHealthReport as B, buildSlackInboundMessage as C, normalizeIncomingSlackThreadId as D, stopSlackThread as E, renderSlackObjectCard as F, createVercelAttachmentStorage as I, AGENT_DISPATCH_MAX_AGE_MS as L, parseContent as M, runWithSlackInstallation as N, withNormalizedThreadId as O, verifySlackSignature as P, enqueueAgentDispatch as R, recordSkippedConversationMessage as S, isSlackMessageStopped as T, readViewerAutomationRuns as _, recordWebConversationActivity as a, readViewerAutomations as b, createProductionSlackWebhookServices as c, resolveSlackConversationContextFromThreadId as d, createSlackWebApiStatusSender as f, readViewerAutomationExecutions as g, readConversationSourceTask as h, createConversationId as i, startProcessingReaction as j, stopConversationTurn as k, getProductionSlackAdapter as l, deleteViewerTask as m, conversationTurnIdForMessage as n, webActorFromEmail as o, ViewerTaskNotFoundError as p, createAndEnqueueConversation as r, createProductionConversationWorkOptions as s, appendAndEnqueueWebMessage as t, formatSlackConversationRedactedLabel as u, readViewerAutomationSummary as v, clearSlackPendingReactions as w, resolveViewerTaskCandidate as x, readViewerAutomationVersions as y, GET as z };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import { $ as getAgentInvocation,
|
|
3
|
-
import { n as botConfig } from "./config-
|
|
4
|
-
import {
|
|
2
|
+
import { $ as getAgentInvocation, Bt as withoutSavedSteeringMessages, G as recordSubagentStarted, Gt as readBlockedReport, H as stopChildAgentsOf, J as createAgentInvocation, Q as getActiveAgentInvocationForConversation, W as recordSubagentEnded, Wt as AuthorizationFlowDisabledError, at as getAgentInvocationTurnId, ct as isTerminalAgentInvocation, dt as markAgentInvocationMailboxAppended, gt as reportReplacedAgentInvocation, ht as markAgentInvocationSteered, m as PluginCredentialFailureError, mt as markAgentInvocationRunning, pt as markAgentInvocationPaused, q as completeAgentInvocation, rt as getAgentInvocationMessageId, st as getLatestAgentInvocationForConversation, zt as buildSteeringPiMessage } from "./agent-runner-D7OboVb3.js";
|
|
3
|
+
import { n as botConfig } from "./config-CJRnWK9H.js";
|
|
4
|
+
import { d as getConversationStore, l as getConversationEventStore } from "./viewer-DSZXygMU.js";
|
|
5
5
|
import { m as sameActorIdentity, u as agentInstructionProvenance } from "./history-9pO1Zd4Y.js";
|
|
6
|
-
import {
|
|
6
|
+
import { J as abandonTurnRecord, Mt as openConversationProjection, X as failTurnRecord, Z as getTurnRecord, q as saveTurnCheckpoint, st as isTurnExecutionLimitExceededError, ut as getTerminalAssistantMessages } from "./tasks-D_WIJtvO.js";
|
|
7
7
|
import { c as isTurnInputCommitLostError, i as TurnInputCommitLostError, o as getConversationTurnBoundaryError } from "./oauth-authorization-BA4Dt6a7.js";
|
|
8
|
-
import { n as getAssistantReplyText } from "./assistant-reply-
|
|
9
|
-
import { A as
|
|
10
|
-
import { r as appendAndEnqueueInboundMessage } from "./store-
|
|
11
|
-
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-
|
|
12
|
-
import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-
|
|
8
|
+
import { n as getAssistantReplyText } from "./assistant-reply-CbTPebzL.js";
|
|
9
|
+
import { A as maybePostAutomatedTurnLimitNotice, M as resetAutomatedTurnLimit, j as recordFinishedTurnForAutomatedLimit } from "./session-stop-CQjKd4a2.js";
|
|
10
|
+
import { r as appendAndEnqueueInboundMessage } from "./store-DXFIQy-G.js";
|
|
11
|
+
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-CO-ylUmV.js";
|
|
12
|
+
import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-Ch4yuCqG.js";
|
|
13
13
|
import { isDeepStrictEqual } from "node:util";
|
|
14
14
|
import { z } from "zod";
|
|
15
15
|
//#region src/chat/runtime/turn-execution.ts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import { v as isProviderRetryError } from "./client-
|
|
3
|
-
import {
|
|
4
|
-
import { i as getChatConfig } from "./config-
|
|
5
|
-
import { f as getTurnRequestDeadline, m as ConversationQueueMessageRejectedError } from "./job-queue-
|
|
6
|
-
import { C as requestAnotherSlice, M as isInvalidConversationRecordError, T as startConversationWork, b as recordConversationRetry, d as countPendingConversationMessages, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, j as isFinalAttempt, k as hasConversationStop, l as completeConversationStop, m as ensureConversationWake, o as checkInConversationWork, p as drainConversationMailbox, s as clearConsumedConversationWake, t as ackMessages, u as completeConversationWork, x as releaseConversationWork, y as recordAttemptFailure } from "./store-
|
|
2
|
+
import { v as isProviderRetryError } from "./client-D8HnkOQX.js";
|
|
3
|
+
import { f as logException, m as logWarn, p as logInfo, w as withLogContext } from "./logging-CWxiIuCF.js";
|
|
4
|
+
import { i as getChatConfig } from "./config-CJRnWK9H.js";
|
|
5
|
+
import { f as getTurnRequestDeadline, m as ConversationQueueMessageRejectedError } from "./job-queue-B6SV9uVa.js";
|
|
6
|
+
import { C as requestAnotherSlice, M as isInvalidConversationRecordError, T as startConversationWork, b as recordConversationRetry, d as countPendingConversationMessages, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, j as isFinalAttempt, k as hasConversationStop, l as completeConversationStop, m as ensureConversationWake, o as checkInConversationWork, p as drainConversationMailbox, s as clearConsumedConversationWake, t as ackMessages, u as completeConversationWork, x as releaseConversationWork, y as recordAttemptFailure } from "./store-DXFIQy-G.js";
|
|
7
7
|
//#region src/chat/task-execution/worker.ts
|
|
8
8
|
var worker_exports = /* @__PURE__ */ __exportAll({
|
|
9
9
|
CONVERSATION_WORK_DEFER_DELAY_MS: () => CONVERSATION_WORK_DEFER_DELAY_MS,
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
ALTER TABLE "junior_automation_runs" ADD COLUMN "automation_version" integer;--> statement-breakpoint
|
|
2
|
+
ALTER TABLE "junior_automation_runs" ADD CONSTRAINT "junior_automation_runs_automation_version_fk" FOREIGN KEY ("automation_id","automation_version") REFERENCES "public"."junior_automation_versions"("automation_id","version") ON DELETE no action ON UPDATE no action;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "junior_identities" ADD COLUMN "signed_in_at" timestamp with time zone;
|