@sentry/junior 0.185.0 → 0.187.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 (96) hide show
  1. package/dist/{agent-hooks-NGZQLL5O.js → agent-hooks-XVAE2554.js} +11 -11
  2. package/dist/api/schema/conversation.d.ts +8 -0
  3. package/dist/api/schema.js +1 -1
  4. package/dist/api.js +44 -36
  5. package/dist/app.js +1079 -264
  6. package/dist/{catalog-runtime-AAEAO2RL.js → catalog-runtime-DWFAC562.js} +4 -4
  7. package/dist/chat/agent/types.d.ts +16 -13
  8. package/dist/chat/api-turns/{accepted-reply.d.ts → assistant-message.d.ts} +3 -2
  9. package/dist/chat/api-turns/cancellation.d.ts +0 -1
  10. package/dist/chat/api-turns/mailbox-input.d.ts +4 -0
  11. package/dist/chat/api-turns/routing.d.ts +23 -7
  12. package/dist/chat/api-turns/work.d.ts +2 -2
  13. package/dist/chat/conversations/location.d.ts +2 -2
  14. package/dist/chat/conversations/store.d.ts +13 -0
  15. package/dist/chat/conversations/turn-lifecycle.d.ts +2 -0
  16. package/dist/chat/providers/slack/runtime.d.ts +0 -2
  17. package/dist/chat/providers/slack/turn.d.ts +0 -2
  18. package/dist/chat/resource-events/actor.d.ts +14 -2
  19. package/dist/chat/resource-events/app-publisher.d.ts +18 -0
  20. package/dist/chat/resource-events/catalog.d.ts +19 -0
  21. package/dist/chat/resource-events/ingest.d.ts +0 -1
  22. package/dist/chat/resource-events/notification.d.ts +28 -3
  23. package/dist/chat/resource-events/runtime-catalog.d.ts +7 -2
  24. package/dist/chat/resource-events/store.d.ts +1 -13
  25. package/dist/chat/resource-events/workspace.d.ts +7 -3
  26. package/dist/chat/sandbox/egress/credentials.d.ts +5 -4
  27. package/dist/chat/sandbox/egress/session.d.ts +9 -9
  28. package/dist/chat/sandbox/errors.d.ts +1 -1
  29. package/dist/chat/sandbox/ref.d.ts +1 -1
  30. package/dist/chat/sandbox/snapshot/events.d.ts +8 -1
  31. package/dist/chat/sandbox/snapshot/not-ready-error.d.ts +6 -1
  32. package/dist/chat/sentry-links.d.ts +2 -0
  33. package/dist/chat/services/turn-session-routing.d.ts +23 -7
  34. package/dist/chat/task-execution/slack-resource-event.d.ts +47 -0
  35. package/dist/chat/task-execution/slack-work.d.ts +0 -21
  36. package/dist/chat/task-input.d.ts +22 -0
  37. package/dist/chat/tools/event-tasks.d.ts +1 -1
  38. package/dist/chat/tools/resource-events.d.ts +1 -1
  39. package/dist/{chunk-Y5G23T2D.js → chunk-27T5HZHO.js} +91 -7
  40. package/dist/{chunk-TVVAMOLS.js → chunk-2VUDJGB6.js} +2 -2
  41. package/dist/{chunk-X7NCJQAA.js → chunk-4A2R3AQB.js} +1 -1
  42. package/dist/{chunk-MWOH6CIK.js → chunk-4YD3DET6.js} +278 -116
  43. package/dist/{chunk-INQHUE72.js → chunk-6FGN7ZEG.js} +6 -2
  44. package/dist/{chunk-ZKKGFUWM.js → chunk-6FKNNUSN.js} +6 -6
  45. package/dist/{chunk-OMQ2J6F6.js → chunk-6YCIYOVA.js} +1 -1
  46. package/dist/{chunk-7GAP2XG4.js → chunk-7LRRVMPH.js} +1 -1
  47. package/dist/{chunk-4HA36IWS.js → chunk-BITZUBPJ.js} +8 -8
  48. package/dist/{chunk-QCT4226Q.js → chunk-D3GDGREI.js} +3 -3
  49. package/dist/{chunk-WLKWN4CD.js → chunk-D5BWM37G.js} +8 -5
  50. package/dist/{chunk-VH4IU3UC.js → chunk-DUE4EUNL.js} +19 -45
  51. package/dist/{chunk-DAPC2HTM.js → chunk-EIWYZXSM.js} +5 -5
  52. package/dist/{chunk-LVK4WJKM.js → chunk-HXR3FHTE.js} +13 -3
  53. package/dist/{chunk-UUULGCKK.js → chunk-ITLYUKGZ.js} +14 -4
  54. package/dist/{chunk-FTVMXDNN.js → chunk-JCRXXEMC.js} +1 -1
  55. package/dist/{chunk-EJYP3NQ4.js → chunk-JZPDYKRG.js} +37 -3
  56. package/dist/{chunk-HJPC32TQ.js → chunk-KRYJ5VOD.js} +20 -14
  57. package/dist/{chunk-QZKHHG3B.js → chunk-MUPPP7A7.js} +436 -283
  58. package/dist/{chunk-D63IUQQE.js → chunk-NIKLTFBP.js} +12 -9
  59. package/dist/{chunk-U4CTAVWN.js → chunk-NU775DLU.js} +2 -2
  60. package/dist/{chunk-W7GCLNIV.js → chunk-OM4SFFJK.js} +3 -3
  61. package/dist/{chunk-X2SS6BF7.js → chunk-P2VU5JNH.js} +32 -36
  62. package/dist/{chunk-4K25ODAO.js → chunk-PFAZSRGR.js} +3 -1
  63. package/dist/{chunk-EIJCPJOY.js → chunk-Q6OCUQ7W.js} +1 -1
  64. package/dist/{chunk-GJTIZQGJ.js → chunk-QH3I7ZOK.js} +1 -1
  65. package/dist/{chunk-4S47VHJR.js → chunk-STF4GSK4.js} +3 -3
  66. package/dist/{chunk-C6TS47CQ.js → chunk-TQHCZXN7.js} +11 -5
  67. package/dist/{chunk-ZIF2S464.js → chunk-U3KMII5Y.js} +1 -1
  68. package/dist/{chunk-6DOAUXLD.js → chunk-U5POFCKM.js} +753 -1718
  69. package/dist/{chunk-PNYJOEVV.js → chunk-U6ZQHRIP.js} +1 -1
  70. package/dist/{chunk-LRI5IRGY.js → chunk-URZ7UD4P.js} +2 -2
  71. package/dist/{chunk-6Q7YZLCL.js → chunk-VC343WHM.js} +9 -1
  72. package/dist/{chunk-ABAX75GG.js → chunk-WKIS4VRK.js} +17 -3
  73. package/dist/{chunk-FFHXG2FX.js → chunk-WL3R2KTS.js} +11 -29
  74. package/dist/{chunk-EWEH2PJW.js → chunk-WRDW3A3D.js} +5 -5
  75. package/dist/{chunk-7MHNIGHP.js → chunk-X5SXFVZT.js} +1 -1
  76. package/dist/{chunk-ATUWN6Z3.js → chunk-Z6OHCDXP.js} +2 -2
  77. package/dist/cli/chat.js +33 -33
  78. package/dist/cli/check.js +5 -5
  79. package/dist/cli/plugins.js +12 -12
  80. package/dist/cli/snapshot-create.js +9 -9
  81. package/dist/cli/upgrade.js +6 -6
  82. package/dist/{db-TRJ77FAU.js → db-FBHAWVXU.js} +6 -6
  83. package/dist/instrumentation.js +3 -3
  84. package/dist/nitro.js +6 -6
  85. package/dist/{oauth-callback-server-XD5SV3MS.js → oauth-callback-server-5HS5ULC6.js} +28 -28
  86. package/dist/{runner-KFX7NG6D.js → runner-46W6NV6B.js} +19 -19
  87. package/dist/{skills-J2AH26CW.js → skills-TG3QC4B6.js} +5 -5
  88. package/dist/spawn-Y6YWBIJS.js +41 -0
  89. package/dist/task-runner-YSGBPN4U.js +34 -0
  90. package/dist/{validation-O5J4VOPF.js → validation-GMRIDBC5.js} +5 -5
  91. package/dist/version.js +1 -1
  92. package/dist/{work-ECPQTG3U.js → work-W4ULBJTU.js} +21 -21
  93. package/dist/{worker-RS3DXUDO.js → worker-M6NVACS2.js} +10 -10
  94. package/package.json +4 -4
  95. package/dist/spawn-VU3CSRI6.js +0 -41
  96. package/dist/task-runner-5JG3VIIY.js +0 -34
