@sentry/junior 0.188.0 → 0.190.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 (115) hide show
  1. package/dist/{agent-hooks-5RQEVLQD.js → agent-hooks-3IG2FQW2.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 +44 -55
  6. package/dist/app.d.ts +1 -1
  7. package/dist/app.js +1025 -349
  8. package/dist/{catalog-runtime-L4A6BJ3U.js → catalog-runtime-2OT7S3ZC.js} +4 -4
  9. package/dist/chat/actor.d.ts +7 -2
  10. package/dist/chat/agent/resume.d.ts +0 -2
  11. package/dist/chat/agent/types.d.ts +8 -9
  12. package/dist/chat/agent-dispatch/work.d.ts +1 -10
  13. package/dist/chat/agent-invocations/spawn.d.ts +1 -1
  14. package/dist/chat/agent-invocations/types.d.ts +44 -108
  15. package/dist/chat/app/conversation-work.d.ts +16 -8
  16. package/dist/chat/conversation-privacy.d.ts +7 -7
  17. package/dist/chat/conversations/destination.d.ts +12 -0
  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 +4 -4
  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/event-tasks/tool-support.d.ts +1 -7
  27. package/dist/chat/providers/slack/runtime.d.ts +1 -0
  28. package/dist/chat/providers/slack/system-turn.d.ts +8 -0
  29. package/dist/chat/resource-events/actor.d.ts +13 -12
  30. package/dist/chat/resource-events/notification.d.ts +1 -1
  31. package/dist/chat/services/guardian-action-policy.d.ts +1 -1
  32. package/dist/chat/services/turn-session-routing.d.ts +2 -2
  33. package/dist/chat/source.d.ts +3 -3
  34. package/dist/chat/task-execution/assistant-message.d.ts +32 -0
  35. package/dist/chat/task-execution/conversation-turn.d.ts +8 -0
  36. package/dist/chat/{api-turns → task-execution}/mailbox-input.d.ts +1 -2
  37. package/dist/chat/task-execution/mailbox-turn.d.ts +52 -0
  38. package/dist/chat/task-execution/paused-turn.d.ts +1 -1
  39. package/dist/chat/task-execution/slack-work.d.ts +0 -2
  40. package/dist/chat/task-execution/state.d.ts +2 -2
  41. package/dist/chat/task-execution/store.d.ts +1 -1
  42. package/dist/chat/task-execution/turn-cursor.d.ts +10 -1
  43. package/dist/chat/tools/types.d.ts +9 -2
  44. package/dist/{chunk-XJIPMHKI.js → chunk-2MKHYSYL.js} +3 -3
  45. package/dist/{chunk-QCGNHSMA.js → chunk-2MRF22J4.js} +25 -10
  46. package/dist/{chunk-HCIVBCP5.js → chunk-3J3BCB4J.js} +1 -1
  47. package/dist/chunk-4BLFIYVK.js +703 -0
  48. package/dist/{chunk-NZLZ4KYZ.js → chunk-4PKEJK5B.js} +1 -1
  49. package/dist/{chunk-VFZAUQ5V.js → chunk-62DRKZQU.js} +5 -183
  50. package/dist/{chunk-QIOUTXTZ.js → chunk-663DQH5W.js} +1 -1
  51. package/dist/{chunk-Z5SKZE5B.js → chunk-67MMSYSE.js} +4 -12
  52. package/dist/{chunk-ZX7RSBQ6.js → chunk-6BXUSF7J.js} +1 -1
  53. package/dist/{chunk-W42ENMJW.js → chunk-6H7YU6XH.js} +1 -1
  54. package/dist/{chunk-WGZJ5SU4.js → chunk-7UJ6IJCK.js} +1 -1
  55. package/dist/{chunk-QDHJTKPE.js → chunk-7Y7XMI6P.js} +8 -6
  56. package/dist/{chunk-6YGFBU3A.js → chunk-BGOLRC36.js} +62 -336
  57. package/dist/{chunk-CVBDVIF4.js → chunk-BUJU6C2J.js} +1 -1
  58. package/dist/{chunk-XI4PVY2T.js → chunk-CZXZKTAI.js} +5 -5
  59. package/dist/chunk-DA2KGZZI.js +13 -0
  60. package/dist/{chunk-RMB7CERI.js → chunk-DJZGQ7OL.js} +311 -137
  61. package/dist/{chunk-FIUCHYT6.js → chunk-DVX6U6GI.js} +1 -1
  62. package/dist/{chunk-AW77HH54.js → chunk-ECOR3OXY.js} +19 -299
  63. package/dist/{chunk-WW2Y7JIA.js → chunk-F3K2267N.js} +51 -50
  64. package/dist/{chunk-W2DDJCPS.js → chunk-FVFJ57RK.js} +8 -8
  65. package/dist/{chunk-UVUXFRYN.js → chunk-GWCFXTB6.js} +211 -7
  66. package/dist/{chunk-X55FOVZO.js → chunk-HI5KXE3C.js} +3 -3
  67. package/dist/{chunk-ERZMACYA.js → chunk-IRQ3RSX3.js} +3 -3
  68. package/dist/{chunk-32XSSFZV.js → chunk-JV7U4665.js} +1 -1
  69. package/dist/chunk-MNHJ4WLE.js +285 -0
  70. package/dist/{chunk-SC67CH3C.js → chunk-OJFX2FP7.js} +14 -17
  71. package/dist/{chunk-IUUQWIG2.js → chunk-OKAHLUSU.js} +70 -19
  72. package/dist/{chunk-PSHMPRIU.js → chunk-OON4IQHH.js} +2 -2
  73. package/dist/{chunk-6JZGXLL2.js → chunk-OYCOLHCR.js} +5 -7
  74. package/dist/{chunk-3HEZWDS5.js → chunk-REVH4BZU.js} +2 -2
  75. package/dist/{chunk-CDSLOYOR.js → chunk-RLYJYEIY.js} +6 -6
  76. package/dist/{chunk-CZRWU4ZM.js → chunk-T66GV7A3.js} +2 -5
  77. package/dist/{chunk-Q7O74WOO.js → chunk-VWNIDTFR.js} +2 -2
  78. package/dist/{chunk-CIG6WI7Q.js → chunk-W2C4TPLB.js} +5 -5
  79. package/dist/{chunk-QIMN3FXL.js → chunk-Y4WL4OYD.js} +1 -1
  80. package/dist/{chunk-MQDIIFZM.js → chunk-YFU4DGZY.js} +12 -5
  81. package/dist/chunk-YKIAUKYH.js +311 -0
  82. package/dist/{chunk-QVH6FW3T.js → chunk-ZFCO2TMB.js} +7 -3
  83. package/dist/cli/chat.js +34 -33
  84. package/dist/cli/check.js +5 -5
  85. package/dist/cli/plugins.js +12 -12
  86. package/dist/cli/snapshot-create.js +9 -9
  87. package/dist/cli/upgrade.js +6 -6
  88. package/dist/db/schema/agent-invocations.d.ts +18 -42
  89. package/dist/db/schema/conversations.d.ts +62 -0
  90. package/dist/db/schema.d.ts +49 -42
  91. package/dist/{db-YPRZAA2T.js → db-2IFDMDDY.js} +6 -6
  92. package/dist/instrumentation.js +3 -3
  93. package/dist/nitro.js +6 -6
  94. package/dist/{oauth-callback-server-DBBIR3XG.js → oauth-callback-server-SZSS2KH6.js} +30 -28
  95. package/dist/{runner-FKVFFPLO.js → runner-2N4QU77X.js} +25 -21
  96. package/dist/{skills-4RBAZEMV.js → skills-VU2LZAKX.js} +5 -5
  97. package/dist/spawn-3K7RV4T5.js +42 -0
  98. package/dist/task-runner-52DYFHW3.js +36 -0
  99. package/dist/{validation-E6Z5LHZM.js → validation-IJGHK7NI.js} +5 -5
  100. package/dist/version.js +1 -1
  101. package/dist/{work-OFTXWOK4.js → work-DI45MLRL.js} +22 -21
  102. package/dist/{worker-OMWNOKTJ.js → worker-FY7KWG2M.js} +10 -10
  103. package/migrations/0037_conversation_location.sql +23 -0
  104. package/migrations/meta/0037_snapshot.json +3192 -0
  105. package/migrations/meta/_journal.json +7 -0
  106. package/package.json +4 -4
  107. package/dist/chat/api-turns/assistant-message.d.ts +0 -12
  108. package/dist/chat/api-turns/cancellation.d.ts +0 -24
  109. package/dist/chat/api-turns/routing.d.ts +0 -51
  110. package/dist/chat/api-turns/work.d.ts +0 -99
  111. package/dist/chat/task-execution/slack-resource-event.d.ts +0 -55
  112. package/dist/chunk-6FGN7ZEG.js +0 -221
  113. package/dist/chunk-LODJKINF.js +0 -1502
  114. package/dist/spawn-CO7QFCNJ.js +0 -41
  115. package/dist/task-runner-DUGZGI7V.js +0 -34
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-NZLZ4KYZ.js";
4
- import "./chunk-QIOUTXTZ.js";
3
+ } from "./chunk-4PKEJK5B.js";
4
+ import "./chunk-663DQH5W.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-QIMN3FXL.js";
9
+ import "./chunk-Y4WL4OYD.js";
10
10
  import "./chunk-PEQXYSSE.js";
