@sentry/junior 0.40.0 → 0.41.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.
@@ -2,7 +2,7 @@ import {
2
2
  getPluginForSkillPath,
3
3
  getPluginSkillRoots,
4
4
  logWarn
5
- } from "./chunk-EU6E7QU2.js";
5
+ } from "./chunk-SCE5C645.js";
6
6
  import {
7
7
  skillRoots
8
8
  } from "./chunk-XPXD3FCE.js";
@@ -219,7 +219,7 @@ async function readSkillDirectory(skillDir) {
219
219
  {},
220
220
  {
221
221
  "file.path": skillDir,
222
- "error.message": parsed.error
222
+ "exception.message": parsed.error
223
223
  },
224
224
  "Invalid skill frontmatter"
225
225
  );
@@ -240,7 +240,7 @@ async function readSkillDirectory(skillDir) {
240
240
  {},
241
241
  {
242
242
  "file.path": skillDir,
243
- "error.message": error instanceof Error ? error.message : String(error)
243
+ "exception.message": error instanceof Error ? error.message : String(error)
244
244
  },
245
245
  "Failed to read skill directory"
246
246
  );
@@ -276,7 +276,7 @@ async function discoverSkills(options) {
276
276
  {},
277
277
  {
278
278
  "file.directory": root,
279
- "error.message": error instanceof Error ? error.message : String(error)
279
+ "exception.message": error instanceof Error ? error.message : String(error)
280
280
  },
281
281
  "Failed to read skill root"
282
282
  );
