@sentry/junior 0.313.0 → 0.314.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 (108) hide show
  1. package/dist/{adapter-CYAvJzZS.js → adapter-JARQvoLw.js} +1 -2
  2. package/dist/{adapter-context-CVsHoVSf.js → adapter-context-B4BrJZuS.js} +2 -2
  3. package/dist/{admin-Cyhb4TwZ.js → admin-BXGAySz0.js} +1 -1
  4. package/dist/{agent-runner-B5y9MsT-.js → agent-runner-qZU5TR8i.js} +797 -118
  5. package/dist/agent-update-cS7Z9mnG.js +26 -0
  6. package/dist/agent-update-delivery-CZ5M8RDa.js +85 -0
  7. package/dist/api/schema.d.ts +2 -2
  8. package/dist/api/schema.js +6 -6
  9. package/dist/api.d.ts +1 -1
  10. package/dist/api.js +334 -100
  11. package/dist/{app-DA8-hCMj.d.ts → app-D7tKnw9a.d.ts} +4 -21
  12. package/dist/app.d.ts +2 -2
  13. package/dist/app.js +80 -169
  14. package/dist/{background-compaction-queue-iZXadLV3.js → background-compaction-queue-C_uIBUvS.js} +6 -67
  15. package/dist/callback-C8SdXCwr.js +68 -0
  16. package/dist/{catalog-runtime-kkE3hvCX.js → catalog-runtime-BLKtnUL3.js} +1 -1
  17. package/dist/{channel-access-mt7K6dPh.js → channel-access-BOL29BG3.js} +6 -6
  18. package/dist/child-message--2G3Ft26.js +19 -0
  19. package/dist/cli/chat.js +18 -21
  20. package/dist/cli/check.js +4 -4
  21. package/dist/cli/main.js +2 -2
  22. package/dist/cli/plugins.js +5 -5
  23. package/dist/cli/snapshot-create.js +5 -5
  24. package/dist/cli/upgrade.d.ts +1 -1
  25. package/dist/cli/upgrade.js +23 -4
  26. package/dist/{config-CWbwKj0j.js → config-BIfHKNXN.js} +40 -35
  27. package/dist/{continue-in-slack-CxyFzdlF.js → continue-in-slack-fnmD2Ifb.js} +5 -7
  28. package/dist/{conversation-feed-BEXLD3Me.js → conversation-feed-DdFQuQDR.js} +1 -1
  29. package/dist/{logging-DNt-qOIO.js → conversation-privacy-DtZhI91r.js} +188 -2
  30. package/dist/{conversation-turn-B35eu0uz.js → conversation-turn-DScuDYmN.js} +418 -33
  31. package/dist/create-CrNt4Ewu.js +212 -0
  32. package/dist/{credential-sync-DWTOEQrm.js → credential-sync-CtqsGjj1.js} +14 -17
  33. package/dist/{credentialed-Dyv8b-lu.js → credentialed-dWRA3-oJ.js} +910 -426
  34. package/dist/{db-PwSRzWWn.js → db-BTmLKZrp.js} +2235 -38
  35. package/dist/{db-DYGcXYl3.d.ts → db-DcmzbA55.d.ts} +2 -2
  36. package/dist/{history-CYstOMKX.js → history-CneKY7_V.js} +19 -1
  37. package/dist/{html-DidUcRhI.js → html-B8rBt7F4.js} +5 -7
  38. package/dist/{install-2urLLXNt.js → install-OtFboxOM.js} +2 -2
  39. package/dist/instrumentation.js +2 -2
  40. package/dist/{lineage-BXplQAVH.js → lineage-EULJkGO1.js} +1 -2
  41. package/dist/{list-DyIyReSV.js → list-C5400AlJ.js} +235 -77
  42. package/dist/{turn-membership-DTR3SaKD.js → mailbox-turn-DL3Lvsm0.js} +4698 -587
  43. package/dist/markers-DUP8aBOp.js +323 -0
  44. package/dist/{media-B0pZJ0bG.js → media-FYM-Bl3H.js} +33 -8
  45. package/dist/{message-Z5YKC-Af.js → message-DuDelZFr.js} +16 -29
  46. package/dist/{model-input-BhPJYdSV.js → model-input-0osF3pBS.js} +3 -3
  47. package/dist/nitro.d.ts +2 -4
  48. package/dist/nitro.js +340 -13
  49. package/dist/{oauth-callback-server-ByvDdcdY.js → oauth-callback-server-DX2fQ7Nq.js} +2 -2
  50. package/dist/{oauth-relay-D-kK0yoN.js → oauth-relay-PwPMdZJv.js} +1 -1
  51. package/dist/{plugins-Bkk0XRo2.js → plugins-BXMdNdyA.js} +1 -1
  52. package/dist/{registry-POH4bZC4.js → registry-D6kS6xYH.js} +1402 -64
  53. package/dist/{resolve-CWtBNSKP.js → resolve-D8CPJcNK.js} +3 -3
  54. package/dist/result-D090hxr5.js +402 -0
  55. package/dist/{runner-CsZ_VRxp.js → runner-BU7fgrm-.js} +7 -8
  56. package/dist/{sandbox-egress-signals-FbCk1FkN.js → sandbox-egress-signals-BUmVrsoG.js} +1 -1
  57. package/dist/{schema-DojR2uCL.js → schema-7gW9vBpJ.js} +90 -9
  58. package/dist/{schema-DBf18QPS.d.ts → schema-BB6E0wyV.d.ts} +138 -5
  59. package/dist/{service-account-CDYb9hfX.js → service-account-plA-uzIB.js} +6 -5
  60. package/dist/{skills-B0jP4whm.js → skills-CIosT6bS.js} +3 -3
  61. package/dist/{slack-conversation-unfurl-D26t9kBC.js → slack-conversation-unfurl-CBgZqth6.js} +8 -10
  62. package/dist/{spawn-BjljgExZ.js → spawn-DRjdzh3R.js} +9 -17
  63. package/dist/{start-conversation-DbVujrwO.js → start-conversation-a4NXH4X9.js} +12 -15
  64. package/dist/{store-CjXrp-Up.js → store-BuhF1QDm.js} +2 -4
  65. package/dist/{task-queue-Cwlatjz3.js → task-queue-CrRjFzOh.js} +5 -16
  66. package/dist/{task-runner--Ke8KSMf.js → task-runner-C-pXsgHM.js} +104 -50
  67. package/dist/{thread-context-B8exINEe.js → thread-context-CDX4dSZd.js} +8 -9
  68. package/dist/turn-session-routing-CZTRU8IY.js +116 -0
  69. package/dist/turn-wake-Bzq1Efrm.js +154 -0
  70. package/dist/user-customization-B27StpVQ.js +9 -0
  71. package/dist/{validation-Ce0qbMlT.js → validation-bTq88sya.js} +1 -1
  72. package/dist/{vercel-queue-q4z8w5QO.js → vercel-queue-nL0Hq3hr.js} +32 -147
  73. package/dist/{version-DFh4n9nr.js → version-DGUa1dZK.js} +1 -1
  74. package/dist/version.js +1 -1
  75. package/dist/{warmup-D5hzqTcp.js → warmup-CCOuIwAS.js} +639 -137
  76. package/dist/{worker-CDg9Lbpg.js → worker-AkZg7Dg1.js} +5 -6
  77. package/migrations/0160_money_micro_usd_repair.sql +99 -0
  78. package/migrations/0161_agent_config_backfill.sql +34 -0
  79. package/migrations/0162_inbox_item_deliveries.sql +15 -0
  80. package/migrations/0163_pg_trgm.sql +2 -0
  81. package/migrations/0164_search_indexes.sql +4 -0
  82. package/migrations/0165_drop_legacy_archive_columns.sql +4 -0
  83. package/migrations/0166_memory_prefix_index.sql +1 -0
  84. package/migrations/0167_todo_search_indexes.sql +2 -0
  85. package/migrations/0168_todo_inbox_items.sql +4 -0
  86. package/migrations/0169_drop_code_urls.sql +2 -0
  87. package/migrations/meta/0160_snapshot.json +6515 -0
  88. package/migrations/meta/0161_snapshot.json +6278 -0
  89. package/migrations/meta/0162_snapshot.json +6404 -0
  90. package/migrations/meta/0163_snapshot.json +6404 -0
  91. package/migrations/meta/0164_snapshot.json +6466 -0
  92. package/migrations/meta/0165_snapshot.json +6466 -0
  93. package/migrations/meta/0166_snapshot.json +6494 -0
  94. package/migrations/meta/0167_snapshot.json +6525 -0
  95. package/migrations/meta/0168_snapshot.json +6525 -0
  96. package/migrations/meta/0169_snapshot.json +6513 -0
  97. package/migrations/meta/_journal.json +70 -0
  98. package/package.json +9 -18
  99. package/skills/design-automation-skill/SKILL.md +2 -3
  100. package/dist/actor-BsBdxDXQ.js +0 -208
  101. package/dist/conversation-privacy-BrMiDN61.js +0 -189
  102. package/dist/executor-CgWyWfYz.js +0 -1858
  103. package/dist/fan-out-Cod-yEHG.js +0 -10
  104. package/dist/ingest-B0AggUEC.js +0 -7931
  105. package/dist/request-deadline-BUiRYQYj.js +0 -24
  106. package/dist/service-account-o15pZWcJ.js +0 -931
  107. package/dist/state-BTawTCme.js +0 -161
  108. package/dist/statuses-BKwqCPhj.js +0 -69
