@sentry/junior 0.113.0 → 0.115.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 (98) hide show
  1. package/dist/{agent-hooks-BKEMWR3Z.js → agent-hooks-4EUUXP2F.js} +12 -11
  2. package/dist/api/conversations/detail.d.ts +26 -0
  3. package/dist/api/conversations/event-list.d.ts +26 -0
  4. package/dist/api/conversations/events.d.ts +1 -1
  5. package/dist/api/health.d.ts +7 -0
  6. package/dist/api/plugin-reports.d.ts +62 -0
  7. package/dist/api/plugins.d.ts +9 -0
  8. package/dist/api/runtime.d.ts +24 -0
  9. package/dist/api/schema/conversation.d.ts +104 -0
  10. package/dist/api/schema.d.ts +2 -2
  11. package/dist/api/schema.js +6 -6
  12. package/dist/api/skills.d.ts +6 -0
  13. package/dist/api.js +140 -100
  14. package/dist/app.d.ts +2 -0
  15. package/dist/app.js +1117 -5010
  16. package/dist/catalog-runtime-Y32UEQLB.js +18 -0
  17. package/dist/chat/agent/request.d.ts +6 -0
  18. package/dist/chat/agent/sandbox.d.ts +2 -0
  19. package/dist/chat/agent/tools.d.ts +2 -0
  20. package/dist/chat/config.d.ts +3 -1
  21. package/dist/chat/conversations/history.d.ts +92 -0
  22. package/dist/chat/conversations/projection.d.ts +20 -1
  23. package/dist/chat/local/credential-sync.d.ts +5 -0
  24. package/dist/chat/local/oauth-relay.d.ts +4 -0
  25. package/dist/chat/mcp/oauth.d.ts +1 -0
  26. package/dist/chat/oauth-authorization.d.ts +17 -0
  27. package/dist/chat/oauth-flow.d.ts +9 -0
  28. package/dist/chat/sandbox/egress/schemas.d.ts +46 -0
  29. package/dist/chat/sandbox/egress/signals.d.ts +9 -0
  30. package/dist/chat/sandbox/sandbox.d.ts +2 -0
  31. package/dist/chat/sentry-payload-filter.d.ts +4 -4
  32. package/dist/chat/services/context-budget.d.ts +7 -2
  33. package/dist/chat/services/context-compaction.d.ts +28 -1
  34. package/dist/chat/services/conversation-memory.d.ts +1 -0
  35. package/dist/chat/services/mcp-auth-orchestration.d.ts +5 -3
  36. package/dist/chat/services/plugin-auth-orchestration.d.ts +2 -0
  37. package/dist/chat/services/provider-error.d.ts +1 -0
  38. package/dist/chat/services/turn-router.d.ts +1 -0
  39. package/dist/chat/slack/message-control.d.ts +2 -0
  40. package/dist/chat/slack/oauth-authorization-message.d.ts +3 -0
  41. package/dist/chat/task-execution/slack-work.d.ts +2 -0
  42. package/dist/chat/tool-support/zod-tool.d.ts +1 -1
  43. package/dist/chat/tools/definition.d.ts +5 -0
  44. package/dist/chat/tools/sandbox/edit-file.d.ts +1 -1
  45. package/dist/chat/tools/sandbox/text-edits.d.ts +1 -0
  46. package/dist/{chunk-4WZ7YKDF.js → chunk-2QG4MZQ7.js} +2 -2
  47. package/dist/{chunk-H5ON7XTE.js → chunk-43RYMWJ2.js} +954 -2514
  48. package/dist/chunk-4CODA7P5.js +43 -0
  49. package/dist/{chunk-HMRVILWZ.js → chunk-67CVNDJ7.js} +1 -1
  50. package/dist/{chunk-LR2SKL5Y.js → chunk-6FKLPVF3.js} +1 -1
  51. package/dist/{chunk-2ZTTXTSZ.js → chunk-6OPTF4BQ.js} +10 -4
  52. package/dist/{chunk-3CTIAKSS.js → chunk-6V762AB4.js} +1 -1
  53. package/dist/{chunk-WBB22ANL.js → chunk-AGLQYELI.js} +77 -8
  54. package/dist/{chunk-DXRPHBOU.js → chunk-CEYOL62C.js} +77 -36
  55. package/dist/{chunk-QTS66GMR.js → chunk-CWEZEPD4.js} +3 -3
  56. package/dist/chunk-DIB4GX3G.js +8 -0
  57. package/dist/{chunk-OXE5ZUTS.js → chunk-EW5MLKT5.js} +10 -75
  58. package/dist/{chunk-42WRQLJ6.js → chunk-F3B2YJ76.js} +0 -14
  59. package/dist/chunk-FA6POGLH.js +70 -0
  60. package/dist/{chunk-ZRSUCJGA.js → chunk-FHC4JUSF.js} +1 -1
  61. package/dist/{chunk-6Y5L4BOM.js → chunk-FXOYURO4.js} +5 -3
  62. package/dist/{chunk-UKGNSJQQ.js → chunk-G36V2YGB.js} +108 -82
  63. package/dist/{chunk-K5BXPM74.js → chunk-G5SX4UPR.js} +3 -43
  64. package/dist/chunk-HDSDCEPK.js +80 -0
  65. package/dist/{chunk-LLKDNPYV.js → chunk-HWCQRGLL.js} +37 -3
  66. package/dist/{chunk-C4MZ3GP5.js → chunk-HZF5P5UN.js} +1 -1
  67. package/dist/chunk-LYA2AB5G.js +1914 -0
  68. package/dist/{chunk-36UJA3OD.js → chunk-NVUQSFWX.js} +2 -2
  69. package/dist/chunk-OB42YVAE.js +16 -0
  70. package/dist/{chunk-4VKFQPCW.js → chunk-PVZHG2XZ.js} +4 -4
  71. package/dist/{chunk-YJ44UT7D.js → chunk-RAVKCKXA.js} +7 -7
  72. package/dist/{chunk-RCBUZGIT.js → chunk-SYJT7AKB.js} +23 -20
  73. package/dist/{chunk-NP7TYFYR.js → chunk-TVE25LPW.js} +1 -1
  74. package/dist/chunk-W3U3YQYI.js +71 -0
  75. package/dist/chunk-YCLO7D7M.js +4267 -0
  76. package/dist/cli/chat.js +72 -40
  77. package/dist/cli/check.js +10 -8
  78. package/dist/cli/init.js +1 -0
  79. package/dist/cli/plugins.js +16 -14
  80. package/dist/cli/snapshot-warmup.js +13 -11
  81. package/dist/cli/upgrade.js +10 -8
  82. package/dist/{db-2ASK6MV6.js → db-KBSJHAZU.js} +8 -7
  83. package/dist/handlers/sandbox-egress-signals.d.ts +4 -0
  84. package/dist/instrumentation.js +72 -4
  85. package/dist/nitro.js +2 -2
  86. package/dist/oauth-callback-server-EYRMJTCS.js +231 -0
  87. package/dist/oauth-relay-3ZU72UGL.js +9 -0
  88. package/dist/reporting-schema.d.ts +12 -4
  89. package/dist/reporting.d.ts +5 -5
  90. package/dist/{runner-L363K62Z.js → runner-RQGZ5Z2S.js} +139 -72
  91. package/dist/sandbox-egress-signals-CDFAP67O.js +75 -0
  92. package/dist/{skills-VCPG3NOO.js → skills-JJQIE3BT.js} +10 -8
  93. package/dist/validation-MZ47PZP5.js +21 -0
  94. package/dist/version.js +1 -1
  95. package/package.json +5 -5
  96. package/dist/catalog-runtime-6XYOUVRZ.js +0 -16
  97. package/dist/chat/oauth-authorization-message.d.ts +0 -6
  98. package/dist/validation-GY7AJBLC.js +0 -19
