@sentry/junior 0.302.0 → 0.304.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-Cx9fn9B3.js → adapter-context-B1IpoELr.js} +2 -2
- package/dist/{admin-_poE5NKL.js → admin-BnVFGo_z.js} +5 -5
- package/dist/{agent-runner-CY9RvsTX.js → agent-runner-CoEeZSRh.js} +1461 -1248
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +6 -6
- package/dist/api.d.ts +13 -12
- package/dist/api.js +230 -105
- package/dist/{app-BpY3wtRP.d.ts → app-Cs157Zc5.d.ts} +17 -15
- package/dist/app.d.ts +1 -1
- package/dist/app.js +108 -96
- package/dist/{automation-Cva5ZOwW.js → automation-CuA3yEcD.js} +3 -1
- package/dist/{background-compaction-queue-CXFq1_Cz.js → background-compaction-queue-WLPNSF_b.js} +6 -6
- package/dist/{briefs-B3NG-pid.js → briefs-CagVVefw.js} +12 -9
- package/dist/{catalog-runtime-Dss0lSV6.js → catalog-runtime-B8ZXvXWm.js} +2 -2
- package/dist/cli/chat.d.ts +1 -1
- package/dist/cli/chat.js +21 -21
- package/dist/cli/check.js +10 -10
- 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 +6 -6
- package/dist/{config-CzeZiMKs.js → config-DdO1BNcw.js} +142 -67
- package/dist/{connections-CDYhMfrs.js → connections-D20kp0j5.js} +6 -6
- package/dist/{continue-in-slack-7Uf05ndC.js → continue-in-slack-BKEVMBj1.js} +8 -8
- package/dist/{conversation-BNXfq6Lb.js → conversation-BOqdRtUx.js} +4 -12
- package/dist/{conversation-feed-Clf_cv0n.js → conversation-feed-CgpgP7yi.js} +35 -2
- package/dist/{conversation-privacy-D9xnM5mK.js → conversation-privacy-L1SK_v0V.js} +16 -8
- package/dist/{conversation-turn-D7SEZgTG.js → conversation-turn-BptVJylj.js} +20 -23
- package/dist/{credential-sync-DoD0gW-j.js → credential-sync-D1J1CGzL.js} +19 -19
- package/dist/{db-B-gtnNjr.js → db-EKJnkrIb.js} +180 -17
- package/dist/{db-BdsCzytP.d.ts → db-zbN5ZV_o.d.ts} +26 -26
- package/dist/{executor-DZg20EqU.js → executor-CoIZmFK8.js} +55 -15
- package/dist/{history-IjdmO_r6.js → history-m2-ceTTX.js} +21 -12
- package/dist/{install-t1KQyTUs.js → install-BT2Pf6HP.js} +3 -3
- package/dist/instrumentation.d.ts +4 -4
- package/dist/instrumentation.js +15 -11
- package/dist/{lineage-C79GjoQr.js → lineage-C5DGQCS_.js} +2 -2
- package/dist/{logging-C9oDAg4M.js → logging-QSZuMcvo.js} +19 -19
- package/dist/{message-BLUCzJXN.js → message-TtxftRHj.js} +9 -9
- package/dist/{model-input-5jwNC45G.js → model-input-BHXfA29g.js} +4 -9
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +8 -8
- package/dist/{oauth-callback-server-BBl66vCb.js → oauth-callback-server-B0enqHtZ.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-CIBwgD3s.js → projection-CNKK7doO.js} +755 -221
- package/dist/{prompt-CRQbzp5e.js → prompt-DSjhoKu5.js} +185 -12
- package/dist/{queue-DtCDaIct.js → queue-CDxkit82.js} +4 -4
- package/dist/{queue-CZyYgPF0.d.ts → queue-CbEHUO0l.d.ts} +1 -1
- package/dist/{registry-DdFQHZ_d.js → registry-DBDNUUmz.js} +37 -37
- package/dist/{resolve-CdW4BdrK.js → resolve-CQLhMWSu.js} +3 -3
- package/dist/{result-oOMv1t4O.js → result-B-pauj42.js} +10 -15
- package/dist/rolldown-runtime-BKpuH2hG.js +26 -0
- package/dist/{runner-DqitLtm-.js → runner-B3KxKks5.js} +10 -10
- package/dist/{sandbox-egress-signals-Bw9I0yfJ.js → sandbox-egress-signals-DJJX9ClG.js} +1 -1
- package/dist/{schema-DnVQepWP.js → schema-Bx0Mlo32.js} +77 -13
- package/dist/{schema-BIFM-U1a.d.ts → schema-CKcu-IK6.d.ts} +562 -23
- 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-CrZftRTb.js → service-account-2HmlNPvy.js} +49 -48
- package/dist/{service-account-B6mKAPVo.js → service-account-DQLqkSVv.js} +5 -5
- package/dist/{session-stop-DW63Z3kj.js → session-stop-DEeZKqbX.js} +132 -74
- package/dist/{skills-C16fz60Z.js → skills-2UrD7JkN.js} +6 -9
- package/dist/{slack-conversation-unfurl-BHhefEb7.js → slack-conversation-unfurl-Dd129Uov.js} +14 -18
- package/dist/{spawn-D_RnFYfy.js → spawn-eMho9HDJ.js} +7 -7
- package/dist/{legacy-web-actor-id-C-cEeWqL.js → state-Bveuc4Zh.js} +32 -32
- package/dist/{stop-7p1i08CY.js → stop-D_ltJLDS.js} +359 -171
- package/dist/{store-C28I0CVW.js → store-COeYnPL_.js} +5 -5
- package/dist/{task-queue-BVUJbQ28.js → task-queue-CBIDXZpV.js} +3 -3
- package/dist/{task-runner-CWi8j7Z6.js → task-runner-CJF7zIJL.js} +15 -18
- package/dist/{thread-context-D3-yYUd0.js → thread-context-Cg0jt0aE.js} +12 -12
- package/dist/{turn-session-routing-BFMS9ATF.js → turn-session-routing-CaY3Tp8m.js} +32 -32
- package/dist/{turn-user-message-C3-O8Omt.js → turn-user-message-tcom1RYd.js} +3 -3
- package/dist/{validation-BSFKUIb4.js → validation-EU91JwIT.js} +2 -2
- package/dist/vercel.js +1 -1
- package/dist/{version-BHHXNi-0.js → version-BYRPhY5G.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-B1SO21Qa.js → viewer-Cf8ISkAc.js} +3 -3
- package/dist/{warmup-Bz9bzkzN.js → warmup-TgY4S1vx.js} +202 -577
- package/dist/{worker-BspReIIK.js → worker-C6Uq4OKD.js} +9 -12
- package/migrations/0109_user_preferences.sql +1 -0
- package/migrations/0110_code_change_repository_state_index.sql +1 -0
- package/migrations/0111_attachment_kinds.sql +14 -0
- package/migrations/0112_attachment_url_fill.sql +51 -0
- package/migrations/0113_attachment_url_index.sql +1 -0
- package/migrations/meta/0099_snapshot.json +102 -326
- package/migrations/meta/0109_snapshot.json +4925 -0
- package/migrations/meta/0110_snapshot.json +4952 -0
- package/migrations/meta/0111_snapshot.json +5011 -0
- package/migrations/meta/0112_snapshot.json +5011 -0
- package/migrations/meta/0113_snapshot.json +5033 -0
- package/migrations/meta/_journal.json +36 -1
- package/package.json +16 -19
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { E as withSpan, g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, p as logException, v as serializeGenAiAttribute } from "./logging-
|
|
3
|
-
import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
|
|
2
|
+
import { E as withSpan, g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, p as logException, v as serializeGenAiAttribute } from "./logging-QSZuMcvo.js";
|
|
3
|
+
import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-L1SK_v0V.js";
|
|
4
4
|
import { AwsClient } from "aws4fetch";
|
|
5
5
|
import { del, get, issueSignedToken, presignUrl, put } from "@vercel/blob";
|
|
6
6
|
import * as z from "zod";
|
|
@@ -8,8 +8,9 @@ import { calculateCost, completeSimple, getEnvApiKey, getModels, registerApiProv
|
|
|
8
8
|
import { stream as streamAnthropic, streamSimple as streamSimpleAnthropic } from "@earendil-works/pi-ai/api/anthropic-messages";
|
|
9
9
|
import { createGatewayProvider } from "@ai-sdk/gateway";
|
|
10
10
|
import { getVercelOidcToken } from "@vercel/oidc";
|
|
11
|
-
import { Experimental_DecisionRefusalError, NoObjectGeneratedError, embedMany, experimental_decide, generateObject, rerank } from "ai";
|
|
11
|
+
import { Experimental_DecisionRefusalError, NoImageGeneratedError, NoObjectGeneratedError, embedMany, experimental_decide, generateImage, generateObject, generateText, rerank } from "ai";
|
|
12
12
|
import { createHash } from "node:crypto";
|
|
13
|
+
import { renderSystemMessageUpdate } from "@earendil-works/pi-ai";
|
|
13
14
|
// src/chat/optional-string.ts
|
|
14
15
|
/**
|
|
15
16
|
* Normalize optional env-style strings so blank values do not masquerade as
|
|
@@ -102,6 +103,21 @@ function createVercelAttachmentStorage() {
|
|
|
102
103
|
url: presignedUrl
|
|
103
104
|
};
|
|
104
105
|
},
|
|
106
|
+
async createDownloadUrl(input) {
|
|
107
|
+
const token = await issueSignedToken({
|
|
108
|
+
operations: ["get"],
|
|
109
|
+
pathname: input.key,
|
|
110
|
+
validUntil: input.expiresAtMs
|
|
111
|
+
});
|
|
112
|
+
const { presignedUrl } = await presignUrl(token, {
|
|
113
|
+
access: "private",
|
|
114
|
+
operation: "get",
|
|
115
|
+
pathname: input.key,
|
|
116
|
+
useCache: false,
|
|
117
|
+
validUntil: input.expiresAtMs
|
|
118
|
+
});
|
|
119
|
+
return presignedUrl;
|
|
120
|
+
},
|
|
105
121
|
async get(key, range) {
|
|
106
122
|
const result = await get(key, {
|
|
107
123
|
access: "private",
|
|
@@ -167,7 +183,7 @@ function readS3StorageConfig(env) {
|
|
|
167
183
|
accessKeyId: readRequiredSetting(env, "JUNIOR_S3_ACCESS_KEY_ID"),
|
|
168
184
|
bucket: readRequiredSetting(env, "JUNIOR_S3_BUCKET"),
|
|
169
185
|
endpoint: readRequiredSetting(env, "JUNIOR_S3_ENDPOINT"),
|
|
170
|
-
region: toOptionalTrimmed(env
|
|
186
|
+
region: toOptionalTrimmed(env["JUNIOR_S3_REGION"]) ?? "us-east-1",
|
|
171
187
|
secretAccessKey: readRequiredSetting(env, "JUNIOR_S3_SECRET_ACCESS_KEY")
|
|
172
188
|
};
|
|
173
189
|
}
|
|
@@ -198,6 +214,10 @@ async function expectOk(response, operation) {
|
|
|
198
214
|
await drain(response);
|
|
199
215
|
if (!response.ok) throw new Error(`S3 ${operation} failed with status ${response.status}`);
|
|
200
216
|
}
|
|
217
|
+
/** Presigned URL lifetime in whole seconds, at least one. */
|
|
218
|
+
function expiresInSeconds(expiresAtMs) {
|
|
219
|
+
return String(Math.max(1, Math.ceil((expiresAtMs - Date.now()) / 1e3)));
|
|
220
|
+
}
|
|
201
221
|
/** Store private conversation attachments in an S3-compatible bucket. */
|
|
202
222
|
function createS3AttachmentStorage(config) {
|
|
203
223
|
const client = new AwsClient({
|
|
@@ -228,7 +248,7 @@ function createS3AttachmentStorage(config) {
|
|
|
228
248
|
},
|
|
229
249
|
async createUploadTarget(input) {
|
|
230
250
|
const url = new URL(objectUrl(config, input.key));
|
|
231
|
-
url.searchParams.set("X-Amz-Expires",
|
|
251
|
+
url.searchParams.set("X-Amz-Expires", expiresInSeconds(input.expiresAtMs));
|
|
232
252
|
const browserHeaders = {
|
|
233
253
|
"content-type": input.contentType,
|
|
234
254
|
"if-none-match": "*"
|
|
@@ -249,6 +269,14 @@ function createS3AttachmentStorage(config) {
|
|
|
249
269
|
})).url
|
|
250
270
|
};
|
|
251
271
|
},
|
|
272
|
+
async createDownloadUrl(input) {
|
|
273
|
+
const url = new URL(objectUrl(config, input.key));
|
|
274
|
+
url.searchParams.set("X-Amz-Expires", expiresInSeconds(input.expiresAtMs));
|
|
275
|
+
return (await client.sign(url.toString(), {
|
|
276
|
+
aws: { signQuery: true },
|
|
277
|
+
method: "GET"
|
|
278
|
+
})).url;
|
|
279
|
+
},
|
|
252
280
|
async get(key, range) {
|
|
253
281
|
const response = await client.fetch(objectUrl(config, key), range ? { headers: { range: rangeHeader(range) } } : void 0);
|
|
254
282
|
if (response.status === 404) {
|
|
@@ -277,7 +305,7 @@ function createS3AttachmentStorage(config) {
|
|
|
277
305
|
// src/chat/attachments/config.ts
|
|
278
306
|
/** Read attachment storage settings from environment variables. */
|
|
279
307
|
function readAttachmentStorageConfig(env) {
|
|
280
|
-
const provider = toOptionalTrimmed(env
|
|
308
|
+
const provider = toOptionalTrimmed(env["JUNIOR_ATTACHMENT_STORAGE_PROVIDER"]) ?? "vercel-blob";
|
|
281
309
|
switch (provider) {
|
|
282
310
|
case "vercel-blob":
|
|
283
311
|
case "memory": return { provider };
|
|
@@ -315,11 +343,11 @@ function parseKey(entry, index) {
|
|
|
315
343
|
}
|
|
316
344
|
/** Parse and check the encryption keyring from environment variables. */
|
|
317
345
|
function readEncryptionKeyring(env) {
|
|
318
|
-
const entries = (env
|
|
346
|
+
const entries = (env["JUNIOR_ENCRYPTION_KEYS"] ?? "").split(",").map((entry) => entry.trim()).filter(Boolean);
|
|
319
347
|
if (entries.length === 0) throw new Error("JUNIOR_ENCRYPTION_KEYS is required. Generate a key with: node -e \"console.log('k1:' + require('node:crypto').randomBytes(32).toString('base64url'))\"");
|
|
320
348
|
const keys = entries.map(parseKey);
|
|
321
349
|
if (new Set(keys.map((key) => key.id)).size !== keys.length) throw new Error("JUNIOR_ENCRYPTION_KEYS must not repeat a key id");
|
|
322
|
-
const activeId = env
|
|
350
|
+
const activeId = env["JUNIOR_ENCRYPTION_KEY_ID"]?.trim() || (keys.length === 1 ? keys[0]?.id : void 0);
|
|
323
351
|
if (!activeId) throw new Error("JUNIOR_ENCRYPTION_KEY_ID is required when JUNIOR_ENCRYPTION_KEYS has more than one key");
|
|
324
352
|
const active = keys.find((key) => key.id === activeId);
|
|
325
353
|
if (!active) throw new Error(`JUNIOR_ENCRYPTION_KEY_ID "${activeId}" is not in JUNIOR_ENCRYPTION_KEYS`);
|
|
@@ -340,16 +368,16 @@ function readWorkerConcurrency(value) {
|
|
|
340
368
|
}
|
|
341
369
|
/** Read queue settings from environment variables. */
|
|
342
370
|
function readQueueConfig(env) {
|
|
343
|
-
const provider = toOptionalTrimmed(env
|
|
371
|
+
const provider = toOptionalTrimmed(env["JUNIOR_QUEUE_PROVIDER"]) ?? "vercel";
|
|
344
372
|
switch (provider) {
|
|
345
373
|
case "vercel": return { provider };
|
|
346
374
|
case "bullmq": {
|
|
347
|
-
const redisUrl = toOptionalTrimmed(env
|
|
375
|
+
const redisUrl = toOptionalTrimmed(env["JUNIOR_QUEUE_REDIS_URL"]);
|
|
348
376
|
if (!redisUrl) throw new Error("JUNIOR_QUEUE_REDIS_URL is required when JUNIOR_QUEUE_PROVIDER is bullmq");
|
|
349
377
|
return {
|
|
350
378
|
provider,
|
|
351
379
|
redisUrl,
|
|
352
|
-
workerConcurrency: readWorkerConcurrency(env
|
|
380
|
+
workerConcurrency: readWorkerConcurrency(env["JUNIOR_QUEUE_WORKER_CONCURRENCY"])
|
|
353
381
|
};
|
|
354
382
|
}
|
|
355
383
|
default: throw new Error("JUNIOR_QUEUE_PROVIDER must be vercel or bullmq");
|
|
@@ -764,6 +792,7 @@ function tokensForChars(chars, profile) {
|
|
|
764
792
|
}
|
|
765
793
|
function messageChars(message) {
|
|
766
794
|
switch (message.role) {
|
|
795
|
+
case "system": return renderSystemMessageUpdate(message).length;
|
|
767
796
|
case "user":
|
|
768
797
|
case "toolResult": return contentChars(message.content);
|
|
769
798
|
case "assistant": {
|
|
@@ -1043,6 +1072,7 @@ const GATEWAY_MODEL_OVERRIDES = {
|
|
|
1043
1072
|
},
|
|
1044
1073
|
compat: {
|
|
1045
1074
|
forceAdaptiveThinking: true,
|
|
1075
|
+
supportsMidConvoSystemMessages: true,
|
|
1046
1076
|
supportsTemperature: false
|
|
1047
1077
|
}
|
|
1048
1078
|
},
|
|
@@ -1089,7 +1119,8 @@ const GATEWAY_MODEL_OVERRIDES = {
|
|
|
1089
1119
|
thinkingLevelMap: {
|
|
1090
1120
|
xhigh: "xhigh",
|
|
1091
1121
|
max: "max"
|
|
1092
|
-
}
|
|
1122
|
+
},
|
|
1123
|
+
compat: { supportsMidConvoSystemMessages: true }
|
|
1093
1124
|
},
|
|
1094
1125
|
"openai/gpt-6-astra": {
|
|
1095
1126
|
id: "openai/gpt-6-astra",
|
|
@@ -1261,10 +1292,10 @@ async function completeText(params) {
|
|
|
1261
1292
|
}, startAttributes);
|
|
1262
1293
|
}
|
|
1263
1294
|
function logContextFromMetadata(modelId, metadata) {
|
|
1264
|
-
const conversationId = typeof metadata?.conversationId === "string"
|
|
1265
|
-
const messageConversationId = typeof metadata?.threadId === "string" ? metadata
|
|
1266
|
-
const destinationName = typeof metadata?.channelId === "string" ? metadata
|
|
1267
|
-
const runId = typeof metadata?.runId === "string" ? metadata
|
|
1295
|
+
const conversationId = typeof metadata?.["conversationId"] === "string" && metadata["conversationId"] ? metadata["conversationId"] : void 0;
|
|
1296
|
+
const messageConversationId = typeof metadata?.["threadId"] === "string" ? metadata["threadId"] : void 0;
|
|
1297
|
+
const destinationName = typeof metadata?.["channelId"] === "string" ? metadata["channelId"] : void 0;
|
|
1298
|
+
const runId = typeof metadata?.["runId"] === "string" ? metadata["runId"] : void 0;
|
|
1268
1299
|
return {
|
|
1269
1300
|
modelId,
|
|
1270
1301
|
...conversationId ? { conversationId } : void 0,
|
|
@@ -1523,6 +1554,66 @@ async function rerankTexts(params) {
|
|
|
1523
1554
|
throw providerError;
|
|
1524
1555
|
}
|
|
1525
1556
|
}
|
|
1557
|
+
const WEB_SEARCH_TOOL_NAME = "parallelSearch";
|
|
1558
|
+
/** Run one AI Gateway parallel search inside a `gen_ai.chat` span. */
|
|
1559
|
+
async function searchWeb(params) {
|
|
1560
|
+
const credential = await resolveGatewayCredential();
|
|
1561
|
+
const provider = createGatewayProvider({ apiKey: credential.token });
|
|
1562
|
+
return await withSpan(`${GEN_AI_OPERATION_CHAT} ${params.modelId}`, "gen_ai.chat", {}, async (setSpanAttributes) => {
|
|
1563
|
+
const response = await generateText({
|
|
1564
|
+
model: provider.chat(params.modelId),
|
|
1565
|
+
prompt: params.query,
|
|
1566
|
+
tools: { [WEB_SEARCH_TOOL_NAME]: provider.tools.parallelSearch({
|
|
1567
|
+
mode: "agentic",
|
|
1568
|
+
maxResults: params.maxResults
|
|
1569
|
+
}) },
|
|
1570
|
+
toolChoice: {
|
|
1571
|
+
type: "tool",
|
|
1572
|
+
toolName: WEB_SEARCH_TOOL_NAME
|
|
1573
|
+
},
|
|
1574
|
+
abortSignal: params.signal
|
|
1575
|
+
});
|
|
1576
|
+
const costUsd = gatewayCostUsd(response.providerMetadata);
|
|
1577
|
+
setSpanAttributes({
|
|
1578
|
+
"gen_ai.response.finish_reasons": [response.finishReason],
|
|
1579
|
+
...extractGenAiUsageAttributes(response.usage, costUsd !== void 0 ? { cost: { total: costUsd } } : void 0)
|
|
1580
|
+
});
|
|
1581
|
+
return {
|
|
1582
|
+
...costUsd !== void 0 ? { costUsd } : void 0,
|
|
1583
|
+
outputs: response.toolResults.filter((result) => result.toolName === WEB_SEARCH_TOOL_NAME).map((result) => result.output)
|
|
1584
|
+
};
|
|
1585
|
+
}, {
|
|
1586
|
+
"gen_ai.provider.name": GEN_AI_PROVIDER_NAME,
|
|
1587
|
+
"gen_ai.operation.name": GEN_AI_OPERATION_CHAT,
|
|
1588
|
+
"gen_ai.request.model": params.modelId,
|
|
1589
|
+
...params.promptName ? { "gen_ai.prompt.name": params.promptName } : void 0,
|
|
1590
|
+
"server.address": GEN_AI_SERVER_ADDRESS,
|
|
1591
|
+
"server.port": 443,
|
|
1592
|
+
"gen_ai.provider.auth_mode": credential.mode
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1595
|
+
/** Generate or edit images with an AI Gateway image model. */
|
|
1596
|
+
async function generateImages(params) {
|
|
1597
|
+
const provider = createGatewayProvider({
|
|
1598
|
+
apiKey: await getGatewayApiKey(),
|
|
1599
|
+
...params.fetch ? { fetch: params.fetch } : void 0
|
|
1600
|
+
});
|
|
1601
|
+
try {
|
|
1602
|
+
const result = await generateImage({
|
|
1603
|
+
model: provider.imageModel(params.modelId),
|
|
1604
|
+
prompt: params.prompt,
|
|
1605
|
+
n: 1
|
|
1606
|
+
});
|
|
1607
|
+
const costUsd = gatewayCostUsd(result.providerMetadata);
|
|
1608
|
+
return {
|
|
1609
|
+
...costUsd !== void 0 ? { costUsd } : void 0,
|
|
1610
|
+
images: result.images
|
|
1611
|
+
};
|
|
1612
|
+
} catch (error) {
|
|
1613
|
+
if (NoImageGeneratedError.isInstance(error)) return { images: [] };
|
|
1614
|
+
throw error;
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1526
1617
|
// src/chat/slack/emoji.ts
|
|
1527
1618
|
const SLACK_EMOJI_NAME_RE = /^(?:[a-z0-9_+-]+)(?:::(?:skin-tone-[2-6]))?$/;
|
|
1528
1619
|
function normalizeSlackEmojiName(value) {
|
|
@@ -1548,26 +1639,7 @@ function toPiReasoningLevel(level) {
|
|
|
1548
1639
|
return level === "none" ? "off" : level;
|
|
1549
1640
|
}
|
|
1550
1641
|
// src/chat/config.ts
|
|
1551
|
-
var config_exports = /* @__PURE__ */ __exportAll({
|
|
1552
|
-
CONVERSATION_WORK_SOFT_YIELD_BUFFER_SECONDS: () => 40,
|
|
1553
|
-
DEFAULT_SQL_STATEMENT_TIMEOUT_MS: () => DEFAULT_SQL_STATEMENT_TIMEOUT_MS,
|
|
1554
|
-
FUNCTION_TIMEOUT_BUFFER_SECONDS: () => 20,
|
|
1555
|
-
botConfig: () => botConfig,
|
|
1556
|
-
getChatConfig: () => getChatConfig,
|
|
1557
|
-
getRuntimeMetadata: () => getRuntimeMetadata,
|
|
1558
|
-
getSlackBotToken: () => getSlackBotToken,
|
|
1559
|
-
getSlackClientId: () => getSlackClientId,
|
|
1560
|
-
getSlackClientSecret: () => getSlackClientSecret,
|
|
1561
|
-
getSlackSigningSecret: () => getSlackSigningSecret,
|
|
1562
|
-
readChatConfig: () => readChatConfig,
|
|
1563
|
-
resetRuntimeConfig: () => resetRuntimeConfig,
|
|
1564
|
-
restoreRuntimeConfig: () => restoreRuntimeConfig,
|
|
1565
|
-
setBotModelConfig: () => setBotModelConfig,
|
|
1566
|
-
setBotName: () => setBotName,
|
|
1567
|
-
setRuntimeLimits: () => setRuntimeLimits,
|
|
1568
|
-
setSlackReactionConfig: () => setSlackReactionConfig,
|
|
1569
|
-
snapshotRuntimeConfig: () => snapshotRuntimeConfig
|
|
1570
|
-
});
|
|
1642
|
+
var config_exports = /* @__PURE__ */ __exportAll({ botConfig: () => botConfig });
|
|
1571
1643
|
const MIN_AGENT_TURN_TIMEOUT_MS = 1e4;
|
|
1572
1644
|
const DEFAULT_AGENT_TURN_TIMEOUT_MS = 72e4;
|
|
1573
1645
|
const MAX_SLICES_PER_TURN = 100;
|
|
@@ -1674,6 +1746,7 @@ const DEFAULT_DECISION_MODEL_ID = "typesafe-ai/jev";
|
|
|
1674
1746
|
const DEFAULT_EMBEDDING_MODEL_ID = "openai/text-embedding-3-small";
|
|
1675
1747
|
const DEFAULT_RERANKING_MODEL_ID = "voyage/rerank-2.5-lite";
|
|
1676
1748
|
const DEFAULT_IMAGE_GENERATION_MODEL_ID = "openai/gpt-image-2";
|
|
1749
|
+
const DEFAULT_TRANSCRIPTION_MODEL_ID = "elevenlabs/scribe-v2";
|
|
1677
1750
|
const DEFAULT_VISION_MODEL_ID = resolveGatewayModel("openai/gpt-5.6-sol").id;
|
|
1678
1751
|
function validateGatewayModelId(raw) {
|
|
1679
1752
|
const trimmed = toOptionalTrimmed(raw);
|
|
@@ -1698,24 +1771,25 @@ function parseReactionEmoji(envName, rawValue, defaultEmoji) {
|
|
|
1698
1771
|
}
|
|
1699
1772
|
function readBotConfig(env, functionMaxDurationSeconds) {
|
|
1700
1773
|
const maxTurnTimeoutMs = resolveMaxTurnTimeoutMs(functionMaxDurationSeconds);
|
|
1701
|
-
const modelId = validateGatewayModelId(env
|
|
1702
|
-
const reasoningLevel = toOptionalTrimmed(env
|
|
1703
|
-
const fastModelId = validateGatewayModelId(env
|
|
1704
|
-
const guardianModelId = validateGatewayModelId(env
|
|
1774
|
+
const modelId = validateGatewayModelId(env["AI_MODEL"]) ?? DEFAULT_MODEL_ID;
|
|
1775
|
+
const reasoningLevel = toOptionalTrimmed(env["AI_REASONING_LEVEL"]);
|
|
1776
|
+
const fastModelId = validateGatewayModelId(env["AI_FAST_MODEL"] ?? env["AI_MODEL"]) ?? DEFAULT_FAST_MODEL_ID;
|
|
1777
|
+
const guardianModelId = validateGatewayModelId(env["AI_GUARDIAN_MODEL"]) ?? DEFAULT_GUARDIAN_MODEL_ID;
|
|
1705
1778
|
return {
|
|
1706
|
-
userName: toOptionalTrimmed(env
|
|
1779
|
+
userName: toOptionalTrimmed(env["JUNIOR_BOT_NAME"]) ?? "junior",
|
|
1707
1780
|
modelId,
|
|
1708
|
-
contextWindowTokens: parseOptionalPositiveInteger("AI_MODEL_CONTEXT_WINDOW_TOKENS", env
|
|
1781
|
+
contextWindowTokens: parseOptionalPositiveInteger("AI_MODEL_CONTEXT_WINDOW_TOKENS", env["AI_MODEL_CONTEXT_WINDOW_TOKENS"]) ?? DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS,
|
|
1709
1782
|
reasoningLevel: reasoningLevel === void 0 ? DEFAULT_REASONING_LEVEL : parseTurnReasoningLevel(reasoningLevel),
|
|
1710
|
-
decisionModelId: toOptionalTrimmed(env
|
|
1783
|
+
decisionModelId: toOptionalTrimmed(env["AI_DECISION_MODEL"]) ?? DEFAULT_DECISION_MODEL_ID,
|
|
1711
1784
|
fastModelId,
|
|
1712
1785
|
guardianModelId,
|
|
1713
|
-
imageGenerationModelId: toOptionalTrimmed(env
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1786
|
+
imageGenerationModelId: toOptionalTrimmed(env["AI_IMAGE_MODEL"]) ?? DEFAULT_IMAGE_GENERATION_MODEL_ID,
|
|
1787
|
+
transcriptionModelId: toOptionalTrimmed(env["AI_TRANSCRIPTION_MODEL"]) ?? DEFAULT_TRANSCRIPTION_MODEL_ID,
|
|
1788
|
+
embeddingModelId: validateEmbeddingModelId(env["AI_EMBEDDING_MODEL"]) ?? DEFAULT_EMBEDDING_MODEL_ID,
|
|
1789
|
+
rerankingModelId: toOptionalTrimmed(env["AI_RERANKING_MODEL"]) ?? DEFAULT_RERANKING_MODEL_ID,
|
|
1790
|
+
loadingMessages: parseLoadingMessages(env["JUNIOR_LOADING_MESSAGES"]),
|
|
1791
|
+
refusalFallbackModelId: validateGatewayModelId(env["AI_REFUSAL_FALLBACK_MODEL"]),
|
|
1792
|
+
visionModelId: env["AI_VISION_MODEL"] === void 0 ? DEFAULT_VISION_MODEL_ID : validateGatewayModelId(env["AI_VISION_MODEL"]),
|
|
1719
1793
|
maxAgentDepth: 0,
|
|
1720
1794
|
maxSlicesPerTurn: MAX_SLICES_PER_TURN,
|
|
1721
1795
|
maxToolCallsPerTurn: MAX_TOOL_CALLS_PER_TURN,
|
|
@@ -1723,12 +1797,12 @@ function readBotConfig(env, functionMaxDurationSeconds) {
|
|
|
1723
1797
|
maxConsecutiveAutomatedTurns: MAX_CONSECUTIVE_AUTOMATED_TURNS,
|
|
1724
1798
|
maxEventAutomationRuns: MAX_EVENT_AUTOMATION_RUNS,
|
|
1725
1799
|
eventAutomationRunWindowMs: EVENT_AUTOMATION_RUN_WINDOW_MS,
|
|
1726
|
-
turnTimeoutMs: parseAgentTurnTimeoutMs(env
|
|
1727
|
-
webSearchModelId: validateGatewayModelId(env
|
|
1800
|
+
turnTimeoutMs: parseAgentTurnTimeoutMs(env["AGENT_TURN_TIMEOUT_MS"], maxTurnTimeoutMs),
|
|
1801
|
+
webSearchModelId: validateGatewayModelId(env["AI_WEB_SEARCH_MODEL"]) ?? DEFAULT_WEB_SEARCH_MODEL_ID
|
|
1728
1802
|
};
|
|
1729
1803
|
}
|
|
1730
1804
|
function readDatabaseUrl(env) {
|
|
1731
|
-
const databaseUrl = toOptionalTrimmed(env
|
|
1805
|
+
const databaseUrl = toOptionalTrimmed(env["DATABASE_URL"]);
|
|
1732
1806
|
if (!databaseUrl) throw new Error("DATABASE_URL is required");
|
|
1733
1807
|
return databaseUrl;
|
|
1734
1808
|
}
|
|
@@ -1741,7 +1815,7 @@ function isLocalDatabaseUrl(databaseUrl) {
|
|
|
1741
1815
|
}
|
|
1742
1816
|
}
|
|
1743
1817
|
function readSqlDriver(env, databaseUrl) {
|
|
1744
|
-
const value = toOptionalTrimmed(env
|
|
1818
|
+
const value = toOptionalTrimmed(env["JUNIOR_DATABASE_DRIVER"]);
|
|
1745
1819
|
if (value === void 0) {
|
|
1746
1820
|
if (isLocalDatabaseUrl(databaseUrl)) return "postgres";
|
|
1747
1821
|
return "neon";
|
|
@@ -1750,7 +1824,7 @@ function readSqlDriver(env, databaseUrl) {
|
|
|
1750
1824
|
throw new Error("JUNIOR_DATABASE_DRIVER must be postgres or neon");
|
|
1751
1825
|
}
|
|
1752
1826
|
function readSqlStatementTimeoutMs(env) {
|
|
1753
|
-
const rawValue = toOptionalTrimmed(env
|
|
1827
|
+
const rawValue = toOptionalTrimmed(env["JUNIOR_SQL_STATEMENT_TIMEOUT_MS"]);
|
|
1754
1828
|
if (rawValue === void 0) return DEFAULT_SQL_STATEMENT_TIMEOUT_MS;
|
|
1755
1829
|
const value = Number.parseInt(rawValue, 10);
|
|
1756
1830
|
if (!Number.isSafeInteger(value) || value < 0 || String(value) !== rawValue) throw new Error("JUNIOR_SQL_STATEMENT_TIMEOUT_MS must be a non-negative integer");
|
|
@@ -1765,8 +1839,8 @@ function readChatConfig(env = process.env, functionMaxDurationSeconds = DEFAULT_
|
|
|
1765
1839
|
bot: readBotConfig(env, resolvedFunctionMaxDurationSeconds),
|
|
1766
1840
|
queue: readQueueConfig(env),
|
|
1767
1841
|
functionMaxDurationSeconds: resolvedFunctionMaxDurationSeconds,
|
|
1768
|
-
cacheWarmingEnabled: parseKillSwitch("JUNIOR_CACHE_WARMING_ENABLED", env
|
|
1769
|
-
conversationWorkEnabled: parseKillSwitch("JUNIOR_CONVERSATION_WORK_ENABLED", env
|
|
1842
|
+
cacheWarmingEnabled: parseKillSwitch("JUNIOR_CACHE_WARMING_ENABLED", env["JUNIOR_CACHE_WARMING_ENABLED"]),
|
|
1843
|
+
conversationWorkEnabled: parseKillSwitch("JUNIOR_CONVERSATION_WORK_ENABLED", env["JUNIOR_CONVERSATION_WORK_ENABLED"]),
|
|
1770
1844
|
conversationWorkSoftYieldAfterMs: resolveConversationWorkSoftYieldAfterMs(resolvedFunctionMaxDurationSeconds),
|
|
1771
1845
|
encryption: readEncryptionKeyring(env),
|
|
1772
1846
|
sql: {
|
|
@@ -1775,18 +1849,18 @@ function readChatConfig(env = process.env, functionMaxDurationSeconds = DEFAULT_
|
|
|
1775
1849
|
statementTimeoutMs: readSqlStatementTimeoutMs(env)
|
|
1776
1850
|
},
|
|
1777
1851
|
slack: {
|
|
1778
|
-
botToken: toOptionalTrimmed(env
|
|
1779
|
-
clientId: toOptionalTrimmed(env
|
|
1780
|
-
clientSecret: toOptionalTrimmed(env
|
|
1852
|
+
botToken: toOptionalTrimmed(env["SLACK_BOT_TOKEN"]) ?? toOptionalTrimmed(env["SLACK_BOT_USER_TOKEN"]),
|
|
1853
|
+
clientId: toOptionalTrimmed(env["SLACK_CLIENT_ID"]),
|
|
1854
|
+
clientSecret: toOptionalTrimmed(env["SLACK_CLIENT_SECRET"]),
|
|
1781
1855
|
completedReactionEmoji: DEFAULT_COMPLETED_REACTION_EMOJI,
|
|
1782
1856
|
processingReactionEmoji: DEFAULT_PROCESSING_REACTION_EMOJI,
|
|
1783
|
-
signingSecret: toOptionalTrimmed(env
|
|
1857
|
+
signingSecret: toOptionalTrimmed(env["SLACK_SIGNING_SECRET"])
|
|
1784
1858
|
},
|
|
1785
|
-
sandbox: { provider: env
|
|
1859
|
+
sandbox: { provider: env["JUNIOR_SANDBOX_PROVIDER"]?.trim().toLowerCase() === "docker" ? "docker" : "vercel" },
|
|
1786
1860
|
state: {
|
|
1787
|
-
adapter: env
|
|
1788
|
-
keyPrefix: toOptionalTrimmed(env
|
|
1789
|
-
redisUrl: toOptionalTrimmed(env
|
|
1861
|
+
adapter: env["JUNIOR_STATE_ADAPTER"]?.trim().toLowerCase() === "memory" ? "memory" : "redis",
|
|
1862
|
+
keyPrefix: toOptionalTrimmed(env["JUNIOR_STATE_KEY_PREFIX"]),
|
|
1863
|
+
redisUrl: toOptionalTrimmed(env["REDIS_URL"])
|
|
1790
1864
|
}
|
|
1791
1865
|
};
|
|
1792
1866
|
}
|
|
@@ -1867,7 +1941,7 @@ function getSlackClientSecret() {
|
|
|
1867
1941
|
}
|
|
1868
1942
|
/** Return runtime metadata (version from deploy environment). */
|
|
1869
1943
|
function getRuntimeMetadata() {
|
|
1870
|
-
return { version: toOptionalTrimmed(process.env
|
|
1944
|
+
return { version: toOptionalTrimmed(process.env["VERCEL_GIT_COMMIT_SHA"]) };
|
|
1871
1945
|
}
|
|
1872
1946
|
/** Apply model overrides from createApp(). */
|
|
1873
1947
|
function setBotModelConfig(config) {
|
|
@@ -1878,6 +1952,7 @@ function setBotModelConfig(config) {
|
|
|
1878
1952
|
if (config.guardianModelId !== void 0) botConfig.guardianModelId = requireModelId("guardianModelId", config.guardianModelId, validateGatewayModelId);
|
|
1879
1953
|
if (config.rerankingModelId !== void 0) botConfig.rerankingModelId = requireModelId("rerankingModelId", config.rerankingModelId, toOptionalTrimmed);
|
|
1880
1954
|
if (config.imageGenerationModelId !== void 0) botConfig.imageGenerationModelId = requireModelId("imageGenerationModelId", config.imageGenerationModelId, validateEmbeddingModelId);
|
|
1955
|
+
if (config.transcriptionModelId !== void 0) botConfig.transcriptionModelId = requireModelId("transcriptionModelId", config.transcriptionModelId, toOptionalTrimmed);
|
|
1881
1956
|
if (config.visionModelId !== void 0) botConfig.visionModelId = requireModelId("visionModelId", config.visionModelId, validateGatewayModelId);
|
|
1882
1957
|
if (config.refusalFallbackModelId !== void 0) botConfig.refusalFallbackModelId = requireModelId("refusalFallbackModelId", config.refusalFallbackModelId, validateGatewayModelId);
|
|
1883
1958
|
if (config.webSearchModelId !== void 0) botConfig.webSearchModelId = requireModelId("webSearchModelId", config.webSearchModelId, validateGatewayModelId);
|
|
@@ -1894,4 +1969,4 @@ function setSlackReactionConfig(overrides) {
|
|
|
1894
1969
|
if (overrides.processingReactionEmoji !== void 0) chatConfig.slack.processingReactionEmoji = parseReactionEmoji("processingReactionEmoji", overrides.processingReactionEmoji, chatConfig.slack.processingReactionEmoji);
|
|
1895
1970
|
if (overrides.completedReactionEmoji !== void 0) chatConfig.slack.completedReactionEmoji = parseReactionEmoji("completedReactionEmoji", overrides.completedReactionEmoji, chatConfig.slack.completedReactionEmoji);
|
|
1896
1971
|
}
|
|
1897
|
-
export {
|
|
1972
|
+
export { bufferBody as $, searchWeb as A, unwrapCurrentInstruction as B, completeObject as C, generateImages as D, gatewayCostUsd as E, textCharsForTokens as F, createProviderError as G, escapeXmlText as H, COMPACTION_SUMMARY_PREFIX as I, getProviderErrorUserMessage as J, findProviderError as K, hasCompactedConversationContext as L, estimateMessagesTokens as M, estimateRequestOverheadTokens as N, rerankTexts as O, estimateTextTokens as P, resolveGatewayCredential as Q, isCompactionSummaryText as R, completeDecision as S, embedTexts as T, ProviderError as U, escapeXml as V, createAssistantProviderError as W, isProviderRetryError as X, isProviderRefusal as Y, getGatewayApiKey as Z, TURN_REASONING_LEVELS as _, getRuntimeMetadata as a, GEN_AI_PROVIDER_NAME as b, getSlackClientSecret as c, restoreRuntimeConfig as d, getAttachmentStorage as et, setBotModelConfig as f, snapshotRuntimeConfig as g, setSlackReactionConfig as h, getChatConfig as i, requestPrefixAttributes as j, resolveGatewayModel as k, getSlackSigningSecret as l, setRuntimeLimits as m, botConfig as n, getSlackBotToken as o, setBotName as p, getProviderErrorAttributes as q, config_exports as r, getSlackClientId as s, DEFAULT_SQL_STATEMENT_TIMEOUT_MS as t, toOptionalTrimmed as tt, resetRuntimeConfig as u, toPiReasoningLevel as v, completeText as w, GEN_AI_SERVER_ADDRESS as x, normalizeSlackEmojiName as y, renderCurrentInstruction as z };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { da as startOAuthFlow } from "./projection-
|
|
2
|
-
import { n as botConfig } from "./config-
|
|
3
|
-
import {
|
|
4
|
-
import { u as hasRequiredOAuthScope } from "./registry-
|
|
5
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
6
|
-
import { h as deleteMcpStoredOAuthCredentials, m as deleteMcpServerSessionId, p as deleteMcpAuthSessionsForUserProvider } from "./service-account-
|
|
1
|
+
import { da as startOAuthFlow } from "./projection-CNKK7doO.js";
|
|
2
|
+
import { n as botConfig } from "./config-DdO1BNcw.js";
|
|
3
|
+
import { R as deleteProviderIdentityForSlackUser, s as getSqlExecutor, z as deleteProviderIdentityForUser } from "./db-EKJnkrIb.js";
|
|
4
|
+
import { u as hasRequiredOAuthScope } from "./registry-DBDNUUmz.js";
|
|
5
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-B8ZXvXWm.js";
|
|
6
|
+
import { h as deleteMcpStoredOAuthCredentials, m as deleteMcpServerSessionId, p as deleteMcpAuthSessionsForUserProvider } from "./service-account-2HmlNPvy.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. */
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Ao as readLatestConversationBrief, Ca as getSlackMessagePermalink, Da as postSlackMessage, Lt as moveIdleConversationDestination, Sa as deleteSlackMessage, ki as getDashboardConversationLink, ma as formatSlackLink, pa as escapeSlackMrkdwnText } from "./projection-
|
|
1
|
+
import { Ao as readLatestConversationBrief, Ca as getSlackMessagePermalink, Da as postSlackMessage, Lt as moveIdleConversationDestination, Sa as deleteSlackMessage, ki as getDashboardConversationLink, ma as formatSlackLink, pa as escapeSlackMrkdwnText } from "./projection-CNKK7doO.js";
|
|
2
|
+
import { C as withConversationMutationLock, M as setFirstConversationLocation, X as getStateAdapter, a as getConversationStore, it as getConversationIdByProviderConversation, o as getDb, rt as claimProviderConversation, s as getSqlExecutor } from "./db-EKJnkrIb.js";
|
|
2
3
|
import { u as parseSlackChannelId, v as parseSlackMessageTs } from "./actor-D2iXzvlN.js";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import "./store-C28I0CVW.js";
|
|
4
|
+
import { mr as joinPublicChannelForRead, pr as checkSlackChannelReadAccess } from "./warmup-TgY4S1vx.js";
|
|
5
|
+
import "./store-COeYnPL_.js";
|
|
6
|
+
import { I as juniorDestinations } from "./executor-CoIZmFK8.js";
|
|
7
7
|
import { and, eq } from "drizzle-orm";
|
|
8
8
|
// src/chat/slack/continue-in-slack.ts
|
|
9
9
|
/** Refusal for a move that cannot wait for the active Run. */
|
|
10
|
-
const BUSY = "Wait for
|
|
11
|
-
const THREAD_TAKEN = "This thread already has a
|
|
10
|
+
const BUSY = "Wait for the current reply to finish, then try again.";
|
|
11
|
+
const THREAD_TAKEN = "This Slack thread already has a conversation.";
|
|
12
12
|
const MOVED_ELSEWHERE = /* @__PURE__ */ new Error("Conversation already has a Location");
|
|
13
13
|
/**
|
|
14
14
|
* Return whether a Conversation can still move to a Slack thread.
|
|
@@ -25,7 +25,7 @@ function canContinueInSlack(conversation, access) {
|
|
|
25
25
|
}
|
|
26
26
|
/** Text for the first message of the Conversation in Slack. */
|
|
27
27
|
async function movedMessageText(conversation, actorName) {
|
|
28
|
-
const title = conversation.title ?? "
|
|
28
|
+
const title = conversation.title ?? "Untitled conversation";
|
|
29
29
|
const url = getDashboardConversationLink(conversation.conversationId);
|
|
30
30
|
const brief = await readLatestConversationBrief(getDb(), conversation.conversationId);
|
|
31
31
|
return [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as conversationTurnFailureReasonSchema, h as usageSchema, i as conversationTurnFailureCodeSchema } from "./history-
|
|
1
|
+
import { a as conversationTurnFailureReasonSchema, h as usageSchema, i as conversationTurnFailureCodeSchema } from "./history-m2-ceTTX.js";
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
import { codeChangeStateSchema, conversationAnnotationInputSchema, conversationEventPresentationSchema, conversationSidebarAnnotationSchema, objectFactFields, objectTypeSchema } from "@sentry/junior-plugin-api";
|
|
4
4
|
// src/chat/briefs/schema.ts
|
|
@@ -155,8 +155,8 @@ const messageAttachmentSchema = z.object({
|
|
|
155
155
|
contentType: z.string().min(1),
|
|
156
156
|
bytes: z.number().int().nonnegative(),
|
|
157
157
|
/**
|
|
158
|
-
* True for a large Slack file that Junior
|
|
159
|
-
* downloads it from Slack, so it has no preview.
|
|
158
|
+
* True for a large Slack file that Junior has not stored yet. A
|
|
159
|
+
* dashboard read downloads it from Slack, so it has no preview.
|
|
160
160
|
*/
|
|
161
161
|
pending: z.literal(true).optional()
|
|
162
162
|
}).strict();
|
|
@@ -424,14 +424,6 @@ const conversationEventsQuerySchema = z.union([
|
|
|
424
424
|
limit: conversationEventsLimitSchema
|
|
425
425
|
}).strict()
|
|
426
426
|
]);
|
|
427
|
-
const conversationFeedQuerySchema = z.object({
|
|
428
|
-
actorEmail: z.string().trim().email().transform((value) => value.toLowerCase()).optional(),
|
|
429
|
-
codeRepositoryId: z.string().uuid().optional(),
|
|
430
|
-
/** `nextCursor` from the previous page of the same feed. */
|
|
431
|
-
cursor: z.string().min(1).max(500).optional(),
|
|
432
|
-
q: z.string().trim().max(200).optional(),
|
|
433
|
-
status: z.enum(["active", "archived"]).default("active")
|
|
434
|
-
}).strict();
|
|
435
427
|
/** Client key that makes a retried send the same Message. */
|
|
436
428
|
const idempotencyKeySchema = z.string().trim().min(1).max(200);
|
|
437
429
|
const createConversationMessageBodySchema = z.object({
|
|
@@ -1024,4 +1016,4 @@ const conversationDetailReportSchema = conversationSummaryReportSchema.extend({
|
|
|
1024
1016
|
sentryConversationUrl: z.string().optional(),
|
|
1025
1017
|
sourceTask: conversationSourceTaskSchema.optional()
|
|
1026
1018
|
}).strict().superRefine(validateConversationEvents);
|
|
1027
|
-
export {
|
|
1019
|
+
export { conversationBriefSchema as $, agentTypeSchema as A, messageCardText as B, createConversationMessageBodySchema as C, conversationChildAgentTotalsSchema as D, idempotencyKeySchema as E, renameConversationResponseSchema as F, MAX_INPUT_ATTACHMENTS as G, removedCardSchema as H, conversationReadPositionSchema as I, readMessageAttachments as J, inputFileSchema as K, reviewItemChangeRecordSchema as L, CONVERSATION_TITLE_MAX_LENGTH as M, conversationTitleSchema as N, AGENT_TYPES as O, renameConversationBodySchema as P, briefResourceLabel as Q, annotationCard as R, createConversationBodySchema as S, forkConversationResponseSchema as T, resolveMessageCards as U, readMessageCardRefs as V, MAX_ATTACHMENT_BYTES as W, briefLinkSchema as X, briefCodeChangeSchema as Y, briefOutcomeStatusSchema as Z, conversationReportMessageEventSchema as _, conversationActivityPreviewSchema as a, conversationSurfaceSchema as b, conversationAuxiliaryCostsSchema as c, conversationEventHistorySchema as d, parseBriefInput as et, conversationEventPageSchema as f, conversationReportEventSchema as g, conversationReportEventDataSchema as h, actorIdentitySchema as i, formatAgentTypes as j, agentTypeInstructions as k, conversationDetailQuerySchema as l, conversationParamsSchema as m, CONVERSATION_VERSION_HEADER as n, conversationAttachmentParamsSchema as o, conversationEventsQuerySchema as p, messageAttachmentSchema as q, acceptedConversationMessageSchema as r, conversationAttachmentQuerySchema as s, CONVERSATION_DETAIL_VERSION_HEADER as t, parseStoredBrief as tt, conversationDetailReportSchema as u, conversationReportStatusSchema as v, forkConversationBodySchema as w, conversationUsageSchema as x, conversationSummaryReportSchema as y, messageCardRef as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { L as reviewItemChangeRecordSchema, Z as briefOutcomeStatusSchema, i as actorIdentitySchema, q as messageAttachmentSchema, u as conversationDetailReportSchema, y as conversationSummaryReportSchema } from "./conversation-BOqdRtUx.js";
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
// src/api/objects/cards.ts
|
|
4
4
|
const MAX_LABEL_CHARS = 256;
|
|
@@ -295,12 +295,45 @@ const conversationFeedBriefSchema = z.object({
|
|
|
295
295
|
status: briefOutcomeStatusSchema,
|
|
296
296
|
summary: z.string()
|
|
297
297
|
}).strict();
|
|
298
|
+
const conversationFeedIncludeSchema = z.enum(["links", "media"]);
|
|
299
|
+
/** Query of `GET /api/conversations`. */
|
|
300
|
+
const conversationFeedQuerySchema = z.object({
|
|
301
|
+
actorEmail: z.string().trim().email().transform((value) => value.toLowerCase()).optional(),
|
|
302
|
+
codeRepositoryId: z.string().uuid().optional(),
|
|
303
|
+
/** `nextCursor` from the previous page of the same feed. */
|
|
304
|
+
cursor: z.string().min(1).max(500).optional(),
|
|
305
|
+
/**
|
|
306
|
+
* Extra row content that costs a query, comma separated: `media` for
|
|
307
|
+
* each row's newest files, `links` for web links from its recent
|
|
308
|
+
* messages. Rows show them only where the viewer sees private content.
|
|
309
|
+
*/
|
|
310
|
+
include: z.string().default("").transform((value) => [...new Set(value.split(",").filter(Boolean))]).pipe(z.array(conversationFeedIncludeSchema)),
|
|
311
|
+
q: z.string().trim().max(200).optional(),
|
|
312
|
+
status: z.enum(["active", "archived"]).default("active")
|
|
313
|
+
}).strict();
|
|
314
|
+
/**
|
|
315
|
+
* One stored file of a Conversation that a feed row previews, newest first.
|
|
316
|
+
* Read it through the Conversation's attachment route.
|
|
317
|
+
*/
|
|
318
|
+
const conversationFeedMediaSchema = z.object({
|
|
319
|
+
contentType: z.string(),
|
|
320
|
+
filename: z.string(),
|
|
321
|
+
id: z.string().min(1)
|
|
322
|
+
}).strict();
|
|
298
323
|
/**
|
|
299
324
|
* A root in the feed, or one of its visible Threads. A Thread nests under
|
|
300
325
|
* its nearest visible Thread ancestor, or under the root. Tasks never show.
|
|
301
326
|
*/
|
|
302
327
|
const conversationFeedItemSchema = conversationSummaryReportSchema.extend({
|
|
303
328
|
brief: conversationFeedBriefSchema.optional(),
|
|
329
|
+
/**
|
|
330
|
+
* Web links from the Conversation's recent messages, newest first, for
|
|
331
|
+
* the row to resolve into cards. URLs only: never message text. Only
|
|
332
|
+
* with `include=links`.
|
|
333
|
+
*/
|
|
334
|
+
links: z.array(z.url()).max(3).optional(),
|
|
335
|
+
/** Only with `include=media`. */
|
|
336
|
+
media: z.array(conversationFeedMediaSchema).max(3).optional(),
|
|
304
337
|
threads: z.lazy(() => z.array(conversationFeedItemSchema)).optional()
|
|
305
338
|
});
|
|
306
339
|
const conversationFeedSchema = z.object({
|
|
@@ -310,4 +343,4 @@ const conversationFeedSchema = z.object({
|
|
|
310
343
|
/** Present when older conversations follow this page. */
|
|
311
344
|
nextCursor: z.string().optional()
|
|
312
345
|
}).strict();
|
|
313
|
-
export {
|
|
346
|
+
export { skillReportSchema as C, personObjectCard as D, messageObjectCard as E, webPageObjectCard as O, skillDetailReportSchema as S, conversationObjectCard as T, pluginPackageContentItemReportSchema as _, cancelConversationPendingMessagesResponseSchema as a, pluginsSchema as b, conversationPendingMessageDeliverySchema as c, conversationUnchangedDetailWithMailboxSchema as d, steerConversationPendingMessagesBodySchema as f, pluginOperationalReportSchema as g, pluginOperationalReportFeedSchema as h, cancelConversationPendingMessagesBodySchema as i, conversationPendingMessageSchema as l, healthReportSchema as m, conversationFeedQuerySchema as n, conversationDetailWithMailboxReportSchema as o, steerConversationPendingMessagesResponseSchema as p, conversationFeedSchema as r, conversationPendingAuthorizationSchema as s, conversationFeedBriefSchema as t, conversationPendingMessagesReportSchema as u, pluginPackageContentReportSchema as v, skillReportsSchema as w, runtimeInfoReportSchema as x, pluginSchema as y };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { h as logWarn } from "./logging-
|
|
1
|
+
import { h as logWarn } from "./logging-QSZuMcvo.js";
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
|
+
import { renderSystemMessageUpdate } from "@earendil-works/pi-ai";
|
|
3
4
|
// src/chat/conversation-privacy.ts
|
|
4
5
|
const SAFE_METADATA_KEY_LIMIT = 20;
|
|
5
6
|
const conversationPrivacyStorage = new AsyncLocalStorage();
|
|
@@ -79,11 +80,11 @@ function summarizeContent(content) {
|
|
|
79
80
|
continue;
|
|
80
81
|
}
|
|
81
82
|
const record = part;
|
|
82
|
-
const type = canonicalContentPartType(typeof record
|
|
83
|
+
const type = canonicalContentPartType(typeof record["type"] === "string" ? record["type"] : "unknown");
|
|
83
84
|
partTypes.add(type);
|
|
84
|
-
if (typeof record
|
|
85
|
-
else if (typeof record
|
|
86
|
-
else if (typeof record
|
|
85
|
+
if (typeof record["text"] === "string") chars += record["text"].length;
|
|
86
|
+
else if (typeof record["thinking"] === "string") chars += record["thinking"].length;
|
|
87
|
+
else if (typeof record["data"] === "string") chars += record["data"].length;
|
|
87
88
|
else chars += serializedLength(part);
|
|
88
89
|
}
|
|
89
90
|
return {
|
|
@@ -133,10 +134,17 @@ function toCanonicalOutputMessage(message) {
|
|
|
133
134
|
};
|
|
134
135
|
}
|
|
135
136
|
/**
|
|
136
|
-
* Map a pi-ai Message (user/assistant/toolResult) to the canonical
|
|
137
|
+
* Map a pi-ai Message (system/user/assistant/toolResult) to the canonical
|
|
137
138
|
* gen_ai.input.messages shape: `{ role, parts: [...] }`.
|
|
138
139
|
*/
|
|
139
140
|
function toCanonicalInputMessage(message) {
|
|
141
|
+
if (message.role === "system") return {
|
|
142
|
+
role: "system",
|
|
143
|
+
parts: [{
|
|
144
|
+
type: "text",
|
|
145
|
+
content: renderSystemMessageUpdate(message)
|
|
146
|
+
}]
|
|
147
|
+
};
|
|
140
148
|
if (message.role === "user") return {
|
|
141
149
|
role: "user",
|
|
142
150
|
parts: typeof message.content === "string" ? [{
|
|
@@ -165,8 +173,8 @@ function toGenAiMessagesTraceAttributes(prefix, messages) {
|
|
|
165
173
|
continue;
|
|
166
174
|
}
|
|
167
175
|
const record = message;
|
|
168
|
-
if (typeof record
|
|
169
|
-
const summary = summarizeContent(record
|
|
176
|
+
if (typeof record["role"] === "string") roles.add(record["role"]);
|
|
177
|
+
const summary = summarizeContent(record["content"]);
|
|
170
178
|
contentChars += summary.chars;
|
|
171
179
|
for (const partType of summary.partTypes) partTypes.add(partType);
|
|
172
180
|
}
|