@sentry/junior 0.53.0 → 0.55.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 (239) hide show
  1. package/README.md +4 -3
  2. package/dist/api-reference.d.ts +7 -0
  3. package/dist/app.d.ts +14 -12
  4. package/dist/app.js +12977 -10333
  5. package/dist/build/copy-build-content.d.ts +4 -0
  6. package/dist/build/glob-to-regex.d.ts +2 -0
  7. package/dist/build/rolldown-workarounds.d.ts +14 -0
  8. package/dist/build/virtual-config.d.ts +4 -0
  9. package/dist/chat/agent-dispatch/context.d.ts +6 -0
  10. package/dist/chat/agent-dispatch/heartbeat.d.ts +14 -0
  11. package/dist/chat/agent-dispatch/runner.d.ts +9 -0
  12. package/dist/chat/agent-dispatch/signing.d.ts +5 -0
  13. package/dist/chat/agent-dispatch/store.d.ts +29 -0
  14. package/dist/chat/agent-dispatch/types.d.ts +57 -0
  15. package/dist/chat/agent-dispatch/validation.d.ts +3 -0
  16. package/dist/chat/app/factory.d.ts +10 -0
  17. package/dist/chat/app/production.d.ts +6 -0
  18. package/dist/chat/app/services.d.ts +17 -0
  19. package/dist/chat/capabilities/catalog.d.ts +16 -0
  20. package/dist/chat/capabilities/factory.d.ts +10 -0
  21. package/dist/chat/capabilities/jr-rpc-command.d.ts +26 -0
  22. package/dist/chat/capabilities/router.d.ts +19 -0
  23. package/dist/chat/coerce.d.ts +6 -0
  24. package/dist/chat/config.d.ts +47 -0
  25. package/dist/chat/configuration/defaults.d.ts +4 -0
  26. package/dist/chat/configuration/service.d.ts +2 -0
  27. package/dist/chat/configuration/types.d.ts +37 -0
  28. package/dist/chat/configuration/validation.d.ts +2 -0
  29. package/dist/chat/credentials/broker.d.ts +22 -0
  30. package/dist/chat/credentials/header-transforms.d.ts +3 -0
  31. package/dist/chat/credentials/oauth-scope.d.ts +4 -0
  32. package/dist/chat/credentials/state-adapter-token-store.d.ts +9 -0
  33. package/dist/chat/credentials/unlink-provider.d.ts +2 -0
  34. package/dist/chat/credentials/user-token-store.d.ts +11 -0
  35. package/dist/chat/discovery.d.ts +47 -0
  36. package/dist/chat/ingress/junior-chat.d.ts +26 -0
  37. package/dist/chat/ingress/message-changed.d.ts +50 -0
  38. package/dist/chat/ingress/message-router.d.ts +9 -0
  39. package/dist/chat/ingress/slash-command.d.ts +3 -0
  40. package/dist/chat/ingress/workspace-membership.d.ts +9 -0
  41. package/dist/chat/interruption-marker.d.ts +2 -0
  42. package/dist/chat/logging.d.ts +90 -0
  43. package/dist/chat/mcp/auth-store.d.ts +41 -0
  44. package/dist/chat/mcp/client.d.ts +34 -0
  45. package/dist/chat/mcp/errors.d.ts +8 -0
  46. package/dist/chat/mcp/oauth-provider.d.ts +27 -0
  47. package/dist/chat/mcp/oauth.d.ts +17 -0
  48. package/dist/chat/mcp/tool-manager.d.ts +60 -0
  49. package/dist/chat/oauth-flow.d.ts +45 -0
  50. package/dist/chat/optional-string.d.ts +5 -0
  51. package/dist/chat/pi/client.d.ts +49 -0
  52. package/dist/chat/pi/messages.d.ts +3 -0
  53. package/dist/chat/pi/traced-stream.d.ts +9 -0
  54. package/dist/chat/plugins/agent-hooks.d.ts +32 -0
  55. package/dist/chat/plugins/auth/api-headers-broker.d.ts +6 -0
  56. package/dist/chat/plugins/auth/auth-token-placeholder.d.ts +3 -0
  57. package/dist/chat/plugins/auth/github-app-broker.d.ts +4 -0
  58. package/dist/chat/plugins/auth/oauth-bearer-broker.d.ts +6 -0
  59. package/dist/chat/plugins/auth/oauth-request.d.ts +18 -0
  60. package/dist/chat/plugins/command-env.d.ts +3 -0
  61. package/dist/chat/plugins/logging.d.ts +3 -0
  62. package/dist/chat/plugins/manifest.d.ts +3 -0
  63. package/dist/chat/plugins/package-discovery.d.ts +14 -0
  64. package/dist/chat/plugins/registry.d.ts +23 -0
  65. package/dist/chat/plugins/state.d.ts +3 -0
  66. package/dist/chat/plugins/types.d.ts +146 -0
  67. package/dist/chat/prompt.d.ts +39 -0
  68. package/dist/chat/queue/thread-message-dispatcher.d.ts +33 -0
  69. package/dist/chat/respond-helpers.d.ts +77 -0
  70. package/dist/chat/respond.d.ts +75 -0
  71. package/dist/chat/runtime/auth-pause-state.d.ts +11 -0
  72. package/dist/chat/runtime/delivered-turn-state.d.ts +15 -0
  73. package/dist/chat/runtime/dev-agent-trace.d.ts +1 -0
  74. package/dist/chat/runtime/processing-reaction.d.ts +25 -0
  75. package/dist/chat/runtime/reply-executor.d.ts +56 -0
  76. package/dist/chat/runtime/report-progress.d.ts +3 -0
  77. package/dist/chat/runtime/slack-resume.d.ts +50 -0
  78. package/dist/chat/runtime/slack-runtime.d.ts +100 -0
  79. package/dist/chat/runtime/thread-context.d.ts +24 -0
  80. package/dist/chat/runtime/thread-state.d.ts +28 -0
  81. package/dist/chat/runtime/turn-preparation.d.ts +43 -0
  82. package/dist/chat/runtime/turn-user-message.d.ts +12 -0
  83. package/dist/chat/runtime/turn.d.ts +69 -0
  84. package/dist/chat/sandbox/credentials.d.ts +11 -0
  85. package/dist/chat/sandbox/egress-oidc.d.ts +3 -0
  86. package/dist/chat/sandbox/egress-policy.d.ts +11 -0
  87. package/dist/chat/sandbox/egress-proxy.d.ts +17 -0
  88. package/dist/chat/sandbox/egress-session.d.ts +27 -0
  89. package/dist/chat/sandbox/errors.d.ts +12 -0
  90. package/dist/chat/sandbox/http-error-details.d.ts +18 -0
  91. package/dist/chat/sandbox/noninteractive-command.d.ts +17 -0
  92. package/dist/chat/sandbox/paths.d.ts +5 -0
  93. package/dist/chat/sandbox/runtime-dependency-snapshots.d.ts +20 -0
  94. package/dist/chat/sandbox/sandbox.d.ts +54 -0
  95. package/dist/chat/sandbox/session.d.ts +54 -0
  96. package/dist/chat/sandbox/skill-sandbox.d.ts +42 -0
  97. package/dist/chat/sandbox/skill-sync.d.ts +16 -0
  98. package/dist/chat/sandbox/workspace.d.ts +55 -0
  99. package/dist/chat/scheduler/cadence.d.ts +24 -0
  100. package/dist/chat/scheduler/plugin.d.ts +2 -0
  101. package/dist/chat/scheduler/prompt.d.ts +7 -0
  102. package/dist/chat/scheduler/store.d.ts +49 -0
  103. package/dist/chat/scheduler/types.d.ts +86 -0
  104. package/dist/chat/sentry.d.ts +2 -0
  105. package/dist/chat/services/attachment-claims.d.ts +2 -0
  106. package/dist/chat/services/auth-pause-response.d.ts +2 -0
  107. package/dist/chat/services/auth-pause.d.ts +19 -0
  108. package/dist/chat/services/channel-intent.d.ts +2 -0
  109. package/dist/chat/services/conversation-memory.d.ts +33 -0
  110. package/dist/chat/services/mcp-auth-orchestration.d.ts +30 -0
  111. package/dist/chat/services/pending-auth.d.ts +27 -0
  112. package/dist/chat/services/plugin-auth-orchestration.d.ts +37 -0
  113. package/dist/chat/services/provider-default-config.d.ts +9 -0
  114. package/dist/chat/services/provider-retry.d.ts +6 -0
  115. package/dist/chat/services/reply-delivery-plan.d.ts +17 -0
  116. package/dist/chat/services/subscribed-decision.d.ts +63 -0
  117. package/dist/chat/services/subscribed-reply-policy.d.ts +23 -0
  118. package/dist/chat/services/timeout-resume.d.ts +17 -0
  119. package/dist/chat/services/turn-checkpoint.d.ts +74 -0
  120. package/dist/chat/services/turn-continuation-response.d.ts +2 -0
  121. package/dist/chat/services/turn-failure-response.d.ts +15 -0
  122. package/dist/chat/services/turn-result.d.ts +55 -0
  123. package/dist/chat/services/turn-thinking-level.d.ts +49 -0
  124. package/dist/chat/services/vision-context.d.ts +61 -0
  125. package/dist/chat/skills.d.ts +48 -0
  126. package/dist/chat/slack/adapter.d.ts +9 -0
  127. package/dist/chat/slack/app-home.d.ts +11 -0
  128. package/dist/chat/slack/assistant-thread/lifecycle.d.ts +13 -0
  129. package/dist/chat/slack/assistant-thread/status-render.d.ts +28 -0
  130. package/dist/chat/slack/assistant-thread/status-scheduler.d.ts +23 -0
  131. package/dist/chat/slack/assistant-thread/status-send.d.ts +31 -0
  132. package/dist/chat/slack/assistant-thread/status.d.ts +36 -0
  133. package/dist/chat/slack/assistant-thread/title.d.ts +28 -0
  134. package/dist/chat/slack/canvas-references.d.ts +2 -0
  135. package/dist/chat/slack/channel.d.ts +48 -0
  136. package/dist/chat/slack/client.d.ts +52 -0
  137. package/dist/chat/slack/context.d.ts +9 -0
  138. package/dist/chat/slack/emoji.d.ts +1 -0
  139. package/dist/chat/slack/errors.d.ts +6 -0
  140. package/dist/chat/slack/footer.d.ts +42 -0
  141. package/dist/chat/slack/ids.d.ts +4 -0
  142. package/dist/chat/slack/legacy-attachments.d.ts +4 -0
  143. package/dist/chat/slack/message.d.ts +6 -0
  144. package/dist/chat/slack/mrkdwn.d.ts +12 -0
  145. package/dist/chat/slack/outbound.d.ts +57 -0
  146. package/dist/chat/slack/output.d.ts +54 -0
  147. package/dist/chat/slack/reply.d.ts +33 -0
  148. package/dist/chat/slack/status-format.d.ts +2 -0
  149. package/dist/chat/slack/turn-continuation-notice.d.ts +8 -0
  150. package/dist/chat/slack/user.d.ts +8 -0
  151. package/dist/chat/slack/users.d.ts +39 -0
  152. package/dist/chat/slack/workspace-context.d.ts +4 -0
  153. package/dist/chat/state/adapter.d.ts +9 -0
  154. package/dist/chat/state/artifacts.d.ts +29 -0
  155. package/dist/chat/state/conversation.d.ts +81 -0
  156. package/dist/chat/state/pi-session-message-store.d.ts +15 -0
  157. package/dist/chat/state/turn-id.d.ts +2 -0
  158. package/dist/chat/state/turn-session-store.d.ts +49 -0
  159. package/dist/chat/tools/advisor/session-store.d.ts +9 -0
  160. package/dist/chat/tools/advisor/tool.d.ts +33 -0
  161. package/dist/chat/tools/agent-tools.d.ts +10 -0
  162. package/dist/chat/tools/channel-capabilities.d.ts +11 -0
  163. package/dist/chat/tools/definition.d.ts +17 -0
  164. package/dist/chat/tools/execution/build-sandbox-input.d.ts +2 -0
  165. package/dist/chat/tools/execution/normalize-result.d.ts +6 -0
  166. package/dist/chat/tools/execution/tool-error-handler.d.ts +3 -0
  167. package/dist/chat/tools/execution/tool-input-error.d.ts +6 -0
  168. package/dist/chat/tools/idempotency.d.ts +1 -0
  169. package/dist/chat/tools/index.d.ts +5 -0
  170. package/dist/chat/tools/runtime/report-progress.d.ts +4 -0
  171. package/dist/chat/tools/sandbox/attach-file.d.ts +7 -0
  172. package/dist/chat/tools/sandbox/bash.d.ts +5 -0
  173. package/dist/chat/tools/sandbox/edit-file.d.ts +37 -0
  174. package/dist/chat/tools/sandbox/file-utils.d.ts +52 -0
  175. package/dist/chat/tools/sandbox/find-files.d.ts +24 -0
  176. package/dist/chat/tools/sandbox/grep.d.ts +33 -0
  177. package/dist/chat/tools/sandbox/list-dir.d.ts +22 -0
  178. package/dist/chat/tools/sandbox/read-file.d.ts +32 -0
  179. package/dist/chat/tools/sandbox/text-edits.d.ts +28 -0
  180. package/dist/chat/tools/sandbox/write-file.d.ts +5 -0
  181. package/dist/chat/tools/skill/call-mcp-tool.d.ts +7 -0
  182. package/dist/chat/tools/skill/load-skill.d.ts +22 -0
  183. package/dist/chat/tools/skill/mcp-tool-summary.d.ts +31 -0
  184. package/dist/chat/tools/skill/search-mcp-tools.d.ts +8 -0
  185. package/dist/chat/tools/slack/canvas-tools.d.ts +29 -0
  186. package/dist/chat/tools/slack/canvases.d.ts +45 -0
  187. package/dist/chat/tools/slack/channel-list-messages.d.ts +9 -0
  188. package/dist/chat/tools/slack/channel-post-message.d.ts +4 -0
  189. package/dist/chat/tools/slack/list-tools.d.ts +21 -0
  190. package/dist/chat/tools/slack/lists.d.ts +42 -0
  191. package/dist/chat/tools/slack/message-add-reaction.d.ts +4 -0
  192. package/dist/chat/tools/slack/schedule-tools.d.ts +29 -0
  193. package/dist/chat/tools/slack/slack-message-url.d.ts +18 -0
  194. package/dist/chat/tools/slack/thread-read.d.ts +9 -0
  195. package/dist/chat/tools/slack/user-lookup.d.ts +8 -0
  196. package/dist/chat/tools/system-time.d.ts +1 -0
  197. package/dist/chat/tools/types.d.ts +61 -0
  198. package/dist/chat/tools/web/constants.d.ts +6 -0
  199. package/dist/chat/tools/web/fetch-content.d.ts +23 -0
  200. package/dist/chat/tools/web/fetch-tool.d.ts +5 -0
  201. package/dist/chat/tools/web/image-generate.d.ts +4 -0
  202. package/dist/chat/tools/web/network.d.ts +6 -0
  203. package/dist/chat/tools/web/search.d.ts +5 -0
  204. package/dist/chat/turn-context-tag.d.ts +6 -0
  205. package/dist/chat/usage.d.ts +24 -0
  206. package/dist/chat/xml.d.ts +1 -0
  207. package/dist/{chunk-XPXD3FCE.js → chunk-5LUISFEY.js} +189 -35
  208. package/dist/{chunk-ZNFNY53B.js → chunk-D3G3YOU4.js} +2 -2
  209. package/dist/chunk-SCQPBJAU.js +21 -0
  210. package/dist/{chunk-Q3FDONU7.js → chunk-TTUY467K.js} +47 -37
  211. package/dist/{chunk-KCOKQLBF.js → chunk-XI3CFWTA.js} +168 -15
  212. package/dist/cli/check.js +3 -3
  213. package/dist/cli/init.js +6 -1
  214. package/dist/cli/snapshot-warmup.js +3 -3
  215. package/dist/handlers/agent-dispatch.d.ts +3 -0
  216. package/dist/handlers/diagnostics-dashboard.d.ts +2 -0
  217. package/dist/handlers/diagnostics.d.ts +2 -0
  218. package/dist/handlers/health.d.ts +4 -0
  219. package/dist/handlers/heartbeat.d.ts +3 -0
  220. package/dist/handlers/mcp-oauth-callback.d.ts +2 -0
  221. package/dist/handlers/oauth-callback.d.ts +2 -0
  222. package/dist/handlers/oauth-html.d.ts +2 -0
  223. package/dist/handlers/sandbox-egress-proxy.d.ts +9 -0
  224. package/dist/handlers/turn-resume.d.ts +3 -0
  225. package/dist/handlers/types.d.ts +2 -0
  226. package/dist/handlers/webhooks.d.ts +15 -0
  227. package/dist/instrumentation.d.ts +1 -3
  228. package/dist/nitro.d.ts +4 -7
  229. package/dist/nitro.js +112 -54
  230. package/dist/package-resolution.d.ts +13 -0
  231. package/dist/vercel.d.ts +2 -4
  232. package/dist/vercel.js +3 -12
  233. package/package.json +32 -26
  234. package/dist/cli/check.d.ts +0 -8
  235. package/dist/cli/env.d.ts +0 -7
  236. package/dist/cli/init.d.ts +0 -3
  237. package/dist/cli/run.d.ts +0 -12
  238. package/dist/cli/snapshot-warmup.d.ts +0 -3
  239. package/dist/types-X_iCClPb.d.ts +0 -75