@@ -0,0 +1,18 @@
1
+ import {
2
+ pluginCatalogRuntime
3
+ } from "./chunk-6FKLPVF3.js";
4
+ import "./chunk-EW5MLKT5.js";
5
+ import "./chunk-W3U3YQYI.js";
6
+ import "./chunk-HZF5P5UN.js";
7
+ import "./chunk-NVUQSFWX.js";
8
+ import "./chunk-OB42YVAE.js";
9
+ import "./chunk-F3B2YJ76.js";
10
+ import "./chunk-6GWA276C.js";
11
+ import "./chunk-B3IT5END.js";
12
+ import "./chunk-3V7OFJZC.js";
13
+ import "./chunk-TVE25LPW.js";
14
+ import "./chunk-FHC4JUSF.js";
15
+ import "./chunk-MLKGABMK.js";
16
+ export {
17
+ pluginCatalogRuntime
18
+ };
@@ -15,7 +15,9 @@ import type { PiMessage } from "@/chat/pi/messages";
15
15
  import type { Actor } from "@/chat/actor";
16
16
  import type { SandboxRef } from "@/chat/sandbox/ref";
17
17
  import type { SandboxEgressTracePropagationConfig } from "@/chat/sandbox/egress/tracing";
18
+ import type { SandboxEgressSignalTransport } from "@/chat/sandbox/egress/signals";
18
19
  import type { AuthorizationFlowMode } from "@/chat/services/auth-pause";
20
+ import type { OAuthAuthorization } from "@/chat/oauth-authorization";
19
21
  import type { AssistantStatusSpec } from "@/chat/slack/assistant-thread/status";
20
22
  import type { SlackConversationContext } from "@/chat/slack/conversation-context";
21
23
  import type { ThreadArtifactsState } from "@/chat/state/artifacts";
