@sentry/junior 0.187.0 → 0.189.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 (108) hide show
  1. package/dist/{agent-hooks-XVAE2554.js → agent-hooks-6QRYH6PX.js} +11 -11
  2. package/dist/api/acp/conversations.d.ts +2 -2
  3. package/dist/api/conversations/list.d.ts +7 -0
  4. package/dist/api/people/shared.d.ts +54 -0
  5. package/dist/api.js +41 -52
  6. package/dist/app.d.ts +1 -1
  7. package/dist/app.js +1001 -338
  8. package/dist/{catalog-runtime-DWFAC562.js → catalog-runtime-IETJLJFG.js} +4 -4
  9. package/dist/chat/agent/resume.d.ts +0 -2
  10. package/dist/chat/agent/types.d.ts +9 -14
  11. package/dist/chat/agent-dispatch/work.d.ts +1 -10
  12. package/dist/chat/agent-invocations/spawn.d.ts +1 -1
  13. package/dist/chat/agent-invocations/types.d.ts +296 -24
  14. package/dist/chat/app/conversation-work.d.ts +16 -8
  15. package/dist/chat/conversation-privacy.d.ts +7 -7
  16. package/dist/chat/conversations/destination.d.ts +12 -0
  17. package/dist/chat/conversations/location.d.ts +3 -8
  18. package/dist/chat/conversations/projection.d.ts +2 -2
  19. package/dist/chat/conversations/sql/location.d.ts +13 -4
  20. package/dist/chat/{api-turns → conversations}/stop.d.ts +2 -2
  21. package/dist/chat/conversations/store.d.ts +8 -11
  22. package/dist/chat/conversations/structured-events.d.ts +1 -1
  23. package/dist/chat/{api-turns/authorization.d.ts → conversations/web-authorization.d.ts} +1 -0
  24. package/dist/chat/conversations/web-input.d.ts +98 -0
  25. package/dist/chat/conversations/web-mailbox.d.ts +12 -0
  26. package/dist/chat/providers/slack/runtime.d.ts +1 -0
  27. package/dist/chat/providers/slack/system-turn.d.ts +8 -0
  28. package/dist/chat/resource-events/actor.d.ts +13 -12
  29. package/dist/chat/resource-events/notification.d.ts +1 -1
  30. package/dist/chat/services/guardian-action-policy.d.ts +1 -1
  31. package/dist/chat/services/turn-session-routing.d.ts +5 -5
  32. package/dist/chat/task-execution/assistant-message.d.ts +32 -0
  33. package/dist/chat/task-execution/conversation-turn.d.ts +8 -0
  34. package/dist/chat/{api-turns → task-execution}/mailbox-input.d.ts +1 -2
  35. package/dist/chat/task-execution/mailbox-turn.d.ts +42 -0
  36. package/dist/chat/task-execution/paused-turn.d.ts +1 -1
  37. package/dist/chat/task-execution/slack-work.d.ts +0 -2
  38. package/dist/{chunk-WL3R2KTS.js → chunk-4RHJ3CXR.js} +90 -289
  39. package/dist/{chunk-U6ZQHRIP.js → chunk-5CXCGDIL.js} +1 -1
  40. package/dist/{chunk-HXR3FHTE.js → chunk-5VWAY27R.js} +7 -3
  41. package/dist/{chunk-D3GDGREI.js → chunk-6AUR6PWR.js} +3 -3
  42. package/dist/{chunk-EIWYZXSM.js → chunk-7R5JRPCY.js} +8 -6
  43. package/dist/{chunk-WRDW3A3D.js → chunk-AC7MDOJW.js} +5 -7
  44. package/dist/{chunk-URZ7UD4P.js → chunk-BYBSI5TI.js} +2 -2
  45. package/dist/{chunk-MUPPP7A7.js → chunk-CMWIMFM6.js} +4 -182
  46. package/dist/{chunk-WKIS4VRK.js → chunk-CUYFCI4G.js} +70 -39
  47. package/dist/chunk-DA2KGZZI.js +13 -0
  48. package/dist/{chunk-Q6OCUQ7W.js → chunk-DYXVAO2E.js} +1 -1
  49. package/dist/{chunk-QH3I7ZOK.js → chunk-E3PDZPGV.js} +1 -1
  50. package/dist/{chunk-NU775DLU.js → chunk-GP32KD2J.js} +4 -12
  51. package/dist/{chunk-STF4GSK4.js → chunk-KN32OWL2.js} +5 -5
  52. package/dist/chunk-LHKZKAZ4.js +285 -0
  53. package/dist/{chunk-D5BWM37G.js → chunk-MFSET7Q7.js} +51 -341
  54. package/dist/{chunk-DUE4EUNL.js → chunk-MI6ZBDTS.js} +6 -6
  55. package/dist/{chunk-27T5HZHO.js → chunk-MRXMFB4L.js} +6 -87
  56. package/dist/{chunk-4A2R3AQB.js → chunk-MVPLEPSI.js} +1 -1
  57. package/dist/{chunk-7LRRVMPH.js → chunk-NY2F7BZA.js} +1 -1
  58. package/dist/chunk-O35GZCKL.js +311 -0
  59. package/dist/{chunk-U3KMII5Y.js → chunk-OEIITG5F.js} +1 -1
  60. package/dist/{chunk-6FKNNUSN.js → chunk-PCPSX4ES.js} +209 -7
  61. package/dist/{chunk-6YCIYOVA.js → chunk-PY3EIEAF.js} +1 -1
  62. package/dist/{chunk-U5POFCKM.js → chunk-QNIOBNOY.js} +284 -123
  63. package/dist/{chunk-JCRXXEMC.js → chunk-S3SGZUOI.js} +1 -1
  64. package/dist/chunk-SR6OMO5C.js +703 -0
  65. package/dist/{chunk-TQHCZXN7.js → chunk-UCWO5MKP.js} +7 -7
  66. package/dist/{chunk-ITLYUKGZ.js → chunk-VKQWU4PO.js} +2 -2
  67. package/dist/{chunk-JZPDYKRG.js → chunk-WDHPN2GH.js} +3 -3
  68. package/dist/{chunk-P2VU5JNH.js → chunk-WMUAKAIF.js} +42 -42
  69. package/dist/{chunk-NIKLTFBP.js → chunk-WN6VLHOU.js} +12 -5
  70. package/dist/{chunk-VC343WHM.js → chunk-WWYUYKKV.js} +1 -1
  71. package/dist/{chunk-OM4SFFJK.js → chunk-WYDF6PGK.js} +3 -3
  72. package/dist/{chunk-KRYJ5VOD.js → chunk-YNZPOFF3.js} +16 -21
  73. package/dist/{chunk-Z6OHCDXP.js → chunk-YYSEH2WC.js} +2 -2
  74. package/dist/{chunk-BITZUBPJ.js → chunk-YYZNESC3.js} +8 -8
  75. package/dist/{chunk-2VUDJGB6.js → chunk-ZUPDSJUE.js} +2 -5
  76. package/dist/{chunk-X5SXFVZT.js → chunk-ZV6PFUA4.js} +1 -1
  77. package/dist/cli/chat.js +34 -33
  78. package/dist/cli/check.js +5 -5
  79. package/dist/cli/plugins.js +12 -12
  80. package/dist/cli/snapshot-create.js +9 -9
  81. package/dist/cli/upgrade.js +6 -6
  82. package/dist/db/schema/conversations.d.ts +62 -0
  83. package/dist/db/schema.d.ts +31 -0
  84. package/dist/{db-FBHAWVXU.js → db-LPJKR2EO.js} +6 -6
  85. package/dist/instrumentation.js +3 -3
  86. package/dist/nitro.js +6 -6
  87. package/dist/{oauth-callback-server-5HS5ULC6.js → oauth-callback-server-DMXF4TTQ.js} +30 -28
  88. package/dist/{runner-46W6NV6B.js → runner-L5DPVYCN.js} +24 -20
  89. package/dist/{skills-TG3QC4B6.js → skills-NXG3LBCK.js} +5 -5
  90. package/dist/spawn-VRUIGKWW.js +42 -0
  91. package/dist/task-runner-7YTBSPXW.js +36 -0
  92. package/dist/{validation-GMRIDBC5.js → validation-CH36LTOS.js} +5 -5
  93. package/dist/version.js +1 -1
  94. package/dist/{work-W4ULBJTU.js → work-HBC5Y5VZ.js} +22 -21
  95. package/dist/{worker-M6NVACS2.js → worker-5RDZHLXH.js} +10 -10
  96. package/migrations/0037_conversation_location.sql +23 -0
  97. package/migrations/meta/0037_snapshot.json +3192 -0
  98. package/migrations/meta/_journal.json +7 -0
  99. package/package.json +4 -4
  100. package/dist/chat/api-turns/assistant-message.d.ts +0 -12
  101. package/dist/chat/api-turns/cancellation.d.ts +0 -24
  102. package/dist/chat/api-turns/routing.d.ts +0 -51
  103. package/dist/chat/api-turns/work.d.ts +0 -99
  104. package/dist/chat/task-execution/slack-resource-event.d.ts +0 -47
  105. package/dist/chunk-4YD3DET6.js +0 -1503
  106. package/dist/chunk-6FGN7ZEG.js +0 -221
  107. package/dist/spawn-Y6YWBIJS.js +0 -41
  108. package/dist/task-runner-YSGBPN4U.js +0 -34
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-QH3I7ZOK.js";
4
- import "./chunk-X5SXFVZT.js";
3
+ } from "./chunk-E3PDZPGV.js";
4
+ import "./chunk-ZV6PFUA4.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-6YCIYOVA.js";
9
+ import "./chunk-PY3EIEAF.js";
10
10
  import "./chunk-PEQXYSSE.js";
