@sentry/junior 0.286.0 → 0.287.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 (69) hide show
  1. package/dist/{adapter-JQZaJ-B_.js → adapter-CL-HUKgd.js} +1 -1
  2. package/dist/{admin-Dm2bimJ-.js → admin-C9urXVfi.js} +2 -1
  3. package/dist/{agent-runner-DGCwOEyL.js → agent-runner-Bfnw551N.js} +644 -312
  4. package/dist/api/schema.d.ts +2 -2
  5. package/dist/api/schema.js +7 -7
  6. package/dist/api.d.ts +1 -1
  7. package/dist/api.js +36 -53
  8. package/dist/{app-BKq0JzWx.d.ts → app-DBY5TnfY.d.ts} +2 -2
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +62 -29
  11. package/dist/{assistant-reply-CAPafcUY.js → assistant-reply-u_PRYzuz.js} +1 -1
  12. package/dist/{automation-B-jJN_gM.js → automation-DksGNDRO.js} +3 -6
  13. package/dist/{background-compaction-queue-Btu2oab_.js → background-compaction-queue-CYI909P5.js} +3 -3
  14. package/dist/{briefs-UMeYehUe.js → briefs-DaXiMWzT.js} +6 -5
  15. package/dist/{catalog-runtime-Bym8GVdh.js → catalog-runtime-BCIuBe4d.js} +1 -1
  16. package/dist/cli/chat.js +14 -14
  17. package/dist/cli/check.js +3 -3
  18. package/dist/cli/main.js +3 -3
  19. package/dist/cli/plugins.js +4 -4
  20. package/dist/cli/snapshot-create.js +4 -4
  21. package/dist/cli/upgrade.d.ts +1 -1
  22. package/dist/cli/upgrade.js +3 -3
  23. package/dist/{client-B0aAs7wC.js → config-CkHcUMN7.js} +580 -3
  24. package/dist/{connections-CQ7p0aNJ.js → connections-BnIj0wtx.js} +9 -9
  25. package/dist/{conversation-BusI2uzj.js → conversation-E7ZPJx2H.js} +8 -1
  26. package/dist/{conversation-pending-messages-DwehU0Fd.js → conversation-pending-messages-DVch6YQw.js} +2 -5
  27. package/dist/{conversation-privacy-Cd_nZZBM.js → conversation-privacy-DF1hW0ja.js} +1 -1
  28. package/dist/{credential-sync-DmiJi_At.js → credential-sync-CzMar9hq.js} +13 -13
  29. package/dist/{viewer-CH-ASQzh.js → db-DJ11eZqq.js} +37 -343
  30. package/dist/{db-C5zi4ecs.d.ts → db-YDKKDxlh.d.ts} +1 -1
  31. package/dist/{executor-Dipi2Ixl.js → executor-BY9TB31g.js} +11 -4
  32. package/dist/instrumentation.js +2 -2
  33. package/dist/{logging-CMFhLLj4.js → logging-BO5zU6Mt.js} +1 -1
  34. package/dist/{media-B-BpXo41.js → media-Cz1ZiV1U.js} +2 -2
  35. package/dist/{message-D1xLljUF.js → message-CsUbuEc8.js} +10 -10
  36. package/dist/nitro.d.ts +1 -1
  37. package/dist/nitro.js +2 -2
  38. package/dist/{oauth-callback-server-DCAFIUQr.js → oauth-callback-server-hiDKK0_n.js} +2 -2
  39. package/dist/{projection-CoeMNxJ4.js → projection-CL_YWeGf.js} +82 -160
  40. package/dist/{prompt-C9OQEfan.js → prompt-BHOEQSmf.js} +182 -2
  41. package/dist/{registry-u-sFYtx_.js → registry-BriFLnaJ.js} +1 -1
  42. package/dist/{reporting-window-B4TwyuJo.js → reporting-window-B3Ze-Qnt.js} +4 -1
  43. package/dist/{resolve-DYqgL3Eo.js → resolve-Bt6GgAiA.js} +3 -3
  44. package/dist/{result-CescSwAw.js → result-Bo1TZu0Q.js} +8 -8
  45. package/dist/{runner-Cr67a8TB.js → runner-D3YeCQgt.js} +8 -8
  46. package/dist/{sandbox-egress-signals-DLOazy5W.js → sandbox-egress-signals-CcnSPP4S.js} +1 -1
  47. package/dist/{schema-BUSi3sgv.js → schema-BWE3RJEB.js} +17 -5
  48. package/dist/{schema-Ih60j59-.d.ts → schema-C6fsEwjo.d.ts} +46 -1
  49. package/dist/{service-account-CGEqz9wG.js → service-account-DiQQuuw7.js} +3 -3
  50. package/dist/{service-account-CsKxktLk.js → service-account-r6fl0b-9.js} +3 -3
  51. package/dist/{session-stop-CGz5DByb.js → session-stop-B2Nut40V.js} +18 -18
  52. package/dist/{skills-COCqf61f.js → skills-CD5aJdzg.js} +2 -2
  53. package/dist/spawn-CalgZQiu.js +79 -0
  54. package/dist/{stop-GyFZkHuQ.js → stop-kujZLbi0.js} +56 -240
  55. package/dist/{store-D0-8plWp.js → store-DdIEUL1q.js} +3 -3
  56. package/dist/{task-runner-xPuQmEot.js → task-runner-D_RDr2Hu.js} +12 -11
  57. package/dist/{turn-failure-response-BOviBdT-.js → turn-failure-response-B5nV1Er-.js} +16 -11
  58. package/dist/{validation-DZDKorGz.js → validation-K4pqwoVZ.js} +1 -1
  59. package/dist/{version-BTIz7fGi.js → version-DBvhk1X9.js} +1 -1
  60. package/dist/version.js +1 -1
  61. package/dist/viewer-DrMmFUul.js +337 -0
  62. package/dist/{work-C75_IM5e.js → work-ljRoODGu.js} +30 -19
  63. package/dist/{worker-Dl47I729.js → worker-CYO1Q0Js.js} +5 -6
  64. package/migrations/0088_conversation_unsubscribe.sql +1 -0
  65. package/migrations/meta/0088_snapshot.json +4372 -0
  66. package/migrations/meta/_journal.json +7 -0
  67. package/package.json +4 -4
  68. package/dist/config-B9f9Lqo5.js +0 -579
  69. package/dist/spawn-C8F_iXWO.js +0 -42
@@ -1,4 +1,4 @@
1
- import { A as reviewItemChangeRecordSchema, i as actorIdentitySchema, l as conversationDetailReportSchema, z as messageAttachmentSchema } from "./conversation-BusI2uzj.js";
1
+ import { A as reviewItemChangeRecordSchema, i as actorIdentitySchema, l as conversationDetailReportSchema, z as messageAttachmentSchema } from "./conversation-E7ZPJx2H.js";
2
2
  import * as z from "zod";
