@sentry/junior 0.72.0 → 0.74.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 (109) hide show
  1. package/bin/junior.mjs +12 -10
  2. package/dist/api-reference.d.ts +1 -1
  3. package/dist/app.d.ts +11 -2
  4. package/dist/app.js +1233 -13143
  5. package/dist/chat/agent-dispatch/runner.d.ts +2 -0
  6. package/dist/chat/agent-dispatch/store.d.ts +2 -2
  7. package/dist/chat/agent-dispatch/types.d.ts +6 -3
  8. package/dist/chat/agent-dispatch/validation.d.ts +2 -3
  9. package/dist/chat/app/production.d.ts +11 -1
  10. package/dist/chat/app/services.d.ts +7 -0
  11. package/dist/chat/config.d.ts +3 -0
  12. package/dist/chat/conversations/configured.d.ts +5 -0
  13. package/dist/chat/conversations/sql/migrations.d.ts +11 -0
  14. package/dist/chat/conversations/sql/schema/conversations.d.ts +435 -0
  15. package/dist/chat/conversations/sql/schema/destinations.d.ts +200 -0
  16. package/dist/chat/conversations/sql/schema/identities.d.ts +214 -0
  17. package/dist/chat/conversations/sql/schema/migrations.d.ts +58 -0
  18. package/dist/chat/conversations/sql/schema/timestamps.d.ts +1 -0
  19. package/dist/chat/conversations/sql/schema.d.ts +910 -0
  20. package/dist/chat/conversations/sql/store.d.ts +52 -0
  21. package/dist/chat/conversations/state.d.ts +4 -0
  22. package/dist/chat/conversations/store.d.ts +57 -0
  23. package/dist/chat/destination.d.ts +3 -1
  24. package/dist/chat/ingress/slack-webhook.d.ts +2 -0
  25. package/dist/chat/logging.d.ts +3 -0
  26. package/dist/chat/oauth-flow.d.ts +1 -1
  27. package/dist/chat/plugins/agent-hooks.d.ts +2 -2
  28. package/dist/chat/plugins/registry.d.ts +2 -0
  29. package/dist/chat/plugins/types.d.ts +2 -0
  30. package/dist/chat/prompt.d.ts +4 -1
  31. package/dist/chat/requester.d.ts +19 -12
  32. package/dist/chat/respond.d.ts +7 -3
  33. package/dist/chat/runtime/agent-continue-runner.d.ts +1 -1
  34. package/dist/chat/runtime/reply-executor.d.ts +3 -1
  35. package/dist/chat/runtime/slack-resume.d.ts +3 -3
  36. package/dist/chat/runtime/slack-runtime.d.ts +13 -3
  37. package/dist/chat/runtime/turn.d.ts +15 -1
  38. package/dist/chat/sandbox/egress-credentials.d.ts +5 -2
  39. package/dist/chat/sandbox/egress-policy.d.ts +5 -1
  40. package/dist/chat/sandbox/egress-proxy.d.ts +2 -0
  41. package/dist/chat/sandbox/egress-schemas.d.ts +4 -0
  42. package/dist/chat/sandbox/egress-session.d.ts +3 -1
  43. package/dist/chat/sandbox/egress-tracing.d.ts +7 -0
  44. package/dist/chat/sandbox/sandbox.d.ts +2 -0
  45. package/dist/chat/sandbox/session.d.ts +3 -2
  46. package/dist/chat/services/auth-pause-response.d.ts +1 -1
  47. package/dist/chat/services/auth-pause.d.ts +2 -1
  48. package/dist/chat/services/mcp-auth-orchestration.d.ts +7 -6
  49. package/dist/chat/services/message-actor-identity.d.ts +2 -2
  50. package/dist/chat/services/pending-auth.d.ts +2 -0
  51. package/dist/chat/services/plugin-auth-orchestration.d.ts +14 -12
  52. package/dist/chat/services/turn-result.d.ts +3 -0
  53. package/dist/chat/slack/user.d.ts +2 -2
  54. package/dist/chat/sql/db.d.ts +20 -0
  55. package/dist/chat/sql/neon.d.ts +9 -0
  56. package/dist/chat/sql/schema.d.ts +906 -0
  57. package/dist/chat/state/turn-session.d.ts +3 -0
  58. package/dist/chat/task-execution/slack-work.d.ts +2 -0
  59. package/dist/chat/task-execution/state.d.ts +209 -0
  60. package/dist/chat/task-execution/store.d.ts +30 -114
  61. package/dist/chat/task-execution/vercel-callback.d.ts +2 -0
  62. package/dist/chat/task-execution/worker.d.ts +2 -0
  63. package/dist/chat/tools/slack/canvas-tools.d.ts +3 -2
  64. package/dist/chat/tools/slack/channel-list-messages.d.ts +2 -2
  65. package/dist/chat/tools/slack/channel-post-message.d.ts +3 -2
  66. package/dist/chat/tools/slack/context.d.ts +15 -2
  67. package/dist/chat/tools/slack/message-add-reaction.d.ts +3 -2
  68. package/dist/chat/tools/slack/thread-read.d.ts +2 -2
  69. package/dist/chat/tools/types.d.ts +19 -19
  70. package/dist/chunk-2LUZA3LY.js +275 -0
  71. package/dist/{chunk-6GEYPE6T.js → chunk-3BYAPS6B.js} +30 -6
  72. package/dist/{chunk-VLIO6RQR.js → chunk-6UP2Z2RZ.js} +4 -4
  73. package/dist/{chunk-GB3AL54K.js → chunk-7Q5YOUUT.js} +10 -2
  74. package/dist/{chunk-PP7AGSBU.js → chunk-CYUI7JU5.js} +18 -8
  75. package/dist/{chunk-3FYPXHPL.js → chunk-F6HWCPOC.js} +1 -1
  76. package/dist/{chunk-ZJQPA67D.js → chunk-GM7HTXYC.js} +230 -224
  77. package/dist/{chunk-VSNA5KAB.js → chunk-HYHKTFG2.js} +1338 -1499
  78. package/dist/chunk-JL2SLRAT.js +1970 -0
  79. package/dist/{chunk-4JXCSGSA.js → chunk-M4FLLXXD.js} +1 -1
  80. package/dist/{chunk-55XEZFGD.js → chunk-OR6NQJ5E.js} +2 -2
  81. package/dist/chunk-SJHUF3DP.js +43 -0
  82. package/dist/chunk-SQGMG7OD.js +12801 -0
  83. package/dist/{chunk-QUXPUKBH.js → chunk-Y7X25LFY.js} +1 -1
  84. package/dist/{chunk-ICKIDP7G.js → chunk-YOHFWWBV.js} +1 -1
  85. package/dist/{chunk-XC33FJZN.js → chunk-YRDS7VKO.js} +25 -4
  86. package/dist/cli/chat.js +205 -0
  87. package/dist/cli/check.js +9 -10
  88. package/dist/cli/init.js +1 -1
  89. package/dist/cli/run.js +10 -2
  90. package/dist/cli/snapshot-warmup.js +7 -7
  91. package/dist/cli/upgrade.js +81 -11
  92. package/dist/deployment.d.ts +4 -0
  93. package/dist/handlers/agent-dispatch.d.ts +6 -1
  94. package/dist/handlers/mcp-oauth-callback.d.ts +6 -1
  95. package/dist/handlers/oauth-callback.d.ts +6 -1
  96. package/dist/handlers/sandbox-egress-proxy.d.ts +2 -0
  97. package/dist/handlers/webhooks.d.ts +4 -2
  98. package/dist/instrumentation.js +17 -3
  99. package/dist/nitro.js +9 -10
  100. package/dist/reporting/conversations.d.ts +13 -3
  101. package/dist/reporting.d.ts +9 -2
  102. package/dist/reporting.js +114 -48
  103. package/dist/runner-27NP2TEO.js +259 -0
  104. package/dist/vercel.d.ts +6 -1
  105. package/dist/vercel.js +1 -1
  106. package/package.json +9 -4
  107. package/dist/chunk-6YY4Q3D4.js +0 -12
  108. package/dist/chunk-HNMUVGSR.js +0 -1119
  109. package/dist/chunk-Z3YD6NHK.js +0 -12
