@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
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Slack edge helpers for resource-event mailbox wakes.
3
+ *
4
+ * Resource-event ingest stores plain conversation mailbox input. When the
5
+ * conversation destination is Slack, this module builds the Message and Thread
6
+ * the Slack runtime needs for one turn. It does not rewrite mailbox rows.
7
+ *
8
+ * TODO(slack-runtime): Drop this module once Slack turns can start from
9
+ * conversation destination + session source (channel, team, threadTs, text,
10
+ * event metadata) without a synthetic chat Message/Thread. Resource wakes and
11
+ * paused resume should share that entry; handleSubscribedMessage stays for
12
+ * real webhook traffic only.
13
+ */
14
+ import { Message, ThreadImpl, type StateAdapter } from "chat";
15
+ import type { SlackAdapter } from "@chat-adapter/slack";
16
+ import type { Destination, SlackDestination } from "@sentry/junior-plugin-api";
17
+ import type { ConversationStore } from "@/chat/conversations/store";
18
+ import type { InboundMessage } from "@/chat/task-execution/store";
19
+ /** Load Slack destination and threadTs for a resource-event wake. */
20
+ export declare function resolveSlackResourceEventThread(args: {
21
+ conversationId: string;
22
+ conversationStore?: ConversationStore;
23
+ destination?: Destination;
24
+ }): Promise<{
25
+ destination: SlackDestination;
26
+ threadTs: string;
27
+ }>;
28
+ /** Whether a mailbox row is a plain resource-event wake (no Slack envelope). */
29
+ export declare function isPlainResourceEventRecord(record: InboundMessage): boolean;
30
+ /**
31
+ * Build a Slack Message for one plain resource-event mailbox row.
32
+ *
33
+ * Used only at the Slack worker edge. The mailbox row stays plain.
34
+ */
35
+ export declare function buildResourceEventSlackMessage(args: {
36
+ channelId: string;
37
+ record: InboundMessage;
38
+ threadTs: string;
39
+ }): Message;
40
+ /** Build a ThreadImpl for a resource-event Slack turn. */
41
+ export declare function buildResourceEventSlackThread(args: {
42
+ adapter: SlackAdapter;
43
+ message: Message;
44
+ state: StateAdapter;
45
+ threadTs: string;
46
+ channelId: string;
47
+ }): ThreadImpl;
@@ -251,25 +251,6 @@ interface SlackInboxTurnRuntime {
251
251
  handleNewMention(thread: ThreadImpl, message: Message, hooks: SlackInboxTurnOptions): Promise<void>;
252
252
  handleSubscribedMessage(thread: ThreadImpl, message: Message, hooks: SlackInboxTurnOptions): Promise<void>;
253
253
  }
