@sentry/junior 0.315.0 → 0.317.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 (139) hide show
  1. package/dist/{admin-5jUYY46p.js → admin-CAugg87B.js} +1 -1
  2. package/dist/{agent-runner-C7GNLRB6.js → agent-runner-AjrEV6Qe.js} +13532 -12811
  3. package/dist/{reporting-window-C4dbzDiR.js → agent-status-BA5x3Xtp.js} +33 -1
  4. package/dist/{agent-update-delivery-BNEYQsAf.js → agent-update-delivery-B_YIZcgf.js} +10 -37
  5. package/dist/api/schema.d.ts +609 -104
  6. package/dist/api/schema.js +6 -6
  7. package/dist/api.js +373 -469
  8. package/dist/{app-D_bAXRDe.d.ts → app-MoNAsVV5.d.ts} +52 -28
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +177 -132
  11. package/dist/catalog-runtime-DfSpJZdY.js +6 -0
  12. package/dist/{change-record-Bqsa5ZXE.d.ts → change-record-BzJgLsv7.d.ts} +60 -1
  13. package/dist/{adapter-context-BlSGE44V.js → channel-access-j-YAVYK4.js} +2 -42
  14. package/dist/{chat-core-engine-CxkwRpn9.js → chat-core-engine-aH85nEHv.js} +4 -3
  15. package/dist/{child-message--2G3Ft26.js → child-message-DHjQLEd1.js} +1 -1
  16. package/dist/cli/chat.js +23 -23
  17. package/dist/cli/check.js +5 -5
  18. package/dist/cli/main.js +2 -2
  19. package/dist/cli/plugins.js +5 -4
  20. package/dist/cli/snapshot-create.js +5 -2
  21. package/dist/cli/upgrade.js +27 -5
  22. package/dist/config-CHQ8X251.js +2422 -0
  23. package/dist/{continue-in-slack-BGKjIdFp.js → continue-in-slack-D-FZ8Fin.js} +2 -3
  24. package/dist/{conversation-feed-Sl8lKKmR.js → conversation-feed--9S0_PXL.js} +9 -4
  25. package/dist/{proxy-path-Dc-0jXGi.js → conversation-privacy-B1uXn5sf.js} +2 -16
  26. package/dist/{conversation-turn-BoLK9i6g.js → conversation-turn-BUE_7xaN.js} +102 -172
  27. package/dist/{create-BOycVH9h.js → create-DoDIYgtZ.js} +12 -10
  28. package/dist/{credential-sync-Mn4OdkEh.js → credential-sync-BJOqGnjV.js} +17 -12
  29. package/dist/{db-DXTOYRzR.js → db-BFmyYZtJ.js} +20276 -27398
  30. package/dist/{deployment-CG3TchWh.js → deployment-DXq9ZLU4.js} +17 -15
  31. package/dist/{engine-context-dyWlfNdD.js → engine-context-CgQ7mlHt.js} +264 -50
  32. package/dist/{html-CfXEwl_h.js → html-B3VKTGbJ.js} +6 -2
  33. package/dist/instrumentation.js +15 -7
  34. package/dist/{job-runner-CySgpi9v.js → job-runner-A1lCkybD.js} +397 -22
  35. package/dist/{lineage-tRTOcrsL.js → lineage-Bktb0UcV.js} +1 -1
  36. package/dist/{list-DXBz8SYL.js → list-Bxvg5wXf.js} +260 -698
  37. package/dist/{logging-czs0nqLC.js → logging--smS7XRK.js} +2 -2
  38. package/dist/{mailbox-turn-79Nv1JXv.js → mailbox-turn-uSXhUFc9.js} +648 -2957
  39. package/dist/{message-BTox2Cmb.js → message-BNenhsmB.js} +12 -22
  40. package/dist/{model-input-IRGa98V7.js → model-input-BReSnwHp.js} +3 -3
  41. package/dist/nitro.d.ts +1 -1
  42. package/dist/nitro.js +20 -6
  43. package/dist/{oauth-callback-server-NXK7AlBp.js → oauth-callback-server-CE4soEIY.js} +2 -2
  44. package/dist/{oauth-relay-6NBPSpFE.js → oauth-relay-C36gX1gH.js} +2 -2
  45. package/dist/{package-discovery-BI6T_RkD.js → package-discovery-DD9vencX.js} +1 -50
  46. package/dist/{parent-result-Dg6P6roR.js → parent-result-Ck1rFYRQ.js} +93 -106
  47. package/dist/{plugins-BXMdNdyA.js → plugins-D_Ru4CWc.js} +1 -1
  48. package/dist/profile-BQ-iBDsZ.js +4657 -0
  49. package/dist/{transcript-BHhJVY0P.js → prompt-Dv7gkpD6.js} +97 -103
  50. package/dist/proxy-path-BHYoKZdq.js +15 -0
  51. package/dist/registry-iXMT5Jmh.js +3279 -0
  52. package/dist/reports-WKHfGTsU.js +195 -0
  53. package/dist/{resolve-BUFkmxkT.js → resolve-tony4ibz.js} +9 -29
  54. package/dist/{result-DfATzX77.js → result-Bta_dlWa.js} +42 -117
  55. package/dist/run-conversation-DL6ru7iW.js +336 -0
  56. package/dist/{runner-CmKP3inb.js → runner-BstDRbD9.js} +7 -7
  57. package/dist/{sandbox-egress-signals-DYo5BsM7.js → sandbox-egress-signals-oSJMJOnn.js} +1 -1
  58. package/dist/{schema-DrBMdPmv.js → schema-DfqrHACA.js} +67 -84
  59. package/dist/sender-actors-CPglLd5R.js +83 -0
  60. package/dist/{service-account-CxTX7nnR.js → service-account-CTV_jaNu.js} +3 -1
  61. package/dist/{skills-BlHUDj7k.js → skills-BCEU41zM.js} +4 -4
  62. package/dist/{slack-conversation-unfurl-Dhe3lB1U.js → slack-conversation-unfurl-DxVmhbGP.js} +7 -6
  63. package/dist/{spawn-CfvlFdfz.js → spawn-frczVPIr.js} +11 -8
  64. package/dist/{system-prompt-table-CDCYVwqN.js → system-prompt-table-CiXy0eNR.js} +91 -70
  65. package/dist/{task-runner-DcdQJd9e.js → task-runner-C9Yc2_ae.js} +35 -49
  66. package/dist/{thread-context-DF5uDcWN.js → thread-context-CqZDKErp.js} +6 -6
  67. package/dist/topics-SRN7IVX-.js +24 -0
  68. package/dist/turn-membership-CENFf3kI.js +856 -0
  69. package/dist/{turn-wake-um5Ubd4m.js → turn-wake-BhloiI2h.js} +4 -5
  70. package/dist/{media-Cr9pGkzr.js → types-C4iC-IMC.js} +819 -777
  71. package/dist/user-customization-CvfuY9Eo.js +93 -0
  72. package/dist/users-ByG5RCEJ.js +181 -0
  73. package/dist/{validation-CJyuOPD2.js → validation-8gjfR91V.js} +1 -1
  74. package/dist/{version-Bhe7RPIe.js → version-BeZhWWBE.js} +1 -1
  75. package/dist/version.js +1 -1
  76. package/dist/{worker-D8PRgUqr.js → worker-BqMQQNRk.js} +5 -4
  77. package/migrations/20261125171254_conversation_visibility/migration.sql +4 -0
  78. package/migrations/20261125171254_conversation_visibility/snapshot.json +67 -0
  79. package/migrations/20261125171257_conversation_visibility_backfill/migration.sql +25 -0
  80. package/migrations/20261125171257_conversation_visibility_backfill/snapshot.json +9 -0
  81. package/migrations/20261125213232_drop_versions_notify/migration.sql +19 -0
  82. package/migrations/20261125213232_drop_versions_notify/snapshot.json +9 -0
  83. package/migrations/20261125225138_conversation_kind_root_thread/migration.sql +23 -0
  84. package/migrations/20261125225138_conversation_kind_root_thread/snapshot.json +55 -0
  85. package/migrations/20261125225142_conversation_kind_root_thread_backfill/migration.sql +7 -0
  86. package/migrations/20261125225142_conversation_kind_root_thread_backfill/snapshot.json +9 -0
  87. package/migrations/20261126000151_conversation_event_message_role_seq_index/migration.sql +1 -0
  88. package/migrations/20261126000151_conversation_event_message_role_seq_index/snapshot.json +69 -0
  89. package/migrations/20261126012917_merge_leaves/migration.sql +2 -0
  90. package/migrations/20261126012917_merge_leaves/snapshot.json +12 -0
  91. package/migrations/20261126025226_drop_agent_invocations/migration.sql +6 -0
  92. package/migrations/20261126025226_drop_agent_invocations/snapshot.json +9 -0
  93. package/migrations/20261126033000_space_conversations_lead_children/migration.sql +155 -0
  94. package/migrations/20261126033000_space_conversations_lead_children/snapshot.json +9 -0
  95. package/migrations/20261126144620_drop_user_message_time_index/migration.sql +1 -0
  96. package/migrations/20261126144620_drop_user_message_time_index/snapshot.json +38 -0
  97. package/migrations/20261126153100_inbox_item_subjects/migration.sql +140 -0
  98. package/migrations/20261126153100_inbox_item_subjects/snapshot.json +9 -0
  99. package/migrations/20261126153103_inbox_item_subjects_not_null/migration.sql +12 -0
  100. package/migrations/20261126153103_inbox_item_subjects_not_null/snapshot.json +9 -0
  101. package/migrations/20261126153105_inbox_item_subject_indexes/migration.sql +1 -0
  102. package/migrations/20261126153105_inbox_item_subject_indexes/snapshot.json +9 -0
  103. package/migrations/20261126153108_automation_run_conversation_index/migration.sql +1 -0
  104. package/migrations/20261126153108_automation_run_conversation_index/snapshot.json +9 -0
  105. package/migrations/20261126153159_inbox_item_subjects_schema/migration.sql +4 -0
  106. package/migrations/20261126153159_inbox_item_subjects_schema/snapshot.json +437 -0
  107. package/migrations/20261126153259_inbox_questions/migration.sql +76 -0
  108. package/migrations/20261126153259_inbox_questions/snapshot.json +9 -0
  109. package/migrations/20261126153301_inbox_questions_valid/migration.sql +3 -0
  110. package/migrations/20261126153301_inbox_questions_valid/snapshot.json +9 -0
  111. package/migrations/20261126153343_inbox_questions_schema/migration.sql +5 -0
  112. package/migrations/20261126153343_inbox_questions_schema/snapshot.json +407 -0
  113. package/migrations/20261126154025_inbox_item_owners/migration.sql +74 -0
  114. package/migrations/20261126154025_inbox_item_owners/snapshot.json +9 -0
  115. package/migrations/20261126154048_inbox_item_open_subject_key_index/migration.sql +1 -0
  116. package/migrations/20261126154048_inbox_item_open_subject_key_index/snapshot.json +9 -0
  117. package/migrations/20261126154051_drop_inbox_item_owner_indexes/migration.sql +7 -0
  118. package/migrations/20261126154051_drop_inbox_item_owner_indexes/snapshot.json +9 -0
  119. package/migrations/20261126154121_inbox_item_owners_schema/migration.sql +8 -0
  120. package/migrations/20261126154121_inbox_item_owners_schema/snapshot.json +311 -0
  121. package/migrations/20261126175601_conversation_event_turn/migration.sql +5 -0
  122. package/migrations/20261126175601_conversation_event_turn/snapshot.json +103 -0
  123. package/migrations/20261126175614_conversation_event_turn_index/migration.sql +1 -0
  124. package/migrations/20261126175614_conversation_event_turn_index/snapshot.json +62 -0
  125. package/migrations/20261126230028_merge_leaves/migration.sql +2 -0
  126. package/migrations/20261126230028_merge_leaves/snapshot.json +12 -0
  127. package/migrations/20261126231932_space_lead_holds_name/migration.sql +46 -0
  128. package/migrations/20261126231932_space_lead_holds_name/snapshot.json +58 -0
  129. package/migrations/20261127001022_merge_leaves/migration.sql +2 -0
  130. package/migrations/20261127001022_merge_leaves/snapshot.json +12 -0
  131. package/package.json +5 -5
  132. package/skills/jr-rpc/SKILL.md +3 -5
  133. package/dist/direct-url-BYgYfuIy.js +0 -22
  134. package/dist/markers-CE0HMXWT.js +0 -67
  135. package/dist/people-Cegp1Iwq.js +0 -81
  136. package/dist/start-conversation-Uh8Sk1EF.js +0 -162
  137. package/dist/turn-session-routing-GtetHsdO.js +0 -1309
  138. package/dist/user-customization-B27StpVQ.js +0 -9
  139. package/dist/web-message-id-C6P83ans.js +0 -10
