@sentry/junior 0.309.0 → 0.311.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-B1wujchl.js +259 -0
- package/dist/{adapter-context-1YUbMpD3.js → adapter-context-G2M0y6rP.js} +2 -2
- package/dist/{admin-u30A8TcD.js → admin-DCiBhUT1.js} +1 -2
- package/dist/{agent-runner-sJLhgPQV.js → agent-runner-BVHPUIc8.js} +695 -1817
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +8 -7
- package/dist/api.d.ts +21 -3
- package/dist/api.js +1479 -372
- package/dist/{app-B_7Wn0en.d.ts → app-Cw5Vy6H6.d.ts} +14 -3
- package/dist/app.d.ts +2 -2
- package/dist/app.js +233 -506
- package/dist/{background-compaction-queue-CUJXVKG3.js → background-compaction-queue-CJDnWVOJ.js} +4 -4
- package/dist/{briefs-BHi70IR5.js → briefs-BDjnug6Y.js} +3 -3
- package/dist/{catalog-runtime-Chc_IP2o.js → catalog-runtime-DMY3VV-D.js} +1 -1
- package/dist/cli/chat.js +16 -16
- package/dist/cli/check.js +23 -29
- package/dist/cli/init.js +1 -6
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +8 -7
- package/dist/cli/snapshot-create.js +5 -5
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -3
- package/dist/{config-BIyIdTtA.js → config-BrXDQefC.js} +239 -5
- package/dist/{continue-in-slack-BQJBfiQh.js → continue-in-slack-DNXSC9So.js} +6 -5
- package/dist/{conversation-CzrLhdHG.js → conversation-ca__NDQW.js} +48 -9
- package/dist/{conversation-feed-B9e3_gxz.js → conversation-feed-DkinDu5o.js} +15 -6
- package/dist/{conversation-privacy-CkTW29hd.js → conversation-privacy-DxttrKb9.js} +1 -1
- package/dist/{conversation-turn-CZaYQUum.js → conversation-turn-DWw7Xhdr.js} +42 -39
- package/dist/{credential-sync-58m_CyIJ.js → credential-sync-Bk8wGb8Y.js} +15 -16
- package/dist/{db-B4Hjxr-u.d.ts → db-7ETESH44.d.ts} +3 -1
- package/dist/{db-CFUpEZi9.js → db-DTxzH7u5.js} +1618 -1041
- package/dist/{executor-DXL0O0MV.js → executor-DqTiYj9S.js} +454 -96
- package/dist/{history-N7IVbUom.js → history-CYstOMKX.js} +6 -0
- package/dist/{html-CaBu2VbT.js → html-B9Sl4Axb.js} +6 -6
- package/dist/{install-DhTBUUov.js → install-Sg4ePfLl.js} +2 -2
- package/dist/instrumentation.js +3 -3
- package/dist/{lineage-CxtOI2_p.js → lineage-BHAMpNKr.js} +2 -2
- package/dist/{logging-BNUovdcX.js → logging-FjclQsXu.js} +47 -9
- package/dist/{message-DcUsS2vg.js → message-CJ7_RL50.js} +5 -8
- package/dist/{model-input-o3rEqgwM.js → model-input-CMLh4Cwq.js} +3 -3
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-callback-server-1Fizd1EM.js → oauth-callback-server-RVcbiDjL.js} +2 -2
- package/dist/{oauth-relay-DOwngqdM.js → oauth-relay-Bu9kkaQu.js} +1 -1
- package/dist/{projection-Ce4pmhKP.js → projection-Cns7XwWa.js} +9206 -5318
- package/dist/{prompt-DEqjDVMs.js → prompt-CDqcsDYC.js} +4 -4
- package/dist/{registry-CNE4ZBnG.js → registry-BPwuOP2O.js} +5 -8
- package/dist/{resolve-qbPg-aC-.js → resolve-BK29bBry.js} +3 -3
- package/dist/rule-DAxQY-1h.js +20 -0
- package/dist/{runner-eGIxpAMf.js → runner-BcAE-cJm.js} +10 -10
- package/dist/{sandbox-egress-signals-DMFB1kCp.js → sandbox-egress-signals-C-q0go5b.js} +1 -1
- package/dist/{schedule-Cire6NU7.js → schedule-BLJ476XQ.js} +209 -43
- package/dist/{schema-CfIey9Ao.js → schema-BLgSZXcL.js} +255 -49
- package/dist/{schema-DriSvB40.d.ts → schema-DYcJeV7d.d.ts} +701 -62
- package/dist/{service-account-Cw_LWZ4-.js → service-account-gN0zqf0S.js} +68 -68
- package/dist/{service-account-B1VXCTqg.js → service-account-iJoCtkHR.js} +3 -3
- package/dist/{skills-Zg8-vrje.js → skills-BoZ80epJ.js} +77 -31
- package/dist/{slack-conversation-unfurl-DA51qH0c.js → slack-conversation-unfurl-CogYrITA.js} +8 -10
- package/dist/{spawn-DBi4-zD8.js → spawn-Dk92r7mX.js} +5 -6
- package/dist/{state-C-Ftk23K.js → state-DH3Cmgp3.js} +4 -4
- package/dist/{stop-D9xideLM.js → stop-CYsfc0Ed.js} +1064 -314
- package/dist/{store-BjIXA0Al.js → store-DmmMIrQi.js} +5 -5
- package/dist/{task-queue-D0_qbnpo.js → task-queue-C_zldF5J.js} +3 -3
- package/dist/{task-runner-DQMq4XY0.js → task-runner-C7oCJQIx.js} +21 -14
- package/dist/{thread-context-D0i1e-5O.js → thread-context-BW2BsQbH.js} +13 -11
- package/dist/{turn-session-routing-C0l68I_O.js → turn-session-routing-Xh_2nSQe.js} +52 -54
- package/dist/{validation-CRbvRPvu.js → validation-DrJd0nnq.js} +1 -1
- package/dist/{version-BYdVs12p.js → version-CNKZ8owc.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{warmup-DN9OHN1-.js → warmup-BWdHew2H.js} +14289 -7197
- package/dist/{web-message-id-BT8Mg8LL.js → web-message-id-Ch5dPq-a.js} +32 -144
- package/dist/{worker-C9ZfJXmV.js → worker-t9qpu_Zx.js} +7 -8
- package/migrations/0124_artifact_visibility.sql +9 -0
- package/migrations/0125_artifact_public_sha_index.sql +1 -0
- package/migrations/0126_artifact_drop_public.sql +8 -0
- package/migrations/0127_artifact_path.sql +4 -0
- package/migrations/0128_artifact_path_index.sql +1 -0
- package/migrations/0129_review_item_answered_index.sql +1 -0
- package/migrations/0130_review_item_status_index.sql +1 -0
- package/migrations/0131_brief_outcome_status.sql +1 -0
- package/migrations/0132_brief_outcome_status_backfill.sql +7 -0
- package/migrations/0133_brief_created_at_index.sql +1 -0
- package/migrations/0134_slack_person_search_index.sql +1 -0
- package/migrations/0135_code_change_size.sql +3 -0
- package/migrations/0136_merge_conflict_notice_dismiss.sql +16 -0
- package/migrations/0137_inbox_snoozes.sql +27 -0
- package/migrations/0138_code_change_search_index.sql +2 -0
- package/migrations/0139_review_item_owner.sql +22 -0
- package/migrations/0140_review_item_owner_index.sql +1 -0
- package/migrations/0141_memory_core_adoption.sql +89 -0
- package/migrations/0142_memory_core_indexes.sql +17 -0
- package/migrations/meta/0124_snapshot.json +5516 -0
- package/migrations/meta/0125_snapshot.json +5516 -0
- package/migrations/meta/0126_snapshot.json +5488 -0
- package/migrations/meta/0127_snapshot.json +5519 -0
- package/migrations/meta/0128_snapshot.json +5519 -0
- package/migrations/meta/0129_snapshot.json +5547 -0
- package/migrations/meta/0130_snapshot.json +5563 -0
- package/migrations/meta/0131_snapshot.json +5569 -0
- package/migrations/meta/0132_snapshot.json +5569 -0
- package/migrations/meta/0133_snapshot.json +5590 -0
- package/migrations/meta/0134_snapshot.json +5606 -0
- package/migrations/meta/0135_snapshot.json +5624 -0
- package/migrations/meta/0136_snapshot.json +5624 -0
- package/migrations/meta/0137_snapshot.json +5864 -0
- package/migrations/meta/0138_snapshot.json +5894 -0
- package/migrations/meta/0139_snapshot.json +5898 -0
- package/migrations/meta/0140_snapshot.json +5919 -0
- package/migrations/meta/0141_snapshot.json +6429 -0
- package/migrations/meta/0142_snapshot.json +6457 -0
- package/migrations/meta/_journal.json +134 -1
- package/package.json +6 -7
- package/dist/result-ZGnDzcsb.js +0 -548
- package/dist/session-stop-P2XdTiwr.js +0 -4252
- package/dist/turn-user-message-nBVvOXjs.js +0 -364
- package/dist/users-DdjMjbmM.js +0 -181
- package/dist/viewer-DudYrQGj.js +0 -212
package/dist/{background-compaction-queue-CUJXVKG3.js → background-compaction-queue-CJDnWVOJ.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as getChatConfig } from "./config-
|
|
2
|
-
import { E as withSpan, h as logWarn } from "./logging-
|
|
3
|
-
import { _ as getQueueProvider, c as QUEUE_SIGNATURE_MAX_AGE_MS, h as queueCallback, l as signQueueMessage, u as verifyQueueMessage } from "./task-queue-
|
|
1
|
+
import { i as getChatConfig } from "./config-BrXDQefC.js";
|
|
2
|
+
import { E as withSpan, h as logWarn } from "./logging-FjclQsXu.js";
|
|
3
|
+
import { _ as getQueueProvider, c as QUEUE_SIGNATURE_MAX_AGE_MS, h as queueCallback, l as signQueueMessage, u as verifyQueueMessage } from "./task-queue-C_zldF5J.js";
|
|
4
4
|
import * as z from "zod";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
6
|
/** Validate the v2 conversation work hint sent through Vercel Queue. */
|
|
@@ -169,7 +169,7 @@ function cacheWarmupCallback() {
|
|
|
169
169
|
maxDeliveries: 1,
|
|
170
170
|
onRejected: logCacheWarmupRejected,
|
|
171
171
|
run: async (message) => {
|
|
172
|
-
const { runCacheWarmup } = await import("./warmup-
|
|
172
|
+
const { runCacheWarmup } = await import("./warmup-BWdHew2H.js").then((n) => n.s);
|
|
173
173
|
await runCacheWarmup(message);
|
|
174
174
|
},
|
|
175
175
|
skip: () => !getChatConfig().cacheWarmingEnabled,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as generateBrief, n as briefEntriesFromReportEvents, t as BRIEF_PROMPT, u as completeObject } from "./prompt-
|
|
1
|
+
import { I as briefResourceLabel, N as briefCodeChangeSchema, R as parseBriefInput, f as conversationEventPageSchema, u as conversationDetailReportSchema } from "./conversation-ca__NDQW.js";
|
|
2
|
+
import { c as generateBrief, n as briefEntriesFromReportEvents, t as BRIEF_PROMPT, u as completeObject } from "./prompt-CDqcsDYC.js";
|
|
3
3
|
import { CLI_USAGE } from "./cli/run.js";
|
|
4
4
|
import * as z from "zod";
|
|
5
5
|
import path from "node:path";
|
|
@@ -264,7 +264,7 @@ async function parseRunOptions(argv) {
|
|
|
264
264
|
* token.
|
|
265
265
|
*/
|
|
266
266
|
async function configuredBot() {
|
|
267
|
-
const { botConfig } = await import("./config-
|
|
267
|
+
const { botConfig } = await import("./config-BrXDQefC.js").then((n) => n.r);
|
|
268
268
|
return botConfig;
|
|
269
269
|
}
|
|
270
270
|
function apiUrl(baseUrl, pathname) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
|
|
2
|
-
import { t as createPluginCatalogRuntime } from "./registry-
|
|
2
|
+
import { t as createPluginCatalogRuntime } from "./registry-BPwuOP2O.js";
|
|
3
3
|
// src/chat/plugins/catalog-runtime.ts
|
|
4
4
|
var catalog_runtime_exports = /* @__PURE__ */ __exportAll({ pluginCatalogRuntime: () => pluginCatalogRuntime });
|
|
5
5
|
const pluginCatalogRuntime = createPluginCatalogRuntime();
|
package/dist/cli/chat.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as loadAppPluginSet } from "../plugin-module-Cv2ETe8Y.js";
|
|
2
|
-
import { n as executeAgentRun, t as createAgentRunner } from "../agent-runner-
|
|
2
|
+
import { n as executeAgentRun, t as createAgentRunner } from "../agent-runner-BVHPUIc8.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
5
5
|
import { stderr, stdin, stdout } from "node:process";
|
|
@@ -99,10 +99,10 @@ async function loadLocalPluginSet() {
|
|
|
99
99
|
async function configureLocalChatPlugins(pluginSet) {
|
|
100
100
|
const [pluginsModule, agentHooksModule, catalogRuntimeModule, validationModule, databaseModule] = await Promise.all([
|
|
101
101
|
import("../plugins-Bkk0XRo2.js").then((n) => n.o),
|
|
102
|
-
import("../projection-
|
|
103
|
-
import("../catalog-runtime-
|
|
104
|
-
import("../validation-
|
|
105
|
-
import("../db-
|
|
102
|
+
import("../projection-Cns7XwWa.js").then((n) => n.En),
|
|
103
|
+
import("../catalog-runtime-DMY3VV-D.js").then((n) => n.t),
|
|
104
|
+
import("../validation-DrJd0nnq.js").then((n) => n.r),
|
|
105
|
+
import("../db-DTxzH7u5.js").then((n) => n.n)
|
|
106
106
|
]);
|
|
107
107
|
const resolvedPluginSet = pluginSet === void 0 ? await loadLocalPluginSet() : pluginSet ?? void 0;
|
|
108
108
|
const plugins = pluginsModule.pluginRuntimeRegistrationsFromPluginSet(resolvedPluginSet);
|
|
@@ -152,20 +152,20 @@ function localDevServerUrl() {
|
|
|
152
152
|
async function prepareLocalChatRun(io, pluginSet) {
|
|
153
153
|
defaultStateAdapterForLocalChat();
|
|
154
154
|
await configureLocalChatPlugins(pluginSet);
|
|
155
|
-
const { setBriefsConfig, setEventEmbeddingsConfig } = await import("../projection-
|
|
155
|
+
const { setBriefsConfig, setEventEmbeddingsConfig } = await import("../projection-Cns7XwWa.js").then((n) => n.Fr);
|
|
156
156
|
setBriefsConfig({ enabled: true });
|
|
157
157
|
setEventEmbeddingsConfig({ enabled: true });
|
|
158
|
-
const { runLocalAgentTurn } = await import("../runner-
|
|
159
|
-
const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-
|
|
160
|
-
const { createLocalOAuthState } = await import("../oauth-relay-
|
|
161
|
-
const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-
|
|
162
|
-
const { bindSpawnAgent } = await import("../spawn-
|
|
163
|
-
const { bindMessageAgent } = await import("../message-
|
|
164
|
-
const { createChildConversationWorker, createDeliverToParent } = await import("../
|
|
165
|
-
const { createConversationTurnWorker } = await import("../conversation-turn-
|
|
166
|
-
const { skipInputAfterConversationStop } = await import("../
|
|
158
|
+
const { runLocalAgentTurn } = await import("../runner-BcAE-cJm.js");
|
|
159
|
+
const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-RVcbiDjL.js");
|
|
160
|
+
const { createLocalOAuthState } = await import("../oauth-relay-Bu9kkaQu.js").then((n) => n.t);
|
|
161
|
+
const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-C-q0go5b.js");
|
|
162
|
+
const { bindSpawnAgent } = await import("../spawn-Dk92r7mX.js").then((n) => n.n);
|
|
163
|
+
const { bindMessageAgent } = await import("../message-CJ7_RL50.js").then((n) => n.n);
|
|
164
|
+
const { createChildConversationWorker, createDeliverToParent } = await import("../warmup-BWdHew2H.js").then((n) => n.kn);
|
|
165
|
+
const { createConversationTurnWorker } = await import("../conversation-turn-DWw7Xhdr.js").then((n) => n.t);
|
|
166
|
+
const { skipInputAfterConversationStop } = await import("../warmup-BWdHew2H.js").then((n) => n.Gr);
|
|
167
167
|
const { createLocalConversationWork } = await import("../conversation-work-BaT_T6EB.js");
|
|
168
|
-
const { processConversationWork } = await import("../worker-
|
|
168
|
+
const { processConversationWork } = await import("../worker-t9qpu_Zx.js").then((n) => n.n);
|
|
169
169
|
let agentRunner;
|
|
170
170
|
const localConversationWork = createLocalConversationWork(async (message) => {
|
|
171
171
|
if (!agentRunner) throw new Error("Local agent runner is not ready");
|
package/dist/cli/check.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { t as mapBounded } from "../fan-out-Cod-yEHG.js";
|
|
2
|
-
import {
|
|
3
|
-
import { N as JUNIOR_HEARTBEAT_ROUTE, R as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, j as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE } from "../logging-
|
|
4
|
-
import { b as parsePluginManifest, y as parseInlinePluginManifest } from "../registry-
|
|
2
|
+
import { a as parseSkillFile } from "../skills-BoZ80epJ.js";
|
|
3
|
+
import { N as JUNIOR_HEARTBEAT_ROUTE, R as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, j as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE } from "../logging-FjclQsXu.js";
|
|
4
|
+
import { b as parsePluginManifest, y as parseInlinePluginManifest } from "../registry-BPwuOP2O.js";
|
|
5
|
+
import * as z from "zod";
|
|
5
6
|
import pLimit from "p-limit";
|
|
6
7
|
import path from "node:path";
|
|
7
8
|
import { mentionsTag } from "@sentry/junior-plugin-api";
|
|
@@ -179,20 +180,18 @@ function validatePluginManifest(manifestPath, manifest, duplicatePluginNames, du
|
|
|
179
180
|
errors: []
|
|
180
181
|
};
|
|
181
182
|
}
|
|
183
|
+
const exportConditionTargetSchema = z.string().optional().catch(void 0);
|
|
184
|
+
const packageExportTargetSchema = z.union([z.string(), z.object({
|
|
185
|
+
default: exportConditionTargetSchema,
|
|
186
|
+
import: exportConditionTargetSchema,
|
|
187
|
+
node: exportConditionTargetSchema
|
|
188
|
+
}).transform((conditions) => conditions.default ?? conditions.import ?? conditions.node)]);
|
|
182
189
|
function packageExportsEntryPath(exportsValue) {
|
|
183
190
|
if (typeof exportsValue === "string") return exportsValue;
|
|
184
|
-
if (
|
|
185
|
-
const rootExport = exportsValue["."] ?? exportsValue;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
for (const condition of [
|
|
189
|
-
"default",
|
|
190
|
-
"import",
|
|
191
|
-
"node"
|
|
192
|
-
]) {
|
|
193
|
-
const target = rootExport[condition];
|
|
194
|
-
if (typeof target === "string") return target;
|
|
195
|
-
}
|
|
191
|
+
if (typeof exportsValue !== "object" || exportsValue === null || Array.isArray(exportsValue)) return;
|
|
192
|
+
const rootExport = ("." in exportsValue ? exportsValue["."] : void 0) ?? exportsValue;
|
|
193
|
+
const target = packageExportTargetSchema.safeParse(rootExport);
|
|
194
|
+
return target.success ? target.data : void 0;
|
|
196
195
|
}
|
|
197
196
|
async function resolvePackageEntryPath(packageDir) {
|
|
198
197
|
const packageJson = await readJsonFile(path.join(packageDir, "package.json"));
|
|
@@ -212,9 +211,7 @@ async function resolvePackageEntryPath(packageDir) {
|
|
|
212
211
|
function isPluginFactoryExport(name, value) {
|
|
213
212
|
return typeof value === "function" && (name === "default" || name.endsWith("Plugin"));
|
|
214
213
|
}
|
|
215
|
-
|
|
216
|
-
return isRecord(value) && isRecord(value["manifest"]);
|
|
217
|
-
}
|
|
214
|
+
const pluginRegistrationLikeSchema = z.object({ manifest: z.custom((value) => typeof value === "object" && value !== null && !Array.isArray(value)) });
|
|
218
215
|
async function collectPackageJsPluginSources(packageDir, packageName) {
|
|
219
216
|
if (packageName === "@sentry/junior") return [];
|
|
220
217
|
const entryPath = await resolvePackageEntryPath(packageDir);
|
|
@@ -242,13 +239,14 @@ async function collectPackageJsPluginSources(packageDir, packageName) {
|
|
|
242
239
|
pluginSources.push(errorSource(manifestPath, error));
|
|
243
240
|
continue;
|
|
244
241
|
}
|
|
245
|
-
|
|
242
|
+
const pluginRegistration = pluginRegistrationLikeSchema.safeParse(registration);
|
|
243
|
+
if (!pluginRegistration.success) continue;
|
|
246
244
|
try {
|
|
247
245
|
pluginSources.push({
|
|
248
246
|
pluginDir: packageDir,
|
|
249
247
|
packageName,
|
|
250
248
|
manifestPath,
|
|
251
|
-
manifest: parseInlinePluginManifest(
|
|
249
|
+
manifest: parseInlinePluginManifest(pluginRegistration.data.manifest, packageDir)
|
|
252
250
|
});
|
|
253
251
|
} catch (error) {
|
|
254
252
|
pluginSources.push(errorSource(manifestPath, error));
|
|
@@ -369,9 +367,6 @@ function reportSkillGroup(label, skillResults, io) {
|
|
|
369
367
|
function reportAppSkills(skillResults, io) {
|
|
370
368
|
reportSkillGroup("app skills", skillResults, io);
|
|
371
369
|
}
|
|
372
|
-
function isRecord(value) {
|
|
373
|
-
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
374
|
-
}
|
|
375
370
|
async function hasJuniorDeploymentMarkers(rootDir, packages, nitroConfig) {
|
|
376
371
|
if (packages.some((declaredPackage) => declaredPackage.name === "@sentry/junior")) return true;
|
|
377
372
|
for (const source of [
|
|
@@ -421,14 +416,13 @@ async function validateDeploymentConfig(rootDir, packages) {
|
|
|
421
416
|
checked = true;
|
|
422
417
|
errors.push(`${vercelConfigPath}: framework must be "nitro" for the Vercel deployment wiring.`);
|
|
423
418
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
}
|
|
419
|
+
const { functions } = vercelConfig;
|
|
420
|
+
if (typeof functions === "object" && functions !== null && "api/internal/agent/continue.ts" in functions) {
|
|
421
|
+
checked = true;
|
|
422
|
+
errors.push(`${vercelConfigPath}: functions.${LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION} targets a source file that Nitro does not deploy. Remove it; juniorNitro() emits the ${JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE} queue trigger through Nitro functionRules.`);
|
|
429
423
|
}
|
|
430
424
|
if (hasJuniorMarkers && Array.isArray(vercelConfig.crons)) {
|
|
431
|
-
if (vercelConfig.crons.some((cron) =>
|
|
425
|
+
if (vercelConfig.crons.some((cron) => typeof cron === "object" && cron !== null && "path" in cron && cron.path === "/api/internal/heartbeat")) {
|
|
432
426
|
checked = true;
|
|
433
427
|
warnings.push(`${vercelConfigPath}: ${JUNIOR_HEARTBEAT_ROUTE} cron is now emitted by juniorNitro() into Nitro's Vercel Build Output config. Remove the root cron entry to avoid deployment drift.`);
|
|
434
428
|
}
|
package/dist/cli/init.js
CHANGED
|
@@ -26,12 +26,8 @@ export default app;
|
|
|
26
26
|
}
|
|
27
27
|
function writePluginsFile(targetDir) {
|
|
28
28
|
fs.writeFileSync(path.join(targetDir, "plugins.ts"), `import { defineJuniorPlugins } from "@sentry/junior";
|
|
29
|
-
import { memoryPlugin } from "@sentry/junior-memory";
|
|
30
29
|
|
|
31
|
-
export const plugins = defineJuniorPlugins([
|
|
32
|
-
memoryPlugin(),
|
|
33
|
-
"@sentry/junior-maintenance",
|
|
34
|
-
]);
|
|
30
|
+
export const plugins = defineJuniorPlugins(["@sentry/junior-maintenance"]);
|
|
35
31
|
`);
|
|
36
32
|
}
|
|
37
33
|
function writeNitroConfig(targetDir) {
|
|
@@ -134,7 +130,6 @@ async function runInit(dir, log = console.log) {
|
|
|
134
130
|
},
|
|
135
131
|
dependencies: {
|
|
136
132
|
"@sentry/junior": "latest",
|
|
137
|
-
"@sentry/junior-memory": "latest",
|
|
138
133
|
"@sentry/junior-maintenance": "latest",
|
|
139
134
|
hono: "^4.13.11"
|
|
140
135
|
},
|
package/dist/cli/main.js
CHANGED
|
@@ -45,13 +45,13 @@ async function runChat(argv, pluginSet) {
|
|
|
45
45
|
return await (await import("./chat.js")).runChat(argv, void 0, { pluginSet });
|
|
46
46
|
}
|
|
47
47
|
async function runAdmin(argv) {
|
|
48
|
-
return await (await import("../admin-
|
|
48
|
+
return await (await import("../admin-DCiBhUT1.js")).runAdmin(argv);
|
|
49
49
|
}
|
|
50
50
|
async function runServiceAccount(argv) {
|
|
51
|
-
return await (await import("../service-account-
|
|
51
|
+
return await (await import("../service-account-iJoCtkHR.js")).runServiceAccount(argv);
|
|
52
52
|
}
|
|
53
53
|
async function runBriefs(argv) {
|
|
54
|
-
return await (await import("../briefs-
|
|
54
|
+
return await (await import("../briefs-BDjnug6Y.js")).runBriefs(argv);
|
|
55
55
|
}
|
|
56
56
|
function topLevelCommand(argv) {
|
|
57
57
|
return (argv[0] === "--" ? argv.slice(1) : argv)[0];
|
package/dist/cli/plugins.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { o as getDb } from "../db-
|
|
2
|
-
import {
|
|
3
|
-
import { n as pluginCatalogRuntime } from "../catalog-runtime-
|
|
4
|
-
import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-
|
|
1
|
+
import { o as getDb } from "../db-DTxzH7u5.js";
|
|
2
|
+
import { Bn as validatePlugins, Da as createPluginLogger, Hn as coreRegistrations, zn as setPlugins } from "../projection-Cns7XwWa.js";
|
|
3
|
+
import { n as pluginCatalogRuntime } from "../catalog-runtime-DMY3VV-D.js";
|
|
4
|
+
import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-DrJd0nnq.js";
|
|
5
5
|
import { t as loadAppPluginSet } from "../plugin-module-Cv2ETe8Y.js";
|
|
6
6
|
import { a as pluginRuntimeRegistrationsFromPluginSet, i as pluginCliRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "../plugins-Bkk0XRo2.js";
|
|
7
|
+
import { Command, CommanderError } from "commander";
|
|
7
8
|
import { stderr, stdout } from "node:process";
|
|
8
9
|
import { createJiti } from "jiti";
|
|
9
|
-
import { Command, CommanderError } from "commander";
|
|
10
10
|
// src/cli/plugins.ts
|
|
11
11
|
/**
|
|
12
12
|
* Plugin CLI bootstrap for the local/package command line.
|
|
@@ -115,11 +115,12 @@ function validateConfiguredPluginCommands(plugins) {
|
|
|
115
115
|
}
|
|
116
116
|
async function loadPluginRegistrations(args) {
|
|
117
117
|
const pluginSet = args.pluginSet;
|
|
118
|
+
const coreCliPlugins = coreRegistrations().filter((plugin) => plugin.cli);
|
|
118
119
|
if (!pluginSet) return {
|
|
119
|
-
cliPlugins:
|
|
120
|
+
cliPlugins: coreCliPlugins,
|
|
120
121
|
runtimePlugins: []
|
|
121
122
|
};
|
|
122
|
-
const cliPlugins = pluginCliRegistrationsFromPluginSet(pluginSet);
|
|
123
|
+
const cliPlugins = [...pluginCliRegistrationsFromPluginSet(pluginSet), ...coreCliPlugins];
|
|
123
124
|
const runtimePlugins = pluginRuntimeRegistrationsFromPluginSet(pluginSet);
|
|
124
125
|
const pluginConfig = pluginCatalogConfigFromPluginSet(pluginSet);
|
|
125
126
|
validatePlugins(runtimePlugins);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { i as getChatConfig } from "../config-
|
|
2
|
-
import { n as pluginCatalogRuntime } from "../catalog-runtime-
|
|
3
|
-
import { n as resolve } from "../resolve-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { i as getChatConfig } from "../config-BrXDQefC.js";
|
|
2
|
+
import { n as pluginCatalogRuntime } from "../catalog-runtime-DMY3VV-D.js";
|
|
3
|
+
import { n as resolve } from "../resolve-BK29bBry.js";
|
|
4
|
+
import { ki as create, sa as SANDBOX_RUNTIME } from "../projection-Cns7XwWa.js";
|
|
5
|
+
import { n as disconnectStateAdapter } from "../adapter-B1wujchl.js";
|
|
6
6
|
// src/cli/snapshot-create.ts
|
|
7
7
|
const DEFAULT_TIMEOUT_MS = 6e5;
|
|
8
8
|
function progressMessage(phase) {
|
package/dist/cli/upgrade.d.ts
CHANGED
package/dist/cli/upgrade.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as getChatConfig } from "../config-
|
|
2
|
-
import { n as isPostgresErrorCode, t as createJuniorSqlExecutor } from "../executor-
|
|
1
|
+
import { i as getChatConfig } from "../config-BrXDQefC.js";
|
|
2
|
+
import { n as isPostgresErrorCode, t as createJuniorSqlExecutor } from "../executor-DqTiYj9S.js";
|
|
3
3
|
import { t as loadAppPluginSet } from "../plugin-module-Cv2ETe8Y.js";
|
|
4
|
-
import { t as createPluginCatalogRuntime } from "../registry-
|
|
4
|
+
import { t as createPluginCatalogRuntime } from "../registry-BPwuOP2O.js";
|
|
5
5
|
import { n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "../plugins-Bkk0XRo2.js";
|
|
6
6
|
import { basename, dirname, join, resolve } from "node:path";
|
|
7
7
|
import { createHash } from "node:crypto";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
|
|
2
2
|
import { t as mapBounded } from "./fan-out-Cod-yEHG.js";
|
|
3
|
-
import { E as withSpan, g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, p as logException, v as serializeGenAiAttribute } from "./logging-
|
|
4
|
-
import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-
|
|
3
|
+
import { E as withSpan, g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, p as logException, v as serializeGenAiAttribute } from "./logging-FjclQsXu.js";
|
|
4
|
+
import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-DxttrKb9.js";
|
|
5
|
+
import { t as gatewayOnlyProviders } from "./rule-DAxQY-1h.js";
|
|
5
6
|
import { AwsClient } from "aws4fetch";
|
|
6
7
|
import { del, get, issueSignedToken, presignUrl, put } from "@vercel/blob";
|
|
7
8
|
import * as z from "zod";
|
|
@@ -13,6 +14,7 @@ import { Experimental_DecisionRefusalError, NoImageGeneratedError, NoObjectGener
|
|
|
13
14
|
import { createHash } from "node:crypto";
|
|
14
15
|
import { renderSystemMessageUpdate } from "@earendil-works/pi-ai";
|
|
15
16
|
import { escapeClosingTags, escapeTagText, escapeTagTextAndQuotes, findTag, readTag, renderTag, startsWithTag, unescapeClosingTags, unescapeTagText } from "@sentry/junior-plugin-api";
|
|
17
|
+
import { setTimeout } from "node:timers/promises";
|
|
16
18
|
// src/chat/optional-string.ts
|
|
17
19
|
/**
|
|
18
20
|
* Normalize optional env-style strings so blank values do not masquerade as
|
|
@@ -775,6 +777,50 @@ function hasCompactedConversationContext(messages) {
|
|
|
775
777
|
return content.some((part) => part && typeof part === "object" && part.type === "text" && typeof part.text === "string" && isCompactionSummaryText(part.text));
|
|
776
778
|
});
|
|
777
779
|
}
|
|
780
|
+
// src/chat/pi/gateway-routing-attributes.ts
|
|
781
|
+
const providerAttemptSchema = z.object({
|
|
782
|
+
success: z.boolean().optional(),
|
|
783
|
+
credentialType: z.string().optional(),
|
|
784
|
+
inferenceEndpoint: z.object({ geoRegion: z.string().optional() }).optional()
|
|
785
|
+
});
|
|
786
|
+
const routingSchema = z.object({
|
|
787
|
+
finalProvider: z.string().optional(),
|
|
788
|
+
totalProviderAttemptCount: z.number().optional(),
|
|
789
|
+
clientSessionIdSource: z.string().optional(),
|
|
790
|
+
affinity: z.object({
|
|
791
|
+
pinned: z.boolean().optional(),
|
|
792
|
+
pinnedProvider: z.string().optional(),
|
|
793
|
+
outcome: z.string().optional()
|
|
794
|
+
}).optional(),
|
|
795
|
+
modelAttempts: z.array(z.object({ providerAttempts: z.array(providerAttemptSchema).optional() })).optional()
|
|
796
|
+
});
|
|
797
|
+
const messageDeltaSchema = z.object({
|
|
798
|
+
type: z.literal("message_delta"),
|
|
799
|
+
provider_metadata: z.object({ gateway: z.object({ routing: routingSchema }) })
|
|
800
|
+
});
|
|
801
|
+
/**
|
|
802
|
+
* Read the AI Gateway routing of one Anthropic Messages stream event as
|
|
803
|
+
* `app.ai.gateway.*` span attributes. Returns undefined for any other event.
|
|
804
|
+
*/
|
|
805
|
+
function gatewayRoutingAttributes(event) {
|
|
806
|
+
const parsed = messageDeltaSchema.safeParse(event);
|
|
807
|
+
if (!parsed.success) return;
|
|
808
|
+
const routing = parsed.data.provider_metadata.gateway.routing;
|
|
809
|
+
const served = routing.modelAttempts?.flatMap((attempt) => attempt.providerAttempts ?? []).find((attempt) => attempt.success === true);
|
|
810
|
+
const attributes = {};
|
|
811
|
+
const set = (key, value) => {
|
|
812
|
+
if (value !== void 0) attributes[`app.ai.gateway.${key}`] = value;
|
|
813
|
+
};
|
|
814
|
+
set("provider", routing.finalProvider);
|
|
815
|
+
set("credential_type", served?.credentialType);
|
|
816
|
+
set("region", served?.inferenceEndpoint?.geoRegion);
|
|
817
|
+
set("provider_attempts", routing.totalProviderAttemptCount);
|
|
818
|
+
set("session_id_source", routing.clientSessionIdSource);
|
|
819
|
+
set("affinity.pinned", routing.affinity?.pinned);
|
|
820
|
+
set("affinity.pinned_provider", routing.affinity?.pinnedProvider);
|
|
821
|
+
set("affinity.outcome", routing.affinity?.outcome);
|
|
822
|
+
return attributes;
|
|
823
|
+
}
|
|
778
824
|
// src/chat/services/image-dimensions.ts
|
|
779
825
|
const HEADER_BASE64_CHARS = 65536;
|
|
780
826
|
const READERS = {
|
|
@@ -1140,11 +1186,194 @@ function requestPrefixAttributes(payload) {
|
|
|
1140
1186
|
return {};
|
|
1141
1187
|
}
|
|
1142
1188
|
}
|
|
1189
|
+
// src/chat/state/locks.ts
|
|
1190
|
+
const ACTIVE_LOCK_TTL_MS = 9e4;
|
|
1191
|
+
const MUTATION_LOCK_TTL_MS = 1e4;
|
|
1192
|
+
/**
|
|
1193
|
+
* Acquire a lock for long-running work that the queued state adapter should
|
|
1194
|
+
* keep alive while the owning invocation is still making progress.
|
|
1195
|
+
*/
|
|
1196
|
+
async function acquireActiveLock(state, threadId) {
|
|
1197
|
+
return await state.acquireLock(threadId, ACTIVE_LOCK_TTL_MS);
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* Run work under one lock, optionally waiting for the current owner.
|
|
1201
|
+
* `keepAlive` is for multi-store mutations that must retain ownership until all
|
|
1202
|
+
* side effects finish; callers should still fence each blind write.
|
|
1203
|
+
*/
|
|
1204
|
+
async function withLock(state, key, run, options = {}) {
|
|
1205
|
+
const ttlMs = options.ttlMs ?? 9e4;
|
|
1206
|
+
const startedAtMs = Date.now();
|
|
1207
|
+
let lock;
|
|
1208
|
+
while (true) {
|
|
1209
|
+
lock = await state.acquireLock(key, ttlMs);
|
|
1210
|
+
if (lock) break;
|
|
1211
|
+
if (Date.now() - startedAtMs >= (options.waitMs ?? 0)) return { acquired: false };
|
|
1212
|
+
await setTimeout(options.retryMs ?? 25, void 0, { ref: false });
|
|
1213
|
+
}
|
|
1214
|
+
const heartbeat = options.keepAlive ? setInterval(() => void state.extendLock(lock, ttlMs).catch(() => void 0), Math.max(1, Math.floor(ttlMs / 3))) : void 0;
|
|
1215
|
+
heartbeat?.unref();
|
|
1216
|
+
try {
|
|
1217
|
+
return {
|
|
1218
|
+
acquired: true,
|
|
1219
|
+
value: await run(lock)
|
|
1220
|
+
};
|
|
1221
|
+
} finally {
|
|
1222
|
+
if (heartbeat) clearInterval(heartbeat);
|
|
1223
|
+
await state.releaseLock(lock);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
/**
|
|
1227
|
+
* Prove lock ownership immediately before a blind write.
|
|
1228
|
+
*
|
|
1229
|
+
* Whole-record mutations must stop if their lock expired rather than overwrite
|
|
1230
|
+
* state committed by a newer owner.
|
|
1231
|
+
*/
|
|
1232
|
+
async function fenceLock(state, lock, ttlMs = MUTATION_LOCK_TTL_MS) {
|
|
1233
|
+
if (!await state.extendLock(lock, ttlMs)) throw new Error(`Lock ownership was lost before write for ${lock.threadId}`);
|
|
1234
|
+
}
|
|
1235
|
+
// src/chat/state/cache.ts
|
|
1236
|
+
const MAX_CACHE_KEY_LENGTH = 512;
|
|
1237
|
+
const LOAD_WAIT_MS = 1e4;
|
|
1238
|
+
/** The prefix of every state key of one cache namespace. */
|
|
1239
|
+
function cacheKeyPrefix(namespace) {
|
|
1240
|
+
return `junior:cache:${namespace}:`;
|
|
1241
|
+
}
|
|
1242
|
+
/**
|
|
1243
|
+
* Create a cache in the state adapter under `junior:cache:{namespace}:`.
|
|
1244
|
+
* Entries are wrapped, so `null` and `false` values are cache hits.
|
|
1245
|
+
*/
|
|
1246
|
+
function createCache(state, namespace) {
|
|
1247
|
+
return { async getOrLoad(key, load, options) {
|
|
1248
|
+
if (!key.trim()) throw new Error("Cache key is required");
|
|
1249
|
+
if (key.length > MAX_CACHE_KEY_LENGTH) throw new Error("Cache key exceeds the maximum length");
|
|
1250
|
+
const cacheKey = `${cacheKeyPrefix(namespace)}${key}`;
|
|
1251
|
+
const cached = async () => options?.refresh ? void 0 : await state.get(cacheKey) ?? void 0;
|
|
1252
|
+
await state.connect();
|
|
1253
|
+
const hit = await cached();
|
|
1254
|
+
if (hit) return hit.value;
|
|
1255
|
+
const attempt = await withLock(state, `${cacheKey}:load`, async () => {
|
|
1256
|
+
const loadedMeanwhile = await cached();
|
|
1257
|
+
if (loadedMeanwhile) return loadedMeanwhile.value;
|
|
1258
|
+
const entry = await load();
|
|
1259
|
+
if (entry.ttlMs !== void 0) {
|
|
1260
|
+
if (!(entry.ttlMs > 0)) throw new Error("Cache ttlMs must be positive");
|
|
1261
|
+
await state.set(cacheKey, { value: entry.value }, entry.ttlMs);
|
|
1262
|
+
}
|
|
1263
|
+
return entry.value;
|
|
1264
|
+
}, {
|
|
1265
|
+
keepAlive: true,
|
|
1266
|
+
waitMs: LOAD_WAIT_MS
|
|
1267
|
+
});
|
|
1268
|
+
if (attempt.acquired) return attempt.value;
|
|
1269
|
+
return (await load()).value;
|
|
1270
|
+
} };
|
|
1271
|
+
}
|
|
1272
|
+
// src/chat/gateway-providers/routing.ts
|
|
1273
|
+
const ENABLED_PROVIDERS_KEY = "junior:gateway:enabled_providers";
|
|
1274
|
+
const MODEL_ENDPOINTS_URL = "https://ai-gateway.vercel.sh/v1/models";
|
|
1275
|
+
const SERVED_PROVIDERS_CACHE_NAMESPACE = "gateway-served-providers";
|
|
1276
|
+
const SERVED_PROVIDERS_TTL_MS = 36e5;
|
|
1277
|
+
const ENDPOINTS_TIMEOUT_MS = 5e3;
|
|
1278
|
+
const PROVIDER_SLUGS = { vertexAnthropic: "vertex" };
|
|
1279
|
+
const LOCAL_TTL_MS = 6e4;
|
|
1280
|
+
const localEnabledProviders = /* @__PURE__ */ new Map();
|
|
1281
|
+
const localServedProviders = /* @__PURE__ */ new Map();
|
|
1282
|
+
function readLocal(entries, key, load) {
|
|
1283
|
+
const entry = entries.get(key);
|
|
1284
|
+
if (entry && entry.expiresAtMs > Date.now()) return entry.value;
|
|
1285
|
+
const value = load();
|
|
1286
|
+
entries.set(key, {
|
|
1287
|
+
value,
|
|
1288
|
+
expiresAtMs: Date.now() + LOCAL_TTL_MS
|
|
1289
|
+
});
|
|
1290
|
+
value.catch(() => {
|
|
1291
|
+
if (entries.get(key)?.value === value) entries.delete(key);
|
|
1292
|
+
});
|
|
1293
|
+
return value;
|
|
1294
|
+
}
|
|
1295
|
+
const enabledProvidersSchema = z.array(z.string());
|
|
1296
|
+
const messagesBodySchema = z.looseObject({ providerOptions: z.looseObject({ gateway: z.looseObject({}).optional() }).optional() });
|
|
1297
|
+
const modelEndpointsSchema = z.object({ data: z.object({ endpoints: z.array(z.object({ provider_name: z.string() })) }) });
|
|
1298
|
+
/** Read the enabled providers. Null means every provider is enabled. */
|
|
1299
|
+
async function readEnabledProviders(state) {
|
|
1300
|
+
const stored = await state.get(ENABLED_PROVIDERS_KEY);
|
|
1301
|
+
return stored === null ? null : enabledProvidersSchema.parse(stored);
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Save the enabled providers. Null enables every provider again.
|
|
1305
|
+
*
|
|
1306
|
+
* Model calls in this process see the change right away. Other processes see
|
|
1307
|
+
* it when their local copy expires.
|
|
1308
|
+
*/
|
|
1309
|
+
async function saveEnabledProviders(state, enabled) {
|
|
1310
|
+
if (enabled === null) await state.delete(ENABLED_PROVIDERS_KEY);
|
|
1311
|
+
else await state.set(ENABLED_PROVIDERS_KEY, [...new Set(enabled)].sort());
|
|
1312
|
+
localEnabledProviders.clear();
|
|
1313
|
+
}
|
|
1314
|
+
async function fetchServedProviders(modelId) {
|
|
1315
|
+
const path = modelId.split("/").map(encodeURIComponent).join("/");
|
|
1316
|
+
const response = await fetch(`${MODEL_ENDPOINTS_URL}/${path}/endpoints`, { signal: AbortSignal.timeout(ENDPOINTS_TIMEOUT_MS) });
|
|
1317
|
+
if (response.status === 404) return [];
|
|
1318
|
+
if (!response.ok) throw new Error(`AI Gateway endpoints returned ${response.status}`);
|
|
1319
|
+
const { data } = modelEndpointsSchema.parse(await response.json());
|
|
1320
|
+
const slugs = data.endpoints.map(({ provider_name }) => PROVIDER_SLUGS[provider_name] ?? provider_name);
|
|
1321
|
+
return [...new Set(slugs)];
|
|
1322
|
+
}
|
|
1323
|
+
/** List the providers that AI Gateway can route one model to. */
|
|
1324
|
+
async function readServedProviders(state, modelId) {
|
|
1325
|
+
return await createCache(state, SERVED_PROVIDERS_CACHE_NAMESPACE).getOrLoad(modelId, async () => ({
|
|
1326
|
+
value: await fetchServedProviders(modelId),
|
|
1327
|
+
ttlMs: SERVED_PROVIDERS_TTL_MS
|
|
1328
|
+
}));
|
|
1329
|
+
}
|
|
1330
|
+
async function gatewayOnlyForModel(modelId) {
|
|
1331
|
+
const { getStateAdapter } = await import("./adapter-B1wujchl.js").then((n) => n.t);
|
|
1332
|
+
const state = getStateAdapter();
|
|
1333
|
+
const enabled = await readLocal(localEnabledProviders, "enabled", () => readEnabledProviders(state));
|
|
1334
|
+
if (enabled === null) return void 0;
|
|
1335
|
+
let served;
|
|
1336
|
+
try {
|
|
1337
|
+
served = await readLocal(localServedProviders, modelId, () => readServedProviders(state, modelId));
|
|
1338
|
+
} catch (error) {
|
|
1339
|
+
logWarn("ai.gateway.served_providers.failed", {
|
|
1340
|
+
"gen_ai.request.model": modelId,
|
|
1341
|
+
"exception.message": error instanceof Error ? error.message : String(error)
|
|
1342
|
+
});
|
|
1343
|
+
return;
|
|
1344
|
+
}
|
|
1345
|
+
return gatewayOnlyProviders(enabled, served);
|
|
1346
|
+
}
|
|
1347
|
+
function withGatewayOnly(payload, only) {
|
|
1348
|
+
const body = messagesBodySchema.parse(payload);
|
|
1349
|
+
return {
|
|
1350
|
+
...body,
|
|
1351
|
+
providerOptions: {
|
|
1352
|
+
...body.providerOptions,
|
|
1353
|
+
gateway: {
|
|
1354
|
+
...body.providerOptions?.gateway,
|
|
1355
|
+
only
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* Wrap a Pi Messages stream so each request body carries the `only` list of
|
|
1362
|
+
* the enabled providers. AI Gateway reads it from
|
|
1363
|
+
* `providerOptions.gateway.only` in the Messages API body.
|
|
1364
|
+
*/
|
|
1365
|
+
function withEnabledGatewayProviders(stream) {
|
|
1366
|
+
return (model, context, options) => stream(model, context, Object.assign({}, options, { onPayload: async (payload, payloadModel) => {
|
|
1367
|
+
const replaced = await options?.onPayload?.(payload, payloadModel);
|
|
1368
|
+
const only = await gatewayOnlyForModel(model.id);
|
|
1369
|
+
return only ? withGatewayOnly(replaced ?? payload, only) : replaced;
|
|
1370
|
+
} }));
|
|
1371
|
+
}
|
|
1143
1372
|
// src/chat/pi/client.ts
|
|
1144
1373
|
registerApiProvider({
|
|
1145
1374
|
api: "anthropic-messages",
|
|
1146
|
-
stream: streamAnthropic,
|
|
1147
|
-
streamSimple: streamSimpleAnthropic
|
|
1375
|
+
stream: withEnabledGatewayProviders(streamAnthropic),
|
|
1376
|
+
streamSimple: withEnabledGatewayProviders(streamSimpleAnthropic)
|
|
1148
1377
|
});
|
|
1149
1378
|
const GATEWAY_PROVIDER = "vercel-ai-gateway";
|
|
1150
1379
|
const GATEWAY_BASE_URL = "https://ai-gateway.vercel.sh";
|
|
@@ -1356,6 +1585,10 @@ async function completeText(params) {
|
|
|
1356
1585
|
onResponse: (response) => {
|
|
1357
1586
|
const vercelId = response.headers["x-vercel-id"];
|
|
1358
1587
|
if (vercelId) setSpanAttributes({ "app.ai.gateway.vercel_id": vercelId });
|
|
1588
|
+
},
|
|
1589
|
+
onProviderStreamEvent: (event) => {
|
|
1590
|
+
const routing = gatewayRoutingAttributes(event);
|
|
1591
|
+
if (routing) setSpanAttributes(routing);
|
|
1359
1592
|
}
|
|
1360
1593
|
});
|
|
1361
1594
|
} catch (error) {
|
|
@@ -1933,6 +2166,7 @@ function readChatConfig(env = process.env, functionMaxDurationSeconds = DEFAULT_
|
|
|
1933
2166
|
queue: readQueueConfig(env),
|
|
1934
2167
|
functionMaxDurationSeconds: resolvedFunctionMaxDurationSeconds,
|
|
1935
2168
|
cacheWarmingEnabled: parseKillSwitch("JUNIOR_CACHE_WARMING_ENABLED", env["JUNIOR_CACHE_WARMING_ENABLED"]),
|
|
2169
|
+
idleCompactionEnabled: parseKillSwitch("JUNIOR_IDLE_COMPACTION_ENABLED", env["JUNIOR_IDLE_COMPACTION_ENABLED"]),
|
|
1936
2170
|
conversationWorkEnabled: parseKillSwitch("JUNIOR_CONVERSATION_WORK_ENABLED", env["JUNIOR_CONVERSATION_WORK_ENABLED"]),
|
|
1937
2171
|
conversationWorkSoftYieldAfterMs: resolveConversationWorkSoftYieldAfterMs(resolvedFunctionMaxDurationSeconds),
|
|
1938
2172
|
encryption: readEncryptionKeyring(env),
|
|
@@ -2062,4 +2296,4 @@ function setSlackReactionConfig(overrides) {
|
|
|
2062
2296
|
if (overrides.processingReactionEmoji !== void 0) chatConfig.slack.processingReactionEmoji = parseReactionEmoji("processingReactionEmoji", overrides.processingReactionEmoji, chatConfig.slack.processingReactionEmoji);
|
|
2063
2297
|
if (overrides.completedReactionEmoji !== void 0) chatConfig.slack.completedReactionEmoji = parseReactionEmoji("completedReactionEmoji", overrides.completedReactionEmoji, chatConfig.slack.completedReactionEmoji);
|
|
2064
2298
|
}
|
|
2065
|
-
export {
|
|
2299
|
+
export { THREAD_CONTEXT_TAGS as $, searchWeb as A, withLock as B, completeObject as C, generateImages as D, gatewayCostUsd as E, createCache as F, textCharsForTokens as G, estimateMessagesTokens as H, ACTIVE_LOCK_TTL_MS as I, hasCompactedConversationContext as J, gatewayRoutingAttributes as K, MUTATION_LOCK_TTL_MS as L, readServedProviders as M, saveEnabledProviders as N, rerankTexts as O, cacheKeyPrefix as P, unwrapCurrentInstruction as Q, acquireActiveLock as R, completeDecision as S, embedTexts as T, estimateRequestOverheadTokens as U, requestPrefixAttributes as V, estimateTextTokens as W, hasCurrentInstruction as X, isCompactionSummaryText as Y, renderCurrentInstruction as Z, TURN_REASONING_LEVELS as _, getAttachmentStorage as _t, getRuntimeMetadata as a, renderUntrustedTag as at, GEN_AI_PROVIDER_NAME as b, getSlackClientSecret as c, createProviderError as ct, restoreRuntimeConfig as d, getProviderErrorUserMessage as dt, authorAttrs as et, setBotModelConfig as f, isProviderRefusal as ft, snapshotRuntimeConfig as g, bufferBody as gt, setSlackReactionConfig as h, resolveGatewayCredential as ht, getChatConfig as i, renderThreadContext as it, readEnabledProviders as j, resolveGatewayModel as k, getSlackSigningSecret as l, findProviderError as lt, setRuntimeLimits as m, getGatewayApiKey as mt, botConfig as n, readParentAgentTask as nt, getSlackBotToken as o, ProviderError as ot, setBotName as p, isProviderRetryError as pt, COMPACTION_SUMMARY_PREFIX as q, config_exports as r, renderParentAgentTask as rt, getSlackClientId as s, createAssistantProviderError as st, DEFAULT_SQL_STATEMENT_TIMEOUT_MS as t, isRuntimeInputText as tt, resetRuntimeConfig as u, getProviderErrorAttributes as ut, toPiReasoningLevel as v, toOptionalTrimmed as vt, completeText as w, GEN_AI_SERVER_ADDRESS as x, normalizeSlackEmojiName as y, fenceLock as z };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Bo as postSlackMessage, Fo as deleteSlackMessage, Io as getSlackMessagePermalink, Lt as moveIdleConversationDestination, ds as formatSlackLink, ja as readLatestConversationBrief, ks as getDashboardConversationLink, us as escapeSlackMrkdwnText } from "./projection-Cns7XwWa.js";
|
|
2
|
+
import { I as setFirstConversationLocation, R as claimProviderConversation, a as getConversationStore, o as getDb, s as getSqlExecutor, w as withConversationMutationLock, z as getConversationIdByProviderConversation } from "./db-DTxzH7u5.js";
|
|
3
3
|
import { u as parseSlackChannelId, v as parseSlackMessageTs } from "./actor-BsBdxDXQ.js";
|
|
4
|
-
import {
|
|
5
|
-
import "./
|
|
6
|
-
import
|
|
4
|
+
import { Hi as checkSlackChannelReadAccess, Ui as joinPublicChannelForRead } from "./warmup-BWdHew2H.js";
|
|
5
|
+
import { i as getStateAdapter } from "./adapter-B1wujchl.js";
|
|
6
|
+
import "./store-DmmMIrQi.js";
|
|
7
|
+
import { q as juniorDestinations } from "./executor-DqTiYj9S.js";
|
|
7
8
|
import { and, eq } from "drizzle-orm";
|
|
8
9
|
// src/chat/slack/continue-in-slack.ts
|
|
9
10
|
/** Refusal for a move that cannot wait for the active Run. */
|