@sentry/junior 0.181.1 → 0.183.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 (107) hide show
  1. package/dist/{agent-hooks-KO56HJ74.js → agent-hooks-SNRBZYAU.js} +11 -11
  2. package/dist/api/code/overview.d.ts +35 -0
  3. package/dist/api/code/routes.d.ts +4 -0
  4. package/dist/api/schema/code.d.ts +75 -0
  5. package/dist/api/schema.d.ts +2 -0
  6. package/dist/api/schema.js +9 -1
  7. package/dist/api.js +347 -149
  8. package/dist/app-adapter.d.ts +85 -0
  9. package/dist/app.d.ts +6 -1
  10. package/dist/app.js +380 -501
  11. package/dist/{catalog-runtime-CJTFLCK3.js → catalog-runtime-3I3JOIIH.js} +4 -4
  12. package/dist/chat/agent-invocations/store.d.ts +4 -2
  13. package/dist/chat/agent-invocations/work.d.ts +1 -3
  14. package/dist/chat/api-turns/adapter-conversations.d.ts +15 -0
  15. package/dist/chat/api-turns/stop.d.ts +12 -0
  16. package/dist/chat/api-turns/work.d.ts +9 -1
  17. package/dist/chat/app/conversation-work.d.ts +1 -1
  18. package/dist/chat/app/factory.d.ts +3 -3
  19. package/dist/chat/app/services.d.ts +3 -3
  20. package/dist/chat/code/publisher.d.ts +3 -0
  21. package/dist/chat/code/store.d.ts +9 -0
  22. package/dist/chat/event-tasks/store.d.ts +10 -0
  23. package/dist/chat/event-tasks/tool-support.d.ts +7 -1
  24. package/dist/chat/event-tasks/types.d.ts +1 -0
  25. package/dist/chat/experimental.d.ts +1 -1
  26. package/dist/chat/ingress/slack-webhook.d.ts +1 -1
  27. package/dist/chat/plugins/agent-hooks.d.ts +5 -0
  28. package/dist/chat/{runtime/slack-runtime.d.ts → providers/slack/runtime.d.ts} +2 -2
  29. package/dist/chat/{runtime/reply-executor.d.ts → providers/slack/turn.d.ts} +10 -9
  30. package/dist/chat/resource-events/catalog.d.ts +11 -1
  31. package/dist/chat/resource-events/store.d.ts +17 -1
  32. package/dist/chat/runtime/turn-execution.d.ts +30 -0
  33. package/dist/chat/services/subscribed-decision.d.ts +2 -1
  34. package/dist/chat/slack/dispatch-turn.d.ts +12 -14
  35. package/dist/chat/task-execution/slack-work.d.ts +1 -1
  36. package/dist/chat/tools/create-event-task.d.ts +3 -0
  37. package/dist/chat/tools/delete-event-task.d.ts +2 -0
  38. package/dist/chat/tools/list-event-tasks.d.ts +2 -0
  39. package/dist/chat/tools/list-resource-event-subscriptions.d.ts +2 -0
  40. package/dist/chat/tools/search-resource-event-types.d.ts +10 -0
  41. package/dist/chat/tools/update-event-task.d.ts +3 -0
  42. package/dist/chat/tools/watch-resource-events.d.ts +3 -0
  43. package/dist/{chunk-DTRCZOHE.js → chunk-24OJZ5OU.js} +6 -6
  44. package/dist/{chunk-Z2UG4FBT.js → chunk-2ADFGSUS.js} +1 -1
  45. package/dist/{chunk-RULGB5NX.js → chunk-2EPYYVJC.js} +9 -9
  46. package/dist/{chunk-VRS6WDK5.js → chunk-2LYHWMR4.js} +1 -1
  47. package/dist/{chunk-XQ56HNH5.js → chunk-35PM4YY5.js} +6 -6
  48. package/dist/{chunk-6TB7JN63.js → chunk-37IQ6DGU.js} +3 -3
  49. package/dist/{chunk-MR36BRPE.js → chunk-3HJ4F4L7.js} +4 -4
  50. package/dist/{chunk-4WYHL4EH.js → chunk-3L7CWDQQ.js} +1 -1
  51. package/dist/{chunk-CJRUBOJI.js → chunk-4WGFWHWP.js} +1 -1
  52. package/dist/{chunk-VHSBLFNT.js → chunk-56XONJPF.js} +1 -1
  53. package/dist/{chunk-ULM7P4EQ.js → chunk-6UXDTPEN.js} +233 -173
  54. package/dist/{chunk-WDNA4LML.js → chunk-AHMWPFIW.js} +188 -11
  55. package/dist/{chunk-YCW6RZGX.js → chunk-AX3UDIMA.js} +3 -3
  56. package/dist/{chunk-HG6HNOTQ.js → chunk-AYW7J6K4.js} +130 -200
  57. package/dist/{chunk-DXK3VTVP.js → chunk-E3OBGRHN.js} +1 -1
  58. package/dist/{chunk-7UF37LNL.js → chunk-EENQGEIP.js} +1 -1
  59. package/dist/{chunk-HRTW7FFX.js → chunk-FJMTMGBC.js} +1 -1
  60. package/dist/{chunk-H6MPFFBE.js → chunk-G2B2XZQW.js} +1 -1
  61. package/dist/{chunk-4GOZBB22.js → chunk-HUK5XIZL.js} +63 -7
  62. package/dist/{chunk-DINF4LMR.js → chunk-IO6KFXYE.js} +160 -97
  63. package/dist/{chunk-KH2SL2HT.js → chunk-KTXOGLNE.js} +2 -2
  64. package/dist/{chunk-S63LNPIV.js → chunk-LMNMMESF.js} +2 -2
  65. package/dist/{chunk-2CZ63QCL.js → chunk-LZBPGX5A.js} +1 -1
  66. package/dist/{chunk-PJ7EGFME.js → chunk-PLZT45VC.js} +5 -5
  67. package/dist/{chunk-ZQQWJMHE.js → chunk-QI5JW5AG.js} +6 -6
  68. package/dist/{chunk-IWRPJ3J5.js → chunk-QZV76CM4.js} +58 -32
  69. package/dist/{chunk-YFJDRORU.js → chunk-R767Y7QV.js} +202 -90
  70. package/dist/{chunk-4OSVTPYQ.js → chunk-SQHFVIMZ.js} +1 -1
  71. package/dist/{chunk-J4ID4ZI6.js → chunk-T5MTGX2E.js} +19 -19
  72. package/dist/{chunk-NRF23QZ4.js → chunk-V64JCZUV.js} +3 -3
  73. package/dist/{chunk-GITIZ6TZ.js → chunk-VOV3SCM3.js} +1 -1
  74. package/dist/{chunk-S5X2VQOD.js → chunk-W46NIB5H.js} +3 -2
  75. package/dist/{chunk-XL3C4NAR.js → chunk-W5JMPEBO.js} +9 -9
  76. package/dist/{chunk-HPFHC7YR.js → chunk-WOKJRLM2.js} +5 -5
  77. package/dist/chunk-WVIA7V3M.js +975 -0
  78. package/dist/{chunk-QA6RE6IB.js → chunk-X52ESOBP.js} +3 -3
  79. package/dist/cli/chat.js +35 -37
  80. package/dist/cli/check.js +5 -5
  81. package/dist/cli/plugins.js +12 -12
  82. package/dist/cli/snapshot-create.js +9 -9
  83. package/dist/cli/upgrade.js +6 -6
  84. package/dist/db/schema/code.d.ts +367 -0
  85. package/dist/db/schema.d.ts +367 -1
  86. package/dist/{db-4PXTD3OH.js → db-K2VMNLHQ.js} +6 -6
  87. package/dist/{experimental-SIJSRDJD.js → experimental-P5FZM4CU.js} +1 -1
  88. package/dist/instrumentation.js +3 -3
  89. package/dist/nitro.js +6 -6
  90. package/dist/{oauth-callback-server-TQWNEVR6.js → oauth-callback-server-DZZMTKSS.js} +26 -26
  91. package/dist/{runner-G5HLQA43.js → runner-IIAKWDXI.js} +18 -18
  92. package/dist/{skills-BNNNRYNT.js → skills-EXIQ7BP5.js} +5 -5
  93. package/dist/spawn-ZR6OOEAN.js +37 -0
  94. package/dist/task-runner-C52HYCVD.js +32 -0
  95. package/dist/{validation-IJSBB6JR.js → validation-XUGIWBJF.js} +5 -5
  96. package/dist/version.js +1 -1
  97. package/dist/{work-5FQI4P2A.js → work-G4RLJ634.js} +18 -18
  98. package/dist/worker-R2JEHK67.js +22 -0
  99. package/migrations/0036_complex_rage.sql +32 -0
  100. package/migrations/meta/0036_snapshot.json +3186 -0
  101. package/migrations/meta/_journal.json +8 -1
  102. package/package.json +6 -5
  103. package/dist/api/acp/route.d.ts +0 -13
  104. package/dist/chunk-CZYNWPWD.js +0 -930
  105. package/dist/spawn-U2RKOFP2.js +0 -37
  106. package/dist/task-runner-CDZJBEXP.js +0 -32
  107. package/dist/worker-KJ362GVB.js +0 -22
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-DXK3VTVP.js";
4
- import "./chunk-7UF37LNL.js";
3
+ } from "./chunk-E3OBGRHN.js";
4
+ import "./chunk-EENQGEIP.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-2CZ63QCL.js";
9
+ import "./chunk-LZBPGX5A.js";
10
10
  import "./chunk-PEQXYSSE.js";
