@sentry/junior 0.185.0 → 0.186.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 (88) hide show
  1. package/dist/{agent-hooks-NGZQLL5O.js → agent-hooks-4B3Z4WRK.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 +43 -35
  5. package/dist/app.js +1061 -216
  6. package/dist/{catalog-runtime-AAEAO2RL.js → catalog-runtime-AFJCAOHC.js} +4 -4
  7. package/dist/chat/api-turns/mailbox-input.d.ts +7 -0
  8. package/dist/chat/api-turns/routing.d.ts +18 -3
  9. package/dist/chat/conversations/turn-lifecycle.d.ts +2 -0
  10. package/dist/chat/providers/slack/runtime.d.ts +0 -2
  11. package/dist/chat/providers/slack/turn.d.ts +0 -2
  12. package/dist/chat/resource-events/actor.d.ts +7 -2
  13. package/dist/chat/resource-events/app-publisher.d.ts +18 -0
  14. package/dist/chat/resource-events/catalog.d.ts +19 -0
  15. package/dist/chat/resource-events/ingest.d.ts +0 -1
  16. package/dist/chat/resource-events/notification.d.ts +28 -3
  17. package/dist/chat/resource-events/runtime-catalog.d.ts +7 -2
  18. package/dist/chat/resource-events/store.d.ts +1 -13
  19. package/dist/chat/resource-events/workspace.d.ts +7 -3
  20. package/dist/chat/sandbox/egress/credentials.d.ts +5 -4
  21. package/dist/chat/sandbox/egress/session.d.ts +9 -9
  22. package/dist/chat/sandbox/errors.d.ts +1 -1
  23. package/dist/chat/sandbox/ref.d.ts +1 -1
  24. package/dist/chat/sandbox/snapshot/events.d.ts +8 -1
  25. package/dist/chat/sandbox/snapshot/not-ready-error.d.ts +6 -1
  26. package/dist/chat/sentry-links.d.ts +2 -0
  27. package/dist/chat/services/turn-session-routing.d.ts +20 -5
  28. package/dist/chat/task-execution/slack-resource-event.d.ts +47 -0
  29. package/dist/chat/task-execution/slack-work.d.ts +0 -21
  30. package/dist/chat/tools/event-tasks.d.ts +1 -1
  31. package/dist/chat/tools/resource-events.d.ts +1 -1
  32. package/dist/{chunk-D63IUQQE.js → chunk-2IBDVE62.js} +12 -9
  33. package/dist/{chunk-C6TS47CQ.js → chunk-2U7EPTRZ.js} +11 -5
  34. package/dist/{chunk-OMQ2J6F6.js → chunk-3CVEE6LA.js} +1 -1
  35. package/dist/{chunk-ABAX75GG.js → chunk-43LODHJM.js} +17 -3
  36. package/dist/{chunk-7MHNIGHP.js → chunk-64WF2GQ3.js} +1 -1
  37. package/dist/{chunk-X7NCJQAA.js → chunk-7EOWT62G.js} +1 -1
  38. package/dist/{chunk-MWOH6CIK.js → chunk-7EU4YSZ4.js} +201 -57
  39. package/dist/{chunk-4S47VHJR.js → chunk-ACGWTJ74.js} +3 -3
  40. package/dist/{chunk-LRI5IRGY.js → chunk-AD64YMEC.js} +2 -2
  41. package/dist/{chunk-FTVMXDNN.js → chunk-BRKB5R7P.js} +1 -1
  42. package/dist/{chunk-Y5G23T2D.js → chunk-CM6RTYSO.js} +5 -5
  43. package/dist/{chunk-QCT4226Q.js → chunk-CV5CPRVG.js} +3 -3
  44. package/dist/{chunk-QZKHHG3B.js → chunk-DHYZ4VKG.js} +382 -279
  45. package/dist/{chunk-PNYJOEVV.js → chunk-DOP3FIQC.js} +1 -1
  46. package/dist/{chunk-HJPC32TQ.js → chunk-EWRPUXE3.js} +9 -9
  47. package/dist/{chunk-EIJCPJOY.js → chunk-FFYDRLXW.js} +1 -1
  48. package/dist/{chunk-W7GCLNIV.js → chunk-GQMQCY7H.js} +2 -2
  49. package/dist/{chunk-6DOAUXLD.js → chunk-GSB3NTNS.js} +744 -1707
  50. package/dist/{chunk-WLKWN4CD.js → chunk-H7X2G2KS.js} +8 -5
  51. package/dist/{chunk-ATUWN6Z3.js → chunk-HKFLRIBD.js} +2 -2
  52. package/dist/{chunk-EJYP3NQ4.js → chunk-HWXP6RHG.js} +37 -3
  53. package/dist/{chunk-VH4IU3UC.js → chunk-JFPY6XFF.js} +19 -45
  54. package/dist/{chunk-FFHXG2FX.js → chunk-MCLWOBPN.js} +76 -16
  55. package/dist/{chunk-GJTIZQGJ.js → chunk-NRMAOGRS.js} +1 -1
  56. package/dist/{chunk-X2SS6BF7.js → chunk-O6GQO7VP.js} +27 -33
  57. package/dist/{chunk-DAPC2HTM.js → chunk-OZG7E22Y.js} +5 -5
  58. package/dist/{chunk-4K25ODAO.js → chunk-PFAZSRGR.js} +3 -1
  59. package/dist/{chunk-UUULGCKK.js → chunk-PZZOGHVR.js} +14 -4
  60. package/dist/{chunk-TVVAMOLS.js → chunk-QBL2AVFF.js} +1 -1
  61. package/dist/{chunk-4HA36IWS.js → chunk-QU3URVWG.js} +8 -8
  62. package/dist/{chunk-6Q7YZLCL.js → chunk-STOCCPWH.js} +9 -1
  63. package/dist/{chunk-EWEH2PJW.js → chunk-TXLBLGNQ.js} +5 -5
  64. package/dist/{chunk-U4CTAVWN.js → chunk-VOGOTEW7.js} +1 -1
  65. package/dist/{chunk-ZIF2S464.js → chunk-VQIWBJOP.js} +1 -1
  66. package/dist/{chunk-ZKKGFUWM.js → chunk-VQZYIVYN.js} +6 -6
  67. package/dist/{chunk-LVK4WJKM.js → chunk-VXL2LBPK.js} +1 -1
  68. package/dist/{chunk-7GAP2XG4.js → chunk-YXSBZRP7.js} +1 -1
  69. package/dist/cli/chat.js +32 -32
  70. package/dist/cli/check.js +5 -5
  71. package/dist/cli/plugins.js +12 -12
  72. package/dist/cli/snapshot-create.js +9 -9
  73. package/dist/cli/upgrade.js +6 -6
  74. package/dist/{db-TRJ77FAU.js → db-7XL4UPAE.js} +6 -6
  75. package/dist/instrumentation.js +3 -3
  76. package/dist/nitro.js +6 -6
  77. package/dist/{oauth-callback-server-XD5SV3MS.js → oauth-callback-server-RAOYHWDI.js} +27 -27
  78. package/dist/{runner-KFX7NG6D.js → runner-KMPBWRPM.js} +19 -19
  79. package/dist/{skills-J2AH26CW.js → skills-IPCALGLQ.js} +5 -5
  80. package/dist/spawn-OSOWTMBG.js +41 -0
  81. package/dist/task-runner-IQNBA3RY.js +34 -0
  82. package/dist/{validation-O5J4VOPF.js → validation-BSRCCX6N.js} +5 -5
  83. package/dist/version.js +1 -1
  84. package/dist/{work-ECPQTG3U.js → work-T6UFTOJY.js} +20 -20
  85. package/dist/{worker-RS3DXUDO.js → worker-L35OG7VA.js} +10 -10
  86. package/package.json +5 -5
  87. package/dist/spawn-VU3CSRI6.js +0 -41
  88. package/dist/task-runner-5JG3VIIY.js +0 -34
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-GJTIZQGJ.js";
4
- import "./chunk-7MHNIGHP.js";
3
+ } from "./chunk-NRMAOGRS.js";
4
+ import "./chunk-64WF2GQ3.js";
5
5
  import "./chunk-CEMMLV5L.js";