@@ -5,19 +5,19 @@ import {
5
5
  isDmChannel,
6
6
  normalizeSlackConversationId,
7
7
  withSlackRetries
8
- } from "./chunk-VH4IU3UC.js";
8
+ } from "./chunk-DUE4EUNL.js";
9
9
  import {
10
10
  parseDestination
11
- } from "./chunk-ABAX75GG.js";
11
+ } from "./chunk-WKIS4VRK.js";
12
12
  import {
13
13
  getStateAdapter
14
- } from "./chunk-PNYJOEVV.js";
14
+ } from "./chunk-U6ZQHRIP.js";
15
15
  import {
16
16
  normalizeSlackEmojiName
17
- } from "./chunk-LRI5IRGY.js";
17
+ } from "./chunk-URZ7UD4P.js";
18
18
  import {
19
19
  pluginCatalogRuntime
20
- } from "./chunk-GJTIZQGJ.js";
20
+ } from "./chunk-QH3I7ZOK.js";
21
21
  import {
22
22
  parseSlackMessageTs,
23
23
  parseSlackUserId
@@ -26,7 +26,7 @@ import {
26
26
  isRecord,
27
27
  logInfo,
28
28
  logWarn
29
- } from "./chunk-OMQ2J6F6.js";
29
+ } from "./chunk-6YCIYOVA.js";
30
30
 
