@sentry/junior 0.68.0 → 0.70.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 (67) hide show
  1. package/dist/app.js +1779 -746
  2. package/dist/build/virtual-config.d.ts +2 -2
  3. package/dist/chat/agent-dispatch/heartbeat.d.ts +2 -2
  4. package/dist/chat/agent-dispatch/store.d.ts +4 -1
  5. package/dist/chat/agent-dispatch/types.d.ts +2 -4
  6. package/dist/chat/agent-dispatch/validation.d.ts +3 -2
  7. package/dist/chat/credentials/context.d.ts +49 -24
  8. package/dist/chat/credentials/user-token-store.d.ts +6 -0
  9. package/dist/chat/destination.d.ts +12 -0
  10. package/dist/chat/ingress/message-router.d.ts +1 -1
  11. package/dist/chat/mcp/auth-store.d.ts +2 -0
  12. package/dist/chat/mcp/oauth.d.ts +2 -0
  13. package/dist/chat/oauth-flow.d.ts +7 -0
  14. package/dist/chat/plugins/agent-hooks.d.ts +9 -9
  15. package/dist/chat/plugins/auth/auth-token-placeholder.d.ts +2 -2
  16. package/dist/chat/plugins/auth/oauth-request.d.ts +3 -1
  17. package/dist/chat/plugins/credential-hooks.d.ts +53 -0
  18. package/dist/chat/plugins/logging.d.ts +1 -1
  19. package/dist/chat/plugins/state.d.ts +1 -1
  20. package/dist/chat/plugins/types.d.ts +19 -23
  21. package/dist/chat/respond.d.ts +2 -0
  22. package/dist/chat/runtime/reply-executor.d.ts +3 -1
  23. package/dist/chat/runtime/slack-runtime.d.ts +8 -3
  24. package/dist/chat/sandbox/egress-credentials.d.ts +34 -0
  25. package/dist/chat/sandbox/egress-schemas.d.ts +105 -0
  26. package/dist/chat/sandbox/egress-session.d.ts +17 -17
  27. package/dist/chat/sandbox/sandbox.d.ts +3 -0
  28. package/dist/chat/sandbox/session.d.ts +1 -0
  29. package/dist/chat/services/mcp-auth-orchestration.d.ts +2 -0
  30. package/dist/chat/services/pending-auth.d.ts +2 -0
  31. package/dist/chat/services/plugin-auth-orchestration.d.ts +2 -0
  32. package/dist/chat/services/provider-retry.d.ts +13 -4
  33. package/dist/chat/services/timeout-resume.d.ts +2 -0
  34. package/dist/chat/services/turn-session-record.d.ts +6 -0
  35. package/dist/chat/slack/attachment-fetchers.d.ts +11 -0
  36. package/dist/chat/state/conversation-details.d.ts +46 -0
  37. package/dist/chat/state/conversation.d.ts +1 -0
  38. package/dist/chat/state/turn-session.d.ts +4 -3
  39. package/dist/chat/task-execution/queue.d.ts +2 -0
  40. package/dist/chat/task-execution/store.d.ts +5 -0
  41. package/dist/chat/task-execution/vercel-callback.d.ts +4 -0
  42. package/dist/chat/task-execution/vercel-queue.d.ts +2 -0
  43. package/dist/chat/task-execution/worker.d.ts +4 -2
  44. package/dist/chat/tools/slack/context.d.ts +3 -0
  45. package/dist/chat/tools/types.d.ts +21 -2
  46. package/dist/chunk-76YMBKW7.js +326 -0
  47. package/dist/{chunk-PIVOJIUD.js → chunk-B5HKWWQB.js} +9 -5
  48. package/dist/chunk-BBXYXOJW.js +1858 -0
  49. package/dist/{chunk-V47RLIO2.js → chunk-GT67ZWZQ.js} +4 -4
  50. package/dist/{chunk-UQQSW7QB.js → chunk-HOGQL2H6.js} +197 -343
  51. package/dist/{chunk-75UZ4JLC.js → chunk-IGLNC5H6.js} +21 -9
  52. package/dist/{chunk-EBVQXCD2.js → chunk-JS4HURDT.js} +362 -280
  53. package/dist/chunk-R62YWUNO.js +264 -0
  54. package/dist/{chunk-OIIXZOOC.js → chunk-UXG6TU2U.js} +311 -2015
  55. package/dist/cli/check.js +4 -4
  56. package/dist/cli/init.js +18 -1
  57. package/dist/cli/snapshot-warmup.js +5 -4
  58. package/dist/nitro.d.ts +1 -1
  59. package/dist/nitro.js +21 -19
  60. package/dist/plugins.d.ts +2 -2
  61. package/dist/reporting.d.ts +8 -4
  62. package/dist/reporting.js +72 -29
  63. package/package.json +6 -4
  64. package/dist/chat/plugins/auth/github-app-broker.d.ts +0 -4
  65. package/dist/chat/plugins/github-permissions.d.ts +0 -11
  66. package/dist/chat/queue/thread-message-dispatcher.d.ts +0 -33
  67. package/dist/chunk-KVZL5NZS.js +0 -519
