@sentry/junior 0.74.0 → 0.75.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 (73) hide show
  1. package/dist/agent-hooks-2HEB4C3Q.js +33 -0
  2. package/dist/api-reference.d.ts +1 -1
  3. package/dist/app.js +5211 -5316
  4. package/dist/build/copy-build-content.d.ts +1 -1
  5. package/dist/chat/agent-dispatch/context.d.ts +2 -3
  6. package/dist/chat/agent-dispatch/types.d.ts +2 -1
  7. package/dist/chat/config.d.ts +2 -0
  8. package/dist/chat/conversations/configured.d.ts +2 -0
  9. package/dist/chat/credentials/subject.d.ts +3 -3
  10. package/dist/chat/plugins/agent-hooks.d.ts +13 -13
  11. package/dist/chat/plugins/credential-hooks.d.ts +6 -6
  12. package/dist/chat/plugins/db.d.ts +31 -0
  13. package/dist/chat/plugins/logging.d.ts +2 -2
  14. package/dist/chat/plugins/package-discovery.d.ts +2 -1
  15. package/dist/chat/plugins/registry.d.ts +4 -0
  16. package/dist/chat/plugins/state.d.ts +3 -5
  17. package/dist/chat/plugins/types.d.ts +1 -0
  18. package/dist/chat/plugins/validation.d.ts +5 -0
  19. package/dist/chat/prompt.d.ts +11 -1
  20. package/dist/chat/respond.d.ts +10 -1
  21. package/dist/chat/runtime/slack-runtime.d.ts +6 -1
  22. package/dist/chat/sandbox/egress-credentials.d.ts +8 -8
  23. package/dist/chat/sandbox/sandbox.d.ts +2 -2
  24. package/dist/chat/sql/db.d.ts +3 -0
  25. package/dist/chat/sql/executor.d.ts +7 -0
  26. package/dist/chat/sql/neon.d.ts +2 -4
  27. package/dist/chat/sql/postgres.d.ts +6 -0
  28. package/dist/chat/task-execution/state.d.ts +7 -2
  29. package/dist/chat/task-execution/worker.d.ts +1 -1
  30. package/dist/chat/tools/agent-tools.d.ts +2 -2
  31. package/dist/chat/tools/types.d.ts +3 -0
  32. package/dist/{chunk-7Q5YOUUT.js → chunk-2RWFUS5F.js} +47 -10
  33. package/dist/{chunk-YRDS7VKO.js → chunk-62FUNJYS.js} +3 -54
  34. package/dist/{chunk-M4FLLXXD.js → chunk-74HO27II.js} +1 -1
  35. package/dist/chunk-BNJIEFQC.js +115 -0
  36. package/dist/{chunk-YOHFWWBV.js → chunk-C3AM4Z4J.js} +1 -103
  37. package/dist/chunk-D7NFH5GD.js +570 -0
  38. package/dist/chunk-EE6PJWY4.js +130 -0
  39. package/dist/{chunk-CYUI7JU5.js → chunk-EIYL7I4S.js} +1 -1
  40. package/dist/{chunk-GM7HTXYC.js → chunk-FCZO7LAR.js} +13 -2
  41. package/dist/{chunk-2LUZA3LY.js → chunk-JEELK46E.js} +5 -5
  42. package/dist/chunk-MCMROINU.js +12 -0
  43. package/dist/chunk-NPVUAXUE.js +694 -0
  44. package/dist/{chunk-OR6NQJ5E.js → chunk-OJODNL2P.js} +3 -3
  45. package/dist/{chunk-3BYAPS6B.js → chunk-OK4KKR7B.js} +1 -11
  46. package/dist/chunk-OZSPLAQ4.js +71 -0
  47. package/dist/{chunk-KVZL5NZS.js → chunk-Q3XNY442.js} +17 -7
  48. package/dist/{chunk-SQGMG7OD.js → chunk-TQ74BATR.js} +100 -58
  49. package/dist/{chunk-JL2SLRAT.js → chunk-UJ7OTHPO.js} +76 -312
  50. package/dist/{chunk-HYHKTFG2.js → chunk-VNTLUFTY.js} +80 -843
  51. package/dist/chunk-WBZ4M5N5.js +59 -0
  52. package/dist/{chunk-6UP2Z2RZ.js → chunk-XJHDZUGD.js} +7 -7
  53. package/dist/chunk-Y2CM7HXH.js +111 -0
  54. package/dist/{chunk-F6HWCPOC.js → chunk-ZNNTSPNF.js} +1 -1
  55. package/dist/cli/chat.js +52 -2
  56. package/dist/cli/check.js +6 -5
  57. package/dist/cli/snapshot-warmup.js +10 -9
  58. package/dist/cli/upgrade.js +256 -16
  59. package/dist/db-A3ILH67H.js +20 -0
  60. package/dist/handlers/sandbox-egress-route.d.ts +4 -0
  61. package/dist/handlers/slack-webhook.d.ts +4 -0
  62. package/dist/handlers/webhooks.d.ts +6 -13
  63. package/dist/nitro.js +34 -89
  64. package/dist/plugin-module.d.ts +21 -0
  65. package/dist/plugins-OMJKLRJ2.js +13 -0
  66. package/dist/plugins.d.ts +6 -4
  67. package/dist/registry-NLZFIW23.js +46 -0
  68. package/dist/reporting/conversations.d.ts +3 -3
  69. package/dist/reporting.d.ts +6 -5
  70. package/dist/reporting.js +23 -17
  71. package/dist/{runner-27NP2TEO.js → runner-LUQZ5G67.js} +18 -13
  72. package/dist/validation-VMCPP3YO.js +15 -0
  73. package/package.json +11 -9
