@sentry/junior 0.317.0 → 0.318.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{admin-CAugg87B.js → admin-UOHix_5P.js} +1 -1
- package/dist/{agent-runner-AjrEV6Qe.js → agent-runner-DeYymwh2.js} +183 -113
- package/dist/{agent-update-delivery-B_YIZcgf.js → agent-update-delivery-DH8bx7jU.js} +5 -5
- package/dist/api/schema.d.ts +42 -28
- package/dist/api/schema.js +3 -3
- package/dist/api.js +38 -41
- package/dist/{app-MoNAsVV5.d.ts → app-DKAOuaoC.d.ts} +4 -9
- package/dist/app.d.ts +1 -1
- package/dist/app.js +62 -91
- package/dist/{thread-context-CqZDKErp.js → auth-pause-state-f9hJM_zO.js} +6 -59
- package/dist/{catalog-runtime-DfSpJZdY.js → catalog-runtime-BfdAnztW.js} +1 -1
- package/dist/{channel-access-j-YAVYK4.js → channel-access-A0de5lRv.js} +1 -1
- package/dist/{chat-core-engine-aH85nEHv.js → chat-core-engine-D3Wd7f5n.js} +6 -6
- package/dist/{child-message-DHjQLEd1.js → child-message-peFWLcCZ.js} +1 -5
- package/dist/cli/chat.js +32 -24
- package/dist/cli/check.js +4 -4
- package/dist/cli/main.js +2 -2
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +4 -5
- package/dist/cli/upgrade.js +3 -3
- package/dist/context-BKF_5zzI.js +1833 -0
- package/dist/{continue-in-slack-D-FZ8Fin.js → continue-in-slack-YxwMQVeR.js} +3 -2
- package/dist/{conversation-feed--9S0_PXL.js → conversation-feed-Cj7IuBtM.js} +1 -1
- package/dist/{conversation-privacy-B1uXn5sf.js → conversation-privacy-Cr_dNW1p.js} +1 -1
- package/dist/{conversation-turn-BUE_7xaN.js → conversation-turn-Bru4w_FD.js} +111 -18
- package/dist/{create-DoDIYgtZ.js → create-Btl1y1rq.js} +13 -15
- package/dist/{credential-sync-BJOqGnjV.js → credential-sync-DTarZ63K.js} +17 -17
- package/dist/{db-BFmyYZtJ.js → db-of6e3sGt.js} +1943 -1189
- package/dist/{deployment-DXq9ZLU4.js → deployment-C0qXa0FD.js} +1 -1
- package/dist/{engine-context-CgQ7mlHt.js → engine-context-C_QL_bMQ.js} +52 -21
- package/dist/{html-B3VKTGbJ.js → html-9_pS9SjY.js} +6 -6
- package/dist/instrumentation.js +2 -2
- package/dist/{job-runner-A1lCkybD.js → job-runner-B2XEvpif.js} +11 -12
- package/dist/{lineage-Bktb0UcV.js → lineage-nh4z9iQN.js} +1 -1
- package/dist/{list-Bxvg5wXf.js → list-HRP3TIRl.js} +45 -37
- package/dist/{logging--smS7XRK.js → logging-BnOG0qz2.js} +3 -49
- package/dist/{mailbox-turn-uSXhUFc9.js → mailbox-turn-Byrry9o1.js} +220 -223
- package/dist/{parent-result-Ck1rFYRQ.js → markers-CTTtJqYn.js} +84 -52
- package/dist/{message-BNenhsmB.js → message-BRUuLgrY.js} +9 -10
- package/dist/{model-input-BReSnwHp.js → model-input-CFC62mf-.js} +2 -2
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +4 -4
- package/dist/{oauth-callback-server-CE4soEIY.js → oauth-callback-server-CjnnUr4o.js} +2 -2
- package/dist/{oauth-relay-C36gX1gH.js → oauth-relay-BvHFH0fV.js} +1 -1
- package/dist/{profile-BQ-iBDsZ.js → profile-iHw1uu32.js} +7 -7
- package/dist/{prompt-Dv7gkpD6.js → prompt-DEkStuxG.js} +10 -10
- package/dist/{registry-iXMT5Jmh.js → registry-Cl7Labpe.js} +7 -7
- package/dist/{reports-WKHfGTsU.js → reports-C1d9azyV.js} +2 -2
- package/dist/{resolve-tony4ibz.js → resolve-DC6zBuDV.js} +5 -5
- package/dist/{result-Bta_dlWa.js → result-DxewDuXb.js} +12 -12
- package/dist/{run-conversation-DL6ru7iW.js → run-conversation-Cz2ubZK-.js} +6 -5
- package/dist/{runner-BstDRbD9.js → runner-99YxVN_r.js} +10 -18
- package/dist/{sandbox-egress-signals-oSJMJOnn.js → sandbox-egress-signals-CgoX5CTI.js} +1 -1
- package/dist/{schema-DfqrHACA.js → schema-BTojNBr5.js} +2 -2
- package/dist/{sender-actors-CPglLd5R.js → sender-actors-77zTQbSG.js} +7 -6
- package/dist/{service-account-CTV_jaNu.js → service-account-YDCPSByj.js} +3 -3
- package/dist/{skills-BCEU41zM.js → skills-CleC0Hze.js} +5 -4
- package/dist/{slack-conversation-unfurl-DxVmhbGP.js → slack-conversation-unfurl-BNQLC12R.js} +7 -7
- package/dist/{spawn-frczVPIr.js → spawn-DuZfodPa.js} +7 -10
- package/dist/{system-prompt-table-CiXy0eNR.js → system-prompt-table-Ci6Ck4gk.js} +2 -2
- package/dist/{task-runner-C9Yc2_ae.js → task-runner-BJ9Up3bG.js} +18 -15
- package/dist/{topics-SRN7IVX-.js → topics-BoCkoPJJ.js} +2 -5
- package/dist/{turn-membership-CENFf3kI.js → turn-membership-VT7XZh-L.js} +4 -4
- package/dist/{turn-wake-BhloiI2h.js → turn-wake-C7HeLHAM.js} +4 -4
- package/dist/{types-C4iC-IMC.js → types-DCzTAA63.js} +55 -49
- package/dist/{users-ByG5RCEJ.js → users-Cb9c1k9q.js} +1 -1
- package/dist/{validation-8gjfR91V.js → validation-BiUmWPhy.js} +1 -1
- package/dist/{version-BeZhWWBE.js → version-VEXiEcZu.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{worker-BqMQQNRk.js → worker-ChWYQdhm.js} +5 -5
- package/migrations/20261127002500_turn_discarded_usage/migration.sql +2 -0
- package/migrations/20261127002500_turn_discarded_usage/snapshot.json +73 -0
- package/package.json +5 -5
- package/dist/config-CHQ8X251.js +0 -2422
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { $
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { h as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { f as createWriteFileTool, g as createEditFileTool, m as createReadFileTool, u as createSystemTimeTool, y as createBashTool } from "./job-runner-
|
|
10
|
-
import { _ as normalizeToolResult, c as buildSandboxInput, g as createAgentSandbox, v as capToolResult } from "./agent-runner-
|
|
1
|
+
import { $ as resolveGatewayModel, L as botConfig, n as credentialContextForActor } from "./context-BKF_5zzI.js";
|
|
2
|
+
import { Ad as juniorTurnOutbox, Br as QUEUE_SIGNATURE_MAX_AGE_MS, Hr as verifyQueueMessage, Ja as usdToMicroUsd, Ku as gatewayRoutingAttributes, M as locationSchema, Ur as getQueueProvider, Vr as signQueueMessage, _ as unseenEvents, a as getDb, af as juniorTurns, dd as agentTurnCostUsd, fd as agentTurnTotalTokens, g as readEventCursor, h as insertEventRows, hf as juniorConversations, id as getGatewayApiKey, if as juniorConversationEvents, jd as juniorTurnInbox, o as getSqlExecutor, ps as resolveRootVisibility, qa as microUsdToUsd, ud as addAgentTurnUsage, v as withConversationEventLock, zu as requestPrefixAttributes } from "./db-of6e3sGt.js";
|
|
3
|
+
import { Kn as usageTokensSchema, St as contextProvenance, dt as agentHistoryFromRow, ft as encodeAgentHistoryPayload, gt as historyItemFromPiMessage, ht as HISTORY_REPLACEMENT_TYPES, mt as AGENT_HISTORY_ITEM_TYPES, vt as isHistoryReplacement, wt as instructionProvenanceFor, yt as piMessageFromHistoryItem } from "./types-DCzTAA63.js";
|
|
4
|
+
import { _ as serializeGenAiAttribute, f as logException, h as normalizeGenAiFinishReason, i as extractGenAiUsageSummary, m as logWarn, r as extractGenAiUsageAttributes } from "./logging-BnOG0qz2.js";
|
|
5
|
+
import { h as SERVICE_INSTANCE_ID } from "./deployment-C0qXa0FD.js";
|
|
6
|
+
import { G as mapBounded } from "./prompt-DEkStuxG.js";
|
|
7
|
+
import { a as toCanonicalInputMessage, o as toCanonicalOutputMessage, r as resolveConversationPrivacy, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-Cr_dNW1p.js";
|
|
8
|
+
import { Kr as reviewToolActions, Or as TURN_LIMIT_WRAP_UP_MESSAGE, Wt as getWorkspace, ft as getPersistedSandboxState, in as buildDeploymentSystemPrompt, jr as TurnToolCallLimitExceededError, kr as TurnBudgetExceededError, mt as persistThreadRuntimeState, pt as getPersistedThreadState } from "./mailbox-turn-Byrry9o1.js";
|
|
9
|
+
import { f as createWriteFileTool, g as createEditFileTool, m as createReadFileTool, u as createSystemTimeTool, y as createBashTool } from "./job-runner-B2XEvpif.js";
|
|
10
|
+
import { _ as normalizeToolResult, c as buildSandboxInput, g as createAgentSandbox, v as capToolResult } from "./agent-runner-DeYymwh2.js";
|
|
11
11
|
import { n as TURN_STEP_TOPIC, t as DELIVERY_TOPIC } from "./topic-CRYYBYp-.js";
|
|
12
12
|
import * as z from "zod";
|
|
13
13
|
import { streamSimple } from "@earendil-works/pi-ai/compat";
|
|
14
|
+
import { and, asc, eq, exists, inArray, like, lt, lte, max, ne, notExists, or, sql } from "drizzle-orm";
|
|
15
|
+
import { alias } from "drizzle-orm/pg-core";
|
|
16
|
+
import { actorSchema, destinationSchema, markdownNodes, parseMarkdown } from "@sentry/junior-plugin-api";
|
|
14
17
|
import * as Sentry from "@sentry/node";
|
|
15
18
|
import { randomUUID } from "node:crypto";
|
|
16
19
|
import { toToolDeclaration, validateToolArguments } from "@earendil-works/pi-ai";
|
|
17
|
-
import { actorSchema, destinationSchema, markdownNodes, parseMarkdown } from "@sentry/junior-plugin-api";
|
|
18
|
-
import { and, asc, eq, exists, inArray, like, lt, lte, max, ne, notExists, or, sql } from "drizzle-orm";
|
|
19
|
-
import { alias } from "drizzle-orm/pg-core";
|
|
20
20
|
import { performance as performance$1 } from "node:perf_hooks";
|
|
21
21
|
// src/core/model/failure.ts
|
|
22
22
|
const RETRYABLE_KINDS = /* @__PURE__ */ new Set([
|
|
@@ -1000,6 +1000,30 @@ async function findTurn({ executor }, turnId) {
|
|
|
1000
1000
|
}).from(juniorTurns).where(eq(juniorTurns.id, turnId));
|
|
1001
1001
|
return turn;
|
|
1002
1002
|
}
|
|
1003
|
+
/** Reads a Turn's discarded usage. Undefined when the Turn does not exist. */
|
|
1004
|
+
async function findDiscardedUsage({ executor }, turnId) {
|
|
1005
|
+
return selectDiscardedUsage({ executor }, eq(juniorTurns.id, turnId));
|
|
1006
|
+
}
|
|
1007
|
+
async function selectDiscardedUsage({ executor }, where) {
|
|
1008
|
+
const [turn] = await executor.db().select({
|
|
1009
|
+
costMicroUsd: juniorTurns.discardedCostMicroUsd,
|
|
1010
|
+
tokens: juniorTurns.discardedTokens
|
|
1011
|
+
}).from(juniorTurns).where(where);
|
|
1012
|
+
if (!turn) return;
|
|
1013
|
+
return turn.tokens === null ? { costMicroUsd: turn.costMicroUsd } : {
|
|
1014
|
+
costMicroUsd: turn.costMicroUsd,
|
|
1015
|
+
tokens: usageTokensSchema.parse(turn.tokens)
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
async function discardedUsageUpdate({ executor }, lease, usage) {
|
|
1019
|
+
const current = usage ? await selectDiscardedUsage({ executor }, leaseFence(lease)) : void 0;
|
|
1020
|
+
if (!current) return {};
|
|
1021
|
+
const { cost: _, ...tokens } = addAgentTurnUsage(current.tokens, usage) ?? {};
|
|
1022
|
+
return {
|
|
1023
|
+
discardedCostMicroUsd: current.costMicroUsd + usdToMicroUsd(agentTurnCostUsd(usage) ?? 0),
|
|
1024
|
+
discardedTokens: tokens
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1003
1027
|
const runOrder = [
|
|
1004
1028
|
sql`${juniorTurns.state} = 'running' desc`,
|
|
1005
1029
|
asc(juniorTurns.priority),
|
|
@@ -1201,8 +1225,9 @@ async function commitOutcome({ executor }, turnId, step, prompt) {
|
|
|
1201
1225
|
* False when the lease is lost. The engine calls it through `endFailedTurn`,
|
|
1202
1226
|
* which also moves the Turn's late inputs.
|
|
1203
1227
|
*/
|
|
1204
|
-
async function failTurn({ executor }, lease, endReason, failure) {
|
|
1228
|
+
async function failTurn({ executor }, lease, endReason, failure, discarded) {
|
|
1205
1229
|
return (await executor.db().update(juniorTurns).set({
|
|
1230
|
+
...await discardedUsageUpdate({ executor }, lease, discarded),
|
|
1206
1231
|
state: "failed",
|
|
1207
1232
|
endReason,
|
|
1208
1233
|
failureCode: failure.failureCode,
|
|
@@ -1217,12 +1242,14 @@ async function failTurn({ executor }, lease, endReason, failure) {
|
|
|
1217
1242
|
/**
|
|
1218
1243
|
* Queues a running Turn again after its invocation failed, so the queue's
|
|
1219
1244
|
* retry can claim the step at once. The failed attempt still counts. A Turn
|
|
1220
|
-
* that another Turn supersedes ends instead, like at a commit.
|
|
1245
|
+
* that another Turn supersedes ends instead, like at a commit. `discarded` is
|
|
1246
|
+
* the usage of the failed model reply that the retry drops. False when the
|
|
1221
1247
|
* lease is lost.
|
|
1222
1248
|
*/
|
|
1223
|
-
async function releaseTurn({ executor }, lease) {
|
|
1249
|
+
async function releaseTurn({ executor }, lease, discarded) {
|
|
1224
1250
|
return executor.transaction(() => withConversationEventLock(executor, lease.conversationId, async () => {
|
|
1225
1251
|
const released = {
|
|
1252
|
+
...await discardedUsageUpdate({ executor }, lease, discarded),
|
|
1226
1253
|
leaseOwner: null,
|
|
1227
1254
|
leaseExpiresAt: null,
|
|
1228
1255
|
updatedAt: sql`now()`
|
|
@@ -1346,11 +1373,12 @@ async function moveLeftovers({ executor }, ended) {
|
|
|
1346
1373
|
* Ends a running Turn as failed and, in the same commit, moves its inputs
|
|
1347
1374
|
* that arrived after its last claim to the next Turn. A crash after the
|
|
1348
1375
|
* commit loses no input: the next Turn is queued, so the sweep finds it.
|
|
1376
|
+
* `discarded` is the usage of a failed model reply that the Turn drops.
|
|
1349
1377
|
* False when the lease is lost, and then nothing changes.
|
|
1350
1378
|
*/
|
|
1351
|
-
async function endFailedTurn({ executor }, lease, endReason, failure) {
|
|
1379
|
+
async function endFailedTurn({ executor }, lease, endReason, failure, discarded) {
|
|
1352
1380
|
return executor.transaction(() => withConversationEventLock(executor, lease.conversationId, async () => {
|
|
1353
|
-
if (!await failTurn({ executor }, lease, endReason, failure)) return false;
|
|
1381
|
+
if (!await failTurn({ executor }, lease, endReason, failure, discarded)) return false;
|
|
1354
1382
|
await moveLeftovers({ executor }, lease);
|
|
1355
1383
|
return true;
|
|
1356
1384
|
}));
|
|
@@ -1657,9 +1685,11 @@ async function runClaimedStep({ executor, queue }, claim, unread, { client, prom
|
|
|
1657
1685
|
}, claim.turnId);
|
|
1658
1686
|
return;
|
|
1659
1687
|
case "failed": {
|
|
1688
|
+
const usage = extractGenAiUsageSummary(result.reply);
|
|
1689
|
+
const discarded = (agentTurnTotalTokens(usage) ?? 0) > 0 || (agentTurnCostUsd(usage) ?? 0) > 0 ? usage : void 0;
|
|
1660
1690
|
const delayMs = modelRetryDelayMs(result.failure, claim.attempts, maxAttempts);
|
|
1661
1691
|
if (delayMs !== void 0) {
|
|
1662
|
-
if (await releaseTurn({ executor }, claim)) {
|
|
1692
|
+
if (await releaseTurn({ executor }, claim, discarded)) {
|
|
1663
1693
|
await publishTurnStep({ queue }, claim.turnId, { delayMs });
|
|
1664
1694
|
logWarn("agent.turn.provider.retrying", {
|
|
1665
1695
|
...modelFailureAttributes(result.failure),
|
|
@@ -1670,7 +1700,7 @@ async function runClaimedStep({ executor, queue }, claim, unread, { client, prom
|
|
|
1670
1700
|
return;
|
|
1671
1701
|
}
|
|
1672
1702
|
const failure = captureModelFailure(result.failure);
|
|
1673
|
-
if (await endFailedTurn({ executor }, claim, result.failure.message, failure)) await reconcileTurn({
|
|
1703
|
+
if (await endFailedTurn({ executor }, claim, result.failure.message, failure, discarded)) await reconcileTurn({
|
|
1674
1704
|
executor,
|
|
1675
1705
|
queue
|
|
1676
1706
|
}, claim.turnId);
|
|
@@ -1878,7 +1908,8 @@ async function checkTurnLimits(ctx, turnId, calls) {
|
|
|
1878
1908
|
const replies = history.filter((message) => message.role === "assistant");
|
|
1879
1909
|
const toolCallCount = replies.flatMap((reply) => reply.content).filter((part) => part.type === "toolCall").length;
|
|
1880
1910
|
const results = history.filter((message) => message.role === "toolResult");
|
|
1881
|
-
const
|
|
1911
|
+
const discarded = await findDiscardedUsage(ctx, turnId);
|
|
1912
|
+
const costUsd = (agentTurnCostUsd(extractGenAiUsageSummary(...replies)) ?? 0) + microUsdToUsd(discarded?.costMicroUsd ?? 0);
|
|
1882
1913
|
const overBudget = costUsd >= botConfig.maxTurnCostUsd;
|
|
1883
1914
|
const overToolCalls = toolCallCount > botConfig.maxToolCallsPerTurn;
|
|
1884
1915
|
const attributes = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { S as deleteMcpStoredOAuthCredentials, b as deleteMcpAuthSessionsForUserProvider, m as hasRequiredOAuthScope, x as deleteMcpServerSessionId } from "./registry-
|
|
6
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
1
|
+
import { L as botConfig } from "./context-BKF_5zzI.js";
|
|
2
|
+
import { nc as deleteProviderIdentityForSlackUser, o as getSqlExecutor, rc as deleteProviderIdentityForUser } from "./db-of6e3sGt.js";
|
|
3
|
+
import { G as mapBounded } from "./prompt-DEkStuxG.js";
|
|
4
|
+
import { ii as startOAuthFlow } from "./mailbox-turn-Byrry9o1.js";
|
|
5
|
+
import { S as deleteMcpStoredOAuthCredentials, b as deleteMcpAuthSessionsForUserProvider, m as hasRequiredOAuthScope, x as deleteMcpServerSessionId } from "./registry-Cl7Labpe.js";
|
|
6
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-BfdAnztW.js";
|
|
7
7
|
import { randomBytes } from "node:crypto";
|
|
8
8
|
// src/handlers/oauth-html.ts
|
|
9
9
|
/** Build pre-escaped callback HTML with the shared response security policy. */
|
package/dist/instrumentation.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { a as getClient, c as init, i as getActiveSpan, o as getGlobalScope, p as spanToJSON, s as getTraceData, u as sentry_exports } from "./sentry-CPbZjomA.js";
|
|
2
|
-
import { n as getCurrentConversationPrivacy } from "./conversation-privacy-
|
|
2
|
+
import { n as getCurrentConversationPrivacy } from "./conversation-privacy-Cr_dNW1p.js";
|
|
3
3
|
import { n as isPushServiceHost } from "./push-endpoint-CO-nomUd.js";
|
|
4
4
|
import { n as redactSandboxEgressProxyPath } from "./proxy-path-BHYoKZdq.js";
|
|
5
5
|
import { n as promoteHttpRouteName, r as routeNameMiddleware, t as nameRequestRoute } from "./sentry-route-name-C6EIzAGP.js";
|
|
6
6
|
import { t as consumePrivateTraceResultMarker } from "./private-trace-result-CE7_lEdq.js";
|
|
7
|
-
import { _ as getDeploymentTelemetryAttributes, g as getDeploymentServiceVersion } from "./deployment-
|
|
7
|
+
import { _ as getDeploymentTelemetryAttributes, g as getDeploymentServiceVersion } from "./deployment-C0qXa0FD.js";
|
|
8
8
|
import { performance } from "node:perf_hooks";
|
|
9
9
|
import { subscribe, unsubscribe } from "node:diagnostics_channel";
|
|
10
10
|
// src/chat/pi/gateway-request-timing.ts
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { $t as
|
|
8
|
-
import { E as createSandboxEgressCredentialToken, _ as WorkspaceSnapshotNotReadyError, j as buildSandboxEgressNetworkPolicy, o as getSandboxProvider, p as isAbortError, r as isStale, t as create, u as SANDBOX_RUNTIME, y as isWorkspaceSnapshotNotReadyError } from "./profile-
|
|
9
|
-
import { i as postinstall, o as getSandboxResources, r as dependencies } from "./resolve-
|
|
1
|
+
import { a as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC } from "./topics-BoCkoPJJ.js";
|
|
2
|
+
import { T as withLock, n as credentialContextForActor, w as fenceLock, y as getStateAdapter } from "./context-BKF_5zzI.js";
|
|
3
|
+
import { $n as resolveEventMentions, Br as QUEUE_SIGNATURE_MAX_AGE_MS, Hr as verifyQueueMessage, Ji as createSandboxCapability, Nr as getVercelConversationWorkQueue, Oo as deliverWatch, Pi as slackMention, Ui as createPluginModel, Ur as getQueueProvider, Vi as createPluginDecider, Vr as signQueueMessage, Vs as sleep, Wi as createPluginModelCostRecorder, Xi as withPluginHookSpan, a as getDb, au as ToolInputError, gf as juniorSpaceConfigurations, go as workspaceSnapshotFinishedEvent, hf as juniorConversations, jo as isQuietEvent, jt as juniorToolOutputSchema, ko as findMatchingWatches, ou as isToolInputError, qi as basePluginContext, qs as readActorIdentity, rs as createPluginAnnotations, ur as getTurnRequestDeadline, wt as getRegistrations } from "./db-of6e3sGt.js";
|
|
4
|
+
import { Fn as isValidTimeZone, Pn as getZonedDateTimeParts } from "./types-DCzTAA63.js";
|
|
5
|
+
import { f as logException, m as logWarn, p as logInfo } from "./logging-BnOG0qz2.js";
|
|
6
|
+
import { c as SANDBOX_REPOS_ROOT, d as SANDBOX_WORKSPACE_ROOT, s as SANDBOX_JUNIOR_ROOT } from "./prompt-DEkStuxG.js";
|
|
7
|
+
import { $t as invalidateReadySnapshot, B as resolveEventAuthor, Qt as workspaceRepoCheckoutPath, Wt as getWorkspace, ci as configValueSchema, en as loadSnapshotsForProfile, j as enqueueEventNotification, k as addQuietEventNote, nn as setWorkspaceSnapshotBuild, oi as validateConfigKey, si as validateConfigValue, tn as setWorkspaceSnapshot } from "./mailbox-turn-Byrry9o1.js";
|
|
8
|
+
import { E as createSandboxEgressCredentialToken, _ as WorkspaceSnapshotNotReadyError, j as buildSandboxEgressNetworkPolicy, o as getSandboxProvider, p as isAbortError, r as isStale, t as create, u as SANDBOX_RUNTIME, y as isWorkspaceSnapshotNotReadyError } from "./profile-iHw1uu32.js";
|
|
9
|
+
import { i as postinstall, o as getSandboxResources, r as dependencies } from "./resolve-DC6zBuDV.js";
|
|
10
10
|
import * as z from "zod";
|
|
11
11
|
import path from "node:path";
|
|
12
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
13
|
-
import { escapeTagTextAndQuotes, eventSchema, objectAnnotationSchema, renderInlineTag } from "@sentry/junior-plugin-api";
|
|
14
12
|
import { and, asc, eq, sql } from "drizzle-orm";
|
|
15
13
|
import { alias } from "drizzle-orm/pg-core";
|
|
14
|
+
import { escapeTagTextAndQuotes, eventSchema, objectAnnotationSchema, renderInlineTag } from "@sentry/junior-plugin-api";
|
|
15
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
16
16
|
import { structuredPatch } from "diff";
|
|
17
17
|
// src/chat/spaces/configuration.ts
|
|
18
18
|
/**
|
|
@@ -365,7 +365,6 @@ const bashToolDefinition = zodToolDefinition({
|
|
|
365
365
|
openWorldHint: false,
|
|
366
366
|
readOnlyHint: false
|
|
367
367
|
},
|
|
368
|
-
approvalMode: "auto",
|
|
369
368
|
description: "Run a bash command inside the isolated sandbox workspace. Use this for repository inspection/execution tasks that need shell access. Do not use for network-sensitive or destructive actions unless explicitly required.",
|
|
370
369
|
inputSchema: z.object({
|
|
371
370
|
command: z.string().min(1).describe("Bash command to run inside the sandbox."),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { J as conversationKindFromRow, a as getDb, hf as juniorConversations } from "./db-of6e3sGt.js";
|
|
2
2
|
import { desc, eq, sql } from "drizzle-orm";
|
|
3
3
|
// src/chat/conversations/lineage.ts
|
|
4
4
|
/**
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { $
|
|
2
|
-
import { $ as
|
|
3
|
-
import {
|
|
1
|
+
import { $ as resolveGatewayModel, B as getSlackBotToken, C as acquireActiveLock, E as parseSlackChannelId, H as getSlackClientSecret, J as normalizeSlackEmojiName, L as botConfig, O as parseSlackTeamId, P as parseSlackMessageTs, R as getChatConfig, U as getSlackSigningSecret, V as getSlackClientId, b as getStateValues, c as createSlackActor, f as isUserActor, l as createSlackResumeActor, n as credentialContextForActor, p as parseActorUserId, s as createActor, t as actorLogContext, u as isActorUserId, x as setStateValues, y as getStateAdapter } from "./context-BKF_5zzI.js";
|
|
2
|
+
import { $a as fallbackShortTitle, $d as juniorConversationParticipants, $r as resolveTurnResumeRouting, Ai as SLACK_USER_MENTION_RE, An as canJoinTurn, Ar as readMemberParticipants, Bi as createPluginState, Bn as pushInboxSnoozeWakes, Bo as verifyEventAutomationCredentialSubject, Bs as withSlackRetries, Bt as setTodoStatusByUser, C as conversationSlackTenantId, Ca as admitEventAutomationRun, Cc as listReplyActionItems, Co as cancelSubscriptions, Cr as leaveEndsAccess, Ct as getPlugins, Dd as listedConversation, Dl as deliversFinalText, Dr as conversationIsMemberRoot, Du as completeText, Ea as automationVersionOf, Ec as takeInboxItem, Ed as spaceLeadIds, Fd as juniorTodos, Fi as slackMentionedUserIds, Fl as postsRunNotices, Fs as isDmChannel, G as conversationTurnFailedSql, Gl as isEventConversationMessage, H as conversationIsActiveSql, Hc as userAvatarUrlsFromIdentities, Hi as createPluginEmbedder, Hl as EVENT_SYSTEM_ACTOR, Ho as verifySlackDirectCredentialSubject, Ic as subjectTodo, Ii as wrapBareSlackUserIds, Io as bindEventAutomationCredentialSubject, Is as isSlackRequestTimeout, J as conversationKindFromRow, K as conversationWaitsOnUserSql, Kl as CORE_EVENT_NAMESPACE, Kt as cancelHumanFacingPendingMessages, L as parseSessionSource, Lc as hasUserPhoto, Li as applyPluginFormatMarkdown, Lo as bindScheduledAutomationCredentialSubject, Ls as normalizeSlackConversationId, Mc as INBOX_SUBJECT_KINDS, Ml as isThread, Mo as listConversationsWithWatches, Mr as viewerMarksFromParticipant, Ms as getSlackClient, Ni as normalizeSlackStatusText, Nl as isTopLevel, Nr as getVercelConversationWorkQueue, Oc as inboxItemAnswer, Or as conversationIsNotUnsubscribedRoot, Os as SlackActionError, Pa as existingConversationId, Pi as slackMention, Q as canActOnInboxItem, Qn as sendSlackReply, Qo as canPauseConversationDelivery, Qr as resolveConversationRouting, R as conversationCostOf, Rc as identityAvatarUrl, Rd as juniorQuestions, Rl as turnBehavior, Rn as createInboxItemShow, Ro as bindSlackDirectCredentialSubject, Ru as createCache, S as setArchivedAt, Sd as requireSlackDestination, Sf as juniorDestinations, Sr as createConversationAccessReader, T as lastMessageAtSql, Td as rootSpaceIdSql, Ti as removeReactionFromMessage, To as collectEventMatchKeys, Tr as readConversationAccessRows, Tu as completeDecision, Ua as readAutomationTitlesByConversationId, Uc as userAvatarUrlsFromJoinedPhotos, Uu as estimateTextTokens, Vd as juniorAutomationRuns, Vo as verifyScheduledAutomationCredentialSubject, W as conversationStatusSql, Wa as recordAutomationExecution, Wc as SNOOZE_TIMER_EVENT_TYPE, Wd as juniorAutomations, Wo as updateTimerIndex, Wr as buildSentryConversationUrl, Ws as createPluginUsers, Wu as textCharsForTokens, X as hasUnexpiredAuthorizationRequest, Xa as AUTOMATION_ALERT_STEPS, Xr as runWithSlackInstallation, Y as awaitsAuthorizationFrom, Yc as listFiringInboxSnoozeTriggers, Yd as juniorInboxItems, Yl as eventGuidance, Yn as safeLinkUrl, Z as treeAwaitsAuthorization, Za as AUTOMATION_ALERT_STEP_FIELD_ID, Zc as settleInboxSnoozes, Zn as resolveSlackReplyTarget, _a as findMatchingEventAutomations, _i as notifyAutomationBlocked, a as getDb, ad as JUNIOR_NATIVE_EVENT_NAMESPACE, an as getConversationWorkState, as as listConversationAnnotationsById, at as inboxItemForUser, bc as getInboxItem, bs as lookupSlackUser, ci as getDispatchTurnId, cl as isDashboardLink, cr as sendVercelPluginTask, cs as conversationSubtreeColumns, ct as inboxItemPlugin, do as slackChannelMessageReplyThreadTs, dr as createPluginCodeChanges, ea as createPluginCache, ec as resolveActorIdentityId, ei as buildDispatchId, er as createPluginEventPublisher, et as canAnswerInboxItem, fo as slackChannelMessageRunsAutomation, fs as isPublicConversation, ft as isAutomationAlertItem, gd as resolveRootConversationId, gr as createPluginInboxItems, hc as closeHandledReplyNotices, hf as juniorConversations, hr as PLUGIN_CHOICE_FIELD_ID, ht as isPluginInboxItem, i as getConversationStore, if as juniorConversationEvents, ii as getDispatchConversationId, il as getDashboardPersonLink, in as getConversation, is as listConversationAnnotations, it as inboxItemAddedByAutomation, jc as itemQuestion, jn as canShareTurn, jr as rootVisibleToViewer, js as getHeaderString, k as locationFromRow, kc as inboxItemRequest, ko as findMatchingWatches, kr as conversationPinnedForUser, ks as downloadPrivateSlackFile, li as getPluginDispatchProjection, ll as parseDashboardConversationLink, ls as conversationSearchVector, ma as collectEventAutomationMatchKeys, mc as waitingConversationIdsQuery, md as hasAgentTurnUsage, mf as juniorMessageAttachments, mr as createPluginConversationChanges, mt as isOnlyAssignee, n as getConversationEventStore, na as truncateStatusText, nt as canUserReadInboxItem, o as getSqlExecutor, oi as getDispatchInputMessageId, os as conversationAncestorsOrSelf, ot as inboxItemNeedsInput, p as copyMessageLinks, pa as blockEventAutomation, pd as agentTurnUsageSchema, pf as juniorAttachments, pt as isInboxItemForEveryone, q as executionIsActive, qi as basePluginContext, qo as readSubjectLinks, rd as isProviderRetryError, ri as createOrGetDispatch, rl as getDashboardLinkFilter, rr as createPluginTaskStarter, rs as createPluginAnnotations, sf as juniorConversationAnnotations, si as getDispatchRecord, so as getEventCatalog, ss as conversationSubtree, st as inboxItemOwnedByConversation, tc as saveActorAvatar, tl as getDashboardConversationLink, u as isPostgresErrorCode, uc as readCachedUserByEmail, ud as addAgentTurnUsage, uf as juniorCodeChanges, ui as isTerminalDispatchStatus, ul as parseDashboardPersonLink, ur as getTurnRequestDeadline, uu as indexEndedTurnEvents, v as withConversationEventLock, vc as closeInboxItem, vf as juniorIdentities, vi as addReactionToMessage, vr as canAddConversationMessages, w as loadConversationSlackTenantIds, wa as eventAutomationRunLimitReason, wc as ownerConversationId, wr as readConversationAccessFromSql, x as readConversationTrees, xd as createSlackDestination, xf as juniorUsers, xr as conversationAccessFromRows, xs as lookupSlackUserNames, y as conversationAncestors, yc as dismissOpenInboxItems, yd as nextDetailVersion, yr as canInviteToConversation, yu as storedMessageJson, zs as streamPrivateSlackFile } from "./db-of6e3sGt.js";
|
|
3
|
+
import { $ as activityPreviewText, Kt as MAX_ATTACHMENT_BYTES, Lt as conversationTreeStateSchema, On as automationTaskText, St as contextProvenance, Xt as readMessageAttachments, Y as conversationReportStatusSchema, Z as conversationSurfaceSchema, at as KNOWN_CONVERSATION_EVENT_TYPES, bn as normalizeUserInputAnswer, fn as inboxItemQuestion, gn as answeredChoices, t as OPEN_TODO_STATUSES, wt as instructionProvenanceFor, yn as isEmptyUserInputAnswer, yt as piMessageFromHistoryItem } from "./types-DCzTAA63.js";
|
|
4
|
+
import { A as toOptionalString, T as withSpan, a as getActiveTraceContext, d as logError, f as logException, k as normalizeIdentityEmail, m as logWarn, o as getActiveTraceId, p as logInfo, t as createChatSdkLogger, v as setSentryUser, w as withLogContext, x as setTags, y as setSpanAttributes } from "./logging-BnOG0qz2.js";
|
|
4
5
|
import { h as startSpan, n as captureMessage } from "./sentry-CPbZjomA.js";
|
|
5
|
-
import { t as JUNIOR_VERSION } from "./version-
|
|
6
|
-
import {
|
|
7
|
-
import { $ as activityPreviewText, Fn as automationTaskText, Kt as MAX_ATTACHMENT_BYTES, Lt as conversationTreeStateSchema, St as contextProvenance, Xt as readMessageAttachments, Y as conversationReportStatusSchema, Z as conversationSurfaceSchema, at as KNOWN_CONVERSATION_EVENT_TYPES, bn as normalizeUserInputAnswer, fn as inboxItemQuestion, gn as answeredChoices, t as OPEN_TODO_STATUSES, wt as instructionProvenanceFor, yn as isEmptyUserInputAnswer, yt as piMessageFromHistoryItem } from "./types-C4iC-IMC.js";
|
|
6
|
+
import { t as JUNIOR_VERSION } from "./version-VEXiEcZu.js";
|
|
7
|
+
import { G as mapBounded, M as trimTrailingAssistantMessages, h as createPluginLogger } from "./prompt-DEkStuxG.js";
|
|
8
8
|
import { n as webMessageId } from "./agent-status-BA5x3Xtp.js";
|
|
9
|
-
import { $ as
|
|
10
|
-
import { o as ingestEvent } from "./job-runner-
|
|
11
|
-
import { $ as requireSpaceForWork, $t as AutomationEditError, At as parseSlackThreadId, B as archiveConversation, C as CONVERSATION_STATE_TTL_MS, Ct as setConversationSubscription, D as isConversationWorkDone, Dt as renderAttachmentText, E as segmentGapsKey, Et as throwApiError, Ht as takeViewerAutomationAlertStep, It as createPluginConversationWatches, J as stopChildAgentsOf, K as stopConversation, Kt as readConversationSourceTask, Mt as resolveSlackChannelIdFromMessage, O as listConversationWork, Ot as renderBlockText, S as ANSWER_TOOL_ENDINGS, Sn as resolveConversationConfiguration, St as leaveConversation, T as GLOBAL_GAPS_TTL_MS, Tt as jsonResponse, U as conversationReadPositionQuery, W as markConversationRead, Wt as ViewerTaskNotFoundError, Y as deliverInboxItemChange, a as getMcpOAuthCallbackPath, an as addHistoryPeriod, bn as NO_REPLY_GAP_MS, bt as setConversationTitle, cn as historyPeriodSavings, ct as
|
|
12
|
-
import { N as webActorUserIds, T as getMcpStoredOAuthCredentials, _ as McpAuthorizationRequiredError, v as PluginMcpClient } from "./registry-
|
|
13
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
14
|
-
import { A as createUserTokenStore } from "./profile-
|
|
15
|
-
import { h as getAssistantReplyText } from "./system-prompt-table-
|
|
9
|
+
import { $ as ConversationTurnBoundaryError, At as instructionActorFor, B as resolveEventAuthor, Bn as estimateConversationMessagesTokens, Bt as buildDeterministicAssistantMessageId, D as notInheritedByForkChild, En as recordAuthorizationCompleted, Et as loadThreadContextTrimFloor, F as eventAuthorText, Fn as persistConversationMessageWindow, Fr as buildTurnFailureResponse, Gn as normalizeConversationText, Hn as isHumanConversationMessage, In as persistConversationMessages, It as renderTaskInput, Jn as trimConversationMessages, Kn as recordDeliveredAssistantMessage, Ln as resolveConversationTitle, Lr as finalizeFailedTurnReplyWithEvent, Mr as buildTurnErrorResponse, Pn as hydrateConversationMessages, Pt as withoutSavedSteeringMessages, Q as getTurnUserSlackMessageTs, Rr as getAgentTurnDiagnosticsAttributes, Sn as loadTurnProjection, Sr as recordTurnSummary, St as savedInputInstruction, Tr as loadTurnStart, Un as latestConversationMessageSeq, V as resolveBotSlackTeamId, Vn as getConversationMessageSlackTs, Vt as buildDeterministicTurnId, W as resumeForPersonInput, Wn as markConversationMessage, Xn as upsertConversationMessage, Y as getTurnUserMessage, Yn as turnHasReply, Z as getTurnUserReplyAttachmentContext, _n as commitAcceptedReply, _r as abandonTurnRecord, at as isTurnInputCommitLostError, bn as loadConversationProjection, br as getTurnRecord, c as legacyWebMailboxMetadataSchema, ci as configValueSchema, ct as markTurnCompleted, dt as getLocationConfigurationService, ei as persistWithRetry, et as CooperativeTurnYieldError, ft as getPersistedSandboxState, gr as saveTurnCheckpoint, gt as coerceThreadConversationState, hr as pauseLostWorkerTurn, ht as persistThreadStateById, it as isCooperativeTurnYieldError, jn as recordSubscribedReplyRoute, kt as buildSteeringPiMessage, lt as markTurnFailed, mr as lostWorkerBeforeFirstSave, mt as persistThreadRuntimeState, nr as PluginCredentialFailureError, nt as TurnInputDeferredError, or as AuthorizationFlowDisabledError, ot as isTurnInputDeferredError, pr as loadTurnCheckpoint, pt as getPersistedThreadState, rn as isExperimentalFeatureEnabled, rt as getConversationTurnBoundaryError, st as markTurnClosed, tr as createPluginEgress, tt as TurnInputCommitLostError, ur as clearPendingAuth, ut as startActiveTurn, vn as commitMessages, vr as completeTurnRecord, wr as getTurnLifecycle, wt as withHeldInput, xr as listTurnSummaries, xt as loadInboxItemInput, yr as failTurnRecord, yt as getWebAuthorization, zr as requireTurnFailureEventId } from "./mailbox-turn-Byrry9o1.js";
|
|
10
|
+
import { o as ingestEvent } from "./job-runner-B2XEvpif.js";
|
|
11
|
+
import { $ as requireSpaceForWork, $t as AutomationEditError, At as parseSlackThreadId, B as archiveConversation, C as CONVERSATION_STATE_TTL_MS, Ct as setConversationSubscription, D as isConversationWorkDone, Dt as renderAttachmentText, E as segmentGapsKey, Et as throwApiError, Ht as takeViewerAutomationAlertStep, It as createPluginConversationWatches, J as stopChildAgentsOf, K as stopConversation, Kt as readConversationSourceTask, Mt as resolveSlackChannelIdFromMessage, O as listConversationWork, Ot as renderBlockText, S as ANSWER_TOOL_ENDINGS, Sn as resolveConversationConfiguration, St as leaveConversation, T as GLOBAL_GAPS_TTL_MS, Tt as jsonResponse, U as conversationReadPositionQuery, W as markConversationRead, Wt as ViewerTaskNotFoundError, Y as deliverInboxItemChange, a as getMcpOAuthCallbackPath, an as addHistoryPeriod, bn as NO_REPLY_GAP_MS, bt as setConversationTitle, cn as historyPeriodSavings, ct as appendAndEnqueueWebMessage, dt as createConversationId, en as findAutomationSkill, et as setConversationSpaceForViewer, ft as recordWebConversationActivity, gn as providerCacheTtlMs, hn as connectedState, ht as AttachmentUploadError, jt as readSlackRawMessageContext, kt as parseSlackMessageReference, l as latestProgressStatus, ln as replaceHistorySavings, n as executeAgentRun, nn as effectiveTaskOutcomes, nt as getSpaceLead, o as createClientMetadata, on as addHistoryWarmupCost, pt as webActorFromUser, r as buildAuthPauseResponse, s as readMcpClientInformation, sn as firstLiveSavingsDate, st as acceptsWebMessages, t as createAgentRunner, tn as missingAutomationSkillReason, tt as readSpaceRefs, u as resolveDestinationVisibility, ut as createAndEnqueueConversation, vn as MINUTE_MS, vt as verifyAttachmentUploads, w as GLOBAL_GAPS_MAX, x as shouldEmitDevAgentTrace, xn as gapSegment, y as RetryableDeliveryError, z as readLastUserMessageAtByConversation } from "./agent-runner-DeYymwh2.js";
|
|
12
|
+
import { N as webActorUserIds, T as getMcpStoredOAuthCredentials, _ as McpAuthorizationRequiredError, v as PluginMcpClient } from "./registry-Cl7Labpe.js";
|
|
13
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-BfdAnztW.js";
|
|
14
|
+
import { A as createUserTokenStore } from "./profile-iHw1uu32.js";
|
|
15
|
+
import { h as getAssistantReplyText } from "./system-prompt-table-Ci6Ck4gk.js";
|
|
16
16
|
import { o as detectImageMediaType, s as isVisionImageMediaType } from "./user-customization-CvfuY9Eo.js";
|
|
17
|
-
import { a as readAttachmentVisionSummary, c as slackAttachmentsVersionQuery, m as storeAttachment, n as savedTurnMessages, r as getSlackFileId, s as recordSlackAttachment, u as isFileAttachment } from "./turn-membership-
|
|
18
|
-
import { a as isConversationMember, i as getConversationInfo, l as listThreadReplies, o as isPublicSlackChannel, r as getChannelMessage } from "./channel-access-
|
|
19
|
-
import { C as cancelConversationPendingMessagesBodySchema, D as conversationPendingMessageDeliverySchema, G as messageObjectCard, K as personObjectCard, N as healthReportSchema, S as conversationAutoArchiveSchema, W as conversationObjectCard, b as archiveConversationResponseSchema, c as conversationSubscriptionResponseSchema, g as pinConversationResponseSchema, h as pinConversationBodySchema, l as setConversationSpaceBodySchema, m as renameConversationResponseSchema, o as conversationLeaveResponseSchema, p as renameConversationBodySchema, q as webPageObjectCard, r as stopConversationTurnResponseSchema, s as conversationSubscriptionBodySchema, u as setConversationSpaceResponseSchema, w as cancelConversationPendingMessagesResponseSchema, x as archiveDoneConversationsResponseSchema, y as archiveConversationBodySchema } from "./conversation-feed
|
|
20
|
-
import { a as
|
|
21
|
-
import { n as attachmentFactLines, r as buildStoredAttachmentPromptText } from "./model-input-
|
|
22
|
-
import { a as getChildAgentLabel } from "./result-
|
|
23
|
-
import { t as bindMessageAgent } from "./message-
|
|
24
|
-
import { t as readConversationLineage } from "./lineage-
|
|
25
|
-
import { t as bindSpawnAgent } from "./spawn-
|
|
26
|
-
import {
|
|
27
|
-
import { c as readConversationEventPageAround, n as scheduleSessionCompletedPluginTasks, o as readConversationEventPage, s as readConversationEventPageAfter } from "./task-runner-
|
|
28
|
-
import { a as createAgentDispatchConversationWorker, i as buildDispatchRoutingContext, o as enqueueAgentDispatch, s as failStoppedDispatch, t as runConversation } from "./run-conversation-
|
|
29
|
-
import { n as getPausedTurnRequest, o as getTurnAuthorization, r as recordFailedDispatchTurn, t as createPausedTurns } from "./turn-wake-
|
|
30
|
-
import { r as canContinueInSlack } from "./continue-in-slack-
|
|
17
|
+
import { a as readAttachmentVisionSummary, c as slackAttachmentsVersionQuery, m as storeAttachment, n as savedTurnMessages, r as getSlackFileId, s as recordSlackAttachment, u as isFileAttachment } from "./turn-membership-VT7XZh-L.js";
|
|
18
|
+
import { a as isConversationMember, i as getConversationInfo, l as listThreadReplies, o as isPublicSlackChannel, r as getChannelMessage } from "./channel-access-A0de5lRv.js";
|
|
19
|
+
import { C as cancelConversationPendingMessagesBodySchema, D as conversationPendingMessageDeliverySchema, G as messageObjectCard, K as personObjectCard, N as healthReportSchema, S as conversationAutoArchiveSchema, W as conversationObjectCard, b as archiveConversationResponseSchema, c as conversationSubscriptionResponseSchema, g as pinConversationResponseSchema, h as pinConversationBodySchema, l as setConversationSpaceBodySchema, m as renameConversationResponseSchema, o as conversationLeaveResponseSchema, p as renameConversationBodySchema, q as webPageObjectCard, r as stopConversationTurnResponseSchema, s as conversationSubscriptionBodySchema, u as setConversationSpaceResponseSchema, w as cancelConversationPendingMessagesResponseSchema, x as archiveDoneConversationsResponseSchema, y as archiveConversationBodySchema } from "./conversation-feed-Cj7IuBtM.js";
|
|
20
|
+
import { a as buildTurnThreadContext, c as AgentRunError, d as turnInputTelemetry, f as withTurnSpan, i as buildConversationContext, l as executeTurn, n as createConversationTurnWorker, o as stopAtAutomatedTurnLimit, r as supersedeTurnForInput, s as recordFinishedTurnForAutomatedLimit, u as getTurnInputSpanAttributes } from "./conversation-turn-Bru4w_FD.js";
|
|
21
|
+
import { n as attachmentFactLines, r as buildStoredAttachmentPromptText } from "./model-input-CFC62mf-.js";
|
|
22
|
+
import { a as getChildAgentLabel } from "./result-DxewDuXb.js";
|
|
23
|
+
import { t as bindMessageAgent } from "./message-BRUuLgrY.js";
|
|
24
|
+
import { t as readConversationLineage } from "./lineage-nh4z9iQN.js";
|
|
25
|
+
import { t as bindSpawnAgent } from "./spawn-DuZfodPa.js";
|
|
26
|
+
import { i as loadPendingMessageCards, n as persistAuthPauseTurnState, r as buildDeliveredTurnStatePatch, t as completeAuthPauseTurn } from "./auth-pause-state-f9hJM_zO.js";
|
|
27
|
+
import { c as readConversationEventPageAround, n as scheduleSessionCompletedPluginTasks, o as readConversationEventPage, s as readConversationEventPageAfter } from "./task-runner-BJ9Up3bG.js";
|
|
28
|
+
import { a as createAgentDispatchConversationWorker, i as buildDispatchRoutingContext, o as enqueueAgentDispatch, s as failStoppedDispatch, t as runConversation } from "./run-conversation-Cz2ubZK-.js";
|
|
29
|
+
import { n as getPausedTurnRequest, o as getTurnAuthorization, r as recordFailedDispatchTurn, t as createPausedTurns } from "./turn-wake-C7HeLHAM.js";
|
|
30
|
+
import { r as canContinueInSlack } from "./continue-in-slack-YxwMQVeR.js";
|
|
31
31
|
import * as z from "zod";
|
|
32
|
-
import {
|
|
33
|
-
import { EVENT_SUMMARY_MAX_LENGTH, EVENT_TEXT_MAX_LENGTH, conversationSidebarAnnotationSchema, createSlackSource, dispatchOptionsSchema, encodeObjectImageRef, escapeTagText, escapeTagTextAndQuotes, eventMatches, eventSchema, isSlackDestination, objectAnnotationSchema, objectLinkFilterMatches, objectLinkFilterSpecificity, objectTypeSchema, ownedObjectAnnotationSchema, renderEmptyTag, renderTag } from "@sentry/junior-plugin-api";
|
|
34
|
-
import { and, asc, count, desc, eq, gt, gte, inArray, isNotNull, isNull, lt, lte, min, ne, not, or, sql } from "drizzle-orm";
|
|
32
|
+
import { and, asc, count, desc, eq, gt, gte, inArray, isNotNull, isNull, lt, lte, min, ne, not, notInArray, or, sql } from "drizzle-orm";
|
|
35
33
|
import { alias } from "drizzle-orm/pg-core";
|
|
34
|
+
import { EVENT_SUMMARY_MAX_LENGTH, EVENT_TEXT_MAX_LENGTH, conversationSidebarAnnotationSchema, createSlackSource, dispatchOptionsSchema, encodeObjectImageRef, escapeTagText, escapeTagTextAndQuotes, eventMatches, eventSchema, isSlackDestination, objectAnnotationSchema, objectLinkFilterMatches, objectLinkFilterSpecificity, objectTypeSchema, ownedObjectAnnotationSchema, renderEmptyTag, renderTag } from "@sentry/junior-plugin-api";
|
|
35
|
+
import { createHash, createHmac, randomUUID, timingSafeEqual } from "node:crypto";
|
|
36
36
|
import pLimit from "p-limit";
|
|
37
37
|
import { performance } from "node:perf_hooks";
|
|
38
38
|
import { Message, ThreadImpl, stringifyMarkdown } from "chat";
|
|
@@ -4052,7 +4052,11 @@ function createSlackTurn(deps) {
|
|
|
4052
4052
|
...activeInstructionAuthorName ? { authorName: activeInstructionAuthorName } : void 0,
|
|
4053
4053
|
...slackMessageTs ? { slackTs: slackMessageTs } : void 0
|
|
4054
4054
|
},
|
|
4055
|
-
...
|
|
4055
|
+
...await withHeldInput({
|
|
4056
|
+
conversation: preparedState.conversation,
|
|
4057
|
+
conversationId,
|
|
4058
|
+
turnId
|
|
4059
|
+
}, savedInput),
|
|
4056
4060
|
context: promptConversationContext,
|
|
4057
4061
|
inboundAttachmentCount: turnAttachments.length,
|
|
4058
4062
|
omittedImageAttachmentCount,
|
|
@@ -6188,12 +6192,16 @@ async function runPausedTurnInContext(payload, options, runOptions) {
|
|
|
6188
6192
|
instruction: {
|
|
6189
6193
|
...instructionActor ? { actor: instructionActor } : void 0,
|
|
6190
6194
|
...getTurnUserReplyAttachmentContext(userMessage),
|
|
6191
|
-
...await
|
|
6195
|
+
...await withHeldInput({
|
|
6196
|
+
conversation,
|
|
6197
|
+
conversationId: payload.conversationId,
|
|
6198
|
+
turnId: payload.turnId
|
|
6199
|
+
}, await savedInputInstruction({
|
|
6192
6200
|
runtime: Boolean(dispatchId) || isEventConversationMessage(userMessage),
|
|
6193
6201
|
requestText: userMessage.meta?.requestText,
|
|
6194
6202
|
reviewItemChange: userMessage.meta?.reviewItemChanges?.[0],
|
|
6195
6203
|
text: userMessage.text
|
|
6196
|
-
})
|
|
6204
|
+
}))
|
|
6197
6205
|
},
|
|
6198
6206
|
history: dispatchId ? {
|
|
6199
6207
|
messages: activeTurn.piMessages,
|
|
@@ -6571,7 +6579,7 @@ function createConversationWork(options) {
|
|
|
6571
6579
|
const run = async (context) => {
|
|
6572
6580
|
await resumeForPersonInput(context.conversationId, context.attempt.messages);
|
|
6573
6581
|
const conversation = await options.conversationStore.get({ conversationId: context.conversationId });
|
|
6574
|
-
const topLevel = !conversation ||
|
|
6582
|
+
const topLevel = !conversation || isTopLevel(conversation);
|
|
6575
6583
|
return await withLogContext({ rootConversationId: conversation?.rootConversationId ?? (topLevel ? context.conversationId : void 0) }, () => runWithStopCascade(context));
|
|
6576
6584
|
};
|
|
6577
6585
|
return {
|
|
@@ -10275,7 +10283,7 @@ async function requireWebMessageConversation(viewer, conversationId, idempotency
|
|
|
10275
10283
|
if (!conversation) throwApiError(404, "Conversation not found.");
|
|
10276
10284
|
if (!acceptsWebMessages(conversation)) throwApiError(409, "Conversation does not accept web messages.");
|
|
10277
10285
|
const access = await readConversationAccessFromSql(getDb(), [conversationId], viewer);
|
|
10278
|
-
if (!canAddConversationMessages(access.get(conversationId))) throwApiError(403, "Only participants can add messages
|
|
10286
|
+
if (!canAddConversationMessages(access.get(conversationId))) throwApiError(403, "Only participants can add messages. Join the conversation first.");
|
|
10279
10287
|
return conversationId;
|
|
10280
10288
|
}
|
|
10281
10289
|
function actorFromViewer(viewer) {
|
|
@@ -12000,7 +12008,7 @@ function findThreadPlacement(threadId, tree, rootIds) {
|
|
|
12000
12008
|
*/
|
|
12001
12009
|
async function readFeedThreadRecords(db, rootIds, viewerUserId) {
|
|
12002
12010
|
if (rootIds.length === 0) return void 0;
|
|
12003
|
-
const rows = await selectConversationRecords(db).innerJoin(conversationSubtree(rootIds), eq(conversationSubtreeColumns.conversationId, juniorConversations.conversationId)).where(and(eq(juniorConversations.kind, "thread"), isNotNull(juniorConversations.parentConversationId),
|
|
12011
|
+
const rows = await selectConversationRecords(db).innerJoin(conversationSubtree(rootIds), eq(conversationSubtreeColumns.conversationId, juniorConversations.conversationId)).where(and(eq(juniorConversations.kind, "thread"), isNotNull(juniorConversations.parentConversationId), notInArray(juniorConversations.conversationId, rootIds), isNull(juniorConversations.archivedAt))).orderBy(desc(juniorConversations.lastActivityAt), asc(juniorConversations.conversationId));
|
|
12004
12012
|
if (rows.length === 0) return void 0;
|
|
12005
12013
|
const threads = rows.map((row) => ({
|
|
12006
12014
|
conversation: conversationFromRecordRow(row),
|
|
@@ -12305,7 +12313,7 @@ async function conversationRows(db, { codeRepository, conversationIds, cursor, f
|
|
|
12305
12313
|
links: include.includes("links") ? feedLinksSql(db) : sql`null`,
|
|
12306
12314
|
media: include.includes("media") ? feedMediaSql(db) : sql`null`,
|
|
12307
12315
|
viewerAnswer: filter?.kind === "viewer" ? feedViewerAnswerSql(db, filter.userId) : sql`null`
|
|
12308
|
-
}).from(juniorConversations).leftJoin(juniorDestinations, conversationRecordJoins.location).leftJoin(juniorIdentities, conversationRecordJoins.identity).leftJoin(juniorUsers, conversationRecordJoins.user).where(and(
|
|
12316
|
+
}).from(juniorConversations).leftJoin(juniorDestinations, conversationRecordJoins.location).leftJoin(juniorIdentities, conversationRecordJoins.identity).leftJoin(juniorUsers, conversationRecordJoins.user).where(and(space ? conversationSpaceFilter(space.id, status, space.viewerUserId) : and(listedConversation(), conversationFeedMembershipFilter(status, filter)), conversationIds ? inArray(juniorConversations.conversationId, conversationIds) : void 0, waitingForUserId ? inArray(juniorConversations.conversationId, waitingConversationIdsQuery(db, waitingForUserId)) : void 0, pinnedForUserId ? pinnedForUserId.pinned ? conversationPinnedForUser(pinnedForUserId.userId) : not(conversationPinnedForUser(pinnedForUserId.userId)) : void 0, cursor ? sql`(${juniorConversations.lastActivityAt} < ${cursor.at}::timestamptz or (${juniorConversations.lastActivityAt} = ${cursor.at}::timestamptz and ${juniorConversations.conversationId} > ${cursor.conversationId}))` : void 0, codeRepository ? conversationCodeRepositoryFilter(codeRepository.id, codeRepository.viewerUserId) : void 0, query ? or(sql`strpos(lower(coalesce(${juniorConversations.title}, '')), ${query}) > 0`, and(includePrivateMatches ? void 0 : isPublicConversation(juniorConversations), sql`${conversationSearchVector} @@ websearch_to_tsquery('english', ${query})`), annotationMatch(db, query, includePrivateMatches)) : void 0)).orderBy(desc(juniorConversations.lastActivityAt), asc(juniorConversations.conversationId)).$dynamic();
|
|
12309
12317
|
return limit === void 0 ? rows : rows.limit(limit);
|
|
12310
12318
|
}
|
|
12311
12319
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as withScope,
|
|
2
|
-
import { _ as getDeploymentTelemetryAttributes } from "./deployment-
|
|
1
|
+
import { _ as withScope, d as setTag, f as setUser, h as startSpan, i as getActiveSpan, l as logger, n as captureMessage, p as spanToJSON, s as getTraceData, t as captureException } from "./sentry-CPbZjomA.js";
|
|
2
|
+
import { _ as getDeploymentTelemetryAttributes } from "./deployment-C0qXa0FD.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { styleText } from "node:util";
|
|
5
5
|
import { ConfigError, configureSync, getConfig, getLogger } from "@logtape/logtape";
|
|
@@ -103,48 +103,6 @@ function getBoundLogContext() {
|
|
|
103
103
|
function getBoundLogAttributes() {
|
|
104
104
|
return logContextStorage.getStore() ?? {};
|
|
105
105
|
}
|
|
106
|
-
// src/chat/sentry-links.ts
|
|
107
|
-
function getSentryOrgSlug() {
|
|
108
|
-
return process.env["SENTRY_ORG_SLUG"]?.trim() || void 0;
|
|
109
|
-
}
|
|
110
|
-
function isSentrySaasDsnHost(host) {
|
|
111
|
-
return host === "sentry.io" || host.endsWith(".sentry.io");
|
|
112
|
-
}
|
|
113
|
-
function buildSentryWebBaseUrl(dsn) {
|
|
114
|
-
if (isSentrySaasDsnHost(dsn.host)) return "https://sentry.io";
|
|
115
|
-
const port = dsn.port ? `:${dsn.port}` : "";
|
|
116
|
-
const path = dsn.path ? `/${dsn.path}` : "";
|
|
117
|
-
return `${dsn.protocol}://${dsn.host}${port}${path}`;
|
|
118
|
-
}
|
|
119
|
-
function buildSentryOrgPath(args) {
|
|
120
|
-
const dsn = getClient()?.getDsn();
|
|
121
|
-
if (!dsn?.host || !dsn.projectId) return;
|
|
122
|
-
const orgSlug = getSentryOrgSlug();
|
|
123
|
-
if (!orgSlug) return;
|
|
124
|
-
const params = new URLSearchParams();
|
|
125
|
-
params.set("project", dsn.projectId);
|
|
126
|
-
if (args.query) for (const [key, value] of Object.entries(args.query)) params.set(key, value);
|
|
127
|
-
const path = `${args.path}?${params.toString()}`;
|
|
128
|
-
if (isSentrySaasDsnHost(dsn.host)) return `https://${orgSlug}.sentry.io/${path}`;
|
|
129
|
-
return `${buildSentryWebBaseUrl(dsn)}/organizations/${orgSlug}/${path}`;
|
|
130
|
-
}
|
|
131
|
-
/** Build a Sentry conversation URL only when the runtime has enough Sentry config. */
|
|
132
|
-
function buildSentryConversationUrl(conversationId) {
|
|
133
|
-
return buildSentryOrgPath({ path: `explore/conversations/${encodeURIComponent(conversationId)}/` });
|
|
134
|
-
}
|
|
135
|
-
/** Build a Sentry event URL only when the runtime has enough Sentry config. */
|
|
136
|
-
function buildSentryEventUrl(eventId) {
|
|
137
|
-
return buildSentryOrgPath({
|
|
138
|
-
path: "issues/",
|
|
139
|
-
query: { query: eventId }
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
/** Format a failure reference, linked to the Sentry event when the runtime can build the URL. */
|
|
143
|
-
function formatSentryEventReference(eventId) {
|
|
144
|
-
const reference = `event_id=${eventId}`;
|
|
145
|
-
const url = buildSentryEventUrl(eventId);
|
|
146
|
-
return url ? `[${reference}](${url})` : `\`${reference}\``;
|
|
147
|
-
}
|
|
148
106
|
// src/chat/logging.ts
|
|
149
107
|
/**
|
|
150
108
|
* Structured logging for Junior runtime events.
|
|
@@ -1099,10 +1057,6 @@ function getActiveTraceId() {
|
|
|
1099
1057
|
return;
|
|
1100
1058
|
}
|
|
1101
1059
|
}
|
|
1102
|
-
/** Build the static user-facing response for a failed turn. */
|
|
1103
|
-
function buildTurnFailureResponse(eventId) {
|
|
1104
|
-
return `I ran into an internal error while processing that. Reference: ${formatSentryEventReference(eventId)}.`;
|
|
1105
|
-
}
|
|
1106
1060
|
const GEN_AI_DEFAULT_MAX_ATTRIBUTE_CHARS = 1e5;
|
|
1107
1061
|
const GEN_AI_MAX_ARRAY_ITEMS = 50;
|
|
1108
1062
|
const GEN_AI_MAX_OBJECT_KEYS = 50;
|
|
@@ -1248,4 +1202,4 @@ function extractGenAiUsageAttributes(...sources) {
|
|
|
1248
1202
|
...cost?.total !== void 0 ? { "app.cost.total_usd": cost.total } : void 0
|
|
1249
1203
|
};
|
|
1250
1204
|
}
|
|
1251
|
-
export {
|
|
1205
|
+
export { toOptionalString as A, withContext as C, GOOGLE_IDENTITY_PROVIDER as D, runWithLogAttributes as E, isNativeIdentityProvider as O, summarizeMessageText as S, withSpan as T, serializeGenAiAttribute as _, getActiveTraceContext as a, setSpanStatus as b, getLogContextAttributesForSpan as c, logError as d, logException as f, runBestEffort as g, normalizeGenAiFinishReason as h, extractGenAiUsageSummary as i, normalizeIdentityEmail as k, getTracePropagationHeaders as l, logWarn as m, createRequestContext as n, getActiveTraceId as o, logInfo as p, extractGenAiUsageAttributes as r, getLogContextAttributes as s, createChatSdkLogger as t, logAudit as u, setSentryUser as v, withLogContext as w, setTags as x, setSpanAttributes as y };
|