11
- import "./chunk-S5X2VQOD.js";
11
+ import "./chunk-W46NIB5H.js";
12
12
  export {
13
13
  pluginCatalogRuntime
14
14
  };
@@ -40,5 +40,7 @@ export declare function completeAgentInvocation(args: {
40
40
  status: "blocked" | "failed";
41
41
  nowMs?: number;
42
42
  }): Promise<AgentInvocation | undefined>;
43
- /** Return whether an invocation already owns its immutable terminal result. */
44
- export declare function isTerminalAgentInvocation(invocation: AgentInvocation): boolean;
43
+ /** Return whether an agent invocation has finished. */
44
+ export declare function isTerminalAgentInvocation(invocation: AgentInvocation): invocation is Extract<AgentInvocation, {
45
+ status: "blocked" | "completed" | "failed";
46
+ }>;
@@ -20,9 +20,7 @@ export declare function createAndEnqueueAgentInvocation(input: CreateAgentInvoca
20
20
  /** Resolve invocation execution from mailbox input or durable active state. */
21
21
  export declare function resolveAgentInvocationId(context: ConversationWorkerContext): Promise<string | undefined>;
22
22
  /** Build the invocation consumer that advances work through the shared runner. */
23
- export declare function createAgentInvocationWorker(options: {
24
- agentRunner: AgentRunner;
25
- }): (context: ConversationWorkerContext, invocationId: string) => Promise<ConversationWorkerResult>;
23
+ export declare function createAgentInvocationWorker(agentRunner: AgentRunner): (context: ConversationWorkerContext, invocationId: string) => Promise<ConversationWorkerResult>;
26
24
  /** Route invocation-backed work before falling through to existing consumers. */
27
25
  export declare function routeAgentInvocationWork(options: {
28
26
  fallbackWorker: (context: ConversationWorkerContext) => Promise<ConversationWorkerResult>;
@@ -0,0 +1,15 @@
1
+ /** Bind app adapters to Junior's Conversation runtime. */
2
+ import type { StateAdapter } from "chat";
3
+ import type { AdapterConversations } from "@/app-adapter";
4
+ import type { ConversationEventStore } from "@/chat/conversations/history";
5
+ import type { ConversationStore } from "@/chat/conversations/store";
6
+ import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
7
+ interface AdapterConversationOptions {
8
+ conversationStore?: ConversationStore;
9
+ eventStore: ConversationEventStore;
10
+ queue: ConversationWorkQueue;
11
+ state: StateAdapter;
12
+ }
13
+ /** Create the Conversation capability supplied to app adapters. */
14
+ export declare function createAdapterConversations(options: AdapterConversationOptions): AdapterConversations;
15
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { StateAdapter } from "chat";
2
+ import type { ConversationStore } from "@/chat/conversations/store";
3
+ import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
4
+ import { type StopConversationWorkResult } from "@/chat/task-execution/store";
5
+ /** Stop the current API Turn and wake an idle durable resume when needed. */
6
+ export declare function stopApiConversationTurn(args: {
7
+ conversationId: string;
8
+ conversationStore?: ConversationStore;
9
+ nowMs?: number;
10
+ queue: ConversationWorkQueue;
11
+ state?: StateAdapter;
12
+ }): Promise<StopConversationWorkResult>;
@@ -37,6 +37,11 @@ export interface ApiConversationMessageAccepted {
37
37
  messageId: string;
38
38
  status: "accepted" | "duplicate";
39
39
  }
40
+ export type ApiConversationMessageAdmission = ApiConversationMessageAccepted | {
41
+ conversationId: string;
42
+ messageId: string;
43
+ status: "active";
44
+ };
40
45
  /**
41
46
  * Build a durable API conversation id for one viewer + create key.
42
47
  *
@@ -81,7 +86,10 @@ export declare function recordApiConversationActivity(args: {
81
86
  }): Promise<Destination>;
82
87
  /** Create a dashboard root conversation and enqueue its first message. */
83
88
  export declare function createAndEnqueueApiConversation(input: CreateApiConversationInput, options: EnqueueOptions): Promise<ApiConversationMessageAccepted>;
84
- /** Append one API message to an existing conversation and wake the worker. */
89
+ /** Append one API message and optionally require an idle Conversation. */
90
+ export declare function appendAndEnqueueApiConversationMessage(input: AppendApiConversationMessageInput, options: EnqueueOptions & {
91
+ exclusive: true;
92
+ }): Promise<ApiConversationMessageAdmission>;
85
93
  export declare function appendAndEnqueueApiConversationMessage(input: AppendApiConversationMessageInput, options: EnqueueOptions): Promise<ApiConversationMessageAccepted>;
86
94
  /** Build the mailbox consumer for API-authored root turns. */
87
95
  export declare function createApiTurnWorker(options: {
@@ -16,7 +16,7 @@ interface ConversationWorkOptions {
16
16
  state?: StateAdapter;
17
17
  }
18
18
  export type ConversationWorkCallbackOptions = VercelConversationWorkCallbackOptions & {
19
- /** App-scoped control required by the experimental ACP route. */
19
+ /** App-scoped control for API Turn cancellation across request handlers. */
20
20
  apiTurnCancellation?: ApiTurnCancellation;
21
21
  };
22
22
  /**
@@ -1,6 +1,6 @@
1
1
  import type { SlackAdapter } from "@chat-adapter/slack";
2
2
  import type { Message } from "chat";
3
- import { type AssistantLifecycleEvent } from "@/chat/runtime/slack-runtime";
3
+ import { type AssistantLifecycleEvent } from "@/chat/providers/slack/runtime";
4
4
  import type { JuniorRuntimeServiceOverrides } from "@/chat/app/services";
5
5
  export interface CreateSlackRuntimeOptions {
6
6
  getSlackAdapter: () => SlackAdapter;
@@ -14,6 +14,6 @@ export declare function createSlackRuntime(options: CreateSlackRuntimeOptions):
14
14
  }) => Promise<import("../agent-dispatch/types").DispatchTurnResult>;
15
15
  handleAssistantContextChanged: (event: AssistantLifecycleEvent) => Promise<void>;
16
16
  handleAssistantThreadStarted: (event: AssistantLifecycleEvent) => Promise<void>;
17
- handleNewMention: (thread: import("chat").Thread, message: Message, hooks: import("@/chat/runtime/slack-runtime").SlackTurnOptions) => Promise<void>;
18
- handleSubscribedMessage: (thread: import("chat").Thread, message: Message, hooks: import("@/chat/runtime/slack-runtime").SlackTurnOptions) => Promise<void>;
17
+ handleNewMention: (thread: import("chat").Thread, message: Message, hooks: import("@/chat/providers/slack/runtime").SlackTurnOptions) => Promise<void>;
18
+ handleSubscribedMessage: (thread: import("chat").Thread, message: Message, hooks: import("@/chat/providers/slack/runtime").SlackTurnOptions) => Promise<void>;
19
19
  };
@@ -2,19 +2,19 @@ import type { SandboxEgressTracePropagationConfig } from "@/chat/sandbox/egress/
2
2
  import { type ConversationMemoryDeps, type ConversationMemoryService } from "@/chat/services/conversation-memory";
3
3
  import { type ContextCompactor, type ContextCompactorDeps } from "@/chat/services/context-compaction";
4
4
  import { type SubscribedReplyPolicy, type SubscribedReplyPolicyDeps } from "@/chat/services/subscribed-reply-policy";
5
- import type { ReplyExecutorServices } from "@/chat/runtime/reply-executor";
5
+ import type { SlackTurnServices } from "@/chat/providers/slack/turn";
6
6
  import { type VisionContextDeps, type VisionContextService } from "@/chat/slack/vision-context";
7
7
  export interface JuniorRuntimeServices {
8
8
  conversationMemory: ConversationMemoryService;
9
9
  contextCompactor: ContextCompactor;
10
- replyExecutor: ReplyExecutorServices;
10
+ replyExecutor: SlackTurnServices;
11
11
  subscribedReplyPolicy: SubscribedReplyPolicy;
12
12
  visionContext: VisionContextService;
13
13
  }
14
14
  export interface JuniorRuntimeServiceOverrides {
15
15
  conversationMemory?: Partial<ConversationMemoryDeps>;
16
16
  contextCompactor?: Partial<ContextCompactorDeps>;
17
- replyExecutor?: Partial<ReplyExecutorServices>;
17
+ replyExecutor?: Partial<SlackTurnServices>;
18
18
  subscribedReplyPolicy?: Partial<SubscribedReplyPolicyDeps>;
19
19
  sandbox?: {
20
20
  tracePropagation?: SandboxEgressTracePropagationConfig;
@@ -0,0 +1,3 @@
1
+ import type { CodeChangePublisher } from "@sentry/junior-plugin-api";
2
+ /** Connect a plugin to Junior's code records. */
3
+ export declare function createCodeChangePublisher(provider: string): CodeChangePublisher;
@@ -0,0 +1,9 @@
1
+ import { type CodeChangeInput } from "@sentry/junior-plugin-api";
2
+ import type { JuniorDatabase } from "@/db/db";
3
+ /** Record the latest details for one code change created by Junior. */
4
+ export declare function recordCodeChange(db: JuniorDatabase, provider: string, input: CodeChangeInput): Promise<void>;
5
+ /** Add conversation links to an existing code change. */
6
+ export declare function associateCodeChangeConversations(db: JuniorDatabase, provider: string, input: {
7
+ conversationIds: string[];
8
+ providerId: string;
9
+ }): Promise<void>;
@@ -17,5 +17,15 @@ export declare function eventTaskBelongsToUser(task: EventTask, user: User): boo
17
17
  export declare function listEventTasksCreatedBy(db: JuniorDatabase, user: User, limit: number): Promise<EventTask[]>;
18
18
  /** List event tasks whose current Slack destination is public. */
19
19
  export declare function listPublicEventTasksForTeams(db: JuniorDatabase, teamIds: string[], limit: number): Promise<EventTask[]>;
20
+ /**
21
+ * Collect match keys from event tasks for these identifiers and event types.
22
+ * Does not evaluate match values — only reports keys that filters use.
23
+ */
24
+ export declare function collectEventTaskMatchKeys(db: JuniorDatabase, input: {
25
+ eventTypes: string[];
26
+ identifiers: string[];
27
+ namespace: string;
28
+ teamId: string;
29
+ }): Promise<string[]>;
20
30
  /** Find every task matching one normalized resource event. */
21
31
  export declare function findMatchingEventTasks(db: JuniorDatabase, event: ResourceEvent, teamId: string): Promise<EventTask[]>;
@@ -19,6 +19,7 @@ export declare const eventTaskToolResultSchema: z.ZodObject<{
19
19
  resourceType: z.ZodString;
20
20
  label: z.ZodString;
21
21
  events: z.ZodArray<z.ZodString>;
22
+ match: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
22
23
  credentialMode: z.ZodEnum<{
23
24
  system: "system";
24
25
  creator: "creator";
@@ -47,6 +48,7 @@ export declare const eventTaskListToolResultSchema: z.ZodObject<{
47
48
  resourceType: z.ZodString;
48
49
  label: z.ZodString;
49
50
  events: z.ZodArray<z.ZodString>;
51
+ match: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
50
52
  credentialMode: z.ZodEnum<{
51
53
  system: "system";
52
54
  creator: "creator";
@@ -73,13 +75,15 @@ export declare function registeredEventTaskTriggerSchema(catalog: ResourceEventC
73
75
  events: z.ZodArray<z.ZodString | z.ZodEnum<{
74
76
  [x: string]: string;
75
77
  }>>;
78
+ match: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodNumber, z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>]>>>;
76
79
  }, z.core.$strict>;
77
80
  /** Reject an event-task trigger that is no longer supported by the catalog. */
78
81
  export declare function requireSupportedEventTaskTrigger(catalog: ResourceEventCatalog, trigger: {
79
82
  events: string[];
83
+ match?: EventTask["trigger"]["match"];
80
84
  namespace: string;
81
85
  resourceType: string;
82
- }): void;
86
+ }): EventTask["trigger"]["match"] | undefined;
83
87
  /** Require the active Slack authority used for event-task management. */
84
88
  export declare function requireEventTaskSlackContext(context: ToolRuntimeContext): {
85
89
  actor: import("../actor").SlackActor;
@@ -121,6 +125,7 @@ export declare function compactEventTask(task: EventTask, catalog: ResourceEvent
121
125
  userName?: string | undefined;
122
126
  };
123
127
  triggerAvailable: boolean;
128
+ match?: Record<string, unknown> | undefined;
124
129
  };
125
130
  /** Return the standard successful event-task tool result. */
126
131
  export declare function eventTaskSuccess(task: EventTask, catalog: ResourceEventCatalog): {
@@ -139,5 +144,6 @@ export declare function eventTaskSuccess(task: EventTask, catalog: ResourceEvent
139
144
  userName?: string | undefined;
140
145
  };
141
146
  triggerAvailable: boolean;
147
+ match?: Record<string, unknown> | undefined;
142
148
  };
143
149
  };
@@ -35,6 +35,7 @@ export declare const eventTaskSchema: z.ZodObject<{
35
35
  trigger: z.ZodObject<{
36
36
  events: z.ZodArray<z.ZodString>;
37
37
  label: z.ZodString;
38
+ match: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodNumber, z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>]>>>;
38
39
  namespace: z.ZodString;
39
40
  identifier: z.ZodString;
40
41
  resourceType: z.ZodString;
@@ -3,7 +3,7 @@
3
3
  * Add new keys here as features graduate from private experiments; remove them
4
4
  * once they become stable defaults.
5
5
  */
6
- export declare const EXPERIMENTAL_FEATURES: readonly ["acp", "subagents"];
6
+ export declare const EXPERIMENTAL_FEATURES: readonly ["passive-routing", "subagents"];
7
7
  /** One known experimental feature name. */
8
8
  export type ExperimentalFeature = (typeof EXPERIMENTAL_FEATURES)[number];
9
9
  /** App-level opt-ins for unstable product features. */
@@ -1,6 +1,6 @@
1
1
  import type { SlackAdapter } from "@chat-adapter/slack";
2
2
  import { type StateAdapter } from "chat";
3
- import type { SlackTurnRuntime } from "@/chat/runtime/slack-runtime";
3
+ import type { SlackTurnRuntime } from "@/chat/providers/slack/runtime";
4
4
  import type { ConversationStore } from "@/chat/conversations/store";
5
5
  import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
6
6
  import type { UserTokenStore } from "@/chat/credentials/user-token-store";
@@ -61,6 +61,11 @@ export declare function getPluginTools(context: ToolRuntimeContext, sandbox?: Pl
61
61
  /** Collect route handlers exposed by plugins for app-level mounting. */
62
62
  export declare function getPluginRoutes(options: {
63
63
  resourceEvents: {
64
+ neededMatchKeys?(input: {
65
+ eventTypes: string[];
66
+ identifiers: string[];
67
+ namespace: string;
68
+ }): Promise<string[]>;
64
69
  publish(event: ResourceEvent): Promise<void>;
65
70
  };
66
71
  }): PluginRouteRegistration[];
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Slack event runtime.
2
+ * Slack provider runtime.
3
3
  *
4
4
  * This module owns inbound Slack routing decisions for mentions, subscribed
5
5
  * messages, assistant lifecycle events, and retryable turn pauses. It should
@@ -93,7 +93,7 @@ export interface SlackTurnRuntimeDependencies<TPreparedState> {
93
93
  thread: Thread;
94
94
  }) => Promise<void>;
95
95
  prepareTurnState: (args: PrepareTurnStateInput) => Promise<TPreparedState>;
96
- replyToThread: (thread: Thread, message: Message, options: {
96
+ executeSlackTurn: (thread: Thread, message: Message, options: {
97
97
  beforeFirstResponsePost?: () => Promise<void>;
98
98
  conversationId?: string;
99
99
  destination: Destination;
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Slack reply execution boundary.
2
+ * Add Slack provider behavior around one native agent Turn.
3
3
  *
4
- * This module bridges prepared Slack thread state into the agent runner
5
- * and commits the resulting Slack-visible delivery/state updates. It is where
6
- * queued messages, compaction, status updates, and Slack posting meet; agent
7
- * internals stay behind the runner seam.
4
+ * This module prepares Slack input and owns Slack status, delivery, and saved
5
+ * Slack state. Native execution concerns that remain here must move behind a
6
+ * provider-neutral runtime contract. Agent execution stays behind
7
+ * `AgentRunner`.
8
8
  */
9
9
  import type { Message, Thread } from "chat";
10
10
  import type { SlackAdapter } from "@chat-adapter/slack";
@@ -17,7 +17,7 @@ import { lookupSlackUser } from "@/chat/slack/user";
17
17
  import type { PausedTurnRequest } from "@/chat/task-execution/turn-wake";
18
18
  import type { ConversationTurnLifecycle } from "@/chat/conversations/turn-lifecycle";
19
19
  import type { DispatchTurnContext, DispatchTurnResult } from "@/chat/agent-dispatch/types";
20
- export interface ReplyExecutorServices {
20
+ export interface SlackTurnServices {
21
21
  agentRunner: AgentRunner;
22
22
  contextCompactor: ContextCompactor;
23
23
  getPausedTurnRequest: (args: {
@@ -32,7 +32,7 @@ export interface ReplyExecutorServices {
32
32
  sessionId: string;
33
33
  }) => Promise<void>;
34
34
  }
35
- interface ReplyExecutorDeps {
35
+ interface SlackTurnDeps {
36
36
  getSlackAdapter: () => SlackAdapter;
37
37
  resolveUserAttachments: (attachments: Message["attachments"] | undefined, context: {
38
38
  threadId?: string;
@@ -48,9 +48,10 @@ interface ReplyExecutorDeps {
48
48
  promptText?: string;
49
49
  }>>;
50
50
  prepareTurnState: (args: PrepareTurnStateInput) => Promise<PreparedTurnState>;
51
- services: ReplyExecutorServices;
51
+ services: SlackTurnServices;
52
52
  }
53
- export declare function createReplyToThread(deps: ReplyExecutorDeps): (thread: Thread, message: Message, options: {
53
+ /** Build the Slack caller that prepares input and delivers output for a Turn. */
54
+ export declare function createSlackTurn(deps: SlackTurnDeps): (thread: Thread, message: Message, options: {
54
55
  beforeFirstResponsePost?: () => Promise<void>;
55
56
  conversationId?: string;
56
57
  destination: Destination;
@@ -1,4 +1,4 @@
1
- import { type PluginResourceEvents } from "@sentry/junior-plugin-api";
1
+ import { type PluginResourceEvents, type ResourceEventMatch, type ResourceEventMatchFields } from "@sentry/junior-plugin-api";
2
2
  import { z } from "zod";
3
3
  type ResourceEventRegistration = Pick<PluginResourceEvents, "resourceTypes" | "normalizeIdentifier">;
4
4
  export type ResourceEventCatalog = Readonly<Record<string, ResourceEventRegistration>>;
@@ -18,6 +18,16 @@ export declare function registeredResourceTypeSchema(catalog: ResourceEventCatal
18
18
  export declare function pluginSupportsEvent(catalog: ResourceEventCatalog, namespace: string, resourceType: string, eventType: string): boolean;
19
19
  /** Return app guidance for one registered resource type and event type. */
20
20
  export declare function resourceEventGuidance(catalog: ResourceEventCatalog, namespace: string, resourceType: string, eventType: string): string | undefined;
21
+ /** Return declared match keys for one registered resource type. */
22
+ export declare function resourceEventMatchFields(catalog: ResourceEventCatalog, namespace: string, resourceType: string): ResourceEventMatchFields | undefined;
23
+ /** Build the match object the tools accept for one resource type. */
24
+ export declare function registeredResourceEventMatchSchema(): z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodNumber, z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>]>>>;
25
+ /** Reject match keys the resource type does not list. */
26
+ export declare function requireSupportedResourceEventMatch(catalog: ResourceEventCatalog, input: {
27
+ match?: ResourceEventMatch;
28
+ namespace: string;
29
+ resourceType: string;
30
+ }): ResourceEventMatch | undefined;
21
31
  /** Normalize one selector with the convention declared by its plugin. */
22
32
  export declare function normalizeEventIdentifier(catalog: ResourceEventCatalog, namespace: string, identifier: string): string;
23
33
  export {};
@@ -1,5 +1,5 @@
1
1
  import type { StateAdapter } from "chat";
2
- import { type Destination } from "@sentry/junior-plugin-api";
2
+ import { type Destination, 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;
@@ -17,6 +17,7 @@ declare const subscriptionSchema: z.ZodObject<{
17
17
  id: z.ZodString;
18
18
  intent: z.ZodString;
19
19
  label: z.ZodString;
20
+ match: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodNumber, z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>]>>>;
20
21
  namespace: z.ZodString;
21
22
  identifier: z.ZodString;
22
23
  resourceType: z.ZodString;
@@ -35,6 +36,7 @@ export interface CreateResourceEventSubscriptionInput {
35
36
  expiresAtMs: number;
36
37
  intent: string;
37
38
  label: string;
39
+ match?: ResourceEventMatch;
38
40
  namespace: string;
39
41
  identifier: string;
40
42
  resourceType: string;
@@ -63,8 +65,21 @@ export declare function cancelSubscriptions(input: {
63
65
  nowMs?: number;
64
66
  state?: StateAdapter;
65
67
  }): Promise<void>;
68
+ /**
69
+ * Collect match keys from active watches for these identifiers and event types.
70
+ * Does not evaluate match values — only reports keys that filters use.
71
+ */
72
+ export declare function collectResourceEventMatchKeys(input: {
73
+ eventTypes: string[];
74
+ identifiers: string[];
75
+ namespace: string;
76
+ nowMs?: number;
77
+ state?: StateAdapter;
78
+ teamId: string;
79
+ }): Promise<string[]>;
66
80
  /** Find active subscriptions interested in a normalized resource event. */
67
81
  export declare function findMatchingResourceEventSubscriptions(input: {
82
+ data?: ResourceEventData;
68
83
  eventType: string;
69
84
  nowMs?: number;
70
85
  namespace: string;
@@ -74,6 +89,7 @@ export declare function findMatchingResourceEventSubscriptions(input: {
74
89
  }): Promise<ResourceEventSubscription[]>;
75
90
  /** Recheck and deliver a matched subscription while holding its status lock. */
76
91
  export declare function deliverResourceEventSubscription(input: {
92
+ data?: ResourceEventData;
77
93
  deliver: (subscription: ResourceEventSubscription) => Promise<boolean>;
78
94
  eventType: string;
79
95
  nowMs?: number;
@@ -0,0 +1,30 @@
1
+ import type { AgentRun } from "@/chat/agent/types";
2
+ import type { CompleteConversationTurnInput, FailConversationTurnInput } from "@/chat/conversations/turn-lifecycle";
3
+ import type { AgentRunOutcome } from "@/chat/runtime/agent-run-outcome";
4
+ import type { AgentRunner } from "@/chat/runtime/agent-runner";
5
+ import type { AgentRunResult } from "@/chat/services/turn-result";
6
+ type SavedTurnResult = {
7
+ finishedAtMs?: number;
8
+ outcome: CompleteConversationTurnInput["outcome"];
9
+ } | {
10
+ finishedAtMs?: number;
11
+ failureCode: FailConversationTurnInput["failureCode"];
12
+ outcome: "failed";
13
+ };
14
+ type TurnExecutionOutcome = Exclude<AgentRunOutcome, {
15
+ status: "completed";
16
+ }> | {
17
+ status: "completed";
18
+ };
19
+ /** An error thrown while the agent advances a Run. */
20
+ export declare class AgentRunError extends Error {
21
+ constructor(cause: unknown);
22
+ }
23
+ /**
24
+ * Run the agent and finish the Turn after the caller saves its result.
25
+ *
26
+ * A paused Run, or a Run waiting for authorization, leaves the Turn open. A
27
+ * save error also leaves the Turn open so the worker can retry or recover it.
28
+ */
29
+ export declare function executeTurn(agentRunner: AgentRunner, run: AgentRun, saveResult: (result: AgentRunResult) => Promise<SavedTurnResult>): Promise<TurnExecutionOutcome>;
30
+ export {};
@@ -8,7 +8,8 @@ export declare enum SubscribedReplyReason {
8
8
  Classifier = "llm_classifier",
9
9
  SideConversation = "side_conversation",
10
10
  LowConfidence = "low_confidence",
11
- ClassifierError = "classifier_error"
11
+ ClassifierError = "classifier_error",
12
+ PassiveDisabled = "passive_disabled"
12
13
  }
13
14
  export interface SubscribedDecisionInput {
14
15
  rawText: string;
@@ -2,24 +2,22 @@ import { Message, ThreadImpl } from "chat";
2
2
  import type { SlackAdapter } from "@chat-adapter/slack";
3
3
  import type { DispatchTurnContext, DispatchTurnResult } from "@/chat/agent-dispatch/types";
4
4
  import type { DispatchRecord } from "@/chat/agent-dispatch/types";
5
- interface DispatchReplyToThread {
6
- (thread: ThreadImpl, message: Message, options: {
7
- ack?: () => Promise<void>;
8
- conversationId?: string;
9
- destination: DispatchRecord["destination"];
10
- execution: DispatchTurnContext;
11
- publishExternally?: boolean;
12
- onTurnDeliveryAccepted?: (messageId?: string) => void;
13
- onTurnOutcome?: (result: DispatchTurnResult) => void;
14
- shouldYield?: () => boolean;
15
- skipBackfill?: boolean;
16
- }): Promise<void>;
17
- }
5
+ type ExecuteSlackTurn = (thread: ThreadImpl, message: Message, options: {
6
+ ack?: () => Promise<void>;
7
+ conversationId?: string;
8
+ destination: DispatchRecord["destination"];
9
+ execution: DispatchTurnContext;
10
+ publishExternally?: boolean;
11
+ onTurnDeliveryAccepted?: (messageId?: string) => void;
12
+ onTurnOutcome?: (result: DispatchTurnResult) => void;
13
+ shouldYield?: () => boolean;
14
+ skipBackfill?: boolean;
15
+ }) => Promise<void>;
18
16
  /** Build the Slack provider adapter for agent-dispatched conversation turns. */
19
17
  export declare function createSlackDispatchTurnRunner(options: {
20
18
  getLocationConfiguration: (destination: DispatchRecord["destination"]) => DispatchTurnContext["locationConfiguration"];
21
19
  getSlackAdapter: () => SlackAdapter;
22
- replyToThread: DispatchReplyToThread;
20
+ executeSlackTurn: ExecuteSlackTurn;
23
21
  }): (dispatch: DispatchRecord, hooks: {
24
22
  ack: () => Promise<void>;
25
23
  shouldYield?: () => boolean;
@@ -1,7 +1,7 @@
1
1
  import type { SlackAdapter } from "@chat-adapter/slack";
2
2
  import { Message, ThreadImpl, type StateAdapter } from "chat";
3
3
  import { z } from "zod";
4
- import type { SlackTurnOptions } from "@/chat/runtime/slack-runtime";
4
+ import type { SlackTurnOptions } from "@/chat/providers/slack/runtime";
5
5
  import type { ConversationStore } from "@/chat/conversations/store";
6
6
  import type { InboundMessage } from "@/chat/task-execution/store";
7
7
  import type { ConversationWorkerContext, ConversationWorkerResult } from "@/chat/task-execution/worker";
@@ -12,6 +12,7 @@ export declare function createEventTaskTool(context: ToolRuntimeContext, catalog
12
12
  resourceType: string;
13
13
  label: string;
14
14
  events: string[];
15
+ match?: Record<string, string | number | boolean | (string | number)[]> | undefined;
15
16
  };
16
17
  title?: string | null | undefined;
17
18
  credentialMode?: "system" | "creator" | null | undefined;
@@ -32,6 +33,7 @@ export declare function createEventTaskTool(context: ToolRuntimeContext, catalog
32
33
  userName?: string | undefined;
33
34
  };
34
35
  triggerAvailable: boolean;
36
+ match?: Record<string, unknown> | undefined;
35
37
  };
36
38
  target?: string | undefined;
37
39
  truncated?: boolean | undefined;
@@ -56,6 +58,7 @@ export declare function createEventTaskTool(context: ToolRuntimeContext, catalog
56
58
  userName?: string | undefined;
57
59
  };
58
60
  triggerAvailable: boolean;
61
+ match?: Record<string, unknown> | undefined;
59
62
  };
60
63
  target?: string | undefined;
61
64
  truncated?: boolean | undefined;
@@ -23,6 +23,7 @@ export declare function createDeleteEventTaskTool(context: ToolRuntimeContext, c
23
23
  userName?: string | undefined;
24
24
  };
25
25
  triggerAvailable: boolean;
26
+ match?: Record<string, unknown> | undefined;
26
27
  };
27
28
  target?: string | undefined;
28
29
  truncated?: boolean | undefined;
@@ -47,6 +48,7 @@ export declare function createDeleteEventTaskTool(context: ToolRuntimeContext, c
47
48
  userName?: string | undefined;
48
49
  };
49
50
  triggerAvailable: boolean;
51
+ match?: Record<string, unknown> | undefined;
50
52
  };
51
53
  target?: string | undefined;
52
54
  truncated?: boolean | undefined;
@@ -21,6 +21,7 @@ export declare function createListEventTasksTool(context: ToolRuntimeContext, ca
21
21
  userName?: string | undefined;
22
22
  };
23
23
  triggerAvailable: boolean;
24
+ match?: Record<string, unknown> | undefined;
24
25
  }[];
25
26
  truncated: boolean;
26
27
  target?: string | undefined;
@@ -45,6 +46,7 @@ export declare function createListEventTasksTool(context: ToolRuntimeContext, ca
45
46
  userName?: string | undefined;
46
47
  };
47
48
  triggerAvailable: boolean;
49
+ match?: Record<string, unknown> | undefined;
48
50
  }[];
49
51
  truncated: boolean;
50
52
  target?: string | undefined;
@@ -14,6 +14,7 @@ export declare function createListResourceEventSubscriptionsTool(context: ToolRu
14
14
  events: string[];
15
15
  intent: string;
16
16
  expiresAtMs: number;
17
+ match?: Record<string, unknown> | undefined;
17
18
  }[];
18
19
  target?: string | undefined;
19
20
  truncated?: boolean | undefined;
@@ -32,6 +33,7 @@ export declare function createListResourceEventSubscriptionsTool(context: ToolRu
32
33
  events: string[];
33
34
  intent: string;
34
35
  expiresAtMs: number;
36
+ match?: Record<string, unknown> | undefined;
35
37
  }[];
36
38
  target?: string | undefined;
37
39
  truncated?: boolean | undefined;
@@ -17,6 +17,11 @@ export declare function createSearchResourceEventTypesTool(catalog: ResourceEven
17
17
  type: string;
18
18
  supportedEvents: string[];
19
19
  suggestedEvents?: string[] | undefined;
20
+ matchFields?: Record<string, {
21
+ kind: "string" | "number" | "boolean";
22
+ description: string;
23
+ enum?: string[] | undefined;
24
+ }> | undefined;
20
25
  }[];
21
26
  target?: string | undefined;
22
27
  truncated?: boolean | undefined;
@@ -34,6 +39,11 @@ export declare function createSearchResourceEventTypesTool(catalog: ResourceEven
34
39
  type: string;
35
40
  supportedEvents: string[];
36
41
  suggestedEvents?: string[] | undefined;
42
+ matchFields?: Record<string, {
43
+ kind: "string" | "number" | "boolean";
44
+ description: string;
45
+ enum?: string[] | undefined;
46
+ }> | undefined;
37
47
  }[];
38
48
  target?: string | undefined;
39
49
  truncated?: boolean | undefined;
@@ -13,6 +13,7 @@ export declare function createUpdateEventTaskTool(context: ToolRuntimeContext, c
13
13
  resourceType: string;
14
14
  label: string;
15
15
  events: string[];
16
+ match?: Record<string, string | number | boolean | (string | number)[]> | undefined;
16
17
  } | null | undefined;
17
18
  credentialMode?: "system" | "creator" | null | undefined;
18
19
  };
@@ -32,6 +33,7 @@ export declare function createUpdateEventTaskTool(context: ToolRuntimeContext, c
32
33
  userName?: string | undefined;
33
34
  };
34
35
  triggerAvailable: boolean;
36
+ match?: Record<string, unknown> | undefined;
35
37
  };
36
38
  target?: string | undefined;
37
39
  truncated?: boolean | undefined;
@@ -56,6 +58,7 @@ export declare function createUpdateEventTaskTool(context: ToolRuntimeContext, c
56
58
  userName?: string | undefined;
57
59
  };
58
60
  triggerAvailable: boolean;
61
+ match?: Record<string, unknown> | undefined;
59
62
  };
60
63
  target?: string | undefined;
61
64
  truncated?: boolean | undefined;