@sentry/junior 0.181.0 → 0.182.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 (81) hide show
  1. package/dist/{agent-hooks-IQUW6ERD.js → agent-hooks-3S25UIHO.js} +11 -11
  2. package/dist/api.js +125 -51
  3. package/dist/app-adapter.d.ts +85 -0
  4. package/dist/app.d.ts +6 -1
  5. package/dist/app.js +343 -487
  6. package/dist/{catalog-runtime-PMQWNIXA.js → catalog-runtime-ESLMBQBV.js} +4 -4
  7. package/dist/chat/api-turns/adapter-conversations.d.ts +15 -0
  8. package/dist/chat/api-turns/stop.d.ts +12 -0
  9. package/dist/chat/api-turns/work.d.ts +9 -1
  10. package/dist/chat/app/conversation-work.d.ts +1 -1
  11. package/dist/chat/event-tasks/tool-support.d.ts +7 -1
  12. package/dist/chat/event-tasks/types.d.ts +1 -0
  13. package/dist/chat/experimental.d.ts +1 -1
  14. package/dist/chat/resource-events/catalog.d.ts +11 -1
  15. package/dist/chat/resource-events/store.d.ts +5 -1
  16. package/dist/chat/services/subscribed-decision.d.ts +2 -1
  17. package/dist/chat/tools/create-event-task.d.ts +3 -0
  18. package/dist/chat/tools/delete-event-task.d.ts +2 -0
  19. package/dist/chat/tools/list-event-tasks.d.ts +2 -0
  20. package/dist/chat/tools/list-resource-event-subscriptions.d.ts +2 -0
  21. package/dist/chat/tools/search-resource-event-types.d.ts +10 -0
  22. package/dist/chat/tools/update-event-task.d.ts +3 -0
  23. package/dist/chat/tools/watch-resource-events.d.ts +3 -0
  24. package/dist/{chunk-D6ZD7VXP.js → chunk-2CEOXDG2.js} +20 -11
  25. package/dist/{chunk-VRS6WDK5.js → chunk-2LYHWMR4.js} +1 -1
  26. package/dist/{chunk-IKKETMQC.js → chunk-3ENUMZNG.js} +3 -3
  27. package/dist/{chunk-IJ6SS4WB.js → chunk-3NFHI2NA.js} +1 -1
  28. package/dist/{chunk-GREV5PJK.js → chunk-3THPTNN6.js} +4 -4
  29. package/dist/{chunk-KKSVCHDO.js → chunk-44BQ3TSK.js} +1 -1
  30. package/dist/{chunk-4IX32NSL.js → chunk-4DZ62L36.js} +1 -1
  31. package/dist/{chunk-RNMASWLP.js → chunk-6TSWXBTQ.js} +3 -3
  32. package/dist/{chunk-PBKZQAUA.js → chunk-A7THOQ6N.js} +58 -32
  33. package/dist/{chunk-DSA6WTRP.js → chunk-BDDWVY32.js} +19 -19
  34. package/dist/{chunk-TJHSAHQN.js → chunk-BZD4ADQH.js} +3 -2
  35. package/dist/{chunk-EU7KJDOG.js → chunk-CVBIM4Z3.js} +1 -1
  36. package/dist/{chunk-LZOQFC5F.js → chunk-D6OHGAIO.js} +5 -5
  37. package/dist/{chunk-KQZX24QQ.js → chunk-DZR3L74W.js} +3 -3
  38. package/dist/{chunk-3KCQEG6W.js → chunk-GGYA5NPN.js} +9 -9
  39. package/dist/{chunk-EM7EECT5.js → chunk-JIOKUIAS.js} +2 -2
  40. package/dist/{chunk-3X55QRAG.js → chunk-KGMHUDVF.js} +6 -6
  41. package/dist/{chunk-3KSSALN4.js → chunk-LB4FWMCV.js} +92 -8
  42. package/dist/{chunk-XYTJUHRZ.js → chunk-LHQK5XCU.js} +2 -2
  43. package/dist/{chunk-LCNPXLE7.js → chunk-LT4QYGKM.js} +7 -7
  44. package/dist/{chunk-TDT2R77B.js → chunk-MJISSOWB.js} +1 -1
  45. package/dist/{chunk-FWILPBVQ.js → chunk-PQES5LB5.js} +5 -5
  46. package/dist/{chunk-GWFRPQNP.js → chunk-QHALFHZA.js} +9 -9
  47. package/dist/{chunk-PPYDHUEL.js → chunk-S35OZMSL.js} +130 -200
  48. package/dist/{chunk-ETJTXYHY.js → chunk-SVFSYQMT.js} +1 -1
  49. package/dist/{chunk-NQTA72Q3.js → chunk-SXOZIG5X.js} +6 -6
  50. package/dist/{chunk-Q2KY27IX.js → chunk-TEFNHMO2.js} +63 -7
  51. package/dist/{chunk-KMBU4PJP.js → chunk-UKIHNBBD.js} +3 -3
  52. package/dist/{chunk-EBMRB6Z6.js → chunk-UQP54CXZ.js} +1 -1
  53. package/dist/{chunk-GPA3ZSYY.js → chunk-UUMBHORH.js} +1 -1
  54. package/dist/{chunk-LG5MYY6U.js → chunk-V5UZCCNW.js} +6 -6
  55. package/dist/{chunk-HZHUMCNV.js → chunk-VHMAFMHB.js} +1 -1
  56. package/dist/{chunk-HEBMSITT.js → chunk-WOIALVN2.js} +1 -1
  57. package/dist/{chunk-HJ27A6YB.js → chunk-YHL2L2ZZ.js} +1 -1
  58. package/dist/{chunk-PL57B6NC.js → chunk-Z7ALSQS3.js} +1 -1
  59. package/dist/cli/chat.js +34 -34
  60. package/dist/cli/check.js +5 -5
  61. package/dist/cli/plugins.js +12 -12
  62. package/dist/cli/snapshot-create.js +9 -9
  63. package/dist/cli/upgrade.js +6 -6
  64. package/dist/{db-QNPVCQPT.js → db-NYIWZ4L5.js} +6 -6
  65. package/dist/{experimental-SIJSRDJD.js → experimental-P5FZM4CU.js} +1 -1
  66. package/dist/instrumentation.js +3 -3
  67. package/dist/nitro.js +6 -6
  68. package/dist/{oauth-callback-server-KYMPJOTC.js → oauth-callback-server-A2YTPVVX.js} +26 -26
  69. package/dist/{runner-3RS2D2ZR.js → runner-VKAEU52J.js} +18 -18
  70. package/dist/{skills-5B3Y6XX6.js → skills-52GMXUTY.js} +5 -5
  71. package/dist/spawn-GSS4EBLR.js +37 -0
  72. package/dist/task-runner-DUGDWF5O.js +32 -0
  73. package/dist/{validation-Q65QD27B.js → validation-VD2YQX2W.js} +5 -5
  74. package/dist/version.js +1 -1
  75. package/dist/{work-DCMQWAAP.js → work-ZWBTGEQP.js} +18 -18
  76. package/dist/worker-XUWD5WS7.js +22 -0
  77. package/package.json +6 -5
  78. package/dist/api/acp/route.d.ts +0 -13
  79. package/dist/spawn-VYARS3DU.js +0 -37
  80. package/dist/task-runner-4IXKKZHL.js +0 -32
  81. package/dist/worker-QL3CHLZL.js +0 -22
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  createWebAuthorization,
3
3
  deleteWebAuthorization