31
31
  // src/chat/slack/outbound.ts
32
32
  var MAX_SLACK_MESSAGE_TEXT_CHARS = 4e4;
@@ -12,7 +12,7 @@ import {
12
12
  } from "./chunk-PEQXYSSE.js";
13
13
  import {
14
14
  JUNIOR_VERSION
15
- } from "./chunk-7GAP2XG4.js";
15
+ } from "./chunk-7LRRVMPH.js";
16
16
 
17
17
  // src/deployment.ts
18
18
  var JUNIOR_HEARTBEAT_ROUTE = "/api/internal/heartbeat";
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "@sentry/junior",
4
- version: "0.185.0",
4
+ version: "0.187.0",
5
5
  private: false,
6
6
  publishConfig: {
7
7
  access: "public"
@@ -1,32 +1,32 @@
1
1
  import {
2
2
  resolveBaseUrl
3
- } from "./chunk-ZKKGFUWM.js";
3
+ } from "./chunk-6FKNNUSN.js";
4
4
  import {
5
5
  createPluginLogger,
6
6
  getPlugins,
7
7
  getSlackClient,
8
8
  withSlackRetries
9
- } from "./chunk-VH4IU3UC.js";
9
+ } from "./chunk-DUE4EUNL.js";
10
10
  import {
11
11
  getDb,
12
12
  parseDestination
13
- } from "./chunk-ABAX75GG.js";
13
+ } from "./chunk-WKIS4VRK.js";
14
14
  import {
15
15
  sleep
16
- } from "./chunk-EJYP3NQ4.js";
16
+ } from "./chunk-JZPDYKRG.js";
17
17
  import {
18
18
  acquireActiveLock,
19
19
  getStateAdapter
20
- } from "./chunk-PNYJOEVV.js";
20
+ } from "./chunk-U6ZQHRIP.js";
21
21
  import {
22
22
  pluginCatalogRuntime
23
- } from "./chunk-GJTIZQGJ.js";
23
+ } from "./chunk-QH3I7ZOK.js";
24
24
  import {
25
25
  fetchWithBoundedOAuthErrorBodies
26
- } from "./chunk-7MHNIGHP.js";
26
+ } from "./chunk-X5SXFVZT.js";
27
27
  import {
28
28
  isRecord
29
- } from "./chunk-OMQ2J6F6.js";
29
+ } from "./chunk-6YCIYOVA.js";
30
30
 
31
31
  // src/chat/capabilities/router.ts
32
32
  var ProviderCredentialRouter = class {
@@ -6,14 +6,14 @@ import {
6
6
  isStale,
7
7
  runNonInteractiveCommand,
8
8
  sleep
9
- } from "./chunk-EJYP3NQ4.js";
9
+ } from "./chunk-JZPDYKRG.js";
10
10
  import {
11
11
  getStateAdapter
12
- } from "./chunk-PNYJOEVV.js";
12
+ } from "./chunk-U6ZQHRIP.js";
13
13
  import {
14
14
  setSpanAttributes,
15
15
  withSpan
16
- } from "./chunk-OMQ2J6F6.js";
16
+ } from "./chunk-6YCIYOVA.js";
17
17
 
18
18
  // src/chat/sandbox/resources.ts
19
19
  var configuredResources;