11
- import "./chunk-7LRRVMPH.js";
11
+ import "./chunk-NY2F7BZA.js";
12
12
  export {
13
13
  pluginCatalogRuntime
14
14
  };
@@ -14,11 +14,9 @@ import { type AuthorizationPauseError } from "@/chat/services/auth-pause";
14
14
  import { type AgentTurnUsage } from "@/chat/usage";
15
15
  import { type AgentDurability } from "@/chat/agent/types";
16
16
  import type { PluginTurnContext } from "@/chat/plugins/prompt";
17
- import type { ConversationPrivacy } from "@/chat/conversation-privacy";
18
17
  interface ResumeStateArgs {
19
18
  channelName?: string;
20
19
  destination: Destination;
21
- destinationVisibility?: ConversationPrivacy;
22
20
  dispatchId?: string;
23
21
  durability: AgentDurability;
24
22
  recordActiveMcpProviders: () => Promise<void>;
@@ -1,8 +1,7 @@
1
1
  /** Input for one Run through Junior's agent. */
2
2
  import type { Destination, ReplyAttribution, Source, SystemActor } from "@sentry/junior-plugin-api";
3
- import type { LocationConfigurationService } from "@/chat/configuration/types";
4
- import type { ConversationPrivacy } from "@/chat/conversation-privacy";
5
3
  import type { Location } from "@/chat/conversations/location";
4
+ import type { LocationConfigurationService } from "@/chat/configuration/types";
6
5
  import type { CredentialContext } from "@/chat/credentials/context";
7
6
  import type { PiMessage } from "@/chat/pi/messages";
8
7
  import type { Actor } from "@/chat/actor";
@@ -101,8 +100,12 @@ export type AgentRunState = {
101
100
  *
102
101
  * The runner must commit the preceding agent boundary before invoking this
103
102
  * port; the accepted reply transaction appends only this message.
103
+ *
104
+ * TODO(dcramer): Remove Conversation Message persistence from Delivery
105
+ * implementations after the core Turn lifecycle stores each completed
106
+ * assistant Message.
104
107
  */
105
- export type AgentDelivery = (message: AssistantMessage) => void | Promise<void>;
108
+ export type Delivery = (message: AssistantMessage) => void | Promise<void>;
106
109
  /** Resume the agent turn after a transient or ambiguous delivery failure. */
107
110
  export declare class RetryableDeliveryError extends Error {
108
111
  constructor(cause: unknown);
@@ -173,18 +176,10 @@ export type AgentRun = {
173
176
  /** Credential authority projected from actor (plus optional subject). */
174
177
  credentialContext?: CredentialContext;
175
178
  source: Source;
176
- /**
177
- * Transitional Conversation Location for this Run.
178
- * TODO(dcramer): Remove top-level Location, Destination, and
179
- * publishExternally after Source and Delivery contain Location across new,
180
- * resumed, and child Runs.
181
- */
179
+ /** Conversation Location available to this Run. */
182
180
  location?: Location;
183
181
  destination: Destination;
184
- /** When true, also publish assistant output to the conversation destination. */
185
182
  publishExternally?: boolean;
186
- /** Confirmed visibility of the destination where this run is delivered. */
187
- destinationVisibility?: ConversationPrivacy;
188
183
  surface?: AgentTurnSurface;
189
184
  dispatch?: AgentDispatch;
190
185
  /**
@@ -215,7 +210,7 @@ export type AgentRun = {
215
210
  state?: AgentRunState;
216
211
  /** Best-effort progress only. */
217
212
  onEvent?: (event: AgentEvent) => void | Promise<void>;
218
- delivery?: AgentDelivery;
213
+ delivery?: Delivery;
219
214
  durability?: AgentDurability;
220
215
  };
221
216
  /** Return whether one optional agent capability is disabled for this run. */
@@ -223,7 +218,7 @@ export declare function isAgentRunFeatureDisabled(disabledFeatures: readonly Age
223
218
  /** Resolve the explicit actor, dispatch actor, or credential actor for this run. */
224
219
  export declare function actorFromRun(run: Pick<AgentRun, "actor" | "dispatch" | "credentialContext">): Actor | undefined;
225
220
  /** Reject contradictory provider coordinates before the run touches state. */
226
- export declare function assertRunConsistency(run: Pick<AgentRun, "conversationId" | "source" | "destination" | "surface" | "publishExternally" | "actor" | "dispatch">): void;
221
+ export declare function assertRunConsistency(run: Pick<AgentRun, "conversationId" | "source" | "location" | "destination" | "surface" | "actor" | "dispatch">): void;
227
222
  /** Route tool side effects to the tool channel when one overrides the destination. */
228
223
  export declare function toolInvocationDestination(run: Pick<AgentRun, "destination" | "toolChannelId">): Destination;
229
224
  /** Infer the run surface when the caller did not state one. */
@@ -12,7 +12,7 @@ import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
12
12
  import type { ConversationWorkerContext, ConversationWorkerResult } from "@/chat/task-execution/worker";
13
13
  import type { DispatchRecord, DispatchTurnContext, DispatchTurnResult } from "./types";
14
14
  export declare const AGENT_DISPATCH_MAX_AGE_MS: number;
15
- type DispatchRoutingContext = Pick<DispatchTurnContext, "credentialContext" | "destinationVisibility" | "dispatch" | "surface"> & {
15
+ type DispatchRoutingContext = Pick<DispatchTurnContext, "credentialContext" | "dispatch" | "surface"> & {
16
16
  actor: DispatchRecord["actor"];
17
17
  };
18
18
  /** Restore the exact actor, credential, and dispatch routing for every slice. */
@@ -44,15 +44,6 @@ export declare function enqueueAgentDispatch(dispatch: DispatchRecord, options:
44
44
  * execution routing authority.
45
45
  */
46
46
  export declare function resolveAgentDispatchId(context: ConversationWorkerContext): Promise<string | undefined>;
47
- /**
48
- * Route leased work through dispatch execution when durable metadata owns it.
49
- *
50
- * The fallback retains ownership of every other conversation source.
51
- */
52
- export declare function createAgentDispatchWorkRouter(options: {
53
- dispatchWorker: (context: ConversationWorkerContext, dispatchId: string) => Promise<ConversationWorkerResult>;
54
- fallbackWorker: (context: ConversationWorkerContext) => Promise<ConversationWorkerResult>;
55
- }): (context: ConversationWorkerContext) => Promise<ConversationWorkerResult>;
56
47
  /** Run one dispatch start or resume under the owning conversation lease. */
57
48
  export declare function createAgentDispatchConversationWorker(options: AgentDispatchConversationWorkerOptions): (context: ConversationWorkerContext, dispatchId: string) => Promise<ConversationWorkerResult>;
58
49
  export {};
@@ -7,6 +7,6 @@ type SpawnOptions = {
7
7
  queue: ConversationWorkQueue | (() => ConversationWorkQueue);
8
8
  state?: StateAdapter;
9
9
  };
10
- /** Bind one run's runtime-owned authority to the model-safe spawn capability. */
10
+ /** Bind a Run's Actor and credentials to new Agent invocations. */
11
11
  export declare function bindSpawnAgent(run: AgentRun, options: SpawnOptions): SpawnAgent | undefined;
12
12
  export {};
@@ -85,10 +85,6 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
85
85
  platform: z.ZodLiteral<"local">;
86
86
  conversationId: z.ZodString;
87
87
  }, z.core.$strict>], "platform">;
88
- destinationVisibility: z.ZodOptional<z.ZodEnum<{
89
- private: "private";
90
- public: "public";
91
- }>>;
92
88
  input: z.ZodString;
93
89
  invocationId: z.ZodString;
94
90
  mailboxStatus: z.ZodEnum<{
@@ -103,7 +99,7 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
103
99
  xhigh: "xhigh";
104
100
  none: "none";
105
101
  }>>;
106
- source: z.ZodDiscriminatedUnion<[z.ZodObject<{
102
+ source: z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
107
103
  platform: z.ZodLiteral<"slack">;
108
104
  teamId: z.ZodString;
109
105
  channelId: z.ZodString;
@@ -113,10 +109,24 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
113
109
  }>;
114
110
  messageTs: z.ZodOptional<z.ZodString>;
115
111
  threadTs: z.ZodOptional<z.ZodString>;
112
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
113
+ id: z.ZodString;
114
+ provider: z.ZodLiteral<"slack">;
115
+ teamId: z.ZodString;
116
+ channelId: z.ZodString;
117
+ threadTs: z.ZodOptional<z.ZodString>;
118
+ }, z.core.$strict>], "provider">>;
116
119
  }, z.core.$strict>, z.ZodObject<{
117
120
  platform: z.ZodLiteral<"local">;
118
121
  visibility: z.ZodLiteral<"private">;
119
122
  conversationId: z.ZodString;
123
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
124
+ id: z.ZodString;
125
+ provider: z.ZodLiteral<"slack">;
126
+ teamId: z.ZodString;
127
+ channelId: z.ZodString;
128
+ threadTs: z.ZodOptional<z.ZodString>;
129
+ }, z.core.$strict>], "provider">>;
120
130
  }, z.core.$strict>, z.ZodObject<{
121
131
  platform: z.ZodLiteral<"web">;
122
132
  visibility: z.ZodEnum<{
@@ -124,7 +134,65 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
124
134
  public: "public";
125
135
  }>;
126
136
  conversationId: z.ZodString;
127
- }, z.core.$strict>], "platform">;
137
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
138
+ id: z.ZodString;
139
+ provider: z.ZodLiteral<"slack">;
140
+ teamId: z.ZodString;
141
+ channelId: z.ZodString;
142
+ threadTs: z.ZodOptional<z.ZodString>;
143
+ }, z.core.$strict>], "provider">>;
144
+ }, z.core.$strict>], "platform">, z.ZodTransform<{
145
+ platform: "slack";
146
+ teamId: string;
147
+ channelId: string;
148
+ visibility: "private" | "public";
149
+ messageTs?: string | undefined;
150
+ threadTs?: string | undefined;
151
+ } | {
152
+ platform: "local";
153
+ visibility: "private";
154
+ conversationId: string;
155
+ } | {
156
+ platform: "web";
157
+ visibility: "private" | "public";
158
+ conversationId: string;
159
+ }, {
160
+ platform: "slack";
161
+ teamId: string;
162
+ channelId: string;
163
+ visibility: "private" | "public";
164
+ messageTs?: string | undefined;
165
+ threadTs?: string | undefined;
166
+ location?: {
167
+ id: string;
168
+ provider: "slack";
169
+ teamId: string;
170
+ channelId: string;
171
+ threadTs?: string | undefined;
172
+ } | undefined;
173
+ } | {
174
+ platform: "local";
175
+ visibility: "private";
176
+ conversationId: string;
177
+ location?: {
178
+ id: string;
179
+ provider: "slack";
180
+ teamId: string;
181
+ channelId: string;
182
+ threadTs?: string | undefined;
183
+ } | undefined;
184
+ } | {
185
+ platform: "web";
186
+ visibility: "private" | "public";
187
+ conversationId: string;
188
+ location?: {
189
+ id: string;
190
+ provider: "slack";
191
+ teamId: string;
192
+ channelId: string;
193
+ threadTs?: string | undefined;
194
+ } | undefined;
195
+ }>>;
128
196
  updatedAtMs: z.ZodNumber;
