@sentry/junior 0.75.0 → 0.76.1

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 (101) hide show
  1. package/README.md +1 -1
  2. package/bin/junior.mjs +4 -66
  3. package/dist/agent-hooks-ZOE7RIED.js +37 -0
  4. package/dist/api-reference.d.ts +2 -0
  5. package/dist/app.js +364 -135
  6. package/dist/build/virtual-config.d.ts +2 -2
  7. package/dist/chat/agent-dispatch/runner.d.ts +2 -0
  8. package/dist/chat/config.d.ts +1 -0
  9. package/dist/chat/credentials/state-adapter-token-store.d.ts +2 -0
  10. package/dist/chat/credentials/user-token-store.d.ts +17 -12
  11. package/dist/chat/db.d.ts +8 -0
  12. package/dist/chat/mcp/auth-store.d.ts +2 -1
  13. package/dist/chat/mcp/oauth.d.ts +2 -1
  14. package/dist/chat/oauth-flow.d.ts +3 -1
  15. package/dist/chat/pi/client.d.ts +15 -7
  16. package/dist/chat/plugins/agent-hooks.d.ts +7 -0
  17. package/dist/chat/plugins/auth/oauth-request.d.ts +11 -7
  18. package/dist/chat/plugins/model.d.ts +9 -0
  19. package/dist/chat/plugins/prompt.d.ts +5 -0
  20. package/dist/chat/plugins/task-callback.d.ts +5 -0
  21. package/dist/chat/plugins/task-message.d.ts +23 -0
  22. package/dist/chat/plugins/task-queue.d.ts +5 -0
  23. package/dist/chat/plugins/task-runner.d.ts +12 -0
  24. package/dist/chat/plugins/task-signing.d.ts +31 -0
  25. package/dist/chat/prompt.d.ts +4 -0
  26. package/dist/chat/requester.d.ts +6 -5
  27. package/dist/chat/respond-helpers.d.ts +2 -0
  28. package/dist/chat/respond.d.ts +4 -2
  29. package/dist/chat/runtime/agent-continue-runner.d.ts +4 -0
  30. package/dist/chat/runtime/reply-executor.d.ts +5 -1
  31. package/dist/chat/runtime/slack-resume.d.ts +10 -2
  32. package/dist/chat/sentry.d.ts +1 -0
  33. package/dist/chat/services/mcp-auth-orchestration.d.ts +2 -1
  34. package/dist/chat/services/plugin-auth-orchestration.d.ts +2 -1
  35. package/dist/chat/services/subscribed-decision.d.ts +2 -2
  36. package/dist/chat/services/turn-session-record.d.ts +11 -7
  37. package/dist/chat/slack/footer.d.ts +1 -1
  38. package/dist/chat/state/turn-session.d.ts +8 -5
  39. package/dist/chat/tools/agent-tools.d.ts +8 -1
  40. package/dist/chat/tools/slack/context.d.ts +2 -2
  41. package/dist/chat/tools/types.d.ts +4 -4
  42. package/dist/chat/vercel-queue-client.d.ts +3 -0
  43. package/dist/{chunk-C3AM4Z4J.js → chunk-2ECJXSVQ.js} +5 -5
  44. package/dist/{chunk-OJODNL2P.js → chunk-4SCWV7TJ.js} +2 -2
  45. package/dist/chunk-4UO6FK4G.js +64 -0
  46. package/dist/{chunk-BNJIEFQC.js → chunk-56TBVRJG.js} +2 -2
  47. package/dist/{chunk-OK4KKR7B.js → chunk-EJN6G5A2.js} +28 -12
  48. package/dist/{chunk-TQ74BATR.js → chunk-FFGXUXMD.js} +435 -111
  49. package/dist/{chunk-XJHDZUGD.js → chunk-JBASI5VV.js} +4 -4
  50. package/dist/chunk-KNFROR7R.js +127 -0
  51. package/dist/{chunk-VNTLUFTY.js → chunk-KOIMO7S3.js} +126 -87
  52. package/dist/chunk-MLKGABMK.js +9 -0
  53. package/dist/{chunk-NPVUAXUE.js → chunk-NFTMTIP3.js} +303 -33
  54. package/dist/chunk-NYKJ3KON.js +1082 -0
  55. package/dist/{chunk-SJHUF3DP.js → chunk-OJ53FYVG.js} +2 -10
  56. package/dist/{chunk-62FUNJYS.js → chunk-Q6XFTRV5.js} +54 -3
  57. package/dist/{chunk-UJ7OTHPO.js → chunk-R6Z5XWY3.js} +12 -670
  58. package/dist/chunk-RV5RYIJW.js +56 -0
  59. package/dist/{chunk-EE6PJWY4.js → chunk-SG5WAA7H.js} +7 -5
  60. package/dist/chunk-ST6YNAXG.js +54 -0
  61. package/dist/{chunk-FCZO7LAR.js → chunk-T77LUIX3.js} +139 -153
  62. package/dist/{chunk-EIYL7I4S.js → chunk-VALUBQ7R.js} +22 -30
  63. package/dist/{chunk-OZSPLAQ4.js → chunk-XBBC6W45.js} +1 -1
  64. package/dist/{chunk-ZNNTSPNF.js → chunk-Y5OFBCBZ.js} +1 -1
  65. package/dist/{chunk-74HO27II.js → chunk-Z4CIQ3EB.js} +5 -1
  66. package/dist/{chunk-2RWFUS5F.js → chunk-ZLMBNBUG.js} +101 -44
  67. package/dist/{chunk-JEELK46E.js → chunk-ZQB37HUX.js} +11 -11
  68. package/dist/cli/chat.js +52 -23
  69. package/dist/cli/check.js +7 -7
  70. package/dist/cli/env.js +4 -53
  71. package/dist/cli/init.js +6 -1
  72. package/dist/cli/main.js +84 -0
  73. package/dist/cli/plugins.js +244 -0
  74. package/dist/cli/run.js +5 -52
  75. package/dist/cli/snapshot-warmup.js +9 -9
  76. package/dist/cli/upgrade.js +167 -48
  77. package/dist/db-7A7PFRGL.js +17 -0
  78. package/dist/deployment.d.ts +1 -0
  79. package/dist/instrumentation.js +14 -18
  80. package/dist/nitro.d.ts +1 -1
  81. package/dist/nitro.js +43 -22
  82. package/dist/plugins-PZMDS7AT.js +15 -0
  83. package/dist/plugins.d.ts +4 -2
  84. package/dist/{registry-NLZFIW23.js → registry-OIPAJU2O.js} +6 -6
  85. package/dist/reporting.js +34 -26
  86. package/dist/{runner-LUQZ5G67.js → runner-7Z4D6AKV.js} +76 -23
  87. package/dist/sentry-4CP5NNQ5.js +31 -0
  88. package/dist/validation-SLA6IGF7.js +15 -0
  89. package/dist/vercel.js +1 -1
  90. package/package.json +8 -7
  91. package/dist/agent-hooks-2HEB4C3Q.js +0 -33
  92. package/dist/chat/conversations/configured.d.ts +0 -7
  93. package/dist/chat/conversations/state.d.ts +0 -4
  94. package/dist/chat/plugins/db.d.ts +0 -31
  95. package/dist/chunk-2KG3PWR4.js +0 -17
  96. package/dist/chunk-D7NFH5GD.js +0 -570
  97. package/dist/chunk-MCMROINU.js +0 -12
  98. package/dist/chunk-WBZ4M5N5.js +0 -59
  99. package/dist/db-A3ILH67H.js +0 -20
  100. package/dist/plugins-OMJKLRJ2.js +0 -13
  101. package/dist/validation-VMCPP3YO.js +0 -15
