@sentry/junior 0.9.2 → 0.9.3
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/{chunk-7DAWPSTI.js → chunk-HRA2FXYH.js} +13 -28
- package/dist/{chunk-OPT4JB73.js → chunk-LWHXDHIN.js} +14 -67
- package/dist/{chunk-D4ULS2MW.js → chunk-PEJ6SSW4.js} +1 -1
- package/dist/{chunk-KZWHD5KH.js → chunk-XHISVOAJ.js} +2 -2
- package/dist/cli/snapshot-warmup.js +1 -1
- package/dist/handlers/queue-callback.js +3 -3
- package/dist/handlers/router.js +4 -4
- package/dist/handlers/webhooks.js +1 -1
- package/dist/{production-H3THODDE.js → production-BGZNVORK.js} +2 -2
- package/package.json +1 -1
|
@@ -6,6 +6,15 @@ import {
|
|
|
6
6
|
withSpan
|
|
7
7
|
} from "./chunk-ZW4OVKF5.js";
|
|
8
8
|
|
|
9
|
+
// src/chat/optional-string.ts
|
|
10
|
+
function toOptionalTrimmed(value) {
|
|
11
|
+
if (!value) {
|
|
12
|
+
return void 0;
|
|
13
|
+
}
|
|
14
|
+
const trimmed = value.trim();
|
|
15
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
9
18
|
// src/chat/config.ts
|
|
10
19
|
var MIN_AGENT_TURN_TIMEOUT_MS = 10 * 1e3;
|
|
11
20
|
var DEFAULT_AGENT_TURN_TIMEOUT_MS = 12 * 60 * 1e3;
|
|
@@ -35,13 +44,6 @@ function resolveMaxTurnTimeoutMs(queueCallbackMaxDurationSeconds) {
|
|
|
35
44
|
const budgetSeconds = queueCallbackMaxDurationSeconds - TURN_TIMEOUT_BUFFER_SECONDS;
|
|
36
45
|
return Math.max(MIN_AGENT_TURN_TIMEOUT_MS, budgetSeconds * 1e3);
|
|
37
46
|
}
|
|
38
|
-
function toOptionalTrimmed(value) {
|
|
39
|
-
if (!value) {
|
|
40
|
-
return void 0;
|
|
41
|
-
}
|
|
42
|
-
const trimmed = value.trim();
|
|
43
|
-
return trimmed.length > 0 ? trimmed : void 0;
|
|
44
|
-
}
|
|
45
47
|
function readBotConfig(env) {
|
|
46
48
|
const queueCallbackMaxDurationSeconds = resolveQueueCallbackMaxDurationSeconds(env);
|
|
47
49
|
const maxTurnTimeoutMs = resolveMaxTurnTimeoutMs(
|
|
@@ -236,31 +238,13 @@ async function runNonInteractiveCommand(runner, input) {
|
|
|
236
238
|
}
|
|
237
239
|
|
|
238
240
|
// src/chat/sandbox/credentials.ts
|
|
239
|
-
function toOptionalTrimmed2(value) {
|
|
240
|
-
if (!value) {
|
|
241
|
-
return void 0;
|
|
242
|
-
}
|
|
243
|
-
const trimmed = value.trim();
|
|
244
|
-
return trimmed.length > 0 ? trimmed : void 0;
|
|
245
|
-
}
|
|
246
|
-
function isVercelRuntime() {
|
|
247
|
-
return process.env.VERCEL === "1" || Boolean(process.env.VERCEL_ENV) || Boolean(process.env.VERCEL_REGION) || Boolean(process.env.VERCEL_URL);
|
|
248
|
-
}
|
|
249
241
|
function getVercelSandboxCredentials() {
|
|
250
|
-
const token =
|
|
251
|
-
const teamId =
|
|
252
|
-
const projectId =
|
|
242
|
+
const token = toOptionalTrimmed(process.env.VERCEL_TOKEN);
|
|
243
|
+
const teamId = toOptionalTrimmed(process.env.VERCEL_TEAM_ID);
|
|
244
|
+
const projectId = toOptionalTrimmed(process.env.VERCEL_PROJECT_ID);
|
|
253
245
|
if (token && teamId && projectId) {
|
|
254
246
|
return { token, teamId, projectId };
|
|
255
247
|
}
|
|
256
|
-
if (toOptionalTrimmed2(process.env.VERCEL_OIDC_TOKEN) || isVercelRuntime()) {
|
|
257
|
-
return void 0;
|
|
258
|
-
}
|
|
259
|
-
if (token || teamId || projectId) {
|
|
260
|
-
throw new Error(
|
|
261
|
-
"Missing Vercel Sandbox credentials: set VERCEL_TOKEN, VERCEL_TEAM_ID, and VERCEL_PROJECT_ID together, or provide VERCEL_OIDC_TOKEN."
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
248
|
return void 0;
|
|
265
249
|
}
|
|
266
250
|
|
|
@@ -821,6 +805,7 @@ function isSnapshotMissingError(error) {
|
|
|
821
805
|
}
|
|
822
806
|
|
|
823
807
|
export {
|
|
808
|
+
toOptionalTrimmed,
|
|
824
809
|
botConfig,
|
|
825
810
|
getSlackBotToken,
|
|
826
811
|
getSlackSigningSecret,
|
|
@@ -25,8 +25,9 @@ import {
|
|
|
25
25
|
isSnapshotMissingError,
|
|
26
26
|
resolveRuntimeDependencySnapshot,
|
|
27
27
|
runNonInteractiveCommand,
|
|
28
|
-
sandboxSkillDir
|
|
29
|
-
|
|
28
|
+
sandboxSkillDir,
|
|
29
|
+
toOptionalTrimmed
|
|
30
|
+
} from "./chunk-HRA2FXYH.js";
|
|
30
31
|
import {
|
|
31
32
|
CredentialUnavailableError,
|
|
32
33
|
createPluginBroker,
|
|
@@ -846,24 +847,10 @@ var GATEWAY_PROVIDER = "vercel-ai-gateway";
|
|
|
846
847
|
var GEN_AI_PROVIDER_NAME = GATEWAY_PROVIDER;
|
|
847
848
|
var GEN_AI_OPERATION_CHAT = "chat";
|
|
848
849
|
var MISSING_GATEWAY_CREDENTIALS_ERROR = "Missing AI gateway credentials (AI_GATEWAY_API_KEY or VERCEL_OIDC_TOKEN)";
|
|
849
|
-
function toOptionalTrimmed(value) {
|
|
850
|
-
if (!value) {
|
|
851
|
-
return void 0;
|
|
852
|
-
}
|
|
853
|
-
const trimmed = value.trim();
|
|
854
|
-
return trimmed.length > 0 ? trimmed : void 0;
|
|
855
|
-
}
|
|
856
|
-
function isVercelRuntime() {
|
|
857
|
-
return process.env.VERCEL === "1" || Boolean(process.env.VERCEL_ENV) || Boolean(process.env.VERCEL_REGION);
|
|
858
|
-
}
|
|
859
850
|
function getGatewayApiKey() {
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
}
|
|
864
|
-
if (!isVercelRuntime()) {
|
|
865
|
-
return void 0;
|
|
866
|
-
}
|
|
851
|
+
return toOptionalTrimmed(getEnvApiKey("vercel-ai-gateway")) ?? toOptionalTrimmed(process.env.VERCEL_OIDC_TOKEN);
|
|
852
|
+
}
|
|
853
|
+
function getPiGatewayApiKeyOverride() {
|
|
867
854
|
return toOptionalTrimmed(process.env.VERCEL_OIDC_TOKEN);
|
|
868
855
|
}
|
|
869
856
|
function extractText(message) {
|
|
@@ -930,18 +917,7 @@ function parseJsonCandidate(text) {
|
|
|
930
917
|
}
|
|
931
918
|
}
|
|
932
919
|
function resolveGatewayModel(modelId) {
|
|
933
|
-
|
|
934
|
-
try {
|
|
935
|
-
models = getModels(GATEWAY_PROVIDER);
|
|
936
|
-
} catch (error) {
|
|
937
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
938
|
-
if (message.includes('missing "key" field')) {
|
|
939
|
-
throw new Error(
|
|
940
|
-
"Invalid AI gateway credentials: Vercel API did not return a key. Set AI_GATEWAY_API_KEY, or ensure VERCEL_OIDC_TOKEN is valid in a Vercel runtime."
|
|
941
|
-
);
|
|
942
|
-
}
|
|
943
|
-
throw error;
|
|
944
|
-
}
|
|
920
|
+
const models = getModels(GATEWAY_PROVIDER);
|
|
945
921
|
const matched = models.find((model) => model.id === modelId);
|
|
946
922
|
if (!matched) {
|
|
947
923
|
throw new Error(`Unknown AI Gateway model id: ${modelId}`);
|
|
@@ -950,18 +926,15 @@ function resolveGatewayModel(modelId) {
|
|
|
950
926
|
}
|
|
951
927
|
async function completeText(params) {
|
|
952
928
|
const startedAt = Date.now();
|
|
953
|
-
if (!getGatewayApiKey()) {
|
|
954
|
-
throw new Error(MISSING_GATEWAY_CREDENTIALS_ERROR);
|
|
955
|
-
}
|
|
956
929
|
const model = resolveGatewayModel(params.modelId);
|
|
957
|
-
const apiKey =
|
|
930
|
+
const apiKey = getPiGatewayApiKeyOverride();
|
|
958
931
|
const requestMessagesAttribute = serializeGenAiAttribute(params.messages);
|
|
959
932
|
const startAttributes = {
|
|
960
933
|
"gen_ai.provider.name": GEN_AI_PROVIDER_NAME,
|
|
961
934
|
"gen_ai.operation.name": GEN_AI_OPERATION_CHAT,
|
|
962
935
|
"gen_ai.request.model": params.modelId,
|
|
963
936
|
...requestMessagesAttribute ? { "gen_ai.input.messages": requestMessagesAttribute } : {},
|
|
964
|
-
"app.ai.auth_mode": apiKey ? "
|
|
937
|
+
"app.ai.auth_mode": apiKey ? "oidc" : "api_key"
|
|
965
938
|
};
|
|
966
939
|
setSpanAttributes(startAttributes);
|
|
967
940
|
const message = await completeSimple(
|
|
@@ -4507,11 +4480,9 @@ function createImageGenerateTool(hooks, deps = {}) {
|
|
|
4507
4480
|
}),
|
|
4508
4481
|
execute: async ({ prompt }) => {
|
|
4509
4482
|
const fetchImpl = deps.fetch ?? fetch;
|
|
4510
|
-
const apiKey =
|
|
4483
|
+
const apiKey = getGatewayApiKey();
|
|
4511
4484
|
if (!apiKey) {
|
|
4512
|
-
throw new Error(
|
|
4513
|
-
"Missing AI gateway credentials (AI_GATEWAY_API_KEY or VERCEL_OIDC_TOKEN)"
|
|
4514
|
-
);
|
|
4485
|
+
throw new Error(MISSING_GATEWAY_CREDENTIALS_ERROR);
|
|
4515
4486
|
}
|
|
4516
4487
|
const model = process.env.AI_IMAGE_MODEL ?? DEFAULT_IMAGE_MODEL;
|
|
4517
4488
|
const enrichedPrompt = await enrichImagePrompt(prompt);
|
|
@@ -6306,7 +6277,7 @@ function formatSearchFailure(error) {
|
|
|
6306
6277
|
}
|
|
6307
6278
|
function isNonRetryableSearchFailure(message) {
|
|
6308
6279
|
const normalized = message.toLowerCase();
|
|
6309
|
-
return normalized.includes("missing ai gateway credentials");
|
|
6280
|
+
return normalized.includes("missing ai gateway credentials") || normalized.includes("authentication failed");
|
|
6310
6281
|
}
|
|
6311
6282
|
function isTimeoutSearchFailure(message) {
|
|
6312
6283
|
return /timed out/i.test(message);
|
|
@@ -6331,14 +6302,8 @@ function createWebSearchTool() {
|
|
|
6331
6302
|
execute: async ({ query, max_results }) => {
|
|
6332
6303
|
const maxResults = max_results ?? 3;
|
|
6333
6304
|
try {
|
|
6334
|
-
const apiKey = getGatewayApiKey();
|
|
6335
|
-
if (!apiKey) {
|
|
6336
|
-
throw new Error(
|
|
6337
|
-
"Missing AI gateway credentials (AI_GATEWAY_API_KEY or VERCEL_OIDC_TOKEN)"
|
|
6338
|
-
);
|
|
6339
|
-
}
|
|
6340
6305
|
const model = process.env.AI_WEB_SEARCH_MODEL ?? process.env.AI_FAST_MODEL ?? process.env.AI_MODEL ?? DEFAULT_SEARCH_MODEL;
|
|
6341
|
-
const provider = createGatewayProvider(
|
|
6306
|
+
const provider = createGatewayProvider();
|
|
6342
6307
|
const response = await withTimeout(
|
|
6343
6308
|
(async () => {
|
|
6344
6309
|
try {
|
|
@@ -9165,24 +9130,6 @@ async function generateAssistantReply(messageText, context = {}) {
|
|
|
9165
9130
|
userInput,
|
|
9166
9131
|
context.conversationContext
|
|
9167
9132
|
);
|
|
9168
|
-
if (!getGatewayApiKey()) {
|
|
9169
|
-
const providerError = "Missing AI gateway credentials (AI_GATEWAY_API_KEY or VERCEL_OIDC_TOKEN)";
|
|
9170
|
-
return {
|
|
9171
|
-
text: `Error: ${providerError}`,
|
|
9172
|
-
sandboxId: sandboxExecutor.getSandboxId(),
|
|
9173
|
-
sandboxDependencyProfileHash: sandboxExecutor.getDependencyProfileHash(),
|
|
9174
|
-
diagnostics: {
|
|
9175
|
-
outcome: "provider_error",
|
|
9176
|
-
modelId: botConfig.modelId,
|
|
9177
|
-
assistantMessageCount: 0,
|
|
9178
|
-
toolCalls: [],
|
|
9179
|
-
toolResultCount: 0,
|
|
9180
|
-
toolErrorCount: 0,
|
|
9181
|
-
usedPrimaryText: false,
|
|
9182
|
-
errorMessage: providerError
|
|
9183
|
-
}
|
|
9184
|
-
};
|
|
9185
|
-
}
|
|
9186
9133
|
timeoutResumeMessages = [];
|
|
9187
9134
|
pendingMcpAuthorizationPause = void 0;
|
|
9188
9135
|
const generatedFiles = [];
|
|
@@ -9387,7 +9334,7 @@ async function generateAssistantReply(messageText, context = {}) {
|
|
|
9387
9334
|
}
|
|
9388
9335
|
);
|
|
9389
9336
|
agent = new Agent({
|
|
9390
|
-
getApiKey: () =>
|
|
9337
|
+
getApiKey: () => getPiGatewayApiKeyOverride(),
|
|
9391
9338
|
initialState: {
|
|
9392
9339
|
systemPrompt: baseInstructions,
|
|
9393
9340
|
model: resolveGatewayModel(botConfig.modelId),
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import { after } from "next/server";
|
|
13
13
|
import * as Sentry from "@sentry/nextjs";
|
|
14
14
|
async function loadBot() {
|
|
15
|
-
const { bot } = await import("./production-
|
|
15
|
+
const { bot } = await import("./production-BGZNVORK.js");
|
|
16
16
|
return bot;
|
|
17
17
|
}
|
|
18
18
|
async function POST(request, context) {
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
getThreadMessageTopic,
|
|
8
8
|
removeReactionFromMessage,
|
|
9
9
|
slackRuntime
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-LWHXDHIN.js";
|
|
11
11
|
import {
|
|
12
12
|
getConnectedStateContext,
|
|
13
13
|
getStateAdapter
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-HRA2FXYH.js";
|
|
15
15
|
import {
|
|
16
16
|
createRequestContext,
|
|
17
17
|
logError,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
POST
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-XHISVOAJ.js";
|
|
4
|
+
import "../chunk-LWHXDHIN.js";
|
|
5
5
|
import "../chunk-VM3CPAZF.js";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-HRA2FXYH.js";
|
|
7
7
|
import "../chunk-ZBWWHP6Q.js";
|
|
8
8
|
import "../chunk-KCLEEKYX.js";
|
|
9
9
|
import "../chunk-ZW4OVKF5.js";
|
package/dist/handlers/router.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
POST as POST2
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-PEJ6SSW4.js";
|
|
4
4
|
import {
|
|
5
5
|
POST
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-XHISVOAJ.js";
|
|
7
7
|
import {
|
|
8
8
|
buildConversationContext,
|
|
9
9
|
buildSlackOutputMessage,
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
updateConversationStats,
|
|
32
32
|
uploadFilesToThread,
|
|
33
33
|
upsertConversationMessage
|
|
34
|
-
} from "../chunk-
|
|
34
|
+
} from "../chunk-LWHXDHIN.js";
|
|
35
35
|
import {
|
|
36
36
|
GET
|
|
37
37
|
} from "../chunk-4RBEYCOG.js";
|
|
@@ -39,7 +39,7 @@ import "../chunk-VM3CPAZF.js";
|
|
|
39
39
|
import {
|
|
40
40
|
botConfig,
|
|
41
41
|
getStateAdapter
|
|
42
|
-
} from "../chunk-
|
|
42
|
+
} from "../chunk-HRA2FXYH.js";
|
|
43
43
|
import {
|
|
44
44
|
buildOAuthTokenRequest,
|
|
45
45
|
getPluginOAuthConfig,
|
|
@@ -2,9 +2,9 @@ import {
|
|
|
2
2
|
bot,
|
|
3
3
|
createNormalizingStream,
|
|
4
4
|
slackRuntime
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-LWHXDHIN.js";
|
|
6
6
|
import "./chunk-VM3CPAZF.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-HRA2FXYH.js";
|
|
8
8
|
import "./chunk-ZBWWHP6Q.js";
|
|
9
9
|
import "./chunk-KCLEEKYX.js";
|
|
10
10
|
import "./chunk-ZW4OVKF5.js";
|