@@ -9,18 +9,18 @@ import {
9
9
  getSqlExecutor,
10
10
  sanitizePostgresJson,
11
11
  withConversationEventLock
12
- } from "./chunk-ABAX75GG.js";
12
+ } from "./chunk-WKIS4VRK.js";
13
13
  import {
14
14
  SANDBOX_REPOS_ROOT,
15
15
  SANDBOX_WORKSPACE_ROOT,
16
16
  sleep
17
- } from "./chunk-EJYP3NQ4.js";
17
+ } from "./chunk-JZPDYKRG.js";
18
18
  import {
19
19
  MUTATION_LOCK_TTL_MS,
20
20
  fenceLock,
21
21
  getStateAdapter,
22
22
  withLock
23
- } from "./chunk-PNYJOEVV.js";
23
+ } from "./chunk-U6ZQHRIP.js";
24
24
  import {
25
25
  agentHistoryItemSchema,
26
26
  contextProvenance,
@@ -33,7 +33,7 @@ import {
33
33
  escapeXml,
34
34
  resolveGatewayModel,
35
35
  unwrapCurrentInstruction
36
- } from "./chunk-LRI5IRGY.js";
36
+ } from "./chunk-URZ7UD4P.js";
37
37
  import {
38
38
  parseSlackMessageTs,
39
39
  toStoredSlackActor
@@ -43,7 +43,7 @@ import {
43
43
  logException,
44
44
  logWarn,
45
45
  setSpanAttributes
46
- } from "./chunk-OMQ2J6F6.js";
46
+ } from "./chunk-6YCIYOVA.js";
47
47
 
48
48
  // src/chat/turn-context-tag.ts
49
49
  var TURN_CONTEXT_TAG = "runtime-turn-context";
@@ -2308,6 +2308,9 @@ async function recordConversationActivityMetadata(args) {
2308
2308
  });
2309
2309
  const isChild = Boolean(conversation?.lineage);
2310
2310
  const destination = isChild ? void 0 : args.destination;
2311
+ if (!isChild && !destination && !conversation) {
2312
+ return;
2313
+ }
2311
2314
  const activitySource = isChild ? "internal" : args.source?.platform === "web" ? "web" : destination?.platform === "local" ? "local" : destination ? args.summary.surface : void 0;
2312
2315
  await conversationStore.recordActivity({
2313
2316
  activityAtMs: args.summary.updatedAtMs,
@@ -5,7 +5,7 @@ import {
5
5
  getConversationEventStore,
6
6
  getDb,
7
7
  getSqlExecutor
8
- } from "./chunk-ABAX75GG.js";
8
+ } from "./chunk-WKIS4VRK.js";
9
9
  import {
10
10
  juniorCodeChanges,
11
11
  juniorCodeRepositories,
@@ -16,7 +16,7 @@ import {
16
16
  juniorUsers,
17
17
  juniorWorkspaceRepos,
18
18
  juniorWorkspaces
19
- } from "./chunk-LVK4WJKM.js";
19
+ } from "./chunk-HXR3FHTE.js";
20
20
  import {
21
21
  SANDBOX_WORKSPACE_ROOT,
22
22
  getVercelSandboxCredentials,
@@ -24,16 +24,16 @@ import {
24
24
  isSandboxMissingError,
25
25
  runNonInteractiveCommand,
26
26
  sleep
27
- } from "./chunk-EJYP3NQ4.js";
27
+ } from "./chunk-JZPDYKRG.js";
28
28
  import {
29
29
  getStateAdapter
30
- } from "./chunk-PNYJOEVV.js";
30
+ } from "./chunk-U6ZQHRIP.js";
31
31
  import {
32
32
  botConfig,
33
33
  completeObject,
34
34
  embedTexts,
35
35
  getSlackBotToken
36
- } from "./chunk-LRI5IRGY.js";
36
+ } from "./chunk-URZ7UD4P.js";
37
37
  import {
38
38
  defaultModelId
39
39
  } from "./chunk-D4YV5TDV.js";
@@ -52,7 +52,7 @@ import {
52
52
  setSpanAttributes,
53
53
  setSpanStatus,
54
54
  withSpan
55
- } from "./chunk-OMQ2J6F6.js";
55
+ } from "./chunk-6YCIYOVA.js";
56
56
 
57
57
  // src/chat/plugins/agent-hooks.ts
