@sentry/junior 0.95.0 → 0.96.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 (49) hide show
  1. package/dist/{agent-hooks-FTQ5EGPO.js → agent-hooks-5URSMY3O.js} +6 -6
  2. package/dist/api/people/list.js +5 -5
  3. package/dist/api/people/profile.js +5 -5
  4. package/dist/api-reference.d.ts +1 -1
  5. package/dist/app.js +24 -20
  6. package/dist/{catalog-runtime-2D7IVKUT.js → catalog-runtime-MSMAYYIK.js} +3 -3
  7. package/dist/chat/logging.d.ts +2 -2
  8. package/dist/chat/plugins/auth/oauth-request.d.ts +2 -0
  9. package/dist/chat/resource-events/notification.d.ts +2 -0
  10. package/dist/chat/runtime/agent-run-outcome.d.ts +3 -0
  11. package/dist/chat/sentry.d.ts +1 -1
  12. package/dist/chat/state/turn-session.d.ts +3 -1
  13. package/dist/chat/usage.d.ts +27 -13
  14. package/dist/{chunk-E3E2XNCN.js → chunk-2NAZZPPS.js} +2 -2
  15. package/dist/{chunk-CRRBJ3JP.js → chunk-5C6XTTFI.js} +4 -4
  16. package/dist/{chunk-3DA7X2U3.js → chunk-6GWA276C.js} +15 -0
  17. package/dist/{chunk-EKNJM5IG.js → chunk-AAZXTVJT.js} +2 -2
  18. package/dist/{chunk-WCMQJE4F.js → chunk-BYZWPRJA.js} +3 -3
  19. package/dist/{chunk-HZNJLKKI.js → chunk-DZENG5ML.js} +1 -1
  20. package/dist/{chunk-5XMNOD3S.js → chunk-GQ3GK22G.js} +3 -3
  21. package/dist/{chunk-WPOJ443W.js → chunk-I35CTGPO.js} +58 -6
  22. package/dist/{chunk-HCXXB35T.js → chunk-IYM2SIVG.js} +21 -19
  23. package/dist/{chunk-GVOUCI2O.js → chunk-L7CDEIVJ.js} +12 -4
  24. package/dist/{chunk-WAGQ377B.js → chunk-MNTINMWR.js} +170 -29
  25. package/dist/{chunk-XX4N4E6C.js → chunk-P3YFQLEN.js} +8 -8
  26. package/dist/{chunk-HDTO3A74.js → chunk-PMNN6ST4.js} +2 -2
  27. package/dist/{chunk-6ONME5IG.js → chunk-RITD7E5L.js} +2 -2
  28. package/dist/{chunk-NSCHU54X.js → chunk-S5KZ5LPG.js} +4 -4
  29. package/dist/{chunk-KDPCGVIT.js → chunk-UKHVMPX5.js} +5 -61
  30. package/dist/{chunk-N4RNJ32C.js → chunk-WM6KHPBQ.js} +1 -1
  31. package/dist/{chunk-AYP4ERVZ.js → chunk-YDT7SNCN.js} +1 -1
  32. package/dist/{chunk-GUE7HTNR.js → chunk-YDVEH3SB.js} +1 -1
  33. package/dist/cli/chat.js +19 -19
  34. package/dist/cli/check.js +4 -4
  35. package/dist/cli/main.js +1 -1
  36. package/dist/cli/plugins.js +8 -8
  37. package/dist/cli/snapshot-warmup.js +5 -5
  38. package/dist/cli/upgrade.js +8 -8
  39. package/dist/{db-W55B74OP.js → db-2D6RMG67.js} +4 -4
  40. package/dist/instrumentation.js +1 -1
  41. package/dist/{legacy-import-ZPLGLAFD.js → legacy-import-VZ2MEGP7.js} +5 -5
  42. package/dist/reporting/conversations/summaries.d.ts +3 -0
  43. package/dist/reporting/conversations/types.d.ts +13 -0
  44. package/dist/reporting.d.ts +1 -1
  45. package/dist/reporting.js +113 -23
  46. package/dist/{runner-OOSBDYRK.js → runner-JZBRQP4F.js} +10 -10
  47. package/dist/{sentry-EGFOV3DH.js → sentry-JMWTS32N.js} +11 -1
  48. package/dist/{validation-QCGRFRFZ.js → validation-6XOOQGME.js} +4 -4
  49. package/package.json +7 -7
