@sentry/junior 0.184.0 → 0.185.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 (111) hide show
  1. package/dist/{agent-hooks-XTZVALGQ.js → agent-hooks-NGZQLL5O.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 +100 -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 +358 -76
  13. package/dist/app.js +406 -377
  14. package/dist/{catalog-runtime-5357XR4F.js → catalog-runtime-AAEAO2RL.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/work.d.ts +4 -9
  18. package/dist/chat/app/conversation-work.d.ts +1 -1
  19. package/dist/chat/app/factory.d.ts +4 -0
  20. package/dist/chat/app/services.d.ts +4 -3
  21. package/dist/chat/conversations/history.d.ts +83 -9
  22. package/dist/chat/conversations/turn-lifecycle.d.ts +4 -3
  23. package/dist/chat/providers/slack/input.d.ts +32 -0
  24. package/dist/chat/{runtime → providers/slack}/processing-reaction.d.ts +6 -8
  25. package/dist/chat/{runtime/slack-resume.d.ts → providers/slack/resume.d.ts} +16 -19
  26. package/dist/chat/providers/slack/runtime.d.ts +1 -10
  27. package/dist/chat/providers/slack/turn.d.ts +11 -24
  28. package/dist/chat/resource-events/store.d.ts +1 -1
  29. package/dist/chat/resource-events/tool-support.d.ts +0 -5
  30. package/dist/chat/runtime/turn-execution.d.ts +7 -2
  31. package/dist/chat/sandbox/egress/credentials.d.ts +3 -3
  32. package/dist/chat/sandbox/egress/session.d.ts +5 -6
  33. package/dist/chat/scheduled-tasks/tool-support.d.ts +5 -5
  34. package/dist/chat/scheduled-tasks/tools/create.d.ts +2 -2
  35. package/dist/chat/scheduled-tasks/tools/delete.d.ts +2 -2
  36. package/dist/chat/scheduled-tasks/tools/list.d.ts +2 -2
  37. package/dist/chat/scheduled-tasks/tools/run-now.d.ts +2 -2
  38. package/dist/chat/scheduled-tasks/tools/update.d.ts +2 -2
  39. package/dist/chat/scheduled-tasks/types.d.ts +1 -1
  40. package/dist/chat/services/provider-retry.d.ts +2 -0
  41. package/dist/chat/services/turn-failure-response.d.ts +4 -0
  42. package/dist/chat/task-execution/paused-turn.d.ts +0 -2
  43. package/dist/chat/task-execution/state.d.ts +2 -2
  44. package/dist/chat/task-execution/store.d.ts +1 -1
  45. package/dist/chat/task-execution/turn-wake.d.ts +12 -0
  46. package/dist/chat/tool-support/action-review.d.ts +1 -1
  47. package/dist/chat/tools/resource-events.d.ts +1 -1
  48. package/dist/chat/tools/search-conversation-events.d.ts +1 -1
  49. package/dist/chat/tools/types.d.ts +1 -1
  50. package/dist/chat/tools/watch-resource-events.d.ts +2 -2
  51. package/dist/{chunk-FKEZZMXS.js → chunk-4HA36IWS.js} +9 -94
  52. package/dist/{chunk-WVIA7V3M.js → chunk-4K25ODAO.js} +27 -1
  53. package/dist/{chunk-UF6BUA5W.js → chunk-4S47VHJR.js} +3 -3
  54. package/dist/{chunk-JNO2GUDS.js → chunk-6DOAUXLD.js} +231 -198
  55. package/dist/{chunk-M3QYTBQ6.js → chunk-6Q7YZLCL.js} +2 -1
  56. package/dist/{chunk-6VOYP4M6.js → chunk-7GAP2XG4.js} +1 -1
  57. package/dist/{chunk-LHXIZLFF.js → chunk-7MHNIGHP.js} +1 -1
  58. package/dist/{chunk-IZDYYYGP.js → chunk-ABAX75GG.js} +10 -384
  59. package/dist/{chunk-WQFEWULF.js → chunk-ATUWN6Z3.js} +2 -2
  60. package/dist/{chunk-4RONS3WR.js → chunk-C6TS47CQ.js} +4 -4
  61. package/dist/chunk-D4YV5TDV.js +45 -0
  62. package/dist/{chunk-Z3QAXJR7.js → chunk-D63IUQQE.js} +4 -4
  63. package/dist/{chunk-M5YWNMTE.js → chunk-DAPC2HTM.js} +24 -6
  64. package/dist/{chunk-BHYRYYLY.js → chunk-EIJCPJOY.js} +1 -1
  65. package/dist/{chunk-SHJK75Z2.js → chunk-EJYP3NQ4.js} +4 -4
  66. package/dist/{chunk-K7VDC2QW.js → chunk-EWEH2PJW.js} +6 -6
  67. package/dist/{chunk-6WGC3SO4.js → chunk-FFHXG2FX.js} +13 -11
  68. package/dist/{chunk-MLSQX2EX.js → chunk-FTVMXDNN.js} +1 -1
  69. package/dist/chunk-GFBR4S3Q.js +406 -0
  70. package/dist/{chunk-PJPRXO2T.js → chunk-GJTIZQGJ.js} +1 -1
  71. package/dist/{chunk-BT53RIGJ.js → chunk-HJPC32TQ.js} +12 -50
  72. package/dist/{chunk-RF6J3DIO.js → chunk-INQHUE72.js} +84 -1
  73. package/dist/{chunk-6UDPINOX.js → chunk-LRI5IRGY.js} +19 -44
  74. package/dist/{chunk-BCHYQS4B.js → chunk-LVK4WJKM.js} +1 -1
  75. package/dist/{chunk-UBOIHNTH.js → chunk-MWOH6CIK.js} +178 -148
  76. package/dist/{chunk-3S7ULUWW.js → chunk-OMQ2J6F6.js} +1 -1
  77. package/dist/{chunk-DUKIDPF6.js → chunk-PNYJOEVV.js} +1 -1
  78. package/dist/{chunk-MAPJFUMV.js → chunk-QCT4226Q.js} +3 -3
  79. package/dist/{chunk-HIPUIPJM.js → chunk-QZKHHG3B.js} +34 -8
  80. package/dist/{chunk-QABCY33S.js → chunk-TVVAMOLS.js} +2 -2
  81. package/dist/{chunk-JA43DV4Y.js → chunk-U4CTAVWN.js} +1 -1
  82. package/dist/{chunk-LCP4EDKR.js → chunk-UUULGCKK.js} +1 -1
  83. package/dist/{chunk-4CNDGK25.js → chunk-VH4IU3UC.js} +928 -984
  84. package/dist/chunk-W7GCLNIV.js +58 -0
  85. package/dist/{chunk-2ZQPVX7C.js → chunk-WLKWN4CD.js} +22 -12
  86. package/dist/{chunk-ACPDVEJO.js → chunk-X2SS6BF7.js} +198 -209
  87. package/dist/{chunk-YKX6MTLU.js → chunk-X7NCJQAA.js} +1 -1
  88. package/dist/{chunk-E57WPXWY.js → chunk-Y5G23T2D.js} +5 -5
  89. package/dist/{chunk-HUXFMDBZ.js → chunk-ZIF2S464.js} +1 -1
  90. package/dist/{chunk-JM2COLGC.js → chunk-ZKKGFUWM.js} +6 -6
  91. package/dist/cli/chat.js +35 -33
  92. package/dist/cli/check.js +5 -5
  93. package/dist/cli/plugins.js +14 -12
  94. package/dist/cli/snapshot-create.js +10 -9
  95. package/dist/cli/upgrade.js +7 -6
  96. package/dist/{db-MA52H62H.js → db-TRJ77FAU.js} +8 -6
  97. package/dist/instrumentation.js +3 -3
  98. package/dist/nitro.js +7 -6
  99. package/dist/{oauth-callback-server-DXGHKN6S.js → oauth-callback-server-XD5SV3MS.js} +30 -27
  100. package/dist/{runner-4IXUAQNK.js → runner-KFX7NG6D.js} +24 -19
  101. package/dist/{skills-X3DY7AXO.js → skills-J2AH26CW.js} +5 -5
  102. package/dist/spawn-VU3CSRI6.js +41 -0
  103. package/dist/task-runner-5JG3VIIY.js +34 -0
  104. package/dist/{validation-Z6JXSTJS.js → validation-O5J4VOPF.js} +5 -5
  105. package/dist/version.js +1 -1
  106. package/dist/{work-OKWRFBDW.js → work-ECPQTG3U.js} +24 -19
  107. package/dist/worker-RS3DXUDO.js +24 -0
  108. package/package.json +4 -4
  109. package/dist/spawn-43WGS6CH.js +0 -37
  110. package/dist/task-runner-VDRKITPV.js +0 -32
  111. 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-GJTIZQGJ.js";
4
+ import "./chunk-7MHNIGHP.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-OMQ2J6F6.js";
10
10
  import "./chunk-PEQXYSSE.js";
11
- import "./chunk-6VOYP4M6.js";
11
+ import "./chunk-7GAP2XG4.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";
@@ -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,6 @@ 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
  }
@@ -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
  */
@@ -47,10 +47,8 @@ export interface SlackTurnRuntimeDependencies<TPreparedState> {
47
47
  cancelEventSubscriptions: (input: {
48
48
  conversationId: string;
49
49
  }) => Promise<void>;
50
- getChannelId: (thread: Thread, message: Message) => string | undefined;
50
+ getBotUserId: () => string | undefined;
51
51
  getPreparedConversationContext: (preparedState: TPreparedState) => string | undefined;
52
- getThreadId: (thread: Thread, message: Message) => string | undefined;
53
- getRunId: (thread: Thread, message: Message) => string | undefined;
54
52
  initializeAssistantThread: (event: {
55
53
  channelId: string;
56
54
  sourceChannelId?: string;
@@ -64,8 +62,6 @@ export interface SlackTurnRuntimeDependencies<TPreparedState> {
64
62
  threadId: string;
65
63
  threadTs: string;
66
64
  }) => Promise<void>;
67
- logException: (error: unknown, eventName: string, attributes?: Record<string, unknown>) => string | undefined;
68
- logWarn: (eventName: string, attributes?: Record<string, unknown>) => void;
69
65
  modelId: string;
70
66
  now: () => number;
71
67
  recordSkippedSteeringMessage: (args: {
@@ -109,11 +105,6 @@ export interface SlackTurnRuntimeDependencies<TPreparedState> {
109
105
  shouldYield?: () => boolean;
110
106
  }) => Promise<void>;
111
107
  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
108
  }
118
109
  export interface SlackTurnRuntime<_TPreparedState, TAssistantEvent extends AssistantLifecycleEvent = AssistantLifecycleEvent> {
119
110
  handleAssistantContextChanged: (event: TAssistantEvent) => Promise<void>;
@@ -1,39 +1,25 @@
1
1
  /**
2
- * Add Slack provider behavior around one native agent Turn.
2
+ * Add Slack behavior around one Turn.
3
3
  *
4
- * This module prepares Slack input and owns Slack status, delivery, and saved
5
- * Slack state. Native execution concerns that remain here must move behind a
6
- * provider-neutral runtime contract. Agent execution stays behind
7
- * `AgentRunner`.
4
+ * This module owns Slack status, delivery, and state.
5
+ * It calls `executeTurn` to run and finish the Turn.
8
6
  */
9
7
  import type { Message, Thread } from "chat";
10
8
  import type { SlackAdapter } from "@chat-adapter/slack";
11
9
  import { type Destination } from "@sentry/junior-plugin-api";
12
- import type { AgentRunner } from "@/chat/runtime/agent-runner";
10
+ import { type ExecuteTurn } from "@/chat/runtime/turn-execution";
13
11
  import type { PreparedTurnState } from "@/chat/runtime/turn-preparation";
14
12
  import { type PrepareTurnStateInput, type QueuedTurnMessage, type TurnToolInvocation } from "@/chat/runtime/turn-input";
15
13
  import type { ContextCompactor } from "@/chat/services/context-compaction";
16
- import { lookupSlackUser } from "@/chat/slack/user";
17
- import type { PausedTurnRequest } from "@/chat/task-execution/turn-wake";
14
+ import type { PausedTurns } from "@/chat/task-execution/turn-wake";
18
15
  import type { ConversationTurnLifecycle } from "@/chat/conversations/turn-lifecycle";
16
+ import { type ScheduleSessionCompletedPluginTasksOptions } from "@/chat/plugins/task-runner";
19
17
  import type { DispatchTurnContext, DispatchTurnResult } from "@/chat/agent-dispatch/types";
20
- export interface SlackTurnServices {
21
- agentRunner: AgentRunner;
22
- contextCompactor: ContextCompactor;
23
- getPausedTurnRequest: (args: {
24
- conversationId: string;
25
- turnId: string;
26
- }) => Promise<PausedTurnRequest | undefined>;
27
- lookupSlackUser: typeof lookupSlackUser;
28
- turnLifecycle: ConversationTurnLifecycle;
29
- wakePausedTurn: (request: PausedTurnRequest) => Promise<void>;
30
- scheduleSessionCompletedPluginTasks: (params: {
31
- conversationId: string;
32
- sessionId: string;
33
- }) => Promise<void>;
34
- }
35
18
  interface SlackTurnDeps {
19
+ contextCompactor: ContextCompactor;
20
+ executeTurn: ExecuteTurn;
36
21
  getSlackAdapter: () => SlackAdapter;
22
+ pausedTurns: PausedTurns;
37
23
  resolveUserAttachments: (attachments: Message["attachments"] | undefined, context: {
38
24
  threadId?: string;
39
25
  actorId?: string;
@@ -48,7 +34,8 @@ interface SlackTurnDeps {
48
34
  promptText?: string;
49
35
  }>>;
50
36
  prepareTurnState: (args: PrepareTurnStateInput) => Promise<PreparedTurnState>;
51
- services: SlackTurnServices;
37
+ sendPluginTask?: ScheduleSessionCompletedPluginTasksOptions["send"];
38
+ turnLifecycle: Pick<ConversationTurnLifecycle, "fail" | "start">;
52
39
  }
53
40
  /** Build the Slack caller that prepares input and delivers output for a Turn. */
54
41
  export declare function createSlackTurn(deps: SlackTurnDeps): (thread: Thread, message: Message, options: {
@@ -23,8 +23,8 @@ declare const subscriptionSchema: z.ZodObject<{
23
23
  resourceType: z.ZodString;
24
24
  status: z.ZodEnum<{
25
25
  completed: "completed";
26
- active: "active";
27
26
  cancelled: "cancelled";
27
+ active: "active";
28
28
  }>;
29
29
  updatedAtMs: z.ZodNumber;
30
30
  }, z.core.$strict>;
@@ -1,4 +1,3 @@
1
- import type { ToolRuntimeContext } from "@/chat/tools/types";
2
1
  /** Default lifetime for temporary resource subscriptions. */
3
2
  export declare const RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS: number;
4
3
  /** Hard upper bound for temporary resource subscriptions. */
@@ -8,7 +7,3 @@ export declare const RESOURCE_WATCH_TOOL_SOURCE: {
8
7
  id: string;
9
8
  description: string;
10
9
  };
11
- /** Require the Slack thread identity that owns a resource watch. */
12
- export declare function requireResourceWatchConversation(context: ToolRuntimeContext): string;
13
- /** Return whether the current runtime can safely manage conversation watches. */
14
- export declare function canUseResourceEventSubscriptionTools(context: ToolRuntimeContext): boolean;
@@ -1,14 +1,16 @@
1
1
  import type { AgentRun } from "@/chat/agent/types";
2
2
  import type { CompleteConversationTurnInput, FailConversationTurnInput } from "@/chat/conversations/turn-lifecycle";
3
3
  import type { AgentRunOutcome } from "@/chat/runtime/agent-run-outcome";
4
- import type { AgentRunner } from "@/chat/runtime/agent-runner";
4
+ import { type AgentRunner } from "@/chat/runtime/agent-runner";
5
5
  import type { AgentRunResult } from "@/chat/services/turn-result";
6
6
  type SavedTurnResult = {
7
7
  finishedAtMs?: number;
8
8
  outcome: CompleteConversationTurnInput["outcome"];
9
9
  } | {
10
+ eventId?: string;
10
11
  finishedAtMs?: number;
11
12
  failureCode: FailConversationTurnInput["failureCode"];
13
+ failureReason?: FailConversationTurnInput["failureReason"];
12
14
  outcome: "failed";
13
15
  };
14
16
  type TurnExecutionOutcome = Exclude<AgentRunOutcome, {
@@ -25,6 +27,9 @@ export declare class AgentRunError extends Error {
25
27
  *
26
28
  * A paused Run, or a Run waiting for authorization, leaves the Turn open. A
27
29
  * save error also leaves the Turn open so the worker can retry or recover it.
30
+ * A timeout aborts the Run before this function reports the failure.
28
31
  */
29
- export declare function executeTurn(agentRunner: AgentRunner, run: AgentRun, saveResult: (result: AgentRunResult) => Promise<SavedTurnResult>): Promise<TurnExecutionOutcome>;
32
+ export declare function executeTurn(agentRunner: AgentRunner, run: AgentRun, saveResult: (result: AgentRunResult) => Promise<SavedTurnResult>, timeoutMs?: number): Promise<TurnExecutionOutcome>;
33
+ /** Run the agent and finish a Turn after its caller saves the result. */
34
+ export type ExecuteTurn = (run: AgentRun, saveResult: (result: AgentRunResult) => Promise<SavedTurnResult>, timeoutMs?: number) => Promise<TurnExecutionOutcome>;
30
35
  export {};