4
- } from "./chunk-EU7KJDOG.js";
4
+ } from "./chunk-CVBIM4Z3.js";
5
5
  import {
6
6
  buildDeliveredTurnStatePatch,
7
7
  completeAuthPauseTurn,
8
8
  finalizeFailedTurnReplyWithEvent,
9
9
  getTurnUserMessage
10
- } from "./chunk-LZOQFC5F.js";
10
+ } from "./chunk-D6OHGAIO.js";
11
11
  import {
12
12
  processPluginTask,
13
13
  scheduleSessionCompletedPluginTasks
14
- } from "./chunk-GWFRPQNP.js";
14
+ } from "./chunk-QHALFHZA.js";
15
15
  import {
16
16
  ConversationTurnLifecycleService
17
17
  } from "./chunk-M3QYTBQ6.js";
@@ -20,16 +20,17 @@ import {
20
20
  getPersistedSandboxState,
21
21
  getPersistedThreadState,
22
22
  persistThreadStateById
23
- } from "./chunk-FWILPBVQ.js";
23
+ } from "./chunk-PQES5LB5.js";
24
24
  import {
25
25
  healthReportSchema
26
26
  } from "./chunk-UTL3MHPC.js";
27
27
  import {
28
28
  parseSlackThreadId
29
- } from "./chunk-TDT2R77B.js";
29
+ } from "./chunk-MJISSOWB.js";
30
30
  import {
31
+ appendAndEnqueueExclusiveInboundMessage,
31
32
  appendAndEnqueueInboundMessage
32
- } from "./chunk-Q2KY27IX.js";
33
+ } from "./chunk-TEFNHMO2.js";
33
34
  import {
34
35
  TurnInputCommitLostError,
35
36
  buildDeterministicTurnId,
@@ -40,7 +41,7 @@ import {
40
41
  markTurnClosed,
41
42
  markTurnFailed,
42
43
  startActiveTurn
43
- } from "./chunk-HJ27A6YB.js";
44
+ } from "./chunk-YHL2L2ZZ.js";
44
45
  import {
45
46
  abandonTurnRecord,
46
47
  buildConversationContext,
@@ -55,28 +56,27 @@ import {
55
56
  recordDeliveredAssistantMessage,
56
57
  saveTurnCheckpoint,
57
58
  upsertConversationMessage
58
- } from "./chunk-NQTA72Q3.js";
59
+ } from "./chunk-SXOZIG5X.js";
59
60
  import {
60
61
  normalizeSlackConversationId
61
- } from "./chunk-D6ZD7VXP.js";
62
+ } from "./chunk-2CEOXDG2.js";
62
63
  import {
63
64
  getConversationEventStore,
64
65
  getConversationStore,
65
66
  getDb
66
- } from "./chunk-RNMASWLP.js";
67
+ } from "./chunk-6TSWXBTQ.js";
67
68
  import {
68
- juniorApiTokens,
69
69
  juniorConversationParticipants,
70
70
  juniorConversations,
71
71
  juniorIdentities,
72
72
  juniorUsers
73
- } from "./chunk-KKSVCHDO.js";
73
+ } from "./chunk-44BQ3TSK.js";
74
74
  import {
75
75
  juniorDestinations
76
76
  } from "./chunk-VFUK3X5B.js";