@@ -2,6 +2,7 @@ import type { Destination } from "@sentry/junior-plugin-api";
2
2
  import type { PiMessage } from "@/chat/pi/messages";
3
3
  import { type StoredSlackRequester } from "@/chat/requester";
4
4
  import type { AgentTurnUsage } from "@/chat/usage";
5
+ import type { ConversationStore } from "@/chat/conversations/store";
5
6
  export type AgentTurnSessionStatus = "running" | "awaiting_resume" | "completed" | "failed" | "abandoned";
6
7
  export type AgentTurnSurface = "slack" | "api" | "scheduler" | "internal";
7
8
  export type AgentTurnResumeReason = "timeout" | "auth" | "yield";
@@ -40,6 +41,7 @@ export declare function upsertAgentTurnSessionRecord(args: {
40
41
  destination?: Destination;
41
42
  lastProgressAtMs?: number;
42
43
  loadedSkillNames?: string[];
44
+ conversationStore?: ConversationStore;
43
45
  sessionId: string;
44
46
  sliceId: number;
45
47
  state: AgentTurnSessionStatus;
@@ -62,6 +64,7 @@ export declare function recordAgentTurnSessionSummary(args: {
62
64
  destination?: Destination;
63
65
  lastProgressAtMs?: number;
64
66
  loadedSkillNames?: string[];
67
+ conversationStore?: ConversationStore;
65
68
  requester?: StoredSlackRequester;
66
69
  resumeReason?: AgentTurnResumeReason;
67
70
  sessionId: string;
@@ -1,6 +1,7 @@
1
1
  import type { SlackAdapter } from "@chat-adapter/slack";
2
2
  import { Message, ThreadImpl, type SerializedMessage, type SerializedThread, type StateAdapter } from "chat";
3
3
  import type { SlackTurnRuntime } from "@/chat/runtime/slack-runtime";
4
+ import type { ConversationStore } from "@/chat/conversations/store";
4
5
  import type { InboundMessage } from "@/chat/task-execution/store";
5
6
  import type { ConversationWorkerContext, ConversationWorkerResult } from "@/chat/task-execution/worker";
6
7
  import { type SlackInstallationContext } from "@/chat/slack/adapter-context";
@@ -18,6 +19,7 @@ export interface CreateSlackConversationWorkerOptions {
18
19
  getSlackAdapter: () => SlackAdapter;
19
20
  lookupSlackUser?: (teamId: string, userId: string) => Promise<SlackRequesterProfile | null | undefined>;
20
21
  resumeAwaitingContinuation: (conversationId: string) => Promise<boolean>;
22
+ conversationStore?: ConversationStore;
21
23
  runtime: Pick<SlackTurnRuntime<unknown>, "handleNewMention" | "handleSubscribedMessage">;
22
24
  state?: StateAdapter;
23
25
  }
@@ -0,0 +1,209 @@
1
+ import type { StateAdapter } from "chat";
2
+ import type { Destination } from "@sentry/junior-plugin-api";
3
+ import { type StoredSlackRequester } from "@/chat/requester";
4
+ export declare const CONVERSATION_BY_ACTIVITY_INDEX_KEY = "junior:conversation:by-activity";
5
+ export declare const CONVERSATION_ACTIVE_INDEX_KEY = "junior:conversation:active";
6
+ export declare const CONVERSATION_WORK_LEASE_TTL_MS = 90000;
7
+ export declare const CONVERSATION_WORK_CHECK_IN_INTERVAL_MS = 15000;
8
+ export declare const CONVERSATION_WORK_STALE_ENQUEUE_MS = 60000;
9
+ export type Source = "api" | "internal" | "local" | "plugin" | "scheduler" | "slack";
10
+ export type ExecutionStatus = "awaiting_resume" | "idle" | "pending" | "running";
11
+ export interface AgentInput {
12
+ attachments?: unknown[];
13
+ authorId?: string;
14
+ metadata?: Record<string, unknown>;
15
+ text: string;
16
+ }
17
+ export interface InboundMessage {
18
+ conversationId: string;
19
+ createdAtMs: number;
20
+ destination: Destination;
21
+ inboundMessageId: string;
22
+ injectedAtMs?: number;
23
+ input: AgentInput;
24
+ receivedAtMs: number;
25
+ source: Source;
26
+ }
27
+ export interface Lease {
28
+ acquiredAtMs: number;
29
+ expiresAtMs: number;
30
+ lastCheckInAtMs: number;
31
+ token: string;
32
+ }
33
+ export interface ConversationExecution {
34
+ inboundMessageIds: string[];
35
+ lastCheckpointAtMs?: number;
36
+ lastEnqueuedAtMs?: number;
37
+ lease?: Lease;
38
+ pendingCount: number;
39
+ pendingMessages: InboundMessage[];
40
+ runId?: string;
41
+ status: ExecutionStatus;
42
+ updatedAtMs?: number;
43
+ }
44
+ export interface Conversation {
45
+ channelName?: string;
46
+ conversationId: string;
47
+ createdAtMs: number;
48
+ destination?: Destination;
49
+ execution: ConversationExecution;
50
+ lastActivityAtMs: number;
51
+ requester?: StoredSlackRequester;
52
+ schemaVersion: 1;
53
+ source?: Source;
54
+ title?: string;
55
+ updatedAtMs: number;
56
+ }
57
+ export interface ConversationWorkLease {
58
+ acquiredAtMs: number;
59
+ lastCheckInAtMs: number;
60
+ leaseExpiresAtMs: number;
61
+ leaseToken: string;
62
+ }
63
+ export interface ConversationWorkState extends Conversation {
64
+ lastEnqueuedAtMs?: number;
65
+ lease?: ConversationWorkLease;
66
+ messages: InboundMessage[];
67
+ needsRun: boolean;
68
+ }
69
+ export interface StartConversationWorkAcquired {
70
+ leaseExpiresAtMs: number;
71
+ leaseToken: string;
72
+ status: "acquired";
73
+ }
74
+ export interface StartConversationWorkActive {
75
+ leaseExpiresAtMs: number;
76
+ status: "active";
77
+ }
78
+ export interface StartConversationWorkNoWork {
79
+ status: "no_work";
80
+ }
81
+ export type StartConversationWorkResult = StartConversationWorkAcquired | StartConversationWorkActive | StartConversationWorkNoWork;
82
+ export interface AppendInboundMessageResult {
83
+ status: "appended" | "duplicate";
84
+ }
85
+ export interface AppendAndEnqueueInboundMessageResult extends AppendInboundMessageResult {
86
+ queueMessageId?: string;
87
+ }
88
+ export interface RequestConversationWorkResult {
89
+ status: "created" | "updated";
90
+ }
91
+ /** Return a persisted conversation record, if one exists. */
92
+ export declare function getConversation(args: {
93
+ conversationId: string;
94
+ state?: StateAdapter;
95
+ }): Promise<Conversation | undefined>;
96
+ /** Return a persisted conversation work record, if one exists. */
97
+ export declare function getConversationWorkState(args: {
98
+ conversationId: string;
99
+ state?: StateAdapter;
100
+ }): Promise<ConversationWorkState | undefined>;
101
+ /** Count mailbox messages that have not yet reached the session log. */
102
+ export declare function countPendingConversationMessages(conversation: Conversation): number;
103
+ /** Return whether a conversation has pending or resumable execution work. */
104
+ export declare function hasRunnableConversationWork(conversation: Conversation): boolean;
105
+ /** Persist one inbound message idempotently in its conversation mailbox. */
106
+ export declare function appendInboundMessage(args: {
107
+ message: InboundMessage;
108
+ nowMs?: number;
109
+ state?: StateAdapter;
110
+ }): Promise<AppendInboundMessageResult>;
111
+ /** Mark a conversation runnable when there is no new mailbox message. */
112
+ export declare function requestConversationWork(args: {
113
+ conversationId: string;
114
+ destination: Destination;
115
+ nowMs?: number;
116
+ state?: StateAdapter;
117
+ }): Promise<RequestConversationWorkResult>;
118
+ /** Record visible conversation activity without making the conversation runnable. */
119
+ export declare function recordConversationActivity(args: {
120
+ activityAtMs?: number;
121
+ channelName?: string;
122
+ conversationId: string;
123
+ destination?: Destination;
124
+ nowMs?: number;
125
+ requester?: StoredSlackRequester;
126
+ source?: Source;
127
+ state?: StateAdapter;
128
+ title?: string;
129
+ }): Promise<void>;
130
+ /** Record that a wake-up nudge was accepted for the conversation. */
131
+ export declare function markConversationWorkEnqueued(args: {
132
+ conversationId: string;
133
+ nowMs?: number;
134
+ state?: StateAdapter;
135
+ }): Promise<void>;
136
+ /** Try to acquire the durable execution lease for one conversation. */
137
+ export declare function startConversationWork(args: {
138
+ conversationId: string;
139
+ nowMs?: number;
140
+ state?: StateAdapter;
141
+ }): Promise<StartConversationWorkResult>;
142
+ /** Extend the durable execution lease when the worker checks in. */
143
+ export declare function checkInConversationWork(args: {
144
+ conversationId: string;
145
+ leaseToken: string;
146
+ nowMs?: number;
147
+ state?: StateAdapter;
148
+ }): Promise<boolean>;
149
+ /** Drain pending mailbox entries after the caller has durably injected them. */
150
+ export declare function drainConversationMailbox(args: {
151
+ conversationId: string;
152
+ inject: (messages: InboundMessage[]) => Promise<void>;
153
+ leaseToken: string;
154
+ nowMs?: number;
155
+ state?: StateAdapter;
156
+ }): Promise<InboundMessage[]>;
157
+ /** Mark selected leased mailbox entries after their session-log injection succeeds. */
158
+ export declare function markConversationMessagesInjected(args: {
159
+ conversationId: string;
160
+ inboundMessageIds: string[];
161
+ leaseToken: string;
162
+ nowMs?: number;
163
+ state?: StateAdapter;
164
+ }): Promise<boolean>;
165
+ /** Mark the leased conversation as needing another queue-delivered slice. */
166
+ export declare function requestConversationContinuation(args: {
167
+ conversationId: string;
168
+ destination: Destination;
169
+ leaseToken: string;
170
+ nowMs?: number;
171
+ state?: StateAdapter;
172
+ }): Promise<boolean>;
173
+ /** Release the durable execution lease without changing completion state. */
174
+ export declare function releaseConversationWork(args: {
175
+ conversationId: string;
176
+ leaseToken: string;
177
+ nowMs?: number;
178
+ state?: StateAdapter;
179
+ }): Promise<boolean>;
180
+ /** Finish a leased conversation and report whether runnable work remains. */
181
+ export declare function completeConversationWork(args: {
182
+ conversationId: string;
183
+ leaseToken: string;
184
+ nowMs?: number;
185
+ state?: StateAdapter;
186
+ }): Promise<"completed" | "lost_lease" | "pending">;
187
+ /** Clear an expired durable lease so a later worker can resume safely. */
188
+ export declare function clearExpiredConversationLease(args: {
189
+ conversationId: string;
190
+ nowMs?: number;
191
+ state?: StateAdapter;
192
+ }): Promise<boolean>;
193
+ /** Remove one conversation from the active index after it is missing or idle. */
194
+ export declare function removeActiveConversation(args: {
195
+ conversationId: string;
196
+ state?: StateAdapter;
197
+ }): Promise<void>;
198
+ /** List active conversation ids by oldest execution update first. */
199
+ export declare function listActiveConversationIds(args?: {
200
+ limit?: number;
201
+ staleBeforeMs?: number;
202
+ state?: StateAdapter;
203
+ }): Promise<string[]>;
204
+ /** List retained conversations by newest visible activity first. */
205
+ export declare function listConversationsByActivity(args?: {
206
+ limit?: number;
207
+ offset?: number;
208
+ state?: StateAdapter;
209
+ }): Promise<Conversation[]>;
@@ -1,104 +1,19 @@
1
1
  import type { StateAdapter } from "chat";
2
- import type { Destination } from "@sentry/junior-plugin-api";
3
- import { type StoredSlackRequester } from "@/chat/requester";
2
+ import type { ConversationStore } from "@/chat/conversations/store";
4
3
  import type { ConversationWorkQueue } from "./queue";
5
- export declare const CONVERSATION_BY_ACTIVITY_INDEX_KEY = "junior:conversation:by-activity";
6
- export declare const CONVERSATION_ACTIVE_INDEX_KEY = "junior:conversation:active";
7
- export declare const CONVERSATION_WORK_LEASE_TTL_MS = 90000;
8
- export declare const CONVERSATION_WORK_CHECK_IN_INTERVAL_MS = 15000;
9
- export declare const CONVERSATION_WORK_STALE_ENQUEUE_MS = 60000;
10
- export type Source = "api" | "internal" | "plugin" | "scheduler" | "slack";
11
- export type ExecutionStatus = "awaiting_resume" | "idle" | "pending" | "running";
12
- export interface AgentInput {
13
- attachments?: unknown[];
14
- authorId?: string;
15
- metadata?: Record<string, unknown>;
16
- text: string;
17
- }
18
- export interface InboundMessage {
19
- conversationId: string;
20
- createdAtMs: number;
21
- destination: Destination;
22
- inboundMessageId: string;
23
- injectedAtMs?: number;
24
- input: AgentInput;
25
- receivedAtMs: number;
26
- source: Source;
27
- }
28
- export interface Lease {
29
- acquiredAtMs: number;
30
- expiresAtMs: number;
31
- lastCheckInAtMs: number;
32
- token: string;
33
- }
34
- export interface ConversationExecution {
35
- inboundMessageIds: string[];
36
- lastCheckpointAtMs?: number;
37
- lastEnqueuedAtMs?: number;
38
- lease?: Lease;
39
- pendingCount: number;
40
- pendingMessages: InboundMessage[];
41
- runId?: string;
42
- status: ExecutionStatus;
43
- updatedAtMs?: number;
44
- }
45
- export interface Conversation {
46
- channelName?: string;
47
- conversationId: string;
48
- createdAtMs: number;
49
- destination?: Destination;
50
- execution: ConversationExecution;
51
- lastActivityAtMs: number;
52
- requester?: StoredSlackRequester;
53
- schemaVersion: 1;
54
- source?: Source;
55
- title?: string;
56
- updatedAtMs: number;
57
- }
58
- export interface ConversationWorkLease {
59
- acquiredAtMs: number;
60
- lastCheckInAtMs: number;
61
- leaseExpiresAtMs: number;
62
- leaseToken: string;
63
- }
64
- export interface ConversationWorkState extends Conversation {
65
- lastEnqueuedAtMs?: number;
66
- lease?: ConversationWorkLease;
67
- messages: InboundMessage[];
68
- needsRun: boolean;
69
- }
70
- export interface StartConversationWorkAcquired {
71
- leaseExpiresAtMs: number;
72
- leaseToken: string;
73
- status: "acquired";
74
- }
75
- export interface StartConversationWorkActive {
76
- leaseExpiresAtMs: number;
77
- status: "active";
78
- }
79
- export interface StartConversationWorkNoWork {
80
- status: "no_work";
81
- }
82
- export type StartConversationWorkResult = StartConversationWorkAcquired | StartConversationWorkActive | StartConversationWorkNoWork;
83
- export interface AppendInboundMessageResult {
84
- status: "appended" | "duplicate";
85
- }
86
- export interface AppendAndEnqueueInboundMessageResult extends AppendInboundMessageResult {
87
- queueMessageId?: string;
88
- }
89
- export interface RequestConversationWorkResult {
90
- status: "created" | "updated";
91
- }
4
+ import * as workState from "./state";
5
+ export { CONVERSATION_ACTIVE_INDEX_KEY, CONVERSATION_BY_ACTIVITY_INDEX_KEY, CONVERSATION_WORK_CHECK_IN_INTERVAL_MS, CONVERSATION_WORK_LEASE_TTL_MS, CONVERSATION_WORK_STALE_ENQUEUE_MS, type AgentInput, type AppendAndEnqueueInboundMessageResult, type AppendInboundMessageResult, type Conversation, type ConversationExecution, type ConversationWorkLease, type ConversationWorkState, type ExecutionStatus, type InboundMessage, type Lease, type RequestConversationWorkResult, type Source, type StartConversationWorkAcquired, type StartConversationWorkActive, type StartConversationWorkNoWork, type StartConversationWorkResult, } from "@/chat/task-execution/state";
6
+ import type { AppendAndEnqueueInboundMessageResult, Conversation, InboundMessage } from "@/chat/task-execution/state";
92
7
  /** Return a persisted conversation record, if one exists. */
93
8
  export declare function getConversation(args: {
94
9
  conversationId: string;
95
10
  state?: StateAdapter;
96
- }): Promise<Conversation | undefined>;
97
- /** Return a persisted conversation record, if one exists. */
11
+ }): Promise<workState.Conversation | undefined>;
12
+ /** Return a persisted conversation work record, if one exists. */
98
13
  export declare function getConversationWorkState(args: {
99
14
  conversationId: string;
100
15
  state?: StateAdapter;
101
- }): Promise<ConversationWorkState | undefined>;
16
+ }): Promise<workState.ConversationWorkState | undefined>;
102
17
  /** Count mailbox messages that have not yet reached the session log. */