129
197
  status: z.ZodEnum<{
130
198
  pending: "pending";
@@ -210,10 +278,6 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
210
278
  platform: z.ZodLiteral<"local">;
211
279
  conversationId: z.ZodString;
212
280
  }, z.core.$strict>], "platform">;
213
- destinationVisibility: z.ZodOptional<z.ZodEnum<{
214
- private: "private";
215
- public: "public";
216
- }>>;
217
281
  input: z.ZodString;
218
282
  invocationId: z.ZodString;
219
283
  mailboxStatus: z.ZodEnum<{
@@ -228,7 +292,7 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
228
292
  xhigh: "xhigh";
229
293
  none: "none";
230
294
  }>>;
231
- source: z.ZodDiscriminatedUnion<[z.ZodObject<{
295
+ source: z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
232
296
  platform: z.ZodLiteral<"slack">;
233
297
  teamId: z.ZodString;
234
298
  channelId: z.ZodString;
@@ -238,10 +302,24 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
238
302
  }>;
239
303
  messageTs: z.ZodOptional<z.ZodString>;
240
304
  threadTs: z.ZodOptional<z.ZodString>;
305
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
306
+ id: z.ZodString;
307
+ provider: z.ZodLiteral<"slack">;
308
+ teamId: z.ZodString;
309
+ channelId: z.ZodString;
310
+ threadTs: z.ZodOptional<z.ZodString>;
311
+ }, z.core.$strict>], "provider">>;
241
312
  }, z.core.$strict>, z.ZodObject<{
242
313
  platform: z.ZodLiteral<"local">;
243
314
  visibility: z.ZodLiteral<"private">;
244
315
  conversationId: z.ZodString;
316
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
317
+ id: z.ZodString;
318
+ provider: z.ZodLiteral<"slack">;
319
+ teamId: z.ZodString;
320
+ channelId: z.ZodString;
321
+ threadTs: z.ZodOptional<z.ZodString>;
322
+ }, z.core.$strict>], "provider">>;
245
323
  }, z.core.$strict>, z.ZodObject<{
246
324
  platform: z.ZodLiteral<"web">;
247
325
  visibility: z.ZodEnum<{
@@ -249,7 +327,65 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
249
327
  public: "public";
250
328
  }>;
251
329
  conversationId: z.ZodString;
252
- }, z.core.$strict>], "platform">;
330
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
331
+ id: z.ZodString;
332
+ provider: z.ZodLiteral<"slack">;
333
+ teamId: z.ZodString;
334
+ channelId: z.ZodString;
335
+ threadTs: z.ZodOptional<z.ZodString>;
336
+ }, z.core.$strict>], "provider">>;
337
+ }, z.core.$strict>], "platform">, z.ZodTransform<{
338
+ platform: "slack";
339
+ teamId: string;
340
+ channelId: string;
341
+ visibility: "private" | "public";
342
+ messageTs?: string | undefined;
343
+ threadTs?: string | undefined;
344
+ } | {
345
+ platform: "local";
346
+ visibility: "private";
347
+ conversationId: string;
348
+ } | {
349
+ platform: "web";
350
+ visibility: "private" | "public";
351
+ conversationId: string;
352
+ }, {
353
+ platform: "slack";
354
+ teamId: string;
355
+ channelId: string;
356
+ visibility: "private" | "public";
357
+ messageTs?: string | undefined;
358
+ threadTs?: string | undefined;
359
+ location?: {
360
+ id: string;
361
+ provider: "slack";
362
+ teamId: string;
363
+ channelId: string;
364
+ threadTs?: string | undefined;
365
+ } | undefined;
366
+ } | {
367
+ platform: "local";
368
+ visibility: "private";
369
+ conversationId: string;
370
+ location?: {
371
+ id: string;
372
+ provider: "slack";
373
+ teamId: string;
374
+ channelId: string;
375
+ threadTs?: string | undefined;
376
+ } | undefined;
377
+ } | {
378
+ platform: "web";
379
+ visibility: "private" | "public";
380
+ conversationId: string;
381
+ location?: {
382
+ id: string;
383
+ provider: "slack";
384
+ teamId: string;
385
+ channelId: string;
386
+ threadTs?: string | undefined;
387
+ } | undefined;
388
+ }>>;
253
389
  updatedAtMs: z.ZodNumber;
