@sentry/junior 0.301.0 → 0.302.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 (79) hide show
  1. package/dist/adapter-context-Cx9fn9B3.js +43 -0
  2. package/dist/{admin-CRJHvCGg.js → admin-_poE5NKL.js} +2 -2
  3. package/dist/{agent-runner-H4YhvNBj.js → agent-runner-CY9RvsTX.js} +1380 -10601
  4. package/dist/api/schema.d.ts +2 -2
  5. package/dist/api/schema.js +4 -5
  6. package/dist/api.d.ts +1 -1
  7. package/dist/api.js +91 -68
  8. package/dist/{app-HDZglaIu.d.ts → app-BpY3wtRP.d.ts} +2 -2
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +66 -296
  11. package/dist/{background-compaction-queue-CNrZ3QcU.js → background-compaction-queue-CXFq1_Cz.js} +94 -203
  12. package/dist/{briefs-x6Mzwxmg.js → briefs-B3NG-pid.js} +2 -2
  13. package/dist/{catalog-runtime-BEY6EGRi.js → catalog-runtime-Dss0lSV6.js} +1 -1
  14. package/dist/cli/chat.js +15 -15
  15. package/dist/cli/check.js +3 -3
  16. package/dist/cli/main.js +3 -3
  17. package/dist/cli/plugins.js +4 -4
  18. package/dist/cli/snapshot-create.js +4 -4
  19. package/dist/cli/upgrade.d.ts +1 -1
  20. package/dist/cli/upgrade.js +3 -3
  21. package/dist/{config-CmjhyqgB.js → config-CzeZiMKs.js} +2 -2
  22. package/dist/{connections-CfIRm0xv.js → connections-CDYhMfrs.js} +6 -6
  23. package/dist/{continue-in-slack-DPoABVkB.js → continue-in-slack-7Uf05ndC.js} +5 -6
  24. package/dist/{conversation-feed-CfpyFMHP.js → conversation-feed-Clf_cv0n.js} +1 -0
  25. package/dist/{conversation-privacy-0CM0V2qK.js → conversation-privacy-D9xnM5mK.js} +1 -1
  26. package/dist/{conversation-turn-C0sxyvS-.js → conversation-turn-D7SEZgTG.js} +15 -16
  27. package/dist/{credential-sync-tEMKZ_8M.js → credential-sync-DoD0gW-j.js} +13 -15
  28. package/dist/{db-Czra10QW.js → db-B-gtnNjr.js} +314 -5
  29. package/dist/{db-BdUHQhrC.d.ts → db-BdsCzytP.d.ts} +1 -1
  30. package/dist/{executor-D_023K0H.js → executor-DZg20EqU.js} +39 -4
  31. package/dist/install-t1KQyTUs.js +228 -0
  32. package/dist/instrumentation.js +2 -2
  33. package/dist/{state-CEbZuZD6.js → legacy-web-actor-id-C-cEeWqL.js} +33 -4
  34. package/dist/{lineage-DmMIE0VL.js → lineage-C79GjoQr.js} +2 -2
  35. package/dist/{logging-DcjLDDqi.js → logging-C9oDAg4M.js} +7 -3
  36. package/dist/{message-C0JY9RJP.js → message-BLUCzJXN.js} +8 -8
  37. package/dist/{model-input-CBp-p24N.js → model-input-5jwNC45G.js} +3 -3
  38. package/dist/nitro.d.ts +1 -1
  39. package/dist/nitro.js +4 -3
  40. package/dist/{oauth-callback-server-BRq9QNhU.js → oauth-callback-server-BBl66vCb.js} +2 -2
  41. package/dist/{projection-CQNDOi82.js → projection-CIBwgD3s.js} +282 -64
  42. package/dist/{prompt-DLUB5m72.js → prompt-CRQbzp5e.js} +14 -4
  43. package/dist/queue-DtCDaIct.js +115 -0
  44. package/dist/{registry-Dj377ADs.js → registry-DdFQHZ_d.js} +1 -1
  45. package/dist/{resolve-DJkh9Fky.js → resolve-CdW4BdrK.js} +4 -229
  46. package/dist/{result-C8iIpDl1.js → result-oOMv1t4O.js} +9 -9
  47. package/dist/{runner-DZqrOy8C.js → runner-DqitLtm-.js} +8 -8
  48. package/dist/{sandbox-egress-signals-CGwH86S9.js → sandbox-egress-signals-Bw9I0yfJ.js} +1 -1
  49. package/dist/{schema-CdZFn7Qd.d.ts → schema-BIFM-U1a.d.ts} +441 -30
  50. package/dist/{schema-DyHXiQKI.js → schema-DnVQepWP.js} +66 -29
  51. package/dist/{service-account-D6jGR4a1.js → service-account-B6mKAPVo.js} +3 -3
  52. package/dist/{service-account-suY004dx.js → service-account-CrZftRTb.js} +257 -6
  53. package/dist/{session-stop-BLmfFI3d.js → session-stop-DW63Z3kj.js} +543 -548
  54. package/dist/{skills-CmNG0dHb.js → skills-C16fz60Z.js} +2 -2
  55. package/dist/{slack-conversation-unfurl-Bty-DlHe.js → slack-conversation-unfurl-BHhefEb7.js} +8 -7
  56. package/dist/{spawn-CNjkpXpk.js → spawn-D_RnFYfy.js} +6 -6
  57. package/dist/{stop-Bjy2-K4H.js → stop-7p1i08CY.js} +724 -106
  58. package/dist/{store-DmV4CoNr.js → store-C28I0CVW.js} +5 -5
  59. package/dist/{task-queue-AhG1tSXR.js → task-queue-BVUJbQ28.js} +3 -3
  60. package/dist/{task-runner-BMxZI3o7.js → task-runner-CWi8j7Z6.js} +6 -8
  61. package/dist/{thread-context-CXLnbg7g.js → thread-context-D3-yYUd0.js} +7 -7
  62. package/dist/{store-Epv6t4vV.js → turn-session-routing-BFMS9ATF.js} +381 -10
  63. package/dist/{turn-user-message-DsUZi9gn.js → turn-user-message-C3-O8Omt.js} +3 -3
  64. package/dist/{validation-DOz8X9BU.js → validation-BSFKUIb4.js} +1 -1
  65. package/dist/{version-CGMRmMPK.js → version-BHHXNi-0.js} +1 -1
  66. package/dist/version.js +1 -1
  67. package/dist/{viewer-H3EsMWtJ.js → viewer-B1SO21Qa.js} +3 -3
  68. package/dist/warmup-Bz9bzkzN.js +13927 -0
  69. package/dist/{statuses-Hn-HsOph.js → web-message-id-lNodcCOI.js} +136 -1
  70. package/dist/{worker-ClphajjD.js → worker-BspReIIK.js} +7 -7
  71. package/migrations/0108_conversation_embeddings.sql +13 -0
  72. package/migrations/meta/0108_snapshot.json +4688 -0
  73. package/migrations/meta/_journal.json +7 -0
  74. package/package.json +8 -6
  75. package/dist/adapter-CNjGEJO9.js +0 -303
  76. package/dist/reporting-window-DopzcOHh.js +0 -137
  77. package/dist/turn-session-routing-BD3-jJl7.js +0 -380
  78. package/dist/users-BxvYclQg.js +0 -424
  79. package/dist/warmup-CdU5hR49.js +0 -3715