@@ -94,6 +96,8 @@ export interface AgentRunPolicy {
94
96
  skillDirs?: string[];
95
97
  /** Per-slice override for app-owned sandbox egress trace propagation. */
96
98
  sandboxTracePropagation?: SandboxEgressTracePropagationConfig;
99
+ /** Per-slice sandbox egress signal storage override. */
100
+ sandboxEgressSignals?: SandboxEgressSignalTransport;
97
101
  toolOverrides?: {
98
102
  imageGenerate?: ImageGenerateToolDeps;
99
103
  webFetch?: WebFetchToolDeps;
@@ -152,6 +156,8 @@ export interface AgentRunRequest {
152
156
  runId?: string;
153
157
  input: AgentRunInput;
154
158
  routing: AgentRunRouting;
159
+ /** Surface-owned OAuth state and private delivery capabilities. */
160
+ authorization?: OAuthAuthorization;
155
161
  policy?: AgentRunPolicy;
156
162
  state?: AgentRunState;
157
163
  observers?: AgentRunObservers;
@@ -11,6 +11,7 @@ import type { ChannelConfigurationService } from "@/chat/configuration/types";
11
11
  import type { CredentialContext } from "@/chat/credentials/context";
12
12
  import type { LogContext } from "@/chat/logging";
13
13
  import type { SandboxEgressTracePropagationConfig } from "@/chat/sandbox/egress/tracing";
14
+ import type { SandboxEgressSignalTransport } from "@/chat/sandbox/egress/signals";
14
15
  import type { SandboxRef } from "@/chat/sandbox/ref";
15
16
  import { type SandboxTools } from "@/chat/sandbox/sandbox";
16
17
  import type { SandboxWorkspace } from "@/chat/sandbox/workspace";
@@ -21,6 +22,7 @@ export interface AgentSandboxOptions {
21
22
  skills: SkillMetadata[];
22
23
  traceContext: LogContext;
23
24
  tracePropagation?: SandboxEgressTracePropagationConfig;
25
+ egressSignals?: SandboxEgressSignalTransport;
24
26
  credentialEgress?: CredentialContext;
25
27
  actor?: Actor;
26
28
  channelConfiguration?: ChannelConfigurationService;
@@ -20,6 +20,7 @@ import type { SandboxRef } from "@/chat/sandbox/ref";
20
20
  import type { PiMessage } from "@/chat/pi/messages";
21
21
  import type { LogContext } from "@/chat/logging";
22
22
  import type { ConversationPrivacy } from "@/chat/conversation-privacy";
23
+ import type { OAuthAuthorization } from "@/chat/oauth-authorization";
23
24
  import type { Actor } from "@/chat/actor";
24
25
  import type { ThreadArtifactsState } from "@/chat/state/artifacts";
25
26
  import type { AuthorizationPauseError } from "@/chat/services/auth-pause";
@@ -38,6 +39,7 @@ interface ToolWiringArgs {
38
39
  connectedMcpProviders: Set<string>;
39
40
  conversationPrivacy?: ConversationPrivacy;
40
41
  durability: AgentRunDurability;
42
+ authorization?: OAuthAuthorization;
41
43
  generatedFiles: FileUpload[];
42
44
  invokedSkill: SkillMetadata | null;
43
45
  observers: AgentRunObservers;
@@ -8,19 +8,21 @@ export declare const FUNCTION_TIMEOUT_BUFFER_SECONDS = 20;
8
8
  /** Additional buffer that makes conversation work yield before the hard request deadline. */
9
9
  export declare const CONVERSATION_WORK_SOFT_YIELD_BUFFER_SECONDS = 40;
10
10
  export interface BotConfig {
11
+ contextWindowTokens: number;
12
+ crossActorMidRunMode: CrossActorMidRunMode;
11
13
  embeddingModelId: string;
12
14
  fastModelId: string;
13
15
  imageGenerationModelId: string;
14
16
  loadingMessages: string[];
15
17
  profiles: Readonly<Record<string, ExecutionProfileConfig>>;
16
18
  reasoningLevel?: TurnReasoningLevel;
17
- modelContextWindowTokens?: number;
18
19
  visionModelId?: string;
19
20
  maxSlicesPerTurn: number;
20
21
  turnTimeoutMs: number;
21
22
  userName: string;
22
23
  webSearchModelId: string;
23
24
  }
25
+ export type CrossActorMidRunMode = "follow_up" | "steer";
24
26
  export type SqlDriver = "neon" | "postgres";
25
27
  export interface ChatConfig {
26
28
  bot: BotConfig;
@@ -27,6 +27,7 @@ export declare const historyReplacementSchema: z.ZodObject<{
27
27
  modelId: z.ZodString;
28
28
  reasoningLevel: z.ZodOptional<z.ZodString>;
29
29
  triggeringToolCallId: z.ZodOptional<z.ZodString>;
30
+ summary: z.ZodOptional<z.ZodString>;
30
31
  replacementHistory: z.ZodArray<z.ZodObject<{
31
32
  message: z.ZodPipe<z.ZodObject<{
32
33
  role: z.ZodString;
@@ -62,6 +63,17 @@ export declare const historyReplacementSchema: z.ZodObject<{
62
63
  type: z.ZodLiteral<"compaction">;
63
64
  modelProfile: z.ZodString;
64
65
  modelId: z.ZodString;
66
+ details: z.ZodOptional<z.ZodObject<{
67
+ reason: z.ZodLiteral<"capacity">;
68
+ estimatedInputTokens: z.ZodNumber;
69
+ replacementInputTokens: z.ZodOptional<z.ZodNumber>;
70
+ triggerTokens: z.ZodNumber;
71
+ inputLimitTokens: z.ZodNumber;
72
+ inputMessageCount: z.ZodNumber;
73
+ retainedMessageCount: z.ZodNumber;
74
+ summaryChars: z.ZodNumber;
75
+ }, z.core.$strict>>;
76
+ summary: z.ZodOptional<z.ZodString>;
65
77
  replacementHistory: z.ZodArray<z.ZodObject<{
66
78
  message: z.ZodPipe<z.ZodObject<{
67
79
  role: z.ZodString;
@@ -204,6 +216,24 @@ export declare const conversationEventDataSchema: z.ZodUnion<readonly [z.ZodUnio
204
216
  internal: "internal";
205
217
  scheduler: "scheduler";
206
218
  }>;
219
+ }, z.core.$strict>, z.ZodObject<{
220
+ type: z.ZodLiteral<"turn_routed">;
221
+ turnId: z.ZodString;
222
+ modelProfile: z.ZodString;
223
+ modelId: z.ZodString;
224
+ reasoningLevel: z.ZodEnum<{
225
+ low: "low";
226
+ medium: "medium";
227
+ high: "high";
228
+ xhigh: "xhigh";
229
+ none: "none";
230
+ }>;
231
+ confidence: z.ZodOptional<z.ZodNumber>;
232
+ source: z.ZodEnum<{
233
+ configured: "configured";
234
+ inherited: "inherited";
235
+ router: "router";
236
+ }>;
207
237
  }, z.core.$strict>, z.ZodObject<{
208
238
  type: z.ZodLiteral<"turn_completed">;
209
239
  turnId: z.ZodString;
@@ -240,6 +270,7 @@ export declare const conversationEventDataSchema: z.ZodUnion<readonly [z.ZodUnio
240
270
  modelId: z.ZodString;
241
271
  reasoningLevel: z.ZodOptional<z.ZodString>;
242
272
  triggeringToolCallId: z.ZodOptional<z.ZodString>;
273
+ summary: z.ZodOptional<z.ZodString>;
243
274
  replacementHistory: z.ZodArray<z.ZodObject<{
244
275
  message: z.ZodPipe<z.ZodObject<{
245
276
  role: z.ZodString;
@@ -275,6 +306,17 @@ export declare const conversationEventDataSchema: z.ZodUnion<readonly [z.ZodUnio
275
306
  type: z.ZodLiteral<"compaction">;
276
307
  modelProfile: z.ZodString;
277
308
  modelId: z.ZodString;
309
+ details: z.ZodOptional<z.ZodObject<{
310
+ reason: z.ZodLiteral<"capacity">;
311
+ estimatedInputTokens: z.ZodNumber;
312
+ replacementInputTokens: z.ZodOptional<z.ZodNumber>;
313
+ triggerTokens: z.ZodNumber;
314
+ inputLimitTokens: z.ZodNumber;
315
+ inputMessageCount: z.ZodNumber;
316
+ retainedMessageCount: z.ZodNumber;
317
+ summaryChars: z.ZodNumber;
318
+ }, z.core.$strict>>;
319
+ summary: z.ZodOptional<z.ZodString>;
278
320
  replacementHistory: z.ZodArray<z.ZodObject<{
279
321
  message: z.ZodPipe<z.ZodObject<{
280
322
  role: z.ZodString;
@@ -447,6 +489,24 @@ export declare const conversationEventSchema: z.ZodUnion<readonly [z.ZodObject<{
447
489
  internal: "internal";
448
490
  scheduler: "scheduler";
449
491
  }>;
492
+ }, z.core.$strict>, z.ZodObject<{
493
+ type: z.ZodLiteral<"turn_routed">;
494
+ turnId: z.ZodString;
495
+ modelProfile: z.ZodString;
496
+ modelId: z.ZodString;
497
+ reasoningLevel: z.ZodEnum<{
498
+ low: "low";
499
+ medium: "medium";
500
+ high: "high";
501
+ xhigh: "xhigh";
502
+ none: "none";
503
+ }>;
504
+ confidence: z.ZodOptional<z.ZodNumber>;
505
+ source: z.ZodEnum<{
506
+ configured: "configured";
507
+ inherited: "inherited";
508
+ router: "router";
509
+ }>;
450
510
  }, z.core.$strict>, z.ZodObject<{
451
511
  type: z.ZodLiteral<"turn_completed">;
452
512
  turnId: z.ZodString;
@@ -483,6 +543,7 @@ export declare const conversationEventSchema: z.ZodUnion<readonly [z.ZodObject<{
483
543
  modelId: z.ZodString;
484
544
  reasoningLevel: z.ZodOptional<z.ZodString>;
485
545
  triggeringToolCallId: z.ZodOptional<z.ZodString>;
546
+ summary: z.ZodOptional<z.ZodString>;
486
547
  replacementHistory: z.ZodArray<z.ZodObject<{
487
548
  message: z.ZodPipe<z.ZodObject<{
488
549
  role: z.ZodString;
@@ -518,6 +579,17 @@ export declare const conversationEventSchema: z.ZodUnion<readonly [z.ZodObject<{
518
579
  type: z.ZodLiteral<"compaction">;
519
580
  modelProfile: z.ZodString;
520
581
  modelId: z.ZodString;
582
+ details: z.ZodOptional<z.ZodObject<{
583
+ reason: z.ZodLiteral<"capacity">;
584
+ estimatedInputTokens: z.ZodNumber;
585
+ replacementInputTokens: z.ZodOptional<z.ZodNumber>;
586
+ triggerTokens: z.ZodNumber;
587
+ inputLimitTokens: z.ZodNumber;
588
+ inputMessageCount: z.ZodNumber;
589
+ retainedMessageCount: z.ZodNumber;
590
+ summaryChars: z.ZodNumber;
591
+ }, z.core.$strict>>;
592
+ summary: z.ZodOptional<z.ZodString>;
521
593
  replacementHistory: z.ZodArray<z.ZodObject<{
522
594
  message: z.ZodPipe<z.ZodObject<{
523
595
  role: z.ZodString;
@@ -717,6 +789,24 @@ export declare const newConversationEventSchema: z.ZodObject<{
717
789
  internal: "internal";
718
790
  scheduler: "scheduler";
719
791
  }>;
792
+ }, z.core.$strict>, z.ZodObject<{
793
+ type: z.ZodLiteral<"turn_routed">;
794
+ turnId: z.ZodString;
795
+ modelProfile: z.ZodString;
796
+ modelId: z.ZodString;
797
+ reasoningLevel: z.ZodEnum<{
798
+ low: "low";
799
+ medium: "medium";
800
+ high: "high";
801
+ xhigh: "xhigh";
802
+ none: "none";
803
+ }>;
804
+ confidence: z.ZodOptional<z.ZodNumber>;
805
+ source: z.ZodEnum<{
806
+ configured: "configured";
807
+ inherited: "inherited";
808
+ router: "router";
809
+ }>;
720
810
  }, z.core.$strict>, z.ZodObject<{
721
811
  type: z.ZodLiteral<"turn_completed">;
722
812
  turnId: z.ZodString;
@@ -759,6 +849,8 @@ export interface ConversationEventStore {
759
849
  append(conversationId: string, events: NewConversationEvent[]): Promise<void>;
760
850
  /** Replace active model history with a compaction or handoff event. */
761
851
  replaceHistory(conversationId: string, replacement: HistoryReplacement): Promise<void>;
852
+ /** One event selected by its retry-stable key across history versions. */
853
+ loadByIdempotencyKey(conversationId: string, idempotencyKey: string): Promise<ConversationEvent | undefined>;
762
854
  /** Events of the current history version in `seq` order. */
763
855
  loadCurrentHistory(conversationId: string): Promise<ConversationEvent[]>;
764
856
  /** Events in the history version containing `seq`, when it exists. */
@@ -1,8 +1,10 @@
1
1
  import { type PiMessage } from "@/chat/pi/messages";
2
2
  import { type ConversationMessageProvenance } from "@/chat/conversations/provenance";
3
- import type { AuthorizationKind } from "@/chat/conversations/history";
3
+ import type { AuthorizationKind, ConversationEvent } from "@/chat/conversations/history";
4
4
  import type { JuniorSqlDatabase } from "@/db/db";
5
5
  import { type PiConversationEventProjection, type PiConversationProjection } from "@/chat/pi/conversation-events";
6
+ import type { ModelProfile } from "@/chat/model-profile";
7
+ import type { TurnReasoningLevel } from "@/chat/reasoning-level";
6
8
  interface ScopedConversation {
7
9
  conversationId: string;
8
10
  }
@@ -77,6 +79,23 @@ export declare function recordAuthorizationCompleted(args: {
77
79
  actorId: string;
78
80
  authorizationId: string;
79
81
  }): Promise<void>;
82
+ /** Load a previously selected execution profile for a resumed turn. */
83
+ export declare function loadTurnRoute(args: {
84
+ conversationId: string;
85
+ turnId: string;
86
+ }): Promise<Extract<ConversationEvent["data"], {
87
+ type: "turn_routed";
88
+ }> | undefined>;
89
+ /** Record the execution profile selected for one turn without changing agent history. */
90
+ export declare function recordTurnRoute(args: {
91
+ conversationId: string;
92
+ turnId: string;
93
+ modelProfile: ModelProfile;
94
+ modelId: string;
95
+ reasoningLevel: TurnReasoningLevel;
96
+ confidence?: number;
97
+ source: "configured" | "inherited" | "router";
98
+ }): Promise<void>;
80
99
  /** Record a host-observed parent tool start without adding it to Pi replay. */
81
100
  export declare function recordToolExecutionStarted(args: {
82
101
  conversationId: string;
@@ -0,0 +1,5 @@
1
+ import { type PluginStoredTokens } from "@sentry/junior-plugin-api";
2
+ /** Copy a local user's provider credential to the loopback dev-server broker. */
3
+ export declare function syncLocalOAuthCredential(provider: string, tokens: PluginStoredTokens): Promise<void>;
4
+ /** Verify and store one credential sent by the local CLI over loopback. */
5
+ export declare function receiveLocalOAuthCredential(request: Request): Promise<Response>;
@@ -0,0 +1,4 @@
1
+ /** Create an OAuth state value that can be safely relayed to a local CLI callback. */
2
+ export declare function createLocalOAuthState(port: number): Promise<string>;
3
+ /** Redirect a provider callback from the public dev URL to the owning local CLI. */
4
+ export declare function relayLocalOAuthCallback(request: Request): Promise<Response | undefined>;
@@ -17,6 +17,7 @@ export declare function createMcpOAuthClientProvider(input: {
17
17
  toolChannelId?: string;
18
18
  configuration?: Record<string, unknown>;
19
19
  artifactState?: ThreadArtifactsState;
20
+ createAuthorizationState?: () => Promise<string>;
20
21
  }): Promise<StateBackedMcpOAuthClientProvider>;
21
22
  /** Exchange a callback code while guarding every shared credential mutation. */
22
23
  export declare function finalizeMcpAuthorization(provider: string, authSessionId: string, authorizationCode: string, runCredentialMutation?: <T>(mutation: () => Promise<T>) => Promise<T>): Promise<McpAuthSessionState>;
@@ -0,0 +1,17 @@
1
+ /** User-facing link and guidance for one OAuth authorization attempt. */
2
+ export interface OAuthAuthorizationRequest {
3
+ authorizationUrl: string;
4
+ completionText: string;
5
+ label: string;
6
+ }
7
+ /** Surface-owned capabilities for creating and presenting OAuth authorization. */
8
+ export interface OAuthAuthorization {
9
+ createState: () => Promise<string>;
10
+ deliver: (request: OAuthAuthorizationRequest) => void | Promise<void>;
11
+ }
12
+ /** Build the stable event identity shared by authorization request and completion. */
13
+ export declare function authorizationId(args: {
14
+ kind: "mcp" | "plugin";
15
+ provider: string;
16
+ sessionId: string;
17
+ }): string;
@@ -1,4 +1,5 @@
1
1
  import { type Destination, type Source } from "@sentry/junior-plugin-api";
2
+ import type { OAuthAuthorization, OAuthAuthorizationRequest } from "@/chat/oauth-authorization";
2
3
  type PrivateDeliveryResult = "in_context" | "fallback_dm" | false;
3
4
  export type OAuthStatePayload = {
4
5
  userId: string;
@@ -21,6 +22,7 @@ type OAuthFlowInput = {
21
22
  resumeConversationId?: string;
22
23
  resumeSessionId?: string;
23
24
  scope?: string;
25
+ authorization?: OAuthAuthorization;
24
26
  };
25
27
  /** Parse OAuth callback state that was persisted before a provider redirect. */
26
28
  export declare function parseOAuthStatePayload(value: unknown): OAuthStatePayload | undefined;
@@ -38,6 +40,13 @@ export declare function deliverPrivateMessage(input: {
38
40
  userId: string;
39
41
  text: string;
40
42
  }): Promise<PrivateDeliveryResult>;
43
+ /** Present one OAuth request through the active surface's private delivery. */
44
+ export declare function deliverOAuthAuthorization(request: OAuthAuthorizationRequest, input: {
45
+ authorization?: OAuthAuthorization;
46
+ channelId?: string;
47
+ threadTs?: string;
48
+ userId: string;
49
+ }): Promise<PrivateDeliveryResult>;
41
50
  /** Initiate an OAuth authorization code flow for a provider and deliver the auth link to the user. */
42
51
  export declare function startOAuthFlow(provider: string, input: OAuthFlowInput): Promise<{
43
52
  ok: false;
@@ -113,6 +113,52 @@ export declare const sandboxEgressPermissionDeniedSignalSchema: z.ZodObject<{
113
113
  upstreamPath: z.ZodString;
114
114
  createdAtMs: z.ZodNumber;
115
115
  }, z.core.$strict>;
116
+ export declare const sandboxEgressSignalsResponseSchema: z.ZodObject<{
117
+ auth_required: z.ZodOptional<z.ZodObject<{
118
+ authorization: z.ZodOptional<z.ZodObject<{
119
+ provider: z.ZodString;
120
+ scope: z.ZodOptional<z.ZodString>;
121
+ type: z.ZodLiteral<"oauth">;
122
+ }, z.core.$strict>>;
123
+ grant: z.ZodObject<{
124
+ access: z.ZodUnion<readonly [z.ZodLiteral<"read">, z.ZodLiteral<"write">]>;
125
+ leaseScope: z.ZodOptional<z.ZodString>;
126
+ name: z.ZodString;
127
+ reason: z.ZodOptional<z.ZodString>;
128
+ requirements: z.ZodOptional<z.ZodArray<z.ZodString>>;
129
+ }, z.core.$strict>;
130
+ kind: z.ZodDefault<z.ZodEnum<{
131
+ unavailable: "unavailable";
132
+ auth_required: "auth_required";
133
+ }>>;
134
+ provider: z.ZodString;
135
+ message: z.ZodOptional<z.ZodString>;
136
+ createdAtMs: z.ZodNumber;
137
+ }, z.core.$strict>>;
138
+ permission_denied: z.ZodOptional<z.ZodObject<{
139
+ account: z.ZodOptional<z.ZodObject<{
140
+ id: z.ZodString;
141
+ label: z.ZodOptional<z.ZodString>;
142
+ url: z.ZodOptional<z.ZodString>;
143
+ }, z.core.$strict>>;
144
+ acceptedPermissions: z.ZodOptional<z.ZodString>;
145
+ grant: z.ZodObject<{
146
+ access: z.ZodUnion<readonly [z.ZodLiteral<"read">, z.ZodLiteral<"write">]>;
147
+ leaseScope: z.ZodOptional<z.ZodString>;
148
+ name: z.ZodString;
149
+ reason: z.ZodOptional<z.ZodString>;
150
+ requirements: z.ZodOptional<z.ZodArray<z.ZodString>>;
151
+ }, z.core.$strict>;
152
+ message: z.ZodString;
153
+ provider: z.ZodString;
154
+ source: z.ZodLiteral<"upstream">;
155
+ sso: z.ZodOptional<z.ZodString>;
156
+ status: z.ZodNumber;
157
+ upstreamHost: z.ZodString;
158
+ upstreamPath: z.ZodString;
159
+ createdAtMs: z.ZodNumber;
160
+ }, z.core.$strict>>;
161
+ }, z.core.$strict>;
116
162
  export type SandboxEgressCredentialContext = z.output<typeof sandboxEgressCredentialContextSchema>;
117
163
  export type SandboxEgressGrant = z.output<typeof sandboxEgressGrantSchema>;
118
164
  export type SandboxEgressCredentialLease = z.output<typeof sandboxEgressCredentialLeaseSchema>;
@@ -0,0 +1,9 @@
1
+ import type { SandboxEgressAuthRequiredSignal, SandboxEgressPermissionDeniedSignal } from "@/chat/sandbox/egress/schemas";
2
+ /** Authenticated transport for signal state owned by another Junior process. */
3
+ export interface SandboxEgressSignalTransport {
4
+ clear: (credentialToken: string) => Promise<void>;
5
+ consume: (credentialToken: string) => Promise<{
6
+ authRequired?: SandboxEgressAuthRequiredSignal;
7
+ permissionDenied?: SandboxEgressPermissionDeniedSignal;
8
+ }>;
9
+ }
@@ -1,4 +1,5 @@
1
1
  import { type LogContext } from "@/chat/logging";
2
+ import type { SandboxEgressSignalTransport } from "@/chat/sandbox/egress/signals";
2
3
  import type { SandboxEgressTracePropagationConfig } from "@/chat/sandbox/egress/tracing";
3
4
  import type { CredentialContext } from "@/chat/credentials/context";
4
5
  import type { SandboxRef } from "@/chat/sandbox/ref";
@@ -26,6 +27,7 @@ export interface SandboxOptions {
26
27
  traceContext?: LogContext;
27
28
  tracePropagation?: SandboxEgressTracePropagationConfig;
28
29
  credentialEgress?: CredentialContext;
30
+ egressSignals?: SandboxEgressSignalTransport;
29
31
  prepare?: (workspace: SandboxWorkspace) => void | Promise<void>;
30
32
  onSandboxRefChanged?: (sandboxRef: SandboxRef) => void | Promise<void>;
31
33
  }
@@ -3,12 +3,12 @@ type SentryErrorEvent = Parameters<NonNullable<Sentry.NodeOptions["beforeSend"]>
3
3
  type SentryTransactionEvent = Parameters<NonNullable<Sentry.NodeOptions["beforeSendTransaction"]>>[0];
4
4
  type SentrySpan = Parameters<Parameters<typeof Sentry.withStreamedSpan>[0]>[0];
5
5
  type SentryLog = Parameters<NonNullable<Sentry.NodeOptions["beforeSendLog"]>>[0];
6
- /** Remove raw private conversation payloads from Sentry error events. */
6
+ /** Remove private conversation payloads and boundary secrets from error events. */
7
7
  export declare function scrubPrivateSentryEvent(event: SentryErrorEvent): SentryErrorEvent | null;
8
- /** Remove raw private conversation payloads from Sentry transaction events. */
8
+ /** Remove private conversation payloads and boundary secrets from transactions. */
9
9
  export declare function scrubPrivateSentryTransaction(event: SentryTransactionEvent): SentryTransactionEvent | null;
10
- /** Remove raw private conversation payloads from streamed Sentry spans. */
10
+ /** Remove private conversation payloads and boundary secrets from streamed spans. */
11
11
  export declare function scrubPrivateSentrySpan(span: SentrySpan): SentrySpan;
12
- /** Remove raw private conversation payloads from Sentry structured logs. */
12
+ /** Remove private conversation payloads and boundary secrets from structured logs. */
13
13
  export declare function scrubPrivateSentryLog(log: SentryLog): SentryLog | null;
14
14
  export {};
@@ -1,14 +1,19 @@
1
1
  export interface ModelContextBudget {
2
2
  contextWindow: number;
3
- maxTokens: number;
4
3
  }
5
4
  /** Estimate text tokens with the shared coarse heuristic used for local budgets. */
6
5
  export declare function estimateTextTokens(text: string): number;
7
6
  /** Derive the automatic compaction threshold from model context capacity. */
8
7
  export declare function calculateContextCompactionTriggerTokens(model: ModelContextBudget): number;
8
+ /** Derive the maximum estimated input size with room for uncounted request overhead. */
9
+ export declare function calculateContextInputLimitTokens(model: ModelContextBudget): number;
9
10
  /** Derive the post-compaction target from the automatic trigger threshold. */
10
11
  export declare function calculateContextCompactionTargetTokens(triggerTokens: number): number;
12
+ /** Cap one model's advertised context capacity with the host bot configuration. */
13
+ export declare function getModelContextBudget(modelId: string): ModelContextBudget;
11
14
  /** Resolve the automatic compaction threshold for the active agent model. */
12
- export declare function getAgentContextCompactionTriggerTokens(): number;
15
+ export declare function getAgentContextCompactionTriggerTokens(modelId: string): number;
16
+ /** Resolve the hard input ceiling for the active agent model. */
17
+ export declare function getAgentContextInputLimitTokens(modelId: string): number;
13
18
  /** Resolve the visible conversation compaction threshold for the auxiliary model. */
14
19
  export declare function getConversationContextCompactionTriggerTokens(): number;
@@ -1,5 +1,6 @@
1
1
  import type { completeText } from "@/chat/pi/client";
2
2
  import type { PiMessage } from "@/chat/pi/messages";
3
+ import { type ConversationMessageProvenance } from "@/chat/conversations/provenance";
3
4
  import type { ThreadConversationState } from "@/chat/state/conversation";
4
5
  import { type ModelProfile } from "@/chat/model-profile";
5
6
  export interface ContextCompactorDeps {
@@ -13,7 +14,7 @@ export interface CompactContextArgs {
13
14
  conversation: ThreadConversationState;
14
15
  conversationContext?: string;
15
16
  conversationId: string;
16
- onCompactionStart?: () => void;
17
+ onCompactionStart?: () => void | Promise<void>;
17
18
  piMessages: PiMessage[];
18
19
  metadata?: {
19
20
  channelId?: string;
@@ -21,6 +22,7 @@ export interface CompactContextArgs {
21
22
  runId?: string;
22
23
  threadId?: string;
23
24
  };
25
+ modelId: string;
24
26
  }
25
27
  export interface CompactContextResult {
26
28
  compacted: boolean;
@@ -41,10 +43,35 @@ interface HandoffContextArgs {
41
43
  reasoningLevel?: string;
42
44
  };
43
45
  }
46
+ interface ActiveContextCompactionArgs {
47
+ conversationContext?: string;
48
+ conversationId: string;
49
+ metadata?: CompactContextArgs["metadata"];
50
+ modelId: string;
51
+ modelProfile: ModelProfile;
52
+ onCompactionStart?: () => void | Promise<void>;
53
+ pendingMessages?: Array<{
54
+ message: PiMessage;
55
+ provenance: ConversationMessageProvenance;
56
+ }>;
57
+ piMessages: PiMessage[];
58
+ signal?: AbortSignal;
59
+ }
60
+ /** Raised when Junior cannot compact history below the active model's hard ceiling. */
61
+ export declare class ContextInputLimitExceededError extends Error {
62
+ readonly estimatedTokens: number;
63
+ readonly inputLimitTokens: number;
64
+ constructor(estimatedTokens: number, inputLimitTokens: number);
65
+ }
44
66
  /** Build retained user messages for a compacted Pi replacement history. */
45
67
  export declare function selectRetainedUserMessages(messages: PiMessage[], maxTokens?: number): PiMessage[];
46
68
  /** Build the service that owns local context compaction. */
47
69
  export declare function createContextCompactor(deps: ContextCompactorDeps): ContextCompactor;
48
70
  /** Compact the active conversation and durably bind its selected handoff profile. */
49
71
  export declare function compactContextForHandoff(args: HandoffContextArgs, deps: Pick<ContextCompactorDeps, "completeText">): Promise<PiMessage[]>;
72
+ /**
73
+ * Replace oversized active history at Pi's next-turn boundary before another
74
+ * provider request can observe it.
75
+ */
76
+ export declare function compactActiveContextIfNeeded(args: ActiveContextCompactionArgs, deps: Pick<ContextCompactorDeps, "completeText">): Promise<CompactContextResult>;
50
77
  export {};
@@ -14,6 +14,7 @@ export interface ConversationMemoryService {
14
14
  generateThreadTitle: (sourceText: string) => Promise<string>;
15
15
  }
16
16
  export declare function generateConversationId(prefix: "assistant" | "backfill" | "compaction" | "turn"): string;
17
+ /** Normalize message boundaries without changing transcript formatting. */
17
18
  export declare function normalizeConversationText(text: string): string;
18
19
  export declare function updateConversationStats(conversation: ThreadConversationState): void;
19
20
  export declare function upsertConversationMessage(conversation: ThreadConversationState, message: ConversationMessage): string;
@@ -2,12 +2,13 @@
2
2
  * MCP authorization pause orchestration.
3
3
  *
4
4
  * This module turns an MCP client auth challenge into Junior's paused-run
5
- * model: create provider auth state, deliver or reuse a private Slack link,
6
- * record pending auth, and abort the agent so the OAuth callback can resume the
7
- * same session.
5
+ * model: create provider auth state, privately present or reuse its link,
6
+ * record pending auth, and abort the agent so the OAuth callback can resume
7
+ * the same session.
8
8
  */
9
9
  import type { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
10
10
  import type { Destination, Source } from "@sentry/junior-plugin-api";
11
+ import { type OAuthAuthorization } from "@/chat/oauth-authorization";
11
12
  import { AuthorizationPauseError, type AuthorizationFlowMode } from "@/chat/services/auth-pause";
12
13
  import type { ThreadArtifactsState } from "@/chat/state/artifacts";
13
14
  import type { ConversationPendingAuthState } from "@/chat/state/conversation";
@@ -32,6 +33,7 @@ export interface McpAuthOrchestrationInput {
32
33
  getMergedArtifactState: () => ThreadArtifactsState;
33
34
  recordPendingAuth?: (pendingAuth: ConversationPendingAuthState | undefined) => void | Promise<void>;
34
35
  authorizationFlowMode?: AuthorizationFlowMode;
36
+ authorization?: OAuthAuthorization;
35
37
  }
36
38
  export interface McpAuthOrchestration {
37
39
  authProviderFactory: (plugin: PluginDefinition) => Promise<OAuthClientProvider | undefined>;
@@ -14,6 +14,7 @@ import type { Destination, Source } from "@sentry/junior-plugin-api";
14
14
  import type { UserTokenStore } from "@/chat/credentials/user-token-store";
15
15
  import { AuthorizationPauseError, type AuthorizationFlowMode } from "@/chat/services/auth-pause";
16
16
  import type { ConversationPendingAuthState } from "@/chat/state/conversation";
17
+ import { type OAuthAuthorization } from "@/chat/oauth-authorization";
17
18
  export declare class PluginAuthorizationPauseError extends AuthorizationPauseError {
18
19
  constructor(provider: string, providerDisplayName: string, disposition: "link_already_sent" | "link_sent", requestText?: string);
19
20
  }
@@ -35,6 +36,7 @@ export interface PluginAuthOrchestrationInput {
35
36
  recordPendingAuth?: (pendingAuth: ConversationPendingAuthState) => void | Promise<void>;
36
37
  authorizationFlowMode?: AuthorizationFlowMode;
37
38
  userTokenStore?: UserTokenStore;
39
+ authorization?: OAuthAuthorization;
38
40
  }
39
41
  export interface PluginAuthOrchestration {
40
42
  /**
@@ -12,6 +12,7 @@ interface ProviderErrorOptions {
12
12
  retryable?: boolean;
13
13
  }
14
14
  interface ProviderErrorDetails {
15
+ cause?: unknown;
15
16
  kind: ProviderErrorKind;
16
17
  modelId?: string;
17
18
  retryable: boolean;
@@ -20,6 +20,7 @@ export interface TurnRoute {
20
20
  profile: ModelProfile;
21
21
  reasoningLevel: TurnReasoningLevel;
22
22
  reason: string;
23
+ source?: "configured" | "inherited" | "router";
23
24
  }
24
25
  /** Preserve an explicitly configured reasoning level without invoking the router. */
25
26
  export declare function configuredTurnRoute(profile: ModelProfile, reasoningLevel: TurnReasoningLevel, source: "agent_config" | "default" | "profile"): TurnRoute;
@@ -0,0 +1,2 @@
1
+ /** Remove the explicit Slack steering marker before building agent input. */
2
+ export declare function stripLeadingSteeringOverride(text: string): string;
@@ -0,0 +1,3 @@
1
+ import type { OAuthAuthorizationRequest } from "@/chat/oauth-authorization";
2
+ /** Format the private OAuth authorization prompt for Slack delivery. */
3
+ export declare function formatOAuthAuthorizationMessage(args: OAuthAuthorizationRequest): string;
@@ -7,6 +7,7 @@ import type { InboundMessage } from "@/chat/task-execution/store";
7
7
  import type { ConversationWorkerContext, ConversationWorkerResult } from "@/chat/task-execution/worker";
8
8
  import { type SlackInstallationContext } from "@/chat/slack/adapter-context";
9
9
  import { type SlackActorProfile } from "@/chat/actor";
10
+ import { type CrossActorMidRunMode } from "@/chat/config";
10
11
  declare const slackConversationRouteSchema: z.ZodEnum<{
11
12
  mention: "mention";
12
13
  subscribed: "subscribed";
@@ -270,6 +271,7 @@ interface SlackResourceEventInboundInput {
270
271
  text: string;
271
272
  }
272
273
  export interface CreateSlackConversationWorkerOptions {
274
+ crossActorMidRunMode?: CrossActorMidRunMode;
273
275
  getSlackAdapter: () => SlackAdapter;
274
276
  lookupSlackUser?: (teamId: string, userId: string) => Promise<SlackActorProfile | null | undefined>;
275
277
  resumeAwaitingContinuation: (conversationId: string, options: {