@sentry/junior 0.301.0 → 0.303.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter-context-BdVnSuY5.js +43 -0
- package/dist/{admin-CRJHvCGg.js → admin-AfeAdS3J.js} +2 -2
- package/dist/{agent-runner-H4YhvNBj.js → agent-runner-BP8_DLUv.js} +4688 -13870
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +7 -8
- package/dist/api.d.ts +13 -12
- package/dist/api.js +268 -118
- package/dist/{app-HDZglaIu.d.ts → app-Dd9v1mNx.d.ts} +15 -15
- package/dist/app.d.ts +1 -1
- package/dist/app.js +99 -330
- package/dist/{automation-Cva5ZOwW.js → automation-D9MvhOWY.js} +3 -1
- package/dist/{background-compaction-queue-CNrZ3QcU.js → background-compaction-queue-xaE05jxH.js} +97 -206
- package/dist/{briefs-x6Mzwxmg.js → briefs-D8i-dKTp.js} +4 -4
- package/dist/{catalog-runtime-BEY6EGRi.js → catalog-runtime-d1EM6Z0V.js} +2 -2
- package/dist/cli/chat.d.ts +1 -1
- package/dist/cli/chat.js +21 -21
- package/dist/cli/check.js +8 -8
- package/dist/cli/env.d.ts +1 -0
- package/dist/cli/env.js +8 -7
- package/dist/cli/init.js +13 -4
- package/dist/cli/main.js +4 -4
- package/dist/cli/plugins.js +6 -6
- package/dist/cli/snapshot-create.js +7 -5
- package/dist/cli/upgrade.d.ts +2 -2
- package/dist/cli/upgrade.js +5 -5
- package/dist/{config-CmjhyqgB.js → config-oGM7KA9M.js} +44 -63
- package/dist/{connections-CfIRm0xv.js → connections-BlikzEJv.js} +6 -6
- package/dist/{continue-in-slack-DPoABVkB.js → continue-in-slack-BZnYifiG.js} +5 -6
- package/dist/{conversation-BNXfq6Lb.js → conversation-CY1jnBiC.js} +1 -1
- package/dist/{conversation-feed-CfpyFMHP.js → conversation-feed-BZJRk6UV.js} +2 -1
- package/dist/{conversation-privacy-0CM0V2qK.js → conversation-privacy-Cx515ddM.js} +7 -7
- package/dist/{conversation-turn-C0sxyvS-.js → conversation-turn-DAhRdX4m.js} +20 -24
- package/dist/{credential-sync-tEMKZ_8M.js → credential-sync-DfhmWFeo.js} +18 -20
- package/dist/{db-Czra10QW.js → db-C-2tFxk3.js} +326 -17
- package/dist/{db-BdUHQhrC.d.ts → db-DPqcEM9_.d.ts} +25 -25
- package/dist/{executor-D_023K0H.js → executor-NVfS8aQ2.js} +51 -10
- package/dist/{history-IjdmO_r6.js → history-UZ3M2M9r.js} +13 -10
- package/dist/install-CHLrpRZc.js +228 -0
- package/dist/instrumentation.d.ts +4 -4
- package/dist/instrumentation.js +10 -10
- package/dist/{lineage-DmMIE0VL.js → lineage-HGLhd_-N.js} +2 -2
- package/dist/{logging-DcjLDDqi.js → logging-DiyqRLBx.js} +24 -20
- package/dist/{message-C0JY9RJP.js → message-CkCOcbFH.js} +9 -9
- package/dist/{model-input-CBp-p24N.js → model-input-DmoPPtPE.js} +5 -10
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +7 -6
- package/dist/{oauth-callback-server-BRq9QNhU.js → oauth-callback-server-CIf_6YmA.js} +5 -4
- package/dist/{oauth-relay-DRzq73b6.js → oauth-relay-DAmfVmJu.js} +3 -6
- package/dist/{package-discovery-DJhGdS4c.js → package-discovery-x4AvVhMj.js} +1 -1
- package/dist/{plugin-module-Cf5gVPWP.js → plugin-module-Cv2ETe8Y.js} +1 -1
- package/dist/{plugins-BBX07Jzt.js → plugins-Bkk0XRo2.js} +3 -3
- package/dist/{projection-CQNDOi82.js → projection-DBq8tsA5.js} +489 -223
- package/dist/{prompt-DLUB5m72.js → prompt-D2KlJopL.js} +15 -5
- package/dist/{queue-CZyYgPF0.d.ts → queue-CbEHUO0l.d.ts} +1 -1
- package/dist/queue-DFaOscp5.js +115 -0
- package/dist/{registry-Dj377ADs.js → registry-Bu0Z9BEO.js} +37 -37
- package/dist/{resolve-DJkh9Fky.js → resolve-DXuA3G0g.js} +4 -229
- package/dist/{result-C8iIpDl1.js → result-DpiNseDA.js} +11 -16
- package/dist/rolldown-runtime-BKpuH2hG.js +26 -0
- package/dist/{runner-DZqrOy8C.js → runner-iu1heRFv.js} +10 -10
- package/dist/{sandbox-egress-signals-CGwH86S9.js → sandbox-egress-signals-2HFYDcQf.js} +1 -1
- package/dist/{schema-CdZFn7Qd.d.ts → schema-DHMOaRzC.d.ts} +959 -41
- package/dist/{schema-DyHXiQKI.js → schema-DvfX3Gq_.js} +141 -40
- package/dist/{secrets-DebYU866.js → secrets-DHaJ5TTn.js} +4 -4
- package/dist/{sentry-BRTJqumy.js → sentry-CPbZjomA.js} +3 -28
- package/dist/{sentry-route-name-BhwWnfqj.js → sentry-route-name-C6EIzAGP.js} +1 -1
- package/dist/{service-account-suY004dx.js → service-account-BcT5LR7V.js} +271 -20
- package/dist/{service-account-D6jGR4a1.js → service-account-xYkaQTrw.js} +3 -3
- package/dist/{session-stop-BLmfFI3d.js → session-stop-BLLp1IP_.js} +1098 -1110
- package/dist/{skills-CmNG0dHb.js → skills-CNAGH4ju.js} +6 -9
- package/dist/{slack-conversation-unfurl-Bty-DlHe.js → slack-conversation-unfurl-DYnqe5ci.js} +10 -14
- package/dist/{spawn-CNjkpXpk.js → spawn-cGasWW33.js} +7 -7
- package/dist/{state-CEbZuZD6.js → state-CDS6h_Wv.js} +34 -5
- package/dist/{stop-Bjy2-K4H.js → stop-DMMA67yT.js} +896 -196
- package/dist/{store-DmV4CoNr.js → store-Dgs7Oe44.js} +5 -5
- package/dist/{task-queue-AhG1tSXR.js → task-queue-DcF0nhhz.js} +3 -3
- package/dist/{task-runner-BMxZI3o7.js → task-runner-BGXF7Fo7.js} +15 -20
- package/dist/{thread-context-CXLnbg7g.js → thread-context-BPky1KBe.js} +12 -12
- package/dist/{store-Epv6t4vV.js → turn-session-routing-DGvn9MSl.js} +384 -13
- package/dist/{turn-user-message-DsUZi9gn.js → turn-user-message-19CkuUvM.js} +3 -3
- package/dist/{validation-DOz8X9BU.js → validation-lu1DgjNQ.js} +2 -2
- package/dist/vercel.js +1 -1
- package/dist/{version-CGMRmMPK.js → version-Uo3c94Dx.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-H3EsMWtJ.js → viewer-BPQHMx3-.js} +3 -3
- package/dist/warmup-H8uLvW9e.js +13946 -0
- package/dist/{statuses-Hn-HsOph.js → web-message-id-lNodcCOI.js} +136 -1
- package/dist/{worker-ClphajjD.js → worker-B-pM_-3K.js} +9 -12
- package/migrations/0108_conversation_embeddings.sql +13 -0
- package/migrations/0109_user_preferences.sql +1 -0
- package/migrations/0110_code_change_repository_state_index.sql +1 -0
- package/migrations/meta/0108_snapshot.json +4688 -0
- package/migrations/meta/0109_snapshot.json +4925 -0
- package/migrations/meta/0110_snapshot.json +4952 -0
- package/migrations/meta/_journal.json +22 -1
- package/package.json +16 -17
- package/dist/adapter-CNjGEJO9.js +0 -303
- package/dist/reporting-window-DopzcOHh.js +0 -137
- package/dist/turn-session-routing-BD3-jJl7.js +0 -380
- package/dist/users-BxvYclQg.js +0 -424
- package/dist/warmup-CdU5hR49.js +0 -3715
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { d as contextProvenance, f as instructionActors, n as agentHistoryItemSchema, p as instructionProvenanceFor } from "./history-IjdmO_r6.js";
|
|
9
|
-
import { a as setStateValues, c as fenceLock, i as getStateValues, l as withLock, n as getDefaultRedisStateAdapterFor, o as MUTATION_LOCK_TTL_MS, r as getStateAdapter, s as acquireActiveLock } from "./adapter-CNjGEJO9.js";
|
|
10
|
-
import { _ as CredentialUnavailableError, a as resolveAuthTokenPlaceholder, f as credentialContextForActor, g as credentialUserSubjectId, h as credentialSubjectSchema, m as credentialLogContext, o as resolvePluginCommandEnv, p as credentialContextSchema } from "./registry-Dj377ADs.js";
|
|
11
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-BEY6EGRi.js";
|
|
12
|
-
import { d as JUNIOR_NATIVE_EVENT_NAMESPACE, f as agentsInstructionsUpdatedEvent, g as renderJuniorNativeConversationEvent, l as completeObject$1, m as authenticationUnlinkedEvent, n as briefEntriesFromReportEvents, o as isEventConversationMessage, p as authenticationLinkedEvent, s as generateBrief, t as BRIEF_PROMPT, u as completeText } from "./prompt-DLUB5m72.js";
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
|
|
2
|
+
import { d as contextProvenance, f as instructionActors, n as agentHistoryItemSchema, p as instructionProvenanceFor } from "./history-UZ3M2M9r.js";
|
|
3
|
+
import { _ as renderJuniorNativeConversationEvent, d as embedTexts, f as JUNIOR_NATIVE_EVENT_NAMESPACE, h as authenticationUnlinkedEvent, l as completeObject, m as authenticationLinkedEvent, n as briefEntriesFromReportEvents, o as isEventConversationMessage, p as agentsInstructionsUpdatedEvent, s as generateBrief, t as BRIEF_PROMPT, u as completeText } from "./prompt-D2KlJopL.js";
|
|
4
|
+
import { $ as fenceLock, C as isPersonInput, G as createCache, J as getStateAdapter, P as resolveActorIdentityId, Q as acquireActiveLock, V as saveUserTimezone, X as setStateValues, Y as getStateValues, Z as MUTATION_LOCK_TTL_MS, _t as sameDestination, a as getConversationStore, b as createSqlStore, c as hasAnnotationKey, ct as hasAgentTurnUsage, d as eventFromRow, dt as conversationDetailTouch, et as withLock, f as withConversationEventLock, ht as parseDestination, it as addAgentTurnUsage, j as startLocationThread, l as treeHasAnnotationKey, o as getDb, q as getDefaultRedisStateAdapterFor, r as getConversationEventStore, s as getSqlExecutor, tt as claimProviderConversation, u as createSqlConversationEventStore, z as readUserTimezone } from "./db-C-2tFxk3.js";
|
|
5
|
+
import { D as juniorConversationAnnotations, F as juniorDestinations, M as juniorConversations, N as juniorIdentities, O as juniorCodeChanges, P as juniorUsers, T as juniorConversationEvents, a as juniorPushSubscriptions, b as juniorConversationEmbeddings, f as juniorAutomations, i as juniorWorkspaces, j as juniorAttachments, k as juniorCodeRepositories, l as juniorReviewItems, m as juniorLocationConfigurations, n as juniorSnapshots, o as juniorReviewItemAssignees, r as juniorWorkspaceRepos, s as juniorReviewItemConversations, v as juniorConversationParticipants, x as juniorConversationBriefs } from "./executor-NVfS8aQ2.js";
|
|
6
|
+
import { E as withSpan, J as toOptionalString, K as isRecord$2, _ as runBestEffort, a as extractGenAiUsageSummary, b as setSpanAttributes, c as getLogContextAttributes, d as logAudit, h as logWarn, m as logInfo, o as getActiveTraceContext, p as logException, q as toOptionalNumber, t as buildTurnFailureResponse, x as setSpanStatus, y as setSentryUser } from "./logging-DiyqRLBx.js";
|
|
7
|
+
import { _ as CredentialUnavailableError, a as resolveAuthTokenPlaceholder, f as credentialContextForActor, g as credentialUserSubjectId, h as credentialSubjectSchema, m as credentialLogContext, o as resolvePluginCommandEnv, p as credentialContextSchema } from "./registry-Bu0Z9BEO.js";
|
|
13
8
|
import { n as isWithinNotificationSchedule, r as notificationScheduleSchema, s as isValidTimeZone, t as DEFAULT_NOTIFICATION_SCHEDULE } from "./schedule-cP0AACm1.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
9
|
+
import { C as completeObject$1, D as resolveGatewayModel, E as rerankTexts, L as unwrapCurrentInstruction, Q as toOptionalTrimmed, R as escapeXml, S as completeDecision, T as embedTexts$1, b as GEN_AI_PROVIDER_NAME, i as getChatConfig, j as estimateTextTokens, n as botConfig, o as getSlackBotToken, y as normalizeSlackEmojiName } from "./config-oGM7KA9M.js";
|
|
10
|
+
import { c as parseStoredSlackActor, d as parseSlackChannelReferenceId, f as parseSlackTeamId, i as isActorUserId, l as toStoredSlackActor, p as parseSlackUserId, s as parseActorUserId, v as parseSlackMessageTs } from "./actor-D2iXzvlN.js";
|
|
11
|
+
import { i as readActorIdentity, l as resolveViewerUser, n as findUserByEmailFromSql, o as readIdentityById, p as parseAvatarUrl, s as readIdentityByIdFromSql } from "./viewer-BPQHMx3-.js";
|
|
12
|
+
import { $ as briefResourceLabel, B as messageCardRef, H as readMessageCardRefs, R as reviewItemChangeRecordSchema, Y as readMessageAttachments, _ as conversationReportEventSchema, et as conversationBriefSchema, nt as parseStoredBrief, tt as parseBriefInput, v as conversationReportMessageEventSchema } from "./conversation-CY1jnBiC.js";
|
|
13
|
+
import { a as getClient$1, h as startSpan, n as captureMessage, r as continueTrace } from "./sentry-CPbZjomA.js";
|
|
14
|
+
import { t as canExposeConversationPayload } from "./conversation-privacy-Cx515ddM.js";
|
|
15
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-d1EM6Z0V.js";
|
|
16
16
|
import { n as redactSandboxEgressProxyPath, t as SANDBOX_EGRESS_PROXY_PATH } from "./proxy-path-BHYoKZdq.js";
|
|
17
|
-
import { n as readEncryptedState, t as createEncryptedState } from "./state-
|
|
18
|
-
import { i as readWebPushPrivateKey, t as readJuniorSecret } from "./secrets-
|
|
17
|
+
import { n as readEncryptedState, r as findLegacyWebActorUserId, t as createEncryptedState } from "./state-CDS6h_Wv.js";
|
|
18
|
+
import { i as readWebPushPrivateKey, t as readJuniorSecret } from "./secrets-DHaJ5TTn.js";
|
|
19
19
|
import * as z from "zod";
|
|
20
20
|
import path from "node:path";
|
|
21
21
|
import { isDeepStrictEqual } from "node:util";
|
|
22
22
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
23
23
|
import { createHash, createHmac, createPrivateKey, createPublicKey, generateKeyPairSync, randomBytes, randomUUID, sign, timingSafeEqual } from "node:crypto";
|
|
24
|
-
import { and, arrayContains, asc, count, desc, eq, exists, getTableColumns, gt, gte, ilike, inArray, isNotNull, isNull, lt, lte, max, ne, not, notLike, or, sql } from "drizzle-orm";
|
|
24
|
+
import { and, arrayContains, asc, count, desc, eq, exists, getTableColumns, gt, gte, ilike, inArray, isNotNull, isNull, lt, lte, max, ne, not, notExists, notLike, or, sql } from "drizzle-orm";
|
|
25
25
|
import { EgressAuthRequired, EgressPolicyDenied, PluginToolInputError, actorSchema, codeChangeInputSchema, conversationAnnotationInputSchema, defineConversationEvent, destinationSchema, eventDataSchema, eventInputSchema, eventMatchSchema, eventMatches, eventTypeSchema, isPluginModelCostEventName, missingToolAnnotationKeys, normalizeEventIdentifier, objectAnnotationSchema, objectIconPath, objectLinkFilterSchema, objectTypeSchema, pluginAuditAttributesSchema, pluginAuthorizationSchema, pluginCredentialHeaderTransformSchema, pluginCredentialResultSchema, pluginEventsSchema, pluginGrantSchema, pluginModelCostEventNames, pluginProviderAccountSchema, pluginStoredTokensSchema, pluginToolReplySchema, promptContextSchema, promptMessageSchema, sourceSchema, stableEventMatchKey } from "@sentry/junior-plugin-api";
|
|
26
26
|
import { alias } from "drizzle-orm/pg-core";
|
|
27
27
|
import fs from "node:fs/promises";
|
|
@@ -213,27 +213,27 @@ function validateConfigValue(value) {
|
|
|
213
213
|
// src/chat/configuration/service.ts
|
|
214
214
|
function sanitizeEntry(value) {
|
|
215
215
|
if (!isRecord$2(value)) return;
|
|
216
|
-
const key = toOptionalString(value
|
|
216
|
+
const key = toOptionalString(value["key"]);
|
|
217
217
|
if (!key || validateConfigKey(key)) return;
|
|
218
|
-
const updatedAt = toOptionalString(value
|
|
218
|
+
const updatedAt = toOptionalString(value["updatedAt"]);
|
|
219
219
|
if (!updatedAt) return;
|
|
220
|
-
if (value
|
|
221
|
-
const parsedValue = configValueSchema.safeParse(value
|
|
220
|
+
if (value["scope"] !== "channel" && value["scope"] !== "conversation" && value["scope"] !== "location") return;
|
|
221
|
+
const parsedValue = configValueSchema.safeParse(value["value"]);
|
|
222
222
|
if (!parsedValue.success) return;
|
|
223
223
|
return {
|
|
224
224
|
key,
|
|
225
225
|
value: parsedValue.data,
|
|
226
226
|
scope: "location",
|
|
227
227
|
updatedAt,
|
|
228
|
-
updatedBy: toOptionalString(value
|
|
229
|
-
source: toOptionalString(value
|
|
230
|
-
expiresAt: toOptionalString(value
|
|
228
|
+
updatedBy: toOptionalString(value["updatedBy"]),
|
|
229
|
+
source: toOptionalString(value["source"]),
|
|
230
|
+
expiresAt: toOptionalString(value["expiresAt"])
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
233
|
/** Coerce legacy persisted configuration into current Location entries. */
|
|
234
234
|
function coerceLegacyLocationConfig(raw) {
|
|
235
|
-
const rawConfig = isRecord$2(raw) && isRecord$2(raw
|
|
236
|
-
const rawEntries = isRecord$2(rawConfig
|
|
235
|
+
const rawConfig = isRecord$2(raw) && isRecord$2(raw["configuration"]) ? raw["configuration"] : {};
|
|
236
|
+
const rawEntries = isRecord$2(rawConfig["entries"]) ? rawConfig["entries"] : {};
|
|
237
237
|
return Object.values(rawEntries).flatMap((value) => {
|
|
238
238
|
const entry = sanitizeEntry(value);
|
|
239
239
|
return entry ? [entry] : [];
|
|
@@ -715,7 +715,7 @@ async function replaceSlackMentions(value, provider) {
|
|
|
715
715
|
});
|
|
716
716
|
const matches = [...tokens.values()].flat();
|
|
717
717
|
if (matches.length === 0) return value;
|
|
718
|
-
const people = await readSlackPeople([...new Set(matches.flatMap((match) => match.groups?.user ?? []))], provider);
|
|
718
|
+
const people = await readSlackPeople([...new Set(matches.flatMap((match) => match.groups?.["user"] ?? []))], provider);
|
|
719
719
|
return mapStrings(value, (text) => {
|
|
720
720
|
let result = "";
|
|
721
721
|
let cursor = 0;
|
|
@@ -853,7 +853,7 @@ async function lookupSlackUserNames(teamId, userIds) {
|
|
|
853
853
|
const DEFAULT_TIMEZONE = "America/Los_Angeles";
|
|
854
854
|
/** The install timezone, used when Junior does not know a person's timezone. */
|
|
855
855
|
function defaultTimezone() {
|
|
856
|
-
return process.env
|
|
856
|
+
return process.env["JUNIOR_TIMEZONE"]?.trim() || DEFAULT_TIMEZONE;
|
|
857
857
|
}
|
|
858
858
|
/**
|
|
859
859
|
* Pick a person's timezone: their Slack profile, then the saved user
|
|
@@ -975,23 +975,231 @@ async function saveObjectAnnotations(conversationId, plugin, value) {
|
|
|
975
975
|
plugin
|
|
976
976
|
}));
|
|
977
977
|
}
|
|
978
|
-
/**
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
978
|
+
/**
|
|
979
|
+
* Save annotations from a successful plugin tool result and attach their cards.
|
|
980
|
+
* An Annotation marks work that the Conversation did, so a read-only tool must
|
|
981
|
+
* not return one: looking up an object does not link it.
|
|
982
|
+
*/
|
|
983
|
+
async function annotateToolResult(conversationId, plugin, result, options) {
|
|
984
|
+
if (!isRecord$2(result) || result["isError"] === true) return result;
|
|
985
|
+
const details = isRecord$2(result["details"]) ? result["details"] : result;
|
|
986
|
+
if (details["timed_out"] === true || details["isError"] === true || !Array.isArray(details["objectAnnotations"])) return result;
|
|
987
|
+
if (options.readOnly) throw new Error(`Read-only ${plugin} tool returned objectAnnotations. Return them only from tools that change the object.`);
|
|
988
|
+
const cards = await saveObjectAnnotations(conversationId, plugin, details["objectAnnotations"]);
|
|
984
989
|
const { objectAnnotations: _annotations, ...rest } = details;
|
|
985
990
|
const annotated = {
|
|
986
991
|
...rest,
|
|
987
992
|
objectCards: cards
|
|
988
993
|
};
|
|
989
|
-
if (isRecord$2(result
|
|
994
|
+
if (isRecord$2(result["details"])) return {
|
|
990
995
|
...result,
|
|
991
996
|
details: annotated
|
|
992
997
|
};
|
|
993
998
|
return annotated;
|
|
994
999
|
}
|
|
1000
|
+
// src/chat/conversations/embedding.ts
|
|
1001
|
+
/**
|
|
1002
|
+
* One embedding per Conversation: a derived index for semantic Conversation
|
|
1003
|
+
* search. Its text is the latest Brief, which summarizes the Conversation.
|
|
1004
|
+
* Vectors are stored per model. A search compares only vectors of the same
|
|
1005
|
+
* provider, model, and size as its query.
|
|
1006
|
+
*/
|
|
1007
|
+
const MAX_EMBEDDED_CHARS = 8e3;
|
|
1008
|
+
/** Create the embedder that charges its cost to one Conversation. */
|
|
1009
|
+
function createConversationEmbedder(args) {
|
|
1010
|
+
return async ({ inputType, text }) => {
|
|
1011
|
+
const result = await embedTexts({
|
|
1012
|
+
cost: args.cost,
|
|
1013
|
+
inputType,
|
|
1014
|
+
modelId: botConfig.embeddingModelId,
|
|
1015
|
+
operation: args.operation,
|
|
1016
|
+
texts: [text.slice(0, MAX_EMBEDDED_CHARS)]
|
|
1017
|
+
});
|
|
1018
|
+
const vector = result.vectors[0];
|
|
1019
|
+
if (!vector) throw new Error("Embedding provider returned no vector");
|
|
1020
|
+
return {
|
|
1021
|
+
model: result.model,
|
|
1022
|
+
provider: result.provider,
|
|
1023
|
+
vector
|
|
1024
|
+
};
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
* Store the Conversation embedding of a stored Brief. Skip it when the
|
|
1029
|
+
* Conversation already has a vector for this or a newer Brief version, so a
|
|
1030
|
+
* task retry embeds once and an older Turn never replaces a newer vector.
|
|
1031
|
+
*/
|
|
1032
|
+
async function storeConversationEmbedding(db, embed, brief) {
|
|
1033
|
+
if (!brief.searchText) return;
|
|
1034
|
+
const table = juniorConversationEmbeddings;
|
|
1035
|
+
const [current] = await db.select({ briefVersion: table.briefVersion }).from(table).where(eq(table.conversationId, brief.conversationId)).limit(1);
|
|
1036
|
+
if (current && current.briefVersion >= brief.version) return;
|
|
1037
|
+
const embedding = await embed({
|
|
1038
|
+
inputType: "document",
|
|
1039
|
+
text: brief.searchText
|
|
1040
|
+
});
|
|
1041
|
+
const row = {
|
|
1042
|
+
briefVersion: brief.version,
|
|
1043
|
+
dimensions: embedding.vector.length,
|
|
1044
|
+
embedding: embedding.vector,
|
|
1045
|
+
model: embedding.model,
|
|
1046
|
+
provider: embedding.provider
|
|
1047
|
+
};
|
|
1048
|
+
await db.insert(table).values({
|
|
1049
|
+
conversationId: brief.conversationId,
|
|
1050
|
+
...row
|
|
1051
|
+
}).onConflictDoUpdate({
|
|
1052
|
+
target: table.conversationId,
|
|
1053
|
+
set: {
|
|
1054
|
+
...row,
|
|
1055
|
+
createdAt: sql`now()`
|
|
1056
|
+
},
|
|
1057
|
+
setWhere: sql`${table.briefVersion} < excluded.brief_version`
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* Cosine similarity of the stored vector to a query vector. Null for a
|
|
1062
|
+
* vector of another model or size. CASE fixes the order, so Postgres never
|
|
1063
|
+
* compares vectors of different sizes, which fails.
|
|
1064
|
+
*/
|
|
1065
|
+
function conversationSimilarity(query) {
|
|
1066
|
+
const table = juniorConversationEmbeddings;
|
|
1067
|
+
return sql`CASE WHEN ${table.provider} = ${query.provider} AND ${table.model} = ${query.model} AND ${table.dimensions} = ${query.vector.length} THEN 1 - (${table.embedding} <=> ${JSON.stringify(query.vector)}::vector) END`;
|
|
1068
|
+
}
|
|
1069
|
+
// src/chat/conversations/search.ts
|
|
1070
|
+
/**
|
|
1071
|
+
* Search the Conversations that one requester may find: Conversations whose
|
|
1072
|
+
* root is public, of any surface, and Conversations whose root is at the
|
|
1073
|
+
* Destination of the requester's root. No other private Conversation is
|
|
1074
|
+
* returned, so no result leaks private data into the requester. See
|
|
1075
|
+
* `policies/conversation-access.md`.
|
|
1076
|
+
*/
|
|
1077
|
+
const MAX_LINKS = 5;
|
|
1078
|
+
const MIN_VECTOR_SIMILARITY = .4;
|
|
1079
|
+
/**
|
|
1080
|
+
* Search the Conversations, outside the requester's own tree, that the
|
|
1081
|
+
* requester may find. Newest activity first, or best match for a query.
|
|
1082
|
+
* With an embedder, a query also matches by the meaning of the latest
|
|
1083
|
+
* Brief, and a match by meaning alone needs `MIN_VECTOR_SIMILARITY`.
|
|
1084
|
+
*/
|
|
1085
|
+
async function searchConversations(db, args) {
|
|
1086
|
+
const { embedder, requesterConversationId, search } = args;
|
|
1087
|
+
const conversations = juniorConversations;
|
|
1088
|
+
const briefs = juniorConversationBriefs;
|
|
1089
|
+
const newer = alias(juniorConversationBriefs, "newer_briefs");
|
|
1090
|
+
const roots = alias(juniorConversations, "target_roots");
|
|
1091
|
+
const requesterRoot = alias(juniorConversations, "requester_roots");
|
|
1092
|
+
const embeddings = juniorConversationEmbeddings;
|
|
1093
|
+
const query = search.query?.trim() || void 0;
|
|
1094
|
+
const queryVector = query && embedder ? await embedder({
|
|
1095
|
+
inputType: "query",
|
|
1096
|
+
text: query
|
|
1097
|
+
}) : void 0;
|
|
1098
|
+
const similarity = queryVector ? conversationSimilarity(queryVector) : void 0;
|
|
1099
|
+
const tsquery = sql`websearch_to_tsquery('english', ${query ?? ""})`;
|
|
1100
|
+
const searchVector = sql`to_tsvector('english', ${briefs.searchText})`;
|
|
1101
|
+
const outcomeStatus = sql`${briefs.content}->'outcome'->>'status'`;
|
|
1102
|
+
const [requester] = await db.select({ rootId: conversations.rootConversationId }).from(conversations).where(eq(conversations.conversationId, requesterConversationId)).limit(1);
|
|
1103
|
+
const requesterRootId = requester?.rootId ?? requesterConversationId;
|
|
1104
|
+
const conditions = [
|
|
1105
|
+
isNull(roots.quickQuestionAt),
|
|
1106
|
+
isNull(conversations.quickQuestionAt),
|
|
1107
|
+
search.rootsOnly ? eq(conversations.conversationId, conversations.rootConversationId) : void 0,
|
|
1108
|
+
ne(conversations.rootConversationId, requesterRootId),
|
|
1109
|
+
or(eq(juniorDestinations.visibility, "public"), eq(roots.destinationId, db.select({ destinationId: requesterRoot.destinationId }).from(requesterRoot).where(eq(requesterRoot.conversationId, requesterRootId)))),
|
|
1110
|
+
search.annotation ? or(search.annotationOnSelf ? void 0 : treeHasAnnotationKey(conversations.conversationId, search.annotation), hasAnnotationKey(conversations.conversationId, search.annotation)) : void 0,
|
|
1111
|
+
search.statuses ? inArray(conversations.executionStatus, [...search.statuses]) : void 0,
|
|
1112
|
+
search.conversationIds ? inArray(conversations.conversationId, [...search.conversationIds]) : void 0,
|
|
1113
|
+
search.includeArchived ? void 0 : and(isNull(conversations.archivedAt), isNull(roots.archivedAt)),
|
|
1114
|
+
search.channelId ? eq(juniorDestinations.providerDestinationId, search.channelId) : void 0,
|
|
1115
|
+
search.outcomeStatus ? sql`${outcomeStatus} = ${search.outcomeStatus}` : void 0,
|
|
1116
|
+
search.afterMs !== void 0 ? gte(conversations.lastActivityAt, new Date(search.afterMs)) : void 0,
|
|
1117
|
+
search.beforeMs !== void 0 ? lt(conversations.lastActivityAt, new Date(search.beforeMs)) : void 0,
|
|
1118
|
+
query ? or(sql`${searchVector} @@ ${tsquery}`, ilike(conversations.title, `%${escapeLike(query)}%`), similarity ? sql`${similarity} >= ${MIN_VECTOR_SIMILARITY}` : void 0) : void 0
|
|
1119
|
+
];
|
|
1120
|
+
const newestFirst = desc(conversations.lastActivityAt);
|
|
1121
|
+
const wordRank = sql`coalesce(ts_rank_cd(${searchVector}, ${tsquery}, 32), 0)`;
|
|
1122
|
+
const order = query ? [desc(similarity ? sql`${wordRank} + coalesce(${similarity}, 0)` : wordRank), newestFirst] : [newestFirst];
|
|
1123
|
+
const excerpt = query ? sql`ts_headline('english', ${briefs.searchText}, ${tsquery}, 'MaxFragments=2, MinWords=8, MaxWords=40, FragmentDelimiter=" … ", StartSel=**, StopSel=**')` : sql`null`;
|
|
1124
|
+
return (await db.select({
|
|
1125
|
+
archivedAt: conversations.archivedAt,
|
|
1126
|
+
rootArchivedAt: roots.archivedAt,
|
|
1127
|
+
briefContent: briefs.content,
|
|
1128
|
+
channelName: juniorDestinations.displayName,
|
|
1129
|
+
conversationId: conversations.conversationId,
|
|
1130
|
+
excerpt: excerpt.as("excerpt"),
|
|
1131
|
+
kind: conversations.kind,
|
|
1132
|
+
lastActivityAt: conversations.lastActivityAt,
|
|
1133
|
+
providerDestinationId: juniorDestinations.providerDestinationId,
|
|
1134
|
+
rootConversationId: roots.conversationId,
|
|
1135
|
+
status: conversations.executionStatus,
|
|
1136
|
+
title: conversations.title,
|
|
1137
|
+
transcriptPurgedAt: conversations.transcriptPurgedAt
|
|
1138
|
+
}).from(conversations).innerJoin(roots, eq(roots.conversationId, conversations.rootConversationId)).innerJoin(juniorDestinations, eq(juniorDestinations.id, roots.destinationId)).leftJoin(briefs, and(eq(briefs.conversationId, conversations.conversationId), notExists(db.select({ one: sql`1` }).from(newer).where(and(eq(newer.conversationId, briefs.conversationId), gt(newer.version, briefs.version)))))).leftJoin(embeddings, and(eq(embeddings.conversationId, briefs.conversationId), eq(embeddings.briefVersion, briefs.version))).where(and(...conditions)).orderBy(...order).limit(search.limit)).map((row) => {
|
|
1139
|
+
const brief = row.briefContent ? parseStoredBrief(row.briefContent) : void 0;
|
|
1140
|
+
return {
|
|
1141
|
+
archived: row.archivedAt !== null || row.rootArchivedAt !== null,
|
|
1142
|
+
...row.channelName ? { channelName: row.channelName } : void 0,
|
|
1143
|
+
conversationId: row.conversationId,
|
|
1144
|
+
...row.excerpt ? { excerpt: row.excerpt } : void 0,
|
|
1145
|
+
...row.kind ? { kind: row.kind } : void 0,
|
|
1146
|
+
links: brief?.links.slice(0, MAX_LINKS) ?? [],
|
|
1147
|
+
...brief ? { outcomeStatus: brief.outcome.status } : void 0,
|
|
1148
|
+
...row.providerDestinationId ? { providerDestinationId: row.providerDestinationId } : void 0,
|
|
1149
|
+
rootConversationId: row.rootConversationId,
|
|
1150
|
+
status: row.status,
|
|
1151
|
+
...brief ? { summary: brief.summary } : void 0,
|
|
1152
|
+
...row.title ? { title: row.title } : void 0,
|
|
1153
|
+
transcriptPurged: row.transcriptPurgedAt !== null,
|
|
1154
|
+
updatedAtMs: row.lastActivityAt.getTime()
|
|
1155
|
+
};
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
function escapeLike(value) {
|
|
1159
|
+
return value.replace(/[\\%_]/g, (match) => `\\${match}`);
|
|
1160
|
+
}
|
|
1161
|
+
// src/chat/conversations/plugin-search.ts
|
|
1162
|
+
const DEFAULT_LIMIT = 10;
|
|
1163
|
+
const MAX_LIMIT = 25;
|
|
1164
|
+
const WORKING_STATUSES = [
|
|
1165
|
+
"pending",
|
|
1166
|
+
"running",
|
|
1167
|
+
"paused"
|
|
1168
|
+
];
|
|
1169
|
+
/**
|
|
1170
|
+
* Let a plugin tool find other Conversations by Annotation key. The current
|
|
1171
|
+
* Conversation is the requester, so the access rules of `searchConversations`
|
|
1172
|
+
* apply and its own tree is never a result.
|
|
1173
|
+
*/
|
|
1174
|
+
function createPluginConversations(conversationId) {
|
|
1175
|
+
return { async search(input) {
|
|
1176
|
+
const limit = Math.min(input.limit ?? DEFAULT_LIMIT, MAX_LIMIT);
|
|
1177
|
+
const search = {
|
|
1178
|
+
annotation: input.annotation,
|
|
1179
|
+
annotationOnSelf: true,
|
|
1180
|
+
includeArchived: false,
|
|
1181
|
+
limit,
|
|
1182
|
+
rootsOnly: false
|
|
1183
|
+
};
|
|
1184
|
+
const find = async (filters) => await searchConversations(getDb(), {
|
|
1185
|
+
requesterConversationId: conversationId,
|
|
1186
|
+
search: {
|
|
1187
|
+
...search,
|
|
1188
|
+
...filters
|
|
1189
|
+
}
|
|
1190
|
+
});
|
|
1191
|
+
const [working, newest] = await Promise.all([find({ statuses: WORKING_STATUSES }), find({})]);
|
|
1192
|
+
const seen = new Set(working.map((match) => match.conversationId));
|
|
1193
|
+
return [...working, ...newest.filter((match) => !seen.has(match.conversationId))].slice(0, limit).map((match) => ({
|
|
1194
|
+
conversationId: match.conversationId,
|
|
1195
|
+
...match.rootConversationId !== match.conversationId ? { rootConversationId: match.rootConversationId } : void 0,
|
|
1196
|
+
status: match.status === "failed" ? "idle" : match.status,
|
|
1197
|
+
...match.summary ? { summary: match.summary } : void 0,
|
|
1198
|
+
...match.title ? { title: match.title } : void 0,
|
|
1199
|
+
updatedAt: new Date(match.updatedAtMs).toISOString()
|
|
1200
|
+
}));
|
|
1201
|
+
} };
|
|
1202
|
+
}
|
|
995
1203
|
// src/chat/conversations/tool-replies.ts
|
|
996
1204
|
/**
|
|
997
1205
|
* Record the reply that a plugin tool posted for Junior, such as a pull
|
|
@@ -1000,10 +1208,10 @@ async function annotateToolResult(conversationId, plugin, result) {
|
|
|
1000
1208
|
*/
|
|
1001
1209
|
async function recordToolReply(args) {
|
|
1002
1210
|
const { result } = args;
|
|
1003
|
-
if (!isRecord$2(result) || result
|
|
1004
|
-
const details = isRecord$2(result
|
|
1005
|
-
if (details
|
|
1006
|
-
const reply = pluginToolReplySchema.parse(details
|
|
1211
|
+
if (!isRecord$2(result) || result["isError"] === true) return result;
|
|
1212
|
+
const details = isRecord$2(result["details"]) ? result["details"] : result;
|
|
1213
|
+
if (details["reply"] === void 0) return result;
|
|
1214
|
+
const reply = pluginToolReplySchema.parse(details["reply"]);
|
|
1007
1215
|
if (args.toolCallId) await getConversationEventStore().append(args.conversationId, [{
|
|
1008
1216
|
idempotencyKey: `reply_posted:tool:${args.toolCallId}`,
|
|
1009
1217
|
data: {
|
|
@@ -1016,7 +1224,7 @@ async function recordToolReply(args) {
|
|
|
1016
1224
|
createdAtMs: Date.now()
|
|
1017
1225
|
}]);
|
|
1018
1226
|
const { reply: _reply, ...rest } = details;
|
|
1019
|
-
if (isRecord$2(result
|
|
1227
|
+
if (isRecord$2(result["details"])) return {
|
|
1020
1228
|
...result,
|
|
1021
1229
|
details: rest
|
|
1022
1230
|
};
|
|
@@ -1270,7 +1478,7 @@ function mapSlackError(error) {
|
|
|
1270
1478
|
statusCode: candidate.statusCode,
|
|
1271
1479
|
requestId: getHeaderString(candidate.headers, "x-slack-req-id"),
|
|
1272
1480
|
errorData: serializeSlackErrorData(candidate.data),
|
|
1273
|
-
...parseSlackCanvasDetail(candidate.data?.detail)
|
|
1481
|
+
...parseSlackCanvasDetail(candidate.data?.["detail"])
|
|
1274
1482
|
};
|
|
1275
1483
|
if (apiError === "missing_scope") return new SlackActionError(message, "missing_scope", {
|
|
1276
1484
|
...baseOptions,
|
|
@@ -1544,9 +1752,9 @@ function slackAttachmentsVersionQuery(db, conversationId) {
|
|
|
1544
1752
|
}
|
|
1545
1753
|
/** Read the Slack file identity retained by the Chat SDK. */
|
|
1546
1754
|
function getSlackFileId(attachment) {
|
|
1547
|
-
const metadataId = attachment.fetchMetadata?.fileId;
|
|
1755
|
+
const metadataId = attachment.fetchMetadata?.["fileId"];
|
|
1548
1756
|
if (metadataId) return metadataId;
|
|
1549
|
-
return (attachment.url ?? attachment.fetchMetadata?.url ?? "").match(/(?:^|[-/])(F[A-Z0-9]+)(?:[-/]|$)/)?.[1];
|
|
1757
|
+
return (attachment.url ?? attachment.fetchMetadata?.["url"] ?? "").match(/(?:^|[-/])(F[A-Z0-9]+)(?:[-/]|$)/)?.[1];
|
|
1550
1758
|
}
|
|
1551
1759
|
/**
|
|
1552
1760
|
* Look up a Slack file that Junior recorded without storing it.
|
|
@@ -1584,7 +1792,7 @@ async function hydrateMessageAttachments(db, conversationId, events) {
|
|
|
1584
1792
|
});
|
|
1585
1793
|
const byFileId = new Map(attachments.map(({ providerId, ...attachment }) => [providerId, attachment]));
|
|
1586
1794
|
for (const message of messages) {
|
|
1587
|
-
const stored = readMessageAttachments(message.meta?.attachments);
|
|
1795
|
+
const stored = readMessageAttachments(message.meta?.["attachments"]);
|
|
1588
1796
|
const matched = slackFileIds(message.meta).flatMap((id) => {
|
|
1589
1797
|
const attachment = byFileId.get(id);
|
|
1590
1798
|
return attachment ? [attachment] : [];
|
|
@@ -1596,7 +1804,7 @@ async function hydrateMessageAttachments(db, conversationId, events) {
|
|
|
1596
1804
|
}
|
|
1597
1805
|
}
|
|
1598
1806
|
function slackFileIds(meta) {
|
|
1599
|
-
const ids = meta?.slackFileIds ?? meta?.imageFileIds;
|
|
1807
|
+
const ids = meta?.["slackFileIds"] ?? meta?.["imageFileIds"];
|
|
1600
1808
|
return Array.isArray(ids) ? ids.filter((id) => typeof id === "string") : [];
|
|
1601
1809
|
}
|
|
1602
1810
|
// src/chat/agent-invocations/fork-history.ts
|
|
@@ -1652,7 +1860,7 @@ function notInheritedByForkChild() {
|
|
|
1652
1860
|
}
|
|
1653
1861
|
// src/chat/sentry-links.ts
|
|
1654
1862
|
function getSentryOrgSlug() {
|
|
1655
|
-
return process.env
|
|
1863
|
+
return process.env["SENTRY_ORG_SLUG"]?.trim() || void 0;
|
|
1656
1864
|
}
|
|
1657
1865
|
function isSentrySaasDsnHost(host) {
|
|
1658
1866
|
return host === "sentry.io" || host.endsWith(".sentry.io");
|
|
@@ -1691,22 +1899,22 @@ function buildSentryEventUrl(eventId) {
|
|
|
1691
1899
|
function conversationEventModel(data, current) {
|
|
1692
1900
|
if (data.type === "turn_started") return void 0;
|
|
1693
1901
|
if (data.type === "assistant_message") {
|
|
1694
|
-
const model = text
|
|
1695
|
-
const provider = text
|
|
1902
|
+
const model = text(data["model"]);
|
|
1903
|
+
const provider = text(data["provider"]);
|
|
1696
1904
|
if (model) return { modelId: model.includes("/") || !provider ? model : `${provider}/${model}` };
|
|
1697
1905
|
}
|
|
1698
1906
|
return current;
|
|
1699
1907
|
}
|
|
1700
|
-
function text
|
|
1908
|
+
function text(value) {
|
|
1701
1909
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
1702
1910
|
}
|
|
1703
1911
|
/** Allowlist model-call diagnostics; never expose opaque provider metadata. */
|
|
1704
1912
|
function conversationEventModelCall(data) {
|
|
1705
1913
|
if (data.type !== "assistant_message") return void 0;
|
|
1706
1914
|
const usage = extractGenAiUsageSummary(data);
|
|
1707
|
-
const provider = text
|
|
1708
|
-
const api = text
|
|
1709
|
-
const stopReason = text
|
|
1915
|
+
const provider = text(data["provider"]);
|
|
1916
|
+
const api = text(data["api"]);
|
|
1917
|
+
const stopReason = text(data["stopReason"]);
|
|
1710
1918
|
return {
|
|
1711
1919
|
...provider ? { provider } : void 0,
|
|
1712
1920
|
...api ? { api } : void 0,
|
|
@@ -1799,7 +2007,7 @@ function modelVisibleToolOutput(content) {
|
|
|
1799
2007
|
}
|
|
1800
2008
|
function reportMessageActorIdentity(data) {
|
|
1801
2009
|
if (data.role !== "user") return void 0;
|
|
1802
|
-
const author = reportingMessageAuthorSchema.safeParse(data.meta?.author);
|
|
2010
|
+
const author = reportingMessageAuthorSchema.safeParse(data.meta?.["author"]);
|
|
1803
2011
|
if (!author.success) return void 0;
|
|
1804
2012
|
const actorIdentity = {
|
|
1805
2013
|
...author.data.fullName ? { fullName: author.data.fullName } : void 0,
|
|
@@ -1904,13 +2112,13 @@ function conversationReportToolResultIds(events) {
|
|
|
1904
2112
|
const storedMessageEventsSchema = z.array(conversationReportMessageEventSchema);
|
|
1905
2113
|
/** Read the Events listed on a message that holds several Events. */
|
|
1906
2114
|
function reportMessageEvents(meta) {
|
|
1907
|
-
const parsed = storedMessageEventsSchema.safeParse(meta?.events);
|
|
2115
|
+
const parsed = storedMessageEventsSchema.safeParse(meta?.["events"]);
|
|
1908
2116
|
return parsed.success ? { events: parsed.data } : void 0;
|
|
1909
2117
|
}
|
|
1910
2118
|
const storedReviewItemChangesSchema = z.array(reviewItemChangeRecordSchema).min(1);
|
|
1911
2119
|
/** Read the Review item changes that a message records. */
|
|
1912
2120
|
function reportReviewItemChanges(meta) {
|
|
1913
|
-
const parsed = storedReviewItemChangesSchema.safeParse(meta?.reviewItemChanges);
|
|
2121
|
+
const parsed = storedReviewItemChangesSchema.safeParse(meta?.["reviewItemChanges"]);
|
|
1914
2122
|
return parsed.success ? { reviewItemChanges: parsed.data } : void 0;
|
|
1915
2123
|
}
|
|
1916
2124
|
const TURN_COMPLETED_STATES = {
|
|
@@ -1941,22 +2149,22 @@ function reportEventData(args) {
|
|
|
1941
2149
|
type: "message",
|
|
1942
2150
|
messageId: data.messageId,
|
|
1943
2151
|
role: data.role,
|
|
1944
|
-
...data.meta?.source === "web" || data.meta?.source === "slack" ? { source: data.meta
|
|
2152
|
+
...data.meta?.["source"] === "web" || data.meta?.["source"] === "slack" ? { source: data.meta["source"] } : void 0,
|
|
1945
2153
|
...actorIdentity ? { actorIdentity } : void 0,
|
|
1946
2154
|
...args.canExposePayload && data.role === "user" && data.authorIdentityId && data.authorIdentityId !== "system" ? { actorIdentityId: data.authorIdentityId } : void 0,
|
|
1947
|
-
...typeof data.meta?.agentInvocationId === "string" ? { agentInvocationId: data.meta
|
|
2155
|
+
...typeof data.meta?.["agentInvocationId"] === "string" ? { agentInvocationId: data.meta["agentInvocationId"] } : void 0,
|
|
1948
2156
|
...args.canExposePayload ? reportReviewItemChanges(data.meta) : void 0,
|
|
1949
|
-
eventObjectType: objectTypeSchema.safeParse(data.meta?.eventObjectType).data,
|
|
1950
|
-
...typeof data.meta?.eventType === "string" ? { eventType: data.meta
|
|
1951
|
-
...typeof data.meta?.eventNamespace === "string" ? { eventNamespace: data.meta
|
|
1952
|
-
...typeof data.meta?.explicitMention === "boolean" ? { explicitMention: data.meta
|
|
1953
|
-
...data.meta?.quiet === true ? { quiet: true } : void 0,
|
|
1954
|
-
...args.canExposePayload && typeof data.meta?.trustedSummary === "string" ? { trustedSummary: data.meta
|
|
2157
|
+
eventObjectType: objectTypeSchema.safeParse(data.meta?.["eventObjectType"]).data,
|
|
2158
|
+
...typeof data.meta?.["eventType"] === "string" ? { eventType: data.meta["eventType"] } : void 0,
|
|
2159
|
+
...typeof data.meta?.["eventNamespace"] === "string" ? { eventNamespace: data.meta["eventNamespace"] } : void 0,
|
|
2160
|
+
...typeof data.meta?.["explicitMention"] === "boolean" ? { explicitMention: data.meta["explicitMention"] } : void 0,
|
|
2161
|
+
...data.meta?.["quiet"] === true ? { quiet: true } : void 0,
|
|
2162
|
+
...args.canExposePayload && typeof data.meta?.["trustedSummary"] === "string" ? { trustedSummary: data.meta["trustedSummary"] } : void 0,
|
|
1955
2163
|
...args.canExposePayload ? reportMessageEvents(data.meta) : void 0,
|
|
1956
|
-
...args.canExposePayload && (data.meta?.cards || data.meta?.objectCards) ? { cards: readMessageCardRefs(data.meta) } : void 0,
|
|
2164
|
+
...args.canExposePayload && (data.meta?.["cards"] || data.meta?.["objectCards"]) ? { cards: readMessageCardRefs(data.meta) } : void 0,
|
|
1957
2165
|
...args.canExposePayload ? {
|
|
1958
2166
|
text: data.text,
|
|
1959
|
-
...data.meta?.attachments ? { attachments: readMessageAttachments(data.meta
|
|
2167
|
+
...data.meta?.["attachments"] ? { attachments: readMessageAttachments(data.meta["attachments"]) } : void 0
|
|
1960
2168
|
} : { redacted: true }
|
|
1961
2169
|
};
|
|
1962
2170
|
}
|
|
@@ -2663,9 +2871,17 @@ async function updateConversationBrief(context) {
|
|
|
2663
2871
|
}
|
|
2664
2872
|
await context.state.withLock(`brief:${run.conversationId}`, BRIEF_LOCK_TTL_MS, async () => {
|
|
2665
2873
|
const db = context.db;
|
|
2874
|
+
const embed = createConversationEmbedder({
|
|
2875
|
+
cost: {
|
|
2876
|
+
conversationId: run.conversationId,
|
|
2877
|
+
turnId: run.runId
|
|
2878
|
+
},
|
|
2879
|
+
operation: "conversation_embedding"
|
|
2880
|
+
});
|
|
2666
2881
|
const existing = await readConversationBriefForTurn(db, run.conversationId, run.runId);
|
|
2667
2882
|
if (existing) {
|
|
2668
2883
|
await emitBriefUpdated(context, existing);
|
|
2884
|
+
await storeConversationEmbedding(db, embed, existing);
|
|
2669
2885
|
logSkip(context, run.conversationId, "turn_already_stored");
|
|
2670
2886
|
return;
|
|
2671
2887
|
}
|
|
@@ -2678,7 +2894,7 @@ async function updateConversationBrief(context) {
|
|
|
2678
2894
|
const input = await briefInputFromSql(executor, run.conversationId, terminalSeq);
|
|
2679
2895
|
const modelId = botConfig.fastModelId;
|
|
2680
2896
|
const generation = await generateBrief({
|
|
2681
|
-
completeObject: (request) => completeObject
|
|
2897
|
+
completeObject: (request) => completeObject({
|
|
2682
2898
|
...request,
|
|
2683
2899
|
modelId,
|
|
2684
2900
|
operation: "brief_update",
|
|
@@ -2699,6 +2915,7 @@ async function updateConversationBrief(context) {
|
|
|
2699
2915
|
...generation.costUsd !== void 0 ? { costUsd: generation.costUsd } : void 0
|
|
2700
2916
|
});
|
|
2701
2917
|
await emitBriefUpdated(context, stored.value);
|
|
2918
|
+
await storeConversationEmbedding(db, embed, stored.value);
|
|
2702
2919
|
if (!stored.inserted) logSkip(context, run.conversationId, "turn_already_stored");
|
|
2703
2920
|
});
|
|
2704
2921
|
}
|
|
@@ -3052,7 +3269,7 @@ function createPluginLogger(plugin) {
|
|
|
3052
3269
|
});
|
|
3053
3270
|
},
|
|
3054
3271
|
warn(message, metadata) {
|
|
3055
|
-
logWarn("plugin.log.
|
|
3272
|
+
logWarn("plugin.log.warning", {
|
|
3056
3273
|
"app.log.message": message,
|
|
3057
3274
|
"app.plugin.name": plugin,
|
|
3058
3275
|
...metadata
|
|
@@ -3124,7 +3341,7 @@ const RUNTIME_GIT_CONFIG = [["credential.helper", ""], ["http.emptyAuth", "true"
|
|
|
3124
3341
|
* always wins.
|
|
3125
3342
|
*/
|
|
3126
3343
|
function gitConfigEnv(env) {
|
|
3127
|
-
const count = Number.parseInt(env
|
|
3344
|
+
const count = Number.parseInt(env["GIT_CONFIG_COUNT"] ?? "0", 10) || 0;
|
|
3128
3345
|
const entries = [];
|
|
3129
3346
|
for (let index = 0; index < count; index++) {
|
|
3130
3347
|
const key = env[`GIT_CONFIG_KEY_${index}`];
|
|
@@ -3192,7 +3409,7 @@ function normalizeWorkspaceRoot(input) {
|
|
|
3192
3409
|
const normalized = candidate.replace(/\/+$/, "");
|
|
3193
3410
|
return normalized.startsWith("/") ? normalized : `/${normalized}`;
|
|
3194
3411
|
}
|
|
3195
|
-
const SANDBOX_WORKSPACE_ROOT = normalizeWorkspaceRoot(process.env
|
|
3412
|
+
const SANDBOX_WORKSPACE_ROOT = normalizeWorkspaceRoot(process.env["VERCEL_SANDBOX_WORKSPACE_DIR"]);
|
|
3196
3413
|
const SANDBOX_REPOS_ROOT = `${SANDBOX_WORKSPACE_ROOT}/repos`;
|
|
3197
3414
|
const SANDBOX_SKILLS_ROOT = `${SANDBOX_WORKSPACE_ROOT}/skills`;
|
|
3198
3415
|
const SANDBOX_DATA_ROOT = `${SANDBOX_WORKSPACE_ROOT}/data`;
|
|
@@ -3278,7 +3495,7 @@ function createSandboxCapability(workspace, ownerSignal) {
|
|
|
3278
3495
|
function createPluginModel(pluginName, options = {}, runtime = {}) {
|
|
3279
3496
|
return { async completeObject(input) {
|
|
3280
3497
|
const modelId = options.structuredModelId ?? (options.structuredModel === "default" ? botConfig.modelId : botConfig.fastModelId);
|
|
3281
|
-
const result = await completeObject({
|
|
3498
|
+
const result = await completeObject$1({
|
|
3282
3499
|
modelId,
|
|
3283
3500
|
schema: input.schema,
|
|
3284
3501
|
prompt: input.prompt,
|
|
@@ -3307,7 +3524,7 @@ function createPluginEmbedder(pluginName, runtime = {}) {
|
|
|
3307
3524
|
model: botConfig.embeddingModelId,
|
|
3308
3525
|
provider: GEN_AI_PROVIDER_NAME,
|
|
3309
3526
|
async embedTexts(input) {
|
|
3310
|
-
const result = await embedTexts({
|
|
3527
|
+
const result = await embedTexts$1({
|
|
3311
3528
|
modelId: botConfig.embeddingModelId,
|
|
3312
3529
|
texts: input.texts,
|
|
3313
3530
|
...input.inputType !== void 0 ? { inputType: input.inputType } : void 0,
|
|
@@ -3425,7 +3642,7 @@ var DockerApiError = class extends Error {
|
|
|
3425
3642
|
};
|
|
3426
3643
|
/** Return the unix socket path of the Docker daemon from `DOCKER_HOST`. */
|
|
3427
3644
|
function dockerSocketPath() {
|
|
3428
|
-
const host = process.env
|
|
3645
|
+
const host = process.env["DOCKER_HOST"]?.trim();
|
|
3429
3646
|
if (!host) return DEFAULT_SOCKET_PATH;
|
|
3430
3647
|
if (!host.startsWith("unix://")) throw new Error(`The Docker sandbox provider supports only unix sockets. DOCKER_HOST is ${host}`);
|
|
3431
3648
|
return host.slice(7);
|
|
@@ -3708,7 +3925,7 @@ const DOCKER_SANDBOX_LABEL = "dev.junior.sandbox";
|
|
|
3708
3925
|
* `JUNIOR_DOCKER_SANDBOX_DIR` overrides the default.
|
|
3709
3926
|
*/
|
|
3710
3927
|
function dockerSandboxDir() {
|
|
3711
|
-
const configured = process.env
|
|
3928
|
+
const configured = process.env["JUNIOR_DOCKER_SANDBOX_DIR"]?.trim();
|
|
3712
3929
|
if (configured) return configured;
|
|
3713
3930
|
return path.join(os.homedir(), ".cache", "junior", "docker-sandbox");
|
|
3714
3931
|
}
|
|
@@ -3720,7 +3937,7 @@ function dockerSandboxDir() {
|
|
|
3720
3937
|
* verify the certificates that this proxy shows.
|
|
3721
3938
|
*/
|
|
3722
3939
|
function dockerSandboxExtraCaFile() {
|
|
3723
|
-
return process.env
|
|
3940
|
+
return process.env["JUNIOR_DOCKER_SANDBOX_EXTRA_CA_CERTS"]?.trim() || void 0;
|
|
3724
3941
|
}
|
|
3725
3942
|
// src/chat/sandbox/docker/tar.ts
|
|
3726
3943
|
const BLOCK = 512;
|
|
@@ -4143,7 +4360,7 @@ const octetString = (value) => tlv(4, value);
|
|
|
4143
4360
|
const bitString = (value) => tlv(3, Buffer.concat([Buffer.from([0]), value]));
|
|
4144
4361
|
const explicit = (index, value) => tlv(160 + index, value);
|
|
4145
4362
|
const booleanTrue = () => tlv(1, Buffer.from([255]));
|
|
4146
|
-
function integer
|
|
4363
|
+
function integer(value) {
|
|
4147
4364
|
return tlv(2, (value[0] ?? 0) & 128 ? Buffer.concat([Buffer.from([0]), value]) : value);
|
|
4148
4365
|
}
|
|
4149
4366
|
function oid(value) {
|
|
@@ -4180,7 +4397,7 @@ function certificate(input) {
|
|
|
4180
4397
|
serial[0] = (serial[0] ?? 0) & 127;
|
|
4181
4398
|
const algorithm = sequence(oid(OID.ecdsaWithSha256));
|
|
4182
4399
|
const now = Date.now();
|
|
4183
|
-
const tbs = sequence(explicit(0, integer
|
|
4400
|
+
const tbs = sequence(explicit(0, integer(Buffer.from([2]))), integer(serial), algorithm, input.issuer, sequence(time(/* @__PURE__ */ new Date(now - DAY_MS)), time(new Date(now + input.validDays * DAY_MS))), input.subject, publicKeyInfo(input.publicKey), explicit(3, sequence(...input.extensions)));
|
|
4184
4401
|
const signature = sign("sha256", tbs, {
|
|
4185
4402
|
key: input.signingKey,
|
|
4186
4403
|
dsaEncoding: "der"
|
|
@@ -5643,7 +5860,7 @@ function absolute(filePath, cwd) {
|
|
|
5643
5860
|
function notFound(filePath) {
|
|
5644
5861
|
return Object.assign(/* @__PURE__ */ new Error(`ENOENT: no such file or directory, '${filePath}'`), { code: "ENOENT" });
|
|
5645
5862
|
}
|
|
5646
|
-
async function readFile
|
|
5863
|
+
async function readFile(id, filePath, signal) {
|
|
5647
5864
|
try {
|
|
5648
5865
|
return unpackFirstFile(await dockerRequest({
|
|
5649
5866
|
path: `/containers/${id}/archive`,
|
|
@@ -5696,7 +5913,7 @@ function fileSystem(id) {
|
|
|
5696
5913
|
return {
|
|
5697
5914
|
async readFile(filePath, options) {
|
|
5698
5915
|
const target = absolute(filePath);
|
|
5699
|
-
const content = await readFile
|
|
5916
|
+
const content = await readFile(id, target, options.signal);
|
|
5700
5917
|
if (!content) throw notFound(target);
|
|
5701
5918
|
return content.toString(options.encoding);
|
|
5702
5919
|
},
|
|
@@ -5771,7 +5988,7 @@ function adaptSession$1(container, options) {
|
|
|
5771
5988
|
const result = await runRawExec(id, { cmd: ["mkdir", target] });
|
|
5772
5989
|
if (result.exitCode !== 0) throw new Error(`mkdir ${target} failed: ${result.stderr.trim()}`);
|
|
5773
5990
|
}),
|
|
5774
|
-
readFileToBuffer: (input) => run(() => readFile
|
|
5991
|
+
readFileToBuffer: (input) => run(() => readFile(id, absolute(input.path, input.cwd))),
|
|
5775
5992
|
runCommand: (input) => run(() => runSandboxCommand(id, {
|
|
5776
5993
|
...input,
|
|
5777
5994
|
cwd: input.cwd ?? SANDBOX_WORKSPACE_ROOT,
|
|
@@ -5902,9 +6119,9 @@ const dockerSandboxProvider = {
|
|
|
5902
6119
|
* the SDK read ambient Vercel auth from its own environment detection.
|
|
5903
6120
|
*/
|
|
5904
6121
|
function getVercelSandboxCredentials() {
|
|
5905
|
-
const token = toOptionalTrimmed(process.env
|
|
5906
|
-
const teamId = toOptionalTrimmed(process.env
|
|
5907
|
-
const projectId = toOptionalTrimmed(process.env
|
|
6122
|
+
const token = toOptionalTrimmed(process.env["VERCEL_TOKEN"]);
|
|
6123
|
+
const teamId = toOptionalTrimmed(process.env["VERCEL_TEAM_ID"]);
|
|
6124
|
+
const projectId = toOptionalTrimmed(process.env["VERCEL_PROJECT_ID"]);
|
|
5908
6125
|
if (token && teamId && projectId) return {
|
|
5909
6126
|
token,
|
|
5910
6127
|
teamId,
|
|
@@ -6623,24 +6840,24 @@ function optionalString(value) {
|
|
|
6623
6840
|
/** Parse OAuth callback state that was persisted before a provider redirect. */
|
|
6624
6841
|
function parseOAuthStatePayload(value) {
|
|
6625
6842
|
if (!isRecord$2(value)) return;
|
|
6626
|
-
if (typeof value
|
|
6627
|
-
const actor = value
|
|
6628
|
-
if (value
|
|
6629
|
-
const destination = parseDestination(value
|
|
6630
|
-
if (value
|
|
6631
|
-
const source = value
|
|
6632
|
-
if (value
|
|
6843
|
+
if (typeof value["userId"] !== "string" || typeof value["provider"] !== "string") return;
|
|
6844
|
+
const actor = value["actor"] === void 0 ? void 0 : actorSchema.safeParse(value["actor"]);
|
|
6845
|
+
if (value["actor"] !== void 0 && (!actor || !actor.success)) return;
|
|
6846
|
+
const destination = parseDestination(value["destination"]);
|
|
6847
|
+
if (value["destination"] !== void 0 && !destination) return;
|
|
6848
|
+
const source = value["source"] === void 0 ? void 0 : sourceSchema.safeParse(value["source"]);
|
|
6849
|
+
if (value["source"] !== void 0 && (!source || !source.success)) return;
|
|
6633
6850
|
return {
|
|
6634
|
-
userId: value
|
|
6635
|
-
provider: value
|
|
6851
|
+
userId: value["userId"],
|
|
6852
|
+
provider: value["provider"],
|
|
6636
6853
|
...actor?.success ? { actor: actor.data } : void 0,
|
|
6637
|
-
...optionalString(value
|
|
6854
|
+
...optionalString(value["channelId"]) ? { channelId: optionalString(value["channelId"]) } : void 0,
|
|
6638
6855
|
...destination ? { destination } : void 0,
|
|
6639
6856
|
...source?.success ? { source: source.data } : void 0,
|
|
6640
|
-
...optionalString(value
|
|
6641
|
-
...optionalString(value
|
|
6642
|
-
...optionalString(value
|
|
6643
|
-
...optionalString(value
|
|
6857
|
+
...optionalString(value["threadTs"]) ? { threadTs: optionalString(value["threadTs"]) } : void 0,
|
|
6858
|
+
...optionalString(value["resumeConversationId"]) ? { resumeConversationId: optionalString(value["resumeConversationId"]) } : void 0,
|
|
6859
|
+
...optionalString(value["resumeSessionId"]) ? { resumeSessionId: optionalString(value["resumeSessionId"]) } : void 0,
|
|
6860
|
+
...optionalString(value["scope"]) ? { scope: optionalString(value["scope"]) } : void 0
|
|
6644
6861
|
};
|
|
6645
6862
|
}
|
|
6646
6863
|
/** Return the manifest-owned display label for a provider. */
|
|
@@ -6651,11 +6868,11 @@ function formatProviderLabel(provider) {
|
|
|
6651
6868
|
}
|
|
6652
6869
|
/** Resolve the public base URL from environment variables (JUNIOR_BASE_URL or Vercel). */
|
|
6653
6870
|
function resolveBaseUrl() {
|
|
6654
|
-
const explicit = process.env
|
|
6871
|
+
const explicit = process.env["JUNIOR_BASE_URL"]?.trim();
|
|
6655
6872
|
if (explicit) return explicit;
|
|
6656
|
-
const vercelProd = process.env
|
|
6873
|
+
const vercelProd = process.env["VERCEL_PROJECT_PRODUCTION_URL"]?.trim();
|
|
6657
6874
|
if (vercelProd) return `https://${vercelProd}`;
|
|
6658
|
-
const vercelUrl = process.env
|
|
6875
|
+
const vercelUrl = process.env["VERCEL_URL"]?.trim();
|
|
6659
6876
|
if (vercelUrl) return `https://${vercelUrl}`;
|
|
6660
6877
|
}
|
|
6661
6878
|
/**
|
|
@@ -6897,7 +7114,7 @@ function normalizePort(value) {
|
|
|
6897
7114
|
return port >= 1 && port <= 65535 ? trimmed : void 0;
|
|
6898
7115
|
}
|
|
6899
7116
|
function sandboxIdFromPayload(payload) {
|
|
6900
|
-
return typeof payload
|
|
7117
|
+
return typeof payload["sandbox_id"] === "string" ? payload["sandbox_id"] : void 0;
|
|
6901
7118
|
}
|
|
6902
7119
|
function normalizedForwardedPath(path) {
|
|
6903
7120
|
if (!path.startsWith("/") || path.startsWith("//") || path.includes("#") || /[\r\n]/.test(path)) return {
|
|
@@ -7042,9 +7259,9 @@ function searchableText(error) {
|
|
|
7042
7259
|
}
|
|
7043
7260
|
function isInvalidSandboxSessionError(error) {
|
|
7044
7261
|
if (!isRecord$1(error)) return false;
|
|
7045
|
-
if (isRecord$1(error
|
|
7046
|
-
const response = error
|
|
7047
|
-
return isRecord$1(response) && response
|
|
7262
|
+
if (isRecord$1(error["json"]) && error["json"]["invalidToken"] === true) return true;
|
|
7263
|
+
const response = error["response"];
|
|
7264
|
+
return isRecord$1(response) && response["status"] === 403 && typeof response["url"] === "string" && response["url"].includes("/sandboxes/sessions");
|
|
7048
7265
|
}
|
|
7049
7266
|
function isUnavailable(error) {
|
|
7050
7267
|
return findInErrorChain(error, (candidate) => {
|
|
@@ -7074,13 +7291,13 @@ function isTransient(error) {
|
|
|
7074
7291
|
const searchable = searchableText(candidate);
|
|
7075
7292
|
if (searchable.includes("internal_server_error") || searchable.includes("status=500") || searchable.includes("status code 500") || searchable.includes("status=502") || searchable.includes("status code 502") || searchable.includes("status=503") || searchable.includes("status code 503") || searchable.includes("status=504") || searchable.includes("status code 504")) return true;
|
|
7076
7293
|
if (!isRecord$1(candidate)) return false;
|
|
7077
|
-
const response = candidate
|
|
7078
|
-
return isRecord$1(response) && typeof response
|
|
7294
|
+
const response = candidate["response"];
|
|
7295
|
+
return isRecord$1(response) && typeof response["status"] === "number" && response["status"] >= 500 && response["status"] < 600;
|
|
7079
7296
|
});
|
|
7080
7297
|
}
|
|
7081
7298
|
const SOCKET_FAILURE_CODES = /* @__PURE__ */ new Set(["ECONNRESET", "UND_ERR_SOCKET"]);
|
|
7082
7299
|
function isFetchSocketFailure(error) {
|
|
7083
|
-
return error.name === "TypeError" && (error.message === "terminated" || error.message === "fetch failed") && isRecord$1(error.cause) && typeof error.cause
|
|
7300
|
+
return error.name === "TypeError" && (error.message === "terminated" || error.message === "fetch failed") && isRecord$1(error.cause) && typeof error.cause["code"] === "string" && SOCKET_FAILURE_CODES.has(error.cause["code"]);
|
|
7084
7301
|
}
|
|
7085
7302
|
function isCommandStreamInterrupted(error) {
|
|
7086
7303
|
return findInErrorChain(error, (candidate) => {
|
|
@@ -7146,6 +7363,9 @@ function adaptSession(sandbox, options) {
|
|
|
7146
7363
|
return session.domain(port);
|
|
7147
7364
|
});
|
|
7148
7365
|
},
|
|
7366
|
+
previewUrls() {
|
|
7367
|
+
return session.routes.map((route) => session.domain(route.port));
|
|
7368
|
+
},
|
|
7149
7369
|
extendTimeout(duration) {
|
|
7150
7370
|
return run(async () => await session.extendTimeout(duration));
|
|
7151
7371
|
},
|
|
@@ -7453,7 +7673,7 @@ function mergeDependencies(dependencies) {
|
|
|
7453
7673
|
return merged;
|
|
7454
7674
|
}
|
|
7455
7675
|
function floatingMaxAgeMs() {
|
|
7456
|
-
const raw = process.env
|
|
7676
|
+
const raw = process.env["SANDBOX_SNAPSHOT_FLOATING_MAX_AGE_MS"];
|
|
7457
7677
|
if (!raw?.trim()) return DEFAULT_FLOATING_MAX_AGE_MS;
|
|
7458
7678
|
const parsed = Number.parseInt(raw, 10);
|
|
7459
7679
|
return Number.isFinite(parsed) && parsed >= 0 ? parsed : DEFAULT_FLOATING_MAX_AGE_MS;
|
|
@@ -7488,7 +7708,7 @@ function create(runtime, workspace) {
|
|
|
7488
7708
|
const { dependencies, postinstall } = getSandboxProvider().selectSnapshotRuntime?.(declared) ?? declared;
|
|
7489
7709
|
const pluginPostinstall = postinstall.filter((command) => !GLOBAL_RUNTIME_POSTINSTALL.includes(command));
|
|
7490
7710
|
if (dependencies.length === 0 && postinstall.length === 0 && !workspace) return null;
|
|
7491
|
-
const rebuildEpoch = process.env
|
|
7711
|
+
const rebuildEpoch = process.env["SANDBOX_SNAPSHOT_REBUILD_EPOCH"]?.trim() ?? "";
|
|
7492
7712
|
const floating = dependencies.some((dependency) => isFloating(dependency)) || pluginPostinstall.length > 0 || Boolean(workspace);
|
|
7493
7713
|
return {
|
|
7494
7714
|
hash: createHash("sha256").update(JSON.stringify({
|
|
@@ -8029,11 +8249,11 @@ function normalizeDashboardPath(path, fallback) {
|
|
|
8029
8249
|
return stripTrailingSlashes(value.startsWith("/") ? value : `/${value}`);
|
|
8030
8250
|
}
|
|
8031
8251
|
function resolveDashboardBaseURL(config) {
|
|
8032
|
-
const explicit = config.baseURL ?? process.env
|
|
8252
|
+
const explicit = config.baseURL ?? process.env["JUNIOR_BASE_URL"];
|
|
8033
8253
|
if (explicit?.trim()) return stripTrailingSlashes(withHttps(explicit.trim()));
|
|
8034
|
-
const vercelProd = process.env
|
|
8254
|
+
const vercelProd = process.env["VERCEL_PROJECT_PRODUCTION_URL"]?.trim();
|
|
8035
8255
|
if (vercelProd) return stripTrailingSlashes(withHttps(vercelProd));
|
|
8036
|
-
const vercelUrl = process.env
|
|
8256
|
+
const vercelUrl = process.env["VERCEL_URL"]?.trim();
|
|
8037
8257
|
if (vercelUrl) return stripTrailingSlashes(withHttps(vercelUrl));
|
|
8038
8258
|
return "http://localhost:3000";
|
|
8039
8259
|
}
|
|
@@ -9009,7 +9229,7 @@ function publicIn(tenants) {
|
|
|
9009
9229
|
* Review item access test checks that they agree.
|
|
9010
9230
|
*/
|
|
9011
9231
|
function reviewItemVisibleTo(reader) {
|
|
9012
|
-
return or(
|
|
9232
|
+
return or(...publicIn(reader.tenants ?? []), ...reader.userId ? [reviewItemAssignedTo(reader.userId)] : [], ...reader.conversationId ? [reviewItemLinkedTo(reader.conversationId)] : [], ...reader.automationId ? [eq(juniorReviewItems.automationId, reader.automationId)] : []) ?? sql`false`;
|
|
9013
9233
|
}
|
|
9014
9234
|
/** Return whether a reader can see one Review item. */
|
|
9015
9235
|
function canReadReviewItem(item, reader) {
|
|
@@ -9130,6 +9350,14 @@ function canActOnReviewItem(item, userId) {
|
|
|
9130
9350
|
if (item.assignees.length === 0) return true;
|
|
9131
9351
|
return item.assignees.some((assignee) => assignee.userId === userId);
|
|
9132
9352
|
}
|
|
9353
|
+
/**
|
|
9354
|
+
* Return whether a Review item needs a User: an open `action` item that is
|
|
9355
|
+
* assigned to them. `reviewItemNeedsUser` is the SQL form; keep the two the
|
|
9356
|
+
* same.
|
|
9357
|
+
*/
|
|
9358
|
+
function itemNeedsUser(item, userId) {
|
|
9359
|
+
return item.status === "open" && item.kind === "action" && item.assignees.some((assignee) => assignee.userId === userId);
|
|
9360
|
+
}
|
|
9133
9361
|
/** Return whether a User is already the only assignee, so take does nothing. */
|
|
9134
9362
|
function isOnlyAssignee(item, userId) {
|
|
9135
9363
|
return !item.assignedToEveryone && item.assignees.length === 1 && item.assignees[0]?.userId === userId;
|
|
@@ -9339,6 +9567,14 @@ async function takeReviewItem(db, input) {
|
|
|
9339
9567
|
function searchConditions(reader, filters) {
|
|
9340
9568
|
const conditions = [reviewItemVisibleTo(reader), inArray(juniorReviewItems.status, [...filters.statuses])];
|
|
9341
9569
|
if (filters.after) conditions.push(or(gt(juniorReviewItems.createdAt, filters.after.createdAt), and(eq(juniorReviewItems.createdAt, filters.after.createdAt), gt(juniorReviewItems.id, filters.after.id))));
|
|
9570
|
+
if (filters.afterWaiting) {
|
|
9571
|
+
if (typeof filters.order !== "object") throw new Error("afterWaiting needs the waiting-first order");
|
|
9572
|
+
const needs = reviewItemNeedsUser(filters.order.needsUserId);
|
|
9573
|
+
const { createdAt, id, needsUser } = filters.afterWaiting;
|
|
9574
|
+
const older = or(lt(juniorReviewItems.createdAt, createdAt), and(eq(juniorReviewItems.createdAt, createdAt), lt(juniorReviewItems.id, id)));
|
|
9575
|
+
conditions.push(needsUser ? or(not(needs), and(needs, older)) : and(not(needs), older));
|
|
9576
|
+
}
|
|
9577
|
+
if (filters.closedBefore) conditions.push(or(lt(juniorReviewItems.closedAt, filters.closedBefore.closedAt), and(eq(juniorReviewItems.closedAt, filters.closedBefore.closedAt), lt(juniorReviewItems.id, filters.closedBefore.id))));
|
|
9342
9578
|
if (filters.subjectId) conditions.push(eq(juniorReviewItems.subjectId, filters.subjectId));
|
|
9343
9579
|
if (filters.automationId) conditions.push(eq(juniorReviewItems.automationId, filters.automationId));
|
|
9344
9580
|
if (filters.conversationId) conditions.push(reviewItemLinkedTo(filters.conversationId));
|
|
@@ -9350,9 +9586,26 @@ function searchConditions(reader, filters) {
|
|
|
9350
9586
|
}
|
|
9351
9587
|
return conditions;
|
|
9352
9588
|
}
|
|
9353
|
-
/**
|
|
9354
|
-
|
|
9355
|
-
|
|
9589
|
+
/**
|
|
9590
|
+
* Count the open Review items that need a User (`reviewItemNeedsUser`), one
|
|
9591
|
+
* row per subject URL, with the ones that ask with a form as `decisions`.
|
|
9592
|
+
* The nav count and the Inbox bundle counts all read this one query.
|
|
9593
|
+
*/
|
|
9594
|
+
async function countReviewItemsNeedingUserBySubject(db, userId) {
|
|
9595
|
+
return await db.select({
|
|
9596
|
+
decisions: count(juniorReviewItems.request),
|
|
9597
|
+
subjectUrl: juniorReviewItems.subjectUrl,
|
|
9598
|
+
total: count()
|
|
9599
|
+
}).from(juniorReviewItems).where(reviewItemNeedsUser(userId)).groupBy(juniorReviewItems.subjectUrl);
|
|
9600
|
+
}
|
|
9601
|
+
/**
|
|
9602
|
+
* Count the items in `ids` that are still open and that the reader's Inbox
|
|
9603
|
+
* lists (`reviewItemForUser`). Snoozes live in the browser, so the
|
|
9604
|
+
* dashboard names the newest item of each snoozed row.
|
|
9605
|
+
*/
|
|
9606
|
+
async function countOpenReviewItemsForUser(db, reader, ids) {
|
|
9607
|
+
if (ids.length === 0) return 0;
|
|
9608
|
+
return (await db.select({ count: count() }).from(juniorReviewItems).where(and(inArray(juniorReviewItems.id, [...ids]), eq(juniorReviewItems.status, "open"), reviewItemVisibleTo(reader), reviewItemForUser(reader.userId))))[0]?.count ?? 0;
|
|
9356
9609
|
}
|
|
9357
9610
|
/**
|
|
9358
9611
|
* Return a query for a token that changes when the open Review items that
|
|
@@ -9367,10 +9620,18 @@ function reviewItemsNeedingUserVersionQuery(db, userId) {
|
|
|
9367
9620
|
* the limit never drops an open item for a closed one. Then the newest
|
|
9368
9621
|
* change comes first: `updated_at`, then `id`, both descending. With
|
|
9369
9622
|
* `order: "oldest"`, the oldest item comes first: `created_at`, then `id`,
|
|
9370
|
-
* both ascending. `after` pages through that order.
|
|
9623
|
+
* both ascending. `after` pages through that order. With `order: "closed"`,
|
|
9624
|
+
* the item closed last comes first: `closed_at`, then `id`, both
|
|
9625
|
+
* descending. `closedBefore` pages through that order. With
|
|
9626
|
+
* `order: { needsUserId }`, the items that need the User come first, then
|
|
9627
|
+
* `created_at` and `id`, both descending. `afterWaiting` pages through it.
|
|
9371
9628
|
*/
|
|
9372
9629
|
async function searchReviewItems(db, reader, filters) {
|
|
9373
|
-
return await hydrate(db, await db.select().from(juniorReviewItems).where(and(...searchConditions(reader, filters))).orderBy(desc(eq(juniorReviewItems.status, "open")), ...filters.order === "
|
|
9630
|
+
return await hydrate(db, await db.select().from(juniorReviewItems).where(and(...searchConditions(reader, filters))).orderBy(desc(eq(juniorReviewItems.status, "open")), ...typeof filters.order === "object" ? [
|
|
9631
|
+
desc(reviewItemNeedsUser(filters.order.needsUserId)),
|
|
9632
|
+
desc(juniorReviewItems.createdAt),
|
|
9633
|
+
desc(juniorReviewItems.id)
|
|
9634
|
+
] : filters.order === "oldest" ? [asc(juniorReviewItems.createdAt), asc(juniorReviewItems.id)] : filters.order === "closed" ? [desc(juniorReviewItems.closedAt), desc(juniorReviewItems.id)] : [desc(juniorReviewItems.updatedAt), desc(juniorReviewItems.id)]).limit(filters.limit));
|
|
9374
9635
|
}
|
|
9375
9636
|
/**
|
|
9376
9637
|
* List the root Conversations that wait on a User: each root or one of its
|
|
@@ -9490,8 +9751,8 @@ function isMessageEvent(event) {
|
|
|
9490
9751
|
}
|
|
9491
9752
|
function splitMeta(meta) {
|
|
9492
9753
|
const rest = { ...meta ?? {} };
|
|
9493
|
-
const author = rest
|
|
9494
|
-
delete rest
|
|
9754
|
+
const author = rest["author"];
|
|
9755
|
+
delete rest["author"];
|
|
9495
9756
|
return {
|
|
9496
9757
|
...author ? { author } : void 0,
|
|
9497
9758
|
...Object.keys(rest).length > 0 ? { meta: rest } : void 0
|
|
@@ -9694,7 +9955,7 @@ async function resolveNotificationTimezone(args) {
|
|
|
9694
9955
|
const PUSH_TTL_SECONDS = 43200;
|
|
9695
9956
|
const PUSH_TIMEOUT_MS = 1e4;
|
|
9696
9957
|
function subjectFromBaseUrl() {
|
|
9697
|
-
const baseUrl = process.env
|
|
9958
|
+
const baseUrl = process.env["JUNIOR_BASE_URL"]?.trim();
|
|
9698
9959
|
if (!baseUrl) return void 0;
|
|
9699
9960
|
return baseUrl.startsWith("https://") || baseUrl.startsWith("http://") ? baseUrl : `https://${baseUrl}`;
|
|
9700
9961
|
}
|
|
@@ -9708,10 +9969,10 @@ function isVapidSubject(subject) {
|
|
|
9708
9969
|
* an `http://` base URL.
|
|
9709
9970
|
*/
|
|
9710
9971
|
function readWebPushConfig() {
|
|
9711
|
-
const publicKey = process.env
|
|
9972
|
+
const publicKey = process.env["JUNIOR_WEB_PUSH_PUBLIC_KEY"]?.trim();
|
|
9712
9973
|
const privateKey = readWebPushPrivateKey();
|
|
9713
9974
|
if (!publicKey || !privateKey) return void 0;
|
|
9714
|
-
const subject = process.env
|
|
9975
|
+
const subject = process.env["JUNIOR_WEB_PUSH_SUBJECT"]?.trim() || subjectFromBaseUrl();
|
|
9715
9976
|
if (!subject || !isVapidSubject(subject)) return void 0;
|
|
9716
9977
|
return {
|
|
9717
9978
|
privateKey,
|
|
@@ -9794,8 +10055,7 @@ function notificationPreview(text) {
|
|
|
9794
10055
|
}
|
|
9795
10056
|
/**
|
|
9796
10057
|
* Return the stored reply of the Turn: the text that the person sees. The
|
|
9797
|
-
* run transcript has the raw model text, which can be a no-reply marker
|
|
9798
|
-
* does not say whether the reply was quiet.
|
|
10058
|
+
* run transcript has the raw model text, which can be a no-reply marker.
|
|
9799
10059
|
*/
|
|
9800
10060
|
async function readTurnReply(run) {
|
|
9801
10061
|
const prefix = `${run.runId}:assistant:`;
|
|
@@ -9836,7 +10096,6 @@ async function notifyReply(context) {
|
|
|
9836
10096
|
if (!url) return skip("no_dashboard");
|
|
9837
10097
|
const reply = await readTurnReply(run);
|
|
9838
10098
|
if (!reply) return skip("no_reply");
|
|
9839
|
-
if (reply.meta?.quiet) return skip("quiet");
|
|
9840
10099
|
const db = context.db;
|
|
9841
10100
|
const userId = await recipientUserId(db, run);
|
|
9842
10101
|
if (!userId) return skip("no_user");
|
|
@@ -9887,11 +10146,7 @@ const notificationsTaskRegistration = {
|
|
|
9887
10146
|
} } }
|
|
9888
10147
|
};
|
|
9889
10148
|
// src/chat/briefs/registration.ts
|
|
9890
|
-
var registration_exports = /* @__PURE__ */ __exportAll({
|
|
9891
|
-
coreTaskRegistrations: () => coreTaskRegistrations,
|
|
9892
|
-
isBriefsEnabled: () => isBriefsEnabled,
|
|
9893
|
-
setBriefsConfig: () => setBriefsConfig
|
|
9894
|
-
});
|
|
10149
|
+
var registration_exports = /* @__PURE__ */ __exportAll({ setBriefsConfig: () => setBriefsConfig });
|
|
9895
10150
|
let configuredBriefs = {};
|
|
9896
10151
|
/** Replace app-level Brief settings and return the previous setting. */
|
|
9897
10152
|
function setBriefsConfig(config) {
|
|
@@ -9921,6 +10176,7 @@ var agent_hooks_exports = /* @__PURE__ */ __exportAll({
|
|
|
9921
10176
|
getPluginTools: () => getPluginTools,
|
|
9922
10177
|
getPluginUserPromptContributions: () => getPluginUserPromptContributions,
|
|
9923
10178
|
getPlugins: () => getPlugins,
|
|
10179
|
+
getStaticPluginToolDefinitions: () => getStaticPluginToolDefinitions,
|
|
9924
10180
|
setPlugins: () => setPlugins,
|
|
9925
10181
|
validatePlugins: () => validatePlugins
|
|
9926
10182
|
});
|
|
@@ -10084,10 +10340,11 @@ function toUserPromptContributionContext(args) {
|
|
|
10084
10340
|
message: message.data,
|
|
10085
10341
|
pluginName: args.pluginName
|
|
10086
10342
|
});
|
|
10087
|
-
if (!isRecord(args.value) || typeof args.value
|
|
10088
|
-
const context = promptContextSchema.safeParse(args.value
|
|
10343
|
+
if (!isRecord(args.value) || typeof args.value["renderPrompt"] !== "function") return;
|
|
10344
|
+
const context = promptContextSchema.safeParse(args.value["context"]);
|
|
10089
10345
|
if (!context.success) return;
|
|
10090
|
-
const
|
|
10346
|
+
const renderPrompt = args.value["renderPrompt"];
|
|
10347
|
+
const text = promptMessageSchema.safeParse({ text: renderPrompt.call(args.value) });
|
|
10091
10348
|
if (!text.success) return;
|
|
10092
10349
|
return {
|
|
10093
10350
|
id: `userPrompt:${args.index}`,
|
|
@@ -10258,13 +10515,48 @@ async function getPluginUserPromptContributions(args) {
|
|
|
10258
10515
|
}
|
|
10259
10516
|
return contributions;
|
|
10260
10517
|
}
|
|
10518
|
+
/**
|
|
10519
|
+
* Model-facing definitions of one plugin's tools, by host tool name. They
|
|
10520
|
+
* come from the plugin's `tools()` with no Turn.
|
|
10521
|
+
*/
|
|
10522
|
+
function pluginToolDefinitions(plugin) {
|
|
10523
|
+
const hook = plugin.hooks?.tools;
|
|
10524
|
+
if (!hook) return {};
|
|
10525
|
+
const pluginName = plugin.manifest.name;
|
|
10526
|
+
const namespace = pluginToolNamespace(pluginName);
|
|
10527
|
+
const definitions = {};
|
|
10528
|
+
for (const [localName, definition] of Object.entries(hook())) {
|
|
10529
|
+
const execute = definition.execute;
|
|
10530
|
+
definitions[`${namespace}_${localName}`] = {
|
|
10531
|
+
...definition,
|
|
10532
|
+
...execute ? { execute: execute.bind(definition) } : void 0,
|
|
10533
|
+
approvalMode: definition.approvalMode ?? "auto",
|
|
10534
|
+
identity: {
|
|
10535
|
+
id: `${pluginName}.${localName}`,
|
|
10536
|
+
name: localName,
|
|
10537
|
+
plugin: pluginName
|
|
10538
|
+
},
|
|
10539
|
+
source: {
|
|
10540
|
+
id: pluginName,
|
|
10541
|
+
description: plugin.manifest.description
|
|
10542
|
+
},
|
|
10543
|
+
exposure: definition.exposure ?? "deferred"
|
|
10544
|
+
};
|
|
10545
|
+
}
|
|
10546
|
+
return definitions;
|
|
10547
|
+
}
|
|
10548
|
+
/** Model-facing definitions of every plugin tool, with no Turn. */
|
|
10549
|
+
function getStaticPluginToolDefinitions() {
|
|
10550
|
+
const definitions = {};
|
|
10551
|
+
for (const plugin of getPlugins()) Object.assign(definitions, pluginToolDefinitions(plugin));
|
|
10552
|
+
return definitions;
|
|
10553
|
+
}
|
|
10261
10554
|
/** Collect turn-scoped tools exposed by plugins. */
|
|
10262
10555
|
function getPluginTools(context, sandbox = createSandboxCapability(context.workspace)) {
|
|
10263
10556
|
const tools = {};
|
|
10264
10557
|
for (const plugin of getPlugins()) {
|
|
10265
10558
|
const pluginName = plugin.manifest.name;
|
|
10266
|
-
|
|
10267
|
-
if (!hook) continue;
|
|
10559
|
+
if (!plugin.hooks?.tools) continue;
|
|
10268
10560
|
const slackToolContext = getSlackToolContext(context);
|
|
10269
10561
|
const credentialSubject = slackToolContext ? createSlackDirectCredentialSubject({
|
|
10270
10562
|
channelId: slackToolContext.locationChannelId,
|
|
@@ -10321,6 +10613,7 @@ function getPluginTools(context, sandbox = createSandboxCapability(context.works
|
|
|
10321
10613
|
...automationUrl ? { automationLink: { url: automationUrl } } : void 0,
|
|
10322
10614
|
...dashboardConversationUrl ? { conversationLink: { url: dashboardConversationUrl } } : void 0,
|
|
10323
10615
|
conversationId: context.conversationId,
|
|
10616
|
+
conversations: createPluginConversations(context.conversationId),
|
|
10324
10617
|
locationId: context.locationId,
|
|
10325
10618
|
...slackContext ? { slack: slackContext } : void 0,
|
|
10326
10619
|
userText: context.userText,
|
|
@@ -10400,40 +10693,31 @@ function getPluginTools(context, sandbox = createSandboxCapability(context.works
|
|
|
10400
10693
|
source: context.source
|
|
10401
10694
|
};
|
|
10402
10695
|
}
|
|
10403
|
-
const
|
|
10696
|
+
const definitions = pluginToolDefinitions(plugin);
|
|
10404
10697
|
const namespace = pluginToolNamespace(pluginName);
|
|
10405
|
-
|
|
10406
|
-
|
|
10698
|
+
const disabled = plugin.hooks?.disabledTools?.(pluginContext) ?? {};
|
|
10699
|
+
for (const localName of Object.keys(disabled)) if (!definitions[`${namespace}_${localName}`]) throw new Error(`Plugin "${pluginName}" disabled unknown tool "${localName}"`);
|
|
10700
|
+
for (const [name, definition] of Object.entries(definitions)) {
|
|
10701
|
+
const localName = definition.identity.name;
|
|
10407
10702
|
if (tools[name]) throw new Error(`Duplicate plugin tool "${name}" from plugin "${pluginName}"`);
|
|
10408
|
-
const definition = tool;
|
|
10409
10703
|
const missingAnnotationKeys = missingToolAnnotationKeys(definition.annotations);
|
|
10410
10704
|
if (missingAnnotationKeys.length > 0) logWarn("plugin.tool_annotations.missing", {
|
|
10411
10705
|
"app.plugin.name": pluginName,
|
|
10412
10706
|
"gen_ai.tool.name": localName,
|
|
10413
10707
|
"app.tool.missing_annotations": missingAnnotationKeys.join(",")
|
|
10414
10708
|
});
|
|
10415
|
-
definition.approvalMode ??= "auto";
|
|
10416
|
-
definition.identity = {
|
|
10417
|
-
id: `${pluginName}.${localName}`,
|
|
10418
|
-
name: localName,
|
|
10419
|
-
plugin: pluginName
|
|
10420
|
-
};
|
|
10421
|
-
definition.source = {
|
|
10422
|
-
id: pluginName,
|
|
10423
|
-
description: plugin.manifest.description
|
|
10424
|
-
};
|
|
10425
|
-
definition.exposure ??= "deferred";
|
|
10426
10709
|
const execute = definition.execute;
|
|
10427
|
-
|
|
10428
|
-
|
|
10429
|
-
|
|
10710
|
+
const disabledReason = disabled[localName];
|
|
10711
|
+
tools[name] = {
|
|
10712
|
+
...definition,
|
|
10713
|
+
...disabledReason ? { disabledReason } : void 0,
|
|
10714
|
+
...execute ? { execute: async (input, options) => annotateToolResult(context.conversationId, pluginName, await recordToolReply({
|
|
10430
10715
|
conversationId: context.conversationId,
|
|
10431
10716
|
plugin: pluginName,
|
|
10432
|
-
result: await execute
|
|
10717
|
+
result: await execute(input, options, pluginContext),
|
|
10433
10718
|
toolCallId: options.toolCallId
|
|
10434
|
-
}))
|
|
10435
|
-
|
|
10436
|
-
} else tools[name] = definition;
|
|
10719
|
+
}), { readOnly: definition.annotations?.readOnlyHint === true }) } : void 0
|
|
10720
|
+
};
|
|
10437
10721
|
}
|
|
10438
10722
|
}
|
|
10439
10723
|
return tools;
|
|
@@ -10896,7 +11180,7 @@ function createPluginHookRunner(input = {}) {
|
|
|
10896
11180
|
juniorRoot: SANDBOX_JUNIOR_ROOT,
|
|
10897
11181
|
env: {
|
|
10898
11182
|
get(key) {
|
|
10899
|
-
return env[key] ?? normalizeEnv(nextInput
|
|
11183
|
+
return env[key] ?? normalizeEnv(nextInput["env"])[key];
|
|
10900
11184
|
},
|
|
10901
11185
|
set(key, value) {
|
|
10902
11186
|
env[key] = value;
|
|
@@ -11073,32 +11357,6 @@ var ProviderCredentialRouter = class {
|
|
|
11073
11357
|
});
|
|
11074
11358
|
}
|
|
11075
11359
|
};
|
|
11076
|
-
// src/chat/conversations/legacy-web-actor-id.ts
|
|
11077
|
-
/**
|
|
11078
|
-
* Web Actor ids that Junior stored before web Actors used the User id.
|
|
11079
|
-
*
|
|
11080
|
-
* Mailbox input, web authorizations, and OAuth credentials saved before that
|
|
11081
|
-
* deploy still carry `dashboard:` and the first 24 hex characters of
|
|
11082
|
-
* sha256(email).
|
|
11083
|
-
*
|
|
11084
|
-
* TODO(dcramer): Delete with its callers after that input and those
|
|
11085
|
-
* authorizations expire and no `dashboard:` credential keys remain.
|
|
11086
|
-
*/
|
|
11087
|
-
const USER_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
11088
|
-
/** Return the legacy web Actor id for one email. */
|
|
11089
|
-
function legacyWebActorUserId(email) {
|
|
11090
|
-
return `dashboard:${createHash("sha256").update(email.trim().toLowerCase()).digest("hex").slice(0, 24)}`;
|
|
11091
|
-
}
|
|
11092
|
-
/** Return every web Actor id that names this User, the User id first. */
|
|
11093
|
-
function webActorUserIds(user) {
|
|
11094
|
-
return [user.id, legacyWebActorUserId(user.email)];
|
|
11095
|
-
}
|
|
11096
|
-
/** Return the legacy web Actor id of a User id, when the User exists. */
|
|
11097
|
-
async function findLegacyWebActorUserId(userId) {
|
|
11098
|
-
if (!USER_ID_PATTERN.test(userId)) return void 0;
|
|
11099
|
-
const rows = await getDb().select({ email: juniorUsers.primaryEmailNormalized }).from(juniorUsers).where(eq(juniorUsers.id, userId)).limit(1);
|
|
11100
|
-
return rows[0] ? legacyWebActorUserId(rows[0].email) : void 0;
|
|
11101
|
-
}
|
|
11102
11360
|
// src/chat/credentials/legacy-web-tokens.ts
|
|
11103
11361
|
/**
|
|
11104
11362
|
* Move OAuth tokens saved under a legacy web Actor id to the User id.
|
|
@@ -11294,6 +11552,11 @@ function assertLeaseTransformsOwnedByProvider(provider, lease) {
|
|
|
11294
11552
|
* use that default for one request.
|
|
11295
11553
|
*/
|
|
11296
11554
|
async function selectSandboxEgressGrant(input) {
|
|
11555
|
+
if (input.userOAuthOnly) {
|
|
11556
|
+
const manifest = pluginCatalogRuntime.getDefinition(input.provider)?.manifest;
|
|
11557
|
+
if (!manifest?.credentials || !manifest.oauth) throw new Error(`Plugin "${input.provider}" has no user OAuth for user-only egress`);
|
|
11558
|
+
return defaultGrantForProvider(input);
|
|
11559
|
+
}
|
|
11297
11560
|
if (!hasEgressCredentialHooks(input.provider)) return defaultGrantForProvider(input);
|
|
11298
11561
|
const pluginGrant = await selectPluginGrant({
|
|
11299
11562
|
...input.bodyText !== void 0 ? { bodyText: input.bodyText } : void 0,
|
|
@@ -11720,6 +11983,7 @@ async function executeCredentialedEgressRequest(input) {
|
|
|
11720
11983
|
...isGitReceivePack(request.method, upstreamUrl) ? { gitPush: readGitPush(body) } : void 0,
|
|
11721
11984
|
...isGraphqlPost(request.method, upstreamUrl) ? { graphql: await readGraphqlRequest(body) } : void 0,
|
|
11722
11985
|
...operation ? { operation } : void 0,
|
|
11986
|
+
...input.userOAuthOnly ? { userOAuthOnly: true } : void 0,
|
|
11723
11987
|
provider,
|
|
11724
11988
|
method: request.method,
|
|
11725
11989
|
upstreamUrl
|
|
@@ -12423,6 +12687,7 @@ function parseAnswer(toolName, details, toolCallId) {
|
|
|
12423
12687
|
case "misconfigured": return { blocked: { missing: parsed.data.reason } };
|
|
12424
12688
|
}
|
|
12425
12689
|
}
|
|
12690
|
+
default: return;
|
|
12426
12691
|
}
|
|
12427
12692
|
}
|
|
12428
12693
|
/**
|
|
@@ -12538,7 +12803,7 @@ const inboundMessageSenderSchema = z.object({
|
|
|
12538
12803
|
}).strict();
|
|
12539
12804
|
/** Read the sender fields that one inbound message stores, if any. */
|
|
12540
12805
|
function readInboundMessageSender(message) {
|
|
12541
|
-
const parsed = inboundMessageSenderSchema.safeParse(message.input.metadata?.sender);
|
|
12806
|
+
const parsed = inboundMessageSenderSchema.safeParse(message.input.metadata?.["sender"]);
|
|
12542
12807
|
return parsed.success ? parsed.data : void 0;
|
|
12543
12808
|
}
|
|
12544
12809
|
/**
|
|
@@ -12730,10 +12995,10 @@ function normalizeActor(value) {
|
|
|
12730
12995
|
}
|
|
12731
12996
|
function normalizeLease(value) {
|
|
12732
12997
|
if (!isRecord$2(value)) return;
|
|
12733
|
-
const token = toOptionalString(value
|
|
12734
|
-
const acquiredAtMs = toOptionalNumber(value
|
|
12735
|
-
const lastCheckInAtMs = toOptionalNumber(value
|
|
12736
|
-
const expiresAtMs = toOptionalNumber(value
|
|
12998
|
+
const token = toOptionalString(value["token"]);
|
|
12999
|
+
const acquiredAtMs = toOptionalNumber(value["acquiredAtMs"]);
|
|
13000
|
+
const lastCheckInAtMs = toOptionalNumber(value["lastCheckInAtMs"]);
|
|
13001
|
+
const expiresAtMs = toOptionalNumber(value["expiresAtMs"]);
|
|
12737
13002
|
if (!token || typeof acquiredAtMs !== "number" || typeof lastCheckInAtMs !== "number" || typeof expiresAtMs !== "number") return;
|
|
12738
13003
|
return {
|
|
12739
13004
|
token,
|
|
@@ -12744,8 +13009,8 @@ function normalizeLease(value) {
|
|
|
12744
13009
|
}
|
|
12745
13010
|
function normalizeStop(value) {
|
|
12746
13011
|
if (!isRecord$2(value)) return;
|
|
12747
|
-
const inboundMessageIds = Array.isArray(value
|
|
12748
|
-
const runId = toOptionalString(value
|
|
13012
|
+
const inboundMessageIds = Array.isArray(value["inboundMessageIds"]) ? uniqueStrings(value["inboundMessageIds"].filter((id) => typeof id === "string")) : [];
|
|
13013
|
+
const runId = toOptionalString(value["runId"]);
|
|
12749
13014
|
return runId ? {
|
|
12750
13015
|
inboundMessageIds,
|
|
12751
13016
|
runId
|
|
@@ -12754,44 +13019,44 @@ function normalizeStop(value) {
|
|
|
12754
13019
|
/** Decode stored execution state. */
|
|
12755
13020
|
function normalizeExecution(conversationId, value) {
|
|
12756
13021
|
if (!isRecord$2(value)) return;
|
|
12757
|
-
const status = normalizeExecutionStatus(value
|
|
13022
|
+
const status = normalizeExecutionStatus(value["status"]);
|
|
12758
13023
|
if (!status) return;
|
|
12759
13024
|
const pendingMessages = [];
|
|
12760
|
-
if (Array.isArray(value
|
|
12761
|
-
for (const rawMessage of value
|
|
13025
|
+
if (Array.isArray(value["pendingMessages"])) {
|
|
13026
|
+
for (const rawMessage of value["pendingMessages"]) {
|
|
12762
13027
|
const message = normalizeMessage(rawMessage);
|
|
12763
13028
|
if (!message || message.conversationId !== conversationId) return;
|
|
12764
13029
|
pendingMessages.push(message);
|
|
12765
13030
|
}
|
|
12766
13031
|
pendingMessages.sort(compareMessages);
|
|
12767
13032
|
}
|
|
12768
|
-
const inboundMessageIds = Array.isArray(value
|
|
12769
|
-
const messageSenders = withMessageSenders(normalizeMessageSenders(value
|
|
13033
|
+
const inboundMessageIds = Array.isArray(value["inboundMessageIds"]) ? uniqueStrings(value["inboundMessageIds"].map((id) => typeof id === "string" ? id : void 0).filter((id) => Boolean(id))) : [];
|
|
13034
|
+
const messageSenders = withMessageSenders(normalizeMessageSenders(value["messageSenders"]), pendingMessages);
|
|
12770
13035
|
return {
|
|
12771
13036
|
status,
|
|
12772
13037
|
inboundMessageIds: uniqueStrings([...inboundMessageIds, ...pendingMessages.map((message) => message.inboundMessageId)]),
|
|
12773
13038
|
...messageSenders ? { messageSenders } : void 0,
|
|
12774
13039
|
pendingCount: pendingMessages.length,
|
|
12775
13040
|
pendingMessages,
|
|
12776
|
-
lease: normalizeLease(value
|
|
12777
|
-
lastCheckpointAtMs: toOptionalNumber(value
|
|
12778
|
-
lastEnqueuedAtMs: toOptionalNumber(value
|
|
12779
|
-
lastProgressAtMs: toOptionalNumber(value
|
|
12780
|
-
retryCount: toOptionalNumber(value
|
|
12781
|
-
runId: toOptionalString(value
|
|
12782
|
-
updatedAtMs: toOptionalNumber(value
|
|
13041
|
+
lease: normalizeLease(value["lease"]),
|
|
13042
|
+
lastCheckpointAtMs: toOptionalNumber(value["lastCheckpointAtMs"]),
|
|
13043
|
+
lastEnqueuedAtMs: toOptionalNumber(value["lastEnqueuedAtMs"]),
|
|
13044
|
+
lastProgressAtMs: toOptionalNumber(value["lastProgressAtMs"]),
|
|
13045
|
+
retryCount: toOptionalNumber(value["retryCount"]),
|
|
13046
|
+
runId: toOptionalString(value["runId"]),
|
|
13047
|
+
updatedAtMs: toOptionalNumber(value["updatedAtMs"])
|
|
12783
13048
|
};
|
|
12784
13049
|
}
|
|
12785
13050
|
/** Decode current conversation records. */
|
|
12786
13051
|
function normalizeConversation(conversationId, value) {
|
|
12787
|
-
if (!isRecord$2(value) || value
|
|
12788
|
-
const storedConversationId = toOptionalString(value
|
|
12789
|
-
const createdAtMs = toOptionalNumber(value
|
|
12790
|
-
const lastActivityAtMs = toOptionalNumber(value
|
|
12791
|
-
const updatedAtMs = toOptionalNumber(value
|
|
12792
|
-
const execution = normalizeExecution(conversationId, value
|
|
12793
|
-
const destination = value
|
|
12794
|
-
if (storedConversationId !== conversationId || typeof createdAtMs !== "number" || typeof lastActivityAtMs !== "number" || typeof updatedAtMs !== "number" || !execution || value
|
|
13052
|
+
if (!isRecord$2(value) || value["schemaVersion"] !== CONVERSATION_SCHEMA_VERSION) return;
|
|
13053
|
+
const storedConversationId = toOptionalString(value["conversationId"]);
|
|
13054
|
+
const createdAtMs = toOptionalNumber(value["createdAtMs"]);
|
|
13055
|
+
const lastActivityAtMs = toOptionalNumber(value["lastActivityAtMs"]);
|
|
13056
|
+
const updatedAtMs = toOptionalNumber(value["updatedAtMs"]);
|
|
13057
|
+
const execution = normalizeExecution(conversationId, value["execution"]);
|
|
13058
|
+
const destination = value["destination"] === void 0 ? void 0 : parseDestination(value["destination"]);
|
|
13059
|
+
if (storedConversationId !== conversationId || typeof createdAtMs !== "number" || typeof lastActivityAtMs !== "number" || typeof updatedAtMs !== "number" || !execution || value["destination"] !== void 0 && !destination) return;
|
|
12795
13060
|
if (execution.pendingMessages.length > 0 && execution.pendingMessages.some((message) => {
|
|
12796
13061
|
if (!message.destination) return false;
|
|
12797
13062
|
return !destination || !sameDestination(message.destination, destination);
|
|
@@ -12804,10 +13069,10 @@ function normalizeConversation(conversationId, value) {
|
|
|
12804
13069
|
updatedAtMs,
|
|
12805
13070
|
execution,
|
|
12806
13071
|
...destination ? { destination } : void 0,
|
|
12807
|
-
...toOptionalString(value
|
|
12808
|
-
...toOptionalString(value
|
|
12809
|
-
...normalizeActor(value
|
|
12810
|
-
...normalizeSource(value
|
|
13072
|
+
...toOptionalString(value["title"]) ? { title: toOptionalString(value["title"]) } : void 0,
|
|
13073
|
+
...toOptionalString(value["channelName"]) ? { channelName: toOptionalString(value["channelName"]) } : void 0,
|
|
13074
|
+
...normalizeActor(value["actor"]) ? { actor: normalizeActor(value["actor"]) } : void 0,
|
|
13075
|
+
...normalizeSource(value["source"]) ? { source: normalizeSource(value["source"]) } : void 0
|
|
12811
13076
|
};
|
|
12812
13077
|
}
|
|
12813
13078
|
function emptyConversation(args) {
|
|
@@ -12899,8 +13164,8 @@ async function withIndexLock(state, indexKey, callback) {
|
|
|
12899
13164
|
}
|
|
12900
13165
|
function normalizeIndexEntry(value) {
|
|
12901
13166
|
if (!isRecord$2(value)) return;
|
|
12902
|
-
const conversationId = toOptionalString(value
|
|
12903
|
-
const score = toOptionalNumber(value
|
|
13167
|
+
const conversationId = toOptionalString(value["conversationId"]);
|
|
13168
|
+
const score = toOptionalNumber(value["score"]);
|
|
12904
13169
|
if (!conversationId || typeof score !== "number") return;
|
|
12905
13170
|
return {
|
|
12906
13171
|
conversationId,
|
|
@@ -12932,7 +13197,8 @@ function parseRedisIndexEntries(values) {
|
|
|
12932
13197
|
const entries = [];
|
|
12933
13198
|
for (let index = 0; index < values.length; index += 2) {
|
|
12934
13199
|
const conversationId = toOptionalString(values[index]);
|
|
12935
|
-
const
|
|
13200
|
+
const rawScore = values[index + 1];
|
|
13201
|
+
const score = typeof rawScore === "number" ? rawScore : Number(rawScore);
|
|
12936
13202
|
if (!conversationId || !Number.isFinite(score)) continue;
|
|
12937
13203
|
entries.push({
|
|
12938
13204
|
conversationId,
|
|
@@ -14994,7 +15260,8 @@ function createPluginEgress(deps) {
|
|
|
14994
15260
|
operation,
|
|
14995
15261
|
provider: input.provider,
|
|
14996
15262
|
request: input.request,
|
|
14997
|
-
upstreamUrl
|
|
15263
|
+
upstreamUrl,
|
|
15264
|
+
...deps.userOAuthOnly ? { userOAuthOnly: true } : void 0
|
|
14998
15265
|
});
|
|
14999
15266
|
} };
|
|
15000
15267
|
}
|
|
@@ -15172,7 +15439,6 @@ function recordDeliveredAssistantMessage(args) {
|
|
|
15172
15439
|
},
|
|
15173
15440
|
meta: {
|
|
15174
15441
|
...objectCards?.length ? { objectCards } : void 0,
|
|
15175
|
-
...args.quiet ? { quiet: args.quiet } : void 0,
|
|
15176
15442
|
replied: true,
|
|
15177
15443
|
...args.source ? { source: args.source } : void 0
|
|
15178
15444
|
}
|
|
@@ -15543,10 +15809,10 @@ async function resolveConversationTitle(args) {
|
|
|
15543
15809
|
/** Serialize one in-memory message into its event-backed write shape. */
|
|
15544
15810
|
function toStoredConversationMessage(message) {
|
|
15545
15811
|
const meta = {};
|
|
15546
|
-
if (message.author) meta
|
|
15812
|
+
if (message.author) meta["author"] = message.author;
|
|
15547
15813
|
const { replied, ...restMeta } = message.meta ?? {};
|
|
15548
15814
|
Object.assign(meta, restMeta);
|
|
15549
|
-
if (replied === false) meta
|
|
15815
|
+
if (replied === false) meta["replied"] = false;
|
|
15550
15816
|
return {
|
|
15551
15817
|
messageId: message.id,
|
|
15552
15818
|
role: message.role,
|
|
@@ -16114,4 +16380,4 @@ async function recordGuardianActionReviewed(args) {
|
|
|
16114
16380
|
createdAtMs: Date.now()
|
|
16115
16381
|
}]);
|
|
16116
16382
|
}
|
|
16117
|
-
export { loadTurnCheckpoint as $, workspaceRepoCheckoutPath as $a, setWorkspaceSnapshotBuild as $i, webActorUserIds as $n, isSlackRequestTimeout as $o, EVERYONE_ASSIGNEE as $r, TurnSliceLimitExceededError as $t, latestConversationMessageSeq as A, updateSlackMessage as Aa, getDashboardLinkFilter as Ai, isStandaloneRuntimeContextMessage as An, readLatestConversationBrief as Ao, countReviewItemsNeedingUser as Ar, getConversationWorkStates as At, getAgentContextInputLimitTokens as B, isWorkspaceSnapshotNotReadyError as Ba, createPluginState as Bi, SCRIPT_TOOLS_SECTION_TAG as Bn, getSlackFileId as Bo, updateReviewItemContent as Br, recordConversationRetry as Bt, settleConversationTitleWork as C, getSlackMessagePermalink as Ca, bindSlackDirectCredentialSubject as Ci, getTerminalAssistantMessages as Cn, conversationIsMemberRoot as Co, readNotificationSchedule as Cr, piMessageFromHistoryItem as Cs, countPendingConversationMessages as Ct, estimateConversationMessagesTokens as D, postSlackMessage as Da, verifyTimerWatchCredentialSubject as Di, instructionTextForProjection as Dn, viewerMarksFromParticipant as Do, projectConversationMessages as Dr, dropPendingMessages as Dt, buildConversationContext as E, postSlackEphemeralMessage as Ea, verifySlackDirectCredentialSubject as Ei, hasTurnInput as En, conversationViewerMarks as Eo, isPausedBySlack as Er, setConfigDefaults as Es, drainConversationMailbox as Et, turnHasReply as F, isAlreadyExistsError as Fa, getDashboardTaskLink as Fi, retainRuntimeTurnContext as Fn, readConversationMessageEventSeq as Fo, listReplyActionItems as Fr, listActiveConversationIds as Ft, AuthPausePersistenceError as G, createSandboxEgressCredentialToken as Ga, getWorkspaceByName as Gi, readParentAgentTask as Gn, slackAttachmentsVersionQuery as Go, canUserReadReviewItem as Gr, startConversationWork as Gt, PluginCredentialFailureError as H, clearSandboxEgressSignals as Ha, createWorkspace as Hi, TURN_CONTEXT_TAG as Hn, readAttachmentVisionSummary as Ho, canActOnReviewItem as Hr, releaseInboundMessage as Ht, upsertConversationMessage as I, throwSandboxOperationError as Ia, isDashboardLink as Ii, stripRuntimeTurnContext as In, buildSentryConversationUrl as Io, listWaitingConversations as Ir, markConversationWorkEnqueued as It, abandonReplacedPendingAuth as J, buildSandboxEgressNetworkPolicy as Ja, updateWorkspace as Ji, renderUntrustedTag as Jn, getFilePermalink as Jo, requireReviewItemAssignees as Jr, takeDeferredConversationMove as Jt, AuthorizationFlowDisabledError as K, parseSandboxEgressCredentialToken as Ka, listWorkspaces as Ki, renderChildTag as Kn, SlackActionError as Ko, isOnlyAssignee as Kr, steerWebPendingMessages as Kt, calculateContextCompactionTargetTokens as L, wrapSandboxSetupError as La, parseDashboardConversationLink as Li, trimTrailingAssistantMessages as Ln, FORK_INSTRUCTIONS as Lo, reviewItemsNeedingUserVersionQuery as Lr, moveIdleConversationDestination as Lt, normalizeConversationText as M, slackEntitySchema as Ma, getDashboardPersonLink as Mi, isToolResultMessage as Mn, readConversationEventPageAfter as Mo, getOpenReviewItemByDedupeKey as Mr, hasRunnableConversationWork as Mt, recordDeliveredAssistantMessage as N, slackExternalRefIdSchema as Na, getDashboardReviewItemLink as Ni, latestTurnContextSection as Nn, readConversationEventPageAround as No, getReviewItem as Nr, isFinalAttempt as Nt, getConversationMessageSlackTs as O, removeReactionFromMessage as Oa, JUNIOR_THREAD_STATE_TTL_MS as Oi, isAssistantMessage as On, createPluginConversationEvents as Oo, REVIEW_ITEM_REPLIED_REASON as Or, getConversation as Ot, trimConversationMessages as P, isAbortError as Pa, getDashboardSettingsLink as Pi, normalizeToolNameFromResult as Pn, readConversationLastEventSeq as Po, insertReviewItem as Pr, isInvalidConversationRecordError as Pt, continuableMessages as Q, tryWorkspaceRepoCheckoutPath as Qa, setWorkspaceSnapshot as Qi, findLegacyWebActorUserId as Qn, isDmChannel as Qo, reviewItemReaderForUserInConversation as Qr, TurnBudgetExceededError as Qt, getAgentBackgroundCompactionMarkTokens as R, WorkspaceSnapshotNotReadyError as Ra, parseDashboardPersonLink as Ri, CAPABILITY_SECTION_TAG as Rn, loadForkHistory as Ro, searchReviewItems as Rr, pruneActiveConversation as Rt, resolveConversationTitle as S, deleteSlackMessage as Sa, bindScheduledAutomationCredentialSubject as Si, getPiMessageRole as Sn, conversationHasParticipantUser as So, listPushSubscriptions as Sr, historyItemFromPiMessage as Ss, completeConversationWork as St, resolveTaskTitle as T, openSlackModal as Ta, verifyScheduledAutomationCredentialSubject as Ti, hasRuntimeTurnContext as Tn, conversationPinnedForUser as To, savePushSubscription as Tr, getConfigDefaults as Ts, deferConversationMove as Tt, createPluginAuthOrchestration as U, consumeSandboxEgressAuthRequiredSignal as Ua, deleteWorkspace as Ui, escapeClosingTags as Un, readSlackAttachmentSource as Uo, canAgentChangeReviewItem as Ur, requestAnotherSlice as Ut, createPluginEgress as V, workspaceSnapshotNotReadyUserMessage as Va, renderToolResultNudge as Vi, SESSION_CONTEXT_SECTION_TAG as Vn, matchSlackAttachments as Vo, PLUGIN_REVIEW_ITEM_KEY_PREFIX as Vr, releaseConversationWork as Vt, authorizationId as W, consumeSandboxEgressPermissionDeniedSignal as Wa, getWorkspace as Wi, escapeTagText as Wn, recordSlackAttachment as Wo, canReadReviewItem as Wr, requestConversationWork as Wt, clearPendingAuth as X, normalizeSandboxEgressTracePropagationDomains as Xa, invalidateReadySnapshot as Xi, SANDBOX_EGRESS_AUTH_REQUIRED_MARKER as Xn, getSlackClient as Xo, reviewItemNeedsSomeone as Xr, GATED_TURN_LIMIT_WRAP_UP_MESSAGE as Xt, canReusePendingAuthLink as Y, resolveSandboxCommandEnvironment as Ya, WorkspaceValidationError as Yi, tagJson as Yn, getHeaderString as Yo, requireReviewItemLinks as Yr, readInboundMessageSender as Yt, getConversationPendingAuth as Z, SANDBOX_RUNTIME as Za, loadSnapshotsForProfile as Zi, createUserTokenStore as Zn, isConversationScopedChannel as Zo, reviewItemReaderForUser as Zr, TURN_LIMIT_WRAP_UP_MESSAGE as Zt, appendConversationMessages as _, slackMention as _a, findMatchingWatches as _i, CODE_MODE_CALL_STATUS_TEXT as _n, createPluginLogger as _o, setBriefsConfig as _r, credentialAuditAttributes as _s, checkInConversationWork as _t, loadProjection as a, isVercelSandboxEgressRequest as aa, resolveChannelCapabilities as ai, isAnswerToolName as an, SANDBOX_COMMAND_PATH as ao, createPluginHookRunner as ar, getWorkspaceTeamId as as, failTurnRecord as at, persistConversationMessages as b, truncateStatusText as ba, takeDueTimerWatches as bi, persistWithRetry as bn, createConversationAccessReader as bo, resolveNotificationTimezone as br, createDurableLocationConfigurationService as bs, clearExpiredConversationLease as bt, recordAgentsInstructionsUpdated as c, formatProviderLabel as ca, RESOURCE_SUBSCRIPTION_MAX_TTL_MS as ci, replyTextSchema as cn, SANDBOX_SKILLS_ROOT as co, getPluginSlackConversationLink as cr, resolveRootVisibility as cs, listTurnSummaries as ct, recordAuthorizationCompleted as d, startOAuthFlow as da, cancelSubscriptions as di, sanitizeAssistantText as dn, sandboxSkillFile as do, getPluginUserPromptContributions as dr, listConversationAnnotations as ds, CONVERSATION_WORK_STALE_ENQUEUE_MS as dt, create as ea, activeParticipantUserIds as ei, TurnToolCallLimitExceededError as en, ToolInputError as eo, getOAuthAccountProviders as er, normalizeSlackConversationId as es, lostWorkerBeforeFirstSave as et, recordAuthorizationRequested as f, SLACK_USER_MENTION_RE as fa, cancelWatch as fi, NO_REPLY_TOOL_NAME as fn, sandboxSkillPathResolution as fo, getPlugins as fr, listConversationAnnotationsById as fs, ackMessages as ft, recordToolExecutionStarted as g, normalizeSlackStatusText as ga, deliverWatch as gi, CODEMODE_TOOL_NAME as gn, createPluginModelCostRecorder as go, registration_exports as gr, lookupSlackUserNames as gs, cancelHumanFacingPendingMessages as gt, recordSubscribedReplyRoute as h, normalizeSlackReplyMarkdown as ha, createWatch as hi, readNoReply as hn, runNonInteractiveCommand as ho, coreTaskRegistrations as hr, lookupSlackUser as hs, beginConversationResume as ht, loadConversationProjection as i, getSandboxProvider as ia, createCodeChangePublisher as ii, REPLY_TOOL_NAME as in, createPluginModel as io, createPluginEventPublisher as ir, sleep$2 as is, completeTurnRecord as it, markConversationMessage as j, uploadFilesToConversation as ja, getDashboardObjectIconLink as ji, isToolResultError as jn, readConversationEventPage as jo, dismissOpenReviewItems as jr, hasConversationStop as jt, isHumanConversationMessage as k, unfurlSlackLinks as ka, getDashboardConversationLink as ki, isContinuablePiBoundary as kn, readConversationBriefThrough as ko, closeReviewItem as kr, getConversationWorkState as kt, recordAttachmentsDelivered as l, parseOAuthStatePayload as la, RESOURCE_WATCH_TOOL_SOURCE as li, decideReply as ln, SANDBOX_WORKSPACE_ROOT as lo, getPluginSystemPromptContributions as lr, saveObjectAnnotations as ls, recordTurnSummary as lt, recordMcpProviderConnected as m, formatSlackLink as ma, createTimerWatch as mi, isLegacyNoReplyMarker as mn, buildNonInteractiveShellScript as mo, validatePlugins as mr, resolveUserTimezone as ms, appendInboundMessage as mt, commitMessages as n, isStale as na, resolveAssignee as ni, createTurnLimitGate as nn, PluginToolDeniedError as no, agent_hooks_exports as nr, streamPrivateSlackFile as ns, saveTurnCheckpoint as nt, loadTurnProjection as o, proxyVercelSandboxEgressRequest as oa, getSlackToolContext as oi, readTurnAnswer as on, SANDBOX_DATA_ROOT as oo, getPluginApiRoutes as or, runWithWorkspaceTeamId as os, getStoredTurnFields as ot, recordGuardianActionReviewed as p, escapeSlackMrkdwnText as pa, collectEventMatchKeys as pi, findLegacyNoReplyMarker as pn, buildCommandScript as po, setPlugins as pr, defaultTimezone as ps, appendExclusiveInboundMessage as pt, AuthorizationPauseError as q, sandboxEgressSignalsResponseSchema as qa, listWorkspacesByRepository as qi, renderTag as qn, downloadPrivateSlackFile as qo, readReviewItemAgentScope as qr, stopConversationWork as qt, loadConnectedMcpProviders as r, ensureDockerDaemon as ra, resolveAssignees as ri, isTurnExecutionLimitExceededError as rn, createPluginEmbedder as ro, applyPluginFormatMarkdown as rr, withSlackRetries as rs, abandonTurnRecord as rt, openConversationProjection as s, deliverOAuthAuthorization as sa, RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS as si, remindMissingAnswer as sn, SANDBOX_REPOS_ROOT as so, getPluginRoutes as sr, AttachmentSourceUnavailableError as ss, getTurnRecord as st, commitAcceptedReply as t, hash as ta, automationCreatorUserId as ti, buildTurnErrorResponse as tn, isToolInputError as to, resolvePluginOAuthAccount as tr, runWithSlackInstallationToken as ts, pauseLostWorkerTurn as tt, recordAuthenticationLinked as u, resolveBaseUrl as ua, STOP_WATCHING_TOOL_NAME as ui, getAssistantReplyText as un, sandboxSkillDir as uo, getPluginTools as ur, createPluginAnnotations as us, CONVERSATION_WORK_CHECK_IN_INTERVAL_MS as ut, hydrateConversationMessages as v, slackMentionedUserIds as va, getWatch as vi, REPORT_BLOCKED_TOOL_NAME as vn, canAccessConversation as vo, readWebPushConfig as vr, credentialAuditSource as vs, claimInboundMessage as vt, fallbackShortTitle as w, openSlackDirectMessage as wa, verifyEventAutomationCredentialSubject as wi, getUserMessageInstructionText as wn, conversationIsNotUnsubscribedRoot as wo, saveNotificationSchedule as wr, projectConversationEvents$1 as ws, deadLetterAttempt as wt, toStoredConversationMessage as x, addReactionToMessage as xa, bindEventAutomationCredentialSubject as xi, extractAssistantText as xn, readConversationAccessFromSql as xo, deletePushSubscription as xr, configValueSchema as xs, completeConversationStop as xt, persistConversationMessageWindow as y, wrapBareSlackUserIds as ya, listWatches as yi, readBlockedReport as yn, canAddConversationMessages as yo, sendPushNotificationToUser as yr, createPluginCache as ys, clearConsumedConversationWake as yt, getAgentContextCompactionTriggerTokens as z, getWorkspaceSnapshotNotReadyError as za, setDashboardConversationLinkOptions as zi, REQUEST_CONTEXT_SECTION_TAG as zn, notInheritedByForkChild as zo, takeReviewItem as zr, recordAttemptFailure as zt };
|
|
16383
|
+
export { loadTurnCheckpoint as $, SANDBOX_RUNTIME as $a, loadSnapshotsForProfile as $i, resolvePluginOAuthAccount as $n, isConversationScopedChannel as $o, reviewItemReaderForUser as $r, TurnSliceLimitExceededError as $t, latestConversationMessageSeq as A, removeReactionFromMessage as Aa, JUNIOR_THREAD_STATE_TTL_MS as Ai, isStandaloneRuntimeContextMessage as An, createPluginConversationEvents as Ao, countOpenReviewItemsForUser as Ar, setConfigDefaults as As, getConversationWorkStates as At, getAgentContextInputLimitTokens as B, WorkspaceSnapshotNotReadyError as Ba, parseDashboardPersonLink as Bi, SCRIPT_TOOLS_SECTION_TAG as Bn, loadForkHistory as Bo, takeReviewItem as Br, recordConversationRetry as Bt, settleConversationTitleWork as C, addReactionToMessage as Ca, bindEventAutomationCredentialSubject as Ci, getTerminalAssistantMessages as Cn, readConversationAccessFromSql as Co, saveNotificationSchedule as Cr, createPluginCache as Cs, countPendingConversationMessages as Ct, estimateConversationMessagesTokens as D, openSlackModal as Da, verifyScheduledAutomationCredentialSubject as Di, instructionTextForProjection as Dn, conversationPinnedForUser as Do, createPluginReviewItems as Dr, piMessageFromHistoryItem as Ds, dropPendingMessages as Dt, buildConversationContext as E, openSlackDirectMessage as Ea, verifyEventAutomationCredentialSubject as Ei, hasTurnInput as En, conversationIsNotUnsubscribedRoot as Eo, projectConversationMessages as Er, historyItemFromPiMessage as Es, drainConversationMailbox as Et, turnHasReply as F, slackExternalRefIdSchema as Fa, getDashboardReviewItemLink as Fi, retainRuntimeTurnContext as Fn, readConversationEventPageAround as Fo, insertReviewItem as Fr, listActiveConversationIds as Ft, AuthPausePersistenceError as G, consumeSandboxEgressAuthRequiredSignal as Ga, deleteWorkspace as Gi, readParentAgentTask as Gn, readSlackAttachmentSource as Go, canReadReviewItem as Gr, startConversationWork as Gt, PluginCredentialFailureError as H, isWorkspaceSnapshotNotReadyError as Ha, createPluginState as Hi, TURN_CONTEXT_TAG as Hn, getSlackFileId as Ho, PLUGIN_REVIEW_ITEM_KEY_PREFIX as Hr, releaseInboundMessage as Ht, upsertConversationMessage as I, isAbortError as Ia, getDashboardSettingsLink as Ii, stripRuntimeTurnContext as In, readConversationLastEventSeq as Io, listReplyActionItems as Ir, markConversationWorkEnqueued as It, abandonReplacedPendingAuth as J, parseSandboxEgressCredentialToken as Ja, listWorkspaces as Ji, renderUntrustedTag as Jn, SlackActionError as Jo, itemNeedsUser as Jr, takeDeferredConversationMove as Jt, AuthorizationFlowDisabledError as K, consumeSandboxEgressPermissionDeniedSignal as Ka, getWorkspace as Ki, renderChildTag as Kn, recordSlackAttachment as Ko, canUserReadReviewItem as Kr, steerWebPendingMessages as Kt, calculateContextCompactionTargetTokens as L, isAlreadyExistsError as La, getDashboardTaskLink as Li, trimTrailingAssistantMessages as Ln, readConversationMessageEventSeq as Lo, listWaitingConversations as Lr, moveIdleConversationDestination as Lt, normalizeConversationText as M, updateSlackMessage as Ma, getDashboardLinkFilter as Mi, isToolResultMessage as Mn, readLatestConversationBrief as Mo, dismissOpenReviewItems as Mr, hasRunnableConversationWork as Mt, recordDeliveredAssistantMessage as N, uploadFilesToConversation as Na, getDashboardObjectIconLink as Ni, latestTurnContextSection as Nn, readConversationEventPage as No, getOpenReviewItemByDedupeKey as Nr, isFinalAttempt as Nt, getConversationMessageSlackTs as O, postSlackEphemeralMessage as Oa, verifySlackDirectCredentialSubject as Oi, isAssistantMessage as On, conversationViewerMarks as Oo, REVIEW_ITEM_REPLIED_REASON as Or, projectConversationEvents$1 as Os, getConversation as Ot, trimConversationMessages as P, slackEntitySchema as Pa, getDashboardPersonLink as Pi, normalizeToolNameFromResult as Pn, readConversationEventPageAfter as Po, getReviewItem as Pr, isInvalidConversationRecordError as Pt, continuableMessages as Q, normalizeSandboxEgressTracePropagationDomains as Qa, invalidateReadySnapshot as Qi, getOAuthAccountProviders as Qn, getSlackClient as Qo, reviewItemNeedsSomeone as Qr, TurnBudgetExceededError as Qt, getAgentBackgroundCompactionMarkTokens as R, throwSandboxOperationError as Ra, isDashboardLink as Ri, CAPABILITY_SECTION_TAG as Rn, buildSentryConversationUrl as Ro, reviewItemsNeedingUserVersionQuery as Rr, pruneActiveConversation as Rt, resolveConversationTitle as S, truncateStatusText as Sa, takeDueTimerWatches as Si, getPiMessageRole as Sn, createConversationAccessReader as So, readNotificationSchedule as Sr, credentialAuditSource as Ss, completeConversationWork as St, resolveTaskTitle as T, getSlackMessagePermalink as Ta, bindSlackDirectCredentialSubject as Ti, hasRuntimeTurnContext as Tn, conversationIsMemberRoot as To, isPausedBySlack as Tr, configValueSchema as Ts, deferConversationMove as Tt, createPluginAuthOrchestration as U, workspaceSnapshotNotReadyUserMessage as Ua, renderToolResultNudge as Ui, escapeClosingTags as Un, matchSlackAttachments as Uo, canActOnReviewItem as Ur, requestAnotherSlice as Ut, createPluginEgress as V, getWorkspaceSnapshotNotReadyError as Va, setDashboardConversationLinkOptions as Vi, SESSION_CONTEXT_SECTION_TAG as Vn, notInheritedByForkChild as Vo, updateReviewItemContent as Vr, releaseConversationWork as Vt, authorizationId as W, clearSandboxEgressSignals as Wa, createWorkspace as Wi, escapeTagText as Wn, readAttachmentVisionSummary as Wo, canAgentChangeReviewItem as Wr, requestConversationWork as Wt, clearPendingAuth as X, buildSandboxEgressNetworkPolicy as Xa, updateWorkspace as Xi, SANDBOX_EGRESS_AUTH_REQUIRED_MARKER as Xn, getFilePermalink as Xo, requireReviewItemAssignees as Xr, GATED_TURN_LIMIT_WRAP_UP_MESSAGE as Xt, canReusePendingAuthLink as Y, sandboxEgressSignalsResponseSchema as Ya, listWorkspacesByRepository as Yi, tagJson as Yn, downloadPrivateSlackFile as Yo, readReviewItemAgentScope as Yr, readInboundMessageSender as Yt, getConversationPendingAuth as Z, resolveSandboxCommandEnvironment as Za, WorkspaceValidationError as Zi, createUserTokenStore as Zn, getHeaderString as Zo, requireReviewItemLinks as Zr, TURN_LIMIT_WRAP_UP_MESSAGE as Zt, appendConversationMessages as _, normalizeSlackReplyMarkdown as _a, createWatch as _i, CODE_MODE_CALL_STATUS_TEXT as _n, runNonInteractiveCommand as _o, readWebPushConfig as _r, defaultTimezone as _s, checkInConversationWork as _t, loadProjection as a, ensureDockerDaemon as aa, resolveAssignees as ai, isAnswerToolName as an, createPluginEmbedder as ao, getPluginRoutes as ar, withSlackRetries as as, failTurnRecord as at, persistConversationMessages as b, slackMentionedUserIds as ba, getWatch as bi, persistWithRetry as bn, canAccessConversation as bo, deletePushSubscription as br, lookupSlackUserNames as bs, clearExpiredConversationLease as bt, recordAgentsInstructionsUpdated as c, proxyVercelSandboxEgressRequest as ca, getSlackToolContext as ci, replyTextSchema as cn, SANDBOX_DATA_ROOT as co, getPluginTools as cr, runWithWorkspaceTeamId as cs, listTurnSummaries as ct, recordAuthorizationCompleted as d, parseOAuthStatePayload as da, RESOURCE_WATCH_TOOL_SOURCE as di, sanitizeAssistantText as dn, SANDBOX_WORKSPACE_ROOT as do, getStaticPluginToolDefinitions as dr, searchConversations as ds, CONVERSATION_WORK_STALE_ENQUEUE_MS as dt, setWorkspaceSnapshot as ea, reviewItemReaderForUserInConversation as ei, TurnToolCallLimitExceededError as en, tryWorkspaceRepoCheckoutPath as eo, agent_hooks_exports as er, isDmChannel as es, lostWorkerBeforeFirstSave as et, recordAuthorizationRequested as f, resolveBaseUrl as fa, STOP_WATCHING_TOOL_NAME as fi, NO_REPLY_TOOL_NAME as fn, sandboxSkillDir as fo, setPlugins as fr, createConversationEmbedder as fs, ackMessages as ft, recordToolExecutionStarted as g, formatSlackLink as ga, createTimerWatch as gi, CODEMODE_TOOL_NAME as gn, buildNonInteractiveShellScript as go, setBriefsConfig as gr, listConversationAnnotationsById as gs, cancelHumanFacingPendingMessages as gt, recordSubscribedReplyRoute as h, escapeSlackMrkdwnText as ha, collectEventMatchKeys as hi, readNoReply as hn, buildCommandScript as ho, registration_exports as hr, listConversationAnnotations as hs, beginConversationResume as ht, loadConversationProjection as i, isStale as ia, resolveAssignee as ii, REPLY_TOOL_NAME as in, PluginToolDeniedError as io, getPluginApiRoutes as ir, streamPrivateSlackFile as is, completeTurnRecord as it, markConversationMessage as j, unfurlSlackLinks as ja, getDashboardConversationLink as ji, isToolResultError as jn, readConversationBriefThrough as jo, countReviewItemsNeedingUserBySubject as jr, hasConversationStop as jt, isHumanConversationMessage as k, postSlackMessage as ka, verifyTimerWatchCredentialSubject as ki, isContinuablePiBoundary as kn, viewerMarksFromParticipant as ko, closeReviewItem as kr, getConfigDefaults as ks, getConversationWorkState as kt, recordAttachmentsDelivered as l, deliverOAuthAuthorization as la, RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS as li, decideReply as ln, SANDBOX_REPOS_ROOT as lo, getPluginUserPromptContributions as lr, AttachmentSourceUnavailableError as ls, recordTurnSummary as lt, recordMcpProviderConnected as m, SLACK_USER_MENTION_RE as ma, cancelWatch as mi, isLegacyNoReplyMarker as mn, sandboxSkillPathResolution as mo, coreTaskRegistrations as mr, createPluginAnnotations as ms, appendInboundMessage as mt, commitMessages as n, create as na, activeParticipantUserIds as ni, createTurnLimitGate as nn, ToolInputError as no, createPluginEventPublisher as nr, normalizeSlackConversationId as ns, saveTurnCheckpoint as nt, loadTurnProjection as o, getSandboxProvider as oa, createCodeChangePublisher as oi, readTurnAnswer as on, createPluginModel as oo, getPluginSlackConversationLink as or, sleep$2 as os, getStoredTurnFields as ot, recordGuardianActionReviewed as p, startOAuthFlow as pa, cancelSubscriptions as pi, findLegacyNoReplyMarker as pn, sandboxSkillFile as po, validatePlugins as pr, saveObjectAnnotations as ps, appendExclusiveInboundMessage as pt, AuthorizationPauseError as q, createSandboxEgressCredentialToken as qa, getWorkspaceByName as qi, renderTag as qn, slackAttachmentsVersionQuery as qo, isOnlyAssignee as qr, stopConversationWork as qt, loadConnectedMcpProviders as r, hash as ra, automationCreatorUserId as ri, isTurnExecutionLimitExceededError as rn, isToolInputError as ro, createPluginHookRunner as rr, runWithSlackInstallationToken as rs, abandonTurnRecord as rt, openConversationProjection as s, isVercelSandboxEgressRequest as sa, resolveChannelCapabilities as si, remindMissingAnswer as sn, SANDBOX_COMMAND_PATH as so, getPluginSystemPromptContributions as sr, getWorkspaceTeamId as ss, getTurnRecord as st, commitAcceptedReply as t, setWorkspaceSnapshotBuild as ta, EVERYONE_ASSIGNEE as ti, buildTurnErrorResponse as tn, workspaceRepoCheckoutPath as to, applyPluginFormatMarkdown as tr, isSlackRequestTimeout as ts, pauseLostWorkerTurn as tt, recordAuthenticationLinked as u, formatProviderLabel as ua, RESOURCE_SUBSCRIPTION_MAX_TTL_MS as ui, getAssistantReplyText as un, SANDBOX_SKILLS_ROOT as uo, getPlugins as ur, resolveRootVisibility as us, CONVERSATION_WORK_CHECK_IN_INTERVAL_MS as ut, hydrateConversationMessages as v, normalizeSlackStatusText as va, deliverWatch as vi, REPORT_BLOCKED_TOOL_NAME as vn, createPluginModelCostRecorder as vo, sendPushNotificationToUser as vr, resolveUserTimezone as vs, claimInboundMessage as vt, fallbackShortTitle as w, deleteSlackMessage as wa, bindScheduledAutomationCredentialSubject as wi, getUserMessageInstructionText as wn, conversationHasParticipantUser as wo, savePushSubscription as wr, createDurableLocationConfigurationService as ws, deadLetterAttempt as wt, toStoredConversationMessage as x, wrapBareSlackUserIds as xa, listWatches as xi, extractAssistantText as xn, canAddConversationMessages as xo, listPushSubscriptions as xr, credentialAuditAttributes as xs, completeConversationStop as xt, persistConversationMessageWindow as y, slackMention as ya, findMatchingWatches as yi, readBlockedReport as yn, createPluginLogger as yo, resolveNotificationTimezone as yr, lookupSlackUser as ys, clearConsumedConversationWake as yt, getAgentContextCompactionTriggerTokens as z, wrapSandboxSetupError as za, parseDashboardConversationLink as zi, REQUEST_CONTEXT_SECTION_TAG as zn, FORK_INSTRUCTIONS as zo, searchReviewItems as zr, recordAttemptFailure as zt };
|