package/dist/nitro.js CHANGED
@@ -1,14 +1,346 @@
1
+ import { ht as readQueueConfig } from "./config-BIfHKNXN.js";
2
+ import { a as CACHE_WARMUP_QUEUE_TOPIC, c as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC, t as BACKGROUND_COMPACTION_QUEUE_TOPIC } from "./background-compaction-queue-C_uIBUvS.js";
3
+ import { t as PLUGIN_TASK_QUEUE_TOPIC } from "./task-queue-CrRjFzOh.js";
4
+ import { n as resolveConversationWorkQueueTopic } from "./vercel-queue-nL0Hq3hr.js";
5
+ import { B as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, G as JUNIOR_RETENTION_ROUTE, H as JUNIOR_HEARTBEAT_ROUTE, I as JUNIOR_AUTO_ARCHIVE_CRON_SCHEDULE, K as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, L as JUNIOR_AUTO_ARCHIVE_ROUTE, R as JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE, U as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, V as JUNIOR_HEARTBEAT_CRON_SCHEDULE, W as JUNIOR_RETENTION_CRON_SCHEDULE, Y as getDeploymentServiceVersion, z as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE } from "./conversation-privacy-DtZhI91r.js";
1
6
  import { d as resolvePackageDir, t as discoverInstalledPluginPackageContent, u as isValidPackageName } from "./package-discovery-DD9vencX.js";