103
18
  export declare function countPendingConversationMessages(conversation: Conversation): number;
104
19
  /** Return whether a conversation has pending or resumable execution work. */
@@ -106,12 +21,14 @@ export declare function hasRunnableConversationWork(conversation: Conversation):
106
21
  /** Persist one inbound message idempotently in its conversation mailbox. */
107
22
  export declare function appendInboundMessage(args: {
108
23
  message: InboundMessage;
24
+ conversationStore?: ConversationStore;
109
25
  nowMs?: number;
110
26
  state?: StateAdapter;
111
- }): Promise<AppendInboundMessageResult>;
27
+ }): Promise<workState.AppendInboundMessageResult>;
112
28
  /** Persist inbound work and send the queue nudge that wakes a worker. */
113
29
  export declare function appendAndEnqueueInboundMessage(args: {
114
30
  message: InboundMessage;
31
+ conversationStore?: ConversationStore;
115
32
  nowMs?: number;
116
33
  queue: ConversationWorkQueue;
117
34
  state?: StateAdapter;
@@ -119,62 +36,58 @@ export declare function appendAndEnqueueInboundMessage(args: {
119
36
  /** Mark a conversation runnable when there is no new mailbox message. */
120
37
  export declare function requestConversationWork(args: {
121
38
  conversationId: string;
122
- destination: Destination;
39
+ destination: InboundMessage["destination"];
40
+ conversationStore?: ConversationStore;
123
41
  nowMs?: number;
124
42
  state?: StateAdapter;
125
- }): Promise<RequestConversationWorkResult>;
43
+ }): Promise<workState.RequestConversationWorkResult>;
126
44
  /** Record visible conversation activity without making the conversation runnable. */
127
- export declare function recordConversationActivity(args: {
128
- activityAtMs?: number;
129
- channelName?: string;
130
- conversationId: string;
131
- destination?: Destination;
132
- nowMs?: number;
133
- requester?: StoredSlackRequester;
134
- source?: Source;
45
+ export declare function recordConversationActivity(args: Parameters<ConversationStore["recordActivity"]>[0] & {
46
+ conversationStore?: ConversationStore;
135
47
  state?: StateAdapter;
136
- title?: string;
137
48
  }): Promise<void>;
138
49
  /** Record that a wake-up nudge was accepted for the conversation. */
139
50
  export declare function markConversationWorkEnqueued(args: {
140
51
  conversationId: string;
52
+ conversationStore?: ConversationStore;
141
53
  nowMs?: number;
142
54
  state?: StateAdapter;
143
55
  }): Promise<void>;
144
56
  /** Try to acquire the durable execution lease for one conversation. */
145
57
  export declare function startConversationWork(args: {
146
58
  conversationId: string;
59
+ conversationStore?: ConversationStore;
147
60
  nowMs?: number;
148
61
  state?: StateAdapter;
149
- }): Promise<StartConversationWorkResult>;
62
+ }): Promise<workState.StartConversationWorkResult>;
150
63
  /** Extend the durable execution lease when the worker checks in. */
151
64
  export declare function checkInConversationWork(args: {
152
65
  conversationId: string;
153
66
  leaseToken: string;
67
+ conversationStore?: ConversationStore;
154
68
  nowMs?: number;
155
69
  state?: StateAdapter;
156
70
  }): Promise<boolean>;
157
71
  /** Drain pending mailbox entries after the caller has durably injected them. */
158
- export declare function drainConversationMailbox(args: {
159
- conversationId: string;
160
- inject: (messages: InboundMessage[]) => Promise<void>;
161
- leaseToken: string;
162
- nowMs?: number;
72
+ export declare function drainConversationMailbox(args: Parameters<typeof workState.drainConversationMailbox>[0] & {
73
+ conversationStore?: ConversationStore;
163
74
  state?: StateAdapter;
164
- }): Promise<InboundMessage[]>;
75
+ }): Promise<workState.InboundMessage[]>;
165
76
  /** Mark selected leased mailbox entries after their session-log injection succeeds. */
166
77
  export declare function markConversationMessagesInjected(args: {
167
78
  conversationId: string;
168
79
  inboundMessageIds: string[];
169
80
  leaseToken: string;
81
+ conversationStore?: ConversationStore;
170
82
  nowMs?: number;
171
83
  state?: StateAdapter;
172
84
  }): Promise<boolean>;
173
85
  /** Mark the leased conversation as needing another queue-delivered slice. */
174
86
  export declare function requestConversationContinuation(args: {
175
87
  conversationId: string;
176
- destination: Destination;
88
+ destination: InboundMessage["destination"];
177
89
  leaseToken: string;
90
+ conversationStore?: ConversationStore;
178
91
  nowMs?: number;
179
92
  state?: StateAdapter;
180
93
  }): Promise<boolean>;
@@ -182,6 +95,7 @@ export declare function requestConversationContinuation(args: {
182
95
  export declare function releaseConversationWork(args: {
183
96
  conversationId: string;
184
97
  leaseToken: string;
98
+ conversationStore?: ConversationStore;
185
99
  nowMs?: number;
186
100
  state?: StateAdapter;
187
101
  }): Promise<boolean>;
@@ -189,12 +103,14 @@ export declare function releaseConversationWork(args: {
189
103
  export declare function completeConversationWork(args: {
190
104
  conversationId: string;
191
105
  leaseToken: string;
106
+ conversationStore?: ConversationStore;
192
107
  nowMs?: number;
193
108
  state?: StateAdapter;
194
- }): Promise<"completed" | "lost_lease" | "pending">;
109
+ }): Promise<"pending" | "completed" | "lost_lease">;
195
110
  /** Clear an expired durable lease so a later worker can resume safely. */
196
111
  export declare function clearExpiredConversationLease(args: {
197
112
  conversationId: string;
113
+ conversationStore?: ConversationStore;
198
114
  nowMs?: number;
199
115
  state?: StateAdapter;
200
116
  }): Promise<boolean>;
@@ -213,4 +129,4 @@ export declare function listActiveConversationIds(args?: {
213
129
  export declare function listConversationsByActivity(args?: {
214
130
  limit?: number;
215
131
  state?: StateAdapter;
216
- }): Promise<Conversation[]>;
132
+ }): Promise<workState.Conversation[]>;
@@ -1,10 +1,12 @@
1
1
  import type { StateAdapter } from "chat";
2
+ import type { ConversationStore } from "@/chat/conversations/store";
2
3
  import { type ConversationWorkQueue } from "./queue";
3
4
  import { type ConversationWorkProcessResult, type ConversationWorkerResult, type ConversationWorkerContext } from "./worker";
4
5
  export declare const CONVERSATION_WORK_VISIBILITY_TIMEOUT_BUFFER_SECONDS = 30;
5
6
  export declare const CONVERSATION_WORK_DEV_CONSUMER_GROUP = "junior_conversation_work_dev";
6
7
  export interface ProcessConversationQueueMessageOptions {
7
8
  checkInIntervalMs?: number;
9
+ conversationStore?: ConversationStore;
8
10
  nowMs?: () => number;
9
11
  queue?: ConversationWorkQueue;
10
12
  run(context: ConversationWorkerContext): Promise<ConversationWorkerResult>;
@@ -1,5 +1,6 @@
1
1
  import type { StateAdapter } from "chat";
2
2
  import type { Destination } from "@sentry/junior-plugin-api";
3
+ import type { ConversationStore } from "@/chat/conversations/store";
3
4
  import { type ConversationQueueMessage, type ConversationWorkQueue } from "./queue";
4
5
  import { type InboundMessage } from "./store";
5
6
  export declare const CONVERSATION_WORK_DEFER_DELAY_MS = 15000;
@@ -20,6 +21,7 @@ export interface ConversationWorkProcessResult {
20
21
  }
21
22
  export interface ProcessConversationWorkOptions {
22
23
  checkInIntervalMs?: number;
24
+ conversationStore?: ConversationStore;
23
25
  nowMs?: () => number;
24
26
  queue: ConversationWorkQueue;
25
27
  run(context: ConversationWorkerContext): Promise<ConversationWorkerResult>;
@@ -1,6 +1,7 @@
1
- import type { ToolRuntimeContext, ToolState } from "@/chat/tools/types";
1
+ import type { SlackToolContext } from "@/chat/tools/slack/context";
2
+ import type { ToolState } from "@/chat/tools/types";
2
3
  /** Create a tool that provisions a new Slack canvas in the active channel. */
3
- export declare function createSlackCanvasCreateTool(context: ToolRuntimeContext, state: ToolState): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{
4
+ export declare function createSlackCanvasCreateTool(context: SlackToolContext, state: ToolState): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{
4
5
  title: import("@sinclair/typebox").TString;
5
6
  markdown: import("@sinclair/typebox").TString;
6
7
  }>>;
@@ -1,5 +1,5 @@
1
- import type { ToolRuntimeContext } from "@/chat/tools/types";
2
- export declare function createSlackChannelListMessagesTool(context: ToolRuntimeContext): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{
1
+ import type { SlackToolContext } from "@/chat/tools/slack/context";
2
+ export declare function createSlackChannelListMessagesTool(context: SlackToolContext): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{
3
3
  limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
4
4
  cursor: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
5
5
  oldest: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
@@ -1,4 +1,5 @@
1
- import type { ToolRuntimeContext, ToolState } from "@/chat/tools/types";
2
- export declare function createSlackChannelPostMessageTool(context: ToolRuntimeContext, state: ToolState): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{
1
+ import type { SlackToolContext } from "@/chat/tools/slack/context";
2
+ import type { ToolState } from "@/chat/tools/types";
3
+ export declare function createSlackChannelPostMessageTool(context: SlackToolContext, state: ToolState): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{
3
4
  text: import("@sinclair/typebox").TString;
4
5
  }>>;
@@ -1,3 +1,16 @@
1
1
  import type { ToolRuntimeContext } from "@/chat/tools/types";
2
- /** Resolve the Slack channel used by first-class delivery tools. */
3
- export declare function getSlackDeliveryChannelId(context: ToolRuntimeContext): string | undefined;
2
+ import type { SlackDestination } from "@sentry/junior-plugin-api";
3
+ import type { SlackSource } from "@sentry/junior-plugin-api";
4
+ import type { SlackRequester } from "@/chat/requester";
5
+ export interface SlackToolContext {
6
+ destination?: SlackDestination;
7
+ source: SlackSource;
8
+ requester?: SlackRequester;
9
+ destinationChannelId?: string;
10
+ messageTs?: string;
11
+ sourceChannelId: string;
12
+ teamId: string;
13
+ threadTs?: string;
14
+ }
15
+ /** Resolve Slack-specific tool context from the active source/destination/requester. */
16
+ export declare function getSlackToolContext(context: ToolRuntimeContext): SlackToolContext | undefined;
@@ -1,4 +1,5 @@
1
- import type { ToolRuntimeContext, ToolState } from "@/chat/tools/types";
2
- export declare function createSlackMessageAddReactionTool(context: ToolRuntimeContext, state: ToolState): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{
1
+ import type { SlackToolContext } from "@/chat/tools/slack/context";
2
+ import type { ToolState } from "@/chat/tools/types";
3
+ export declare function createSlackMessageAddReactionTool(context: SlackToolContext, state: ToolState): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{
3
4
  emoji: import("@sinclair/typebox").TString;
4
5
  }>>;
@@ -1,6 +1,6 @@
1
- import type { ToolRuntimeContext } from "@/chat/tools/types";
1
+ import type { SlackToolContext } from "@/chat/tools/slack/context";
2
2
  /** Create a tool that reads a Slack thread from a shared message URL or explicit coordinates. */
3
- export declare function createSlackThreadReadTool(context: ToolRuntimeContext): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{
3
+ export declare function createSlackThreadReadTool(context: SlackToolContext): import("@/chat/tools/definition").ToolDefinition<import("@sinclair/typebox").TObject<{
4
4
  url: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
5
5
  channel_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
6
6
  ts: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
@@ -1,12 +1,12 @@
1
1
  import type { FileUpload } from "chat";
2
- import type { Destination } from "@sentry/junior-plugin-api";
2
+ import type { Destination, LocalDestination, LocalSource, SlackDestination, SlackSource, Source } from "@sentry/junior-plugin-api";
3
3
  import type { McpToolManager } from "@/chat/mcp/tool-manager";
4
4
  import type { SandboxWorkspace } from "@/chat/sandbox/workspace";
5
5
  import type { ThreadArtifactsState } from "@/chat/state/artifacts";
6
6
  import type { Skill } from "@/chat/skills";
7
7
  import type { LoadSkillMetadata } from "@/chat/tools/skill/load-skill";
8
8
  import type { AdvisorToolRuntimeContext } from "@/chat/tools/advisor/tool";
9
- import type { Requester } from "@/chat/requester";
9
+ import type { LocalRequester, Requester, SlackRequester } from "@/chat/requester";
10
10
  export interface ImageGenerateToolDeps {
11
11
  fetch?: typeof fetch;
12
12
  }
@@ -34,20 +34,8 @@ export interface ToolHooks {
34
34
  webSearch?: WebSearchToolDeps;
35
35
  };
36
36
  }
37
- export interface ToolRuntimeContext {
37
+ interface BaseToolRuntimeContext {
38
38
  advisor?: AdvisorToolRuntimeContext;
39
- /**
40
- * Raw Slack channel/conversation container for this turn: `C...`, `D...`,
41
- * or `G...`. Never overridden by assistant context. Stable binding key for
42
- * state scoped to a Slack conversation. Passed to plugin hooks as-is via
43
- * `ToolRegistrationHookContext.channelId`.
44
- */
45
- channelId?: string;
46
- /**
47
- * Slack channel used by first-class delivery tools when assistant context
48
- * points at a source channel different from the raw conversation channel.
49
- */
50
- deliveryChannelId?: string;
51
39
  /**
52
40
  * Opaque Junior conversation/session identity for this turn.
53
41
  * Interactive Slack turns use `slack:{channelId}:{threadTs}`.
@@ -55,18 +43,29 @@ export interface ToolRuntimeContext {
55
43
  * Do not parse as Slack unless the value starts with `slack:`.
56
44
  */
57
45
  conversationId?: string;
58
- /** Runtime-owned destination for provider-neutral side effects. */
46
+ /** Runtime-owned default outbound destination, if this invocation has one. */
59
47
  destination?: Destination;
60
48
  requester?: Requester;
61
- teamId?: string;
62
- messageTs?: string;
63
- threadTs?: string;
49
+ /** Runtime-owned source where this invocation came from. */
50
+ source: Source;
64
51
  userText?: string;
65
52
  artifactState?: ThreadArtifactsState;
66
53
  configuration?: Record<string, unknown>;
67
54
  mcpToolManager?: McpToolManager;
68
55
  sandbox: SandboxWorkspace;
69
56
  }
57
+ interface SlackToolRuntimeContext extends BaseToolRuntimeContext {
58
+ destination?: SlackDestination;
59
+ requester?: SlackRequester;
60
+ source: SlackSource;
61
+ }
62
+ interface LocalToolRuntimeContext extends BaseToolRuntimeContext {
63
+ destination?: LocalDestination;
64
+ requester?: LocalRequester;
65
+ source: LocalSource;
66
+ slack?: never;
67
+ }
68
+ export type ToolRuntimeContext = LocalToolRuntimeContext | SlackToolRuntimeContext;
70
69
  export interface ToolState {
71
70
  artifactState: ThreadArtifactsState;
72
71
  patchArtifactState: (patch: Partial<ThreadArtifactsState>) => void | Promise<void>;
@@ -74,3 +73,4 @@ export interface ToolState {
74
73
  getOperationResult: <T>(operationKey: string) => T | undefined;
75
74
  setOperationResult: (operationKey: string, result: unknown) => void;
76
75
  }
76
+ export {};