@sentry/junior 0.71.3 → 0.73.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 (103) hide show
  1. package/bin/junior.mjs +22 -10
  2. package/dist/api-reference.d.ts +2 -0
  3. package/dist/app.d.ts +12 -3
  4. package/dist/app.js +2522 -15560
  5. package/dist/chat/agent-dispatch/heartbeat.d.ts +0 -6
  6. package/dist/chat/agent-dispatch/runner.d.ts +2 -0
  7. package/dist/chat/agent-dispatch/store.d.ts +2 -2
  8. package/dist/chat/agent-dispatch/types.d.ts +6 -3
  9. package/dist/chat/agent-dispatch/validation.d.ts +2 -3
  10. package/dist/chat/app/production.d.ts +8 -1
  11. package/dist/chat/app/services.d.ts +7 -0
  12. package/dist/chat/destination.d.ts +3 -1
  13. package/dist/chat/logging.d.ts +3 -0
  14. package/dist/chat/mcp/errors.d.ts +3 -0
  15. package/dist/chat/mcp/tool-manager.d.ts +5 -1
  16. package/dist/chat/oauth-flow.d.ts +1 -1
  17. package/dist/chat/plugins/agent-hooks.d.ts +3 -2
  18. package/dist/chat/plugins/registry.d.ts +2 -0
  19. package/dist/chat/plugins/types.d.ts +2 -0
  20. package/dist/chat/prompt.d.ts +4 -1
  21. package/dist/chat/requester.d.ts +67 -0
  22. package/dist/chat/respond.d.ts +8 -8
  23. package/dist/chat/runtime/agent-continue-runner.d.ts +25 -0
  24. package/dist/chat/runtime/reply-executor.d.ts +7 -5
  25. package/dist/chat/runtime/slack-resume.d.ts +3 -3
  26. package/dist/chat/runtime/slack-runtime.d.ts +13 -3
  27. package/dist/chat/runtime/turn.d.ts +17 -3
  28. package/dist/chat/sandbox/egress-credentials.d.ts +5 -2
  29. package/dist/chat/sandbox/egress-policy.d.ts +5 -1
  30. package/dist/chat/sandbox/egress-proxy.d.ts +2 -0
  31. package/dist/chat/sandbox/egress-schemas.d.ts +4 -0
  32. package/dist/chat/sandbox/egress-session.d.ts +3 -1
  33. package/dist/chat/sandbox/egress-tracing.d.ts +7 -0
  34. package/dist/chat/sandbox/sandbox.d.ts +2 -0
  35. package/dist/chat/sandbox/session.d.ts +3 -2
  36. package/dist/chat/services/agent-continue.d.ts +27 -0
  37. package/dist/chat/services/auth-pause-response.d.ts +1 -1
  38. package/dist/chat/services/auth-pause.d.ts +2 -1
  39. package/dist/chat/services/mcp-auth-orchestration.d.ts +1 -1
  40. package/dist/chat/services/message-actor-identity.d.ts +12 -4
  41. package/dist/chat/services/plugin-auth-orchestration.d.ts +9 -8
  42. package/dist/chat/services/turn-result.d.ts +3 -0
  43. package/dist/chat/services/turn-session-record.d.ts +10 -7
  44. package/dist/chat/slack/user.d.ts +4 -4
  45. package/dist/chat/state/adapter.d.ts +2 -0
  46. package/dist/chat/state/conversation-details.d.ts +4 -3
  47. package/dist/chat/state/session-log.d.ts +43 -0
  48. package/dist/chat/state/turn-session.d.ts +7 -10
  49. package/dist/chat/task-execution/slack-work.d.ts +5 -5
  50. package/dist/chat/task-execution/store.d.ts +83 -48
  51. package/dist/chat/task-execution/worker.d.ts +3 -3
  52. package/dist/chat/tools/definition.d.ts +3 -0
  53. package/dist/chat/tools/execution/tool-error-handler.d.ts +2 -1
  54. package/dist/chat/tools/slack/canvas-tools.d.ts +3 -2
  55. package/dist/chat/tools/slack/channel-list-messages.d.ts +2 -2
  56. package/dist/chat/tools/slack/channel-post-message.d.ts +3 -2
  57. package/dist/chat/tools/slack/context.d.ts +15 -2
  58. package/dist/chat/tools/slack/message-add-reaction.d.ts +3 -2
  59. package/dist/chat/tools/slack/thread-read.d.ts +2 -2
  60. package/dist/chat/tools/types.d.ts +20 -23
  61. package/dist/{chunk-BBXYXOJW.js → chunk-3BYAPS6B.js} +48 -529
  62. package/dist/{chunk-UXG6TU2U.js → chunk-7Q5YOUUT.js} +16 -93
  63. package/dist/chunk-AL5T52ZD.js +1119 -0
  64. package/dist/chunk-CYUI7JU5.js +195 -0
  65. package/dist/{chunk-R62YWUNO.js → chunk-DIMX5F3T.js} +10 -28
  66. package/dist/chunk-G3E7SCME.js +28 -0
  67. package/dist/chunk-KVZL5NZS.js +519 -0
  68. package/dist/chunk-M4FLLXXD.js +212 -0
  69. package/dist/chunk-OQSYYOLM.js +12787 -0
  70. package/dist/{chunk-GT67ZWZQ.js → chunk-OR6NQJ5E.js} +5 -3
  71. package/dist/{chunk-B5HKWWQB.js → chunk-RY6AL5C7.js} +8 -6
  72. package/dist/chunk-SJHUF3DP.js +43 -0
  73. package/dist/{chunk-XE2VFQQN.js → chunk-UOTZ3EEQ.js} +1 -1
  74. package/dist/{chunk-HOGQL2H6.js → chunk-UZVHXZ7V.js} +1357 -1486
  75. package/dist/{chunk-76YMBKW7.js → chunk-V4VYUY4A.js} +27 -14
  76. package/dist/{chunk-JS4HURDT.js → chunk-WS2EG3GW.js} +224 -224
  77. package/dist/chunk-ZDA2HYX5.js +275 -0
  78. package/dist/cli/chat.js +205 -0
  79. package/dist/cli/check.js +6 -5
  80. package/dist/cli/run.js +18 -2
  81. package/dist/cli/snapshot-warmup.js +11 -8
  82. package/dist/cli/upgrade.js +599 -0
  83. package/dist/deployment.d.ts +4 -0
  84. package/dist/handlers/agent-dispatch.d.ts +6 -1
  85. package/dist/handlers/mcp-oauth-callback.d.ts +6 -1
  86. package/dist/handlers/oauth-callback.d.ts +6 -1
  87. package/dist/handlers/sandbox-egress-proxy.d.ts +2 -0
  88. package/dist/handlers/webhooks.d.ts +4 -2
  89. package/dist/instrumentation.js +17 -2
  90. package/dist/nitro.d.ts +1 -1
  91. package/dist/nitro.js +10 -10
  92. package/dist/plugins.d.ts +1 -1
  93. package/dist/reporting/conversations.d.ts +116 -0
  94. package/dist/reporting.d.ts +24 -129
  95. package/dist/reporting.js +320 -166
  96. package/dist/runner-LMAM4OGD.js +259 -0
  97. package/package.json +3 -3
  98. package/dist/chat/runtime/timeout-resume-runner.d.ts +0 -19
  99. package/dist/chat/services/requester-identity.d.ts +0 -19
  100. package/dist/chat/services/timeout-resume.d.ts +0 -23
  101. package/dist/chunk-6YY4Q3D4.js +0 -12
  102. package/dist/chunk-Z3YD6NHK.js +0 -12
  103. package/dist/handlers/turn-resume.d.ts +0 -4