@@ -37,14 +37,14 @@ var SECRETS_RE = [
37
37
  /\b[A-Z0-9_]+(?:KEY|TOKEN|SECRET|PASSWORD|PASSWD)\s*[=:]\s*([^\s"']{8,})/gi
38
38
  ];
39
39
  var LEGACY_KEY_MAP = {
40
- error: "error.message",
40
+ error: "exception.message",
41
41
  "error.stack": "exception.stacktrace",
42
42
  "gen_ai.system": "gen_ai.provider.name",
43
43
  "gen_ai.request.messages": "gen_ai.input.messages",
44
44
  "gen_ai.response.text": "gen_ai.output.messages",
45
45
  "messaging.conversation.id": "messaging.message.conversation_id",
46
46
  bytes: "file.size",
47
- media_type: "file.mime_type",
47
+ media_type: "app.file.mime_type",
48
48
  skillDir: "file.path",
49
49
  root: "file.directory",
50
50
  originalLength: "app.output.original_length",
@@ -70,14 +70,12 @@ var LOGTAPE_BODY_KEY = "__logtape_body";
70
70
  var ROOT_LOGGER_CATEGORY = ["junior"];
71
71
  var CONSOLE_PRIORITY_KEYS = [
72
72
  "gen_ai.conversation.id",
73
- "app.turn.id",
74
73
  "event.name",
75
74
  "app.log.source",
76
- "error.message",
75
+ "exception.message",
77
76
  "messaging.message.id",
78
- "app.trace_id",
79
- "app.span_id",
80
- "app.agent.id",
77
+ "trace_id",
78
+ "span_id",
81
79
  "messaging.message.conversation_id",
82
80
  "messaging.destination.name",
83
81
  "app.run.id",
@@ -90,7 +88,7 @@ var CONSOLE_ALWAYS_HIDDEN_KEYS = /* @__PURE__ */ new Set([
90
88
  "gen_ai.agent.name",
91
89
  "app.platform",
92
90
  "enduser.id",
93
- "enduser.pseudo_id",
91
+ "enduser.pseudo.id",
94
92
  "http.request.method",
95
93
  "messaging.system",
96
94
  "url.full",
@@ -290,15 +288,13 @@ function sanitizeValue(value) {
290
288
  function contextToAttributes(context) {
291
289
  const attributes = {
292
290
  "gen_ai.conversation.id": context.conversationId,
293
- "app.turn.id": context.turnId,
294
- "app.agent.id": context.agentId,
295
291
  "app.platform": context.platform,
296
292
  "app.request.id": context.requestId,
297
293
  "messaging.system": context.platform === "slack" ? "slack" : context.platform,
298
294
  "messaging.message.conversation_id": context.slackThreadId,
299
295
  "messaging.destination.name": context.slackChannelId,
300
296
  "enduser.id": context.slackUserId,
301
- "enduser.pseudo_id": context.slackUserName,
297
+ "enduser.pseudo.id": context.slackUserName,
302
298
  "app.run.id": context.runId,
303
299
  "gen_ai.agent.name": context.assistantUserName,
304
300
  "gen_ai.request.model": context.modelId,
@@ -539,9 +535,6 @@ function shouldHideConsoleAttribute(level, eventName, key, attributes) {
539
535
  if (CONSOLE_DROP_WHEN_COUNTED_KEYS.has(key)) {
540
536
  return true;
541
537
  }
542
- if (key === "app.agent.id" && attributes[key] === attributes["app.turn.id"]) {
543
- return true;
544
- }
545
538
  if (key === "messaging.message.conversation_id" && attributes[key] === attributes["gen_ai.conversation.id"]) {
546
539
  return true;
547
540
  }
@@ -673,7 +666,6 @@ function getPrettyConsoleSummaryTokens(level, eventName, attributes) {
673
666
  const conversationId = toOptionalString(
674
667
  attributes["gen_ai.conversation.id"]
675
668
  );
676
- const turnId = toOptionalString(attributes["app.turn.id"]);
677
669
  const messageId = toOptionalString(attributes["messaging.message.id"]);
678
670
  if (conversationId) {
679
671
  pushPrettyConsoleToken(
@@ -681,9 +673,6 @@ function getPrettyConsoleSummaryTokens(level, eventName, attributes) {
681
673
  `conv=${abbreviateConsoleId(conversationId)}`
682
674
  );
683
675
  }
684
- if (turnId) {
685
- pushPrettyConsoleToken(tokens, `turn=${abbreviateConsoleId(turnId)}`);
686
- }
687
676
  if (messageId) {
688
677
  pushPrettyConsoleToken(tokens, `msg=${abbreviateConsoleId(messageId)}`);
689
678
  }
@@ -853,7 +842,6 @@ var log = {
853
842
  {
854
843
  ...attrs,
855
844
  "error.type": normalizedError.name,
856
- "error.message": normalizedError.message,
857
845
  "exception.type": normalizedError.name,
858
846
  "exception.message": normalizedError.message,
859
847
  "exception.stacktrace": normalizedError.stack
@@ -1019,6 +1007,16 @@ function toSpanAttributeValue(value) {
1019
1007
  );
1020
1008
  return sanitized.length > 0 ? sanitized : void 0;
1021
1009
  }
1010
+ function normalizeSpanAttributes(attributes) {
1011
+ const normalized = {};
1012
+ for (const [rawKey, value] of Object.entries(attributes)) {
1013
+ const normalizedValue = toSpanAttributeValue(value);
1014
+ if (normalizedValue !== void 0) {
1015
+ normalized[normalizeAttributeKey(rawKey)] = normalizedValue;
1016
+ }
1017
+ }
1018
+ return normalized;
1019
+ }
1022
1020
  function logInfo(eventName, context = {}, attributes = {}, body) {
1023
1021
  log.info(eventName, { ...toSpanAttributes(context), ...attributes }, body);
1024
1022
  }
@@ -1048,13 +1046,7 @@ async function withContext(context, callback) {
1048
1046
  return withLogContext(context, callback);
1049
1047
  }
1050
1048
  async function withSpan(name, op, context, callback, attributes = {}) {
1051
- const normalizedAttributes = {};
1052
- for (const [key, value] of Object.entries(attributes)) {
1053
- const normalizedValue = toSpanAttributeValue(value);
1054
- if (normalizedValue !== void 0) {
1055
- normalizedAttributes[key] = normalizedValue;
1056
- }
1057
- }
1049
+ const normalizedAttributes = normalizeSpanAttributes(attributes);
1058
1050
  return withLogContext(context, () => {
1059
1051
  const inheritedAttributes = getLogContextAttributes();
1060
1052
  return sentry_exports.startSpan(
@@ -1080,11 +1072,10 @@ function setSpanAttributes(attributes) {
1080
1072
  if (typeof setAttribute !== "function") {
1081
1073
  return;
1082
1074
  }
1083
- for (const [key, value] of Object.entries(attributes)) {
1084
- const normalizedValue = toSpanAttributeValue(value);
1085
- if (normalizedValue !== void 0) {
1086
- setAttribute.call(span, key, normalizedValue);
1087
- }
1075
+ for (const [key, value] of Object.entries(
1076
+ normalizeSpanAttributes(attributes)
1077
+ )) {
1078
+ setAttribute.call(span, key, value);
1088
1079
  }
1089
1080
  }
1090
1081
  function setSpanStatus(status) {
@@ -1189,6 +1180,18 @@ function toFiniteTokenCount(value) {
1189
1180
  const rounded = Math.floor(value);
1190
1181
  return rounded >= 0 ? rounded : void 0;
1191
1182
  }
1183
+ function sumTokenCounts(...values) {
1184
+ let total = 0;
1185
+ let hasValue = false;
1186
+ for (const value of values) {
1187
+ if (value === void 0) {
1188
+ continue;
1189
+ }
1190
+ total += value;
1191
+ hasValue = true;
1192
+ }
1193
+ return hasValue ? total : void 0;
1194
+ }
1192
1195
  var PI_USAGE_FIELDS = [
1193
1196
  ["input", "inputTokens"],
1194
1197
  ["output", "outputTokens"],
@@ -1204,7 +1207,7 @@ function readPiUsage(source) {
1204
1207
  const usage = asRecord(record.usage) ?? record;
1205
1208
  const summary = {};
1206
1209
  for (const [piKey, ourKey] of PI_USAGE_FIELDS) {
1207
- const value = toFiniteTokenCount(usage[piKey]);
1210
+ const value = toFiniteTokenCount(usage[piKey]) ?? toFiniteTokenCount(usage[ourKey]);
1208
1211
  if (value !== void 0) {
1209
1212
  summary[ourKey] = value;
1210
1213
  }
@@ -1224,10 +1227,17 @@ function extractGenAiUsageSummary(...sources) {
1224
1227
  return summary;
1225
1228
  }
1226
1229
  function extractGenAiUsageAttributes(...sources) {
1227
- const { inputTokens, outputTokens } = extractGenAiUsageSummary(...sources);
1230
+ const { inputTokens, outputTokens, cachedInputTokens, cacheCreationTokens } = extractGenAiUsageSummary(...sources);
1231
+ const semanticInputTokens = sumTokenCounts(
1232
+ inputTokens,
1233
+ cachedInputTokens,
1234
+ cacheCreationTokens
1235
+ );
1228
1236
  return {
1229
- ...inputTokens !== void 0 ? { "gen_ai.usage.input_tokens": inputTokens } : {},
1230
- ...outputTokens !== void 0 ? { "gen_ai.usage.output_tokens": outputTokens } : {}
1237
+ ...semanticInputTokens !== void 0 ? { "gen_ai.usage.input_tokens": semanticInputTokens } : {},
1238
+ ...outputTokens !== void 0 ? { "gen_ai.usage.output_tokens": outputTokens } : {},
1239
+ ...cachedInputTokens !== void 0 ? { "gen_ai.usage.cache_read.input_tokens": cachedInputTokens } : {},
1240
+ ...cacheCreationTokens !== void 0 ? { "gen_ai.usage.cache_creation.input_tokens": cacheCreationTokens } : {}
1231
1241
  };
1232
1242
  }
1233
1243
 
@@ -2709,7 +2719,7 @@ function buildLoadedPluginState(source) {
2709
2719
  {},
2710
2720
  {
2711
2721
  "file.directory": pluginsRoot,
2712
- "error.message": error instanceof Error ? error.message : String(error)
2722
+ "exception.message": error instanceof Error ? error.message : String(error)
2713
2723
  },
2714
2724
  "Failed to read plugin root"
2715
2725
  );
@@ -2737,7 +2747,7 @@ function buildLoadedPluginState(source) {
2737
2747
  {},
2738
2748
  {
2739
2749
  "file.directory": pluginsRoot,
2740
- "error.message": error instanceof Error ? error.message : String(error)
2750
+ "exception.message": error instanceof Error ? error.message : String(error)
2741
2751
  },
2742
2752
  "Failed to read plugin root"
2743
2753
  );
@@ -2781,7 +2791,7 @@ function logLoadedPlugins(state) {
2781
2791
  "app.plugin.config_key_count": plugin.manifest.configKeys.length,
2782
2792
  "app.plugin.has_mcp": Boolean(plugin.manifest.mcp),
2783
2793
  "file.directory": plugin.dir,
2784
- "file.skill_directory": plugin.skillsDir
2794
+ "app.file.skill_directory": plugin.skillsDir
2785
2795
  },
2786
2796
  "Loaded plugin"
2787
2797
  );
@@ -7,7 +7,7 @@ import {
7
7
  serializeGenAiAttribute,
8
8
  setSpanAttributes,
9
9
  withSpan
10
- } from "./chunk-EU6E7QU2.js";
10
+ } from "./chunk-SCE5C645.js";
11
11
 
12
12
  // src/chat/state/adapter.ts
13
13
  import { createMemoryState } from "@chat-adapter/state-memory";
@@ -182,7 +182,7 @@ async function completeText(params) {
182
182
  {},
183
183
  {
184
184
  ...baseAttributes,
185
- "error.message": providerMessage
185
+ "exception.message": providerMessage
186
186
  },
187
187
  "AI completion returned provider error"
188
188
  );
@@ -197,7 +197,6 @@ async function completeText(params) {
197
197
  );
198
198
  }
199
199
  async function completeObject(params) {
200
- const startedAt = Date.now();
201
200
  let text = "";
202
201
  try {
203
202
  ({ text } = await completeText({
@@ -224,8 +223,7 @@ async function completeObject(params) {
224
223
  {
225
224
  "gen_ai.provider.name": GEN_AI_PROVIDER_NAME,
226
225
  "gen_ai.operation.name": GEN_AI_OPERATION_CHAT,
227
- "gen_ai.request.model": params.modelId,
228
- "app.ai.duration_ms": Date.now() - startedAt
226
+ "gen_ai.request.model": params.modelId
229
227
  },
230
228
  "AI object completion failed"
231
229
  );
@@ -242,7 +240,6 @@ async function completeObject(params) {
242
240
  "gen_ai.provider.name": GEN_AI_PROVIDER_NAME,
243
241
  "gen_ai.operation.name": GEN_AI_OPERATION_CHAT,
244
242
  "gen_ai.request.model": params.modelId,
245
- "app.ai.duration_ms": Date.now() - startedAt,
246
243
  "app.ai.response_preview": preview
247
244
  },
248
245
  "AI object completion schema parse failed"
package/dist/cli/check.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  parseSkillFile
3
- } from "../chunk-SPNY2HJJ.js";
3
+ } from "../chunk-7QYONRLH.js";
4
4
  import {
5
5
  parsePluginManifest
6
- } from "../chunk-EU6E7QU2.js";
6
+ } from "../chunk-SCE5C645.js";
7
7
  import "../chunk-Z3YD6NHK.js";
8
8
  import "../chunk-XPXD3FCE.js";
9
9
  import "../chunk-2KG3PWR4.js";
package/dist/cli/init.js CHANGED
@@ -147,6 +147,7 @@ AI_VISION_MODEL=
147
147
  AI_WEB_SEARCH_MODEL=
148
148
  REDIS_URL=
149
149
  SENTRY_DSN=
150
+ SENTRY_ORG_SLUG=
150
151
  `
151
152
  );
152
153
  writeServerEntry(target);
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  disconnectStateAdapter,
3
3
  resolveRuntimeDependencySnapshot
4
- } from "../chunk-SY4ULGUN.js";
4
+ } from "../chunk-Y3UO7NR6.js";
5
5
  import {
6
6
  getPluginProviders,
7
7
  getPluginRuntimeDependencies,
8
8
  getPluginRuntimePostinstall
9
- } from "../chunk-EU6E7QU2.js";
9
+ } from "../chunk-SCE5C645.js";
10
10
  import "../chunk-Z3YD6NHK.js";
11
11
  import "../chunk-XPXD3FCE.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.40.0",
3
+ "version": "0.41.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"