@@ -0,0 +1,93 @@
1
+ import * as z from "zod";
2
+ // src/chat/attachments/media.ts
3
+ const INPUT_IMAGE_TYPES = [
4
+ "image/png",
5
+ "image/jpeg",
6
+ "image/gif",
7
+ "image/webp"
8
+ ];
9
+ /** Video types that browsers play in a `<video>` element. */
10
+ const INLINE_VIDEO_TYPES = ["video/mp4", "video/webm"];
11
+ /** Leading bytes of each accepted image type. `null` matches any byte. */
12
+ const IMAGE_SIGNATURES = [
13
+ {
14
+ mediaType: "image/png",
15
+ bytes: [
16
+ 137,
17
+ 80,
18
+ 78,
19
+ 71,
20
+ 13,
21
+ 10,
22
+ 26,
23
+ 10
24
+ ]
25
+ },
26
+ {
27
+ mediaType: "image/jpeg",
28
+ bytes: [
29
+ 255,
30
+ 216,
31
+ 255
32
+ ]
33
+ },
34
+ {
35
+ mediaType: "image/gif",
36
+ bytes: [
37
+ 71,
38
+ 73,
39
+ 70,
40
+ 56,
41
+ 55,
42
+ 97
43
+ ]
44
+ },
45
+ {
46
+ mediaType: "image/gif",
47
+ bytes: [
48
+ 71,
49
+ 73,
50
+ 70,
51
+ 56,
52
+ 57,
53
+ 97
54
+ ]
55
+ },
56
+ {
57
+ mediaType: "image/webp",
58
+ bytes: [
59
+ 82,
60
+ 73,
61
+ 70,
62
+ 70,
63
+ null,
64
+ null,
65
+ null,
66
+ null,
67
+ 87,
68
+ 69,
69
+ 66,
70
+ 80
71
+ ]
72
+ }
73
+ ];
74
+ /**
75
+ * Detect an accepted image type from file bytes. Use this instead of a file
76
+ * name or declared content type, which can be wrong.
77
+ */
78
+ function detectImageMediaType(data) {
79
+ return IMAGE_SIGNATURES.find(({ bytes }) => data.length >= bytes.length && bytes.every((byte, index) => byte === null || data[index] === byte))?.mediaType;
80
+ }
81
+ /** Report whether a media type is a raster image accepted by vision models. */
82
+ function isVisionImageMediaType(mediaType) {
83
+ const normalized = mediaType.split(";", 1)[0]?.trim().toLowerCase();
84
+ return normalized ? INPUT_IMAGE_TYPES.some((type) => type === normalized) : false;
85
+ }
86
+ // src/api/schema/user-customization.ts
87
+ /** Longest customization text one user can save. */
88
+ const USER_CUSTOMIZATION_MAX_CHARS = 1e3;
89
+ /** Saved customization text. An empty string means none. */
90
+ const userCustomizationTextSchema = z.string().trim().max(USER_CUSTOMIZATION_MAX_CHARS);
91
+ /** Request and response body for the viewer's customization. */
92
+ const userCustomizationSchema = z.object({ customization: userCustomizationTextSchema }).strict();
93
+ export { INPUT_IMAGE_TYPES as a, INLINE_VIDEO_TYPES as i, userCustomizationSchema as n, detectImageMediaType as o, userCustomizationTextSchema as r, isVisionImageMediaType as s, USER_CUSTOMIZATION_MAX_CHARS as t };
@@ -0,0 +1,181 @@
1
+ import { Fs as SlackActionError, qs as withSlackRetries, zs as getSlackClient } from "./db-BFmyYZtJ.js";
2
+ import * as z from "zod";
3
+ // src/chat/slack/users.ts
4
+ const profileFieldsSchema = z.object({ fields: z.record(z.string(), z.object({
5
+ value: z.string().optional(),
6
+ alt: z.string().optional(),
7
+ label: z.string().optional()
8
+ }).nullable()).nullish() });
9
+ function normalizeUser(raw) {
10
+ const rawFields = profileFieldsSchema.parse(raw.profile ?? {}).fields;
11
+ const profileFields = [];
12
+ if (rawFields) for (const [id, field] of Object.entries(rawFields)) {
13
+ if (!field) continue;
14
+ profileFields.push({
15
+ id,
16
+ label: field.label || void 0,
17
+ value: field.value || void 0,
18
+ alt: field.alt || void 0
19
+ });
20
+ }
21
+ return {
22
+ id: raw.id ?? "",
23
+ team_id: raw.team_id || void 0,
24
+ name: raw.name || void 0,
25
+ real_name: raw.real_name || raw.profile?.real_name || void 0,
26
+ display_name: raw.profile?.display_name || void 0,
27
+ title: raw.profile?.title || void 0,
28
+ email: raw.profile?.email || void 0,
29
+ status_text: raw.profile?.status_text ?? void 0,
30
+ status_emoji: raw.profile?.status_emoji ?? void 0,
31
+ avatar_url: raw.profile?.image_512 || void 0,
32
+ is_bot: raw.is_bot ?? false,
33
+ is_deleted: raw.deleted ?? false,
34
+ timezone: raw.tz || void 0,
35
+ ...profileFields.length > 0 ? { profile_fields: profileFields } : void 0
36
+ };
37
+ }
38
+ function normalizeNameTokens(value) {
39
+ return value.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);
40
+ }
41
+ function nameFields(user) {
42
+ return [
43
+ user.name ?? "",
44
+ user.profile?.display_name ?? "",
45
+ user.real_name ?? user.profile?.real_name ?? ""
46
+ ].map((value) => value.toLowerCase().trim()).filter(Boolean);
47
+ }
48
+ /** Look up a Slack user by ID, returning the full profile including custom fields. */
49
+ async function lookupSlackUserProfile(userId) {
50
+ const client = getSlackClient();
51
+ const user = (await withSlackRetries(() => client.users.info({ user: userId }), 3, { action: "users.info" })).user;
52
+ if (!user) throw new Error(`Slack users.info returned no user for ${userId}`);
53
+ return normalizeUser(user);
54
+ }
55
+ /**
56
+ * Look up one Slack user who is a current human member of a workspace.
57
+ *
58
+ * Returns undefined for a user that Slack cannot find, a deleted user, a bot,
59
+ * or a user of another workspace. Other lookup errors propagate.
60
+ */
61
+ async function lookupActiveSlackWorkspaceMember(userId, teamId) {
62
+ let user;
63
+ try {
64
+ user = await lookupSlackUserProfile(userId);
65
+ } catch (error) {
66
+ if (error instanceof SlackActionError && error.apiError === "user_not_found") return;
67
+ throw error;
68
+ }
69
+ return user.id === userId && user.team_id === teamId && !user.is_deleted && !user.is_bot ? user : void 0;
70
+ }
71
+ /** Look up a Slack bot by ID. Returns undefined when Slack has no such bot. */
72
+ async function lookupSlackBot(botId) {
73
+ try {
74
+ return (await withSlackRetries(() => getSlackClient().bots.info({ bot: botId }), 3, { action: "bots.info" })).bot;
75
+ } catch (error) {
76
+ if (error instanceof SlackActionError && error.apiError === "bot_not_found") return;
77
+ throw error;
78
+ }
79
+ }
80
+ /** Look up a Slack user by email. Returns null when no user matches. */
81
+ async function lookupSlackUserByEmail(email) {
82
+ const client = getSlackClient();
83
+ let result;
84
+ try {
85
+ result = await withSlackRetries(() => client.users.lookupByEmail({ email }), 3, { action: "users.lookupByEmail" });
86
+ } catch (error) {
87
+ if (error instanceof SlackActionError && error.apiError === "users_not_found") return null;
88
+ throw error;
89
+ }
90
+ const user = result.user;
91
+ if (!user) return null;
92
+ return normalizeUser(user);
93
+ }
94
+ /**
95
+ * Rank Slack name-search quality for one candidate.
96
+ * Exact field and token matches beat field prefixes so a display-name prefix
97
+ * cannot outrank a real-name first-name hit.
98
+ */
99
+ function scoreNameMatch(user, query) {
100
+ const queryLower = query.toLowerCase().trim();
101
+ if (!queryLower) return 0;
102
+ const fields = nameFields(user);
103
+ if (fields.length === 0) return 0;
104
+ let best = 0;
105
+ const queryTokens = normalizeNameTokens(queryLower);
106
+ for (const field of fields) {
107
+ if (field === queryLower) {
108
+ best = Math.max(best, 100);
109
+ continue;
110
+ }
111
+ if (field.startsWith(queryLower)) best = Math.max(best, 70);
112
+ else if (field.includes(queryLower)) best = Math.max(best, 25);
113
+ const tokens = normalizeNameTokens(field);
114
+ for (const token of tokens) if (token === queryLower) best = Math.max(best, 85);
115
+ else if (token.startsWith(queryLower)) best = Math.max(best, 60);
116
+ if (queryTokens.length > 1 && queryTokens.every((queryToken) => tokens.some((token) => token === queryToken || token.startsWith(queryToken)))) best = Math.max(best, 95);
117
+ }
118
+ return best;
119
+ }
120
+ function compareNameMatches(left, right) {
121
+ if (right.score !== left.score) return right.score - left.score;
122
+ return (left.user.name ?? "").localeCompare(right.user.name ?? "");
123
+ }
124
+ async function listWorkspaceUsers(options) {
125
+ const client = getSlackClient();
126
+ const matches = [];
127
+ let cursor;
128
+ let pages = 0;
129
+ let totalScanned = 0;
130
+ while (pages < options.maxPages) {
131
+ pages++;
132
+ const result = await withSlackRetries(() => client.users.list({
133
+ limit: 200,
134
+ ...cursor ? { cursor } : void 0
135
+ }), 3, { action: "users.list" });
136
+ const members = result.members ?? [];
137
+ totalScanned += members.length;
138
+ for (const member of members) {
139
+ if (!options.includeDeleted && member.deleted) continue;
140
+ if (!options.includeBots && member.is_bot) continue;
141
+ if (member.id === "USLACKBOT") continue;
142
+ const score = options.score(member);
143
+ if (score <= 0) continue;
144
+ matches.push({
145
+ user: member,
146
+ score
147
+ });
148
+ }
149
+ const nextCursor = result.response_metadata?.next_cursor;
150
+ if (!nextCursor) {
151
+ cursor = void 0;
152
+ break;
153
+ }
154
+ cursor = nextCursor;
155
+ }
156
+ return {
157
+ matches,
158
+ searched_pages: pages,
159
+ searched_user_count: totalScanned,
160
+ truncated: pages >= options.maxPages && Boolean(cursor)
161
+ };
162
+ }
163
+ /** Search workspace users by name with bounded pagination through `users.list`. */
164
+ async function searchSlackUsers(options) {
165
+ const { query, limit = 10, maxPages = 3, includeDeleted = false, includeBots = false } = options;
166
+ const queryLower = query.toLowerCase().trim();
167
+ const listed = await listWorkspaceUsers({
168
+ maxPages,
169
+ includeDeleted,
170
+ includeBots,
171
+ score: (member) => scoreNameMatch(member, queryLower)
172
+ });
173
+ listed.matches.sort(compareNameMatches);
174
+ return {
175
+ users: listed.matches.slice(0, limit).map((m) => normalizeUser(m.user)),
176
+ searched_pages: listed.searched_pages,
177
+ searched_user_count: listed.searched_user_count,
178
+ truncated: listed.truncated
179
+ };
180
+ }
181
+ export { searchSlackUsers as a, lookupSlackUserProfile as i, lookupSlackBot as n, lookupSlackUserByEmail as r, lookupActiveSlackWorkspaceMember as t };
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
- import { Ar as pluginCatalogRuntime } from "./db-DXTOYRzR.js";
2
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-DfSpJZdY.js";
3
3
  import { isDeepStrictEqual } from "node:util";