@@ -1,59 +1,85 @@
1
1
  import type { StateAdapter } from "chat";
2
2
  import type { Destination } from "@sentry/junior-plugin-api";
3
+ import { type StoredSlackRequester } from "@/chat/requester";
3
4
  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";
4
7
  export declare const CONVERSATION_WORK_LEASE_TTL_MS = 90000;
5
8
  export declare const CONVERSATION_WORK_CHECK_IN_INTERVAL_MS = 15000;
6
9
  export declare const CONVERSATION_WORK_STALE_ENQUEUE_MS = 60000;
7
- export declare const CONVERSATION_WORK_MAX_CONSECUTIVE_FAILURES = 5;
8
- export type InboundMessageSource = "plugin" | "scheduler" | "slack";
9
- export interface AgentInputMessage {
10
+ export type Source = "api" | "internal" | "local" | "plugin" | "scheduler" | "slack";
11
+ export type ExecutionStatus = "awaiting_resume" | "idle" | "pending" | "running";
12
+ export interface AgentInput {
10
13
  attachments?: unknown[];
11
14
  authorId?: string;
12
15
  metadata?: Record<string, unknown>;
13
16
  text: string;
14
17
  }
15
- export interface InboundMessageRecord {
18
+ export interface InboundMessage {
16
19
  conversationId: string;
17
20
  createdAtMs: number;
18
21
  destination: Destination;
19
22
  inboundMessageId: string;
20
23
  injectedAtMs?: number;
21
- input: AgentInputMessage;
24
+ input: AgentInput;
22
25
  receivedAtMs: number;
23
- source: InboundMessageSource;
26
+ source: Source;
24
27
  }
25
- export interface ConversationLease {
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 {
26
59
  acquiredAtMs: number;
27
60
  lastCheckInAtMs: number;
28
61
  leaseExpiresAtMs: number;
29
62
  leaseToken: string;
30
63
  }
31
- export interface ConversationWorkState {
32
- consecutiveFailureCount: number;
33
- conversationId: string;
34
- destination: Destination;
64
+ export interface ConversationWorkState extends Conversation {
35
65
  lastEnqueuedAtMs?: number;
36
- lastFailureAtMs?: number;
37
- lease?: ConversationLease;
38
- messages: InboundMessageRecord[];
66
+ lease?: ConversationWorkLease;
67
+ messages: InboundMessage[];
39
68
  needsRun: boolean;
40
- schemaVersion: 1;
41
- terminallyFailedAtMs?: number;
42
- updatedAtMs: number;
43
69
  }
44
- export interface ConversationLeaseAcquired {
70
+ export interface StartConversationWorkAcquired {
45
71
  leaseExpiresAtMs: number;
46
72
  leaseToken: string;
47
73
  status: "acquired";
48
74
  }
49
- export interface ConversationLeaseActive {
75
+ export interface StartConversationWorkActive {
50
76
  leaseExpiresAtMs: number;
51
77
  status: "active";
52
78
  }
53
- export interface ConversationLeaseNoWork {
79
+ export interface StartConversationWorkNoWork {
54
80
  status: "no_work";
55
81
  }
56
- export type ConversationLeaseStartResult = ConversationLeaseAcquired | ConversationLeaseActive | ConversationLeaseNoWork;
82
+ export type StartConversationWorkResult = StartConversationWorkAcquired | StartConversationWorkActive | StartConversationWorkNoWork;
57
83
  export interface AppendInboundMessageResult {
58
84
  status: "appended" | "duplicate";
59
85
  }
@@ -63,24 +89,29 @@ export interface AppendAndEnqueueInboundMessageResult extends AppendInboundMessa
63
89
  export interface RequestConversationWorkResult {
64
90
  status: "created" | "updated";
65
91
  }
66
- /** Return a persisted conversation work record, if one exists. */
92
+ /** Return a persisted conversation record, if one exists. */
93
+ export declare function getConversation(args: {
94
+ conversationId: string;
95
+ state?: StateAdapter;
96
+ }): Promise<Conversation | undefined>;
97
+ /** Return a persisted conversation record, if one exists. */
67
98
  export declare function getConversationWorkState(args: {
68
99
  conversationId: string;
69
100
  state?: StateAdapter;
70
101
  }): Promise<ConversationWorkState | undefined>;
71
102
  /** Count mailbox messages that have not yet reached the session log. */
72
- export declare function countPendingConversationMessages(state: ConversationWorkState): number;
103
+ export declare function countPendingConversationMessages(conversation: Conversation): number;
73
104
  /** Return whether a conversation has pending or resumable execution work. */
74
- export declare function hasRunnableConversationWork(state: ConversationWorkState): boolean;
105
+ export declare function hasRunnableConversationWork(conversation: Conversation): boolean;
75
106
  /** Persist one inbound message idempotently in its conversation mailbox. */
76
107
  export declare function appendInboundMessage(args: {
77
- message: InboundMessageRecord;
108
+ message: InboundMessage;
78
109
  nowMs?: number;
79
110
  state?: StateAdapter;
80
111
  }): Promise<AppendInboundMessageResult>;
81
112
  /** Persist inbound work and send the queue nudge that wakes a worker. */
82
113
  export declare function appendAndEnqueueInboundMessage(args: {
83
- message: InboundMessageRecord;
114
+ message: InboundMessage;
84
115
  nowMs?: number;
85
116
  queue: ConversationWorkQueue;
86
117
  state?: StateAdapter;
@@ -92,6 +123,18 @@ export declare function requestConversationWork(args: {
92
123
  nowMs?: number;
93
124
  state?: StateAdapter;
94
125
  }): Promise<RequestConversationWorkResult>;
126
+ /** 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;
135
+ state?: StateAdapter;
136
+ title?: string;
137
+ }): Promise<void>;
95
138
  /** Record that a wake-up nudge was accepted for the conversation. */
96
139
  export declare function markConversationWorkEnqueued(args: {
97
140
  conversationId: string;
@@ -103,7 +146,7 @@ export declare function startConversationWork(args: {
103
146
  conversationId: string;
104
147
  nowMs?: number;
105
148
  state?: StateAdapter;
106
- }): Promise<ConversationLeaseStartResult>;
149
+ }): Promise<StartConversationWorkResult>;
107
150
  /** Extend the durable execution lease when the worker checks in. */
108
151
  export declare function checkInConversationWork(args: {
109
152
  conversationId: string;
@@ -114,11 +157,11 @@ export declare function checkInConversationWork(args: {
114
157
  /** Drain pending mailbox entries after the caller has durably injected them. */
115
158
  export declare function drainConversationMailbox(args: {
116
159
  conversationId: string;
117
- inject: (messages: InboundMessageRecord[]) => Promise<void>;
160
+ inject: (messages: InboundMessage[]) => Promise<void>;
118
161
  leaseToken: string;
119
162
  nowMs?: number;
120
163
  state?: StateAdapter;
121
- }): Promise<InboundMessageRecord[]>;
164
+ }): Promise<InboundMessage[]>;
122
165
  /** Mark selected leased mailbox entries after their session-log injection succeeds. */
123
166
  export declare function markConversationMessagesInjected(args: {
124
167
  conversationId: string;
@@ -155,27 +198,19 @@ export declare function clearExpiredConversationLease(args: {
155
198
  nowMs?: number;
156
199
  state?: StateAdapter;
157
200
  }): Promise<boolean>;
158
- export interface RecordConversationWorkFailureResult {
159
- abandoned: boolean;
160
- consecutiveFailureCount: number;
161
- releasedLease: boolean;
162
- }
163
- /**
164
- * Increment the durable failure counter after a caught worker error so
165
- * deterministic poison work cannot churn the queue forever. When the counter
166
- * crosses {@link CONVERSATION_WORK_MAX_CONSECUTIVE_FAILURES}, the conversation
167
- * is marked terminally failed: the lease is cleared, pending mailbox messages
168
- * are dropped, and the conversation drops out of the recovery index so neither
169
- * the worker nor heartbeat will requeue it again. A later inbound message
170
- * resets the counter and gives the conversation a fresh attempt.
171
- */
172
- export declare function recordConversationWorkFailure(args: {
201
+ /** Remove one conversation from the active index after it is missing or idle. */
202
+ export declare function removeActiveConversation(args: {
173
203
  conversationId: string;
174
- nowMs?: number;
175
204
  state?: StateAdapter;
176
- }): Promise<RecordConversationWorkFailureResult>;
177
- /** List bounded conversation ids that may need heartbeat recovery. */
178
- export declare function listConversationWorkIds(args?: {
205
+ }): Promise<void>;
206
+ /** List active conversation ids by oldest execution update first. */
207
+ export declare function listActiveConversationIds(args?: {
179
208
  limit?: number;
209
+ staleBeforeMs?: number;
180
210
  state?: StateAdapter;
181
211
  }): Promise<string[]>;
212
+ /** List retained conversations by newest visible activity first. */
213
+ export declare function listConversationsByActivity(args?: {
214
+ limit?: number;
215
+ state?: StateAdapter;
216
+ }): Promise<Conversation[]>;
@@ -1,14 +1,14 @@
1
1
  import type { StateAdapter } from "chat";
2
2
  import type { Destination } from "@sentry/junior-plugin-api";
3
3
  import { type ConversationQueueMessage, type ConversationWorkQueue } from "./queue";
4
- import { type InboundMessageRecord } from "./store";
4
+ import { type InboundMessage } from "./store";
5
5
  export declare const CONVERSATION_WORK_DEFER_DELAY_MS = 15000;
6
6
  export declare const CONVERSATION_WORK_SOFT_YIELD_AFTER_MS = 240000;
7
7
  export interface ConversationWorkerContext {
8
8
  checkIn(): Promise<boolean>;
9
9
  conversationId: string;
10
10
  destination: Destination;
11
- drainMailbox(inject: (messages: InboundMessageRecord[]) => Promise<void>): Promise<InboundMessageRecord[]>;
11
+ drainMailbox(inject: (messages: InboundMessage[]) => Promise<void>): Promise<InboundMessage[]>;
12
12
  leaseToken: string;
13
13
  shouldYield(): boolean;
14
14
  }
@@ -16,7 +16,7 @@ export interface ConversationWorkerResult {
16
16
  status: "completed" | "lost_lease" | "yielded";
17
17
  }
18
18
  export interface ConversationWorkProcessResult {
19
- status: "abandoned" | "active" | "completed" | "lost_lease" | "no_work" | "pending_requeued" | "yielded";
19
+ status: "active" | "completed" | "lost_lease" | "no_work" | "pending_requeued" | "yielded";
20
20
  }
21
21
  export interface ProcessConversationWorkOptions {
22
22
  checkInIntervalMs?: number;
@@ -1,6 +1,7 @@
1
1
  import type { ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
2
2
  import type { Static, TSchema } from "@sinclair/typebox";
3
3
  import type { ToolExecutionMode } from "@earendil-works/pi-agent-core";
4
+ import type { ConversationPrivacy } from "@/chat/conversation-privacy";
4
5
  export interface ToolDefinition<TInputSchema extends TSchema = TSchema> {
5
6
  description: string;
6
7
  inputSchema: TInputSchema;
@@ -22,6 +23,8 @@ export interface ToolDefinition<TInputSchema extends TSchema = TSchema> {
22
23
  execute?: (input: Static<TInputSchema>, options: {
23
24
  experimental_context?: unknown;
24
25
  signal?: AbortSignal;
26
+ conversationPrivacy?: ConversationPrivacy;
27
+ toolCallId?: string;
25
28
  }) => Promise<unknown> | unknown;
26
29
  }
27
30
  /** Infer execute parameter types from the inputSchema via generic binding. */
@@ -1,3 +1,4 @@
1
1
  import { type LogContext } from "@/chat/logging";
2
+ import type { ConversationPrivacy } from "@/chat/conversation-privacy";
2
3
  /** Handle tool execution errors: set span attributes, log, and rethrow. */
3
- export declare function handleToolExecutionError(error: unknown, toolName: string, toolCallId: string | undefined, shouldTrace: boolean, traceContext: LogContext): never;
4
+ export declare function handleToolExecutionError(error: unknown, toolName: string, toolCallId: string | undefined, shouldTrace: boolean, traceContext: LogContext, conversationPrivacy?: ConversationPrivacy): never;
@@ -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,11 +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 { LocalRequester, Requester, SlackRequester } from "@/chat/requester";
9
10
  export interface ImageGenerateToolDeps {
10
11
  fetch?: typeof fetch;
11
12
  }
@@ -33,20 +34,8 @@ export interface ToolHooks {
33
34
  webSearch?: WebSearchToolDeps;
34
35
  };
35
36
  }
36
- export interface ToolRuntimeContext {
37
+ interface BaseToolRuntimeContext {
37
38
  advisor?: AdvisorToolRuntimeContext;
38
- /**
39
- * Raw Slack channel/conversation container for this turn: `C...`, `D...`,
40
- * or `G...`. Never overridden by assistant context. Stable binding key for
41
- * state scoped to a Slack conversation. Passed to plugin hooks as-is via
42
- * `ToolRegistrationHookContext.channelId`.
43
- */
44
- channelId?: string;
45
- /**
46
- * Slack channel used by first-class delivery tools when assistant context
47
- * points at a source channel different from the raw conversation channel.
48
- */
49
- deliveryChannelId?: string;
50
39
  /**
51
40
  * Opaque Junior conversation/session identity for this turn.
52
41
  * Interactive Slack turns use `slack:{channelId}:{threadTs}`.
@@ -54,22 +43,29 @@ export interface ToolRuntimeContext {
54
43
  * Do not parse as Slack unless the value starts with `slack:`.
55
44
  */
56
45
  conversationId?: string;
57
- /** Runtime-owned destination for provider-neutral side effects. */
46
+ /** Runtime-owned default outbound destination, if this invocation has one. */
58
47
  destination?: Destination;
59
- requester?: {
60
- userId?: string;
61
- userName?: string;
62
- fullName?: string;
63
- };
64
- teamId?: string;
65
- messageTs?: string;
66
- threadTs?: string;
48
+ requester?: Requester;
49
+ /** Runtime-owned source where this invocation came from. */
50
+ source: Source;
67
51
  userText?: string;
68
52
  artifactState?: ThreadArtifactsState;
69
53
  configuration?: Record<string, unknown>;
70
54
  mcpToolManager?: McpToolManager;
71
55
  sandbox: SandboxWorkspace;
72
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;
73
69
  export interface ToolState {
74
70
  artifactState: ThreadArtifactsState;
75
71
  patchArtifactState: (patch: Partial<ThreadArtifactsState>) => void | Promise<void>;
@@ -77,3 +73,4 @@ export interface ToolState {
77
73
  getOperationResult: <T>(operationKey: string) => T | undefined;
78
74
  setOperationResult: (operationKey: string, result: unknown) => void;
79
75
  }
76
+ export {};