254
- interface SlackResourceEventInboundInput {
255
- event: {
256
- eventKey: string;
257
- eventType: string;
258
- occurredAtMs: number;
259
- namespace: string;
260
- identifier: string;
261
- };
262
- subscription: {
263
- conversationId: string;
264
- destination: {
265
- channelId: string;
266
- platform: "slack";
267
- teamId: string;
268
- };
269
- id: string;
270
- };
271
- text: string;
272
- }
273
254
  export interface CreateSlackConversationWorkerOptions {
274
255
  crossActorMidRunMode?: CrossActorMidRunMode;
275
256
  getSlackAdapter: () => SlackAdapter;
@@ -281,8 +262,6 @@ export interface CreateSlackConversationWorkerOptions {
281
262
  runtime: SlackInboxTurnRuntime;
282
263
  state?: StateAdapter;
283
264
  }
284
- /** Create a Slack mailbox record for a subscribed resource-event notification. */
285
- export declare function createSlackResourceEventInboundMessage(input: SlackResourceEventInboundInput): InboundMessage;
286
265
  /** Build the worker run function for queued Slack conversation work. */
287
266
  export declare function createSlackConversationWorker(options: CreateSlackConversationWorkerOptions): (context: ConversationWorkerContext) => Promise<ConversationWorkerResult>;
288
267
  /** Serialize a Slack message into the generic durable conversation mailbox. */
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Render agent input for a task run.
3
+ *
4
+ * Section order and required prose live in `chat/README.md` under Task agent
5
+ * input. Empty optional fields are omitted.
6
+ */
7
+ export declare function renderTaskInput(args: {
8
+ /** Stored task instruction, or subscription intent. */
9
+ instructions: string;
10
+ /** Human label for the matched resource, when present. */
11
+ about?: string;
12
+ /** Plugin guidance scoped under the instructions. */
13
+ guidance?: string;
14
+ /** Trusted one-line summary, when available. */
15
+ trustedSummary?: string;
16
+ /** Structured verified fields, when available. */
17
+ verifiedDetails?: Record<string, unknown>;
18
+ /** Untrusted provider text; never treated as instructions. */
19
+ externalText?: string;
20
+ externalTextMaxLength?: number;
21
+ trustedSummaryMaxLength?: number;
22
+ }): string;
@@ -1,4 +1,4 @@
1
- import type { ResourceEventCatalog } from "@/chat/resource-events/catalog";
1
+ import { type ResourceEventCatalog } from "@/chat/resource-events/catalog";
2
2
  import type { ToolRegistry } from "@/chat/tools/definition";
3
3
  import type { ToolRuntimeContext } from "@/chat/tools/types";
4
4
  /** Build event task tools for an interactive Slack actor. */
@@ -1,4 +1,4 @@
1
- import type { ResourceEventCatalog } from "@/chat/resource-events/catalog";
1
+ import { type ResourceEventCatalog } from "@/chat/resource-events/catalog";
2
2
  import type { ToolRegistry } from "@/chat/tools/definition";
3
3
  import type { ToolRuntimeContext } from "@/chat/tools/types";
4
4
  /** Build the complete resource-watch tool set for this runtime context. */
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  persistConversationMessages
3
- } from "./chunk-WLKWN4CD.js";
3
+ } from "./chunk-D5BWM37G.js";
4
4
  import {
5
5
  JUNIOR_THREAD_STATE_TTL_MS
6
6
  } from "./chunk-3Y47VMHV.js";
7
7
  import {
8
8
  getDb
9
- } from "./chunk-ABAX75GG.js";
9
+ } from "./chunk-WKIS4VRK.js";
10
10
  import {
11
11
  juniorLocationConfigurations
12
- } from "./chunk-LVK4WJKM.js";
12
+ } from "./chunk-HXR3FHTE.js";
13
13
  import {
14
14
  getStateAdapter
15
- } from "./chunk-PNYJOEVV.js";
15
+ } from "./chunk-U6ZQHRIP.js";
16
16
  import {
17
17
  juniorDestinations
18
18
  } from "./chunk-VFUK3X5B.js";
@@ -20,7 +20,7 @@ import {
20
20
  isRecord,
21
21
  toOptionalNumber,
22
22
  toOptionalString
23
- } from "./chunk-OMQ2J6F6.js";
23
+ } from "./chunk-6YCIYOVA.js";
24
24
 
25
25
  // src/chat/state/conversation.ts
26
26
  function defaultConversationState() {
@@ -372,7 +372,10 @@ function createSqlLocationConfigurationStorage(db, destination) {
372
372
  };
373
373
  }
