@sentry/junior 0.310.0 → 0.312.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 (157) hide show
  1. package/dist/{adapter-context-BhKpjpGD.js → adapter-context-BRjEWRy1.js} +2 -2
  2. package/dist/adapter-iIq7ihf7.js +259 -0
  3. package/dist/{admin-tgZEZAk2.js → admin-DhInw5K9.js} +1 -2
  4. package/dist/{agent-runner-D9cvNlQl.js → agent-runner-C9iDurwX.js} +6507 -7721
  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 +1625 -535
  9. package/dist/{app-B_7Wn0en.d.ts → app-DRFrC8Mw.d.ts} +14 -10
  10. package/dist/app.d.ts +2 -2
  11. package/dist/app.js +454 -994
  12. package/dist/{background-compaction-queue-BGHqkhkY.js → background-compaction-queue-DrKi7w3d.js} +10 -85
  13. package/dist/callback-mFlTUWWx.js +75 -0
  14. package/dist/{catalog-runtime-BxwzbLKY.js → catalog-runtime-D7xapBAX.js} +1 -1
  15. package/dist/channel-access-CJGfNTdn.js +221 -0
  16. package/dist/child-message-DcsritGf.js +179 -0
  17. package/dist/cli/chat.js +18 -19
  18. package/dist/cli/check.js +23 -29
  19. package/dist/cli/init.js +1 -7
  20. package/dist/cli/main.js +3 -7
  21. package/dist/cli/plugins.js +8 -7
  22. package/dist/cli/run.d.ts +1 -2
  23. package/dist/cli/run.js +1 -2
  24. package/dist/cli/snapshot-create.js +5 -5
  25. package/dist/cli/upgrade.d.ts +1 -1
  26. package/dist/cli/upgrade.js +3 -3
  27. package/dist/{config-Dkt2Le2b.js → config-kXB2Y5tl.js} +294 -28
  28. package/dist/{continue-in-slack-BWVwePKD.js → continue-in-slack-O6pV5004.js} +7 -7
  29. package/dist/{conversation-feed-Ci6YD1N-.js → conversation-feed-uNOv_x68.js} +87 -24
  30. package/dist/{conversation-privacy-C39g8BY4.js → conversation-privacy-L4ja1_W6.js} +1 -1
  31. package/dist/{conversation-turn-CBlZIH02.js → conversation-turn-CeLbHqdw.js} +56 -49
  32. package/dist/{credential-sync-vGnrB0BY.js → credential-sync-I8VBGk05.js} +16 -16
  33. package/dist/{projection-jZSlEAXG.js → credentialed-Cb6E2phL.js} +16268 -16821
  34. package/dist/{db-B4Hjxr-u.d.ts → db-BbC5stfa.d.ts} +13 -6
  35. package/dist/{db-CFZggNoy.js → db-LAyyX8tk.js} +1698 -1046
  36. package/dist/{executor-BPkZDx5-.js → executor-SCub-fAq.js} +552 -181
  37. package/dist/{html-2r2KmLwi.js → html-BCZ3Xtb_.js} +6 -6
  38. package/dist/{session-stop-BfY4rhJs.js → ingest-BDf3D50j.js} +2134 -2553
  39. package/dist/{install-C-oE6C_u.js → install-DCFJFkC0.js} +2 -2
  40. package/dist/instrumentation.js +4 -4
  41. package/dist/{lineage-CsvrEFQe.js → lineage-B_m-4TJw.js} +2 -2
  42. package/dist/{stop-DYzjRf2U.js → list-CN2QA2R9.js} +1656 -685
  43. package/dist/{logging-D5gkyvnK.js → logging-dQ9ZRGQ8.js} +47 -9
  44. package/dist/media-CYm1QD8T.js +2356 -0
  45. package/dist/{message-DwvJ-I3w.js → message-DSXGj1hM.js} +19 -29
  46. package/dist/{model-input-MAq2881y.js → model-input--TrP9hYV.js} +3 -3
  47. package/dist/nitro.d.ts +1 -1
  48. package/dist/nitro.js +4 -3
  49. package/dist/{oauth-callback-server-DIF6Li06.js → oauth-callback-server-DHCZC6B4.js} +2 -2
  50. package/dist/{oauth-relay-DPE-wrwO.js → oauth-relay-pPMGnDZt.js} +1 -1
  51. package/dist/{registry-BBkWFCl8.js → registry-CZOzddwu.js} +5 -8
  52. package/dist/{resolve-B38MkHXE.js → resolve-cKOQ14Dh.js} +3 -3
  53. package/dist/{result-BaqSZcJb.js → result-DcvEOe1r.js} +119 -93
  54. package/dist/result-event-type-BdIJuZxg.js +48 -0
  55. package/dist/rule-DAxQY-1h.js +20 -0
  56. package/dist/{runner-11h8PrHh.js → runner-DBfUW44l.js} +14 -16
  57. package/dist/{sandbox-egress-signals-CTcACAtJ.js → sandbox-egress-signals-BVF_xAm1.js} +1 -1
  58. package/dist/{schema-DriSvB40.d.ts → schema-BEHKxr4I.d.ts} +861 -298
  59. package/dist/{schema-obw5jvR4.js → schema-Bk9Nm2E8.js} +344 -153
  60. package/dist/{service-account-Bx93N1n1.js → service-account-CVYsFjty.js} +3 -3
  61. package/dist/{service-account-Zc5bUcIJ.js → service-account-Ts4ulcrV.js} +68 -68
  62. package/dist/{skills-C8Npu5zO.js → skills-VTnhAJWm.js} +2 -2
  63. package/dist/{slack-conversation-unfurl-DlRVA02H.js → slack-conversation-unfurl-fuLnF1jE.js} +9 -11
  64. package/dist/{spawn-CXr58R0x.js → spawn-vxAarlX5.js} +6 -6
  65. package/dist/start-conversation-CEn2KH1A.js +941 -0
  66. package/dist/{state-CGrGVeQC.js → state-C1P3_Ywk.js} +4 -4
  67. package/dist/statuses-_cRJHXK7.js +150 -0
  68. package/dist/store-DFZaN-Ix.js +492 -0
  69. package/dist/task-queue-Cx4Lmjyk.js +90 -0
  70. package/dist/task-runner-CbTwFA6k.js +1432 -0
  71. package/dist/{thread-context-Dyj1KWaY.js → thread-context-BkAZDTX2.js} +13 -11
  72. package/dist/thread-state-DhPndWi1.js +5625 -0
  73. package/dist/{validation-DxVNIxA0.js → validation-nIzMtAVJ.js} +1 -1
  74. package/dist/{task-queue-CaZffYaH.js → vercel-queue-hW90XzbG.js} +93 -172
  75. package/dist/{version-Cr7Z71yG.js → version-Brbtz4Qf.js} +1 -1
  76. package/dist/version.js +1 -1
  77. package/dist/{warmup-C6LOZ2d2.js → warmup-BDA5myRK.js} +5832 -4567
  78. package/dist/web-message-id-C6P83ans.js +10 -0
  79. package/dist/{worker-CUBtu1Li.js → worker-D63RcaVD.js} +20 -8
  80. package/migrations/0126_artifact_drop_public.sql +8 -0
  81. package/migrations/0127_artifact_path.sql +4 -0
  82. package/migrations/0128_artifact_path_index.sql +1 -0
  83. package/migrations/0129_review_item_answered_index.sql +1 -0
  84. package/migrations/0130_review_item_status_index.sql +1 -0
  85. package/migrations/0131_brief_outcome_status.sql +1 -0
  86. package/migrations/0132_brief_outcome_status_backfill.sql +7 -0
  87. package/migrations/0133_brief_created_at_index.sql +1 -0
  88. package/migrations/0134_slack_person_search_index.sql +1 -0
  89. package/migrations/0135_code_change_size.sql +3 -0
  90. package/migrations/0136_merge_conflict_notice_dismiss.sql +16 -0
  91. package/migrations/0137_inbox_snoozes.sql +27 -0
  92. package/migrations/0138_code_change_search_index.sql +2 -0
  93. package/migrations/0139_review_item_owner.sql +22 -0
  94. package/migrations/0140_review_item_owner_index.sql +1 -0
  95. package/migrations/0141_memory_core_adoption.sql +89 -0
  96. package/migrations/0142_memory_core_indexes.sql +17 -0
  97. package/migrations/0143_todos.sql +14 -0
  98. package/migrations/0144_inbox_items.sql +32 -0
  99. package/migrations/0145_todo_changed_by_agent.sql +1 -0
  100. package/migrations/0146_inbox_item_subject_title_parts.sql +1 -0
  101. package/migrations/0147_inbox_snooze_wake_reason.sql +1 -0
  102. package/migrations/0148_authorization_request_index.sql +1 -0
  103. package/migrations/0149_conversation_metadata.sql +10 -0
  104. package/migrations/0150_conversation_metadata_fill.sql +39 -0
  105. package/migrations/0151_conversation_search_index.sql +1 -0
  106. package/migrations/0152_inbox_item_legacy_automation_keys.sql +21 -0
  107. package/migrations/0153_artifact_expiry.sql +1 -0
  108. package/migrations/0154_artifact_permanent_sha_index.sql +1 -0
  109. package/migrations/0155_artifact_drop_public_sha_index.sql +3 -0
  110. package/migrations/0156_conversation_kind_lead.sql +6 -0
  111. package/migrations/0157_conversation_lead_actor_index.sql +1 -0
  112. package/migrations/meta/0126_snapshot.json +5488 -0
  113. package/migrations/meta/0127_snapshot.json +5519 -0
  114. package/migrations/meta/0128_snapshot.json +5519 -0
  115. package/migrations/meta/0129_snapshot.json +5547 -0
  116. package/migrations/meta/0130_snapshot.json +5563 -0
  117. package/migrations/meta/0131_snapshot.json +5569 -0
  118. package/migrations/meta/0132_snapshot.json +5569 -0
  119. package/migrations/meta/0133_snapshot.json +5590 -0
  120. package/migrations/meta/0134_snapshot.json +5606 -0
  121. package/migrations/meta/0135_snapshot.json +5624 -0
  122. package/migrations/meta/0136_snapshot.json +5624 -0
  123. package/migrations/meta/0137_snapshot.json +5864 -0
  124. package/migrations/meta/0138_snapshot.json +5894 -0
  125. package/migrations/meta/0139_snapshot.json +5898 -0
  126. package/migrations/meta/0140_snapshot.json +5919 -0
  127. package/migrations/meta/0141_snapshot.json +6429 -0
  128. package/migrations/meta/0142_snapshot.json +6457 -0
  129. package/migrations/meta/0143_snapshot.json +6434 -0
  130. package/migrations/meta/0144_snapshot.json +6434 -0
  131. package/migrations/meta/0145_snapshot.json +6440 -0
  132. package/migrations/meta/0146_snapshot.json +6446 -0
  133. package/migrations/meta/0147_snapshot.json +6452 -0
  134. package/migrations/meta/0148_snapshot.json +6474 -0
  135. package/migrations/meta/0149_snapshot.json +6490 -0
  136. package/migrations/meta/0150_snapshot.json +6490 -0
  137. package/migrations/meta/0151_snapshot.json +6505 -0
  138. package/migrations/meta/0152_snapshot.json +6505 -0
  139. package/migrations/meta/0153_snapshot.json +6511 -0
  140. package/migrations/meta/0154_snapshot.json +6533 -0
  141. package/migrations/meta/0155_snapshot.json +6511 -0
  142. package/migrations/meta/0156_snapshot.json +6511 -0
  143. package/migrations/meta/0157_snapshot.json +6527 -0
  144. package/migrations/meta/_journal.json +224 -0
  145. package/package.json +7 -8
  146. package/skills/design-automation-skill/SKILL.md +108 -0
  147. package/dist/briefs-DKxkoruh.js +0 -395
  148. package/dist/conversation-M9KZ5JxF.js +0 -1024
  149. package/dist/prompt-CaMyeCpA.js +0 -910
  150. package/dist/schedule-DWxZ3kja.js +0 -1146
  151. package/dist/store-D4FQ1Nml.js +0 -335
  152. package/dist/task-runner-Dm7BHbGp.js +0 -287
  153. package/dist/turn-session-routing-CD0BRCex.js +0 -263
  154. package/dist/turn-user-message-9IxeEv5v.js +0 -364
  155. package/dist/users-CaUAYMb3.js +0 -181
  156. package/dist/viewer-AHldghAD.js +0 -212
  157. package/dist/web-message-id-BT8Mg8LL.js +0 -418
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
- import { n as pluginCatalogRuntime } from "./catalog-runtime-BxwzbLKY.js";
2
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-D7xapBAX.js";
3
3
  import { isDeepStrictEqual } from "node:util";