6
6
  import "./chunk-N7TMSOZH.js";
7
7
  import "./chunk-DWPN6SCH.js";
8
8
  import "./chunk-TXKUKMVO.js";
9
- import "./chunk-OMQ2J6F6.js";
9
+ import "./chunk-3CVEE6LA.js";
10
10
  import "./chunk-PEQXYSSE.js";
11
- import "./chunk-7GAP2XG4.js";
11
+ import "./chunk-YXSBZRP7.js";
12
12
  export {
13
13
  pluginCatalogRuntime
14
14
  };
@@ -0,0 +1,7 @@
1
+ /** Shared mailbox helpers for conversation-only turns. */
2
+ import type { LocalActor } from "@/chat/actor";
3
+ import type { InboundMessage } from "@/chat/task-execution/store";
4
+ /** Join non-empty mailbox texts for one conversation-only turn. */
5
+ export declare function joinMailboxText(messages: readonly InboundMessage[]): string;
6
+ /** Local actor stamped on resource-event conversation-only turns. */
7
+ export declare function localResourceEventActor(): LocalActor;
@@ -10,15 +10,27 @@ declare const apiTurnMailboxMetadataSchema: z.ZodObject<{
10
10
  messageId: z.ZodString;
11
11
  }, z.core.$strict>;