11
- import "./chunk-32XSSFZV.js";
11
+ import "./chunk-JV7U4665.js";
12
12
  export {
13
13
  pluginCatalogRuntime
14
14
  };
@@ -69,9 +69,14 @@ export declare function createSlackActor(teamId: string, userId: string, profile
69
69
  export declare function parseStoredSlackActor(value: unknown): StoredSlackActor | undefined;
70
70
  /** Convert a runtime Slack actor into its durable session shape. */
71
71
  export declare function toStoredSlackActor(actor: SlackActor): StoredSlackActor;
72
- /** Resolve a Slack resume actor from stored profile data and the active actor. */
72
+ /**
73
+ * Resolve a Slack resume actor from stored profile data and the active actor.
74
+ *
75
+ * TODO(dcramer): Require Actor and remove ID-only construction after no
76
+ * deployed Turn cursor can omit Actor.
77
+ */
73
78
  export declare function createSlackResumeActor(args: {
74
- actor?: UserActor;
79
+ actor?: Actor;
75
80
  teamId: string;
76
81
  userId: string;
77
82
  }): SlackActor;
@@ -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>;
@@ -2,7 +2,6 @@
2
2
  import type { Destination, ReplyAttribution, Source, SystemActor } from "@sentry/junior-plugin-api";
3
3
  import type { Location } from "@/chat/conversations/location";
4
4
  import type { LocationConfigurationService } from "@/chat/configuration/types";
5
- import type { ConversationPrivacy } from "@/chat/conversation-privacy";
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,13 +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 Delivery = {
106
- /** Location where this capability can send output, when outside Junior. */
107
- location?: Location;
108
- /** Send one accepted assistant message. */
109
- send(message: AssistantMessage): void | Promise<void>;
110
- };
108
+ export type Delivery = (message: AssistantMessage) => void | Promise<void>;
111
109
  /** Resume the agent turn after a transient or ambiguous delivery failure. */
112
110
  export declare class RetryableDeliveryError extends Error {
113
111
  constructor(cause: unknown);
@@ -178,9 +176,10 @@ export type AgentRun = {
178
176
  /** Credential authority projected from actor (plus optional subject). */
179
177
  credentialContext?: CredentialContext;
180
178
  source: Source;
179
+ /** Conversation Location available to this Run. */
180
+ location?: Location;
181
181
  destination: Destination;
182
182
  publishExternally?: boolean;
183
- destinationVisibility?: ConversationPrivacy;
184
183
  surface?: AgentTurnSurface;
185
184
  dispatch?: AgentDispatch;
186
185
  /**
@@ -219,7 +218,7 @@ export declare function isAgentRunFeatureDisabled(disabledFeatures: readonly Age
219
218
  /** Resolve the explicit actor, dispatch actor, or credential actor for this run. */
220
219
  export declare function actorFromRun(run: Pick<AgentRun, "actor" | "dispatch" | "credentialContext">): Actor | undefined;
221
220
  /** Reject contradictory provider coordinates before the run touches state. */
222
- 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;
223
222
  /** Route tool side effects to the tool channel when one overrides the destination. */
224
223
  export declare function toolInvocationDestination(run: Pick<AgentRun, "destination" | "toolChannelId">): Destination;
225
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,16 +99,10 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
103
99
  xhigh: "xhigh";
104
100
  none: "none";
105
101
  }>>;
106
- source: z.ZodDiscriminatedUnion<[z.ZodObject<{
107
- platform: z.ZodLiteral<"slack">;
102
+ source: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
103
+ kind: z.ZodLiteral<"slack">;
108
104
  teamId: z.ZodString;
109
105
  channelId: z.ZodString;
110
- location: z.ZodOptional<z.ZodObject<{
111
- id: z.ZodString;
112
- provider: z.ZodString;
113
- tenantId: z.ZodOptional<z.ZodString>;
114
- providerId: z.ZodString;
115
- }, z.core.$strict>>;
116
106
  visibility: z.ZodEnum<{
117
107
  private: "private";
118
108
  public: "public";
@@ -120,29 +110,23 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
120
110
  messageTs: z.ZodOptional<z.ZodString>;
121
111
  threadTs: z.ZodOptional<z.ZodString>;
122
112
  }, z.core.$strict>, z.ZodObject<{
123
- location: z.ZodOptional<z.ZodObject<{
124
- id: z.ZodString;
125
- provider: z.ZodString;
126
- tenantId: z.ZodOptional<z.ZodString>;
127
- providerId: z.ZodString;
128
- }, z.core.$strict>>;
129
- platform: z.ZodLiteral<"local">;
113
+ kind: z.ZodLiteral<"local">;
130
114
  visibility: z.ZodLiteral<"private">;
131
115
  conversationId: z.ZodString;
132
116
  }, z.core.$strict>, z.ZodObject<{
133
- location: z.ZodOptional<z.ZodObject<{
134
- id: z.ZodString;
135
- provider: z.ZodString;
136
- tenantId: z.ZodOptional<z.ZodString>;
137
- providerId: z.ZodString;
138
- }, z.core.$strict>>;
139
- platform: z.ZodLiteral<"web">;
117
+ kind: z.ZodLiteral<"web">;
140
118
  visibility: z.ZodEnum<{
141
119
  private: "private";
142
120
  public: "public";
143
121
  }>;
144
122
  conversationId: z.ZodString;
145
- }, z.core.$strict>], "platform">;
123
+ }, z.core.$strict>, z.ZodObject<{
124
+ kind: z.ZodLiteral<"resource_event">;
125
+ eventKey: z.ZodString;
126
+ eventType: z.ZodString;
127
+ identifier: z.ZodString;
128
+ namespace: z.ZodString;
129
+ }, z.core.$strict>], "kind">>;
146
130
  updatedAtMs: z.ZodNumber;
147
131
  status: z.ZodEnum<{
148
132
  pending: "pending";
@@ -228,10 +212,6 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
228
212
  platform: z.ZodLiteral<"local">;
229
213
  conversationId: z.ZodString;
230
214
  }, z.core.$strict>], "platform">;
