@sentry/junior 0.310.0 → 0.311.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 (112) hide show
  1. package/dist/adapter-B1wujchl.js +259 -0
  2. package/dist/{adapter-context-BhKpjpGD.js → adapter-context-G2M0y6rP.js} +2 -2
  3. package/dist/{admin-tgZEZAk2.js → admin-DCiBhUT1.js} +1 -2
  4. package/dist/{agent-runner-D9cvNlQl.js → agent-runner-BVHPUIc8.js} +543 -1703
  5. package/dist/api/schema.d.ts +2 -2
  6. package/dist/api/schema.js +7 -6
  7. package/dist/api.d.ts +21 -3
  8. package/dist/api.js +1479 -372
  9. package/dist/{app-B_7Wn0en.d.ts → app-Cw5Vy6H6.d.ts} +14 -3
  10. package/dist/app.d.ts +2 -2
  11. package/dist/app.js +232 -506
  12. package/dist/{background-compaction-queue-BGHqkhkY.js → background-compaction-queue-CJDnWVOJ.js} +4 -4
  13. package/dist/{briefs-DKxkoruh.js → briefs-BDjnug6Y.js} +3 -3
  14. package/dist/{catalog-runtime-BxwzbLKY.js → catalog-runtime-DMY3VV-D.js} +1 -1
  15. package/dist/cli/chat.js +16 -16
  16. package/dist/cli/check.js +23 -29
  17. package/dist/cli/init.js +1 -6
  18. package/dist/cli/main.js +3 -3
  19. package/dist/cli/plugins.js +8 -7
  20. package/dist/cli/snapshot-create.js +5 -5
  21. package/dist/cli/upgrade.d.ts +1 -1
  22. package/dist/cli/upgrade.js +3 -3
  23. package/dist/{config-Dkt2Le2b.js → config-BrXDQefC.js} +239 -5
  24. package/dist/{continue-in-slack-BWVwePKD.js → continue-in-slack-DNXSC9So.js} +6 -5
  25. package/dist/{conversation-M9KZ5JxF.js → conversation-ca__NDQW.js} +47 -8
  26. package/dist/{conversation-feed-Ci6YD1N-.js → conversation-feed-DkinDu5o.js} +15 -6
  27. package/dist/{conversation-privacy-C39g8BY4.js → conversation-privacy-DxttrKb9.js} +1 -1
  28. package/dist/{conversation-turn-CBlZIH02.js → conversation-turn-DWw7Xhdr.js} +41 -38
  29. package/dist/{credential-sync-vGnrB0BY.js → credential-sync-Bk8wGb8Y.js} +15 -16
  30. package/dist/{db-B4Hjxr-u.d.ts → db-7ETESH44.d.ts} +3 -1
  31. package/dist/{db-CFZggNoy.js → db-DTxzH7u5.js} +1609 -1040
  32. package/dist/{executor-BPkZDx5-.js → executor-DqTiYj9S.js} +450 -99
  33. package/dist/{html-2r2KmLwi.js → html-B9Sl4Axb.js} +6 -6
  34. package/dist/{install-C-oE6C_u.js → install-Sg4ePfLl.js} +2 -2
  35. package/dist/instrumentation.js +3 -3
  36. package/dist/{lineage-CsvrEFQe.js → lineage-BHAMpNKr.js} +2 -2
  37. package/dist/{logging-D5gkyvnK.js → logging-FjclQsXu.js} +47 -9
  38. package/dist/{message-DwvJ-I3w.js → message-CJ7_RL50.js} +5 -8
  39. package/dist/{model-input-MAq2881y.js → model-input-CMLh4Cwq.js} +3 -3
  40. package/dist/nitro.d.ts +1 -1
  41. package/dist/nitro.js +3 -3
  42. package/dist/{oauth-callback-server-DIF6Li06.js → oauth-callback-server-RVcbiDjL.js} +2 -2
  43. package/dist/{oauth-relay-DPE-wrwO.js → oauth-relay-Bu9kkaQu.js} +1 -1
  44. package/dist/{projection-jZSlEAXG.js → projection-Cns7XwWa.js} +9445 -5574
  45. package/dist/{prompt-CaMyeCpA.js → prompt-CDqcsDYC.js} +4 -4
  46. package/dist/{registry-BBkWFCl8.js → registry-BPwuOP2O.js} +5 -8
  47. package/dist/{resolve-B38MkHXE.js → resolve-BK29bBry.js} +3 -3
  48. package/dist/rule-DAxQY-1h.js +20 -0
  49. package/dist/{runner-11h8PrHh.js → runner-BcAE-cJm.js} +10 -10
  50. package/dist/{sandbox-egress-signals-CTcACAtJ.js → sandbox-egress-signals-C-q0go5b.js} +1 -1
  51. package/dist/{schedule-DWxZ3kja.js → schedule-BLJ476XQ.js} +209 -43
  52. package/dist/{schema-obw5jvR4.js → schema-BLgSZXcL.js} +255 -49
  53. package/dist/{schema-DriSvB40.d.ts → schema-DYcJeV7d.d.ts} +701 -62
  54. package/dist/{service-account-Zc5bUcIJ.js → service-account-gN0zqf0S.js} +68 -68
  55. package/dist/{service-account-Bx93N1n1.js → service-account-iJoCtkHR.js} +3 -3
  56. package/dist/{skills-C8Npu5zO.js → skills-BoZ80epJ.js} +2 -2
  57. package/dist/{slack-conversation-unfurl-DlRVA02H.js → slack-conversation-unfurl-CogYrITA.js} +8 -10
  58. package/dist/{spawn-CXr58R0x.js → spawn-Dk92r7mX.js} +5 -6
  59. package/dist/{state-CGrGVeQC.js → state-DH3Cmgp3.js} +4 -4
  60. package/dist/{stop-DYzjRf2U.js → stop-CYsfc0Ed.js} +1063 -313
  61. package/dist/{store-D4FQ1Nml.js → store-DmmMIrQi.js} +5 -5
  62. package/dist/{task-queue-CaZffYaH.js → task-queue-C_zldF5J.js} +3 -3
  63. package/dist/{task-runner-Dm7BHbGp.js → task-runner-C7oCJQIx.js} +20 -13
  64. package/dist/{thread-context-Dyj1KWaY.js → thread-context-BW2BsQbH.js} +13 -11
  65. package/dist/{turn-session-routing-CD0BRCex.js → turn-session-routing-Xh_2nSQe.js} +52 -54
  66. package/dist/{validation-DxVNIxA0.js → validation-DrJd0nnq.js} +1 -1
  67. package/dist/{version-Cr7Z71yG.js → version-CNKZ8owc.js} +1 -1
  68. package/dist/version.js +1 -1
  69. package/dist/{warmup-C6LOZ2d2.js → warmup-BWdHew2H.js} +14287 -7195
  70. package/dist/{web-message-id-BT8Mg8LL.js → web-message-id-Ch5dPq-a.js} +32 -144
  71. package/dist/{worker-CUBtu1Li.js → worker-t9qpu_Zx.js} +7 -8
  72. package/migrations/0126_artifact_drop_public.sql +8 -0
  73. package/migrations/0127_artifact_path.sql +4 -0
  74. package/migrations/0128_artifact_path_index.sql +1 -0
  75. package/migrations/0129_review_item_answered_index.sql +1 -0
  76. package/migrations/0130_review_item_status_index.sql +1 -0
  77. package/migrations/0131_brief_outcome_status.sql +1 -0
  78. package/migrations/0132_brief_outcome_status_backfill.sql +7 -0
  79. package/migrations/0133_brief_created_at_index.sql +1 -0
  80. package/migrations/0134_slack_person_search_index.sql +1 -0
  81. package/migrations/0135_code_change_size.sql +3 -0
  82. package/migrations/0136_merge_conflict_notice_dismiss.sql +16 -0
  83. package/migrations/0137_inbox_snoozes.sql +27 -0
  84. package/migrations/0138_code_change_search_index.sql +2 -0
  85. package/migrations/0139_review_item_owner.sql +22 -0
  86. package/migrations/0140_review_item_owner_index.sql +1 -0
  87. package/migrations/0141_memory_core_adoption.sql +89 -0
  88. package/migrations/0142_memory_core_indexes.sql +17 -0
  89. package/migrations/meta/0126_snapshot.json +5488 -0
  90. package/migrations/meta/0127_snapshot.json +5519 -0
  91. package/migrations/meta/0128_snapshot.json +5519 -0
  92. package/migrations/meta/0129_snapshot.json +5547 -0
  93. package/migrations/meta/0130_snapshot.json +5563 -0
  94. package/migrations/meta/0131_snapshot.json +5569 -0
  95. package/migrations/meta/0132_snapshot.json +5569 -0
  96. package/migrations/meta/0133_snapshot.json +5590 -0
  97. package/migrations/meta/0134_snapshot.json +5606 -0
  98. package/migrations/meta/0135_snapshot.json +5624 -0
  99. package/migrations/meta/0136_snapshot.json +5624 -0
  100. package/migrations/meta/0137_snapshot.json +5864 -0
  101. package/migrations/meta/0138_snapshot.json +5894 -0
  102. package/migrations/meta/0139_snapshot.json +5898 -0
  103. package/migrations/meta/0140_snapshot.json +5919 -0
  104. package/migrations/meta/0141_snapshot.json +6429 -0
  105. package/migrations/meta/0142_snapshot.json +6457 -0
  106. package/migrations/meta/_journal.json +120 -1
  107. package/package.json +6 -7
  108. package/dist/result-BaqSZcJb.js +0 -548
  109. package/dist/session-stop-BfY4rhJs.js +0 -4255
  110. package/dist/turn-user-message-9IxeEv5v.js +0 -364
  111. package/dist/users-CaUAYMb3.js +0 -181
  112. package/dist/viewer-AHldghAD.js +0 -212