@@ -25,7 +25,7 @@ export interface SlackReplyFooter {
25
25
  items: SlackReplyFooterItem[];
26
26
  }
27
27
  /**
28
- * Build the compact conversation footer for the finalized Slack reply.
28
+ * Build the compact conversation footer for visible Slack reply surfaces.
29
29
  *
30
30
  * Detailed turn metrics stay in the dashboard instead of Slack-visible copy.
31
31
  */
@@ -1,6 +1,6 @@
1
- import type { Destination } from "@sentry/junior-plugin-api";
1
+ import { type Destination, type Source } from "@sentry/junior-plugin-api";
2
2
  import type { PiMessage } from "@/chat/pi/messages";
3
- import { type StoredSlackRequester } from "@/chat/requester";
3
+ import { type Requester } from "@/chat/requester";
4
4
  import type { AgentTurnUsage } from "@/chat/usage";
5
5
  import type { ConversationStore } from "@/chat/conversations/store";
6
6
  export type AgentTurnSessionStatus = "running" | "awaiting_resume" | "completed" | "failed" | "abandoned";
@@ -13,11 +13,12 @@ export interface AgentTurnSessionRecord {
13
13
  cumulativeDurationMs: number;
14
14
  cumulativeUsage?: AgentTurnUsage;
15
15
  destination?: Destination;
16
+ source?: Source;
16
17
  errorMessage?: string;
17
18
  lastProgressAtMs: number;
18
19
  loadedSkillNames?: string[];
19
20
  piMessages: PiMessage[];
20
- requester?: StoredSlackRequester;
21
+ requester?: Requester;
21
22
  resumeReason?: AgentTurnResumeReason;
22
23
  resumedFromSliceId?: number;
23
24
  sessionId: string;
@@ -39,6 +40,7 @@ export declare function upsertAgentTurnSessionRecord(args: {
39
40
  cumulativeDurationMs?: number;
40
41
  cumulativeUsage?: AgentTurnUsage;
41
42
  destination?: Destination;
43
+ source?: Source;
42
44
  lastProgressAtMs?: number;
43
45
  loadedSkillNames?: string[];
44
46
  conversationStore?: ConversationStore;
@@ -47,7 +49,7 @@ export declare function upsertAgentTurnSessionRecord(args: {
47
49
  state: AgentTurnSessionStatus;
48
50
  surface?: AgentTurnSurface;
49
51
  piMessages: PiMessage[];
50
- requester?: StoredSlackRequester;
52
+ requester?: Requester;
51
53
  resumeReason?: AgentTurnResumeReason;
52
54
  errorMessage?: string;
53
55
  resumedFromSliceId?: number;
@@ -62,10 +64,11 @@ export declare function recordAgentTurnSessionSummary(args: {
62
64
  cumulativeDurationMs?: number;
63
65
  cumulativeUsage?: AgentTurnUsage;
64
66
  destination?: Destination;
67
+ source?: Source;
65
68
  lastProgressAtMs?: number;
66
69
  loadedSkillNames?: string[];
67
70
  conversationStore?: ConversationStore;
68
- requester?: StoredSlackRequester;
71
+ requester?: Requester;
69
72
  resumeReason?: AgentTurnResumeReason;
70
73
  sessionId: string;
71
74
  sliceId: number;
@@ -7,5 +7,12 @@ import type { SandboxExecutor } from "@/chat/sandbox/sandbox";
7
7
  import type { SkillSandbox } from "@/chat/sandbox/skill-sandbox";
8
8
  import type { ToolDefinition } from "@/chat/tools/definition";
9
9
  import type { PluginHookRunner } from "@/chat/plugins/agent-hooks";
10
+ export interface ToolExecutionReport {
11
+ error?: string;
12
+ ok: boolean;
13
+ params: Record<string, unknown>;
14
+ result?: unknown;
15
+ toolName: string;
16
+ }
10
17
  /** Wrap tool definitions into Pi Agent tool objects with logging, validation, and sandbox execution. */
11
- export declare function createAgentTools(tools: Record<string, ToolDefinition<any>>, sandbox: SkillSandbox, spanContext: LogContext, onStatus?: (status: AssistantStatusSpec) => void | Promise<void>, sandboxExecutor?: SandboxExecutor, pluginAuthOrchestration?: PluginAuthOrchestration, onToolCall?: (toolName: string, params: Record<string, unknown>) => void, agentHooks?: PluginHookRunner, conversationPrivacy?: ConversationPrivacy): AgentTool[];
18
+ export declare function createAgentTools(tools: Record<string, ToolDefinition<any>>, sandbox: SkillSandbox, spanContext: LogContext, onStatus?: (status: AssistantStatusSpec) => void | Promise<void>, sandboxExecutor?: SandboxExecutor, pluginAuthOrchestration?: PluginAuthOrchestration, onToolCall?: (toolName: string, params: Record<string, unknown>) => void | Promise<void>, agentHooks?: PluginHookRunner, conversationPrivacy?: ConversationPrivacy, onToolResult?: (report: ToolExecutionReport) => void | Promise<void>): AgentTool[];
@@ -3,10 +3,10 @@ import type { SlackDestination } from "@sentry/junior-plugin-api";
3
3
  import type { SlackSource } from "@sentry/junior-plugin-api";
4
4
  import type { SlackRequester } from "@/chat/requester";
5
5
  export interface SlackToolContext {
6
- destination?: SlackDestination;
6
+ destination: SlackDestination;
7
7
  source: SlackSource;
8
8
  requester?: SlackRequester;
9
- destinationChannelId?: string;
9
+ destinationChannelId: string;
10
10
  messageTs?: string;
11
11
  sourceChannelId: string;
12
12
  teamId: string;
@@ -44,8 +44,8 @@ interface BaseToolRuntimeContext {
44
44
  * Do not parse as Slack unless the value starts with `slack:`.
45
45
  */
46
46
  conversationId?: string;
47
- /** Runtime-owned default outbound destination, if this invocation has one. */
48
- destination?: Destination;
47
+ /** Runtime-owned default outbound destination for this invocation. */
48
+ destination: Destination;
49
49
  requester?: Requester;
50
50
  /** Runtime-owned source where this invocation came from. */
51
51
  source: Source;
@@ -58,12 +58,12 @@ interface BaseToolRuntimeContext {
58
58
  sandbox: SandboxWorkspace;
59
59
  }
60
60
  interface SlackToolRuntimeContext extends BaseToolRuntimeContext {
61
- destination?: SlackDestination;
61
+ destination: SlackDestination;
62
62
  requester?: SlackRequester;
63
63
  source: SlackSource;
64
64
  }
65
65
  interface LocalToolRuntimeContext extends BaseToolRuntimeContext {
66
- destination?: LocalDestination;
66
+ destination: LocalDestination;
67
67
  requester?: LocalRequester;
68
68
  source: LocalSource;
69
69
  slack?: never;
@@ -0,0 +1,3 @@
1
+ import { QueueClient } from "@vercel/queue";
2
+ /** Create a Vercel Queue client that also works in local and eval runtimes. */
3
+ export declare function createVercelQueueClient(): QueueClient;
@@ -1,10 +1,10 @@
1
+ import {
2
+ createVercelQueueClient
3
+ } from "./chunk-KNFROR7R.js";
1
4
  import {
2
5
  destinationKey,
3
6
  parseDestination
4
- } from "./chunk-WBZ4M5N5.js";
5
-
6
- // src/chat/task-execution/vercel-queue.ts
7
- import { QueueClient } from "@vercel/queue";
7
+ } from "./chunk-Q6XFTRV5.js";
8
8
 
9
9
  // src/chat/task-execution/queue-signing.ts
10
10
  import { createHmac, timingSafeEqual } from "crypto";
@@ -108,7 +108,7 @@ function toDelaySeconds(options) {
108
108
  }
109
109
  function createVercelConversationWorkQueue(options = {}) {
110
110
  const topic = resolveConversationWorkQueueTopic(options);
111
- const client = options.client ?? new QueueClient();
111
+ const client = options.client ?? createVercelQueueClient();
112
112
  return {
113
113
  async send(message, sendOptions) {
114
114
  const result = await client.send(
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  getPluginForSkillPath,
3
3
  getPluginSkillRoots
4
- } from "./chunk-2RWFUS5F.js";
4
+ } from "./chunk-ZLMBNBUG.js";
5
5
  import {
6
6
  skillRoots
7
7
  } from "./chunk-Q3XNY442.js";
8
8
  import {
9
9
  logWarn
10
- } from "./chunk-OK4KKR7B.js";
10
+ } from "./chunk-EJN6G5A2.js";
11
11
 
12
12
  // src/chat/skills.ts
13
13
  import fs from "fs/promises";
@@ -0,0 +1,64 @@
1
+ // src/cli/run.ts
2
+ var CLI_USAGE = "usage: junior init <dir>\n junior snapshot create\n junior check [dir]\n junior upgrade\n junior chat\n junior chat -p <message>";
3
+ var DEFAULT_IO = {
4
+ error: console.error
5
+ };
6
+ function normalizeCliArgv(argv) {
7
+ return argv[0] === "--" ? argv.slice(1) : argv;
8
+ }
9
+ async function runCli(argv, handlers, io = DEFAULT_IO) {
10
+ const [command, subcommand, ...rest] = normalizeCliArgv(argv);
11
+ if (command === "chat") {
12
+ return await handlers.runChat(
13
+ subcommand === void 0 ? [] : [subcommand, ...rest]
14
+ );
15
+ }
16
+ if (command === "init") {
17
+ if (!subcommand || rest.length > 0) {
18
+ io.error(CLI_USAGE);
19
+ return 1;
20
+ }
21
+ await handlers.runInit(subcommand);
22
+ return 0;
23
+ }
24
+ if (command === "snapshot" && subcommand === "create") {
25
+ if (rest.length > 0) {
26
+ io.error(CLI_USAGE);
27
+ return 1;
28
+ }
29
+ await handlers.runSnapshotCreate();
30
+ return 0;
31
+ }
32
+ if (command === "check") {
33
+ if (rest.length > 0) {
34
+ io.error(CLI_USAGE);
35
+ return 1;
36
+ }
37
+ await handlers.runCheck(subcommand);
38
+ return 0;
39
+ }
40
+ if (command === "upgrade") {
41
+ if (subcommand || rest.length > 0) {
42
+ io.error(CLI_USAGE);
43
+ return 1;
44
+ }
45
+ await handlers.runUpgrade();
46
+ return 0;
47
+ }
48
+ if (command && handlers.runPluginCommand) {
49
+ const exitCode = await handlers.runPluginCommand(
50
+ command,
51
+ subcommand === void 0 ? [] : [subcommand, ...rest]
52
+ );
53
+ if (exitCode !== void 0) {
54
+ return exitCode;
55
+ }
56
+ }
57
+ io.error(CLI_USAGE);
58
+ return 1;
59
+ }
60
+
61
+ export {
62
+ CLI_USAGE,
63
+ runCli
64
+ };
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  getStateAdapter
3
- } from "./chunk-ZNNTSPNF.js";
3
+ } from "./chunk-Y5OFBCBZ.js";
4
4
  import {
5
5
  logException,
6
6
  logInfo,
7
7
  logWarn
8
- } from "./chunk-OK4KKR7B.js";
8
+ } from "./chunk-EJN6G5A2.js";
9
9
 
10
10
  // src/chat/plugins/logging.ts
11
11
  function createPluginLogger(plugin) {
@@ -1,7 +1,14 @@
1
1
  import {
2
- getDeploymentTelemetryAttributes,
3
- sentry_exports
4
- } from "./chunk-SJHUF3DP.js";
2
+ getDeploymentTelemetryAttributes
3
+ } from "./chunk-OJ53FYVG.js";
4
+ import {
5
+ captureException,
6
+ sentry_exports,
7
+ setTag,
8
+ setUser,
9
+ startSpan,
10
+ withScope
11
+ } from "./chunk-ST6YNAXG.js";
5
12
 
6
13
  // src/chat/logging.ts
7
14
  import { AsyncLocalStorage } from "async_hooks";
@@ -887,8 +894,8 @@ var log = {
887
894
  body ?? normalizedError.message
888
895
  );
889
896
  let eventId;
890
- const sentryWithScope = sentry_exports.withScope;
891
- const sentryCaptureException = sentry_exports.captureException;
897
+ const sentryWithScope = withScope;
898
+ const sentryCaptureException = captureException;
892
899
  if (typeof sentryWithScope === "function" && typeof sentryCaptureException === "function") {
893
900
  sentryWithScope((scope) => {
894
901
  if (context) {
@@ -1032,7 +1039,7 @@ function setSentryTagsFromContext(context) {
1032
1039
  continue;
1033
1040
  }
1034
1041
  if (typeof value === "string" && value.length > 0) {
1035
- sentry_exports.setTag(key, value);
1042
+ setTag(key, value);
1036
1043
  }
1037
1044
  }
1038
1045
  }
@@ -1056,7 +1063,7 @@ function sentryUserFromIdentity(identity) {
1056
1063
  }
1057
1064
  function setSentryUser(identity) {
1058
1065
  if (!identity) return;
1059
- sentry_exports.setUser(sentryUserFromIdentity(identity));
1066
+ setUser(sentryUserFromIdentity(identity));
1060
1067
  }
1061
1068
  function setSentryScopeContext(scope, context) {
1062
1069
  const attrs = contextToAttributes(context);
@@ -1133,7 +1140,7 @@ async function withSpan(name, op, context, callback, attributes = {}) {
1133
1140
  const normalizedAttributes = normalizeSpanAttributes(attributes);
1134
1141
  return withLogContext(context, () => {
1135
1142
  const inheritedAttributes = getLogContextAttributes();
1136
- return sentry_exports.startSpan(
1143
+ return startSpan(
1137
1144
  {
1138
1145
  name,
1139
1146
  op,
@@ -1208,8 +1215,7 @@ var TURN_FAILURE_RESPONSE_TEMPLATE = "I ran into an internal error while process
1208
1215
  function buildTurnFailureResponse(eventId) {
1209
1216
  return TURN_FAILURE_RESPONSE_TEMPLATE.replace("{eventId}", eventId);
1210
1217
  }
1211
- var GEN_AI_DEFAULT_MAX_ATTRIBUTE_CHARS = 12e3;
1212
- var GEN_AI_MAX_STRING_CHARS = 2e3;
1218
+ var GEN_AI_DEFAULT_MAX_ATTRIBUTE_CHARS = 1e5;
1213
1219
  var GEN_AI_MAX_ARRAY_ITEMS = 50;
1214
1220
  var GEN_AI_MAX_OBJECT_KEYS = 50;
1215
1221
  function truncateGenAiString(value, maxChars) {
@@ -1224,7 +1230,7 @@ function sanitizeGenAiValue(value, seen, depth, keyName) {
1224
1230
  if (shouldTreatAsBlob) {
1225
1231
  return `[omitted:${value.length}]`;
1226
1232
  }
1227
- return truncateGenAiString(redactSecrets(value), GEN_AI_MAX_STRING_CHARS);
1233
+ return redactSecrets(value);
1228
1234
  }
1229
1235
  if (typeof value === "number") {
1230
1236
  return Number.isFinite(value) ? value : void 0;
@@ -1340,6 +1346,14 @@ function extractGenAiUsageAttributes(...sources) {
1340
1346
  };
1341
1347
  }
1342
1348
 
1349
+ // src/chat/slack/ids.ts
1350
+ function isSlackTeamId(value) {
1351
+ return /^T[A-Z0-9]+$/.test(value);
1352
+ }
1353
+ function isSlackConversationId(value) {
1354
+ return /^(C|G|D)[A-Z0-9]+$/.test(value);
1355
+ }
1356
+
1343
1357
  export {
1344
1358
  toOptionalString,
1345
1359
  toOptionalNumber,
@@ -1363,5 +1377,7 @@ export {
1363
1377
  buildTurnFailureResponse,
1364
1378
  serializeGenAiAttribute,
1365
1379
  extractGenAiUsageSummary,
1366
- extractGenAiUsageAttributes
1380
+ extractGenAiUsageAttributes,
1381
+ isSlackTeamId,
1382
+ isSlackConversationId
1367
1383
  };