231
- destinationVisibility: z.ZodOptional<z.ZodEnum<{
232
- private: "private";
233
- public: "public";
234
- }>>;
235
215
  input: z.ZodString;
236
216
  invocationId: z.ZodString;
237
217
  mailboxStatus: z.ZodEnum<{
@@ -246,16 +226,10 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
246
226
  xhigh: "xhigh";
247
227
  none: "none";
248
228
  }>>;
249
- source: z.ZodDiscriminatedUnion<[z.ZodObject<{
250
- platform: z.ZodLiteral<"slack">;
229
+ source: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
230
+ kind: z.ZodLiteral<"slack">;
251
231
  teamId: z.ZodString;
252
232
  channelId: z.ZodString;
253
- location: z.ZodOptional<z.ZodObject<{
254
- id: z.ZodString;
255
- provider: z.ZodString;
256
- tenantId: z.ZodOptional<z.ZodString>;
257
- providerId: z.ZodString;
258
- }, z.core.$strict>>;
259
233
  visibility: z.ZodEnum<{
260
234
  private: "private";
261
235
  public: "public";
@@ -263,29 +237,23 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
263
237
  messageTs: z.ZodOptional<z.ZodString>;
264
238
  threadTs: z.ZodOptional<z.ZodString>;
265
239
  }, z.core.$strict>, z.ZodObject<{
266
- location: z.ZodOptional<z.ZodObject<{
267
- id: z.ZodString;
268
- provider: z.ZodString;
269
- tenantId: z.ZodOptional<z.ZodString>;
270
- providerId: z.ZodString;
271
- }, z.core.$strict>>;
272
- platform: z.ZodLiteral<"local">;
240
+ kind: z.ZodLiteral<"local">;
273
241
  visibility: z.ZodLiteral<"private">;
274
242
  conversationId: z.ZodString;
275
243
  }, z.core.$strict>, z.ZodObject<{
276
- location: z.ZodOptional<z.ZodObject<{
277
- id: z.ZodString;
278
- provider: z.ZodString;
279
- tenantId: z.ZodOptional<z.ZodString>;
280
- providerId: z.ZodString;
281
- }, z.core.$strict>>;
282
- platform: z.ZodLiteral<"web">;
244
+ kind: z.ZodLiteral<"web">;
283
245
  visibility: z.ZodEnum<{
284
246
  private: "private";
285
247
  public: "public";
286
248
  }>;
287
249
  conversationId: z.ZodString;
288
- }, z.core.$strict>], "platform">;
250
+ }, z.core.$strict>, z.ZodObject<{
251
+ kind: z.ZodLiteral<"resource_event">;
252
+ eventKey: z.ZodString;
253
+ eventType: z.ZodString;
254
+ identifier: z.ZodString;
255
+ namespace: z.ZodString;
256
+ }, z.core.$strict>], "kind">>;
289
257
  updatedAtMs: z.ZodNumber;
