@sentry/junior 0.134.0 → 0.135.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 (51) hide show
  1. package/dist/{agent-hooks-HGXNYOOD.js → agent-hooks-EMXDAD2K.js} +9 -9
  2. package/dist/api/schema/task.d.ts +0 -24
  3. package/dist/api/schema.d.ts +2 -2
  4. package/dist/api/schema.js +1 -3
  5. package/dist/api.js +20 -71
  6. package/dist/app.js +23 -25
  7. package/dist/{catalog-runtime-P6QHU6XE.js → catalog-runtime-NVPT6HA5.js} +5 -5
  8. package/dist/chat/tasks/execution-stats.d.ts +1 -2
  9. package/dist/{chunk-KWGJG4HO.js → chunk-45DPXMI3.js} +3 -3
  10. package/dist/{chunk-FL466XX5.js → chunk-5EX36ZCD.js} +12 -12
  11. package/dist/{chunk-LKK4XMUV.js → chunk-5LD6EBH2.js} +1 -1
  12. package/dist/{chunk-VP6NCPRS.js → chunk-6UNZ5DHG.js} +1 -1
  13. package/dist/{chunk-S6DMTEOM.js → chunk-AGAHACF7.js} +2 -2
  14. package/dist/{chunk-NYWSCJVW.js → chunk-EBRB6ZBF.js} +1 -1
  15. package/dist/{chunk-52DIKFJV.js → chunk-EJT7EPP3.js} +6 -14
  16. package/dist/{chunk-U3ZI7CCW.js → chunk-HDGTBCQR.js} +1 -1
  17. package/dist/{chunk-MFERLE3G.js → chunk-IRTIVX42.js} +1 -1
  18. package/dist/{chunk-7GKQ7UIO.js → chunk-NGX2V4WY.js} +4 -4
  19. package/dist/{chunk-YNLQQ622.js → chunk-OSCF2BDE.js} +4 -4
  20. package/dist/{chunk-VGXJMECA.js → chunk-P2D7IW57.js} +7 -7
  21. package/dist/{chunk-6T3AYZT7.js → chunk-QQCEMMVN.js} +1 -1
  22. package/dist/{chunk-XG5PHKPM.js → chunk-RMI6OX52.js} +2 -2
  23. package/dist/{chunk-7UTBPDXK.js → chunk-TRZSM67C.js} +0 -13
  24. package/dist/{chunk-FDNAUM7X.js → chunk-TYEDZVRM.js} +1 -1
  25. package/dist/{chunk-QLEKAO7O.js → chunk-U37P4IIP.js} +13 -7
  26. package/dist/{chunk-VEGF62FV.js → chunk-UXYZPEWP.js} +1 -1
  27. package/dist/{chunk-VPYKNCTN.js → chunk-VZEKCQLD.js} +3 -3
  28. package/dist/{chunk-NF2TNZPD.js → chunk-Y6627MTY.js} +14 -14
  29. package/dist/{chunk-GSP5SMZJ.js → chunk-YPKPXLMS.js} +1 -1
  30. package/dist/chunk-Z67KVHMJ.js +233 -0
  31. package/dist/{chunk-TR6UEEYD.js → chunk-ZBQIA5NI.js} +5 -5
  32. package/dist/cli/chat.js +24 -24
  33. package/dist/cli/check.js +6 -6
  34. package/dist/cli/plugins.js +12 -12
  35. package/dist/cli/snapshot-create.js +9 -9
  36. package/dist/cli/upgrade.js +7 -7
  37. package/dist/{db-GFK4NHWJ.js → db-UA6OFL25.js} +7 -7
  38. package/dist/instrumentation.js +4 -4
  39. package/dist/nitro.js +2 -2
  40. package/dist/{oauth-callback-server-HUJLAQ5N.js → oauth-callback-server-IJDYBSTX.js} +17 -18
  41. package/dist/{runner-T77AFAH4.js → runner-K6GID4HN.js} +11 -12
  42. package/dist/{skills-3KUFJOOR.js → skills-KJVS753I.js} +6 -6
  43. package/dist/{validation-FMWDHKYU.js → validation-7VDJGK7K.js} +6 -6
  44. package/dist/version.js +1 -1
  45. package/migrations/0020_restrict_task_execution_kinds.sql +2 -0
  46. package/migrations/meta/0020_snapshot.json +1848 -0
  47. package/migrations/meta/_journal.json +8 -1
  48. package/package.json +4 -4
  49. package/dist/chat/tasks/registered.d.ts +0 -3
  50. package/dist/chunk-AS3I7OIL.js +0 -115
  51. package/dist/chunk-NOA34AJY.js +0 -122