@@ -1,519 +0,0 @@
1
- // src/chat/discovery.ts
2
- import fs, { statSync } from "fs";
3
- import path from "path";
4
- import { fileURLToPath } from "url";
5
- function isDirectory(targetPath) {
6
- try {
7
- return statSync(targetPath).isDirectory();
8
- } catch {
9
- return false;
10
- }
11
- }
12
- function isFile(targetPath) {
13
- try {
14
- return statSync(targetPath).isFile();
15
- } catch {
16
- return false;
17
- }
18
- }
19
- function normalizePath(targetPath) {
20
- return path.resolve(targetPath);
21
- }
22
- function uniqueResolvedPathsInOrder(values) {
23
- const seen = /* @__PURE__ */ new Set();
24
- const resolved = [];
25
- for (const value of values) {
26
- const normalized = normalizePath(value);
27
- if (seen.has(normalized)) {
28
- continue;
29
- }
30
- seen.add(normalized);
31
- resolved.push(normalized);
32
- }
33
- return resolved;
34
- }
35
- function isNodeModulesPath(candidatePath) {
36
- return path.basename(candidatePath) === "node_modules";
37
- }
38
- function isInsidePnpmStore(candidatePath) {
39
- return candidatePath.split(path.sep).includes(".pnpm");
40
- }
41
- function runningFromInstalledPackage() {
42
- const currentFile = fileURLToPath(import.meta.url);
43
- const marker = `${path.sep}node_modules${path.sep}@sentry${path.sep}junior${path.sep}`;
44
- return currentFile.includes(marker);
45
- }
46
- function listInstalledPackageNodeModulesDirs() {
47
- if (!runningFromInstalledPackage()) {
48
- return [];
49
- }
50
- const dirs = [];
51
- let current = path.resolve(path.dirname(fileURLToPath(import.meta.url)));
52
- while (true) {
53
- if (isNodeModulesPath(current) && !isInsidePnpmStore(current) && isDirectory(current)) {
54
- dirs.push(current);
55
- }
56
- const parent = path.dirname(current);
57
- if (parent === current) {
58
- break;
59
- }
60
- current = parent;
61
- }
62
- return dirs;
63
- }
64
- function listCwdAncestorNodeModulesDirs(cwd) {
65
- const resolvedCwd = normalizePath(cwd);
66
- const dirs = [];
67
- let current = resolvedCwd;
68
- while (true) {
69
- const nodeModulesDir = path.join(current, "node_modules");
70
- if (isDirectory(nodeModulesDir)) {
71
- dirs.push(nodeModulesDir);
72
- }
73
- if (isFile(path.join(current, "package.json"))) {
74
- break;
75
- }
76
- const parent = path.dirname(current);
77
- if (parent === current) {
78
- break;
79
- }
80
- current = parent;
81
- }
82
- return dirs;
83
- }
84
- function discoverNodeModulesDirs(cwd = process.cwd(), options) {
85
- const explicit = options?.candidateDirs?.filter((dir) => isDirectory(dir)) ?? [];
86
- if (explicit.length > 0) {
87
- return uniqueResolvedPathsInOrder(explicit);
88
- }
89
- return uniqueResolvedPathsInOrder([
90
- ...listInstalledPackageNodeModulesDirs(),
91
- ...listCwdAncestorNodeModulesDirs(cwd)
92
- ]);
93
- }
94
- function discoverProjectRoots(cwd = process.cwd(), options) {
95
- const roots = discoverNodeModulesDirs(
96
- cwd,
97
- options?.nodeModulesDirs ? { candidateDirs: options.nodeModulesDirs } : void 0
98
- ).map((nodeModulesDir) => path.dirname(nodeModulesDir));
99
- return uniqueResolvedPathsInOrder([cwd, ...roots]);
100
- }
101
- function unique(values) {
102
- return [...new Set(values)];
103
- }
104
- function pathExists(targetPath) {
105
- try {
106
- fs.accessSync(targetPath);
107
- return true;
108
- } catch {
109
- return false;
110
- }
111
- }
112
- function hasAnyDataMarkers(appDir) {
113
- return pathExists(path.join(appDir, "SOUL.md")) || pathExists(path.join(appDir, "WORLD.md"));
114
- }
115
- function scoreAppCandidate(appDir) {
116
- let score = 0;
117
- if (pathExists(path.join(appDir, "SOUL.md"))) {
118
- score += 4;
119
- }
120
- if (pathExists(path.join(appDir, "WORLD.md"))) {
121
- score += 2;
122
- }
123
- if (pathExists(path.join(appDir, "skills"))) {
124
- score += 1;
125
- }
126
- if (pathExists(path.join(appDir, "plugins"))) {
127
- score += 1;
128
- }
129
- return score;
130
- }
131
- function resolveCandidateAppDirs(cwd, projectRoots) {
132
- const roots = projectRoots ?? discoverProjectRoots(cwd);
133
- const resolved = [];
134
- const seen = /* @__PURE__ */ new Set();
135
- for (const root of roots) {
136
- const appDir = path.resolve(root, "app");
137
- if (!pathExists(appDir)) {
138
- continue;
139
- }
140
- if (seen.has(appDir)) {
141
- continue;
142
- }
143
- seen.add(appDir);
144
- resolved.push(appDir);
145
- }
146
- return resolved;
147
- }
148
- function homeDir() {
149
- return resolveHomeDir();
150
- }
151
- function resolveHomeDir(cwd = process.cwd(), options) {
152
- const resolvedCwd = path.resolve(cwd);
153
- const directApp = path.resolve(resolvedCwd, "app");
154
- if (pathExists(directApp) && hasAnyDataMarkers(directApp)) {
155
- return directApp;
156
- }
157
- const candidates = resolveCandidateAppDirs(
158
- resolvedCwd,
159
- options?.projectRoots
160
- );
161
- if (candidates.length === 0) {
162
- return directApp;
163
- }
164
- candidates.sort((left, right) => {
165
- const leftScore = scoreAppCandidate(left);
166
- const rightScore = scoreAppCandidate(right);
167
- if (leftScore !== rightScore) {
168
- return rightScore - leftScore;
169
- }
170
- const leftDistance = path.relative(resolvedCwd, left).split(path.sep).length;
171
- const rightDistance = path.relative(resolvedCwd, right).split(path.sep).length;
172
- if (leftDistance !== rightDistance) {
173
- return leftDistance - rightDistance;
174
- }
175
- return left.localeCompare(right);
176
- });
177
- return candidates[0];
178
- }
179
- function resolveContentRoots(subdir) {
180
- if (subdir === "data") {
181
- return [homeDir()];
182
- }
183
- return [path.join(homeDir(), subdir)];
184
- }
185
- function dataRoots() {
186
- return unique(resolveContentRoots("data"));
187
- }
188
- function skillRoots() {
189
- return unique(resolveContentRoots("skills"));
190
- }
191
- function pluginRoots() {
192
- return unique(resolveContentRoots("plugins"));
193
- }
194
- function soulPathCandidates() {
195
- const candidates = dataRoots().map((root) => path.join(root, "SOUL.md"));
196
- return unique(candidates);
197
- }
198
- function worldPathCandidates() {
199
- const candidates = dataRoots().map((root) => path.join(root, "WORLD.md"));
200
- return unique(candidates);
201
- }
202
- var RESERVED_APP_FILES = /* @__PURE__ */ new Set([
203
- "SOUL.md",
204
- "WORLD.md",
205
- "DESCRIPTION.md",
206
- "ABOUT.md"
207
- ]);
208
- function listReferenceFiles() {
209
- const appDir = homeDir();
210
- try {
211
- const entries = fs.readdirSync(appDir, { withFileTypes: true });
212
- return entries.filter(
213
- (entry) => entry.isFile() && entry.name.endsWith(".md") && !RESERVED_APP_FILES.has(entry.name)
214
- ).map((entry) => path.join(appDir, entry.name)).sort();
215
- } catch {
216
- return [];
217
- }
218
- }
219
-
220
- // src/package-resolution.ts
221
- import { statSync as statSync2 } from "fs";
222
- import { createRequire } from "module";
223
- import path2 from "path";
224
- function isDirectory2(targetPath) {
225
- try {
226
- return statSync2(targetPath).isDirectory();
227
- } catch {
228
- return false;
229
- }
230
- }
231
- function isFile2(targetPath) {
232
- try {
233
- return statSync2(targetPath).isFile();
234
- } catch {
235
- return false;
236
- }
237
- }
238
- function uniqueResolvedPathsInOrder2(values) {
239
- const seen = /* @__PURE__ */ new Set();
240
- const resolved = [];
241
- for (const value of values) {
242
- const normalized = path2.resolve(value);
243
- if (seen.has(normalized)) {
244
- continue;
245
- }
246
- seen.add(normalized);
247
- resolved.push(normalized);
248
- }
249
- return resolved;
250
- }
251
- function ancestorNodeModulesDirs(cwd) {
252
- const dirs = [];
253
- let current = path2.resolve(cwd);
254
- while (true) {
255
- const nodeModulesDir = path2.join(current, "node_modules");
256
- if (isDirectory2(nodeModulesDir)) {
257
- dirs.push(nodeModulesDir);
258
- }
259
- const parent = path2.dirname(current);
260
- if (parent === current) {
261
- break;
262
- }
263
- current = parent;
264
- }
265
- return dirs;
266
- }
267
- function packageDirInNodeModules(nodeModulesDir, packageName) {
268
- const packageDir = path2.join(nodeModulesDir, ...packageName.split("/"));
269
- return isDirectory2(packageDir) ? path2.resolve(packageDir) : void 0;
270
- }
271
- function isValidPackageSegment(segment) {
272
- return Boolean(segment) && segment !== "." && segment !== ".." && !segment.startsWith(".") && /^[A-Za-z0-9._~-]+$/.test(segment);
273
- }
274
- function isValidPackageName(packageName) {
275
- if (!packageName || packageName.includes("\\") || path2.isAbsolute(packageName)) {
276
- return false;
277
- }
278
- const parts = packageName.split("/");
279
- if (parts[0].startsWith("@")) {
280
- return parts.length === 2 && parts[0].length > 1 && isValidPackageSegment(parts[0].slice(1)) && isValidPackageSegment(parts[1]);
281
- }
282
- return parts.length === 1 && isValidPackageSegment(parts[0]);
283
- }
284
- function findPackageRoot(entryPath) {
285
- let dir = path2.dirname(entryPath);
286
- while (dir !== path2.dirname(dir)) {
287
- if (isFile2(path2.join(dir, "package.json"))) {
288
- return path2.resolve(dir);
289
- }
290
- dir = path2.dirname(dir);
291
- }
292
- return void 0;
293
- }
294
- function findPackageNodeModulesDir(packageDir, packageName) {
295
- const parts = path2.resolve(packageDir).split(path2.sep);
296
- const packageParts = packageName.split("/");
297
- for (let index = parts.length - 1; index >= 0; index -= 1) {
298
- if (parts[index] !== "node_modules") {
299
- continue;
300
- }
301
- const candidatePackageParts = parts.slice(
302
- index + 1,
303
- index + 1 + packageParts.length
304
- );
305
- if (candidatePackageParts.join("/") !== packageParts.join("/")) {
306
- continue;
307
- }
308
- return path2.resolve(parts.slice(0, index + 1).join(path2.sep) || path2.sep);
309
- }
310
- return void 0;
311
- }
312
- function resolvePackageWithNode(cwd, packageName) {
313
- let requireFromCwd;
314
- try {
315
- requireFromCwd = createRequire(path2.join(cwd, "package.json"));
316
- } catch {
317
- return void 0;
318
- }
319
- for (const specifier of [`${packageName}/package.json`, packageName]) {
320
- try {
321
- const resolved = requireFromCwd.resolve(specifier);
322
- const dir = specifier.endsWith("/package.json") ? path2.dirname(resolved) : findPackageRoot(resolved);
323
- if (!dir) {
324
- continue;
325
- }
326
- const nodeModulesDir = findPackageNodeModulesDir(dir, packageName);
327
- return {
328
- dir,
329
- ...nodeModulesDir ? { nodeModulesDir } : {}
330
- };
331
- } catch {
332
- }
333
- }
334
- return void 0;
335
- }
336
- function resolvePackageLocation(cwd, packageName, options) {
337
- if (!isValidPackageName(packageName)) {
338
- return void 0;
339
- }
340
- const nodeModulesDirs = uniqueResolvedPathsInOrder2([
341
- ...options?.nodeModulesDirs ?? [],
342
- ...ancestorNodeModulesDirs(cwd)
343
- ]);
344
- for (const nodeModulesDir of nodeModulesDirs) {
345
- const dir = packageDirInNodeModules(nodeModulesDir, packageName);
346
- if (dir) {
347
- return { dir, nodeModulesDir };
348
- }
349
- }
350
- return resolvePackageWithNode(cwd, packageName);
351
- }
352
- function resolvePackageDir(cwd, packageName) {
353
- return resolvePackageLocation(cwd, packageName)?.dir;
354
- }
355
-
356
- // src/chat/plugins/package-discovery.ts
357
- import path3 from "path";
358
- function normalizeForGlob(targetPath) {
359
- return targetPath.split(path3.sep).join("/");
360
- }
361
- function uniqueStringsInOrder(values) {
362
- const seen = /* @__PURE__ */ new Set();
363
- const resolved = [];
364
- for (const value of values) {
365
- if (seen.has(value)) {
366
- continue;
367
- }
368
- seen.add(value);
369
- resolved.push(value);
370
- }
371
- return resolved;
372
- }
373
- function pathForTracingInclude(cwd, targetPath) {
374
- const relative = path3.relative(cwd, targetPath);
375
- if (!relative || path3.isAbsolute(relative) || relative === ".." || relative.startsWith(`..${path3.sep}`)) {
376
- return null;
377
- }
378
- const normalized = normalizeForGlob(relative);
379
- return normalized.startsWith(".") ? normalized : `./${normalized}`;
380
- }
381
- function normalizePluginPackageNames(packageNames) {
382
- if (packageNames === void 0) {
383
- return [];
384
- }
385
- if (!Array.isArray(packageNames)) {
386
- throw new Error("Plugin package names must be an array");
387
- }
388
- const normalized = [];
389
- const seen = /* @__PURE__ */ new Set();
390
- for (const packageName of packageNames) {
391
- const normalizedPackageName = typeof packageName === "string" ? packageName.trim() : "";
392
- if (!normalizedPackageName || !isValidPackageName(normalizedPackageName)) {
393
- throw new Error("Plugin package names must be valid npm package names");
394
- }
395
- if (seen.has(normalizedPackageName)) {
396
- continue;
397
- }
398
- seen.add(normalizedPackageName);
399
- normalized.push(normalizedPackageName);
400
- }
401
- return normalized;
402
- }
403
- function formatNodeModulesDirs(candidateNodeModulesDirs) {
404
- return candidateNodeModulesDirs.length > 0 ? candidateNodeModulesDirs.join(", ") : "none found";
405
- }
406
- function resolvePackageDirFromName(cwd, packageName, candidateNodeModulesDirs) {
407
- return resolvePackageLocation(cwd, packageName, {
408
- nodeModulesDirs: candidateNodeModulesDirs
409
- }) ?? null;
410
- }
411
- function readPluginPackageFlags(dir) {
412
- const hasRootPluginManifest = isFile(path3.join(dir, "plugin.yaml"));
413
- const hasPluginsDir = isDirectory(path3.join(dir, "plugins"));
414
- const hasSkillsDir = isDirectory(path3.join(dir, "skills"));
415
- if (!hasRootPluginManifest && !hasPluginsDir && !hasSkillsDir) {
416
- return null;
417
- }
418
- return {
419
- hasRootPluginManifest,
420
- hasPluginsDir,
421
- hasSkillsDir
422
- };
423
- }
424
- function discoverDeclaredPackages(packageNames, candidateNodeModulesDirs, cwd) {
425
- const discovered = [];
426
- const seenPackageDirs = /* @__PURE__ */ new Set();
427
- for (const packageName of packageNames) {
428
- const resolved = resolvePackageDirFromName(
429
- cwd,
430
- packageName,
431
- candidateNodeModulesDirs
432
- );
433
- if (!resolved) {
434
- throw new Error(
435
- `Plugin package "${packageName}" was configured but could not be resolved from node_modules or package resolution (${formatNodeModulesDirs(candidateNodeModulesDirs)})`
436
- );
437
- }
438
- if (seenPackageDirs.has(resolved.dir)) {
439
- continue;
440
- }
441
- const pluginFlags = readPluginPackageFlags(resolved.dir);
442
- if (!pluginFlags) {
443
- throw new Error(
444
- `Plugin package "${packageName}" was configured but does not contain plugin content; expected plugin.yaml, plugins/, or skills/ in ${resolved.dir}`
445
- );
446
- }
447
- seenPackageDirs.add(resolved.dir);
448
- discovered.push({
449
- name: packageName,
450
- dir: resolved.dir,
451
- nodeModulesDir: resolved.nodeModulesDir,
452
- ...pluginFlags
453
- });
454
- }
455
- return discovered;
456
- }
457
- function discoverInstalledPluginPackageContent(cwd = process.cwd(), options) {
458
- const resolvedCwd = path3.resolve(cwd);
459
- const packageNames = normalizePluginPackageNames(options?.packageNames);
460
- const nodeModulesDirs = options?.nodeModulesDirs ?? discoverNodeModulesDirs(resolvedCwd);
461
- const discoveredPackages = discoverDeclaredPackages(
462
- packageNames,
463
- nodeModulesDirs,
464
- resolvedCwd
465
- );
466
- const manifestRoots = [];
467
- const skillRoots2 = [];
468
- const tracingIncludes = [];
469
- for (const pkg of discoveredPackages) {
470
- const tracingBasePath = pkg.nodeModulesDir ? pathForTracingInclude(
471
- resolvedCwd,
472
- path3.join(pkg.nodeModulesDir, ...pkg.name.split("/"))
473
- ) : pathForTracingInclude(resolvedCwd, pkg.dir);
474
- if (pkg.hasRootPluginManifest) {
475
- manifestRoots.push(pkg.dir);
476
- if (tracingBasePath) {
477
- tracingIncludes.push(`${tracingBasePath}/plugin.yaml`);
478
- }
479
- }
480
- if (pkg.hasPluginsDir) {
481
- manifestRoots.push(path3.join(pkg.dir, "plugins"));
482
- if (tracingBasePath) {
483
- tracingIncludes.push(`${tracingBasePath}/plugins/**/*`);
484
- }
485
- }
486
- if (pkg.hasSkillsDir) {
487
- skillRoots2.push(path3.join(pkg.dir, "skills"));
488
- if (tracingBasePath) {
489
- tracingIncludes.push(`${tracingBasePath}/skills/**/*`);
490
- }
491
- }
492
- }
493
- return {
494
- packageNames: uniqueStringsInOrder(
495
- discoveredPackages.map((pkg) => pkg.name)
496
- ),
497
- packages: discoveredPackages.map((pkg) => ({
498
- dir: pkg.dir,
499
- hasSkillsDir: pkg.hasSkillsDir,
500
- name: pkg.name
501
- })),
502
- manifestRoots: uniqueStringsInOrder(manifestRoots),
503
- skillRoots: uniqueStringsInOrder(skillRoots2),
504
- tracingIncludes: uniqueStringsInOrder(tracingIncludes)
505
- };
506
- }
507
-
508
- export {
509
- homeDir,
510
- skillRoots,
511
- pluginRoots,
512
- soulPathCandidates,
513
- worldPathCandidates,
514
- listReferenceFiles,
515
- isValidPackageName,
516
- resolvePackageDir,
517
- normalizePluginPackageNames,
518
- discoverInstalledPluginPackageContent
519
- };