290
258
  result: z.ZodString;
291
259
  status: z.ZodLiteral<"completed">;
@@ -369,10 +337,6 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
369
337
  platform: z.ZodLiteral<"local">;
370
338
  conversationId: z.ZodString;
371
339
  }, z.core.$strict>], "platform">;
372
- destinationVisibility: z.ZodOptional<z.ZodEnum<{
373
- private: "private";
374
- public: "public";
375
- }>>;
376
340
  input: z.ZodString;
377
341
  invocationId: z.ZodString;
378
342
  mailboxStatus: z.ZodEnum<{
@@ -387,16 +351,10 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
387
351
  xhigh: "xhigh";
388
352
  none: "none";
389
353
  }>>;
390
- source: z.ZodDiscriminatedUnion<[z.ZodObject<{
391
- platform: z.ZodLiteral<"slack">;
354
+ source: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
355
+ kind: z.ZodLiteral<"slack">;
392
356
  teamId: z.ZodString;
393
357
  channelId: z.ZodString;
394
- location: z.ZodOptional<z.ZodObject<{
395
- id: z.ZodString;
396
- provider: z.ZodString;
397
- tenantId: z.ZodOptional<z.ZodString>;
398
- providerId: z.ZodString;
399
- }, z.core.$strict>>;
400
358
  visibility: z.ZodEnum<{
401
359
  private: "private";
402
360
  public: "public";
@@ -404,29 +362,23 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
404
362
  messageTs: z.ZodOptional<z.ZodString>;
405
363
  threadTs: z.ZodOptional<z.ZodString>;
406
364
  }, z.core.$strict>, z.ZodObject<{
407
- location: z.ZodOptional<z.ZodObject<{
408
- id: z.ZodString;
409
- provider: z.ZodString;
410
- tenantId: z.ZodOptional<z.ZodString>;
411
- providerId: z.ZodString;
412
- }, z.core.$strict>>;
413
- platform: z.ZodLiteral<"local">;
365
+ kind: z.ZodLiteral<"local">;
414
366
  visibility: z.ZodLiteral<"private">;
415
367
  conversationId: z.ZodString;
416
368
  }, z.core.$strict>, z.ZodObject<{
417
- location: z.ZodOptional<z.ZodObject<{
418
- id: z.ZodString;
419
- provider: z.ZodString;
420
- tenantId: z.ZodOptional<z.ZodString>;
421
- providerId: z.ZodString;
422
- }, z.core.$strict>>;
423
- platform: z.ZodLiteral<"web">;
369
+ kind: z.ZodLiteral<"web">;
424
370
  visibility: z.ZodEnum<{
425
371
  private: "private";
426
372
  public: "public";
427
373
  }>;
428
374
  conversationId: z.ZodString;
429
- }, z.core.$strict>], "platform">;
375
+ }, z.core.$strict>, z.ZodObject<{
376
+ kind: z.ZodLiteral<"resource_event">;
377
+ eventKey: z.ZodString;
378
+ eventType: z.ZodString;
379
+ identifier: z.ZodString;
380
+ namespace: z.ZodString;
381
+ }, z.core.$strict>], "kind">>;
430
382
  updatedAtMs: z.ZodNumber;