254
390
  result: z.ZodString;
255
391
  status: z.ZodLiteral<"completed">;
@@ -333,10 +469,6 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
333
469
  platform: z.ZodLiteral<"local">;
334
470
  conversationId: z.ZodString;
335
471
  }, z.core.$strict>], "platform">;
336
- destinationVisibility: z.ZodOptional<z.ZodEnum<{
337
- private: "private";
338
- public: "public";
339
- }>>;
340
472
  input: z.ZodString;
341
473
  invocationId: z.ZodString;
342
474
  mailboxStatus: z.ZodEnum<{
@@ -351,7 +483,7 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
351
483
  xhigh: "xhigh";
352
484
  none: "none";
353
485
  }>>;
354
- source: z.ZodDiscriminatedUnion<[z.ZodObject<{
486
+ source: z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
355
487
  platform: z.ZodLiteral<"slack">;
356
488
  teamId: z.ZodString;
357
489
  channelId: z.ZodString;
@@ -361,10 +493,24 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
361
493
  }>;
362
494
  messageTs: z.ZodOptional<z.ZodString>;
363
495
  threadTs: z.ZodOptional<z.ZodString>;
496
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
497
+ id: z.ZodString;
498
+ provider: z.ZodLiteral<"slack">;
499
+ teamId: z.ZodString;
500
+ channelId: z.ZodString;
501
+ threadTs: z.ZodOptional<z.ZodString>;
502
+ }, z.core.$strict>], "provider">>;
364
503
  }, z.core.$strict>, z.ZodObject<{
365
504
  platform: z.ZodLiteral<"local">;
366
505
  visibility: z.ZodLiteral<"private">;
367
506
  conversationId: z.ZodString;
507
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
508
+ id: z.ZodString;
509
+ provider: z.ZodLiteral<"slack">;
510
+ teamId: z.ZodString;
511
+ channelId: z.ZodString;
512
+ threadTs: z.ZodOptional<z.ZodString>;
513
+ }, z.core.$strict>], "provider">>;
368
514
  }, z.core.$strict>, z.ZodObject<{
369
515
  platform: z.ZodLiteral<"web">;
370
516
  visibility: z.ZodEnum<{
@@ -372,7 +518,65 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
372
518
  public: "public";
373
519
  }>;
374
520
  conversationId: z.ZodString;
375
- }, z.core.$strict>], "platform">;
521
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
522
+ id: z.ZodString;
523
+ provider: z.ZodLiteral<"slack">;
524
+ teamId: z.ZodString;
525
+ channelId: z.ZodString;
526
+ threadTs: z.ZodOptional<z.ZodString>;
527
+ }, z.core.$strict>], "provider">>;
528
+ }, z.core.$strict>], "platform">, z.ZodTransform<{
529
+ platform: "slack";
530
+ teamId: string;
531
+ channelId: string;
532
+ visibility: "private" | "public";
533
+ messageTs?: string | undefined;
534
+ threadTs?: string | undefined;
535
+ } | {
536
+ platform: "local";
537
+ visibility: "private";
538
+ conversationId: string;
539
+ } | {
540
+ platform: "web";
541
+ visibility: "private" | "public";
542
+ conversationId: string;
543
+ }, {
544
+ platform: "slack";
545
+ teamId: string;
546
+ channelId: string;
547
+ visibility: "private" | "public";
548
+ messageTs?: string | undefined;
549
+ threadTs?: string | undefined;
550
+ location?: {
551
+ id: string;
552
+ provider: "slack";
553
+ teamId: string;
554
+ channelId: string;
555
+ threadTs?: string | undefined;
556
+ } | undefined;
557
+ } | {
558
+ platform: "local";
559
+ visibility: "private";
560
+ conversationId: string;
561
+ location?: {
562
+ id: string;
563
+ provider: "slack";
564
+ teamId: string;
565
+ channelId: string;
566
+ threadTs?: string | undefined;
567
+ } | undefined;
568
+ } | {
569
+ platform: "web";
570
+ visibility: "private" | "public";
571
+ conversationId: string;
572
+ location?: {
573
+ id: string;
574
+ provider: "slack";
575
+ teamId: string;
576
+ channelId: string;
577
+ threadTs?: string | undefined;
578
+ } | undefined;
579
+ }>>;
376
580
  updatedAtMs: z.ZodNumber;