374
374
  function createDurableLocationConfigurationService(args) {
375
- const storage = createSqlLocationConfigurationStorage(args.db, args.destination);
375
+ const storage = createSqlLocationConfigurationStorage(
376
+ args.db,
377
+ args.destination
378
+ );
376
379
  let cutover;
377
380
  const ensureCutover = () => cutover ??= (async () => {
378
381
  if ((await storage.list()).length > 0) {
@@ -504,6 +507,85 @@ function getLocationConfigurationService(destination) {
504
507
  });
505
508
  }
506
509
 
510
+ // src/chat/services/turn-session-routing.ts
511
+ async function loadConversationChain(conversationId, conversationStore) {
512
+ const chain = [];
513
+ const seen = /* @__PURE__ */ new Set();
514
+ let cursor = conversationId;
515
+ while (cursor && !seen.has(cursor)) {
516
+ seen.add(cursor);
517
+ const conversation = await conversationStore.get({
518
+ conversationId: cursor
519
+ });
520
+ if (!conversation) {
521
+ break;
522
+ }
523
+ chain.push(conversation);
524
+ cursor = conversation.lineage?.parentConversationId;
525
+ }
526
+ return chain;
527
+ }
528
+ function slackSourceForDestination(args) {
529
+ if (args.source?.platform !== "slack" || args.source.channelId !== args.destination.channelId) {
530
+ return void 0;
531
+ }
532
+ const threadTs = args.source.threadTs?.trim();
533
+ return {
534
+ platform: "slack",
535
+ visibility: args.source.visibility ?? "public",
536
+ teamId: args.source.teamId?.trim() || args.destination.teamId,
537
+ channelId: args.source.channelId,
538
+ ...threadTs ? { threadTs } : void 0
539
+ };
540
+ }
541
+ async function resolveConversationRouting(args) {
542
+ const conversationStore = args.conversationStore ?? (await import("./db-FBHAWVXU.js")).getConversationStore();
543
+ const chain = await loadConversationChain(
544
+ args.conversationId,
545
+ conversationStore
546
+ );
547
+ let destination;
548
+ let source;
549
+ let location;
550
+ for (const conversation of chain) {
551
+ destination ??= conversation.destination;
552
+ source ??= conversation.sessionSource;
553
+ location ??= conversation.location;
554
+ if (destination && source) {
555
+ break;
556
+ }
557
+ }
558
+ if (!destination) {
559
+ return void 0;
560
+ }
561
+ if (destination.platform === "slack") {
562
+ const slackSource = slackSourceForDestination({ destination, source });
563
+ return {
564
+ destination,
565
+ ...location ? { location } : void 0,
566
+ ...slackSource ? { source: slackSource } : void 0
567
+ };
568
+ }
569
+ return {
570
+ destination,
571
+ ...location ? { location } : void 0,
572
+ ...source ? { source } : void 0
573
+ };
574
+ }
575
+ async function resolveTurnSessionRouting(args) {
576
+ const routing = await resolveConversationRouting(args);
577
+ if (!routing?.destination || !routing.source) {
578
+ throw new Error(
579
+ `Conversation ${args.conversationId} is missing durable routing metadata`
580
+ );
581
+ }
582
+ return {
583
+ destination: routing.destination,
584
+ source: routing.source,
585
+ ...routing.location ? { location: routing.location } : void 0
586
+ };
587
+ }
588
+
507
589
  export {
508
590
  configValueSchema,
509
591
  coerceThreadConversationState,
@@ -512,5 +594,7 @@ export {
512
594
  persistThreadRuntimeState,
513
595
  getPersistedThreadState,
514
596
  persistThreadStateById,
515
- getLocationConfigurationService
597
+ getLocationConfigurationService,
598
+ resolveConversationRouting,
599
+ resolveTurnSessionRouting
516
600
  };
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  createAndEnqueueAgentInvocation
3
- } from "./chunk-HJPC32TQ.js";
3
+ } from "./chunk-KRYJ5VOD.js";
4
4
  import {
5
5
  actorFromRun,
6
6
  toolInvocationDestination
7
- } from "./chunk-INQHUE72.js";
7
+ } from "./chunk-6FGN7ZEG.js";
8
8
 
9
9
  // src/chat/agent-invocations/spawn.ts
10
10
  function bindSpawnAgent(run, options) {
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-N7TMSOZH.js";
6
6
  import {
7
7
  toOptionalString
8
- } from "./chunk-OMQ2J6F6.js";
8
+ } from "./chunk-6YCIYOVA.js";
9
9
 
10
10
  // src/chat/slack/context.ts
11
11
  import { z } from "zod";