4
4
  // src/chat/plugins/validation.ts
5
5
  var validation_exports = /* @__PURE__ */ __exportAll({
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.315.0";
2
+ var version = "0.317.0";
3
3
  // src/version.ts
4
4
  /** Installed Junior package version, or `unknown` when package metadata is unavailable. */
5
5
  const JUNIOR_VERSION = typeof version === "string" && version.trim() ? version : "unknown";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export { t as JUNIOR_VERSION } from "./version-Bhe7RPIe.js";
1
+ export { t as JUNIOR_VERSION } from "./version-BeZhWWBE.js";
@@ -1,7 +1,8 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
- import { bn as getTurnRequestDeadline, ia as nudgeIdempotencyKey, jf as getChatConfig, ta as ConversationQueueMessageRejectedError, xp as isProviderRetryError } from "./db-DXTOYRzR.js";
3
- import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-czs0nqLC.js";
4
- import { $t as checkInConversationWork, J as saveHeldInput, Jt as ackMessages, K as getConversationStoppedAtMs, Si as selectAttemptMessages, Zt as beginConversationResume, _n as requestAnotherSlice, an as completeConversationWork, ci as countPendingConversationMessages, dn as getConversationWorkState, en as claimConversationAttempt, fi as isFinalAttempt, gn as releaseConversationWork, hn as recordConversationRetry, in as completeConversationStop, ln as ensureConversationWake, mn as recordAttemptFailure, nn as clearConsumedConversationWake, on as deadLetterAttempt, pi as isInvalidConversationRecordError, sn as drainConversationMailbox, ui as hasConversationStop, xi as isAttemptInterrupt, yn as startConversationWork } from "./mailbox-turn-79Nv1JXv.js";
2
+ import { $t as drainConversationMailbox, An as isAttemptInterrupt, Gt as checkInConversationWork, Ir as nudgeIdempotencyKey, Jt as clearConsumedConversationWake, Kt as claimConversationAttempt, Nr as ConversationQueueMessageRejectedError, Qt as deadLetterAttempt, Sn as isInvalidConversationRecordError, Ut as beginConversationResume, Xt as completeConversationStop, Zt as completeConversationWork, _n as countPendingConversationMessages, cn as releaseConversationWork, cr as getTurnRequestDeadline, dn as startConversationWork, jn as selectAttemptMessages, ln as requestAnotherSlice, on as recordAttemptFailure, ou as ownsLocation, rn as getConversationWorkState, sn as recordConversationRetry, tn as ensureConversationWake, xn as isFinalAttempt, yn as hasConversationStop, zt as ackMessages } from "./db-BFmyYZtJ.js";
3
+ import { $ as isProviderRetryError, n as getChatConfig } from "./config-CHQ8X251.js";
4
+ import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging--smS7XRK.js";
5
+ import { K as saveHeldInput, W as getConversationStoppedAtMs } from "./mailbox-turn-uSXhUFc9.js";
5
6
  // src/chat/task-execution/lost-lease.ts
6
7
  /**
7
8
  * Count a slice that lost its Conversation Lease as a failed attempt, then
@@ -212,7 +213,7 @@ async function processConversationWorkInContext(message, options) {
212
213
  let destination = initial.destination;
213
214
  if (!destination && options.conversationStore) {
214
215
  const stored = await options.conversationStore.get({ conversationId });
215
- if (stored && !stored.parentConversationId) destination = stored.destination;
216
+ if (stored && ownsLocation(stored)) destination = stored.destination;
216
217
  }
217
218
  const lease = await startConversationWork({
218
219
  conversationId,
@@ -0,0 +1,4 @@
1
+ ALTER TABLE "junior_conversations" ADD COLUMN "visibility" text;--> statement-breakpoint
2
+ -- The column is new, so every row is null and passes the constraint. NOT
3
+ -- VALID skips the scan under lock and still checks every new write.
4
+ ALTER TABLE "junior_conversations" ADD CONSTRAINT "junior_conversations_visibility_check" CHECK ("visibility" is null or "visibility" in ('public', 'private')) NOT VALID;
@@ -0,0 +1,67 @@
1
+ {
2
+ "type": "diff",
3
+ "version": "10",
4
+ "dialect": "postgres",
5
+ "id": "7bbde9ec-c4d7-4543-9c2d-fe4a569cff2a",
6
+ "prevIds": ["453e2def-765a-4fb8-8b61-982131badb8b"],
7
+ "footprints": [
8
+ {
9
+ "statementType": "add_column",
10
+ "statementTarget": [
11
+ "column",
12
+ "public",
13
+ "junior_conversations",
14
+ "visibility"
15
+ ],
16
+ "writes": [
17
+ "s|col|public.junior_conversations.visibility",
18
+ "n|col|public.junior_conversations.visibility",
19
+ "e|col|public.junior_conversations.visibility"
20
+ ],
21
+ "reads": ["n|tbl|public.junior_conversations", "n|sch|public"]
22
+ },
23
+ {
24
+ "statementType": "add_check",
25
+ "statementTarget": ["table", "public", "junior_conversations"],
26
+ "writes": [
27
+ "s|ck|public.junior_conversations.junior_conversations_visibility_check",
28
+ "n|ck|public.junior_conversations.junior_conversations_visibility_check",
29
+ "e|ck|public.junior_conversations.junior_conversations_visibility_check",
30
+ "n|con|public.junior_conversations.junior_conversations_visibility_check"
31
+ ],
32
+ "reads": [
33
+ "n|tbl|public.junior_conversations",
34
+ "n|sch|public",
35
+ "n|col|public.junior_conversations.visibility"
36
+ ]
37
+ }
38
+ ],
39
+ "deltas": [
40
+ {
41
+ "op": "create",
42
+ "row": {
43
+ "schema": "public",
44
+ "table": "junior_conversations",
45
+ "name": "visibility",
46
+ "type": "text",
47
+ "typeSchema": null,
48
+ "notNull": false,
49
+ "dimensions": 0,
50
+ "default": null,
51
+ "generated": null,
52
+ "identity": null,
53
+ "entityType": "columns"
54
+ }
55
+ },
56
+ {
57
+ "op": "create",
58
+ "row": {
59
+ "schema": "public",
60
+ "table": "junior_conversations",
61
+ "name": "junior_conversations_visibility_check",
62
+ "value": "\"visibility\" is null or \"visibility\" in ('public', 'private')",
63
+ "entityType": "checks"
64
+ }
65
+ }
66
+ ]
67
+ }
@@ -0,0 +1,25 @@
1
+ -- Access now reads visibility from each Conversation row instead of its
2
+ -- root's Destination. Copy the Destination value to each root, then the
3
+ -- root value to each child. Direct and private Destinations are private. A
4
+ -- root with no Destination, or one whose visibility is unknown, stays null,
5
+ -- which reads as private. This runs in its own transaction, after the one
6
+ -- that adds the column, so it holds no table lock that blocks reads.
7
+ -- junior:bounded-backfill: runs once and sets only the new column of each row once. Most Conversations are idle.
8
+ UPDATE "junior_conversations" AS "conversations"
9
+ SET "visibility" = CASE
10
+ WHEN "destinations"."visibility" = 'public' THEN 'public'
11
+ ELSE 'private'
12
+ END
13
+ FROM "junior_destinations" AS "destinations"
14
+ WHERE "destinations"."id" = "conversations"."destination_id"
15
+ AND "conversations"."parent_conversation_id" IS NULL
16
+ AND "destinations"."visibility" <> 'unknown'
17
+ AND "conversations"."visibility" IS NULL;--> statement-breakpoint
18
+ -- junior:bounded-backfill: runs once and sets only the new column of each child once, from its root.
19
+ UPDATE "junior_conversations" AS "children"
20
+ SET "visibility" = "roots"."visibility"
21
+ FROM "junior_conversations" AS "roots"
22
+ WHERE "roots"."conversation_id" = "children"."root_conversation_id"
23
+ AND "children"."parent_conversation_id" IS NOT NULL
24
+ AND "roots"."visibility" IS NOT NULL
25
+ AND "children"."visibility" IS NULL;
@@ -0,0 +1,9 @@
1
+ {
2
+ "type": "diff",
3
+ "version": "10",
4
+ "dialect": "postgres",
5
+ "id": "f43e2e77-6550-4715-85fe-8c5100af8af8",
6
+ "prevIds": ["7bbde9ec-c4d7-4543-9c2d-fe4a569cff2a"],
7
+ "footprints": [],
8
+ "deltas": []
9
+ }
@@ -0,0 +1,19 @@
1
+ -- Drop the `junior_notify_versions` triggers and function from
2
+ -- 20261125124506_versions_notify. Only the dashboard versions stream listened
3
+ -- to them, and only release 0.315.0 shipped it. The release after 0.315.0
4
+ -- removes the stream. Code in 0.315.0 still works without them: an open
5
+ -- stream gets no change, and the client reads fresh tokens when the stream
6
+ -- reconnects or the poll runs.
7
+ DROP TRIGGER IF EXISTS "junior_notify_versions" ON "junior_conversations";--> statement-breakpoint
8
+ DROP TRIGGER IF EXISTS "junior_notify_versions" ON "junior_conversation_participants";--> statement-breakpoint
9
+ DROP TRIGGER IF EXISTS "junior_notify_versions" ON "junior_conversation_annotations";--> statement-breakpoint
10
+ DROP TRIGGER IF EXISTS "junior_notify_versions" ON "junior_inbox_items";--> statement-breakpoint
11
+ DROP TRIGGER IF EXISTS "junior_notify_versions" ON "junior_conversation_metrics";--> statement-breakpoint
12
+ DROP TRIGGER IF EXISTS "junior_notify_versions" ON "junior_attachments";--> statement-breakpoint
13
+ DROP TRIGGER IF EXISTS "junior_notify_versions" ON "junior_identities";--> statement-breakpoint
14
+ DROP TRIGGER IF EXISTS "junior_notify_versions" ON "junior_users";--> statement-breakpoint
15
+ DROP TRIGGER IF EXISTS "junior_notify_versions" ON "junior_destinations";--> statement-breakpoint
16
+ DROP TRIGGER IF EXISTS "junior_notify_versions" ON "junior_inbox_snoozes";--> statement-breakpoint
17
+ DROP TRIGGER IF EXISTS "junior_notify_versions" ON "junior_conversation_events";--> statement-breakpoint
18
+ -- squawk-ignore ban-drop-function -- unused since 0.315.0
19
+ DROP FUNCTION IF EXISTS "junior_notify_versions"();
@@ -0,0 +1,9 @@
1
+ {
2
+ "type": "diff",
3
+ "version": "10",
4
+ "dialect": "postgres",
5
+ "id": "df7b3240-6223-4c94-ab4c-da5347b0d335",
6
+ "prevIds": ["f43e2e77-6550-4715-85fe-8c5100af8af8"],
7
+ "footprints": [],
8
+ "deltas": []
9
+ }
@@ -0,0 +1,23 @@
1
+ -- The `root` kind is now `thread`, and a `thread` may have a parent. A
2
+ -- writer of the previous deploy still writes `root`, so this trigger stores
3
+ -- it as `thread`, and both checks accept both values until every writer
4
+ -- stores `thread`. NOT VALID skips the scan under lock, and every new write
5
+ -- is checked. The next migration moves the stored `root` rows to `thread`.
6
+ -- Each new check accepts every value that the dropped one accepted, so the
7
+ -- release that is live during the deploy keeps writing.
8
+ -- squawk-ignore ban-drop-constraint -- unused since 0.315.0
9
+ ALTER TABLE "junior_conversations" DROP CONSTRAINT "junior_conversations_kind_check";--> statement-breakpoint
10
+ -- squawk-ignore ban-drop-constraint -- unused since 0.315.0
11
+ ALTER TABLE "junior_conversations" DROP CONSTRAINT "junior_conversations_kind_parent_check";--> statement-breakpoint
12
+ ALTER TABLE "junior_conversations" ADD CONSTRAINT "junior_conversations_kind_check" CHECK ("kind" in ('root', 'thread', 'automation', 'lead', 'task')) NOT VALID;--> statement-breakpoint
13
+ ALTER TABLE "junior_conversations" ADD CONSTRAINT "junior_conversations_kind_parent_check" CHECK ("kind" is null or "kind" in ('root', 'thread') or (("kind" in ('automation', 'lead')) = ("parent_conversation_id" is null))) NOT VALID;--> statement-breakpoint
14
+ CREATE OR REPLACE FUNCTION "junior_conversations_kind_root_to_thread"()
15
+ RETURNS trigger
16
+ LANGUAGE plpgsql
17
+ AS $function$
18
+ BEGIN
19
+ NEW."kind" := 'thread';
20
+ RETURN NEW;
21
+ END
22
+ $function$;--> statement-breakpoint
23
+ CREATE TRIGGER "junior_conversations_kind_root_to_thread" BEFORE INSERT OR UPDATE ON "junior_conversations" FOR EACH ROW WHEN (NEW."kind" = 'root') EXECUTE FUNCTION "junior_conversations_kind_root_to_thread"();
@@ -0,0 +1,55 @@
1
+ {
2
+ "type": "diff",
3
+ "version": "10",
4
+ "dialect": "postgres",
5
+ "id": "ce981d67-12ad-415c-bc30-6066fbccc4ef",
6
+ "prevIds": ["df7b3240-6223-4c94-ab4c-da5347b0d335"],
7
+ "footprints": [
8
+ {
9
+ "statementType": "alter_check",
10
+ "statementTarget": ["table", "public", "junior_conversations"],
11
+ "writes": [
12
+ "s|ck|public.junior_conversations.junior_conversations_kind_check"
13
+ ],
14
+ "reads": [
15
+ "n|tbl|public.junior_conversations",
16
+ "n|sch|public",
17
+ "n|col|public.junior_conversations.kind",
18
+ "e|col|public.junior_conversations.kind"
19
+ ],
20
+ "sqlHash": "345e5044564ea1db"
21
+ },
22
+ {
23
+ "statementType": "alter_check",
24
+ "statementTarget": ["table", "public", "junior_conversations"],
25
+ "writes": [
26
+ "s|ck|public.junior_conversations.junior_conversations_kind_parent_check"
27
+ ],
28
+ "reads": [
29
+ "n|tbl|public.junior_conversations",
30
+ "n|sch|public",
31
+ "n|col|public.junior_conversations.kind",
32
+ "n|col|public.junior_conversations.parent_conversation_id",
33
+ "e|col|public.junior_conversations.kind",
34
+ "e|col|public.junior_conversations.parent_conversation_id"
35
+ ],
36
+ "sqlHash": "d3fa5107402d76be"
37
+ }
38
+ ],
39
+ "deltas": [
40
+ {
41
+ "op": "alter",
42
+ "key": "checks\u0000[\"public\",\"junior_conversations\",\"junior_conversations_kind_check\"]",
43
+ "set": {
44
+ "value": "\"kind\" in ('root', 'thread', 'automation', 'lead', 'task')"
45
+ }
46
+ },
47
+ {
48
+ "op": "alter",
49
+ "key": "checks\u0000[\"public\",\"junior_conversations\",\"junior_conversations_kind_parent_check\"]",
50
+ "set": {
51
+ "value": "\"kind\" is null or \"kind\" in ('root', 'thread') or ((\"kind\" in ('automation', 'lead')) = (\"parent_conversation_id\" is null))"
52
+ }
53
+ }
54
+ ]
55
+ }
@@ -0,0 +1,7 @@
1
+ -- The `root` kind is now `thread`. This runs in its own transaction, after
2
+ -- the one that changes the checks, so it holds no table lock that blocks
3
+ -- reads.
4
+ -- junior:bounded-backfill: runs once and sets only the kind of each `root` row once. Most Conversations are idle.
5
+ UPDATE "junior_conversations"
6
+ SET "kind" = 'thread'
7
+ WHERE "kind" = 'root';
@@ -0,0 +1,9 @@
1
+ {
2
+ "type": "diff",
3
+ "version": "10",
4
+ "dialect": "postgres",
5
+ "id": "0ade2c1c-c3d4-47eb-b7cc-b76d694776bc",
6
+ "prevIds": ["ce981d67-12ad-415c-bc30-6066fbccc4ef"],
7
+ "footprints": [],
8
+ "deltas": []
9
+ }
@@ -0,0 +1 @@
1
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_conversation_events_message_role_seq_idx" ON "junior_conversation_events" ("conversation_id",("payload"->>'role'),"seq") WHERE "type" = 'message';
@@ -0,0 +1,69 @@
1
+ {
2
+ "type": "diff",
3
+ "version": "10",
4
+ "dialect": "postgres",
5
+ "id": "d643f037-e1f1-41fd-a368-e705f2818a34",
6
+ "prevIds": ["df7b3240-6223-4c94-ab4c-da5347b0d335"],
7
+ "footprints": [
8
+ {
9
+ "statementType": "create_index",
10
+ "statementTarget": [
11
+ "index",
12
+ "public",
13
+ "junior_conversation_events",
14
+ "junior_conversation_events_message_role_seq_idx"
15
+ ],
16
+ "writes": [
17
+ "s|idx|public.junior_conversation_events_message_role_seq_idx",
18
+ "n|idx|public.junior_conversation_events_message_role_seq_idx",
19
+ "e|idx|public.junior_conversation_events_message_role_seq_idx",
20
+ "n|rel|public.junior_conversation_events_message_role_seq_idx"
21
+ ],
22
+ "reads": [
23
+ "n|tbl|public.junior_conversation_events",
24
+ "n|sch|public",
25
+ "n|col|public.junior_conversation_events.conversation_id",
26
+ "n|col|public.junior_conversation_events.seq"
27
+ ]
28
+ }
29
+ ],
30
+ "deltas": [
31
+ {
32
+ "op": "create",
33
+ "row": {
34
+ "schema": "public",
35
+ "table": "junior_conversation_events",
36
+ "name": "junior_conversation_events_message_role_seq_idx",
37
+ "nameExplicit": true,
38
+ "columns": [
39
+ {
40
+ "value": "conversation_id",
41
+ "isExpression": false,
42
+ "asc": true,
43
+ "nullsFirst": false,
44
+ "opclass": null
45
+ },
46
+ {
47
+ "value": "(\"payload\"->>'role')",
48
+ "isExpression": true,
49
+ "asc": true,
50
+ "nullsFirst": false,
51
+ "opclass": null
52
+ },
53
+ {
54
+ "value": "seq",
55
+ "isExpression": false,
56
+ "asc": true,
57
+ "nullsFirst": false,
58
+ "opclass": null
59
+ }
60
+ ],
61
+ "isUnique": false,
62
+ "where": "\"type\" = 'message'",
63
+ "with": "",
64
+ "method": "btree",
65
+ "entityType": "indexes"
66
+ }
67
+ }
68
+ ]
69
+ }
@@ -0,0 +1,2 @@
1
+ -- Two migrations merged to main in parallel. This migration joins their
2
+ -- snapshots into one leaf. It changes no schema.
@@ -0,0 +1,12 @@
1
+ {
2
+ "type": "diff",
3
+ "version": "10",
4
+ "dialect": "postgres",
5
+ "id": "0e1b857d-8d81-45fd-b576-822a76b32c70",
6
+ "prevIds": [
7
+ "0ade2c1c-c3d4-47eb-b7cc-b76d694776bc",
8
+ "d643f037-e1f1-41fd-a368-e705f2818a34"
9
+ ],
10
+ "footprints": [],
11
+ "deltas": []
12
+ }
@@ -0,0 +1,6 @@
1
+ -- Drop the junior_agent_invocations table that 0160_agent_config_backfill
2
+ -- kept in the database. No runtime code reads or writes it since 0.314.0.
3
+ -- Retention purge in 0.316.0 still deletes its rows, so a purge that runs on
4
+ -- that release during the deploy fails, and the next run retries the tree.
5
+ -- squawk-ignore ban-drop-table -- unused since 0.314.0
6
+ DROP TABLE IF EXISTS "junior_agent_invocations";