4
4
  // src/chat/plugins/validation.ts
5
5
  var validation_exports = /* @__PURE__ */ __exportAll({
@@ -1,11 +1,27 @@
1
- import { h as logWarn, m as logInfo, p as logException } from "./logging-D5gkyvnK.js";
2
- import { i as getChatConfig } from "./config-Dkt2Le2b.js";
1
+ import { E as withSpan, m as logInfo, p as logException } from "./logging-dQ9ZRGQ8.js";
2
+ import { r as getChatConfig } from "./config-kXB2Y5tl.js";
3
3
  import "./fan-out-Cod-yEHG.js";
4
4
  import * as z from "zod";
5
5
  import pLimit from "p-limit";
6
- import { AsyncLocalStorage } from "node:async_hooks";
7
6
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
8
7
  import { QueueClient, handleCallback, registerDevConsumer } from "@vercel/queue";
8
+ // src/chat/secrets.ts
9
+ /** Read the server secret that signs internal tokens and payloads. */
10
+ function readJuniorSecret() {
11
+ return process.env["JUNIOR_SECRET"]?.trim() || void 0;
12
+ }
13
+ /** Read the raw dashboard session secret, with `JUNIOR_SECRET` as fallback. */
14
+ function readSignInSecret() {
15
+ return process.env["BETTER_AUTH_SECRET"] ?? process.env["JUNIOR_SECRET"];
16
+ }
17
+ /** Read the bearer secret that internal cron requests must send. */
18
+ function readSchedulerSecret() {
19
+ return process.env["JUNIOR_SCHEDULER_SECRET"]?.trim() || process.env["CRON_SECRET"]?.trim();
20
+ }
21
+ /** Read the VAPID private key that signs web push messages. */
22
+ function readWebPushPrivateKey() {
23
+ return process.env["JUNIOR_WEB_PUSH_PRIVATE_KEY"]?.trim();
24
+ }
9
25
  // src/chat/queue/bullmq.ts
10
26
  const MAX_ATTEMPTS = 50;
11
27
  const MAX_BACKOFF_MS = 3e4;
@@ -170,94 +186,6 @@ const vercelQueueProvider = {
170
186
  function getQueueProvider() {
171
187
  return getChatConfig().queue.provider === "bullmq" ? bullmqQueueProvider : vercelQueueProvider;
172
188
  }
173
- // src/chat/runtime/request-deadline.ts
174
- const requestDeadlineStorage = new AsyncLocalStorage();
175
- function createTurnRequestDeadline(startedAtMs) {
176
- return {
177
- startedAtMs,
178
- deadlineAtMs: startedAtMs + Math.max(1, getChatConfig().functionMaxDurationSeconds * 1e3 - 2e4)
179
- };
180
- }
181
- /** Return the host request deadline inherited by the current async turn. */
182
- function getTurnRequestDeadline() {
183
- return requestDeadlineStorage.getStore();
184
- }
185
- /** Run work under the current host request deadline, or start one. */
186
- function runWithTurnRequestDeadline(callback, startedAtMs = Date.now()) {
187
- if (requestDeadlineStorage.getStore()) return callback();
188
- return runWithNewTurnRequestDeadline(callback, startedAtMs);
189
- }
190
- /** Run work that a new host request owns, even inside another request. */
191
- function runWithNewTurnRequestDeadline(callback, startedAtMs = Date.now()) {
192
- return requestDeadlineStorage.run(createTurnRequestDeadline(startedAtMs), callback);
193
- }
194
- // src/chat/queue/callback.ts
195
- /** Shared queue callback wiring for signed messages. */
196
- /** Build the HTTP callback and local-dev consumer for one signed queue. */
197
- function queueCallback(options) {
198
- const consume = async (message, metadata) => {
199
- if (options.skip?.(metadata)) return;
200
- try {
201
- await runWithTurnRequestDeadline(() => options.run(message, metadata));
202
- } catch (error) {
203
- const reason = options.permanentError?.(error);
204
- if (!reason) throw error;
205
- options.onRejected(reason, metadata, error);
206
- }
207
- };
208
- const handler = async (value, metadata) => {
209
- if (options.skip?.(metadata)) return;
210
- const checked = options.verify(value);
211
- if (checked.status === "rejected") {
212
- options.onRejected(checked.reason, metadata);
213
- return;
214
- }
215
- if (checked.status === "unavailable") throw new Error(`Queue message verification unavailable: ${checked.reason}`);
216
- await runWithNewTurnRequestDeadline(() => consume(checked.message, metadata));
217
- };
218
- const retry = (error, metadata) => {
219
- const reason = options.permanentError?.(error);
220
- if (reason) {
221
- options.onRejected(reason, metadata, error);
222
- return { acknowledge: true };
223
- }
224
- if (options.maxDeliveries !== null && metadata.deliveryCount >= options.maxDeliveries) return { acknowledge: true };
225
- };
226
- const consumer = {
227
- consumerGroup: options.consumerGroup,
228
- handler,
229
- retry,
230
- topic: options.topic,
231
- visibilityTimeoutSeconds: options.visibilityTimeoutSeconds
232
- };
233
- return {
234
- /** Run a message that an in-process queue already trusts. */
235
- consume,
236
- consumer,
237
- create: () => getQueueProvider().createCallback(consumer),
238
- registerDev: () => {
239
- if (process.env["NODE_ENV"] !== "development") return;
240
- return getQueueProvider().registerDevConsumer?.(consumer);
241
- }
242
- };
243
- }
244
- // src/chat/secrets.ts
245
- /** Read the server secret that signs internal tokens and payloads. */
246
- function readJuniorSecret() {
247
- return process.env["JUNIOR_SECRET"]?.trim() || void 0;
248
- }
249
- /** Read the raw dashboard session secret, with `JUNIOR_SECRET` as fallback. */
250
- function readSignInSecret() {
251
- return process.env["BETTER_AUTH_SECRET"] ?? process.env["JUNIOR_SECRET"];
252
- }
253
- /** Read the bearer secret that internal cron requests must send. */
254
- function readSchedulerSecret() {
255
- return process.env["JUNIOR_SCHEDULER_SECRET"]?.trim() || process.env["CRON_SECRET"]?.trim();
256
- }
257
- /** Read the VAPID private key that signs web push messages. */
258
- function readWebPushPrivateKey() {
259
- return process.env["JUNIOR_WEB_PUSH_PRIVATE_KEY"]?.trim();
260
- }
261
189
  // src/chat/queue/sign.ts
262
190
  /** Sign and check queue messages before public callbacks run them. */
263
191
  const QUEUE_SIGNATURE_MAX_AGE_MS = 36e5;
@@ -341,88 +269,81 @@ function verifyQueueMessage(config, value, nowMs = Date.now()) {
341
269
  message: message.data
342
270
  };
343
271
  }
344
- // src/chat/plugins/task-queue.ts
345
- /**
346
- * Delivery for plugin-registered tasks.
347
- *
348
- * Plugins register named tasks. This module owns the shared signed message,
349
- * send path, and HTTP/local callback. Core keeps one topic and one runner.
350
- */
351
- /** Deploy topic name. Keep stable for Vercel queue wiring. */
352
- const PLUGIN_TASK_QUEUE_TOPIC = "junior_plugin_tasks";
353
- const PLUGIN_TASK_DEV_CONSUMER_GROUP = "junior_plugin_tasks_dev";
354
- const PLUGIN_TASK_MAX_DELIVERIES = 5;
355
- const PLUGIN_TASK_SIGN_CONTEXT = "junior.plugin_task_queue.v1";
356
- const PLUGIN_TASK_SIGN_VERSION = "v1";
357
- const pluginTaskParamsSchema = z.object({
358
- conversationId: z.string().min(1),
359
- sessionId: z.string().min(1)
272
+ /** Validate the v2 conversation work hint sent through Vercel Queue. */
273
+ const conversationQueueMessageSchema = z.object({
274
+ schemaVersion: z.literal(2),
275
+ conversationId: z.string().trim().min(1)
360
276
  }).strict();
361
- const pluginTaskSign = {
362
- context: PLUGIN_TASK_SIGN_CONTEXT,
363
- schema: z.object({
364
- name: z.string().min(1),
365
- params: pluginTaskParamsSchema,
366
- plugin: z.string().min(1)
367
- }).strict(),
368
- signatureVersion: PLUGIN_TASK_SIGN_VERSION,
369
- parts: (message) => [
370
- message.plugin,
371
- message.name,
372
- message.params.conversationId,
373
- message.params.sessionId
374
- ]
277
+ var ConversationQueueMessageRejectedError = class extends Error {
278
+ conversationId;
279
+ reason;
280
+ constructor(reason, message, options = {}) {
281
+ super(message);
282
+ this.name = "ConversationQueueMessageRejectedError";
283
+ this.reason = reason;
284
+ this.conversationId = options.conversationId;
285
+ }
375
286
  };
376
- /** Build the stable id used for delivery dedupe and tracing. */
377
- function pluginTaskId(args) {
378
- return `plugin-task_${createHash("sha256").update(args.plugin).update("\0").update(args.name).update("\0").update(args.params.conversationId).update("\0").update(args.params.sessionId).digest("hex").slice(0, 32)}`;
379
- }
380
- /** Sign a plugin task message for tests and local checks. */
381
- function signPluginTaskQueueMessage(message, nowMs = Date.now()) {
382
- return signQueueMessage(pluginTaskSign, message, nowMs);
383
- }
384
- function verifyPluginTaskQueueMessage(value, nowMs = Date.now()) {
385
- return verifyQueueMessage(pluginTaskSign, value, nowMs);
386
- }
387
- function logPluginTaskQueueMessageRejected(reason, metadata) {
388
- logWarn("plugin.task.queue_message.rejected", {
389
- "app.queue.consumer_group": metadata.consumerGroup,
390
- "app.queue.delivery_count": metadata.deliveryCount,
391
- "app.queue.message_id": metadata.messageId,
392
- "app.queue.reject_reason": reason,
393
- "app.queue.topic_name": metadata.topicName
394
- });
395
- }
396
- function pluginTaskCallback() {
397
- return queueCallback({
398
- consumerGroup: PLUGIN_TASK_DEV_CONSUMER_GROUP,
399
- maxDeliveries: PLUGIN_TASK_MAX_DELIVERIES,
400
- onRejected: logPluginTaskQueueMessageRejected,
401
- run: async (message) => {
402
- const { processPluginTask } = await import("./task-runner-Dm7BHbGp.js").then((n) => n.r);
403
- await processPluginTask(message);
404
- },
405
- topic: PLUGIN_TASK_QUEUE_TOPIC,
406
- verify: verifyPluginTaskQueueMessage
407
- });
408
- }
409
- /** Send one plugin task through the shared signed delivery path. */
410
- async function sendVercelPluginTask(message) {
411
- await getQueueProvider().send(PLUGIN_TASK_QUEUE_TOPIC, signPluginTaskQueueMessage(message), {
412
- idempotencyKey: pluginTaskId(message),
413
- retentionSeconds: QUEUE_SIGNATURE_MAX_AGE_MS / 1e3
414
- });
415
- }
416
- /** Create the HTTP callback for plugin tasks. */
417
- function createVercelPluginTaskCallback() {
418
- return pluginTaskCallback().create();
419
- }
420
- /** Return the queue consumer for plugin tasks, for a pulling queue worker. */
421
- function pluginTaskQueueConsumer() {
422
- return pluginTaskCallback().consumer;
287
+ /** Return whether an error means the queue message was permanently rejected. */
288
+ function isConversationQueueMessageRejectedError(error) {
289
+ return error instanceof ConversationQueueMessageRejectedError;
290
+ }
291
+ /** Build the idempotency key of a wake that one worker event sends. */
292
+ function nudgeIdempotencyKey(reason, conversationId, nowMs) {
293
+ return `${reason}:${conversationId}:${nowMs}`;
294
+ }
295
+ // src/chat/task-execution/queue-signing.ts
296
+ const conversationQueueSign = {
297
+ context: "junior.conversation_work_queue.v2",
298
+ schema: conversationQueueMessageSchema,
299
+ separator: ":",
300
+ signatureVersion: "v2",
301
+ parts: (message) => [message.conversationId]
302
+ };
303
+ const CONVERSATION_WORK_QUEUE_SIGNATURE_MAX_SKEW_MS = QUEUE_SIGNATURE_MAX_AGE_MS;
304
+ /** Sign a conversation queue payload before it crosses the public callback route. */
305
+ function signConversationQueueMessage(message, nowMs = Date.now()) {
306
+ return signQueueMessage(conversationQueueSign, message, nowMs);
307
+ }
308
+ /** Explain whether a queue payload is verified, rejected, or unavailable. */
309
+ function verifyConversationQueueMessage(value, nowMs = Date.now()) {
310
+ return verifyQueueMessage(conversationQueueSign, value, nowMs);
311
+ }
312
+ const CONVERSATION_WORK_QUEUE_RETENTION_SECONDS = CONVERSATION_WORK_QUEUE_SIGNATURE_MAX_SKEW_MS / 1e3;
313
+ let defaultQueue;
314
+ /** Resolve the Vercel Queue topic used for conversation wake-up nudges. */
315
+ function resolveConversationWorkQueueTopic(options = {}) {
316
+ return options.topic?.trim() || process.env["JUNIOR_CONVERSATION_WORK_QUEUE_TOPIC"]?.trim() || "junior_conversation_work";
317
+ }
318
+ function toDelaySeconds(options) {
319
+ if (!options?.delayMs || options.delayMs <= 0) return;
320
+ return Math.ceil(options.delayMs / 1e3);
321
+ }
322
+ /** Create the Vercel Queue implementation for conversation wake-up nudges. */
323
+ function createVercelConversationWorkQueue(options = {}) {
324
+ const topic = resolveConversationWorkQueueTopic(options);
325
+ const client = options.client ?? getQueueProvider();
326
+ return { async send(message, sendOptions) {
327
+ const payload = signConversationQueueMessage(message);
328
+ return await withSpan("conversation.work.publish", "queue.publish", { conversationId: message.conversationId }, async (setSpanAttributes) => {
329
+ const result = await client.send(topic, payload, {
330
+ idempotencyKey: sendOptions?.idempotencyKey,
331
+ delaySeconds: toDelaySeconds(sendOptions),
332
+ retentionSeconds: options.retentionSeconds ?? CONVERSATION_WORK_QUEUE_RETENTION_SECONDS
333
+ });
334
+ if (!result.messageId) return {};
335
+ setSpanAttributes({ "messaging.message.id": result.messageId });
336
+ return { messageId: result.messageId };
337
+ }, {
338
+ "messaging.destination.name": topic,
339
+ "messaging.message.body.size": Buffer.byteLength(JSON.stringify(payload)),
340
+ "messaging.system": getQueueProvider().messagingSystem
341
+ });
342
+ } };
423
343
  }
424
- /** Register the local-dev consumer for plugin tasks. */
425
- function registerVercelPluginTaskDevConsumer() {
426
- return pluginTaskCallback().registerDev();
344
+ /** Return the default production conversation work queue. */
345
+ function getVercelConversationWorkQueue() {
346
+ defaultQueue ??= createVercelConversationWorkQueue();
347
+ return defaultQueue;
427
348
  }
428
- export { getQueueProvider as _, pluginTaskQueueConsumer as a, QUEUE_SIGNATURE_MAX_AGE_MS as c, readJuniorSecret as d, readSchedulerSecret as f, getTurnRequestDeadline as g, queueCallback as h, pluginTaskParamsSchema as i, signQueueMessage as l, readWebPushPrivateKey as m, createVercelPluginTaskCallback as n, registerVercelPluginTaskDevConsumer as o, readSignInSecret as p, pluginTaskId as r, sendVercelPluginTask as s, PLUGIN_TASK_QUEUE_TOPIC as t, verifyQueueMessage as u };
349
+ export { conversationQueueMessageSchema as a, QUEUE_SIGNATURE_MAX_AGE_MS as c, getQueueProvider as d, readJuniorSecret as f, readWebPushPrivateKey as h, ConversationQueueMessageRejectedError as i, signQueueMessage as l, readSignInSecret as m, resolveConversationWorkQueueTopic as n, isConversationQueueMessageRejectedError as o, readSchedulerSecret as p, verifyConversationQueueMessage as r, nudgeIdempotencyKey as s, getVercelConversationWorkQueue as t, verifyQueueMessage as u };
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.310.0";
2
+ var version = "0.312.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-Cr7Z71yG.js";
1
+ export { t as JUNIOR_VERSION } from "./version-Brbtz4Qf.js";