@@ -1,4 +1,130 @@
1
1
  import * as z from "zod";
2
+ // src/api/reporting-window.ts
3
+ /** Shared UTC day/hour/six-hour windows for dashboard activity series. */
4
+ const HOUR_MS = 36e5;
5
+ const SIX_HOUR_MS = 6 * HOUR_MS;
6
+ const DAY_MS = 24 * HOUR_MS;
7
+ /** Start of the UTC calendar day containing `valueMs`. */
8
+ function startOfUtcDay(valueMs) {
9
+ const date = new Date(valueMs);
10
+ date.setUTCHours(0, 0, 0, 0);
11
+ return date;
12
+ }
13
+ /** Start of the UTC hour containing `valueMs`. */
14
+ function startOfUtcHour(valueMs) {
15
+ const date = new Date(valueMs);
16
+ date.setUTCMinutes(0, 0, 0);
17
+ return date;
18
+ }
19
+ /** Start of the UTC 6-hour bucket containing `valueMs` (00/06/12/18). */
20
+ function startOfUtcSixHour(valueMs) {
21
+ const date = startOfUtcHour(valueMs);
22
+ date.setUTCHours(Math.floor(date.getUTCHours() / 6) * 6, 0, 0, 0);
23
+ return date;
24
+ }
25
+ /** UTC day key `YYYY-MM-DD`. */
26
+ function utcDayKey(value) {
27
+ return (typeof value === "number" ? new Date(value) : value).toISOString().slice(0, 10);
28
+ }
29
+ /** UTC hour key `YYYY-MM-DDTHH`. */
30
+ function utcHourKey(value) {
31
+ return (typeof value === "number" ? new Date(value) : value).toISOString().slice(0, 13);
32
+ }
33
+ /** UTC 6-hour bucket key `YYYY-MM-DDTHH` at 00/06/12/18. */
34
+ function utcSixHourKey(value) {
35
+ return utcHourKey(startOfUtcSixHour(typeof value === "number" ? value : value.getTime()));
36
+ }
37
+ /** Inclusive trailing UTC day window ending on today's UTC day. */
38
+ function trailingUtcDayWindow(nowMs, dayCount) {
39
+ const end = startOfUtcDay(nowMs);
40
+ const start = new Date(end);
41
+ start.setUTCDate(start.getUTCDate() - (dayCount - 1));
42
+ return {
43
+ end,
44
+ start
45
+ };
46
+ }
47
+ /** Inclusive trailing UTC hour window ending on the current UTC hour. */
48
+ function trailingUtcHourWindow(nowMs, hourCount = 24) {
49
+ const end = startOfUtcHour(nowMs);
50
+ return {
51
+ end,
52
+ start: /* @__PURE__ */ new Date(end.getTime() - (hourCount - 1) * HOUR_MS)
53
+ };
54
+ }
55
+ /** Inclusive trailing UTC 6-hour window ending on the current 6h bucket. */
56
+ function trailingUtcSixHourWindow(nowMs, bucketCount = 28) {
57
+ const end = startOfUtcSixHour(nowMs);
58
+ return {
59
+ end,
60
+ start: /* @__PURE__ */ new Date(end.getTime() - (bucketCount - 1) * SIX_HOUR_MS)
61
+ };
62
+ }
63
+ /** Fill a fixed UTC day window from a sparse map. */
64
+ function fillUtcDays(args) {
65
+ const { end, start } = trailingUtcDayWindow(args.nowMs, args.count);
66
+ const items = [];
67
+ for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setUTCDate(cursor.getUTCDate() + 1)) {
68
+ const date = utcDayKey(cursor);
69
+ items.push(args.rows.get(date) ?? args.empty(date));
70
+ }
71
+ return items;
72
+ }
73
+ /** Fill a fixed UTC hour window from a sparse map. */
74
+ function fillUtcHours(args) {
75
+ const hourCount = args.count ?? 24;
76
+ const { end, start } = trailingUtcHourWindow(args.nowMs, hourCount);
77
+ const items = [];
78
+ for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setTime(cursor.getTime() + HOUR_MS)) {
79
+ const date = utcHourKey(cursor);
80
+ items.push(args.rows.get(date) ?? args.empty(date));
81
+ }
82
+ return items;
83
+ }
84
+ /** Fill a fixed UTC 6-hour window from a map of known rows. */
85
+ function fillUtcSixHours(args) {
86
+ const bucketCount = args.count ?? 28;
87
+ const { end, start } = trailingUtcSixHourWindow(args.nowMs, bucketCount);
88
+ const items = [];
89
+ for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setTime(cursor.getTime() + SIX_HOUR_MS)) {
90
+ const date = utcSixHourKey(cursor);
91
+ items.push(args.rows.get(date) ?? args.empty(date));
92
+ }
93
+ return items;
94
+ }
95
+ /**
96
+ * Sum hour rows into trailing 6-hour buckets.
97
+ * Adds number fields. Keeps other fields from the first row in the bucket.
98
+ * Sets `date` to the 6-hour bucket key.
99
+ */
100
+ function sumUtcHoursIntoSixHours(args) {
101
+ const bucketCount = args.count ?? 28;
102
+ const bySix = /* @__PURE__ */ new Map();
103
+ for (const hour of args.hours) {
104
+ const key = utcSixHourKey(Date.parse(`${hour.date}:00:00.000Z`));
105
+ const next = {
106
+ ...bySix.get(key) ?? args.empty(key),
107
+ date: key
108
+ };
109
+ for (const [field, value] of Object.entries(hour)) {
110
+ if (field === "date") continue;
111
+ if (typeof value === "number") {
112
+ const prior = next[field];
113
+ next[field] = (typeof prior === "number" ? prior : 0) + value;
114
+ }
115
+ }
116
+ bySix.set(key, next);
117
+ }
118
+ return fillUtcSixHours({
119
+ count: bucketCount,
120
+ empty: args.empty,
121
+ nowMs: args.nowMs,
122
+ rows: bySix
123
+ });
124
+ }
125
+ // src/api/schema/common.ts
126
+ /** Stable error body returned by Junior-owned REST endpoints. */
127
+ const apiErrorSchema = z.object({ error: z.string().min(1) }).strict();
2
128
  // src/chat/agent-invocations/result-event-type.ts
