@sentry/junior 0.208.0 → 0.210.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.
Files changed (54) hide show
  1. package/dist/{agent-BfxfHsf1.js → agent-DKboUiLS.js} +34 -25
  2. package/dist/{agent-hooks-CuGjLjmR.js → agent-hooks-4I-C-LhZ.js} +8 -8
  3. package/dist/{agent-runner-Dz1PMKP0.js → agent-runner-DgqYKBZm.js} +5 -5
  4. package/dist/api.js +15 -15
  5. package/dist/{app-DfNrn_gS.d.ts → app-gyu3D9Gn.d.ts} +2 -0
  6. package/dist/app.d.ts +1 -1
  7. package/dist/app.js +64 -31
  8. package/dist/{auth-pause-state-Bjoh8wCy.js → auth-pause-state-3wQ2cGwW.js} +6 -6
  9. package/dist/{briefs-q_onrGmf.js → briefs-DsJVC55W.js} +3 -3
  10. package/dist/{catalog-runtime-D8YUMNhb.js → catalog-runtime-D11j6L4T.js} +1 -1
  11. package/dist/{checkpoint-FKMcINix.js → checkpoint-CHdApjyQ.js} +6 -6
  12. package/dist/cli/chat.js +13 -13
  13. package/dist/cli/check.js +3 -3
  14. package/dist/cli/main.js +2 -2
  15. package/dist/cli/plugins.js +3 -3
  16. package/dist/cli/snapshot-create.js +3 -3
  17. package/dist/cli/upgrade.js +3 -3
  18. package/dist/{client-bRyPqwAV.js → client-CuyBdpWp.js} +54 -6
  19. package/dist/{config-EtF2uEaW.js → config-DoMOvr4Z.js} +3 -3
  20. package/dist/{conversation-privacy-whGaV2TG.js → conversation-privacy-Dxiz_d9l.js} +1 -1
  21. package/dist/{credential-sync-DM-EE1ey.js → credential-sync-6WRLsSQy.js} +32 -23
  22. package/dist/{execution-stats-C-f8zwMU.js → execution-stats-D7Q3Mo8Y.js} +4 -4
  23. package/dist/{executor-BW5qp0jC.js → executor-BR-u7Eiz.js} +277 -21
  24. package/dist/instrumentation.js +3 -3
  25. package/dist/{job-queue-BIHNIEIX.js → job-queue-FcjDDzOt.js} +1 -1
  26. package/dist/{logging-sNS84Yuu.js → logging-GTB-Z6hs.js} +2 -2
  27. package/dist/nitro.d.ts +1 -1
  28. package/dist/nitro.js +3 -3
  29. package/dist/{oauth-callback-server-Co6D_yXP.js → oauth-callback-server-CuLHQpGM.js} +2 -2
  30. package/dist/{pending-auth-CRJCt9Ux.js → pending-auth-DZKNc2-v.js} +2 -2
  31. package/dist/{profile-BfLMVhWo.js → profile-DEoalaoa.js} +4 -4
  32. package/dist/{prompt-x-0ZtTyb.js → prompt-Calvr7V2.js} +3 -3
  33. package/dist/{registry-Cyww_jnC.js → registry-wMxSBovn.js} +1 -1
  34. package/dist/{resolve-BApIFQXX.js → resolve-C0ds-bvC.js} +2 -2
  35. package/dist/{runner-C9okx4GL.js → runner-BoK9ACgc.js} +9 -9
  36. package/dist/{sandbox-egress-signals-BHfx0esj.js → sandbox-egress-signals-CnzazNxY.js} +1 -1
  37. package/dist/{sentry-CD3SdJl-.js → sentry-CgWZM_kV.js} +3 -2
  38. package/dist/{skills-DhL_wXEp.js → skills-CbGNcUOh.js} +2 -2
  39. package/dist/{spawn-msnzfE8_.js → spawn-Dm3kRFmC.js} +2 -2
  40. package/dist/{stats-Cq5w_Awk.js → stats-DROv84Z6.js} +46 -34
  41. package/dist/{task-queue-JfmWmpjS.js → task-queue-BUAVtd2X.js} +3 -3
  42. package/dist/{task-runner-Cm0gXoLH.js → task-runner-ByBGnm9Q.js} +7 -7
  43. package/dist/{thread-state-lw2QwQ-y.js → thread-state-BTFCRXKk.js} +5 -5
  44. package/dist/{turn-execution-C7K6lQp1.js → turn-execution-BXKiBFtp.js} +3 -3
  45. package/dist/{turn-lifecycle-DVlJLwB0.js → turn-lifecycle-Bu7HgoE6.js} +1 -1
  46. package/dist/{usage-BMuAlKIW.js → usage-DJ2WBjfc.js} +2 -2
  47. package/dist/{validation-BI-r3iQA.js → validation-ZZEOV02h.js} +1 -1
  48. package/dist/{version-s6smK6lP.js → version-Cf7Fwr1w.js} +1 -1
  49. package/dist/version.js +1 -1
  50. package/dist/{web-authorization-C9MxPvXX.js → web-authorization-D74eDSAs.js} +1 -1
  51. package/dist/{web-input-CwVlaLd0.js → web-input-c6W_exA0.js} +4 -4
  52. package/dist/{work-BK0W1QAt.js → work-zBMuzR-T.js} +9 -9
  53. package/dist/{worker-D-WWKHQD.js → worker-C-9UqHKm.js} +19 -11
  54. package/package.json +6 -6
package/dist/cli/check.js CHANGED
@@ -1,6 +1,6 @@
1
- import { E as JUNIOR_HEARTBEAT_ROUTE, j as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, w as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE } from "../logging-sNS84Yuu.js";
2
- import { d as parseInlinePluginManifest, f as parsePluginManifest } from "../registry-Cyww_jnC.js";
3
- import { i as parseSkillFile } from "../skills-DhL_wXEp.js";
1
+ import { E as JUNIOR_HEARTBEAT_ROUTE, j as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, w as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE } from "../logging-GTB-Z6hs.js";
2
+ import { d as parseInlinePluginManifest, f as parsePluginManifest } from "../registry-wMxSBovn.js";
3
+ import { i as parseSkillFile } from "../skills-CbGNcUOh.js";
4
4
  import { pathToFileURL } from "node:url";