431
383
  errorMessage: z.ZodString;
432
384
  status: z.ZodEnum<{
@@ -512,10 +464,6 @@ export declare const createAgentInvocationSchema: z.ZodObject<{
512
464
  platform: z.ZodLiteral<"local">;
513
465
  conversationId: z.ZodString;
514
466
  }, z.core.$strict>], "platform">;
515
- destinationVisibility: z.ZodOptional<z.ZodEnum<{
516
- private: "private";
517
- public: "public";
518
- }>>;
519
467
  idempotencyKey: z.ZodString;
520
468
  input: z.ZodString;
521
469
  parentConversationId: z.ZodString;
@@ -526,16 +474,10 @@ export declare const createAgentInvocationSchema: z.ZodObject<{
526
474
  xhigh: "xhigh";
527
475
  none: "none";
528
476
  }>>;
529
- source: z.ZodDiscriminatedUnion<[z.ZodObject<{
530
- platform: z.ZodLiteral<"slack">;
477
+ source: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
478
+ kind: z.ZodLiteral<"slack">;
531
479
  teamId: z.ZodString;
532
480
  channelId: z.ZodString;
533
- location: z.ZodOptional<z.ZodObject<{
534
- id: z.ZodString;
535
- provider: z.ZodString;
536
- tenantId: z.ZodOptional<z.ZodString>;
537
- providerId: z.ZodString;
538
- }, z.core.$strict>>;
539
481
  visibility: z.ZodEnum<{
540
482
  private: "private";
541
483
  public: "public";
@@ -543,29 +485,23 @@ export declare const createAgentInvocationSchema: z.ZodObject<{
543
485
  messageTs: z.ZodOptional<z.ZodString>;
544
486
  threadTs: z.ZodOptional<z.ZodString>;
545
487
  }, z.core.$strict>, z.ZodObject<{
546
- location: z.ZodOptional<z.ZodObject<{
547
- id: z.ZodString;
548
- provider: z.ZodString;
549
- tenantId: z.ZodOptional<z.ZodString>;
550
- providerId: z.ZodString;
551
- }, z.core.$strict>>;
552
- platform: z.ZodLiteral<"local">;
488
+ kind: z.ZodLiteral<"local">;
553
489
  visibility: z.ZodLiteral<"private">;
554
490
  conversationId: z.ZodString;
555
491
  }, z.core.$strict>, z.ZodObject<{
556
- location: z.ZodOptional<z.ZodObject<{
557
- id: z.ZodString;
558
- provider: z.ZodString;
559
- tenantId: z.ZodOptional<z.ZodString>;
560
- providerId: z.ZodString;
561
- }, z.core.$strict>>;
562
- platform: z.ZodLiteral<"web">;
492
+ kind: z.ZodLiteral<"web">;
563
493
  visibility: z.ZodEnum<{
564
494
  private: "private";
565
495
  public: "public";
566
496
  }>;
567
497
  conversationId: z.ZodString;
568
- }, z.core.$strict>], "platform">;
498
+ }, z.core.$strict>, z.ZodObject<{
499
+ kind: z.ZodLiteral<"resource_event">;
500
+ eventKey: z.ZodString;
501
+ eventType: z.ZodString;
502
+ identifier: z.ZodString;
503
+ namespace: z.ZodString;
504
+ }, z.core.$strict>], "kind">>;
569
505
  }, z.core.$strict>;
