@sentry/junior 0.114.0 → 0.116.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 (147) hide show
  1. package/dist/{agent-hooks-WNBUY4OB.js → agent-hooks-67NFITDH.js} +13 -12
  2. package/dist/api/conversations/detail.d.ts +20 -0
  3. package/dist/api/conversations/event-list.d.ts +2 -0
  4. package/dist/api/conversations/event-page.d.ts +1 -1
  5. package/dist/api/conversations/events.d.ts +1 -1
  6. package/dist/api/health.d.ts +7 -0
  7. package/dist/api/people/profile.d.ts +2 -2
  8. package/dist/api/people/shared.d.ts +1 -1
  9. package/dist/api/personal-tokens/create.d.ts +11 -0
  10. package/dist/api/personal-tokens/list.d.ts +12 -0
  11. package/dist/api/personal-tokens/revoke.d.ts +5 -0
  12. package/dist/api/personal-tokens/routes.d.ts +4 -0
  13. package/dist/api/plugin-reports.d.ts +62 -0
  14. package/dist/api/plugins.d.ts +8 -0
  15. package/dist/api/route.d.ts +1 -1
  16. package/dist/api/runtime.d.ts +24 -0
  17. package/dist/api/schema/conversation.d.ts +26 -0
  18. package/dist/api/schema/person.d.ts +3 -3
  19. package/dist/api/schema/personal-token.d.ts +38 -0
  20. package/dist/api/schema.d.ts +4 -2
  21. package/dist/api/schema.js +19 -7
  22. package/dist/api/skills.d.ts +6 -0
  23. package/dist/api.d.ts +1 -0
  24. package/dist/api.js +285 -121
  25. package/dist/app.js +1957 -5677
  26. package/dist/catalog-runtime-CWZY6GTH.js +18 -0
  27. package/dist/chat/agent/request.d.ts +7 -0
  28. package/dist/chat/agent/resume.d.ts +1 -0
  29. package/dist/chat/agent/sandbox.d.ts +3 -0
  30. package/dist/chat/agent/tools.d.ts +3 -0
  31. package/dist/chat/agent-dispatch/context.d.ts +2 -0
  32. package/dist/chat/agent-dispatch/heartbeat.d.ts +11 -5
  33. package/dist/chat/agent-dispatch/signing.d.ts +14 -5
  34. package/dist/chat/agent-dispatch/store.d.ts +36 -15
  35. package/dist/chat/agent-dispatch/types.d.ts +23 -10
  36. package/dist/chat/agent-dispatch/work.d.ts +58 -0
  37. package/dist/chat/app/factory.d.ts +12 -3
  38. package/dist/chat/config.d.ts +2 -0
  39. package/dist/chat/conversations/history.d.ts +291 -290
  40. package/dist/chat/conversations/projection.d.ts +2 -2
  41. package/dist/chat/local/credential-sync.d.ts +5 -0
  42. package/dist/chat/local/oauth-relay.d.ts +4 -0
  43. package/dist/chat/mcp/oauth.d.ts +1 -0
  44. package/dist/chat/mcp/tool-manager.d.ts +2 -1
  45. package/dist/chat/oauth-authorization.d.ts +17 -0
  46. package/dist/chat/oauth-flow.d.ts +9 -0
  47. package/dist/chat/pi/conversation-events.d.ts +6 -2
  48. package/dist/chat/plugins/annotations.d.ts +8 -0
  49. package/dist/chat/plugins/registry.d.ts +0 -3
  50. package/dist/chat/plugins/types.d.ts +0 -2
  51. package/dist/chat/runtime/agent-continue-runner.d.ts +4 -0
  52. package/dist/chat/runtime/reply-executor.d.ts +6 -1
  53. package/dist/chat/runtime/slack-resume.d.ts +5 -1
  54. package/dist/chat/runtime/turn-input.d.ts +3 -0
  55. package/dist/chat/sandbox/egress/schemas.d.ts +46 -0
  56. package/dist/chat/sandbox/egress/signals.d.ts +9 -0
  57. package/dist/chat/sandbox/sandbox.d.ts +4 -1
  58. package/dist/chat/sandbox/session.d.ts +2 -11
  59. package/dist/chat/sandbox/workspace.d.ts +10 -2
  60. package/dist/chat/sentry-payload-filter.d.ts +4 -4
  61. package/dist/chat/services/mcp-auth-orchestration.d.ts +5 -3
  62. package/dist/chat/services/plugin-auth-orchestration.d.ts +2 -0
  63. package/dist/chat/services/turn-session-record.d.ts +14 -1
  64. package/dist/chat/slack/dispatch-turn.d.ts +25 -0
  65. package/dist/chat/slack/message-control.d.ts +2 -0
  66. package/dist/chat/slack/oauth-authorization-message.d.ts +3 -0
  67. package/dist/chat/state/turn-session.d.ts +11 -0
  68. package/dist/chat/task-execution/slack-work.d.ts +2 -0
  69. package/dist/chat/tool-support/text-range-result.d.ts +3 -0
  70. package/dist/chat/tool-support/zod-tool.d.ts +2 -1
  71. package/dist/chat/tools/definition.d.ts +3 -5
  72. package/dist/chat/tools/query-conversation-events.d.ts +68 -0
  73. package/dist/chat/tools/sandbox/file-utils.d.ts +8 -1
  74. package/dist/chat/tools/sandbox/find-files.d.ts +2 -1
  75. package/dist/chat/tools/sandbox/grep.d.ts +2 -1
  76. package/dist/{chunk-OSKEC4XU.js → chunk-25GU5B5E.js} +1 -1
  77. package/dist/{chunk-XLFBQJUO.js → chunk-3H45VOBZ.js} +32 -7
  78. package/dist/{chunk-4FUEG3QY.js → chunk-3JOGUT46.js} +4 -16
  79. package/dist/chunk-4CODA7P5.js +43 -0
  80. package/dist/{chunk-O4GT7LYB.js → chunk-4DD6AOCG.js} +3 -43
  81. package/dist/{chunk-YU6PO42Q.js → chunk-53ZKTQO6.js} +1 -1
  82. package/dist/{chunk-WV4UJBAS.js → chunk-5UNB623T.js} +1282 -2536
  83. package/dist/{chunk-TLGM5X2M.js → chunk-6RQ5GCWH.js} +2 -2
  84. package/dist/{chunk-MIAKQNYX.js → chunk-6ZK6FZIV.js} +1 -1
  85. package/dist/{chunk-W6RDUAO3.js → chunk-BXLS3I4W.js} +1 -1
  86. package/dist/{chunk-RD7EJI7H.js → chunk-CI3VK7X5.js} +69 -3
  87. package/dist/chunk-DIB4GX3G.js +8 -0
  88. package/dist/{chunk-42WRQLJ6.js → chunk-F3B2YJ76.js} +0 -14
  89. package/dist/chunk-FA6POGLH.js +70 -0
  90. package/dist/{chunk-6Y5L4BOM.js → chunk-FXOYURO4.js} +5 -3
  91. package/dist/chunk-HDSDCEPK.js +80 -0
  92. package/dist/{chunk-C4MZ3GP5.js → chunk-HZF5P5UN.js} +1 -1
  93. package/dist/{chunk-K2W4CK7K.js → chunk-JZPQ5K4V.js} +10 -129
  94. package/dist/{chunk-FIGAF6KL.js → chunk-KBNDFU6J.js} +108 -38
  95. package/dist/{chunk-PM3PX42K.js → chunk-MGH5ADQS.js} +1 -2
  96. package/dist/{chunk-5CZ7RETL.js → chunk-N7TMYLF2.js} +1 -1
  97. package/dist/chunk-OB42YVAE.js +16 -0
  98. package/dist/{chunk-6QWPVTMO.js → chunk-OF5FODBL.js} +125 -23
  99. package/dist/{chunk-2ZTTXTSZ.js → chunk-PE44LDDQ.js} +9 -4
  100. package/dist/chunk-PGKWXHYJ.js +1870 -0
  101. package/dist/{chunk-ZGXH3REA.js → chunk-PZGPCOSD.js} +12 -2
  102. package/dist/{chunk-JQFJO5WH.js → chunk-RXRQJF7Y.js} +74 -17
  103. package/dist/{chunk-S4QDH23A.js → chunk-TC4ZEM2D.js} +113 -79
  104. package/dist/{chunk-ABPSDO6M.js → chunk-UEVLIYK5.js} +234 -165
  105. package/dist/chunk-VKZ6WVAY.js +4318 -0
  106. package/dist/{chunk-VNNBSKCO.js → chunk-VZCSLYCE.js} +22 -7
  107. package/dist/chunk-W3U3YQYI.js +71 -0
  108. package/dist/{chunk-SG5WAA7H.js → chunk-WKU7TY22.js} +0 -3
  109. package/dist/cli/chat.js +74 -42
  110. package/dist/cli/check.js +10 -8
  111. package/dist/cli/init.js +1 -0
  112. package/dist/cli/plugins.js +18 -16
  113. package/dist/cli/snapshot-warmup.js +13 -11
  114. package/dist/cli/upgrade.js +12 -10
  115. package/dist/db/schema/api-tokens.d.ts +160 -0
  116. package/dist/db/schema/conversation-annotations.d.ts +142 -0
  117. package/dist/db/schema.d.ts +305 -1
  118. package/dist/{db-4VLP7KBF.js → db-57FHVGGQ.js} +9 -8
  119. package/dist/handlers/agent-dispatch.d.ts +7 -3
  120. package/dist/handlers/sandbox-egress-signals.d.ts +4 -0
  121. package/dist/instrumentation.js +72 -4
  122. package/dist/nitro.js +5 -5
  123. package/dist/oauth-callback-server-PAQRPXZX.js +231 -0
  124. package/dist/oauth-relay-3ZU72UGL.js +9 -0
  125. package/dist/personal-tokens/store.d.ts +27 -0
  126. package/dist/{plugins-PZMDS7AT.js → plugins-IUJA4VBU.js} +1 -1
  127. package/dist/reporting-schema.d.ts +10 -4
  128. package/dist/reporting.d.ts +5 -5
  129. package/dist/{runner-IPXLWQOF.js → runner-4ISZYJEX.js} +141 -74
  130. package/dist/sandbox-egress-signals-CDFAP67O.js +75 -0
  131. package/dist/{skills-QCNZISNF.js → skills-UE2KXQMB.js} +10 -8
  132. package/dist/validation-PO5LHTJT.js +21 -0
  133. package/dist/version.js +1 -1
  134. package/migrations/0008_sticky_rage.sql +14 -0
  135. package/migrations/0009_slippery_harrier.sql +12 -0
  136. package/migrations/0010_native_conversation_history.sql +142 -0
  137. package/migrations/meta/0008_snapshot.json +1076 -0
  138. package/migrations/meta/0009_snapshot.json +1146 -0
  139. package/migrations/meta/0010_snapshot.json +1190 -0
  140. package/migrations/meta/_journal.json +22 -1
  141. package/package.json +6 -7
  142. package/dist/catalog-runtime-6O4M6JGA.js +0 -16
  143. package/dist/chat/agent-dispatch/runner.d.ts +0 -13
  144. package/dist/chat/capabilities/catalog.d.ts +0 -16
  145. package/dist/chat/oauth-authorization-message.d.ts +0 -6
  146. package/dist/validation-I2BW3UHD.js +0 -19
  147. package/dist/{chunk-KNFROR7R.js → chunk-5I6ORJUY.js} +1 -1