package/dist/reporting.js CHANGED
@@ -4,29 +4,30 @@ import {
4
4
  buildSentryTraceUrl,
5
5
  formatSlackConversationRedactedLabel,
6
6
  resolveSlackConversationContextFromThreadId
7
- } from "./chunk-EKNJM5IG.js";
7
+ } from "./chunk-AAZXTVJT.js";
8
8
  import {
9
9
  unwrapAdvisorRequest
10
- } from "./chunk-N4RNJ32C.js";
10
+ } from "./chunk-WM6KHPBQ.js";
11
11
  import {
12
12
  listAgentTurnSessionSummariesForConversation,
13
+ listAgentTurnSessionSummariesForConversations,
13
14
  loadProjection,
14
15
  projectSteps
15
- } from "./chunk-WAGQ377B.js";
16
- import "./chunk-CRRBJ3JP.js";
16
+ } from "./chunk-MNTINMWR.js";
17
+ import "./chunk-5C6XTTFI.js";
17
18
  import {
18
19
  getPluginOperationalReports
19
- } from "./chunk-NSCHU54X.js";
20
- import "./chunk-E3E2XNCN.js";
20
+ } from "./chunk-S5KZ5LPG.js";
21
+ import "./chunk-2NAZZPPS.js";
21
22
  import "./chunk-CZEX6KIQ.js";
22
23
  import {
23
24
  getAgentStepStore,
24
25
  getConversationMessageStore,
25
26
  getConversationStore
26
- } from "./chunk-6ONME5IG.js";
27
+ } from "./chunk-RITD7E5L.js";
27
28
  import {
28
29
  unwrapCurrentInstruction
29
- } from "./chunk-GUE7HTNR.js";
30
+ } from "./chunk-YDVEH3SB.js";
30
31
  import {
31
32
  canExposeConversationPayload,
32
33
  parseSlackThreadId,
@@ -35,15 +36,15 @@ import {
35
36
  import "./chunk-B7PUBQQM.js";
36
37
  import {
37
38
  discoverSkills
38
- } from "./chunk-HDTO3A74.js";
39
+ } from "./chunk-PMNN6ST4.js";
39
40
  import {
40
41
  pluginCatalogRuntime
41
- } from "./chunk-GVOUCI2O.js";
42
- import "./chunk-WPOJ443W.js";
42
+ } from "./chunk-L7CDEIVJ.js";
43
+ import "./chunk-I35CTGPO.js";
43
44
  import {
44
45
  isRecord
45
46
  } from "./chunk-OB42YVAE.js";
46
- import "./chunk-3DA7X2U3.js";
47
+ import "./chunk-6GWA276C.js";
47
48
  import {
48
49
  homeDir
49
50
  } from "./chunk-6APU57E6.js";
@@ -446,6 +447,18 @@ function surfaceFromSource(source, conversationId) {
446
447
  }