570
506
  export type AgentBinding = z.output<typeof agentBindingSchema>;
571
507
  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;
@@ -3,7 +3,7 @@ import { type ConversationMessageProvenance } from "@/chat/conversations/provena
3
3
  import type { AuthorizationKind, ConversationEvent } from "@/chat/conversations/history";
4
4
  import type { RepositoryInstructions } from "@/chat/repository-instructions";
5
5
  import type { JuniorSqlDatabase } from "@/db/db";
6
- import { type ProviderConversationBinding } from "@/chat/conversations/sql/bindings";
6
+ import { type ProviderConversationReference } from "@/chat/conversations/sql/bindings";
7
7
  import { type PiConversationEventProjection, type PiConversationProjection } from "@/chat/pi/conversation-events";
8
8
  import type { ModelProfile } from "@/chat/model-profile";
9
9
  import type { TurnReasoningLevel } from "@/chat/reasoning-level";
@@ -90,7 +90,7 @@ export declare function commitAcceptedReply(args: {
90
90
  conversation: ThreadConversationState;
91
91
  conversationMessageId: string;
92
92
  conversationId: string;
93
- providerConversationBindings?: Array<Omit<ProviderConversationBinding, "conversationId">>;
93
+ providerConversationBindings?: ProviderConversationReference[];
94
94
  repliedAtMs?: number;
95
95
  }): Promise<void>;