@@ -1,11 +1,9 @@
1
1
  import {
2
2
  getSlackBotToken
3
- } from "./chunk-GM7HTXYC.js";
3
+ } from "./chunk-FCZO7LAR.js";
4
4
  import {
5
- isSlackConversationId,
6
- isSlackTeamId,
7
5
  logWarn
8
- } from "./chunk-3BYAPS6B.js";
6
+ } from "./chunk-OK4KKR7B.js";
9
7
 
10
8
  // src/chat/slack/client.ts
11
9
  import { WebClient } from "@slack/web-api";
@@ -276,50 +274,6 @@ async function downloadPrivateSlackFile(url) {
276
274
  return Buffer.from(await response.arrayBuffer());
277
275
  }
278
276
 
279
- // src/chat/destination.ts
280
- import {
281
- destinationSchema
282
- } from "@sentry/junior-plugin-api";
283
- function createSlackDestination(input) {
284
- const channelId = normalizeSlackConversationId(input.channelId);
285
- const teamId = input.teamId?.trim();
286
- if (!channelId || !teamId) {
287
- return void 0;
288
- }
289
- if (!isSlackConversationId(channelId) || !isSlackTeamId(teamId)) {
290
- return void 0;
291
- }
292
- return { platform: "slack", teamId, channelId };
293
- }
294
- function parseDestination(value) {
295
- const parsed = destinationSchema.safeParse(value);
296
- return parsed.success ? parsed.data : void 0;
297
- }
298
- function requireSlackDestination(destination, action) {
299
- if (destination?.platform === "slack") {
300
- return destination;
301
- }
302
- throw new Error(`${action} requires a Slack destination`);
303
- }
304
- function sameDestination(left, right) {
305
- if (left.platform !== right.platform) {
306
- return false;
307
- }
308
- if (left.platform === "local" && right.platform === "local") {
309
- return left.conversationId === right.conversationId;
310
- }
311
- if (left.platform === "slack" && right.platform === "slack") {
312
- return left.teamId === right.teamId && left.channelId === right.channelId;
313
- }
314
- return false;
315
- }
316
- function destinationKey(destination) {
317
- if (destination.platform === "local") {
318
- return destination.conversationId;
319
- }
320
- return `slack:${destination.teamId}:${destination.channelId}`;
321
- }
322
-
323
277
  export {
324
278
  SlackActionError,
325
279
  getHeaderString,
@@ -330,10 +284,5 @@ export {
330
284
  isConversationScopedChannel,
331
285
  isConversationChannel,
332
286
  getFilePermalink,
333
- downloadPrivateSlackFile,
334
- createSlackDestination,
335
- parseDestination,
336
- requireSlackDestination,
337
- sameDestination,
338
- destinationKey
287
+ downloadPrivateSlackFile
339
288
  };
@@ -2,7 +2,7 @@ import {
2
2
  isRecord,
3
3
  toOptionalNumber,
4
4
  toOptionalString
5
- } from "./chunk-3BYAPS6B.js";
5
+ } from "./chunk-OK4KKR7B.js";
6
6
 
7
7
  // src/chat/state/conversation.ts
