@sentry/junior 0.15.2 → 0.16.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/app.d.ts CHANGED
@@ -7,7 +7,7 @@ interface JuniorAppOptions {
7
7
  pluginPackages?: string[];
8
8
  waitUntil?: WaitUntilFn;
9
9
  }
10
- /** Create a Hono app with all Junior routes mounted under `/api`. */
10
+ /** Create a Hono app with all Junior routes. */
11
11
  declare function createApp(options?: JuniorAppOptions): Promise<Hono>;
12
12
 
13
13
  export { type JuniorAppOptions, createApp };
package/dist/app.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  logCapabilityCatalogLoadedOnce,
8
8
  parseSkillInvocation,
9
9
  stripFrontmatter
10
- } from "./chunk-KTBQH6L5.js";
10
+ } from "./chunk-ZU6X5ZGL.js";
11
11
  import {
12
12
  SANDBOX_SKILLS_ROOT,
13
13
  SANDBOX_WORKSPACE_ROOT,
@@ -26,13 +26,14 @@ import {
26
26
  runNonInteractiveCommand,
27
27
  sandboxSkillDir,
28
28
  toOptionalTrimmed
29
- } from "./chunk-ESPIOJPM.js";
29
+ } from "./chunk-3JKW7ISL.js";
30
30
  import {
31
31
  CredentialUnavailableError,
32
32
  buildOAuthTokenRequest,
33
33
  createPluginBroker,
34
34
  createRequestContext,
35
35
  extractGenAiUsageAttributes,
36
+ getActiveTraceId,
36
37
  getPluginDefinition,
37
38
  getPluginMcpProviders,
38
39
  getPluginOAuthConfig,
@@ -54,7 +55,7 @@ import {
54
55
  toOptionalString,
55
56
  withContext,
56
57
  withSpan
57
- } from "./chunk-5JHLDXBN.js";
58
+ } from "./chunk-RUC2V7Q7.js";
58
59
  import "./chunk-Z3YD6NHK.js";