12
12
  export type ApiTurnMailboxMetadata = z.output<typeof apiTurnMailboxMetadataSchema>;
13
+ /**
14
+ * Local destination resource-event mailbox rows share the conversation-only runner.
15
+ *
16
+ * TODO(resource-events): Remove the dedicated `resource_event` work kind once
17
+ * local/web destinations run plain mailbox system wakes the same way as any
18
+ * other deferred conversation turn (no special batch/actor fork).
19
+ */
20
+ export type LocalResourceEventMailboxEntry = {
21
+ message: InboundMessage;
22
+ kind: "resource_event";
23
+ };
13
24
  /** Return the active root API Turn for one Conversation, if it has one. */
14
25
  export declare function getActiveApiTurnId(conversationId: string): Promise<string | undefined>;
15
26
  /** Return the idle auth-paused root API Turn for one Conversation. */
16
27
  export declare function getAuthPausedApiTurnId(conversationId: string): Promise<string | undefined>;
17
28
  /**
18
- * Resolve API Turn work from mailbox metadata or an active checkpoint.
29
+ * Resolve conversation-only work from mailbox metadata or an active checkpoint.
19
30
  *
20
- * Empty resume wakes after yield carry no mailbox rows. Use durable active
21
- * Turn state so these wakes do not fall through to Slack.
31
+ * Covers dashboard API turns and local destination resource-event wakes. Empty
32
+ * resume wakes after yield carry no mailbox rows; durable active Turn state keeps
33
+ * those wakes on this runner instead of falling through to Slack.
22
34
  */
23
35
  export declare function resolveApiTurnWork(context: ConversationWorkerContext): Promise<{
24
36
  kind: "mailbox";
@@ -26,6 +38,9 @@ export declare function resolveApiTurnWork(context: ConversationWorkerContext):
26
38
  message: InboundMessage;
27
39
  metadata: ApiTurnMailboxMetadata;
28
40
  }>;
41
+ } | {
42
+ kind: "resource_event";
43
+ batch: LocalResourceEventMailboxEntry[];
29
44
  } | {
30
45
  kind: "resume";
31
46
  turnId: string;
@@ -40,3 +40,5 @@ export declare class ConversationTurnLifecycleService implements ConversationTur
40
40
  /** Record a classified failure once. Do not store raw error text. */
41
41
  fail(input: FailConversationTurnInput): Promise<void>;
42
42
  }
43
+ /** Return the Turn lifecycle that records Conversation events. */
44
+ export declare function getTurnLifecycle(): ConversationTurnLifecycle;
@@ -10,7 +10,6 @@ import type { Message, MessageContext, Thread } from "chat";
10
10
  import type { Destination } from "@sentry/junior-plugin-api";
11
11
  import type { SubscribedReplyDecision, SubscribedReplyPolicy } from "@/chat/services/subscribed-reply-policy";
12
12
  import { type PrepareTurnStateInput, type QueuedTurnMessage, type TurnMessageText, type TurnToolInvocation } from "@/chat/runtime/turn-input";
