@sentry/junior 0.184.0 → 0.186.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 (129) hide show
  1. package/dist/{agent-hooks-XTZVALGQ.js → agent-hooks-4B3Z4WRK.js} +13 -11
  2. package/dist/api/acp/schema.d.ts +20 -2
  3. package/dist/api/code/overview.d.ts +39 -0
  4. package/dist/api/locations/detail.d.ts +1 -1
  5. package/dist/api/people/code.d.ts +22 -0
  6. package/dist/api/schema/code.d.ts +46 -0
  7. package/dist/api/schema/conversation.d.ts +108 -20
  8. package/dist/api/schema/location.d.ts +1 -1
  9. package/dist/api/schema/person.d.ts +1 -1
  10. package/dist/api/schema.d.ts +4 -4
  11. package/dist/api/schema.js +12 -1
  12. package/dist/api.js +368 -78
  13. package/dist/app.js +1412 -538
  14. package/dist/{catalog-runtime-5357XR4F.js → catalog-runtime-AFJCAOHC.js} +4 -4
  15. package/dist/chat/api-turns/accepted-reply.d.ts +11 -0
  16. package/dist/chat/api-turns/cancellation.d.ts +3 -5
  17. package/dist/chat/api-turns/mailbox-input.d.ts +7 -0
  18. package/dist/chat/api-turns/routing.d.ts +18 -3
  19. package/dist/chat/api-turns/work.d.ts +4 -9
  20. package/dist/chat/app/conversation-work.d.ts +1 -1
  21. package/dist/chat/app/factory.d.ts +4 -0
  22. package/dist/chat/app/services.d.ts +4 -3
  23. package/dist/chat/conversations/history.d.ts +83 -9
  24. package/dist/chat/conversations/turn-lifecycle.d.ts +6 -3
  25. package/dist/chat/providers/slack/input.d.ts +32 -0
  26. package/dist/chat/{runtime → providers/slack}/processing-reaction.d.ts +6 -8
  27. package/dist/chat/{runtime/slack-resume.d.ts → providers/slack/resume.d.ts} +16 -19
  28. package/dist/chat/providers/slack/runtime.d.ts +1 -12
  29. package/dist/chat/providers/slack/turn.d.ts +10 -25
  30. package/dist/chat/resource-events/actor.d.ts +7 -2
  31. package/dist/chat/resource-events/app-publisher.d.ts +18 -0
  32. package/dist/chat/resource-events/catalog.d.ts +19 -0
  33. package/dist/chat/resource-events/ingest.d.ts +0 -1
  34. package/dist/chat/resource-events/notification.d.ts +28 -3
  35. package/dist/chat/resource-events/runtime-catalog.d.ts +7 -2
  36. package/dist/chat/resource-events/store.d.ts +2 -14
  37. package/dist/chat/resource-events/tool-support.d.ts +0 -5
  38. package/dist/chat/resource-events/workspace.d.ts +7 -3
  39. package/dist/chat/runtime/turn-execution.d.ts +7 -2
  40. package/dist/chat/sandbox/egress/credentials.d.ts +5 -4
  41. package/dist/chat/sandbox/egress/session.d.ts +10 -11
  42. package/dist/chat/sandbox/errors.d.ts +1 -1
  43. package/dist/chat/sandbox/ref.d.ts +1 -1
  44. package/dist/chat/sandbox/snapshot/events.d.ts +8 -1
  45. package/dist/chat/sandbox/snapshot/not-ready-error.d.ts +6 -1
  46. package/dist/chat/scheduled-tasks/tool-support.d.ts +5 -5
  47. package/dist/chat/scheduled-tasks/tools/create.d.ts +2 -2
  48. package/dist/chat/scheduled-tasks/tools/delete.d.ts +2 -2
  49. package/dist/chat/scheduled-tasks/tools/list.d.ts +2 -2
  50. package/dist/chat/scheduled-tasks/tools/run-now.d.ts +2 -2
  51. package/dist/chat/scheduled-tasks/tools/update.d.ts +2 -2
  52. package/dist/chat/scheduled-tasks/types.d.ts +1 -1
  53. package/dist/chat/sentry-links.d.ts +2 -0
  54. package/dist/chat/services/provider-retry.d.ts +2 -0
  55. package/dist/chat/services/turn-failure-response.d.ts +4 -0
  56. package/dist/chat/services/turn-session-routing.d.ts +20 -5
  57. package/dist/chat/task-execution/paused-turn.d.ts +0 -2
  58. package/dist/chat/task-execution/slack-resource-event.d.ts +47 -0
  59. package/dist/chat/task-execution/slack-work.d.ts +0 -21
  60. package/dist/chat/task-execution/state.d.ts +2 -2
  61. package/dist/chat/task-execution/store.d.ts +1 -1
  62. package/dist/chat/task-execution/turn-wake.d.ts +12 -0
  63. package/dist/chat/tool-support/action-review.d.ts +1 -1
  64. package/dist/chat/tools/event-tasks.d.ts +1 -1
  65. package/dist/chat/tools/resource-events.d.ts +2 -2
  66. package/dist/chat/tools/search-conversation-events.d.ts +1 -1
  67. package/dist/chat/tools/types.d.ts +1 -1
  68. package/dist/chat/tools/watch-resource-events.d.ts +2 -2
  69. package/dist/{chunk-Z3QAXJR7.js → chunk-2IBDVE62.js} +12 -9
  70. package/dist/{chunk-4RONS3WR.js → chunk-2U7EPTRZ.js} +11 -5
  71. package/dist/{chunk-3S7ULUWW.js → chunk-3CVEE6LA.js} +1 -1
  72. package/dist/{chunk-IZDYYYGP.js → chunk-43LODHJM.js} +24 -384
  73. package/dist/{chunk-LHXIZLFF.js → chunk-64WF2GQ3.js} +1 -1
  74. package/dist/{chunk-YKX6MTLU.js → chunk-7EOWT62G.js} +1 -1
  75. package/dist/{chunk-UBOIHNTH.js → chunk-7EU4YSZ4.js} +362 -188
  76. package/dist/{chunk-UF6BUA5W.js → chunk-ACGWTJ74.js} +3 -3
  77. package/dist/{chunk-6UDPINOX.js → chunk-AD64YMEC.js} +19 -44
  78. package/dist/{chunk-MLSQX2EX.js → chunk-BRKB5R7P.js} +1 -1
  79. package/dist/{chunk-E57WPXWY.js → chunk-CM6RTYSO.js} +5 -5
  80. package/dist/{chunk-MAPJFUMV.js → chunk-CV5CPRVG.js} +3 -3
  81. package/dist/chunk-D4YV5TDV.js +45 -0
  82. package/dist/{chunk-HIPUIPJM.js → chunk-DHYZ4VKG.js} +383 -254
  83. package/dist/{chunk-DUKIDPF6.js → chunk-DOP3FIQC.js} +1 -1
  84. package/dist/{chunk-BT53RIGJ.js → chunk-EWRPUXE3.js} +12 -50
  85. package/dist/{chunk-BHYRYYLY.js → chunk-FFYDRLXW.js} +1 -1
  86. package/dist/chunk-GFBR4S3Q.js +406 -0
  87. package/dist/chunk-GQMQCY7H.js +58 -0
  88. package/dist/{chunk-JNO2GUDS.js → chunk-GSB3NTNS.js} +926 -1856
  89. package/dist/{chunk-2ZQPVX7C.js → chunk-H7X2G2KS.js} +25 -12
  90. package/dist/{chunk-WQFEWULF.js → chunk-HKFLRIBD.js} +2 -2
  91. package/dist/{chunk-SHJK75Z2.js → chunk-HWXP6RHG.js} +38 -4
  92. package/dist/{chunk-RF6J3DIO.js → chunk-INQHUE72.js} +84 -1
  93. package/dist/{chunk-4CNDGK25.js → chunk-JFPY6XFF.js} +911 -993
  94. package/dist/{chunk-6WGC3SO4.js → chunk-MCLWOBPN.js} +80 -18
  95. package/dist/{chunk-PJPRXO2T.js → chunk-NRMAOGRS.js} +1 -1
  96. package/dist/{chunk-ACPDVEJO.js → chunk-O6GQO7VP.js} +201 -218
  97. package/dist/{chunk-M5YWNMTE.js → chunk-OZG7E22Y.js} +24 -6
  98. package/dist/{chunk-WVIA7V3M.js → chunk-PFAZSRGR.js} +29 -1
  99. package/dist/{chunk-LCP4EDKR.js → chunk-PZZOGHVR.js} +14 -4
  100. package/dist/{chunk-QABCY33S.js → chunk-QBL2AVFF.js} +2 -2
  101. package/dist/{chunk-FKEZZMXS.js → chunk-QU3URVWG.js} +9 -94
  102. package/dist/{chunk-M3QYTBQ6.js → chunk-STOCCPWH.js} +11 -2
  103. package/dist/{chunk-K7VDC2QW.js → chunk-TXLBLGNQ.js} +6 -6
  104. package/dist/{chunk-JA43DV4Y.js → chunk-VOGOTEW7.js} +1 -1
  105. package/dist/{chunk-HUXFMDBZ.js → chunk-VQIWBJOP.js} +1 -1
  106. package/dist/{chunk-JM2COLGC.js → chunk-VQZYIVYN.js} +6 -6
  107. package/dist/{chunk-BCHYQS4B.js → chunk-VXL2LBPK.js} +1 -1
  108. package/dist/{chunk-6VOYP4M6.js → chunk-YXSBZRP7.js} +1 -1
  109. package/dist/cli/chat.js +35 -33
  110. package/dist/cli/check.js +5 -5
  111. package/dist/cli/plugins.js +14 -12
  112. package/dist/cli/snapshot-create.js +10 -9
  113. package/dist/cli/upgrade.js +7 -6
  114. package/dist/{db-MA52H62H.js → db-7XL4UPAE.js} +8 -6
  115. package/dist/instrumentation.js +3 -3
  116. package/dist/nitro.js +7 -6
  117. package/dist/{oauth-callback-server-DXGHKN6S.js → oauth-callback-server-RAOYHWDI.js} +30 -27
  118. package/dist/{runner-4IXUAQNK.js → runner-KMPBWRPM.js} +24 -19
  119. package/dist/{skills-X3DY7AXO.js → skills-IPCALGLQ.js} +5 -5
  120. package/dist/spawn-OSOWTMBG.js +41 -0
  121. package/dist/task-runner-IQNBA3RY.js +34 -0
  122. package/dist/{validation-Z6JXSTJS.js → validation-BSRCCX6N.js} +5 -5
  123. package/dist/version.js +1 -1
  124. package/dist/{work-OKWRFBDW.js → work-T6UFTOJY.js} +24 -19
  125. package/dist/worker-L35OG7VA.js +24 -0
  126. package/package.json +5 -5
  127. package/dist/spawn-43WGS6CH.js +0 -37
  128. package/dist/task-runner-VDRKITPV.js +0 -32
  129. package/dist/worker-B236AE72.js +0 -22
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-PJPRXO2T.js";
4
- import "./chunk-LHXIZLFF.js";
3
+ } from "./chunk-NRMAOGRS.js";
4
+ import "./chunk-64WF2GQ3.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-3S7ULUWW.js";
9
+ import "./chunk-3CVEE6LA.js";
10
10
  import "./chunk-PEQXYSSE.js";