@@ -0,0 +1,86 @@
1
+ export type ScheduledTaskStatus = "active" | "paused" | "blocked" | "deleted";
2
+ export type ScheduledRunStatus = "pending" | "running" | "completed" | "failed" | "blocked" | "skipped";
3
+ export interface ScheduledTaskPrincipal {
4
+ slackUserId: string;
5
+ fullName?: string;
6
+ userName?: string;
7
+ }
8
+ export interface ScheduledTaskExecutionActor {
9
+ type: "system";
10
+ id: string;
11
+ }
12
+ export declare const SCHEDULED_TASK_SYSTEM_ACTOR: Readonly<{
13
+ type: "system";
14
+ id: string;
15
+ }>;
16
+ export interface ScheduledTaskDestination {
17
+ platform: "slack";
18
+ teamId: string;
19
+ channelId: string;
20
+ }
21
+ export interface ScheduledTaskConversationAccess {
22
+ audience: "direct" | "group" | "channel";
23
+ visibility: "private" | "public" | "unknown";
24
+ }
25
+ export interface ScheduledTaskCredentialSubject {
26
+ type: "user";
27
+ userId: string;
28
+ allowedWhen: "private-direct-conversation";
29
+ }
30
+ export type ScheduledCalendarFrequency = "daily" | "weekly" | "monthly" | "yearly";
31
+ export interface ScheduledLocalTime {
32
+ hour: number;
33
+ minute: number;
34
+ }
35
+ export interface ScheduledTaskRecurrence {
36
+ dayOfMonth?: number;
37
+ frequency: ScheduledCalendarFrequency;
38
+ interval: number;
39
+ month?: number;
40
+ startDate: string;
41
+ time: ScheduledLocalTime;
42
+ weekdays?: number[];
43
+ }
44
+ export interface ScheduledTaskSchedule {
45
+ description: string;
46
+ timezone: string;
47
+ kind: "one_off" | "recurring";
48
+ recurrence?: ScheduledTaskRecurrence;
49
+ }
50
+ export interface ScheduledTaskSpec {
51
+ text: string;
52
+ }
53
+ export interface ScheduledTask {
54
+ id: string;
55
+ createdAtMs: number;
56
+ createdBy: ScheduledTaskPrincipal;
57
+ conversationAccess?: ScheduledTaskConversationAccess;
58
+ credentialSubject?: ScheduledTaskCredentialSubject;
59
+ destination: ScheduledTaskDestination;
60
+ executionActor?: ScheduledTaskExecutionActor;
61
+ lastRunAtMs?: number;
62
+ nextRunAtMs?: number;
63
+ originalRequest?: string;
64
+ runNowAtMs?: number;
65
+ schedule: ScheduledTaskSchedule;
66
+ status: ScheduledTaskStatus;
67
+ statusReason?: string;
68
+ task: ScheduledTaskSpec;
69
+ updatedAtMs: number;
70
+ version: number;
71
+ }
72
+ export interface ScheduledRun {
73
+ id: string;
74
+ attempt: number;
75
+ claimedAtMs: number;
76
+ completedAtMs?: number;
77
+ dispatchId?: string;
78
+ errorMessage?: string;
79
+ idempotencyKey: string;
80
+ resultMessageTs?: string;
81
+ scheduledForMs: number;
82
+ startedAtMs?: number;
83
+ status: ScheduledRunStatus;
84
+ taskId: string;
85
+ taskVersion: number;
86
+ }
@@ -0,0 +1,2 @@
1
+ /** Sentry SDK re-export. Isolates the concrete package to a single file. */
2
+ export * from "@sentry/node";
@@ -0,0 +1,2 @@
1
+ /** Append a correction when the assistant claims it attached a file but none was actually delivered. */
2
+ export declare function enforceAttachmentClaimTruth(text: string, hasAttachedFiles: boolean): string;
@@ -0,0 +1,2 @@
1
+ /** Build the visible Slack thread note for an auth-paused turn. */
2
+ export declare function buildAuthPauseResponse(): string;
@@ -0,0 +1,19 @@
1
+ export type AuthorizationPauseKind = "mcp" | "plugin";
2
+ export type AuthorizationPauseDisposition = "link_already_sent" | "link_sent";
3
+ export type AuthorizationFlowMode = "interactive" | "disabled";
4
+ /**
5
+ * Runtime-owned signal that the current turn must park until the user
6
+ * completes an external authorization step.
7
+ */
8
+ export declare class AuthorizationPauseError extends Error {
9
+ readonly disposition: AuthorizationPauseDisposition;
10
+ readonly kind: AuthorizationPauseKind;
11
+ readonly provider: string;
12
+ constructor(kind: AuthorizationPauseKind, provider: string, disposition: AuthorizationPauseDisposition);
13
+ }
14
+ /** Error indicating this turn cannot start an external authorization flow. */
15
+ export declare class AuthorizationFlowDisabledError extends Error {
16
+ readonly kind: AuthorizationPauseKind;
17
+ readonly provider: string;
18
+ constructor(kind: AuthorizationPauseKind, provider: string);
19
+ }
@@ -0,0 +1,2 @@
1
+ /** Detect whether the user explicitly asked the assistant to post a message in the channel (not the thread). */
2
+ export declare function isExplicitChannelPostIntent(text: string): boolean;
@@ -0,0 +1,33 @@
1
+ import type { completeText } from "@/chat/pi/client";
2
+ import type { ConversationMessage, ThreadConversationState } from "@/chat/state/conversation";
3
+ export interface ConversationMemoryDeps {
4
+ completeText: typeof completeText;
5
+ }
6
+ export interface ConversationMemoryService {
7
+ compactConversationIfNeeded: (conversation: ThreadConversationState, context: {
8
+ threadId?: string;
9
+ channelId?: string;
10
+ requesterId?: string;
11
+ runId?: string;
12
+ }) => Promise<void>;
13
+ generateThreadTitle: (sourceText: string) => Promise<string>;
14
+ }
15
+ export declare function generateConversationId(prefix: "assistant" | "backfill" | "compaction" | "turn"): string;
16
+ export declare function normalizeConversationText(text: string): string;
17
+ export declare function updateConversationStats(conversation: ThreadConversationState): void;
18
+ export declare function upsertConversationMessage(conversation: ThreadConversationState, message: ConversationMessage): string;
19
+ export declare function markConversationMessage(conversation: ThreadConversationState, messageId: string | undefined, patch: Partial<NonNullable<ConversationMessage["meta"]>>): void;
20
+ /**
21
+ * Render thread history as structured XML. Each compaction and message is
22
+ * wrapped with index/ts metadata so the model can reference prior items
23
+ * individually instead of treating the whole block as one flat narrative.
24
+ */
25
+ export declare function buildConversationContext(conversation: ThreadConversationState, options?: {
26
+ excludeMessageId?: string;
27
+ }): string | undefined;
28
+ /** Return the earliest human-authored message known for a thread. */
29
+ export declare function getThreadTitleSourceMessage(conversation: ThreadConversationState): ConversationMessage | undefined;
30
+ /** Build the service that owns durable conversation memory compaction and titles. */
31
+ export declare function createConversationMemoryService(deps: ConversationMemoryDeps): ConversationMemoryService;
32
+ export declare function isHumanConversationMessage(message: ConversationMessage): boolean;
33
+ export declare function getConversationMessageSlackTs(message: ConversationMessage): string | undefined;
@@ -0,0 +1,30 @@
1
+ import type { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
2
+ import { AuthorizationPauseError, type AuthorizationFlowMode } from "@/chat/services/auth-pause";
3
+ import type { ThreadArtifactsState } from "@/chat/state/artifacts";
4
+ import type { ConversationPendingAuthState } from "@/chat/state/conversation";
5
+ import type { PluginDefinition } from "@/chat/plugins/types";
6
+ export declare class McpAuthorizationPauseError extends AuthorizationPauseError {
7
+ constructor(provider: string, disposition: "link_already_sent" | "link_sent");
8
+ }
9
+ export interface McpAuthOrchestrationDeps {
10
+ conversationId?: string;
11
+ sessionId?: string;
12
+ requesterId?: string;
13
+ channelId?: string;
14
+ threadTs?: string;
15
+ toolChannelId?: string;
16
+ userMessage: string;
17
+ currentPendingAuth?: ConversationPendingAuthState;
18
+ getConfiguration: () => Record<string, unknown>;
19
+ getArtifactState: () => ThreadArtifactsState | undefined;
20
+ getMergedArtifactState: () => ThreadArtifactsState;
21
+ onPendingAuth?: (pendingAuth: ConversationPendingAuthState) => void | Promise<void>;
22
+ authorizationFlowMode?: AuthorizationFlowMode;
23
+ }
24
+ export interface McpAuthOrchestration {
25
+ authProviderFactory: (plugin: PluginDefinition) => Promise<OAuthClientProvider | undefined>;
26
+ onAuthorizationRequired: (provider: string) => Promise<boolean>;
27
+ getPendingPause: () => McpAuthorizationPauseError | undefined;
28
+ }
29
+ /** Create MCP authorization orchestration for a single turn. */
30
+ export declare function createMcpAuthOrchestration(deps: McpAuthOrchestrationDeps, abortAgent: () => void): McpAuthOrchestration;
@@ -0,0 +1,27 @@
1
+ import type { AuthorizationPauseKind } from "@/chat/services/auth-pause";
2
+ import type { ConversationPendingAuthState, ThreadConversationState } from "@/chat/state/conversation";
3
+ export declare function canReusePendingAuthLink(args: {
4
+ kind: AuthorizationPauseKind;
5
+ nowMs?: number;
6
+ pendingAuth?: ConversationPendingAuthState;
7
+ provider: string;
8
+ requesterId: string;
9
+ }): boolean;
10
+ export declare function getConversationPendingAuth(args: {
11
+ conversation: ThreadConversationState;
12
+ kind: AuthorizationPauseKind;
13
+ provider: string;
14
+ requesterId: string;
15
+ }): ConversationPendingAuthState | undefined;
16
+ export declare function clearPendingAuth(conversation: ThreadConversationState, sessionId?: string): void;
17
+ /**
18
+ * Apply a new pending-auth record to the conversation and, when replacing a
19
+ * different session's pending-auth, mark the prior checkpoint as superseded.
20
+ * Callers are responsible for persisting the mutated conversation afterwards.
21
+ */
22
+ export declare function applyPendingAuthUpdate(args: {
23
+ conversation: ThreadConversationState;
24
+ conversationId: string | undefined;
25
+ nextPendingAuth: ConversationPendingAuthState;
26
+ }): Promise<void>;
27
+ export declare function isPendingAuthLatestRequest(conversation: ThreadConversationState, pendingAuth: ConversationPendingAuthState): boolean;
@@ -0,0 +1,37 @@
1
+ import type { ChannelConfigurationService } from "@/chat/configuration/types";
2
+ import type { UserTokenStore } from "@/chat/credentials/user-token-store";
3
+ import { AuthorizationPauseError, type AuthorizationFlowMode } from "@/chat/services/auth-pause";
4
+ import type { ConversationPendingAuthState } from "@/chat/state/conversation";
5
+ import type { Skill } from "@/chat/skills";
6
+ export declare class PluginAuthorizationPauseError extends AuthorizationPauseError {
7
+ constructor(provider: string, disposition: "link_already_sent" | "link_sent");
8
+ }
9
+ export declare class PluginCredentialFailureError extends Error {
10
+ readonly provider: string;
11
+ constructor(provider: string, message: string);
12
+ }
13
+ export interface PluginAuthOrchestrationDeps {
14
+ conversationId?: string;
15
+ sessionId?: string;
16
+ requesterId?: string;
17
+ channelId?: string;
18
+ threadTs?: string;
19
+ userMessage: string;
20
+ channelConfiguration?: ChannelConfigurationService;
21
+ currentPendingAuth?: ConversationPendingAuthState;
22
+ onPendingAuth?: (pendingAuth: ConversationPendingAuthState) => void | Promise<void>;
23
+ authorizationFlowMode?: AuthorizationFlowMode;
24
+ userTokenStore?: UserTokenStore;
25
+ }
26
+ export interface PluginAuthOrchestration {
27
+ handleCommandFailure: (input: {
28
+ activeSkill: Skill | null;
29
+ command: string;
30
+ details: unknown;
31
+ }) => Promise<void>;
32
+ getPendingPause: () => PluginAuthorizationPauseError | undefined;
33
+ }
34
+ /**
35
+ * Start plugin OAuth from an authenticated bash command and park the turn.
36
+ */
37
+ export declare function createPluginAuthOrchestration(deps: PluginAuthOrchestrationDeps, abortAgent: () => void): PluginAuthOrchestration;
@@ -0,0 +1,9 @@
1
+ import type { ChannelConfigurationService } from "@/chat/configuration/types";
2
+ /** Apply explicit provider-default config requests that do not need agent reasoning. */
3
+ export declare function maybeApplyProviderDefaultConfigRequest(args: {
4
+ channelConfiguration?: ChannelConfigurationService;
5
+ requesterId?: string;
6
+ text: string;
7
+ }): Promise<{
8
+ text: string;
9
+ } | null>;
@@ -0,0 +1,6 @@
1
+ import type { AssistantMessage } from "@earendil-works/pi-ai";
2
+ import type { PiMessage } from "@/chat/pi/messages";
3
+ /** Detect transient provider failures that are safe to retry from a Pi boundary. */
4
+ export declare function isRetryableProviderError(message: Pick<AssistantMessage, "stopReason" | "errorMessage"> | undefined): boolean;
5
+ /** Remove a failed assistant tail only when the remaining Pi history can continue. */
6
+ export declare function trimRetryableProviderErrorTail(messages: PiMessage[]): PiMessage[] | undefined;
@@ -0,0 +1,17 @@
1
+ export type ReplyDeliveryMode = "thread" | "channel_only";
2
+ export type ReplyFileDelivery = "none" | "inline" | "followup";
3
+ export interface ReplyDeliveryPlan {
4
+ mode: ReplyDeliveryMode;
5
+ postThreadText: boolean;
6
+ attachFiles: ReplyFileDelivery;
7
+ }
8
+ /** Check if text is a short acknowledgment (emoji, "ok", etc.) that a reaction already covers. */
9
+ export declare function isRedundantReactionAckText(text: string): boolean;
10
+ /** Check if the user asked for a reaction without also asking for text. */
11
+ export declare function isReactionOnlyIntent(text: string): boolean;
12
+ /** Determine how a reply should be delivered (thread vs channel, file handling). */
13
+ export declare function buildReplyDeliveryPlan(args: {
14
+ explicitChannelPostIntent: boolean;
15
+ channelPostPerformed: boolean;
16
+ hasFiles: boolean;
17
+ }): ReplyDeliveryPlan;
@@ -0,0 +1,63 @@
1
+ import { z } from "zod";
2
+ export declare enum SubscribedReplyReason {
3
+ ThreadOptOut = "thread_opt_out",
4
+ ExplicitMention = "explicit_mention",
5
+ DirectedFollowUp = "directed_follow_up",
6
+ DirectedToOtherParty = "directed_to_other_party",
7
+ EmptyMessage = "empty_message",
8
+ Classifier = "llm_classifier",
9
+ SideConversation = "side_conversation",
10
+ LowConfidence = "low_confidence",
11
+ ClassifierError = "classifier_error"
12
+ }
13
+ export interface SubscribedDecisionInput {
14
+ rawText: string;
15
+ text: string;
16
+ conversationContext?: string;
17
+ hasAttachments?: boolean;
18
+ isExplicitMention?: boolean;
19
+ context: {
20
+ threadId?: string;
21
+ requesterId?: string;
22
+ channelId?: string;
23
+ runId?: string;
24
+ };
25
+ }
26
+ export interface SubscribedDecisionResult {
27
+ shouldReply: boolean;
28
+ shouldUnsubscribe?: boolean;
29
+ reason: SubscribedReplyReason;
30
+ reasonDetail?: string;
31
+ }
32
+ declare const replyDecisionSchema: z.ZodObject<{
33
+ should_reply: z.ZodBoolean;
34
+ should_unsubscribe: z.ZodOptional<z.ZodBoolean>;
35
+ confidence: z.ZodNumber;
36
+ reason: z.ZodOptional<z.ZodString>;
37
+ }, z.core.$strip>;
38
+ /** Fast heuristic check before the LLM classifier — skips messages directed at another party. */
39
+ export declare function getSubscribedReplyPreflightDecision(args: {
40
+ botUserName: string;
41
+ rawText: string;
42
+ text: string;
43
+ isExplicitMention?: boolean;
44
+ }): SubscribedDecisionResult | undefined;
45
+ /** Decide whether to reply to a message in a subscribed thread using an LLM classifier. */
46
+ export declare function decideSubscribedThreadReply(args: {
47
+ botUserName: string;
48
+ modelId: string;
49
+ input: SubscribedDecisionInput;
50
+ completeObject: (args: {
51
+ modelId: string;
52
+ schema: typeof replyDecisionSchema;
53
+ maxTokens: number;
54
+ temperature: number;
55
+ system: string;
56
+ prompt: string;
57
+ metadata: Record<string, string>;
58
+ }) => Promise<{
59
+ object: unknown;
60
+ }>;
61
+ logClassifierFailure: (error: unknown, input: SubscribedDecisionInput) => void;
62
+ }): Promise<SubscribedDecisionResult>;
63
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { completeObject } from "@/chat/pi/client";
2
+ export interface SubscribedReplyPolicyDeps {
3
+ completeObject: typeof completeObject;
4
+ }
5
+ export interface SubscribedReplyDecision {
6
+ reason: string;
7
+ shouldReply: boolean;
8
+ shouldUnsubscribe?: boolean;
9
+ }
10
+ export type SubscribedReplyPolicy = (args: {
11
+ rawText: string;
12
+ text: string;
13
+ conversationContext?: string;
14
+ hasAttachments?: boolean;
15
+ isExplicitMention?: boolean;
16
+ context: {
17
+ threadId?: string;
18
+ requesterId?: string;
19
+ channelId?: string;
20
+ runId?: string;
21
+ };
22
+ }) => Promise<SubscribedReplyDecision>;
23
+ export declare function createSubscribedReplyPolicy(deps: SubscribedReplyPolicyDeps): SubscribedReplyPolicy;
@@ -0,0 +1,17 @@
1
+ export interface TurnContinuationRequest {
2
+ conversationId: string;
3
+ expectedCheckpointVersion: number;
4
+ sessionId: string;
5
+ }
6
+ export type TurnTimeoutResumeRequest = TurnContinuationRequest;
7
+ /** Bound automatic timeout continuation so one bad turn cannot loop forever. */
8
+ export declare function canScheduleTurnTimeoutResume(nextSliceId: number | undefined): boolean;
9
+ /** Build the callback request for an awaiting automatic turn continuation. */
10
+ export declare function getAwaitingTurnContinuationRequest(args: {
11
+ conversationId: string;
12
+ sessionId: string;
13
+ }): Promise<TurnContinuationRequest | undefined>;
14
+ /** Schedule an authenticated internal callback to resume a timed-out turn. */
15
+ export declare function scheduleTurnTimeoutResume(request: TurnContinuationRequest): Promise<void>;
16
+ /** Verify and parse an authenticated timeout resume callback request. */
17
+ export declare function verifyTurnTimeoutResumeRequest(request: Request): Promise<TurnContinuationRequest | undefined>;
@@ -0,0 +1,74 @@
1
+ import { type AgentTurnSessionCheckpoint } from "@/chat/state/turn-session-store";
2
+ import type { PiMessage } from "@/chat/pi/messages";
3
+ import { type AgentTurnUsage } from "@/chat/usage";
4
+ export interface TurnCheckpointContext {
5
+ conversationId?: string;
6
+ sessionId?: string;
7
+ }
8
+ export interface TurnCheckpointState {
9
+ canUseTurnSession: boolean;
10
+ resumedFromCheckpoint: boolean;
11
+ currentSliceId: number;
12
+ existingCheckpoint?: AgentTurnSessionCheckpoint;
13
+ }
14
+ interface CheckpointLogContext {
15
+ threadId?: string;
16
+ requesterId?: string;
17
+ channelId?: string;
18
+ runId?: string;
19
+ assistantUserName?: string;
20
+ modelId: string;
21
+ }
22
+ /** Load turn checkpoint state for a conversation/session pair. */
23
+ export declare function loadTurnCheckpoint(ctx: TurnCheckpointContext): Promise<TurnCheckpointState>;
24
+ /** Persist the latest safe in-progress boundary without scheduling continuation. */
25
+ export declare function persistRunningCheckpoint(args: {
26
+ conversationId: string;
27
+ sessionId: string;
28
+ sliceId: number;
29
+ messages: PiMessage[];
30
+ loadedSkillNames: string[];
31
+ logContext: CheckpointLogContext;
32
+ }): Promise<void>;
33
+ /** Persist a completed turn checkpoint. */
34
+ export declare function persistCompletedCheckpoint(args: {
35
+ conversationId: string;
36
+ currentDurationMs?: number;
37
+ currentUsage?: AgentTurnUsage;
38
+ sessionId: string;
39
+ sliceId: number;
40
+ allMessages: PiMessage[];
41
+ loadedSkillNames: string[];
42
+ logContext: CheckpointLogContext;
43
+ }): Promise<void>;
44
+ /**
45
+ * Persist an auth-pause checkpoint. Returns the durable checkpoint only when
46
+ * the caller can safely hand the user to an authorization resume flow.
47
+ */
48
+ export declare function persistAuthPauseCheckpoint(args: {
49
+ conversationId: string;
50
+ sessionId: string;
51
+ currentSliceId: number;
52
+ currentDurationMs?: number;
53
+ currentUsage?: AgentTurnUsage;
54
+ messages: PiMessage[];
55
+ loadedSkillNames: string[];
56
+ errorMessage: string;
57
+ logContext: CheckpointLogContext;
58
+ }): Promise<AgentTurnSessionCheckpoint | undefined>;
59
+ /**
60
+ * Persist a timeout checkpoint at the last safe boundary. Returns the durable
61
+ * checkpoint when persistence succeeds so callers can enqueue a continuation.
62
+ */
63
+ export declare function persistTimeoutCheckpoint(args: {
64
+ conversationId: string;
65
+ sessionId: string;
66
+ currentSliceId: number;
67
+ currentDurationMs?: number;
68
+ currentUsage?: AgentTurnUsage;
69
+ messages: PiMessage[];
70
+ loadedSkillNames: string[];
71
+ errorMessage: string;
72
+ logContext: CheckpointLogContext;
73
+ }): Promise<AgentTurnSessionCheckpoint | undefined>;
74
+ export {};
@@ -0,0 +1,2 @@
1
+ /** Build the user-facing response for a turn parked for continuation. */
2
+ export declare function buildTurnContinuationResponse(): string;
@@ -0,0 +1,15 @@
1
+ import type { LogContext } from "@/chat/logging";
2
+ import type { AssistantReply } from "@/chat/services/turn-result";
3
+ type LogException = (error: unknown, eventName: string, context?: LogContext, attributes?: Record<string, unknown>, body?: string) => string | undefined;
4
+ /** Require captured turn failures to carry a real Sentry event reference. */
5
+ export declare function requireTurnFailureEventId(eventId: string | undefined, eventName: string): string;
6
+ /** Keep failed-turn Sentry captures and completion spans on the same keys. */
7
+ export declare function getAgentTurnDiagnosticsAttributes(reply: AssistantReply): Record<string, unknown>;
8
+ /** Enforce one captured, event-ID-bearing failure response before delivery. */
9
+ export declare function finalizeFailedTurnReply(args: {
10
+ reply: AssistantReply;
11
+ logException: LogException;
12
+ context: LogContext;
13
+ attributes?: Record<string, unknown>;
14
+ }): AssistantReply;
15
+ export {};
@@ -0,0 +1,55 @@
1
+ import type { FileUpload } from "chat";
2
+ import type { LogContext } from "@/chat/logging";
3
+ import type { TurnThinkingSelection } from "@/chat/services/turn-thinking-level";
4
+ import type { AgentTurnUsage } from "@/chat/usage";
5
+ import { type ReplyDeliveryPlan } from "@/chat/services/reply-delivery-plan";
6
+ import type { ThreadArtifactsState } from "@/chat/state/artifacts";
7
+ export interface AgentTurnDiagnostics {
8
+ assistantMessageCount: number;
9
+ durationMs?: number;
10
+ errorMessage?: string;
11
+ providerError?: unknown;
12
+ modelId: string;
13
+ outcome: "success" | "execution_failure" | "provider_error";
14
+ thinkingLevel?: TurnThinkingSelection["thinkingLevel"];
15
+ stopReason?: string;
16
+ toolCalls: string[];
17
+ toolErrorCount: number;
18
+ toolResultCount: number;
19
+ usage?: AgentTurnUsage;
20
+ usedPrimaryText: boolean;
21
+ }
22
+ export interface AssistantReply {
23
+ text: string;
24
+ files?: FileUpload[];
25
+ artifactStatePatch?: Partial<ThreadArtifactsState>;
26
+ deliveryPlan?: ReplyDeliveryPlan;
27
+ deliveryMode?: "thread" | "channel_only";
28
+ sandboxId?: string;
29
+ sandboxDependencyProfileHash?: string;
30
+ diagnostics: AgentTurnDiagnostics;
31
+ }
32
+ export interface TurnResultInput {
33
+ newMessages: unknown[];
34
+ userInput: string;
35
+ replyFiles: FileUpload[];
36
+ artifactStatePatch: Partial<ThreadArtifactsState>;
37
+ toolCalls: string[];
38
+ sandboxId?: string;
39
+ sandboxDependencyProfileHash?: string;
40
+ durationMs?: number;
41
+ generatedFileCount: number;
42
+ shouldTrace: boolean;
43
+ spanContext: LogContext;
44
+ usage?: AgentTurnUsage;
45
+ thinkingSelection: TurnThinkingSelection;
46
+ correlation?: {
47
+ threadId?: string;
48
+ requesterId?: string;
49
+ channelId?: string;
50
+ runId?: string;
51
+ };
52
+ assistantUserName?: string;
53
+ }
54
+ /** Process raw agent messages into a structured AssistantReply. */
55
+ export declare function buildTurnResult(input: TurnResultInput): AssistantReply;
@@ -0,0 +1,49 @@
1
+ import type { ThinkingLevel as AgentThinkingLevel } from "@earendil-works/pi-agent-core";
2
+ import type { ThinkingLevel as ProviderThinkingLevel } from "@earendil-works/pi-ai";
3
+ import { z } from "zod";
4
+ declare const TURN_THINKING_LEVELS: readonly ["none", "low", "medium", "high", "xhigh"];
5
+ declare const turnExecutionProfileSchema: z.ZodObject<{
6
+ thinking_level: z.ZodEnum<{
7
+ low: "low";
8
+ medium: "medium";
9
+ high: "high";
10
+ xhigh: "xhigh";
11
+ none: "none";
12
+ }>;
13
+ confidence: z.ZodPreprocess<z.ZodNumber>;
14
+ reason: z.ZodString;
15
+ }, z.core.$strip>;
16
+ type TurnThinkingLevel = (typeof TURN_THINKING_LEVELS)[number];
17
+ export interface TurnThinkingSelection {
18
+ confidence?: number;
19
+ thinkingLevel: TurnThinkingLevel;
20
+ reason: string;
21
+ }
22
+ /** Choose the thinking level for the upcoming assistant turn. */
23
+ export declare function selectTurnThinkingLevel(args: {
24
+ completeObject: (args: {
25
+ modelId: string;
26
+ schema: typeof turnExecutionProfileSchema;
27
+ maxTokens: number;
28
+ metadata: Record<string, string>;
29
+ prompt: string;
30
+ thinkingLevel?: ProviderThinkingLevel;
31
+ system: string;
32
+ temperature: number;
33
+ }) => Promise<{
34
+ object: unknown;
35
+ }>;
36
+ conversationContext?: string;
37
+ context?: {
38
+ channelId?: string;
39
+ requesterId?: string;
40
+ runId?: string;
41
+ threadId?: string;
42
+ };
43
+ currentTurnBlocks?: string[];
44
+ fastModelId: string;
45
+ messageText: string;
46
+ }): Promise<TurnThinkingSelection>;
47
+ /** Convert a routing bucket into the Pi Agent thinking level for a main turn. */
48
+ export declare function toAgentThinkingLevel(level: TurnThinkingSelection["thinkingLevel"]): AgentThinkingLevel | "off";
49
+ export {};
@@ -0,0 +1,61 @@
1
+ import type { Attachment } from "chat";
2
+ import type { completeText } from "@/chat/pi/client";
3
+ import type { ThreadConversationState } from "@/chat/state/conversation";
4
+ export interface UserInputAttachment {
5
+ data?: Buffer;
6
+ mediaType: string;
7
+ filename?: string;
8
+ promptText?: string;
9
+ }
10
+ interface VisionThreadFile {
11
+ id?: string;
12
+ mimetype?: string;
13
+ name?: string;
14
+ size?: number;
15
+ url_private?: string;
16
+ url_private_download?: string;
17
+ }
18
+ interface VisionThreadReply {
19
+ ts?: string;
20
+ subtype?: string;
21
+ bot_id?: string;
22
+ files?: VisionThreadFile[];
23
+ }
24
+ export interface VisionContextDeps {
25
+ completeText: typeof completeText;
26
+ downloadFile: (url: string) => Promise<Buffer>;
27
+ listThreadReplies: (input: {
28
+ channelId: string;
29
+ threadTs: string;
30
+ limit?: number;
31
+ maxPages?: number;
32
+ targetMessageTs?: string[];
33
+ }) => Promise<VisionThreadReply[]>;
34
+ }
35
+ export interface VisionContextService {
36
+ hydrateConversationVisionContext: (conversation: ThreadConversationState, context: {
37
+ threadId?: string;
38
+ channelId?: string;
39
+ requesterId?: string;
40
+ runId?: string;
41
+ threadTs?: string;
42
+ }) => Promise<void>;
43
+ resolveUserAttachments: (attachments: Attachment[] | undefined, context: ResolveUserAttachmentsContext) => Promise<UserInputAttachment[]>;
44
+ }
45
+ interface ResolveUserAttachmentsContext {
46
+ threadId?: string;
47
+ requesterId?: string;
48
+ channelId?: string;
49
+ runId?: string;
50
+ conversation?: ThreadConversationState;
51
+ messageTs?: string;
52
+ }
53
+ /** Report whether the current Slack message carries an image that needs vision hydration. */
54
+ export declare function hasPotentialImageAttachment(attachments: Attachment[] | undefined): boolean;
55
+ /** Count image-bearing Slack attachments before vision filtering removes them. */
56
+ export declare function countPotentialImageAttachments(attachments: Attachment[] | undefined): number;
57
+ /** Report whether a dedicated vision model is configured for image analysis. */
58
+ export declare function isVisionEnabled(): boolean;
59
+ /** Build the vision service that owns thread image hydration and attachment preprocessing. */
60
+ export declare function createVisionContextService(deps: VisionContextDeps): VisionContextService;
61
+ export {};