77
77
  import {
78
78
  canExposeConversationPayload
79
- } from "./chunk-ETJTXYHY.js";
79
+ } from "./chunk-SVFSYQMT.js";
80
80
  import {
81
81
  credentialContextForActor
82
82
  } from "./chunk-CEMMLV5L.js";
@@ -84,7 +84,7 @@ import {
84
84
  logException,
85
85
  setTags,
86
86
  withLogContext
87
- } from "./chunk-EBMRB6Z6.js";
87
+ } from "./chunk-UQP54CXZ.js";
88
88
 
89
89
  // src/handlers/health.ts
90
90
  function readHealthReport() {
@@ -122,83 +122,75 @@ function createVercelAttachmentStorage() {
122
122
  };
123
123
  }
124
124
 
125
- // src/personal-tokens/store.ts
126
- import { createHash, randomBytes, randomUUID } from "crypto";
127
- import { and, desc, eq, gt, isNull } from "drizzle-orm";
128
- var TOKEN_PREFIX = "jr_pat_";
129
- var TOKEN_SUFFIX_LENGTH = 8;
130
- var DEFAULT_TOKEN_LIFETIME_MS = 90 * 24 * 60 * 60 * 1e3;
131
- function normalizeEmail(email) {
132
- return email.trim().toLowerCase();
133
- }
134
- function hashToken(token) {
135
- return createHash("sha256").update(token, "utf8").digest("hex");
136
- }
137
- function metadata(row) {
138
- return {
139
- id: row.id,
140
- name: row.name,
141
- tokenSuffix: row.tokenSuffix,
142
- createdAt: row.createdAt.toISOString(),
143
- expiresAt: row.expiresAt.toISOString(),
144
- lastUsedAt: row.lastUsedAt?.toISOString() ?? null
145
- };
125
+ // src/chat/api-turns/routing.ts
126
+ import { z } from "zod";
127
+ var apiTurnMailboxMetadataSchema = z.object({
128
+ authorEmail: z.string().email(),
129
+ authorFullName: z.string().min(1).optional(),
130
+ authorUserId: z.string().min(1),
131
+ authorUserName: z.string().min(1).optional(),
132
+ kind: z.literal("api_turn"),
133
+ messageId: z.string().min(1)
134
+ }).strict();
135
+ async function getActiveApiTurnId(conversationId) {
136
+ const summaries = await listTurnSummaries(conversationId);
137
+ const active = summaries.filter(
138
+ (summary) => summary.surface === "api" && !summary.dispatchId && (summary.state === "paused" || summary.state === "running")
139
+ );
140
+ if (active.length > 1) {
141
+ throw new Error(
142
+ `Conversation ${conversationId} has multiple active web turns`
143
+ );
144
+ }
145
+ const turnId = active[0]?.turnId;
146
+ if (!turnId) return void 0;
147
+ const record = await getTurnRecord(conversationId, turnId);
148
+ return record && record.surface === "api" && !record.dispatchId && (record.state === "paused" || record.state === "running") ? turnId : void 0;
146
149
  }
147
- async function createPersonalToken(args) {
148
- const now = args.now ?? /* @__PURE__ */ new Date();
149
- const token = `${TOKEN_PREFIX}${randomBytes(32).toString("base64url")}`;
150
- const row = {
151
- id: randomUUID(),
152
- ownerEmailNormalized: normalizeEmail(args.email),
153
- name: args.name.trim(),
154
- tokenHash: hashToken(token),
155
- tokenSuffix: token.slice(-TOKEN_SUFFIX_LENGTH),
156
- createdAt: now,
157
- expiresAt: new Date(now.getTime() + DEFAULT_TOKEN_LIFETIME_MS)
158
- };
159
- await getDb().insert(juniorApiTokens).values(row);
160
- return { ...metadata({ ...row, lastUsedAt: null, revokedAt: null }), token };
150
+ async function getAuthPausedApiTurnId(conversationId) {
151
+ const turnId = await getActiveApiTurnId(conversationId);
152
+ if (!turnId) return void 0;
153
+ const record = await getTurnRecord(conversationId, turnId);
154
+ return record?.state === "paused" && record.resumeReason === "auth" ? turnId : void 0;
161
155
  }
162
- async function listPersonalTokens(email, now = /* @__PURE__ */ new Date()) {
163
- const rows = await getDb().select().from(juniorApiTokens).where(
164
- and(
165
- eq(juniorApiTokens.ownerEmailNormalized, normalizeEmail(email)),
166
- isNull(juniorApiTokens.revokedAt),
167
- gt(juniorApiTokens.expiresAt, now)
168
- )
169
- ).orderBy(desc(juniorApiTokens.createdAt));
170
- return rows.map(metadata);
156
+ function parseApiTurnMessages(messages) {
157
+ if (messages.length === 0) {
158
+ return [];
159
+ }
160
+ const parsed = messages.map((message) => ({
161
+ message,
162
+ metadata: apiTurnMailboxMetadataSchema.safeParse(message.input.metadata)
163
+ }));
164
+ if (parsed.every((entry) => !entry.metadata.success)) {
165
+ return [];
166
+ }
167
+ if (parsed.some((entry) => !entry.metadata.success)) {
168
+ throw new Error("Conversation mailbox mixes web turns and other input");
169
+ }
170
+ return parsed.map((entry) => {
171
+ if (!entry.metadata.success) {
172
+ throw new Error("API turn mailbox metadata failed validation");
173
+ }
174
+ return { message: entry.message, metadata: entry.metadata.data };
175
+ });
171
176
  }
172
- async function revokePersonalToken(args) {
173
- const rows = await getDb().update(juniorApiTokens).set({ revokedAt: args.now ?? /* @__PURE__ */ new Date() }).where(
174
- and(
175
- eq(juniorApiTokens.id, args.id),
176
- eq(juniorApiTokens.ownerEmailNormalized, normalizeEmail(args.email)),
177
- isNull(juniorApiTokens.revokedAt)
178
- )
179
- ).returning({ id: juniorApiTokens.id });
180
- return rows.length > 0;
177
+ async function resolveApiTurnWork(context) {
178
+ const batch = parseApiTurnMessages(context.attempt.messages);
179
+ if (batch.length > 0) {
180
+ return { kind: "mailbox", batch };
181
+ }
182
+ if (context.attempt.messages.length > 0) {
183
+ return void 0;
184
+ }
185
+ const turnId = await getActiveApiTurnId(context.conversationId);
186
+ return turnId ? { kind: "resume", turnId } : void 0;
181
187
  }
182
- async function authenticatePersonalToken(token, now = /* @__PURE__ */ new Date()) {
183
- if (!token.startsWith(TOKEN_PREFIX)) return void 0;
184
- const rows = await getDb().select({
185
- id: juniorApiTokens.id,
186
- ownerEmailNormalized: juniorApiTokens.ownerEmailNormalized
187
- }).from(juniorApiTokens).where(
188
- and(
189
- eq(juniorApiTokens.tokenHash, hashToken(token)),
190
- isNull(juniorApiTokens.revokedAt),
191
- gt(juniorApiTokens.expiresAt, now)
192
- )
193
- ).limit(1);
194
- const match = rows[0];
195
- if (!match) return void 0;
196
- await getDb().update(juniorApiTokens).set({ lastUsedAt: now }).where(eq(juniorApiTokens.id, match.id));
197
- return match.ownerEmailNormalized;
188
+ async function isApiTurnWork(context) {
189
+ return await resolveApiTurnWork(context) !== void 0;
198
190
  }
199
191
 
200
192
  // src/chat/api-turns/work.ts
201
- import { createHash as createHash2 } from "crypto";
193
+ import { createHash } from "crypto";
202
194
  import {
203
195
  createWebSource,
204
196
  localDestinationSchema
@@ -301,77 +293,16 @@ async function completeCancelledApiTurn(args) {
301
293
  await args.acknowledge();
302
294
  }
303
295
 
304
- // src/chat/api-turns/routing.ts
305
- import { z } from "zod";
306
- var apiTurnMailboxMetadataSchema = z.object({
307
- authorEmail: z.string().email(),
308
- authorFullName: z.string().min(1).optional(),
309
- authorUserId: z.string().min(1),
310
- authorUserName: z.string().min(1).optional(),
311
- kind: z.literal("api_turn"),
312
- messageId: z.string().min(1)
313
- }).strict();
314
- async function getActiveApiTurnId(conversationId) {
315
- const summaries = await listTurnSummaries(conversationId);
316
- const active = summaries.filter(
317
- (summary) => summary.surface === "api" && !summary.dispatchId && (summary.state === "paused" || summary.state === "running")
318
- );
319
- if (active.length > 1) {
320
- throw new Error(
321
- `Conversation ${conversationId} has multiple active web turns`
322
- );
323
- }
324
- const turnId = active[0]?.turnId;
325
- if (!turnId) return void 0;
326
- const record = await getTurnRecord(conversationId, turnId);
327
- return record && record.surface === "api" && !record.dispatchId && (record.state === "paused" || record.state === "running") ? turnId : void 0;
328
- }
329
- function parseApiTurnMessages(messages) {
330
- if (messages.length === 0) {
331
- return [];
332
- }
333
- const parsed = messages.map((message) => ({
334
- message,
335
- metadata: apiTurnMailboxMetadataSchema.safeParse(message.input.metadata)
336
- }));
337
- if (parsed.every((entry) => !entry.metadata.success)) {
338
- return [];
339
- }
340
- if (parsed.some((entry) => !entry.metadata.success)) {
341
- throw new Error("Conversation mailbox mixes web turns and other input");
342
- }
343
- return parsed.map((entry) => {
344
- if (!entry.metadata.success) {
345
- throw new Error("API turn mailbox metadata failed validation");
346
- }
347
- return { message: entry.message, metadata: entry.metadata.data };
348
- });
349
- }
350
- async function resolveApiTurnWork(context) {
351
- const batch = parseApiTurnMessages(context.attempt.messages);
352
- if (batch.length > 0) {
353
- return { kind: "mailbox", batch };
354
- }
355
- if (context.attempt.messages.length > 0) {
356
- return void 0;
357
- }
358
- const turnId = await getActiveApiTurnId(context.conversationId);
359
- return turnId ? { kind: "resume", turnId } : void 0;
360
- }
361
- async function isApiTurnWork(context) {
362
- return await resolveApiTurnWork(context) !== void 0;
363
- }
364
-
365
296
  // src/chat/api-turns/work.ts
366
- function normalizeEmail2(email) {
297
+ function normalizeEmail(email) {
367
298
  return email.trim().toLowerCase();
368
299
  }
369
300
  function stableHex(...parts) {
370
- return createHash2("sha256").update(parts.join("\0")).digest("hex").slice(0, 24);
301
+ return createHash("sha256").update(parts.join("\0")).digest("hex").slice(0, 24);
371
302
  }
372
303
  function createApiConversationId(args) {
373
304
  return `local:web:${stableHex(
374
- normalizeEmail2(args.actorEmail),
305
+ normalizeEmail(args.actorEmail),
375
306
  args.idempotencyKey
376
307
  )}`;
377
308
  }
@@ -403,23 +334,23 @@ function webSourceForConversation(args) {
403
334
  args.visibility === "private" ? "private" : "public"
404
335
  );
405
336
  }
406
- function actorFromMetadata(metadata2) {
337
+ function actorFromMetadata(metadata) {
407
338
  return {
408
339
  platform: "web",
409
- userId: metadata2.authorUserId,
410
- email: normalizeEmail2(metadata2.authorEmail),
411
- ...metadata2.authorFullName ? { fullName: metadata2.authorFullName } : void 0,
412
- ...metadata2.authorUserName ? { userName: metadata2.authorUserName } : void 0
340
+ userId: metadata.authorUserId,
341
+ email: normalizeEmail(metadata.authorEmail),
342
+ ...metadata.authorFullName ? { fullName: metadata.authorFullName } : void 0,
343
+ ...metadata.authorUserName ? { userName: metadata.authorUserName } : void 0
413
344
  };
414
345
  }
415
346
  function storedActorFromApi(actor) {
416
347
  return {
417
- ...actor.email ? { email: normalizeEmail2(actor.email) } : void 0,
348
+ ...actor.email ? { email: normalizeEmail(actor.email) } : void 0,
418
349
  ...actor.fullName ? { fullName: actor.fullName } : void 0
419
350
  };
420
351
  }
421
352
  function webActorFromEmail(email, profile) {
422
- const normalized = normalizeEmail2(email);
353
+ const normalized = normalizeEmail(email);
423
354
  return {
424
355
  platform: "web",
425
356
  userId: `dashboard:${stableHex(normalized)}`,
@@ -461,10 +392,10 @@ function buildApiTurnInboundMessage(args) {
461
392
  authorId: args.actor.userId,
462
393
  text,
463
394
  metadata: {
464
- authorEmail: normalizeEmail2(args.actor.email),
465
- ...args.actor.fullName ? { authorFullName: args.actor.fullName } : void 0,
395
+ authorEmail: normalizeEmail(args.actor.email),
396
+ ...args.actor.fullName && { authorFullName: args.actor.fullName },
466
397
  authorUserId: args.actor.userId,
467
- ...args.actor.userName ? { authorUserName: args.actor.userName } : void 0,
398
+ ...args.actor.userName && { authorUserName: args.actor.userName },
468
399
  kind: "api_turn",
469
400
  messageId: args.messageId
470
401
  }
@@ -537,9 +468,10 @@ async function appendAndEnqueueApiConversationMessage(input, options) {
537
468
  conversationId: input.conversationId,
538
469
  conversationStore: options.conversationStore,
539
470
  nowMs,
540
- ...input.rootVisibility ? { rootVisibility: input.rootVisibility } : void 0
471
+ ...input.rootVisibility && { rootVisibility: input.rootVisibility }
541
472
  });
542
- const result = await appendAndEnqueueInboundMessage({
473
+ const enqueue = options.exclusive ? appendAndEnqueueExclusiveInboundMessage : appendAndEnqueueInboundMessage;
474
+ const result = await enqueue({
543
475
  message: buildApiTurnInboundMessage({
544
476
  actor: input.actor,
545
477
  conversationId: input.conversationId,
@@ -553,10 +485,11 @@ async function appendAndEnqueueApiConversationMessage(input, options) {
553
485
  queue: options.queue,
554
486
  state: options.state
555
487
  });
488
+ const status = result.status === "appended" ? "accepted" : result.status;
556
489
  return {
557
490
  conversationId: input.conversationId,
558
491
  messageId,
559
- status: result.status === "duplicate" ? "duplicate" : "accepted"
492
+ status
560
493
  };
561
494
  }
562
495
  function captureApiBoundaryFailure(args) {
@@ -1033,13 +966,13 @@ function routeApiTurnWork(options) {
1033
966
  }
1034
967
 
1035
968
  // src/api/conversations/access.ts
1036
- import { eq as eq3, inArray as inArray2 } from "drizzle-orm";
969
+ import { eq as eq2, inArray as inArray2 } from "drizzle-orm";
1037
970
  import { alias } from "drizzle-orm/pg-core";
1038
971
 
1039
972
  // src/api/conversations/membership.ts
1040
973
  import {
1041
- and as and2,
1042
- eq as eq2,
974
+ and,
975
+ eq,
1043
976
  exists,
1044
977
  inArray,
1045
978
  isNotNull,
@@ -1050,12 +983,12 @@ function conversationHasParticipantUser(userId) {
1050
983
  const participant = getDb().select({
1051
984
  rootConversationId: juniorConversationParticipants.rootConversationId
1052
985
  }).from(juniorConversationParticipants).where(
1053
- and2(
1054
- eq2(
986
+ and(
987
+ eq(
1055
988
  juniorConversationParticipants.rootConversationId,
1056
989
  juniorConversations.conversationId
1057
990
  ),
1058
- eq2(juniorConversationParticipants.userId, userId)
991
+ eq(juniorConversationParticipants.userId, userId)
1059
992
  )
1060
993
  );
1061
994
  return exists(participant);
@@ -1065,14 +998,14 @@ function conversationHasParticipantEmail(email) {
1065
998
  rootConversationId: juniorConversationParticipants.rootConversationId
1066
999
  }).from(juniorConversationParticipants).innerJoin(
1067
1000
  juniorUsers,
1068
- eq2(juniorUsers.id, juniorConversationParticipants.userId)
1001
+ eq(juniorUsers.id, juniorConversationParticipants.userId)
1069
1002
  ).where(
1070
- and2(
1071
- eq2(
1003
+ and(
1004
+ eq(
1072
1005
  juniorConversationParticipants.rootConversationId,
1073
1006
  juniorConversations.conversationId
1074
1007
  ),
1075
- eq2(juniorUsers.primaryEmailNormalized, email)
1008
+ eq(juniorUsers.primaryEmailNormalized, email)
1076
1009
  )
1077
1010
  );
1078
1011
  return exists(participant);
@@ -1081,12 +1014,12 @@ function conversationArchivedForUser(userId) {
1081
1014
  const archive = getDb().select({
1082
1015
  rootConversationId: juniorConversationParticipants.rootConversationId
1083
1016
  }).from(juniorConversationParticipants).where(
1084
- and2(
1085
- eq2(
1017
+ and(
1018
+ eq(
1086
1019
  juniorConversationParticipants.rootConversationId,
1087
1020
  juniorConversations.conversationId
1088
1021
  ),
1089
- eq2(juniorConversationParticipants.userId, userId),
1022
+ eq(juniorConversationParticipants.userId, userId),
1090
1023
  isNotNull(juniorConversationParticipants.archivedAt)
1091
1024
  )
1092
1025
  );
@@ -1096,12 +1029,12 @@ function conversationNotArchivedForUser(userId) {
1096
1029
  const archive = getDb().select({
1097
1030
  rootConversationId: juniorConversationParticipants.rootConversationId
1098
1031
  }).from(juniorConversationParticipants).where(
1099
- and2(
1100
- eq2(
1032
+ and(
1033
+ eq(
1101
1034
  juniorConversationParticipants.rootConversationId,
1102
1035
  juniorConversations.conversationId
1103
1036
  ),
1104
- eq2(juniorConversationParticipants.userId, userId),
1037
+ eq(juniorConversationParticipants.userId, userId),
1105
1038
  isNotNull(juniorConversationParticipants.archivedAt)
1106
1039
  )
1107
1040
  );
@@ -1112,14 +1045,14 @@ function conversationArchivedForEmail(email) {
1112
1045
  rootConversationId: juniorConversationParticipants.rootConversationId
1113
1046
  }).from(juniorConversationParticipants).innerJoin(
1114
1047
  juniorUsers,
1115
- eq2(juniorUsers.id, juniorConversationParticipants.userId)
1048
+ eq(juniorUsers.id, juniorConversationParticipants.userId)
1116
1049
  ).where(
1117
- and2(
1118
- eq2(
1050
+ and(
1051
+ eq(
1119
1052
  juniorConversationParticipants.rootConversationId,
1120
1053
  juniorConversations.conversationId
1121
1054
  ),
1122
- eq2(juniorUsers.primaryEmailNormalized, email),
1055
+ eq(juniorUsers.primaryEmailNormalized, email),
1123
1056
  isNotNull(juniorConversationParticipants.archivedAt)
1124
1057
  )
1125
1058
  );
@@ -1130,14 +1063,14 @@ function conversationNotArchivedForEmail(email) {
1130
1063
  rootConversationId: juniorConversationParticipants.rootConversationId
1131
1064
  }).from(juniorConversationParticipants).innerJoin(
1132
1065
  juniorUsers,
1133
- eq2(juniorUsers.id, juniorConversationParticipants.userId)
1066
+ eq(juniorUsers.id, juniorConversationParticipants.userId)
1134
1067
  ).where(
1135
- and2(
1136
- eq2(
1068
+ and(
1069
+ eq(
1137
1070
  juniorConversationParticipants.rootConversationId,
1138
1071
  juniorConversations.conversationId
1139
1072
  ),
1140
- eq2(juniorUsers.primaryEmailNormalized, email),
1073
+ eq(juniorUsers.primaryEmailNormalized, email),
1141
1074
  isNotNull(juniorConversationParticipants.archivedAt)
1142
1075
  )
1143
1076
  );
@@ -1156,8 +1089,8 @@ async function conversationArchiveTimes(db, conversationIds, subject) {
1156
1089
  rootConversationId: juniorConversationParticipants.rootConversationId
1157
1090
  }).from(juniorConversationParticipants);
1158
1091
  const rows = "userId" in subject ? await query.where(
1159
- and2(
1160
- eq2(juniorConversationParticipants.userId, subject.userId),
1092
+ and(
1093
+ eq(juniorConversationParticipants.userId, subject.userId),
1161
1094
  inArray(juniorConversationParticipants.rootConversationId, [
1162
1095
  ...conversationIds
1163
1096
  ]),
@@ -1165,10 +1098,10 @@ async function conversationArchiveTimes(db, conversationIds, subject) {
1165
1098
  )
1166
1099
  ) : await query.innerJoin(
1167
1100
  juniorUsers,
1168
- eq2(juniorUsers.id, juniorConversationParticipants.userId)
1101
+ eq(juniorUsers.id, juniorConversationParticipants.userId)
1169
1102
  ).where(
1170
- and2(
1171
- eq2(juniorUsers.primaryEmailNormalized, subject.email),
1103
+ and(
1104
+ eq(juniorUsers.primaryEmailNormalized, subject.email),
1172
1105
  inArray(juniorConversationParticipants.rootConversationId, [
1173
1106
  ...conversationIds
1174
1107
  ]),
@@ -1188,8 +1121,8 @@ async function conversationIdsWithParticipantUser(db, conversationIds, userId) {
1188
1121
  const rows = await db.select({
1189
1122
  rootConversationId: juniorConversationParticipants.rootConversationId
1190
1123
  }).from(juniorConversationParticipants).where(
1191
- and2(
1192
- eq2(juniorConversationParticipants.userId, userId),
1124
+ and(
1125
+ eq(juniorConversationParticipants.userId, userId),
1193
1126
  inArray(juniorConversationParticipants.rootConversationId, [
1194
1127
  ...conversationIds
1195
1128
  ])
@@ -1218,16 +1151,16 @@ async function readConversationAccessFromSql(db, conversationIds, viewer) {
1218
1151
  rootUserId: rootIdentity.userId
1219
1152
  }).from(juniorConversations).leftJoin(
1220
1153
  rootConversation,
1221
- eq3(
1154
+ eq2(
1222
1155
  rootConversation.conversationId,
1223
1156
  juniorConversations.rootConversationId
1224
1157
  )
1225
1158
  ).leftJoin(
1226
1159
  rootDestination,
1227
- eq3(rootDestination.id, rootConversation.destinationId)
1160
+ eq2(rootDestination.id, rootConversation.destinationId)
1228
1161
  ).leftJoin(
1229
1162
  rootIdentity,
1230
- eq3(rootIdentity.id, rootConversation.actorIdentityId)
1163
+ eq2(rootIdentity.id, rootConversation.actorIdentityId)
1231
1164
  ).where(inArray2(juniorConversations.conversationId, [...conversationIds]));
1232
1165
  const membershipConversationIds = /* @__PURE__ */ new Set();
1233
1166
  for (const row of rows) {
@@ -1358,6 +1291,7 @@ export {
1358
1291
  resolveSlackConversationContextFromThreadId,
1359
1292
  formatSlackConversationRedactedLabel,
1360
1293
  createApiTurnCancellation,
1294
+ getAuthPausedApiTurnId,
1361
1295
  apiTurnIdForMessage,
1362
1296
  webActorFromEmail,
1363
1297
  recordApiConversationActivity,
@@ -1373,9 +1307,5 @@ export {
1373
1307
  conversationNotArchivedForEmail,
1374
1308
  viewerConversationMembership,
1375
1309
  conversationArchiveTimes,
1376
- readConversationAccessFromSql,
1377
- createPersonalToken,
1378
- listPersonalTokens,
1379
- revokePersonalToken,
1380
- authenticatePersonalToken
1310
+ readConversationAccessFromSql
1381
1311
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logWarn
3
- } from "./chunk-EBMRB6Z6.js";
3
+ } from "./chunk-UQP54CXZ.js";
4
4
 
5
5
  // src/chat/conversation-privacy.ts
6
6
  import { AsyncLocalStorage } from "async_hooks";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-PDO5BLNM.js";
4
4
  import {
5
5
  ToolInputError
6
- } from "./chunk-D6ZD7VXP.js";
6
+ } from "./chunk-2CEOXDG2.js";
7
7
  import {
8
8
  agentHistoryItemSchema,
9
9
  bindProviderConversation,
@@ -16,25 +16,25 @@ import {
16
16
  instructionProvenanceFor,
17
17
  sanitizePostgresJson,
18
18
  withConversationEventLock
19
- } from "./chunk-RNMASWLP.js";
19
+ } from "./chunk-6TSWXBTQ.js";
20
20
  import {
21
21
  SANDBOX_REPOS_ROOT,
22
22
  SANDBOX_WORKSPACE_ROOT,
23
23
  sleep
24
- } from "./chunk-KMBU4PJP.js";
24
+ } from "./chunk-UKIHNBBD.js";
25
25
  import {
26
26
  MUTATION_LOCK_TTL_MS,
27
27
  fenceLock,
28
28
  getStateAdapter,
29
29
  withLock
30
- } from "./chunk-PL57B6NC.js";
30
+ } from "./chunk-Z7ALSQS3.js";
31
31
  import {
32
32
  botConfig,
33
33
  completeText,
34
34
  escapeXml,
35
35
  resolveGatewayModel,
36
36
  unwrapCurrentInstruction
37
- } from "./chunk-XYTJUHRZ.js";
37
+ } from "./chunk-LHQK5XCU.js";
38
38
  import {
39
39
  parseSlackMessageTs,
40
40
  toStoredSlackActor
@@ -44,7 +44,7 @@ import {
44
44
  logException,
45
45
  logWarn,
46
46
  setSpanAttributes
47
- } from "./chunk-EBMRB6Z6.js";
47
+ } from "./chunk-UQP54CXZ.js";
48
48
 
49
49
  // src/chat/turn-context-tag.ts
50
50
  var TURN_CONTEXT_TAG = "runtime-turn-context";