11
- import "./chunk-6VOYP4M6.js";
11
+ import "./chunk-YXSBZRP7.js";
12
12
  export {
13
13
  pluginCatalogRuntime
14
14
  };
@@ -0,0 +1,11 @@
1
+ import type { AssistantMessage } from "@earendil-works/pi-ai";
2
+ import type { ThreadConversationState } from "@/chat/state/conversation";
3
+ /** Record a web-accepted assistant reply with agent history before the visible message. */
4
+ export declare function commitWebAcceptedReply(args: {
5
+ agentMessage?: AssistantMessage;
6
+ conversation: ThreadConversationState;
7
+ conversationId: string;
8
+ sessionId: string;
9
+ text: string;
10
+ userMessageId: string;
11
+ }): Promise<void>;
@@ -1,4 +1,4 @@
1
- /** App-scoped control for one active API Turn per Conversation. */
1
+ /** App-scoped control for one active Turn started by the Conversation API. */
2
2
  export interface ApiTurnCancellation {
3
3
  begin(conversationId: string): AbortSignal | undefined;
4
4
  cancel(conversationId: string): boolean;
@@ -7,21 +7,19 @@ export interface ApiTurnCancellation {
7
7
  park(conversationId: string, signal: AbortSignal): void;
8
8
  signal(conversationId: string): AbortSignal | undefined;
9
9
  }
10
- /** Create in-process cancellation state for active API Turns. */
10
+ /** Create in-process cancellation state for Turns from the Conversation API. */
11
11
  export declare function createApiTurnCancellation(): ApiTurnCancellation;
12
- /** Close one cancelled API Turn without a failure reply or retry. */
12
+ /** Close one cancelled Turn without a failure reply or retry. */
13
13
  export declare function completeCancelledApiTurn(args: {
14
14
  acknowledge(): Promise<void>;
15
15
  actorId: string;
16
16
  cancellation?: ApiTurnCancellation;
17
17
  conversation: ThreadConversationState;
18
18
  conversationId: string;
19
- lifecycle: ConversationTurnLifecycle;
20
19
  sandboxRef?: SandboxRef;
21
20
  signal?: AbortSignal;
22
21
  turnId: string;
23
22
  userMessageId: string;
24
23
  }): Promise<void>;
25
- import type { ConversationTurnLifecycle } from "@/chat/conversations/turn-lifecycle";
26
24
  import type { SandboxRef } from "@/chat/sandbox/ref";
27
25
  import type { ThreadConversationState } from "@/chat/state/conversation";
@@ -0,0 +1,7 @@
1
+ /** Shared mailbox helpers for conversation-only turns. */
2
+ import type { LocalActor } from "@/chat/actor";
3
+ import type { InboundMessage } from "@/chat/task-execution/store";
4
+ /** Join non-empty mailbox texts for one conversation-only turn. */
5
+ export declare function joinMailboxText(messages: readonly InboundMessage[]): string;
6
+ /** Local actor stamped on resource-event conversation-only turns. */
7
+ export declare function localResourceEventActor(): LocalActor;
@@ -10,15 +10,27 @@ declare const apiTurnMailboxMetadataSchema: z.ZodObject<{
10
10
  messageId: z.ZodString;
11
11
  }, z.core.$strict>;
12
12
  export type ApiTurnMailboxMetadata = z.output<typeof apiTurnMailboxMetadataSchema>;
13
+ /**
14
+ * Local destination resource-event mailbox rows share the conversation-only runner.
15
+ *
16
+ * TODO(resource-events): Remove the dedicated `resource_event` work kind once
17
+ * local/web destinations run plain mailbox system wakes the same way as any
18
+ * other deferred conversation turn (no special batch/actor fork).
19
+ */
20
+ export type LocalResourceEventMailboxEntry = {
21
+ message: InboundMessage;
22
+ kind: "resource_event";
23
+ };
13
24
  /** Return the active root API Turn for one Conversation, if it has one. */
14
25
  export declare function getActiveApiTurnId(conversationId: string): Promise<string | undefined>;
15
26
  /** Return the idle auth-paused root API Turn for one Conversation. */
16
27
  export declare function getAuthPausedApiTurnId(conversationId: string): Promise<string | undefined>;
17
28
  /**
18
- * Resolve API Turn work from mailbox metadata or an active checkpoint.
29
+ * Resolve conversation-only work from mailbox metadata or an active checkpoint.
19
30
  *
20
- * Empty resume wakes after yield carry no mailbox rows. Use durable active
21
- * Turn state so these wakes do not fall through to Slack.
31
+ * Covers dashboard API turns and local destination resource-event wakes. Empty
32
+ * resume wakes after yield carry no mailbox rows; durable active Turn state keeps
33
+ * those wakes on this runner instead of falling through to Slack.
22
34
  */
23
35
  export declare function resolveApiTurnWork(context: ConversationWorkerContext): Promise<{
24
36
  kind: "mailbox";
@@ -26,6 +38,9 @@ export declare function resolveApiTurnWork(context: ConversationWorkerContext):
26
38
  message: InboundMessage;
27
39
  metadata: ApiTurnMailboxMetadata;
28
40
  }>;
41
+ } | {
42
+ kind: "resource_event";
43
+ batch: LocalResourceEventMailboxEntry[];
29
44
  } | {
30
45
  kind: "resume";
31
46
  turnId: string;
@@ -3,7 +3,6 @@ import { type Destination } from "@sentry/junior-plugin-api";
3
3
  import type { ConversationPrivacy } from "@/chat/conversation-privacy";
4
4
  import type { WebActor } from "@/chat/actor";
5
5
  import type { ConversationStore } from "@/chat/conversations/store";
6
- import { type ConversationTurnLifecycle } from "@/chat/conversations/turn-lifecycle";
7
6
  import type { AgentRunner } from "@/chat/runtime/agent-runner";
8
7
  import { type InboundMessage } from "@/chat/task-execution/store";
9
8
  import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
@@ -86,18 +85,14 @@ export declare function recordApiConversationActivity(args: {
86
85
  }): Promise<Destination>;
87
86
  /** Create a dashboard root conversation and enqueue its first message. */
88
87
  export declare function createAndEnqueueApiConversation(input: CreateApiConversationInput, options: EnqueueOptions): Promise<ApiConversationMessageAccepted>;
89
- /** Append one API message and optionally require an idle Conversation. */
88
+ /** Append one Conversation API message and optionally require an idle Conversation. */
90
89
  export declare function appendAndEnqueueApiConversationMessage(input: AppendApiConversationMessageInput, options: EnqueueOptions & {
91
90
  exclusive: true;
92
91
  }): Promise<ApiConversationMessageAdmission>;
93
92
  export declare function appendAndEnqueueApiConversationMessage(input: AppendApiConversationMessageInput, options: EnqueueOptions): Promise<ApiConversationMessageAccepted>;
94
- /** Build the mailbox consumer for API-authored root turns. */
95
- export declare function createApiTurnWorker(options: {
96
- agentRunner: AgentRunner;
97
- cancellation?: ApiTurnCancellation;
98
- turnLifecycle?: ConversationTurnLifecycle;
99
- }): (context: ConversationWorkerContext) => Promise<ConversationWorkerResult>;
100
- /** Route API turn work before falling through to other consumers. */
93
+ /** Create the worker for messages from the Conversation API. */
94
+ export declare function createApiTurnWorker(agentRunner: AgentRunner, cancellation?: ApiTurnCancellation): (context: ConversationWorkerContext) => Promise<ConversationWorkerResult>;
95
+ /** Route Conversation API work before other work. */
101
96
  export declare function routeApiTurnWork(options: {
102
97
  apiTurnWorker: (context: ConversationWorkerContext) => Promise<ConversationWorkerResult>;
103
98
  fallbackWorker: (context: ConversationWorkerContext) => Promise<ConversationWorkerResult>;
@@ -16,7 +16,7 @@ interface ConversationWorkOptions {
16
16
  state?: StateAdapter;
17
17
  }
18
18
  export type ConversationWorkCallbackOptions = VercelConversationWorkCallbackOptions & {
19
- /** App-scoped control for API Turn cancellation across request handlers. */
19
+ /** App-scoped Turn cancellation for Conversation API request handlers. */
20
20
  apiTurnCancellation?: ApiTurnCancellation;
21
21
  };
22
22
  /**
@@ -2,9 +2,13 @@ import type { SlackAdapter } from "@chat-adapter/slack";
2
2
  import type { Message } from "chat";
3
3
  import { type AssistantLifecycleEvent } from "@/chat/providers/slack/runtime";
4
4
  import type { JuniorRuntimeServiceOverrides } from "@/chat/app/services";
5
+ import type { ScheduleSessionCompletedPluginTasksOptions } from "@/chat/plugins/task-runner";
6
+ import { type PausedTurns } from "@/chat/task-execution/turn-wake";
5
7
  export interface CreateSlackRuntimeOptions {
6
8
  getSlackAdapter: () => SlackAdapter;
7
9
  now?: () => number;
10
+ pausedTurns?: PausedTurns;
11
+ sendPluginTask?: ScheduleSessionCompletedPluginTasksOptions["send"];
8
12
  services?: JuniorRuntimeServiceOverrides;
9
13
  }
10
14
  export declare function createSlackRuntime(options: CreateSlackRuntimeOptions): {
@@ -2,19 +2,20 @@ import type { SandboxEgressTracePropagationConfig } from "@/chat/sandbox/egress/
2
2
  import { type ConversationMemoryDeps, type ConversationMemoryService } from "@/chat/services/conversation-memory";
3
3
  import { type ContextCompactor, type ContextCompactorDeps } from "@/chat/services/context-compaction";
4
4
  import { type SubscribedReplyPolicy, type SubscribedReplyPolicyDeps } from "@/chat/services/subscribed-reply-policy";
5
- import type { SlackTurnServices } from "@/chat/providers/slack/turn";
6
5
  import { type VisionContextDeps, type VisionContextService } from "@/chat/slack/vision-context";
6
+ import { type AgentRunner } from "@/chat/runtime/agent-runner";
7
+ import { type ExecuteTurn } from "@/chat/runtime/turn-execution";
7
8
  export interface JuniorRuntimeServices {
8
9
  conversationMemory: ConversationMemoryService;
9
10
  contextCompactor: ContextCompactor;
10
- replyExecutor: SlackTurnServices;
11
+ executeTurn: ExecuteTurn;
11
12
  subscribedReplyPolicy: SubscribedReplyPolicy;
12
13
  visionContext: VisionContextService;
13
14
  }
14
15
  export interface JuniorRuntimeServiceOverrides {
16
+ agentRunner?: AgentRunner;
15
17
  conversationMemory?: Partial<ConversationMemoryDeps>;
16
18
  contextCompactor?: Partial<ContextCompactorDeps>;
17
- replyExecutor?: Partial<SlackTurnServices>;
18
19
  subscribedReplyPolicy?: Partial<SubscribedReplyPolicyDeps>;
19
20
  sandbox?: {
20
21
  tracePropagation?: SandboxEgressTracePropagationConfig;
@@ -165,18 +165,41 @@ export type AuthorizationKind = z.output<typeof authorizationKindSchema>;
165
165
  export declare const conversationTurnSurfaceSchema: z.ZodEnum<{
166
166
  slack: "slack";
167
167
  api: "api";
168
- internal: "internal";
169
168
  scheduler: "scheduler";
169
+ internal: "internal";
170
170
  }>;
171
- /** Stable, privacy-safe classification for a failed turn. */
171
+ /** Where a failed turn stopped. */
172
172
  export declare const conversationTurnFailureCodeSchema: z.ZodEnum<{
173
173
  agent_run_failed: "agent_run_failed";
174
174
  delivery_failed: "delivery_failed";
175
175
  model_execution_failed: "model_execution_failed";
176
176
  persistence_failed: "persistence_failed";
177
177
  }>;
178
- /** Failure classification persisted without raw provider or exception data. */
178
+ /** Where a failed turn stopped. */
179
179
  export type ConversationTurnFailureCode = z.output<typeof conversationTurnFailureCodeSchema>;
180
+ /**
181
+ * Why a failed turn stopped.
182
+ * Values are fixed labels only. Do not store raw exception text.
183
+ */
184
+ export declare const conversationTurnFailureReasonSchema: z.ZodEnum<{
185
+ unknown: "unknown";
186
+ auth: "auth";
187
+ permission: "permission";
188
+ rate_limit: "rate_limit";
189
+ capacity: "capacity";
190
+ timeout: "timeout";
191
+ network: "network";
192
+ server: "server";
193
+ invalid_request: "invalid_request";
194
+ invalid_response: "invalid_response";
195
+ quota: "quota";
196
+ content_policy: "content_policy";
197
+ empty_output: "empty_output";
198
+ tool_errors: "tool_errors";
199
+ suppressed_output: "suppressed_output";
200
+ }>;
201
+ /** Why a failed turn stopped. */
202
+ export type ConversationTurnFailureReason = z.output<typeof conversationTurnFailureReasonSchema>;
180
203
  /** Strict event-data contract reused by the SQL row codec. */
181
204
  export declare const conversationEventDataSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
182
205
  type: z.ZodLiteral<"message">;
@@ -290,8 +313,8 @@ export declare const conversationEventDataSchema: z.ZodUnion<readonly [z.ZodUnio
290
313
  surface: z.ZodEnum<{
291
314
  slack: "slack";
292
315
  api: "api";
293
- internal: "internal";
294
316
  scheduler: "scheduler";
317
+ internal: "internal";
295
318
  }>;
296
319
  }, z.core.$strict>, z.ZodObject<{
297
320
  type: z.ZodLiteral<"turn_context">;
@@ -341,8 +364,8 @@ export declare const conversationEventDataSchema: z.ZodUnion<readonly [z.ZodUnio
341
364
  turnId: z.ZodString;
342
365
  outcome: z.ZodEnum<{
343
366
  success: "success";
344
- no_reply: "no_reply";
345
367
  cancelled: "cancelled";
368
+ no_reply: "no_reply";
346
369
  }>;
347
370
  }, z.core.$strict>, z.ZodObject<{
348
371
  type: z.ZodLiteral<"turn_failed">;
@@ -353,6 +376,23 @@ export declare const conversationEventDataSchema: z.ZodUnion<readonly [z.ZodUnio
353
376
  model_execution_failed: "model_execution_failed";
354
377
  persistence_failed: "persistence_failed";
355
378
  }>;
379
+ failureReason: z.ZodOptional<z.ZodEnum<{
380
+ unknown: "unknown";
381
+ auth: "auth";
382
+ permission: "permission";
383
+ rate_limit: "rate_limit";
384
+ capacity: "capacity";
385
+ timeout: "timeout";
386
+ network: "network";
387
+ server: "server";
388
+ invalid_request: "invalid_request";
389
+ invalid_response: "invalid_response";
390
+ quota: "quota";
391
+ content_policy: "content_policy";
392
+ empty_output: "empty_output";
393
+ tool_errors: "tool_errors";
394
+ suppressed_output: "suppressed_output";
395
+ }>>;
356
396
  eventId: z.ZodOptional<z.ZodString>;
357
397
  }, z.core.$strict>, z.ZodObject<{
358
398
  type: z.ZodLiteral<"subagent_started">;
@@ -606,8 +646,8 @@ export declare const conversationEventSchema: z.ZodUnion<readonly [z.ZodObject<{
606
646
  surface: z.ZodEnum<{
607
647
  slack: "slack";
608
648
  api: "api";
609
- internal: "internal";
610
649
  scheduler: "scheduler";
650
+ internal: "internal";
611
651
  }>;
612
652
  }, z.core.$strict>, z.ZodObject<{
613
653
  type: z.ZodLiteral<"turn_context">;
@@ -657,8 +697,8 @@ export declare const conversationEventSchema: z.ZodUnion<readonly [z.ZodObject<{
657
697
  turnId: z.ZodString;
658
698
  outcome: z.ZodEnum<{
659
699
  success: "success";
660
- no_reply: "no_reply";
661
700
  cancelled: "cancelled";
701
+ no_reply: "no_reply";
662
702
  }>;
663
703
  }, z.core.$strict>, z.ZodObject<{
664
704
  type: z.ZodLiteral<"turn_failed">;
@@ -669,6 +709,23 @@ export declare const conversationEventSchema: z.ZodUnion<readonly [z.ZodObject<{
669
709
  model_execution_failed: "model_execution_failed";
670
710
  persistence_failed: "persistence_failed";
671
711
  }>;
712
+ failureReason: z.ZodOptional<z.ZodEnum<{
713
+ unknown: "unknown";
714
+ auth: "auth";
715
+ permission: "permission";
716
+ rate_limit: "rate_limit";
717
+ capacity: "capacity";
718
+ timeout: "timeout";
719
+ network: "network";
720
+ server: "server";
721
+ invalid_request: "invalid_request";
722
+ invalid_response: "invalid_response";
723
+ quota: "quota";
724
+ content_policy: "content_policy";
725
+ empty_output: "empty_output";
726
+ tool_errors: "tool_errors";
727
+ suppressed_output: "suppressed_output";
728
+ }>>;
672
729
  eventId: z.ZodOptional<z.ZodString>;
673
730
  }, z.core.$strict>, z.ZodObject<{
674
731
  type: z.ZodLiteral<"subagent_started">;
@@ -945,8 +1002,8 @@ export declare const newConversationEventSchema: z.ZodObject<{
945
1002
  surface: z.ZodEnum<{
946
1003
  slack: "slack";
947
1004
  api: "api";
948
- internal: "internal";
949
1005
  scheduler: "scheduler";
1006
+ internal: "internal";
950
1007
  }>;
951
1008
  }, z.core.$strict>, z.ZodObject<{
952
1009
  type: z.ZodLiteral<"turn_context">;
@@ -996,8 +1053,8 @@ export declare const newConversationEventSchema: z.ZodObject<{
996
1053
  turnId: z.ZodString;
997
1054
  outcome: z.ZodEnum<{
998
1055
  success: "success";
999
- no_reply: "no_reply";
1000
1056
  cancelled: "cancelled";
1057
+ no_reply: "no_reply";
1001
1058
  }>;
1002
1059
  }, z.core.$strict>, z.ZodObject<{
1003
1060
  type: z.ZodLiteral<"turn_failed">;
@@ -1008,6 +1065,23 @@ export declare const newConversationEventSchema: z.ZodObject<{
1008
1065
  model_execution_failed: "model_execution_failed";
1009
1066
  persistence_failed: "persistence_failed";
1010
1067
  }>;
1068
+ failureReason: z.ZodOptional<z.ZodEnum<{
1069
+ unknown: "unknown";
1070
+ auth: "auth";
1071
+ permission: "permission";
1072
+ rate_limit: "rate_limit";
1073
+ capacity: "capacity";
1074
+ timeout: "timeout";
1075
+ network: "network";
1076
+ server: "server";
1077
+ invalid_request: "invalid_request";
1078
+ invalid_response: "invalid_response";
1079
+ quota: "quota";
1080
+ content_policy: "content_policy";
1081
+ empty_output: "empty_output";
1082
+ tool_errors: "tool_errors";
1083
+ suppressed_output: "suppressed_output";
1084
+ }>>;
1011
1085
  eventId: z.ZodOptional<z.ZodString>;
1012
1086
  }, z.core.$strict>, z.ZodObject<{
1013
1087
  type: z.ZodLiteral<"subagent_started">;
@@ -1,4 +1,4 @@
1
- import type { ConversationEventStore, ConversationTurnFailureCode } from "./history";
1
+ import type { ConversationEventStore, ConversationTurnFailureCode, ConversationTurnFailureReason } from "./history";
2
2
  /** Product-owned inputs for opening one correlated conversation turn. */
3
3
  export interface StartConversationTurnInput {
4
4
  conversationId: string;
@@ -14,12 +14,13 @@ export interface CompleteConversationTurnInput {
14
14
  outcome: "success" | "no_reply" | "cancelled";
15
15
  turnId: string;
16
16
  }
17
- /** Privacy-safe inputs for failing one correlated conversation turn. */
17
+ /** Inputs for failing one correlated conversation turn. */
18
18
  export interface FailConversationTurnInput {
19
19
  conversationId: string;
20
20
  createdAtMs: number;
21
21
  eventId?: string;
22
22
  failureCode: ConversationTurnFailureCode;
23
+ failureReason?: ConversationTurnFailureReason;
23
24
  turnId: string;
24
25
  }
25
26
  /** Runtime port for correlated canonical turn lifecycle persistence. */
@@ -36,6 +37,8 @@ export declare class ConversationTurnLifecycleService implements ConversationTur
36
37
  start(input: StartConversationTurnInput): Promise<void>;
37
38
  /** Record successful or intentional-silence completion once. */
38
39
  complete(input: CompleteConversationTurnInput): Promise<void>;
39
- /** Record a classified failure once without accepting raw error details. */
40
+ /** Record a classified failure once. Do not store raw error text. */
40
41
  fail(input: FailConversationTurnInput): Promise<void>;
41
42
  }
43
+ /** Return the Turn lifecycle that records Conversation events. */
44
+ export declare function getTurnLifecycle(): ConversationTurnLifecycle;
@@ -0,0 +1,32 @@
1
+ import type { Message, Thread } from "chat";
2
+ import type { AgentSteeringMessage } from "@/chat/agent/types";
3
+ import { type ConversationMessageProvenance } from "@/chat/conversations/provenance";
4
+ import type { PiMessage } from "@/chat/pi/messages";
5
+ import type { QueuedTurnMessage } from "@/chat/runtime/turn-input";
6
+ /**
7
+ * Return a stable key for one steering message. Resolved attachments may change
8
+ * when Junior retries a mailbox delivery, so only the message time and text
9
+ * form the key.
10
+ */
11
+ export declare function steeringMessageKey(message: PiMessage): string | undefined;
12
+ /** Add recent Slack messages to the agent context. */
13
+ export declare function appendRecentMessagesToContext(conversationContext: string | undefined, messages: QueuedTurnMessage[]): string | undefined;
14
+ /** Return the actor stored with one inbound Slack message. */
15
+ export declare function inboundMessageActor(queued: QueuedTurnMessage): AgentSteeringMessage["actor"];
16
+ /** Return the authority stored with one inbound Slack message. */
17
+ export declare function inboundMessageProvenance(queued: QueuedTurnMessage, teamId: string): ConversationMessageProvenance;
18
+ /** Return the Slack channel name when it is available. */
19
+ export declare function resolveChannelName(thread: Thread): Promise<string | undefined>;
20
+ /** Collect attachments from the current Slack message and its batch. */
21
+ export declare function collectAttachments(message: Message, batchedMessages?: QueuedTurnMessage[]): Message["attachments"];
22
+ /**
23
+ * Save each steering message once. Return false when a resumed Run is active
24
+ * so the mailbox delivery stays pending.
25
+ */
26
+ export declare function saveSteeringMessages(args: {
27
+ conversationId: string;
28
+ messages: Array<{
29
+ message: PiMessage;
30
+ provenance: ConversationMessageProvenance;
31
+ }>;
32
+ }): Promise<boolean>;
@@ -2,22 +2,20 @@ import type { Message, Thread } from "chat";
2
2
  import type { TurnToolInvocation } from "@/chat/runtime/turn-input";
3
3
  import type { SlackMessageTs } from "@/chat/slack/timestamp";
4
4
  /** Controls the automatic Slack processing reaction lifecycle for one message. */
5
- export interface ProcessingReactionSession {
5
+ export interface ProcessingReaction {
6
6
  complete: () => Promise<void>;
7
7
  keep: () => void;
8
8
  stop: () => Promise<void>;
9
9
  }
10
- /** Return true when a Slack reaction tool call should leave the processing reaction in place. */
10
+ /** Return true when a Slack reaction tool invocation keeps the processing reaction. */
11
11
  export declare function shouldKeepProcessingReactionForToolInvocation(input: TurnToolInvocation): boolean;
12
12
  /** Start Junior's automatic Slack processing reaction for one inbound message. */
13
- export declare function startSlackProcessingReaction(args: {
14
- logException: (error: unknown, eventName: string, attributes?: Record<string, unknown>) => string | undefined;
13
+ export declare function startProcessingReaction(args: {
15
14
  message: Message;
16
15
  thread: Thread;
17
- }): Promise<ProcessingReactionSession>;
16
+ }): Promise<ProcessingReaction>;
18
17
  /** Start Junior's automatic Slack processing reaction for a known Slack message. */
19
- export declare function startSlackProcessingReactionForMessage(args: {
18
+ export declare function startProcessingReactionForMessage(args: {
20
19
  channelId: string;
21
20
  timestamp: SlackMessageTs;
22
- logException: (error: unknown, eventName: string, attributes?: Record<string, unknown>) => string | undefined;
23
- }): Promise<ProcessingReactionSession>;
21
+ }): Promise<ProcessingReaction>;
@@ -1,10 +1,10 @@
1
1
  import { type AgentRun } from "@/chat/agent/types";
2
2
  import type { AgentRunResult } from "@/chat/services/turn-result";
3
- import { type AgentRunner } from "@/chat/runtime/agent-runner";
4
- import { type ConversationTurnLifecycle } from "@/chat/conversations/turn-lifecycle";
3
+ import { type ExecuteTurn } from "@/chat/runtime/turn-execution";
4
+ import { scheduleSessionCompletedPluginTasks } from "@/chat/plugins/task-runner";
5
5
  import { type AssistantStatusSpec } from "@/chat/slack/assistant-thread/status";
6
6
  import type { SlackMessageTs } from "@/chat/slack/timestamp";
7
- /** Error raised when another worker already owns the resume lock. */
7
+ /** Error raised when another worker is already resuming the Slack Turn. */
8
8
  export declare class ResumeTurnBusyError extends Error {
9
9
  constructor(lockKey: string);
10
10
  }
@@ -17,23 +17,20 @@ interface ResumeSlackTurnArgs {
17
17
  channelId: string;
18
18
  threadTs?: string;
19
19
  messageTs?: SlackMessageTs;
20
- replyContext?: ResumeReplyContext;
20
+ /** Saved Run fields. `beforeStart` may supply them after stale-work checks. */
21
+ run?: ResumeRun;
21
22
  lockKey?: string;
22
23
  /**
23
24
  * When true, the caller already holds the conversation work lease.
24
- * Skip the second resume lock so queue continue is one owner, not two.
25
- * OAuth and other out-of-band resumes leave this false.
25
+ * Skip the second resume lock so the queue continuation has one owner.
26
+ * Authorization callbacks and other independent resumes leave this false.
26
27
  */
27
28
  ownsConversationLease?: boolean;
28
29
  initialText?: string;
29
30
  initialStatus?: AssistantStatusSpec;
30
- agentRunner: AgentRunner;
31
+ executeTurn: ExecuteTurn;
31
32
  inputMessageIds?: string[];
32
- turnLifecycle?: ConversationTurnLifecycle;
33
- scheduleSessionCompletedPluginTasks?: (params: {
34
- conversationId: string;
35
- sessionId: string;
36
- }) => Promise<void>;
33
+ scheduleSessionCompletedPluginTasks?: typeof scheduleSessionCompletedPluginTasks;
37
34
  commitResult?: (result: AgentRunResult) => Promise<void>;
38
35
  onFailure?: (error: unknown) => Promise<void>;
39
36
  onAuthPause?: (pause: {
@@ -42,9 +39,8 @@ interface ResumeSlackTurnArgs {
42
39
  onSuspend?: (resumeVersion: number) => Promise<void>;
43
40
  onPostDeliveryCommitFailure?: (error: unknown) => Promise<void>;
44
41
  beforeStart?: () => Promise<ResumePreparedTurn | false | void>;
45
- replyTimeoutMs?: number;
46
42
  }
47
- type ResumeReplyContext = Omit<AgentRun, "conversationId" | "turnId" | "runId" | "instruction" | "delivery"> & {
43
+ type ResumeRun = Omit<AgentRun, "conversationId" | "turnId" | "runId" | "instruction" | "delivery"> & {
48
44
  instruction?: Omit<AgentRun["instruction"], "text">;
49
45
  };
50
46
  interface ResumePreparedTurn {
@@ -54,7 +50,7 @@ interface ResumePreparedTurn {
54
50
  messageTs?: SlackMessageTs;
55
51
  inputMessageIds?: string[];
56
52
  initialStatus?: AssistantStatusSpec;
57
- replyContext: ResumeReplyContext;
53
+ run: ResumeRun;
58
54
  commitResult?: (result: AgentRunResult) => Promise<void>;
59
55
  onFailure?: (error: unknown) => Promise<void>;
60
56
  onAuthPause?: (pause: {
@@ -64,11 +60,12 @@ interface ResumePreparedTurn {
64
60
  onPostDeliveryCommitFailure?: (error: unknown) => Promise<void>;
65
61
  }
66
62
  /**
67
- * Resume a paused Slack turn.
63
+ * Resume a paused Slack Turn.
68
64
  *
69
- * Queue continues pass `ownsConversationLease` and skip the second lock
70
- * (worker lease is already held). OAuth and other out-of-band resumes still
71
- * take the thread lock. Started resumes own their completion side effects.
65
+ * Queue continuations pass `ownsConversationLease` and skip the second lock
66
+ * because the worker lease is already held. Authorization callbacks and other
67
+ * independent resumes still take the thread lock. A started resume owns its
68
+ * completion work.
72
69
  * Returns false only when `beforeStart` proves the resume is stale before
73
70
  * generation begins.
74
71
  */
@@ -10,7 +10,6 @@ import type { Message, MessageContext, Thread } from "chat";
10
10
  import type { Destination } from "@sentry/junior-plugin-api";
11
11
  import type { SubscribedReplyDecision, SubscribedReplyPolicy } from "@/chat/services/subscribed-reply-policy";
12
12
  import { type PrepareTurnStateInput, type QueuedTurnMessage, type TurnMessageText, type TurnToolInvocation } from "@/chat/runtime/turn-input";
13
- import type { FailConversationTurnInput } from "@/chat/conversations/turn-lifecycle";
14
13
  export interface AssistantLifecycleEvent {
15
14
  channelId: string;
16
15
  context?: {
@@ -47,25 +46,20 @@ export interface SlackTurnRuntimeDependencies<TPreparedState> {
47
46
  cancelEventSubscriptions: (input: {
48
47
  conversationId: string;
49
48
  }) => Promise<void>;
50
- getChannelId: (thread: Thread, message: Message) => string | undefined;
49
+ getBotUserId: () => string | undefined;
51
50
  getPreparedConversationContext: (preparedState: TPreparedState) => string | undefined;
52
- getThreadId: (thread: Thread, message: Message) => string | undefined;
53
- getRunId: (thread: Thread, message: Message) => string | undefined;
54
51
  initializeAssistantThread: (event: {
55
52
  channelId: string;
56
53
  sourceChannelId?: string;
57
54
  threadId: string;
58
55
  threadTs: string;
59
56
  }) => Promise<void>;
60
- failConversationTurn: (input: FailConversationTurnInput) => Promise<void>;
61
57
  refreshAssistantThreadContext: (event: {
62
58
  channelId: string;
63
59
  sourceChannelId?: string;
64
60
  threadId: string;
65
61
  threadTs: string;
66
62
  }) => Promise<void>;
67
- logException: (error: unknown, eventName: string, attributes?: Record<string, unknown>) => string | undefined;
68
- logWarn: (eventName: string, attributes?: Record<string, unknown>) => void;
69
63
  modelId: string;
70
64
  now: () => number;
71
65
  recordSkippedSteeringMessage: (args: {
@@ -109,11 +103,6 @@ export interface SlackTurnRuntimeDependencies<TPreparedState> {
109
103
  shouldYield?: () => boolean;
110
104
  }) => Promise<void>;
111
105
  decideSubscribedReply: SubscribedReplyPolicy;
112
- stripLeadingBotMention: (text: string, options: {
113
- botUserId?: string;
114
- stripLeadingSlackMentionToken?: boolean;
115
- }) => string;
116
- withSpan: (name: string, op: string, context: Record<string, unknown>, callback: () => Promise<void>) => Promise<void>;
117
106
  }
118
107
  export interface SlackTurnRuntime<_TPreparedState, TAssistantEvent extends AssistantLifecycleEvent = AssistantLifecycleEvent> {
119
108
  handleAssistantContextChanged: (event: TAssistantEvent) => Promise<void>;