3
129
  /** Event namespace of the messages between a parent and its child agents. */
4
130
  const AGENT_INVOCATION_EVENT_NAMESPACE = "junior";
@@ -265,4 +391,13 @@ const AGENT_INVOCATION_PARENT_MAILBOX_STATUSES = [
265
391
  "skipped",
266
392
  "steered"
267
393
  ];
268
- export { isAgentInvocationResultEventType as C, agentInvocationResultEventType as S, userCustomizationTextSchema as _, USER_INPUT_NOTE as a, AGENT_PARENT_MESSAGE_EVENT_TYPE as b, isEmptyUserInputAnswer as c, INLINE_VIDEO_TYPES as d, INPUT_IMAGE_TYPES as f, userCustomizationSchema as g, USER_CUSTOMIZATION_MAX_CHARS as h, USER_INPUT_LIMITS as i, normalizeUserInputAnswer as l, isVisionImageMediaType as m, AGENT_INVOCATION_PARENT_MAILBOX_STATUSES as n, buttonUserInputField as o, detectImageMediaType as p, AGENT_INVOCATION_STATUSES as r, formatUserInputAnswer as s, AGENT_INVOCATION_MAILBOX_STATUSES as t, userInputRequestSchema as u, AGENT_INVOCATION_EVENT_NAMESPACE as v, AGENT_REPLY_EVENT_TYPE as x, AGENT_MESSAGE_EVENT_TYPE as y };
394
+ // src/chat/conversations/web-message-id.ts
395
+ /**
396
+ * Build the retry-stable Message id shared by web ingress and browser sends.
397
+ * Keep the existing hash and prefix so retries still address stored Messages.
398
+ */
399
+ async function webMessageId(args) {
400
+ const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(`${args.conversationId}\u0000${args.idempotencyKey}`));
401
+ return `api-msg:${Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("").slice(0, 24)}`;
402
+ }
403
+ export { fillUtcSixHours as A, agentInvocationResultEventType as C, HOUR_MS as D, DAY_MS as E, trailingUtcSixHourWindow as F, utcDayKey as I, utcHourKey as L, sumUtcHoursIntoSixHours as M, trailingUtcDayWindow as N, fillUtcDays as O, trailingUtcHourWindow as P, AGENT_REPLY_EVENT_TYPE as S, apiErrorSchema as T, userCustomizationSchema as _, USER_INPUT_LIMITS as a, AGENT_MESSAGE_EVENT_TYPE 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, startOfUtcHour as j, fillUtcHours 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, isAgentInvocationResultEventType as w, AGENT_PARENT_MESSAGE_EVENT_TYPE as x, AGENT_INVOCATION_EVENT_NAMESPACE as y };
@@ -1,11 +1,11 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { Ct as countPendingConversationMessages, Nt as isFinalAttempt, Pt as isInvalidConversationRecordError, jt as hasConversationStop } from "./projection-CQNDOi82.js";
3
- import { i as getChatConfig, q as isProviderRetryError } from "./config-CmjhyqgB.js";
4
- import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-DcjLDDqi.js";
5
- import { t as getConversationStoppedAtMs } from "./session-stop-BLmfFI3d.js";
6
- import { bt as isAttemptInterrupt, xt as selectAttemptMessages } from "./warmup-CdU5hR49.js";
7
- import { T as getTurnRequestDeadline, f as ConversationQueueMessageRejectedError, h as nudgeIdempotencyKey } from "./background-compaction-queue-CNrZ3QcU.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-DmV4CoNr.js";
2
+ import { Ct as countPendingConversationMessages, Nt as isFinalAttempt, Pt as isInvalidConversationRecordError, jt as hasConversationStop } from "./projection-CIBwgD3s.js";
3
+ import { i as getChatConfig, q as isProviderRetryError } from "./config-CzeZiMKs.js";
4
+ import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-C9oDAg4M.js";
5
+ import { t as getConversationStoppedAtMs } from "./session-stop-DW63Z3kj.js";
6
+ import { Bn as selectAttemptMessages, zn as isAttemptInterrupt } from "./warmup-Bz9bzkzN.js";
7
+ import { _ as nudgeIdempotencyKey, m as ConversationQueueMessageRejectedError, p as getTurnRequestDeadline } from "./background-compaction-queue-CXFq1_Cz.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-C28I0CVW.js";
9
9
  // src/chat/task-execution/lost-lease.ts
10
10
  /**
11
11
  * Count a slice that lost its Conversation Lease as a failed attempt, then
@@ -0,0 +1,13 @@
1
+ CREATE EXTENSION IF NOT EXISTS vector;--> statement-breakpoint
2
+ CREATE TABLE "junior_conversation_embeddings" (
3
+ "conversation_id" text PRIMARY KEY NOT NULL,
4
+ "brief_version" integer NOT NULL,
5
+ "provider" text NOT NULL,
6
+ "model" text NOT NULL,
7
+ "dimensions" integer NOT NULL,
8
+ "embedding" vector NOT NULL,
9
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
10
+ CONSTRAINT "junior_conversation_embeddings_dimensions_check" CHECK (vector_dims("junior_conversation_embeddings"."embedding") = "junior_conversation_embeddings"."dimensions")
11
+ );
12
+ --> statement-breakpoint
13
+ ALTER TABLE "junior_conversation_embeddings" ADD CONSTRAINT "junior_conversation_embeddings_brief_fk" FOREIGN KEY ("conversation_id","brief_version") REFERENCES "public"."junior_conversation_briefs"("conversation_id","version") ON DELETE cascade ON UPDATE no action;