@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
@@ -125,27 +125,20 @@ function sumUtcHoursIntoSixHours(args) {
125
125
  // src/api/schema/common.ts
126
126
  /** Stable error body returned by Junior-owned REST endpoints. */
127
127
  const apiErrorSchema = z.object({ error: z.string().min(1) }).strict();
128
- // src/chat/agent-invocations/result-event-type.ts
129
- /** Event namespace of the messages between a parent and its child agents. */
130
- const AGENT_INVOCATION_EVENT_NAMESPACE = "junior";
131
- const AGENT_INVOCATION_RESULT_EVENT_TYPE_PREFIX = "agent_invocation.";
132
- /** Build the Event type of the parent message for one agent invocation result. */
133
- function agentInvocationResultEventType(status) {
134
- return `${AGENT_INVOCATION_RESULT_EVENT_TYPE_PREFIX}${status}`;
135
- }
136
- /** True when an Event type names an agent invocation result. */
137
- function isAgentInvocationResultEventType(eventType) {
138
- return eventType.startsWith(AGENT_INVOCATION_RESULT_EVENT_TYPE_PREFIX);
139
- }
140
- /** Event type of the `reply` that ends a child agent's Turn. */
141
- const AGENT_REPLY_EVENT_TYPE = "agent.reply";
142
- /** Event type of a message that a child agent sends to its parent. */
143
- const AGENT_MESSAGE_EVENT_TYPE = "agent.message";
144
128
  /**
145
- * Event type of a parent agent task or message to a child that no agent
146
- * invocation names.
129
+ * Carries a content token in both directions. A custom header, not `ETag` /
130
+ * `If-None-Match`: the Vercel CDN removes `If-None-Match` before it calls the
131
+ * function, with every `Cache-Control` value, and no setting stops this. The
132
+ * CDN then answers a match with a 304 only after the function built the full
133
+ * response, so the read is not saved and the 304 does not show in app
134
+ * telemetry. A probe deployment confirmed this for `private, no-cache`,
135
+ * `no-cache`, `private, no-store`, `private, max-age=0, must-revalidate`, and
136
+ * no header. See
137
+ * https://vercel.com/docs/manage-cdn-usage#optimizing-fast-origin-transfer.
138
+ * A read that sends the token of the copy it holds gets an empty 304 while
139
+ * the content is unchanged.
147
140
  */
148
- const AGENT_PARENT_MESSAGE_EVENT_TYPE = "agent.parent_message";
141
+ const CONTENT_VERSION_HEADER = "x-junior-content-version";
149
142
  // src/chat/plan/types.ts
150
143
  /** Statuses of a Plan item. `done` and `cancelled` close it. */
151
144
  const PLAN_ITEM_STATUSES = [
@@ -159,6 +152,8 @@ const PLAN_ITEM_STATUSES = [
159
152
  function isOpenPlanItemStatus(status) {
160
153
  return status !== "done" && status !== "cancelled";
161
154
  }
155
+ /** Model-facing tool that changes the plan. */
156
+ const UPDATE_PLAN_TOOL_NAME = "updatePlan";
162
157
  /** Assignee text for the plan's own agent, in tool results and blocks. */
163
158
  const SELF_PLAN_ASSIGNEE = "self";
164
159
  // src/api/schema/user-customization.ts
@@ -252,134 +247,27 @@ function isVisionImageMediaType(mediaType) {
252
247
  const normalized = mediaType.split(";", 1)[0]?.trim().toLowerCase();
253
248
  return normalized ? INPUT_IMAGE_TYPES.some((type) => type === normalized) : false;
254
249
  }
255
- // src/chat/tools/runtime/user-input-request.ts
256
- const USER_INPUT_LIMITS = {
257
- maxButtonOptions: 5,
258
- maxDescriptionChars: 200,
259
- maxFields: 4,
260
- maxLabelChars: 75,
261
- maxOptions: 10,
262
- maxTextChars: 3e3,
263
- maxQuestionChars: 3e3,
264
- minOptions: 2
265
- };
266
- const labelSchema = z.string().trim().min(1).max(USER_INPUT_LIMITS.maxLabelChars);
267
- const descriptionSchema = z.string().trim().min(1).max(USER_INPUT_LIMITS.maxDescriptionChars).optional();
268
- const optionSchema = z.object({
269
- label: labelSchema.describe("Short choice text, such as `Accept` or `Decline`. The answer uses this exact text."),
270
- description: descriptionSchema.describe("Optional short note about what this choice does."),
271
- recommended: z.boolean().optional().describe("Set true on the choice that you recommend, put that choice first, and say why in its description. A `choice` field can recommend one option.")
272
- });
273
- const fieldBase = {
274
- id: z.string().regex(/^[a-z][a-z0-9_]{0,31}$/).describe("Stable key for this field, such as `approach`."),
275
- label: labelSchema.describe("Short field name, such as `Approach`."),
276
- description: descriptionSchema.describe("Optional short help text for this field.")
277
- };
278
- const optionsSchema = z.array(optionSchema).min(USER_INPUT_LIMITS.minOptions).max(USER_INPUT_LIMITS.maxOptions).describe("Choices in display order.");
279
- const userInputFieldSchema = z.discriminatedUnion("kind", [
280
- z.object({
281
- ...fieldBase,
282
- kind: z.literal("choice").describe("The person picks one option."),
283
- options: optionsSchema
284
- }),
285
- z.object({
286
- ...fieldBase,
287
- kind: z.literal("multi_choice").describe("The person picks any number of options."),
288
- options: optionsSchema
289
- }),
290
- z.object({
291
- ...fieldBase,
292
- kind: z.literal("text").describe("The person types a short answer.")
293
- })
294
- ]);
295
- const userInputRequestSchema = z.object({
296
- question: z.string().trim().min(1).max(USER_INPUT_LIMITS.maxQuestionChars).describe("The question, in markdown. Include the facts the person needs to decide."),
297
- fields: z.array(userInputFieldSchema).min(1).max(USER_INPUT_LIMITS.maxFields).describe("What to ask, in display order. Use one `choice` field for a simple decision.")
298
- }).superRefine((request, context) => {
299
- const ids = /* @__PURE__ */ new Set();
300
- for (const field of request.fields) {
301
- if (ids.has(field.id)) context.addIssue({
302
- code: "custom",
303
- message: "Each field needs a different id."
304
- });
305
- ids.add(field.id);
306
- if (field.kind === "text") continue;
307
- const labels = field.options.map((option) => option.label.toLowerCase());
308
- if (new Set(labels).size !== labels.length) context.addIssue({
309
- code: "custom",
310
- message: "Each choice of a field needs a different label."
311
- });
312
- if (field.kind === "choice" && field.options.filter((option) => option.recommended).length > 1) context.addIssue({
313
- code: "custom",
314
- message: "A `choice` field can recommend only one option."
315
- });
316
- }
317
- });
318
- /**
319
- * Label and help text of the free-text input that every form adds after the
320
- * fields. The text goes with the picked answers and does not replace them, so
321
- * every surface says that in the same words.
322
- */
323
- const USER_INPUT_NOTE = {
324
- label: "Anything else?",
325
- description: "Optional. This note is sent together with your answers above."
326
- };
327
- /**
328
- * Return the single choice field of a request that a surface can show as
329
- * one row of buttons, where one click is the whole answer.
330
- */
331
- function buttonUserInputField(request) {
332
- const [field, ...rest] = request.fields;
333
- if (rest.length || field?.kind !== "choice") return void 0;
334
- return field.options.length <= USER_INPUT_LIMITS.maxButtonOptions ? field : void 0;
335
- }
336
- /**
337
- * Keep only answer values that match the request: known field ids, known
338
- * option labels, one value for a `choice` field, and trimmed text.
339
- */
340
- function normalizeUserInputAnswer(request, answer) {
341
- const values = {};
342
- for (const field of request.fields) {
343
- const raw = (answer.values[field.id] ?? []).map((value) => value.trim()).filter(Boolean);
344
- if (field.kind === "text") {
345
- const text = raw.join("\n").slice(0, USER_INPUT_LIMITS.maxTextChars);
346
- if (text) values[field.id] = [text];
347
- continue;
348
- }
349
- const picked = field.options.map((option) => option.label).filter((label) => raw.includes(label));
350
- const kept = field.kind === "choice" ? picked.slice(0, 1) : picked;
351
- if (kept.length) values[field.id] = kept;
352
- }
353
- const other = answer.other?.trim().slice(0, USER_INPUT_LIMITS.maxTextChars);
354
- return {
355
- requestId: answer.requestId,
356
- values,
357
- ...other ? { other } : void 0
358
- };
359
- }
360
- /** Return true when an answer has no value and no free text. */
361
- function isEmptyUserInputAnswer(answer) {
362
- return !answer.other && Object.keys(answer.values).length === 0;
250
+ // src/chat/agent-invocations/result-event-type.ts
251
+ /** Event namespace of the messages between a parent and its child agents. */
252
+ const AGENT_INVOCATION_EVENT_NAMESPACE = "junior";
253
+ const AGENT_INVOCATION_RESULT_EVENT_TYPE_PREFIX = "agent_invocation.";
254
+ /** Build the Event type of the parent message for one agent invocation result. */
255
+ function agentInvocationResultEventType(status) {
256
+ return `${AGENT_INVOCATION_RESULT_EVENT_TYPE_PREFIX}${status}`;
363
257
  }
364
- function answerLine(text) {
365
- return text.split("\n").map((line) => line.trim()).filter(Boolean).join("\n");
258
+ /** True when an Event type names an agent invocation result. */
259
+ function isAgentInvocationResultEventType(eventType) {
260
+ return eventType.startsWith(AGENT_INVOCATION_RESULT_EVENT_TYPE_PREFIX);
366
261
  }
262
+ /** Event type of the `reply` that ends a child agent's Turn. */
263
+ const AGENT_REPLY_EVENT_TYPE = "agent.reply";
264
+ /** Event type of a message that a child agent sends to its parent. */
265
+ const AGENT_MESSAGE_EVENT_TYPE = "agent.message";
367
266
  /**
368
- * Write the fields of an answer, one `Label (field_id): value` line each.
369
- * Slack, the web dashboard, and the prompt all use this text, so the model
370
- * reads one format.
267
+ * Event type of a parent agent task or message to a child that no agent
268
+ * invocation names.
371
269
  */
372
- function formatUserInputAnswer(request, answer) {
373
- const normalized = normalizeUserInputAnswer(request, answer);
374
- const lines = [];
375
- for (const field of request.fields) {
376
- const values = normalized.values[field.id];
377
- const value = values?.length ? values.join(", ") : "(no answer)";
378
- lines.push(answerLine(`${field.label} (${field.id}): ${value}`));
379
- }
380
- if (normalized.other) lines.push(answerLine(`Other: ${normalized.other}`));
381
- return lines.join("\n");
382
- }
270
+ const AGENT_PARENT_MESSAGE_EVENT_TYPE = "agent.parent_message";
383
271
  // src/chat/agent-invocations/statuses.ts
384
272
  const AGENT_INVOCATION_STATUSES = [
385
273
  "pending",
@@ -415,4 +303,4 @@ async function webMessageId(args) {
415
303
  const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(`${args.conversationId}\u0000${args.idempotencyKey}`));
416
304
  return `api-msg:${Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("").slice(0, 24)}`;
417
305
  }
418
- export { HOUR_MS as A, AGENT_MESSAGE_EVENT_TYPE as C, isAgentInvocationResultEventType as D, agentInvocationResultEventType as E, sumUtcHoursIntoSixHours as F, trailingUtcDayWindow as I, trailingUtcHourWindow as L, fillUtcHours as M, fillUtcSixHours as N, apiErrorSchema as O, startOfUtcHour as P, trailingUtcSixHourWindow as R, AGENT_INVOCATION_EVENT_NAMESPACE as S, AGENT_REPLY_EVENT_TYPE as T, userCustomizationSchema as _, USER_INPUT_LIMITS as a, SELF_PLAN_ASSIGNEE as b, formatUserInputAnswer as c, userInputRequestSchema as d, INLINE_VIDEO_TYPES as f, USER_CUSTOMIZATION_MAX_CHARS as g, isVisionImageMediaType as h, AGENT_INVOCATION_STATUSES as i, fillUtcDays as j, DAY_MS as k, isEmptyUserInputAnswer as l, detectImageMediaType as m, AGENT_INVOCATION_MAILBOX_STATUSES as n, USER_INPUT_NOTE as o, INPUT_IMAGE_TYPES as p, AGENT_INVOCATION_PARENT_MAILBOX_STATUSES as r, buttonUserInputField as s, webMessageId as t, normalizeUserInputAnswer as u, userCustomizationTextSchema as v, AGENT_PARENT_MESSAGE_EVENT_TYPE as w, isOpenPlanItemStatus as x, PLAN_ITEM_STATUSES as y, utcHourKey as z };
306
+ export { sumUtcHoursIntoSixHours as A, apiErrorSchema as C, fillUtcHours as D, fillUtcDays as E, trailingUtcHourWindow as M, trailingUtcSixHourWindow as N, fillUtcSixHours as O, utcHourKey as P, CONTENT_VERSION_HEADER as S, HOUR_MS as T, userCustomizationTextSchema as _, AGENT_INVOCATION_EVENT_NAMESPACE as a, UPDATE_PLAN_TOOL_NAME as b, AGENT_REPLY_EVENT_TYPE as c, INLINE_VIDEO_TYPES as d, INPUT_IMAGE_TYPES as f, userCustomizationSchema as g, USER_CUSTOMIZATION_MAX_CHARS as h, AGENT_INVOCATION_STATUSES as i, trailingUtcDayWindow as j, startOfUtcHour as k, agentInvocationResultEventType as l, isVisionImageMediaType as m, AGENT_INVOCATION_MAILBOX_STATUSES as n, AGENT_MESSAGE_EVENT_TYPE as o, detectImageMediaType as p, AGENT_INVOCATION_PARENT_MAILBOX_STATUSES as r, AGENT_PARENT_MESSAGE_EVENT_TYPE as s, webMessageId as t, isAgentInvocationResultEventType as u, PLAN_ITEM_STATUSES as v, DAY_MS as w, isOpenPlanItemStatus as x, SELF_PLAN_ASSIGNEE as y };
@@ -1,12 +1,11 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
- import { Ct as countPendingConversationMessages, Nt as isFinalAttempt, Pt as isInvalidConversationRecordError, jt as hasConversationStop } from "./projection-jZSlEAXG.js";
3
- import { i as getChatConfig, nt as isProviderRetryError } from "./config-Dkt2Le2b.js";
4
- import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-D5gkyvnK.js";
5
- import { t as getConversationStoppedAtMs } from "./session-stop-BfY4rhJs.js";
6
- import { g as getTurnRequestDeadline } from "./task-queue-CaZffYaH.js";
7
- import { _ as ConversationQueueMessageRejectedError, b as nudgeIdempotencyKey } from "./background-compaction-queue-BGHqkhkY.js";
8
- import { C as requestAnotherSlice, S as releaseConversationWork, T as startConversationWork, _ as getConversationWorkState, b as recordAttemptFailure, c as clearConsumedConversationWake, d as completeConversationWork, f as deadLetterAttempt, h as ensureConversationWake, i as beginConversationResume, o as checkInConversationWork, p as drainConversationMailbox, t as ackMessages, u as completeConversationStop, x as recordConversationRetry } from "./store-D4FQ1Nml.js";
9
- import { Ln as isAttemptInterrupt, Rn as selectAttemptMessages } from "./warmup-C6LOZ2d2.js";
2
+ import { Ct as countPendingConversationMessages, Nt as isFinalAttempt, Pt as isInvalidConversationRecordError, jt as hasConversationStop } from "./projection-Cns7XwWa.js";
3
+ import { i as getChatConfig, pt as isProviderRetryError } from "./config-BrXDQefC.js";
4
+ import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-FjclQsXu.js";
5
+ import { Ur as getConversationStoppedAtMs, _r as isAttemptInterrupt, vr as selectAttemptMessages } from "./warmup-BWdHew2H.js";
6
+ import { g as getTurnRequestDeadline } from "./task-queue-C_zldF5J.js";
7
+ import { _ as ConversationQueueMessageRejectedError, b as nudgeIdempotencyKey } from "./background-compaction-queue-CJDnWVOJ.js";
8
+ import { C as requestAnotherSlice, S as releaseConversationWork, T as startConversationWork, _ as getConversationWorkState, b as recordAttemptFailure, c as clearConsumedConversationWake, d as completeConversationWork, f as deadLetterAttempt, h as ensureConversationWake, i as beginConversationResume, o as checkInConversationWork, p as drainConversationMailbox, t as ackMessages, u as completeConversationStop, x as recordConversationRetry } from "./store-DmmMIrQi.js";
10
9
  // src/chat/task-execution/lost-lease.ts
11
10
  /**
12
11
  * Count a slice that lost its Conversation Lease as a failed attempt, then
@@ -0,0 +1,8 @@
1
+ -- 0124 and 0125 (Junior 0.310.0) moved every reader and writer to
2
+ -- `visibility` and the public-row index. This drops what only older runtimes
3
+ -- used. A host that upgrades from before 0.310.0 straight past this release
4
+ -- fails image publishes and public artifact reads until the new runtime serves.
5
+ DROP INDEX "junior_artifacts_conversation_sha_uidx";--> statement-breakpoint
6
+ -- A write that omits `visibility` gets the narrowest audience, never public.
7
+ ALTER TABLE "junior_artifacts" ALTER COLUMN "visibility" SET DEFAULT 'conversation';--> statement-breakpoint
8
+ ALTER TABLE "junior_artifacts" DROP COLUMN "public";
@@ -0,0 +1,4 @@
1
+ ALTER TABLE "junior_artifacts" ADD COLUMN "path" text;--> statement-breakpoint
2
+ -- Every existing row is a public frozen copy with no path. NOT VALID skips
3
+ -- the scan under lock and still checks every new write.
4
+ ALTER TABLE "junior_artifacts" ADD CONSTRAINT "junior_artifacts_path_visibility_check" CHECK (("junior_artifacts"."path" is null) = ("junior_artifacts"."visibility" = 'public')) NOT VALID;
@@ -0,0 +1 @@
1
+ CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "junior_artifacts_conversation_path_uidx" ON "junior_artifacts" USING btree ("conversation_id","path");
@@ -0,0 +1 @@
1
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_review_items_answered_idx" ON "junior_review_items" USING btree ("added_by_conversation_id","closed_by_user_id","closed_at") WHERE "junior_review_items"."answer" is not null;
@@ -0,0 +1 @@
1
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_review_items_open_action_added_by_idx" ON "junior_review_items" USING btree ("added_by_conversation_id") WHERE "junior_review_items"."status" = 'open' and "junior_review_items"."kind" = 'action';
@@ -0,0 +1 @@
1
+ ALTER TABLE "junior_conversation_briefs" ADD COLUMN "outcome_status" text;
@@ -0,0 +1,7 @@
1
+ -- Rows that the runtime before this release writes during the rollout keep a
2
+ -- null status, and readers fall back to the content. This runs in its own
3
+ -- transaction, after the one that adds the column, so it holds no table lock
4
+ -- that blocks Brief reads or new Brief versions.
5
+ -- junior:bounded-backfill: Brief versions are append-only, so no app write changes these rows; only a cascade delete of a Conversation waits.
6
+ UPDATE "junior_conversation_briefs"
7
+ SET "outcome_status" = "content"->'outcome'->>'status';
@@ -0,0 +1 @@
1
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_conversation_briefs_created_at_idx" ON "junior_conversation_briefs" USING btree ("created_at","conversation_id");
@@ -0,0 +1 @@
1
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_identities_slack_person_search_idx" ON "junior_identities" USING gin (to_tsvector('simple', coalesce("display_name", '') || ' ' || coalesce("handle", ''))) WHERE "junior_identities"."provider" = 'slack' AND "junior_identities"."kind" = 'user';
@@ -0,0 +1,3 @@
1
+ ALTER TABLE "junior_code_changes" ADD COLUMN "additions" integer;--> statement-breakpoint
2
+ ALTER TABLE "junior_code_changes" ADD COLUMN "changed_files" integer;--> statement-breakpoint
3
+ ALTER TABLE "junior_code_changes" ADD COLUMN "deletions" integer;
@@ -0,0 +1,16 @@
1
+ -- The GitHub plugin now asks to resume merge conflict fixes with an action
2
+ -- item that has a Resume button. The old notices have no button, so this
3
+ -- dismisses the ones that are still open. The next check of a pull request
4
+ -- that is still stopped adds the new item. Like a dismiss when no agent can
5
+ -- act, it sends no message and does not change the Slack cards. A click on
6
+ -- an old card finds the item closed and updates the card.
7
+ -- junior:bounded-backfill: only open GitHub merge conflict notices, at most one per open Junior pull request, among open items, which the status index finds.
8
+ UPDATE "junior_review_items"
9
+ SET
10
+ "status" = 'dismissed',
11
+ "closed_at" = now(),
12
+ "close_reason" = 'Replaced by an item with a Resume button.',
13
+ "updated_at" = now()
14
+ WHERE "status" = 'open'
15
+ AND "kind" = 'notice'
16
+ AND "dedupe_key" LIKE 'plugin:github:merge-conflict:%';
@@ -0,0 +1,27 @@
1
+ CREATE TABLE "junior_inbox_snooze_triggers" (
2
+ "snooze_id" text NOT NULL,
3
+ "outcome" text NOT NULL,
4
+ "namespace" text NOT NULL,
5
+ "identifier" text NOT NULL,
6
+ "event_type" text NOT NULL,
7
+ "match" jsonb,
8
+ CONSTRAINT "junior_inbox_snooze_triggers_outcome_check" CHECK ("junior_inbox_snooze_triggers"."outcome" in ('wake', 'resolve'))
9
+ );
10
+ --> statement-breakpoint
11
+ CREATE TABLE "junior_inbox_snoozes" (
12
+ "id" text PRIMARY KEY NOT NULL,
13
+ "user_id" text NOT NULL,
14
+ "review_item_id" text NOT NULL,
15
+ "state" text NOT NULL,
16
+ "created_at" timestamp with time zone NOT NULL,
17
+ CONSTRAINT "junior_inbox_snoozes_state_check" CHECK ("junior_inbox_snoozes"."state" in ('snoozed', 'woken', 'cancelled'))
18
+ );
19
+ --> statement-breakpoint
20
+ ALTER TABLE "junior_inbox_snooze_triggers" ADD CONSTRAINT "junior_inbox_snooze_triggers_snooze_id_junior_inbox_snoozes_id_fk" FOREIGN KEY ("snooze_id") REFERENCES "public"."junior_inbox_snoozes"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
21
+ ALTER TABLE "junior_inbox_snoozes" ADD CONSTRAINT "junior_inbox_snoozes_user_id_junior_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."junior_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
22
+ ALTER TABLE "junior_inbox_snoozes" ADD CONSTRAINT "junior_inbox_snoozes_review_item_id_junior_review_items_id_fk" FOREIGN KEY ("review_item_id") REFERENCES "public"."junior_review_items"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
23
+ CREATE INDEX "junior_inbox_snooze_triggers_event_idx" ON "junior_inbox_snooze_triggers" USING btree ("namespace","identifier","event_type");--> statement-breakpoint
24
+ CREATE INDEX "junior_inbox_snooze_triggers_snooze_idx" ON "junior_inbox_snooze_triggers" USING btree ("snooze_id");--> statement-breakpoint
25
+ CREATE UNIQUE INDEX "junior_inbox_snoozes_snoozed_uidx" ON "junior_inbox_snoozes" USING btree ("user_id","review_item_id") WHERE "junior_inbox_snoozes"."state" = 'snoozed';--> statement-breakpoint
26
+ CREATE INDEX "junior_inbox_snoozes_settled_idx" ON "junior_inbox_snoozes" USING btree ("created_at") WHERE "junior_inbox_snoozes"."state" <> 'snoozed';--> statement-breakpoint
27
+ CREATE INDEX "junior_inbox_snoozes_review_item_idx" ON "junior_inbox_snoozes" USING btree ("review_item_id");
@@ -0,0 +1,2 @@
1
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_code_changes_search_idx" ON "junior_code_changes" USING gin (to_tsvector('simple', "number"::text || ' ' || coalesce("title", '')));--> statement-breakpoint
2
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_code_repositories_search_idx" ON "junior_code_repositories" USING gin (to_tsvector('simple', translate("name", '/', ' ')));
@@ -0,0 +1,22 @@
1
+ -- A Review item now names its owner: a Conversation, as before, or an
2
+ -- Automation for an Automation alert. Every existing item belongs to the
3
+ -- Conversation that added it, so the old column becomes the owner id, and
4
+ -- the default of the new kind column fills existing rows with
5
+ -- 'conversation'. A constant default writes no row. The owner id has no
6
+ -- foreign key, because it can name more than one table. Conversations are
7
+ -- never deleted, so no cascade is lost. An older runtime cannot write
8
+ -- Review items once this runs, until the new runtime serves.
9
+ ALTER TABLE "junior_review_items" RENAME COLUMN "added_by_conversation_id" TO "owner_id";--> statement-breakpoint
10
+ ALTER TABLE "junior_review_items" DROP CONSTRAINT "junior_review_items_added_by_conversation_id_junior_conversations_conversation_id_fk";--> statement-breakpoint
11
+ ALTER TABLE "junior_review_items" ADD COLUMN "owner_kind" text DEFAULT 'conversation' NOT NULL;--> statement-breakpoint
12
+ -- The index keeps its definition on the renamed column.
13
+ ALTER INDEX "junior_review_items_open_action_added_by_idx" RENAME TO "junior_review_items_open_action_owner_idx";--> statement-breakpoint
14
+ ALTER TABLE "junior_review_items" DROP CONSTRAINT "junior_review_items_kind_check";--> statement-breakpoint
15
+ -- Both checks hold for every existing row: each is a Conversation item, and
16
+ -- agents and plugins use no `automation:` key. NOT VALID skips the scan
17
+ -- under lock and still checks every new write.
18
+ ALTER TABLE "junior_review_items" ADD CONSTRAINT "junior_review_items_owner_check" CHECK (("junior_review_items"."owner_kind" = 'conversation' and "junior_review_items"."dedupe_key" not like 'automation:%') or ("junior_review_items"."owner_kind" = 'automation' and "junior_review_items"."dedupe_key" like 'automation:%')) NOT VALID;--> statement-breakpoint
19
+ ALTER TABLE "junior_review_items" ADD CONSTRAINT "junior_review_items_kind_check" CHECK (("junior_review_items"."kind" = 'notice' and "junior_review_items"."request" is null and "junior_review_items"."answer" is null) or ("junior_review_items"."kind" = 'action' and ("junior_review_items"."request" is not null or (("junior_review_items"."dedupe_key" like 'plugin:%' or "junior_review_items"."dedupe_key" like 'automation:%') and "junior_review_items"."answer" is null)))) NOT VALID;--> statement-breakpoint
20
+ -- A person's dismiss hides an Automation's alerts until core sees it
21
+ -- recover. Existing Automations have no dismissed alert, so null is right.
22
+ ALTER TABLE "junior_automations" ADD COLUMN "alert_recovered_at_ms" bigint;
@@ -0,0 +1 @@
1
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_review_items_owner_idx" ON "junior_review_items" USING btree ("owner_kind","owner_id");
@@ -0,0 +1,89 @@
1
+ -- Memory moved from the @sentry/junior-memory plugin into core. A database
2
+ -- that ran the plugin already has these tables. This migration keeps their
3
+ -- data and the plugin journal unchanged, and adds only the schema of plugin
4
+ -- migrations 0015 and 0016, which change no data. A fresh database gets the
5
+ -- final Memory schema. Columns keep the order that the plugin migrations made.
6
+ -- Stop on a database that did not run the plugin migrations through 0014, the
7
+ -- last one that changes data, so that those changes never run out of order.
8
+ -- The journal query is dynamic because PL/pgSQL plans a static query before
9
+ -- the to_regclass check runs.
10
+ DO $$
11
+ DECLARE
12
+ plugin_complete boolean;
13
+ BEGIN
14
+ IF to_regclass('drizzle.__drizzle_memory_c064fbca') IS NULL THEN
15
+ RETURN;
16
+ END IF;
17
+ EXECUTE 'SELECT EXISTS (
18
+ SELECT 1
19
+ FROM drizzle.__drizzle_memory_c064fbca
20
+ WHERE created_at >= 1793829580242
21
+ )' INTO plugin_complete;
22
+ IF NOT plugin_complete THEN
23
+ RAISE EXCEPTION 'The Memory plugin migrations are not complete. Run junior upgrade with @sentry/junior 0.310.0 and @sentry/junior-memory 0.310.0 first.';
24
+ END IF;
25
+ END $$;
26
+ --> statement-breakpoint
27
+ CREATE EXTENSION IF NOT EXISTS btree_gin;
28
+ --> statement-breakpoint
29
+ CREATE TABLE IF NOT EXISTS "junior_memory_memories" (
30
+ "id" text PRIMARY KEY NOT NULL,
31
+ "scope" text NOT NULL,
32
+ "scope_key" text NOT NULL,
33
+ "type" text NOT NULL,
34
+ "subject_type" text NOT NULL,
35
+ "subject_key" text,
36
+ "content" text NOT NULL,
37
+ "source_platform" text NOT NULL,
38
+ "source_key" text NOT NULL,
39
+ "idempotency_key" text,
40
+ "observed_at_ms" bigint NOT NULL,
41
+ "created_at_ms" bigint NOT NULL,
42
+ "expires_at_ms" bigint,
43
+ "superseded_at_ms" bigint,
44
+ "superseded_by_id" text,
45
+ "archived_at_ms" bigint,
46
+ "archive_reason" text,
47
+ "search_vector" "tsvector" GENERATED ALWAYS AS (to_tsvector('english', "content")) STORED,
48
+ "location_id" text,
49
+ "conversation_id" text,
50
+ CONSTRAINT "junior_memory_memories_scope_check" CHECK ("junior_memory_memories"."scope" IN ('private', 'public')),
51
+ CONSTRAINT "junior_memory_memories_kind_check" CHECK ("junior_memory_memories"."type" IN ('preference', 'procedure', 'knowledge')),
52
+ CONSTRAINT "junior_memory_memories_subject_type_check" CHECK ("junior_memory_memories"."subject_type" IN ('user', 'conversation', 'general')),
53
+ CONSTRAINT "junior_memory_memories_subject_key_check" CHECK (("junior_memory_memories"."subject_type" = 'general' AND "junior_memory_memories"."subject_key" IS NULL) OR ("junior_memory_memories"."subject_type" IN ('user', 'conversation') AND "junior_memory_memories"."subject_key" IS NOT NULL AND length("junior_memory_memories"."subject_key") > 0)),
54
+ CONSTRAINT "junior_memory_memories_source_platform_check" CHECK ("junior_memory_memories"."source_platform" IN ('slack', 'local', 'web'))
55
+ );
56
+ --> statement-breakpoint
57
+ CREATE TABLE IF NOT EXISTS "junior_memory_embeddings" (
58
+ "memory_id" text NOT NULL,
59
+ "provider" text NOT NULL,
60
+ "model" text NOT NULL,
61
+ "dimensions" integer NOT NULL,
62
+ "metric" text NOT NULL,
63
+ "content_hash" text NOT NULL,
64
+ "embedding" vector NOT NULL,
65
+ "created_at_ms" bigint NOT NULL,
66
+ CONSTRAINT "junior_memory_embeddings_memory_id_provider_model_pk" PRIMARY KEY("memory_id","provider","model"),
67
+ CONSTRAINT "junior_memory_embeddings_memory_id_junior_memory_memories_id_fk" FOREIGN KEY ("memory_id") REFERENCES "public"."junior_memory_memories"("id") ON DELETE cascade ON UPDATE no action,
68
+ CONSTRAINT "junior_memory_embeddings_metric_check" CHECK ("junior_memory_embeddings"."metric" IN ('cosine')),
69
+ CONSTRAINT "junior_memory_embeddings_dimensions_check" CHECK ("junior_memory_embeddings"."dimensions" IN (1024, 1536) AND vector_dims("junior_memory_embeddings"."embedding") = "junior_memory_embeddings"."dimensions")
70
+ );
71
+ --> statement-breakpoint
72
+ CREATE TABLE IF NOT EXISTS "junior_memory_signals" (
73
+ "memory_id" text NOT NULL,
74
+ "signal" text NOT NULL,
75
+ "idempotency_key" text NOT NULL,
76
+ "conversation_id" text,
77
+ "observed_at_ms" bigint NOT NULL,
78
+ CONSTRAINT "junior_memory_signals_memory_id_signal_idempotency_key_pk" PRIMARY KEY("memory_id","signal","idempotency_key"),
79
+ CONSTRAINT "junior_memory_signals_memory_id_junior_memory_memories_id_fk" FOREIGN KEY ("memory_id") REFERENCES "public"."junior_memory_memories"("id") ON DELETE cascade ON UPDATE no action,
80
+ CONSTRAINT "junior_memory_signals_signal_check" CHECK ("junior_memory_signals"."signal" IN ('duplicate', 'contradicted', 'superseded'))
81
+ );
82
+ --> statement-breakpoint
83
+ -- Plugin migration 0015 widened this check. Replace it here, so a database
84
+ -- that ran the plugin only through 0014 gets the same check, and every
85
+ -- database ends with the same constraint. The new check only allows more
86
+ -- values, so NOT VALID skips the scan and still checks every new write.
87
+ ALTER TABLE "junior_memory_signals" DROP CONSTRAINT IF EXISTS "junior_memory_signals_signal_check";
88
+ --> statement-breakpoint
89
+ ALTER TABLE "junior_memory_signals" ADD CONSTRAINT "junior_memory_signals_signal_check" CHECK ("junior_memory_signals"."signal" IN ('duplicate', 'contradicted', 'superseded')) NOT VALID;
@@ -0,0 +1,17 @@
1
+ -- The Memory indexes. A database that ran the Memory plugin has them already,
2
+ -- and IF NOT EXISTS skips them without a lock that blocks app writes.
3
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_memory_embeddings_model_idx" ON "junior_memory_embeddings" USING btree ("provider","model","dimensions","metric");
4
+ --> statement-breakpoint
5
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_memory_embeddings_embedding_1024_hnsw_idx" ON "junior_memory_embeddings" USING hnsw (("embedding"::vector(1024)) vector_cosine_ops) WITH (m=16,ef_construction=64) WHERE "junior_memory_embeddings"."dimensions" = 1024;
6
+ --> statement-breakpoint
7
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_memory_memories_visible_idx" ON "junior_memory_memories" USING btree ("scope","scope_key","created_at_ms" DESC NULLS LAST,"id") WHERE "junior_memory_memories"."archived_at_ms" IS NULL AND "junior_memory_memories"."superseded_at_ms" IS NULL AND "junior_memory_memories"."superseded_by_id" IS NULL;
8
+ --> statement-breakpoint
9
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_memory_memories_expiration_idx" ON "junior_memory_memories" USING btree ("expires_at_ms") WHERE "junior_memory_memories"."archived_at_ms" IS NULL AND "junior_memory_memories"."expires_at_ms" IS NOT NULL;
10
+ --> statement-breakpoint
11
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_memory_memories_search_idx" ON "junior_memory_memories" USING gin ("scope","scope_key","search_vector") WHERE "junior_memory_memories"."archived_at_ms" IS NULL AND "junior_memory_memories"."superseded_at_ms" IS NULL AND "junior_memory_memories"."superseded_by_id" IS NULL;
12
+ --> statement-breakpoint
13
+ CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "junior_memory_memories_idempotency_idx" ON "junior_memory_memories" USING btree ("scope","scope_key","idempotency_key") WHERE "junior_memory_memories"."idempotency_key" IS NOT NULL AND "junior_memory_memories"."archived_at_ms" IS NULL AND "junior_memory_memories"."superseded_at_ms" IS NULL AND "junior_memory_memories"."superseded_by_id" IS NULL;
14
+ --> statement-breakpoint
15
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_memory_memories_archived_idempotency_idx" ON "junior_memory_memories" USING btree ("scope","scope_key","idempotency_key") WHERE "junior_memory_memories"."idempotency_key" IS NOT NULL AND "junior_memory_memories"."archived_at_ms" IS NOT NULL AND "junior_memory_memories"."archive_reason" <> 'expired';
16
+ --> statement-breakpoint
17
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_memory_signals_observed_idx" ON "junior_memory_signals" USING btree ("memory_id","signal","observed_at_ms");