58
58
  import {
@@ -473,14 +473,13 @@ function getDashboardTaskLink(taskId) {
473
473
  // src/chat/resource-events/store.ts
474
474
  import { createHash as createHash2 } from "crypto";
475
475
  import {
476
- destinationSchema,
477
476
  resourceEventMatchSchema,
478
477
  resourceEventMatches,
479
478
  resourceEventTypeSchema,
480
479
  stableResourceEventMatchKey
481
480
  } from "@sentry/junior-plugin-api";
482
481
  import { z as z2 } from "zod";
483
- var RESOURCE_EVENT_PREFIX = "junior:resource_event_subscription:v3";
482
+ var RESOURCE_EVENT_PREFIX = "junior:resource_event_subscription:v5";
484
483
  var INDEX_LOCK_TTL_MS = 1e4;
485
484
  var SUBSCRIPTION_LOCK_TTL_MS = 1e4;
486
485
  var SUBSCRIPTION_LOCK_WAIT_MS = 1e4;
@@ -491,7 +490,6 @@ var subscriptionIdIndexSchema = z2.array(z2.string().min(1));
491
490
  var subscriptionSchema = z2.object({
492
491
  conversationId: z2.string().min(1),
493
492
  createdAtMs: z2.number().finite(),
494
- destination: destinationSchema,
495
493
  events: z2.array(resourceEventTypeSchema).min(1),
496
494
  expiresAtMs: z2.number().finite(),
497
495
  id: z2.string().min(1),
@@ -513,14 +511,8 @@ function subscriptionKey(id) {
513
511
  function subscriptionLockKey(id) {
514
512
  return `${RESOURCE_EVENT_PREFIX}:lock:${id}`;
515
513
  }
516
- function resourceIndexKey(teamId, namespace, identifier) {
517
- return `${RESOURCE_EVENT_PREFIX}:resource:${digest(`${teamId}\0${namespace}\0${identifier}`)}`;
518
- }
519
- function subscriptionTeamId(destination) {
520
- if (destination.platform !== "slack") {
521
- throw new Error("Resource event subscriptions require a Slack destination");
522
- }
523
- return destination.teamId;
514
+ function resourceIndexKey(namespace, identifier) {
515
+ return `${RESOURCE_EVENT_PREFIX}:resource:${digest(`${namespace}\0${identifier}`)}`;
524
516
  }
525
517
  function conversationIndexKey(conversationId) {
526
518
  return `${RESOURCE_EVENT_PREFIX}:conversation:${digest(conversationId)}`;
@@ -606,7 +598,7 @@ async function readSubscriptionIdIndex(state, key) {
606
598
  function buildSubscriptionId(input) {
607
599
  const eventKey = [...new Set(input.events)].sort().join("\0");
608
600
  const matchKey = stableResourceEventMatchKey(input.match);
609
- const material = matchKey ? `${input.teamId}\0${input.namespace}\0${input.identifier}\0${input.conversationId}\0${eventKey}\0${matchKey}` : `${input.teamId}\0${input.namespace}\0${input.identifier}\0${input.conversationId}\0${eventKey}`;
601
+ const material = matchKey ? `${input.namespace}\0${input.identifier}\0${input.conversationId}\0${eventKey}\0${matchKey}` : `${input.namespace}\0${input.identifier}\0${input.conversationId}\0${eventKey}`;
610
602
  return `resub_${digest(material)}`;
611
603
  }
612
604
  async function withIndexLock(state, key, callback) {
@@ -658,7 +650,7 @@ function activeAt(subscription, nowMs) {
658
650
  return subscription.status === "active" && subscription.expiresAtMs > nowMs;
659
651
  }
660
652
  function matchesEvent(subscription, input) {
661
- return subscription.namespace === input.namespace && subscription.identifier === input.identifier && subscriptionTeamId(subscription.destination) === input.teamId && subscription.events.includes(input.eventType) && activeAt(subscription, input.nowMs) && resourceEventMatches(subscription.match, input.data);
653
+ return subscription.namespace === input.namespace && subscription.identifier === input.identifier && subscription.events.includes(input.eventType) && activeAt(subscription, input.nowMs) && resourceEventMatches(subscription.match, input.data);
662
654
  }
663
655
  async function createResourceEventSubscription(input, options = {}) {
664
656
  const state = options.state ?? getStateAdapter();
@@ -679,13 +671,11 @@ async function createResourceEventSubscription(input, options = {}) {
679
671
  events,
680
672
  match,
681
673
  namespace: input.namespace,
682
- identifier: input.identifier,
683
- teamId: subscriptionTeamId(input.destination)
674
+ identifier: input.identifier
684
675
  });
685
676
  const record = {
686
677
  conversationId: input.conversationId,
687
678
  createdAtMs: nowMs,
688
- destination: input.destination,
689
679
  events,
690
680
  expiresAtMs: input.expiresAtMs,
691
681
  id,
@@ -706,11 +696,7 @@ async function createResourceEventSubscription(input, options = {}) {
706
696
  );
707
697
  await addToIndex(
708
698
  state,
709
- resourceIndexKey(
710
- subscriptionTeamId(parsed.destination),
711
- input.namespace,
712
- input.identifier
713
- ),
699
+ resourceIndexKey(input.namespace, input.identifier),
714
700
  id,
715
701
  nowMs
716
702
  );
@@ -762,11 +748,7 @@ async function cancelResourceEventSubscription(input) {
762
748
  );
763
749
  await removeFromIndex(
764
750
  state,
765
- resourceIndexKey(
766
- subscriptionTeamId(current.destination),
767
- current.namespace,
768
- current.identifier
769
- ),
751
+ resourceIndexKey(current.namespace, current.identifier),
770
752
  input.id,
771
753
  nowMs
772
754
  );
@@ -805,7 +787,7 @@ async function collectResourceEventMatchKeys(input) {
805
787
  for (const identifier of identifiers) {
806
788
  const ids = await readSubscriptionIdIndex(
807
789
  state,
808
- resourceIndexKey(input.teamId, input.namespace, identifier)
790
+ resourceIndexKey(input.namespace, identifier)
809
791
  );
810
792
  const records = await Promise.all(
811
793
  ids.map(
@@ -816,7 +798,6 @@ async function collectResourceEventMatchKeys(input) {
816
798
  if (!record) continue;
817
799
  if (record.namespace !== input.namespace) continue;
818
800
  if (record.identifier !== identifier) continue;
819
- if (subscriptionTeamId(record.destination) !== input.teamId) continue;
820
801
  if (!activeAt(record, nowMs)) continue;
821
802
  if (!record.events.some((eventType) => eventTypes.has(eventType))) continue;
822
803
  for (const key of Object.keys(record.match ?? {})) {
@@ -832,7 +813,7 @@ async function findMatchingResourceEventSubscriptions(input) {
832
813
  const nowMs = input.nowMs ?? Date.now();
833
814
  const ids = await readSubscriptionIdIndex(
834
815
  state,
835
- resourceIndexKey(input.teamId, input.namespace, input.identifier)
816
+ resourceIndexKey(input.namespace, input.identifier)
836
817
  );
837
818
  const records = await Promise.all(
838
819
  ids.map(
@@ -845,8 +826,7 @@ async function findMatchingResourceEventSubscriptions(input) {
845
826
  eventType: input.eventType,
846
827
  nowMs,
847
828
  namespace: input.namespace,
848
- identifier: input.identifier,
849
- teamId: input.teamId
829
+ identifier: input.identifier
850
830
  })
851
831
  );
852
832
  }
@@ -866,8 +846,7 @@ async function deliverResourceEventSubscription(input) {
866
846
  eventType: input.eventType,
867
847
  nowMs,
868
848
  namespace: input.namespace,
869
- identifier: input.identifier,
870
- teamId: input.teamId
849
+ identifier: input.identifier
871
850
  })) {
872
851
  return false;
873
852
  }
@@ -891,11 +870,7 @@ async function deliverResourceEventSubscription(input) {
891
870
  );
892
871
  await removeFromIndex(
893
872
  state,
894
- resourceIndexKey(
895
- subscriptionTeamId(current.destination),
896
- current.namespace,
897
- current.identifier
898
- ),
873
+ resourceIndexKey(current.namespace, current.identifier),
899
874
  current.id,
900
875
  nowMs
901
876
  );
@@ -2711,7 +2686,6 @@ function getPluginTools(context, sandbox = createSandboxCapability(context.works
2711
2686
  }
2712
2687
  const subscription = await createResourceEventSubscription({
2713
2688
  conversationId: context.conversationId,
2714
- destination: context.destination,
2715
2689
  events: input.events,
2716
2690
  expiresAtMs: Date.now() + RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS,
2717
2691
  intent: input.intent,
@@ -2,29 +2,29 @@ import {
2
2
  coerceThreadConversationState,
3
3
  getPersistedThreadState,
4
4
  persistThreadStateById
5
- } from "./chunk-Y5G23T2D.js";
5
+ } from "./chunk-27T5HZHO.js";
6
6
  import {
7
7
  buildDeterministicTurnId,
8
8
  clearPendingAuth,
9
9
  markTurnClosed,
10
10
  markTurnCompleted
11
- } from "./chunk-U4CTAVWN.js";
11
+ } from "./chunk-NU775DLU.js";
12
12
  import {
13
13
  hydrateConversationMessages,
14
14
  markConversationMessage
15
- } from "./chunk-WLKWN4CD.js";
15
+ } from "./chunk-D5BWM37G.js";
16
16
  import {
17
17
  ProviderError,
18
18
  findProviderError,
19
19
  getProviderErrorAttributes,
20
20
  getProviderErrorUserMessage
21
- } from "./chunk-LRI5IRGY.js";
21
+ } from "./chunk-URZ7UD4P.js";
22
22
  import {
23
23
  parseSlackMessageTs
24
24
  } from "./chunk-N7TMSOZH.js";
25
25
  import {
26
26
  buildTurnFailureResponse
27
- } from "./chunk-OMQ2J6F6.js";
27
+ } from "./chunk-6YCIYOVA.js";
28
28
 
29
29
  // src/chat/runtime/delivered-turn-state.ts
30
30
  function buildDeliveredTurnStatePatch(args) {
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-VFUK3X5B.js";
5
5
  import {
6
6
  DEFAULT_SQL_STATEMENT_TIMEOUT_MS
7
- } from "./chunk-LRI5IRGY.js";
7
+ } from "./chunk-URZ7UD4P.js";
8
8
 
9
9
  // src/db/neon.ts
10
10
  import { AsyncLocalStorage } from "async_hooks";
@@ -137,13 +137,19 @@ var juniorConversations = pgTable4(
137
137
  schemaVersion: integer2("schema_version").notNull().default(1),
138
138
  source: text4("source").$type(),
139
139
  /** Structured session Source locator; set-once on the conversation root. */
140
+ // TODO(dcramer): Remove source_json after every stored Conversation has a
141
+ // complete Location and all readers use it for provider context.
140
142
  sessionSource: jsonb2("source_json").$type(),
141
143
  originType: text4("origin_type"),
142
144
  originId: text4("origin_id"),
143
145
  originRunId: text4("origin_run_id"),
146
+ // TODO(dcramer): Rename destination_id to location_id after all deployed
147
+ // readers and writers use the singular Conversation Location contract.
144
148
  destinationId: text4("destination_id").references(
145
149
  () => juniorDestinations.id
146
150
  ),
151
+ // TODO(dcramer): Drop destination_json after every row uses location_id and
152
+ // no supported worker writes the legacy JSON value.
147
153
  destination: jsonb2("destination_json").$type(),
148
154
  actorIdentityId: text4("actor_identity_id").references(
149
155
  () => juniorIdentities.id
@@ -422,6 +428,8 @@ var juniorConversationBindings = pgTable10(
422
428
  conversationId: text10("conversation_id").notNull().references(() => juniorConversations.conversationId),
423
429
  provider: text10("provider").notNull(),
424
430
  providerTenantId: text10("provider_tenant_id").notNull().default(""),
431
+ // TODO(dcramer): Rename provider_destination_id with the Location SQL
432
+ // migration. It identifies the provider place that contains the thread.
425
433
  providerDestinationId: text10("provider_destination_id").notNull(),
426
434
  providerConversationId: text10("provider_conversation_id").notNull(),
427
435
  createdAt: timestamptz("created_at").notNull()
@@ -660,7 +668,8 @@ var juniorSchedulerTasks = pgTable17(
660
668
  {
661
669
  id: text17("id").primaryKey(),
662
670
  teamId: text17("team_id").notNull(),
663
- // TODO(v0.128.0): Remove after v0.127.x runtimes no longer write this column.
671
+ // TODO(dcramer): Remove after v0.127.x runtimes are unsupported and no
672
+ // supported runtime writes this column.
664
673
  creatorSlackUserId: text17("creator_slack_user_id"),
665
674
  creatorIdentityId: text17("creator_identity_id"),
666
675
  status: text17("status").notNull(),
@@ -672,7 +681,8 @@ var juniorSchedulerTasks = pgTable17(
672
681
  record: jsonb7("record").$type().notNull()
673
682
  },
674
683
  (table) => [
675
- // TODO(v0.128.0): Remove with creatorSlackUserId.
684
+ // TODO(dcramer): Remove after no supported runtime reads or writes the
685
+ // legacy creatorSlackUserId column.
676
686
  index13("junior_scheduler_tasks_creator_idx").on(table.teamId, table.creatorSlackUserId, table.createdAtMs, table.id).where(sql6`${table.status} <> 'deleted'`),
677
687
  index13("junior_scheduler_tasks_creator_identity_idx").on(table.creatorIdentityId, table.createdAtMs, table.id).where(
678
688
  sql6`${table.status} <> 'deleted' AND ${table.creatorIdentityId} IS NOT NULL`
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getStateAdapter
3
- } from "./chunk-PNYJOEVV.js";
3
+ } from "./chunk-U6ZQHRIP.js";
4
4
  import {
5
5
  getClient
6
6
  } from "./chunk-PEQXYSSE.js";
@@ -61,7 +61,7 @@ function buildSentryWebBaseUrl(dsn) {
61
61
  const path = dsn.path ? `/${dsn.path}` : "";
62
62
  return `${dsn.protocol}://${dsn.host}${port}${path}`;
63
63
  }
64
- function buildSentryConversationUrl(conversationId) {
64
+ function buildSentryOrgPath(args) {
65
65
  const client = getClient();
66
66
  const dsn = client?.getDsn();
67
67
  if (!dsn?.host || !dsn.projectId) {
@@ -71,18 +71,28 @@ function buildSentryConversationUrl(conversationId) {
71
71
  if (!orgSlug) {
72
72
  return void 0;
73
73
  }
74
- const encodedId = encodeURIComponent(conversationId);
75
74
  const params = new URLSearchParams();
76
75
  params.set("project", dsn.projectId);
77
- const path = `explore/conversations/${encodedId}/?${params.toString()}`;
76
+ const path = `${args.path}?${params.toString()}`;
78
77
  if (isSentrySaasDsnHost(dsn.host)) {
79
78
  return `https://${orgSlug}.sentry.io/${path}`;
80
79
  }
81
80
  return `${buildSentryWebBaseUrl(dsn)}/organizations/${orgSlug}/${path}`;
82
81
  }
82
+ function buildSentryConversationUrl(conversationId) {
83
+ return buildSentryOrgPath({
84
+ path: `explore/conversations/${encodeURIComponent(conversationId)}/`
85
+ });
86
+ }
87
+ function buildSentryEventUrl(eventId) {
88
+ return buildSentryOrgPath({
89
+ path: `events/${encodeURIComponent(eventId)}/`
90
+ });
91
+ }
83
92
 
84
93
  export {
85
94
  buildSentryConversationUrl,
95
+ buildSentryEventUrl,
86
96
  createWebAuthorization,
87
97
  getWebAuthorization,
88
98
  deleteWebAuthorization
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  FUNCTION_TIMEOUT_BUFFER_SECONDS,
3
3
  getChatConfig
4
- } from "./chunk-LRI5IRGY.js";
4
+ } from "./chunk-URZ7UD4P.js";
5
5
 
6
6
  // src/chat/runtime/request-deadline.ts
7
7
  import { AsyncLocalStorage } from "async_hooks";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  toOptionalTrimmed
3
- } from "./chunk-LRI5IRGY.js";
3
+ } from "./chunk-URZ7UD4P.js";
4
4
  import {
5
5
  pluginCatalogRuntime
6
- } from "./chunk-GJTIZQGJ.js";
6
+ } from "./chunk-QH3I7ZOK.js";
7
7
  import {
8
8
  setSpanAttributes,
9
9
  setSpanStatus
10
- } from "./chunk-OMQ2J6F6.js";
10
+ } from "./chunk-6YCIYOVA.js";
11
11
 
12
12
  // src/chat/sandbox/paths.ts
13
13
  function normalizeWorkspaceRoot(input) {
@@ -399,6 +399,32 @@ function getVercelSandboxCredentials() {
399
399
  return void 0;
400
400
  }
401
401
 
402
+ // src/chat/sandbox/snapshot/not-ready-error.ts
403
+ var WorkspaceSnapshotNotReadyError = class extends Error {
404
+ workspaceName;
405
+ constructor(workspaceName) {
406
+ super(`Workspace ${workspaceName} snapshot is not ready`);
407
+ this.name = "WorkspaceSnapshotNotReadyError";
408
+ this.workspaceName = workspaceName;
409
+ }
410
+ };
411
+ function getWorkspaceSnapshotNotReadyError(error) {
412
+ const seen = /* @__PURE__ */ new Set();
413
+ let current = error;
414
+ while (current instanceof Error && !seen.has(current)) {
415
+ if (current instanceof WorkspaceSnapshotNotReadyError) return current;
416
+ seen.add(current);
417
+ current = current.cause;
418
+ }
419
+ return void 0;
420
+ }
421
+ function isWorkspaceSnapshotNotReadyError(error) {
422
+ return getWorkspaceSnapshotNotReadyError(error) !== void 0;
423
+ }
424
+ function workspaceSnapshotNotReadyUserMessage(error) {
425
+ return `The ${error.workspaceName} workspace is still preparing its sandbox. Wait for that preparation to finish, then try again.`;
426
+ }
427
+
402
428
  // src/chat/sandbox/http-error-details.ts
403
429
  var DEFAULT_PREVIEW_LIMIT = 512;
404
430
  function toTrimmedString(value, maxChars) {
@@ -615,6 +641,10 @@ function isSandboxCommandStreamInterruptedError(error) {
615
641
  });
616
642
  }
617
643
  function wrapSandboxSetupError(error) {
644
+ const notReady = getWorkspaceSnapshotNotReadyError(error);
645
+ if (notReady) {
646
+ return notReady;
647
+ }
618
648
  try {
619
649
  const details = getSandboxErrorDetails(error);
620
650
  if (details.summary) {
@@ -667,6 +697,10 @@ export {
667
697
  buildNonInteractiveShellScript,
668
698
  runNonInteractiveCommand,
669
699
  getVercelSandboxCredentials,
700
+ WorkspaceSnapshotNotReadyError,
701
+ getWorkspaceSnapshotNotReadyError,
702
+ isWorkspaceSnapshotNotReadyError,
703
+ workspaceSnapshotNotReadyUserMessage,
670
704
  isAlreadyExistsError,
671
705
  isSandboxUnavailableError,
672
706
  isSandboxMissingError,