447
448
  function actorIdentityReport(actor) {
448
449
  if (!actor) return void 0;
450
+ if ("name" in actor) {
451
+ return { fullName: actor.name };
452
+ }
453
+ if ("userId" in actor) {
454
+ const identity2 = {
455
+ ...actor.email !== void 0 ? { email: actor.email } : {},
456
+ ...actor.fullName !== void 0 ? { fullName: actor.fullName } : {},
457
+ ...actor.platform === "slack" ? { slackUserId: actor.userId } : {},
458
+ ...actor.platform === "slack" && actor.userName !== void 0 ? { slackUserName: actor.userName } : {}
459
+ };
460
+ return Object.keys(identity2).length > 0 ? identity2 : void 0;
461
+ }
449
462
  const identity = {
450
463
  ...actor.email !== void 0 ? { email: actor.email } : {},
451
464
  ...actor.fullName !== void 0 ? { fullName: actor.fullName } : {},
@@ -542,6 +555,42 @@ function sessionReportFromConversation(conversation, nowMs) {
542
555
  ...channelNameRedacted ? { channelNameRedacted: true } : {}
543
556
  };
544
557
  }
558
+ function statusFromTurnSummary(summary, nowMs) {
559
+ if (summary.state === "running" && nowMs - summary.lastProgressAtMs > HUNG_TURN_PROGRESS_MS) {
560
+ return "hung";
561
+ }
562
+ if (summary.state === "running" || summary.state === "awaiting_resume") {
563
+ return "active";
564
+ }
565
+ if (summary.state === "abandoned") {
566
+ return "superseded";
567
+ }
568
+ return summary.state;
569
+ }
570
+ function sessionReportFromTurnSummary(conversation, summary, nowMs) {
571
+ const base = sessionReportFromConversation(conversation, nowMs);
572
+ if (summary.actor !== void 0) {
573
+ const actorIdentity = actorIdentityReport(summary.actor);
574
+ if (actorIdentity) {
575
+ base.actorIdentity = actorIdentity;
576
+ } else {
577
+ delete base.actorIdentity;
578
+ }
579
+ }
580
+ return {
581
+ ...base,
582
+ cumulativeDurationMs: summary.cumulativeDurationMs,
583
+ ...summary.cumulativeUsage ? { cumulativeUsage: summary.cumulativeUsage } : {},
584
+ id: summary.sessionId,
585
+ lastProgressAt: new Date(summary.lastProgressAtMs).toISOString(),
586
+ lastSeenAt: new Date(summary.updatedAtMs).toISOString(),
587
+ startedAt: new Date(summary.startedAtMs).toISOString(),
588
+ status: statusFromTurnSummary(summary, nowMs),
589
+ surface: summary.surface ?? base.surface,
590
+ ...summary.state === "completed" ? { completedAt: new Date(summary.updatedAtMs).toISOString() } : {},
591
+ ...summary.traceId ? { traceId: summary.traceId } : {}
592
+ };
593
+ }
545
594
  async function reportsFromConversations(args) {
546
595
  const reports = /* @__PURE__ */ new Map();
547
596
  for (const conversation of args.conversations) {
@@ -662,6 +711,10 @@ async function readConversationReport(conversationId, options = {}) {
662
711
  const effectiveRuns = conversation ? [
663
712
  {
664
713
  ...sessionReportFromConversation(conversation, nowMs),
714
+ ...currentTurnSummary ? {
715
+ cumulativeDurationMs: currentTurnSummary.cumulativeDurationMs,
716
+ ...currentTurnSummary.cumulativeUsage ? { cumulativeUsage: currentTurnSummary.cumulativeUsage } : {}
717
+ } : {},
665
718
  ...currentTurnSummary?.modelId ? { modelId: currentTurnSummary.modelId } : {},
666
719
  ...currentTurnSummary?.reasoningLevel ? { reasoningLevel: currentTurnSummary.reasoningLevel } : {},
667
720
  ...traceId ? { traceId } : {},
@@ -795,27 +848,41 @@ function usageTokenTotal(usage) {
795
848
  }
796
849
  return typeof usage.totalTokens === "number" && Number.isFinite(usage.totalTokens) ? Math.max(0, Math.floor(usage.totalTokens)) : void 0;
797
850
  }
851
+ function usageCostTotal(usage) {
852
+ if (!usage?.cost) return void 0;
853
+ if (typeof usage.cost.total === "number" && Number.isFinite(usage.cost.total)) {
854
+ return Math.max(0, usage.cost.total);
855
+ }
856
+ return [
857
+ usage.cost.input,
858
+ usage.cost.output,
859
+ usage.cost.cacheRead,
860
+ usage.cost.cacheWrite
861
+ ].reduce((sum, value) => {
862
+ const amount = typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : void 0;
863
+ return amount === void 0 ? sum : (sum ?? 0) + amount;
864
+ }, void 0);
865
+ }
866
+ function addUsd(left, right) {
867
+ return Math.round(((left ?? 0) + right) * 1e12) / 1e12;
868
+ }
798
869
  function runDurationSnapshot(run) {
799
870
  return typeof run.cumulativeDurationMs === "number" && Number.isFinite(run.cumulativeDurationMs) ? Math.max(0, Math.floor(run.cumulativeDurationMs)) : void 0;
800
871
  }
801
872
  function runContributions(runs) {
802
- let previousDuration = 0;
803
- let previousTokens = 0;
804
873
  return runs.map((run) => {
805
874
  const duration = runDurationSnapshot(run);
806
875
  const tokens = usageTokenTotal(run.cumulativeUsage);
876
+ const costUsd = usageCostTotal(run.cumulativeUsage);
807
877
  const contribution = {
808
- durationMs: duration === void 0 ? 0 : Math.max(0, duration - previousDuration),
878
+ durationMs: duration ?? 0,
809
879
  run
810
880
  };
811
881
  if (tokens !== void 0) {
812
- contribution.tokens = Math.max(0, tokens - previousTokens);
882
+ contribution.tokens = tokens;
813
883
  }
814
- if (duration !== void 0) {
815
- previousDuration = Math.max(previousDuration, duration);
816
- }
817
- if (tokens !== void 0) {
818
- previousTokens = Math.max(previousTokens, tokens);
884
+ if (costUsd !== void 0) {
885
+ contribution.costUsd = costUsd;
819
886
  }
820
887
  return contribution;
821
888
  });
@@ -835,6 +902,12 @@ function contributionTokenTotal(contributions) {
835
902
  void 0
836
903
  );
837
904
  }
905
+ function contributionCostTotal(contributions) {
906
+ return contributions.reduce(
907
+ (sum, contribution) => contribution.costUsd === void 0 ? sum : addUsd(sum, contribution.costUsd),
908
+ void 0
909
+ );
910
+ }
838
911
  function actorLabel(actor) {
839
912
  const email = actor?.email?.trim() || void 0;
840
913
  const fullName = actor?.fullName?.trim() || void 0;
@@ -860,6 +933,11 @@ function addItemTokens(item, tokens) {
860
933
  item.tokens = (item.tokens ?? 0) + tokens;
861
934
  }
862
935
  }
936
+ function addItemCost(item, costUsd) {
937
+ if (costUsd !== void 0) {
938
+ item.costUsd = addUsd(item.costUsd, costUsd);
939
+ }
940
+ }
863
941
  function statusSignals(runs) {
864
942
  return {
865
943
  active: runs.some((run) => run.status === "active"),
@@ -901,6 +979,7 @@ function buildConversationStatsReport(args) {
901
979
  const actors = /* @__PURE__ */ new Map();
902
980
  const locations = /* @__PURE__ */ new Map();
903
981
  let durationMs = 0;
982
+ let costUsd;
904
983
  let tokens;
905
984
  let active = 0;
906
985
  let failed = 0;
@@ -908,8 +987,10 @@ function buildConversationStatsReport(args) {
908
987
  for (const runs of conversations) {
909
988
  const contributions = runContributions(runs);
910
989
  const conversationSignals = statusSignals(runs);
990
+ const conversationCostUsd = contributionCostTotal(contributions);
911
991
  const conversationTokens = contributionTokenTotal(contributions);
912
992
  durationMs += contributionDurationTotal(contributions);
993
+ costUsd = conversationCostUsd === void 0 ? costUsd : addUsd(costUsd, conversationCostUsd);
913
994
  tokens = addTokenTotal(tokens, conversationTokens);
914
995
  active += conversationSignals.active ? 1 : 0;
915
996
  failed += conversationSignals.failed ? 1 : 0;
@@ -931,6 +1012,7 @@ function buildConversationStatsReport(args) {
931
1012
  item.failed += signals.failed ? 1 : 0;
932
1013
  item.hung += signals.hung ? 1 : 0;
933
1014
  addItemTokens(item, contributionTokenTotal(actorContributions));
1015
+ addItemCost(item, contributionCostTotal(actorContributions));
934
1016
  actors.set(actor, item);
935
1017
  }
936
1018
  const location = locationLabel(newestRun(runs));
@@ -942,6 +1024,7 @@ function buildConversationStatsReport(args) {
942
1024
  locationItem.failed += conversationSignals.failed ? 1 : 0;
943
1025
  locationItem.hung += conversationSignals.hung ? 1 : 0;
944
1026
  addItemTokens(locationItem, conversationTokens);
1027
+ addItemCost(locationItem, conversationCostUsd);
945
1028
  locations.set(location, locationItem);
946
1029
  }
947
1030
  return {
@@ -956,6 +1039,7 @@ function buildConversationStatsReport(args) {
956
1039
  sampleLimit: args.sampleLimit,
957
1040
  sampleSize: args.sampleSize,
958
1041
  source: "conversation_index",
1042
+ ...costUsd !== void 0 ? { costUsd } : {},
959
1043
  ...tokens !== void 0 ? { tokens } : {},
960
1044
  truncated: args.truncated,
961
1045
  runs: conversations.reduce((sum, runs) => sum + runs.length, 0),
@@ -974,9 +1058,15 @@ async function readConversationStatsReport(options = {}) {
974
1058
  });
975
1059
  const truncated = conversations.length > CONVERSATION_STATS_LIMIT;
976
1060
  const sampledConversations = conversations.slice(0, CONVERSATION_STATS_LIMIT);
977
- const summaries = sampledConversations.map(
978
- (conversation) => sessionReportFromConversation(conversation, nowMs)
1061
+ const summariesByConversation = await listAgentTurnSessionSummariesForConversations(
1062
+ sampledConversations.map((conversation) => conversation.conversationId)
979
1063
  );
1064
+ const summaries = sampledConversations.flatMap((conversation) => {
1065
+ const turnSummaries = summariesByConversation.get(conversation.conversationId) ?? [];
1066
+ return turnSummaries.length > 0 ? turnSummaries.map(
1067
+ (summary) => sessionReportFromTurnSummary(conversation, summary, nowMs)
1068
+ ) : [sessionReportFromConversation(conversation, nowMs)];
1069
+ });
980
1070
  return buildConversationStatsReport({
981
1071
  generatedAt,
982
1072
  nowMs,
@@ -3,7 +3,7 @@ import {
3
3
  finalizeFailedTurnReply,
4
4
  processPluginTask,
5
5
  scheduleSessionCompletedPluginTasks
6
- } from "./chunk-XX4N4E6C.js";
6
+ } from "./chunk-P3YFQLEN.js";
7
7
  import "./chunk-KNFROR7R.js";
8
8
  import {
9
9
  coerceThreadArtifactsState,
@@ -13,14 +13,14 @@ import {
13
13
  markTurnFailed,
14
14
  persistThreadStateById,
15
15
  startActiveTurn
16
- } from "./chunk-KDPCGVIT.js";
16
+ } from "./chunk-UKHVMPX5.js";
17
17
  import {
18
18
  coerceThreadConversationState
19
19
  } from "./chunk-RAIB6WSG.js";
20
20
  import {
21
21
  commitMessages,
22
22
  loadProjection
23
- } from "./chunk-WAGQ377B.js";
23
+ } from "./chunk-MNTINMWR.js";
24
24
  import {
25
25
  buildConversationContext,
26
26
  hydrateConversationMessages,
@@ -28,24 +28,24 @@ import {
28
28
  normalizeConversationText,
29
29
  updateConversationStats,
30
30
  upsertConversationMessage
31
- } from "./chunk-CRRBJ3JP.js";
32
- import "./chunk-NSCHU54X.js";
33
- import "./chunk-E3E2XNCN.js";
31
+ } from "./chunk-5C6XTTFI.js";
32
+ import "./chunk-S5KZ5LPG.js";
33
+ import "./chunk-2NAZZPPS.js";
34
34
  import {
35
35
  sleep
36
36
  } from "./chunk-CZEX6KIQ.js";
37
- import "./chunk-6ONME5IG.js";
37
+ import "./chunk-RITD7E5L.js";
38
38
  import {
39
39
  stripRuntimeTurnContext,
40
40
  trimTrailingAssistantMessages
41
- } from "./chunk-GUE7HTNR.js";
41
+ } from "./chunk-YDVEH3SB.js";
42
42
  import "./chunk-GY34VGP5.js";
43
43
  import "./chunk-B7PUBQQM.js";
44
44
  import {
45
45
  logException
46
- } from "./chunk-WPOJ443W.js";
46
+ } from "./chunk-I35CTGPO.js";
47
47
  import "./chunk-OB42YVAE.js";
48
- import "./chunk-3DA7X2U3.js";
48
+ import "./chunk-6GWA276C.js";
49
49
  import "./chunk-7FBGKXPE.js";
50
50
  import "./chunk-MLKGABMK.js";
51
51
 
@@ -1,29 +1,39 @@
1
1
  import {
2
2
  captureException,
3
+ captureMessage,
3
4
  continueTrace,
4
5
  flush,
6
+ getActiveSpan,
5
7
  getClient,
6
8
  getGlobalScope,
9
+ getTraceData,
7
10
  init,
11
+ logger,
8
12
  setTag,
9
13
  setUser,
14
+ spanToJSON,
10
15
  startInactiveSpan,
11
16
  startSpan,
12
17
  vercelAIIntegration,
13
18
  withActiveSpan,
14
19
  withScope,
15
20
  withStreamedSpan
16
- } from "./chunk-3DA7X2U3.js";
21
+ } from "./chunk-6GWA276C.js";
17
22
  import "./chunk-MLKGABMK.js";
18
23
  export {
19
24
  captureException,
25
+ captureMessage,
20
26
  continueTrace,
21
27
  flush,
28
+ getActiveSpan,
22
29
  getClient,
23
30
  getGlobalScope,
31
+ getTraceData,
24
32
  init,
33
+ logger,
25
34
  setTag,
26
35
  setUser,
36
+ spanToJSON,
27
37
  startInactiveSpan,
28
38
  startSpan,
29
39
  vercelAIIntegration,
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  validatePluginEgressCredentialHooks,
3
3
  validatePluginRegistrations
4
- } from "./chunk-AYP4ERVZ.js";
5
- import "./chunk-GVOUCI2O.js";
6
- import "./chunk-WPOJ443W.js";
4
+ } from "./chunk-YDT7SNCN.js";
5
+ import "./chunk-L7CDEIVJ.js";
6
+ import "./chunk-I35CTGPO.js";
7
7
  import "./chunk-OB42YVAE.js";
8
- import "./chunk-3DA7X2U3.js";
8
+ import "./chunk-6GWA276C.js";
9
9
  import "./chunk-6APU57E6.js";
10
10
  import "./chunk-7FBGKXPE.js";
11
11
  import "./chunk-MLKGABMK.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior",
3
- "version": "0.95.0",
3
+ "version": "0.96.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -60,7 +60,7 @@
60
60
  "@logtape/logtape": "^2.1.1",
61
61
  "@modelcontextprotocol/sdk": "1.29.0",
62
62
  "@neondatabase/serverless": "^1.1.0",
63
- "@sentry/node": "10.59.0",
63
+ "@sentry/node": "10.65.0",
64
64
  "@sinclair/typebox": "^0.34.49",
65
65
  "@slack/web-api": "^7.16.0",
66
66
  "@vercel/functions": "^3.6.0",
@@ -79,7 +79,7 @@
79
79
  "pg": "^8.16.3",
80
80
  "yaml": "^2.9.0",
81
81
  "zod": "^4.4.3",
82
- "@sentry/junior-plugin-api": "0.95.0"
82
+ "@sentry/junior-plugin-api": "0.96.0"
83
83
  },
84
84
  "devDependencies": {
85
85
  "@emnapi/core": "^1.10.0",
@@ -96,10 +96,10 @@
96
96
  "typescript": "^6.0.3",
97
97
  "vercel": "^54.4.0",
98
98
  "vitest": "^4.1.7",
99
- "@sentry/junior-github": "0.95.0",
100
- "@sentry/junior-memory": "0.95.0",
101
- "@sentry/junior-testing": "0.0.0",
102
- "@sentry/junior-scheduler": "0.95.0"
99
+ "@sentry/junior-github": "0.96.0",
100
+ "@sentry/junior-scheduler": "0.96.0",
101
+ "@sentry/junior-memory": "0.96.0",
102
+ "@sentry/junior-testing": "0.0.0"
103
103
  },
104
104
  "scripts": {
105
105
  "build": "tsup && tsc -p tsconfig.build.json --emitDeclarationOnly",