377
581
  errorMessage: z.ZodString;
378
582
  status: z.ZodEnum<{
@@ -458,10 +662,6 @@ export declare const createAgentInvocationSchema: z.ZodObject<{
458
662
  platform: z.ZodLiteral<"local">;
459
663
  conversationId: z.ZodString;
460
664
  }, z.core.$strict>], "platform">;
461
- destinationVisibility: z.ZodOptional<z.ZodEnum<{
462
- private: "private";
463
- public: "public";
464
- }>>;
465
665
  idempotencyKey: z.ZodString;
466
666
  input: z.ZodString;
467
667
  parentConversationId: z.ZodString;
@@ -472,7 +672,7 @@ export declare const createAgentInvocationSchema: z.ZodObject<{
472
672
  xhigh: "xhigh";
473
673
  none: "none";
474
674
  }>>;
475
- source: z.ZodDiscriminatedUnion<[z.ZodObject<{
675
+ source: z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
476
676
  platform: z.ZodLiteral<"slack">;
477
677
  teamId: z.ZodString;
478
678
  channelId: z.ZodString;
@@ -482,10 +682,24 @@ export declare const createAgentInvocationSchema: z.ZodObject<{
482
682
  }>;
483
683
  messageTs: z.ZodOptional<z.ZodString>;
484
684
  threadTs: z.ZodOptional<z.ZodString>;
685
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
686
+ id: z.ZodString;
687
+ provider: z.ZodLiteral<"slack">;
688
+ teamId: z.ZodString;
689
+ channelId: z.ZodString;
690
+ threadTs: z.ZodOptional<z.ZodString>;
691
+ }, z.core.$strict>], "provider">>;
485
692
  }, z.core.$strict>, z.ZodObject<{
486
693
  platform: z.ZodLiteral<"local">;
487
694
  visibility: z.ZodLiteral<"private">;
488
695
  conversationId: z.ZodString;
696
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
697
+ id: z.ZodString;
698
+ provider: z.ZodLiteral<"slack">;
699
+ teamId: z.ZodString;
700
+ channelId: z.ZodString;
701
+ threadTs: z.ZodOptional<z.ZodString>;
702
+ }, z.core.$strict>], "provider">>;
489
703
  }, z.core.$strict>, z.ZodObject<{
490
704
  platform: z.ZodLiteral<"web">;
491
705
  visibility: z.ZodEnum<{
@@ -493,7 +707,65 @@ export declare const createAgentInvocationSchema: z.ZodObject<{
493
707
  public: "public";
494
708
  }>;
495
709
  conversationId: z.ZodString;
496
- }, z.core.$strict>], "platform">;
710
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
711
+ id: z.ZodString;
712
+ provider: z.ZodLiteral<"slack">;
713
+ teamId: z.ZodString;
714
+ channelId: z.ZodString;
715
+ threadTs: z.ZodOptional<z.ZodString>;
716
+ }, z.core.$strict>], "provider">>;
717
+ }, z.core.$strict>], "platform">, z.ZodTransform<{
718
+ platform: "slack";
719
+ teamId: string;
720
+ channelId: string;
721
+ visibility: "private" | "public";
722
+ messageTs?: string | undefined;
723
+ threadTs?: string | undefined;
724
+ } | {
725
+ platform: "local";
726
+ visibility: "private";
727
+ conversationId: string;
728
+ } | {
729
+ platform: "web";
730
+ visibility: "private" | "public";
731
+ conversationId: string;
732
+ }, {
733
+ platform: "slack";
734
+ teamId: string;
735
+ channelId: string;
736
+ visibility: "private" | "public";
737
+ messageTs?: string | undefined;
738
+ threadTs?: string | undefined;
739
+ location?: {
740
+ id: string;
741
+ provider: "slack";
742
+ teamId: string;
743
+ channelId: string;
744
+ threadTs?: string | undefined;
745
+ } | undefined;
746
+ } | {
747
+ platform: "local";
748
+ visibility: "private";
749
+ conversationId: string;
750
+ location?: {
751
+ id: string;
752
+ provider: "slack";
753
+ teamId: string;
754
+ channelId: string;
755
+ threadTs?: string | undefined;
756
+ } | undefined;
757
+ } | {
758
+ platform: "web";
759
+ visibility: "private" | "public";
760
+ conversationId: string;
761
+ location?: {
762
+ id: string;
763
+ provider: "slack";
764
+ teamId: string;
765
+ channelId: string;
766
+ threadTs?: string | undefined;
767
+ } | undefined;
768
+ }>>;
497
769
  }, z.core.$strict>;