96
96
  /** Record a successful MCP provider connection for one credential subject without duplicating it. */
@@ -1,9 +1,18 @@
1
+ import type { Destination } from "@sentry/junior-plugin-api";
1
2
  import type { ConversationPrivacy } from "@/chat/conversation-privacy";
2
3
  import { type Location } from "@/chat/conversations/location";
4
+ import type { SessionSource } from "@/chat/source";
3
5
  import type { juniorDestinations } from "@/db/schema";
4
6
  type LocationRow = typeof juniorDestinations.$inferSelect;
5
- /** Project one supported provider location from its linked SQL row. */
6
- export declare function locationFromRow(row: LocationRow | null): Location | undefined;
7
- /** Resolve conversation privacy from one linked provider-location row. */
8
- export declare function privacyFromLocationRow(row: LocationRow | null): ConversationPrivacy | undefined;
7
+ /** Build the complete Location for one Conversation SQL write. */
8
+ export declare function locationForWrite(args: {
9
+ destination: Destination | undefined;
10
+ destinationId: string | undefined;
11
+ location: Location | undefined;
12
+ sessionSource: SessionSource | undefined;
13
+ }): Location | undefined;
14
+ /** Read one complete Location from SQL. */
15
+ export declare function locationFromRow(value: unknown, row: LocationRow | null, sessionSource: SessionSource | undefined): Location | undefined;
16
+ /** Read confirmed visibility from one linked Location row. */
17
+ export declare function visibilityFromLocationRow(row: LocationRow | null): ConversationPrivacy | undefined;
9
18
  export {};