2
- import { a as pluginRuntimeRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "./plugins-Bkk0XRo2.js";
3
- import { a as CACHE_WARMUP_QUEUE_TOPIC, d as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC, t as BACKGROUND_COMPACTION_QUEUE_TOPIC } from "./background-compaction-queue-iZXadLV3.js";
4
- import { t as PLUGIN_TASK_QUEUE_TOPIC } from "./task-queue-Cwlatjz3.js";
5
- import { n as resolveConversationWorkQueueTopic } from "./vercel-queue-q4z8w5QO.js";
6
- import { A as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE, B as getDeploymentServiceVersion, D as JUNIOR_AUTO_ARCHIVE_CRON_SCHEDULE, F as JUNIOR_RETENTION_CRON_SCHEDULE, I as JUNIOR_RETENTION_ROUTE, L as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, M as JUNIOR_HEARTBEAT_CRON_SCHEDULE, N as JUNIOR_HEARTBEAT_ROUTE, O as JUNIOR_AUTO_ARCHIVE_ROUTE, P as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, j as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, k as JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE } from "./logging-DNt-qOIO.js";
7
+ import { a as pluginRuntimeRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "./plugins-BXMdNdyA.js";
7
8
  import { n as loadPluginSetFromModule, r as resolvePluginModule } from "./plugin-module-Cv2ETe8Y.js";
9
+ import * as z from "zod";
8
10
  import path from "node:path";
11
+ import { randomUUID } from "node:crypto";
9
12
  import { cpSync, existsSync, mkdirSync, readdirSync, statSync } from "node:fs";
13
+ import { createServer } from "node:http";
10
14
  import { withSentryConfig as withSentryConfig$1 } from "@sentry/nitro";
11
15
  import { sentryOrchestrionPlugin } from "@sentry/server-utils/orchestrion/rollup";
16
+ // src/chat/queue/local-server.ts
17
+ const API_PATH = "/api/v3/topic/";
18
+ const CLOUD_EVENT_TYPE = "com.vercel.queue.v1beta";
19
+ const NAME_PATTERN = /^[A-Za-z0-9_-]+$/;
20
+ const DEFAULT_RETENTION_SECONDS = 86400;
21
+ const MAX_RETENTION_SECONDS = 604800;
22
+ const DEFAULT_VISIBILITY_TIMEOUT_SECONDS = 60;
23
+ const MAX_VISIBILITY_TIMEOUT_SECONDS = 3600;
24
+ const MAX_IDEMPOTENCY_KEY_LENGTH = 256;
25
+ const PUSH_RETRY_MS = 1e3;
26
+ const extendLeaseBodySchema = z.object({ visibilityTimeoutSeconds: z.number().int().min(0).max(MAX_VISIBILITY_TIMEOUT_SECONDS) }).strict();
27
+ function json(status, value) {
28
+ return {
29
+ body: JSON.stringify(value),
30
+ headers: { "content-type": "application/json" },
31
+ status
32
+ };
33
+ }
34
+ function error(status, message) {
35
+ return json(status, { error: message });
36
+ }
37
+ function readSeconds(request, name, min, max) {
38
+ const raw = request.headers[name.toLowerCase()];
39
+ if (raw === void 0) return;
40
+ const value = Number(raw);
41
+ if (typeof raw !== "string" || !/^\d+$/.test(raw) || value < min || value > max) return /* @__PURE__ */ new Error(`${name} must be an integer from ${min} to ${max}`);
42
+ return value;
43
+ }
44
+ async function readBody(request) {
45
+ const chunks = [];
46
+ for await (const chunk of request) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));
47
+ return Buffer.concat(chunks);
48
+ }
49
+ /** Start a local Vercel Queues API server that pushes to `consumers`. */
50
+ async function startLocalVercelQueueServer(options) {
51
+ const pushFetch = options.fetch ?? fetch;
52
+ const maxLeaseMs = (options.maxLeaseSeconds ?? MAX_VISIBILITY_TIMEOUT_SECONDS) * 1e3;
53
+ const messages = /* @__PURE__ */ new Map();
54
+ const duplicates = /* @__PURE__ */ new Map();
55
+ const idempotencyKeys = /* @__PURE__ */ new Map();
56
+ const leases = /* @__PURE__ */ new Map();
57
+ const runningPushes = /* @__PURE__ */ new Set();
58
+ let closing = false;
59
+ const leaseUntil = (message, seconds) => Math.min(Date.now() + Math.min(seconds * 1e3, maxLeaseMs), message.expiresAt);
60
+ const isLeased = (group) => group.receiptHandle !== void 0 && group.visibleAt > Date.now();
61
+ const schedule = (message, group) => {
62
+ clearTimeout(group.timer);
63
+ group.timer = void 0;
64
+ const now = Date.now();
65
+ if (closing || group.acked || group.unclaimedPush !== void 0 || now >= message.expiresAt) return;
66
+ if (group.visibleAt > now) {
67
+ group.timer = setTimeout(() => schedule(message, group), group.visibleAt - now);
68
+ group.timer.unref();
69
+ return;
70
+ }
71
+ const push = deliver(message, group);
72
+ runningPushes.add(push);
73
+ push.finally(() => runningPushes.delete(push));
74
+ };
75
+ const deliver = async (message, group) => {
76
+ const { consumer } = group;
77
+ const push = Symbol("push");
78
+ group.unclaimedPush = push;
79
+ try {
80
+ await (await pushFetch(new Request(consumer.url, {
81
+ body: JSON.stringify({
82
+ data: {
83
+ consumerGroup: consumer.consumerGroup,
84
+ messageId: message.id,
85
+ queueName: message.topic
86
+ },
87
+ id: randomUUID(),
88
+ source: "local-vercel-queue",
89
+ specversion: "1.0",
90
+ type: CLOUD_EVENT_TYPE
91
+ }),
92
+ headers: { "content-type": "application/cloudevents+json" },
93
+ method: "POST"
94
+ }))).arrayBuffer();
95
+ } catch {} finally {
96
+ if (group.unclaimedPush === push) group.unclaimedPush = void 0;
97
+ if (!group.acked && !isLeased(group)) group.visibleAt = Math.max(group.visibleAt, Date.now() + PUSH_RETRY_MS);
98
+ schedule(message, group);
99
+ }
100
+ };
101
+ const expire = (message) => {
102
+ messages.delete(message.id);
103
+ for (const id of message.duplicateIds) duplicates.delete(id);
104
+ if (message.idempotencyKey !== void 0) idempotencyKeys.delete(message.idempotencyKey);
105
+ for (const group of message.groups.values()) {
106
+ clearTimeout(group.timer);
107
+ if (group.receiptHandle !== void 0) leases.delete(group.receiptHandle);
108
+ }
109
+ };
110
+ const sendMessage = async (request, topic) => {
111
+ const retention = readSeconds(request, "Vqs-Retention-Seconds", 1, MAX_RETENTION_SECONDS) ?? DEFAULT_RETENTION_SECONDS;
112
+ const delay = readSeconds(request, "Vqs-Delay-Seconds", 0, MAX_RETENTION_SECONDS) ?? 0;
113
+ if (retention instanceof Error) return error(400, retention.message);
114
+ if (delay instanceof Error) return error(400, delay.message);
115
+ const rawKey = request.headers["vqs-idempotency-key"];
116
+ if (Array.isArray(rawKey) || (rawKey?.length ?? 0) > MAX_IDEMPOTENCY_KEY_LENGTH) return error(400, "Invalid Vqs-Idempotency-Key");
117
+ const body = await readBody(request);
118
+ const id = `msg_${randomUUID()}`;
119
+ const reply = {
120
+ body: JSON.stringify({ messageId: id }),
121
+ headers: {
122
+ "content-type": "application/json",
123
+ "vqs-message-id": id
124
+ },
125
+ status: 201
126
+ };
127
+ const key = rawKey === void 0 ? void 0 : `${topic}\n${rawKey}`;
128
+ const original = key === void 0 ? void 0 : messages.get(idempotencyKeys.get(key) ?? "");
129
+ if (original && Date.now() >= original.expiresAt) {
130
+ clearTimeout(original.expiryTimer);
131
+ expire(original);
132
+ } else if (original) {
133
+ original.duplicateIds.push(id);
134
+ duplicates.set(id, original.id);
135
+ return reply;
136
+ }
137
+ const createdAt = Date.now();
138
+ const expiresAt = createdAt + retention * 1e3;
139
+ const message = {
140
+ body,
141
+ contentType: request.headers["content-type"] ?? "application/octet-stream",
142
+ createdAt,
143
+ duplicateIds: [],
144
+ expiresAt,
145
+ expiryTimer: setTimeout(() => expire(message), expiresAt - createdAt),
146
+ groups: /* @__PURE__ */ new Map(),
147
+ id,
148
+ idempotencyKey: key,
149
+ topic
150
+ };
151
+ message.expiryTimer.unref();
152
+ messages.set(id, message);
153
+ if (key !== void 0) idempotencyKeys.set(key, id);
154
+ for (const consumer of options.consumers) {
155
+ if (consumer.topic !== topic) continue;
156
+ const group = {
157
+ acked: false,
158
+ consumer,
159
+ deliveryCount: 0,
160
+ receiptHandle: void 0,
161
+ timer: void 0,
162
+ unclaimedPush: void 0,
163
+ visibleAt: createdAt + delay * 1e3
164
+ };
165
+ message.groups.set(consumer.consumerGroup, group);
166
+ schedule(message, group);
167
+ }
168
+ return reply;
169
+ };
170
+ const receiveMessageById = (request, topic, consumerGroup, messageId) => {
171
+ if (!request.headers.accept?.includes("multipart/mixed")) return error(400, "Accept must include multipart/mixed");
172
+ const timeout = readSeconds(request, "Vqs-Visibility-Timeout-Seconds", 0, MAX_VISIBILITY_TIMEOUT_SECONDS) ?? DEFAULT_VISIBILITY_TIMEOUT_SECONDS;
173
+ if (timeout instanceof Error) return error(400, timeout.message);
174
+ const originalMessageId = duplicates.get(messageId);
175
+ if (originalMessageId !== void 0) return json(409, { originalMessageId });
176
+ const message = messages.get(messageId);
177
+ if (!message || message.topic !== topic || Date.now() >= message.expiresAt) return error(404, "Message not found");
178
+ const group = message.groups.get(consumerGroup);
179
+ if (!group) return error(404, "Message not found for this consumer group");
180
+ if (group.acked) return error(410, "Message already acknowledged");
181
+ if (group.visibleAt > Date.now()) return error(409, "Message is locked or delayed");
182
+ if (group.receiptHandle !== void 0) leases.delete(group.receiptHandle);
183
+ const receiptHandle = `rh_${randomUUID()}`;
184
+ group.receiptHandle = receiptHandle;
185
+ group.deliveryCount += 1;
186
+ group.visibleAt = leaseUntil(message, timeout);
187
+ group.unclaimedPush = void 0;
188
+ leases.set(receiptHandle, {
189
+ group,
190
+ message
191
+ });
192
+ schedule(message, group);
193
+ const boundary = `vqs-boundary-${randomUUID()}`;
194
+ const partHeaders = [
195
+ `Content-Type: ${message.contentType}`,
196
+ `Vqs-Message-Id: ${message.id}`,
197
+ `Vqs-Receipt-Handle: ${receiptHandle}`,
198
+ `Vqs-Delivery-Count: ${group.deliveryCount}`,
199
+ `Vqs-Timestamp: ${new Date(message.createdAt).toISOString()}`,
200
+ `Vqs-Expires-At: ${new Date(message.expiresAt).toISOString()}`
201
+ ].join("\r\n");
202
+ return {
203
+ body: Buffer.concat([
204
+ Buffer.from(`--${boundary}\r\n${partHeaders}\r\n\r\n`),
205
+ message.body,
206
+ Buffer.from(`\r\n--${boundary}--\r\n`)
207
+ ]),
208
+ headers: { "content-type": `multipart/mixed; boundary=${boundary}` },
209
+ status: 200
210
+ };
211
+ };
212
+ const findLease = (topic, consumerGroup, receiptHandle) => {
213
+ const lease = leases.get(receiptHandle);
214
+ if (!lease || lease.message.topic !== topic || lease.message.groups.get(consumerGroup) !== lease.group) return;
215
+ return lease;
216
+ };
217
+ const acknowledgeMessage = (topic, consumerGroup, receiptHandle) => {
218
+ const lease = findLease(topic, consumerGroup, receiptHandle);
219
+ if (lease?.group.acked) return { status: 204 };
220
+ if (!lease || !isLeased(lease.group)) return error(409, "Message is not in flight or the lease expired");
221
+ lease.group.acked = true;
222
+ schedule(lease.message, lease.group);
223
+ return { status: 204 };
224
+ };
225
+ const extendLease = async (request, topic, consumerGroup, receiptHandle) => {
226
+ let input;
227
+ try {
228
+ input = JSON.parse((await readBody(request)).toString("utf8"));
229
+ } catch {
230
+ return error(400, "Body must be JSON");
231
+ }
232
+ const parsed = extendLeaseBodySchema.safeParse(input);
233
+ if (!parsed.success) return error(400, "Invalid visibilityTimeoutSeconds");
234
+ const lease = findLease(topic, consumerGroup, receiptHandle);
235
+ if (!lease || lease.group.acked || !isLeased(lease.group)) return error(409, "Message is not in flight or the lease expired");
236
+ const seconds = parsed.data.visibilityTimeoutSeconds;
237
+ if (Date.now() + seconds * 1e3 > lease.message.expiresAt) return error(400, "Lease would extend beyond message expiration");
238
+ lease.group.visibleAt = leaseUntil(lease.message, seconds);
239
+ schedule(lease.message, lease.group);
240
+ return json(200, { success: true });
241
+ };
242
+ const route = async (request) => {
243
+ if (!request.headers.authorization?.startsWith("Bearer ")) return error(401, "Missing bearer token");
244
+ const { pathname } = new URL(request.url ?? "/", "http://localhost");
245
+ if (!pathname.startsWith(API_PATH)) return error(404, "Not found");
246
+ const parts = pathname.slice(14).split("/").map(decodeURIComponent);
247
+ const [topic, consumerPart, consumerGroup, kind, id, suffix] = parts;
248
+ if (!topic || !NAME_PATTERN.test(topic) || topic.length > 256) return error(400, "Invalid topic name");
249
+ if (parts.length === 1 && request.method === "POST") return sendMessage(request, topic);
250
+ if (consumerPart !== "consumer" || !consumerGroup || !NAME_PATTERN.test(consumerGroup) || !id) return error(404, "Not found");
251
+ if (kind === "id" && parts.length === 5 && request.method === "POST") return receiveMessageById(request, topic, consumerGroup, id);
252
+ if (kind === "lease" && parts.length === 5 && request.method === "DELETE") return acknowledgeMessage(topic, consumerGroup, id);
253
+ if (kind === "lease" && request.method === "PATCH" && (parts.length === 5 || parts.length === 6 && suffix === "visibility")) return extendLease(request, topic, consumerGroup, id);
254
+ return error(404, "Not found");
255
+ };
256
+ const respond = (reply, response) => {
257
+ response.writeHead(reply.status, reply.headers);
258
+ response.end(reply.body);
259
+ };
260
+ const server = createServer((request, response) => {
261
+ route(request).then((reply) => respond(reply, response), (failure) => {
262
+ console.error("Local Vercel Queues server request failed:", failure);
263
+ respond(error(500, "Internal server error"), response);
264
+ });
265
+ });
266
+ await new Promise((resolve, reject) => {
267
+ server.once("error", reject);
268
+ server.listen(options.port ?? 0, "127.0.0.1", () => resolve());
269
+ });
270
+ const address = server.address();
271
+ if (!address || typeof address === "string") throw new Error("Local Vercel Queues server has no TCP address");
272
+ return {
273
+ url: new URL(`http://127.0.0.1:${address.port}`),
274
+ close: async () => {
275
+ closing = true;
276
+ for (const message of messages.values()) {
277
+ clearTimeout(message.expiryTimer);
278
+ for (const group of message.groups.values()) clearTimeout(group.timer);
279
+ }
280
+ await Promise.allSettled(runningPushes);
281
+ await new Promise((resolve, reject) => {
282
+ server.close((failure) => failure ? reject(failure) : resolve());
283
+ server.closeAllConnections();
284
+ });
285
+ }
286
+ };
287
+ }
288
+ // src/chat/queue/routes.ts
289
+ /**
290
+ * Return the callback route of each queue topic. The queue pushes each
291
+ * message of a topic to its route.
292
+ */
293
+ function queueCallbackRoutes() {
294
+ return [
295
+ {
296
+ route: JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE,
297
+ topic: resolveConversationWorkQueueTopic()
298
+ },
299
+ {
300
+ route: JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE,
301
+ topic: PLUGIN_TASK_QUEUE_TOPIC
302
+ },
303
+ {
304
+ route: JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE,
305
+ topic: WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC
306
+ },
307
+ {
308
+ route: JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE,
309
+ topic: CACHE_WARMUP_QUEUE_TOPIC
310
+ },
311
+ {
312
+ route: JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE,
313
+ topic: BACKGROUND_COMPACTION_QUEUE_TOPIC
314
+ }
315
+ ];
316
+ }
317
+ // src/build/dev-queue.ts
318
+ const LOCAL_CONSUMER_GROUP = "local";
319
+ /**
320
+ * Start a local Vercel Queues server for `nitro dev`, and point the app's
321
+ * `vercel` queue provider at it. The server pushes each message to its
322
+ * callback route on the dev server, as Vercel does in production.
323
+ *
324
+ * Nitro runs modules in its main process, which outlives each reload of the
325
+ * app worker, so queued messages survive an app reload. A Nitro restart
326
+ * loses them. Does nothing when `JUNIOR_QUEUE_API_URL` names another
327
+ * server.
328
+ */
329
+ async function startDevQueue(nitro) {
330
+ if (readQueueConfig(process.env).apiUrl) return;
331
+ const appUrl = `http://localhost:${nitro.options.devServer.port ?? (process.env["PORT"]?.trim() || 3e3)}`;
332
+ const server = await startLocalVercelQueueServer({ consumers: queueCallbackRoutes().map(({ route, topic }) => ({
333
+ consumerGroup: LOCAL_CONSUMER_GROUP,
334
+ topic,
335
+ url: new URL(route, appUrl).href
336
+ })) });
337
+ process.env["JUNIOR_QUEUE_API_URL"] = server.url.href;
338
+ nitro.logger.info(`Local Vercel Queues server: ${server.url.href}`);
339
+ nitro.hooks.hook("close", async () => {
340
+ delete process.env["JUNIOR_QUEUE_API_URL"];
341
+ await server.close();
342
+ });
343
+ }
12
344
  // src/build/rolldown-workarounds.ts