498
770
  export type AgentBinding = z.output<typeof agentBindingSchema>;
499
771
  export type AgentInvocation = z.output<typeof agentInvocationSchema>;
@@ -4,26 +4,34 @@ import type { AgentRunner } from "@/chat/runtime/agent-runner";
4
4
  import type { ConversationStore } from "@/chat/conversations/store";
5
5
  import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
6
6
  import type { VercelConversationWorkCallbackOptions } from "@/chat/task-execution/vercel-callback";
7
- import { type ApiTurnCancellation } from "@/chat/api-turns/cancellation";
8
7
  import { createSlackRuntime } from "./factory";
9
8
  import type { JuniorRuntimeServiceOverrides } from "./services";
9
+ import { type ScheduleSessionCompletedPluginTasksOptions } from "@/chat/plugins/task-runner";
10
+ type SlackRuntime = ReturnType<typeof createSlackRuntime>;
10
11
  interface ConversationWorkOptions {
11
12
  agentRunner: AgentRunner;
12
13
  conversationStore: ConversationStore;
13
14
  getSlackAdapter: () => SlackAdapter;
14
15
  queue: ConversationWorkQueue;
16
+ /**
17
+ * Optional plugin-task send path for completed Turns.
18
+ * Production omits this and uses the default Vercel queue sender.
19
+ */
20
+ sendPluginTask?: ScheduleSessionCompletedPluginTasksOptions["send"];
15
21
  services?: JuniorRuntimeServiceOverrides;
16
22
  state?: StateAdapter;
23
+ /**
24
+ * Optional wrapper around the composed Slack runtime.
25
+ * Eval harnesses use this so worker Delivery lands on TestThreads.
26
+ */
27
+ wrapRuntime?: (runtime: SlackRuntime) => SlackRuntime;
17
28
  }