3
3
  // src/reporting-schema.ts
4
4
  const healthReportSchema = z.object({
@@ -102,9 +102,6 @@ const pluginOperationalReportFeedSchema = z.object({
102
102
  reports: z.array(pluginOperationalReportSchema),
103
103
  source: z.literal("plugins")
104
104
  }).strict();
105
- // src/api/schema/common.ts
106
- /** Stable error body returned by Junior-owned REST endpoints. */
107
- const apiErrorSchema = z.object({ error: z.string().min(1) }).strict();
108
105
  // src/api/schema/conversation-pending-messages.ts
109
106
  /** Mailbox delivery mode for one accepted inbound message. */
110
107
  const conversationPendingMessageDeliverySchema = z.enum(["defer", "interrupt"]);
@@ -178,4 +175,4 @@ const steerConversationPendingMessagesResponseSchema = z.object({
178
175
  conversationId: z.string().min(1),
179
176
  steeredInboundMessageIds: z.array(z.string().min(1))
180
177
  }).strict();
181
- export { pluginSchema as _, conversationPendingMessageDeliverySchema as a, skillReportSchema as b, conversationUnchangedDetailWithMailboxSchema as c, apiErrorSchema as d, healthReportSchema as f, pluginPackageContentReportSchema as g, pluginPackageContentItemReportSchema as h, conversationPendingAuthorizationSchema as i, steerConversationPendingMessagesBodySchema as l, pluginOperationalReportSchema as m, cancelConversationPendingMessagesResponseSchema as n, conversationPendingMessageSchema as o, pluginOperationalReportFeedSchema as p, conversationDetailWithMailboxReportSchema as r, conversationPendingMessagesReportSchema as s, cancelConversationPendingMessagesBodySchema as t, steerConversationPendingMessagesResponseSchema as u, pluginsSchema as v, skillReportsSchema as x, runtimeInfoReportSchema as y };
178
+ export { pluginsSchema as _, conversationPendingMessageDeliverySchema as a, skillReportsSchema as b, conversationUnchangedDetailWithMailboxSchema as c, healthReportSchema as d, pluginOperationalReportFeedSchema as f, pluginSchema as g, pluginPackageContentReportSchema as h, conversationPendingAuthorizationSchema as i, steerConversationPendingMessagesBodySchema as l, pluginPackageContentItemReportSchema as m, cancelConversationPendingMessagesResponseSchema as n, conversationPendingMessageSchema as o, pluginOperationalReportSchema as p, conversationDetailWithMailboxReportSchema as r, conversationPendingMessagesReportSchema as s, cancelConversationPendingMessagesBodySchema as t, steerConversationPendingMessagesResponseSchema as u, runtimeInfoReportSchema as v, skillReportSchema as y };
@@ -1,4 +1,4 @@
1
- import { h as logWarn } from "./logging-CMFhLLj4.js";
1
+ import { h as logWarn } from "./logging-BO5zU6Mt.js";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
3
  // src/chat/conversation-privacy.ts
4
4
  const SAFE_METADATA_KEY_LIMIT = 20;
@@ -1,19 +1,19 @@
1
- import { Bn as resolvePluginOAuthAccount, Fi as formatProviderLabel, Ii as parseOAuthStatePayload, In as createUserTokenStore, J as getConversationPendingAuth, Li as resolveBaseUrl, Zi as postSlackMessage, d as recordAuthorizationCompleted, it as getTurnRecord, sa as getSlackClient, u as recordAuthenticationLinked } from "./projection-CoeMNxJ4.js";
2
- import { m as escapeXml } from "./client-B0aAs7wC.js";
3
- import { a as getRuntimeMetadata, n as botConfig } from "./config-B9f9Lqo5.js";
4
- import { H as isNativeIdentityProvider, _ as runBestEffort, h as logWarn, p as logException } from "./logging-CMFhLLj4.js";
1
+ import { $i as postSlackMessage, Hn as resolvePluginOAuthAccount, J as getConversationPendingAuth, Li as formatProviderLabel, Ri as parseOAuthStatePayload, Rn as createUserTokenStore, d as recordAuthorizationCompleted, it as getTurnRecord, la as getSlackClient, u as recordAuthenticationLinked, zi as resolveBaseUrl } from "./projection-CL_YWeGf.js";
2
+ import { M as escapeXml, a as getRuntimeMetadata, n as botConfig } from "./config-CkHcUMN7.js";
3
+ import { H as isNativeIdentityProvider, _ as runBestEffort, h as logWarn, p as logException } from "./logging-BO5zU6Mt.js";
5
4
  import { p as parseSlackUserId } from "./actor-6jsm_v96.js";
6
- import { C as getSqlExecutor, H as resolveActorIdentityId, K as findUserByVerifiedEmails, X as upsertLinkedIdentity, o as readIdentityById } from "./viewer-CH-ASQzh.js";
5
+ import { D as resolveActorIdentityId, F as upsertLinkedIdentity, j as findUserByVerifiedEmails, s as getSqlExecutor } from "./db-DJ11eZqq.js";
7
6
  import { i as homeDir } from "./package-discovery-DJhGdS4c.js";
8
- import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-u-sFYtx_.js";
9
- import { n as pluginCatalogRuntime } from "./catalog-runtime-Bym8GVdh.js";
10
- import { t as discoverSkills } from "./skills-COCqf61f.js";
11
- import { Mt as deleteWebAuthorization, d as getMcpAuthSession, f as getMcpStoredOAuthCredentials, o as finalizeMcpAuthorization, p as putMcpStoredOAuthCredentials, s as deleteMcpAuthSession, y as lookupSlackUserProfile } from "./agent-runner-DGCwOEyL.js";
7
+ import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-BriFLnaJ.js";
8
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-BCIuBe4d.js";
9
+ import { t as discoverSkills } from "./skills-CD5aJdzg.js";
10
+ import { a as finalizeMcpAuthorization, d as getMcpStoredOAuthCredentials, f as putMcpStoredOAuthCredentials, o as deleteMcpAuthSession, u as getMcpAuthSession, y as lookupSlackUserProfile, zt as deleteWebAuthorization } from "./agent-runner-Bfnw551N.js";
12
11
  import { r as acquireActiveLock } from "./locks-D-0h111u.js";
13
- import { r as getStateAdapter } from "./adapter-JQZaJ-B_.js";
14
- import { _t as getPersistedThreadState, bt as coerceThreadConversationState } from "./task-runner-xPuQmEot.js";
15
- import { _ as getMcpProviderErrorAttributes } from "./service-account-CGEqz9wG.js";
16
- import { d as wakePausedTurn, i as readConnectedOAuthTokens, s as htmlCallbackResponse, u as wakeAuthorizedTurn } from "./connections-CQ7p0aNJ.js";
12
+ import { o as readIdentityById } from "./viewer-DrMmFUul.js";
13
+ import { r as getStateAdapter } from "./adapter-CL-HUKgd.js";
14
+ import { _t as getPersistedThreadState, bt as coerceThreadConversationState } from "./task-runner-D_RDr2Hu.js";
15
+ import { _ as getMcpProviderErrorAttributes } from "./service-account-DiQQuuw7.js";
16
+ import { d as wakePausedTurn, i as readConnectedOAuthTokens, s as htmlCallbackResponse, u as wakeAuthorizedTurn } from "./connections-BnIj0wtx.js";
17
17
  import { n as relayLocalOAuthCallback } from "./oauth-relay-D6xxVywK.js";
18
18
  import path from "node:path";
19
19
  import { createHmac, createSecretKey, timingSafeEqual } from "node:crypto";
@@ -1,13 +1,12 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { i as getChatConfig } from "./config-B9f9Lqo5.js";
3
- import { U as normalizeIdentityEmail, V as GOOGLE_IDENTITY_PROVIDER, h as logWarn } from "./logging-CMFhLLj4.js";
2
+ import { i as getChatConfig } from "./config-CkHcUMN7.js";
3
+ import { U as normalizeIdentityEmail, V as GOOGLE_IDENTITY_PROVIDER, h as logWarn } from "./logging-BO5zU6Mt.js";
4
4
  import { a as isSlackUserId, d as parseSlackChannelReferenceId, f as parseSlackTeamId, s as parseActorUserId } from "./actor-6jsm_v96.js";
5
- import { A as juniorConversations, E as juniorConversationAnnotations, M as juniorUsers, N as juniorDestinations, S as juniorConversationMetrics, j as juniorIdentities, t as createJuniorSqlExecutor, v as juniorConversationParticipants, w as juniorConversationEvents, x as CONVERSATION_METRICS, y as juniorConversationBindings } from "./executor-Dipi2Ixl.js";
6
- import { d as historyReplacementSchema, f as newConversationEventSchema, p as encodeHistoryPayload, r as detectImageMediaType, s as conversationEventDataSchema, u as decodeStoredConversationEvent, y as usageSchema } from "./media-B-BpXo41.js";
7
- import { a as withLock } from "./locks-D-0h111u.js";
8
- import { createHash, randomUUID } from "node:crypto";
9
- import { and, asc, desc, eq, gt, gte, inArray, isNotNull, isNull, lt, lte, ne, or, sql } from "drizzle-orm";
10
- import { destinationSchema, identitySchema, locationSchema, sourceSchema, userSchema } from "@sentry/junior-plugin-api";
5
+ import { A as juniorConversations, E as juniorConversationAnnotations, M as juniorUsers, N as juniorDestinations, S as juniorConversationMetrics, j as juniorIdentities, t as createJuniorSqlExecutor, v as juniorConversationParticipants, w as juniorConversationEvents, x as CONVERSATION_METRICS, y as juniorConversationBindings } from "./executor-BY9TB31g.js";
6
+ import { d as historyReplacementSchema, f as newConversationEventSchema, p as encodeHistoryPayload, s as conversationEventDataSchema, u as decodeStoredConversationEvent, y as usageSchema } from "./media-Cz1ZiV1U.js";
7
+ import { randomUUID } from "node:crypto";
8
+ import { and, asc, desc, eq, gt, gte, inArray, isNull, lt, lte, ne, or, sql } from "drizzle-orm";
9
+ import { destinationSchema, locationSchema, sourceSchema } from "@sentry/junior-plugin-api";
11
10
  import { alias } from "drizzle-orm/pg-core";
12
11
  // src/chat/destination.ts
13
12
  /** Build Junior's canonical destination from Slack workspace and channel ids. */
@@ -44,10 +43,16 @@ async function resolveRootConversationId(executor, conversationId) {
44
43
  const [row] = await executor.db().select({ rootConversationId: juniorConversations.rootConversationId }).from(juniorConversations).where(eq(juniorConversations.conversationId, conversationId)).limit(1);
45
44
  return row?.rootConversationId ?? conversationId;
46
45
  }
46
+ /** True when the root of this conversation is archived. */
47
+ async function rootConversationIsArchived(executor, conversationId) {
48
+ const rootConversationId = await resolveRootConversationId(executor, conversationId);
49
+ const [row] = await executor.db().select({ archivedAt: juniorConversations.archivedAt }).from(juniorConversations).where(eq(juniorConversations.conversationId, rootConversationId)).limit(1);
50
+ return Boolean(row?.archivedAt);
51
+ }
47
52
  /**
48
53
  * Upsert one linked user as a participant on a root conversation.
49
54
  * No-ops and returns false when the identity is missing, unlinked, or not a
50
- * user.
55
+ * user. `resubscribe` ends an unsubscribe: the user addressed Junior again.
51
56
  */
52
57
  async function recordConversationParticipant(executor, args) {
53
58
  const [identity] = await executor.db().select({
@@ -63,7 +68,10 @@ async function recordConversationParticipant(executor, args) {
63
68
  lastMessageAt: at
64
69
  }).onConflictDoUpdate({
65
70
  target: [juniorConversationParticipants.userId, juniorConversationParticipants.rootConversationId],
66
- set: { lastMessageAt: sql`greatest(${juniorConversationParticipants.lastMessageAt}, excluded.last_message_at)` }
71
+ set: {
72
+ lastMessageAt: sql`greatest(${juniorConversationParticipants.lastMessageAt}, excluded.last_message_at)`,
73
+ ...args.resubscribe ? { unsubscribedAt: null } : void 0
74
+ }
67
75
  });
68
76
  return true;
69
77
  }
@@ -1470,6 +1478,16 @@ const HUMAN_INSTRUCTION_PLATFORMS = /* @__PURE__ */ new Set([
1470
1478
  "web"
1471
1479
  ]);
1472
1480
  /**
1481
+ * True when a Turn input message is addressed to Junior, which subscribes its
1482
+ * author again (contract: `api/conversations/subscription.ts`). A Slack
1483
+ * message in a subscribed thread that does not mention Junior is marked
1484
+ * `explicitMention: false`. Other Sources, such as the dashboard and Slack
1485
+ * mentions and DMs, always address Junior.
1486
+ */
1487
+ function eventAddressesJunior(data) {
1488
+ return data.type === "message" && data.meta?.explicitMention !== false;
1489
+ }
1490
+ /**
1473
1491
  * Whether one event should restore an archived conversation to the feed.
1474
1492
  *
1475
1493
  * Archive hides finished noise until a human comes back. Events,
@@ -1584,16 +1602,19 @@ var SqlConversationEventStore = class {
1584
1602
  */
1585
1603
  async recordTurnInputParticipants(conversationId, inputMessageIds) {
1586
1604
  const rows = await this.executor.db().select().from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, conversationId), eq(juniorConversationEvents.type, "message"), inArray(sql`${juniorConversationEvents.payload}->>'messageId'`, [...inputMessageIds])));
1605
+ const rootArchived = await rootConversationIsArchived(this.executor, conversationId);
1587
1606
  let restores = false;
1588
1607
  for (const row of rows) {
1589
1608
  const { data } = eventFromRow(row);
1590
1609
  if (!row.actorIdentityId || data.type !== "message") continue;
1610
+ const unarchives = eventUnarchivesConversation(data);
1591
1611
  const isPerson = await recordConversationParticipant(this.executor, {
1592
1612
  actorIdentityId: row.actorIdentityId,
1593
1613
  conversationId,
1594
- atMs: row.createdAt.getTime()
1614
+ atMs: row.createdAt.getTime(),
1615
+ resubscribe: eventAddressesJunior(data) || rootArchived && unarchives
1595
1616
  });
1596
- restores ||= isPerson && eventUnarchivesConversation(data);
1617
+ restores ||= isPerson && unarchives;
1597
1618
  }
1598
1619
  if (restores) await restoreArchivedPath(this.executor.db(), conversationId);
1599
1620
  }