13
345
  /**
14
346
  * Override rolldown's treeshake config so that module side effects survive
@@ -232,7 +564,6 @@ function runtimeModuleForResolvedPluginModule(moduleRef) {
232
564
  }
233
565
  function configureVercelDeployment(nitro, options) {
234
566
  const defaultMaxDuration = options.maxDuration ?? DEFAULT_FUNCTION_MAX_DURATION_SECONDS;
235
- const queueTopic = resolveConversationWorkQueueTopic({ topic: options.conversationWorkQueueTopic });
236
567
  nitro.options.vercel ??= {};
237
568
  nitro.options.vercel.config ??= { version: 3 };
238
569
  nitro.options.vercel.config.crons ??= [];
@@ -252,7 +583,7 @@ function configureVercelDeployment(nitro, options) {
252
583
  nitro.options.vercel.functions.maxDuration = defaultMaxDuration;
253
584
  nitro.options.vercel.functionRules ??= {};
254
585
  const functionRules = nitro.options.vercel.functionRules;
255
- const addQueueTrigger = (route, topic) => {
586
+ for (const { route, topic } of queueCallbackRoutes()) {
256
587
  const existingRule = functionRules[route] ?? {};
257
588
  const existingTriggers = Array.isArray(existingRule.experimentalTriggers) ? existingRule.experimentalTriggers : [];
258
589
  functionRules[route] = {
@@ -263,12 +594,7 @@ function configureVercelDeployment(nitro, options) {
263
594
  topic
264
595
  }]
265
596
  };
266
- };
267
- addQueueTrigger(JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, queueTopic);
268
- addQueueTrigger(JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, PLUGIN_TASK_QUEUE_TOPIC);
269
- addQueueTrigger(JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC);
270
- addQueueTrigger(JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE, CACHE_WARMUP_QUEUE_TOPIC);
271
- addQueueTrigger(JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE, BACKGROUND_COMPACTION_QUEUE_TOPIC);
597
+ }
272
598
  return defaultMaxDuration;
273
599
  }
274
600
  function dropRoutedServerEntry(nitro) {
@@ -328,6 +654,7 @@ function juniorNitro(options = {}) {
328
654
  }
329
655
  });
330
656
  });
657
+ return nitro.options.dev ? startDevQueue(nitro) : void 0;
331
658
  } } };
332
659
  }
333
660
  export { juniorNitro, withSentryConfig };
@@ -1,5 +1,5 @@
1
- import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-DWTOEQrm.js";
2
- import { r as createUserTokenStore } from "./credentialed-Dyv8b-lu.js";
1
+ import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-CtqsGjj1.js";
2
+ import { r as createUserTokenStore } from "./credentialed-dWRA3-oJ.js";
3
3
  import { createServer } from "node:http";
4
4
  // src/chat/local/oauth-callback-server.ts
5
5
  const LOCAL_OAUTH_TIMEOUT_MS = 6e5;
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
- import { f as readJuniorSecret } from "./vercel-queue-q4z8w5QO.js";
2
+ import { f as readJuniorSecret } from "./vercel-queue-nL0Hq3hr.js";
3
3
  import * as z from "zod";
4
4
  import { randomBytes } from "node:crypto";
5
5
  import { SignJWT, jwtVerify } from "jose";
@@ -89,7 +89,7 @@ function pluginCatalogConfigFromEnv(env = process.env) {
89
89
  }
90
90
  /** Return registrations that expose in-process runtime code. */
91
91
  function pluginRuntimeRegistrationsFromPluginSet(pluginSet) {
92
- return pluginSet?.registrations.filter((plugin) => plugin.hooks || plugin.images || plugin.tasks || plugin.userPages?.length || plugin.objectLinks?.length) ?? [];
92
+ return pluginSet?.registrations.filter((plugin) => plugin.codeLinks || plugin.hooks || plugin.images || plugin.tasks || plugin.userPages?.length || plugin.objectLinks?.length) ?? [];
93
93
  }
94
94
  /** Return registrations that expose host CLI commands. */
95
95
  function pluginCliRegistrationsFromPluginSet(pluginSet) {