5
5
  import path from "node:path";
6
6
  import fs from "node:fs/promises";
package/dist/cli/main.js CHANGED
@@ -4,7 +4,7 @@ import { pathToFileURL } from "node:url";
4
4
  //#region src/cli/main.ts
5
5
  const SENTRY_FLUSH_TIMEOUT_MS = 2e3;
6
6
  async function flushSentry() {
7
- await (await import("../sentry-CD3SdJl-.js").then((n) => n.u)).flush(SENTRY_FLUSH_TIMEOUT_MS);
7
+ await (await import("../sentry-CgWZM_kV.js").then((n) => n.u)).flush(SENTRY_FLUSH_TIMEOUT_MS);
8
8
  }
9
9
  async function initSentry() {
10
10
  (await import("../instrumentation.js")).initSentry();
@@ -25,7 +25,7 @@ async function runChat(argv, pluginSet) {
25
25
  return await (await import("./chat.js")).runChat(argv, void 0, { pluginSet });
26
26
  }
27
27
  async function runBriefs(argv) {
28
- return await (await import("../briefs-q_onrGmf.js")).runBriefs(argv);
28
+ return await (await import("../briefs-DsJVC55W.js")).runBriefs(argv);
29
29
  }
30
30
  function topLevelCommand(argv) {
31
31
  return (argv[0] === "--" ? argv.slice(1) : argv)[0];
@@ -1,6 +1,6 @@
1
- import { Gt as getDb, bt as createPluginLogger, d as setPlugins, f as validatePlugins } from "../agent-hooks-CuGjLjmR.js";
2
- import { n as pluginCatalogRuntime } from "../catalog-runtime-D8YUMNhb.js";
3
- import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-BI-r3iQA.js";
1
+ import { Gt as getDb, bt as createPluginLogger, d as setPlugins, f as validatePlugins } from "../agent-hooks-4I-C-LhZ.js";
2
+ import { n as pluginCatalogRuntime } from "../catalog-runtime-D11j6L4T.js";
3
+ import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-ZZEOV02h.js";
4
4
  import { a as pluginRuntimeRegistrationsFromPluginSet, i as pluginCliRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "../plugins-egKWjgue.js";
5
5
  import { t as loadAppPluginSet } from "../plugin-module-BKGOXca2.js";
6
6
  import { stderr, stdout } from "node:process";
@@ -1,6 +1,6 @@
1
- import { n as pluginCatalogRuntime } from "../catalog-runtime-D8YUMNhb.js";
2
- import { S as disconnectStateAdapter, t as create } from "../profile-BfLMVhWo.js";
3
- import { r as resolve } from "../resolve-BApIFQXX.js";
1
+ import { n as pluginCatalogRuntime } from "../catalog-runtime-D11j6L4T.js";
2
+ import { S as disconnectStateAdapter, t as create } from "../profile-DEoalaoa.js";
3
+ import { r as resolve } from "../resolve-C0ds-bvC.js";
4
4
  //#region src/cli/snapshot-create.ts
5
5
  const DEFAULT_RUNTIME = "node22";
6
6
  const DEFAULT_TIMEOUT_MS = 6e5;
@@ -1,6 +1,6 @@
1
- import { a as getChatConfig } from "../config-EtF2uEaW.js";
2
- import { t as createJuniorSqlExecutor } from "../executor-BW5qp0jC.js";
3
- import { t as createPluginCatalogRuntime } from "../registry-Cyww_jnC.js";
1
+ import { a as getChatConfig } from "../config-DoMOvr4Z.js";
2
+ import { t as createJuniorSqlExecutor } from "../executor-BR-u7Eiz.js";
3
+ import { t as createPluginCatalogRuntime } from "../registry-wMxSBovn.js";
4
4
  import { n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "../plugins-egKWjgue.js";
5
5
  import { t as loadAppPluginSet } from "../plugin-module-BKGOXca2.js";
6
6
  import { fileURLToPath } from "node:url";
@@ -1,5 +1,5 @@
1
- import { C as withSpan, f as logWarn, h as serializeGenAiAttribute, i as extractGenAiUsageAttributes, p as normalizeGenAiFinishReason, u as logException } from "./logging-sNS84Yuu.js";
2
- import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-whGaV2TG.js";
1
+ import { C as withSpan, f as logWarn, h as serializeGenAiAttribute, i as extractGenAiUsageAttributes, p as normalizeGenAiFinishReason, u as logException } from "./logging-GTB-Z6hs.js";
2
+ import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-Dxiz_d9l.js";
3
3
  import { calculateCost, completeSimple, getEnvApiKey, getModels, registerApiProvider } from "@earendil-works/pi-ai/compat";
4
4
  import { stream as streamAnthropic, streamSimple as streamSimpleAnthropic } from "@earendil-works/pi-ai/api/anthropic-messages";
5
5
  import { createGatewayProvider } from "@ai-sdk/gateway";
@@ -302,6 +302,55 @@ registerApiProvider({
302
302
  streamSimple: streamSimpleAnthropic
303
303
  });
304
304
  const GATEWAY_PROVIDER = "vercel-ai-gateway";
305
+ const GATEWAY_BASE_URL = "https://ai-gateway.vercel.sh";
306
+ const GATEWAY_MODEL_OVERRIDES = {
307
+ "xai/grok-4.5": {
308
+ id: "xai/grok-4.5",
309
+ name: "Grok 4.5",
310
+ api: "anthropic-messages",
311
+ provider: GATEWAY_PROVIDER,
312
+ baseUrl: GATEWAY_BASE_URL,
313
+ reasoning: true,
314
+ input: ["text", "image"],
315
+ cost: {
316
+ input: 2,
317
+ output: 6,
318
+ cacheRead: .3,
319
+ cacheWrite: 0
320
+ },
321
+ contextWindow: 5e5,
322
+ maxTokens: 5e5
323
+ },
324
+ "openai/gpt-6-astra": {
325
+ id: "openai/gpt-6-astra",
326
+ name: "GPT-6 Astra",
327
+ api: "anthropic-messages",
328
+ provider: GATEWAY_PROVIDER,
329
+ baseUrl: GATEWAY_BASE_URL,
330
+ reasoning: true,
331
+ input: ["text", "image"],
332
+ cost: {
333
+ input: 10,
334
+ output: 50,
335
+ cacheRead: 1,
336
+ cacheWrite: 12.5,
337
+ tiers: [{
338
+ inputTokensAbove: 272e3,
339
+ input: 20,
340
+ output: 75,
341
+ cacheRead: 2,
342
+ cacheWrite: 25
343
+ }]
344
+ },
345
+ contextWindow: 105e4,
346
+ maxTokens: 128e3,
347
+ thinkingLevelMap: {
348
+ xhigh: "xhigh",
349
+ max: "max"
350
+ },
351
+ compat: { supportsTemperature: false }
352
+ }
353
+ };
305
354
  const GEN_AI_PROVIDER_NAME = GATEWAY_PROVIDER;
306
355
  const GEN_AI_SERVER_ADDRESS = "ai-gateway.vercel.sh";
307
356
  const GEN_AI_OPERATION_CHAT = "chat";
@@ -325,12 +374,11 @@ function extractText(message) {
325
374
  return (message.content ?? []).filter((part) => part.type === "text" && typeof part.text === "string").map((part) => part.text ?? "").join("").trim();
326
375
  }
327
376
  /**
328
- * Look up a gateway model by id. Throws `Unknown AI Gateway model id: …` if
329
- * the id is not in pi-ai's registry — callers at the config boundary can use
330
- * this to fail fast at startup instead of mid-turn.
377
+ * Look up a gateway model by id. Junior-owned overrides let new gateway
378
+ * models work before pi-ai publishes an updated bundled catalog.
331
379
  */
332
380
  function resolveGatewayModel(modelId) {
333
- const matched = getModels(GATEWAY_PROVIDER).find((model) => model.id === modelId);
381
+ const matched = GATEWAY_MODEL_OVERRIDES[modelId] ?? getModels(GATEWAY_PROVIDER).find((model) => model.id === modelId);
334
382
  if (!matched) throw new Error(`Unknown AI Gateway model id: ${modelId}`);
335
383
  return matched;
336
384
  }
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { o as resolveGatewayModel, w as toOptionalTrimmed } from "./client-bRyPqwAV.js";
3
- import { f as logWarn } from "./logging-sNS84Yuu.js";
2
+ import { o as resolveGatewayModel, w as toOptionalTrimmed } from "./client-CuyBdpWp.js";
3
+ import { f as logWarn } from "./logging-GTB-Z6hs.js";
4
4
  import { c as TURN_REASONING_LEVELS, l as parseTurnReasoningLevel, o as modelProfileSchema } from "./model-profile-CZmVoGdX.js";
5
5
  import { getModel } from "@earendil-works/pi-ai/compat";
6
6
  //#region src/chat/slack/emoji.ts
@@ -125,7 +125,7 @@ function parseCrossActorMidRunMode(rawValue) {
125
125
  if (value === "follow_up" || value === "steer") return value;
126
126
  throw new Error("JUNIOR_CROSS_ACTOR_MID_RUN_MODE must be follow_up or steer");
127
127
  }
128
- const DEFAULT_MODEL_ID = getModel("vercel-ai-gateway", "xai/grok-4.5").id;
128
+ const DEFAULT_MODEL_ID = "xai/grok-4.5";
129
129
  const DEFAULT_FAST_MODEL_ID = getModel("vercel-ai-gateway", "openai/gpt-5.6-luna").id;
130
130
  const DEFAULT_GUARDIAN_MODEL_ID = getModel("vercel-ai-gateway", "openai/gpt-5.6-luna").id;
131
131
  const DEFAULT_HANDOFF_MODEL_ID = getModel("vercel-ai-gateway", "openai/gpt-5.6-sol").id;
@@ -1,4 +1,4 @@
1
- import { f as logWarn } from "./logging-sNS84Yuu.js";
1
+ import { f as logWarn } from "./logging-GTB-Z6hs.js";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
3
  //#region src/chat/conversation-privacy.ts
4
4
  const SAFE_METADATA_KEY_LIMIT = 20;
@@ -1,28 +1,28 @@
1
- import { N as getMcpProviderErrorAttributes, Y as createUserTokenStore, a as deleteMcpAuthSession, d as putMcpStoredOAuthCredentials, h as resolvePluginOAuthAccount, i as finalizeMcpAuthorization, l as getMcpAuthSession, u as getMcpStoredOAuthCredentials, y as lookupSlackUserProfile } from "./agent-BfxfHsf1.js";
2
- import { m as escapeXml } from "./client-bRyPqwAV.js";
3
- import { L as toOptionalString, S as withLogContext, d as logInfo, f as logWarn, m as runBestEffort, u as logException, y as setTags } from "./logging-sNS84Yuu.js";
4
- import { a as getChatConfig, h as normalizeSlackEmojiName, n as botConfig, o as getRuntimeMetadata } from "./config-EtF2uEaW.js";
1
+ import { N as getMcpProviderErrorAttributes, X as createUserTokenStore, a as deleteMcpAuthSession, d as putMcpStoredOAuthCredentials, h as resolvePluginOAuthAccount, i as finalizeMcpAuthorization, l as getMcpAuthSession, u as getMcpStoredOAuthCredentials, y as lookupSlackUserProfile } from "./agent-DKboUiLS.js";
2
+ import { m as escapeXml } from "./client-CuyBdpWp.js";
3
+ import { L as toOptionalString, S as withLogContext, d as logInfo, f as logWarn, m as runBestEffort, u as logException, y as setTags } from "./logging-GTB-Z6hs.js";
4
+ import { a as getChatConfig, h as normalizeSlackEmojiName, n as botConfig, o as getRuntimeMetadata } from "./config-DoMOvr4Z.js";
5
5
  import { n as defaultModelId } from "./model-profile-CZmVoGdX.js";
6
6
  import { _ as parseSlackMessageTs, g as parseSlackUserId, l as isUserActor, s as createSlackResumeActor } from "./context-Bplcgypl.js";
7
- import { G as isDmChannel, H as getHeaderString, K as normalizeSlackConversationId, Kt as getSqlExecutor, Nt as buildSentryConversationUrl, U as getSlackClient, Wt as getConversationStore, mt as getDashboardConversationLink, nn as upsertIdentity, o as getPluginSlackConversationLink, on as requireSlackDestination, rn as upsertLinkedIdentity, z as SlackActionError } from "./agent-hooks-CuGjLjmR.js";
7
+ import { G as isDmChannel, H as getHeaderString, K as normalizeSlackConversationId, Kt as getSqlExecutor, Nt as buildSentryConversationUrl, U as getSlackClient, Wt as getConversationStore, mt as getDashboardConversationLink, nn as upsertIdentity, o as getPluginSlackConversationLink, on as requireSlackDestination, rn as upsertLinkedIdentity, z as SlackActionError } from "./agent-hooks-4I-C-LhZ.js";
8
8
  import { i as homeDir } from "./package-discovery-7a9YqLhE.js";
9
- import { l as hasRequiredOAuthScope, n as buildOAuthTokenRequest, r as parseOAuthTokenResponse } from "./registry-Cyww_jnC.js";
10
- import { n as pluginCatalogRuntime } from "./catalog-runtime-D8YUMNhb.js";
11
- import { t as discoverSkills } from "./skills-DhL_wXEp.js";
12
- import { P as commitAcceptedReply, Q as hydrateConversationMessages, R as loadProjection, U as recordAuthenticationLinked, W as recordAuthorizationCompleted, d as persistWithRetry, dt as recordDeliveredAssistantMessage, ft as turnHasReply, i as abandonTurnRecord, it as buildConversationContext, lt as markConversationMessage, m as buildTurnErrorResponse, n as loadTurnCheckpoint, o as failTurnRecord, r as saveTurnCheckpoint, s as getTurnRecord, u as recordTurnSummary } from "./checkpoint-FKMcINix.js";
13
- import { E as acquireActiveLock, w as getStateAdapter } from "./profile-BfLMVhWo.js";
14
- import { Pt as requestConversationWork, c as parseSlackThreadId, d as resolveSlackChannelIdFromThreadId, l as readSlackRawMessageContext, u as resolveSlackChannelIdFromMessage, wt as ensureConversationWake } from "./stats-Cq5w_Awk.js";
15
- import { a as isPendingAuthLatestRequest, f as CooperativeTurnYieldError, g as isCooperativeTurnYieldError, i as getConversationPendingAuth, r as clearPendingAuth, s as getAssistantReplyText, x as markTurnFailed } from "./pending-auth-CRJCt9Ux.js";
16
- import { a as parseOAuthStatePayload, c as escapeSlackMrkdwnText, d as normalizeSlackStatusText, f as truncateStatusText, g as removeReactionFromMessage, h as postSlackMessage, i as formatProviderLabel, l as formatSlackLink, o as resolveBaseUrl, p as addReactionToMessage, u as normalizeSlackReplyMarkdown, v as RetryableDeliveryError } from "./agent-runner-Dz1PMKP0.js";
9
+ import { l as hasRequiredOAuthScope, n as buildOAuthTokenRequest, r as parseOAuthTokenResponse } from "./registry-wMxSBovn.js";
10
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-D11j6L4T.js";
11
+ import { t as discoverSkills } from "./skills-CbGNcUOh.js";
12
+ import { P as commitAcceptedReply, Q as hydrateConversationMessages, R as loadProjection, U as recordAuthenticationLinked, W as recordAuthorizationCompleted, d as persistWithRetry, dt as recordDeliveredAssistantMessage, ft as turnHasReply, i as abandonTurnRecord, it as buildConversationContext, lt as markConversationMessage, m as buildTurnErrorResponse, n as loadTurnCheckpoint, o as failTurnRecord, r as saveTurnCheckpoint, s as getTurnRecord, u as recordTurnSummary } from "./checkpoint-CHdApjyQ.js";
13
+ import { E as acquireActiveLock, w as getStateAdapter } from "./profile-DEoalaoa.js";
14
+ import { Pt as requestConversationWork, c as parseSlackThreadId, d as resolveSlackChannelIdFromThreadId, l as readSlackRawMessageContext, u as resolveSlackChannelIdFromMessage, wt as ensureConversationWake } from "./stats-DROv84Z6.js";
15
+ import { a as isPendingAuthLatestRequest, f as CooperativeTurnYieldError, g as isCooperativeTurnYieldError, i as getConversationPendingAuth, r as clearPendingAuth, s as getAssistantReplyText, x as markTurnFailed } from "./pending-auth-DZKNc2-v.js";
16
+ import { a as parseOAuthStatePayload, c as escapeSlackMrkdwnText, d as normalizeSlackStatusText, f as truncateStatusText, g as removeReactionFromMessage, h as postSlackMessage, i as formatProviderLabel, l as formatSlackLink, o as resolveBaseUrl, p as addReactionToMessage, u as normalizeSlackReplyMarkdown, v as RetryableDeliveryError } from "./agent-runner-DgqYKBZm.js";
17
17
  import { t as getVercelConversationWorkQueue } from "./vercel-queue-DIkVcfK4.js";
18
- import { a as getTurnRequestDeadline } from "./job-queue-BIHNIEIX.js";
19
- import { i as resolveTurnSessionRouting, n as scheduleSessionCompletedPluginTasks } from "./task-runner-Cm0gXoLH.js";
20
- import { n as getTurnLifecycle } from "./turn-lifecycle-DVlJLwB0.js";
21
- import { n as executeTurn, t as AgentRunError } from "./turn-execution-C7K6lQp1.js";
22
- import { c as configValueSchema, n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState, t as getLocationConfigurationService } from "./thread-state-lw2QwQ-y.js";
23
- import { a as requireTurnFailureEventId, c as getTurnUserMessageId, d as buildDeliveredTurnStatePatch, l as getTurnUserReplyAttachmentContext, n as persistAuthPauseTurnState, o as getInterruptionMarker, r as finalizeFailedTurnReplyWithEvent, s as getTurnUserMessage, u as getTurnUserSlackMessageTs } from "./auth-pause-state-Bjoh8wCy.js";
18
+ import { a as getTurnRequestDeadline } from "./job-queue-FcjDDzOt.js";
19
+ import { i as resolveTurnSessionRouting, n as scheduleSessionCompletedPluginTasks } from "./task-runner-ByBGnm9Q.js";
20
+ import { n as getTurnLifecycle } from "./turn-lifecycle-Bu7HgoE6.js";
21
+ import { n as executeTurn, t as AgentRunError } from "./turn-execution-BXKiBFtp.js";
22
+ import { c as configValueSchema, n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState, t as getLocationConfigurationService } from "./thread-state-BTFCRXKk.js";
23
+ import { a as requireTurnFailureEventId, c as getTurnUserMessageId, d as buildDeliveredTurnStatePatch, l as getTurnUserReplyAttachmentContext, n as persistAuthPauseTurnState, o as getInterruptionMarker, r as finalizeFailedTurnReplyWithEvent, s as getTurnUserMessage, u as getTurnUserSlackMessageTs } from "./auth-pause-state-3wQ2cGwW.js";
24
24
  import { n as relayLocalOAuthCallback } from "./oauth-relay-CdCnu80W.js";
25
- import { n as deleteWebAuthorization } from "./web-authorization-C9MxPvXX.js";
25
+ import { n as deleteWebAuthorization } from "./web-authorization-D74eDSAs.js";
26
26
  import path from "node:path";
27
27
  import { z } from "zod";
28
28
  import { createHmac, createSecretKey, timingSafeEqual } from "node:crypto";
@@ -963,7 +963,7 @@ async function handleResumeFailure(args) {
963
963
  eventId
964
964
  });
965
965
  }
966
- function buildResumedRun(args, statusSession, delivery) {
966
+ function buildResumedRun(args, statusSession, delivery, postIntentAcknowledgment) {
967
967
  const savedRun = args.run;
968
968
  if (!savedRun) throw new TypeError("Slack resume requires a saved Run");
969
969
  if (!savedRun.source) throw new TypeError("Slack resume requires a Run Source");
@@ -992,7 +992,10 @@ function buildResumedRun(args, statusSession, delivery) {
992
992
  locationConfiguration: persistedLocationConfiguration
993
993
  },
994
994
  onEvent: async (event) => {
995
- if (event.type === "status") statusSession.update({ text: event.text });
995
+ if (event.type === "status") {
996
+ statusSession.update({ text: event.text });
997
+ if (event.intentAcknowledgment) await postIntentAcknowledgment(event.text);
998
+ }
996
999
  await priorOnEvent?.(event);
997
1000
  },
998
1001
  ...savedRun.dispatch?.outcomes?.length === 0 ? void 0 : { delivery },
@@ -1175,7 +1178,13 @@ async function resumeSlackTurnInContext(args) {
1175
1178
  };
1176
1179
  const deliveryState = await getDeliveryConversation();
1177
1180
  assistantMessageDelivered = turnHasReply(deliveryState.conversation, sessionId);
1178
- const run = buildResumedRun(runArgs, status, deliverAssistantMessage);
1181
+ let intentAcknowledgmentPosted = false;
1182
+ const postIntentAcknowledgment = async (text) => {
1183
+ if (intentAcknowledgmentPosted || runArgs.run?.dispatch?.outcomes?.length === 0) return;
1184
+ intentAcknowledgmentPosted = true;
1185
+ await postSlackMessageBestEffort(runArgs.channelId, runArgs.threadTs, text, runArgs.conversationId, runArgs.run?.dispatch?.replyAttribution);
1186
+ };
1187
+ const run = buildResumedRun(runArgs, status, deliverAssistantMessage, postIntentAcknowledgment);
1179
1188
  if (runArgs.inputMessageIds?.length) await turnLifecycle.start({
1180
1189
  conversationId: runArgs.conversationId,
1181
1190
  turnId: runArgs.turnId,
@@ -1,7 +1,7 @@
1
- import { f as logWarn } from "./logging-sNS84Yuu.js";
2
- import { Gt as getDb } from "./agent-hooks-CuGjLjmR.js";
3
- import { s as juniorAutomationExecutions, w as juniorConversations } from "./executor-BW5qp0jC.js";
4
- import { n as agentTurnCostUsd, r as agentTurnTotalTokens } from "./usage-BMuAlKIW.js";
1
+ import { f as logWarn } from "./logging-GTB-Z6hs.js";
2
+ import { Gt as getDb } from "./agent-hooks-4I-C-LhZ.js";
3
+ import { s as juniorAutomationExecutions, w as juniorConversations } from "./executor-BR-u7Eiz.js";
4
+ import { n as agentTurnCostUsd, r as agentTurnTotalTokens } from "./usage-DJ2WBjfc.js";
5
5
  import { and, asc, count, desc, eq, gte, inArray, lte, max, or, sql } from "drizzle-orm";
6
6
  //#region src/api/conversations/aggregate.ts
7
7
  function usageTokenValue(source, field) {
@@ -1,5 +1,5 @@
1
- import { h as startSpan } from "./sentry-CD3SdJl-.js";
2
- import "./config-EtF2uEaW.js";
1
+ import { g as startSpanManual } from "./sentry-CgWZM_kV.js";
2
+ import "./config-DoMOvr4Z.js";
3
3
  import { n as juniorDestinations, r as timestamptz } from "./destinations-BeBiJeEM.js";
4
4
  import { AsyncLocalStorage } from "node:async_hooks";
5
5
  import { getTableColumns, sql } from "drizzle-orm";
@@ -7,6 +7,7 @@ import { bigint, boolean, check, date, doublePrecision, foreignKey, index, integ
7
7
  import { Pool } from "@neondatabase/serverless";
8
8
  import { drizzle } from "drizzle-orm/neon-serverless";
9
9
  import { migrate } from "drizzle-orm/neon-serverless/migrator";
10
+ import { SpanKind } from "@opentelemetry/api";
10
11
  import pg from "pg";
11
12
  import { drizzle as drizzle$1 } from "drizzle-orm/node-postgres";
12
13
  import { migrate as migrate$1 } from "drizzle-orm/node-postgres/migrator";
@@ -535,28 +536,273 @@ const juniorSqlSchema = {
535
536
  //#endregion
536
537
  //#region src/db/tracing.ts
537
538
  const traced = Symbol("junior.db.traced");
538
- const SQL_OPERATION = /^[\s;]*(ALTER|CALL|CREATE|DELETE|DROP|INSERT|MERGE|SELECT|TRUNCATE|UPDATE)\b/i;
539
- function operationFromQuery(query) {
540
- const text = typeof query === "string" ? query : query && typeof query === "object" && "text" in query ? query.text : void 0;
541
- return typeof text === "string" ? SQL_OPERATION.exec(text)?.[1]?.toUpperCase() : void 0;
539
+ const MAX_QUERY_TEXT_LENGTH = 1e4;
540
+ const MAX_QUERY_SUMMARY_LENGTH = 255;
541
+ const SQL_OPERATIONS = /* @__PURE__ */ new Set([
542
+ "ALTER",
543
+ "ANALYZE",
544
+ "BEGIN",
545
+ "CALL",
546
+ "COMMIT",
547
+ "COPY",
548
+ "CREATE",
549
+ "DELETE",
550
+ "DROP",
551
+ "EXPLAIN",
552
+ "GRANT",
553
+ "INSERT",
554
+ "MERGE",
555
+ "RELEASE",
556
+ "REVOKE",
557
+ "ROLLBACK",
558
+ "SAVEPOINT",
559
+ "SELECT",
560
+ "SET",
561
+ "SHOW",
562
+ "TRUNCATE",
563
+ "UPDATE",
564
+ "VACUUM"
565
+ ]);
566
+ const SQL_IDENTIFIER = String.raw`(?:(?:U&)?"(?:""|[^"])*"|[A-Za-z_][A-Za-z0-9_$]*)(?:\.(?:(?:U&)?"(?:""|[^"])*"|[A-Za-z_][A-Za-z0-9_$]*))*`;
567
+ function targetPattern(prefix) {
568
+ return new RegExp(`${prefix}(${SQL_IDENTIFIER})`, "i");
569
+ }
570
+ const SQL_TARGET = {
571
+ ALTER: targetPattern(String.raw`\bALTER\s+TABLE\s+`),
572
+ CALL: targetPattern(String.raw`\bCALL\s+`),
573
+ CREATE: targetPattern(String.raw`\bCREATE\s+(?:OR\s+REPLACE\s+)?(?:TABLE|VIEW)\s+(?:IF\s+NOT\s+EXISTS\s+)?`),
574
+ DELETE: targetPattern(String.raw`\bDELETE\s+FROM\s+`),
575
+ DROP: targetPattern(String.raw`\bDROP\s+(?:TABLE|VIEW)\s+(?:IF\s+EXISTS\s+)?`),
576
+ INSERT: targetPattern(String.raw`\bINSERT\s+INTO\s+`),
577
+ MERGE: targetPattern(String.raw`\bMERGE\s+INTO\s+`),
578
+ SELECT: targetPattern(String.raw`\bFROM\s+`),
579
+ TRUNCATE: targetPattern(String.raw`\bTRUNCATE\s+(?:TABLE\s+)?`),
580
+ UPDATE: targetPattern(String.raw`\bUPDATE\s+`)
581
+ };
582
+ function queryText(query) {
583
+ if (typeof query === "string") return query;
584
+ if (!query || typeof query !== "object" || !("text" in query)) return;
585
+ return typeof query.text === "string" ? query.text : void 0;
586
+ }
587
+ function safeSqlText(text) {
588
+ let safe = "";
589
+ for (let index = 0; index < text.length;) {
590
+ if (text.startsWith("--", index)) {
591
+ const end = text.indexOf("\n", index + 2);
592
+ safe += " ";
593
+ index = end === -1 ? text.length : end;
594
+ continue;
595
+ }
596
+ if (text.startsWith("/*", index)) {
597
+ let depth = 1;
598
+ index += 2;
599
+ while (index < text.length && depth > 0) if (text.startsWith("/*", index)) {
600
+ depth += 1;
601
+ index += 2;
602
+ } else if (text.startsWith("*/", index)) {
603
+ depth -= 1;
604
+ index += 2;
605
+ } else index += 1;
606
+ safe += " ";
607
+ continue;
608
+ }
609
+ const dollarTag = /^\$(?:[A-Za-z_][A-Za-z0-9_]*)?\$/.exec(text.slice(index))?.[0];
610
+ if (dollarTag) {
611
+ const end = text.indexOf(dollarTag, index + dollarTag.length);
612
+ index = end === -1 ? text.length : end + dollarTag.length;
613
+ safe += "?";
614
+ continue;
615
+ }
616
+ const identifierPrefix = /^(?:U&)?"/i.exec(text.slice(index))?.[0];
617
+ if (identifierPrefix) {
618
+ let end = index + identifierPrefix.length;
619
+ while (end < text.length) {
620
+ if (text[end] !== "\"") {
621
+ end += 1;
622
+ continue;
623
+ }
624
+ if (text[end + 1] === "\"") {
625
+ end += 2;
626
+ continue;
627
+ }
628
+ end += 1;
629
+ break;
630
+ }
631
+ safe += text.slice(index, end);
632
+ index = end;
633
+ continue;
634
+ }
635
+ const stringPrefix = /^(?:E|U&|B|X)?'/i.exec(text.slice(index))?.[0];
636
+ if (stringPrefix) {
637
+ const supportsBackslashEscapes = /^E'/i.test(stringPrefix);
638
+ let end = index + stringPrefix.length;
639
+ while (end < text.length) {
640
+ if (supportsBackslashEscapes && text[end] === "\\") {
641
+ end += 2;
642
+ continue;
643
+ }
644
+ if (text[end] !== "'") {
645
+ end += 1;
646
+ continue;
647
+ }
648
+ if (text[end + 1] === "'") {
649
+ end += 2;
650
+ continue;
651
+ }
652
+ end += 1;
653
+ break;
654
+ }
655
+ safe += "?";
656
+ index = end;
657
+ continue;
658
+ }
659
+ const token = /^(?:TRUE|FALSE|NULL|0x[\da-f_]+|0b[01_]+|0o[0-7_]+|\d[\d_]*(?:\.[\d_]*)?(?:e[+-]?[\d_]+)?)(?![A-Za-z0-9_$])/i.exec(text.slice(index))?.[0];
660
+ const previous = text[index - 1];
661
+ if (token && (!previous || !/[A-Za-z0-9_$]/.test(previous))) {
662
+ safe += "?";
663
+ index += token.length;
664
+ continue;
665
+ }
666
+ safe += text[index];
667
+ index += 1;
668
+ }
669
+ return safe;
542
670
  }
543
- /** Add safe database spans to an owned PostgreSQL query client. */
544
- function traceQueries(client, driver) {
671
+ function normalizeQueryText(text) {
672
+ return safeSqlText(text.slice(0, MAX_QUERY_TEXT_LENGTH)).replace(/\s+/g, " ").trim().slice(0, MAX_QUERY_TEXT_LENGTH);
673
+ }
674
+ function operationFromText(text) {
675
+ const tokens = /(?:U&)?"(?:""|[^"])*"|[A-Za-z_][A-Za-z0-9_$]*|[()]/gi;
676
+ let depth = 0;
677
+ for (const match of text.matchAll(tokens)) {
678
+ const token = match[0];
679
+ if (token === "(") depth += 1;
680
+ else if (token === ")") depth = Math.max(0, depth - 1);
681
+ else if (depth === 0 && !token.includes("\"")) {
682
+ if (SQL_OPERATIONS.has(token.toUpperCase())) return {
683
+ index: match.index,
684
+ name: token
685
+ };
686
+ }
687
+ }
688
+ }
689
+ function targetFromOperation(operation, text) {
690
+ if (operation.toUpperCase() !== "SELECT") return SQL_TARGET[operation.toUpperCase()]?.exec(text)?.[1];
691
+ const tokens = /(?:U&)?"(?:""|[^"])*"|[A-Za-z_][A-Za-z0-9_$]*|[()]/gi;
692
+ let depth = 0;
693
+ for (const match of text.matchAll(tokens)) {
694
+ const token = match[0];
695
+ if (token === "(") depth += 1;
696
+ else if (token === ")") depth = Math.max(0, depth - 1);
697
+ else if (depth === 0 && token.toUpperCase() === "FROM") {
698
+ const targetText = text.slice(match.index + token.length).trimStart();
699
+ return new RegExp(`^(${SQL_IDENTIFIER})`, "i").exec(targetText)?.[1];
700
+ }
701
+ }
702
+ }
703
+ function querySummary(operation, target) {
704
+ if (!operation) return void 0;
705
+ const summary = target ? `${operation} ${target}` : operation;
706
+ return summary.length <= MAX_QUERY_SUMMARY_LENGTH ? summary : operation;
707
+ }
708
+ function detailsFromQuery(args) {
709
+ const rawText = queryText(args[0]);
710
+ if (!rawText) return {};
711
+ const text = normalizeQueryText(rawText);
712
+ const operationMatch = operationFromText(text);
713
+ const operation = operationMatch?.name;
714
+ const operationText = operationMatch ? text.slice(operationMatch.index) : "";
715
+ const target = operation ? targetFromOperation(operation, operationText) : void 0;
716
+ const summary = querySummary(operation, target);
717
+ const isCall = operation?.toUpperCase() === "CALL";
718
+ return {
719
+ collection: isCall ? void 0 : target,
720
+ operation,
721
+ storedProcedure: isCall ? target : void 0,
722
+ summary,
723
+ text: text || void 0
724
+ };
725
+ }
726
+ function connectionAttributes(connectionString) {
727
+ try {
728
+ const url = new URL(connectionString);
729
+ const namespace = decodeURIComponent(url.pathname.replace(/^\//, ""));
730
+ const port = url.port ? Number(url.port) : void 0;
731
+ return {
732
+ ...namespace ? { "db.namespace": namespace } : void 0,
733
+ ...url.hostname ? { "server.address": url.hostname } : void 0,
734
+ ...port && port !== 5432 ? { "server.port": port } : void 0
735
+ };
736
+ } catch {
737
+ return {};
738
+ }
739
+ }
740
+ function responseStatusCode(error) {
741
+ if (!error || typeof error !== "object" || !("code" in error)) return;
742
+ return typeof error.code === "string" || typeof error.code === "number" ? String(error.code) : void 0;
743
+ }
744
+ function errorType(error) {
745
+ return responseStatusCode(error) ?? (error instanceof Error ? error.name : typeof error);
746
+ }
747
+ function markFailed(span, error) {
748
+ const statusCode = responseStatusCode(error);
749
+ span.setAttribute("error.type", statusCode ?? errorType(error));
750
+ if (statusCode && /^[0-9A-Z]{5}$/i.test(statusCode)) span.setAttribute("db.response.status_code", statusCode);
751
+ span.setStatus({ code: 2 });
752
+ }
753
+ /** Add OpenTelemetry database client spans to an owned PostgreSQL query client. */
754
+ function traceQueries(client, options) {
545
755
  if (client[traced]) return client;
546
756
  client[traced] = true;
547
757
  const query = client.query.bind(client);
548
- client.query = ((...args) => {
549
- const operation = operationFromQuery(args[0]);
550
- return startSpan({
551
- name: operation ?? "postgresql",
758
+ const connection = connectionAttributes(options.connectionString);
759
+ client.query = ((...originalArgs) => {
760
+ const details = detailsFromQuery(originalArgs);
761
+ const args = [...originalArgs];
762
+ const callbackIndex = typeof args.at(-1) === "function" ? args.length - 1 : void 0;
763
+ return startSpanManual({
764
+ name: details.summary ?? details.operation ?? "postgresql",
552
765
  op: "db.query",
766
+ kind: SpanKind.CLIENT,
553
767
  onlyIfParent: true,
554
768
  attributes: {
555
769
  "db.system.name": "postgresql",
556
- ...operation ? { "db.operation.name": operation } : void 0,
557
- "app.db.driver": driver
770
+ ...connection,
771
+ ...details.operation ? { "db.operation.name": details.operation } : void 0,
772
+ ...details.summary ? { "db.query.summary": details.summary } : void 0,
773
+ ...details.text ? { "db.query.text": details.text } : void 0,
774
+ ...details.storedProcedure ? { "db.stored_procedure.name": details.storedProcedure } : void 0,
775
+ ...details.collection ? { "db.collection.name": details.collection } : void 0,
776
+ "app.db.driver": options.driver
777
+ }
778
+ }, (span, finish) => {
779
+ if (callbackIndex !== void 0) {
780
+ const callback = args[callbackIndex];
781
+ args[callbackIndex] = ((error, ...callbackArgs) => {
782
+ if (error) markFailed(span, error);
783
+ finish();
784
+ return callback(error, ...callbackArgs);
785
+ });
786
+ }
787
+ try {
788
+ const result = query(...args);
789
+ if (callbackIndex !== void 0) return result;
790
+ if (result && typeof result === "object" && "then" in result) return Promise.resolve(result).then((value) => {
791
+ finish();
792
+ return value;
793
+ }, (error) => {
794
+ markFailed(span, error);
795
+ finish();
796
+ throw error;
797
+ });
798
+ finish();
799
+ return result;
800
+ } catch (error) {
801
+ markFailed(span, error);
802
+ finish();
803
+ throw error;
558
804
  }
559
- }, () => query(...args));
805
+ });
560
806
  });
561
807
  return client;
562
808
  }
@@ -564,10 +810,12 @@ function traceQueries(client, driver) {
564
810
  //#region src/db/neon.ts
565
811
  var NeonExecutor = class {
566
812
  pool;
813
+ connectionString;
567
814
  transactionClient = new AsyncLocalStorage();
568
815
  savepointId = 0;
569
- constructor(pool) {
816
+ constructor(pool, connectionString) {
570
817
  this.pool = pool;
818
+ this.connectionString = connectionString;
571
819
  }
572
820
  db() {
573
821
  return drizzle(this.queryClient(), { schema: juniorSqlSchema });
@@ -648,7 +896,10 @@ var NeonExecutor = class {
648
896
  await this.pool.end();
649
897
  }
650
898
  queryClient() {
651
- return traceQueries(this.transactionClient.getStore() ?? this.pool, "neon");
899
+ return traceQueries(this.transactionClient.getStore() ?? this.pool, {
900
+ connectionString: this.connectionString,
901
+ driver: "neon"
902
+ });
652
903
  }
653
904
  };
654
905
  /** Create the shared Neon-backed Junior SQL executor. */
@@ -657,17 +908,19 @@ function createNeonJuniorSqlExecutor(args) {
657
908
  connectionString: args.connectionString,
658
909
  max: 3,
659
910
  statement_timeout: args.statementTimeoutMs
660
- }));
911
+ }), args.connectionString);
661
912
  }
662
913
  //#endregion
663
914
  //#region src/db/postgres.ts
664
915
  const { Pool: Pool$1 } = pg;
665
916
  var PostgresExecutor = class {
666
917
  pool;
918
+ connectionString;
667
919
  transactionClient = new AsyncLocalStorage();
668
920
  savepointId = 0;
669
- constructor(pool) {
921
+ constructor(pool, connectionString) {
670
922
  this.pool = pool;
923
+ this.connectionString = connectionString;
671
924
  }
672
925
  db() {
673
926
  return drizzle$1(this.queryClient(), { schema: juniorSqlSchema });
@@ -748,7 +1001,10 @@ var PostgresExecutor = class {
748
1001
  await this.pool.end();
749
1002
  }
750
1003
  queryClient() {
751
- return traceQueries(this.transactionClient.getStore() ?? this.pool, "postgres");
1004
+ return traceQueries(this.transactionClient.getStore() ?? this.pool, {
1005
+ connectionString: this.connectionString,
1006
+ driver: "postgres"
1007
+ });
752
1008
  }
753
1009
  };
754
1010
  /** Create the shared Node Postgres-backed Junior SQL executor. */
@@ -758,7 +1014,7 @@ function createPostgresJuniorSqlExecutor(args) {
758
1014
  connectionString: args.connectionString,
759
1015
  max: 3,
760
1016
  statement_timeout: args.statementTimeoutMs
761
- }));
1017
+ }), args.connectionString);
762
1018
  }
763
1019
  //#endregion
764
1020
  //#region src/db/executor.ts
@@ -1,6 +1,6 @@
1
- import { M as getDeploymentServiceVersion, N as getDeploymentTelemetryAttributes } from "./logging-sNS84Yuu.js";
2
- import { a as getClient, c as init, g as vercelAIIntegration, o as getGlobalScope, y as withStreamedSpan } from "./sentry-CD3SdJl-.js";
3
- import { n as getCurrentConversationPrivacy } from "./conversation-privacy-whGaV2TG.js";
1
+ import { M as getDeploymentServiceVersion, N as getDeploymentTelemetryAttributes } from "./logging-GTB-Z6hs.js";
2
+ import { _ as vercelAIIntegration, a as getClient, b as withStreamedSpan, c as init, o as getGlobalScope } from "./sentry-CgWZM_kV.js";
3
+ import { n as getCurrentConversationPrivacy } from "./conversation-privacy-Dxiz_d9l.js";
4
4
  import { t as consumePrivateTraceResultMarker } from "./private-trace-result-BLvBjy_e.js";
5
5
  //#region src/chat/sentry-payload-filter.ts
6
6
  const PAYLOAD_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([