@@ -2,8 +2,8 @@ import type { StateAdapter } from "chat";
2
2
  import type { ConversationStore } from "@/chat/conversations/store";
3
3
  import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
4
4
  import { type StopConversationWorkResult } from "@/chat/task-execution/store";
5
- /** Stop the current API Turn and wake an idle durable resume when needed. */
6
- export declare function stopApiConversationTurn(args: {
5
+ /** Stop the current Conversation Turn and wake an idle resume when needed. */
6
+ export declare function stopConversationTurn(args: {
7
7
  conversationId: string;
8
8
  conversationStore?: ConversationStore;
9
9
  nowMs?: number;
@@ -18,9 +18,9 @@ export interface ConversationExecution {
18
18
  *
19
19
  * The final interface stores zero or one complete Location here. No Location
20
20
  * means the Conversation stays in Junior's API and UI. A Location names the
21
- * outside place where a provider can deliver the Conversation. Source may also
22
- * contain this Location so the agent can use it. Delivery contains it when
23
- * output may be sent there. Only Delivery allows output to be sent.
21
+ * outside place where a provider can deliver the Conversation. A Run carries
22
+ * this Location when the agent or tools need it. Source stays about the input.
23
+ * Delivery is created for the Location and allows output to be sent there.
24
24
  *
25
25
  * `destination` and `sessionSource` temporarily duplicate parts of that model.
26
26
  * Their field TODOs state when each legacy copy can be removed.
@@ -58,7 +58,7 @@ export interface Conversation {
58
58
  * rather than privacy-redacted (`../../../../../policies/data-redaction.md`).
59
59
  */
60
60
  transcriptPurgedAtMs?: number;
61
- /** Persisted destination visibility. Undefined means no destination row exists. */
61
+ /** Confirmed Conversation visibility. Undefined means no confirmation exists. */
62
62
  visibility?: ConversationPrivacy;
63
63
  }
64
64
  /** Persist and read durable conversation metadata for reporting surfaces. */
@@ -19,7 +19,7 @@ export declare const authenticationUnlinkedEvent: import("@sentry/junior-plugin-
19
19
  }>;
20
20
  /** Junior-owned AGENTS.md bootstrap transition for the dashboard timeline. */
21
21
  export declare const agentsInstructionsUpdatedEvent: import("@sentry/junior-plugin-api").DefinedConversationEvent<{
22
- action: "loaded" | "replaced" | "cleared";
22
+ action: "cleared" | "loaded" | "replaced";
23
23
  fingerprint: string;
24
24
  sources: {
25
25
  content: string;
@@ -1,4 +1,5 @@
1
1
  import type { OAuthAuthorizationRequest } from "@/chat/oauth-authorization";
2
+ /** Pending web authorization saved for one Actor and Conversation. */
2
3
  export interface WebAuthorizationState extends OAuthAuthorizationRequest {
3
4
  actorId: string;
4
5
  conversationId: string;