13
- import type { FailConversationTurnInput } from "@/chat/conversations/turn-lifecycle";
14
13
  export interface AssistantLifecycleEvent {
15
14
  channelId: string;
16
15
  context?: {
@@ -55,7 +54,6 @@ export interface SlackTurnRuntimeDependencies<TPreparedState> {
55
54
  threadId: string;
56
55
  threadTs: string;
57
56
  }) => Promise<void>;
58
- failConversationTurn: (input: FailConversationTurnInput) => Promise<void>;
59
57
  refreshAssistantThreadContext: (event: {
60
58
  channelId: string;
61
59
  sourceChannelId?: string;
@@ -12,7 +12,6 @@ import type { PreparedTurnState } from "@/chat/runtime/turn-preparation";
12
12
  import { type PrepareTurnStateInput, type QueuedTurnMessage, type TurnToolInvocation } from "@/chat/runtime/turn-input";
13
13
  import type { ContextCompactor } from "@/chat/services/context-compaction";
14
14
  import type { PausedTurns } from "@/chat/task-execution/turn-wake";
15
- import type { ConversationTurnLifecycle } from "@/chat/conversations/turn-lifecycle";
16
15
  import { type ScheduleSessionCompletedPluginTasksOptions } from "@/chat/plugins/task-runner";
17
16
  import type { DispatchTurnContext, DispatchTurnResult } from "@/chat/agent-dispatch/types";
18
17
  interface SlackTurnDeps {
@@ -35,7 +34,6 @@ interface SlackTurnDeps {
35
34
  }>>;
36
35
  prepareTurnState: (args: PrepareTurnStateInput) => Promise<PreparedTurnState>;
37
36
  sendPluginTask?: ScheduleSessionCompletedPluginTasksOptions["send"];
38
- turnLifecycle: Pick<ConversationTurnLifecycle, "fail" | "start">;
39
37
  }
40
38
  /** Build the Slack caller that prepares input and delivers output for a Turn. */
41
39
  export declare function createSlackTurn(deps: SlackTurnDeps): (thread: Thread, message: Message, options: {
@@ -1,5 +1,10 @@
1
- /** Synthetic Slack author id stamped on resource-event mailbox messages. */
2
- export declare const RESOURCE_EVENT_SLACK_AUTHOR_ID = "UJRNEVENT";
1
+ /**
2
+ * Synthetic author id stamped on resource-event mailbox messages.
3
+ *
4
+ * Kept stable so provider adapters and conversation history can recognize the
5
+ * same system input for resource-event turns.
6
+ */
7
+ export declare const RESOURCE_EVENT_AUTHOR_ID = "UJRNEVENT";
3
8
  /** System execution actor for every resource-event turn. */
4
9
  export declare const RESOURCE_EVENT_SYSTEM_ACTOR: {
5
10
  readonly platform: "system";
@@ -0,0 +1,18 @@
1
+ import type { ResourceEvent } from "@sentry/junior-plugin-api";
2
+ import type { StateAdapter } from "chat";
3
+ import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
4
+ export type ResourceEventAppPublisher = {
5
+ neededMatchKeys(input: {
6
+ eventTypes: string[];
7
+ identifiers: string[];
8
+ namespace: string;
9
+ }): Promise<string[]>;
10
+ publish(event: ResourceEvent): Promise<void>;
11
+ };
12
+ /** Build the core resource-event publisher used by plugin routes. */
13
+ export declare function createResourceEventAppPublisher(args: {
14
+ conversationWork: () => {
15
+ queue?: ConversationWorkQueue;
16
+ state?: StateAdapter;
17
+ };
18
+ }): ResourceEventAppPublisher;
@@ -2,6 +2,25 @@ import { type PluginResourceEvents, type ResourceEventMatch, type ResourceEventM
2
2
  import { z } from "zod";
3
3
  type ResourceEventRegistration = Pick<PluginResourceEvents, "resourceTypes" | "normalizeIdentifier">;
4
4
  export type ResourceEventCatalog = Readonly<Record<string, ResourceEventRegistration>>;
5
+ /** Core-owned resource-event namespace. Not a plugin publisher. */
6
+ export declare const CORE_RESOURCE_EVENT_NAMESPACE = "junior";
7
+ /** True when the catalog has any enabled registration. */
8
+ export declare function hasResourceEventCatalogEntries(catalog: ResourceEventCatalog): boolean;
9
+ /**
10
+ * True when at least one plugin namespace is enabled.
11
+ *
12
+ * Core Workspace snapshot events stay in the catalog for search and temporary
13
+ * watches. Durable event tasks still require a plugin publisher.
14
+ */
15
+ export declare function hasPluginResourceEventCatalogEntries(catalog: ResourceEventCatalog): boolean;
16
+ /**
17
+ * Catalog entries that durable event tasks may select.
18
+ *
19
+ * Core Workspace snapshot events only wake temporary watches. Snapshot finish
20
+ * does not run event-task ingest, so those namespaces stay out of create/update
21
+ * schemas and trigger availability.
22
+ */
23
+ export declare function pluginResourceEventCatalog(catalog: ResourceEventCatalog): ResourceEventCatalog;
5
24
  /** Build the model-facing namespace enum from enabled resource event plugins. */
6
25
  export declare function eventNamespaceSchema(catalog: ResourceEventCatalog): z.ZodString | z.ZodEnum<{
7
26
  [x: string]: string;
@@ -5,7 +5,6 @@ export declare function ingestResourceEvent(input: unknown, options: {
5
5
  nowMs?: number;
6
6
  queue: ConversationWorkQueue;
7
7
  state?: StateAdapter;
8
- teamId: string;
9
8
  }): Promise<{
10
9
  enqueued: number;
11
10
  }>;
@@ -1,5 +1,5 @@
1
1
  import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
2
- import { appendAndEnqueueInboundMessage } from "@/chat/task-execution/store";
2
+ import { appendAndEnqueueInboundMessage, type AppendAndEnqueueInboundMessageResult, type InboundMessage } from "@/chat/task-execution/store";
3
3
  import type { ResourceEventSubscription } from "@/chat/resource-events/store";
4
4
  export interface ResourceEventNotification {
5
5
  eventKey: string;
@@ -19,10 +19,35 @@ export interface ResourceEventNotification {
19
19
  * contract. Stable delivery rules live in runtime and docs, not this prompt.
20
20
  */
21
21
  export declare function renderResourceEventNotificationText(subscription: Pick<ResourceEventSubscription, "intent" | "label" | "resourceType">, event: Pick<ResourceEventNotification, "namespace" | "eventType" | "trustedSummary" | "data" | "untrustedText">): string;
22
- /** Enqueue a resource event as normal conversation mailbox input. */
22
+ /** Resource-event identity stamped on plain mailbox input. */
23
+ export type ResourceEventMailboxMetadata = {
24
+ kind: "resource_event";
25
+ resourceEvent: {
26
+ eventKey: string;
27
+ eventType: string;
28
+ namespace: string;
29
+ identifier: string;
30
+ subscriptionId: string;
31
+ };
32
+ } & Record<string, unknown>;
33
+ /** Whether mailbox metadata is a plain resource-event wake. */
34
+ export declare function isResourceEventMailboxMetadata(value: unknown): value is ResourceEventMailboxMetadata;
35
+ /** Build plain conversation mailbox input for one matched watch. */
36
+ export declare function createResourceEventInboundMessage(input: {
37
+ event: ResourceEventNotification;
38
+ subscription: Pick<ResourceEventSubscription, "conversationId" | "id">;
39
+ text: string;
40
+ receivedAtMs?: number;
41
+ }): InboundMessage;
42
+ /**
43
+ * Enqueue a resource event as normal conversation mailbox input.
44
+ *
45
+ * The watch only names the conversation. Destination stays on the conversation
46
+ * and is applied when the worker runs.
47
+ */
23
48
  export declare function enqueueResourceEventNotification(args: {
24
49
  event: ResourceEventNotification;
25
50
  queue: ConversationWorkQueue;
26
51
  subscription: ResourceEventSubscription;
27
52
  state?: Parameters<typeof appendAndEnqueueInboundMessage>[0]["state"];
28
- }): Promise<Awaited<ReturnType<typeof appendAndEnqueueInboundMessage>>>;
53
+ }): Promise<AppendAndEnqueueInboundMessageResult>;
@@ -1,3 +1,8 @@
1
- import type { ResourceEventCatalog } from "@/chat/resource-events/catalog";
2
- /** Read enabled plugin resource-event registrations as one core catalog. */
1
+ import { type ResourceEventCatalog } from "@/chat/resource-events/catalog";
2
+ /**
3
+ * Enabled resource-event registrations for search, guidance, and tool schemas.
4
+ *
5
+ * Includes core Workspace snapshot events under the `junior` namespace, plus
6
+ * every enabled plugin registration. Plugins may not use the `junior` namespace.
7
+ */
3
8
  export declare function getResourceEventCatalog(): ResourceEventCatalog;
@@ -1,17 +1,9 @@
1
1
  import type { StateAdapter } from "chat";
2
- import { type Destination, type ResourceEventData, type ResourceEventMatch } from "@sentry/junior-plugin-api";
2
+ import { type ResourceEventData, type ResourceEventMatch } from "@sentry/junior-plugin-api";
3
3
  import { z } from "zod";
4
4
  declare const subscriptionSchema: z.ZodObject<{
5
5
  conversationId: z.ZodString;
6
6
  createdAtMs: z.ZodNumber;
7
- destination: z.ZodDiscriminatedUnion<[z.ZodObject<{
8
- platform: z.ZodLiteral<"slack">;
9
- teamId: z.ZodString;
10
- channelId: z.ZodString;
11
- }, z.core.$strict>, z.ZodObject<{
12
- platform: z.ZodLiteral<"local">;
13
- conversationId: z.ZodString;
14
- }, z.core.$strict>], "platform">;
15
7
  events: z.ZodArray<z.ZodString>;
16
8
  expiresAtMs: z.ZodNumber;
17
9
  id: z.ZodString;
@@ -31,7 +23,6 @@ declare const subscriptionSchema: z.ZodObject<{
31
23
  export type ResourceEventSubscription = z.output<typeof subscriptionSchema>;
32
24
  export interface CreateResourceEventSubscriptionInput {
33
25
  conversationId: string;
34
- destination: Destination;
35
26
  events: string[];
36
27
  expiresAtMs: number;
37
28
  intent: string;
@@ -75,7 +66,6 @@ export declare function collectResourceEventMatchKeys(input: {
75
66
  namespace: string;
76
67
  nowMs?: number;
77
68
  state?: StateAdapter;
78
- teamId: string;
79
69
  }): Promise<string[]>;
80
70
  /** Find active subscriptions interested in a normalized resource event. */
81
71
  export declare function findMatchingResourceEventSubscriptions(input: {
@@ -85,7 +75,6 @@ export declare function findMatchingResourceEventSubscriptions(input: {
85
75
  namespace: string;
86
76
  identifier: string;
87
77
  state?: StateAdapter;
88
- teamId: string;
89
78
  }): Promise<ResourceEventSubscription[]>;
90
79
  /** Recheck and deliver a matched subscription while holding its status lock. */
91
80
  export declare function deliverResourceEventSubscription(input: {
@@ -97,7 +86,6 @@ export declare function deliverResourceEventSubscription(input: {
97
86
  identifier: string;
98
87
  state?: StateAdapter;
99
88
  subscription: ResourceEventSubscription;
100
- teamId: string;
101
89
  terminal?: boolean;
102
90
  waitDeadlineMs?: number;
103
91
  }): Promise<boolean>;
@@ -1,4 +1,8 @@
1
- /** Return whether provider events can be bound to one Slack workspace. */
2
- export declare function canRouteResourceEvents(): boolean;
3
- /** Resolve and cache the Slack workspace owned by this app instance. */
1
+ /**
2
+ * Resolve the single-bot Slack team id for event-task indexing.
3
+ *
4
+ * Resource watches do not use this. Event tasks still key by destination team
5
+ * until that store is conversation-owned. Resource-event delivery itself is
6
+ * not gated on Slack.
7
+ */
4
8
  export declare function createResourceEventTeamIdResolver(): () => Promise<string | undefined>;
@@ -49,11 +49,12 @@ export declare function selectSandboxEgressGrant(input: {
49
49
  */
50
50
  export declare function authorizationForSandboxEgressGrant(provider: string, selection: SandboxEgressGrantSelection): PluginAuthorization | undefined;
51
51
  /**
52
- * Return cached or newly issued credential header transforms for a selected grant.
52
+ * Return credential header transforms for a selected grant.
53
53
  *
54
- * Leases are cached on the host by provider grant, validated against
55
- * provider-owned domains, and reused until the provider lease is near expiry.
56
- * Sandbox context only authorizes the hop.
54
+ * Only shared installation grants are remembered on the host. User and other
55
+ * grants always issue from the live credential source so a saved login change
56
+ * cannot leave stale auth headers in place. The sandbox context only authorizes
57
+ * the request.
57
58
  */
58
59
  export declare function sandboxEgressCredentialLease(provider: string, selection: SandboxEgressGrantSelection, context: SandboxEgressCredentialContext): Promise<SandboxEgressCredentialLease>;
59
60
  /** Return whether a credential lease can modify requests to the target host. */
@@ -22,17 +22,17 @@ export declare function createSandboxEgressCredentialToken(input: {
22
22
  */
23
23
  export declare function parseSandboxEgressCredentialToken(token: string | undefined): SandboxEgressCredentialContext | undefined;
24
24
  /**
25
- * Cache credential header transforms for one provider grant.
25
+ * Remember auth headers for a shared installation grant.
26
26
  *
27
- * TTL follows the provider lease expiry. Sandbox context expiry still decides
28
- * whether a hop may use the cache; it does not shorten a shared installation
29
- * lease for other sandboxes.
27
+ * User and other grants are ignored here. TTL follows the provider expiry.
28
+ * Sandbox context expiry still decides whether a request may use the headers;
29
+ * it does not shorten a shared installation grant for other sandboxes.
30
30
  */
31
- export declare function setSandboxEgressCredentialLease(context: SandboxEgressCredentialContext, lease: SandboxEgressCredentialLease): Promise<void>;
32
- /** Load cached credential header transforms for one provider grant. */
33
- export declare function getSandboxEgressCredentialLease(provider: string, grant: SandboxEgressCredentialLease["grant"], context: SandboxEgressCredentialContext): Promise<SandboxEgressCredentialLease | undefined>;
34
- /** Clear a cached lease after the upstream provider rejects its auth headers. */
35
- export declare function clearSandboxEgressCredentialLease(provider: string, grant: SandboxEgressCredentialLease["grant"], context: SandboxEgressCredentialContext): Promise<void>;
31
+ export declare function setSandboxEgressCredentialLease(_context: SandboxEgressCredentialContext, lease: SandboxEgressCredentialLease): Promise<void>;
32
+ /** Load remembered auth headers for a shared installation grant. */
33
+ export declare function getSandboxEgressCredentialLease(provider: string, grant: SandboxEgressCredentialLease["grant"], _context: SandboxEgressCredentialContext): Promise<SandboxEgressCredentialLease | undefined>;
34
+ /** Drop remembered installation headers after the upstream rejects them. */
35
+ export declare function clearSandboxEgressCredentialLease(provider: string, grant: SandboxEgressCredentialLease["grant"], _context: SandboxEgressCredentialContext): Promise<void>;
36
36
  /**
37
37
  * Record that credential issuance needs user authorization for this command.
38
38
  *
@@ -12,7 +12,7 @@ export declare function isAbortError(error: unknown): boolean;
12
12
  export declare function isSandboxApiTransientError(error: unknown): boolean;
13
13
  /** Detect interrupted command streams where no reliable exit status is available. */
14
14
  export declare function isSandboxCommandStreamInterruptedError(error: unknown): boolean;
15
- /** Wrap raw sandbox setup failures into one stable user-facing error contract. */
15
+ /** Wrap setup failures. Keep WorkspaceSnapshotNotReadyError as-is. */
16
16
  export declare function wrapSandboxSetupError(error: unknown): Error;
17
17
  /** Record span data and throw one stable sandbox operation error. */
18
18
  export declare function throwSandboxOperationError(action: string, error: unknown, includeMissingPath?: boolean): never;
@@ -1,4 +1,4 @@
1
- /** Durable opaque handle used to reopen a conversation's sandbox. */
1
+ /** Sandbox this conversation is using. Reopen by `id`; only switchWorkspace replaces it. */
2
2
  export interface SandboxRef {
3
3
  id: string;
4
4
  profileHash?: string;
@@ -1,8 +1,15 @@
1
- import type { ResourceEvent, SubscribableResource } from "@sentry/junior-plugin-api";
1
+ import type { PluginResourceEvents, ResourceEvent, SubscribableResource } from "@sentry/junior-plugin-api";
2
2
  export declare const WORKSPACE_SNAPSHOT_NAMESPACE = "junior";
3
3
  export declare const WORKSPACE_SNAPSHOT_RESOURCE_TYPE = "workspace_snapshot";
4
4
  export declare const WORKSPACE_SNAPSHOT_READY_EVENT = "workspace_snapshot.ready";
5
5
  export declare const WORKSPACE_SNAPSHOT_FAILED_EVENT = "workspace_snapshot.failed";
6
+ /**
7
+ * Core catalog entry for Workspace snapshot ready and failed events.
8
+ *
9
+ * Uses the same registration shape as plugins so search, guidance, and tool
10
+ * schemas treat these events like any other resource type.
11
+ */
12
+ export declare function workspaceSnapshotResourceEvents(): PluginResourceEvents;
6
13
  /** Describe the events that report when a snapshot build ends. */
7
14
  export declare function workspaceSnapshotWatch(input: {
8
15
  workspaceId: string;
@@ -1,6 +1,11 @@
1
1
  /** Report that a Workspace snapshot is not ready to use. */
2
2
  export declare class WorkspaceSnapshotNotReadyError extends Error {
3
+ readonly workspaceName: string;
3
4
  constructor(workspaceName: string);
4
5
  }
5
- /** Check an error and its causes for a snapshot that is not ready. */
6
+ /** Return WorkspaceSnapshotNotReadyError from this error or its causes. */
7
+ export declare function getWorkspaceSnapshotNotReadyError(error: unknown): WorkspaceSnapshotNotReadyError | undefined;
8
+ /** True when this error or a cause is WorkspaceSnapshotNotReadyError. */
6
9
  export declare function isWorkspaceSnapshotNotReadyError(error: unknown): boolean;
10
+ /** User message when a Workspace sandbox is still preparing. */
11
+ export declare function workspaceSnapshotNotReadyUserMessage(error: WorkspaceSnapshotNotReadyError): string;
@@ -1,4 +1,6 @@
1
1
  /** Build a Sentry conversation URL only when the runtime has enough Sentry config. */
2
2
  export declare function buildSentryConversationUrl(conversationId: string): string | undefined;
3
+ /** Build a Sentry event URL only when the runtime has enough Sentry config. */
4
+ export declare function buildSentryEventUrl(eventId: string): string | undefined;
3
5
  /** Build a Sentry trace URL only when the runtime has enough Sentry config. */
4
6
  export declare function buildSentryTraceUrl(traceId: string): string | undefined;
@@ -1,18 +1,33 @@
1
1
  /**
2
- * Load turn-session routing from durable conversation metadata.
2
+ * Load destination and session source from the conversation record.
3
3
  *
4
- * SQL owns destination and session source. Resume paths query those columns
5
- * directly — no redis fallback and no derived rebuild of missing fields.
4
+ * Destination is set once on the root conversation. Child conversations
5
+ * inherit through parent lineage. Later turns and mailbox wakes use that
6
+ * same destination so tools stay consistent for the whole conversation.
6
7
  */
7
8
  import type { Destination, Source } from "@sentry/junior-plugin-api";
8
9
  import type { ConversationStore } from "@/chat/conversations/store";
9
10
  export interface TurnSessionRouting {
10
11
  destination: Destination;
11
12
  locationId?: string;
12
- source: Source;
13
+ /** Present when the conversation already stores a session source. */
14
+ source?: Source;
13
15
  }
16
+ /** Full turn routing: destination plus a completed session source. */
17
+ export type RequiredTurnSessionRouting = TurnSessionRouting & {
18
+ source: Source;
19
+ };
20
+ /**
21
+ * Resolve the conversation's destination and session source.
22
+ *
23
+ * Walks parent lineage when the conversation has no destination of its own.
24
+ */
25
+ export declare function resolveConversationRouting(args: {
26
+ conversationId: string;
27
+ conversationStore?: ConversationStore;
28
+ }): Promise<TurnSessionRouting | undefined>;
14
29
  /** Require conversation destination and session source from SQL. */
15
30
  export declare function resolveTurnSessionRouting(args: {
16
31
  conversationId: string;
17
32
  conversationStore?: ConversationStore;
18
- }): Promise<TurnSessionRouting>;
33
+ }): Promise<RequiredTurnSessionRouting>;
@@ -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. */
@@ -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. */
@@ -8,14 +8,14 @@ import {
8
8
  getConversationStore,
9
9
  parseDestination,
10
10
  sameDestination
11
- } from "./chunk-ABAX75GG.js";
11
+ } from "./chunk-43LODHJM.js";
12
12
  import {
13
13
  getDefaultRedisStateAdapterFor,
14
14
  getStateAdapter
15
- } from "./chunk-PNYJOEVV.js";
15
+ } from "./chunk-DOP3FIQC.js";
16
16
  import {
17
17
  getChatConfig
18
- } from "./chunk-LRI5IRGY.js";
18
+ } from "./chunk-AD64YMEC.js";
19
19
  import {
20
20
  parseStoredSlackActor
21
21
  } from "./chunk-N7TMSOZH.js";
@@ -23,7 +23,7 @@ import {
23
23
  isRecord,
24
24
  toOptionalNumber,
25
25
  toOptionalString
26
- } from "./chunk-OMQ2J6F6.js";
26
+ } from "./chunk-3CVEE6LA.js";
27
27
 
28
28
  // src/chat/task-execution/state.ts
29
29
  import { randomUUID } from "crypto";
@@ -248,9 +248,12 @@ function normalizeConversation(conversationId, value) {
248
248
  if (storedConversationId !== conversationId || typeof createdAtMs !== "number" || typeof lastActivityAtMs !== "number" || typeof updatedAtMs !== "number" || !execution || value.destination !== void 0 && !destination) {
249
249
  return void 0;
250
250
  }
251
- if (execution.pendingMessages.length > 0 && execution.pendingMessages.some(
252
- (message) => message.destination ? !destination || !sameDestination(message.destination, destination) : Boolean(destination)
253
- )) {
251
+ if (execution.pendingMessages.length > 0 && execution.pendingMessages.some((message) => {
252
+ if (!message.destination) {
253
+ return false;
254
+ }
255
+ return !destination || !sameDestination(message.destination, destination);
256
+ })) {
254
257
  return void 0;
255
258
  }
256
259
  return {
@@ -636,10 +639,10 @@ async function writeConversation(state, lock, conversation) {
636
639
  });
637
640
  }
638
641
  function assertSameOptionalConversationDestination(args) {
639
- if (!args.current && !args.next) {
642
+ if (!args.next || !args.current) {
640
643
  return;
641
644
  }
642
- if (args.current && args.next && sameDestination(args.current, args.next)) {
645
+ if (sameDestination(args.current, args.next)) {
643
646
  return;
644
647
  }
645
648
  throw new Error(