8
8
  function coerceRole(value) {
@@ -0,0 +1,115 @@
1
+ import {
2
+ getStateAdapter
3
+ } from "./chunk-ZNNTSPNF.js";
4
+ import {
5
+ logException,
6
+ logInfo,
7
+ logWarn
8
+ } from "./chunk-OK4KKR7B.js";
9
+
10
+ // src/chat/plugins/logging.ts
11
+ function createPluginLogger(plugin) {
12
+ return {
13
+ info(message, metadata) {
14
+ logInfo(
15
+ "agent_plugin_log_info",
16
+ {},
17
+ { "app.plugin.name": plugin, ...metadata },
18
+ message
19
+ );
20
+ },
21
+ warn(message, metadata) {
22
+ logWarn(
23
+ "agent_plugin_log_warn",
24
+ {},
25
+ { "app.plugin.name": plugin, ...metadata },
26
+ message
27
+ );
28
+ },
29
+ error(message, metadata) {
30
+ logException(
31
+ new Error(message),
32
+ "agent_plugin_log_error",
33
+ {},
34
+ { "app.plugin.name": plugin, ...metadata },
35
+ message
36
+ );
37
+ }
38
+ };
39
+ }
40
+
41
+ // src/chat/plugins/state.ts
42
+ import { createHash } from "crypto";
43
+ var MAX_PLUGIN_STATE_KEY_LENGTH = 512;
44
+ function hashKeyPart(value) {
45
+ return createHash("sha256").update(value).digest("hex").slice(0, 32);
46
+ }
47
+ function pluginStateKey(plugin, key) {
48
+ const pluginPrefix = `junior:${plugin}`;
49
+ if (key === pluginPrefix || key.startsWith(`${pluginPrefix}:`)) {
50
+ return key;
51
+ }
52
+ return `junior:plugin_state:${hashKeyPart(plugin)}:${hashKeyPart(key)}`;
53
+ }
54
+ function validatePluginStateKey(key) {
55
+ if (!key.trim()) {
56
+ throw new Error("Plugin state key is required");
57
+ }
58
+ if (key.length > MAX_PLUGIN_STATE_KEY_LENGTH) {
59
+ throw new Error("Plugin state key exceeds the maximum length");
60
+ }
61
+ }
62
+ function createPluginState(plugin, adapter) {
63
+ const getAdapter = () => adapter ?? getStateAdapter();
64
+ return {
65
+ async delete(key) {
66
+ validatePluginStateKey(key);
67
+ const state = getAdapter();
68
+ await state.connect();
69
+ await state.delete(pluginStateKey(plugin, key));
70
+ },
71
+ async get(key) {
72
+ validatePluginStateKey(key);
73
+ const state = getAdapter();
74
+ await state.connect();
75
+ const value = await state.get(pluginStateKey(plugin, key));
76
+ return value ?? void 0;
77
+ },
78
+ async set(key, value, ttlMs) {
79
+ validatePluginStateKey(key);
80
+ const state = getAdapter();
81
+ await state.connect();
82
+ await state.set(pluginStateKey(plugin, key), value, ttlMs);
83
+ },
84
+ async setIfNotExists(key, value, ttlMs) {
85
+ validatePluginStateKey(key);
86
+ const state = getAdapter();
87
+ await state.connect();
88
+ return await state.setIfNotExists(
89
+ pluginStateKey(plugin, key),
90
+ value,
91
+ ttlMs
92
+ );
93
+ },
94
+ async withLock(key, ttlMs, callback) {
95
+ validatePluginStateKey(key);
96
+ const state = getAdapter();
97
+ await state.connect();
98
+ const lockKey = pluginStateKey(plugin, key);
99
+ const lock = await state.acquireLock(lockKey, ttlMs);
100
+ if (!lock) {
101
+ throw new Error(`Could not acquire plugin state lock for ${key}`);
102
+ }
103
+ try {
104
+ return await callback();
105
+ } finally {
106
+ await state.releaseLock(lock);
107
+ }
108
+ }
109
+ };
110
+ }
111
+
112
+ export {
113
+ createPluginLogger,
114
+ createPluginState
115
+ };
@@ -1,106 +1,7 @@
1
1
  import {
2
2
  destinationKey,
3
3
  parseDestination
4
- } from "./chunk-YRDS7VKO.js";
5
-
6
- // src/plugins.ts
7
- function cloneManifests(manifests) {
8
- return manifests ? structuredClone(manifests) : void 0;
9
- }
10
- function cloneInlineManifests(registrations) {
11
- const inlineManifests = registrations.flatMap(
12
- (plugin) => plugin.manifest ? [
13
- {
14
- manifest: {
15
- ...structuredClone(plugin.manifest),
16
- capabilities: plugin.manifest.capabilities?.map(
17
- (capability) => capability.includes(".") ? capability : `${plugin.manifest.name}.${capability}`
18
- ) ?? [],
19
- configKeys: plugin.manifest.configKeys?.map(
20
- (key) => key.includes(".") ? key : `${plugin.manifest.name}.${key}`
21
- ) ?? [],
22
- ...plugin.manifest.target ? {
23
- target: {
24
- ...plugin.manifest.target,
25
- configKey: plugin.manifest.target.configKey.includes(".") ? plugin.manifest.target.configKey : `${plugin.manifest.name}.${plugin.manifest.target.configKey}`
26
- }
27
- } : {}
28
- },
29
- ...plugin.packageName ? { packageName: plugin.packageName } : {}
30
- }
31
- ] : []
32
- );
33
- return inlineManifests.length > 0 ? inlineManifests : void 0;
34
- }
35
- function assertUniquePluginNames(registrations) {
36
- const seen = /* @__PURE__ */ new Set();
37
- for (const plugin of registrations) {
38
- if (seen.has(plugin.name)) {
39
- throw new Error(`Duplicate plugin registration name "${plugin.name}"`);
40
- }
41
- seen.add(plugin.name);
42
- }
43
- }
44
- function assertUniquePackageNames(packageNames) {
45
- const seen = /* @__PURE__ */ new Set();
46
- for (const packageName of packageNames) {
47
- if (seen.has(packageName)) {
48
- throw new Error(`Duplicate plugin package name "${packageName}"`);
49
- }
50
- seen.add(packageName);
51
- }
52
- }
53
- function normalizePluginInput(input) {
54
- if (typeof input === "string") {
55
- return { packageName: input };
56
- }
57
- return { registration: input };
58
- }
59
- function defineJuniorPlugins(inputs, options = {}) {
60
- const normalized = inputs.map(normalizePluginInput);
61
- const packageNames = normalized.flatMap(
62
- (input) => input.packageName ? [input.packageName] : []
63
- );
64
- const registrations = normalized.flatMap(
65
- (input) => input.registration ? [input.registration] : []
66
- );
67
- assertUniquePackageNames(packageNames);
68
- assertUniquePluginNames(registrations);
69
- const manifests = cloneManifests(options.manifests);
70
- return {
71
- packageNames,
72
- registrations: registrations.map((plugin) => ({ ...plugin })),
73
- ...manifests ? { manifests } : {}
74
- };
75
- }
76
- function pluginCatalogConfigFromPluginSet(pluginSet) {
77
- if (!pluginSet) {
78
- return void 0;
79
- }
80
- const packages = [
81
- .../* @__PURE__ */ new Set([
82
- ...pluginSet.packageNames,
83
- ...pluginSet.registrations.flatMap(
84
- (plugin) => plugin.packageName ? [plugin.packageName] : []
85
- )
86
- ])
87
- ];
88
- const manifests = cloneManifests(pluginSet.manifests);
89
- const inlineManifests = cloneInlineManifests(pluginSet.registrations);
90
- if (packages.length === 0 && !manifests && !inlineManifests) {
91
- return void 0;
92
- }
93
- return {
94
- ...inlineManifests ? { inlineManifests } : {},
95
- ...packages.length > 0 ? { packages } : {},
96
- ...manifests ? { manifests } : {}
97
- };
98
- }
99
- function pluginHookRegistrationsFromPluginSet(pluginSet) {
100
- return pluginSet?.registrations.filter(
101
- (plugin) => plugin.hooks || plugin.legacyStatePrefixes
102
- ) ?? [];
103
- }
4
+ } from "./chunk-WBZ4M5N5.js";
104
5
 
105
6
  // src/chat/task-execution/vercel-queue.ts
106
7
  import { QueueClient } from "@vercel/queue";
@@ -229,9 +130,6 @@ function getVercelConversationWorkQueue() {
229
130
  }
230
131
 
231
132
  export {
232
- defineJuniorPlugins,
233
- pluginCatalogConfigFromPluginSet,
234
- pluginHookRegistrationsFromPluginSet,
235
133
  verifyConversationQueueMessage,
236
134
  resolveConversationWorkQueueTopic,
237
135
  getVercelConversationWorkQueue