@@ -1,212 +0,0 @@
1
- import { I as findActorIdentityId, X as readCachedUserByEmail, Y as clearCachedUser, o as getDb } from "./db-CFZggNoy.js";
2
- import { B as juniorUsers, z as juniorIdentities } from "./executor-BPkZDx5-.js";
3
- import { G as normalizeIdentityEmail, U as GOOGLE_IDENTITY_PROVIDER } from "./logging-D5gkyvnK.js";
4
- import { createHash, randomUUID } from "node:crypto";
5
- import { identitySchema, userSchema } from "@sentry/junior-plugin-api";
6
- import { and, asc, eq, inArray, isNotNull } from "drizzle-orm";
7
- // src/chat/identities/avatar.ts
8
- /**
9
- * Profile photos of people, saved on their native Slack and Google
10
- * identities. `/api/people/avatars/:identityId` serves each photo through
11
- * the shared image route code, so browsers never load a photo from Slack or
12
- * Google.
13
- */
14
- const AVATAR_HOSTS = {
15
- slack: ["avatars.slack-edge.com"],
16
- [GOOGLE_IDENTITY_PROVIDER]: ["googleusercontent.com"]
17
- };
18
- const AVATAR_PROVIDERS = Object.keys(AVATAR_HOSTS);
19
- /**
20
- * Return the URL when it is HTTPS on a photo host of the provider or a
21
- * subdomain. Junior fetches only these URLs.
22
- */
23
- function parseAvatarUrl(value, provider) {
24
- const hosts = AVATAR_HOSTS[provider];
25
- if (!hosts || !value || !URL.canParse(value)) return void 0;
26
- const url = new URL(value);
27
- if (url.protocol !== "https:" || url.username || url.password) return;
28
- const host = url.hostname.toLowerCase();
29
- return hosts.some((allowed) => host === allowed || host.endsWith(`.${allowed}`)) ? url.href : void 0;
30
- }
31
- function avatarVersion(url) {
32
- return createHash("sha256").update(url).digest("hex").slice(0, 16);
33
- }
34
- function avatarPath(identityId, avatarUrl) {
35
- return `/api/people/avatars/${encodeURIComponent(identityId)}?v=${avatarVersion(avatarUrl)}`;
36
- }
37
- /**
38
- * Read the photo path of each user: the Slack photo, then the Google photo.
39
- * Users without a photo are not in the map.
40
- */
41
- async function readUserAvatarUrls(db, userIds) {
42
- if (userIds.length === 0) return /* @__PURE__ */ new Map();
43
- return userAvatarUrlsFromIdentities(await db.select({
44
- avatarUrl: juniorIdentities.avatarUrl,
45
- identityId: juniorIdentities.id,
46
- provider: juniorIdentities.provider,
47
- updatedAt: juniorIdentities.updatedAt,
48
- userId: juniorIdentities.userId
49
- }).from(juniorIdentities).where(and(inArray(juniorIdentities.userId, [...new Set(userIds)]), eq(juniorIdentities.kind, "user"), inArray(juniorIdentities.provider, AVATAR_PROVIDERS), isNotNull(juniorIdentities.avatarUrl))));
50
- }
51
- /**
52
- * Pick the photo path of each user from their user Identities, for a caller
53
- * that already read them: the Slack photo, then the Google photo.
54
- */
55
- function userAvatarUrlsFromIdentities(rows) {
56
- const rank = (row) => AVATAR_PROVIDERS.indexOf(row.provider);
57
- const ranked = rows.filter((row) => rank(row) >= 0).sort((left, right) => rank(left) - rank(right) || right.updatedAt.getTime() - left.updatedAt.getTime());
58
- const avatars = /* @__PURE__ */ new Map();
59
- for (const row of ranked) if (row.userId && row.avatarUrl && !avatars.has(row.userId)) avatars.set(row.userId, avatarPath(row.identityId, row.avatarUrl));
60
- return avatars;
61
- }
62
- /**
63
- * Return the photo path for one Identity row. A linked Identity uses the
64
- * photo of its user. An Identity without a user uses its own photo.
65
- */
66
- function identityAvatarUrl(row, userAvatarUrls) {
67
- if (row.userId) return userAvatarUrls.get(row.userId);
68
- return row.avatarUrl ? avatarPath(row.identityId, row.avatarUrl) : void 0;
69
- }
70
- /**
71
- * Return how to fetch the photo of one user Identity, or nothing when it has
72
- * no photo on a photo host of its provider. A redirect cannot leave the
73
- * photo hosts of the provider.
74
- */
75
- async function readAvatarFetch(db, identityId) {
76
- const [row] = await db.select({
77
- avatarUrl: juniorIdentities.avatarUrl,
78
- provider: juniorIdentities.provider
79
- }).from(juniorIdentities).where(and(eq(juniorIdentities.id, identityId), eq(juniorIdentities.kind, "user"))).limit(1);
80
- const url = row ? parseAvatarUrl(row.avatarUrl, row.provider) : void 0;
81
- const hosts = row && AVATAR_HOSTS[row.provider];
82
- return url && hosts ? {
83
- hosts,
84
- url
85
- } : void 0;
86
- }
87
- // src/chat/plugins/viewer.ts
88
- function identityFromRow(row) {
89
- return identitySchema.parse({
90
- id: row.id,
91
- provider: row.provider,
92
- providerSubjectId: row.providerSubjectId,
93
- ...row.providerTenantId ? { providerTenantId: row.providerTenantId } : void 0,
94
- ...row.displayName ? { displayName: row.displayName } : void 0,
95
- ...row.handle ? { handle: row.handle } : void 0
96
- });
97
- }
98
- async function readUserById(db, userRow) {
99
- return userFromRows(userRow, await db.select().from(juniorIdentities).where(and(eq(juniorIdentities.userId, userRow.id), eq(juniorIdentities.kind, "user"))).orderBy(asc(juniorIdentities.provider), asc(juniorIdentities.providerTenantId), asc(juniorIdentities.providerSubjectId)));
100
- }
101
- function userFromRows(userRow, identityRows) {
102
- return userSchema.parse({
103
- email: userRow.primaryEmail,
104
- id: userRow.id,
105
- identities: identityRows.map(identityFromRow),
106
- ...userRow.displayName ? { displayName: userRow.displayName } : void 0,
107
- ...userRow.isAdmin ? { isAdmin: true } : void 0
108
- });
109
- }
110
- async function readUserByNormalizedEmail(db, normalizedEmail) {
111
- const cached = await readCachedUserByEmail(db, normalizedEmail);
112
- return cached ? userFromRows(cached.user, cached.identities) : void 0;
113
- }
114
- /** Resolve or create the canonical user for one verified viewer email. */
115
- async function resolveViewerUserFromSql(db, email) {
116
- const normalizedEmail = normalizeIdentityEmail(email);
117
- if (!normalizedEmail) return void 0;
118
- const existing = await readUserByNormalizedEmail(db, normalizedEmail);
119
- if (existing) return existing;
120
- const now = /* @__PURE__ */ new Date();
121
- const userRow = (await db.insert(juniorUsers).values({
122
- id: randomUUID(),
123
- primaryEmail: email.trim(),
124
- primaryEmailNormalized: normalizedEmail,
125
- displayName: null,
126
- createdAt: now,
127
- updatedAt: now
128
- }).onConflictDoNothing({ target: juniorUsers.primaryEmailNormalized }).returning())[0] ?? (await db.select().from(juniorUsers).where(eq(juniorUsers.primaryEmailNormalized, normalizedEmail)).limit(1))[0];
129
- return userRow ? await readUserById(db, userRow) : void 0;
130
- }
131
- /** Resolve or create the canonical user for one authenticated viewer. */
132
- async function resolveViewerUser(email) {
133
- return await resolveViewerUserFromSql(getDb(), email);
134
- }
135
- /** Read one existing canonical user by verified email without creating a row. */
136
- async function findUserByEmailFromSql(db, email) {
137
- const normalizedEmail = normalizeIdentityEmail(email);
138
- if (!normalizedEmail) return void 0;
139
- return await readUserByNormalizedEmail(db, normalizedEmail);
140
- }
141
- /** Read one existing canonical user by verified email without creating a row. */
142
- async function findUserByEmail(email) {
143
- return await findUserByEmailFromSql(getDb(), email);
144
- }
145
- /** Update one canonical user's display name in SQL. */
146
- async function updateViewerDisplayNameFromSql(db, userId, displayName) {
147
- const rows = await db.update(juniorUsers).set({
148
- displayName,
149
- updatedAt: /* @__PURE__ */ new Date()
150
- }).where(eq(juniorUsers.id, userId)).returning();
151
- await clearCachedUser(userId);
152
- const userRow = rows[0];
153
- return userRow ? await readUserById(db, userRow) : void 0;
154
- }
155
- /** Read the photo path of one canonical user: Slack, then Google. */
156
- async function readViewerAvatarUrl(userId) {
157
- return (await readUserAvatarUrls(getDb(), [userId])).get(userId);
158
- }
159
- /** Update one canonical user's display name. */
160
- async function updateViewerDisplayName(userId, displayName) {
161
- return await updateViewerDisplayNameFromSql(getDb(), userId, displayName);
162
- }
163
- /**
164
- * Grant or revoke the Junior-wide admin role for one email.
165
- *
166
- * Granting creates the canonical user when needed, so an operator can grant
167
- * admin before that person first signs in. Revoking never creates a user.
168
- */
169
- async function setUserAdminFromSql(db, email, isAdmin) {
170
- const user = isAdmin ? await resolveViewerUserFromSql(db, email) : await findUserByEmailFromSql(db, email);
171
- if (!user) return void 0;
172
- const rows = await db.update(juniorUsers).set({
173
- isAdmin,
174
- updatedAt: /* @__PURE__ */ new Date()
175
- }).where(eq(juniorUsers.id, user.id)).returning();
176
- await clearCachedUser(user.id);
177
- const userRow = rows[0];
178
- return userRow ? await readUserById(db, userRow) : void 0;
179
- }
180
- /** List every Junior admin by primary email. */
181
- async function listAdminUsersFromSql(db) {
182
- const rows = await db.select().from(juniorUsers).where(eq(juniorUsers.isAdmin, true)).orderBy(asc(juniorUsers.primaryEmailNormalized));
183
- if (rows.length === 0) return [];
184
- const identityRows = await db.select().from(juniorIdentities).where(and(inArray(juniorIdentities.userId, rows.map((row) => row.id)), eq(juniorIdentities.kind, "user"))).orderBy(asc(juniorIdentities.provider), asc(juniorIdentities.providerTenantId), asc(juniorIdentities.providerSubjectId));
185
- return rows.map((row) => userFromRows(row, identityRows.filter((identity) => identity.userId === row.id)));
186
- }
187
- /** Resolve the stored identity and linked user for one runtime actor. */
188
- async function readActorIdentityFromSql(db, actor) {
189
- const identityId = await findActorIdentityId(db, actor);
190
- return identityId ? await readIdentityByIdFromSql(db, identityId) : void 0;
191
- }
192
- /** Resolve the stored identity and linked user for one runtime actor. */
193
- async function readActorIdentity(actor) {
194
- return await readActorIdentityFromSql(getDb(), actor);
195
- }
196
- /** Read one stored identity and its linked user by identity id. */
197
- async function readIdentityByIdFromSql(db, identityId) {
198
- const row = (await db.select({
199
- identity: juniorIdentities,
200
- user: juniorUsers
201
- }).from(juniorIdentities).leftJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(and(eq(juniorIdentities.id, identityId), eq(juniorIdentities.kind, "user"))).limit(1))[0];
202
- if (!row) return void 0;
203
- return {
204
- identity: identityFromRow(row.identity),
205
- ...row.user ? { user: await readUserById(db, row.user) } : void 0
206
- };
207
- }
208
- /** Read one stored identity and its linked user by identity id. */
209
- async function readIdentityById(identityId) {
210
- return await readIdentityByIdFromSql(getDb(), identityId);
211
- }
212
- export { readActorIdentityFromSql as a, readViewerAvatarUrl as c, updateViewerDisplayName as d, identityAvatarUrl as f, userAvatarUrlsFromIdentities as g, readUserAvatarUrls as h, readActorIdentity as i, resolveViewerUser as l, readAvatarFetch as m, findUserByEmailFromSql as n, readIdentityById as o, parseAvatarUrl as p, listAdminUsersFromSql as r, readIdentityByIdFromSql as s, findUserByEmail as t, setUserAdminFromSql as u };