@@ -33,7 +33,7 @@ export declare function loadTurnProjection(args: {
33
33
  /** Load MCP providers connected in the current agent-history version. */
34
34
  export declare function loadConnectedMcpProviders(args: ScopedConversation): Promise<string[]>;
35
35
  /**
36
- * Append newly stable agent steps. A shorter or changed prefix indicates
36
+ * Append newly stable native history items. A shorter or changed prefix indicates
37
37
  * that a caller persisted volatile Pi state; only compaction and handoff may
38
38
  * intentionally replace active model history.
39
39
  */
@@ -51,7 +51,7 @@ export declare function commitMessages(args: {
51
51
  }): Promise<{
52
52
  committedSeq: number;
53
53
  historyVersion: number;
54
- /** Event sequence for every projected agent step. */
54
+ /** Event sequence for every projected agent history item. */
55
55
  messageSeqs: number[];
56
56
  /** Normalized durable messages after volatile runtime context is removed. */
57
57
  messages: PiMessage[];
@@ -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>;
@@ -8,6 +8,7 @@
8
8
  */
9
9
  import type { ImageContent, TextContent } from "@earendil-works/pi-ai";
10
10
  import type { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
11
+ import type { ToolAnnotations } from "@sentry/junior-plugin-api";
11
12
  import type { ConversationPrivacy } from "@/chat/conversation-privacy";
12
13
  import type { SkillMetadata } from "@/chat/skills";
13
14
  import type { PluginDefinition } from "@/chat/plugins/types";
@@ -27,7 +28,7 @@ export interface ManagedMcpToolDescriptor {
27
28
  description: string;
28
29
  parameters: Record<string, unknown>;
29
30
  outputSchema?: Record<string, unknown>;
30
- annotations?: Record<string, unknown>;
31
+ annotations?: ToolAnnotations;
31
32
  provider: string;
32
33
  }
33
34
  type ActiveMcpSkill = Pick<SkillMetadata, "name" | "pluginProvider">;
@@ -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;
@@ -5,7 +5,7 @@
5
5
  * stored messages into the active Pi context.
6
6
  */
7
7
  import type { ModelProfile } from "@/chat/model-profile";
8
- import type { ConversationEvent } from "@/chat/conversations/history";
8
+ import type { ConversationEvent, AgentHistoryItem } from "@/chat/conversations/history";
9
9
  import { type PiMessage } from "@/chat/pi/messages";
10
10
  import { type ConversationMessageProvenance } from "@/chat/conversations/provenance";
11
11
  /** Pi context projected from one Junior model-history version. */
@@ -19,10 +19,14 @@ export interface PiConversationProjection {
19
19
  export interface PiConversationEventProjection extends PiConversationProjection {
20
20
  seqs: number[];
21
21
  }
22
+ /** Translate one Pi message into Junior's native durable history item. */
23
+ export declare function historyItemFromPiMessage(message: PiMessage, provenance: ConversationMessageProvenance): AgentHistoryItem;
24
+ /** Translate one Junior-native history item into the Pi message it represents. */
25
+ export declare function piMessageFromHistoryItem(data: AgentHistoryItem): PiMessage;
22
26
  /**
23
27
  * Project ordered Junior events into Pi context.
24
28
  *
25
- * Compaction and handoff start with replacement history. Later agent-step
29
+ * Compaction and handoff start with replacement history. Later native history
26
30
  * events append after it.
27
31
  *
28
32
  * Host-only events are filtered, completed authorization becomes a synthetic
@@ -0,0 +1,8 @@
1
+ import { type ConversationAnnotation, type PluginAnnotations } from "@sentry/junior-plugin-api";
2
+ import type { JuniorDatabase } from "@/db/db";
3
+ export declare function createPluginAnnotations(args: {
4
+ conversationId: string;
5
+ db: JuniorDatabase;
6
+ plugin: string;
7
+ }): PluginAnnotations;
8
+ export declare function listConversationAnnotations(db: JuniorDatabase, conversationId: string): Promise<ConversationAnnotation[]>;
@@ -1,10 +1,8 @@
1
- import type { CapabilityProviderDefinition } from "@/chat/capabilities/catalog";
2
1
  import type { CredentialBroker } from "@/chat/credentials/broker";
3
2
  import { type InstalledPluginPackageContent } from "./package-discovery";
4
3
  import type { InlinePluginManifestDefinition, PluginBrokerDeps, PluginCatalogConfig, PluginDefinition, OAuthProviderConfig, PluginRuntimeDependency, PluginRuntimePostinstallCommand } from "./types";
5
4
  export interface PluginCatalogRuntime {
6
5
  createBroker(provider: string, deps: PluginBrokerDeps): CredentialBroker;
7
- getCapabilityProviders(): CapabilityProviderDefinition[];
8
6
  getDefinition(provider: string): PluginDefinition | undefined;
9
7
  getDisplayName(provider: string): string | undefined;
10
8
  getForSkillPath(skillPath: string): PluginDefinition | undefined;
@@ -20,7 +18,6 @@ export interface PluginCatalogRuntime {
20
18
  getRuntimePostinstall(): PluginRuntimePostinstallCommand[];
21
19
  getSignature(): string;
22
20
  getSkillRoots(): string[];
23
- isCapability(capability: string): boolean;
24
21
  isConfigKey(key: string): boolean;
25
22
  isProvider(provider: string): boolean;
26
23
  parseConfiguredInlineManifest(manifest: InlinePluginManifestDefinition["manifest"], dir: string): PluginDefinition["manifest"];
@@ -63,7 +63,6 @@ export interface PluginManifest {
63
63
  name: string;
64
64
  displayName: string;
65
65
  description: string;
66
- capabilities: string[];
67
66
  configKeys: string[];
68
67
  domains?: string[];
69
68
  apiHeaders?: Record<string, string>;
@@ -109,7 +108,6 @@ type PluginCredentialConfig = PluginCredentialConfigBase & {
109
108
  export interface PluginManifestConfig {
110
109
  displayName?: string;
111
110
  description?: string;
112
- capabilities?: string[];
113
111
  configKeys?: string[];
114
112
  domains?: string[] | null;
115
113
  apiHeaders?: Record<string, string | null> | null;
@@ -1,9 +1,13 @@
1
1
  import { resumeSlackTurn } from "@/chat/runtime/slack-resume";
2
2
  import { type AgentContinueRequest } from "@/chat/services/agent-continue";
3
3
  import type { AgentRunner } from "@/chat/runtime/agent-runner";
4
+ import type { AgentRunRouting } from "@/chat/agent/request";
4
5
  /** Runtime ports for agent continuation scheduling. */
5
6
  export interface AgentContinueRunnerOptions {
6
7
  agentRunner: AgentRunner;
8
+ /** Exact persisted input ids accepted for a non-interactive continuation. */
9
+ inputMessageIds?: readonly string[];
10
+ routingContext?: Pick<AgentRunRouting, "actor" | "credentialContext" | "destinationVisibility" | "dispatch" | "surface">;
7
11
  resumeTurn?: typeof resumeSlackTurn;
8
12
  scheduleAgentContinue?: (request: AgentContinueRequest) => Promise<void>;
9
13
  scheduleSessionCompletedPluginTasks?: (params: {
@@ -17,6 +17,7 @@ import type { ContextCompactor } from "@/chat/services/context-compaction";
17
17
  import { lookupSlackUser } from "@/chat/slack/user";
18
18
  import type { AgentContinueRequest } from "@/chat/services/agent-continue";
19
19
  import type { ConversationTurnLifecycle } from "@/chat/conversations/turn-lifecycle";
20
+ import type { DispatchTurnContext, DispatchTurnResult } from "@/chat/agent-dispatch/types";
20
21
  export interface ReplyExecutorServices {
21
22
  agentRunner: AgentRunner;
22
23
  contextCompactor: ContextCompactor;
@@ -51,7 +52,7 @@ interface ReplyExecutorDeps {
51
52
  prepareTurnState: (args: PrepareTurnStateInput) => Promise<PreparedTurnState>;
52
53
  services: ReplyExecutorServices;
53
54
  }
54
- /** Build the Slack reply handler that prepares state, runs Pi, and delivers replies. */
55
+ /** Build the shared reply handler that prepares, advances, and commits a turn. */
55
56
  export declare function createReplyToThread(deps: ReplyExecutorDeps): (thread: Thread, message: Message, options: {
56
57
  beforeFirstResponsePost?: () => Promise<void>;
57
58
  destination: Destination;
@@ -59,9 +60,13 @@ export declare function createReplyToThread(deps: ReplyExecutorDeps): (thread: T
59
60
  ack?: () => Promise<void>;
60
61
  onToolInvocation?: (invocation: TurnToolInvocation) => void;
61
62
  onTurnCompleted?: () => Promise<void>;
63
+ onTurnDeliveryAccepted?: (messageId?: string) => void;
64
+ onTurnOutcome?: (result: DispatchTurnResult) => void;
62
65
  onTurnStatePersisted?: () => Promise<void>;
63
66
  preparedState?: PreparedTurnState;
64
67
  queuedMessages?: QueuedTurnMessage[];
68
+ execution?: DispatchTurnContext;
69
+ skipBackfill?: boolean;
65
70
  drainSteeringMessages?: (accept: (messages: QueuedTurnMessage[]) => Promise<void>, context?: {
66
71
  conversationContext?: string;
67
72
  }) => Promise<QueuedTurnMessage[]>;
@@ -12,8 +12,10 @@ interface ResumeSlackTurnArgs {
12
12
  messageText: string;
13
13
  conversationId: string;
14
14
  turnId: string;
15
+ /** Active durable execution slice being resumed. */
16
+ sliceId?: number;
15
17
  channelId: string;
16
- threadTs: string;
18
+ threadTs?: string;
17
19
  messageTs?: SlackMessageTs;
18
20
  replyContext?: ResumeReplyContext;
19
21
  lockKey?: string;
@@ -41,6 +43,8 @@ type ResumeReplyContext = Omit<AgentRunRequest, "conversationId" | "turnId" | "r
41
43
  };
42
44
  interface ResumePreparedTurn {
43
45
  messageText: string;
46
+ /** Active durable execution slice being resumed. */
47
+ sliceId?: number;
44
48
  messageTs?: SlackMessageTs;
45
49
  inputMessageIds?: string[];
46
50
  initialStatus?: AssistantStatusSpec;
@@ -1,4 +1,5 @@
1
1
  import type { Message, Thread } from "chat";
2
+ import type { ChannelConfigurationService } from "@/chat/configuration/types";
2
3
  export interface TurnContext {
3
4
  channelId?: string;
4
5
  actorId?: string;
@@ -18,10 +19,12 @@ export interface QueuedTurnMessage extends TurnMessageText {
18
19
  message: Message;
19
20
  }
20
21
  export interface PrepareTurnStateInput {
22
+ channelConfiguration?: ChannelConfigurationService;
21
23
  context: TurnContext;
22
24
  explicitMention: boolean;
23
25
  message: Message;
24
26
  queuedMessages?: QueuedTurnMessage[];
27
+ skipBackfill?: boolean;
25
28
  text: TurnMessageText;
26
29
  thread: Thread;
27
30
  }
@@ -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,8 +1,9 @@
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";
5
- import type { SandboxWorkspace } from "@/chat/sandbox/workspace";
6
+ import { type SandboxWorkspace } from "@/chat/sandbox/workspace";
6
7
  import type { SkillMetadata } from "@/chat/skills";
7
8
  export interface SandboxToolCall {
8
9
  toolName: string;
@@ -17,6 +18,7 @@ export interface SandboxAccess {
17
18
  readonly tools: SandboxTools;
18
19
  readonly workspace: SandboxWorkspace;
19
20
  sandboxRef(): SandboxRef | undefined;
21
+ close(): void;
20
22
  }
21
23
  export interface SandboxOptions {
22
24
  sandboxRef?: SandboxRef;
@@ -26,6 +28,7 @@ export interface SandboxOptions {
26
28
  traceContext?: LogContext;
27
29
  tracePropagation?: SandboxEgressTracePropagationConfig;
28
30
  credentialEgress?: CredentialContext;
31
+ egressSignals?: SandboxEgressSignalTransport;
29
32
  prepare?: (workspace: SandboxWorkspace) => void | Promise<void>;
30
33
  onSandboxRefChanged?: (sandboxRef: SandboxRef) => void | Promise<void>;
31
34
  }
@@ -19,24 +19,15 @@ interface SandboxToolExecutors {
19
19
  aborted?: boolean;
20
20
  timedOut?: boolean;
21
21
  }>;
22
- readFile: (input: {
23
- path: string;
24
- }) => Promise<{
25
- content: string;
26
- }>;
27
- writeFile: (input: {
28
- path: string;
29
- content: string;
30
- }) => Promise<{
31
- success: boolean;
32
- }>;
33
22
  fs: SandboxFileSystem;
23
+ runCommand: SandboxSession["runCommand"];
34
24
  }
35
25
  interface SandboxRuntime {
36
26
  sandboxRef(): SandboxRef | undefined;
37
27
  acquire(): Promise<SandboxSession>;
38
28
  tools(): Promise<SandboxToolExecutors>;
39
29
  refreshNetworkPolicy(traceHeaders?: TracePropagationHeaders): Promise<void>;
30
+ close(): void;
40
31
  }
41
32
  interface SandboxRuntimeOptions {
42
33
  sandboxRef?: SandboxRef;
@@ -18,13 +18,21 @@ export interface SandboxFileStat {
18
18
  export interface SandboxFileSystem {
19
19
  readFile(filePath: string, options: {
20
20
  encoding: BufferEncoding;
21
+ signal?: AbortSignal;
21
22
  }): Promise<string>;
22
23
  writeFile(filePath: string, content: string, options?: {
23
24
  encoding?: BufferEncoding;
25
+ signal?: AbortSignal;
24
26
  }): Promise<void>;
25
- readdir(filePath: string): Promise<string[]>;
26
- stat(filePath: string): Promise<SandboxFileStat>;
27
+ readdir(filePath: string, options?: {
28
+ signal?: AbortSignal;
29
+ }): Promise<string[]>;
30
+ stat(filePath: string, options?: {
31
+ signal?: AbortSignal;
32
+ }): Promise<SandboxFileStat>;
27
33
  }
34
+ /** Bind one tool call's cancellation to every sandbox filesystem operation. */
35
+ export declare function bindSandboxFileSystem(fs: SandboxFileSystem, signal?: AbortSignal): SandboxFileSystem;
28
36
  export interface SandboxWorkspace {
29
37
  readFileToBuffer(input: {
30
38
  cwd?: string;
@@ -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 {};
@@ -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
  /**
@@ -1,4 +1,4 @@
1
- import { type AgentTurnSessionRecord, type AgentTurnSurface } from "@/chat/state/turn-session";
1
+ import { type AgentDispatchOutcome, type AgentTurnSessionRecord, type AgentTurnSurface } from "@/chat/state/turn-session";
2
2
  import type { ConversationPrivacy } from "@/chat/conversation-privacy";
3
3
  import type { Destination, Actor, Source } from "@sentry/junior-plugin-api";
4
4
  import type { PiMessage } from "@/chat/pi/messages";
@@ -27,6 +27,7 @@ export declare function persistRunningSessionRecord(args: {
27
27
  channelName?: string;
28
28
  conversationId: string;
29
29
  destination?: Destination;
30
+ dispatchId?: string;
30
31
  source?: Source;
31
32
  sessionId: string;
32
33
  sliceId: number;
@@ -56,8 +57,13 @@ export declare function persistCompletedSessionRecord(args: {
56
57
  currentDurationMs?: number;
57
58
  currentUsage?: AgentTurnUsage;
58
59
  destination?: Destination;
60
+ dispatchId?: string;
61
+ dispatchOutcome?: AgentDispatchOutcome;
62
+ errorMessage?: string;
59
63
  /** Source-confirmed destination visibility from the current event's signal. */
60
64
  destinationVisibility?: ConversationPrivacy;
65
+ /** Provider-owned identifier returned after visible delivery is accepted. */
66
+ resultMessageId?: string;
61
67
  source?: Source;
62
68
  sessionId: string;
63
69
  /** Defaults to the latest stored slice when the deliverer does not know it. */
@@ -76,12 +82,16 @@ export declare function completeDeliveredTurn(args: {
76
82
  conversationId: string;
77
83
  destination: Destination;
78
84
  destinationVisibility?: ConversationPrivacy;
85
+ dispatchId?: string;
86
+ dispatchOutcome?: AgentDispatchOutcome;
87
+ errorMessage?: string;
79
88
  durationMs?: number;
80
89
  loadedSkillNames?: string[];
81
90
  messages: PiMessage[];
82
91
  modelId: string;
83
92
  actor?: Actor;
84
93
  reasoningLevel?: string;
94
+ resultMessageId?: string;
85
95
  sessionId: string;
86
96
  sliceId: number;
87
97
  source: Source;
@@ -101,6 +111,7 @@ export declare function persistAuthPauseSessionRecord(args: {
101
111
  currentDurationMs?: number;
102
112
  currentUsage?: AgentTurnUsage;
103
113
  destination?: Destination;
114
+ dispatchId?: string;
104
115
  source?: Source;
105
116
  messages: PiMessage[];
106
117
  loadedSkillNames?: string[];
@@ -119,6 +130,7 @@ interface ContinuationRecordInput {
119
130
  currentDurationMs?: number;
120
131
  currentUsage?: AgentTurnUsage;
121
132
  destination?: Destination;
133
+ dispatchId?: string;
122
134
  source?: Source;
123
135
  messages: PiMessage[];
124
136
  loadedSkillNames?: string[];
@@ -144,6 +156,7 @@ export declare function persistYieldSessionRecord(args: {
144
156
  currentDurationMs?: number;
145
157
  currentUsage?: AgentTurnUsage;
146
158
  destination?: Destination;
159
+ dispatchId?: string;
147
160
  source?: Source;
148
161
  messages: PiMessage[];
149
162
  loadedSkillNames?: string[];
@@ -0,0 +1,25 @@
1
+ import { Message, ThreadImpl } from "chat";
2
+ import type { SlackAdapter } from "@chat-adapter/slack";
3
+ import type { DispatchTurnContext, DispatchTurnResult } from "@/chat/agent-dispatch/types";
4
+ import type { DispatchRecord } from "@/chat/agent-dispatch/types";
5
+ interface DispatchReplyToThread {
6
+ (thread: ThreadImpl, message: Message, options: {
7
+ ack?: () => Promise<void>;
8
+ destination: DispatchRecord["destination"];
9
+ execution: DispatchTurnContext;
10
+ onTurnDeliveryAccepted?: (messageId?: string) => void;
11
+ onTurnOutcome?: (result: DispatchTurnResult) => void;
12
+ shouldYield?: () => boolean;
13
+ skipBackfill?: boolean;
14
+ }): Promise<void>;
15
+ }
16
+ /** Build the Slack provider adapter for plugin-dispatched conversation turns. */
17
+ export declare function createSlackDispatchTurnRunner(options: {
18
+ getChannelConfiguration: (channelId: string) => DispatchTurnContext["channelConfiguration"];
19
+ getSlackAdapter: () => SlackAdapter;
20
+ replyToThread: DispatchReplyToThread;
21
+ }): (dispatch: DispatchRecord, hooks: {
22
+ ack: () => Promise<void>;
23
+ shouldYield?: () => boolean;
24
+ }) => Promise<DispatchTurnResult>;
25
+ export {};
@@ -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;
@@ -18,6 +18,7 @@ import type { ConversationStore } from "@/chat/conversations/store";
18
18
  export type AgentTurnSessionStatus = "running" | "awaiting_resume" | "completed" | "failed" | "abandoned";
19
19
  export type AgentTurnSurface = "slack" | "api" | "scheduler" | "internal";
20
20
  export type AgentTurnResumeReason = "timeout" | "auth" | "yield" | "retry";
21
+ export type AgentDispatchOutcome = "blocked" | "completed" | "failed";
21
22
  export interface AgentTurnSessionRecord {
22
23
  channelName?: string;
23
24
  version: number;
@@ -25,6 +26,10 @@ export interface AgentTurnSessionRecord {
25
26
  cumulativeDurationMs: number;
26
27
  cumulativeUsage?: AgentTurnUsage;
27
28
  destination?: Destination;
29
+ dispatchId?: string;
30
+ dispatchOutcome?: AgentDispatchOutcome;
31
+ /** Provider-owned identifier returned after visible delivery is accepted. */
32
+ resultMessageId?: string;
28
33
  source?: Source;
29
34
  errorMessage?: string;
30
35
  lastProgressAtMs: number;
@@ -66,6 +71,9 @@ export declare function upsertAgentTurnSessionRecord(args: {
66
71
  cumulativeDurationMs?: number;
67
72
  cumulativeUsage?: AgentTurnUsage;
68
73
  destination?: Destination;
74
+ dispatchId?: string;
75
+ dispatchOutcome?: AgentDispatchOutcome;
76
+ resultMessageId?: string;
69
77
  /** Source-confirmed destination visibility from the current event's signal. */
70
78
  destinationVisibility?: ConversationPrivacy;
71
79
  source?: Source;
@@ -97,6 +105,9 @@ export declare function recordAgentTurnSessionSummary(args: {
97
105
  cumulativeDurationMs?: number;
98
106
  cumulativeUsage?: AgentTurnUsage;
99
107
  destination?: Destination;
108
+ dispatchId?: string;
109
+ dispatchOutcome?: AgentDispatchOutcome;
110
+ resultMessageId?: string;
100
111
  /**
101
112
  * Source-confirmed destination visibility from the current event's signal
102
113
  * (Slack `channel_type`). Leave unset when no live signal exists so an
@@ -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: {
@@ -13,8 +13,11 @@ interface TextRangeResult {
13
13
  path: string;
14
14
  start_line: number;
15
15
  total_lines: number;
16
+ truncation_reasons?: string[];
16
17
  };
17
18
  truncated: boolean;
19
+ character_limit_reached?: number;
20
+ line_truncated?: boolean;
18
21
  continuation?: {
19
22
  arguments: {
20
23
  offset: number;