@@ -141,6 +141,13 @@
141
141
  "when": 1785951633228,
142
142
  "tag": "0019_lowly_valkyrie",
143
143
  "breakpoints": true
144
+ },
145
+ {
146
+ "idx": 20,
147
+ "version": "7",
148
+ "when": 1785960181727,
149
+ "tag": "0020_restrict_task_execution_kinds",
150
+ "breakpoints": true
144
151
  }
145
152
  ]
146
- }
153
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior",
3
- "version": "0.134.0",
3
+ "version": "0.135.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -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.134.0"
82
+ "@sentry/junior-plugin-api": "0.135.0"
83
83
  },
84
84
  "devDependencies": {
85
85
  "@emnapi/core": "^1.10.0",
@@ -96,8 +96,8 @@
96
96
  "typescript": "^6.0.3",
97
97
  "vercel": "^54.4.0",
98
98
  "vitest": "^4.1.7",
99
- "@sentry/junior-memory": "0.134.0",
100
- "@sentry/junior-github": "0.134.0",
99
+ "@sentry/junior-github": "0.135.0",
100
+ "@sentry/junior-memory": "0.135.0",
101
101
  "@sentry/junior-testing": "0.0.0"
102
102
  },
103
103
  "scripts": {
@@ -1,3 +0,0 @@
1
- import type { RegisteredTaskSummary } from "@/api/schema/task";
2
- /** Load registered plugin background tasks with execution analytics. */
3
- export declare function readRegisteredTasks(): Promise<RegisteredTaskSummary[]>;
@@ -1,115 +0,0 @@
1
- import {
2
- healthReportSchema
3
- } from "./chunk-UTL3MHPC.js";
4
- import {
5
- parseSlackThreadId
6
- } from "./chunk-MFERLE3G.js";
7
- import {
8
- normalizeSlackConversationId
9
- } from "./chunk-TR6UEEYD.js";
10
-
11
- // src/handlers/health.ts
12
- function readHealthReport() {
13
- return healthReportSchema.parse({
14
- status: "ok",
15
- service: "junior",
16
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
17
- });
18
- }
19
- function GET() {
20
- return Response.json(readHealthReport());
21
- }
22
-
23
- // src/chat/slack/conversation-context.ts
24
- function normalizeConversationName(type, channelName) {
25
- const trimmed = channelName?.trim();
26
- if (!trimmed) return void 0;
27
- if (type === "public_channel" || type === "private_channel" || type === "private_channel_or_group_dm") {
28
- return trimmed.startsWith("#") ? trimmed : `#${trimmed}`;
29
- }
30
- return trimmed;
31
- }
32
- function typeFromSlackChannelType(channelType) {
33
- if (channelType === "channel") return "public_channel";
34
- if (channelType === "group") return "private_channel";
35
- if (channelType === "mpim") return "group_dm";
36
- if (channelType === "im") return "direct_message";
37
- return void 0;
38
- }
39
- function typeFromChannelId(channelId, channelName) {
40
- const normalized = normalizeSlackConversationId(channelId);
41
- if (!normalized) return void 0;
42
- if (normalized.startsWith("C")) return "public_channel";
43
- if (normalized.startsWith("D")) return "direct_message";
44
- if (normalized.startsWith("G")) {
45
- return channelName?.trim().startsWith("mpdm-") ? "group_dm" : "private_channel_or_group_dm";
46
- }
47
- return void 0;
48
- }
49
- function toSlackEventChannelType(channelType) {
50
- if (channelType === "channel" || channelType === "group" || channelType === "mpim" || channelType === "im") {
51
- return channelType;
52
- }
53
- return void 0;
54
- }
55
- function conversationVisibilityFromSlackChannelType(channelType) {
56
- if (!channelType) return void 0;
57
- return channelType === "channel" ? "public" : "private";
58
- }
59
- function resolveSlackChannelTypeFromMessage(message) {
60
- const raw = message.raw;
61
- if (!raw || typeof raw !== "object") {
62
- return void 0;
63
- }
64
- const channelType = raw.channel_type;
65
- return typeof channelType === "string" ? toSlackEventChannelType(channelType.trim()) : void 0;
66
- }
67
- function resolveSlackConversationContext(input) {
68
- const type = typeFromSlackChannelType(input.channelType) ?? typeFromChannelId(input.channelId, input.channelName);
69
- if (!type) return void 0;
70
- const name = normalizeConversationName(type, input.channelName);
71
- const visibility = conversationVisibilityFromSlackChannelType(
72
- input.channelType
73
- );
74
- return {
75
- type,
76
- ...name ? { name } : {},
77
- ...visibility ? { visibility } : {}
78
- };
79
- }
80
- function resolveSlackConversationContextFromThreadId(input) {
81
- const slackThread = parseSlackThreadId(input.threadId);
82
- const context = resolveSlackConversationContext({
83
- channelId: slackThread?.channelId,
84
- channelName: input.channelName
85
- });
86
- if (!context || !input.visibility) {
87
- return context;
88
- }
89
- return {
90
- ...context,
91
- type: input.visibility === "private" && context.type === "public_channel" ? "private_channel" : context.type,
92
- visibility: input.visibility
93
- };
94
- }
95
- function formatSlackConversationTypeLabel(type) {
96
- if (type === "public_channel") return "Public Channel";
97
- if (type === "private_channel") return "Private Channel";
98
- if (type === "group_dm") return "Group DM";
99
- if (type === "direct_message") return "Direct Message";
100
- return "Private Channel or Group DM";
101
- }
102
- function formatSlackConversationRedactedLabel(context) {
103
- if (!context) return void 0;
104
- return formatSlackConversationTypeLabel(context.type);
105
- }
106
-
107
- export {
108
- readHealthReport,
109
- GET,
110
- conversationVisibilityFromSlackChannelType,
111
- resolveSlackChannelTypeFromMessage,
112
- resolveSlackConversationContext,
113
- resolveSlackConversationContextFromThreadId,
114
- formatSlackConversationRedactedLabel
115
- };
@@ -1,122 +0,0 @@
1
- import {
2
- getDb
3
- } from "./chunk-VPYKNCTN.js";
4
- import {
5
- juniorTaskExecutions
6
- } from "./chunk-QLEKAO7O.js";
7
- import {
8
- logWarn
9
- } from "./chunk-6T3AYZT7.js";
10
-
11
- // src/chat/tasks/execution-stats.ts
12
- import { and, asc, count, desc, eq, gte, lte, max, sql } from "drizzle-orm";
13
- function utcDate(nowMs) {
14
- return new Date(nowMs).toISOString().slice(0, 10);
15
- }
16
- function emptyDay(date) {
17
- return { date, event: 0, registered: 0, scheduled: 0 };
18
- }
19
- async function recordTaskExecution(type, taskId, options) {
20
- const namespace = options.namespace ?? "junior";
21
- const nowMs = options.nowMs ?? Date.now();
22
- try {
23
- await getDb().insert(juniorTaskExecutions).values({
24
- conversationId: options.conversationId,
25
- executedAtMs: nowMs,
26
- executionId: options.executionId,
27
- kind: type,
28
- namespace,
29
- taskId
30
- }).onConflictDoNothing({
31
- target: [
32
- juniorTaskExecutions.kind,
33
- juniorTaskExecutions.namespace,
34
- juniorTaskExecutions.executionId
35
- ]
36
- });
37
- } catch (error) {
38
- logWarn("task.execution.stat_failed", {
39
- error,
40
- "app.task.execution.id": options.executionId,
41
- "app.task.execution.namespace": namespace,
42
- "app.task.execution.task_id": taskId,
43
- "app.task.execution.type": type
44
- });
45
- }
46
- }
47
- async function readTaskExecutionSummaries(type, namespace, options = {}) {
48
- const sevenDaysAgoMs = (options.nowMs ?? Date.now()) - 7 * 24 * 60 * 60 * 1e3;
49
- const db = getDb();
50
- const latest = db.selectDistinctOn([juniorTaskExecutions.taskId], {
51
- conversationId: juniorTaskExecutions.conversationId,
52
- taskId: juniorTaskExecutions.taskId
53
- }).from(juniorTaskExecutions).where(
54
- and(
55
- eq(juniorTaskExecutions.kind, type),
56
- eq(juniorTaskExecutions.namespace, namespace)
57
- )
58
- ).orderBy(
59
- juniorTaskExecutions.taskId,
60
- desc(juniorTaskExecutions.executedAtMs),
61
- desc(juniorTaskExecutions.executionId)
62
- ).as("latest_task_execution");
63
- const rows = await db.select({
64
- lastConversationId: latest.conversationId,
65
- lastExecutedAtMs: max(juniorTaskExecutions.executedAtMs),
66
- runsLast7Days: sql`count(*) filter (where ${juniorTaskExecutions.executedAtMs} >= ${sevenDaysAgoMs})::int`,
67
- taskId: juniorTaskExecutions.taskId,
68
- totalRuns: sql`count(*)::int`
69
- }).from(juniorTaskExecutions).innerJoin(latest, eq(latest.taskId, juniorTaskExecutions.taskId)).where(
70
- and(
71
- eq(juniorTaskExecutions.kind, type),
72
- eq(juniorTaskExecutions.namespace, namespace)
73
- )
74
- ).groupBy(juniorTaskExecutions.taskId, latest.conversationId);
75
- return new Map(
76
- rows.map((row) => [
77
- row.taskId,
78
- {
79
- lastConversationId: row.lastConversationId,
80
- ...row.lastExecutedAtMs !== null ? { lastExecutedAtMs: row.lastExecutedAtMs } : {},
81
- runsLast7Days: row.runsLast7Days,
82
- totalRuns: row.totalRuns
83
- }
84
- ])
85
- );
86
- }
87
- async function readTaskExecutionDays(dayCount = 90, options = {}) {
88
- const nowMs = options.nowMs ?? Date.now();
89
- const end = utcDate(nowMs);
90
- const endMs = Date.parse(`${end}T23:59:59.999Z`);
91
- const startMs = Date.parse(`${end}T00:00:00.000Z`) - (dayCount - 1) * 864e5;
92
- const executionDate = sql`to_char(to_timestamp(${juniorTaskExecutions.executedAtMs} / 1000.0) at time zone 'UTC', 'YYYY-MM-DD')`;
93
- const rows = await getDb().select({
94
- count: count(),
95
- date: executionDate,
96
- kind: juniorTaskExecutions.kind
97
- }).from(juniorTaskExecutions).where(
98
- and(
99
- gte(juniorTaskExecutions.executedAtMs, startMs),
100
- lte(juniorTaskExecutions.executedAtMs, endMs)
101
- )
102
- ).groupBy(executionDate, juniorTaskExecutions.kind).orderBy(asc(executionDate), asc(juniorTaskExecutions.kind));
103
- const byDate = /* @__PURE__ */ new Map();
104
- for (let offset = 0; offset < dayCount; offset += 1) {
105
- const date = utcDate(startMs + offset * 864e5);
106
- byDate.set(date, emptyDay(date));
107
- }
108
- for (const row of rows) {
109
- const day = byDate.get(row.date);
110
- if (!day) continue;
111
- if (row.kind === "registered") day.registered = row.count;
112
- else if (row.kind === "scheduled") day.scheduled = row.count;
113
- else if (row.kind === "event") day.event = row.count;
114
- }
115
- return [...byDate.values()];
116
- }
117
-
118
- export {
119
- recordTaskExecution,
120
- readTaskExecutionSummaries,
121
- readTaskExecutionDays
122
- };