18
- export type ConversationWorkCallbackOptions = VercelConversationWorkCallbackOptions & {
19
- /** App-scoped Turn cancellation for Conversation API request handlers. */
20
- apiTurnCancellation?: ApiTurnCancellation;
21
- };
29
+ export type ConversationWorkCallbackOptions = VercelConversationWorkCallbackOptions;
22
30
  /**
23
- * Compose conversation work once for production and integration tests.
24
- * Environment-specific queue, state, Slack, and agent adapters stop here.
31
+ * Build conversation work once for production and integration tests.
32
+ * The app chooses the queue, state, Slack, and agent values here.
25
33
  */
26
34
  export declare function createConversationWork(options: ConversationWorkOptions): ConversationWorkCallbackOptions & {
27
- runtime: ReturnType<typeof createSlackRuntime>;
35
+ runtime: SlackRuntime;
28
36
  };
29
37
  export {};
@@ -2,21 +2,21 @@ import type { AssistantMessage, Message } from "@earendil-works/pi-ai";
2
2
  export type ConversationPrivacy = "public" | "private";
3
3
  type TraceAttributeValue = string | number | boolean | string[];
4
4
  /**
5
- * Resolve whether a conversation may expose raw payloads.
5
+ * Resolve whether a Conversation may expose full transcript and tool data.
6
6
  *
7
- * Explicit destination visibility is authoritative. Missing visibility is
8
- * observable and fails closed without inferring from identifiers.
7
+ * Read visibility from the stored Conversation. If it is missing, warn and
8
+ * treat the Conversation as private. Do not infer visibility from identifiers.
9
9
  */