@@ -1652,6 +1673,9 @@ var SqlConversationEventStore = class {
1652
1673
  async loadHistory(conversationId) {
1653
1674
  return (await this.executor.db().select().from(juniorConversationEvents).where(eq(juniorConversationEvents.conversationId, conversationId)).orderBy(asc(juniorConversationEvents.seq))).map(eventFromRow);
1654
1675
  }
1676
+ async loadEventsOfType(conversationId, type) {
1677
+ return (await this.executor.db().select().from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, conversationId), eq(juniorConversationEvents.type, type))).orderBy(asc(juniorConversationEvents.seq))).map(eventFromRow);
1678
+ }
1655
1679
  async query(conversationId, query) {
1656
1680
  if (query.limit < 1) throw new Error("Conversation event query limit must be at least 1");
1657
1681
  if (query.afterSeq !== void 0 && query.beforeSeq !== void 0 && query.afterSeq >= query.beforeSeq) return {
@@ -1776,8 +1800,6 @@ var SqlConversationMessageSearchStore = class {
1776
1800
  isNull(juniorConversations.parentConversationId),
1777
1801
  isNull(juniorConversations.transcriptPurgedAt),
1778
1802
  ne(juniorConversations.conversationId, args.currentConversationId),
1779
- eq(juniorDestinations.provider, args.scope.provider),
1780
- eq(juniorDestinations.providerTenantId, args.scope.providerTenantId),
1781
1803
  eq(juniorDestinations.visibility, "public"),
1782
1804
  eq(juniorConversationEvents.type, "message"),
1783
1805
  sql`${role} in ('user', 'assistant')`
@@ -1881,332 +1903,4 @@ async function closeDb() {
1881
1903
  current = void 0;
1882
1904
  await previous?.db.close();
1883
1905
  }
1884
- // src/chat/state/cache.ts
1885
- const MAX_CACHE_KEY_LENGTH = 512;
1886
- const LOAD_WAIT_MS = 1e4;
1887
- /**
1888
- * Create a cache in the state adapter under `junior:cache:{namespace}:`.
1889
- * Entries are wrapped, so `null` and `false` values are cache hits.
1890
- */
1891
- function createCache(state, namespace) {
1892
- return { async getOrLoad(key, load, options) {
1893
- if (!key.trim()) throw new Error("Cache key is required");
1894
- if (key.length > MAX_CACHE_KEY_LENGTH) throw new Error("Cache key exceeds the maximum length");
1895
- const cacheKey = `junior:cache:${namespace}:${key}`;
1896
- const cached = async () => options?.refresh ? void 0 : await state.get(cacheKey) ?? void 0;
1897
- await state.connect();
1898
- const hit = await cached();
1899
- if (hit) return hit.value;
1900
- const attempt = await withLock(state, `${cacheKey}:load`, async () => {
1901
- const loadedMeanwhile = await cached();
1902
- if (loadedMeanwhile) return loadedMeanwhile.value;
1903
- const entry = await load();
1904
- if (entry.ttlMs !== void 0) {
1905
- if (!(entry.ttlMs > 0)) throw new Error("Cache ttlMs must be positive");
1906
- await state.set(cacheKey, { value: entry.value }, entry.ttlMs);
1907
- }
1908
- return entry.value;
1909
- }, {
1910
- keepAlive: true,
1911
- waitMs: LOAD_WAIT_MS
1912
- });
1913
- if (attempt.acquired) return attempt.value;
1914
- return (await load()).value;
1915
- } };
1916
- }
1917
- // src/chat/identities/avatar.ts
1918
- /**
1919
- * Profile photos of people, saved on their native Slack and Google
1920
- * identities. Junior serves each photo from its own API, so browsers never
1921
- * load a photo from Slack or Google.
1922
- */
1923
- const AVATAR_HOSTS = {
1924
- slack: ["avatars.slack-edge.com"],
1925
- [GOOGLE_IDENTITY_PROVIDER]: ["googleusercontent.com"]
1926
- };
1927
- const AVATAR_PROVIDERS = Object.keys(AVATAR_HOSTS);
1928
- const AVATAR_CACHE_TTL_MS = 864e5;
1929
- const AVATAR_FAILURE_TTL_MS = 3e5;
1930
- const AVATAR_FETCH_TIMEOUT_MS = 5e3;
1931
- const MAX_AVATAR_BYTES = 1048576;
1932
- const AVATAR_EDGE_PX = 96;
1933
- const MAX_AVATAR_REDIRECTS = 3;
1934
- /**
1935
- * Return the URL when it is HTTPS on a photo host of the provider or a
1936
- * subdomain. Junior fetches only these URLs.
1937
- */
1938
- function parseAvatarUrl(value, provider) {
1939
- const hosts = AVATAR_HOSTS[provider];
1940
- if (!hosts || !value || !URL.canParse(value)) return void 0;
1941
- const url = new URL(value);
1942
- if (url.protocol !== "https:" || url.username || url.password) return;
1943
- const host = url.hostname.toLowerCase();
1944
- return hosts.some((allowed) => host === allowed || host.endsWith(`.${allowed}`)) ? url.href : void 0;
1945
- }
1946
- function avatarUrlHash(url) {
1947
- return createHash("sha256").update(url).digest("hex");
1948
- }
1949
- function avatarVersion(url) {
1950
- return avatarUrlHash(url).slice(0, 16);
1951
- }
1952
- function avatarPath(identityId, avatarUrl) {
1953
- return `/api/people/avatars/${encodeURIComponent(identityId)}?v=${avatarVersion(avatarUrl)}`;
1954
- }
1955
- /**
1956
- * Read the photo path of each user: the Slack photo, then the Google photo.
1957
- * Users without a photo are not in the map.
1958
- */
1959
- async function readUserAvatarUrls(db, userIds) {
1960
- if (userIds.length === 0) return /* @__PURE__ */ new Map();
1961
- const rows = await db.select({
1962
- avatarUrl: juniorIdentities.avatarUrl,
1963
- identityId: juniorIdentities.id,
1964
- provider: juniorIdentities.provider,
1965
- updatedAt: juniorIdentities.updatedAt,
1966
- userId: juniorIdentities.userId
1967
- }).from(juniorIdentities).where(and(inArray(juniorIdentities.userId, [...new Set(userIds)]), eq(juniorIdentities.kind, "user"), inArray(juniorIdentities.provider, AVATAR_PROVIDERS), isNotNull(juniorIdentities.avatarUrl)));
1968
- const rank = (row) => AVATAR_PROVIDERS.indexOf(row.provider);
1969
- rows.sort((left, right) => rank(left) - rank(right) || right.updatedAt.getTime() - left.updatedAt.getTime());
1970
- const avatars = /* @__PURE__ */ new Map();
1971
- for (const row of rows) if (row.userId && row.avatarUrl && !avatars.has(row.userId)) avatars.set(row.userId, avatarPath(row.identityId, row.avatarUrl));
1972
- return avatars;
1973
- }
1974
- /**
1975
- * Return the photo path for one Identity row. A linked Identity uses the
1976
- * photo of its user. An Identity without a user uses its own photo.
1977
- */
1978
- function identityAvatarUrl(row, userAvatarUrls) {
1979
- if (row.userId) return userAvatarUrls.get(row.userId);
1980
- return row.avatarUrl ? avatarPath(row.identityId, row.avatarUrl) : void 0;
1981
- }
1982
- async function readBoundedBody(response, maxBytes) {
1983
- if (!response.body) return /* @__PURE__ */ new Uint8Array();
1984
- const reader = response.body.getReader();
1985
- const chunks = [];
1986
- let total = 0;
1987
- while (true) {
1988
- const { done, value } = await reader.read();
1989
- if (done) return Buffer.concat(chunks);
1990
- total += value.byteLength;
1991
- if (total > maxBytes) {
1992
- await reader.cancel();
1993
- return;
1994
- }
1995
- chunks.push(value);
1996
- }
1997
- }
1998
- function avatarFetchFailed(host, attributes) {
1999
- logWarn("avatar.fetch.failed", {
2000
- "server.address": host,
2001
- ...attributes
2002
- });
2003
- return null;
2004
- }
2005
- async function fetchAvatarResponse(url, provider, signal) {
2006
- let current = url;
2007
- for (let redirects = 0;; redirects += 1) {
2008
- const response = await fetch(current, {
2009
- redirect: "manual",
2010
- signal
2011
- });
2012
- const location = response.headers.get("location");
2013
- if (response.status < 300 || response.status >= 400 || !location) return response;
2014
- await response.body?.cancel();
2015
- const next = URL.canParse(location, current) ? parseAvatarUrl(new URL(location, current).href, provider) : void 0;
2016
- if (!next) return "redirect_off_host";
2017
- if (redirects >= MAX_AVATAR_REDIRECTS) return "too_many_redirects";
2018
- current = next;
2019
- }
2020
- }
2021
- async function fetchAvatarImage(url, provider) {
2022
- const host = new URL(url).hostname;
2023
- let data;
2024
- try {
2025
- const response = await fetchAvatarResponse(url, provider, AbortSignal.timeout(AVATAR_FETCH_TIMEOUT_MS));
2026
- if (typeof response === "string") return avatarFetchFailed(host, { "app.reason": response });
2027
- if (!response.ok) {
2028
- await response.body?.cancel();
2029
- return avatarFetchFailed(host, { "http.response.status_code": response.status });
2030
- }
2031
- data = await readBoundedBody(response, MAX_AVATAR_BYTES);
2032
- } catch (error) {
2033
- return avatarFetchFailed(host, { "exception.message": error instanceof Error ? error.message : String(error) });
2034
- }
2035
- if (!data) return avatarFetchFailed(host, { "app.reason": "too_large" });
2036
- const contentType = detectImageMediaType(data);
2037
- if (!contentType) return avatarFetchFailed(host, { "app.reason": "not_an_image" });
2038
- try {
2039
- return {
2040
- contentType: "image/webp",
2041
- data: await shrinkAvatar(data)
2042
- };
2043
- } catch (error) {
2044
- logWarn("avatar.resize.failed", {
2045
- "server.address": host,
2046
- "exception.message": error instanceof Error ? error.message : String(error)
2047
- });
2048
- return {
2049
- contentType,
2050
- data: Buffer.from(data).toString("base64")
2051
- };
2052
- }
2053
- }
2054
- async function shrinkAvatar(data) {
2055
- const { default: sharp } = await import("sharp");
2056
- return (await sharp(data).rotate().resize({
2057
- width: AVATAR_EDGE_PX,
2058
- height: AVATAR_EDGE_PX,
2059
- withoutEnlargement: true
2060
- }).webp({ quality: 80 }).toBuffer()).toString("base64");
2061
- }
2062
- /**
2063
- * Read the saved photo of one Identity and its version. Junior fetches it
2064
- * from the provider once, resizes it, and keeps it in the state cache for a
2065
- * day. Return undefined when the Identity has no photo or the provider does
2066
- * not return one.
2067
- */
2068
- async function readAvatarImage(db, state, identityId) {
2069
- const [row] = await db.select({
2070
- avatarUrl: juniorIdentities.avatarUrl,
2071
- provider: juniorIdentities.provider
2072
- }).from(juniorIdentities).where(and(eq(juniorIdentities.id, identityId), eq(juniorIdentities.kind, "user"))).limit(1);
2073
- const url = row ? parseAvatarUrl(row.avatarUrl, row.provider) : void 0;
2074
- if (!row?.avatarUrl || !url) return void 0;
2075
- const key = `avatar:${AVATAR_EDGE_PX}:${avatarUrlHash(url)}`;
2076
- const image = await createCache(state, "core").getOrLoad(key, async () => {
2077
- const loaded = await fetchAvatarImage(url, row.provider);
2078
- return {
2079
- value: loaded,
2080
- ttlMs: loaded ? AVATAR_CACHE_TTL_MS : AVATAR_FAILURE_TTL_MS
2081
- };
2082
- });
2083
- return image ? {
2084
- image,
2085
- version: avatarVersion(row.avatarUrl)
2086
- } : void 0;
2087
- }
2088
- // src/chat/plugins/viewer.ts
2089
- function identityFromRow(row) {
2090
- return identitySchema.parse({
2091
- id: row.id,
2092
- provider: row.provider,
2093
- providerSubjectId: row.providerSubjectId,
2094
- ...row.providerTenantId ? { providerTenantId: row.providerTenantId } : void 0,
2095
- ...row.displayName ? { displayName: row.displayName } : void 0,
2096
- ...row.handle ? { handle: row.handle } : void 0
2097
- });
2098
- }
2099
- async function readUserById(db, userRow) {
2100
- return userFromRows(userRow, await db.select().from(juniorIdentities).where(and(eq(juniorIdentities.userId, userRow.id), eq(juniorIdentities.kind, "user"))).orderBy(asc(juniorIdentities.provider), asc(juniorIdentities.providerTenantId), asc(juniorIdentities.providerSubjectId)));
2101
- }
2102
- function userFromRows(userRow, identityRows) {
2103
- return userSchema.parse({
2104
- email: userRow.primaryEmail,
2105
- id: userRow.id,
2106
- identities: identityRows.map(identityFromRow),
2107
- ...userRow.displayName ? { displayName: userRow.displayName } : void 0,
2108
- ...userRow.isAdmin ? { isAdmin: true } : void 0
2109
- });
2110
- }
2111
- async function readUserByNormalizedEmail(db, normalizedEmail) {
2112
- const rows = await db.select({
2113
- user: juniorUsers,
2114
- identity: juniorIdentities
2115
- }).from(juniorUsers).leftJoin(juniorIdentities, and(eq(juniorIdentities.userId, juniorUsers.id), eq(juniorIdentities.kind, "user"))).where(eq(juniorUsers.primaryEmailNormalized, normalizedEmail)).orderBy(asc(juniorIdentities.provider), asc(juniorIdentities.providerTenantId), asc(juniorIdentities.providerSubjectId));
2116
- const userRow = rows[0]?.user;
2117
- if (!userRow) return void 0;
2118
- return userFromRows(userRow, rows.flatMap((row) => row.identity ? [row.identity] : []));
2119
- }
2120
- /** Resolve or create the canonical user for one verified viewer email. */
2121
- async function resolveViewerUserFromSql(db, email) {
2122
- const normalizedEmail = normalizeIdentityEmail(email);
2123
- if (!normalizedEmail) return void 0;
2124
- const existing = await readUserByNormalizedEmail(db, normalizedEmail);
2125
- if (existing) return existing;
2126
- const now = /* @__PURE__ */ new Date();
2127
- const userRow = (await db.insert(juniorUsers).values({
2128
- id: randomUUID(),
2129
- primaryEmail: email.trim(),
2130
- primaryEmailNormalized: normalizedEmail,
2131
- displayName: null,
2132
- createdAt: now,
2133
- updatedAt: now
2134
- }).onConflictDoNothing({ target: juniorUsers.primaryEmailNormalized }).returning())[0] ?? (await db.select().from(juniorUsers).where(eq(juniorUsers.primaryEmailNormalized, normalizedEmail)).limit(1))[0];
2135
- return userRow ? await readUserById(db, userRow) : void 0;
2136
- }
2137
- /** Resolve or create the canonical user for one authenticated viewer. */
2138
- async function resolveViewerUser(email) {
2139
- return await resolveViewerUserFromSql(getDb(), email);
2140
- }
2141
- /** Read one existing canonical user by verified email without creating a row. */
2142
- async function findUserByEmailFromSql(db, email) {
2143
- const normalizedEmail = normalizeIdentityEmail(email);
2144
- if (!normalizedEmail) return void 0;
2145
- return await readUserByNormalizedEmail(db, normalizedEmail);
2146
- }
2147
- /** Read one existing canonical user by verified email without creating a row. */
2148
- async function findUserByEmail(email) {
2149
- return await findUserByEmailFromSql(getDb(), email);
2150
- }
2151
- /** Update one canonical user's display name in SQL. */
2152
- async function updateViewerDisplayNameFromSql(db, userId, displayName) {
2153
- const userRow = (await db.update(juniorUsers).set({
2154
- displayName,
2155
- updatedAt: /* @__PURE__ */ new Date()
2156
- }).where(eq(juniorUsers.id, userId)).returning())[0];
2157
- return userRow ? await readUserById(db, userRow) : void 0;
2158
- }
2159
- /** Read the photo path of one canonical user: Slack, then Google. */
2160
- async function readViewerAvatarUrl(userId) {
2161
- return (await readUserAvatarUrls(getDb(), [userId])).get(userId);
2162
- }
2163
- /** Update one canonical user's display name. */
2164
- async function updateViewerDisplayName(userId, displayName) {
2165
- return await updateViewerDisplayNameFromSql(getDb(), userId, displayName);
2166
- }
2167
- /**
2168
- * Grant or revoke the Junior-wide admin role for one email.
2169
- *
2170
- * Granting creates the canonical user when needed, so an operator can grant
2171
- * admin before that person first signs in. Revoking never creates a user.
2172
- */
2173
- async function setUserAdminFromSql(db, email, isAdmin) {
2174
- const user = isAdmin ? await resolveViewerUserFromSql(db, email) : await findUserByEmailFromSql(db, email);
2175
- if (!user) return void 0;
2176
- const userRow = (await db.update(juniorUsers).set({
2177
- isAdmin,
2178
- updatedAt: /* @__PURE__ */ new Date()
2179
- }).where(eq(juniorUsers.id, user.id)).returning())[0];
2180
- return userRow ? await readUserById(db, userRow) : void 0;
2181
- }
2182
- /** List every Junior admin by primary email. */
2183
- async function listAdminUsersFromSql(db) {
2184
- const rows = await db.select().from(juniorUsers).where(eq(juniorUsers.isAdmin, true)).orderBy(asc(juniorUsers.primaryEmailNormalized));
2185
- return await Promise.all(rows.map((row) => readUserById(db, row)));
2186
- }
2187
- /** Resolve the stored identity and linked user for one runtime actor. */
2188
- async function readActorIdentityFromSql(db, actor) {
2189
- const identityId = await findActorIdentityId(db, actor);
2190
- return identityId ? await readIdentityByIdFromSql(db, identityId) : void 0;
2191
- }
2192
- /** Resolve the stored identity and linked user for one runtime actor. */
2193
- async function readActorIdentity(actor) {
2194
- return await readActorIdentityFromSql(getDb(), actor);
2195
- }
2196
- /** Read one stored identity and its linked user by identity id. */
2197
- async function readIdentityByIdFromSql(db, identityId) {
2198
- const row = (await db.select({
2199
- identity: juniorIdentities,
2200
- user: juniorUsers
2201
- }).from(juniorIdentities).leftJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(and(eq(juniorIdentities.id, identityId), eq(juniorIdentities.kind, "user"))).limit(1))[0];
2202
- if (!row) return void 0;
2203
- return {
2204
- identity: identityFromRow(row.identity),
2205
- ...row.user ? { user: await readUserById(db, row.user) } : void 0
2206
- };
2207
- }
2208
- /** Read one stored identity and its linked user by identity id. */
2209
- async function readIdentityById(identityId) {
2210
- return await readIdentityByIdFromSql(getDb(), identityId);
2211
- }
2212
- export { conversationDetailTouch as $, conversationAncestors as A, startLocationThread as B, getSqlExecutor as C, createSqlConversationEventStore as D, treeHasAnnotationKey as E, createSqlStore as F, deleteProviderIdentityForUser as G, resolveActorIdentityId as H, withConversationMutationLock as I, recordGoogleSignIn as J, findUserByVerifiedEmails as K, conversationKindFromRow as L, readConversationTrees as M, setArchivedAt as N, eventFromRow as O, loadConversationSlackTenantIds as P, parseSessionSource as Q, locationFromRow as R, getDb as S, hasAnnotationKey as T, saveActorAvatar as U, SYSTEM_IDENTITY_ID as V, deleteProviderIdentityForSlackUser as W, upsertLinkedIdentity as X, saveUserTimezone as Y, bindProviderConversation as Z, closeDb as _, readActorIdentityFromSql as a, agentTurnUsageSchema as at, getConversationMessageSearchStore as b, readViewerAvatarUrl as c, createSlackDestination as ct, updateViewerDisplayName as d, sameDestination as dt, nextDetailVersion as et, identityAvatarUrl as f, createCache as g, readUserAvatarUrls as h, readActorIdentity as i, agentTurnTotalTokens as it, conversationDescendants as j, withConversationEventLock as k, resolveViewerUser as l, parseDestination as lt, readAvatarImage as m, findUserByEmailFromSql as n, addAgentTurnUsage as nt, readIdentityById as o, hasAgentTurnUsage as ot, parseAvatarUrl as p, readUserTimezone as q, listAdminUsersFromSql as r, agentTurnCostUsd as rt, readIdentityByIdFromSql as s, resolveRootConversationId as st, findUserByEmail as t, touchConversationDetail as tt, setUserAdminFromSql as u, requireSlackDestination as ut, db_exports as v, conversationIdsWithAnnotation as w, getConversationStore as x, getConversationEventStore as y, setFirstConversationLocation as z };
1906
+ export { deleteProviderIdentityForUser as A, touchConversationDetail as B, setFirstConversationLocation as C, resolveActorIdentityId as D, findActorIdentityId as E, upsertLinkedIdentity as F, hasAgentTurnUsage as G, agentTurnCostUsd as H, bindProviderConversation as I, parseDestination as J, resolveRootConversationId as K, parseSessionSource as L, readUserTimezone as M, recordGoogleSignIn as N, saveActorAvatar as O, saveUserTimezone as P, conversationDetailTouch as R, locationFromRow as S, SYSTEM_IDENTITY_ID as T, agentTurnTotalTokens as U, addAgentTurnUsage as V, agentTurnUsageSchema as W, sameDestination as X, requireSlackDestination as Y, setArchivedAt as _, getConversationStore as a, withConversationMutationLock as b, conversationIdsWithAnnotation as c, createSqlConversationEventStore as d, eventFromRow as f, readConversationTrees as g, conversationDescendants as h, getConversationMessageSearchStore as i, findUserByVerifiedEmails as j, deleteProviderIdentityForSlackUser as k, hasAnnotationKey as l, conversationAncestors as m, db_exports as n, getDb as o, withConversationEventLock as p, createSlackDestination as q, getConversationEventStore as r, getSqlExecutor as s, closeDb as t, treeHasAnnotationKey as u, loadConversationSlackTenantIds as v, startLocationThread as w, conversationKindFromRow as x, createSqlStore as y, nextDetailVersion as z };
@@ -1,4 +1,4 @@
1
- import "./schema-Ih60j59-.js";
1
+ import "./schema-C6fsEwjo.js";
2
2
  import * as z from "zod";
3
3
  import "drizzle-orm";
4
4
  import { Destination, Source, locationSchema } from "@sentry/junior-plugin-api";
@@ -1,5 +1,5 @@
1
- import "./config-B9f9Lqo5.js";
2
- import { p as logException } from "./logging-CMFhLLj4.js";
1
+ import "./config-CkHcUMN7.js";
2
+ import { p as logException } from "./logging-BO5zU6Mt.js";
3
3
  import { AsyncLocalStorage } from "node:async_hooks";
4
4
  import { sql } from "drizzle-orm";
5
5
  import { bigint, boolean, check, date, doublePrecision, foreignKey, index, integer, jsonb, pgTable, primaryKey, text, timestamp, uniqueIndex, uuid } from "drizzle-orm/pg-core";
@@ -366,7 +366,8 @@ const juniorConversationBindings = pgTable("junior_conversation_bindings", {
366
366
  /**
367
367
  * Materialized personal-feed membership for one linked user on one root
368
368
  * conversation. Rows come from the root actor and from the authors of Turn
369
- * input messages. Thread context authors do not get a row.
369
+ * input messages. Thread context authors do not get a row. An unsubscribed
370
+ * row keeps access but leaves the active feed.
370
371
  */
371
372
  const juniorConversationParticipants = pgTable("junior_conversation_participants", {
372
373
  userId: text("user_id").notNull().references(() => juniorUsers.id),
@@ -384,7 +385,13 @@ const juniorConversationParticipants = pgTable("junior_conversation_participants
384
385
  * Per-conversation auto-archive choice for this user. Null uses the
385
386
  * user's `autoArchiveDefault`.
386
387
  */
387
- autoArchive: boolean("auto_archive")
388
+ autoArchive: boolean("auto_archive"),
389
+ /**
390
+ * Set when this user left the conversation. It stays out of their
391
+ * active feed until they mention Junior in it again, subscribe, or pin
392
+ * it. The row keeps its access, so it is not deleted.
393
+ */
394
+ unsubscribedAt: timestamptz("unsubscribed_at")
388
395
  }, (table) => [
389
396
  primaryKey({
390
397
  name: "junior_conversation_participants_user_root_pk",
@@ -1,6 +1,6 @@
1
1
  import { a as getClient, c as init, i as getActiveSpan, o as getGlobalScope, p as spanToJSON, s as getTraceData } from "./sentry-BRTJqumy.js";
2
- import { R as getDeploymentServiceVersion, z as getDeploymentTelemetryAttributes } from "./logging-CMFhLLj4.js";
3
- import { n as getCurrentConversationPrivacy } from "./conversation-privacy-Cd_nZZBM.js";
2
+ import { R as getDeploymentServiceVersion, z as getDeploymentTelemetryAttributes } from "./logging-BO5zU6Mt.js";
3
+ import { n as getCurrentConversationPrivacy } from "./conversation-privacy-DF1hW0ja.js";
4
4
  import { n as redactSandboxEgressProxyPath } from "./proxy-path-BHYoKZdq.js";
5
5
  import { t as consumePrivateTraceResultMarker } from "./private-trace-result-CE7_lEdq.js";
6
6
  import { n as promoteHttpRouteName, r as routeNameMiddleware, t as nameRequestRoute } from "./sentry-route-name-BhwWnfqj.js";
@@ -1,5 +1,5 @@
1
1
  import { _ as withScope, d as setTag, f as setUser, h as startSpan, i as getActiveSpan, l as logger, n as captureMessage, p as spanToJSON, s as getTraceData, t as captureException } from "./sentry-BRTJqumy.js";
2
- import { t as JUNIOR_VERSION } from "./version-BTIz7fGi.js";
2
+ import { t as JUNIOR_VERSION } from "./version-DBvhk1X9.js";
3
3
  import path from "node:path";
4
4
  import { styleText } from "node:util";
5
5
  import { ConfigError, configureSync, getConfig, getLogger } from "@logtape/logtape";
@@ -37,8 +37,8 @@ function instructionProvenanceFor(actor) {
37
37
  }
38
38
  /**
39
39
  * Provenance of an instruction that an agent wrote, such as a parent agent
40
- * task in a child Conversation. It has no Actor, so it never counts as user
41
- * intent.
40
+ * task in a child Conversation. It has no Actor: it is user intent only for a
41
+ * Run whose instructions an agent writes.
42
42
  */
43
43
  const agentInstructionProvenance = { authority: "instruction" };
44
44
  /** Unattributed ambient-context provenance for non-instruction messages. */
@@ -1,13 +1,13 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { Qa as canAccessConversation, eo as readConversationAccessFromSql, yn as renderUntrustedTag } from "./projection-CoeMNxJ4.js";
3
- import { n as botConfig } from "./config-B9f9Lqo5.js";
4
- import { S as getDb, V as SYSTEM_IDENTITY_ID, x as getConversationStore } from "./viewer-CH-ASQzh.js";
5
- import { Gt as actorFromRun, It as AgentMessagePausedError, Kt as toolInvocationDestination, Rt as AgentMessageTargetError } from "./agent-runner-DGCwOEyL.js";
6
- import { F as PARENT_AGENT_TARGET, v as getActiveAgentInvocationForConversation } from "./turn-failure-response-BOviBdT-.js";
7
- import { G as admitAutomatedTurn, S as EVENT_WAIT_MS, V as postAutomatedTurnLimitNoticeForConversation } from "./session-stop-CGz5DByb.js";
8
- import { r as appendAndEnqueueInboundMessage } from "./store-D0-8plWp.js";
9
- import { a as enqueueAgentInvocation, c as createAgentInvocationForMessage, u as findChildAgentConversationId } from "./work-C75_IM5e.js";
10
- import { r as enqueueAgentMessageToParent } from "./result-CescSwAw.js";
2
+ import { bn as renderUntrustedTag, eo as canAccessConversation, no as readConversationAccessFromSql } from "./projection-CL_YWeGf.js";
3
+ import { n as botConfig } from "./config-CkHcUMN7.js";
4
+ import { T as SYSTEM_IDENTITY_ID, a as getConversationStore, o as getDb } from "./db-DJ11eZqq.js";
5
+ import { $t as toolInvocationDestination, Gt as AgentMessageTargetError, Qt as actorFromRun, Ut as AgentMessagePausedError } from "./agent-runner-Bfnw551N.js";
6
+ import { I as PARENT_AGENT_TARGET, v as getActiveAgentInvocationForConversation } from "./turn-failure-response-B5nV1Er-.js";
7
+ import { G as admitAutomatedTurn, S as EVENT_WAIT_MS, V as postAutomatedTurnLimitNoticeForConversation } from "./session-stop-B2Nut40V.js";
8
+ import { r as appendAndEnqueueInboundMessage } from "./store-DdIEUL1q.js";
9
+ import { a as enqueueAgentInvocation, c as createAgentInvocationForMessage, u as findChildAgentConversationId } from "./work-ljRoODGu.js";
10
+ import { r as enqueueAgentMessageToParent } from "./result-Bo1TZu0Q.js";
11
11
  // src/chat/agent-invocations/top-level-message.ts
12
12
  const AGENT_MESSAGE_EVENT_NAMESPACE = "junior";
13
13
  /** Event type of a message from another top-level agent. */
@@ -15,7 +15,7 @@ const TOP_LEVEL_AGENT_MESSAGE_EVENT_TYPE = "agent.top_level_message";
15
15
  /**
16
16
  * Check that a top-level agent can message another top-level agent under
17
17
  * `policies/conversation-access.md`. A private Conversation is isolated, so
18
- * only public agents in the same provider tenant can message each other.
18
+ * only public agents can message each other.
19
19
  * Every target that the sender cannot reach gets the same error, so the
20
20
  * error does not show that a private Conversation exists.
21
21
  */
package/dist/nitro.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as JuniorDashboardOptions } from "./app-BKq0JzWx.js";
1
+ import { i as JuniorDashboardOptions } from "./app-DBY5TnfY.js";
2
2
  import { n as JuniorPluginSet } from "./plugins-DtmjkTza.js";
3
3
  import { withSentryConfig as withSentryConfig$1 } from "@sentry/nitro";
4
4
  type SentryNitroConfig = Parameters<typeof withSentryConfig$1>[0];
package/dist/nitro.js CHANGED
@@ -1,6 +1,6 @@
1
- import { A as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, D as JUNIOR_AUTO_ARCHIVE_CRON_SCHEDULE, F as JUNIOR_RETENTION_ROUTE, I as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, M as JUNIOR_HEARTBEAT_ROUTE, N as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, O as JUNIOR_AUTO_ARCHIVE_ROUTE, P as JUNIOR_RETENTION_CRON_SCHEDULE, R as getDeploymentServiceVersion, j as JUNIOR_HEARTBEAT_CRON_SCHEDULE, k as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE } from "./logging-CMFhLLj4.js";
1
+ import { A as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, D as JUNIOR_AUTO_ARCHIVE_CRON_SCHEDULE, F as JUNIOR_RETENTION_ROUTE, I as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, M as JUNIOR_HEARTBEAT_ROUTE, N as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, O as JUNIOR_AUTO_ARCHIVE_ROUTE, P as JUNIOR_RETENTION_CRON_SCHEDULE, R as getDeploymentServiceVersion, j as JUNIOR_HEARTBEAT_CRON_SCHEDULE, k as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE } from "./logging-BO5zU6Mt.js";
2
2
  import { d as resolvePackageDir, t as discoverInstalledPluginPackageContent, u as isValidPackageName } from "./package-discovery-DJhGdS4c.js";
3
- import { a as PLUGIN_TASK_QUEUE_TOPIC, p as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC, t as BACKGROUND_COMPACTION_QUEUE_TOPIC, v as resolveConversationWorkQueueTopic } from "./background-compaction-queue-Btu2oab_.js";
3
+ import { a as PLUGIN_TASK_QUEUE_TOPIC, p as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC, t as BACKGROUND_COMPACTION_QUEUE_TOPIC, v as resolveConversationWorkQueueTopic } from "./background-compaction-queue-CYI909P5.js";
4
4
  import { a as pluginRuntimeRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "./plugins-HYh_JOdw.js";
5
5
  import { n as loadPluginSetFromModule, r as resolvePluginModule } from "./plugin-module-Cf5gVPWP.js";
6
6
  import path from "node:path";