59
60
  import {
60
61
  aboutPathCandidates,
@@ -224,8 +225,8 @@ async function GET3() {
224
225
  html += `
225
226
  </div>`;
226
227
  const endpoints = [
227
- { method: "GET", path: "/api/health" },
228
- { method: "GET", path: "/api/__junior/discovery" },
228
+ { method: "GET", path: "/health" },
229
+ { method: "GET", path: "/api/info" },
229
230
  { method: "GET", path: "/api/oauth/callback/mcp/:provider" },
230
231
  { method: "GET", path: "/api/oauth/callback/:provider" },
231
232
  { method: "POST", path: "/api/webhooks/:platform" }
@@ -1157,21 +1158,44 @@ function summarizeMessageText(text) {
1157
1158
  }
1158
1159
  return normalized.length > 1200 ? `${normalized.slice(0, 1200)}...` : normalized;
1159
1160
  }
1160
- function buildUserTurnText(userInput, conversationContext) {
1161
+ function buildUserTurnText(userInput, conversationContext, metadata) {
1161
1162
  const trimmedContext = conversationContext?.trim();
1162
- if (!trimmedContext) {
1163
+ const hasSessionContext = Boolean(metadata?.sessionContext?.conversationId);
1164
+ const hasTurnContext = Boolean(metadata?.turnContext?.traceId);
1165
+ if (!trimmedContext && !hasSessionContext && !hasTurnContext) {
1163
1166
  return userInput;
1164
1167
  }
1165
- return [
1168
+ const sections = [
1166
1169
  "<current-message>",
1167
1170
  userInput,
1168
- "</current-message>",
1169
- "",
1170
- "<thread-conversation-context>",
1171
- "Use this context for continuity across prior thread turns.",
1172
- trimmedContext,
1173
- "</thread-conversation-context>"
1174
- ].join("\n");
1171
+ "</current-message>"
1172
+ ];
1173
+ if (trimmedContext) {
1174
+ sections.push(
1175
+ "",
1176
+ "<thread-conversation-context>",
1177
+ "Use this context for continuity across prior thread turns.",
1178
+ trimmedContext,
1179
+ "</thread-conversation-context>"
1180
+ );
1181
+ }
1182
+ if (metadata?.sessionContext?.conversationId) {
1183
+ sections.push(
1184
+ "",
1185
+ "<session-context>",
1186
+ `- gen_ai.conversation.id: ${metadata.sessionContext.conversationId}`,
1187
+ "</session-context>"
1188
+ );
1189
+ }
1190
+ if (metadata?.turnContext?.traceId) {
1191
+ sections.push(
1192
+ "",
1193
+ "<turn-context>",
1194
+ `- trace_id: ${metadata.turnContext.traceId}`,
1195
+ "</turn-context>"
1196
+ );
1197
+ }
1198
+ return sections.join("\n");
1175
1199
  }
1176
1200
  function encodeNonImageAttachmentForPrompt(attachment) {
1177
1201
  const base64 = attachment.data.toString("base64");
@@ -3006,7 +3030,8 @@ function buildSystemPrompt(params) {
3006
3030
  "- Never call side-effecting tools when the user only asked for analysis or options.",
3007
3031
  "- `loadSkill` returns `available_tools` when the loaded skill exposes MCP tools. Use those exact tool_name values instead of guessing.",
3008
3032
  "- `searchTools` searches active MCP tools exposed by currently loaded skills when you need to rediscover or filter them.",
3009
- "- `useTool` executes a canonical MCP tool name from `loadSkill.available_tools`, `<loaded_tools>`, or `searchTools`."
3033
+ "- `useTool` executes a canonical MCP tool name from `loadSkill.available_tools`, `<loaded_tools>`, or `searchTools`.",
3034
+ "- When the user asks for their conversation ID, trace ID, or a reference for Sentry lookup, use the IDs from `<session-context>` and `<turn-context>` in the user turn."
3010
3035
  ].join("\n")
3011
3036
  ),
3012
3037
  renderTag(
@@ -8960,7 +8985,11 @@ async function generateAssistantReply(messageText, context = {}) {
8960
8985
  }
8961
8986
  const userTurnText = buildUserTurnText(
8962
8987
  userInput,
8963
- context.conversationContext
8988
+ context.conversationContext,
8989
+ {
8990
+ sessionContext: { conversationId: sessionConversationId },
8991
+ turnContext: { traceId: getActiveTraceId() }
8992
+ }
8964
8993
  );
8965
8994
  timeoutResumeMessages = [];
8966
8995
  pendingMcpAuthorizationPause = void 0;
@@ -12973,21 +13002,21 @@ async function createApp(options) {
12973
13002
  options?.pluginPackages ?? await resolveBuildPluginPackages()
12974
13003
  );
12975
13004
  const waitUntil = options?.waitUntil ?? await defaultWaitUntil();
12976
- const app = new Hono().basePath("/api");
13005
+ const app = new Hono();
12977
13006
  app.onError((err, c) => {
12978
13007
  logException(err, "unhandled_route_error");
12979
13008
  return c.text("Internal Server Error", 500);
12980
13009
  });
13010
+ app.get("/", () => GET3());
12981
13011
  app.get("/health", () => GET2());
12982
- app.get("/__junior/discovery", () => GET());
12983
- app.get("/__junior/dashboard", () => GET3());
12984
- app.get("/oauth/callback/mcp/:provider", (c) => {
13012
+ app.get("/api/info", () => GET());
13013
+ app.get("/api/oauth/callback/mcp/:provider", (c) => {
12985
13014
  return GET4(c.req.raw, c.req.param("provider"), waitUntil);
12986
13015
  });
12987
- app.get("/oauth/callback/:provider", (c) => {
13016
+ app.get("/api/oauth/callback/:provider", (c) => {
12988
13017
  return GET5(c.req.raw, c.req.param("provider"), waitUntil);
12989
13018
  });
12990
- app.post("/webhooks/:platform", (c) => {
13019
+ app.post("/api/webhooks/:platform", (c) => {
12991
13020
  return POST(c.req.raw, c.req.param("platform"), waitUntil);
12992
13021
  });
12993
13022
  return app;
@@ -2,7 +2,7 @@ import {
2
2
  getPluginRuntimeDependencies,
3
3
  getPluginRuntimePostinstall,
4
4
  withSpan
5
- } from "./chunk-5JHLDXBN.js";
5
+ } from "./chunk-RUC2V7Q7.js";
6
6
 
7
7
  // src/chat/state/adapter.ts
8
8
  import { createMemoryState } from "@chat-adapter/state-memory";
@@ -1623,6 +1623,12 @@ function createGitHubAppBroker(manifest, credentials) {
1623
1623
  function leaseDomainsFor(capability) {
1624
1624
  return GIT_CAPABILITIES.has(capability) ? [...apiDomains, GIT_DOMAIN] : apiDomains;
1625
1625
  }
1626
+ function authorizationFor(domain, token) {
1627
+ if (domain === GIT_DOMAIN) {
1628
+ return `Basic ${Buffer.from(`x-access-token:${token}`).toString("base64")}`;
1629
+ }
1630
+ return `Bearer ${token}`;
1631
+ }
1626
1632
  const supportedCapabilities = new Set(manifest.capabilities);
1627
1633
  return {
1628
1634
  async issue(input) {
@@ -1659,7 +1665,7 @@ function createGitHubAppBroker(manifest, credentials) {
1659
1665
  domain,
1660
1666
  headers: {
1661
1667
  ...apiHeaders ?? {},
1662
- Authorization: `Bearer ${cached.token}`
1668
+ Authorization: authorizationFor(domain, cached.token)
1663
1669
  }
1664
1670
  })),
1665
1671
  expiresAt: new Date(cached.expiresAt).toISOString(),
@@ -1703,7 +1709,7 @@ function createGitHubAppBroker(manifest, credentials) {
1703
1709
  domain,
1704
1710
  headers: {
1705
1711
  ...apiHeaders ?? {},
1706
- Authorization: `Bearer ${accessTokenResponse.token}`
1712
+ Authorization: authorizationFor(domain, accessTokenResponse.token)
1707
1713
  }
1708
1714
  })),
1709
1715
  expiresAt: new Date(expiresAtMs).toISOString(),
@@ -2288,6 +2294,7 @@ export {
2288
2294
  withSpan,
2289
2295
  setSpanAttributes,
2290
2296
  setSpanStatus,
2297
+ getActiveTraceId,
2291
2298
  resolveErrorReference,
2292
2299
  serializeGenAiAttribute,
2293
2300
  extractGenAiUsageAttributes,
@@ -5,7 +5,7 @@ import {
5
5
  getPluginSkillRoots,
6
6
  logInfo,
7
7
  logWarn
8
- } from "./chunk-5JHLDXBN.js";
8
+ } from "./chunk-RUC2V7Q7.js";
9
9
  import {
10
10
  skillRoots
11
11
  } from "./chunk-RBB2MZAN.js";
package/dist/cli/check.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  parseSkillFile
3
- } from "../chunk-KTBQH6L5.js";
3
+ } from "../chunk-ZU6X5ZGL.js";
4
4
  import {
5
5
  parsePluginManifest
6
- } from "../chunk-5JHLDXBN.js";
6
+ } from "../chunk-RUC2V7Q7.js";
7
7
  import "../chunk-Z3YD6NHK.js";
8
8
  import "../chunk-RBB2MZAN.js";
9
9
  import "../chunk-2KG3PWR4.js";
package/dist/cli/init.js CHANGED
@@ -27,7 +27,7 @@ export default defineConfig({
27
27
  preset: "vercel",
28
28
  modules: [juniorNitro()],
29
29
  routes: {
30
- "/api/**": { handler: "./server.ts" },
30
+ "/**": { handler: "./server.ts" },
31
31
  },
32
32
  });
33
33
  `
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  disconnectStateAdapter,
3
3
  resolveRuntimeDependencySnapshot
4
- } from "../chunk-ESPIOJPM.js";
4
+ } from "../chunk-3JKW7ISL.js";
5
5
  import {
6
6
  getPluginProviders,
7
7
  getPluginRuntimeDependencies,
8
8
  getPluginRuntimePostinstall
9
- } from "../chunk-5JHLDXBN.js";
9
+ } from "../chunk-RUC2V7Q7.js";
10
10
  import "../chunk-Z3YD6NHK.js";
11
11
  import "../chunk-RBB2MZAN.js";
12
12
  import "../chunk-2KG3PWR4.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior",
3
- "version": "0.15.2",
3
+ "version": "0.16.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"