10
10
  export declare function resolveConversationPrivacy(input: {
11
- /** Live or persisted destination visibility, when the caller has one. */
11
+ /** Stored Conversation visibility, when known. */
12
12
  visibility?: ConversationPrivacy | "direct" | "unknown";
13
13
  }): ConversationPrivacy;
14
- /** Gate raw transcript/tool payload exposure to public conversations. */
14
+ /** Return whether a public Conversation may expose transcript and tool data. */
15
15
  export declare function canExposeConversationPayload(input: {
16
- /** Live or persisted destination visibility, when the caller has one. */
16
+ /** Conversation visibility, when known. */
17
17
  visibility?: ConversationPrivacy | "direct" | "unknown";
18
18
  }): boolean;
19
- /** Return the privacy mode bound to the current agent turn. */
19
+ /** Return privacy for the current agent Turn. */
20
20
  export declare function getCurrentConversationPrivacy(): ConversationPrivacy | undefined;
21
21
  /** Bind one conversation privacy mode to all async work in a turn. */
22
22
  export declare function runWithConversationPrivacy<T>(privacy: ConversationPrivacy, callback: () => T): T;
@@ -0,0 +1,12 @@
1
+ import { type Destination } from "@sentry/junior-plugin-api";
2
+ /**
3
+ * Keep a stored Destination, or create the temporary local Destination.
4
+ *
5
+ * TODO(dcramer): Delete this module after Conversation and AgentRun use
6
+ * Location, and web and resource-event Turns no longer need a local
7
+ * Destination.
8
+ */
9
+ export declare function resolveConversationDestination(args: {
10
+ conversationId: string;
11
+ existing?: Destination;
12
+ }): Destination;
@@ -1,10 +1,5 @@
1
- import { z } from "zod";
2
- /** One place outside Junior where a Conversation can be delivered. */
3
- export declare const locationSchema: z.ZodObject<{
4
- id: z.ZodString;
5
- provider: z.ZodString;
6
- tenantId: z.ZodOptional<z.ZodString>;
7
- providerId: z.ZodString;
8
- }, z.core.$strict>;
1
+ import { locationSchema } from "@sentry/junior-plugin-api";
2
+ import type { z } from "zod";
3
+ export { locationSchema };
9
4
  /** Validated Location associated with a Conversation. */
10
5
  export type Location = z.output<typeof locationSchema>;